diff
stringlengths
41
2.03M
msg
stringlengths
1
1.5k
repo
stringlengths
5
40
sha
stringlengths
40
40
time
stringlengths
20
20
mmm a / hphp / runtime / ext / xdebug / xdebug_server . cpp <nl> ppp b / hphp / runtime / ext / xdebug / xdebug_server . cpp <nl> <nl> <nl> # include " hphp / runtime / base / externals . h " <nl> # include " hphp / runtime / base / thread - info . h " <nl> + # include " hphp / runtime / debugger / debugger_hook_handler . h " <nl> # include " hphp / runtime / ext / string / ext_string . h " <nl> # include " hphp / util / timer . h " <nl> # include " hphp / util / network . h " <nl> mmm a / hphp / runtime / vm / debugger - hook . cpp <nl> ppp b / hphp / runtime / vm / debugger - hook . cpp <nl> <nl> # include " hphp / runtime / vm / jit / mc - generator . h " <nl> # include " hphp / runtime / debugger / break_point . h " <nl> # include " hphp / runtime / debugger / debugger . h " <nl> + # include " hphp / runtime / debugger / debugger_hook_handler . h " <nl> # include " hphp / runtime / base / unit - cache . h " <nl> # include " hphp / runtime / ext / generator / ext_generator . h " <nl> # include " hphp / runtime / vm / unit . h " <nl> using StepOutState = RequestInjectionData : : StepOutState ; <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / DebugHookHandler implementation <nl> <nl> + bool isHphpd ( const DebugHookHandler * handler ) { <nl> + return dynamic_cast < const Eval : : DebuggerHookHandler * > ( handler ) ! = nullptr ; <nl> + } <nl> + <nl> void DebugHookHandler : : detach ( ThreadInfo * ti / * = nullptr * / ) { <nl> / / legacy hphpd code expects no failure if no hook handler is attached <nl> ti = ( ti ! = nullptr ) ? ti : & TI ( ) ; <nl> mmm a / hphp / runtime / vm / debugger - hook . h <nl> ppp b / hphp / runtime / vm / debugger - hook . h <nl> <nl> <nl> namespace HPHP { <nl> <nl> + namespace Eval { struct DebuggerHookHandler ; } <nl> + <nl> struct Class ; <nl> + struct DebugHookHandler ; <nl> struct Func ; <nl> struct ObjectData ; <nl> <nl> inline bool isDebuggerAttached ( ThreadInfo * ti = nullptr ) { <nl> return ti - > m_reqInjectionData . getDebuggerAttached ( ) ; <nl> } <nl> <nl> + / * Hacky way of checking if a DebugHookHandler is a DebuggerHookHandler . * / <nl> + bool isHphpd ( const DebugHookHandler * ) ; <nl> + <nl> / / Executes the passed code only if there is a debugger attached to the current <nl> / / thread . <nl> # define DEBUGGER_ATTACHED_ONLY ( code ) do { \ <nl> struct DebugHookHandler { <nl> template < class HandlerClass > <nl> static bool attach ( ThreadInfo * ti = nullptr ) { <nl> ti = ( ti ! = nullptr ) ? ti : & TI ( ) ; <nl> + <nl> + / / The only time one hook handler can override another is when hphpd tries <nl> + / / to override xdebug . <nl> if ( isDebuggerAttached ( ti ) ) { <nl> - return false ; <nl> + using HPHPD = HPHP : : Eval : : DebuggerHookHandler ; <nl> + if ( ! std : : is_same < HandlerClass , HPHPD > : : value ) { <nl> + return false ; <nl> + } <nl> + if ( isHphpd ( ti - > m_debugHookHandler ) ) { <nl> + return false ; <nl> + } <nl> + detach ( ) ; <nl> } <nl> <nl> / / Attach to the thread <nl>
hphpd should override xdebug
facebook/hhvm
2debe138f8f40f5a7f826a8825cac0ffbe593911
2015-08-11T08:32:16Z
mmm a / . bazelrc <nl> ppp b / . bazelrc <nl> build : remote - clang - cl - - config = rbe - toolchain - clang - cl <nl> <nl> # Docker sandbox <nl> # NOTE : Update this from https : / / github . com / envoyproxy / envoy - build - tools / blob / master / toolchains / rbe_toolchains_config . bzl # L8 <nl> - build : docker - sandbox - - experimental_docker_image = envoyproxy / envoy - build - ubuntu : e7ea4e81bbd5028abb9d3a2f2c0afe063d9b62c0 <nl> + build : docker - sandbox - - experimental_docker_image = envoyproxy / envoy - build - ubuntu : 1526786b8f5cfce7a40829a0c527b5a27570889c <nl> build : docker - sandbox - - spawn_strategy = docker <nl> build : docker - sandbox - - strategy = Javac = docker <nl> build : docker - sandbox - - strategy = Closure = docker <nl> mmm a / . circleci / config . yml <nl> ppp b / . circleci / config . yml <nl> executors : <nl> description : " A regular build executor based on ubuntu image " <nl> docker : <nl> # NOTE : Update this from https : / / github . com / envoyproxy / envoy - build - tools / blob / master / toolchains / rbe_toolchains_config . bzl # L8 <nl> - - image : envoyproxy / envoy - build - ubuntu : e7ea4e81bbd5028abb9d3a2f2c0afe063d9b62c0 <nl> + - image : envoyproxy / envoy - build - ubuntu : 1526786b8f5cfce7a40829a0c527b5a27570889c <nl> resource_class : xlarge <nl> working_directory : / source <nl> <nl> mmm a / . devcontainer / Dockerfile <nl> ppp b / . devcontainer / Dockerfile <nl> <nl> - FROM gcr . io / envoy - ci / envoy - build : e7ea4e81bbd5028abb9d3a2f2c0afe063d9b62c0 <nl> + FROM gcr . io / envoy - ci / envoy - build : 1526786b8f5cfce7a40829a0c527b5a27570889c <nl> <nl> ARG USERNAME = vscode <nl> ARG USER_UID = 501 <nl> mmm a / bazel / repository_locations . bzl <nl> ppp b / bazel / repository_locations . bzl <nl> DEPENDENCY_REPOSITORIES_SPEC = dict ( <nl> project_name = " envoy - build - tools " , <nl> project_desc = " Common build tools shared by the Envoy / UDPA ecosystem " , <nl> project_url = " https : / / github . com / envoyproxy / envoy - build - tools " , <nl> - version = " 2d13ad4157997715a4939bd218a89c81c26ff28e " , <nl> - sha256 = " 0dc8ce5eb645ae069ce710c1010975456f723ffd4fc788a03dacfcd0647b05b9 " , <nl> + version = " 0ba5aa98a6e6c5efcc63f53602f69548d2417683 " , <nl> + sha256 = " dc3881d16e7b0c855a7279f5757d55e4aa55fe2befbd9e34215b971818622f9e " , <nl> strip_prefix = " envoy - build - tools - { version } " , <nl> urls = [ " https : / / github . com / envoyproxy / envoy - build - tools / archive / { version } . tar . gz " ] , <nl> - last_updated = " 2020 - 08 - 21 " , <nl> + last_updated = " 2020 - 10 - 01 " , <nl> use_category = [ " build " ] , <nl> ) , <nl> boringssl = dict ( <nl>
Bump envoy - build - tools ( )
envoyproxy/envoy
67121609934889eb4f6e9a4696c2ab16f9c3ae0d
2020-10-02T16:04:22Z
mmm a / scripts / generate_rpc_templates . py <nl> ppp b / scripts / generate_rpc_templates . py <nl> def cpre ( template ) : <nl> print " public : " <nl> print " typedef mailbox_addr_t < void ( " + csep ( " arg # _t " ) + " ) > address_t ; " <nl> print <nl> - print " mailbox_t ( mailbox_manager_t * manager , const boost : : function < void ( " + csep ( " arg # _t " ) + " ) > & fun ) : " <nl> - print " mailbox ( manager , boost : : bind ( & mailbox_t : : on_message , _1 , _2 , fun ) ) " <nl> - print " { " <nl> - print " rassert ( fun ) ; " <nl> - print " } " <nl> - print <nl> - print " ~ mailbox_t ( ) { " <nl> - print " } " <nl> + print " mailbox_t ( mailbox_manager_t * manager , const boost : : function < void ( " + csep ( " arg # _t " ) + " ) > & f , mailbox_callback_mode_t cbm = mailbox_callback_mode_coroutine ) : " <nl> + print " fun ( f ) , callback_mode ( cbm ) , mailbox ( manager , boost : : bind ( & mailbox_t : : on_message , this , _1 ) ) " <nl> + print " { } " <nl> print <nl> print " address_t get_address ( ) { " <nl> print " address_t a ; " <nl> def cpre ( template ) : <nl> print " int res = send_write_message ( stream , & msg ) ; " <nl> print " if ( res ) { throw fake_archive_exc_t ( ) ; } " <nl> print " } " <nl> - print " static void on_message ( % sread_stream_t * stream , const boost : : function < void ( ) > & done , const boost : : function < void ( " % ( " UNUSED " if nargs = = 0 else " " ) + csep ( " arg # _t " ) + " ) > & fun ) { " <nl> + print " void on_message ( % sread_stream_t * stream ) { " % ( " " if nargs > 0 else " UNUSED " ) <nl> for i in xrange ( nargs ) : <nl> print " arg % d_t arg % d ; " % ( i , i ) <nl> <nl> for i in xrange ( nargs ) : <nl> print " % sres = deserialize ( stream , & arg % d ) ; " % ( " int " if i = = 0 else " " , i ) <nl> print " if ( res ) { throw fake_archive_exc_t ( ) ; } " <nl> - print " done ( ) ; " <nl> - print " fun ( " + csep ( " arg # " ) + " ) ; " <nl> + print " if ( callback_mode = = mailbox_callback_mode_coroutine ) { " <nl> + print " coro_t : : spawn_sometime ( boost : : bind ( fun " + cpre ( " arg # " ) + " ) ) ; " <nl> + print " } else { " <nl> + print " fun ( " + csep ( " arg # " ) + " ) ; " <nl> + print " } " <nl> print " } " <nl> print <nl> + print " boost : : function < void ( " + csep ( " arg # _t " ) + " ) > fun ; " <nl> + print " mailbox_callback_mode_t callback_mode ; " <nl> print " raw_mailbox_t mailbox ; " <nl> print " } ; " <nl> print <nl> def cpre ( template ) : <nl> print " # include \ " rpc / mailbox / mailbox . hpp \ " " <nl> print <nl> <nl> + print " / * If you pass ` mailbox_callback_mode_coroutine ` to the ` mailbox_t ` " <nl> + print " constructor , it will spawn the callback in a new coroutine . If you " <nl> + print " ` mailbox_callback_mode_inline ` , it will call the callback inline " <nl> + print " and the callback must not block . The former is the default for " <nl> + print " historical reasons , but the latter is better . Eventually the former " <nl> + print " will go away . * / " <nl> + print " enum mailbox_callback_mode_t { " <nl> + print " mailbox_callback_mode_coroutine , " <nl> + print " mailbox_callback_mode_inline " <nl> + print " } ; " <nl> + print <nl> + <nl> print " template < class invalid_proto_t > class mailbox_t { " <nl> print " / * If someone tries to instantiate ` mailbox_t ` " <nl> print " incorrectly , this should cause an error . * / " <nl> mmm a / src / rpc / mailbox / mailbox . cc <nl> ppp b / src / rpc / mailbox / mailbox . cc <nl> std : : string raw_mailbox_t : : address_t : : human_readable ( ) const { <nl> return strprintf ( " % s : % d : % d " , boost : : uuids : : to_string ( peer . get_uuid ( ) ) . c_str ( ) , thread , mailbox_id ) ; <nl> } <nl> <nl> - raw_mailbox_t : : raw_mailbox_t ( mailbox_manager_t * m , const boost : : function < void ( read_stream_t * , const boost : : function < void ( ) > & ) > & fun ) : <nl> + raw_mailbox_t : : raw_mailbox_t ( mailbox_manager_t * m , const boost : : function < void ( read_stream_t * ) > & fun ) : <nl> manager ( m ) , <nl> mailbox_id ( manager - > mailbox_tables . get ( ) - > next_mailbox_id + + ) , <nl> callback ( fun ) <nl> void mailbox_manager_t : : on_message ( UNUSED peer_id_t source_peer , read_stream_t * <nl> <nl> raw_mailbox_t * mbox = mailbox_tables . get ( ) - > find_mailbox ( dest_mailbox_id ) ; <nl> if ( mbox ) { <nl> - cond_t done_cond ; <nl> - boost : : function < void ( ) > done_fun = boost : : bind ( & cond_t : : pulse , & done_cond ) ; <nl> - coro_t : : spawn_sometime ( boost : : bind ( mbox - > callback , stream , done_fun ) ) ; <nl> - done_cond . wait_lazily_unordered ( ) ; <nl> + mbox - > callback ( stream ) ; <nl> } else { <nl> / * Print a warning message * / <nl> raw_mailbox_t : : address_t dest_address ; <nl> mmm a / src / rpc / mailbox / mailbox . hpp <nl> ppp b / src / rpc / mailbox / mailbox . hpp <nl> struct raw_mailbox_t : <nl> typedef int id_t ; <nl> id_t mailbox_id ; <nl> <nl> - boost : : function < void ( read_stream_t * , const boost : : function < void ( ) > & ) > callback ; <nl> + boost : : function < void ( read_stream_t * ) > callback ; <nl> <nl> DISABLE_COPYING ( raw_mailbox_t ) ; <nl> <nl> struct raw_mailbox_t : <nl> id_t mailbox_id ; <nl> } ; <nl> <nl> - raw_mailbox_t ( mailbox_manager_t * , const boost : : function < void ( read_stream_t * , const boost : : function < void ( ) > & ) > & ) ; <nl> + raw_mailbox_t ( mailbox_manager_t * , const boost : : function < void ( read_stream_t * ) > & ) ; <nl> ~ raw_mailbox_t ( ) ; <nl> <nl> address_t get_address ( ) ; <nl> mmm a / src / rpc / mailbox / typed . hpp <nl> ppp b / src / rpc / mailbox / typed . hpp <nl> Please modify ' . . / scripts / generate_rpc_templates . py ' instead of modifying this f <nl> # include " rpc / serialize_macros . hpp " <nl> # include " rpc / mailbox / mailbox . hpp " <nl> <nl> + / * If you pass ` mailbox_callback_mode_coroutine ` to the ` mailbox_t ` <nl> + constructor , it will spawn the callback in a new coroutine . If you <nl> + ` mailbox_callback_mode_inline ` , it will call the callback inline <nl> + and the callback must not block . The former is the default for <nl> + historical reasons , but the latter is better . Eventually the former <nl> + will go away . * / <nl> + enum mailbox_callback_mode_t { <nl> + mailbox_callback_mode_coroutine , <nl> + mailbox_callback_mode_inline <nl> + } ; <nl> + <nl> template < class invalid_proto_t > class mailbox_t { <nl> - / * If someone tries to instantiate ` mailbox_t ` <nl> + / * If someone tries to instantiate ` mailbox_t ` <nl> incorrectly , this should cause an error . * / <nl> typename invalid_proto_t : : you_are_using_mailbox_t_incorrectly foo ; <nl> } ; <nl> class mailbox_t < void ( ) > { <nl> public : <nl> typedef mailbox_addr_t < void ( ) > address_t ; <nl> <nl> - mailbox_t ( mailbox_manager_t * manager , const boost : : function < void ( ) > & fun ) : <nl> - mailbox ( manager , boost : : bind ( & mailbox_t : : on_message , _1 , _2 , fun ) ) <nl> - { <nl> - rassert ( fun ) ; <nl> - } <nl> - <nl> - ~ mailbox_t ( ) { <nl> - } <nl> + mailbox_t ( mailbox_manager_t * manager , const boost : : function < void ( ) > & f , mailbox_callback_mode_t cbm = mailbox_callback_mode_coroutine ) : <nl> + fun ( f ) , callback_mode ( cbm ) , mailbox ( manager , boost : : bind ( & mailbox_t : : on_message , this , _1 ) ) <nl> + { } <nl> <nl> address_t get_address ( ) { <nl> address_t a ; <nl> class mailbox_t < void ( ) > { <nl> int res = send_write_message ( stream , & msg ) ; <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> } <nl> - static void on_message ( UNUSED read_stream_t * stream , const boost : : function < void ( ) > & done , const boost : : function < void ( ) > & fun ) { <nl> - done ( ) ; <nl> - fun ( ) ; <nl> + void on_message ( UNUSED read_stream_t * stream ) { <nl> + if ( callback_mode = = mailbox_callback_mode_coroutine ) { <nl> + coro_t : : spawn_sometime ( boost : : bind ( fun ) ) ; <nl> + } else { <nl> + fun ( ) ; <nl> + } <nl> } <nl> <nl> + boost : : function < void ( ) > fun ; <nl> + mailbox_callback_mode_t callback_mode ; <nl> raw_mailbox_t mailbox ; <nl> } ; <nl> <nl> class mailbox_t < void ( arg0_t ) > { <nl> public : <nl> typedef mailbox_addr_t < void ( arg0_t ) > address_t ; <nl> <nl> - mailbox_t ( mailbox_manager_t * manager , const boost : : function < void ( arg0_t ) > & fun ) : <nl> - mailbox ( manager , boost : : bind ( & mailbox_t : : on_message , _1 , _2 , fun ) ) <nl> - { <nl> - rassert ( fun ) ; <nl> - } <nl> - <nl> - ~ mailbox_t ( ) { <nl> - } <nl> + mailbox_t ( mailbox_manager_t * manager , const boost : : function < void ( arg0_t ) > & f , mailbox_callback_mode_t cbm = mailbox_callback_mode_coroutine ) : <nl> + fun ( f ) , callback_mode ( cbm ) , mailbox ( manager , boost : : bind ( & mailbox_t : : on_message , this , _1 ) ) <nl> + { } <nl> <nl> address_t get_address ( ) { <nl> address_t a ; <nl> class mailbox_t < void ( arg0_t ) > { <nl> int res = send_write_message ( stream , & msg ) ; <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> } <nl> - static void on_message ( read_stream_t * stream , const boost : : function < void ( ) > & done , const boost : : function < void ( arg0_t ) > & fun ) { <nl> + void on_message ( read_stream_t * stream ) { <nl> arg0_t arg0 ; <nl> int res = deserialize ( stream , & arg0 ) ; <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> - done ( ) ; <nl> - fun ( arg0 ) ; <nl> + if ( callback_mode = = mailbox_callback_mode_coroutine ) { <nl> + coro_t : : spawn_sometime ( boost : : bind ( fun , arg0 ) ) ; <nl> + } else { <nl> + fun ( arg0 ) ; <nl> + } <nl> } <nl> <nl> + boost : : function < void ( arg0_t ) > fun ; <nl> + mailbox_callback_mode_t callback_mode ; <nl> raw_mailbox_t mailbox ; <nl> } ; <nl> <nl> class mailbox_t < void ( arg0_t , arg1_t ) > { <nl> public : <nl> typedef mailbox_addr_t < void ( arg0_t , arg1_t ) > address_t ; <nl> <nl> - mailbox_t ( mailbox_manager_t * manager , const boost : : function < void ( arg0_t , arg1_t ) > & fun ) : <nl> - mailbox ( manager , boost : : bind ( & mailbox_t : : on_message , _1 , _2 , fun ) ) <nl> - { <nl> - rassert ( fun ) ; <nl> - } <nl> - <nl> - ~ mailbox_t ( ) { <nl> - } <nl> + mailbox_t ( mailbox_manager_t * manager , const boost : : function < void ( arg0_t , arg1_t ) > & f , mailbox_callback_mode_t cbm = mailbox_callback_mode_coroutine ) : <nl> + fun ( f ) , callback_mode ( cbm ) , mailbox ( manager , boost : : bind ( & mailbox_t : : on_message , this , _1 ) ) <nl> + { } <nl> <nl> address_t get_address ( ) { <nl> address_t a ; <nl> class mailbox_t < void ( arg0_t , arg1_t ) > { <nl> int res = send_write_message ( stream , & msg ) ; <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> } <nl> - static void on_message ( read_stream_t * stream , const boost : : function < void ( ) > & done , const boost : : function < void ( arg0_t , arg1_t ) > & fun ) { <nl> + void on_message ( read_stream_t * stream ) { <nl> arg0_t arg0 ; <nl> arg1_t arg1 ; <nl> int res = deserialize ( stream , & arg0 ) ; <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> res = deserialize ( stream , & arg1 ) ; <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> - done ( ) ; <nl> - fun ( arg0 , arg1 ) ; <nl> + if ( callback_mode = = mailbox_callback_mode_coroutine ) { <nl> + coro_t : : spawn_sometime ( boost : : bind ( fun , arg0 , arg1 ) ) ; <nl> + } else { <nl> + fun ( arg0 , arg1 ) ; <nl> + } <nl> } <nl> <nl> + boost : : function < void ( arg0_t , arg1_t ) > fun ; <nl> + mailbox_callback_mode_t callback_mode ; <nl> raw_mailbox_t mailbox ; <nl> } ; <nl> <nl> class mailbox_t < void ( arg0_t , arg1_t , arg2_t ) > { <nl> public : <nl> typedef mailbox_addr_t < void ( arg0_t , arg1_t , arg2_t ) > address_t ; <nl> <nl> - mailbox_t ( mailbox_manager_t * manager , const boost : : function < void ( arg0_t , arg1_t , arg2_t ) > & fun ) : <nl> - mailbox ( manager , boost : : bind ( & mailbox_t : : on_message , _1 , _2 , fun ) ) <nl> - { <nl> - rassert ( fun ) ; <nl> - } <nl> - <nl> - ~ mailbox_t ( ) { <nl> - } <nl> + mailbox_t ( mailbox_manager_t * manager , const boost : : function < void ( arg0_t , arg1_t , arg2_t ) > & f , mailbox_callback_mode_t cbm = mailbox_callback_mode_coroutine ) : <nl> + fun ( f ) , callback_mode ( cbm ) , mailbox ( manager , boost : : bind ( & mailbox_t : : on_message , this , _1 ) ) <nl> + { } <nl> <nl> address_t get_address ( ) { <nl> address_t a ; <nl> class mailbox_t < void ( arg0_t , arg1_t , arg2_t ) > { <nl> int res = send_write_message ( stream , & msg ) ; <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> } <nl> - static void on_message ( read_stream_t * stream , const boost : : function < void ( ) > & done , const boost : : function < void ( arg0_t , arg1_t , arg2_t ) > & fun ) { <nl> + void on_message ( read_stream_t * stream ) { <nl> arg0_t arg0 ; <nl> arg1_t arg1 ; <nl> arg2_t arg2 ; <nl> class mailbox_t < void ( arg0_t , arg1_t , arg2_t ) > { <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> res = deserialize ( stream , & arg2 ) ; <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> - done ( ) ; <nl> - fun ( arg0 , arg1 , arg2 ) ; <nl> + if ( callback_mode = = mailbox_callback_mode_coroutine ) { <nl> + coro_t : : spawn_sometime ( boost : : bind ( fun , arg0 , arg1 , arg2 ) ) ; <nl> + } else { <nl> + fun ( arg0 , arg1 , arg2 ) ; <nl> + } <nl> } <nl> <nl> + boost : : function < void ( arg0_t , arg1_t , arg2_t ) > fun ; <nl> + mailbox_callback_mode_t callback_mode ; <nl> raw_mailbox_t mailbox ; <nl> } ; <nl> <nl> class mailbox_t < void ( arg0_t , arg1_t , arg2_t , arg3_t ) > { <nl> public : <nl> typedef mailbox_addr_t < void ( arg0_t , arg1_t , arg2_t , arg3_t ) > address_t ; <nl> <nl> - mailbox_t ( mailbox_manager_t * manager , const boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t ) > & fun ) : <nl> - mailbox ( manager , boost : : bind ( & mailbox_t : : on_message , _1 , _2 , fun ) ) <nl> - { <nl> - rassert ( fun ) ; <nl> - } <nl> - <nl> - ~ mailbox_t ( ) { <nl> - } <nl> + mailbox_t ( mailbox_manager_t * manager , const boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t ) > & f , mailbox_callback_mode_t cbm = mailbox_callback_mode_coroutine ) : <nl> + fun ( f ) , callback_mode ( cbm ) , mailbox ( manager , boost : : bind ( & mailbox_t : : on_message , this , _1 ) ) <nl> + { } <nl> <nl> address_t get_address ( ) { <nl> address_t a ; <nl> class mailbox_t < void ( arg0_t , arg1_t , arg2_t , arg3_t ) > { <nl> int res = send_write_message ( stream , & msg ) ; <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> } <nl> - static void on_message ( read_stream_t * stream , const boost : : function < void ( ) > & done , const boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t ) > & fun ) { <nl> + void on_message ( read_stream_t * stream ) { <nl> arg0_t arg0 ; <nl> arg1_t arg1 ; <nl> arg2_t arg2 ; <nl> class mailbox_t < void ( arg0_t , arg1_t , arg2_t , arg3_t ) > { <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> res = deserialize ( stream , & arg3 ) ; <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> - done ( ) ; <nl> - fun ( arg0 , arg1 , arg2 , arg3 ) ; <nl> + if ( callback_mode = = mailbox_callback_mode_coroutine ) { <nl> + coro_t : : spawn_sometime ( boost : : bind ( fun , arg0 , arg1 , arg2 , arg3 ) ) ; <nl> + } else { <nl> + fun ( arg0 , arg1 , arg2 , arg3 ) ; <nl> + } <nl> } <nl> <nl> + boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t ) > fun ; <nl> + mailbox_callback_mode_t callback_mode ; <nl> raw_mailbox_t mailbox ; <nl> } ; <nl> <nl> class mailbox_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t ) > { <nl> public : <nl> typedef mailbox_addr_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t ) > address_t ; <nl> <nl> - mailbox_t ( mailbox_manager_t * manager , const boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t ) > & fun ) : <nl> - mailbox ( manager , boost : : bind ( & mailbox_t : : on_message , _1 , _2 , fun ) ) <nl> - { <nl> - rassert ( fun ) ; <nl> - } <nl> - <nl> - ~ mailbox_t ( ) { <nl> - } <nl> + mailbox_t ( mailbox_manager_t * manager , const boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t ) > & f , mailbox_callback_mode_t cbm = mailbox_callback_mode_coroutine ) : <nl> + fun ( f ) , callback_mode ( cbm ) , mailbox ( manager , boost : : bind ( & mailbox_t : : on_message , this , _1 ) ) <nl> + { } <nl> <nl> address_t get_address ( ) { <nl> address_t a ; <nl> class mailbox_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t ) > { <nl> int res = send_write_message ( stream , & msg ) ; <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> } <nl> - static void on_message ( read_stream_t * stream , const boost : : function < void ( ) > & done , const boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t ) > & fun ) { <nl> + void on_message ( read_stream_t * stream ) { <nl> arg0_t arg0 ; <nl> arg1_t arg1 ; <nl> arg2_t arg2 ; <nl> class mailbox_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t ) > { <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> res = deserialize ( stream , & arg4 ) ; <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> - done ( ) ; <nl> - fun ( arg0 , arg1 , arg2 , arg3 , arg4 ) ; <nl> + if ( callback_mode = = mailbox_callback_mode_coroutine ) { <nl> + coro_t : : spawn_sometime ( boost : : bind ( fun , arg0 , arg1 , arg2 , arg3 , arg4 ) ) ; <nl> + } else { <nl> + fun ( arg0 , arg1 , arg2 , arg3 , arg4 ) ; <nl> + } <nl> } <nl> <nl> + boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t ) > fun ; <nl> + mailbox_callback_mode_t callback_mode ; <nl> raw_mailbox_t mailbox ; <nl> } ; <nl> <nl> class mailbox_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t ) > { <nl> public : <nl> typedef mailbox_addr_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t ) > address_t ; <nl> <nl> - mailbox_t ( mailbox_manager_t * manager , const boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t ) > & fun ) : <nl> - mailbox ( manager , boost : : bind ( & mailbox_t : : on_message , _1 , _2 , fun ) ) <nl> - { <nl> - rassert ( fun ) ; <nl> - } <nl> - <nl> - ~ mailbox_t ( ) { <nl> - } <nl> + mailbox_t ( mailbox_manager_t * manager , const boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t ) > & f , mailbox_callback_mode_t cbm = mailbox_callback_mode_coroutine ) : <nl> + fun ( f ) , callback_mode ( cbm ) , mailbox ( manager , boost : : bind ( & mailbox_t : : on_message , this , _1 ) ) <nl> + { } <nl> <nl> address_t get_address ( ) { <nl> address_t a ; <nl> class mailbox_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t ) > { <nl> int res = send_write_message ( stream , & msg ) ; <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> } <nl> - static void on_message ( read_stream_t * stream , const boost : : function < void ( ) > & done , const boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t ) > & fun ) { <nl> + void on_message ( read_stream_t * stream ) { <nl> arg0_t arg0 ; <nl> arg1_t arg1 ; <nl> arg2_t arg2 ; <nl> class mailbox_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t ) > { <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> res = deserialize ( stream , & arg5 ) ; <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> - done ( ) ; <nl> - fun ( arg0 , arg1 , arg2 , arg3 , arg4 , arg5 ) ; <nl> + if ( callback_mode = = mailbox_callback_mode_coroutine ) { <nl> + coro_t : : spawn_sometime ( boost : : bind ( fun , arg0 , arg1 , arg2 , arg3 , arg4 , arg5 ) ) ; <nl> + } else { <nl> + fun ( arg0 , arg1 , arg2 , arg3 , arg4 , arg5 ) ; <nl> + } <nl> } <nl> <nl> + boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t ) > fun ; <nl> + mailbox_callback_mode_t callback_mode ; <nl> raw_mailbox_t mailbox ; <nl> } ; <nl> <nl> class mailbox_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t ) > <nl> public : <nl> typedef mailbox_addr_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t ) > address_t ; <nl> <nl> - mailbox_t ( mailbox_manager_t * manager , const boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t ) > & fun ) : <nl> - mailbox ( manager , boost : : bind ( & mailbox_t : : on_message , _1 , _2 , fun ) ) <nl> - { <nl> - rassert ( fun ) ; <nl> - } <nl> - <nl> - ~ mailbox_t ( ) { <nl> - } <nl> + mailbox_t ( mailbox_manager_t * manager , const boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t ) > & f , mailbox_callback_mode_t cbm = mailbox_callback_mode_coroutine ) : <nl> + fun ( f ) , callback_mode ( cbm ) , mailbox ( manager , boost : : bind ( & mailbox_t : : on_message , this , _1 ) ) <nl> + { } <nl> <nl> address_t get_address ( ) { <nl> address_t a ; <nl> class mailbox_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t ) > <nl> int res = send_write_message ( stream , & msg ) ; <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> } <nl> - static void on_message ( read_stream_t * stream , const boost : : function < void ( ) > & done , const boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t ) > & fun ) { <nl> + void on_message ( read_stream_t * stream ) { <nl> arg0_t arg0 ; <nl> arg1_t arg1 ; <nl> arg2_t arg2 ; <nl> class mailbox_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t ) > <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> res = deserialize ( stream , & arg6 ) ; <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> - done ( ) ; <nl> - fun ( arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 ) ; <nl> + if ( callback_mode = = mailbox_callback_mode_coroutine ) { <nl> + coro_t : : spawn_sometime ( boost : : bind ( fun , arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 ) ) ; <nl> + } else { <nl> + fun ( arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 ) ; <nl> + } <nl> } <nl> <nl> + boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t ) > fun ; <nl> + mailbox_callback_mode_t callback_mode ; <nl> raw_mailbox_t mailbox ; <nl> } ; <nl> <nl> class mailbox_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , ar <nl> public : <nl> typedef mailbox_addr_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , arg7_t ) > address_t ; <nl> <nl> - mailbox_t ( mailbox_manager_t * manager , const boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , arg7_t ) > & fun ) : <nl> - mailbox ( manager , boost : : bind ( & mailbox_t : : on_message , _1 , _2 , fun ) ) <nl> - { <nl> - rassert ( fun ) ; <nl> - } <nl> - <nl> - ~ mailbox_t ( ) { <nl> - } <nl> + mailbox_t ( mailbox_manager_t * manager , const boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , arg7_t ) > & f , mailbox_callback_mode_t cbm = mailbox_callback_mode_coroutine ) : <nl> + fun ( f ) , callback_mode ( cbm ) , mailbox ( manager , boost : : bind ( & mailbox_t : : on_message , this , _1 ) ) <nl> + { } <nl> <nl> address_t get_address ( ) { <nl> address_t a ; <nl> class mailbox_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , ar <nl> int res = send_write_message ( stream , & msg ) ; <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> } <nl> - static void on_message ( read_stream_t * stream , const boost : : function < void ( ) > & done , const boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , arg7_t ) > & fun ) { <nl> + void on_message ( read_stream_t * stream ) { <nl> arg0_t arg0 ; <nl> arg1_t arg1 ; <nl> arg2_t arg2 ; <nl> class mailbox_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , ar <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> res = deserialize ( stream , & arg7 ) ; <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> - done ( ) ; <nl> - fun ( arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 ) ; <nl> + if ( callback_mode = = mailbox_callback_mode_coroutine ) { <nl> + coro_t : : spawn_sometime ( boost : : bind ( fun , arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 ) ) ; <nl> + } else { <nl> + fun ( arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 ) ; <nl> + } <nl> } <nl> <nl> + boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , arg7_t ) > fun ; <nl> + mailbox_callback_mode_t callback_mode ; <nl> raw_mailbox_t mailbox ; <nl> } ; <nl> <nl> class mailbox_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , ar <nl> public : <nl> typedef mailbox_addr_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , arg7_t , arg8_t ) > address_t ; <nl> <nl> - mailbox_t ( mailbox_manager_t * manager , const boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , arg7_t , arg8_t ) > & fun ) : <nl> - mailbox ( manager , boost : : bind ( & mailbox_t : : on_message , _1 , _2 , fun ) ) <nl> - { <nl> - rassert ( fun ) ; <nl> - } <nl> - <nl> - ~ mailbox_t ( ) { <nl> - } <nl> + mailbox_t ( mailbox_manager_t * manager , const boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , arg7_t , arg8_t ) > & f , mailbox_callback_mode_t cbm = mailbox_callback_mode_coroutine ) : <nl> + fun ( f ) , callback_mode ( cbm ) , mailbox ( manager , boost : : bind ( & mailbox_t : : on_message , this , _1 ) ) <nl> + { } <nl> <nl> address_t get_address ( ) { <nl> address_t a ; <nl> class mailbox_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , ar <nl> int res = send_write_message ( stream , & msg ) ; <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> } <nl> - static void on_message ( read_stream_t * stream , const boost : : function < void ( ) > & done , const boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , arg7_t , arg8_t ) > & fun ) { <nl> + void on_message ( read_stream_t * stream ) { <nl> arg0_t arg0 ; <nl> arg1_t arg1 ; <nl> arg2_t arg2 ; <nl> class mailbox_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , ar <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> res = deserialize ( stream , & arg8 ) ; <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> - done ( ) ; <nl> - fun ( arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 , arg8 ) ; <nl> + if ( callback_mode = = mailbox_callback_mode_coroutine ) { <nl> + coro_t : : spawn_sometime ( boost : : bind ( fun , arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 , arg8 ) ) ; <nl> + } else { <nl> + fun ( arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 , arg8 ) ; <nl> + } <nl> } <nl> <nl> + boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , arg7_t , arg8_t ) > fun ; <nl> + mailbox_callback_mode_t callback_mode ; <nl> raw_mailbox_t mailbox ; <nl> } ; <nl> <nl> class mailbox_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , ar <nl> public : <nl> typedef mailbox_addr_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , arg7_t , arg8_t , arg9_t ) > address_t ; <nl> <nl> - mailbox_t ( mailbox_manager_t * manager , const boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , arg7_t , arg8_t , arg9_t ) > & fun ) : <nl> - mailbox ( manager , boost : : bind ( & mailbox_t : : on_message , _1 , _2 , fun ) ) <nl> - { <nl> - rassert ( fun ) ; <nl> - } <nl> - <nl> - ~ mailbox_t ( ) { <nl> - } <nl> + mailbox_t ( mailbox_manager_t * manager , const boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , arg7_t , arg8_t , arg9_t ) > & f , mailbox_callback_mode_t cbm = mailbox_callback_mode_coroutine ) : <nl> + fun ( f ) , callback_mode ( cbm ) , mailbox ( manager , boost : : bind ( & mailbox_t : : on_message , this , _1 ) ) <nl> + { } <nl> <nl> address_t get_address ( ) { <nl> address_t a ; <nl> class mailbox_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , ar <nl> int res = send_write_message ( stream , & msg ) ; <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> } <nl> - static void on_message ( read_stream_t * stream , const boost : : function < void ( ) > & done , const boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , arg7_t , arg8_t , arg9_t ) > & fun ) { <nl> + void on_message ( read_stream_t * stream ) { <nl> arg0_t arg0 ; <nl> arg1_t arg1 ; <nl> arg2_t arg2 ; <nl> class mailbox_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , ar <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> res = deserialize ( stream , & arg9 ) ; <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> - done ( ) ; <nl> - fun ( arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 , arg8 , arg9 ) ; <nl> + if ( callback_mode = = mailbox_callback_mode_coroutine ) { <nl> + coro_t : : spawn_sometime ( boost : : bind ( fun , arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 , arg8 , arg9 ) ) ; <nl> + } else { <nl> + fun ( arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 , arg8 , arg9 ) ; <nl> + } <nl> } <nl> <nl> + boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , arg7_t , arg8_t , arg9_t ) > fun ; <nl> + mailbox_callback_mode_t callback_mode ; <nl> raw_mailbox_t mailbox ; <nl> } ; <nl> <nl> class mailbox_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , ar <nl> public : <nl> typedef mailbox_addr_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , arg7_t , arg8_t , arg9_t , arg10_t ) > address_t ; <nl> <nl> - mailbox_t ( mailbox_manager_t * manager , const boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , arg7_t , arg8_t , arg9_t , arg10_t ) > & fun ) : <nl> - mailbox ( manager , boost : : bind ( & mailbox_t : : on_message , _1 , _2 , fun ) ) <nl> - { <nl> - rassert ( fun ) ; <nl> - } <nl> - <nl> - ~ mailbox_t ( ) { <nl> - } <nl> + mailbox_t ( mailbox_manager_t * manager , const boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , arg7_t , arg8_t , arg9_t , arg10_t ) > & f , mailbox_callback_mode_t cbm = mailbox_callback_mode_coroutine ) : <nl> + fun ( f ) , callback_mode ( cbm ) , mailbox ( manager , boost : : bind ( & mailbox_t : : on_message , this , _1 ) ) <nl> + { } <nl> <nl> address_t get_address ( ) { <nl> address_t a ; <nl> class mailbox_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , ar <nl> int res = send_write_message ( stream , & msg ) ; <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> } <nl> - static void on_message ( read_stream_t * stream , const boost : : function < void ( ) > & done , const boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , arg7_t , arg8_t , arg9_t , arg10_t ) > & fun ) { <nl> + void on_message ( read_stream_t * stream ) { <nl> arg0_t arg0 ; <nl> arg1_t arg1 ; <nl> arg2_t arg2 ; <nl> class mailbox_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , ar <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> res = deserialize ( stream , & arg10 ) ; <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> - done ( ) ; <nl> - fun ( arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 , arg8 , arg9 , arg10 ) ; <nl> + if ( callback_mode = = mailbox_callback_mode_coroutine ) { <nl> + coro_t : : spawn_sometime ( boost : : bind ( fun , arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 , arg8 , arg9 , arg10 ) ) ; <nl> + } else { <nl> + fun ( arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 , arg8 , arg9 , arg10 ) ; <nl> + } <nl> } <nl> <nl> + boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , arg7_t , arg8_t , arg9_t , arg10_t ) > fun ; <nl> + mailbox_callback_mode_t callback_mode ; <nl> raw_mailbox_t mailbox ; <nl> } ; <nl> <nl> class mailbox_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , ar <nl> public : <nl> typedef mailbox_addr_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , arg7_t , arg8_t , arg9_t , arg10_t , arg11_t ) > address_t ; <nl> <nl> - mailbox_t ( mailbox_manager_t * manager , const boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , arg7_t , arg8_t , arg9_t , arg10_t , arg11_t ) > & fun ) : <nl> - mailbox ( manager , boost : : bind ( & mailbox_t : : on_message , _1 , _2 , fun ) ) <nl> - { <nl> - rassert ( fun ) ; <nl> - } <nl> - <nl> - ~ mailbox_t ( ) { <nl> - } <nl> + mailbox_t ( mailbox_manager_t * manager , const boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , arg7_t , arg8_t , arg9_t , arg10_t , arg11_t ) > & f , mailbox_callback_mode_t cbm = mailbox_callback_mode_coroutine ) : <nl> + fun ( f ) , callback_mode ( cbm ) , mailbox ( manager , boost : : bind ( & mailbox_t : : on_message , this , _1 ) ) <nl> + { } <nl> <nl> address_t get_address ( ) { <nl> address_t a ; <nl> class mailbox_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , ar <nl> int res = send_write_message ( stream , & msg ) ; <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> } <nl> - static void on_message ( read_stream_t * stream , const boost : : function < void ( ) > & done , const boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , arg7_t , arg8_t , arg9_t , arg10_t , arg11_t ) > & fun ) { <nl> + void on_message ( read_stream_t * stream ) { <nl> arg0_t arg0 ; <nl> arg1_t arg1 ; <nl> arg2_t arg2 ; <nl> class mailbox_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , ar <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> res = deserialize ( stream , & arg11 ) ; <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> - done ( ) ; <nl> - fun ( arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 , arg8 , arg9 , arg10 , arg11 ) ; <nl> + if ( callback_mode = = mailbox_callback_mode_coroutine ) { <nl> + coro_t : : spawn_sometime ( boost : : bind ( fun , arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 , arg8 , arg9 , arg10 , arg11 ) ) ; <nl> + } else { <nl> + fun ( arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 , arg8 , arg9 , arg10 , arg11 ) ; <nl> + } <nl> } <nl> <nl> + boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , arg7_t , arg8_t , arg9_t , arg10_t , arg11_t ) > fun ; <nl> + mailbox_callback_mode_t callback_mode ; <nl> raw_mailbox_t mailbox ; <nl> } ; <nl> <nl> class mailbox_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , ar <nl> public : <nl> typedef mailbox_addr_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , arg7_t , arg8_t , arg9_t , arg10_t , arg11_t , arg12_t ) > address_t ; <nl> <nl> - mailbox_t ( mailbox_manager_t * manager , const boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , arg7_t , arg8_t , arg9_t , arg10_t , arg11_t , arg12_t ) > & fun ) : <nl> - mailbox ( manager , boost : : bind ( & mailbox_t : : on_message , _1 , _2 , fun ) ) <nl> - { <nl> - rassert ( fun ) ; <nl> - } <nl> - <nl> - ~ mailbox_t ( ) { <nl> - } <nl> + mailbox_t ( mailbox_manager_t * manager , const boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , arg7_t , arg8_t , arg9_t , arg10_t , arg11_t , arg12_t ) > & f , mailbox_callback_mode_t cbm = mailbox_callback_mode_coroutine ) : <nl> + fun ( f ) , callback_mode ( cbm ) , mailbox ( manager , boost : : bind ( & mailbox_t : : on_message , this , _1 ) ) <nl> + { } <nl> <nl> address_t get_address ( ) { <nl> address_t a ; <nl> class mailbox_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , ar <nl> int res = send_write_message ( stream , & msg ) ; <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> } <nl> - static void on_message ( read_stream_t * stream , const boost : : function < void ( ) > & done , const boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , arg7_t , arg8_t , arg9_t , arg10_t , arg11_t , arg12_t ) > & fun ) { <nl> + void on_message ( read_stream_t * stream ) { <nl> arg0_t arg0 ; <nl> arg1_t arg1 ; <nl> arg2_t arg2 ; <nl> class mailbox_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , ar <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> res = deserialize ( stream , & arg12 ) ; <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> - done ( ) ; <nl> - fun ( arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 , arg8 , arg9 , arg10 , arg11 , arg12 ) ; <nl> + if ( callback_mode = = mailbox_callback_mode_coroutine ) { <nl> + coro_t : : spawn_sometime ( boost : : bind ( fun , arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 , arg8 , arg9 , arg10 , arg11 , arg12 ) ) ; <nl> + } else { <nl> + fun ( arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 , arg8 , arg9 , arg10 , arg11 , arg12 ) ; <nl> + } <nl> } <nl> <nl> + boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , arg7_t , arg8_t , arg9_t , arg10_t , arg11_t , arg12_t ) > fun ; <nl> + mailbox_callback_mode_t callback_mode ; <nl> raw_mailbox_t mailbox ; <nl> } ; <nl> <nl> class mailbox_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , ar <nl> public : <nl> typedef mailbox_addr_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , arg7_t , arg8_t , arg9_t , arg10_t , arg11_t , arg12_t , arg13_t ) > address_t ; <nl> <nl> - mailbox_t ( mailbox_manager_t * manager , const boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , arg7_t , arg8_t , arg9_t , arg10_t , arg11_t , arg12_t , arg13_t ) > & fun ) : <nl> - mailbox ( manager , boost : : bind ( & mailbox_t : : on_message , _1 , _2 , fun ) ) <nl> - { <nl> - rassert ( fun ) ; <nl> - } <nl> - <nl> - ~ mailbox_t ( ) { <nl> - } <nl> + mailbox_t ( mailbox_manager_t * manager , const boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , arg7_t , arg8_t , arg9_t , arg10_t , arg11_t , arg12_t , arg13_t ) > & f , mailbox_callback_mode_t cbm = mailbox_callback_mode_coroutine ) : <nl> + fun ( f ) , callback_mode ( cbm ) , mailbox ( manager , boost : : bind ( & mailbox_t : : on_message , this , _1 ) ) <nl> + { } <nl> <nl> address_t get_address ( ) { <nl> address_t a ; <nl> class mailbox_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , ar <nl> int res = send_write_message ( stream , & msg ) ; <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> } <nl> - static void on_message ( read_stream_t * stream , const boost : : function < void ( ) > & done , const boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , arg7_t , arg8_t , arg9_t , arg10_t , arg11_t , arg12_t , arg13_t ) > & fun ) { <nl> + void on_message ( read_stream_t * stream ) { <nl> arg0_t arg0 ; <nl> arg1_t arg1 ; <nl> arg2_t arg2 ; <nl> class mailbox_t < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , ar <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> res = deserialize ( stream , & arg13 ) ; <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> - done ( ) ; <nl> - fun ( arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 , arg8 , arg9 , arg10 , arg11 , arg12 , arg13 ) ; <nl> + if ( callback_mode = = mailbox_callback_mode_coroutine ) { <nl> + coro_t : : spawn_sometime ( boost : : bind ( fun , arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 , arg8 , arg9 , arg10 , arg11 , arg12 , arg13 ) ) ; <nl> + } else { <nl> + fun ( arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 , arg8 , arg9 , arg10 , arg11 , arg12 , arg13 ) ; <nl> + } <nl> } <nl> <nl> + boost : : function < void ( arg0_t , arg1_t , arg2_t , arg3_t , arg4_t , arg5_t , arg6_t , arg7_t , arg8_t , arg9_t , arg10_t , arg11_t , arg12_t , arg13_t ) > fun ; <nl> + mailbox_callback_mode_t callback_mode ; <nl> raw_mailbox_t mailbox ; <nl> } ; <nl> <nl> mmm a / src / unittest / clustering_branch . cc <nl> ppp b / src / unittest / clustering_branch . cc <nl> void run_read_write_test ( UNUSED simple_mailbox_cluster_t * cluster , <nl> EXPECT_FALSE ( ( * initial_listener ) - > get_broadcaster_lost_signal ( ) - > is_pulsed ( ) ) ; <nl> replier_t < dummy_protocol_t > replier ( initial_listener - > get ( ) ) ; <nl> <nl> + / * Give time for the broadcaster to see the replier * / <nl> + let_stuff_happen ( ) ; <nl> + <nl> order_source_t order_source ; <nl> <nl> / * Send some writes via the broadcaster to the mirror * / <nl> mmm a / src / unittest / rpc_mailbox . cc <nl> ppp b / src / unittest / rpc_mailbox . cc <nl> You can send to a ` dummy_mailbox_t ` with ` send ( ) ` . * / <nl> struct dummy_mailbox_t { <nl> private : <nl> std : : set < int > inbox ; <nl> - void on_message ( read_stream_t * stream , const boost : : function < void ( ) > & on_done ) { <nl> + void on_message ( read_stream_t * stream ) { <nl> int i ; <nl> int res = deserialize ( stream , & i ) ; <nl> if ( res ) { throw fake_archive_exc_t ( ) ; } <nl> - on_done ( ) ; <nl> inbox . insert ( i ) ; <nl> } <nl> public : <nl> explicit dummy_mailbox_t ( mailbox_manager_t * m ) : <nl> - mailbox ( m , boost : : bind ( & dummy_mailbox_t : : on_message , this , _1 , _2 ) ) <nl> + mailbox ( m , boost : : bind ( & dummy_mailbox_t : : on_message , this , _1 ) ) <nl> { } <nl> void expect ( int message ) { <nl> EXPECT_EQ ( 1 , inbox . count ( message ) ) ; <nl> void run_typed_mailbox_test ( ) { <nl> connectivity_cluster_t : : run_t r ( & c , port , & m ) ; <nl> <nl> std : : vector < std : : string > inbox ; <nl> - mailbox_t < void ( std : : string ) > mbox ( & m , boost : : bind ( & std : : vector < std : : string > : : push_back , & inbox , _1 ) ) ; <nl> + mailbox_t < void ( std : : string ) > mbox ( & m , boost : : bind ( & std : : vector < std : : string > : : push_back , & inbox , _1 ) , mailbox_callback_mode_inline ) ; <nl> <nl> mailbox_addr_t < void ( std : : string ) > addr = mbox . get_address ( ) ; <nl> <nl>
Flag that makes mailboxes call their callback inline instead of spawning a new coroutine .
rethinkdb/rethinkdb
e425301fa6ee5d8cf2a308037f7bfeef2a9cc754
2012-05-07T23:44:56Z
mmm a / torch / utils / data / sampler . py <nl> ppp b / torch / utils / data / sampler . py <nl> def __len__ ( self ) : <nl> class WeightedRandomSampler ( Sampler ) : <nl> r " " " Samples elements from [ 0 , . . , len ( weights ) - 1 ] with given probabilities ( weights ) . <nl> <nl> - Arguments : <nl> + Args : <nl> weights ( sequence ) : a sequence of weights , not necessary summing up to one <nl> num_samples ( int ) : number of samples to draw <nl> replacement ( bool ) : if ` ` True ` ` , samples are drawn with replacement . <nl> If not , they are drawn without replacement , which means that when a <nl> sample index is drawn for a row , it cannot be drawn again for that row . <nl> + <nl> + Example : <nl> + > > > list ( WeightedRandomSampler ( [ 0 . 1 , 0 . 9 , 0 . 4 , 0 . 7 , 3 . 0 , 0 . 6 ] , 5 , replacement = True ) ) <nl> + [ 0 , 0 , 0 , 1 , 0 ] <nl> + > > > list ( WeightedRandomSampler ( [ 0 . 9 , 0 . 4 , 0 . 05 , 0 . 2 , 0 . 3 , 0 . 1 ] , 5 , replacement = False ) ) <nl> + [ 0 , 1 , 4 , 3 , 2 ] <nl> " " " <nl> <nl> def __init__ ( self , weights , num_samples , replacement = True ) : <nl>
Add example to WeightedRandomSampler doc string ( )
pytorch/pytorch
d80f0a1f3a6f6e3c3148e3e3b7f551257c01b786
2019-02-24T04:29:06Z
mmm a / scene / 2d / audio_stream_player_2d . cpp <nl> ppp b / scene / 2d / audio_stream_player_2d . cpp <nl> void AudioStreamPlayer2D : : _bind_methods ( ) { <nl> <nl> ADD_PROPERTY ( PropertyInfo ( Variant : : OBJECT , " stream " , PROPERTY_HINT_RESOURCE_TYPE , " AudioStream " ) , " set_stream " , " get_stream " ) ; <nl> ADD_PROPERTY ( PropertyInfo ( Variant : : REAL , " volume_db " , PROPERTY_HINT_RANGE , " - 80 , 24 " ) , " set_volume_db " , " get_volume_db " ) ; <nl> - ADD_PROPERTY ( PropertyInfo ( Variant : : REAL , " pitch_scale " , PROPERTY_HINT_RANGE , " 0 . 01 , 32 , 0 . 01 " ) , " set_pitch_scale " , " get_pitch_scale " ) ; <nl> + ADD_PROPERTY ( PropertyInfo ( Variant : : REAL , " pitch_scale " , PROPERTY_HINT_RANGE , " 0 . 01 , 4 , 0 . 01 , or_greater " ) , " set_pitch_scale " , " get_pitch_scale " ) ; <nl> ADD_PROPERTY ( PropertyInfo ( Variant : : BOOL , " playing " , PROPERTY_HINT_NONE , " " , PROPERTY_USAGE_EDITOR ) , " _set_playing " , " is_playing " ) ; <nl> ADD_PROPERTY ( PropertyInfo ( Variant : : BOOL , " autoplay " ) , " set_autoplay " , " is_autoplay_enabled " ) ; <nl> ADD_PROPERTY ( PropertyInfo ( Variant : : BOOL , " stream_paused " , PROPERTY_HINT_NONE , " " ) , " set_stream_paused " , " get_stream_paused " ) ; <nl> mmm a / scene / 3d / audio_stream_player_3d . cpp <nl> ppp b / scene / 3d / audio_stream_player_3d . cpp <nl> void AudioStreamPlayer3D : : _bind_methods ( ) { <nl> ADD_PROPERTY ( PropertyInfo ( Variant : : REAL , " unit_db " , PROPERTY_HINT_RANGE , " - 80 , 80 " ) , " set_unit_db " , " get_unit_db " ) ; <nl> ADD_PROPERTY ( PropertyInfo ( Variant : : REAL , " unit_size " , PROPERTY_HINT_RANGE , " 0 . 1 , 100 , 0 . 1 " ) , " set_unit_size " , " get_unit_size " ) ; <nl> ADD_PROPERTY ( PropertyInfo ( Variant : : REAL , " max_db " , PROPERTY_HINT_RANGE , " - 24 , 6 " ) , " set_max_db " , " get_max_db " ) ; <nl> - ADD_PROPERTY ( PropertyInfo ( Variant : : REAL , " pitch_scale " , PROPERTY_HINT_RANGE , " 0 . 01 , 32 , 0 . 01 " ) , " set_pitch_scale " , " get_pitch_scale " ) ; <nl> + ADD_PROPERTY ( PropertyInfo ( Variant : : REAL , " pitch_scale " , PROPERTY_HINT_RANGE , " 0 . 01 , 4 , 0 . 01 , or_greater " ) , " set_pitch_scale " , " get_pitch_scale " ) ; <nl> ADD_PROPERTY ( PropertyInfo ( Variant : : BOOL , " playing " , PROPERTY_HINT_NONE , " " , PROPERTY_USAGE_EDITOR ) , " _set_playing " , " is_playing " ) ; <nl> ADD_PROPERTY ( PropertyInfo ( Variant : : BOOL , " autoplay " ) , " set_autoplay " , " is_autoplay_enabled " ) ; <nl> ADD_PROPERTY ( PropertyInfo ( Variant : : BOOL , " stream_paused " , PROPERTY_HINT_NONE , " " ) , " set_stream_paused " , " get_stream_paused " ) ; <nl> mmm a / scene / audio / audio_stream_player . cpp <nl> ppp b / scene / audio / audio_stream_player . cpp <nl> void AudioStreamPlayer : : _bind_methods ( ) { <nl> <nl> ADD_PROPERTY ( PropertyInfo ( Variant : : OBJECT , " stream " , PROPERTY_HINT_RESOURCE_TYPE , " AudioStream " ) , " set_stream " , " get_stream " ) ; <nl> ADD_PROPERTY ( PropertyInfo ( Variant : : REAL , " volume_db " , PROPERTY_HINT_RANGE , " - 80 , 24 " ) , " set_volume_db " , " get_volume_db " ) ; <nl> - ADD_PROPERTY ( PropertyInfo ( Variant : : REAL , " pitch_scale " , PROPERTY_HINT_RANGE , " 0 . 01 , 32 , 0 . 01 " ) , " set_pitch_scale " , " get_pitch_scale " ) ; <nl> + ADD_PROPERTY ( PropertyInfo ( Variant : : REAL , " pitch_scale " , PROPERTY_HINT_RANGE , " 0 . 01 , 4 , 0 . 01 , or_greater " ) , " set_pitch_scale " , " get_pitch_scale " ) ; <nl> ADD_PROPERTY ( PropertyInfo ( Variant : : BOOL , " playing " , PROPERTY_HINT_NONE , " " , PROPERTY_USAGE_EDITOR ) , " _set_playing " , " is_playing " ) ; <nl> ADD_PROPERTY ( PropertyInfo ( Variant : : BOOL , " autoplay " ) , " set_autoplay " , " is_autoplay_enabled " ) ; <nl> ADD_PROPERTY ( PropertyInfo ( Variant : : BOOL , " stream_paused " , PROPERTY_HINT_NONE , " " ) , " set_stream_paused " , " get_stream_paused " ) ; <nl>
Reduce AudioStreamPlayer ' s pitch_scale max value
godotengine/godot
61d20b1f56d5be72508b51e8dec2c5944493e9f3
2020-02-15T11:26:08Z
mmm a / Marlin / gcode . h <nl> ppp b / Marlin / gcode . h <nl> class GCodeParser { <nl> return input_temp_units = = TEMPUNIT_K ? ' K ' : input_temp_units = = TEMPUNIT_F ? ' F ' : ' C ' ; <nl> } <nl> FORCE_INLINE static char * temp_units_name ( ) { <nl> - return input_temp_units = = TEMPUNIT_K ? PSTR ( " Kelvin " ) : input_temp_units = = TEMPUNIT_F ? PSTR ( " Fahrenheit " ) : PSTR ( " Celsius " ) <nl> + return input_temp_units = = TEMPUNIT_K ? PSTR ( " Kelvin " ) : input_temp_units = = TEMPUNIT_F ? PSTR ( " Fahrenheit " ) : PSTR ( " Celsius " ) ; <nl> } <nl> inline static float to_temp_units ( const float & f ) { <nl> switch ( input_temp_units ) { <nl>
Merge pull request from Bob - the - Kuhn / gcode . h - 2
MarlinFirmware/Marlin
4ecd41ef90fc8b589e20f21b708109856e9b79a6
2017-05-31T19:03:33Z
mmm a / src / test / coins_tests . cpp <nl> ppp b / src / test / coins_tests . cpp <nl> <nl> / / Distributed under the MIT software license , see the accompanying <nl> / / file COPYING or http : / / www . opensource . org / licenses / mit - license . php . <nl> <nl> + # include < attributes . h > <nl> # include < coins . h > <nl> + # include < consensus / validation . h > <nl> # include < script / standard . h > <nl> + # include < test / test_bitcoin . h > <nl> # include < uint256 . h > <nl> # include < undo . h > <nl> # include < util / strencodings . h > <nl> - # include < test / test_bitcoin . h > <nl> # include < validation . h > <nl> - # include < consensus / validation . h > <nl> <nl> - # include < vector > <nl> # include < map > <nl> + # include < vector > <nl> <nl> # include < boost / test / unit_test . hpp > <nl> <nl> class CCoinsViewTest : public CCoinsView <nl> std : : map < COutPoint , Coin > map_ ; <nl> <nl> public : <nl> - bool GetCoin ( const COutPoint & outpoint , Coin & coin ) const override <nl> + NODISCARD bool GetCoin ( const COutPoint & outpoint , Coin & coin ) const override <nl> { <nl> std : : map < COutPoint , Coin > : : const_iterator it = map_ . find ( outpoint ) ; <nl> if ( it = = map_ . end ( ) ) { <nl> mmm a / src / test / dbwrapper_tests . cpp <nl> ppp b / src / test / dbwrapper_tests . cpp <nl> BOOST_AUTO_TEST_CASE ( dbwrapper_iterator ) <nl> char key_res ; <nl> uint256 val_res ; <nl> <nl> - it - > GetKey ( key_res ) ; <nl> - it - > GetValue ( val_res ) ; <nl> + BOOST_REQUIRE ( it - > GetKey ( key_res ) ) ; <nl> + BOOST_REQUIRE ( it - > GetValue ( val_res ) ) ; <nl> BOOST_CHECK_EQUAL ( key_res , key ) ; <nl> BOOST_CHECK_EQUAL ( val_res . ToString ( ) , in . ToString ( ) ) ; <nl> <nl> it - > Next ( ) ; <nl> <nl> - it - > GetKey ( key_res ) ; <nl> - it - > GetValue ( val_res ) ; <nl> + BOOST_REQUIRE ( it - > GetKey ( key_res ) ) ; <nl> + BOOST_REQUIRE ( it - > GetValue ( val_res ) ) ; <nl> BOOST_CHECK_EQUAL ( key_res , key2 ) ; <nl> BOOST_CHECK_EQUAL ( val_res . ToString ( ) , in2 . ToString ( ) ) ; <nl> <nl> mmm a / src / test / util_tests . cpp <nl> ppp b / src / test / util_tests . cpp <nl> struct TestArgsManager : public ArgsManager <nl> m_config_args . clear ( ) ; <nl> } <nl> std : : string error ; <nl> - ReadConfigStream ( streamConfig , error ) ; <nl> + BOOST_REQUIRE ( ReadConfigStream ( streamConfig , error ) ) ; <nl> } <nl> void SetNetworkOnlyArg ( const std : : string arg ) <nl> { <nl> mmm a / src / util / system . h <nl> ppp b / src / util / system . h <nl> class ArgsManager <nl> std : : map < OptionsCategory , std : : map < std : : string , Arg > > m_available_args GUARDED_BY ( cs_args ) ; <nl> std : : set < std : : string > m_config_sections GUARDED_BY ( cs_args ) ; <nl> <nl> - bool ReadConfigStream ( std : : istream & stream , std : : string & error , bool ignore_invalid_keys = false ) ; <nl> + NODISCARD bool ReadConfigStream ( std : : istream & stream , std : : string & error , bool ignore_invalid_keys = false ) ; <nl> <nl> public : <nl> ArgsManager ( ) ; <nl> class ArgsManager <nl> void SelectConfigNetwork ( const std : : string & network ) ; <nl> <nl> NODISCARD bool ParseParameters ( int argc , const char * const argv [ ] , std : : string & error ) ; <nl> - bool ReadConfigFiles ( std : : string & error , bool ignore_invalid_keys = false ) ; <nl> + NODISCARD bool ReadConfigFiles ( std : : string & error , bool ignore_invalid_keys = false ) ; <nl> <nl> / * * <nl> * Log warnings for options in m_section_only_args when <nl>
Merge : test : Add BOOST_REQUIRE to getters returning optional
bitcoin/bitcoin
2a97f192ea92e7accb21288c3c5822f480808566
2018-11-22T16:37:17Z
mmm a / docs / ru / query_language / functions / rounding_functions . md <nl> ppp b / docs / ru / query_language / functions / rounding_functions . md <nl> round ( 3 . 65 , 1 ) = 3 . 6 <nl> <nl> - Если округляемое число равноудалено от соседних чисел , то используется банковское округление . <nl> <nl> - Банковское округление ( англ . banker ' s rounding ) — метод округления дробных чисел . Если округляемое число равноудалёно от соседних чисел , то оно округляется до ближайшей чётной цифры на заданном десятичном разряде . К примеру , 3 , 5 округляется до 4 , а 2 , 5 до 2 . <nl> + Банковское округление ( англ . banker ' s rounding ) — метод округления дробных чисел . Если округляемое число равноудалёно от соседних чисел , то оно округляется до ближайшей чётной цифры заданного десятичного разряда . К примеру , 3 , 5 округляется до 4 , а 2 , 5 до 2 . <nl> <nl> Это метод округления по умолчанию используемый для чисел с плавающей запятой , определённый в стандарте [ IEEE 754 ] ( https : / / en . wikipedia . org / wiki / IEEE_754 # Roundings_to_nearest ) . Функция [ round ] ( # rounding_functions - round ) также округляет числа с плавающей запятой по этому методу . Функция ` roundBankers ` округляет не только числа с плавающей запятой , но и целые числа методом банковского округления , например , ` roundBankers ( 45 , - 1 ) = 40 ` . <nl> <nl>
CLICKHOUSEDOCS - 496 : Clarification .
ClickHouse/ClickHouse
c9f57955e83f3acb9455bc201465735e36dffb8a
2020-01-28T16:13:58Z
mmm a / Code / Sandbox / Plugins / EditorCommon / EditorFramework / Editor . cpp <nl> ppp b / Code / Sandbox / Plugins / EditorCommon / EditorFramework / Editor . cpp <nl> void CEditor : : UpdateAdaptiveLayout ( ) <nl> if ( newOrientation = = m_currentOrientation ) <nl> return ; <nl> <nl> + / / Before switching orientation , make sure the current size isn ' t smaller than the minimum size <nl> + / / supported by the new orientation of the editor . Otherwise we get layout flickering <nl> + QSize minSize = m_pEditorContent - > GetMinimumSizeForOrientation ( newOrientation ) ; <nl> + QSize currentSize = size ( ) ; <nl> + if ( currentSize . width ( ) < minSize . width ( ) | | currentSize . height ( ) < minSize . height ( ) ) <nl> + return ; <nl> + <nl> m_currentOrientation = newOrientation ; <nl> OnAdaptiveLayoutChanged ( ) ; <nl> } <nl> mmm a / Code / Sandbox / Plugins / EditorCommon / EditorFramework / EditorContent . cpp <nl> ppp b / Code / Sandbox / Plugins / EditorCommon / EditorFramework / EditorContent . cpp <nl> QVariantMap CEditorContent : : GetState ( ) const <nl> return m_pToolBarAreaManager - > GetState ( ) ; <nl> } <nl> <nl> + QSize CEditorContent : : GetMinimumSizeForOrientation ( Qt : : Orientation orientation ) const <nl> + { <nl> + const bool isDefaultOrientation = orientation = = m_pEditor - > GetDefaultOrientation ( ) ; <nl> + QSize contentMinSize = m_pContent - > layout ( ) - > minimumSize ( ) ; <nl> + <nl> + CToolBarArea * pTopArea = m_pToolBarAreaManager - > GetWidget ( CToolBarAreaManager : : Area : : Top ) ; <nl> + CToolBarArea * pBottomArea = m_pToolBarAreaManager - > GetWidget ( CToolBarAreaManager : : Area : : Bottom ) ; <nl> + CToolBarArea * pLeftArea = m_pToolBarAreaManager - > GetWidget ( CToolBarAreaManager : : Area : : Left ) ; <nl> + CToolBarArea * pRightArea = m_pToolBarAreaManager - > GetWidget ( CToolBarAreaManager : : Area : : Right ) ; <nl> + <nl> + QSize result ( 0 , 0 ) ; <nl> + if ( isDefaultOrientation ) <nl> + { <nl> + / / Take width from left and right areas if we ' re switching to the editor ' s default orientation <nl> + result . setWidth ( result . width ( ) + pLeftArea - > GetLargestItemMinimumSize ( ) . width ( ) ) ; <nl> + result . setWidth ( result . width ( ) + pRightArea - > GetLargestItemMinimumSize ( ) . width ( ) ) ; <nl> + <nl> + / / Use top and bottom area to calculate min height <nl> + result . setHeight ( result . height ( ) + pTopArea - > GetLargestItemMinimumSize ( ) . height ( ) ) ; <nl> + result . setHeight ( result . height ( ) + pBottomArea - > GetLargestItemMinimumSize ( ) . height ( ) ) ; <nl> + <nl> + / / Add content min size <nl> + result + = contentMinSize ; <nl> + <nl> + / / Take the area layout minimum sizes into account . We just need to expand the already provided minimum size <nl> + / / with values of min size of layouts holding toolbars . These match the minimum size of the full collection of toolbars <nl> + result . expandedTo ( QSize ( pTopArea - > layout ( ) - > minimumSize ( ) . width ( ) , pLeftArea - > layout ( ) - > minimumSize ( ) . height ( ) ) ) ; <nl> + result . expandedTo ( QSize ( pBottomArea - > layout ( ) - > minimumSize ( ) . width ( ) , pRightArea - > layout ( ) - > minimumSize ( ) . height ( ) ) ) ; <nl> + } <nl> + else <nl> + { <nl> + / / If we ' re not switching to the default orientation , then we need to use the top and bottom toolbar areas ' width <nl> + / / since these areas will be placed at the left and right of the editor content in this case of adaptive layouts <nl> + result . setWidth ( result . width ( ) + pTopArea - > GetLargestItemMinimumSize ( ) . width ( ) ) ; <nl> + result . setWidth ( result . width ( ) + pBottomArea - > GetLargestItemMinimumSize ( ) . width ( ) ) ; <nl> + <nl> + / / We must also flip where we get toolbar area min height from <nl> + result . setHeight ( result . height ( ) + pLeftArea - > GetLargestItemMinimumSize ( ) . height ( ) ) ; <nl> + result . setHeight ( result . height ( ) + pRightArea - > GetLargestItemMinimumSize ( ) . height ( ) ) ; <nl> + <nl> + / / Add flipped content min size <nl> + result + = QSize ( contentMinSize . height ( ) , contentMinSize . width ( ) ) ; <nl> + <nl> + result . expandedTo ( QSize ( pLeftArea - > layout ( ) - > minimumSize ( ) . width ( ) , pTopArea - > layout ( ) - > minimumSize ( ) . height ( ) ) ) ; <nl> + result . expandedTo ( QSize ( pRightArea - > layout ( ) - > minimumSize ( ) . width ( ) , pBottomArea - > layout ( ) - > minimumSize ( ) . height ( ) ) ) ; <nl> + } <nl> + <nl> + return result ; <nl> + } <nl> + <nl> void CEditorContent : : OnAdaptiveLayoutChanged ( Qt : : Orientation orientation ) <nl> { <nl> const bool isDefaultOrientation = m_pEditor - > GetOrientation ( ) = = m_pEditor - > GetDefaultOrientation ( ) ; <nl> mmm a / Code / Sandbox / Plugins / EditorCommon / EditorFramework / EditorContent . h <nl> ppp b / Code / Sandbox / Plugins / EditorCommon / EditorFramework / EditorContent . h <nl> class CEditorContent : public QWidget , public IStateSerializable <nl> / / Layout management <nl> QVariantMap GetState ( ) const override ; <nl> void SetState ( const QVariantMap & state ) override ; <nl> + QSize GetMinimumSizeForOrientation ( Qt : : Orientation orientation ) const ; <nl> void OnAdaptiveLayoutChanged ( Qt : : Orientation orientation ) ; <nl> <nl> protected : <nl> mmm a / Code / Sandbox / Plugins / EditorCommon / EditorFramework / ToolBar / ToolBarArea . cpp <nl> ppp b / Code / Sandbox / Plugins / EditorCommon / EditorFramework / ToolBar / ToolBarArea . cpp <nl> std : : vector < CToolBarItem * > CToolBarArea : : GetToolBars ( ) const <nl> return toolBarItems ; <nl> } <nl> <nl> + QSize CToolBarArea : : GetLargestItemMinimumSize ( ) const <nl> + { <nl> + QSize minSize = minimumSize ( ) ; <nl> + const QList < CToolBarAreaItem * > items = Private_ToolBarArea : : GetAllItems ( this ) ; <nl> + <nl> + for ( CToolBarAreaItem * pItem : items ) <nl> + { <nl> + minSize = minSize . expandedTo ( pItem - > GetMinimumSize ( ) ) ; <nl> + } <nl> + <nl> + return minSize ; <nl> + } <nl> + <nl> void CToolBarArea : : SetOrientation ( Qt : : Orientation orientation ) <nl> { <nl> m_orientation = orientation ; <nl> mmm a / Code / Sandbox / Plugins / EditorCommon / EditorFramework / ToolBar / ToolBarArea . h <nl> ppp b / Code / Sandbox / Plugins / EditorCommon / EditorFramework / ToolBar / ToolBarArea . h <nl> class CToolBarArea : public QWidget , public IStateSerializable <nl> Qt : : Orientation GetOrientation ( ) const { return m_orientation ; } <nl> std : : vector < CToolBarItem * > GetToolBars ( ) const ; <nl> <nl> + / / Provides the minimum size of the largest item in this area <nl> + QSize GetLargestItemMinimumSize ( ) const ; <nl> void SetOrientation ( Qt : : Orientation orientation ) ; <nl> void SetActionContextPosition ( const QPoint & actionContextPosition ) { m_actionContextPosition = actionContextPosition ; } <nl> void FillContextMenu ( CAbstractMenu * pMenu ) ; <nl> mmm a / Code / Sandbox / Plugins / EditorCommon / EditorFramework / ToolBar / ToolBarAreaItem . cpp <nl> ppp b / Code / Sandbox / Plugins / EditorCommon / EditorFramework / ToolBar / ToolBarAreaItem . cpp <nl> void CToolBarItem : : SetOrientation ( Qt : : Orientation orientation ) <nl> m_pToolBar - > setOrientation ( m_orientation ) ; <nl> } <nl> <nl> + QSize CToolBarItem : : GetMinimumSize ( ) const <nl> + { <nl> + / / Get min size set on the toolbar area item <nl> + QSize minSize = CToolBarAreaItem : : GetMinimumSize ( ) ; <nl> + / / Expand to toolbars min size if it exceeds the widget ' s min size <nl> + minSize = minSize . expandedTo ( m_pToolBar - > minimumSize ( ) ) ; <nl> + / / Expand to the toolbar layouts minimum size , this accounts for internal widget min sizes <nl> + minSize = minSize . expandedTo ( m_pToolBar - > layout ( ) - > minimumSize ( ) ) ; <nl> + <nl> + return minSize ; <nl> + } <nl> + <nl> QString CToolBarItem : : GetTitle ( ) const <nl> { <nl> return m_pToolBar - > windowTitle ( ) ; <nl> mmm a / Code / Sandbox / Plugins / EditorCommon / EditorFramework / ToolBar / ToolBarAreaItem . h <nl> ppp b / Code / Sandbox / Plugins / EditorCommon / EditorFramework / ToolBar / ToolBarAreaItem . h <nl> class CToolBarAreaItem : public QWidget <nl> virtual Type GetType ( ) const = 0 ; <nl> CToolBarArea * GetArea ( ) const { return m_pArea ; } <nl> Qt : : Orientation GetOrientation ( ) const { return m_orientation ; } <nl> - <nl> + virtual QSize GetMinimumSize ( ) const { return minimumSize ( ) ; } <nl> static const char * GetMimeType ( ) { return " CToolBarAreaItem " ; } <nl> <nl> protected : <nl> class CToolBarItem : public CToolBarAreaItem <nl> void ReplaceToolBar ( QToolBar * pNewToolBar ) ; <nl> void SetOrientation ( Qt : : Orientation orientation ) override ; <nl> <nl> + virtual QSize GetMinimumSize ( ) const override ; <nl> Type GetType ( ) const override { return Type : : ToolBar ; } <nl> QString GetTitle ( ) const ; <nl> QString GetName ( ) const ; <nl>
! I integrate from / / ce / main . . .
CRYTEK/CRYENGINE
bf8d392e988c76225e6469950ac41ffb2053ca83
2019-06-19T11:02:06Z
mmm a / editor / plugins / tile_set_editor_plugin . cpp <nl> ppp b / editor / plugins / tile_set_editor_plugin . cpp <nl> void TileSetEditor : : _import_node ( Node * p_node , Ref < TileSet > p_library ) { <nl> Transform2D shape_transform = sb - > shape_owner_get_transform ( E - > get ( ) ) ; <nl> bool one_way = sb - > is_shape_owner_one_way_collision_enabled ( E - > get ( ) ) ; <nl> <nl> - shape_transform . set_origin ( shape_transform . get_origin ( ) - phys_offset ) ; <nl> + shape_transform [ 2 ] - = phys_offset - sb - > get_transform ( ) . xform ( shape_transform [ 2 ] ) ; <nl> <nl> for ( int k = 0 ; k < sb - > shape_owner_get_shape_count ( E - > get ( ) ) ; k + + ) { <nl> <nl>
Fix tileset bug to use StaticBody2D position
godotengine/godot
8529763a0f9b4368bc907c61c47e1eaeacc374e4
2018-05-09T06:42:10Z
mmm a / platform / android / AndroidManifest . xml . template <nl> ppp b / platform / android / AndroidManifest . xml . template <nl> $ $ ADD_PERMISSION_CHUNKS $ $ <nl> < uses - permission android : name = " godot . custom . 18 " / > <nl> < uses - permission android : name = " godot . custom . 19 " / > <nl> <nl> - < uses - sdk android : minSdkVersion = " 10 " android : targetSdkVersion = " 19 " / > <nl> + < uses - sdk android : minSdkVersion = " 10 " android : targetSdkVersion = " 23 " / > <nl> <nl> < / manifest > <nl> mmm a / platform / android / build . gradle . template <nl> ppp b / platform / android / build . gradle . template <nl> allprojects { <nl> } <nl> <nl> dependencies { <nl> - <nl> + compile ' com . android . support : support - v4 : 23 . + ' <nl> $ $ GRADLE_DEPENDENCIES $ $ <nl> } <nl> <nl> mmm a / platform / android / java / src / com / android / vending / licensing / LicenseChecker . java <nl> ppp b / platform / android / java / src / com / android / vending / licensing / LicenseChecker . java <nl> public synchronized void checkAccess ( LicenseCheckerCallback callback ) { <nl> if ( mService = = null ) { <nl> Log . i ( TAG , " Binding to licensing service . " ) ; <nl> try { <nl> + Intent serviceIntent = new Intent ( new String ( Base64 . decode ( " Y29tLmFuZHJvaWQudmVuZGluZy5saWNlbnNpbmcuSUxpY2Vuc2luZ1NlcnZpY2U = " ) ) ) ; <nl> + serviceIntent . setPackage ( " com . android . vending " ) ; <nl> boolean bindResult = mContext <nl> . bindService ( <nl> - new Intent ( <nl> - new String ( <nl> - Base64 . decode ( " Y29tLmFuZHJvaWQudmVuZGluZy5saWNlbnNpbmcuSUxpY2Vuc2luZ1NlcnZpY2U = " ) ) ) , <nl> + serviceIntent , <nl> this , / / ServiceConnection . <nl> Context . BIND_AUTO_CREATE ) ; <nl> <nl> mmm a / platform / android / java / src / com / google / android / vending / expansion / downloader / impl / DownloadNotification . java <nl> ppp b / platform / android / java / src / com / google / android / vending / expansion / downloader / impl / DownloadNotification . java <nl> <nl> import android . app . PendingIntent ; <nl> import android . content . Context ; <nl> import android . os . Messenger ; <nl> + import android . support . v4 . app . NotificationCompat ; <nl> <nl> / * * <nl> * This class handles displaying the notification associated with the download <nl> <nl> <nl> private IDownloaderClient mClientProxy ; <nl> final ICustomNotification mCustomNotification ; <nl> - private Notification . Builder mNotificationBuilder ; <nl> - private Notification . Builder mCurrentNotificationBuilder ; <nl> + private NotificationCompat . Builder mNotificationBuilder ; <nl> + private NotificationCompat . Builder mCurrentNotificationBuilder ; <nl> private CharSequence mLabel ; <nl> private String mCurrentText ; <nl> private PendingIntent mContentIntent ; <nl> public void onDownloadProgress ( DownloadProgressInfo progress ) { <nl> <nl> void setTimeRemaining ( long timeRemaining ) ; <nl> <nl> - Notification . Builder updateNotification ( Context c ) ; <nl> + NotificationCompat . Builder updateNotification ( Context c ) ; <nl> } <nl> <nl> / * * <nl> public void setMessenger ( Messenger msg ) { <nl> mContext . getSystemService ( Context . NOTIFICATION_SERVICE ) ; <nl> mCustomNotification = CustomNotificationFactory <nl> . createCustomNotification ( ) ; <nl> - mNotificationBuilder = new Notification . Builder ( ctx ) ; <nl> + mNotificationBuilder = new NotificationCompat . Builder ( ctx ) ; <nl> mCurrentNotificationBuilder = mNotificationBuilder ; <nl> <nl> } <nl> mmm a / platform / android / java / src / com / google / android / vending / expansion / downloader / impl / V14CustomNotification . java <nl> ppp b / platform / android / java / src / com / google / android / vending / expansion / downloader / impl / V14CustomNotification . java <nl> <nl> import android . app . Notification ; <nl> import android . app . PendingIntent ; <nl> import android . content . Context ; <nl> + import android . support . v4 . app . NotificationCompat ; <nl> <nl> public class V14CustomNotification implements DownloadNotification . ICustomNotification { <nl> <nl> public void setCurrentBytes ( long currentBytes ) { <nl> mCurrentKB = currentBytes ; <nl> } <nl> <nl> - void setProgress ( Notification . Builder builder ) { <nl> + void setProgress ( NotificationCompat . Builder builder ) { <nl> <nl> } <nl> <nl> @ Override <nl> - public Notification . Builder updateNotification ( Context c ) { <nl> - Notification . Builder builder = new Notification . Builder ( c ) ; <nl> + public NotificationCompat . Builder updateNotification ( Context c ) { <nl> + NotificationCompat . Builder builder = new NotificationCompat . Builder ( c ) ; <nl> builder . setContentTitle ( mTitle ) ; <nl> if ( mTotalKB > 0 & & - 1 ! = mCurrentKB ) { <nl> builder . setProgress ( ( int ) ( mTotalKB > > 8 ) , ( int ) ( mCurrentKB > > 8 ) , false ) ; <nl>
fix compatibility for Android API 14 with supporting API 23
godotengine/godot
ff67c256f52b904bdabe17e755194149da9b219f
2016-05-24T02:22:35Z
mmm a / src / core / lib / surface / init . cc <nl> ppp b / src / core / lib / surface / init . cc <nl> static void do_basic_init ( void ) { <nl> g_shutting_down = false ; <nl> grpc_register_built_in_plugins ( ) ; <nl> grpc_cq_global_init ( ) ; <nl> + gpr_time_init ( ) ; <nl> g_initializations = 0 ; <nl> } <nl> <nl> void grpc_init ( void ) { <nl> } <nl> grpc_core : : Fork : : GlobalInit ( ) ; <nl> grpc_fork_handlers_auto_register ( ) ; <nl> - gpr_time_init ( ) ; <nl> gpr_arena_init ( ) ; <nl> grpc_stats_init ( ) ; <nl> grpc_slice_intern_init ( ) ; <nl>
Initialize time as part of basic initialization .
grpc/grpc
c239e0416d54c0a19b55a056fa1c92bbd400cac7
2019-04-01T00:18:13Z
mmm a / cocos2dx / support / user_default / CCUserDefault . h <nl> ppp b / cocos2dx / support / user_default / CCUserDefault . h <nl> class CC_DLL CCUserDefault <nl> static CCUserDefault * sharedUserDefault ( ) ; <nl> static void purgeSharedUserDefault ( ) ; <nl> const static std : : string & getXMLFilePath ( ) ; <nl> + static bool isXMLFileExist ( ) ; <nl> <nl> private : <nl> CCUserDefault ( ) ; <nl> static bool createXMLFile ( ) ; <nl> - static bool isXMLFileExist ( ) ; <nl> static void initXMLFilePath ( ) ; <nl> <nl> static CCUserDefault * m_spUserDefault ; <nl> mmm a / cocos2dx / support / user_default / CCUserDefault . mm <nl> ppp b / cocos2dx / support / user_default / CCUserDefault . mm <nl> of this software and associated documentation files ( the " Software " ) , to deal <nl> <nl> # import " CCUserDefault . h " <nl> # import < string > <nl> + # import " platform / CCFileUtils . h " <nl> + # import " . . / tinyxml2 / tinyxml2 . h " <nl> # import " platform / CCPlatformConfig . h " <nl> + # import " platform / CCPlatformMacros . h " <nl> <nl> # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_IOS ) | | ( CC_TARGET_PLATFORM = = CC_PLATFORM_MAC ) <nl> <nl> - NS_CC_BEGIN <nl> + <nl> + # define XML_FILE_NAME " UserDefault . xml " <nl> + <nl> + / / root name of xml <nl> + # define USERDEFAULT_ROOT_NAME " userDefaultRoot " <nl> + <nl> + # define KEEP_COMPATABILITY <nl> + <nl> using namespace std ; <nl> <nl> + NS_CC_BEGIN <nl> + <nl> / * * <nl> * implements of CCUserDefault <nl> * / <nl> of this software and associated documentation files ( the " Software " ) , to deal <nl> string CCUserDefault : : m_sFilePath = string ( " " ) ; <nl> bool CCUserDefault : : m_sbIsFilePathInitialized = false ; <nl> <nl> + # ifdef KEEP_COMPATABILITY <nl> + static tinyxml2 : : XMLElement * getXMLNodeForKey ( const char * pKey , tinyxml2 : : XMLDocument * * doc ) <nl> + { <nl> + tinyxml2 : : XMLElement * curNode = NULL ; <nl> + tinyxml2 : : XMLElement * rootNode = NULL ; <nl> + <nl> + if ( ! CCUserDefault : : isXMLFileExist ( ) ) <nl> + { <nl> + return NULL ; <nl> + } <nl> + <nl> + / / check the key value <nl> + if ( ! pKey ) <nl> + { <nl> + return NULL ; <nl> + } <nl> + <nl> + do <nl> + { <nl> + tinyxml2 : : XMLDocument * xmlDoc = new tinyxml2 : : XMLDocument ( ) ; <nl> + * doc = xmlDoc ; <nl> + unsigned long nSize ; <nl> + const char * pXmlBuffer = ( const char * ) CCFileUtils : : sharedFileUtils ( ) - > getFileData ( CCUserDefault : : sharedUserDefault ( ) - > getXMLFilePath ( ) . c_str ( ) , " rb " , & nSize ) ; <nl> + / / const char * pXmlBuffer = ( const char * ) data . getBuffer ( ) ; <nl> + if ( NULL = = pXmlBuffer ) <nl> + { <nl> + NSLog ( @ " can not read xml file " ) ; <nl> + break ; <nl> + } <nl> + xmlDoc - > Parse ( pXmlBuffer ) ; <nl> + / / get root node <nl> + rootNode = xmlDoc - > RootElement ( ) ; <nl> + if ( NULL = = rootNode ) <nl> + { <nl> + NSLog ( @ " read root node error " ) ; <nl> + break ; <nl> + } <nl> + / / find the node <nl> + curNode = rootNode - > FirstChildElement ( ) ; <nl> + if ( ! curNode ) <nl> + { <nl> + / / There is not xml node , delete xml file . <nl> + remove ( CCUserDefault : : sharedUserDefault ( ) - > getXMLFilePath ( ) . c_str ( ) ) ; <nl> + <nl> + return NULL ; <nl> + } <nl> + <nl> + while ( NULL ! = curNode ) <nl> + { <nl> + const char * nodeName = curNode - > Value ( ) ; <nl> + if ( ! strcmp ( nodeName , pKey ) ) <nl> + { <nl> + / / delete the node <nl> + break ; <nl> + } <nl> + <nl> + curNode = curNode - > NextSiblingElement ( ) ; <nl> + } <nl> + } while ( 0 ) ; <nl> + <nl> + return curNode ; <nl> + } <nl> + <nl> + static void deleteNode ( tinyxml2 : : XMLDocument * doc , tinyxml2 : : XMLElement * node ) <nl> + { <nl> + if ( node ) <nl> + { <nl> + doc - > DeleteNode ( node ) ; <nl> + doc - > SaveFile ( CCUserDefault : : sharedUserDefault ( ) - > getXMLFilePath ( ) . c_str ( ) ) ; <nl> + delete doc ; <nl> + } <nl> + } <nl> + <nl> + static void deleteNodeByKey ( const char * pKey ) <nl> + { <nl> + tinyxml2 : : XMLDocument * doc = NULL ; <nl> + tinyxml2 : : XMLElement * node = getXMLNodeForKey ( pKey , & doc ) ; <nl> + deleteNode ( doc , node ) ; <nl> + } <nl> + # endif <nl> + <nl> / * * <nl> * If the user invoke delete CCUserDefault : : sharedUserDefault ( ) , should set m_spUserDefault <nl> * to null to avoid error when he invoke CCUserDefault : : sharedUserDefault ( ) later . <nl> of this software and associated documentation files ( the " Software " ) , to deal <nl> <nl> bool CCUserDefault : : getBoolForKey ( const char * pKey , bool defaultValue ) <nl> { <nl> + # ifdef KEEP_COMPATABILITY <nl> + tinyxml2 : : XMLDocument * doc = NULL ; <nl> + tinyxml2 : : XMLElement * node = getXMLNodeForKey ( pKey , & doc ) ; <nl> + if ( node ) <nl> + { <nl> + if ( node - > FirstChild ( ) ) <nl> + { <nl> + const char * value = ( const char * ) node - > FirstChild ( ) - > Value ( ) ; <nl> + bool ret = ( ! strcmp ( value , " true " ) ) ; <nl> + <nl> + / / set value in NSUserDefaults <nl> + setBoolForKey ( pKey , ret ) ; <nl> + flush ( ) ; <nl> + <nl> + / / delete xmle node <nl> + deleteNode ( doc , node ) ; <nl> + <nl> + return ret ; <nl> + } <nl> + else <nl> + { <nl> + / / delete xmle node <nl> + deleteNode ( doc , node ) ; <nl> + } <nl> + } <nl> + # endif <nl> + <nl> bool ret = defaultValue ; <nl> <nl> NSNumber * value = [ [ NSUserDefaults standardUserDefaults ] objectForKey : [ NSString stringWithUTF8String : pKey ] ] ; <nl> of this software and associated documentation files ( the " Software " ) , to deal <nl> <nl> int CCUserDefault : : getIntegerForKey ( const char * pKey , int defaultValue ) <nl> { <nl> + # ifdef KEEP_COMPATABILITY <nl> + tinyxml2 : : XMLDocument * doc = NULL ; <nl> + tinyxml2 : : XMLElement * node = getXMLNodeForKey ( pKey , & doc ) ; <nl> + if ( node ) <nl> + { <nl> + if ( node - > FirstChild ( ) ) <nl> + { <nl> + int ret = atoi ( ( const char * ) node - > FirstChild ( ) - > Value ( ) ) ; <nl> + <nl> + / / set value in NSUserDefaults <nl> + setIntegerForKey ( pKey , ret ) ; <nl> + flush ( ) ; <nl> + <nl> + / / delete xmle node <nl> + deleteNode ( doc , node ) ; <nl> + <nl> + return ret ; <nl> + } <nl> + else <nl> + { <nl> + / / delete xmle node <nl> + deleteNode ( doc , node ) ; <nl> + } <nl> + } <nl> + # endif <nl> + <nl> int ret = defaultValue ; <nl> <nl> NSNumber * value = [ [ NSUserDefaults standardUserDefaults ] objectForKey : [ NSString stringWithUTF8String : pKey ] ] ; <nl> of this software and associated documentation files ( the " Software " ) , to deal <nl> <nl> float CCUserDefault : : getFloatForKey ( const char * pKey , float defaultValue ) <nl> { <nl> + # ifdef KEEP_COMPATABILITY <nl> + tinyxml2 : : XMLDocument * doc = NULL ; <nl> + tinyxml2 : : XMLElement * node = getXMLNodeForKey ( pKey , & doc ) ; <nl> + if ( node ) <nl> + { <nl> + if ( node - > FirstChild ( ) ) <nl> + { <nl> + float ret = atof ( ( const char * ) node - > FirstChild ( ) - > Value ( ) ) ; <nl> + <nl> + / / set value in NSUserDefaults <nl> + setFloatForKey ( pKey , ret ) ; <nl> + flush ( ) ; <nl> + <nl> + / / delete xmle node <nl> + deleteNode ( doc , node ) ; <nl> + <nl> + return ret ; <nl> + } <nl> + else <nl> + { <nl> + / / delete xmle node <nl> + deleteNode ( doc , node ) ; <nl> + } <nl> + } <nl> + # endif <nl> + <nl> float ret = defaultValue ; <nl> <nl> NSNumber * value = [ [ NSUserDefaults standardUserDefaults ] objectForKey : [ NSString stringWithUTF8String : pKey ] ] ; <nl> of this software and associated documentation files ( the " Software " ) , to deal <nl> <nl> double CCUserDefault : : getDoubleForKey ( const char * pKey , double defaultValue ) <nl> { <nl> + # ifdef KEEP_COMPATABILITY <nl> + tinyxml2 : : XMLDocument * doc = NULL ; <nl> + tinyxml2 : : XMLElement * node = getXMLNodeForKey ( pKey , & doc ) ; <nl> + if ( node ) <nl> + { <nl> + if ( node - > FirstChild ( ) ) <nl> + { <nl> + double ret = atof ( ( const char * ) node - > FirstChild ( ) - > Value ( ) ) ; <nl> + <nl> + / / set value in NSUserDefaults <nl> + setDoubleForKey ( pKey , ret ) ; <nl> + flush ( ) ; <nl> + <nl> + / / delete xmle node <nl> + deleteNode ( doc , node ) ; <nl> + <nl> + return ret ; <nl> + } <nl> + else <nl> + { <nl> + / / delete xmle node <nl> + deleteNode ( doc , node ) ; <nl> + } <nl> + } <nl> + # endif <nl> + <nl> double ret = defaultValue ; <nl> <nl> NSNumber * value = [ [ NSUserDefaults standardUserDefaults ] objectForKey : [ NSString stringWithUTF8String : pKey ] ] ; <nl> of this software and associated documentation files ( the " Software " ) , to deal <nl> <nl> string CCUserDefault : : getStringForKey ( const char * pKey , const std : : string & defaultValue ) <nl> { <nl> + # ifdef KEEP_COMPATABILITY <nl> + tinyxml2 : : XMLDocument * doc = NULL ; <nl> + tinyxml2 : : XMLElement * node = getXMLNodeForKey ( pKey , & doc ) ; <nl> + if ( node ) <nl> + { <nl> + if ( node - > FirstChild ( ) ) <nl> + { <nl> + string ret = ( const char * ) node - > FirstChild ( ) - > Value ( ) ; <nl> + <nl> + / / set value in NSUserDefaults <nl> + setStringForKey ( pKey , ret ) ; <nl> + flush ( ) ; <nl> + <nl> + / / delete xmle node <nl> + deleteNode ( doc , node ) ; <nl> + <nl> + return ret ; <nl> + } <nl> + else <nl> + { <nl> + / / delete xmle node <nl> + deleteNode ( doc , node ) ; <nl> + } <nl> + } <nl> + # endif <nl> + <nl> NSString * str = [ [ NSUserDefaults standardUserDefaults ] stringForKey : [ NSString stringWithUTF8String : pKey ] ] ; <nl> if ( ! str ) <nl> { <nl> of this software and associated documentation files ( the " Software " ) , to deal <nl> <nl> void CCUserDefault : : setBoolForKey ( const char * pKey , bool value ) <nl> { <nl> + # ifdef KEEP_COMPATABILITY <nl> + deleteNodeByKey ( pKey ) ; <nl> + # endif <nl> + <nl> [ [ NSUserDefaults standardUserDefaults ] setObject : [ NSNumber numberWithBool : value ] forKey : [ NSString stringWithUTF8String : pKey ] ] ; <nl> } <nl> <nl> void CCUserDefault : : setIntegerForKey ( const char * pKey , int value ) <nl> { <nl> + # ifdef KEEP_COMPATABILITY <nl> + deleteNodeByKey ( pKey ) ; <nl> + # endif <nl> + <nl> [ [ NSUserDefaults standardUserDefaults ] setObject : [ NSNumber numberWithInt : value ] forKey : [ NSString stringWithUTF8String : pKey ] ] ; <nl> } <nl> <nl> void CCUserDefault : : setFloatForKey ( const char * pKey , float value ) <nl> { <nl> + # ifdef KEEP_COMPATABILITY <nl> + deleteNodeByKey ( pKey ) ; <nl> + # endif <nl> + <nl> [ [ NSUserDefaults standardUserDefaults ] setObject : [ NSNumber numberWithFloat : value ] forKey : [ NSString stringWithUTF8String : pKey ] ] ; <nl> } <nl> <nl> void CCUserDefault : : setDoubleForKey ( const char * pKey , double value ) <nl> { <nl> + # ifdef KEEP_COMPATABILITY <nl> + deleteNodeByKey ( pKey ) ; <nl> + # endif <nl> + <nl> [ [ NSUserDefaults standardUserDefaults ] setObject : [ NSNumber numberWithDouble : value ] forKey : [ NSString stringWithUTF8String : pKey ] ] ; <nl> } <nl> <nl> void CCUserDefault : : setStringForKey ( const char * pKey , const std : : string & value ) <nl> { <nl> + # ifdef KEEP_COMPATABILITY <nl> + deleteNodeByKey ( pKey ) ; <nl> + # endif <nl> + <nl> [ [ NSUserDefaults standardUserDefaults ] setObject : [ NSString stringWithUTF8String : value . c_str ( ) ] forKey : [ NSString stringWithUTF8String : pKey ] ] ; <nl> } <nl> <nl> CCUserDefault * CCUserDefault : : sharedUserDefault ( ) <nl> { <nl> + # ifdef KEEP_COMPATABILITY <nl> + initXMLFilePath ( ) ; <nl> + # endif <nl> + <nl> if ( ! m_spUserDefault ) <nl> { <nl> m_spUserDefault = new CCUserDefault ( ) ; <nl> of this software and associated documentation files ( the " Software " ) , to deal <nl> <nl> bool CCUserDefault : : isXMLFileExist ( ) <nl> { <nl> - return false ; <nl> + FILE * fp = fopen ( m_sFilePath . c_str ( ) , " r " ) ; <nl> + bool bRet = false ; <nl> + <nl> + if ( fp ) <nl> + { <nl> + bRet = true ; <nl> + fclose ( fp ) ; <nl> + } <nl> + <nl> + return bRet ; <nl> } <nl> <nl> void CCUserDefault : : initXMLFilePath ( ) <nl> { <nl> - <nl> + # ifdef KEEP_COMPATABILITY <nl> + if ( ! m_sbIsFilePathInitialized ) <nl> + { <nl> + m_sFilePath + = CCFileUtils : : sharedFileUtils ( ) - > getWritablePath ( ) + XML_FILE_NAME ; <nl> + m_sbIsFilePathInitialized = true ; <nl> + } <nl> + # endif <nl> } <nl> <nl> / / create new xml file <nl> bool CCUserDefault : : createXMLFile ( ) <nl> { <nl> - return false ; <nl> + return false ; <nl> } <nl> <nl> const string & CCUserDefault : : getXMLFilePath ( ) <nl> of this software and associated documentation files ( the " Software " ) , to deal <nl> <nl> void CCUserDefault : : flush ( ) <nl> { <nl> + [ [ NSUserDefaults standardUserDefaults ] synchronize ] ; <nl> } <nl> <nl> <nl> mmm a / cocos2dx / support / user_default / CCUserDefaultAndroid . cpp <nl> ppp b / cocos2dx / support / user_default / CCUserDefaultAndroid . cpp <nl> THE SOFTWARE . <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> # include " CCUserDefault . h " <nl> # include " platform / CCPlatformConfig . h " <nl> + # include " platform / CCCommon . h " <nl> <nl> # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_ANDROID ) <nl> # include " platform / android / jni / Java_org_cocos2dx_lib_Cocos2dxHelper . h " <nl> THE SOFTWARE . <nl> / / root name of xml <nl> # define USERDEFAULT_ROOT_NAME " userDefaultRoot " <nl> <nl> + # define KEEP_COMPATABILITY <nl> + <nl> # define XML_FILE_NAME " UserDefault . xml " <nl> <nl> + # ifdef KEEP_COMPATABILITY <nl> + # include " platform / CCFileUtils . h " <nl> + # include " . . / tinyxml2 / tinyxml2 . h " <nl> + # endif <nl> + <nl> using namespace std ; <nl> <nl> NS_CC_BEGIN <nl> CCUserDefault * CCUserDefault : : m_spUserDefault = 0 ; <nl> string CCUserDefault : : m_sFilePath = string ( " " ) ; <nl> bool CCUserDefault : : m_sbIsFilePathInitialized = false ; <nl> <nl> + # ifdef KEEP_COMPATABILITY <nl> + static tinyxml2 : : XMLElement * getXMLNodeForKey ( const char * pKey , tinyxml2 : : XMLDocument * * doc ) <nl> + { <nl> + tinyxml2 : : XMLElement * curNode = NULL ; <nl> + tinyxml2 : : XMLElement * rootNode = NULL ; <nl> + <nl> + if ( ! CCUserDefault : : isXMLFileExist ( ) ) <nl> + { <nl> + return NULL ; <nl> + } <nl> + <nl> + / / check the key value <nl> + if ( ! pKey ) <nl> + { <nl> + return NULL ; <nl> + } <nl> + <nl> + do <nl> + { <nl> + tinyxml2 : : XMLDocument * xmlDoc = new tinyxml2 : : XMLDocument ( ) ; <nl> + * doc = xmlDoc ; <nl> + unsigned long nSize ; <nl> + const char * pXmlBuffer = ( const char * ) CCFileUtils : : sharedFileUtils ( ) - > getFileData ( CCUserDefault : : sharedUserDefault ( ) - > getXMLFilePath ( ) . c_str ( ) , " rb " , & nSize ) ; <nl> + / / const char * pXmlBuffer = ( const char * ) data . getBuffer ( ) ; <nl> + if ( NULL = = pXmlBuffer ) <nl> + { <nl> + CCLOG ( " can not read xml file " ) ; <nl> + break ; <nl> + } <nl> + xmlDoc - > Parse ( pXmlBuffer ) ; <nl> + / / get root node <nl> + rootNode = xmlDoc - > RootElement ( ) ; <nl> + if ( NULL = = rootNode ) <nl> + { <nl> + CCLOG ( " read root node error " ) ; <nl> + break ; <nl> + } <nl> + / / find the node <nl> + curNode = rootNode - > FirstChildElement ( ) ; <nl> + if ( ! curNode ) <nl> + { <nl> + / / There is not xml node , delete xml file . <nl> + remove ( CCUserDefault : : sharedUserDefault ( ) - > getXMLFilePath ( ) . c_str ( ) ) ; <nl> + <nl> + return NULL ; <nl> + } <nl> + <nl> + while ( NULL ! = curNode ) <nl> + { <nl> + const char * nodeName = curNode - > Value ( ) ; <nl> + if ( ! strcmp ( nodeName , pKey ) ) <nl> + { <nl> + / / delete the node <nl> + break ; <nl> + } <nl> + <nl> + curNode = curNode - > NextSiblingElement ( ) ; <nl> + } <nl> + } while ( 0 ) ; <nl> + <nl> + return curNode ; <nl> + } <nl> + <nl> + static void deleteNode ( tinyxml2 : : XMLDocument * doc , tinyxml2 : : XMLElement * node ) <nl> + { <nl> + if ( node ) <nl> + { <nl> + doc - > DeleteNode ( node ) ; <nl> + doc - > SaveFile ( CCUserDefault : : sharedUserDefault ( ) - > getXMLFilePath ( ) . c_str ( ) ) ; <nl> + delete doc ; <nl> + } <nl> + } <nl> + <nl> + static void deleteNodeByKey ( const char * pKey ) <nl> + { <nl> + tinyxml2 : : XMLDocument * doc = NULL ; <nl> + tinyxml2 : : XMLElement * node = getXMLNodeForKey ( pKey , & doc ) ; <nl> + deleteNode ( doc , node ) ; <nl> + } <nl> + # endif <nl> + <nl> / * * <nl> * If the user invoke delete CCUserDefault : : sharedUserDefault ( ) , should set m_spUserDefault <nl> * to null to avoid error when he invoke CCUserDefault : : sharedUserDefault ( ) later . <nl> void CCUserDefault : : purgeSharedUserDefault ( ) <nl> <nl> bool CCUserDefault : : getBoolForKey ( const char * pKey , bool defaultValue ) <nl> { <nl> + # ifdef KEEP_COMPATABILITY <nl> + tinyxml2 : : XMLDocument * doc = NULL ; <nl> + tinyxml2 : : XMLElement * node = getXMLNodeForKey ( pKey , & doc ) ; <nl> + if ( node ) <nl> + { <nl> + if ( node - > FirstChild ( ) ) <nl> + { <nl> + const char * value = ( const char * ) node - > FirstChild ( ) - > Value ( ) ; <nl> + bool ret = ( ! strcmp ( value , " true " ) ) ; <nl> + <nl> + / / set value in NSUserDefaults <nl> + setBoolForKey ( pKey , ret ) ; <nl> + flush ( ) ; <nl> + <nl> + / / delete xmle node <nl> + deleteNode ( doc , node ) ; <nl> + <nl> + return ret ; <nl> + } <nl> + else <nl> + { <nl> + / / delete xmle node <nl> + deleteNode ( doc , node ) ; <nl> + } <nl> + } <nl> + # endif <nl> + <nl> return getBoolForKeyJNI ( pKey , defaultValue ) ; <nl> } <nl> <nl> int CCUserDefault : : getIntegerForKey ( const char * pKey ) <nl> <nl> int CCUserDefault : : getIntegerForKey ( const char * pKey , int defaultValue ) <nl> { <nl> + # ifdef KEEP_COMPATABILITY <nl> + tinyxml2 : : XMLDocument * doc = NULL ; <nl> + tinyxml2 : : XMLElement * node = getXMLNodeForKey ( pKey , & doc ) ; <nl> + if ( node ) <nl> + { <nl> + if ( node - > FirstChild ( ) ) <nl> + { <nl> + int ret = atoi ( ( const char * ) node - > FirstChild ( ) - > Value ( ) ) ; <nl> + <nl> + / / set value in NSUserDefaults <nl> + setIntegerForKey ( pKey , ret ) ; <nl> + flush ( ) ; <nl> + <nl> + / / delete xmle node <nl> + deleteNode ( doc , node ) ; <nl> + <nl> + return ret ; <nl> + } <nl> + else <nl> + { <nl> + / / delete xmle node <nl> + deleteNode ( doc , node ) ; <nl> + } <nl> + } <nl> + # endif <nl> + <nl> return getIntegerForKeyJNI ( pKey , defaultValue ) ; <nl> } <nl> <nl> float CCUserDefault : : getFloatForKey ( const char * pKey ) <nl> <nl> float CCUserDefault : : getFloatForKey ( const char * pKey , float defaultValue ) <nl> { <nl> + # ifdef KEEP_COMPATABILITY <nl> + tinyxml2 : : XMLDocument * doc = NULL ; <nl> + tinyxml2 : : XMLElement * node = getXMLNodeForKey ( pKey , & doc ) ; <nl> + if ( node ) <nl> + { <nl> + if ( node - > FirstChild ( ) ) <nl> + { <nl> + float ret = atof ( ( const char * ) node - > FirstChild ( ) - > Value ( ) ) ; <nl> + <nl> + / / set value in NSUserDefaults <nl> + setFloatForKey ( pKey , ret ) ; <nl> + flush ( ) ; <nl> + <nl> + / / delete xmle node <nl> + deleteNode ( doc , node ) ; <nl> + <nl> + return ret ; <nl> + } <nl> + else <nl> + { <nl> + / / delete xmle node <nl> + deleteNode ( doc , node ) ; <nl> + } <nl> + } <nl> + # endif <nl> + <nl> return getFloatForKeyJNI ( pKey , defaultValue ) ; <nl> } <nl> <nl> double CCUserDefault : : getDoubleForKey ( const char * pKey ) <nl> <nl> double CCUserDefault : : getDoubleForKey ( const char * pKey , double defaultValue ) <nl> { <nl> + # ifdef KEEP_COMPATABILITY <nl> + tinyxml2 : : XMLDocument * doc = NULL ; <nl> + tinyxml2 : : XMLElement * node = getXMLNodeForKey ( pKey , & doc ) ; <nl> + if ( node ) <nl> + { <nl> + if ( node - > FirstChild ( ) ) <nl> + { <nl> + double ret = atof ( ( const char * ) node - > FirstChild ( ) - > Value ( ) ) ; <nl> + <nl> + / / set value in NSUserDefaults <nl> + setDoubleForKey ( pKey , ret ) ; <nl> + flush ( ) ; <nl> + <nl> + / / delete xmle node <nl> + deleteNode ( doc , node ) ; <nl> + <nl> + return ret ; <nl> + } <nl> + else <nl> + { <nl> + / / delete xmle node <nl> + deleteNode ( doc , node ) ; <nl> + } <nl> + } <nl> + # endif <nl> + <nl> return getDoubleForKeyJNI ( pKey , defaultValue ) ; <nl> } <nl> <nl> std : : string CCUserDefault : : getStringForKey ( const char * pKey ) <nl> <nl> string CCUserDefault : : getStringForKey ( const char * pKey , const std : : string & defaultValue ) <nl> { <nl> + # ifdef KEEP_COMPATABILITY <nl> + tinyxml2 : : XMLDocument * doc = NULL ; <nl> + tinyxml2 : : XMLElement * node = getXMLNodeForKey ( pKey , & doc ) ; <nl> + if ( node ) <nl> + { <nl> + if ( node - > FirstChild ( ) ) <nl> + { <nl> + string ret = ( const char * ) node - > FirstChild ( ) - > Value ( ) ; <nl> + <nl> + / / set value in NSUserDefaults <nl> + setStringForKey ( pKey , ret ) ; <nl> + flush ( ) ; <nl> + <nl> + / / delete xmle node <nl> + deleteNode ( doc , node ) ; <nl> + <nl> + return ret ; <nl> + } <nl> + else <nl> + { <nl> + / / delete xmle node <nl> + deleteNode ( doc , node ) ; <nl> + } <nl> + } <nl> + # endif <nl> + <nl> return getStringForKeyJNI ( pKey , defaultValue . c_str ( ) ) ; <nl> } <nl> <nl> void CCUserDefault : : setBoolForKey ( const char * pKey , bool value ) <nl> { <nl> + # ifdef KEEP_COMPATABILITY <nl> + deleteNodeByKey ( pKey ) ; <nl> + # endif <nl> + <nl> return setBoolForKeyJNI ( pKey , value ) ; <nl> } <nl> <nl> void CCUserDefault : : setIntegerForKey ( const char * pKey , int value ) <nl> { <nl> + # ifdef KEEP_COMPATABILITY <nl> + deleteNodeByKey ( pKey ) ; <nl> + # endif <nl> + <nl> return setIntegerForKeyJNI ( pKey , value ) ; <nl> } <nl> <nl> void CCUserDefault : : setFloatForKey ( const char * pKey , float value ) <nl> { <nl> + # ifdef KEEP_COMPATABILITY <nl> + deleteNodeByKey ( pKey ) ; <nl> + # endif <nl> + <nl> return setFloatForKeyJNI ( pKey , value ) ; <nl> } <nl> <nl> void CCUserDefault : : setDoubleForKey ( const char * pKey , double value ) <nl> { <nl> + # ifdef KEEP_COMPATABILITY <nl> + deleteNodeByKey ( pKey ) ; <nl> + # endif <nl> + <nl> return setDoubleForKeyJNI ( pKey , value ) ; <nl> } <nl> <nl> void CCUserDefault : : setStringForKey ( const char * pKey , const std : : string & value ) <nl> { <nl> + # ifdef KEEP_COMPATABILITY <nl> + deleteNodeByKey ( pKey ) ; <nl> + # endif <nl> + <nl> return setStringForKeyJNI ( pKey , value . c_str ( ) ) ; <nl> } <nl> <nl> CCUserDefault * CCUserDefault : : sharedUserDefault ( ) <nl> { <nl> + # ifdef KEEP_COMPATABILITY <nl> + initXMLFilePath ( ) ; <nl> + # endif <nl> + <nl> if ( ! m_spUserDefault ) <nl> { <nl> m_spUserDefault = new CCUserDefault ( ) ; <nl> CCUserDefault * CCUserDefault : : sharedUserDefault ( ) <nl> <nl> bool CCUserDefault : : isXMLFileExist ( ) <nl> { <nl> - return false ; <nl> + FILE * fp = fopen ( m_sFilePath . c_str ( ) , " r " ) ; <nl> + bool bRet = false ; <nl> + <nl> + if ( fp ) <nl> + { <nl> + bRet = true ; <nl> + fclose ( fp ) ; <nl> + } <nl> + <nl> + return bRet ; <nl> } <nl> <nl> void CCUserDefault : : initXMLFilePath ( ) <nl> - { <nl> + { <nl> + # ifdef KEEP_COMPATABILITY <nl> + if ( ! m_sbIsFilePathInitialized ) <nl> + { <nl> + m_sFilePath + = CCFileUtils : : sharedFileUtils ( ) - > getWritablePath ( ) + XML_FILE_NAME ; <nl> + m_sbIsFilePathInitialized = true ; <nl> + } <nl> + # endif <nl> } <nl> <nl> / / create new xml file <nl> bool CCUserDefault : : createXMLFile ( ) <nl> { <nl> - return false ; <nl> + return false ; <nl> } <nl> <nl> const string & CCUserDefault : : getXMLFilePath ( ) <nl>
fixed : make CCUserDefault compatible with previous version on Android and iOS
cocos2d/cocos2d-x
d3aa718b2283f90f3a2a5b939a17afcc41530518
2013-04-08T13:35:43Z
mmm a / src / Storages / RocksDB / StorageEmbeddedRocksDB . cpp <nl> ppp b / src / Storages / RocksDB / StorageEmbeddedRocksDB . cpp <nl> <nl> # include < Storages / RocksDB / EmbeddedRocksDBBlockInputStream . h > <nl> <nl> # include < DataTypes / DataTypesNumber . h > <nl> + <nl> + # include < Storages / SelectQueryInfo . h > <nl> # include < Storages / StorageFactory . h > <nl> <nl> # include < Parsers / ASTSelectQuery . h > <nl>
fixup
ClickHouse/ClickHouse
d54d96701aa9f830f196e50dcf92636b74ad01aa
2020-12-11T15:57:26Z
mmm a / include / swift / Runtime / Metadata . h <nl> ppp b / include / swift / Runtime / Metadata . h <nl> void swift_initStructMetadata ( StructMetadata * self , <nl> / / / members . <nl> SWIFT_RUNTIME_EXPORT <nl> ClassMetadata * <nl> - swift_relocateClassMetadata ( ClassMetadata * self , <nl> - size_t templateSize , <nl> - size_t numImmediateMembers ) ; <nl> + swift_relocateClassMetadata ( ClassDescriptor * descriptor , <nl> + ClassMetadata * pattern , <nl> + size_t patternSize ) ; <nl> <nl> / / / Initialize the field offset vector for a dependent - layout class , using the <nl> / / / " Universal " layout strategy . <nl> mmm a / include / swift / Runtime / RuntimeFunctions . def <nl> ppp b / include / swift / Runtime / RuntimeFunctions . def <nl> FUNCTION ( GetExistentialMetadata , <nl> ProtocolDescriptorRefTy - > getPointerTo ( ) ) , <nl> ATTRS ( NoUnwind , ReadOnly ) ) <nl> <nl> - / / Metadata * swift_relocateClassMetadata ( Metadata * self , <nl> - / / size_t templateSize , <nl> - / / size_t numImmediateMembers ) ; <nl> + / / Metadata * swift_relocateClassMetadata ( TypeContextDescriptor * descriptor , <nl> + / / Metadata * pattern , <nl> + / / size_t patternSize ) ; <nl> FUNCTION ( RelocateClassMetadata , <nl> swift_relocateClassMetadata , C_CC , <nl> RETURNS ( TypeMetadataPtrTy ) , <nl> - ARGS ( TypeMetadataPtrTy , SizeTy , SizeTy ) , <nl> + ARGS ( TypeContextDescriptorPtrTy , TypeMetadataPtrTy , SizeTy ) , <nl> ATTRS ( NoUnwind ) ) <nl> <nl> / / struct FieldInfo { size_t Size ; size_t AlignMask ; } ; <nl> mmm a / lib / IRGen / GenMeta . cpp <nl> ppp b / lib / IRGen / GenMeta . cpp <nl> namespace { <nl> <nl> MetadataDependencyCollector * collector = nullptr ; <nl> <nl> + / / Relocate the metadata . <nl> + llvm : : Value * descriptor = <nl> + IGF . IGM . getAddrOfTypeContextDescriptor ( Target , RequireMetadata ) ; <nl> + auto patternSize = IGM . getSize ( Size ( B . getNextOffsetFromGlobal ( ) ) ) ; <nl> + metadata = IGF . Builder . CreateCall ( IGF . IGM . getRelocateClassMetadataFn ( ) , <nl> + { descriptor , metadata , patternSize } ) ; <nl> + <nl> / / Initialize the superclass if we didn ' t do so as a constant . <nl> if ( HasUnfilledSuperclass ) { <nl> auto superclass = type - > getSuperclass ( ) - > getCanonicalType ( ) ; <nl> this - > emitStoreOfSuperclass ( IGF , superclass , metadata , collector ) ; <nl> } <nl> <nl> - / / Relocate the metadata . <nl> - auto templateSize = IGM . getSize ( Size ( B . getNextOffsetFromGlobal ( ) ) ) ; <nl> - auto numImmediateMembers = IGM . getSize ( <nl> - Size ( IGM . getClassMetadataLayout ( Target ) . getNumImmediateMembers ( ) ) ) ; <nl> - metadata = IGF . Builder . CreateCall ( IGF . IGM . getRelocateClassMetadataFn ( ) , <nl> - { metadata , templateSize , <nl> - numImmediateMembers } ) ; <nl> - <nl> return emitFinishInitializationOfClassMetadata ( IGF , metadata , collector ) ; <nl> } <nl> } ; <nl> mmm a / stdlib / public / runtime / Metadata . cpp <nl> ppp b / stdlib / public / runtime / Metadata . cpp <nl> static MetadataAllocator & getResilientMetadataAllocator ( ) { <nl> # endif <nl> <nl> ClassMetadata * <nl> - swift : : swift_relocateClassMetadata ( ClassMetadata * self , <nl> - size_t templateSize , <nl> - size_t numImmediateMembers ) { <nl> - / / Force the initialization of the metadata layout . <nl> - ( void ) self - > getDescription ( ) - > getMetadataBounds ( ) ; <nl> - <nl> - const ClassMetadata * superclass = self - > Superclass ; <nl> - <nl> - size_t metadataSize ; <nl> - if ( superclass & & superclass - > isTypeMetadata ( ) ) { <nl> - metadataSize = ( superclass - > getClassSize ( ) - <nl> - superclass - > getClassAddressPoint ( ) + <nl> - self - > getClassAddressPoint ( ) + <nl> - numImmediateMembers * sizeof ( void * ) ) ; <nl> - } else { <nl> - metadataSize = ( templateSize + <nl> - numImmediateMembers * sizeof ( void * ) ) ; <nl> - } <nl> - <nl> - if ( templateSize < metadataSize ) { <nl> - auto rawNewClass = ( char * ) malloc ( metadataSize ) ; <nl> - auto rawOldClass = ( const char * ) self ; <nl> - rawOldClass - = self - > getClassAddressPoint ( ) ; <nl> + swift : : swift_relocateClassMetadata ( ClassDescriptor * description , <nl> + ClassMetadata * pattern , <nl> + size_t patternSize ) { <nl> + auto bounds = description - > getMetadataBounds ( ) ; <nl> + auto metadataSize = bounds . getTotalSizeInBytes ( ) ; <nl> <nl> - memcpy ( rawNewClass , rawOldClass , templateSize ) ; <nl> - memset ( rawNewClass + templateSize , 0 , <nl> - metadataSize - templateSize ) ; <nl> + if ( patternSize < metadataSize ) { <nl> + auto bytes = ( char * ) malloc ( metadataSize ) ; <nl> <nl> - rawNewClass + = self - > getClassAddressPoint ( ) ; <nl> - auto * newClass = ( ClassMetadata * ) rawNewClass ; <nl> - newClass - > setClassSize ( metadataSize ) ; <nl> + auto fullPattern = ( const char * ) pattern ; <nl> + fullPattern - = pattern - > getClassAddressPoint ( ) ; <nl> + memcpy ( bytes , fullPattern , patternSize ) ; <nl> + memset ( bytes + patternSize , 0 , <nl> + metadataSize - patternSize ) ; <nl> <nl> - assert ( newClass - > isTypeMetadata ( ) ) ; <nl> + auto addressPoint = bytes + bounds . getAddressPointInBytes ( ) ; <nl> + auto metadata = reinterpret_cast < ClassMetadata * > ( addressPoint ) ; <nl> <nl> - return newClass ; <nl> + metadata - > setClassSize ( metadataSize ) ; <nl> + assert ( metadata - > isTypeMetadata ( ) ) ; <nl> + return metadata ; <nl> } <nl> <nl> - return self ; <nl> + return pattern ; <nl> } <nl> <nl> / / / Initialize the field offset vector for a dependent - layout class , using the <nl> mmm a / test / IRGen / class_resilience . swift <nl> ppp b / test / IRGen / class_resilience . swift <nl> extension ResilientGenericOutsideParent { <nl> <nl> / / CHECK - LABEL : define private void @ initialize_metadata_ResilientChild ( i8 * ) <nl> <nl> + / / Relocate metadata if necessary . . . <nl> + / / CHECK : [ [ METADATA : % . * ] ] = call % swift . type * @ swift_relocateClassMetadata ( % swift . type_descriptor * bitcast ( { { . * } } @ " $ S16class_resilience14ResilientChildCMn " to % swift . type_descriptor * ) , % swift . type * bitcast ( { { . * } } @ " $ S16class_resilience14ResilientChildCMf " , { { . * } } ) , [ [ INT ] ] { { 60 | 96 } } ) <nl> + <nl> / / Initialize the superclass field . . . <nl> / / CHECK : [ [ T0 : % . * ] ] = call swiftcc % swift . metadata_response @ " $ S15resilient_class22ResilientOutsideParentCMa " ( [ [ INT ] ] 1 ) <nl> / / CHECK : [ [ SUPER : % . * ] ] = extractvalue % swift . metadata_response [ [ T0 ] ] , 0 <nl> - / / CHECK : store % swift . type * [ [ SUPER ] ] , % swift . type * * getelementptr inbounds ( { { . * } } ) <nl> - <nl> - / / Relocate metadata if necessary . . . <nl> - / / CHECK : [ [ METADATA : % . * ] ] = call % swift . type * @ swift_relocateClassMetadata ( % swift . type * { { . * } } , [ [ INT ] ] { { 60 | 96 } } , [ [ INT ] ] 4 ) <nl> + / / CHECK : [ [ METADATA_ADDR : % . * ] ] = bitcast % swift . type * [ [ METADATA ] ] to % swift . type * * <nl> + / / CHECK : [ [ SUPER_SLOT : % . * ] ] = getelementptr inbounds % swift . type * , % swift . type * * [ [ METADATA_ADDR ] ] , i32 1 <nl> + / / CHECK : store % swift . type * [ [ SUPER ] ] , % swift . type * * [ [ SUPER_SLOT ] ] <nl> <nl> / / Initialize field offset vector . . . <nl> / / CHECK : [ [ BASE : % . * ] ] = load [ [ INT ] ] , [ [ INT ] ] * getelementptr inbounds ( [ [ BOUNDS ] ] , [ [ BOUNDS ] ] * @ " $ S16class_resilience14ResilientChildCMo " , i32 0 , i32 0 ) <nl> extension ResilientGenericOutsideParent { <nl> <nl> / / CHECK - LABEL : define private void @ initialize_metadata_FixedLayoutChild ( i8 * ) <nl> <nl> + / / Relocate metadata if necessary . . . <nl> + / / CHECK : call % swift . type * @ swift_relocateClassMetadata ( % swift . type_descriptor * { { . * } } , % swift . type * { { . * } } , [ [ INT ] ] { { 60 | 96 } } ) <nl> + <nl> / / Initialize the superclass field . . . <nl> / / CHECK : [ [ T0 : % . * ] ] = call swiftcc % swift . metadata_response @ " $ S15resilient_class22ResilientOutsideParentCMa " ( [ [ INT ] ] 1 ) <nl> / / CHECK : [ [ SUPER : % . * ] ] = extractvalue % swift . metadata_response [ [ T0 ] ] , 0 <nl> - / / CHECK : store % swift . type * [ [ SUPER ] ] , % swift . type * * getelementptr inbounds ( { { . * } } ) <nl> - <nl> - / / Relocate metadata if necessary . . . <nl> - / / CHECK : call % swift . type * @ swift_relocateClassMetadata ( % swift . type * { { . * } } , [ [ INT ] ] { { 60 | 96 } } , [ [ INT ] ] 4 ) <nl> + / / CHECK : [ [ METADATA_ADDR : % . * ] ] = bitcast % swift . type * [ [ METADATA ] ] to % swift . type * * <nl> + / / CHECK : [ [ SUPER_SLOT : % . * ] ] = getelementptr inbounds % swift . type * , % swift . type * * [ [ METADATA_ADDR ] ] , i32 1 <nl> + / / CHECK : store % swift . type * [ [ SUPER ] ] , % swift . type * * [ [ SUPER_SLOT ] ] <nl> <nl> + / / CHECK : call void @ swift_initClassMetadata ( % swift . type * [ [ METADATA ] ] , [ [ INT ] ] 0 , [ [ INT ] ] 1 , i8 * * * { { % . * } } , [ [ INT ] ] * { { % . * } } ) <nl> / / CHECK : ret void <nl> <nl> <nl>
Runtime : swift_relocateClassMetadata ( ) calculates metadata bounds from the class descriptor
apple/swift
3256ee43c06fae757de8404e45bdf1445ecc7adb
2018-08-20T23:23:07Z
mmm a / conformance / Makefile . am <nl> ppp b / conformance / Makefile . am <nl> protoc_outputs = \ <nl> conformance . pb . h <nl> <nl> other_language_protoc_outputs = \ <nl> + conformance_pb2 . py \ <nl> + Conformance . pbobjc . h \ <nl> + Conformance . pbobjc . m \ <nl> conformance . rb \ <nl> + com / google / protobuf / Any . java \ <nl> + com / google / protobuf / AnyOrBuilder . java \ <nl> + com / google / protobuf / AnyProto . java \ <nl> + com / google / protobuf / BoolValue . java \ <nl> + com / google / protobuf / BoolValueOrBuilder . java \ <nl> + com / google / protobuf / BytesValue . java \ <nl> + com / google / protobuf / BytesValueOrBuilder . java \ <nl> com / google / protobuf / conformance / Conformance . java \ <nl> + com / google / protobuf / DoubleValue . java \ <nl> + com / google / protobuf / DoubleValueOrBuilder . java \ <nl> + com / google / protobuf / Duration . java \ <nl> + com / google / protobuf / DurationOrBuilder . java \ <nl> + com / google / protobuf / DurationProto . java \ <nl> + com / google / protobuf / FieldMask . java \ <nl> + com / google / protobuf / FieldMaskOrBuilder . java \ <nl> + com / google / protobuf / FieldMaskProto . java \ <nl> + com / google / protobuf / FloatValue . java \ <nl> + com / google / protobuf / FloatValueOrBuilder . java \ <nl> + com / google / protobuf / Int32Value . java \ <nl> + com / google / protobuf / Int32ValueOrBuilder . java \ <nl> + com / google / protobuf / Int64Value . java \ <nl> + com / google / protobuf / Int64ValueOrBuilder . java \ <nl> + com / google / protobuf / ListValue . java \ <nl> + com / google / protobuf / ListValueOrBuilder . java \ <nl> + com / google / protobuf / NullValue . java \ <nl> + com / google / protobuf / StringValue . java \ <nl> + com / google / protobuf / StringValueOrBuilder . java \ <nl> + com / google / protobuf / Struct . java \ <nl> + com / google / protobuf / StructOrBuilder . java \ <nl> + com / google / protobuf / StructProto . java \ <nl> + com / google / protobuf / Timestamp . java \ <nl> + com / google / protobuf / TimestampOrBuilder . java \ <nl> + com / google / protobuf / TimestampProto . java \ <nl> + com / google / protobuf / UInt32Value . java \ <nl> + com / google / protobuf / UInt32ValueOrBuilder . java \ <nl> + com / google / protobuf / UInt64Value . java \ <nl> + com / google / protobuf / UInt64ValueOrBuilder . java \ <nl> + com / google / protobuf / Value . java \ <nl> + com / google / protobuf / ValueOrBuilder . java \ <nl> + com / google / protobuf / WrappersProto . java \ <nl> + google / protobuf / any . pb . cc \ <nl> + google / protobuf / any . pb . h \ <nl> + google / protobuf / any . rb \ <nl> + google / protobuf / any_pb2 . py \ <nl> + google / protobuf / duration . pb . cc \ <nl> + google / protobuf / duration . pb . h \ <nl> + google / protobuf / duration . rb \ <nl> + google / protobuf / duration_pb2 . py \ <nl> + google / protobuf / field_mask . pb . cc \ <nl> + google / protobuf / field_mask . pb . h \ <nl> + google / protobuf / field_mask . rb \ <nl> + google / protobuf / field_mask_pb2 . py \ <nl> + google / protobuf / struct . pb . cc \ <nl> + google / protobuf / struct . pb . h \ <nl> + google / protobuf / struct . rb \ <nl> + google / protobuf / struct_pb2 . py \ <nl> + google / protobuf / timestamp . pb . cc \ <nl> + google / protobuf / timestamp . pb . h \ <nl> + google / protobuf / timestamp . rb \ <nl> + google / protobuf / timestamp_pb2 . py \ <nl> + google / protobuf / wrappers . pb . cc \ <nl> + google / protobuf / wrappers . pb . h \ <nl> + google / protobuf / wrappers . rb \ <nl> + google / protobuf / wrappers_pb2 . py \ <nl> + lite / com / google / protobuf / Any . java \ <nl> + lite / com / google / protobuf / AnyOrBuilder . java \ <nl> + lite / com / google / protobuf / AnyProto . java \ <nl> + lite / com / google / protobuf / BoolValue . java \ <nl> + lite / com / google / protobuf / BoolValueOrBuilder . java \ <nl> + lite / com / google / protobuf / BytesValue . java \ <nl> + lite / com / google / protobuf / BytesValueOrBuilder . java \ <nl> lite / com / google / protobuf / conformance / Conformance . java \ <nl> - conformance_pb2 . py \ <nl> - Conformance . pbobjc . h \ <nl> - Conformance . pbobjc . m <nl> + lite / com / google / protobuf / DoubleValue . java \ <nl> + lite / com / google / protobuf / DoubleValueOrBuilder . java \ <nl> + lite / com / google / protobuf / Duration . java \ <nl> + lite / com / google / protobuf / DurationOrBuilder . java \ <nl> + lite / com / google / protobuf / DurationProto . java \ <nl> + lite / com / google / protobuf / FieldMask . java \ <nl> + lite / com / google / protobuf / FieldMaskOrBuilder . java \ <nl> + lite / com / google / protobuf / FieldMaskProto . java \ <nl> + lite / com / google / protobuf / FloatValue . java \ <nl> + lite / com / google / protobuf / FloatValueOrBuilder . java \ <nl> + lite / com / google / protobuf / Int32Value . java \ <nl> + lite / com / google / protobuf / Int32ValueOrBuilder . java \ <nl> + lite / com / google / protobuf / Int64Value . java \ <nl> + lite / com / google / protobuf / Int64ValueOrBuilder . java \ <nl> + lite / com / google / protobuf / ListValue . java \ <nl> + lite / com / google / protobuf / ListValueOrBuilder . java \ <nl> + lite / com / google / protobuf / NullValue . java \ <nl> + lite / com / google / protobuf / StringValue . java \ <nl> + lite / com / google / protobuf / StringValueOrBuilder . java \ <nl> + lite / com / google / protobuf / Struct . java \ <nl> + lite / com / google / protobuf / StructOrBuilder . java \ <nl> + lite / com / google / protobuf / StructProto . java \ <nl> + lite / com / google / protobuf / Timestamp . java \ <nl> + lite / com / google / protobuf / TimestampOrBuilder . java \ <nl> + lite / com / google / protobuf / TimestampProto . java \ <nl> + lite / com / google / protobuf / UInt32Value . java \ <nl> + lite / com / google / protobuf / UInt32ValueOrBuilder . java \ <nl> + lite / com / google / protobuf / UInt64Value . java \ <nl> + lite / com / google / protobuf / UInt64ValueOrBuilder . java \ <nl> + lite / com / google / protobuf / Value . java \ <nl> + lite / com / google / protobuf / ValueOrBuilder . java \ <nl> + lite / com / google / protobuf / WrappersProto . java <nl> <nl> bin_PROGRAMS = conformance - test - runner conformance - cpp <nl> <nl>
Properly express all outputs for the conformance build
protocolbuffers/protobuf
ce2ef0d7055cbf03ae585b7131db166a4727c555
2016-05-06T16:41:23Z
mmm a / tensorflow / compiler / xla / service / gpu / multi_output_fusion . cc <nl> ppp b / tensorflow / compiler / xla / service / gpu / multi_output_fusion . cc <nl> limitations under the License . <nl> # include < string > <nl> # include < utility > <nl> <nl> + # include " tensorflow / compiler / xla / layout_util . h " <nl> # include " tensorflow / compiler / xla / service / gpu / ir_emission_utils . h " <nl> # include " tensorflow / compiler / xla / service / hlo_instruction . h " <nl> # include " tensorflow / compiler / xla / service / hlo_opcode . h " <nl> bool GpuMultiOutputFusion : : ShapesCompatibleForFusion ( HloInstruction * instr1 , <nl> / / In that case , the operand of the reduce needs to have the same shape <nl> / / as the other tuple operands , but also we need to compare the output <nl> / / shapes of the reduces . <nl> - / / TODO ( tjoerg ) : Allow differences in fp precision . <nl> auto * element_instr_1 = get_element_instr ( instr1 ) ; <nl> auto * element_instr_2 = get_element_instr ( instr2 ) ; <nl> if ( element_instr_1 - > opcode ( ) = = HloOpcode : : kReduce & & <nl> bool GpuMultiOutputFusion : : ShapesCompatibleForFusion ( HloInstruction * instr1 , <nl> return false ; <nl> } <nl> / / The elementwise output shapes must be the same ( including layout ) . <nl> - return ShapeUtil : : Equal ( get_element_shape ( element_instr_1 ) , <nl> - get_element_shape ( element_instr_2 ) ) ; <nl> + return ShapeUtil : : EqualIgnoringFpPrecision ( <nl> + get_element_shape ( element_instr_1 ) , get_element_shape ( element_instr_2 ) ) ; <nl> } <nl> <nl> namespace { <nl> bool IsInputFusibleReduction ( HloInstruction * instr ) { <nl> return IsReductionToVector ( * instr ) ; <nl> } <nl> } <nl> + <nl> + / / The code emitted for reduction suffers from poor data locality if the layouts <nl> + / / of input parameters differ . In such situtations it is beneficial not to fuse . <nl> + / / We consider input params with maximum rank only . Params with smaller ranks <nl> + / / will be broadcasted and have not been observed to cause data locality issues . <nl> + / / TODO ( b / 110927656 ) : Improve reduce emitters to remove this limitation . <nl> + bool ReduceFriendlyInputLayouts ( HloInstruction * instr ) { <nl> + int64 max_rank = 0 ; <nl> + const Layout * max_rank_layout ; <nl> + for ( HloInstruction * param : instr - > fused_parameters ( ) ) { <nl> + if ( ShapeUtil : : Rank ( param - > shape ( ) ) > max_rank ) { <nl> + max_rank = ShapeUtil : : Rank ( param - > shape ( ) ) ; <nl> + max_rank_layout = & param - > shape ( ) . layout ( ) ; <nl> + } <nl> + } <nl> + return c_all_of ( instr - > fused_parameters ( ) , [ & ] ( HloInstruction * param ) { <nl> + return ( ShapeUtil : : Rank ( param - > shape ( ) ) < max_rank ) | | <nl> + ( LayoutUtil : : Equal ( param - > shape ( ) . layout ( ) , * max_rank_layout ) ) ; <nl> + } ) ; <nl> + } <nl> + <nl> } / / namespace <nl> <nl> bool GpuMultiOutputFusion : : IsFusible ( HloInstruction * instr ) { <nl> bool GpuMultiOutputFusion : : DoProducerConsumerMultiOutputFusion ( ) { <nl> / / fusions operands . <nl> for ( HloInstruction * consumer : computation ( ) - > MakeInstructionPostOrder ( ) ) { <nl> if ( consumer - > user_count ( ) = = 0 ) { <nl> + VLOG ( 3 ) < < consumer - > name ( ) < < " has no users . " ; <nl> continue ; <nl> } <nl> if ( ! IsInputFusibleReduction ( consumer ) ) { <nl> + VLOG ( 3 ) < < consumer - > name ( ) < < " is not an input - fusable reduction . " ; <nl> continue ; <nl> } <nl> + VLOG ( 3 ) < < consumer - > name ( ) <nl> + < < " is a fusion candidate . Looking for fuseable operands . " ; <nl> <nl> auto consumer_operands = consumer - > operands ( ) ; <nl> for ( size_t i = 0 ; i < consumer_operands . size ( ) ; + + i ) { <nl> HloInstruction * producer = consumer_operands [ i ] ; <nl> if ( ! producer - > IsFusable ( ) ) { <nl> + VLOG ( 3 ) < < producer - > name ( ) < < " is not fusable . " ; <nl> continue ; <nl> } <nl> const bool is_loop_fusion = <nl> producer - > opcode ( ) = = HloOpcode : : kFusion & & <nl> producer - > fusion_kind ( ) = = HloInstruction : : FusionKind : : kLoop ; <nl> if ( ! is_loop_fusion ) { <nl> + VLOG ( 3 ) < < producer - > name ( ) < < " is not a loop fusion . " ; <nl> continue ; <nl> } <nl> if ( ! ShapesCompatibleForFusion ( producer , consumer ) ) { <nl> + VLOG ( 3 ) < < producer - > name ( ) < < " has an incompatible shape . " ; <nl> + continue ; <nl> + } <nl> + if ( ! ReduceFriendlyInputLayouts ( producer ) ) { <nl> + VLOG ( 3 ) < < producer - > name ( ) < < " has inputs with mixed layouts . " ; <nl> continue ; <nl> } <nl> / / If we have already decided to fuse this producer , skip it . <nl> if ( ContainsKey ( to_fuse , producer ) ) { <nl> + VLOG ( 3 ) < < producer - > name ( ) < < " will be fused with another consumer . " ; <nl> continue ; <nl> } <nl> / / Do not fuse a producer if the other operands of the fusion are <nl> bool GpuMultiOutputFusion : : DoProducerConsumerMultiOutputFusion ( ) { <nl> return producer ! = operand & & <nl> reachability ( ) - > IsReachable ( producer , operand ) ; <nl> } ) ) { <nl> + VLOG ( 3 ) < < producer - > name ( ) < < " would introduce a cycle when fused . " ; <nl> break ; <nl> } <nl> to_fuse . insert ( producer ) ; <nl> mmm a / tensorflow / compiler / xla / service / gpu / multi_output_fusion_test . cc <nl> ppp b / tensorflow / compiler / xla / service / gpu / multi_output_fusion_test . cc <nl> TEST_F ( MultiOutputFusionTest , ProducerConsumerFusionDoNotFuseLoopReduceFusion ) { <nl> ASSERT_FALSE ( GpuMultiOutputFusion ( ) . Run ( module . get ( ) ) . ValueOrDie ( ) ) ; <nl> } <nl> <nl> + TEST_F ( MultiOutputFusionTest , <nl> + ProducerConsumerFusionFp16LoopFusionAndReduceFusion ) { <nl> + auto module = ParseHloString ( tensorflow : : strings : : StrCat ( kModulePrefix , R " ( <nl> + fused_select { <nl> + p1 . 1 = f16 [ 2 , 2 , 2 ] { 2 , 1 , 0 } parameter ( 1 ) <nl> + c0 = f16 [ ] constant ( 0 ) <nl> + broadcast = f16 [ 2 , 2 , 2 ] { 2 , 1 , 0 } broadcast ( f16 [ ] c0 ) , dimensions = { } <nl> + greater - than = pred [ 2 , 2 , 2 ] { 2 , 1 , 0 } greater - than ( f32 [ 2 , 2 , 2 ] { 2 , 1 , 0 } p1 . 1 , f32 [ 2 , 2 , 2 ] { 2 , 1 , 0 } broadcast ) <nl> + p0 . 1 = f16 [ 2 , 2 , 2 ] { 2 , 1 , 0 } parameter ( 0 ) <nl> + ROOT select = f16 [ 2 , 2 , 2 ] { 2 , 1 , 0 } select ( pred [ 2 , 2 , 2 ] { 2 , 1 , 0 } greater - than , f16 [ 2 , 2 , 2 ] { 2 , 1 , 0 } p0 . 1 , f16 [ 2 , 2 , 2 ] { 2 , 1 , 0 } broadcast ) <nl> + } <nl> + fused_reduce { <nl> + p0 . 2 = f16 [ 2 , 2 , 2 ] { 2 , 1 , 0 } parameter ( 0 ) <nl> + convert = f32 [ 2 , 2 , 2 ] { 2 , 1 , 0 } convert ( p0 . 2 ) <nl> + c1 = f32 [ ] constant ( 0 ) <nl> + r1 = f32 [ 2 , 2 ] { 1 , 0 } reduce ( convert , c1 ) , dimensions = { 2 } , to_apply = scalar_add_computation <nl> + mul = f32 [ 2 , 2 , 2 ] { 2 , 1 , 0 } multiply ( convert , convert ) <nl> + r2 = f32 [ 2 , 2 ] { 1 , 0 } reduce ( mul , c1 ) , dimensions = { 2 } , to_apply = scalar_add_computation <nl> + ROOT tuple = ( f32 [ 2 , 2 ] { 1 , 0 } , f32 [ 2 , 2 ] { 1 , 0 } ) tuple ( r1 , r2 ) <nl> + } <nl> + ENTRY reduce { <nl> + p0 = f16 [ 2 , 2 , 2 ] { 2 , 1 , 0 } parameter ( 0 ) <nl> + p1 = f16 [ 2 , 2 , 2 ] { 2 , 1 , 0 } parameter ( 1 ) <nl> + select = f16 [ 2 , 2 , 2 ] { 2 , 1 , 0 } fusion ( p0 , p1 ) , kind = kLoop , calls = fused_select <nl> + fusion = ( f32 [ 2 , 2 ] { 1 , 0 } , f32 [ 2 , 2 ] { 1 , 0 } ) fusion ( select ) , kind = kInput , calls = fused_reduce <nl> + gte0 = f32 [ 2 , 2 ] { 1 , 0 } get - tuple - element ( fusion ) , index = 0 <nl> + gte1 = f32 [ 2 , 2 ] { 1 , 0 } get - tuple - element ( fusion ) , index = 1 <nl> + ROOT root = ( f32 [ 2 , 2 ] { 1 , 0 } , f32 [ 2 , 2 ] { 1 , 0 } , f16 [ 2 , 2 , 2 ] { 2 , 1 , 0 } ) tuple ( gte1 , gte1 , select ) <nl> + } ) " ) ) <nl> + . ValueOrDie ( ) ; <nl> + ASSERT_TRUE ( GpuMultiOutputFusion ( ) . Run ( module . get ( ) ) . ValueOrDie ( ) ) ; <nl> + SCOPED_TRACE ( module - > ToString ( ) ) ; <nl> + const HloInstruction * root = module - > entry_computation ( ) - > root_instruction ( ) ; <nl> + EXPECT_THAT ( root , op : : Tuple ( op : : GetTupleElement ( ) , op : : GetTupleElement ( ) , <nl> + op : : GetTupleElement ( ) ) ) ; <nl> + const HloInstruction * fusion = root - > operand ( 0 ) - > operand ( 0 ) ; <nl> + ASSERT_TRUE ( fusion - > IsMultiOutputFusion ( ) ) ; <nl> + EXPECT_THAT ( fusion - > fused_expression_root ( ) , <nl> + op : : Tuple ( op : : Reduce ( ) , op : : Reduce ( ) , op : : Select ( ) ) ) ; <nl> + } <nl> + <nl> + TEST_F ( MultiOutputFusionTest , <nl> + ProducerConsumerFusionReduceUnfriendlyLoopFusion ) { <nl> + auto module = ParseHloString ( tensorflow : : strings : : StrCat ( kModulePrefix , R " ( <nl> + mixed_input_layouts_computation { <nl> + p0 . 1 = f16 [ 128 , 1024 , 32 , 32 ] { 1 , 3 , 2 , 0 } parameter ( 0 ) <nl> + p1 . 1 = f16 [ 128 , 1024 , 32 , 32 ] { 3 , 2 , 1 , 0 } parameter ( 1 ) <nl> + copy = f16 [ 128 , 1024 , 32 , 32 ] { 1 , 3 , 2 , 0 } copy ( p1 . 1 ) <nl> + c0 = f16 [ ] constant ( 0 ) <nl> + broadcast = f16 [ 128 , 1024 , 32 , 32 ] { 1 , 3 , 2 , 0 } broadcast ( c0 ) , dimensions = { } <nl> + greater - than = pred [ 128 , 1024 , 32 , 32 ] { 1 , 3 , 2 , 0 } greater - than ( copy , broadcast ) <nl> + ROOT root = f16 [ 128 , 1024 , 32 , 32 ] { 1 , 3 , 2 , 0 } select ( greater - than , p0 . 1 , broadcast ) <nl> + } <nl> + fused_reduce { <nl> + p0 . 2 = f16 [ 128 , 1024 , 32 , 32 ] { 1 , 3 , 2 , 0 } parameter ( 0 ) <nl> + convert = f32 [ 128 , 1024 , 32 , 32 ] { 1 , 3 , 2 , 0 } convert ( p0 . 2 ) <nl> + c0 . 2 = f32 [ ] constant ( 0 ) <nl> + ROOT reduce = f32 [ 1024 ] { 0 } reduce ( convert , c0 . 2 ) , dimensions = { 0 , 2 , 3 } , to_apply = scalar_add_computation <nl> + } <nl> + ENTRY reduce { <nl> + p0 = f16 [ 128 , 1024 , 32 , 32 ] { 3 , 2 , 1 , 0 } parameter ( 0 ) <nl> + p1 = f16 [ 128 , 1024 , 32 , 32 ] { 1 , 3 , 2 , 0 } parameter ( 1 ) <nl> + loop_fusion = f16 [ 128 , 1024 , 32 , 32 ] { 1 , 3 , 2 , 0 } fusion ( p0 , p1 ) , kind = kLoop , calls = mixed_input_layouts_computation <nl> + reduce_fusion = f32 [ 1024 ] { 0 } fusion ( loop_fusion ) , kind = kInput , calls = fused_reduce <nl> + ROOT root = ( f32 [ 1024 ] { 0 } , f16 [ 128 , 1024 , 32 , 32 ] { 1 , 3 , 2 , 0 } ) tuple ( reduce_fusion , loop_fusion ) <nl> + } ) " ) ) <nl> + . ValueOrDie ( ) ; <nl> + ASSERT_FALSE ( GpuMultiOutputFusion ( ) . Run ( module . get ( ) ) . ValueOrDie ( ) ) ; <nl> + } <nl> + <nl> } / / namespace gpu <nl> } / / namespace xla <nl>
[ XLA : GPU ] Ignore fp precision for multi - output fusion .
tensorflow/tensorflow
68353db31b981057d612a46571ee244a2aca6840
2018-07-19T12:26:31Z
mmm a / docs / CHANGELOG . txt <nl> ppp b / docs / CHANGELOG . txt <nl> HOW TO UPDATE ? <nl> VERSION 1 . 69 ( In Progress ) <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> + Breaking Changes : <nl> + <nl> + - Renamed ColorEdit / ColorPicker ' s ImGuiColorEditFlags_RGB / _HSV / _HEX flags to respectively <nl> + ImGuiColorEditFlags_DisplayRGB / _DisplayHSV / _DisplayHex . This is anticipation of adding new <nl> + flags to ColorEdit / ColorPicker functions which would make those ambiguous . ( # 2384 ) [ @ haldean ] <nl> + <nl> Other Changes : <nl> <nl> - Nav : Fixed a tap on AltGR ( e . g . German keyboard ) from navigation to the menu layer . <nl> mmm a / imgui . cpp <nl> ppp b / imgui . cpp <nl> CODE <nl> When you are not sure about a old symbol or function name , try using the Search / Find function of your IDE to look for comments or references in all imgui files . <nl> You can read releases logs https : / / github . com / ocornut / imgui / releases for more details . <nl> <nl> + - 2019 / 02 / 26 ( 1 . 69 ) - renamed ImGuiColorEditFlags_RGB / ImGuiColorEditFlags_HSV / ImGuiColorEditFlags_HEX to ImGuiColorEditFlags_DisplayRGB / ImGuiColorEditFlags_DisplayHSV / ImGuiColorEditFlags_DisplayHex . Kept redirection enums ( will obsolete ) . <nl> - 2019 / 02 / 14 ( 1 . 68 ) - made it illegal / assert when io . DisplayTime = = 0 . 0f ( with an exception for the first frame ) . If for some reason your time step calculation gives you a zero value , replace it with a dummy small value ! <nl> - 2019 / 02 / 01 ( 1 . 68 ) - removed io . DisplayVisibleMin / DisplayVisibleMax ( which were marked obsolete and removed from viewport / docking branch already ) . <nl> - 2019 / 01 / 06 ( 1 . 67 ) - renamed io . InputCharacters [ ] , marked internal as was always intended . Please don ' t access directly , and use AddInputCharacter ( ) instead ! <nl> mmm a / imgui . h <nl> ppp b / imgui . h <nl> enum ImGuiStyleVar_ <nl> enum ImGuiColorEditFlags_ <nl> { <nl> ImGuiColorEditFlags_None = 0 , <nl> - ImGuiColorEditFlags_NoAlpha = 1 < < 1 , / / / / ColorEdit , ColorPicker , ColorButton : ignore Alpha component ( read 3 components from the input pointer ) . <nl> + ImGuiColorEditFlags_NoAlpha = 1 < < 1 , / / / / ColorEdit , ColorPicker , ColorButton : ignore Alpha component ( will only read 3 components from the input pointer ) . <nl> ImGuiColorEditFlags_NoPicker = 1 < < 2 , / / / / ColorEdit : disable picker when clicking on colored square . <nl> ImGuiColorEditFlags_NoOptions = 1 < < 3 , / / / / ColorEdit : disable toggling options menu when right - clicking on inputs / small preview . <nl> ImGuiColorEditFlags_NoSmallPreview = 1 < < 4 , / / / / ColorEdit , ColorPicker : disable colored square preview next to the inputs . ( e . g . to show only the inputs ) <nl> enum ImGuiColorEditFlags_ <nl> ImGuiColorEditFlags_NoSidePreview = 1 < < 8 , / / / / ColorPicker : disable bigger color preview on right side of the picker , use small colored square preview instead . <nl> ImGuiColorEditFlags_NoDragDrop = 1 < < 9 , / / / / ColorEdit : disable drag and drop target . ColorButton : disable drag and drop source . <nl> <nl> - / / User Options ( right - click on widget to change some of them ) . You can set application defaults using SetColorEditOptions ( ) . The idea is that you probably don ' t want to override them in most of your calls , let the user choose and / or call SetColorEditOptions ( ) during startup . <nl> + / / User Options ( right - click on widget to change some of them ) . You can set application defaults using SetColorEditOptions ( ) . <nl> + / / The intent is that you probably don ' t want to override them in most of your calls , let the user choose via the option menu and / or call SetColorEditOptions ( ) during startup . <nl> ImGuiColorEditFlags_AlphaBar = 1 < < 16 , / / / / ColorEdit , ColorPicker : show vertical alpha bar / gradient in picker . <nl> ImGuiColorEditFlags_AlphaPreview = 1 < < 17 , / / / / ColorEdit , ColorPicker , ColorButton : display preview as a transparent color over a checkerboard , instead of opaque . <nl> ImGuiColorEditFlags_AlphaPreviewHalf = 1 < < 18 , / / / / ColorEdit , ColorPicker , ColorButton : display half opaque / half checkerboard , instead of opaque . <nl> ImGuiColorEditFlags_HDR = 1 < < 19 , / / / / ( WIP ) ColorEdit : Currently only disable 0 . 0f . . 1 . 0f limits in RGBA edition ( note : you probably want to use ImGuiColorEditFlags_Float flag as well ) . <nl> - ImGuiColorEditFlags_ShowRGB = 1 < < 20 , / / [ Show ] / / ColorEdit : choose one among RGB / HSV / HEX . ColorPicker : choose any combination using RGB / HSV / HEX . <nl> - ImGuiColorEditFlags_ShowHSV = 1 < < 21 , / / [ Show ] / / " <nl> - ImGuiColorEditFlags_ShowHEX = 1 < < 22 , / / [ Show ] / / " <nl> + ImGuiColorEditFlags_DisplayRGB = 1 < < 20 , / / [ Display ] / / ColorEdit : override _display_ type among RGB / HSV / Hex . ColorPicker : select any combination using one or more of RGB / HSV / Hex . <nl> + ImGuiColorEditFlags_DisplayHSV = 1 < < 21 , / / [ Display ] / / " <nl> + ImGuiColorEditFlags_DisplayHex = 1 < < 22 , / / [ Display ] / / " <nl> ImGuiColorEditFlags_Uint8 = 1 < < 23 , / / [ DataType ] / / ColorEdit , ColorPicker , ColorButton : _display_ values formatted as 0 . . 255 . <nl> ImGuiColorEditFlags_Float = 1 < < 24 , / / [ DataType ] / / ColorEdit , ColorPicker , ColorButton : _display_ values formatted as 0 . 0f . . 1 . 0f floats instead of 0 . . 255 integers . No round - trip of value via integers . <nl> ImGuiColorEditFlags_PickerHueBar = 1 < < 25 , / / [ PickerMode ] / / ColorPicker : bar for Hue , rectangle for Sat / Value . <nl> ImGuiColorEditFlags_PickerHueWheel = 1 < < 26 , / / [ PickerMode ] / / ColorPicker : wheel for Hue , triangle for Sat / Value . <nl> - / / Obsolete names ( will be removed ) <nl> - # ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS <nl> - ImGuiColorEditFlags_RGB = ImGuiColorEditFlags_ShowRGB , ImGuiColorEditFlags_HSV = ImGuiColorEditFlags_ShowHSV , ImGuiColorEditFlags_HEX = ImGuiColorEditFlags_ShowHEX , <nl> - # endif <nl> <nl> / / [ Internal ] Masks <nl> - ImGuiColorEditFlags__ShowMask = ImGuiColorEditFlags_ShowRGB | ImGuiColorEditFlags_ShowHSV | ImGuiColorEditFlags_ShowHEX , <nl> + ImGuiColorEditFlags__DisplayMask = ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_DisplayHSV | ImGuiColorEditFlags_DisplayHex , <nl> ImGuiColorEditFlags__DataTypeMask = ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_Float , <nl> ImGuiColorEditFlags__PickerMask = ImGuiColorEditFlags_PickerHueWheel | ImGuiColorEditFlags_PickerHueBar , <nl> - ImGuiColorEditFlags__OptionsDefault = ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_ShowRGB | ImGuiColorEditFlags_PickerHueBar / / Change application default using SetColorEditOptions ( ) <nl> + ImGuiColorEditFlags__OptionsDefault = ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_PickerHueBar / / Change application default using SetColorEditOptions ( ) <nl> + <nl> + / / Obsolete names ( will be removed ) <nl> + # ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS <nl> + , ImGuiColorEditFlags_RGB = ImGuiColorEditFlags_DisplayRGB , ImGuiColorEditFlags_HSV = ImGuiColorEditFlags_DisplayHSV , ImGuiColorEditFlags_HEX = ImGuiColorEditFlags_DisplayHex <nl> + # endif <nl> } ; <nl> <nl> / / Enumeration for GetMouseCursor ( ) <nl> mmm a / imgui_demo . cpp <nl> ppp b / imgui_demo . cpp <nl> static void ShowDemoWindowWidgets ( ) <nl> ImGui : : ColorEdit3 ( " MyColor # # 1 " , ( float * ) & color , misc_flags ) ; <nl> <nl> ImGui : : Text ( " Color widget HSV with Alpha : " ) ; <nl> - ImGui : : ColorEdit4 ( " MyColor # # 2 " , ( float * ) & color , ImGuiColorEditFlags_ShowHSV | misc_flags ) ; <nl> + ImGui : : ColorEdit4 ( " MyColor # # 2 " , ( float * ) & color , ImGuiColorEditFlags_DisplayHSV | misc_flags ) ; <nl> <nl> ImGui : : Text ( " Color widget with Float Display : " ) ; <nl> ImGui : : ColorEdit4 ( " MyColor # # 2f " , ( float * ) & color , ImGuiColorEditFlags_Float | misc_flags ) ; <nl> static void ShowDemoWindowWidgets ( ) <nl> static bool side_preview = true ; <nl> static bool ref_color = false ; <nl> static ImVec4 ref_color_v ( 1 . 0f , 0 . 0f , 1 . 0f , 0 . 5f ) ; <nl> - static int show_mode = 2 ; <nl> + static int display_mode = 0 ; <nl> static int picker_mode = 0 ; <nl> ImGui : : Checkbox ( " With Alpha " , & alpha ) ; <nl> ImGui : : Checkbox ( " With Alpha Bar " , & alpha_bar ) ; <nl> static void ShowDemoWindowWidgets ( ) <nl> ImGui : : ColorEdit4 ( " # # RefColor " , & ref_color_v . x , ImGuiColorEditFlags_NoInputs | misc_flags ) ; <nl> } <nl> } <nl> - ImGui : : Combo ( " Show Mode " , & show_mode , " All \ 0None \ 0Show RGB \ 0Show HSV \ 0Show HEX \ 0 " ) ; <nl> + ImGui : : Combo ( " Display Mode " , & display_mode , " Auto / Current \ 0None \ 0RGB Only \ 0HSV Only \ 0Hex Only \ 0 " ) ; <nl> + ImGui : : SameLine ( ) ; ShowHelpMarker ( " ColorEdit defaults to displaying RGB inputs if you don ' t specify a display mode , but the user can change it with a right - click . \ n \ nColorPicker defaults to displaying RGB + HSV + Hex if you don ' t specify a display mode . \ n \ nYou can change the defaults using SetColorEditOptions ( ) . " ) ; <nl> ImGui : : Combo ( " Picker Mode " , & picker_mode , " Auto / Current \ 0Hue bar + SV rect \ 0Hue wheel + SV triangle \ 0 " ) ; <nl> ImGui : : SameLine ( ) ; ShowHelpMarker ( " User can right - click the picker to change mode . " ) ; <nl> ImGuiColorEditFlags flags = misc_flags ; <nl> - if ( ! alpha ) flags | = ImGuiColorEditFlags_NoAlpha ; / / This is by default if you call ColorPicker3 ( ) instead of ColorPicker4 ( ) <nl> - if ( alpha_bar ) flags | = ImGuiColorEditFlags_AlphaBar ; <nl> - if ( ! side_preview ) flags | = ImGuiColorEditFlags_NoSidePreview ; <nl> - if ( picker_mode = = 1 ) flags | = ImGuiColorEditFlags_PickerHueBar ; <nl> - if ( picker_mode = = 2 ) flags | = ImGuiColorEditFlags_PickerHueWheel ; <nl> - if ( show_mode = = 1 ) flags | = ImGuiColorEditFlags_NoInputs ; <nl> - if ( show_mode = = 2 ) flags | = ImGuiColorEditFlags_ShowRGB ; <nl> - if ( show_mode = = 3 ) flags | = ImGuiColorEditFlags_ShowHSV ; <nl> - if ( show_mode = = 4 ) flags | = ImGuiColorEditFlags_ShowHEX ; <nl> + if ( ! alpha ) flags | = ImGuiColorEditFlags_NoAlpha ; / / This is by default if you call ColorPicker3 ( ) instead of ColorPicker4 ( ) <nl> + if ( alpha_bar ) flags | = ImGuiColorEditFlags_AlphaBar ; <nl> + if ( ! side_preview ) flags | = ImGuiColorEditFlags_NoSidePreview ; <nl> + if ( picker_mode = = 1 ) flags | = ImGuiColorEditFlags_PickerHueBar ; <nl> + if ( picker_mode = = 2 ) flags | = ImGuiColorEditFlags_PickerHueWheel ; <nl> + if ( display_mode = = 1 ) flags | = ImGuiColorEditFlags_NoInputs ; / / Disable all RGB / HSV / Hex displays <nl> + if ( display_mode = = 2 ) flags | = ImGuiColorEditFlags_DisplayRGB ; / / Override display mode <nl> + if ( display_mode = = 3 ) flags | = ImGuiColorEditFlags_DisplayHSV ; <nl> + if ( display_mode = = 4 ) flags | = ImGuiColorEditFlags_DisplayHex ; <nl> ImGui : : ColorPicker4 ( " MyColor # # 4 " , ( float * ) & color , flags , ref_color ? & ref_color_v . x : NULL ) ; <nl> <nl> ImGui : : Text ( " Programmatically set defaults : " ) ; <nl> ImGui : : SameLine ( ) ; ShowHelpMarker ( " SetColorEditOptions ( ) is designed to allow you to set boot - time default . \ nWe don ' t have Push / Pop functions because you can force options on a per - widget basis if needed , and the user can change non - forced ones with the options menu . \ nWe don ' t have a getter to avoid encouraging you to persistently save values that aren ' t forward - compatible . " ) ; <nl> if ( ImGui : : Button ( " Default : Uint8 + HSV + Hue Bar " ) ) <nl> - ImGui : : SetColorEditOptions ( ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_ShowHSV | ImGuiColorEditFlags_PickerHueBar ) ; <nl> + ImGui : : SetColorEditOptions ( ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_DisplayHSV | ImGuiColorEditFlags_PickerHueBar ) ; <nl> if ( ImGui : : Button ( " Default : Float + HDR + Hue Wheel " ) ) <nl> ImGui : : SetColorEditOptions ( ImGuiColorEditFlags_Float | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_PickerHueWheel ) ; <nl> <nl> mmm a / imgui_widgets . cpp <nl> ppp b / imgui_widgets . cpp <nl> bool ImGui : : ColorEdit4 ( const char * label , float col [ 4 ] , ImGuiColorEditFlags flag <nl> / / If we ' re not showing any slider there ' s no point in doing any HSV conversions <nl> const ImGuiColorEditFlags flags_untouched = flags ; <nl> if ( flags & ImGuiColorEditFlags_NoInputs ) <nl> - flags = ( flags & ( ~ ImGuiColorEditFlags__ShowMask ) ) | ImGuiColorEditFlags_ShowRGB | ImGuiColorEditFlags_NoOptions ; <nl> + flags = ( flags & ( ~ ImGuiColorEditFlags__DisplayMask ) ) | ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_NoOptions ; <nl> <nl> / / Context menu : display and modify options ( before defaults are applied ) <nl> if ( ! ( flags & ImGuiColorEditFlags_NoOptions ) ) <nl> ColorEditOptionsPopup ( col , flags ) ; <nl> <nl> / / Read stored options <nl> - if ( ! ( flags & ImGuiColorEditFlags__ShowMask ) ) <nl> - flags | = ( g . ColorEditOptions & ImGuiColorEditFlags__ShowMask ) ; <nl> + if ( ! ( flags & ImGuiColorEditFlags__DisplayMask ) ) <nl> + flags | = ( g . ColorEditOptions & ImGuiColorEditFlags__DisplayMask ) ; <nl> if ( ! ( flags & ImGuiColorEditFlags__DataTypeMask ) ) <nl> flags | = ( g . ColorEditOptions & ImGuiColorEditFlags__DataTypeMask ) ; <nl> if ( ! ( flags & ImGuiColorEditFlags__PickerMask ) ) <nl> flags | = ( g . ColorEditOptions & ImGuiColorEditFlags__PickerMask ) ; <nl> - flags | = ( g . ColorEditOptions & ~ ( ImGuiColorEditFlags__ShowMask | ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags__PickerMask ) ) ; <nl> + flags | = ( g . ColorEditOptions & ~ ( ImGuiColorEditFlags__DisplayMask | ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags__PickerMask ) ) ; <nl> <nl> const bool alpha = ( flags & ImGuiColorEditFlags_NoAlpha ) = = 0 ; <nl> const bool hdr = ( flags & ImGuiColorEditFlags_HDR ) ! = 0 ; <nl> bool ImGui : : ColorEdit4 ( const char * label , float col [ 4 ] , ImGuiColorEditFlags flag <nl> <nl> / / Convert to the formats we need <nl> float f [ 4 ] = { col [ 0 ] , col [ 1 ] , col [ 2 ] , alpha ? col [ 3 ] : 1 . 0f } ; <nl> - if ( flags & ImGuiColorEditFlags_ShowHSV ) <nl> + if ( flags & ImGuiColorEditFlags_DisplayHSV ) <nl> ColorConvertRGBtoHSV ( f [ 0 ] , f [ 1 ] , f [ 2 ] , f [ 0 ] , f [ 1 ] , f [ 2 ] ) ; <nl> int i [ 4 ] = { IM_F32_TO_INT8_UNBOUND ( f [ 0 ] ) , IM_F32_TO_INT8_UNBOUND ( f [ 1 ] ) , IM_F32_TO_INT8_UNBOUND ( f [ 2 ] ) , IM_F32_TO_INT8_UNBOUND ( f [ 3 ] ) } ; <nl> <nl> bool value_changed = false ; <nl> bool value_changed_as_float = false ; <nl> <nl> - if ( ( flags & ( ImGuiColorEditFlags_ShowRGB | ImGuiColorEditFlags_ShowHSV ) ) ! = 0 & & ( flags & ImGuiColorEditFlags_NoInputs ) = = 0 ) <nl> + if ( ( flags & ( ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_DisplayHSV ) ) ! = 0 & & ( flags & ImGuiColorEditFlags_NoInputs ) = = 0 ) <nl> { <nl> / / RGB / HSV 0 . . 255 Sliders <nl> const float w_item_one = ImMax ( 1 . 0f , ( float ) ( int ) ( ( w_items_all - ( style . ItemInnerSpacing . x ) * ( components - 1 ) ) / ( float ) components ) ) ; <nl> bool ImGui : : ColorEdit4 ( const char * label , float col [ 4 ] , ImGuiColorEditFlags flag <nl> { " R : % 0 . 3f " , " G : % 0 . 3f " , " B : % 0 . 3f " , " A : % 0 . 3f " } , / / Long display for RGBA <nl> { " H : % 0 . 3f " , " S : % 0 . 3f " , " V : % 0 . 3f " , " A : % 0 . 3f " } / / Long display for HSVA <nl> } ; <nl> - const int fmt_idx = hide_prefix ? 0 : ( flags & ImGuiColorEditFlags_ShowHSV ) ? 2 : 1 ; <nl> + const int fmt_idx = hide_prefix ? 0 : ( flags & ImGuiColorEditFlags_DisplayHSV ) ? 2 : 1 ; <nl> <nl> PushItemWidth ( w_item_one ) ; <nl> for ( int n = 0 ; n < components ; n + + ) <nl> bool ImGui : : ColorEdit4 ( const char * label , float col [ 4 ] , ImGuiColorEditFlags flag <nl> PopItemWidth ( ) ; <nl> PopItemWidth ( ) ; <nl> } <nl> - else if ( ( flags & ImGuiColorEditFlags_ShowHEX ) ! = 0 & & ( flags & ImGuiColorEditFlags_NoInputs ) = = 0 ) <nl> + else if ( ( flags & ImGuiColorEditFlags_DisplayHex ) ! = 0 & & ( flags & ImGuiColorEditFlags_NoInputs ) = = 0 ) <nl> { <nl> / / RGB Hexadecimal Input <nl> char buf [ 64 ] ; <nl> bool ImGui : : ColorEdit4 ( const char * label , float col [ 4 ] , ImGuiColorEditFlags flag <nl> Spacing ( ) ; <nl> } <nl> ImGuiColorEditFlags picker_flags_to_forward = ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags__PickerMask | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaBar ; <nl> - ImGuiColorEditFlags picker_flags = ( flags_untouched & picker_flags_to_forward ) | ImGuiColorEditFlags__ShowMask | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_AlphaPreviewHalf ; <nl> + ImGuiColorEditFlags picker_flags = ( flags_untouched & picker_flags_to_forward ) | ImGuiColorEditFlags__DisplayMask | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_AlphaPreviewHalf ; <nl> PushItemWidth ( square_sz * 12 . 0f ) ; / / Use 256 + bar sizes ? <nl> value_changed | = ColorPicker4 ( " # # picker " , col , picker_flags , & g . ColorPickerRef . x ) ; <nl> PopItemWidth ( ) ; <nl> bool ImGui : : ColorEdit4 ( const char * label , float col [ 4 ] , ImGuiColorEditFlags flag <nl> if ( ! value_changed_as_float ) <nl> for ( int n = 0 ; n < 4 ; n + + ) <nl> f [ n ] = i [ n ] / 255 . 0f ; <nl> - if ( flags & ImGuiColorEditFlags_ShowHSV ) <nl> + if ( flags & ImGuiColorEditFlags_DisplayHSV ) <nl> ColorConvertHSVtoRGB ( f [ 0 ] , f [ 1 ] , f [ 2 ] , f [ 0 ] , f [ 1 ] , f [ 2 ] ) ; <nl> if ( value_changed ) <nl> { <nl> bool ImGui : : ColorPicker4 ( const char * label , float col [ 4 ] , ImGuiColorEditFlags fl <nl> PushItemWidth ( ( alpha_bar ? bar1_pos_x : bar0_pos_x ) + bars_width - picker_pos . x ) ; <nl> ImGuiColorEditFlags sub_flags_to_forward = ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoOptions | ImGuiColorEditFlags_NoSmallPreview | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf ; <nl> ImGuiColorEditFlags sub_flags = ( flags & sub_flags_to_forward ) | ImGuiColorEditFlags_NoPicker ; <nl> - if ( flags & ImGuiColorEditFlags_ShowRGB | | ( flags & ImGuiColorEditFlags__ShowMask ) = = 0 ) <nl> - if ( ColorEdit4 ( " # # rgb " , col , sub_flags | ImGuiColorEditFlags_ShowRGB ) ) <nl> + if ( flags & ImGuiColorEditFlags_DisplayRGB | | ( flags & ImGuiColorEditFlags__DisplayMask ) = = 0 ) <nl> + if ( ColorEdit4 ( " # # rgb " , col , sub_flags | ImGuiColorEditFlags_DisplayRGB ) ) <nl> { <nl> / / FIXME : Hackily differenciating using the DragInt ( ActiveId ! = 0 & & ! ActiveIdAllowOverlap ) vs . using the InputText or DropTarget . <nl> / / For the later we don ' t want to run the hue - wrap canceling code . If you are well versed in HSV picker please provide your input ! ( See # 2050 ) <nl> value_changed_fix_hue_wrap = ( g . ActiveId ! = 0 & & ! g . ActiveIdAllowOverlap ) ; <nl> value_changed = true ; <nl> } <nl> - if ( flags & ImGuiColorEditFlags_ShowHSV | | ( flags & ImGuiColorEditFlags__ShowMask ) = = 0 ) <nl> - value_changed | = ColorEdit4 ( " # # hsv " , col , sub_flags | ImGuiColorEditFlags_ShowHSV ) ; <nl> - if ( flags & ImGuiColorEditFlags_ShowHEX | | ( flags & ImGuiColorEditFlags__ShowMask ) = = 0 ) <nl> - value_changed | = ColorEdit4 ( " # # hex " , col , sub_flags | ImGuiColorEditFlags_ShowHEX ) ; <nl> + if ( flags & ImGuiColorEditFlags_DisplayHSV | | ( flags & ImGuiColorEditFlags__DisplayMask ) = = 0 ) <nl> + value_changed | = ColorEdit4 ( " # # hsv " , col , sub_flags | ImGuiColorEditFlags_DisplayHSV ) ; <nl> + if ( flags & ImGuiColorEditFlags_DisplayHex | | ( flags & ImGuiColorEditFlags__DisplayMask ) = = 0 ) <nl> + value_changed | = ColorEdit4 ( " # # hex " , col , sub_flags | ImGuiColorEditFlags_DisplayHex ) ; <nl> PopItemWidth ( ) ; <nl> } <nl> <nl> bool ImGui : : ColorButton ( const char * desc_id , const ImVec4 & col , ImGuiColorEditFl <nl> return pressed ; <nl> } <nl> <nl> + / / Initialize / override default color options <nl> void ImGui : : SetColorEditOptions ( ImGuiColorEditFlags flags ) <nl> { <nl> ImGuiContext & g = * GImGui ; <nl> - if ( ( flags & ImGuiColorEditFlags__ShowMask ) = = 0 ) <nl> - flags | = ImGuiColorEditFlags__OptionsDefault & ImGuiColorEditFlags__ShowMask ; <nl> + if ( ( flags & ImGuiColorEditFlags__DisplayMask ) = = 0 ) <nl> + flags | = ImGuiColorEditFlags__OptionsDefault & ImGuiColorEditFlags__DisplayMask ; <nl> if ( ( flags & ImGuiColorEditFlags__DataTypeMask ) = = 0 ) <nl> flags | = ImGuiColorEditFlags__OptionsDefault & ImGuiColorEditFlags__DataTypeMask ; <nl> if ( ( flags & ImGuiColorEditFlags__PickerMask ) = = 0 ) <nl> flags | = ImGuiColorEditFlags__OptionsDefault & ImGuiColorEditFlags__PickerMask ; <nl> - IM_ASSERT ( ImIsPowerOfTwo ( ( int ) ( flags & ImGuiColorEditFlags__ShowMask ) ) ) ; / / Check only 1 option is selected <nl> + IM_ASSERT ( ImIsPowerOfTwo ( ( int ) ( flags & ImGuiColorEditFlags__DisplayMask ) ) ) ; / / Check only 1 option is selected <nl> IM_ASSERT ( ImIsPowerOfTwo ( ( int ) ( flags & ImGuiColorEditFlags__DataTypeMask ) ) ) ; / / Check only 1 option is selected <nl> IM_ASSERT ( ImIsPowerOfTwo ( ( int ) ( flags & ImGuiColorEditFlags__PickerMask ) ) ) ; / / Check only 1 option is selected <nl> g . ColorEditOptions = flags ; <nl> void ImGui : : ColorTooltip ( const char * text , const float * col , ImGuiColorEditFlags <nl> <nl> void ImGui : : ColorEditOptionsPopup ( const float * col , ImGuiColorEditFlags flags ) <nl> { <nl> - bool allow_opt_inputs = ! ( flags & ImGuiColorEditFlags__ShowMask ) ; <nl> + bool allow_opt_inputs = ! ( flags & ImGuiColorEditFlags__DisplayMask ) ; <nl> bool allow_opt_datatype = ! ( flags & ImGuiColorEditFlags__DataTypeMask ) ; <nl> if ( ( ! allow_opt_inputs & & ! allow_opt_datatype ) | | ! BeginPopup ( " context " ) ) <nl> return ; <nl> void ImGui : : ColorEditOptionsPopup ( const float * col , ImGuiColorEditFlags flags ) <nl> ImGuiColorEditFlags opts = g . ColorEditOptions ; <nl> if ( allow_opt_inputs ) <nl> { <nl> - if ( RadioButton ( " RGB " , ( opts & ImGuiColorEditFlags_ShowRGB ) ! = 0 ) ) opts = ( opts & ~ ImGuiColorEditFlags__ShowMask ) | ImGuiColorEditFlags_ShowRGB ; <nl> - if ( RadioButton ( " HSV " , ( opts & ImGuiColorEditFlags_ShowHSV ) ! = 0 ) ) opts = ( opts & ~ ImGuiColorEditFlags__ShowMask ) | ImGuiColorEditFlags_ShowHSV ; <nl> - if ( RadioButton ( " HEX " , ( opts & ImGuiColorEditFlags_ShowHEX ) ! = 0 ) ) opts = ( opts & ~ ImGuiColorEditFlags__ShowMask ) | ImGuiColorEditFlags_ShowHEX ; <nl> + if ( RadioButton ( " RGB " , ( opts & ImGuiColorEditFlags_DisplayRGB ) ! = 0 ) ) opts = ( opts & ~ ImGuiColorEditFlags__DisplayMask ) | ImGuiColorEditFlags_DisplayRGB ; <nl> + if ( RadioButton ( " HSV " , ( opts & ImGuiColorEditFlags_DisplayHSV ) ! = 0 ) ) opts = ( opts & ~ ImGuiColorEditFlags__DisplayMask ) | ImGuiColorEditFlags_DisplayHSV ; <nl> + if ( RadioButton ( " Hex " , ( opts & ImGuiColorEditFlags_DisplayHex ) ! = 0 ) ) opts = ( opts & ~ ImGuiColorEditFlags__DisplayMask ) | ImGuiColorEditFlags_DisplayHex ; <nl> } <nl> if ( allow_opt_datatype ) <nl> { <nl>
Renamed ColorEdit / ColorPicker ' s ImGuiColorEditFlags_RGB / _HSV / _HEX flags to respectively ImGuiColorEditFlags_DisplayRGB / _DisplayHSV / _DisplayHex . This is anticipation of adding new flags to ColorEdit / ColorPicker functions which would make those ambiguous . ( ) [ @ haldean ]
ocornut/imgui
6de09a5e480fc04019ecbd2e2eb46dc5c5fdc847
2019-02-27T15:45:58Z
mmm a / lib / Parse / ParseStmt . cpp <nl> ppp b / lib / Parse / ParseStmt . cpp <nl> ParserResult < Stmt > Parser : : parseStmtForEach ( SourceLoc ForLoc , <nl> LabeledStmtInfo LabelInfo ) { <nl> ParserStatus Status ; <nl> <nl> - / / Change the parser state to know that the pattern we ' re about to parse is <nl> - / / implicitly mutable . Bound variables can be changed to mutable explicitly <nl> - / / if desired by using a ' var ' pattern . <nl> - assert ( InVarOrLetPattern = = IVOLP_NotInVarOrLet & & <nl> - " for - each loops cannot exist inside other patterns " ) ; <nl> - InVarOrLetPattern = IVOLP_ImplicitlyImmutable ; <nl> - ParserResult < Pattern > Pattern = parseTypedPattern ( ) ; <nl> - assert ( InVarOrLetPattern = = IVOLP_ImplicitlyImmutable ) ; <nl> - InVarOrLetPattern = IVOLP_NotInVarOrLet ; <nl> - <nl> + ParserResult < Pattern > pattern ; <nl> + <nl> + / / Parse teh pattern . This is either ' case < refutable pattern > ' or just a <nl> + / / normal pattern . <nl> + if ( consumeIf ( tok : : kw_case ) ) { <nl> + pattern = parseMatchingPattern ( / * isExprBasic * / true ) ; <nl> + pattern = parseOptionalPatternTypeAnnotation ( pattern , / * isOptional * / false ) ; <nl> + } else { <nl> + / / Change the parser state to know that the pattern we ' re about to parse is <nl> + / / implicitly mutable . Bound variables can be changed to mutable explicitly <nl> + / / if desired by using a ' var ' pattern . <nl> + assert ( InVarOrLetPattern = = IVOLP_NotInVarOrLet & & <nl> + " for - each loops cannot exist inside other patterns " ) ; <nl> + InVarOrLetPattern = IVOLP_ImplicitlyImmutable ; <nl> + pattern = parseTypedPattern ( ) ; <nl> + assert ( InVarOrLetPattern = = IVOLP_ImplicitlyImmutable ) ; <nl> + InVarOrLetPattern = IVOLP_NotInVarOrLet ; <nl> + } <nl> <nl> - if ( Pattern . isNull ( ) ) <nl> + if ( pattern . isNull ( ) ) <nl> / / Recover by creating a " _ " pattern . <nl> - Pattern = makeParserErrorResult ( new ( Context ) AnyPattern ( SourceLoc ( ) ) ) ; <nl> + pattern = makeParserErrorResult ( new ( Context ) AnyPattern ( SourceLoc ( ) ) ) ; <nl> <nl> / / Bound variables all get their initial values from the generator . <nl> - Pattern . get ( ) - > markHasNonPatternBindingInit ( ) ; <nl> + pattern . get ( ) - > markHasNonPatternBindingInit ( ) ; <nl> <nl> SourceLoc InLoc ; <nl> parseToken ( tok : : kw_in , InLoc , diag : : expected_foreach_in ) ; <nl> ParserResult < Stmt > Parser : : parseStmtForEach ( SourceLoc ForLoc , <nl> Scope S ( this , ScopeKind : : ForeachVars ) ; <nl> <nl> / / Introduce variables to the current scope . <nl> - addPatternVariablesToScope ( Pattern . get ( ) ) ; <nl> + addPatternVariablesToScope ( pattern . get ( ) ) ; <nl> <nl> / / Parse the ' where ' expression if present . <nl> ParserResult < Expr > Where ; <nl> ParserResult < Stmt > Parser : : parseStmtForEach ( SourceLoc ForLoc , <nl> <nl> return makeParserResult ( <nl> Status , <nl> - new ( Context ) ForEachStmt ( LabelInfo , ForLoc , Pattern . get ( ) , InLoc , <nl> + new ( Context ) ForEachStmt ( LabelInfo , ForLoc , pattern . get ( ) , InLoc , <nl> Container . get ( ) , Where . getPtrOrNull ( ) , <nl> Body . get ( ) ) ) ; <nl> } <nl> mmm a / lib / SILGen / SILGenDecl . cpp <nl> ppp b / lib / SILGen / SILGenDecl . cpp <nl> void SILGenFunction : : visitPatternBindingDecl ( PatternBindingDecl * PBD ) { <nl> / / Allocate the variables and build up an Initialization over their <nl> / / allocated storage . <nl> for ( auto entry : PBD - > getPatternList ( ) ) { <nl> - auto initialization = emitPatternBindingInitialization ( entry . ThePattern ) ; <nl> + auto initialization = emitPatternBindingInitialization ( entry . ThePattern , <nl> + JumpDest : : invalid ( ) ) ; <nl> <nl> / / If an initial value expression was specified by the decl , emit it into <nl> / / the initialization . Otherwise , mark it uninitialized for DI to resolve . <nl> void SILGenFunction : : emitStmtCondition ( StmtCondition Cond , <nl> } <nl> <nl> InitializationPtr <nl> - SILGenFunction : : emitPatternBindingInitialization ( Pattern * P ) { <nl> - return InitializationForPattern ( * this , JumpDest : : invalid ( ) ) . visit ( P ) ; <nl> + SILGenFunction : : emitPatternBindingInitialization ( Pattern * P , <nl> + JumpDest failureDest ) { <nl> + return InitializationForPattern ( * this , failureDest ) . visit ( P ) ; <nl> } <nl> <nl> / / / Enter a cleanup to deallocate the given location . <nl> mmm a / lib / SILGen / SILGenFunction . h <nl> ppp b / lib / SILGen / SILGenFunction . h <nl> class LLVM_LIBRARY_VISIBILITY SILGenFunction <nl> void visitFuncDecl ( FuncDecl * D ) ; <nl> void visitPatternBindingDecl ( PatternBindingDecl * D ) ; <nl> <nl> - std : : unique_ptr < Initialization > emitPatternBindingInitialization ( Pattern * P ) ; <nl> + std : : unique_ptr < Initialization > <nl> + emitPatternBindingInitialization ( Pattern * P , JumpDest failureDest ) ; <nl> <nl> void visitTypeAliasDecl ( TypeAliasDecl * D ) { <nl> / / No lowering support needed . <nl> mmm a / lib / SILGen / SILGenStmt . cpp <nl> ppp b / lib / SILGen / SILGenStmt . cpp <nl> void StmtEmitter : : visitForEachStmt ( ForEachStmt * S ) { <nl> / / at the end of each loop iteration . <nl> { <nl> Scope InnerForScope ( SGF . Cleanups , CleanupLocation ( S - > getBody ( ) ) ) ; <nl> + / / Emit the initialization for the pattern . If any of the bound patterns <nl> + / / fail ( because this is a ' for case ' pattern with a refutable pattern , <nl> + / / the code should jump to the continue block . <nl> InitializationPtr initLoopVars <nl> - = SGF . emitPatternBindingInitialization ( S - > getPattern ( ) ) ; <nl> + = SGF . emitPatternBindingInitialization ( S - > getPattern ( ) , loopDest ) ; <nl> ManagedValue val ; <nl> <nl> / / If we had a loadable " next " generator value , we know it is present . <nl> mmm a / lib / Sema / TypeCheckStmt . cpp <nl> ppp b / lib / Sema / TypeCheckStmt . cpp <nl> class StmtChecker : public StmtVisitor < StmtChecker , Stmt * > { <nl> options | = TR_AllowUnspecifiedTypes ; <nl> options | = TR_AllowUnboundGenerics ; <nl> options | = TR_InExpression ; <nl> + <nl> + if ( auto * P = TC . resolvePattern ( S - > getPattern ( ) , DC , <nl> + / * isStmtCondition * / false ) ) { <nl> + S - > setPattern ( P ) ; <nl> + } else { <nl> + S - > getPattern ( ) - > setType ( ErrorType : : get ( TC . Context ) ) ; <nl> + return nullptr ; <nl> + } <nl> + <nl> if ( TC . typeCheckPattern ( S - > getPattern ( ) , DC , options ) ) { <nl> / / FIXME : Handle errors better . <nl> S - > getPattern ( ) - > setType ( ErrorType : : get ( TC . Context ) ) ; <nl> mmm a / test / Interpreter / statements . swift <nl> ppp b / test / Interpreter / statements . swift <nl> <nl> <nl> / / Foreach loops <nl> <nl> - print ( " start foreach " ) <nl> + print ( " foreach / where " ) <nl> for i in 0 . . . 6 where i & 1 = = 0 { <nl> print ( i ) <nl> } <nl> - print ( " end foreach " ) <nl> <nl> - / / CHECK - LABEL : start foreach <nl> + / / CHECK - LABEL : foreach / where <nl> / / CHECK - NEXT : 0 <nl> / / CHECK - NEXT : 2 <nl> / / CHECK - NEXT : 4 <nl> / / CHECK - NEXT : 6 <nl> - / / CHECK - NEXT : end <nl> <nl> <nl> + let OptionalArr : [ Int ? ] = [ 1 , nil , 2 , nil , 3 , nil , nil , nil , 4 , 5 ] <nl> + <nl> + print ( " foreach / case " ) <nl> + for case let i ? in OptionalArr { <nl> + print ( i ) <nl> + } <nl> + <nl> + / / CHECK - LABEL : foreach / case <nl> + / / CHECK - NEXT : 1 <nl> + / / CHECK - NEXT : 2 <nl> + / / CHECK - NEXT : 3 <nl> + / / CHECK - NEXT : 4 <nl> + / / CHECK - NEXT : 5 <nl> + <nl> + print ( " foreach / case / where " ) <nl> + <nl> + for case let i ? in OptionalArr where i ! = 3 { <nl> + print ( i ) <nl> + } <nl> + <nl> + / / CHECK - LABEL : foreach / case <nl> + / / CHECK - NEXT : 1 <nl> + / / CHECK - NEXT : 2 <nl> + / / CHECK - NEXT : 4 <nl> + / / CHECK - NEXT : 5 <nl> + <nl> + <nl> + <nl> + print ( " done " ) ; <nl> + / / CHECK - LABEL : done <nl> + <nl>
Implement support for arbitrary pattern matching in for - each statements ,
apple/swift
3814b7003fc6cdc60fd484c161ce9d059e7e018b
2015-05-09T21:34:35Z
mmm a / Source / Readers / ImageReader / ImageReader . cpp <nl> ppp b / Source / Readers / ImageReader / ImageReader . cpp <nl> ImageReader : : ImageReader ( MemoryProviderPtr provider , <nl> const bool multithreadedGetNextSequences = true ; <nl> if ( configHelper . ShouldRandomize ( ) ) <nl> { <nl> + / / We do not use legacy randomization . <nl> bool useLegacyRandomization = false ; <nl> randomizer = std : : make_shared < BlockRandomizer > ( 0 , 1 , deserializer , BlockRandomizer : : DecimationMode : : sequence , useLegacyRandomization , multithreadedGetNextSequences ) ; <nl> } <nl> mmm a / Source / Readers / ReaderLib / BlockRandomizer . cpp <nl> ppp b / Source / Readers / ReaderLib / BlockRandomizer . cpp <nl> Sequences BlockRandomizer : : GetNextSequences ( size_t sampleCount ) <nl> / / TODO : This will be changed , when we move transformers under the randomizer , should not deal with multithreading here . <nl> if ( m_multithreadedGetNextSequences ) <nl> { <nl> - # pragma omp parallel for ordered schedule ( dynamic ) <nl> + # pragma omp parallel for schedule ( dynamic ) <nl> for ( int i = 0 ; i < decimated . size ( ) ; + + i ) <nl> process ( i ) ; <nl> } <nl> mmm a / Source / Readers / ReaderLib / NoRandomizer . cpp <nl> ppp b / Source / Readers / ReaderLib / NoRandomizer . cpp <nl> Sequences NoRandomizer : : GetNextSequences ( size_t sampleCount ) <nl> / / TODO : This will be changed , when we move transformers under the ( no - ) randomizer , should not deal with multithreading here . <nl> if ( m_multithreadedGetNextSequences ) <nl> { <nl> - # pragma omp parallel for ordered schedule ( dynamic ) <nl> + # pragma omp parallel for schedule ( dynamic ) <nl> for ( int i = 0 ; i < subsetSize ; + + i ) <nl> process ( i ) ; <nl> } <nl> mmm a / Source / Readers / ReaderLib / TransformerBase . h <nl> ppp b / Source / Readers / ReaderLib / TransformerBase . h <nl> class TransformerBase : public Transformer <nl> size_t streamId = appliedStreamIds [ j ] ; <nl> auto & allSamples = samples . m_data [ streamId ] ; <nl> <nl> - # pragma omp parallel for ordered schedule ( dynamic ) <nl> + # pragma omp parallel for schedule ( dynamic ) <nl> for ( int i = 0 ; i < allSamples . size ( ) ; + + i ) <nl> { <nl> allSamples [ i ] = Apply ( allSamples [ i ] , * m_inputStreams [ streamId ] , * outputStreams [ streamId ] ) ; <nl>
Address CR comments
microsoft/CNTK
695f4a24e1e1f7ddd5b56ea0177a5847d4555390
2016-04-20T07:05:11Z
mmm a / xbmc / addons / settings / GUIDialogAddonSettings . cpp <nl> ppp b / xbmc / addons / settings / GUIDialogAddonSettings . cpp <nl> <nl> # include " settings / lib / SettingsManager . h " <nl> # include " utils / StringUtils . h " <nl> # include " utils / Variant . h " <nl> + # include " view / ViewStateSettings . h " <nl> <nl> using namespace KODI : : MESSAGING ; <nl> <nl> std : : string CGUIDialogAddonSettings : : GetSettingsLabel ( std : : shared_ptr < ISetting > <nl> <nl> int CGUIDialogAddonSettings : : GetSettingLevel ( ) const <nl> { <nl> - return static_cast < int > ( SettingLevel : : Standard ) ; <nl> + return static_cast < int > ( CViewStateSettings : : GetInstance ( ) . GetSettingLevel ( ) ) ; <nl> } <nl> <nl> std : : shared_ptr < CSettingSection > CGUIDialogAddonSettings : : GetSection ( ) <nl>
Merge pull request from ronie / addon - settingslevel . 18
xbmc/xbmc
295594d0e7a184d48bd9611ef611505a29082d97
2019-03-31T21:51:56Z
new file mode 100644 <nl> index 00000000000 . . 48803134755 <nl> mmm / dev / null <nl> ppp b / UnitTests / HttpInterface / api - simple - hash - spec . rb <nl> <nl> + # coding : utf - 8 <nl> + <nl> + require ' rspec ' <nl> + require ' . / arangodb . rb ' <nl> + <nl> + describe ArangoDB do <nl> + api = " / _api / simple " <nl> + prefix = " api - simple " <nl> + <nl> + context " simple queries : " do <nl> + <nl> + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> + # # range query <nl> + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> + <nl> + context " hash query : " do <nl> + before do <nl> + @ cn = " UnitTestsCollectionHash " <nl> + ArangoDB . drop_collection ( @ cn ) <nl> + @ cid = ArangoDB . create_collection ( @ cn , false ) <nl> + end <nl> + <nl> + after do <nl> + ArangoDB . drop_collection ( @ cn ) <nl> + end <nl> + <nl> + it " finds the examples , wrong index specified " do <nl> + cmd = api + " / by - example - hash " <nl> + body = " { \ " collection \ " : \ " # { @ cn } \ " , \ " index \ " : \ " 1 \ " , \ " example \ " : { \ " i \ " : 12 } } " <nl> + doc = ArangoDB . log_put ( " # { prefix } - hash " , cmd , : body = > body ) <nl> + <nl> + doc . code . should eq ( 404 ) <nl> + doc . headers [ ' content - type ' ] . should eq ( " application / json ; charset = utf - 8 " ) <nl> + doc . parsed_response [ ' code ' ] . should eq ( 404 ) <nl> + doc . parsed_response [ ' error ' ] . should eq ( true ) <nl> + doc . parsed_response [ ' errorNum ' ] . should eq ( 1209 ) <nl> + end <nl> + <nl> + it " finds the examples , wrong attribute " do <nl> + # create index <nl> + cmd = " / _api / index ? collection = # { @ cn } " <nl> + body = " { \ " type \ " : \ " hash \ " , \ " unique \ " : true , \ " fields \ " : [ \ " i \ " ] } " <nl> + doc = ArangoDB . log_post ( " # { prefix } - hash - index " , cmd , : body = > body ) <nl> + <nl> + doc . code . should eq ( 201 ) <nl> + iid = doc . parsed_response [ ' id ' ] <nl> + <nl> + cmd = api + " / by - example - hash " <nl> + body = " { \ " collection \ " : \ " # { @ cn } \ " , \ " index \ " : \ " # { iid } \ " , \ " example \ " : { \ " j \ " : 12 } } " <nl> + doc = ArangoDB . log_put ( " # { prefix } - hash " , cmd , : body = > body ) <nl> + <nl> + doc . code . should eq ( 404 ) <nl> + doc . headers [ ' content - type ' ] . should eq ( " application / json ; charset = utf - 8 " ) <nl> + doc . parsed_response [ ' code ' ] . should eq ( 404 ) <nl> + doc . parsed_response [ ' error ' ] . should eq ( true ) <nl> + doc . parsed_response [ ' errorNum ' ] . should eq ( 1209 ) <nl> + end <nl> + <nl> + it " finds the examples , no index specified " do <nl> + cmd = api + " / by - example - hash " <nl> + body = " { \ " collection \ " : \ " # { @ cn } \ " , \ " example \ " : { \ " i \ " : 12 } } " <nl> + doc = ArangoDB . log_put ( " # { prefix } - hash " , cmd , : body = > body ) <nl> + <nl> + doc . code . should eq ( 201 ) <nl> + doc . headers [ ' content - type ' ] . should eq ( " application / json ; charset = utf - 8 " ) <nl> + doc . parsed_response [ ' error ' ] . should eq ( false ) <nl> + doc . parsed_response [ ' code ' ] . should eq ( 201 ) <nl> + doc . parsed_response [ ' hasMore ' ] . should eq ( false ) <nl> + doc . parsed_response [ ' result ' ] . length . should eq ( 0 ) <nl> + doc . parsed_response [ ' count ' ] . should eq ( 0 ) <nl> + end <nl> + <nl> + it " finds the examples , unique index " do <nl> + # create data <nl> + for i in [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ] <nl> + body = " { \ " i \ " : # { i } } " <nl> + doc = ArangoDB . post ( " / _api / document ? collection = # { @ cn } " , : body = > body ) <nl> + doc . code . should eq ( 202 ) <nl> + end <nl> + <nl> + # create index <nl> + cmd = " / _api / index ? collection = # { @ cn } " <nl> + body = " { \ " type \ " : \ " hash \ " , \ " unique \ " : true , \ " fields \ " : [ \ " i \ " ] } " <nl> + doc = ArangoDB . log_post ( " # { prefix } - hash - index " , cmd , : body = > body ) <nl> + <nl> + doc . code . should eq ( 201 ) <nl> + iid = doc . parsed_response [ ' id ' ] <nl> + <nl> + # by - example - hash <nl> + cmd = api + " / by - example - hash " <nl> + body = " { \ " collection \ " : \ " # { @ cn } \ " , \ " index \ " : \ " # { iid } \ " , \ " example \ " : { \ " i \ " : 3 } } " <nl> + doc = ArangoDB . log_put ( " # { prefix } - hash " , cmd , : body = > body ) <nl> + <nl> + doc . code . should eq ( 201 ) <nl> + doc . headers [ ' content - type ' ] . should eq ( " application / json ; charset = utf - 8 " ) <nl> + doc . parsed_response [ ' error ' ] . should eq ( false ) <nl> + doc . parsed_response [ ' code ' ] . should eq ( 201 ) <nl> + doc . parsed_response [ ' hasMore ' ] . should eq ( false ) <nl> + doc . parsed_response [ ' result ' ] . length . should eq ( 1 ) <nl> + doc . parsed_response [ ' count ' ] . should eq ( 1 ) <nl> + doc . parsed_response [ ' result ' ] . map { | i | i [ ' i ' ] } . should = ~ [ 3 ] <nl> + <nl> + body = " { \ " collection \ " : \ " # { @ cn } \ " , \ " index \ " : \ " # { iid } \ " , \ " example \ " : { \ " i \ " : 12 } } " <nl> + doc = ArangoDB . log_put ( " # { prefix } - hash " , cmd , : body = > body ) <nl> + <nl> + doc . code . should eq ( 201 ) <nl> + doc . headers [ ' content - type ' ] . should eq ( " application / json ; charset = utf - 8 " ) <nl> + doc . parsed_response [ ' error ' ] . should eq ( false ) <nl> + doc . parsed_response [ ' code ' ] . should eq ( 201 ) <nl> + doc . parsed_response [ ' hasMore ' ] . should eq ( false ) <nl> + doc . parsed_response [ ' result ' ] . length . should eq ( 0 ) <nl> + doc . parsed_response [ ' count ' ] . should eq ( 0 ) <nl> + end <nl> + <nl> + it " finds the examples , non - unique index " do <nl> + # create data <nl> + for i in [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ] <nl> + body = " { \ " i \ " : # { i } , \ " j \ " : 2 } " <nl> + doc = ArangoDB . post ( " / _api / document ? collection = # { @ cn } " , : body = > body ) <nl> + doc . code . should eq ( 202 ) <nl> + end <nl> + <nl> + # create index <nl> + cmd = " / _api / index ? collection = # { @ cn } " <nl> + body = " { \ " type \ " : \ " hash \ " , \ " unique \ " : false , \ " fields \ " : [ \ " j \ " , \ " i \ " ] } " <nl> + doc = ArangoDB . log_post ( " # { prefix } - hash - index " , cmd , : body = > body ) <nl> + <nl> + doc . code . should eq ( 201 ) <nl> + iid = doc . parsed_response [ ' id ' ] <nl> + <nl> + # by - example - hash <nl> + cmd = api + " / by - example - hash " <nl> + body = " { \ " collection \ " : \ " # { @ cn } \ " , \ " index \ " : \ " # { iid } \ " , \ " example \ " : { \ " j \ " : 2 , \ " i \ " : 2 } } " <nl> + doc = ArangoDB . log_put ( " # { prefix } - hash " , cmd , : body = > body ) <nl> + <nl> + doc . code . should eq ( 201 ) <nl> + doc . headers [ ' content - type ' ] . should eq ( " application / json ; charset = utf - 8 " ) <nl> + doc . parsed_response [ ' error ' ] . should eq ( false ) <nl> + doc . parsed_response [ ' code ' ] . should eq ( 201 ) <nl> + doc . parsed_response [ ' hasMore ' ] . should eq ( false ) <nl> + doc . parsed_response [ ' result ' ] . length . should eq ( 1 ) <nl> + doc . parsed_response [ ' count ' ] . should eq ( 1 ) <nl> + doc . parsed_response [ ' result ' ] . map { | i | i [ ' i ' ] } . should = ~ [ 2 ] <nl> + doc . parsed_response [ ' result ' ] . map { | i | i [ ' j ' ] } . should = ~ [ 2 ] <nl> + <nl> + body = " { \ " collection \ " : \ " # { @ cn } \ " , \ " index \ " : \ " # { iid } \ " , \ " example \ " : { \ " i \ " : 2 , \ " j \ " : 2 } } " <nl> + doc = ArangoDB . log_put ( " # { prefix } - hash " , cmd , : body = > body ) <nl> + <nl> + doc . code . should eq ( 201 ) <nl> + doc . headers [ ' content - type ' ] . should eq ( " application / json ; charset = utf - 8 " ) <nl> + doc . parsed_response [ ' error ' ] . should eq ( false ) <nl> + doc . parsed_response [ ' code ' ] . should eq ( 201 ) <nl> + doc . parsed_response [ ' hasMore ' ] . should eq ( false ) <nl> + doc . parsed_response [ ' result ' ] . length . should eq ( 1 ) <nl> + doc . parsed_response [ ' count ' ] . should eq ( 1 ) <nl> + doc . parsed_response [ ' result ' ] . map { | i | i [ ' i ' ] } . should = ~ [ 2 ] <nl> + doc . parsed_response [ ' result ' ] . map { | i | i [ ' j ' ] } . should = ~ [ 2 ] <nl> + <nl> + body = " { \ " collection \ " : \ " # { @ cn } \ " , \ " index \ " : \ " # { iid } \ " , \ " example \ " : { \ " j \ " : 3 , \ " i \ " : 2 } } " <nl> + doc = ArangoDB . log_put ( " # { prefix } - hash " , cmd , : body = > body ) <nl> + <nl> + doc . code . should eq ( 201 ) <nl> + doc . headers [ ' content - type ' ] . should eq ( " application / json ; charset = utf - 8 " ) <nl> + doc . parsed_response [ ' error ' ] . should eq ( false ) <nl> + doc . parsed_response [ ' code ' ] . should eq ( 201 ) <nl> + doc . parsed_response [ ' hasMore ' ] . should eq ( false ) <nl> + doc . parsed_response [ ' result ' ] . length . should eq ( 0 ) <nl> + doc . parsed_response [ ' count ' ] . should eq ( 0 ) <nl> + end <nl> + <nl> + it " finds the examples " do <nl> + # create data <nl> + <nl> + ( 0 . . 10 ) . each do | i | <nl> + ( 0 . . 10 ) . each do | j | <nl> + body = " { \ " i \ " : # { i } , \ " j \ " : # { j } } " <nl> + doc = ArangoDB . post ( " / _api / document ? collection = # { @ cn } " , : body = > body ) <nl> + doc . code . should eq ( 202 ) <nl> + end <nl> + end <nl> + <nl> + # create index <nl> + cmd = " / _api / index ? collection = # { @ cn } " <nl> + body = " { \ " type \ " : \ " hash \ " , \ " unique \ " : false , \ " fields \ " : [ \ " i \ " , \ " j \ " ] } " <nl> + doc = ArangoDB . log_post ( " # { prefix } - hash - index " , cmd , : body = > body ) <nl> + <nl> + doc . code . should eq ( 201 ) <nl> + iid = doc . parsed_response [ ' id ' ] <nl> + <nl> + # by - example - hash <nl> + cmd = api + " / by - example - hash " <nl> + body = " { \ " collection \ " : \ " # { @ cn } \ " , \ " index \ " : \ " # { iid } \ " , \ " example \ " : { \ " i \ " : 1 , \ " j \ " : 7 } } " <nl> + doc = ArangoDB . log_put ( " # { prefix } - hash " , cmd , : body = > body ) <nl> + <nl> + doc . code . should eq ( 201 ) <nl> + doc . headers [ ' content - type ' ] . should eq ( " application / json ; charset = utf - 8 " ) <nl> + doc . parsed_response [ ' error ' ] . should eq ( false ) <nl> + doc . parsed_response [ ' code ' ] . should eq ( 201 ) <nl> + doc . parsed_response [ ' hasMore ' ] . should eq ( false ) <nl> + doc . parsed_response [ ' result ' ] . length . should eq ( 1 ) <nl> + doc . parsed_response [ ' count ' ] . should eq ( 1 ) <nl> + doc . parsed_response [ ' result ' ] . map { | i | i [ ' i ' ] } . should = ~ [ 1 ] <nl> + doc . parsed_response [ ' result ' ] . map { | i | i [ ' j ' ] } . should = ~ [ 7 ] <nl> + end <nl> + <nl> + it " finds the examples , multiple elements " do <nl> + # create data <nl> + <nl> + ( 0 . . 9 ) . each do | i | <nl> + ( 0 . . 9 ) . each do | j | <nl> + body = " { \ " i \ " : # { i } , \ " j \ " : # { j } } " <nl> + doc = ArangoDB . post ( " / _api / document ? collection = # { @ cn } " , : body = > body ) <nl> + doc . code . should eq ( 202 ) <nl> + end <nl> + end <nl> + <nl> + # create index <nl> + cmd = " / _api / index ? collection = # { @ cn } " <nl> + body = " { \ " type \ " : \ " hash \ " , \ " unique \ " : false , \ " fields \ " : [ \ " i \ " ] } " <nl> + doc = ArangoDB . log_post ( " # { prefix } - hash - index " , cmd , : body = > body ) <nl> + <nl> + doc . code . should eq ( 201 ) <nl> + iid = doc . parsed_response [ ' id ' ] <nl> + <nl> + # by - example - hash <nl> + cmd = api + " / by - example - hash " <nl> + body = " { \ " collection \ " : \ " # { @ cn } \ " , \ " index \ " : \ " # { iid } \ " , \ " example \ " : { \ " i \ " : 1 } } " <nl> + doc = ArangoDB . log_put ( " # { prefix } - hash " , cmd , : body = > body ) <nl> + <nl> + doc . code . should eq ( 201 ) <nl> + doc . headers [ ' content - type ' ] . should eq ( " application / json ; charset = utf - 8 " ) <nl> + doc . parsed_response [ ' error ' ] . should eq ( false ) <nl> + doc . parsed_response [ ' code ' ] . should eq ( 201 ) <nl> + doc . parsed_response [ ' hasMore ' ] . should eq ( false ) <nl> + doc . parsed_response [ ' result ' ] . length . should eq ( 10 ) <nl> + doc . parsed_response [ ' count ' ] . should eq ( 10 ) <nl> + doc . parsed_response [ ' result ' ] . map { | i | i [ ' i ' ] } . should = ~ [ 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ] <nl> + end <nl> + <nl> + it " finds the examples , small batchsize " do <nl> + # create data <nl> + <nl> + ( 0 . . 9 ) . each do | i | <nl> + ( 0 . . 9 ) . each do | j | <nl> + body = " { \ " i \ " : # { i } , \ " j \ " : # { j } } " <nl> + doc = ArangoDB . post ( " / _api / document ? collection = # { @ cn } " , : body = > body ) <nl> + doc . code . should eq ( 202 ) <nl> + end <nl> + end <nl> + <nl> + # create index <nl> + cmd = " / _api / index ? collection = # { @ cn } " <nl> + body = " { \ " type \ " : \ " hash \ " , \ " unique \ " : false , \ " fields \ " : [ \ " i \ " ] } " <nl> + doc = ArangoDB . log_post ( " # { prefix } - hash - index " , cmd , : body = > body ) <nl> + <nl> + doc . code . should eq ( 201 ) <nl> + iid = doc . parsed_response [ ' id ' ] <nl> + <nl> + # by - example - hash <nl> + cmd = api + " / by - example - hash " <nl> + body = " { \ " collection \ " : \ " # { @ cn } \ " , \ " index \ " : \ " # { iid } \ " , \ " example \ " : { \ " i \ " : 0 } , \ " batchSize \ " : 2 } " <nl> + doc = ArangoDB . log_put ( " # { prefix } - hash " , cmd , : body = > body ) <nl> + <nl> + doc . code . should eq ( 201 ) <nl> + doc . headers [ ' content - type ' ] . should eq ( " application / json ; charset = utf - 8 " ) <nl> + doc . parsed_response [ ' error ' ] . should eq ( false ) <nl> + doc . parsed_response [ ' code ' ] . should eq ( 201 ) <nl> + doc . parsed_response [ ' hasMore ' ] . should eq ( true ) <nl> + doc . parsed_response [ ' result ' ] . length . should eq ( 2 ) <nl> + doc . parsed_response [ ' count ' ] . should eq ( 10 ) <nl> + doc . parsed_response [ ' result ' ] . map { | i | i [ ' i ' ] } . should = ~ [ 0 , 0 ] <nl> + end <nl> + end <nl> + <nl> + end <nl> + end <nl> new file mode 100644 <nl> index 00000000000 . . 05defef8a18 <nl> mmm / dev / null <nl> ppp b / UnitTests / HttpInterface / api - simple - skiplist - spec . rb <nl> <nl> + # coding : utf - 8 <nl> + <nl> + require ' rspec ' <nl> + require ' . / arangodb . rb ' <nl> + <nl> + describe ArangoDB do <nl> + api = " / _api / simple " <nl> + prefix = " api - simple " <nl> + <nl> + context " simple queries : " do <nl> + <nl> + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> + # # range query <nl> + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> + <nl> + context " skiplist query : " do <nl> + before do <nl> + @ cn = " UnitTestsCollectionSkiplist " <nl> + ArangoDB . drop_collection ( @ cn ) <nl> + @ cid = ArangoDB . create_collection ( @ cn , false ) <nl> + end <nl> + <nl> + after do <nl> + ArangoDB . drop_collection ( @ cn ) <nl> + end <nl> + <nl> + it " finds the examples , wrong index specified " do <nl> + cmd = api + " / by - example - skiplist " <nl> + body = " { \ " collection \ " : \ " # { @ cn } \ " , \ " index \ " : \ " 1 \ " , \ " example \ " : { \ " i \ " : 12 } } " <nl> + doc = ArangoDB . log_put ( " # { prefix } - skiplist " , cmd , : body = > body ) <nl> + <nl> + doc . code . should eq ( 404 ) <nl> + doc . headers [ ' content - type ' ] . should eq ( " application / json ; charset = utf - 8 " ) <nl> + doc . parsed_response [ ' code ' ] . should eq ( 404 ) <nl> + doc . parsed_response [ ' error ' ] . should eq ( true ) <nl> + doc . parsed_response [ ' errorNum ' ] . should eq ( 1209 ) <nl> + end <nl> + <nl> + it " finds the examples , wrong attribute " do <nl> + # create index <nl> + cmd = " / _api / index ? collection = # { @ cn } " <nl> + body = " { \ " type \ " : \ " skiplist \ " , \ " unique \ " : true , \ " fields \ " : [ \ " i \ " ] } " <nl> + doc = ArangoDB . log_post ( " # { prefix } - skiplist - index " , cmd , : body = > body ) <nl> + <nl> + doc . code . should eq ( 201 ) <nl> + iid = doc . parsed_response [ ' id ' ] <nl> + <nl> + cmd = api + " / by - example - skiplist " <nl> + body = " { \ " collection \ " : \ " # { @ cn } \ " , \ " index \ " : \ " # { iid } \ " , \ " example \ " : { \ " j \ " : 12 } } " <nl> + doc = ArangoDB . log_put ( " # { prefix } - skiplist " , cmd , : body = > body ) <nl> + <nl> + doc . code . should eq ( 404 ) <nl> + doc . headers [ ' content - type ' ] . should eq ( " application / json ; charset = utf - 8 " ) <nl> + doc . parsed_response [ ' code ' ] . should eq ( 404 ) <nl> + doc . parsed_response [ ' error ' ] . should eq ( true ) <nl> + doc . parsed_response [ ' errorNum ' ] . should eq ( 1209 ) <nl> + end <nl> + <nl> + it " finds the examples , no index specified " do <nl> + cmd = api + " / by - example - skiplist " <nl> + body = " { \ " collection \ " : \ " # { @ cn } \ " , \ " example \ " : { \ " i \ " : 12 } } " <nl> + doc = ArangoDB . log_put ( " # { prefix } - skiplist " , cmd , : body = > body ) <nl> + <nl> + doc . code . should eq ( 201 ) <nl> + doc . headers [ ' content - type ' ] . should eq ( " application / json ; charset = utf - 8 " ) <nl> + doc . parsed_response [ ' error ' ] . should eq ( false ) <nl> + doc . parsed_response [ ' code ' ] . should eq ( 201 ) <nl> + doc . parsed_response [ ' hasMore ' ] . should eq ( false ) <nl> + doc . parsed_response [ ' result ' ] . length . should eq ( 0 ) <nl> + doc . parsed_response [ ' count ' ] . should eq ( 0 ) <nl> + end <nl> + <nl> + it " finds the examples , unique index " do <nl> + # create data <nl> + for i in [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ] <nl> + body = " { \ " i \ " : # { i } } " <nl> + doc = ArangoDB . post ( " / _api / document ? collection = # { @ cn } " , : body = > body ) <nl> + doc . code . should eq ( 202 ) <nl> + end <nl> + <nl> + # create index <nl> + cmd = " / _api / index ? collection = # { @ cn } " <nl> + body = " { \ " type \ " : \ " skiplist \ " , \ " unique \ " : true , \ " fields \ " : [ \ " i \ " ] } " <nl> + doc = ArangoDB . log_post ( " # { prefix } - skiplist - index " , cmd , : body = > body ) <nl> + <nl> + doc . code . should eq ( 201 ) <nl> + iid = doc . parsed_response [ ' id ' ] <nl> + <nl> + # by - example - skiplist <nl> + cmd = api + " / by - example - skiplist " <nl> + body = " { \ " collection \ " : \ " # { @ cn } \ " , \ " index \ " : \ " # { iid } \ " , \ " example \ " : { \ " i \ " : 3 } } " <nl> + doc = ArangoDB . log_put ( " # { prefix } - skiplist " , cmd , : body = > body ) <nl> + <nl> + doc . code . should eq ( 201 ) <nl> + doc . headers [ ' content - type ' ] . should eq ( " application / json ; charset = utf - 8 " ) <nl> + doc . parsed_response [ ' error ' ] . should eq ( false ) <nl> + doc . parsed_response [ ' code ' ] . should eq ( 201 ) <nl> + doc . parsed_response [ ' hasMore ' ] . should eq ( false ) <nl> + doc . parsed_response [ ' result ' ] . length . should eq ( 1 ) <nl> + doc . parsed_response [ ' count ' ] . should eq ( 1 ) <nl> + doc . parsed_response [ ' result ' ] . map { | i | i [ ' i ' ] } . should = ~ [ 3 ] <nl> + <nl> + body = " { \ " collection \ " : \ " # { @ cn } \ " , \ " index \ " : \ " # { iid } \ " , \ " example \ " : { \ " i \ " : 12 } } " <nl> + doc = ArangoDB . log_put ( " # { prefix } - skiplist " , cmd , : body = > body ) <nl> + <nl> + doc . code . should eq ( 201 ) <nl> + doc . headers [ ' content - type ' ] . should eq ( " application / json ; charset = utf - 8 " ) <nl> + doc . parsed_response [ ' error ' ] . should eq ( false ) <nl> + doc . parsed_response [ ' code ' ] . should eq ( 201 ) <nl> + doc . parsed_response [ ' hasMore ' ] . should eq ( false ) <nl> + doc . parsed_response [ ' result ' ] . length . should eq ( 0 ) <nl> + doc . parsed_response [ ' count ' ] . should eq ( 0 ) <nl> + end <nl> + <nl> + it " finds the examples , non - unique index " do <nl> + # create data <nl> + for i in [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ] <nl> + body = " { \ " i \ " : # { i } , \ " j \ " : 2 } " <nl> + doc = ArangoDB . post ( " / _api / document ? collection = # { @ cn } " , : body = > body ) <nl> + doc . code . should eq ( 202 ) <nl> + end <nl> + <nl> + # create index <nl> + cmd = " / _api / index ? collection = # { @ cn } " <nl> + body = " { \ " type \ " : \ " skiplist \ " , \ " unique \ " : false , \ " fields \ " : [ \ " j \ " , \ " i \ " ] } " <nl> + doc = ArangoDB . log_post ( " # { prefix } - skiplist - index " , cmd , : body = > body ) <nl> + <nl> + doc . code . should eq ( 201 ) <nl> + iid = doc . parsed_response [ ' id ' ] <nl> + <nl> + # by - example - skiplist <nl> + cmd = api + " / by - example - skiplist " <nl> + body = " { \ " collection \ " : \ " # { @ cn } \ " , \ " index \ " : \ " # { iid } \ " , \ " example \ " : { \ " j \ " : 2 , \ " i \ " : 2 } } " <nl> + doc = ArangoDB . log_put ( " # { prefix } - skiplist " , cmd , : body = > body ) <nl> + <nl> + doc . code . should eq ( 201 ) <nl> + doc . headers [ ' content - type ' ] . should eq ( " application / json ; charset = utf - 8 " ) <nl> + doc . parsed_response [ ' error ' ] . should eq ( false ) <nl> + doc . parsed_response [ ' code ' ] . should eq ( 201 ) <nl> + doc . parsed_response [ ' hasMore ' ] . should eq ( false ) <nl> + doc . parsed_response [ ' result ' ] . length . should eq ( 1 ) <nl> + doc . parsed_response [ ' count ' ] . should eq ( 1 ) <nl> + doc . parsed_response [ ' result ' ] . map { | i | i [ ' i ' ] } . should = ~ [ 2 ] <nl> + doc . parsed_response [ ' result ' ] . map { | i | i [ ' j ' ] } . should = ~ [ 2 ] <nl> + <nl> + body = " { \ " collection \ " : \ " # { @ cn } \ " , \ " index \ " : \ " # { iid } \ " , \ " example \ " : { \ " i \ " : 2 , \ " j \ " : 2 } } " <nl> + doc = ArangoDB . log_put ( " # { prefix } - skiplist " , cmd , : body = > body ) <nl> + <nl> + doc . code . should eq ( 201 ) <nl> + doc . headers [ ' content - type ' ] . should eq ( " application / json ; charset = utf - 8 " ) <nl> + doc . parsed_response [ ' error ' ] . should eq ( false ) <nl> + doc . parsed_response [ ' code ' ] . should eq ( 201 ) <nl> + doc . parsed_response [ ' hasMore ' ] . should eq ( false ) <nl> + doc . parsed_response [ ' result ' ] . length . should eq ( 1 ) <nl> + doc . parsed_response [ ' count ' ] . should eq ( 1 ) <nl> + doc . parsed_response [ ' result ' ] . map { | i | i [ ' i ' ] } . should = ~ [ 2 ] <nl> + doc . parsed_response [ ' result ' ] . map { | i | i [ ' j ' ] } . should = ~ [ 2 ] <nl> + <nl> + body = " { \ " collection \ " : \ " # { @ cn } \ " , \ " index \ " : \ " # { iid } \ " , \ " example \ " : { \ " j \ " : 3 , \ " i \ " : 2 } } " <nl> + doc = ArangoDB . log_put ( " # { prefix } - skiplist " , cmd , : body = > body ) <nl> + <nl> + doc . code . should eq ( 201 ) <nl> + doc . headers [ ' content - type ' ] . should eq ( " application / json ; charset = utf - 8 " ) <nl> + doc . parsed_response [ ' error ' ] . should eq ( false ) <nl> + doc . parsed_response [ ' code ' ] . should eq ( 201 ) <nl> + doc . parsed_response [ ' hasMore ' ] . should eq ( false ) <nl> + doc . parsed_response [ ' result ' ] . length . should eq ( 0 ) <nl> + doc . parsed_response [ ' count ' ] . should eq ( 0 ) <nl> + end <nl> + <nl> + it " finds the examples " do <nl> + # create data <nl> + <nl> + ( 0 . . 10 ) . each do | i | <nl> + ( 0 . . 10 ) . each do | j | <nl> + body = " { \ " i \ " : # { i } , \ " j \ " : # { j } } " <nl> + doc = ArangoDB . post ( " / _api / document ? collection = # { @ cn } " , : body = > body ) <nl> + doc . code . should eq ( 202 ) <nl> + end <nl> + end <nl> + <nl> + # create index <nl> + cmd = " / _api / index ? collection = # { @ cn } " <nl> + body = " { \ " type \ " : \ " skiplist \ " , \ " unique \ " : false , \ " fields \ " : [ \ " i \ " , \ " j \ " ] } " <nl> + doc = ArangoDB . log_post ( " # { prefix } - skiplist - index " , cmd , : body = > body ) <nl> + <nl> + doc . code . should eq ( 201 ) <nl> + iid = doc . parsed_response [ ' id ' ] <nl> + <nl> + # by - example - skiplist <nl> + cmd = api + " / by - example - skiplist " <nl> + body = " { \ " collection \ " : \ " # { @ cn } \ " , \ " index \ " : \ " # { iid } \ " , \ " example \ " : { \ " i \ " : 1 , \ " j \ " : 7 } } " <nl> + doc = ArangoDB . log_put ( " # { prefix } - skiplist " , cmd , : body = > body ) <nl> + <nl> + doc . code . should eq ( 201 ) <nl> + doc . headers [ ' content - type ' ] . should eq ( " application / json ; charset = utf - 8 " ) <nl> + doc . parsed_response [ ' error ' ] . should eq ( false ) <nl> + doc . parsed_response [ ' code ' ] . should eq ( 201 ) <nl> + doc . parsed_response [ ' hasMore ' ] . should eq ( false ) <nl> + doc . parsed_response [ ' result ' ] . length . should eq ( 1 ) <nl> + doc . parsed_response [ ' count ' ] . should eq ( 1 ) <nl> + doc . parsed_response [ ' result ' ] . map { | i | i [ ' i ' ] } . should = ~ [ 1 ] <nl> + doc . parsed_response [ ' result ' ] . map { | i | i [ ' j ' ] } . should = ~ [ 7 ] <nl> + end <nl> + <nl> + it " finds the examples , multiple elements " do <nl> + # create data <nl> + <nl> + ( 0 . . 9 ) . each do | i | <nl> + ( 0 . . 9 ) . each do | j | <nl> + body = " { \ " i \ " : # { i } , \ " j \ " : # { j } } " <nl> + doc = ArangoDB . post ( " / _api / document ? collection = # { @ cn } " , : body = > body ) <nl> + doc . code . should eq ( 202 ) <nl> + end <nl> + end <nl> + <nl> + # create index <nl> + cmd = " / _api / index ? collection = # { @ cn } " <nl> + body = " { \ " type \ " : \ " skiplist \ " , \ " unique \ " : false , \ " fields \ " : [ \ " i \ " ] } " <nl> + doc = ArangoDB . log_post ( " # { prefix } - skiplist - index " , cmd , : body = > body ) <nl> + <nl> + doc . code . should eq ( 201 ) <nl> + iid = doc . parsed_response [ ' id ' ] <nl> + <nl> + # by - example - skiplist <nl> + cmd = api + " / by - example - skiplist " <nl> + body = " { \ " collection \ " : \ " # { @ cn } \ " , \ " index \ " : \ " # { iid } \ " , \ " example \ " : { \ " i \ " : 1 } } " <nl> + doc = ArangoDB . log_put ( " # { prefix } - skiplist " , cmd , : body = > body ) <nl> + <nl> + doc . code . should eq ( 201 ) <nl> + doc . headers [ ' content - type ' ] . should eq ( " application / json ; charset = utf - 8 " ) <nl> + doc . parsed_response [ ' error ' ] . should eq ( false ) <nl> + doc . parsed_response [ ' code ' ] . should eq ( 201 ) <nl> + doc . parsed_response [ ' hasMore ' ] . should eq ( false ) <nl> + doc . parsed_response [ ' result ' ] . length . should eq ( 10 ) <nl> + doc . parsed_response [ ' count ' ] . should eq ( 10 ) <nl> + doc . parsed_response [ ' result ' ] . map { | i | i [ ' i ' ] } . should = ~ [ 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ] <nl> + end <nl> + <nl> + it " finds the examples , small batchsize " do <nl> + # create data <nl> + <nl> + ( 0 . . 9 ) . each do | i | <nl> + ( 0 . . 9 ) . each do | j | <nl> + body = " { \ " i \ " : # { i } , \ " j \ " : # { j } } " <nl> + doc = ArangoDB . post ( " / _api / document ? collection = # { @ cn } " , : body = > body ) <nl> + doc . code . should eq ( 202 ) <nl> + end <nl> + end <nl> + <nl> + # create index <nl> + cmd = " / _api / index ? collection = # { @ cn } " <nl> + body = " { \ " type \ " : \ " skiplist \ " , \ " unique \ " : false , \ " fields \ " : [ \ " i \ " ] } " <nl> + doc = ArangoDB . log_post ( " # { prefix } - skiplist - index " , cmd , : body = > body ) <nl> + <nl> + doc . code . should eq ( 201 ) <nl> + iid = doc . parsed_response [ ' id ' ] <nl> + <nl> + # by - example - skiplist <nl> + cmd = api + " / by - example - skiplist " <nl> + body = " { \ " collection \ " : \ " # { @ cn } \ " , \ " index \ " : \ " # { iid } \ " , \ " example \ " : { \ " i \ " : 0 } , \ " batchSize \ " : 2 } " <nl> + doc = ArangoDB . log_put ( " # { prefix } - skiplist " , cmd , : body = > body ) <nl> + <nl> + doc . code . should eq ( 201 ) <nl> + doc . headers [ ' content - type ' ] . should eq ( " application / json ; charset = utf - 8 " ) <nl> + doc . parsed_response [ ' error ' ] . should eq ( false ) <nl> + doc . parsed_response [ ' code ' ] . should eq ( 201 ) <nl> + doc . parsed_response [ ' hasMore ' ] . should eq ( true ) <nl> + doc . parsed_response [ ' result ' ] . length . should eq ( 2 ) <nl> + doc . parsed_response [ ' count ' ] . should eq ( 10 ) <nl> + doc . parsed_response [ ' result ' ] . map { | i | i [ ' i ' ] } . should = ~ [ 0 , 0 ] <nl> + end <nl> + end <nl> + <nl> + end <nl> + end <nl> mmm a / UnitTests / HttpInterface / run - tests <nl> ppp b / UnitTests / HttpInterface / run - tests <nl> rspec - - color - - format d \ <nl> api - simple - example - spec . rb \ <nl> api - simple - fulltext - spec . rb \ <nl> api - simple - geo - spec . rb \ <nl> + api - simple - hash - spec . rb \ <nl> api - simple - range - spec . rb \ <nl> + api - simple - skiplist - spec . rb \ <nl> api - simple - spec . rb \ <nl> api - structures . rb \ <nl> api - transactions - spec . rb \ <nl>
added tests
arangodb/arangodb
5c13019522a261a8ad7549ade88fbf314842bf88
2014-02-17T10:37:49Z
mmm a / modules / ml / src / tree . cpp <nl> ppp b / modules / ml / src / tree . cpp <nl> int DTreesImpl : : addTree ( const vector < int > & sidx ) <nl> int ssize = getSubsetSize ( split . varIdx ) ; <nl> split . subsetOfs = ( int ) subsets . size ( ) ; <nl> subsets . resize ( split . subsetOfs + ssize ) ; <nl> - memcpy ( & subsets [ split . subsetOfs ] , & w - > wsubsets [ wsplit . subsetOfs ] , ssize * sizeof ( int ) ) ; <nl> + / / This check verifies that subsets index is in the correct range <nl> + / / as in case ssize = = 0 no real resize performed . <nl> + / / Thus memory kept safe . <nl> + / / Also this skips useless memcpy call when size parameter is zero <nl> + if ( ssize > 0 ) <nl> + { <nl> + memcpy ( & subsets [ split . subsetOfs ] , & w - > wsubsets [ wsplit . subsetOfs ] , ssize * sizeof ( int ) ) ; <nl> + } <nl> } <nl> node . split = ( int ) splits . size ( ) ; <nl> splits . push_back ( split ) ; <nl>
Fixing invalid opencv_test_ml calls
opencv/opencv
91bd7df8c1be1f4cb0d59207c99ba7c8afc24a43
2015-03-20T14:49:03Z
mmm a / src / idl_gen_js . cpp <nl> ppp b / src / idl_gen_js . cpp <nl> class JsGenerator : public BaseGenerator { <nl> const auto basename = <nl> flatbuffers : : StripPath ( flatbuffers : : StripExtension ( file ) ) ; <nl> if ( basename ! = file_name_ ) { <nl> - const auto file_name = basename + kGeneratedFileNamePostfix ; <nl> - code + = GenPrefixedImport ( file , file_name ) ; <nl> + code + = GenPrefixedImport ( file , basename ) ; <nl> } <nl> } <nl> } <nl> class JsGenerator : public BaseGenerator { <nl> return " NS " + std : : to_string ( HashFnv1a < uint64_t > ( file . c_str ( ) ) ) ; <nl> } <nl> <nl> - static std : : string GenPrefixedImport ( const std : : string & full_file_name , <nl> - const std : : string & base_file_name ) { <nl> + std : : string GenPrefixedImport ( const std : : string & full_file_name , <nl> + const std : : string & base_name ) { <nl> + / / Either keep the include path as it was <nl> + / / or use only the base_name + kGeneratedFileNamePostfix <nl> + std : : string path ; <nl> + if ( parser_ . opts . keep_include_path ) { <nl> + auto it = parser_ . included_files_ . find ( full_file_name ) ; <nl> + FLATBUFFERS_ASSERT ( it ! = parser_ . included_files_ . end ( ) ) ; <nl> + path = <nl> + flatbuffers : : StripExtension ( it - > second ) + kGeneratedFileNamePostfix ; <nl> + } else { <nl> + path = base_name + kGeneratedFileNamePostfix ; <nl> + } <nl> + <nl> + / / Add the include prefix and make the path always relative <nl> + path = flatbuffers : : ConCatPathFileName ( parser_ . opts . include_prefix , path ) ; <nl> + path = std : : string ( " . " ) + kPathSeparator + path ; <nl> + <nl> return " import * as " + GenFileNamespacePrefix ( full_file_name ) + <nl> - " from \ " . / " + base_file_name + " \ " ; \ n " ; <nl> + " from \ " " + path + " \ " ; \ n " ; <nl> } <nl> <nl> / / Adds a source - dependent prefix , for of import * statements . <nl>
- - keep - prefix for JS generator ( )
google/flatbuffers
db0fcdd906422be064ca9bf543b95b6de0f61e6b
2018-11-02T15:54:43Z
mmm a / BUILD <nl> ppp b / BUILD <nl> grpc_cc_library ( <nl> ] , <nl> ) <nl> <nl> + grpc_cc_library ( <nl> + name = " grpc + + _internal_hdrs_only " , <nl> + hdrs = [ <nl> + " include / grpcpp / impl / codegen / sync . h " , <nl> + ] , <nl> + language = " c + + " , <nl> + deps = [ <nl> + " gpr_codegen " , <nl> + ] , <nl> + ) <nl> + <nl> grpc_cc_library ( <nl> name = " gpr_base " , <nl> srcs = [ <nl> grpc_cc_library ( <nl> " src / core / lib / gprpp / manual_constructor . h " , <nl> " src / core / lib / gprpp / map . h " , <nl> " src / core / lib / gprpp / memory . h " , <nl> - " src / core / lib / gprpp / mutex_lock . h " , <nl> " src / core / lib / gprpp / pair . h " , <nl> + " src / core / lib / gprpp / sync . h " , <nl> " src / core / lib / gprpp / thd . h " , <nl> " src / core / lib / profiling / timers . h " , <nl> ] , <nl> grpc_cc_library ( <nl> " include / grpcpp / impl / codegen / time . h " , <nl> ] , <nl> deps = [ <nl> + " grpc + + _internal_hdrs_only " , <nl> " grpc_codegen " , <nl> ] , <nl> ) <nl> mmm a / BUILD . gn <nl> ppp b / BUILD . gn <nl> config ( " grpc_config " ) { <nl> " src / core / lib / gprpp / manual_constructor . h " , <nl> " src / core / lib / gprpp / map . h " , <nl> " src / core / lib / gprpp / memory . h " , <nl> - " src / core / lib / gprpp / mutex_lock . h " , <nl> " src / core / lib / gprpp / pair . h " , <nl> + " src / core / lib / gprpp / sync . h " , <nl> " src / core / lib / gprpp / thd . h " , <nl> " src / core / lib / gprpp / thd_posix . cc " , <nl> " src / core / lib / gprpp / thd_windows . cc " , <nl> config ( " grpc_config " ) { <nl> " include / grpcpp / impl / codegen / status_code_enum . h " , <nl> " include / grpcpp / impl / codegen / string_ref . h " , <nl> " include / grpcpp / impl / codegen / stub_options . h " , <nl> + " include / grpcpp / impl / codegen / sync . h " , <nl> " include / grpcpp / impl / codegen / sync_stream . h " , <nl> " include / grpcpp / impl / codegen / time . h " , <nl> " include / grpcpp / impl / grpc_library . h " , <nl> config ( " grpc_config " ) { <nl> " src / core / lib / gprpp / manual_constructor . h " , <nl> " src / core / lib / gprpp / map . h " , <nl> " src / core / lib / gprpp / memory . h " , <nl> - " src / core / lib / gprpp / mutex_lock . h " , <nl> " src / core / lib / gprpp / optional . h " , <nl> " src / core / lib / gprpp / orphanable . h " , <nl> " src / core / lib / gprpp / pair . h " , <nl> " src / core / lib / gprpp / ref_counted . h " , <nl> " src / core / lib / gprpp / ref_counted_ptr . h " , <nl> + " src / core / lib / gprpp / sync . h " , <nl> " src / core / lib / gprpp / thd . h " , <nl> " src / core / lib / http / format_request . h " , <nl> " src / core / lib / http / httpcli . h " , <nl> mmm a / CMakeLists . txt <nl> ppp b / CMakeLists . txt <nl> foreach ( _hdr <nl> include / grpcpp / impl / codegen / stub_options . h <nl> include / grpcpp / impl / codegen / sync_stream . h <nl> include / grpcpp / impl / codegen / time . h <nl> + include / grpcpp / impl / codegen / sync . h <nl> include / grpc + + / impl / codegen / proto_utils . h <nl> include / grpcpp / impl / codegen / proto_buffer_reader . h <nl> include / grpcpp / impl / codegen / proto_buffer_writer . h <nl> foreach ( _hdr <nl> include / grpcpp / impl / codegen / stub_options . h <nl> include / grpcpp / impl / codegen / sync_stream . h <nl> include / grpcpp / impl / codegen / time . h <nl> + include / grpcpp / impl / codegen / sync . h <nl> include / grpc / census . h <nl> ) <nl> string ( REPLACE " include / " " " _path $ { _hdr } ) <nl> foreach ( _hdr <nl> include / grpc / impl / codegen / sync_generic . h <nl> include / grpc / impl / codegen / sync_posix . h <nl> include / grpc / impl / codegen / sync_windows . h <nl> + include / grpcpp / impl / codegen / sync . h <nl> include / grpc + + / impl / codegen / proto_utils . h <nl> include / grpcpp / impl / codegen / proto_buffer_reader . h <nl> include / grpcpp / impl / codegen / proto_buffer_writer . h <nl> foreach ( _hdr <nl> include / grpc / impl / codegen / sync_generic . h <nl> include / grpc / impl / codegen / sync_posix . h <nl> include / grpc / impl / codegen / sync_windows . h <nl> + include / grpcpp / impl / codegen / sync . h <nl> include / grpc + + / impl / codegen / proto_utils . h <nl> include / grpcpp / impl / codegen / proto_buffer_reader . h <nl> include / grpcpp / impl / codegen / proto_buffer_writer . h <nl> foreach ( _hdr <nl> include / grpcpp / impl / codegen / stub_options . h <nl> include / grpcpp / impl / codegen / sync_stream . h <nl> include / grpcpp / impl / codegen / time . h <nl> + include / grpcpp / impl / codegen / sync . h <nl> ) <nl> string ( REPLACE " include / " " " _path $ { _hdr } ) <nl> get_filename_component ( _path $ { _path } PATH ) <nl> mmm a / Makefile <nl> ppp b / Makefile <nl> PUBLIC_HEADERS_CXX + = \ <nl> include / grpcpp / impl / codegen / stub_options . h \ <nl> include / grpcpp / impl / codegen / sync_stream . h \ <nl> include / grpcpp / impl / codegen / time . h \ <nl> + include / grpcpp / impl / codegen / sync . h \ <nl> include / grpc + + / impl / codegen / proto_utils . h \ <nl> include / grpcpp / impl / codegen / proto_buffer_reader . h \ <nl> include / grpcpp / impl / codegen / proto_buffer_writer . h \ <nl> PUBLIC_HEADERS_CXX + = \ <nl> include / grpcpp / impl / codegen / stub_options . h \ <nl> include / grpcpp / impl / codegen / sync_stream . h \ <nl> include / grpcpp / impl / codegen / time . h \ <nl> + include / grpcpp / impl / codegen / sync . h \ <nl> include / grpc / census . h \ <nl> <nl> LIBGRPC + + _CRONET_OBJS = $ ( addprefix $ ( OBJDIR ) / $ ( CONFIG ) / , $ ( addsuffix . o , $ ( basename $ ( LIBGRPC + + _CRONET_SRC ) ) ) ) <nl> PUBLIC_HEADERS_CXX + = \ <nl> include / grpc / impl / codegen / sync_generic . h \ <nl> include / grpc / impl / codegen / sync_posix . h \ <nl> include / grpc / impl / codegen / sync_windows . h \ <nl> + include / grpcpp / impl / codegen / sync . h \ <nl> include / grpc + + / impl / codegen / proto_utils . h \ <nl> include / grpcpp / impl / codegen / proto_buffer_reader . h \ <nl> include / grpcpp / impl / codegen / proto_buffer_writer . h \ <nl> PUBLIC_HEADERS_CXX + = \ <nl> include / grpc / impl / codegen / sync_generic . h \ <nl> include / grpc / impl / codegen / sync_posix . h \ <nl> include / grpc / impl / codegen / sync_windows . h \ <nl> + include / grpcpp / impl / codegen / sync . h \ <nl> include / grpc + + / impl / codegen / proto_utils . h \ <nl> include / grpcpp / impl / codegen / proto_buffer_reader . h \ <nl> include / grpcpp / impl / codegen / proto_buffer_writer . h \ <nl> PUBLIC_HEADERS_CXX + = \ <nl> include / grpcpp / impl / codegen / stub_options . h \ <nl> include / grpcpp / impl / codegen / sync_stream . h \ <nl> include / grpcpp / impl / codegen / time . h \ <nl> + include / grpcpp / impl / codegen / sync . h \ <nl> <nl> LIBGRPC + + _UNSECURE_OBJS = $ ( addprefix $ ( OBJDIR ) / $ ( CONFIG ) / , $ ( addsuffix . o , $ ( basename $ ( LIBGRPC + + _UNSECURE_SRC ) ) ) ) <nl> <nl> mmm a / build . yaml <nl> ppp b / build . yaml <nl> filegroups : <nl> - src / core / lib / gprpp / manual_constructor . h <nl> - src / core / lib / gprpp / map . h <nl> - src / core / lib / gprpp / memory . h <nl> - - src / core / lib / gprpp / mutex_lock . h <nl> - src / core / lib / gprpp / pair . h <nl> + - src / core / lib / gprpp / sync . h <nl> - src / core / lib / gprpp / thd . h <nl> - src / core / lib / profiling / timers . h <nl> uses : <nl> filegroups : <nl> - include / grpcpp / impl / codegen / time . h <nl> uses : <nl> - grpc_codegen <nl> + - grpc + + _internal_hdrs_only <nl> - name : grpc + + _codegen_base_src <nl> language : c + + <nl> src : <nl> filegroups : <nl> - grpc_base_headers <nl> - grpc_transport_inproc_headers <nl> - grpc + + _codegen_base <nl> + - grpc + + _internal_hdrs_only <nl> - nanopb_headers <nl> - health_proto <nl> - name : grpc + + _config_proto <nl> filegroups : <nl> public_headers : <nl> - include / grpc + + / impl / codegen / config_protobuf . h <nl> - include / grpcpp / impl / codegen / config_protobuf . h <nl> + - name : grpc + + _internal_hdrs_only <nl> + language : c + + <nl> + public_headers : <nl> + - include / grpcpp / impl / codegen / sync . h <nl> - name : grpc + + _reflection_proto <nl> language : c + + <nl> src : <nl> mmm a / gRPC - C + + . podspec <nl> ppp b / gRPC - C + + . podspec <nl> Pod : : Spec . new do | s | <nl> ' include / grpcpp / impl / codegen / string_ref . h ' , <nl> ' include / grpcpp / impl / codegen / stub_options . h ' , <nl> ' include / grpcpp / impl / codegen / sync_stream . h ' , <nl> - ' include / grpcpp / impl / codegen / time . h ' <nl> + ' include / grpcpp / impl / codegen / time . h ' , <nl> + ' include / grpcpp / impl / codegen / sync . h ' <nl> end <nl> <nl> s . subspec ' Implementation ' do | ss | <nl> Pod : : Spec . new do | s | <nl> ' src / core / lib / gprpp / manual_constructor . h ' , <nl> ' src / core / lib / gprpp / map . h ' , <nl> ' src / core / lib / gprpp / memory . h ' , <nl> - ' src / core / lib / gprpp / mutex_lock . h ' , <nl> ' src / core / lib / gprpp / pair . h ' , <nl> + ' src / core / lib / gprpp / sync . h ' , <nl> ' src / core / lib / gprpp / thd . h ' , <nl> ' src / core / lib / profiling / timers . h ' , <nl> ' src / core / ext / transport / chttp2 / transport / bin_decoder . h ' , <nl> Pod : : Spec . new do | s | <nl> ' src / core / lib / gprpp / manual_constructor . h ' , <nl> ' src / core / lib / gprpp / map . h ' , <nl> ' src / core / lib / gprpp / memory . h ' , <nl> - ' src / core / lib / gprpp / mutex_lock . h ' , <nl> ' src / core / lib / gprpp / pair . h ' , <nl> + ' src / core / lib / gprpp / sync . h ' , <nl> ' src / core / lib / gprpp / thd . h ' , <nl> ' src / core / lib / profiling / timers . h ' , <nl> ' src / core / lib / avl / avl . h ' , <nl> mmm a / gRPC - Core . podspec <nl> ppp b / gRPC - Core . podspec <nl> Pod : : Spec . new do | s | <nl> ' src / core / lib / gprpp / manual_constructor . h ' , <nl> ' src / core / lib / gprpp / map . h ' , <nl> ' src / core / lib / gprpp / memory . h ' , <nl> - ' src / core / lib / gprpp / mutex_lock . h ' , <nl> ' src / core / lib / gprpp / pair . h ' , <nl> + ' src / core / lib / gprpp / sync . h ' , <nl> ' src / core / lib / gprpp / thd . h ' , <nl> ' src / core / lib / profiling / timers . h ' , <nl> ' src / core / lib / gpr / alloc . cc ' , <nl> Pod : : Spec . new do | s | <nl> ' src / core / lib / gprpp / manual_constructor . h ' , <nl> ' src / core / lib / gprpp / map . h ' , <nl> ' src / core / lib / gprpp / memory . h ' , <nl> - ' src / core / lib / gprpp / mutex_lock . h ' , <nl> ' src / core / lib / gprpp / pair . h ' , <nl> + ' src / core / lib / gprpp / sync . h ' , <nl> ' src / core / lib / gprpp / thd . h ' , <nl> ' src / core / lib / profiling / timers . h ' , <nl> ' src / core / ext / transport / chttp2 / transport / bin_decoder . h ' , <nl> mmm a / grpc . gemspec <nl> ppp b / grpc . gemspec <nl> Gem : : Specification . new do | s | <nl> s . files + = % w ( src / core / lib / gprpp / manual_constructor . h ) <nl> s . files + = % w ( src / core / lib / gprpp / map . h ) <nl> s . files + = % w ( src / core / lib / gprpp / memory . h ) <nl> - s . files + = % w ( src / core / lib / gprpp / mutex_lock . h ) <nl> s . files + = % w ( src / core / lib / gprpp / pair . h ) <nl> + s . files + = % w ( src / core / lib / gprpp / sync . h ) <nl> s . files + = % w ( src / core / lib / gprpp / thd . h ) <nl> s . files + = % w ( src / core / lib / profiling / timers . h ) <nl> s . files + = % w ( src / core / lib / gpr / alloc . cc ) <nl> mmm a / include / grpcpp / channel . h <nl> ppp b / include / grpcpp / channel . h <nl> <nl> # include < grpcpp / impl / codegen / client_interceptor . h > <nl> # include < grpcpp / impl / codegen / config . h > <nl> # include < grpcpp / impl / codegen / grpc_library . h > <nl> + # include < grpcpp / impl / codegen / sync . h > <nl> <nl> struct grpc_channel ; <nl> <nl> class Channel final : public ChannelInterface , <nl> grpc_channel * const c_channel_ ; / / owned <nl> <nl> / / mu_ protects callback_cq_ ( the per - channel callbackable completion queue ) <nl> - std : : mutex mu_ ; <nl> + grpc : : internal : : Mutex mu_ ; <nl> <nl> / / callback_cq_ references the callbackable completion queue associated <nl> / / with this channel ( if any ) . It is set on the first call to CallbackCQ ( ) . <nl> mmm a / include / grpcpp / impl / codegen / client_context . h <nl> ppp b / include / grpcpp / impl / codegen / client_context . h <nl> <nl> # include < grpcpp / impl / codegen / slice . h > <nl> # include < grpcpp / impl / codegen / status . h > <nl> # include < grpcpp / impl / codegen / string_ref . h > <nl> + # include < grpcpp / impl / codegen / sync . h > <nl> # include < grpcpp / impl / codegen / time . h > <nl> <nl> struct census_context ; <nl> class ClientContext { <nl> bool idempotent_ ; <nl> bool cacheable_ ; <nl> std : : shared_ptr < Channel > channel_ ; <nl> - std : : mutex mu_ ; <nl> + grpc : : internal : : Mutex mu_ ; <nl> grpc_call * call_ ; <nl> bool call_canceled_ ; <nl> gpr_timespec deadline_ ; <nl> new file mode 100644 <nl> index 00000000000 . . 2ed71eeb9f2 <nl> mmm / dev / null <nl> ppp b / include / grpcpp / impl / codegen / sync . h <nl> <nl> + / * <nl> + * <nl> + * Copyright 2019 gRPC authors . <nl> + * <nl> + * Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + * you may not use this file except in compliance with the License . <nl> + * You may obtain a copy of the License at <nl> + * <nl> + * http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + * <nl> + * Unless required by applicable law or agreed to in writing , software <nl> + * distributed under the License is distributed on an " AS IS " BASIS , <nl> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + * See the License for the specific language governing permissions and <nl> + * limitations under the License . <nl> + * <nl> + * / <nl> + <nl> + # ifndef GRPCPP_IMPL_CODEGEN_SYNC_H <nl> + # define GRPCPP_IMPL_CODEGEN_SYNC_H <nl> + <nl> + # include < grpc / impl / codegen / log . h > <nl> + # include < grpc / impl / codegen / port_platform . h > <nl> + # include < grpc / impl / codegen / sync . h > <nl> + <nl> + # include < grpcpp / impl / codegen / core_codegen_interface . h > <nl> + <nl> + / / The core library is not accessible in C + + codegen headers , and vice versa . <nl> + / / Thus , we need to have duplicate headers with similar functionality . <nl> + / / Make sure any change to this file is also reflected in <nl> + / / src / core / lib / gprpp / sync . h too . <nl> + / / <nl> + / / Whenever possible , prefer " src / core / lib / gprpp / sync . h " over this file , <nl> + / / since in core we do not rely on g_core_codegen_interface and hence do not <nl> + / / pay the costs of virtual function calls . <nl> + <nl> + namespace grpc { <nl> + namespace internal { <nl> + <nl> + class Mutex { <nl> + public : <nl> + Mutex ( ) { g_core_codegen_interface - > gpr_mu_init ( & mu_ ) ; } <nl> + ~ Mutex ( ) { g_core_codegen_interface - > gpr_mu_destroy ( & mu_ ) ; } <nl> + <nl> + Mutex ( const Mutex & ) = delete ; <nl> + Mutex & operator = ( const Mutex & ) = delete ; <nl> + <nl> + gpr_mu * get ( ) { return & mu_ ; } <nl> + const gpr_mu * get ( ) const { return & mu_ ; } <nl> + <nl> + private : <nl> + gpr_mu mu_ ; <nl> + } ; <nl> + <nl> + / / MutexLock is a std : : <nl> + class MutexLock { <nl> + public : <nl> + explicit MutexLock ( Mutex * mu ) : mu_ ( mu - > get ( ) ) { <nl> + g_core_codegen_interface - > gpr_mu_lock ( mu_ ) ; <nl> + } <nl> + explicit MutexLock ( gpr_mu * mu ) : mu_ ( mu ) { <nl> + g_core_codegen_interface - > gpr_mu_lock ( mu_ ) ; <nl> + } <nl> + ~ MutexLock ( ) { g_core_codegen_interface - > gpr_mu_unlock ( mu_ ) ; } <nl> + <nl> + MutexLock ( const MutexLock & ) = delete ; <nl> + MutexLock & operator = ( const MutexLock & ) = delete ; <nl> + <nl> + private : <nl> + gpr_mu * const mu_ ; <nl> + } ; <nl> + <nl> + class ReleasableMutexLock { <nl> + public : <nl> + explicit ReleasableMutexLock ( Mutex * mu ) : mu_ ( mu - > get ( ) ) { <nl> + g_core_codegen_interface - > gpr_mu_lock ( mu_ ) ; <nl> + } <nl> + explicit ReleasableMutexLock ( gpr_mu * mu ) : mu_ ( mu ) { <nl> + g_core_codegen_interface - > gpr_mu_lock ( mu_ ) ; <nl> + } <nl> + ~ ReleasableMutexLock ( ) { <nl> + if ( ! released_ ) g_core_codegen_interface - > gpr_mu_unlock ( mu_ ) ; <nl> + } <nl> + <nl> + ReleasableMutexLock ( const ReleasableMutexLock & ) = delete ; <nl> + ReleasableMutexLock & operator = ( const ReleasableMutexLock & ) = delete ; <nl> + <nl> + void Lock ( ) { <nl> + GPR_DEBUG_ASSERT ( released_ ) ; <nl> + g_core_codegen_interface - > gpr_mu_lock ( mu_ ) ; <nl> + released_ = false ; <nl> + } <nl> + <nl> + void Unlock ( ) { <nl> + GPR_DEBUG_ASSERT ( ! released_ ) ; <nl> + released_ = true ; <nl> + g_core_codegen_interface - > gpr_mu_unlock ( mu_ ) ; <nl> + } <nl> + <nl> + private : <nl> + gpr_mu * const mu_ ; <nl> + bool released_ = false ; <nl> + } ; <nl> + <nl> + class CondVar { <nl> + public : <nl> + CondVar ( ) { g_core_codegen_interface - > gpr_cv_init ( & cv_ ) ; } <nl> + ~ CondVar ( ) { g_core_codegen_interface - > gpr_cv_destroy ( & cv_ ) ; } <nl> + <nl> + CondVar ( const CondVar & ) = delete ; <nl> + CondVar & operator = ( const CondVar & ) = delete ; <nl> + <nl> + void Signal ( ) { g_core_codegen_interface - > gpr_cv_signal ( & cv_ ) ; } <nl> + void Broadcast ( ) { g_core_codegen_interface - > gpr_cv_broadcast ( & cv_ ) ; } <nl> + <nl> + int Wait ( Mutex * mu ) { <nl> + return Wait ( mu , <nl> + g_core_codegen_interface - > gpr_inf_future ( GPR_CLOCK_REALTIME ) ) ; <nl> + } <nl> + int Wait ( Mutex * mu , const gpr_timespec & deadline ) { <nl> + return g_core_codegen_interface - > gpr_cv_wait ( & cv_ , mu - > get ( ) , deadline ) ; <nl> + } <nl> + <nl> + template < typename Predicate > <nl> + void WaitUntil ( Mutex * mu , Predicate pred ) { <nl> + while ( ! pred ( ) ) { <nl> + Wait ( mu , g_core_codegen_interface - > gpr_inf_future ( GPR_CLOCK_REALTIME ) ) ; <nl> + } <nl> + } <nl> + <nl> + private : <nl> + gpr_cv cv_ ; <nl> + } ; <nl> + <nl> + } / / namespace internal <nl> + } / / namespace grpc <nl> + <nl> + # endif / / GRPCPP_IMPL_CODEGEN_SYNC_H <nl> mmm a / include / grpcpp / server . h <nl> ppp b / include / grpcpp / server . h <nl> class Server : public ServerInterface , private GrpcLibraryCodegen { <nl> experimental_registration_type experimental_registration_ { this } ; <nl> <nl> / / Server status <nl> - std : : mutex mu_ ; <nl> + grpc : : internal : : Mutex mu_ ; <nl> bool started_ ; <nl> bool shutdown_ ; <nl> bool shutdown_notified_ ; / / Was notify called on the shutdown_cv_ <nl> <nl> - std : : condition_variable shutdown_cv_ ; <nl> + grpc : : internal : : CondVar shutdown_cv_ ; <nl> <nl> / / It is ok ( but not required ) to nest callback_reqs_mu_ under mu_ . <nl> / / Incrementing callback_reqs_outstanding_ is ok without a lock but it must be <nl> class Server : public ServerInterface , private GrpcLibraryCodegen { <nl> / / during periods of increasing load ; the decrement happens only when memory <nl> / / is maxed out , during server shutdown , or ( possibly in a future version ) <nl> / / during decreasing load , so it is less performance - critical . <nl> - std : : mutex callback_reqs_mu_ ; <nl> - std : : condition_variable callback_reqs_done_cv_ ; <nl> + grpc : : internal : : Mutex callback_reqs_mu_ ; <nl> + grpc : : internal : : CondVar callback_reqs_done_cv_ ; <nl> std : : atomic_int callback_reqs_outstanding_ { 0 } ; <nl> <nl> std : : shared_ptr < GlobalCallbacks > global_callbacks_ ; <nl> mmm a / include / grpcpp / server_impl . h <nl> ppp b / include / grpcpp / server_impl . h <nl> class Server : public grpc : : ServerInterface , private grpc : : GrpcLibraryCodegen { <nl> experimental_registration_type experimental_registration_ { this } ; <nl> <nl> / / Server status <nl> - std : : mutex mu_ ; <nl> + grpc : : internal : : Mutex mu_ ; <nl> bool started_ ; <nl> bool shutdown_ ; <nl> bool shutdown_notified_ ; / / Was notify called on the shutdown_cv_ <nl> <nl> - std : : condition_variable shutdown_cv_ ; <nl> + grpc : : internal : : CondVar shutdown_cv_ ; <nl> <nl> / / It is ok ( but not required ) to nest callback_reqs_mu_ under mu_ . <nl> / / Incrementing callback_reqs_outstanding_ is ok without a lock but it must be <nl> class Server : public grpc : : ServerInterface , private grpc : : GrpcLibraryCodegen { <nl> / / during periods of increasing load ; the decrement happens only when memory <nl> / / is maxed out , during server shutdown , or ( possibly in a future version ) <nl> / / during decreasing load , so it is less performance - critical . <nl> - std : : mutex callback_reqs_mu_ ; <nl> - std : : condition_variable callback_reqs_done_cv_ ; <nl> + grpc : : internal : : Mutex callback_reqs_mu_ ; <nl> + grpc : : internal : : CondVar callback_reqs_done_cv_ ; <nl> std : : atomic_int callback_reqs_outstanding_ { 0 } ; <nl> <nl> std : : shared_ptr < GlobalCallbacks > global_callbacks_ ; <nl> mmm a / package . xml <nl> ppp b / package . xml <nl> <nl> < file baseinstalldir = " / " name = " src / core / lib / gprpp / manual_constructor . h " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / lib / gprpp / map . h " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / lib / gprpp / memory . h " role = " src " / > <nl> - < file baseinstalldir = " / " name = " src / core / lib / gprpp / mutex_lock . h " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / lib / gprpp / pair . h " role = " src " / > <nl> + < file baseinstalldir = " / " name = " src / core / lib / gprpp / sync . h " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / lib / gprpp / thd . h " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / lib / profiling / timers . h " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / lib / gpr / alloc . cc " role = " src " / > <nl> mmm a / src / core / ext / filters / client_channel / client_channel . cc <nl> ppp b / src / core / ext / filters / client_channel / client_channel . cc <nl> <nl> # include " src / core / lib / gpr / string . h " <nl> # include " src / core / lib / gprpp / inlined_vector . h " <nl> # include " src / core / lib / gprpp / manual_constructor . h " <nl> - # include " src / core / lib / gprpp / mutex_lock . h " <nl> + # include " src / core / lib / gprpp / sync . h " <nl> # include " src / core / lib / iomgr / combiner . h " <nl> # include " src / core / lib / iomgr / iomgr . h " <nl> # include " src / core / lib / iomgr / polling_entity . h " <nl> mmm a / src / core / ext / filters / client_channel / health / health_check_client . cc <nl> ppp b / src / core / ext / filters / client_channel / health / health_check_client . cc <nl> <nl> # include " pb_encode . h " <nl> # include " src / core / ext / filters / client_channel / health / health . pb . h " <nl> # include " src / core / lib / debug / trace . h " <nl> - # include " src / core / lib / gprpp / mutex_lock . h " <nl> + # include " src / core / lib / gprpp / sync . h " <nl> # include " src / core / lib / slice / slice_internal . h " <nl> # include " src / core / lib / transport / error_utils . h " <nl> # include " src / core / lib / transport / status_metadata . h " <nl> HealthCheckClient : : HealthCheckClient ( <nl> } <nl> GRPC_CLOSURE_INIT ( & retry_timer_callback_ , OnRetryTimer , this , <nl> grpc_schedule_on_exec_ctx ) ; <nl> - gpr_mu_init ( & mu_ ) ; <nl> StartCall ( ) ; <nl> } <nl> <nl> HealthCheckClient : : ~ HealthCheckClient ( ) { <nl> gpr_log ( GPR_INFO , " destroying HealthCheckClient % p " , this ) ; <nl> } <nl> GRPC_ERROR_UNREF ( error_ ) ; <nl> - gpr_mu_destroy ( & mu_ ) ; <nl> } <nl> <nl> void HealthCheckClient : : NotifyOnHealthChange ( grpc_connectivity_state * state , <nl> mmm a / src / core / ext / filters / client_channel / health / health_check_client . h <nl> ppp b / src / core / ext / filters / client_channel / health / health_check_client . h <nl> <nl> # include " src / core / lib / gprpp / atomic . h " <nl> # include " src / core / lib / gprpp / orphanable . h " <nl> # include " src / core / lib / gprpp / ref_counted_ptr . h " <nl> + # include " src / core / lib / gprpp / sync . h " <nl> # include " src / core / lib / iomgr / call_combiner . h " <nl> # include " src / core / lib / iomgr / closure . h " <nl> # include " src / core / lib / iomgr / polling_entity . h " <nl> class HealthCheckClient : public InternallyRefCounted < HealthCheckClient > { <nl> grpc_pollset_set * interested_parties_ ; / / Do not own . <nl> RefCountedPtr < channelz : : SubchannelNode > channelz_node_ ; <nl> <nl> - gpr_mu mu_ ; <nl> + Mutex mu_ ; <nl> grpc_connectivity_state state_ = GRPC_CHANNEL_CONNECTING ; <nl> grpc_error * error_ = GRPC_ERROR_NONE ; <nl> grpc_connectivity_state * notify_state_ = nullptr ; <nl> mmm a / src / core / ext / filters / client_channel / http_connect_handshaker . cc <nl> ppp b / src / core / ext / filters / client_channel / http_connect_handshaker . cc <nl> <nl> # include " src / core / lib / channel / handshaker_registry . h " <nl> # include " src / core / lib / gpr / env . h " <nl> # include " src / core / lib / gpr / string . h " <nl> - # include " src / core / lib / gprpp / mutex_lock . h " <nl> + # include " src / core / lib / gprpp / sync . h " <nl> # include " src / core / lib / http / format_request . h " <nl> # include " src / core / lib / http / parser . h " <nl> # include " src / core / lib / slice / slice_internal . h " <nl> mmm a / src / core / ext / filters / client_channel / lb_policy / grpclb / grpclb . cc <nl> ppp b / src / core / ext / filters / client_channel / lb_policy / grpclb / grpclb . cc <nl> <nl> # include " src / core / lib / gpr / string . h " <nl> # include " src / core / lib / gprpp / manual_constructor . h " <nl> # include " src / core / lib / gprpp / memory . h " <nl> - # include " src / core / lib / gprpp / mutex_lock . h " <nl> # include " src / core / lib / gprpp / orphanable . h " <nl> # include " src / core / lib / gprpp / ref_counted_ptr . h " <nl> # include " src / core / lib / iomgr / combiner . h " <nl> mmm a / src / core / ext / filters / client_channel / lb_policy / grpclb / grpclb_client_stats . cc <nl> ppp b / src / core / ext / filters / client_channel / lb_policy / grpclb / grpclb_client_stats . cc <nl> <nl> # include < grpc / support / atm . h > <nl> # include < grpc / support / string_util . h > <nl> <nl> - # include " src / core / lib / gprpp / mutex_lock . h " <nl> + # include " src / core / lib / gprpp / sync . h " <nl> <nl> namespace grpc_core { <nl> <nl> mmm a / src / core / ext / filters / client_channel / lb_policy / grpclb / grpclb_client_stats . h <nl> ppp b / src / core / ext / filters / client_channel / lb_policy / grpclb / grpclb_client_stats . h <nl> <nl> # include " src / core / lib / gprpp / inlined_vector . h " <nl> # include " src / core / lib / gprpp / memory . h " <nl> # include " src / core / lib / gprpp / ref_counted . h " <nl> + # include " src / core / lib / gprpp / sync . h " <nl> <nl> namespace grpc_core { <nl> <nl> class GrpcLbClientStats : public RefCounted < GrpcLbClientStats > { <nl> <nl> typedef InlinedVector < DropTokenCount , 10 > DroppedCallCounts ; <nl> <nl> - GrpcLbClientStats ( ) { gpr_mu_init ( & drop_count_mu_ ) ; } <nl> - ~ GrpcLbClientStats ( ) { gpr_mu_destroy ( & drop_count_mu_ ) ; } <nl> - <nl> void AddCallStarted ( ) ; <nl> void AddCallFinished ( bool finished_with_client_failed_to_send , <nl> bool finished_known_received ) ; <nl> class GrpcLbClientStats : public RefCounted < GrpcLbClientStats > { <nl> gpr_atm num_calls_finished_ = 0 ; <nl> gpr_atm num_calls_finished_with_client_failed_to_send_ = 0 ; <nl> gpr_atm num_calls_finished_known_received_ = 0 ; <nl> - gpr_mu drop_count_mu_ ; / / Guards drop_token_counts_ . <nl> + Mutex drop_count_mu_ ; / / Guards drop_token_counts_ . <nl> UniquePtr < DroppedCallCounts > drop_token_counts_ ; <nl> } ; <nl> <nl> mmm a / src / core / ext / filters / client_channel / lb_policy / pick_first / pick_first . cc <nl> ppp b / src / core / ext / filters / client_channel / lb_policy / pick_first / pick_first . cc <nl> <nl> # include " src / core / ext / filters / client_channel / server_address . h " <nl> # include " src / core / ext / filters / client_channel / subchannel . h " <nl> # include " src / core / lib / channel / channel_args . h " <nl> - # include " src / core / lib / gprpp / mutex_lock . h " <nl> + # include " src / core / lib / gprpp / sync . h " <nl> # include " src / core / lib / iomgr / combiner . h " <nl> # include " src / core / lib / iomgr / sockaddr_utils . h " <nl> # include " src / core / lib / transport / connectivity_state . h " <nl> class PickFirst : public LoadBalancingPolicy { <nl> <nl> / / / Lock and data used to capture snapshots of this channels child <nl> / / / channels and subchannels . This data is consumed by channelz . <nl> - gpr_mu child_refs_mu_ ; <nl> + Mutex child_refs_mu_ ; <nl> channelz : : ChildRefsList child_subchannels_ ; <nl> channelz : : ChildRefsList child_channels_ ; <nl> } ; <nl> <nl> PickFirst : : PickFirst ( Args args ) : LoadBalancingPolicy ( std : : move ( args ) ) { <nl> - gpr_mu_init ( & child_refs_mu_ ) ; <nl> if ( grpc_lb_pick_first_trace . enabled ( ) ) { <nl> gpr_log ( GPR_INFO , " Pick First % p created . " , this ) ; <nl> } <nl> PickFirst : : ~ PickFirst ( ) { <nl> if ( grpc_lb_pick_first_trace . enabled ( ) ) { <nl> gpr_log ( GPR_INFO , " Destroying Pick First % p " , this ) ; <nl> } <nl> - gpr_mu_destroy ( & child_refs_mu_ ) ; <nl> GPR_ASSERT ( subchannel_list_ = = nullptr ) ; <nl> GPR_ASSERT ( latest_pending_subchannel_list_ = = nullptr ) ; <nl> } <nl> mmm a / src / core / ext / filters / client_channel / lb_policy / round_robin / round_robin . cc <nl> ppp b / src / core / ext / filters / client_channel / lb_policy / round_robin / round_robin . cc <nl> <nl> # include " src / core / ext / filters / client_channel / subchannel . h " <nl> # include " src / core / lib / channel / channel_args . h " <nl> # include " src / core / lib / debug / trace . h " <nl> - # include " src / core / lib / gprpp / mutex_lock . h " <nl> # include " src / core / lib / gprpp / ref_counted_ptr . h " <nl> + # include " src / core / lib / gprpp / sync . h " <nl> # include " src / core / lib / iomgr / combiner . h " <nl> # include " src / core / lib / iomgr / sockaddr_utils . h " <nl> # include " src / core / lib / transport / connectivity_state . h " <nl> class RoundRobin : public LoadBalancingPolicy { <nl> bool shutdown_ = false ; <nl> / / / Lock and data used to capture snapshots of this channel ' s child <nl> / / / channels and subchannels . This data is consumed by channelz . <nl> - gpr_mu child_refs_mu_ ; <nl> + Mutex child_refs_mu_ ; <nl> channelz : : ChildRefsList child_subchannels_ ; <nl> channelz : : ChildRefsList child_channels_ ; <nl> } ; <nl> RoundRobin : : PickResult RoundRobin : : Picker : : Pick ( PickArgs * pick , <nl> / / <nl> <nl> RoundRobin : : RoundRobin ( Args args ) : LoadBalancingPolicy ( std : : move ( args ) ) { <nl> - gpr_mu_init ( & child_refs_mu_ ) ; <nl> if ( grpc_lb_round_robin_trace . enabled ( ) ) { <nl> gpr_log ( GPR_INFO , " [ RR % p ] Created " , this ) ; <nl> } <nl> RoundRobin : : ~ RoundRobin ( ) { <nl> if ( grpc_lb_round_robin_trace . enabled ( ) ) { <nl> gpr_log ( GPR_INFO , " [ RR % p ] Destroying Round Robin policy " , this ) ; <nl> } <nl> - gpr_mu_destroy ( & child_refs_mu_ ) ; <nl> GPR_ASSERT ( subchannel_list_ = = nullptr ) ; <nl> GPR_ASSERT ( latest_pending_subchannel_list_ = = nullptr ) ; <nl> } <nl> mmm a / src / core / ext / filters / client_channel / lb_policy / xds / xds . cc <nl> ppp b / src / core / ext / filters / client_channel / lb_policy / xds / xds . cc <nl> <nl> # include " src / core / lib / gprpp / manual_constructor . h " <nl> # include " src / core / lib / gprpp / map . h " <nl> # include " src / core / lib / gprpp / memory . h " <nl> - # include " src / core / lib / gprpp / mutex_lock . h " <nl> # include " src / core / lib / gprpp / orphanable . h " <nl> # include " src / core / lib / gprpp / ref_counted_ptr . h " <nl> + # include " src / core / lib / gprpp / sync . h " <nl> # include " src / core / lib / iomgr / combiner . h " <nl> # include " src / core / lib / iomgr / sockaddr . h " <nl> # include " src / core / lib / iomgr / sockaddr_utils . h " <nl> class XdsLb : public LoadBalancingPolicy { <nl> class LocalityEntry : public InternallyRefCounted < LocalityEntry > { <nl> public : <nl> explicit LocalityEntry ( RefCountedPtr < XdsLb > parent ) <nl> - : parent_ ( std : : move ( parent ) ) { <nl> - gpr_mu_init ( & child_policy_mu_ ) ; <nl> - } <nl> - ~ LocalityEntry ( ) { gpr_mu_destroy ( & child_policy_mu_ ) ; } <nl> + : parent_ ( std : : move ( parent ) ) { } <nl> + ~ LocalityEntry ( ) = default ; <nl> <nl> void UpdateLocked ( xds_grpclb_serverlist * serverlist , <nl> LoadBalancingPolicy : : Config * child_policy_config , <nl> class XdsLb : public LoadBalancingPolicy { <nl> OrphanablePtr < LoadBalancingPolicy > pending_child_policy_ ; <nl> / / Lock held when modifying the value of child_policy_ or <nl> / / pending_child_policy_ . <nl> - gpr_mu child_policy_mu_ ; <nl> + Mutex child_policy_mu_ ; <nl> RefCountedPtr < XdsLb > parent_ ; <nl> } ; <nl> <nl> - LocalityMap ( ) { gpr_mu_init ( & child_refs_mu_ ) ; } <nl> - ~ LocalityMap ( ) { gpr_mu_destroy ( & child_refs_mu_ ) ; } <nl> - <nl> void UpdateLocked ( const LocalityList & locality_list , <nl> LoadBalancingPolicy : : Config * child_policy_config , <nl> const grpc_channel_args * args , XdsLb * parent ) ; <nl> class XdsLb : public LoadBalancingPolicy { <nl> Map < UniquePtr < char > , OrphanablePtr < LocalityEntry > , StringLess > map_ ; <nl> / / Lock held while filling child refs for all localities <nl> / / inside the map <nl> - gpr_mu child_refs_mu_ ; <nl> + Mutex child_refs_mu_ ; <nl> } ; <nl> <nl> struct LocalityServerlistEntry { <nl> class XdsLb : public LoadBalancingPolicy { <nl> / / Mutex to protect the channel to the LB server . This is used when <nl> / / processing a channelz request . <nl> / / TODO ( juanlishen ) : Replace this with atomic . <nl> - gpr_mu lb_chand_mu_ ; <nl> + Mutex lb_chand_mu_ ; <nl> <nl> / / Timeout in milliseconds for the LB call . 0 means no deadline . <nl> int lb_call_timeout_ms_ = 0 ; <nl> XdsLb : : XdsLb ( Args args ) <nl> : LoadBalancingPolicy ( std : : move ( args ) ) , <nl> locality_map_ ( ) , <nl> locality_serverlist_ ( ) { <nl> - gpr_mu_init ( & lb_chand_mu_ ) ; <nl> / / Record server name . <nl> const grpc_arg * arg = grpc_channel_args_find ( args . args , GRPC_ARG_SERVER_URI ) ; <nl> const char * server_uri = grpc_channel_arg_get_string ( arg ) ; <nl> XdsLb : : XdsLb ( Args args ) <nl> } <nl> <nl> XdsLb : : ~ XdsLb ( ) { <nl> - gpr_mu_destroy ( & lb_chand_mu_ ) ; <nl> gpr_free ( ( void * ) server_name_ ) ; <nl> grpc_channel_args_destroy ( args_ ) ; <nl> locality_serverlist_ . clear ( ) ; <nl> mmm a / src / core / ext / filters / client_channel / resolving_lb_policy . cc <nl> ppp b / src / core / ext / filters / client_channel / resolving_lb_policy . cc <nl> <nl> # include " src / core / lib / gpr / string . h " <nl> # include " src / core / lib / gprpp / inlined_vector . h " <nl> # include " src / core / lib / gprpp / manual_constructor . h " <nl> - # include " src / core / lib / gprpp / mutex_lock . h " <nl> + # include " src / core / lib / gprpp / sync . h " <nl> # include " src / core / lib / iomgr / combiner . h " <nl> # include " src / core / lib / iomgr / iomgr . h " <nl> # include " src / core / lib / iomgr / polling_entity . h " <nl> mmm a / src / core / ext / filters / client_channel / subchannel . cc <nl> ppp b / src / core / ext / filters / client_channel / subchannel . cc <nl> <nl> # include " src / core / lib / gpr / alloc . h " <nl> # include " src / core / lib / gprpp / debug_location . h " <nl> # include " src / core / lib / gprpp / manual_constructor . h " <nl> - # include " src / core / lib / gprpp / mutex_lock . h " <nl> # include " src / core / lib / gprpp / ref_counted_ptr . h " <nl> + # include " src / core / lib / gprpp / sync . h " <nl> # include " src / core / lib / iomgr / sockaddr_utils . h " <nl> # include " src / core / lib / profiling / timers . h " <nl> # include " src / core / lib / slice / slice_internal . h " <nl> struct Subchannel : : ExternalStateWatcher { <nl> grpc_pollset_set_del_pollset_set ( w - > subchannel - > pollset_set_ , <nl> w - > pollset_set ) ; <nl> } <nl> - gpr_mu_lock ( & w - > subchannel - > mu_ ) ; <nl> - if ( w - > subchannel - > external_state_watcher_list_ = = w ) { <nl> - w - > subchannel - > external_state_watcher_list_ = w - > next ; <nl> + { <nl> + MutexLock lock ( & w - > subchannel - > mu_ ) ; <nl> + if ( w - > subchannel - > external_state_watcher_list_ = = w ) { <nl> + w - > subchannel - > external_state_watcher_list_ = w - > next ; <nl> + } <nl> + if ( w - > next ! = nullptr ) w - > next - > prev = w - > prev ; <nl> + if ( w - > prev ! = nullptr ) w - > prev - > next = w - > next ; <nl> } <nl> - if ( w - > next ! = nullptr ) w - > next - > prev = w - > prev ; <nl> - if ( w - > prev ! = nullptr ) w - > prev - > next = w - > next ; <nl> - gpr_mu_unlock ( & w - > subchannel - > mu_ ) ; <nl> GRPC_SUBCHANNEL_WEAK_UNREF ( w - > subchannel , " external_state_watcher + done " ) ; <nl> Delete ( w ) ; <nl> GRPC_CLOSURE_SCHED ( follow_up , GRPC_ERROR_REF ( error ) ) ; <nl> Subchannel : : Subchannel ( SubchannelKey * key , grpc_connector * connector , <nl> " subchannel " ) ; <nl> grpc_connectivity_state_init ( & state_and_health_tracker_ , GRPC_CHANNEL_IDLE , <nl> " subchannel " ) ; <nl> - gpr_mu_init ( & mu_ ) ; <nl> / / Check whether we should enable health checking . <nl> const char * service_config_json = grpc_channel_arg_get_string ( <nl> grpc_channel_args_find ( args_ , GRPC_ARG_SERVICE_CONFIG ) ) ; <nl> Subchannel : : ~ Subchannel ( ) { <nl> grpc_connector_unref ( connector_ ) ; <nl> grpc_pollset_set_destroy ( pollset_set_ ) ; <nl> Delete ( key_ ) ; <nl> - gpr_mu_destroy ( & mu_ ) ; <nl> } <nl> <nl> Subchannel * Subchannel : : Create ( grpc_connector * connector , <nl> void Subchannel : : MaybeStartConnectingLocked ( ) { <nl> <nl> void Subchannel : : OnRetryAlarm ( void * arg , grpc_error * error ) { <nl> Subchannel * c = static_cast < Subchannel * > ( arg ) ; <nl> - gpr_mu_lock ( & c - > mu_ ) ; <nl> + / / TODO ( soheilhy ) : Once subchannel refcounting is simplified , we can get use <nl> + / / MutexLock instead of ReleasableMutexLock , here . <nl> + ReleasableMutexLock lock ( & c - > mu_ ) ; <nl> c - > have_retry_alarm_ = false ; <nl> if ( c - > disconnected_ ) { <nl> error = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING ( " Disconnected " , <nl> void Subchannel : : OnRetryAlarm ( void * arg , grpc_error * error ) { <nl> if ( error = = GRPC_ERROR_NONE ) { <nl> gpr_log ( GPR_INFO , " Failed to connect to channel , retrying " ) ; <nl> c - > ContinueConnectingLocked ( ) ; <nl> - gpr_mu_unlock ( & c - > mu_ ) ; <nl> + lock . Unlock ( ) ; <nl> } else { <nl> - gpr_mu_unlock ( & c - > mu_ ) ; <nl> + lock . Unlock ( ) ; <nl> GRPC_SUBCHANNEL_WEAK_UNREF ( c , " connecting " ) ; <nl> } <nl> GRPC_ERROR_UNREF ( error ) ; <nl> void Subchannel : : OnConnectingFinished ( void * arg , grpc_error * error ) { <nl> auto * c = static_cast < Subchannel * > ( arg ) ; <nl> grpc_channel_args * delete_channel_args = c - > connecting_result_ . channel_args ; <nl> GRPC_SUBCHANNEL_WEAK_REF ( c , " on_connecting_finished " ) ; <nl> - gpr_mu_lock ( & c - > mu_ ) ; <nl> - c - > connecting_ = false ; <nl> - if ( c - > connecting_result_ . transport ! = nullptr & & <nl> - c - > PublishTransportLocked ( ) ) { <nl> - / / Do nothing , transport was published . <nl> - } else if ( c - > disconnected_ ) { <nl> - GRPC_SUBCHANNEL_WEAK_UNREF ( c , " connecting " ) ; <nl> - } else { <nl> - gpr_log ( GPR_INFO , " Connect failed : % s " , grpc_error_string ( error ) ) ; <nl> - c - > SetConnectivityStateLocked ( GRPC_CHANNEL_TRANSIENT_FAILURE , <nl> + { <nl> + MutexLock lock ( & c - > mu_ ) ; <nl> + c - > connecting_ = false ; <nl> + if ( c - > connecting_result_ . transport ! = nullptr & & <nl> + c - > PublishTransportLocked ( ) ) { <nl> + / / Do nothing , transport was published . <nl> + } else if ( c - > disconnected_ ) { <nl> + GRPC_SUBCHANNEL_WEAK_UNREF ( c , " connecting " ) ; <nl> + } else { <nl> + gpr_log ( GPR_INFO , " Connect failed : % s " , grpc_error_string ( error ) ) ; <nl> + c - > SetConnectivityStateLocked ( GRPC_CHANNEL_TRANSIENT_FAILURE , <nl> + " connect_failed " ) ; <nl> + grpc_connectivity_state_set ( & c - > state_and_health_tracker_ , <nl> + GRPC_CHANNEL_TRANSIENT_FAILURE , <nl> " connect_failed " ) ; <nl> - grpc_connectivity_state_set ( & c - > state_and_health_tracker_ , <nl> - GRPC_CHANNEL_TRANSIENT_FAILURE , <nl> - " connect_failed " ) ; <nl> - c - > MaybeStartConnectingLocked ( ) ; <nl> - GRPC_SUBCHANNEL_WEAK_UNREF ( c , " connecting " ) ; <nl> + c - > MaybeStartConnectingLocked ( ) ; <nl> + GRPC_SUBCHANNEL_WEAK_UNREF ( c , " connecting " ) ; <nl> + } <nl> } <nl> - gpr_mu_unlock ( & c - > mu_ ) ; <nl> GRPC_SUBCHANNEL_WEAK_UNREF ( c , " on_connecting_finished " ) ; <nl> grpc_channel_args_destroy ( delete_channel_args ) ; <nl> } <nl> mmm a / src / core / ext / filters / client_channel / subchannel . h <nl> ppp b / src / core / ext / filters / client_channel / subchannel . h <nl> <nl> # include " src / core / lib / gpr / arena . h " <nl> # include " src / core / lib / gprpp / ref_counted . h " <nl> # include " src / core / lib / gprpp / ref_counted_ptr . h " <nl> + # include " src / core / lib / gprpp / sync . h " <nl> # include " src / core / lib / iomgr / polling_entity . h " <nl> # include " src / core / lib / iomgr / timer . h " <nl> # include " src / core / lib / transport / connectivity_state . h " <nl> class Subchannel { <nl> / / pollset_set tracking who ' s interested in a connection being setup . <nl> grpc_pollset_set * pollset_set_ ; <nl> / / Protects the other members . <nl> - gpr_mu mu_ ; <nl> + Mutex mu_ ; <nl> / / Refcount <nl> / / - lower INTERNAL_REF_BITS bits are for internal references : <nl> / / these do not keep the subchannel open . <nl> mmm a / src / core / lib / channel / channelz_registry . cc <nl> ppp b / src / core / lib / channel / channelz_registry . cc <nl> <nl> # include " src / core / lib / channel / channelz_registry . h " <nl> # include " src / core / lib / gpr / useful . h " <nl> # include " src / core / lib / gprpp / memory . h " <nl> - # include " src / core / lib / gprpp / mutex_lock . h " <nl> + # include " src / core / lib / gprpp / sync . h " <nl> <nl> # include < grpc / support / alloc . h > <nl> # include < grpc / support / log . h > <nl> mmm a / src / core / lib / channel / handshaker . h <nl> ppp b / src / core / lib / channel / handshaker . h <nl> <nl> <nl> # include " src / core / lib / channel / channel_args . h " <nl> # include " src / core / lib / gprpp / inlined_vector . h " <nl> - # include " src / core / lib / gprpp / mutex_lock . h " <nl> # include " src / core / lib / gprpp / ref_counted . h " <nl> + # include " src / core / lib / gprpp / sync . h " <nl> # include " src / core / lib / iomgr / closure . h " <nl> # include " src / core / lib / iomgr / endpoint . h " <nl> # include " src / core / lib / iomgr / exec_ctx . h " <nl> deleted file mode 100644 <nl> index 54751d5fe46 . . 00000000000 <nl> mmm a / src / core / lib / gprpp / mutex_lock . h <nl> ppp / dev / null <nl> <nl> - / * <nl> - * <nl> - * Copyright 2018 gRPC authors . <nl> - * <nl> - * Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> - * you may not use this file except in compliance with the License . <nl> - * You may obtain a copy of the License at <nl> - * <nl> - * http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> - * <nl> - * Unless required by applicable law or agreed to in writing , software <nl> - * distributed under the License is distributed on an " AS IS " BASIS , <nl> - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> - * See the License for the specific language governing permissions and <nl> - * limitations under the License . <nl> - * <nl> - * / <nl> - <nl> - # ifndef GRPC_CORE_LIB_GPRPP_MUTEX_LOCK_H <nl> - # define GRPC_CORE_LIB_GPRPP_MUTEX_LOCK_H <nl> - <nl> - # include < grpc / support / port_platform . h > <nl> - <nl> - # include < grpc / support / sync . h > <nl> - <nl> - namespace grpc_core { <nl> - <nl> - class MutexLock { <nl> - public : <nl> - explicit MutexLock ( gpr_mu * mu ) : mu_ ( mu ) { gpr_mu_lock ( mu ) ; } <nl> - ~ MutexLock ( ) { gpr_mu_unlock ( mu_ ) ; } <nl> - <nl> - MutexLock ( const MutexLock & ) = delete ; <nl> - MutexLock & operator = ( const MutexLock & ) = delete ; <nl> - <nl> - private : <nl> - gpr_mu * const mu_ ; <nl> - } ; <nl> - <nl> - } / / namespace grpc_core <nl> - <nl> - # endif / * GRPC_CORE_LIB_GPRPP_MUTEX_LOCK_H * / <nl> new file mode 100644 <nl> index 00000000000 . . 895ca60fec0 <nl> mmm / dev / null <nl> ppp b / src / core / lib / gprpp / sync . h <nl> <nl> + / * <nl> + * <nl> + * Copyright 2019 gRPC authors . <nl> + * <nl> + * Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + * you may not use this file except in compliance with the License . <nl> + * You may obtain a copy of the License at <nl> + * <nl> + * http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + * <nl> + * Unless required by applicable law or agreed to in writing , software <nl> + * distributed under the License is distributed on an " AS IS " BASIS , <nl> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + * See the License for the specific language governing permissions and <nl> + * limitations under the License . <nl> + * <nl> + * / <nl> + <nl> + # ifndef GRPC_CORE_LIB_GPRPP_SYNC_H <nl> + # define GRPC_CORE_LIB_GPRPP_SYNC_H <nl> + <nl> + # include < grpc / impl / codegen / port_platform . h > <nl> + <nl> + # include < grpc / impl / codegen / log . h > <nl> + # include < grpc / impl / codegen / sync . h > <nl> + # include < grpc / support / sync . h > <nl> + # include < grpc / support / time . h > <nl> + <nl> + / / The core library is not accessible in C + + codegen headers , and vice versa . <nl> + / / Thus , we need to have duplicate headers with similar functionality . <nl> + / / Make sure any change to this file is also reflected in <nl> + / / include / grpcpp / impl / codegen / sync . h . <nl> + / / <nl> + / / Whenever possible , prefer using this file over < grpcpp / impl / codegen / sync . h > <nl> + / / since this file doesn ' t rely on g_core_codegen_interface and hence does not <nl> + / / pay the costs of virtual function calls . <nl> + <nl> + namespace grpc_core { <nl> + <nl> + class Mutex { <nl> + public : <nl> + Mutex ( ) { gpr_mu_init ( & mu_ ) ; } <nl> + ~ Mutex ( ) { gpr_mu_destroy ( & mu_ ) ; } <nl> + <nl> + Mutex ( const Mutex & ) = delete ; <nl> + Mutex & operator = ( const Mutex & ) = delete ; <nl> + <nl> + gpr_mu * get ( ) { return & mu_ ; } <nl> + const gpr_mu * get ( ) const { return & mu_ ; } <nl> + <nl> + private : <nl> + gpr_mu mu_ ; <nl> + } ; <nl> + <nl> + / / MutexLock is a std : : <nl> + class MutexLock { <nl> + public : <nl> + explicit MutexLock ( Mutex * mu ) : mu_ ( mu - > get ( ) ) { gpr_mu_lock ( mu_ ) ; } <nl> + explicit MutexLock ( gpr_mu * mu ) : mu_ ( mu ) { gpr_mu_lock ( mu_ ) ; } <nl> + ~ MutexLock ( ) { gpr_mu_unlock ( mu_ ) ; } <nl> + <nl> + MutexLock ( const MutexLock & ) = delete ; <nl> + MutexLock & operator = ( const MutexLock & ) = delete ; <nl> + <nl> + private : <nl> + gpr_mu * const mu_ ; <nl> + } ; <nl> + <nl> + class ReleasableMutexLock { <nl> + public : <nl> + explicit ReleasableMutexLock ( Mutex * mu ) : mu_ ( mu - > get ( ) ) { gpr_mu_lock ( mu_ ) ; } <nl> + explicit ReleasableMutexLock ( gpr_mu * mu ) : mu_ ( mu ) { gpr_mu_lock ( mu_ ) ; } <nl> + ~ ReleasableMutexLock ( ) { <nl> + if ( ! released_ ) gpr_mu_unlock ( mu_ ) ; <nl> + } <nl> + <nl> + ReleasableMutexLock ( const ReleasableMutexLock & ) = delete ; <nl> + ReleasableMutexLock & operator = ( const ReleasableMutexLock & ) = delete ; <nl> + <nl> + void Lock ( ) { <nl> + GPR_DEBUG_ASSERT ( released_ ) ; <nl> + gpr_mu_lock ( mu_ ) ; <nl> + released_ = false ; <nl> + } <nl> + <nl> + void Unlock ( ) { <nl> + GPR_DEBUG_ASSERT ( ! released_ ) ; <nl> + released_ = true ; <nl> + gpr_mu_unlock ( mu_ ) ; <nl> + } <nl> + <nl> + private : <nl> + gpr_mu * const mu_ ; <nl> + bool released_ = false ; <nl> + } ; <nl> + <nl> + class CondVar { <nl> + public : <nl> + CondVar ( ) { gpr_cv_init ( & cv_ ) ; } <nl> + ~ CondVar ( ) { gpr_cv_destroy ( & cv_ ) ; } <nl> + <nl> + CondVar ( const CondVar & ) = delete ; <nl> + CondVar & operator = ( const CondVar & ) = delete ; <nl> + <nl> + void Signal ( ) { gpr_cv_signal ( & cv_ ) ; } <nl> + void Broadcast ( ) { gpr_cv_broadcast ( & cv_ ) ; } <nl> + <nl> + int Wait ( Mutex * mu ) { return Wait ( mu , gpr_inf_future ( GPR_CLOCK_REALTIME ) ) ; } <nl> + int Wait ( Mutex * mu , const gpr_timespec & deadline ) { <nl> + return gpr_cv_wait ( & cv_ , mu - > get ( ) , deadline ) ; <nl> + } <nl> + <nl> + template < typename Predicate > <nl> + void WaitUntil ( Mutex * mu , Predicate pred ) { <nl> + while ( ! pred ( ) ) { <nl> + Wait ( mu , gpr_inf_future ( GPR_CLOCK_REALTIME ) ) ; <nl> + } <nl> + } <nl> + <nl> + private : <nl> + gpr_cv cv_ ; <nl> + } ; <nl> + <nl> + } / / namespace grpc_core <nl> + <nl> + # endif / * GRPC_CORE_LIB_GPRPP_SYNC_H * / <nl> mmm a / src / core / lib / iomgr / ev_epollex_linux . cc <nl> ppp b / src / core / lib / iomgr / ev_epollex_linux . cc <nl> <nl> # include " src / core / lib / gpr / useful . h " <nl> # include " src / core / lib / gprpp / inlined_vector . h " <nl> # include " src / core / lib / gprpp / manual_constructor . h " <nl> - # include " src / core / lib / gprpp / mutex_lock . h " <nl> + # include " src / core / lib / gprpp / sync . h " <nl> # include " src / core / lib / iomgr / block_annotate . h " <nl> # include " src / core / lib / iomgr / iomgr_internal . h " <nl> # include " src / core / lib / iomgr / is_epollexclusive_available . h " <nl> mmm a / src / core / lib / surface / init . cc <nl> ppp b / src / core / lib / surface / init . cc <nl> <nl> # include " src / core / lib / debug / stats . h " <nl> # include " src / core / lib / debug / trace . h " <nl> # include " src / core / lib / gprpp / fork . h " <nl> - # include " src / core / lib / gprpp / mutex_lock . h " <nl> + # include " src / core / lib / gprpp / sync . h " <nl> # include " src / core / lib / http / parser . h " <nl> # include " src / core / lib / iomgr / call_combiner . h " <nl> # include " src / core / lib / iomgr / combiner . h " <nl> mmm a / src / core / tsi / ssl / session_cache / ssl_session_cache . cc <nl> ppp b / src / core / tsi / ssl / session_cache / ssl_session_cache . cc <nl> <nl> <nl> # include < grpc / support / port_platform . h > <nl> <nl> - # include " src / core / lib / gprpp / mutex_lock . h " <nl> + # include " src / core / lib / gprpp / sync . h " <nl> # include " src / core / lib / slice / slice_internal . h " <nl> # include " src / core / tsi / ssl / session_cache / ssl_session . h " <nl> # include " src / core / tsi / ssl / session_cache / ssl_session_cache . h " <nl> mmm a / src / cpp / client / channel_cc . cc <nl> ppp b / src / cpp / client / channel_cc . cc <nl> class ShutdownCallback : public grpc_experimental_completion_queue_functor { <nl> CompletionQueue * Channel : : CallbackCQ ( ) { <nl> / / TODO ( vjpai ) : Consider using a single global CQ for the default CQ <nl> / / if there is no explicit per - channel CQ registered <nl> - std : : lock_guard < std : : mutex > l ( mu_ ) ; <nl> + grpc : : internal : : MutexLock l ( & mu_ ) ; <nl> if ( callback_cq_ = = nullptr ) { <nl> auto * shutdown_callback = new ShutdownCallback ; <nl> callback_cq_ = new CompletionQueue ( grpc_completion_queue_attributes { <nl> mmm a / src / cpp / client / client_context . cc <nl> ppp b / src / cpp / client / client_context . cc <nl> <nl> # include < grpc / support / string_util . h > <nl> <nl> # include < grpcpp / impl / codegen / interceptor_common . h > <nl> + # include < grpcpp / impl / codegen / sync . h > <nl> # include < grpcpp / impl / grpc_library . h > <nl> # include < grpcpp / security / credentials . h > <nl> # include < grpcpp / server_context . h > <nl> void ClientContext : : AddMetadata ( const grpc : : string & meta_key , <nl> <nl> void ClientContext : : set_call ( grpc_call * call , <nl> const std : : shared_ptr < Channel > & channel ) { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & mu_ ) ; <nl> GPR_ASSERT ( call_ = = nullptr ) ; <nl> call_ = call ; <nl> channel_ = channel ; <nl> void ClientContext : : set_compression_algorithm ( <nl> } <nl> <nl> void ClientContext : : TryCancel ( ) { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & mu_ ) ; <nl> if ( call_ ) { <nl> SendCancelToInterceptors ( ) ; <nl> grpc_call_cancel ( call_ , nullptr ) ; <nl> mmm a / src / cpp / server / dynamic_thread_pool . cc <nl> ppp b / src / cpp / server / dynamic_thread_pool . cc <nl> <nl> # include < mutex > <nl> <nl> # include < grpc / support / log . h > <nl> + # include < grpcpp / impl / codegen / sync . h > <nl> <nl> # include " src / core / lib / gprpp / thd . h " <nl> <nl> DynamicThreadPool : : DynamicThread : : ~ DynamicThread ( ) { thd_ . Join ( ) ; } <nl> void DynamicThreadPool : : DynamicThread : : ThreadFunc ( ) { <nl> pool_ - > ThreadFunc ( ) ; <nl> / / Now that we have killed ourselves , we should reduce the thread count <nl> - std : : unique_lock < std : : mutex > lock ( pool_ - > mu_ ) ; <nl> + grpc_core : : MutexLock lock ( & pool_ - > mu_ ) ; <nl> pool_ - > nthreads_ - - ; <nl> / / Move ourselves to dead list <nl> pool_ - > dead_threads_ . push_back ( this ) ; <nl> <nl> if ( ( pool_ - > shutdown_ ) & & ( pool_ - > nthreads_ = = 0 ) ) { <nl> - pool_ - > shutdown_cv_ . notify_one ( ) ; <nl> + pool_ - > shutdown_cv_ . Signal ( ) ; <nl> } <nl> } <nl> <nl> void DynamicThreadPool : : ThreadFunc ( ) { <nl> for ( ; ; ) { <nl> / / Wait until work is available or we are shutting down . <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc_core : : ReleasableMutexLock lock ( & mu_ ) ; <nl> if ( ! shutdown_ & & callbacks_ . empty ( ) ) { <nl> / / If there are too many threads waiting , then quit this thread <nl> if ( threads_waiting_ > = reserve_threads_ ) { <nl> break ; <nl> } <nl> threads_waiting_ + + ; <nl> - cv_ . wait ( lock ) ; <nl> + cv_ . Wait ( & mu_ ) ; <nl> threads_waiting_ - - ; <nl> } <nl> / / Drain callbacks before considering shutdown to ensure all work <nl> void DynamicThreadPool : : ThreadFunc ( ) { <nl> if ( ! callbacks_ . empty ( ) ) { <nl> auto cb = callbacks_ . front ( ) ; <nl> callbacks_ . pop ( ) ; <nl> - lock . unlock ( ) ; <nl> + lock . Unlock ( ) ; <nl> cb ( ) ; <nl> } else if ( shutdown_ ) { <nl> break ; <nl> DynamicThreadPool : : DynamicThreadPool ( int reserve_threads ) <nl> nthreads_ ( 0 ) , <nl> threads_waiting_ ( 0 ) { <nl> for ( int i = 0 ; i < reserve_threads_ ; i + + ) { <nl> - std : : lock_guard < std : : mutex > lock ( mu_ ) ; <nl> + grpc_core : : MutexLock lock ( & mu_ ) ; <nl> nthreads_ + + ; <nl> new DynamicThread ( this ) ; <nl> } <nl> void DynamicThreadPool : : ReapThreads ( std : : list < DynamicThread * > * tlist ) { <nl> } <nl> <nl> DynamicThreadPool : : ~ DynamicThreadPool ( ) { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc_core : : MutexLock lock ( & mu_ ) ; <nl> shutdown_ = true ; <nl> - cv_ . notify_all ( ) ; <nl> + cv_ . Broadcast ( ) ; <nl> while ( nthreads_ ! = 0 ) { <nl> - shutdown_cv_ . wait ( lock ) ; <nl> + shutdown_cv_ . Wait ( & mu_ ) ; <nl> } <nl> ReapThreads ( & dead_threads_ ) ; <nl> } <nl> <nl> void DynamicThreadPool : : Add ( const std : : function < void ( ) > & callback ) { <nl> - std : : lock_guard < std : : mutex > lock ( mu_ ) ; <nl> + grpc_core : : MutexLock lock ( & mu_ ) ; <nl> / / Add works to the callbacks list <nl> callbacks_ . push ( callback ) ; <nl> / / Increase pool size or notify as needed <nl> void DynamicThreadPool : : Add ( const std : : function < void ( ) > & callback ) { <nl> nthreads_ + + ; <nl> new DynamicThread ( this ) ; <nl> } else { <nl> - cv_ . notify_one ( ) ; <nl> + cv_ . Signal ( ) ; <nl> } <nl> / / Also use this chance to harvest dead threads <nl> if ( ! dead_threads_ . empty ( ) ) { <nl> mmm a / src / cpp / server / dynamic_thread_pool . h <nl> ppp b / src / cpp / server / dynamic_thread_pool . h <nl> <nl> <nl> # include < grpcpp / support / config . h > <nl> <nl> + # include " src / core / lib / gprpp / sync . h " <nl> # include " src / core / lib / gprpp / thd . h " <nl> # include " src / cpp / server / thread_pool_interface . h " <nl> <nl> class DynamicThreadPool final : public ThreadPoolInterface { <nl> grpc_core : : Thread thd_ ; <nl> void ThreadFunc ( ) ; <nl> } ; <nl> - std : : mutex mu_ ; <nl> - std : : condition_variable cv_ ; <nl> - std : : condition_variable shutdown_cv_ ; <nl> + grpc_core : : Mutex mu_ ; <nl> + grpc_core : : CondVar cv_ ; <nl> + grpc_core : : CondVar shutdown_cv_ ; <nl> bool shutdown_ ; <nl> std : : queue < std : : function < void ( ) > > callbacks_ ; <nl> int reserve_threads_ ; <nl> mmm a / src / cpp / server / health / default_health_check_service . cc <nl> ppp b / src / cpp / server / health / default_health_check_service . cc <nl> DefaultHealthCheckService : : DefaultHealthCheckService ( ) { <nl> <nl> void DefaultHealthCheckService : : SetServingStatus ( <nl> const grpc : : string & service_name , bool serving ) { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc_core : : MutexLock lock ( & mu_ ) ; <nl> if ( shutdown_ ) { <nl> / / Set to NOT_SERVING in case service_name is not in the map . <nl> serving = false ; <nl> void DefaultHealthCheckService : : SetServingStatus ( <nl> <nl> void DefaultHealthCheckService : : SetServingStatus ( bool serving ) { <nl> const ServingStatus status = serving ? SERVING : NOT_SERVING ; <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc_core : : MutexLock lock ( & mu_ ) ; <nl> if ( shutdown_ ) { <nl> return ; <nl> } <nl> void DefaultHealthCheckService : : SetServingStatus ( bool serving ) { <nl> } <nl> <nl> void DefaultHealthCheckService : : Shutdown ( ) { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc_core : : MutexLock lock ( & mu_ ) ; <nl> if ( shutdown_ ) { <nl> return ; <nl> } <nl> void DefaultHealthCheckService : : Shutdown ( ) { <nl> DefaultHealthCheckService : : ServingStatus <nl> DefaultHealthCheckService : : GetServingStatus ( <nl> const grpc : : string & service_name ) const { <nl> - std : : lock_guard < std : : mutex > lock ( mu_ ) ; <nl> + grpc_core : : MutexLock lock ( & mu_ ) ; <nl> auto it = services_map_ . find ( service_name ) ; <nl> if ( it = = services_map_ . end ( ) ) { <nl> return NOT_FOUND ; <nl> DefaultHealthCheckService : : GetServingStatus ( <nl> void DefaultHealthCheckService : : RegisterCallHandler ( <nl> const grpc : : string & service_name , <nl> std : : shared_ptr < HealthCheckServiceImpl : : CallHandler > handler ) { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc_core : : MutexLock lock ( & mu_ ) ; <nl> ServiceData & service_data = services_map_ [ service_name ] ; <nl> service_data . AddCallHandler ( handler / * copies ref * / ) ; <nl> HealthCheckServiceImpl : : CallHandler * h = handler . get ( ) ; <nl> void DefaultHealthCheckService : : RegisterCallHandler ( <nl> void DefaultHealthCheckService : : UnregisterCallHandler ( <nl> const grpc : : string & service_name , <nl> const std : : shared_ptr < HealthCheckServiceImpl : : CallHandler > & handler ) { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc_core : : MutexLock lock ( & mu_ ) ; <nl> auto it = services_map_ . find ( service_name ) ; <nl> if ( it = = services_map_ . end ( ) ) return ; <nl> ServiceData & service_data = it - > second ; <nl> DefaultHealthCheckService : : HealthCheckServiceImpl : : ~ HealthCheckServiceImpl ( ) { <nl> / / We will reach here after the server starts shutting down . <nl> shutdown_ = true ; <nl> { <nl> - std : : unique_lock < std : : mutex > lock ( cq_shutdown_mu_ ) ; <nl> + grpc_core : : MutexLock lock ( & cq_shutdown_mu_ ) ; <nl> cq_ - > Shutdown ( ) ; <nl> } <nl> thread_ - > Join ( ) ; <nl> void DefaultHealthCheckService : : HealthCheckServiceImpl : : CheckCallHandler : : <nl> std : : make_shared < CheckCallHandler > ( cq , database , service ) ; <nl> CheckCallHandler * handler = static_cast < CheckCallHandler * > ( self . get ( ) ) ; <nl> { <nl> - std : : unique_lock < std : : mutex > lock ( service - > cq_shutdown_mu_ ) ; <nl> + grpc_core : : MutexLock lock ( & service - > cq_shutdown_mu_ ) ; <nl> if ( service - > shutdown_ ) return ; <nl> / / Request a Check ( ) call . <nl> handler - > next_ = <nl> void DefaultHealthCheckService : : HealthCheckServiceImpl : : CheckCallHandler : : <nl> } <nl> / / Send response . <nl> { <nl> - std : : unique_lock < std : : mutex > lock ( service_ - > cq_shutdown_mu_ ) ; <nl> + grpc_core : : MutexLock lock ( & service_ - > cq_shutdown_mu_ ) ; <nl> if ( ! service_ - > shutdown_ ) { <nl> next_ = <nl> CallableTag ( std : : bind ( & CheckCallHandler : : OnFinishDone , this , <nl> void DefaultHealthCheckService : : HealthCheckServiceImpl : : WatchCallHandler : : <nl> std : : make_shared < WatchCallHandler > ( cq , database , service ) ; <nl> WatchCallHandler * handler = static_cast < WatchCallHandler * > ( self . get ( ) ) ; <nl> { <nl> - std : : unique_lock < std : : mutex > lock ( service - > cq_shutdown_mu_ ) ; <nl> + grpc_core : : MutexLock lock ( & service - > cq_shutdown_mu_ ) ; <nl> if ( service - > shutdown_ ) return ; <nl> / / Request AsyncNotifyWhenDone ( ) . <nl> handler - > on_done_notified_ = <nl> void DefaultHealthCheckService : : HealthCheckServiceImpl : : WatchCallHandler : : <nl> <nl> void DefaultHealthCheckService : : HealthCheckServiceImpl : : WatchCallHandler : : <nl> SendHealth ( std : : shared_ptr < CallHandler > self , ServingStatus status ) { <nl> - std : : unique_lock < std : : mutex > lock ( send_mu_ ) ; <nl> + grpc_core : : MutexLock lock ( & send_mu_ ) ; <nl> / / If there ' s already a send in flight , cache the new status , and <nl> / / we ' ll start a new send for it when the one in flight completes . <nl> if ( send_in_flight_ ) { <nl> void DefaultHealthCheckService : : HealthCheckServiceImpl : : WatchCallHandler : : <nl> ByteBuffer response ; <nl> bool success = service_ - > EncodeResponse ( status , & response ) ; <nl> / / Grab shutdown lock and send response . <nl> - std : : unique_lock < std : : mutex > cq_lock ( service_ - > cq_shutdown_mu_ ) ; <nl> + grpc_core : : MutexLock cq_lock ( & service_ - > cq_shutdown_mu_ ) ; <nl> if ( service_ - > shutdown_ ) { <nl> SendFinishLocked ( std : : move ( self ) , Status : : CANCELLED ) ; <nl> return ; <nl> void DefaultHealthCheckService : : HealthCheckServiceImpl : : WatchCallHandler : : <nl> SendFinish ( std : : move ( self ) , Status : : CANCELLED ) ; <nl> return ; <nl> } <nl> - std : : unique_lock < std : : mutex > lock ( send_mu_ ) ; <nl> + grpc_core : : MutexLock lock ( & send_mu_ ) ; <nl> send_in_flight_ = false ; <nl> / / If we got a new status since we started the last send , start a <nl> / / new send for it . <nl> void DefaultHealthCheckService : : HealthCheckServiceImpl : : WatchCallHandler : : <nl> void DefaultHealthCheckService : : HealthCheckServiceImpl : : WatchCallHandler : : <nl> SendFinish ( std : : shared_ptr < CallHandler > self , const Status & status ) { <nl> if ( finish_called_ ) return ; <nl> - std : : unique_lock < std : : mutex > cq_lock ( service_ - > cq_shutdown_mu_ ) ; <nl> + grpc_core : : MutexLock cq_lock ( & service_ - > cq_shutdown_mu_ ) ; <nl> if ( service_ - > shutdown_ ) return ; <nl> SendFinishLocked ( std : : move ( self ) , status ) ; <nl> } <nl> mmm a / src / cpp / server / health / default_health_check_service . h <nl> ppp b / src / cpp / server / health / default_health_check_service . h <nl> <nl> # include < grpcpp / impl / codegen / service_type . h > <nl> # include < grpcpp / support / byte_buffer . h > <nl> <nl> + # include " src / core / lib / gprpp / sync . h " <nl> # include " src / core / lib / gprpp / thd . h " <nl> <nl> namespace grpc { <nl> class DefaultHealthCheckService final : public HealthCheckServiceInterface { <nl> GenericServerAsyncWriter stream_ ; <nl> ServerContext ctx_ ; <nl> <nl> - std : : mutex send_mu_ ; <nl> + grpc_core : : Mutex send_mu_ ; <nl> bool send_in_flight_ = false ; / / Guarded by mu_ . <nl> ServingStatus pending_status_ = NOT_FOUND ; / / Guarded by mu_ . <nl> <nl> class DefaultHealthCheckService final : public HealthCheckServiceInterface { <nl> <nl> / / To synchronize the operations related to shutdown state of cq_ , so that <nl> / / we don ' t enqueue new tags into cq_ after it is already shut down . <nl> - std : : mutex cq_shutdown_mu_ ; <nl> + grpc_core : : Mutex cq_shutdown_mu_ ; <nl> std : : atomic_bool shutdown_ { false } ; <nl> std : : unique_ptr < : : grpc_core : : Thread > thread_ ; <nl> } ; <nl> class DefaultHealthCheckService final : public HealthCheckServiceInterface { <nl> const grpc : : string & service_name , <nl> const std : : shared_ptr < HealthCheckServiceImpl : : CallHandler > & handler ) ; <nl> <nl> - mutable std : : mutex mu_ ; <nl> + mutable grpc_core : : Mutex mu_ ; <nl> bool shutdown_ = false ; / / Guarded by mu_ . <nl> std : : map < grpc : : string , ServiceData > services_map_ ; / / Guarded by mu_ . <nl> std : : unique_ptr < HealthCheckServiceImpl > impl_ ; <nl> mmm a / src / cpp / server / load_reporter / load_reporter . cc <nl> ppp b / src / cpp / server / load_reporter / load_reporter . cc <nl> grpc : : string LoadReporter : : GenerateLbId ( ) { <nl> <nl> : : grpc : : lb : : v1 : : LoadBalancingFeedback <nl> LoadReporter : : GenerateLoadBalancingFeedback ( ) { <nl> - std : : unique_lock < std : : mutex > lock ( feedback_mu_ ) ; <nl> + grpc_core : : ReleasableMutexLock lock ( & feedback_mu_ ) ; <nl> auto now = std : : chrono : : system_clock : : now ( ) ; <nl> / / Discard records outside the window until there is only one record <nl> / / outside the window , which is used as the base for difference . <nl> LoadReporter : : GenerateLoadBalancingFeedback ( ) { <nl> double cpu_limit = newest - > cpu_limit - oldest - > cpu_limit ; <nl> std : : chrono : : duration < double > duration_seconds = <nl> newest - > end_time - oldest - > end_time ; <nl> - lock . unlock ( ) ; <nl> + lock . Unlock ( ) ; <nl> : : grpc : : lb : : v1 : : LoadBalancingFeedback feedback ; <nl> feedback . set_server_utilization ( static_cast < float > ( cpu_usage / cpu_limit ) ) ; <nl> feedback . set_calls_per_second ( <nl> LoadReporter : : GenerateLoadBalancingFeedback ( ) { <nl> : : google : : protobuf : : RepeatedPtrField < : : grpc : : lb : : v1 : : Load > <nl> LoadReporter : : GenerateLoads ( const grpc : : string & hostname , <nl> const grpc : : string & lb_id ) { <nl> - std : : lock_guard < std : : mutex > lock ( store_mu_ ) ; <nl> + grpc_core : : MutexLock lock ( & store_mu_ ) ; <nl> auto assigned_stores = load_data_store_ . GetAssignedStores ( hostname , lb_id ) ; <nl> GPR_ASSERT ( assigned_stores ! = nullptr ) ; <nl> GPR_ASSERT ( ! assigned_stores - > empty ( ) ) ; <nl> void LoadReporter : : AppendNewFeedbackRecord ( uint64_t rpcs , uint64_t errors ) { <nl> / / This will make the load balancing feedback generation a no - op . <nl> cpu_stats = { 0 , 0 } ; <nl> } <nl> - std : : unique_lock < std : : mutex > lock ( feedback_mu_ ) ; <nl> + grpc_core : : MutexLock lock ( & feedback_mu_ ) ; <nl> feedback_records_ . emplace_back ( std : : chrono : : system_clock : : now ( ) , rpcs , errors , <nl> cpu_stats . first , cpu_stats . second ) ; <nl> } <nl> void LoadReporter : : AppendNewFeedbackRecord ( uint64_t rpcs , uint64_t errors ) { <nl> void LoadReporter : : ReportStreamCreated ( const grpc : : string & hostname , <nl> const grpc : : string & lb_id , <nl> const grpc : : string & load_key ) { <nl> - std : : lock_guard < std : : mutex > lock ( store_mu_ ) ; <nl> + grpc_core : : MutexLock lock ( & store_mu_ ) ; <nl> load_data_store_ . ReportStreamCreated ( hostname , lb_id , load_key ) ; <nl> gpr_log ( GPR_INFO , <nl> " [ LR % p ] Report stream created ( host : % s , LB ID : % s , load key : % s ) . " , <nl> void LoadReporter : : ReportStreamCreated ( const grpc : : string & hostname , <nl> <nl> void LoadReporter : : ReportStreamClosed ( const grpc : : string & hostname , <nl> const grpc : : string & lb_id ) { <nl> - std : : lock_guard < std : : mutex > lock ( store_mu_ ) ; <nl> + grpc_core : : MutexLock lock ( & store_mu_ ) ; <nl> load_data_store_ . ReportStreamClosed ( hostname , lb_id ) ; <nl> gpr_log ( GPR_INFO , " [ LR % p ] Report stream closed ( host : % s , LB ID : % s ) . " , this , <nl> hostname . c_str ( ) , lb_id . c_str ( ) ) ; <nl> void LoadReporter : : ProcessViewDataCallStart ( <nl> LoadRecordKey key ( client_ip_and_token , user_id ) ; <nl> LoadRecordValue value = LoadRecordValue ( start_count ) ; <nl> { <nl> - std : : unique_lock < std : : mutex > lock ( store_mu_ ) ; <nl> + grpc_core : : MutexLock lock ( & store_mu_ ) ; <nl> load_data_store_ . MergeRow ( host , key , value ) ; <nl> } <nl> } <nl> void LoadReporter : : ProcessViewDataCallEnd ( <nl> LoadRecordValue value = LoadRecordValue ( <nl> 0 , ok_count , error_count , bytes_sent , bytes_received , latency_ms ) ; <nl> { <nl> - std : : unique_lock < std : : mutex > lock ( store_mu_ ) ; <nl> + grpc_core : : MutexLock lock ( & store_mu_ ) ; <nl> load_data_store_ . MergeRow ( host , key , value ) ; <nl> } <nl> } <nl> void LoadReporter : : ProcessViewDataOtherCallMetrics ( <nl> LoadRecordValue value = LoadRecordValue ( <nl> metric_name , static_cast < uint64_t > ( num_calls ) , total_metric_value ) ; <nl> { <nl> - std : : unique_lock < std : : mutex > lock ( store_mu_ ) ; <nl> + grpc_core : : MutexLock lock ( & store_mu_ ) ; <nl> load_data_store_ . MergeRow ( host , key , value ) ; <nl> } <nl> } <nl> mmm a / src / cpp / server / load_reporter / load_reporter . h <nl> ppp b / src / cpp / server / load_reporter / load_reporter . h <nl> <nl> # include < grpc / support / log . h > <nl> # include < grpcpp / impl / codegen / config . h > <nl> <nl> + # include " src / core / lib / gprpp / sync . h " <nl> # include " src / cpp / server / load_reporter / load_data_store . h " <nl> # include " src / proto / grpc / lb / v1 / load_reporter . grpc . pb . h " <nl> <nl> class LoadReporter { <nl> <nl> std : : atomic < int64_t > next_lb_id_ { 0 } ; <nl> const std : : chrono : : seconds feedback_sample_window_seconds_ ; <nl> - std : : mutex feedback_mu_ ; <nl> + grpc_core : : Mutex feedback_mu_ ; <nl> std : : deque < LoadBalancingFeedbackRecord > feedback_records_ ; <nl> / / TODO ( juanlishen ) : Lock in finer grain . Locking the whole store may be <nl> / / too expensive . <nl> - std : : mutex store_mu_ ; <nl> + grpc_core : : Mutex store_mu_ ; <nl> LoadDataStore load_data_store_ ; <nl> std : : unique_ptr < CensusViewProvider > census_view_provider_ ; <nl> std : : unique_ptr < CpuStatsProvider > cpu_stats_provider_ ; <nl> mmm a / src / cpp / server / load_reporter / load_reporter_async_service_impl . cc <nl> ppp b / src / cpp / server / load_reporter / load_reporter_async_service_impl . cc <nl> LoadReporterAsyncServiceImpl : : ~ LoadReporterAsyncServiceImpl ( ) { <nl> / / We will reach here after the server starts shutting down . <nl> shutdown_ = true ; <nl> { <nl> - std : : unique_lock < std : : mutex > lock ( cq_shutdown_mu_ ) ; <nl> + grpc_core : : MutexLock lock ( & cq_shutdown_mu_ ) ; <nl> cq_ - > Shutdown ( ) ; <nl> } <nl> if ( next_fetch_and_sample_alarm_ ! = nullptr ) <nl> void LoadReporterAsyncServiceImpl : : ScheduleNextFetchAndSample ( ) { <nl> gpr_time_from_millis ( kFetchAndSampleIntervalSeconds * 1000 , <nl> GPR_TIMESPAN ) ) ; <nl> { <nl> - std : : unique_lock < std : : mutex > lock ( cq_shutdown_mu_ ) ; <nl> + grpc_core : : MutexLock lock ( & cq_shutdown_mu_ ) ; <nl> if ( shutdown_ ) return ; <nl> / / TODO ( juanlishen ) : Improve the Alarm implementation to reuse a single <nl> / / instance for multiple events . <nl> void LoadReporterAsyncServiceImpl : : ReportLoadHandler : : CreateAndStart ( <nl> std : : make_shared < ReportLoadHandler > ( cq , service , load_reporter ) ; <nl> ReportLoadHandler * p = handler . get ( ) ; <nl> { <nl> - std : : unique_lock < std : : mutex > lock ( service - > cq_shutdown_mu_ ) ; <nl> + grpc_core : : MutexLock lock ( & service - > cq_shutdown_mu_ ) ; <nl> if ( service - > shutdown_ ) return ; <nl> p - > on_done_notified_ = <nl> CallableTag ( std : : bind ( & ReportLoadHandler : : OnDoneNotified , p , <nl> void LoadReporterAsyncServiceImpl : : ReportLoadHandler : : OnRequestDelivered ( <nl> / / instance will deallocate itself when it ' s done . <nl> CreateAndStart ( cq_ , service_ , load_reporter_ ) ; <nl> { <nl> - std : : unique_lock < std : : mutex > lock ( service_ - > cq_shutdown_mu_ ) ; <nl> + grpc_core : : ReleasableMutexLock lock ( & service_ - > cq_shutdown_mu_ ) ; <nl> if ( service_ - > shutdown_ ) { <nl> - lock . release ( ) - > unlock ( ) ; <nl> + lock . Unlock ( ) ; <nl> Shutdown ( std : : move ( self ) , " OnRequestDelivered " ) ; <nl> return ; <nl> } <nl> void LoadReporterAsyncServiceImpl : : ReportLoadHandler : : OnReadDone ( <nl> SendReport ( self , true / * ok * / ) ; <nl> / / Expect this read to fail . <nl> { <nl> - std : : unique_lock < std : : mutex > lock ( service_ - > cq_shutdown_mu_ ) ; <nl> + grpc_core : : ReleasableMutexLock lock ( & service_ - > cq_shutdown_mu_ ) ; <nl> if ( service_ - > shutdown_ ) { <nl> - lock . release ( ) - > unlock ( ) ; <nl> + lock . Unlock ( ) ; <nl> Shutdown ( std : : move ( self ) , " OnReadDone " ) ; <nl> return ; <nl> } <nl> void LoadReporterAsyncServiceImpl : : ReportLoadHandler : : ScheduleNextReport ( <nl> gpr_now ( GPR_CLOCK_MONOTONIC ) , <nl> gpr_time_from_millis ( load_report_interval_ms_ , GPR_TIMESPAN ) ) ; <nl> { <nl> - std : : unique_lock < std : : mutex > lock ( service_ - > cq_shutdown_mu_ ) ; <nl> + grpc_core : : ReleasableMutexLock lock ( & service_ - > cq_shutdown_mu_ ) ; <nl> if ( service_ - > shutdown_ ) { <nl> - lock . release ( ) - > unlock ( ) ; <nl> + lock . Unlock ( ) ; <nl> Shutdown ( std : : move ( self ) , " ScheduleNextReport " ) ; <nl> return ; <nl> } <nl> void LoadReporterAsyncServiceImpl : : ReportLoadHandler : : SendReport ( <nl> call_status_ = INITIAL_RESPONSE_SENT ; <nl> } <nl> { <nl> - std : : unique_lock < std : : mutex > lock ( service_ - > cq_shutdown_mu_ ) ; <nl> + grpc_core : : ReleasableMutexLock lock ( & service_ - > cq_shutdown_mu_ ) ; <nl> if ( service_ - > shutdown_ ) { <nl> - lock . release ( ) - > unlock ( ) ; <nl> + lock . Unlock ( ) ; <nl> Shutdown ( std : : move ( self ) , " SendReport " ) ; <nl> return ; <nl> } <nl> void LoadReporterAsyncServiceImpl : : ReportLoadHandler : : Shutdown ( <nl> / / OnRequestDelivered ( ) may be called after OnDoneNotified ( ) , so we need to <nl> / / try to Finish ( ) every time we are in Shutdown ( ) . <nl> if ( call_status_ > = DELIVERED & & call_status_ < FINISH_CALLED ) { <nl> - std : : unique_lock < std : : mutex > lock ( service_ - > cq_shutdown_mu_ ) ; <nl> + grpc_core : : MutexLock lock ( & service_ - > cq_shutdown_mu_ ) ; <nl> if ( ! service_ - > shutdown_ ) { <nl> on_finish_done_ = <nl> CallableTag ( std : : bind ( & ReportLoadHandler : : OnFinishDone , this , <nl> mmm a / src / cpp / server / load_reporter / load_reporter_async_service_impl . h <nl> ppp b / src / cpp / server / load_reporter / load_reporter_async_service_impl . h <nl> <nl> # include < grpcpp / alarm . h > <nl> # include < grpcpp / grpcpp . h > <nl> <nl> + # include " src / core / lib / gprpp / sync . h " <nl> # include " src / core / lib / gprpp / thd . h " <nl> # include " src / cpp / server / load_reporter / load_reporter . h " <nl> <nl> class LoadReporterAsyncServiceImpl <nl> std : : unique_ptr < ServerCompletionQueue > cq_ ; <nl> / / To synchronize the operations related to shutdown state of cq_ , so that we <nl> / / don ' t enqueue new tags into cq_ after it is already shut down . <nl> - std : : mutex cq_shutdown_mu_ ; <nl> + grpc_core : : Mutex cq_shutdown_mu_ ; <nl> std : : atomic_bool shutdown_ { false } ; <nl> std : : unique_ptr < : : grpc_core : : Thread > thread_ ; <nl> std : : unique_ptr < LoadReporter > load_reporter_ ; <nl> mmm a / src / cpp / server / server_cc . cc <nl> ppp b / src / cpp / server / server_cc . cc <nl> class Server : : CallbackRequest final : public Server : : CallbackRequestBase { <nl> <nl> / / The counter of outstanding requests must be decremented <nl> / / under a lock in case it causes the server shutdown . <nl> - std : : lock_guard < std : : mutex > l ( server_ - > callback_reqs_mu_ ) ; <nl> + grpc : : internal : : MutexLock l ( & server_ - > callback_reqs_mu_ ) ; <nl> if ( - - server_ - > callback_reqs_outstanding_ = = 0 ) { <nl> - server_ - > callback_reqs_done_cv_ . notify_one ( ) ; <nl> + server_ - > callback_reqs_done_cv_ . Signal ( ) ; <nl> } <nl> } <nl> <nl> Server : : Server ( <nl> <nl> Server : : ~ Server ( ) { <nl> { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc : : internal : : ReleasableMutexLock lock ( & mu_ ) ; <nl> if ( callback_cq_ ! = nullptr ) { <nl> callback_cq_ - > Shutdown ( ) ; <nl> } <nl> if ( started_ & & ! shutdown_ ) { <nl> - lock . unlock ( ) ; <nl> + lock . Unlock ( ) ; <nl> Shutdown ( ) ; <nl> } else if ( ! started_ ) { <nl> / / Shutdown the completion queues <nl> void Server : : Start ( ServerCompletionQueue * * cqs , size_t num_cqs ) { <nl> } <nl> <nl> void Server : : ShutdownInternal ( gpr_timespec deadline ) { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & mu_ ) ; <nl> if ( shutdown_ ) { <nl> return ; <nl> } <nl> void Server : : ShutdownInternal ( gpr_timespec deadline ) { <nl> / / will report a failure , indicating a shutdown and again we won ' t end <nl> / / up incrementing the counter . <nl> { <nl> - std : : unique_lock < std : : mutex > cblock ( callback_reqs_mu_ ) ; <nl> - callback_reqs_done_cv_ . wait ( <nl> - cblock , [ this ] { return callback_reqs_outstanding_ = = 0 ; } ) ; <nl> + grpc : : internal : : MutexLock cblock ( & callback_reqs_mu_ ) ; <nl> + callback_reqs_done_cv_ . WaitUntil ( <nl> + & callback_reqs_mu_ , [ this ] { return callback_reqs_outstanding_ = = 0 ; } ) ; <nl> } <nl> <nl> / / Drain the shutdown queue ( if the previous call to AsyncNext ( ) timed out <nl> void Server : : ShutdownInternal ( gpr_timespec deadline ) { <nl> } <nl> <nl> shutdown_notified_ = true ; <nl> - shutdown_cv_ . notify_all ( ) ; <nl> + shutdown_cv_ . Broadcast ( ) ; <nl> } <nl> <nl> void Server : : Wait ( ) { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & mu_ ) ; <nl> while ( started_ & & ! shutdown_notified_ ) { <nl> - shutdown_cv_ . wait ( lock ) ; <nl> + shutdown_cv_ . Wait ( & mu_ ) ; <nl> } <nl> } <nl> <nl> class ShutdownCallback : public grpc_experimental_completion_queue_functor { <nl> CompletionQueue * Server : : CallbackCQ ( ) { <nl> / / TODO ( vjpai ) : Consider using a single global CQ for the default CQ <nl> / / if there is no explicit per - server CQ registered <nl> - std : : lock_guard < std : : mutex > l ( mu_ ) ; <nl> + grpc : : internal : : MutexLock l ( & mu_ ) ; <nl> if ( callback_cq_ = = nullptr ) { <nl> auto * shutdown_callback = new ShutdownCallback ; <nl> callback_cq_ = new CompletionQueue ( grpc_completion_queue_attributes { <nl> mmm a / src / cpp / server / server_context . cc <nl> ppp b / src / cpp / server / server_context . cc <nl> <nl> # include < grpcpp / support / time . h > <nl> <nl> # include " src / core / lib / gprpp / ref_counted . h " <nl> + # include " src / core / lib / gprpp / sync . h " <nl> # include " src / core / lib / surface / call . h " <nl> <nl> namespace grpc { <nl> class ServerContext : : CompletionOp final : public internal : : CallOpSetInterface { <nl> } <nl> <nl> void SetCancelCallback ( std : : function < void ( ) > callback ) { <nl> - std : : lock_guard < std : : mutex > lock ( mu_ ) ; <nl> + grpc_core : : MutexLock lock ( & mu_ ) ; <nl> <nl> if ( finalized_ & & ( cancelled_ ! = 0 ) ) { <nl> callback ( ) ; <nl> class ServerContext : : CompletionOp final : public internal : : CallOpSetInterface { <nl> } <nl> <nl> void ClearCancelCallback ( ) { <nl> - std : : lock_guard < std : : mutex > g ( mu_ ) ; <nl> + grpc_core : : MutexLock g ( & mu_ ) ; <nl> cancel_callback_ = nullptr ; <nl> } <nl> <nl> class ServerContext : : CompletionOp final : public internal : : CallOpSetInterface { <nl> <nl> private : <nl> bool CheckCancelledNoPluck ( ) { <nl> - std : : lock_guard < std : : mutex > g ( mu_ ) ; <nl> + grpc_core : : MutexLock lock ( & mu_ ) ; <nl> return finalized_ ? ( cancelled_ ! = 0 ) : false ; <nl> } <nl> <nl> class ServerContext : : CompletionOp final : public internal : : CallOpSetInterface { <nl> void * tag_ ; <nl> void * core_cq_tag_ ; <nl> grpc_core : : RefCount refs_ ; <nl> - std : : mutex mu_ ; <nl> + grpc_core : : Mutex mu_ ; <nl> bool finalized_ ; <nl> int cancelled_ ; / / This is an int ( not bool ) because it is passed to core <nl> std : : function < void ( ) > cancel_callback_ ; <nl> void ServerContext : : CompletionOp : : FillOps ( internal : : Call * call ) { <nl> <nl> bool ServerContext : : CompletionOp : : FinalizeResult ( void * * tag , bool * status ) { <nl> bool ret = false ; <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc_core : : ReleasableMutexLock lock ( & mu_ ) ; <nl> if ( done_intercepting_ ) { <nl> / * We are done intercepting . * / <nl> if ( has_tag_ ) { <nl> bool ServerContext : : CompletionOp : : FinalizeResult ( void * * tag , bool * status ) { <nl> cancel_callback_ ( ) ; <nl> } <nl> <nl> - / / Release the lock since we are going to be calling a callback and <nl> - / / interceptors now <nl> - lock . unlock ( ) ; <nl> + / / Release the lock since we may call a callback and interceptors now . <nl> + lock . Unlock ( ) ; <nl> <nl> if ( call_cancel & & reactor_ ! = nullptr ) { <nl> reactor_ - > MaybeCallOnCancel ( ) ; <nl> } <nl> - <nl> / * Add interception point and run through interceptors * / <nl> interceptor_methods_ . AddInterceptionHookPoint ( <nl> experimental : : InterceptionHookPoints : : POST_RECV_CLOSE ) ; <nl> mmm a / src / cpp / thread_manager / thread_manager . cc <nl> ppp b / src / cpp / thread_manager / thread_manager . cc <nl> ThreadManager : : ThreadManager ( const char * name , <nl> <nl> ThreadManager : : ~ ThreadManager ( ) { <nl> { <nl> - std : : lock_guard < std : : mutex > lock ( mu_ ) ; <nl> + grpc_core : : MutexLock lock ( & mu_ ) ; <nl> GPR_ASSERT ( num_threads_ = = 0 ) ; <nl> } <nl> <nl> ThreadManager : : ~ ThreadManager ( ) { <nl> } <nl> <nl> void ThreadManager : : Wait ( ) { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc_core : : MutexLock lock ( & mu_ ) ; <nl> while ( num_threads_ ! = 0 ) { <nl> - shutdown_cv_ . wait ( lock ) ; <nl> + shutdown_cv_ . Wait ( & mu_ ) ; <nl> } <nl> } <nl> <nl> void ThreadManager : : Shutdown ( ) { <nl> - std : : lock_guard < std : : mutex > lock ( mu_ ) ; <nl> + grpc_core : : MutexLock lock ( & mu_ ) ; <nl> shutdown_ = true ; <nl> } <nl> <nl> bool ThreadManager : : IsShutdown ( ) { <nl> - std : : lock_guard < std : : mutex > lock ( mu_ ) ; <nl> + grpc_core : : MutexLock lock ( & mu_ ) ; <nl> return shutdown_ ; <nl> } <nl> <nl> int ThreadManager : : GetMaxActiveThreadsSoFar ( ) { <nl> - std : : lock_guard < std : : mutex > list_lock ( list_mu_ ) ; <nl> + grpc_core : : MutexLock list_lock ( & list_mu_ ) ; <nl> return max_active_threads_sofar_ ; <nl> } <nl> <nl> void ThreadManager : : MarkAsCompleted ( WorkerThread * thd ) { <nl> { <nl> - std : : lock_guard < std : : mutex > list_lock ( list_mu_ ) ; <nl> + grpc_core : : MutexLock list_lock ( & list_mu_ ) ; <nl> completed_threads_ . push_back ( thd ) ; <nl> } <nl> <nl> { <nl> - std : : lock_guard < std : : mutex > lock ( mu_ ) ; <nl> + grpc_core : : MutexLock lock ( & mu_ ) ; <nl> num_threads_ - - ; <nl> if ( num_threads_ = = 0 ) { <nl> - shutdown_cv_ . notify_one ( ) ; <nl> + shutdown_cv_ . Signal ( ) ; <nl> } <nl> } <nl> <nl> void ThreadManager : : CleanupCompletedThreads ( ) { <nl> { <nl> / / swap out the completed threads list : allows other threads to clean up <nl> / / more quickly <nl> - std : : unique_lock < std : : mutex > lock ( list_mu_ ) ; <nl> + grpc_core : : MutexLock lock ( & list_mu_ ) ; <nl> completed_threads . swap ( completed_threads_ ) ; <nl> } <nl> for ( auto thd : completed_threads ) delete thd ; <nl> void ThreadManager : : Initialize ( ) { <nl> } <nl> <nl> { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc_core : : MutexLock lock ( & mu_ ) ; <nl> num_pollers_ = min_pollers_ ; <nl> num_threads_ = min_pollers_ ; <nl> max_active_threads_sofar_ = min_pollers_ ; <nl> void ThreadManager : : MainWorkLoop ( ) { <nl> bool ok ; <nl> WorkStatus work_status = PollForWork ( & tag , & ok ) ; <nl> <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc_core : : ReleasableMutexLock lock ( & mu_ ) ; <nl> / / Reduce the number of pollers by 1 and check what happened with the poll <nl> num_pollers_ - - ; <nl> bool done = false ; <nl> void ThreadManager : : MainWorkLoop ( ) { <nl> max_active_threads_sofar_ = num_threads_ ; <nl> } <nl> / / Drop lock before spawning thread to avoid contention <nl> - lock . unlock ( ) ; <nl> + lock . Unlock ( ) ; <nl> new WorkerThread ( this ) ; <nl> } else if ( num_pollers_ > 0 ) { <nl> / / There is still at least some thread polling , so we can go on <nl> / / even though we are below the number of pollers that we would <nl> / / like to have ( min_pollers_ ) <nl> - lock . unlock ( ) ; <nl> + lock . Unlock ( ) ; <nl> } else { <nl> / / There are no pollers to spare and we couldn ' t allocate <nl> / / a new thread , so resources are exhausted ! <nl> - lock . unlock ( ) ; <nl> + lock . Unlock ( ) ; <nl> resource_exhausted = true ; <nl> } <nl> } else { <nl> / / There are a sufficient number of pollers available so we can do <nl> / / the work and continue polling with our existing poller threads <nl> - lock . unlock ( ) ; <nl> + lock . Unlock ( ) ; <nl> } <nl> / / Lock is always released at this point - do the application work <nl> / / or return resource exhausted if there is new work but we couldn ' t <nl> / / get a thread in which to do it . <nl> DoWork ( tag , ok , ! resource_exhausted ) ; <nl> / / Take the lock again to check post conditions <nl> - lock . lock ( ) ; <nl> + lock . Lock ( ) ; <nl> / / If we ' re shutdown , we should finish at this point . <nl> if ( shutdown_ ) done = true ; <nl> break ; <nl> mmm a / src / cpp / thread_manager / thread_manager . h <nl> ppp b / src / cpp / thread_manager / thread_manager . h <nl> <nl> <nl> # include < grpcpp / support / config . h > <nl> <nl> + # include " src / core / lib / gprpp / sync . h " <nl> # include " src / core / lib / gprpp / thd . h " <nl> # include " src / core / lib / iomgr / resource_quota . h " <nl> <nl> class ThreadManager { <nl> <nl> / / Protects shutdown_ , num_pollers_ , num_threads_ and <nl> / / max_active_threads_sofar_ <nl> - std : : mutex mu_ ; <nl> + grpc_core : : Mutex mu_ ; <nl> <nl> bool shutdown_ ; <nl> - std : : condition_variable shutdown_cv_ ; <nl> + grpc_core : : CondVar shutdown_cv_ ; <nl> <nl> / / The resource user object to use when requesting quota to create threads <nl> / / <nl> class ThreadManager { <nl> / / ever set so far <nl> int max_active_threads_sofar_ ; <nl> <nl> - std : : mutex list_mu_ ; <nl> + grpc_core : : Mutex list_mu_ ; <nl> std : : list < WorkerThread * > completed_threads_ ; <nl> } ; <nl> <nl> mmm a / test / cpp / client / client_channel_stress_test . cc <nl> ppp b / test / cpp / client / client_channel_stress_test . cc <nl> <nl> # include < grpcpp / channel . h > <nl> # include < grpcpp / client_context . h > <nl> # include < grpcpp / create_channel . h > <nl> + # include < grpcpp / impl / codegen / sync . h > <nl> # include < grpcpp / server . h > <nl> # include < grpcpp / server_builder . h > <nl> <nl> class ClientChannelStressTest { <nl> explicit ServerThread ( const grpc : : string & type , <nl> const grpc : : string & server_host , T * service ) <nl> : type_ ( type ) , service_ ( service ) { <nl> - std : : mutex mu ; <nl> + grpc : : internal : : Mutex mu ; <nl> / / We need to acquire the lock here in order to prevent the notify_one <nl> / / by ServerThread : : Start from firing before the wait below is hit . <nl> - std : : unique_lock < std : : mutex > lock ( mu ) ; <nl> + grpc : : internal : : MutexLock lock ( & mu ) ; <nl> port_ = grpc_pick_unused_port_or_die ( ) ; <nl> gpr_log ( GPR_INFO , " starting % s server on port % d " , type_ . c_str ( ) , port_ ) ; <nl> - std : : condition_variable cond ; <nl> + grpc : : internal : : CondVar cond ; <nl> thread_ . reset ( new std : : thread ( <nl> std : : bind ( & ServerThread : : Start , this , server_host , & mu , & cond ) ) ) ; <nl> - cond . wait ( lock ) ; <nl> + cond . Wait ( & mu ) ; <nl> gpr_log ( GPR_INFO , " % s server startup complete " , type_ . c_str ( ) ) ; <nl> } <nl> <nl> - void Start ( const grpc : : string & server_host , std : : mutex * mu , <nl> - std : : condition_variable * cond ) { <nl> + void Start ( const grpc : : string & server_host , grpc : : internal : : Mutex * mu , <nl> + grpc : : internal : : CondVar * cond ) { <nl> / / We need to acquire the lock here in order to prevent the notify_one <nl> / / below from firing before its corresponding wait is executed . <nl> - std : : lock_guard < std : : mutex > lock ( * mu ) ; <nl> + grpc : : internal : : MutexLock lock ( mu ) ; <nl> std : : ostringstream server_address ; <nl> server_address < < server_host < < " : " < < port_ ; <nl> ServerBuilder builder ; <nl> class ClientChannelStressTest { <nl> InsecureServerCredentials ( ) ) ; <nl> builder . RegisterService ( service_ ) ; <nl> server_ = builder . BuildAndStart ( ) ; <nl> - cond - > notify_one ( ) ; <nl> + cond - > Signal ( ) ; <nl> } <nl> <nl> void Shutdown ( ) { <nl> mmm a / test / cpp / end2end / client_lb_end2end_test . cc <nl> ppp b / test / cpp / end2end / client_lb_end2end_test . cc <nl> <nl> # include < grpcpp / client_context . h > <nl> # include < grpcpp / create_channel . h > <nl> # include < grpcpp / health_check_service_interface . h > <nl> + # include < grpcpp / impl / codegen / sync . h > <nl> # include < grpcpp / server . h > <nl> # include < grpcpp / server_builder . h > <nl> <nl> class MyTestServiceImpl : public TestServiceImpl { <nl> Status Echo ( ServerContext * context , const EchoRequest * request , <nl> EchoResponse * response ) override { <nl> { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & mu_ ) ; <nl> + + request_count_ ; <nl> } <nl> AddClient ( context - > peer ( ) ) ; <nl> class MyTestServiceImpl : public TestServiceImpl { <nl> } <nl> <nl> int request_count ( ) { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & mu_ ) ; <nl> return request_count_ ; <nl> } <nl> <nl> void ResetCounters ( ) { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & mu_ ) ; <nl> request_count_ = 0 ; <nl> } <nl> <nl> std : : set < grpc : : string > clients ( ) { <nl> - std : : unique_lock < std : : mutex > lock ( clients_mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & clients_mu_ ) ; <nl> return clients_ ; <nl> } <nl> <nl> private : <nl> void AddClient ( const grpc : : string & client ) { <nl> - std : : unique_lock < std : : mutex > lock ( clients_mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & clients_mu_ ) ; <nl> clients_ . insert ( client ) ; <nl> } <nl> <nl> - std : : mutex mu_ ; <nl> + grpc : : internal : : Mutex mu_ ; <nl> int request_count_ ; <nl> - std : : mutex clients_mu_ ; <nl> + grpc : : internal : : Mutex clients_mu_ ; <nl> std : : set < grpc : : string > clients_ ; <nl> } ; <nl> <nl> class ClientLbEnd2endTest : public : : testing : : Test { <nl> void Start ( const grpc : : string & server_host ) { <nl> gpr_log ( GPR_INFO , " starting server on port % d " , port_ ) ; <nl> started_ = true ; <nl> - std : : mutex mu ; <nl> - std : : unique_lock < std : : mutex > lock ( mu ) ; <nl> - std : : condition_variable cond ; <nl> + grpc : : internal : : Mutex mu ; <nl> + grpc : : internal : : MutexLock lock ( & mu ) ; <nl> + grpc : : internal : : CondVar cond ; <nl> thread_ . reset ( new std : : thread ( <nl> std : : bind ( & ServerData : : Serve , this , server_host , & mu , & cond ) ) ) ; <nl> - cond . wait ( lock , [ this ] { return server_ready_ ; } ) ; <nl> + cond . WaitUntil ( & mu , [ this ] { return server_ready_ ; } ) ; <nl> server_ready_ = false ; <nl> gpr_log ( GPR_INFO , " server startup complete " ) ; <nl> } <nl> <nl> - void Serve ( const grpc : : string & server_host , std : : mutex * mu , <nl> - std : : condition_variable * cond ) { <nl> + void Serve ( const grpc : : string & server_host , grpc : : internal : : Mutex * mu , <nl> + grpc : : internal : : CondVar * cond ) { <nl> std : : ostringstream server_address ; <nl> server_address < < server_host < < " : " < < port_ ; <nl> ServerBuilder builder ; <nl> class ClientLbEnd2endTest : public : : testing : : Test { <nl> builder . AddListeningPort ( server_address . str ( ) , std : : move ( creds ) ) ; <nl> builder . RegisterService ( & service_ ) ; <nl> server_ = builder . BuildAndStart ( ) ; <nl> - std : : lock_guard < std : : mutex > lock ( * mu ) ; <nl> + grpc : : internal : : MutexLock lock ( mu ) ; <nl> server_ready_ = true ; <nl> - cond - > notify_one ( ) ; <nl> + cond - > Signal ( ) ; <nl> } <nl> <nl> void Shutdown ( ) { <nl> class ClientLbInterceptTrailingMetadataTest : public ClientLbEnd2endTest { <nl> void TearDown ( ) override { ClientLbEnd2endTest : : TearDown ( ) ; } <nl> <nl> int trailers_intercepted ( ) { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & mu_ ) ; <nl> return trailers_intercepted_ ; <nl> } <nl> <nl> class ClientLbInterceptTrailingMetadataTest : public ClientLbEnd2endTest { <nl> static void ReportTrailerIntercepted ( void * arg ) { <nl> ClientLbInterceptTrailingMetadataTest * self = <nl> static_cast < ClientLbInterceptTrailingMetadataTest * > ( arg ) ; <nl> - std : : unique_lock < std : : mutex > lock ( self - > mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & self - > mu_ ) ; <nl> self - > trailers_intercepted_ + + ; <nl> } <nl> <nl> - std : : mutex mu_ ; <nl> + grpc : : internal : : Mutex mu_ ; <nl> int trailers_intercepted_ = 0 ; <nl> } ; <nl> <nl> mmm a / test / cpp / end2end / grpclb_end2end_test . cc <nl> ppp b / test / cpp / end2end / grpclb_end2end_test . cc <nl> <nl> # include < grpcpp / channel . h > <nl> # include < grpcpp / client_context . h > <nl> # include < grpcpp / create_channel . h > <nl> + # include < grpcpp / impl / codegen / sync . h > <nl> # include < grpcpp / server . h > <nl> # include < grpcpp / server_builder . h > <nl> <nl> template < typename ServiceType > <nl> class CountedService : public ServiceType { <nl> public : <nl> size_t request_count ( ) { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & mu_ ) ; <nl> return request_count_ ; <nl> } <nl> <nl> size_t response_count ( ) { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & mu_ ) ; <nl> return response_count_ ; <nl> } <nl> <nl> void IncreaseResponseCount ( ) { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & mu_ ) ; <nl> + + response_count_ ; <nl> } <nl> void IncreaseRequestCount ( ) { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & mu_ ) ; <nl> + + request_count_ ; <nl> } <nl> <nl> void ResetCounters ( ) { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & mu_ ) ; <nl> request_count_ = 0 ; <nl> response_count_ = 0 ; <nl> } <nl> <nl> protected : <nl> - std : : mutex mu_ ; <nl> + grpc : : internal : : Mutex mu_ ; <nl> <nl> private : <nl> size_t request_count_ = 0 ; <nl> class BackendServiceImpl : public BackendService { <nl> void Shutdown ( ) { } <nl> <nl> std : : set < grpc : : string > clients ( ) { <nl> - std : : unique_lock < std : : mutex > lock ( clients_mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & clients_mu_ ) ; <nl> return clients_ ; <nl> } <nl> <nl> private : <nl> void AddClient ( const grpc : : string & client ) { <nl> - std : : unique_lock < std : : mutex > lock ( clients_mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & clients_mu_ ) ; <nl> clients_ . insert ( client ) ; <nl> } <nl> <nl> - std : : mutex mu_ ; <nl> - std : : mutex clients_mu_ ; <nl> + grpc : : internal : : Mutex mu_ ; <nl> + grpc : : internal : : Mutex clients_mu_ ; <nl> std : : set < grpc : : string > clients_ ; <nl> } ; <nl> <nl> class BalancerServiceImpl : public BalancerService { <nl> Status BalanceLoad ( ServerContext * context , Stream * stream ) override { <nl> gpr_log ( GPR_INFO , " LB [ % p ] : BalanceLoad " , this ) ; <nl> { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & mu_ ) ; <nl> if ( serverlist_done_ ) goto done ; <nl> } <nl> { <nl> class BalancerServiceImpl : public BalancerService { <nl> } <nl> <nl> { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & mu_ ) ; <nl> responses_and_delays = responses_and_delays_ ; <nl> } <nl> for ( const auto & response_and_delay : responses_and_delays ) { <nl> class BalancerServiceImpl : public BalancerService { <nl> response_and_delay . second ) ; <nl> } <nl> { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> - serverlist_cond_ . wait ( lock , [ this ] { return serverlist_done_ ; } ) ; <nl> + grpc : : internal : : MutexLock lock ( & mu_ ) ; <nl> + serverlist_cond_ . WaitUntil ( & mu_ , [ this ] { return serverlist_done_ ; } ) ; <nl> } <nl> <nl> if ( client_load_reporting_interval_seconds_ > 0 ) { <nl> class BalancerServiceImpl : public BalancerService { <nl> GPR_ASSERT ( request . has_client_stats ( ) ) ; <nl> / / We need to acquire the lock here in order to prevent the notify_one <nl> / / below from firing before its corresponding wait is executed . <nl> - std : : lock_guard < std : : mutex > lock ( mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & mu_ ) ; <nl> client_stats_ . num_calls_started + = <nl> request . client_stats ( ) . num_calls_started ( ) ; <nl> client_stats_ . num_calls_finished + = <nl> class BalancerServiceImpl : public BalancerService { <nl> drop_token_count . num_calls ( ) ; <nl> } <nl> load_report_ready_ = true ; <nl> - load_report_cond_ . notify_one ( ) ; <nl> + load_report_cond_ . Signal ( ) ; <nl> } <nl> } <nl> } <nl> class BalancerServiceImpl : public BalancerService { <nl> } <nl> <nl> void add_response ( const LoadBalanceResponse & response , int send_after_ms ) { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & mu_ ) ; <nl> responses_and_delays_ . push_back ( std : : make_pair ( response , send_after_ms ) ) ; <nl> } <nl> <nl> void Start ( ) { <nl> - std : : lock_guard < std : : mutex > lock ( mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & mu_ ) ; <nl> serverlist_done_ = false ; <nl> load_report_ready_ = false ; <nl> responses_and_delays_ . clear ( ) ; <nl> class BalancerServiceImpl : public BalancerService { <nl> } <nl> <nl> const ClientStats & WaitForLoadReport ( ) { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> - load_report_cond_ . wait ( lock , [ this ] { return load_report_ready_ ; } ) ; <nl> + grpc : : internal : : MutexLock lock ( & mu_ ) ; <nl> + load_report_cond_ . WaitUntil ( & mu_ , [ this ] { return load_report_ready_ ; } ) ; <nl> load_report_ready_ = false ; <nl> return client_stats_ ; <nl> } <nl> <nl> void NotifyDoneWithServerlists ( ) { <nl> - std : : lock_guard < std : : mutex > lock ( mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & mu_ ) ; <nl> if ( ! serverlist_done_ ) { <nl> serverlist_done_ = true ; <nl> - serverlist_cond_ . notify_all ( ) ; <nl> + serverlist_cond_ . Broadcast ( ) ; <nl> } <nl> } <nl> <nl> class BalancerServiceImpl : public BalancerService { <nl> <nl> const int client_load_reporting_interval_seconds_ ; <nl> std : : vector < ResponseDelayPair > responses_and_delays_ ; <nl> - std : : mutex mu_ ; <nl> - std : : condition_variable load_report_cond_ ; <nl> + grpc : : internal : : Mutex mu_ ; <nl> + grpc : : internal : : CondVar load_report_cond_ ; <nl> bool load_report_ready_ = false ; <nl> - std : : condition_variable serverlist_cond_ ; <nl> + grpc : : internal : : CondVar serverlist_cond_ ; <nl> bool serverlist_done_ = false ; <nl> ClientStats client_stats_ ; <nl> } ; <nl> class GrpclbEnd2endTest : public : : testing : : Test { <nl> GPR_ASSERT ( ! running_ ) ; <nl> running_ = true ; <nl> service_ . Start ( ) ; <nl> - std : : mutex mu ; <nl> + grpc : : internal : : Mutex mu ; <nl> / / We need to acquire the lock here in order to prevent the notify_one <nl> / / by ServerThread : : Serve from firing before the wait below is hit . <nl> - std : : unique_lock < std : : mutex > lock ( mu ) ; <nl> - std : : condition_variable cond ; <nl> + grpc : : internal : : MutexLock lock ( & mu ) ; <nl> + grpc : : internal : : CondVar cond ; <nl> thread_ . reset ( new std : : thread ( <nl> std : : bind ( & ServerThread : : Serve , this , server_host , & mu , & cond ) ) ) ; <nl> - cond . wait ( lock ) ; <nl> + cond . Wait ( & mu ) ; <nl> gpr_log ( GPR_INFO , " % s server startup complete " , type_ . c_str ( ) ) ; <nl> } <nl> <nl> - void Serve ( const grpc : : string & server_host , std : : mutex * mu , <nl> - std : : condition_variable * cond ) { <nl> + void Serve ( const grpc : : string & server_host , grpc : : internal : : Mutex * mu , <nl> + grpc : : internal : : CondVar * cond ) { <nl> / / We need to acquire the lock here in order to prevent the notify_one <nl> / / below from firing before its corresponding wait is executed . <nl> - std : : lock_guard < std : : mutex > lock ( * mu ) ; <nl> + grpc : : internal : : MutexLock lock ( mu ) ; <nl> std : : ostringstream server_address ; <nl> server_address < < server_host < < " : " < < port_ ; <nl> ServerBuilder builder ; <nl> class GrpclbEnd2endTest : public : : testing : : Test { <nl> builder . AddListeningPort ( server_address . str ( ) , creds ) ; <nl> builder . RegisterService ( & service_ ) ; <nl> server_ = builder . BuildAndStart ( ) ; <nl> - cond - > notify_one ( ) ; <nl> + cond - > Signal ( ) ; <nl> } <nl> <nl> void Shutdown ( ) { <nl> mmm a / test / cpp / end2end / thread_stress_test . cc <nl> ppp b / test / cpp / end2end / thread_stress_test . cc <nl> <nl> # include < grpcpp / channel . h > <nl> # include < grpcpp / client_context . h > <nl> # include < grpcpp / create_channel . h > <nl> + # include < grpcpp / impl / codegen / sync . h > <nl> # include < grpcpp / resource_quota . h > <nl> # include < grpcpp / server . h > <nl> # include < grpcpp / server_builder . h > <nl> class CommonStressTestAsyncServer : public BaseClass { <nl> } <nl> void TearDown ( ) override { <nl> { <nl> - std : : unique_lock < std : : mutex > l ( mu_ ) ; <nl> + grpc : : internal : : MutexLock l ( & mu_ ) ; <nl> this - > TearDownStart ( ) ; <nl> shutting_down_ = true ; <nl> cq_ - > Shutdown ( ) ; <nl> class CommonStressTestAsyncServer : public BaseClass { <nl> } <nl> } <nl> void RefreshContext ( int i ) { <nl> - std : : unique_lock < std : : mutex > l ( mu_ ) ; <nl> + grpc : : internal : : MutexLock l ( & mu_ ) ; <nl> if ( ! shutting_down_ ) { <nl> contexts_ [ i ] . state = Context : : READY ; <nl> contexts_ [ i ] . srv_ctx . reset ( new ServerContext ) ; <nl> class CommonStressTestAsyncServer : public BaseClass { <nl> : : grpc : : testing : : EchoTestService : : AsyncService service_ ; <nl> std : : unique_ptr < ServerCompletionQueue > cq_ ; <nl> bool shutting_down_ ; <nl> - std : : mutex mu_ ; <nl> + grpc : : internal : : Mutex mu_ ; <nl> std : : vector < std : : thread > server_threads_ ; <nl> } ; <nl> <nl> class AsyncClientEnd2endTest : public : : testing : : Test { <nl> } <nl> <nl> void Wait ( ) { <nl> - std : : unique_lock < std : : mutex > l ( mu_ ) ; <nl> + grpc : : internal : : MutexLock l ( & mu_ ) ; <nl> while ( rpcs_outstanding_ ! = 0 ) { <nl> - cv_ . wait ( l ) ; <nl> + cv_ . Wait ( & mu_ ) ; <nl> } <nl> <nl> cq_ . Shutdown ( ) ; <nl> class AsyncClientEnd2endTest : public : : testing : : Test { <nl> call - > response_reader - > Finish ( & call - > response , & call - > status , <nl> ( void * ) call ) ; <nl> <nl> - std : : unique_lock < std : : mutex > l ( mu_ ) ; <nl> + grpc : : internal : : MutexLock l ( & mu_ ) ; <nl> rpcs_outstanding_ + + ; <nl> } <nl> } <nl> class AsyncClientEnd2endTest : public : : testing : : Test { <nl> <nl> bool notify ; <nl> { <nl> - std : : unique_lock < std : : mutex > l ( mu_ ) ; <nl> + grpc : : internal : : MutexLock l ( & mu_ ) ; <nl> rpcs_outstanding_ - - ; <nl> notify = ( rpcs_outstanding_ = = 0 ) ; <nl> } <nl> if ( notify ) { <nl> - cv_ . notify_all ( ) ; <nl> + cv_ . Signal ( ) ; <nl> } <nl> } <nl> } <nl> <nl> Common common_ ; <nl> CompletionQueue cq_ ; <nl> - std : : mutex mu_ ; <nl> - std : : condition_variable cv_ ; <nl> + grpc : : internal : : Mutex mu_ ; <nl> + grpc : : internal : : CondVar cv_ ; <nl> int rpcs_outstanding_ ; <nl> } ; <nl> <nl> mmm a / test / cpp / end2end / xds_end2end_test . cc <nl> ppp b / test / cpp / end2end / xds_end2end_test . cc <nl> template < typename ServiceType > <nl> class CountedService : public ServiceType { <nl> public : <nl> size_t request_count ( ) { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & mu_ ) ; <nl> return request_count_ ; <nl> } <nl> <nl> size_t response_count ( ) { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & mu_ ) ; <nl> return response_count_ ; <nl> } <nl> <nl> void IncreaseResponseCount ( ) { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & mu_ ) ; <nl> + + response_count_ ; <nl> } <nl> void IncreaseRequestCount ( ) { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & mu_ ) ; <nl> + + request_count_ ; <nl> } <nl> <nl> void ResetCounters ( ) { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & mu_ ) ; <nl> request_count_ = 0 ; <nl> response_count_ = 0 ; <nl> } <nl> <nl> protected : <nl> - std : : mutex mu_ ; <nl> + grpc : : internal : : Mutex mu_ ; <nl> <nl> private : <nl> size_t request_count_ = 0 ; <nl> class BackendServiceImpl : public BackendService { <nl> void Shutdown ( ) { } <nl> <nl> std : : set < grpc : : string > clients ( ) { <nl> - std : : unique_lock < std : : mutex > lock ( clients_mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & clients_mu_ ) ; <nl> return clients_ ; <nl> } <nl> <nl> private : <nl> void AddClient ( const grpc : : string & client ) { <nl> - std : : unique_lock < std : : mutex > lock ( clients_mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & clients_mu_ ) ; <nl> clients_ . insert ( client ) ; <nl> } <nl> <nl> - std : : mutex mu_ ; <nl> - std : : mutex clients_mu_ ; <nl> + grpc : : internal : : Mutex mu_ ; <nl> + grpc : : internal : : Mutex clients_mu_ ; <nl> std : : set < grpc : : string > clients_ ; <nl> } ; <nl> <nl> class BalancerServiceImpl : public BalancerService { <nl> / / TODO ( juanlishen ) : Clean up the scoping . <nl> gpr_log ( GPR_INFO , " LB [ % p ] : BalanceLoad " , this ) ; <nl> { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & mu_ ) ; <nl> if ( serverlist_done_ ) goto done ; <nl> } <nl> { <nl> class BalancerServiceImpl : public BalancerService { <nl> } <nl> <nl> { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & mu_ ) ; <nl> responses_and_delays = responses_and_delays_ ; <nl> } <nl> for ( const auto & response_and_delay : responses_and_delays ) { <nl> class BalancerServiceImpl : public BalancerService { <nl> response_and_delay . second ) ; <nl> } <nl> { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> - serverlist_cond_ . wait ( lock , [ this ] { return serverlist_done_ ; } ) ; <nl> + grpc : : internal : : MutexLock lock ( & mu_ ) ; <nl> + serverlist_cond_ . WaitUntil ( & mu_ , [ this ] { return serverlist_done_ ; } ) ; <nl> } <nl> <nl> if ( client_load_reporting_interval_seconds_ > 0 ) { <nl> class BalancerServiceImpl : public BalancerService { <nl> GPR_ASSERT ( request . has_client_stats ( ) ) ; <nl> / / We need to acquire the lock here in order to prevent the notify_one <nl> / / below from firing before its corresponding wait is executed . <nl> - std : : lock_guard < std : : mutex > lock ( mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & mu_ ) ; <nl> client_stats_ . num_calls_started + = <nl> request . client_stats ( ) . num_calls_started ( ) ; <nl> client_stats_ . num_calls_finished + = <nl> class BalancerServiceImpl : public BalancerService { <nl> drop_token_count . num_calls ( ) ; <nl> } <nl> load_report_ready_ = true ; <nl> - load_report_cond_ . notify_one ( ) ; <nl> + load_report_cond_ . Signal ( ) ; <nl> } <nl> } <nl> } <nl> class BalancerServiceImpl : public BalancerService { <nl> } <nl> <nl> void add_response ( const LoadBalanceResponse & response , int send_after_ms ) { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & mu_ ) ; <nl> responses_and_delays_ . push_back ( std : : make_pair ( response , send_after_ms ) ) ; <nl> } <nl> <nl> void Shutdown ( ) { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & mu_ ) ; <nl> NotifyDoneWithServerlistsLocked ( ) ; <nl> responses_and_delays_ . clear ( ) ; <nl> client_stats_ . Reset ( ) ; <nl> class BalancerServiceImpl : public BalancerService { <nl> } <nl> <nl> const ClientStats & WaitForLoadReport ( ) { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> - load_report_cond_ . wait ( lock , [ this ] { return load_report_ready_ ; } ) ; <nl> + grpc : : internal : : MutexLock lock ( & mu_ ) ; <nl> + load_report_cond_ . WaitUntil ( & mu_ , [ this ] { return load_report_ready_ ; } ) ; <nl> load_report_ready_ = false ; <nl> return client_stats_ ; <nl> } <nl> <nl> void NotifyDoneWithServerlists ( ) { <nl> - std : : lock_guard < std : : mutex > lock ( mu_ ) ; <nl> + grpc : : internal : : MutexLock lock ( & mu_ ) ; <nl> NotifyDoneWithServerlistsLocked ( ) ; <nl> } <nl> <nl> void NotifyDoneWithServerlistsLocked ( ) { <nl> if ( ! serverlist_done_ ) { <nl> serverlist_done_ = true ; <nl> - serverlist_cond_ . notify_all ( ) ; <nl> + serverlist_cond_ . Broadcast ( ) ; <nl> } <nl> } <nl> <nl> class BalancerServiceImpl : public BalancerService { <nl> <nl> const int client_load_reporting_interval_seconds_ ; <nl> std : : vector < ResponseDelayPair > responses_and_delays_ ; <nl> - std : : mutex mu_ ; <nl> - std : : condition_variable load_report_cond_ ; <nl> + grpc : : internal : : Mutex mu_ ; <nl> + grpc : : internal : : CondVar load_report_cond_ ; <nl> bool load_report_ready_ = false ; <nl> - std : : condition_variable serverlist_cond_ ; <nl> + grpc : : internal : : CondVar serverlist_cond_ ; <nl> bool serverlist_done_ = false ; <nl> ClientStats client_stats_ ; <nl> } ; <nl> class XdsEnd2endTest : public : : testing : : Test { <nl> gpr_log ( GPR_INFO , " starting % s server on port % d " , type_ . c_str ( ) , port_ ) ; <nl> GPR_ASSERT ( ! running_ ) ; <nl> running_ = true ; <nl> - std : : mutex mu ; <nl> + grpc : : internal : : Mutex mu ; <nl> / / We need to acquire the lock here in order to prevent the notify_one <nl> / / by ServerThread : : Serve from firing before the wait below is hit . <nl> - std : : unique_lock < std : : mutex > lock ( mu ) ; <nl> - std : : condition_variable cond ; <nl> + grpc : : internal : : MutexLock lock ( & mu ) ; <nl> + grpc : : internal : : CondVar cond ; <nl> thread_ . reset ( new std : : thread ( <nl> std : : bind ( & ServerThread : : Serve , this , server_host , & mu , & cond ) ) ) ; <nl> - cond . wait ( lock ) ; <nl> + cond . Wait ( & mu ) ; <nl> gpr_log ( GPR_INFO , " % s server startup complete " , type_ . c_str ( ) ) ; <nl> } <nl> <nl> - void Serve ( const grpc : : string & server_host , std : : mutex * mu , <nl> - std : : condition_variable * cond ) { <nl> + void Serve ( const grpc : : string & server_host , grpc : : internal : : Mutex * mu , <nl> + grpc : : internal : : CondVar * cond ) { <nl> / / We need to acquire the lock here in order to prevent the notify_one <nl> / / below from firing before its corresponding wait is executed . <nl> - std : : lock_guard < std : : mutex > lock ( * mu ) ; <nl> + grpc : : internal : : MutexLock lock ( mu ) ; <nl> std : : ostringstream server_address ; <nl> server_address < < server_host < < " : " < < port_ ; <nl> ServerBuilder builder ; <nl> class XdsEnd2endTest : public : : testing : : Test { <nl> builder . AddListeningPort ( server_address . str ( ) , creds ) ; <nl> builder . RegisterService ( & service_ ) ; <nl> server_ = builder . BuildAndStart ( ) ; <nl> - cond - > notify_one ( ) ; <nl> + cond - > Signal ( ) ; <nl> } <nl> <nl> void Shutdown ( ) { <nl> mmm a / tools / doxygen / Doxyfile . c + + <nl> ppp b / tools / doxygen / Doxyfile . c + + <nl> include / grpcpp / impl / codegen / status . h \ <nl> include / grpcpp / impl / codegen / status_code_enum . h \ <nl> include / grpcpp / impl / codegen / string_ref . h \ <nl> include / grpcpp / impl / codegen / stub_options . h \ <nl> + include / grpcpp / impl / codegen / sync . h \ <nl> include / grpcpp / impl / codegen / sync_stream . h \ <nl> include / grpcpp / impl / codegen / time . h \ <nl> include / grpcpp / impl / grpc_library . h \ <nl> mmm a / tools / doxygen / Doxyfile . c + + . internal <nl> ppp b / tools / doxygen / Doxyfile . c + + . internal <nl> include / grpcpp / impl / codegen / status . h \ <nl> include / grpcpp / impl / codegen / status_code_enum . h \ <nl> include / grpcpp / impl / codegen / string_ref . h \ <nl> include / grpcpp / impl / codegen / stub_options . h \ <nl> + include / grpcpp / impl / codegen / sync . h \ <nl> include / grpcpp / impl / codegen / sync_stream . h \ <nl> include / grpcpp / impl / codegen / time . h \ <nl> include / grpcpp / impl / grpc_library . h \ <nl> src / core / lib / gprpp / inlined_vector . h \ <nl> src / core / lib / gprpp / manual_constructor . h \ <nl> src / core / lib / gprpp / map . h \ <nl> src / core / lib / gprpp / memory . h \ <nl> - src / core / lib / gprpp / mutex_lock . h \ <nl> src / core / lib / gprpp / optional . h \ <nl> src / core / lib / gprpp / orphanable . h \ <nl> src / core / lib / gprpp / pair . h \ <nl> src / core / lib / gprpp / ref_counted . h \ <nl> src / core / lib / gprpp / ref_counted_ptr . h \ <nl> + src / core / lib / gprpp / sync . h \ <nl> src / core / lib / gprpp / thd . h \ <nl> src / core / lib / http / format_request . h \ <nl> src / core / lib / http / httpcli . h \ <nl> mmm a / tools / doxygen / Doxyfile . core . internal <nl> ppp b / tools / doxygen / Doxyfile . core . internal <nl> src / core / lib / gprpp / inlined_vector . h \ <nl> src / core / lib / gprpp / manual_constructor . h \ <nl> src / core / lib / gprpp / map . h \ <nl> src / core / lib / gprpp / memory . h \ <nl> - src / core / lib / gprpp / mutex_lock . h \ <nl> src / core / lib / gprpp / optional . h \ <nl> src / core / lib / gprpp / orphanable . h \ <nl> src / core / lib / gprpp / pair . h \ <nl> src / core / lib / gprpp / ref_counted . h \ <nl> src / core / lib / gprpp / ref_counted_ptr . h \ <nl> + src / core / lib / gprpp / sync . h \ <nl> src / core / lib / gprpp / thd . h \ <nl> src / core / lib / gprpp / thd_posix . cc \ <nl> src / core / lib / gprpp / thd_windows . cc \ <nl> mmm a / tools / run_tests / generated / sources_and_headers . json <nl> ppp b / tools / run_tests / generated / sources_and_headers . json <nl> <nl> " src / core / lib / gprpp / manual_constructor . h " , <nl> " src / core / lib / gprpp / map . h " , <nl> " src / core / lib / gprpp / memory . h " , <nl> - " src / core / lib / gprpp / mutex_lock . h " , <nl> " src / core / lib / gprpp / pair . h " , <nl> + " src / core / lib / gprpp / sync . h " , <nl> " src / core / lib / gprpp / thd . h " , <nl> " src / core / lib / profiling / timers . h " <nl> ] , <nl> <nl> " src / core / lib / gprpp / manual_constructor . h " , <nl> " src / core / lib / gprpp / map . h " , <nl> " src / core / lib / gprpp / memory . h " , <nl> - " src / core / lib / gprpp / mutex_lock . h " , <nl> " src / core / lib / gprpp / pair . h " , <nl> + " src / core / lib / gprpp / sync . h " , <nl> " src / core / lib / gprpp / thd . h " , <nl> " src / core / lib / profiling / timers . h " <nl> ] , <nl> <nl> } , <nl> { <nl> " deps " : [ <nl> + " grpc + + _internal_hdrs_only " , <nl> " grpc_codegen " <nl> ] , <nl> " headers " : [ <nl> <nl> " gpr " , <nl> " gpr_base_headers " , <nl> " grpc + + _codegen_base " , <nl> + " grpc + + _internal_hdrs_only " , <nl> " grpc_base_headers " , <nl> " grpc_transport_inproc_headers " , <nl> " health_proto " , <nl> <nl> " third_party " : false , <nl> " type " : " filegroup " <nl> } , <nl> + { <nl> + " deps " : [ ] , <nl> + " headers " : [ <nl> + " include / grpcpp / impl / codegen / sync . h " <nl> + ] , <nl> + " is_filegroup " : true , <nl> + " language " : " c + + " , <nl> + " name " : " grpc + + _internal_hdrs_only " , <nl> + " src " : [ <nl> + " include / grpcpp / impl / codegen / sync . h " <nl> + ] , <nl> + " third_party " : false , <nl> + " type " : " filegroup " <nl> + } , <nl> { <nl> " deps " : [ ] , <nl> " headers " : [ <nl>
Revert " Revert " Introduce C + + wrappers for gpr_mu and gpr_cv . " "
grpc/grpc
2b9448a71c39e5ebcd79bedc71d1da8efcdbfceb
2019-04-17T18:35:29Z
mmm a / include / swift / SIL / DebugUtils . h <nl> ppp b / include / swift / SIL / DebugUtils . h <nl> <nl> # define SWIFT_SIL_DEBUGUTILS_H <nl> <nl> # include " swift / SIL / SILValue . h " <nl> - # include " swift / SIL / SILInstruction . h " <nl> <nl> namespace swift { <nl> + <nl> + class SILInstruction ; <nl> <nl> / / / Returns true if the instruction \ p Inst is an instruction which is only <nl> / / / relevant for debug information and has no other impact on program semantics . <nl> mmm a / include / swift / SIL / PatternMatch . h <nl> ppp b / include / swift / SIL / PatternMatch . h <nl> <nl> <nl> # include " swift / SIL / SILArgument . h " <nl> # include " swift / SIL / SILUndef . h " <nl> - # include " swift / SIL / SILInstruction . h " <nl> - <nl> namespace swift { <nl> + <nl> + class SILInstruction ; <nl> + <nl> namespace PatternMatch { <nl> <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl>
Add forward declarations for SILInstruction .
apple/swift
406fe201293478a647d71ba964312cdf8bd7d1a5
2015-09-19T02:48:06Z
mmm a / tools / js - optimizer . js <nl> ppp b / tools / js - optimizer . js <nl> function outline ( ast ) { <nl> for ( var name in appearances ) { <nl> if ( appearances [ name ] > 0 ) reads [ name ] = 0 ; <nl> } <nl> - <nl> - return { writes : writes , reads : reads , hasReturn : hasReturn , breaks : breaks , continues : continues , labels : labels } ; <nl> + return { writes : writes , reads : reads , hasReturn : hasReturn , hasBreak : hasBreak , hasContinue : hasContinue , breaks : breaks , continues : continues , labels : labels } ; <nl> } <nl> <nl> function makeAssign ( dst , src ) { <nl> function outline ( ast ) { <nl> if ( codeInfo . hasBreak ) { <nl> reps . push ( makeIf ( <nl> makeComparison ( makeStackAccess ( ASM_INT , asmData . controlStackPos ) , ' = = ' , [ ' num ' , CONTROL_BREAK ] ) , <nl> - [ ' stat ' , [ ' break ' ] ] <nl> + [ [ ' stat ' , [ ' break ' ] ] ] <nl> ) ) ; <nl> reps . push ( makeIf ( <nl> makeComparison ( makeStackAccess ( ASM_INT , asmData . controlStackPos ) , ' = = ' , [ ' num ' , CONTROL_BREAK_LABEL ] ) , <nl> - [ ' stat ' , [ ' break ' , makeStackAccess ( ASM_INT , asmData . controlDataStackPos ) ] ] / / XXX here and below , need a switch overall possible labels <nl> + [ [ ' stat ' , [ ' break ' , makeStackAccess ( ASM_INT , asmData . controlDataStackPos ) ] ] ] / / XXX here and below , need a switch overall possible labels <nl> ) ) ; <nl> } <nl> if ( codeInfo . hasContinue ) { <nl> reps . push ( makeIf ( <nl> makeComparison ( makeStackAccess ( ASM_INT , asmData . controlStackPos ) , ' = = ' , [ ' num ' , CONTROL_CONTINUE ] ) , <nl> - [ ' stat ' , [ ' break ' ] ] <nl> + [ [ ' stat ' , [ ' break ' ] ] ] <nl> ) ) ; <nl> reps . push ( makeIf ( <nl> makeComparison ( makeStackAccess ( ASM_INT , asmData . controlStackPos ) , ' = = ' , [ ' num ' , CONTROL_CONTINUE_LABEL ] ) , <nl> - [ ' stat ' , [ ' continue ' , makeStackAccess ( ASM_INT , asmData . controlDataStackPos ) ] ] / / XXX <nl> + [ [ ' stat ' , [ ' continue ' , makeStackAccess ( ASM_INT , asmData . controlDataStackPos ) ] ] ] / / XXX <nl> ) ) ; <nl> } <nl> } <nl>
fix hasBreak / hasContinue processing in outline
emscripten-core/emscripten
e747992077a1889a92330d7677cb1324c5fb499b
2013-07-17T00:12:31Z
mmm a / tensorflow / core / distributed_runtime / graph_mgr . cc <nl> ppp b / tensorflow / core / distributed_runtime / graph_mgr . cc <nl> Status GraphMgr : : RecvOutputsFromRendezvous ( Rendezvous * rendezvous , <nl> return Status : : OK ( ) ; <nl> } <nl> <nl> + void GraphMgr : : RecvOutputsFromRendezvousAsync ( Rendezvous * rendezvous , <nl> + NamedTensors * out , <nl> + const StatusCallback & done ) { <nl> + if ( out - > empty ( ) ) { <nl> + done ( Status : : OK ( ) ) ; <nl> + return ; <nl> + } <nl> + / / We compute the args before calling RecvAsync because we need to ensure that <nl> + / / out isn ' t being iterated over after done is called , since done deletes out . <nl> + std : : vector < std : : tuple < string , Tensor * , Rendezvous : : ParsedKey > > args ; <nl> + for ( auto & p : * out ) { <nl> + Rendezvous : : ParsedKey parsed ; <nl> + Status s = Rendezvous : : ParseKey ( p . first , & parsed ) ; <nl> + if ( ! s . ok ( ) ) { <nl> + done ( s ) ; <nl> + return ; <nl> + } <nl> + args . push_back ( std : : make_tuple ( p . first , & p . second , parsed ) ) ; <nl> + } <nl> + <nl> + typedef struct { <nl> + mutex mu ; <nl> + int done_counter ; <nl> + Status shared_status = Status : : OK ( ) ; <nl> + } CallState ; <nl> + CallState * call_state = new CallState ; <nl> + call_state - > done_counter = out - > size ( ) ; <nl> + for ( auto & p : args ) { <nl> + const string & key = std : : get < 0 > ( p ) ; <nl> + Tensor * val = std : : get < 1 > ( p ) ; <nl> + Rendezvous : : ParsedKey parsed = std : : get < 2 > ( p ) ; <nl> + rendezvous - > RecvAsync ( <nl> + parsed , Rendezvous : : Args ( ) , <nl> + [ val , done , key , call_state ] ( const Status & s , <nl> + const Rendezvous : : Args & send_args , <nl> + const Rendezvous : : Args & recv_args , <nl> + const Tensor & v , const bool is_dead ) { <nl> + Status status = s ; <nl> + if ( status . ok ( ) ) { <nl> + * val = v ; <nl> + if ( is_dead ) { <nl> + status = errors : : InvalidArgument ( " The tensor returned for " , key , <nl> + " was not valid . " ) ; <nl> + } <nl> + } <nl> + call_state - > mu . lock ( ) ; <nl> + if ( status . ok ( ) ) { <nl> + call_state - > shared_status = status ; <nl> + } <nl> + call_state - > done_counter - - ; <nl> + / / If we are the last async call to return , call the done callback . <nl> + if ( call_state - > done_counter = = 0 ) { <nl> + const Status & final_status = call_state - > shared_status ; <nl> + call_state - > mu . unlock ( ) ; <nl> + done ( final_status ) ; <nl> + delete call_state ; <nl> + return ; <nl> + } <nl> + call_state - > mu . unlock ( ) ; <nl> + } ) ; <nl> + } <nl> + } <nl> + <nl> Status GraphMgr : : SendInputs ( const int64 step_id , const NamedTensors & in ) { <nl> Rendezvous * rendezvous = worker_env_ - > rendezvous_mgr - > Find ( step_id ) ; <nl> Status s = SendInputsToRendezvous ( rendezvous , in ) ; <nl> Status GraphMgr : : RecvOutputs ( const int64 step_id , NamedTensors * out ) { <nl> return s ; <nl> } <nl> <nl> + void GraphMgr : : RecvOutputsAsync ( const int64 step_id , NamedTensors * out , <nl> + StatusCallback done ) { <nl> + Rendezvous * rendezvous = worker_env_ - > rendezvous_mgr - > Find ( step_id ) ; <nl> + RecvOutputsFromRendezvousAsync ( rendezvous , out , <nl> + [ done , rendezvous ] ( const Status s ) { <nl> + rendezvous - > Unref ( ) ; <nl> + done ( s ) ; <nl> + } ) ; <nl> + } <nl> + <nl> void GraphMgr : : ExecuteAsync ( const string & handle , const int64 step_id , <nl> const ExecutorOpts & opts , <nl> StepStatsCollector * collector , <nl> void GraphMgr : : StartParallelExecutors ( const string & handle , int64 step_id , <nl> worker_env_ - > device_mgr - > ClearContainers ( { name } ) ; <nl> } ) ; <nl> / / NOTE : Transfer one ref of rendezvous and item . <nl> - ExecutorBarrier * barrier = new ExecutorBarrier ( <nl> - num_units , rendezvous , [ this , item , collector , cost_graph , step_container , <nl> - done ] ( const Status & s ) { <nl> - BuildCostModel ( item , collector , cost_graph ) ; <nl> - done ( s ) ; <nl> - delete step_container ; <nl> - } ) ; <nl> + ExecutorBarrier * barrier = <nl> + new ExecutorBarrier ( num_units , rendezvous , <nl> + [ this , item , collector , cost_graph , step_container , <nl> + done ] ( const Status & s ) { <nl> + BuildCostModel ( item , collector , cost_graph ) ; <nl> + done ( s ) ; <nl> + delete step_container ; <nl> + } ) ; <nl> Executor : : Args args ; <nl> { <nl> mutex_lock l ( mu_ ) ; <nl> void GraphMgr : : StartParallelExecutors ( const string & handle , int64 step_id , <nl> LogMemory : : RecordStep ( args . step_id , handle ) ; <nl> } <nl> thread : : ThreadPool * pool = worker_env_ - > compute_pool ; <nl> - using namespace std : : placeholders ; <nl> + using std : : placeholders : : _1 ; <nl> / / Line below is equivalent to this code , but does one less indirect call : <nl> / / args . runner = [ pool ] ( std : : function < void ( ) > fn ) { pool - > Schedule ( fn ) ; } ; <nl> args . runner = std : : bind ( & thread : : ThreadPool : : Schedule , pool , _1 ) ; <nl> mmm a / tensorflow / core / distributed_runtime / graph_mgr . h <nl> ppp b / tensorflow / core / distributed_runtime / graph_mgr . h <nl> class GraphMgr { <nl> <nl> Status SendInputs ( const int64 step_id , const NamedTensors & in ) ; <nl> Status RecvOutputs ( const int64 step_id , NamedTensors * out ) ; <nl> + void RecvOutputsAsync ( const int64 step_id , NamedTensors * out , <nl> + StatusCallback done ) ; <nl> <nl> / / Deregisters a graph . <nl> Status Deregister ( const string & handle ) ; <nl> class GraphMgr { <nl> <nl> Status SendInputsToRendezvous ( Rendezvous * rendezvous , const NamedTensors & in ) ; <nl> Status RecvOutputsFromRendezvous ( Rendezvous * rendezvous , NamedTensors * out ) ; <nl> + void RecvOutputsFromRendezvousAsync ( Rendezvous * rendezvous , NamedTensors * out , <nl> + const StatusCallback & done ) ; <nl> <nl> Status InitItem ( const string & session , const GraphDef & gdef , <nl> const GraphOptions & graph_options , Item * item ) ; <nl> mmm a / tensorflow / core / distributed_runtime / worker . cc <nl> ppp b / tensorflow / core / distributed_runtime / worker . cc <nl> void Worker : : DeregisterGraphAsync ( const DeregisterGraphRequest * request , <nl> <nl> Worker : : PartialRunState * Worker : : FindPartialRun ( const string & graph_handle , <nl> int step_id ) { <nl> - std : : pair < string , int > k ( graph_handle , step_id ) ; <nl> + const std : : pair < string , int > k ( graph_handle , step_id ) ; <nl> Worker : : PartialRunState * prun_state = nullptr ; <nl> mutex_lock l ( mu_ ) ; <nl> auto it = partial_runs_ . find ( k ) ; <nl> Worker : : PartialRunState * Worker : : FindPartialRun ( const string & graph_handle , <nl> void Worker : : InsertPartialRunLocked ( const string & graph_handle , int step_id , <nl> Worker : : PartialRunState * partial_run_state ) <nl> EXCLUSIVE_LOCKS_REQUIRED ( mu_ ) { <nl> - std : : pair < string , int > k ( graph_handle , step_id ) ; <nl> + const std : : pair < string , int > k ( graph_handle , step_id ) ; <nl> partial_runs_ . emplace ( std : : make_pair ( <nl> k , std : : unique_ptr < Worker : : PartialRunState > ( partial_run_state ) ) ) ; <nl> } <nl> <nl> void Worker : : RemovePartialRun ( const string & graph_handle , int step_id ) { <nl> - std : : pair < string , int > k ( graph_handle , step_id ) ; <nl> + const std : : pair < string , int > k ( graph_handle , step_id ) ; <nl> mutex_lock l ( mu_ ) ; <nl> partial_runs_ . erase ( partial_runs_ . find ( k ) ) ; <nl> } <nl> <nl> + void Worker : : MaybeCallFinalCallback ( const string & graph_handle , int step_id , <nl> + const Status & executor_status ) { <nl> + const std : : pair < string , int > k ( graph_handle , step_id ) ; <nl> + StatusCallback done ; <nl> + Status s ; <nl> + { <nl> + mutex_lock l ( mu_ ) ; <nl> + auto it = partial_runs_ . find ( k ) ; <nl> + if ( it ! = partial_runs_ . end ( ) ) { <nl> + / / If we found the partial_run , we call the final callback , if it <nl> + / / exists . <nl> + std : : swap ( done , it - > second - > final_callback ) ; <nl> + s = it - > second - > final_status ; <nl> + it - > second - > executor_done = true ; <nl> + } <nl> + } <nl> + if ( done ! = nullptr ) { <nl> + if ( s . ok ( ) ) { <nl> + s = executor_status ; <nl> + } <nl> + done ( s ) ; <nl> + } <nl> + } <nl> + <nl> + void Worker : : SetOrCallFinalCallback ( const string & graph_handle , int step_id , <nl> + StatusCallback done , const Status & s ) { <nl> + const std : : pair < string , int > k ( graph_handle , step_id ) ; <nl> + { <nl> + mutex_lock l ( mu_ ) ; <nl> + auto it = partial_runs_ . find ( k ) ; <nl> + if ( ! it - > second - > executor_done ) { <nl> + / / If we found the partial_run , we set the final callback to call only <nl> + / / when the executor is completely done . <nl> + it - > second - > final_callback = std : : move ( done ) ; <nl> + it - > second - > final_status = s ; <nl> + return ; <nl> + } <nl> + } <nl> + / / Otherwise we call the callback immediately . <nl> + done ( s ) ; <nl> + } <nl> + <nl> void Worker : : AbortStep ( int64 step_id ) { <nl> Rendezvous * rendez = env_ - > rendezvous_mgr - > Find ( step_id ) ; <nl> SchedNonBlockingClosureAfter ( 1000000 , [ rendez , step_id ] ( ) { <nl> void Worker : : DoPartialRunGraph ( CallOptions * opts , <nl> GraphMgr : : NamedTensors in ; <nl> GraphMgr : : NamedTensors * out = new GraphMgr : : NamedTensors ; <nl> Status s = PrepareRunGraph ( request , & in , out ) ; <nl> - auto finish = [ this , done , out ] ( const Status & s ) { <nl> + auto finish = [ this , done , out , opts ] ( const Status & s ) { <nl> + opts - > ClearCancelCallback ( ) ; <nl> delete out ; <nl> done ( s ) ; <nl> } ; <nl> void Worker : : DoPartialRunGraph ( CallOptions * opts , <nl> env_ - > graph_mgr - > ExecuteAsync ( <nl> graph_handle , step_id , request - > exec_opts ( ) , nullptr / * collector * / , <nl> nullptr / * cost_graph * / , cm , in , <nl> - [ this , step_id , graph_handle , token , partial_run_state ] ( Status s ) { <nl> + [ this , token , graph_handle , step_id , cm ] ( Status s ) { <nl> { <nl> mutex_lock l ( mu_ ) ; <nl> cancellation_manager_ - > DeregisterCallback ( token ) ; <nl> } <nl> - partial_run_state - > executor_done . Notify ( ) ; <nl> - / / TODO ( suharshs ) : Propagate the status once we keep state for <nl> - / / each partial run call . <nl> + MaybeCallFinalCallback ( graph_handle , step_id , s ) ; <nl> + delete cm ; <nl> } ) ; <nl> } else { <nl> / / Send the partial run ' s new inputs . <nl> void Worker : : DoPartialRunGraph ( CallOptions * opts , <nl> } <nl> } <nl> <nl> - / / Receive the partial run ' s outputs . <nl> - s = env_ - > graph_mgr - > RecvOutputs ( step_id , out ) ; <nl> - if ( ! s . ok ( ) ) { <nl> - finish ( s ) ; <nl> - return ; <nl> - } <nl> - <nl> - / / Construct and return the resp . <nl> - for ( const auto & p : * out ) { <nl> - const string & key = p . first ; <nl> - const Tensor & val = p . second ; <nl> - response - > AddRecv ( key , val ) ; <nl> - } <nl> - <nl> - / / If this is the last partial run request we must also wait for the entire <nl> - / / graph execution to be completed . <nl> - if ( request - > is_last_partial_run ( ) ) { <nl> - partial_run_state - > executor_done . WaitForNotification ( ) ; <nl> - RemovePartialRun ( graph_handle , step_id ) ; <nl> - / / Before deleting the cancellation manager on the final call , ensure <nl> - / / that we clear the RPC cancel callback , which has a reference to the <nl> - / / cancellation manager . <nl> - opts - > ClearCancelCallback ( ) ; <nl> - delete cm ; <nl> - } <nl> - <nl> - finish ( s ) ; <nl> + env_ - > graph_mgr - > RecvOutputsAsync ( <nl> + step_id , out , <nl> + [ this , out , request , response , graph_handle , step_id , <nl> + finish ] ( Status s ) { <nl> + if ( s . ok ( ) ) { <nl> + / / Construct and return the resp . <nl> + for ( const auto & p : * out ) { <nl> + const string & key = p . first ; <nl> + const Tensor & val = p . second ; <nl> + response - > AddRecv ( key , val ) ; <nl> + } <nl> + } <nl> + if ( request - > is_last_partial_run ( ) ) { <nl> + SetOrCallFinalCallback ( <nl> + graph_handle , step_id , <nl> + [ this , graph_handle , step_id , finish ] ( const Status & s ) { <nl> + finish ( s ) ; <nl> + / / We must wait to remove the partial_run_state until both the <nl> + / / executor and the RecvAsync are complete . <nl> + RemovePartialRun ( graph_handle , step_id ) ; <nl> + } , <nl> + s ) ; <nl> + } else { <nl> + finish ( s ) ; <nl> + } <nl> + } ) ; <nl> } <nl> <nl> void Worker : : CleanupGraphAsync ( const CleanupGraphRequest * request , <nl> mmm a / tensorflow / core / distributed_runtime / worker . h <nl> ppp b / tensorflow / core / distributed_runtime / worker . h <nl> class Worker : public WorkerInterface { <nl> <nl> struct PartialRunState { <nl> CancellationManager * cancellation_manager ; <nl> - Notification executor_done ; <nl> + <nl> + bool executor_done = false ; <nl> + StatusCallback final_callback = nullptr ; <nl> + Status final_status ; <nl> <nl> explicit PartialRunState ( CancellationManager * cm ) <nl> : cancellation_manager ( cm ) { } <nl> class Worker : public WorkerInterface { <nl> <nl> void RemovePartialRun ( const string & graph_handle , int step_id ) ; <nl> <nl> + void MaybeCallFinalCallback ( const string & graph_handle , int step_id , <nl> + const Status & executor_status ) ; <nl> + <nl> + void SetOrCallFinalCallback ( const string & graph_handle , int step_id , <nl> + StatusCallback done , const Status & s ) ; <nl> + <nl> Status PrepareRunGraph ( RunGraphRequestWrapper * req , <nl> GraphMgr : : NamedTensors * in , <nl> GraphMgr : : NamedTensors * out ) ; <nl>
Ensure that partial run doesn ' t block any threads on the worker compute_pool .
tensorflow/tensorflow
7b03171d6e50216fc7fdff9a2502a6af660291dd
2017-03-16T00:44:33Z
mmm a / src / mongo / db / range_deleter . cpp <nl> ppp b / src / mongo / db / range_deleter . cpp <nl> <nl> # include < memory > <nl> <nl> # include " mongo / s / range_arithmetic . h " <nl> + # include " mongo / db / client . h " <nl> # include " mongo / db / range_deleter_stats . h " <nl> # include " mongo / util / concurrency / synchronization . h " <nl> # include " mongo / util / mongoutils / str . h " <nl> namespace mongo { <nl> } <nl> <nl> void RangeDeleter : : doWork ( ) { <nl> + if ( currentClient . get ( ) = = NULL ) <nl> + Client : : initThread ( " RangeDeleter " ) ; <nl> + <nl> while ( ! inShutdown ( ) & & ! stopRequested ( ) ) { <nl> string errMsg ; <nl> <nl>
RangeDeleter must initialize its thread
mongodb/mongo
27fc2e488079ca2bfc04dadfa4512b7ca5c3bc54
2014-01-26T01:14:30Z
mmm a / contracts / eoslib / message . hpp <nl> ppp b / contracts / eoslib / message . hpp <nl> namespace eosio { <nl> * require_notice ( N ( Account1 ) , N ( Account2 ) , N ( Account3 ) ) ; / / throws exception if any of them not in set . <nl> * @ endcode <nl> * / <nl> - template < typename . . . accounts > <nl> - void require_notice ( account_name name , accounts . . . remaining_accounts ) { <nl> + template < typename . . . Accounts > <nl> + void require_notice ( account_name name , Accounts . . . remaining_accounts ) { <nl> require_notice ( name ) ; <nl> require_notice ( remaining_accounts . . . ) ; <nl> } <nl> mmm a / contracts / eoslib / print . hpp <nl> ppp b / contracts / eoslib / print . hpp <nl> namespace eosio { <nl> * @ brief Prints a 64 bit names as base32 encoded string <nl> * @ param Value of 64 bit names to be printed <nl> * / <nl> - inline void print ( Name name ) { <nl> + inline void print ( name name ) { <nl> printn ( name . value ) ; <nl> } <nl> <nl> mmm a / contracts / eoslib / token . hpp <nl> ppp b / contracts / eoslib / token . hpp <nl> namespace eosio { <nl> * <nl> * @ brief a uint64_t wrapper with checks for proper types and over / underflows . <nl> * @ tparam NumberType - numeric type of the token <nl> - * @ tparam CurrencyType - type of the currency ( e . g . eos ) represented as an unsigned 64 bit integer <nl> + * @ tparam currency - type of the currency ( e . g . eos ) represented as an unsigned 64 bit integer <nl> * @ ingroup tokens <nl> * <nl> * @ details Base token structure with checks for proper types and over / underflows . <nl> namespace eosio { <nl> * <nl> * @ { <nl> * / <nl> - template < typename NumberType , uint64_t CurrencyType = N ( eos ) > <nl> + template < typename NumberType , uint64_t currency = N ( eos ) > <nl> struct token { <nl> / * * <nl> * Type of the currency ( e . g . eos ) represented as an unsigned 64 bit integer <nl> * @ brief Type of the currency <nl> * / <nl> - static const uint64_t currency_type = CurrencyType ; <nl> + static const uint64_t currency_type = currency ; <nl> <nl> / * * <nl> * Default constructor <nl> namespace eosio { <nl> * @ brief Print as string <nl> * / <nl> inline void print ( ) { <nl> - eosio : : print ( quantity , " " , Name ( CurrencyType ) ) ; <nl> + eosio : : print ( quantity , " " , name ( currency_type ) ) ; <nl> } <nl> } ; <nl> / / / @ } <nl> namespace eosio { <nl> * @ brief Prints as string . <nl> * / <nl> inline void print ( ) { <nl> - eosio : : print ( base_per_quote , " . " , " " , Name ( base_token_type : : currency_type ) , " / " , Name ( quote_token_type : : currency_type ) ) ; <nl> + eosio : : print ( base_per_quote , " . " , " " , name ( base_token_type : : currency_type ) , " / " , name ( quote_token_type : : currency_type ) ) ; <nl> } <nl> private : <nl> / * * <nl> mmm a / contracts / eoslib / types . hpp <nl> ppp b / contracts / eoslib / types . hpp <nl> namespace eosio { <nl> # define N ( X ) : : eosio : : string_to_name ( # X ) <nl> <nl> / * * <nl> - * @ class Name <nl> + * @ class name <nl> * @ brief wraps a uint64_t to ensure it is only passed to methods that expect a Name <nl> * @ details wraps a uint64_t to ensure it is only passed to methods that expect a Name and <nl> * that no mathematical operations occur . It also enables specialization of print <nl> namespace eosio { <nl> * @ ingroup types <nl> * @ { <nl> * / <nl> - struct Name { <nl> - Name ( uint64_t v = 0 ) : value ( v ) { } <nl> + struct name { <nl> + name ( uint64_t v = 0 ) : value ( v ) { } <nl> operator uint64_t ( ) const { return value ; } <nl> <nl> - friend bool operator = = ( const Name & a , const Name & b ) { return a . value = = b . value ; } <nl> + friend bool operator = = ( const name & a , const name & b ) { return a . value = = b . value ; } <nl> account_name value = 0 ; <nl> } ; <nl> <nl> mmm a / contracts / exchange / exchange . cpp <nl> ppp b / contracts / exchange / exchange . cpp <nl> void match ( bid & bid_to_match , account & buyer , ask & ask_to_match , account & selle <nl> fill_amount_currency = fill_amount_eos / ask_to_match . at_price ; <nl> } <nl> <nl> - print ( " \ n \ nmatch bid : " , Name ( bid_to_match . buyer . name ) , " : " , bid_to_match . buyer . number , <nl> - " match ask : " , Name ( ask_to_match . seller . name ) , " : " , ask_to_match . seller . number , " \ n \ n " ) ; <nl> + print ( " \ n \ nmatch bid : " , name ( bid_to_match . buyer . name ) , " : " , bid_to_match . buyer . number , <nl> + " match ask : " , name ( ask_to_match . seller . name ) , " : " , ask_to_match . seller . number , " \ n \ n " ) ; <nl> <nl> <nl> bid_to_match . quantity - = fill_amount_eos ; <nl> void apply_exchange_buy ( buy_order order ) { <nl> assert ( exchange_bid . quantity > eosio : : tokens ( 0 ) , " invalid quantity " ) ; <nl> assert ( exchange_bid . expiration > now ( ) , " order expired " ) ; <nl> <nl> - print ( Name ( exchange_bid . buyer . name ) , " created bid for " , order . quantity , " currency at price : " , order . at_price , " \ n " ) ; <nl> + print ( name ( exchange_bid . buyer . name ) , " created bid for " , order . quantity , " currency at price : " , order . at_price , " \ n " ) ; <nl> <nl> bid existing_bid ; <nl> assert ( ! bids_by_id : : get ( exchange_bid . buyer , existing_bid ) , " order with this id already exists " ) ; <nl> void apply_exchange_sell ( sell_order order ) { <nl> assert ( exchange_ask . quantity > currency_tokens ( 0 ) , " invalid quantity " ) ; <nl> assert ( exchange_ask . expiration > now ( ) , " order expired " ) ; <nl> <nl> - print ( " \ n \ n " , Name ( exchange_ask . seller . name ) , " created sell for " , order . quantity , <nl> + print ( " \ n \ n " , name ( exchange_ask . seller . name ) , " created sell for " , order . quantity , <nl> " currency at price : " , order . at_price , " \ n " ) ; <nl> <nl> ask existing_ask ; <nl> mmm a / contracts / test_api / test_types . cpp <nl> ppp b / contracts / test_api / test_types . cpp <nl> unsigned int test_types : : string_to_name ( ) { <nl> <nl> unsigned int test_types : : name_class ( ) { <nl> <nl> - WASM_ASSERT ( eosio : : Name ( eosio : : string_to_name ( " azAA34 " ) ) . value = = N ( azAA34 ) , " eosio : : Name ! = N ( azAA34 ) " ) ; <nl> - WASM_ASSERT ( eosio : : Name ( eosio : : string_to_name ( " AABBCC " ) ) . value = = 0 , " eosio : : Name ! = N ( 0 ) " ) ; <nl> - WASM_ASSERT ( eosio : : Name ( eosio : : string_to_name ( " AA11 " ) ) . value = = N ( AA11 ) , " eosio : : Name ! = N ( AA11 ) " ) ; <nl> - WASM_ASSERT ( eosio : : Name ( eosio : : string_to_name ( " 11AA " ) ) . value = = N ( 11 ) , " eosio : : Name ! = N ( 11 ) " ) ; <nl> - WASM_ASSERT ( eosio : : Name ( eosio : : string_to_name ( " 22BBCCXXAA " ) ) . value = = N ( 22 ) , " eosio : : Name ! = N ( 22 ) " ) ; <nl> - WASM_ASSERT ( eosio : : Name ( eosio : : string_to_name ( " AAAbbcccdd " ) ) = = eosio : : Name ( eosio : : string_to_name ( " AAAbbcccdd " ) ) , " eosio : : Name = = eosio : : Name " ) ; <nl> + WASM_ASSERT ( eosio : : name ( eosio : : string_to_name ( " azAA34 " ) ) . value = = N ( azAA34 ) , " eosio : : name ! = N ( azAA34 ) " ) ; <nl> + WASM_ASSERT ( eosio : : name ( eosio : : string_to_name ( " AABBCC " ) ) . value = = 0 , " eosio : : name ! = N ( 0 ) " ) ; <nl> + WASM_ASSERT ( eosio : : name ( eosio : : string_to_name ( " AA11 " ) ) . value = = N ( AA11 ) , " eosio : : name ! = N ( AA11 ) " ) ; <nl> + WASM_ASSERT ( eosio : : name ( eosio : : string_to_name ( " 11AA " ) ) . value = = N ( 11 ) , " eosio : : name ! = N ( 11 ) " ) ; <nl> + WASM_ASSERT ( eosio : : name ( eosio : : string_to_name ( " 22BBCCXXAA " ) ) . value = = N ( 22 ) , " eosio : : name ! = N ( 22 ) " ) ; <nl> + WASM_ASSERT ( eosio : : name ( eosio : : string_to_name ( " AAAbbcccdd " ) ) = = eosio : : name ( eosio : : string_to_name ( " AAAbbcccdd " ) ) , " eosio : : name = = eosio : : name " ) ; <nl> <nl> - uint64_t tmp = eosio : : Name ( eosio : : string_to_name ( " 11bbcccdd " ) ) ; <nl> + uint64_t tmp = eosio : : name ( eosio : : string_to_name ( " 11bbcccdd " ) ) ; <nl> WASM_ASSERT ( N ( 11bbcccdd ) = = tmp , " N ( 11bbcccdd ) = = tmp " ) ; <nl> <nl> return WASM_TEST_PASS ; <nl> mmm a / libraries / chain / chain_controller . cpp <nl> ppp b / libraries / chain / chain_controller . cpp <nl> namespace { <nl> } ; <nl> } <nl> <nl> - auto make_authority_checker ( const chainbase : : database & db , const flat_set < public_key_type > & signingKeys ) { <nl> + auto make_auth_checker ( const chainbase : : database & db , const flat_set < public_key_type > & signingKeys ) { <nl> auto getPermission = make_get_permission ( db ) ; <nl> auto getAuthority = [ getPermission ] ( const types : : account_permission & permission ) { <nl> return getPermission ( permission ) . auth ; <nl> } ; <nl> auto depthLimit = db . get < global_property_object > ( ) . configuration . auth_depth_limit ; <nl> - return MakeAuthorityChecker ( std : : move ( getAuthority ) , depthLimit , signingKeys ) ; <nl> + return make_authority_checker ( std : : move ( getAuthority ) , depthLimit , signingKeys ) ; <nl> } <nl> <nl> } <nl> <nl> flat_set < public_key_type > chain_controller : : get_required_keys ( const signed_transaction & trx , const flat_set < public_key_type > & candidateKeys ) const { <nl> - auto checker = make_authority_checker ( _db , candidateKeys ) ; <nl> + auto checker = make_auth_checker ( _db , candidateKeys ) ; <nl> <nl> for ( const auto & message : trx . messages ) { <nl> for ( const auto & declaredAuthority : message . authorization ) { <nl> void chain_controller : : check_transaction_authorization ( const signed_transaction & <nl> <nl> auto getPermission = make_get_permission ( _db ) ; <nl> # warning TODO : Use a real chain_id here ( where is this stored ? Do we still need it ? ) <nl> - auto checker = make_authority_checker ( _db , trx . get_signature_keys ( chain_id_type { } ) ) ; <nl> + auto checker = make_auth_checker ( _db , trx . get_signature_keys ( chain_id_type { } ) ) ; <nl> <nl> for ( const auto & message : trx . messages ) <nl> for ( const auto & declaredAuthority : message . authorization ) { <nl> mmm a / libraries / chain / include / eos / chain / authority_checker . hpp <nl> ppp b / libraries / chain / include / eos / chain / authority_checker . hpp <nl> <nl> namespace eosio { namespace chain { <nl> <nl> namespace detail { <nl> - using MetaPermission = static_variant < types : : key_permission_weight , types : : account_permission_weight > ; <nl> + using meta_permission = static_variant < types : : key_permission_weight , types : : account_permission_weight > ; <nl> <nl> - struct GetWeightVisitor { <nl> + struct get_weight_visitor { <nl> using result_type = uint32 ; <nl> <nl> template < typename Permission > <nl> struct GetWeightVisitor { <nl> } ; <nl> <nl> / / Orders permissions descending by weight , and breaks ties with Key permissions being less than Account permissions <nl> - struct MetaPermissionComparator { <nl> - bool operator ( ) ( const MetaPermission & a , const MetaPermission & b ) const { <nl> - GetWeightVisitor scale ; <nl> + struct meta_permission_comparator { <nl> + bool operator ( ) ( const meta_permission & a , const meta_permission & b ) const { <nl> + get_weight_visitor scale ; <nl> if ( a . visit ( scale ) > b . visit ( scale ) ) return true ; <nl> return a . contains < types : : key_permission_weight > ( ) & & ! b . contains < types : : key_permission_weight > ( ) ; <nl> } <nl> } ; <nl> <nl> - using MetaPermissionSet = boost : : container : : flat_multiset < MetaPermission , MetaPermissionComparator > ; <nl> + using meta_permission_set = boost : : container : : flat_multiset < meta_permission , meta_permission_comparator > ; <nl> } <nl> <nl> / * * <nl> using MetaPermissionSet = boost : : container : : flat_multiset < MetaPermission , MetaPe <nl> * then determine whether that list of keys is sufficient to satisfy the authority . This class takes a list of keys and <nl> * provides the @ ref satisfied method to determine whether that list of keys satisfies a provided authority . <nl> * <nl> - * @ tparam F A callable which takes a single argument of type @ ref AccountPermission and returns the corresponding <nl> + * @ tparam F A callable which takes a single argument of type @ ref account_permission and returns the corresponding <nl> * authority <nl> * / <nl> template < typename F > <nl> - class AuthorityChecker { <nl> + class authority_checker { <nl> F PermissionToAuthority ; <nl> uint16 recursionDepthLimit ; <nl> vector < public_key_type > signingKeys ; <nl> vector < bool > usedKeys ; <nl> <nl> - struct WeightTallyVisitor { <nl> + struct weight_tally_visitor { <nl> using result_type = uint32 ; <nl> <nl> - AuthorityChecker & checker ; <nl> + authority_checker & checker ; <nl> uint16 recursionDepth ; <nl> uint32 totalWeight = 0 ; <nl> <nl> - WeightTallyVisitor ( AuthorityChecker & checker , uint16 recursionDepth ) <nl> + weight_tally_visitor ( authority_checker & checker , uint16 recursionDepth ) <nl> : checker ( checker ) , recursionDepth ( recursionDepth ) { } <nl> <nl> uint32 operator ( ) ( const types : : key_permission_weight & permission ) { <nl> class AuthorityChecker { <nl> } ; <nl> <nl> public : <nl> - AuthorityChecker ( F PermissionToAuthority , uint16 recursionDepthLimit , const flat_set < public_key_type > & signingKeys ) <nl> + authority_checker ( F PermissionToAuthority , uint16 recursionDepthLimit , const flat_set < public_key_type > & signingKeys ) <nl> : PermissionToAuthority ( PermissionToAuthority ) , <nl> recursionDepthLimit ( recursionDepthLimit ) , <nl> signingKeys ( signingKeys . begin ( ) , signingKeys . end ( ) ) , <nl> class AuthorityChecker { <nl> } <nl> template < typename AuthorityType > <nl> bool satisfied ( const AuthorityType & authority , uint16 depth = 0 ) { <nl> - / / This check is redundant , since WeightTallyVisitor did it too , but I ' ll leave it here for future - proofing <nl> + / / This check is redundant , since weight_tally_visitor did it too , but I ' ll leave it here for future - proofing <nl> if ( depth > recursionDepthLimit ) <nl> return false ; <nl> <nl> class AuthorityChecker { <nl> } ) ; <nl> <nl> / / Sort key permissions and account permissions together into a single set of MetaPermissions <nl> - detail : : MetaPermissionSet permissions ; <nl> + detail : : meta_permission_set permissions ; <nl> permissions . insert ( authority . keys . begin ( ) , authority . keys . end ( ) ) ; <nl> permissions . insert ( authority . accounts . begin ( ) , authority . accounts . end ( ) ) ; <nl> <nl> / / Check all permissions , from highest weight to lowest , seeing if signingKeys satisfies them or not <nl> - WeightTallyVisitor visitor ( * this , depth ) ; <nl> + weight_tally_visitor visitor ( * this , depth ) ; <nl> for ( const auto & permission : permissions ) <nl> / / If we ' ve got enough weight , to satisfy the authority , return ! <nl> if ( permission . visit ( visitor ) > = authority . threshold ) { <nl> class AuthorityChecker { <nl> <nl> bool all_keys_used ( ) const { return boost : : algorithm : : all_of_equal ( usedKeys , true ) ; } <nl> flat_set < public_key_type > used_keys ( ) const { <nl> - auto range = utilities : : FilterDataByMarker ( signingKeys , usedKeys , true ) ; <nl> + auto range = utilities : : filter_data_by_marker ( signingKeys , usedKeys , true ) ; <nl> return { range . begin ( ) , range . end ( ) } ; <nl> } <nl> flat_set < public_key_type > unused_keys ( ) const { <nl> - auto range = utilities : : FilterDataByMarker ( signingKeys , usedKeys , false ) ; <nl> + auto range = utilities : : filter_data_by_marker ( signingKeys , usedKeys , false ) ; <nl> return { range . begin ( ) , range . end ( ) } ; <nl> } <nl> } ; <nl> <nl> template < typename F > <nl> - AuthorityChecker < F > MakeAuthorityChecker ( F & & pta , uint16 recursionDepthLimit , <nl> - const flat_set < public_key_type > & signingKeys ) { <nl> - return AuthorityChecker < F > ( std : : forward < F > ( pta ) , recursionDepthLimit , signingKeys ) ; <nl> + authority_checker < F > make_authority_checker ( F & & pta , uint16 recursionDepthLimit , <nl> + const flat_set < public_key_type > & signingKeys ) { <nl> + return authority_checker < F > ( std : : forward < F > ( pta ) , recursionDepthLimit , signingKeys ) ; <nl> } <nl> <nl> } } / / namespace eosio : : chain <nl> mmm a / libraries / chain / message_handling_contexts . cpp <nl> ppp b / libraries / chain / message_handling_contexts . cpp <nl> bool apply_context : : all_authorizations_used ( ) const { <nl> } <nl> <nl> vector < types : : account_permission > apply_context : : unused_authorizations ( ) const { <nl> - auto range = utilities : : FilterDataByMarker ( msg . authorization , used_authorizations , false ) ; <nl> + auto range = utilities : : filter_data_by_marker ( msg . authorization , used_authorizations , false ) ; <nl> return { range . begin ( ) , range . end ( ) } ; <nl> } <nl> <nl> mmm a / libraries / native_contract / eos_contract . cpp <nl> ppp b / libraries / native_contract / eos_contract . cpp <nl> void apply_eos_newaccount ( apply_context & context ) { <nl> } ) ; <nl> } <nl> <nl> - const auto & creatorBalance = context . mutable_db . get < BalanceObject , byOwnerName > ( create . creator ) ; <nl> + const auto & creatorBalance = context . mutable_db . get < balance_object , by_owner_name > ( create . creator ) ; <nl> <nl> EOS_ASSERT ( creatorBalance . balance > = create . deposit . amount , message_validate_exception , <nl> " Creator ' $ { c } ' has insufficient funds to make account creation deposit of $ { a } " , <nl> ( " c " , create . creator ) ( " a " , create . deposit ) ) ; <nl> <nl> - context . mutable_db . modify ( creatorBalance , [ & create ] ( BalanceObject & b ) { <nl> + context . mutable_db . modify ( creatorBalance , [ & create ] ( balance_object & b ) { <nl> b . balance - = create . deposit . amount ; <nl> } ) ; <nl> <nl> - context . mutable_db . create < BalanceObject > ( [ & create ] ( BalanceObject & b ) { <nl> - b . ownerName = create . name ; <nl> + context . mutable_db . create < balance_object > ( [ & create ] ( balance_object & b ) { <nl> + b . owner_name = create . name ; <nl> b . balance = 0 ; / / create . deposit . amount ; TODO : make sure we credit this in @ staked <nl> } ) ; <nl> <nl> - context . mutable_db . create < StakedBalanceObject > ( [ & create ] ( StakedBalanceObject & sbo ) { <nl> + context . mutable_db . create < staked_balance_object > ( [ & create ] ( staked_balance_object & sbo ) { <nl> sbo . ownerName = create . name ; <nl> - sbo . stakedBalance = create . deposit . amount ; <nl> + sbo . staked_balance = create . deposit . amount ; <nl> } ) ; <nl> } <nl> <nl> void apply_eos_transfer ( apply_context & context ) { <nl> <nl> try { <nl> auto & db = context . mutable_db ; <nl> - const auto & from = db . get < BalanceObject , byOwnerName > ( transfer . from ) ; <nl> + const auto & from = db . get < balance_object , by_owner_name > ( transfer . from ) ; <nl> <nl> EOS_ASSERT ( from . balance > = transfer . amount , message_precondition_exception , " Insufficient Funds " , <nl> ( " from . balance " , from . balance ) ( " transfer . amount " , transfer . amount ) ) ; <nl> <nl> - const auto & to = db . get < BalanceObject , byOwnerName > ( transfer . to ) ; <nl> - db . modify ( from , [ & ] ( BalanceObject & a ) { <nl> + const auto & to = db . get < balance_object , by_owner_name > ( transfer . to ) ; <nl> + db . modify ( from , [ & ] ( balance_object & a ) { <nl> a . balance - = share_type ( transfer . amount ) ; <nl> } ) ; <nl> - db . modify ( to , [ & ] ( BalanceObject & a ) { <nl> + db . modify ( to , [ & ] ( balance_object & a ) { <nl> a . balance + = share_type ( transfer . amount ) ; <nl> } ) ; <nl> } FC_CAPTURE_AND_RETHROW ( ( transfer ) ) <nl> void apply_eos_lock ( apply_context & context ) { <nl> context . require_recipient ( lock . to ) ; <nl> context . require_recipient ( lock . from ) ; <nl> <nl> - const auto & locker = context . db . get < BalanceObject , byOwnerName > ( lock . from ) ; <nl> + const auto & locker = context . db . get < balance_object , by_owner_name > ( lock . from ) ; <nl> <nl> EOS_ASSERT ( locker . balance > = lock . amount , message_precondition_exception , <nl> " Account $ { a } lacks sufficient funds to lock $ { amt } EOS " , ( " a " , lock . from ) ( " amt " , lock . amount ) ( " available " , locker . balance ) ) ; <nl> <nl> - context . mutable_db . modify ( locker , [ & lock ] ( BalanceObject & a ) { <nl> + context . mutable_db . modify ( locker , [ & lock ] ( balance_object & a ) { <nl> a . balance - = lock . amount ; <nl> } ) ; <nl> <nl> - const auto & balance = context . db . get < StakedBalanceObject , byOwnerName > ( lock . to ) ; <nl> - balance . stakeTokens ( lock . amount , context . mutable_db ) ; <nl> + const auto & balance = context . db . get < staked_balance_object , by_owner_name > ( lock . to ) ; <nl> + balance . stake_tokens ( lock . amount , context . mutable_db ) ; <nl> } <nl> <nl> void apply_eos_unlock ( apply_context & context ) { <nl> void apply_eos_unlock ( apply_context & context ) { <nl> <nl> EOS_ASSERT ( unlock . amount > = 0 , message_validate_exception , " Unlock amount cannot be negative " ) ; <nl> <nl> - const auto & balance = context . db . get < StakedBalanceObject , byOwnerName > ( unlock . account ) ; <nl> + const auto & balance = context . db . get < staked_balance_object , by_owner_name > ( unlock . account ) ; <nl> <nl> - EOS_ASSERT ( balance . stakedBalance > = unlock . amount , message_precondition_exception , <nl> + EOS_ASSERT ( balance . staked_balance > = unlock . amount , message_precondition_exception , <nl> " Insufficient locked funds to unlock $ { a } " , ( " a " , unlock . amount ) ) ; <nl> <nl> - balance . beginUnstakingTokens ( unlock . amount , context . mutable_db ) ; <nl> + balance . begin_unstaking_tokens ( unlock . amount , context . mutable_db ) ; <nl> } <nl> <nl> <nl> void apply_eos_setcode ( apply_context & context ) { <nl> <nl> context . require_authorization ( msg . account ) ; <nl> <nl> - FC_ASSERT ( msg . vmtype = = 0 ) ; <nl> - FC_ASSERT ( msg . vmversion = = 0 ) ; <nl> + FC_ASSERT ( msg . vm_type = = 0 ) ; <nl> + FC_ASSERT ( msg . vm_version = = 0 ) ; <nl> <nl> / / / if an ABI is specified make sure it is well formed and doesn ' t <nl> / / / reference any undefined types <nl> void apply_eos_claim ( apply_context & context ) { <nl> <nl> context . require_authorization ( claim . account ) ; <nl> <nl> - auto balance = context . db . find < StakedBalanceObject , byOwnerName > ( claim . account ) ; <nl> + auto balance = context . db . find < staked_balance_object , by_owner_name > ( claim . account ) ; <nl> EOS_ASSERT ( balance ! = nullptr , message_precondition_exception , <nl> " Could not find staked balance for $ { name } " , ( " name " , claim . account ) ) ; <nl> - auto balanceReleaseTime = balance - > lastUnstakingTime + config : : staked_balance_cooldown_seconds ; <nl> + auto balanceReleaseTime = balance - > last_unstaking_time + config : : staked_balance_cooldown_seconds ; <nl> auto now = context . controller . head_block_time ( ) ; <nl> EOS_ASSERT ( now > = balanceReleaseTime , message_precondition_exception , <nl> " Cannot claim balance until $ { releaseDate } " , ( " releaseDate " , balanceReleaseTime ) ) ; <nl> - EOS_ASSERT ( balance - > unstakingBalance > = claim . amount , message_precondition_exception , <nl> + EOS_ASSERT ( balance - > unstaking_balance > = claim . amount , message_precondition_exception , <nl> " Cannot claim $ { claimAmount } as only $ { available } is available for claim " , <nl> - ( " claimAmount " , claim . amount ) ( " available " , balance - > unstakingBalance ) ) ; <nl> + ( " claimAmount " , claim . amount ) ( " available " , balance - > unstaking_balance ) ) ; <nl> <nl> - const auto & stakedBalance = context . db . get < StakedBalanceObject , byOwnerName > ( claim . account ) ; <nl> - stakedBalance . finishUnstakingTokens ( claim . amount , context . mutable_db ) ; <nl> + const auto & stakedBalance = context . db . get < staked_balance_object , by_owner_name > ( claim . account ) ; <nl> + stakedBalance . finish_unstaking_tokens ( claim . amount , context . mutable_db ) ; <nl> <nl> - const auto & liquidBalance = context . db . get < BalanceObject , byOwnerName > ( claim . account ) ; <nl> - context . mutable_db . modify ( liquidBalance , [ & claim ] ( BalanceObject & a ) { <nl> + const auto & liquidBalance = context . db . get < balance_object , by_owner_name > ( claim . account ) ; <nl> + context . mutable_db . modify ( liquidBalance , [ & claim ] ( balance_object & a ) { <nl> a . balance + = claim . amount ; <nl> } ) ; <nl> } <nl> void apply_eos_setproducer ( apply_context & context ) { <nl> p . signing_key = update . key ; <nl> p . configuration = update . configuration ; <nl> } ) ; <nl> - auto raceTime = ProducerScheduleObject : : get ( db ) . currentRaceTime ; <nl> - db . create < ProducerVotesObject > ( [ & ] ( ProducerVotesObject & pvo ) { <nl> + auto raceTime = producer_schedule_object : : get ( db ) . currentRaceTime ; <nl> + db . create < producer_votes_object > ( [ & ] ( producer_votes_object & pvo ) { <nl> pvo . ownerName = update . name ; <nl> - pvo . startNewRaceLap ( raceTime ) ; <nl> + pvo . start_new_race_lap ( raceTime ) ; <nl> } ) ; <nl> } <nl> } <nl> void apply_eos_okproducer ( apply_context & context ) { <nl> <nl> <nl> auto & db = context . mutable_db ; <nl> - const auto & producer = db . get < ProducerVotesObject , byOwnerName > ( approve . producer ) ; <nl> - const auto & voter = db . get < StakedBalanceObject , byOwnerName > ( approve . voter ) ; <nl> + const auto & producer = db . get < producer_votes_object , by_owner_name > ( approve . producer ) ; <nl> + const auto & voter = db . get < staked_balance_object , by_owner_name > ( approve . voter ) ; <nl> <nl> <nl> - EOS_ASSERT ( voter . producerVotes . contains < ProducerSlate > ( ) , message_precondition_exception , <nl> + EOS_ASSERT ( voter . producer_votes . contains < producer_slate > ( ) , message_precondition_exception , <nl> " Cannot approve producer ; approving account ' $ { name } ' proxies its votes to ' $ { proxy } ' " , <nl> - ( " name " , voter . ownerName ) ( " proxy " , voter . producerVotes . get < account_name > ( ) ) ) ; <nl> + ( " name " , voter . ownerName ) ( " proxy " , voter . producer_votes . get < account_name > ( ) ) ) ; <nl> <nl> <nl> - const auto & slate = voter . producerVotes . get < ProducerSlate > ( ) ; <nl> + const auto & slate = voter . producer_votes . get < producer_slate > ( ) ; <nl> <nl> EOS_ASSERT ( slate . size < config : : max_producer_votes , message_precondition_exception , <nl> " Cannot approve producer ; approved producer count is already at maximum " ) ; <nl> void apply_eos_okproducer ( apply_context & context ) { <nl> ( " name " , producer . ownerName ) ) ; <nl> <nl> <nl> - auto raceTime = ProducerScheduleObject : : get ( db ) . currentRaceTime ; <nl> - auto totalVotingStake = voter . stakedBalance ; <nl> + auto raceTime = producer_schedule_object : : get ( db ) . currentRaceTime ; <nl> + auto totalVotingStake = voter . staked_balance ; <nl> <nl> / / Check if voter is proxied to ; if so , we need to add in the proxied stake <nl> - if ( auto proxy = db . find < ProxyVoteObject , byTargetName > ( voter . ownerName ) ) <nl> - totalVotingStake + = proxy - > proxiedStake ; <nl> + if ( auto proxy = db . find < proxy_vote_object , by_target_name > ( voter . ownerName ) ) <nl> + totalVotingStake + = proxy - > proxied_stake ; <nl> <nl> / / Add / remove votes from producer <nl> - db . modify ( producer , [ approve = approve . approve , totalVotingStake , & raceTime ] ( ProducerVotesObject & pvo ) { <nl> + db . modify ( producer , [ approve = approve . approve , totalVotingStake , & raceTime ] ( producer_votes_object & pvo ) { <nl> if ( approve ) <nl> - pvo . updateVotes ( totalVotingStake , raceTime ) ; <nl> + pvo . update_votes ( totalVotingStake , raceTime ) ; <nl> else <nl> - pvo . updateVotes ( - totalVotingStake , raceTime ) ; <nl> + pvo . update_votes ( - totalVotingStake , raceTime ) ; <nl> } ) ; <nl> / / Add / remove producer from voter ' s approved producer list <nl> - db . modify ( voter , [ & approve , producer = producer . ownerName ] ( StakedBalanceObject & sbo ) { <nl> - auto & slate = sbo . producerVotes . get < ProducerSlate > ( ) ; <nl> + db . modify ( voter , [ & approve , producer = producer . ownerName ] ( staked_balance_object & sbo ) { <nl> + auto & slate = sbo . producer_votes . get < producer_slate > ( ) ; <nl> if ( approve . approve ) <nl> slate . add ( producer ) ; <nl> else <nl> void apply_eos_setproxy ( apply_context & context ) { <nl> context . require_recipient ( svp . proxy ) ; <nl> <nl> auto & db = context . mutable_db ; <nl> - const auto & proxy = db . get < ProxyVoteObject , byTargetName > ( context . msg . recipient ( svp . proxy ) ) ; <nl> - const auto & balance = db . get < StakedBalanceObject , byOwnerName > ( context . msg . recipient ( svp . stakeholder ) ) ; <nl> + const auto & proxy = db . get < proxy_vote_object , by_target_name > ( context . msg . recipient ( svp . proxy ) ) ; <nl> + const auto & balance = db . get < staked_balance_object , by_owner_name > ( context . msg . recipient ( svp . stakeholder ) ) ; <nl> <nl> <nl> - auto proxy = db . find < ProxyVoteObject , byTargetName > ( context . msg . recipient ( svp . proxy ) ) ; <nl> + auto proxy = db . find < proxy_vote_object , by_target_name > ( context . msg . recipient ( svp . proxy ) ) ; <nl> <nl> <nl> if ( svp . proxy ! = svp . stakeholder ) { <nl> / / We are enabling proxying to svp . proxy <nl> - proxy . addProxySource ( context . msg . recipient ( svp . stakeholder ) , balance . stakedBalance , db ) ; <nl> - db . modify ( balance , [ target = proxy . proxyTarget ] ( StakedBalanceObject & sbo ) { sbo . producerVotes = target ; } ) ; <nl> + proxy . add_proxy_source ( context . msg . recipient ( svp . stakeholder ) , balance . staked_balance , db ) ; <nl> + db . modify ( balance , [ target = proxy . proxy_target ] ( staked_balance_object & sbo ) { sbo . producer_votes = target ; } ) ; <nl> } else { <nl> - / / We are disabling proxying to balance . producerVotes . get < account_name > ( ) <nl> - proxy . removeProxySource ( context . msg . recipient ( svp . stakeholder ) , balance . stakedBalance , db ) ; <nl> - db . modify ( balance , [ ] ( StakedBalanceObject & sbo ) { sbo . producerVotes = ProducerSlate { } ; } ) ; <nl> + / / We are disabling proxying to balance . producer_votes . get < account_name > ( ) <nl> + proxy . removeProxySource ( context . msg . recipient ( svp . stakeholder ) , balance . staked_balance , db ) ; <nl> + db . modify ( balance , [ ] ( staked_balance_object & sbo ) { sbo . producer_votes = producer_slate { } ; } ) ; <nl> } <nl> * / <nl> } <nl> mmm a / libraries / native_contract / include / eos / native_contract / balance_object . hpp <nl> ppp b / libraries / native_contract / include / eos / native_contract / balance_object . hpp <nl> namespace types = : : eosio : : types ; <nl> namespace config = : : eosio : : config ; <nl> <nl> / * * <nl> - * @ brief The BalanceObject class tracks the EOS balance for accounts <nl> + * @ brief The balance_object class tracks the EOS balance for accounts <nl> * / <nl> - class BalanceObject : public chainbase : : object < chain : : balance_object_type , BalanceObject > { <nl> - OBJECT_CTOR ( BalanceObject ) <nl> + class balance_object : public chainbase : : object < chain : : balance_object_type , balance_object > { <nl> + OBJECT_CTOR ( balance_object ) <nl> <nl> id_type id ; <nl> - types : : account_name ownerName ; <nl> + types : : account_name owner_name ; <nl> types : : share_type balance = 0 ; <nl> } ; <nl> <nl> - struct byOwnerName ; <nl> + struct by_owner_name ; <nl> <nl> - using BalanceMultiIndex = chainbase : : shared_multi_index_container < <nl> - BalanceObject , <nl> + using balance_multi_index = chainbase : : shared_multi_index_container < <nl> + balance_object , <nl> indexed_by < <nl> ordered_unique < tag < by_id > , <nl> - member < BalanceObject , BalanceObject : : id_type , & BalanceObject : : id > <nl> + member < balance_object , balance_object : : id_type , & balance_object : : id > <nl> > , <nl> - ordered_unique < tag < byOwnerName > , <nl> - member < BalanceObject , types : : account_name , & BalanceObject : : ownerName > <nl> + ordered_unique < tag < by_owner_name > , <nl> + member < balance_object , types : : account_name , & balance_object : : owner_name > <nl> > <nl> > <nl> > ; <nl> <nl> - } } / / namespace native : : eos <nl> + } } / / namespace native : : eosio <nl> <nl> - CHAINBASE_SET_INDEX_TYPE ( native : : eosio : : BalanceObject , native : : eosio : : BalanceMultiIndex ) <nl> + CHAINBASE_SET_INDEX_TYPE ( native : : eosio : : balance_object , native : : eosio : : balance_multi_index ) <nl> mmm a / libraries / native_contract / include / eos / native_contract / producer_objects . hpp <nl> ppp b / libraries / native_contract / include / eos / native_contract / producer_objects . hpp <nl> namespace config = : : eosio : : config ; <nl> namespace chain = : : eosio : : chain ; <nl> namespace types = : : eosio : : types ; <nl> <nl> - FC_DECLARE_EXCEPTION ( ProducerRaceOverflowException , 10000000 , " Producer Virtual Race time has overflowed " ) ; <nl> + FC_DECLARE_EXCEPTION ( producer_race_overflow_exception , 10000000 , " Producer Virtual Race time has overflowed " ) ; <nl> <nl> / * * <nl> - * @ brief The ProducerVotesObject class tracks all votes for and by the block producers <nl> + * @ brief The producer_votes_object class tracks all votes for and by the block producers <nl> * <nl> * This class tracks the voting for block producers , as well as the virtual time ' race ' to select the runner - up block <nl> * producer . <nl> * <nl> * This class also tracks the votes cast by block producers on various chain configuration options and key documents . <nl> * / <nl> - class ProducerVotesObject : public chainbase : : object < chain : : producer_votes_object_type , ProducerVotesObject > { <nl> - OBJECT_CTOR ( ProducerVotesObject ) <nl> + class producer_votes_object : public chainbase : : object < chain : : producer_votes_object_type , producer_votes_object > { <nl> + OBJECT_CTOR ( producer_votes_object ) <nl> <nl> id_type id ; <nl> types : : account_name ownerName ; <nl> class ProducerVotesObject : public chainbase : : object < chain : : producer_votes_objec <nl> * This function will update the producer ' s position in the race <nl> * <nl> * @ param deltaVotes The change in votes since the last update <nl> - * @ param currentRaceTime The current " race time " <nl> + * @ param current_race_time The current " race time " <nl> * / <nl> - void updateVotes ( types : : share_type deltaVotes , types : : uint128 currentRaceTime ) ; <nl> + void update_votes ( types : : share_type deltaVotes , types : : uint128 current_race_time ) ; <nl> / / / @ brief Get the number of votes this producer has received <nl> - types : : share_type getVotes ( ) const { return race . speed ; } <nl> - pair < types : : share_type , id_type > getVoteOrder ( ) const { return { race . speed , id } ; } <nl> + types : : share_type get_votes ( ) const { return race . speed ; } <nl> + pair < types : : share_type , id_type > get_vote_order ( ) const { return { race . speed , id } ; } <nl> <nl> / * * <nl> * These fields are used for the producer scheduling algorithm which uses a virtual race to ensure that runner - up <nl> * producers are given proportional time for producing blocks . Producers are constantly running a racetrack of <nl> - * length config : : ProducerRaceLapLength , at a speed equal to the number of votes they have received . Runner - up <nl> + * length config : : producer_race_lap_length , at a speed equal to the number of votes they have received . Runner - up <nl> * producers , who lack sufficient votes to get in as a top - N voted producer , get scheduled to produce a block every <nl> * time they finish the race . The race algorithm ensures that runner - up producers are scheduled with a frequency <nl> * proportional to their relative vote tallies ; i . e . a runner - up with more votes is scheduled more often than one <nl> class ProducerVotesObject : public chainbase : : object < chain : : producer_votes_objec <nl> * projected finishing time based on his new position and speed are updated so we know where he shakes out in the <nl> * new projected finish times . <nl> * <nl> - * @ warning Do not update these values directly ; use @ ref updateVotes instead ! <nl> + * @ warning Do not update these values directly ; use @ ref update_votes instead ! <nl> * / <nl> struct { <nl> / / / The current speed for this producer ( which is actually the total votes for the producer ) <nl> class ProducerVotesObject : public chainbase : : object < chain : : producer_votes_objec <nl> / / / The position of this producer when we last updated the records <nl> types : : uint128 position = 0 ; <nl> / / / The " race time " when we last updated the records <nl> - types : : uint128 positionUpdateTime = 0 ; <nl> + types : : uint128 position_update_time = 0 ; <nl> / / / The projected " race time " at which this producer will finish the race <nl> - types : : uint128 projectedFinishTime = std : : numeric_limits < types : : uint128 > : : max ( ) ; <nl> + types : : uint128 projected_finish_time = std : : numeric_limits < types : : uint128 > : : max ( ) ; <nl> <nl> / / / Set all fields on race , given the current speed , position , and time <nl> - void update ( types : : share_type currentSpeed , types : : uint128 currentPosition , types : : uint128 currentRaceTime ) { <nl> + void update ( types : : share_type currentSpeed , types : : uint128 current_position , types : : uint128 current_race_time ) { <nl> speed = currentSpeed ; <nl> - position = currentPosition ; <nl> - positionUpdateTime = currentRaceTime ; <nl> - auto distanceRemaining = config : : producer_race_lap_length - position ; <nl> - auto projectedTimeToFinish = speed > 0 ? distanceRemaining / speed <nl> + position = current_position ; <nl> + position_update_time = current_race_time ; <nl> + auto distance_remaining = config : : producer_race_lap_length - position ; <nl> + auto projected_time_to_finish = speed > 0 ? distance_remaining / speed <nl> : std : : numeric_limits < types : : uint128 > : : max ( ) ; <nl> - EOS_ASSERT ( currentRaceTime < = std : : numeric_limits < types : : uint128 > : : max ( ) - projectedTimeToFinish , <nl> - ProducerRaceOverflowException , " Producer race time has overflowed " , <nl> - ( " currentTime " , currentRaceTime ) ( " timeToFinish " , projectedTimeToFinish ) ( " limit " , std : : numeric_limits < types : : uint128 > : : max ( ) ) ) ; <nl> - projectedFinishTime = currentRaceTime + projectedTimeToFinish ; <nl> + EOS_ASSERT ( current_race_time < = std : : numeric_limits < types : : uint128 > : : max ( ) - projected_time_to_finish , <nl> + producer_race_overflow_exception , " Producer race time has overflowed " , <nl> + ( " currentTime " , current_race_time ) ( " timeToFinish " , projected_time_to_finish ) ( " limit " , std : : numeric_limits < types : : uint128 > : : max ( ) ) ) ; <nl> + projected_finish_time = current_race_time + projected_time_to_finish ; <nl> } <nl> } race ; <nl> <nl> - void startNewRaceLap ( types : : uint128 currentRaceTime ) { race . update ( race . speed , 0 , currentRaceTime ) ; } <nl> - types : : uint128 projectedRaceFinishTime ( ) const { return race . projectedFinishTime ; } <nl> + void start_new_race_lap ( types : : uint128 current_race_time ) { race . update ( race . speed , 0 , current_race_time ) ; } <nl> + types : : uint128 projected_race_finish_time ( ) const { return race . projected_finish_time ; } <nl> <nl> typedef std : : pair < types : : uint128 , id_type > rft_order_type ; <nl> - rft_order_type projectedRaceFinishTimeOrder ( ) const { return { race . projectedFinishTime , id } ; } <nl> + rft_order_type projected_race_finish_time_order ( ) const { return { race . projected_finish_time , id } ; } <nl> } ; <nl> <nl> / * * <nl> - * @ brief The ProxyVoteObject tracks proxied votes <nl> + * @ brief The proxy_vote_object tracks proxied votes <nl> * <nl> * This object is created when an account indicates that it wishes to allow other accounts to proxy their votes to it , <nl> * so that the proxying accounts add their stake to the proxy target ' s votes . <nl> * <nl> - * When an account S proxies its votes to an account P , we look up the @ ref ProxyVoteObject with @ ref proxyTarget P , <nl> - * and add S to the @ ref proxySources , and add S ' s stake to @ proxiedStake . We then update @ ref proxyTarget ' s votes , to <nl> - * account for the change in its voting weight . Any time S ' s stake changes , we update the @ ref proxiedStake accordingly . <nl> + * When an account S proxies its votes to an account P , we look up the @ ref proxy_vote_object with @ ref proxy_target P , <nl> + * and add S to the @ ref proxy_sources , and add S ' s stake to @ proxied_stake . We then update @ ref proxy_target ' s votes , to <nl> + * account for the change in its voting weight . Any time S ' s stake changes , we update the @ ref proxied_stake accordingly . <nl> * If S terminates its vote delegation to P , we remove S and its stake from @ ref proxySources and @ ref proxiedStake , <nl> - * then update @ ref proxyTarget ' s votes . If P stops accepting proxied votes , then its @ ref ProxyVoteObject is removed <nl> - * and all accounts listed in @ ref proxySources revert back to an unproxied voting state . <nl> + * then update @ ref proxy_target ' s votes . If P stops accepting proxied votes , then its @ ref proxy_vote_object is removed <nl> + * and all accounts listed in @ ref proxy_sources revert back to an unproxied voting state . <nl> * <nl> * Whenever any account A changes its votes , we check if there is some @ ref ProxyVoteObject for which A is the target , <nl> * and if so , we add the @ ref proxiedStake to its voting weight . <nl> class ProducerVotesObject : public chainbase : : object < chain : : producer_votes_objec <nl> * An account A may only proxy to one account at a time , and if A has proxied its votes to some other account , A may <nl> * not cast any other votes until it unproxies its voting power . <nl> * / <nl> - class ProxyVoteObject : public chainbase : : object < chain : : proxy_vote_object_type , ProxyVoteObject > { <nl> - OBJECT_CTOR ( ProxyVoteObject , ( proxySources ) ) <nl> + class proxy_vote_object : public chainbase : : object < chain : : proxy_vote_object_type , proxy_vote_object > { <nl> + OBJECT_CTOR ( proxy_vote_object , ( proxy_sources ) ) <nl> <nl> id_type id ; <nl> / / / The account receiving the proxied voting power <nl> - types : : account_name proxyTarget ; <nl> - / / / The list of accounts proxying their voting power to @ ref proxyTarget <nl> - chain : : shared_set < types : : account_name > proxySources ; <nl> - / / / The total stake proxied to @ ref proxyTarget . At all times , this should be equal to the sum of stake over all <nl> - / / / accounts in @ ref proxySources <nl> - types : : share_type proxiedStake = 0 ; <nl> + types : : account_name proxy_target ; <nl> + / / / The list of accounts proxying their voting power to @ ref proxy_target <nl> + chain : : shared_set < types : : account_name > proxy_sources ; <nl> + / / / The total stake proxied to @ ref proxy_target . At all times , this should be equal to the sum of stake over all <nl> + / / / accounts in @ ref proxy_sources <nl> + types : : share_type proxied_stake = 0 ; <nl> <nl> - void addProxySource ( const types : : account_name & source , chain : : share_type sourceStake , chainbase : : database & db ) const ; <nl> - void removeProxySource ( const types : : account_name & source , chain : : share_type sourceStake , <nl> + void add_proxy_source ( const types : : account_name & source , chain : : share_type source_stake , chainbase : : database & db ) const ; <nl> + void removeProxySource ( const types : : account_name & source , chain : : share_type source_stake , <nl> chainbase : : database & db ) const ; <nl> - void updateProxiedStake ( chain : : share_type stakeDelta , chainbase : : database & db ) const ; <nl> + void update_proxied_stake ( chain : : share_type stake_delta , chainbase : : database & db ) const ; <nl> <nl> / / / Cancel proxying votes to @ ref proxyTarget for all @ ref proxySources <nl> - void cancelProxies ( chainbase : : database & db ) const ; <nl> + void cancel_proxies ( chainbase : : database & db ) const ; <nl> } ; <nl> <nl> / * * <nl> - * @ brief The ProducerScheduleObject class schedules producers into rounds <nl> + * @ brief The producer_schedule_object class schedules producers into rounds <nl> * <nl> * This class stores the state of the virtual race to select runner - up producers , and provides the logic for selecting <nl> * a round of producers . <nl> * <nl> * This is a singleton object within the database ; there will only be one stored . <nl> * / <nl> - class ProducerScheduleObject : public chainbase : : object < chain : : producer_schedule_object_type , ProducerScheduleObject > { <nl> - OBJECT_CTOR ( ProducerScheduleObject ) <nl> + class producer_schedule_object : public chainbase : : object < chain : : producer_schedule_object_type , producer_schedule_object > { <nl> + OBJECT_CTOR ( producer_schedule_object ) <nl> <nl> id_type id ; <nl> types : : uint128 currentRaceTime = 0 ; <nl> <nl> - / / / Retrieve a reference to the ProducerScheduleObject stored in the provided database <nl> - static const ProducerScheduleObject & get ( const chainbase : : database & db ) { return db . get ( id_type ( ) ) ; } <nl> + / / / Retrieve a reference to the producer_schedule_object stored in the provided database <nl> + static const producer_schedule_object & get ( const chainbase : : database & db ) { return db . get ( id_type ( ) ) ; } <nl> <nl> / * * <nl> * @ brief Calculate the next round of block producers <nl> class ProducerScheduleObject : public chainbase : : object < chain : : producer_schedule <nl> * producers . Although it is a const method , it will use its non - const db parameter to update its own records , as <nl> * well as the race records stored in the @ ref ProducerVotesObjects <nl> * / <nl> - chain : : producer_round calculateNextRound ( chainbase : : database & db ) const ; <nl> + chain : : producer_round calculate_next_round ( chainbase : : database & db ) const ; <nl> <nl> / * * <nl> * @ brief Reset all producers in the virtual race to the starting line , and reset virtual time to zero <nl> * / <nl> - void resetProducerRace ( chainbase : : database & db ) const ; <nl> + void reset_producer_race ( chainbase : : database & db ) const ; <nl> } ; <nl> <nl> using boost : : multi_index : : const_mem_fun ; <nl> / / / Index producers by their owner ' s name <nl> - struct byOwnerName ; <nl> + struct by_owner_name ; <nl> / / / Index producers by projected race finishing time , from soonest to latest <nl> - struct byProjectedRaceFinishTime ; <nl> + struct by_projected_race_finish_time ; <nl> / / / Index producers by votes , from greatest to least <nl> - struct byVotes ; <nl> + struct by_votes ; <nl> <nl> - using ProducerVotesMultiIndex = chainbase : : shared_multi_index_container < <nl> - ProducerVotesObject , <nl> + using producer_votes_multi_index = chainbase : : shared_multi_index_container < <nl> + producer_votes_object , <nl> indexed_by < <nl> ordered_unique < tag < by_id > , <nl> - member < ProducerVotesObject , ProducerVotesObject : : id_type , & ProducerVotesObject : : id > <nl> + member < producer_votes_object , producer_votes_object : : id_type , & producer_votes_object : : id > <nl> > , <nl> - ordered_unique < tag < byOwnerName > , <nl> - member < ProducerVotesObject , types : : account_name , & ProducerVotesObject : : ownerName > <nl> + ordered_unique < tag < by_owner_name > , <nl> + member < producer_votes_object , types : : account_name , & producer_votes_object : : ownerName > <nl> > , <nl> - ordered_non_unique < tag < byVotes > , <nl> - const_mem_fun < ProducerVotesObject , std : : pair < types : : share_type , ProducerVotesObject : : id_type > , & ProducerVotesObject : : getVoteOrder > , <nl> - std : : greater < std : : pair < types : : share_type , ProducerVotesObject : : id_type > > <nl> + ordered_non_unique < tag < by_votes > , <nl> + const_mem_fun < producer_votes_object , std : : pair < types : : share_type , producer_votes_object : : id_type > , & producer_votes_object : : get_vote_order > , <nl> + std : : greater < std : : pair < types : : share_type , producer_votes_object : : id_type > > <nl> > , <nl> - ordered_unique < tag < byProjectedRaceFinishTime > , <nl> - const_mem_fun < ProducerVotesObject , ProducerVotesObject : : rft_order_type , & ProducerVotesObject : : projectedRaceFinishTimeOrder > <nl> + ordered_unique < tag < by_projected_race_finish_time > , <nl> + const_mem_fun < producer_votes_object , producer_votes_object : : rft_order_type , & producer_votes_object : : projected_race_finish_time_order > <nl> > <nl> / * <nl> For some reason this does not compile , so I simulate it by adding a new method <nl> - ordered_unique < tag < byVotes > , <nl> + ordered_unique < tag < by_votes > , <nl> composite_key < <nl> - const_mem_fun < ProducerVotesObject , types : : share_type , & ProducerVotesObject : : getVotes > , <nl> - member < ProducerVotesObject , ProducerVotesObject : : id_type , & ProducerVotesObject : : id > <nl> + const_mem_fun < producer_votes_object , types : : share_type , & producer_votes_object : : get_votes > , <nl> + member < producer_votes_object , producer_votes_object : : id_type , & producer_votes_object : : id > <nl> > , <nl> - composite_key_compare < std : : greater < types : : share_type > , std : : less < ProducerVotesObject : : id_type > > <nl> + composite_key_compare < std : : greater < types : : share_type > , std : : less < producer_votes_object : : id_type > > <nl> > * / / * , <nl> * / <nl> > <nl> > ; <nl> <nl> / / / Index proxies by the proxy target account name <nl> - struct byTargetName ; <nl> + struct by_target_name ; <nl> <nl> - using ProxyVoteMultiIndex = chainbase : : shared_multi_index_container < <nl> - ProxyVoteObject , <nl> + using proxy_vote_multi_index = chainbase : : shared_multi_index_container < <nl> + proxy_vote_object , <nl> indexed_by < <nl> - ordered_unique < tag < by_id > , member < ProxyVoteObject , ProxyVoteObject : : id_type , & ProxyVoteObject : : id > > , <nl> - ordered_unique < tag < byTargetName > , member < ProxyVoteObject , types : : account_name , & ProxyVoteObject : : proxyTarget > > <nl> + ordered_unique < tag < by_id > , member < proxy_vote_object , proxy_vote_object : : id_type , & proxy_vote_object : : id > > , <nl> + ordered_unique < tag < by_target_name > , member < proxy_vote_object , types : : account_name , & proxy_vote_object : : proxy_target > > <nl> > <nl> > ; <nl> <nl> - using ProducerScheduleMultiIndex = chainbase : : shared_multi_index_container < <nl> - ProducerScheduleObject , <nl> + using producer_schedule_multi_index = chainbase : : shared_multi_index_container < <nl> + producer_schedule_object , <nl> indexed_by < <nl> ordered_unique < tag < by_id > , <nl> - member < ProducerScheduleObject , ProducerScheduleObject : : id_type , & ProducerScheduleObject : : id > <nl> + member < producer_schedule_object , producer_schedule_object : : id_type , & producer_schedule_object : : id > <nl> > <nl> > <nl> > ; <nl> <nl> } } / / namespace native : : eos <nl> <nl> - CHAINBASE_SET_INDEX_TYPE ( native : : eosio : : ProducerVotesObject , native : : eosio : : ProducerVotesMultiIndex ) <nl> - CHAINBASE_SET_INDEX_TYPE ( native : : eosio : : ProxyVoteObject , native : : eosio : : ProxyVoteMultiIndex ) <nl> - CHAINBASE_SET_INDEX_TYPE ( native : : eosio : : ProducerScheduleObject , native : : eosio : : ProducerScheduleMultiIndex ) <nl> + CHAINBASE_SET_INDEX_TYPE ( native : : eosio : : producer_votes_object , native : : eosio : : producer_votes_multi_index ) <nl> + CHAINBASE_SET_INDEX_TYPE ( native : : eosio : : proxy_vote_object , native : : eosio : : proxy_vote_multi_index ) <nl> + CHAINBASE_SET_INDEX_TYPE ( native : : eosio : : producer_schedule_object , native : : eosio : : producer_schedule_multi_index ) <nl> mmm a / libraries / native_contract / include / eos / native_contract / staked_balance_objects . hpp <nl> ppp b / libraries / native_contract / include / eos / native_contract / staked_balance_objects . hpp <nl> namespace chain = : : eosio : : chain ; <nl> namespace types = : : eosio : : types ; <nl> <nl> / * * <nl> - * @ brief The ProducerSlate struct stores a list of producers voted on by an account <nl> + * @ brief The producer_slate struct stores a list of producers voted on by an account <nl> * / <nl> - struct ProducerSlate { <nl> + struct producer_slate { <nl> std : : array < types : : account_name , config : : max_producer_votes > votes ; <nl> size_t size = 0 ; <nl> <nl> struct ProducerSlate { <nl> } ; <nl> <nl> / * * <nl> - * @ brief The StakedBalanceObject class tracks the staked balance ( voting balance ) for accounts <nl> + * @ brief The staked_balance_object class tracks the staked balance ( voting balance ) for accounts <nl> * / <nl> - class StakedBalanceObject : public chainbase : : object < chain : : staked_balance_object_type , StakedBalanceObject > { <nl> - OBJECT_CTOR ( StakedBalanceObject ) <nl> + class staked_balance_object : public chainbase : : object < chain : : staked_balance_object_type , staked_balance_object > { <nl> + OBJECT_CTOR ( staked_balance_object ) <nl> <nl> id_type id ; <nl> types : : account_name ownerName ; <nl> <nl> - types : : share_type stakedBalance = 0 ; <nl> - types : : share_type unstakingBalance = 0 ; <nl> - types : : time lastUnstakingTime = types : : time : : maximum ( ) ; <nl> + types : : share_type staked_balance = 0 ; <nl> + types : : share_type unstaking_balance = 0 ; <nl> + types : : time last_unstaking_time = types : : time : : maximum ( ) ; <nl> <nl> / / / The account ' s vote on producers . This may either be a list of approved producers , or an account to proxy vote to <nl> - fc : : static_variant < ProducerSlate , types : : account_name > producerVotes = ProducerSlate { } ; <nl> + fc : : static_variant < producer_slate , types : : account_name > producer_votes = producer_slate { } ; <nl> <nl> / * * <nl> * @ brief Add the provided stake to this balance , maintaining invariants <nl> - * @ param newStake The new stake to add to the balance <nl> + * @ param new_stake The new stake to add to the balance <nl> * @ param db Read - write reference to the database <nl> * <nl> * This method will update this object with the new stake , while maintaining invariants around the stake balance , <nl> * such as by updating vote tallies <nl> * / <nl> - void stakeTokens ( types : : share_type newStake , chainbase : : database & db ) const ; <nl> + void stake_tokens ( types : : share_type new_stake , chainbase : : database & db ) const ; <nl> / * * <nl> * @ brief Begin unstaking the specified amount of stake , maintaining invariants <nl> * @ param amount The amount of stake to begin unstaking <nl> class StakedBalanceObject : public chainbase : : object < chain : : staked_balance_objec <nl> * This method will update this object ' s balances while maintaining invariants around the stake balances , such as by <nl> * updating vote tallies <nl> * / <nl> - void beginUnstakingTokens ( types : : share_type amount , chainbase : : database & db ) const ; <nl> + void begin_unstaking_tokens ( types : : share_type amount , chainbase : : database & db ) const ; <nl> / * * <nl> * @ brief Finish unstaking the specified amount of stake <nl> * @ param amount The amount of stake to finish unstaking <nl> class StakedBalanceObject : public chainbase : : object < chain : : staked_balance_objec <nl> * This method will update this object ' s balances . There aren ' t really any invariants to maintain on this call , as <nl> * the tokens are already unstaked and removed from vote tallies , but it is provided for completeness ' sake . <nl> * / <nl> - void finishUnstakingTokens ( types : : share_type amount , chainbase : : database & db ) const ; <nl> + void finish_unstaking_tokens ( types : : share_type amount , chainbase : : database & db ) const ; <nl> <nl> / * * <nl> * @ brief Propagate the specified change in stake to the producer votes or the proxy <nl> - * @ param stakeDelta The change in stake <nl> + * @ param stake_delta The change in stake <nl> * @ param db Read - write reference to the database <nl> * <nl> * This method will apply the provided delta in voting stake to the next stage in the producer voting pipeline , <nl> class StakedBalanceObject : public chainbase : : object < chain : : staked_balance_objec <nl> * <nl> * This method will * not * update this object in any way . It will not adjust @ ref stakedBalance , etc <nl> * / <nl> - void propagateVotes ( types : : share_type stakeDelta , chainbase : : database & db ) const ; <nl> + void propagate_votes ( types : : share_type stake_delta , chainbase : : database & db ) const ; <nl> } ; <nl> <nl> - struct byOwnerName ; <nl> + struct by_owner_name ; <nl> <nl> - using StakedBalanceMultiIndex = chainbase : : shared_multi_index_container < <nl> - StakedBalanceObject , <nl> + using staked_balance_multi_index = chainbase : : shared_multi_index_container < <nl> + staked_balance_object , <nl> indexed_by < <nl> ordered_unique < tag < by_id > , <nl> - member < StakedBalanceObject , StakedBalanceObject : : id_type , & StakedBalanceObject : : id > <nl> + member < staked_balance_object , staked_balance_object : : id_type , & staked_balance_object : : id > <nl> > , <nl> - ordered_unique < tag < byOwnerName > , <nl> - member < StakedBalanceObject , types : : account_name , & StakedBalanceObject : : ownerName > <nl> + ordered_unique < tag < by_owner_name > , <nl> + member < staked_balance_object , types : : account_name , & staked_balance_object : : ownerName > <nl> > <nl> > <nl> > ; <nl> <nl> } } / / namespace native : : eos <nl> <nl> - CHAINBASE_SET_INDEX_TYPE ( native : : eosio : : StakedBalanceObject , native : : eosio : : StakedBalanceMultiIndex ) <nl> + CHAINBASE_SET_INDEX_TYPE ( native : : eosio : : staked_balance_object , native : : eosio : : staked_balance_multi_index ) <nl> mmm a / libraries / native_contract / native_contract_chain_administrator . cpp <nl> ppp b / libraries / native_contract / native_contract_chain_administrator . cpp <nl> namespace eosio { namespace native_contract { <nl> using administrator = native_contract_chain_administrator ; <nl> <nl> producer_round administrator : : get_next_round ( chainbase : : database & db ) { <nl> - return native : : eosio : : ProducerScheduleObject : : get ( db ) . calculateNextRound ( db ) ; <nl> + return native : : eosio : : producer_schedule_object : : get ( db ) . calculate_next_round ( db ) ; <nl> } <nl> <nl> chain : : blockchain_configuration administrator : : get_blockchain_configuration ( const chainbase : : database & db , <nl> mmm a / libraries / native_contract / native_contract_chain_initializer . cpp <nl> ppp b / libraries / native_contract / native_contract_chain_initializer . cpp <nl> std : : array < types : : account_name , config : : blocks_per_round > native_contract_chain_ <nl> <nl> void native_contract_chain_initializer : : register_types ( chain_controller & chain , chainbase : : database & db ) { <nl> / / Install the native contract ' s indexes ; we can ' t do anything until our objects are recognized <nl> - db . add_index < native : : eosio : : StakedBalanceMultiIndex > ( ) ; <nl> - db . add_index < native : : eosio : : ProducerVotesMultiIndex > ( ) ; <nl> - db . add_index < native : : eosio : : ProxyVoteMultiIndex > ( ) ; <nl> - db . add_index < native : : eosio : : ProducerScheduleMultiIndex > ( ) ; <nl> + db . add_index < native : : eosio : : staked_balance_multi_index > ( ) ; <nl> + db . add_index < native : : eosio : : producer_votes_multi_index > ( ) ; <nl> + db . add_index < native : : eosio : : proxy_vote_multi_index > ( ) ; <nl> + db . add_index < native : : eosio : : producer_schedule_multi_index > ( ) ; <nl> <nl> - db . add_index < native : : eosio : : BalanceMultiIndex > ( ) ; <nl> + db . add_index < native : : eosio : : balance_multi_index > ( ) ; <nl> <nl> # define SET_APP_HANDLER ( contract , scope , action , nspace ) \ <nl> chain . set_apply_handler ( # contract , # scope , # action , & BOOST_PP_CAT ( native : : nspace : : apply_ , BOOST_PP_CAT ( contract , BOOST_PP_CAT ( _ , action ) ) ) ) <nl> std : : vector < message > native_contract_chain_initializer : : prepare_database ( chain_c <nl> chainbase : : database & db ) { <nl> std : : vector < message > messages_to_process ; <nl> <nl> - / / Create the singleton object , ProducerScheduleObject <nl> - db . create < native : : eosio : : ProducerScheduleObject > ( [ ] ( const auto & ) { } ) ; <nl> + / / Create the singleton object , producer_schedule_object <nl> + db . create < native : : eosio : : producer_schedule_object > ( [ ] ( const auto & ) { } ) ; <nl> <nl> / / / Create the native contract accounts manually ; sadly , we can ' t run their contracts to make them create themselves <nl> auto CreateNativeAccount = [ this , & db ] ( name name , auto liquidBalance ) { <nl> std : : vector < message > native_contract_chain_initializer : : prepare_database ( chain_c <nl> p . name = " active " ; <nl> p . auth . threshold = 1 ; <nl> } ) ; <nl> - db . create < native : : eosio : : BalanceObject > ( [ & name , liquidBalance ] ( auto & b ) { <nl> - b . ownerName = name ; <nl> + db . create < native : : eosio : : balance_object > ( [ & name , liquidBalance ] ( auto & b ) { <nl> + b . owner_name = name ; <nl> b . balance = liquidBalance ; <nl> } ) ; <nl> - db . create < native : : eosio : : StakedBalanceObject > ( [ & name ] ( auto & sb ) { sb . ownerName = name ; } ) ; <nl> + db . create < native : : eosio : : staked_balance_object > ( [ & name ] ( auto & sb ) { sb . ownerName = name ; } ) ; <nl> } ; <nl> CreateNativeAccount ( config : : eos_contract_name , config : : initial_token_supply ) ; <nl> <nl> mmm a / libraries / native_contract / producer_objects . cpp <nl> ppp b / libraries / native_contract / producer_objects . cpp <nl> namespace eosio { <nl> using namespace chain ; <nl> using namespace types ; <nl> <nl> - void ProducerVotesObject : : updateVotes ( share_type deltaVotes , uint128 currentRaceTime ) { <nl> - auto timeSinceLastUpdate = currentRaceTime - race . positionUpdateTime ; <nl> + void producer_votes_object : : update_votes ( share_type deltaVotes , uint128 current_race_time ) { <nl> + auto timeSinceLastUpdate = current_race_time - race . position_update_time ; <nl> auto newPosition = race . position + race . speed * timeSinceLastUpdate ; <nl> auto newSpeed = race . speed + deltaVotes ; <nl> <nl> - race . update ( newSpeed , newPosition , currentRaceTime ) ; <nl> + race . update ( newSpeed , newPosition , current_race_time ) ; <nl> } <nl> <nl> - void ProxyVoteObject : : addProxySource ( const account_name & source , share_type sourceStake , chainbase : : database & db ) const { <nl> - db . modify ( * this , [ & source , sourceStake ] ( ProxyVoteObject & pvo ) { <nl> - pvo . proxySources . insert ( source ) ; <nl> - pvo . proxiedStake + = sourceStake ; <nl> + void proxy_vote_object : : add_proxy_source ( const account_name & source , share_type sourceStake , chainbase : : database & db ) const { <nl> + db . modify ( * this , [ & source , sourceStake ] ( proxy_vote_object & pvo ) { <nl> + pvo . proxy_sources . insert ( source ) ; <nl> + pvo . proxied_stake + = sourceStake ; <nl> } ) ; <nl> - db . get < StakedBalanceObject , byOwnerName > ( proxyTarget ) . propagateVotes ( sourceStake , db ) ; <nl> + db . get < staked_balance_object , by_owner_name > ( proxy_target ) . propagate_votes ( sourceStake , db ) ; <nl> } <nl> <nl> - void ProxyVoteObject : : removeProxySource ( const account_name & source , share_type sourceStake , <nl> + void proxy_vote_object : : removeProxySource ( const account_name & source , share_type sourceStake , <nl> chainbase : : database & db ) const { <nl> - db . modify ( * this , [ & source , sourceStake ] ( ProxyVoteObject & pvo ) { <nl> - pvo . proxySources . erase ( source ) ; <nl> - pvo . proxiedStake - = sourceStake ; <nl> + db . modify ( * this , [ & source , sourceStake ] ( proxy_vote_object & pvo ) { <nl> + pvo . proxy_sources . erase ( source ) ; <nl> + pvo . proxied_stake - = sourceStake ; <nl> } ) ; <nl> - db . get < StakedBalanceObject , byOwnerName > ( proxyTarget ) . propagateVotes ( sourceStake , db ) ; <nl> + db . get < staked_balance_object , by_owner_name > ( proxy_target ) . propagate_votes ( sourceStake , db ) ; <nl> } <nl> <nl> - void ProxyVoteObject : : updateProxiedStake ( share_type stakeDelta , chainbase : : database & db ) const { <nl> - db . modify ( * this , [ stakeDelta ] ( ProxyVoteObject & pvo ) { <nl> - pvo . proxiedStake + = stakeDelta ; <nl> + void proxy_vote_object : : update_proxied_stake ( share_type stakeDelta , chainbase : : database & db ) const { <nl> + db . modify ( * this , [ stakeDelta ] ( proxy_vote_object & pvo ) { <nl> + pvo . proxied_stake + = stakeDelta ; <nl> } ) ; <nl> - db . get < StakedBalanceObject , byOwnerName > ( proxyTarget ) . propagateVotes ( stakeDelta , db ) ; <nl> + db . get < staked_balance_object , by_owner_name > ( proxy_target ) . propagate_votes ( stakeDelta , db ) ; <nl> } <nl> <nl> - void ProxyVoteObject : : cancelProxies ( chainbase : : database & db ) const { <nl> - boost : : for_each ( proxySources , [ & db ] ( const account_name & source ) { <nl> - const auto & balance = db . get < StakedBalanceObject , byOwnerName > ( source ) ; <nl> - db . modify ( balance , [ ] ( StakedBalanceObject & sbo ) { <nl> - sbo . producerVotes = ProducerSlate { } ; <nl> + void proxy_vote_object : : cancel_proxies ( chainbase : : database & db ) const { <nl> + boost : : for_each ( proxy_sources , [ & db ] ( const account_name & source ) { <nl> + const auto & balance = db . get < staked_balance_object , by_owner_name > ( source ) ; <nl> + db . modify ( balance , [ ] ( staked_balance_object & sbo ) { <nl> + sbo . producer_votes = producer_slate { } ; <nl> } ) ; <nl> } ) ; <nl> } <nl> <nl> - producer_round ProducerScheduleObject : : calculateNextRound ( chainbase : : database & db ) const { <nl> + producer_round producer_schedule_object : : calculate_next_round ( chainbase : : database & db ) const { <nl> / / Create storage and machinery with nice names , for choosing the top - voted producers <nl> producer_round round ; <nl> - auto FilterRetiredProducers = boost : : adaptors : : filtered ( [ & db ] ( const ProducerVotesObject & pvo ) { <nl> + auto FilterRetiredProducers = boost : : adaptors : : filtered ( [ & db ] ( const producer_votes_object & pvo ) { <nl> return db . get < producer_object , by_owner > ( pvo . ownerName ) . signing_key ! = public_key ( ) ; <nl> } ) ; <nl> - auto ProducerObjectToName = boost : : adaptors : : transformed ( [ ] ( const ProducerVotesObject & p ) { return p . ownerName ; } ) ; <nl> - const auto & AllProducersByVotes = db . get_index < ProducerVotesMultiIndex , byVotes > ( ) ; <nl> + auto ProducerObjectToName = boost : : adaptors : : transformed ( [ ] ( const producer_votes_object & p ) { return p . ownerName ; } ) ; <nl> + const auto & AllProducersByVotes = db . get_index < producer_votes_multi_index , by_votes > ( ) ; <nl> auto ActiveProducersByVotes = AllProducersByVotes | FilterRetiredProducers ; <nl> <nl> FC_ASSERT ( boost : : distance ( ActiveProducersByVotes ) > = config : : blocks_per_round , <nl> producer_round ProducerScheduleObject : : calculateNextRound ( chainbase : : database & d <nl> auto VotedProducerRange = boost : : make_iterator_range ( round . begin ( ) , runnerUpStorage ) ; <nl> / / Sort the voted producer names ; we ' ll need to do it anyways , and it makes searching faster if we do it now <nl> boost : : sort ( VotedProducerRange ) ; <nl> - auto FilterVotedProducers = boost : : adaptors : : filtered ( [ & VotedProducerRange ] ( const ProducerVotesObject & pvo ) { <nl> + auto FilterVotedProducers = boost : : adaptors : : filtered ( [ & VotedProducerRange ] ( const producer_votes_object & pvo ) { <nl> return ! boost : : binary_search ( VotedProducerRange , pvo . ownerName ) ; <nl> } ) ; <nl> - const auto & AllProducersByFinishTime = db . get_index < ProducerVotesMultiIndex , byProjectedRaceFinishTime > ( ) ; <nl> + const auto & AllProducersByFinishTime = db . get_index < producer_votes_multi_index , by_projected_race_finish_time > ( ) ; <nl> auto EligibleProducersByFinishTime = AllProducersByFinishTime | FilterRetiredProducers | FilterVotedProducers ; <nl> <nl> auto runnerUpProducerCount = config : : blocks_per_round - config : : voted_producers_per_round ; <nl> producer_round ProducerScheduleObject : : calculateNextRound ( chainbase : : database & d <nl> boost : : inplace_merge ( round , runnerUpStorage ) ; <nl> <nl> / / Machinery to update the virtual race tracking for the producers that completed their lap <nl> - auto lastRunnerUp = AllProducersByFinishTime . iterator_to ( db . get < ProducerVotesObject , byOwnerName > ( lastRunnerUpName ) ) ; <nl> - auto newRaceTime = lastRunnerUp - > projectedRaceFinishTime ( ) ; <nl> - auto StartNewLap = [ & db , newRaceTime ] ( const ProducerVotesObject & pvo ) { <nl> - db . modify ( pvo , [ newRaceTime ] ( ProducerVotesObject & pvo ) { <nl> - pvo . startNewRaceLap ( newRaceTime ) ; <nl> + auto lastRunnerUp = AllProducersByFinishTime . iterator_to ( db . get < producer_votes_object , by_owner_name > ( lastRunnerUpName ) ) ; <nl> + auto newRaceTime = lastRunnerUp - > projected_race_finish_time ( ) ; <nl> + auto StartNewLap = [ & db , newRaceTime ] ( const producer_votes_object & pvo ) { <nl> + db . modify ( pvo , [ newRaceTime ] ( producer_votes_object & pvo ) { <nl> + pvo . start_new_race_lap ( newRaceTime ) ; <nl> } ) ; <nl> } ; <nl> auto LapCompleters = boost : : make_iterator_range ( AllProducersByFinishTime . begin ( ) , + + lastRunnerUp ) ; <nl> producer_round ProducerScheduleObject : : calculateNextRound ( chainbase : : database & d <nl> / / ilog ( " Processed producer race . $ { count } producers completed a lap at virtual time $ { time } " , <nl> / / ( " count " , ( int64_t ) boost : : distance ( LapCompleters ) ) ( " time " , newRaceTime ) ) ; <nl> boost : : for_each ( LapCompleters , StartNewLap ) ; <nl> - db . modify ( * this , [ newRaceTime ] ( ProducerScheduleObject & pso ) { <nl> + db . modify ( * this , [ newRaceTime ] ( producer_schedule_object & pso ) { <nl> pso . currentRaceTime = newRaceTime ; <nl> } ) ; <nl> } else { <nl> / / wlog ( " Producer race finished ; restarting race . " ) ; <nl> - resetProducerRace ( db ) ; <nl> + reset_producer_race ( db ) ; <nl> } <nl> - } catch ( ProducerRaceOverflowException & ) { <nl> + } catch ( producer_race_overflow_exception & ) { <nl> / / Virtual race time has overflown . Reset race for everyone . <nl> / / wlog ( " Producer race virtual time overflow detected ! Resetting race . " ) ; <nl> - resetProducerRace ( db ) ; <nl> + reset_producer_race ( db ) ; <nl> } <nl> <nl> return round ; <nl> } <nl> <nl> - void ProducerScheduleObject : : resetProducerRace ( chainbase : : database & db ) const { <nl> - auto ResetRace = [ & db ] ( const ProducerVotesObject & pvo ) { <nl> - db . modify ( pvo , [ ] ( ProducerVotesObject & pvo ) { <nl> - pvo . startNewRaceLap ( 0 ) ; <nl> + void producer_schedule_object : : reset_producer_race ( chainbase : : database & db ) const { <nl> + auto ResetRace = [ & db ] ( const producer_votes_object & pvo ) { <nl> + db . modify ( pvo , [ ] ( producer_votes_object & pvo ) { <nl> + pvo . start_new_race_lap ( 0 ) ; <nl> } ) ; <nl> } ; <nl> - const auto & AllProducers = db . get_index < ProducerVotesMultiIndex , byVotes > ( ) ; <nl> + const auto & AllProducers = db . get_index < producer_votes_multi_index , by_votes > ( ) ; <nl> <nl> boost : : for_each ( AllProducers , ResetRace ) ; <nl> - db . modify ( * this , [ ] ( ProducerScheduleObject & pso ) { <nl> + db . modify ( * this , [ ] ( producer_schedule_object & pso ) { <nl> pso . currentRaceTime = 0 ; <nl> } ) ; <nl> } <nl> mmm a / libraries / native_contract / staked_balance_objects . cpp <nl> ppp b / libraries / native_contract / staked_balance_objects . cpp <nl> namespace eosio { <nl> using namespace eosio : : chain ; <nl> using namespace eosio : : types ; <nl> <nl> - void StakedBalanceObject : : stakeTokens ( share_type newStake , chainbase : : database & db ) const { <nl> + void staked_balance_object : : stake_tokens ( share_type new_stake , chainbase : : database & db ) const { <nl> / / Update the staked balance <nl> - db . modify ( * this , [ & newStake ] ( StakedBalanceObject & sbo ) { <nl> - sbo . stakedBalance + = newStake ; <nl> + db . modify ( * this , [ & new_stake ] ( staked_balance_object & sbo ) { <nl> + sbo . staked_balance + = new_stake ; <nl> } ) ; <nl> <nl> - propagateVotes ( newStake , db ) ; <nl> + propagate_votes ( new_stake , db ) ; <nl> } <nl> <nl> - void StakedBalanceObject : : beginUnstakingTokens ( share_type amount , chainbase : : database & db ) const { <nl> - / / Remember there might be stake left over from a previous , uncompleted unstaking in unstakingBalance <nl> - auto deltaStake = unstakingBalance - amount ; <nl> + void staked_balance_object : : begin_unstaking_tokens ( share_type amount , chainbase : : database & db ) const { <nl> + / / Remember there might be stake left over from a previous , uncompleted unstaking in unstaking_balance <nl> + auto deltaStake = unstaking_balance - amount ; <nl> <nl> / / Update actual stake balance and invariants around it <nl> - stakeTokens ( deltaStake , db ) ; <nl> + stake_tokens ( deltaStake , db ) ; <nl> / / Update stats for unstaking process <nl> - db . modify ( * this , [ & amount , & db ] ( StakedBalanceObject & sbo ) { <nl> - sbo . unstakingBalance = amount ; <nl> - sbo . lastUnstakingTime = db . get ( dynamic_global_property_object : : id_type ( ) ) . time ; <nl> + db . modify ( * this , [ & amount , & db ] ( staked_balance_object & sbo ) { <nl> + sbo . unstaking_balance = amount ; <nl> + sbo . last_unstaking_time = db . get ( dynamic_global_property_object : : id_type ( ) ) . time ; <nl> } ) ; <nl> } <nl> <nl> - void StakedBalanceObject : : finishUnstakingTokens ( share_type amount , chainbase : : database & db ) const { <nl> - db . modify ( * this , [ & amount ] ( StakedBalanceObject & sbo ) { <nl> - sbo . unstakingBalance - = amount ; <nl> + void staked_balance_object : : finish_unstaking_tokens ( share_type amount , chainbase : : database & db ) const { <nl> + db . modify ( * this , [ & amount ] ( staked_balance_object & sbo ) { <nl> + sbo . unstaking_balance - = amount ; <nl> } ) ; <nl> } <nl> <nl> - void StakedBalanceObject : : propagateVotes ( share_type stakeDelta , chainbase : : database & db ) const { <nl> - if ( producerVotes . contains < ProducerSlate > ( ) ) <nl> + void staked_balance_object : : propagate_votes ( share_type stake_delta , chainbase : : database & db ) const { <nl> + if ( producer_votes . contains < producer_slate > ( ) ) <nl> / / This account votes for producers directly ; update their stakes <nl> - boost : : for_each ( producerVotes . get < ProducerSlate > ( ) . range ( ) , [ & db , & stakeDelta ] ( const account_name & name ) { <nl> - db . modify ( db . get < ProducerVotesObject , byOwnerName > ( name ) , [ & db , & stakeDelta ] ( ProducerVotesObject & pvo ) { <nl> - pvo . updateVotes ( stakeDelta , ProducerScheduleObject : : get ( db ) . currentRaceTime ) ; <nl> + boost : : for_each ( producer_votes . get < producer_slate > ( ) . range ( ) , [ & db , & stake_delta ] ( const account_name & name ) { <nl> + db . modify ( db . get < producer_votes_object , by_owner_name > ( name ) , [ & db , & stake_delta ] ( producer_votes_object & pvo ) { <nl> + pvo . update_votes ( stake_delta , producer_schedule_object : : get ( db ) . currentRaceTime ) ; <nl> } ) ; <nl> } ) ; <nl> else { <nl> - / / This account has proxied its votes to another account ; update the ProxyVoteObject <nl> - const auto & proxy = db . get < ProxyVoteObject , byTargetName > ( producerVotes . get < account_name > ( ) ) ; <nl> - proxy . updateProxiedStake ( stakeDelta , db ) ; <nl> + / / This account has proxied its votes to another account ; update the proxy_vote_object <nl> + const auto & proxy = db . get < proxy_vote_object , by_target_name > ( producer_votes . get < account_name > ( ) ) ; <nl> + proxy . update_proxied_stake ( stake_delta , db ) ; <nl> } <nl> } <nl> <nl> mmm a / libraries / types / abi_serializer . cpp <nl> ppp b / libraries / types / abi_serializer . cpp <nl> namespace eosio { namespace types { <nl> } <nl> <nl> abi_serializer : : abi_serializer ( const abi & abi ) { <nl> - configureBuiltInTypes ( ) ; <nl> + configure_built_in_types ( ) ; <nl> setAbi ( abi ) ; <nl> } <nl> <nl> - void abi_serializer : : configureBuiltInTypes ( ) { <nl> + void abi_serializer : : configure_built_in_types ( ) { <nl> / / public_key . hpp <nl> built_in_types . emplace ( " public_key " , packUnpack < public_key > ( ) ) ; <nl> <nl> mmm a / libraries / types / include / eos / types / abi_serializer . hpp <nl> ppp b / libraries / types / include / eos / types / abi_serializer . hpp <nl> using std : : pair ; <nl> * be converted to and from JSON . <nl> * / <nl> struct abi_serializer { <nl> - abi_serializer ( ) { configureBuiltInTypes ( ) ; } <nl> + abi_serializer ( ) { configure_built_in_types ( ) ; } <nl> abi_serializer ( const abi & abi ) ; <nl> void setAbi ( const abi & abi ) ; <nl> <nl> struct abi_serializer { <nl> typedef std : : function < void ( const fc : : variant & , fc : : datastream < char * > & , bool ) > pack_function ; <nl> <nl> map < type_name , pair < unpack_function , pack_function > > built_in_types ; <nl> - void configureBuiltInTypes ( ) ; <nl> + void configure_built_in_types ( ) ; <nl> <nl> bool has_cycle ( const vector < pair < string , string > > & sedges ) const ; <nl> void validate ( ) const ; <nl> struct abi_serializer { <nl> } <nl> <nl> private : <nl> - void binary_to_variant ( const type_name & type , fc : : datastream < const char * > & stream , fc : : mutable_variant_object & obj ) const ; <nl> + void binary_to_variant ( const type_name & type , fc : : datastream < const char * > & stream , fc : : mutable_variant_object & obj ) const ; <nl> } ; <nl> <nl> } } / / eosio : : types <nl> mmm a / libraries / types / types . eos <nl> ppp b / libraries / types / types . eos <nl> struct newaccount <nl> <nl> struct setcode <nl> account account_name # the account that is handling the message <nl> - vmtype uint8 # the virtual machine type <nl> - vmversion uint8 # the virtual machine version <nl> + vm_type uint8 # the virtual machine type <nl> + vm_version uint8 # the virtual machine version <nl> code bytes # the apply <nl> abi abi # the interface description of the code <nl> <nl> mmm a / libraries / utilities / include / eos / utilities / parallel_markers . hpp <nl> ppp b / libraries / utilities / include / eos / utilities / parallel_markers . hpp <nl> namespace eosio { namespace utilities { <nl> * @ endcode <nl> * / <nl> template < typename DataRange , typename MarkerRange , typename Marker > <nl> - DataRange FilterDataByMarker ( DataRange data , MarkerRange markers , const Marker & markerValue ) { <nl> - auto RemoveMismatchedMarkers = boost : : adaptors : : filtered ( [ & markerValue ] ( const auto & tuple ) { <nl> + DataRange filter_data_by_marker ( DataRange data , MarkerRange markers , const Marker & markerValue ) { <nl> + auto remove_mismatched_markers = boost : : adaptors : : filtered ( [ & markerValue ] ( const auto & tuple ) { <nl> return boost : : get < 0 > ( tuple ) = = markerValue ; <nl> } ) ; <nl> auto ToData = boost : : adaptors : : transformed ( [ ] ( const auto & tuple ) { <nl> DataRange FilterDataByMarker ( DataRange data , MarkerRange markers , const Marker & <nl> } ) ; <nl> <nl> / / Zip the ranges together , filter out data with markers that don ' t match , and return the data without the markers <nl> - auto range = boost : : combine ( markers , data ) | RemoveMismatchedMarkers | ToData ; <nl> + auto range = boost : : combine ( markers , data ) | remove_mismatched_markers | ToData ; <nl> return { range . begin ( ) , range . end ( ) } ; <nl> } <nl> <nl> mmm a / plugins / chain_plugin / chain_plugin . cpp <nl> ppp b / plugins / chain_plugin / chain_plugin . cpp <nl> read_only : : get_account_results read_only : : get_account ( const get_account_params & <nl> result . name = params . name ; <nl> <nl> const auto & d = db . get_database ( ) ; <nl> - const auto & balance = d . get < BalanceObject , byOwnerName > ( params . name ) ; <nl> - const auto & staked_balance = d . get < StakedBalanceObject , byOwnerName > ( params . name ) ; <nl> + const auto & balance = d . get < balance_object , by_owner_name > ( params . name ) ; <nl> + const auto & staked_balance = d . get < staked_balance_object , by_owner_name > ( params . name ) ; <nl> <nl> result . eos_balance = asset ( balance . balance , EOS_SYMBOL ) ; <nl> - result . staked_balance = asset ( staked_balance . stakedBalance ) ; <nl> - result . unstaking_balance = asset ( staked_balance . unstakingBalance ) ; <nl> - result . last_unstaking_time = staked_balance . lastUnstakingTime ; <nl> + result . staked_balance = asset ( staked_balance . staked_balance ) ; <nl> + result . unstaking_balance = asset ( staked_balance . unstaking_balance ) ; <nl> + result . last_unstaking_time = staked_balance . last_unstaking_time ; <nl> <nl> const auto & permissions = d . get_index < permission_index , by_owner > ( ) ; <nl> auto perm = permissions . lower_bound ( boost : : make_tuple ( params . name ) ) ; <nl> mmm a / tests / common / database_fixture . cpp <nl> ppp b / tests / common / database_fixture . cpp <nl> void testing_blockchain : : sync_with ( testing_blockchain & other ) { <nl> } <nl> <nl> types : : asset testing_blockchain : : get_liquid_balance ( const types : : account_name & account ) { <nl> - return get_database ( ) . get < BalanceObject , native : : eosio : : byOwnerName > ( account ) . balance ; <nl> + return get_database ( ) . get < balance_object , native : : eosio : : by_owner_name > ( account ) . balance ; <nl> } <nl> <nl> types : : asset testing_blockchain : : get_staked_balance ( const types : : account_name & account ) { <nl> - return get_database ( ) . get < StakedBalanceObject , native : : eosio : : byOwnerName > ( account ) . stakedBalance ; <nl> + return get_database ( ) . get < staked_balance_object , native : : eosio : : by_owner_name > ( account ) . staked_balance ; <nl> } <nl> <nl> types : : asset testing_blockchain : : get_unstaking_balance ( const types : : account_name & account ) { <nl> - return get_database ( ) . get < StakedBalanceObject , native : : eosio : : byOwnerName > ( account ) . unstakingBalance ; <nl> + return get_database ( ) . get < staked_balance_object , native : : eosio : : by_owner_name > ( account ) . unstaking_balance ; <nl> } <nl> <nl> std : : set < types : : account_name > testing_blockchain : : get_approved_producers ( const types : : account_name & account ) { <nl> - const auto & sbo = get_database ( ) . get < StakedBalanceObject , byOwnerName > ( account ) ; <nl> - if ( sbo . producerVotes . contains < ProducerSlate > ( ) ) { <nl> - auto range = sbo . producerVotes . get < ProducerSlate > ( ) . range ( ) ; <nl> + const auto & sbo = get_database ( ) . get < staked_balance_object , by_owner_name > ( account ) ; <nl> + if ( sbo . producer_votes . contains < producer_slate > ( ) ) { <nl> + auto range = sbo . producer_votes . get < producer_slate > ( ) . range ( ) ; <nl> return { range . begin ( ) , range . end ( ) } ; <nl> } <nl> return { } ; <nl> mmm a / tests / tests / misc_tests . cpp <nl> ppp b / tests / tests / misc_tests . cpp <nl> BOOST_AUTO_TEST_CASE ( authority_checker ) <nl> <nl> auto A = Complex_Authority ( 2 , ( ( a , 1 ) ) ( ( b , 1 ) ) , ) ; <nl> { <nl> - auto checker = MakeAuthorityChecker ( GetNullAuthority , 2 , { a , b } ) ; <nl> + auto checker = make_authority_checker ( GetNullAuthority , 2 , { a , b } ) ; <nl> BOOST_CHECK ( checker . satisfied ( A ) ) ; <nl> BOOST_CHECK ( checker . all_keys_used ( ) ) ; <nl> BOOST_CHECK_EQUAL ( checker . used_keys ( ) . size ( ) , 2 ) ; <nl> BOOST_CHECK_EQUAL ( checker . unused_keys ( ) . size ( ) , 0 ) ; <nl> } <nl> { <nl> - auto checker = MakeAuthorityChecker ( GetNullAuthority , 2 , { a , c } ) ; <nl> + auto checker = make_authority_checker ( GetNullAuthority , 2 , { a , c } ) ; <nl> BOOST_CHECK ( ! checker . satisfied ( A ) ) ; <nl> BOOST_CHECK ( ! checker . all_keys_used ( ) ) ; <nl> BOOST_CHECK_EQUAL ( checker . used_keys ( ) . size ( ) , 0 ) ; <nl> BOOST_CHECK_EQUAL ( checker . unused_keys ( ) . size ( ) , 2 ) ; <nl> } <nl> { <nl> - auto checker = MakeAuthorityChecker ( GetNullAuthority , 2 , { a , b , c } ) ; <nl> + auto checker = make_authority_checker ( GetNullAuthority , 2 , { a , b , c } ) ; <nl> BOOST_CHECK ( checker . satisfied ( A ) ) ; <nl> BOOST_CHECK ( ! checker . all_keys_used ( ) ) ; <nl> BOOST_CHECK_EQUAL ( checker . used_keys ( ) . size ( ) , 2 ) ; <nl> BOOST_AUTO_TEST_CASE ( authority_checker ) <nl> BOOST_CHECK_EQUAL ( checker . unused_keys ( ) . count ( c ) , 1 ) ; <nl> } <nl> { <nl> - auto checker = MakeAuthorityChecker ( GetNullAuthority , 2 , { b , c } ) ; <nl> + auto checker = make_authority_checker ( GetNullAuthority , 2 , { b , c } ) ; <nl> BOOST_CHECK ( ! checker . satisfied ( A ) ) ; <nl> BOOST_CHECK ( ! checker . all_keys_used ( ) ) ; <nl> BOOST_CHECK_EQUAL ( checker . used_keys ( ) . size ( ) , 0 ) ; <nl> } <nl> <nl> A = Complex_Authority ( 3 , ( ( a , 1 ) ) ( ( b , 1 ) ) ( ( c , 1 ) ) , ) ; <nl> - BOOST_CHECK ( MakeAuthorityChecker ( GetNullAuthority , 2 , { c , b , a } ) . satisfied ( A ) ) ; <nl> - BOOST_CHECK ( ! MakeAuthorityChecker ( GetNullAuthority , 2 , { a , b } ) . satisfied ( A ) ) ; <nl> - BOOST_CHECK ( ! MakeAuthorityChecker ( GetNullAuthority , 2 , { a , c } ) . satisfied ( A ) ) ; <nl> - BOOST_CHECK ( ! MakeAuthorityChecker ( GetNullAuthority , 2 , { b , c } ) . satisfied ( A ) ) ; <nl> + BOOST_CHECK ( make_authority_checker ( GetNullAuthority , 2 , { c , b , a } ) . satisfied ( A ) ) ; <nl> + BOOST_CHECK ( ! make_authority_checker ( GetNullAuthority , 2 , { a , b } ) . satisfied ( A ) ) ; <nl> + BOOST_CHECK ( ! make_authority_checker ( GetNullAuthority , 2 , { a , c } ) . satisfied ( A ) ) ; <nl> + BOOST_CHECK ( ! make_authority_checker ( GetNullAuthority , 2 , { b , c } ) . satisfied ( A ) ) ; <nl> <nl> A = Complex_Authority ( 1 , ( ( a , 1 ) ) ( ( b , 1 ) ) , ) ; <nl> - BOOST_CHECK ( MakeAuthorityChecker ( GetNullAuthority , 2 , { a } ) . satisfied ( A ) ) ; <nl> - BOOST_CHECK ( MakeAuthorityChecker ( GetNullAuthority , 2 , { b } ) . satisfied ( A ) ) ; <nl> - BOOST_CHECK ( ! MakeAuthorityChecker ( GetNullAuthority , 2 , { c } ) . satisfied ( A ) ) ; <nl> + BOOST_CHECK ( make_authority_checker ( GetNullAuthority , 2 , { a } ) . satisfied ( A ) ) ; <nl> + BOOST_CHECK ( make_authority_checker ( GetNullAuthority , 2 , { b } ) . satisfied ( A ) ) ; <nl> + BOOST_CHECK ( ! make_authority_checker ( GetNullAuthority , 2 , { c } ) . satisfied ( A ) ) ; <nl> <nl> A = Complex_Authority ( 1 , ( ( a , 2 ) ) ( ( b , 1 ) ) , ) ; <nl> - BOOST_CHECK ( MakeAuthorityChecker ( GetNullAuthority , 2 , { a } ) . satisfied ( A ) ) ; <nl> - BOOST_CHECK ( MakeAuthorityChecker ( GetNullAuthority , 2 , { b } ) . satisfied ( A ) ) ; <nl> - BOOST_CHECK ( ! MakeAuthorityChecker ( GetNullAuthority , 2 , { c } ) . satisfied ( A ) ) ; <nl> + BOOST_CHECK ( make_authority_checker ( GetNullAuthority , 2 , { a } ) . satisfied ( A ) ) ; <nl> + BOOST_CHECK ( make_authority_checker ( GetNullAuthority , 2 , { b } ) . satisfied ( A ) ) ; <nl> + BOOST_CHECK ( ! make_authority_checker ( GetNullAuthority , 2 , { c } ) . satisfied ( A ) ) ; <nl> <nl> auto GetCAuthority = [ c_public_key ] ( auto ) { return Complex_Authority ( 1 , ( ( c , 1 ) ) , ) ; } ; <nl> <nl> A = Complex_Authority ( 2 , ( ( a , 2 ) ) ( ( b , 1 ) ) , ( ( " hello " , " world " , 1 ) ) ) ; <nl> { <nl> - auto checker = MakeAuthorityChecker ( GetCAuthority , 2 , { a } ) ; <nl> + auto checker = make_authority_checker ( GetCAuthority , 2 , { a } ) ; <nl> BOOST_CHECK ( checker . satisfied ( A ) ) ; <nl> BOOST_CHECK ( checker . all_keys_used ( ) ) ; <nl> } <nl> { <nl> - auto checker = MakeAuthorityChecker ( GetCAuthority , 2 , { b } ) ; <nl> + auto checker = make_authority_checker ( GetCAuthority , 2 , { b } ) ; <nl> BOOST_CHECK ( ! checker . satisfied ( A ) ) ; <nl> BOOST_CHECK_EQUAL ( checker . used_keys ( ) . size ( ) , 0 ) ; <nl> BOOST_CHECK_EQUAL ( checker . unused_keys ( ) . size ( ) , 1 ) ; <nl> BOOST_CHECK_EQUAL ( checker . unused_keys ( ) . count ( b ) , 1 ) ; <nl> } <nl> { <nl> - auto checker = MakeAuthorityChecker ( GetCAuthority , 2 , { c } ) ; <nl> + auto checker = make_authority_checker ( GetCAuthority , 2 , { c } ) ; <nl> BOOST_CHECK ( ! checker . satisfied ( A ) ) ; <nl> BOOST_CHECK_EQUAL ( checker . used_keys ( ) . size ( ) , 0 ) ; <nl> BOOST_CHECK_EQUAL ( checker . unused_keys ( ) . size ( ) , 1 ) ; <nl> BOOST_CHECK_EQUAL ( checker . unused_keys ( ) . count ( c ) , 1 ) ; <nl> } <nl> { <nl> - auto checker = MakeAuthorityChecker ( GetCAuthority , 2 , { b , c } ) ; <nl> + auto checker = make_authority_checker ( GetCAuthority , 2 , { b , c } ) ; <nl> BOOST_CHECK ( checker . satisfied ( A ) ) ; <nl> BOOST_CHECK ( checker . all_keys_used ( ) ) ; <nl> BOOST_CHECK_EQUAL ( checker . used_keys ( ) . size ( ) , 2 ) ; <nl> BOOST_AUTO_TEST_CASE ( authority_checker ) <nl> BOOST_CHECK_EQUAL ( checker . used_keys ( ) . count ( c ) , 1 ) ; <nl> } <nl> { <nl> - auto checker = MakeAuthorityChecker ( GetCAuthority , 2 , { b , c , a } ) ; <nl> + auto checker = make_authority_checker ( GetCAuthority , 2 , { b , c , a } ) ; <nl> BOOST_CHECK ( checker . satisfied ( A ) ) ; <nl> BOOST_CHECK ( ! checker . all_keys_used ( ) ) ; <nl> BOOST_CHECK_EQUAL ( checker . used_keys ( ) . size ( ) , 1 ) ; <nl> BOOST_AUTO_TEST_CASE ( authority_checker ) <nl> } <nl> <nl> A = Complex_Authority ( 2 , ( ( a , 1 ) ) ( ( b , 1 ) ) , ( ( " hello " , " world " , 1 ) ) ) ; <nl> - BOOST_CHECK ( ! MakeAuthorityChecker ( GetCAuthority , 2 , { a } ) . satisfied ( A ) ) ; <nl> - BOOST_CHECK ( ! MakeAuthorityChecker ( GetCAuthority , 2 , { b } ) . satisfied ( A ) ) ; <nl> - BOOST_CHECK ( ! MakeAuthorityChecker ( GetCAuthority , 2 , { c } ) . satisfied ( A ) ) ; <nl> - BOOST_CHECK ( MakeAuthorityChecker ( GetCAuthority , 2 , { a , b } ) . satisfied ( A ) ) ; <nl> - BOOST_CHECK ( MakeAuthorityChecker ( GetCAuthority , 2 , { b , c } ) . satisfied ( A ) ) ; <nl> - BOOST_CHECK ( MakeAuthorityChecker ( GetCAuthority , 2 , { a , c } ) . satisfied ( A ) ) ; <nl> + BOOST_CHECK ( ! make_authority_checker ( GetCAuthority , 2 , { a } ) . satisfied ( A ) ) ; <nl> + BOOST_CHECK ( ! make_authority_checker ( GetCAuthority , 2 , { b } ) . satisfied ( A ) ) ; <nl> + BOOST_CHECK ( ! make_authority_checker ( GetCAuthority , 2 , { c } ) . satisfied ( A ) ) ; <nl> + BOOST_CHECK ( make_authority_checker ( GetCAuthority , 2 , { a , b } ) . satisfied ( A ) ) ; <nl> + BOOST_CHECK ( make_authority_checker ( GetCAuthority , 2 , { b , c } ) . satisfied ( A ) ) ; <nl> + BOOST_CHECK ( make_authority_checker ( GetCAuthority , 2 , { a , c } ) . satisfied ( A ) ) ; <nl> { <nl> - auto checker = MakeAuthorityChecker ( GetCAuthority , 2 , { a , b , c } ) ; <nl> + auto checker = make_authority_checker ( GetCAuthority , 2 , { a , b , c } ) ; <nl> BOOST_CHECK ( checker . satisfied ( A ) ) ; <nl> BOOST_CHECK ( ! checker . all_keys_used ( ) ) ; <nl> BOOST_CHECK_EQUAL ( checker . used_keys ( ) . size ( ) , 2 ) ; <nl> BOOST_AUTO_TEST_CASE ( authority_checker ) <nl> } <nl> <nl> A = Complex_Authority ( 2 , ( ( a , 1 ) ) ( ( b , 1 ) ) , ( ( " hello " , " world " , 2 ) ) ) ; <nl> - BOOST_CHECK ( MakeAuthorityChecker ( GetCAuthority , 2 , { a , b } ) . satisfied ( A ) ) ; <nl> - BOOST_CHECK ( MakeAuthorityChecker ( GetCAuthority , 2 , { c } ) . satisfied ( A ) ) ; <nl> - BOOST_CHECK ( ! MakeAuthorityChecker ( GetCAuthority , 2 , { a } ) . satisfied ( A ) ) ; <nl> - BOOST_CHECK ( ! MakeAuthorityChecker ( GetCAuthority , 2 , { b } ) . satisfied ( A ) ) ; <nl> + BOOST_CHECK ( make_authority_checker ( GetCAuthority , 2 , { a , b } ) . satisfied ( A ) ) ; <nl> + BOOST_CHECK ( make_authority_checker ( GetCAuthority , 2 , { c } ) . satisfied ( A ) ) ; <nl> + BOOST_CHECK ( ! make_authority_checker ( GetCAuthority , 2 , { a } ) . satisfied ( A ) ) ; <nl> + BOOST_CHECK ( ! make_authority_checker ( GetCAuthority , 2 , { b } ) . satisfied ( A ) ) ; <nl> { <nl> - auto checker = MakeAuthorityChecker ( GetCAuthority , 2 , { a , b , c } ) ; <nl> + auto checker = make_authority_checker ( GetCAuthority , 2 , { a , b , c } ) ; <nl> BOOST_CHECK ( checker . satisfied ( A ) ) ; <nl> BOOST_CHECK ( ! checker . all_keys_used ( ) ) ; <nl> BOOST_CHECK_EQUAL ( checker . used_keys ( ) . size ( ) , 1 ) ; <nl> BOOST_AUTO_TEST_CASE ( authority_checker ) <nl> <nl> A = Complex_Authority ( 5 , ( ( a , 2 ) ) ( ( b , 2 ) ) ( ( c , 2 ) ) , ( ( " top " , " top " , 5 ) ) ) ; <nl> { <nl> - auto checker = MakeAuthorityChecker ( GetAuthority , 2 , { d , e } ) ; <nl> + auto checker = make_authority_checker ( GetAuthority , 2 , { d , e } ) ; <nl> BOOST_CHECK ( checker . satisfied ( A ) ) ; <nl> BOOST_CHECK ( checker . all_keys_used ( ) ) ; <nl> } <nl> { <nl> - auto checker = MakeAuthorityChecker ( GetAuthority , 2 , { a , b , c , d , e } ) ; <nl> + auto checker = make_authority_checker ( GetAuthority , 2 , { a , b , c , d , e } ) ; <nl> BOOST_CHECK ( checker . satisfied ( A ) ) ; <nl> BOOST_CHECK ( ! checker . all_keys_used ( ) ) ; <nl> BOOST_CHECK_EQUAL ( checker . used_keys ( ) . size ( ) , 2 ) ; <nl> BOOST_AUTO_TEST_CASE ( authority_checker ) <nl> BOOST_CHECK_EQUAL ( checker . used_keys ( ) . count ( e ) , 1 ) ; <nl> } <nl> { <nl> - auto checker = MakeAuthorityChecker ( GetAuthority , 2 , { a , b , c , e } ) ; <nl> + auto checker = make_authority_checker ( GetAuthority , 2 , { a , b , c , e } ) ; <nl> BOOST_CHECK ( checker . satisfied ( A ) ) ; <nl> BOOST_CHECK ( ! checker . all_keys_used ( ) ) ; <nl> BOOST_CHECK_EQUAL ( checker . used_keys ( ) . size ( ) , 3 ) ; <nl> BOOST_AUTO_TEST_CASE ( authority_checker ) <nl> BOOST_CHECK_EQUAL ( checker . used_keys ( ) . count ( b ) , 1 ) ; <nl> BOOST_CHECK_EQUAL ( checker . used_keys ( ) . count ( c ) , 1 ) ; <nl> } <nl> - BOOST_CHECK ( MakeAuthorityChecker ( GetAuthority , 1 , { a , b , c } ) . satisfied ( A ) ) ; <nl> + BOOST_CHECK ( make_authority_checker ( GetAuthority , 1 , { a , b , c } ) . satisfied ( A ) ) ; <nl> / / Fails due to short recursion depth limit <nl> - BOOST_CHECK ( ! MakeAuthorityChecker ( GetAuthority , 1 , { d , e } ) . satisfied ( A ) ) ; <nl> + BOOST_CHECK ( ! make_authority_checker ( GetAuthority , 1 , { d , e } ) . satisfied ( A ) ) ; <nl> <nl> A = Complex_Authority ( 2 , ( ( a , 1 ) ) ( ( b , 1 ) ) ( ( c , 1 ) ) , ) ; <nl> auto B = Complex_Authority ( 1 , ( ( b , 1 ) ) ( ( c , 1 ) ) , ) ; <nl> { <nl> - auto checker = MakeAuthorityChecker ( GetNullAuthority , 2 , { a , b , c } ) ; <nl> + auto checker = make_authority_checker ( GetNullAuthority , 2 , { a , b , c } ) ; <nl> BOOST_CHECK ( validate ( A ) ) ; <nl> BOOST_CHECK ( validate ( B ) ) ; <nl> BOOST_CHECK ( checker . satisfied ( A ) ) ; <nl> mmm a / tests / tests / native_contract_tests . cpp <nl> ppp b / tests / tests / native_contract_tests . cpp <nl> BOOST_FIXTURE_TEST_CASE ( producer_voting_1 , testing_fixture ) { <nl> { <nl> BOOST_CHECK_EQUAL ( chain . get_approved_producers ( " bob " ) . count ( " joe " ) , 1 ) ; <nl> BOOST_CHECK_EQUAL ( chain . get_staked_balance ( " bob " ) , asset ( 100 ) ) ; <nl> - const auto & joeVotes = chain_db . get < native : : eosio : : ProducerVotesObject , native : : eosio : : byOwnerName > ( " joe " ) ; <nl> - BOOST_CHECK_EQUAL ( joeVotes . getVotes ( ) , chain . get_staked_balance ( " bob " ) ) ; <nl> + const auto & joeVotes = chain_db . get < native : : eosio : : producer_votes_object , native : : eosio : : by_owner_name > ( " joe " ) ; <nl> + BOOST_CHECK_EQUAL ( joeVotes . get_votes ( ) , chain . get_staked_balance ( " bob " ) ) ; <nl> } <nl> <nl> / / OK , let ' s go to the next round <nl> BOOST_FIXTURE_TEST_CASE ( producer_voting_1 , testing_fixture ) { <nl> <nl> { <nl> BOOST_CHECK_EQUAL ( chain . get_approved_producers ( " bob " ) . count ( " joe " ) , 0 ) ; <nl> - const auto & joeVotes = chain_db . get < native : : eosio : : ProducerVotesObject , native : : eosio : : byOwnerName > ( " joe " ) ; <nl> - BOOST_CHECK_EQUAL ( joeVotes . getVotes ( ) , 0 ) ; <nl> + const auto & joeVotes = chain_db . get < native : : eosio : : producer_votes_object , native : : eosio : : by_owner_name > ( " joe " ) ; <nl> + BOOST_CHECK_EQUAL ( joeVotes . get_votes ( ) , 0 ) ; <nl> } <nl> } FC_LOG_AND_RETHROW ( ) <nl> } <nl> BOOST_FIXTURE_TEST_CASE ( producer_voting_2 , testing_fixture ) { <nl> { <nl> BOOST_CHECK_EQUAL ( chain . get_approved_producers ( " bob " ) . count ( " joe " ) , 1 ) ; <nl> BOOST_CHECK_EQUAL ( chain . get_staked_balance ( " bob " ) , asset ( 100 ) ) ; <nl> - const auto & joeVotes = chain_db . get < native : : eosio : : ProducerVotesObject , native : : eosio : : byOwnerName > ( " joe " ) ; <nl> - BOOST_CHECK_EQUAL ( joeVotes . getVotes ( ) , chain . get_staked_balance ( " bob " ) ) ; <nl> + const auto & joeVotes = chain_db . get < native : : eosio : : producer_votes_object , native : : eosio : : by_owner_name > ( " joe " ) ; <nl> + BOOST_CHECK_EQUAL ( joeVotes . get_votes ( ) , chain . get_staked_balance ( " bob " ) ) ; <nl> } <nl> <nl> / / Produce blocks up to , but not including , the last block in the round <nl> BOOST_FIXTURE_TEST_CASE ( producer_voting_2 , testing_fixture ) { <nl> { <nl> BOOST_CHECK_EQUAL ( chain . get_approved_producers ( " bob " ) . count ( " joe " ) , 1 ) ; <nl> BOOST_CHECK_EQUAL ( chain . get_staked_balance ( " bob " ) , asset ( 100 ) ) ; <nl> - const auto & joeVotes = chain_db . get < native : : eosio : : ProducerVotesObject , native : : eosio : : byOwnerName > ( " joe " ) ; <nl> - BOOST_CHECK_EQUAL ( joeVotes . getVotes ( ) , chain . get_staked_balance ( " bob " ) ) ; <nl> + const auto & joeVotes = chain_db . get < native : : eosio : : producer_votes_object , native : : eosio : : by_owner_name > ( " joe " ) ; <nl> + BOOST_CHECK_EQUAL ( joeVotes . get_votes ( ) , chain . get_staked_balance ( " bob " ) ) ; <nl> } <nl> <nl> / / OK , let ' s go to the next round <nl> BOOST_FIXTURE_TEST_CASE ( producer_voting_2 , testing_fixture ) { <nl> <nl> { <nl> BOOST_CHECK_EQUAL ( chain . get_approved_producers ( " bob " ) . count ( " joe " ) , 0 ) ; <nl> - const auto & joeVotes = chain_db . get < native : : eosio : : ProducerVotesObject , native : : eosio : : byOwnerName > ( " joe " ) ; <nl> - BOOST_CHECK_EQUAL ( joeVotes . getVotes ( ) , 0 ) ; <nl> + const auto & joeVotes = chain_db . get < native : : eosio : : producer_votes_object , native : : eosio : : by_owner_name > ( " joe " ) ; <nl> + BOOST_CHECK_EQUAL ( joeVotes . get_votes ( ) , 0 ) ; <nl> } <nl> } FC_LOG_AND_RETHROW ( ) <nl> } <nl> BOOST_FIXTURE_TEST_CASE ( producer_proxy_voting , testing_fixture ) { <nl> { <nl> BOOST_CHECK_EQUAL ( chain . get_approved_producers ( " proxy " ) . count ( " producer " ) , 1 ) ; <nl> BOOST_CHECK_EQUAL ( chain . get_staked_balance ( " stakeholder " ) , asset ( 100 ) ) ; <nl> - const auto & producerVotes = chain_db . get < native : : eosio : : ProducerVotesObject , native : : eosio : : byOwnerName > ( " producer " ) ; <nl> - BOOST_CHECK_EQUAL ( producerVotes . getVotes ( ) , chain . get_staked_balance ( " stakeholder " ) ) ; <nl> + const auto & producerVotes = chain_db . get < native : : eosio : : producer_votes_object , native : : eosio : : by_owner_name > ( " producer " ) ; <nl> + BOOST_CHECK_EQUAL ( producerVotes . get_votes ( ) , chain . get_staked_balance ( " stakeholder " ) ) ; <nl> } <nl> <nl> / / OK , let ' s go to the next round <nl> BOOST_FIXTURE_TEST_CASE ( producer_proxy_voting , testing_fixture ) { <nl> <nl> { <nl> BOOST_CHECK_EQUAL ( chain . get_approved_producers ( " proxy " ) . count ( " producer " ) , 0 ) ; <nl> - const auto & producerVotes = chain_db . get < native : : eosio : : ProducerVotesObject , native : : eosio : : byOwnerName > ( " producer " ) ; <nl> - BOOST_CHECK_EQUAL ( producerVotes . getVotes ( ) , 0 ) ; <nl> + const auto & producerVotes = chain_db . get < native : : eosio : : producer_votes_object , native : : eosio : : by_owner_name > ( " producer " ) ; <nl> + BOOST_CHECK_EQUAL ( producerVotes . get_votes ( ) , 0 ) ; <nl> } <nl> } ; <nl> <nl> BOOST_FIXTURE_TEST_CASE ( auth_tests , testing_fixture ) { <nl> / / Abort if this gets run ; it shouldn ' t get run in this test <nl> auto PermissionToAuthority = [ ] ( auto ) - > authority { abort ( ) ; } ; <nl> <nl> - auto tradingChecker = MakeAuthorityChecker ( PermissionToAuthority , 2 , { k1_public_key } ) ; <nl> - auto spendingChecker = MakeAuthorityChecker ( PermissionToAuthority , 2 , { k2_public_key } ) ; <nl> + auto tradingChecker = make_authority_checker ( PermissionToAuthority , 2 , { k1_public_key } ) ; <nl> + auto spendingChecker = make_authority_checker ( PermissionToAuthority , 2 , { k2_public_key } ) ; <nl> <nl> BOOST_CHECK ( tradingChecker . satisfied ( trading - > auth ) ) ; <nl> BOOST_CHECK ( spendingChecker . satisfied ( spending - > auth ) ) ; <nl>
Some additional renaming . A few that were missed before .
EOSIO/eos
1866c47042e6c6f68e7a15f3f80e99e035278f6f
2017-11-09T16:09:43Z
mmm a / hphp / hack / src / typing / typing . ml <nl> ppp b / hphp / hack / src / typing / typing . ml <nl> and new_object <nl> ( env , tcid , tal , tel , typed_unpack_element , new_ty , ctor_fty ) <nl> <nl> and attributes_check_def env kind attrs = <nl> - Typing_attributes . check_def env new_object kind attrs <nl> + ( * TODO ( coeffects ) change to mixed after changing those constructors to pure * ) <nl> + let defaults = MakeType . default_capability in <nl> + let ( env , _ ) = <nl> + Typing_lenv . stash_and_do env ( Env . all_continuations env ) ( fun env - > <nl> + let env = <nl> + fst @ @ Typing_coeffects . register_capabilities env defaults defaults <nl> + in <nl> + ( Typing_attributes . check_def env new_object kind attrs , ( ) ) ) <nl> + in <nl> + env <nl> <nl> ( * * Get class infos for a class expression ( e . g . ` parent ` , ` self ` or <nl> regular classnames ) - which might resolve to a union or intersection <nl> new file mode 100644 <nl> index 00000000000 . . eaadfcaad7b <nl> mmm / dev / null <nl> ppp b / hphp / hack / test / typecheck / coeffects / ctor . php <nl> <nl> + < ? hh / / strict <nl> + < < file : __EnableUnstableFeatures ( ' coeffects_provisional ' ) > > <nl> + <nl> + class NoCtor implements \ HH \ FunctionAttribute { <nl> + public int $ x = 42 ; <nl> + } <nl> + <nl> + function call_implicitly_pure_ctor ( ) [ ] : NoCtor { <nl> + return new NoCtor ( ) ; / / ok <nl> + } <nl> + <nl> + class WithPureCtor implements \ HH \ FunctionAttribute { <nl> + public function __construct ( ) [ ] { } <nl> + } <nl> + <nl> + function call_explicitly_pure_ctor ( ) [ ] : WithPureCtor { <nl> + return new WithPureCtor ( ) ; / / ok <nl> + } <nl> + <nl> + class WithImpureCtor implements \ HH \ FunctionAttribute { <nl> + public function __construct ( ) [ output ] { } <nl> + } <nl> + <nl> + function call_impure_ctor_bad ( ) [ ] : WithImpureCtor { <nl> + return new WithImpureCtor ( ) ; / / error <nl> + } <nl> + <nl> + function call_impure_ctor_good ( ) [ output ] : WithImpureCtor { <nl> + return new WithImpureCtor ( ) ; / / ok <nl> + } <nl> + <nl> + < < NoCtor > > <nl> + function attr_no_ctor ( ) : void { } <nl> + <nl> + < < WithPureCtor > > <nl> + function attr_pure_ctor ( ) : void { } <nl> + <nl> + < < WithImpureCtor > > <nl> + function attr_impure_ctor ( ) : void { } <nl> new file mode 100644 <nl> index 00000000000 . . 17865cecaf0 <nl> mmm / dev / null <nl> ppp b / hphp / hack / test / typecheck / coeffects / ctor . php . exp <nl> <nl> + File " ctor . php " , line 25 , characters 14 - 27 : <nl> + This call is not allowed because its coeffects are incompatible with the context ( Typing [ 4390 ] ) <nl> + File " ctor . php " , line 24 , characters 32 - 33 : <nl> + From this declaration , the context of this function body provides the capability set { } <nl> + File " ctor . php " , line 21 , characters 33 - 38 : <nl> + But the function being called requires the capability Output <nl>
type - check constructors in attributes with default capabilities
facebook/hhvm
e940c9dbcf799f71904212d198cd539cd86799c9
2020-12-21T08:25:11Z
mmm a / CMakeLists . txt <nl> ppp b / CMakeLists . txt <nl> configure_file ( " $ { CMAKE_CURRENT_SOURCE_DIR } / OpenCVConfig . cmake . in " " $ { CMAKE_BINA <nl> <nl> if ( UNIX ) <nl> # For a command " FIND_PACKAGE ( FOO ) " , CMake will look at the directory / usr / share | lib / FOO / FOOConfig . cmake , so : <nl> - install ( FILES $ { CMAKE_BINARY_DIR } / unix - install / OpenCVConfig . cmake DESTINATION $ { CMAKE_INSTALL_PREFIX } / share / opencv / ) <nl> + install ( FILES $ { CMAKE_BINARY_DIR } / unix - install / OpenCVConfig . cmake DESTINATION share / opencv / ) <nl> endif ( ) <nl> <nl> # mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> if ( BUILD_PACKAGE ) <nl> <nl> if ( CMAKE_INSTALL_DEBUG_LIBRARIES ) <nl> foreach ( m calib3d core contrib features2d ffmpeg flann gpu highgui imgproc legacy ml objdetect video ) <nl> - install ( FILES $ { CMAKE_BINARY_DIR } / bin / Debug / opencv_ $ { m } $ { OPENCV_DLLVERSION } d . dll <nl> + install ( FILES $ { EXECUTABLE_OUTPUT_PATH } / Debug / opencv_ $ { m } $ { OPENCV_DLLVERSION } d . dll <nl> DESTINATION bin COMPONENT main ) <nl> - install ( FILES $ { CMAKE_BINARY_DIR } / lib / Debug / opencv_ $ { m } $ { OPENCV_DLLVERSION } d . lib <nl> + install ( FILES $ { LIBRARY_OUTPUT_PATH } / Debug / opencv_ $ { m } $ { OPENCV_DLLVERSION } d . lib <nl> DESTINATION lib COMPONENT main ) <nl> endforeach ( ) <nl> endif ( ) <nl> mmm a / OpenCVModule . cmake <nl> ppp b / OpenCVModule . cmake <nl> macro ( define_opencv_module name ) <nl> # Additional target properties <nl> set_target_properties ( $ { the_target } PROPERTIES <nl> DEBUG_POSTFIX " $ { OPENCV_DEBUG_POSTFIX } " <nl> - ARCHIVE_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } / lib / " <nl> - RUNTIME_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } / bin / " <nl> - INSTALL_NAME_DIR " $ { CMAKE_INSTALL_PREFIX } / lib " <nl> + ARCHIVE_OUTPUT_DIRECTORY $ { LIBRARY_OUTPUT_PATH } <nl> + RUNTIME_OUTPUT_DIRECTORY $ { EXECUTABLE_OUTPUT_PATH } <nl> + INSTALL_NAME_DIR lib <nl> ) <nl> <nl> if ( PCHSupport_FOUND AND USE_PRECOMPILED_HEADERS ) <nl> macro ( define_opencv_module name ) <nl> # Additional target properties <nl> set_target_properties ( $ { the_target } PROPERTIES <nl> DEBUG_POSTFIX " $ { OPENCV_DEBUG_POSTFIX } " <nl> - RUNTIME_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } / bin / " <nl> + RUNTIME_OUTPUT_DIRECTORY " $ { EXECUTABLE_OUTPUT_PATH } " <nl> ) <nl> <nl> if ( ENABLE_SOLUTION_FOLDERS ) <nl> mmm a / modules / ffmpeg / CMakeLists . txt <nl> ppp b / modules / ffmpeg / CMakeLists . txt <nl> set_target_properties ( $ { the_target } PROPERTIES <nl> VERSION $ { OPENCV_VERSION } <nl> OUTPUT_NAME " $ { the_target } $ { OPENCV_DLLVERSION } " <nl> DEFINE_SYMBOL " CVAPI_EXPORTS " <nl> - ARCHIVE_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } / lib / " <nl> - RUNTIME_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } / bin / " <nl> + ARCHIVE_OUTPUT_DIRECTORY $ { LIBRARY_OUTPUT_PATH } <nl> + RUNTIME_OUTPUT_DIRECTORY $ { EXECUTABLE_OUTPUT_PATH } <nl> ) <nl> <nl> if ( ENABLE_SOLUTION_FOLDERS ) <nl> mmm a / modules / gpu / CMakeLists . txt <nl> ppp b / modules / gpu / CMakeLists . txt <nl> endif ( ) <nl> # Additional target properties <nl> set_target_properties ( $ { the_target } PROPERTIES <nl> DEBUG_POSTFIX " $ { OPENCV_DEBUG_POSTFIX } " <nl> - ARCHIVE_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } / lib / " <nl> - RUNTIME_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } / bin / " <nl> - INSTALL_NAME_DIR " $ { CMAKE_INSTALL_PREFIX } / lib " <nl> + ARCHIVE_OUTPUT_DIRECTORY $ { LIBRARY_OUTPUT_PATH } <nl> + RUNTIME_OUTPUT_DIRECTORY $ { EXECUTABLE_OUTPUT_PATH } <nl> + INSTALL_NAME_DIR lib <nl> ) <nl> <nl> # Add the required libraries for linking : <nl> if ( BUILD_TESTS AND EXISTS $ { CMAKE_CURRENT_SOURCE_DIR } / test ) <nl> # Additional target properties <nl> set_target_properties ( $ { the_test_target } PROPERTIES <nl> DEBUG_POSTFIX " $ { OPENCV_DEBUG_POSTFIX } " <nl> - RUNTIME_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } / bin / " <nl> + RUNTIME_OUTPUT_DIRECTORY $ { EXECUTABLE_OUTPUT_PATH } <nl> ) <nl> <nl> if ( ENABLE_SOLUTION_FOLDERS ) <nl> mmm a / modules / haartraining / CMakeLists . txt <nl> ppp b / modules / haartraining / CMakeLists . txt <nl> set ( cvhaartraining_lib_src <nl> add_library ( opencv_haartraining_engine STATIC $ { cvhaartraining_lib_src } ) <nl> set_target_properties ( opencv_haartraining_engine PROPERTIES <nl> DEBUG_POSTFIX " $ { OPENCV_DEBUG_POSTFIX } " <nl> - ARCHIVE_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } / lib / " <nl> - RUNTIME_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } / bin / " <nl> - INSTALL_NAME_DIR " $ { CMAKE_INSTALL_PREFIX } / lib " <nl> + ARCHIVE_OUTPUT_DIRECTORY $ { LIBRARY_OUTPUT_PATH } <nl> + RUNTIME_OUTPUT_DIRECTORY $ { EXECUTABLE_OUTPUT_PATH } <nl> + INSTALL_NAME_DIR lib <nl> ) <nl> <nl> if ( NOT ANDROID ) <nl> if ( ENABLE_SOLUTION_FOLDERS ) <nl> set_target_properties ( opencv_haartraining_engine PROPERTIES FOLDER " applications " ) <nl> endif ( ) <nl> <nl> - endif ( ) <nl> \ No newline at end of file <nl> + endif ( ) <nl> mmm a / modules / highgui / CMakeLists . txt <nl> ppp b / modules / highgui / CMakeLists . txt <nl> set_target_properties ( $ { the_target } PROPERTIES <nl> # Additional target properties <nl> set_target_properties ( $ { the_target } PROPERTIES <nl> DEBUG_POSTFIX " $ { OPENCV_DEBUG_POSTFIX } " <nl> - ARCHIVE_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } / lib / " <nl> - RUNTIME_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } / bin / " <nl> - INSTALL_NAME_DIR " $ { CMAKE_INSTALL_PREFIX } / lib " <nl> + ARCHIVE_OUTPUT_DIRECTORY $ { LIBRARY_OUTPUT_PATH } <nl> + RUNTIME_OUTPUT_DIRECTORY $ { EXECUTABLE_OUTPUT_PATH } <nl> + INSTALL_NAME_DIR lib <nl> LINK_INTERFACE_LIBRARIES " " <nl> ) <nl> <nl> mmm a / modules / stitching / CMakeLists . txt <nl> ppp b / modules / stitching / CMakeLists . txt <nl> add_executable ( $ { the_target } $ { stitching_files } ) <nl> add_dependencies ( $ { the_target } $ { stitching_libs } ) <nl> set_target_properties ( $ { the_target } PROPERTIES <nl> DEBUG_POSTFIX " $ { OPENCV_DEBUG_POSTFIX } " <nl> - ARCHIVE_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } / lib / " <nl> - RUNTIME_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } / bin / " <nl> - INSTALL_NAME_DIR " $ { CMAKE_INSTALL_PREFIX } / lib " <nl> + ARCHIVE_OUTPUT_DIRECTORY $ { LIBRARY_OUTPUT_PATH } <nl> + RUNTIME_OUTPUT_DIRECTORY $ { EXECUTABLE_OUTPUT_PATH } <nl> + INSTALL_NAME_DIR lib <nl> OUTPUT_NAME " opencv_stitching " ) <nl> <nl> if ( ENABLE_SOLUTION_FOLDERS ) <nl> mmm a / modules / traincascade / CMakeLists . txt <nl> ppp b / modules / traincascade / CMakeLists . txt <nl> add_executable ( $ { the_target } $ { traincascade_files } ) <nl> add_dependencies ( $ { the_target } $ { traincascade_libs } ) <nl> set_target_properties ( $ { the_target } PROPERTIES <nl> DEBUG_POSTFIX " $ { OPENCV_DEBUG_POSTFIX } " <nl> - ARCHIVE_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } / lib / " <nl> - RUNTIME_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } / bin / " <nl> - INSTALL_NAME_DIR " $ { CMAKE_INSTALL_PREFIX } / lib " <nl> + ARCHIVE_OUTPUT_DIRECTORY $ { LIBRARY_OUTPUT_PATH } <nl> + RUNTIME_OUTPUT_DIRECTORY $ { EXECUTABLE_OUTPUT_PATH } <nl> + INSTALL_NAME_DIR lib <nl> OUTPUT_NAME " opencv_traincascade " ) <nl> <nl> if ( ENABLE_SOLUTION_FOLDERS ) <nl>
Making the install and lib , bin directories consistent .
opencv/opencv
76538fbe6bba2ab397c5511d70362125beb3bbc6
2011-05-30T22:13:32Z
mmm a / tensorflow / python / data / experimental / kernel_tests / serialization / BUILD <nl> ppp b / tensorflow / python / data / experimental / kernel_tests / serialization / BUILD <nl> py_test ( <nl> <nl> py_test ( <nl> name = " choose_fastest_branch_dataset_serialization_test " , <nl> - size = " small " , <nl> + size = " medium " , <nl> srcs = [ " choose_fastest_branch_dataset_serialization_test . py " ] , <nl> srcs_version = " PY2AND3 " , <nl> tags = [ <nl>
Internal change
tensorflow/tensorflow
b3363d26c0832d05dfe907191d2640cdb1499e55
2019-03-14T01:05:38Z
mmm a / tensorflow / tools / ci_build / install / install_pip_packages . sh <nl> ppp b / tensorflow / tools / ci_build / install / install_pip_packages . sh <nl> pip2 install grpcio <nl> pip3 install grpcio <nl> <nl> # Eager execution needs autograd : <nl> - pip2 install - - upgrade autograd <nl> - pip3 install - - upgrade autograd <nl> + pip2 install - - upgrade autograd > = 1 . 1 . 12 <nl> + pip3 install - - upgrade autograd > = 1 . 1 . 12 <nl>
Bump the version of autograd
tensorflow/tensorflow
23542421a3dd8869ae3f30a0375e76b0888347c2
2017-08-24T00:46:49Z
mmm a / third_party / abseil - cpp <nl> ppp b / third_party / abseil - cpp <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit 308ce31528a7edfa39f5f6d36142278a0ae1bf45 <nl> + Subproject commit cc4bed2d74f7c8717e31f9579214ab52a9c9c610 <nl>
submodule update
grpc/grpc
3f3da2e23f32e640ab4e8c71eed49ffedc6c0bf3
2019-02-26T18:42:18Z
mmm a / buildscripts / bb . py <nl> ppp b / buildscripts / bb . py <nl> def checkOk ( ) : <nl> <nl> m = " v " + m [ 0 ] <nl> print ( m ) <nl> - print ( " excpted version [ " + m + " ] " ) <nl> + print ( " expected version [ " + m + " ] " ) <nl> <nl> from subprocess import Popen , PIPE <nl> diff = Popen ( [ " git " , " diff " , " origin / v1 . 2 " ] , stdout = PIPE ) . communicate ( ) [ 0 ] <nl>
Merge pull request from cathoderay / patch - 1
mongodb/mongo
c270ddb2bf3c81c065cc3c9df6d9ce9479837064
2012-01-16T20:45:22Z
mmm a / hphp / runtime / vm / jit / translator . cpp <nl> ppp b / hphp / runtime / vm / jit / translator . cpp <nl> Translator : : translateRegion ( const RegionDesc & region , <nl> <nl> skipTrans = false ; <nl> <nl> - / / Insert a fallthrough jump <nl> - if ( ht . genMode ( ) = = IRGenMode : : CFG & & <nl> - i = = block - > length ( ) - 1 & & block ! = blocks . back ( ) ) { <nl> + / / In CFG mode , insert a fallthrough jump at the end of each block . <nl> + if ( ht . genMode ( ) = = IRGenMode : : CFG & & i = = block - > length ( ) - 1 ) { <nl> if ( instrAllowsFallThru ( inst . op ( ) ) ) { <nl> auto nextOffset = inst . nextOffset ! = kInvalidOffset <nl> ? inst . nextOffset <nl> Translator : : translateRegion ( const RegionDesc & region , <nl> ht . prepareForSideExit ( ) ; <nl> } <nl> ht . endBlock ( nextOffset , inst . nextIsMerge ) ; <nl> - } else if ( isRet ( inst . op ( ) ) | | inst . op ( ) = = OpNativeImpl ) { <nl> + } else if ( b < blocks . size ( ) - 1 & & <nl> + ( isRet ( inst . op ( ) ) | | inst . op ( ) = = OpNativeImpl ) ) { <nl> / / " Fallthrough " from inlined return to the next block <nl> ht . endBlock ( blocks [ b + 1 ] - > start ( ) . offset ( ) , inst . nextIsMerge ) ; <nl> } <nl>
Fix fall - through jump for the last region block
facebook/hhvm
62ddc5c147f3bb8b63c2ef19efe7aeaba948427c
2014-09-04T05:00:18Z
mmm a / scripts / eosio_build . sh <nl> ppp b / scripts / eosio_build . sh <nl> if [ [ ! - z $ CMAKE_CURRENT_VERSION ] ] & & [ [ $ ( echo $ CURRENT_CMAKE_VERSION | awk <nl> export CMAKE = <nl> if [ [ $ ARCH = = ' Darwin ' ] ] ; then <nl> echo " $ { COLOR_RED } The currently installed cmake version ( $ CMAKE_CURRENT_VERSION ) is less than the required version ( $ CMAKE_REQUIRED_VERSION ) . Cannot proceed . " <nl> - exit <nl> + exit 1 <nl> else <nl> echo " $ { COLOR_YELLOW } The currently installed cmake version ( $ CMAKE_CURRENT_VERSION ) is less than the required version ( $ CMAKE_REQUIRED_VERSION ) . We will be installing $ CMAKE_VERSION . $ { COLOR_NC } " <nl> fi <nl>
exit 1
EOSIO/eos
cdcfdb6784cafe3089234b3779981fa3db89651d
2019-06-28T19:16:42Z
mmm a / src / mongo / db / repl / topology_coordinator_impl . cpp <nl> ppp b / src / mongo / db / repl / topology_coordinator_impl . cpp <nl> namespace { <nl> BSONObjBuilder * response , <nl> Status * result ) { <nl> <nl> - if ( ! _currentConfig . isInitialized ( ) ) { <nl> + if ( _selfIndex = = - 1 ) { <nl> * result = Status ( ErrorCodes : : ReplicaSetNotFound , <nl> " Cannot participate in elections because not initialized " ) ; <nl> return ; <nl> namespace { <nl> " Our set name of " < < ourSetName < < " does not match name " < < rshb < < <nl> " reported by remote node " ) ; <nl> } <nl> - if ( _currentConfig . isInitialized ( ) ) { <nl> + if ( _selfIndex ! = - 1 ) { <nl> invariant ( _currentConfig . getReplSetName ( ) = = args . getSetName ( ) ) ; <nl> if ( args . getSenderId ( ) = = _selfConfig ( ) . getId ( ) ) { <nl> return Status ( ErrorCodes : : BadValue , <nl> namespace { <nl> if ( ! _aMajoritySeemsToBeUp ( ) ) { <nl> return CannotSeeMajority ; <nl> } <nl> + else if ( _selfIndex = = - 1 ) { <nl> + return NotInitialized ; <nl> + } <nl> else if ( _selfConfig ( ) . isArbiter ( ) ) { <nl> return ArbiterIAm ; <nl> } <nl> mmm a / src / mongo / db / repl / topology_coordinator_impl . h <nl> ppp b / src / mongo / db / repl / topology_coordinator_impl . h <nl> namespace repl { <nl> NotSecondary , <nl> NoPriority , <nl> StepDownPeriodActive , <nl> - NoData <nl> + NoData , <nl> + NotInitialized <nl> } ; <nl> <nl> / / Returns the number of heartbeat pings which have occurred . <nl>
SERVER - 15535 Make TopologyCoordinator more resilient to being in state REMOVED
mongodb/mongo
2eb2944b39fc9812b9e6279bd2a924917e6c57d4
2014-10-08T19:22:39Z
mmm a / arangod / RestHandler / RestDocumentHandler . cpp <nl> ppp b / arangod / RestHandler / RestDocumentHandler . cpp <nl> HttpHandler : : status_t RestDocumentHandler : : execute ( ) { <nl> bool RestDocumentHandler : : createDocument ( ) { <nl> vector < string > const & suffix = _request - > suffix ( ) ; <nl> <nl> - if ( suffix . size ( ) ! = 0 ) { <nl> + if ( ! suffix . empty ( ) ) { <nl> generateError ( HttpResponse : : BAD , <nl> TRI_ERROR_HTTP_SUPERFLUOUS_SUFFICES , <nl> " superfluous suffix , expecting " + DOCUMENT_PATH + " ? collection = < identifier > " ) ; <nl> bool RestDocumentHandler : : readSingleDocument ( bool generateBody ) { <nl> vector < string > const & suffix = _request - > suffix ( ) ; <nl> <nl> / / split the document reference <nl> - const string & collection = suffix [ 0 ] ; <nl> - const string & key = suffix [ 1 ] ; <nl> + string const & collection = suffix [ 0 ] ; <nl> + string const & key = suffix [ 1 ] ; <nl> <nl> / / check for an etag <nl> bool isValidRevision ; <nl> - const TRI_voc_rid_t ifNoneRid = extractRevision ( " if - none - match " , 0 , isValidRevision ) ; <nl> + TRI_voc_rid_t const ifNoneRid = extractRevision ( " if - none - match " , 0 , isValidRevision ) ; <nl> if ( ! isValidRevision ) { <nl> generateError ( HttpResponse : : BAD , <nl> TRI_ERROR_HTTP_BAD_PARAMETER , <nl> bool RestDocumentHandler : : readSingleDocument ( bool generateBody ) { <nl> return false ; <nl> } <nl> <nl> - const TRI_voc_rid_t ifRid = extractRevision ( " if - match " , " rev " , isValidRevision ) ; <nl> + TRI_voc_rid_t const ifRid = extractRevision ( " if - match " , " rev " , isValidRevision ) ; <nl> if ( ! isValidRevision ) { <nl> generateError ( HttpResponse : : BAD , <nl> TRI_ERROR_HTTP_BAD_PARAMETER , <nl> bool RestDocumentHandler : : readSingleDocument ( bool generateBody ) { <nl> return false ; <nl> } <nl> <nl> - const TRI_voc_cid_t cid = trx . cid ( ) ; <nl> + TRI_voc_cid_t const cid = trx . cid ( ) ; <nl> TRI_doc_mptr_copy_t mptr ; <nl> <nl> res = trx . read ( & mptr , key ) ; <nl> bool RestDocumentHandler : : readSingleDocument ( bool generateBody ) { <nl> } <nl> <nl> / / generate result <nl> - const TRI_voc_rid_t rid = mptr . _rid ; <nl> + TRI_voc_rid_t const rid = mptr . _rid ; <nl> <nl> if ( ifNoneRid = = 0 ) { <nl> if ( ifRid = = 0 | | ifRid = = rid ) { <nl> bool RestDocumentHandler : : modifyDocument ( bool isPatch ) { <nl> } <nl> <nl> / / split the document reference <nl> - const string & collection = suffix [ 0 ] ; <nl> - const string & key = suffix [ 1 ] ; <nl> + string const & collection = suffix [ 0 ] ; <nl> + string const & key = suffix [ 1 ] ; <nl> <nl> TRI_json_t * json = parseJsonBody ( ) ; <nl> <nl> if ( ! TRI_IsArrayJson ( json ) ) { <nl> generateTransactionError ( collection , TRI_ERROR_ARANGO_DOCUMENT_TYPE_INVALID ) ; <nl> - if ( json ! = 0 ) { <nl> + if ( json ! = nullptr ) { <nl> TRI_FreeJson ( TRI_UNKNOWN_MEM_ZONE , json ) ; <nl> } <nl> return false ; <nl> bool RestDocumentHandler : : modifyDocument ( bool isPatch ) { <nl> <nl> / / extract the revision <nl> bool isValidRevision ; <nl> - const TRI_voc_rid_t revision = extractRevision ( " if - match " , " rev " , isValidRevision ) ; <nl> + TRI_voc_rid_t const revision = extractRevision ( " if - match " , " rev " , isValidRevision ) ; <nl> if ( ! isValidRevision ) { <nl> generateError ( HttpResponse : : BAD , <nl> TRI_ERROR_HTTP_BAD_PARAMETER , <nl> " invalid revision number " ) ; <nl> - if ( json ! = 0 ) { <nl> + if ( json ! = nullptr ) { <nl> TRI_FreeJson ( TRI_UNKNOWN_MEM_ZONE , json ) ; <nl> } <nl> return false ; <nl> } <nl> <nl> / / extract or chose the update policy <nl> - const TRI_doc_update_policy_e policy = extractUpdatePolicy ( ) ; <nl> - const bool waitForSync = extractWaitForSync ( ) ; <nl> + TRI_doc_update_policy_e const policy = extractUpdatePolicy ( ) ; <nl> + bool const waitForSync = extractWaitForSync ( ) ; <nl> <nl> if ( ServerState : : instance ( ) - > isCoordinator ( ) ) { <nl> / / json will be freed inside <nl> bool RestDocumentHandler : : modifyDocument ( bool isPatch ) { <nl> return false ; <nl> } <nl> <nl> - const TRI_voc_cid_t cid = trx . cid ( ) ; <nl> + TRI_voc_cid_t const cid = trx . cid ( ) ; <nl> TRI_voc_rid_t rid = 0 ; <nl> TRI_document_collection_t * document = trx . documentCollection ( ) ; <nl> TRI_ASSERT ( document ! = nullptr ) ; <nl> TRI_shaper_t * shaper = document - > getShaper ( ) ; / / PROTECTED by trx here <nl> <nl> - string const cidString = StringUtils : : itoa ( document - > _info . _planId ) ; <nl> + string const & & cidString = StringUtils : : itoa ( document - > _info . _planId ) ; <nl> <nl> if ( trx . orderBarrier ( trx . trxCollection ( ) ) = = nullptr ) { <nl> generateTransactionError ( collection , TRI_ERROR_OUT_OF_MEMORY ) ; <nl> bool RestDocumentHandler : : modifyDocument ( bool isPatch ) { <nl> TRI_FreeJson ( shaper - > _memoryZone , old ) ; <nl> TRI_FreeJson ( TRI_UNKNOWN_MEM_ZONE , json ) ; <nl> <nl> - if ( patchedJson = = 0 ) { <nl> + if ( patchedJson = = nullptr ) { <nl> trx . abort ( ) ; <nl> generateTransactionError ( collection , TRI_ERROR_OUT_OF_MEMORY ) ; <nl> <nl> bool RestDocumentHandler : : modifyDocument ( bool isPatch ) { <nl> return false ; <nl> } <nl> <nl> - if ( old ! = 0 ) { <nl> + if ( old ! = nullptr ) { <nl> TRI_FreeJson ( shaper - > _memoryZone , old ) ; <nl> } <nl> } <nl> bool RestDocumentHandler : : deleteDocument ( ) { <nl> } <nl> <nl> / / split the document reference <nl> - const string & collection = suffix [ 0 ] ; <nl> - const string & key = suffix [ 1 ] ; <nl> + string const & collection = suffix [ 0 ] ; <nl> + string const & key = suffix [ 1 ] ; <nl> <nl> / / extract the revision <nl> bool isValidRevision ; <nl> - const TRI_voc_rid_t revision = extractRevision ( " if - match " , " rev " , isValidRevision ) ; <nl> + TRI_voc_rid_t const revision = extractRevision ( " if - match " , " rev " , isValidRevision ) ; <nl> if ( ! isValidRevision ) { <nl> generateError ( HttpResponse : : BAD , <nl> TRI_ERROR_HTTP_BAD_PARAMETER , <nl> bool RestDocumentHandler : : deleteDocument ( ) { <nl> } <nl> <nl> / / extract or choose the update policy <nl> - const TRI_doc_update_policy_e policy = extractUpdatePolicy ( ) ; <nl> - const bool waitForSync = extractWaitForSync ( ) ; <nl> + TRI_doc_update_policy_e const policy = extractUpdatePolicy ( ) ; <nl> + bool const waitForSync = extractWaitForSync ( ) ; <nl> <nl> if ( policy = = TRI_DOC_UPDATE_ILLEGAL ) { <nl> generateError ( HttpResponse : : BAD , <nl> bool RestDocumentHandler : : deleteDocument ( ) { <nl> return false ; <nl> } <nl> <nl> - const TRI_voc_cid_t cid = trx . cid ( ) ; <nl> + TRI_voc_cid_t const cid = trx . cid ( ) ; <nl> <nl> TRI_voc_rid_t rid = 0 ; <nl> res = trx . deleteDocument ( key , policy , waitForSync , revision , & rid ) ; <nl> mmm a / arangod / RestHandler / RestVocbaseBaseHandler . cpp <nl> ppp b / arangod / RestHandler / RestVocbaseBaseHandler . cpp <nl> bool RestVocbaseBaseHandler : : checkCreateCollection ( string const & name , <nl> type , <nl> TRI_GetIdServer ( ) ) ; <nl> <nl> - if ( collection = = 0 ) { <nl> + if ( collection = = nullptr ) { <nl> generateTransactionError ( name , TRI_errno ( ) ) ; <nl> return false ; <nl> } <nl> void RestVocbaseBaseHandler : : generate20x ( HttpResponse : : HttpResponseCode respons <nl> string const & collectionName , <nl> TRI_voc_key_t key , <nl> TRI_voc_rid_t rid ) { <nl> - string const handle = DocumentHelper : : assembleDocumentId ( collectionName , key ) ; <nl> - string const rev = StringUtils : : itoa ( rid ) ; <nl> + string const & & handle = DocumentHelper : : assembleDocumentId ( collectionName , key ) ; <nl> + string const & & rev = StringUtils : : itoa ( rid ) ; <nl> <nl> _response = createResponse ( responseCode ) ; <nl> _response - > setContentType ( " application / json ; charset = utf - 8 " ) ; <nl> void RestVocbaseBaseHandler : : generateForbidden ( ) { <nl> void RestVocbaseBaseHandler : : generatePreconditionFailed ( string const & collectionName , <nl> TRI_voc_key_t key , <nl> TRI_voc_rid_t rid ) { <nl> - const string rev = StringUtils : : itoa ( rid ) ; <nl> + string const & & rev = StringUtils : : itoa ( rid ) ; <nl> <nl> _response = createResponse ( HttpResponse : : PRECONDITION_FAILED ) ; <nl> _response - > setContentType ( " application / json ; charset = utf - 8 " ) ; <nl> void RestVocbaseBaseHandler : : generatePreconditionFailed ( string const & collectio <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> void RestVocbaseBaseHandler : : generateNotModified ( TRI_voc_rid_t rid ) { <nl> - string const rev = StringUtils : : itoa ( rid ) ; <nl> + string const & & rev = StringUtils : : itoa ( rid ) ; <nl> <nl> _response = createResponse ( HttpResponse : : NOT_MODIFIED ) ; <nl> _response - > setHeader ( " etag " , 4 , " \ " " + rev + " \ " " ) ; <nl> void RestVocbaseBaseHandler : : generateDocument ( SingleCollectionReadOnlyTransacti <nl> CollectionNameResolver const * resolver = trx . resolver ( ) ; <nl> <nl> char const * key = TRI_EXTRACT_MARKER_KEY ( & mptr ) ; / / PROTECTED by trx from above <nl> - string const id = DocumentHelper : : assembleDocumentId ( resolver - > getCollectionName ( cid ) , key ) ; <nl> + string const & & id = DocumentHelper : : assembleDocumentId ( resolver - > getCollectionName ( cid ) , key ) ; <nl> <nl> TRI_json_t augmented ; <nl> TRI_InitArray2Json ( TRI_UNKNOWN_MEM_ZONE , & augmented , 5 ) ; <nl> void RestVocbaseBaseHandler : : generateDocument ( SingleCollectionReadOnlyTransacti <nl> } <nl> <nl> / / convert rid from uint64_t to string <nl> - string const rid = StringUtils : : itoa ( mptr . _rid ) ; <nl> + string const & & rid = StringUtils : : itoa ( mptr . _rid ) ; <nl> TRI_json_t * rev = TRI_CreateString2CopyJson ( TRI_UNKNOWN_MEM_ZONE , rid . c_str ( ) , rid . size ( ) ) ; <nl> <nl> if ( rev ! = nullptr ) { <nl> void RestVocbaseBaseHandler : : generateDocument ( SingleCollectionReadOnlyTransacti <nl> <nl> if ( type = = TRI_DOC_MARKER_KEY_EDGE ) { <nl> TRI_doc_edge_key_marker_t const * marker = static_cast < TRI_doc_edge_key_marker_t const * > ( mptr . getDataPtr ( ) ) ; / / PROTECTED by trx passed from above <nl> - const string from = DocumentHelper : : assembleDocumentId ( resolver - > getCollectionNameCluster ( marker - > _fromCid ) , string ( ( char * ) marker + marker - > _offsetFromKey ) ) ; <nl> - const string to = DocumentHelper : : assembleDocumentId ( resolver - > getCollectionNameCluster ( marker - > _toCid ) , string ( ( char * ) marker + marker - > _offsetToKey ) ) ; <nl> + string const & & from = DocumentHelper : : assembleDocumentId ( resolver - > getCollectionNameCluster ( marker - > _fromCid ) , string ( ( char * ) marker + marker - > _offsetFromKey ) ) ; <nl> + string const & & to = DocumentHelper : : assembleDocumentId ( resolver - > getCollectionNameCluster ( marker - > _toCid ) , string ( ( char * ) marker + marker - > _offsetToKey ) ) ; <nl> <nl> TRI_Insert3ArrayJson ( TRI_UNKNOWN_MEM_ZONE , & augmented , TRI_VOC_ATTRIBUTE_FROM , TRI_CreateString2CopyJson ( TRI_UNKNOWN_MEM_ZONE , from . c_str ( ) , from . size ( ) ) ) ; <nl> TRI_Insert3ArrayJson ( TRI_UNKNOWN_MEM_ZONE , & augmented , TRI_VOC_ATTRIBUTE_TO , TRI_CreateString2CopyJson ( TRI_UNKNOWN_MEM_ZONE , to . c_str ( ) , to . size ( ) ) ) ; <nl> } <nl> else if ( type = = TRI_WAL_MARKER_EDGE ) { <nl> triagens : : wal : : edge_marker_t const * marker = static_cast < triagens : : wal : : edge_marker_t const * > ( mptr . getDataPtr ( ) ) ; / / PROTECTED by trx passed from above <nl> - const string from = DocumentHelper : : assembleDocumentId ( resolver - > getCollectionNameCluster ( marker - > _fromCid ) , string ( ( char * ) marker + marker - > _offsetFromKey ) ) ; <nl> - const string to = DocumentHelper : : assembleDocumentId ( resolver - > getCollectionNameCluster ( marker - > _toCid ) , string ( ( char * ) marker + marker - > _offsetToKey ) ) ; <nl> + string const & & from = DocumentHelper : : assembleDocumentId ( resolver - > getCollectionNameCluster ( marker - > _fromCid ) , string ( ( char * ) marker + marker - > _offsetFromKey ) ) ; <nl> + string const & & to = DocumentHelper : : assembleDocumentId ( resolver - > getCollectionNameCluster ( marker - > _toCid ) , string ( ( char * ) marker + marker - > _offsetToKey ) ) ; <nl> <nl> TRI_Insert3ArrayJson ( TRI_UNKNOWN_MEM_ZONE , & augmented , TRI_VOC_ATTRIBUTE_FROM , TRI_CreateString2CopyJson ( TRI_UNKNOWN_MEM_ZONE , from . c_str ( ) , from . size ( ) ) ) ; <nl> TRI_Insert3ArrayJson ( TRI_UNKNOWN_MEM_ZONE , & augmented , TRI_VOC_ATTRIBUTE_TO , TRI_CreateString2CopyJson ( TRI_UNKNOWN_MEM_ZONE , to . c_str ( ) , to . size ( ) ) ) ; <nl> TRI_voc_rid_t RestVocbaseBaseHandler : : extractRevision ( char const * header , <nl> return rid ; <nl> } <nl> <nl> - if ( parameter ! = 0 ) { <nl> + if ( parameter ! = nullptr ) { <nl> etag = _request - > value ( parameter , found ) ; <nl> <nl> if ( found ) { <nl> bool RestVocbaseBaseHandler : : extractWaitForSync ( ) const { <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> TRI_json_t * RestVocbaseBaseHandler : : parseJsonBody ( ) { <nl> - char * errmsg = 0 ; <nl> + char * errmsg = nullptr ; <nl> TRI_json_t * json = _request - > toJson ( & errmsg ) ; <nl> <nl> - if ( json = = 0 ) { <nl> - if ( errmsg = = 0 ) { <nl> + if ( json = = nullptr ) { <nl> + if ( errmsg = = nullptr ) { <nl> generateError ( HttpResponse : : BAD , <nl> TRI_ERROR_HTTP_CORRUPTED_JSON , <nl> " cannot parse json object " ) ; <nl> TRI_json_t * RestVocbaseBaseHandler : : parseJsonBody ( ) { <nl> TRI_FreeString ( TRI_CORE_MEM_ZONE , errmsg ) ; <nl> } <nl> <nl> - return 0 ; <nl> + return nullptr ; <nl> } <nl> <nl> - TRI_ASSERT ( errmsg = = 0 ) ; <nl> + TRI_ASSERT ( errmsg = = nullptr ) ; <nl> <nl> if ( TRI_HasDuplicateKeyJson ( json ) ) { <nl> generateError ( HttpResponse : : BAD , <nl> TRI_ERROR_HTTP_CORRUPTED_JSON , <nl> " cannot parse json object " ) ; <nl> TRI_FreeJson ( TRI_UNKNOWN_MEM_ZONE , json ) ; <nl> - return 0 ; <nl> + return nullptr ; <nl> } <nl> <nl> return json ; <nl> int RestVocbaseBaseHandler : : parseDocumentId ( CollectionNameResolver const * resol <nl> string const & handle , <nl> TRI_voc_cid_t & cid , <nl> TRI_voc_key_t & key ) { <nl> - vector < string > split ( StringUtils : : split ( handle , TRI_DOCUMENT_HANDLE_SEPARATOR_CHR ) ) ; <nl> + vector < string > & & split ( StringUtils : : split ( handle , TRI_DOCUMENT_HANDLE_SEPARATOR_CHR ) ) ; <nl> <nl> if ( split . size ( ) ! = 2 ) { <nl> return TRI_set_errno ( TRI_ERROR_ARANGO_DOCUMENT_HANDLE_BAD ) ; <nl> mmm a / arangod / Utils / DocumentHelper . cpp <nl> ppp b / arangod / Utils / DocumentHelper . cpp <nl> using namespace triagens : : basics ; <nl> / / / @ brief assemble a document id from a string and a string <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - std : : string DocumentHelper : : assembleDocumentId ( const std : : string & collectionName , <nl> - const std : : string & key ) { <nl> + std : : string DocumentHelper : : assembleDocumentId ( std : : string const & collectionName , <nl> + std : : string const & key ) { <nl> return collectionName + TRI_DOCUMENT_HANDLE_SEPARATOR_STR + key ; <nl> } <nl> <nl> std : : string DocumentHelper : : assembleDocumentId ( const std : : string & collectionNam <nl> / / / @ brief assemble a document id from a string and a char * key <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - std : : string DocumentHelper : : assembleDocumentId ( const std : : string & collectionName , <nl> + std : : string DocumentHelper : : assembleDocumentId ( std : : string const & collectionName , <nl> const TRI_voc_key_t key ) { <nl> if ( key = = 0 ) { <nl> return collectionName + TRI_DOCUMENT_HANDLE_SEPARATOR_STR + " _unknown " ; <nl> std : : string DocumentHelper : : assembleDocumentId ( const std : : string & collectionNam <nl> return collectionName + TRI_DOCUMENT_HANDLE_SEPARATOR_STR + key ; <nl> } <nl> <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief extract the collection id and document key from an id <nl> - / / / TODO : merge with RestVocBaseBaseHandler : : parseDocumentId <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - bool DocumentHelper : : parseDocumentId ( const std : : string & input , <nl> - TRI_voc_cid_t & cid , <nl> - std : : string & key ) { <nl> - size_t pos = input . find ( TRI_DOCUMENT_HANDLE_SEPARATOR_CHR ) ; <nl> - <nl> - if ( pos = = string : : npos ) { <nl> - return false ; <nl> - } <nl> - <nl> - cid = StringUtils : : uint64 ( input . c_str ( ) , pos ) ; <nl> - key = input . substr ( pos + 1 ) ; <nl> - <nl> - if ( key . empty ( ) ) { <nl> - / / empty key <nl> - return false ; <nl> - } <nl> - <nl> - return true ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief extract the collection id and document key from an id <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - bool DocumentHelper : : parseDocumentId ( const char * input , <nl> - TRI_voc_cid_t & cid , <nl> - char * * key ) { <nl> - <nl> - if ( input = = 0 ) { <nl> - return false ; <nl> - } <nl> - <nl> - const char * pos = strchr ( input , TRI_DOCUMENT_HANDLE_SEPARATOR_CHR ) ; <nl> - <nl> - if ( pos = = 0 ) { <nl> - return false ; <nl> - } <nl> - <nl> - cid = StringUtils : : uint64 ( input , pos - input ) ; <nl> - * key = ( char * ) ( pos + 1 ) ; <nl> - <nl> - if ( * * key = = ' \ 0 ' ) { <nl> - / / empty key <nl> - return false ; <nl> - } <nl> - <nl> - return true ; <nl> - } <nl> - <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief extract the collection id and document key from an id <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> bool DocumentHelper : : parseDocumentId ( CollectionNameResolver const & resolver , <nl> - const char * input , <nl> + char const * input , <nl> TRI_voc_cid_t & cid , <nl> char * * key ) { <nl> <nl> - if ( input = = 0 ) { <nl> + if ( input = = nullptr ) { <nl> return false ; <nl> } <nl> <nl> - const char * pos = strchr ( input , TRI_DOCUMENT_HANDLE_SEPARATOR_CHR ) ; <nl> + char const * pos = strchr ( input , TRI_DOCUMENT_HANDLE_SEPARATOR_CHR ) ; <nl> <nl> - if ( pos = = 0 ) { <nl> + if ( pos = = nullptr ) { <nl> return false ; <nl> } <nl> <nl> int DocumentHelper : : getKey ( TRI_json_t const * json , <nl> * key = 0 ; <nl> <nl> / / check type of json <nl> - if ( json = = 0 | | json - > _type ! = TRI_JSON_ARRAY ) { <nl> + if ( ! TRI_IsArrayJson ( json ) ) { <nl> return TRI_ERROR_NO_ERROR ; <nl> } <nl> <nl> / / check if _key is there <nl> - const TRI_json_t * k = TRI_LookupArrayJson ( ( TRI_json_t * ) json , TRI_VOC_ATTRIBUTE_KEY ) ; <nl> + TRI_json_t const * k = TRI_LookupArrayJson ( json , TRI_VOC_ATTRIBUTE_KEY ) ; <nl> <nl> - if ( k = = 0 ) { <nl> + if ( k = = nullptr ) { <nl> return TRI_ERROR_NO_ERROR ; <nl> } <nl> <nl> mmm a / arangod / Utils / DocumentHelper . h <nl> ppp b / arangod / Utils / DocumentHelper . h <nl> namespace triagens { <nl> <nl> private : <nl> <nl> - DocumentHelper ( ) ; <nl> + DocumentHelper ( ) = delete ; <nl> <nl> - ~ DocumentHelper ( ) ; <nl> + ~ DocumentHelper ( ) = delete ; <nl> <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> / / - - SECTION - - public static methods <nl> namespace triagens { <nl> / / / @ brief assemble a document id from a string and a string <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - static std : : string assembleDocumentId ( const std : : string & , <nl> - const std : : string & key ) ; <nl> + static std : : string assembleDocumentId ( std : : string const & , <nl> + std : : string const & key ) ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief assemble a document id from a string and a char * key <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - static std : : string assembleDocumentId ( const std : : string & , <nl> + static std : : string assembleDocumentId ( std : : string const & , <nl> const TRI_voc_key_t ) ; <nl> <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief extract the collection id and document key from an id <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - static bool parseDocumentId ( const std : : string & , <nl> - TRI_voc_cid_t & , <nl> - std : : string & ) ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief extract the collection id and document key from an id <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - static bool parseDocumentId ( const char * , <nl> - TRI_voc_cid_t & , <nl> - char * * ) ; <nl> - <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief extract the collection id and document key from an id <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> static bool parseDocumentId ( triagens : : arango : : CollectionNameResolver const & , <nl> - const char * , <nl> + char const * , <nl> TRI_voc_cid_t & , <nl> char * * ) ; <nl> <nl> new file mode 100644 <nl> index 00000000000 . . 31742d756dc <nl> mmm / dev / null <nl> ppp b / arangod / Utils / V8ResolverGuard . h <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief V8 collection name resolver guard <nl> + / / / <nl> + / / / @ file <nl> + / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2014 ArangoDB GmbH , Cologne , Germany <nl> + / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Jan Steemann <nl> + / / / @ author Copyright 2014 , ArangoDB GmbH , Cologne , Germany <nl> + / / / @ author Copyright 2011 - 2013 , triAGENS GmbH , Cologne , Germany <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # ifndef ARANGODB_UTILS_V8RESOLVER_GUARD_H <nl> + # define ARANGODB_UTILS_V8RESOLVER_GUARD_H 1 <nl> + <nl> + # include " Basics / Common . h " <nl> + <nl> + # include < v8 . h > <nl> + # include " Utils / CollectionNameResolver . h " <nl> + # include " VocBase / vocbase . h " <nl> + # include " V8 / v8 - globals . h " <nl> + <nl> + namespace triagens { <nl> + namespace arango { <nl> + <nl> + class V8ResolverGuard { <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - class V8ResolverGuard <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - constructors and destructors <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + public : <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief create the guard <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + V8ResolverGuard ( TRI_vocbase_t * vocbase ) <nl> + : _v8g ( static_cast < TRI_v8_global_t * > ( v8 : : Isolate : : GetCurrent ( ) - > GetData ( ) ) ) , <nl> + _ownResolver ( false ) { <nl> + <nl> + if ( _v8g - > _resolver = = nullptr ) { <nl> + _v8g - > _resolver = static_cast < void * > ( new CollectionNameResolver ( vocbase ) ) ; <nl> + _ownResolver = true ; <nl> + } <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief destroy the guard <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + ~ V8ResolverGuard ( ) { <nl> + if ( _ownResolver & & _v8g - > _resolver ! = nullptr ) { <nl> + delete static_cast < CollectionNameResolver * > ( _v8g - > _resolver ) ; <nl> + _v8g - > _resolver = nullptr ; <nl> + } <nl> + } <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - public functions <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + public : <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief return the resolver <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + inline CollectionNameResolver const * getResolver ( ) const { <nl> + TRI_ASSERT_EXPENSIVE ( _v8g - > _resolver ! = nullptr ) ; <nl> + return static_cast < CollectionNameResolver * > ( _v8g - > _resolver ) ; <nl> + } <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - private variables <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + private : <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief v8 global context <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + TRI_v8_global_t * _v8g ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief whether or not we are responsible for the resolver <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + bool _ownResolver ; <nl> + <nl> + } ; <nl> + <nl> + } <nl> + } <nl> + <nl> + # endif <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - END - OF - FILE <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + / / Local Variables : <nl> + / / mode : outline - minor <nl> + / / outline - regexp : " / / / @ brief \ \ | / / / { @ inheritDoc } \ \ | / / / @ page \ \ | / / - - SECTION - - \ \ | / / / @ \ \ } " <nl> + / / End : <nl> mmm a / arangod / Utils / V8TransactionContext . h <nl> ppp b / arangod / Utils / V8TransactionContext . h <nl> namespace triagens { <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> V8TransactionContext ( ) <nl> - : _v8g ( static_cast < TRI_v8_global_t * > ( v8 : : Isolate : : GetCurrent ( ) - > GetData ( ) ) ) { <nl> + : _v8g ( static_cast < TRI_v8_global_t * > ( v8 : : Isolate : : GetCurrent ( ) - > GetData ( ) ) ) , <nl> + _ownResolver ( false ) { <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> namespace triagens { <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> virtual ~ V8TransactionContext ( ) { <nl> - / / unregisterTransaction ( ) ; <nl> } <nl> <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> namespace triagens { <nl> / / / @ brief return the resolver <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - inline CollectionNameResolver const * getResolver ( ) const { <nl> + inline CollectionNameResolver const * getResolver ( ) const { <nl> + TRI_ASSERT_EXPENSIVE ( _v8g - > _resolver ! = nullptr ) ; <nl> return static_cast < CollectionNameResolver * > ( _v8g - > _resolver ) ; <nl> } <nl> <nl> namespace triagens { <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> inline int registerTransaction ( TRI_transaction_t * trx ) { <nl> + TRI_ASSERT_EXPENSIVE ( _v8g - > _currentTransaction = = nullptr ) ; <nl> _v8g - > _currentTransaction = trx ; <nl> - _v8g - > _resolver = static_cast < void * > ( new CollectionNameResolver ( trx - > _vocbase ) ) ; <nl> + <nl> + if ( _v8g - > _resolver = = nullptr ) { <nl> + _v8g - > _resolver = static_cast < void * > ( new CollectionNameResolver ( trx - > _vocbase ) ) ; <nl> + _ownResolver = true ; <nl> + } <nl> <nl> return TRI_ERROR_NO_ERROR ; <nl> } <nl> namespace triagens { <nl> inline int unregisterTransaction ( ) { <nl> _v8g - > _currentTransaction = nullptr ; <nl> <nl> - if ( _v8g - > _resolver ! = nullptr ) { <nl> + if ( _ownResolver & & _v8g - > _resolver ! = nullptr ) { <nl> + _ownResolver = false ; <nl> CollectionNameResolver * resolver = static_cast < CollectionNameResolver * > ( _v8g - > _resolver ) ; <nl> delete resolver ; <nl> <nl> namespace triagens { <nl> <nl> TRI_v8_global_t * _v8g ; <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief whether or not we are responsible for the resolver <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + bool _ownResolver ; <nl> + <nl> } ; <nl> <nl> } <nl> mmm a / arangod / V8Server / v8 - vocbase . cpp <nl> ppp b / arangod / V8Server / v8 - vocbase . cpp <nl> <nl> # include " Utils / AhuacatlTransaction . h " <nl> # include " Utils / DocumentHelper . h " <nl> # include " Utils / transactions . h " <nl> + # include " Utils / V8ResolverGuard . h " <nl> # include " V8 / v8 - conv . h " <nl> # include " V8 / v8 - execution . h " <nl> # include " V8 / v8 - utils . h " <nl> static inline v8 : : Handle < v8 : : Value > V8RevisionId ( TRI_voc_rid_t rid ) { <nl> <nl> static inline v8 : : Handle < v8 : : Value > V8DocumentId ( string const & collectionName , <nl> string const & key ) { <nl> - string const id = DocumentHelper : : assembleDocumentId ( collectionName , key ) ; <nl> + string const & & id = DocumentHelper : : assembleDocumentId ( collectionName , key ) ; <nl> <nl> return v8 : : String : : New ( id . c_str ( ) , ( int ) id . size ( ) ) ; <nl> } <nl> static inline TRI_vocbase_t * GetContextVocBase ( ) { <nl> static bool ParseDocumentHandle ( v8 : : Handle < v8 : : Value > const arg , <nl> string & collectionName , <nl> TRI_voc_key_t & key ) { <nl> - TRI_ASSERT ( collectionName = = " " ) ; <nl> + TRI_ASSERT ( collectionName . empty ( ) ) ; <nl> <nl> if ( ! arg - > IsString ( ) ) { <nl> return false ; <nl> static bool ExtractDocumentHandle ( v8 : : Handle < v8 : : Value > const val , <nl> TRI_v8_global_t * v8g = ( TRI_v8_global_t * ) v8 : : Isolate : : GetCurrent ( ) - > GetData ( ) ; <nl> <nl> v8 : : Handle < v8 : : Object > obj = val - > ToObject ( ) ; <nl> - v8 : : Handle < v8 : : Value > didVal = obj - > Get ( v8g - > _IdKey ) ; <nl> + <nl> + if ( obj - > Has ( v8g - > _IdKey ) ) { <nl> + v8 : : Handle < v8 : : Value > didVal = obj - > Get ( v8g - > _IdKey ) ; <nl> + <nl> + if ( ! ParseDocumentHandle ( didVal , collectionName , key ) ) { <nl> + return false ; <nl> + } <nl> + } <nl> + else if ( obj - > Has ( v8g - > _KeyKey ) ) { <nl> + v8 : : Handle < v8 : : Value > didVal = obj - > Get ( v8g - > _KeyKey ) ; <nl> <nl> - if ( ! ParseDocumentHandle ( didVal , collectionName , key ) ) { <nl> + if ( ! ParseDocumentHandle ( didVal , collectionName , key ) ) { <nl> + return false ; <nl> + } <nl> + } <nl> + else { <nl> return false ; <nl> } <nl> <nl> static v8 : : Handle < v8 : : Value > ParseDocumentOrDocumentHandle ( TRI_vocbase_t * vocba <nl> TRI_ASSERT ( key = = nullptr ) ; <nl> <nl> / / reset the collection identifier and the revision <nl> - string collectionName = " " ; <nl> + string collectionName ; <nl> rid = 0 ; <nl> <nl> / / try to extract the collection name , key , and revision from the object passed <nl> static v8 : : Handle < v8 : : Value > ParseDocumentOrDocumentHandle ( TRI_vocbase_t * vocba <nl> <nl> TRI_ASSERT ( collectionName ! = " " ) ; <nl> <nl> - if ( collection = = 0 ) { <nl> + if ( collection = = nullptr ) { <nl> / / no collection object was passed , now check the user - supplied collection name <nl> <nl> - TRI_vocbase_col_t const * col = 0 ; <nl> + TRI_vocbase_col_t const * col = nullptr ; <nl> <nl> if ( ServerState : : instance ( ) - > isCoordinator ( ) ) { <nl> ClusterInfo * ci = ClusterInfo : : instance ( ) ; <nl> shared_ptr < CollectionInfo > const & c = ci - > getCollection ( vocbase - > _name , collectionName ) ; <nl> col = CoordinatorCollection ( vocbase , * c ) ; <nl> <nl> - if ( col ! = 0 & & col - > _cid = = 0 ) { <nl> + if ( col ! = nullptr & & col - > _cid = = 0 ) { <nl> FreeCoordinatorCollection ( const_cast < TRI_vocbase_col_t * > ( col ) ) ; <nl> - col = 0 ; <nl> + col = nullptr ; <nl> } <nl> } <nl> else { <nl> col = resolver - > getCollectionStruct ( collectionName ) ; <nl> } <nl> <nl> - if ( col = = 0 ) { <nl> + if ( col = = nullptr ) { <nl> / / collection not found <nl> return scope . Close ( TRI_CreateErrorObject ( __FILE__ , <nl> __LINE__ , <nl> static v8 : : Handle < v8 : : Value > ParseDocumentOrDocumentHandle ( TRI_vocbase_t * vocba <nl> collection = col ; <nl> } <nl> <nl> - TRI_ASSERT ( collection ! = 0 ) ; <nl> + TRI_ASSERT ( collection ! = nullptr ) ; <nl> <nl> v8 : : Handle < v8 : : Value > empty ; <nl> return scope . Close ( empty ) ; <nl> static TRI_vocbase_col_t const * UseCollection ( v8 : : Handle < v8 : : Object > collection <nl> int res = TRI_ERROR_INTERNAL ; <nl> TRI_vocbase_col_t * col = TRI_UnwrapClass < TRI_vocbase_col_t > ( collection , WRP_VOCBASE_COL_TYPE ) ; <nl> <nl> - if ( col ! = 0 ) { <nl> + if ( col ! = nullptr ) { <nl> if ( ! col - > _isLocal ) { <nl> * err = TRI_CreateErrorObject ( __FILE__ , <nl> __LINE__ , <nl> TRI_ERROR_NOT_IMPLEMENTED ) ; <nl> TRI_set_errno ( TRI_ERROR_NOT_IMPLEMENTED ) ; <nl> - return 0 ; <nl> + return nullptr ; <nl> } <nl> <nl> TRI_vocbase_col_status_e status ; <nl> res = TRI_UseCollectionVocBase ( col - > _vocbase , col , status ) ; <nl> <nl> if ( res = = TRI_ERROR_NO_ERROR & & <nl> - col - > _collection ! = 0 ) { <nl> + col - > _collection ! = nullptr ) { <nl> / / no error <nl> return col ; <nl> } <nl> static TRI_vocbase_col_t const * UseCollection ( v8 : : Handle < v8 : : Object > collection <nl> / / some error occurred <nl> * err = TRI_CreateErrorObject ( __FILE__ , __LINE__ , res , " cannot use / load collection " , true ) ; <nl> TRI_set_errno ( res ) ; <nl> - return 0 ; <nl> + return nullptr ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> static v8 : : Handle < v8 : : Value > IndexRep ( string const & collectionName , <nl> TRI_json_t const * idx ) { <nl> v8 : : HandleScope scope ; <nl> <nl> - TRI_ASSERT ( idx ! = 0 ) ; <nl> + TRI_ASSERT ( idx ! = nullptr ) ; <nl> <nl> v8 : : Handle < v8 : : Object > rep = TRI_ObjectJson ( idx ) - > ToObject ( ) ; <nl> <nl> string iid = TRI_ObjectToString ( rep - > Get ( TRI_V8_SYMBOL ( " id " ) ) ) ; <nl> - const string id = collectionName + TRI_INDEX_HANDLE_SEPARATOR_STR + iid ; <nl> + string const id = collectionName + TRI_INDEX_HANDLE_SEPARATOR_STR + iid ; <nl> rep - > Set ( TRI_V8_SYMBOL ( " id " ) , v8 : : String : : New ( id . c_str ( ) , ( int ) id . size ( ) ) ) ; <nl> <nl> return scope . Close ( rep ) ; <nl> int ProcessBitarrayIndexFields ( v8 : : Handle < v8 : : Object > const obj , <nl> <nl> TRI_json_t * fieldJson = TRI_CreateListJson ( TRI_UNKNOWN_MEM_ZONE ) ; <nl> <nl> - if ( fieldJson = = 0 ) { <nl> + if ( fieldJson = = nullptr ) { <nl> return TRI_ERROR_OUT_OF_MEMORY ; <nl> } <nl> <nl> static v8 : : Handle < v8 : : Value > DocumentVocbaseCol ( bool useCollection , <nl> TRI_V8_EXCEPTION_USAGE ( scope , " document ( < document - handle > ) " ) ; <nl> } <nl> <nl> - TRI_voc_key_t key = 0 ; <nl> + TRI_voc_key_t key = nullptr ; <nl> TRI_voc_rid_t rid ; <nl> TRI_vocbase_t * vocbase ; <nl> - TRI_vocbase_col_t const * col = 0 ; <nl> + TRI_vocbase_col_t const * col = nullptr ; <nl> <nl> if ( useCollection ) { <nl> / / called as db . collection . document ( ) <nl> col = TRI_UnwrapClass < TRI_vocbase_col_t > ( argv . Holder ( ) , WRP_VOCBASE_COL_TYPE ) ; <nl> <nl> - if ( col = = 0 ) { <nl> + if ( col = = nullptr ) { <nl> TRI_V8_EXCEPTION_INTERNAL ( scope , " cannot extract collection " ) ; <nl> } <nl> <nl> static v8 : : Handle < v8 : : Value > DocumentVocbaseCol ( bool useCollection , <nl> vocbase = GetContextVocBase ( ) ; <nl> } <nl> <nl> - if ( vocbase = = 0 ) { <nl> + if ( vocbase = = nullptr ) { <nl> TRI_V8_EXCEPTION ( scope , TRI_ERROR_ARANGO_DATABASE_NOT_FOUND ) ; <nl> } <nl> <nl> - CollectionNameResolver resolver ( vocbase ) ; <nl> - v8 : : Handle < v8 : : Value > err = ParseDocumentOrDocumentHandle ( vocbase , & resolver , col , key , rid , argv [ 0 ] ) ; <nl> + V8ResolverGuard resolver ( vocbase ) ; <nl> + v8 : : Handle < v8 : : Value > err = ParseDocumentOrDocumentHandle ( vocbase , resolver . getResolver ( ) , col , key , rid , argv [ 0 ] ) ; <nl> <nl> LocalCollectionGuard g ( useCollection ? 0 : const_cast < TRI_vocbase_col_t * > ( col ) ) ; <nl> <nl> static v8 : : Handle < v8 : : Value > DocumentVocbaseCol ( bool useCollection , <nl> return scope . Close ( v8 : : ThrowException ( err ) ) ; <nl> } <nl> <nl> - TRI_ASSERT ( col ! = 0 ) ; <nl> + TRI_ASSERT ( col ! = nullptr ) ; <nl> TRI_ASSERT ( key ! = nullptr ) ; <nl> <nl> if ( ServerState : : instance ( ) - > isCoordinator ( ) ) { <nl> static v8 : : Handle < v8 : : Value > ExistsVocbaseCol ( bool useCollection , <nl> TRI_V8_EXCEPTION_USAGE ( scope , " exists ( < document - handle > ) " ) ; <nl> } <nl> <nl> - TRI_voc_key_t key = 0 ; <nl> + TRI_voc_key_t key = nullptr ; <nl> TRI_voc_rid_t rid ; <nl> TRI_vocbase_t * vocbase ; <nl> - TRI_vocbase_col_t const * col = 0 ; <nl> + TRI_vocbase_col_t const * col = nullptr ; <nl> <nl> if ( useCollection ) { <nl> / / called as db . collection . exists ( ) <nl> col = TRI_UnwrapClass < TRI_vocbase_col_t > ( argv . Holder ( ) , WRP_VOCBASE_COL_TYPE ) ; <nl> <nl> - if ( col = = 0 ) { <nl> + if ( col = = nullptr ) { <nl> TRI_V8_EXCEPTION_INTERNAL ( scope , " cannot extract collection " ) ; <nl> } <nl> <nl> static v8 : : Handle < v8 : : Value > ExistsVocbaseCol ( bool useCollection , <nl> vocbase = GetContextVocBase ( ) ; <nl> } <nl> <nl> - if ( vocbase = = 0 ) { <nl> + if ( vocbase = = nullptr ) { <nl> TRI_V8_EXCEPTION ( scope , TRI_ERROR_ARANGO_DATABASE_NOT_FOUND ) ; <nl> } <nl> <nl> - CollectionNameResolver resolver ( vocbase ) ; <nl> - v8 : : Handle < v8 : : Value > err = ParseDocumentOrDocumentHandle ( vocbase , & resolver , col , key , rid , argv [ 0 ] ) ; <nl> + V8ResolverGuard resolver ( vocbase ) ; <nl> + v8 : : Handle < v8 : : Value > err = ParseDocumentOrDocumentHandle ( vocbase , resolver . getResolver ( ) , col , key , rid , argv [ 0 ] ) ; <nl> <nl> LocalCollectionGuard g ( useCollection ? 0 : const_cast < TRI_vocbase_col_t * > ( col ) ) ; <nl> <nl> - if ( key = = 0 ) { <nl> + if ( key = = nullptr ) { <nl> TRI_V8_EXCEPTION ( scope , TRI_ERROR_ARANGO_DOCUMENT_HANDLE_BAD ) ; <nl> } <nl> <nl> static v8 : : Handle < v8 : : Value > ExistsVocbaseCol ( bool useCollection , <nl> return scope . Close ( v8 : : ThrowException ( err ) ) ; <nl> } <nl> <nl> - TRI_ASSERT ( col ! = 0 ) ; <nl> - TRI_ASSERT ( key ! = 0 ) ; <nl> + TRI_ASSERT ( col ! = nullptr ) ; <nl> + TRI_ASSERT ( key ! = nullptr ) ; <nl> <nl> if ( ServerState : : instance ( ) - > isCoordinator ( ) ) { <nl> return scope . Close ( DocumentVocbaseColCoordinator ( col , argv , false ) ) ; <nl> static v8 : : Handle < v8 : : Value > ModifyVocbaseColCoordinator ( <nl> v8 : : Arguments const & argv ) { <nl> v8 : : HandleScope scope ; <nl> <nl> - TRI_ASSERT ( collection ! = 0 ) ; <nl> + TRI_ASSERT ( collection ! = nullptr ) ; <nl> <nl> / / First get the initial data : <nl> string const dbname ( collection - > _dbName ) ; <nl> static v8 : : Handle < v8 : : Value > ReplaceVocbaseCol ( bool useCollection , <nl> TRI_doc_update_policy_e policy = TRI_DOC_UPDATE_ERROR ; <nl> <nl> / / check the arguments <nl> - if ( argv . Length ( ) < 2 ) { <nl> + uint32_t const argLength = argv . Length ( ) ; <nl> + <nl> + if ( argLength < 2 ) { <nl> TRI_V8_EXCEPTION_USAGE ( scope , " replace ( < document > , < data > , { overwrite : booleanValue , waitForSync : booleanValue } ) " ) ; <nl> } <nl> <nl> static v8 : : Handle < v8 : : Value > ReplaceVocbaseCol ( bool useCollection , <nl> else { / / old variant replace ( < document > , < data > , < overwrite > , < waitForSync > ) <nl> options . overwrite = TRI_ObjectToBoolean ( argv [ 2 ] ) ; <nl> policy = ExtractUpdatePolicy ( options . overwrite ) ; <nl> - if ( argv . Length ( ) > 3 ) { <nl> + if ( argLength > 3 ) { <nl> options . waitForSync = TRI_ObjectToBoolean ( argv [ 3 ] ) ; <nl> } <nl> } <nl> } <nl> <nl> - TRI_voc_key_t key = 0 ; <nl> + TRI_voc_key_t key = nullptr ; <nl> TRI_voc_rid_t rid ; <nl> TRI_voc_rid_t actualRevision = 0 ; <nl> <nl> TRI_vocbase_t * vocbase ; <nl> - TRI_vocbase_col_t const * col = 0 ; <nl> + TRI_vocbase_col_t const * col = nullptr ; <nl> <nl> if ( useCollection ) { <nl> / / called as db . collection . replace ( ) <nl> col = TRI_UnwrapClass < TRI_vocbase_col_t > ( argv . Holder ( ) , WRP_VOCBASE_COL_TYPE ) ; <nl> <nl> - if ( col = = 0 ) { <nl> + if ( col = = nullptr ) { <nl> TRI_V8_EXCEPTION_INTERNAL ( scope , " cannot extract collection " ) ; <nl> } <nl> <nl> static v8 : : Handle < v8 : : Value > ReplaceVocbaseCol ( bool useCollection , <nl> vocbase = GetContextVocBase ( ) ; <nl> } <nl> <nl> - if ( vocbase = = 0 ) { <nl> + if ( vocbase = = nullptr ) { <nl> TRI_V8_EXCEPTION ( scope , TRI_ERROR_ARANGO_DATABASE_NOT_FOUND ) ; <nl> } <nl> <nl> - CollectionNameResolver resolver ( vocbase ) ; <nl> - v8 : : Handle < v8 : : Value > err = ParseDocumentOrDocumentHandle ( vocbase , & resolver , col , key , rid , argv [ 0 ] ) ; <nl> + V8ResolverGuard resolver ( vocbase ) ; <nl> + v8 : : Handle < v8 : : Value > err = ParseDocumentOrDocumentHandle ( vocbase , resolver . getResolver ( ) , col , key , rid , argv [ 0 ] ) ; <nl> <nl> LocalCollectionGuard g ( useCollection ? 0 : const_cast < TRI_vocbase_col_t * > ( col ) ) ; <nl> <nl> - if ( key = = 0 ) { <nl> + if ( key = = nullptr ) { <nl> TRI_V8_EXCEPTION ( scope , TRI_ERROR_ARANGO_DOCUMENT_HANDLE_BAD ) ; <nl> } <nl> <nl> static v8 : : Handle < v8 : : Value > ReplaceVocbaseCol ( bool useCollection , <nl> <nl> TRI_json_t * json = TRI_ObjectToJson ( argv [ 1 ] ) ; <nl> <nl> - if ( json = = 0 ) { <nl> + if ( json = = nullptr ) { <nl> TRI_FreeString ( TRI_CORE_MEM_ZONE , key ) ; <nl> TRI_V8_EXCEPTION_MEMORY ( scope ) ; <nl> } <nl> static v8 : : Handle < v8 : : Value > ReplaceVocbaseCol ( bool useCollection , <nl> TRI_EXTRACT_SHAPED_JSON_MARKER ( shaped , mptr . getDataPtr ( ) ) ; / / PROTECTED by trx here <nl> TRI_json_t * old = TRI_JsonShapedJson ( document - > getShaper ( ) , & shaped ) ; / / PROTECTED by trx here <nl> <nl> - if ( old = = 0 ) { <nl> + if ( old = = nullptr ) { <nl> TRI_FreeJson ( TRI_UNKNOWN_MEM_ZONE , json ) ; <nl> TRI_FreeString ( TRI_CORE_MEM_ZONE , key ) ; <nl> TRI_V8_EXCEPTION_MEMORY ( scope ) ; <nl> static v8 : : Handle < v8 : : Value > ReplaceVocbaseCol ( bool useCollection , <nl> <nl> TRI_shaped_json_t * shaped = TRI_ShapedJsonV8Object ( argv [ 1 ] , document - > getShaper ( ) , true ) ; / / PROTECTED by trx here <nl> <nl> - if ( shaped = = 0 ) { <nl> + if ( shaped = = nullptr ) { <nl> TRI_FreeString ( TRI_CORE_MEM_ZONE , key ) ; <nl> TRI_V8_EXCEPTION_MESSAGE ( scope , TRI_errno ( ) , " < data > cannot be converted into JSON shape " ) ; <nl> } <nl> static v8 : : Handle < v8 : : Value > UpdateVocbaseCol ( bool useCollection , <nl> TRI_doc_update_policy_e policy = TRI_DOC_UPDATE_ERROR ; <nl> <nl> / / check the arguments <nl> - if ( argv . Length ( ) < 2 | | argv . Length ( ) > 5 ) { <nl> + uint32_t const argLength = argv . Length ( ) ; <nl> + <nl> + if ( argLength < 2 | | argLength > 5 ) { <nl> TRI_V8_EXCEPTION_USAGE ( scope , " update ( < document > , < data > , { overwrite : booleanValue , keepNull : booleanValue , waitForSync : booleanValue } ) " ) ; <nl> } <nl> <nl> - if ( argv . Length ( ) > 2 ) { <nl> + if ( argLength > 2 ) { <nl> if ( argv [ 2 ] - > IsObject ( ) ) { <nl> v8 : : Handle < v8 : : Object > optionsObject = argv [ 2 ] . As < v8 : : Object > ( ) ; <nl> if ( optionsObject - > Has ( v8 : : String : : New ( " overwrite " ) ) ) { <nl> static v8 : : Handle < v8 : : Value > UpdateVocbaseCol ( bool useCollection , <nl> else { / / old variant update ( < document > , < data > , < overwrite > , < keepNull > , < waitForSync > ) <nl> options . overwrite = TRI_ObjectToBoolean ( argv [ 2 ] ) ; <nl> policy = ExtractUpdatePolicy ( options . overwrite ) ; <nl> - if ( argv . Length ( ) > 3 ) { <nl> + if ( argLength > 3 ) { <nl> options . keepNull = TRI_ObjectToBoolean ( argv [ 3 ] ) ; <nl> } <nl> - if ( argv . Length ( ) > 4 ) { <nl> + if ( argLength > 4 ) { <nl> options . waitForSync = TRI_ObjectToBoolean ( argv [ 4 ] ) ; <nl> } <nl> } <nl> } <nl> <nl> - TRI_voc_key_t key = 0 ; <nl> + TRI_voc_key_t key = nullptr ; <nl> TRI_voc_rid_t rid ; <nl> TRI_voc_rid_t actualRevision = 0 ; <nl> TRI_vocbase_t * vocbase ; <nl> - TRI_vocbase_col_t const * col = 0 ; <nl> + TRI_vocbase_col_t const * col = nullptr ; <nl> <nl> if ( useCollection ) { <nl> / / called as db . collection . update ( ) <nl> col = TRI_UnwrapClass < TRI_vocbase_col_t > ( argv . Holder ( ) , WRP_VOCBASE_COL_TYPE ) ; <nl> <nl> - if ( col = = 0 ) { <nl> + if ( col = = nullptr ) { <nl> TRI_V8_EXCEPTION_INTERNAL ( scope , " cannot extract collection " ) ; <nl> } <nl> <nl> static v8 : : Handle < v8 : : Value > UpdateVocbaseCol ( bool useCollection , <nl> vocbase = GetContextVocBase ( ) ; <nl> } <nl> <nl> - if ( vocbase = = 0 ) { <nl> + if ( vocbase = = nullptr ) { <nl> TRI_V8_EXCEPTION ( scope , TRI_ERROR_ARANGO_DATABASE_NOT_FOUND ) ; <nl> } <nl> <nl> - CollectionNameResolver resolver ( vocbase ) ; <nl> - v8 : : Handle < v8 : : Value > err = ParseDocumentOrDocumentHandle ( vocbase , & resolver , col , key , rid , argv [ 0 ] ) ; <nl> + V8ResolverGuard resolver ( vocbase ) ; <nl> + v8 : : Handle < v8 : : Value > err = ParseDocumentOrDocumentHandle ( vocbase , resolver . getResolver ( ) , col , key , rid , argv [ 0 ] ) ; <nl> <nl> LocalCollectionGuard g ( useCollection ? 0 : const_cast < TRI_vocbase_col_t * > ( col ) ) ; <nl> <nl> - if ( key = = 0 ) { <nl> + if ( key = = nullptr ) { <nl> TRI_V8_EXCEPTION ( scope , TRI_ERROR_ARANGO_DOCUMENT_HANDLE_BAD ) ; <nl> } <nl> <nl> static v8 : : Handle < v8 : : Value > UpdateVocbaseCol ( bool useCollection , <nl> return scope . Close ( v8 : : ThrowException ( err ) ) ; <nl> } <nl> <nl> - TRI_ASSERT ( col ! = 0 ) ; <nl> - TRI_ASSERT ( key ! = 0 ) ; <nl> + TRI_ASSERT ( col ! = nullptr ) ; <nl> + TRI_ASSERT ( key ! = nullptr ) ; <nl> <nl> if ( ServerState : : instance ( ) - > isCoordinator ( ) ) { <nl> return scope . Close ( ModifyVocbaseColCoordinator ( col , <nl> static v8 : : Handle < v8 : : Value > UpdateVocbaseCol ( bool useCollection , <nl> <nl> TRI_json_t * json = TRI_ObjectToJson ( argv [ 1 ] ) ; <nl> <nl> - if ( json = = 0 ) { <nl> + if ( json = = nullptr ) { <nl> FREE_STRING ( TRI_CORE_MEM_ZONE , key ) ; <nl> TRI_V8_EXCEPTION_MESSAGE ( scope , TRI_errno ( ) , " < data > is no valid JSON " ) ; <nl> } <nl> static v8 : : Handle < v8 : : Value > UpdateVocbaseCol ( bool useCollection , <nl> TRI_FreeJson ( zone , old ) ; <nl> TRI_FreeJson ( TRI_UNKNOWN_MEM_ZONE , json ) ; <nl> <nl> - if ( patchedJson = = 0 ) { <nl> + if ( patchedJson = = nullptr ) { <nl> FREE_STRING ( TRI_CORE_MEM_ZONE , key ) ; <nl> TRI_V8_EXCEPTION_MEMORY ( scope ) ; <nl> } <nl> static v8 : : Handle < v8 : : Value > RemoveVocbaseCol ( bool useCollection , <nl> TRI_voc_rid_t rid ; <nl> TRI_voc_rid_t actualRevision = 0 ; <nl> TRI_vocbase_t * vocbase ; <nl> - TRI_vocbase_col_t const * col = 0 ; <nl> + TRI_vocbase_col_t const * col = nullptr ; <nl> <nl> if ( useCollection ) { <nl> / / called as db . collection . remove ( ) <nl> col = TRI_UnwrapClass < TRI_vocbase_col_t > ( argv . Holder ( ) , WRP_VOCBASE_COL_TYPE ) ; <nl> <nl> - if ( col = = 0 ) { <nl> + if ( col = = nullptr ) { <nl> TRI_V8_EXCEPTION_INTERNAL ( scope , " cannot extract collection " ) ; <nl> } <nl> <nl> static v8 : : Handle < v8 : : Value > RemoveVocbaseCol ( bool useCollection , <nl> vocbase = GetContextVocBase ( ) ; <nl> } <nl> <nl> - if ( vocbase = = 0 ) { <nl> + if ( vocbase = = nullptr ) { <nl> TRI_V8_EXCEPTION ( scope , TRI_ERROR_ARANGO_DATABASE_NOT_FOUND ) ; <nl> } <nl> <nl> - CollectionNameResolver resolver ( vocbase ) ; <nl> - v8 : : Handle < v8 : : Value > err = ParseDocumentOrDocumentHandle ( vocbase , & resolver , col , key , rid , argv [ 0 ] ) ; <nl> + V8ResolverGuard resolver ( vocbase ) ; <nl> + v8 : : Handle < v8 : : Value > err = ParseDocumentOrDocumentHandle ( vocbase , resolver . getResolver ( ) , col , key , rid , argv [ 0 ] ) ; <nl> <nl> LocalCollectionGuard g ( useCollection ? 0 : const_cast < TRI_vocbase_col_t * > ( col ) ) ; <nl> <nl> - if ( key = = 0 ) { <nl> + if ( key = = nullptr ) { <nl> TRI_V8_EXCEPTION ( scope , TRI_ERROR_ARANGO_DOCUMENT_HANDLE_BAD ) ; <nl> } <nl> <nl> static v8 : : Handle < v8 : : Value > RemoveVocbaseCol ( bool useCollection , <nl> return scope . Close ( v8 : : ThrowException ( err ) ) ; <nl> } <nl> <nl> - TRI_ASSERT ( col ! = 0 ) ; <nl> - TRI_ASSERT ( key ! = 0 ) ; <nl> + TRI_ASSERT ( col ! = nullptr ) ; <nl> + TRI_ASSERT ( key ! = nullptr ) ; <nl> <nl> if ( ServerState : : instance ( ) - > isCoordinator ( ) ) { <nl> return scope . Close ( RemoveVocbaseColCoordinator ( col , policy , options . waitForSync , argv ) ) ; <nl> static v8 : : Handle < v8 : : Value > JS_SaveVocbaseCol ( v8 : : Arguments const & argv ) { <nl> <nl> TRI_vocbase_col_t * collection = TRI_UnwrapClass < TRI_vocbase_col_t > ( argv . Holder ( ) , WRP_VOCBASE_COL_TYPE ) ; <nl> <nl> - if ( collection = = 0 ) { <nl> + if ( collection = = nullptr ) { <nl> TRI_V8_EXCEPTION_INTERNAL ( scope , " cannot extract collection " ) ; <nl> } <nl> <nl> static v8 : : Handle < v8 : : Value > JS_StatusVocbaseCol ( v8 : : Arguments const & argv ) { <nl> <nl> TRI_vocbase_col_t * collection = TRI_UnwrapClass < TRI_vocbase_col_t > ( argv . Holder ( ) , WRP_VOCBASE_COL_TYPE ) ; <nl> <nl> - if ( collection = = 0 ) { <nl> + if ( collection = = nullptr ) { <nl> TRI_V8_EXCEPTION_INTERNAL ( scope , " cannot extract collection " ) ; <nl> } <nl> <nl> static v8 : : Handle < v8 : : Value > JS_StatusVocbaseCol ( v8 : : Arguments const & argv ) { <nl> static v8 : : Handle < v8 : : Value > JS_TruncateVocbaseCol ( v8 : : Arguments const & argv ) { <nl> v8 : : HandleScope scope ; <nl> <nl> - const bool forceSync = ExtractForceSync ( argv , 1 ) ; <nl> + bool const forceSync = ExtractForceSync ( argv , 1 ) ; <nl> <nl> TRI_vocbase_col_t * collection = TRI_UnwrapClass < TRI_vocbase_col_t > ( argv . Holder ( ) , WRP_VOCBASE_COL_TYPE ) ; <nl> <nl> - if ( collection = = 0 ) { <nl> + if ( collection = = nullptr ) { <nl> TRI_V8_EXCEPTION_INTERNAL ( scope , " cannot extract collection " ) ; <nl> } <nl> <nl> static v8 : : Handle < v8 : : Integer > PropertyQueryShapedJson ( v8 : : Local < v8 : : String > na <nl> / / get shaped json <nl> void * marker = TRI_UnwrapClass < TRI_shaped_json_t > ( self , WRP_SHAPED_JSON_TYPE ) ; <nl> <nl> - if ( marker = = 0 ) { <nl> + if ( marker = = nullptr ) { <nl> return scope . Close ( v8 : : Handle < v8 : : Integer > ( ) ) ; <nl> } <nl> <nl> / / convert the JavaScript string to a string <nl> - string const key = TRI_ObjectToString ( name ) ; <nl> + string const & & key = TRI_ObjectToString ( name ) ; <nl> <nl> if ( key . empty ( ) ) { <nl> return scope . Close ( v8 : : Handle < v8 : : Integer > ( ) ) ; <nl> static v8 : : Handle < v8 : : Integer > PropertyQueryShapedJson ( v8 : : Local < v8 : : String > na <nl> TRI_shape_sid_t sid ; <nl> TRI_EXTRACT_SHAPE_IDENTIFIER_MARKER ( sid , marker ) ; <nl> <nl> - if ( sid = = 0 ) { <nl> + if ( sid = = TRI_SHAPE_ILLEGAL ) { <nl> / / invalid shape <nl> # ifdef TRI_ENABLE_MAINTAINER_MODE <nl> LOG_WARNING ( " invalid shape id ' % llu ' found for key ' % s ' " , ( unsigned long long ) sid , key . c_str ( ) ) ; <nl> static v8 : : Handle < v8 : : Value > MapGetIndexedShapedJson ( uint32_t idx , <nl> v8 : : HandleScope scope ; <nl> <nl> char buffer [ 11 ] ; <nl> - size_t len ; <nl> - <nl> - len = TRI_StringUInt32InPlace ( idx , ( char * ) & buffer ) ; <nl> + size_t len = TRI_StringUInt32InPlace ( idx , ( char * ) & buffer ) ; <nl> <nl> v8 : : Local < v8 : : String > strVal = v8 : : String : : New ( ( char * ) & buffer , ( int ) len ) ; <nl> <nl> int TRI_ParseVertex ( CollectionNameResolver const * resolver , <nl> <nl> v8 : : HandleScope scope ; <nl> <nl> - TRI_ASSERT ( key = = 0 ) ; <nl> + TRI_ASSERT ( key = = nullptr ) ; <nl> <nl> / / reset everything <nl> - string collectionName = " " ; <nl> + string collectionName ; <nl> TRI_voc_rid_t rid = 0 ; <nl> <nl> / / try to extract the collection name , key , and revision from the object passed <nl> int TRI_ParseVertex ( CollectionNameResolver const * resolver , <nl> } <nl> <nl> / / we have at least a key , we also might have a collection name <nl> - TRI_ASSERT ( key ! = 0 ) ; <nl> + TRI_ASSERT ( key ! = nullptr ) ; <nl> <nl> - if ( collectionName = = " " ) { <nl> + if ( collectionName . empty ( ) ) { <nl> / / we do not know the collection <nl> TRI_FreeString ( TRI_CORE_MEM_ZONE , key ) ; <nl> - key = 0 ; <nl> + key = nullptr ; <nl> <nl> return TRI_ERROR_ARANGO_DOCUMENT_HANDLE_BAD ; <nl> } <nl> int TRI_ParseVertex ( CollectionNameResolver const * resolver , <nl> <nl> if ( cid = = 0 ) { <nl> TRI_FreeString ( TRI_CORE_MEM_ZONE , key ) ; <nl> - key = 0 ; <nl> + key = nullptr ; <nl> return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND ; <nl> } <nl> <nl> TRI_index_t * TRI_LookupIndexByHandle ( CollectionNameResolver const * resolver , <nl> bool ignoreNotFound , <nl> v8 : : Handle < v8 : : Object > * err ) { <nl> / / reset the collection identifier <nl> - string collectionName = " " ; <nl> + string collectionName ; <nl> TRI_idx_iid_t iid = 0 ; <nl> <nl> / / assume we are already loaded <nl> - TRI_ASSERT ( collection ! = 0 ) ; <nl> - TRI_ASSERT ( collection - > _collection ! = 0 ) ; <nl> + TRI_ASSERT ( collection ! = nullptr ) ; <nl> + TRI_ASSERT ( collection - > _collection ! = nullptr ) ; <nl> <nl> / / extract the index identifier from a string <nl> if ( val - > IsString ( ) | | val - > IsStringObject ( ) | | val - > IsNumber ( ) ) { <nl> if ( ! IsIndexHandle ( val , collectionName , iid ) ) { <nl> * err = TRI_CreateErrorObject ( __FILE__ , __LINE__ , TRI_ERROR_ARANGO_INDEX_HANDLE_BAD ) ; <nl> - return 0 ; <nl> + return nullptr ; <nl> } <nl> } <nl> <nl> TRI_index_t * TRI_LookupIndexByHandle ( CollectionNameResolver const * resolver , <nl> <nl> if ( ! IsIndexHandle ( iidVal , collectionName , iid ) ) { <nl> * err = TRI_CreateErrorObject ( __FILE__ , __LINE__ , TRI_ERROR_ARANGO_INDEX_HANDLE_BAD ) ; <nl> - return 0 ; <nl> + return nullptr ; <nl> } <nl> } <nl> <nl> TRI_index_t * TRI_LookupIndexByHandle ( CollectionNameResolver const * resolver , <nl> / / I wish this error provided me with more information ! <nl> / / e . g . ' cannot access index outside the collection it was defined in ' <nl> * err = TRI_CreateErrorObject ( __FILE__ , __LINE__ , TRI_ERROR_ARANGO_CROSS_COLLECTION_REQUEST ) ; <nl> - return 0 ; <nl> + return nullptr ; <nl> } <nl> } <nl> <nl> TRI_index_t * idx = TRI_LookupIndex ( collection - > _collection , iid ) ; <nl> <nl> - if ( idx = = 0 ) { <nl> + if ( idx = = nullptr ) { <nl> if ( ! ignoreNotFound ) { <nl> * err = TRI_CreateErrorObject ( __FILE__ , __LINE__ , TRI_ERROR_ARANGO_INDEX_NOT_FOUND ) ; <nl> } <nl> mmm a / arangod / VocBase / document - collection . cpp <nl> ppp b / arangod / VocBase / document - collection . cpp <nl> static TRI_index_t * CreateHashIndexDocumentCollection ( TRI_document_collection_t <nl> TRI_vector_t paths ; <nl> int res ; <nl> <nl> - idx = NULL ; <nl> + idx = nullptr ; <nl> <nl> / / determine the sorted shape ids for the attributes <nl> res = PidNamesByAttributeNames ( attributes , <nl> static TRI_index_t * CreateHashIndexDocumentCollection ( TRI_document_collection_t <nl> true ) ; <nl> <nl> if ( res ! = TRI_ERROR_NO_ERROR ) { <nl> - if ( created ! = NULL ) { <nl> + if ( created ! = nullptr ) { <nl> * created = false ; <nl> } <nl> <nl> - return NULL ; <nl> + return nullptr ; <nl> } <nl> <nl> / / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <nl> static TRI_index_t * CreateHashIndexDocumentCollection ( TRI_document_collection_t <nl> <nl> idx = LookupPathIndexDocumentCollection ( document , & paths , TRI_IDX_TYPE_HASH_INDEX , unique , false ) ; <nl> <nl> - if ( idx ! = NULL ) { <nl> + if ( idx ! = nullptr ) { <nl> TRI_DestroyVector ( & paths ) ; <nl> TRI_DestroyVectorPointer ( & fields ) ; <nl> LOG_TRACE ( " hash - index already created " ) ; <nl> <nl> - if ( created ! = NULL ) { <nl> + if ( created ! = nullptr ) { <nl> * created = false ; <nl> } <nl> <nl> static TRI_index_t * CreateHashIndexDocumentCollection ( TRI_document_collection_t <nl> & paths , <nl> unique ) ; <nl> <nl> - if ( idx = = NULL ) { <nl> + if ( idx = = nullptr ) { <nl> TRI_DestroyVector ( & paths ) ; <nl> TRI_DestroyVectorPointer ( & fields ) ; <nl> TRI_set_errno ( TRI_ERROR_OUT_OF_MEMORY ) ; <nl> - return NULL ; <nl> + return nullptr ; <nl> } <nl> <nl> / / release memory allocated to vector <nl> static TRI_index_t * CreateHashIndexDocumentCollection ( TRI_document_collection_t <nl> if ( res ! = TRI_ERROR_NO_ERROR ) { <nl> TRI_FreeHashIndex ( idx ) ; <nl> <nl> - return NULL ; <nl> + return nullptr ; <nl> } <nl> <nl> / / store index and return <nl> static TRI_index_t * CreateHashIndexDocumentCollection ( TRI_document_collection_t <nl> if ( res ! = TRI_ERROR_NO_ERROR ) { <nl> TRI_FreeHashIndex ( idx ) ; <nl> <nl> - return NULL ; <nl> + return nullptr ; <nl> } <nl> <nl> - if ( created ! = NULL ) { <nl> + if ( created ! = nullptr ) { <nl> * created = true ; <nl> } <nl> <nl> TRI_index_t * TRI_LookupHashIndexDocumentCollection ( TRI_document_collection_t * d <nl> false ) ; <nl> <nl> if ( res ! = TRI_ERROR_NO_ERROR ) { <nl> - return NULL ; <nl> + return nullptr ; <nl> } <nl> <nl> idx = LookupPathIndexDocumentCollection ( document , & paths , TRI_IDX_TYPE_HASH_INDEX , unique , true ) ; <nl> static TRI_index_t * CreateSkiplistIndexDocumentCollection ( TRI_document_collecti <nl> true ) ; <nl> <nl> if ( res ! = TRI_ERROR_NO_ERROR ) { <nl> - if ( created ! = NULL ) { <nl> + if ( created ! = nullptr ) { <nl> * created = false ; <nl> } <nl> <nl> - return NULL ; <nl> + return nullptr ; <nl> } <nl> <nl> / / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <nl> static TRI_index_t * CreateSkiplistIndexDocumentCollection ( TRI_document_collecti <nl> <nl> idx = LookupPathIndexDocumentCollection ( document , & paths , TRI_IDX_TYPE_SKIPLIST_INDEX , unique , false ) ; <nl> <nl> - if ( idx ! = NULL ) { <nl> + if ( idx ! = nullptr ) { <nl> TRI_DestroyVector ( & paths ) ; <nl> TRI_DestroyVectorPointer ( & fields ) ; <nl> LOG_TRACE ( " skiplist - index already created " ) ; <nl> <nl> - if ( created ! = NULL ) { <nl> + if ( created ! = nullptr ) { <nl> * created = false ; <nl> } <nl> <nl> static TRI_index_t * CreateSkiplistIndexDocumentCollection ( TRI_document_collecti <nl> / / Create the skiplist index <nl> idx = TRI_CreateSkiplistIndex ( document , iid , & fields , & paths , unique ) ; <nl> <nl> - if ( idx = = NULL ) { <nl> + if ( idx = = nullptr ) { <nl> TRI_set_errno ( TRI_ERROR_OUT_OF_MEMORY ) ; <nl> - return NULL ; <nl> + return nullptr ; <nl> } <nl> <nl> / / release memory allocated to vector <nl> static TRI_index_t * CreateSkiplistIndexDocumentCollection ( TRI_document_collecti <nl> TRI_FreeSkiplistIndex ( idx ) ; <nl> <nl> TRI_set_errno ( res ) ; <nl> - return NULL ; <nl> + return nullptr ; <nl> } <nl> <nl> / / store index and return <nl> static TRI_index_t * CreateSkiplistIndexDocumentCollection ( TRI_document_collecti <nl> if ( res ! = TRI_ERROR_NO_ERROR ) { <nl> TRI_FreeSkiplistIndex ( idx ) ; <nl> <nl> - return NULL ; <nl> + return nullptr ; <nl> } <nl> <nl> - if ( created ! = NULL ) { <nl> + if ( created ! = nullptr ) { <nl> * created = true ; <nl> } <nl> <nl>
nullptr
arangodb/arangodb
fc823938c0641e8a50ef14674fa4c47c76124ec8
2014-06-21T01:27:38Z
mmm a / R - package / src / Makevars . win <nl> ppp b / R - package / src / Makevars . win <nl> CXX = ` Rcmd config CXX ` <nl> TCFLAGS = ` Rcmd config CFLAGS ` <nl> # expose these flags to R CMD SHLIB <nl> PKG_CPPFLAGS = - DXGBOOST_CUSTOMIZE_ERROR_ - I $ ( PKGROOT ) $ ( SHLIB_OPENMP_CFLAGS ) <nl> - XGBFLAG = $ ( TCFLAGS ) - DXGBOOST_CUSTOMIZE_ERROR_ - fPIC $ ( SHLIB_OPENMP_CFLAGS ) <nl> + GBFLAG = $ ( TCFLAGS ) - DXGBOOST_CUSTOMIZE_ERROR_ - fPIC $ ( SHLIB_OPENMP_CFLAGS ) <nl> PKG_LIBS = $ ( SHLIB_OPENMP_CFLAGS ) <nl> <nl> ifeq ( $ ( no_omp ) , 1 ) <nl>
fix windows
dmlc/xgboost
202a17f148cbbcdadf1a333e2e2845b0f7005783
2014-08-30T19:10:50Z
mmm a / include / swift / AST / DiagnosticsSema . def <nl> ppp b / include / swift / AST / DiagnosticsSema . def <nl> NOTE ( unwrap_with_guard , none , <nl> ERROR ( optional_base_not_unwrapped , none , <nl> " value of optional type % 0 must be unwrapped to refer to member % 1 of " <nl> " wrapped base type % 2 " , ( Type , DeclNameRef , Type ) ) <nl> + ERROR ( invalid_optional_infered_keypath_root , none , <nl> + " key path root inferred as optional type % 0 must be unwrapped to refer to member % 1 " <nl> + " of unwrapped type % 2 " , ( Type , DeclNameRef , Type ) ) <nl> NOTE ( optional_base_chain , none , <nl> " chain the optional using ' ? ' to access member % 0 only for non - ' nil ' " <nl> " base values " , ( DeclNameRef ) ) <nl> NOTE ( optional_base_remove_optional_for_keypath_root , none , <nl> " use unwrapped type % 0 as key path root " , ( Type ) ) <nl> NOTE ( optional_keypath_application_base , none , <nl> " use ' ? ' to access key path subscript only for non - ' nil ' base values " , ( ) ) <nl> + NOTE ( optional_key_path_root_base_chain , none , <nl> + " chain the optional using ' ? . ' to access unwrapped type member % 0 " , <nl> + ( DeclNameRef ) ) <nl> + NOTE ( optional_key_path_root_base_unwrap , none , <nl> + " unwrap the optional using ' ! . ' to access unwrapped type member % 0 " , <nl> + ( DeclNameRef ) ) <nl> <nl> ERROR ( missing_unwrap_optional_try , none , <nl> " value of optional type % 0 not unwrapped ; did you mean to use ' try ! ' " <nl> mmm a / lib / Sema / CSDiagnostics . cpp <nl> ppp b / lib / Sema / CSDiagnostics . cpp <nl> bool MemberAccessOnOptionalBaseFailure : : diagnoseAsError ( ) { <nl> return false ; <nl> <nl> auto sourceRange = getSourceRange ( ) ; <nl> - <nl> - emitDiagnostic ( diag : : optional_base_not_unwrapped , <nl> - baseType , Member , unwrappedBaseType ) ; <nl> <nl> auto componentPathElt = <nl> locator - > getLastElementAs < LocatorPathElt : : KeyPathComponent > ( ) ; <nl> bool MemberAccessOnOptionalBaseFailure : : diagnoseAsError ( ) { <nl> / / let ' s emit a tailored note suggesting to use its unwrapped type . <nl> auto * keyPathExpr = castToExpr < KeyPathExpr > ( getAnchor ( ) ) ; <nl> if ( auto rootType = keyPathExpr - > getRootType ( ) ) { <nl> + emitDiagnostic ( diag : : optional_base_not_unwrapped , baseType , Member , <nl> + unwrappedBaseType ) ; <nl> + <nl> emitDiagnostic ( diag : : optional_base_remove_optional_for_keypath_root , <nl> unwrappedBaseType ) <nl> . fixItReplace ( rootType - > getSourceRange ( ) , <nl> unwrappedBaseType . getString ( ) ) ; <nl> + } else { <nl> + emitDiagnostic ( diag : : invalid_optional_infered_keypath_root , baseType , <nl> + Member , unwrappedBaseType ) ; <nl> + emitDiagnostic ( diag : : optional_key_path_root_base_chain , Member ) <nl> + . fixItInsert ( sourceRange . End , " ? . " ) ; <nl> + emitDiagnostic ( diag : : optional_key_path_root_base_unwrap , Member ) <nl> + . fixItInsert ( sourceRange . End , " ! . " ) ; <nl> } <nl> } else { <nl> + emitDiagnostic ( diag : : optional_base_not_unwrapped , baseType , Member , <nl> + unwrappedBaseType ) ; <nl> + <nl> / / FIXME : It would be nice to immediately offer " base ? . member ? ? defaultValue " <nl> / / for non - optional results where that would be appropriate . For the moment <nl> / / always offering " ? " means that if the user chooses chaining , we ' ll end up <nl> mmm a / localization / diagnostics / en . yaml <nl> ppp b / localization / diagnostics / en . yaml <nl> <nl> - id : optional_base_not_unwrapped <nl> msg : " value of optional type % 0 must be unwrapped to refer to member % 1 of wrapped base type % 2 " <nl> <nl> + - id : invalid_optional_infered_keypath_root <nl> + msg : " key path root inferred as optional type % 0 must be unwrapped to refer to member % 1 of unwrapped type % 2 " <nl> + <nl> - id : optional_base_chain <nl> msg : " chain the optional using ' ? ' to access member % 0 only for non - ' nil ' base values " <nl> <nl> <nl> - id : optional_keypath_application_base <nl> msg : " use ' ? ' to access key path subscript only for non - ' nil ' base values " <nl> <nl> + - id : optional_key_path_root_base_chain <nl> + msg : " chain the optional using ' ? . ' to access unwrapped type member % 0 " <nl> + <nl> + - id : optional_key_path_root_base_unwrap <nl> + msg : " unwrap the optional using ' ! . ' to access unwrapped type member % 0 " <nl> + <nl> - id : missing_unwrap_optional_try <nl> msg : " value of optional type % 0 not unwrapped ; did you mean to use ' try ! ' or chain with ' ? ' ? " <nl> <nl> mmm a / test / expr / unary / keypath / keypath . swift <nl> ppp b / test / expr / unary / keypath / keypath . swift <nl> func testMemberAccessOnOptionalKeyPathComponent ( ) { <nl> / / expected - error @ - 1 { { value of optional type ' ( Int , Int ) ? ' must be unwrapped to refer to member ' 0 ' of wrapped base type ' ( Int , Int ) ' } } <nl> / / expected - note @ - 2 { { use unwrapped type ' ( Int , Int ) ' as key path root } } { { 4 - 15 = ( Int , Int ) } } <nl> <nl> - / / TODO ( diagnostics ) Improve diagnostics refering to key path root not able to be infered as an optional type . <nl> - SR5688_KP ( \ . count ) <nl> - / / expected - error @ - 1 { { value of optional type ' String ? ' must be unwrapped to refer to member ' count ' of wrapped base type ' String ' } } <nl> + SR5688_KP ( \ . count ) / / expected - error { { key path root inferred as optional type ' String ? ' must be unwrapped to refer to member ' count ' of unwrapped type ' String ' } } <nl> + / / expected - note @ - 1 { { chain the optional using ' ? . ' to access unwrapped type member ' count ' } } { { 15 - 15 = ? . } } <nl> + / / expected - note @ - 2 { { unwrap the optional using ' ! . ' to access unwrapped type member ' count ' } } { { 15 - 15 = ! . } } <nl> + let _ : KeyPath < String ? , Int > = \ . count / / expected - error { { key path root inferred as optional type ' String ? ' must be unwrapped to refer to member ' count ' of unwrapped type ' String ' } } <nl> + / / expected - note @ - 1 { { chain the optional using ' ? . ' to access unwrapped type member ' count ' } } { { 37 - 37 = ? . } } <nl> + / / expected - note @ - 2 { { unwrap the optional using ' ! . ' to access unwrapped type member ' count ' } } { { 37 - 37 = ! . } } <nl> } <nl> <nl> func testSyntaxErrors ( ) { <nl>
Merge remote - tracking branch ' origin / master ' into master - rebranch
apple/swift
da8260c9996a209fc3d4328b40cd706187bb898e
2020-08-28T03:38:50Z
mmm a / src / rdb_protocol / stream . cc <nl> ppp b / src / rdb_protocol / stream . cc <nl> boost : : shared_ptr < scoped_cJSON_t > batched_rget_stream_t : : next ( ) { <nl> } <nl> <nl> boost : : shared_ptr < json_stream_t > batched_rget_stream_t : : add_transformation ( const rdb_protocol_details : : transform_variant_t & t , UNUSED runtime_environment_t * env2 , const scopes_t & scopes , const backtrace_t & per_op_backtrace ) { <nl> - guarantee_unreviewed ( ! started ) ; <nl> + guarantee_reviewed ( ! started ) ; <nl> transform . push_back ( rdb_protocol_details : : transform_atom_t ( t , scopes , per_op_backtrace ) ) ; <nl> return shared_from_this ( ) ; <nl> } <nl> result_t batched_rget_stream_t : : apply_terminal ( const rdb_protocol_details : : termi <nl> ns_access . get_namespace_if ( ) - > read ( read , & res , order_token_t : : ignore , interruptor ) ; <nl> } <nl> rdb_protocol_t : : rget_read_response_t * p_res = boost : : get < rdb_protocol_t : : rget_read_response_t > ( & res . response ) ; <nl> - rassert_unreviewed ( p_res ) ; <nl> + guarantee_reviewed ( p_res ) ; <nl> <nl> / * Re throw an exception if we got one . * / <nl> if ( runtime_exc_t * e = boost : : get < runtime_exc_t > ( & p_res - > result ) ) { <nl> void batched_rget_stream_t : : read_more ( ) { <nl> rdb_protocol_t : : rget_read_t rget_read ( rdb_protocol_t : : region_t ( range ) , transform ) ; <nl> rdb_protocol_t : : read_t read ( rget_read ) ; <nl> try { <nl> - guarantee_unreviewed ( ns_access . get_namespace_if ( ) ) ; <nl> + guarantee_reviewed ( ns_access . get_namespace_if ( ) ) ; <nl> rdb_protocol_t : : read_response_t res ; <nl> if ( use_outdated ) { <nl> ns_access . get_namespace_if ( ) - > read_outdated ( read , & res , interruptor ) ; <nl> void batched_rget_stream_t : : read_more ( ) { <nl> ns_access . get_namespace_if ( ) - > read ( read , & res , order_token_t : : ignore , interruptor ) ; <nl> } <nl> rdb_protocol_t : : rget_read_response_t * p_res = boost : : get < rdb_protocol_t : : rget_read_response_t > ( & res . response ) ; <nl> - guarantee_unreviewed ( p_res ) ; <nl> + guarantee_reviewed ( p_res ) ; <nl> <nl> / * Re throw an exception if we got one . * / <nl> if ( runtime_exc_t * e = boost : : get < runtime_exc_t > ( & p_res - > result ) ) { <nl> void batched_rget_stream_t : : read_more ( ) { <nl> / / todo : just do a straight copy ? <nl> typedef rdb_protocol_t : : rget_read_response_t : : stream_t stream_t ; <nl> stream_t * stream = boost : : get < stream_t > ( & p_res - > result ) ; <nl> - guarantee_unreviewed ( stream ) ; <nl> + guarantee_reviewed ( stream ) ; <nl> <nl> for ( stream_t : : iterator i = stream - > begin ( ) ; i ! = stream - > end ( ) ; + + i ) { <nl> + guarantee_reviewed ( i - > second ) ; <nl> data . push_back ( i - > second ) ; <nl> - rassert_unreviewed ( data . back ( ) ) ; <nl> } <nl> <nl> range . left = p_res - > last_considered_key ; <nl>
Reviewed assertions in stream . cc .
rethinkdb/rethinkdb
f0f17d7969a0b32860db54327133544cce3b618c
2012-09-24T23:30:12Z
mmm a / src / video_core / engines / shader_bytecode . h <nl> ppp b / src / video_core / engines / shader_bytecode . h <nl> class OpCode { <nl> BRK , <nl> DEPBAR , <nl> VOTE , <nl> + VOTE_VTG , <nl> SHFL , <nl> FSWZADD , <nl> BFE_C , <nl> class OpCode { <nl> IPA , <nl> OUT_R , / / Emit vertex / primitive <nl> ISBERD , <nl> + BAR , <nl> MEMBAR , <nl> VMAD , <nl> VSETP , <nl> class OpCode { <nl> MOV_C , <nl> MOV_R , <nl> MOV_IMM , <nl> - MOV_SYS , <nl> + S2R , <nl> MOV32_IMM , <nl> SHL_C , <nl> SHL_R , <nl> class OpCode { <nl> INST ( " 111000110000mmm - " , Id : : EXIT , Type : : Flow , " EXIT " ) , <nl> INST ( " 1111000011110mmm " , Id : : DEPBAR , Type : : Synch , " DEPBAR " ) , <nl> INST ( " 0101000011011mmm " , Id : : VOTE , Type : : Warp , " VOTE " ) , <nl> + INST ( " 0101000011100mmm " , Id : : VOTE_VTG , Type : : Warp , " VOTE_VTG " ) , <nl> INST ( " 1110111100010mmm " , Id : : SHFL , Type : : Warp , " SHFL " ) , <nl> INST ( " 0101000011111mmm " , Id : : FSWZADD , Type : : Warp , " FSWZADD " ) , <nl> INST ( " 1110111111011mmm " , Id : : LD_A , Type : : Memory , " LD_A " ) , <nl> class OpCode { <nl> INST ( " 11100000mmmmmm - - " , Id : : IPA , Type : : Trivial , " IPA " ) , <nl> INST ( " 1111101111100mmm " , Id : : OUT_R , Type : : Trivial , " OUT_R " ) , <nl> INST ( " 1110111111010mmm " , Id : : ISBERD , Type : : Trivial , " ISBERD " ) , <nl> + INST ( " 1111000010101mmm " , Id : : BAR , Type : : Trivial , " BAR " ) , <nl> INST ( " 1110111110011mmm " , Id : : MEMBAR , Type : : Trivial , " MEMBAR " ) , <nl> INST ( " 01011111mmmmmm - - " , Id : : VMAD , Type : : Video , " VMAD " ) , <nl> INST ( " 0101000011110mmm " , Id : : VSETP , Type : : Video , " VSETP " ) , <nl> class OpCode { <nl> INST ( " 0100110010011mmm " , Id : : MOV_C , Type : : Arithmetic , " MOV_C " ) , <nl> INST ( " 0101110010011mmm " , Id : : MOV_R , Type : : Arithmetic , " MOV_R " ) , <nl> INST ( " 0011100 - 10011mmm " , Id : : MOV_IMM , Type : : Arithmetic , " MOV_IMM " ) , <nl> - INST ( " 1111000011001mmm " , Id : : MOV_SYS , Type : : Trivial , " MOV_SYS " ) , <nl> + INST ( " 1111000011001mmm " , Id : : S2R , Type : : Trivial , " S2R " ) , <nl> INST ( " 000000010000mmm - " , Id : : MOV32_IMM , Type : : ArithmeticImmediate , " MOV32_IMM " ) , <nl> INST ( " 0100110001100mmm " , Id : : FMNMX_C , Type : : Arithmetic , " FMNMX_C " ) , <nl> INST ( " 0101110001100mmm " , Id : : FMNMX_R , Type : : Arithmetic , " FMNMX_R " ) , <nl> mmm a / src / video_core / shader / decode / other . cpp <nl> ppp b / src / video_core / shader / decode / other . cpp <nl> u32 ShaderIR : : DecodeOther ( NodeBlock & bb , u32 pc ) { <nl> bb . push_back ( Operation ( OperationCode : : Discard ) ) ; <nl> break ; <nl> } <nl> - case OpCode : : Id : : MOV_SYS : { <nl> + case OpCode : : Id : : S2R : { <nl> const Node value = [ this , instr ] { <nl> switch ( instr . sys20 ) { <nl> case SystemVariable : : LaneId : <nl> - LOG_WARNING ( HW_GPU , " MOV_SYS instruction with LaneId is incomplete " ) ; <nl> + LOG_WARNING ( HW_GPU , " S2R instruction with LaneId is incomplete " ) ; <nl> return Immediate ( 0U ) ; <nl> case SystemVariable : : InvocationId : <nl> return Operation ( OperationCode : : InvocationId ) ; <nl> case SystemVariable : : Ydirection : <nl> return Operation ( OperationCode : : YNegate ) ; <nl> case SystemVariable : : InvocationInfo : <nl> - LOG_WARNING ( HW_GPU , " MOV_SYS instruction with InvocationInfo is incomplete " ) ; <nl> + LOG_WARNING ( HW_GPU , " S2R instruction with InvocationInfo is incomplete " ) ; <nl> + return Immediate ( 0U ) ; <nl> + case SystemVariable : : WscaleFactorXY : <nl> + UNIMPLEMENTED_MSG ( " S2R WscaleFactorXY is not implemented " ) ; <nl> + return Immediate ( 0U ) ; <nl> + case SystemVariable : : WscaleFactorZ : <nl> + UNIMPLEMENTED_MSG ( " S2R WscaleFactorZ is not implemented " ) ; <nl> return Immediate ( 0U ) ; <nl> case SystemVariable : : Tid : { <nl> Node value = Immediate ( 0 ) ; <nl> mmm a / src / video_core / shader / shader_ir . cpp <nl> ppp b / src / video_core / shader / shader_ir . cpp <nl> Node ShaderIR : : GetConditionCode ( Tegra : : Shader : : ConditionCode cc ) const { <nl> switch ( cc ) { <nl> case Tegra : : Shader : : ConditionCode : : NEU : <nl> return GetInternalFlag ( InternalFlag : : Zero , true ) ; <nl> + case Tegra : : Shader : : ConditionCode : : FCSM_TR : <nl> + UNIMPLEMENTED_MSG ( " EXIT . FCSM_TR is not implemented " ) ; <nl> + return MakeNode < PredicateNode > ( Pred : : NeverExecute , false ) ; <nl> default : <nl> UNIMPLEMENTED_MSG ( " Unimplemented condition code : { } " , static_cast < u32 > ( cc ) ) ; <nl> return MakeNode < PredicateNode > ( Pred : : NeverExecute , false ) ; <nl>
Merge pull request from ReinUsesLisp / some - shader - encodings
yuzu-emu/yuzu
b96fd0bd0e562770399441c8164069d2437f00e7
2020-04-09T04:17:39Z
mmm a / hphp / hack / src / typing / tast_check / reified_check . ml <nl> ppp b / hphp / hack / src / typing / tast_check / reified_check . ml <nl> let verify_targ_valid env reification tparam ( ( _ , hint ) as targ ) = <nl> <nl> let verify_call_targs env expr_pos decl_pos tparams targs = <nl> ( if tparams_has_reified tparams then <nl> - let check_targ_hints = function <nl> - | ( _ , ( pos , Aast . Happly ( ( _ , class_id ) , hints ) ) ) - > <nl> - let tc = Env . get_class env class_id in <nl> - Option . iter tc ~ f : ( fun tc - > <nl> - let tparams = Cls . tparams tc in <nl> - let tparams_length = List . length tparams in <nl> - let targs_length = List . length hints in <nl> - if Int . ( < > ) tparams_length targs_length then <nl> - let c_pos = Cls . pos tc in <nl> - if Int . ( < > ) targs_length 0 then <nl> - Errors . type_arity <nl> - pos <nl> - c_pos <nl> - ~ expected : tparams_length <nl> - ~ actual : targs_length <nl> - else <nl> - Errors . require_args_reify c_pos pos ) <nl> - | _ - > ( ) <nl> - in <nl> - List . iter targs ~ f : check_targ_hints ) ; <nl> + let tparams_length = List . length tparams in <nl> + let targs_length = List . length targs in <nl> + if Int . ( < > ) tparams_length targs_length then <nl> + if Int . ( = ) targs_length 0 then <nl> + Errors . require_args_reify decl_pos expr_pos <nl> + else <nl> + ( * mismatches with targs_length > 0 are not specific to reification and handled <nl> + elsewhere * ) <nl> + ( ) ) ; <nl> let all_wildcards = List . for_all ~ f : is_wildcard targs in <nl> if all_wildcards & & tparams_has_reified tparams then <nl> Errors . require_args_reify decl_pos expr_pos <nl> let handler = <nl> <nl> method ! at_hint env = <nl> function <nl> - | ( pos , Aast . Happly ( ( _ , class_id ) , hints ) ) - > <nl> + | ( _pos , Aast . Happly ( ( _ , class_id ) , hints ) ) - > <nl> let tc = Env . get_class env class_id in <nl> Option . iter tc ~ f : ( fun tc - > <nl> let tparams = Cls . tparams tc in <nl> ignore <nl> ( List . iter2 tparams hints ~ f : ( fun tp hint - > <nl> - verify_targ_valid env Unresolved tp ( ( ) , hint ) ) ) ; <nl> - <nl> - ( * TODO : This check could be unified with the existence check above , <nl> - * but would require some consolidation T38941033 . List . iter2 gives <nl> - * a nice Or_unequal_lengths . t result that replaces this if statement * ) <nl> - let tparams_length = List . length tparams in <nl> - let targs_length = List . length hints in <nl> - if Int . ( < > ) tparams_length targs_length then <nl> - let c_pos = Cls . pos tc in <nl> - if Int . ( < > ) targs_length 0 then <nl> - Errors . type_arity <nl> - pos <nl> - c_pos <nl> - ~ expected : tparams_length <nl> - ~ actual : targs_length <nl> - else if tparams_has_reified tparams then <nl> - Errors . require_args_reify c_pos pos ) <nl> + verify_targ_valid env Unresolved tp ( ( ) , hint ) ) ) ) <nl> | _ - > ( ) <nl> <nl> method ! at_tparam env tparam = <nl> mmm a / hphp / hack / src / typing / tast_check / type_params_arity_check . ml <nl> ppp b / hphp / hack / src / typing / tast_check / type_params_arity_check . ml <nl> let handler = <nl> check_variadic_param env f . f_variadic <nl> <nl> method ! at_expr env ( _ , e ) = <nl> + let check_targs targs = <nl> + List . iter targs ( fun ( _ , hint ) - > check_hint env hint ) <nl> + in <nl> + <nl> match e with <nl> | As ( _ , h , _ ) - > check_hint env h <nl> | Is ( _ , h ) - > check_hint env h <nl> - | New ( ( _ , CI ( _ , cid ) ) , targs , _ , _ , ( p , _ ) ) - > <nl> - begin <nl> - match Env . get_class env cid with <nl> - | None - > ( ) <nl> - | Some class_ - > <nl> - let tparams_length = List . length ( Cls . tparams class_ ) in <nl> - let hargs_length = List . length targs in <nl> - let c_pos = Cls . pos class_ in <nl> - if <nl> - Int . ( < > ) hargs_length tparams_length <nl> - & & Int . ( < > ) 0 hargs_length <nl> - then <nl> - Errors . type_arity <nl> - p <nl> - c_pos <nl> - ~ expected : tparams_length <nl> - ~ actual : hargs_length <nl> - end <nl> + | FunctionPointer ( _ , targs ) <nl> + | Call ( _ , _ , targs , _ , _ ) <nl> + | New ( _ , targs , _ , _ , _ ) - > <nl> + check_targs targs <nl> | _ - > ( ) <nl> <nl> method ! at_typedef env t = <nl> new file mode 100644 <nl> index 00000000000 . . 1a90b8fe9f3 <nl> mmm / dev / null <nl> ppp b / hphp / hack / test / typecheck / function_call_targ_illformed . php <nl> <nl> + < ? hh / / strict <nl> + <nl> + class Foo < T > { } <nl> + <nl> + function foo < T > ( T $ x ) : void { } <nl> + <nl> + function test ( ) : void { <nl> + foo < Foo > ( ) ; / / bad , missing type arg on Foo <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 9eb552b5757 <nl> mmm / dev / null <nl> ppp b / hphp / hack / test / typecheck / function_call_targ_illformed . php . exp <nl> <nl> + File " function_call_targ_illformed . php " , line 8 , characters 3 - 12 : <nl> + Too few arguments ( required 1 but got 0 ) ( Typing [ 4104 ] ) <nl> + File " function_call_targ_illformed . php " , line 5 , characters 10 - 12 : <nl> + Definition is here <nl> new file mode 100644 <nl> index 00000000000 . . 897ffde063d <nl> mmm / dev / null <nl> ppp b / hphp / hack / test / typecheck / new_expression_targ_illformed . php <nl> <nl> + < ? hh / / strict <nl> + <nl> + class Test < T > { } <nl> + <nl> + function test ( ) : void { <nl> + new Test < Test > ( ) ; / / bad , missing type arg on inner Test <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 0b35c3dd804 <nl> mmm / dev / null <nl> ppp b / hphp / hack / test / typecheck / new_expression_targ_illformed . php . exp <nl> <nl> + File " new_expression_targ_illformed . php " , line 6 , characters 12 - 15 : <nl> + Wrong number of type arguments ( expected 1 , got 0 ) ( Typing [ 4101 ] ) <nl> + File " new_expression_targ_illformed . php " , line 3 , characters 7 - 10 : <nl> + Definition is here <nl> new file mode 100644 <nl> index 00000000000 . . 2435a45a549 <nl> mmm / dev / null <nl> ppp b / hphp / hack / test / typecheck / new_expression_targ_num_mismatch . php <nl> <nl> + < ? hh / / strict <nl> + <nl> + class Foo < T > { } <nl> + <nl> + function foo < T > ( ) : void { } <nl> + <nl> + function test ( ) : void { <nl> + new Foo < int , int > ( ) ; / / bad <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . ce11603592b <nl> mmm / dev / null <nl> ppp b / hphp / hack / test / typecheck / new_expression_targ_num_mismatch . php . exp <nl> <nl> + File " new_expression_targ_num_mismatch . php " , line 8 , characters 7 - 9 : <nl> + Wrong number of type arguments ( expected 1 , got 2 ) ( Typing [ 4101 ] ) <nl> + File " new_expression_targ_num_mismatch . php " , line 3 , characters 7 - 9 : <nl> + Definition is here <nl> mmm a / hphp / hack / test / typecheck / reified_generics / box_arity . php <nl> ppp b / hphp / hack / test / typecheck / reified_generics / box_arity . php <nl> function Erased_arityCheck ( ) : void { <nl> } <nl> <nl> function Reified_arityCheck ( ) : void { <nl> - new Reified < Erased > ( ) ; <nl> + new Reified < Erased > ( ) ; / / bad : Erased requires argument <nl> new Reified < Erased < int > > ( ) ; <nl> new Reified < Erased < int , string > > ( ) ; / / bad <nl> <nl> - new Reified < Reified > ( ) ; / / bad , Reified requires parameters <nl> + new Reified < Reified > ( ) ; / / bad , inner Reified requires argument <nl> new Reified < Reified < int > > ( ) ; <nl> new Reified < Reified < int , string > > ( ) ; / / bad <nl> } <nl> mmm a / hphp / hack / test / typecheck / reified_generics / box_arity . php . exp <nl> ppp b / hphp / hack / test / typecheck / reified_generics / box_arity . php . exp <nl> Wrong number of type arguments ( expected 1 , got 2 ) ( Typing [ 4101 ] ) <nl> File " box_arity . php " , line 5 , characters 7 - 13 : <nl> Definition is here <nl> File " box_arity . php " , line 18 , characters 15 - 20 : <nl> - All type arguments must be specified because a type parameter is reified ( Typing [ 4303 ] ) <nl> + Wrong number of type arguments ( expected 1 , got 0 ) ( Typing [ 4101 ] ) <nl> File " box_arity . php " , line 4 , characters 7 - 12 : <nl> Definition is here <nl> File " box_arity . php " , line 20 , characters 15 - 33 : <nl> Wrong number of type arguments ( expected 1 , got 2 ) ( Typing [ 4101 ] ) <nl> File " box_arity . php " , line 4 , characters 7 - 12 : <nl> Definition is here <nl> File " box_arity . php " , line 22 , characters 15 - 21 : <nl> - All type arguments must be specified because a type parameter is reified ( Typing [ 4303 ] ) <nl> + Wrong number of type arguments ( expected 1 , got 0 ) ( Typing [ 4101 ] ) <nl> File " box_arity . php " , line 5 , characters 7 - 13 : <nl> Definition is here <nl> File " box_arity . php " , line 24 , characters 15 - 34 : <nl> mmm a / hphp / hack / test / typecheck / reified_generics / box_keyword . php <nl> ppp b / hphp / hack / test / typecheck / reified_generics / box_keyword . php <nl> class Erased < T > { } <nl> class Reified < reify Tr > { } <nl> <nl> function Erased_keywordCheck ( ) : void { <nl> - new Erased < Erased > ( ) ; <nl> - new Erased < Erased > ( ) ; <nl> + new Erased < Erased > ( ) ; / / bad , Erased requires argument <nl> + new Erased < Erased < _ > > ( ) ; <nl> <nl> new Erased < Reified < int > > ( ) ; <nl> new Erased < Reified < int > > ( ) ; <nl> } <nl> <nl> function Reified_keywordCheck ( ) : void { <nl> - new Reified < Erased > ( ) ; <nl> - new Reified < Erased > ( ) ; <nl> + new Reified < Erased > ( ) ; / / bad , Erased requires argument <nl> + new Reified < Erased < _ > > ( ) ; <nl> <nl> new Reified < Reified < int > > ( ) ; <nl> new Reified < Reified < int > > ( ) ; <nl> mmm a / hphp / hack / test / typecheck / reified_generics / box_keyword . php . exp <nl> ppp b / hphp / hack / test / typecheck / reified_generics / box_keyword . php . exp <nl> <nl> - File " box_keyword . php " , line 16 , characters 15 - 20 : <nl> - All type arguments must be specified because a type parameter is reified ( Typing [ 4303 ] ) <nl> + File " box_keyword . php " , line 8 , characters 14 - 19 : <nl> + Wrong number of type arguments ( expected 1 , got 0 ) ( Typing [ 4101 ] ) <nl> File " box_keyword . php " , line 4 , characters 7 - 12 : <nl> Definition is here <nl> - File " box_keyword . php " , line 17 , characters 15 - 20 : <nl> - All type arguments must be specified because a type parameter is reified ( Typing [ 4303 ] ) <nl> + File " box_keyword . php " , line 16 , characters 15 - 20 : <nl> + Wrong number of type arguments ( expected 1 , got 0 ) ( Typing [ 4101 ] ) <nl> File " box_keyword . php " , line 4 , characters 7 - 12 : <nl> Definition is here <nl> + File " box_keyword . php " , line 17 , characters 15 - 23 : <nl> + Invalid reified hint ( Typing [ 4305 ] ) <nl> + File " box_keyword . php " , line 17 , characters 22 - 22 : <nl> + This is a wildcard , it cannot be used as a reified type argument <nl> + File " box_keyword . php " , line 5 , characters 21 - 22 : <nl> + Tr is reified <nl> mmm a / hphp / hack / test / typecheck / reified_generics / box_parametrized . php <nl> ppp b / hphp / hack / test / typecheck / reified_generics / box_parametrized . php <nl> class Erased < T > { } <nl> class Reified < reify Tr > { } <nl> <nl> function Erased_parametrizedCheck ( ) : void { <nl> - new Erased < Erased > ( ) ; <nl> + new Erased < Erased < _ > > ( ) ; <nl> <nl> new Erased < Reified > ( ) ; / / bad <nl> new Erased < Reified < int > > ( ) ; <nl> } <nl> <nl> function Reified_parametrizedCheck ( ) : void { <nl> - new Reified < Erased > ( ) ; <nl> + new Reified < Erased > ( ) ; / / bad <nl> <nl> new Reified < Reified > ( ) ; / / bad <nl> new Reified < Reified < int > > ( ) ; <nl> function Reified_parametrizedCheck ( ) : void { <nl> <nl> / / just some sanity checks <nl> function deepChecks ( ) : void { <nl> - new Erased < Erased < Erased > > ( ) ; <nl> + new Erased < Erased < Erased > > ( ) ; / / bad <nl> new Erased < Erased < Erased < Reified > > > ( ) ; / / bad <nl> new Erased < Erased < Erased < Reified < int > > > > ( ) ; <nl> <nl> mmm a / hphp / hack / test / typecheck / reified_generics / box_parametrized . php . exp <nl> ppp b / hphp / hack / test / typecheck / reified_generics / box_parametrized . php . exp <nl> <nl> File " box_parametrized . php " , line 13 , characters 14 - 20 : <nl> - All type arguments must be specified because a type parameter is reified ( Typing [ 4303 ] ) <nl> + Wrong number of type arguments ( expected 1 , got 0 ) ( Typing [ 4101 ] ) <nl> File " box_parametrized . php " , line 8 , characters 7 - 13 : <nl> Definition is here <nl> File " box_parametrized . php " , line 18 , characters 15 - 20 : <nl> - All type arguments must be specified because a type parameter is reified ( Typing [ 4303 ] ) <nl> + Wrong number of type arguments ( expected 1 , got 0 ) ( Typing [ 4101 ] ) <nl> File " box_parametrized . php " , line 7 , characters 7 - 12 : <nl> Definition is here <nl> File " box_parametrized . php " , line 20 , characters 15 - 21 : <nl> - All type arguments must be specified because a type parameter is reified ( Typing [ 4303 ] ) <nl> + Wrong number of type arguments ( expected 1 , got 0 ) ( Typing [ 4101 ] ) <nl> File " box_parametrized . php " , line 8 , characters 7 - 13 : <nl> Definition is here <nl> + File " box_parametrized . php " , line 26 , characters 21 - 26 : <nl> + Wrong number of type arguments ( expected 1 , got 0 ) ( Typing [ 4101 ] ) <nl> + File " box_parametrized . php " , line 7 , characters 7 - 12 : <nl> + Definition is here <nl> File " box_parametrized . php " , line 27 , characters 28 - 34 : <nl> - All type arguments must be specified because a type parameter is reified ( Typing [ 4303 ] ) <nl> + Wrong number of type arguments ( expected 1 , got 0 ) ( Typing [ 4101 ] ) <nl> File " box_parametrized . php " , line 8 , characters 7 - 13 : <nl> Definition is here <nl> File " box_parametrized . php " , line 31 , characters 29 - 35 : <nl> - All type arguments must be specified because a type parameter is reified ( Typing [ 4303 ] ) <nl> + Wrong number of type arguments ( expected 1 , got 0 ) ( Typing [ 4101 ] ) <nl> File " box_parametrized . php " , line 8 , characters 7 - 13 : <nl> Definition is here <nl> mmm a / hphp / hack / test / typecheck / reified_generics / deep_soft_reification . php <nl> ppp b / hphp / hack / test / typecheck / reified_generics / deep_soft_reification . php <nl> class SoftReified < < < __Soft > > reify T > { } <nl> class Reified < reify T > { } <nl> <nl> function new_targCheck ( ) : void { <nl> - new Erased < Erased > ( ) ; <nl> + new Erased < Erased < _ > > ( ) ; <nl> new Erased < Erased < int > > ( ) ; <nl> <nl> new Erased < SoftReified > ( ) ; / / bad <nl> mmm a / hphp / hack / test / typecheck / reified_generics / deep_soft_reification . php . exp <nl> ppp b / hphp / hack / test / typecheck / reified_generics / deep_soft_reification . php . exp <nl> <nl> File " deep_soft_reification . php " , line 12 , characters 14 - 24 : <nl> - All type arguments must be specified because a type parameter is reified ( Typing [ 4303 ] ) <nl> + Wrong number of type arguments ( expected 1 , got 0 ) ( Typing [ 4101 ] ) <nl> File " deep_soft_reification . php " , line 5 , characters 7 - 17 : <nl> Definition is here <nl> File " deep_soft_reification . php " , line 15 , characters 14 - 20 : <nl> - All type arguments must be specified because a type parameter is reified ( Typing [ 4303 ] ) <nl> + Wrong number of type arguments ( expected 1 , got 0 ) ( Typing [ 4101 ] ) <nl> File " deep_soft_reification . php " , line 6 , characters 7 - 13 : <nl> Definition is here <nl> File " deep_soft_reification . php " , line 28 , characters 26 - 31 : <nl> mmm a / hphp / hack / test / typecheck / reified_generics / funciton_call_missing_reified_generics1 . php . exp <nl> ppp b / hphp / hack / test / typecheck / reified_generics / funciton_call_missing_reified_generics1 . php . exp <nl> <nl> File " funciton_call_missing_reified_generics1 . php " , line 8 , characters 7 - 9 : <nl> - All type arguments must be specified because a type parameter is reified ( Typing [ 4303 ] ) <nl> + Wrong number of type arguments ( expected 1 , got 0 ) ( Typing [ 4101 ] ) <nl> File " hackarray . hhi " , line 15 , characters 22 - 24 : <nl> Definition is here <nl> File " funciton_call_missing_reified_generics1 . php " , line 9 , characters 7 - 9 : <nl> - All type arguments must be specified because a type parameter is reified ( Typing [ 4303 ] ) <nl> + Wrong number of type arguments ( expected 1 , got 0 ) ( Typing [ 4101 ] ) <nl> File " funciton_call_missing_reified_generics1 . php " , line 4 , characters 7 - 9 : <nl> Definition is here <nl> mmm a / hphp / hack / test / typecheck / reified_generics / funciton_call_missing_reified_generics2 . php . exp <nl> ppp b / hphp / hack / test / typecheck / reified_generics / funciton_call_missing_reified_generics2 . php . exp <nl> <nl> File " funciton_call_missing_reified_generics2 . php " , line 11 , characters 16 - 18 : <nl> - All type arguments must be specified because a type parameter is reified ( Typing [ 4303 ] ) <nl> + Wrong number of type arguments ( expected 1 , got 0 ) ( Typing [ 4101 ] ) <nl> File " hackarray . hhi " , line 15 , characters 22 - 24 : <nl> Definition is here <nl> File " funciton_call_missing_reified_generics2 . php " , line 12 , characters 12 - 14 : <nl> - All type arguments must be specified because a type parameter is reified ( Typing [ 4303 ] ) <nl> + Wrong number of type arguments ( expected 1 , got 0 ) ( Typing [ 4101 ] ) <nl> File " hackarray . hhi " , line 15 , characters 22 - 24 : <nl> Definition is here <nl> File " funciton_call_missing_reified_generics2 . php " , line 13 , characters 11 - 13 : <nl> - All type arguments must be specified because a type parameter is reified ( Typing [ 4303 ] ) <nl> + Wrong number of type arguments ( expected 1 , got 0 ) ( Typing [ 4101 ] ) <nl> File " hackarray . hhi " , line 15 , characters 22 - 24 : <nl> Definition is here <nl>
check well - formedness of types in type argument list of new & functions
facebook/hhvm
ae83a914729f7fa004ecb6e859c47cb3cb22f47b
2020-08-17T16:19:42Z
mmm a / Documentation / Books / Users / Aql / Invoke . mdpp <nl> ppp b / Documentation / Books / Users / Aql / Invoke . mdpp <nl> will be returned without any optimizations applied to it . <nl> @ EXAMPLE_ARANGOSH_OUTPUT { 11_workWithAQL_parseQueries } <nl> var stmt = db . _createStatement ( " FOR doc IN @ @ collection FILTER doc . foo = = @ bar RETURN doc " ) ; <nl> stmt . parse ( ) ; <nl> - ~ addIgnoreCollection ( " mycollection " ) <nl> + ~ removeIgnoreCollection ( " mycollection " ) <nl> ~ db . _drop ( " mycollection " ) <nl> @ END_EXAMPLE_ARANGOSH_OUTPUT <nl> @ endDocuBlock 11_workWithAQL_parseQueries <nl> mmm a / Documentation / Examples / 01_workWithAQL_all . generated <nl> ppp b / Documentation / Examples / 01_workWithAQL_all . generated <nl> <nl> arangosh & gt ; db . _create ( < span class = " hljs - string " > " mycollection " < / span > ) <nl> - [ ArangoCollection < span class = " hljs - number " > 452333090 < / span > , < span class = " hljs - string " > " mycollection " < / span > ( type < span class = " hljs - built_in " > document < / span > , status loaded ) ] <nl> + [ ArangoCollection < span class = " hljs - number " > 997012029636 < / span > , < span class = " hljs - string " > " mycollection " < / span > ( type < span class = " hljs - built_in " > document < / span > , status loaded ) ] <nl> arangosh & gt ; db . mycollection . save ( { _key : < span class = " hljs - string " > " testKey " < / span > , Hello : < span class = " hljs - string " > " World " < / span > } ) <nl> { <nl> < span class = " hljs - string " > " _id " < / span > : < span class = " hljs - string " > " mycollection / testKey " < / span > , <nl> - < span class = " hljs - string " > " _rev " < / span > : < span class = " hljs - string " > " 452660770 " < / span > , <nl> + < span class = " hljs - string " > " _rev " < / span > : < span class = " hljs - string " > " 997012357316 " < / span > , <nl> < span class = " hljs - string " > " _key " < / span > : < span class = " hljs - string " > " testKey " < / span > <nl> } <nl> arangosh & gt ; db . _query ( < span class = " hljs - string " > ' FOR my IN mycollection RETURN my . _key ' < / span > ) . toArray ( ) <nl> mmm a / Documentation / Examples / 09_workWithAQL_statementsPlansBind . generated <nl> ppp b / Documentation / Examples / 09_workWithAQL_statementsPlansBind . generated <nl> arangosh & gt ; stmt . explain ( ) ; <nl> ] , <nl> < span class = " hljs - string " > " index " < / span > : { <nl> < span class = " hljs - string " > " type " < / span > : < span class = " hljs - string " > " hash " < / span > , <nl> - < span class = " hljs - string " > " id " < / span > : < span class = " hljs - string " > " 527906 " < / span > , <nl> + < span class = " hljs - string " > " id " < / span > : < span class = " hljs - string " > " 879605 " < / span > , <nl> < span class = " hljs - string " > " unique " < / span > : < span class = " hljs - literal " > true < / span > , <nl> < span class = " hljs - string " > " sparse " < / span > : < span class = " hljs - literal " > true < / span > , <nl> < span class = " hljs - string " > " selectivityEstimate " < / span > : < span class = " hljs - number " > 1 < / span > , <nl>
Generate examples , fix cleanup
arangodb/arangodb
da1f023de6f0eb25123476f65632366f549f827e
2015-09-14T09:22:39Z
mmm a / doc / parameter . rst <nl> ppp b / doc / parameter . rst <nl> Parameters for Tree Booster <nl> <nl> * ` ` colsample_bylevel ` ` [ default = 1 ] <nl> <nl> - - Subsample ratio of columns for each split , in each level . Subsampling will occur each time a new split is made . This parameter has no effect when ` ` tree_method ` ` is set to ` ` hist ` ` . <nl> + - Subsample ratio of columns for each split , in each level . Subsampling will occur each time a new split is made . <nl> - range : ( 0 , 1 ] <nl> <nl> * ` ` lambda ` ` [ default = 1 , alias : ` ` reg_lambda ` ` ] <nl>
Update doc : colsample_bylevel now works for tree_method = hist ( )
dmlc/xgboost
a650131fc338422df731cb64082115cadc5791e9
2018-11-04T10:25:25Z
mmm a / dbms / include / DB / Common / ProfileEvents . h <nl> ppp b / dbms / include / DB / Common / ProfileEvents . h <nl> <nl> M ( DistributedConnectionFailTry ) \ <nl> M ( DistributedConnectionFailAtAll ) \ <nl> \ <nl> + M ( CompileAttempt ) \ <nl> + M ( CompileSuccess ) \ <nl> + \ <nl> M ( END ) <nl> <nl> namespace ProfileEvents <nl> mmm a / dbms / src / Interpreters / Compiler . cpp <nl> ppp b / dbms / src / Interpreters / Compiler . cpp <nl> void Compiler : : compile ( <nl> CodeGenerator get_code , <nl> ReadyCallback on_ready ) <nl> { <nl> + ProfileEvents : : increment ( ProfileEvents : : CompileAttempt ) ; <nl> + <nl> std : : string prefix = path + " / " + file_name ; <nl> std : : string cpp_file_path = prefix + " . cpp " ; <nl> std : : string so_file_path = prefix + " . so " ; <nl> void Compiler : : compile ( <nl> } <nl> <nl> LOG_INFO ( log , " Compiled code " < < file_name ) ; <nl> + ProfileEvents : : increment ( ProfileEvents : : CompileSuccess ) ; <nl> <nl> on_ready ( lib ) ; <nl> } <nl>
dbms : added ProfileEvents for Compiler [ # METR - 16212 ] .
ClickHouse/ClickHouse
9c99febfc318c686ada3ad20b290e546f2850b17
2015-05-05T15:50:20Z
mmm a / src / hydrogen . cc <nl> ppp b / src / hydrogen . cc <nl> void HInferRepresentation : : Analyze ( ) { <nl> bool change = true ; <nl> while ( change ) { <nl> change = false ; <nl> - for ( int i = 0 ; i < phi_count ; + + i ) { <nl> + / / We normally have far more " forward edges " than " backward edges " , <nl> + / / so we terminate faster when we walk backwards . <nl> + for ( int i = phi_count - 1 ; i > = 0 ; - - i ) { <nl> HPhi * phi = phi_list - > at ( i ) ; <nl> for ( HUseIterator it ( phi - > uses ( ) ) ; ! it . Done ( ) ; it . Advance ( ) ) { <nl> HValue * use = it . value ( ) ; <nl>
Improved phi reachability computation a bit .
v8/v8
ffb70bc8439325b541536355ddfd4991adda2ed9
2011-09-08T07:40:11Z
mmm a / bazel / repository_locations . bzl <nl> ppp b / bazel / repository_locations . bzl <nl> REPOSITORY_LOCATIONS = dict ( <nl> urls = [ " https : / / storage . googleapis . com / envoyproxy - wee8 / wee8 - 8 . 0 . 426 . 12 . tar . gz " ] , <nl> ) , <nl> com_googlesource_quiche = dict ( <nl> - # Static snapshot of https : / / quiche . googlesource . com / quiche / + archive / 4f6ba16cf16505f12dc8d2f23cfc6e13c1aa5806 . tar . gz <nl> - sha256 = " 2990ca4434a6fc1b63560b1aa000f5765c174ad906642e123a92498f1ad6c03d " , <nl> - urls = [ " https : / / storage . googleapis . com / quiche - envoy - integration / 4f6ba16cf16505f12dc8d2f23cfc6e13c1aa5806 . tar . gz " ] , <nl> + # Static snapshot of https : / / quiche . googlesource . com / quiche / + archive / 41c9fdead26b31deefae3c325a2cf1a873688ba3 . tar . gz <nl> + sha256 = " 75af53154402e1654cfd32d8aaeed5fab4dbb79d3cab8c9866019d5369c1889e " , <nl> + urls = [ " https : / / storage . googleapis . com / quiche - envoy - integration / 41c9fdead26b31deefae3c325a2cf1a873688ba3 . tar . gz " ] , <nl> ) , <nl> com_google_cel_cpp = dict ( <nl> sha256 = " 326ec397b55e39f48bd5380ccded1af5b04653ee96e769cd4d694f9a3bacef50 " , <nl> mmm a / source / extensions / quic_listeners / quiche / platform / flags_list . h <nl> ppp b / source / extensions / quic_listeners / quiche / platform / flags_list . h <nl> <nl> <nl> # if defined ( QUICHE_FLAG ) <nl> <nl> - QUICHE_FLAG ( bool , http2_reloadable_flag_http2_add_backend_ping_manager , false , <nl> + QUICHE_FLAG ( bool , http2_reloadable_flag_http2_add_backend_ping_manager , true , <nl> " If true , SpdyBackendDispatcher will instantiate and use a PeriodicPingManager for " <nl> " handling PING logic . " ) <nl> <nl> QUICHE_FLAG ( <nl> bool , http2_reloadable_flag_http2_backend_alpn_failure_error_code , false , <nl> " If true , the GFE will return a new ResponseCodeDetails error when ALPN to the backend fails . " ) <nl> <nl> - QUICHE_FLAG ( bool , http2_reloadable_flag_http2_refactor_client_ping_rtt , true , <nl> - " If true , logic for coordinating RTT PINGs moves from " <nl> - " SpdyClientDispatcher : : PingManager into SpdyClientDispatcher proper . No expected " <nl> - " functional change , but protected out of an abundance of caution . " ) <nl> - <nl> QUICHE_FLAG ( bool , http2_reloadable_flag_http2_security_requirement_for_client3 , false , <nl> " If true , check whether client meets security requirements during SSL handshake . If " <nl> " flag is true and client does not meet security requirements , do not negotiate HTTP / 2 " <nl> QUICHE_FLAG ( bool , http2_reloadable_flag_http2_security_requirement_for_client3 , <nl> " already negotiated . The spec contains both cipher and TLS version requirements . " ) <nl> <nl> QUICHE_FLAG ( <nl> - bool , http2_reloadable_flag_http2_skip_querying_entry_buffer_error , false , <nl> + bool , http2_reloadable_flag_http2_skip_querying_entry_buffer_error , true , <nl> " If true , do not query entry_buffer_ . error_detected ( ) in HpackDecoder : : error_detected ( ) . " ) <nl> <nl> QUICHE_FLAG ( <nl> - bool , http2_reloadable_flag_http2_support_periodic_ping_manager_cbs , false , <nl> + bool , http2_reloadable_flag_http2_support_periodic_ping_manager_cbs , true , <nl> " If true , PeriodicPingManager will invoke user - provided callbacks on receiving PING acks . " ) <nl> <nl> QUICHE_FLAG ( <nl> - bool , http2_reloadable_flag_http2_use_settings_rtt_in_ping_manager , false , <nl> + bool , http2_reloadable_flag_http2_use_settings_rtt_in_ping_manager , true , <nl> " If true along with - - gfe2_reloadable_flag_http2_add_backend_ping_manager , SpdyDispatcher will " <nl> " bootstrap its PingManager RTT with the RTT determined from the initial SETTINGS < - - > ack . " ) <nl> <nl> QUICHE_FLAG ( bool , quic_reloadable_flag_quic_allow_client_enabled_bbr_v2 , true , <nl> QUICHE_FLAG ( bool , quic_reloadable_flag_quic_alpn_dispatch , false , <nl> " Support different QUIC sessions , as indicated by ALPN . Used for QBONE . " ) <nl> <nl> - QUICHE_FLAG ( bool , quic_reloadable_flag_quic_arm_pto_with_earliest_sent_time , false , <nl> + QUICHE_FLAG ( bool , quic_reloadable_flag_quic_arm_pto_with_earliest_sent_time , true , <nl> " If true , arm the 1st PTO with earliest in flight sent time . " ) <nl> <nl> - QUICHE_FLAG ( bool , quic_reloadable_flag_quic_avoid_overestimate_bandwidth_with_aggregation , false , <nl> + QUICHE_FLAG ( bool , quic_reloadable_flag_quic_avoid_overestimate_bandwidth_with_aggregation , true , <nl> " If true , fix QUIC bandwidth sampler to avoid over estimating bandwidth in the " <nl> " presence of ack aggregation . " ) <nl> <nl> - QUICHE_FLAG ( <nl> - bool , quic_reloadable_flag_quic_batch_writer_flush_after_mtu_probe , true , <nl> - " If true and batch writer is used , QuicConnection will flush after a mtu probe is sent . " ) <nl> - <nl> QUICHE_FLAG ( bool , quic_reloadable_flag_quic_bbr2_add_ack_height_to_queueing_threshold , false , <nl> " If true , QUIC BBRv2 to take ack height into account when calculating " <nl> " queuing_threshold in PROBE_UP . " ) <nl> <nl> - QUICHE_FLAG ( bool , quic_reloadable_flag_quic_bbr2_avoid_unnecessary_probe_rtt , false , <nl> + QUICHE_FLAG ( bool , quic_reloadable_flag_quic_bbr2_avoid_unnecessary_probe_rtt , true , <nl> " If true , QUIC BBRv2 to avoid unnecessary PROBE_RTTs after quiescence . " ) <nl> <nl> QUICHE_FLAG ( bool , quic_reloadable_flag_quic_bbr_donot_inject_bandwidth , true , <nl> QUICHE_FLAG ( bool , quic_reloadable_flag_quic_bbr_donot_inject_bandwidth , true , <nl> QUICHE_FLAG ( bool , quic_reloadable_flag_quic_bbr_fix_pacing_rate , true , <nl> " If true , re - calculate pacing rate when cwnd gets bootstrapped . " ) <nl> <nl> + QUICHE_FLAG ( <nl> + bool , quic_reloadable_flag_quic_bbr_fix_zero_bw_on_loss_only_event , false , <nl> + " If true , fix a bug in QUIC BBR where bandwidth estimate becomes 0 after a loss only event . " ) <nl> + <nl> QUICHE_FLAG ( bool , quic_reloadable_flag_quic_bbr_flexible_app_limited , false , <nl> " When true and the BBR9 connection option is present , BBR only considers bandwidth " <nl> " samples app - limited if they ' re not filling the pipe . " ) <nl> QUICHE_FLAG ( bool , quic_reloadable_flag_quic_bbr_startup_rate_reduction , false , <nl> " When true , enables the BBS4 and BBS5 connection options , which reduce BBR ' s pacing " <nl> " rate in STARTUP as more losses occur as a fraction of CWND . " ) <nl> <nl> - QUICHE_FLAG ( bool , quic_reloadable_flag_quic_better_mtu_packet_check , true , <nl> - " If true , QuicConnection will check MTU_DISCOVERY_FRAME in nonretransmittable_frames " <nl> - " to see if a packet is a MTU probe . " ) <nl> - <nl> - QUICHE_FLAG ( bool , quic_reloadable_flag_quic_bundle_retransmittable_with_pto_ack , false , <nl> + QUICHE_FLAG ( bool , quic_reloadable_flag_quic_bundle_retransmittable_with_pto_ack , true , <nl> " When the EACK connection option is sent by the client , an ack - eliciting frame is " <nl> " bundled with ACKs sent after the PTO fires . " ) <nl> <nl> - QUICHE_FLAG ( bool , quic_reloadable_flag_quic_check_handshake_timeout_before_idle_timeout , true , <nl> - " If true , QuicConnection will check handshake timeout before idle timeout . " ) <nl> + QUICHE_FLAG ( bool , quic_reloadable_flag_quic_bw_sampler_app_limited_starting_value , false , <nl> + " If true , quic : : BandwidthSampler will start in application limited phase . " ) <nl> <nl> QUICHE_FLAG ( bool , quic_reloadable_flag_quic_conservative_bursts , false , <nl> " If true , set burst token to 2 in cwnd bootstrapping experiment . " ) <nl> QUICHE_FLAG ( bool , quic_reloadable_flag_quic_conservative_bursts , false , <nl> QUICHE_FLAG ( bool , quic_reloadable_flag_quic_conservative_cwnd_and_pacing_gains , false , <nl> " If true , uses conservative cwnd gain and pacing gain when cwnd gets bootstrapped . " ) <nl> <nl> + QUICHE_FLAG ( bool , quic_reloadable_flag_quic_create_incoming_stream_bug , false , <nl> + " If true , trigger QUIC_BUG in two ShouldCreateIncomingStream ( ) overrides when called " <nl> + " with locally initiated stream ID . " ) <nl> + <nl> QUICHE_FLAG ( bool , quic_reloadable_flag_quic_debug_wrong_qos , false , <nl> " If true , consider getting QoS after stream has been detached as GFE bug . " ) <nl> <nl> QUICHE_FLAG ( <nl> bool , quic_reloadable_flag_quic_do_not_accept_stop_waiting , false , <nl> " In v44 and above , where STOP_WAITING is never sent , close the connection if it ' s received . " ) <nl> <nl> - QUICHE_FLAG ( bool , quic_reloadable_flag_quic_donot_dispatch_data_when_disconnected , true , <nl> - " If true , do not dispatch data if connection disconnected . " ) <nl> - <nl> QUICHE_FLAG ( bool , quic_reloadable_flag_quic_donot_reset_ideal_next_packet_send_time , false , <nl> " If true , stop resetting ideal_next_packet_send_time_ in pacing sender . " ) <nl> <nl> QUICHE_FLAG ( bool , quic_reloadable_flag_quic_enable_version_draft_25_v3 , false , <nl> QUICHE_FLAG ( bool , quic_reloadable_flag_quic_enable_version_draft_27 , false , <nl> " If true , enable QUIC version h3 - 27 . " ) <nl> <nl> - QUICHE_FLAG ( bool , quic_reloadable_flag_quic_enable_version_t050 , false , <nl> + QUICHE_FLAG ( bool , quic_reloadable_flag_quic_enable_version_t050 , true , <nl> " If true , enable QUIC version T050 . " ) <nl> <nl> QUICHE_FLAG ( bool , quic_reloadable_flag_quic_enabled , false , " " ) <nl> QUICHE_FLAG ( bool , quic_reloadable_flag_quic_enabled , false , " " ) <nl> QUICHE_FLAG ( bool , quic_reloadable_flag_quic_fix_bbr_cwnd_in_bandwidth_resumption , true , <nl> " If true , adjust congestion window when doing bandwidth resumption in BBR . " ) <nl> <nl> + QUICHE_FLAG ( bool , quic_reloadable_flag_quic_ignore_one_write_error_after_mtu_probe , false , <nl> + " If true , QUIC connection will ignore one packet write error after MTU probe . " ) <nl> + <nl> QUICHE_FLAG ( bool , quic_reloadable_flag_quic_listener_never_fake_epollout , false , <nl> " If true , QuicListener : : OnSocketIsWritable will always return false , which means there " <nl> " will never be a fake EPOLLOUT event in the next epoll iteration . " ) <nl> <nl> QUICHE_FLAG ( <nl> - bool , quic_reloadable_flag_quic_minimum_validation_of_coalesced_packets , false , <nl> + bool , quic_reloadable_flag_quic_minimum_validation_of_coalesced_packets , true , <nl> " If true , only do minimum validation of coalesced packets ( only validate connection ID ) . " ) <nl> <nl> QUICHE_FLAG ( bool , quic_reloadable_flag_quic_negotiate_ack_delay_time , false , <nl> " If true , will negotiate the ACK delay time . " ) <nl> <nl> - QUICHE_FLAG ( <nl> - bool , quic_reloadable_flag_quic_neuter_unencrypted_control_frames , true , <nl> - " If true , neuter unencrypted control frames in QuicUnackedPacketMap : : NeuterUnencryptedPackets . " ) <nl> - <nl> QUICHE_FLAG ( bool , quic_reloadable_flag_quic_no_dup_experiment_id_2 , false , <nl> " If true , transport connection stats doesn ' t report duplicated experiments for same " <nl> " connection . " ) <nl> <nl> - QUICHE_FLAG ( bool , quic_reloadable_flag_quic_no_window_update_if_disconnected , true , <nl> - " If true , do not send WINDOW_UPDATE if connection has been disconnected . " ) <nl> - <nl> QUICHE_FLAG ( bool , quic_reloadable_flag_quic_populate_mean_rtt_deviation_in_tcs , true , <nl> " If true , populate mean rtt deviation in transport connection stats . " ) <nl> <nl> QUICHE_FLAG ( bool , quic_reloadable_flag_quic_proxy_write_packed_strings , false , <nl> <nl> QUICHE_FLAG ( bool , quic_reloadable_flag_quic_record_frontend_service_vip_mapping , false , <nl> " If true , for L1 GFE , as requests come in , record frontend service to VIP mapping " <nl> - " which is used to announce VIP in SHLO for proxied sessions . " ) <nl> + " which is used to announce VIP in SHLO for proxied sessions . " ) <nl> <nl> QUICHE_FLAG ( bool , quic_reloadable_flag_quic_reject_all_traffic , false , " " ) <nl> <nl> QUICHE_FLAG ( bool , quic_reloadable_flag_quic_require_handshake_confirmation , fals <nl> " If true , require handshake confirmation for QUIC connections , functionally disabling " <nl> " 0 - rtt handshakes . " ) <nl> <nl> + QUICHE_FLAG ( bool , quic_reloadable_flag_quic_send_ping_when_pto_skips_packet_number , false , <nl> + " If true , send PING when PTO skips packet number and there is no data to send . " ) <nl> + <nl> QUICHE_FLAG ( bool , quic_reloadable_flag_quic_send_timestamps , false , <nl> " When the STMP connection option is sent by the client , timestamps in the QUIC ACK " <nl> " frame are sent and processed . " ) <nl> QUICHE_FLAG ( bool , quic_reloadable_flag_quic_send_timestamps , false , <nl> QUICHE_FLAG ( bool , quic_reloadable_flag_quic_server_push , true , <nl> " If true , enable server push feature on QUIC . " ) <nl> <nl> - QUICHE_FLAG ( bool , quic_reloadable_flag_quic_set_send_algorithm_noop_if_cc_type_unchanged , true , <nl> - " If true , QuicSentPacketManager : : SetSendAlgorithm ( CongestionControlType ) will become a " <nl> - " no - op if the current and the requested cc_type are the same . " ) <nl> - <nl> QUICHE_FLAG ( bool , quic_reloadable_flag_quic_skip_packet_threshold_loss_detection_with_runt , false , <nl> " If true , skip packet threshold loss detection if largest acked is a runt . " ) <nl> <nl> QUICHE_FLAG ( bool , quic_reloadable_flag_quic_use_pigeon_sockets , false , <nl> " Use USPS Direct Path for QUIC egress . " ) <nl> <nl> QUICHE_FLAG ( <nl> - bool , quic_reloadable_flag_quic_use_quic_time_for_received_timestamp2 , false , <nl> + bool , quic_reloadable_flag_quic_use_quic_time_for_received_timestamp2 , true , <nl> " If true , use QuicClock : : Now ( ) as the source of packet receive time instead of WallNow ( ) . " ) <nl> <nl> - QUICHE_FLAG ( bool , quic_reloadable_flag_quic_use_standard_deviation_for_pto , false , <nl> + QUICHE_FLAG ( bool , quic_reloadable_flag_quic_use_standard_deviation_for_pto , true , <nl> " If true , use standard deviation when calculating PTO timeout . " ) <nl> <nl> + QUICHE_FLAG ( bool , quic_reloadable_flag_quic_write_with_transmission , false , <nl> + " If true , QuicSession ' s various write methods will set transmission type . " ) <nl> + <nl> QUICHE_FLAG ( <nl> - bool , quic_reloadable_flag_quic_writevdata_at_level , false , <nl> + bool , quic_reloadable_flag_quic_writevdata_at_level , true , <nl> " If true , QuicSession : : WritevData ( ) will support writing data at a specified encryption level . " ) <nl> <nl> QUICHE_FLAG ( bool , quic_reloadable_flag_send_quic_fallback_server_config_on_leto_error , false , <nl> QUICHE_FLAG ( bool , quic_restart_flag_quic_offload_pacing_to_usps2 , false , <nl> QUICHE_FLAG ( bool , quic_restart_flag_quic_rx_ring_use_tpacket_v3 , false , <nl> " If true , use TPACKET_V3 for QuicRxRing instead of TPACKET_V2 . " ) <nl> <nl> + QUICHE_FLAG ( bool , quic_restart_flag_quic_send_settings_on_write_key_available , false , <nl> + " If true , send H3 SETTINGs when 1 - RTT write key is available ( rather then both keys " <nl> + " are available ) . " ) <nl> + <nl> QUICHE_FLAG ( bool , quic_restart_flag_quic_should_accept_new_connection , false , <nl> " If true , reject QUIC CHLO packets when dispatcher is asked to do so . " ) <nl> <nl> QUICHE_FLAG ( bool , quic_restart_flag_quic_use_pigeon_socket_to_backend , false , <nl> " If true , create a shared pigeon socket for all quic to backend connections and switch " <nl> " to use it after successful handshake . " ) <nl> <nl> - QUICHE_FLAG ( bool , quic_restart_flag_quic_use_rxring_when_explicitly_specified , true , <nl> - " If true , GFE will use QuicRxRing for ingress only when ingress_method is explicitly " <nl> - " set to RXRING_INGRESS in quic_config . " ) <nl> - <nl> QUICHE_FLAG ( <nl> bool , spdy_reloadable_flag_spdy_discard_response_body_if_disallowed , false , <nl> " If true , SPDY will discard all response body bytes when response code indicates no response " <nl> QUICHE_FLAG ( int32_t , quic_bbr2_default_probe_bw_max_rand_duration_ms , 1000 , <nl> QUICHE_FLAG ( int32_t , quic_bbr2_default_probe_rtt_period_ms , 10000 , <nl> " The default period for entering PROBE_RTT , in milliseconds . " ) <nl> <nl> - QUICHE_FLAG ( double , quic_bbr2_default_loss_threshold , 0 . 3 , <nl> + QUICHE_FLAG ( double , quic_bbr2_default_loss_threshold , 0 . 02 , <nl> " The default loss threshold for QUIC BBRv2 , should be a value " <nl> " between 0 and 1 . " ) <nl> <nl> - QUICHE_FLAG ( int32_t , quic_bbr2_default_startup_full_loss_count , 2 , <nl> + QUICHE_FLAG ( int32_t , quic_bbr2_default_startup_full_loss_count , 8 , <nl> " The default minimum number of loss marking events to exit STARTUP . " ) <nl> <nl> QUICHE_FLAG ( int32_t , quic_bbr2_default_probe_bw_full_loss_count , 2 , <nl>
quiche : update tar ( )
envoyproxy/envoy
bd08435eed6e435c261bccdc0e178aa8e7a4fd4f
2020-03-23T18:49:01Z
mmm a / scene / resources / material . cpp <nl> ppp b / scene / resources / material . cpp <nl> void SpatialMaterial : : _update_shader ( ) { <nl> } <nl> <nl> code + = " \ t \ tbase_uv = ofs ; \ n " ; <nl> + code + = " \ t \ tif ( base_uv . x > 1 . 0 | | base_uv . y > 1 . 0 | | base_uv . x < 0 . 0 | | base_uv . y < 0 . 0 ) \ n " ; <nl> + code + = " \ t \ t \ tdiscard ; \ n " ; <nl> if ( features [ FEATURE_DETAIL ] & & detail_uv = = DETAIL_UV_2 ) { <nl> code + = " \ t \ tbase_uv2 - = ofs ; \ n " ; <nl> } <nl>
Merge pull request from guilhermefelipecgs / fix_border_artifact
godotengine/godot
e651102b6f2d4aad48db37ee4017415db031f302
2018-08-14T07:45:38Z
mmm a / Marlin / src / gcode / bedlevel / abl / G29 . cpp <nl> ppp b / Marlin / src / gcode / bedlevel / abl / G29 . cpp <nl> <nl> * <nl> * S Set the XY travel speed between probe points ( in units / min ) <nl> * <nl> + * H Set bounds to a centered square H x H units in size <nl> + * <nl> + * - or - <nl> + * <nl> * F Set the Front limit of the probing grid <nl> * B Set the Back limit of the probing grid <nl> * L Set the Left limit of the probing grid <nl> G29_TYPE GcodeSuite : : G29 ( ) { <nl> <nl> xy_probe_feedrate_mm_s = MMM_TO_MMS ( parser . linearval ( ' S ' , XY_PROBE_SPEED ) ) ; <nl> <nl> - left_probe_bed_position = parser . seenval ( ' L ' ) ? ( int ) RAW_X_POSITION ( parser . value_linear_units ( ) ) : LEFT_PROBE_BED_POSITION ; <nl> - right_probe_bed_position = parser . seenval ( ' R ' ) ? ( int ) RAW_X_POSITION ( parser . value_linear_units ( ) ) : RIGHT_PROBE_BED_POSITION ; <nl> - front_probe_bed_position = parser . seenval ( ' F ' ) ? ( int ) RAW_Y_POSITION ( parser . value_linear_units ( ) ) : FRONT_PROBE_BED_POSITION ; <nl> - back_probe_bed_position = parser . seenval ( ' B ' ) ? ( int ) RAW_Y_POSITION ( parser . value_linear_units ( ) ) : BACK_PROBE_BED_POSITION ; <nl> + if ( parser . seen ( ' H ' ) ) { <nl> + const int16_t size = ( int16_t ) parser . value_linear_units ( ) ; <nl> + left_probe_bed_position = MAX ( ( MIN_PROBE_X + MAX_PROBE_X - size ) / 2 , MIN_PROBE_X ) ; <nl> + right_probe_bed_position = MIN ( left_probe_bed_position + size , MAX_PROBE_X ) ; <nl> + front_probe_bed_position = MAX ( ( MIN_PROBE_Y + MAX_PROBE_Y - size ) / 2 , MIN_PROBE_Y ) ; <nl> + back_probe_bed_position = MIN ( front_probe_bed_position + size , MAX_PROBE_Y ) ; <nl> + } <nl> + else { <nl> + left_probe_bed_position = parser . seenval ( ' L ' ) ? ( int ) RAW_X_POSITION ( parser . value_linear_units ( ) ) : LEFT_PROBE_BED_POSITION ; <nl> + right_probe_bed_position = parser . seenval ( ' R ' ) ? ( int ) RAW_X_POSITION ( parser . value_linear_units ( ) ) : RIGHT_PROBE_BED_POSITION ; <nl> + front_probe_bed_position = parser . seenval ( ' F ' ) ? ( int ) RAW_Y_POSITION ( parser . value_linear_units ( ) ) : FRONT_PROBE_BED_POSITION ; <nl> + back_probe_bed_position = parser . seenval ( ' B ' ) ? ( int ) RAW_Y_POSITION ( parser . value_linear_units ( ) ) : BACK_PROBE_BED_POSITION ; <nl> + } <nl> <nl> if ( <nl> # if IS_SCARA | | ENABLED ( DELTA ) <nl> mmm a / Marlin / src / module / probe . cpp <nl> ppp b / Marlin / src / module / probe . cpp <nl> FORCE_INLINE void probe_specific_action ( const bool deploy ) { <nl> deploy ? run_deploy_moves_script ( ) : run_stow_moves_script ( ) ; <nl> <nl> # elif ENABLED ( RACK_AND_PINION_PROBE ) <nl> - <nl> + <nl> do_blocking_move_to_x ( deploy ? Z_PROBE_DEPLOY_X : Z_PROBE_RETRACT_X ) ; <nl> <nl> # endif <nl>
' G29 H ' to set a centered square probe area ( linear , bilinear ) ( )
MarlinFirmware/Marlin
6fbc87301f628bf859933fc69064008fc9726806
2018-10-28T01:30:21Z
mmm a / Makefile <nl> ppp b / Makefile <nl> CNTKLIBRARY_TESTS_SRC = \ <nl> Tests / UnitTests / V2LibraryTests / FunctionTests . cpp \ <nl> Tests / UnitTests / V2LibraryTests / SequenceClassification . cpp \ <nl> Tests / UnitTests / V2LibraryTests / Seq2Seq . cpp \ <nl> + Tests / UnitTests / V2LibraryTests / TruncatedLSTMAcousticModel . cpp \ <nl> Examples / Evaluation / CPPEvalV2Client / EvalMultithreads . cpp \ <nl> <nl> CNTKLIBRARY_TESTS : = $ ( BINDIR ) / v2librarytests <nl> mmm a / Source / CNTKv2LibraryDll / API / CNTKLibrary . h <nl> ppp b / Source / CNTKv2LibraryDll / API / CNTKLibrary . h <nl> namespace CNTK <nl> / / / <nl> virtual bool IsReadOnly ( ) const { return m_data - > IsReadOnly ( ) ; } <nl> <nl> + / / / <nl> + / / / Returns the number of masked / invalid values <nl> + / / / <nl> + virtual size_t MaskedCount ( ) const <nl> + { <nl> + return m_mask ? m_mask - > MaskedCount ( ) : 0 ; <nl> + } <nl> + <nl> / / / <nl> / / / Returns the NDArrayView object corresponding to the data contents of ' this value object . <nl> / / / <nl> namespace CNTK <nl> / / / <nl> class Learner : public std : : enable_shared_from_this < Learner > <nl> { <nl> + static const std : : wstring LearningRateAttributeName ; <nl> + <nl> public : <nl> / / <nl> / / Method to update the parameters associated with this learner . By returning false , this method indicates that <nl> namespace CNTK <nl> / / / <nl> / / TODO : move the following two methods into ISerializable interface , make <nl> / / Learner ( and all other entities that need checkpointing capability ) implement it . <nl> - CNTK_API virtual Dictionary GetCheckpointState ( ) const { return Dictionary ( ) ; } <nl> + CNTK_API virtual Dictionary GetCheckpointState ( ) const <nl> + { <nl> + Dictionary baseCheckpointState ; <nl> + baseCheckpointState [ LearningRateAttributeName ] = m_learningRate ; <nl> + <nl> + return baseCheckpointState ; <nl> + } <nl> <nl> / / / <nl> / / / Optionally overridable method to restore the learner ' s state from a previous checkpoint . <nl> / / / <nl> - CNTK_API virtual void RestoreFromCheckpoint ( const Dictionary & / * checkpoint * / ) { } <nl> + CNTK_API virtual void RestoreFromCheckpoint ( const Dictionary & checkpoint ) <nl> + { <nl> + if ( checkpoint . Contains ( LearningRateAttributeName ) ) <nl> + m_learningRate = checkpoint [ LearningRateAttributeName ] . Value < double > ( ) ; <nl> + } <nl> <nl> / / / <nl> / / / Destruct this Learner . <nl> / / / <nl> virtual ~ Learner ( ) { } <nl> <nl> + CNTK_API virtual void ResetLearningRate ( double learningRate ) { m_learningRate = learningRate ; } <nl> + CNTK_API virtual double LearningRate ( ) const { return m_learningRate ; } <nl> + <nl> protected : <nl> - Learner ( const std : : vector < Parameter > & parameters ) <nl> - : m_parameters ( parameters . begin ( ) , parameters . end ( ) ) <nl> + Learner ( const std : : vector < Parameter > & parameters , double learningRate ) <nl> + : m_parameters ( parameters . begin ( ) , parameters . end ( ) ) , m_learningRate ( learningRate ) <nl> { } <nl> <nl> std : : unordered_set < Parameter > m_parameters ; <nl> - <nl> + double m_learningRate ; <nl> } ; <nl> <nl> / / / <nl> namespace CNTK <nl> FunctionPtr m_combinedTrainingFunction ; <nl> FunctionPtr m_model ; <nl> FunctionPtr m_lossFunction ; <nl> + FunctionPtr m_aggregatedLossFunction ; <nl> FunctionPtr m_evaluationFunction ; <nl> + FunctionPtr m_aggregatedEvaluationFunction ; <nl> <nl> std : : unordered_set < LearnerPtr > m_parameterLearners ; <nl> <nl> namespace CNTK <nl> CNTK_API void ComputeInputPerDimMeansAndInvStdDevs ( const MinibatchSourcePtr & minibatchSource , <nl> std : : unordered_map < StreamInformation , std : : pair < NDArrayViewPtr , NDArrayViewPtr > > & computedMeanAndVariances , <nl> const DeviceDescriptor & device = DeviceDescriptor : : CPUDevice ( ) ) ; <nl> + <nl> + / / / <nl> + / / / Set the process - wide setting for maximum number of CPU threads to be used by any individual compute operation <nl> + / / / Note that this is a per compute operation limit and if the user performs multiple compute operations concurrently <nl> + / / / by launching multiple threads and performing a compute operation inside , it will result in each of those concurrently <nl> + / / / executing operations to use the specified number of CPU threads limit . <nl> + / / / <nl> + CNTK_API void SetMaxNumCPUThreads ( size_t numCPUThreads ) ; <nl> + <nl> + / / / <nl> + / / / Returns the current process - wide setting for maximum number of CPU threads to be used by any individual compute operation <nl> + / / / <nl> + CNTK_API size_t GetMaxNumCPUThreads ( ) ; <nl> } <nl> mmm a / Source / CNTKv2LibraryDll / Common . cpp <nl> ppp b / Source / CNTKv2LibraryDll / Common . cpp <nl> <nl> # include " BestGpu . h " <nl> # include < mutex > <nl> # include < algorithm > <nl> + # include < CPUMatrix . h > / / For CPUMatrix : : SetNumThreads <nl> + # include < thread > <nl> <nl> namespace CNTK <nl> { <nl> namespace CNTK <nl> { <nl> s_uniqueDynamicAxisNames . RegisterAxisName ( axisName ) ; <nl> } <nl> + <nl> + std : : atomic < size_t > s_maxNumCPUThreads ( std : : thread : : hardware_concurrency ( ) ) ; <nl> + void SetMaxNumCPUThreads ( size_t numCPUThreads ) <nl> + { <nl> + s_maxNumCPUThreads . store ( numCPUThreads ) ; <nl> + Microsoft : : MSR : : CNTK : : CPUMatrix < float > : : SetNumThreads ( ( int ) numCPUThreads ) ; <nl> + } <nl> + <nl> + size_t GetMaxNumCPUThreads ( ) <nl> + { <nl> + return s_maxNumCPUThreads . load ( ) ; <nl> + } <nl> } <nl> mmm a / Source / CNTKv2LibraryDll / Function . cpp <nl> ppp b / Source / CNTKv2LibraryDll / Function . cpp <nl> namespace CNTK <nl> } <nl> <nl> ValuePtr nodeValue ; <nl> + auto layout = computationNode - > GetMBLayout ( ) ; <nl> switch ( var . GetDataType ( ) ) <nl> { <nl> case DataType : : Float : <nl> - nodeValue = GetValueObjectFromCNTKImplMatrixAndMBLayout < float > ( var , <nl> - getGradient ? computationNode - > As < ComputationNode < float > > ( ) - > Gradient ( ) : computationNode - > As < ComputationNode < float > > ( ) - > Value ( ) , <nl> - computationNode - > GetMBLayout ( ) ) ; <nl> + { <nl> + auto & matrix = getGradient ? computationNode - > As < ComputationNode < float > > ( ) - > Gradient ( ) : computationNode - > As < ComputationNode < float > > ( ) - > Value ( ) ; <nl> + if ( varValue = = nullptr ) <nl> + nodeValue = MakeSharedObject < PackedValue > ( var . Shape ( ) , std : : make_shared < Matrix < float > > ( matrix . AsReference ( ) ) , layout , / * readOnly = * / false ) ; <nl> + else <nl> + nodeValue = GetValueObjectFromCNTKImplMatrixAndMBLayout < float > ( var , matrix , layout ) ; <nl> break ; <nl> + } <nl> case DataType : : Double : <nl> - nodeValue = GetValueObjectFromCNTKImplMatrixAndMBLayout < double > ( var , <nl> - getGradient ? computationNode - > As < ComputationNode < double > > ( ) - > Gradient ( ) : computationNode - > As < ComputationNode < double > > ( ) - > Value ( ) , <nl> - computationNode - > GetMBLayout ( ) ) ; <nl> + { <nl> + auto & matrix = getGradient ? computationNode - > As < ComputationNode < double > > ( ) - > Gradient ( ) : computationNode - > As < ComputationNode < double > > ( ) - > Value ( ) ; <nl> + if ( varValue = = nullptr ) <nl> + nodeValue = MakeSharedObject < PackedValue > ( var . Shape ( ) , std : : make_shared < Matrix < double > > ( matrix . AsReference ( ) ) , layout , / * readOnly = * / false ) ; <nl> + else <nl> + nodeValue = GetValueObjectFromCNTKImplMatrixAndMBLayout < double > ( var , matrix , layout ) ; <nl> break ; <nl> + } <nl> default : <nl> LogicError ( " Unsupported DataType % s " , DataTypeName ( var . GetDataType ( ) ) ) ; <nl> break ; <nl> namespace CNTK <nl> <nl> FunctionPtr SquaredError ( const Variable & prediction , const Variable & targets , const std : : wstring & name / * = L " " * / ) <nl> { <nl> - return BinaryOp ( PrimitiveOpType : : SquaredError , prediction , targets , Dictionary ( ) , name ) ; <nl> + auto difference = Minus ( prediction , targets ) ; <nl> + auto squaredDifference = ElementTimes ( difference , difference ) ; <nl> + return Internal : : ReduceElements ( squaredDifference , PrimitiveFunction : : InternalSumReductionOpName , Axis : : AllStaticAxes ( ) , name ) ; <nl> } <nl> <nl> FunctionPtr CrossEntropyWithSoftmax ( const Variable & prediction , const Variable & labels , const std : : wstring & name / * = L " " * / ) <nl> { <nl> - return ReduceSum ( Minus ( ReduceLogSum ( prediction , Axis ( 0 ) ) , TransposeTimes ( labels , prediction ) ) , name ) ; <nl> + return Minus ( ReduceLogSum ( prediction , Axis ( 0 ) ) , TransposeTimes ( labels , prediction ) , name ) ; <nl> } <nl> <nl> FunctionPtr ClassificationError ( const Variable & prediction , const Variable & labels , const std : : wstring & name / * = L " " * / ) <nl> { <nl> - return ReduceSum ( Minus ( Constant : : Scalar ( prediction . GetDataType ( ) , 1 . 0 ) , TransposeTimes ( labels , Hardmax ( prediction ) ) ) , name ) ; <nl> + return Minus ( Constant : : Scalar ( prediction . GetDataType ( ) , 1 . 0 ) , TransposeTimes ( labels , Hardmax ( prediction ) ) , name ) ; <nl> } <nl> <nl> FunctionPtr PastValue ( const Variable & operand , const Variable & initialState , size_t offset , const std : : wstring & name ) <nl> mmm a / Source / CNTKv2LibraryDll / Learner . cpp <nl> ppp b / Source / CNTKv2LibraryDll / Learner . cpp <nl> using namespace std ; <nl> <nl> namespace CNTK <nl> { <nl> + / * static * / const std : : wstring Learner : : LearningRateAttributeName = L " learningRate " ; <nl> + / * static * / const std : : wstring LearnerBase : : WasLearningRateResetAttributeName = L " wasLearningRateReset " ; <nl> + <nl> template < typename ElementType > <nl> / * static * / shared_ptr < const Matrix < ElementType > > LearnerBase : : GetMatrix ( const NDArrayViewPtr & arrayView ) <nl> { <nl> namespace CNTK <nl> / / L1 regularizer with proximal gradient descent method <nl> if ( m_additionalOptions . l1RegularizationWeight > 0 ) <nl> { <nl> - auto learningRate = ElementType ( m_learningRates [ m_sampleCount ] ) ; <nl> + auto learningRate = ElementType ( LearningRate ( ) ) ; <nl> / / multiply by actualMBSize so that it ' s invariant to minibatch size since learning rate is per sample <nl> auto weight = ElementType ( learningRate * m_additionalOptions . l1RegularizationWeight * actualMBSize ) ; <nl> parameterValue - > GetWritableMatrix < ElementType > ( ) - > InplaceSoftThreshold ( weight ) ; <nl> namespace CNTK <nl> bool allocateSmoothGradients / * = true * / , <nl> double clippingThresholdPerSample / * = std : : numeric_limits < double > : : infinity ( ) * / , <nl> bool gradientClippingWithTruncation / * = true * / ) <nl> - : Learner ( parameters ) , <nl> - m_learningRates ( learningRates ) , <nl> + : Learner ( parameters , learningRates [ 0 ] ) , <nl> + m_wasLearningRateReset ( false ) , <nl> + m_learningRateSchedule ( learningRates ) , <nl> m_sampleCount ( 0 ) , <nl> m_minibatchCount ( 0 ) <nl> { <nl> namespace CNTK <nl> # endif <nl> <nl> # if DUMPOUTPUT <nl> - auto learningRate = ElementType ( m_learningRates [ m_sampleCount ] ) ; <nl> + auto learningRate = ElementType ( LearningRate ( ) ) ; <nl> auto momentum = ElementType ( MomentumPerMB ( m_momentums [ m_sampleCount ] , trainingSampleCount ) ) ; <nl> LOGPRINTF ( stderr , " learnRatePerSample = % 0 . 8f , momentum = % 0 . 8f , actualMBSize = % ld \ n " , <nl> learningRate , momentum , trainingSampleCount ) ; <nl> namespace CNTK <nl> checkpoint [ L " sampleCount " ] = m_sampleCount ; <nl> checkpoint [ L " minibatchCount " ] = m_minibatchCount ; <nl> <nl> + if ( m_wasLearningRateReset ) <nl> + checkpoint [ WasLearningRateResetAttributeName ] = m_wasLearningRateReset ; <nl> + <nl> / / TODO : should we also save learning rate schedule into the checkpoint ? <nl> / / If that is the case , need to be able to override this method in subclasses <nl> / / and save momentum schedule as well . <nl> namespace CNTK <nl> const auto & smoothedGradientValue = m_smoothedGradientValues . at ( parameter ) ; <nl> checkpoint [ parameter . Uid ( ) ] = * smoothedGradientValue ; <nl> } <nl> + <nl> + / / Add the base Learner ' s checkpoint state <nl> + auto baseCheckpointState = Learner : : GetCheckpointState ( ) ; <nl> + checkpoint . Add ( baseCheckpointState ) ; <nl> + <nl> return checkpoint ; <nl> } <nl> <nl> / * virtual * / void LearnerBase : : RestoreFromCheckpoint ( const Dictionary & checkpoint ) / * override * / <nl> { <nl> + / / Restore the base learner ' s checkpoint state <nl> + Learner : : RestoreFromCheckpoint ( checkpoint ) ; <nl> + <nl> m_sampleCount = checkpoint [ L " sampleCount " ] . Value < size_t > ( ) ; <nl> m_minibatchCount = checkpoint [ L " minibatchCount " ] . Value < size_t > ( ) ; <nl> <nl> namespace CNTK <nl> LogicError ( " Unsupported checkpoint version . " ) ; <nl> } <nl> <nl> + if ( checkpoint . Contains ( WasLearningRateResetAttributeName ) ) <nl> + m_wasLearningRateReset = checkpoint [ WasLearningRateResetAttributeName ] . Value < bool > ( ) ; <nl> + <nl> for ( const auto & parameter : Parameters ( ) ) <nl> { <nl> if ( ! checkpoint . Contains ( parameter . Uid ( ) ) ) <nl> namespace CNTK <nl> const auto & gradientMatrix = GetWritableMatrix < ElementType > ( gradientValue ) ; <nl> const auto & parameterMatrix = GetWritableMatrix < ElementType > ( parameterValue ) ; <nl> <nl> - auto learningRate = ElementType ( m_learningRates [ m_sampleCount ] ) ; <nl> + auto learningRate = ElementType ( LearningRate ( ) ) ; <nl> auto momentum = ElementType ( MomentumPerMB ( m_momentums [ m_sampleCount ] , trainingSampleCount ) ) ; <nl> <nl> / / TODO : break up the NormalGrad into 3 different functions , each with its own set of parameters <nl> namespace CNTK <nl> const auto & gradientMatrix = GetWritableMatrix < ElementType > ( gradientValue ) ; <nl> const auto & parameterMatrix = GetWritableMatrix < ElementType > ( parameterValue ) ; <nl> <nl> - auto learningRate = ElementType ( m_learningRates [ m_sampleCount ] ) ; <nl> + auto learningRate = ElementType ( LearningRate ( ) ) ; <nl> <nl> auto aveMultiplier = smoothedGradientMatrix - > Adagrad ( * gradientMatrix , m_needAveMultiplier ) ; <nl> Matrix < ElementType > : : ScaleAndAdd ( ElementType ( - learningRate / aveMultiplier ) , * gradientMatrix , * parameterMatrix ) ; <nl> namespace CNTK <nl> const auto & gradientMatrix = GetWritableMatrix < ElementType > ( gradientValue ) ; <nl> const auto & parameterMatrix = GetWritableMatrix < ElementType > ( parameterValue ) ; <nl> <nl> - auto learningRate = m_learningRates [ m_sampleCount ] ; <nl> + auto learningRate = LearningRate ( ) ; <nl> auto momentum = MomentumPerMB ( m_momentums [ m_sampleCount ] , trainingSampleCount ) ; <nl> <nl> const double targetAdagradAvDenom = 0 . 0025 ; / / 1 / 400 magic constant <nl> namespace CNTK <nl> const auto & gradientMatrix = GetWritableMatrix < ElementType > ( gradientValue ) ; <nl> const auto & parameterMatrix = GetWritableMatrix < ElementType > ( parameterValue ) ; <nl> <nl> - auto learningRate = ElementType ( m_learningRates [ m_sampleCount ] ) ; <nl> + auto learningRate = ElementType ( LearningRate ( ) ) ; <nl> <nl> auto aveMultiplier = smoothedGradientMatrix - > RmsProp ( * gradientMatrix , <nl> ElementType ( m_gamma ) , ElementType ( m_inc ) , <nl> mmm a / Source / CNTKv2LibraryDll / Learner . h <nl> ppp b / Source / CNTKv2LibraryDll / Learner . h <nl> namespace CNTK <nl> / / and adds a few pre - / postprocessing methods ( which are invoked before and after the update ) . <nl> class LearnerBase : public Learner <nl> { <nl> + static const std : : wstring WasLearningRateResetAttributeName ; <nl> + <nl> public : <nl> virtual bool Update ( const std : : unordered_map < Parameter , NDArrayViewPtr > & gradientValues , size_t trainingSampleCount ) override final ; <nl> <nl> namespace CNTK <nl> <nl> virtual void RestoreFromCheckpoint ( const Dictionary & checkpoint ) override final ; <nl> <nl> + virtual void ResetLearningRate ( double learningRate ) override final <nl> + { <nl> + m_wasLearningRateReset = true ; <nl> + Learner : : ResetLearningRate ( learningRate ) ; <nl> + } <nl> + <nl> + virtual double LearningRate ( ) const override final <nl> + { <nl> + if ( m_wasLearningRateReset ) <nl> + return Learner : : LearningRate ( ) ; <nl> + else <nl> + return m_learningRateSchedule [ m_sampleCount ] ; <nl> + } <nl> + <nl> protected : <nl> LearnerBase ( const std : : vector < Parameter > & parameters , <nl> const LearningRatesPerSample & learningRates , <nl> namespace CNTK <nl> <nl> std : : string LearnerType ( ) const ; <nl> <nl> - LearningRatesPerSample m_learningRates ; <nl> + bool m_wasLearningRateReset ; <nl> + LearningRatesPerSample m_learningRateSchedule ; <nl> <nl> AdditionalLearningOptions m_additionalOptions ; <nl> <nl> mmm a / Source / CNTKv2LibraryDll / Trainer . cpp <nl> ppp b / Source / CNTKv2LibraryDll / Trainer . cpp <nl> namespace CNTK <nl> Trainer : : Trainer ( const FunctionPtr & model , const FunctionPtr & lossFunction , const FunctionPtr & evaluationFunction , const std : : unordered_set < LearnerPtr > & parameterLearners ) <nl> : m_model ( model ) , m_lossFunction ( lossFunction ) , m_evaluationFunction ( evaluationFunction ) , m_parameterLearners ( parameterLearners ) , m_prevMinibatchNumSamples ( 1 ) <nl> { <nl> - m_combinedTrainingFunction = Combine ( { model , lossFunction , evaluationFunction } ) ; <nl> + if ( m_lossFunction - > Output ( ) . DynamicAxes ( ) . empty ( ) ) <nl> + InvalidArgument ( " The loss function specified in the Trainer constructor must correspond to minibatch data and have dynamic axes " ) ; <nl> + <nl> + if ( m_evaluationFunction & & m_evaluationFunction - > Output ( ) . DynamicAxes ( ) . empty ( ) ) <nl> + InvalidArgument ( " The evaluation function specified in the Trainer constructor must correspond to minibatch data and have dynamic axes " ) ; <nl> + <nl> + m_aggregatedLossFunction = ReduceSum ( lossFunction ) ; <nl> + if ( m_evaluationFunction ) <nl> + m_aggregatedEvaluationFunction = ReduceSum ( m_evaluationFunction ) ; <nl> + <nl> + std : : vector < FunctionPtr > combinedFunctionArgs = { m_model , m_aggregatedLossFunction , m_lossFunction } ; <nl> + if ( m_evaluationFunction ) <nl> + { <nl> + combinedFunctionArgs . push_back ( m_aggregatedEvaluationFunction ) ; <nl> + combinedFunctionArgs . push_back ( m_evaluationFunction ) ; <nl> + } <nl> + <nl> + m_combinedTrainingFunction = Combine ( combinedFunctionArgs ) ; <nl> <nl> auto modelParameters = m_combinedTrainingFunction - > Parameters ( ) ; <nl> std : : unordered_set < Parameter > learnerParameters ; <nl> namespace CNTK <nl> return scalar ; <nl> } <nl> <nl> - static size_t GetSampleCountFromArguments ( const Variable & evalOrLossArgument , const std : : unordered_map < Variable , ValuePtr > & arguments ) <nl> + static size_t GetSampleCount ( const Variable & var , const ValuePtr & value ) <nl> { <nl> - / / Find the argument whose dynamic axes match the criterion operation ' s dynamic axes ( i . e . label dynamic axes ) <nl> - / / Then we determine the actual number of samples contributing to the training loss from the argument ' s Value object <nl> - auto argumentIter = std : : find_if ( arguments . begin ( ) , arguments . end ( ) , [ evalOrLossArgument ] ( const std : : pair < Variable , ValuePtr > & currentPair ) { <nl> - return ( currentPair . first . DynamicAxes ( ) = = evalOrLossArgument . DynamicAxes ( ) ) ; <nl> - } ) ; <nl> - <nl> - auto argumentValue = argumentIter - > second ; <nl> - auto argumentVar = argumentIter - > first ; <nl> - auto argumentDataShape = argumentValue - > Shape ( ) ; <nl> - auto mask = argumentValue - > Mask ( ) ; <nl> - size_t numMaskedSamples = ( mask ! = nullptr ) ? mask - > MaskedCount ( ) : 0 ; <nl> - size_t numSamplesInDataArrayView = argumentDataShape . SubShape ( argumentVar . Shape ( ) . Rank ( ) ) . TotalSize ( ) ; <nl> + auto valueDataShape = value - > Shape ( ) ; <nl> + size_t numMaskedSamples = value - > MaskedCount ( ) ; <nl> + size_t numSamplesInDataArrayView = valueDataShape . SubShape ( var . Shape ( ) . Rank ( ) ) . TotalSize ( ) ; <nl> if ( numMaskedSamples > numSamplesInDataArrayView ) <nl> LogicError ( " Number of masked values cannot exceed the number of samples that the Value object ' s Data NDArrayView can hold " ) ; <nl> <nl> namespace CNTK <nl> <nl> double Trainer : : TestMinibatch ( const std : : unordered_map < Variable , ValuePtr > & arguments , const DeviceDescriptor & computeDevice / * = DeviceDescriptor : : UseDefaultDevice ( ) * / ) <nl> { <nl> - if ( ! m_evaluationFunction ) <nl> + if ( ! m_aggregatedEvaluationFunction ) <nl> InvalidArgument ( " Trainer : : TestMinibatch : Cannot test when no evaluation function was specified during ' this ' trainer ' s construction " ) ; <nl> <nl> / / TODO : Should we refactor this code that is somewhat similar to the prologue of the TrainMinibatch function <nl> - std : : unordered_map < Variable , ValuePtr > outputs = { { m_evaluationFunction , nullptr } } ; <nl> + std : : unordered_map < Variable , ValuePtr > outputs = { { m_aggregatedEvaluationFunction , nullptr } , { m_evaluationFunction , nullptr } } ; <nl> m_combinedTrainingFunction - > Forward ( arguments , outputs , computeDevice ) ; <nl> <nl> - auto sampleCount = GetSampleCountFromArguments ( * ( m_evaluationFunction - > Arguments ( ) . begin ( ) ) , arguments ) ; <nl> - return ( GetScalarValue ( outputs [ m_evaluationFunction ] ) / sampleCount ) ; <nl> + auto sampleCount = GetSampleCount ( m_evaluationFunction , outputs [ m_evaluationFunction ] ) ; <nl> + return ( GetScalarValue ( outputs [ m_aggregatedEvaluationFunction ] ) / sampleCount ) ; <nl> } <nl> <nl> bool Trainer : : TrainMinibatch ( const std : : unordered_map < Variable , ValuePtr > & arguments , const DeviceDescriptor & computeDevice / * = DeviceDescriptor : : UseDefaultDevice ( ) * / ) <nl> namespace CNTK <nl> <nl> bool Trainer : : TrainMinibatch ( const std : : unordered_map < Variable , ValuePtr > & arguments , std : : unordered_map < Variable , ValuePtr > & outputsToFetch , const DeviceDescriptor & computeDevice / * = DeviceDescriptor : : UseDefaultDevice ( ) * / ) <nl> { <nl> - std : : unordered_map < Variable , ValuePtr > outputs = { { m_lossFunction , nullptr } } ; <nl> - if ( m_evaluationFunction ) <nl> - outputs . insert ( { m_evaluationFunction , nullptr } ) ; <nl> + std : : unordered_map < Variable , ValuePtr > outputs = { { m_aggregatedLossFunction , nullptr } , { m_lossFunction , nullptr } } ; <nl> + if ( m_aggregatedEvaluationFunction ) <nl> + outputs . insert ( { m_aggregatedEvaluationFunction , nullptr } ) ; <nl> <nl> outputs . insert ( outputsToFetch . begin ( ) , outputsToFetch . end ( ) ) ; <nl> <nl> - auto backPropSate = m_combinedTrainingFunction - > Forward ( arguments , outputs , computeDevice , { m_lossFunction } ) ; <nl> - m_prevMinibatchAggregateTrainingLossValue = outputs [ m_lossFunction ] ; <nl> - if ( m_evaluationFunction ) <nl> - m_prevMinibatchAggregateEvalCriterionValue = outputs [ m_evaluationFunction ] ; <nl> + auto backPropSate = m_combinedTrainingFunction - > Forward ( arguments , outputs , computeDevice , { m_aggregatedLossFunction } ) ; <nl> + m_prevMinibatchAggregateTrainingLossValue = outputs [ m_aggregatedLossFunction ] ; <nl> + if ( m_aggregatedEvaluationFunction ) <nl> + m_prevMinibatchAggregateEvalCriterionValue = outputs [ m_aggregatedEvaluationFunction ] ; <nl> <nl> for ( auto outputToFetch : outputsToFetch ) <nl> { <nl> namespace CNTK <nl> outputsToFetch [ outputToFetch . first ] = outputs [ outputToFetch . first ] ; <nl> } <nl> <nl> - ValuePtr rootGradientValue = MakeSharedObject < Value > ( MakeSharedObject < NDArrayView > ( m_lossFunction - > Output ( ) . GetDataType ( ) , m_prevMinibatchAggregateTrainingLossValue - > Shape ( ) , computeDevice ) , outputs . at ( m_lossFunction ) - > Mask ( ) ) ; <nl> - if ( m_lossFunction - > Output ( ) . GetDataType ( ) = = DataType : : Float ) <nl> + ValuePtr rootGradientValue = MakeSharedObject < Value > ( MakeSharedObject < NDArrayView > ( m_aggregatedLossFunction - > Output ( ) . GetDataType ( ) , m_prevMinibatchAggregateTrainingLossValue - > Shape ( ) , computeDevice ) , outputs . at ( m_aggregatedLossFunction ) - > Mask ( ) ) ; <nl> + if ( m_aggregatedLossFunction - > Output ( ) . GetDataType ( ) = = DataType : : Float ) <nl> rootGradientValue - > Data ( ) - > SetValue ( 1 . 0f ) ; <nl> else <nl> rootGradientValue - > Data ( ) - > SetValue ( 1 . 0 ) ; <nl> namespace CNTK <nl> for ( const auto & parameter : modelParameters ) <nl> parameterGradients [ parameter ] = nullptr ; <nl> <nl> - m_combinedTrainingFunction - > Backward ( backPropSate , { { m_lossFunction , rootGradientValue } } , parameterGradients ) ; <nl> + m_combinedTrainingFunction - > Backward ( backPropSate , { { m_aggregatedLossFunction , rootGradientValue } } , parameterGradients ) ; <nl> <nl> - m_prevMinibatchNumSamples = GetSampleCountFromArguments ( * ( m_lossFunction - > Arguments ( ) . begin ( ) ) , arguments ) ; <nl> + m_prevMinibatchNumSamples = GetSampleCount ( m_lossFunction , outputs [ m_lossFunction ] ) ; <nl> <nl> bool anyUpdatesPerformed = false ; <nl> for ( auto learner : m_parameterLearners ) <nl> mmm a / Source / CNTKv2LibraryDll / Value . cpp <nl> ppp b / Source / CNTKv2LibraryDll / Value . cpp <nl> namespace CNTK <nl> <nl> void PackedValue : : Unpack ( ) const <nl> { <nl> - if ( Internal : : IsAutomaticUnpackingOfPackedValuesDisabled ( ) ) <nl> + if ( m_packedDataLayout & & ( m_packedDataLayout - > GetNumTimeSteps ( ) ! = 1 ) & & ( m_packedDataLayout - > GetNumSequences ( ) ! = 1 ) & & Internal : : IsAutomaticUnpackingOfPackedValuesDisabled ( ) ) <nl> LogicError ( " PackedValue : : Unpack : Automatic unpacking of PackedValue objects is disabled " ) ; <nl> <nl> if ( m_isPacked ) <nl> mmm a / Source / CNTKv2LibraryDll / Value . h <nl> ppp b / Source / CNTKv2LibraryDll / Value . h <nl> namespace CNTK <nl> { <nl> class PackedValue final : public Value <nl> { <nl> + template < typename T , typename . . . CtorArgTypes > <nl> + friend inline std : : shared_ptr < T > MakeSharedObject ( CtorArgTypes & & . . . ctorArgs ) ; <nl> + <nl> public : <nl> template < typename ElementType > <nl> PackedValue ( const NDShape & sampleShape , const std : : shared_ptr < Microsoft : : MSR : : CNTK : : Matrix < ElementType > > & packedDataMatrix , const std : : shared_ptr < Microsoft : : MSR : : CNTK : : MBLayout > & packedDataLayout , bool isReadOnly ) <nl> : Value ( nullptr ) , m_isPacked ( true ) , m_sampleShape ( sampleShape ) , m_packedData ( nullptr ) , m_packedDataLayout ( packedDataLayout ) , m_isReadOnly ( isReadOnly ) <nl> { <nl> NDShape packedMatrixShape ( { packedDataMatrix - > GetNumRows ( ) , packedDataMatrix - > GetNumCols ( ) } ) ; <nl> - auto tensorView = new TensorView < ElementType > ( packedDataMatrix , AsTensorViewShape ( packedMatrixShape ) ) ; <nl> + auto tensorView = new Microsoft : : MSR : : CNTK : : TensorView < ElementType > ( packedDataMatrix , AsTensorViewShape ( packedMatrixShape ) ) ; <nl> m_packedData = MakeSharedObject < NDArrayView > ( AsDataType < ElementType > ( ) , AsDeviceDescriptor ( packedDataMatrix - > GetDeviceId ( ) ) , AsStorageFormat ( packedDataMatrix - > GetFormat ( ) ) , packedMatrixShape , m_isReadOnly , tensorView ) ; <nl> <nl> / / Determine unpacked shape <nl> namespace CNTK <nl> StorageFormat GetStorageFormat ( ) const override { return m_isPacked ? m_packedData - > GetStorageFormat ( ) : Value : : GetStorageFormat ( ) ; } <nl> bool IsReadOnly ( ) const override { return m_isPacked ? m_packedData - > IsReadOnly ( ) : Value : : IsReadOnly ( ) ; } <nl> <nl> + size_t MaskedCount ( ) const override <nl> + { <nl> + if ( m_isPacked ) <nl> + / / Compute the number of masked samples after the data will be unpacked <nl> + return m_packedDataLayout ? ( ( m_packedDataLayout - > GetNumTimeSteps ( ) * m_packedDataLayout - > GetNumSequences ( ) ) - m_packedDataLayout - > GetActualNumSamples ( ) ) : 0 ; <nl> + else <nl> + return Value : : MaskedCount ( ) ; <nl> + } <nl> + <nl> NDArrayViewPtr Data ( ) const override <nl> { <nl> Unpack ( ) ; <nl> namespace CNTK <nl> <nl> ValuePtr DeepClone ( bool / * readOnly = false * / ) const override <nl> { <nl> - LogicError ( " DeepClone is currently unsupported for PackedValue objects " ) ; <nl> + if ( m_isPacked ) <nl> + { <nl> + std : : shared_ptr < Microsoft : : MSR : : CNTK : : MBLayout > packedLayoutCopy ; <nl> + if ( m_packedDataLayout ) <nl> + { <nl> + packedLayoutCopy = std : : make_shared < Microsoft : : MSR : : CNTK : : MBLayout > ( ) ; <nl> + packedLayoutCopy - > CopyFrom ( m_packedDataLayout ) ; <nl> + } <nl> + return MakeSharedObject < PackedValue > ( m_sampleShape , m_packedData - > DeepClone ( ) , packedLayoutCopy , m_isReadOnly ) ; <nl> + } <nl> + else <nl> + return Value : : DeepClone ( ) ; <nl> } <nl> <nl> ValuePtr Alias ( bool / * readOnly = false * / ) const override <nl> namespace CNTK <nl> return { m_packedData - > GetMatrix < ElementType > ( ) , m_packedDataLayout } ; <nl> } <nl> <nl> + private : <nl> + PackedValue ( const NDShape & sampleShape , const NDArrayViewPtr & packedData , const std : : shared_ptr < Microsoft : : MSR : : CNTK : : MBLayout > & packedDataLayout , bool isReadOnly ) <nl> + : Value ( nullptr ) , m_isPacked ( true ) , m_sampleShape ( sampleShape ) , m_packedData ( packedData ) , m_packedDataLayout ( packedDataLayout ) , m_isReadOnly ( isReadOnly ) <nl> + { <nl> + / / Determine unpacked shape <nl> + m_unpackedShape = sampleShape ; <nl> + if ( packedDataLayout ) <nl> + m_unpackedShape = m_unpackedShape . AppendShape ( { packedDataLayout - > GetNumTimeSteps ( ) , packedDataLayout - > GetNumSequences ( ) } ) ; <nl> + } <nl> + <nl> private : <nl> bool m_isReadOnly ; <nl> NDShape m_sampleShape ; <nl> mmm a / Source / CNTKv2LibraryDll / Variable . cpp <nl> ppp b / Source / CNTKv2LibraryDll / Variable . cpp <nl> namespace CNTK <nl> assert ( ! m_valueInitializer ) ; <nl> assert ( ! m_valueInitializationDevice ) ; <nl> <nl> - auto filterRank = ( int ) initializationConfig [ FilterRankAttributeName ] . Value < size_t > ( ) ; <nl> - auto outputRank = ( int ) initializationConfig [ OutputRankAttributeName ] . Value < size_t > ( ) ; <nl> - if ( ( filterRank + outputRank ) > m_shape . Rank ( ) ) <nl> - InvalidArgument ( " Sum of filter rank ( % d ) and output rank ( % d ) of the parameter initializer cannot exceed the Parameter ' s rank " , filterRank , outputRank , ( int ) m_shape . Rank ( ) ) ; <nl> + if ( initializationConfig . Contains ( FilterRankAttributeName ) ) <nl> + { <nl> + auto filterRank = ( int ) initializationConfig [ FilterRankAttributeName ] . Value < size_t > ( ) ; <nl> + auto outputRank = ( int ) initializationConfig [ OutputRankAttributeName ] . Value < size_t > ( ) ; <nl> + if ( ( filterRank + outputRank ) > m_shape . Rank ( ) ) <nl> + InvalidArgument ( " Sum of filter rank ( % d ) and output rank ( % d ) of the parameter initializer cannot exceed the Parameter ' s rank ( % d ) " , filterRank , outputRank , ( int ) m_shape . Rank ( ) ) ; <nl> + } <nl> <nl> m_valueInitializer . reset ( new ParameterInitializer ( initializationConfig ) ) ; <nl> m_valueInitializationDevice . reset ( new DeviceDescriptor ( device ) ) ; <nl> mmm a / Tests / EndToEndTests / CNTKv2Library / UnitTests / run - test <nl> ppp b / Tests / EndToEndTests / CNTKv2Library / UnitTests / run - test <nl> cp - R $ DataSourceDir / CIFAR / v0 / cifar - 10 - batches - py $ DataDir | | exit $ ? <nl> cp - R $ TEST_DIR / . . / . . / . . / . . / Examples / Other / Simple2d / Data / SimpleDataTrain_cntk_text . txt $ DataDir | | exit $ ? <nl> cp - R $ TEST_DIR / . . / . . / Text / SequenceClassification / Data / Train . ctf $ DataDir | | exit $ ? <nl> cp - R $ TEST_DIR / . . / . . / . . / . . / Examples / SequenceToSequence / CMUDict / Data / cmudict - 0 . 7b . train - dev - 20 - 21 . ctf $ DataDir | | exit $ ? <nl> + cp - R $ TEST_DIR / . . / . . / . . / . . / Examples / Speech / AN4 / Data / * $ DataDir | | exit $ ? <nl> <nl> pushd $ DataDir <nl> <nl> mmm a / Tests / UnitTests / V2LibraryTests / CifarResNet . cpp <nl> ppp b / Tests / UnitTests / V2LibraryTests / CifarResNet . cpp <nl> void TrainResNetCifarClassifer ( const DeviceDescriptor & device , bool testSaveAndR <nl> } <nl> } <nl> <nl> - void TestCifarResnet ( ) <nl> + void TrainCifarResnet ( ) <nl> { <nl> # ifndef CPUONLY <nl> TrainResNetCifarClassifer ( DeviceDescriptor : : GPUDevice ( 0 ) , true / * testSaveAndReLoad * / ) ; <nl> mmm a / Tests / UnitTests / V2LibraryTests / Common . h <nl> ppp b / Tests / UnitTests / V2LibraryTests / Common . h <nl> std : : pair < CNTK : : FunctionPtr , CNTK : : FunctionPtr > LSTMPCellWithSelfStabilization ( C <nl> <nl> unsigned long seed = 1 ; <nl> auto createProjectionParam = [ device , & seed ] ( size_t outputDim , size_t inputDim ) { <nl> - return CNTK : : Parameter ( { outputDim , inputDim } , AsDataType < ElementType > ( ) , UniformInitializer ( 1 , seed + + ) , device ) ; <nl> + return CNTK : : Parameter ( { outputDim , inputDim } , CNTK : : AsDataType < ElementType > ( ) , CNTK : : UniformInitializer ( 1 , seed + + ) , device ) ; <nl> } ; <nl> <nl> auto createDiagWeightParam = [ device , & seed ] ( size_t dim ) { <nl> - return CNTK : : Parameter ( { dim } , AsDataType < ElementType > ( ) , UniformInitializer ( 1 , seed + + ) , device ) ; <nl> + return CNTK : : Parameter ( { dim } , CNTK : : AsDataType < ElementType > ( ) , CNTK : : UniformInitializer ( 1 , seed + + ) , device ) ; <nl> } ; <nl> <nl> auto stabilizedPrevOutput = Stabilize < ElementType > ( prevOutput , device ) ; <nl> std : : pair < CNTK : : FunctionPtr , CNTK : : FunctionPtr > LSTMPCellWithSelfStabilization ( C <nl> auto bit = CNTK : : ElementTimes ( it , CNTK : : Tanh ( projectInput ( ) + CNTK : : Times ( createProjectionParam ( cellDim , outputDim ) , stabilizedPrevOutput ) ) ) ; <nl> <nl> / / Forget - me - not gate <nl> - auto ft = CNTK : : Sigmoid ( projectInput ( ) + CNTK : : Times ( createProjectionParam ( cellDim , outputDim ) , stabilizedPrevOutput ) + ElementTimes ( createDiagWeightParam ( cellDim ) , stabilizedPrevCellState ) ) ; <nl> + auto ft = CNTK : : Sigmoid ( projectInput ( ) + CNTK : : Times ( createProjectionParam ( cellDim , outputDim ) , stabilizedPrevOutput ) + CNTK : : ElementTimes ( createDiagWeightParam ( cellDim ) , stabilizedPrevCellState ) ) ; <nl> auto bft = CNTK : : ElementTimes ( ft , prevCellState ) ; <nl> <nl> auto ct = bft + bit ; <nl> mmm a / Tests / UnitTests / V2LibraryTests / FeedForwardTests . cpp <nl> ppp b / Tests / UnitTests / V2LibraryTests / FeedForwardTests . cpp <nl> void TestFeedForwardNetworkCreation ( const DeviceDescriptor & device , bool testSav <nl> auto classifierOutput = FullyConnectedFeedForwardClassifierNet ( inputVar , numOutputClasses , hiddenLayersDim , numHiddenLayers , device , std : : bind ( Sigmoid , _1 , L " " ) , L " classifierOutput " ) ; <nl> <nl> auto labelsVar = InputVariable ( { numOutputClasses } , DataType : : Float , L " Labels " ) ; <nl> - auto trainingLoss = CNTK : : CrossEntropyWithSoftmax ( classifierOutput , labelsVar , L " LossFunction " ) ; <nl> - auto prediction = CNTK : : ClassificationError ( classifierOutput , labelsVar , L " ClassificationError " ) ; <nl> + auto trainingLoss = ReduceSum ( CNTK : : CrossEntropyWithSoftmax ( classifierOutput , labelsVar ) , L " LossFunction " ) ; <nl> + auto prediction = ReduceSum ( CNTK : : ClassificationError ( classifierOutput , labelsVar ) , L " ClassificationError " ) ; <nl> <nl> auto ffNet = CNTK : : Combine ( { trainingLoss , prediction , classifierOutput } , L " ClassifierModel " ) ; <nl> <nl> mmm a / Tests / UnitTests / V2LibraryTests / Main . cpp <nl> ppp b / Tests / UnitTests / V2LibraryTests / Main . cpp <nl> void TensorTests ( ) ; <nl> void FeedForwardTests ( ) ; <nl> void RecurrentFunctionTests ( ) ; <nl> void TrainerTests ( ) ; <nl> - void TestCifarResnet ( ) ; <nl> + void TrainCifarResnet ( ) ; <nl> void FunctionTests ( ) ; <nl> void TrainLSTMSequenceClassifer ( ) ; <nl> void SerializationTests ( ) ; <nl> int main ( ) <nl> LearnerTests ( ) ; <nl> <nl> TrainerTests ( ) ; <nl> - TestCifarResnet ( ) ; <nl> + TrainCifarResnet ( ) ; <nl> TrainLSTMSequenceClassifer ( ) ; <nl> <nl> TrainSequenceToSequenceTranslator ( ) ; <nl> mmm a / Tests / UnitTests / V2LibraryTests / RecurrentFunctionTests . cpp <nl> ppp b / Tests / UnitTests / V2LibraryTests / RecurrentFunctionTests . cpp <nl> void TestRecurrentNetworkCreation ( const DeviceDescriptor & device , bool testSaveA <nl> auto classifierOutput = LSTMNet < ElementType > ( features , cellDim , hiddenDim , numOutputClasses , numLSTMLayers , device , L " classifierOutput " ) ; <nl> <nl> auto labelsVar = InputVariable ( { numOutputClasses } , AsDataType < ElementType > ( ) , L " labels " ) ; <nl> - auto trainingLoss = CrossEntropyWithSoftmax ( classifierOutput , labelsVar , L " lossFunction " ) ; <nl> - auto prediction = ClassificationError ( classifierOutput , labelsVar , L " classificationError " ) ; <nl> + auto trainingLoss = ReduceSum ( CrossEntropyWithSoftmax ( classifierOutput , labelsVar ) , L " lossFunction " ) ; <nl> + auto prediction = ReduceSum ( ClassificationError ( classifierOutput , labelsVar ) , L " classificationError " ) ; <nl> <nl> auto LSTMClassifier = Combine ( { trainingLoss , prediction , classifierOutput } , L " LSTMClassifier " ) ; <nl> <nl> mmm a / Tests / UnitTests / V2LibraryTests / SequenceClassification . cpp <nl> ppp b / Tests / UnitTests / V2LibraryTests / SequenceClassification . cpp <nl> void TrainLSTMSequenceClassifer ( const DeviceDescriptor & device , bool testSaveAnd <nl> } <nl> } <nl> <nl> + void TestLearningRateControl ( const DeviceDescriptor & device ) <nl> + { <nl> + const size_t inputDim = 2000 ; <nl> + const size_t cellDim = 25 ; <nl> + const size_t hiddenDim = 25 ; <nl> + const size_t embeddingDim = 50 ; <nl> + const size_t numOutputClasses = 5 ; <nl> + <nl> + auto features = InputVariable ( { inputDim } , true / * isSparse * / , DataType : : Float , L " features " ) ; <nl> + auto classifierOutput = LSTMSequenceClassiferNet ( features , numOutputClasses , embeddingDim , hiddenDim , cellDim , device , L " classifierOutput " ) ; <nl> + <nl> + auto labels = InputVariable ( { numOutputClasses } , DataType : : Float , L " labels " , { Axis : : DefaultBatchAxis ( ) } ) ; <nl> + auto trainingLoss = CNTK : : CrossEntropyWithSoftmax ( classifierOutput , labels , L " lossFunction " ) ; <nl> + auto prediction = CNTK : : ClassificationError ( classifierOutput , labels , L " classificationError " ) ; <nl> + <nl> + auto minibatchSource = TextFormatMinibatchSource ( L " Train . ctf " , { { L " features " , inputDim , true , L " x " } , { L " labels " , numOutputClasses , false , L " y " } } , 0 ) ; <nl> + auto featureStreamInfo = minibatchSource - > StreamInfo ( features ) ; <nl> + auto labelStreamInfo = minibatchSource - > StreamInfo ( labels ) ; <nl> + <nl> + const size_t minibatchSize = 200 ; <nl> + auto minibatchData = minibatchSource - > GetNextMinibatch ( minibatchSize , device ) ; <nl> + auto actualMBSize = minibatchData [ labelStreamInfo ] . m_numSamples ; <nl> + <nl> + LearningRatesPerSample learningRateSchedule ( { { 2 , 0 . 0005 } , { 2 , 0 . 00025 } } , actualMBSize ) ; <nl> + auto learner = SGDLearner ( classifierOutput - > Parameters ( ) , learningRateSchedule ) ; <nl> + Trainer trainer ( classifierOutput , trainingLoss , prediction , { learner } ) ; <nl> + <nl> + if ( learner - > LearningRate ( ) ! = 0 . 0005 ) <nl> + throw std : : runtime_error ( " Learner : : LearningRate does not match expectation " ) ; <nl> + <nl> + trainer . TrainMinibatch ( { { features , minibatchData [ featureStreamInfo ] . m_data } , { labels , minibatchData [ labelStreamInfo ] . m_data } } , device ) ; <nl> + if ( learner - > LearningRate ( ) ! = 0 . 0005 ) <nl> + throw std : : runtime_error ( " Learner : : LearningRate does not match expectation " ) ; <nl> + <nl> + const wchar_t * modelFile = L " seq2seq . model " ; <nl> + trainer . SaveCheckpoint ( modelFile ) ; <nl> + <nl> + trainer . TrainMinibatch ( { { features , minibatchData [ featureStreamInfo ] . m_data } , { labels , minibatchData [ labelStreamInfo ] . m_data } } , device ) ; <nl> + auto MB2Loss = trainer . PreviousMinibatchLossAverage ( ) ; <nl> + if ( learner - > LearningRate ( ) ! = 0 . 00025 ) <nl> + throw std : : runtime_error ( " Learner : : LearningRate does not match expectation " ) ; <nl> + <nl> + trainer . TrainMinibatch ( { { features , minibatchData [ featureStreamInfo ] . m_data } , { labels , minibatchData [ labelStreamInfo ] . m_data } } , device ) ; <nl> + auto MB3Loss = trainer . PreviousMinibatchLossAverage ( ) ; <nl> + if ( learner - > LearningRate ( ) ! = 0 . 00025 ) <nl> + throw std : : runtime_error ( " Learner : : LearningRate does not match expectation " ) ; <nl> + <nl> + trainer . RestoreFromCheckpoint ( modelFile ) ; <nl> + if ( learner - > LearningRate ( ) ! = 0 . 0005 ) <nl> + throw std : : runtime_error ( " Learner : : LearningRate does not match expectation " ) ; <nl> + <nl> + trainer . TrainMinibatch ( { { features , minibatchData [ featureStreamInfo ] . m_data } , { labels , minibatchData [ labelStreamInfo ] . m_data } } , device ) ; <nl> + auto postRestoreMB2Loss = trainer . PreviousMinibatchLossAverage ( ) ; <nl> + if ( postRestoreMB2Loss ! = MB2Loss ) <nl> + throw std : : runtime_error ( " Post checkpoint restoration training loss does not match expectation " ) ; <nl> + <nl> + if ( learner - > LearningRate ( ) ! = 0 . 00025 ) <nl> + throw std : : runtime_error ( " Learner : : LearningRate does not match expectation " ) ; <nl> + <nl> + trainer . TrainMinibatch ( { { features , minibatchData [ featureStreamInfo ] . m_data } , { labels , minibatchData [ labelStreamInfo ] . m_data } } , device ) ; <nl> + auto postRestoreMB3Loss = trainer . PreviousMinibatchLossAverage ( ) ; <nl> + if ( postRestoreMB3Loss ! = MB3Loss ) <nl> + throw std : : runtime_error ( " Post checkpoint restoration training loss does not match expectation " ) ; <nl> + <nl> + trainer . RestoreFromCheckpoint ( modelFile ) ; <nl> + if ( learner - > LearningRate ( ) ! = 0 . 0005 ) <nl> + throw std : : runtime_error ( " Learner : : LearningRate does not match expectation " ) ; <nl> + <nl> + learner - > ResetLearningRate ( 0 . 0004 ) ; <nl> + if ( learner - > LearningRate ( ) ! = 0 . 0004 ) <nl> + throw std : : runtime_error ( " Learner : : LearningRate does not match expectation " ) ; <nl> + <nl> + trainer . SaveCheckpoint ( modelFile ) ; <nl> + trainer . TrainMinibatch ( { { features , minibatchData [ featureStreamInfo ] . m_data } , { labels , minibatchData [ labelStreamInfo ] . m_data } } , device ) ; <nl> + postRestoreMB2Loss = trainer . PreviousMinibatchLossAverage ( ) ; <nl> + if ( postRestoreMB2Loss ! = MB2Loss ) <nl> + throw std : : runtime_error ( " Post checkpoint restoration training loss does not match expectation " ) ; <nl> + <nl> + if ( learner - > LearningRate ( ) ! = 0 . 0004 ) <nl> + throw std : : runtime_error ( " Learner : : LearningRate does not match expectation " ) ; <nl> + <nl> + trainer . TrainMinibatch ( { { features , minibatchData [ featureStreamInfo ] . m_data } , { labels , minibatchData [ labelStreamInfo ] . m_data } } , device ) ; <nl> + postRestoreMB3Loss = trainer . PreviousMinibatchLossAverage ( ) ; <nl> + if ( postRestoreMB3Loss = = MB3Loss ) <nl> + throw std : : runtime_error ( " Post checkpoint restoration training loss does not match expectation " ) ; <nl> + <nl> + if ( learner - > LearningRate ( ) ! = 0 . 0004 ) <nl> + throw std : : runtime_error ( " Learner : : LearningRate does not match expectation " ) ; <nl> + <nl> + trainer . RestoreFromCheckpoint ( modelFile ) ; <nl> + if ( learner - > LearningRate ( ) ! = 0 . 0004 ) <nl> + throw std : : runtime_error ( " Learner : : LearningRate does not match expectation " ) ; <nl> + <nl> + trainer . TrainMinibatch ( { { features , minibatchData [ featureStreamInfo ] . m_data } , { labels , minibatchData [ labelStreamInfo ] . m_data } } , device ) ; <nl> + postRestoreMB2Loss = trainer . PreviousMinibatchLossAverage ( ) ; <nl> + if ( postRestoreMB2Loss ! = MB2Loss ) <nl> + throw std : : runtime_error ( " Post checkpoint restoration training loss does not match expectation " ) ; <nl> + <nl> + if ( learner - > LearningRate ( ) ! = 0 . 0004 ) <nl> + throw std : : runtime_error ( " Learner : : LearningRate does not match expectation " ) ; <nl> + <nl> + trainer . TrainMinibatch ( { { features , minibatchData [ featureStreamInfo ] . m_data } , { labels , minibatchData [ labelStreamInfo ] . m_data } } , device ) ; <nl> + postRestoreMB3Loss = trainer . PreviousMinibatchLossAverage ( ) ; <nl> + if ( postRestoreMB3Loss = = MB3Loss ) <nl> + throw std : : runtime_error ( " Post checkpoint restoration training loss does not match expectation " ) ; <nl> + <nl> + if ( learner - > LearningRate ( ) ! = 0 . 0004 ) <nl> + throw std : : runtime_error ( " Learner : : LearningRate does not match expectation " ) ; <nl> + } <nl> + <nl> void TrainLSTMSequenceClassifer ( ) <nl> { <nl> + # ifndef CPUONLY <nl> + TestLearningRateControl ( DeviceDescriptor : : GPUDevice ( 0 ) ) ; <nl> + # endif <nl> + <nl> # ifndef CPUONLY <nl> TrainLSTMSequenceClassifer ( DeviceDescriptor : : GPUDevice ( 0 ) , true ) ; <nl> # endif <nl> mmm a / Tests / UnitTests / V2LibraryTests / TruncatedLSTMAcousticModel . cpp <nl> ppp b / Tests / UnitTests / V2LibraryTests / TruncatedLSTMAcousticModel . cpp <nl> void TrainTruncatedLSTMAcousticModelClassifer ( const DeviceDescriptor & device , bo <nl> prediction = predictionVar ; <nl> } <nl> <nl> - const size_t numTrainingSamples = 20480 ; <nl> + const size_t numTrainingSamples = 81920 ; <nl> const size_t truncationLength = 20 ; <nl> Dictionary truncatedModeConfig ; <nl> truncatedModeConfig [ L " truncated " ] = true ; <nl> truncatedModeConfig [ L " truncationLength " ] = truncationLength ; <nl> minibatchSource = CreateMinibatchSource ( baseFeaturesDim , numOutputClasses , truncatedModeConfig , numTrainingSamples ) ; <nl> <nl> - const size_t numberParallelSequencesPerMB = 1 ; <nl> + const size_t numberParallelSequencesPerMB = 32 ; <nl> const size_t minibatchSize = truncationLength * numberParallelSequencesPerMB ; <nl> <nl> featureStreamInfo = minibatchSource - > StreamInfo ( features ) ; <nl> auto labelStreamInfo = minibatchSource - > StreamInfo ( labels ) ; <nl> <nl> double learningRatePerSample = 0 . 000781 ; <nl> - auto learner = MomentumSGDLearner ( classifierOutput - > Parameters ( ) , learningRatePerSample , 0 . 0 ) ; <nl> + size_t momentumTimeConstant = 6074 ; <nl> + double momentumPerSample = std : : exp ( - 1 . 0 / momentumTimeConstant ) ; <nl> + auto learner = MomentumSGDLearner ( classifierOutput - > Parameters ( ) , learningRatePerSample , momentumPerSample ) ; <nl> Trainer trainer ( classifierOutput , trainingLoss , prediction , { learner } ) ; <nl> <nl> size_t outputFrequencyInMinibatches = 1 ; <nl>
CNTK v2 library : Fixed a bug in counting samples for computing criterion value
microsoft/CNTK
762b4c288065b5c4da0a908ffed0be41ec0dc7a4
2016-09-29T09:48:13Z
similarity index 100 % <nl> rename from cocos / 2d / actions / CCAction . cpp <nl> rename to cocos / 2d / CCAction . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / actions / CCAction . h <nl> rename to cocos / 2d / CCAction . h <nl> similarity index 100 % <nl> rename from cocos / 2d / actions / CCActionCamera . cpp <nl> rename to cocos / 2d / CCActionCamera . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / actions / CCActionCamera . h <nl> rename to cocos / 2d / CCActionCamera . h <nl> similarity index 100 % <nl> rename from cocos / 2d / actions / CCActionCatmullRom . cpp <nl> rename to cocos / 2d / CCActionCatmullRom . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / actions / CCActionCatmullRom . h <nl> rename to cocos / 2d / CCActionCatmullRom . h <nl> similarity index 100 % <nl> rename from cocos / 2d / actions / CCActionEase . cpp <nl> rename to cocos / 2d / CCActionEase . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / actions / CCActionEase . h <nl> rename to cocos / 2d / CCActionEase . h <nl> similarity index 100 % <nl> rename from cocos / 2d / actions / CCActionGrid . cpp <nl> rename to cocos / 2d / CCActionGrid . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / actions / CCActionGrid . h <nl> rename to cocos / 2d / CCActionGrid . h <nl> similarity index 100 % <nl> rename from cocos / 2d / actions / CCActionGrid3D . cpp <nl> rename to cocos / 2d / CCActionGrid3D . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / actions / CCActionGrid3D . h <nl> rename to cocos / 2d / CCActionGrid3D . h <nl> similarity index 100 % <nl> rename from cocos / 2d / actions / CCActionInstant . cpp <nl> rename to cocos / 2d / CCActionInstant . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / actions / CCActionInstant . h <nl> rename to cocos / 2d / CCActionInstant . h <nl> similarity index 100 % <nl> rename from cocos / 2d / actions / CCActionInterval . cpp <nl> rename to cocos / 2d / CCActionInterval . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / actions / CCActionInterval . h <nl> rename to cocos / 2d / CCActionInterval . h <nl> similarity index 100 % <nl> rename from cocos / 2d / actions / CCActionManager . cpp <nl> rename to cocos / 2d / CCActionManager . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / actions / CCActionManager . h <nl> rename to cocos / 2d / CCActionManager . h <nl> similarity index 100 % <nl> rename from cocos / 2d / actions / CCActionPageTurn3D . cpp <nl> rename to cocos / 2d / CCActionPageTurn3D . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / actions / CCActionPageTurn3D . h <nl> rename to cocos / 2d / CCActionPageTurn3D . h <nl> similarity index 100 % <nl> rename from cocos / 2d / actions / CCActionProgressTimer . cpp <nl> rename to cocos / 2d / CCActionProgressTimer . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / actions / CCActionProgressTimer . h <nl> rename to cocos / 2d / CCActionProgressTimer . h <nl> similarity index 100 % <nl> rename from cocos / 2d / actions / CCActionTiledGrid . cpp <nl> rename to cocos / 2d / CCActionTiledGrid . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / actions / CCActionTiledGrid . h <nl> rename to cocos / 2d / CCActionTiledGrid . h <nl> similarity index 100 % <nl> rename from cocos / 2d / actions / CCActionTween . cpp <nl> rename to cocos / 2d / CCActionTween . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / actions / CCActionTween . h <nl> rename to cocos / 2d / CCActionTween . h <nl> similarity index 100 % <nl> rename from cocos / 2d / sprite - nodes / CCAnimation . cpp <nl> rename to cocos / 2d / CCAnimation . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / sprite - nodes / CCAnimation . h <nl> rename to cocos / 2d / CCAnimation . h <nl> similarity index 100 % <nl> rename from cocos / 2d / sprite - nodes / CCAnimationCache . cpp <nl> rename to cocos / 2d / CCAnimationCache . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / sprite - nodes / CCAnimationCache . h <nl> rename to cocos / 2d / CCAnimationCache . h <nl> similarity index 100 % <nl> rename from cocos / 2d / base - nodes / CCAtlasNode . cpp <nl> rename to cocos / 2d / CCAtlasNode . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / base - nodes / CCAtlasNode . h <nl> rename to cocos / 2d / CCAtlasNode . h <nl> similarity index 100 % <nl> rename from cocos / 2d / misc - nodes / CCClippingNode . cpp <nl> rename to cocos / 2d / CCClippingNode . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / misc - nodes / CCClippingNode . h <nl> rename to cocos / 2d / CCClippingNode . h <nl> similarity index 100 % <nl> rename from cocos / 2d / support / component / CCComponent . cpp <nl> rename to cocos / 2d / CCComponent . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / support / component / CCComponent . h <nl> rename to cocos / 2d / CCComponent . h <nl> similarity index 100 % <nl> rename from cocos / 2d / support / component / CCComponentContainer . cpp <nl> rename to cocos / 2d / CCComponentContainer . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / support / component / CCComponentContainer . h <nl> rename to cocos / 2d / CCComponentContainer . h <nl> similarity index 100 % <nl> rename from cocos / 2d / include / CCDeprecated . h <nl> rename to cocos / 2d / CCDeprecated . h <nl> similarity index 100 % <nl> rename from cocos / 2d / draw - nodes / CCDrawNode . cpp <nl> rename to cocos / 2d / CCDrawNode . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / draw - nodes / CCDrawNode . h <nl> rename to cocos / 2d / CCDrawNode . h <nl> similarity index 100 % <nl> rename from cocos / 2d / draw - nodes / CCDrawingPrimitives . cpp <nl> rename to cocos / 2d / CCDrawingPrimitives . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / draw - nodes / CCDrawingPrimitives . h <nl> rename to cocos / 2d / CCDrawingPrimitives . h <nl> similarity index 100 % <nl> rename from cocos / 2d / event - dispatcher / CCEvent . cpp <nl> rename to cocos / 2d / CCEvent . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / event - dispatcher / CCEvent . h <nl> rename to cocos / 2d / CCEvent . h <nl> similarity index 100 % <nl> rename from cocos / 2d / event - dispatcher / CCEventAcceleration . cpp <nl> rename to cocos / 2d / CCEventAcceleration . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / event - dispatcher / CCEventAcceleration . h <nl> rename to cocos / 2d / CCEventAcceleration . h <nl> similarity index 100 % <nl> rename from cocos / 2d / event - dispatcher / CCEventCustom . cpp <nl> rename to cocos / 2d / CCEventCustom . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / event - dispatcher / CCEventCustom . h <nl> rename to cocos / 2d / CCEventCustom . h <nl> similarity index 100 % <nl> rename from cocos / 2d / event - dispatcher / CCEventDispatcher . cpp <nl> rename to cocos / 2d / CCEventDispatcher . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / event - dispatcher / CCEventDispatcher . h <nl> rename to cocos / 2d / CCEventDispatcher . h <nl> similarity index 100 % <nl> rename from cocos / 2d / event - dispatcher / CCEventKeyboard . cpp <nl> rename to cocos / 2d / CCEventKeyboard . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / event - dispatcher / CCEventKeyboard . h <nl> rename to cocos / 2d / CCEventKeyboard . h <nl> similarity index 100 % <nl> rename from cocos / 2d / event - dispatcher / CCEventListener . cpp <nl> rename to cocos / 2d / CCEventListener . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / event - dispatcher / CCEventListener . h <nl> rename to cocos / 2d / CCEventListener . h <nl> similarity index 100 % <nl> rename from cocos / 2d / event - dispatcher / CCEventListenerAcceleration . cpp <nl> rename to cocos / 2d / CCEventListenerAcceleration . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / event - dispatcher / CCEventListenerAcceleration . h <nl> rename to cocos / 2d / CCEventListenerAcceleration . h <nl> similarity index 100 % <nl> rename from cocos / 2d / event - dispatcher / CCEventListenerCustom . cpp <nl> rename to cocos / 2d / CCEventListenerCustom . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / event - dispatcher / CCEventListenerCustom . h <nl> rename to cocos / 2d / CCEventListenerCustom . h <nl> similarity index 100 % <nl> rename from cocos / 2d / event - dispatcher / CCEventListenerKeyboard . cpp <nl> rename to cocos / 2d / CCEventListenerKeyboard . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / event - dispatcher / CCEventListenerKeyboard . h <nl> rename to cocos / 2d / CCEventListenerKeyboard . h <nl> similarity index 100 % <nl> rename from cocos / 2d / event - dispatcher / CCEventListenerTouch . cpp <nl> rename to cocos / 2d / CCEventListenerTouch . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / event - dispatcher / CCEventListenerTouch . h <nl> rename to cocos / 2d / CCEventListenerTouch . h <nl> similarity index 100 % <nl> rename from cocos / 2d / event - dispatcher / CCEventTouch . cpp <nl> rename to cocos / 2d / CCEventTouch . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / event - dispatcher / CCEventTouch . h <nl> rename to cocos / 2d / CCEventTouch . h <nl> similarity index 100 % <nl> rename from cocos / 2d / include / CCEventType . h <nl> rename to cocos / 2d / CCEventType . h <nl> similarity index 100 % <nl> rename from cocos / 2d / label - nodes / CCFont . cpp <nl> rename to cocos / 2d / CCFont . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / label - nodes / CCFont . h <nl> rename to cocos / 2d / CCFont . h <nl> similarity index 100 % <nl> rename from cocos / 2d / label - nodes / CCFontAtlas . cpp <nl> rename to cocos / 2d / CCFontAtlas . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / label - nodes / CCFontAtlas . h <nl> rename to cocos / 2d / CCFontAtlas . h <nl> similarity index 100 % <nl> rename from cocos / 2d / label - nodes / CCFontAtlasCache . cpp <nl> rename to cocos / 2d / CCFontAtlasCache . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / label - nodes / CCFontAtlasCache . h <nl> rename to cocos / 2d / CCFontAtlasCache . h <nl> similarity index 100 % <nl> rename from cocos / 2d / label - nodes / CCFontAtlasFactory . cpp <nl> rename to cocos / 2d / CCFontAtlasFactory . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / label - nodes / CCFontAtlasFactory . h <nl> rename to cocos / 2d / CCFontAtlasFactory . h <nl> similarity index 100 % <nl> rename from cocos / 2d / label - nodes / CCFontDefinition . cpp <nl> rename to cocos / 2d / CCFontDefinition . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / label - nodes / CCFontDefinition . h <nl> rename to cocos / 2d / CCFontDefinition . h <nl> similarity index 100 % <nl> rename from cocos / 2d / label - nodes / CCFontFNT . cpp <nl> rename to cocos / 2d / CCFontFNT . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / label - nodes / CCFontFNT . h <nl> rename to cocos / 2d / CCFontFNT . h <nl> similarity index 100 % <nl> rename from cocos / 2d / label - nodes / CCFontFreeType . cpp <nl> rename to cocos / 2d / CCFontFreeType . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / label - nodes / CCFontFreeType . h <nl> rename to cocos / 2d / CCFontFreeType . h <nl> similarity index 100 % <nl> rename from cocos / 2d / base - nodes / CCGLBufferedNode . cpp <nl> rename to cocos / 2d / CCGLBufferedNode . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / base - nodes / CCGLBufferedNode . h <nl> rename to cocos / 2d / CCGLBufferedNode . h <nl> similarity index 100 % <nl> rename from cocos / 2d / shaders / CCGLProgram . cpp <nl> rename to cocos / 2d / CCGLProgram . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / shaders / CCGLProgram . h <nl> rename to cocos / 2d / CCGLProgram . h <nl> similarity index 100 % <nl> rename from cocos / 2d / effects / CCGrabber . cpp <nl> rename to cocos / 2d / CCGrabber . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / effects / CCGrabber . h <nl> rename to cocos / 2d / CCGrabber . h <nl> similarity index 100 % <nl> rename from cocos / 2d / effects / CCGrid . cpp <nl> rename to cocos / 2d / CCGrid . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / effects / CCGrid . h <nl> rename to cocos / 2d / CCGrid . h <nl> similarity index 100 % <nl> rename from cocos / 2d / text - input - node / CCIMEDelegate . h <nl> rename to cocos / 2d / CCIMEDelegate . h <nl> similarity index 100 % <nl> rename from cocos / 2d / text - input - node / CCIMEDispatcher . cpp <nl> rename to cocos / 2d / CCIMEDispatcher . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / text - input - node / CCIMEDispatcher . h <nl> rename to cocos / 2d / CCIMEDispatcher . h <nl> similarity index 100 % <nl> rename from cocos / 2d / label - nodes / CCLabel . cpp <nl> rename to cocos / 2d / CCLabel . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / label - nodes / CCLabel . h <nl> rename to cocos / 2d / CCLabel . h <nl> similarity index 100 % <nl> rename from cocos / 2d / label - nodes / CCLabelAtlas . cpp <nl> rename to cocos / 2d / CCLabelAtlas . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / label - nodes / CCLabelAtlas . h <nl> rename to cocos / 2d / CCLabelAtlas . h <nl> similarity index 100 % <nl> rename from cocos / 2d / label - nodes / CCLabelBMFont . cpp <nl> rename to cocos / 2d / CCLabelBMFont . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / label - nodes / CCLabelBMFont . h <nl> rename to cocos / 2d / CCLabelBMFont . h <nl> similarity index 100 % <nl> rename from cocos / 2d / label - nodes / CCLabelTTF . cpp <nl> rename to cocos / 2d / CCLabelTTF . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / label - nodes / CCLabelTTF . h <nl> rename to cocos / 2d / CCLabelTTF . h <nl> similarity index 100 % <nl> rename from cocos / 2d / label - nodes / CCLabelTextFormatProtocol . h <nl> rename to cocos / 2d / CCLabelTextFormatProtocol . h <nl> similarity index 100 % <nl> rename from cocos / 2d / label - nodes / CCLabelTextFormatter . cpp <nl> rename to cocos / 2d / CCLabelTextFormatter . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / label - nodes / CCLabelTextFormatter . h <nl> rename to cocos / 2d / CCLabelTextFormatter . h <nl> similarity index 100 % <nl> rename from cocos / 2d / layers - scenes - transitions - nodes / CCLayer . cpp <nl> rename to cocos / 2d / CCLayer . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / layers - scenes - transitions - nodes / CCLayer . h <nl> rename to cocos / 2d / CCLayer . h <nl> similarity index 100 % <nl> rename from cocos / 2d / menu - nodes / CCMenu . cpp <nl> rename to cocos / 2d / CCMenu . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / menu - nodes / CCMenu . h <nl> rename to cocos / 2d / CCMenu . h <nl> similarity index 100 % <nl> rename from cocos / 2d / menu - nodes / CCMenuItem . cpp <nl> rename to cocos / 2d / CCMenuItem . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / menu - nodes / CCMenuItem . h <nl> rename to cocos / 2d / CCMenuItem . h <nl> similarity index 100 % <nl> rename from cocos / 2d / misc - nodes / CCMotionStreak . cpp <nl> rename to cocos / 2d / CCMotionStreak . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / misc - nodes / CCMotionStreak . h <nl> rename to cocos / 2d / CCMotionStreak . h <nl> similarity index 100 % <nl> rename from cocos / 2d / base - nodes / CCNode . cpp <nl> rename to cocos / 2d / CCNode . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / base - nodes / CCNode . h <nl> rename to cocos / 2d / CCNode . h <nl> similarity index 100 % <nl> rename from cocos / 2d / support / CCNotificationCenter . cpp <nl> rename to cocos / 2d / CCNotificationCenter . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / support / CCNotificationCenter . h <nl> rename to cocos / 2d / CCNotificationCenter . h <nl> similarity index 100 % <nl> rename from cocos / 2d / tilemap - parallax - nodes / CCParallaxNode . cpp <nl> rename to cocos / 2d / CCParallaxNode . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / tilemap - parallax - nodes / CCParallaxNode . h <nl> rename to cocos / 2d / CCParallaxNode . h <nl> similarity index 100 % <nl> rename from cocos / 2d / particle - nodes / CCParticleBatchNode . cpp <nl> rename to cocos / 2d / CCParticleBatchNode . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / particle - nodes / CCParticleBatchNode . h <nl> rename to cocos / 2d / CCParticleBatchNode . h <nl> similarity index 100 % <nl> rename from cocos / 2d / particle - nodes / CCParticleExamples . cpp <nl> rename to cocos / 2d / CCParticleExamples . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / particle - nodes / CCParticleExamples . h <nl> rename to cocos / 2d / CCParticleExamples . h <nl> similarity index 100 % <nl> rename from cocos / 2d / particle - nodes / CCParticleSystem . cpp <nl> rename to cocos / 2d / CCParticleSystem . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / particle - nodes / CCParticleSystem . h <nl> rename to cocos / 2d / CCParticleSystem . h <nl> similarity index 100 % <nl> rename from cocos / 2d / particle - nodes / CCParticleSystemQuad . cpp <nl> rename to cocos / 2d / CCParticleSystemQuad . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / particle - nodes / CCParticleSystemQuad . h <nl> rename to cocos / 2d / CCParticleSystemQuad . h <nl> similarity index 100 % <nl> rename from cocos / 2d / support / CCProfiling . cpp <nl> rename to cocos / 2d / CCProfiling . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / support / CCProfiling . h <nl> rename to cocos / 2d / CCProfiling . h <nl> similarity index 100 % <nl> rename from cocos / 2d / misc - nodes / CCProgressTimer . cpp <nl> rename to cocos / 2d / CCProgressTimer . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / misc - nodes / CCProgressTimer . h <nl> rename to cocos / 2d / CCProgressTimer . h <nl> similarity index 100 % <nl> rename from cocos / 2d / include / CCProtocols . h <nl> rename to cocos / 2d / CCProtocols . h <nl> similarity index 100 % <nl> rename from cocos / 2d / misc - nodes / CCRenderTexture . cpp <nl> rename to cocos / 2d / CCRenderTexture . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / misc - nodes / CCRenderTexture . h <nl> rename to cocos / 2d / CCRenderTexture . h <nl> similarity index 100 % <nl> rename from cocos / 2d / layers - scenes - transitions - nodes / CCScene . cpp <nl> rename to cocos / 2d / CCScene . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / layers - scenes - transitions - nodes / CCScene . h <nl> rename to cocos / 2d / CCScene . h <nl> similarity index 100 % <nl> rename from cocos / 2d / script - support / CCScriptSupport . cpp <nl> rename to cocos / 2d / CCScriptSupport . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / script - support / CCScriptSupport . h <nl> rename to cocos / 2d / CCScriptSupport . h <nl> similarity index 100 % <nl> rename from cocos / 2d / shaders / CCShaderCache . cpp <nl> rename to cocos / 2d / CCShaderCache . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / shaders / CCShaderCache . h <nl> rename to cocos / 2d / CCShaderCache . h <nl> similarity index 100 % <nl> rename from cocos / 2d / sprite - nodes / CCSprite . cpp <nl> rename to cocos / 2d / CCSprite . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / sprite - nodes / CCSprite . h <nl> rename to cocos / 2d / CCSprite . h <nl> similarity index 100 % <nl> rename from cocos / 2d / sprite - nodes / CCSpriteBatchNode . cpp <nl> rename to cocos / 2d / CCSpriteBatchNode . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / sprite - nodes / CCSpriteBatchNode . h <nl> rename to cocos / 2d / CCSpriteBatchNode . h <nl> similarity index 100 % <nl> rename from cocos / 2d / sprite - nodes / CCSpriteFrame . cpp <nl> rename to cocos / 2d / CCSpriteFrame . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / sprite - nodes / CCSpriteFrame . h <nl> rename to cocos / 2d / CCSpriteFrame . h <nl> similarity index 100 % <nl> rename from cocos / 2d / sprite - nodes / CCSpriteFrameCache . cpp <nl> rename to cocos / 2d / CCSpriteFrameCache . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / sprite - nodes / CCSpriteFrameCache . h <nl> rename to cocos / 2d / CCSpriteFrameCache . h <nl> similarity index 100 % <nl> rename from cocos / 2d / tilemap - parallax - nodes / CCTMXLayer . cpp <nl> rename to cocos / 2d / CCTMXLayer . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / tilemap - parallax - nodes / CCTMXLayer . h <nl> rename to cocos / 2d / CCTMXLayer . h <nl> similarity index 100 % <nl> rename from cocos / 2d / tilemap - parallax - nodes / CCTMXObjectGroup . cpp <nl> rename to cocos / 2d / CCTMXObjectGroup . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / tilemap - parallax - nodes / CCTMXObjectGroup . h <nl> rename to cocos / 2d / CCTMXObjectGroup . h <nl> similarity index 100 % <nl> rename from cocos / 2d / tilemap - parallax - nodes / CCTMXTiledMap . cpp <nl> rename to cocos / 2d / CCTMXTiledMap . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / tilemap - parallax - nodes / CCTMXTiledMap . h <nl> rename to cocos / 2d / CCTMXTiledMap . h <nl> similarity index 100 % <nl> rename from cocos / 2d / tilemap - parallax - nodes / CCTMXXMLParser . cpp <nl> rename to cocos / 2d / CCTMXXMLParser . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / tilemap - parallax - nodes / CCTMXXMLParser . h <nl> rename to cocos / 2d / CCTMXXMLParser . h <nl> similarity index 100 % <nl> rename from cocos / 2d / text - input - node / CCTextFieldTTF . cpp <nl> rename to cocos / 2d / CCTextFieldTTF . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / text - input - node / CCTextFieldTTF . h <nl> rename to cocos / 2d / CCTextFieldTTF . h <nl> similarity index 100 % <nl> rename from cocos / 2d / label - nodes / CCTextImage . cpp <nl> rename to cocos / 2d / CCTextImage . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / label - nodes / CCTextImage . h <nl> rename to cocos / 2d / CCTextImage . h <nl> similarity index 100 % <nl> rename from cocos / 2d / textures / CCTexture2D . cpp <nl> rename to cocos / 2d / CCTexture2D . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / textures / CCTexture2D . h <nl> rename to cocos / 2d / CCTexture2D . h <nl> similarity index 100 % <nl> rename from cocos / 2d / textures / CCTextureAtlas . cpp <nl> rename to cocos / 2d / CCTextureAtlas . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / textures / CCTextureAtlas . h <nl> rename to cocos / 2d / CCTextureAtlas . h <nl> similarity index 100 % <nl> rename from cocos / 2d / textures / CCTextureCache . cpp <nl> rename to cocos / 2d / CCTextureCache . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / textures / CCTextureCache . h <nl> rename to cocos / 2d / CCTextureCache . h <nl> similarity index 100 % <nl> rename from cocos / 2d / tilemap - parallax - nodes / CCTileMapAtlas . cpp <nl> rename to cocos / 2d / CCTileMapAtlas . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / tilemap - parallax - nodes / CCTileMapAtlas . h <nl> rename to cocos / 2d / CCTileMapAtlas . h <nl> similarity index 100 % <nl> rename from cocos / 2d / event - dispatcher / CCTouch . cpp <nl> rename to cocos / 2d / CCTouch . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / event - dispatcher / CCTouch . h <nl> rename to cocos / 2d / CCTouch . h <nl> similarity index 100 % <nl> rename from cocos / 2d / layers - scenes - transitions - nodes / CCTransition . cpp <nl> rename to cocos / 2d / CCTransition . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / layers - scenes - transitions - nodes / CCTransition . h <nl> rename to cocos / 2d / CCTransition . h <nl> similarity index 100 % <nl> rename from cocos / 2d / layers - scenes - transitions - nodes / CCTransitionPageTurn . cpp <nl> rename to cocos / 2d / CCTransitionPageTurn . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / layers - scenes - transitions - nodes / CCTransitionPageTurn . h <nl> rename to cocos / 2d / CCTransitionPageTurn . h <nl> similarity index 100 % <nl> rename from cocos / 2d / layers - scenes - transitions - nodes / CCTransitionProgress . cpp <nl> rename to cocos / 2d / CCTransitionProgress . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / layers - scenes - transitions - nodes / CCTransitionProgress . h <nl> rename to cocos / 2d / CCTransitionProgress . h <nl> similarity index 100 % <nl> rename from cocos / 2d / support / user_default / CCUserDefault . cpp <nl> rename to cocos / 2d / CCUserDefault . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / support / user_default / CCUserDefault . h <nl> rename to cocos / 2d / CCUserDefault . h <nl> similarity index 100 % <nl> rename from cocos / 2d / support / user_default / CCUserDefault . mm <nl> rename to cocos / 2d / CCUserDefault . mm <nl> similarity index 100 % <nl> rename from cocos / 2d / support / user_default / CCUserDefaultAndroid . cpp <nl> rename to cocos / 2d / CCUserDefaultAndroid . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / support / CCVertex . cpp <nl> rename to cocos / 2d / CCVertex . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / support / CCVertex . h <nl> rename to cocos / 2d / CCVertex . h <nl> similarity index 100 % <nl> rename from cocos / 2d / proj . linux / Makefile <nl> rename to cocos / 2d / Makefile <nl> similarity index 100 % <nl> rename from cocos / 2d / support / image_support / TGAlib . cpp <nl> rename to cocos / 2d / TGAlib . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / support / image_support / TGAlib . h <nl> rename to cocos / 2d / TGAlib . h <nl> similarity index 100 % <nl> rename from cocos / 2d / support / TransformUtils . cpp <nl> rename to cocos / 2d / TransformUtils . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / support / TransformUtils . h <nl> rename to cocos / 2d / TransformUtils . h <nl> similarity index 100 % <nl> rename from cocos / 2d / support / zip_support / ZipUtils . cpp <nl> rename to cocos / 2d / ZipUtils . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / support / zip_support / ZipUtils . h <nl> rename to cocos / 2d / ZipUtils . h <nl> similarity index 100 % <nl> rename from cocos / 2d / support / base64 . cpp <nl> rename to cocos / 2d / base64 . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / support / base64 . h <nl> rename to cocos / 2d / base64 . h <nl> similarity index 100 % <nl> rename from cocos / 2d / support / data_support / ccCArray . cpp <nl> rename to cocos / 2d / ccCArray . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / support / data_support / ccCArray . h <nl> rename to cocos / 2d / ccCArray . h <nl> similarity index 100 % <nl> rename from cocos / 2d / include / ccConfig . h <nl> rename to cocos / 2d / ccConfig . h <nl> similarity index 100 % <nl> rename from cocos / 2d / shaders / ccGLStateCache . cpp <nl> rename to cocos / 2d / ccGLStateCache . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / shaders / ccGLStateCache . h <nl> rename to cocos / 2d / ccGLStateCache . h <nl> similarity index 100 % <nl> rename from cocos / 2d / include / ccMacros . h <nl> rename to cocos / 2d / ccMacros . h <nl> similarity index 100 % <nl> rename from cocos / 2d / shaders / ccShaderEx_SwitchMask_frag . h <nl> rename to cocos / 2d / ccShaderEx_SwitchMask_frag . h <nl> similarity index 100 % <nl> rename from cocos / 2d / shaders / ccShader_PositionColorLengthTexture_frag . h <nl> rename to cocos / 2d / ccShader_PositionColorLengthTexture_frag . h <nl> similarity index 100 % <nl> rename from cocos / 2d / shaders / ccShader_PositionColorLengthTexture_vert . h <nl> rename to cocos / 2d / ccShader_PositionColorLengthTexture_vert . h <nl> similarity index 100 % <nl> rename from cocos / 2d / shaders / ccShader_PositionColor_frag . h <nl> rename to cocos / 2d / ccShader_PositionColor_frag . h <nl> similarity index 100 % <nl> rename from cocos / 2d / shaders / ccShader_PositionColor_vert . h <nl> rename to cocos / 2d / ccShader_PositionColor_vert . h <nl> similarity index 100 % <nl> rename from cocos / 2d / shaders / ccShader_PositionTextureA8Color_frag . h <nl> rename to cocos / 2d / ccShader_PositionTextureA8Color_frag . h <nl> similarity index 100 % <nl> rename from cocos / 2d / shaders / ccShader_PositionTextureA8Color_vert . h <nl> rename to cocos / 2d / ccShader_PositionTextureA8Color_vert . h <nl> similarity index 100 % <nl> rename from cocos / 2d / shaders / ccShader_PositionTextureColorAlphaTest_frag . h <nl> rename to cocos / 2d / ccShader_PositionTextureColorAlphaTest_frag . h <nl> similarity index 100 % <nl> rename from cocos / 2d / shaders / ccShader_PositionTextureColor_frag . h <nl> rename to cocos / 2d / ccShader_PositionTextureColor_frag . h <nl> similarity index 100 % <nl> rename from cocos / 2d / shaders / ccShader_PositionTextureColor_vert . h <nl> rename to cocos / 2d / ccShader_PositionTextureColor_vert . h <nl> similarity index 100 % <nl> rename from cocos / 2d / shaders / ccShader_PositionTexture_frag . h <nl> rename to cocos / 2d / ccShader_PositionTexture_frag . h <nl> similarity index 100 % <nl> rename from cocos / 2d / shaders / ccShader_PositionTexture_uColor_frag . h <nl> rename to cocos / 2d / ccShader_PositionTexture_uColor_frag . h <nl> similarity index 100 % <nl> rename from cocos / 2d / shaders / ccShader_PositionTexture_uColor_vert . h <nl> rename to cocos / 2d / ccShader_PositionTexture_uColor_vert . h <nl> similarity index 100 % <nl> rename from cocos / 2d / shaders / ccShader_PositionTexture_vert . h <nl> rename to cocos / 2d / ccShader_PositionTexture_vert . h <nl> similarity index 100 % <nl> rename from cocos / 2d / shaders / ccShader_Position_uColor_frag . h <nl> rename to cocos / 2d / ccShader_Position_uColor_frag . h <nl> similarity index 100 % <nl> rename from cocos / 2d / shaders / ccShader_Position_uColor_vert . h <nl> rename to cocos / 2d / ccShader_Position_uColor_vert . h <nl> similarity index 100 % <nl> rename from cocos / 2d / shaders / ccShaders . cpp <nl> rename to cocos / 2d / ccShaders . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / shaders / ccShaders . h <nl> rename to cocos / 2d / ccShaders . h <nl> similarity index 100 % <nl> rename from cocos / 2d / include / ccTypes . h <nl> rename to cocos / 2d / ccTypes . h <nl> similarity index 100 % <nl> rename from cocos / 2d / support / ccUTF8 . cpp <nl> rename to cocos / 2d / ccUTF8 . cpp <nl> similarity index 100 % <nl> rename from cocos / 2d / support / ccUTF8 . h <nl> rename to cocos / 2d / ccUTF8 . h <nl> similarity index 100 % <nl> rename from cocos / 2d / support / ccUtils . h <nl> rename to cocos / 2d / ccUtils . h <nl> similarity index 100 % <nl> rename from cocos / 2d / include / cocos2d . h <nl> rename to cocos / 2d / cocos2d . h <nl> similarity index 100 % <nl> rename from cocos / 2d / proj . win32 / cocos2d . vcxproj <nl> rename to cocos / 2d / cocos2d . vcxproj <nl> similarity index 100 % <nl> rename from cocos / 2d / proj . win32 / cocos2d . vcxproj . filters <nl> rename to cocos / 2d / cocos2d . vcxproj . filters <nl> similarity index 100 % <nl> rename from cocos / 2d / proj . win32 / cocos2d . vcxproj . user <nl> rename to cocos / 2d / cocos2d . vcxproj . user <nl> similarity index 100 % <nl> rename from cocos / 2d / proj . linux / cocos2dx . mk <nl> rename to cocos / 2d / cocos2dx . mk <nl> similarity index 100 % <nl> rename from cocos / 2d / proj . win32 / cocos2dx . props <nl> rename to cocos / 2d / cocos2dx . props <nl> similarity index 100 % <nl> rename from cocos / 2d / particle - nodes / firePngData . h <nl> rename to cocos / 2d / firePngData . h <nl> deleted file mode 100755 <nl> index aaae232fb453 . . 000000000000 <nl> mmm a / cocos / 2d / proj . linux / . cproject <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " UTF - 8 " standalone = " no " ? > <nl> - < ? fileVersion 4 . 0 . 0 ? > < cproject storage_type_id = " org . eclipse . cdt . core . XmlProjectDescriptionStorage " > <nl> - < storageModule moduleId = " org . eclipse . cdt . core . settings " > <nl> - < cconfiguration id = " cdt . managedbuild . config . gnu . exe . debug . 502995704 " > <nl> - < storageModule buildSystemId = " org . eclipse . cdt . managedbuilder . core . configurationDataProvider " id = " cdt . managedbuild . config . gnu . exe . debug . 502995704 " moduleId = " org . eclipse . cdt . core . settings " name = " Debug " > <nl> - < externalSettings > <nl> - < externalSetting > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " includePath " name = " / libcocos2d " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " libraryPath " name = " / libcocos2d / Debug " / > <nl> - < entry flags = " RESOLVED " kind = " libraryFile " name = " cocos2d " srcPrefixMapping = " " srcRootPath = " " / > <nl> - < / externalSetting > <nl> - < / externalSettings > <nl> - < extensions > <nl> - < extension id = " org . eclipse . cdt . core . ELF " point = " org . eclipse . cdt . core . BinaryParser " / > <nl> - < extension id = " org . eclipse . cdt . core . GmakeErrorParser " point = " org . eclipse . cdt . core . ErrorParser " / > <nl> - < extension id = " org . eclipse . cdt . core . CWDLocator " point = " org . eclipse . cdt . core . ErrorParser " / > <nl> - < extension id = " org . eclipse . cdt . core . GCCErrorParser " point = " org . eclipse . cdt . core . ErrorParser " / > <nl> - < extension id = " org . eclipse . cdt . core . GASErrorParser " point = " org . eclipse . cdt . core . ErrorParser " / > <nl> - < extension id = " org . eclipse . cdt . core . GLDErrorParser " point = " org . eclipse . cdt . core . ErrorParser " / > <nl> - < / extensions > <nl> - < / storageModule > <nl> - < storageModule moduleId = " cdtBuildSystem " version = " 4 . 0 . 0 " > <nl> - < configuration artifactExtension = " so " artifactName = " cocos2d " buildArtefactType = " org . eclipse . cdt . build . core . buildArtefactType . sharedLib " buildProperties = " org . eclipse . cdt . build . core . buildType = org . eclipse . cdt . build . core . buildType . debug , org . eclipse . cdt . build . core . buildArtefactType = org . eclipse . cdt . build . core . buildArtefactType . sharedLib " cleanCommand = " rm - rf " description = " " errorParsers = " org . eclipse . cdt . core . GmakeErrorParser ; org . eclipse . cdt . core . CWDLocator ; org . eclipse . cdt . core . GCCErrorParser ; org . eclipse . cdt . core . GASErrorParser ; org . eclipse . cdt . core . GLDErrorParser " id = " cdt . managedbuild . config . gnu . exe . debug . 502995704 " name = " Debug " parent = " cdt . managedbuild . config . gnu . exe . debug " postannouncebuildStep = " " postbuildStep = " " preannouncebuildStep = " " prebuildStep = " " > <nl> - < folderInfo id = " cdt . managedbuild . config . gnu . exe . debug . 502995704 . " name = " / " resourcePath = " " > <nl> - < toolChain errorParsers = " " id = " cdt . managedbuild . toolchain . gnu . exe . debug . 1381795813 " name = " Linux GCC " superClass = " cdt . managedbuild . toolchain . gnu . exe . debug " > <nl> - < targetPlatform binaryParser = " org . eclipse . cdt . core . ELF " id = " cdt . managedbuild . target . gnu . platform . exe . debug . 493450185 " name = " Debug Platform " superClass = " cdt . managedbuild . target . gnu . platform . exe . debug " / > <nl> - < builder buildPath = " $ { workspace_loc : / libcocos2d / Debug } " errorParsers = " org . eclipse . cdt . core . GmakeErrorParser ; org . eclipse . cdt . core . CWDLocator " id = " cdt . managedbuild . target . gnu . builder . exe . debug . 148088968 " keepEnvironmentInBuildfile = " false " managedBuildOn = " true " name = " Gnu Make Builder " superClass = " cdt . managedbuild . target . gnu . builder . exe . debug " / > <nl> - < tool commandLinePattern = " $ { COMMAND } $ { FLAGS } $ { OUTPUT_FLAG } $ { OUTPUT_PREFIX } $ { OUTPUT } $ { INPUTS } " id = " cdt . managedbuild . tool . gnu . archiver . base . 1953133549 " name = " GCC Archiver " superClass = " cdt . managedbuild . tool . gnu . archiver . base " / > <nl> - < tool command = " g + + " commandLinePattern = " $ { COMMAND } $ { FLAGS } $ { OUTPUT_FLAG } $ { OUTPUT_PREFIX } $ { OUTPUT } $ { INPUTS } " errorParsers = " org . eclipse . cdt . core . GCCErrorParser " id = " cdt . managedbuild . tool . gnu . cpp . compiler . exe . debug . 2063289710 " name = " GCC C + + Compiler " superClass = " cdt . managedbuild . tool . gnu . cpp . compiler . exe . debug " > <nl> - < option id = " gnu . cpp . compiler . exe . debug . option . optimization . level . 1363689121 " name = " Optimization Level " superClass = " gnu . cpp . compiler . exe . debug . option . optimization . level " value = " gnu . cpp . compiler . optimization . level . none " valueType = " enumerated " / > <nl> - < option id = " gnu . cpp . compiler . exe . debug . option . debugging . level . 182720845 " name = " Debug Level " superClass = " gnu . cpp . compiler . exe . debug . option . debugging . level " value = " gnu . cpp . compiler . debugging . level . max " valueType = " enumerated " / > <nl> - < option id = " gnu . cpp . compiler . option . include . paths . 1224978101 " name = " Include paths ( - I ) " superClass = " gnu . cpp . compiler . option . include . paths " valueType = " includePath " > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / include " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / linux " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / kazmath / include " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libfreetype2 " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libpng " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libjpeg " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libtiff / include " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libwebp " / > <nl> - < / option > <nl> - < option id = " gnu . cpp . compiler . option . preprocessor . def . 954744053 " name = " Defined symbols ( - D ) " superClass = " gnu . cpp . compiler . option . preprocessor . def " valueType = " definedSymbols " > <nl> - < listOptionValue builtIn = " false " value = " LINUX " / > <nl> - < listOptionValue builtIn = " false " value = " CC_KEYBOARD_SUPPORT " / > <nl> - < / option > <nl> - < option id = " gnu . cpp . compiler . option . warnings . allwarn . 1620989551 " name = " All warnings ( - Wall ) " superClass = " gnu . cpp . compiler . option . warnings . allwarn " value = " false " valueType = " boolean " / > <nl> - < option id = " gnu . cpp . compiler . option . other . pic . 1121644479 " name = " Position Independent Code ( - fPIC ) " superClass = " gnu . cpp . compiler . option . other . pic " value = " true " valueType = " boolean " / > <nl> - < option id = " gnu . cpp . compiler . option . other . other . 1525878615 " name = " Other flags " superClass = " gnu . cpp . compiler . option . other . other " value = " - c - fmessage - length = 0 - Wno - deprecated - declarations - std = gnu + + 0x " valueType = " string " / > <nl> - < inputType id = " cdt . managedbuild . tool . gnu . cpp . compiler . input . 966305124 " superClass = " cdt . managedbuild . tool . gnu . cpp . compiler . input " / > <nl> - < / tool > <nl> - < tool command = " gcc " commandLinePattern = " $ { COMMAND } $ { FLAGS } $ { OUTPUT_FLAG } $ { OUTPUT_PREFIX } $ { OUTPUT } $ { INPUTS } " errorParsers = " org . eclipse . cdt . core . GCCErrorParser " id = " cdt . managedbuild . tool . gnu . c . compiler . exe . debug . 452615323 " name = " GCC C Compiler " superClass = " cdt . managedbuild . tool . gnu . c . compiler . exe . debug " > <nl> - < option defaultValue = " gnu . c . optimization . level . none " id = " gnu . c . compiler . exe . debug . option . optimization . level . 1079128222 " name = " Optimization Level " superClass = " gnu . c . compiler . exe . debug . option . optimization . level " valueType = " enumerated " / > <nl> - < option id = " gnu . c . compiler . exe . debug . option . debugging . level . 703039623 " name = " Debug Level " superClass = " gnu . c . compiler . exe . debug . option . debugging . level " value = " gnu . c . debugging . level . max " valueType = " enumerated " / > <nl> - < option id = " gnu . c . compiler . option . include . paths . 500257262 " name = " Include paths ( - I ) " superClass = " gnu . c . compiler . option . include . paths " valueType = " includePath " > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / include " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / linux " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / kazmath / include " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libfreetype2 " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libpng " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libjpeg " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libtiff / include " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libwebp " / > <nl> - < / option > <nl> - < option id = " gnu . c . compiler . option . preprocessor . def . symbols . 1531770269 " name = " Defined symbols ( - D ) " superClass = " gnu . c . compiler . option . preprocessor . def . symbols " valueType = " definedSymbols " > <nl> - < listOptionValue builtIn = " false " value = " LINUX " / > <nl> - < listOptionValue builtIn = " false " value = " CC_KEYBOARD_SUPPORT " / > <nl> - < / option > <nl> - < option id = " gnu . c . compiler . option . warnings . allwarn . 1446204747 " name = " All warnings ( - Wall ) " superClass = " gnu . c . compiler . option . warnings . allwarn " value = " false " valueType = " boolean " / > <nl> - < option id = " gnu . c . compiler . option . misc . pic . 1626885407 " name = " Position Independent Code ( - fPIC ) " superClass = " gnu . c . compiler . option . misc . pic " value = " true " valueType = " boolean " / > <nl> - < option id = " gnu . c . compiler . option . misc . other . 1947498091 " name = " Other flags " superClass = " gnu . c . compiler . option . misc . other " value = " - c - fmessage - length = 0 - Wno - deprecated - declarations " valueType = " string " / > <nl> - < inputType id = " cdt . managedbuild . tool . gnu . c . compiler . input . 697502414 " superClass = " cdt . managedbuild . tool . gnu . c . compiler . input " / > <nl> - < / tool > <nl> - < tool commandLinePattern = " $ { COMMAND } $ { FLAGS } $ { OUTPUT_FLAG } $ { OUTPUT_PREFIX } $ { OUTPUT } $ { INPUTS } " id = " cdt . managedbuild . tool . gnu . c . linker . exe . debug . 1826952880 " name = " GCC C Linker " superClass = " cdt . managedbuild . tool . gnu . c . linker . exe . debug " > <nl> - < option defaultValue = " true " id = " gnu . c . link . option . shared . 978860202 " name = " Shared ( - shared ) " superClass = " gnu . c . link . option . shared " valueType = " boolean " / > <nl> - < / tool > <nl> - < tool command = " g + + " commandLinePattern = " $ { COMMAND } $ { FLAGS } $ { OUTPUT_FLAG } $ { OUTPUT_PREFIX } $ { OUTPUT } $ { INPUTS } " errorParsers = " org . eclipse . cdt . core . GLDErrorParser " id = " cdt . managedbuild . tool . gnu . cpp . linker . exe . debug . 1429401820 " name = " GCC C + + Linker " superClass = " cdt . managedbuild . tool . gnu . cpp . linker . exe . debug " > <nl> - < option defaultValue = " true " id = " gnu . cpp . link . option . shared . 1563119377 " name = " Shared ( - shared ) " superClass = " gnu . cpp . link . option . shared " value = " true " valueType = " boolean " / > <nl> - < option id = " gnu . cpp . link . option . libs . 1265275896 " name = " Libraries ( - l ) " superClass = " gnu . cpp . link . option . libs " valueType = " libs " > <nl> - < listOptionValue builtIn = " false " value = " glfw " / > <nl> - < listOptionValue builtIn = " false " value = " fontconfig " / > <nl> - < listOptionValue builtIn = " false " value = " GLEW " / > <nl> - < / option > <nl> - < option id = " gnu . cpp . link . option . soname . 2012475291 " name = " Shared object name ( - Wl , - soname = ) " superClass = " gnu . cpp . link . option . soname " value = " " valueType = " string " / > <nl> - < option id = " gnu . cpp . link . option . userobjs . 1360463693 " name = " Other objects " superClass = " gnu . cpp . link . option . userobjs " valueType = " userObjs " > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libraries / libfreetype . a " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libraries / libcurl . a " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libraries / libtiff . a " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libraries / libpng . a " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libraries / libjpeg . a " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libraries / libwebp . a " / > <nl> - < / option > <nl> - < option id = " gnu . cpp . link . option . paths . 1027331890 " name = " Library search path ( - L ) " superClass = " gnu . cpp . link . option . paths " / > <nl> - < inputType id = " cdt . managedbuild . tool . gnu . cpp . linker . input . 620370737 " superClass = " cdt . managedbuild . tool . gnu . cpp . linker . input " > <nl> - < additionalInput kind = " additionalinputdependency " paths = " $ ( USER_OBJS ) " / > <nl> - < additionalInput kind = " additionalinput " paths = " $ ( LIBS ) " / > <nl> - < / inputType > <nl> - < / tool > <nl> - < tool command = " as " commandLinePattern = " $ { COMMAND } $ { FLAGS } $ { OUTPUT_FLAG } $ { OUTPUT_PREFIX } $ { OUTPUT } $ { INPUTS } " errorParsers = " org . eclipse . cdt . core . GASErrorParser " id = " cdt . managedbuild . tool . gnu . assembler . exe . debug . 857245124 " name = " GCC Assembler " superClass = " cdt . managedbuild . tool . gnu . assembler . exe . debug " > <nl> - < inputType id = " cdt . managedbuild . tool . gnu . assembler . input . 673491520 " superClass = " cdt . managedbuild . tool . gnu . assembler . input " / > <nl> - < / tool > <nl> - < / toolChain > <nl> - < / folderInfo > <nl> - < sourceEntries > <nl> - < entry excluding = " draw_nodes | shaders | kazmath | tilemap_parallax_nodes | actions | base_nodes | cocoa | effects | include | keypad_dispatcher | label_nodes | layers_scenes_transitions_nodes | menu_nodes | misc_nodes | particle_nodes | platform | script_support | sprite_nodes | support | text_input_node | textures | tileMap_parallax_nodes | touch_dispatcher " flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " actions " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " base_nodes " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " cocoa " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " draw_nodes " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " effects " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " include " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " kazmath " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " keypad_dispatcher " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " label_nodes " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " layers_scenes_transitions_nodes " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " menu_nodes " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " misc_nodes " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " particle_nodes " / > <nl> - < entry excluding = " android / | bada / | ios / | marmalade / | qnx / | third_party / | win32 / | wophone / " flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " platform " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " script_support " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " shaders " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " sprite_nodes " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " support " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " text_input_node " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " textures " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " tilemap_parallax_nodes " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " touch_dispatcher " / > <nl> - < / sourceEntries > <nl> - < / configuration > <nl> - < / storageModule > <nl> - < storageModule moduleId = " org . eclipse . cdt . core . externalSettings " / > <nl> - < storageModule moduleId = " org . eclipse . cdt . internal . ui . text . commentOwnerProjectMappings " / > <nl> - < storageModule moduleId = " org . eclipse . cdt . core . language . mapping " / > <nl> - < / cconfiguration > <nl> - < cconfiguration id = " cdt . managedbuild . config . gnu . exe . release . 1270689208 " > <nl> - < storageModule buildSystemId = " org . eclipse . cdt . managedbuilder . core . configurationDataProvider " id = " cdt . managedbuild . config . gnu . exe . release . 1270689208 " moduleId = " org . eclipse . cdt . core . settings " name = " Release " > <nl> - < externalSettings > <nl> - < externalSetting > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " includePath " name = " / libcocos2d " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " libraryPath " name = " / libcocos2d / Release " / > <nl> - < entry flags = " RESOLVED " kind = " libraryFile " name = " cocos2d " srcPrefixMapping = " " srcRootPath = " " / > <nl> - < / externalSetting > <nl> - < / externalSettings > <nl> - < extensions > <nl> - < extension id = " org . eclipse . cdt . core . ELF " point = " org . eclipse . cdt . core . BinaryParser " / > <nl> - < extension id = " org . eclipse . cdt . core . GmakeErrorParser " point = " org . eclipse . cdt . core . ErrorParser " / > <nl> - < extension id = " org . eclipse . cdt . core . CWDLocator " point = " org . eclipse . cdt . core . ErrorParser " / > <nl> - < extension id = " org . eclipse . cdt . core . GCCErrorParser " point = " org . eclipse . cdt . core . ErrorParser " / > <nl> - < extension id = " org . eclipse . cdt . core . GASErrorParser " point = " org . eclipse . cdt . core . ErrorParser " / > <nl> - < extension id = " org . eclipse . cdt . core . GLDErrorParser " point = " org . eclipse . cdt . core . ErrorParser " / > <nl> - < / extensions > <nl> - < / storageModule > <nl> - < storageModule moduleId = " cdtBuildSystem " version = " 4 . 0 . 0 " > <nl> - < configuration artifactExtension = " so " artifactName = " cocos2d " buildArtefactType = " org . eclipse . cdt . build . core . buildArtefactType . sharedLib " buildProperties = " org . eclipse . cdt . build . core . buildType = org . eclipse . cdt . build . core . buildType . release , org . eclipse . cdt . build . core . buildArtefactType = org . eclipse . cdt . build . core . buildArtefactType . sharedLib " cleanCommand = " rm - rf " description = " " errorParsers = " org . eclipse . cdt . core . GmakeErrorParser ; org . eclipse . cdt . core . CWDLocator ; org . eclipse . cdt . core . GCCErrorParser ; org . eclipse . cdt . core . GASErrorParser ; org . eclipse . cdt . core . GLDErrorParser " id = " cdt . managedbuild . config . gnu . exe . release . 1270689208 " name = " Release " parent = " cdt . managedbuild . config . gnu . exe . release " postannouncebuildStep = " " postbuildStep = " " preannouncebuildStep = " " prebuildStep = " " > <nl> - < folderInfo id = " cdt . managedbuild . config . gnu . exe . release . 1270689208 . " name = " / " resourcePath = " " > <nl> - < toolChain errorParsers = " " id = " cdt . managedbuild . toolchain . gnu . exe . release . 1907181202 " name = " Linux GCC " superClass = " cdt . managedbuild . toolchain . gnu . exe . release " > <nl> - < targetPlatform binaryParser = " org . eclipse . cdt . core . ELF " id = " cdt . managedbuild . target . gnu . platform . exe . release . 294936983 " name = " Debug Platform " superClass = " cdt . managedbuild . target . gnu . platform . exe . release " / > <nl> - < builder buildPath = " " errorParsers = " org . eclipse . cdt . core . GmakeErrorParser ; org . eclipse . cdt . core . CWDLocator " id = " cdt . managedbuild . target . gnu . builder . exe . release . 1974622272 " keepEnvironmentInBuildfile = " false " managedBuildOn = " true " name = " Gnu Make Builder " superClass = " cdt . managedbuild . target . gnu . builder . exe . release " / > <nl> - < tool commandLinePattern = " $ { COMMAND } $ { FLAGS } $ { OUTPUT_FLAG } $ { OUTPUT_PREFIX } $ { OUTPUT } $ { INPUTS } " id = " cdt . managedbuild . tool . gnu . archiver . base . 958073991 " name = " GCC Archiver " superClass = " cdt . managedbuild . tool . gnu . archiver . base " / > <nl> - < tool command = " g + + " commandLinePattern = " $ { COMMAND } $ { FLAGS } $ { OUTPUT_FLAG } $ { OUTPUT_PREFIX } $ { OUTPUT } $ { INPUTS } " errorParsers = " org . eclipse . cdt . core . GCCErrorParser " id = " cdt . managedbuild . tool . gnu . cpp . compiler . exe . release . 1336291657 " name = " GCC C + + Compiler " superClass = " cdt . managedbuild . tool . gnu . cpp . compiler . exe . release " > <nl> - < option id = " gnu . cpp . compiler . exe . release . option . optimization . level . 1498871898 " name = " Optimization Level " superClass = " gnu . cpp . compiler . exe . release . option . optimization . level " value = " gnu . cpp . compiler . optimization . level . most " valueType = " enumerated " / > <nl> - < option id = " gnu . cpp . compiler . exe . release . option . debugging . level . 1985273019 " name = " Debug Level " superClass = " gnu . cpp . compiler . exe . release . option . debugging . level " value = " gnu . cpp . compiler . debugging . level . none " valueType = " enumerated " / > <nl> - < option id = " gnu . cpp . compiler . option . include . paths . 1571711257 " name = " Include paths ( - I ) " superClass = " gnu . cpp . compiler . option . include . paths " valueType = " includePath " > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / include " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / linux " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / kazmath / include " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libfreetype2 " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libpng " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libjpeg " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libtiff / include " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libwebp " / > <nl> - < / option > <nl> - < option id = " gnu . cpp . compiler . option . preprocessor . def . 1432872181 " name = " Defined symbols ( - D ) " superClass = " gnu . cpp . compiler . option . preprocessor . def " valueType = " definedSymbols " > <nl> - < listOptionValue builtIn = " false " value = " LINUX " / > <nl> - < listOptionValue builtIn = " false " value = " CC_KEYBOARD_SUPPORT " / > <nl> - < / option > <nl> - < option id = " gnu . cpp . compiler . option . warnings . allwarn . 1658108227 " name = " All warnings ( - Wall ) " superClass = " gnu . cpp . compiler . option . warnings . allwarn " value = " true " valueType = " boolean " / > <nl> - < option id = " gnu . cpp . compiler . option . other . other . 1465323333 " name = " Other flags " superClass = " gnu . cpp . compiler . option . other . other " value = " - c - fmessage - length = 0 - Wno - deprecated - declarations - std = gnu + + 0x " valueType = " string " / > <nl> - < inputType id = " cdt . managedbuild . tool . gnu . cpp . compiler . input . 1506297979 " superClass = " cdt . managedbuild . tool . gnu . cpp . compiler . input " / > <nl> - < / tool > <nl> - < tool command = " gcc " commandLinePattern = " $ { COMMAND } $ { FLAGS } $ { OUTPUT_FLAG } $ { OUTPUT_PREFIX } $ { OUTPUT } $ { INPUTS } " errorParsers = " org . eclipse . cdt . core . GCCErrorParser " id = " cdt . managedbuild . tool . gnu . c . compiler . exe . release . 984270671 " name = " GCC C Compiler " superClass = " cdt . managedbuild . tool . gnu . c . compiler . exe . release " > <nl> - < option defaultValue = " gnu . c . optimization . level . most " id = " gnu . c . compiler . exe . release . option . optimization . level . 1465078999 " name = " Optimization Level " superClass = " gnu . c . compiler . exe . release . option . optimization . level " value = " gnu . c . optimization . level . most " valueType = " enumerated " / > <nl> - < option id = " gnu . c . compiler . exe . release . option . debugging . level . 519142307 " name = " Debug Level " superClass = " gnu . c . compiler . exe . release . option . debugging . level " value = " gnu . c . debugging . level . none " valueType = " enumerated " / > <nl> - < option id = " gnu . c . compiler . option . include . paths . 1095324729 " name = " Include paths ( - I ) " superClass = " gnu . c . compiler . option . include . paths " valueType = " includePath " > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / include " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / linux " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / kazmath / include " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libfreetype2 " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libpng " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libjpeg " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libtiff / include " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libwebp " / > <nl> - < / option > <nl> - < option id = " gnu . c . compiler . option . preprocessor . def . symbols . 1479035749 " name = " Defined symbols ( - D ) " superClass = " gnu . c . compiler . option . preprocessor . def . symbols " valueType = " definedSymbols " > <nl> - < listOptionValue builtIn = " false " value = " LINUX " / > <nl> - < listOptionValue builtIn = " false " value = " CC_KEYBOARD_SUPPORT " / > <nl> - < / option > <nl> - < option id = " gnu . c . compiler . option . warnings . allwarn . 2077117046 " name = " All warnings ( - Wall ) " superClass = " gnu . c . compiler . option . warnings . allwarn " value = " false " valueType = " boolean " / > <nl> - < option id = " gnu . c . compiler . option . misc . other . 1031698537 " name = " Other flags " superClass = " gnu . c . compiler . option . misc . other " value = " - c - fmessage - length = 0 - Wno - deprecated - declarations " valueType = " string " / > <nl> - < inputType id = " cdt . managedbuild . tool . gnu . c . compiler . input . 191330176 " superClass = " cdt . managedbuild . tool . gnu . c . compiler . input " / > <nl> - < / tool > <nl> - < tool commandLinePattern = " $ { COMMAND } $ { FLAGS } $ { OUTPUT_FLAG } $ { OUTPUT_PREFIX } $ { OUTPUT } $ { INPUTS } " id = " cdt . managedbuild . tool . gnu . c . linker . exe . release . 1375796638 " name = " GCC C Linker " superClass = " cdt . managedbuild . tool . gnu . c . linker . exe . release " > <nl> - < option defaultValue = " true " id = " gnu . c . link . option . shared . 10185576 " name = " Shared ( - shared ) " superClass = " gnu . c . link . option . shared " valueType = " boolean " / > <nl> - < / tool > <nl> - < tool command = " g + + " commandLinePattern = " $ { COMMAND } $ { FLAGS } $ { OUTPUT_FLAG } $ { OUTPUT_PREFIX } $ { OUTPUT } $ { INPUTS } " errorParsers = " org . eclipse . cdt . core . GLDErrorParser " id = " cdt . managedbuild . tool . gnu . cpp . linker . exe . release . 1659743626 " name = " GCC C + + Linker " superClass = " cdt . managedbuild . tool . gnu . cpp . linker . exe . release " > <nl> - < option defaultValue = " true " id = " gnu . cpp . link . option . shared . 1422544016 " name = " Shared ( - shared ) " superClass = " gnu . cpp . link . option . shared " value = " true " valueType = " boolean " / > <nl> - < option id = " gnu . cpp . link . option . libs . 1080426232 " name = " Libraries ( - l ) " superClass = " gnu . cpp . link . option . libs " valueType = " libs " > <nl> - < listOptionValue builtIn = " false " value = " glfw " / > <nl> - < listOptionValue builtIn = " false " value = " fontconfig " / > <nl> - < listOptionValue builtIn = " false " value = " GLEW " / > <nl> - < / option > <nl> - < option id = " gnu . cpp . link . option . soname . 1066283521 " name = " Shared object name ( - Wl , - soname = ) " superClass = " gnu . cpp . link . option . soname " value = " " valueType = " string " / > <nl> - < option id = " gnu . cpp . link . option . userobjs . 394630625 " name = " Other objects " superClass = " gnu . cpp . link . option . userobjs " valueType = " userObjs " > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libraries / libfreetype . a " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libraries / libcurl . a " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libraries / libtiff . a " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libraries / libpng . a " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libraries / libjpeg . a " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libraries / libwebp . a " / > <nl> - < / option > <nl> - < option id = " gnu . cpp . link . option . paths . 1001119408 " name = " Library search path ( - L ) " superClass = " gnu . cpp . link . option . paths " / > <nl> - < inputType id = " cdt . managedbuild . tool . gnu . cpp . linker . input . 319060310 " superClass = " cdt . managedbuild . tool . gnu . cpp . linker . input " > <nl> - < additionalInput kind = " additionalinputdependency " paths = " $ ( USER_OBJS ) " / > <nl> - < additionalInput kind = " additionalinput " paths = " $ ( LIBS ) " / > <nl> - < / inputType > <nl> - < / tool > <nl> - < tool command = " as " commandLinePattern = " $ { COMMAND } $ { FLAGS } $ { OUTPUT_FLAG } $ { OUTPUT_PREFIX } $ { OUTPUT } $ { INPUTS } " errorParsers = " org . eclipse . cdt . core . GASErrorParser " id = " cdt . managedbuild . tool . gnu . assembler . exe . release . 1254214954 " name = " GCC Assembler " superClass = " cdt . managedbuild . tool . gnu . assembler . exe . release " > <nl> - < inputType id = " cdt . managedbuild . tool . gnu . assembler . input . 43527139 " superClass = " cdt . managedbuild . tool . gnu . assembler . input " / > <nl> - < / tool > <nl> - < / toolChain > <nl> - < / folderInfo > <nl> - < sourceEntries > <nl> - < entry excluding = " draw_nodes | shaders | kazmath | tilemap_parallax_nodes | actions | base_nodes | cocoa | effects | include | keypad_dispatcher | label_nodes | layers_scenes_transitions_nodes | menu_nodes | misc_nodes | particle_nodes | platform | script_support | sprite_nodes | support | text_input_node | textures | tileMap_parallax_nodes | touch_dispatcher " flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " actions " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " base_nodes " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " cocoa " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " draw_nodes " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " effects " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " include " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " kazmath " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " keypad_dispatcher " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " label_nodes " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " layers_scenes_transitions_nodes " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " menu_nodes " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " misc_nodes " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " particle_nodes " / > <nl> - < entry excluding = " android / | bada / | ios / | marmalade / | qnx / | third_party / | win32 / | wophone / " flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " platform " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " script_support " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " shaders " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " sprite_nodes " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " support " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " text_input_node " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " textures " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " tileMap_parallax_nodes " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " tilemap_parallax_nodes " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " touch_dispatcher " / > <nl> - < / sourceEntries > <nl> - < / configuration > <nl> - < / storageModule > <nl> - < storageModule moduleId = " org . eclipse . cdt . core . externalSettings " / > <nl> - < storageModule moduleId = " org . eclipse . cdt . internal . ui . text . commentOwnerProjectMappings " / > <nl> - < storageModule moduleId = " org . eclipse . cdt . core . language . mapping " / > <nl> - < / cconfiguration > <nl> - < cconfiguration id = " cdt . managedbuild . config . gnu . exe . debug . 502995704 . 1339240180 " > <nl> - < storageModule buildSystemId = " org . eclipse . cdt . managedbuilder . core . configurationDataProvider " id = " cdt . managedbuild . config . gnu . exe . debug . 502995704 . 1339240180 " moduleId = " org . eclipse . cdt . core . settings " name = " Debug64 " > <nl> - < externalSettings > <nl> - < externalSetting > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " includePath " name = " / libcocos2d " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " libraryPath " name = " / libcocos2d / Debug64 " / > <nl> - < entry flags = " RESOLVED " kind = " libraryFile " name = " cocos2d " srcPrefixMapping = " " srcRootPath = " " / > <nl> - < / externalSetting > <nl> - < / externalSettings > <nl> - < extensions > <nl> - < extension id = " org . eclipse . cdt . core . ELF " point = " org . eclipse . cdt . core . BinaryParser " / > <nl> - < extension id = " org . eclipse . cdt . core . GmakeErrorParser " point = " org . eclipse . cdt . core . ErrorParser " / > <nl> - < extension id = " org . eclipse . cdt . core . CWDLocator " point = " org . eclipse . cdt . core . ErrorParser " / > <nl> - < extension id = " org . eclipse . cdt . core . GCCErrorParser " point = " org . eclipse . cdt . core . ErrorParser " / > <nl> - < extension id = " org . eclipse . cdt . core . GASErrorParser " point = " org . eclipse . cdt . core . ErrorParser " / > <nl> - < extension id = " org . eclipse . cdt . core . GLDErrorParser " point = " org . eclipse . cdt . core . ErrorParser " / > <nl> - < / extensions > <nl> - < / storageModule > <nl> - < storageModule moduleId = " cdtBuildSystem " version = " 4 . 0 . 0 " > <nl> - < configuration artifactExtension = " so " artifactName = " cocos2d " buildArtefactType = " org . eclipse . cdt . build . core . buildArtefactType . sharedLib " buildProperties = " org . eclipse . cdt . build . core . buildType = org . eclipse . cdt . build . core . buildType . debug , org . eclipse . cdt . build . core . buildArtefactType = org . eclipse . cdt . build . core . buildArtefactType . sharedLib " cleanCommand = " rm - rf " description = " " errorParsers = " org . eclipse . cdt . core . GmakeErrorParser ; org . eclipse . cdt . core . CWDLocator ; org . eclipse . cdt . core . GCCErrorParser ; org . eclipse . cdt . core . GASErrorParser ; org . eclipse . cdt . core . GLDErrorParser " id = " cdt . managedbuild . config . gnu . exe . debug . 502995704 . 1339240180 " name = " Debug64 " parent = " cdt . managedbuild . config . gnu . exe . debug " postannouncebuildStep = " " postbuildStep = " " preannouncebuildStep = " " prebuildStep = " " > <nl> - < folderInfo id = " cdt . managedbuild . config . gnu . exe . debug . 502995704 . 1339240180 . " name = " / " resourcePath = " " > <nl> - < toolChain errorParsers = " " id = " cdt . managedbuild . toolchain . gnu . exe . debug . 142429516 " name = " Linux GCC " superClass = " cdt . managedbuild . toolchain . gnu . exe . debug " > <nl> - < targetPlatform binaryParser = " org . eclipse . cdt . core . ELF " id = " cdt . managedbuild . target . gnu . platform . exe . debug . 648351050 " name = " Debug Platform " superClass = " cdt . managedbuild . target . gnu . platform . exe . debug " / > <nl> - < builder buildPath = " $ { workspace_loc : / libcocos2d / Debug } " errorParsers = " org . eclipse . cdt . core . GmakeErrorParser ; org . eclipse . cdt . core . CWDLocator " id = " cdt . managedbuild . target . gnu . builder . exe . debug . 1313583572 " keepEnvironmentInBuildfile = " false " managedBuildOn = " true " name = " Gnu Make Builder " superClass = " cdt . managedbuild . target . gnu . builder . exe . debug " / > <nl> - < tool commandLinePattern = " $ { COMMAND } $ { FLAGS } $ { OUTPUT_FLAG } $ { OUTPUT_PREFIX } $ { OUTPUT } $ { INPUTS } " id = " cdt . managedbuild . tool . gnu . archiver . base . 831583821 " name = " GCC Archiver " superClass = " cdt . managedbuild . tool . gnu . archiver . base " / > <nl> - < tool command = " g + + " commandLinePattern = " $ { COMMAND } $ { FLAGS } $ { OUTPUT_FLAG } $ { OUTPUT_PREFIX } $ { OUTPUT } $ { INPUTS } " errorParsers = " org . eclipse . cdt . core . GCCErrorParser " id = " cdt . managedbuild . tool . gnu . cpp . compiler . exe . debug . 1527575500 " name = " GCC C + + Compiler " superClass = " cdt . managedbuild . tool . gnu . cpp . compiler . exe . debug " > <nl> - < option id = " gnu . cpp . compiler . exe . debug . option . optimization . level . 670632373 " name = " Optimization Level " superClass = " gnu . cpp . compiler . exe . debug . option . optimization . level " value = " gnu . cpp . compiler . optimization . level . none " valueType = " enumerated " / > <nl> - < option id = " gnu . cpp . compiler . exe . debug . option . debugging . level . 1998417258 " name = " Debug Level " superClass = " gnu . cpp . compiler . exe . debug . option . debugging . level " value = " gnu . cpp . compiler . debugging . level . max " valueType = " enumerated " / > <nl> - < option id = " gnu . cpp . compiler . option . include . paths . 993029961 " name = " Include paths ( - I ) " superClass = " gnu . cpp . compiler . option . include . paths " valueType = " includePath " > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / include " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / linux " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / kazmath / include " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libfreetype2 " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libpng " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libjpeg " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libtiff / include " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libwebp " / > <nl> - < / option > <nl> - < option id = " gnu . cpp . compiler . option . preprocessor . def . 500904227 " name = " Defined symbols ( - D ) " superClass = " gnu . cpp . compiler . option . preprocessor . def " valueType = " definedSymbols " > <nl> - < listOptionValue builtIn = " false " value = " LINUX " / > <nl> - < listOptionValue builtIn = " false " value = " CC_KEYBOARD_SUPPORT " / > <nl> - < / option > <nl> - < option id = " gnu . cpp . compiler . option . warnings . allwarn . 342084758 " name = " All warnings ( - Wall ) " superClass = " gnu . cpp . compiler . option . warnings . allwarn " value = " false " valueType = " boolean " / > <nl> - < option id = " gnu . cpp . compiler . option . other . pic . 1479362521 " name = " Position Independent Code ( - fPIC ) " superClass = " gnu . cpp . compiler . option . other . pic " value = " true " valueType = " boolean " / > <nl> - < option id = " gnu . cpp . compiler . option . other . other . 1396416546 " name = " Other flags " superClass = " gnu . cpp . compiler . option . other . other " value = " - c - fmessage - length = 0 - Wno - deprecated - declarations - std = gnu + + 0x " valueType = " string " / > <nl> - < inputType id = " cdt . managedbuild . tool . gnu . cpp . compiler . input . 386716465 " superClass = " cdt . managedbuild . tool . gnu . cpp . compiler . input " / > <nl> - < / tool > <nl> - < tool command = " gcc " commandLinePattern = " $ { COMMAND } $ { FLAGS } $ { OUTPUT_FLAG } $ { OUTPUT_PREFIX } $ { OUTPUT } $ { INPUTS } " errorParsers = " org . eclipse . cdt . core . GCCErrorParser " id = " cdt . managedbuild . tool . gnu . c . compiler . exe . debug . 320530417 " name = " GCC C Compiler " superClass = " cdt . managedbuild . tool . gnu . c . compiler . exe . debug " > <nl> - < option defaultValue = " gnu . c . optimization . level . none " id = " gnu . c . compiler . exe . debug . option . optimization . level . 965493763 " name = " Optimization Level " superClass = " gnu . c . compiler . exe . debug . option . optimization . level " valueType = " enumerated " / > <nl> - < option id = " gnu . c . compiler . exe . debug . option . debugging . level . 1976860143 " name = " Debug Level " superClass = " gnu . c . compiler . exe . debug . option . debugging . level " value = " gnu . c . debugging . level . max " valueType = " enumerated " / > <nl> - < option id = " gnu . c . compiler . option . include . paths . 590611875 " name = " Include paths ( - I ) " superClass = " gnu . c . compiler . option . include . paths " valueType = " includePath " > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / include " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / linux " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / kazmath / include " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libfreetype2 " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libpng " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libjpeg " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libtiff / include " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libwebp " / > <nl> - < / option > <nl> - < option id = " gnu . c . compiler . option . preprocessor . def . symbols . 1461044764 " name = " Defined symbols ( - D ) " superClass = " gnu . c . compiler . option . preprocessor . def . symbols " valueType = " definedSymbols " > <nl> - < listOptionValue builtIn = " false " value = " LINUX " / > <nl> - < listOptionValue builtIn = " false " value = " CC_KEYBOARD_SUPPORT " / > <nl> - < / option > <nl> - < option id = " gnu . c . compiler . option . warnings . allwarn . 742815361 " name = " All warnings ( - Wall ) " superClass = " gnu . c . compiler . option . warnings . allwarn " value = " false " valueType = " boolean " / > <nl> - < option id = " gnu . c . compiler . option . misc . pic . 1135702714 " name = " Position Independent Code ( - fPIC ) " superClass = " gnu . c . compiler . option . misc . pic " value = " true " valueType = " boolean " / > <nl> - < option id = " gnu . c . compiler . option . misc . other . 1509540325 " name = " Other flags " superClass = " gnu . c . compiler . option . misc . other " value = " - c - fmessage - length = 0 - Wno - deprecated - declarations " valueType = " string " / > <nl> - < inputType id = " cdt . managedbuild . tool . gnu . c . compiler . input . 1931033313 " superClass = " cdt . managedbuild . tool . gnu . c . compiler . input " / > <nl> - < / tool > <nl> - < tool commandLinePattern = " $ { COMMAND } $ { FLAGS } $ { OUTPUT_FLAG } $ { OUTPUT_PREFIX } $ { OUTPUT } $ { INPUTS } " id = " cdt . managedbuild . tool . gnu . c . linker . exe . debug . 1972290949 " name = " GCC C Linker " superClass = " cdt . managedbuild . tool . gnu . c . linker . exe . debug " > <nl> - < option defaultValue = " true " id = " gnu . c . link . option . shared . 1540950483 " name = " Shared ( - shared ) " superClass = " gnu . c . link . option . shared " valueType = " boolean " / > <nl> - < / tool > <nl> - < tool command = " g + + " commandLinePattern = " $ { COMMAND } $ { FLAGS } $ { OUTPUT_FLAG } $ { OUTPUT_PREFIX } $ { OUTPUT } $ { INPUTS } " errorParsers = " org . eclipse . cdt . core . GLDErrorParser " id = " cdt . managedbuild . tool . gnu . cpp . linker . exe . debug . 1067471813 " name = " GCC C + + Linker " superClass = " cdt . managedbuild . tool . gnu . cpp . linker . exe . debug " > <nl> - < option defaultValue = " true " id = " gnu . cpp . link . option . shared . 1341887029 " name = " Shared ( - shared ) " superClass = " gnu . cpp . link . option . shared " value = " true " valueType = " boolean " / > <nl> - < option id = " gnu . cpp . link . option . libs . 1702730055 " name = " Libraries ( - l ) " superClass = " gnu . cpp . link . option . libs " valueType = " libs " > <nl> - < listOptionValue builtIn = " false " value = " glfw " / > <nl> - < listOptionValue builtIn = " false " value = " fontconfig " / > <nl> - < listOptionValue builtIn = " false " value = " GLEW " / > <nl> - < / option > <nl> - < option id = " gnu . cpp . link . option . soname . 1183316897 " name = " Shared object name ( - Wl , - soname = ) " superClass = " gnu . cpp . link . option . soname " value = " " valueType = " string " / > <nl> - < option id = " gnu . cpp . link . option . userobjs . 927005091 " name = " Other objects " superClass = " gnu . cpp . link . option . userobjs " valueType = " userObjs " > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libraries / lib64 / libfreetype . a " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libraries / lib64 / libcurl . a " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libraries / lib64 / libtiff . a " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libraries / lib64 / libpng . a " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libraries / lib64 / libjpeg . a " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libraries / lib64 / libwebp . a " / > <nl> - < / option > <nl> - < option id = " gnu . cpp . link . option . paths . 2216001 " name = " Library search path ( - L ) " superClass = " gnu . cpp . link . option . paths " / > <nl> - < inputType id = " cdt . managedbuild . tool . gnu . cpp . linker . input . 1435212610 " superClass = " cdt . managedbuild . tool . gnu . cpp . linker . input " > <nl> - < additionalInput kind = " additionalinputdependency " paths = " $ ( USER_OBJS ) " / > <nl> - < additionalInput kind = " additionalinput " paths = " $ ( LIBS ) " / > <nl> - < / inputType > <nl> - < / tool > <nl> - < tool command = " as " commandLinePattern = " $ { COMMAND } $ { FLAGS } $ { OUTPUT_FLAG } $ { OUTPUT_PREFIX } $ { OUTPUT } $ { INPUTS } " errorParsers = " org . eclipse . cdt . core . GASErrorParser " id = " cdt . managedbuild . tool . gnu . assembler . exe . debug . 910953756 " name = " GCC Assembler " superClass = " cdt . managedbuild . tool . gnu . assembler . exe . debug " > <nl> - < inputType id = " cdt . managedbuild . tool . gnu . assembler . input . 1531018644 " superClass = " cdt . managedbuild . tool . gnu . assembler . input " / > <nl> - < / tool > <nl> - < / toolChain > <nl> - < / folderInfo > <nl> - < sourceEntries > <nl> - < entry excluding = " draw_nodes | shaders | kazmath | tilemap_parallax_nodes | actions | base_nodes | cocoa | effects | include | keypad_dispatcher | label_nodes | layers_scenes_transitions_nodes | menu_nodes | misc_nodes | particle_nodes | platform | script_support | sprite_nodes | support | text_input_node | textures | tileMap_parallax_nodes | touch_dispatcher " flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " actions " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " base_nodes " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " cocoa " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " draw_nodes " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " effects " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " include " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " kazmath " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " keypad_dispatcher " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " label_nodes " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " layers_scenes_transitions_nodes " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " menu_nodes " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " misc_nodes " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " particle_nodes " / > <nl> - < entry excluding = " android / | bada / | ios / | marmalade / | qnx / | third_party / | win32 / | wophone / " flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " platform " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " script_support " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " shaders " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " sprite_nodes " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " support " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " text_input_node " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " textures " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " tilemap_parallax_nodes " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " touch_dispatcher " / > <nl> - < / sourceEntries > <nl> - < / configuration > <nl> - < / storageModule > <nl> - < storageModule moduleId = " org . eclipse . cdt . core . externalSettings " / > <nl> - < storageModule moduleId = " org . eclipse . cdt . internal . ui . text . commentOwnerProjectMappings " / > <nl> - < storageModule moduleId = " org . eclipse . cdt . core . language . mapping " / > <nl> - < / cconfiguration > <nl> - < cconfiguration id = " cdt . managedbuild . config . gnu . exe . release . 1270689208 . 755655996 " > <nl> - < storageModule buildSystemId = " org . eclipse . cdt . managedbuilder . core . configurationDataProvider " id = " cdt . managedbuild . config . gnu . exe . release . 1270689208 . 755655996 " moduleId = " org . eclipse . cdt . core . settings " name = " Release64 " > <nl> - < externalSettings > <nl> - < externalSetting > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " includePath " name = " / libcocos2d " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " libraryPath " name = " / libcocos2d / Release64 " / > <nl> - < entry flags = " RESOLVED " kind = " libraryFile " name = " cocos2d " srcPrefixMapping = " " srcRootPath = " " / > <nl> - < / externalSetting > <nl> - < / externalSettings > <nl> - < extensions > <nl> - < extension id = " org . eclipse . cdt . core . ELF " point = " org . eclipse . cdt . core . BinaryParser " / > <nl> - < extension id = " org . eclipse . cdt . core . GmakeErrorParser " point = " org . eclipse . cdt . core . ErrorParser " / > <nl> - < extension id = " org . eclipse . cdt . core . CWDLocator " point = " org . eclipse . cdt . core . ErrorParser " / > <nl> - < extension id = " org . eclipse . cdt . core . GCCErrorParser " point = " org . eclipse . cdt . core . ErrorParser " / > <nl> - < extension id = " org . eclipse . cdt . core . GASErrorParser " point = " org . eclipse . cdt . core . ErrorParser " / > <nl> - < extension id = " org . eclipse . cdt . core . GLDErrorParser " point = " org . eclipse . cdt . core . ErrorParser " / > <nl> - < / extensions > <nl> - < / storageModule > <nl> - < storageModule moduleId = " cdtBuildSystem " version = " 4 . 0 . 0 " > <nl> - < configuration artifactExtension = " so " artifactName = " cocos2d " buildArtefactType = " org . eclipse . cdt . build . core . buildArtefactType . sharedLib " buildProperties = " org . eclipse . cdt . build . core . buildType = org . eclipse . cdt . build . core . buildType . release , org . eclipse . cdt . build . core . buildArtefactType = org . eclipse . cdt . build . core . buildArtefactType . sharedLib " cleanCommand = " rm - rf " description = " " errorParsers = " org . eclipse . cdt . core . GmakeErrorParser ; org . eclipse . cdt . core . CWDLocator ; org . eclipse . cdt . core . GCCErrorParser ; org . eclipse . cdt . core . GASErrorParser ; org . eclipse . cdt . core . GLDErrorParser " id = " cdt . managedbuild . config . gnu . exe . release . 1270689208 . 755655996 " name = " Release64 " parent = " cdt . managedbuild . config . gnu . exe . release " postannouncebuildStep = " " postbuildStep = " " preannouncebuildStep = " " prebuildStep = " " > <nl> - < folderInfo id = " cdt . managedbuild . config . gnu . exe . release . 1270689208 . 755655996 . " name = " / " resourcePath = " " > <nl> - < toolChain errorParsers = " " id = " cdt . managedbuild . toolchain . gnu . exe . release . 1514038466 " name = " Linux GCC " superClass = " cdt . managedbuild . toolchain . gnu . exe . release " > <nl> - < targetPlatform binaryParser = " org . eclipse . cdt . core . ELF " id = " cdt . managedbuild . target . gnu . platform . exe . release . 268543647 " name = " Debug Platform " superClass = " cdt . managedbuild . target . gnu . platform . exe . release " / > <nl> - < builder buildPath = " " errorParsers = " org . eclipse . cdt . core . GmakeErrorParser ; org . eclipse . cdt . core . CWDLocator " id = " cdt . managedbuild . target . gnu . builder . exe . release . 1467307465 " keepEnvironmentInBuildfile = " false " managedBuildOn = " true " name = " Gnu Make Builder " superClass = " cdt . managedbuild . target . gnu . builder . exe . release " / > <nl> - < tool commandLinePattern = " $ { COMMAND } $ { FLAGS } $ { OUTPUT_FLAG } $ { OUTPUT_PREFIX } $ { OUTPUT } $ { INPUTS } " id = " cdt . managedbuild . tool . gnu . archiver . base . 667402707 " name = " GCC Archiver " superClass = " cdt . managedbuild . tool . gnu . archiver . base " / > <nl> - < tool command = " g + + " commandLinePattern = " $ { COMMAND } $ { FLAGS } $ { OUTPUT_FLAG } $ { OUTPUT_PREFIX } $ { OUTPUT } $ { INPUTS } " errorParsers = " org . eclipse . cdt . core . GCCErrorParser " id = " cdt . managedbuild . tool . gnu . cpp . compiler . exe . release . 409581596 " name = " GCC C + + Compiler " superClass = " cdt . managedbuild . tool . gnu . cpp . compiler . exe . release " > <nl> - < option id = " gnu . cpp . compiler . exe . release . option . optimization . level . 537177307 " name = " Optimization Level " superClass = " gnu . cpp . compiler . exe . release . option . optimization . level " value = " gnu . cpp . compiler . optimization . level . most " valueType = " enumerated " / > <nl> - < option id = " gnu . cpp . compiler . exe . release . option . debugging . level . 859466544 " name = " Debug Level " superClass = " gnu . cpp . compiler . exe . release . option . debugging . level " value = " gnu . cpp . compiler . debugging . level . none " valueType = " enumerated " / > <nl> - < option id = " gnu . cpp . compiler . option . include . paths . 2007706028 " name = " Include paths ( - I ) " superClass = " gnu . cpp . compiler . option . include . paths " valueType = " includePath " > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / include " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / linux " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / kazmath / include " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libfreetype2 " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libpng " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libjpeg " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libtiff / include " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libwebp " / > <nl> - < / option > <nl> - < option id = " gnu . cpp . compiler . option . preprocessor . def . 120885829 " name = " Defined symbols ( - D ) " superClass = " gnu . cpp . compiler . option . preprocessor . def " valueType = " definedSymbols " > <nl> - < listOptionValue builtIn = " false " value = " LINUX " / > <nl> - < listOptionValue builtIn = " false " value = " CC_KEYBOARD_SUPPORT " / > <nl> - < / option > <nl> - < option id = " gnu . cpp . compiler . option . warnings . allwarn . 1763578720 " name = " All warnings ( - Wall ) " superClass = " gnu . cpp . compiler . option . warnings . allwarn " value = " true " valueType = " boolean " / > <nl> - < option id = " gnu . cpp . compiler . option . other . pic . 240673876 " name = " Position Independent Code ( - fPIC ) " superClass = " gnu . cpp . compiler . option . other . pic " value = " true " valueType = " boolean " / > <nl> - < option id = " gnu . cpp . compiler . option . other . other . 1435671044 " name = " Other flags " superClass = " gnu . cpp . compiler . option . other . other " value = " - c - fmessage - length = 0 - Wno - deprecated - declarations - std = gnu + + 0x " valueType = " string " / > <nl> - < inputType id = " cdt . managedbuild . tool . gnu . cpp . compiler . input . 854667177 " superClass = " cdt . managedbuild . tool . gnu . cpp . compiler . input " / > <nl> - < / tool > <nl> - < tool command = " gcc " commandLinePattern = " $ { COMMAND } $ { FLAGS } $ { OUTPUT_FLAG } $ { OUTPUT_PREFIX } $ { OUTPUT } $ { INPUTS } " errorParsers = " org . eclipse . cdt . core . GCCErrorParser " id = " cdt . managedbuild . tool . gnu . c . compiler . exe . release . 1189084590 " name = " GCC C Compiler " superClass = " cdt . managedbuild . tool . gnu . c . compiler . exe . release " > <nl> - < option defaultValue = " gnu . c . optimization . level . most " id = " gnu . c . compiler . exe . release . option . optimization . level . 1077023295 " name = " Optimization Level " superClass = " gnu . c . compiler . exe . release . option . optimization . level " value = " gnu . c . optimization . level . most " valueType = " enumerated " / > <nl> - < option id = " gnu . c . compiler . exe . release . option . debugging . level . 68955217 " name = " Debug Level " superClass = " gnu . c . compiler . exe . release . option . debugging . level " value = " gnu . c . debugging . level . none " valueType = " enumerated " / > <nl> - < option id = " gnu . c . compiler . option . include . paths . 68933948 " name = " Include paths ( - I ) " superClass = " gnu . c . compiler . option . include . paths " valueType = " includePath " > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / include " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / linux " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / kazmath / include " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libfreetype2 " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libpng " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libjpeg " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libtiff / include " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libwebp " / > <nl> - < / option > <nl> - < option id = " gnu . c . compiler . option . preprocessor . def . symbols . 1821931544 " name = " Defined symbols ( - D ) " superClass = " gnu . c . compiler . option . preprocessor . def . symbols " valueType = " definedSymbols " > <nl> - < listOptionValue builtIn = " false " value = " LINUX " / > <nl> - < listOptionValue builtIn = " false " value = " CC_KEYBOARD_SUPPORT " / > <nl> - < / option > <nl> - < option id = " gnu . c . compiler . option . warnings . allwarn . 320491147 " name = " All warnings ( - Wall ) " superClass = " gnu . c . compiler . option . warnings . allwarn " value = " false " valueType = " boolean " / > <nl> - < option id = " gnu . c . compiler . option . misc . pic . 349169503 " name = " Position Independent Code ( - fPIC ) " superClass = " gnu . c . compiler . option . misc . pic " value = " true " valueType = " boolean " / > <nl> - < option id = " gnu . c . compiler . option . misc . other . 1812062349 " name = " Other flags " superClass = " gnu . c . compiler . option . misc . other " value = " - c - fmessage - length = 0 - Wno - deprecated - declarations " valueType = " string " / > <nl> - < inputType id = " cdt . managedbuild . tool . gnu . c . compiler . input . 630327615 " superClass = " cdt . managedbuild . tool . gnu . c . compiler . input " / > <nl> - < / tool > <nl> - < tool commandLinePattern = " $ { COMMAND } $ { FLAGS } $ { OUTPUT_FLAG } $ { OUTPUT_PREFIX } $ { OUTPUT } $ { INPUTS } " id = " cdt . managedbuild . tool . gnu . c . linker . exe . release . 490273333 " name = " GCC C Linker " superClass = " cdt . managedbuild . tool . gnu . c . linker . exe . release " > <nl> - < option defaultValue = " true " id = " gnu . c . link . option . shared . 557672269 " name = " Shared ( - shared ) " superClass = " gnu . c . link . option . shared " valueType = " boolean " / > <nl> - < / tool > <nl> - < tool command = " g + + " commandLinePattern = " $ { COMMAND } $ { FLAGS } $ { OUTPUT_FLAG } $ { OUTPUT_PREFIX } $ { OUTPUT } $ { INPUTS } " errorParsers = " org . eclipse . cdt . core . GLDErrorParser " id = " cdt . managedbuild . tool . gnu . cpp . linker . exe . release . 833162416 " name = " GCC C + + Linker " superClass = " cdt . managedbuild . tool . gnu . cpp . linker . exe . release " > <nl> - < option defaultValue = " true " id = " gnu . cpp . link . option . shared . 1070095229 " name = " Shared ( - shared ) " superClass = " gnu . cpp . link . option . shared " value = " true " valueType = " boolean " / > <nl> - < option id = " gnu . cpp . link . option . libs . 514385176 " name = " Libraries ( - l ) " superClass = " gnu . cpp . link . option . libs " valueType = " libs " > <nl> - < listOptionValue builtIn = " false " value = " glfw " / > <nl> - < listOptionValue builtIn = " false " value = " fontconfig " / > <nl> - < listOptionValue builtIn = " false " value = " GLEW " / > <nl> - < / option > <nl> - < option id = " gnu . cpp . link . option . soname . 121494156 " name = " Shared object name ( - Wl , - soname = ) " superClass = " gnu . cpp . link . option . soname " value = " " valueType = " string " / > <nl> - < option id = " gnu . cpp . link . option . userobjs . 686006869 " name = " Other objects " superClass = " gnu . cpp . link . option . userobjs " valueType = " userObjs " > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libraries / lib64 / libfreetype . a " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libraries / lib64 / libcurl . a " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libraries / lib64 / libtiff . a " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libraries / lib64 / libpng . a " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libraries / lib64 / libjpeg . a " / > <nl> - < listOptionValue builtIn = " false " value = " . . / . . / . . / cocos2dx / platform / third_party / linux / libraries / lib64 / libwebp . a " / > <nl> - < / option > <nl> - < option id = " gnu . cpp . link . option . paths . 2133869956 " name = " Library search path ( - L ) " superClass = " gnu . cpp . link . option . paths " / > <nl> - < inputType id = " cdt . managedbuild . tool . gnu . cpp . linker . input . 350375429 " superClass = " cdt . managedbuild . tool . gnu . cpp . linker . input " > <nl> - < additionalInput kind = " additionalinputdependency " paths = " $ ( USER_OBJS ) " / > <nl> - < additionalInput kind = " additionalinput " paths = " $ ( LIBS ) " / > <nl> - < / inputType > <nl> - < / tool > <nl> - < tool command = " as " commandLinePattern = " $ { COMMAND } $ { FLAGS } $ { OUTPUT_FLAG } $ { OUTPUT_PREFIX } $ { OUTPUT } $ { INPUTS } " errorParsers = " org . eclipse . cdt . core . GASErrorParser " id = " cdt . managedbuild . tool . gnu . assembler . exe . release . 379086255 " name = " GCC Assembler " superClass = " cdt . managedbuild . tool . gnu . assembler . exe . release " > <nl> - < inputType id = " cdt . managedbuild . tool . gnu . assembler . input . 676939679 " superClass = " cdt . managedbuild . tool . gnu . assembler . input " / > <nl> - < / tool > <nl> - < / toolChain > <nl> - < / folderInfo > <nl> - < sourceEntries > <nl> - < entry excluding = " draw_nodes | shaders | kazmath | tilemap_parallax_nodes | actions | base_nodes | cocoa | effects | include | keypad_dispatcher | label_nodes | layers_scenes_transitions_nodes | menu_nodes | misc_nodes | particle_nodes | platform | script_support | sprite_nodes | support | text_input_node | textures | tileMap_parallax_nodes | touch_dispatcher " flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " actions " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " base_nodes " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " cocoa " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " draw_nodes " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " effects " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " include " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " kazmath " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " keypad_dispatcher " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " label_nodes " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " layers_scenes_transitions_nodes " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " menu_nodes " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " misc_nodes " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " particle_nodes " / > <nl> - < entry excluding = " android / | bada / | ios / | marmalade / | qnx / | third_party / | win32 / | wophone / " flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " platform " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " script_support " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " shaders " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " sprite_nodes " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " support " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " text_input_node " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " textures " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " tileMap_parallax_nodes " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " tilemap_parallax_nodes " / > <nl> - < entry flags = " VALUE_WORKSPACE_PATH " kind = " sourcePath " name = " touch_dispatcher " / > <nl> - < / sourceEntries > <nl> - < / configuration > <nl> - < / storageModule > <nl> - < storageModule moduleId = " org . eclipse . cdt . core . externalSettings " / > <nl> - < storageModule moduleId = " org . eclipse . cdt . internal . ui . text . commentOwnerProjectMappings " / > <nl> - < storageModule moduleId = " org . eclipse . cdt . core . language . mapping " / > <nl> - < / cconfiguration > <nl> - < / storageModule > <nl> - < storageModule moduleId = " cdtBuildSystem " version = " 4 . 0 . 0 " > <nl> - < project id = " libcocos2d . cdt . managedbuild . target . gnu . exe . 634598992 " name = " Executable " projectType = " cdt . managedbuild . target . gnu . exe " / > <nl> - < / storageModule > <nl> - < storageModule moduleId = " refreshScope " versionNumber = " 2 " > <nl> - < configuration configurationName = " Release " > <nl> - < resource resourceType = " PROJECT " workspacePath = " / libcocos2d " / > <nl> - < / configuration > <nl> - < configuration configurationName = " Debug64 " > <nl> - < resource resourceType = " PROJECT " workspacePath = " / libcocos2d " / > <nl> - < / configuration > <nl> - < configuration configurationName = " Release64 " > <nl> - < resource resourceType = " PROJECT " workspacePath = " / libcocos2d " / > <nl> - < / configuration > <nl> - < configuration configurationName = " Debug " > <nl> - < resource resourceType = " PROJECT " workspacePath = " / libcocos2d " / > <nl> - < / configuration > <nl> - < / storageModule > <nl> - < storageModule moduleId = " org . eclipse . cdt . internal . ui . text . commentOwnerProjectMappings " / > <nl> - < storageModule moduleId = " org . eclipse . cdt . make . core . buildtargets " > <nl> - < buildTargets / > <nl> - < / storageModule > <nl> - < storageModule moduleId = " org . eclipse . cdt . core . LanguageSettingsProviders " / > <nl> - < storageModule moduleId = " scannerConfiguration " > <nl> - < autodiscovery enabled = " true " problemReportingEnabled = " true " selectedProfileId = " " / > <nl> - < scannerConfigBuildInfo instanceId = " cdt . managedbuild . config . gnu . exe . debug . 502995704 ; cdt . managedbuild . config . gnu . exe . debug . 502995704 . ; cdt . managedbuild . tool . gnu . cpp . compiler . exe . debug . 2063289710 ; cdt . managedbuild . tool . gnu . cpp . compiler . input . 966305124 " > <nl> - < autodiscovery enabled = " true " problemReportingEnabled = " true " selectedProfileId = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileCPP " / > <nl> - < / scannerConfigBuildInfo > <nl> - < scannerConfigBuildInfo instanceId = " cdt . managedbuild . config . gnu . exe . debug . 502995704 . 1534655526 ; cdt . managedbuild . config . gnu . exe . debug . 502995704 . 1534655526 . ; cdt . managedbuild . tool . gnu . cpp . compiler . exe . debug . 1024625311 ; cdt . managedbuild . tool . gnu . cpp . compiler . input . 1920645677 " > <nl> - < autodiscovery enabled = " true " problemReportingEnabled = " true " selectedProfileId = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileCPP " / > <nl> - < / scannerConfigBuildInfo > <nl> - < scannerConfigBuildInfo instanceId = " cdt . managedbuild . config . gnu . exe . release . 1270689208 . 232480047 ; cdt . managedbuild . config . gnu . exe . release . 1270689208 . 232480047 . ; cdt . managedbuild . tool . gnu . cpp . compiler . exe . release . 1742516529 ; cdt . managedbuild . tool . gnu . cpp . compiler . input . 1036435822 " > <nl> - < autodiscovery enabled = " true " problemReportingEnabled = " true " selectedProfileId = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileCPP " / > <nl> - < / scannerConfigBuildInfo > <nl> - < scannerConfigBuildInfo instanceId = " cdt . managedbuild . config . gnu . exe . release . 1270689208 . 755655996 ; cdt . managedbuild . config . gnu . exe . release . 1270689208 . 755655996 . ; cdt . managedbuild . tool . gnu . c . compiler . exe . release . 1189084590 ; cdt . managedbuild . tool . gnu . c . compiler . input . 630327615 " > <nl> - < autodiscovery enabled = " true " problemReportingEnabled = " true " selectedProfileId = " " / > <nl> - < / scannerConfigBuildInfo > <nl> - < scannerConfigBuildInfo instanceId = " cdt . managedbuild . config . gnu . exe . debug . 502995704 . 1339240180 ; cdt . managedbuild . config . gnu . exe . debug . 502995704 . 1339240180 . ; cdt . managedbuild . tool . gnu . cpp . compiler . exe . debug . 1527575500 ; cdt . managedbuild . tool . gnu . cpp . compiler . input . 386716465 " > <nl> - < autodiscovery enabled = " true " problemReportingEnabled = " true " selectedProfileId = " " / > <nl> - < / scannerConfigBuildInfo > <nl> - < scannerConfigBuildInfo instanceId = " cdt . managedbuild . config . gnu . exe . release . 1270689208 . 232480047 ; cdt . managedbuild . config . gnu . exe . release . 1270689208 . 232480047 . ; cdt . managedbuild . tool . gnu . c . compiler . exe . release . 518312421 ; cdt . managedbuild . tool . gnu . c . compiler . input . 1602098267 " > <nl> - < autodiscovery enabled = " true " problemReportingEnabled = " true " selectedProfileId = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileC " / > <nl> - < / scannerConfigBuildInfo > <nl> - < scannerConfigBuildInfo instanceId = " cdt . managedbuild . config . gnu . exe . debug . 502995704 . 1339240180 ; cdt . managedbuild . config . gnu . exe . debug . 502995704 . 1339240180 . ; cdt . managedbuild . tool . gnu . c . compiler . exe . debug . 320530417 ; cdt . managedbuild . tool . gnu . c . compiler . input . 1931033313 " > <nl> - < autodiscovery enabled = " true " problemReportingEnabled = " true " selectedProfileId = " " / > <nl> - < / scannerConfigBuildInfo > <nl> - < scannerConfigBuildInfo instanceId = " cdt . managedbuild . config . gnu . exe . release . 1270689208 . 755655996 ; cdt . managedbuild . config . gnu . exe . release . 1270689208 . 755655996 . ; cdt . managedbuild . tool . gnu . cpp . compiler . exe . release . 409581596 ; cdt . managedbuild . tool . gnu . cpp . compiler . input . 854667177 " > <nl> - < autodiscovery enabled = " true " problemReportingEnabled = " true " selectedProfileId = " " / > <nl> - < / scannerConfigBuildInfo > <nl> - < scannerConfigBuildInfo instanceId = " cdt . managedbuild . config . gnu . exe . debug . 502995704 . 1534655526 ; cdt . managedbuild . config . gnu . exe . debug . 502995704 . 1534655526 . ; cdt . managedbuild . tool . gnu . c . compiler . exe . debug . 870071077 ; cdt . managedbuild . tool . gnu . c . compiler . input . 132105612 " > <nl> - < autodiscovery enabled = " true " problemReportingEnabled = " true " selectedProfileId = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileC " / > <nl> - < / scannerConfigBuildInfo > <nl> - < scannerConfigBuildInfo instanceId = " cdt . managedbuild . config . gnu . exe . debug . 502995704 ; cdt . managedbuild . config . gnu . exe . debug . 502995704 . ; cdt . managedbuild . tool . gnu . c . compiler . exe . debug . 452615323 ; cdt . managedbuild . tool . gnu . c . compiler . input . 697502414 " > <nl> - < autodiscovery enabled = " true " problemReportingEnabled = " true " selectedProfileId = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileC " / > <nl> - < / scannerConfigBuildInfo > <nl> - < scannerConfigBuildInfo instanceId = " cdt . managedbuild . config . gnu . exe . release . 1270689208 ; cdt . managedbuild . config . gnu . exe . release . 1270689208 . ; cdt . managedbuild . tool . gnu . cpp . compiler . exe . release . 1336291657 ; cdt . managedbuild . tool . gnu . cpp . compiler . input . 1506297979 " > <nl> - < autodiscovery enabled = " true " problemReportingEnabled = " true " selectedProfileId = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileCPP " / > <nl> - < / scannerConfigBuildInfo > <nl> - < scannerConfigBuildInfo instanceId = " cdt . managedbuild . config . gnu . exe . release . 1270689208 ; cdt . managedbuild . config . gnu . exe . release . 1270689208 . ; cdt . managedbuild . tool . gnu . c . compiler . exe . release . 984270671 ; cdt . managedbuild . tool . gnu . c . compiler . input . 191330176 " > <nl> - < autodiscovery enabled = " true " problemReportingEnabled = " true " selectedProfileId = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileC " / > <nl> - < / scannerConfigBuildInfo > <nl> - < / storageModule > <nl> - < / cproject > <nl> deleted file mode 100755 <nl> index 8811b56dd0ed . . 000000000000 <nl> mmm a / cocos / 2d / proj . linux / . project <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " UTF - 8 " ? > <nl> - < projectDescription > <nl> - < name > libcocos2d < / name > <nl> - < comment > < / comment > <nl> - < projects > <nl> - < / projects > <nl> - < buildSpec > <nl> - < buildCommand > <nl> - < name > org . eclipse . cdt . managedbuilder . core . genmakebuilder < / name > <nl> - < triggers > clean , full , incremental , < / triggers > <nl> - < arguments > <nl> - < dictionary > <nl> - < key > ? name ? < / key > <nl> - < value > < / value > <nl> - < / dictionary > <nl> - < dictionary > <nl> - < key > org . eclipse . cdt . make . core . append_environment < / key > <nl> - < value > true < / value > <nl> - < / dictionary > <nl> - < dictionary > <nl> - < key > org . eclipse . cdt . make . core . autoBuildTarget < / key > <nl> - < value > all < / value > <nl> - < / dictionary > <nl> - < dictionary > <nl> - < key > org . eclipse . cdt . make . core . buildArguments < / key > <nl> - < value > < / value > <nl> - < / dictionary > <nl> - < dictionary > <nl> - < key > org . eclipse . cdt . make . core . buildCommand < / key > <nl> - < value > make < / value > <nl> - < / dictionary > <nl> - < dictionary > <nl> - < key > org . eclipse . cdt . make . core . buildLocation < / key > <nl> - < value > $ { workspace_loc : / cocos2dx - base / Debug } < / value > <nl> - < / dictionary > <nl> - < dictionary > <nl> - < key > org . eclipse . cdt . make . core . cleanBuildTarget < / key > <nl> - < value > clean < / value > <nl> - < / dictionary > <nl> - < dictionary > <nl> - < key > org . eclipse . cdt . make . core . contents < / key > <nl> - < value > org . eclipse . cdt . make . core . activeConfigSettings < / value > <nl> - < / dictionary > <nl> - < dictionary > <nl> - < key > org . eclipse . cdt . make . core . enableAutoBuild < / key > <nl> - < value > false < / value > <nl> - < / dictionary > <nl> - < dictionary > <nl> - < key > org . eclipse . cdt . make . core . enableCleanBuild < / key > <nl> - < value > true < / value > <nl> - < / dictionary > <nl> - < dictionary > <nl> - < key > org . eclipse . cdt . make . core . enableFullBuild < / key > <nl> - < value > true < / value > <nl> - < / dictionary > <nl> - < dictionary > <nl> - < key > org . eclipse . cdt . make . core . fullBuildTarget < / key > <nl> - < value > all < / value > <nl> - < / dictionary > <nl> - < dictionary > <nl> - < key > org . eclipse . cdt . make . core . stopOnError < / key > <nl> - < value > true < / value > <nl> - < / dictionary > <nl> - < dictionary > <nl> - < key > org . eclipse . cdt . make . core . useDefaultBuildCmd < / key > <nl> - < value > true < / value > <nl> - < / dictionary > <nl> - < / arguments > <nl> - < / buildCommand > <nl> - < buildCommand > <nl> - < name > org . eclipse . cdt . managedbuilder . core . ScannerConfigBuilder < / name > <nl> - < triggers > full , incremental , < / triggers > <nl> - < arguments > <nl> - < / arguments > <nl> - < / buildCommand > <nl> - < / buildSpec > <nl> - < natures > <nl> - < nature > org . eclipse . cdt . core . cnature < / nature > <nl> - < nature > org . eclipse . cdt . core . ccnature < / nature > <nl> - < nature > org . eclipse . cdt . managedbuilder . core . managedBuildNature < / nature > <nl> - < nature > org . eclipse . cdt . managedbuilder . core . ScannerConfigNature < / nature > <nl> - < / natures > <nl> - < linkedResources > <nl> - < link > <nl> - < name > CCCamera . cpp < / name > <nl> - < type > 1 < / type > <nl> - < locationURI > PARENT - 1 - PROJECT_LOC / CCCamera . cpp < / locationURI > <nl> - < / link > <nl> - < link > <nl> - < name > CCConfiguration . cpp < / name > <nl> - < type > 1 < / type > <nl> - < locationURI > PARENT - 1 - PROJECT_LOC / CCConfiguration . cpp < / locationURI > <nl> - < / link > <nl> - < link > <nl> - < name > CCConfiguration . h < / name > <nl> - < type > 1 < / type > <nl> - < locationURI > PARENT - 1 - PROJECT_LOC / CCConfiguration . h < / locationURI > <nl> - < / link > <nl> - < link > <nl> - < name > ccFPSImages . c < / name > <nl> - < type > 1 < / type > <nl> - < locationURI > PARENT - 1 - PROJECT_LOC / ccFPSImages . c < / locationURI > <nl> - < / link > <nl> - < link > <nl> - < name > ccFPSImages . h < / name > <nl> - < type > 1 < / type > <nl> - < locationURI > PARENT - 1 - PROJECT_LOC / ccFPSImages . h < / locationURI > <nl> - < / link > <nl> - < link > <nl> - < name > ccTypes . cpp < / name > <nl> - < type > 1 < / type > <nl> - < locationURI > PARENT - 1 - PROJECT_LOC / ccTypes . cpp < / locationURI > <nl> - < / link > <nl> - < link > <nl> - < name > CCDirector . cpp < / name > <nl> - < type > 1 < / type > <nl> - < locationURI > PARENT - 1 - PROJECT_LOC / CCDirector . cpp < / locationURI > <nl> - < / link > <nl> - < link > <nl> - < name > CCScheduler . cpp < / name > <nl> - < type > 1 < / type > <nl> - < locationURI > PARENT - 1 - PROJECT_LOC / CCScheduler . cpp < / locationURI > <nl> - < / link > <nl> - < link > <nl> - < name > actions < / name > <nl> - < type > 2 < / type > <nl> - < locationURI > PARENT - 1 - PROJECT_LOC / actions < / locationURI > <nl> - < / link > <nl> - < link > <nl> - < name > base_nodes < / name > <nl> - < type > 2 < / type > <nl> - < locationURI > PARENT - 1 - PROJECT_LOC / base_nodes < / locationURI > <nl> - < / link > <nl> - < link > <nl> - < name > cocoa < / name > <nl> - < type > 2 < / type > <nl> - < locationURI > PARENT - 1 - PROJECT_LOC / cocoa < / locationURI > <nl> - < / link > <nl> - < link > <nl> - < name > cocos2d . cpp < / name > <nl> - < type > 1 < / type > <nl> - < locationURI > PARENT - 1 - PROJECT_LOC / cocos2d . cpp < / locationURI > <nl> - < / link > <nl> - < link > <nl> - < name > draw_nodes < / name > <nl> - < type > 2 < / type > <nl> - < locationURI > PARENT - 1 - PROJECT_LOC / draw_nodes < / locationURI > <nl> - < / link > <nl> - < link > <nl> - < name > effects < / name > <nl> - < type > 2 < / type > <nl> - < locationURI > PARENT - 1 - PROJECT_LOC / effects < / locationURI > <nl> - < / link > <nl> - < link > <nl> - < name > include < / name > <nl> - < type > 2 < / type > <nl> - < locationURI > PARENT - 1 - PROJECT_LOC / include < / locationURI > <nl> - < / link > <nl> - < link > <nl> - < name > kazmath < / name > <nl> - < type > 2 < / type > <nl> - < locationURI > PARENT - 1 - PROJECT_LOC / kazmath < / locationURI > <nl> - < / link > <nl> - < link > <nl> - < name > keypad_dispatcher < / name > <nl> - < type > 2 < / type > <nl> - < locationURI > PARENT - 1 - PROJECT_LOC / keypad_dispatcher < / locationURI > <nl> - < / link > <nl> - < link > <nl> - < name > keyboard_dispatcher < / name > <nl> - < type > 2 < / type > <nl> - < locationURI > PARENT - 1 - PROJECT_LOC / keyboard_dispatcher < / locationURI > <nl> - < / link > <nl> - < link > <nl> - < name > label_nodes < / name > <nl> - < type > 2 < / type > <nl> - < locationURI > PARENT - 1 - PROJECT_LOC / label_nodes < / locationURI > <nl> - < / link > <nl> - < link > <nl> - < name > layers_scenes_transitions_nodes < / name > <nl> - < type > 2 < / type > <nl> - < locationURI > PARENT - 1 - PROJECT_LOC / layers_scenes_transitions_nodes < / locationURI > <nl> - < / link > <nl> - < link > <nl> - < name > menu_nodes < / name > <nl> - < type > 2 < / type > <nl> - < locationURI > PARENT - 1 - PROJECT_LOC / menu_nodes < / locationURI > <nl> - < / link > <nl> - < link > <nl> - < name > misc_nodes < / name > <nl> - < type > 2 < / type > <nl> - < locationURI > PARENT - 1 - PROJECT_LOC / misc_nodes < / locationURI > <nl> - < / link > <nl> - < link > <nl> - < name > particle_nodes < / name > <nl> - < type > 2 < / type > <nl> - < locationURI > PARENT - 1 - PROJECT_LOC / particle_nodes < / locationURI > <nl> - < / link > <nl> - < link > <nl> - < name > platform < / name > <nl> - < type > 2 < / type > <nl> - < locationURI > PARENT - 1 - PROJECT_LOC / platform < / locationURI > <nl> - < / link > <nl> - < link > <nl> - < name > script_support < / name > <nl> - < type > 2 < / type > <nl> - < locationURI > PARENT - 1 - PROJECT_LOC / script_support < / locationURI > <nl> - < / link > <nl> - < link > <nl> - < name > shaders < / name > <nl> - < type > 2 < / type > <nl> - < locationURI > PARENT - 1 - PROJECT_LOC / shaders < / locationURI > <nl> - < / link > <nl> - < link > <nl> - < name > sprite_nodes < / name > <nl> - < type > 2 < / type > <nl> - < locationURI > PARENT - 1 - PROJECT_LOC / sprite_nodes < / locationURI > <nl> - < / link > <nl> - < link > <nl> - < name > support < / name > <nl> - < type > 2 < / type > <nl> - < locationURI > PARENT - 1 - PROJECT_LOC / support < / locationURI > <nl> - < / link > <nl> - < link > <nl> - < name > text_input_node < / name > <nl> - < type > 2 < / type > <nl> - < locationURI > PARENT - 1 - PROJECT_LOC / text_input_node < / locationURI > <nl> - < / link > <nl> - < link > <nl> - < name > textures < / name > <nl> - < type > 2 < / type > <nl> - < locationURI > PARENT - 1 - PROJECT_LOC / textures < / locationURI > <nl> - < / link > <nl> - < link > <nl> - < name > tilemap_parallax_nodes < / name > <nl> - < type > 2 < / type > <nl> - < locationURI > PARENT - 1 - PROJECT_LOC / tilemap_parallax_nodes < / locationURI > <nl> - < / link > <nl> - < link > <nl> - < name > touch_dispatcher < / name > <nl> - < type > 2 < / type > <nl> - < locationURI > PARENT - 1 - PROJECT_LOC / touch_dispatcher < / locationURI > <nl> - < / link > <nl> - < / linkedResources > <nl> - < filteredResources > <nl> - < filter > <nl> - < id > 1360135975775 < / id > <nl> - < name > platform < / name > <nl> - < type > 9 < / type > <nl> - < matcher > <nl> - < id > org . eclipse . ui . ide . multiFilter < / id > <nl> - < arguments > 1 . 0 - name - matches - true - false - linux < / arguments > <nl> - < / matcher > <nl> - < / filter > <nl> - < / filteredResources > <nl> - < / projectDescription > <nl> deleted file mode 100644 <nl> index 1122180b535a . . 000000000000 <nl> mmm a / cocos / 2d / proj . linux / cocos2dx . prf <nl> ppp / dev / null <nl> <nl> - # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> - # Do not include this file in your project : see cocos2dx . pri . <nl> - # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> - <nl> - linux { <nl> - # Use OpenAL in default QtCreator project . <nl> - isEmpty ( COCOS2D_USE_FMOD ) : COCOS2D_USE_FMOD = 0 <nl> - <nl> - # Variables used when building libraries . <nl> - CC_LIBRARY_DIR = $ $ PWD / . . / . . / lib / linux / release <nl> - CC_MAKE_FLAGS = - s <nl> - CONFIG ( debug , debug | release ) { <nl> - # Override in debug build . <nl> - CC_MAKE_FLAGS + = DEBUG = 1 <nl> - CC_LIBRARY_DIR = $ $ PWD / . . / . . / lib / linux / debug <nl> - } <nl> - contains ( COCOS2D_MODULES , box2d ) { <nl> - CC_MAKE_FLAGS + = USE_BOX2D = 1 <nl> - } <nl> - ! equals ( COCOS2D_USE_FMOD , 1 ) { <nl> - CC_MAKE_FLAGS + = OPENAL = 1 <nl> - } <nl> - <nl> - # We will compile cocos2d shared library on demand using Makefile . <nl> - build_cocos2d . name = Build cocos2d shared library <nl> - build_cocos2d . input = $ $ PWD / Makefile <nl> - build_cocos2d . output = $ $ CC_LIBRARY_DIR / libcocos2d . so <nl> - build_cocos2d . target = $ $ CC_LIBRARY_DIR / libcocos2d . so <nl> - build_cocos2d . CONFIG = no_link target_predeps <nl> - build_cocos2d . commands = cd $ $ PWD & & make $ $ CC_MAKE_FLAGS $ { QMAKE_FILE_IN } <nl> - <nl> - QMAKE_EXTRA_COMPILERS + = build_cocos2d <nl> - QMAKE_EXTRA_TARGETS + = build_cocos2d <nl> - <nl> - PRE_TARGETDEPS + = $ $ CC_LIBRARY_DIR / libcocos2d . so <nl> - LIBS + = - L $ $ CC_LIBRARY_DIR - lcocos2d - Wl , - rpath , \ ' $ $ CC_LIBRARY_DIR \ ' <nl> - } <nl> deleted file mode 100644 <nl> index 84bbb6d98705 . . 000000000000 <nl> mmm a / cocos / 2d / proj . linux / cocos2dx . pri <nl> ppp / dev / null <nl> <nl> - <nl> - # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> - # <nl> - # If you want enable extra modules , set COCOS2D_MODULES variable before include <nl> - # this file , example : <nl> - # COCOS2D_MODULES + = CocosDenshion <nl> - # COCOS2D_MODULES + = extensions <nl> - # COCOS2D_MODULES + = box2d <nl> - # or <nl> - # COCOS2D_MODULES + = chipmunk <nl> - # note : you cannot include both box2d and chipmunk . <nl> - # <nl> - # By default , QtCreator project will use OpenAL audio backend ( because FMOD is <nl> - # free only for non - commercial use ) . If you are legal FMOD user , set variable <nl> - # COCOS2D_USE_FMOD to use FMOD audio backend : <nl> - # COCOS2D_USE_FMOD = 1 <nl> - # <nl> - # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> - <nl> - INCLUDEPATH + = $ $ PWD / . . / <nl> - INCLUDEPATH + = $ $ PWD / . . / cocoa / <nl> - INCLUDEPATH + = $ $ PWD / . . / include / <nl> - INCLUDEPATH + = $ $ PWD / . . / platform / <nl> - INCLUDEPATH + = $ $ PWD / . . / kazmath / include <nl> - <nl> - * - msvc * { <nl> - # Use equivalents of - Wno - overloaded - virtual - Wno - unused - parameter . <nl> - QMAKE_CXXFLAGS_WARN_ON + = / wd4263 / wd4100 <nl> - } else { <nl> - QMAKE_CXXFLAGS_WARN_ON + = - Wno - ignored - qualifiers - Wno - overloaded - virtual - Wno - unused - parameter - Wno - unused - function <nl> - QMAKE_CXXFLAGS + = - std = c + + 0x <nl> - } <nl> - <nl> - include ( $ $ PWD / cocos2dx . prf ) <nl> - <nl> - linux { <nl> - DEFINES + = LINUX <nl> - INCLUDEPATH + = $ $ PWD / . . / platform / linux <nl> - LIBS + = - lpthread <nl> - } <nl> - <nl> - contains ( COCOS2D_MODULES , CocosDenshion ) { <nl> - INCLUDEPATH + = $ $ PWD / . . / . . / CocosDenshion / include <nl> - include ( $ $ PWD / . . / . . / CocosDenshion / proj . linux / CocosDenshion . prf ) <nl> - } <nl> - <nl> - contains ( COCOS2D_MODULES , extensions ) { <nl> - INCLUDEPATH + = $ $ PWD / . . / . . / extensions <nl> - LIBS + = - lcurl <nl> - include ( $ $ PWD / . . / . . / extensions / proj . linux / extensions . prf ) <nl> - } <nl> - <nl> - contains ( COCOS2D_MODULES , box2d ) { <nl> - INCLUDEPATH + = $ $ PWD / . . / . . / external <nl> - include ( $ $ PWD / . . / . . / external / Box2D / proj . linux / box2d . prf ) <nl> - } <nl> - <nl> - contains ( COCOS2D_MODULES , chipmunk ) { <nl> - contains ( COCOS2D_MODULES , box2d ) : error ( " COCOS2D_MODULES cannot contain both box2d and chipmunk : choose one and remove another . " ) <nl> - <nl> - INCLUDEPATH + = $ $ PWD / . . / . . / external / chipmunk / include / chipmunk <nl> - include ( $ $ PWD / . . / . . / external / chipmunk / proj . linux / chipmunk . prf ) <nl> - } <nl> - <nl> - CONFIG ( debug , debug | release ) { <nl> - DEFINES + = COCOS2D_DEBUG = 1 <nl> - } <nl> - else { <nl> - DEFINES + = COCOS2D_DEBUG = 0 <nl> - } <nl> deleted file mode 100644 <nl> index d78324565ba0 . . 000000000000 <nl> mmm a / cocos / 2d / support / ccUtils . cpp <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2010 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - # include " ccUtils . h " <nl> - <nl> - namespace cocos2d { <nl> - <nl> - unsigned long ccNextPOT ( unsigned long x ) <nl> - { <nl> - x = x - 1 ; <nl> - x = x | ( x > > 1 ) ; <nl> - x = x | ( x > > 2 ) ; <nl> - x = x | ( x > > 4 ) ; <nl> - x = x | ( x > > 8 ) ; <nl> - x = x | ( x > > 16 ) ; <nl> - return x + 1 ; <nl> - } <nl> - <nl> - } <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index f181b9050c0f . . 000000000000 <nl> mmm a / cocos / 2d / support / tinyxml2 / tinyxml2 . cpp <nl> ppp / dev / null <nl> <nl> - / * <nl> - Original code by Lee Thomason ( www . grinninglizard . com ) <nl> - <nl> - This software is provided ' as - is ' , without any express or implied <nl> - warranty . In no event will the authors be held liable for any <nl> - damages arising from the use of this software . <nl> - <nl> - Permission is granted to anyone to use this software for any <nl> - purpose , including commercial applications , and to alter it and <nl> - redistribute it freely , subject to the following restrictions : <nl> - <nl> - 1 . The origin of this software must not be misrepresented ; you must <nl> - not claim that you wrote the original software . If you use this <nl> - software in a product , an acknowledgment in the product documentation <nl> - would be appreciated but is not required . <nl> - <nl> - 2 . Altered source versions must be plainly marked as such , and <nl> - must not be misrepresented as being the original software . <nl> - <nl> - 3 . This notice may not be removed or altered from any source <nl> - distribution . <nl> - * / <nl> - <nl> - # include " tinyxml2 . h " <nl> - <nl> - # include < new > / / yes , this one new style header , is in the Android SDK . <nl> - # if defined ( ANDROID_NDK ) | | ( CC_TARGET_PLATFORM = = CC_PLATFORM_BLACKBERRY ) <nl> - # include < stddef . h > <nl> - # else <nl> - # include < cstddef > <nl> - # endif <nl> - <nl> - static const char LINE_FEED = ( char ) 0x0a ; / / all line endings are normalized to LF <nl> - static const char LF = LINE_FEED ; <nl> - static const char CARRIAGE_RETURN = ( char ) 0x0d ; / / CR gets filtered out <nl> - static const char CR = CARRIAGE_RETURN ; <nl> - static const char SINGLE_QUOTE = ' \ ' ' ; <nl> - static const char DOUBLE_QUOTE = ' \ " ' ; <nl> - <nl> - / / Bunch of unicode info at : <nl> - / / http : / / www . unicode . org / faq / utf_bom . html <nl> - / / ef bb bf ( Microsoft " lead bytes " ) - designates UTF - 8 <nl> - <nl> - static const unsigned char TIXML_UTF_LEAD_0 = 0xefU ; <nl> - static const unsigned char TIXML_UTF_LEAD_1 = 0xbbU ; <nl> - static const unsigned char TIXML_UTF_LEAD_2 = 0xbfU ; <nl> - <nl> - <nl> - # define DELETE_NODE ( node ) { \ <nl> - if ( node ) { \ <nl> - MemPool * pool = node - > _memPool ; \ <nl> - node - > ~ XMLNode ( ) ; \ <nl> - pool - > Free ( node ) ; \ <nl> - } \ <nl> - } <nl> - # define DELETE_ATTRIBUTE ( attrib ) { \ <nl> - if ( attrib ) { \ <nl> - MemPool * pool = attrib - > _memPool ; \ <nl> - attrib - > ~ XMLAttribute ( ) ; \ <nl> - pool - > Free ( attrib ) ; \ <nl> - } \ <nl> - } <nl> - <nl> - namespace tinyxml2 <nl> - { <nl> - <nl> - struct Entity { <nl> - const char * pattern ; <nl> - int length ; <nl> - char value ; <nl> - } ; <nl> - <nl> - static const int NUM_ENTITIES = 5 ; <nl> - static const Entity entities [ NUM_ENTITIES ] = { <nl> - { " quot " , 4 , DOUBLE_QUOTE } , <nl> - { " amp " , 3 , ' & ' } , <nl> - { " apos " , 4 , SINGLE_QUOTE } , <nl> - { " lt " , 2 , ' < ' } , <nl> - { " gt " , 2 , ' > ' } <nl> - } ; <nl> - <nl> - <nl> - StrPair : : ~ StrPair ( ) <nl> - { <nl> - Reset ( ) ; <nl> - } <nl> - <nl> - <nl> - void StrPair : : Reset ( ) <nl> - { <nl> - if ( _flags & NEEDS_DELETE ) { <nl> - delete [ ] _start ; <nl> - } <nl> - _flags = 0 ; <nl> - _start = 0 ; <nl> - _end = 0 ; <nl> - } <nl> - <nl> - <nl> - void StrPair : : SetStr ( const char * str , int flags ) <nl> - { <nl> - Reset ( ) ; <nl> - size_t len = strlen ( str ) ; <nl> - _start = new char [ len + 1 ] ; <nl> - memcpy ( _start , str , len + 1 ) ; <nl> - _end = _start + len ; <nl> - _flags = flags | NEEDS_DELETE ; <nl> - } <nl> - <nl> - <nl> - char * StrPair : : ParseText ( char * p , const char * endTag , int strFlags ) <nl> - { <nl> - TIXMLASSERT ( endTag & & * endTag ) ; <nl> - <nl> - char * start = p ; / / fixme : hides a member <nl> - char endChar = * endTag ; <nl> - size_t length = strlen ( endTag ) ; <nl> - <nl> - / / Inner loop of text parsing . <nl> - while ( * p ) { <nl> - if ( * p = = endChar & & strncmp ( p , endTag , length ) = = 0 ) { <nl> - Set ( start , p , strFlags ) ; <nl> - return p + length ; <nl> - } <nl> - + + p ; <nl> - } <nl> - return 0 ; <nl> - } <nl> - <nl> - <nl> - char * StrPair : : ParseName ( char * p ) <nl> - { <nl> - char * start = p ; <nl> - <nl> - if ( ! start | | ! ( * start ) ) { <nl> - return 0 ; <nl> - } <nl> - <nl> - while ( * p & & ( <nl> - XMLUtil : : IsAlphaNum ( ( unsigned char ) * p ) <nl> - | | * p = = ' _ ' <nl> - | | * p = = ' : ' <nl> - | | ( * p = = ' - ' & & p > start ) / / can be in a name , but not lead it . <nl> - | | ( * p = = ' . ' & & p > start ) ) ) { / / can be in a name , but not lead it . <nl> - + + p ; <nl> - } <nl> - <nl> - if ( p > start ) { <nl> - Set ( start , p , 0 ) ; <nl> - return p ; <nl> - } <nl> - return 0 ; <nl> - } <nl> - <nl> - <nl> - void StrPair : : CollapseWhitespace ( ) <nl> - { <nl> - / / Trim leading space . <nl> - _start = XMLUtil : : SkipWhiteSpace ( _start ) ; <nl> - <nl> - if ( _start & & * _start ) { <nl> - char * p = _start ; / / the read pointer <nl> - char * q = _start ; / / the write pointer <nl> - <nl> - while ( * p ) { <nl> - if ( XMLUtil : : IsWhiteSpace ( * p ) ) { <nl> - p = XMLUtil : : SkipWhiteSpace ( p ) ; <nl> - if ( * p = = 0 ) { <nl> - break ; / / don ' t write to q ; this trims the trailing space . <nl> - } <nl> - * q = ' ' ; <nl> - + + q ; <nl> - } <nl> - * q = * p ; <nl> - + + q ; <nl> - + + p ; <nl> - } <nl> - * q = 0 ; <nl> - } <nl> - } <nl> - <nl> - <nl> - const char * StrPair : : GetStr ( ) <nl> - { <nl> - if ( _flags & NEEDS_FLUSH ) { <nl> - * _end = 0 ; <nl> - _flags ^ = NEEDS_FLUSH ; <nl> - <nl> - if ( _flags ) { <nl> - char * p = _start ; / / the read pointer <nl> - char * q = _start ; / / the write pointer <nl> - <nl> - while ( p < _end ) { <nl> - if ( ( _flags & NEEDS_NEWLINE_NORMALIZATION ) & & * p = = CR ) { <nl> - / / CR - LF pair becomes LF <nl> - / / CR alone becomes LF <nl> - / / LF - CR becomes LF <nl> - if ( * ( p + 1 ) = = LF ) { <nl> - p + = 2 ; <nl> - } <nl> - else { <nl> - + + p ; <nl> - } <nl> - * q + + = LF ; <nl> - } <nl> - else if ( ( _flags & NEEDS_NEWLINE_NORMALIZATION ) & & * p = = LF ) { <nl> - if ( * ( p + 1 ) = = CR ) { <nl> - p + = 2 ; <nl> - } <nl> - else { <nl> - + + p ; <nl> - } <nl> - * q + + = LF ; <nl> - } <nl> - else if ( ( _flags & NEEDS_ENTITY_PROCESSING ) & & * p = = ' & ' ) { <nl> - / / Entities handled by tinyXML2 : <nl> - / / - special entities in the entity table [ in / out ] <nl> - / / - numeric character reference [ in ] <nl> - / / & # 20013 ; or & # x4e2d ; <nl> - <nl> - if ( * ( p + 1 ) = = ' # ' ) { <nl> - char buf [ 10 ] = { 0 } ; <nl> - int len ; <nl> - p = const_cast < char * > ( XMLUtil : : GetCharacterRef ( p , buf , & len ) ) ; <nl> - for ( int i = 0 ; i < len ; + + i ) { <nl> - * q + + = buf [ i ] ; <nl> - } <nl> - TIXMLASSERT ( q < = p ) ; <nl> - } <nl> - else { <nl> - int i = 0 ; <nl> - for ( ; i < NUM_ENTITIES ; + + i ) { <nl> - if ( strncmp ( p + 1 , entities [ i ] . pattern , entities [ i ] . length ) = = 0 <nl> - & & * ( p + entities [ i ] . length + 1 ) = = ' ; ' ) { <nl> - / / Found an entity convert ; <nl> - * q = entities [ i ] . value ; <nl> - + + q ; <nl> - p + = entities [ i ] . length + 2 ; <nl> - break ; <nl> - } <nl> - } <nl> - if ( i = = NUM_ENTITIES ) { <nl> - / / fixme : treat as error ? <nl> - + + p ; <nl> - + + q ; <nl> - } <nl> - } <nl> - } <nl> - else { <nl> - * q = * p ; <nl> - + + p ; <nl> - + + q ; <nl> - } <nl> - } <nl> - * q = 0 ; <nl> - } <nl> - / / The loop below has plenty going on , and this <nl> - / / is a less useful mode . Break it out . <nl> - if ( _flags & COLLAPSE_WHITESPACE ) { <nl> - CollapseWhitespace ( ) ; <nl> - } <nl> - _flags = ( _flags & NEEDS_DELETE ) ; <nl> - } <nl> - return _start ; <nl> - } <nl> - <nl> - <nl> - <nl> - <nl> - / / mmmmmmmmm XMLUtil mmmmmmmmm - - / / <nl> - <nl> - const char * XMLUtil : : ReadBOM ( const char * p , bool * bom ) <nl> - { <nl> - * bom = false ; <nl> - const unsigned char * pu = reinterpret_cast < const unsigned char * > ( p ) ; <nl> - / / Check for BOM : <nl> - if ( * ( pu + 0 ) = = TIXML_UTF_LEAD_0 <nl> - & & * ( pu + 1 ) = = TIXML_UTF_LEAD_1 <nl> - & & * ( pu + 2 ) = = TIXML_UTF_LEAD_2 ) { <nl> - * bom = true ; <nl> - p + = 3 ; <nl> - } <nl> - return p ; <nl> - } <nl> - <nl> - <nl> - void XMLUtil : : ConvertUTF32ToUTF8 ( unsigned long input , char * output , int * length ) <nl> - { <nl> - const unsigned long BYTE_MASK = 0xBF ; <nl> - const unsigned long BYTE_MARK = 0x80 ; <nl> - const unsigned long FIRST_BYTE_MARK [ 7 ] = { 0x00 , 0x00 , 0xC0 , 0xE0 , 0xF0 , 0xF8 , 0xFC } ; <nl> - <nl> - if ( input < 0x80 ) { <nl> - * length = 1 ; <nl> - } <nl> - else if ( input < 0x800 ) { <nl> - * length = 2 ; <nl> - } <nl> - else if ( input < 0x10000 ) { <nl> - * length = 3 ; <nl> - } <nl> - else if ( input < 0x200000 ) { <nl> - * length = 4 ; <nl> - } <nl> - else { <nl> - * length = 0 ; / / This code won ' t covert this correctly anyway . <nl> - return ; <nl> - } <nl> - <nl> - output + = * length ; <nl> - <nl> - / / Scary scary fall throughs . <nl> - switch ( * length ) { <nl> - case 4 : <nl> - - - output ; <nl> - * output = ( char ) ( ( input | BYTE_MARK ) & BYTE_MASK ) ; <nl> - input > > = 6 ; <nl> - case 3 : <nl> - - - output ; <nl> - * output = ( char ) ( ( input | BYTE_MARK ) & BYTE_MASK ) ; <nl> - input > > = 6 ; <nl> - case 2 : <nl> - - - output ; <nl> - * output = ( char ) ( ( input | BYTE_MARK ) & BYTE_MASK ) ; <nl> - input > > = 6 ; <nl> - case 1 : <nl> - - - output ; <nl> - * output = ( char ) ( input | FIRST_BYTE_MARK [ * length ] ) ; <nl> - default : <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - <nl> - const char * XMLUtil : : GetCharacterRef ( const char * p , char * value , int * length ) <nl> - { <nl> - / / Presume an entity , and pull it out . <nl> - * length = 0 ; <nl> - <nl> - if ( * ( p + 1 ) = = ' # ' & & * ( p + 2 ) ) { <nl> - unsigned long ucs = 0 ; <nl> - ptrdiff_t delta = 0 ; <nl> - unsigned mult = 1 ; <nl> - <nl> - if ( * ( p + 2 ) = = ' x ' ) { <nl> - / / Hexadecimal . <nl> - if ( ! * ( p + 3 ) ) { <nl> - return 0 ; <nl> - } <nl> - <nl> - const char * q = p + 3 ; <nl> - q = strchr ( q , ' ; ' ) ; <nl> - <nl> - if ( ! q | | ! * q ) { <nl> - return 0 ; <nl> - } <nl> - <nl> - delta = q - p ; <nl> - - - q ; <nl> - <nl> - while ( * q ! = ' x ' ) { <nl> - if ( * q > = ' 0 ' & & * q < = ' 9 ' ) { <nl> - ucs + = mult * ( * q - ' 0 ' ) ; <nl> - } <nl> - else if ( * q > = ' a ' & & * q < = ' f ' ) { <nl> - ucs + = mult * ( * q - ' a ' + 10 ) ; <nl> - } <nl> - else if ( * q > = ' A ' & & * q < = ' F ' ) { <nl> - ucs + = mult * ( * q - ' A ' + 10 ) ; <nl> - } <nl> - else { <nl> - return 0 ; <nl> - } <nl> - mult * = 16 ; <nl> - - - q ; <nl> - } <nl> - } <nl> - else { <nl> - / / Decimal . <nl> - if ( ! * ( p + 2 ) ) { <nl> - return 0 ; <nl> - } <nl> - <nl> - const char * q = p + 2 ; <nl> - q = strchr ( q , ' ; ' ) ; <nl> - <nl> - if ( ! q | | ! * q ) { <nl> - return 0 ; <nl> - } <nl> - <nl> - delta = q - p ; <nl> - - - q ; <nl> - <nl> - while ( * q ! = ' # ' ) { <nl> - if ( * q > = ' 0 ' & & * q < = ' 9 ' ) { <nl> - ucs + = mult * ( * q - ' 0 ' ) ; <nl> - } <nl> - else { <nl> - return 0 ; <nl> - } <nl> - mult * = 10 ; <nl> - - - q ; <nl> - } <nl> - } <nl> - / / convert the UCS to UTF - 8 <nl> - ConvertUTF32ToUTF8 ( ucs , value , length ) ; <nl> - return p + delta + 1 ; <nl> - } <nl> - return p + 1 ; <nl> - } <nl> - <nl> - <nl> - void XMLUtil : : ToStr ( int v , char * buffer , int bufferSize ) <nl> - { <nl> - TIXML_SNPRINTF ( buffer , bufferSize , " % d " , v ) ; <nl> - } <nl> - <nl> - <nl> - void XMLUtil : : ToStr ( unsigned v , char * buffer , int bufferSize ) <nl> - { <nl> - TIXML_SNPRINTF ( buffer , bufferSize , " % u " , v ) ; <nl> - } <nl> - <nl> - <nl> - void XMLUtil : : ToStr ( bool v , char * buffer , int bufferSize ) <nl> - { <nl> - TIXML_SNPRINTF ( buffer , bufferSize , " % d " , v ? 1 : 0 ) ; <nl> - } <nl> - <nl> - <nl> - void XMLUtil : : ToStr ( float v , char * buffer , int bufferSize ) <nl> - { <nl> - TIXML_SNPRINTF ( buffer , bufferSize , " % g " , v ) ; <nl> - } <nl> - <nl> - <nl> - void XMLUtil : : ToStr ( double v , char * buffer , int bufferSize ) <nl> - { <nl> - TIXML_SNPRINTF ( buffer , bufferSize , " % g " , v ) ; <nl> - } <nl> - <nl> - <nl> - bool XMLUtil : : ToInt ( const char * str , int * value ) <nl> - { <nl> - if ( TIXML_SSCANF ( str , " % d " , value ) = = 1 ) { <nl> - return true ; <nl> - } <nl> - return false ; <nl> - } <nl> - <nl> - bool XMLUtil : : ToUnsigned ( const char * str , unsigned * value ) <nl> - { <nl> - if ( TIXML_SSCANF ( str , " % u " , value ) = = 1 ) { <nl> - return true ; <nl> - } <nl> - return false ; <nl> - } <nl> - <nl> - bool XMLUtil : : ToBool ( const char * str , bool * value ) <nl> - { <nl> - int ival = 0 ; <nl> - if ( ToInt ( str , & ival ) ) { <nl> - * value = ( ival = = 0 ) ? false : true ; <nl> - return true ; <nl> - } <nl> - if ( StringEqual ( str , " true " ) ) { <nl> - * value = true ; <nl> - return true ; <nl> - } <nl> - else if ( StringEqual ( str , " false " ) ) { <nl> - * value = false ; <nl> - return true ; <nl> - } <nl> - return false ; <nl> - } <nl> - <nl> - <nl> - bool XMLUtil : : ToFloat ( const char * str , float * value ) <nl> - { <nl> - if ( TIXML_SSCANF ( str , " % f " , value ) = = 1 ) { <nl> - return true ; <nl> - } <nl> - return false ; <nl> - } <nl> - <nl> - bool XMLUtil : : ToDouble ( const char * str , double * value ) <nl> - { <nl> - if ( TIXML_SSCANF ( str , " % lf " , value ) = = 1 ) { <nl> - return true ; <nl> - } <nl> - return false ; <nl> - } <nl> - <nl> - <nl> - char * XMLDocument : : Identify ( char * p , XMLNode * * node ) <nl> - { <nl> - XMLNode * returnNode = 0 ; <nl> - char * start = p ; <nl> - p = XMLUtil : : SkipWhiteSpace ( p ) ; <nl> - if ( ! p | | ! * p ) { <nl> - return p ; <nl> - } <nl> - <nl> - / / What is this thing ? <nl> - / / - Elements start with a letter or underscore , but xml is reserved . <nl> - / / - Comments : < ! - - <nl> - / / - Decleration : < ? <nl> - / / - Everthing else is unknown to tinyxml . <nl> - / / <nl> - <nl> - static const char * xmlHeader = { " < ? " } ; <nl> - static const char * commentHeader = { " < ! - - " } ; <nl> - static const char * dtdHeader = { " < ! " } ; <nl> - static const char * cdataHeader = { " < ! [ CDATA [ " } ; <nl> - static const char * elementHeader = { " < " } ; / / and a header for everything else ; check last . <nl> - <nl> - static const int xmlHeaderLen = 2 ; <nl> - static const int commentHeaderLen = 4 ; <nl> - static const int dtdHeaderLen = 2 ; <nl> - static const int cdataHeaderLen = 9 ; <nl> - static const int elementHeaderLen = 1 ; <nl> - <nl> - # if defined ( _MSC_VER ) <nl> - # pragma warning ( push ) <nl> - # pragma warning ( disable : 4127 ) <nl> - # endif <nl> - TIXMLASSERT ( sizeof ( XMLComment ) = = sizeof ( XMLUnknown ) ) ; / / use same memory pool <nl> - TIXMLASSERT ( sizeof ( XMLComment ) = = sizeof ( XMLDeclaration ) ) ; / / use same memory pool <nl> - # if defined ( _MSC_VER ) <nl> - # pragma warning ( pop ) <nl> - # endif <nl> - if ( XMLUtil : : StringEqual ( p , xmlHeader , xmlHeaderLen ) ) { <nl> - returnNode = new ( _commentPool . Alloc ( ) ) XMLDeclaration ( this ) ; <nl> - returnNode - > _memPool = & _commentPool ; <nl> - p + = xmlHeaderLen ; <nl> - } <nl> - else if ( XMLUtil : : StringEqual ( p , commentHeader , commentHeaderLen ) ) { <nl> - returnNode = new ( _commentPool . Alloc ( ) ) XMLComment ( this ) ; <nl> - returnNode - > _memPool = & _commentPool ; <nl> - p + = commentHeaderLen ; <nl> - } <nl> - else if ( XMLUtil : : StringEqual ( p , cdataHeader , cdataHeaderLen ) ) { <nl> - XMLText * text = new ( _textPool . Alloc ( ) ) XMLText ( this ) ; <nl> - returnNode = text ; <nl> - returnNode - > _memPool = & _textPool ; <nl> - p + = cdataHeaderLen ; <nl> - text - > SetCData ( true ) ; <nl> - } <nl> - else if ( XMLUtil : : StringEqual ( p , dtdHeader , dtdHeaderLen ) ) { <nl> - returnNode = new ( _commentPool . Alloc ( ) ) XMLUnknown ( this ) ; <nl> - returnNode - > _memPool = & _commentPool ; <nl> - p + = dtdHeaderLen ; <nl> - } <nl> - else if ( XMLUtil : : StringEqual ( p , elementHeader , elementHeaderLen ) ) { <nl> - returnNode = new ( _elementPool . Alloc ( ) ) XMLElement ( this ) ; <nl> - returnNode - > _memPool = & _elementPool ; <nl> - p + = elementHeaderLen ; <nl> - } <nl> - else { <nl> - returnNode = new ( _textPool . Alloc ( ) ) XMLText ( this ) ; <nl> - returnNode - > _memPool = & _textPool ; <nl> - p = start ; / / Back it up , all the text counts . <nl> - } <nl> - <nl> - * node = returnNode ; <nl> - return p ; <nl> - } <nl> - <nl> - <nl> - bool XMLDocument : : Accept ( XMLVisitor * visitor ) const <nl> - { <nl> - if ( visitor - > VisitEnter ( * this ) ) { <nl> - for ( const XMLNode * node = FirstChild ( ) ; node ; node = node - > NextSibling ( ) ) { <nl> - if ( ! node - > Accept ( visitor ) ) { <nl> - break ; <nl> - } <nl> - } <nl> - } <nl> - return visitor - > VisitExit ( * this ) ; <nl> - } <nl> - <nl> - <nl> - / / mmmmmmmmm XMLNode mmmmmmmmm - - / / <nl> - <nl> - XMLNode : : XMLNode ( XMLDocument * doc ) : <nl> - _document ( doc ) , <nl> - _parent ( 0 ) , <nl> - _firstChild ( 0 ) , _lastChild ( 0 ) , <nl> - _prev ( 0 ) , _next ( 0 ) <nl> - { <nl> - } <nl> - <nl> - <nl> - XMLNode : : ~ XMLNode ( ) <nl> - { <nl> - DeleteChildren ( ) ; <nl> - if ( _parent ) { <nl> - _parent - > Unlink ( this ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - void XMLNode : : SetValue ( const char * str , bool staticMem ) <nl> - { <nl> - if ( staticMem ) { <nl> - _value . SetInternedStr ( str ) ; <nl> - } <nl> - else { <nl> - _value . SetStr ( str ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - void XMLNode : : DeleteChildren ( ) <nl> - { <nl> - while ( _firstChild ) { <nl> - XMLNode * node = _firstChild ; <nl> - Unlink ( node ) ; <nl> - <nl> - DELETE_NODE ( node ) ; <nl> - } <nl> - _firstChild = _lastChild = 0 ; <nl> - } <nl> - <nl> - <nl> - void XMLNode : : Unlink ( XMLNode * child ) <nl> - { <nl> - TIXMLASSERT ( child - > _parent = = this ) ; <nl> - if ( child = = _firstChild ) { <nl> - _firstChild = _firstChild - > _next ; <nl> - } <nl> - if ( child = = _lastChild ) { <nl> - _lastChild = _lastChild - > _prev ; <nl> - } <nl> - <nl> - if ( child - > _prev ) { <nl> - child - > _prev - > _next = child - > _next ; <nl> - } <nl> - if ( child - > _next ) { <nl> - child - > _next - > _prev = child - > _prev ; <nl> - } <nl> - child - > _parent = 0 ; <nl> - } <nl> - <nl> - <nl> - void XMLNode : : DeleteChild ( XMLNode * node ) <nl> - { <nl> - TIXMLASSERT ( node - > _parent = = this ) ; <nl> - DELETE_NODE ( node ) ; <nl> - } <nl> - <nl> - <nl> - XMLNode * XMLNode : : InsertEndChild ( XMLNode * addThis ) <nl> - { <nl> - if ( _lastChild ) { <nl> - TIXMLASSERT ( _firstChild ) ; <nl> - TIXMLASSERT ( _lastChild - > _next = = 0 ) ; <nl> - _lastChild - > _next = addThis ; <nl> - addThis - > _prev = _lastChild ; <nl> - _lastChild = addThis ; <nl> - <nl> - addThis - > _next = 0 ; <nl> - } <nl> - else { <nl> - TIXMLASSERT ( _firstChild = = 0 ) ; <nl> - _firstChild = _lastChild = addThis ; <nl> - <nl> - addThis - > _prev = 0 ; <nl> - addThis - > _next = 0 ; <nl> - } <nl> - addThis - > _parent = this ; <nl> - addThis - > _memPool - > SetTracked ( ) ; <nl> - return addThis ; <nl> - } <nl> - <nl> - <nl> - XMLNode * XMLNode : : InsertFirstChild ( XMLNode * addThis ) <nl> - { <nl> - if ( _firstChild ) { <nl> - TIXMLASSERT ( _lastChild ) ; <nl> - TIXMLASSERT ( _firstChild - > _prev = = 0 ) ; <nl> - <nl> - _firstChild - > _prev = addThis ; <nl> - addThis - > _next = _firstChild ; <nl> - _firstChild = addThis ; <nl> - <nl> - addThis - > _prev = 0 ; <nl> - } <nl> - else { <nl> - TIXMLASSERT ( _lastChild = = 0 ) ; <nl> - _firstChild = _lastChild = addThis ; <nl> - <nl> - addThis - > _prev = 0 ; <nl> - addThis - > _next = 0 ; <nl> - } <nl> - addThis - > _parent = this ; <nl> - addThis - > _memPool - > SetTracked ( ) ; <nl> - return addThis ; <nl> - } <nl> - <nl> - <nl> - XMLNode * XMLNode : : InsertAfterChild ( XMLNode * afterThis , XMLNode * addThis ) <nl> - { <nl> - TIXMLASSERT ( afterThis - > _parent = = this ) ; <nl> - if ( afterThis - > _parent ! = this ) { <nl> - return 0 ; <nl> - } <nl> - <nl> - if ( afterThis - > _next = = 0 ) { <nl> - / / The last node or the only node . <nl> - return InsertEndChild ( addThis ) ; <nl> - } <nl> - addThis - > _prev = afterThis ; <nl> - addThis - > _next = afterThis - > _next ; <nl> - afterThis - > _next - > _prev = addThis ; <nl> - afterThis - > _next = addThis ; <nl> - addThis - > _parent = this ; <nl> - addThis - > _memPool - > SetTracked ( ) ; <nl> - return addThis ; <nl> - } <nl> - <nl> - <nl> - <nl> - <nl> - const XMLElement * XMLNode : : FirstChildElement ( const char * value ) const <nl> - { <nl> - for ( XMLNode * node = _firstChild ; node ; node = node - > _next ) { <nl> - XMLElement * element = node - > ToElement ( ) ; <nl> - if ( element ) { <nl> - if ( ! value | | XMLUtil : : StringEqual ( element - > Name ( ) , value ) ) { <nl> - return element ; <nl> - } <nl> - } <nl> - } <nl> - return 0 ; <nl> - } <nl> - <nl> - <nl> - const XMLElement * XMLNode : : LastChildElement ( const char * value ) const <nl> - { <nl> - for ( XMLNode * node = _lastChild ; node ; node = node - > _prev ) { <nl> - XMLElement * element = node - > ToElement ( ) ; <nl> - if ( element ) { <nl> - if ( ! value | | XMLUtil : : StringEqual ( element - > Name ( ) , value ) ) { <nl> - return element ; <nl> - } <nl> - } <nl> - } <nl> - return 0 ; <nl> - } <nl> - <nl> - <nl> - const XMLElement * XMLNode : : NextSiblingElement ( const char * value ) const <nl> - { <nl> - for ( XMLNode * element = this - > _next ; element ; element = element - > _next ) { <nl> - if ( element - > ToElement ( ) <nl> - & & ( ! value | | XMLUtil : : StringEqual ( value , element - > Value ( ) ) ) ) { <nl> - return element - > ToElement ( ) ; <nl> - } <nl> - } <nl> - return 0 ; <nl> - } <nl> - <nl> - <nl> - const XMLElement * XMLNode : : PreviousSiblingElement ( const char * value ) const <nl> - { <nl> - for ( XMLNode * element = _prev ; element ; element = element - > _prev ) { <nl> - if ( element - > ToElement ( ) <nl> - & & ( ! value | | XMLUtil : : StringEqual ( value , element - > Value ( ) ) ) ) { <nl> - return element - > ToElement ( ) ; <nl> - } <nl> - } <nl> - return 0 ; <nl> - } <nl> - <nl> - <nl> - char * XMLNode : : ParseDeep ( char * p , StrPair * parentEnd ) <nl> - { <nl> - / / This is a recursive method , but thinking about it " at the current level " <nl> - / / it is a pretty simple flat list : <nl> - / / < foo / > <nl> - / / < ! - - comment - - > <nl> - / / <nl> - / / With a special case : <nl> - / / < foo > <nl> - / / < / foo > <nl> - / / < ! - - comment - - > <nl> - / / <nl> - / / Where the closing element ( / foo ) * must * be the next thing after the opening <nl> - / / element , and the names must match . BUT the tricky bit is that the closing <nl> - / / element will be read by the child . <nl> - / / <nl> - / / ' endTag ' is the end tag for this node , it is returned by a call to a child . <nl> - / / ' parentEnd ' is the end tag for the parent , which is filled in and returned . <nl> - <nl> - while ( p & & * p ) { <nl> - XMLNode * node = 0 ; <nl> - <nl> - p = _document - > Identify ( p , & node ) ; <nl> - if ( p = = 0 | | node = = 0 ) { <nl> - break ; <nl> - } <nl> - <nl> - StrPair endTag ; <nl> - p = node - > ParseDeep ( p , & endTag ) ; <nl> - if ( ! p ) { <nl> - DELETE_NODE ( node ) ; <nl> - node = 0 ; <nl> - if ( ! _document - > Error ( ) ) { <nl> - _document - > SetError ( XML_ERROR_PARSING , 0 , 0 ) ; <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - / / We read the end tag . Return it to the parent . <nl> - if ( node - > ToElement ( ) & & node - > ToElement ( ) - > ClosingType ( ) = = XMLElement : : CLOSING ) { <nl> - if ( parentEnd ) { <nl> - * parentEnd = static_cast < XMLElement * > ( node ) - > _value ; <nl> - } <nl> - node - > _memPool - > SetTracked ( ) ; / / created and then immediately deleted . <nl> - DELETE_NODE ( node ) ; <nl> - return p ; <nl> - } <nl> - <nl> - / / Handle an end tag returned to this level . <nl> - / / And handle a bunch of annoying errors . <nl> - XMLElement * ele = node - > ToElement ( ) ; <nl> - if ( ele ) { <nl> - if ( endTag . Empty ( ) & & ele - > ClosingType ( ) = = XMLElement : : OPEN ) { <nl> - _document - > SetError ( XML_ERROR_MISMATCHED_ELEMENT , node - > Value ( ) , 0 ) ; <nl> - p = 0 ; <nl> - } <nl> - else if ( ! endTag . Empty ( ) & & ele - > ClosingType ( ) ! = XMLElement : : OPEN ) { <nl> - _document - > SetError ( XML_ERROR_MISMATCHED_ELEMENT , node - > Value ( ) , 0 ) ; <nl> - p = 0 ; <nl> - } <nl> - else if ( ! endTag . Empty ( ) ) { <nl> - if ( ! XMLUtil : : StringEqual ( endTag . GetStr ( ) , node - > Value ( ) ) ) { <nl> - _document - > SetError ( XML_ERROR_MISMATCHED_ELEMENT , node - > Value ( ) , 0 ) ; <nl> - p = 0 ; <nl> - } <nl> - } <nl> - } <nl> - if ( p = = 0 ) { <nl> - DELETE_NODE ( node ) ; <nl> - node = 0 ; <nl> - } <nl> - if ( node ) { <nl> - this - > InsertEndChild ( node ) ; <nl> - } <nl> - } <nl> - return 0 ; <nl> - } <nl> - <nl> - / / mmmmmmmmm XMLText mmmmmmmmm - / / <nl> - char * XMLText : : ParseDeep ( char * p , StrPair * ) <nl> - { <nl> - const char * start = p ; <nl> - if ( this - > CData ( ) ) { <nl> - p = _value . ParseText ( p , " ] ] > " , StrPair : : NEEDS_NEWLINE_NORMALIZATION ) ; <nl> - if ( ! p ) { <nl> - _document - > SetError ( XML_ERROR_PARSING_CDATA , start , 0 ) ; <nl> - } <nl> - return p ; <nl> - } <nl> - else { <nl> - int flags = _document - > ProcessEntities ( ) ? StrPair : : TEXT_ELEMENT : StrPair : : TEXT_ELEMENT_LEAVE_ENTITIES ; <nl> - if ( _document - > WhitespaceMode ( ) = = COLLAPSE_WHITESPACE ) { <nl> - flags | = StrPair : : COLLAPSE_WHITESPACE ; <nl> - } <nl> - <nl> - p = _value . ParseText ( p , " < " , flags ) ; <nl> - if ( ! p ) { <nl> - _document - > SetError ( XML_ERROR_PARSING_TEXT , start , 0 ) ; <nl> - } <nl> - if ( p & & * p ) { <nl> - return p - 1 ; <nl> - } <nl> - } <nl> - return 0 ; <nl> - } <nl> - <nl> - <nl> - XMLNode * XMLText : : ShallowClone ( XMLDocument * doc ) const <nl> - { <nl> - if ( ! doc ) { <nl> - doc = _document ; <nl> - } <nl> - XMLText * text = doc - > NewText ( Value ( ) ) ; / / fixme : this will always allocate memory . Intern ? <nl> - text - > SetCData ( this - > CData ( ) ) ; <nl> - return text ; <nl> - } <nl> - <nl> - <nl> - bool XMLText : : ShallowEqual ( const XMLNode * compare ) const <nl> - { <nl> - return ( compare - > ToText ( ) & & XMLUtil : : StringEqual ( compare - > ToText ( ) - > Value ( ) , Value ( ) ) ) ; <nl> - } <nl> - <nl> - <nl> - bool XMLText : : Accept ( XMLVisitor * visitor ) const <nl> - { <nl> - return visitor - > Visit ( * this ) ; <nl> - } <nl> - <nl> - <nl> - / / mmmmmmmmm XMLComment mmmmmmmmm - / / <nl> - <nl> - XMLComment : : XMLComment ( XMLDocument * doc ) : XMLNode ( doc ) <nl> - { <nl> - } <nl> - <nl> - <nl> - XMLComment : : ~ XMLComment ( ) <nl> - { <nl> - } <nl> - <nl> - <nl> - char * XMLComment : : ParseDeep ( char * p , StrPair * ) <nl> - { <nl> - / / Comment parses as text . <nl> - const char * start = p ; <nl> - p = _value . ParseText ( p , " - - > " , StrPair : : COMMENT ) ; <nl> - if ( p = = 0 ) { <nl> - _document - > SetError ( XML_ERROR_PARSING_COMMENT , start , 0 ) ; <nl> - } <nl> - return p ; <nl> - } <nl> - <nl> - <nl> - XMLNode * XMLComment : : ShallowClone ( XMLDocument * doc ) const <nl> - { <nl> - if ( ! doc ) { <nl> - doc = _document ; <nl> - } <nl> - XMLComment * comment = doc - > NewComment ( Value ( ) ) ; / / fixme : this will always allocate memory . Intern ? <nl> - return comment ; <nl> - } <nl> - <nl> - <nl> - bool XMLComment : : ShallowEqual ( const XMLNode * compare ) const <nl> - { <nl> - return ( compare - > ToComment ( ) & & XMLUtil : : StringEqual ( compare - > ToComment ( ) - > Value ( ) , Value ( ) ) ) ; <nl> - } <nl> - <nl> - <nl> - bool XMLComment : : Accept ( XMLVisitor * visitor ) const <nl> - { <nl> - return visitor - > Visit ( * this ) ; <nl> - } <nl> - <nl> - <nl> - / / mmmmmmmmm XMLDeclaration mmmmmmmmm - / / <nl> - <nl> - XMLDeclaration : : XMLDeclaration ( XMLDocument * doc ) : XMLNode ( doc ) <nl> - { <nl> - } <nl> - <nl> - <nl> - XMLDeclaration : : ~ XMLDeclaration ( ) <nl> - { <nl> - / / printf ( " ~ XMLDeclaration \ n " ) ; <nl> - } <nl> - <nl> - <nl> - char * XMLDeclaration : : ParseDeep ( char * p , StrPair * ) <nl> - { <nl> - / / Declaration parses as text . <nl> - const char * start = p ; <nl> - p = _value . ParseText ( p , " ? > " , StrPair : : NEEDS_NEWLINE_NORMALIZATION ) ; <nl> - if ( p = = 0 ) { <nl> - _document - > SetError ( XML_ERROR_PARSING_DECLARATION , start , 0 ) ; <nl> - } <nl> - return p ; <nl> - } <nl> - <nl> - <nl> - XMLNode * XMLDeclaration : : ShallowClone ( XMLDocument * doc ) const <nl> - { <nl> - if ( ! doc ) { <nl> - doc = _document ; <nl> - } <nl> - XMLDeclaration * dec = doc - > NewDeclaration ( Value ( ) ) ; / / fixme : this will always allocate memory . Intern ? <nl> - return dec ; <nl> - } <nl> - <nl> - <nl> - bool XMLDeclaration : : ShallowEqual ( const XMLNode * compare ) const <nl> - { <nl> - return ( compare - > ToDeclaration ( ) & & XMLUtil : : StringEqual ( compare - > ToDeclaration ( ) - > Value ( ) , Value ( ) ) ) ; <nl> - } <nl> - <nl> - <nl> - <nl> - bool XMLDeclaration : : Accept ( XMLVisitor * visitor ) const <nl> - { <nl> - return visitor - > Visit ( * this ) ; <nl> - } <nl> - <nl> - / / mmmmmmmmm XMLUnknown mmmmmmmmm - / / <nl> - <nl> - XMLUnknown : : XMLUnknown ( XMLDocument * doc ) : XMLNode ( doc ) <nl> - { <nl> - } <nl> - <nl> - <nl> - XMLUnknown : : ~ XMLUnknown ( ) <nl> - { <nl> - } <nl> - <nl> - <nl> - char * XMLUnknown : : ParseDeep ( char * p , StrPair * ) <nl> - { <nl> - / / Unknown parses as text . <nl> - const char * start = p ; <nl> - <nl> - p = _value . ParseText ( p , " > " , StrPair : : NEEDS_NEWLINE_NORMALIZATION ) ; <nl> - if ( ! p ) { <nl> - _document - > SetError ( XML_ERROR_PARSING_UNKNOWN , start , 0 ) ; <nl> - } <nl> - return p ; <nl> - } <nl> - <nl> - <nl> - XMLNode * XMLUnknown : : ShallowClone ( XMLDocument * doc ) const <nl> - { <nl> - if ( ! doc ) { <nl> - doc = _document ; <nl> - } <nl> - XMLUnknown * text = doc - > NewUnknown ( Value ( ) ) ; / / fixme : this will always allocate memory . Intern ? <nl> - return text ; <nl> - } <nl> - <nl> - <nl> - bool XMLUnknown : : ShallowEqual ( const XMLNode * compare ) const <nl> - { <nl> - return ( compare - > ToUnknown ( ) & & XMLUtil : : StringEqual ( compare - > ToUnknown ( ) - > Value ( ) , Value ( ) ) ) ; <nl> - } <nl> - <nl> - <nl> - bool XMLUnknown : : Accept ( XMLVisitor * visitor ) const <nl> - { <nl> - return visitor - > Visit ( * this ) ; <nl> - } <nl> - <nl> - / / mmmmmmmmm XMLAttribute mmmmmmmmm - / / <nl> - char * XMLAttribute : : ParseDeep ( char * p , bool processEntities ) <nl> - { <nl> - / / Parse using the name rules : bug fix , was using ParseText before <nl> - p = _name . ParseName ( p ) ; <nl> - if ( ! p | | ! * p ) { <nl> - return 0 ; <nl> - } <nl> - <nl> - / / Skip white space before = <nl> - p = XMLUtil : : SkipWhiteSpace ( p ) ; <nl> - if ( ! p | | * p ! = ' = ' ) { <nl> - return 0 ; <nl> - } <nl> - <nl> - + + p ; / / move up to opening quote <nl> - p = XMLUtil : : SkipWhiteSpace ( p ) ; <nl> - if ( * p ! = ' \ " ' & & * p ! = ' \ ' ' ) { <nl> - return 0 ; <nl> - } <nl> - <nl> - char endTag [ 2 ] = { * p , 0 } ; <nl> - + + p ; / / move past opening quote <nl> - <nl> - p = _value . ParseText ( p , endTag , processEntities ? StrPair : : ATTRIBUTE_VALUE : StrPair : : ATTRIBUTE_VALUE_LEAVE_ENTITIES ) ; <nl> - return p ; <nl> - } <nl> - <nl> - <nl> - void XMLAttribute : : SetName ( const char * n ) <nl> - { <nl> - _name . SetStr ( n ) ; <nl> - } <nl> - <nl> - <nl> - XMLError XMLAttribute : : QueryIntValue ( int * value ) const <nl> - { <nl> - if ( XMLUtil : : ToInt ( Value ( ) , value ) ) { <nl> - return XML_NO_ERROR ; <nl> - } <nl> - return XML_WRONG_ATTRIBUTE_TYPE ; <nl> - } <nl> - <nl> - <nl> - XMLError XMLAttribute : : QueryUnsignedValue ( unsigned int * value ) const <nl> - { <nl> - if ( XMLUtil : : ToUnsigned ( Value ( ) , value ) ) { <nl> - return XML_NO_ERROR ; <nl> - } <nl> - return XML_WRONG_ATTRIBUTE_TYPE ; <nl> - } <nl> - <nl> - <nl> - XMLError XMLAttribute : : QueryBoolValue ( bool * value ) const <nl> - { <nl> - if ( XMLUtil : : ToBool ( Value ( ) , value ) ) { <nl> - return XML_NO_ERROR ; <nl> - } <nl> - return XML_WRONG_ATTRIBUTE_TYPE ; <nl> - } <nl> - <nl> - <nl> - XMLError XMLAttribute : : QueryFloatValue ( float * value ) const <nl> - { <nl> - if ( XMLUtil : : ToFloat ( Value ( ) , value ) ) { <nl> - return XML_NO_ERROR ; <nl> - } <nl> - return XML_WRONG_ATTRIBUTE_TYPE ; <nl> - } <nl> - <nl> - <nl> - XMLError XMLAttribute : : QueryDoubleValue ( double * value ) const <nl> - { <nl> - if ( XMLUtil : : ToDouble ( Value ( ) , value ) ) { <nl> - return XML_NO_ERROR ; <nl> - } <nl> - return XML_WRONG_ATTRIBUTE_TYPE ; <nl> - } <nl> - <nl> - <nl> - void XMLAttribute : : SetAttribute ( const char * v ) <nl> - { <nl> - _value . SetStr ( v ) ; <nl> - } <nl> - <nl> - <nl> - void XMLAttribute : : SetAttribute ( int v ) <nl> - { <nl> - char buf [ BUF_SIZE ] ; <nl> - XMLUtil : : ToStr ( v , buf , BUF_SIZE ) ; <nl> - _value . SetStr ( buf ) ; <nl> - } <nl> - <nl> - <nl> - void XMLAttribute : : SetAttribute ( unsigned v ) <nl> - { <nl> - char buf [ BUF_SIZE ] ; <nl> - XMLUtil : : ToStr ( v , buf , BUF_SIZE ) ; <nl> - _value . SetStr ( buf ) ; <nl> - } <nl> - <nl> - <nl> - void XMLAttribute : : SetAttribute ( bool v ) <nl> - { <nl> - char buf [ BUF_SIZE ] ; <nl> - XMLUtil : : ToStr ( v , buf , BUF_SIZE ) ; <nl> - _value . SetStr ( buf ) ; <nl> - } <nl> - <nl> - void XMLAttribute : : SetAttribute ( double v ) <nl> - { <nl> - char buf [ BUF_SIZE ] ; <nl> - XMLUtil : : ToStr ( v , buf , BUF_SIZE ) ; <nl> - _value . SetStr ( buf ) ; <nl> - } <nl> - <nl> - void XMLAttribute : : SetAttribute ( float v ) <nl> - { <nl> - char buf [ BUF_SIZE ] ; <nl> - XMLUtil : : ToStr ( v , buf , BUF_SIZE ) ; <nl> - _value . SetStr ( buf ) ; <nl> - } <nl> - <nl> - <nl> - / / mmmmmmmmm XMLElement mmmmmmmmm - / / <nl> - XMLElement : : XMLElement ( XMLDocument * doc ) : XMLNode ( doc ) , <nl> - _closingType ( 0 ) , <nl> - _rootAttribute ( 0 ) <nl> - { <nl> - } <nl> - <nl> - <nl> - XMLElement : : ~ XMLElement ( ) <nl> - { <nl> - while ( _rootAttribute ) { <nl> - XMLAttribute * next = _rootAttribute - > _next ; <nl> - DELETE_ATTRIBUTE ( _rootAttribute ) ; <nl> - _rootAttribute = next ; <nl> - } <nl> - } <nl> - <nl> - <nl> - XMLAttribute * XMLElement : : FindAttribute ( const char * name ) <nl> - { <nl> - XMLAttribute * a = 0 ; <nl> - for ( a = _rootAttribute ; a ; a = a - > _next ) { <nl> - if ( XMLUtil : : StringEqual ( a - > Name ( ) , name ) ) { <nl> - return a ; <nl> - } <nl> - } <nl> - return 0 ; <nl> - } <nl> - <nl> - <nl> - const XMLAttribute * XMLElement : : FindAttribute ( const char * name ) const <nl> - { <nl> - XMLAttribute * a = 0 ; <nl> - for ( a = _rootAttribute ; a ; a = a - > _next ) { <nl> - if ( XMLUtil : : StringEqual ( a - > Name ( ) , name ) ) { <nl> - return a ; <nl> - } <nl> - } <nl> - return 0 ; <nl> - } <nl> - <nl> - <nl> - const char * XMLElement : : Attribute ( const char * name , const char * value ) const <nl> - { <nl> - const XMLAttribute * a = FindAttribute ( name ) ; <nl> - if ( ! a ) { <nl> - return 0 ; <nl> - } <nl> - if ( ! value | | XMLUtil : : StringEqual ( a - > Value ( ) , value ) ) { <nl> - return a - > Value ( ) ; <nl> - } <nl> - return 0 ; <nl> - } <nl> - <nl> - <nl> - const char * XMLElement : : GetText ( ) const <nl> - { <nl> - if ( FirstChild ( ) & & FirstChild ( ) - > ToText ( ) ) { <nl> - return FirstChild ( ) - > ToText ( ) - > Value ( ) ; <nl> - } <nl> - return 0 ; <nl> - } <nl> - <nl> - <nl> - XMLError XMLElement : : QueryIntText ( int * ival ) const <nl> - { <nl> - if ( FirstChild ( ) & & FirstChild ( ) - > ToText ( ) ) { <nl> - const char * t = FirstChild ( ) - > ToText ( ) - > Value ( ) ; <nl> - if ( XMLUtil : : ToInt ( t , ival ) ) { <nl> - return XML_SUCCESS ; <nl> - } <nl> - return XML_CAN_NOT_CONVERT_TEXT ; <nl> - } <nl> - return XML_NO_TEXT_NODE ; <nl> - } <nl> - <nl> - <nl> - XMLError XMLElement : : QueryUnsignedText ( unsigned * uval ) const <nl> - { <nl> - if ( FirstChild ( ) & & FirstChild ( ) - > ToText ( ) ) { <nl> - const char * t = FirstChild ( ) - > ToText ( ) - > Value ( ) ; <nl> - if ( XMLUtil : : ToUnsigned ( t , uval ) ) { <nl> - return XML_SUCCESS ; <nl> - } <nl> - return XML_CAN_NOT_CONVERT_TEXT ; <nl> - } <nl> - return XML_NO_TEXT_NODE ; <nl> - } <nl> - <nl> - <nl> - XMLError XMLElement : : QueryBoolText ( bool * bval ) const <nl> - { <nl> - if ( FirstChild ( ) & & FirstChild ( ) - > ToText ( ) ) { <nl> - const char * t = FirstChild ( ) - > ToText ( ) - > Value ( ) ; <nl> - if ( XMLUtil : : ToBool ( t , bval ) ) { <nl> - return XML_SUCCESS ; <nl> - } <nl> - return XML_CAN_NOT_CONVERT_TEXT ; <nl> - } <nl> - return XML_NO_TEXT_NODE ; <nl> - } <nl> - <nl> - <nl> - XMLError XMLElement : : QueryDoubleText ( double * dval ) const <nl> - { <nl> - if ( FirstChild ( ) & & FirstChild ( ) - > ToText ( ) ) { <nl> - const char * t = FirstChild ( ) - > ToText ( ) - > Value ( ) ; <nl> - if ( XMLUtil : : ToDouble ( t , dval ) ) { <nl> - return XML_SUCCESS ; <nl> - } <nl> - return XML_CAN_NOT_CONVERT_TEXT ; <nl> - } <nl> - return XML_NO_TEXT_NODE ; <nl> - } <nl> - <nl> - <nl> - XMLError XMLElement : : QueryFloatText ( float * fval ) const <nl> - { <nl> - if ( FirstChild ( ) & & FirstChild ( ) - > ToText ( ) ) { <nl> - const char * t = FirstChild ( ) - > ToText ( ) - > Value ( ) ; <nl> - if ( XMLUtil : : ToFloat ( t , fval ) ) { <nl> - return XML_SUCCESS ; <nl> - } <nl> - return XML_CAN_NOT_CONVERT_TEXT ; <nl> - } <nl> - return XML_NO_TEXT_NODE ; <nl> - } <nl> - <nl> - <nl> - <nl> - XMLAttribute * XMLElement : : FindOrCreateAttribute ( const char * name ) <nl> - { <nl> - XMLAttribute * last = 0 ; <nl> - XMLAttribute * attrib = 0 ; <nl> - for ( attrib = _rootAttribute ; <nl> - attrib ; <nl> - last = attrib , attrib = attrib - > _next ) { <nl> - if ( XMLUtil : : StringEqual ( attrib - > Name ( ) , name ) ) { <nl> - break ; <nl> - } <nl> - } <nl> - if ( ! attrib ) { <nl> - attrib = new ( _document - > _attributePool . Alloc ( ) ) XMLAttribute ( ) ; <nl> - attrib - > _memPool = & _document - > _attributePool ; <nl> - if ( last ) { <nl> - last - > _next = attrib ; <nl> - } <nl> - else { <nl> - _rootAttribute = attrib ; <nl> - } <nl> - attrib - > SetName ( name ) ; <nl> - attrib - > _memPool - > SetTracked ( ) ; / / always created and linked . <nl> - } <nl> - return attrib ; <nl> - } <nl> - <nl> - <nl> - void XMLElement : : DeleteAttribute ( const char * name ) <nl> - { <nl> - XMLAttribute * prev = 0 ; <nl> - for ( XMLAttribute * a = _rootAttribute ; a ; a = a - > _next ) { <nl> - if ( XMLUtil : : StringEqual ( name , a - > Name ( ) ) ) { <nl> - if ( prev ) { <nl> - prev - > _next = a - > _next ; <nl> - } <nl> - else { <nl> - _rootAttribute = a - > _next ; <nl> - } <nl> - DELETE_ATTRIBUTE ( a ) ; <nl> - break ; <nl> - } <nl> - prev = a ; <nl> - } <nl> - } <nl> - <nl> - <nl> - char * XMLElement : : ParseAttributes ( char * p ) <nl> - { <nl> - const char * start = p ; <nl> - XMLAttribute * prevAttribute = 0 ; <nl> - <nl> - / / Read the attributes . <nl> - while ( p ) { <nl> - p = XMLUtil : : SkipWhiteSpace ( p ) ; <nl> - if ( ! p | | ! ( * p ) ) { <nl> - _document - > SetError ( XML_ERROR_PARSING_ELEMENT , start , Name ( ) ) ; <nl> - return 0 ; <nl> - } <nl> - <nl> - / / attribute . <nl> - if ( XMLUtil : : IsAlpha ( * p ) ) { <nl> - XMLAttribute * attrib = new ( _document - > _attributePool . Alloc ( ) ) XMLAttribute ( ) ; <nl> - attrib - > _memPool = & _document - > _attributePool ; <nl> - attrib - > _memPool - > SetTracked ( ) ; <nl> - <nl> - p = attrib - > ParseDeep ( p , _document - > ProcessEntities ( ) ) ; <nl> - if ( ! p | | Attribute ( attrib - > Name ( ) ) ) { <nl> - DELETE_ATTRIBUTE ( attrib ) ; <nl> - _document - > SetError ( XML_ERROR_PARSING_ATTRIBUTE , start , p ) ; <nl> - return 0 ; <nl> - } <nl> - / / There is a minor bug here : if the attribute in the source xml <nl> - / / document is duplicated , it will not be detected and the <nl> - / / attribute will be doubly added . However , tracking the ' prevAttribute ' <nl> - / / avoids re - scanning the attribute list . Preferring performance for <nl> - / / now , may reconsider in the future . <nl> - if ( prevAttribute ) { <nl> - prevAttribute - > _next = attrib ; <nl> - } <nl> - else { <nl> - _rootAttribute = attrib ; <nl> - } <nl> - prevAttribute = attrib ; <nl> - } <nl> - / / end of the tag <nl> - else if ( * p = = ' / ' & & * ( p + 1 ) = = ' > ' ) { <nl> - _closingType = CLOSED ; <nl> - return p + 2 ; / / done ; sealed element . <nl> - } <nl> - / / end of the tag <nl> - else if ( * p = = ' > ' ) { <nl> - + + p ; <nl> - break ; <nl> - } <nl> - else { <nl> - _document - > SetError ( XML_ERROR_PARSING_ELEMENT , start , p ) ; <nl> - return 0 ; <nl> - } <nl> - } <nl> - return p ; <nl> - } <nl> - <nl> - <nl> - / / <nl> - / / < ele > < / ele > <nl> - / / < ele > foo < b > bar < / b > < / ele > <nl> - / / <nl> - char * XMLElement : : ParseDeep ( char * p , StrPair * strPair ) <nl> - { <nl> - / / Read the element name . <nl> - p = XMLUtil : : SkipWhiteSpace ( p ) ; <nl> - if ( ! p ) { <nl> - return 0 ; <nl> - } <nl> - <nl> - / / The closing element is the < / element > form . It is <nl> - / / parsed just like a regular element then deleted from <nl> - / / the DOM . <nl> - if ( * p = = ' / ' ) { <nl> - _closingType = CLOSING ; <nl> - + + p ; <nl> - } <nl> - <nl> - p = _value . ParseName ( p ) ; <nl> - if ( _value . Empty ( ) ) { <nl> - return 0 ; <nl> - } <nl> - <nl> - p = ParseAttributes ( p ) ; <nl> - if ( ! p | | ! * p | | _closingType ) { <nl> - return p ; <nl> - } <nl> - <nl> - p = XMLNode : : ParseDeep ( p , strPair ) ; <nl> - return p ; <nl> - } <nl> - <nl> - <nl> - <nl> - XMLNode * XMLElement : : ShallowClone ( XMLDocument * doc ) const <nl> - { <nl> - if ( ! doc ) { <nl> - doc = _document ; <nl> - } <nl> - XMLElement * element = doc - > NewElement ( Value ( ) ) ; / / fixme : this will always allocate memory . Intern ? <nl> - for ( const XMLAttribute * a = FirstAttribute ( ) ; a ; a = a - > Next ( ) ) { <nl> - element - > SetAttribute ( a - > Name ( ) , a - > Value ( ) ) ; / / fixme : this will always allocate memory . Intern ? <nl> - } <nl> - return element ; <nl> - } <nl> - <nl> - <nl> - bool XMLElement : : ShallowEqual ( const XMLNode * compare ) const <nl> - { <nl> - const XMLElement * other = compare - > ToElement ( ) ; <nl> - if ( other & & XMLUtil : : StringEqual ( other - > Value ( ) , Value ( ) ) ) { <nl> - <nl> - const XMLAttribute * a = FirstAttribute ( ) ; <nl> - const XMLAttribute * b = other - > FirstAttribute ( ) ; <nl> - <nl> - while ( a & & b ) { <nl> - if ( ! XMLUtil : : StringEqual ( a - > Value ( ) , b - > Value ( ) ) ) { <nl> - return false ; <nl> - } <nl> - a = a - > Next ( ) ; <nl> - b = b - > Next ( ) ; <nl> - } <nl> - if ( a | | b ) { <nl> - / / different count <nl> - return false ; <nl> - } <nl> - return true ; <nl> - } <nl> - return false ; <nl> - } <nl> - <nl> - <nl> - bool XMLElement : : Accept ( XMLVisitor * visitor ) const <nl> - { <nl> - if ( visitor - > VisitEnter ( * this , _rootAttribute ) ) { <nl> - for ( const XMLNode * node = FirstChild ( ) ; node ; node = node - > NextSibling ( ) ) { <nl> - if ( ! node - > Accept ( visitor ) ) { <nl> - break ; <nl> - } <nl> - } <nl> - } <nl> - return visitor - > VisitExit ( * this ) ; <nl> - } <nl> - <nl> - <nl> - / / mmmmmmmmm XMLDocument mmmmmmmmm - - / / <nl> - XMLDocument : : XMLDocument ( bool processEntities , Whitespace whitespace ) : <nl> - XMLNode ( 0 ) , <nl> - _writeBOM ( false ) , <nl> - _processEntities ( processEntities ) , <nl> - _errorID ( XML_NO_ERROR ) , <nl> - _whitespace ( whitespace ) , <nl> - _errorStr1 ( 0 ) , <nl> - _errorStr2 ( 0 ) , <nl> - _charBuffer ( 0 ) <nl> - { <nl> - _document = this ; / / avoid warning about ' this ' in initializer list <nl> - } <nl> - <nl> - <nl> - XMLDocument : : ~ XMLDocument ( ) <nl> - { <nl> - DeleteChildren ( ) ; <nl> - delete [ ] _charBuffer ; <nl> - <nl> - # if 0 <nl> - textPool . Trace ( " text " ) ; <nl> - elementPool . Trace ( " element " ) ; <nl> - commentPool . Trace ( " comment " ) ; <nl> - attributePool . Trace ( " attribute " ) ; <nl> - # endif <nl> - <nl> - # ifdef DEBUG <nl> - if ( Error ( ) = = false ) { <nl> - TIXMLASSERT ( _elementPool . CurrentAllocs ( ) = = _elementPool . Untracked ( ) ) ; <nl> - TIXMLASSERT ( _attributePool . CurrentAllocs ( ) = = _attributePool . Untracked ( ) ) ; <nl> - TIXMLASSERT ( _textPool . CurrentAllocs ( ) = = _textPool . Untracked ( ) ) ; <nl> - TIXMLASSERT ( _commentPool . CurrentAllocs ( ) = = _commentPool . Untracked ( ) ) ; <nl> - } <nl> - # endif <nl> - } <nl> - <nl> - <nl> - void XMLDocument : : InitDocument ( ) <nl> - { <nl> - _errorID = XML_NO_ERROR ; <nl> - _errorStr1 = 0 ; <nl> - _errorStr2 = 0 ; <nl> - <nl> - delete [ ] _charBuffer ; <nl> - _charBuffer = 0 ; <nl> - } <nl> - <nl> - <nl> - XMLElement * XMLDocument : : NewElement ( const char * name ) <nl> - { <nl> - XMLElement * ele = new ( _elementPool . Alloc ( ) ) XMLElement ( this ) ; <nl> - ele - > _memPool = & _elementPool ; <nl> - ele - > SetName ( name ) ; <nl> - return ele ; <nl> - } <nl> - <nl> - <nl> - XMLComment * XMLDocument : : NewComment ( const char * str ) <nl> - { <nl> - XMLComment * comment = new ( _commentPool . Alloc ( ) ) XMLComment ( this ) ; <nl> - comment - > _memPool = & _commentPool ; <nl> - comment - > SetValue ( str ) ; <nl> - return comment ; <nl> - } <nl> - <nl> - <nl> - XMLText * XMLDocument : : NewText ( const char * str ) <nl> - { <nl> - XMLText * text = new ( _textPool . Alloc ( ) ) XMLText ( this ) ; <nl> - text - > _memPool = & _textPool ; <nl> - text - > SetValue ( str ) ; <nl> - return text ; <nl> - } <nl> - <nl> - <nl> - XMLDeclaration * XMLDocument : : NewDeclaration ( const char * str ) <nl> - { <nl> - XMLDeclaration * dec = new ( _commentPool . Alloc ( ) ) XMLDeclaration ( this ) ; <nl> - dec - > _memPool = & _commentPool ; <nl> - dec - > SetValue ( str ? str : " xml version = \ " 1 . 0 \ " encoding = \ " UTF - 8 \ " " ) ; <nl> - return dec ; <nl> - } <nl> - <nl> - <nl> - XMLUnknown * XMLDocument : : NewUnknown ( const char * str ) <nl> - { <nl> - XMLUnknown * unk = new ( _commentPool . Alloc ( ) ) XMLUnknown ( this ) ; <nl> - unk - > _memPool = & _commentPool ; <nl> - unk - > SetValue ( str ) ; <nl> - return unk ; <nl> - } <nl> - <nl> - <nl> - XMLError XMLDocument : : LoadFile ( const char * filename ) <nl> - { <nl> - DeleteChildren ( ) ; <nl> - InitDocument ( ) ; <nl> - FILE * fp = 0 ; <nl> - <nl> - # if defined ( _MSC_VER ) & & ( _MSC_VER > = 1400 ) & & ( CC_TARGET_PLATFORM ! = CC_PLATFORM_MARMALADE ) <nl> - errno_t err = fopen_s ( & fp , filename , " rb " ) ; <nl> - if ( ! fp | | err ) { <nl> - # else <nl> - fp = fopen ( filename , " rb " ) ; <nl> - if ( ! fp ) { <nl> - # endif <nl> - SetError ( XML_ERROR_FILE_NOT_FOUND , filename , 0 ) ; <nl> - return _errorID ; <nl> - } <nl> - LoadFile ( fp ) ; <nl> - fclose ( fp ) ; <nl> - return _errorID ; <nl> - } <nl> - <nl> - <nl> - XMLError XMLDocument : : LoadFile ( FILE * fp ) <nl> - { <nl> - DeleteChildren ( ) ; <nl> - InitDocument ( ) ; <nl> - <nl> - fseek ( fp , 0 , SEEK_END ) ; <nl> - size_t size = ftell ( fp ) ; <nl> - fseek ( fp , 0 , SEEK_SET ) ; <nl> - <nl> - if ( size = = 0 ) { <nl> - return _errorID ; <nl> - } <nl> - <nl> - _charBuffer = new char [ size + 1 ] ; <nl> - size_t read = fread ( _charBuffer , 1 , size , fp ) ; <nl> - if ( read ! = size ) { <nl> - SetError ( XML_ERROR_FILE_READ_ERROR , 0 , 0 ) ; <nl> - return _errorID ; <nl> - } <nl> - <nl> - _charBuffer [ size ] = 0 ; <nl> - <nl> - const char * p = _charBuffer ; <nl> - p = XMLUtil : : SkipWhiteSpace ( p ) ; <nl> - p = XMLUtil : : ReadBOM ( p , & _writeBOM ) ; <nl> - if ( ! p | | ! * p ) { <nl> - SetError ( XML_ERROR_EMPTY_DOCUMENT , 0 , 0 ) ; <nl> - return _errorID ; <nl> - } <nl> - <nl> - ParseDeep ( _charBuffer + ( p - _charBuffer ) , 0 ) ; <nl> - return _errorID ; <nl> - } <nl> - <nl> - <nl> - XMLError XMLDocument : : SaveFile ( const char * filename , bool compact ) <nl> - { <nl> - FILE * fp = 0 ; <nl> - # if defined ( _MSC_VER ) & & ( _MSC_VER > = 1400 ) & & ( CC_TARGET_PLATFORM ! = CC_PLATFORM_MARMALADE ) <nl> - errno_t err = fopen_s ( & fp , filename , " w " ) ; <nl> - if ( ! fp | | err ) { <nl> - # else <nl> - fp = fopen ( filename , " w " ) ; <nl> - if ( ! fp ) { <nl> - # endif <nl> - SetError ( XML_ERROR_FILE_COULD_NOT_BE_OPENED , filename , 0 ) ; <nl> - return _errorID ; <nl> - } <nl> - SaveFile ( fp , compact ) ; <nl> - fclose ( fp ) ; <nl> - return _errorID ; <nl> - } <nl> - <nl> - <nl> - XMLError XMLDocument : : SaveFile ( FILE * fp , bool compact ) <nl> - { <nl> - XMLPrinter stream ( fp , compact ) ; <nl> - Print ( & stream ) ; <nl> - return _errorID ; <nl> - } <nl> - <nl> - <nl> - XMLError XMLDocument : : Parse ( const char * p , size_t len ) <nl> - { <nl> - DeleteChildren ( ) ; <nl> - InitDocument ( ) ; <nl> - <nl> - if ( ! p | | ! * p ) { <nl> - SetError ( XML_ERROR_EMPTY_DOCUMENT , 0 , 0 ) ; <nl> - return _errorID ; <nl> - } <nl> - if ( len = = ( size_t ) ( - 1 ) ) { <nl> - len = strlen ( p ) ; <nl> - } <nl> - _charBuffer = new char [ len + 1 ] ; <nl> - memcpy ( _charBuffer , p , len ) ; <nl> - _charBuffer [ len ] = 0 ; <nl> - <nl> - p = XMLUtil : : SkipWhiteSpace ( p ) ; <nl> - p = XMLUtil : : ReadBOM ( p , & _writeBOM ) ; <nl> - if ( ! p | | ! * p ) { <nl> - SetError ( XML_ERROR_EMPTY_DOCUMENT , 0 , 0 ) ; <nl> - return _errorID ; <nl> - } <nl> - <nl> - ParseDeep ( _charBuffer , 0 ) ; <nl> - return _errorID ; <nl> - } <nl> - <nl> - <nl> - void XMLDocument : : Print ( XMLPrinter * streamer ) <nl> - { <nl> - XMLPrinter stdStreamer ( stdout ) ; <nl> - if ( ! streamer ) { <nl> - streamer = & stdStreamer ; <nl> - } <nl> - Accept ( streamer ) ; <nl> - } <nl> - <nl> - <nl> - void XMLDocument : : SetError ( XMLError error , const char * str1 , const char * str2 ) <nl> - { <nl> - _errorID = error ; <nl> - _errorStr1 = str1 ; <nl> - _errorStr2 = str2 ; <nl> - } <nl> - <nl> - <nl> - void XMLDocument : : PrintError ( ) const <nl> - { <nl> - if ( _errorID ) { <nl> - static const int LEN = 20 ; <nl> - char buf1 [ LEN ] = { 0 } ; <nl> - char buf2 [ LEN ] = { 0 } ; <nl> - <nl> - if ( _errorStr1 ) { <nl> - TIXML_SNPRINTF ( buf1 , LEN , " % s " , _errorStr1 ) ; <nl> - } <nl> - if ( _errorStr2 ) { <nl> - TIXML_SNPRINTF ( buf2 , LEN , " % s " , _errorStr2 ) ; <nl> - } <nl> - <nl> - printf ( " XMLDocument error id = % d str1 = % s str2 = % s \ n " , <nl> - _errorID , buf1 , buf2 ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - XMLPrinter : : XMLPrinter ( FILE * file , bool compact ) : <nl> - _elementJustOpened ( false ) , <nl> - _firstElement ( true ) , <nl> - _fp ( file ) , <nl> - _depth ( 0 ) , <nl> - _textDepth ( - 1 ) , <nl> - _processEntities ( true ) , <nl> - _compactMode ( compact ) <nl> - { <nl> - for ( int i = 0 ; i < ENTITY_RANGE ; + + i ) { <nl> - _entityFlag [ i ] = false ; <nl> - _restrictedEntityFlag [ i ] = false ; <nl> - } <nl> - for ( int i = 0 ; i < NUM_ENTITIES ; + + i ) { <nl> - TIXMLASSERT ( entities [ i ] . value < ENTITY_RANGE ) ; <nl> - if ( entities [ i ] . value < ENTITY_RANGE ) { <nl> - _entityFlag [ ( int ) entities [ i ] . value ] = true ; <nl> - } <nl> - } <nl> - _restrictedEntityFlag [ ( int ) ' & ' ] = true ; <nl> - _restrictedEntityFlag [ ( int ) ' < ' ] = true ; <nl> - _restrictedEntityFlag [ ( int ) ' > ' ] = true ; / / not required , but consistency is nice <nl> - _buffer . Push ( 0 ) ; <nl> - } <nl> - <nl> - <nl> - void XMLPrinter : : Print ( const char * format , . . . ) <nl> - { <nl> - va_list va ; <nl> - va_start ( va , format ) ; <nl> - <nl> - if ( _fp ) { <nl> - vfprintf ( _fp , format , va ) ; <nl> - } <nl> - else { <nl> - / / This seems brutally complex . Haven ' t figured out a better <nl> - / / way on windows . <nl> - # if defined _MSC_VER & & ( CC_TARGET_PLATFORM ! = CC_PLATFORM_MARMALADE ) <nl> - int len = - 1 ; <nl> - int expand = 1000 ; <nl> - while ( len < 0 ) { <nl> - len = vsnprintf_s ( _accumulator . Mem ( ) , _accumulator . Capacity ( ) , _TRUNCATE , format , va ) ; <nl> - if ( len < 0 ) { <nl> - expand * = 3 / 2 ; <nl> - _accumulator . PushArr ( expand ) ; <nl> - } <nl> - } <nl> - char * p = _buffer . PushArr ( len ) - 1 ; <nl> - memcpy ( p , _accumulator . Mem ( ) , len + 1 ) ; <nl> - # else <nl> - int len = vsnprintf ( 0 , 0 , format , va ) ; <nl> - / / Close out and re - start the va - args <nl> - va_end ( va ) ; <nl> - va_start ( va , format ) ; <nl> - char * p = _buffer . PushArr ( len ) - 1 ; <nl> - vsnprintf ( p , len + 1 , format , va ) ; <nl> - # endif <nl> - } <nl> - va_end ( va ) ; <nl> - } <nl> - <nl> - <nl> - void XMLPrinter : : PrintSpace ( int depth ) <nl> - { <nl> - for ( int i = 0 ; i < depth ; + + i ) { <nl> - Print ( " " ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - void XMLPrinter : : PrintString ( const char * p , bool restricted ) <nl> - { <nl> - / / Look for runs of bytes between entities to print . <nl> - const char * q = p ; <nl> - const bool * flag = restricted ? _restrictedEntityFlag : _entityFlag ; <nl> - <nl> - if ( _processEntities ) { <nl> - while ( * q ) { <nl> - / / Remember , char is sometimes signed . ( How many times has that bitten me ? ) <nl> - if ( * q > 0 & & * q < ENTITY_RANGE ) { <nl> - / / Check for entities . If one is found , flush <nl> - / / the stream up until the entity , write the <nl> - / / entity , and keep looking . <nl> - if ( flag [ ( unsigned ) ( * q ) ] ) { <nl> - while ( p < q ) { <nl> - Print ( " % c " , * p ) ; <nl> - + + p ; <nl> - } <nl> - for ( int i = 0 ; i < NUM_ENTITIES ; + + i ) { <nl> - if ( entities [ i ] . value = = * q ) { <nl> - Print ( " & % s ; " , entities [ i ] . pattern ) ; <nl> - break ; <nl> - } <nl> - } <nl> - + + p ; <nl> - } <nl> - } <nl> - + + q ; <nl> - } <nl> - } <nl> - / / Flush the remaining string . This will be the entire <nl> - / / string if an entity wasn ' t found . <nl> - if ( ! _processEntities | | ( q - p > 0 ) ) { <nl> - Print ( " % s " , p ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - void XMLPrinter : : PushHeader ( bool writeBOM , bool writeDec ) <nl> - { <nl> - static const unsigned char bom [ ] = { TIXML_UTF_LEAD_0 , TIXML_UTF_LEAD_1 , TIXML_UTF_LEAD_2 , 0 } ; <nl> - if ( writeBOM ) { <nl> - Print ( " % s " , bom ) ; <nl> - } <nl> - if ( writeDec ) { <nl> - PushDeclaration ( " xml version = \ " 1 . 0 \ " " ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - void XMLPrinter : : OpenElement ( const char * name ) <nl> - { <nl> - if ( _elementJustOpened ) { <nl> - SealElement ( ) ; <nl> - } <nl> - _stack . Push ( name ) ; <nl> - <nl> - if ( _textDepth < 0 & & ! _firstElement & & ! _compactMode ) { <nl> - Print ( " \ n " ) ; <nl> - PrintSpace ( _depth ) ; <nl> - } <nl> - <nl> - Print ( " < % s " , name ) ; <nl> - _elementJustOpened = true ; <nl> - _firstElement = false ; <nl> - + + _depth ; <nl> - } <nl> - <nl> - <nl> - void XMLPrinter : : PushAttribute ( const char * name , const char * value ) <nl> - { <nl> - TIXMLASSERT ( _elementJustOpened ) ; <nl> - Print ( " % s = \ " " , name ) ; <nl> - PrintString ( value , false ) ; <nl> - Print ( " \ " " ) ; <nl> - } <nl> - <nl> - <nl> - void XMLPrinter : : PushAttribute ( const char * name , int v ) <nl> - { <nl> - char buf [ BUF_SIZE ] ; <nl> - XMLUtil : : ToStr ( v , buf , BUF_SIZE ) ; <nl> - PushAttribute ( name , buf ) ; <nl> - } <nl> - <nl> - <nl> - void XMLPrinter : : PushAttribute ( const char * name , unsigned v ) <nl> - { <nl> - char buf [ BUF_SIZE ] ; <nl> - XMLUtil : : ToStr ( v , buf , BUF_SIZE ) ; <nl> - PushAttribute ( name , buf ) ; <nl> - } <nl> - <nl> - <nl> - void XMLPrinter : : PushAttribute ( const char * name , bool v ) <nl> - { <nl> - char buf [ BUF_SIZE ] ; <nl> - XMLUtil : : ToStr ( v , buf , BUF_SIZE ) ; <nl> - PushAttribute ( name , buf ) ; <nl> - } <nl> - <nl> - <nl> - void XMLPrinter : : PushAttribute ( const char * name , double v ) <nl> - { <nl> - char buf [ BUF_SIZE ] ; <nl> - XMLUtil : : ToStr ( v , buf , BUF_SIZE ) ; <nl> - PushAttribute ( name , buf ) ; <nl> - } <nl> - <nl> - <nl> - void XMLPrinter : : CloseElement ( ) <nl> - { <nl> - - - _depth ; <nl> - const char * name = _stack . Pop ( ) ; <nl> - <nl> - if ( _elementJustOpened ) { <nl> - Print ( " / > " ) ; <nl> - } <nl> - else { <nl> - if ( _textDepth < 0 & & ! _compactMode ) { <nl> - Print ( " \ n " ) ; <nl> - PrintSpace ( _depth ) ; <nl> - } <nl> - Print ( " < / % s > " , name ) ; <nl> - } <nl> - <nl> - if ( _textDepth = = _depth ) { <nl> - _textDepth = - 1 ; <nl> - } <nl> - if ( _depth = = 0 & & ! _compactMode ) { <nl> - Print ( " \ n " ) ; <nl> - } <nl> - _elementJustOpened = false ; <nl> - } <nl> - <nl> - <nl> - void XMLPrinter : : SealElement ( ) <nl> - { <nl> - _elementJustOpened = false ; <nl> - Print ( " > " ) ; <nl> - } <nl> - <nl> - <nl> - void XMLPrinter : : PushText ( const char * text , bool cdata ) <nl> - { <nl> - _textDepth = _depth - 1 ; <nl> - <nl> - if ( _elementJustOpened ) { <nl> - SealElement ( ) ; <nl> - } <nl> - if ( cdata ) { <nl> - Print ( " < ! [ CDATA [ " ) ; <nl> - Print ( " % s " , text ) ; <nl> - Print ( " ] ] > " ) ; <nl> - } <nl> - else { <nl> - PrintString ( text , true ) ; <nl> - } <nl> - } <nl> - <nl> - void XMLPrinter : : PushText ( int value ) <nl> - { <nl> - char buf [ BUF_SIZE ] ; <nl> - XMLUtil : : ToStr ( value , buf , BUF_SIZE ) ; <nl> - PushText ( buf , false ) ; <nl> - } <nl> - <nl> - <nl> - void XMLPrinter : : PushText ( unsigned value ) <nl> - { <nl> - char buf [ BUF_SIZE ] ; <nl> - XMLUtil : : ToStr ( value , buf , BUF_SIZE ) ; <nl> - PushText ( buf , false ) ; <nl> - } <nl> - <nl> - <nl> - void XMLPrinter : : PushText ( bool value ) <nl> - { <nl> - char buf [ BUF_SIZE ] ; <nl> - XMLUtil : : ToStr ( value , buf , BUF_SIZE ) ; <nl> - PushText ( buf , false ) ; <nl> - } <nl> - <nl> - <nl> - void XMLPrinter : : PushText ( float value ) <nl> - { <nl> - char buf [ BUF_SIZE ] ; <nl> - XMLUtil : : ToStr ( value , buf , BUF_SIZE ) ; <nl> - PushText ( buf , false ) ; <nl> - } <nl> - <nl> - <nl> - void XMLPrinter : : PushText ( double value ) <nl> - { <nl> - char buf [ BUF_SIZE ] ; <nl> - XMLUtil : : ToStr ( value , buf , BUF_SIZE ) ; <nl> - PushText ( buf , false ) ; <nl> - } <nl> - <nl> - <nl> - void XMLPrinter : : PushComment ( const char * comment ) <nl> - { <nl> - if ( _elementJustOpened ) { <nl> - SealElement ( ) ; <nl> - } <nl> - if ( _textDepth < 0 & & ! _firstElement & & ! _compactMode ) { <nl> - Print ( " \ n " ) ; <nl> - PrintSpace ( _depth ) ; <nl> - } <nl> - _firstElement = false ; <nl> - Print ( " < ! - - % s - - > " , comment ) ; <nl> - } <nl> - <nl> - <nl> - void XMLPrinter : : PushDeclaration ( const char * value ) <nl> - { <nl> - if ( _elementJustOpened ) { <nl> - SealElement ( ) ; <nl> - } <nl> - if ( _textDepth < 0 & & ! _firstElement & & ! _compactMode ) { <nl> - Print ( " \ n " ) ; <nl> - PrintSpace ( _depth ) ; <nl> - } <nl> - _firstElement = false ; <nl> - Print ( " < ? % s ? > " , value ) ; <nl> - } <nl> - <nl> - <nl> - void XMLPrinter : : PushUnknown ( const char * value ) <nl> - { <nl> - if ( _elementJustOpened ) { <nl> - SealElement ( ) ; <nl> - } <nl> - if ( _textDepth < 0 & & ! _firstElement & & ! _compactMode ) { <nl> - Print ( " \ n " ) ; <nl> - PrintSpace ( _depth ) ; <nl> - } <nl> - _firstElement = false ; <nl> - Print ( " < ! % s > " , value ) ; <nl> - } <nl> - <nl> - <nl> - bool XMLPrinter : : VisitEnter ( const XMLDocument & doc ) <nl> - { <nl> - _processEntities = doc . ProcessEntities ( ) ; <nl> - if ( doc . HasBOM ( ) ) { <nl> - PushHeader ( true , false ) ; <nl> - } <nl> - return true ; <nl> - } <nl> - <nl> - <nl> - bool XMLPrinter : : VisitEnter ( const XMLElement & element , const XMLAttribute * attribute ) <nl> - { <nl> - OpenElement ( element . Name ( ) ) ; <nl> - while ( attribute ) { <nl> - PushAttribute ( attribute - > Name ( ) , attribute - > Value ( ) ) ; <nl> - attribute = attribute - > Next ( ) ; <nl> - } <nl> - return true ; <nl> - } <nl> - <nl> - <nl> - bool XMLPrinter : : VisitExit ( const XMLElement & ) <nl> - { <nl> - CloseElement ( ) ; <nl> - return true ; <nl> - } <nl> - <nl> - <nl> - bool XMLPrinter : : Visit ( const XMLText & text ) <nl> - { <nl> - PushText ( text . Value ( ) , text . CData ( ) ) ; <nl> - return true ; <nl> - } <nl> - <nl> - <nl> - bool XMLPrinter : : Visit ( const XMLComment & comment ) <nl> - { <nl> - PushComment ( comment . Value ( ) ) ; <nl> - return true ; <nl> - } <nl> - <nl> - bool XMLPrinter : : Visit ( const XMLDeclaration & declaration ) <nl> - { <nl> - PushDeclaration ( declaration . Value ( ) ) ; <nl> - return true ; <nl> - } <nl> - <nl> - <nl> - bool XMLPrinter : : Visit ( const XMLUnknown & unknown ) <nl> - { <nl> - PushUnknown ( unknown . Value ( ) ) ; <nl> - return true ; <nl> - } <nl> - <nl> - } / / namespace tinyxml2 <nl> - <nl> deleted file mode 100644 <nl> index eeffa1096f24 . . 000000000000 <nl> mmm a / cocos / 2d / support / tinyxml2 / tinyxml2 . h <nl> ppp / dev / null <nl> <nl> - / * <nl> - Original code by Lee Thomason ( www . grinninglizard . com ) <nl> - <nl> - This software is provided ' as - is ' , without any express or implied <nl> - warranty . In no event will the authors be held liable for any <nl> - damages arising from the use of this software . <nl> - <nl> - Permission is granted to anyone to use this software for any <nl> - purpose , including commercial applications , and to alter it and <nl> - redistribute it freely , subject to the following restrictions : <nl> - <nl> - 1 . The origin of this software must not be misrepresented ; you must <nl> - not claim that you wrote the original software . If you use this <nl> - software in a product , an acknowledgment in the product documentation <nl> - would be appreciated but is not required . <nl> - <nl> - 2 . Altered source versions must be plainly marked as such , and <nl> - must not be misrepresented as being the original software . <nl> - <nl> - 3 . This notice may not be removed or altered from any source <nl> - distribution . <nl> - * / <nl> - <nl> - # ifndef TINYXML2_INCLUDED <nl> - # define TINYXML2_INCLUDED <nl> - <nl> - # include " platform / CCPlatformConfig . h " <nl> - # include " platform / CCPlatformMacros . h " <nl> - <nl> - # if defined ( ANDROID_NDK ) | | defined ( __BORLANDC__ ) | | ( CC_TARGET_PLATFORM = = CC_PLATFORM_BLACKBERRY ) <nl> - # include < ctype . h > <nl> - # include < limits . h > <nl> - # include < stdio . h > <nl> - # include < stdlib . h > <nl> - # include < string . h > <nl> - # include < stdarg . h > <nl> - # else <nl> - # include < cctype > <nl> - # include < climits > <nl> - # include < cstdio > <nl> - # include < cstdlib > <nl> - # include < cstring > <nl> - # include < cstdarg > <nl> - # endif <nl> - <nl> - / * <nl> - TODO : intern strings instead of allocation . <nl> - * / <nl> - / * <nl> - gcc : <nl> - g + + - Wall - DDEBUG tinyxml2 . cpp xmltest . cpp - o gccxmltest . exe <nl> - <nl> - Formatting , Artistic Style : <nl> - AStyle . exe - - style = 1tbs - - indent - switches - - break - closing - brackets - - indent - preprocessor tinyxml2 . cpp tinyxml2 . h <nl> - * / <nl> - <nl> - # if defined ( _DEBUG ) | | defined ( DEBUG ) | | defined ( __DEBUG__ ) <nl> - # ifndef DEBUG <nl> - # define DEBUG <nl> - # endif <nl> - # endif <nl> - <nl> - <nl> - # if defined ( DEBUG ) <nl> - # if defined ( _MSC_VER ) <nl> - # define TIXMLASSERT ( x ) if ( ! ( x ) ) { __debugbreak ( ) ; } / / if ( ! ( x ) ) WinDebugBreak ( ) <nl> - # elif defined ( ANDROID_NDK ) <nl> - # include < android / log . h > <nl> - # define TIXMLASSERT ( x ) if ( ! ( x ) ) { __android_log_assert ( " assert " , " grinliz " , " ASSERT in ' % s ' at % d . " , __FILE__ , __LINE__ ) ; } <nl> - # else <nl> - # include < assert . h > <nl> - # define TIXMLASSERT assert <nl> - # endif <nl> - # else <nl> - # define TIXMLASSERT ( x ) { } <nl> - # endif <nl> - <nl> - <nl> - # if ( defined ( _MSC_VER ) & & ( _MSC_VER > = 1400 ) & & ( CC_TARGET_PLATFORM ! = CC_PLATFORM_MARMALADE ) ) <nl> - / / Microsoft visual studio , version 2005 and higher . <nl> - / * int _snprintf_s ( <nl> - char * buffer , <nl> - size_t sizeOfBuffer , <nl> - size_t count , <nl> - const char * format [ , <nl> - argument ] . . . <nl> - ) ; * / <nl> - inline int TIXML_SNPRINTF ( char * buffer , size_t size , const char * format , . . . ) <nl> - { <nl> - va_list va ; <nl> - va_start ( va , format ) ; <nl> - int result = vsnprintf_s ( buffer , size , _TRUNCATE , format , va ) ; <nl> - va_end ( va ) ; <nl> - return result ; <nl> - } <nl> - # define TIXML_SSCANF sscanf_s <nl> - # else <nl> - / / GCC version 3 and higher <nl> - / / # warning ( " Using sn * functions . " ) <nl> - # define TIXML_SNPRINTF snprintf <nl> - # define TIXML_SSCANF sscanf <nl> - # endif <nl> - <nl> - static const int TIXML2_MAJOR_VERSION = 1 ; <nl> - static const int TIXML2_MINOR_VERSION = 0 ; <nl> - static const int TIXML2_PATCH_VERSION = 9 ; <nl> - <nl> - namespace tinyxml2 <nl> - { <nl> - class XMLDocument ; <nl> - class XMLElement ; <nl> - class XMLAttribute ; <nl> - class XMLComment ; <nl> - class XMLNode ; <nl> - class XMLText ; <nl> - class XMLDeclaration ; <nl> - class XMLUnknown ; <nl> - <nl> - class XMLPrinter ; <nl> - <nl> - / * <nl> - A class that wraps strings . Normally stores the start and end <nl> - pointers into the XML file itself , and will apply normalization <nl> - and entity translation if actually read . Can also store ( and memory <nl> - manage ) a traditional char [ ] <nl> - * / <nl> - class CC_DLL StrPair <nl> - { <nl> - public : <nl> - enum { <nl> - NEEDS_ENTITY_PROCESSING = 0x01 , <nl> - NEEDS_NEWLINE_NORMALIZATION = 0x02 , <nl> - COLLAPSE_WHITESPACE = 0x04 , <nl> - <nl> - TEXT_ELEMENT = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION , <nl> - TEXT_ELEMENT_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION , <nl> - ATTRIBUTE_NAME = 0 , <nl> - ATTRIBUTE_VALUE = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION , <nl> - ATTRIBUTE_VALUE_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION , <nl> - COMMENT = NEEDS_NEWLINE_NORMALIZATION <nl> - } ; <nl> - <nl> - StrPair ( ) : _flags ( 0 ) , _start ( 0 ) , _end ( 0 ) { } <nl> - ~ StrPair ( ) ; <nl> - <nl> - void Set ( char * start , char * end , int flags ) { <nl> - Reset ( ) ; <nl> - _start = start ; <nl> - _end = end ; <nl> - _flags = flags | NEEDS_FLUSH ; <nl> - } <nl> - <nl> - const char * GetStr ( ) ; <nl> - <nl> - bool Empty ( ) const { <nl> - return _start = = _end ; <nl> - } <nl> - <nl> - void SetInternedStr ( const char * str ) { <nl> - Reset ( ) ; <nl> - _start = const_cast < char * > ( str ) ; <nl> - } <nl> - <nl> - void SetStr ( const char * str , int flags = 0 ) ; <nl> - <nl> - char * ParseText ( char * in , const char * endTag , int strFlags ) ; <nl> - char * ParseName ( char * in ) ; <nl> - <nl> - private : <nl> - void Reset ( ) ; <nl> - void CollapseWhitespace ( ) ; <nl> - <nl> - enum { <nl> - NEEDS_FLUSH = 0x100 , <nl> - NEEDS_DELETE = 0x200 <nl> - } ; <nl> - <nl> - / / After parsing , if * end ! = 0 , it can be set to zero . <nl> - int _flags ; <nl> - char * _start ; <nl> - char * _end ; <nl> - } ; <nl> - <nl> - <nl> - / * <nl> - A dynamic array of Plain Old Data . Doesn ' t support constructors , etc . <nl> - Has a small initial memory pool , so that low or no usage will not <nl> - cause a call to new / delete <nl> - * / <nl> - template < class T , int INIT > <nl> - class CC_DLL DynArray <nl> - { <nl> - public : <nl> - DynArray < T , INIT > ( ) { <nl> - _mem = _pool ; <nl> - _allocated = INIT ; <nl> - _size = 0 ; <nl> - } <nl> - <nl> - ~ DynArray ( ) { <nl> - if ( _mem ! = _pool ) { <nl> - delete [ ] _mem ; <nl> - } <nl> - } <nl> - <nl> - void Push ( T t ) { <nl> - EnsureCapacity ( _size + 1 ) ; <nl> - _mem [ _size + + ] = t ; <nl> - } <nl> - <nl> - T * PushArr ( int count ) { <nl> - EnsureCapacity ( _size + count ) ; <nl> - T * ret = & _mem [ _size ] ; <nl> - _size + = count ; <nl> - return ret ; <nl> - } <nl> - <nl> - T Pop ( ) { <nl> - return _mem [ - - _size ] ; <nl> - } <nl> - <nl> - void PopArr ( int count ) { <nl> - TIXMLASSERT ( _size > = count ) ; <nl> - _size - = count ; <nl> - } <nl> - <nl> - bool Empty ( ) const { <nl> - return _size = = 0 ; <nl> - } <nl> - <nl> - T & operator [ ] ( int i ) { <nl> - TIXMLASSERT ( i > = 0 & & i < _size ) ; <nl> - return _mem [ i ] ; <nl> - } <nl> - <nl> - const T & operator [ ] ( int i ) const { <nl> - TIXMLASSERT ( i > = 0 & & i < _size ) ; <nl> - return _mem [ i ] ; <nl> - } <nl> - <nl> - int Size ( ) const { <nl> - return _size ; <nl> - } <nl> - <nl> - int Capacity ( ) const { <nl> - return _allocated ; <nl> - } <nl> - <nl> - const T * Mem ( ) const { <nl> - return _mem ; <nl> - } <nl> - <nl> - T * Mem ( ) { <nl> - return _mem ; <nl> - } <nl> - <nl> - private : <nl> - void EnsureCapacity ( int cap ) { <nl> - if ( cap > _allocated ) { <nl> - int newAllocated = cap * 2 ; <nl> - T * newMem = new T [ newAllocated ] ; <nl> - memcpy ( newMem , _mem , sizeof ( T ) * _size ) ; / / warning : not using constructors , only works for PODs <nl> - if ( _mem ! = _pool ) { <nl> - delete [ ] _mem ; <nl> - } <nl> - _mem = newMem ; <nl> - _allocated = newAllocated ; <nl> - } <nl> - } <nl> - <nl> - T * _mem ; <nl> - T _pool [ INIT ] ; <nl> - int _allocated ; / / objects allocated <nl> - int _size ; / / number objects in use <nl> - } ; <nl> - <nl> - <nl> - / * <nl> - Parent virtual class of a pool for fast allocation <nl> - and deallocation of objects . <nl> - * / <nl> - class CC_DLL MemPool <nl> - { <nl> - public : <nl> - MemPool ( ) { } <nl> - virtual ~ MemPool ( ) { } <nl> - <nl> - virtual int ItemSize ( ) const = 0 ; <nl> - virtual void * Alloc ( ) = 0 ; <nl> - virtual void Free ( void * ) = 0 ; <nl> - virtual void SetTracked ( ) = 0 ; <nl> - } ; <nl> - <nl> - <nl> - / * <nl> - Template child class to create pools of the correct type . <nl> - * / <nl> - template < int SIZE > <nl> - class CC_DLL MemPoolT : public MemPool <nl> - { <nl> - public : <nl> - MemPoolT ( ) : _root ( 0 ) , _currentAllocs ( 0 ) , _nAllocs ( 0 ) , _maxAllocs ( 0 ) , _nUntracked ( 0 ) { } <nl> - ~ MemPoolT ( ) { <nl> - / / Delete the blocks . <nl> - for ( int i = 0 ; i < _blockPtrs . Size ( ) ; + + i ) { <nl> - delete _blockPtrs [ i ] ; <nl> - } <nl> - } <nl> - <nl> - virtual int ItemSize ( ) const { <nl> - return SIZE ; <nl> - } <nl> - int CurrentAllocs ( ) const { <nl> - return _currentAllocs ; <nl> - } <nl> - <nl> - virtual void * Alloc ( ) { <nl> - if ( ! _root ) { <nl> - / / Need a new block . <nl> - Block * block = new Block ( ) ; <nl> - _blockPtrs . Push ( block ) ; <nl> - <nl> - for ( int i = 0 ; i < COUNT - 1 ; + + i ) { <nl> - block - > chunk [ i ] . next = & block - > chunk [ i + 1 ] ; <nl> - } <nl> - block - > chunk [ COUNT - 1 ] . next = 0 ; <nl> - _root = block - > chunk ; <nl> - } <nl> - void * result = _root ; <nl> - _root = _root - > next ; <nl> - <nl> - + + _currentAllocs ; <nl> - if ( _currentAllocs > _maxAllocs ) { <nl> - _maxAllocs = _currentAllocs ; <nl> - } <nl> - _nAllocs + + ; <nl> - _nUntracked + + ; <nl> - return result ; <nl> - } <nl> - virtual void Free ( void * mem ) { <nl> - if ( ! mem ) { <nl> - return ; <nl> - } <nl> - - - _currentAllocs ; <nl> - Chunk * chunk = ( Chunk * ) mem ; <nl> - # ifdef DEBUG <nl> - memset ( chunk , 0xfe , sizeof ( Chunk ) ) ; <nl> - # endif <nl> - chunk - > next = _root ; <nl> - _root = chunk ; <nl> - } <nl> - void Trace ( const char * name ) { <nl> - printf ( " Mempool % s watermark = % d [ % dk ] current = % d size = % d nAlloc = % d blocks = % d \ n " , <nl> - name , _maxAllocs , _maxAllocs * SIZE / 1024 , _currentAllocs , SIZE , _nAllocs , _blockPtrs . Size ( ) ) ; <nl> - } <nl> - <nl> - void SetTracked ( ) { <nl> - _nUntracked - - ; <nl> - } <nl> - <nl> - int Untracked ( ) const { <nl> - return _nUntracked ; <nl> - } <nl> - <nl> - enum { COUNT = 1024 / SIZE } ; / / Some compilers do not accept to use COUNT in private part if COUNT is private <nl> - <nl> - private : <nl> - union Chunk { <nl> - Chunk * next ; <nl> - char mem [ SIZE ] ; <nl> - } ; <nl> - struct Block { <nl> - Chunk chunk [ COUNT ] ; <nl> - } ; <nl> - DynArray < Block * , 10 > _blockPtrs ; <nl> - Chunk * _root ; <nl> - <nl> - int _currentAllocs ; <nl> - int _nAllocs ; <nl> - int _maxAllocs ; <nl> - int _nUntracked ; <nl> - } ; <nl> - <nl> - <nl> - <nl> - / * * <nl> - Implements the interface to the " Visitor pattern " ( see the Accept ( ) method . ) <nl> - If you call the Accept ( ) method , it requires being passed a XMLVisitor <nl> - class to handle callbacks . For nodes that contain other nodes ( Document , Element ) <nl> - you will get called with a VisitEnter / VisitExit pair . Nodes that are always leafs <nl> - are simply called with Visit ( ) . <nl> - <nl> - If you return ' true ' from a Visit method , recursive parsing will continue . If you return <nl> - false , < b > no children of this node or its sibilings < / b > will be visited . <nl> - <nl> - All flavors of Visit methods have a default implementation that returns ' true ' ( continue <nl> - visiting ) . You need to only override methods that are interesting to you . <nl> - <nl> - Generally Accept ( ) is called on the TiXmlDocument , although all nodes support visiting . <nl> - <nl> - You should never change the document from a callback . <nl> - <nl> - @ sa XMLNode : : Accept ( ) <nl> - * / <nl> - class CC_DLL XMLVisitor <nl> - { <nl> - public : <nl> - virtual ~ XMLVisitor ( ) { } <nl> - <nl> - / / / Visit a document . <nl> - virtual bool VisitEnter ( const XMLDocument & / * doc * / ) { <nl> - return true ; <nl> - } <nl> - / / / Visit a document . <nl> - virtual bool VisitExit ( const XMLDocument & / * doc * / ) { <nl> - return true ; <nl> - } <nl> - <nl> - / / / Visit an element . <nl> - virtual bool VisitEnter ( const XMLElement & / * element * / , const XMLAttribute * / * firstAttribute * / ) { <nl> - return true ; <nl> - } <nl> - / / / Visit an element . <nl> - virtual bool VisitExit ( const XMLElement & / * element * / ) { <nl> - return true ; <nl> - } <nl> - <nl> - / / / Visit a declaration . <nl> - virtual bool Visit ( const XMLDeclaration & / * declaration * / ) { <nl> - return true ; <nl> - } <nl> - / / / Visit a text node . <nl> - virtual bool Visit ( const XMLText & / * text * / ) { <nl> - return true ; <nl> - } <nl> - / / / Visit a comment node . <nl> - virtual bool Visit ( const XMLComment & / * comment * / ) { <nl> - return true ; <nl> - } <nl> - / / / Visit an unknown node . <nl> - virtual bool Visit ( const XMLUnknown & / * unknown * / ) { <nl> - return true ; <nl> - } <nl> - } ; <nl> - <nl> - <nl> - / * <nl> - Utility functionality . <nl> - * / <nl> - class CC_DLL XMLUtil <nl> - { <nl> - public : <nl> - / / Anything in the high order range of UTF - 8 is assumed to not be whitespace . This isn ' t <nl> - / / correct , but simple , and usually works . <nl> - static const char * SkipWhiteSpace ( const char * p ) { <nl> - while ( ! IsUTF8Continuation ( * p ) & & isspace ( * reinterpret_cast < const unsigned char * > ( p ) ) ) { <nl> - + + p ; <nl> - } <nl> - return p ; <nl> - } <nl> - static char * SkipWhiteSpace ( char * p ) { <nl> - while ( ! IsUTF8Continuation ( * p ) & & isspace ( * reinterpret_cast < unsigned char * > ( p ) ) ) { <nl> - + + p ; <nl> - } <nl> - return p ; <nl> - } <nl> - static bool IsWhiteSpace ( char p ) { <nl> - return ! IsUTF8Continuation ( p ) & & isspace ( static_cast < unsigned char > ( p ) ) ; <nl> - } <nl> - <nl> - inline static bool StringEqual ( const char * p , const char * q , int nChar = INT_MAX ) { <nl> - int n = 0 ; <nl> - if ( p = = q ) { <nl> - return true ; <nl> - } <nl> - while ( * p & & * q & & * p = = * q & & n < nChar ) { <nl> - + + p ; <nl> - + + q ; <nl> - + + n ; <nl> - } <nl> - if ( ( n = = nChar ) | | ( * p = = 0 & & * q = = 0 ) ) { <nl> - return true ; <nl> - } <nl> - return false ; <nl> - } <nl> - inline static int IsUTF8Continuation ( const char p ) { <nl> - return p & 0x80 ; <nl> - } <nl> - inline static int IsAlphaNum ( unsigned char anyByte ) { <nl> - return ( anyByte < 128 ) ? isalnum ( anyByte ) : 1 ; <nl> - } <nl> - inline static int IsAlpha ( unsigned char anyByte ) { <nl> - return ( anyByte < 128 ) ? isalpha ( anyByte ) : 1 ; <nl> - } <nl> - <nl> - static const char * ReadBOM ( const char * p , bool * hasBOM ) ; <nl> - / / p is the starting location , <nl> - / / the UTF - 8 value of the entity will be placed in value , and length filled in . <nl> - static const char * GetCharacterRef ( const char * p , char * value , int * length ) ; <nl> - static void ConvertUTF32ToUTF8 ( unsigned long input , char * output , int * length ) ; <nl> - <nl> - / / converts primitive types to strings <nl> - static void ToStr ( int v , char * buffer , int bufferSize ) ; <nl> - static void ToStr ( unsigned v , char * buffer , int bufferSize ) ; <nl> - static void ToStr ( bool v , char * buffer , int bufferSize ) ; <nl> - static void ToStr ( float v , char * buffer , int bufferSize ) ; <nl> - static void ToStr ( double v , char * buffer , int bufferSize ) ; <nl> - <nl> - / / converts strings to primitive types <nl> - static bool ToInt ( const char * str , int * value ) ; <nl> - static bool ToUnsigned ( const char * str , unsigned * value ) ; <nl> - static bool ToBool ( const char * str , bool * value ) ; <nl> - static bool ToFloat ( const char * str , float * value ) ; <nl> - static bool ToDouble ( const char * str , double * value ) ; <nl> - } ; <nl> - <nl> - <nl> - / * * XMLNode is a base class for every object that is in the <nl> - XML Document Object Model ( DOM ) , except XMLAttributes . <nl> - Nodes have siblings , a parent , and children which can <nl> - be navigated . A node is always in a XMLDocument . <nl> - The type of a XMLNode can be queried , and it can <nl> - be cast to its more defined type . <nl> - <nl> - A XMLDocument allocates memory for all its Nodes . <nl> - When the XMLDocument gets deleted , all its Nodes <nl> - will also be deleted . <nl> - <nl> - @ verbatim <nl> - A Document can contain : Element ( container or leaf ) <nl> - Comment ( leaf ) <nl> - Unknown ( leaf ) <nl> - Declaration ( leaf ) <nl> - <nl> - An Element can contain : Element ( container or leaf ) <nl> - Text ( leaf ) <nl> - Attributes ( not on tree ) <nl> - Comment ( leaf ) <nl> - Unknown ( leaf ) <nl> - <nl> - @ endverbatim <nl> - * / <nl> - class CC_DLL XMLNode <nl> - { <nl> - friend class XMLDocument ; <nl> - friend class XMLElement ; <nl> - public : <nl> - <nl> - / / / Get the XMLDocument that owns this XMLNode . <nl> - const XMLDocument * GetDocument ( ) const { <nl> - return _document ; <nl> - } <nl> - / / / Get the XMLDocument that owns this XMLNode . <nl> - XMLDocument * GetDocument ( ) { <nl> - return _document ; <nl> - } <nl> - <nl> - / / / Safely cast to an Element , or null . <nl> - virtual XMLElement * ToElement ( ) { <nl> - return 0 ; <nl> - } <nl> - / / / Safely cast to Text , or null . <nl> - virtual XMLText * ToText ( ) { <nl> - return 0 ; <nl> - } <nl> - / / / Safely cast to a Comment , or null . <nl> - virtual XMLComment * ToComment ( ) { <nl> - return 0 ; <nl> - } <nl> - / / / Safely cast to a Document , or null . <nl> - virtual XMLDocument * ToDocument ( ) { <nl> - return 0 ; <nl> - } <nl> - / / / Safely cast to a Declaration , or null . <nl> - virtual XMLDeclaration * ToDeclaration ( ) { <nl> - return 0 ; <nl> - } <nl> - / / / Safely cast to an Unknown , or null . <nl> - virtual XMLUnknown * ToUnknown ( ) { <nl> - return 0 ; <nl> - } <nl> - <nl> - virtual const XMLElement * ToElement ( ) const { <nl> - return 0 ; <nl> - } <nl> - virtual const XMLText * ToText ( ) const { <nl> - return 0 ; <nl> - } <nl> - virtual const XMLComment * ToComment ( ) const { <nl> - return 0 ; <nl> - } <nl> - virtual const XMLDocument * ToDocument ( ) const { <nl> - return 0 ; <nl> - } <nl> - virtual const XMLDeclaration * ToDeclaration ( ) const { <nl> - return 0 ; <nl> - } <nl> - virtual const XMLUnknown * ToUnknown ( ) const { <nl> - return 0 ; <nl> - } <nl> - <nl> - / * * The meaning of ' value ' changes for the specific type . <nl> - @ verbatim <nl> - Document : empty <nl> - Element : name of the element <nl> - Comment : the comment text <nl> - Unknown : the tag contents <nl> - Text : the text string <nl> - @ endverbatim <nl> - * / <nl> - const char * Value ( ) const { <nl> - return _value . GetStr ( ) ; <nl> - } <nl> - <nl> - / * * Set the Value of an XML node . <nl> - @ sa Value ( ) <nl> - * / <nl> - void SetValue ( const char * val , bool staticMem = false ) ; <nl> - <nl> - / / / Get the parent of this node on the DOM . <nl> - const XMLNode * Parent ( ) const { <nl> - return _parent ; <nl> - } <nl> - <nl> - XMLNode * Parent ( ) { <nl> - return _parent ; <nl> - } <nl> - <nl> - / / / Returns true if this node has no children . <nl> - bool NoChildren ( ) const { <nl> - return ! _firstChild ; <nl> - } <nl> - <nl> - / / / Get the first child node , or null if none exists . <nl> - const XMLNode * FirstChild ( ) const { <nl> - return _firstChild ; <nl> - } <nl> - <nl> - XMLNode * FirstChild ( ) { <nl> - return _firstChild ; <nl> - } <nl> - <nl> - / * * Get the first child element , or optionally the first child <nl> - element with the specified name . <nl> - * / <nl> - const XMLElement * FirstChildElement ( const char * value = 0 ) const ; <nl> - <nl> - XMLElement * FirstChildElement ( const char * value = 0 ) { <nl> - return const_cast < XMLElement * > ( const_cast < const XMLNode * > ( this ) - > FirstChildElement ( value ) ) ; <nl> - } <nl> - <nl> - / / / Get the last child node , or null if none exists . <nl> - const XMLNode * LastChild ( ) const { <nl> - return _lastChild ; <nl> - } <nl> - <nl> - XMLNode * LastChild ( ) { <nl> - return const_cast < XMLNode * > ( const_cast < const XMLNode * > ( this ) - > LastChild ( ) ) ; <nl> - } <nl> - <nl> - / * * Get the last child element or optionally the last child <nl> - element with the specified name . <nl> - * / <nl> - const XMLElement * LastChildElement ( const char * value = 0 ) const ; <nl> - <nl> - XMLElement * LastChildElement ( const char * value = 0 ) { <nl> - return const_cast < XMLElement * > ( const_cast < const XMLNode * > ( this ) - > LastChildElement ( value ) ) ; <nl> - } <nl> - <nl> - / / / Get the previous ( left ) sibling node of this node . <nl> - const XMLNode * PreviousSibling ( ) const { <nl> - return _prev ; <nl> - } <nl> - <nl> - XMLNode * PreviousSibling ( ) { <nl> - return _prev ; <nl> - } <nl> - <nl> - / / / Get the previous ( left ) sibling element of this node , with an opitionally supplied name . <nl> - const XMLElement * PreviousSiblingElement ( const char * value = 0 ) const ; <nl> - <nl> - XMLElement * PreviousSiblingElement ( const char * value = 0 ) { <nl> - return const_cast < XMLElement * > ( const_cast < const XMLNode * > ( this ) - > PreviousSiblingElement ( value ) ) ; <nl> - } <nl> - <nl> - / / / Get the next ( right ) sibling node of this node . <nl> - const XMLNode * NextSibling ( ) const { <nl> - return _next ; <nl> - } <nl> - <nl> - XMLNode * NextSibling ( ) { <nl> - return _next ; <nl> - } <nl> - <nl> - / / / Get the next ( right ) sibling element of this node , with an opitionally supplied name . <nl> - const XMLElement * NextSiblingElement ( const char * value = 0 ) const ; <nl> - <nl> - XMLElement * NextSiblingElement ( const char * value = 0 ) { <nl> - return const_cast < XMLElement * > ( const_cast < const XMLNode * > ( this ) - > NextSiblingElement ( value ) ) ; <nl> - } <nl> - <nl> - / * * <nl> - Add a child node as the last ( right ) child . <nl> - * / <nl> - XMLNode * InsertEndChild ( XMLNode * addThis ) ; <nl> - <nl> - XMLNode * LinkEndChild ( XMLNode * addThis ) { <nl> - return InsertEndChild ( addThis ) ; <nl> - } <nl> - / * * <nl> - Add a child node as the first ( left ) child . <nl> - * / <nl> - XMLNode * InsertFirstChild ( XMLNode * addThis ) ; <nl> - / * * <nl> - Add a node after the specified child node . <nl> - * / <nl> - XMLNode * InsertAfterChild ( XMLNode * afterThis , XMLNode * addThis ) ; <nl> - <nl> - / * * <nl> - Delete all the children of this node . <nl> - * / <nl> - void DeleteChildren ( ) ; <nl> - <nl> - / * * <nl> - Delete a child of this node . <nl> - * / <nl> - void DeleteChild ( XMLNode * node ) ; <nl> - <nl> - / * * <nl> - Make a copy of this node , but not its children . <nl> - You may pass in a Document pointer that will be <nl> - the owner of the new Node . If the ' document ' is <nl> - null , then the node returned will be allocated <nl> - from the current Document . ( this - > GetDocument ( ) ) <nl> - <nl> - Note : if called on a XMLDocument , this will return null . <nl> - * / <nl> - virtual XMLNode * ShallowClone ( XMLDocument * document ) const = 0 ; <nl> - <nl> - / * * <nl> - Test if 2 nodes are the same , but don ' t test children . <nl> - The 2 nodes do not need to be in the same Document . <nl> - <nl> - Note : if called on a XMLDocument , this will return false . <nl> - * / <nl> - virtual bool ShallowEqual ( const XMLNode * compare ) const = 0 ; <nl> - <nl> - / * * Accept a hierarchical visit of the nodes in the TinyXML DOM . Every node in the <nl> - XML tree will be conditionally visited and the host will be called back <nl> - via the TiXmlVisitor interface . <nl> - <nl> - This is essentially a SAX interface for TinyXML . ( Note however it doesn ' t re - parse <nl> - the XML for the callbacks , so the performance of TinyXML is unchanged by using this <nl> - interface versus any other . ) <nl> - <nl> - The interface has been based on ideas from : <nl> - <nl> - - http : / / www . saxproject . org / <nl> - - http : / / c2 . com / cgi / wiki ? HierarchicalVisitorPattern <nl> - <nl> - Which are both good references for " visiting " . <nl> - <nl> - An example of using Accept ( ) : <nl> - @ verbatim <nl> - TiXmlPrinter printer ; <nl> - tinyxmlDoc . Accept ( & printer ) ; <nl> - const char * xmlcstr = printer . CStr ( ) ; <nl> - @ endverbatim <nl> - * / <nl> - virtual bool Accept ( XMLVisitor * visitor ) const = 0 ; <nl> - <nl> - / / internal <nl> - virtual char * ParseDeep ( char * , StrPair * ) ; <nl> - <nl> - protected : <nl> - XMLNode ( XMLDocument * ) ; <nl> - virtual ~ XMLNode ( ) ; <nl> - XMLNode ( const XMLNode & ) ; / / not supported <nl> - XMLNode & operator = ( const XMLNode & ) ; / / not supported <nl> - <nl> - XMLDocument * _document ; <nl> - XMLNode * _parent ; <nl> - mutable StrPair _value ; <nl> - <nl> - XMLNode * _firstChild ; <nl> - XMLNode * _lastChild ; <nl> - <nl> - XMLNode * _prev ; <nl> - XMLNode * _next ; <nl> - <nl> - private : <nl> - MemPool * _memPool ; <nl> - void Unlink ( XMLNode * child ) ; <nl> - } ; <nl> - <nl> - <nl> - / * * XML text . <nl> - <nl> - Note that a text node can have child element nodes , for example : <nl> - @ verbatim <nl> - < root > This is < b > bold < / b > < / root > <nl> - @ endverbatim <nl> - <nl> - A text node can have 2 ways to output the next . " normal " output <nl> - and CDATA . It will default to the mode it was parsed from the XML file and <nl> - you generally want to leave it alone , but you can change the output mode with <nl> - SetCDATA ( ) and query it with CDATA ( ) . <nl> - * / <nl> - class CC_DLL XMLText : public XMLNode <nl> - { <nl> - friend class XMLBase ; <nl> - friend class XMLDocument ; <nl> - public : <nl> - virtual bool Accept ( XMLVisitor * visitor ) const ; <nl> - <nl> - virtual XMLText * ToText ( ) { <nl> - return this ; <nl> - } <nl> - virtual const XMLText * ToText ( ) const { <nl> - return this ; <nl> - } <nl> - <nl> - / / / Declare whether this should be CDATA or standard text . <nl> - void SetCData ( bool isCData ) { <nl> - _isCData = isCData ; <nl> - } <nl> - / / / Returns true if this is a CDATA text element . <nl> - bool CData ( ) const { <nl> - return _isCData ; <nl> - } <nl> - <nl> - char * ParseDeep ( char * , StrPair * endTag ) ; <nl> - virtual XMLNode * ShallowClone ( XMLDocument * document ) const ; <nl> - virtual bool ShallowEqual ( const XMLNode * compare ) const ; <nl> - <nl> - protected : <nl> - XMLText ( XMLDocument * doc ) : XMLNode ( doc ) , _isCData ( false ) { } <nl> - virtual ~ XMLText ( ) { } <nl> - XMLText ( const XMLText & ) ; / / not supported <nl> - XMLText & operator = ( const XMLText & ) ; / / not supported <nl> - <nl> - private : <nl> - bool _isCData ; <nl> - } ; <nl> - <nl> - <nl> - / * * An XML Comment . * / <nl> - class CC_DLL XMLComment : public XMLNode <nl> - { <nl> - friend class XMLDocument ; <nl> - public : <nl> - virtual XMLComment * ToComment ( ) { <nl> - return this ; <nl> - } <nl> - virtual const XMLComment * ToComment ( ) const { <nl> - return this ; <nl> - } <nl> - <nl> - virtual bool Accept ( XMLVisitor * visitor ) const ; <nl> - <nl> - char * ParseDeep ( char * , StrPair * endTag ) ; <nl> - virtual XMLNode * ShallowClone ( XMLDocument * document ) const ; <nl> - virtual bool ShallowEqual ( const XMLNode * compare ) const ; <nl> - <nl> - protected : <nl> - XMLComment ( XMLDocument * doc ) ; <nl> - virtual ~ XMLComment ( ) ; <nl> - XMLComment ( const XMLComment & ) ; / / not supported <nl> - XMLComment & operator = ( const XMLComment & ) ; / / not supported <nl> - <nl> - private : <nl> - } ; <nl> - <nl> - <nl> - / * * In correct XML the declaration is the first entry in the file . <nl> - @ verbatim <nl> - < ? xml version = " 1 . 0 " standalone = " yes " ? > <nl> - @ endverbatim <nl> - <nl> - TinyXML2 will happily read or write files without a declaration , <nl> - however . <nl> - <nl> - The text of the declaration isn ' t interpreted . It is parsed <nl> - and written as a string . <nl> - * / <nl> - class CC_DLL XMLDeclaration : public XMLNode <nl> - { <nl> - friend class XMLDocument ; <nl> - public : <nl> - virtual XMLDeclaration * ToDeclaration ( ) { <nl> - return this ; <nl> - } <nl> - virtual const XMLDeclaration * ToDeclaration ( ) const { <nl> - return this ; <nl> - } <nl> - <nl> - virtual bool Accept ( XMLVisitor * visitor ) const ; <nl> - <nl> - char * ParseDeep ( char * , StrPair * endTag ) ; <nl> - virtual XMLNode * ShallowClone ( XMLDocument * document ) const ; <nl> - virtual bool ShallowEqual ( const XMLNode * compare ) const ; <nl> - <nl> - protected : <nl> - XMLDeclaration ( XMLDocument * doc ) ; <nl> - virtual ~ XMLDeclaration ( ) ; <nl> - XMLDeclaration ( const XMLDeclaration & ) ; / / not supported <nl> - XMLDeclaration & operator = ( const XMLDeclaration & ) ; / / not supported <nl> - } ; <nl> - <nl> - <nl> - / * * Any tag that tinyXml doesn ' t recognize is saved as an <nl> - unknown . It is a tag of text , but should not be modified . <nl> - It will be written back to the XML , unchanged , when the file <nl> - is saved . <nl> - <nl> - DTD tags get thrown into TiXmlUnknowns . <nl> - * / <nl> - class CC_DLL XMLUnknown : public XMLNode <nl> - { <nl> - friend class XMLDocument ; <nl> - public : <nl> - virtual XMLUnknown * ToUnknown ( ) { <nl> - return this ; <nl> - } <nl> - virtual const XMLUnknown * ToUnknown ( ) const { <nl> - return this ; <nl> - } <nl> - <nl> - virtual bool Accept ( XMLVisitor * visitor ) const ; <nl> - <nl> - char * ParseDeep ( char * , StrPair * endTag ) ; <nl> - virtual XMLNode * ShallowClone ( XMLDocument * document ) const ; <nl> - virtual bool ShallowEqual ( const XMLNode * compare ) const ; <nl> - <nl> - protected : <nl> - XMLUnknown ( XMLDocument * doc ) ; <nl> - virtual ~ XMLUnknown ( ) ; <nl> - XMLUnknown ( const XMLUnknown & ) ; / / not supported <nl> - XMLUnknown & operator = ( const XMLUnknown & ) ; / / not supported <nl> - } ; <nl> - <nl> - <nl> - enum XMLError { <nl> - XML_NO_ERROR = 0 , <nl> - XML_SUCCESS = 0 , <nl> - <nl> - XML_NO_ATTRIBUTE , <nl> - XML_WRONG_ATTRIBUTE_TYPE , <nl> - <nl> - XML_ERROR_FILE_NOT_FOUND , <nl> - XML_ERROR_FILE_COULD_NOT_BE_OPENED , <nl> - XML_ERROR_FILE_READ_ERROR , <nl> - XML_ERROR_ELEMENT_MISMATCH , <nl> - XML_ERROR_PARSING_ELEMENT , <nl> - XML_ERROR_PARSING_ATTRIBUTE , <nl> - XML_ERROR_IDENTIFYING_TAG , <nl> - XML_ERROR_PARSING_TEXT , <nl> - XML_ERROR_PARSING_CDATA , <nl> - XML_ERROR_PARSING_COMMENT , <nl> - XML_ERROR_PARSING_DECLARATION , <nl> - XML_ERROR_PARSING_UNKNOWN , <nl> - XML_ERROR_EMPTY_DOCUMENT , <nl> - XML_ERROR_MISMATCHED_ELEMENT , <nl> - XML_ERROR_PARSING , <nl> - <nl> - XML_CAN_NOT_CONVERT_TEXT , <nl> - XML_NO_TEXT_NODE <nl> - } ; <nl> - <nl> - <nl> - / * * An attribute is a name - value pair . Elements have an arbitrary <nl> - number of attributes , each with a unique name . <nl> - <nl> - @ note The attributes are not XMLNodes . You may only query the <nl> - Next ( ) attribute in a list . <nl> - * / <nl> - class CC_DLL XMLAttribute <nl> - { <nl> - friend class XMLElement ; <nl> - public : <nl> - / / / The name of the attribute . <nl> - const char * Name ( ) const { <nl> - return _name . GetStr ( ) ; <nl> - } <nl> - / / / The value of the attribute . <nl> - const char * Value ( ) const { <nl> - return _value . GetStr ( ) ; <nl> - } <nl> - / / / The next attribute in the list . <nl> - const XMLAttribute * Next ( ) const { <nl> - return _next ; <nl> - } <nl> - <nl> - / * * IntAttribute interprets the attribute as an integer , and returns the value . <nl> - If the value isn ' t an integer , 0 will be returned . There is no error checking ; <nl> - use QueryIntAttribute ( ) if you need error checking . <nl> - * / <nl> - int IntValue ( ) const { <nl> - int i = 0 ; <nl> - QueryIntValue ( & i ) ; <nl> - return i ; <nl> - } <nl> - / / / Query as an unsigned integer . See IntAttribute ( ) <nl> - unsigned UnsignedValue ( ) const { <nl> - unsigned i = 0 ; <nl> - QueryUnsignedValue ( & i ) ; <nl> - return i ; <nl> - } <nl> - / / / Query as a boolean . See IntAttribute ( ) <nl> - bool BoolValue ( ) const { <nl> - bool b = false ; <nl> - QueryBoolValue ( & b ) ; <nl> - return b ; <nl> - } <nl> - / / / Query as a double . See IntAttribute ( ) <nl> - double DoubleValue ( ) const { <nl> - double d = 0 ; <nl> - QueryDoubleValue ( & d ) ; <nl> - return d ; <nl> - } <nl> - / / / Query as a float . See IntAttribute ( ) <nl> - float FloatValue ( ) const { <nl> - float f = 0 ; <nl> - QueryFloatValue ( & f ) ; <nl> - return f ; <nl> - } <nl> - <nl> - / * * QueryIntAttribute interprets the attribute as an integer , and returns the value <nl> - in the provided paremeter . The function will return XML_NO_ERROR on success , <nl> - and XML_WRONG_ATTRIBUTE_TYPE if the conversion is not successful . <nl> - * / <nl> - XMLError QueryIntValue ( int * value ) const ; <nl> - / / / See QueryIntAttribute <nl> - XMLError QueryUnsignedValue ( unsigned int * value ) const ; <nl> - / / / See QueryIntAttribute <nl> - XMLError QueryBoolValue ( bool * value ) const ; <nl> - / / / See QueryIntAttribute <nl> - XMLError QueryDoubleValue ( double * value ) const ; <nl> - / / / See QueryIntAttribute <nl> - XMLError QueryFloatValue ( float * value ) const ; <nl> - <nl> - / / / Set the attribute to a string value . <nl> - void SetAttribute ( const char * value ) ; <nl> - / / / Set the attribute to value . <nl> - void SetAttribute ( int value ) ; <nl> - / / / Set the attribute to value . <nl> - void SetAttribute ( unsigned value ) ; <nl> - / / / Set the attribute to value . <nl> - void SetAttribute ( bool value ) ; <nl> - / / / Set the attribute to value . <nl> - void SetAttribute ( double value ) ; <nl> - / / / Set the attribute to value . <nl> - void SetAttribute ( float value ) ; <nl> - <nl> - private : <nl> - enum { BUF_SIZE = 200 } ; <nl> - <nl> - XMLAttribute ( ) : _next ( 0 ) { } <nl> - virtual ~ XMLAttribute ( ) { } <nl> - <nl> - XMLAttribute ( const XMLAttribute & ) ; / / not supported <nl> - void operator = ( const XMLAttribute & ) ; / / not supported <nl> - void SetName ( const char * name ) ; <nl> - <nl> - char * ParseDeep ( char * p , bool processEntities ) ; <nl> - <nl> - mutable StrPair _name ; <nl> - mutable StrPair _value ; <nl> - XMLAttribute * _next ; <nl> - MemPool * _memPool ; <nl> - } ; <nl> - <nl> - <nl> - / * * The element is a container class . It has a value , the element name , <nl> - and can contain other elements , text , comments , and unknowns . <nl> - Elements also contain an arbitrary number of attributes . <nl> - * / <nl> - class CC_DLL XMLElement : public XMLNode <nl> - { <nl> - friend class XMLBase ; <nl> - friend class XMLDocument ; <nl> - public : <nl> - / / / Get the name of an element ( which is the Value ( ) of the node . ) <nl> - const char * Name ( ) const { <nl> - return Value ( ) ; <nl> - } <nl> - / / / Set the name of the element . <nl> - void SetName ( const char * str , bool staticMem = false ) { <nl> - SetValue ( str , staticMem ) ; <nl> - } <nl> - <nl> - virtual XMLElement * ToElement ( ) { <nl> - return this ; <nl> - } <nl> - virtual const XMLElement * ToElement ( ) const { <nl> - return this ; <nl> - } <nl> - virtual bool Accept ( XMLVisitor * visitor ) const ; <nl> - <nl> - / * * Given an attribute name , Attribute ( ) returns the value <nl> - for the attribute of that name , or null if none <nl> - exists . For example : <nl> - <nl> - @ verbatim <nl> - const char * value = ele - > Attribute ( " foo " ) ; <nl> - @ endverbatim <nl> - <nl> - The ' value ' parameter is normally null . However , if specified , <nl> - the attribute will only be returned if the ' name ' and ' value ' <nl> - match . This allow you to write code : <nl> - <nl> - @ verbatim <nl> - if ( ele - > Attribute ( " foo " , " bar " ) ) callFooIsBar ( ) ; <nl> - @ endverbatim <nl> - <nl> - rather than : <nl> - @ verbatim <nl> - if ( ele - > Attribute ( " foo " ) ) { <nl> - if ( strcmp ( ele - > Attribute ( " foo " ) , " bar " ) = = 0 ) callFooIsBar ( ) ; <nl> - } <nl> - @ endverbatim <nl> - * / <nl> - const char * Attribute ( const char * name , const char * value = 0 ) const ; <nl> - <nl> - / * * Given an attribute name , IntAttribute ( ) returns the value <nl> - of the attribute interpreted as an integer . 0 will be <nl> - returned if there is an error . For a method with error <nl> - checking , see QueryIntAttribute ( ) <nl> - * / <nl> - int IntAttribute ( const char * name ) const { <nl> - int i = 0 ; <nl> - QueryIntAttribute ( name , & i ) ; <nl> - return i ; <nl> - } <nl> - / / / See IntAttribute ( ) <nl> - unsigned UnsignedAttribute ( const char * name ) const { <nl> - unsigned i = 0 ; <nl> - QueryUnsignedAttribute ( name , & i ) ; <nl> - return i ; <nl> - } <nl> - / / / See IntAttribute ( ) <nl> - bool BoolAttribute ( const char * name ) const { <nl> - bool b = false ; <nl> - QueryBoolAttribute ( name , & b ) ; <nl> - return b ; <nl> - } <nl> - / / / See IntAttribute ( ) <nl> - double DoubleAttribute ( const char * name ) const { <nl> - double d = 0 ; <nl> - QueryDoubleAttribute ( name , & d ) ; <nl> - return d ; <nl> - } <nl> - / / / See IntAttribute ( ) <nl> - float FloatAttribute ( const char * name ) const { <nl> - float f = 0 ; <nl> - QueryFloatAttribute ( name , & f ) ; <nl> - return f ; <nl> - } <nl> - <nl> - / * * Given an attribute name , QueryIntAttribute ( ) returns <nl> - XML_NO_ERROR , XML_WRONG_ATTRIBUTE_TYPE if the conversion <nl> - can ' t be performed , or XML_NO_ATTRIBUTE if the attribute <nl> - doesn ' t exist . If successful , the result of the conversion <nl> - will be written to ' value ' . If not successful , nothing will <nl> - be written to ' value ' . This allows you to provide default <nl> - value : <nl> - <nl> - @ verbatim <nl> - int value = 10 ; <nl> - QueryIntAttribute ( " foo " , & value ) ; / / if " foo " isn ' t found , value will still be 10 <nl> - @ endverbatim <nl> - * / <nl> - XMLError QueryIntAttribute ( const char * name , int * value ) const { <nl> - const XMLAttribute * a = FindAttribute ( name ) ; <nl> - if ( ! a ) { <nl> - return XML_NO_ATTRIBUTE ; <nl> - } <nl> - return a - > QueryIntValue ( value ) ; <nl> - } <nl> - / / / See QueryIntAttribute ( ) <nl> - XMLError QueryUnsignedAttribute ( const char * name , unsigned int * value ) const { <nl> - const XMLAttribute * a = FindAttribute ( name ) ; <nl> - if ( ! a ) { <nl> - return XML_NO_ATTRIBUTE ; <nl> - } <nl> - return a - > QueryUnsignedValue ( value ) ; <nl> - } <nl> - / / / See QueryIntAttribute ( ) <nl> - XMLError QueryBoolAttribute ( const char * name , bool * value ) const { <nl> - const XMLAttribute * a = FindAttribute ( name ) ; <nl> - if ( ! a ) { <nl> - return XML_NO_ATTRIBUTE ; <nl> - } <nl> - return a - > QueryBoolValue ( value ) ; <nl> - } <nl> - / / / See QueryIntAttribute ( ) <nl> - XMLError QueryDoubleAttribute ( const char * name , double * value ) const { <nl> - const XMLAttribute * a = FindAttribute ( name ) ; <nl> - if ( ! a ) { <nl> - return XML_NO_ATTRIBUTE ; <nl> - } <nl> - return a - > QueryDoubleValue ( value ) ; <nl> - } <nl> - / / / See QueryIntAttribute ( ) <nl> - XMLError QueryFloatAttribute ( const char * name , float * value ) const { <nl> - const XMLAttribute * a = FindAttribute ( name ) ; <nl> - if ( ! a ) { <nl> - return XML_NO_ATTRIBUTE ; <nl> - } <nl> - return a - > QueryFloatValue ( value ) ; <nl> - } <nl> - <nl> - / / / Sets the named attribute to value . <nl> - void SetAttribute ( const char * name , const char * value ) { <nl> - XMLAttribute * a = FindOrCreateAttribute ( name ) ; <nl> - a - > SetAttribute ( value ) ; <nl> - } <nl> - / / / Sets the named attribute to value . <nl> - void SetAttribute ( const char * name , int value ) { <nl> - XMLAttribute * a = FindOrCreateAttribute ( name ) ; <nl> - a - > SetAttribute ( value ) ; <nl> - } <nl> - / / / Sets the named attribute to value . <nl> - void SetAttribute ( const char * name , unsigned value ) { <nl> - XMLAttribute * a = FindOrCreateAttribute ( name ) ; <nl> - a - > SetAttribute ( value ) ; <nl> - } <nl> - / / / Sets the named attribute to value . <nl> - void SetAttribute ( const char * name , bool value ) { <nl> - XMLAttribute * a = FindOrCreateAttribute ( name ) ; <nl> - a - > SetAttribute ( value ) ; <nl> - } <nl> - / / / Sets the named attribute to value . <nl> - void SetAttribute ( const char * name , double value ) { <nl> - XMLAttribute * a = FindOrCreateAttribute ( name ) ; <nl> - a - > SetAttribute ( value ) ; <nl> - } <nl> - <nl> - / * * <nl> - Delete an attribute . <nl> - * / <nl> - void DeleteAttribute ( const char * name ) ; <nl> - <nl> - / / / Return the first attribute in the list . <nl> - const XMLAttribute * FirstAttribute ( ) const { <nl> - return _rootAttribute ; <nl> - } <nl> - / / / Query a specific attribute in the list . <nl> - const XMLAttribute * FindAttribute ( const char * name ) const ; <nl> - <nl> - / * * Convenience function for easy access to the text inside an element . Although easy <nl> - and concise , GetText ( ) is limited compared to getting the TiXmlText child <nl> - and accessing it directly . <nl> - <nl> - If the first child of ' this ' is a TiXmlText , the GetText ( ) <nl> - returns the character string of the Text node , else null is returned . <nl> - <nl> - This is a convenient method for getting the text of simple contained text : <nl> - @ verbatim <nl> - < foo > This is text < / foo > <nl> - const char * str = fooElement - > GetText ( ) ; <nl> - @ endverbatim <nl> - <nl> - ' str ' will be a pointer to " This is text " . <nl> - <nl> - Note that this function can be misleading . If the element foo was created from <nl> - this XML : <nl> - @ verbatim <nl> - < foo > < b > This is text < / b > < / foo > <nl> - @ endverbatim <nl> - <nl> - then the value of str would be null . The first child node isn ' t a text node , it is <nl> - another element . From this XML : <nl> - @ verbatim <nl> - < foo > This is < b > text < / b > < / foo > <nl> - @ endverbatim <nl> - GetText ( ) will return " This is " . <nl> - * / <nl> - const char * GetText ( ) const ; <nl> - <nl> - / * * <nl> - Convenience method to query the value of a child text node . This is probably best <nl> - shown by example . Given you have a document is this form : <nl> - @ verbatim <nl> - < point > <nl> - < x > 1 < / x > <nl> - < y > 1 . 4 < / y > <nl> - < / point > <nl> - @ endverbatim <nl> - <nl> - The QueryIntText ( ) and similar functions provide a safe and easier way to get to the <nl> - " value " of x and y . <nl> - <nl> - @ verbatim <nl> - int x = 0 ; <nl> - float y = 0 ; / / types of x and y are contrived for example <nl> - const XMLElement * xElement = pointElement - > FirstChildElement ( " x " ) ; <nl> - const XMLElement * yElement = pointElement - > FirstChildElement ( " y " ) ; <nl> - xElement - > QueryIntText ( & x ) ; <nl> - yElement - > QueryFloatText ( & y ) ; <nl> - @ endverbatim <nl> - <nl> - @ returns XML_SUCCESS ( 0 ) on success , XML_CAN_NOT_CONVERT_TEXT if the text cannot be converted <nl> - to the requested type , and XML_NO_TEXT_NODE if there is no child text to query . <nl> - <nl> - * / <nl> - XMLError QueryIntText ( int * ival ) const ; <nl> - / / / See QueryIntText ( ) <nl> - XMLError QueryUnsignedText ( unsigned * uval ) const ; <nl> - / / / See QueryIntText ( ) <nl> - XMLError QueryBoolText ( bool * bval ) const ; <nl> - / / / See QueryIntText ( ) <nl> - XMLError QueryDoubleText ( double * dval ) const ; <nl> - / / / See QueryIntText ( ) <nl> - XMLError QueryFloatText ( float * fval ) const ; <nl> - <nl> - / / internal : <nl> - enum { <nl> - OPEN , / / < foo > <nl> - CLOSED , / / < foo / > <nl> - CLOSING / / < / foo > <nl> - } ; <nl> - int ClosingType ( ) const { <nl> - return _closingType ; <nl> - } <nl> - char * ParseDeep ( char * p , StrPair * endTag ) ; <nl> - virtual XMLNode * ShallowClone ( XMLDocument * document ) const ; <nl> - virtual bool ShallowEqual ( const XMLNode * compare ) const ; <nl> - <nl> - private : <nl> - XMLElement ( XMLDocument * doc ) ; <nl> - virtual ~ XMLElement ( ) ; <nl> - XMLElement ( const XMLElement & ) ; / / not supported <nl> - void operator = ( const XMLElement & ) ; / / not supported <nl> - <nl> - XMLAttribute * FindAttribute ( const char * name ) ; <nl> - XMLAttribute * FindOrCreateAttribute ( const char * name ) ; <nl> - / / void LinkAttribute ( XMLAttribute * attrib ) ; <nl> - char * ParseAttributes ( char * p ) ; <nl> - <nl> - int _closingType ; <nl> - / / The attribute list is ordered ; there is no ' lastAttribute ' <nl> - / / because the list needs to be scanned for dupes before adding <nl> - / / a new attribute . <nl> - XMLAttribute * _rootAttribute ; <nl> - } ; <nl> - <nl> - <nl> - enum Whitespace { <nl> - PRESERVE_WHITESPACE , <nl> - COLLAPSE_WHITESPACE <nl> - } ; <nl> - <nl> - <nl> - / * * A Document binds together all the functionality . <nl> - It can be saved , loaded , and printed to the screen . <nl> - All Nodes are connected and allocated to a Document . <nl> - If the Document is deleted , all its Nodes are also deleted . <nl> - * / <nl> - class CC_DLL XMLDocument : public XMLNode <nl> - { <nl> - friend class XMLElement ; <nl> - public : <nl> - / / / constructor <nl> - XMLDocument ( bool processEntities = true , Whitespace = PRESERVE_WHITESPACE ) ; <nl> - ~ XMLDocument ( ) ; <nl> - <nl> - virtual XMLDocument * ToDocument ( ) { <nl> - return this ; <nl> - } <nl> - virtual const XMLDocument * ToDocument ( ) const { <nl> - return this ; <nl> - } <nl> - <nl> - / * * <nl> - Parse an XML file from a character string . <nl> - Returns XML_NO_ERROR ( 0 ) on success , or <nl> - an errorID . <nl> - <nl> - You may optionally pass in the ' nBytes ' , which is <nl> - the number of bytes which will be parsed . If not <nl> - specified , TinyXML will assume ' xml ' points to a <nl> - null terminated string . <nl> - * / <nl> - XMLError Parse ( const char * xml , size_t nBytes = ( size_t ) ( - 1 ) ) ; <nl> - <nl> - / * * <nl> - Load an XML file from disk . <nl> - Returns XML_NO_ERROR ( 0 ) on success , or <nl> - an errorID . <nl> - * / <nl> - XMLError LoadFile ( const char * filename ) ; <nl> - <nl> - / * * <nl> - Load an XML file from disk . You are responsible <nl> - for providing and closing the FILE * . <nl> - <nl> - Returns XML_NO_ERROR ( 0 ) on success , or <nl> - an errorID . <nl> - * / <nl> - XMLError LoadFile ( FILE * ) ; <nl> - <nl> - / * * <nl> - Save the XML file to disk . <nl> - Returns XML_NO_ERROR ( 0 ) on success , or <nl> - an errorID . <nl> - * / <nl> - XMLError SaveFile ( const char * filename , bool compact = false ) ; <nl> - <nl> - / * * <nl> - Save the XML file to disk . You are responsible <nl> - for providing and closing the FILE * . <nl> - <nl> - Returns XML_NO_ERROR ( 0 ) on success , or <nl> - an errorID . <nl> - * / <nl> - XMLError SaveFile ( FILE * fp , bool compact = false ) ; <nl> - <nl> - bool ProcessEntities ( ) const { <nl> - return _processEntities ; <nl> - } <nl> - Whitespace WhitespaceMode ( ) const { <nl> - return _whitespace ; <nl> - } <nl> - <nl> - / * * <nl> - Returns true if this document has a leading Byte Order Mark of UTF8 . <nl> - * / <nl> - bool HasBOM ( ) const { <nl> - return _writeBOM ; <nl> - } <nl> - / * * Sets whether to write the BOM when writing the file . <nl> - * / <nl> - void SetBOM ( bool useBOM ) { <nl> - _writeBOM = useBOM ; <nl> - } <nl> - <nl> - / * * Return the root element of DOM . Equivalent to FirstChildElement ( ) . <nl> - To get the first node , use FirstChild ( ) . <nl> - * / <nl> - XMLElement * RootElement ( ) { <nl> - return FirstChildElement ( ) ; <nl> - } <nl> - const XMLElement * RootElement ( ) const { <nl> - return FirstChildElement ( ) ; <nl> - } <nl> - <nl> - / * * Print the Document . If the Printer is not provided , it will <nl> - print to stdout . If you provide Printer , this can print to a file : <nl> - @ verbatim <nl> - XMLPrinter printer ( fp ) ; <nl> - doc . Print ( & printer ) ; <nl> - @ endverbatim <nl> - <nl> - Or you can use a printer to print to memory : <nl> - @ verbatim <nl> - XMLPrinter printer ; <nl> - doc - > Print ( & printer ) ; <nl> - / / printer . CStr ( ) has a const char * to the XML <nl> - @ endverbatim <nl> - * / <nl> - void Print ( XMLPrinter * streamer = 0 ) ; <nl> - virtual bool Accept ( XMLVisitor * visitor ) const ; <nl> - <nl> - / * * <nl> - Create a new Element associated with <nl> - this Document . The memory for the Element <nl> - is managed by the Document . <nl> - * / <nl> - XMLElement * NewElement ( const char * name ) ; <nl> - / * * <nl> - Create a new Comment associated with <nl> - this Document . The memory for the Comment <nl> - is managed by the Document . <nl> - * / <nl> - XMLComment * NewComment ( const char * comment ) ; <nl> - / * * <nl> - Create a new Text associated with <nl> - this Document . The memory for the Text <nl> - is managed by the Document . <nl> - * / <nl> - XMLText * NewText ( const char * text ) ; <nl> - / * * <nl> - Create a new Declaration associated with <nl> - this Document . The memory for the object <nl> - is managed by the Document . <nl> - <nl> - If the ' text ' param is null , the standard <nl> - declaration is used . : <nl> - @ verbatim <nl> - < ? xml version = " 1 . 0 " encoding = " UTF - 8 " ? > <nl> - @ endverbatim <nl> - * / <nl> - XMLDeclaration * NewDeclaration ( const char * text = 0 ) ; <nl> - / * * <nl> - Create a new Unknown associated with <nl> - this Document . The memory forthe object <nl> - is managed by the Document . <nl> - * / <nl> - XMLUnknown * NewUnknown ( const char * text ) ; <nl> - <nl> - / * * <nl> - Delete a node associated with this document . <nl> - It will be unlinked from the DOM . <nl> - * / <nl> - void DeleteNode ( XMLNode * node ) { <nl> - node - > _parent - > DeleteChild ( node ) ; <nl> - } <nl> - <nl> - void SetError ( XMLError error , const char * str1 , const char * str2 ) ; <nl> - <nl> - / / / Return true if there was an error parsing the document . <nl> - bool Error ( ) const { <nl> - return _errorID ! = XML_NO_ERROR ; <nl> - } <nl> - / / / Return the errorID . <nl> - XMLError ErrorID ( ) const { <nl> - return _errorID ; <nl> - } <nl> - / / / Return a possibly helpful diagnostic location or string . <nl> - const char * GetErrorStr1 ( ) const { <nl> - return _errorStr1 ; <nl> - } <nl> - / / / Return a possibly helpful secondary diagnostic location or string . <nl> - const char * GetErrorStr2 ( ) const { <nl> - return _errorStr2 ; <nl> - } <nl> - / / / If there is an error , print it to stdout . <nl> - void PrintError ( ) const ; <nl> - <nl> - / / internal <nl> - char * Identify ( char * p , XMLNode * * node ) ; <nl> - <nl> - virtual XMLNode * ShallowClone ( XMLDocument * / * document * / ) const { <nl> - return 0 ; <nl> - } <nl> - virtual bool ShallowEqual ( const XMLNode * / * compare * / ) const { <nl> - return false ; <nl> - } <nl> - <nl> - private : <nl> - XMLDocument ( const XMLDocument & ) ; / / not supported <nl> - void operator = ( const XMLDocument & ) ; / / not supported <nl> - void InitDocument ( ) ; <nl> - <nl> - bool _writeBOM ; <nl> - bool _processEntities ; <nl> - XMLError _errorID ; <nl> - Whitespace _whitespace ; <nl> - const char * _errorStr1 ; <nl> - const char * _errorStr2 ; <nl> - char * _charBuffer ; <nl> - <nl> - MemPoolT < sizeof ( XMLElement ) > _elementPool ; <nl> - MemPoolT < sizeof ( XMLAttribute ) > _attributePool ; <nl> - MemPoolT < sizeof ( XMLText ) > _textPool ; <nl> - MemPoolT < sizeof ( XMLComment ) > _commentPool ; <nl> - } ; <nl> - <nl> - <nl> - / * * <nl> - A XMLHandle is a class that wraps a node pointer with null checks ; this is <nl> - an incredibly useful thing . Note that XMLHandle is not part of the TinyXML <nl> - DOM structure . It is a separate utility class . <nl> - <nl> - Take an example : <nl> - @ verbatim <nl> - < Document > <nl> - < Element attributeA = " valueA " > <nl> - < Child attributeB = " value1 " / > <nl> - < Child attributeB = " value2 " / > <nl> - < / Element > <nl> - < / Document > <nl> - @ endverbatim <nl> - <nl> - Assuming you want the value of " attributeB " in the 2nd " Child " element , it ' s very <nl> - easy to write a * lot * of code that looks like : <nl> - <nl> - @ verbatim <nl> - XMLElement * root = document . FirstChildElement ( " Document " ) ; <nl> - if ( root ) <nl> - { <nl> - XMLElement * element = root - > FirstChildElement ( " Element " ) ; <nl> - if ( element ) <nl> - { <nl> - XMLElement * child = element - > FirstChildElement ( " Child " ) ; <nl> - if ( child ) <nl> - { <nl> - XMLElement * child2 = child - > NextSiblingElement ( " Child " ) ; <nl> - if ( child2 ) <nl> - { <nl> - / / Finally do something useful . <nl> - @ endverbatim <nl> - <nl> - And that doesn ' t even cover " else " cases . XMLHandle addresses the verbosity <nl> - of such code . A XMLHandle checks for null pointers so it is perfectly safe <nl> - and correct to use : <nl> - <nl> - @ verbatim <nl> - XMLHandle docHandle ( & document ) ; <nl> - XMLElement * child2 = docHandle . FirstChild ( " Document " ) . FirstChild ( " Element " ) . FirstChild ( ) . NextSibling ( ) . ToElement ( ) ; <nl> - if ( child2 ) <nl> - { <nl> - / / do something useful <nl> - @ endverbatim <nl> - <nl> - Which is MUCH more concise and useful . <nl> - <nl> - It is also safe to copy handles - internally they are nothing more than node pointers . <nl> - @ verbatim <nl> - XMLHandle handleCopy = handle ; <nl> - @ endverbatim <nl> - <nl> - See also XMLConstHandle , which is the same as XMLHandle , but operates on const objects . <nl> - * / <nl> - class CC_DLL XMLHandle <nl> - { <nl> - public : <nl> - / / / Create a handle from any node ( at any depth of the tree . ) This can be a null pointer . <nl> - XMLHandle ( XMLNode * node ) { <nl> - _node = node ; <nl> - } <nl> - / / / Create a handle from a node . <nl> - XMLHandle ( XMLNode & node ) { <nl> - _node = & node ; <nl> - } <nl> - / / / Copy constructor <nl> - XMLHandle ( const XMLHandle & ref ) { <nl> - _node = ref . _node ; <nl> - } <nl> - / / / Assignment <nl> - XMLHandle & operator = ( const XMLHandle & ref ) { <nl> - _node = ref . _node ; <nl> - return * this ; <nl> - } <nl> - <nl> - / / / Get the first child of this handle . <nl> - XMLHandle FirstChild ( ) { <nl> - return XMLHandle ( _node ? _node - > FirstChild ( ) : 0 ) ; <nl> - } <nl> - / / / Get the first child element of this handle . <nl> - XMLHandle FirstChildElement ( const char * value = 0 ) { <nl> - return XMLHandle ( _node ? _node - > FirstChildElement ( value ) : 0 ) ; <nl> - } <nl> - / / / Get the last child of this handle . <nl> - XMLHandle LastChild ( ) { <nl> - return XMLHandle ( _node ? _node - > LastChild ( ) : 0 ) ; <nl> - } <nl> - / / / Get the last child element of this handle . <nl> - XMLHandle LastChildElement ( const char * _value = 0 ) { <nl> - return XMLHandle ( _node ? _node - > LastChildElement ( _value ) : 0 ) ; <nl> - } <nl> - / / / Get the previous sibling of this handle . <nl> - XMLHandle PreviousSibling ( ) { <nl> - return XMLHandle ( _node ? _node - > PreviousSibling ( ) : 0 ) ; <nl> - } <nl> - / / / Get the previous sibling element of this handle . <nl> - XMLHandle PreviousSiblingElement ( const char * _value = 0 ) { <nl> - return XMLHandle ( _node ? _node - > PreviousSiblingElement ( _value ) : 0 ) ; <nl> - } <nl> - / / / Get the next sibling of this handle . <nl> - XMLHandle NextSibling ( ) { <nl> - return XMLHandle ( _node ? _node - > NextSibling ( ) : 0 ) ; <nl> - } <nl> - / / / Get the next sibling element of this handle . <nl> - XMLHandle NextSiblingElement ( const char * _value = 0 ) { <nl> - return XMLHandle ( _node ? _node - > NextSiblingElement ( _value ) : 0 ) ; <nl> - } <nl> - <nl> - / / / Safe cast to XMLNode . This can return null . <nl> - XMLNode * ToNode ( ) { <nl> - return _node ; <nl> - } <nl> - / / / Safe cast to XMLElement . This can return null . <nl> - XMLElement * ToElement ( ) { <nl> - return ( ( _node & & _node - > ToElement ( ) ) ? _node - > ToElement ( ) : 0 ) ; <nl> - } <nl> - / / / Safe cast to XMLText . This can return null . <nl> - XMLText * ToText ( ) { <nl> - return ( ( _node & & _node - > ToText ( ) ) ? _node - > ToText ( ) : 0 ) ; <nl> - } <nl> - / / / Safe cast to XMLUnknown . This can return null . <nl> - XMLUnknown * ToUnknown ( ) { <nl> - return ( ( _node & & _node - > ToUnknown ( ) ) ? _node - > ToUnknown ( ) : 0 ) ; <nl> - } <nl> - / / / Safe cast to XMLDeclaration . This can return null . <nl> - XMLDeclaration * ToDeclaration ( ) { <nl> - return ( ( _node & & _node - > ToDeclaration ( ) ) ? _node - > ToDeclaration ( ) : 0 ) ; <nl> - } <nl> - <nl> - private : <nl> - XMLNode * _node ; <nl> - } ; <nl> - <nl> - <nl> - / * * <nl> - A variant of the XMLHandle class for working with const XMLNodes and Documents . It is the <nl> - same in all regards , except for the ' const ' qualifiers . See XMLHandle for API . <nl> - * / <nl> - class CC_DLL XMLConstHandle <nl> - { <nl> - public : <nl> - XMLConstHandle ( const XMLNode * node ) { <nl> - _node = node ; <nl> - } <nl> - XMLConstHandle ( const XMLNode & node ) { <nl> - _node = & node ; <nl> - } <nl> - XMLConstHandle ( const XMLConstHandle & ref ) { <nl> - _node = ref . _node ; <nl> - } <nl> - <nl> - XMLConstHandle & operator = ( const XMLConstHandle & ref ) { <nl> - _node = ref . _node ; <nl> - return * this ; <nl> - } <nl> - <nl> - const XMLConstHandle FirstChild ( ) const { <nl> - return XMLConstHandle ( _node ? _node - > FirstChild ( ) : 0 ) ; <nl> - } <nl> - const XMLConstHandle FirstChildElement ( const char * value = 0 ) const { <nl> - return XMLConstHandle ( _node ? _node - > FirstChildElement ( value ) : 0 ) ; <nl> - } <nl> - const XMLConstHandle LastChild ( ) const { <nl> - return XMLConstHandle ( _node ? _node - > LastChild ( ) : 0 ) ; <nl> - } <nl> - const XMLConstHandle LastChildElement ( const char * _value = 0 ) const { <nl> - return XMLConstHandle ( _node ? _node - > LastChildElement ( _value ) : 0 ) ; <nl> - } <nl> - const XMLConstHandle PreviousSibling ( ) const { <nl> - return XMLConstHandle ( _node ? _node - > PreviousSibling ( ) : 0 ) ; <nl> - } <nl> - const XMLConstHandle PreviousSiblingElement ( const char * _value = 0 ) const { <nl> - return XMLConstHandle ( _node ? _node - > PreviousSiblingElement ( _value ) : 0 ) ; <nl> - } <nl> - const XMLConstHandle NextSibling ( ) const { <nl> - return XMLConstHandle ( _node ? _node - > NextSibling ( ) : 0 ) ; <nl> - } <nl> - const XMLConstHandle NextSiblingElement ( const char * _value = 0 ) const { <nl> - return XMLConstHandle ( _node ? _node - > NextSiblingElement ( _value ) : 0 ) ; <nl> - } <nl> - <nl> - <nl> - const XMLNode * ToNode ( ) const { <nl> - return _node ; <nl> - } <nl> - const XMLElement * ToElement ( ) const { <nl> - return ( ( _node & & _node - > ToElement ( ) ) ? _node - > ToElement ( ) : 0 ) ; <nl> - } <nl> - const XMLText * ToText ( ) const { <nl> - return ( ( _node & & _node - > ToText ( ) ) ? _node - > ToText ( ) : 0 ) ; <nl> - } <nl> - const XMLUnknown * ToUnknown ( ) const { <nl> - return ( ( _node & & _node - > ToUnknown ( ) ) ? _node - > ToUnknown ( ) : 0 ) ; <nl> - } <nl> - const XMLDeclaration * ToDeclaration ( ) const { <nl> - return ( ( _node & & _node - > ToDeclaration ( ) ) ? _node - > ToDeclaration ( ) : 0 ) ; <nl> - } <nl> - <nl> - private : <nl> - const XMLNode * _node ; <nl> - } ; <nl> - <nl> - <nl> - / * * <nl> - Printing functionality . The XMLPrinter gives you more <nl> - options than the XMLDocument : : Print ( ) method . <nl> - <nl> - It can : <nl> - - # Print to memory . <nl> - - # Print to a file you provide . <nl> - - # Print XML without a XMLDocument . <nl> - <nl> - Print to Memory <nl> - <nl> - @ verbatim <nl> - XMLPrinter printer ; <nl> - doc - > Print ( & printer ) ; <nl> - SomeFunction ( printer . CStr ( ) ) ; <nl> - @ endverbatim <nl> - <nl> - Print to a File <nl> - <nl> - You provide the file pointer . <nl> - @ verbatim <nl> - XMLPrinter printer ( fp ) ; <nl> - doc . Print ( & printer ) ; <nl> - @ endverbatim <nl> - <nl> - Print without a XMLDocument <nl> - <nl> - When loading , an XML parser is very useful . However , sometimes <nl> - when saving , it just gets in the way . The code is often set up <nl> - for streaming , and constructing the DOM is just overhead . <nl> - <nl> - The Printer supports the streaming case . The following code <nl> - prints out a trivially simple XML file without ever creating <nl> - an XML document . <nl> - <nl> - @ verbatim <nl> - XMLPrinter printer ( fp ) ; <nl> - printer . OpenElement ( " foo " ) ; <nl> - printer . PushAttribute ( " foo " , " bar " ) ; <nl> - printer . CloseElement ( ) ; <nl> - @ endverbatim <nl> - * / <nl> - class CC_DLL XMLPrinter : public XMLVisitor <nl> - { <nl> - public : <nl> - / * * Construct the printer . If the FILE * is specified , <nl> - this will print to the FILE . Else it will print <nl> - to memory , and the result is available in CStr ( ) . <nl> - If ' compact ' is set to true , then output is created <nl> - with only required whitespace and newlines . <nl> - * / <nl> - XMLPrinter ( FILE * file = 0 , bool compact = false ) ; <nl> - ~ XMLPrinter ( ) { } <nl> - <nl> - / * * If streaming , write the BOM and declaration . * / <nl> - void PushHeader ( bool writeBOM , bool writeDeclaration ) ; <nl> - / * * If streaming , start writing an element . <nl> - The element must be closed with CloseElement ( ) <nl> - * / <nl> - void OpenElement ( const char * name ) ; <nl> - / / / If streaming , add an attribute to an open element . <nl> - void PushAttribute ( const char * name , const char * value ) ; <nl> - void PushAttribute ( const char * name , int value ) ; <nl> - void PushAttribute ( const char * name , unsigned value ) ; <nl> - void PushAttribute ( const char * name , bool value ) ; <nl> - void PushAttribute ( const char * name , double value ) ; <nl> - / / / If streaming , close the Element . <nl> - void CloseElement ( ) ; <nl> - <nl> - / / / Add a text node . <nl> - void PushText ( const char * text , bool cdata = false ) ; <nl> - / / / Add a text node from an integer . <nl> - void PushText ( int value ) ; <nl> - / / / Add a text node from an unsigned . <nl> - void PushText ( unsigned value ) ; <nl> - / / / Add a text node from a bool . <nl> - void PushText ( bool value ) ; <nl> - / / / Add a text node from a float . <nl> - void PushText ( float value ) ; <nl> - / / / Add a text node from a double . <nl> - void PushText ( double value ) ; <nl> - <nl> - / / / Add a comment <nl> - void PushComment ( const char * comment ) ; <nl> - <nl> - void PushDeclaration ( const char * value ) ; <nl> - void PushUnknown ( const char * value ) ; <nl> - <nl> - virtual bool VisitEnter ( const XMLDocument & / * doc * / ) ; <nl> - virtual bool VisitExit ( const XMLDocument & / * doc * / ) { <nl> - return true ; <nl> - } <nl> - <nl> - virtual bool VisitEnter ( const XMLElement & element , const XMLAttribute * attribute ) ; <nl> - virtual bool VisitExit ( const XMLElement & element ) ; <nl> - <nl> - virtual bool Visit ( const XMLText & text ) ; <nl> - virtual bool Visit ( const XMLComment & comment ) ; <nl> - virtual bool Visit ( const XMLDeclaration & declaration ) ; <nl> - virtual bool Visit ( const XMLUnknown & unknown ) ; <nl> - <nl> - / * * <nl> - If in print to memory mode , return a pointer to <nl> - the XML file in memory . <nl> - * / <nl> - const char * CStr ( ) const { <nl> - return _buffer . Mem ( ) ; <nl> - } <nl> - / * * <nl> - If in print to memory mode , return the size <nl> - of the XML file in memory . ( Note the size returned <nl> - includes the terminating null . ) <nl> - * / <nl> - int CStrSize ( ) const { <nl> - return _buffer . Size ( ) ; <nl> - } <nl> - <nl> - private : <nl> - void SealElement ( ) ; <nl> - void PrintSpace ( int depth ) ; <nl> - void PrintString ( const char * , bool restrictedEntitySet ) ; / / prints out , after detecting entities . <nl> - void Print ( const char * format , . . . ) ; <nl> - <nl> - bool _elementJustOpened ; <nl> - bool _firstElement ; <nl> - FILE * _fp ; <nl> - int _depth ; <nl> - int _textDepth ; <nl> - bool _processEntities ; <nl> - bool _compactMode ; <nl> - <nl> - enum { <nl> - ENTITY_RANGE = 64 , <nl> - BUF_SIZE = 200 <nl> - } ; <nl> - bool _entityFlag [ ENTITY_RANGE ] ; <nl> - bool _restrictedEntityFlag [ ENTITY_RANGE ] ; <nl> - <nl> - DynArray < const char * , 10 > _stack ; <nl> - DynArray < char , 20 > _buffer ; <nl> - # ifdef _MSC_VER <nl> - DynArray < char , 20 > _accumulator ; <nl> - # endif <nl> - } ; <nl> - <nl> - <nl> - } / / tinyxml2 <nl> - <nl> - <nl> - # endif / / TINYXML2_INCLUDED <nl> deleted file mode 100644 <nl> index 669ea369279f . . 000000000000 <nl> mmm a / cocos / 2d / support / zip_support / ioapi . cpp <nl> ppp / dev / null <nl> <nl> - / * ioapi . h - - IO base function header for compress / uncompress . zip <nl> - part of the MiniZip project - ( http : / / www . winimage . com / zLibDll / minizip . html ) <nl> - <nl> - Copyright ( C ) 1998 - 2010 Gilles Vollant ( minizip ) ( http : / / www . winimage . com / zLibDll / minizip . html ) <nl> - <nl> - Modifications for Zip64 support <nl> - Copyright ( C ) 2009 - 2010 Mathias Svensson ( http : / / result42 . com ) <nl> - <nl> - For more info read MiniZip_info . txt <nl> - <nl> - * / <nl> - <nl> - # include " ioapi . h " <nl> - <nl> - namespace cocos2d { <nl> - <nl> - voidpf call_zopen64 ( const zlib_filefunc64_32_def * pfilefunc , const void * filename , int mode ) <nl> - { <nl> - if ( pfilefunc - > zfile_func64 . zopen64_file ! = NULL ) <nl> - return ( * ( pfilefunc - > zfile_func64 . zopen64_file ) ) ( pfilefunc - > zfile_func64 . opaque , filename , mode ) ; <nl> - else <nl> - { <nl> - return ( * ( pfilefunc - > zopen32_file ) ) ( pfilefunc - > zfile_func64 . opaque , ( const char * ) filename , mode ) ; <nl> - } <nl> - } <nl> - <nl> - long call_zseek64 ( const zlib_filefunc64_32_def * pfilefunc , voidpf filestream , ZPOS64_T offset , int origin ) <nl> - { <nl> - if ( pfilefunc - > zfile_func64 . zseek64_file ! = NULL ) <nl> - return ( * ( pfilefunc - > zfile_func64 . zseek64_file ) ) ( pfilefunc - > zfile_func64 . opaque , filestream , offset , origin ) ; <nl> - else <nl> - { <nl> - uLong offsetTruncated = ( uLong ) offset ; <nl> - if ( offsetTruncated ! = offset ) <nl> - return - 1 ; <nl> - else <nl> - return ( * ( pfilefunc - > zseek32_file ) ) ( pfilefunc - > zfile_func64 . opaque , filestream , offsetTruncated , origin ) ; <nl> - } <nl> - } <nl> - <nl> - ZPOS64_T call_ztell64 ( const zlib_filefunc64_32_def * pfilefunc , voidpf filestream ) <nl> - { <nl> - if ( pfilefunc - > zfile_func64 . zseek64_file ! = NULL ) <nl> - return ( * ( pfilefunc - > zfile_func64 . ztell64_file ) ) ( pfilefunc - > zfile_func64 . opaque , filestream ) ; <nl> - else <nl> - { <nl> - uLong tell_uLong = ( * ( pfilefunc - > ztell32_file ) ) ( pfilefunc - > zfile_func64 . opaque , filestream ) ; <nl> - if ( ( tell_uLong ) = = ( ( uLong ) - 1 ) ) <nl> - return ( ZPOS64_T ) - 1 ; <nl> - else <nl> - return tell_uLong ; <nl> - } <nl> - } <nl> - <nl> - void fill_zlib_filefunc64_32_def_from_filefunc32 ( zlib_filefunc64_32_def * p_filefunc64_32 , const zlib_filefunc_def * p_filefunc32 ) <nl> - { <nl> - p_filefunc64_32 - > zfile_func64 . zopen64_file = NULL ; <nl> - p_filefunc64_32 - > zopen32_file = p_filefunc32 - > zopen_file ; <nl> - p_filefunc64_32 - > zfile_func64 . zerror_file = p_filefunc32 - > zerror_file ; <nl> - p_filefunc64_32 - > zfile_func64 . zread_file = p_filefunc32 - > zread_file ; <nl> - p_filefunc64_32 - > zfile_func64 . zwrite_file = p_filefunc32 - > zwrite_file ; <nl> - p_filefunc64_32 - > zfile_func64 . ztell64_file = NULL ; <nl> - p_filefunc64_32 - > zfile_func64 . zseek64_file = NULL ; <nl> - p_filefunc64_32 - > zfile_func64 . zclose_file = p_filefunc32 - > zclose_file ; <nl> - p_filefunc64_32 - > zfile_func64 . zerror_file = p_filefunc32 - > zerror_file ; <nl> - p_filefunc64_32 - > zfile_func64 . opaque = p_filefunc32 - > opaque ; <nl> - p_filefunc64_32 - > zseek32_file = p_filefunc32 - > zseek_file ; <nl> - p_filefunc64_32 - > ztell32_file = p_filefunc32 - > ztell_file ; <nl> - } <nl> - <nl> - <nl> - <nl> - static voidpf ZCALLBACK fopen_file_func OF ( ( voidpf opaque , const char * filename , int mode ) ) ; <nl> - static uLong ZCALLBACK fread_file_func OF ( ( voidpf opaque , voidpf stream , void * buf , uLong size ) ) ; <nl> - static uLong ZCALLBACK fwrite_file_func OF ( ( voidpf opaque , voidpf stream , const void * buf , uLong size ) ) ; <nl> - static ZPOS64_T ZCALLBACK ftell64_file_func OF ( ( voidpf opaque , voidpf stream ) ) ; <nl> - static long ZCALLBACK fseek64_file_func OF ( ( voidpf opaque , voidpf stream , ZPOS64_T offset , int origin ) ) ; <nl> - static int ZCALLBACK fclose_file_func OF ( ( voidpf opaque , voidpf stream ) ) ; <nl> - static int ZCALLBACK ferror_file_func OF ( ( voidpf opaque , voidpf stream ) ) ; <nl> - <nl> - static voidpf ZCALLBACK fopen_file_func ( voidpf opaque , const char * filename , int mode ) <nl> - { <nl> - FILE * file = NULL ; <nl> - const char * mode_fopen = NULL ; <nl> - if ( ( mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER ) = = ZLIB_FILEFUNC_MODE_READ ) <nl> - mode_fopen = " rb " ; <nl> - else <nl> - if ( mode & ZLIB_FILEFUNC_MODE_EXISTING ) <nl> - mode_fopen = " r + b " ; <nl> - else <nl> - if ( mode & ZLIB_FILEFUNC_MODE_CREATE ) <nl> - mode_fopen = " wb " ; <nl> - <nl> - if ( ( filename ! = NULL ) & & ( mode_fopen ! = NULL ) ) <nl> - file = fopen ( filename , mode_fopen ) ; <nl> - return file ; <nl> - } <nl> - <nl> - static voidpf ZCALLBACK fopen64_file_func ( voidpf opaque , const void * filename , int mode ) <nl> - { <nl> - FILE * file = NULL ; <nl> - const char * mode_fopen = NULL ; <nl> - if ( ( mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER ) = = ZLIB_FILEFUNC_MODE_READ ) <nl> - mode_fopen = " rb " ; <nl> - else <nl> - if ( mode & ZLIB_FILEFUNC_MODE_EXISTING ) <nl> - mode_fopen = " r + b " ; <nl> - else <nl> - if ( mode & ZLIB_FILEFUNC_MODE_CREATE ) <nl> - mode_fopen = " wb " ; <nl> - <nl> - if ( ( filename ! = NULL ) & & ( mode_fopen ! = NULL ) ) <nl> - { <nl> - # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_MARMALADE | | CC_TARGET_PLATFORM = = CC_PLATFORM_BADA | | CC_TARGET_PLATFORM = = CC_PLATFORM_BLACKBERRY | | CC_TARGET_PLATFORM = = CC_PLATFORM_NACL | | CC_TARGET_PLATFORM = = CC_PLATFORM_EMSCRIPTEN ) <nl> - file = NULL ; <nl> - # else <nl> - file = fopen64 ( ( const char * ) filename , mode_fopen ) ; <nl> - # endif <nl> - } <nl> - <nl> - return file ; <nl> - } <nl> - <nl> - <nl> - static uLong ZCALLBACK fread_file_func ( voidpf opaque , voidpf stream , void * buf , uLong size ) <nl> - { <nl> - uLong ret ; <nl> - ret = ( uLong ) fread ( buf , 1 , ( size_t ) size , ( FILE * ) stream ) ; <nl> - return ret ; <nl> - } <nl> - <nl> - static uLong ZCALLBACK fwrite_file_func ( voidpf opaque , voidpf stream , const void * buf , uLong size ) <nl> - { <nl> - uLong ret ; <nl> - ret = ( uLong ) fwrite ( buf , 1 , ( size_t ) size , ( FILE * ) stream ) ; <nl> - return ret ; <nl> - } <nl> - <nl> - static long ZCALLBACK ftell_file_func ( voidpf opaque , voidpf stream ) <nl> - { <nl> - long ret ; <nl> - ret = ftell ( ( FILE * ) stream ) ; <nl> - return ret ; <nl> - } <nl> - <nl> - <nl> - static ZPOS64_T ZCALLBACK ftell64_file_func ( voidpf opaque , voidpf stream ) <nl> - { <nl> - ZPOS64_T ret ; <nl> - # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_MARMALADE | | CC_TARGET_PLATFORM = = CC_PLATFORM_BADA | | CC_TARGET_PLATFORM = = CC_PLATFORM_BLACKBERRY | | CC_TARGET_PLATFORM = = CC_PLATFORM_NACL | | CC_TARGET_PLATFORM = = CC_PLATFORM_EMSCRIPTEN ) <nl> - ret = 0 ; <nl> - # else <nl> - ret = ftello64 ( ( FILE * ) stream ) ; <nl> - # endif <nl> - return ret ; <nl> - } <nl> - <nl> - static long ZCALLBACK fseek_file_func ( voidpf opaque , voidpf stream , uLong offset , int origin ) <nl> - { <nl> - int fseek_origin = 0 ; <nl> - long ret ; <nl> - switch ( origin ) <nl> - { <nl> - case ZLIB_FILEFUNC_SEEK_CUR : <nl> - fseek_origin = SEEK_CUR ; <nl> - break ; <nl> - case ZLIB_FILEFUNC_SEEK_END : <nl> - fseek_origin = SEEK_END ; <nl> - break ; <nl> - case ZLIB_FILEFUNC_SEEK_SET : <nl> - fseek_origin = SEEK_SET ; <nl> - break ; <nl> - default : return - 1 ; <nl> - } <nl> - ret = 0 ; <nl> - if ( fseek ( ( FILE * ) stream , offset , fseek_origin ) ! = 0 ) <nl> - ret = - 1 ; <nl> - return ret ; <nl> - } <nl> - <nl> - static long ZCALLBACK fseek64_file_func ( voidpf opaque , voidpf stream , ZPOS64_T offset , int origin ) <nl> - { <nl> - # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_MARMALADE | | CC_TARGET_PLATFORM = = CC_PLATFORM_BADA | | CC_TARGET_PLATFORM = = CC_PLATFORM_BLACKBERRY | | CC_TARGET_PLATFORM = = CC_PLATFORM_NACL | | CC_TARGET_PLATFORM = = CC_PLATFORM_EMSCRIPTEN ) <nl> - return - 1 ; <nl> - # else <nl> - int fseek_origin = 0 ; <nl> - switch ( origin ) <nl> - { <nl> - case ZLIB_FILEFUNC_SEEK_CUR : <nl> - fseek_origin = SEEK_CUR ; <nl> - break ; <nl> - case ZLIB_FILEFUNC_SEEK_END : <nl> - fseek_origin = SEEK_END ; <nl> - break ; <nl> - case ZLIB_FILEFUNC_SEEK_SET : <nl> - fseek_origin = SEEK_SET ; <nl> - break ; <nl> - default : return - 1 ; <nl> - } <nl> - if ( fseeko64 ( ( FILE * ) stream , offset , fseek_origin ) ! = 0 ) <nl> - return - 1 ; <nl> - return 0 ; <nl> - # endif <nl> - } <nl> - <nl> - <nl> - static int ZCALLBACK fclose_file_func ( voidpf opaque , voidpf stream ) <nl> - { <nl> - int ret ; <nl> - ret = fclose ( ( FILE * ) stream ) ; <nl> - return ret ; <nl> - } <nl> - <nl> - static int ZCALLBACK ferror_file_func ( voidpf opaque , voidpf stream ) <nl> - { <nl> - int ret ; <nl> - ret = ferror ( ( FILE * ) stream ) ; <nl> - return ret ; <nl> - } <nl> - <nl> - void fill_fopen_filefunc ( zlib_filefunc_def * pzlib_filefunc_def ) <nl> - { <nl> - pzlib_filefunc_def - > zopen_file = fopen_file_func ; <nl> - pzlib_filefunc_def - > zread_file = fread_file_func ; <nl> - pzlib_filefunc_def - > zwrite_file = fwrite_file_func ; <nl> - pzlib_filefunc_def - > ztell_file = ftell_file_func ; <nl> - pzlib_filefunc_def - > zseek_file = fseek_file_func ; <nl> - pzlib_filefunc_def - > zclose_file = fclose_file_func ; <nl> - pzlib_filefunc_def - > zerror_file = ferror_file_func ; <nl> - pzlib_filefunc_def - > opaque = NULL ; <nl> - } <nl> - <nl> - void fill_fopen64_filefunc ( zlib_filefunc64_def * pzlib_filefunc_def ) <nl> - { <nl> - pzlib_filefunc_def - > zopen64_file = fopen64_file_func ; <nl> - pzlib_filefunc_def - > zread_file = fread_file_func ; <nl> - pzlib_filefunc_def - > zwrite_file = fwrite_file_func ; <nl> - pzlib_filefunc_def - > ztell64_file = ftell64_file_func ; <nl> - pzlib_filefunc_def - > zseek64_file = fseek64_file_func ; <nl> - pzlib_filefunc_def - > zclose_file = fclose_file_func ; <nl> - pzlib_filefunc_def - > zerror_file = ferror_file_func ; <nl> - pzlib_filefunc_def - > opaque = NULL ; <nl> - } <nl> - <nl> - } / / end of namespace cocos2d <nl> deleted file mode 100644 <nl> index 575f44ece470 . . 000000000000 <nl> mmm a / cocos / 2d / support / zip_support / ioapi . h <nl> ppp / dev / null <nl> <nl> - / * ioapi . h - - IO base function header for compress / uncompress . zip <nl> - part of the MiniZip project - ( http : / / www . winimage . com / zLibDll / minizip . html ) <nl> - <nl> - Copyright ( C ) 1998 - 2010 Gilles Vollant ( minizip ) ( http : / / www . winimage . com / zLibDll / minizip . html ) <nl> - <nl> - Modifications for Zip64 support <nl> - Copyright ( C ) 2009 - 2010 Mathias Svensson ( http : / / result42 . com ) <nl> - <nl> - For more info read MiniZip_info . txt <nl> - <nl> - Changes <nl> - <nl> - Oct - 2009 - Defined ZPOS64_T to fpos_t on windows and u_int64_t on linux . ( might need to find a better why for this ) <nl> - Oct - 2009 - Change to fseeko64 , ftello64 and fopen64 so large files would work on linux . <nl> - More if / def section may be needed to support other platforms <nl> - Oct - 2009 - Defined fxxxx64 calls to normal fopen / ftell / fseek so they would compile on windows . <nl> - ( but you should use iowin32 . c for windows instead ) <nl> - <nl> - * / <nl> - <nl> - # ifndef _ZLIBIOAPI64_H <nl> - # define _ZLIBIOAPI64_H <nl> - <nl> - # include " platform / CCPlatformConfig . h " <nl> - <nl> - # if ( ! defined ( _WIN32 ) ) & & ( ! defined ( WIN32 ) ) <nl> - <nl> - / / Linux needs this to support file operation on files larger then 4 + GB <nl> - / / But might need better if / def to select just the platforms that needs them . <nl> - <nl> - # ifndef __USE_FILE_OFFSET64 <nl> - # define __USE_FILE_OFFSET64 <nl> - # endif <nl> - # ifndef __USE_LARGEFILE64 <nl> - # define __USE_LARGEFILE64 <nl> - # endif <nl> - # ifndef _LARGEFILE64_SOURCE <nl> - # define _LARGEFILE64_SOURCE <nl> - # endif <nl> - # ifndef _FILE_OFFSET_BIT <nl> - # define _FILE_OFFSET_BIT 64 <nl> - # endif <nl> - # endif <nl> - <nl> - # include < stdio . h > <nl> - # include < stdlib . h > <nl> - # include " zlib . h " <nl> - <nl> - namespace cocos2d { <nl> - <nl> - # ifndef OF <nl> - # define OF _Z_OF <nl> - # endif <nl> - <nl> - # if defined ( USE_FILE32API ) <nl> - # define fopen64 fopen <nl> - # define ftello64 ftell <nl> - # define fseeko64 fseek <nl> - # else <nl> - # ifdef _MSC_VER <nl> - # define fopen64 fopen <nl> - # if ( _MSC_VER > = 1400 ) & & ( ! ( defined ( NO_MSCVER_FILE64_FUNC ) ) ) <nl> - # define ftello64 _ftelli64 <nl> - # define fseeko64 _fseeki64 <nl> - # else / / old MSC <nl> - # define ftello64 ftell <nl> - # define fseeko64 fseek <nl> - # endif <nl> - # endif <nl> - # endif <nl> - <nl> - / * <nl> - # ifndef ZPOS64_T <nl> - # ifdef _WIN32 <nl> - # define ZPOS64_T fpos_t <nl> - # else <nl> - # include < stdint . h > <nl> - # define ZPOS64_T uint64_t <nl> - # endif <nl> - # endif <nl> - * / <nl> - <nl> - # ifdef HAVE_MINIZIP64_CONF_H <nl> - # include " mz64conf . h " <nl> - # endif <nl> - <nl> - / * a type chosen by DEFINE * / <nl> - # ifdef HAVE_64BIT_INT_CUSTOM <nl> - typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T ; <nl> - # else <nl> - # ifdef HAS_STDINT_H <nl> - # include " stdint . h " <nl> - typedef uint64_t ZPOS64_T ; <nl> - # else <nl> - <nl> - <nl> - # if defined ( _MSC_VER ) | | defined ( __BORLANDC__ ) <nl> - typedef unsigned __int64 ZPOS64_T ; <nl> - # else <nl> - typedef unsigned long long int ZPOS64_T ; <nl> - # endif <nl> - # endif <nl> - # endif <nl> - <nl> - <nl> - <nl> - # define ZLIB_FILEFUNC_SEEK_CUR ( 1 ) <nl> - # define ZLIB_FILEFUNC_SEEK_END ( 2 ) <nl> - # define ZLIB_FILEFUNC_SEEK_SET ( 0 ) <nl> - <nl> - # define ZLIB_FILEFUNC_MODE_READ ( 1 ) <nl> - # define ZLIB_FILEFUNC_MODE_WRITE ( 2 ) <nl> - # define ZLIB_FILEFUNC_MODE_READWRITEFILTER ( 3 ) <nl> - <nl> - # define ZLIB_FILEFUNC_MODE_EXISTING ( 4 ) <nl> - # define ZLIB_FILEFUNC_MODE_CREATE ( 8 ) <nl> - <nl> - <nl> - # ifndef ZCALLBACK <nl> - # if ( defined ( WIN32 ) | | defined ( _WIN32 ) | | defined ( WINDOWS ) | | defined ( _WINDOWS ) ) & & defined ( CALLBACK ) & & defined ( USEWINDOWS_CALLBACK ) <nl> - # define ZCALLBACK CALLBACK <nl> - # else <nl> - # define ZCALLBACK <nl> - # endif <nl> - # endif <nl> - <nl> - <nl> - <nl> - <nl> - typedef voidpf ( ZCALLBACK * open_file_func ) OF ( ( voidpf opaque , const char * filename , int mode ) ) ; <nl> - typedef uLong ( ZCALLBACK * read_file_func ) OF ( ( voidpf opaque , voidpf stream , void * buf , uLong size ) ) ; <nl> - typedef uLong ( ZCALLBACK * write_file_func ) OF ( ( voidpf opaque , voidpf stream , const void * buf , uLong size ) ) ; <nl> - typedef int ( ZCALLBACK * close_file_func ) OF ( ( voidpf opaque , voidpf stream ) ) ; <nl> - typedef int ( ZCALLBACK * testerror_file_func ) OF ( ( voidpf opaque , voidpf stream ) ) ; <nl> - <nl> - typedef long ( ZCALLBACK * tell_file_func ) OF ( ( voidpf opaque , voidpf stream ) ) ; <nl> - typedef long ( ZCALLBACK * seek_file_func ) OF ( ( voidpf opaque , voidpf stream , uLong offset , int origin ) ) ; <nl> - <nl> - <nl> - / * here is the " old " 32 bits structure structure * / <nl> - typedef struct zlib_filefunc_def_s <nl> - { <nl> - open_file_func zopen_file ; <nl> - read_file_func zread_file ; <nl> - write_file_func zwrite_file ; <nl> - tell_file_func ztell_file ; <nl> - seek_file_func zseek_file ; <nl> - close_file_func zclose_file ; <nl> - testerror_file_func zerror_file ; <nl> - voidpf opaque ; <nl> - } zlib_filefunc_def ; <nl> - <nl> - typedef ZPOS64_T ( ZCALLBACK * tell64_file_func ) OF ( ( voidpf opaque , voidpf stream ) ) ; <nl> - typedef long ( ZCALLBACK * seek64_file_func ) OF ( ( voidpf opaque , voidpf stream , ZPOS64_T offset , int origin ) ) ; <nl> - typedef voidpf ( ZCALLBACK * open64_file_func ) OF ( ( voidpf opaque , const void * filename , int mode ) ) ; <nl> - <nl> - typedef struct zlib_filefunc64_def_s <nl> - { <nl> - open64_file_func zopen64_file ; <nl> - read_file_func zread_file ; <nl> - write_file_func zwrite_file ; <nl> - tell64_file_func ztell64_file ; <nl> - seek64_file_func zseek64_file ; <nl> - close_file_func zclose_file ; <nl> - testerror_file_func zerror_file ; <nl> - voidpf opaque ; <nl> - } zlib_filefunc64_def ; <nl> - <nl> - void fill_fopen64_filefunc OF ( ( zlib_filefunc64_def * pzlib_filefunc_def ) ) ; <nl> - void fill_fopen_filefunc OF ( ( zlib_filefunc_def * pzlib_filefunc_def ) ) ; <nl> - <nl> - / * now internal definition , only for zip . c and unzip . h * / <nl> - typedef struct zlib_filefunc64_32_def_s <nl> - { <nl> - zlib_filefunc64_def zfile_func64 ; <nl> - open_file_func zopen32_file ; <nl> - tell_file_func ztell32_file ; <nl> - seek_file_func zseek32_file ; <nl> - } zlib_filefunc64_32_def ; <nl> - <nl> - <nl> - # define ZREAD64 ( filefunc , filestream , buf , size ) ( ( * ( ( filefunc ) . zfile_func64 . zread_file ) ) ( ( filefunc ) . zfile_func64 . opaque , filestream , buf , size ) ) <nl> - # define ZWRITE64 ( filefunc , filestream , buf , size ) ( ( * ( ( filefunc ) . zfile_func64 . zwrite_file ) ) ( ( filefunc ) . zfile_func64 . opaque , filestream , buf , size ) ) <nl> - / / # define ZTELL64 ( filefunc , filestream ) ( ( * ( ( filefunc ) . ztell64_file ) ) ( ( filefunc ) . opaque , filestream ) ) <nl> - / / # define ZSEEK64 ( filefunc , filestream , pos , mode ) ( ( * ( ( filefunc ) . zseek64_file ) ) ( ( filefunc ) . opaque , filestream , pos , mode ) ) <nl> - # define ZCLOSE64 ( filefunc , filestream ) ( ( * ( ( filefunc ) . zfile_func64 . zclose_file ) ) ( ( filefunc ) . zfile_func64 . opaque , filestream ) ) <nl> - # define ZERROR64 ( filefunc , filestream ) ( ( * ( ( filefunc ) . zfile_func64 . zerror_file ) ) ( ( filefunc ) . zfile_func64 . opaque , filestream ) ) <nl> - <nl> - voidpf call_zopen64 OF ( ( const zlib_filefunc64_32_def * pfilefunc , const void * filename , int mode ) ) ; <nl> - long call_zseek64 OF ( ( const zlib_filefunc64_32_def * pfilefunc , voidpf filestream , ZPOS64_T offset , int origin ) ) ; <nl> - ZPOS64_T call_ztell64 OF ( ( const zlib_filefunc64_32_def * pfilefunc , voidpf filestream ) ) ; <nl> - <nl> - void fill_zlib_filefunc64_32_def_from_filefunc32 ( zlib_filefunc64_32_def * p_filefunc64_32 , const zlib_filefunc_def * p_filefunc32 ) ; <nl> - <nl> - # define ZOPEN64 ( filefunc , filename , mode ) ( call_zopen64 ( ( & ( filefunc ) ) , ( filename ) , ( mode ) ) ) <nl> - # define ZTELL64 ( filefunc , filestream ) ( call_ztell64 ( ( & ( filefunc ) ) , ( filestream ) ) ) <nl> - # define ZSEEK64 ( filefunc , filestream , pos , mode ) ( call_zseek64 ( ( & ( filefunc ) ) , ( filestream ) , ( pos ) , ( mode ) ) ) <nl> - <nl> - } / / end of namespace cocos2d <nl> - <nl> - # endif <nl> deleted file mode 100644 <nl> index 66cfeff16a6f . . 000000000000 <nl> mmm a / cocos / 2d / support / zip_support / unzip . cpp <nl> ppp / dev / null <nl> <nl> - / * unzip . c - - IO for uncompress . zip files using zlib <nl> - Version 1 . 1 , February 14h , 2010 <nl> - part of the MiniZip project - ( http : / / www . winimage . com / zLibDll / minizip . html ) <nl> - <nl> - Copyright ( C ) 1998 - 2010 Gilles Vollant ( minizip ) ( http : / / www . winimage . com / zLibDll / minizip . html ) <nl> - <nl> - Modifications of Unzip for Zip64 <nl> - Copyright ( C ) 2007 - 2008 Even Rouault <nl> - <nl> - Modifications for Zip64 support on both zip and unzip <nl> - Copyright ( C ) 2009 - 2010 Mathias Svensson ( http : / / result42 . com ) <nl> - <nl> - For more info read MiniZip_info . txt <nl> - <nl> - <nl> - mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> - Decryption code comes from crypt . c by Info - ZIP but has been greatly reduced in terms of <nl> - compatibility with older software . The following is from the original crypt . c . <nl> - Code woven in by Terry Thorsen 1 / 2003 . <nl> - <nl> - Copyright ( c ) 1990 - 2000 Info - ZIP . All rights reserved . <nl> - <nl> - See the accompanying file LICENSE , version 2000 - Apr - 09 or later <nl> - ( the contents of which are also included in zip . h ) for terms of use . <nl> - If , for some reason , all these files are missing , the Info - ZIP license <nl> - also may be found at : ftp : / / ftp . info - zip . org / pub / infozip / license . html <nl> - <nl> - crypt . c ( full version ) by Info - ZIP . Last revised : [ see crypt . h ] <nl> - <nl> - The encryption / decryption parts of this source code ( as opposed to the <nl> - non - echoing password parts ) were originally written in Europe . The <nl> - whole source package can be freely distributed , including from the USA . <nl> - ( Prior to January 2000 , re - export from the US was a violation of US law . ) <nl> - <nl> - This encryption code is a direct transcription of the algorithm from <nl> - Roger Schlafly , described by Phil Katz in the file appnote . txt . This <nl> - file ( appnote . txt ) is distributed with the PKZIP program ( even in the <nl> - version without encryption capabilities ) . <nl> - <nl> - mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> - <nl> - Changes in unzip . c <nl> - <nl> - 2007 - 2008 - Even Rouault - Addition of cpl_unzGetCurrentFileZStreamPos <nl> - 2007 - 2008 - Even Rouault - Decoration of symbol names unz * - > cpl_unz * <nl> - 2007 - 2008 - Even Rouault - Remove old C style function prototypes <nl> - 2007 - 2008 - Even Rouault - Add unzip support for ZIP64 <nl> - <nl> - Copyright ( C ) 2007 - 2008 Even Rouault <nl> - <nl> - <nl> - Oct - 2009 - Mathias Svensson - Removed cpl_ * from symbol names ( Even Rouault added them but since this is now moved to a new project ( minizip64 ) I renamed them again ) . <nl> - Oct - 2009 - Mathias Svensson - Fixed problem if uncompressed size was > 4G and compressed size was < 4G <nl> - should only read the compressed / uncompressed size from the Zip64 format if <nl> - the size from normal header was 0xFFFFFFFF <nl> - Oct - 2009 - Mathias Svensson - Applied some bug fixes from patches received from Gilles Vollant <nl> - Oct - 2009 - Mathias Svensson - Applied support to unzip files with compression method BZIP2 ( bzip2 lib is required ) <nl> - Patch created by Daniel Borca <nl> - <nl> - Jan - 2010 - back to unzip and minizip 1 . 0 name scheme , with compatibility layer <nl> - <nl> - Copyright ( C ) 1998 - 2010 Gilles Vollant , Even Rouault , Mathias Svensson <nl> - <nl> - * / <nl> - <nl> - <nl> - # include < stdio . h > <nl> - # include < stdlib . h > <nl> - # include < string . h > <nl> - <nl> - # ifndef NOUNCRYPT <nl> - # define NOUNCRYPT <nl> - # endif <nl> - <nl> - # include " zlib . h " <nl> - # include " unzip . h " <nl> - <nl> - # ifdef STDC <nl> - # include < stddef . h > <nl> - # include < string . h > <nl> - # include < stdlib . h > <nl> - # endif <nl> - # ifdef NO_ERRNO_H <nl> - extern int errno ; <nl> - # else <nl> - # include < errno . h > <nl> - # endif <nl> - <nl> - namespace cocos2d { <nl> - <nl> - # ifndef local <nl> - # define local static <nl> - # endif <nl> - / * compile with - Dlocal if your debugger can ' t find static symbols * / <nl> - <nl> - <nl> - # ifndef CASESENSITIVITYDEFAULT_NO <nl> - # if ! defined ( unix ) & & ! defined ( CASESENSITIVITYDEFAULT_YES ) <nl> - # define CASESENSITIVITYDEFAULT_NO <nl> - # endif <nl> - # endif <nl> - <nl> - <nl> - # ifndef UNZ_BUFSIZE <nl> - # define UNZ_BUFSIZE ( 16384 ) <nl> - # endif <nl> - <nl> - # ifndef UNZ_MAXFILENAMEINZIP <nl> - # define UNZ_MAXFILENAMEINZIP ( 256 ) <nl> - # endif <nl> - <nl> - # ifndef ALLOC <nl> - # define ALLOC ( size ) ( malloc ( size ) ) <nl> - # endif <nl> - # ifndef TRYFREE <nl> - # define TRYFREE ( p ) { if ( p ) free ( p ) ; } <nl> - # endif <nl> - <nl> - # define SIZECENTRALDIRITEM ( 0x2e ) <nl> - # define SIZEZIPLOCALHEADER ( 0x1e ) <nl> - <nl> - <nl> - const char unz_copyright [ ] = <nl> - " unzip 1 . 01 Copyright 1998 - 2004 Gilles Vollant - http : / / www . winimage . com / zLibDll " ; <nl> - <nl> - / * unz_file_info_interntal contain internal info about a file in zipfile * / <nl> - typedef struct unz_file_info64_internal_s <nl> - { <nl> - ZPOS64_T offset_curfile ; / * relative offset of local header 8 bytes * / <nl> - } unz_file_info64_internal ; <nl> - <nl> - <nl> - / * file_in_zip_read_info_s contain internal information about a file in zipfile , <nl> - when reading and decompress it * / <nl> - typedef struct <nl> - { <nl> - char * read_buffer ; / * internal buffer for compressed data * / <nl> - z_stream stream ; / * zLib stream structure for inflate * / <nl> - <nl> - # ifdef HAVE_BZIP2 <nl> - bz_stream bstream ; / * bzLib stream structure for bziped * / <nl> - # endif <nl> - <nl> - ZPOS64_T pos_in_zipfile ; / * position in byte on the zipfile , for fseek * / <nl> - uLong stream_initialised ; / * flag set if stream structure is initialized * / <nl> - <nl> - ZPOS64_T offset_local_extrafield ; / * offset of the local extra field * / <nl> - uInt size_local_extrafield ; / * size of the local extra field * / <nl> - ZPOS64_T pos_local_extrafield ; / * position in the local extra field in read * / <nl> - ZPOS64_T total_out_64 ; <nl> - <nl> - uLong crc32 ; / * crc32 of all data uncompressed * / <nl> - uLong crc32_wait ; / * crc32 we must obtain after decompress all * / <nl> - ZPOS64_T rest_read_compressed ; / * number of byte to be decompressed * / <nl> - ZPOS64_T rest_read_uncompressed ; / * number of byte to be obtained after decomp * / <nl> - zlib_filefunc64_32_def z_filefunc ; <nl> - voidpf filestream ; / * io structure of the zipfile * / <nl> - uLong compression_method ; / * compression method ( 0 = = store ) * / <nl> - ZPOS64_T byte_before_the_zipfile ; / * byte before the zipfile , ( > 0 for sfx ) * / <nl> - int raw ; <nl> - } file_in_zip64_read_info_s ; <nl> - <nl> - <nl> - / * unz64_s contain internal information about the zipfile <nl> - * / <nl> - typedef struct <nl> - { <nl> - zlib_filefunc64_32_def z_filefunc ; <nl> - int is64bitOpenFunction ; <nl> - voidpf filestream ; / * io structure of the zipfile * / <nl> - unz_global_info64 gi ; / * public global information * / <nl> - ZPOS64_T byte_before_the_zipfile ; / * byte before the zipfile , ( > 0 for sfx ) * / <nl> - ZPOS64_T num_file ; / * number of the current file in the zipfile * / <nl> - ZPOS64_T pos_in_central_dir ; / * pos of the current file in the central dir * / <nl> - ZPOS64_T current_file_ok ; / * flag about the usability of the current file * / <nl> - ZPOS64_T central_pos ; / * position of the beginning of the central dir * / <nl> - <nl> - ZPOS64_T size_central_dir ; / * size of the central directory * / <nl> - ZPOS64_T offset_central_dir ; / * offset of start of central directory with <nl> - respect to the starting disk number * / <nl> - <nl> - unz_file_info64 cur_file_info ; / * public info about the current file in zip * / <nl> - unz_file_info64_internal cur_file_info_internal ; / * private info about it * / <nl> - file_in_zip64_read_info_s * pfile_in_zip_read ; / * structure about the current <nl> - file if we are decompressing it * / <nl> - int encrypted ; <nl> - <nl> - int isZip64 ; <nl> - <nl> - # ifndef NOUNCRYPT <nl> - unsigned long keys [ 3 ] ; / * keys defining the pseudo - random sequence * / <nl> - const unsigned long * pcrc_32_tab ; <nl> - # endif <nl> - } unz64_s ; <nl> - <nl> - <nl> - # ifndef NOUNCRYPT <nl> - # include " crypt . h " <nl> - # endif <nl> - <nl> - / * = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - Read a byte from a gz_stream ; update next_in and avail_in . Return EOF <nl> - for end of file . <nl> - IN assertion : the stream s has been successfully opened for reading . <nl> - * / <nl> - <nl> - <nl> - local int unz64local_getByte OF ( ( <nl> - const zlib_filefunc64_32_def * pzlib_filefunc_def , <nl> - voidpf filestream , <nl> - int * pi ) ) ; <nl> - <nl> - local int unz64local_getByte ( const zlib_filefunc64_32_def * pzlib_filefunc_def , voidpf filestream , int * pi ) <nl> - { <nl> - unsigned char c ; <nl> - int err = ( int ) ZREAD64 ( * pzlib_filefunc_def , filestream , & c , 1 ) ; <nl> - if ( err = = 1 ) <nl> - { <nl> - * pi = ( int ) c ; <nl> - return UNZ_OK ; <nl> - } <nl> - else <nl> - { <nl> - if ( ZERROR64 ( * pzlib_filefunc_def , filestream ) ) <nl> - return UNZ_ERRNO ; <nl> - else <nl> - return UNZ_EOF ; <nl> - } <nl> - } <nl> - <nl> - <nl> - / * = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - Reads a long in LSB order from the given gz_stream . Sets <nl> - * / <nl> - local int unz64local_getShort OF ( ( <nl> - const zlib_filefunc64_32_def * pzlib_filefunc_def , <nl> - voidpf filestream , <nl> - uLong * pX ) ) ; <nl> - <nl> - local int unz64local_getShort ( const zlib_filefunc64_32_def * pzlib_filefunc_def , <nl> - voidpf filestream , <nl> - uLong * pX ) <nl> - { <nl> - uLong x ; <nl> - int i = 0 ; <nl> - int err ; <nl> - <nl> - err = unz64local_getByte ( pzlib_filefunc_def , filestream , & i ) ; <nl> - x = ( uLong ) i ; <nl> - <nl> - if ( err = = UNZ_OK ) <nl> - err = unz64local_getByte ( pzlib_filefunc_def , filestream , & i ) ; <nl> - x | = ( ( uLong ) i ) < < 8 ; <nl> - <nl> - if ( err = = UNZ_OK ) <nl> - * pX = x ; <nl> - else <nl> - * pX = 0 ; <nl> - return err ; <nl> - } <nl> - <nl> - local int unz64local_getLong OF ( ( <nl> - const zlib_filefunc64_32_def * pzlib_filefunc_def , <nl> - voidpf filestream , <nl> - uLong * pX ) ) ; <nl> - <nl> - local int unz64local_getLong ( const zlib_filefunc64_32_def * pzlib_filefunc_def , <nl> - voidpf filestream , <nl> - uLong * pX ) <nl> - { <nl> - uLong x ; <nl> - int i = 0 ; <nl> - int err ; <nl> - <nl> - err = unz64local_getByte ( pzlib_filefunc_def , filestream , & i ) ; <nl> - x = ( uLong ) i ; <nl> - <nl> - if ( err = = UNZ_OK ) <nl> - err = unz64local_getByte ( pzlib_filefunc_def , filestream , & i ) ; <nl> - x | = ( ( uLong ) i ) < < 8 ; <nl> - <nl> - if ( err = = UNZ_OK ) <nl> - err = unz64local_getByte ( pzlib_filefunc_def , filestream , & i ) ; <nl> - x | = ( ( uLong ) i ) < < 16 ; <nl> - <nl> - if ( err = = UNZ_OK ) <nl> - err = unz64local_getByte ( pzlib_filefunc_def , filestream , & i ) ; <nl> - x + = ( ( uLong ) i ) < < 24 ; <nl> - <nl> - if ( err = = UNZ_OK ) <nl> - * pX = x ; <nl> - else <nl> - * pX = 0 ; <nl> - return err ; <nl> - } <nl> - <nl> - local int unz64local_getLong64 OF ( ( <nl> - const zlib_filefunc64_32_def * pzlib_filefunc_def , <nl> - voidpf filestream , <nl> - ZPOS64_T * pX ) ) ; <nl> - <nl> - <nl> - local int unz64local_getLong64 ( const zlib_filefunc64_32_def * pzlib_filefunc_def , <nl> - voidpf filestream , <nl> - ZPOS64_T * pX ) <nl> - { <nl> - ZPOS64_T x ; <nl> - int i = 0 ; <nl> - int err ; <nl> - <nl> - err = unz64local_getByte ( pzlib_filefunc_def , filestream , & i ) ; <nl> - x = ( ZPOS64_T ) i ; <nl> - <nl> - if ( err = = UNZ_OK ) <nl> - err = unz64local_getByte ( pzlib_filefunc_def , filestream , & i ) ; <nl> - x | = ( ( ZPOS64_T ) i ) < < 8 ; <nl> - <nl> - if ( err = = UNZ_OK ) <nl> - err = unz64local_getByte ( pzlib_filefunc_def , filestream , & i ) ; <nl> - x | = ( ( ZPOS64_T ) i ) < < 16 ; <nl> - <nl> - if ( err = = UNZ_OK ) <nl> - err = unz64local_getByte ( pzlib_filefunc_def , filestream , & i ) ; <nl> - x | = ( ( ZPOS64_T ) i ) < < 24 ; <nl> - <nl> - if ( err = = UNZ_OK ) <nl> - err = unz64local_getByte ( pzlib_filefunc_def , filestream , & i ) ; <nl> - x | = ( ( ZPOS64_T ) i ) < < 32 ; <nl> - <nl> - if ( err = = UNZ_OK ) <nl> - err = unz64local_getByte ( pzlib_filefunc_def , filestream , & i ) ; <nl> - x | = ( ( ZPOS64_T ) i ) < < 40 ; <nl> - <nl> - if ( err = = UNZ_OK ) <nl> - err = unz64local_getByte ( pzlib_filefunc_def , filestream , & i ) ; <nl> - x | = ( ( ZPOS64_T ) i ) < < 48 ; <nl> - <nl> - if ( err = = UNZ_OK ) <nl> - err = unz64local_getByte ( pzlib_filefunc_def , filestream , & i ) ; <nl> - x | = ( ( ZPOS64_T ) i ) < < 56 ; <nl> - <nl> - if ( err = = UNZ_OK ) <nl> - * pX = x ; <nl> - else <nl> - * pX = 0 ; <nl> - return err ; <nl> - } <nl> - <nl> - / * My own strcmpi / strcasecmp * / <nl> - local int strcmpcasenosensitive_internal ( const char * fileName1 , const char * fileName2 ) <nl> - { <nl> - for ( ; ; ) <nl> - { <nl> - char c1 = * ( fileName1 + + ) ; <nl> - char c2 = * ( fileName2 + + ) ; <nl> - if ( ( c1 > = ' a ' ) & & ( c1 < = ' z ' ) ) <nl> - c1 - = 0x20 ; <nl> - if ( ( c2 > = ' a ' ) & & ( c2 < = ' z ' ) ) <nl> - c2 - = 0x20 ; <nl> - if ( c1 = = ' \ 0 ' ) <nl> - return ( ( c2 = = ' \ 0 ' ) ? 0 : - 1 ) ; <nl> - if ( c2 = = ' \ 0 ' ) <nl> - return 1 ; <nl> - if ( c1 < c2 ) <nl> - return - 1 ; <nl> - if ( c1 > c2 ) <nl> - return 1 ; <nl> - } <nl> - } <nl> - <nl> - <nl> - # ifdef CASESENSITIVITYDEFAULT_NO <nl> - # define CASESENSITIVITYDEFAULTVALUE 2 <nl> - # else <nl> - # define CASESENSITIVITYDEFAULTVALUE 1 <nl> - # endif <nl> - <nl> - # ifndef STRCMPCASENOSENTIVEFUNCTION <nl> - # define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal <nl> - # endif <nl> - <nl> - / * <nl> - Compare two filename ( fileName1 , fileName2 ) . <nl> - If iCaseSenisivity = 1 , comparison is case sensitivity ( like strcmp ) <nl> - If iCaseSenisivity = 2 , comparison is not case sensitivity ( like strcmpi <nl> - or strcasecmp ) <nl> - If iCaseSenisivity = 0 , case sensitivity is default of your operating system <nl> - ( like 1 on Unix , 2 on Windows ) <nl> - <nl> - * / <nl> - int ZEXPORT unzStringFileNameCompare ( const char * fileName1 , <nl> - const char * fileName2 , <nl> - int iCaseSensitivity ) <nl> - <nl> - { <nl> - if ( iCaseSensitivity = = 0 ) <nl> - iCaseSensitivity = CASESENSITIVITYDEFAULTVALUE ; <nl> - <nl> - if ( iCaseSensitivity = = 1 ) <nl> - return strcmp ( fileName1 , fileName2 ) ; <nl> - <nl> - return STRCMPCASENOSENTIVEFUNCTION ( fileName1 , fileName2 ) ; <nl> - } <nl> - <nl> - # ifndef BUFREADCOMMENT <nl> - # define BUFREADCOMMENT ( 0x400 ) <nl> - # endif <nl> - <nl> - / * <nl> - Locate the Central directory of a zipfile ( at the end , just before <nl> - the global comment ) <nl> - * / <nl> - local ZPOS64_T unz64local_SearchCentralDir OF ( ( const zlib_filefunc64_32_def * pzlib_filefunc_def , voidpf filestream ) ) ; <nl> - local ZPOS64_T unz64local_SearchCentralDir ( const zlib_filefunc64_32_def * pzlib_filefunc_def , voidpf filestream ) <nl> - { <nl> - unsigned char * buf ; <nl> - ZPOS64_T uSizeFile ; <nl> - ZPOS64_T uBackRead ; <nl> - ZPOS64_T uMaxBack = 0xffff ; / * maximum size of global comment * / <nl> - ZPOS64_T uPosFound = 0 ; <nl> - <nl> - if ( ZSEEK64 ( * pzlib_filefunc_def , filestream , 0 , ZLIB_FILEFUNC_SEEK_END ) ! = 0 ) <nl> - return 0 ; <nl> - <nl> - <nl> - uSizeFile = ZTELL64 ( * pzlib_filefunc_def , filestream ) ; <nl> - <nl> - if ( uMaxBack > uSizeFile ) <nl> - uMaxBack = uSizeFile ; <nl> - <nl> - buf = ( unsigned char * ) ALLOC ( BUFREADCOMMENT + 4 ) ; <nl> - if ( buf = = NULL ) <nl> - return 0 ; <nl> - <nl> - uBackRead = 4 ; <nl> - while ( uBackRead < uMaxBack ) <nl> - { <nl> - uLong uReadSize ; <nl> - ZPOS64_T uReadPos ; <nl> - int i ; <nl> - if ( uBackRead + BUFREADCOMMENT > uMaxBack ) <nl> - uBackRead = uMaxBack ; <nl> - else <nl> - uBackRead + = BUFREADCOMMENT ; <nl> - uReadPos = uSizeFile - uBackRead ; <nl> - <nl> - uReadSize = ( ( BUFREADCOMMENT + 4 ) < ( uSizeFile - uReadPos ) ) ? <nl> - ( BUFREADCOMMENT + 4 ) : ( uLong ) ( uSizeFile - uReadPos ) ; <nl> - if ( ZSEEK64 ( * pzlib_filefunc_def , filestream , uReadPos , ZLIB_FILEFUNC_SEEK_SET ) ! = 0 ) <nl> - break ; <nl> - <nl> - if ( ZREAD64 ( * pzlib_filefunc_def , filestream , buf , uReadSize ) ! = uReadSize ) <nl> - break ; <nl> - <nl> - for ( i = ( int ) uReadSize - 3 ; ( i - - ) > 0 ; ) <nl> - if ( ( ( * ( buf + i ) ) = = 0x50 ) & & ( ( * ( buf + i + 1 ) ) = = 0x4b ) & & <nl> - ( ( * ( buf + i + 2 ) ) = = 0x05 ) & & ( ( * ( buf + i + 3 ) ) = = 0x06 ) ) <nl> - { <nl> - uPosFound = uReadPos + i ; <nl> - break ; <nl> - } <nl> - <nl> - if ( uPosFound ! = 0 ) <nl> - break ; <nl> - } <nl> - TRYFREE ( buf ) ; <nl> - return uPosFound ; <nl> - } <nl> - <nl> - <nl> - / * <nl> - Locate the Central directory 64 of a zipfile ( at the end , just before <nl> - the global comment ) <nl> - * / <nl> - local ZPOS64_T unz64local_SearchCentralDir64 OF ( ( <nl> - const zlib_filefunc64_32_def * pzlib_filefunc_def , <nl> - voidpf filestream ) ) ; <nl> - <nl> - local ZPOS64_T unz64local_SearchCentralDir64 ( const zlib_filefunc64_32_def * pzlib_filefunc_def , <nl> - voidpf filestream ) <nl> - { <nl> - unsigned char * buf ; <nl> - ZPOS64_T uSizeFile ; <nl> - ZPOS64_T uBackRead ; <nl> - ZPOS64_T uMaxBack = 0xffff ; / * maximum size of global comment * / <nl> - ZPOS64_T uPosFound = 0 ; <nl> - uLong uL ; <nl> - ZPOS64_T relativeOffset ; <nl> - <nl> - if ( ZSEEK64 ( * pzlib_filefunc_def , filestream , 0 , ZLIB_FILEFUNC_SEEK_END ) ! = 0 ) <nl> - return 0 ; <nl> - <nl> - <nl> - uSizeFile = ZTELL64 ( * pzlib_filefunc_def , filestream ) ; <nl> - <nl> - if ( uMaxBack > uSizeFile ) <nl> - uMaxBack = uSizeFile ; <nl> - <nl> - buf = ( unsigned char * ) ALLOC ( BUFREADCOMMENT + 4 ) ; <nl> - if ( buf = = NULL ) <nl> - return 0 ; <nl> - <nl> - uBackRead = 4 ; <nl> - while ( uBackRead < uMaxBack ) <nl> - { <nl> - uLong uReadSize ; <nl> - ZPOS64_T uReadPos ; <nl> - int i ; <nl> - if ( uBackRead + BUFREADCOMMENT > uMaxBack ) <nl> - uBackRead = uMaxBack ; <nl> - else <nl> - uBackRead + = BUFREADCOMMENT ; <nl> - uReadPos = uSizeFile - uBackRead ; <nl> - <nl> - uReadSize = ( ( BUFREADCOMMENT + 4 ) < ( uSizeFile - uReadPos ) ) ? <nl> - ( BUFREADCOMMENT + 4 ) : ( uLong ) ( uSizeFile - uReadPos ) ; <nl> - if ( ZSEEK64 ( * pzlib_filefunc_def , filestream , uReadPos , ZLIB_FILEFUNC_SEEK_SET ) ! = 0 ) <nl> - break ; <nl> - <nl> - if ( ZREAD64 ( * pzlib_filefunc_def , filestream , buf , uReadSize ) ! = uReadSize ) <nl> - break ; <nl> - <nl> - for ( i = ( int ) uReadSize - 3 ; ( i - - ) > 0 ; ) <nl> - if ( ( ( * ( buf + i ) ) = = 0x50 ) & & ( ( * ( buf + i + 1 ) ) = = 0x4b ) & & <nl> - ( ( * ( buf + i + 2 ) ) = = 0x06 ) & & ( ( * ( buf + i + 3 ) ) = = 0x07 ) ) <nl> - { <nl> - uPosFound = uReadPos + i ; <nl> - break ; <nl> - } <nl> - <nl> - if ( uPosFound ! = 0 ) <nl> - break ; <nl> - } <nl> - TRYFREE ( buf ) ; <nl> - if ( uPosFound = = 0 ) <nl> - return 0 ; <nl> - <nl> - / * Zip64 end of central directory locator * / <nl> - if ( ZSEEK64 ( * pzlib_filefunc_def , filestream , uPosFound , ZLIB_FILEFUNC_SEEK_SET ) ! = 0 ) <nl> - return 0 ; <nl> - <nl> - / * the signature , already checked * / <nl> - if ( unz64local_getLong ( pzlib_filefunc_def , filestream , & uL ) ! = UNZ_OK ) <nl> - return 0 ; <nl> - <nl> - / * number of the disk with the start of the zip64 end of central directory * / <nl> - if ( unz64local_getLong ( pzlib_filefunc_def , filestream , & uL ) ! = UNZ_OK ) <nl> - return 0 ; <nl> - if ( uL ! = 0 ) <nl> - return 0 ; <nl> - <nl> - / * relative offset of the zip64 end of central directory record * / <nl> - if ( unz64local_getLong64 ( pzlib_filefunc_def , filestream , & relativeOffset ) ! = UNZ_OK ) <nl> - return 0 ; <nl> - <nl> - / * total number of disks * / <nl> - if ( unz64local_getLong ( pzlib_filefunc_def , filestream , & uL ) ! = UNZ_OK ) <nl> - return 0 ; <nl> - if ( uL ! = 1 ) <nl> - return 0 ; <nl> - <nl> - / * Goto end of central directory record * / <nl> - if ( ZSEEK64 ( * pzlib_filefunc_def , filestream , relativeOffset , ZLIB_FILEFUNC_SEEK_SET ) ! = 0 ) <nl> - return 0 ; <nl> - <nl> - / * the signature * / <nl> - if ( unz64local_getLong ( pzlib_filefunc_def , filestream , & uL ) ! = UNZ_OK ) <nl> - return 0 ; <nl> - <nl> - if ( uL ! = 0x06064b50 ) <nl> - return 0 ; <nl> - <nl> - return relativeOffset ; <nl> - } <nl> - <nl> - / * <nl> - Open a Zip file . path contain the full pathname ( by example , <nl> - on a Windows NT computer " c : \ \ test \ \ zlib114 . zip " or on an Unix computer <nl> - " zlib / zlib114 . zip " . <nl> - If the zipfile cannot be opened ( file doesn ' t exist or in not valid ) , the <nl> - return value is NULL . <nl> - Else , the return value is a unzFile Handle , usable with other function <nl> - of this unzip package . <nl> - * / <nl> - local unzFile unzOpenInternal ( const void * path , <nl> - zlib_filefunc64_32_def * pzlib_filefunc64_32_def , <nl> - int is64bitOpenFunction ) <nl> - { <nl> - unz64_s us ; <nl> - unz64_s * s ; <nl> - ZPOS64_T central_pos ; <nl> - uLong uL ; <nl> - <nl> - uLong number_disk ; / * number of the current dist , used for <nl> - spanning ZIP , unsupported , always 0 * / <nl> - uLong number_disk_with_CD ; / * number the the disk with central dir , used <nl> - for spanning ZIP , unsupported , always 0 * / <nl> - ZPOS64_T number_entry_CD ; / * total number of entries in <nl> - the central dir <nl> - ( same than number_entry on nospan ) * / <nl> - <nl> - int err = UNZ_OK ; <nl> - <nl> - if ( unz_copyright [ 0 ] ! = ' ' ) <nl> - return NULL ; <nl> - <nl> - us . z_filefunc . zseek32_file = NULL ; <nl> - us . z_filefunc . ztell32_file = NULL ; <nl> - if ( pzlib_filefunc64_32_def = = NULL ) <nl> - fill_fopen64_filefunc ( & us . z_filefunc . zfile_func64 ) ; <nl> - else <nl> - us . z_filefunc = * pzlib_filefunc64_32_def ; <nl> - us . is64bitOpenFunction = is64bitOpenFunction ; <nl> - <nl> - <nl> - <nl> - us . filestream = ZOPEN64 ( us . z_filefunc , <nl> - path , <nl> - ZLIB_FILEFUNC_MODE_READ | <nl> - ZLIB_FILEFUNC_MODE_EXISTING ) ; <nl> - if ( us . filestream = = NULL ) <nl> - return NULL ; <nl> - <nl> - central_pos = unz64local_SearchCentralDir64 ( & us . z_filefunc , us . filestream ) ; <nl> - if ( central_pos ) <nl> - { <nl> - uLong uS ; <nl> - ZPOS64_T uL64 ; <nl> - <nl> - us . isZip64 = 1 ; <nl> - <nl> - if ( ZSEEK64 ( us . z_filefunc , us . filestream , <nl> - central_pos , ZLIB_FILEFUNC_SEEK_SET ) ! = 0 ) <nl> - err = UNZ_ERRNO ; <nl> - <nl> - / * the signature , already checked * / <nl> - if ( unz64local_getLong ( & us . z_filefunc , us . filestream , & uL ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - <nl> - / * size of zip64 end of central directory record * / <nl> - if ( unz64local_getLong64 ( & us . z_filefunc , us . filestream , & uL64 ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - <nl> - / * version made by * / <nl> - if ( unz64local_getShort ( & us . z_filefunc , us . filestream , & uS ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - <nl> - / * version needed to extract * / <nl> - if ( unz64local_getShort ( & us . z_filefunc , us . filestream , & uS ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - <nl> - / * number of this disk * / <nl> - if ( unz64local_getLong ( & us . z_filefunc , us . filestream , & number_disk ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - <nl> - / * number of the disk with the start of the central directory * / <nl> - if ( unz64local_getLong ( & us . z_filefunc , us . filestream , & number_disk_with_CD ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - <nl> - / * total number of entries in the central directory on this disk * / <nl> - if ( unz64local_getLong64 ( & us . z_filefunc , us . filestream , & us . gi . number_entry ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - <nl> - / * total number of entries in the central directory * / <nl> - if ( unz64local_getLong64 ( & us . z_filefunc , us . filestream , & number_entry_CD ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - <nl> - if ( ( number_entry_CD ! = us . gi . number_entry ) | | <nl> - ( number_disk_with_CD ! = 0 ) | | <nl> - ( number_disk ! = 0 ) ) <nl> - err = UNZ_BADZIPFILE ; <nl> - <nl> - / * size of the central directory * / <nl> - if ( unz64local_getLong64 ( & us . z_filefunc , us . filestream , & us . size_central_dir ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - <nl> - / * offset of start of central directory with respect to the <nl> - starting disk number * / <nl> - if ( unz64local_getLong64 ( & us . z_filefunc , us . filestream , & us . offset_central_dir ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - <nl> - us . gi . size_comment = 0 ; <nl> - } <nl> - else <nl> - { <nl> - central_pos = unz64local_SearchCentralDir ( & us . z_filefunc , us . filestream ) ; <nl> - if ( central_pos = = 0 ) <nl> - err = UNZ_ERRNO ; <nl> - <nl> - us . isZip64 = 0 ; <nl> - <nl> - if ( ZSEEK64 ( us . z_filefunc , us . filestream , <nl> - central_pos , ZLIB_FILEFUNC_SEEK_SET ) ! = 0 ) <nl> - err = UNZ_ERRNO ; <nl> - <nl> - / * the signature , already checked * / <nl> - if ( unz64local_getLong ( & us . z_filefunc , us . filestream , & uL ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - <nl> - / * number of this disk * / <nl> - if ( unz64local_getShort ( & us . z_filefunc , us . filestream , & number_disk ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - <nl> - / * number of the disk with the start of the central directory * / <nl> - if ( unz64local_getShort ( & us . z_filefunc , us . filestream , & number_disk_with_CD ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - <nl> - / * total number of entries in the central dir on this disk * / <nl> - if ( unz64local_getShort ( & us . z_filefunc , us . filestream , & uL ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - us . gi . number_entry = uL ; <nl> - <nl> - / * total number of entries in the central dir * / <nl> - if ( unz64local_getShort ( & us . z_filefunc , us . filestream , & uL ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - number_entry_CD = uL ; <nl> - <nl> - if ( ( number_entry_CD ! = us . gi . number_entry ) | | <nl> - ( number_disk_with_CD ! = 0 ) | | <nl> - ( number_disk ! = 0 ) ) <nl> - err = UNZ_BADZIPFILE ; <nl> - <nl> - / * size of the central directory * / <nl> - if ( unz64local_getLong ( & us . z_filefunc , us . filestream , & uL ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - us . size_central_dir = uL ; <nl> - <nl> - / * offset of start of central directory with respect to the <nl> - starting disk number * / <nl> - if ( unz64local_getLong ( & us . z_filefunc , us . filestream , & uL ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - us . offset_central_dir = uL ; <nl> - <nl> - / * zipfile comment length * / <nl> - if ( unz64local_getShort ( & us . z_filefunc , us . filestream , & us . gi . size_comment ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - } <nl> - <nl> - if ( ( central_pos < us . offset_central_dir + us . size_central_dir ) & & <nl> - ( err = = UNZ_OK ) ) <nl> - err = UNZ_BADZIPFILE ; <nl> - <nl> - if ( err ! = UNZ_OK ) <nl> - { <nl> - ZCLOSE64 ( us . z_filefunc , us . filestream ) ; <nl> - return NULL ; <nl> - } <nl> - <nl> - us . byte_before_the_zipfile = central_pos - <nl> - ( us . offset_central_dir + us . size_central_dir ) ; <nl> - us . central_pos = central_pos ; <nl> - us . pfile_in_zip_read = NULL ; <nl> - us . encrypted = 0 ; <nl> - <nl> - <nl> - s = ( unz64_s * ) ALLOC ( sizeof ( unz64_s ) ) ; <nl> - if ( s ! = NULL ) <nl> - { <nl> - * s = us ; <nl> - unzGoToFirstFile ( ( unzFile ) s ) ; <nl> - } <nl> - return ( unzFile ) s ; <nl> - } <nl> - <nl> - <nl> - unzFile ZEXPORT unzOpen2 ( const char * path , <nl> - zlib_filefunc_def * pzlib_filefunc32_def ) <nl> - { <nl> - if ( pzlib_filefunc32_def ! = NULL ) <nl> - { <nl> - zlib_filefunc64_32_def zlib_filefunc64_32_def_fill ; <nl> - fill_zlib_filefunc64_32_def_from_filefunc32 ( & zlib_filefunc64_32_def_fill , pzlib_filefunc32_def ) ; <nl> - return unzOpenInternal ( path , & zlib_filefunc64_32_def_fill , 0 ) ; <nl> - } <nl> - else <nl> - return unzOpenInternal ( path , NULL , 0 ) ; <nl> - } <nl> - <nl> - unzFile ZEXPORT unzOpen2_64 ( const void * path , <nl> - zlib_filefunc64_def * pzlib_filefunc_def ) <nl> - { <nl> - if ( pzlib_filefunc_def ! = NULL ) <nl> - { <nl> - zlib_filefunc64_32_def zlib_filefunc64_32_def_fill ; <nl> - zlib_filefunc64_32_def_fill . zfile_func64 = * pzlib_filefunc_def ; <nl> - zlib_filefunc64_32_def_fill . ztell32_file = NULL ; <nl> - zlib_filefunc64_32_def_fill . zseek32_file = NULL ; <nl> - return unzOpenInternal ( path , & zlib_filefunc64_32_def_fill , 1 ) ; <nl> - } <nl> - else <nl> - return unzOpenInternal ( path , NULL , 1 ) ; <nl> - } <nl> - <nl> - unzFile ZEXPORT unzOpen ( const char * path ) <nl> - { <nl> - return unzOpenInternal ( path , NULL , 0 ) ; <nl> - } <nl> - <nl> - unzFile ZEXPORT unzOpen64 ( const void * path ) <nl> - { <nl> - return unzOpenInternal ( path , NULL , 1 ) ; <nl> - } <nl> - <nl> - / * <nl> - Close a ZipFile opened with unzipOpen . <nl> - If there is files inside the . Zip opened with unzipOpenCurrentFile ( see later ) , <nl> - these files MUST be closed with unzipCloseCurrentFile before call unzipClose . <nl> - return UNZ_OK if there is no problem . * / <nl> - int ZEXPORT unzClose ( unzFile file ) <nl> - { <nl> - unz64_s * s ; <nl> - if ( file = = NULL ) <nl> - return UNZ_PARAMERROR ; <nl> - s = ( unz64_s * ) file ; <nl> - <nl> - if ( s - > pfile_in_zip_read ! = NULL ) <nl> - unzCloseCurrentFile ( file ) ; <nl> - <nl> - ZCLOSE64 ( s - > z_filefunc , s - > filestream ) ; <nl> - TRYFREE ( s ) ; <nl> - return UNZ_OK ; <nl> - } <nl> - <nl> - <nl> - / * <nl> - Write info about the ZipFile in the * pglobal_info structure . <nl> - No preparation of the structure is needed <nl> - return UNZ_OK if there is no problem . * / <nl> - int ZEXPORT unzGetGlobalInfo64 ( unzFile file , unz_global_info64 * pglobal_info ) <nl> - { <nl> - unz64_s * s ; <nl> - if ( file = = NULL ) <nl> - return UNZ_PARAMERROR ; <nl> - s = ( unz64_s * ) file ; <nl> - * pglobal_info = s - > gi ; <nl> - return UNZ_OK ; <nl> - } <nl> - <nl> - int ZEXPORT unzGetGlobalInfo ( unzFile file , unz_global_info * pglobal_info32 ) <nl> - { <nl> - unz64_s * s ; <nl> - if ( file = = NULL ) <nl> - return UNZ_PARAMERROR ; <nl> - s = ( unz64_s * ) file ; <nl> - / * to do : check if number_entry is not truncated * / <nl> - pglobal_info32 - > number_entry = ( uLong ) s - > gi . number_entry ; <nl> - pglobal_info32 - > size_comment = s - > gi . size_comment ; <nl> - return UNZ_OK ; <nl> - } <nl> - / * <nl> - Translate date / time from Dos format to tm_unz ( readable more easily ) <nl> - * / <nl> - local void unz64local_DosDateToTmuDate ( ZPOS64_T ulDosDate , tm_unz * ptm ) <nl> - { <nl> - ZPOS64_T uDate ; <nl> - uDate = ( ZPOS64_T ) ( ulDosDate > > 16 ) ; <nl> - ptm - > tm_mday = ( uInt ) ( uDate & 0x1f ) ; <nl> - ptm - > tm_mon = ( uInt ) ( ( ( ( uDate ) & 0x1E0 ) / 0x20 ) - 1 ) ; <nl> - ptm - > tm_year = ( uInt ) ( ( ( uDate & 0x0FE00 ) / 0x0200 ) + 1980 ) ; <nl> - <nl> - ptm - > tm_hour = ( uInt ) ( ( ulDosDate & 0xF800 ) / 0x800 ) ; <nl> - ptm - > tm_min = ( uInt ) ( ( ulDosDate & 0x7E0 ) / 0x20 ) ; <nl> - ptm - > tm_sec = ( uInt ) ( 2 * ( ulDosDate & 0x1f ) ) ; <nl> - } <nl> - <nl> - / * <nl> - Get Info about the current file in the zipfile , with internal only info <nl> - * / <nl> - local int unz64local_GetCurrentFileInfoInternal OF ( ( unzFile file , <nl> - unz_file_info64 * pfile_info , <nl> - unz_file_info64_internal <nl> - * pfile_info_internal , <nl> - char * szFileName , <nl> - uLong fileNameBufferSize , <nl> - void * extraField , <nl> - uLong extraFieldBufferSize , <nl> - char * szComment , <nl> - uLong commentBufferSize ) ) ; <nl> - <nl> - local int unz64local_GetCurrentFileInfoInternal ( unzFile file , <nl> - unz_file_info64 * pfile_info , <nl> - unz_file_info64_internal <nl> - * pfile_info_internal , <nl> - char * szFileName , <nl> - uLong fileNameBufferSize , <nl> - void * extraField , <nl> - uLong extraFieldBufferSize , <nl> - char * szComment , <nl> - uLong commentBufferSize ) <nl> - { <nl> - unz64_s * s ; <nl> - unz_file_info64 file_info ; <nl> - unz_file_info64_internal file_info_internal ; <nl> - int err = UNZ_OK ; <nl> - uLong uMagic ; <nl> - long lSeek = 0 ; <nl> - uLong uL ; <nl> - <nl> - if ( file = = NULL ) <nl> - return UNZ_PARAMERROR ; <nl> - s = ( unz64_s * ) file ; <nl> - if ( ZSEEK64 ( s - > z_filefunc , s - > filestream , <nl> - s - > pos_in_central_dir + s - > byte_before_the_zipfile , <nl> - ZLIB_FILEFUNC_SEEK_SET ) ! = 0 ) <nl> - err = UNZ_ERRNO ; <nl> - <nl> - <nl> - / * we check the magic * / <nl> - if ( err = = UNZ_OK ) <nl> - { <nl> - if ( unz64local_getLong ( & s - > z_filefunc , s - > filestream , & uMagic ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - else if ( uMagic ! = 0x02014b50 ) <nl> - err = UNZ_BADZIPFILE ; <nl> - } <nl> - <nl> - if ( unz64local_getShort ( & s - > z_filefunc , s - > filestream , & file_info . version ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - <nl> - if ( unz64local_getShort ( & s - > z_filefunc , s - > filestream , & file_info . version_needed ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - <nl> - if ( unz64local_getShort ( & s - > z_filefunc , s - > filestream , & file_info . flag ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - <nl> - if ( unz64local_getShort ( & s - > z_filefunc , s - > filestream , & file_info . compression_method ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - <nl> - if ( unz64local_getLong ( & s - > z_filefunc , s - > filestream , & file_info . dosDate ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - <nl> - unz64local_DosDateToTmuDate ( file_info . dosDate , & file_info . tmu_date ) ; <nl> - <nl> - if ( unz64local_getLong ( & s - > z_filefunc , s - > filestream , & file_info . crc ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - <nl> - if ( unz64local_getLong ( & s - > z_filefunc , s - > filestream , & uL ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - file_info . compressed_size = uL ; <nl> - <nl> - if ( unz64local_getLong ( & s - > z_filefunc , s - > filestream , & uL ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - file_info . uncompressed_size = uL ; <nl> - <nl> - if ( unz64local_getShort ( & s - > z_filefunc , s - > filestream , & file_info . size_filename ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - <nl> - if ( unz64local_getShort ( & s - > z_filefunc , s - > filestream , & file_info . size_file_extra ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - <nl> - if ( unz64local_getShort ( & s - > z_filefunc , s - > filestream , & file_info . size_file_comment ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - <nl> - if ( unz64local_getShort ( & s - > z_filefunc , s - > filestream , & file_info . disk_num_start ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - <nl> - if ( unz64local_getShort ( & s - > z_filefunc , s - > filestream , & file_info . internal_fa ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - <nl> - if ( unz64local_getLong ( & s - > z_filefunc , s - > filestream , & file_info . external_fa ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - <nl> - / / relative offset of local header <nl> - if ( unz64local_getLong ( & s - > z_filefunc , s - > filestream , & uL ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - file_info_internal . offset_curfile = uL ; <nl> - <nl> - lSeek + = file_info . size_filename ; <nl> - if ( ( err = = UNZ_OK ) & & ( szFileName ! = NULL ) ) <nl> - { <nl> - uLong uSizeRead ; <nl> - if ( file_info . size_filename < fileNameBufferSize ) <nl> - { <nl> - * ( szFileName + file_info . size_filename ) = ' \ 0 ' ; <nl> - uSizeRead = file_info . size_filename ; <nl> - } <nl> - else <nl> - uSizeRead = fileNameBufferSize ; <nl> - <nl> - if ( ( file_info . size_filename > 0 ) & & ( fileNameBufferSize > 0 ) ) <nl> - if ( ZREAD64 ( s - > z_filefunc , s - > filestream , szFileName , uSizeRead ) ! = uSizeRead ) <nl> - err = UNZ_ERRNO ; <nl> - lSeek - = uSizeRead ; <nl> - } <nl> - <nl> - / / Read extrafield <nl> - if ( ( err = = UNZ_OK ) & & ( extraField ! = NULL ) ) <nl> - { <nl> - ZPOS64_T uSizeRead ; <nl> - if ( file_info . size_file_extra < extraFieldBufferSize ) <nl> - uSizeRead = file_info . size_file_extra ; <nl> - else <nl> - uSizeRead = extraFieldBufferSize ; <nl> - <nl> - if ( lSeek ! = 0 ) <nl> - { <nl> - if ( ZSEEK64 ( s - > z_filefunc , s - > filestream , lSeek , ZLIB_FILEFUNC_SEEK_CUR ) = = 0 ) <nl> - lSeek = 0 ; <nl> - else <nl> - err = UNZ_ERRNO ; <nl> - } <nl> - <nl> - if ( ( file_info . size_file_extra > 0 ) & & ( extraFieldBufferSize > 0 ) ) <nl> - if ( ZREAD64 ( s - > z_filefunc , s - > filestream , extraField , ( uLong ) uSizeRead ) ! = uSizeRead ) <nl> - err = UNZ_ERRNO ; <nl> - <nl> - lSeek + = file_info . size_file_extra - ( uLong ) uSizeRead ; <nl> - } <nl> - else <nl> - lSeek + = file_info . size_file_extra ; <nl> - <nl> - <nl> - if ( ( err = = UNZ_OK ) & & ( file_info . size_file_extra ! = 0 ) ) <nl> - { <nl> - uLong acc = 0 ; <nl> - <nl> - / / since lSeek now points to after the extra field we need to move back <nl> - lSeek - = file_info . size_file_extra ; <nl> - <nl> - if ( lSeek ! = 0 ) <nl> - { <nl> - if ( ZSEEK64 ( s - > z_filefunc , s - > filestream , lSeek , ZLIB_FILEFUNC_SEEK_CUR ) = = 0 ) <nl> - lSeek = 0 ; <nl> - else <nl> - err = UNZ_ERRNO ; <nl> - } <nl> - <nl> - while ( acc < file_info . size_file_extra ) <nl> - { <nl> - uLong headerId ; <nl> - uLong dataSize ; <nl> - <nl> - if ( unz64local_getShort ( & s - > z_filefunc , s - > filestream , & headerId ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - <nl> - if ( unz64local_getShort ( & s - > z_filefunc , s - > filestream , & dataSize ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - <nl> - / * ZIP64 extra fields * / <nl> - if ( headerId = = 0x0001 ) <nl> - { <nl> - uLong uL ; <nl> - <nl> - if ( file_info . uncompressed_size = = ( ZPOS64_T ) ( unsigned long ) - 1 ) <nl> - { <nl> - if ( unz64local_getLong64 ( & s - > z_filefunc , s - > filestream , & file_info . uncompressed_size ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - } <nl> - <nl> - if ( file_info . compressed_size = = ( ZPOS64_T ) ( unsigned long ) - 1 ) <nl> - { <nl> - if ( unz64local_getLong64 ( & s - > z_filefunc , s - > filestream , & file_info . compressed_size ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - } <nl> - <nl> - if ( file_info_internal . offset_curfile = = ( ZPOS64_T ) ( unsigned long ) - 1 ) <nl> - { <nl> - / * Relative Header offset * / <nl> - if ( unz64local_getLong64 ( & s - > z_filefunc , s - > filestream , & file_info_internal . offset_curfile ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - } <nl> - <nl> - if ( file_info . disk_num_start = = ( unsigned long ) - 1 ) <nl> - { <nl> - / * Disk Start Number * / <nl> - if ( unz64local_getLong ( & s - > z_filefunc , s - > filestream , & uL ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - } <nl> - <nl> - } <nl> - else <nl> - { <nl> - if ( ZSEEK64 ( s - > z_filefunc , s - > filestream , dataSize , ZLIB_FILEFUNC_SEEK_CUR ) ! = 0 ) <nl> - err = UNZ_ERRNO ; <nl> - } <nl> - <nl> - acc + = 2 + 2 + dataSize ; <nl> - } <nl> - } <nl> - <nl> - if ( ( err = = UNZ_OK ) & & ( szComment ! = NULL ) ) <nl> - { <nl> - uLong uSizeRead ; <nl> - if ( file_info . size_file_comment < commentBufferSize ) <nl> - { <nl> - * ( szComment + file_info . size_file_comment ) = ' \ 0 ' ; <nl> - uSizeRead = file_info . size_file_comment ; <nl> - } <nl> - else <nl> - uSizeRead = commentBufferSize ; <nl> - <nl> - if ( lSeek ! = 0 ) <nl> - { <nl> - if ( ZSEEK64 ( s - > z_filefunc , s - > filestream , lSeek , ZLIB_FILEFUNC_SEEK_CUR ) = = 0 ) { <nl> - / / lSeek = 0 ; <nl> - } <nl> - else <nl> - err = UNZ_ERRNO ; <nl> - } <nl> - <nl> - if ( ( file_info . size_file_comment > 0 ) & & ( commentBufferSize > 0 ) ) <nl> - if ( ZREAD64 ( s - > z_filefunc , s - > filestream , szComment , uSizeRead ) ! = uSizeRead ) <nl> - err = UNZ_ERRNO ; <nl> - / / lSeek + = file_info . size_file_comment - uSizeRead ; <nl> - } <nl> - / / else <nl> - / / lSeek + = file_info . size_file_comment ; <nl> - <nl> - <nl> - if ( ( err = = UNZ_OK ) & & ( pfile_info ! = NULL ) ) <nl> - * pfile_info = file_info ; <nl> - <nl> - if ( ( err = = UNZ_OK ) & & ( pfile_info_internal ! = NULL ) ) <nl> - * pfile_info_internal = file_info_internal ; <nl> - <nl> - return err ; <nl> - } <nl> - <nl> - <nl> - <nl> - / * <nl> - Write info about the ZipFile in the * pglobal_info structure . <nl> - No preparation of the structure is needed <nl> - return UNZ_OK if there is no problem . <nl> - * / <nl> - int ZEXPORT unzGetCurrentFileInfo64 ( unzFile file , <nl> - unz_file_info64 * pfile_info , <nl> - char * szFileName , uLong fileNameBufferSize , <nl> - void * extraField , uLong extraFieldBufferSize , <nl> - char * szComment , uLong commentBufferSize ) <nl> - { <nl> - return unz64local_GetCurrentFileInfoInternal ( file , pfile_info , NULL , <nl> - szFileName , fileNameBufferSize , <nl> - extraField , extraFieldBufferSize , <nl> - szComment , commentBufferSize ) ; <nl> - } <nl> - <nl> - int ZEXPORT unzGetCurrentFileInfo ( unzFile file , <nl> - unz_file_info * pfile_info , <nl> - char * szFileName , uLong fileNameBufferSize , <nl> - void * extraField , uLong extraFieldBufferSize , <nl> - char * szComment , uLong commentBufferSize ) <nl> - { <nl> - int err ; <nl> - unz_file_info64 file_info64 ; <nl> - err = unz64local_GetCurrentFileInfoInternal ( file , & file_info64 , NULL , <nl> - szFileName , fileNameBufferSize , <nl> - extraField , extraFieldBufferSize , <nl> - szComment , commentBufferSize ) ; <nl> - if ( err = = UNZ_OK ) <nl> - { <nl> - pfile_info - > version = file_info64 . version ; <nl> - pfile_info - > version_needed = file_info64 . version_needed ; <nl> - pfile_info - > flag = file_info64 . flag ; <nl> - pfile_info - > compression_method = file_info64 . compression_method ; <nl> - pfile_info - > dosDate = file_info64 . dosDate ; <nl> - pfile_info - > crc = file_info64 . crc ; <nl> - <nl> - pfile_info - > size_filename = file_info64 . size_filename ; <nl> - pfile_info - > size_file_extra = file_info64 . size_file_extra ; <nl> - pfile_info - > size_file_comment = file_info64 . size_file_comment ; <nl> - <nl> - pfile_info - > disk_num_start = file_info64 . disk_num_start ; <nl> - pfile_info - > internal_fa = file_info64 . internal_fa ; <nl> - pfile_info - > external_fa = file_info64 . external_fa ; <nl> - <nl> - pfile_info - > tmu_date = file_info64 . tmu_date , <nl> - <nl> - <nl> - pfile_info - > compressed_size = ( uLong ) file_info64 . compressed_size ; <nl> - pfile_info - > uncompressed_size = ( uLong ) file_info64 . uncompressed_size ; <nl> - <nl> - } <nl> - return err ; <nl> - } <nl> - <nl> - / * <nl> - Set the current file of the zipfile to the first file <nl> - with retrieving an information about the file . <nl> - return UNZ_OK if there is no problem <nl> - * / <nl> - int ZEXPORT unzGoToFirstFile64 ( unzFile file , <nl> - unz_file_info64 * pfile_info , <nl> - char * szFileName , <nl> - uLong fileNameBufferSize ) <nl> - { <nl> - int err = UNZ_OK ; <nl> - unz64_s * s ; <nl> - if ( file = = NULL ) <nl> - return UNZ_PARAMERROR ; <nl> - s = ( unz64_s * ) file ; <nl> - s - > pos_in_central_dir = s - > offset_central_dir ; <nl> - s - > num_file = 0 ; <nl> - err = unz64local_GetCurrentFileInfoInternal ( file , & s - > cur_file_info , <nl> - & s - > cur_file_info_internal , <nl> - szFileName , fileNameBufferSize , NULL , 0 , NULL , 0 ) ; <nl> - s - > current_file_ok = ( err = = UNZ_OK ) ; <nl> - if ( pfile_info ) <nl> - * pfile_info = s - > cur_file_info ; <nl> - return err ; <nl> - } <nl> - <nl> - / * <nl> - Set the current file of the zipfile to the first file . <nl> - return UNZ_OK if there is no problem <nl> - * / <nl> - int ZEXPORT unzGoToFirstFile ( unzFile file ) <nl> - { <nl> - return unzGoToFirstFile64 ( file , NULL , NULL , 0 ) ; <nl> - } <nl> - <nl> - / * <nl> - Set the current file of the zipfile to the next file <nl> - with retrieving an information about the file . <nl> - return UNZ_OK if there is no problem <nl> - return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest . <nl> - * / <nl> - int ZEXPORT unzGoToNextFile64 ( unzFile file , <nl> - unz_file_info64 * pfile_info , <nl> - char * szFileName , <nl> - uLong fileNameBufferSize ) <nl> - { <nl> - unz64_s * s ; <nl> - int err ; <nl> - <nl> - if ( file = = NULL ) <nl> - return UNZ_PARAMERROR ; <nl> - s = ( unz64_s * ) file ; <nl> - if ( ! s - > current_file_ok ) <nl> - return UNZ_END_OF_LIST_OF_FILE ; <nl> - if ( s - > gi . number_entry ! = 0xffff ) / * 2 ^ 16 files overflow hack * / <nl> - if ( s - > num_file + 1 = = s - > gi . number_entry ) <nl> - return UNZ_END_OF_LIST_OF_FILE ; <nl> - <nl> - s - > pos_in_central_dir + = SIZECENTRALDIRITEM + s - > cur_file_info . size_filename + <nl> - s - > cur_file_info . size_file_extra + s - > cur_file_info . size_file_comment ; <nl> - s - > num_file + + ; <nl> - err = unz64local_GetCurrentFileInfoInternal ( file , & s - > cur_file_info , <nl> - & s - > cur_file_info_internal , <nl> - szFileName , fileNameBufferSize , NULL , 0 , NULL , 0 ) ; <nl> - s - > current_file_ok = ( err = = UNZ_OK ) ; <nl> - if ( pfile_info ) <nl> - * pfile_info = s - > cur_file_info ; <nl> - return err ; <nl> - } <nl> - <nl> - / * <nl> - Set the current file of the zipfile to the next file . <nl> - return UNZ_OK if there is no problem <nl> - return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest . <nl> - * / <nl> - int ZEXPORT unzGoToNextFile ( unzFile file ) <nl> - { <nl> - return unzGoToNextFile64 ( file , NULL , NULL , 0 ) ; <nl> - } <nl> - <nl> - <nl> - / * <nl> - Try locate the file szFileName in the zipfile . <nl> - For the iCaseSensitivity signification , see unzipStringFileNameCompare <nl> - <nl> - return value : <nl> - UNZ_OK if the file is found . It becomes the current file . <nl> - UNZ_END_OF_LIST_OF_FILE if the file is not found <nl> - * / <nl> - int ZEXPORT unzLocateFile ( unzFile file , const char * szFileName , int iCaseSensitivity ) <nl> - { <nl> - unz64_s * s ; <nl> - int err ; <nl> - <nl> - / * We remember the ' current ' position in the file so that we can jump <nl> - * back there if we fail . <nl> - * / <nl> - unz_file_info64 cur_file_infoSaved ; <nl> - unz_file_info64_internal cur_file_info_internalSaved ; <nl> - ZPOS64_T num_fileSaved ; <nl> - ZPOS64_T pos_in_central_dirSaved ; <nl> - <nl> - <nl> - if ( file = = NULL ) <nl> - return UNZ_PARAMERROR ; <nl> - <nl> - if ( strlen ( szFileName ) > = UNZ_MAXFILENAMEINZIP ) <nl> - return UNZ_PARAMERROR ; <nl> - <nl> - s = ( unz64_s * ) file ; <nl> - if ( ! s - > current_file_ok ) <nl> - return UNZ_END_OF_LIST_OF_FILE ; <nl> - <nl> - / * Save the current state * / <nl> - num_fileSaved = s - > num_file ; <nl> - pos_in_central_dirSaved = s - > pos_in_central_dir ; <nl> - cur_file_infoSaved = s - > cur_file_info ; <nl> - cur_file_info_internalSaved = s - > cur_file_info_internal ; <nl> - <nl> - err = unzGoToFirstFile ( file ) ; <nl> - <nl> - while ( err = = UNZ_OK ) <nl> - { <nl> - char szCurrentFileName [ UNZ_MAXFILENAMEINZIP + 1 ] ; <nl> - err = unzGetCurrentFileInfo64 ( file , NULL , <nl> - szCurrentFileName , sizeof ( szCurrentFileName ) - 1 , <nl> - NULL , 0 , NULL , 0 ) ; <nl> - if ( err = = UNZ_OK ) <nl> - { <nl> - if ( unzStringFileNameCompare ( szCurrentFileName , <nl> - szFileName , iCaseSensitivity ) = = 0 ) <nl> - return UNZ_OK ; <nl> - err = unzGoToNextFile ( file ) ; <nl> - } <nl> - } <nl> - <nl> - / * We failed , so restore the state of the ' current file ' to where we <nl> - * were . <nl> - * / <nl> - s - > num_file = num_fileSaved ; <nl> - s - > pos_in_central_dir = pos_in_central_dirSaved ; <nl> - s - > cur_file_info = cur_file_infoSaved ; <nl> - s - > cur_file_info_internal = cur_file_info_internalSaved ; <nl> - return err ; <nl> - } <nl> - <nl> - <nl> - / * <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / Contributed by Ryan Haksi ( mailto : / / cryogen @ infoserve . net ) <nl> - / / I need random access <nl> - / / <nl> - / / Further optimization could be realized by adding an ability <nl> - / / to cache the directory in memory . The goal being a single <nl> - / / comprehensive file read to put the file I need in a memory . <nl> - * / <nl> - <nl> - / * <nl> - typedef struct unz_file_pos_s <nl> - { <nl> - ZPOS64_T pos_in_zip_directory ; / / offset in file <nl> - ZPOS64_T num_of_file ; / / # of file <nl> - } unz_file_pos ; <nl> - * / <nl> - <nl> - int ZEXPORT unzGetFilePos64 ( unzFile file , unz64_file_pos * file_pos ) <nl> - { <nl> - unz64_s * s ; <nl> - <nl> - if ( file = = NULL | | file_pos = = NULL ) <nl> - return UNZ_PARAMERROR ; <nl> - s = ( unz64_s * ) file ; <nl> - if ( ! s - > current_file_ok ) <nl> - return UNZ_END_OF_LIST_OF_FILE ; <nl> - <nl> - file_pos - > pos_in_zip_directory = s - > pos_in_central_dir ; <nl> - file_pos - > num_of_file = s - > num_file ; <nl> - <nl> - return UNZ_OK ; <nl> - } <nl> - <nl> - int ZEXPORT unzGetFilePos ( <nl> - unzFile file , <nl> - unz_file_pos * file_pos ) <nl> - { <nl> - unz64_file_pos file_pos64 ; <nl> - int err = unzGetFilePos64 ( file , & file_pos64 ) ; <nl> - if ( err = = UNZ_OK ) <nl> - { <nl> - file_pos - > pos_in_zip_directory = ( uLong ) file_pos64 . pos_in_zip_directory ; <nl> - file_pos - > num_of_file = ( uLong ) file_pos64 . num_of_file ; <nl> - } <nl> - return err ; <nl> - } <nl> - <nl> - int ZEXPORT unzGoToFilePos64 ( unzFile file , const unz64_file_pos * file_pos ) <nl> - { <nl> - unz64_s * s ; <nl> - int err ; <nl> - <nl> - if ( file = = NULL | | file_pos = = NULL ) <nl> - return UNZ_PARAMERROR ; <nl> - s = ( unz64_s * ) file ; <nl> - <nl> - / * jump to the right spot * / <nl> - s - > pos_in_central_dir = file_pos - > pos_in_zip_directory ; <nl> - s - > num_file = file_pos - > num_of_file ; <nl> - <nl> - / * set the current file * / <nl> - err = unz64local_GetCurrentFileInfoInternal ( file , & s - > cur_file_info , <nl> - & s - > cur_file_info_internal , <nl> - NULL , 0 , NULL , 0 , NULL , 0 ) ; <nl> - / * return results * / <nl> - s - > current_file_ok = ( err = = UNZ_OK ) ; <nl> - return err ; <nl> - } <nl> - <nl> - int ZEXPORT unzGoToFilePos ( <nl> - unzFile file , <nl> - unz_file_pos * file_pos ) <nl> - { <nl> - unz64_file_pos file_pos64 ; <nl> - if ( file_pos = = NULL ) <nl> - return UNZ_PARAMERROR ; <nl> - <nl> - file_pos64 . pos_in_zip_directory = file_pos - > pos_in_zip_directory ; <nl> - file_pos64 . num_of_file = file_pos - > num_of_file ; <nl> - return unzGoToFilePos64 ( file , & file_pos64 ) ; <nl> - } <nl> - <nl> - / * <nl> - / / Unzip Helper Functions - should be here ? <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - * / <nl> - <nl> - / * <nl> - Read the local header of the current zipfile <nl> - Check the coherency of the local header and info in the end of central <nl> - directory about this file <nl> - store in * piSizeVar the size of extra info in local header <nl> - ( filename and size of extra field data ) <nl> - * / <nl> - local int unz64local_CheckCurrentFileCoherencyHeader ( unz64_s * s , uInt * piSizeVar , <nl> - ZPOS64_T * poffset_local_extrafield , <nl> - uInt * psize_local_extrafield ) <nl> - { <nl> - uLong uMagic , uData , uFlags ; <nl> - uLong size_filename ; <nl> - uLong size_extra_field ; <nl> - int err = UNZ_OK ; <nl> - <nl> - * piSizeVar = 0 ; <nl> - * poffset_local_extrafield = 0 ; <nl> - * psize_local_extrafield = 0 ; <nl> - <nl> - if ( ZSEEK64 ( s - > z_filefunc , s - > filestream , s - > cur_file_info_internal . offset_curfile + <nl> - s - > byte_before_the_zipfile , ZLIB_FILEFUNC_SEEK_SET ) ! = 0 ) <nl> - return UNZ_ERRNO ; <nl> - <nl> - <nl> - if ( err = = UNZ_OK ) <nl> - { <nl> - if ( unz64local_getLong ( & s - > z_filefunc , s - > filestream , & uMagic ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - else if ( uMagic ! = 0x04034b50 ) <nl> - err = UNZ_BADZIPFILE ; <nl> - } <nl> - <nl> - if ( unz64local_getShort ( & s - > z_filefunc , s - > filestream , & uData ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - / * <nl> - else if ( ( err = = UNZ_OK ) & & ( uData ! = s - > cur_file_info . wVersion ) ) <nl> - err = UNZ_BADZIPFILE ; <nl> - * / <nl> - if ( unz64local_getShort ( & s - > z_filefunc , s - > filestream , & uFlags ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - <nl> - if ( unz64local_getShort ( & s - > z_filefunc , s - > filestream , & uData ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - else if ( ( err = = UNZ_OK ) & & ( uData ! = s - > cur_file_info . compression_method ) ) <nl> - err = UNZ_BADZIPFILE ; <nl> - <nl> - if ( ( err = = UNZ_OK ) & & ( s - > cur_file_info . compression_method ! = 0 ) & & <nl> - / * # ifdef HAVE_BZIP2 * / <nl> - ( s - > cur_file_info . compression_method ! = Z_BZIP2ED ) & & <nl> - / * # endif * / <nl> - ( s - > cur_file_info . compression_method ! = Z_DEFLATED ) ) <nl> - err = UNZ_BADZIPFILE ; <nl> - <nl> - if ( unz64local_getLong ( & s - > z_filefunc , s - > filestream , & uData ) ! = UNZ_OK ) / * date / time * / <nl> - err = UNZ_ERRNO ; <nl> - <nl> - if ( unz64local_getLong ( & s - > z_filefunc , s - > filestream , & uData ) ! = UNZ_OK ) / * crc * / <nl> - err = UNZ_ERRNO ; <nl> - else if ( ( err = = UNZ_OK ) & & ( uData ! = s - > cur_file_info . crc ) & & ( ( uFlags & 8 ) = = 0 ) ) <nl> - err = UNZ_BADZIPFILE ; <nl> - <nl> - if ( unz64local_getLong ( & s - > z_filefunc , s - > filestream , & uData ) ! = UNZ_OK ) / * size compr * / <nl> - err = UNZ_ERRNO ; <nl> - else if ( uData ! = 0xFFFFFFFF & & ( err = = UNZ_OK ) & & ( uData ! = s - > cur_file_info . compressed_size ) & & ( ( uFlags & 8 ) = = 0 ) ) <nl> - err = UNZ_BADZIPFILE ; <nl> - <nl> - if ( unz64local_getLong ( & s - > z_filefunc , s - > filestream , & uData ) ! = UNZ_OK ) / * size uncompr * / <nl> - err = UNZ_ERRNO ; <nl> - else if ( uData ! = 0xFFFFFFFF & & ( err = = UNZ_OK ) & & ( uData ! = s - > cur_file_info . uncompressed_size ) & & ( ( uFlags & 8 ) = = 0 ) ) <nl> - err = UNZ_BADZIPFILE ; <nl> - <nl> - if ( unz64local_getShort ( & s - > z_filefunc , s - > filestream , & size_filename ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - else if ( ( err = = UNZ_OK ) & & ( size_filename ! = s - > cur_file_info . size_filename ) ) <nl> - err = UNZ_BADZIPFILE ; <nl> - <nl> - * piSizeVar + = ( uInt ) size_filename ; <nl> - <nl> - if ( unz64local_getShort ( & s - > z_filefunc , s - > filestream , & size_extra_field ) ! = UNZ_OK ) <nl> - err = UNZ_ERRNO ; <nl> - * poffset_local_extrafield = s - > cur_file_info_internal . offset_curfile + <nl> - SIZEZIPLOCALHEADER + size_filename ; <nl> - * psize_local_extrafield = ( uInt ) size_extra_field ; <nl> - <nl> - * piSizeVar + = ( uInt ) size_extra_field ; <nl> - <nl> - return err ; <nl> - } <nl> - <nl> - / * <nl> - Open for reading data the current file in the zipfile . <nl> - If there is no error and the file is opened , the return value is UNZ_OK . <nl> - * / <nl> - int ZEXPORT unzOpenCurrentFile3 ( unzFile file , int * method , <nl> - int * level , int raw , const char * password ) <nl> - { <nl> - int err = UNZ_OK ; <nl> - uInt iSizeVar ; <nl> - unz64_s * s ; <nl> - file_in_zip64_read_info_s * pfile_in_zip_read_info ; <nl> - ZPOS64_T offset_local_extrafield ; / * offset of the local extra field * / <nl> - uInt size_local_extrafield ; / * size of the local extra field * / <nl> - # ifndef NOUNCRYPT <nl> - char source [ 12 ] ; <nl> - # else <nl> - if ( password ! = NULL ) <nl> - return UNZ_PARAMERROR ; <nl> - # endif <nl> - <nl> - if ( file = = NULL ) <nl> - return UNZ_PARAMERROR ; <nl> - s = ( unz64_s * ) file ; <nl> - if ( ! s - > current_file_ok ) <nl> - return UNZ_PARAMERROR ; <nl> - <nl> - if ( s - > pfile_in_zip_read ! = NULL ) <nl> - unzCloseCurrentFile ( file ) ; <nl> - <nl> - if ( unz64local_CheckCurrentFileCoherencyHeader ( s , & iSizeVar , & offset_local_extrafield , & size_local_extrafield ) ! = UNZ_OK ) <nl> - return UNZ_BADZIPFILE ; <nl> - <nl> - pfile_in_zip_read_info = ( file_in_zip64_read_info_s * ) ALLOC ( sizeof ( file_in_zip64_read_info_s ) ) ; <nl> - if ( pfile_in_zip_read_info = = NULL ) <nl> - return UNZ_INTERNALERROR ; <nl> - <nl> - pfile_in_zip_read_info - > read_buffer = ( char * ) ALLOC ( UNZ_BUFSIZE ) ; <nl> - pfile_in_zip_read_info - > offset_local_extrafield = offset_local_extrafield ; <nl> - pfile_in_zip_read_info - > size_local_extrafield = size_local_extrafield ; <nl> - pfile_in_zip_read_info - > pos_local_extrafield = 0 ; <nl> - pfile_in_zip_read_info - > raw = raw ; <nl> - <nl> - if ( pfile_in_zip_read_info - > read_buffer = = NULL ) <nl> - { <nl> - TRYFREE ( pfile_in_zip_read_info ) ; <nl> - return UNZ_INTERNALERROR ; <nl> - } <nl> - <nl> - pfile_in_zip_read_info - > stream_initialised = 0 ; <nl> - <nl> - if ( method ! = NULL ) <nl> - * method = ( int ) s - > cur_file_info . compression_method ; <nl> - <nl> - if ( level ! = NULL ) <nl> - { <nl> - * level = 6 ; <nl> - switch ( s - > cur_file_info . flag & 0x06 ) <nl> - { <nl> - case 6 : * level = 1 ; break ; <nl> - case 4 : * level = 2 ; break ; <nl> - case 2 : * level = 9 ; break ; <nl> - } <nl> - } <nl> - <nl> - if ( ( s - > cur_file_info . compression_method ! = 0 ) & & <nl> - / * # ifdef HAVE_BZIP2 * / <nl> - ( s - > cur_file_info . compression_method ! = Z_BZIP2ED ) & & <nl> - / * # endif * / <nl> - ( s - > cur_file_info . compression_method ! = Z_DEFLATED ) ) { <nl> - <nl> - / / err = UNZ_BADZIPFILE ; <nl> - } <nl> - pfile_in_zip_read_info - > crc32_wait = s - > cur_file_info . crc ; <nl> - pfile_in_zip_read_info - > crc32 = 0 ; <nl> - pfile_in_zip_read_info - > total_out_64 = 0 ; <nl> - pfile_in_zip_read_info - > compression_method = s - > cur_file_info . compression_method ; <nl> - pfile_in_zip_read_info - > filestream = s - > filestream ; <nl> - pfile_in_zip_read_info - > z_filefunc = s - > z_filefunc ; <nl> - pfile_in_zip_read_info - > byte_before_the_zipfile = s - > byte_before_the_zipfile ; <nl> - <nl> - pfile_in_zip_read_info - > stream . total_out = 0 ; <nl> - <nl> - if ( ( s - > cur_file_info . compression_method = = Z_BZIP2ED ) & & ( ! raw ) ) <nl> - { <nl> - # ifdef HAVE_BZIP2 <nl> - pfile_in_zip_read_info - > bstream . bzalloc = ( void * ( * ) ( void * , int , int ) ) 0 ; <nl> - pfile_in_zip_read_info - > bstream . bzfree = ( free_func ) 0 ; <nl> - pfile_in_zip_read_info - > bstream . opaque = ( voidpf ) 0 ; <nl> - pfile_in_zip_read_info - > bstream . state = ( voidpf ) 0 ; <nl> - <nl> - pfile_in_zip_read_info - > stream . zalloc = ( alloc_func ) 0 ; <nl> - pfile_in_zip_read_info - > stream . zfree = ( free_func ) 0 ; <nl> - pfile_in_zip_read_info - > stream . opaque = ( voidpf ) 0 ; <nl> - pfile_in_zip_read_info - > stream . next_in = ( voidpf ) 0 ; <nl> - pfile_in_zip_read_info - > stream . avail_in = 0 ; <nl> - <nl> - err = BZ2_bzDecompressInit ( & pfile_in_zip_read_info - > bstream , 0 , 0 ) ; <nl> - if ( err = = Z_OK ) <nl> - pfile_in_zip_read_info - > stream_initialised = Z_BZIP2ED ; <nl> - else <nl> - { <nl> - TRYFREE ( pfile_in_zip_read_info ) ; <nl> - return err ; <nl> - } <nl> - # else <nl> - pfile_in_zip_read_info - > raw = 1 ; <nl> - # endif <nl> - } <nl> - else if ( ( s - > cur_file_info . compression_method = = Z_DEFLATED ) & & ( ! raw ) ) <nl> - { <nl> - pfile_in_zip_read_info - > stream . zalloc = ( alloc_func ) 0 ; <nl> - pfile_in_zip_read_info - > stream . zfree = ( free_func ) 0 ; <nl> - pfile_in_zip_read_info - > stream . opaque = ( voidpf ) 0 ; <nl> - pfile_in_zip_read_info - > stream . next_in = 0 ; <nl> - pfile_in_zip_read_info - > stream . avail_in = 0 ; <nl> - <nl> - err = inflateInit2 ( & pfile_in_zip_read_info - > stream , - MAX_WBITS ) ; <nl> - if ( err = = Z_OK ) <nl> - pfile_in_zip_read_info - > stream_initialised = Z_DEFLATED ; <nl> - else <nl> - { <nl> - TRYFREE ( pfile_in_zip_read_info ) ; <nl> - return err ; <nl> - } <nl> - / * windowBits is passed < 0 to tell that there is no zlib header . <nl> - * Note that in this case inflate * requires * an extra " dummy " byte <nl> - * after the compressed stream in order to complete decompression and <nl> - * return Z_STREAM_END . <nl> - * In unzip , i don ' t wait absolutely Z_STREAM_END because I known the <nl> - * size of both compressed and uncompressed data <nl> - * / <nl> - } <nl> - pfile_in_zip_read_info - > rest_read_compressed = <nl> - s - > cur_file_info . compressed_size ; <nl> - pfile_in_zip_read_info - > rest_read_uncompressed = <nl> - s - > cur_file_info . uncompressed_size ; <nl> - <nl> - <nl> - pfile_in_zip_read_info - > pos_in_zipfile = <nl> - s - > cur_file_info_internal . offset_curfile + SIZEZIPLOCALHEADER + <nl> - iSizeVar ; <nl> - <nl> - pfile_in_zip_read_info - > stream . avail_in = ( uInt ) 0 ; <nl> - <nl> - s - > pfile_in_zip_read = pfile_in_zip_read_info ; <nl> - s - > encrypted = 0 ; <nl> - <nl> - # ifndef NOUNCRYPT <nl> - if ( password ! = NULL ) <nl> - { <nl> - int i ; <nl> - s - > pcrc_32_tab = get_crc_table ( ) ; <nl> - init_keys ( password , s - > keys , s - > pcrc_32_tab ) ; <nl> - if ( ZSEEK64 ( s - > z_filefunc , s - > filestream , <nl> - s - > pfile_in_zip_read - > pos_in_zipfile + <nl> - s - > pfile_in_zip_read - > byte_before_the_zipfile , <nl> - SEEK_SET ) ! = 0 ) <nl> - return UNZ_INTERNALERROR ; <nl> - if ( ZREAD64 ( s - > z_filefunc , s - > filestream , source , 12 ) < 12 ) <nl> - return UNZ_INTERNALERROR ; <nl> - <nl> - for ( i = 0 ; i < 12 ; i + + ) <nl> - zdecode ( s - > keys , s - > pcrc_32_tab , source [ i ] ) ; <nl> - <nl> - s - > pfile_in_zip_read - > pos_in_zipfile + = 12 ; <nl> - s - > encrypted = 1 ; <nl> - } <nl> - # endif <nl> - <nl> - <nl> - return UNZ_OK ; <nl> - } <nl> - <nl> - int ZEXPORT unzOpenCurrentFile ( unzFile file ) <nl> - { <nl> - return unzOpenCurrentFile3 ( file , NULL , NULL , 0 , NULL ) ; <nl> - } <nl> - <nl> - int ZEXPORT unzOpenCurrentFilePassword ( unzFile file , const char * password ) <nl> - { <nl> - return unzOpenCurrentFile3 ( file , NULL , NULL , 0 , password ) ; <nl> - } <nl> - <nl> - int ZEXPORT unzOpenCurrentFile2 ( unzFile file , int * method , int * level , int raw ) <nl> - { <nl> - return unzOpenCurrentFile3 ( file , method , level , raw , NULL ) ; <nl> - } <nl> - <nl> - / * * Addition for GDAL : START * / <nl> - <nl> - ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 ( unzFile file ) <nl> - { <nl> - unz64_s * s ; <nl> - file_in_zip64_read_info_s * pfile_in_zip_read_info ; <nl> - s = ( unz64_s * ) file ; <nl> - if ( file = = NULL ) <nl> - return 0 ; / / UNZ_PARAMERROR ; <nl> - pfile_in_zip_read_info = s - > pfile_in_zip_read ; <nl> - if ( pfile_in_zip_read_info = = NULL ) <nl> - return 0 ; / / UNZ_PARAMERROR ; <nl> - return pfile_in_zip_read_info - > pos_in_zipfile + <nl> - pfile_in_zip_read_info - > byte_before_the_zipfile ; <nl> - } <nl> - <nl> - / * * Addition for GDAL : END * / <nl> - <nl> - / * <nl> - Read bytes from the current file . <nl> - buf contain buffer where data must be copied <nl> - len the size of buf . <nl> - <nl> - return the number of byte copied if some bytes are copied <nl> - return 0 if the end of file was reached <nl> - return < 0 with error code if there is an error <nl> - ( UNZ_ERRNO for IO error , or zLib error for uncompress error ) <nl> - * / <nl> - int ZEXPORT unzReadCurrentFile ( unzFile file , voidp buf , unsigned len ) <nl> - { <nl> - int err = UNZ_OK ; <nl> - uInt iRead = 0 ; <nl> - unz64_s * s ; <nl> - file_in_zip64_read_info_s * pfile_in_zip_read_info ; <nl> - if ( file = = NULL ) <nl> - return UNZ_PARAMERROR ; <nl> - s = ( unz64_s * ) file ; <nl> - pfile_in_zip_read_info = s - > pfile_in_zip_read ; <nl> - <nl> - if ( pfile_in_zip_read_info = = NULL ) <nl> - return UNZ_PARAMERROR ; <nl> - <nl> - <nl> - if ( pfile_in_zip_read_info - > read_buffer = = NULL ) <nl> - return UNZ_END_OF_LIST_OF_FILE ; <nl> - if ( len = = 0 ) <nl> - return 0 ; <nl> - <nl> - pfile_in_zip_read_info - > stream . next_out = ( Bytef * ) buf ; <nl> - <nl> - pfile_in_zip_read_info - > stream . avail_out = ( uInt ) len ; <nl> - <nl> - if ( ( len > pfile_in_zip_read_info - > rest_read_uncompressed ) & & <nl> - ( ! ( pfile_in_zip_read_info - > raw ) ) ) <nl> - pfile_in_zip_read_info - > stream . avail_out = <nl> - ( uInt ) pfile_in_zip_read_info - > rest_read_uncompressed ; <nl> - <nl> - if ( ( len > pfile_in_zip_read_info - > rest_read_compressed + <nl> - pfile_in_zip_read_info - > stream . avail_in ) & & <nl> - ( pfile_in_zip_read_info - > raw ) ) <nl> - pfile_in_zip_read_info - > stream . avail_out = <nl> - ( uInt ) pfile_in_zip_read_info - > rest_read_compressed + <nl> - pfile_in_zip_read_info - > stream . avail_in ; <nl> - <nl> - while ( pfile_in_zip_read_info - > stream . avail_out > 0 ) <nl> - { <nl> - if ( ( pfile_in_zip_read_info - > stream . avail_in = = 0 ) & & <nl> - ( pfile_in_zip_read_info - > rest_read_compressed > 0 ) ) <nl> - { <nl> - uInt uReadThis = UNZ_BUFSIZE ; <nl> - if ( pfile_in_zip_read_info - > rest_read_compressed < uReadThis ) <nl> - uReadThis = ( uInt ) pfile_in_zip_read_info - > rest_read_compressed ; <nl> - if ( uReadThis = = 0 ) <nl> - return UNZ_EOF ; <nl> - if ( ZSEEK64 ( pfile_in_zip_read_info - > z_filefunc , <nl> - pfile_in_zip_read_info - > filestream , <nl> - pfile_in_zip_read_info - > pos_in_zipfile + <nl> - pfile_in_zip_read_info - > byte_before_the_zipfile , <nl> - ZLIB_FILEFUNC_SEEK_SET ) ! = 0 ) <nl> - return UNZ_ERRNO ; <nl> - if ( ZREAD64 ( pfile_in_zip_read_info - > z_filefunc , <nl> - pfile_in_zip_read_info - > filestream , <nl> - pfile_in_zip_read_info - > read_buffer , <nl> - uReadThis ) ! = uReadThis ) <nl> - return UNZ_ERRNO ; <nl> - <nl> - <nl> - # ifndef NOUNCRYPT <nl> - if ( s - > encrypted ) <nl> - { <nl> - uInt i ; <nl> - for ( i = 0 ; i < uReadThis ; i + + ) <nl> - pfile_in_zip_read_info - > read_buffer [ i ] = <nl> - zdecode ( s - > keys , s - > pcrc_32_tab , <nl> - pfile_in_zip_read_info - > read_buffer [ i ] ) ; <nl> - } <nl> - # endif <nl> - <nl> - <nl> - pfile_in_zip_read_info - > pos_in_zipfile + = uReadThis ; <nl> - <nl> - pfile_in_zip_read_info - > rest_read_compressed - = uReadThis ; <nl> - <nl> - pfile_in_zip_read_info - > stream . next_in = <nl> - ( Bytef * ) pfile_in_zip_read_info - > read_buffer ; <nl> - pfile_in_zip_read_info - > stream . avail_in = ( uInt ) uReadThis ; <nl> - } <nl> - <nl> - if ( ( pfile_in_zip_read_info - > compression_method = = 0 ) | | ( pfile_in_zip_read_info - > raw ) ) <nl> - { <nl> - uInt uDoCopy , i ; <nl> - <nl> - if ( ( pfile_in_zip_read_info - > stream . avail_in = = 0 ) & & <nl> - ( pfile_in_zip_read_info - > rest_read_compressed = = 0 ) ) <nl> - return ( iRead = = 0 ) ? UNZ_EOF : iRead ; <nl> - <nl> - if ( pfile_in_zip_read_info - > stream . avail_out < <nl> - pfile_in_zip_read_info - > stream . avail_in ) <nl> - uDoCopy = pfile_in_zip_read_info - > stream . avail_out ; <nl> - else <nl> - uDoCopy = pfile_in_zip_read_info - > stream . avail_in ; <nl> - <nl> - for ( i = 0 ; i < uDoCopy ; i + + ) <nl> - * ( pfile_in_zip_read_info - > stream . next_out + i ) = <nl> - * ( pfile_in_zip_read_info - > stream . next_in + i ) ; <nl> - <nl> - pfile_in_zip_read_info - > total_out_64 = pfile_in_zip_read_info - > total_out_64 + uDoCopy ; <nl> - <nl> - pfile_in_zip_read_info - > crc32 = crc32 ( pfile_in_zip_read_info - > crc32 , <nl> - pfile_in_zip_read_info - > stream . next_out , <nl> - uDoCopy ) ; <nl> - pfile_in_zip_read_info - > rest_read_uncompressed - = uDoCopy ; <nl> - pfile_in_zip_read_info - > stream . avail_in - = uDoCopy ; <nl> - pfile_in_zip_read_info - > stream . avail_out - = uDoCopy ; <nl> - pfile_in_zip_read_info - > stream . next_out + = uDoCopy ; <nl> - pfile_in_zip_read_info - > stream . next_in + = uDoCopy ; <nl> - pfile_in_zip_read_info - > stream . total_out + = uDoCopy ; <nl> - iRead + = uDoCopy ; <nl> - } <nl> - else if ( pfile_in_zip_read_info - > compression_method = = Z_BZIP2ED ) <nl> - { <nl> - # ifdef HAVE_BZIP2 <nl> - uLong uTotalOutBefore , uTotalOutAfter ; <nl> - const Bytef * bufBefore ; <nl> - uLong uOutThis ; <nl> - <nl> - pfile_in_zip_read_info - > bstream . next_in = ( char * ) pfile_in_zip_read_info - > stream . next_in ; <nl> - pfile_in_zip_read_info - > bstream . avail_in = pfile_in_zip_read_info - > stream . avail_in ; <nl> - pfile_in_zip_read_info - > bstream . total_in_lo32 = pfile_in_zip_read_info - > stream . total_in ; <nl> - pfile_in_zip_read_info - > bstream . total_in_hi32 = 0 ; <nl> - pfile_in_zip_read_info - > bstream . next_out = ( char * ) pfile_in_zip_read_info - > stream . next_out ; <nl> - pfile_in_zip_read_info - > bstream . avail_out = pfile_in_zip_read_info - > stream . avail_out ; <nl> - pfile_in_zip_read_info - > bstream . total_out_lo32 = pfile_in_zip_read_info - > stream . total_out ; <nl> - pfile_in_zip_read_info - > bstream . total_out_hi32 = 0 ; <nl> - <nl> - uTotalOutBefore = pfile_in_zip_read_info - > bstream . total_out_lo32 ; <nl> - bufBefore = ( const Bytef * ) pfile_in_zip_read_info - > bstream . next_out ; <nl> - <nl> - err = BZ2_bzDecompress ( & pfile_in_zip_read_info - > bstream ) ; <nl> - <nl> - uTotalOutAfter = pfile_in_zip_read_info - > bstream . total_out_lo32 ; <nl> - uOutThis = uTotalOutAfter - uTotalOutBefore ; <nl> - <nl> - pfile_in_zip_read_info - > total_out_64 = pfile_in_zip_read_info - > total_out_64 + uOutThis ; <nl> - <nl> - pfile_in_zip_read_info - > crc32 = crc32 ( pfile_in_zip_read_info - > crc32 , bufBefore , ( uInt ) ( uOutThis ) ) ; <nl> - pfile_in_zip_read_info - > rest_read_uncompressed - = uOutThis ; <nl> - iRead + = ( uInt ) ( uTotalOutAfter - uTotalOutBefore ) ; <nl> - <nl> - pfile_in_zip_read_info - > stream . next_in = ( Bytef * ) pfile_in_zip_read_info - > bstream . next_in ; <nl> - pfile_in_zip_read_info - > stream . avail_in = pfile_in_zip_read_info - > bstream . avail_in ; <nl> - pfile_in_zip_read_info - > stream . total_in = pfile_in_zip_read_info - > bstream . total_in_lo32 ; <nl> - pfile_in_zip_read_info - > stream . next_out = ( Bytef * ) pfile_in_zip_read_info - > bstream . next_out ; <nl> - pfile_in_zip_read_info - > stream . avail_out = pfile_in_zip_read_info - > bstream . avail_out ; <nl> - pfile_in_zip_read_info - > stream . total_out = pfile_in_zip_read_info - > bstream . total_out_lo32 ; <nl> - <nl> - if ( err = = BZ_STREAM_END ) <nl> - return ( iRead = = 0 ) ? UNZ_EOF : iRead ; <nl> - if ( err ! = BZ_OK ) <nl> - break ; <nl> - # endif <nl> - } / / end Z_BZIP2ED <nl> - else <nl> - { <nl> - ZPOS64_T uTotalOutBefore , uTotalOutAfter ; <nl> - const Bytef * bufBefore ; <nl> - ZPOS64_T uOutThis ; <nl> - int flush = Z_SYNC_FLUSH ; <nl> - <nl> - uTotalOutBefore = pfile_in_zip_read_info - > stream . total_out ; <nl> - bufBefore = pfile_in_zip_read_info - > stream . next_out ; <nl> - <nl> - / * <nl> - if ( ( pfile_in_zip_read_info - > rest_read_uncompressed = = <nl> - pfile_in_zip_read_info - > stream . avail_out ) & & <nl> - ( pfile_in_zip_read_info - > rest_read_compressed = = 0 ) ) <nl> - flush = Z_FINISH ; <nl> - * / <nl> - err = inflate ( & pfile_in_zip_read_info - > stream , flush ) ; <nl> - <nl> - if ( ( err > = 0 ) & & ( pfile_in_zip_read_info - > stream . msg ! = NULL ) ) <nl> - err = Z_DATA_ERROR ; <nl> - <nl> - uTotalOutAfter = pfile_in_zip_read_info - > stream . total_out ; <nl> - uOutThis = uTotalOutAfter - uTotalOutBefore ; <nl> - <nl> - pfile_in_zip_read_info - > total_out_64 = pfile_in_zip_read_info - > total_out_64 + uOutThis ; <nl> - <nl> - pfile_in_zip_read_info - > crc32 = <nl> - crc32 ( pfile_in_zip_read_info - > crc32 , bufBefore , <nl> - ( uInt ) ( uOutThis ) ) ; <nl> - <nl> - pfile_in_zip_read_info - > rest_read_uncompressed - = <nl> - uOutThis ; <nl> - <nl> - iRead + = ( uInt ) ( uTotalOutAfter - uTotalOutBefore ) ; <nl> - <nl> - if ( err = = Z_STREAM_END ) <nl> - return ( iRead = = 0 ) ? UNZ_EOF : iRead ; <nl> - if ( err ! = Z_OK ) <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - if ( err = = Z_OK ) <nl> - return iRead ; <nl> - return err ; <nl> - } <nl> - <nl> - <nl> - / * <nl> - Give the current position in uncompressed data <nl> - * / <nl> - z_off_t ZEXPORT unztell ( unzFile file ) <nl> - { <nl> - unz64_s * s ; <nl> - file_in_zip64_read_info_s * pfile_in_zip_read_info ; <nl> - if ( file = = NULL ) <nl> - return UNZ_PARAMERROR ; <nl> - s = ( unz64_s * ) file ; <nl> - pfile_in_zip_read_info = s - > pfile_in_zip_read ; <nl> - <nl> - if ( pfile_in_zip_read_info = = NULL ) <nl> - return UNZ_PARAMERROR ; <nl> - <nl> - return ( z_off_t ) pfile_in_zip_read_info - > stream . total_out ; <nl> - } <nl> - <nl> - ZPOS64_T ZEXPORT unztell64 ( unzFile file ) <nl> - { <nl> - <nl> - unz64_s * s ; <nl> - file_in_zip64_read_info_s * pfile_in_zip_read_info ; <nl> - if ( file = = NULL ) <nl> - return ( ZPOS64_T ) - 1 ; <nl> - s = ( unz64_s * ) file ; <nl> - pfile_in_zip_read_info = s - > pfile_in_zip_read ; <nl> - <nl> - if ( pfile_in_zip_read_info = = NULL ) <nl> - return ( ZPOS64_T ) - 1 ; <nl> - <nl> - return pfile_in_zip_read_info - > total_out_64 ; <nl> - } <nl> - <nl> - <nl> - / * <nl> - return 1 if the end of file was reached , 0 elsewhere <nl> - * / <nl> - int ZEXPORT unzeof ( unzFile file ) <nl> - { <nl> - unz64_s * s ; <nl> - file_in_zip64_read_info_s * pfile_in_zip_read_info ; <nl> - if ( file = = NULL ) <nl> - return UNZ_PARAMERROR ; <nl> - s = ( unz64_s * ) file ; <nl> - pfile_in_zip_read_info = s - > pfile_in_zip_read ; <nl> - <nl> - if ( pfile_in_zip_read_info = = NULL ) <nl> - return UNZ_PARAMERROR ; <nl> - <nl> - if ( pfile_in_zip_read_info - > rest_read_uncompressed = = 0 ) <nl> - return 1 ; <nl> - else <nl> - return 0 ; <nl> - } <nl> - <nl> - <nl> - <nl> - / * <nl> - Read extra field from the current file ( opened by unzOpenCurrentFile ) <nl> - This is the local - header version of the extra field ( sometimes , there is <nl> - more info in the local - header version than in the central - header ) <nl> - <nl> - if buf = = NULL , it return the size of the local extra field that can be read <nl> - <nl> - if buf ! = NULL , len is the size of the buffer , the extra header is copied in <nl> - buf . <nl> - the return value is the number of bytes copied in buf , or ( if < 0 ) <nl> - the error code <nl> - * / <nl> - int ZEXPORT unzGetLocalExtrafield ( unzFile file , voidp buf , unsigned len ) <nl> - { <nl> - unz64_s * s ; <nl> - file_in_zip64_read_info_s * pfile_in_zip_read_info ; <nl> - uInt read_now ; <nl> - ZPOS64_T size_to_read ; <nl> - <nl> - if ( file = = NULL ) <nl> - return UNZ_PARAMERROR ; <nl> - s = ( unz64_s * ) file ; <nl> - pfile_in_zip_read_info = s - > pfile_in_zip_read ; <nl> - <nl> - if ( pfile_in_zip_read_info = = NULL ) <nl> - return UNZ_PARAMERROR ; <nl> - <nl> - size_to_read = ( pfile_in_zip_read_info - > size_local_extrafield - <nl> - pfile_in_zip_read_info - > pos_local_extrafield ) ; <nl> - <nl> - if ( buf = = NULL ) <nl> - return ( int ) size_to_read ; <nl> - <nl> - if ( len > size_to_read ) <nl> - read_now = ( uInt ) size_to_read ; <nl> - else <nl> - read_now = ( uInt ) len ; <nl> - <nl> - if ( read_now = = 0 ) <nl> - return 0 ; <nl> - <nl> - if ( ZSEEK64 ( pfile_in_zip_read_info - > z_filefunc , <nl> - pfile_in_zip_read_info - > filestream , <nl> - pfile_in_zip_read_info - > offset_local_extrafield + <nl> - pfile_in_zip_read_info - > pos_local_extrafield , <nl> - ZLIB_FILEFUNC_SEEK_SET ) ! = 0 ) <nl> - return UNZ_ERRNO ; <nl> - <nl> - if ( ZREAD64 ( pfile_in_zip_read_info - > z_filefunc , <nl> - pfile_in_zip_read_info - > filestream , <nl> - buf , read_now ) ! = read_now ) <nl> - return UNZ_ERRNO ; <nl> - <nl> - return ( int ) read_now ; <nl> - } <nl> - <nl> - / * <nl> - Close the file in zip opened with unzipOpenCurrentFile <nl> - Return UNZ_CRCERROR if all the file was read but the CRC is not good <nl> - * / <nl> - int ZEXPORT unzCloseCurrentFile ( unzFile file ) <nl> - { <nl> - int err = UNZ_OK ; <nl> - <nl> - unz64_s * s ; <nl> - file_in_zip64_read_info_s * pfile_in_zip_read_info ; <nl> - if ( file = = NULL ) <nl> - return UNZ_PARAMERROR ; <nl> - s = ( unz64_s * ) file ; <nl> - pfile_in_zip_read_info = s - > pfile_in_zip_read ; <nl> - <nl> - if ( pfile_in_zip_read_info = = NULL ) <nl> - return UNZ_PARAMERROR ; <nl> - <nl> - <nl> - if ( ( pfile_in_zip_read_info - > rest_read_uncompressed = = 0 ) & & <nl> - ( ! pfile_in_zip_read_info - > raw ) ) <nl> - { <nl> - if ( pfile_in_zip_read_info - > crc32 ! = pfile_in_zip_read_info - > crc32_wait ) <nl> - err = UNZ_CRCERROR ; <nl> - } <nl> - <nl> - <nl> - TRYFREE ( pfile_in_zip_read_info - > read_buffer ) ; <nl> - pfile_in_zip_read_info - > read_buffer = NULL ; <nl> - if ( pfile_in_zip_read_info - > stream_initialised = = Z_DEFLATED ) <nl> - inflateEnd ( & pfile_in_zip_read_info - > stream ) ; <nl> - # ifdef HAVE_BZIP2 <nl> - else if ( pfile_in_zip_read_info - > stream_initialised = = Z_BZIP2ED ) <nl> - BZ2_bzDecompressEnd ( & pfile_in_zip_read_info - > bstream ) ; <nl> - # endif <nl> - <nl> - <nl> - pfile_in_zip_read_info - > stream_initialised = 0 ; <nl> - TRYFREE ( pfile_in_zip_read_info ) ; <nl> - <nl> - s - > pfile_in_zip_read = NULL ; <nl> - <nl> - return err ; <nl> - } <nl> - <nl> - <nl> - / * <nl> - Get the global comment string of the ZipFile , in the szComment buffer . <nl> - uSizeBuf is the size of the szComment buffer . <nl> - return the number of byte copied or an error code < 0 <nl> - * / <nl> - int ZEXPORT unzGetGlobalComment ( unzFile file , char * szComment , uLong uSizeBuf ) <nl> - { <nl> - unz64_s * s ; <nl> - uLong uReadThis ; <nl> - if ( file = = NULL ) <nl> - return ( int ) UNZ_PARAMERROR ; <nl> - s = ( unz64_s * ) file ; <nl> - <nl> - uReadThis = uSizeBuf ; <nl> - if ( uReadThis > s - > gi . size_comment ) <nl> - uReadThis = s - > gi . size_comment ; <nl> - <nl> - if ( ZSEEK64 ( s - > z_filefunc , s - > filestream , s - > central_pos + 22 , ZLIB_FILEFUNC_SEEK_SET ) ! = 0 ) <nl> - return UNZ_ERRNO ; <nl> - <nl> - if ( uReadThis > 0 ) <nl> - { <nl> - * szComment = ' \ 0 ' ; <nl> - if ( ZREAD64 ( s - > z_filefunc , s - > filestream , szComment , uReadThis ) ! = uReadThis ) <nl> - return UNZ_ERRNO ; <nl> - } <nl> - <nl> - if ( ( szComment ! = NULL ) & & ( uSizeBuf > s - > gi . size_comment ) ) <nl> - * ( szComment + s - > gi . size_comment ) = ' \ 0 ' ; <nl> - return ( int ) uReadThis ; <nl> - } <nl> - <nl> - / * Additions by RX ' 2004 * / <nl> - ZPOS64_T ZEXPORT unzGetOffset64 ( unzFile file ) <nl> - { <nl> - unz64_s * s ; <nl> - <nl> - if ( file = = NULL ) <nl> - return 0 ; / / UNZ_PARAMERROR ; <nl> - s = ( unz64_s * ) file ; <nl> - if ( ! s - > current_file_ok ) <nl> - return 0 ; <nl> - if ( s - > gi . number_entry ! = 0 & & s - > gi . number_entry ! = 0xffff ) <nl> - if ( s - > num_file = = s - > gi . number_entry ) <nl> - return 0 ; <nl> - return s - > pos_in_central_dir ; <nl> - } <nl> - <nl> - uLong ZEXPORT unzGetOffset ( unzFile file ) <nl> - { <nl> - ZPOS64_T offset64 ; <nl> - <nl> - if ( file = = NULL ) <nl> - return 0 ; / / UNZ_PARAMERROR ; <nl> - offset64 = unzGetOffset64 ( file ) ; <nl> - return ( uLong ) offset64 ; <nl> - } <nl> - <nl> - int ZEXPORT unzSetOffset64 ( unzFile file , ZPOS64_T pos ) <nl> - { <nl> - unz64_s * s ; <nl> - int err ; <nl> - <nl> - if ( file = = NULL ) <nl> - return UNZ_PARAMERROR ; <nl> - s = ( unz64_s * ) file ; <nl> - <nl> - s - > pos_in_central_dir = pos ; <nl> - s - > num_file = s - > gi . number_entry ; / * hack * / <nl> - err = unz64local_GetCurrentFileInfoInternal ( file , & s - > cur_file_info , <nl> - & s - > cur_file_info_internal , <nl> - NULL , 0 , NULL , 0 , NULL , 0 ) ; <nl> - s - > current_file_ok = ( err = = UNZ_OK ) ; <nl> - return err ; <nl> - } <nl> - <nl> - int ZEXPORT unzSetOffset ( unzFile file , uLong pos ) <nl> - { <nl> - return unzSetOffset64 ( file , pos ) ; <nl> - } <nl> - <nl> - } / / end of namespace cocos2d <nl> deleted file mode 100644 <nl> index 54e73a55ea62 . . 000000000000 <nl> mmm a / cocos / 2d / support / zip_support / unzip . h <nl> ppp / dev / null <nl> <nl> - / * unzip . h - - IO for uncompress . zip files using zlib <nl> - Version 1 . 1 , February 14h , 2010 <nl> - part of the MiniZip project - ( http : / / www . winimage . com / zLibDll / minizip . html ) <nl> - <nl> - Copyright ( C ) 1998 - 2010 Gilles Vollant ( minizip ) ( http : / / www . winimage . com / zLibDll / minizip . html ) <nl> - <nl> - Modifications of Unzip for Zip64 <nl> - Copyright ( C ) 2007 - 2008 Even Rouault <nl> - <nl> - Modifications for Zip64 support on both zip and unzip <nl> - Copyright ( C ) 2009 - 2010 Mathias Svensson ( http : / / result42 . com ) <nl> - <nl> - For more info read MiniZip_info . txt <nl> - <nl> - mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> - <nl> - Condition of use and distribution are the same than zlib : <nl> - <nl> - This software is provided ' as - is ' , without any express or implied <nl> - warranty . In no event will the authors be held liable for any damages <nl> - arising from the use of this software . <nl> - <nl> - Permission is granted to anyone to use this software for any purpose , <nl> - including commercial applications , and to alter it and redistribute it <nl> - freely , subject to the following restrictions : <nl> - <nl> - 1 . The origin of this software must not be misrepresented ; you must not <nl> - claim that you wrote the original software . If you use this software <nl> - in a product , an acknowledgment in the product documentation would be <nl> - appreciated but is not required . <nl> - 2 . Altered source versions must be plainly marked as such , and must not be <nl> - misrepresented as being the original software . <nl> - 3 . This notice may not be removed or altered from any source distribution . <nl> - <nl> - mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> - <nl> - Changes <nl> - <nl> - See header of unzip64 . c <nl> - <nl> - * / <nl> - <nl> - # ifndef _unz64_H <nl> - # define _unz64_H <nl> - <nl> - # include " CCPlatformDefine . h " <nl> - <nl> - # ifndef _ZLIB_H <nl> - # include " zlib . h " <nl> - # endif <nl> - <nl> - # ifndef _ZLIBIOAPI_H <nl> - # include " ioapi . h " <nl> - # endif <nl> - <nl> - # ifdef HAVE_BZIP2 <nl> - # include " bzlib . h " <nl> - # endif <nl> - <nl> - # define Z_BZIP2ED 12 <nl> - <nl> - # if defined ( STRICTUNZIP ) | | defined ( STRICTZIPUNZIP ) <nl> - / * like the STRICT of WIN32 , we define a pointer that cannot be converted <nl> - from ( void * ) without cast * / <nl> - typedef struct TagunzFile__ { int unused ; } unzFile__ ; <nl> - typedef unzFile__ * unzFile ; <nl> - # else <nl> - typedef voidp unzFile ; <nl> - # endif <nl> - <nl> - <nl> - # define UNZ_OK ( 0 ) <nl> - # define UNZ_END_OF_LIST_OF_FILE ( - 100 ) <nl> - # define UNZ_ERRNO ( Z_ERRNO ) <nl> - # define UNZ_EOF ( 0 ) <nl> - # define UNZ_PARAMERROR ( - 102 ) <nl> - # define UNZ_BADZIPFILE ( - 103 ) <nl> - # define UNZ_INTERNALERROR ( - 104 ) <nl> - # define UNZ_CRCERROR ( - 105 ) <nl> - <nl> - namespace cocos2d { <nl> - <nl> - / * tm_unz contain date / time info * / <nl> - typedef struct tm_unz_s <nl> - { <nl> - uInt tm_sec ; / * seconds after the minute - [ 0 , 59 ] * / <nl> - uInt tm_min ; / * minutes after the hour - [ 0 , 59 ] * / <nl> - uInt tm_hour ; / * hours since midnight - [ 0 , 23 ] * / <nl> - uInt tm_mday ; / * day of the month - [ 1 , 31 ] * / <nl> - uInt tm_mon ; / * months since January - [ 0 , 11 ] * / <nl> - uInt tm_year ; / * years - [ 1980 . . 2044 ] * / <nl> - } tm_unz ; <nl> - <nl> - / * unz_global_info structure contain global data about the ZIPfile <nl> - These data comes from the end of central dir * / <nl> - typedef struct unz_global_info64_s <nl> - { <nl> - ZPOS64_T number_entry ; / * total number of entries in <nl> - the central dir on this disk * / <nl> - uLong size_comment ; / * size of the global comment of the zipfile * / <nl> - } unz_global_info64 ; <nl> - <nl> - typedef struct unz_global_info_s <nl> - { <nl> - uLong number_entry ; / * total number of entries in <nl> - the central dir on this disk * / <nl> - uLong size_comment ; / * size of the global comment of the zipfile * / <nl> - } unz_global_info ; <nl> - <nl> - / * unz_file_info contain information about a file in the zipfile * / <nl> - typedef struct unz_file_info64_s <nl> - { <nl> - uLong version ; / * version made by 2 bytes * / <nl> - uLong version_needed ; / * version needed to extract 2 bytes * / <nl> - uLong flag ; / * general purpose bit flag 2 bytes * / <nl> - uLong compression_method ; / * compression method 2 bytes * / <nl> - uLong dosDate ; / * last mod file date in Dos fmt 4 bytes * / <nl> - uLong crc ; / * crc - 32 4 bytes * / <nl> - ZPOS64_T compressed_size ; / * compressed size 8 bytes * / <nl> - ZPOS64_T uncompressed_size ; / * uncompressed size 8 bytes * / <nl> - uLong size_filename ; / * filename length 2 bytes * / <nl> - uLong size_file_extra ; / * extra field length 2 bytes * / <nl> - uLong size_file_comment ; / * file comment length 2 bytes * / <nl> - <nl> - uLong disk_num_start ; / * disk number start 2 bytes * / <nl> - uLong internal_fa ; / * internal file attributes 2 bytes * / <nl> - uLong external_fa ; / * external file attributes 4 bytes * / <nl> - <nl> - tm_unz tmu_date ; <nl> - } unz_file_info64 ; <nl> - <nl> - typedef struct unz_file_info_s <nl> - { <nl> - uLong version ; / * version made by 2 bytes * / <nl> - uLong version_needed ; / * version needed to extract 2 bytes * / <nl> - uLong flag ; / * general purpose bit flag 2 bytes * / <nl> - uLong compression_method ; / * compression method 2 bytes * / <nl> - uLong dosDate ; / * last mod file date in Dos fmt 4 bytes * / <nl> - uLong crc ; / * crc - 32 4 bytes * / <nl> - uLong compressed_size ; / * compressed size 4 bytes * / <nl> - uLong uncompressed_size ; / * uncompressed size 4 bytes * / <nl> - uLong size_filename ; / * filename length 2 bytes * / <nl> - uLong size_file_extra ; / * extra field length 2 bytes * / <nl> - uLong size_file_comment ; / * file comment length 2 bytes * / <nl> - <nl> - uLong disk_num_start ; / * disk number start 2 bytes * / <nl> - uLong internal_fa ; / * internal file attributes 2 bytes * / <nl> - uLong external_fa ; / * external file attributes 4 bytes * / <nl> - <nl> - tm_unz tmu_date ; <nl> - } unz_file_info ; <nl> - <nl> - int CC_DLL unzStringFileNameCompare OF ( ( const char * fileName1 , <nl> - const char * fileName2 , <nl> - int iCaseSensitivity ) ) ; <nl> - / * <nl> - Compare two filename ( fileName1 , fileName2 ) . <nl> - If iCaseSenisivity = 1 , comparison is case sensitivity ( like strcmp ) <nl> - If iCaseSenisivity = 2 , comparison is not case sensitivity ( like strcmpi <nl> - or strcasecmp ) <nl> - If iCaseSenisivity = 0 , case sensitivity is default of your operating system <nl> - ( like 1 on Unix , 2 on Windows ) <nl> - * / <nl> - <nl> - <nl> - unzFile CC_DLL unzOpen OF ( ( const char * path ) ) ; <nl> - unzFile CC_DLL unzOpen64 OF ( ( const void * path ) ) ; <nl> - / * <nl> - Open a Zip file . path contain the full pathname ( by example , <nl> - on a Windows XP computer " c : \ \ zlib \ \ zlib113 . zip " or on an Unix computer <nl> - " zlib / zlib113 . zip " . <nl> - If the zipfile cannot be opened ( file don ' t exist or in not valid ) , the <nl> - return value is NULL . <nl> - Else , the return value is a unzFile Handle , usable with other function <nl> - of this unzip package . <nl> - the " 64 " function take a const void * pointer , because the path is just the <nl> - value passed to the open64_file_func callback . <nl> - Under Windows , if UNICODE is defined , using fill_fopen64_filefunc , the path <nl> - is a pointer to a wide unicode string ( LPCTSTR is LPCWSTR ) , so const char * <nl> - does not describe the reality <nl> - * / <nl> - <nl> - <nl> - unzFile CC_DLL unzOpen2 OF ( ( const char * path , <nl> - zlib_filefunc_def * pzlib_filefunc_def ) ) ; <nl> - / * <nl> - Open a Zip file , like unzOpen , but provide a set of file low level API <nl> - for read / write the zip file ( see ioapi . h ) <nl> - * / <nl> - <nl> - unzFile CC_DLL unzOpen2_64 OF ( ( const void * path , <nl> - zlib_filefunc64_def * pzlib_filefunc_def ) ) ; <nl> - / * <nl> - Open a Zip file , like unz64Open , but provide a set of file low level API <nl> - for read / write the zip file ( see ioapi . h ) <nl> - * / <nl> - <nl> - int CC_DLL unzClose OF ( ( unzFile file ) ) ; <nl> - / * <nl> - Close a ZipFile opened with unzipOpen . <nl> - If there is files inside the . Zip opened with unzOpenCurrentFile ( see later ) , <nl> - these files MUST be closed with unzipCloseCurrentFile before call unzipClose . <nl> - return UNZ_OK if there is no problem . * / <nl> - <nl> - int CC_DLL unzGetGlobalInfo OF ( ( unzFile file , <nl> - unz_global_info * pglobal_info ) ) ; <nl> - <nl> - int CC_DLL unzGetGlobalInfo64 OF ( ( unzFile file , <nl> - unz_global_info64 * pglobal_info ) ) ; <nl> - / * <nl> - Write info about the ZipFile in the * pglobal_info structure . <nl> - No preparation of the structure is needed <nl> - return UNZ_OK if there is no problem . * / <nl> - <nl> - <nl> - int CC_DLL unzGetGlobalComment OF ( ( unzFile file , <nl> - char * szComment , <nl> - uLong uSizeBuf ) ) ; <nl> - / * <nl> - Get the global comment string of the ZipFile , in the szComment buffer . <nl> - uSizeBuf is the size of the szComment buffer . <nl> - return the number of byte copied or an error code < 0 <nl> - * / <nl> - <nl> - <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * Unzip package allow you browse the directory of the zipfile * / <nl> - <nl> - int CC_DLL unzGoToFirstFile OF ( ( unzFile file ) ) ; <nl> - <nl> - / * <nl> - Set the current file of the zipfile to the first file . <nl> - return UNZ_OK if there is no problem <nl> - * / <nl> - <nl> - int CC_DLL unzGoToFirstFile64 OF ( ( unzFile file , <nl> - unz_file_info64 * pfile_info , <nl> - char * szFileName , <nl> - uLong fileNameBufferSize ) ) ; <nl> - / * <nl> - Set the current file of the zipfile to the first file <nl> - with retrieving an information about the file . <nl> - return UNZ_OK if there is no problem <nl> - * / <nl> - <nl> - int CC_DLL unzGoToNextFile OF ( ( unzFile file ) ) ; <nl> - / * <nl> - Set the current file of the zipfile to the next file . <nl> - return UNZ_OK if there is no problem <nl> - return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest . <nl> - * / <nl> - <nl> - int CC_DLL unzGoToNextFile64 OF ( ( unzFile file , <nl> - unz_file_info64 * pfile_info , <nl> - char * szFileName , <nl> - uLong fileNameBufferSize ) ) ; <nl> - / * <nl> - Set the current file of the zipfile to the next file <nl> - with retrieving an information about the file . <nl> - return UNZ_OK if there is no problem <nl> - return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest . <nl> - * / <nl> - <nl> - int CC_DLL unzLocateFile OF ( ( unzFile file , <nl> - const char * szFileName , <nl> - int iCaseSensitivity ) ) ; <nl> - / * <nl> - Try locate the file szFileName in the zipfile . <nl> - For the iCaseSensitivity signification , see unzStringFileNameCompare <nl> - <nl> - return value : <nl> - UNZ_OK if the file is found . It becomes the current file . <nl> - UNZ_END_OF_LIST_OF_FILE if the file is not found <nl> - * / <nl> - <nl> - <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * Ryan supplied functions * / <nl> - / * unz_file_info contain information about a file in the zipfile * / <nl> - typedef struct unz_file_pos_s <nl> - { <nl> - uLong pos_in_zip_directory ; / * offset in zip file directory * / <nl> - uLong num_of_file ; / * # of file * / <nl> - } unz_file_pos ; <nl> - <nl> - int CC_DLL unzGetFilePos ( <nl> - unzFile file , <nl> - unz_file_pos * file_pos ) ; <nl> - <nl> - int CC_DLL unzGoToFilePos ( <nl> - unzFile file , <nl> - unz_file_pos * file_pos ) ; <nl> - <nl> - typedef struct unz64_file_pos_s <nl> - { <nl> - ZPOS64_T pos_in_zip_directory ; / * offset in zip file directory * / <nl> - ZPOS64_T num_of_file ; / * # of file * / <nl> - } unz64_file_pos ; <nl> - <nl> - int CC_DLL unzGetFilePos64 ( <nl> - unzFile file , <nl> - unz64_file_pos * file_pos ) ; <nl> - <nl> - int CC_DLL unzGoToFilePos64 ( <nl> - unzFile file , <nl> - const unz64_file_pos * file_pos ) ; <nl> - <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - int CC_DLL unzGetCurrentFileInfo64 OF ( ( unzFile file , <nl> - unz_file_info64 * pfile_info , <nl> - char * szFileName , <nl> - uLong fileNameBufferSize , <nl> - void * extraField , <nl> - uLong extraFieldBufferSize , <nl> - char * szComment , <nl> - uLong commentBufferSize ) ) ; <nl> - <nl> - int CC_DLL unzGetCurrentFileInfo OF ( ( unzFile file , <nl> - unz_file_info * pfile_info , <nl> - char * szFileName , <nl> - uLong fileNameBufferSize , <nl> - void * extraField , <nl> - uLong extraFieldBufferSize , <nl> - char * szComment , <nl> - uLong commentBufferSize ) ) ; <nl> - / * <nl> - Get Info about the current file <nl> - if pfile_info ! = NULL , the * pfile_info structure will contain some info about <nl> - the current file <nl> - if szFileName ! = NULL , the filename string will be copied in szFileName <nl> - ( fileNameBufferSize is the size of the buffer ) <nl> - if extraField ! = NULL , the extra field information will be copied in extraField <nl> - ( extraFieldBufferSize is the size of the buffer ) . <nl> - This is the Central - header version of the extra field <nl> - if szComment ! = NULL , the comment string of the file will be copied in szComment <nl> - ( commentBufferSize is the size of the buffer ) <nl> - * / <nl> - <nl> - <nl> - / * * Addition for GDAL : START * / <nl> - <nl> - ZPOS64_T CC_DLL unzGetCurrentFileZStreamPos64 OF ( ( unzFile file ) ) ; <nl> - <nl> - / * * Addition for GDAL : END * / <nl> - <nl> - <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * for reading the content of the current zipfile , you can open it , read data <nl> - from it , and close it ( you can close it before reading all the file ) <nl> - * / <nl> - <nl> - int CC_DLL unzOpenCurrentFile OF ( ( unzFile file ) ) ; <nl> - / * <nl> - Open for reading data the current file in the zipfile . <nl> - If there is no error , the return value is UNZ_OK . <nl> - * / <nl> - <nl> - int CC_DLL unzOpenCurrentFilePassword OF ( ( unzFile file , <nl> - const char * password ) ) ; <nl> - / * <nl> - Open for reading data the current file in the zipfile . <nl> - password is a crypting password <nl> - If there is no error , the return value is UNZ_OK . <nl> - * / <nl> - <nl> - int CC_DLL unzOpenCurrentFile2 OF ( ( unzFile file , <nl> - int * method , <nl> - int * level , <nl> - int raw ) ) ; <nl> - / * <nl> - Same than unzOpenCurrentFile , but open for read raw the file ( not uncompress ) <nl> - if raw = = 1 <nl> - * method will receive method of compression , * level will receive level of <nl> - compression <nl> - note : you can set level parameter as NULL ( if you did not want known level , <nl> - but you CANNOT set method parameter as NULL <nl> - * / <nl> - <nl> - int CC_DLL unzOpenCurrentFile3 OF ( ( unzFile file , <nl> - int * method , <nl> - int * level , <nl> - int raw , <nl> - const char * password ) ) ; <nl> - / * <nl> - Same than unzOpenCurrentFile , but open for read raw the file ( not uncompress ) <nl> - if raw = = 1 <nl> - * method will receive method of compression , * level will receive level of <nl> - compression <nl> - note : you can set level parameter as NULL ( if you did not want known level , <nl> - but you CANNOT set method parameter as NULL <nl> - * / <nl> - <nl> - <nl> - int CC_DLL unzCloseCurrentFile OF ( ( unzFile file ) ) ; <nl> - / * <nl> - Close the file in zip opened with unzOpenCurrentFile <nl> - Return UNZ_CRCERROR if all the file was read but the CRC is not good <nl> - * / <nl> - <nl> - int CC_DLL unzReadCurrentFile OF ( ( unzFile file , <nl> - voidp buf , <nl> - unsigned len ) ) ; <nl> - / * <nl> - Read bytes from the current file ( opened by unzOpenCurrentFile ) <nl> - buf contain buffer where data must be copied <nl> - len the size of buf . <nl> - <nl> - return the number of byte copied if some bytes are copied <nl> - return 0 if the end of file was reached <nl> - return < 0 with error code if there is an error <nl> - ( UNZ_ERRNO for IO error , or zLib error for uncompress error ) <nl> - * / <nl> - <nl> - z_off_t CC_DLL unztell OF ( ( unzFile file ) ) ; <nl> - <nl> - ZPOS64_T CC_DLL unztell64 OF ( ( unzFile file ) ) ; <nl> - / * <nl> - Give the current position in uncompressed data <nl> - * / <nl> - <nl> - int CC_DLL unzeof OF ( ( unzFile file ) ) ; <nl> - / * <nl> - return 1 if the end of file was reached , 0 elsewhere <nl> - * / <nl> - <nl> - int CC_DLL unzGetLocalExtrafield OF ( ( unzFile file , <nl> - voidp buf , <nl> - unsigned len ) ) ; <nl> - / * <nl> - Read extra field from the current file ( opened by unzOpenCurrentFile ) <nl> - This is the local - header version of the extra field ( sometimes , there is <nl> - more info in the local - header version than in the central - header ) <nl> - <nl> - if buf = = NULL , it return the size of the local extra field <nl> - <nl> - if buf ! = NULL , len is the size of the buffer , the extra header is copied in <nl> - buf . <nl> - the return value is the number of bytes copied in buf , or ( if < 0 ) <nl> - the error code <nl> - * / <nl> - <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - / * Get the current file offset * / <nl> - ZPOS64_T CC_DLL unzGetOffset64 ( unzFile file ) ; <nl> - uLong CC_DLL unzGetOffset ( unzFile file ) ; <nl> - <nl> - / * Set the current file offset * / <nl> - int CC_DLL unzSetOffset64 ( unzFile file , ZPOS64_T pos ) ; <nl> - int CC_DLL unzSetOffset ( unzFile file , uLong pos ) ; <nl> - <nl> - } / / end of namespace cocos2d <nl> - <nl> - # endif / * _unz64_H * / <nl> similarity index 100 % <nl> rename from cocos / 2d / support / data_support / uthash . h <nl> rename to cocos / 2d / uthash . h <nl> similarity index 100 % <nl> rename from cocos / 2d / support / data_support / utlist . h <nl> rename to cocos / 2d / utlist . h <nl> deleted file mode 100644 <nl> index 5ba0757daca3 . . 000000000000 <nl> mmm a / cocos / platform / CCPlatformConfig . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2010 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # ifndef __CC_PLATFORM_CONFIG_H__ <nl> - # define __CC_PLATFORM_CONFIG_H__ <nl> - <nl> - / * * <nl> - Config of cocos2d - x project , per target platform . <nl> - * / <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / pre configure <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - / / define supported target platform macro which CC uses . <nl> - # define CC_PLATFORM_UNKNOWN 0 <nl> - # define CC_PLATFORM_IOS 1 <nl> - # define CC_PLATFORM_ANDROID 2 <nl> - # define CC_PLATFORM_WIN32 3 <nl> - # define CC_PLATFORM_MARMALADE 4 <nl> - # define CC_PLATFORM_LINUX 5 <nl> - # define CC_PLATFORM_BADA 6 <nl> - # define CC_PLATFORM_BLACKBERRY 7 <nl> - # define CC_PLATFORM_MAC 8 <nl> - # define CC_PLATFORM_NACL 9 <nl> - # define CC_PLATFORM_EMSCRIPTEN 10 <nl> - # define CC_PLATFORM_TIZEN 11 <nl> - # define CC_PLATFORM_QT5 12 <nl> - <nl> - / / Determine target platform by compile environment macro . <nl> - # define CC_TARGET_PLATFORM CC_PLATFORM_UNKNOWN <nl> - <nl> - / / mac <nl> - # if defined ( CC_TARGET_OS_MAC ) <nl> - # undef CC_TARGET_PLATFORM <nl> - # define CC_TARGET_PLATFORM CC_PLATFORM_MAC <nl> - # endif <nl> - <nl> - / / iphone <nl> - # if defined ( CC_TARGET_OS_IPHONE ) <nl> - # undef CC_TARGET_PLATFORM <nl> - # define CC_TARGET_PLATFORM CC_PLATFORM_IOS <nl> - # endif <nl> - <nl> - / / android <nl> - # if defined ( ANDROID ) <nl> - # undef CC_TARGET_PLATFORM <nl> - # define CC_TARGET_PLATFORM CC_PLATFORM_ANDROID <nl> - # endif <nl> - <nl> - / / win32 <nl> - # if defined ( WIN32 ) & & defined ( _WINDOWS ) <nl> - # undef CC_TARGET_PLATFORM <nl> - # define CC_TARGET_PLATFORM CC_PLATFORM_WIN32 <nl> - # endif <nl> - <nl> - / / linux <nl> - # if defined ( LINUX ) <nl> - # undef CC_TARGET_PLATFORM <nl> - # define CC_TARGET_PLATFORM CC_PLATFORM_LINUX <nl> - # endif <nl> - <nl> - / / marmalade <nl> - # if defined ( MARMALADE ) <nl> - # undef CC_TARGET_PLATFORM <nl> - # define CC_TARGET_PLATFORM CC_PLATFORM_MARMALADE <nl> - # endif <nl> - <nl> - / / bada <nl> - # if defined ( SHP ) <nl> - # undef CC_TARGET_PLATFORM <nl> - # define CC_TARGET_PLATFORM CC_PLATFORM_BADA <nl> - # endif <nl> - <nl> - / / qnx <nl> - # if defined ( __QNX__ ) <nl> - # undef CC_TARGET_PLATFORM <nl> - # define CC_TARGET_PLATFORM CC_PLATFORM_BLACKBERRY <nl> - # endif <nl> - <nl> - / / native client <nl> - # if defined ( __native_client__ ) <nl> - # undef CC_TARGET_PLATFORM <nl> - # define CC_TARGET_PLATFORM CC_PLATFORM_NACL <nl> - # endif <nl> - <nl> - / / Emscripten <nl> - # if defined ( EMSCRIPTEN ) <nl> - # undef CC_TARGET_PLATFORM <nl> - # define CC_TARGET_PLATFORM CC_PLATFORM_EMSCRIPTEN <nl> - # endif <nl> - <nl> - / / tizen <nl> - # if defined ( TIZEN ) <nl> - # undef CC_TARGET_PLATFORM <nl> - # define CC_TARGET_PLATFORM CC_PLATFORM_TIZEN <nl> - # endif <nl> - <nl> - / / qt5 <nl> - # if defined ( CC_TARGET_QT5 ) <nl> - # undef CC_TARGET_PLATFORM <nl> - # define CC_TARGET_PLATFORM CC_PLATFORM_QT5 <nl> - # endif <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / post configure <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - / / check user set platform <nl> - # if ! CC_TARGET_PLATFORM <nl> - # error " Cannot recognize the target platform ; are you targeting an unsupported platform ? " <nl> - # endif <nl> - <nl> - # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_WIN32 ) <nl> - # pragma warning ( disable : 4127 ) <nl> - # endif / / CC_PLATFORM_WIN32 <nl> - <nl> - # endif / / __CC_PLATFORM_CONFIG_H__ <nl> - <nl> deleted file mode 100644 <nl> index fca1255c0d60 . . 000000000000 <nl> mmm a / cocos / platform / CCPlatformMacros . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2010 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - # ifndef __CC_PLATFORM_MACROS_H__ <nl> - # define __CC_PLATFORM_MACROS_H__ <nl> - <nl> - / * * <nl> - * define some platform specific macros <nl> - * / <nl> - # include " ccConfig . h " <nl> - # include " CCPlatformConfig . h " <nl> - # include " CCPlatformDefine . h " <nl> - <nl> - / * * <nl> - * define a create function for a specific type , such as Layer <nl> - * @ param \ __TYPE__ class type to add create ( ) , such as Layer <nl> - * / <nl> - # define CREATE_FUNC ( __TYPE__ ) \ <nl> - static __TYPE__ * create ( ) \ <nl> - { \ <nl> - __TYPE__ * pRet = new __TYPE__ ( ) ; \ <nl> - if ( pRet & & pRet - > init ( ) ) \ <nl> - { \ <nl> - pRet - > autorelease ( ) ; \ <nl> - return pRet ; \ <nl> - } \ <nl> - else \ <nl> - { \ <nl> - delete pRet ; \ <nl> - pRet = NULL ; \ <nl> - return NULL ; \ <nl> - } \ <nl> - } <nl> - <nl> - / * * <nl> - * define a node function for a specific type , such as Layer <nl> - * @ param \ __TYPE__ class type to add node ( ) , such as Layer <nl> - * @ deprecated This interface will be deprecated sooner or later . <nl> - * / <nl> - # define NODE_FUNC ( __TYPE__ ) \ <nl> - CC_DEPRECATED_ATTRIBUTE static __TYPE__ * node ( ) \ <nl> - { \ <nl> - __TYPE__ * pRet = new __TYPE__ ( ) ; \ <nl> - if ( pRet & & pRet - > init ( ) ) \ <nl> - { \ <nl> - pRet - > autorelease ( ) ; \ <nl> - return pRet ; \ <nl> - } \ <nl> - else \ <nl> - { \ <nl> - delete pRet ; \ <nl> - pRet = NULL ; \ <nl> - return NULL ; \ <nl> - } \ <nl> - } <nl> - <nl> - / * * @ def CC_ENABLE_CACHE_TEXTURE_DATA <nl> - Enable it if you want to cache the texture data . <nl> - Not enabling for Emscripten any more - - doesn ' t seem necessary and don ' t want <nl> - to be different from other platforms unless there ' s a good reason . <nl> - <nl> - It ' s new in cocos2d - x since v0 . 99 . 5 <nl> - * / <nl> - # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_ANDROID ) <nl> - # define CC_ENABLE_CACHE_TEXTURE_DATA 1 <nl> - # else <nl> - # define CC_ENABLE_CACHE_TEXTURE_DATA 0 <nl> - # endif <nl> - <nl> - # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_ANDROID ) | | ( CC_TARGET_PLATFORM = = CC_PLATFORM_WIN32 ) | | ( CC_TARGET_PLATFORM = = CC_PLATFORM_EMSCRIPTEN ) <nl> - / * Application will crash in glDrawElements function on some win32 computers and some android devices . <nl> - Indices should be bound again while drawing to avoid this bug . <nl> - * / <nl> - # define CC_REBIND_INDICES_BUFFER 1 <nl> - # else <nl> - # define CC_REBIND_INDICES_BUFFER 0 <nl> - # endif <nl> - <nl> - / / generic macros <nl> - <nl> - / / namespace cocos2d { } <nl> - # ifdef __cplusplus <nl> - # define NS_CC_BEGIN namespace cocos2d { <nl> - # define NS_CC_END } <nl> - # define USING_NS_CC using namespace cocos2d <nl> - # else <nl> - # define NS_CC_BEGIN <nl> - # define NS_CC_END <nl> - # define USING_NS_CC <nl> - # endif <nl> - <nl> - / * * CC_PROPERTY_READONLY is used to declare a protected variable . <nl> - We can use getter to read the variable . <nl> - @ param varType the type of variable . <nl> - @ param varName variable name . <nl> - @ param funName " get + funName " will be the name of the getter . <nl> - @ warning The getter is a public virtual function , you should rewrite it first . <nl> - The variables and methods declared after CC_PROPERTY_READONLY are all public . <nl> - If you need protected or private , please declare . <nl> - * / <nl> - # define CC_PROPERTY_READONLY ( varType , varName , funName ) \ <nl> - protected : varType varName ; \ <nl> - public : virtual varType get # # funName ( void ) const ; <nl> - <nl> - # define CC_PROPERTY_READONLY_PASS_BY_REF ( varType , varName , funName ) \ <nl> - protected : varType varName ; \ <nl> - public : virtual const varType & get # # funName ( void ) const ; <nl> - <nl> - / * * CC_PROPERTY is used to declare a protected variable . <nl> - We can use getter to read the variable , and use the setter to change the variable . <nl> - @ param varType the type of variable . <nl> - @ param varName variable name . <nl> - @ param funName " get + funName " will be the name of the getter . <nl> - " set + funName " will be the name of the setter . <nl> - @ warning The getter and setter are public virtual functions , you should rewrite them first . <nl> - The variables and methods declared after CC_PROPERTY are all public . <nl> - If you need protected or private , please declare . <nl> - * / <nl> - # define CC_PROPERTY ( varType , varName , funName ) \ <nl> - protected : varType varName ; \ <nl> - public : virtual varType get # # funName ( void ) ; \ <nl> - public : virtual void set # # funName ( varType var ) ; <nl> - <nl> - # define CC_PROPERTY_PASS_BY_REF ( varType , varName , funName ) \ <nl> - protected : varType varName ; \ <nl> - public : virtual const varType & get # # funName ( void ) const ; \ <nl> - public : virtual void set # # funName ( const varType & var ) ; <nl> - <nl> - / * * CC_SYNTHESIZE_READONLY is used to declare a protected variable . <nl> - We can use getter to read the variable . <nl> - @ param varType the type of variable . <nl> - @ param varName variable name . <nl> - @ param funName " get + funName " will be the name of the getter . <nl> - @ warning The getter is a public inline function . <nl> - The variables and methods declared after CC_SYNTHESIZE_READONLY are all public . <nl> - If you need protected or private , please declare . <nl> - * / <nl> - # define CC_SYNTHESIZE_READONLY ( varType , varName , funName ) \ <nl> - protected : varType varName ; \ <nl> - public : virtual varType get # # funName ( void ) const { return varName ; } <nl> - <nl> - # define CC_SYNTHESIZE_READONLY_PASS_BY_REF ( varType , varName , funName ) \ <nl> - protected : varType varName ; \ <nl> - public : virtual const varType & get # # funName ( void ) const { return varName ; } <nl> - <nl> - / * * CC_SYNTHESIZE is used to declare a protected variable . <nl> - We can use getter to read the variable , and use the setter to change the variable . <nl> - @ param varType the type of variable . <nl> - @ param varName variable name . <nl> - @ param funName " get + funName " will be the name of the getter . <nl> - " set + funName " will be the name of the setter . <nl> - @ warning The getter and setter are public inline functions . <nl> - The variables and methods declared after CC_SYNTHESIZE are all public . <nl> - If you need protected or private , please declare . <nl> - * / <nl> - # define CC_SYNTHESIZE ( varType , varName , funName ) \ <nl> - protected : varType varName ; \ <nl> - public : virtual varType get # # funName ( void ) const { return varName ; } \ <nl> - public : virtual void set # # funName ( varType var ) { varName = var ; } <nl> - <nl> - # define CC_SYNTHESIZE_PASS_BY_REF ( varType , varName , funName ) \ <nl> - protected : varType varName ; \ <nl> - public : virtual const varType & get # # funName ( void ) const { return varName ; } \ <nl> - public : virtual void set # # funName ( const varType & var ) { varName = var ; } <nl> - <nl> - # define CC_SYNTHESIZE_RETAIN ( varType , varName , funName ) \ <nl> - private : varType varName ; \ <nl> - public : virtual varType get # # funName ( void ) const { return varName ; } \ <nl> - public : virtual void set # # funName ( varType var ) \ <nl> - { \ <nl> - if ( varName ! = var ) \ <nl> - { \ <nl> - CC_SAFE_RETAIN ( var ) ; \ <nl> - CC_SAFE_RELEASE ( varName ) ; \ <nl> - varName = var ; \ <nl> - } \ <nl> - } <nl> - <nl> - # define CC_SAFE_DELETE ( p ) do { delete ( p ) ; ( p ) = nullptr ; } while ( 0 ) <nl> - # define CC_SAFE_DELETE_ARRAY ( p ) do { if ( p ) { delete [ ] ( p ) ; ( p ) = nullptr ; } } while ( 0 ) <nl> - # define CC_SAFE_FREE ( p ) do { if ( p ) { free ( p ) ; ( p ) = nullptr ; } } while ( 0 ) <nl> - # define CC_SAFE_RELEASE ( p ) do { if ( p ) { ( p ) - > release ( ) ; } } while ( 0 ) <nl> - # define CC_SAFE_RELEASE_NULL ( p ) do { if ( p ) { ( p ) - > release ( ) ; ( p ) = nullptr ; } } while ( 0 ) <nl> - # define CC_SAFE_RETAIN ( p ) do { if ( p ) { ( p ) - > retain ( ) ; } } while ( 0 ) <nl> - # define CC_BREAK_IF ( cond ) if ( cond ) break <nl> - <nl> - # define __CCLOGWITHFUNCTION ( s , . . . ) \ <nl> - log ( " % s : % s " , __FUNCTION__ , String : : createWithFormat ( s , # # __VA_ARGS__ ) - > getCString ( ) ) <nl> - <nl> - / / cocos2d debug <nl> - # if ! defined ( COCOS2D_DEBUG ) | | COCOS2D_DEBUG = = 0 <nl> - # define CCLOG ( . . . ) do { } while ( 0 ) <nl> - # define CCLOGINFO ( . . . ) do { } while ( 0 ) <nl> - # define CCLOGERROR ( . . . ) do { } while ( 0 ) <nl> - # define CCLOGWARN ( . . . ) do { } while ( 0 ) <nl> - <nl> - # elif COCOS2D_DEBUG = = 1 <nl> - # define CCLOG ( format , . . . ) cocos2d : : log ( format , # # __VA_ARGS__ ) <nl> - # define CCLOGERROR ( format , . . . ) cocos2d : : log ( format , # # __VA_ARGS__ ) <nl> - # define CCLOGINFO ( format , . . . ) do { } while ( 0 ) <nl> - # define CCLOGWARN ( . . . ) __CCLOGWITHFUNCTION ( __VA_ARGS__ ) <nl> - <nl> - # elif COCOS2D_DEBUG > 1 <nl> - # define CCLOG ( format , . . . ) cocos2d : : log ( format , # # __VA_ARGS__ ) <nl> - # define CCLOGERROR ( format , . . . ) cocos2d : : log ( format , # # __VA_ARGS__ ) <nl> - # define CCLOGINFO ( format , . . . ) cocos2d : : log ( format , # # __VA_ARGS__ ) <nl> - # define CCLOGWARN ( . . . ) __CCLOGWITHFUNCTION ( __VA_ARGS__ ) <nl> - # endif / / COCOS2D_DEBUG <nl> - <nl> - / / Lua engine debug <nl> - # if ! defined ( COCOS2D_DEBUG ) | | COCOS2D_DEBUG = = 0 | | CC_LUA_ENGINE_DEBUG = = 0 <nl> - # define LUALOG ( . . . ) <nl> - # else <nl> - # define LUALOG ( format , . . . ) cocos2d : : log ( format , # # __VA_ARGS__ ) <nl> - # endif / / Lua engine debug <nl> - <nl> - # if defined ( __GNUC__ ) & & ( ( __GNUC__ > = 5 ) | | ( ( __GNUG__ = = 4 ) & & ( __GNUC_MINOR__ > = 4 ) ) ) \ <nl> - | | ( defined ( __clang__ ) & & ( __clang_major__ > = 3 ) ) <nl> - # define CC_DISABLE_COPY ( Class ) \ <nl> - private : \ <nl> - Class ( const Class & ) = delete ; \ <nl> - Class & operator = ( const Class & ) = delete ; <nl> - # else <nl> - # define CC_DISABLE_COPY ( Class ) \ <nl> - private : \ <nl> - Class ( const Class & ) ; \ <nl> - Class & operator = ( const Class & ) ; <nl> - # endif <nl> - <nl> - / * <nl> - * only certain compilers support __attribute__ ( ( deprecated ) ) <nl> - * / <nl> - # if defined ( __GNUC__ ) & & ( ( __GNUC__ > = 4 ) | | ( ( __GNUC__ = = 3 ) & & ( __GNUC_MINOR__ > = 1 ) ) ) <nl> - # define CC_DEPRECATED_ATTRIBUTE __attribute__ ( ( deprecated ) ) <nl> - # elif _MSC_VER > = 1400 / / vs 2005 or higher <nl> - # define CC_DEPRECATED_ATTRIBUTE __declspec ( deprecated ) <nl> - # else <nl> - # define CC_DEPRECATED_ATTRIBUTE <nl> - # endif <nl> - <nl> - / * <nl> - * only certain compiler support __attribute__ ( ( format ) ) <nl> - * formatPos - 1 - based position of format string argument <nl> - * argPos - 1 - based position of first format - dependent argument <nl> - * / <nl> - # if defined ( __GNUC__ ) & & ( __GNUC__ > = 4 ) <nl> - # define CC_FORMAT_PRINTF ( formatPos , argPos ) __attribute__ ( ( __format__ ( printf , formatPos , argPos ) ) ) <nl> - # elif defined ( __has_attribute ) <nl> - # if __has_attribute ( format ) <nl> - # define CC_FORMAT_PRINTF ( formatPos , argPos ) __attribute__ ( ( __format__ ( printf , formatPos , argPos ) ) ) <nl> - # endif / / __has_attribute ( format ) <nl> - # else <nl> - # define CC_FORMAT_PRINTF ( formatPos , argPos ) <nl> - # endif <nl> - <nl> - # if defined ( _MSC_VER ) <nl> - # define CC_FORMAT_PRINTF_SIZE_T " % 08lX " <nl> - # else <nl> - # define CC_FORMAT_PRINTF_SIZE_T " % 08zX " <nl> - # endif <nl> - <nl> - # ifdef __GNUC__ <nl> - # define CC_UNUSED __attribute__ ( ( unused ) ) <nl> - # else <nl> - # define CC_UNUSED <nl> - # endif <nl> - <nl> - / / <nl> - / / CC_REQUIRES_NULL_TERMINATION <nl> - / / <nl> - # if ! defined ( CC_REQUIRES_NULL_TERMINATION ) <nl> - # if defined ( __APPLE_CC__ ) & & ( __APPLE_CC__ > = 5549 ) <nl> - # define CC_REQUIRES_NULL_TERMINATION __attribute__ ( ( sentinel ( 0 , 1 ) ) ) <nl> - # elif defined ( __GNUC__ ) <nl> - # define CC_REQUIRES_NULL_TERMINATION __attribute__ ( ( sentinel ) ) <nl> - # else <nl> - # define CC_REQUIRES_NULL_TERMINATION <nl> - # endif <nl> - # endif <nl> - <nl> - # endif / / __CC_PLATFORM_MACROS_H__ <nl> deleted file mode 100644 <nl> index 2e39f344cc01 . . 000000000000 <nl> mmm a / cocos / platform / cocoa / CCAffineTransform . cpp <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2010 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - # include " CCAffineTransform . h " <nl> - # include < algorithm > <nl> - # include < math . h > <nl> - <nl> - using namespace std ; <nl> - <nl> - <nl> - NS_CC_BEGIN <nl> - <nl> - AffineTransform __CCAffineTransformMake ( float a , float b , float c , float d , float tx , float ty ) <nl> - { <nl> - AffineTransform t ; <nl> - t . a = a ; t . b = b ; t . c = c ; t . d = d ; t . tx = tx ; t . ty = ty ; <nl> - return t ; <nl> - } <nl> - <nl> - Point __CCPointApplyAffineTransform ( const Point & point , const AffineTransform & t ) <nl> - { <nl> - Point p ; <nl> - p . x = ( float ) ( ( double ) t . a * point . x + ( double ) t . c * point . y + t . tx ) ; <nl> - p . y = ( float ) ( ( double ) t . b * point . x + ( double ) t . d * point . y + t . ty ) ; <nl> - return p ; <nl> - } <nl> - <nl> - Size __CCSizeApplyAffineTransform ( const Size & size , const AffineTransform & t ) <nl> - { <nl> - Size s ; <nl> - s . width = ( float ) ( ( double ) t . a * size . width + ( double ) t . c * size . height ) ; <nl> - s . height = ( float ) ( ( double ) t . b * size . width + ( double ) t . d * size . height ) ; <nl> - return s ; <nl> - } <nl> - <nl> - <nl> - AffineTransform AffineTransformMakeIdentity ( ) <nl> - { <nl> - return __CCAffineTransformMake ( 1 . 0 , 0 . 0 , 0 . 0 , 1 . 0 , 0 . 0 , 0 . 0 ) ; <nl> - } <nl> - <nl> - extern const AffineTransform AffineTransformIdentity = AffineTransformMakeIdentity ( ) ; <nl> - const AffineTransform AffineTransform : : IDENTITY = AffineTransformMakeIdentity ( ) ; <nl> - <nl> - Rect RectApplyAffineTransform ( const Rect & rect , const AffineTransform & anAffineTransform ) <nl> - { <nl> - float top = rect . getMinY ( ) ; <nl> - float left = rect . getMinX ( ) ; <nl> - float right = rect . getMaxX ( ) ; <nl> - float bottom = rect . getMaxY ( ) ; <nl> - <nl> - Point topLeft = PointApplyAffineTransform ( Point ( left , top ) , anAffineTransform ) ; <nl> - Point topRight = PointApplyAffineTransform ( Point ( right , top ) , anAffineTransform ) ; <nl> - Point bottomLeft = PointApplyAffineTransform ( Point ( left , bottom ) , anAffineTransform ) ; <nl> - Point bottomRight = PointApplyAffineTransform ( Point ( right , bottom ) , anAffineTransform ) ; <nl> - <nl> - float minX = min ( min ( topLeft . x , topRight . x ) , min ( bottomLeft . x , bottomRight . x ) ) ; <nl> - float maxX = max ( max ( topLeft . x , topRight . x ) , max ( bottomLeft . x , bottomRight . x ) ) ; <nl> - float minY = min ( min ( topLeft . y , topRight . y ) , min ( bottomLeft . y , bottomRight . y ) ) ; <nl> - float maxY = max ( max ( topLeft . y , topRight . y ) , max ( bottomLeft . y , bottomRight . y ) ) ; <nl> - <nl> - return Rect ( minX , minY , ( maxX - minX ) , ( maxY - minY ) ) ; <nl> - } <nl> - <nl> - AffineTransform AffineTransformTranslate ( const AffineTransform & t , float tx , float ty ) <nl> - { <nl> - return __CCAffineTransformMake ( t . a , t . b , t . c , t . d , t . tx + t . a * tx + t . c * ty , t . ty + t . b * tx + t . d * ty ) ; <nl> - } <nl> - <nl> - AffineTransform AffineTransformScale ( const AffineTransform & t , float sx , float sy ) <nl> - { <nl> - return __CCAffineTransformMake ( t . a * sx , t . b * sx , t . c * sy , t . d * sy , t . tx , t . ty ) ; <nl> - } <nl> - <nl> - AffineTransform AffineTransformRotate ( const AffineTransform & t , float anAngle ) <nl> - { <nl> - float sine = sinf ( anAngle ) ; <nl> - float cosine = cosf ( anAngle ) ; <nl> - <nl> - return __CCAffineTransformMake ( t . a * cosine + t . c * sine , <nl> - t . b * cosine + t . d * sine , <nl> - t . c * cosine - t . a * sine , <nl> - t . d * cosine - t . b * sine , <nl> - t . tx , <nl> - t . ty ) ; <nl> - } <nl> - <nl> - / * Concatenate ` t2 ' to ` t1 ' and return the result : <nl> - t ' = t1 * t2 * / <nl> - AffineTransform AffineTransformConcat ( const AffineTransform & t1 , const AffineTransform & t2 ) <nl> - { <nl> - return __CCAffineTransformMake ( t1 . a * t2 . a + t1 . b * t2 . c , t1 . a * t2 . b + t1 . b * t2 . d , / / a , b <nl> - t1 . c * t2 . a + t1 . d * t2 . c , t1 . c * t2 . b + t1 . d * t2 . d , / / c , d <nl> - t1 . tx * t2 . a + t1 . ty * t2 . c + t2 . tx , / / tx <nl> - t1 . tx * t2 . b + t1 . ty * t2 . d + t2 . ty ) ; / / ty <nl> - } <nl> - <nl> - / * Return true if ` t1 ' and ` t2 ' are equal , false otherwise . * / <nl> - bool AffineTransformEqualToTransform ( const AffineTransform & t1 , const AffineTransform & t2 ) <nl> - { <nl> - return ( t1 . a = = t2 . a & & t1 . b = = t2 . b & & t1 . c = = t2 . c & & t1 . d = = t2 . d & & t1 . tx = = t2 . tx & & t1 . ty = = t2 . ty ) ; <nl> - } <nl> - <nl> - AffineTransform AffineTransformInvert ( const AffineTransform & t ) <nl> - { <nl> - float determinant = 1 / ( t . a * t . d - t . b * t . c ) ; <nl> - <nl> - return __CCAffineTransformMake ( determinant * t . d , - determinant * t . b , - determinant * t . c , determinant * t . a , <nl> - determinant * ( t . c * t . ty - t . d * t . tx ) , determinant * ( t . b * t . tx - t . a * t . ty ) ) ; <nl> - } <nl> - <nl> - NS_CC_END <nl> deleted file mode 100644 <nl> index 667b5d9b461e . . 000000000000 <nl> mmm a / cocos / platform / cocoa / CCAffineTransform . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2010 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # ifndef __COCOA_CGAFFINETRANSFORM_H__ <nl> - # define __COCOA_CGAFFINETRANSFORM_H__ <nl> - <nl> - # include " CCGeometry . h " <nl> - # include " platform / CCPlatformMacros . h " <nl> - <nl> - NS_CC_BEGIN <nl> - <nl> - struct AffineTransform { <nl> - float a , b , c , d ; <nl> - float tx , ty ; <nl> - <nl> - static const AffineTransform IDENTITY ; <nl> - } ; <nl> - <nl> - CC_DLL AffineTransform __CCAffineTransformMake ( float a , float b , float c , float d , float tx , float ty ) ; <nl> - # define AffineTransformMake __CCAffineTransformMake <nl> - <nl> - CC_DLL Point __CCPointApplyAffineTransform ( const Point & point , const AffineTransform & t ) ; <nl> - # define PointApplyAffineTransform __CCPointApplyAffineTransform <nl> - <nl> - CC_DLL Size __CCSizeApplyAffineTransform ( const Size & size , const AffineTransform & t ) ; <nl> - # define SizeApplyAffineTransform __CCSizeApplyAffineTransform <nl> - <nl> - CC_DLL AffineTransform AffineTransformMakeIdentity ( ) ; <nl> - CC_DLL Rect RectApplyAffineTransform ( const Rect & rect , const AffineTransform & anAffineTransform ) ; <nl> - <nl> - CC_DLL AffineTransform AffineTransformTranslate ( const AffineTransform & t , float tx , float ty ) ; <nl> - CC_DLL AffineTransform AffineTransformRotate ( const AffineTransform & aTransform , float anAngle ) ; <nl> - CC_DLL AffineTransform AffineTransformScale ( const AffineTransform & t , float sx , float sy ) ; <nl> - CC_DLL AffineTransform AffineTransformConcat ( const AffineTransform & t1 , const AffineTransform & t2 ) ; <nl> - CC_DLL bool AffineTransformEqualToTransform ( const AffineTransform & t1 , const AffineTransform & t2 ) ; <nl> - CC_DLL AffineTransform AffineTransformInvert ( const AffineTransform & t ) ; <nl> - <nl> - extern CC_DLL const AffineTransform AffineTransformIdentity ; <nl> - <nl> - NS_CC_END <nl> - <nl> - # endif / / __COCOA_CGAFFINETRANSFORM_H__ <nl> deleted file mode 100644 <nl> index 3a55d6050dad . . 000000000000 <nl> mmm a / cocos / platform / cocoa / CCArray . cpp <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2010 ForzeField Studios S . L . http : / / forzefield . com <nl> - Copyright ( c ) 2010 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # include " CCArray . h " <nl> - # include " CCString . h " <nl> - # include " platform / CCFileUtils . h " <nl> - <nl> - NS_CC_BEGIN <nl> - <nl> - <nl> - # if CC_USE_ARRAY_VECTOR <nl> - <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> - / / std : : vector implementation <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> - <nl> - Array : : Array ( ) <nl> - : data ( NULL ) <nl> - { <nl> - init ( ) ; <nl> - } <nl> - <nl> - Array * Array : : create ( ) <nl> - { <nl> - Array * array = new Array ( ) ; <nl> - <nl> - if ( array & & array - > initWithCapacity ( 7 ) ) <nl> - { <nl> - array - > autorelease ( ) ; <nl> - } <nl> - else <nl> - { <nl> - CC_SAFE_DELETE ( array ) ; <nl> - } <nl> - <nl> - return array ; <nl> - } <nl> - <nl> - Array * Array : : createWithObject ( Object * object ) <nl> - { <nl> - Array * array = new Array ( ) ; <nl> - <nl> - if ( array & & array - > initWithObject ( object ) ) <nl> - { <nl> - array - > autorelease ( ) ; <nl> - } <nl> - else <nl> - { <nl> - CC_SAFE_DELETE ( array ) ; <nl> - } <nl> - <nl> - return array ; <nl> - } <nl> - <nl> - Array * Array : : create ( Object * object , . . . ) <nl> - { <nl> - va_list args ; <nl> - va_start ( args , object ) ; <nl> - <nl> - Array * array = create ( ) ; <nl> - if ( array & & object ) <nl> - { <nl> - array - > addObject ( object ) ; <nl> - Object * i = va_arg ( args , Object * ) ; <nl> - while ( i ) <nl> - { <nl> - array - > addObject ( i ) ; <nl> - i = va_arg ( args , Object * ) ; <nl> - } <nl> - } <nl> - else <nl> - { <nl> - CC_SAFE_DELETE ( array ) ; <nl> - } <nl> - <nl> - va_end ( args ) ; <nl> - <nl> - return array ; <nl> - } <nl> - <nl> - Array * Array : : createWithArray ( Array * otherArray ) <nl> - { <nl> - return otherArray - > clone ( ) ; <nl> - } <nl> - <nl> - Array * Array : : createWithCapacity ( int capacity ) <nl> - { <nl> - CCASSERT ( capacity > = 0 , " Invalid capacity " ) ; <nl> - <nl> - Array * array = new Array ( ) ; <nl> - <nl> - if ( array & & array - > initWithCapacity ( capacity ) ) <nl> - { <nl> - array - > autorelease ( ) ; <nl> - } <nl> - else <nl> - { <nl> - CC_SAFE_DELETE ( array ) ; <nl> - } <nl> - <nl> - return array ; <nl> - } <nl> - <nl> - Array * Array : : createWithContentsOfFile ( const char * fileName ) <nl> - { <nl> - Array * ret = Array : : createWithContentsOfFileThreadSafe ( fileName ) ; <nl> - if ( ret ! = nullptr ) <nl> - { <nl> - ret - > autorelease ( ) ; <nl> - } <nl> - return ret ; <nl> - } <nl> - <nl> - Array * Array : : createWithContentsOfFileThreadSafe ( const char * fileName ) <nl> - { <nl> - return FileUtils : : getInstance ( ) - > createArrayWithContentsOfFile ( fileName ) ; <nl> - } <nl> - <nl> - bool Array : : init ( ) <nl> - { <nl> - return initWithCapacity ( 7 ) ; <nl> - } <nl> - <nl> - bool Array : : initWithObject ( Object * object ) <nl> - { <nl> - bool ret = initWithCapacity ( 7 ) ; <nl> - if ( ret ) <nl> - { <nl> - addObject ( object ) ; <nl> - } <nl> - return ret ; <nl> - } <nl> - <nl> - / * * Initializes an array with some objects * / <nl> - bool Array : : initWithObjects ( Object * object , . . . ) <nl> - { <nl> - bool ret = false ; <nl> - do <nl> - { <nl> - CC_BREAK_IF ( object = = nullptr ) ; <nl> - <nl> - va_list args ; <nl> - va_start ( args , object ) ; <nl> - <nl> - if ( object ) <nl> - { <nl> - this - > addObject ( object ) ; <nl> - Object * i = va_arg ( args , Object * ) ; <nl> - while ( i ) <nl> - { <nl> - this - > addObject ( i ) ; <nl> - i = va_arg ( args , Object * ) ; <nl> - } <nl> - ret = true ; <nl> - } <nl> - va_end ( args ) ; <nl> - <nl> - } while ( false ) ; <nl> - <nl> - return ret ; <nl> - } <nl> - <nl> - bool Array : : initWithCapacity ( int capacity ) <nl> - { <nl> - CCASSERT ( capacity > = 0 , " Invalid capacity " ) ; <nl> - <nl> - data . reserve ( capacity ) ; <nl> - return true ; <nl> - } <nl> - <nl> - bool Array : : initWithArray ( Array * otherArray ) <nl> - { <nl> - data = otherArray - > data ; <nl> - return true ; <nl> - } <nl> - <nl> - int Array : : getIndexOfObject ( Object * object ) const <nl> - { <nl> - auto it = data . begin ( ) ; <nl> - <nl> - for ( int i = 0 ; it ! = data . end ( ) ; + + it , + + i ) <nl> - { <nl> - if ( it - > get ( ) = = object ) <nl> - { <nl> - return i ; <nl> - } <nl> - } <nl> - <nl> - return - 1 ; <nl> - } <nl> - <nl> - Object * Array : : getRandomObject ( ) <nl> - { <nl> - if ( data . size ( ) = = 0 ) <nl> - { <nl> - return nullptr ; <nl> - } <nl> - <nl> - float r = CCRANDOM_0_1 ( ) ; <nl> - <nl> - if ( r = = 1 ) / / to prevent from accessing data - arr [ data - > num ] , out of range . <nl> - { <nl> - r = 0 ; <nl> - } <nl> - <nl> - r * = data . size ( ) ; <nl> - <nl> - return data [ r ] . get ( ) ; <nl> - } <nl> - <nl> - bool Array : : containsObject ( Object * object ) const <nl> - { <nl> - int i = this - > getIndexOfObject ( object ) ; <nl> - return ( i > = 0 ) ; <nl> - } <nl> - <nl> - bool Array : : isEqualToArray ( Array * otherArray ) <nl> - { <nl> - for ( int i = 0 ; i < this - > count ( ) ; i + + ) <nl> - { <nl> - if ( ! this - > getObjectAtIndex ( i ) - > isEqual ( otherArray - > getObjectAtIndex ( i ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - } <nl> - return true ; <nl> - } <nl> - <nl> - void Array : : addObject ( Object * object ) <nl> - { <nl> - data . push_back ( RCPtr < Object > ( object ) ) ; <nl> - } <nl> - <nl> - void Array : : addObjectsFromArray ( Array * otherArray ) <nl> - { <nl> - data . insert ( data . end ( ) , otherArray - > data . begin ( ) , otherArray - > data . end ( ) ) ; <nl> - } <nl> - <nl> - void Array : : insertObject ( Object * object , int index ) <nl> - { <nl> - data . insert ( std : : begin ( data ) + index , RCPtr < Object > ( object ) ) ; <nl> - } <nl> - <nl> - void Array : : setObject ( Object * object , int index ) <nl> - { <nl> - data [ index ] = RCPtr < Object > ( object ) ; <nl> - } <nl> - <nl> - void Array : : removeLastObject ( bool releaseObj ) <nl> - { <nl> - CCASSERT ( data . size ( ) , " no objects added " ) ; <nl> - data . pop_back ( ) ; <nl> - } <nl> - <nl> - void Array : : removeObject ( Object * object , bool releaseObj / * ignored * / ) <nl> - { <nl> - data . erase ( std : : remove ( data . begin ( ) , data . end ( ) , object ) ) ; <nl> - } <nl> - <nl> - void Array : : removeObjectAtIndex ( int index , bool releaseObj / * ignored * / ) <nl> - { <nl> - auto obj = data [ index ] ; <nl> - data . erase ( data . begin ( ) + index ) ; <nl> - } <nl> - <nl> - void Array : : removeObjectsInArray ( Array * otherArray ) <nl> - { <nl> - CCASSERT ( false , " not implemented " ) ; <nl> - } <nl> - <nl> - void Array : : removeAllObjects ( ) <nl> - { <nl> - data . erase ( std : : begin ( data ) , std : : end ( data ) ) ; <nl> - } <nl> - <nl> - void Array : : fastRemoveObjectAtIndex ( int index ) <nl> - { <nl> - removeObjectAtIndex ( index ) ; <nl> - } <nl> - <nl> - void Array : : fastRemoveObject ( Object * object ) <nl> - { <nl> - removeObject ( object ) ; <nl> - } <nl> - <nl> - void Array : : exchangeObject ( Object * object1 , Object * object2 ) <nl> - { <nl> - int idx1 = getIndexOfObject ( object1 ) ; <nl> - int idx2 = getIndexOfObject ( object2 ) ; <nl> - <nl> - CCASSERT ( idx1 > = 0 & & idx2 > = 2 , " invalid object index " ) ; <nl> - <nl> - std : : swap ( data [ idx1 ] , data [ idx2 ] ) ; <nl> - } <nl> - <nl> - void Array : : exchangeObjectAtIndex ( int index1 , int index2 ) <nl> - { <nl> - std : : swap ( data [ index1 ] , data [ index2 ] ) ; <nl> - } <nl> - <nl> - void Array : : replaceObjectAtIndex ( int index , Object * object , bool releaseObject / * ignored * / ) <nl> - { <nl> - data [ index ] = object ; <nl> - } <nl> - <nl> - void Array : : reverseObjects ( ) <nl> - { <nl> - std : : reverse ( std : : begin ( data ) , std : : end ( data ) ) ; <nl> - } <nl> - <nl> - void Array : : reduceMemoryFootprint ( ) <nl> - { <nl> - / / N / A <nl> - } <nl> - <nl> - Array : : ~ Array ( ) <nl> - { <nl> - CCLOGINFO ( " deallocing Array : % p - len : % d " , this , count ( ) ) ; <nl> - } <nl> - <nl> - Array * Array : : clone ( ) const <nl> - { <nl> - Array * ret = new Array ( ) ; <nl> - ret - > autorelease ( ) ; <nl> - ret - > initWithCapacity ( this - > data . size ( ) > 0 ? this - > data . size ( ) : 1 ) ; <nl> - <nl> - Object * obj = nullptr ; <nl> - Object * tmpObj = nullptr ; <nl> - Clonable * clonable = nullptr ; <nl> - CCARRAY_FOREACH ( this , obj ) <nl> - { <nl> - clonable = dynamic_cast < Clonable * > ( obj ) ; <nl> - if ( clonable ) <nl> - { <nl> - tmpObj = dynamic_cast < Object * > ( clonable - > clone ( ) ) ; <nl> - if ( tmpObj ) <nl> - { <nl> - ret - > addObject ( tmpObj ) ; <nl> - } <nl> - } <nl> - else <nl> - { <nl> - CCLOGWARN ( " % s isn ' t clonable . " , typeid ( * obj ) . name ( ) ) ; <nl> - } <nl> - } <nl> - return ret ; <nl> - } <nl> - <nl> - void Array : : acceptVisitor ( DataVisitor & visitor ) <nl> - { <nl> - visitor . visit ( this ) ; <nl> - } <nl> - <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> - / / ccArray implementation <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> - <nl> - # else <nl> - <nl> - Array : : Array ( ) <nl> - : data ( nullptr ) <nl> - { <nl> - / / init ( ) ; <nl> - } <nl> - <nl> - Array * Array : : create ( ) <nl> - { <nl> - Array * array = new Array ( ) ; <nl> - <nl> - if ( array & & array - > initWithCapacity ( 7 ) ) <nl> - { <nl> - array - > autorelease ( ) ; <nl> - } <nl> - else <nl> - { <nl> - CC_SAFE_DELETE ( array ) ; <nl> - } <nl> - <nl> - return array ; <nl> - } <nl> - <nl> - Array * Array : : createWithObject ( Object * object ) <nl> - { <nl> - Array * array = new Array ( ) ; <nl> - <nl> - if ( array & & array - > initWithObject ( object ) ) <nl> - { <nl> - array - > autorelease ( ) ; <nl> - } <nl> - else <nl> - { <nl> - CC_SAFE_DELETE ( array ) ; <nl> - } <nl> - <nl> - return array ; <nl> - } <nl> - <nl> - Array * Array : : create ( Object * object , . . . ) <nl> - { <nl> - va_list args ; <nl> - va_start ( args , object ) ; <nl> - <nl> - Array * array = create ( ) ; <nl> - if ( array & & object ) <nl> - { <nl> - array - > addObject ( object ) ; <nl> - Object * i = va_arg ( args , Object * ) ; <nl> - while ( i ) <nl> - { <nl> - array - > addObject ( i ) ; <nl> - i = va_arg ( args , Object * ) ; <nl> - } <nl> - } <nl> - else <nl> - { <nl> - CC_SAFE_DELETE ( array ) ; <nl> - } <nl> - <nl> - va_end ( args ) ; <nl> - <nl> - return array ; <nl> - } <nl> - <nl> - Array * Array : : createWithArray ( Array * otherArray ) <nl> - { <nl> - return otherArray - > clone ( ) ; <nl> - } <nl> - <nl> - Array * Array : : createWithCapacity ( int capacity ) <nl> - { <nl> - CCASSERT ( capacity > = 0 , " Invalid capacity " ) ; <nl> - <nl> - Array * array = new Array ( ) ; <nl> - <nl> - if ( array & & array - > initWithCapacity ( capacity ) ) <nl> - { <nl> - array - > autorelease ( ) ; <nl> - } <nl> - else <nl> - { <nl> - CC_SAFE_DELETE ( array ) ; <nl> - } <nl> - <nl> - return array ; <nl> - } <nl> - <nl> - Array * Array : : createWithContentsOfFile ( const char * fileName ) <nl> - { <nl> - Array * ret = Array : : createWithContentsOfFileThreadSafe ( fileName ) ; <nl> - if ( ret ! = nullptr ) <nl> - { <nl> - ret - > autorelease ( ) ; <nl> - } <nl> - return ret ; <nl> - } <nl> - <nl> - Array * Array : : createWithContentsOfFileThreadSafe ( const char * fileName ) <nl> - { <nl> - return FileUtils : : getInstance ( ) - > createArrayWithContentsOfFile ( fileName ) ; <nl> - } <nl> - <nl> - bool Array : : init ( ) <nl> - { <nl> - CCASSERT ( ! data , " Array cannot be re - initialized " ) ; <nl> - <nl> - return initWithCapacity ( 7 ) ; <nl> - } <nl> - <nl> - bool Array : : initWithObject ( Object * object ) <nl> - { <nl> - CCASSERT ( ! data , " Array cannot be re - initialized " ) ; <nl> - <nl> - bool ret = initWithCapacity ( 7 ) ; <nl> - if ( ret ) <nl> - { <nl> - addObject ( object ) ; <nl> - } <nl> - return ret ; <nl> - } <nl> - <nl> - / * * Initializes an array with some objects * / <nl> - bool Array : : initWithObjects ( Object * object , . . . ) <nl> - { <nl> - CCASSERT ( ! data , " Array cannot be re - initialized " ) ; <nl> - <nl> - bool ret = false ; <nl> - do <nl> - { <nl> - CC_BREAK_IF ( object = = nullptr ) ; <nl> - <nl> - va_list args ; <nl> - va_start ( args , object ) ; <nl> - <nl> - if ( object ) <nl> - { <nl> - this - > addObject ( object ) ; <nl> - Object * i = va_arg ( args , Object * ) ; <nl> - while ( i ) <nl> - { <nl> - this - > addObject ( i ) ; <nl> - i = va_arg ( args , Object * ) ; <nl> - } <nl> - ret = true ; <nl> - } <nl> - va_end ( args ) ; <nl> - <nl> - } while ( false ) ; <nl> - <nl> - return ret ; <nl> - } <nl> - <nl> - bool Array : : initWithCapacity ( int capacity ) <nl> - { <nl> - CCASSERT ( capacity > = 0 & & ! data , " Array cannot be re - initialized " ) ; <nl> - <nl> - data = ccArrayNew ( capacity ) ; <nl> - return true ; <nl> - } <nl> - <nl> - bool Array : : initWithArray ( Array * otherArray ) <nl> - { <nl> - CCASSERT ( ! data , " Array cannot be re - initialized " ) ; <nl> - <nl> - bool ret = false ; <nl> - do <nl> - { <nl> - CC_BREAK_IF ( ! initWithCapacity ( otherArray - > data - > num ) ) ; <nl> - <nl> - addObjectsFromArray ( otherArray ) ; <nl> - ret = true ; <nl> - } while ( 0 ) ; <nl> - <nl> - return ret ; <nl> - } <nl> - <nl> - int Array : : getIndexOfObject ( Object * object ) const <nl> - { <nl> - return ccArrayGetIndexOfObject ( data , object ) ; <nl> - } <nl> - <nl> - Object * Array : : getRandomObject ( ) <nl> - { <nl> - if ( data - > num = = 0 ) <nl> - { <nl> - return nullptr ; <nl> - } <nl> - <nl> - float r = CCRANDOM_0_1 ( ) ; <nl> - <nl> - if ( r = = 1 ) / / to prevent from accessing data - arr [ data - > num ] , out of range . <nl> - { <nl> - r = 0 ; <nl> - } <nl> - <nl> - return data - > arr [ ( int ) ( data - > num * r ) ] ; <nl> - } <nl> - <nl> - bool Array : : containsObject ( Object * object ) const <nl> - { <nl> - return ccArrayContainsObject ( data , object ) ; <nl> - } <nl> - <nl> - bool Array : : isEqualToArray ( Array * otherArray ) <nl> - { <nl> - for ( int i = 0 ; i < this - > count ( ) ; i + + ) <nl> - { <nl> - if ( ! this - > getObjectAtIndex ( i ) - > isEqual ( otherArray - > getObjectAtIndex ( i ) ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - } <nl> - return true ; <nl> - } <nl> - <nl> - void Array : : addObject ( Object * object ) <nl> - { <nl> - CCASSERT ( data , " Array not initialized " ) ; <nl> - ccArrayAppendObjectWithResize ( data , object ) ; <nl> - } <nl> - <nl> - void Array : : addObjectsFromArray ( Array * otherArray ) <nl> - { <nl> - CCASSERT ( data , " Array not initialized " ) ; <nl> - ccArrayAppendArrayWithResize ( data , otherArray - > data ) ; <nl> - } <nl> - <nl> - void Array : : insertObject ( Object * object , int index ) <nl> - { <nl> - CCASSERT ( data , " Array not initialized " ) ; <nl> - ccArrayInsertObjectAtIndex ( data , object , index ) ; <nl> - } <nl> - <nl> - void Array : : setObject ( Object * object , int index ) <nl> - { <nl> - CCASSERT ( index > = 0 & & index < count ( ) , " Invalid index " ) ; <nl> - <nl> - if ( object ! = data - > arr [ index ] ) <nl> - { <nl> - data - > arr [ index ] - > release ( ) ; <nl> - data - > arr [ index ] = object ; <nl> - object - > retain ( ) ; <nl> - } <nl> - } <nl> - <nl> - void Array : : removeLastObject ( bool releaseObj ) <nl> - { <nl> - CCASSERT ( data - > num , " no objects added " ) ; <nl> - ccArrayRemoveObjectAtIndex ( data , data - > num - 1 , releaseObj ) ; <nl> - } <nl> - <nl> - void Array : : removeObject ( Object * object , bool releaseObj / * = true * / ) <nl> - { <nl> - ccArrayRemoveObject ( data , object , releaseObj ) ; <nl> - } <nl> - <nl> - void Array : : removeObjectAtIndex ( int index , bool releaseObj ) <nl> - { <nl> - ccArrayRemoveObjectAtIndex ( data , index , releaseObj ) ; <nl> - } <nl> - <nl> - void Array : : removeObjectsInArray ( Array * otherArray ) <nl> - { <nl> - ccArrayRemoveArray ( data , otherArray - > data ) ; <nl> - } <nl> - <nl> - void Array : : removeAllObjects ( ) <nl> - { <nl> - ccArrayRemoveAllObjects ( data ) ; <nl> - } <nl> - <nl> - void Array : : fastRemoveObjectAtIndex ( int index ) <nl> - { <nl> - ccArrayFastRemoveObjectAtIndex ( data , index ) ; <nl> - } <nl> - <nl> - void Array : : fastRemoveObject ( Object * object ) <nl> - { <nl> - ccArrayFastRemoveObject ( data , object ) ; <nl> - } <nl> - <nl> - void Array : : exchangeObject ( Object * object1 , Object * object2 ) <nl> - { <nl> - int index1 = ccArrayGetIndexOfObject ( data , object1 ) ; <nl> - if ( index1 = = UINT_MAX ) <nl> - { <nl> - return ; <nl> - } <nl> - <nl> - int index2 = ccArrayGetIndexOfObject ( data , object2 ) ; <nl> - if ( index2 = = UINT_MAX ) <nl> - { <nl> - return ; <nl> - } <nl> - <nl> - ccArraySwapObjectsAtIndexes ( data , index1 , index2 ) ; <nl> - } <nl> - <nl> - void Array : : exchangeObjectAtIndex ( int index1 , int index2 ) <nl> - { <nl> - ccArraySwapObjectsAtIndexes ( data , index1 , index2 ) ; <nl> - } <nl> - <nl> - void Array : : replaceObjectAtIndex ( int index , Object * object , bool releaseObject / * = true * / ) <nl> - { <nl> - ccArrayInsertObjectAtIndex ( data , object , index ) ; <nl> - ccArrayRemoveObjectAtIndex ( data , index + 1 ) ; <nl> - } <nl> - <nl> - void Array : : reverseObjects ( ) <nl> - { <nl> - if ( data - > num > 1 ) <nl> - { <nl> - / / floorf ( ) , since in the case of an even number , the number of swaps stays the same <nl> - int count = ( int ) floorf ( data - > num / 2 . f ) ; <nl> - int maxIndex = data - > num - 1 ; <nl> - <nl> - for ( int i = 0 ; i < count ; i + + ) <nl> - { <nl> - ccArraySwapObjectsAtIndexes ( data , i , maxIndex ) ; <nl> - - - maxIndex ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - void Array : : reduceMemoryFootprint ( ) <nl> - { <nl> - ccArrayShrink ( data ) ; <nl> - } <nl> - <nl> - Array : : ~ Array ( ) <nl> - { <nl> - CCLOGINFO ( " deallocing Array : % p - len : % d " , this , count ( ) ) ; <nl> - <nl> - ccArrayFree ( data ) ; <nl> - } <nl> - <nl> - Array * Array : : clone ( ) const <nl> - { <nl> - Array * ret = new Array ( ) ; <nl> - ret - > autorelease ( ) ; <nl> - ret - > initWithCapacity ( this - > data - > num > 0 ? this - > data - > num : 1 ) ; <nl> - <nl> - Object * obj = nullptr ; <nl> - Object * tmpObj = nullptr ; <nl> - Clonable * clonable = nullptr ; <nl> - CCARRAY_FOREACH ( this , obj ) <nl> - { <nl> - clonable = dynamic_cast < Clonable * > ( obj ) ; <nl> - if ( clonable ) <nl> - { <nl> - tmpObj = dynamic_cast < Object * > ( clonable - > clone ( ) ) ; <nl> - if ( tmpObj ) <nl> - { <nl> - ret - > addObject ( tmpObj ) ; <nl> - } <nl> - } <nl> - else <nl> - { <nl> - CCLOGWARN ( " % s isn ' t clonable . " , typeid ( * obj ) . name ( ) ) ; <nl> - } <nl> - } <nl> - return ret ; <nl> - } <nl> - <nl> - void Array : : acceptVisitor ( DataVisitor & visitor ) <nl> - { <nl> - visitor . visit ( this ) ; <nl> - } <nl> - <nl> - # endif / / uses ccArray <nl> - <nl> - NS_CC_END <nl> deleted file mode 100644 <nl> index 4f5beea50104 . . 000000000000 <nl> mmm a / cocos / platform / cocoa / CCArray . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2010 ForzeField Studios S . L . http : / / forzefield . com <nl> - Copyright ( c ) 2010 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - # ifndef __CCARRAY_H__ <nl> - # define __CCARRAY_H__ <nl> - <nl> - # define CC_USE_ARRAY_VECTOR 0 <nl> - <nl> - # if CC_USE_ARRAY_VECTOR <nl> - # include < vector > <nl> - # include < algorithm > <nl> - # include " cocoa / CCObject . h " <nl> - # include " ccMacros . h " <nl> - # else <nl> - # include " support / data_support / ccCArray . h " <nl> - # endif <nl> - <nl> - <nl> - # if CC_USE_ARRAY_VECTOR <nl> - / * * <nl> - * A reference counting - managed pointer for classes derived from RCBase which can <nl> - * be used as C pointer <nl> - * Original code : http : / / www . codeproject . com / Articles / 64111 / Building - a - Quick - and - Handy - Reference - Counting - Clas <nl> - * License : http : / / www . codeproject . com / info / cpol10 . aspx <nl> - * / <nl> - template < class T > <nl> - class RCPtr <nl> - { <nl> - public : <nl> - / / Construct using a C pointer <nl> - / / e . g . RCPtr < T > x = new T ( ) ; <nl> - RCPtr ( T * ptr = nullptr ) <nl> - : _ptr ( ptr ) <nl> - { <nl> - if ( ptr ! = nullptr ) { ptr - > retain ( ) ; } <nl> - } <nl> - <nl> - / / Copy constructor <nl> - RCPtr ( const RCPtr & ptr ) <nl> - : _ptr ( ptr . _ptr ) <nl> - { <nl> - / / printf ( " Array : copy constructor : % p \ n " , this ) ; <nl> - if ( _ptr ! = NULL ) { _ptr - > retain ( ) ; } <nl> - } <nl> - <nl> - / / Move constructor <nl> - RCPtr ( RCPtr & & ptr ) <nl> - : _ptr ( ptr . _ptr ) <nl> - { <nl> - / / printf ( " Array : Move Constructor : % p \ n " , this ) ; <nl> - ptr . _ptr = nullptr ; <nl> - } <nl> - <nl> - ~ RCPtr ( ) <nl> - { <nl> - / / printf ( " Array : Destructor : % p \ n " , this ) ; <nl> - if ( _ptr ! = nullptr ) { _ptr - > release ( ) ; } <nl> - } <nl> - <nl> - / / Assign a pointer <nl> - / / e . g . x = new T ( ) ; <nl> - RCPtr & operator = ( T * ptr ) <nl> - { <nl> - / / printf ( " Array : operator = T * : % p \ n " , this ) ; <nl> - <nl> - / / The following grab and release operations have to be performed <nl> - / / in that order to handle the case where ptr = = _ptr <nl> - / / ( See comment below by David Garlisch ) <nl> - if ( ptr ! = nullptr ) { ptr - > retain ( ) ; } <nl> - if ( _ptr ! = nullptr ) { _ptr - > release ( ) ; } <nl> - _ptr = ptr ; <nl> - return ( * this ) ; <nl> - } <nl> - <nl> - / / Assign another RCPtr <nl> - RCPtr & operator = ( const RCPtr & ptr ) <nl> - { <nl> - / / printf ( " Array : operator = const & : % p \ n " , this ) ; <nl> - return ( * this ) = ptr . _ptr ; <nl> - } <nl> - <nl> - / / Retrieve actual pointer <nl> - T * get ( ) const <nl> - { <nl> - return _ptr ; <nl> - } <nl> - <nl> - / / Some overloaded operators to facilitate dealing with an RCPtr <nl> - / / as a conventional C pointer . <nl> - / / Without these operators , one can still use the less transparent <nl> - / / get ( ) method to access the pointer . <nl> - T * operator - > ( ) const { return _ptr ; } / / x - > member <nl> - T & operator * ( ) const { return * _ptr ; } / / * x , ( * x ) . member <nl> - explicit operator T * ( ) const { return _ptr ; } / / T * y = x ; <nl> - explicit operator bool ( ) const { return _ptr ! = nullptr ; } / / if ( x ) { / * x is not NULL * / } <nl> - bool operator = = ( const RCPtr & ptr ) { return _ptr = = ptr . _ptr ; } <nl> - bool operator = = ( const T * ptr ) { return _ptr = = ptr ; } <nl> - <nl> - private : <nl> - T * _ptr ; / / Actual pointer <nl> - } ; <nl> - # endif / / CC_USE_ARRAY_VECTOR <nl> - <nl> - <nl> - / * * <nl> - * @ addtogroup data_structures <nl> - * @ { <nl> - * / <nl> - <nl> - / * * @ def CCARRAY_FOREACH <nl> - A convenience macro to iterate over a Array using . It is faster than the " fast enumeration " interface . <nl> - @ since v0 . 99 . 4 <nl> - * / <nl> - <nl> - / * <nl> - In cocos2d - iphone 1 . 0 . 0 , This macro have been update to like this : <nl> - <nl> - # define CCARRAY_FOREACH ( __array__ , __object__ ) \ <nl> - if ( __array__ & & __array__ - > data - > num > 0 ) \ <nl> - for ( id * __arr__ = __array__ - > data - > arr , * end = __array__ - > data - > arr + __array__ - > data - > num - 1 ; \ <nl> - __arr__ < = end & & ( ( __object__ = * __arr__ ) ! = nil | | true ) ; \ <nl> - __arr__ + + ) <nl> - <nl> - I found that it ' s not work in C + + . So it keep what it ' s look like in version 1 . 0 . 0 - rc3 . mmmBy Bin <nl> - * / <nl> - <nl> - # if CC_USE_ARRAY_VECTOR <nl> - # define CCARRAY_FOREACH ( __array__ , __object__ ) \ <nl> - if ( __array__ ) \ <nl> - for ( auto __it__ = ( __array__ ) - > data . begin ( ) ; \ <nl> - __it__ ! = ( __array__ ) - > data . end ( ) & & ( ( __object__ ) = __it__ - > get ( ) ) ! = nullptr ; \ <nl> - + + __it__ ) <nl> - <nl> - <nl> - # define CCARRAY_FOREACH_REVERSE ( __array__ , __object__ ) \ <nl> - if ( __array__ ) \ <nl> - for ( auto __it__ = ( __array__ ) - > data . rbegin ( ) ; \ <nl> - __it__ ! = ( __array__ ) - > data . rend ( ) & & ( ( __object__ ) = __it__ - > get ( ) ) ! = nullptr ; \ <nl> - + + __it__ ) <nl> - <nl> - <nl> - # define CCARRAY_VERIFY_TYPE ( __array__ , __type__ ) void ( 0 ) <nl> - <nl> - # else / / ! CC_USE_ARRAY_VECTOR mmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - <nl> - # define CCARRAY_FOREACH ( __array__ , __object__ ) \ <nl> - if ( ( __array__ ) & & ( __array__ ) - > data - > num > 0 ) \ <nl> - for ( Object * * __arr__ = ( __array__ ) - > data - > arr , * * __end__ = ( __array__ ) - > data - > arr + ( __array__ ) - > data - > num - 1 ; \ <nl> - __arr__ < = __end__ & & ( ( ( __object__ ) = * __arr__ ) ! = NULL / * | | true * / ) ; \ <nl> - __arr__ + + ) <nl> - <nl> - # define CCARRAY_FOREACH_REVERSE ( __array__ , __object__ ) \ <nl> - if ( ( __array__ ) & & ( __array__ ) - > data - > num > 0 ) \ <nl> - for ( Object * * __arr__ = ( __array__ ) - > data - > arr + ( __array__ ) - > data - > num - 1 , * * __end__ = ( __array__ ) - > data - > arr ; \ <nl> - __arr__ > = __end__ & & ( ( ( __object__ ) = * __arr__ ) ! = NULL / * | | true * / ) ; \ <nl> - __arr__ - - ) <nl> - <nl> - # if defined ( COCOS2D_DEBUG ) & & ( COCOS2D_DEBUG > 0 ) <nl> - # define CCARRAY_VERIFY_TYPE ( __array__ , __type__ ) \ <nl> - do { \ <nl> - if ( ( __array__ ) & & ( __array__ ) - > data - > num > 0 ) \ <nl> - for ( Object * * __arr__ = ( __array__ ) - > data - > arr , \ <nl> - * * __end__ = ( __array__ ) - > data - > arr + ( __array__ ) - > data - > num - 1 ; __arr__ < = __end__ ; __arr__ + + ) \ <nl> - CCASSERT ( dynamic_cast < __type__ > ( * __arr__ ) , " element type is wrong ! " ) ; \ <nl> - } while ( false ) <nl> - # else <nl> - # define CCARRAY_VERIFY_TYPE ( __array__ , __type__ ) void ( 0 ) <nl> - # endif <nl> - <nl> - # endif / / ! CC_USE_ARRAY_VECTOR <nl> - <nl> - <nl> - / / Common defines mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - <nl> - # define arrayMakeObjectsPerformSelector ( pArray , func , elementType ) \ <nl> - do { \ <nl> - if ( pArray & & pArray - > count ( ) > 0 ) \ <nl> - { \ <nl> - Object * child ; \ <nl> - CCARRAY_FOREACH ( pArray , child ) \ <nl> - { \ <nl> - elementType pNode = static_cast < elementType > ( child ) ; \ <nl> - if ( pNode ) \ <nl> - { \ <nl> - pNode - > func ( ) ; \ <nl> - } \ <nl> - } \ <nl> - } \ <nl> - } \ <nl> - while ( false ) <nl> - <nl> - # define arrayMakeObjectsPerformSelectorWithObject ( pArray , func , object , elementType ) \ <nl> - do { \ <nl> - if ( pArray & & pArray - > count ( ) > 0 ) \ <nl> - { \ <nl> - Object * child ; \ <nl> - CCARRAY_FOREACH ( pArray , child ) \ <nl> - { \ <nl> - elementType pNode = static_cast < elementType > ( child ) ; \ <nl> - if ( pNode ) \ <nl> - { \ <nl> - pNode - > func ( object ) ; \ <nl> - } \ <nl> - } \ <nl> - } \ <nl> - } \ <nl> - while ( false ) <nl> - <nl> - <nl> - NS_CC_BEGIN <nl> - <nl> - class CC_DLL Array : public Object , public Clonable <nl> - { <nl> - public : <nl> - <nl> - / * * Creates an empty array . Default capacity is 10 <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - static Array * create ( ) ; <nl> - / * * Create an array with objects <nl> - * @ js NA <nl> - * / <nl> - static Array * create ( Object * object , . . . ) CC_REQUIRES_NULL_TERMINATION ; <nl> - / * * Create an array with one object <nl> - * @ js NA <nl> - * / <nl> - static Array * createWithObject ( Object * object ) ; <nl> - / * * Create an array with a default capacity <nl> - * @ js NA <nl> - * / <nl> - static Array * createWithCapacity ( int capacity ) ; <nl> - / * * Create an array with from an existing array <nl> - * @ js NA <nl> - * / <nl> - static Array * createWithArray ( Array * otherArray ) ; <nl> - / * * <nl> - @ brief Generate a Array pointer by file <nl> - @ param pFileName The file name of * . plist file <nl> - @ return The Array pointer generated from the file <nl> - * @ js NA <nl> - * / <nl> - static Array * createWithContentsOfFile ( const char * pFileName ) ; <nl> - <nl> - / * <nl> - @ brief The same meaning as arrayWithContentsOfFile ( ) , but it doesn ' t call autorelease , so the <nl> - invoker should call release ( ) . <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - static Array * createWithContentsOfFileThreadSafe ( const char * pFileName ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - ~ Array ( ) ; <nl> - <nl> - / * * Initializes an array <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - bool init ( ) ; <nl> - / * * Initializes an array with one object <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - bool initWithObject ( Object * object ) ; <nl> - / * * Initializes an array with some objects <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - bool initWithObjects ( Object * object , . . . ) CC_REQUIRES_NULL_TERMINATION ; <nl> - / * * Initializes an array with capacity <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - bool initWithCapacity ( int capacity ) ; <nl> - / * * Initializes an array with an existing array <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - bool initWithArray ( Array * otherArray ) ; <nl> - <nl> - / / Querying an Array <nl> - <nl> - / * * Returns element count of the array <nl> - * @ js NA <nl> - * / <nl> - int count ( ) const <nl> - { <nl> - # if CC_USE_ARRAY_VECTOR <nl> - return data . size ( ) ; <nl> - # else <nl> - return data - > num ; <nl> - # endif <nl> - } <nl> - / * * Returns capacity of the array <nl> - * @ js NA <nl> - * / <nl> - int capacity ( ) const <nl> - { <nl> - # if CC_USE_ARRAY_VECTOR <nl> - return data . capacity ( ) ; <nl> - # else <nl> - return data - > max ; <nl> - # endif <nl> - } <nl> - / * * Returns index of a certain object , return UINT_MAX if doesn ' t contain the object <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - int getIndexOfObject ( Object * object ) const ; <nl> - / * * <nl> - * @ js NA <nl> - * / <nl> - CC_DEPRECATED_ATTRIBUTE int indexOfObject ( Object * object ) const { return getIndexOfObject ( object ) ; } <nl> - <nl> - / * * Returns an element with a certain index <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - Object * getObjectAtIndex ( int index ) <nl> - { <nl> - CCASSERT ( index > = 0 & & index < count ( ) , " index out of range in getObjectAtIndex ( ) " ) ; <nl> - # if CC_USE_ARRAY_VECTOR <nl> - return data [ index ] . get ( ) ; <nl> - # else <nl> - return data - > arr [ index ] ; <nl> - # endif <nl> - } <nl> - CC_DEPRECATED_ATTRIBUTE Object * objectAtIndex ( int index ) { return getObjectAtIndex ( index ) ; } <nl> - / * * Returns the last element of the array <nl> - * @ js NA <nl> - * / <nl> - Object * getLastObject ( ) <nl> - { <nl> - # if CC_USE_ARRAY_VECTOR <nl> - return data . back ( ) . get ( ) ; <nl> - # else <nl> - if ( data - > num > 0 ) <nl> - return data - > arr [ data - > num - 1 ] ; <nl> - <nl> - return nullptr ; <nl> - # endif <nl> - } <nl> - / * * <nl> - * @ js NA <nl> - * / <nl> - CC_DEPRECATED_ATTRIBUTE Object * lastObject ( ) { return getLastObject ( ) ; } <nl> - / * * Returns a random element <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - Object * getRandomObject ( ) ; <nl> - / * * <nl> - * @ js NA <nl> - * / <nl> - CC_DEPRECATED_ATTRIBUTE Object * randomObject ( ) { return getRandomObject ( ) ; } <nl> - / * * Returns a Boolean value that indicates whether object is present in array . <nl> - * @ js NA <nl> - * / <nl> - bool containsObject ( Object * object ) const ; <nl> - / * * @ since 1 . 1 <nl> - * @ js NA <nl> - * / <nl> - bool isEqualToArray ( Array * otherArray ) ; <nl> - / / Adding Objects <nl> - <nl> - / * * Add a certain object <nl> - * @ js NA <nl> - * / <nl> - void addObject ( Object * object ) ; <nl> - / * * <nl> - * @ js NA <nl> - * / <nl> - / * * Add all elements of an existing array <nl> - * @ js NA <nl> - * / <nl> - void addObjectsFromArray ( Array * otherArray ) ; <nl> - / * * Insert a certain object at a certain index <nl> - * @ js NA <nl> - * / <nl> - void insertObject ( Object * object , int index ) ; <nl> - / * * sets a certain object at a certain index <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - void setObject ( Object * object , int index ) ; <nl> - / * * sets a certain object at a certain index without retaining . Use it with caution <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - void fastSetObject ( Object * object , int index ) <nl> - { <nl> - # if CC_USE_ARRAY_VECTOR <nl> - setObject ( object , index ) ; <nl> - # else <nl> - / / no retain <nl> - data - > arr [ index ] = object ; <nl> - # endif <nl> - } <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - void swap ( int indexOne , int indexTwo ) <nl> - { <nl> - CCASSERT ( indexOne > = 0 & & indexOne < count ( ) & & indexTwo > = 0 & & indexTwo < count ( ) , " Invalid indices " ) ; <nl> - # if CC_USE_ARRAY_VECTOR <nl> - std : : swap ( data [ indexOne ] , data [ indexTwo ] ) ; <nl> - # else <nl> - std : : swap ( data - > arr [ indexOne ] , data - > arr [ indexTwo ] ) ; <nl> - # endif <nl> - } <nl> - <nl> - / / Removing Objects <nl> - <nl> - / * * Remove last object <nl> - * @ js NA <nl> - * / <nl> - void removeLastObject ( bool releaseObj = true ) ; <nl> - / * * Remove a certain object <nl> - * @ js NA <nl> - * / <nl> - void removeObject ( Object * object , bool releaseObj = true ) ; <nl> - / * * Remove an element with a certain index <nl> - * @ js NA <nl> - * / <nl> - void removeObjectAtIndex ( int index , bool releaseObj = true ) ; <nl> - / * * Remove all elements <nl> - * @ js NA <nl> - * / <nl> - void removeObjectsInArray ( Array * otherArray ) ; <nl> - / * * Remove all objects <nl> - * @ js NA <nl> - * / <nl> - void removeAllObjects ( ) ; <nl> - / * * Fast way to remove a certain object <nl> - * @ js NA <nl> - * / <nl> - void fastRemoveObject ( Object * object ) ; <nl> - / * * Fast way to remove an element with a certain index <nl> - * @ js NA <nl> - * / <nl> - void fastRemoveObjectAtIndex ( int index ) ; <nl> - <nl> - / / Rearranging Content <nl> - <nl> - / * * Swap two elements <nl> - * @ js NA <nl> - * / <nl> - void exchangeObject ( Object * object1 , Object * object2 ) ; <nl> - / * * Swap two elements with certain indexes <nl> - * @ js NA <nl> - * / <nl> - void exchangeObjectAtIndex ( int index1 , int index2 ) ; <nl> - <nl> - / * * Replace object at index with another object . <nl> - * @ js NA <nl> - * / <nl> - void replaceObjectAtIndex ( int index , Object * object , bool releaseObject = true ) ; <nl> - <nl> - / * * Revers the array <nl> - * @ js NA <nl> - * / <nl> - void reverseObjects ( ) ; <nl> - / * Shrinks the array so the memory footprint corresponds with the number of items <nl> - * @ js NA <nl> - * / <nl> - void reduceMemoryFootprint ( ) ; <nl> - <nl> - / * override functions <nl> - * @ js NA <nl> - * / <nl> - virtual void acceptVisitor ( DataVisitor & visitor ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - virtual Array * clone ( ) const ; <nl> - <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> - / / Iterators <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> - # if CC_USE_ARRAY_VECTOR <nl> - typedef std : : vector < RCPtr < Object > > : : iterator iterator ; <nl> - typedef std : : vector < RCPtr < Object > > : : const_iterator const_iterator ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - iterator begin ( ) { return data . begin ( ) ; } <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - iterator end ( ) { return data . end ( ) ; } <nl> - const_iterator cbegin ( ) { return data . cbegin ( ) ; } <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - const_iterator cend ( ) { return data . cend ( ) ; } <nl> - <nl> - std : : vector < RCPtr < Object > > data ; <nl> - <nl> - # else <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - Object * * begin ( ) { return & data - > arr [ 0 ] ; } <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - Object * * end ( ) { return & data - > arr [ data - > num ] ; } <nl> - <nl> - ccArray * data ; <nl> - <nl> - # endif <nl> - <nl> - / / protected : <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - Array ( ) ; <nl> - } ; <nl> - <nl> - / / end of data_structure group <nl> - / / / @ } <nl> - <nl> - NS_CC_END <nl> - <nl> - # endif / / __CCARRAY_H__ <nl> deleted file mode 100644 <nl> index 89a3528f733b . . 000000000000 <nl> mmm a / cocos / platform / cocoa / CCAutoreleasePool . cpp <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2010 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - # include " CCAutoreleasePool . h " <nl> - # include " ccMacros . h " <nl> - <nl> - NS_CC_BEGIN <nl> - <nl> - static PoolManager * s_pPoolManager = NULL ; <nl> - <nl> - AutoreleasePool : : AutoreleasePool ( ) <nl> - { <nl> - _managedObjectArray = new Array ( ) ; <nl> - _managedObjectArray - > initWithCapacity ( 150 ) ; <nl> - } <nl> - <nl> - AutoreleasePool : : ~ AutoreleasePool ( ) <nl> - { <nl> - CCLOGINFO ( " deallocing AutoreleasePool : % p " , this ) ; <nl> - CC_SAFE_DELETE ( _managedObjectArray ) ; <nl> - } <nl> - <nl> - void AutoreleasePool : : addObject ( Object * object ) <nl> - { <nl> - _managedObjectArray - > addObject ( object ) ; <nl> - <nl> - CCASSERT ( object - > _reference > 1 , " reference count should be greater than 1 " ) ; <nl> - + + ( object - > _autoReleaseCount ) ; <nl> - object - > release ( ) ; / / no ref count , in this case autorelease pool added . <nl> - } <nl> - <nl> - void AutoreleasePool : : removeObject ( Object * object ) <nl> - { <nl> - for ( unsigned int i = 0 ; i < object - > _autoReleaseCount ; + + i ) <nl> - { <nl> - _managedObjectArray - > removeObject ( object , false ) ; <nl> - } <nl> - } <nl> - <nl> - void AutoreleasePool : : clear ( ) <nl> - { <nl> - if ( _managedObjectArray - > count ( ) > 0 ) <nl> - { <nl> - / / CCAutoreleasePool * pReleasePool ; <nl> - # ifdef _DEBUG <nl> - int nIndex = _managedObjectArray - > count ( ) - 1 ; <nl> - # endif <nl> - <nl> - Object * pObj = NULL ; <nl> - CCARRAY_FOREACH_REVERSE ( _managedObjectArray , pObj ) <nl> - { <nl> - if ( ! pObj ) <nl> - break ; <nl> - <nl> - - - ( pObj - > _autoReleaseCount ) ; <nl> - / / ( * it ) - > release ( ) ; <nl> - / / delete ( * it ) ; <nl> - # ifdef _DEBUG <nl> - nIndex - - ; <nl> - # endif <nl> - } <nl> - <nl> - _managedObjectArray - > removeAllObjects ( ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - / / <nl> - / / PoolManager <nl> - / / <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - <nl> - PoolManager * PoolManager : : sharedPoolManager ( ) <nl> - { <nl> - if ( s_pPoolManager = = NULL ) <nl> - { <nl> - s_pPoolManager = new PoolManager ( ) ; <nl> - } <nl> - return s_pPoolManager ; <nl> - } <nl> - <nl> - void PoolManager : : purgePoolManager ( ) <nl> - { <nl> - CC_SAFE_DELETE ( s_pPoolManager ) ; <nl> - } <nl> - <nl> - PoolManager : : PoolManager ( ) <nl> - { <nl> - _releasePoolStack = new Array ( ) ; <nl> - _releasePoolStack - > initWithCapacity ( 150 ) ; <nl> - _curReleasePool = 0 ; <nl> - } <nl> - <nl> - PoolManager : : ~ PoolManager ( ) <nl> - { <nl> - CCLOGINFO ( " deallocing PoolManager : % p " , this ) ; <nl> - finalize ( ) ; <nl> - <nl> - / / we only release the last autorelease pool here <nl> - _curReleasePool = 0 ; <nl> - _releasePoolStack - > removeObjectAtIndex ( 0 ) ; <nl> - <nl> - CC_SAFE_DELETE ( _releasePoolStack ) ; <nl> - } <nl> - <nl> - void PoolManager : : finalize ( ) <nl> - { <nl> - if ( _releasePoolStack - > count ( ) > 0 ) <nl> - { <nl> - / / CCAutoreleasePool * pReleasePool ; <nl> - Object * pObj = NULL ; <nl> - CCARRAY_FOREACH ( _releasePoolStack , pObj ) <nl> - { <nl> - if ( ! pObj ) <nl> - break ; <nl> - AutoreleasePool * pPool = static_cast < AutoreleasePool * > ( pObj ) ; <nl> - pPool - > clear ( ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - void PoolManager : : push ( ) <nl> - { <nl> - AutoreleasePool * pPool = new AutoreleasePool ( ) ; / / ref = 1 <nl> - _curReleasePool = pPool ; <nl> - <nl> - _releasePoolStack - > addObject ( pPool ) ; / / ref = 2 <nl> - <nl> - pPool - > release ( ) ; / / ref = 1 <nl> - } <nl> - <nl> - void PoolManager : : pop ( ) <nl> - { <nl> - if ( ! _curReleasePool ) <nl> - { <nl> - return ; <nl> - } <nl> - <nl> - int nCount = _releasePoolStack - > count ( ) ; <nl> - <nl> - _curReleasePool - > clear ( ) ; <nl> - <nl> - if ( nCount > 1 ) <nl> - { <nl> - _releasePoolStack - > removeObjectAtIndex ( nCount - 1 ) ; <nl> - <nl> - / / if ( nCount > 1 ) <nl> - / / { <nl> - / / _curReleasePool = _releasePoolStack - > getObjectAtIndex ( nCount - 2 ) ; <nl> - / / return ; <nl> - / / } <nl> - _curReleasePool = ( AutoreleasePool * ) _releasePoolStack - > getObjectAtIndex ( nCount - 2 ) ; <nl> - } <nl> - <nl> - / * _curReleasePool = NULL ; * / <nl> - } <nl> - <nl> - void PoolManager : : removeObject ( Object * object ) <nl> - { <nl> - CCASSERT ( _curReleasePool , " current auto release pool should not be null " ) ; <nl> - <nl> - _curReleasePool - > removeObject ( object ) ; <nl> - } <nl> - <nl> - void PoolManager : : addObject ( Object * object ) <nl> - { <nl> - getCurReleasePool ( ) - > addObject ( object ) ; <nl> - } <nl> - <nl> - <nl> - AutoreleasePool * PoolManager : : getCurReleasePool ( ) <nl> - { <nl> - if ( ! _curReleasePool ) <nl> - { <nl> - push ( ) ; <nl> - } <nl> - <nl> - CCASSERT ( _curReleasePool , " current auto release pool should not be null " ) ; <nl> - <nl> - return _curReleasePool ; <nl> - } <nl> - <nl> - NS_CC_END <nl> deleted file mode 100644 <nl> index e446ceb4025a . . 000000000000 <nl> mmm a / cocos / platform / cocoa / CCAutoreleasePool . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2010 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - # ifndef __AUTORELEASEPOOL_H__ <nl> - # define __AUTORELEASEPOOL_H__ <nl> - <nl> - # include " CCObject . h " <nl> - # include " CCArray . h " <nl> - <nl> - NS_CC_BEGIN <nl> - <nl> - / * * <nl> - * @ addtogroup base_nodes <nl> - * @ { <nl> - * / <nl> - <nl> - class CC_DLL AutoreleasePool : public Object <nl> - { <nl> - / * * <nl> - * The underlying array of object managed by the pool . <nl> - * <nl> - * Although Array retains the object once when an object is added , proper <nl> - * Object : : release ( ) is called outside the array to make sure that the pool <nl> - * does not affect the managed object ' s reference count . So an object can <nl> - * be destructed properly by calling Object : : release ( ) even if the object <nl> - * is in the pool . <nl> - * / <nl> - Array * _managedObjectArray ; <nl> - public : <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - AutoreleasePool ( ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - ~ AutoreleasePool ( ) ; <nl> - <nl> - / * * <nl> - * Add a given object to this pool . <nl> - * <nl> - * The same object may be added several times to the same pool ; When the <nl> - * pool is destructed , the object ' s Object : : release ( ) method will be called <nl> - * for each time it was added . <nl> - * <nl> - * @ param object The object to add to the pool . <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - void addObject ( Object * object ) ; <nl> - <nl> - / * * <nl> - * Remove a given object from this pool . <nl> - * <nl> - * @ param object The object to be removed from the pool . <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - void removeObject ( Object * object ) ; <nl> - <nl> - / * * <nl> - * Clear the autorelease pool . <nl> - * <nl> - * Object : : release ( ) will be called for each time the managed object is <nl> - * added to the pool . <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - void clear ( ) ; <nl> - } ; <nl> - <nl> - class CC_DLL PoolManager <nl> - { <nl> - Array * _releasePoolStack ; <nl> - AutoreleasePool * _curReleasePool ; <nl> - <nl> - AutoreleasePool * getCurReleasePool ( ) ; <nl> - public : <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - static PoolManager * sharedPoolManager ( ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - static void purgePoolManager ( ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - PoolManager ( ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - ~ PoolManager ( ) ; <nl> - <nl> - / * * <nl> - * Clear all the AutoreleasePool on the pool stack . <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - void finalize ( ) ; <nl> - <nl> - / * * <nl> - * Push a new AutoreleasePool to the pool stack . <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - void push ( ) ; <nl> - <nl> - / * * <nl> - * Pop one AutoreleasePool from the pool stack . <nl> - * <nl> - * This method will ensure that there is at least one AutoreleasePool on <nl> - * the stack . <nl> - * <nl> - * The AutoreleasePool being poped is destructed . <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - void pop ( ) ; <nl> - <nl> - / * * <nl> - * Remove a given object from the current autorelease pool . <nl> - * <nl> - * @ param object The object to be removed . <nl> - * <nl> - * @ see AutoreleasePool : : removeObject <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - void removeObject ( Object * object ) ; <nl> - <nl> - / * * <nl> - * Add a given object to the current autorelease pool . <nl> - * <nl> - * @ param object The object to add . <nl> - * <nl> - * @ see AutoreleasePool : : addObject <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - void addObject ( Object * object ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - friend class AutoreleasePool ; <nl> - } ; <nl> - <nl> - / / end of base_nodes group <nl> - / / / @ } <nl> - <nl> - NS_CC_END <nl> - <nl> - # endif / / __AUTORELEASEPOOL_H__ <nl> deleted file mode 100644 <nl> index 32b7b276eec7 . . 000000000000 <nl> mmm a / cocos / platform / cocoa / CCBool . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2010 - 2012 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # ifndef __CCBOOL_H__ <nl> - # define __CCBOOL_H__ <nl> - <nl> - # include " CCObject . h " <nl> - <nl> - NS_CC_BEGIN <nl> - <nl> - / * * <nl> - * @ addtogroup data_structures <nl> - * @ { <nl> - * / <nl> - <nl> - class CC_DLL Bool : public Object , public Clonable <nl> - { <nl> - public : <nl> - Bool ( bool v ) <nl> - : _value ( v ) { } <nl> - bool getValue ( ) const { return _value ; } <nl> - <nl> - static Bool * create ( bool v ) <nl> - { <nl> - Bool * pRet = new Bool ( v ) ; <nl> - if ( pRet ) <nl> - { <nl> - pRet - > autorelease ( ) ; <nl> - } <nl> - return pRet ; <nl> - } <nl> - <nl> - / * override functions * / <nl> - virtual void acceptVisitor ( DataVisitor & visitor ) { visitor . visit ( this ) ; } <nl> - <nl> - Bool * clone ( ) const <nl> - { <nl> - return Bool : : create ( _value ) ; <nl> - } <nl> - private : <nl> - bool _value ; <nl> - } ; <nl> - <nl> - / / end of data_structure group <nl> - / / / @ } <nl> - <nl> - NS_CC_END <nl> - <nl> - # endif / * __CCBOOL_H__ * / <nl> deleted file mode 100644 <nl> index 1c42a12ee59e . . 000000000000 <nl> mmm a / cocos / platform / cocoa / CCData . cpp <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2010 - 2012 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # include < string . h > <nl> - # include " CCData . h " <nl> - # include " platform / CCCommon . h " <nl> - <nl> - NS_CC_BEGIN <nl> - <nl> - Data : : Data ( unsigned char * pBytes , const unsigned long nSize ) <nl> - { <nl> - _size = nSize ; <nl> - _bytes = new unsigned char [ _size ] ; <nl> - memcpy ( _bytes , pBytes , _size ) ; <nl> - } <nl> - <nl> - Data : : Data ( Data * pData ) <nl> - { <nl> - _size = pData - > _size ; <nl> - _bytes = new unsigned char [ _size ] ; <nl> - memcpy ( _bytes , pData - > _bytes , _size ) ; <nl> - } <nl> - <nl> - Data : : ~ Data ( ) <nl> - { <nl> - CCLOGINFO ( " deallocing Data : % p " , this ) ; <nl> - CC_SAFE_DELETE_ARRAY ( _bytes ) ; <nl> - } <nl> - <nl> - unsigned char * Data : : getBytes ( ) const <nl> - { <nl> - return _bytes ; <nl> - } <nl> - <nl> - unsigned long Data : : getSize ( ) const <nl> - { <nl> - return _size ; <nl> - } <nl> - <nl> - NS_CC_END <nl> deleted file mode 100644 <nl> index 889a2d557bbe . . 000000000000 <nl> mmm a / cocos / platform / cocoa / CCData . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2010 - 2012 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # ifndef __CCDATA_H__ <nl> - # define __CCDATA_H__ <nl> - <nl> - # include " platform / CCPlatformMacros . h " <nl> - # include " CCObject . h " <nl> - <nl> - NS_CC_BEGIN <nl> - <nl> - class CC_DLL Data : public Object <nl> - { <nl> - public : <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - Data ( unsigned char * pBytes , const unsigned long nSize ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - Data ( Data * pData ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - ~ Data ( ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - static Data * create ( unsigned char * pBytes , const unsigned long nSize ) <nl> - { <nl> - Data * pRet = new Data ( pBytes , nSize ) ; <nl> - if ( pRet ) <nl> - { <nl> - pRet - > autorelease ( ) ; <nl> - } <nl> - return pRet ; <nl> - } <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - unsigned char * getBytes ( ) const ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - unsigned long getSize ( ) const ; <nl> - <nl> - / * * override functions <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - virtual void acceptVisitor ( DataVisitor & visitor ) { visitor . visit ( this ) ; } <nl> - <nl> - private : <nl> - unsigned char * _bytes ; <nl> - unsigned long _size ; <nl> - } ; <nl> - <nl> - NS_CC_END <nl> - <nl> - # endif / / __CCDATA_H__ <nl> deleted file mode 100644 <nl> index 2d2a1f812123 . . 000000000000 <nl> mmm a / cocos / platform / cocoa / CCDataVisitor . cpp <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2013 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # include " CCObject . h " <nl> - # include " CCBool . h " <nl> - # include " CCInteger . h " <nl> - # include " CCFloat . h " <nl> - # include " CCDouble . h " <nl> - # include " CCString . h " <nl> - # include " CCArray . h " <nl> - # include " CCDictionary . h " <nl> - # include " CCSet . h " <nl> - # include " CCData . h " <nl> - <nl> - NS_CC_BEGIN <nl> - <nl> - void DataVisitor : : visit ( const Bool * value ) <nl> - { <nl> - visitObject ( value ) ; <nl> - } <nl> - <nl> - void DataVisitor : : visit ( const Integer * value ) <nl> - { <nl> - visitObject ( value ) ; <nl> - } <nl> - <nl> - void DataVisitor : : visit ( const Float * value ) <nl> - { <nl> - visitObject ( value ) ; <nl> - } <nl> - <nl> - void DataVisitor : : visit ( const Double * value ) <nl> - { <nl> - visitObject ( value ) ; <nl> - } <nl> - <nl> - void DataVisitor : : visit ( const String * value ) <nl> - { <nl> - visitObject ( value ) ; <nl> - } <nl> - <nl> - void DataVisitor : : visit ( const Array * value ) <nl> - { <nl> - visitObject ( value ) ; <nl> - } <nl> - <nl> - void DataVisitor : : visit ( const Dictionary * value ) <nl> - { <nl> - visitObject ( value ) ; <nl> - } <nl> - <nl> - void DataVisitor : : visit ( const Set * value ) <nl> - { <nl> - visitObject ( value ) ; <nl> - } <nl> - <nl> - void DataVisitor : : visit ( const Data * value ) <nl> - { <nl> - visitObject ( value ) ; <nl> - } <nl> - <nl> - / / PrettyPrinter <nl> - PrettyPrinter : : PrettyPrinter ( int indentLevel / * = 0 * / ) <nl> - { <nl> - setIndentLevel ( indentLevel ) ; <nl> - } <nl> - <nl> - void PrettyPrinter : : clear ( ) <nl> - { <nl> - _result . clear ( ) ; <nl> - } <nl> - <nl> - std : : string PrettyPrinter : : getResult ( ) <nl> - { <nl> - return _result ; <nl> - } <nl> - <nl> - void PrettyPrinter : : visitObject ( const Object * p ) <nl> - { <nl> - char buf [ 50 ] = { 0 } ; <nl> - sprintf ( buf , " % p " , p ) ; <nl> - _result + = buf ; <nl> - } <nl> - <nl> - void PrettyPrinter : : visit ( const Bool * p ) <nl> - { <nl> - char buf [ 50 ] = { 0 } ; <nl> - sprintf ( buf , " % s " , p - > getValue ( ) ? " true " : " false " ) ; <nl> - _result + = buf ; <nl> - } <nl> - <nl> - void PrettyPrinter : : visit ( const Integer * p ) <nl> - { <nl> - char buf [ 50 ] = { 0 } ; <nl> - sprintf ( buf , " % d " , p - > getValue ( ) ) ; <nl> - _result + = buf ; <nl> - } <nl> - <nl> - void PrettyPrinter : : visit ( const Float * p ) <nl> - { <nl> - char buf [ 50 ] = { 0 } ; <nl> - sprintf ( buf , " % f " , p - > getValue ( ) ) ; <nl> - _result + = buf ; <nl> - } <nl> - <nl> - void PrettyPrinter : : visit ( const Double * p ) <nl> - { <nl> - char buf [ 50 ] = { 0 } ; <nl> - sprintf ( buf , " % lf " , p - > getValue ( ) ) ; <nl> - _result + = buf ; <nl> - } <nl> - <nl> - void PrettyPrinter : : visit ( const String * p ) <nl> - { <nl> - _result + = p - > getCString ( ) ; <nl> - } <nl> - <nl> - void PrettyPrinter : : visit ( const Array * p ) <nl> - { <nl> - _result + = " \ n " ; <nl> - _result + = _indentStr ; <nl> - _result + = " < array > \ n " ; <nl> - <nl> - setIndentLevel ( _indentLevel + 1 ) ; <nl> - Object * obj ; <nl> - int i = 0 ; <nl> - char buf [ 50 ] = { 0 } ; <nl> - CCARRAY_FOREACH ( p , obj ) <nl> - { <nl> - if ( i > 0 ) { <nl> - _result + = " \ n " ; <nl> - } <nl> - sprintf ( buf , " % s % 02d : " , _indentStr . c_str ( ) , i ) ; <nl> - _result + = buf ; <nl> - PrettyPrinter v ( _indentLevel ) ; <nl> - obj - > acceptVisitor ( v ) ; <nl> - _result + = v . getResult ( ) ; <nl> - i + + ; <nl> - } <nl> - setIndentLevel ( _indentLevel - 1 ) ; <nl> - <nl> - _result + = " \ n " ; <nl> - _result + = _indentStr ; <nl> - _result + = " < / array > " ; <nl> - } <nl> - <nl> - void PrettyPrinter : : visit ( const Dictionary * p ) <nl> - { <nl> - _result + = " \ n " ; <nl> - _result + = _indentStr ; <nl> - _result + = " < dict > \ n " ; <nl> - <nl> - setIndentLevel ( _indentLevel + 1 ) ; <nl> - DictElement * element ; <nl> - bool bFirstElement = true ; <nl> - char buf [ 1000 ] = { 0 } ; <nl> - CCDICT_FOREACH ( p , element ) <nl> - { <nl> - if ( ! bFirstElement ) { <nl> - _result + = " \ n " ; <nl> - } <nl> - sprintf ( buf , " % s % s : " , _indentStr . c_str ( ) , element - > getStrKey ( ) ) ; <nl> - _result + = buf ; <nl> - PrettyPrinter v ( _indentLevel ) ; <nl> - element - > getObject ( ) - > acceptVisitor ( v ) ; <nl> - _result + = v . getResult ( ) ; <nl> - bFirstElement = false ; <nl> - } <nl> - setIndentLevel ( _indentLevel - 1 ) ; <nl> - <nl> - _result + = " \ n " ; <nl> - _result + = _indentStr ; <nl> - _result + = " < / dict > " ; <nl> - } <nl> - <nl> - void PrettyPrinter : : visit ( const Set * p ) <nl> - { <nl> - _result + = " \ n " ; <nl> - _result + = _indentStr ; <nl> - _result + = " < set > \ n " ; <nl> - <nl> - setIndentLevel ( _indentLevel + 1 ) ; <nl> - <nl> - int i = 0 ; <nl> - Set * tmp = const_cast < Set * > ( p ) ; <nl> - SetIterator it = tmp - > begin ( ) ; <nl> - <nl> - for ( ; it ! = tmp - > end ( ) ; + + it , + + i ) { <nl> - if ( i > 0 ) { <nl> - _result + = " \ n " ; <nl> - } <nl> - _result + = _indentStr . c_str ( ) ; <nl> - PrettyPrinter v ( _indentLevel ) ; <nl> - ( * it ) - > acceptVisitor ( v ) ; <nl> - _result + = v . getResult ( ) ; <nl> - } <nl> - setIndentLevel ( _indentLevel - 1 ) ; <nl> - <nl> - _result + = " \ n " ; <nl> - _result + = _indentStr ; <nl> - _result + = " < / set > \ n " ; <nl> - } <nl> - <nl> - void PrettyPrinter : : visit ( const Data * p ) <nl> - { <nl> - / / TODO Implement <nl> - DataVisitor : : visit ( p ) ; <nl> - } <nl> - <nl> - void PrettyPrinter : : setIndentLevel ( int indentLevel ) <nl> - { <nl> - _indentLevel = indentLevel ; <nl> - _indentStr . clear ( ) ; <nl> - for ( int i = 0 ; i < _indentLevel ; + + i ) { <nl> - _indentStr + = " \ t " ; <nl> - } <nl> - } <nl> - <nl> - NS_CC_END <nl> deleted file mode 100644 <nl> index 3395b43dea86 . . 000000000000 <nl> mmm a / cocos / platform / cocoa / CCDataVisitor . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2013 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # ifndef __CCDATAVISITOR_H__ <nl> - # define __CCDATAVISITOR_H__ <nl> - <nl> - # include " platform / CCPlatformMacros . h " <nl> - # include < string > <nl> - <nl> - NS_CC_BEGIN <nl> - <nl> - class Object ; <nl> - class Bool ; <nl> - class Integer ; <nl> - class Float ; <nl> - class Double ; <nl> - class String ; <nl> - class Array ; <nl> - class Dictionary ; <nl> - class Set ; <nl> - class Data ; <nl> - <nl> - / * * <nl> - * @ addtogroup data_structures <nl> - * @ { <nl> - * / <nl> - <nl> - / * * <nl> - * Visitor that helps to perform action that depends on polymorphic object type <nl> - * <nl> - * Use cases : <nl> - * - data serialization , <nl> - * - pretty printing of Object * <nl> - * - safe value reading from Array , Dictionary , Set <nl> - * <nl> - * Usage : <nl> - * 1 . subclass DataVisitor <nl> - * 2 . overload visit ( ) methods for object that you need to handle <nl> - * 3 . handle other objects in visitObject ( ) <nl> - * 4 . pass your visitor to Object : : acceptVisitor ( ) <nl> - * / <nl> - class CC_DLL DataVisitor <nl> - { <nl> - public : <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - virtual ~ DataVisitor ( ) { } <nl> - <nl> - / * * default method , called from non - overloaded methods and for unrecognized objects * / <nl> - virtual void visitObject ( const Object * p ) = 0 ; <nl> - <nl> - virtual void visit ( const Bool * p ) ; <nl> - virtual void visit ( const Integer * p ) ; <nl> - virtual void visit ( const Float * p ) ; <nl> - virtual void visit ( const Double * p ) ; <nl> - virtual void visit ( const String * p ) ; <nl> - virtual void visit ( const Array * p ) ; <nl> - virtual void visit ( const Dictionary * p ) ; <nl> - virtual void visit ( const Set * p ) ; <nl> - virtual void visit ( const Data * p ) ; <nl> - } ; <nl> - <nl> - <nl> - class CC_DLL PrettyPrinter : public DataVisitor <nl> - { <nl> - public : <nl> - PrettyPrinter ( int indentLevel = 0 ) ; <nl> - <nl> - virtual void clear ( ) ; <nl> - virtual std : : string getResult ( ) ; <nl> - <nl> - virtual void visitObject ( const Object * p ) ; <nl> - virtual void visit ( const Bool * p ) ; <nl> - virtual void visit ( const Integer * p ) ; <nl> - virtual void visit ( const Float * p ) ; <nl> - virtual void visit ( const Double * p ) ; <nl> - virtual void visit ( const String * p ) ; <nl> - virtual void visit ( const Array * p ) ; <nl> - virtual void visit ( const Dictionary * p ) ; <nl> - virtual void visit ( const Set * p ) ; <nl> - virtual void visit ( const Data * p ) ; <nl> - private : <nl> - void setIndentLevel ( int indentLevel ) ; <nl> - int _indentLevel ; <nl> - std : : string _indentStr ; <nl> - std : : string _result ; <nl> - } ; <nl> - <nl> - / / end of data_structure group <nl> - / / / @ } <nl> - <nl> - NS_CC_END <nl> - <nl> - # endif / / __CCDATAVISITOR_H__ <nl> deleted file mode 100644 <nl> index 6b8df0febfdb . . 000000000000 <nl> mmm a / cocos / platform / cocoa / CCDictionary . cpp <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2012 - 2013 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # include " CCDictionary . h " <nl> - # include " CCString . h " <nl> - # include " CCInteger . h " <nl> - # include " platform / CCFileUtils . h " <nl> - <nl> - using namespace std ; <nl> - <nl> - NS_CC_BEGIN <nl> - <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - / / DictElement <nl> - <nl> - DictElement : : DictElement ( const char * pszKey , Object * pObject ) <nl> - { <nl> - CCASSERT ( pszKey & & strlen ( pszKey ) > 0 , " Invalid key value . " ) ; <nl> - _intKey = 0 ; <nl> - const char * pStart = pszKey ; <nl> - <nl> - size_t len = strlen ( pszKey ) ; <nl> - if ( len > MAX_KEY_LEN ) <nl> - { <nl> - char * pEnd = ( char * ) & pszKey [ len - 1 ] ; <nl> - pStart = pEnd - ( MAX_KEY_LEN - 1 ) ; <nl> - } <nl> - <nl> - strcpy ( _strKey , pStart ) ; <nl> - <nl> - _object = pObject ; <nl> - memset ( & hh , 0 , sizeof ( hh ) ) ; <nl> - } <nl> - <nl> - DictElement : : DictElement ( intptr_t iKey , Object * pObject ) <nl> - { <nl> - _strKey [ 0 ] = ' \ 0 ' ; <nl> - _intKey = iKey ; <nl> - _object = pObject ; <nl> - memset ( & hh , 0 , sizeof ( hh ) ) ; <nl> - } <nl> - <nl> - DictElement : : ~ DictElement ( ) <nl> - { <nl> - CCLOGINFO ( " deallocing DictElement : % p " , this ) ; <nl> - } <nl> - <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - / / Dictionary <nl> - <nl> - Dictionary : : Dictionary ( ) <nl> - : _elements ( NULL ) <nl> - , _dictType ( kDictUnknown ) <nl> - { <nl> - <nl> - } <nl> - <nl> - Dictionary : : ~ Dictionary ( ) <nl> - { <nl> - CCLOGINFO ( " deallocing Dictionary : % p " , this ) ; <nl> - removeAllObjects ( ) ; <nl> - } <nl> - <nl> - unsigned int Dictionary : : count ( ) <nl> - { <nl> - return HASH_COUNT ( _elements ) ; <nl> - } <nl> - <nl> - Array * Dictionary : : allKeys ( ) <nl> - { <nl> - int iKeyCount = this - > count ( ) ; <nl> - if ( iKeyCount < = 0 ) return NULL ; <nl> - <nl> - Array * pArray = Array : : createWithCapacity ( iKeyCount ) ; <nl> - <nl> - DictElement * pElement , * tmp ; <nl> - if ( _dictType = = kDictStr ) <nl> - { <nl> - HASH_ITER ( hh , _elements , pElement , tmp ) <nl> - { <nl> - String * pOneKey = new String ( pElement - > _strKey ) ; <nl> - pArray - > addObject ( pOneKey ) ; <nl> - CC_SAFE_RELEASE ( pOneKey ) ; <nl> - } <nl> - } <nl> - else if ( _dictType = = kDictInt ) <nl> - { <nl> - HASH_ITER ( hh , _elements , pElement , tmp ) <nl> - { <nl> - Integer * pOneKey = new Integer ( pElement - > _intKey ) ; <nl> - pArray - > addObject ( pOneKey ) ; <nl> - CC_SAFE_RELEASE ( pOneKey ) ; <nl> - } <nl> - } <nl> - <nl> - return pArray ; <nl> - } <nl> - <nl> - Array * Dictionary : : allKeysForObject ( Object * object ) <nl> - { <nl> - int iKeyCount = this - > count ( ) ; <nl> - if ( iKeyCount < = 0 ) return NULL ; <nl> - Array * pArray = Array : : create ( ) ; <nl> - <nl> - DictElement * pElement , * tmp ; <nl> - <nl> - if ( _dictType = = kDictStr ) <nl> - { <nl> - HASH_ITER ( hh , _elements , pElement , tmp ) <nl> - { <nl> - if ( object = = pElement - > _object ) <nl> - { <nl> - String * pOneKey = new String ( pElement - > _strKey ) ; <nl> - pArray - > addObject ( pOneKey ) ; <nl> - CC_SAFE_RELEASE ( pOneKey ) ; <nl> - } <nl> - } <nl> - } <nl> - else if ( _dictType = = kDictInt ) <nl> - { <nl> - HASH_ITER ( hh , _elements , pElement , tmp ) <nl> - { <nl> - if ( object = = pElement - > _object ) <nl> - { <nl> - Integer * pOneKey = new Integer ( pElement - > _intKey ) ; <nl> - pArray - > addObject ( pOneKey ) ; <nl> - CC_SAFE_RELEASE ( pOneKey ) ; <nl> - } <nl> - } <nl> - } <nl> - return pArray ; <nl> - } <nl> - <nl> - Object * Dictionary : : objectForKey ( const std : : string & key ) <nl> - { <nl> - / / if dictionary wasn ' t initialized , return NULL directly . <nl> - if ( _dictType = = kDictUnknown ) return NULL ; <nl> - / / Dictionary only supports one kind of key , string or integer . <nl> - / / This method uses string as key , therefore we should make sure that the key type of this Dictionary is string . <nl> - CCASSERT ( _dictType = = kDictStr , " this dictionary does not use string as key . " ) ; <nl> - <nl> - Object * pRetObject = NULL ; <nl> - DictElement * pElement = NULL ; <nl> - HASH_FIND_STR ( _elements , key . c_str ( ) , pElement ) ; <nl> - if ( pElement ! = NULL ) <nl> - { <nl> - pRetObject = pElement - > _object ; <nl> - } <nl> - return pRetObject ; <nl> - } <nl> - <nl> - Object * Dictionary : : objectForKey ( intptr_t key ) <nl> - { <nl> - / / if dictionary wasn ' t initialized , return NULL directly . <nl> - if ( _dictType = = kDictUnknown ) return NULL ; <nl> - / / Dictionary only supports one kind of key , string or integer . <nl> - / / This method uses integer as key , therefore we should make sure that the key type of this Dictionary is integer . <nl> - CCASSERT ( _dictType = = kDictInt , " this dictionary does not use integer as key . " ) ; <nl> - <nl> - Object * pRetObject = NULL ; <nl> - DictElement * pElement = NULL ; <nl> - HASH_FIND_PTR ( _elements , & key , pElement ) ; <nl> - if ( pElement ! = NULL ) <nl> - { <nl> - pRetObject = pElement - > _object ; <nl> - } <nl> - return pRetObject ; <nl> - } <nl> - <nl> - const String * Dictionary : : valueForKey ( const std : : string & key ) <nl> - { <nl> - String * pStr = dynamic_cast < String * > ( objectForKey ( key ) ) ; <nl> - if ( pStr = = NULL ) <nl> - { <nl> - pStr = String : : create ( " " ) ; <nl> - } <nl> - return pStr ; <nl> - } <nl> - <nl> - const String * Dictionary : : valueForKey ( intptr_t key ) <nl> - { <nl> - String * pStr = dynamic_cast < String * > ( objectForKey ( key ) ) ; <nl> - if ( pStr = = NULL ) <nl> - { <nl> - pStr = String : : create ( " " ) ; <nl> - } <nl> - return pStr ; <nl> - } <nl> - <nl> - void Dictionary : : setObject ( Object * pObject , const std : : string & key ) <nl> - { <nl> - CCASSERT ( key . length ( ) > 0 & & pObject ! = NULL , " Invalid Argument ! " ) ; <nl> - if ( _dictType = = kDictUnknown ) <nl> - { <nl> - _dictType = kDictStr ; <nl> - } <nl> - <nl> - CCASSERT ( _dictType = = kDictStr , " this dictionary doesn ' t use string as key . " ) ; <nl> - <nl> - DictElement * pElement = NULL ; <nl> - HASH_FIND_STR ( _elements , key . c_str ( ) , pElement ) ; <nl> - if ( pElement = = NULL ) <nl> - { <nl> - setObjectUnSafe ( pObject , key ) ; <nl> - } <nl> - else if ( pElement - > _object ! = pObject ) <nl> - { <nl> - Object * pTmpObj = pElement - > _object ; <nl> - pTmpObj - > retain ( ) ; <nl> - removeObjectForElememt ( pElement ) ; <nl> - setObjectUnSafe ( pObject , key ) ; <nl> - pTmpObj - > release ( ) ; <nl> - } <nl> - } <nl> - <nl> - void Dictionary : : setObject ( Object * pObject , intptr_t key ) <nl> - { <nl> - CCASSERT ( pObject ! = NULL , " Invalid Argument ! " ) ; <nl> - if ( _dictType = = kDictUnknown ) <nl> - { <nl> - _dictType = kDictInt ; <nl> - } <nl> - <nl> - CCASSERT ( _dictType = = kDictInt , " this dictionary doesn ' t use integer as key . " ) ; <nl> - <nl> - DictElement * pElement = NULL ; <nl> - HASH_FIND_PTR ( _elements , & key , pElement ) ; <nl> - if ( pElement = = NULL ) <nl> - { <nl> - setObjectUnSafe ( pObject , key ) ; <nl> - } <nl> - else if ( pElement - > _object ! = pObject ) <nl> - { <nl> - Object * pTmpObj = pElement - > _object ; <nl> - pTmpObj - > retain ( ) ; <nl> - removeObjectForElememt ( pElement ) ; <nl> - setObjectUnSafe ( pObject , key ) ; <nl> - pTmpObj - > release ( ) ; <nl> - } <nl> - <nl> - } <nl> - <nl> - void Dictionary : : removeObjectForKey ( const std : : string & key ) <nl> - { <nl> - if ( _dictType = = kDictUnknown ) <nl> - { <nl> - return ; <nl> - } <nl> - <nl> - CCASSERT ( _dictType = = kDictStr , " this dictionary doesn ' t use string as its key " ) ; <nl> - CCASSERT ( key . length ( ) > 0 , " Invalid Argument ! " ) ; <nl> - DictElement * pElement = NULL ; <nl> - HASH_FIND_STR ( _elements , key . c_str ( ) , pElement ) ; <nl> - removeObjectForElememt ( pElement ) ; <nl> - } <nl> - <nl> - void Dictionary : : removeObjectForKey ( intptr_t key ) <nl> - { <nl> - if ( _dictType = = kDictUnknown ) <nl> - { <nl> - return ; <nl> - } <nl> - <nl> - CCASSERT ( _dictType = = kDictInt , " this dictionary doesn ' t use integer as its key " ) ; <nl> - DictElement * pElement = NULL ; <nl> - HASH_FIND_PTR ( _elements , & key , pElement ) ; <nl> - removeObjectForElememt ( pElement ) ; <nl> - } <nl> - <nl> - void Dictionary : : setObjectUnSafe ( Object * pObject , const std : : string & key ) <nl> - { <nl> - pObject - > retain ( ) ; <nl> - DictElement * pElement = new DictElement ( key . c_str ( ) , pObject ) ; <nl> - HASH_ADD_STR ( _elements , _strKey , pElement ) ; <nl> - } <nl> - <nl> - void Dictionary : : setObjectUnSafe ( Object * pObject , const intptr_t key ) <nl> - { <nl> - pObject - > retain ( ) ; <nl> - DictElement * pElement = new DictElement ( key , pObject ) ; <nl> - HASH_ADD_PTR ( _elements , _intKey , pElement ) ; <nl> - } <nl> - <nl> - void Dictionary : : removeObjectsForKeys ( Array * pKeyArray ) <nl> - { <nl> - Object * pObj = NULL ; <nl> - CCARRAY_FOREACH ( pKeyArray , pObj ) <nl> - { <nl> - String * pStr = static_cast < String * > ( pObj ) ; <nl> - removeObjectForKey ( pStr - > getCString ( ) ) ; <nl> - } <nl> - } <nl> - <nl> - void Dictionary : : removeObjectForElememt ( DictElement * pElement ) <nl> - { <nl> - if ( pElement ! = NULL ) <nl> - { <nl> - HASH_DEL ( _elements , pElement ) ; <nl> - pElement - > _object - > release ( ) ; <nl> - CC_SAFE_DELETE ( pElement ) ; <nl> - } <nl> - } <nl> - <nl> - void Dictionary : : removeAllObjects ( ) <nl> - { <nl> - DictElement * pElement , * tmp ; <nl> - HASH_ITER ( hh , _elements , pElement , tmp ) <nl> - { <nl> - HASH_DEL ( _elements , pElement ) ; <nl> - pElement - > _object - > release ( ) ; <nl> - CC_SAFE_DELETE ( pElement ) ; <nl> - <nl> - } <nl> - } <nl> - <nl> - Object * Dictionary : : randomObject ( ) <nl> - { <nl> - if ( _dictType = = kDictUnknown ) <nl> - { <nl> - return NULL ; <nl> - } <nl> - <nl> - Object * key = allKeys ( ) - > getRandomObject ( ) ; <nl> - <nl> - if ( _dictType = = kDictInt ) <nl> - { <nl> - return objectForKey ( static_cast < Integer * > ( key ) - > getValue ( ) ) ; <nl> - } <nl> - else if ( _dictType = = kDictStr ) <nl> - { <nl> - return objectForKey ( static_cast < String * > ( key ) - > getCString ( ) ) ; <nl> - } <nl> - else <nl> - { <nl> - return NULL ; <nl> - } <nl> - } <nl> - <nl> - Dictionary * Dictionary : : create ( ) <nl> - { <nl> - Dictionary * ret = new Dictionary ( ) ; <nl> - if ( ret & & ret - > init ( ) ) <nl> - { <nl> - ret - > autorelease ( ) ; <nl> - } <nl> - return ret ; <nl> - } <nl> - <nl> - bool Dictionary : : init ( ) <nl> - { <nl> - return true ; <nl> - } <nl> - <nl> - Dictionary * Dictionary : : createWithDictionary ( Dictionary * srcDict ) <nl> - { <nl> - return srcDict - > clone ( ) ; <nl> - } <nl> - <nl> - Dictionary * Dictionary : : createWithContentsOfFileThreadSafe ( const char * pFileName ) <nl> - { <nl> - return FileUtils : : getInstance ( ) - > createDictionaryWithContentsOfFile ( pFileName ) ; <nl> - } <nl> - <nl> - void Dictionary : : acceptVisitor ( DataVisitor & visitor ) <nl> - { <nl> - return visitor . visit ( this ) ; <nl> - } <nl> - <nl> - Dictionary * Dictionary : : createWithContentsOfFile ( const char * pFileName ) <nl> - { <nl> - auto ret = createWithContentsOfFileThreadSafe ( pFileName ) ; <nl> - if ( ret ! = nullptr ) <nl> - { <nl> - ret - > autorelease ( ) ; <nl> - } <nl> - return ret ; <nl> - } <nl> - <nl> - bool Dictionary : : writeToFile ( const char * fullPath ) <nl> - { <nl> - return FileUtils : : getInstance ( ) - > writeToFile ( this , fullPath ) ; <nl> - } <nl> - <nl> - Dictionary * Dictionary : : clone ( ) const <nl> - { <nl> - Dictionary * newDict = Dictionary : : create ( ) ; <nl> - <nl> - DictElement * element = NULL ; <nl> - Object * tmpObj = NULL ; <nl> - Clonable * obj = NULL ; <nl> - if ( _dictType = = kDictInt ) <nl> - { <nl> - CCDICT_FOREACH ( this , element ) <nl> - { <nl> - obj = dynamic_cast < Clonable * > ( element - > getObject ( ) ) ; <nl> - if ( obj ) <nl> - { <nl> - tmpObj = dynamic_cast < Object * > ( obj - > clone ( ) ) ; <nl> - if ( tmpObj ) <nl> - { <nl> - newDict - > setObject ( tmpObj , element - > getIntKey ( ) ) ; <nl> - } <nl> - } <nl> - else <nl> - { <nl> - CCLOGWARN ( " % s isn ' t clonable . " , typeid ( * element - > getObject ( ) ) . name ( ) ) ; <nl> - } <nl> - } <nl> - } <nl> - else if ( _dictType = = kDictStr ) <nl> - { <nl> - CCDICT_FOREACH ( this , element ) <nl> - { <nl> - obj = dynamic_cast < Clonable * > ( element - > getObject ( ) ) ; <nl> - if ( obj ) <nl> - { <nl> - tmpObj = dynamic_cast < Object * > ( obj - > clone ( ) ) ; <nl> - if ( tmpObj ) <nl> - { <nl> - newDict - > setObject ( tmpObj , element - > getStrKey ( ) ) ; <nl> - } <nl> - } <nl> - else <nl> - { <nl> - CCLOGWARN ( " % s isn ' t clonable . " , typeid ( * element - > getObject ( ) ) . name ( ) ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - return newDict ; <nl> - } <nl> - <nl> - NS_CC_END <nl> deleted file mode 100644 <nl> index b0f1c98a9cc7 . . 000000000000 <nl> mmm a / cocos / platform / cocoa / CCDictionary . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2012 - 2013 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # ifndef __CCDICTIONARY_H__ <nl> - # define __CCDICTIONARY_H__ <nl> - <nl> - # include " support / data_support / uthash . h " <nl> - # include " CCObject . h " <nl> - # include " CCArray . h " <nl> - # include " CCString . h " <nl> - <nl> - NS_CC_BEGIN <nl> - <nl> - class Dictionary ; <nl> - <nl> - / * * <nl> - * @ addtogroup data_structures <nl> - * @ { <nl> - * / <nl> - <nl> - <nl> - / * * <nl> - * DictElement is used for traversing Dictionary . <nl> - * <nl> - * A DictElement is one element of Dictionary , it contains two properties , key and object . <nl> - * Its key has two different type ( integer and string ) . <nl> - * <nl> - * @ note The key type is unique , all the elements in Dictionary has the same key type ( integer or string ) . <nl> - * @ code <nl> - * DictElement * pElement ; <nl> - * CCDICT_FOREACH ( dict , pElement ) <nl> - * { <nl> - * const char * key = pElement - > getStrKey ( ) ; <nl> - * / / You certainly know the type of value , so we assume that it ' s a Sprite . <nl> - * Sprite * pSprite = static_cast < Sprite * > ( pElement - > getObject ( ) ) ; <nl> - * / / . . . . . . <nl> - * } <nl> - * @ endcode <nl> - * <nl> - * / <nl> - class CC_DLL DictElement <nl> - { <nl> - private : <nl> - / * * <nl> - * Constructor of DictElement . It ' s only for internal usage . Dictionary is its friend class . <nl> - * <nl> - * @ param pszKey The string key of this element . <nl> - * @ param pObject The object of this element . <nl> - * / <nl> - DictElement ( const char * pszKey , Object * pObject ) ; <nl> - <nl> - / * * <nl> - * Constructor of DictElement . It ' s only for internal usage . Dictionary is its friend class . <nl> - * <nl> - * @ param iKey The integer key of this element . <nl> - * @ param pObject The object of this element . <nl> - * / <nl> - DictElement ( intptr_t iKey , Object * pObject ) ; <nl> - <nl> - public : <nl> - / * * <nl> - * The destructor of DictElement . <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - ~ DictElement ( ) ; <nl> - <nl> - / / Inline functions need to be implemented in header file on Android . <nl> - <nl> - / * * <nl> - * Get the string key of this element . <nl> - * @ note This method assumes you know the key type in the element . <nl> - * If the element ' s key type is integer , invoking this method will cause an assert . <nl> - * <nl> - * @ return The string key of this element . <nl> - * / <nl> - inline const char * getStrKey ( ) const <nl> - { <nl> - CCASSERT ( _strKey [ 0 ] ! = ' \ 0 ' , " Should not call this function for integer dictionary " ) ; <nl> - return _strKey ; <nl> - } <nl> - <nl> - / * * <nl> - * Get the integer key of this element . <nl> - * @ note This method assumes you know the key type in the element . <nl> - * If the element ' s key type is string , invoking this method will cause an assert . <nl> - * <nl> - * @ return The integer key of this element . <nl> - * / <nl> - inline intptr_t getIntKey ( ) const <nl> - { <nl> - CCASSERT ( _strKey [ 0 ] = = ' \ 0 ' , " Should not call this function for string dictionary " ) ; <nl> - return _intKey ; <nl> - } <nl> - <nl> - / * * <nl> - * Get the object of this element . <nl> - * <nl> - * @ return The object of this element . <nl> - * / <nl> - inline Object * getObject ( ) const { return _object ; } <nl> - <nl> - private : <nl> - / / The max length of string key . <nl> - # define MAX_KEY_LEN 256 <nl> - / / char array is needed for HASH_ADD_STR in UT_HASH . <nl> - / / So it ' s a pain that all elements will allocate 256 bytes for this array . <nl> - char _strKey [ MAX_KEY_LEN ] ; / / hash key of string type <nl> - intptr_t _intKey ; / / hash key of integer type <nl> - Object * _object ; / / hash value <nl> - public : <nl> - UT_hash_handle hh ; / / makes this class hashable <nl> - friend class Dictionary ; / / declare Dictionary as friend class <nl> - } ; <nl> - <nl> - / * * The macro for traversing dictionary <nl> - * <nl> - * @ note It ' s faster than getting all keys and traversing keys to get objects by objectForKey . <nl> - * It ' s also safe to remove elements while traversing . <nl> - * / <nl> - # define CCDICT_FOREACH ( __dict__ , __el__ ) \ <nl> - DictElement * pTmp # # __dict__ # # __el__ = nullptr ; \ <nl> - if ( __dict__ ) \ <nl> - HASH_ITER ( hh , ( __dict__ ) - > _elements , __el__ , pTmp # # __dict__ # # __el__ ) <nl> - <nl> - <nl> - <nl> - / * * <nl> - * Dictionary is a class like NSDictionary in Obj - C . <nl> - * <nl> - * @ note Only the pointer of Object or its subclass can be inserted to Dictionary . <nl> - * @ code <nl> - * / / Create a dictionary , return an autorelease object . <nl> - * Dictionary * pDict = Dictionary : : create ( ) ; <nl> - * <nl> - * / / Insert objects to dictionary <nl> - * String * pValue1 = String : : create ( " 100 " ) ; <nl> - * String * pValue2 = String : : create ( " 120 " ) ; <nl> - * Integer * pValue3 = Integer : : create ( 200 ) ; <nl> - * pDict - > setObject ( pValue1 , " key1 " ) ; <nl> - * pDict - > setObject ( pValue2 , " key2 " ) ; <nl> - * pDict - > setObject ( pValue3 , " key3 " ) ; <nl> - * <nl> - * / / Get the object for key <nl> - * String * pStr1 = ( String * ) pDict - > objectForKey ( " key1 " ) ; <nl> - * log ( " { key1 : % s } " , pStr1 - > getCString ( ) ) ; <nl> - * Integer * pInteger = ( Integer * ) pDict - > objectForKey ( " key3 " ) ; <nl> - * log ( " { key3 : % d } " , pInteger - > getValue ( ) ) ; <nl> - * @ endcode <nl> - * <nl> - * / <nl> - <nl> - class CC_DLL Dictionary : public Object , public Clonable <nl> - { <nl> - public : <nl> - / * * <nl> - * The constructor of Dictionary . <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - Dictionary ( ) ; <nl> - <nl> - / * * <nl> - * The destructor of Dictionary <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - ~ Dictionary ( ) ; <nl> - <nl> - / * * Initializes the dictionary . It returns true if the initializations was successful . <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - bool init ( ) ; <nl> - / * * <nl> - * Get the count of elements in Dictionary . <nl> - * <nl> - * @ return The count of elements . <nl> - * @ js NA <nl> - * / <nl> - unsigned int count ( ) ; <nl> - <nl> - / * * <nl> - * Return all keys of elements . <nl> - * <nl> - * @ return The array contains all keys of elements . It ' s an autorelease object yet . <nl> - * @ js NA <nl> - * / <nl> - Array * allKeys ( ) ; <nl> - <nl> - / * * <nl> - * Get all keys according to the specified object . <nl> - * @ warning We use ' = = ' to compare two objects <nl> - * @ return The array contains all keys for the specified object . It ' s an autorelease object yet . <nl> - * @ js NA <nl> - * / <nl> - Array * allKeysForObject ( Object * object ) ; <nl> - <nl> - / * * <nl> - * Get the object according to the specified string key . <nl> - * <nl> - * @ note The dictionary needs to use string as key . If integer is passed , an assert will appear . <nl> - * @ param key The string key for searching . <nl> - * @ return The object matches the key . You need to force convert it to the type you know . <nl> - * @ code <nl> - * / / Assume that the elements are String * pointers . Convert it by following code . <nl> - * String * pStr = ( String * ) pDict - > objectForKey ( " key1 " ) ; <nl> - * / / Do something about pStr . <nl> - * / / If you don ' t know the object type , properly you need to use dynamic_cast < SomeType * > to check it . <nl> - * String * pStr2 = dynamic_cast < String * > ( pDict - > objectForKey ( " key1 " ) ) ; <nl> - * if ( pStr2 ! = NULL ) { <nl> - * / / Do something about pStr2 <nl> - * } <nl> - * @ endcode <nl> - * @ see objectForKey ( intptr_t ) <nl> - * @ js NA <nl> - * / <nl> - Object * objectForKey ( const std : : string & key ) ; <nl> - <nl> - / * * <nl> - * Get the object according to the specified integer key . <nl> - * <nl> - * @ note The dictionary needs to use integer as key . If string is passed , an assert will appear . <nl> - * @ param key The integer key for searching . <nl> - * @ return The object matches the key . <nl> - * @ see objectForKey ( const std : : string & ) <nl> - * @ js NA <nl> - * / <nl> - Object * objectForKey ( intptr_t key ) ; <nl> - <nl> - / * * Get the value according to the specified string key . <nl> - * <nl> - * @ note Be careful to use this function since it assumes the objects in the dictionary are String pointer . <nl> - * @ param key The string key for searching <nl> - * @ return An instance of String . <nl> - * It will return an empty string if the objects aren ' t String pointer or the key wasn ' t found . <nl> - * @ see valueForKey ( intptr_t ) <nl> - * @ js NA <nl> - * / <nl> - const String * valueForKey ( const std : : string & key ) ; <nl> - <nl> - / * * Get the value according to the specified integer key . <nl> - * <nl> - * @ note Be careful to use this function since it assumes the objects in the dictionary are String pointer . <nl> - * @ param key The string key for searching . <nl> - * @ return An instance of String . <nl> - * It will return an empty string if the objects aren ' t String pointer or the key wasn ' t found . <nl> - * @ see valueForKey ( intptr_t ) <nl> - * @ js NA <nl> - * / <nl> - const String * valueForKey ( intptr_t key ) ; <nl> - <nl> - / * * Insert an object to dictionary , and match it with the specified string key . <nl> - * <nl> - * @ note Whe the first time this method is invoked , the key type will be set to string . <nl> - * After that you can ' t setObject with an integer key . <nl> - * If the dictionary contains the key you passed , the object matching the key will be released and removed from dictionary . <nl> - * Then the new object will be inserted after that . <nl> - * <nl> - * @ param pObject The Object to be inserted . <nl> - * @ param key The string key for searching . <nl> - * @ see setObject ( Object * , intptr_t ) <nl> - * @ js NA <nl> - * / <nl> - void setObject ( Object * pObject , const std : : string & key ) ; <nl> - <nl> - / * * Insert an object to dictionary , and match it with the specified string key . <nl> - * <nl> - * @ note Then the first time this method is invoked , the key type will be set to string . <nl> - * After that you can ' t setObject with an integer key . <nl> - * If the dictionary contains the key you passed , the object matching the key will be released and removed from dictionary . <nl> - * Then the new object will be inserted after that . <nl> - * @ param pObject The Object to be inserted . <nl> - * @ param key The string key for searching . <nl> - * @ see setObject ( Object * , const std : : string & ) <nl> - * @ js NA <nl> - * / <nl> - void setObject ( Object * pObject , intptr_t key ) ; <nl> - <nl> - / * * <nl> - * Remove an object by the specified string key . <nl> - * <nl> - * @ param key The string key for searching . <nl> - * @ see removeObjectForKey ( intptr_t ) , removeObjectsForKeys ( Array * ) , <nl> - * removeObjectForElememt ( DictElement * ) , removeAllObjects ( ) . <nl> - * @ js NA <nl> - * / <nl> - void removeObjectForKey ( const std : : string & key ) ; <nl> - <nl> - / * * <nl> - * Remove an object by the specified integer key . <nl> - * <nl> - * @ param key The integer key for searching . <nl> - * @ see removeObjectForKey ( const std : : string & ) , removeObjectsForKeys ( Array * ) , <nl> - * removeObjectForElememt ( DictElement * ) , removeAllObjects ( ) . <nl> - * @ js NA <nl> - * / <nl> - void removeObjectForKey ( intptr_t key ) ; <nl> - <nl> - / * * <nl> - * Remove objects by an array of keys . <nl> - * <nl> - * @ param pKeyArray The array contains keys to be removed . <nl> - * @ see removeObjectForKey ( const std : : string & ) , removeObjectForKey ( intptr_t ) , <nl> - * removeObjectForElememt ( DictElement * ) , removeAllObjects ( ) . <nl> - * @ js NA <nl> - * / <nl> - void removeObjectsForKeys ( Array * pKeyArray ) ; <nl> - <nl> - / * * <nl> - * Remove an object by an element . <nl> - * <nl> - * @ param pElement The element need to be removed . <nl> - * @ see removeObjectForKey ( const std : : string & ) , removeObjectForKey ( intptr_t ) , <nl> - * removeObjectsForKeys ( Array * ) , removeAllObjects ( ) . <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - void removeObjectForElememt ( DictElement * pElement ) ; <nl> - <nl> - / * * <nl> - * Remove all objects in the dictionary . <nl> - * <nl> - * @ see removeObjectForKey ( const std : : string & ) , removeObjectForKey ( intptr_t ) , <nl> - * removeObjectsForKeys ( Array * ) , removeObjectForElememt ( DictElement * ) . <nl> - * @ js NA <nl> - * / <nl> - void removeAllObjects ( ) ; <nl> - <nl> - / * * <nl> - * Return a random object in the dictionary . <nl> - * <nl> - * @ return The random object . <nl> - * @ see objectForKey ( intptr_t ) , objectForKey ( const std : : string & ) <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - Object * randomObject ( ) ; <nl> - <nl> - / * * <nl> - * Create a dictionary . <nl> - * @ return A dictionary which is an autorelease object . <nl> - * @ see createWithDictionary ( Dictionary * ) , createWithContentsOfFile ( const char * ) , createWithContentsOfFileThreadSafe ( const char * ) . <nl> - * @ js NA <nl> - * / <nl> - static Dictionary * create ( ) ; <nl> - <nl> - / * * <nl> - * Create a dictionary with an existing dictionary . <nl> - * <nl> - * @ param srcDict The exist dictionary . <nl> - * @ return A dictionary which is an autorelease object . <nl> - * @ see create ( ) , createWithContentsOfFile ( const char * ) , createWithContentsOfFileThreadSafe ( const char * ) . <nl> - * @ js NA <nl> - * / <nl> - static Dictionary * createWithDictionary ( Dictionary * srcDict ) ; <nl> - <nl> - / * * <nl> - * Create a dictionary with a plist file . <nl> - * @ param pFileName The name of the plist file . <nl> - * @ return A dictionary which is an autorelease object . <nl> - * @ see create ( ) , createWithDictionary ( Dictionary * ) , createWithContentsOfFileThreadSafe ( const char * ) . <nl> - * @ js NA <nl> - * / <nl> - static Dictionary * createWithContentsOfFile ( const char * pFileName ) ; <nl> - <nl> - / * * <nl> - * Write a dictionary to a plist file . <nl> - * @ param fullPath The full path of the plist file . You can get writeable path by getWritablePath ( ) <nl> - * @ return true if successed , false if failed <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - bool writeToFile ( const char * fullPath ) ; <nl> - <nl> - / * * <nl> - * Create a dictionary with a plist file . <nl> - * <nl> - * @ note the return object isn ' t an autorelease object . <nl> - * This can make sure not using autorelease pool in a new thread . <nl> - * Therefore , you need to manage the lifecycle of the return object . <nl> - * It means that when you don ' t need it , CC_SAFE_RELEASE needs to be invoked . <nl> - * <nl> - * @ param pFileName The name of the plist file . <nl> - * @ return A dictionary which isn ' t an autorelease object . <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - static Dictionary * createWithContentsOfFileThreadSafe ( const char * pFileName ) ; <nl> - <nl> - / * override functions <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - virtual void acceptVisitor ( DataVisitor & visitor ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - virtual Dictionary * clone ( ) const ; <nl> - <nl> - private : <nl> - / * * <nl> - * For internal usage , invoked by setObject . <nl> - * / <nl> - void setObjectUnSafe ( Object * pObject , const std : : string & key ) ; <nl> - void setObjectUnSafe ( Object * pObject , const intptr_t key ) ; <nl> - <nl> - public : <nl> - / * * <nl> - * All the elements in dictionary . <nl> - * <nl> - * @ note For internal usage , we need to declare this member variable as public since it ' s used in UT_HASH . <nl> - * / <nl> - DictElement * _elements ; <nl> - private : <nl> - <nl> - / * * The support type of dictionary , it ' s confirmed when setObject is invoked . * / <nl> - enum DictType <nl> - { <nl> - kDictUnknown = 0 , <nl> - kDictStr , <nl> - kDictInt <nl> - } ; <nl> - <nl> - / * * <nl> - * The type of dictionary , it ' s assigned to kDictUnknown by default . <nl> - * / <nl> - DictType _dictType ; <nl> - } ; <nl> - <nl> - / / end of data_structure group <nl> - / / / @ } <nl> - <nl> - NS_CC_END <nl> - <nl> - # endif / * __CCDICTIONARY_H__ * / <nl> deleted file mode 100644 <nl> index 5b45b1d6cf28 . . 000000000000 <nl> mmm a / cocos / platform / cocoa / CCDouble . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2010 - 2012 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # ifndef __CCDOUBLE_H__ <nl> - # define __CCDOUBLE_H__ <nl> - <nl> - # include " CCObject . h " <nl> - <nl> - NS_CC_BEGIN <nl> - <nl> - / * * <nl> - * @ addtogroup data_structures <nl> - * @ { <nl> - * / <nl> - <nl> - class CC_DLL Double : public Object , public Clonable <nl> - { <nl> - public : <nl> - Double ( double v ) <nl> - : _value ( v ) { } <nl> - double getValue ( ) const { return _value ; } <nl> - <nl> - static Double * create ( double v ) <nl> - { <nl> - Double * pRet = new Double ( v ) ; <nl> - if ( pRet ) <nl> - { <nl> - pRet - > autorelease ( ) ; <nl> - } <nl> - return pRet ; <nl> - } <nl> - <nl> - / * override functions * / <nl> - virtual void acceptVisitor ( DataVisitor & visitor ) { visitor . visit ( this ) ; } <nl> - <nl> - Double * clone ( ) const <nl> - { <nl> - return Double : : create ( _value ) ; <nl> - } <nl> - private : <nl> - double _value ; <nl> - } ; <nl> - <nl> - / / end of data_structure group <nl> - / / / @ } <nl> - <nl> - NS_CC_END <nl> - <nl> - # endif / * __CCDOUBLE_H__ * / <nl> deleted file mode 100644 <nl> index c85a2e1e7078 . . 000000000000 <nl> mmm a / cocos / platform / cocoa / CCFloat . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2010 - 2012 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # ifndef __CCFLOAT_H__ <nl> - # define __CCFLOAT_H__ <nl> - <nl> - # include " CCObject . h " <nl> - <nl> - NS_CC_BEGIN <nl> - <nl> - / * * <nl> - * @ addtogroup data_structures <nl> - * @ { <nl> - * / <nl> - <nl> - class CC_DLL Float : public Object , public Clonable <nl> - { <nl> - public : <nl> - Float ( float v ) <nl> - : _value ( v ) { } <nl> - float getValue ( ) const { return _value ; } <nl> - <nl> - static Float * create ( float v ) <nl> - { <nl> - Float * pRet = new Float ( v ) ; <nl> - if ( pRet ) <nl> - { <nl> - pRet - > autorelease ( ) ; <nl> - } <nl> - return pRet ; <nl> - } <nl> - <nl> - / * override functions * / <nl> - virtual void acceptVisitor ( DataVisitor & visitor ) { visitor . visit ( this ) ; } <nl> - <nl> - Float * clone ( ) const <nl> - { <nl> - return Float : : create ( _value ) ; <nl> - } <nl> - <nl> - private : <nl> - float _value ; <nl> - } ; <nl> - <nl> - / / end of data_structure group <nl> - / / / @ } <nl> - <nl> - NS_CC_END <nl> - <nl> - # endif / * __CCFLOAT_H__ * / <nl> deleted file mode 100644 <nl> index cfce9d3fa784 . . 000000000000 <nl> mmm a / cocos / platform / cocoa / CCGeometry . cpp <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2010 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # include " CCGeometry . h " <nl> - # include " ccMacros . h " <nl> - # include < algorithm > <nl> - <nl> - / / implementation of Point <nl> - NS_CC_BEGIN <nl> - <nl> - Point : : Point ( void ) : x ( 0 ) , y ( 0 ) <nl> - { <nl> - } <nl> - <nl> - Point : : Point ( float xx , float yy ) : x ( xx ) , y ( yy ) <nl> - { <nl> - } <nl> - <nl> - Point : : Point ( const Point & other ) : x ( other . x ) , y ( other . y ) <nl> - { <nl> - } <nl> - <nl> - Point : : Point ( const Size & size ) : x ( size . width ) , y ( size . height ) <nl> - { <nl> - } <nl> - <nl> - Point & Point : : operator = ( const Point & other ) <nl> - { <nl> - setPoint ( other . x , other . y ) ; <nl> - return * this ; <nl> - } <nl> - <nl> - Point & Point : : operator = ( const Size & size ) <nl> - { <nl> - setPoint ( size . width , size . height ) ; <nl> - return * this ; <nl> - } <nl> - <nl> - Point Point : : operator + ( const Point & right ) const <nl> - { <nl> - return Point ( this - > x + right . x , this - > y + right . y ) ; <nl> - } <nl> - <nl> - Point Point : : operator - ( const Point & right ) const <nl> - { <nl> - return Point ( this - > x - right . x , this - > y - right . y ) ; <nl> - } <nl> - <nl> - Point Point : : operator - ( ) const <nl> - { <nl> - return Point ( - x , - y ) ; <nl> - } <nl> - <nl> - Point Point : : operator * ( float a ) const <nl> - { <nl> - return Point ( this - > x * a , this - > y * a ) ; <nl> - } <nl> - <nl> - Point Point : : operator / ( float a ) const <nl> - { <nl> - CCASSERT ( a ! = 0 , " CCPoint division by 0 . " ) ; <nl> - return Point ( this - > x / a , this - > y / a ) ; <nl> - } <nl> - <nl> - void Point : : setPoint ( float xx , float yy ) <nl> - { <nl> - this - > x = xx ; <nl> - this - > y = yy ; <nl> - } <nl> - <nl> - bool Point : : equals ( const Point & target ) const <nl> - { <nl> - return ( fabs ( this - > x - target . x ) < FLT_EPSILON ) <nl> - & & ( fabs ( this - > y - target . y ) < FLT_EPSILON ) ; <nl> - } <nl> - <nl> - bool Point : : fuzzyEquals ( const Point & b , float var ) const <nl> - { <nl> - if ( x - var < = b . x & & b . x < = x + var ) <nl> - if ( y - var < = b . y & & b . y < = y + var ) <nl> - return true ; <nl> - return false ; <nl> - } <nl> - <nl> - float Point : : getAngle ( const Point & other ) const <nl> - { <nl> - Point a2 = normalize ( ) ; <nl> - Point b2 = other . normalize ( ) ; <nl> - float angle = atan2f ( a2 . cross ( b2 ) , a2 . dot ( b2 ) ) ; <nl> - if ( fabs ( angle ) < FLT_EPSILON ) return 0 . f ; <nl> - return angle ; <nl> - } <nl> - <nl> - Point Point : : rotateByAngle ( const Point & pivot , float angle ) const <nl> - { <nl> - return pivot + ( * this - pivot ) . rotate ( Point : : forAngle ( angle ) ) ; <nl> - } <nl> - <nl> - bool Point : : isOneDemensionSegmentOverlap ( float A , float B , float C , float D , float * S , float * E ) <nl> - { <nl> - float ABmin = MIN ( A , B ) ; <nl> - float ABmax = MAX ( A , B ) ; <nl> - float CDmin = MIN ( C , D ) ; <nl> - float CDmax = MAX ( C , D ) ; <nl> - <nl> - if ( ABmax < CDmin | | CDmax < ABmin ) <nl> - { <nl> - / / ABmin - > ABmax - > CDmin - > CDmax or CDmin - > CDmax - > ABmin - > ABmax <nl> - return false ; <nl> - } <nl> - else <nl> - { <nl> - if ( ABmin > = CDmin & & ABmin < = CDmax ) <nl> - { <nl> - / / CDmin - > ABmin - > CDmax - > ABmax or CDmin - > ABmin - > ABmax - > CDmax <nl> - if ( S ! = nullptr ) * S = ABmin ; <nl> - if ( E ! = nullptr ) * E = CDmax < ABmax ? CDmax : ABmax ; <nl> - } <nl> - else if ( ABmax > = CDmin & & ABmax < = CDmax ) <nl> - { <nl> - / / ABmin - > CDmin - > ABmax - > CDmax <nl> - if ( S ! = nullptr ) * S = CDmin ; <nl> - if ( E ! = nullptr ) * E = ABmax ; <nl> - } <nl> - else <nl> - { <nl> - / / ABmin - > CDmin - > CDmax - > ABmax <nl> - if ( S ! = nullptr ) * S = CDmin ; <nl> - if ( E ! = nullptr ) * E = CDmax ; <nl> - } <nl> - return true ; <nl> - } <nl> - } <nl> - <nl> - bool Point : : isLineIntersect ( const Point & A , const Point & B , <nl> - const Point & C , const Point & D , <nl> - float * S , float * T ) <nl> - { <nl> - / / FAIL : Line undefined <nl> - if ( ( A . x = = B . x & & A . y = = B . y ) | | ( C . x = = D . x & & C . y = = D . y ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - <nl> - const float denom = crossProduct2Vector ( A , B , C , D ) ; <nl> - <nl> - if ( denom = = 0 ) <nl> - { <nl> - / / Lines parallel or overlap <nl> - return false ; <nl> - } <nl> - <nl> - if ( S ! = nullptr ) * S = crossProduct2Vector ( C , D , C , A ) / denom ; <nl> - if ( T ! = nullptr ) * T = crossProduct2Vector ( A , B , C , A ) / denom ; <nl> - <nl> - return true ; <nl> - } <nl> - <nl> - bool Point : : isLineParallel ( const Point & A , const Point & B , <nl> - const Point & C , const Point & D ) <nl> - { <nl> - / / FAIL : Line undefined <nl> - if ( ( A . x = = B . x & & A . y = = B . y ) | | ( C . x = = D . x & & C . y = = D . y ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - <nl> - if ( crossProduct2Vector ( A , B , C , D ) = = 0 ) <nl> - { <nl> - / / line overlap <nl> - if ( crossProduct2Vector ( C , D , C , A ) = = 0 | | crossProduct2Vector ( A , B , C , A ) = = 0 ) <nl> - { <nl> - return false ; <nl> - } <nl> - <nl> - return true ; <nl> - } <nl> - <nl> - return false ; <nl> - } <nl> - <nl> - bool Point : : isLineOverlap ( const Point & A , const Point & B , <nl> - const Point & C , const Point & D ) <nl> - { <nl> - / / FAIL : Line undefined <nl> - if ( ( A . x = = B . x & & A . y = = B . y ) | | ( C . x = = D . x & & C . y = = D . y ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - <nl> - if ( crossProduct2Vector ( A , B , C , D ) = = 0 & & <nl> - ( crossProduct2Vector ( C , D , C , A ) = = 0 | | crossProduct2Vector ( A , B , C , A ) = = 0 ) ) <nl> - { <nl> - return true ; <nl> - } <nl> - <nl> - return false ; <nl> - } <nl> - <nl> - bool Point : : isSegmentOverlap ( const Point & A , const Point & B , const Point & C , const Point & D , Point * S , Point * E ) <nl> - { <nl> - <nl> - if ( isLineOverlap ( A , B , C , D ) ) <nl> - { <nl> - return isOneDemensionSegmentOverlap ( A . x , B . x , C . x , D . x , & S - > x , & E - > x ) & & <nl> - isOneDemensionSegmentOverlap ( A . y , B . y , C . y , D . y , & S - > y , & E - > y ) ; <nl> - } <nl> - <nl> - return false ; <nl> - } <nl> - <nl> - bool Point : : isSegmentIntersect ( const Point & A , const Point & B , const Point & C , const Point & D ) <nl> - { <nl> - float S , T ; <nl> - <nl> - if ( isLineIntersect ( A , B , C , D , & S , & T ) & & <nl> - ( S > = 0 . 0f & & S < = 1 . 0f & & T > = 0 . 0f & & T < = 1 . 0f ) ) <nl> - { <nl> - return true ; <nl> - } <nl> - <nl> - return false ; <nl> - } <nl> - <nl> - Point Point : : getIntersectPoint ( const Point & A , const Point & B , const Point & C , const Point & D ) <nl> - { <nl> - float S , T ; <nl> - <nl> - if ( isLineIntersect ( A , B , C , D , & S , & T ) ) <nl> - { <nl> - / / Point of intersection <nl> - Point P ; <nl> - P . x = A . x + S * ( B . x - A . x ) ; <nl> - P . y = A . y + S * ( B . y - A . y ) ; <nl> - return P ; <nl> - } <nl> - <nl> - return Point : : ZERO ; <nl> - } <nl> - <nl> - const Point Point : : ZERO = Point ( 0 , 0 ) ; <nl> - <nl> - / / implementation of Size <nl> - <nl> - Size : : Size ( void ) : width ( 0 ) , height ( 0 ) <nl> - { <nl> - } <nl> - <nl> - Size : : Size ( float w , float h ) : width ( w ) , height ( h ) <nl> - { <nl> - } <nl> - <nl> - Size : : Size ( const Size & other ) : width ( other . width ) , height ( other . height ) <nl> - { <nl> - } <nl> - <nl> - Size : : Size ( const Point & point ) : width ( point . x ) , height ( point . y ) <nl> - { <nl> - } <nl> - <nl> - Size & Size : : operator = ( const Size & other ) <nl> - { <nl> - setSize ( other . width , other . height ) ; <nl> - return * this ; <nl> - } <nl> - <nl> - Size & Size : : operator = ( const Point & point ) <nl> - { <nl> - setSize ( point . x , point . y ) ; <nl> - return * this ; <nl> - } <nl> - <nl> - Size Size : : operator + ( const Size & right ) const <nl> - { <nl> - return Size ( this - > width + right . width , this - > height + right . height ) ; <nl> - } <nl> - <nl> - Size Size : : operator - ( const Size & right ) const <nl> - { <nl> - return Size ( this - > width - right . width , this - > height - right . height ) ; <nl> - } <nl> - <nl> - Size Size : : operator * ( float a ) const <nl> - { <nl> - return Size ( this - > width * a , this - > height * a ) ; <nl> - } <nl> - <nl> - Size Size : : operator / ( float a ) const <nl> - { <nl> - CCASSERT ( a ! = 0 , " CCSize division by 0 . " ) ; <nl> - return Size ( this - > width / a , this - > height / a ) ; <nl> - } <nl> - <nl> - void Size : : setSize ( float w , float h ) <nl> - { <nl> - this - > width = w ; <nl> - this - > height = h ; <nl> - } <nl> - <nl> - bool Size : : equals ( const Size & target ) const <nl> - { <nl> - return ( fabs ( this - > width - target . width ) < FLT_EPSILON ) <nl> - & & ( fabs ( this - > height - target . height ) < FLT_EPSILON ) ; <nl> - } <nl> - <nl> - const Size Size : : ZERO = Size ( 0 , 0 ) ; <nl> - <nl> - / / implementation of Rect <nl> - <nl> - Rect : : Rect ( void ) <nl> - { <nl> - setRect ( 0 . 0f , 0 . 0f , 0 . 0f , 0 . 0f ) ; <nl> - } <nl> - <nl> - Rect : : Rect ( float x , float y , float width , float height ) <nl> - { <nl> - setRect ( x , y , width , height ) ; <nl> - } <nl> - <nl> - Rect : : Rect ( const Rect & other ) <nl> - { <nl> - setRect ( other . origin . x , other . origin . y , other . size . width , other . size . height ) ; <nl> - } <nl> - <nl> - Rect & Rect : : operator = ( const Rect & other ) <nl> - { <nl> - setRect ( other . origin . x , other . origin . y , other . size . width , other . size . height ) ; <nl> - return * this ; <nl> - } <nl> - <nl> - void Rect : : setRect ( float x , float y , float width , float height ) <nl> - { <nl> - / / CGRect can support width < 0 or height < 0 <nl> - / / CCASSERT ( width > = 0 . 0f & & height > = 0 . 0f , " width and height of Rect must not less than 0 . " ) ; <nl> - <nl> - origin . x = x ; <nl> - origin . y = y ; <nl> - <nl> - size . width = width ; <nl> - size . height = height ; <nl> - } <nl> - <nl> - bool Rect : : equals ( const Rect & rect ) const <nl> - { <nl> - return ( origin . equals ( rect . origin ) & & <nl> - size . equals ( rect . size ) ) ; <nl> - } <nl> - <nl> - float Rect : : getMaxX ( ) const <nl> - { <nl> - return origin . x + size . width ; <nl> - } <nl> - <nl> - float Rect : : getMidX ( ) const <nl> - { <nl> - return origin . x + size . width / 2 . 0f ; <nl> - } <nl> - <nl> - float Rect : : getMinX ( ) const <nl> - { <nl> - return origin . x ; <nl> - } <nl> - <nl> - float Rect : : getMaxY ( ) const <nl> - { <nl> - return origin . y + size . height ; <nl> - } <nl> - <nl> - float Rect : : getMidY ( ) const <nl> - { <nl> - return origin . y + size . height / 2 . 0f ; <nl> - } <nl> - <nl> - float Rect : : getMinY ( ) const <nl> - { <nl> - return origin . y ; <nl> - } <nl> - <nl> - bool Rect : : containsPoint ( const Point & point ) const <nl> - { <nl> - bool bRet = false ; <nl> - <nl> - if ( point . x > = getMinX ( ) & & point . x < = getMaxX ( ) <nl> - & & point . y > = getMinY ( ) & & point . y < = getMaxY ( ) ) <nl> - { <nl> - bRet = true ; <nl> - } <nl> - <nl> - return bRet ; <nl> - } <nl> - <nl> - bool Rect : : intersectsRect ( const Rect & rect ) const <nl> - { <nl> - return ! ( getMaxX ( ) < rect . getMinX ( ) | | <nl> - rect . getMaxX ( ) < getMinX ( ) | | <nl> - getMaxY ( ) < rect . getMinY ( ) | | <nl> - rect . getMaxY ( ) < getMinY ( ) ) ; <nl> - } <nl> - <nl> - Rect Rect : : unionWithRect ( const Rect & rect ) const <nl> - { <nl> - float thisLeftX = origin . x ; <nl> - float thisRightX = origin . x + size . width ; <nl> - float thisTopY = origin . y + size . height ; <nl> - float thisBottomY = origin . y ; <nl> - <nl> - if ( thisRightX < thisLeftX ) <nl> - { <nl> - std : : swap ( thisRightX , thisLeftX ) ; / / This rect has negative width <nl> - } <nl> - <nl> - if ( thisTopY < thisBottomY ) <nl> - { <nl> - std : : swap ( thisTopY , thisBottomY ) ; / / This rect has negative height <nl> - } <nl> - <nl> - float otherLeftX = rect . origin . x ; <nl> - float otherRightX = rect . origin . x + rect . size . width ; <nl> - float otherTopY = rect . origin . y + rect . size . height ; <nl> - float otherBottomY = rect . origin . y ; <nl> - <nl> - if ( otherRightX < otherLeftX ) <nl> - { <nl> - std : : swap ( otherRightX , otherLeftX ) ; / / Other rect has negative width <nl> - } <nl> - <nl> - if ( otherTopY < otherBottomY ) <nl> - { <nl> - std : : swap ( otherTopY , otherBottomY ) ; / / Other rect has negative height <nl> - } <nl> - <nl> - float combinedLeftX = std : : min ( thisLeftX , otherLeftX ) ; <nl> - float combinedRightX = std : : max ( thisRightX , otherRightX ) ; <nl> - float combinedTopY = std : : max ( thisTopY , otherTopY ) ; <nl> - float combinedBottomY = std : : min ( thisBottomY , otherBottomY ) ; <nl> - <nl> - return Rect ( combinedLeftX , combinedBottomY , combinedRightX - combinedLeftX , combinedTopY - combinedBottomY ) ; <nl> - } <nl> - <nl> - const Rect Rect : : ZERO = Rect ( 0 , 0 , 0 , 0 ) ; <nl> - <nl> - NS_CC_END <nl> deleted file mode 100644 <nl> index 47e2fdf9aced . . 000000000000 <nl> mmm a / cocos / platform / cocoa / CCGeometry . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2010 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # ifndef __CCGEMETRY_H__ <nl> - # define __CCGEMETRY_H__ <nl> - <nl> - # include < math . h > <nl> - # include < functional > <nl> - <nl> - # include " platform / CCPlatformMacros . h " <nl> - # include " CCObject . h " <nl> - # include " ccMacros . h " <nl> - <nl> - NS_CC_BEGIN <nl> - <nl> - / * * Clamp a value between from and to . <nl> - @ since v0 . 99 . 1 <nl> - * / <nl> - inline float clampf ( float value , float min_inclusive , float max_inclusive ) <nl> - { <nl> - if ( min_inclusive > max_inclusive ) { <nl> - CC_SWAP ( min_inclusive , max_inclusive , float ) ; <nl> - } <nl> - return value < min_inclusive ? min_inclusive : value < max_inclusive ? value : max_inclusive ; <nl> - } <nl> - <nl> - / * * <nl> - * @ addtogroup data_structures <nl> - * @ { <nl> - * / <nl> - <nl> - / / for Point assignement operator and copy constructor <nl> - class CC_DLL Size ; <nl> - <nl> - class CC_DLL Point <nl> - { <nl> - public : <nl> - float x ; <nl> - float y ; <nl> - <nl> - public : <nl> - / * * <nl> - * @ js NA <nl> - * / <nl> - Point ( ) ; <nl> - / * * <nl> - * @ js NA <nl> - * / <nl> - Point ( float x , float y ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - Point ( const Point & other ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - explicit Point ( const Size & size ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - Point & operator = ( const Point & other ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - Point & operator = ( const Size & size ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - Point operator + ( const Point & right ) const ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - Point operator - ( const Point & right ) const ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - Point operator - ( ) const ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - Point operator * ( float a ) const ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - Point operator / ( float a ) const ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - void setPoint ( float x , float y ) ; <nl> - / * * <nl> - * @ js NA <nl> - * / <nl> - bool equals ( const Point & target ) const ; <nl> - <nl> - / * * @ returns if points have fuzzy equality which means equal with some degree of variance . <nl> - @ since v2 . 1 . 4 <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - bool fuzzyEquals ( const Point & target , float variance ) const ; <nl> - <nl> - / * * Calculates distance between point an origin <nl> - @ return float <nl> - @ since v2 . 1 . 4 <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - inline float getLength ( ) const { <nl> - return sqrtf ( x * x + y * y ) ; <nl> - } ; <nl> - <nl> - / * * Calculates the square length of a Point ( not calling sqrt ( ) ) <nl> - @ return float <nl> - @ since v2 . 1 . 4 <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - inline float getLengthSq ( ) const { <nl> - return dot ( * this ) ; / / x * x + y * y ; <nl> - } ; <nl> - <nl> - / * * Calculates the square distance between two points ( not calling sqrt ( ) ) <nl> - @ return float <nl> - @ since v2 . 1 . 4 <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - inline float getDistanceSq ( const Point & other ) const { <nl> - return ( * this - other ) . getLengthSq ( ) ; <nl> - } ; <nl> - <nl> - / * * Calculates the distance between two points <nl> - @ return float <nl> - @ since v2 . 1 . 4 <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - inline float getDistance ( const Point & other ) const { <nl> - return ( * this - other ) . getLength ( ) ; <nl> - } ; <nl> - <nl> - / * * @ returns the angle in radians between this vector and the x axis <nl> - @ since v2 . 1 . 4 <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - inline float getAngle ( ) const { <nl> - return atan2f ( y , x ) ; <nl> - } ; <nl> - <nl> - / * * @ returns the angle in radians between two vector directions <nl> - @ since v2 . 1 . 4 <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - float getAngle ( const Point & other ) const ; <nl> - <nl> - / * * Calculates dot product of two points . <nl> - @ return float <nl> - @ since v2 . 1 . 4 <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - inline float dot ( const Point & other ) const { <nl> - return x * other . x + y * other . y ; <nl> - } ; <nl> - <nl> - / * * Calculates cross product of two points . <nl> - @ return float <nl> - @ since v2 . 1 . 4 <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - inline float cross ( const Point & other ) const { <nl> - return x * other . y - y * other . x ; <nl> - } ; <nl> - <nl> - / * * Calculates perpendicular of v , rotated 90 degrees counter - clockwise - - cross ( v , perp ( v ) ) > = 0 <nl> - @ return Point <nl> - @ since v2 . 1 . 4 <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - inline Point getPerp ( ) const { <nl> - return Point ( - y , x ) ; <nl> - } ; <nl> - <nl> - / * * Calculates midpoint between two points . <nl> - @ return Point <nl> - @ since v3 . 0 <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - inline Point getMidpoint ( const Point & other ) const <nl> - { <nl> - return Point ( ( x + other . x ) / 2 . 0f , ( y + other . y ) / 2 . 0f ) ; <nl> - } <nl> - <nl> - / * * Clamp a point between from and to . <nl> - @ since v3 . 0 <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - inline Point getClampPoint ( const Point & min_inclusive , const Point & max_inclusive ) const <nl> - { <nl> - return Point ( clampf ( x , min_inclusive . x , max_inclusive . x ) , clampf ( y , min_inclusive . y , max_inclusive . y ) ) ; <nl> - } <nl> - <nl> - / * * Run a math operation function on each point component <nl> - * absf , fllorf , ceilf , roundf <nl> - * any function that has the signature : float func ( float ) ; <nl> - * For example : let ' s try to take the floor of x , y <nl> - * p . compOp ( floorf ) ; <nl> - @ since v3 . 0 <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - inline Point compOp ( std : : function < float ( float ) > function ) const <nl> - { <nl> - return Point ( function ( x ) , function ( y ) ) ; <nl> - } <nl> - <nl> - / * * Calculates perpendicular of v , rotated 90 degrees clockwise - - cross ( v , rperp ( v ) ) < = 0 <nl> - @ return Point <nl> - @ since v2 . 1 . 4 <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - inline Point getRPerp ( ) const { <nl> - return Point ( y , - x ) ; <nl> - } ; <nl> - <nl> - / * * Calculates the projection of this over other . <nl> - @ return Point <nl> - @ since v2 . 1 . 4 <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - inline Point project ( const Point & other ) const { <nl> - return other * ( dot ( other ) / other . dot ( other ) ) ; <nl> - } ; <nl> - <nl> - / * * Complex multiplication of two points ( " rotates " two points ) . <nl> - @ return Point vector with an angle of this . getAngle ( ) + other . getAngle ( ) , <nl> - and a length of this . getLength ( ) * other . getLength ( ) . <nl> - @ since v2 . 1 . 4 <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - inline Point rotate ( const Point & other ) const { <nl> - return Point ( x * other . x - y * other . y , x * other . y + y * other . x ) ; <nl> - } ; <nl> - <nl> - / * * Unrotates two points . <nl> - @ return Point vector with an angle of this . getAngle ( ) - other . getAngle ( ) , <nl> - and a length of this . getLength ( ) * other . getLength ( ) . <nl> - @ since v2 . 1 . 4 <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - inline Point unrotate ( const Point & other ) const { <nl> - return Point ( x * other . x + y * other . y , y * other . x - x * other . y ) ; <nl> - } ; <nl> - <nl> - / * * Returns point multiplied to a length of 1 . <nl> - * If the point is 0 , it returns ( 1 , 0 ) <nl> - @ return Point <nl> - @ since v2 . 1 . 4 <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - inline Point normalize ( ) const { <nl> - float length = getLength ( ) ; <nl> - if ( length = = 0 . ) return Point ( 1 . f , 0 ) ; <nl> - return * this / getLength ( ) ; <nl> - } ; <nl> - <nl> - / * * Linear Interpolation between two points a and b <nl> - @ returns <nl> - alpha = = 0 ? a <nl> - alpha = = 1 ? b <nl> - otherwise a value between a . . b <nl> - @ since v2 . 1 . 4 <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - inline Point lerp ( const Point & other , float alpha ) const { <nl> - return * this * ( 1 . f - alpha ) + other * alpha ; <nl> - } ; <nl> - <nl> - / * * Rotates a point counter clockwise by the angle around a pivot <nl> - @ param pivot is the pivot , naturally <nl> - @ param angle is the angle of rotation ccw in radians <nl> - @ returns the rotated point <nl> - @ since v2 . 1 . 4 <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - Point rotateByAngle ( const Point & pivot , float angle ) const ; <nl> - <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - static inline Point forAngle ( const float a ) <nl> - { <nl> - return Point ( cosf ( a ) , sinf ( a ) ) ; <nl> - } <nl> - <nl> - / * * A general line - line intersection test <nl> - @ param A the startpoint for the first line L1 = ( A - B ) <nl> - @ param B the endpoint for the first line L1 = ( A - B ) <nl> - @ param C the startpoint for the second line L2 = ( C - D ) <nl> - @ param D the endpoint for the second line L2 = ( C - D ) <nl> - @ param S the range for a hitpoint in L1 ( p = A + S * ( B - A ) ) <nl> - @ param T the range for a hitpoint in L2 ( p = C + T * ( D - C ) ) <nl> - @ returns whether these two lines interects . <nl> - <nl> - Note that to truly test intersection for segments we have to make <nl> - sure that S & T lie within [ 0 . . 1 ] and for rays , make sure S & T > 0 <nl> - the hit point is C + T * ( D - C ) ; <nl> - the hit point also is A + S * ( B - A ) ; <nl> - @ since 3 . 0 <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - static bool isLineIntersect ( const Point & A , const Point & B , <nl> - const Point & C , const Point & D , <nl> - float * S = nullptr , float * T = nullptr ) ; <nl> - <nl> - / * * <nl> - returns true if Line A - B overlap with segment C - D <nl> - @ since v3 . 0 <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - static bool isLineOverlap ( const Point & A , const Point & B , <nl> - const Point & C , const Point & D ) ; <nl> - <nl> - / * * <nl> - returns true if Line A - B parallel with segment C - D <nl> - @ since v3 . 0 <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - static bool isLineParallel ( const Point & A , const Point & B , <nl> - const Point & C , const Point & D ) ; <nl> - <nl> - / * * <nl> - returns true if Segment A - B overlap with segment C - D <nl> - @ since v3 . 0 <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - static bool isSegmentOverlap ( const Point & A , const Point & B , <nl> - const Point & C , const Point & D , <nl> - Point * S = nullptr , Point * E = nullptr ) ; <nl> - <nl> - / * * <nl> - returns true if Segment A - B intersects with segment C - D <nl> - @ since v3 . 0 <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - static bool isSegmentIntersect ( const Point & A , const Point & B , const Point & C , const Point & D ) ; <nl> - <nl> - / * * <nl> - returns the intersection point of line A - B , C - D <nl> - @ since v3 . 0 <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - static Point getIntersectPoint ( const Point & A , const Point & B , const Point & C , const Point & D ) ; <nl> - <nl> - static const Point ZERO ; <nl> - <nl> - private : <nl> - / / returns true if segment A - B intersects with segment C - D . S - > E is the ovderlap part <nl> - static bool isOneDemensionSegmentOverlap ( float A , float B , float C , float D , float * S , float * E ) ; <nl> - <nl> - / / cross procuct of 2 vector . A - > B X C - > D <nl> - static float crossProduct2Vector ( const Point & A , const Point & B , const Point & C , const Point & D ) { return ( D . y - C . y ) * ( B . x - A . x ) - ( D . x - C . x ) * ( B . y - A . y ) ; } <nl> - } ; <nl> - <nl> - class CC_DLL Size <nl> - { <nl> - public : <nl> - float width ; <nl> - float height ; <nl> - <nl> - public : <nl> - / * * <nl> - * @ js NA <nl> - * / <nl> - Size ( ) ; <nl> - / * * <nl> - * @ js NA <nl> - * / <nl> - Size ( float width , float height ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - Size ( const Size & other ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - explicit Size ( const Point & point ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - Size & operator = ( const Size & other ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - Size & operator = ( const Point & point ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - Size operator + ( const Size & right ) const ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - Size operator - ( const Size & right ) const ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - Size operator * ( float a ) const ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - Size operator / ( float a ) const ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - void setSize ( float width , float height ) ; <nl> - / * * <nl> - * @ js NA <nl> - * / <nl> - bool equals ( const Size & target ) const ; <nl> - <nl> - static const Size ZERO ; <nl> - } ; <nl> - <nl> - class CC_DLL Rect <nl> - { <nl> - public : <nl> - Point origin ; <nl> - Size size ; <nl> - <nl> - public : <nl> - / * * <nl> - * @ js NA <nl> - * / <nl> - Rect ( ) ; <nl> - / * * <nl> - * @ js NA <nl> - * / <nl> - Rect ( float x , float y , float width , float height ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - Rect ( const Rect & other ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - Rect & operator = ( const Rect & other ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - void setRect ( float x , float y , float width , float height ) ; <nl> - / * * <nl> - * @ js NA <nl> - * / <nl> - float getMinX ( ) const ; / / / return the leftmost x - value of current rect <nl> - / * * <nl> - * @ js NA <nl> - * / <nl> - float getMidX ( ) const ; / / / return the midpoint x - value of current rect <nl> - / * * <nl> - * @ js NA <nl> - * / <nl> - float getMaxX ( ) const ; / / / return the rightmost x - value of current rect <nl> - / * * <nl> - * @ js NA <nl> - * / <nl> - float getMinY ( ) const ; / / / return the bottommost y - value of current rect <nl> - / * * <nl> - * @ js NA <nl> - * / <nl> - float getMidY ( ) const ; / / / return the midpoint y - value of current rect <nl> - / * * <nl> - * @ js NA <nl> - * / <nl> - float getMaxY ( ) const ; / / / return the topmost y - value of current rect <nl> - / * * <nl> - * @ js NA <nl> - * / <nl> - bool equals ( const Rect & rect ) const ; <nl> - / * * <nl> - * @ js NA <nl> - * / <nl> - bool containsPoint ( const Point & point ) const ; <nl> - / * * <nl> - * @ js NA <nl> - * / <nl> - bool intersectsRect ( const Rect & rect ) const ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - Rect unionWithRect ( const Rect & rect ) const ; <nl> - <nl> - static const Rect ZERO ; <nl> - } ; <nl> - <nl> - / / end of data_structure group <nl> - / / / @ } <nl> - <nl> - NS_CC_END <nl> - <nl> - # endif / / __CCGEMETRY_H__ <nl> deleted file mode 100644 <nl> index 23735627dd43 . . 000000000000 <nl> mmm a / cocos / platform / cocoa / CCInteger . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2010 - 2012 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # ifndef __CCINTEGER_H__ <nl> - # define __CCINTEGER_H__ <nl> - <nl> - # include " CCObject . h " <nl> - # include " platform / CCCommon . h " <nl> - <nl> - NS_CC_BEGIN <nl> - <nl> - / * * <nl> - * @ addtogroup data_structures <nl> - * @ { <nl> - * / <nl> - <nl> - class CC_DLL Integer : public Object , public Clonable <nl> - { <nl> - public : <nl> - static Integer * create ( int v ) <nl> - { <nl> - Integer * pRet = new Integer ( v ) ; <nl> - pRet - > autorelease ( ) ; <nl> - return pRet ; <nl> - } <nl> - / * * <nl> - * @ js NA <nl> - * / <nl> - Integer ( int v ) <nl> - : _value ( v ) { } <nl> - int getValue ( ) const { return _value ; } <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - virtual ~ Integer ( ) { <nl> - CCLOGINFO ( " deallocing ~ Integer : % p " , this ) ; <nl> - } <nl> - <nl> - / * override functions * / <nl> - virtual void acceptVisitor ( DataVisitor & visitor ) { visitor . visit ( this ) ; } <nl> - <nl> - / / overrides <nl> - virtual Integer * clone ( ) const override <nl> - { <nl> - return Integer : : create ( _value ) ; <nl> - } <nl> - <nl> - private : <nl> - int _value ; <nl> - } ; <nl> - <nl> - / / end of data_structure group <nl> - / / / @ } <nl> - <nl> - NS_CC_END <nl> - <nl> - # endif / * __CCINTEGER_H__ * / <nl> deleted file mode 100644 <nl> index 8cf496c0b194 . . 000000000000 <nl> mmm a / cocos / platform / cocoa / CCNS . cpp <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2010 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - # include " CCNS . h " <nl> - # include < string > <nl> - # include < vector > <nl> - # include < string . h > <nl> - # include < stdlib . h > <nl> - <nl> - using namespace std ; <nl> - <nl> - NS_CC_BEGIN <nl> - <nl> - typedef std : : vector < std : : string > strArray ; <nl> - <nl> - / / string toolkit <nl> - static inline void split ( std : : string src , const char * token , strArray & vect ) <nl> - { <nl> - int nend = 0 ; <nl> - int nbegin = 0 ; <nl> - while ( nend ! = - 1 ) <nl> - { <nl> - nend = src . find ( token , nbegin ) ; <nl> - if ( nend = = - 1 ) <nl> - vect . push_back ( src . substr ( nbegin , src . length ( ) - nbegin ) ) ; <nl> - else <nl> - vect . push_back ( src . substr ( nbegin , nend - nbegin ) ) ; <nl> - nbegin = nend + strlen ( token ) ; <nl> - } <nl> - } <nl> - <nl> - / / first , judge whether the form of the string like this : { x , y } <nl> - / / if the form is right , the string will be split into the parameter strs ; <nl> - / / or the parameter strs will be empty . <nl> - / / if the form is right return true , else return false . <nl> - static bool splitWithForm ( const char * pStr , strArray & strs ) <nl> - { <nl> - bool bRet = false ; <nl> - <nl> - do <nl> - { <nl> - CC_BREAK_IF ( ! pStr ) ; <nl> - <nl> - / / string is empty <nl> - std : : string content = pStr ; <nl> - CC_BREAK_IF ( content . length ( ) = = 0 ) ; <nl> - <nl> - int nPosLeft = content . find ( ' { ' ) ; <nl> - int nPosRight = content . find ( ' } ' ) ; <nl> - <nl> - / / don ' t have ' { ' and ' } ' <nl> - CC_BREAK_IF ( nPosLeft = = ( int ) std : : string : : npos | | nPosRight = = ( int ) std : : string : : npos ) ; <nl> - / / ' } ' is before ' { ' <nl> - CC_BREAK_IF ( nPosLeft > nPosRight ) ; <nl> - <nl> - std : : string pointStr = content . substr ( nPosLeft + 1 , nPosRight - nPosLeft - 1 ) ; <nl> - / / nothing between ' { ' and ' } ' <nl> - CC_BREAK_IF ( pointStr . length ( ) = = 0 ) ; <nl> - <nl> - int nPos1 = pointStr . find ( ' { ' ) ; <nl> - int nPos2 = pointStr . find ( ' } ' ) ; <nl> - / / contain ' { ' or ' } ' <nl> - CC_BREAK_IF ( nPos1 ! = ( int ) std : : string : : npos | | nPos2 ! = ( int ) std : : string : : npos ) ; <nl> - <nl> - split ( pointStr , " , " , strs ) ; <nl> - if ( strs . size ( ) ! = 2 | | strs [ 0 ] . length ( ) = = 0 | | strs [ 1 ] . length ( ) = = 0 ) <nl> - { <nl> - strs . clear ( ) ; <nl> - break ; <nl> - } <nl> - <nl> - bRet = true ; <nl> - } while ( 0 ) ; <nl> - <nl> - return bRet ; <nl> - } <nl> - <nl> - / / implement the functions <nl> - <nl> - Rect RectFromString ( const char * pszContent ) <nl> - { <nl> - Rect result = Rect : : ZERO ; <nl> - <nl> - do <nl> - { <nl> - CC_BREAK_IF ( ! pszContent ) ; <nl> - std : : string content = pszContent ; <nl> - <nl> - / / find the first ' { ' and the third ' } ' <nl> - int nPosLeft = content . find ( ' { ' ) ; <nl> - int nPosRight = content . find ( ' } ' ) ; <nl> - for ( int i = 1 ; i < 3 ; + + i ) <nl> - { <nl> - if ( nPosRight = = ( int ) std : : string : : npos ) <nl> - { <nl> - break ; <nl> - } <nl> - nPosRight = content . find ( ' } ' , nPosRight + 1 ) ; <nl> - } <nl> - CC_BREAK_IF ( nPosLeft = = ( int ) std : : string : : npos | | nPosRight = = ( int ) std : : string : : npos ) ; <nl> - <nl> - content = content . substr ( nPosLeft + 1 , nPosRight - nPosLeft - 1 ) ; <nl> - int nPointEnd = content . find ( ' } ' ) ; <nl> - CC_BREAK_IF ( nPointEnd = = ( int ) std : : string : : npos ) ; <nl> - nPointEnd = content . find ( ' , ' , nPointEnd ) ; <nl> - CC_BREAK_IF ( nPointEnd = = ( int ) std : : string : : npos ) ; <nl> - <nl> - / / get the point string and size string <nl> - std : : string pointStr = content . substr ( 0 , nPointEnd ) ; <nl> - std : : string sizeStr = content . substr ( nPointEnd + 1 , content . length ( ) - nPointEnd ) ; <nl> - <nl> - / / split the string with ' , ' <nl> - strArray pointInfo ; <nl> - CC_BREAK_IF ( ! splitWithForm ( pointStr . c_str ( ) , pointInfo ) ) ; <nl> - strArray sizeInfo ; <nl> - CC_BREAK_IF ( ! splitWithForm ( sizeStr . c_str ( ) , sizeInfo ) ) ; <nl> - <nl> - float x = ( float ) atof ( pointInfo [ 0 ] . c_str ( ) ) ; <nl> - float y = ( float ) atof ( pointInfo [ 1 ] . c_str ( ) ) ; <nl> - float width = ( float ) atof ( sizeInfo [ 0 ] . c_str ( ) ) ; <nl> - float height = ( float ) atof ( sizeInfo [ 1 ] . c_str ( ) ) ; <nl> - <nl> - result = Rect ( x , y , width , height ) ; <nl> - } while ( 0 ) ; <nl> - <nl> - return result ; <nl> - } <nl> - <nl> - Point PointFromString ( const char * pszContent ) <nl> - { <nl> - Point ret = Point : : ZERO ; <nl> - <nl> - do <nl> - { <nl> - strArray strs ; <nl> - CC_BREAK_IF ( ! splitWithForm ( pszContent , strs ) ) ; <nl> - <nl> - float x = ( float ) atof ( strs [ 0 ] . c_str ( ) ) ; <nl> - float y = ( float ) atof ( strs [ 1 ] . c_str ( ) ) ; <nl> - <nl> - ret = Point ( x , y ) ; <nl> - } while ( 0 ) ; <nl> - <nl> - return ret ; <nl> - } <nl> - <nl> - Size SizeFromString ( const char * pszContent ) <nl> - { <nl> - Size ret = Size : : ZERO ; <nl> - <nl> - do <nl> - { <nl> - strArray strs ; <nl> - CC_BREAK_IF ( ! splitWithForm ( pszContent , strs ) ) ; <nl> - <nl> - float width = ( float ) atof ( strs [ 0 ] . c_str ( ) ) ; <nl> - float height = ( float ) atof ( strs [ 1 ] . c_str ( ) ) ; <nl> - <nl> - ret = Size ( width , height ) ; <nl> - } while ( 0 ) ; <nl> - <nl> - return ret ; <nl> - } <nl> - <nl> - NS_CC_END <nl> deleted file mode 100644 <nl> index 8ce8e1dde6f2 . . 000000000000 <nl> mmm a / cocos / platform / cocoa / CCNS . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2010 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # ifndef __PLATFOMR_CCNS_H__ <nl> - # define __PLATFOMR_CCNS_H__ <nl> - <nl> - # include " CCGeometry . h " <nl> - <nl> - NS_CC_BEGIN <nl> - <nl> - / * * <nl> - * @ addtogroup data_structures <nl> - * @ { <nl> - * / <nl> - <nl> - / * * <nl> - @ brief Returns a Core Graphics rectangle structure corresponding to the data in a given string . <nl> - @ param pszContent A string object whose contents are of the form " { { x , y } , { w , h } } " , <nl> - where x is the x coordinate , y is the y coordinate , w is the width , and h is the height . <nl> - These components can represent integer or float values . <nl> - An example of a valid string is " { { 3 , 2 } , { 4 , 5 } } " . <nl> - The string is not localized , so items are always separated with a comma . <nl> - @ return A Core Graphics structure that represents a rectangle . <nl> - If the string is not well - formed , the function returns Rect : : ZERO . <nl> - * / <nl> - Rect CC_DLL RectFromString ( const char * pszContent ) ; <nl> - <nl> - / * * <nl> - @ brief Returns a Core Graphics point structure corresponding to the data in a given string . <nl> - @ param pszContent A string object whose contents are of the form " { x , y } " , <nl> - where x is the x coordinate and y is the y coordinate . <nl> - The x and y values can represent integer or float values . <nl> - An example of a valid string is " { 3 . 0 , 2 . 5 } " . <nl> - The string is not localized , so items are always separated with a comma . <nl> - @ return A Core Graphics structure that represents a point . <nl> - If the string is not well - formed , the function returns Point : : ZERO . <nl> - * / <nl> - Point CC_DLL PointFromString ( const char * pszContent ) ; <nl> - <nl> - / * * <nl> - @ brief Returns a Core Graphics size structure corresponding to the data in a given string . <nl> - @ param pszContent A string object whose contents are of the form " { w , h } " , <nl> - where w is the width and h is the height . <nl> - The w and h values can be integer or float values . <nl> - An example of a valid string is " { 3 . 0 , 2 . 5 } " . <nl> - The string is not localized , so items are always separated with a comma . <nl> - @ return A Core Graphics structure that represents a size . <nl> - If the string is not well - formed , the function returns Size : : ZERO . <nl> - * / <nl> - Size CC_DLL SizeFromString ( const char * pszContent ) ; <nl> - <nl> - / / end of data_structure group <nl> - / / / @ } <nl> - <nl> - NS_CC_END <nl> - <nl> - # endif / / __PLATFOMR_CCNS_H__ <nl> - <nl> - <nl> deleted file mode 100644 <nl> index 13fa0e32364f . . 000000000000 <nl> mmm a / cocos / platform / cocoa / CCObject . cpp <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2010 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - <nl> - # include " CCObject . h " <nl> - # include " CCAutoreleasePool . h " <nl> - # include " ccMacros . h " <nl> - # include " script_support / CCScriptSupport . h " <nl> - <nl> - NS_CC_BEGIN <nl> - <nl> - Object : : Object ( ) <nl> - : _luaID ( 0 ) <nl> - , _reference ( 1 ) / / when the object is created , the reference count of it is 1 <nl> - , _autoReleaseCount ( 0 ) <nl> - { <nl> - static unsigned int uObjectCount = 0 ; <nl> - <nl> - _ID = + + uObjectCount ; <nl> - } <nl> - <nl> - Object : : ~ Object ( ) <nl> - { <nl> - / / if the object is managed , we should remove it <nl> - / / from pool manager <nl> - if ( _autoReleaseCount > 0 ) <nl> - { <nl> - PoolManager : : sharedPoolManager ( ) - > removeObject ( this ) ; <nl> - } <nl> - <nl> - / / if the object is referenced by Lua engine , remove it <nl> - if ( _luaID ) <nl> - { <nl> - ScriptEngineManager : : getInstance ( ) - > getScriptEngine ( ) - > removeScriptObjectByObject ( this ) ; <nl> - } <nl> - else <nl> - { <nl> - ScriptEngineProtocol * pEngine = ScriptEngineManager : : getInstance ( ) - > getScriptEngine ( ) ; <nl> - if ( pEngine ! = NULL & & pEngine - > getScriptType ( ) = = kScriptTypeJavascript ) <nl> - { <nl> - pEngine - > removeScriptObjectByObject ( this ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - Object * Object : : autorelease ( ) <nl> - { <nl> - PoolManager : : sharedPoolManager ( ) - > addObject ( this ) ; <nl> - return this ; <nl> - } <nl> - <nl> - bool Object : : isSingleReference ( ) const <nl> - { <nl> - return _reference = = 1 ; <nl> - } <nl> - <nl> - unsigned int Object : : retainCount ( ) const <nl> - { <nl> - return _reference ; <nl> - } <nl> - <nl> - bool Object : : isEqual ( const Object * object ) <nl> - { <nl> - return this = = object ; <nl> - } <nl> - <nl> - void Object : : acceptVisitor ( DataVisitor & visitor ) <nl> - { <nl> - visitor . visitObject ( this ) ; <nl> - } <nl> - <nl> - NS_CC_END <nl> deleted file mode 100644 <nl> index 8de1ff9d8bfd . . 000000000000 <nl> mmm a / cocos / platform / cocoa / CCObject . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2010 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # ifndef __CCOBJECT_H__ <nl> - # define __CCOBJECT_H__ <nl> - <nl> - # include " cocoa / CCDataVisitor . h " <nl> - # include " ccMacros . h " <nl> - <nl> - # ifdef EMSCRIPTEN <nl> - # include < GLES2 / gl2 . h > <nl> - # endif / / EMSCRIPTEN <nl> - <nl> - NS_CC_BEGIN <nl> - <nl> - / * * <nl> - * @ addtogroup base_nodes <nl> - * @ { <nl> - * / <nl> - <nl> - class Object ; <nl> - class Node ; <nl> - <nl> - / * * Interface that defines how to clone an object * / <nl> - class CC_DLL Clonable <nl> - { <nl> - public : <nl> - / * * returns a copy of the object * / <nl> - virtual Clonable * clone ( ) const = 0 ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - virtual ~ Clonable ( ) { } ; <nl> - <nl> - / * * returns a copy of the object . <nl> - @ deprecated Use clone ( ) instead <nl> - * / <nl> - CC_DEPRECATED_ATTRIBUTE Object * copy ( ) const <nl> - { <nl> - / / use " clone " instead <nl> - CC_ASSERT ( false ) ; <nl> - return nullptr ; <nl> - } <nl> - } ; <nl> - <nl> - class CC_DLL Object <nl> - { <nl> - public : <nl> - / / / object id , ScriptSupport need public _ID <nl> - unsigned int _ID ; <nl> - / / / Lua reference id <nl> - int _luaID ; <nl> - protected : <nl> - / / / count of references <nl> - unsigned int _reference ; <nl> - / / / count of autorelease <nl> - unsigned int _autoReleaseCount ; <nl> - public : <nl> - / * * <nl> - * Constructor <nl> - * <nl> - * The object ' s reference count is 1 after construction . <nl> - * @ js NA <nl> - * / <nl> - Object ( ) ; <nl> - <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - virtual ~ Object ( ) ; <nl> - <nl> - / * * <nl> - * Release the ownership immediately . <nl> - * <nl> - * This decrements the object ' s reference count . <nl> - * <nl> - * If the reference count reaches 0 after the descrement , this object is <nl> - * destructed . <nl> - * <nl> - * @ see retain , autorelease <nl> - * @ js NA <nl> - * / <nl> - inline void release ( ) <nl> - { <nl> - CCASSERT ( _reference > 0 , " reference count should greater than 0 " ) ; <nl> - - - _reference ; <nl> - <nl> - if ( _reference = = 0 ) <nl> - delete this ; <nl> - } <nl> - <nl> - / * * <nl> - * Retains the ownership . <nl> - * <nl> - * This increases the object ' s reference count . <nl> - * <nl> - * @ see release , autorelease <nl> - * @ js NA <nl> - * / <nl> - inline void retain ( ) <nl> - { <nl> - CCASSERT ( _reference > 0 , " reference count should greater than 0 " ) ; <nl> - + + _reference ; <nl> - } <nl> - <nl> - / * * <nl> - * Release the ownership sometime soon automatically . <nl> - * <nl> - * This descrements the object ' s reference count at the end of current <nl> - * autorelease pool block . <nl> - * <nl> - * If the reference count reaches 0 after the descrement , this object is <nl> - * destructed . <nl> - * <nl> - * @ returns The object itself . <nl> - * <nl> - * @ see AutoreleasePool , retain , release <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - Object * autorelease ( ) ; <nl> - <nl> - / * * <nl> - * Returns a boolean value that indicates whether there is only one <nl> - * reference to the object . That is , whether the reference count is 1 . <nl> - * <nl> - * @ returns Whether the object ' s reference count is 1 . <nl> - * @ js NA <nl> - * / <nl> - bool isSingleReference ( ) const ; <nl> - <nl> - / * * <nl> - * Returns the object ' s current reference count . <nl> - * <nl> - * @ returns The object ' s reference count . <nl> - * @ js NA <nl> - * / <nl> - unsigned int retainCount ( ) const ; <nl> - <nl> - / * * <nl> - * Returns a boolean value that indicates whether this object and a given <nl> - * object are equal . <nl> - * <nl> - * @ param object The object to be compared to this object . <nl> - * <nl> - * @ returns True if this object and @ p object are equal , otherwise false . <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - virtual bool isEqual ( const Object * object ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - virtual void acceptVisitor ( DataVisitor & visitor ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - virtual void update ( float dt ) { CC_UNUSED_PARAM ( dt ) ; } ; <nl> - <nl> - friend class AutoreleasePool ; <nl> - } ; <nl> - <nl> - <nl> - typedef void ( Object : : * SEL_SCHEDULE ) ( float ) ; <nl> - typedef void ( Object : : * SEL_CallFunc ) ( ) ; <nl> - typedef void ( Object : : * SEL_CallFuncN ) ( Node * ) ; <nl> - typedef void ( Object : : * SEL_CallFuncND ) ( Node * , void * ) ; <nl> - typedef void ( Object : : * SEL_CallFuncO ) ( Object * ) ; <nl> - typedef void ( Object : : * SEL_MenuHandler ) ( Object * ) ; <nl> - typedef int ( Object : : * SEL_Compare ) ( Object * ) ; <nl> - <nl> - # define schedule_selector ( _SELECTOR ) static_cast < cocos2d : : SEL_SCHEDULE > ( & _SELECTOR ) <nl> - # define callfunc_selector ( _SELECTOR ) static_cast < cocos2d : : SEL_CallFunc > ( & _SELECTOR ) <nl> - # define callfuncN_selector ( _SELECTOR ) static_cast < cocos2d : : SEL_CallFuncN > ( & _SELECTOR ) <nl> - # define callfuncND_selector ( _SELECTOR ) static_cast < cocos2d : : SEL_CallFuncND > ( & _SELECTOR ) <nl> - # define callfuncO_selector ( _SELECTOR ) static_cast < cocos2d : : SEL_CallFuncO > ( & _SELECTOR ) <nl> - # define menu_selector ( _SELECTOR ) static_cast < cocos2d : : SEL_MenuHandler > ( & _SELECTOR ) <nl> - # define event_selector ( _SELECTOR ) static_cast < cocos2d : : SEL_EventHandler > ( & _SELECTOR ) <nl> - # define compare_selector ( _SELECTOR ) static_cast < cocos2d : : SEL_Compare > ( & _SELECTOR ) <nl> - <nl> - / / new callbacks based on C + + 11 <nl> - # define CC_CALLBACK_0 ( __selector__ , __target__ , . . . ) std : : bind ( & __selector__ , __target__ , # # __VA_ARGS__ ) <nl> - # define CC_CALLBACK_1 ( __selector__ , __target__ , . . . ) std : : bind ( & __selector__ , __target__ , std : : placeholders : : _1 , # # __VA_ARGS__ ) <nl> - # define CC_CALLBACK_2 ( __selector__ , __target__ , . . . ) std : : bind ( & __selector__ , __target__ , std : : placeholders : : _1 , std : : placeholders : : _2 , # # __VA_ARGS__ ) <nl> - <nl> - / / end of base_nodes group <nl> - / / / @ } <nl> - <nl> - NS_CC_END <nl> - <nl> - # endif / / __CCOBJECT_H__ <nl> deleted file mode 100644 <nl> index c3c24e0e5e60 . . 000000000000 <nl> mmm a / cocos / platform / cocoa / CCSet . cpp <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2010 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # include " CCSet . h " <nl> - <nl> - using namespace std ; <nl> - <nl> - NS_CC_BEGIN <nl> - <nl> - Set : : Set ( void ) <nl> - { <nl> - _set = new set < Object * > ; <nl> - } <nl> - <nl> - Set : : Set ( const Set & rSetObject ) <nl> - { <nl> - _set = new set < Object * > ( * rSetObject . _set ) ; <nl> - <nl> - / / call retain of members <nl> - SetIterator iter ; <nl> - for ( iter = _set - > begin ( ) ; iter ! = _set - > end ( ) ; + + iter ) <nl> - { <nl> - if ( ! ( * iter ) ) <nl> - { <nl> - break ; <nl> - } <nl> - <nl> - ( * iter ) - > retain ( ) ; <nl> - } <nl> - } <nl> - <nl> - Set : : ~ Set ( void ) <nl> - { <nl> - removeAllObjects ( ) ; <nl> - CC_SAFE_DELETE ( _set ) ; <nl> - } <nl> - <nl> - void Set : : acceptVisitor ( DataVisitor & visitor ) <nl> - { <nl> - visitor . visit ( this ) ; <nl> - } <nl> - <nl> - Set * Set : : create ( ) <nl> - { <nl> - Set * pRet = new Set ( ) ; <nl> - <nl> - if ( pRet ! = NULL ) <nl> - { <nl> - pRet - > autorelease ( ) ; <nl> - } <nl> - <nl> - return pRet ; <nl> - } <nl> - <nl> - Set * Set : : copy ( void ) <nl> - { <nl> - Set * pSet = new Set ( * this ) ; <nl> - <nl> - return pSet ; <nl> - } <nl> - <nl> - Set * Set : : mutableCopy ( void ) <nl> - { <nl> - return copy ( ) ; <nl> - } <nl> - <nl> - int Set : : count ( void ) <nl> - { <nl> - return ( int ) _set - > size ( ) ; <nl> - } <nl> - <nl> - void Set : : addObject ( Object * pObject ) <nl> - { <nl> - if ( _set - > count ( pObject ) = = 0 ) <nl> - { <nl> - CC_SAFE_RETAIN ( pObject ) ; <nl> - _set - > insert ( pObject ) ; <nl> - } <nl> - } <nl> - <nl> - void Set : : removeObject ( Object * pObject ) <nl> - { <nl> - if ( _set - > erase ( pObject ) > 0 ) <nl> - { <nl> - CC_SAFE_RELEASE ( pObject ) ; <nl> - } <nl> - } <nl> - <nl> - void Set : : removeAllObjects ( ) <nl> - { <nl> - SetIterator it = _set - > begin ( ) ; <nl> - SetIterator tmp ; <nl> - <nl> - while ( it ! = _set - > end ( ) ) <nl> - { <nl> - if ( ! ( * it ) ) <nl> - { <nl> - break ; <nl> - } <nl> - <nl> - tmp = it ; <nl> - + + tmp ; <nl> - Object * obj = * it ; <nl> - _set - > erase ( it ) ; <nl> - CC_SAFE_RELEASE ( obj ) ; <nl> - it = tmp ; <nl> - } <nl> - } <nl> - <nl> - bool Set : : containsObject ( Object * pObject ) <nl> - { <nl> - return _set - > find ( pObject ) ! = _set - > end ( ) ; <nl> - } <nl> - <nl> - SetIterator Set : : begin ( void ) <nl> - { <nl> - return _set - > begin ( ) ; <nl> - } <nl> - <nl> - SetIterator Set : : end ( void ) <nl> - { <nl> - return _set - > end ( ) ; <nl> - } <nl> - <nl> - Object * Set : : anyObject ( ) <nl> - { <nl> - if ( ! _set | | _set - > empty ( ) ) <nl> - { <nl> - return 0 ; <nl> - } <nl> - <nl> - SetIterator it ; <nl> - <nl> - for ( it = _set - > begin ( ) ; it ! = _set - > end ( ) ; + + it ) <nl> - { <nl> - if ( * it ) <nl> - { <nl> - return ( * it ) ; <nl> - } <nl> - } <nl> - <nl> - return 0 ; <nl> - } <nl> - <nl> - NS_CC_END <nl> deleted file mode 100644 <nl> index c748f0ada542 . . 000000000000 <nl> mmm a / cocos / platform / cocoa / CCSet . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2010 - 2012 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # ifndef __CC_SET_H__ <nl> - # define __CC_SET_H__ <nl> - <nl> - # include < set > <nl> - # include " CCObject . h " <nl> - <nl> - NS_CC_BEGIN <nl> - <nl> - / * * <nl> - * @ addtogroup data_structures <nl> - * @ { <nl> - * / <nl> - <nl> - typedef std : : set < Object * > : : iterator SetIterator ; <nl> - <nl> - class CC_DLL Set : public Object <nl> - { <nl> - public : <nl> - / * * <nl> - * @ js ctor <nl> - * / <nl> - Set ( void ) ; <nl> - Set ( const Set & rSetObject ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - virtual ~ Set ( void ) ; <nl> - <nl> - / * * <nl> - * @ brief Create and return a new empty set . <nl> - * / <nl> - static Set * create ( ) ; <nl> - <nl> - / * * <nl> - * @ brief Return a copy of the Set , it will copy all the elements . <nl> - * / <nl> - Set * copy ( ) ; <nl> - / * * <nl> - * @ brief It is the same as copy ( ) . <nl> - * / <nl> - Set * mutableCopy ( ) ; <nl> - / * * <nl> - * @ brief Return the number of elements the Set contains . <nl> - * / <nl> - int count ( ) ; <nl> - / * * <nl> - * @ brief Add a element into Set , it will retain the element . <nl> - * / <nl> - void addObject ( Object * pObject ) ; <nl> - / * * <nl> - * @ brief Remove the given element , nothing todo if no element equals pObject . <nl> - * / <nl> - void removeObject ( Object * pObject ) ; <nl> - / * * <nl> - * @ brief Remove all elements of the set <nl> - * / <nl> - void removeAllObjects ( ) ; <nl> - / * * <nl> - * @ brief Check if Set contains a element equals pObject . <nl> - * / <nl> - bool containsObject ( Object * pObject ) ; <nl> - / * * <nl> - * @ brief Return the iterator that points to the first element . <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - SetIterator begin ( ) ; <nl> - / * * <nl> - * @ brief Return the iterator that points to the position after the last element . <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - SetIterator end ( ) ; <nl> - / * * <nl> - * @ brief Return the first element if it contains elements , or null if it doesn ' t contain any element . <nl> - * / <nl> - Object * anyObject ( ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - virtual void acceptVisitor ( DataVisitor & visitor ) ; <nl> - <nl> - private : <nl> - std : : set < Object * > * _set ; <nl> - } ; <nl> - <nl> - / / end of data_structure group <nl> - / / / @ } <nl> - <nl> - NS_CC_END <nl> - <nl> - # endif / / __CC_SET_H__ <nl> - <nl> deleted file mode 100644 <nl> index f9962b1ba42d . . 000000000000 <nl> mmm a / cocos / platform / cocoa / CCString . cpp <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2010 - 2012 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # include " CCString . h " <nl> - # include " platform / CCFileUtils . h " <nl> - # include " ccMacros . h " <nl> - # include < stdlib . h > <nl> - # include < stdio . h > <nl> - # include " CCArray . h " <nl> - <nl> - NS_CC_BEGIN <nl> - <nl> - # define kMaxStringLen ( 1024 * 100 ) <nl> - <nl> - String : : String ( ) <nl> - : _string ( " " ) <nl> - { } <nl> - <nl> - String : : String ( const char * str ) <nl> - : _string ( str ) <nl> - { } <nl> - <nl> - String : : String ( const std : : string & str ) <nl> - : _string ( str ) <nl> - { } <nl> - <nl> - String : : String ( const String & str ) <nl> - : _string ( str . getCString ( ) ) <nl> - { } <nl> - <nl> - String : : ~ String ( ) <nl> - { <nl> - CCLOGINFO ( " deallocing String : % p " , this ) ; <nl> - <nl> - _string . clear ( ) ; <nl> - } <nl> - <nl> - String & String : : operator = ( const String & other ) <nl> - { <nl> - _string = other . _string ; <nl> - return * this ; <nl> - } <nl> - <nl> - bool String : : initWithFormatAndValist ( const char * format , va_list ap ) <nl> - { <nl> - bool bRet = false ; <nl> - char * pBuf = ( char * ) malloc ( kMaxStringLen ) ; <nl> - if ( pBuf ! = NULL ) <nl> - { <nl> - vsnprintf ( pBuf , kMaxStringLen , format , ap ) ; <nl> - _string = pBuf ; <nl> - free ( pBuf ) ; <nl> - bRet = true ; <nl> - } <nl> - return bRet ; <nl> - } <nl> - <nl> - bool String : : initWithFormat ( const char * format , . . . ) <nl> - { <nl> - bool bRet = false ; <nl> - _string . clear ( ) ; <nl> - <nl> - va_list ap ; <nl> - va_start ( ap , format ) ; <nl> - <nl> - bRet = initWithFormatAndValist ( format , ap ) ; <nl> - <nl> - va_end ( ap ) ; <nl> - <nl> - return bRet ; <nl> - } <nl> - <nl> - int String : : intValue ( ) const <nl> - { <nl> - if ( length ( ) = = 0 ) <nl> - { <nl> - return 0 ; <nl> - } <nl> - return atoi ( _string . c_str ( ) ) ; <nl> - } <nl> - <nl> - unsigned int String : : uintValue ( ) const <nl> - { <nl> - if ( length ( ) = = 0 ) <nl> - { <nl> - return 0 ; <nl> - } <nl> - return ( unsigned int ) atoi ( _string . c_str ( ) ) ; <nl> - } <nl> - <nl> - float String : : floatValue ( ) const <nl> - { <nl> - if ( length ( ) = = 0 ) <nl> - { <nl> - return 0 . 0f ; <nl> - } <nl> - return ( float ) atof ( _string . c_str ( ) ) ; <nl> - } <nl> - <nl> - double String : : doubleValue ( ) const <nl> - { <nl> - if ( length ( ) = = 0 ) <nl> - { <nl> - return 0 . 0 ; <nl> - } <nl> - return atof ( _string . c_str ( ) ) ; <nl> - } <nl> - <nl> - bool String : : boolValue ( ) const <nl> - { <nl> - if ( length ( ) = = 0 ) <nl> - { <nl> - return false ; <nl> - } <nl> - <nl> - if ( 0 = = strcmp ( _string . c_str ( ) , " 0 " ) | | 0 = = strcmp ( _string . c_str ( ) , " false " ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - return true ; <nl> - } <nl> - <nl> - const char * String : : getCString ( ) const <nl> - { <nl> - return _string . c_str ( ) ; <nl> - } <nl> - <nl> - unsigned int String : : length ( ) const <nl> - { <nl> - return _string . length ( ) ; <nl> - } <nl> - <nl> - int String : : compare ( const char * pStr ) const <nl> - { <nl> - return strcmp ( getCString ( ) , pStr ) ; <nl> - } <nl> - <nl> - void String : : append ( const std : : string & str ) <nl> - { <nl> - _string . append ( str ) ; <nl> - } <nl> - <nl> - void String : : appendWithFormat ( const char * format , . . . ) <nl> - { <nl> - va_list ap ; <nl> - va_start ( ap , format ) ; <nl> - <nl> - char * pBuf = ( char * ) malloc ( kMaxStringLen ) ; <nl> - if ( pBuf ! = NULL ) <nl> - { <nl> - vsnprintf ( pBuf , kMaxStringLen , format , ap ) ; <nl> - _string . append ( pBuf ) ; <nl> - free ( pBuf ) ; <nl> - } <nl> - <nl> - va_end ( ap ) ; <nl> - <nl> - } <nl> - <nl> - Array * String : : componentsSeparatedByString ( const char * delimiter ) <nl> - { <nl> - Array * result = Array : : create ( ) ; <nl> - <nl> - int cutAt ; <nl> - while ( ( cutAt = _string . find_first_of ( delimiter ) ) ! = _string . npos ) <nl> - { <nl> - if ( cutAt > 0 ) <nl> - { <nl> - result - > addObject ( String : : create ( _string . substr ( 0 , cutAt ) ) ) ; <nl> - } <nl> - _string = _string . substr ( cutAt + 1 ) ; <nl> - } <nl> - <nl> - if ( _string . length ( ) > 0 ) <nl> - { <nl> - result - > addObject ( String : : create ( _string ) ) ; <nl> - } <nl> - <nl> - return result ; <nl> - } <nl> - <nl> - bool String : : isEqual ( const Object * pObject ) <nl> - { <nl> - bool bRet = false ; <nl> - const String * pStr = dynamic_cast < const String * > ( pObject ) ; <nl> - if ( pStr ! = NULL ) <nl> - { <nl> - if ( 0 = = _string . compare ( pStr - > _string ) ) <nl> - { <nl> - bRet = true ; <nl> - } <nl> - } <nl> - return bRet ; <nl> - } <nl> - <nl> - String * String : : create ( const std : : string & str ) <nl> - { <nl> - String * pRet = new String ( str ) ; <nl> - pRet - > autorelease ( ) ; <nl> - return pRet ; <nl> - } <nl> - <nl> - String * String : : createWithData ( const unsigned char * pData , unsigned long nLen ) <nl> - { <nl> - String * pRet = NULL ; <nl> - if ( pData ! = NULL ) <nl> - { <nl> - char * pStr = ( char * ) malloc ( nLen + 1 ) ; <nl> - if ( pStr ! = NULL ) <nl> - { <nl> - pStr [ nLen ] = ' \ 0 ' ; <nl> - if ( nLen > 0 ) <nl> - { <nl> - memcpy ( pStr , pData , nLen ) ; <nl> - } <nl> - <nl> - pRet = String : : create ( pStr ) ; <nl> - free ( pStr ) ; <nl> - } <nl> - } <nl> - return pRet ; <nl> - } <nl> - <nl> - String * String : : createWithFormat ( const char * format , . . . ) <nl> - { <nl> - String * pRet = String : : create ( " " ) ; <nl> - va_list ap ; <nl> - va_start ( ap , format ) ; <nl> - pRet - > initWithFormatAndValist ( format , ap ) ; <nl> - va_end ( ap ) ; <nl> - <nl> - return pRet ; <nl> - } <nl> - <nl> - String * String : : createWithContentsOfFile ( const char * filename ) <nl> - { <nl> - unsigned long size = 0 ; <nl> - unsigned char * pData = 0 ; <nl> - String * pRet = NULL ; <nl> - pData = FileUtils : : getInstance ( ) - > getFileData ( filename , " rb " , & size ) ; <nl> - pRet = String : : createWithData ( pData , size ) ; <nl> - CC_SAFE_DELETE_ARRAY ( pData ) ; <nl> - return pRet ; <nl> - } <nl> - <nl> - void String : : acceptVisitor ( DataVisitor & visitor ) <nl> - { <nl> - visitor . visit ( this ) ; <nl> - } <nl> - <nl> - String * String : : clone ( ) const <nl> - { <nl> - return String : : create ( _string ) ; <nl> - } <nl> - <nl> - NS_CC_END <nl> deleted file mode 100644 <nl> index a6f237a4762b . . 000000000000 <nl> mmm a / cocos / platform / cocoa / CCString . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2010 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - # ifndef __CCSTRING_H__ <nl> - # define __CCSTRING_H__ <nl> - <nl> - # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_BLACKBERRY ) <nl> - # include < string . h > <nl> - # endif <nl> - <nl> - # include < stdarg . h > <nl> - # include < string > <nl> - # include < functional > <nl> - # include " CCObject . h " <nl> - <nl> - NS_CC_BEGIN <nl> - <nl> - / * * <nl> - * @ addtogroup data_structures <nl> - * @ { <nl> - * / <nl> - <nl> - class CC_DLL String : public Object , public Clonable <nl> - { <nl> - public : <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - String ( ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - String ( const char * str ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - String ( const std : : string & str ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - String ( const String & str ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - virtual ~ String ( ) ; <nl> - <nl> - / * override assignment operator <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - String & operator = ( const String & other ) ; <nl> - <nl> - / * * init a string with format , it ' s similar with the c function ' sprintf ' <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - bool initWithFormat ( const char * format , . . . ) CC_FORMAT_PRINTF ( 2 , 3 ) ; <nl> - <nl> - / * * convert to int value <nl> - * @ js NA <nl> - * / <nl> - int intValue ( ) const ; <nl> - <nl> - / * * convert to unsigned int value <nl> - * @ js NA <nl> - * / <nl> - unsigned int uintValue ( ) const ; <nl> - <nl> - / * * convert to float value <nl> - * @ js NA <nl> - * / <nl> - float floatValue ( ) const ; <nl> - <nl> - / * * convert to double value <nl> - * @ js NA <nl> - * / <nl> - double doubleValue ( ) const ; <nl> - <nl> - / * * convert to bool value <nl> - * @ js NA <nl> - * / <nl> - bool boolValue ( ) const ; <nl> - <nl> - / * * get the C string <nl> - * @ js NA <nl> - * / <nl> - const char * getCString ( ) const ; <nl> - <nl> - / * * get the length of string <nl> - * @ js NA <nl> - * / <nl> - unsigned int length ( ) const ; <nl> - <nl> - / * * compare to a c string <nl> - * @ js NA <nl> - * / <nl> - int compare ( const char * ) const ; <nl> - <nl> - / * * append additional characters at the end of its current value <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - void append ( const std : : string & str ) ; <nl> - <nl> - / * * append ( w / format ) additional characters at the end of its current value <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - void appendWithFormat ( const char * format , . . . ) ; <nl> - <nl> - / * * split a string <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - Array * componentsSeparatedByString ( const char * delimiter ) ; <nl> - <nl> - / * override functions <nl> - * @ js NA <nl> - * / <nl> - virtual bool isEqual ( const Object * pObject ) ; <nl> - <nl> - / * * create a string with std string , you can also pass a c string pointer because the default constructor of std : : string can access a c string pointer . <nl> - * @ return A String pointer which is an autorelease object pointer , <nl> - * it means that you needn ' t do a release operation unless you retain it . <nl> - * @ js NA <nl> - * / <nl> - static String * create ( const std : : string & str ) ; <nl> - <nl> - / * * create a string with format , it ' s similar with the c function ' sprintf ' , the default buffer size is ( 1024 * 100 ) bytes , <nl> - * if you want to change it , you should modify the kMaxStringLen macro in String . cpp file . <nl> - * @ return A String pointer which is an autorelease object pointer , <nl> - * it means that you needn ' t do a release operation unless you retain it . <nl> - * @ js NA <nl> - * / <nl> - static String * createWithFormat ( const char * format , . . . ) CC_FORMAT_PRINTF ( 1 , 2 ) ; <nl> - <nl> - / * * create a string with binary data <nl> - * @ return A String pointer which is an autorelease object pointer , <nl> - * it means that you needn ' t do a release operation unless you retain it . <nl> - * @ js NA <nl> - * / <nl> - static String * createWithData ( const unsigned char * pData , unsigned long nLen ) ; <nl> - <nl> - / * * create a string with a file , <nl> - * @ return A String pointer which is an autorelease object pointer , <nl> - * it means that you needn ' t do a release operation unless you retain it . <nl> - * @ js NA <nl> - * / <nl> - static String * createWithContentsOfFile ( const char * filename ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - virtual void acceptVisitor ( DataVisitor & visitor ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - virtual String * clone ( ) const ; <nl> - <nl> - private : <nl> - <nl> - / * * only for internal use * / <nl> - bool initWithFormatAndValist ( const char * format , va_list ap ) ; <nl> - <nl> - public : <nl> - std : : string _string ; <nl> - } ; <nl> - <nl> - struct StringCompare : public std : : binary_function < String * , String * , bool > { <nl> - public : <nl> - bool operator ( ) ( String * a , String * b ) const { <nl> - return strcmp ( a - > getCString ( ) , b - > getCString ( ) ) < 0 ; <nl> - } <nl> - } ; <nl> - <nl> - # define StringMake ( str ) String : : create ( str ) <nl> - # define ccs StringMake <nl> - <nl> - / / end of data_structure group <nl> - / / / @ } <nl> - <nl> - NS_CC_END <nl> - <nl> - # endif / / __CCSTRING_H__ <nl>
Merge pull request from minggo / remove - subfolder
cocos2d/cocos2d-x
1751cc3d890f8f17c39350b726ec90b7f3f1d306
2013-10-14T01:40:02Z
mmm a / tensorflow / contrib / tpu / python / tpu / keras_support . py <nl> ppp b / tensorflow / contrib / tpu / python / tpu / keras_support . py <nl> def _cross_replica_concat ( tensor , core_id , num_cores , name ) : <nl> ' { } . ' . format ( input_dtype , name ) ) <nl> <nl> batch_size = tensor . shape [ 0 ] <nl> - mask = math_ops . to_float ( math_ops . equal ( range ( num_cores ) , core_id ) ) <nl> + mask = math_ops . to_float ( <nl> + math_ops . equal ( np . arange ( num_cores , dtype = np . int32 ) , core_id ) ) <nl> mask = array_ops . reshape ( mask , [ num_cores ] + [ 1 ] * tensor . shape . ndims ) <nl> result = mask * math_ops . to_float ( tensor ) <nl> local_tensor_with_holes = array_ops . reshape ( result , <nl>
Fix Keras support in Python 3 . ( )
tensorflow/tensorflow
0e525204967f7eaf01e79c9a651a3dd1f1d4d3c1
2018-10-11T23:36:57Z
mmm a / src / catch2 / reporters / catch_reporter_xml . cpp <nl> ppp b / src / catch2 / reporters / catch_reporter_xml . cpp <nl> namespace Catch { <nl> . writeAttribute ( " successes " , testGroupStats . totals . assertions . passed ) <nl> . writeAttribute ( " failures " , testGroupStats . totals . assertions . failed ) <nl> . writeAttribute ( " expectedFailures " , testGroupStats . totals . assertions . failedButOk ) ; <nl> + m_xml . scopedElement ( " OverallResultsCases " ) <nl> + . writeAttribute ( " successes " , testGroupStats . totals . testCases . passed ) <nl> + . writeAttribute ( " failures " , testGroupStats . totals . testCases . failed ) <nl> + . writeAttribute ( " expectedFailures " , testGroupStats . totals . testCases . failedButOk ) ; <nl> m_xml . endElement ( ) ; <nl> } <nl> <nl> namespace Catch { <nl> . writeAttribute ( " successes " , testRunStats . totals . assertions . passed ) <nl> . writeAttribute ( " failures " , testRunStats . totals . assertions . failed ) <nl> . writeAttribute ( " expectedFailures " , testRunStats . totals . assertions . failedButOk ) ; <nl> + m_xml . scopedElement ( " OverallResultsCases " ) <nl> + . writeAttribute ( " successes " , testRunStats . totals . testCases . passed ) <nl> + . writeAttribute ( " failures " , testRunStats . totals . testCases . failed ) <nl> + . writeAttribute ( " expectedFailures " , testRunStats . totals . testCases . failedButOk ) ; <nl> m_xml . endElement ( ) ; <nl> } <nl> <nl> mmm a / tests / SelfTest / Baselines / xml . sw . approved . txt <nl> ppp b / tests / SelfTest / Baselines / xml . sw . approved . txt <nl> loose text artifact <nl> < OverallResult success = " true " / > <nl> < / TestCase > <nl> < OverallResults successes = " 1789 " failures = " 149 " expectedFailures = " 21 " / > <nl> + < OverallResultsCases successes = " 253 " failures = " 86 " expectedFailures = " 4 " / > <nl> < / Group > <nl> < OverallResults successes = " 1789 " failures = " 148 " expectedFailures = " 21 " / > <nl> + < OverallResultsCases successes = " 253 " failures = " 86 " expectedFailures = " 4 " / > <nl> < / Catch > <nl>
Add OverallResultsCases element to XML reporter
catchorg/Catch2
7f5884016313989fd52a09a4c030fa441d3fd99a
2020-07-24T20:30:28Z
mmm a / src / qt / bitcoin . cpp <nl> ppp b / src / qt / bitcoin . cpp <nl> void BitcoinApplication : : initializeResult ( bool success ) <nl> } <nl> # endif <nl> <nl> - / / If - min option passed , start window minimized . <nl> - if ( gArgs . GetBoolArg ( " - min " , false ) ) <nl> - { <nl> - window - > showMinimized ( ) ; <nl> - } <nl> - else <nl> - { <nl> + / / If - min option passed , start window minimized ( iconified ) or minimized to tray <nl> + if ( ! gArgs . GetBoolArg ( " - min " , false ) ) { <nl> window - > show ( ) ; <nl> + } else if ( clientModel - > getOptionsModel ( ) - > getMinimizeToTray ( ) & & window - > hasTrayIcon ( ) ) { <nl> + / / do nothing as the window is managed by the tray icon <nl> + } else { <nl> + window - > showMinimized ( ) ; <nl> } <nl> Q_EMIT splashFinished ( ) ; <nl> Q_EMIT windowShown ( window ) ; <nl> mmm a / src / qt / bitcoingui . h <nl> ppp b / src / qt / bitcoingui . h <nl> class BitcoinGUI : public QMainWindow <nl> # endif / / ENABLE_WALLET <nl> bool enableWallet = false ; <nl> <nl> + / * * Get the tray icon status . <nl> + Some systems have not " system tray " or " notification area " available . <nl> + * / <nl> + bool hasTrayIcon ( ) const { return trayIcon ; } <nl> + <nl> protected : <nl> void changeEvent ( QEvent * e ) ; <nl> void closeEvent ( QCloseEvent * event ) ; <nl>
Merge : qt : Fix start with the ` - min ` option
bitcoin/bitcoin
0ed279cb4e4198e20a552c279c09134626bbb0bd
2019-01-09T18:44:43Z
mmm a / util / automation . py <nl> ppp b / util / automation . py <nl> <nl> import sys <nl> import shutil <nl> import subprocess <nl> + import datetime <nl> <nl> from glob import glob <nl> from xdg import BaseDirectory <nl> def get_github_compare_url ( last_sha1 ) : <nl> " " " <nl> return ' % s / repos / % s / % s / compare / % s . . . % s ' % ( GITHUB_API_BASE , MOZILLA_GITHUB_ACCOUNT , DEEPSPEECH_GITHUB_PROJ , last_sha1 , DEEPSPEECH_GITHUB_REF ) <nl> <nl> + def git_date ( d ) : <nl> + " " " <nl> + Returns datetime object from a git date <nl> + " " " <nl> + return datetime . datetime . strptime ( d , ' % Y - % m - % dT % H : % M : % SZ ' ) <nl> + <nl> + def is_webflow ( commit ) : <nl> + " " " <nl> + Check if commit is a valid " webflow " commit , i . e . , whose committer is web - flow <nl> + " " " <nl> + return commit [ ' committer ' ] and ( commit [ ' committer ' ] [ ' login ' ] = = ' web - flow ' ) <nl> + <nl> + def is_newer ( refdate , commit ) : <nl> + " " " <nl> + Check is a merge commit is a GitHub newer one <nl> + " " " <nl> + c = commit [ ' commit ' ] [ ' committer ' ] <nl> + return c and ( c [ ' name ' ] = = ' GitHub ' ) and ( git_date ( c [ ' date ' ] ) > = refdate ) <nl> + <nl> def get_current_sha1 ( ) : <nl> r = requests . get ( get_github_ref_url ( ) ) <nl> if r . status_code is not 200 : <nl> def get_new_commits ( sha1_from ) : <nl> return None , r . status_code <nl> payload = json . loads ( r . text ) <nl> <nl> + this_merge_date = git_date ( payload [ ' base_commit ' ] [ ' commit ' ] [ ' committer ' ] [ ' date ' ] ) <nl> + <nl> if payload [ ' status ' ] = = ' identical ' : <nl> # When there is no change , just nicely output no new commits <nl> return [ ] , r . status_code <nl> elif payload [ ' status ' ] = = ' ahead ' : <nl> # Let us just keep the merges commits , we can identify them because they <nl> # are the commits with two parents <nl> - merges = filter ( lambda x : len ( x [ ' parents ' ] ) > = 2 , payload [ ' commits ' ] ) <nl> - return map ( lambda x : x [ ' sha ' ] , merges ) , r . status_code <nl> + all_merges = filter ( lambda x : len ( x [ ' parents ' ] ) > = 2 , payload [ ' commits ' ] ) <nl> + # Keep only merges made from Github UI <nl> + gh_merges = filter ( lambda x : is_webflow ( x ) , all_merges ) <nl> + # Keep only merges with committer date > = this_merge_date <nl> + new_merges = filter ( lambda x : is_newer ( this_merge_date , x ) , gh_merges ) <nl> + return map ( lambda x : x [ ' sha ' ] , new_merges ) , r . status_code <nl> <nl> # Should not happen <nl> return None , r . status_code <nl> def exec_wer_run ( ) : <nl> print " Error with git repo handling . " <nl> sys_exit_safe ( ) <nl> <nl> + print " Ready for " , sha <nl> + <nl> print " Let us place ourselves into the git clone directory . . . " <nl> root_dir = os . getcwd ( ) <nl> os . chdir ( DEEPSPEECH_CLONE_PATH ) <nl>
Verify date of merges when pulling list of changes
mozilla/DeepSpeech
fa0fc1443925fe60f71dd436e55e685b0077bf99
2016-11-08T13:11:34Z
mmm a / xbmc / addons / AddonBuilder . cpp <nl> ppp b / xbmc / addons / AddonBuilder . cpp <nl> std : : shared_ptr < IAddon > CAddonBuilder : : Build ( ) <nl> case ADDON_SCRAPER_TVSHOWS : <nl> case ADDON_SCRAPER_LIBRARY : <nl> return CScraper : : FromExtension ( std : : move ( m_addonInfo ) , m_extPoint ) ; <nl> + case ADDON_IMAGEDECODER : <nl> case ADDON_VIZ : <nl> case ADDON_SCREENSAVER : <nl> return std : : make_shared < CAddonDll > ( std : : move ( m_addonInfo ) ) ; <nl> std : : shared_ptr < IAddon > CAddonBuilder : : Build ( ) <nl> return CAudioEncoder : : FromExtension ( std : : move ( m_addonInfo ) , m_extPoint ) ; <nl> case ADDON_AUDIODECODER : <nl> return CAudioDecoder : : FromExtension ( std : : move ( m_addonInfo ) , m_extPoint ) ; <nl> - case ADDON_IMAGEDECODER : <nl> - return CImageDecoder : : FromExtension ( std : : move ( m_addonInfo ) , m_extPoint ) ; <nl> case ADDON_INPUTSTREAM : <nl> return CInputStream : : FromExtension ( std : : move ( m_addonInfo ) , m_extPoint ) ; <nl> case ADDON_PERIPHERALDLL : <nl> AddonPtr CAddonBuilder : : FromProps ( CAddonInfo addonInfo ) <nl> return AddonPtr ( new CScraper ( std : : move ( addonInfo ) ) ) ; <nl> case ADDON_SKIN : <nl> return AddonPtr ( new CSkinInfo ( std : : move ( addonInfo ) ) ) ; <nl> + case ADDON_IMAGEDECODER : <nl> case ADDON_VIZ : <nl> case ADDON_SCREENSAVER : <nl> return AddonPtr ( new CAddonDll ( std : : move ( addonInfo ) ) ) ; <nl> AddonPtr CAddonBuilder : : FromProps ( CAddonInfo addonInfo ) <nl> return AddonPtr ( new GAME : : CController ( std : : move ( addonInfo ) ) ) ; <nl> case ADDON_GAMEDLL : <nl> return AddonPtr ( new GAME : : CGameClient ( std : : move ( addonInfo ) ) ) ; <nl> - case ADDON_IMAGEDECODER : <nl> - return AddonPtr ( new CImageDecoder ( std : : move ( addonInfo ) ) ) ; <nl> case ADDON_VFS : <nl> return AddonPtr ( new CVFSEntry ( std : : move ( addonInfo ) , " " , " " , false , false , false ) ) ; <nl> default : <nl> mmm a / xbmc / addons / BinaryAddonCache . cpp <nl> ppp b / xbmc / addons / BinaryAddonCache . cpp <nl> void CBinaryAddonCache : : Init ( ) <nl> { <nl> m_addonsToCache = { <nl> ADDON_AUDIODECODER , <nl> - ADDON_IMAGEDECODER , <nl> ADDON_INPUTSTREAM , <nl> ADDON_PVRDLL , <nl> ADDON_GAMEDLL , <nl> mmm a / xbmc / addons / ImageDecoder . cpp <nl> ppp b / xbmc / addons / ImageDecoder . cpp <nl> <nl> * < http : / / www . gnu . org / licenses / > . <nl> * <nl> * / <nl> + <nl> # include " ImageDecoder . h " <nl> - # include " kodi - addon - dev - kit / include / kodi / kodi_imagedec_types . h " <nl> # include " guilib / TextureFormats . h " <nl> <nl> static const std : : map < int , int > KodiToAddonFormat = { { XB_FMT_A8R8G8B8 , ADDON_IMG_FMT_A8R8G8B8 } , <nl> static const std : : map < int , int > KodiToAddonFormat = { { XB_FMT_A8R8G8B8 , ADDON_IMG_ <nl> namespace ADDON <nl> { <nl> <nl> - std : : unique_ptr < CImageDecoder > <nl> - CImageDecoder : : FromExtension ( CAddonInfo & & addonInfo , const cp_extension_t * ext ) <nl> - { <nl> - std : : string mime = CAddonMgr : : GetInstance ( ) . GetExtValue ( ext - > configuration , " @ mimetype " ) ; <nl> - std : : string extension = CAddonMgr : : GetInstance ( ) . GetExtValue ( ext - > configuration , " @ extension " ) ; <nl> - return std : : unique_ptr < CImageDecoder > ( new CImageDecoder ( std : : move ( addonInfo ) , <nl> - std : : move ( mime ) , <nl> - std : : move ( extension ) ) ) ; <nl> - } <nl> - <nl> - CImageDecoder : : CImageDecoder ( CAddonInfo & & addonInfo , std : : string mime , std : : string extension ) : <nl> - CAddonDll ( std : : move ( addonInfo ) ) , <nl> - m_mimetype ( std : : move ( mime ) ) , <nl> - m_extension ( std : : move ( extension ) ) <nl> + CImageDecoder : : CImageDecoder ( BinaryAddonBasePtr addonBase ) <nl> + : IAddonInstanceHandler ( ADDON_INSTANCE_IMAGEDECODER , addonBase ) <nl> { <nl> } <nl> <nl> CImageDecoder : : ~ CImageDecoder ( ) <nl> { <nl> - if ( m_image & & Initialized ( ) ) <nl> - m_struct . toAddon . Close ( m_image ) ; <nl> + DestroyInstance ( ) ; <nl> } <nl> <nl> bool CImageDecoder : : LoadImageFromMemory ( unsigned char * buffer , unsigned int bufSize , <nl> unsigned int width , unsigned int height ) <nl> { <nl> - if ( ! Initialized ( ) ) <nl> + if ( ! m_struct . toAddon . load_image_from_memory ) <nl> return false ; <nl> <nl> m_width = width ; <nl> m_height = height ; <nl> - m_image = m_struct . toAddon . LoadImage ( buffer , bufSize , & m_width , & m_height ) ; <nl> - <nl> - return m_image ! = nullptr ; <nl> + return m_struct . toAddon . load_image_from_memory ( & m_struct , buffer , bufSize , & m_width , & m_height ) ; <nl> } <nl> <nl> bool CImageDecoder : : Decode ( unsigned char * const pixels , unsigned int width , <nl> unsigned int height , unsigned int pitch , <nl> unsigned int format ) <nl> { <nl> - if ( ! Initialized ( ) ) <nl> + if ( ! m_struct . toAddon . decode ) <nl> return false ; <nl> <nl> auto it = KodiToAddonFormat . find ( format & XB_FMT_MASK ) ; <nl> if ( it = = KodiToAddonFormat . end ( ) ) <nl> return false ; <nl> <nl> - bool result = m_struct . toAddon . Decode ( m_image , pixels , width , height , pitch , it - > second ) ; <nl> + bool result = m_struct . toAddon . decode ( & m_struct , pixels , width , height , pitch , it - > second ) ; <nl> m_width = width ; <nl> m_height = height ; <nl> <nl> bool CImageDecoder : : Decode ( unsigned char * const pixels , unsigned int width , <nl> bool CImageDecoder : : Create ( const std : : string & mimetype ) <nl> { <nl> m_struct . props . mimetype = mimetype . c_str ( ) ; <nl> - m_struct . toKodi . kodiInstance = this ; <nl> - return CAddonDll : : Create ( ADDON_INSTANCE_IMAGEDECODER , & m_struct , & m_struct . props ) = = ADDON_STATUS_OK ; <nl> + m_struct . toKodi . kodi_instance = this ; <nl> + return CreateInstance ( & m_struct ) ; <nl> } <nl> <nl> } / * namespace ADDON * / <nl> mmm a / xbmc / addons / ImageDecoder . h <nl> ppp b / xbmc / addons / ImageDecoder . h <nl> <nl> * / <nl> # pragma once <nl> <nl> - # include " addons / binary - addons / AddonDll . h " <nl> - # include " addons / kodi - addon - dev - kit / include / kodi / kodi_imagedec_types . h " <nl> + # include " addons / kodi - addon - dev - kit / include / kodi / addon - instance / ImageDecoder . h " <nl> + # include " addons / binary - addons / AddonInstanceHandler . h " <nl> # include " guilib / iimage . h " <nl> <nl> namespace ADDON <nl> { <nl> - class CImageDecoder : public CAddonDll , <nl> + class CImageDecoder : public IAddonInstanceHandler , <nl> public IImage <nl> { <nl> public : <nl> - static std : : unique_ptr < CImageDecoder > FromExtension ( CAddonInfo & & , <nl> - const cp_extension_t * ext ) ; <nl> - explicit CImageDecoder ( CAddonInfo addonInfo ) : <nl> - CAddonDll ( std : : move ( addonInfo ) ) <nl> - { } <nl> - <nl> - CImageDecoder ( CAddonInfo & & addonInfo , std : : string mimetypes , std : : string extensions ) ; <nl> + CImageDecoder ( ADDON : : BinaryAddonBasePtr addonBase ) ; <nl> virtual ~ CImageDecoder ( ) ; <nl> <nl> bool Create ( const std : : string & mimetype ) ; <nl> namespace ADDON <nl> <nl> const std : : string & GetMimetypes ( ) const { return m_mimetype ; } <nl> const std : : string & GetExtensions ( ) const { return m_extension ; } <nl> + <nl> protected : <nl> - void * m_image = nullptr ; <nl> std : : string m_mimetype ; <nl> std : : string m_extension ; <nl> AddonInstance_ImageDecoder m_struct = { } ; <nl> new file mode 100644 <nl> index 000000000000 . . 617b05f06923 <nl> mmm / dev / null <nl> ppp b / xbmc / addons / kodi - addon - dev - kit / include / kodi / addon - instance / ImageDecoder . h <nl> <nl> + # pragma once <nl> + / * <nl> + * Copyright ( C ) 2005 - 2017 Team Kodi <nl> + * http : / / kodi . tv <nl> + * <nl> + * This Program is free software ; you can redistribute it and / or modify <nl> + * it under the terms of the GNU General Public License as published by <nl> + * the Free Software Foundation ; either version 2 , or ( at your option ) <nl> + * any later version . <nl> + * <nl> + * This Program is distributed in the hope that it will be useful , <nl> + * but WITHOUT ANY WARRANTY ; without even the implied warranty of <nl> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the <nl> + * GNU General Public License for more details . <nl> + * <nl> + * You should have received a copy of the GNU General Public License <nl> + * along with Kodi ; see the file COPYING . If not , see <nl> + * < http : / / www . gnu . org / licenses / > . <nl> + * <nl> + * / <nl> + <nl> + # include " . . / AddonBase . h " <nl> + <nl> + namespace kodi { namespace addon { class CInstanceImageDecoder ; } } <nl> + <nl> + extern " C " <nl> + { <nl> + <nl> + typedef struct AddonProps_ImageDecoder <nl> + { <nl> + const char * mimetype ; <nl> + } AddonProps_ImageDecoder ; <nl> + <nl> + typedef struct AddonToKodiFuncTable_ImageDecoder <nl> + { <nl> + KODI_HANDLE kodi_instance ; <nl> + } AddonToKodiFuncTable_ImageDecoder ; <nl> + <nl> + struct AddonInstance_ImageDecoder ; <nl> + typedef struct KodiToAddonFuncTable_ImageDecoder <nl> + { <nl> + kodi : : addon : : CInstanceImageDecoder * addonInstance ; <nl> + bool ( __cdecl * load_image_from_memory ) ( const AddonInstance_ImageDecoder * instance , <nl> + unsigned char * buffer , unsigned int buf_size , <nl> + unsigned int * width , unsigned int * height ) ; <nl> + <nl> + bool ( __cdecl * decode ) ( const AddonInstance_ImageDecoder * instance , <nl> + unsigned char * pixels , <nl> + unsigned int width , unsigned int height , <nl> + unsigned int pitch , unsigned int format ) ; <nl> + } KodiToAddonFuncTable_ImageDecoder ; <nl> + <nl> + typedef struct AddonInstance_ImageDecoder <nl> + { <nl> + AddonProps_ImageDecoder props ; <nl> + AddonToKodiFuncTable_ImageDecoder toKodi ; <nl> + KodiToAddonFuncTable_ImageDecoder toAddon ; <nl> + } AddonInstance_ImageDecoder ; <nl> + <nl> + } / * extern " C " * / <nl> + <nl> + typedef enum ImageFormat : unsigned int <nl> + { <nl> + ADDON_IMG_FMT_A8R8G8B8 = 1 , <nl> + ADDON_IMG_FMT_A8 = 2 , <nl> + ADDON_IMG_FMT_RGBA8 = 3 , <nl> + ADDON_IMG_FMT_RGB8 = 4 <nl> + } ImageFormat ; <nl> + <nl> + namespace kodi <nl> + { <nl> + namespace addon <nl> + { <nl> + <nl> + class CInstanceImageDecoder : public IAddonInstance <nl> + { <nl> + public : <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + / / / @ brief Class constructor <nl> + / / / <nl> + / / / @ param [ in ] instance The from Kodi given instance given be <nl> + / / / add - on CreateInstance call with instance <nl> + / / / id ADDON_INSTANCE_IMAGEDECODER . <nl> + CInstanceImageDecoder ( KODI_HANDLE instance ) <nl> + : IAddonInstance ( ADDON_INSTANCE_IMAGEDECODER ) <nl> + { <nl> + if ( CAddonBase : : m_interface - > globalSingleInstance ! = nullptr ) <nl> + throw std : : logic_error ( " kodi : : addon : : CInstanceImageDecoder : Creation of multiple together with single instance way is not allowed ! " ) ; <nl> + <nl> + SetAddonStruct ( instance ) ; <nl> + } <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + virtual ~ CInstanceImageDecoder ( ) = default ; <nl> + <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + / / / @ brief Initialize an encoder <nl> + / / / <nl> + / / / @ param [ in ] buffer The data to read from memory <nl> + / / / @ param [ in ] bufSize The buffer size <nl> + / / / @ param [ in , out ] width The optimal width of image on entry , obtained width on return <nl> + / / / @ param [ in , out ] height The optimal height of image , actual obtained height on return <nl> + / / / @ return true if successful done , false on error <nl> + / / / <nl> + virtual bool LoadImageFromMemory ( unsigned char * buffer , unsigned int bufSize , <nl> + unsigned int & width , unsigned int & height ) = 0 ; <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + / / / @ brief Decode previously loaded image <nl> + / / / <nl> + / / / @ param [ in ] pixels Output buffer <nl> + / / / @ param [ in ] width Width of output image <nl> + / / / @ param [ in ] height Height of output image <nl> + / / / @ param [ in ] pitch Pitch of output image <nl> + / / / @ param [ in ] format Format of output image <nl> + / / / @ return true if successful done , false on error <nl> + / / / <nl> + virtual bool Decode ( unsigned char * pixels , <nl> + unsigned int width , unsigned int height , <nl> + unsigned int pitch , ImageFormat format ) = 0 ; <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + / / / @ brief Get the wanted mime type from Kodi <nl> + / / / <nl> + / / / @ return the mimetype wanted from Kodi <nl> + / / / <nl> + inline std : : string MimeType ( ) { return m_instanceData - > props . mimetype ; } <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + private : <nl> + void SetAddonStruct ( KODI_HANDLE instance ) <nl> + { <nl> + if ( instance = = nullptr ) <nl> + throw std : : logic_error ( " kodi : : addon : : CInstanceImageDecoder : Creation with empty addon structure not allowed , table must be given from Kodi ! " ) ; <nl> + <nl> + m_instanceData = static_cast < AddonInstance_ImageDecoder * > ( instance ) ; <nl> + m_instanceData - > toAddon . addonInstance = this ; <nl> + m_instanceData - > toAddon . load_image_from_memory = ADDON_LoadImageFromMemory ; <nl> + m_instanceData - > toAddon . decode = ADDON_Decode ; <nl> + } <nl> + <nl> + inline static bool ADDON_LoadImageFromMemory ( const AddonInstance_ImageDecoder * instance , <nl> + unsigned char * buffer , unsigned int bufSize , <nl> + unsigned int * width , unsigned int * height ) <nl> + { <nl> + return instance - > toAddon . addonInstance - > LoadImageFromMemory ( buffer , bufSize , * width , * height ) ; <nl> + } <nl> + <nl> + inline static bool ADDON_Decode ( const AddonInstance_ImageDecoder * instance , <nl> + unsigned char * pixels , <nl> + unsigned int width , unsigned int height , <nl> + unsigned int pitch , unsigned int format ) <nl> + { <nl> + return instance - > toAddon . addonInstance - > Decode ( pixels , width , height , pitch , static_cast < ImageFormat > ( format ) ) ; <nl> + } <nl> + <nl> + AddonInstance_ImageDecoder * m_instanceData ; <nl> + } ; <nl> + <nl> + } / * namespace addon * / <nl> + } / * namespace kodi * / <nl> deleted file mode 100644 <nl> index a87c9c08231f . . 000000000000 <nl> mmm a / xbmc / addons / kodi - addon - dev - kit / include / kodi / kodi_imagedec_dll . h <nl> ppp / dev / null <nl> <nl> - / * <nl> - * Copyright ( C ) 2005 - 2013 Team XBMC <nl> - * http : / / xbmc . org <nl> - * <nl> - * This Program is free software ; you can redistribute it and / or modify <nl> - * it under the terms of the GNU General Public License as published by <nl> - * the Free Software Foundation ; either version 2 , or ( at your option ) <nl> - * any later version . <nl> - * <nl> - * This Program is distributed in the hope that it will be useful , <nl> - * but WITHOUT ANY WARRANTY ; without even the implied warranty of <nl> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the <nl> - * GNU General Public License for more details . <nl> - * <nl> - * You should have received a copy of the GNU General Public License <nl> - * along with XBMC ; see the file COPYING . If not , see <nl> - * < http : / / www . gnu . org / licenses / > . <nl> - * <nl> - * / <nl> - <nl> - # pragma once <nl> - <nl> - # include < stdint . h > <nl> - # include " xbmc_addon_dll . h " <nl> - # include " kodi_imagedec_types . h " <nl> - <nl> - extern " C " <nl> - { <nl> - void * LoadImage ( unsigned char * buffer , unsigned int bufSize , <nl> - unsigned int * width , unsigned int * height ) ; <nl> - <nl> - bool Decode ( void * image , unsigned char * pixels , <nl> - unsigned int width , unsigned int height , <nl> - unsigned int pitch , unsigned int format ) ; <nl> - <nl> - void Close ( void * image ) ; <nl> - <nl> - / / function to export the above structure to Kodi <nl> - void __declspec ( dllexport ) get_addon ( void * ptr ) <nl> - { <nl> - AddonInstance_ImageDecoder * img = static_cast < AddonInstance_ImageDecoder * > ( ptr ) ; <nl> - img - > toAddon . LoadImage = LoadImage ; <nl> - img - > toAddon . Decode = Decode ; <nl> - img - > toAddon . Close = Close ; <nl> - } <nl> - } ; <nl> deleted file mode 100644 <nl> index 7af585c0f47b . . 000000000000 <nl> mmm a / xbmc / addons / kodi - addon - dev - kit / include / kodi / kodi_imagedec_types . h <nl> ppp / dev / null <nl> <nl> - / * <nl> - * Copyright ( C ) 2005 - 2013 Team XBMC <nl> - * http : / / xbmc . org <nl> - * <nl> - * This Program is free software ; you can redistribute it and / or modify <nl> - * it under the terms of the GNU General Public License as published by <nl> - * the Free Software Foundation ; either version 2 , or ( at your option ) <nl> - * any later version . <nl> - * <nl> - * This Program is distributed in the hope that it will be useful , <nl> - * but WITHOUT ANY WARRANTY ; without even the implied warranty of <nl> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the <nl> - * GNU General Public License for more details . <nl> - * <nl> - * You should have received a copy of the GNU General Public License <nl> - * along with XBMC ; see the file COPYING . If not , see <nl> - * < http : / / www . gnu . org / licenses / > . <nl> - * <nl> - * / <nl> - <nl> - # pragma once <nl> - <nl> - # include < stdint . h > <nl> - <nl> - # define ADDON_IMG_FMT_A8R8G8B8 1 <nl> - # define ADDON_IMG_FMT_A8 2 <nl> - # define ADDON_IMG_FMT_RGBA8 3 <nl> - # define ADDON_IMG_FMT_RGB8 4 <nl> - <nl> - extern " C " <nl> - { <nl> - typedef struct AddonProps_ImageDecoder <nl> - { <nl> - const char * mimetype ; <nl> - } AddonProps_ImageDecoder ; <nl> - <nl> - typedef struct AddonToKodiFuncTable_ImageDecoder <nl> - { <nl> - KODI_HANDLE kodiInstance ; <nl> - } AddonToKodiFuncTable_ImageDecoder ; <nl> - <nl> - typedef struct KodiToAddonFuncTable_ImageDecoder <nl> - { <nl> - / / ! \ brief Initialize an encoder <nl> - / / ! \ param buffer The data to read from memory <nl> - / / ! \ param bufSize The buffer size <nl> - / / ! \ param width The optimal width of image on entry , obtained width on return <nl> - / / ! \ param height The optimal height of image , actual obtained height on return <nl> - / / ! \ return Image or nullptr on error <nl> - void * ( __cdecl * LoadImage ) ( unsigned char * buffer , unsigned int bufSize , <nl> - unsigned int * width , unsigned int * height ) ; <nl> - <nl> - / / ! \ brief Decode previously loaded image <nl> - / / ! \ param image Image to decode <nl> - / / ! \ param pixels Output buffer <nl> - / / ! \ param width Width of output image <nl> - / / ! \ param height Height of output image <nl> - / / ! \ param pitch Pitch of output image <nl> - / / ! \ param format Format of output image <nl> - bool ( __cdecl * Decode ) ( void * image , unsigned char * pixels , <nl> - unsigned int width , unsigned int height , <nl> - unsigned int pitch , unsigned int format ) ; <nl> - <nl> - / / ! \ brief Close an opened image <nl> - / / ! \ param image Image to close <nl> - / / ! \ return True on success , false on failure <nl> - void ( __cdecl * Close ) ( void * image ) ; <nl> - } KodiToAddonFuncTable_ImageDecoder ; <nl> - <nl> - typedef struct AddonInstance_ImageDecoder <nl> - { <nl> - AddonProps_ImageDecoder props ; <nl> - AddonToKodiFuncTable_ImageDecoder toKodi ; <nl> - KodiToAddonFuncTable_ImageDecoder toAddon ; <nl> - } AddonInstance_ImageDecoder ; <nl> - } <nl> mmm a / xbmc / addons / kodi - addon - dev - kit / include / kodi / versions . h <nl> ppp b / xbmc / addons / kodi - addon - dev - kit / include / kodi / versions . h <nl> <nl> " kodi_game_types . h " \ <nl> " libKODI_game . h " <nl> <nl> - # define ADDON_INSTANCE_VERSION_IMAGEDECODER " 1 . 0 . 1 " <nl> - # define ADDON_INSTANCE_VERSION_IMAGEDECODER_MIN " 1 . 0 . 1 " <nl> + # define ADDON_INSTANCE_VERSION_IMAGEDECODER " 2 . 0 . 0 " <nl> + # define ADDON_INSTANCE_VERSION_IMAGEDECODER_MIN " 2 . 0 . 0 " <nl> # define ADDON_INSTANCE_VERSION_IMAGEDECODER_XML_ID " kodi . binary . instance . imagedecoder " <nl> - # define ADDON_INSTANCE_VERSION_IMAGEDECODER_DEPENDS " kodi_imagedec_dll . h " \ <nl> - " kodi_imagedec_types . h " <nl> + # define ADDON_INSTANCE_VERSION_IMAGEDECODER_DEPENDS " addon - instance / ImageDecoder . h " <nl> <nl> # define ADDON_INSTANCE_VERSION_INPUTSTREAM " 1 . 0 . 8 " <nl> # define ADDON_INSTANCE_VERSION_INPUTSTREAM_MIN " 1 . 0 . 8 " <nl> mmm a / xbmc / guilib / imagefactory . cpp <nl> ppp b / xbmc / guilib / imagefactory . cpp <nl> <nl> <nl> # include " imagefactory . h " <nl> # include " guilib / FFmpegImage . h " <nl> - # include " addons / BinaryAddonCache . h " <nl> # include " addons / ImageDecoder . h " <nl> + # include " addons / binary - addons / BinaryAddonBase . h " <nl> # include " utils / Mime . h " <nl> # include " utils / StringUtils . h " <nl> # include " ServiceBroker . h " <nl> IImage * ImageFactory : : CreateLoader ( const CURL & url ) <nl> <nl> IImage * ImageFactory : : CreateLoaderFromMimeType ( const std : : string & strMimeType ) <nl> { <nl> - VECADDONS codecs ; <nl> - ADDON : : CBinaryAddonCache & addonCache = CServiceBroker : : GetBinaryAddonCache ( ) ; <nl> - addonCache . GetAddons ( codecs , ADDON : : ADDON_IMAGEDECODER ) ; <nl> - for ( auto & codec : codecs ) <nl> + BinaryAddonBaseList addonInfos ; <nl> + <nl> + CServiceBroker : : GetBinaryAddonManager ( ) . GetAddonInfos ( addonInfos , true , ADDON_IMAGEDECODER ) ; <nl> + for ( auto addonInfo : addonInfos ) <nl> { <nl> - std : : shared_ptr < CImageDecoder > enc ( std : : static_pointer_cast < CImageDecoder > ( codec ) ) ; <nl> - std : : vector < std : : string > mime = StringUtils : : Split ( enc - > GetMimetypes ( ) , " | " ) ; <nl> + std : : vector < std : : string > mime = StringUtils : : Split ( addonInfo - > Type ( ADDON_IMAGEDECODER ) - > GetValue ( " @ mimetype " ) . asString ( ) , " | " ) ; <nl> if ( std : : find ( mime . begin ( ) , mime . end ( ) , strMimeType ) ! = mime . end ( ) ) <nl> { <nl> - CImageDecoder * result = new CImageDecoder ( * enc ) ; <nl> + CImageDecoder * result = new CImageDecoder ( addonInfo ) ; <nl> result - > Create ( strMimeType ) ; <nl> return result ; <nl> } <nl> mmm a / xbmc / settings / AdvancedSettings . cpp <nl> ppp b / xbmc / settings / AdvancedSettings . cpp <nl> <nl> # include " addons / BinaryAddonCache . h " <nl> # include " addons / IAddon . h " <nl> # include " addons / ImageDecoder . h " <nl> + # include " addons / binary - addons / BinaryAddonBase . h " <nl> # include " Application . h " <nl> # include " ServiceBroker . h " <nl> # include " filesystem / File . h " <nl> std : : string CAdvancedSettings : : GetPictureExtensions ( ) const <nl> { <nl> std : : string result ( m_pictureExtensions ) ; <nl> <nl> - VECADDONS codecs ; <nl> - CBinaryAddonCache & addonCache = CServiceBroker : : GetBinaryAddonCache ( ) ; <nl> - addonCache . GetAddons ( codecs , ADDON_IMAGEDECODER ) ; <nl> - for ( size_t i = 0 ; i < codecs . size ( ) ; + + i ) <nl> + BinaryAddonBaseList addonInfos ; <nl> + CServiceBroker : : GetBinaryAddonManager ( ) . GetAddonInfos ( addonInfos , true , ADDON_IMAGEDECODER ) ; <nl> + for ( auto addonInfo : addonInfos ) <nl> { <nl> - std : : shared_ptr < CImageDecoder > dec ( std : : static_pointer_cast < CImageDecoder > ( codecs [ i ] ) ) ; <nl> result + = ' | ' ; <nl> - result + = dec - > GetExtensions ( ) ; <nl> + result + = addonInfo - > Type ( ADDON_IMAGEDECODER ) - > GetValue ( " @ extension " ) . asString ( ) ; <nl> } <nl> <nl> return result ; <nl>
Merge pull request from AlwinEsch / change - imagedecoder
xbmc/xbmc
e1b08f6f0160698c5c331724f733f562911ef922
2017-06-19T08:29:29Z
mmm a / xbmc / windowing / X11 / WinSystemX11GLContext . cpp <nl> ppp b / xbmc / windowing / X11 / WinSystemX11GLContext . cpp <nl> bool CWinSystemX11GLContext : : RefreshGLContext ( bool force ) <nl> std : : transform ( gpuvendor . begin ( ) , gpuvendor . end ( ) , gpuvendor . begin ( ) , : : tolower ) ; <nl> bool isNvidia = ( gpuvendor . compare ( 0 , 6 , " nvidia " ) = = 0 ) ; <nl> bool isIntel = ( gpuvendor . compare ( 0 , 5 , " intel " ) = = 0 ) ; <nl> - std : : string gli = ( getenv ( " GL_INTERFACE " ) ! = nullptr ) ? getenv ( " GL_INTERFACE " ) : " " ; <nl> + std : : string gli = ( getenv ( " KODI_GL_INTERFACE " ) ! = nullptr ) ? getenv ( " KODI_GL_INTERFACE " ) : " " ; <nl> <nl> if ( gli ! = " GLX " ) <nl> { <nl>
Rename GL_INTERFACE to KODI_GL_INTERFACE
xbmc/xbmc
e543687aabc2f58bb686c491dc5fde2d5c281226
2018-06-10T08:28:55Z
mmm a / docs / en / operations / table_engines / hdfs . md <nl> ppp b / docs / en / operations / table_engines / hdfs . md <nl> SELECT * FROM hdfs_engine_table LIMIT 2 <nl> <nl> Multiple path components can have globs . For being processed file should exists and matches to the whole path pattern . Listing of files determines during ` SELECT ` ( not at ` CREATE ` moment ) . <nl> <nl> - - ` * ` — Substitutes any number of any characters except ` / ` including none . <nl> + - ` * ` — Substitutes any number of any characters except ` / ` including empty string . <nl> - ` ? ` — Substitutes any single character . <nl> - ` { some_string , another_string , yet_another_one } ` — Substitutes any of strings ` ' some_string ' , ' another_string ' , ' yet_another_one ' ` . <nl> - ` { N . . M } ` — Substitutes any number in range from N to M including both borders . <nl> mmm a / docs / en / query_language / table_functions / file . md <nl> ppp b / docs / en / query_language / table_functions / file . md <nl> SELECT * FROM file ( ' test . csv ' , ' CSV ' , ' column1 UInt32 , column2 UInt32 , column3 U <nl> <nl> Multiple path components can have globs . For being processed file should exists and matches to the whole path pattern ( not only suffix or prefix ) . <nl> <nl> - - ` * ` — Substitutes any number of any characters except ` / ` including none . <nl> + - ` * ` — Substitutes any number of any characters except ` / ` including empty string . <nl> - ` ? ` — Substitutes any single character . <nl> - ` { some_string , another_string , yet_another_one } ` — Substitutes any of strings ` ' some_string ' , ' another_string ' , ' yet_another_one ' ` . <nl> - ` { N . . M } ` — Substitutes any number in range from N to M including both borders . <nl> mmm a / docs / en / query_language / table_functions / hdfs . md <nl> ppp b / docs / en / query_language / table_functions / hdfs . md <nl> LIMIT 2 <nl> <nl> Multiple path components can have globs . For being processed file should exists and matches to the whole path pattern ( not only suffix or prefix ) . <nl> <nl> - - ` * ` — Substitutes any number of any characters except ` / ` including none . <nl> + - ` * ` — Substitutes any number of any characters except ` / ` including empty string . <nl> - ` ? ` — Substitutes any single character . <nl> - ` { some_string , another_string , yet_another_one } ` — Substitutes any of strings ` ' some_string ' , ' another_string ' , ' yet_another_one ' ` . <nl> - ` { N . . M } ` — Substitutes any number in range from N to M including both borders . <nl>
minor changes
ClickHouse/ClickHouse
433e97f9e2f4cfe1f2fb3e0753ab8dbfe61d1b39
2019-09-23T15:12:43Z
mmm a / editor / plugins / script_editor_plugin . cpp <nl> ppp b / editor / plugins / script_editor_plugin . cpp <nl> <nl> # include " editor / editor_node . h " <nl> # include " editor / editor_settings . h " <nl> # include " editor / script_editor_debugger . h " <nl> - # include " project_settings . h " <nl> # include " io / resource_loader . h " <nl> # include " io / resource_saver . h " <nl> # include " os / file_access . h " <nl> # include " os / input . h " <nl> # include " os / keyboard . h " <nl> # include " os / os . h " <nl> + # include " project_settings . h " <nl> # include " scene / main / viewport . h " <nl> <nl> / * * * SCRIPT EDITOR * * * * / <nl> void ScriptEditor : : ensure_focus_current ( ) { <nl> <nl> int cidx = tab_container - > get_current_tab ( ) ; <nl> if ( cidx < 0 | | cidx > = tab_container - > get_tab_count ( ) ) <nl> - ; <nl> + return ; <nl> + <nl> Control * c = tab_container - > get_child ( cidx ) - > cast_to < Control > ( ) ; <nl> if ( ! c ) <nl> return ; <nl> struct _ScriptEditorItemData { <nl> } ; <nl> <nl> void ScriptEditor : : _update_members_overview_visibility ( ) { <nl> + <nl> + int selected = tab_container - > get_current_tab ( ) ; <nl> + if ( selected < 0 | | selected > = tab_container - > get_child_count ( ) ) <nl> + return ; <nl> + <nl> Node * current = tab_container - > get_child ( tab_container - > get_current_tab ( ) ) ; <nl> ScriptEditorBase * se = current - > cast_to < ScriptEditorBase > ( ) ; <nl> if ( ! se ) { <nl> void ScriptEditor : : _update_members_overview_visibility ( ) { <nl> void ScriptEditor : : _update_members_overview ( ) { <nl> members_overview - > clear ( ) ; <nl> <nl> + int selected = tab_container - > get_current_tab ( ) ; <nl> + if ( selected < 0 | | selected > = tab_container - > get_child_count ( ) ) <nl> + return ; <nl> + <nl> Node * current = tab_container - > get_child ( tab_container - > get_current_tab ( ) ) ; <nl> ScriptEditorBase * se = current - > cast_to < ScriptEditorBase > ( ) ; <nl> if ( ! se ) { <nl>
ScriptEditor : suppress get_child errors
godotengine/godot
843589d9d1fecd5a0345cd08464a565c5eb9415b
2017-07-22T07:02:34Z
mmm a / scripting / javascript / bindings / ScriptingCore . cpp <nl> ppp b / scripting / javascript / bindings / ScriptingCore . cpp <nl> JSBool JSBDebug_BufferRead ( JSContext * cx , unsigned argc , jsval * vp ) <nl> <nl> static void _clientSocketWriteAndClearString ( std : : string & s ) <nl> { <nl> - : : write ( clientSocket , s . c_str ( ) , s . length ( ) ) ; <nl> + : : send ( clientSocket , s . c_str ( ) , s . length ( ) , 0 ) ; <nl> s . clear ( ) ; <nl> } <nl> <nl> static void clearBuffers ( ) { <nl> static void serverEntryPoint ( void ) <nl> { <nl> / / start a server , accept the connection and keep reading data from it <nl> - struct addrinfo hints , * result , * rp ; <nl> - int s ; <nl> + struct addrinfo hints , * result = nullptr , * rp = nullptr ; <nl> + int s = 0 ; <nl> memset ( & hints , 0 , sizeof ( struct addrinfo ) ) ; <nl> hints . ai_family = AF_INET ; / / IPv4 <nl> hints . ai_socktype = SOCK_STREAM ; / / TCP stream sockets <nl> static void serverEntryPoint ( void ) <nl> stringstream portstr ; <nl> portstr < < JSB_DEBUGGER_PORT ; <nl> <nl> - int err ; <nl> + int err = 0 ; <nl> + <nl> + # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_WIN32 ) <nl> + WSADATA wsaData ; <nl> + err = WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) ; <nl> + # endif <nl> + <nl> if ( ( err = getaddrinfo ( NULL , portstr . str ( ) . c_str ( ) , & hints , & result ) ) ! = 0 ) { <nl> LOGD ( " getaddrinfo error : % s \ n " , gai_strerror ( err ) ) ; <nl> } <nl>
issue : Fix socket errors on WINDOWS .
cocos2d/cocos2d-x
a919fd5de121fa6a9f8ce4ef74ae4d061ce0cd4a
2013-10-10T08:18:10Z
mmm a / ports / parallel - hashmap / CONTROL <nl> ppp b / ports / parallel - hashmap / CONTROL <nl> <nl> Source : parallel - hashmap <nl> - Version : 1 . 27 <nl> + Version : 1 . 30 <nl> Description : A header - only , very fast and memory - friendly family of C + + hash maps . <nl> mmm a / ports / parallel - hashmap / portfile . cmake <nl> ppp b / ports / parallel - hashmap / portfile . cmake <nl> include ( vcpkg_common_functions ) <nl> vcpkg_from_github ( <nl> OUT_SOURCE_PATH SOURCE_PATH <nl> REPO greg7mdp / parallel - hashmap <nl> - REF 1 . 27 <nl> - SHA512 2c142d111e79487d0e4fdd88841c38995f77112b1a4e3501ad91fdaf20be2f274a6b3fd6957bf41b96ff68b5d5274d40f4ac4b448a2ef4262efe8c409894d57e <nl> + REF 1 . 30 <nl> + SHA512 5c2f4d1f50a6dc17bd763243412786056d5ecc4ec801ac5fe5bacbf0e6abe30e17347f3e4a22c12dc293e74843920cbc9b19ec3f1a048f8a3f58626457cba32a <nl> HEAD_REF master <nl> ) <nl> <nl>
[ parallel - hashmap ] Update to 1 . 30 ( )
microsoft/vcpkg
f122800c086036fe5277bfaf260c1e8ef9fe3e9e
2020-01-06T19:06:29Z
mmm a / dbms / src / Functions / demange . cpp <nl> ppp b / dbms / src / Functions / demange . cpp <nl> class FunctionDemangle : public IFunction <nl> for ( size_t i = 0 ; i < input_rows_count ; + + i ) <nl> { <nl> StringRef source = column_concrete - > getDataAt ( i ) ; <nl> - auto demangled = try_demangle ( source . data ) ; <nl> + auto demangled = tryDemangle ( source . data ) ; <nl> if ( demangled . data ) <nl> { <nl> result_column - > insertDataWithTerminatingZero ( demangled . data , demangled . size ) ; <nl> mmm a / libs / libcommon / include / common / demangle . h <nl> ppp b / libs / libcommon / include / common / demangle . h <nl> struct DemangleResult <nl> } <nl> } ; <nl> <nl> - DemangleResult try_demangle ( const char * name ) ; <nl> + DemangleResult tryDemangle ( const char * name ) ; <nl> mmm a / libs / libcommon / src / demangle . cpp <nl> ppp b / libs / libcommon / src / demangle . cpp <nl> <nl> <nl> # if _MSC_VER | | MEMORY_SANITIZER <nl> <nl> + DemangleResult tryDemangle ( const char * name ) <nl> + { <nl> + return DemangleResult { } ; <nl> + } <nl> + <nl> std : : string demangle ( const char * name , int & status ) <nl> { <nl> status = 0 ; <nl> std : : string demangle ( const char * name , int & status ) <nl> # include < stdlib . h > <nl> # include < cxxabi . h > <nl> <nl> - static DemangleResult try_demangle ( const char * name , int & status ) <nl> + static DemangleResult tryDemangle ( const char * name , int & status ) <nl> { <nl> DemangleResult result ; <nl> result . data = abi : : __cxa_demangle ( name , nullptr , & result . size , & status ) ; <nl> return result ; <nl> } <nl> <nl> - DemangleResult try_demangle ( const char * name ) <nl> + DemangleResult tryDemangle ( const char * name ) <nl> { <nl> int status = 0 ; <nl> - return try_demangle ( name , status ) ; <nl> + return tryDemangle ( name , status ) ; <nl> } <nl> <nl> std : : string demangle ( const char * name , int & status ) <nl> { <nl> - auto result = try_demangle ( name , status ) ; <nl> + auto result = tryDemangle ( name , status ) ; <nl> if ( result . data ) <nl> { <nl> return std : : string ( result . data , result . size - 1 ) ; <nl>
style
ClickHouse/ClickHouse
7b898ec871a56b559c3255e021be3138ceebe55d
2020-02-04T13:31:15Z
mmm a / src / compiler / python_plugin . cc <nl> ppp b / src / compiler / python_plugin . cc <nl> <nl> # include < cstring > <nl> # include < memory > <nl> # include < string > <nl> + # include < tuple > <nl> <nl> # include " src / compiler / python_generator . h " <nl> # include < google / protobuf / compiler / code_generator . h > <nl>
Fixing Windows build of the python protoc plugin .
grpc/grpc
c16b7952f835748d03518dc8c732d1c5fbbf6a1d
2015-02-26T02:16:53Z
new file mode 100644 <nl> index 000000000000 . . 53a69d6c3bb2 <nl> mmm / dev / null <nl> ppp b / jstests / exists3 . js <nl> <nl> + / / Check exists with non empty document , based on SERVER - 2470 example . <nl> + <nl> + t = db . jstests_exists3 ; <nl> + t . drop ( ) ; <nl> + <nl> + t . insert ( { a : 1 , b : 2 } ) ; <nl> + <nl> + assert . eq ( 1 , t . find ( { } ) . sort ( { c : - 1 } ) . itcount ( ) ) ; <nl> + assert . eq ( 1 , t . count ( { c : { $ exists : false } } ) ) ; <nl> + assert . eq ( 1 , t . find ( { c : { $ exists : false } } ) . itcount ( ) ) ; <nl> + assert . eq ( 1 , t . find ( { c : { $ exists : false } } ) . sort ( { c : - 1 } ) . itcount ( ) ) ; <nl> + <nl> + / / now we have an index on the sort key <nl> + t . ensureIndex ( { c : - 1 } ) <nl> + <nl> + assert . eq ( 1 , t . find ( { c : { $ exists : false } } ) . sort ( { c : - 1 } ) . itcount ( ) ) ; <nl> + assert . eq ( 1 , t . find ( { c : { $ exists : false } } ) . itcount ( ) ) ; <nl> + / / still ok without the $ exists <nl> + assert . eq ( 1 , t . find ( { } ) . sort ( { c : - 1 } ) . itcount ( ) ) ; <nl> + / / and ok with a convoluted $ not $ exists <nl> + assert . eq ( 1 , t . find ( { c : { $ not : { $ exists : true } } } ) . sort ( { c : - 1 } ) . itcount ( ) ) ; <nl> new file mode 100644 <nl> index 000000000000 . . fb801ed62e9d <nl> mmm / dev / null <nl> ppp b / jstests / exists4 . js <nl> <nl> + / / Check various exists cases , based on SERVER - 1735 example . <nl> + <nl> + t = db . jstests_exists4 ; <nl> + t . drop ( ) ; <nl> + <nl> + t . ensureIndex ( { date : - 1 , country_code : 1 , user_id : 1 } , { unique : 1 , background : 1 } ) ; <nl> + t . insert ( { date : new Date ( " 08 / 27 / 2010 " ) , tot_visit : 100 } ) ; <nl> + t . insert ( { date : new Date ( " 08 / 27 / 2010 " ) , country_code : " IT " , tot_visit : 77 } ) ; <nl> + t . insert ( { date : new Date ( " 08 / 27 / 2010 " ) , country_code : " ES " , tot_visit : 23 } ) ; <nl> + t . insert ( { date : new Date ( " 08 / 27 / 2010 " ) , country_code : " ES " , user_id : " and . . . @ spacca . org " , tot_visit : 11 } ) ; <nl> + t . insert ( { date : new Date ( " 08 / 27 / 2010 " ) , country_code : " ES " , user_id : " andrea . spa . . . @ gmail . com " , tot_visit : 5 } ) ; <nl> + t . insert ( { date : new Date ( " 08 / 27 / 2010 " ) , country_code : " ES " , user_id : " andrea . spa . . . @ progloedizioni . com " , tot_visit : 7 } ) ; <nl> + <nl> + assert . eq ( 6 , t . find ( { date : new Date ( " 08 / 27 / 2010 " ) } ) . count ( ) ) ; <nl> + assert . eq ( 5 , t . find ( { date : new Date ( " 08 / 27 / 2010 " ) , country_code : { $ exists : true } } ) . count ( ) ) ; <nl> + assert . eq ( 1 , t . find ( { date : new Date ( " 08 / 27 / 2010 " ) , country_code : { $ exists : false } } ) . count ( ) ) ; <nl> + assert . eq ( 1 , t . find ( { date : new Date ( " 08 / 27 / 2010 " ) , country_code : null } ) . count ( ) ) ; <nl> + assert . eq ( 3 , t . find ( { date : new Date ( " 08 / 27 / 2010 " ) , country_code : { $ exists : true } , user_id : { $ exists : true } } ) . count ( ) ) ; <nl> + assert . eq ( 2 , t . find ( { date : new Date ( " 08 / 27 / 2010 " ) , country_code : { $ exists : true } , user_id : { $ exists : false } } ) . count ( ) ) ; <nl> + assert . eq ( 2 , t . find ( { date : new Date ( " 08 / 27 / 2010 " ) , country_code : { $ exists : true } , user_id : null } ) . count ( ) ) ; <nl>
SERVER - 1587 add tests
mongodb/mongo
74086c6f40a39a34b3ba034ed82b695cc4758f37
2011-04-05T20:14:15Z
mmm a / Tests / EndToEndTests / CNTKv2Python / Examples / run_ConvNet_CIFAR10_DataAug_Distributed . py <nl> ppp b / Tests / EndToEndTests / CNTKv2Python / Examples / run_ConvNet_CIFAR10_DataAug_Distributed . py <nl> def run_cifar_convnet_distributed ( ) : <nl> test_data = os . path . join ( base_path , ' test_map . txt ' ) <nl> <nl> num_quantization_bits = 32 <nl> - return convnet_cifar10_dataaug ( train_data , test_data , mean_data , num_quantization_bits , epoch_size = 512 , max_epochs = 2 , num_mbs_per_log = 1 ) <nl> + return convnet_cifar10_dataaug ( train_data , test_data , mean_data , num_quantization_bits , epoch_size = 512 , max_epochs = 2 ) <nl> <nl> if __name__ = = ' __main__ ' : <nl> assert distributed . Communicator . rank ( ) < distributed . Communicator . num_workers ( ) <nl>
Fix to not output too much in log , which may cause racing condition .
microsoft/CNTK
dcc4b5677662134a223e7768d9197d305bfa8fab
2017-01-19T20:36:12Z
mmm a / docs / en / operations / tips . md <nl> ppp b / docs / en / operations / tips . md <nl> zoo . cfg : <nl> tickTime = 2000 <nl> # The number of ticks that the initial <nl> # synchronization phase can take <nl> + # This value is not quite motivated <nl> initLimit = 30000 <nl> # The number of ticks that can pass between <nl> # sending a request and getting an acknowledgement <nl> syncLimit = 10 <nl> <nl> maxClientCnxns = 2000 <nl> <nl> + # It is the maximum value that client may request and the server will accept . <nl> + # It is Ok to have high maxSessionTimeout on server to allow clients to work with high session timeout if they want . <nl> + # But we request session timeout of 30 seconds by default ( you can change it with session_timeout_ms in ClickHouse config ) . <nl> maxSessionTimeout = 60000000 <nl> # the directory where the snapshot is stored . <nl> dataDir = / opt / zookeeper / { { ' { { ' } } cluster [ ' name ' ] { { ' } } ' } } / data <nl>
Update tips . md
ClickHouse/ClickHouse
4d01fb3cbce2971f19a66ac97e85092523487125
2020-07-02T12:54:32Z
mmm a / docs / tutorial / snapcraft - guide . md <nl> ppp b / docs / tutorial / snapcraft - guide . md <nl> <nl> # Snapcraft Guide ( Ubuntu Software Center & More ) <nl> <nl> This guide provides information on how to package your Electron application <nl> - for the Ubuntu Software Center or any other Snapcraft environment . <nl> + for any Snapcraft environment , including the Ubuntu Software Center . <nl> <nl> # # Background and Requirements <nl> <nl> project . Snaps are containerized software packages that include required <nl> dependencies , auto - update , and work on all major Linux distributions without <nl> system modification . <nl> <nl> - Snapcraft is the primary way to get your application into the Ubuntu Software <nl> - Center , but the underlying [ Snap Store ] ( snapcraft - store ) supports all major <nl> - Linux distributions , too . <nl> - <nl> There are three ways to create a ` . snap ` file : <nl> <nl> 1 ) Using ` electron - installer - snap ` , which takes ` electron - packager ' s ` output <nl>
: memo : Some more words
electron/electron
9d0d83a002c91d70c54c9b6fe4fe4b3ad5c6b483
2018-02-01T00:57:45Z
mmm a / src / library_gl . js <nl> ppp b / src / library_gl . js <nl> var LibraryGL = { <nl> Module . ctx . bindTexture ( Module . ctx . TEXTURE_2D , texture ) ; <nl> Module . ctx . uniform1i ( this . textureLocation , 0 ) ; <nl> } <nl> + } , <nl> + <nl> + cleanup : function ( ) { <nl> + Module . ctx . disableVertexAttribArray ( this . positionLocation ) ; <nl> + if ( this . hasTexture ) { <nl> + Module . ctx . disableVertexAttribArray ( this . texCoordLocation ) ; <nl> + } <nl> } <nl> } ; <nl> ret . init ( ) ; <nl> var LibraryGL = { <nl> Module . ctx . drawArrays ( GL . immediate . mode , startIndex , numVertexes ) ; <nl> } <nl> <nl> + renderer . cleanup ( ) ; <nl> + <nl> if ( ! GL . currArrayBuffer ) { <nl> Module . ctx . bindBuffer ( Module . ctx . ARRAY_BUFFER , null ) ; <nl> } <nl>
clean up activated vertex attrib arrays in renderers , fixes bug with only 1 / 4 of the world drawn in bananabread
emscripten-core/emscripten
1943a11a77d6870ee3b227bf4be1b619ed66719b
2012-04-30T22:36:35Z
mmm a / trunk / src / core / srs_core . hpp <nl> ppp b / trunk / src / core / srs_core . hpp <nl> <nl> <nl> / / The current stable release . <nl> # define VERSION_STABLE 2 <nl> - # define VERSION_STABLE_BRANCH SRS_XSTR ( VERSION_STABLE ) " . 0release " <nl> + # define VERSION_STABLE_BRANCH SRS_XSTR ( VERSION_STABLE ) " . 0release " <nl> <nl> / / For 32bit os , 2G big file limit for unistd io , <nl> / / ie . read / write / lseek to use 64bits size for huge file . <nl> mmm a / trunk / src / kernel / srs_kernel_utility . cpp <nl> ppp b / trunk / src / kernel / srs_kernel_utility . cpp <nl> srs_utime_t srs_get_system_startup_time ( ) <nl> <nl> / / For utest to mock it . <nl> # ifndef SRS_AUTO_OSX <nl> - _srs_gettimeofday_t _srs_gettimeofday = : : gettimeofday ; <nl> + _srs_gettimeofday_t _srs_gettimeofday = ( _srs_gettimeofday_t ) : : gettimeofday ; <nl> # endif <nl> <nl> srs_utime_t srs_update_system_time ( ) <nl> mmm a / trunk / src / protocol / srs_protocol_utility . cpp <nl> ppp b / trunk / src / protocol / srs_protocol_utility . cpp <nl> void srs_discovery_tc_url ( string tcUrl , string & schema , string & host , string & vh <nl> srs_vhost_resolve ( vhost , stream , param ) ; <nl> <nl> / / Ignore when the param only contains the default vhost . <nl> - if ( param = = " ? vhost = " SRS_CONSTS_RTMP_DEFAULT_VHOST ) { <nl> + if ( param = = " ? vhost = " SRS_CONSTS_RTMP_DEFAULT_VHOST ) { <nl> param = " " ; <nl> } <nl> } <nl>
For , build fail on ubuntu : focal . 3 . 0 . 144
ossrs/srs
13af54171f2f809015560db88a55252c28c9ab85
2020-10-10T08:20:05Z
mmm a / vnpy / gateway / mt5 / mt5_gateway . py <nl> ppp b / vnpy / gateway / mt5 / mt5_gateway . py <nl> def generate_datetime3 ( datetime : datetime ) - > str : <nl> " " " " " " <nl> dt = datetime . replace ( tzinfo = None ) <nl> local_tz = LOCAL_TZ . normalize ( dt . astimezone ( LOCAL_TZ ) ) <nl> - utc_tz = pytz . utc . normalize ( dt . astimezone ( pytz . utc ) ) <nl> + utc_tz = pytz . utc . normalize ( local_tz . astimezone ( pytz . utc ) ) <nl> utc_tz = utc_tz . replace ( tzinfo = None ) <nl> dt = utc_tz . isoformat ( ) <nl> dt = dt . replace ( ' T ' , ' ' ) <nl>
tz name adjustment
vnpy/vnpy
a920f87f817eaf12bc86f807ee916c4e65d32ee3
2020-08-04T03:37:20Z
mmm a / build / cocos2d_libs . xcodeproj / project . pbxproj . REMOVED . git - id <nl> ppp b / build / cocos2d_libs . xcodeproj / project . pbxproj . REMOVED . git - id <nl> @ @ - 1 + 1 @ @ <nl> - a7af0ccd05e86210026f7c72d6f5a7be8e17fe3d <nl> \ No newline at end of file <nl> + 7a08f39c61b9613934d801462de6404ef7673c59 <nl> \ No newline at end of file <nl> mmm a / cocos / 2d / CCActionEase . h <nl> ppp b / cocos / 2d / CCActionEase . h <nl> class CC_DLL ActionEase : public ActionInterval <nl> <nl> / * * The inner action * / <nl> ActionInterval * _inner ; <nl> + std : : function < float ( float ) > tweenFunction ; <nl> <nl> private : <nl> CC_DISALLOW_COPY_AND_ASSIGN ( ActionEase ) ; <nl> similarity index 100 % <nl> rename from cocos / editor - support / cocostudio / CCActionEaseEx . cpp <nl> rename to cocos / 2d / CCActionEaseEx . cpp <nl> similarity index 100 % <nl> rename from cocos / editor - support / cocostudio / CCActionEaseEx . h <nl> rename to cocos / 2d / CCActionEaseEx . h <nl> similarity index 99 % <nl> rename from cocos / editor - support / cocostudio / CCTweenFunction . cpp <nl> rename to cocos / 2d / CCTweenFunction . cpp <nl> mmm a / cocos / editor - support / cocostudio / CCTweenFunction . cpp <nl> ppp b / cocos / 2d / CCTweenFunction . cpp <nl> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> THE SOFTWARE . <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> <nl> - # include " cocostudio / CCTweenFunction . h " <nl> + # include " CCTweenFunction . h " <nl> # include " cocostudio / CCUtilMath . h " <nl> <nl> # ifndef M_PI_X_2 <nl> similarity index 100 % <nl> rename from cocos / editor - support / cocostudio / CCTweenFunction . h <nl> rename to cocos / 2d / CCTweenFunction . h <nl> mmm a / cocos / 2d / cocos2d . h <nl> ppp b / cocos / 2d / cocos2d . h <nl> THE SOFTWARE . <nl> # include " CCActionInstant . h " <nl> # include " CCActionTween . h " <nl> # include " CCActionCatmullRom . h " <nl> + # include " CCTweenFunction . h " <nl> <nl> / / base_nodes <nl> # include " CCNode . h " <nl> mmm a / cocos / editor - support / cocostudio / CCDatas . h <nl> ppp b / cocos / editor - support / cocostudio / CCDatas . h <nl> THE SOFTWARE . <nl> # include " CCAffineTransform . h " <nl> # include " CCNode . h " <nl> # include " cocostudio / CCArmatureDefine . h " <nl> - # include " cocostudio / CCTweenFunction . h " <nl> + # include " CCTweenFunction . h " <nl> <nl> <nl> # define CC_CREATE_NO_PARAM_NO_INIT ( varType ) \ <nl> mmm a / cocos / editor - support / cocostudio / CCTween . cpp <nl> ppp b / cocos / editor - support / cocostudio / CCTween . cpp <nl> THE SOFTWARE . <nl> # include " cocostudio / CCBone . h " <nl> # include " cocostudio / CCArmature . h " <nl> # include " cocostudio / CCUtilMath . h " <nl> - # include " cocostudio / CCTweenFunction . h " <nl> # include " cocostudio / CCTransformHelp . h " <nl> <nl> <nl> mmm a / cocos / editor - support / cocostudio / CCTween . h <nl> ppp b / cocos / editor - support / cocostudio / CCTween . h <nl> THE SOFTWARE . <nl> # define __CCTWEEN_H__ <nl> <nl> # include " cocostudio / CCProcessBase . h " <nl> - # include " cocostudio / CCTweenFunction . h " <nl> + # include " CCTweenFunction . h " <nl> <nl> namespace cocostudio { <nl> <nl> mmm a / cocos / editor - support / cocostudio / CocoStudio . h <nl> ppp b / cocos / editor - support / cocostudio / CocoStudio . h <nl> THE SOFTWARE . <nl> # include " cocostudio / CCDataReaderHelper . h " <nl> # include " cocostudio / CCSpriteFrameCacheHelper . h " <nl> # include " cocostudio / CCTransformHelp . h " <nl> - # include " cocostudio / CCTweenFunction . h " <nl> # include " cocostudio / CCUtilMath . h " <nl> # include " cocostudio / CCComBase . h " <nl> # include " cocostudio / CCComAttribute . h " <nl>
move CCActionEaseEx and CCTweenFunction to core engine
cocos2d/cocos2d-x
895b2a005558ef8e29f6188c7cf0a4ffa0341ef2
2014-02-18T06:22:12Z
mmm a / src / elements . cc <nl> ppp b / src / elements . cc <nl> class DictionaryElementsAccessor <nl> DisallowHeapAllocation no_gc ; <nl> / / Remove elements that should be deleted . <nl> int removed_entries = 0 ; <nl> - Handle < Object > the_hole_value = isolate - > factory ( ) - > the_hole_value ( ) ; <nl> for ( int entry = 0 ; entry < capacity ; entry + + ) { <nl> Object * index = dict - > KeyAt ( entry ) ; <nl> if ( index - > IsNumber ( ) ) { <nl> uint32_t number = static_cast < uint32_t > ( index - > Number ( ) ) ; <nl> if ( length < = number & & number < old_length ) { <nl> - dict - > SetEntry ( entry , the_hole_value , the_hole_value ) ; <nl> + dict - > ClearEntry ( entry ) ; <nl> removed_entries + + ; <nl> } <nl> } <nl> mmm a / src / lookup . cc <nl> ppp b / src / lookup . cc <nl> void LookupIterator : : ReconfigureDataProperty ( Handle < Object > value , <nl> int enumeration_index = original_details . dictionary_index ( ) ; <nl> DCHECK ( enumeration_index > 0 ) ; <nl> details = details . set_index ( enumeration_index ) ; <nl> - dictionary - > SetEntry ( dictionary_entry ( ) , name ( ) , value , details ) ; <nl> + dictionary - > SetEntry ( dictionary_entry ( ) , * name ( ) , * value , details ) ; <nl> property_details_ = details ; <nl> } <nl> state_ = DATA ; <nl> mmm a / src / objects - inl . h <nl> ppp b / src / objects - inl . h <nl> bool AccessorPair : : IsJSAccessor ( Object * obj ) { <nl> } <nl> <nl> template < typename Derived , typename Shape > <nl> - void Dictionary < Derived , Shape > : : SetEntry ( int entry , Handle < Object > key , <nl> - Handle < Object > value ) { <nl> - this - > SetEntry ( entry , key , value , PropertyDetails ( Smi : : kZero ) ) ; <nl> + void Dictionary < Derived , Shape > : : ClearEntry ( int entry ) { <nl> + Object * the_hole = this - > GetHeap ( ) - > the_hole_value ( ) ; <nl> + SetEntry ( entry , the_hole , the_hole , PropertyDetails : : Empty ( ) ) ; <nl> } <nl> <nl> template < typename Derived , typename Shape > <nl> - void Dictionary < Derived , Shape > : : SetEntry ( int entry , Handle < Object > key , <nl> - Handle < Object > value , <nl> + void Dictionary < Derived , Shape > : : SetEntry ( int entry , Object * key , Object * value , <nl> PropertyDetails details ) { <nl> - Shape : : SetEntry ( static_cast < Derived * > ( this ) , entry , key , value , details ) ; <nl> - } <nl> - <nl> - <nl> - template < typename Key > <nl> - template < typename Dictionary > <nl> - void BaseDictionaryShape < Key > : : SetEntry ( Dictionary * dict , int entry , <nl> - Handle < Object > key , <nl> - Handle < Object > value , <nl> - PropertyDetails details ) { <nl> STATIC_ASSERT ( Dictionary : : kEntrySize = = 2 | | Dictionary : : kEntrySize = = 3 ) ; <nl> DCHECK ( ! key - > IsName ( ) | | details . dictionary_index ( ) > 0 ) ; <nl> - int index = dict - > EntryToIndex ( entry ) ; <nl> + int index = DerivedHashTable : : EntryToIndex ( entry ) ; <nl> DisallowHeapAllocation no_gc ; <nl> - WriteBarrierMode mode = dict - > GetWriteBarrierMode ( no_gc ) ; <nl> - dict - > set ( index + Dictionary : : kEntryKeyIndex , * key , mode ) ; <nl> - dict - > set ( index + Dictionary : : kEntryValueIndex , * value , mode ) ; <nl> - if ( Dictionary : : kEntrySize = = 3 ) { <nl> - dict - > set ( index + Dictionary : : kEntryDetailsIndex , details . AsSmi ( ) ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - template < typename Dictionary > <nl> - void GlobalDictionaryShape : : SetEntry ( Dictionary * dict , int entry , <nl> - Handle < Object > key , Handle < Object > value , <nl> - PropertyDetails details ) { <nl> - STATIC_ASSERT ( Dictionary : : kEntrySize = = 2 ) ; <nl> - DCHECK ( ! key - > IsName ( ) | | details . dictionary_index ( ) > 0 ) ; <nl> - DCHECK ( value - > IsPropertyCell ( ) ) ; <nl> - int index = dict - > EntryToIndex ( entry ) ; <nl> - DisallowHeapAllocation no_gc ; <nl> - WriteBarrierMode mode = dict - > GetWriteBarrierMode ( no_gc ) ; <nl> - dict - > set ( index + Dictionary : : kEntryKeyIndex , * key , mode ) ; <nl> - dict - > set ( index + Dictionary : : kEntryValueIndex , * value , mode ) ; <nl> - PropertyCell : : cast ( * value ) - > set_property_details ( details ) ; <nl> + WriteBarrierMode mode = this - > GetWriteBarrierMode ( no_gc ) ; <nl> + this - > set ( index + Derived : : kEntryKeyIndex , key , mode ) ; <nl> + this - > set ( index + Derived : : kEntryValueIndex , value , mode ) ; <nl> + if ( Shape : : kHasDetails ) DetailsAtPut ( entry , details ) ; <nl> } <nl> <nl> <nl> Handle < Object > NameDictionaryShape : : AsHandle ( Isolate * isolate , <nl> <nl> template < typename Dictionary > <nl> PropertyDetails GlobalDictionaryShape : : DetailsAt ( Dictionary * dict , int entry ) { <nl> - DCHECK ( entry > = 0 ) ; / / Not found is - 1 , which is not caught by get ( ) . <nl> + DCHECK_LE ( 0 , entry ) ; / / Not found is - 1 , which is not caught by get ( ) . <nl> Object * raw_value = dict - > ValueAt ( entry ) ; <nl> DCHECK ( raw_value - > IsPropertyCell ( ) ) ; <nl> PropertyCell * cell = PropertyCell : : cast ( raw_value ) ; <nl> PropertyDetails GlobalDictionaryShape : : DetailsAt ( Dictionary * dict , int entry ) { <nl> template < typename Dictionary > <nl> void GlobalDictionaryShape : : DetailsAtPut ( Dictionary * dict , int entry , <nl> PropertyDetails value ) { <nl> - DCHECK ( entry > = 0 ) ; / / Not found is - 1 , which is not caught by get ( ) . <nl> - Object * raw_value = dict - > ValueAt ( entry ) ; <nl> - DCHECK ( raw_value - > IsPropertyCell ( ) ) ; <nl> - PropertyCell * cell = PropertyCell : : cast ( raw_value ) ; <nl> + DCHECK_LE ( 0 , entry ) ; / / Not found is - 1 , which is not caught by get ( ) . <nl> + PropertyCell * cell = PropertyCell : : cast ( dict - > ValueAt ( entry ) ) ; <nl> if ( cell - > property_details ( ) . IsReadOnly ( ) ! = value . IsReadOnly ( ) ) { <nl> cell - > dependent_code ( ) - > DeoptimizeDependentCodeGroup ( <nl> cell - > GetIsolate ( ) , DependentCode : : kPropertyCellChangedGroup ) ; <nl> void GlobalDictionaryShape : : DetailsAtPut ( Dictionary * dict , int entry , <nl> cell - > set_property_details ( value ) ; <nl> } <nl> <nl> - <nl> template < typename Dictionary > <nl> bool GlobalDictionaryShape : : IsDeleted ( Dictionary * dict , int entry ) { <nl> DCHECK ( dict - > ValueAt ( entry ) - > IsPropertyCell ( ) ) ; <nl> mmm a / src / objects . cc <nl> ppp b / src / objects . cc <nl> void JSObject : : SetNormalizedProperty ( Handle < JSObject > object , <nl> int enumeration_index = original_details . dictionary_index ( ) ; <nl> DCHECK ( enumeration_index > 0 ) ; <nl> details = details . set_index ( enumeration_index ) ; <nl> - dictionary - > SetEntry ( entry , name , value , details ) ; <nl> + dictionary - > SetEntry ( entry , * name , * value , details ) ; <nl> } <nl> } <nl> } <nl> Handle < Derived > BaseNameDictionary < Derived , Shape > : : EnsureCapacity ( <nl> template < typename Derived , typename Shape > <nl> Handle < Derived > Dictionary < Derived , Shape > : : DeleteEntry ( <nl> Handle < Derived > dictionary , int entry ) { <nl> - Factory * factory = dictionary - > GetIsolate ( ) - > factory ( ) ; <nl> DCHECK ( Shape : : kEntrySize ! = 3 | | <nl> dictionary - > DetailsAt ( entry ) . IsConfigurable ( ) ) ; <nl> - dictionary - > SetEntry ( <nl> - entry , factory - > the_hole_value ( ) , factory - > the_hole_value ( ) ) ; <nl> + dictionary - > ClearEntry ( entry ) ; <nl> dictionary - > ElementRemoved ( ) ; <nl> return Shrink ( dictionary ) ; <nl> } <nl> Handle < Derived > Dictionary < Derived , Shape > : : Add ( Handle < Derived > dictionary , <nl> Handle < Object > k = Shape : : AsHandle ( isolate , key ) ; <nl> <nl> uint32_t entry = dictionary - > FindInsertionEntry ( hash ) ; <nl> - dictionary - > SetEntry ( entry , k , value , details ) ; <nl> + dictionary - > SetEntry ( entry , * k , * value , details ) ; <nl> DCHECK ( dictionary - > KeyAt ( entry ) - > IsNumber ( ) | | <nl> dictionary - > KeyAt ( entry ) - > IsUniqueName ( ) ) ; <nl> dictionary - > ElementAdded ( ) ; <nl> mmm a / src / objects / dictionary . h <nl> ppp b / src / objects / dictionary . h <nl> class Dictionary : public HashTable < Derived , Shape > { <nl> Object * SlowReverseLookup ( Object * value ) ; <nl> <nl> / / Sets the entry to ( key , value ) pair . <nl> - inline void SetEntry ( int entry , Handle < Object > key , Handle < Object > value ) ; <nl> - inline void SetEntry ( int entry , Handle < Object > key , Handle < Object > value , <nl> + inline void ClearEntry ( int entry ) ; <nl> + inline void SetEntry ( int entry , Object * key , Object * value , <nl> PropertyDetails details ) ; <nl> <nl> MUST_USE_RESULT static Handle < Derived > Add ( Handle < Derived > dictionary , <nl> class Dictionary : public HashTable < Derived , Shape > { <nl> template < typename Key > <nl> class BaseDictionaryShape : public BaseShape < Key > { <nl> public : <nl> + static const bool kHasDetails = true ; <nl> template < typename Dictionary > <nl> static inline PropertyDetails DetailsAt ( Dictionary * dict , int entry ) { <nl> STATIC_ASSERT ( Dictionary : : kEntrySize = = 3 ) ; <nl> class BaseDictionaryShape : public BaseShape < Key > { <nl> static bool IsDeleted ( Dictionary * dict , int entry ) { <nl> return false ; <nl> } <nl> - <nl> - template < typename Dictionary > <nl> - static inline void SetEntry ( Dictionary * dict , int entry , Handle < Object > key , <nl> - Handle < Object > value , PropertyDetails details ) ; <nl> } ; <nl> <nl> class NameDictionaryShape : public BaseDictionaryShape < Handle < Name > > { <nl> class GlobalDictionaryShape : public NameDictionaryShape { <nl> <nl> template < typename Dictionary > <nl> static bool IsDeleted ( Dictionary * dict , int entry ) ; <nl> - <nl> - template < typename Dictionary > <nl> - static inline void SetEntry ( Dictionary * dict , int entry , Handle < Object > key , <nl> - Handle < Object > value , PropertyDetails details ) ; <nl> } ; <nl> <nl> class GlobalDictionary <nl> class SeededNumberDictionaryShape : public NumberDictionaryShape { <nl> <nl> class UnseededNumberDictionaryShape : public NumberDictionaryShape { <nl> public : <nl> + static const bool kHasDetails = false ; <nl> static const int kPrefixSize = 0 ; <nl> static const int kEntrySize = 2 ; <nl> <nl>
[ runtime ] Unify * DictionaryShape : : SetEntry into * Dictionary : : SetEntry
v8/v8
731d1b73af90f1e5507adfc53a00d4418e509158
2017-06-22T15:26:50Z
mmm a / src / main . cpp <nl> ppp b / src / main . cpp <nl> <nl> * along with this program . If not , see < http : / / www . gnu . org / licenses / > . <nl> * / <nl> <nl> + # include < cstdio > <nl> + # include < sstream > <nl> # include < iostream > <nl> - # include < stdio . h > <nl> + # include < iterator > <nl> + # include < algorithm > <nl> <nl> # include " opencv2 / highgui / highgui . hpp " <nl> # include " opencv2 / imgproc / imgproc . hpp " <nl> int main ( int argc , const char * * argv ) <nl> std : : string country ; <nl> int topn ; <nl> <nl> - try <nl> - { <nl> - TCLAP : : CmdLine cmd ( " OpenAlpr Command Line Utility " , ' ' , OPENALPR_VERSION ) ; <nl> + TCLAP : : CmdLine cmd ( " OpenAlpr Command Line Utility " , ' ' , OPENALPR_VERSION ) ; <nl> <nl> - TCLAP : : UnlabeledValueArg < std : : string > fileArg ( " image_file " , " Image containing license plates " , true , " " , " image_file_path " ) ; <nl> + TCLAP : : UnlabeledValueArg < std : : string > fileArg ( " image_file " , " Image containing license plates " , false , " " , " image_file_path " ) ; <nl> <nl> - TCLAP : : ValueArg < std : : string > countryCodeArg ( " c " , " country " , " Country code to identify ( either us for USA or eu for Europe ) . Default = us " , false , " us " , " country_code " ) ; <nl> - TCLAP : : ValueArg < int > seekToMsArg ( " " , " seek " , " Seek to the specied millisecond in a video file . Default = 0 " , false , 0 , " integer_ms " ) ; <nl> - TCLAP : : ValueArg < std : : string > runtimeDirArg ( " r " , " runtime_dir " , " Path to the OpenAlpr runtime data directory " , false , " " , " runtime_dir " ) ; <nl> - TCLAP : : ValueArg < std : : string > templateRegionArg ( " t " , " template_region " , " Attempt to match the plate number against a region template ( e . g . , md for Maryland , ca for California ) " , false , " " , " region code " ) ; <nl> - TCLAP : : ValueArg < int > topNArg ( " n " , " topn " , " Max number of possible plate numbers to return . Default = 10 " , false , 10 , " topN " ) ; <nl> + TCLAP : : ValueArg < std : : string > countryCodeArg ( " c " , " country " , " Country code to identify ( either us for USA or eu for Europe ) . Default = us " , false , " us " , " country_code " ) ; <nl> + TCLAP : : ValueArg < int > seekToMsArg ( " " , " seek " , " Seek to the specied millisecond in a video file . Default = 0 " , false , 0 , " integer_ms " ) ; <nl> + TCLAP : : ValueArg < std : : string > runtimeDirArg ( " r " , " runtime_dir " , " Path to the OpenAlpr runtime data directory " , false , " " , " runtime_dir " ) ; <nl> + TCLAP : : ValueArg < std : : string > templateRegionArg ( " t " , " template_region " , " Attempt to match the plate number against a region template ( e . g . , md for Maryland , ca for California ) " , false , " " , " region code " ) ; <nl> + TCLAP : : ValueArg < int > topNArg ( " n " , " topn " , " Max number of possible plate numbers to return . Default = 10 " , false , 10 , " topN " ) ; <nl> <nl> - TCLAP : : SwitchArg jsonSwitch ( " j " , " json " , " Output recognition results in JSON format . Default = off " , cmd , false ) ; <nl> - TCLAP : : SwitchArg detectRegionSwitch ( " d " , " detect_region " , " Attempt to detect the region of the plate image . Default = off " , cmd , false ) ; <nl> - TCLAP : : SwitchArg clockSwitch ( " " , " clock " , " Measure / print the total time to process image and all plates . Default = off " , cmd , false ) ; <nl> + TCLAP : : SwitchArg jsonSwitch ( " j " , " json " , " Output recognition results in JSON format . Default = off " , cmd , false ) ; <nl> + TCLAP : : SwitchArg detectRegionSwitch ( " d " , " detect_region " , " Attempt to detect the region of the plate image . Default = off " , cmd , false ) ; <nl> + TCLAP : : SwitchArg clockSwitch ( " " , " clock " , " Measure / print the total time to process image and all plates . Default = off " , cmd , false ) ; <nl> <nl> + try <nl> + { <nl> cmd . add ( fileArg ) ; <nl> cmd . add ( countryCodeArg ) ; <nl> cmd . add ( seekToMsArg ) ; <nl> int main ( int argc , const char * * argv ) <nl> return 1 ; <nl> } <nl> <nl> - if ( filename = = " webcam " ) <nl> + if ( filename . empty ( ) ) <nl> + { <nl> + std : : string line ; <nl> + while ( std : : getline ( std : : cin , line ) ) <nl> + { <nl> + std : : istringstream is ( line ) ; <nl> + std : : vector < std : : string > args ; <nl> + args . push_back ( " tmp " ) ; <nl> + args . insert ( args . end ( ) , std : : istream_iterator < std : : string > ( is ) , std : : istream_iterator < std : : string > ( ) ) ; <nl> + try <nl> + { <nl> + cmd . reset ( ) ; <nl> + cmd . parse ( args ) ; <nl> + <nl> + filename = fileArg . getValue ( ) ; <nl> + outputJson = jsonSwitch . getValue ( ) ; <nl> + detectRegion = detectRegionSwitch . getValue ( ) ; <nl> + templateRegion = templateRegionArg . getValue ( ) ; <nl> + topn = topNArg . getValue ( ) ; <nl> + <nl> + alpr . setTopN ( topn ) ; <nl> + if ( detectRegion ) <nl> + alpr . setDetectRegion ( detectRegion ) ; <nl> + if ( templateRegion . empty ( ) = = false ) <nl> + alpr . setDefaultRegion ( templateRegion ) ; <nl> + <nl> + frame = cv : : imread ( filename ) ; <nl> + detectandshow ( & alpr , frame , " " , outputJson ) ; <nl> + } <nl> + catch ( TCLAP : : ArgException & e ) / / catch any exceptions <nl> + { <nl> + std : : cerr < < " error : " < < e . error ( ) < < " for arg " < < e . argId ( ) < < std : : endl ; <nl> + } <nl> + } <nl> + } <nl> + else if ( filename = = " webcam " ) <nl> { <nl> int framenum = 0 ; <nl> cv : : VideoCapture cap ( 0 ) ; <nl>
Add daemon support
openalpr/openalpr
c62a76d6a8a084b29bc39a4a8117151944375c29
2014-03-28T09:10:49Z
mmm a / tensorflow / python / data / ops / dataset_ops . py <nl> ppp b / tensorflow / python / data / ops / dataset_ops . py <nl> def from_tensor_slices ( tensors ) : <nl> # = = > [ { " a " : 1 , " b " : 3 , " c " : 5 } , { " a " : 2 , " b " : 4 , " c : " 6 } ] <nl> <nl> <nl> - # Example 1 : Two tensors can be combined into one Dataset object . <nl> - features = tf . constant ( [ [ 1 , 3 ] , [ 2 , 3 ] , [ 2 , 1 ] , [ 1 , 2 ] , [ 3 , 3 ] , [ 3 , 2 ] ] ) # = = > 6x2 tensor <nl> - labels = tf . constant ( [ ' A ' , ' A ' , ' B ' , ' B ' , ' A ' , ' B ' ] ) # = = > 6x1 tensor <nl> + # Two tensors can be combined into one Dataset object . <nl> + features = tf . constant ( [ [ 1 , 3 ] , [ 2 , 1 ] , [ 3 , 3 ] ] ) # = = > 3x2 tensor <nl> + labels = tf . constant ( [ ' A ' , ' B ' , ' A ' ] ) # = = > 3x1 tensor <nl> dataset = Dataset . from_tensor_slices ( ( features , labels ) ) <nl> <nl> - # Example 2 : Both the features and the labels tensors can be converted <nl> + # Both the features and the labels tensors can be converted <nl> # to a Dataset object separately and combined after . <nl> features_dataset = Dataset . from_tensor_slices ( features ) <nl> labels_dataset = Dataset . from_tensor_slices ( labels ) <nl> dataset = Dataset . zip ( ( features_dataset , labels_dataset ) ) <nl> <nl> - # Example 3 : A batched feature and label set can be converted to a Dataset <nl> + # A batched feature and label set can be converted to a Dataset <nl> # in similar fashion . <nl> batched_features = tf . constant ( [ [ [ 1 , 3 ] , [ 2 , 3 ] ] , <nl> [ [ 2 , 1 ] , [ 1 , 2 ] ] , <nl>
remove ' example ' tags and simplify example tensors
tensorflow/tensorflow
fb70d4c35ddcd745fd04fd77ace7232ad9c31a31
2019-09-27T17:24:58Z
mmm a / xbmc / cores / VideoRenderers / MMALRenderer . cpp <nl> ppp b / xbmc / cores / VideoRenderers / MMALRenderer . cpp <nl> void CMMALRenderer : : vout_input_port_cb ( MMAL_PORT_T * port , MMAL_BUFFER_HEADER_T * <nl> { <nl> # if defined ( MMAL_DEBUG_VERBOSE ) <nl> CMMALVideoBuffer * omvb = ( CMMALVideoBuffer * ) buffer - > user_data ; <nl> - CLog : : Log ( LOGDEBUG , " % s : : % s port : % p buffer % p ( % p ) , len % d cmd : % x " , CLASSNAME , __func__ , port , buffer , omvb , buffer - > length , buffer - > cmd ) ; <nl> + CLog : : Log ( LOGDEBUG , " % s : : % s port : % p buffer % p ( % p ) , len % d cmd : % x f : % x " , CLASSNAME , __func__ , port , buffer , omvb , buffer - > length , buffer - > cmd , buffer - > flags ) ; <nl> # endif <nl> <nl> + assert ( ! ( buffer - > flags & MMAL_BUFFER_HEADER_FLAG_TRANSMISSION_FAILED ) ) ; <nl> + buffer - > flags & = ~ MMAL_BUFFER_HEADER_FLAG_USER2 ; <nl> if ( m_format = = RENDER_FMT_MMAL ) <nl> { <nl> - buffer - > flags & = ~ MMAL_BUFFER_HEADER_FLAG_USER2 ; <nl> mmal_queue_put ( m_release_queue , buffer ) ; <nl> } <nl> else if ( m_format = = RENDER_FMT_YUV420P ) <nl> void CMMALRenderer : : RenderUpdate ( bool clear , DWORD flags , DWORD alpha ) <nl> if ( omvb ) <nl> { <nl> # if defined ( MMAL_DEBUG_VERBOSE ) <nl> - CLog : : Log ( LOGDEBUG , " % s : : % s % p ( % p ) " , CLASSNAME , __func__ , omvb , omvb - > mmal_buffer ) ; <nl> + CLog : : Log ( LOGDEBUG , " % s : : % s % p ( % p ) f : % x " , CLASSNAME , __func__ , omvb , omvb - > mmal_buffer , omvb - > mmal_buffer - > flags ) ; <nl> # endif <nl> / / we only want to upload frames once <nl> if ( omvb - > mmal_buffer - > flags & MMAL_BUFFER_HEADER_FLAG_USER1 ) <nl> void CMMALRenderer : : RenderUpdate ( bool clear , DWORD flags , DWORD alpha ) <nl> } <nl> else if ( m_format = = RENDER_FMT_YUV420P ) <nl> { <nl> - CLog : : Log ( LOGDEBUG , " % s : : % s - % p % d " , CLASSNAME , __func__ , buffer - > mmal_buffer , source ) ; <nl> if ( buffer - > mmal_buffer ) <nl> { <nl> + CLog : : Log ( LOGDEBUG , " % s : : % s - % p % d f : % x " , CLASSNAME , __func__ , buffer - > mmal_buffer , source , buffer - > mmal_buffer - > flags ) ; <nl> / / we only want to upload frames once <nl> if ( buffer - > mmal_buffer - > flags & MMAL_BUFFER_HEADER_FLAG_USER1 ) <nl> return ; <nl> / / sanity check it is not on display <nl> - buffer - > mmal_buffer - > flags | = MMAL_BUFFER_HEADER_FLAG_USER1 ; <nl> + buffer - > mmal_buffer - > flags | = MMAL_BUFFER_HEADER_FLAG_USER1 | MMAL_BUFFER_HEADER_FLAG_USER2 ; <nl> mmal_port_send_buffer ( m_vout_input , buffer - > mmal_buffer ) ; <nl> } <nl> else <nl> mmm a / xbmc / cores / dvdplayer / DVDCodecs / Video / MMALCodec . cpp <nl> ppp b / xbmc / cores / dvdplayer / DVDCodecs / Video / MMALCodec . cpp <nl> long CMMALVideoBuffer : : Release ( ) <nl> { <nl> m_omv - > ReleaseBuffer ( this ) ; <nl> } <nl> + else assert ( count > 0 ) ; <nl> return count ; <nl> } <nl> <nl> void CMMALVideo : : dec_output_port_cb ( MMAL_PORT_T * port , MMAL_BUFFER_HEADER_T * buf <nl> <nl> bool kept = false ; <nl> <nl> + assert ( ! ( buffer - > flags & MMAL_BUFFER_HEADER_FLAG_TRANSMISSION_FAILED ) ) ; <nl> if ( buffer - > cmd = = 0 ) <nl> { <nl> if ( buffer - > length > 0 ) <nl>
[ mmal ] Add some sanity checks to mmal flags
xbmc/xbmc
7dfda0c8544f42c1f08160472e63e6edeee9f338
2015-05-09T12:29:10Z
mmm a / lib / SILOptimizer / SILCombiner / SILCombinerApplyVisitors . cpp <nl> ppp b / lib / SILOptimizer / SILCombiner / SILCombinerApplyVisitors . cpp <nl> SILInstruction * SILCombiner : : visitPartialApplyInst ( PartialApplyInst * PAI ) { <nl> if ( foldInverseReabstractionThunks ( PAI , this ) ) <nl> return nullptr ; <nl> <nl> - SILBuilderContext BuilderCtxt ( Builder . getModule ( ) , Builder . getTrackingList ( ) ) ; <nl> - BuilderCtxt . setOpenedArchetypesTracker ( Builder . getOpenedArchetypesTracker ( ) ) ; <nl> - bool argsAreKeptAlive = <nl> - tryOptimizeApplyOfPartialApply ( PAI , BuilderCtxt , getInstModCallbacks ( ) ) ; <nl> + bool argsAreKeptAlive = tryOptimizeApplyOfPartialApply ( <nl> + PAI , Builder . getBuilderContext ( ) , getInstModCallbacks ( ) ) ; <nl> if ( argsAreKeptAlive ) <nl> needUpdateStackNesting = true ; <nl> <nl>
SILCombine : directly get the SILBuilderContext from SILBuilder for tryOptimizeApplyOfPartialApply
apple/swift
bfff4825b46ba550802cbdb02abb8ed5cce3ec86
2020-02-11T17:15:11Z
mmm a / modules / control / common / BUILD <nl> ppp b / modules / control / common / BUILD <nl> load ( " / / tools : cpplint . bzl " , " cpplint " ) <nl> <nl> package ( default_visibility = [ " / / visibility : public " ] ) <nl> <nl> - cc_library ( <nl> - name = " control_gflags " , <nl> - srcs = [ <nl> - " control_gflags . cc " , <nl> - ] , <nl> - hdrs = [ <nl> - " control_gflags . h " , <nl> - ] , <nl> - deps = [ <nl> - " / / external : gflags " , <nl> - ] , <nl> - ) <nl> - <nl> cc_library ( <nl> name = " hysteresis_filter " , <nl> srcs = [ <nl> cc_library ( <nl> cc_library ( <nl> name = " common " , <nl> deps = [ <nl> - " : control_gflags " , <nl> " : hysteresis_filter " , <nl> " : interpolation_1d " , <nl> " : interpolation_2d " , <nl> deleted file mode 100644 <nl> index 7bbbb351b0c . . 00000000000 <nl> mmm a / modules / control / common / control_gflags . cc <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - * Copyright 2017 The Apollo Authors . All Rights Reserved . <nl> - * <nl> - * Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> - * you may not use this file except in compliance with the License . <nl> - * You may obtain a copy of the License at <nl> - * <nl> - * http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> - * <nl> - * Unless required by applicable law or agreed to in writing , software <nl> - * distributed under the License is distributed on an " AS IS " BASIS , <nl> - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> - * See the License for the specific language governing permissions and <nl> - * limitations under the License . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # include " modules / control / common / control_gflags . h " <nl> - <nl> - DEFINE_string ( control_conf_file , " modules / control / conf / lincoln . pb . txt " , <nl> - " default control conf data file " ) ; <nl> - <nl> - DEFINE_string ( control_adapter_config_filename , <nl> - " modules / control / conf / adapter . conf " , " The adapter config file " ) ; <nl> - <nl> - DEFINE_bool ( enable_csv_debug , false , " True to write out csv debug file . " ) ; <nl> - DEFINE_bool ( enable_speed_station_preview , true , " enable speed / station preview " ) ; <nl> - DEFINE_string ( control_node_name , " control " , " The control node name in proto " ) ; <nl> - DEFINE_bool ( is_control_test_mode , false , " True to run control in test mode " ) ; <nl> - DEFINE_double ( control_test_duration , - 1 . 0 , <nl> - " Control testing duration in seconds . This number is will not " <nl> - " take effect if negative " ) ; <nl> - DEFINE_bool ( use_preview_speed_for_table , false , <nl> - " True to use preview speed for table lookup " ) ; <nl> - <nl> - DEFINE_bool ( enable_input_timestamp_check , true , <nl> - " True to enable input timestamp delay check " ) ; <nl> - <nl> - DEFINE_int32 ( max_localization_miss_num , 20 , <nl> - " Max missing number of localization before entering estop mode " ) ; <nl> - DEFINE_int32 ( max_chassis_miss_num , 20 , <nl> - " Max missing number of chassis before entering estop mode " ) ; <nl> - DEFINE_int32 ( max_planning_miss_num , 20 , <nl> - " Max missing number of planning before entering estop mode " ) ; <nl> - <nl> - DEFINE_double ( max_acceleration_when_stopped , 0 . 01 , <nl> - " max acceleration can be observed when vehicle is stopped " ) ; <nl> - <nl> - DEFINE_double ( steer_angle_rate , 100 . 0 , <nl> - " Steer angle change rate in percentage . " ) ; <nl> - DEFINE_bool ( enable_gain_scheduler , false , <nl> - " Enable gain scheduler for higher vehicle speed " ) ; <nl> - DEFINE_bool ( set_steer_limit , false , " Set steer limit " ) ; <nl> - <nl> - DEFINE_bool ( enable_slope_offset , false , " Enable slope offset compensation " ) ; <nl> - <nl> - DEFINE_double ( lock_steer_speed , 0 . 081 , <nl> - " Minimum speed to lock the steer , in m / s " ) ; <nl> - <nl> - DEFINE_bool ( enable_navigation_mode_error_filter , false , <nl> - " Enable error_filter for navigation mode " ) ; <nl> - <nl> - DEFINE_bool ( enable_navigation_mode_position_update , true , <nl> - " Enable position update for navigation mode " ) ; <nl> - <nl> - DEFINE_bool ( enable_persistent_estop , false , <nl> - " True to persistent keep estop status , " <nl> - " pad reset can reset the estop status . " ) ; <nl> deleted file mode 100644 <nl> index 0a9440ebbad . . 00000000000 <nl> mmm a / modules / control / common / control_gflags . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - * Copyright 2017 The Apollo Authors . All Rights Reserved . <nl> - * <nl> - * Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> - * you may not use this file except in compliance with the License . <nl> - * You may obtain a copy of the License at <nl> - * <nl> - * http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> - * <nl> - * Unless required by applicable law or agreed to in writing , software <nl> - * distributed under the License is distributed on an " AS IS " BASIS , <nl> - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> - * See the License for the specific language governing permissions and <nl> - * limitations under the License . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # ifndef MODULES_CONTROL_COMMON_CONTROL_GFLAGS_H_ <nl> - # define MODULES_CONTROL_COMMON_CONTROL_GFLAGS_H_ <nl> - <nl> - # include " gflags / gflags . h " <nl> - <nl> - / / data file <nl> - DECLARE_string ( control_conf_file ) ; <nl> - <nl> - DECLARE_double ( control_test_duration ) ; <nl> - <nl> - DECLARE_string ( control_adapter_config_filename ) ; <nl> - <nl> - DECLARE_bool ( enable_csv_debug ) ; <nl> - <nl> - / / temporary gflag for test purpose <nl> - DECLARE_bool ( enable_speed_station_preview ) ; <nl> - <nl> - DECLARE_string ( control_node_name ) ; <nl> - DECLARE_bool ( is_control_test_mode ) ; <nl> - DECLARE_bool ( use_preview_speed_for_table ) ; <nl> - <nl> - DECLARE_bool ( enable_input_timestamp_check ) ; <nl> - <nl> - DECLARE_int32 ( max_localization_miss_num ) ; <nl> - DECLARE_int32 ( max_chassis_miss_num ) ; <nl> - DECLARE_int32 ( max_planning_miss_num ) ; <nl> - <nl> - DECLARE_double ( max_acceleration_when_stopped ) ; <nl> - <nl> - DECLARE_double ( steer_angle_rate ) ; <nl> - DECLARE_bool ( enable_gain_scheduler ) ; <nl> - DECLARE_bool ( set_steer_limit ) ; <nl> - DECLARE_bool ( enable_slope_offset ) ; <nl> - <nl> - DECLARE_double ( lock_steer_speed ) ; <nl> - <nl> - DECLARE_bool ( enable_navigation_mode_error_filter ) ; <nl> - DECLARE_bool ( enable_navigation_mode_position_update ) ; <nl> - <nl> - DECLARE_bool ( enable_persistent_estop ) ; <nl> - <nl> - # endif / / MODULES_CONTROL_COMMON_CONTROL_GFLAGS_H_ <nl>
Control : remove gflags in control and compile control / common
ApolloAuto/apollo
90db67ed46c5a9240e8d58161020d758f1f0233b
2018-09-13T09:47:41Z
mmm a / stdlib / core / ArrayType . swift <nl> ppp b / stdlib / core / ArrayType . swift <nl> protocol ArrayType <nl> <nl> / / = = = mmm implementation detail mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - = = = / / <nl> <nl> - typealias Buffer : ArrayBufferType <nl> - init ( _ buffer : Buffer ) <nl> + typealias _Buffer : ArrayBufferType <nl> + init ( _ buffer : _Buffer ) <nl> <nl> - var buffer : Buffer { get set } <nl> + var _buffer : _Buffer { get set } <nl> } <nl> <nl> struct _ArrayTypeMirror < T : ArrayType > : Mirror { <nl> mmm a / stdlib / core / Arrays . swift . gyb <nl> ppp b / stdlib / core / Arrays . swift . gyb <nl> struct $ { Self } < T > : MutableCollection , Sliceable { <nl> } <nl> <nl> var endIndex : Int { <nl> - return buffer . count <nl> + return _buffer . count <nl> } <nl> <nl> subscript ( index : Int ) - > Element { <nl> get { <nl> assert ( index < count , " Array index out of range " ) <nl> - return buffer [ index ] <nl> + return _buffer [ index ] <nl> } <nl> nonmutating set { <nl> assert ( index < count , " Array index out of range " ) <nl> - buffer [ index ] = newValue <nl> + _buffer [ index ] = newValue <nl> } <nl> } <nl> <nl> struct $ { Self } < T > : MutableCollection , Sliceable { <nl> typealias SliceType = Slice < T > <nl> subscript ( subRange : Range < Int > ) - > SliceType { <nl> get { <nl> - return Slice ( buffer [ subRange ] ) <nl> + return Slice ( _buffer [ subRange ] ) <nl> } <nl> set { <nl> if self [ subRange ] ! = = newValue { <nl> struct $ { Self } < T > : MutableCollection , Sliceable { <nl> } <nl> <nl> / / = = = mmm private mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - = = = / / <nl> - typealias Buffer = $ { ' Array ' if Self . startswith ( ' New ' ) else Self } Buffer < T > <nl> + typealias _Buffer = $ { ' Array ' if Self . startswith ( ' New ' ) else Self } Buffer < T > <nl> <nl> - init ( _ buffer : Buffer ) { <nl> - self . buffer = buffer <nl> + init ( _ buffer : _Buffer ) { <nl> + self . _buffer = buffer <nl> } <nl> <nl> - var buffer : Buffer <nl> + var _buffer : _Buffer <nl> } <nl> <nl> extension $ { Self } : ArrayLiteralConvertible { <nl> static func convertFromArrayLiteral ( elements : Element . . . ) - > $ { Self } { <nl> - return $ { Self } ( _extractOrCopyToNativeArrayBuffer ( elements . buffer ) ) <nl> + return $ { Self } ( _extractOrCopyToNativeArrayBuffer ( elements . _buffer ) ) <nl> } <nl> } <nl> <nl> extension $ { Self } { <nl> func _asCocoaArray ( ) - > _CocoaArray { <nl> - return buffer . _asCocoaArray ( ) <nl> + return _buffer . _asCocoaArray ( ) <nl> } <nl> } <nl> <nl> extension $ { Self } : ArrayType { <nl> / / / Construct an empty $ { Self } <nl> init ( ) { <nl> - buffer = Buffer ( ) <nl> + _buffer = _Buffer ( ) <nl> } <nl> <nl> - init < S : Sequence where S . GeneratorType . Element = = Buffer . Element > ( _ s : S ) { <nl> - self = $ { Self } ( Buffer ( s ~ > _copyToNativeArrayBuffer ( ) ) ) <nl> + init < S : Sequence where S . GeneratorType . Element = = _Buffer . Element > ( _ s : S ) { <nl> + self = $ { Self } ( _Buffer ( s ~ > _copyToNativeArrayBuffer ( ) ) ) <nl> } <nl> <nl> / / / Construct an array of count elements , each initialized to value <nl> init ( count : Int , repeatedValue : T ) { <nl> assert ( count > = 0 ) <nl> - buffer = Buffer ( ) <nl> + _buffer = _Buffer ( ) <nl> reserveCapacity ( count ) <nl> - var p = buffer . elementStorage <nl> + var p = _buffer . elementStorage <nl> for _ in 0 . . count { <nl> p + + . initialize ( repeatedValue ) <nl> } <nl> - buffer . count = count <nl> + _buffer . count = count <nl> } <nl> <nl> / / / How many elements the $ { Self } stores <nl> var count : Int { <nl> - return buffer . count <nl> + return _buffer . count <nl> } <nl> <nl> / / / How many elements the $ { Self } can store without reallocation <nl> var capacity : Int { <nl> - return buffer . capacity <nl> + return _buffer . capacity <nl> } <nl> <nl> / / / true if and only if the $ { Self } is empty <nl> extension $ { Self } : ArrayType { <nl> <nl> / / / An object that guarantees the lifetime of this array ' s elements <nl> var _owner : AnyObject ? { <nl> - return buffer . owner <nl> + return _buffer . owner <nl> } <nl> <nl> / / / If the elements are stored contiguously , a pointer to the first <nl> / / / element . Otherwise , nil . <nl> var _elementStorageIfContiguous : UnsafePointer < Element > { <nl> - return buffer . elementStorage <nl> + return _buffer . elementStorage <nl> } <nl> <nl> % if Self ! = ' Array ' : # / / Array does not necessarily have contiguous storage <nl> var _elementStorage : UnsafePointer < Element > { <nl> - return buffer . elementStorage <nl> + return _buffer . elementStorage <nl> } <nl> % end <nl> / / = = = mmm basic mutations mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = = = / / <nl> extension $ { Self } : ArrayType { <nl> / / / newCapacity elements in . Note : does not affect count . <nl> / / / Complexity : O ( N ) <nl> mutating func reserveCapacity ( newCapacity : Int ) { <nl> - if ! buffer . requestUniqueMutableBuffer ( newCapacity ) { <nl> + if ! _buffer . requestUniqueMutableBuffer ( newCapacity ) { <nl> var newBuffer = ContiguousArrayBuffer < T > ( count : count , minimumCapacity : newCapacity ) <nl> - buffer . _uninitializedCopy ( 0 . . count , target : newBuffer . elementStorage ) <nl> - buffer = Buffer ( newBuffer ) <nl> + _buffer . _uninitializedCopy ( 0 . . count , target : newBuffer . elementStorage ) <nl> + _buffer = _Buffer ( newBuffer ) <nl> } <nl> assert ( capacity > = newCapacity ) <nl> } <nl> <nl> / / / Append newElement to the $ { Self } in O ( 1 ) ( amortized ) <nl> mutating func append ( newElement : T ) { <nl> - _arrayAppend ( & buffer , newElement ) <nl> + _arrayAppend ( & _buffer , newElement ) <nl> } <nl> <nl> / / / Remove an element from the end of the $ { Self } in O ( 1 ) . <nl> extension $ { Self } : ArrayType { <nl> / / / will not change <nl> mutating func removeAll ( keepCapacity : Bool = false ) { <nl> if ! keepCapacity { <nl> - buffer = Buffer ( ) <nl> + _buffer = _Buffer ( ) <nl> } <nl> else { <nl> replace ( & self , indices ( self ) , EmptyCollection ( ) ) <nl> extension $ { Self } : ArrayType { <nl> <nl> let count = self . count <nl> result . reserveCapacity ( count ) <nl> - var p = result . buffer . elementStorage <nl> + var p = result . _buffer . elementStorage <nl> for i in 0 . . count { <nl> p + + . initialize ( transform ( self [ i ] ) ) <nl> } <nl> - result . buffer . count = count <nl> + result . _buffer . count = count <nl> <nl> return result <nl> } <nl> extension $ { Self } { <nl> if _fastPath ( p ! = nil | | count = = 0 ) { <nl> return ( _owner , p . value ) <nl> } <nl> - let n = _extractOrCopyToNativeArrayBuffer ( self . buffer ) <nl> + let n = _extractOrCopyToNativeArrayBuffer ( self . _buffer ) <nl> return ( n . owner , n . elementStorage . value ) <nl> } <nl> <nl> extension $ { Self } { <nl> / / / Requires : the Array ' s storage is not provided by an opaque NSArray <nl> % end <nl> func withUnsafePointerToElements < R > ( body : ( UnsafePointer < T > ) - > R ) - > R { <nl> - return buffer . withUnsafePointerToElements ( body ) <nl> + return _buffer . withUnsafePointerToElements ( body ) <nl> } <nl> } <nl> <nl> struct _InitializeMemoryFromCollection < C : Collection > : PointerFunction { <nl> <nl> func replace < <nl> A : ArrayType , C : Collection <nl> - where C . GeneratorType . Element = = A . Buffer . Element , A . IndexType = = Int <nl> + where C . GeneratorType . Element = = A . _Buffer . Element , A . IndexType = = Int <nl> > ( <nl> inout target : A , subRange : Range < Int > , newValues : C <nl> ) { <nl> func replace < <nl> let eraseCount = countElements ( subRange ) <nl> let insertCount = numericCast ( countElements ( newValues ) ) as Int <nl> var newBuffer = _demandUniqueMutableBuffer ( <nl> - & target . buffer , oldCount + insertCount - eraseCount ) <nl> + & target . _buffer , oldCount + insertCount - eraseCount ) <nl> <nl> if _fastPath ( ! newBuffer ) { <nl> let growth = insertCount - eraseCount <nl> <nl> - let elements = target . buffer . elementStorage <nl> + let elements = target . _buffer . elementStorage <nl> assert ( elements ! = nil ) <nl> <nl> let oldTailIndex = subRange . endIndex <nl> func replace < <nl> } <nl> else { <nl> _arrayOutOfPlaceUpdate ( <nl> - & target . buffer , & newBuffer , <nl> + & target . _buffer , & newBuffer , <nl> subRange . startIndex , insertCount , <nl> _InitializeMemoryFromCollection ( newValues ) <nl> ) <nl> func replace < <nl> @ assignment <nl> func + = < <nl> A : ArrayType , S : Sequence <nl> - where S . GeneratorType . Element = = A . Buffer . Element <nl> + where S . GeneratorType . Element = = A . _Buffer . Element <nl> > ( inout lhs : A , rhs : S ) { <nl> - _arrayAppendSequence ( & lhs . buffer , rhs ) <nl> + _arrayAppendSequence ( & lhs . _buffer , rhs ) <nl> } <nl> <nl> @ assignment <nl> func + = < <nl> A : ArrayType , C : Collection <nl> - where C . GeneratorType . Element = = A . Buffer . Element <nl> + where C . GeneratorType . Element = = A . _Buffer . Element <nl> > ( inout lhs : A , rhs : C ) { <nl> let rhsCount = numericCast ( countElements ( rhs ) ) as Int <nl> <nl> where C . GeneratorType . Element = = A . Buffer . Element <nl> / / Ensure uniqueness , mutability , and sufficient storage . Note that <nl> / / for consistency , we need unique lhs even if rhs is empty . <nl> lhs . reserveCapacity ( newCount > capacity ? max ( newCount , capacity * 2 ) : newCount ) <nl> - var p = lhs . buffer . elementStorage + oldCount <nl> + var p = lhs . _buffer . elementStorage + oldCount <nl> for x in rhs { <nl> ( p + + ) . initialize ( x ) <nl> } <nl> - lhs . buffer . count = newCount <nl> + lhs . _buffer . count = newCount <nl> } <nl> <nl> @ assignment <nl> func + = < <nl> A : ArrayType <nl> - > ( inout lhs : A , rhs : A . Buffer . Element ) { <nl> + > ( inout lhs : A , rhs : A . _Buffer . Element ) { <nl> lhs + = CollectionOfOne ( rhs ) <nl> } <nl> <nl> func + = < <nl> / / / the buffer that satisfies the capacity request now has a count <nl> / / / that does not match its number of initialized elements , and that <nl> / / / needs to be corrected before the buffer can go back into circulation . <nl> - func _demandUniqueMutableBuffer < Buffer : ArrayBufferType > ( <nl> - inout source : Buffer , newCount : Int , minimumCapacity : Int = 0 ) <nl> - - > ContiguousArrayBuffer < Buffer . Element > ? { <nl> + func _demandUniqueMutableBuffer < _Buffer : ArrayBufferType > ( <nl> + inout source : _Buffer , newCount : Int , minimumCapacity : Int = 0 ) <nl> + - > ContiguousArrayBuffer < _Buffer . Element > ? { <nl> <nl> assert ( newCount > = 0 ) <nl> <nl> protocol PointerFunction { <nl> / / / As an optimization , may move elements out of source rather than <nl> / / / copying when it isUniquelyReferenced . <nl> func _arrayOutOfPlaceUpdate < <nl> - Buffer : ArrayBufferType , Initializer : PointerFunction <nl> - where Initializer . Element = = Buffer . Element <nl> + _Buffer : ArrayBufferType , Initializer : PointerFunction <nl> + where Initializer . Element = = _Buffer . Element <nl> > ( <nl> - inout source : Buffer , <nl> - inout dest : ContiguousArrayBuffer < Buffer . Element > ? , <nl> + inout source : _Buffer , <nl> + inout dest : ContiguousArrayBuffer < _Buffer . Element > ? , <nl> headCount : Int , / / Count of initial source elements to copy / move <nl> newCount : Int , / / Count of new elements to insert <nl> initializeNewElements : Initializer <nl> func _arrayOutOfPlaceUpdate < <nl> source . _uninitializedCopy ( headCount + oldCount . . sourceCount , <nl> target : newEnd ) <nl> } <nl> - source = Buffer ( dest ! ) <nl> + source = _Buffer ( dest ! ) <nl> } <nl> <nl> struct InitializePointer < T > : PointerFunction { <nl> struct InitializePointer < T > : PointerFunction { <nl> var newValue : T <nl> } <nl> <nl> - func _arrayAppend < Buffer : ArrayBufferType > ( <nl> - inout buffer : Buffer , newValue : Buffer . Element <nl> + func _arrayAppend < _Buffer : ArrayBufferType > ( <nl> + inout buffer : _Buffer , newValue : _Buffer . Element <nl> ) { <nl> let oldCount = buffer . count <nl> var newBuffer = _demandUniqueMutableBuffer ( & buffer , oldCount + 1 ) <nl> struct IgnorePointer < T > : PointerFunction { <nl> func call ( _ : UnsafePointer < T > ) { } <nl> } <nl> <nl> - func _arrayReserve < Buffer : ArrayBufferType > ( <nl> - inout buffer : Buffer , newCapacity : Int <nl> + func _arrayReserve < _Buffer : ArrayBufferType > ( <nl> + inout buffer : _Buffer , newCapacity : Int <nl> ) { <nl> let oldCount = buffer . count <nl> var newBuffer = _demandUniqueMutableBuffer ( & buffer , oldCount , minimumCapacity : newCapacity ) <nl> func _arrayReserve < Buffer : ArrayBufferType > ( <nl> } <nl> <nl> func _extractOrCopyToNativeArrayBuffer < <nl> - Buffer : ArrayBufferType where Buffer . GeneratorType . Element = = Buffer . Element <nl> - > ( source : Buffer ) <nl> - - > ContiguousArrayBuffer < Buffer . Element > <nl> + _Buffer : ArrayBufferType where _Buffer . GeneratorType . Element = = _Buffer . Element <nl> + > ( source : _Buffer ) <nl> + - > ContiguousArrayBuffer < _Buffer . Element > <nl> { <nl> if let n = source . requestNativeBuffer ( ) { <nl> return n <nl> func _extractOrCopyToNativeArrayBuffer < <nl> <nl> / / / Append items from newItems to buffer <nl> func _arrayAppendSequence < <nl> - Buffer : ArrayBufferType , <nl> - S : Sequence where S . GeneratorType . Element = = Buffer . Element <nl> + _Buffer : ArrayBufferType , <nl> + S : Sequence where S . GeneratorType . Element = = _Buffer . Element <nl> > ( <nl> - inout buffer : Buffer , newItems : S <nl> + inout buffer : _Buffer , newItems : S <nl> ) { <nl> var stream = newItems . generate ( ) <nl> var nextItem = stream . next ( ) <nl> func = = = < T : ArrayType , U : ArrayType > ( lhs : T , rhs : U ) - > Bool { <nl> return false <nl> } <nl> <nl> - return lhsCount = = 0 | | lhs . buffer . identity = = rhs . buffer . identity <nl> + return lhsCount = = 0 | | lhs . _buffer . identity = = rhs . _buffer . identity <nl> } <nl> <nl> / / / Returns false iff these arrays reference exactly the same <nl> func = = < T : Equatable > ( lhs : $ { Self } < T > , rhs : $ { Self } < T > ) - > Bool { <nl> } <nl> <nl> / / Test referential equality . <nl> - if lhsCount = = 0 | | lhs . buffer . identity = = rhs . buffer . identity { <nl> + if lhsCount = = 0 | | lhs . _buffer . identity = = rhs . _buffer . identity { <nl> return true <nl> } <nl> <nl> func ! = < T : Equatable > ( lhs : $ { Self } < T > , rhs : $ { Self } < T > ) - > Bool { <nl> / / / O ( 1 ) . Requires : Base is a base class or base @ objc protocol ( such <nl> / / / as AnyObject ) of Derived . <nl> func _arrayUpCast < Derived , Base > ( a : Array < Derived > ) - > Array < Base > { <nl> - return Array ( a . buffer . castToBufferOf ( Base . self ) ) <nl> + return Array ( a . _buffer . castToBufferOf ( Base . self ) ) <nl> } <nl> <nl> / / / Implements the semantics of ` x as Derived [ ] ` where ` x ` has type <nl> func _arrayCheckedDownCast < Base , Derived > ( a : Array < Base > ) - > Derived [ ] ? { <nl> _sanityCheck ( isBridgedVerbatimToObjectiveC ( Derived . self ) ) <nl> <nl> if _fastPath ( ! a . isEmpty ) { <nl> - let native = a . buffer . requestNativeBuffer ( ) <nl> + let native = a . _buffer . requestNativeBuffer ( ) <nl> <nl> if _fastPath ( native ) { <nl> if native ! . storesOnlyElementsOfType ( Derived . self ) { <nl> - return Array ( a . buffer . castToBufferOf ( Derived . self ) ) <nl> + return Array ( a . _buffer . castToBufferOf ( Derived . self ) ) <nl> } <nl> return nil <nl> } <nl> func _arrayCheckedDownCast < Base , Derived > ( a : Array < Base > ) - > Derived [ ] ? { <nl> } <nl> } <nl> } <nl> - return Array ( a . buffer . castToBufferOf ( Derived . self ) ) <nl> + return Array ( a . _buffer . castToBufferOf ( Derived . self ) ) <nl> } <nl> return [ ] <nl> } <nl> mmm a / stdlib / core / ContiguousArrayBuffer . swift <nl> ppp b / stdlib / core / ContiguousArrayBuffer . swift <nl> struct ContiguousArrayBuffer < T > : ArrayBufferType , LogicValue { <nl> if _fastPath ( base . value . elementTypeIsBridgedVerbatim ) { <nl> return reinterpretCast ( base . storage ) <nl> } <nl> - return ContiguousArray ( self ) . map { bridgeToObjectiveC ( $ 0 ) ! } . buffer . storage ! <nl> + return ContiguousArray ( self ) . map { bridgeToObjectiveC ( $ 0 ) ! } . _buffer . storage ! <nl> } <nl> <nl> / / / An object that keeps the elements stored in this buffer alive <nl> func _copyCollectionToNativeArrayBuffer < C : protocol < _Collection , _Sequence_ > > ( <nl> protocol _ArrayType : Collection { <nl> var count : Int { get } <nl> <nl> - typealias Buffer : ArrayBufferType <nl> - var buffer : Buffer { get } <nl> + typealias _Buffer : ArrayBufferType <nl> + var _buffer : _Buffer { get } <nl> } <nl> mmm a / stdlib / objc / Foundation / Foundation . swift <nl> ppp b / stdlib / objc / Foundation / Foundation . swift <nl> let NSNotFound : Int = . max <nl> extension NSArray : ArrayLiteralConvertible { <nl> class func convertFromArrayLiteral ( elements : AnyObject . . . ) - > Self { <nl> / / + ( instancetype ) arrayWithObjects : ( const id [ ] ) objects count : ( NSUInteger ) cnt ; <nl> - let x = _extractOrCopyToNativeArrayBuffer ( elements . buffer ) <nl> + let x = _extractOrCopyToNativeArrayBuffer ( elements . _buffer ) <nl> let result = self ( objects : UnsafePointer ( x . elementStorage ) , count : x . count ) <nl> _fixLifetime ( x ) <nl> return result <nl> extension Array : _ConditionallyBridgedToObjectiveC { <nl> } <nl> <nl> func bridgeToObjectiveC ( ) - > NSArray { <nl> - return reinterpretCast ( self . buffer . _asCocoaArray ( ) ) <nl> + return reinterpretCast ( self . _buffer . _asCocoaArray ( ) ) <nl> } <nl> <nl> static func bridgeFromObjectiveC ( source : NSArray ) - > Array ? { <nl> extension NSArray { <nl> / / Overlay : - ( instancetype ) initWithObjects : ( id ) firstObj , . . . <nl> convenience init ( objects elements : AnyObject . . . ) { <nl> / / - ( instancetype ) initWithObjects : ( const id [ ] ) objects count : ( NSUInteger ) cnt ; <nl> - let x = _extractOrCopyToNativeArrayBuffer ( elements . buffer ) <nl> + let x = _extractOrCopyToNativeArrayBuffer ( elements . _buffer ) <nl> / / Use Imported : <nl> / / @ objc ( initWithObjects : count : ) <nl> / / init ( withObjects objects : CConstPointer < AnyObject ? > , <nl> extension NSDictionary { <nl> extension NSOrderedSet { <nl> / / - ( instancetype ) initWithObjects : ( id ) firstObj , . . . <nl> convenience init ( objects elements : AnyObject . . . ) { <nl> - let x = _extractOrCopyToNativeArrayBuffer ( elements . buffer ) <nl> + let x = _extractOrCopyToNativeArrayBuffer ( elements . _buffer ) <nl> / / - ( instancetype ) initWithObjects : ( const id [ ] ) objects count : ( NSUInteger ) cnt ; <nl> / / Imported as : <nl> / / @ objc ( initWithObjects : count : ) <nl> extension NSOrderedSet { <nl> extension NSSet { <nl> / / - ( instancetype ) initWithObjects : ( id ) firstObj , . . . <nl> convenience init ( objects elements : AnyObject . . . ) { <nl> - let x = _extractOrCopyToNativeArrayBuffer ( elements . buffer ) <nl> + let x = _extractOrCopyToNativeArrayBuffer ( elements . _buffer ) <nl> / / - ( instancetype ) initWithObjects : ( const id [ ] ) objects count : ( NSUInteger ) cnt ; <nl> / / Imported as : <nl> / / @ objc ( initWithObjects : count : ) <nl> mmm a / test / stdlib / ArrayCore . swift <nl> ppp b / test / stdlib / ArrayCore . swift <nl> struct MrMcRange : Collection { <nl> / / ContiguousArrayBuffer , it is first asked for its underlying <nl> / / ContiguousArrayBuffer . <nl> struct MrMcArray < T > : Collection , _ArrayType { <nl> - typealias Buffer = ContiguousArrayBuffer < T > <nl> + typealias _Buffer = ContiguousArrayBuffer < T > <nl> <nl> - init ( _ buffer : Buffer ) { <nl> - self . buffer = buffer <nl> + init ( _ buffer : _Buffer ) { <nl> + self . _buffer = buffer <nl> } <nl> <nl> var count : Int { <nl> - return buffer . count <nl> + return _buffer . count <nl> } <nl> <nl> typealias GeneratorType = IndexingGenerator < MrMcArray > <nl> struct MrMcArray < T > : Collection , _ArrayType { <nl> } <nl> <nl> var endIndex : Int { <nl> - return buffer . count <nl> + return _buffer . count <nl> } <nl> <nl> subscript ( i : Int ) - > T { <nl> - return buffer [ i ] <nl> + return _buffer [ i ] <nl> } <nl> <nl> - var buffer : Buffer <nl> + var _buffer : _Buffer <nl> } <nl> <nl> func printSequence < T : Sequence > ( x : T ) { <nl> mmm a / test / stdlib / BridgeNonVerbatim . swift <nl> ppp b / test / stdlib / BridgeNonVerbatim . swift <nl> func testScope ( ) { <nl> / / Because the elements come back at + 0 , we really don ' t want to <nl> / / treat them as objects , or we ' ll get double deletion <nl> let objects : Word [ ] = [ 0 , 0 ] <nl> - <nl> - nsx . getObjects ( <nl> - UnsafePointer ( objects . buffer . elementStorage ) , / / pointer cast <nl> - range : _SwiftNSRange ( location : 1 , length : 2 ) ) <nl> + <nl> + objects . withUnsafePointerToElements { <nl> + nsx . getObjects ( <nl> + UnsafePointer ( $ 0 ) , / / pointer cast <nl> + range : _SwiftNSRange ( location : 1 , length : 2 ) ) <nl> + } <nl> <nl> / / CHECK - NEXT : getObjects yields them at + 0 : true <nl> var x = objects [ 0 ] <nl> mmm a / test / stdlib / NewArray . swift . gyb <nl> ppp b / test / stdlib / NewArray . swift . gyb <nl> func printSequence < T : Sequence > ( x : T ) { <nl> } <nl> <nl> func bufferID < T : ArrayType > ( x : T ) - > Int { <nl> - return reinterpretCast ( x . buffer . elementStorage ) as Int <nl> + return reinterpretCast ( x . _buffer . elementStorage ) as Int <nl> } <nl> <nl> func checkReallocation < T : ArrayType > ( <nl> func checkEqual < <nl> <nl> func test < <nl> T : ArrayType <nl> - where T . GeneratorType . Element = = T . Buffer . Element , <nl> - T . Buffer . Element = = T . Element , <nl> + where T . GeneratorType . Element = = T . _Buffer . Element , <nl> + T . _Buffer . Element = = T . Element , <nl> T . Element = = X , <nl> T . IndexType = = Int <nl> > ( _ : T . Type , label : String ) { <nl> import Foundation <nl> func nsArrayOfStrings ( ) - > Array < NSString > { <nl> let src : ContiguousArray < NSString > = [ " foo " , " bar " , " baz " ] <nl> <nl> - let ns = NSArray ( <nl> - objects : UnsafePointer ( src . buffer . elementStorage ) , <nl> - count : src . count ) <nl> - <nl> - return Array ( ArrayBuffer ( reinterpretCast ( ns ) as _CocoaArray ) ) <nl> + return src . withUnsafePointerToElements { <nl> + let ns = NSArray ( objects : UnsafePointer ( $ 0 ) , count : src . count ) <nl> + return Array ( ArrayBuffer ( reinterpretCast ( ns ) as _CocoaArray ) ) <nl> + } <nl> } <nl> <nl> func testCocoa ( ) { <nl>
[ stdlib ] Array API review : privatize [ bB ] uffer
apple/swift
200b89291c1cc48ad516c5b8a64623f325b651da
2014-05-18T17:32:00Z
mmm a / test / mozilla / mozilla . status <nl> ppp b / test / mozilla / mozilla . status <nl> js1_5 / Regress / regress - 234389 : FAIL_OK <nl> js1_5 / Regress / regress - 320119 : FAIL_OK <nl> <nl> <nl> - # We do not recognize a multiline comment as newline character . <nl> - # We are compatible with JSC . <nl> - ecma_3 / LexicalConventions / 7 . 4 - 01 : FAIL_OK <nl> - <nl> - <nl> # No support for toSource ( ) . <nl> js1_5 / Regress / regress - 248444 : FAIL_OK <nl> js1_5 / Regress / regress - 313967 - 01 : FAIL_OK <nl> js1_5 / extensions / regress - 352060 : FAIL_OK <nl> js1_5 / extensions / regress - 352094 : FAIL_OK <nl> js1_5 / extensions / regress - 352261 : FAIL_OK <nl> js1_5 / extensions / regress - 352281 : FAIL_OK <nl> - js1_5 / extensions / regress - 352372 : FAIL_OK <nl> js1_5 / extensions / regress - 352455 : FAIL_OK <nl> js1_5 / extensions / regress - 352604 : FAIL_OK <nl> js1_5 / extensions / regress - 353214 : FAIL_OK <nl>
Fix mozilla test - expectatations to match the new behavior of multi - line comments .
v8/v8
7ba9fea8b5d566fd026f5d6f0b603e4edf810e2a
2011-06-17T08:20:27Z
mmm a / stdlib / private / StdlibUnittest / SymbolLookup . swift <nl> ppp b / stdlib / private / StdlibUnittest / SymbolLookup . swift <nl> <nl> # elseif os ( Linux ) <nl> let RTLD_DEFAULT = UnsafeMutableRawPointer ( bitPattern : 0 ) <nl> # elseif os ( Android ) <nl> - # if arch ( arm ) <nl> + # if arch ( arm ) | | arch ( i386 ) <nl> let RTLD_DEFAULT = UnsafeMutableRawPointer ( bitPattern : 0xffffffff as UInt ) <nl> - # elseif arch ( arm64 ) <nl> + # elseif arch ( arm64 ) | | arch ( x86_64 ) <nl> let RTLD_DEFAULT = UnsafeMutableRawPointer ( bitPattern : 0 ) <nl> # else <nl> # error ( " Unsupported platform " ) <nl>
StdlibUnittest : port to android x86 , x86_64
apple/swift
5d683d9670338d3dbd8638035a4104c2f16fa6f4
2019-11-04T04:52:11Z
mmm a / tensorflow / compiler / xla / service / gpu / cudnn_fused_conv_rewriter . cc <nl> ppp b / tensorflow / compiler / xla / service / gpu / cudnn_fused_conv_rewriter . cc <nl> absl : : optional < ConvWithRelu > FindConvWithRelu ( HloInstruction * instr ) { <nl> return absl : : nullopt ; <nl> } <nl> <nl> - / / In order to map to cudnnConvolutionBiasAcitvationForward for int8 , the <nl> + / / In order to map to cudnnConvolutionBiasActivationForward for int8 , the <nl> / / convolution output is float , i . e . conv < float > ( int8_x , int8_w ) <nl> if ( conv - > operand ( 0 ) - > shape ( ) . element_type ( ) = = xla : : S8 ) { <nl> if ( conv - > shape ( ) . tuple_shapes ( 0 ) . element_type ( ) ! = xla : : F32 ) { <nl> StatusOr < std : : unique_ptr < HloInstruction > > TryRewriteToCudnnForwardRelu ( <nl> <nl> / / Fuse bias / scaling / ReLU with convolution custom call with floating point <nl> / / output <nl> - StatusOr < bool > RunFuseBiasSideActivation ( <nl> - HloModule * module , <nl> - std : : unordered_set < const HloInstruction * > & tracked_custom_calls ) { <nl> + StatusOr < bool > RunFuseBiasSideActivation ( HloModule * module ) { <nl> bool changed = false ; <nl> for ( HloComputation * computation : module - > MakeNonfusionComputations ( ) ) { <nl> std : : vector < ConvWithRelu > matches ; <nl> StatusOr < bool > RunFuseBiasSideActivation ( <nl> replacements ; <nl> for ( const ConvWithRelu & match : matches ) { <nl> TF_ASSIGN_OR_RETURN ( auto new_instr , TryRewriteToCudnnForwardRelu ( match ) ) ; <nl> - / / Update the tracked convolutions , if they are going to be replaced . <nl> - if ( tracked_custom_calls . find ( match . conv ) ! = tracked_custom_calls . end ( ) ) { <nl> - tracked_custom_calls . erase ( match . conv ) ; <nl> - tracked_custom_calls . insert ( new_instr - > operand ( 0 ) ) ; <nl> - } <nl> replacements . push_back ( { match . maximum , std : : move ( new_instr ) } ) ; <nl> changed = true ; <nl> } <nl> StatusOr < bool > RunFuseBiasSideActivation ( <nl> / / Describes a matched pattern : <nl> / / convert_or_clamp ( get_tuple_element ( custom_call ( x , w , . . . ) ) ) ; <nl> / / where the custom_call targets CuDNN convolution ( either pure convolution or <nl> - / / fused convlution ) . <nl> + / / fused convolution ) . <nl> struct ConvWithConvertOrClamp { <nl> HloInstruction * convert_or_clamp ; <nl> HloInstruction * gte ; <nl> HloCustomCallInstruction * conv ; <nl> } ; <nl> <nl> - absl : : optional < ConvWithConvertOrClamp > FindConvWithClamp ( <nl> + absl : : optional < ConvWithConvertOrClamp > FindConvWithClampAndConvertToInt8 ( <nl> HloInstruction * instr ) { <nl> using match : : Broadcast ; <nl> using match : : Clamp ; <nl> absl : : optional < ConvWithConvertOrClamp > FindConvWithClamp ( <nl> using match : : Op ; <nl> <nl> / / The pattern we want to match : <nl> - / / clamp ( broadcast ( - 128 ) , ( get_tuple_element ( custom_call ( int8_x , <nl> - / / int8_w , . . . ) ) , broadcast ( 127 ) ; <nl> + / / convert < int8 > ( clamp ( broadcast ( - 128 ) , ( get_tuple_element ( custom_call ( int8_x , <nl> + / / int8_w , . . . ) ) , broadcast ( 127 ) ) ; <nl> / / <nl> <nl> HloInstruction * gte = nullptr ; <nl> absl : : optional < ConvWithConvertOrClamp > FindConvWithClamp ( <nl> auto lower_pattern = Broadcast ( match : : ConstantScalar ( - 128 ) ) ; <nl> auto upper_pattern = Broadcast ( match : : ConstantScalar ( 127 ) ) ; <nl> auto pattern = <nl> - Clamp ( lower_pattern , <nl> + Convert ( Clamp ( lower_pattern , <nl> GetTupleElement ( <nl> & gte , Op ( & conv_instr ) . WithOpcode ( HloOpcode : : kCustomCall ) , 0 ) , <nl> - upper_pattern ) ; <nl> + upper_pattern ) ) ; <nl> <nl> if ( Match ( instr , pattern ) ) { <nl> - if ( conv_instr - > operand ( 0 ) - > shape ( ) . element_type ( ) = = xla : : S8 ) { <nl> + if ( conv_instr - > operand ( 0 ) - > shape ( ) . element_type ( ) = = xla : : S8 & & <nl> + instr - > shape ( ) . element_type ( ) = = xla : : S8 ) { <nl> HloCustomCallInstruction * conv = <nl> CastOrNull < HloCustomCallInstruction > ( conv_instr ) ; <nl> return ConvWithConvertOrClamp { instr , gte , conv } ; <nl> absl : : optional < ConvWithConvertOrClamp > FindConvWithClamp ( <nl> return absl : : nullopt ; <nl> } <nl> <nl> - Status TryRewriteForConvertOrClampImpl ( ConvWithConvertOrClamp match ) { <nl> + StatusOr < bool > TryRewriteForConvertOrClampImpl ( ConvWithConvertOrClamp match ) { <nl> auto conv = match . conv ; <nl> auto gte = match . gte ; <nl> auto convert_or_clamp = match . convert_or_clamp ; <nl> Status TryRewriteForConvertOrClampImpl ( ConvWithConvertOrClamp match ) { <nl> convert_or_clamp - > ReplaceAllUsesWithDifferentShape ( gte ) ; <nl> conv - > parent ( ) - > RemoveInstructionAndUnusedOperands ( convert_or_clamp ) ; <nl> <nl> - return Status : : OK ( ) ; <nl> + return true ; <nl> } <nl> <nl> - Status TryRewriteForFinalOutput ( ConvWithConvertOrClamp match ) { <nl> + StatusOr < bool > TryRewriteForFinalOutput ( ConvWithConvertOrClamp match ) { <nl> + bool changed = false ; <nl> / / When the matched clamp has a single user , which is convert < int8 > , we <nl> / / will absorb it , if <nl> / / 1 . the side_input matches a convert < float > ( int8_side_input ) , or <nl> Status TryRewriteForFinalOutput ( ConvWithConvertOrClamp match ) { <nl> instr - > operand ( 0 ) - > user_count ( ) = = 1 & & <nl> instr - > operand ( 0 ) - > shape ( ) . element_type ( ) = = X ) ; <nl> } ; <nl> - HloInstruction * convert = match . convert_or_clamp - > users ( ) [ 0 ] ; <nl> - if ( match . conv - > operand_count ( ) < 4 & & <nl> - ( is_one_to_one_X_to_Y_cast ( convert , F32 , S8 ) | | <nl> - is_one_to_one_X_to_Y_cast ( convert , S32 , S8 ) ) ) { <nl> + <nl> + if ( match . conv - > operand_count ( ) < 4 ) { <nl> / / Conv input # 3 ( zero based ) is side_input , after x , w , and bias . <nl> - / / <nl> - / / Update convert_or_clamp with the output converter , so that it will be <nl> - / / skipped by TryRewriteForConvertOrClampImpl <nl> - match . convert_or_clamp = match . convert_or_clamp - > users ( ) [ 0 ] ; <nl> - } else if ( match . conv - > operand_count ( ) > = 4 & & <nl> - is_one_to_one_X_to_Y_cast ( convert , F32 , S8 ) & & <nl> - is_one_to_one_X_to_Y_cast ( match . conv - > operand ( 3 ) , S8 , F32 ) ) { <nl> - / / If both conv output and side_input have convert_float_to_int8 and <nl> - / / convert_int8_to_float , respectively , absorb both . <nl> - / / <nl> - / / Update convert_or_clamp with the output converter , so that it will be <nl> - / / skipped by TryRewriteForConvertOrClampImpl <nl> - match . convert_or_clamp = match . convert_or_clamp - > users ( ) [ 0 ] ; <nl> - / / Bypass the converter on side input <nl> + / / Side input doesn ' t exist in this case . <nl> + TF_ASSIGN_OR_RETURN ( changed , TryRewriteForConvertOrClampImpl ( match ) ) ; <nl> + } else if ( is_one_to_one_X_to_Y_cast ( match . conv - > operand ( 3 ) , S8 , F32 ) ) { <nl> + / / If side_input has a convert_float_to_int8 , absorb it as well . <nl> auto side_converter = match . conv - > mutable_operand ( 3 ) ; <nl> side_converter - > ReplaceAllUsesWithDifferentShape ( <nl> side_converter - > mutable_operand ( 0 ) ) ; <nl> side_converter - > parent ( ) - > RemoveInstructionAndUnusedOperands ( <nl> side_converter ) ; <nl> - } <nl> <nl> - return TryRewriteForConvertOrClampImpl ( match ) ; <nl> + TF_ASSIGN_OR_RETURN ( changed , TryRewriteForConvertOrClampImpl ( match ) ) ; <nl> + } <nl> + return changed ; <nl> } <nl> <nl> / / Fuse the clamp / convert pattern with the int8 convolution custom call <nl> / / ( either pure or fused ) for int8 output <nl> - StatusOr < bool > RunFuseClamp ( <nl> - HloModule * module , <nl> - std : : unordered_set < const HloInstruction * > & tracked_custom_calls ) { <nl> + StatusOr < bool > RunFuseClamp ( HloModule * module ) { <nl> bool changed = false ; <nl> for ( HloComputation * computation : module - > MakeNonfusionComputations ( ) ) { <nl> std : : vector < ConvWithConvertOrClamp > matches ; <nl> int num_forward_convs = 0 ; <nl> for ( auto instr : computation - > instructions ( ) ) { <nl> - auto match = FindConvWithClamp ( instr ) ; <nl> + auto match = FindConvWithClampAndConvertToInt8 ( instr ) ; <nl> if ( match . has_value ( ) ) { <nl> matches . push_back ( * match ) ; <nl> } <nl> - if ( auto call = DynCast < HloCustomCallInstruction > ( instr ) ) { <nl> - if ( call - > custom_call_target ( ) = = kCudnnConvForwardCallTarget ) { <nl> - num_forward_convs + + ; <nl> - } <nl> - } <nl> } <nl> - VLOG ( 1 ) < < " Identified cuDNN forward conv + convert : " < < matches . size ( ) <nl> - < < " out of " < < num_forward_convs < < " forward convs . " ; <nl> std : : vector < std : : pair < HloInstruction * , std : : unique_ptr < HloInstruction > > > <nl> replacements ; <nl> for ( const ConvWithConvertOrClamp & match : matches ) { <nl> - TF_RETURN_IF_ERROR ( TryRewriteForFinalOutput ( match ) ) ; <nl> - / / We have done with the convolution custom_call . <nl> - tracked_custom_calls . erase ( match . conv ) ; <nl> - changed = true ; <nl> + TF_ASSIGN_OR_RETURN ( bool c , TryRewriteForFinalOutput ( match ) ) ; <nl> + changed | = c ; <nl> + } <nl> + <nl> + / / Report error for any convolution still having int32 output . <nl> + / / Although int32 output convolution will trigger other sanity check errors <nl> + / / later , we want to give specific error message here . <nl> + for ( auto instr : computation - > instructions ( ) ) { <nl> + if ( auto call = DynCast < HloCustomCallInstruction > ( instr ) ) { <nl> + if ( ( call - > custom_call_target ( ) = = kCudnnConvForwardCallTarget | | <nl> + call - > custom_call_target ( ) = = <nl> + kCudnnConvBiasActivationForwardCallTarget ) & & <nl> + call - > shape ( ) . tuple_shapes ( 0 ) . element_type ( ) = = xla : : S32 ) { <nl> + return Unimplemented ( <nl> + " Integer convolutions for CuDNN must have float or int8 output . " <nl> + " Use convert to cast output to float or the following pattern to " <nl> + " int8 : " <nl> + " clamp ( broadcast ( - 128 ) , conv ( int8_x , int8_w , . . . ) , " <nl> + " broadcast ( 127 ) ) . " ) ; <nl> + } <nl> + } <nl> } <nl> - } <nl> - / / All convolutions being tracked shall be clamped by now . We error out if <nl> - / / anything left , because CuDNN semantics require clamping , but XLA ' s don ' t . <nl> - if ( ! tracked_custom_calls . empty ( ) ) { <nl> - return Unimplemented ( <nl> - " Integer convolutions for CuDNN must use this pattern to clamp output : " <nl> - " clamp ( broadcast ( - 128 ) , conv ( int8_x , int8_w , . . . ) , broadcast ( 127 ) ) ) . " ) ; <nl> } <nl> return changed ; <nl> } <nl> absl : : optional < ConvWithConvertOrClamp > FindConvWithConvertToFloat ( <nl> return absl : : nullopt ; <nl> } <nl> <nl> - Status TryRewriteForConvertToFloat ( ConvWithConvertOrClamp match ) { <nl> + StatusOr < bool > TryRewriteForConvertToFloat ( ConvWithConvertOrClamp match ) { <nl> return TryRewriteForConvertOrClampImpl ( match ) ; <nl> } <nl> <nl> Status TryRewriteForConvertToFloat ( ConvWithConvertOrClamp match ) { <nl> / / convert < float > ( GetTupleElement < int32 > ( custom_call < int32 > ( int8_x , int8_w ) ) ) <nl> / / to <nl> / / GetTupleElement < float > ( custom_call < int32 > ( int8_x , int8_w ) ) <nl> - StatusOr < std : : unordered_set < const HloInstruction * > > RunFuseConvertToFloat ( <nl> - HloModule * module ) { <nl> - std : : unordered_set < const HloInstruction * > tracked_custom_calls ; <nl> + StatusOr < bool > RunFuseConvertToFloat ( HloModule * module ) { <nl> + bool changed = false ; <nl> const auto is_int8_conv = [ ] ( HloInstruction * instr ) - > bool { <nl> using match : : Op ; <nl> HloInstruction * conv_instr ; <nl> StatusOr < std : : unordered_set < const HloInstruction * > > RunFuseConvertToFloat ( <nl> auto match = FindConvWithConvertToFloat ( instr ) ; <nl> if ( match . has_value ( ) ) { <nl> matches . push_back ( * match ) ; <nl> - / / Track all int8 to float convolutions created by this transform . <nl> - tracked_custom_calls . insert ( match . value ( ) . conv ) ; <nl> - } else if ( is_int8_conv ( instr ) ) { <nl> - / / Track all int8 to int32 convolution . <nl> - tracked_custom_calls . insert ( instr ) ; <nl> } <nl> } <nl> <nl> for ( const ConvWithConvertOrClamp & match : matches ) { <nl> - TF_RETURN_IF_ERROR ( TryRewriteForConvertToFloat ( match ) ) ; <nl> + TF_ASSIGN_OR_RETURN ( bool c , TryRewriteForConvertToFloat ( match ) ) ; <nl> + changed | = c ; <nl> } <nl> } <nl> - return tracked_custom_calls ; <nl> + return changed ; <nl> } <nl> } / / namespace <nl> <nl> StatusOr < bool > CudnnFusedConvRewriter : : Run ( HloModule * module ) { <nl> - / / In addition to fusing convolutions with fuse bias / scaling / ReLU , we track <nl> - / / the convolutions doing int8 convolutio patterns matching with <nl> - / / tracked_custom_calls in this transform . Because the pattern matching and <nl> - / / graph tranformation happens in multiple phases for compilation efficiency , <nl> - / / we don ' t know the final matching result until all phases complete . During <nl> - / / this process , the intermediate HLOs may change semantics temporarily and <nl> - / / expect to be fixed in a later phase . However , the fix may not happen , if <nl> - / / the pattern matching can ' t finish successfully and we don ' t undo <nl> - / / transforms . We can ' t let such partially modified HLOs that may alter the <nl> - / / original semantics slip . By tracking the convolutions being matched and <nl> - / / mutated , we are able to report error about any HLO that we are responsible <nl> - / / for alternating semantics . <nl> - <nl> - TF_ASSIGN_OR_RETURN ( <nl> - std : : unordered_set < const HloInstruction * > tracked_custom_calls , <nl> - RunFuseConvertToFloat ( module ) ) ; <nl> + TF_ASSIGN_OR_RETURN ( bool fused_for_convert_to_float , <nl> + RunFuseConvertToFloat ( module ) ) ; <nl> <nl> TF_ASSIGN_OR_RETURN ( bool fused_for_bias , <nl> - RunFuseBiasSideActivation ( module , tracked_custom_calls ) ) ; <nl> + RunFuseBiasSideActivation ( module ) ) ; <nl> <nl> TF_ASSIGN_OR_RETURN ( bool fused_for_clamp , <nl> - RunFuseClamp ( module , tracked_custom_calls ) ) ; <nl> + RunFuseClamp ( module ) ) ; <nl> <nl> - return fused_for_bias | | fused_for_clamp ; <nl> + return fused_for_convert_to_float | | fused_for_bias | | fused_for_clamp ; <nl> } <nl> } / / namespace gpu <nl> } / / namespace xla <nl> mmm a / tensorflow / compiler / xla / service / gpu / cudnn_fused_conv_rewriter . h <nl> ppp b / tensorflow / compiler / xla / service / gpu / cudnn_fused_conv_rewriter . h <nl> namespace gpu { <nl> / / cudnnConvolutionBiasActivationForward ( x , w , bias , alpha1 , alpha2 , side ) <nl> / / <nl> / / Integer convolution requires additional patterns to match CuDNN semantics : <nl> - / / from <nl> - / / cast < int8 > ( clamp < - 128 , 127 > ( conv ( cast < int32 > ( int8_x ) , cast < int32 > ( int8_w ) ) ) ) <nl> + / / # 1 from <nl> + / / cast < int8 > ( clamp < - 128 , 127 > ( conv ( int8_x , int8_w ) ) ) <nl> / / to <nl> / / cudnnConvolutionForward < int8 > ( int8_x , int8_w ) <nl> - / / or from <nl> - / / clamp < - 128 , 127 > ( conv ( cast < int32 > ( int8_x ) , cast < int32 > ( int8_w ) ) ) <nl> + / / or # 2 from <nl> + / / cast < float > ( conv ( int8_x , int8_w ) ) <nl> / / to <nl> / / cudnnConvolutionForward < float > ( int8_x , int8_w ) <nl> - / / or from <nl> - / / cast < int8 > ( clamp < - 128 , 127 > ( max ( 0 , alpha1 * <nl> - / / cast < float > ( conv ( cast < int32 > ( int8_x ) , cast < int32 > ( int8_w ) ) ) + <nl> - / / alpha2 * cast < float > ( int8_side ) + <nl> + / / or # 3 from <nl> + / / cast < int8 > ( clamp < - 128 , 127 > ( max ( 0 , alpha1 * <nl> + / / cast < float > ( conv ( int8_x , int8_w ) ) + <nl> + / / alpha2 * cast < float > ( int8_side ) + <nl> / / broadcast ( bias ) ) ) <nl> / / to <nl> - / / cudnnConvolutionBiasActivationForward < int8 > ( int8_x , int8_w , bias , alpha1 , alpha2 , int8_side ) <nl> - / / or from <nl> - / / clamp < - 128 , 127 > ( max ( 0 , alpha1 * <nl> - / / cast < float > ( conv ( cast < int32 > ( int8_x ) , cast < int32 > ( int8_w ) ) ) + <nl> - / / alpha2 * float_side + <nl> - / / broadcast ( bias ) ) ) <nl> + / / cudnnConvolutionBiasActivationForward < int8 > ( int8_x , int8_w , bias , alpha1 , <nl> + / / alpha2 , int8_side ) <nl> + / / or # 4 from <nl> + / / max ( 0 , alpha1 * cast < float > ( conv ( int8_x , int8_w ) ) + <nl> + / / alpha2 * float_side + broadcast ( bias ) ) <nl> / / to <nl> - / / cudnnConvolutionBiasActivationForward < float > ( int8_x , int8_w , bias , alpha1 , alpha2 , float_side ) <nl> + / / cudnnConvolutionBiasActivationForward < float > ( int8_x , int8_w , bias , alpha1 , <nl> + / / alpha2 , float_side ) <nl> <nl> class CudnnFusedConvRewriter : public HloModulePass { <nl> public : <nl>
1 . Update int8 - to - float convolution patterns by removing the clamp .
tensorflow/tensorflow
89ba54f5cd734a247ed42cc686a309b739fd598e
2019-08-27T04:26:15Z
mmm a / db / client . cpp <nl> ppp b / db / client . cpp <nl> namespace mongo { <nl> _client - > _context = _oldContext ; / / note : _oldContext may be null <nl> } <nl> <nl> + string Client : : toString ( ) const { <nl> + stringstream ss ; <nl> + if ( _curOp ) <nl> + ss < < _curOp - > infoNoauth ( ) . jsonString ( ) ; <nl> + return ss . str ( ) ; <nl> + } <nl> + <nl> + string sayClientState ( ) { <nl> + Client * c = currentClient . get ( ) ; <nl> + if ( ! c ) <nl> + return " no client " ; <nl> + return c - > toString ( ) ; <nl> + } <nl> + <nl> } <nl> mmm a / db / client . h <nl> ppp b / db / client . h <nl> namespace mongo { <nl> bool isGod ( ) const { return _god ; } <nl> <nl> friend class CurOp ; <nl> + <nl> + string toString ( ) const ; <nl> } ; <nl> <nl> inline Client & cc ( ) { <nl> namespace mongo { <nl> cc ( ) . getContext ( ) - > unlocked ( ) ; <nl> } <nl> } <nl> + <nl> + string sayClientState ( ) ; <nl> <nl> } ; <nl> <nl> mmm a / db / concurrency . h <nl> ppp b / db / concurrency . h <nl> <nl> <nl> namespace mongo { <nl> <nl> + string sayClientState ( ) ; <nl> + <nl> / * mutex time stats * / <nl> class MutexInfo { <nl> unsigned long long start , enter , timeLocked ; / / all in microseconds <nl> namespace mongo { <nl> _state . set ( s + 1 ) ; <nl> return ; <nl> } <nl> - massert ( 10293 , " internal error : locks are not upgradeable " , s = = 0 ) ; <nl> + massert ( 10293 , ( string ) " internal error : locks are not upgradeable : " + sayClientState ( ) , s = = 0 ) ; <nl> _state . set ( 1 ) ; <nl> _m . lock ( ) ; <nl> _minfo . entered ( ) ; <nl>
debugging MINOR
mongodb/mongo
52427e60ebef9e70fa65f38c31f63bdf6784a9b9
2010-02-05T03:51:57Z
mmm a / src / lstm / network . cpp <nl> ppp b / src / lstm / network . cpp <nl> Network * Network : : CreateFromFile ( TFile * fp ) { <nl> network = new FullyConnected ( stub . name_ , stub . ni_ , stub . no_ , stub . type_ ) ; <nl> break ; <nl> default : <nl> + ; <nl> } <nl> if ( network ) { <nl> network - > training_ = stub . training_ ; <nl> Network * Network : : CreateFromFile ( TFile * fp ) { <nl> network - > num_weights_ = stub . num_weights_ ; <nl> if ( ! network - > DeSerialize ( fp ) ) { <nl> delete network ; <nl> - network = ‌ nullptr ; <nl> + network = nullptr ; <nl> } <nl> } <nl> return network ; <nl>
Merge pull request from stweil / fix
tesseract-ocr/tesseract
d27f5b58f93511f684f05c361fd0ee350fb1cd5d
2018-07-05T05:54:07Z
mmm a / boards . txt <nl> ppp b / boards . txt <nl> esp01 . upload . speed = 115200 <nl> esp01 . upload . resetmethod = none <nl> esp01 . upload . maximum_size = 524288 <nl> esp01 . upload . wait_for_upload_port = true <nl> + esp01 . serial . disableDTR = true <nl> + esp01 . serial . disableRTS = true <nl> <nl> esp01 . build . mcu = esp8266 <nl> esp01 . build . f_cpu = 80000000L <nl>
Added to configuration options to disable ArduinoIDE SerialMonitor to set DTR and RTS active when the Monitor is opened
esp8266/Arduino
0a1eae4df56cd08ce161b1d78ffab4f15ecc93fd
2015-04-01T10:41:36Z
mmm a / ELECTRON_VERSION <nl> ppp b / ELECTRON_VERSION <nl> @ @ - 1 + 1 @ @ <nl> - 8 . 0 . 0 - nightly . 20191008 <nl> \ No newline at end of file <nl> + 8 . 0 . 0 - nightly . 20191009 <nl> \ No newline at end of file <nl> mmm a / package . json <nl> ppp b / package . json <nl> <nl> { <nl> " name " : " electron " , <nl> - " version " : " 8 . 0 . 0 - nightly . 20191008 " , <nl> + " version " : " 8 . 0 . 0 - nightly . 20191009 " , <nl> " repository " : " https : / / github . com / electron / electron " , <nl> " description " : " Build cross platform desktop apps with JavaScript , HTML , and CSS " , <nl> " devDependencies " : { <nl> mmm a / shell / browser / resources / win / atom . rc <nl> ppp b / shell / browser / resources / win / atom . rc <nl> END <nl> / / <nl> <nl> VS_VERSION_INFO VERSIONINFO <nl> - FILEVERSION 8 , 0 , 0 , 20191008 <nl> - PRODUCTVERSION 8 , 0 , 0 , 20191008 <nl> + FILEVERSION 8 , 0 , 0 , 20191009 <nl> + PRODUCTVERSION 8 , 0 , 0 , 20191009 <nl> FILEFLAGSMASK 0x3fL <nl> # ifdef _DEBUG <nl> FILEFLAGS 0x1L <nl>
Bump v8 . 0 . 0 - nightly . 20191009
electron/electron
c250cd6e7c56632c853d8a8bda0bce244cfb0a47
2019-10-09T15:33:39Z
mmm a / python / caffe / pycaffe . cpp <nl> ppp b / python / caffe / pycaffe . cpp <nl> struct CaffeNet <nl> return vector < CaffeBlob > ( net_ - > blobs ( ) . begin ( ) , net_ - > blobs ( ) . end ( ) ) ; <nl> } <nl> <nl> + vector < CaffeBlob > params ( ) { <nl> + return vector < CaffeBlob > ( net_ - > params ( ) . begin ( ) , net_ - > params ( ) . end ( ) ) ; <nl> } <nl> <nl> / / The pointer to the internal caffe : : Net instant . <nl> BOOST_PYTHON_MODULE ( pycaffe ) <nl> . def ( " set_phase_test " , & CaffeNet : : set_phase_test ) <nl> . def ( " set_device " , & CaffeNet : : set_device ) <nl> . def ( " blobs " , & CaffeNet : : blobs ) <nl> + . def ( " params " , & CaffeNet : : params ) <nl> ; <nl> <nl> boost : : python : : class_ < CaffeBlob , CaffeBlobWrap > ( <nl>
Expose params in Python interface
BVLC/caffe
ae72b9e8701e34004d5ca7c09d5ddded8bdfcefb
2014-01-14T23:46:52Z
mmm a / tensorflow / core / grappler / optimizers / auto_mixed_precision . cc <nl> ppp b / tensorflow / core / grappler / optimizers / auto_mixed_precision . cc <nl> class NodeTypeAttrMap { <nl> input_arg_inds . size ( ) , " non - control input ( s ) , but got " , <nl> node . input_size ( ) ) ; <nl> } <nl> + / / Note that the mappings generated here include inputs / outputs with fixed <nl> + / / types . This makes the mappings complete ( all inputs and outputs are <nl> + / / included ) , and allows the graph rewriter to propagate black paint <nl> + / / from / through ops with fixed types . <nl> io2type_entry . first . reserve ( input_arg_inds . size ( ) ) ; <nl> for ( int i = 0 ; i < ( int ) input_arg_inds . size ( ) ; + + i ) { <nl> const auto & arg_inds = input_arg_inds [ i ] ; <nl>
Add note regarding fixed types in NodeTypeAttrMap
tensorflow/tensorflow
1af2f7064c250e9c667b5b508ef5ae0d150019ce
2019-03-26T00:49:05Z
mmm a / xbmc / utils / XBMCTinyXML . cpp <nl> ppp b / xbmc / utils / XBMCTinyXML . cpp <nl> bool CXBMCTinyXML : : Parse ( const std : : string & data , TiXmlEncoding encoding / * = TIX <nl> <nl> std : : string detectedCharset ; <nl> if ( CCharsetDetection : : DetectXmlEncoding ( data , detectedCharset ) & & TryParse ( data , detectedCharset ) ) <nl> + { <nl> + if ( ! m_SuggestedCharset . empty ( ) ) <nl> + CLog : : Log ( LOGWARNING , " % s : \ " % s \ " charset was used instead of suggested charset \ " % s \ " for % s " , __FUNCTION__ , m_UsedCharset . c_str ( ) , m_SuggestedCharset . c_str ( ) , <nl> + ( value . empty ( ) ? " XML data " : ( " file \ " " + value + " \ " " ) . c_str ( ) ) ) ; <nl> + <nl> return true ; <nl> + } <nl> <nl> / / check for valid UTF - 8 <nl> if ( m_SuggestedCharset ! = " UTF - 8 " & & detectedCharset ! = " UTF - 8 " & & CUtf8Utils : : isValidUtf8 ( data ) & & <nl> TryParse ( data , " UTF - 8 " ) ) <nl> - return true ; <nl> + { <nl> + if ( ! m_SuggestedCharset . empty ( ) ) <nl> + CLog : : Log ( LOGWARNING , " % s : \ " % s \ " charset was used instead of suggested charset \ " % s \ " for % s " , __FUNCTION__ , m_UsedCharset . c_str ( ) , m_SuggestedCharset . c_str ( ) , <nl> + ( value . empty ( ) ? " XML data " : ( " file \ " " + value + " \ " " ) . c_str ( ) ) ) ; <nl> + else if ( ! detectedCharset . empty ( ) ) <nl> + CLog : : Log ( LOGWARNING , " % s : \ " % s \ " charset was used instead of detected charset \ " % s \ " for % s " , __FUNCTION__ , m_UsedCharset . c_str ( ) , detectedCharset . c_str ( ) , <nl> + ( value . empty ( ) ? " XML data " : ( " file \ " " + value + " \ " " ) . c_str ( ) ) ) ; <nl> + return true ; <nl> + } <nl> <nl> / / fallback : try user GUI charset <nl> if ( TryParse ( data , g_langInfo . GetGuiCharSet ( ) ) ) <nl> + { <nl> + if ( ! m_SuggestedCharset . empty ( ) ) <nl> + CLog : : Log ( LOGWARNING , " % s : \ " % s \ " charset was used instead of suggested charset \ " % s \ " for % s " , __FUNCTION__ , m_UsedCharset . c_str ( ) , m_SuggestedCharset . c_str ( ) , <nl> + ( value . empty ( ) ? " XML data " : ( " file \ " " + value + " \ " " ) . c_str ( ) ) ) ; <nl> + else if ( ! detectedCharset . empty ( ) ) <nl> + CLog : : Log ( LOGWARNING , " % s : \ " % s \ " charset was used instead of detected charset \ " % s \ " for % s " , __FUNCTION__ , m_UsedCharset . c_str ( ) , detectedCharset . c_str ( ) , <nl> + ( value . empty ( ) ? " XML data " : ( " file \ " " + value + " \ " " ) . c_str ( ) ) ) ; <nl> return true ; <nl> + } <nl> <nl> / / can ' t detect correct data charset , try to process data as is <nl> - return InternalParse ( data , TIXML_ENCODING_UNKNOWN ) ; <nl> + if ( InternalParse ( data , TIXML_ENCODING_UNKNOWN ) ) <nl> + { <nl> + if ( ! m_SuggestedCharset . empty ( ) ) <nl> + CLog : : Log ( LOGWARNING , " % s : Processed % s as unknown encoding instead of suggested \ " % s \ " " , __FUNCTION__ , <nl> + ( value . empty ( ) ? " XML data " : ( " file \ " " + value + " \ " " ) . c_str ( ) ) , m_SuggestedCharset . c_str ( ) ) ; <nl> + else if ( ! detectedCharset . empty ( ) ) <nl> + CLog : : Log ( LOGWARNING , " % s : Processed % s as unknown encoding instead of detected \ " % s \ " " , __FUNCTION__ , <nl> + ( value . empty ( ) ? " XML data " : ( " file \ " " + value + " \ " " ) . c_str ( ) ) , detectedCharset . c_str ( ) ) ; <nl> + return true ; <nl> + } <nl> + <nl> + return false ; <nl> } <nl> <nl> bool CXBMCTinyXML : : TryParse ( const std : : string & data , const std : : string & tryDataCharset ) <nl> bool CXBMCTinyXML : : TryParse ( const std : : string & data , const std : : string & tryDataC <nl> } <nl> <nl> m_UsedCharset = tryDataCharset ; <nl> - if ( ! m_SuggestedCharset . empty ( ) & & m_UsedCharset ! = m_SuggestedCharset ) <nl> - CLog : : Log ( LOGWARNING , " % s : Using \ " % s \ " charset instead of \ " % s \ " charset % s " , __FUNCTION__ , m_UsedCharset . c_str ( ) , m_SuggestedCharset . c_str ( ) , <nl> - ( value . empty ( ) ? " " : ( " for file " + value ) . c_str ( ) ) ) ; <nl> - <nl> return true ; <nl> } <nl> <nl>
Merge pull request from Karlson2k / xml_warn_charset
xbmc/xbmc
c0ed440ed153460998eec56613978dbb8d4b6e8a
2014-03-22T22:04:24Z
mmm a / CMakeLists . txt <nl> ppp b / CMakeLists . txt <nl> EXECUTE_PROCESS ( <nl> ERROR_VARIABLE generated_cpp <nl> RESULT_VARIABLE RETURN_VALUE <nl> ) <nl> + # Filter out anything that is not a source file <nl> + filter_list ( generated_cpp generated_cpp " ( \ \ . cpp | \ \ . h ) $ " ) <nl> if ( NOT RETURN_VALUE EQUAL 0 ) <nl> message ( STATUS $ { generated_cpp } ) <nl> message ( FATAL_ERROR " Failed to get generated_cpp list " ) <nl>
Fix ATen build for debug python
pytorch/pytorch
dc2ed7fd3394db6627ace2c9386bfa8b3e76e810
2017-07-12T18:52:03Z
mmm a / dbms / include / DB / Dictionaries / ComplexKeyCacheDictionary . h <nl> ppp b / dbms / include / DB / Dictionaries / ComplexKeyCacheDictionary . h <nl> <nl> # include < DB / Common / HashTable / HashMap . h > <nl> # include < DB / Columns / ColumnString . h > <nl> # include < DB / Core / StringRef . h > <nl> + # include < ext / enumerate . hpp > <nl> # include < ext / scope_guard . hpp > <nl> # include < ext / bit_cast . hpp > <nl> # include < ext / range . hpp > <nl> <nl> # include < vector > <nl> # include < map > <nl> # include < tuple > <nl> - # include < DB / DataStreams / NullBlockInputStream . h > <nl> <nl> <nl> namespace DB <nl> class ComplexKeyCacheDictionary final : public IDictionaryBase <nl> <nl> std : : size_t getBytesAllocated ( ) const override <nl> { <nl> - return bytes_allocated + key_size_is_fixed ? fixed_size_keys_pool - > size ( ) : keys_pool - > size ( ) ; <nl> + return bytes_allocated + ( key_size_is_fixed ? fixed_size_keys_pool - > size ( ) : keys_pool - > size ( ) ) ; <nl> } <nl> <nl> std : : size_t getQueryCount ( ) const override { return query_count . load ( std : : memory_order_relaxed ) ; } <nl> class ComplexKeyCacheDictionary final : public IDictionaryBase <nl> outdated_keys [ key ] . push_back ( row ) ; <nl> else <nl> { <nl> - const auto string_ref = cell . isDefault ( ) ? get_default ( row ) : attribute_array [ cell_idx ] ; <nl> + const auto string_ref = cell . isDefault ( ) ? get_default ( row ) : attribute_array [ cell_idx ] ; <nl> map [ key ] = String { string_ref } ; <nl> total_length + = string_ref . size + 1 ; <nl> } <nl> class ComplexKeyCacheDictionary final : public IDictionaryBase <nl> auto stream = source_ptr - > loadKeys ( in_key_columns , in_requested_rows ) ; <nl> stream - > readPrefix ( ) ; <nl> <nl> - MapType < UInt8 > remaining_keys { in_requested_rows . size ( ) } ; <nl> + MapType < bool > remaining_keys { in_requested_rows . size ( ) } ; <nl> for ( const auto row : in_requested_rows ) <nl> - remaining_keys . insert ( { in_keys [ row ] , 0 } ) ; <nl> + remaining_keys . insert ( { in_keys [ row ] , false } ) ; <nl> <nl> std : : uniform_int_distribution < std : : uint64_t > distribution { <nl> dict_lifetime . min_sec , <nl> class ComplexKeyCacheDictionary final : public IDictionaryBase <nl> / / / inform caller <nl> on_cell_updated ( key , cell_idx ) ; <nl> / / / mark corresponding id as found <nl> - remaining_keys [ key ] = 1 ; <nl> + remaining_keys [ key ] = true ; <nl> } <nl> } <nl> <nl>
dbms : fix error with ternary operator having priority lower than binary + [ # METR - 17328 ]
ClickHouse/ClickHouse
7159c572807f25eb50c3894323365ab96969df1b
2015-11-24T11:28:29Z
mmm a / src / Access / RowPolicy . cpp <nl> ppp b / src / Access / RowPolicy . cpp <nl> String RowPolicy : : NameParts : : getName ( ) const <nl> name . reserve ( database . length ( ) + table_name . length ( ) + short_name . length ( ) + 6 ) ; <nl> name + = backQuoteIfNeed ( short_name ) ; <nl> name + = " ON " ; <nl> - if ( ! name . empty ( ) ) <nl> + if ( ! database . empty ( ) ) <nl> { <nl> name + = backQuoteIfNeed ( database ) ; <nl> name + = ' . ' ; <nl>
Fix calculating full names of row policies .
ClickHouse/ClickHouse
ca2fb5932126175fed213a6f040fd34ff7b2d908
2020-06-14T22:44:25Z
mmm a / ports / tesseract / fix - text2image . patch <nl> ppp b / ports / tesseract / fix - text2image . patch <nl> ) <nl> add_library ( unicharset_training $ { unicharset_training_src } ) <nl> + if ( UNIX ) <nl> - + list ( APPEND ICU_LIBRARIES - ldl ) <nl> + + list ( APPEND ICU_LIBRARIES $ { CMAKE_DL_LIBS } ) <nl> + endif ( ) <nl> if ( NOT CPPAN_BUILD ) <nl> target_link_libraries ( unicharset_training common_training $ { ICU_LIBRARIES } ) <nl>
Update - ldl as CMAKE_DL_LIBS
microsoft/vcpkg
496f5cd5faa2848342d50860dc3b369d63d83cc1
2019-12-18T06:04:06Z
mmm a / js / apps / system / aardvark / frontend / css / general . css <nl> ppp b / js / apps / system / aardvark / frontend / css / general . css <nl> <nl> / * Sets the default values shared for content views * / <nl> - <nl> - # aboutDiv , # queryDiv , # queryDropdown , <nl> - # documentsFooterBox , # documentsDiv , <nl> - # databaseDiv , <nl> - . arangoDropdown , <nl> - . thumbnails2 , . thumbnails , <nl> - . api - actions <nl> + # content <nl> { <nl> background - color : rgba ( 0 , 0 , 0 , 0 . 15 ) ; <nl> + margin - top : 74px ; <nl> + margin - bottom : 33px ; <nl> + min - height : 80px ; <nl> + height : 100 % ; <nl> + width : 100 % ; <nl> + margin - left : 20px ; <nl> + margin - left : 0 ; <nl> } <nl> - <nl> / * layout . css <nl> # aboutDiv { <nl> padding - bottom : 5px ; <nl> mmm a / js / apps / system / aardvark / frontend / css / layout . css <nl> ppp b / js / apps / system / aardvark / frontend / css / layout . css <nl> textarea , . alert { <nl> color : # b9d375 ; <nl> } <nl> <nl> - # content { <nl> - margin - top : 74px ; <nl> - margin - bottom : 33px ; <nl> - min - height : 80px ; <nl> - height : 100 % ; <nl> - width : 100 % ; <nl> - margin - left : 20px ; <nl> - margin - left : 0 ; <nl> - } <nl> - <nl> body { <nl> background - color : white ! important ; <nl> / * background : url ( " . . / img / bg_paper . gif " ) repeat scroll 0 0 # E5E1DD ! important ; * / <nl> body { <nl> } <nl> <nl> . form - actions { <nl> - background - color : # FFFFFF ; <nl> + margin - top : - 10px ! important ; <nl> + background - color : rgba ( 0 , 0 , 0 , 0 . 05 ) ; <nl> border : none ; <nl> } <nl> <nl> table . sorting { <nl> margin - bottom : 20px ; <nl> } <nl> <nl> - . marginRight10 { <nl> - } <nl> - <nl> - . form - actions { <nl> - margin - top : - 10px ! important ; <nl> - } <nl> <nl> input , select , option { <nl> border - radius : 0 ! important ; <nl> mmm a / js / apps / system / aardvark / frontend / css / queryView . css <nl> ppp b / js / apps / system / aardvark / frontend / css / queryView . css <nl> <nl> padding - top : 6px ! important ; <nl> padding - left : 5px ; <nl> padding - right : 5px ; <nl> - padding - bottom : 5px ! important ; <nl> + padding - bottom : 20px ! important ; <nl> + background - color : transparent ; <nl> } <nl> <nl> # outputToolbar span , # editorToolbar span { <nl> mmm a / js / apps / system / aardvark / frontend / css / shellView . css <nl> ppp b / js / apps / system / aardvark / frontend / css / shellView . css <nl> <nl> . shellul { <nl> border - bottom : 20px solid rgba ( 0 , 0 , 0 , 0 . 00 ) ; <nl> padding - bottom : 20px ; <nl> - background - color : black ; <nl> } <nl> <nl> # shell_workspace { <nl> mmm a / js / apps / system / aardvark / frontend / css / swaggerView . css <nl> ppp b / js / apps / system / aardvark / frontend / css / swaggerView . css <nl> pre { <nl> margin : 0 0 0 0 ; <nl> } <nl> . form - actions { <nl> - background - color : rgba ( 0 , 0 , 0 , 0 . 05 ) ; <nl> } <nl> . swagger - ui - wrap . container { <nl> width : auto ; <nl> mmm a / js / apps / system / aardvark / frontend / js / templates / queryView . ejs <nl> ppp b / js / apps / system / aardvark / frontend / js / templates / queryView . ejs <nl> <nl> < / div > <nl> < / div > <nl> <nl> - < div id = " queryDiv " class = " form - actions " style = " display : none " > <nl> + < div id = " queryDiv " style = " display : none " > <nl> < div id = " editorLabel " > < h6 > Query < / h6 > < / div > <nl> < div id = " editorToolbar " class = " queryToolbar " > <nl> < span class = " arangoicon arango - icon - remove queryTooltips " title = " Clear " id = " clearInput " / > <nl>
Moved definition of content to the central general . css . Removed class form - actions from query view , all of it has been overwritten anyways
arangodb/arangodb
4905007eeffe5851f57370fa7d8a3ef8a2446477
2013-12-01T20:22:19Z
mmm a / userguide / recommender / README . md <nl> ppp b / userguide / recommender / README . md <nl> results = model . recommend ( ) <nl> The following sections provide more information about the recommender model : <nl> <nl> - [ Using models ] ( using - trained - models . md ) <nl> - * making recommendations <nl> - * finding similar items and users <nl> - * evaluating the model <nl> - * interactive visualizations <nl> - * saving models <nl> - * and more <nl> + * Making recommendations <nl> + * Finding similar items <nl> + * Saving and loading models <nl> - [ Choosing a model ] ( choosing - a - model . md ) <nl> - * data you might encounter ( implicit or explicit ) <nl> - * types of models worth considering ( item - based similarity , factorization - based models , and so on ) . <nl> + * Data you might encounter ( implicit or explicit ) <nl> + * Types of models worth considering ( item - based similarity , factorization - based models , and so on ) . <nl> - [ Deployment to Core ML ] ( coreml - deployment . md ) <nl> - * export to Core ML , drag and drop in an iOS application <nl> + * Export to Core ML , drag and drop in an iOS application <nl> - [ API Docs ] ( https : / / apple . github . io / turicreate / docs / api / turicreate . toolkits . recommender . html ) <nl> mmm a / userguide / recommender / using - trained - models . md <nl> ppp b / userguide / recommender / using - trained - models . md <nl> In this section we will cover <nl> - [ Finding similar items ] ( # finding - similar - items ) <nl> - [ Saving and loading ] ( # saving - and - loading - models ) <nl> <nl> - # # # # # Making recommendations <nl> + # # # # Making recommendations <nl> <nl> Once a model is created , you can now make recommendations of new items <nl> for users . To do so , call ` model . recommend ( ) ` with an SArray of user <nl> recommendations = m_side_info . recommend ( [ ' Charlie ' ] , <nl> <nl> Given Charlie ' s age category , the model can incorporate what it knows about the importance of age categories for item recommendations . Currently , the following models can take side information into account when making recommendations : [ LinearRegressionModel ] ( https : / / apple . github . io / turicreate / docs / api / generated / turicreate . linear_regression . LinearRegression . html ) , [ FactorizationRecommender ] ( https : / / apple . github . io / turicreate / docs / api / generated / turicreate . recommender . factorization_recommender . FactorizationRecommender . html # turicreate . recommender . factorization_recommender . FactorizationRecommender ) . LinearRegressionModel is the simpler model , and FactorizationRecommender the more powerful . For more details on how each model makes use of side information , please refer to the model definition sections in the individual models ' API documentation . <nl> <nl> - # # # # Incorporating new observation data <nl> + # # # # # Incorporating new observation data <nl> <nl> ` recommend ( ) ` accepts new observation data . Currently , the [ ItemSimilarityModel ] ( https : / / apple . github . io / turicreate / docs / api / generated / turicreate . recommender . item_similarity_recommender . ItemSimilarityRecommender . html ) makes the best use of this information . <nl> <nl>
Minor updates for User Guide of Recommender System ( )
apple/turicreate
3e45e79cf45259ca46e94f15c2732e0f6368523f
2018-06-26T23:28:55Z
mmm a / src / test / CMakeLists . txt <nl> ppp b / src / test / CMakeLists . txt <nl> set ( CXX_SOURCES ) <nl> auto_sources ( files " * . cpp " " " ) <nl> list ( APPEND CXX_SOURCES $ { files } ) <nl> <nl> + add_definitions ( - DHPHPI_PATH = " hphpi / hphpi " ) <nl> + <nl> configure_file ( $ { CMAKE_CURRENT_SOURCE_DIR } / test_base_suite . inc $ { CMAKE_CURRENT_SOURCE_DIR } / test_suite . inc COPYONLY ) <nl> configure_file ( $ { CMAKE_CURRENT_SOURCE_DIR } / test_base_fast . inc $ { CMAKE_CURRENT_SOURCE_DIR } / test_fast . inc COPYONLY ) <nl> configure_file ( $ { CMAKE_CURRENT_SOURCE_DIR } / dummy_mysql_info . inc $ { CMAKE_CURRENT_SOURCE_DIR } / test_mysql_info . inc COPYONLY ) <nl>
Fix build
facebook/hhvm
40934db6280ca2dce46e218c6f2df9e725f5108c
2011-10-18T01:37:59Z
mmm a / dbms / src / Functions / FunctionsArray . cpp <nl> ppp b / dbms / src / Functions / FunctionsArray . cpp <nl> bool FunctionArrayElement : : executeConstConst ( Block & block , const ColumnNumbers <nl> if ( ! col_array ) <nl> return false ; <nl> <nl> - const DB : : Array & array = col_array - > getData ( ) ; <nl> + const Array & array = col_array - > getData ( ) ; <nl> size_t array_size = array . size ( ) ; <nl> size_t real_index = 0 ; <nl> <nl> bool FunctionArrayElement : : executeConstConst ( Block & block , const ColumnNumbers <nl> else <nl> throw Exception ( " Illegal type of array index " , ErrorCodes : : LOGICAL_ERROR ) ; <nl> <nl> - Field value = col_array - > getData ( ) . at ( real_index ) ; <nl> + Field value ; <nl> + if ( real_index < array_size ) <nl> + value = array . at ( real_index ) ; <nl> + else <nl> + value = block . getByPosition ( result ) . type - > getDefault ( ) ; <nl> <nl> - block . safeGetByPosition ( result ) . column = block . safeGetByPosition ( result ) . type - > createConstColumn ( <nl> + block . getByPosition ( result ) . column = block . getByPosition ( result ) . type - > createConstColumn ( <nl> block . rows ( ) , <nl> value ) ; <nl> <nl> bool FunctionArrayElement : : executeConst ( Block & block , const ColumnNumbers & arg <nl> if ( ! col_array ) <nl> return false ; <nl> <nl> - const DB : : Array & array = col_array - > getData ( ) ; <nl> + const Array & array = col_array - > getData ( ) ; <nl> size_t array_size = array . size ( ) ; <nl> <nl> block . safeGetByPosition ( result ) . column = block . safeGetByPosition ( result ) . type - > createColumn ( ) ; <nl>
Removed questionable code [ # CLICKHOUSE - 2 ] .
ClickHouse/ClickHouse
7c6f64755911e4f0afbc79e84e8e486b0cb5cf87
2017-06-07T01:52:11Z
mmm a / hphp / hhvm / main . cpp <nl> ppp b / hphp / hhvm / main . cpp <nl> int main ( int argc , char * * argv ) { <nl> args . insert ( args . end ( ) , argv + 1 , argv + argc ) ; <nl> } <nl> return HPHP : : execute_program ( args . size ( ) , & args [ 0 ] ) ; <nl> - } <nl> \ No newline at end of file <nl> + } <nl>
Update libevent builds .
facebook/hhvm
270cfcddc1a36bfb6d6f24bf9f12c22e876ab6e0
2014-02-06T19:26:33Z