diff
stringlengths 41
2.03M
| msg
stringlengths 1
1.5k
⌀ | repo
stringlengths 5
40
| sha
stringlengths 40
40
| time
stringlengths 20
20
|
---|---|---|---|---|
mmm a / test / functional / p2p_invalid_messages . py <nl> ppp b / test / functional / p2p_invalid_messages . py <nl> <nl> # file COPYING or http : / / www . opensource . org / licenses / mit - license . php . <nl> " " " Test node responses to invalid network messages . " " " <nl> import asyncio <nl> - import os <nl> import struct <nl> import sys <nl> <nl> def run_test ( self ) : <nl> msg_at_size = msg_unrecognized ( str_data = " b " * valid_data_limit ) <nl> assert len ( msg_at_size . serialize ( ) ) = = msg_limit <nl> <nl> - increase_allowed = 0 . 5 <nl> - if [ s for s in os . environ . get ( " BITCOIN_CONFIG " , " " ) . split ( " " ) if " - - with - sanitizers " in s and " address " in s ] : <nl> - increase_allowed = 3 . 5 <nl> - with node . assert_memory_usage_stable ( increase_allowed = increase_allowed ) : <nl> - self . log . info ( <nl> - " Sending a bunch of large , junk messages to test " <nl> - " memory exhaustion . May take a bit . . . " ) <nl> - <nl> - # Run a bunch of times to test for memory exhaustion . <nl> - for _ in range ( 80 ) : <nl> - node . p2p . send_message ( msg_at_size ) <nl> - <nl> - # Check that , even though the node is being hammered by nonsense from one <nl> - # connection , it can still service other peers in a timely way . <nl> - for _ in range ( 20 ) : <nl> - conn2 . sync_with_ping ( timeout = 2 ) <nl> - <nl> - # Peer 1 , despite serving up a bunch of nonsense , should still be connected . <nl> - self . log . info ( " Waiting for node to drop junk messages . " ) <nl> - node . p2p . sync_with_ping ( timeout = 320 ) <nl> - assert node . p2p . is_connected <nl> + self . log . info ( " Sending a bunch of large , junk messages to test memory exhaustion . May take a bit . . . " ) <nl> + <nl> + # Run a bunch of times to test for memory exhaustion . <nl> + for _ in range ( 80 ) : <nl> + node . p2p . send_message ( msg_at_size ) <nl> + <nl> + # Check that , even though the node is being hammered by nonsense from one <nl> + # connection , it can still service other peers in a timely way . <nl> + for _ in range ( 20 ) : <nl> + conn2 . sync_with_ping ( timeout = 2 ) <nl> + <nl> + # Peer 1 , despite serving up a bunch of nonsense , should still be connected . <nl> + self . log . info ( " Waiting for node to drop junk messages . " ) <nl> + node . p2p . sync_with_ping ( timeout = 320 ) <nl> + assert node . p2p . is_connected <nl> <nl> # <nl> # 1 . <nl> mmm a / test / functional / test_framework / test_node . py <nl> ppp b / test / functional / test_framework / test_node . py <nl> def get_deterministic_priv_key ( self ) : <nl> assert len ( self . PRIV_KEYS ) = = MAX_NODES <nl> return self . PRIV_KEYS [ self . index ] <nl> <nl> - def get_mem_rss_kilobytes ( self ) : <nl> - " " " Get the memory usage ( RSS ) per ` ps ` . <nl> - <nl> - Returns None if ` ps ` is unavailable . <nl> - " " " <nl> - assert self . running <nl> - <nl> - try : <nl> - return int ( subprocess . check_output ( <nl> - [ " ps " , " h " , " - o " , " rss " , " { } " . format ( self . process . pid ) ] , <nl> - stderr = subprocess . DEVNULL ) . split ( ) [ - 1 ] ) <nl> - <nl> - # Avoid failing on platforms where ps isn ' t installed . <nl> - # <nl> - # We could later use something like ` psutils ` to work across platforms . <nl> - except ( FileNotFoundError , subprocess . SubprocessError ) : <nl> - self . log . exception ( " Unable to get memory usage " ) <nl> - return None <nl> - <nl> def _node_msg ( self , msg : str ) - > str : <nl> " " " Return a modified msg that identifies this node by its index as a debugging aid . " " " <nl> return " [ node % d ] % s " % ( self . index , msg ) <nl> def assert_debug_log ( self , expected_msgs , timeout = 2 ) : <nl> time . sleep ( 0 . 05 ) <nl> self . _raise_assertion_error ( ' Expected messages " { } " does not partially match log : \ n \ n { } \ n \ n ' . format ( str ( expected_msgs ) , print_log ) ) <nl> <nl> - @ contextlib . contextmanager <nl> - def assert_memory_usage_stable ( self , * , increase_allowed = 0 . 03 ) : <nl> - " " " Context manager that allows the user to assert that a node ' s memory usage ( RSS ) <nl> - hasn ' t increased beyond some threshold percentage . <nl> - <nl> - Args : <nl> - increase_allowed ( float ) : the fractional increase in memory allowed until failure ; <nl> - e . g . ` 0 . 12 ` for up to 12 % increase allowed . <nl> - " " " <nl> - before_memory_usage = self . get_mem_rss_kilobytes ( ) <nl> - <nl> - yield <nl> - <nl> - after_memory_usage = self . get_mem_rss_kilobytes ( ) <nl> - <nl> - if not ( before_memory_usage and after_memory_usage ) : <nl> - self . log . warning ( " Unable to detect memory usage ( RSS ) - skipping memory check . " ) <nl> - return <nl> - <nl> - perc_increase_memory_usage = ( after_memory_usage / before_memory_usage ) - 1 <nl> - <nl> - if perc_increase_memory_usage > increase_allowed : <nl> - self . _raise_assertion_error ( <nl> - " Memory usage increased over threshold of { : . 3f } % from { } to { } ( { : . 3f } % ) " . format ( <nl> - increase_allowed * 100 , before_memory_usage , after_memory_usage , <nl> - perc_increase_memory_usage * 100 ) ) <nl> - <nl> @ contextlib . contextmanager <nl> def profile_with_perf ( self , profile_name ) : <nl> " " " <nl> | Merge : test : Remove fragile assert_memory_usage_stable | bitcoin/bitcoin | c7709cbf4c15123332dc37c70dc491422f81e080 | 2019-11-15T17:46:51Z |
mmm a / dlib / matrix / matrix_assign . h <nl> ppp b / dlib / matrix / matrix_assign . h <nl> namespace dlib <nl> { <nl> if ( add_to ) <nl> { <nl> - matrix < T , NR , NC , MM , L > temp ( dest ) ; <nl> + matrix < T , NR , NC , MM , L > temp ( dest . nr ( ) , dest . nc ( ) ) ; <nl> + set_all_elements ( temp , 0 ) ; <nl> default_matrix_multiply ( temp , src . lhs , src . rhs ) ; <nl> - dest = alpha * temp ; <nl> + dest + = alpha * temp ; <nl> } <nl> else <nl> { <nl> namespace dlib <nl> / * ! <nl> requires <nl> - src . aliases ( dest ) = = false <nl> + - dest . nr ( ) = = src . nr ( ) <nl> + - dest . nc ( ) = = src . nc ( ) <nl> ! * / <nl> <nl> template < <nl> namespace dlib <nl> / * ! <nl> requires <nl> - src . aliases ( dest ) = = false <nl> + - dest . nr ( ) = = src . nr ( ) <nl> + - dest . nc ( ) = = src . nc ( ) <nl> ! * / <nl> <nl> template < <nl> namespace dlib <nl> / * ! <nl> requires <nl> - src . aliases ( dest ) = = false <nl> + - dest . nr ( ) = = src . nr ( ) <nl> + - dest . nc ( ) = = src . nc ( ) <nl> ! * / <nl> <nl> template < <nl> namespace dlib <nl> / * ! <nl> requires <nl> - src . aliases ( dest ) = = false <nl> + - dest . nr ( ) = = src . nr ( ) <nl> + - dest . nc ( ) = = src . nc ( ) <nl> ! * / <nl> <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> namespace dlib <nl> { <nl> if ( src . aliases ( dest ) ) <nl> { <nl> - matrix < T , NR , NC , MM , L > temp ; <nl> + matrix < T , NR , NC , MM , L > temp ( dest . nr ( ) , dest . nc ( ) ) ; <nl> matrix_assign_blas_proxy ( temp , src , 1 , false ) ; <nl> temp . swap ( dest ) ; <nl> } <nl> namespace dlib <nl> matrix_assign_default ( dest , src ) ; <nl> } <nl> } <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + <nl> + template < <nl> + typename T , long NR , long NC , typename MM , typename L , <nl> + typename src_exp <nl> + > <nl> + void matrix_assign_blas ( <nl> + matrix < T , NR , NC , MM , L > & dest , <nl> + const matrix_add_exp < src_exp , matrix < T , NR , NC , MM , L > > & src <nl> + ) <nl> + { <nl> + / / Just switch around the left and right hand sides of the incoming <nl> + / / add expression and pass it back into matrix_assign_blas ( ) so that <nl> + / / the above function will be called . <nl> + typedef matrix_add_exp < matrix < T , NR , NC , MM , L > , src_exp > swapped_add_exp ; <nl> + matrix_assign_blas ( dest , swapped_add_exp ( src . rhs , src . lhs ) ) ; <nl> + } <nl> <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> <nl> mmm a / dlib / matrix / matrix_assign_fwd . h <nl> ppp b / dlib / matrix / matrix_assign_fwd . h <nl> namespace dlib <nl> / * ! <nl> requires <nl> - src . destructively_aliases ( dest ) = = false <nl> + - dest . nr ( ) = = src . nr ( ) <nl> + - dest . nc ( ) = = src . nc ( ) <nl> ensures <nl> - # dest = = src <nl> ! * / <nl> namespace dlib <nl> / * ! <nl> requires <nl> - src . destructively_aliases ( dest ) = = false <nl> + - dest . nr ( ) = = src . nr ( ) <nl> + - dest . nc ( ) = = src . nc ( ) <nl> ensures <nl> - if ( add_to = = false ) then <nl> - # dest = = alpha * src <nl> namespace dlib <nl> / * ! <nl> requires <nl> - src . destructively_aliases ( dest ) = = false <nl> + - dest . nr ( ) = = src . nr ( ) <nl> + - dest . nc ( ) = = src . nc ( ) <nl> ensures <nl> - # dest = = src <nl> ! * / <nl> namespace dlib <nl> / * ! <nl> requires <nl> - src . destructively_aliases ( dest ) = = false <nl> + - dest . nr ( ) = = src . nr ( ) <nl> + - dest . nc ( ) = = src . nc ( ) <nl> ensures <nl> - # dest = = src <nl> ! * / <nl> | Fixed some bugs and cleaned up the code . | davisking/dlib | 876c77e481c072c10d068bc14e0435e4df159048 | 2009-01-03T00:22:23Z |
mmm a / src / Storages / StorageReplicatedMergeTree . cpp <nl> ppp b / src / Storages / StorageReplicatedMergeTree . cpp <nl> void StorageReplicatedMergeTree : : drop ( ) <nl> <nl> if ( has_metadata_in_zookeeper ) <nl> { <nl> - auto zookeeper = tryGetZooKeeper ( ) ; <nl> + / / / Table can be shut down , restarting thread is not active <nl> + / / / and calling StorageReplicatedMergeTree : : getZooKeeper ( ) won ' t suffice . <nl> + auto zookeeper = global_context . getZooKeeper ( ) ; <nl> <nl> / / / If probably there is metadata in ZooKeeper , we don ' t allow to drop the table . <nl> if ( is_readonly | | ! zookeeper ) <nl> | Better drop replicated tables | ClickHouse/ClickHouse | a5560cd62dd9b6c058c71f0c9d72e11300b58a2d | 2020-09-17T11:27:17Z |
mmm a / dbms / include / DB / AggregateFunctions / AggregateFunctionsMinMaxAny . h <nl> ppp b / dbms / include / DB / AggregateFunctions / AggregateFunctionsMinMaxAny . h <nl> struct __attribute__ ( ( __packed__ ) ) SingleValueDataString <nl> static constexpr Int32 AUTOMATIC_STORAGE_SIZE = 64 ; <nl> static constexpr Int32 MAX_SMALL_STRING_SIZE = AUTOMATIC_STORAGE_SIZE - sizeof ( size ) ; <nl> <nl> - union <nl> + union __attribute__ ( ( __aligned__ ( 1 ) ) ) <nl> { <nl> char small_data [ MAX_SMALL_STRING_SIZE ] ; / / / Включая завершающий ноль . <nl> - char * large_data ; <nl> + char * __attribute__ ( ( __aligned__ ( 1 ) ) ) large_data ; <nl> } ; <nl> <nl> ~ SingleValueDataString ( ) <nl> | dbms : tiny modification [ # METR - 2944 ] . | ClickHouse/ClickHouse | 0b071033058e556deba64940d504df98033aad07 | 2015-03-12T02:21:28Z |
mmm a / python_examples / train_shape_predictor . py <nl> ppp b / python_examples / train_shape_predictor . py <nl> <nl> print ( " Testing accuracy : { } " . format ( <nl> dlib . test_shape_predictor ( testing_xml_path , " predictor . dat " ) ) ) <nl> <nl> - # Now let ' s it as you would in a normal application . First we will load it <nl> + # Now let ' s use it as you would in a normal application . First we will load it <nl> # from disk . We also need to load a face detector to provide the initial <nl> # estimate of the facial location . <nl> predictor = dlib . shape_predictor ( " predictor . dat " ) <nl> | Fixed grammar | davisking/dlib | ef06f0e8d5a42e16e2c5ab4a2a440d20aab60ac1 | 2014-12-27T23:15:07Z |
mmm a / src / memcached / memcached . cc <nl> ppp b / src / memcached / memcached . cc <nl> class enable_gc_request_t : <nl> DISABLE_COPYING ( enable_gc_request_t ) ; <nl> } ; <nl> <nl> + perfmon_duration_sampler_t <nl> + pm_conns_reading ( " conns_reading " , secs_to_ticks ( 1 ) ) , <nl> + pm_conns_writing ( " conns_writing " , secs_to_ticks ( 1 ) ) , <nl> + pm_conns_acting ( " conns_acting " , secs_to_ticks ( 1 ) ) ; <nl> + <nl> txt_memcached_handler_t : : txt_memcached_handler_t ( conn_acceptor_t * acc , net_conn_t * conn , server_t * server ) <nl> : conn_handler_t ( acc , conn ) , conn ( conn ) , server ( server ) , send_buffer ( conn ) <nl> { <nl> logINF ( " Opened connection % p \ n " , this ) ; <nl> + pm_conns_acting . begin ( & start_time ) ; <nl> read_next_command ( ) ; <nl> } <nl> <nl> void txt_memcached_handler_t : : quit ( ) { <nl> <nl> void txt_memcached_handler_t : : read_next_command ( ) { <nl> <nl> + pm_conns_acting . end ( & start_time ) ; <nl> + <nl> / * Prevent arbitrarily deep stacks when reading many commands that come quickly * / <nl> call_later_on_this_thread ( this ) ; <nl> } <nl> void txt_memcached_handler_t : : on_thread_switch ( ) { <nl> } else { <nl> / * Before we read another command off the socket , we must make sure that there isn ' t <nl> any data in the send buffer that we should flush first . * / <nl> + pm_conns_writing . begin ( & start_time ) ; <nl> send_buffer . flush ( this ) ; <nl> } <nl> } <nl> void txt_memcached_handler_t : : on_send_buffer_flush ( ) { <nl> <nl> / * Now that we ' re sure that the send buffer is empty , start reading a new line off of <nl> the socket . * / <nl> + pm_conns_writing . end ( & start_time ) ; <nl> + pm_conns_reading . begin ( & start_time ) ; <nl> conn - > read_buffered ( this ) ; <nl> } <nl> <nl> void txt_memcached_handler_t : : on_send_buffer_socket_closed ( ) { <nl> <nl> / * Socket closed as we were flushing the send buffer . * / <nl> - <nl> + <nl> + pm_conns_writing . end ( & start_time ) ; <nl> delete this ; <nl> } <nl> <nl> void txt_memcached_handler_t : : on_net_conn_read_buffered ( const char * buffer , size <nl> } <nl> } <nl> <nl> + pm_conns_reading . end ( & start_time ) ; <nl> + pm_conns_acting . begin ( & start_time ) ; <nl> + <nl> / * We must duplicate the line because accept_buffer ( ) may invalidate " buffer " * / <nl> int line_size = ( char * ) crlf_loc - buffer + 2 ; <nl> std : : vector < char > line_storage ; / / Easy way to make sure ' line ' gets freed when we exit this function <nl> void txt_memcached_handler_t : : on_net_conn_close ( ) { <nl> <nl> / * The connection was closed as we were waiting for a complete line to buffer * / <nl> <nl> + pm_conns_reading . end ( & start_time ) ; <nl> delete this ; <nl> } <nl> mmm a / src / memcached / memcached . hpp <nl> ppp b / src / memcached / memcached . hpp <nl> struct txt_memcached_handler_t : <nl> net_conn_t * conn ; <nl> server_t * server ; <nl> send_buffer_t send_buffer ; <nl> + ticks_t start_time ; / / Used for various perfmonning stuff <nl> <nl> txt_memcached_handler_t ( conn_acceptor_t * acc , net_conn_t * , server_t * ) ; <nl> ~ txt_memcached_handler_t ( ) ; <nl> mmm a / src / memcached / send_buffer . cc <nl> ppp b / src / memcached / send_buffer . cc <nl> <nl> # include " send_buffer . hpp " <nl> <nl> send_buffer_t : : send_buffer_t ( net_conn_t * conn ) <nl> - : conn ( conn ) , flush_cb ( NULL ) , writing ( false ) , writing_buffer ( & buffers [ 0 ] ) , growing_buffer ( & buffers [ 1 ] ) <nl> + : conn ( conn ) , flush_cb ( NULL ) <nl> { <nl> } <nl> <nl> - void send_buffer_t : : write ( size_t bytes , const char * buffer ) { <nl> - size_t s = growing_buffer - > size ( ) ; <nl> - growing_buffer - > resize ( s + bytes ) ; <nl> - memcpy ( growing_buffer - > data ( ) + s , buffer , bytes ) ; <nl> + void send_buffer_t : : write ( size_t s , const char * v ) { <nl> <nl> - if ( ! writing ) { <nl> - write_growing_buffer ( ) ; <nl> - } <nl> + assert ( ! flush_cb , " Can ' t write to a send_buffer_t while it ' s flushing . " ) ; <nl> + <nl> + size_t bytes = buffer . size ( ) ; <nl> + buffer . resize ( bytes + s ) ; <nl> + memcpy ( buffer . data ( ) + bytes , v , s ) ; <nl> } <nl> <nl> void send_buffer_t : : flush ( send_buffer_callback_t * cb ) { <nl> assert ( ! flush_cb ) ; <nl> + flush_cb = cb ; <nl> assert ( ! conn - > closed ( ) ) ; <nl> - if ( writing ) { <nl> - flush_cb = cb ; <nl> - } else { <nl> - assert ( growing_buffer - > size ( ) = = 0 ) ; <nl> - cb - > on_send_buffer_flush ( ) ; <nl> - } <nl> + conn - > write_external ( buffer . data ( ) , buffer . size ( ) , this ) ; <nl> } <nl> <nl> void send_buffer_t : : on_net_conn_write_external ( ) { <nl> - writing = false ; <nl> - if ( growing_buffer - > size ( ) ! = 0 ) { <nl> - write_growing_buffer ( ) ; <nl> - } else if ( flush_cb ) { <nl> - send_buffer_callback_t * cb = flush_cb ; <nl> - flush_cb = NULL ; <nl> - cb - > on_send_buffer_flush ( ) ; <nl> - } <nl> + assert ( flush_cb ) ; <nl> + send_buffer_callback_t * cb = flush_cb ; <nl> + flush_cb = NULL ; <nl> + buffer . resize ( 0 ) ; <nl> + cb - > on_send_buffer_flush ( ) ; <nl> } <nl> <nl> void send_buffer_t : : on_net_conn_close ( ) { <nl> - if ( flush_cb ) { <nl> - send_buffer_callback_t * cb = flush_cb ; <nl> - flush_cb = NULL ; <nl> - cb - > on_send_buffer_socket_closed ( ) ; <nl> - } <nl> - } <nl> - <nl> - void send_buffer_t : : write_growing_buffer ( ) { <nl> - <nl> - if ( conn - > closed ( ) ) return ; <nl> - <nl> - assert ( ! writing ) ; <nl> - std : : vector < char > * temp = writing_buffer ; <nl> - writing_buffer = growing_buffer ; <nl> - temp - > resize ( 0 ) ; / / Wipe and reuse the buffer <nl> - growing_buffer = temp ; <nl> - <nl> - writing = true ; <nl> - conn - > write_external ( writing_buffer - > data ( ) , writing_buffer - > size ( ) , this ) ; <nl> + assert ( flush_cb ) ; <nl> + send_buffer_callback_t * cb = flush_cb ; <nl> + flush_cb = NULL ; <nl> + cb - > on_send_buffer_socket_closed ( ) ; <nl> } <nl> mmm a / src / memcached / send_buffer . hpp <nl> ppp b / src / memcached / send_buffer . hpp <nl> struct send_buffer_t : <nl> private : <nl> net_conn_t * conn ; <nl> send_buffer_callback_t * flush_cb ; <nl> - bool writing ; <nl> <nl> - / * One of these points to buffers [ 0 ] and the other points to buffers [ 1 ] . * / <nl> - std : : vector < char > * writing_buffer , * growing_buffer ; <nl> - std : : vector < char > buffers [ 2 ] ; <nl> + std : : vector < char > buffer ; <nl> <nl> void on_net_conn_write_external ( ) ; <nl> void on_net_conn_close ( ) ; <nl> - void write_growing_buffer ( ) ; <nl> } ; <nl> <nl> # endif / * __MEMCACHED_SEND_BUFFER_HPP__ * / <nl> | Added perfmons to the request handler ; made sends buffer until the entire response has been built . Closes . | rethinkdb/rethinkdb | 2c0e958f551f0318e144aa971941c0b615a3eb46 | 2010-12-17T23:32:15Z |
mmm a / modules / gpu / src / color . cpp <nl> ppp b / modules / gpu / src / color . cpp <nl> namespace <nl> luv_to_rgb ( src , dst , - 1 , stream ) ; <nl> bgr_to_rgb ( dst , dst , - 1 , stream ) ; <nl> } <nl> + <nl> + void rgba_to_mbgra ( const GpuMat & src , GpuMat & dst , int , Stream & stream ) <nl> + { <nl> + # if ( CUDA_VERSION < 5000 ) <nl> + ( void ) src ; <nl> + ( void ) dst ; <nl> + ( void ) stream ; <nl> + CV_Error ( CV_StsBadFlag , " Unknown / unsupported color conversion code " ) ; <nl> + # else <nl> + CV_Assert ( src . type ( ) = = CV_8UC4 | | src . type ( ) = = CV_16UC4 ) ; <nl> + <nl> + dst . create ( src . size ( ) , src . type ( ) ) ; <nl> + <nl> + NppStreamHandler h ( StreamAccessor : : getStream ( stream ) ) ; <nl> + <nl> + NppiSize oSizeROI ; <nl> + oSizeROI . width = src . cols ; <nl> + oSizeROI . height = src . rows ; <nl> + <nl> + if ( src . depth ( ) = = CV_8U ) <nl> + nppSafeCall ( nppiAlphaPremul_8u_AC4R ( src . ptr < Npp8u > ( ) , static_cast < int > ( src . step ) , dst . ptr < Npp8u > ( ) , static_cast < int > ( dst . step ) , oSizeROI ) ) ; <nl> + else <nl> + nppSafeCall ( nppiAlphaPremul_16u_AC4R ( src . ptr < Npp16u > ( ) , static_cast < int > ( src . step ) , dst . ptr < Npp16u > ( ) , static_cast < int > ( dst . step ) , oSizeROI ) ) ; <nl> + # endif <nl> + } <nl> } <nl> <nl> void cv : : gpu : : cvtColor ( const GpuMat & src , GpuMat & dst , int code , int dcn , Stream & stream ) <nl> void cv : : gpu : : cvtColor ( const GpuMat & src , GpuMat & dst , int code , int dcn , Stream <nl> 0 , / / CV_BayerBG2GRAY = 86 <nl> 0 , / / CV_BayerGB2GRAY = 87 <nl> 0 , / / CV_BayerRG2GRAY = 88 <nl> - 0 / / CV_BayerGR2GRAY = 89 <nl> + 0 , / / CV_BayerGR2GRAY = 89 <nl> + <nl> + / / YUV 4 : 2 : 0 formats family <nl> + 0 , / / COLOR_YUV2RGB_NV12 = 90 , <nl> + 0 , / / COLOR_YUV2BGR_NV12 = 91 , <nl> + 0 , / / COLOR_YUV2RGB_NV21 = 92 , <nl> + 0 , / / COLOR_YUV2BGR_NV21 = 93 , <nl> + <nl> + 0 , / / COLOR_YUV2RGBA_NV12 = 94 , <nl> + 0 , / / COLOR_YUV2BGRA_NV12 = 95 , <nl> + 0 , / / COLOR_YUV2RGBA_NV21 = 96 , <nl> + 0 , / / COLOR_YUV2BGRA_NV21 = 97 , <nl> + <nl> + 0 , / / COLOR_YUV2RGB_YV12 = 98 , <nl> + 0 , / / COLOR_YUV2BGR_YV12 = 99 , <nl> + 0 , / / COLOR_YUV2RGB_IYUV = 100 , <nl> + 0 , / / COLOR_YUV2BGR_IYUV = 101 , <nl> + <nl> + 0 , / / COLOR_YUV2RGBA_YV12 = 102 , <nl> + 0 , / / COLOR_YUV2BGRA_YV12 = 103 , <nl> + 0 , / / COLOR_YUV2RGBA_IYUV = 104 , <nl> + 0 , / / COLOR_YUV2BGRA_IYUV = 105 , <nl> + <nl> + 0 , / / COLOR_YUV2GRAY_420 = 106 , <nl> + <nl> + / / YUV 4 : 2 : 2 formats family <nl> + 0 , / / COLOR_YUV2RGB_UYVY = 107 , <nl> + 0 , / / COLOR_YUV2BGR_UYVY = 108 , <nl> + 0 , / / / / COLOR_YUV2RGB_VYUY = 109 , <nl> + 0 , / / / / COLOR_YUV2BGR_VYUY = 110 , <nl> + <nl> + 0 , / / COLOR_YUV2RGBA_UYVY = 111 , <nl> + 0 , / / COLOR_YUV2BGRA_UYVY = 112 , <nl> + 0 , / / / / COLOR_YUV2RGBA_VYUY = 113 , <nl> + 0 , / / / / COLOR_YUV2BGRA_VYUY = 114 , <nl> + <nl> + 0 , / / COLOR_YUV2RGB_YUY2 = 115 , <nl> + 0 , / / COLOR_YUV2BGR_YUY2 = 116 , <nl> + 0 , / / COLOR_YUV2RGB_YVYU = 117 , <nl> + 0 , / / COLOR_YUV2BGR_YVYU = 118 , <nl> + <nl> + 0 , / / COLOR_YUV2RGBA_YUY2 = 119 , <nl> + 0 , / / COLOR_YUV2BGRA_YUY2 = 120 , <nl> + 0 , / / COLOR_YUV2RGBA_YVYU = 121 , <nl> + 0 , / / COLOR_YUV2BGRA_YVYU = 122 , <nl> + <nl> + 0 , / / COLOR_YUV2GRAY_UYVY = 123 , <nl> + 0 , / / COLOR_YUV2GRAY_YUY2 = 124 , <nl> + <nl> + / / alpha premultiplication <nl> + rgba_to_mbgra , / / COLOR_RGBA2mRGBA = 125 , <nl> + 0 , / / COLOR_mRGBA2RGBA = 126 , <nl> + <nl> + 0 , / / COLOR_COLORCVT_MAX = 127 <nl> } ; <nl> <nl> - CV_Assert ( code < 94 ) ; <nl> + CV_Assert ( code < 128 ) ; <nl> <nl> func_t func = funcs [ code ] ; <nl> <nl> mmm a / modules / gpu / test / test_color . cpp <nl> ppp b / modules / gpu / test / test_color . cpp <nl> TEST_P ( CvtColor , RGB2Luv ) <nl> } <nl> } <nl> <nl> + TEST_P ( CvtColor , RGBA2mRGBA ) <nl> + { <nl> + if ( depth ! = CV_8U ) <nl> + return ; <nl> + <nl> + try <nl> + { <nl> + cv : : Mat src = randomMat ( size , CV_MAKE_TYPE ( depth , 4 ) ) ; <nl> + <nl> + cv : : gpu : : GpuMat dst = createMat ( src . size ( ) , src . type ( ) , useRoi ) ; <nl> + cv : : gpu : : cvtColor ( loadMat ( src , useRoi ) , dst , cv : : COLOR_RGBA2mRGBA ) ; <nl> + <nl> + cv : : Mat dst_gold ; <nl> + cv : : cvtColor ( src , dst_gold , cv : : COLOR_RGBA2mRGBA ) ; <nl> + <nl> + EXPECT_MAT_NEAR ( dst_gold , dst , 1 ) ; <nl> + } <nl> + catch ( const cv : : Exception & e ) <nl> + { <nl> + # if ( CUDA_VERSION < 5000 ) <nl> + ASSERT_EQ ( CV_StsBadFlag , e . code ) ; <nl> + # else <nl> + FAIL ( ) ; <nl> + # endif <nl> + } <nl> + } <nl> + <nl> INSTANTIATE_TEST_CASE_P ( GPU_ImgProc , CvtColor , testing : : Combine ( <nl> ALL_DEVICES , <nl> DIFFERENT_SIZES , <nl> | added gpu alpha premultiplication | opencv/opencv | 4f99f69a29a6c3b6c3ae8736e49b650b4dccd2cf | 2012-07-31T08:46:04Z |
mmm a / tensorflow / go / op / wrappers . go <nl> ppp b / tensorflow / go / op / wrappers . go <nl> func MergeV2Checkpoints ( scope * Scope , checkpoint_prefixes tf . Output , destination <nl> return scope . AddOperation ( opspec ) <nl> } <nl> <nl> - / / AudioSpectrogramAttr is an optional argument to AudioSpectrogram . <nl> - type AudioSpectrogramAttr func ( optionalAttr ) <nl> - <nl> - / / AudioSpectrogramMagnitudeSquared sets the optional magnitude_squared attribute to value . <nl> - / / <nl> - / / value : Whether to return the squared magnitude or just the <nl> - / / magnitude . Using squared magnitude can avoid extra calculations . <nl> - / / If not specified , defaults to false <nl> - func AudioSpectrogramMagnitudeSquared ( value bool ) AudioSpectrogramAttr { <nl> - return func ( m optionalAttr ) { <nl> - m [ " magnitude_squared " ] = value <nl> - } <nl> - } <nl> - <nl> - / / Produces a visualization of audio data over time . <nl> - / / <nl> - / / Spectrograms are a standard way of representing audio information as a series of <nl> - / / slices of frequency information , one slice for each window of time . By joining <nl> - / / these together into a sequence , they form a distinctive fingerprint of the sound <nl> - / / over time . <nl> - / / <nl> - / / This op expects to receive audio data as an input , stored as floats in the range <nl> - / / - 1 to 1 , together with a window width in samples , and a stride specifying how <nl> - / / far to move the window between slices . From this it generates a three <nl> - / / dimensional output . The lowest dimension has an amplitude value for each <nl> - / / frequency during that time slice . The next dimension is time , with successive <nl> - / / frequency slices . The final dimension is for the channels in the input , so a <nl> - / / stereo audio input would have two here for example . <nl> - / / <nl> - / / This means the layout when converted and saved as an image is rotated 90 degrees <nl> - / / clockwise from a typical spectrogram . Time is descending down the Y axis , and <nl> - / / the frequency decreases from left to right . <nl> - / / <nl> - / / Each value in the result represents the square root of the sum of the real and <nl> - / / imaginary parts of an FFT on the current window of samples . In this way , the <nl> - / / lowest dimension represents the power of each frequency in the current window , <nl> - / / and adjacent windows are concatenated in the next dimension . <nl> - / / <nl> - / / To get a more intuitive and visual look at what this operation does , you can run <nl> - / / tensorflow / examples / wav_to_spectrogram to read in an audio file and save out the <nl> - / / resulting spectrogram as a PNG image . <nl> - / / <nl> - / / Arguments : <nl> - / / input : Float representation of audio data . <nl> - / / window_size : How wide the input window is in samples . For the highest efficiency <nl> - / / this should be a power of two , but other values are accepted . <nl> - / / stride : How widely apart the center of adjacent sample windows should be . <nl> - / / <nl> - / / Returns 3D representation of the audio frequencies as an image . <nl> - func AudioSpectrogram ( scope * Scope , input tf . Output , window_size int64 , stride int64 , optional . . . AudioSpectrogramAttr ) ( spectrogram tf . Output ) { <nl> - if scope . Err ( ) ! = nil { <nl> - return <nl> - } <nl> - attrs : = map [ string ] interface { } { " window_size " : window_size , " stride " : stride } <nl> - for _ , a : = range optional { <nl> - a ( attrs ) <nl> - } <nl> - opspec : = tf . OpSpec { <nl> - Type : " AudioSpectrogram " , <nl> - Input : [ ] tf . Input { <nl> - input , <nl> - } , <nl> - Attrs : attrs , <nl> - } <nl> - op : = scope . AddOperation ( opspec ) <nl> - return op . Output ( 0 ) <nl> - } <nl> - <nl> - / / Computes the gradient of morphological 2 - D dilation with respect to the input . <nl> - / / <nl> - / / Arguments : <nl> - / / input : 4 - D with shape ` [ batch , in_height , in_width , depth ] ` . <nl> - / / filter : 3 - D with shape ` [ filter_height , filter_width , depth ] ` . <nl> - / / out_backprop : 4 - D with shape ` [ batch , out_height , out_width , depth ] ` . <nl> - / / strides : 1 - D of length 4 . The stride of the sliding window for each dimension of <nl> - / / the input tensor . Must be : ` [ 1 , stride_height , stride_width , 1 ] ` . <nl> - / / rates : 1 - D of length 4 . The input stride for atrous morphological dilation . <nl> - / / Must be : ` [ 1 , rate_height , rate_width , 1 ] ` . <nl> - / / padding : The type of padding algorithm to use . <nl> - / / <nl> - / / Returns 4 - D with shape ` [ batch , in_height , in_width , depth ] ` . <nl> - func Dilation2DBackpropInput ( scope * Scope , input tf . Output , filter tf . Output , out_backprop tf . Output , strides [ ] int64 , rates [ ] int64 , padding string ) ( in_backprop tf . Output ) { <nl> - if scope . Err ( ) ! = nil { <nl> - return <nl> - } <nl> - attrs : = map [ string ] interface { } { " strides " : strides , " rates " : rates , " padding " : padding } <nl> - opspec : = tf . OpSpec { <nl> - Type : " Dilation2DBackpropInput " , <nl> - Input : [ ] tf . Input { <nl> - input , filter , out_backprop , <nl> - } , <nl> - Attrs : attrs , <nl> - } <nl> - op : = scope . AddOperation ( opspec ) <nl> - return op . Output ( 0 ) <nl> - } <nl> - <nl> / / FusedBatchNormGradAttr is an optional argument to FusedBatchNormGrad . <nl> type FusedBatchNormGradAttr func ( optionalAttr ) <nl> <nl> func FusedBatchNormGradIsTraining ( value bool ) FusedBatchNormGradAttr { <nl> / / y_backprop : A 4D Tensor for the gradient with respect to y . <nl> / / x : A 4D Tensor for input data . <nl> / / scale : A 1D Tensor for scaling factor , to scale the normalized x . <nl> - / / reserve_space_1 : When is_training is True , a 1D Tensor for the computed batch mean <nl> - / / to be reused in gradient computation . <nl> - / / When is_training is False , a 1D Tensor for the population mean <nl> - / / to be reused in both 1st and 2nd order gradient computation . <nl> - / / reserve_space_2 : When is_training is True , a 1D Tensor for the computed batch variance <nl> - / / ( inverted variance in the cuDNN case ) to be reused in gradient computation . <nl> - / / When is_training is False , a 1D Tensor for the population variance <nl> - / / to be reused in both 1st and 2nd order gradient computation . <nl> + / / reserve_space_1 : When is_training is True , a 1D Tensor for the computed batch <nl> + / / mean to be reused in gradient computation . When is_training is <nl> + / / False , a 1D Tensor for the population mean to be reused in both <nl> + / / 1st and 2nd order gradient computation . <nl> + / / reserve_space_2 : When is_training is True , a 1D Tensor for the computed batch <nl> + / / variance ( inverted variance in the cuDNN case ) to be reused in <nl> + / / gradient computation . When is_training is False , a 1D Tensor <nl> + / / for the population variance to be reused in both 1st and 2nd <nl> + / / order gradient computation . <nl> / / <nl> / / Returns A 4D Tensor for the gradient with respect to x . A 1D Tensor for the gradient with respect to scale . A 1D Tensor for the gradient with respect to offset . Unused placeholder to match the mean input in FusedBatchNorm . Unused placeholder to match the variance input <nl> / / in FusedBatchNorm . <nl> func MaxPoolGradWithArgmax ( scope * Scope , input tf . Output , grad tf . Output , argmax <nl> return op . Output ( 0 ) <nl> } <nl> <nl> - / / Computes the gradient of morphological 2 - D dilation with respect to the filter . <nl> - / / <nl> - / / Arguments : <nl> - / / input : 4 - D with shape ` [ batch , in_height , in_width , depth ] ` . <nl> - / / filter : 3 - D with shape ` [ filter_height , filter_width , depth ] ` . <nl> - / / out_backprop : 4 - D with shape ` [ batch , out_height , out_width , depth ] ` . <nl> - / / strides : 1 - D of length 4 . The stride of the sliding window for each dimension of <nl> - / / the input tensor . Must be : ` [ 1 , stride_height , stride_width , 1 ] ` . <nl> - / / rates : 1 - D of length 4 . The input stride for atrous morphological dilation . <nl> - / / Must be : ` [ 1 , rate_height , rate_width , 1 ] ` . <nl> - / / padding : The type of padding algorithm to use . <nl> - / / <nl> - / / Returns 3 - D with shape ` [ filter_height , filter_width , depth ] ` . <nl> - func Dilation2DBackpropFilter ( scope * Scope , input tf . Output , filter tf . Output , out_backprop tf . Output , strides [ ] int64 , rates [ ] int64 , padding string ) ( filter_backprop tf . Output ) { <nl> - if scope . Err ( ) ! = nil { <nl> - return <nl> - } <nl> - attrs : = map [ string ] interface { } { " strides " : strides , " rates " : rates , " padding " : padding } <nl> - opspec : = tf . OpSpec { <nl> - Type : " Dilation2DBackpropFilter " , <nl> - Input : [ ] tf . Input { <nl> - input , filter , out_backprop , <nl> - } , <nl> - Attrs : attrs , <nl> - } <nl> - op : = scope . AddOperation ( opspec ) <nl> - return op . Output ( 0 ) <nl> - } <nl> - <nl> - / / Returns the truth value of ( x = = y ) element - wise . <nl> - / / <nl> - / / * NOTE * : ` Equal ` supports broadcasting . More about broadcasting <nl> - / / [ here ] ( http : / / docs . scipy . org / doc / numpy / user / basics . broadcasting . html ) <nl> - func Equal ( scope * Scope , x tf . Output , y tf . Output ) ( z tf . Output ) { <nl> - if scope . Err ( ) ! = nil { <nl> - return <nl> - } <nl> - opspec : = tf . OpSpec { <nl> - Type : " Equal " , <nl> - Input : [ ] tf . Input { <nl> - x , y , <nl> - } , <nl> - } <nl> - op : = scope . AddOperation ( opspec ) <nl> - return op . Output ( 0 ) <nl> - } <nl> - <nl> / / QuantizeAndDequantizeV3Attr is an optional argument to QuantizeAndDequantizeV3 . <nl> type QuantizeAndDequantizeV3Attr func ( optionalAttr ) <nl> <nl> func BatchNormWithGlobalNormalizationGrad ( scope * Scope , t tf . Output , m tf . Output <nl> return op . Output ( 0 ) , op . Output ( 1 ) , op . Output ( 2 ) , op . Output ( 3 ) , op . Output ( 4 ) <nl> } <nl> <nl> + / / FusedBatchNormV2Attr is an optional argument to FusedBatchNormV2 . <nl> + type FusedBatchNormV2Attr func ( optionalAttr ) <nl> + <nl> + / / FusedBatchNormV2Epsilon sets the optional epsilon attribute to value . <nl> + / / <nl> + / / value : A small float number added to the variance of x . <nl> + / / If not specified , defaults to 0 . 0001 <nl> + func FusedBatchNormV2Epsilon ( value float32 ) FusedBatchNormV2Attr { <nl> + return func ( m optionalAttr ) { <nl> + m [ " epsilon " ] = value <nl> + } <nl> + } <nl> + <nl> + / / FusedBatchNormV2DataFormat sets the optional data_format attribute to value . <nl> + / / <nl> + / / value : The data format for x and y . Either " NHWC " ( default ) or " NCHW " . <nl> + / / If not specified , defaults to " NHWC " <nl> + func FusedBatchNormV2DataFormat ( value string ) FusedBatchNormV2Attr { <nl> + return func ( m optionalAttr ) { <nl> + m [ " data_format " ] = value <nl> + } <nl> + } <nl> + <nl> + / / FusedBatchNormV2IsTraining sets the optional is_training attribute to value . <nl> + / / <nl> + / / value : A bool value to indicate the operation is for training ( default ) <nl> + / / or inference . <nl> + / / If not specified , defaults to true <nl> + func FusedBatchNormV2IsTraining ( value bool ) FusedBatchNormV2Attr { <nl> + return func ( m optionalAttr ) { <nl> + m [ " is_training " ] = value <nl> + } <nl> + } <nl> + <nl> + / / Batch normalization . <nl> + / / <nl> + / / Note that the size of 4D Tensors are defined by either " NHWC " or " NCHW " . <nl> + / / The size of 1D Tensors matches the dimension C of the 4D Tensors . <nl> + / / <nl> + / / Arguments : <nl> + / / x : A 4D Tensor for input data . <nl> + / / scale : A 1D Tensor for scaling factor , to scale the normalized x . <nl> + / / offset : A 1D Tensor for offset , to shift to the normalized x . <nl> + / / mean : A 1D Tensor for population mean . Used for inference only ; <nl> + / / must be empty for training . <nl> + / / variance : A 1D Tensor for population variance . Used for inference only ; <nl> + / / must be empty for training . <nl> + / / <nl> + / / Returns A 4D Tensor for output data . A 1D Tensor for the computed batch mean , to be used by TensorFlow <nl> + / / to compute the running mean . A 1D Tensor for the computed batch variance , to be used by <nl> + / / TensorFlow to compute the running variance . A 1D Tensor for the computed batch mean , to be reused <nl> + / / in the gradient computation . A 1D Tensor for the computed batch variance ( inverted variance <nl> + / / in the cuDNN case ) , to be reused in the gradient computation . <nl> + func FusedBatchNormV2 ( scope * Scope , x tf . Output , scale tf . Output , offset tf . Output , mean tf . Output , variance tf . Output , optional . . . FusedBatchNormV2Attr ) ( y tf . Output , batch_mean tf . Output , batch_variance tf . Output , reserve_space_1 tf . Output , reserve_space_2 tf . Output ) { <nl> + if scope . Err ( ) ! = nil { <nl> + return <nl> + } <nl> + attrs : = map [ string ] interface { } { } <nl> + for _ , a : = range optional { <nl> + a ( attrs ) <nl> + } <nl> + opspec : = tf . OpSpec { <nl> + Type : " FusedBatchNormV2 " , <nl> + Input : [ ] tf . Input { <nl> + x , scale , offset , mean , variance , <nl> + } , <nl> + Attrs : attrs , <nl> + } <nl> + op : = scope . AddOperation ( opspec ) <nl> + return op . Output ( 0 ) , op . Output ( 1 ) , op . Output ( 2 ) , op . Output ( 3 ) , op . Output ( 4 ) <nl> + } <nl> + <nl> / / Conv2DBackpropInputAttr is an optional argument to Conv2DBackpropInput . <nl> type Conv2DBackpropInputAttr func ( optionalAttr ) <nl> <nl> func AddSparseToTensorsMap ( scope * Scope , sparse_indices tf . Output , sparse_values <nl> return op . Output ( 0 ) <nl> } <nl> <nl> + / / FusedBatchNormGradV2Attr is an optional argument to FusedBatchNormGradV2 . <nl> + type FusedBatchNormGradV2Attr func ( optionalAttr ) <nl> + <nl> + / / FusedBatchNormGradV2Epsilon sets the optional epsilon attribute to value . <nl> + / / <nl> + / / value : A small float number added to the variance of x . <nl> + / / If not specified , defaults to 0 . 0001 <nl> + func FusedBatchNormGradV2Epsilon ( value float32 ) FusedBatchNormGradV2Attr { <nl> + return func ( m optionalAttr ) { <nl> + m [ " epsilon " ] = value <nl> + } <nl> + } <nl> + <nl> + / / FusedBatchNormGradV2DataFormat sets the optional data_format attribute to value . <nl> + / / <nl> + / / value : The data format for y_backprop , x , x_backprop . <nl> + / / Either " NHWC " ( default ) or " NCHW " . <nl> + / / If not specified , defaults to " NHWC " <nl> + func FusedBatchNormGradV2DataFormat ( value string ) FusedBatchNormGradV2Attr { <nl> + return func ( m optionalAttr ) { <nl> + m [ " data_format " ] = value <nl> + } <nl> + } <nl> + <nl> + / / FusedBatchNormGradV2IsTraining sets the optional is_training attribute to value . <nl> + / / <nl> + / / value : A bool value to indicate the operation is for training ( default ) <nl> + / / or inference . <nl> + / / If not specified , defaults to true <nl> + func FusedBatchNormGradV2IsTraining ( value bool ) FusedBatchNormGradV2Attr { <nl> + return func ( m optionalAttr ) { <nl> + m [ " is_training " ] = value <nl> + } <nl> + } <nl> + <nl> + / / Gradient for batch normalization . <nl> + / / <nl> + / / Note that the size of 4D Tensors are defined by either " NHWC " or " NCHW " . <nl> + / / The size of 1D Tensors matches the dimension C of the 4D Tensors . <nl> + / / <nl> + / / Arguments : <nl> + / / y_backprop : A 4D Tensor for the gradient with respect to y . <nl> + / / x : A 4D Tensor for input data . <nl> + / / scale : A 1D Tensor for scaling factor , to scale the normalized x . <nl> + / / reserve_space_1 : When is_training is True , a 1D Tensor for the computed batch <nl> + / / mean to be reused in gradient computation . When is_training is <nl> + / / False , a 1D Tensor for the population mean to be reused in both <nl> + / / 1st and 2nd order gradient computation . <nl> + / / reserve_space_2 : When is_training is True , a 1D Tensor for the computed batch <nl> + / / variance ( inverted variance in the cuDNN case ) to be reused in <nl> + / / gradient computation . When is_training is False , a 1D Tensor <nl> + / / for the population variance to be reused in both 1st and 2nd <nl> + / / order gradient computation . <nl> + / / <nl> + / / Returns A 4D Tensor for the gradient with respect to x . A 1D Tensor for the gradient with respect to scale . A 1D Tensor for the gradient with respect to offset . Unused placeholder to match the mean input in FusedBatchNorm . Unused placeholder to match the variance input <nl> + / / in FusedBatchNorm . <nl> + func FusedBatchNormGradV2 ( scope * Scope , y_backprop tf . Output , x tf . Output , scale tf . Output , reserve_space_1 tf . Output , reserve_space_2 tf . Output , optional . . . FusedBatchNormGradV2Attr ) ( x_backprop tf . Output , scale_backprop tf . Output , offset_backprop tf . Output , reserve_space_3 tf . Output , reserve_space_4 tf . Output ) { <nl> + if scope . Err ( ) ! = nil { <nl> + return <nl> + } <nl> + attrs : = map [ string ] interface { } { } <nl> + for _ , a : = range optional { <nl> + a ( attrs ) <nl> + } <nl> + opspec : = tf . OpSpec { <nl> + Type : " FusedBatchNormGradV2 " , <nl> + Input : [ ] tf . Input { <nl> + y_backprop , x , scale , reserve_space_1 , reserve_space_2 , <nl> + } , <nl> + Attrs : attrs , <nl> + } <nl> + op : = scope . AddOperation ( opspec ) <nl> + return op . Output ( 0 ) , op . Output ( 1 ) , op . Output ( 2 ) , op . Output ( 3 ) , op . Output ( 4 ) <nl> + } <nl> + <nl> / / Constructs a tensor by tiling a given tensor . <nl> / / <nl> / / This operation creates a new tensor by replicating ` input ` ` multiples ` times . <nl> func Sub ( scope * Scope , x tf . Output , y tf . Output ) ( z tf . Output ) { <nl> return op . Output ( 0 ) <nl> } <nl> <nl> + / / AudioSpectrogramAttr is an optional argument to AudioSpectrogram . <nl> + type AudioSpectrogramAttr func ( optionalAttr ) <nl> + <nl> + / / AudioSpectrogramMagnitudeSquared sets the optional magnitude_squared attribute to value . <nl> + / / <nl> + / / value : Whether to return the squared magnitude or just the <nl> + / / magnitude . Using squared magnitude can avoid extra calculations . <nl> + / / If not specified , defaults to false <nl> + func AudioSpectrogramMagnitudeSquared ( value bool ) AudioSpectrogramAttr { <nl> + return func ( m optionalAttr ) { <nl> + m [ " magnitude_squared " ] = value <nl> + } <nl> + } <nl> + <nl> + / / Produces a visualization of audio data over time . <nl> + / / <nl> + / / Spectrograms are a standard way of representing audio information as a series of <nl> + / / slices of frequency information , one slice for each window of time . By joining <nl> + / / these together into a sequence , they form a distinctive fingerprint of the sound <nl> + / / over time . <nl> + / / <nl> + / / This op expects to receive audio data as an input , stored as floats in the range <nl> + / / - 1 to 1 , together with a window width in samples , and a stride specifying how <nl> + / / far to move the window between slices . From this it generates a three <nl> + / / dimensional output . The lowest dimension has an amplitude value for each <nl> + / / frequency during that time slice . The next dimension is time , with successive <nl> + / / frequency slices . The final dimension is for the channels in the input , so a <nl> + / / stereo audio input would have two here for example . <nl> + / / <nl> + / / This means the layout when converted and saved as an image is rotated 90 degrees <nl> + / / clockwise from a typical spectrogram . Time is descending down the Y axis , and <nl> + / / the frequency decreases from left to right . <nl> + / / <nl> + / / Each value in the result represents the square root of the sum of the real and <nl> + / / imaginary parts of an FFT on the current window of samples . In this way , the <nl> + / / lowest dimension represents the power of each frequency in the current window , <nl> + / / and adjacent windows are concatenated in the next dimension . <nl> + / / <nl> + / / To get a more intuitive and visual look at what this operation does , you can run <nl> + / / tensorflow / examples / wav_to_spectrogram to read in an audio file and save out the <nl> + / / resulting spectrogram as a PNG image . <nl> + / / <nl> + / / Arguments : <nl> + / / input : Float representation of audio data . <nl> + / / window_size : How wide the input window is in samples . For the highest efficiency <nl> + / / this should be a power of two , but other values are accepted . <nl> + / / stride : How widely apart the center of adjacent sample windows should be . <nl> + / / <nl> + / / Returns 3D representation of the audio frequencies as an image . <nl> + func AudioSpectrogram ( scope * Scope , input tf . Output , window_size int64 , stride int64 , optional . . . AudioSpectrogramAttr ) ( spectrogram tf . Output ) { <nl> + if scope . Err ( ) ! = nil { <nl> + return <nl> + } <nl> + attrs : = map [ string ] interface { } { " window_size " : window_size , " stride " : stride } <nl> + for _ , a : = range optional { <nl> + a ( attrs ) <nl> + } <nl> + opspec : = tf . OpSpec { <nl> + Type : " AudioSpectrogram " , <nl> + Input : [ ] tf . Input { <nl> + input , <nl> + } , <nl> + Attrs : attrs , <nl> + } <nl> + op : = scope . AddOperation ( opspec ) <nl> + return op . Output ( 0 ) <nl> + } <nl> + <nl> + / / Computes the gradient of morphological 2 - D dilation with respect to the input . <nl> + / / <nl> + / / Arguments : <nl> + / / input : 4 - D with shape ` [ batch , in_height , in_width , depth ] ` . <nl> + / / filter : 3 - D with shape ` [ filter_height , filter_width , depth ] ` . <nl> + / / out_backprop : 4 - D with shape ` [ batch , out_height , out_width , depth ] ` . <nl> + / / strides : 1 - D of length 4 . The stride of the sliding window for each dimension of <nl> + / / the input tensor . Must be : ` [ 1 , stride_height , stride_width , 1 ] ` . <nl> + / / rates : 1 - D of length 4 . The input stride for atrous morphological dilation . <nl> + / / Must be : ` [ 1 , rate_height , rate_width , 1 ] ` . <nl> + / / padding : The type of padding algorithm to use . <nl> + / / <nl> + / / Returns 4 - D with shape ` [ batch , in_height , in_width , depth ] ` . <nl> + func Dilation2DBackpropInput ( scope * Scope , input tf . Output , filter tf . Output , out_backprop tf . Output , strides [ ] int64 , rates [ ] int64 , padding string ) ( in_backprop tf . Output ) { <nl> + if scope . Err ( ) ! = nil { <nl> + return <nl> + } <nl> + attrs : = map [ string ] interface { } { " strides " : strides , " rates " : rates , " padding " : padding } <nl> + opspec : = tf . OpSpec { <nl> + Type : " Dilation2DBackpropInput " , <nl> + Input : [ ] tf . Input { <nl> + input , filter , out_backprop , <nl> + } , <nl> + Attrs : attrs , <nl> + } <nl> + op : = scope . AddOperation ( opspec ) <nl> + return op . Output ( 0 ) <nl> + } <nl> + <nl> + / / Returns the truth value of ( x = = y ) element - wise . <nl> + / / <nl> + / / * NOTE * : ` Equal ` supports broadcasting . More about broadcasting <nl> + / / [ here ] ( http : / / docs . scipy . org / doc / numpy / user / basics . broadcasting . html ) <nl> + func Equal ( scope * Scope , x tf . Output , y tf . Output ) ( z tf . Output ) { <nl> + if scope . Err ( ) ! = nil { <nl> + return <nl> + } <nl> + opspec : = tf . OpSpec { <nl> + Type : " Equal " , <nl> + Input : [ ] tf . Input { <nl> + x , y , <nl> + } , <nl> + } <nl> + op : = scope . AddOperation ( opspec ) <nl> + return op . Output ( 0 ) <nl> + } <nl> + <nl> + / / Computes the gradient of morphological 2 - D dilation with respect to the filter . <nl> + / / <nl> + / / Arguments : <nl> + / / input : 4 - D with shape ` [ batch , in_height , in_width , depth ] ` . <nl> + / / filter : 3 - D with shape ` [ filter_height , filter_width , depth ] ` . <nl> + / / out_backprop : 4 - D with shape ` [ batch , out_height , out_width , depth ] ` . <nl> + / / strides : 1 - D of length 4 . The stride of the sliding window for each dimension of <nl> + / / the input tensor . Must be : ` [ 1 , stride_height , stride_width , 1 ] ` . <nl> + / / rates : 1 - D of length 4 . The input stride for atrous morphological dilation . <nl> + / / Must be : ` [ 1 , rate_height , rate_width , 1 ] ` . <nl> + / / padding : The type of padding algorithm to use . <nl> + / / <nl> + / / Returns 3 - D with shape ` [ filter_height , filter_width , depth ] ` . <nl> + func Dilation2DBackpropFilter ( scope * Scope , input tf . Output , filter tf . Output , out_backprop tf . Output , strides [ ] int64 , rates [ ] int64 , padding string ) ( filter_backprop tf . Output ) { <nl> + if scope . Err ( ) ! = nil { <nl> + return <nl> + } <nl> + attrs : = map [ string ] interface { } { " strides " : strides , " rates " : rates , " padding " : padding } <nl> + opspec : = tf . OpSpec { <nl> + Type : " Dilation2DBackpropFilter " , <nl> + Input : [ ] tf . Input { <nl> + input , filter , out_backprop , <nl> + } , <nl> + Attrs : attrs , <nl> + } <nl> + op : = scope . AddOperation ( opspec ) <nl> + return op . Output ( 0 ) <nl> + } <nl> + <nl> / / Computes rectified linear gradients for a Relu operation . <nl> / / <nl> / / Arguments : <nl> | Go : Update generated wrapper functions for TensorFlow ops . | tensorflow/tensorflow | 24890d550d124162e74f858d710cf76117ac649a | 2017-09-27T20:16:48Z |
mmm a / tensorflow / core / BUILD <nl> ppp b / tensorflow / core / BUILD <nl> cc_library ( <nl> name = " android_tensorflow_test_lib " , <nl> testonly = 1 , <nl> srcs = if_android ( [ " : android_test_srcs " ] ) , <nl> + hdrs = [ <nl> + " framework / fake_input . h " , <nl> + " framework / shape_inference_testutil . h " , <nl> + " framework / tensor_testutil . h " , <nl> + " util / reporter . h " , <nl> + ] , <nl> copts = tf_copts ( ) + [ " - Os " ] , <nl> tags = [ <nl> " manual " , <nl> mmm a / tensorflow / core / kernels / BUILD <nl> ppp b / tensorflow / core / kernels / BUILD <nl> cc_binary ( <nl> " notap " , <nl> ] , <nl> deps = [ <nl> - " : android_tensorflow_kernels " , <nl> " / / tensorflow / cc : cc_ops " , <nl> " / / tensorflow / cc : client_session " , <nl> - " / / tensorflow / core : android_tensorflow_lib " , <nl> - " / / tensorflow / core : android_tensorflow_test_lib " , <nl> - ] , <nl> + ] + select ( { <nl> + " / / tensorflow : android " : [ <nl> + " : android_tensorflow_kernels " , <nl> + " / / tensorflow / core : android_tensorflow_lib " , <nl> + " / / tensorflow / core : android_tensorflow_test_lib " , <nl> + ] , <nl> + " / / conditions : default " : [ <nl> + " / / tensorflow / core : framework " , <nl> + " / / tensorflow / core : tensor_testutil " , <nl> + " / / tensorflow / core : test_main " , <nl> + ] , <nl> + } ) , <nl> ) <nl> <nl> tf_cc_test ( <nl> cc_binary ( <nl> " notap " , <nl> ] , <nl> deps = [ <nl> - " : android_tensorflow_kernels " , <nl> " / / tensorflow / cc : cc_ops " , <nl> " / / tensorflow / cc : client_session " , <nl> - " / / tensorflow / core : android_tensorflow_test_lib " , <nl> - ] , <nl> + ] + select ( { <nl> + " / / tensorflow : android " : [ <nl> + " : android_tensorflow_kernels " , <nl> + " / / tensorflow / core : android_tensorflow_lib " , <nl> + " / / tensorflow / core : android_tensorflow_test_lib " , <nl> + ] , <nl> + " / / conditions : default " : [ <nl> + " / / tensorflow / core : framework " , <nl> + " / / tensorflow / core : tensor_testutil " , <nl> + " / / tensorflow / core : test_main " , <nl> + ] , <nl> + } ) , <nl> ) <nl> <nl> tf_cc_test ( <nl> | Change dependencies for the _android_only binaries . | tensorflow/tensorflow | 983efe163b9ff0fa1c5b843cf28a9f9d5fb83071 | 2017-02-07T03:11:20Z |
mmm a / src / builtins / builtins - definitions . h <nl> ppp b / src / builtins / builtins - definitions . h <nl> namespace internal { <nl> / * StringIterator * / \ <nl> / * ES6 # sec - % stringiteratorprototype % . next * / \ <nl> TFJ ( StringIteratorPrototypeNext , 0 , kReceiver ) \ <nl> - TFS ( StringToList , kSource ) \ <nl> \ <nl> / * Symbol * / \ <nl> / * ES # sec - symbol - constructor * / \ <nl> mmm a / src / builtins / builtins - iterator - gen . cc <nl> ppp b / src / builtins / builtins - iterator - gen . cc <nl> <nl> # include " src / builtins / builtins - iterator - gen . h " <nl> # include " src / builtins / growable - fixed - array - gen . h " <nl> <nl> - # include " src / builtins / builtins - string - gen . h " <nl> # include " src / builtins / builtins - utils - gen . h " <nl> # include " src / builtins / builtins . h " <nl> # include " src / code - stub - assembler . h " <nl> TF_BUILTIN ( IterableToListMayPreserveHoles , IteratorBuiltinsAssembler ) { <nl> } <nl> <nl> / / This builtin loads the property Symbol . iterator as the iterator , and has a <nl> - / / fast path for fast arrays and another one for strings . These fast paths will <nl> - / / only be taken if Symbol . iterator and the Iterator prototype are not modified <nl> - / / in a way that changes the original iteration behavior . <nl> - / / * In case of fast holey arrays , holes will be converted to undefined to <nl> - / / reflect iteration semantics . Note that replacement by undefined is only <nl> - / / correct when the NoElements protector is valid . <nl> + / / fast path for fast arrays . In case of fast holey arrays , holes will be <nl> + / / converted to undefined to reflect iteration semantics . Note that replacement <nl> + / / by undefined is only correct when the NoElements protector is valid . <nl> TF_BUILTIN ( IterableToListWithSymbolLookup , IteratorBuiltinsAssembler ) { <nl> TNode < Context > context = CAST ( Parameter ( Descriptor : : kContext ) ) ; <nl> TNode < Object > iterable = CAST ( Parameter ( Descriptor : : kIterable ) ) ; <nl> <nl> - Label slow_path ( this ) , check_string ( this ) ; <nl> - <nl> - GotoIfForceSlowPath ( & slow_path ) ; <nl> - <nl> - GotoIfNot ( IsFastJSArrayWithNoCustomIteration ( iterable , context ) , <nl> - & check_string ) ; <nl> + Label slow_path ( this ) ; <nl> <nl> - / / Fast path for fast JSArray . <nl> + GotoIfNot ( IsFastJSArrayWithNoCustomIteration ( iterable , context ) , & slow_path ) ; <nl> + / / Here we are guaranteed that iterable is a fast JSArray with an original <nl> + / / iterator . <nl> TailCallBuiltin ( Builtins : : kCloneFastJSArrayFillingHoles , context , iterable ) ; <nl> <nl> - BIND ( & check_string ) ; <nl> - { <nl> - StringBuiltinsAssembler string_assembler ( state ( ) ) ; <nl> - GotoIfNot ( string_assembler . IsStringPrimitiveWithNoCustomIteration ( iterable , <nl> - context ) , <nl> - & slow_path ) ; <nl> - <nl> - / / Fast path for strings . <nl> - TailCallBuiltin ( Builtins : : kStringToList , context , iterable ) ; <nl> - } <nl> - <nl> BIND ( & slow_path ) ; <nl> { <nl> TNode < Object > iterator_fn = GetIteratorMethod ( context , iterable ) ; <nl> mmm a / src / builtins / builtins - string - gen . cc <nl> ppp b / src / builtins / builtins - string - gen . cc <nl> TF_BUILTIN ( StringIteratorPrototypeNext , StringBuiltinsAssembler ) { <nl> } <nl> } <nl> <nl> - TNode < BoolT > StringBuiltinsAssembler : : IsStringPrimitiveWithNoCustomIteration ( <nl> - TNode < Object > object , TNode < Context > context ) { <nl> - Label if_false ( this , Label : : kDeferred ) , exit ( this ) ; <nl> - TVARIABLE ( BoolT , var_result ) ; <nl> - <nl> - GotoIf ( TaggedIsSmi ( object ) , & if_false ) ; <nl> - GotoIfNot ( IsString ( CAST ( object ) ) , & if_false ) ; <nl> - <nl> - / / Check that the String iterator hasn ' t been modified in a way that would <nl> - / / affect iteration . <nl> - Node * protector_cell = LoadRoot ( RootIndex : : kStringIteratorProtector ) ; <nl> - DCHECK ( isolate ( ) - > heap ( ) - > string_iterator_protector ( ) - > IsPropertyCell ( ) ) ; <nl> - var_result = <nl> - WordEqual ( LoadObjectField ( protector_cell , PropertyCell : : kValueOffset ) , <nl> - SmiConstant ( Isolate : : kProtectorValid ) ) ; <nl> - Goto ( & exit ) ; <nl> - <nl> - BIND ( & if_false ) ; <nl> - { <nl> - var_result = Int32FalseConstant ( ) ; <nl> - Goto ( & exit ) ; <nl> - } <nl> - <nl> - BIND ( & exit ) ; <nl> - return var_result . value ( ) ; <nl> - } <nl> - <nl> - TNode < JSArray > StringBuiltinsAssembler : : StringToList ( TNode < Context > context , <nl> - TNode < String > string ) { <nl> - CSA_ASSERT ( this , IsStringPrimitiveWithNoCustomIteration ( string , context ) ) ; <nl> - const ElementsKind kind = PACKED_ELEMENTS ; <nl> - TNode < IntPtrT > length = LoadStringLengthAsWord ( string ) ; <nl> - <nl> - Node * array = nullptr , * elements = nullptr ; <nl> - Node * array_map = LoadJSArrayElementsMap ( kind , LoadNativeContext ( context ) ) ; <nl> - / / Allocate both array and elements object , and initialize the JSArray . <nl> - std : : tie ( array , elements ) = AllocateUninitializedJSArrayWithElements ( <nl> - kind , array_map , SmiTag ( length ) , nullptr , length ) ; <nl> - / / Put the array in a valid state because the loop below can trigger GC . <nl> - FillFixedArrayWithSmiZero ( CAST ( elements ) , length ) ; <nl> - <nl> - const int first_element_offset = FixedArray : : kHeaderSize - kHeapObjectTag ; <nl> - TNode < IntPtrT > first_to_element_offset = <nl> - ElementOffsetFromIndex ( IntPtrConstant ( 0 ) , kind , INTPTR_PARAMETERS , 0 ) ; <nl> - VARIABLE ( <nl> - var_offset , MachineType : : PointerRepresentation ( ) , <nl> - IntPtrAdd ( first_to_element_offset , IntPtrConstant ( first_element_offset ) ) ) ; <nl> - TVARIABLE ( IntPtrT , var_position , IntPtrConstant ( 0 ) ) ; <nl> - Label done ( this ) , next_codepoint ( this , { & var_position , & var_offset } ) ; <nl> - <nl> - / / TODO ( dhai ) : refactor the loop construction for string to reuse . <nl> - Goto ( & next_codepoint ) ; <nl> - <nl> - BIND ( & next_codepoint ) ; <nl> - { <nl> - / / Loop condition . <nl> - GotoIfNot ( IntPtrLessThan ( var_position . value ( ) , length ) , & done ) ; <nl> - const UnicodeEncoding encoding = UnicodeEncoding : : UTF16 ; <nl> - TNode < Int32T > ch = <nl> - LoadSurrogatePairAt ( string , length , var_position . value ( ) , encoding ) ; <nl> - TNode < String > value = StringFromSingleCodePoint ( ch , encoding ) ; <nl> - <nl> - Store ( elements , var_offset . value ( ) , value ) ; <nl> - <nl> - / / Increment the position . <nl> - TNode < IntPtrT > ch_length = LoadStringLengthAsWord ( value ) ; <nl> - var_position = IntPtrAdd ( var_position . value ( ) , ch_length ) ; <nl> - / / Increment the array offset and continue the loop . <nl> - var_offset . Bind ( <nl> - IntPtrAdd ( var_offset . value ( ) , IntPtrConstant ( kPointerSize ) ) ) ; <nl> - Goto ( & next_codepoint ) ; <nl> - } <nl> - <nl> - BIND ( & done ) ; <nl> - return UncheckedCast < JSArray > ( array ) ; <nl> - } <nl> - <nl> - TF_BUILTIN ( StringToList , StringBuiltinsAssembler ) { <nl> - TNode < Context > context = CAST ( Parameter ( Descriptor : : kContext ) ) ; <nl> - TNode < String > string = CAST ( Parameter ( Descriptor : : kSource ) ) ; <nl> - Return ( StringToList ( context , string ) ) ; <nl> - } <nl> - <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> / / ES6 section B . 2 . 3 Additional Properties of the String . prototype object <nl> <nl> mmm a / src / builtins / builtins - string - gen . h <nl> ppp b / src / builtins / builtins - string - gen . h <nl> class StringBuiltinsAssembler : public CodeStubAssembler { <nl> Node * rhs , Node * rhs_instance_type , <nl> TNode < IntPtrT > length , Label * if_equal , <nl> Label * if_not_equal , Label * if_indirect ) ; <nl> - TNode < BoolT > IsStringPrimitiveWithNoCustomIteration ( TNode < Object > object , <nl> - TNode < Context > context ) ; <nl> <nl> protected : <nl> - TNode < JSArray > StringToList ( TNode < Context > context , TNode < String > string ) ; <nl> - <nl> void StringEqual_Loop ( Node * lhs , Node * lhs_instance_type , <nl> MachineType lhs_type , Node * rhs , <nl> Node * rhs_instance_type , MachineType rhs_type , <nl> mmm a / src / compiler / js - heap - broker . h <nl> ppp b / src / compiler / js - heap - broker . h <nl> class ContextRef : public HeapObjectRef { <nl> V ( JSFunction , promise_function ) \ <nl> V ( Map , fast_aliased_arguments_map ) \ <nl> V ( Map , initial_array_iterator_map ) \ <nl> - V ( Map , initial_string_iterator_map ) \ <nl> V ( Map , iterator_result_map ) \ <nl> V ( Map , js_array_holey_double_elements_map ) \ <nl> V ( Map , js_array_holey_elements_map ) \ <nl> class ContextRef : public HeapObjectRef { <nl> V ( Map , sloppy_arguments_map ) \ <nl> V ( Map , slow_object_with_null_prototype_map ) \ <nl> V ( Map , strict_arguments_map ) \ <nl> + V ( Map , initial_string_iterator_map ) \ <nl> V ( ScriptContextTable , script_context_table ) <nl> <nl> class NativeContextRef : public ContextRef { <nl> mmm a / src / heap / heap . h <nl> ppp b / src / heap / heap . h <nl> using v8 : : MemoryPressureLevel ; <nl> V ( TypedArraySpeciesProtector ) \ <nl> V ( PromiseSpeciesProtector ) \ <nl> V ( StaleRegister ) \ <nl> - V ( StringIteratorProtector ) \ <nl> V ( StringLengthProtector ) \ <nl> V ( StringTableMap ) \ <nl> V ( SymbolMap ) \ <nl> mmm a / tools / v8heapconst . py <nl> ppp b / tools / v8heapconst . py <nl> <nl> ( " OLD_SPACE " , 0x02361 ) : " StringLengthProtector " , <nl> ( " OLD_SPACE " , 0x02371 ) : " ArrayIteratorProtector " , <nl> ( " OLD_SPACE " , 0x02399 ) : " ArrayBufferNeuteringProtector " , <nl> - ( " OLD_SPACE " , 0x02421 ) : " StringIteratorProtector " , <nl> } <nl> <nl> # List of known V8 Frame Markers . <nl> | Revert " Add fast path for spreading primitive strings . " | v8/v8 | 19594301f25a988d1e9256f5faf20c3846398ca8 | 2018-10-04T08:50:59Z |
mmm a / src / x87 / code - stubs - x87 . cc <nl> ppp b / src / x87 / code - stubs - x87 . cc <nl> void TransitionElementsKindStub : : InitializeInterfaceDescriptor ( <nl> } <nl> <nl> <nl> - const Register InterfaceDescriptor : : ContextRegister ( ) { return esi ; } <nl> - <nl> - <nl> static void InitializeArrayConstructorDescriptor ( <nl> Isolate * isolate , CodeStub : : Major major , <nl> CodeStubInterfaceDescriptor * descriptor , <nl> void StringAddStub : : InitializeInterfaceDescriptor ( <nl> } <nl> <nl> <nl> - void CallDescriptors : : InitializeForIsolate ( Isolate * isolate ) { <nl> - { <nl> - CallInterfaceDescriptor * descriptor = <nl> - isolate - > call_descriptor ( Isolate : : ArgumentAdaptorCall ) ; <nl> - Register registers [ ] = { esi , / / context <nl> - edi , / / JSFunction <nl> - eax , / / actual number of arguments <nl> - ebx , / / expected number of arguments <nl> - } ; <nl> - Representation representations [ ] = { <nl> - Representation : : Tagged ( ) , / / context <nl> - Representation : : Tagged ( ) , / / JSFunction <nl> - Representation : : Integer32 ( ) , / / actual number of arguments <nl> - Representation : : Integer32 ( ) , / / expected number of arguments <nl> - } ; <nl> - descriptor - > Initialize ( arraysize ( registers ) , registers , representations ) ; <nl> - } <nl> - { <nl> - CallInterfaceDescriptor * descriptor = <nl> - isolate - > call_descriptor ( Isolate : : KeyedCall ) ; <nl> - Register registers [ ] = { esi , / / context <nl> - ecx , / / key <nl> - } ; <nl> - Representation representations [ ] = { <nl> - Representation : : Tagged ( ) , / / context <nl> - Representation : : Tagged ( ) , / / key <nl> - } ; <nl> - descriptor - > Initialize ( arraysize ( registers ) , registers , representations ) ; <nl> - } <nl> - { <nl> - CallInterfaceDescriptor * descriptor = <nl> - isolate - > call_descriptor ( Isolate : : NamedCall ) ; <nl> - Register registers [ ] = { esi , / / context <nl> - ecx , / / name <nl> - } ; <nl> - Representation representations [ ] = { <nl> - Representation : : Tagged ( ) , / / context <nl> - Representation : : Tagged ( ) , / / name <nl> - } ; <nl> - descriptor - > Initialize ( arraysize ( registers ) , registers , representations ) ; <nl> - } <nl> - { <nl> - CallInterfaceDescriptor * descriptor = <nl> - isolate - > call_descriptor ( Isolate : : CallHandler ) ; <nl> - Register registers [ ] = { esi , / / context <nl> - edx , / / name <nl> - } ; <nl> - Representation representations [ ] = { <nl> - Representation : : Tagged ( ) , / / context <nl> - Representation : : Tagged ( ) , / / receiver <nl> - } ; <nl> - descriptor - > Initialize ( arraysize ( registers ) , registers , representations ) ; <nl> - } <nl> - { <nl> - CallInterfaceDescriptor * descriptor = <nl> - isolate - > call_descriptor ( Isolate : : ApiFunctionCall ) ; <nl> - Register registers [ ] = { esi , / / context <nl> - eax , / / callee <nl> - ebx , / / call_data <nl> - ecx , / / holder <nl> - edx , / / api_function_address <nl> - } ; <nl> - Representation representations [ ] = { <nl> - Representation : : Tagged ( ) , / / context <nl> - Representation : : Tagged ( ) , / / callee <nl> - Representation : : Tagged ( ) , / / call_data <nl> - Representation : : Tagged ( ) , / / holder <nl> - Representation : : External ( ) , / / api_function_address <nl> - } ; <nl> - descriptor - > Initialize ( arraysize ( registers ) , registers , representations ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> # define __ ACCESS_MASM ( masm ) <nl> <nl> <nl> new file mode 100644 <nl> index 00000000000 . . dfa18847857 <nl> mmm / dev / null <nl> ppp b / src / x87 / interface - descriptors - x87 . cc <nl> <nl> + / / Copyright 2012 the V8 project authors . All rights reserved . <nl> + / / Use of this source code is governed by a BSD - style license that can be <nl> + / / found in the LICENSE file . <nl> + <nl> + # include " src / v8 . h " <nl> + <nl> + # if V8_TARGET_ARCH_X87 <nl> + <nl> + # include " src / ic / ic - conventions . h " <nl> + # include " src / interface - descriptors . h " <nl> + <nl> + namespace v8 { <nl> + namespace internal { <nl> + <nl> + const Register CallInterfaceDescriptor : : ContextRegister ( ) { return esi ; } <nl> + <nl> + <nl> + void CallDescriptors : : InitializeForIsolate ( Isolate * isolate ) { <nl> + InitializeForIsolateAllPlatforms ( isolate ) ; <nl> + <nl> + { <nl> + CallInterfaceDescriptor * descriptor = <nl> + isolate - > call_descriptor ( CallDescriptorKey : : FastNewClosureCall ) ; <nl> + Register registers [ ] = { esi , ebx } ; <nl> + descriptor - > Initialize ( arraysize ( registers ) , registers , NULL ) ; <nl> + } <nl> + { <nl> + CallInterfaceDescriptor * descriptor = <nl> + isolate - > call_descriptor ( CallDescriptorKey : : FastNewContextCall ) ; <nl> + Register registers [ ] = { esi , edi } ; <nl> + descriptor - > Initialize ( arraysize ( registers ) , registers , NULL ) ; <nl> + } <nl> + { <nl> + CallInterfaceDescriptor * descriptor = <nl> + isolate - > call_descriptor ( CallDescriptorKey : : ToNumberCall ) ; <nl> + / / ToNumberStub invokes a function , and therefore needs a context . <nl> + Register registers [ ] = { esi , eax } ; <nl> + descriptor - > Initialize ( arraysize ( registers ) , registers , NULL ) ; <nl> + } <nl> + { <nl> + CallInterfaceDescriptor * descriptor = <nl> + isolate - > call_descriptor ( CallDescriptorKey : : NumberToStringCall ) ; <nl> + Register registers [ ] = { esi , eax } ; <nl> + descriptor - > Initialize ( arraysize ( registers ) , registers , NULL ) ; <nl> + } <nl> + { <nl> + CallInterfaceDescriptor * descriptor = <nl> + isolate - > call_descriptor ( CallDescriptorKey : : FastCloneShallowArrayCall ) ; <nl> + Register registers [ ] = { esi , eax , ebx , ecx } ; <nl> + Representation representations [ ] = { <nl> + Representation : : Tagged ( ) , Representation : : Tagged ( ) , <nl> + Representation : : Smi ( ) , Representation : : Tagged ( ) } ; <nl> + descriptor - > Initialize ( arraysize ( registers ) , registers , representations ) ; <nl> + } <nl> + { <nl> + CallInterfaceDescriptor * descriptor = <nl> + isolate - > call_descriptor ( CallDescriptorKey : : FastCloneShallowObjectCall ) ; <nl> + Register registers [ ] = { esi , eax , ebx , ecx , edx } ; <nl> + descriptor - > Initialize ( arraysize ( registers ) , registers , NULL ) ; <nl> + } <nl> + { <nl> + CallInterfaceDescriptor * descriptor = <nl> + isolate - > call_descriptor ( CallDescriptorKey : : CreateAllocationSiteCall ) ; <nl> + Register registers [ ] = { esi , ebx , edx } ; <nl> + descriptor - > Initialize ( arraysize ( registers ) , registers , NULL ) ; <nl> + } <nl> + { <nl> + CallInterfaceDescriptor * descriptor = <nl> + isolate - > call_descriptor ( CallDescriptorKey : : CallFunctionCall ) ; <nl> + Register registers [ ] = { esi , edi } ; <nl> + descriptor - > Initialize ( arraysize ( registers ) , registers , NULL ) ; <nl> + } <nl> + { <nl> + CallInterfaceDescriptor * descriptor = <nl> + isolate - > call_descriptor ( CallDescriptorKey : : CallConstructCall ) ; <nl> + / / eax : number of arguments <nl> + / / ebx : feedback vector <nl> + / / edx : ( only if ebx is not the megamorphic symbol ) slot in feedback <nl> + / / vector ( Smi ) <nl> + / / edi : constructor function <nl> + / / TODO ( turbofan ) : So far we don ' t gather type feedback and hence skip the <nl> + / / slot parameter , but ArrayConstructStub needs the vector to be undefined . <nl> + Register registers [ ] = { esi , eax , edi , ebx } ; <nl> + descriptor - > Initialize ( arraysize ( registers ) , registers , NULL ) ; <nl> + } <nl> + { <nl> + CallInterfaceDescriptor * descriptor = <nl> + isolate - > call_descriptor ( CallDescriptorKey : : RegExpConstructResultCall ) ; <nl> + Register registers [ ] = { esi , ecx , ebx , eax } ; <nl> + descriptor - > Initialize ( arraysize ( registers ) , registers , NULL ) ; <nl> + } <nl> + { <nl> + CallInterfaceDescriptor * descriptor = <nl> + isolate - > call_descriptor ( CallDescriptorKey : : TransitionElementsKindCall ) ; <nl> + Register registers [ ] = { esi , eax , ebx } ; <nl> + descriptor - > Initialize ( arraysize ( registers ) , registers , NULL ) ; <nl> + } <nl> + { <nl> + CallInterfaceDescriptor * descriptor = isolate - > call_descriptor ( <nl> + CallDescriptorKey : : ArrayConstructorConstantArgCountCall ) ; <nl> + / / register state <nl> + / / eax - - number of arguments <nl> + / / edi - - function <nl> + / / ebx - - allocation site with elements kind <nl> + Register registers [ ] = { esi , edi , ebx } ; <nl> + descriptor - > Initialize ( arraysize ( registers ) , registers , NULL ) ; <nl> + } <nl> + { <nl> + CallInterfaceDescriptor * descriptor = <nl> + isolate - > call_descriptor ( CallDescriptorKey : : ArrayConstructorCall ) ; <nl> + / / stack param count needs ( constructor pointer , and single argument ) <nl> + Register registers [ ] = { esi , edi , ebx , eax } ; <nl> + Representation representations [ ] = { <nl> + Representation : : Tagged ( ) , Representation : : Tagged ( ) , <nl> + Representation : : Tagged ( ) , Representation : : Integer32 ( ) } ; <nl> + descriptor - > Initialize ( arraysize ( registers ) , registers , representations ) ; <nl> + } <nl> + { <nl> + CallInterfaceDescriptor * descriptor = isolate - > call_descriptor ( <nl> + CallDescriptorKey : : InternalArrayConstructorConstantArgCountCall ) ; <nl> + / / register state <nl> + / / eax - - number of arguments <nl> + / / edi - - function <nl> + Register registers [ ] = { esi , edi } ; <nl> + descriptor - > Initialize ( arraysize ( registers ) , registers , NULL ) ; <nl> + } <nl> + { <nl> + CallInterfaceDescriptor * descriptor = isolate - > call_descriptor ( <nl> + CallDescriptorKey : : InternalArrayConstructorCall ) ; <nl> + / / stack param count needs ( constructor pointer , and single argument ) <nl> + Register registers [ ] = { esi , edi , eax } ; <nl> + Representation representations [ ] = { Representation : : Tagged ( ) , <nl> + Representation : : Tagged ( ) , <nl> + Representation : : Integer32 ( ) } ; <nl> + descriptor - > Initialize ( arraysize ( registers ) , registers , representations ) ; <nl> + } <nl> + { <nl> + CallInterfaceDescriptor * descriptor = <nl> + isolate - > call_descriptor ( CallDescriptorKey : : CompareNilCall ) ; <nl> + Register registers [ ] = { esi , eax } ; <nl> + descriptor - > Initialize ( arraysize ( registers ) , registers , NULL ) ; <nl> + } <nl> + { <nl> + CallInterfaceDescriptor * descriptor = <nl> + isolate - > call_descriptor ( CallDescriptorKey : : ToBooleanCall ) ; <nl> + Register registers [ ] = { esi , eax } ; <nl> + descriptor - > Initialize ( arraysize ( registers ) , registers , NULL ) ; <nl> + } <nl> + { <nl> + CallInterfaceDescriptor * descriptor = <nl> + isolate - > call_descriptor ( CallDescriptorKey : : BinaryOpCall ) ; <nl> + Register registers [ ] = { esi , edx , eax } ; <nl> + descriptor - > Initialize ( arraysize ( registers ) , registers , NULL ) ; <nl> + } <nl> + { <nl> + CallInterfaceDescriptor * descriptor = isolate - > call_descriptor ( <nl> + CallDescriptorKey : : BinaryOpWithAllocationSiteCall ) ; <nl> + Register registers [ ] = { esi , ecx , edx , eax } ; <nl> + descriptor - > Initialize ( arraysize ( registers ) , registers , NULL ) ; <nl> + } <nl> + { <nl> + CallInterfaceDescriptor * descriptor = <nl> + isolate - > call_descriptor ( CallDescriptorKey : : StringAddCall ) ; <nl> + Register registers [ ] = { esi , edx , eax } ; <nl> + descriptor - > Initialize ( arraysize ( registers ) , registers , NULL ) ; <nl> + } <nl> + <nl> + { <nl> + CallInterfaceDescriptor * descriptor = <nl> + isolate - > call_descriptor ( CallDescriptorKey : : ArgumentAdaptorCall ) ; <nl> + Register registers [ ] = { <nl> + esi , / / context <nl> + edi , / / JSFunction <nl> + eax , / / actual number of arguments <nl> + ebx , / / expected number of arguments <nl> + } ; <nl> + Representation representations [ ] = { <nl> + Representation : : Tagged ( ) , / / context <nl> + Representation : : Tagged ( ) , / / JSFunction <nl> + Representation : : Integer32 ( ) , / / actual number of arguments <nl> + Representation : : Integer32 ( ) , / / expected number of arguments <nl> + } ; <nl> + descriptor - > Initialize ( arraysize ( registers ) , registers , representations ) ; <nl> + } <nl> + { <nl> + CallInterfaceDescriptor * descriptor = <nl> + isolate - > call_descriptor ( CallDescriptorKey : : KeyedCall ) ; <nl> + Register registers [ ] = { <nl> + esi , / / context <nl> + ecx , / / key <nl> + } ; <nl> + Representation representations [ ] = { <nl> + Representation : : Tagged ( ) , / / context <nl> + Representation : : Tagged ( ) , / / key <nl> + } ; <nl> + descriptor - > Initialize ( arraysize ( registers ) , registers , representations ) ; <nl> + } <nl> + { <nl> + CallInterfaceDescriptor * descriptor = <nl> + isolate - > call_descriptor ( CallDescriptorKey : : NamedCall ) ; <nl> + Register registers [ ] = { <nl> + esi , / / context <nl> + ecx , / / name <nl> + } ; <nl> + Representation representations [ ] = { <nl> + Representation : : Tagged ( ) , / / context <nl> + Representation : : Tagged ( ) , / / name <nl> + } ; <nl> + descriptor - > Initialize ( arraysize ( registers ) , registers , representations ) ; <nl> + } <nl> + { <nl> + CallInterfaceDescriptor * descriptor = <nl> + isolate - > call_descriptor ( CallDescriptorKey : : CallHandler ) ; <nl> + Register registers [ ] = { <nl> + esi , / / context <nl> + edx , / / name <nl> + } ; <nl> + Representation representations [ ] = { <nl> + Representation : : Tagged ( ) , / / context <nl> + Representation : : Tagged ( ) , / / receiver <nl> + } ; <nl> + descriptor - > Initialize ( arraysize ( registers ) , registers , representations ) ; <nl> + } <nl> + { <nl> + CallInterfaceDescriptor * descriptor = <nl> + isolate - > call_descriptor ( CallDescriptorKey : : ApiFunctionCall ) ; <nl> + Register registers [ ] = { <nl> + esi , / / context <nl> + eax , / / callee <nl> + ebx , / / call_data <nl> + ecx , / / holder <nl> + edx , / / api_function_address <nl> + } ; <nl> + Representation representations [ ] = { <nl> + Representation : : Tagged ( ) , / / context <nl> + Representation : : Tagged ( ) , / / callee <nl> + Representation : : Tagged ( ) , / / call_data <nl> + Representation : : Tagged ( ) , / / holder <nl> + Representation : : External ( ) , / / api_function_address <nl> + } ; <nl> + descriptor - > Initialize ( arraysize ( registers ) , registers , representations ) ; <nl> + } <nl> + } <nl> + } <nl> + } / / namespace v8 : : internal <nl> + <nl> + # endif / / V8_TARGET_ARCH_X87 <nl> mmm a / tools / gyp / v8 . gyp <nl> ppp b / tools / gyp / v8 . gyp <nl> <nl> ' . . / . . / src / x87 / frames - x87 . cc ' , <nl> ' . . / . . / src / x87 / frames - x87 . h ' , <nl> ' . . / . . / src / x87 / full - codegen - x87 . cc ' , <nl> + ' . . / . . / src / x87 / interface - descriptors - x87 . cc ' , <nl> ' . . / . . / src / x87 / lithium - codegen - x87 . cc ' , <nl> ' . . / . . / src / x87 / lithium - codegen - x87 . h ' , <nl> ' . . / . . / src / x87 / lithium - gap - resolver - x87 . cc ' , <nl> | X87 : Refactoring InterfaceDescriptors away from code - stubs . h | v8/v8 | 5c782b9d8c7687b7e73380795ecb650729367e8d | 2014-09-01T14:00:25Z |
mmm a / tensorflow / core / kernels / one_hot_op . cc <nl> ppp b / tensorflow / core / kernels / one_hot_op . cc <nl> class OneHotOp : public OpKernel { <nl> Tensor * output ; <nl> OP_REQUIRES_OK ( ctx , ctx - > allocate_output ( 0 , output_shape , & output ) ) ; <nl> <nl> - / / prefix_dim_size = = # of elements before the axis <nl> - / / depth_v = = # of elements per axis <nl> - / / suffix_dim_size = = # of elements after the axis <nl> - int64 prefix_dim_size = 1 ; <nl> - for ( int i = 0 ; i < axis ; + + i ) { <nl> - prefix_dim_size * = indices_shape . dim_size ( i ) ; <nl> + if ( output_shape . num_elements ( ) > 0 ) { <nl> + / / prefix_dim_size = = # of elements before the axis <nl> + / / depth_v = = # of elements per axis <nl> + / / suffix_dim_size = = # of elements after the axis <nl> + int64 prefix_dim_size = 1 ; <nl> + for ( int i = 0 ; i < axis ; + + i ) { <nl> + prefix_dim_size * = indices_shape . dim_size ( i ) ; <nl> + } <nl> + TI suffix_dim_size = indices_shape . num_elements ( ) / prefix_dim_size ; <nl> + <nl> + / / Split indices into matrix of size prefix_dim_size x suffix_dim_size <nl> + auto indices_t = <nl> + indices . shaped < TI , 2 > ( { prefix_dim_size , suffix_dim_size } ) ; <nl> + / / Split output into 3 - Tensor of size : <nl> + / / prefix_dim_size x depth x suffix_dim_size . <nl> + auto output_t = <nl> + output - > shaped < T , 3 > ( { prefix_dim_size , depth_v , suffix_dim_size } ) ; <nl> + <nl> + functor : : OneHot < Device , T , TI > : : Compute ( ctx - > eigen_device < Device > ( ) , <nl> + indices_t , on_value_t , <nl> + off_value_t , & output_t ) ; <nl> } <nl> - TI suffix_dim_size = <nl> - indices_shape . num_elements ( ) / prefix_dim_size ; <nl> - <nl> - / / Split indices into matrix of size prefix_dim_size x suffix_dim_size <nl> - auto indices_t = <nl> - indices . shaped < TI , 2 > ( { prefix_dim_size , suffix_dim_size } ) ; <nl> - / / Split output into 3 - Tensor of size : <nl> - / / prefix_dim_size x depth x suffix_dim_size . <nl> - auto output_t = <nl> - output - > shaped < T , 3 > ( { prefix_dim_size , depth_v , suffix_dim_size } ) ; <nl> - <nl> - functor : : OneHot < Device , T , TI > : : Compute ( ctx - > eigen_device < Device > ( ) , indices_t , <nl> - on_value_t , off_value_t , & output_t ) ; <nl> } <nl> <nl> private : <nl> class OneHotOp : public OpKernel { <nl> TF_DISALLOW_COPY_AND_ASSIGN ( OneHotOp ) ; <nl> } ; <nl> <nl> - # define REGISTER_ONE_HOT_INDEX ( type , index_type ) \ <nl> - REGISTER_KERNEL_BUILDER ( Name ( " OneHot " ) \ <nl> - . Device ( DEVICE_CPU ) \ <nl> - . TypeConstraint < index_type > ( " TI " ) \ <nl> - . TypeConstraint < type > ( " T " ) \ <nl> - . HostMemory ( " depth " ) , \ <nl> + # define REGISTER_ONE_HOT_INDEX ( type , index_type ) \ <nl> + REGISTER_KERNEL_BUILDER ( Name ( " OneHot " ) \ <nl> + . Device ( DEVICE_CPU ) \ <nl> + . TypeConstraint < index_type > ( " TI " ) \ <nl> + . TypeConstraint < type > ( " T " ) \ <nl> + . HostMemory ( " depth " ) , \ <nl> OneHotOp < CPUDevice , type , index_type > ) ; <nl> <nl> # define REGISTER_ONE_HOT ( type ) \ <nl> TF_CALL_ALL_TYPES ( REGISTER_ONE_HOT ) ; <nl> <nl> / / Forward declarations of the functor specializations for GPU . <nl> namespace functor { <nl> - # define DECLARE_GPU_SPEC_INDEX ( T , TI ) \ <nl> - template < > \ <nl> - void OneHot < GPUDevice , T , TI > : : Compute ( \ <nl> - const GPUDevice & d , const typename TTypes < TI > : : ConstMatrix & indices , \ <nl> - const typename TTypes < T > : : ConstScalar & on_value , \ <nl> - const typename TTypes < T > : : ConstScalar & off_value , \ <nl> - typename TTypes < T , 3 > : : Tensor * output ) ; \ <nl> + # define DECLARE_GPU_SPEC_INDEX ( T , TI ) \ <nl> + template < > \ <nl> + void OneHot < GPUDevice , T , TI > : : Compute ( \ <nl> + const GPUDevice & d , const typename TTypes < TI > : : ConstMatrix & indices , \ <nl> + const typename TTypes < T > : : ConstScalar & on_value , \ <nl> + const typename TTypes < T > : : ConstScalar & off_value , \ <nl> + typename TTypes < T , 3 > : : Tensor * output ) ; \ <nl> extern template struct OneHot < GPUDevice , T , TI > ; <nl> <nl> # define DECLARE_GPU_SPEC ( T ) \ <nl> TF_CALL_GPU_NUMBER_TYPES ( DECLARE_GPU_SPEC ) ; <nl> } / / namespace functor <nl> <nl> / / Registration of the GPU implementations . <nl> - # define REGISTER_ONE_HOT_GPU_INDEX ( type , index_type ) \ <nl> - REGISTER_KERNEL_BUILDER ( Name ( " OneHot " ) \ <nl> - . Device ( DEVICE_GPU ) \ <nl> - . TypeConstraint < index_type > ( " TI " ) \ <nl> - . TypeConstraint < type > ( " T " ) \ <nl> - . HostMemory ( " depth " ) , \ <nl> + # define REGISTER_ONE_HOT_GPU_INDEX ( type , index_type ) \ <nl> + REGISTER_KERNEL_BUILDER ( Name ( " OneHot " ) \ <nl> + . Device ( DEVICE_GPU ) \ <nl> + . TypeConstraint < index_type > ( " TI " ) \ <nl> + . TypeConstraint < type > ( " T " ) \ <nl> + . HostMemory ( " depth " ) , \ <nl> OneHotOp < GPUDevice , type , index_type > ) ; <nl> <nl> # define REGISTER_ONE_HOT_GPU ( type ) \ <nl> mmm a / tensorflow / python / kernel_tests / one_hot_op_test . py <nl> ppp b / tensorflow / python / kernel_tests / one_hot_op_test . py <nl> def _testValueTypeBatch ( self , dtype ) : <nl> dtype = dtype , <nl> truth = [ truth [ 0 ] . T , truth [ 1 ] . T ] ) # Do not transpose the batch <nl> <nl> + def _testEmpty ( self , dtype ) : <nl> + indices = np . zeros ( ( 0 , 16 ) , dtype = np . int64 ) <nl> + depth = 3 <nl> + on_value = np . asarray ( 1 . 0 , dtype = dtype ) <nl> + off_value = np . asarray ( - 1 . 0 , dtype = dtype ) <nl> + truth = np . empty ( ( 0 , 16 , 3 ) , dtype = dtype ) <nl> + <nl> + # axis = = - 1 <nl> + self . _testBothOneHot ( <nl> + indices = indices , <nl> + depth = depth , <nl> + on_value = on_value , <nl> + off_value = off_value , <nl> + dtype = dtype , <nl> + truth = truth ) <nl> + <nl> + def testHalfBatch ( self ) : <nl> + self . _testEmpty ( np . float16 ) <nl> + self . _testBatch ( np . float16 ) <nl> + self . _testDefaultValuesBatch ( np . float16 ) <nl> + self . _testValueTypeBatch ( np . float16 ) <nl> + <nl> def testFloatBatch ( self ) : <nl> + self . _testEmpty ( np . float32 ) <nl> self . _testBatch ( np . float32 ) <nl> self . _testDefaultValuesBatch ( np . float32 ) <nl> self . _testValueTypeBatch ( np . float32 ) <nl> <nl> def testDoubleBatch ( self ) : <nl> + self . _testEmpty ( np . float64 ) <nl> self . _testBatch ( np . float64 ) <nl> self . _testDefaultValuesBatch ( np . float64 ) <nl> self . _testValueTypeBatch ( np . float64 ) <nl> <nl> def testInt32Batch ( self ) : <nl> + self . _testEmpty ( np . int32 ) <nl> self . _testBatch ( np . int32 ) <nl> self . _testDefaultValuesBatch ( np . int32 ) <nl> self . _testValueTypeBatch ( np . int32 ) <nl> <nl> def testInt64Batch ( self ) : <nl> + self . _testEmpty ( np . int64 ) <nl> self . _testBatch ( np . int64 ) <nl> self . _testDefaultValuesBatch ( np . int64 ) <nl> self . _testValueTypeBatch ( np . int64 ) <nl> <nl> def testComplexBatch ( self ) : <nl> + self . _testEmpty ( np . complex64 ) <nl> self . _testBatch ( np . complex64 ) <nl> # self . _testDefaultValuesBatch ( np . complex64 ) <nl> self . _testValueTypeBatch ( np . complex64 ) <nl> | Bugfix for one - hot op when inputs have no elements . | tensorflow/tensorflow | 763b829da21b7724cc8d5c5a5ec7e4971b78a3e8 | 2016-07-29T16:02:57Z |
mmm a / generic / THTensorRandom . c <nl> ppp b / generic / THTensorRandom . c <nl> void THTensor_ ( random ) ( THTensor * self , THGenerator * _generator ) <nl> # endif <nl> } <nl> <nl> + void THTensor_ ( clampedRandom ) ( THTensor * self , THGenerator * _generator , long min , long max ) { <nl> + THArgCheck ( max > min , 2 , " max must be greater than min " ) ; <nl> + TH_TENSOR_APPLY ( real , self , * self_data = ( real ) ( ( THRandom_random ( _generator ) % ( max - min ) ) + min ) ; ) <nl> + } <nl> + <nl> + void THTensor_ ( cappedRandom ) ( THTensor * self , THGenerator * _generator , long max ) { <nl> + THArgCheck ( max > 0 , 1 , " max must be positive " ) ; <nl> + THTensor_ ( clampedRandom ) ( self , _generator , 0 , max ) ; <nl> + } <nl> + <nl> void THTensor_ ( geometric ) ( THTensor * self , THGenerator * _generator , double p ) <nl> { <nl> TH_TENSOR_APPLY ( real , self , * self_data = ( real ) THRandom_geometric ( _generator , p ) ; ) ; <nl> mmm a / generic / THTensorRandom . h <nl> ppp b / generic / THTensorRandom . h <nl> <nl> # else <nl> <nl> TH_API void THTensor_ ( random ) ( THTensor * self , THGenerator * _generator ) ; <nl> + TH_API void THTensor_ ( clampedRandom ) ( THTensor * self , THGenerator * _generator , long min , long max ) ; <nl> + TH_API void THTensor_ ( cappedRandom ) ( THTensor * self , THGenerator * _generator , long max ) ; <nl> TH_API void THTensor_ ( geometric ) ( THTensor * self , THGenerator * _generator , double p ) ; <nl> TH_API void THTensor_ ( bernoulli ) ( THTensor * self , THGenerator * _generator , double p ) ; <nl> TH_API void THTensor_ ( bernoulli_FloatTensor ) ( THTensor * self , THGenerator * _generator , THFloatTensor * p ) ; <nl> | move clamped random functions out of cwrap and into TH | pytorch/pytorch | 54a111564147f7621785b0f284f77a7afd22f337 | 2017-08-15T06:58:14Z |
mmm a / hphp / runtime / base / array / array_iterator . cpp <nl> ppp b / hphp / runtime / base / array / array_iterator . cpp <nl> bool Iter : : init ( TypedValue * c1 ) { <nl> Class * ctx = arGetContextClass ( g_vmContext - > getFP ( ) ) ; <nl> CStrRef ctxStr = ctx ? ctx - > nameRef ( ) : null_string ; <nl> Array iterArray ( obj - > o_toIterArray ( ctxStr ) ) ; <nl> - ArrayData * ad = iterArray . getArrayData ( ) ; <nl> + ArrayData * ad = iterArray . get ( ) ; <nl> ( void ) new ( & arr ( ) ) ArrayIter ( ad ) ; <nl> } <nl> } <nl> static int64_t new_iter_object_any ( Iter * dest , ObjectData * obj , Class * ctx , <nl> __func__ , dest , obj , ctx ) ; <nl> CStrRef ctxStr = ctx ? ctx - > nameRef ( ) : null_string ; <nl> Array iterArray ( itObj - > o_toIterArray ( ctxStr ) ) ; <nl> - ArrayData * ad = iterArray . getArrayData ( ) ; <nl> + ArrayData * ad = iterArray . get ( ) ; <nl> ( void ) new ( & dest - > arr ( ) ) ArrayIter ( ad ) ; <nl> itType = ArrayIter : : TypeArray ; <nl> } <nl> mmm a / hphp / runtime / base / array / array_util . cpp <nl> ppp b / hphp / runtime / base / array / array_util . cpp <nl> Variant ArrayUtil : : CountValues ( CArrRef input ) { <nl> <nl> Array ArrayUtil : : EnsureIntKeys ( CArrRef input ) { <nl> assert ( ! input . isNull ( ) ) ; <nl> - if ( ! input . getArrayData ( ) - > isVectorData ( ) ) { <nl> + if ( ! input . get ( ) - > isVectorData ( ) ) { <nl> return input . values ( ) ; <nl> } <nl> return input ; <nl> mmm a / hphp / runtime / base / type_array . h <nl> ppp b / hphp / runtime / base / type_array . h <nl> class Array : protected SmartPtr < ArrayData > { <nl> <nl> void dump ( ) ; <nl> <nl> - ArrayData * getArrayData ( ) const { <nl> - return m_px ; <nl> - } <nl> - <nl> void setEvalScalar ( ) const ; <nl> <nl> private : <nl> | Remove redundant function in Array | facebook/hhvm | 1c764cabf09f9c695d4e7f238b99480a0e45bc2a | 2013-07-15T22:46:27Z |
mmm a / tensorflow / lite / kernels / internal / optimized / depthwiseconv_3x3_filter_common . h <nl> ppp b / tensorflow / lite / kernels / internal / optimized / depthwiseconv_3x3_filter_common . h <nl> inline DotProduct3x3KernelType CategorizeDotProductKernel ( <nl> const int32 filter_height = filter_shape . Dims ( 1 ) ; <nl> const int32 filter_width = filter_shape . Dims ( 2 ) ; <nl> <nl> - bool supported = <nl> - stride = = params . stride_height & & stride < = 2 & & padding < = 1 & & <nl> - filter_width = = 3 & & filter_height = = 3 & & params . output_shift < = 0 & & <nl> - params . dilation_width_factor = = 1 & & params . dilation_height_factor = = 1 & & <nl> - ( ( ( input_depth % 8 ) = = 0 & & depth_multiplier = = 1 ) | | <nl> - ( input_depth = = 1 & & depth_multiplier > 1 ) ) ; <nl> + bool supported = stride = = params . stride_height & & stride < = 2 & & <nl> + padding < = 1 & & filter_width = = 3 & & filter_height = = 3 & & <nl> + params . dilation_width_factor = = 1 & & <nl> + params . dilation_height_factor = = 1 & & <nl> + ( ( ( input_depth % 8 ) = = 0 & & depth_multiplier = = 1 ) | | <nl> + ( input_depth = = 1 & & depth_multiplier > 1 ) ) ; <nl> <nl> if ( ! supported ) { <nl> return DotProduct3x3KernelType : : kNone ; <nl> inline DotProduct3x3KernelType CategorizeDotProductKernel ( <nl> } <nl> <nl> if ( quantization_type = = QuantizationType : : kPerChannelInt8 ) { <nl> - const int32 output_depth = output_shape . Dims ( 3 ) ; <nl> if ( output_shift_ptr = = nullptr ) { <nl> return DotProduct3x3KernelType : : kNone ; <nl> } <nl> - for ( int i = 0 ; i < output_depth ; + + i ) { <nl> - if ( output_shift_ptr [ i ] > 0 ) { <nl> - return DotProduct3x3KernelType : : kNone ; <nl> - } <nl> - } <nl> + } else if ( params . output_shift > 0 ) { <nl> + return DotProduct3x3KernelType : : kNone ; <nl> } <nl> <nl> if ( params . depth_multiplier = = 1 ) { <nl> mmm a / tensorflow / lite / kernels / internal / optimized / integer_ops / depthwise_conv . h <nl> ppp b / tensorflow / lite / kernels / internal / optimized / integer_ops / depthwise_conv . h <nl> inline void DepthwiseConvWithRounding ( <nl> DotProduct3x3KernelType kernel_type = <nl> optimized_ops : : depthwise_conv : : CategorizeDotProductKernel < <nl> optimized_ops : : depthwise_conv : : QuantizationType : : kPerChannelInt8 > ( <nl> - input_shape , filter_shape , output_shape , params ) ; <nl> + input_shape , filter_shape , output_shape , params , output_shift ) ; <nl> if ( kernel_type ! = DotProduct3x3KernelType : : kNone ) { <nl> ruy : : profiler : : ScopeLabel specialized_label ( <nl> " DepthwiseConvInt8 / 8bit / 3x3XDotProduct " ) ; <nl> + DepthwiseParams params_copy = params ; <nl> + params_copy . output_shift_per_channel = output_shift ; <nl> + params_copy . output_multiplier_per_channel = output_multiplier ; <nl> optimized_ops : : depthwise_conv : : DepthwiseConvDotProduct3x3PerChannel < <nl> DepthwiseConvImplementation : : kUseNeon3x3DotProduct > ( <nl> - params , input_shape , input_data , filter_shape , filter_data , <nl> + params_copy , input_shape , input_data , filter_shape , filter_data , <nl> bias_shape , bias_data , output_shape , output_data , thread_start , <nl> thread_end , thread_dim ) ; <nl> return ; <nl> | Depthwise convolution 3x3 per - channel int8 for dot - product ARM ( 17 ) . | tensorflow/tensorflow | 8aca7a7815307f1369c64be746b7ed206efab240 | 2020-02-24T16:30:37Z |
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> - 5a0361664f33af4303065c98da4b8d8e4efe48b4 <nl> \ No newline at end of file <nl> + 12034db6a7c20a09b3e866ab79a536bfc0208d3f <nl> \ No newline at end of file <nl> mmm a / build / cocos2d_samples . xcodeproj / project . pbxproj . REMOVED . git - id <nl> ppp b / build / cocos2d_samples . xcodeproj / project . pbxproj . REMOVED . git - id <nl> @ @ - 1 + 1 @ @ <nl> - b473303312be3b69891020b5fb470dd382f31284 <nl> \ No newline at end of file <nl> + f441e32e09388d5c434035e100e591cf9a6d29fd <nl> \ No newline at end of file <nl> mmm a / cocos / editor - support / cocostudio / CCActionNode . cpp <nl> ppp b / cocos / editor - support / cocostudio / CCActionNode . cpp <nl> void ActionNode : : initActionNodeFromRoot ( Object * root ) <nl> UIWidget * rootWidget = dynamic_cast < UIWidget * > ( root ) ; <nl> if ( rootWidget ! = NULL ) <nl> { <nl> - UIWidget * widget = UIHelper : : instance ( ) - > seekActionWidgetByActionTag ( rootWidget , getActionTag ( ) ) ; <nl> + UIWidget * widget = UIHelper : : seekActionWidgetByActionTag ( rootWidget , getActionTag ( ) ) ; <nl> if ( widget ! = NULL ) <nl> { <nl> setObject ( widget ) ; <nl> mmm a / cocos / editor - support / cocostudio / CCSGUIReader . cpp <nl> ppp b / cocos / editor - support / cocostudio / CCSGUIReader . cpp <nl> UIWidget * CCSGUIReader : : widgetFromJsonDictionary ( JsonDictionary * data ) <nl> } <nl> else if ( classname & & strcmp ( classname , " Panel " ) = = 0 ) <nl> { <nl> - widget = Layout : : create ( ) ; <nl> + widget = UILayout : : create ( ) ; <nl> setPropsForPanelFromJsonDictionary ( widget , uiOptions ) ; <nl> } <nl> else if ( classname & & strcmp ( classname , " Slider " ) = = 0 ) <nl> UIWidget * CCSGUIReader : : widgetFromJsonDictionary ( JsonDictionary * data ) <nl> } <nl> else if ( classname & & strcmp ( classname , " DragPanel " ) = = 0 ) <nl> { <nl> - widget = UIDragPanel : : create ( ) ; <nl> + widget = UIScrollView : : create ( ) ; <nl> setPropsForDragPanelFromJsonDictionary ( widget , uiOptions ) ; <nl> } <nl> <nl> UIWidget * CCSGUIReader : : widgetFromJsonFile ( const char * fileName ) <nl> const char * file = DICTOOL - > getStringValueFromArray_json ( jsonDict , " textures " , i ) ; <nl> std : : string tp = m_strFilePath ; <nl> tp . append ( file ) ; <nl> - CCUIHELPER - > addSpriteFrame ( tp . c_str ( ) ) ; <nl> + / / CCUIHELPER - > addSpriteFrame ( tp . c_str ( ) ) ; <nl> } <nl> float fileDesignWidth = DICTOOL - > getFloatValue_json ( jsonDict , " designWidth " ) ; <nl> float fileDesignHeight = DICTOOL - > getFloatValue_json ( jsonDict , " designHeight " ) ; <nl> if ( fileDesignWidth < = 0 | | fileDesignHeight < = 0 ) { <nl> printf ( " Read design size error ! \ n " ) ; <nl> Size winSize = Director : : getInstance ( ) - > getWinSize ( ) ; <nl> - CCUIHELPER - > setFileDesignWidth ( winSize . width ) ; <nl> - CCUIHELPER - > setFileDesignHeight ( winSize . height ) ; <nl> + / / CCUIHELPER - > setFileDesignWidth ( winSize . width ) ; <nl> + / / CCUIHELPER - > setFileDesignHeight ( winSize . height ) ; <nl> } <nl> else <nl> { <nl> - CCUIHELPER - > setFileDesignWidth ( fileDesignWidth ) ; <nl> - CCUIHELPER - > setFileDesignHeight ( fileDesignHeight ) ; <nl> + / / CCUIHELPER - > setFileDesignWidth ( fileDesignWidth ) ; <nl> + / / CCUIHELPER - > setFileDesignHeight ( fileDesignHeight ) ; <nl> } <nl> JsonDictionary * widgetTree = DICTOOL - > getSubDictionary_json ( jsonDict , " widgetTree " ) ; <nl> UIWidget * widget = widgetFromJsonDictionary ( widgetTree ) ; <nl> UIWidget * CCSGUIReader : : widgetFromJsonFile ( const char * fileName ) <nl> / * * * * * * * * * * temp * * * * * * * * * * / <nl> if ( widget - > getContentSize ( ) . equals ( Size : : ZERO ) ) <nl> { <nl> - Layout * rootWidget = dynamic_cast < Layout * > ( widget ) ; <nl> + UILayout * rootWidget = dynamic_cast < UILayout * > ( widget ) ; <nl> rootWidget - > setSize ( Size ( fileDesignWidth , fileDesignHeight ) ) ; <nl> } <nl> / * * * * * * * * * * * * * * * * * * * * * * * * / <nl> void CCSGUIReader : : setPropsForLabelFromJsonDictionary ( UIWidget * widget , JsonDictio <nl> setPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> UILabel * label = ( UILabel * ) widget ; <nl> bool touchScaleChangeAble = DICTOOL - > getBooleanValue_json ( options , " touchScaleEnable " ) ; <nl> - label - > setTouchScaleChangeAble ( touchScaleChangeAble ) ; <nl> + label - > setTouchScaleChangeEnabled ( touchScaleChangeAble ) ; <nl> const char * text = DICTOOL - > getStringValue_json ( options , " text " ) ; <nl> label - > setText ( text ) ; <nl> bool fs = DICTOOL - > checkObjectExist_json ( options , " fontSize " ) ; <nl> void CCSGUIReader : : setPropsForLabelAtlasFromJsonDictionary ( UIWidget * widget , JsonD <nl> void CCSGUIReader : : setPropsForContainerWidgetFromJsonDictionary ( UIWidget * widget , JsonDictionary * options ) <nl> { <nl> setPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> - Layout * containerWidget = ( Layout * ) widget ; <nl> + UILayout * containerWidget = ( UILayout * ) widget ; <nl> if ( ! dynamic_cast < UIScrollView * > ( containerWidget ) <nl> - & & ! dynamic_cast < UIListView * > ( containerWidget ) <nl> - & & ! dynamic_cast < UIDragPanel * > ( containerWidget ) ) <nl> + & & ! dynamic_cast < UIListView * > ( containerWidget ) ) <nl> { <nl> containerWidget - > setClippingEnabled ( DICTOOL - > getBooleanValue_json ( options , " clipAble " ) ) ; <nl> } <nl> void CCSGUIReader : : setPropsForPanelFromJsonDictionary ( UIWidget * widget , JsonDictio <nl> if ( m_bOlderVersion ) <nl> { <nl> setPropsForContainerWidgetFromJsonDictionary ( widget , options ) ; <nl> - Layout * panel = ( Layout * ) widget ; <nl> + UILayout * panel = ( UILayout * ) widget ; <nl> bool backGroundScale9Enable = DICTOOL - > getBooleanValue_json ( options , " backGroundScale9Enable " ) ; <nl> panel - > setBackGroundImageScale9Enabled ( backGroundScale9Enable ) ; <nl> int cr = DICTOOL - > getIntValue_json ( options , " bgColorR " ) ; <nl> void CCSGUIReader : : setPropsForPanelFromJsonDictionary ( UIWidget * widget , JsonDictio <nl> else <nl> { <nl> setPropsForContainerWidgetFromJsonDictionary ( widget , options ) ; <nl> - Layout * panel = ( Layout * ) widget ; <nl> + UILayout * panel = ( UILayout * ) widget ; <nl> bool backGroundScale9Enable = DICTOOL - > getBooleanValue_json ( options , " backGroundScale9Enable " ) ; <nl> panel - > setBackGroundImageScale9Enabled ( backGroundScale9Enable ) ; <nl> int cr = DICTOOL - > getIntValue_json ( options , " bgColorR " ) ; <nl> void CCSGUIReader : : setPropsForTextFieldFromJsonDictionary ( UIWidget * widget , JsonDi <nl> / / textField - > setSize ( CCSizeMake ( dw , dh ) ) ; <nl> } <nl> bool maxLengthEnable = DICTOOL - > getBooleanValue_json ( options , " maxLengthEnable " ) ; <nl> - textField - > setMaxLengthEnable ( maxLengthEnable ) ; <nl> + textField - > setMaxLengthEnabled ( maxLengthEnable ) ; <nl> <nl> if ( maxLengthEnable ) <nl> { <nl> void CCSGUIReader : : setPropsForTextFieldFromJsonDictionary ( UIWidget * widget , JsonDi <nl> textField - > setMaxLength ( maxLength ) ; <nl> } <nl> bool passwordEnable = DICTOOL - > getBooleanValue_json ( options , " passwordEnable " ) ; <nl> - textField - > setPasswordEnable ( passwordEnable ) ; <nl> + textField - > setPasswordEnabled ( passwordEnable ) ; <nl> if ( passwordEnable ) <nl> { <nl> textField - > setPasswordStyleText ( DICTOOL - > getStringValue_json ( options , " passwordStyleText " ) ) ; <nl> void CCSGUIReader : : setPropsForDragPanelFromJsonDictionary ( UIWidget * widget , Json <nl> { <nl> setPropsForPanelFromJsonDictionary ( widget , options ) ; <nl> <nl> - UIDragPanel * dragPanel = ( UIDragPanel * ) widget ; <nl> + UIScrollView * dragPanel = ( UIScrollView * ) widget ; <nl> <nl> bool bounceEnable = DICTOOL - > getBooleanValue_json ( options , " bounceEnable " ) ; <nl> - dragPanel - > setBounceEnable ( bounceEnable ) ; <nl> + dragPanel - > setBounceEnabled ( bounceEnable ) ; <nl> <nl> float innerWidth = DICTOOL - > getFloatValue_json ( options , " innerWidth " ) ; <nl> float innerHeight = DICTOOL - > getFloatValue_json ( options , " innerHeight " ) ; <nl> mmm a / cocos / editor - support / cocostudio / CCSSceneReader . cpp <nl> ppp b / cocos / editor - support / cocostudio / CCSSceneReader . cpp <nl> namespace cocostudio { <nl> { <nl> gui : : UILayer * pLayer = gui : : UILayer : : create ( ) ; <nl> pLayer - > scheduleUpdate ( ) ; <nl> - UIWidget * widget = gui : : UIHelper : : instance ( ) - > createWidgetFromJsonFile ( pPath . c_str ( ) ) ; <nl> - pLayer - > addWidget ( widget ) ; <nl> + / / UIWidget * widget = gui : : UIHelper : : instance ( ) - > createWidgetFromJsonFile ( pPath . c_str ( ) ) ; <nl> + / / pLayer - > addWidget ( widget ) ; <nl> ComRender * pRender = ComRender : : create ( pLayer , " GUIComponent " ) ; <nl> if ( pComName ! = NULL ) <nl> { <nl> mmm a / cocos / gui / CocosGUI . h <nl> ppp b / cocos / gui / CocosGUI . h <nl> <nl> <nl> <nl> # include " gui / UIWidget . h " <nl> - # include " gui / Layout . h " <nl> + # include " gui / UILayout . h " <nl> # include " gui / UIRootWidget . h " <nl> # include " gui / UIButton . h " <nl> # include " gui / UICheckBox . h " <nl> <nl> # include " gui / UILabelAtlas . h " <nl> # include " gui / UILoadingBar . h " <nl> # include " gui / UIScrollView . h " <nl> + # include " gui / UIListView . h " <nl> # include " gui / UISlider . h " <nl> # include " gui / UITextField . h " <nl> - # include " gui / UIListView . h " <nl> - # include " gui / UIDragPanel . h " <nl> # include " gui / UILabelBMFont . h " <nl> # include " gui / UIPageView . h " <nl> # include " gui / UIHelper . h " <nl> deleted file mode 100644 <nl> index a9e4f75a3071 . . 000000000000 <nl> mmm a / cocos / gui / Layout . 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 " gui / Layout . h " <nl> - # include " gui / UILayer . h " <nl> - # include " gui / UIHelper . h " <nl> - # include " extensions / GUI / CCControlExtension / CCScale9Sprite . h " <nl> - <nl> - using namespace cocos2d ; <nl> - using namespace cocos2d : : extension ; <nl> - <nl> - namespace gui { <nl> - <nl> - # define DYNAMIC_CAST_CLIPPINGLAYER dynamic_cast < RectClippingNode * > ( _renderer ) <nl> - <nl> - Layout : : Layout ( ) : <nl> - _clippingEnabled ( false ) , <nl> - _backGroundScale9Enabled ( false ) , <nl> - _backGroundImage ( NULL ) , <nl> - _backGroundImageFileName ( " " ) , <nl> - _backGroundImageCapInsets ( Rect : : ZERO ) , <nl> - _colorType ( LAYOUT_COLOR_NONE ) , <nl> - _bgImageTexType ( UI_TEX_TYPE_LOCAL ) , <nl> - _colorRender ( NULL ) , <nl> - _gradientRender ( NULL ) , <nl> - _cColor ( Color3B : : WHITE ) , <nl> - _gStartColor ( Color3B : : WHITE ) , <nl> - _gEndColor ( Color3B : : WHITE ) , <nl> - _alongVector ( Point ( 0 . 0f , - 1 . 0f ) ) , <nl> - _cOpacity ( 255 ) , <nl> - _backGroundImageTextureSize ( Size : : ZERO ) , <nl> - _layoutType ( LAYOUT_ABSOLUTE ) <nl> - { <nl> - _widgetType = WidgetTypeContainer ; <nl> - } <nl> - <nl> - Layout : : ~ Layout ( ) <nl> - { <nl> - } <nl> - <nl> - Layout * Layout : : create ( ) <nl> - { <nl> - Layout * layout = new Layout ( ) ; <nl> - if ( layout & & layout - > init ( ) ) <nl> - { <nl> - layout - > autorelease ( ) ; <nl> - return layout ; <nl> - } <nl> - CC_SAFE_DELETE ( layout ) ; <nl> - return NULL ; <nl> - } <nl> - <nl> - bool Layout : : init ( ) <nl> - { <nl> - _children = CCArray : : create ( ) ; <nl> - _children - > retain ( ) ; <nl> - initRenderer ( ) ; <nl> - _renderer - > retain ( ) ; <nl> - _renderer - > setZOrder ( _widgetZOrder ) ; <nl> - RGBAProtocol * renderRGBA = dynamic_cast < RGBAProtocol * > ( _renderer ) ; <nl> - if ( renderRGBA ) <nl> - { <nl> - renderRGBA - > setCascadeColorEnabled ( false ) ; <nl> - renderRGBA - > setCascadeOpacityEnabled ( false ) ; <nl> - } <nl> - ignoreContentAdaptWithSize ( false ) ; <nl> - setSize ( Size : : ZERO ) ; <nl> - setBright ( true ) ; <nl> - setAnchorPoint ( Point ( 0 , 0 ) ) ; <nl> - _scheduler = Director : : getInstance ( ) - > getScheduler ( ) ; <nl> - CC_SAFE_RETAIN ( _scheduler ) ; <nl> - return true ; <nl> - } <nl> - <nl> - void Layout : : initRenderer ( ) <nl> - { <nl> - _renderer = RectClippingNode : : create ( ) ; <nl> - } <nl> - <nl> - bool Layout : : isClippingEnabled ( ) <nl> - { <nl> - return _clippingEnabled ; <nl> - } <nl> - <nl> - bool Layout : : hitTest ( const Point & pt ) <nl> - { <nl> - Point nsp = _renderer - > convertToNodeSpace ( pt ) ; <nl> - Rect bb = Rect ( 0 . 0f , 0 . 0f , _size . width , _size . height ) ; <nl> - if ( nsp . x > = bb . origin . x & & nsp . x < = bb . origin . x + bb . size . width & & nsp . y > = bb . origin . y & & nsp . y < = bb . origin . y + bb . size . height ) <nl> - { <nl> - return true ; <nl> - } <nl> - return false ; <nl> - } <nl> - <nl> - void Layout : : setClippingEnabled ( bool able ) <nl> - { <nl> - _clippingEnabled = able ; <nl> - DYNAMIC_CAST_CLIPPINGLAYER - > setClippingEnabled ( able ) ; <nl> - } <nl> - <nl> - void Layout : : onSizeChanged ( ) <nl> - { <nl> - DYNAMIC_CAST_CLIPPINGLAYER - > setClippingSize ( _size ) ; <nl> - doLayout ( ) ; <nl> - if ( _backGroundImage ) <nl> - { <nl> - _backGroundImage - > setPosition ( Point ( _size . width / 2 . 0f , _size . height / 2 . 0f ) ) ; <nl> - if ( _backGroundScale9Enabled ) <nl> - { <nl> - dynamic_cast < Scale9Sprite * > ( _backGroundImage ) - > setPreferredSize ( _size ) ; <nl> - } <nl> - } <nl> - if ( _colorRender ) <nl> - { <nl> - _colorRender - > setContentSize ( _size ) ; <nl> - } <nl> - if ( _gradientRender ) <nl> - { <nl> - _gradientRender - > setContentSize ( _size ) ; <nl> - } <nl> - } <nl> - <nl> - void Layout : : setBackGroundImageScale9Enabled ( bool able ) <nl> - { <nl> - if ( _backGroundScale9Enabled = = able ) <nl> - { <nl> - return ; <nl> - } <nl> - _renderer - > removeChild ( _backGroundImage , true ) ; <nl> - _backGroundImage = NULL ; <nl> - _backGroundScale9Enabled = able ; <nl> - if ( _backGroundScale9Enabled ) <nl> - { <nl> - _backGroundImage = Scale9Sprite : : create ( ) ; <nl> - _renderer - > addChild ( _backGroundImage ) ; <nl> - } <nl> - else <nl> - { <nl> - _backGroundImage = Sprite : : create ( ) ; <nl> - _renderer - > addChild ( _backGroundImage ) ; <nl> - } <nl> - _backGroundImage - > setZOrder ( - 1 ) ; <nl> - setBackGroundImage ( _backGroundImageFileName . c_str ( ) , _bgImageTexType ) ; <nl> - setBackGroundImageCapInsets ( _backGroundImageCapInsets ) ; <nl> - } <nl> - <nl> - void Layout : : setBackGroundImage ( const char * fileName , TextureResType texType ) <nl> - { <nl> - if ( ! fileName | | strcmp ( fileName , " " ) = = 0 ) <nl> - { <nl> - return ; <nl> - } <nl> - if ( _backGroundImage = = NULL ) <nl> - { <nl> - addBackGroundImage ( ) ; <nl> - } <nl> - _backGroundImageFileName = fileName ; <nl> - _bgImageTexType = texType ; <nl> - if ( _backGroundScale9Enabled ) <nl> - { <nl> - switch ( _bgImageTexType ) <nl> - { <nl> - case UI_TEX_TYPE_LOCAL : <nl> - dynamic_cast < Scale9Sprite * > ( _backGroundImage ) - > initWithFile ( fileName ) ; <nl> - break ; <nl> - case UI_TEX_TYPE_PLIST : <nl> - dynamic_cast < Scale9Sprite * > ( _backGroundImage ) - > initWithSpriteFrameName ( fileName ) ; <nl> - break ; <nl> - default : <nl> - break ; <nl> - } <nl> - dynamic_cast < Scale9Sprite * > ( _backGroundImage ) - > setPreferredSize ( _size ) ; <nl> - } <nl> - else <nl> - { <nl> - switch ( _bgImageTexType ) <nl> - { <nl> - case UI_TEX_TYPE_LOCAL : <nl> - dynamic_cast < Sprite * > ( _backGroundImage ) - > initWithFile ( fileName ) ; <nl> - break ; <nl> - case UI_TEX_TYPE_PLIST : <nl> - dynamic_cast < Sprite * > ( _backGroundImage ) - > initWithSpriteFrameName ( fileName ) ; <nl> - break ; <nl> - default : <nl> - break ; <nl> - } <nl> - } <nl> - if ( _backGroundScale9Enabled ) <nl> - { <nl> - dynamic_cast < Scale9Sprite * > ( _backGroundImage ) - > setColor ( getColor ( ) ) ; <nl> - dynamic_cast < Scale9Sprite * > ( _backGroundImage ) - > setOpacity ( getOpacity ( ) ) ; <nl> - } <nl> - else <nl> - { <nl> - dynamic_cast < Sprite * > ( _backGroundImage ) - > setColor ( getColor ( ) ) ; <nl> - dynamic_cast < Sprite * > ( _backGroundImage ) - > setOpacity ( getOpacity ( ) ) ; <nl> - } <nl> - _backGroundImageTextureSize = _backGroundImage - > getContentSize ( ) ; <nl> - _backGroundImage - > setPosition ( Point ( _size . width / 2 . 0f , _size . height / 2 . 0f ) ) ; <nl> - } <nl> - <nl> - void Layout : : setBackGroundImageCapInsets ( const Rect & capInsets ) <nl> - { <nl> - _backGroundImageCapInsets = capInsets ; <nl> - if ( _backGroundScale9Enabled ) <nl> - { <nl> - dynamic_cast < Scale9Sprite * > ( _backGroundImage ) - > setCapInsets ( capInsets ) ; <nl> - } <nl> - } <nl> - <nl> - void Layout : : addBackGroundImage ( ) <nl> - { <nl> - if ( _backGroundScale9Enabled ) <nl> - { <nl> - _backGroundImage = Scale9Sprite : : create ( ) ; <nl> - _backGroundImage - > setZOrder ( - 1 ) ; <nl> - _renderer - > addChild ( _backGroundImage ) ; <nl> - dynamic_cast < Scale9Sprite * > ( _backGroundImage ) - > setPreferredSize ( _size ) ; <nl> - } <nl> - else <nl> - { <nl> - _backGroundImage = CCSprite : : create ( ) ; <nl> - _backGroundImage - > setZOrder ( - 1 ) ; <nl> - _renderer - > addChild ( _backGroundImage ) ; <nl> - } <nl> - _backGroundImage - > setPosition ( Point ( _size . width / 2 . 0f , _size . height / 2 . 0f ) ) ; <nl> - } <nl> - <nl> - void Layout : : removeBackGroundImage ( ) <nl> - { <nl> - if ( ! _backGroundImage ) <nl> - { <nl> - return ; <nl> - } <nl> - _renderer - > removeChild ( _backGroundImage , true ) ; <nl> - _backGroundImage = NULL ; <nl> - _backGroundImageFileName = " " ; <nl> - _backGroundImageTextureSize = Size : : ZERO ; <nl> - } <nl> - <nl> - void Layout : : setBackGroundColorType ( LayoutBackGroundColorType type ) <nl> - { <nl> - if ( _colorType = = type ) <nl> - { <nl> - return ; <nl> - } <nl> - switch ( _colorType ) <nl> - { <nl> - case LAYOUT_COLOR_NONE : <nl> - if ( _colorRender ) <nl> - { <nl> - _renderer - > removeChild ( _colorRender , true ) ; <nl> - _colorRender = NULL ; <nl> - } <nl> - if ( _gradientRender ) <nl> - { <nl> - _renderer - > removeChild ( _gradientRender , true ) ; <nl> - _gradientRender = NULL ; <nl> - } <nl> - break ; <nl> - case LAYOUT_COLOR_SOLID : <nl> - if ( _colorRender ) <nl> - { <nl> - _renderer - > removeChild ( _colorRender , true ) ; <nl> - _colorRender = NULL ; <nl> - } <nl> - break ; <nl> - case LAYOUT_COLOR_GRADIENT : <nl> - if ( _gradientRender ) <nl> - { <nl> - _renderer - > removeChild ( _gradientRender , true ) ; <nl> - _gradientRender = NULL ; <nl> - } <nl> - break ; <nl> - default : <nl> - break ; <nl> - } <nl> - _colorType = type ; <nl> - switch ( _colorType ) <nl> - { <nl> - case LAYOUT_COLOR_NONE : <nl> - break ; <nl> - case LAYOUT_COLOR_SOLID : <nl> - _colorRender = CCLayerColor : : create ( ) ; <nl> - _colorRender - > setContentSize ( _size ) ; <nl> - _colorRender - > setOpacity ( _cOpacity ) ; <nl> - _colorRender - > setColor ( _cColor ) ; <nl> - _renderer - > addChild ( _colorRender , - 2 ) ; <nl> - break ; <nl> - case LAYOUT_COLOR_GRADIENT : <nl> - _gradientRender = CCLayerGradient : : create ( ) ; <nl> - _gradientRender - > setContentSize ( _size ) ; <nl> - _gradientRender - > setOpacity ( _cOpacity ) ; <nl> - _gradientRender - > setStartColor ( _gStartColor ) ; <nl> - _gradientRender - > setEndColor ( _gEndColor ) ; <nl> - _gradientRender - > setVector ( _alongVector ) ; <nl> - _renderer - > addChild ( _gradientRender , - 2 ) ; <nl> - break ; <nl> - default : <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - void Layout : : setBackGroundColor ( const Color3B & color ) <nl> - { <nl> - _cColor = color ; <nl> - if ( _colorRender ) <nl> - { <nl> - _colorRender - > setColor ( color ) ; <nl> - } <nl> - } <nl> - <nl> - void Layout : : setBackGroundColor ( const Color3B & startColor , const Color3B & endColor ) <nl> - { <nl> - _gStartColor = startColor ; <nl> - if ( _gradientRender ) <nl> - { <nl> - _gradientRender - > setStartColor ( startColor ) ; <nl> - } <nl> - _gEndColor = endColor ; <nl> - if ( _gradientRender ) <nl> - { <nl> - _gradientRender - > setEndColor ( endColor ) ; <nl> - } <nl> - } <nl> - <nl> - void Layout : : setBackGroundColorOpacity ( int opacity ) <nl> - { <nl> - _cOpacity = opacity ; <nl> - switch ( _colorType ) <nl> - { <nl> - case LAYOUT_COLOR_NONE : <nl> - break ; <nl> - case LAYOUT_COLOR_SOLID : <nl> - _colorRender - > setOpacity ( opacity ) ; <nl> - break ; <nl> - case LAYOUT_COLOR_GRADIENT : <nl> - _gradientRender - > setOpacity ( opacity ) ; <nl> - break ; <nl> - default : <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - void Layout : : setBackGroundColorVector ( const Point & vector ) <nl> - { <nl> - _alongVector = vector ; <nl> - if ( _gradientRender ) <nl> - { <nl> - _gradientRender - > setVector ( vector ) ; <nl> - } <nl> - } <nl> - <nl> - void Layout : : setColor ( const Color3B & color ) <nl> - { <nl> - UIWidget : : setColor ( color ) ; <nl> - if ( _backGroundImage ) <nl> - { <nl> - RGBAProtocol * rgbap = dynamic_cast < RGBAProtocol * > ( _backGroundImage ) ; <nl> - if ( rgbap ) <nl> - { <nl> - rgbap - > setColor ( color ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - void Layout : : setOpacity ( int opacity ) <nl> - { <nl> - UIWidget : : setOpacity ( opacity ) ; <nl> - if ( _backGroundImage ) <nl> - { <nl> - RGBAProtocol * rgbap = dynamic_cast < RGBAProtocol * > ( _backGroundImage ) ; <nl> - if ( rgbap ) <nl> - { <nl> - rgbap - > setOpacity ( opacity ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - const Size & Layout : : getBackGroundImageTextureSize ( ) const <nl> - { <nl> - return _backGroundImageTextureSize ; <nl> - } <nl> - <nl> - const Size & Layout : : getContentSize ( ) const <nl> - { <nl> - return _renderer - > getContentSize ( ) ; <nl> - } <nl> - <nl> - void Layout : : setLayoutType ( LayoutType type ) <nl> - { <nl> - _layoutType = type ; <nl> - } <nl> - <nl> - LayoutType Layout : : getLayoutType ( ) const <nl> - { <nl> - return _layoutType ; <nl> - } <nl> - <nl> - void Layout : : doLayout ( ) <nl> - { <nl> - switch ( _layoutType ) <nl> - { <nl> - case LAYOUT_ABSOLUTE : <nl> - break ; <nl> - case LAYOUT_LINEAR_VERTICAL : <nl> - { <nl> - ccArray * layoutChildrenArray = getChildren ( ) - > data ; <nl> - int length = layoutChildrenArray - > num ; <nl> - Size layoutSize = getSize ( ) ; <nl> - float topBoundary = layoutSize . height ; <nl> - for ( int i = 0 ; i < length ; + + i ) <nl> - { <nl> - UIWidget * child = dynamic_cast < UIWidget * > ( layoutChildrenArray - > arr [ i ] ) ; <nl> - LinearLayoutParameter * layoutParameter = dynamic_cast < LinearLayoutParameter * > ( child - > getLayoutParameter ( ) ) ; <nl> - <nl> - if ( layoutParameter ) <nl> - { <nl> - WidgetType childType = child - > getWidgetType ( ) ; <nl> - UILinearGravity childGravity = layoutParameter - > getGravity ( ) ; <nl> - Point ap = child - > getAnchorPoint ( ) ; <nl> - Size cs = child - > getSize ( ) ; <nl> - float finalPosX = childType = = WidgetTypeWidget ? ap . x * cs . width : 0 . 0f ; <nl> - float finalPosY = childType = = WidgetTypeWidget ? topBoundary - ( ( 1 . 0f - ap . y ) * cs . height ) : topBoundary - cs . height ; <nl> - switch ( childGravity ) <nl> - { <nl> - case LINEAR_GRAVITY_NONE : <nl> - case LINEAR_GRAVITY_LEFT : <nl> - break ; <nl> - case LINEAR_GRAVITY_RIGHT : <nl> - finalPosX = childType = = WidgetTypeWidget ? layoutSize . width - ( ( 1 . 0f - ap . x ) * cs . width ) : layoutSize . width - cs . width ; <nl> - break ; <nl> - case LINEAR_GRAVITY_CENTER_HORIZONTAL : <nl> - finalPosX = childType = = WidgetTypeWidget ? layoutSize . width / 2 . 0f - cs . width * ( 0 . 5f - ap . x ) : ( layoutSize . width - cs . width ) * 0 . 5f ; <nl> - break ; <nl> - default : <nl> - break ; <nl> - } <nl> - UIMargin mg = layoutParameter - > getMargin ( ) ; <nl> - finalPosX + = mg . left ; <nl> - finalPosY - = mg . top ; <nl> - child - > setPosition ( Point ( finalPosX , finalPosY ) ) ; <nl> - topBoundary = child - > getBottomInParent ( ) - mg . bottom ; <nl> - } <nl> - } <nl> - break ; <nl> - } <nl> - case LAYOUT_LINEAR_HORIZONTAL : <nl> - { <nl> - ccArray * layoutChildrenArray = getChildren ( ) - > data ; <nl> - int length = layoutChildrenArray - > num ; <nl> - Size layoutSize = getSize ( ) ; <nl> - float leftBoundary = 0 . 0f ; <nl> - for ( int i = 0 ; i < length ; + + i ) <nl> - { <nl> - UIWidget * child = dynamic_cast < UIWidget * > ( layoutChildrenArray - > arr [ i ] ) ; <nl> - LinearLayoutParameter * layoutParameter = dynamic_cast < LinearLayoutParameter * > ( child - > getLayoutParameter ( ) ) ; <nl> - <nl> - if ( layoutParameter ) <nl> - { <nl> - WidgetType childType = child - > getWidgetType ( ) ; <nl> - UILinearGravity childGravity = layoutParameter - > getGravity ( ) ; <nl> - Point ap = child - > getAnchorPoint ( ) ; <nl> - Size cs = child - > getSize ( ) ; <nl> - float finalPosX = childType = = WidgetTypeWidget ? leftBoundary + ( ap . x * cs . width ) : leftBoundary ; <nl> - float finalPosY = childType = = WidgetTypeWidget ? layoutSize . height - ( 1 . 0f - ap . y ) * cs . height : layoutSize . height - cs . height ; <nl> - switch ( childGravity ) <nl> - { <nl> - case LINEAR_GRAVITY_NONE : <nl> - case LINEAR_GRAVITY_TOP : <nl> - break ; <nl> - case LINEAR_GRAVITY_BOTTOM : <nl> - finalPosY = childType = = WidgetTypeWidget ? ap . y * cs . height : 0 . 0f ; <nl> - break ; <nl> - case LINEAR_GRAVITY_CENTER_VERTICAL : <nl> - finalPosY = childType = = WidgetTypeWidget ? layoutSize . height / 2 . 0f - cs . height * ( 0 . 5f - ap . y ) : ( layoutSize . height - cs . height ) * 0 . 5f ; <nl> - break ; <nl> - default : <nl> - break ; <nl> - } <nl> - UIMargin mg = layoutParameter - > getMargin ( ) ; <nl> - finalPosX + = mg . left ; <nl> - finalPosY - = mg . top ; <nl> - child - > setPosition ( Point ( finalPosX , finalPosY ) ) ; <nl> - leftBoundary = child - > getRightInParent ( ) + mg . right ; <nl> - } <nl> - } <nl> - break ; <nl> - } <nl> - case LAYOUT_RELATIVE : <nl> - { <nl> - ccArray * layoutChildrenArray = getChildren ( ) - > data ; <nl> - int length = layoutChildrenArray - > num ; <nl> - Size layoutSize = getSize ( ) ; <nl> - for ( int i = 0 ; i < length ; i + + ) <nl> - { <nl> - UIWidget * child = dynamic_cast < UIWidget * > ( layoutChildrenArray - > arr [ i ] ) ; <nl> - WidgetType childType = child - > getWidgetType ( ) ; <nl> - Point ap = child - > getAnchorPoint ( ) ; <nl> - Size cs = child - > getSize ( ) ; <nl> - RelativeLayoutParameter * layoutParameter = dynamic_cast < RelativeLayoutParameter * > ( child - > getLayoutParameter ( ) ) ; <nl> - if ( layoutParameter ) <nl> - { <nl> - float finalPosX = childType = = WidgetTypeWidget ? ap . x * cs . width : 0 . 0f ; <nl> - float finalPosY = childType = = WidgetTypeWidget ? layoutSize . height - ( ( 1 . 0f - ap . y ) * cs . height ) : layoutSize . height - cs . height ; <nl> - UIRelativeAlign align = layoutParameter - > getAlign ( ) ; <nl> - const char * relativeName = layoutParameter - > getRelativeToWidgetName ( ) ; <nl> - UIWidget * relativeWidget = NULL ; <nl> - if ( relativeName & & strcmp ( relativeName , " " ) ) <nl> - { <nl> - relativeWidget = CCUIHELPER - > seekWidgetByRelativeName ( this , relativeName ) ; <nl> - } <nl> - switch ( align ) <nl> - { <nl> - case RELATIVE_ALIGN_NONE : <nl> - break ; <nl> - case RELATIVE_ALIGN_PARENT_LEFT : <nl> - break ; <nl> - case RELATIVE_ALIGN_PARENT_TOP : <nl> - break ; <nl> - case RELATIVE_ALIGN_PARENT_RIGHT : <nl> - finalPosX = childType = = WidgetTypeWidget ? layoutSize . width - ( ( 1 . 0f - ap . x ) * cs . width ) : layoutSize . width - cs . width ; <nl> - break ; <nl> - case RELATIVE_ALIGN_PARENT_BOTTOM : <nl> - finalPosY = childType = = WidgetTypeWidget ? ap . y * cs . height : 0 . 0f ; <nl> - break ; <nl> - case RELATIVE_CENTER_IN_PARENT : <nl> - finalPosX = childType = = WidgetTypeWidget ? layoutSize . width * 0 . 5f - cs . width * ( 0 . 5f - ap . x ) : ( layoutSize . width - cs . width ) * 0 . 5f ; <nl> - finalPosY = childType = = WidgetTypeWidget ? layoutSize . height * 0 . 5f - cs . height * ( 0 . 5f - ap . y ) : ( layoutSize . height - cs . height ) * 0 . 5f ; <nl> - break ; <nl> - case RELATIVE_CENTER_HORIZONTAL : <nl> - finalPosX = childType = = WidgetTypeWidget ? layoutSize . width * 0 . 5f - cs . width * ( 0 . 5f - ap . x ) : ( layoutSize . width - cs . width ) * 0 . 5f ; <nl> - break ; <nl> - case RELATIVE_CENTER_VERTICAL : <nl> - finalPosY = childType = = WidgetTypeWidget ? layoutSize . height * 0 . 5f - cs . height * ( 0 . 5f - ap . y ) : ( layoutSize . height - cs . height ) * 0 . 5f ; <nl> - break ; <nl> - case RELATIVE_LOCATION_LEFT_OF_TOPALIGN : <nl> - if ( relativeWidget ) <nl> - { <nl> - float locationTop = relativeWidget - > getTopInParent ( ) ; <nl> - float locationRight = relativeWidget - > getLeftInParent ( ) ; <nl> - finalPosY = childType = = WidgetTypeWidget ? locationTop - ap . y * cs . height : locationTop - cs . height ; <nl> - finalPosX = childType = = WidgetTypeWidget ? locationRight - ( 1 . 0f - ap . x ) * cs . width : locationRight - cs . width ; <nl> - } <nl> - break ; <nl> - case RELATIVE_LOCATION_LEFT_OF_CENTER : <nl> - break ; <nl> - case RELATIVE_LOCATION_LEFT_OF_BOTTOMALIGN : <nl> - if ( relativeWidget ) <nl> - { <nl> - float locationRight = relativeWidget - > getLeftInParent ( ) ; <nl> - float locationBottom = relativeWidget - > getBottomInParent ( ) ; <nl> - finalPosY = childType = = WidgetTypeWidget ? locationBottom + ap . y * cs . height : locationBottom ; <nl> - finalPosX = childType = = WidgetTypeWidget ? locationRight - ( 1 . 0f - ap . x ) * cs . width : locationRight - cs . width ; <nl> - } <nl> - break ; <nl> - case RELATIVE_LOCATION_RIGHT_OF_TOPALIGN : <nl> - if ( relativeWidget ) <nl> - { <nl> - float locationTop = relativeWidget - > getTopInParent ( ) ; <nl> - float locationLeft = relativeWidget - > getRightInParent ( ) ; <nl> - finalPosY = childType = = WidgetTypeWidget ? locationTop - ap . y * cs . height : locationTop - cs . height ; <nl> - finalPosX = childType = = WidgetTypeWidget ? locationLeft + ap . x * cs . width : locationLeft ; <nl> - } <nl> - break ; <nl> - case RELATIVE_LOCATION_RIGHT_OF_CENTER : <nl> - break ; <nl> - case RELATIVE_LOCATION_RIGHT_OF_BOTTOMALIGN : <nl> - if ( relativeWidget ) <nl> - { <nl> - float locationLeft = relativeWidget - > getRightInParent ( ) ; <nl> - float locationBottom = relativeWidget - > getBottomInParent ( ) ; <nl> - finalPosY = childType = = WidgetTypeWidget ? locationBottom + ap . y * cs . height : locationBottom ; <nl> - finalPosX = childType = = WidgetTypeWidget ? locationLeft + ap . x * cs . width : locationLeft ; <nl> - } <nl> - break ; <nl> - case RELATIVE_LOCATION_ABOVE_LEFTALIGN : <nl> - if ( relativeWidget ) <nl> - { <nl> - float locationBottom = relativeWidget - > getTopInParent ( ) ; <nl> - float locationLeft = relativeWidget - > getLeftInParent ( ) ; <nl> - finalPosY = childType = = WidgetTypeWidget ? locationBottom + ap . y * cs . height : locationBottom ; <nl> - finalPosX = childType = = WidgetTypeWidget ? locationLeft + ap . x * cs . width : locationLeft ; <nl> - } <nl> - break ; <nl> - case RELATIVE_LOCATION_ABOVE_CENTER : <nl> - break ; <nl> - case RELATIVE_LOCATION_ABOVE_RIGHTALIGN : <nl> - if ( relativeWidget ) <nl> - { <nl> - float locationBottom = relativeWidget - > getTopInParent ( ) ; <nl> - float locationRight = relativeWidget - > getRightInParent ( ) ; <nl> - finalPosY = childType = = WidgetTypeWidget ? locationBottom + ap . y * cs . height : locationBottom ; <nl> - finalPosX = childType = = WidgetTypeWidget ? locationRight - ( 1 . 0f - ap . x ) * cs . width : locationRight - cs . width ; <nl> - } <nl> - break ; <nl> - case RELATIVE_LOCATION_BELOW_LEFTALIGN : <nl> - if ( relativeWidget ) <nl> - { <nl> - float locationTop = relativeWidget - > getBottomInParent ( ) ; <nl> - float locationLeft = relativeWidget - > getLeftInParent ( ) ; <nl> - finalPosY = childType = = WidgetTypeWidget ? locationTop - ( 1 . 0f - ap . y ) * cs . height : locationTop - cs . height ; <nl> - finalPosX = childType = = WidgetTypeWidget ? locationLeft + ap . x * cs . width : locationLeft ; <nl> - } <nl> - break ; <nl> - case RELATIVE_LOCATION_BELOW_CENTER : <nl> - break ; <nl> - case RELATIVE_LOCATION_BELOW_RIGHTALIGN : <nl> - if ( relativeWidget ) <nl> - { <nl> - float locationTop = relativeWidget - > getBottomInParent ( ) ; <nl> - float locationRight = relativeWidget - > getRightInParent ( ) ; <nl> - finalPosY = childType = = WidgetTypeWidget ? locationTop - ( 1 . 0f - ap . y ) * cs . height : locationTop - cs . height ; <nl> - finalPosX = childType = = WidgetTypeWidget ? locationRight - ( 1 . 0f - ap . x ) * cs . width : locationRight - cs . width ; <nl> - } <nl> - break ; <nl> - default : <nl> - break ; <nl> - } <nl> - UIMargin relativeWidgetMargin ; <nl> - UIMargin mg ; <nl> - if ( relativeWidget ) <nl> - { <nl> - relativeWidgetMargin = relativeWidget - > getLayoutParameter ( ) - > getMargin ( ) ; <nl> - mg = child - > getLayoutParameter ( ) - > getMargin ( ) ; <nl> - } <nl> - / / handle margin <nl> - switch ( align ) <nl> - { <nl> - case RELATIVE_LOCATION_ABOVE_LEFTALIGN : <nl> - case RELATIVE_LOCATION_ABOVE_RIGHTALIGN : <nl> - case RELATIVE_LOCATION_ABOVE_CENTER : <nl> - finalPosY + = relativeWidgetMargin . top ; <nl> - finalPosY + = mg . bottom ; <nl> - break ; <nl> - case RELATIVE_LOCATION_BELOW_LEFTALIGN : <nl> - case RELATIVE_LOCATION_BELOW_RIGHTALIGN : <nl> - case RELATIVE_LOCATION_BELOW_CENTER : <nl> - finalPosY - = relativeWidgetMargin . bottom ; <nl> - finalPosY - = mg . top ; <nl> - break ; <nl> - case RELATIVE_LOCATION_LEFT_OF_TOPALIGN : <nl> - case RELATIVE_LOCATION_LEFT_OF_BOTTOMALIGN : <nl> - case RELATIVE_LOCATION_LEFT_OF_CENTER : <nl> - finalPosX - = relativeWidgetMargin . left ; <nl> - finalPosX - = mg . right ; <nl> - break ; <nl> - case RELATIVE_LOCATION_RIGHT_OF_TOPALIGN : <nl> - case RELATIVE_LOCATION_RIGHT_OF_BOTTOMALIGN : <nl> - case RELATIVE_LOCATION_RIGHT_OF_CENTER : <nl> - finalPosX + = relativeWidgetMargin . right ; <nl> - finalPosX + = mg . left ; <nl> - break ; <nl> - default : <nl> - break ; <nl> - } <nl> - child - > setPosition ( Point ( finalPosX , finalPosY ) ) ; <nl> - } <nl> - } <nl> - break ; <nl> - } <nl> - default : <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - const char * Layout : : getDescription ( ) const <nl> - { <nl> - return " Layout " ; <nl> - } <nl> - <nl> - RectClippingNode : : RectClippingNode ( ) : <nl> - m_pInnerStencil ( NULL ) , <nl> - _enabled ( true ) , <nl> - _clippingSize ( Size ( 50 . 0f , 50 . 0f ) ) , <nl> - _clippingEnabled ( false ) <nl> - { <nl> - <nl> - } <nl> - <nl> - RectClippingNode : : ~ RectClippingNode ( ) <nl> - { <nl> - <nl> - } <nl> - <nl> - RectClippingNode * RectClippingNode : : create ( ) <nl> - { <nl> - RectClippingNode * pRet = new RectClippingNode ( ) ; <nl> - if ( pRet & & pRet - > init ( ) ) <nl> - { <nl> - pRet - > autorelease ( ) ; <nl> - } <nl> - else <nl> - { <nl> - CC_SAFE_DELETE ( pRet ) ; <nl> - } <nl> - <nl> - return pRet ; <nl> - } <nl> - <nl> - bool RectClippingNode : : init ( ) <nl> - { <nl> - m_pInnerStencil = CCDrawNode : : create ( ) ; <nl> - rect [ 0 ] = Point ( 0 , 0 ) ; <nl> - rect [ 1 ] = Point ( _clippingSize . width , 0 ) ; <nl> - rect [ 2 ] = Point ( _clippingSize . width , _clippingSize . height ) ; <nl> - rect [ 3 ] = Point ( 0 , _clippingSize . height ) ; <nl> - <nl> - Color4F green ( 0 , 1 , 0 , 1 ) ; <nl> - m_pInnerStencil - > drawPolygon ( rect , 4 , green , 0 , green ) ; <nl> - if ( CCClippingNode : : init ( m_pInnerStencil ) ) <nl> - { <nl> - return true ; <nl> - } <nl> - return false ; <nl> - } <nl> - <nl> - <nl> - void RectClippingNode : : setClippingSize ( const Size & size ) <nl> - { <nl> - setContentSize ( size ) ; <nl> - _clippingSize = size ; <nl> - rect [ 0 ] = Point ( 0 , 0 ) ; <nl> - rect [ 1 ] = Point ( _clippingSize . width , 0 ) ; <nl> - rect [ 2 ] = Point ( _clippingSize . width , _clippingSize . height ) ; <nl> - rect [ 3 ] = Point ( 0 , _clippingSize . height ) ; <nl> - Color4F green ( 0 , 1 , 0 , 1 ) ; <nl> - m_pInnerStencil - > clear ( ) ; <nl> - m_pInnerStencil - > drawPolygon ( rect , 4 , green , 0 , green ) ; <nl> - } <nl> - <nl> - void RectClippingNode : : setClippingEnabled ( bool enabled ) <nl> - { <nl> - _clippingEnabled = enabled ; <nl> - } <nl> - <nl> - void RectClippingNode : : visit ( ) <nl> - { <nl> - if ( ! _enabled ) <nl> - { <nl> - return ; <nl> - } <nl> - if ( _clippingEnabled ) <nl> - { <nl> - CCClippingNode : : visit ( ) ; <nl> - } <nl> - else <nl> - { <nl> - CCNode : : visit ( ) ; <nl> - } <nl> - } <nl> - <nl> - void RectClippingNode : : setEnabled ( bool enabled ) <nl> - { <nl> - _enabled = enabled ; <nl> - } <nl> - <nl> - bool RectClippingNode : : isEnabled ( ) const <nl> - { <nl> - return _enabled ; <nl> - } <nl> - <nl> - } <nl> mmm a / cocos / gui / UIButton . cpp <nl> ppp b / cocos / gui / UIButton . cpp <nl> <nl> # include " gui / UIButton . h " <nl> # include " extensions / GUI / CCControlExtension / CCScale9Sprite . h " <nl> <nl> - using namespace cocos2d ; <nl> - using namespace cocos2d : : extension ; <nl> - <nl> namespace gui { <nl> <nl> # define NORMALRENDERERZ ( 0 ) <nl> _clickedFileName ( " " ) , <nl> _disabledFileName ( " " ) , <nl> _prevIgnoreSize ( true ) , <nl> _scale9Enabled ( false ) , <nl> - _capInsetsNormal ( Rect : : ZERO ) , <nl> - _capInsetsPressed ( Rect : : ZERO ) , <nl> - _capInsetsDisabled ( Rect : : ZERO ) , <nl> + _capInsetsNormal ( cocos2d : : Rect : : ZERO ) , <nl> + _capInsetsPressed ( cocos2d : : Rect : : ZERO ) , <nl> + _capInsetsDisabled ( cocos2d : : Rect : : ZERO ) , <nl> _normalTexType ( UI_TEX_TYPE_LOCAL ) , <nl> _pressedTexType ( UI_TEX_TYPE_LOCAL ) , <nl> _disabledTexType ( UI_TEX_TYPE_LOCAL ) , <nl> _normalTextureSize ( _size ) , <nl> _pressedTextureSize ( _size ) , <nl> _disabledTextureSize ( _size ) , <nl> _pressedActionEnabled ( false ) , <nl> - _titleColor ( Color3B : : WHITE ) <nl> + _titleColor ( cocos2d : : Color3B : : WHITE ) <nl> { <nl> <nl> } <nl> bool UIButton : : init ( ) <nl> void UIButton : : initRenderer ( ) <nl> { <nl> UIWidget : : initRenderer ( ) ; <nl> - _buttonNormalRenderer = Sprite : : create ( ) ; <nl> - _buttonClickedRenderer = Sprite : : create ( ) ; <nl> - _buttonDisableRenderer = Sprite : : create ( ) ; <nl> - _titleRenderer = LabelTTF : : create ( ) ; <nl> + _buttonNormalRenderer = cocos2d : : Sprite : : create ( ) ; <nl> + _buttonClickedRenderer = cocos2d : : Sprite : : create ( ) ; <nl> + _buttonDisableRenderer = cocos2d : : Sprite : : create ( ) ; <nl> + _titleRenderer = cocos2d : : LabelTTF : : create ( ) ; <nl> _renderer - > addChild ( _buttonNormalRenderer , NORMALRENDERERZ ) ; <nl> _renderer - > addChild ( _buttonClickedRenderer , PRESSEDRENDERERZ ) ; <nl> _renderer - > addChild ( _buttonDisableRenderer , DISABLEDRENDERERZ ) ; <nl> void UIButton : : setScale9Enabled ( bool able ) <nl> _buttonDisableRenderer = NULL ; <nl> if ( _scale9Enabled ) <nl> { <nl> - _buttonNormalRenderer = Scale9Sprite : : create ( ) ; <nl> - _buttonClickedRenderer = Scale9Sprite : : create ( ) ; <nl> - _buttonDisableRenderer = Scale9Sprite : : create ( ) ; <nl> + _buttonNormalRenderer = cocos2d : : extension : : Scale9Sprite : : create ( ) ; <nl> + _buttonClickedRenderer = cocos2d : : extension : : Scale9Sprite : : create ( ) ; <nl> + _buttonDisableRenderer = cocos2d : : extension : : Scale9Sprite : : create ( ) ; <nl> } <nl> else <nl> { <nl> - _buttonNormalRenderer = CCSprite : : create ( ) ; <nl> - _buttonClickedRenderer = CCSprite : : create ( ) ; <nl> - _buttonDisableRenderer = CCSprite : : create ( ) ; <nl> + _buttonNormalRenderer = cocos2d : : Sprite : : create ( ) ; <nl> + _buttonClickedRenderer = cocos2d : : Sprite : : create ( ) ; <nl> + _buttonDisableRenderer = cocos2d : : Sprite : : create ( ) ; <nl> } <nl> <nl> loadTextureNormal ( _normalFileName . c_str ( ) , _normalTexType ) ; <nl> void UIButton : : loadTextureNormal ( const char * normal , TextureResType texType ) <nl> switch ( _normalTexType ) <nl> { <nl> case UI_TEX_TYPE_LOCAL : <nl> - dynamic_cast < Scale9Sprite * > ( _buttonNormalRenderer ) - > initWithFile ( normal ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonNormalRenderer ) - > initWithFile ( normal ) ; <nl> break ; <nl> case UI_TEX_TYPE_PLIST : <nl> - dynamic_cast < Scale9Sprite * > ( _buttonNormalRenderer ) - > initWithSpriteFrameName ( normal ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonNormalRenderer ) - > initWithSpriteFrameName ( normal ) ; <nl> break ; <nl> default : <nl> break ; <nl> } <nl> - dynamic_cast < Scale9Sprite * > ( _buttonNormalRenderer ) - > setColor ( getColor ( ) ) ; <nl> - dynamic_cast < Scale9Sprite * > ( _buttonNormalRenderer ) - > setOpacity ( getOpacity ( ) ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonNormalRenderer ) - > setColor ( getColor ( ) ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonNormalRenderer ) - > setOpacity ( getOpacity ( ) ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonNormalRenderer ) - > setCapInsets ( _capInsetsNormal ) ; <nl> } <nl> else <nl> { <nl> switch ( _normalTexType ) <nl> { <nl> case UI_TEX_TYPE_LOCAL : <nl> - dynamic_cast < Sprite * > ( _buttonNormalRenderer ) - > initWithFile ( normal ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _buttonNormalRenderer ) - > initWithFile ( normal ) ; <nl> break ; <nl> case UI_TEX_TYPE_PLIST : <nl> - dynamic_cast < Sprite * > ( _buttonNormalRenderer ) - > initWithSpriteFrameName ( normal ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _buttonNormalRenderer ) - > initWithSpriteFrameName ( normal ) ; <nl> break ; <nl> default : <nl> break ; <nl> } <nl> - dynamic_cast < Sprite * > ( _buttonNormalRenderer ) - > setColor ( getColor ( ) ) ; <nl> - dynamic_cast < Sprite * > ( _buttonNormalRenderer ) - > setOpacity ( getOpacity ( ) ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _buttonNormalRenderer ) - > setColor ( getColor ( ) ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _buttonNormalRenderer ) - > setOpacity ( getOpacity ( ) ) ; <nl> } <nl> _normalTextureSize = _buttonNormalRenderer - > getContentSize ( ) ; <nl> updateAnchorPoint ( ) ; <nl> void UIButton : : loadTexturePressed ( const char * selected , TextureResType texType ) <nl> switch ( _pressedTexType ) <nl> { <nl> case UI_TEX_TYPE_LOCAL : <nl> - dynamic_cast < Scale9Sprite * > ( _buttonClickedRenderer ) - > initWithFile ( selected ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonClickedRenderer ) - > initWithFile ( selected ) ; <nl> break ; <nl> case UI_TEX_TYPE_PLIST : <nl> - dynamic_cast < Scale9Sprite * > ( _buttonClickedRenderer ) - > initWithSpriteFrameName ( selected ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonClickedRenderer ) - > initWithSpriteFrameName ( selected ) ; <nl> break ; <nl> default : <nl> break ; <nl> } <nl> - dynamic_cast < Scale9Sprite * > ( _buttonClickedRenderer ) - > setColor ( getColor ( ) ) ; <nl> - dynamic_cast < Scale9Sprite * > ( _buttonClickedRenderer ) - > setOpacity ( getOpacity ( ) ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonClickedRenderer ) - > setColor ( getColor ( ) ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonClickedRenderer ) - > setOpacity ( getOpacity ( ) ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonClickedRenderer ) - > setCapInsets ( _capInsetsPressed ) ; <nl> } <nl> else <nl> { <nl> switch ( _pressedTexType ) <nl> { <nl> case UI_TEX_TYPE_LOCAL : <nl> - dynamic_cast < Sprite * > ( _buttonClickedRenderer ) - > initWithFile ( selected ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _buttonClickedRenderer ) - > initWithFile ( selected ) ; <nl> break ; <nl> case UI_TEX_TYPE_PLIST : <nl> - dynamic_cast < Sprite * > ( _buttonClickedRenderer ) - > initWithSpriteFrameName ( selected ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _buttonClickedRenderer ) - > initWithSpriteFrameName ( selected ) ; <nl> break ; <nl> default : <nl> break ; <nl> } <nl> - dynamic_cast < Sprite * > ( _buttonClickedRenderer ) - > setColor ( getColor ( ) ) ; <nl> - dynamic_cast < Sprite * > ( _buttonClickedRenderer ) - > setOpacity ( getOpacity ( ) ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _buttonClickedRenderer ) - > setColor ( getColor ( ) ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _buttonClickedRenderer ) - > setOpacity ( getOpacity ( ) ) ; <nl> } <nl> _pressedTextureSize = _buttonClickedRenderer - > getContentSize ( ) ; <nl> updateAnchorPoint ( ) ; <nl> void UIButton : : loadTextureDisabled ( const char * disabled , TextureResType texType ) <nl> switch ( _disabledTexType ) <nl> { <nl> case UI_TEX_TYPE_LOCAL : <nl> - dynamic_cast < Scale9Sprite * > ( _buttonDisableRenderer ) - > initWithFile ( disabled ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonDisableRenderer ) - > initWithFile ( disabled ) ; <nl> break ; <nl> case UI_TEX_TYPE_PLIST : <nl> - dynamic_cast < Scale9Sprite * > ( _buttonDisableRenderer ) - > initWithSpriteFrameName ( disabled ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonDisableRenderer ) - > initWithSpriteFrameName ( disabled ) ; <nl> break ; <nl> default : <nl> break ; <nl> } <nl> - dynamic_cast < Scale9Sprite * > ( _buttonDisableRenderer ) - > setColor ( getColor ( ) ) ; <nl> - dynamic_cast < Scale9Sprite * > ( _buttonDisableRenderer ) - > setOpacity ( getOpacity ( ) ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonDisableRenderer ) - > setColor ( getColor ( ) ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonDisableRenderer ) - > setOpacity ( getOpacity ( ) ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonDisableRenderer ) - > setCapInsets ( _capInsetsDisabled ) ; <nl> } <nl> else <nl> { <nl> switch ( _disabledTexType ) <nl> { <nl> case UI_TEX_TYPE_LOCAL : <nl> - dynamic_cast < Sprite * > ( _buttonDisableRenderer ) - > initWithFile ( disabled ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _buttonDisableRenderer ) - > initWithFile ( disabled ) ; <nl> break ; <nl> case UI_TEX_TYPE_PLIST : <nl> - dynamic_cast < Sprite * > ( _buttonDisableRenderer ) - > initWithSpriteFrameName ( disabled ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _buttonDisableRenderer ) - > initWithSpriteFrameName ( disabled ) ; <nl> break ; <nl> default : <nl> break ; <nl> } <nl> - dynamic_cast < Sprite * > ( _buttonDisableRenderer ) - > setColor ( getColor ( ) ) ; <nl> - dynamic_cast < Sprite * > ( _buttonDisableRenderer ) - > setOpacity ( getOpacity ( ) ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _buttonDisableRenderer ) - > setColor ( getColor ( ) ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _buttonDisableRenderer ) - > setOpacity ( getOpacity ( ) ) ; <nl> } <nl> _disabledTextureSize = _buttonDisableRenderer - > getContentSize ( ) ; <nl> updateAnchorPoint ( ) ; <nl> disabledTextureScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - void UIButton : : setCapInsets ( const Rect & capInsets ) <nl> + void UIButton : : setCapInsets ( const cocos2d : : Rect & capInsets ) <nl> { <nl> setCapInsetsNormalRenderer ( capInsets ) ; <nl> setCapInsetsPressedRenderer ( capInsets ) ; <nl> setCapInsetsDisabledRenderer ( capInsets ) ; <nl> } <nl> <nl> - void UIButton : : setCapInsetsNormalRenderer ( const Rect & capInsets ) <nl> + void UIButton : : setCapInsetsNormalRenderer ( const cocos2d : : Rect & capInsets ) <nl> { <nl> _capInsetsNormal = capInsets ; <nl> if ( ! _scale9Enabled ) <nl> { <nl> return ; <nl> } <nl> - dynamic_cast < Scale9Sprite * > ( _buttonNormalRenderer ) - > setCapInsets ( capInsets ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonNormalRenderer ) - > setCapInsets ( capInsets ) ; <nl> } <nl> <nl> - void UIButton : : setCapInsetsPressedRenderer ( const Rect & capInsets ) <nl> + void UIButton : : setCapInsetsPressedRenderer ( const cocos2d : : Rect & capInsets ) <nl> { <nl> _capInsetsPressed = capInsets ; <nl> if ( ! _scale9Enabled ) <nl> { <nl> return ; <nl> } <nl> - dynamic_cast < Scale9Sprite * > ( _buttonClickedRenderer ) - > setCapInsets ( capInsets ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonClickedRenderer ) - > setCapInsets ( capInsets ) ; <nl> } <nl> <nl> - void UIButton : : setCapInsetsDisabledRenderer ( const Rect & capInsets ) <nl> + void UIButton : : setCapInsetsDisabledRenderer ( const cocos2d : : Rect & capInsets ) <nl> { <nl> _capInsetsDisabled = capInsets ; <nl> if ( ! _scale9Enabled ) <nl> { <nl> return ; <nl> } <nl> - dynamic_cast < Scale9Sprite * > ( _buttonDisableRenderer ) - > setCapInsets ( capInsets ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonDisableRenderer ) - > setCapInsets ( capInsets ) ; <nl> } <nl> <nl> void UIButton : : onPressStateChangedToNormal ( ) <nl> void UIButton : : onPressStateChangedToNormal ( ) <nl> _buttonNormalRenderer - > stopAllActions ( ) ; <nl> _buttonClickedRenderer - > stopAllActions ( ) ; <nl> _buttonDisableRenderer - > stopAllActions ( ) ; <nl> - Action * zoomAction = ScaleTo : : create ( 0 . 05f , 1 . 0f ) ; <nl> - Action * zoomAction1 = ScaleTo : : create ( 0 . 05f , 1 . 0f ) ; <nl> - Action * zoomAction2 = ScaleTo : : create ( 0 . 05f , 1 . 0f ) ; <nl> + cocos2d : : Action * zoomAction = cocos2d : : ScaleTo : : create ( 0 . 05f , 1 . 0f ) ; <nl> + cocos2d : : Action * zoomAction1 = cocos2d : : ScaleTo : : create ( 0 . 05f , 1 . 0f ) ; <nl> + cocos2d : : Action * zoomAction2 = cocos2d : : ScaleTo : : create ( 0 . 05f , 1 . 0f ) ; <nl> _buttonNormalRenderer - > runAction ( zoomAction ) ; <nl> _buttonClickedRenderer - > runAction ( zoomAction1 ) ; <nl> _buttonDisableRenderer - > runAction ( zoomAction2 ) ; <nl> void UIButton : : onPressStateChangedToPressed ( ) <nl> _buttonNormalRenderer - > stopAllActions ( ) ; <nl> _buttonClickedRenderer - > stopAllActions ( ) ; <nl> _buttonDisableRenderer - > stopAllActions ( ) ; <nl> - Action * zoomAction = ScaleTo : : create ( 0 . 05f , 1 . 1f ) ; <nl> - Action * zoomAction1 = ScaleTo : : create ( 0 . 05f , 1 . 1f ) ; <nl> - Action * zoomAction2 = ScaleTo : : create ( 0 . 05f , 1 . 1f ) ; <nl> + cocos2d : : Action * zoomAction = cocos2d : : ScaleTo : : create ( 0 . 05f , 1 . 1f ) ; <nl> + cocos2d : : Action * zoomAction1 = cocos2d : : ScaleTo : : create ( 0 . 05f , 1 . 1f ) ; <nl> + cocos2d : : Action * zoomAction2 = cocos2d : : ScaleTo : : create ( 0 . 05f , 1 . 1f ) ; <nl> _buttonNormalRenderer - > runAction ( zoomAction ) ; <nl> _buttonClickedRenderer - > runAction ( zoomAction1 ) ; <nl> _buttonDisableRenderer - > runAction ( zoomAction2 ) ; <nl> void UIButton : : setFlipX ( bool flipX ) <nl> { <nl> return ; <nl> } <nl> - dynamic_cast < Sprite * > ( _buttonNormalRenderer ) - > setFlippedX ( flipX ) ; <nl> - dynamic_cast < Sprite * > ( _buttonClickedRenderer ) - > setFlippedX ( flipX ) ; <nl> - dynamic_cast < Sprite * > ( _buttonDisableRenderer ) - > setFlippedX ( flipX ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _buttonNormalRenderer ) - > setFlippedX ( flipX ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _buttonClickedRenderer ) - > setFlippedX ( flipX ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _buttonDisableRenderer ) - > setFlippedX ( flipX ) ; <nl> } <nl> <nl> void UIButton : : setFlipY ( bool flipY ) <nl> void UIButton : : setFlipY ( bool flipY ) <nl> { <nl> return ; <nl> } <nl> - dynamic_cast < Sprite * > ( _buttonNormalRenderer ) - > setFlippedY ( flipY ) ; <nl> - dynamic_cast < Sprite * > ( _buttonClickedRenderer ) - > setFlippedY ( flipY ) ; <nl> - dynamic_cast < Sprite * > ( _buttonDisableRenderer ) - > setFlippedY ( flipY ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _buttonNormalRenderer ) - > setFlippedY ( flipY ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _buttonClickedRenderer ) - > setFlippedY ( flipY ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _buttonDisableRenderer ) - > setFlippedY ( flipY ) ; <nl> } <nl> <nl> bool UIButton : : isFlipX ( ) <nl> bool UIButton : : isFlipX ( ) <nl> { <nl> return false ; <nl> } <nl> - return dynamic_cast < Sprite * > ( _buttonNormalRenderer ) - > isFlippedX ( ) ; <nl> + return dynamic_cast < cocos2d : : Sprite * > ( _buttonNormalRenderer ) - > isFlippedX ( ) ; <nl> } <nl> <nl> bool UIButton : : isFlipY ( ) <nl> bool UIButton : : isFlipY ( ) <nl> { <nl> return false ; <nl> } <nl> - return dynamic_cast < Sprite * > ( _buttonNormalRenderer ) - > isFlippedY ( ) ; <nl> + return dynamic_cast < cocos2d : : Sprite * > ( _buttonNormalRenderer ) - > isFlippedY ( ) ; <nl> } <nl> <nl> - void UIButton : : setAnchorPoint ( const Point & pt ) <nl> + void UIButton : : setAnchorPoint ( const cocos2d : : Point & pt ) <nl> { <nl> UIWidget : : setAnchorPoint ( pt ) ; <nl> _buttonNormalRenderer - > setAnchorPoint ( pt ) ; <nl> _buttonClickedRenderer - > setAnchorPoint ( pt ) ; <nl> _buttonDisableRenderer - > setAnchorPoint ( pt ) ; <nl> - _titleRenderer - > setPosition ( Point ( _size . width * ( 0 . 5f - _anchorPoint . x ) , _size . height * ( 0 . 5f - _anchorPoint . y ) ) ) ; <nl> + _titleRenderer - > setPosition ( cocos2d : : Point ( _size . width * ( 0 . 5f - _anchorPoint . x ) , _size . height * ( 0 . 5f - _anchorPoint . y ) ) ) ; <nl> } <nl> <nl> void UIButton : : onSizeChanged ( ) <nl> void UIButton : : onSizeChanged ( ) <nl> disabledTextureScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - const Size & UIButton : : getContentSize ( ) const <nl> + const cocos2d : : Size & UIButton : : getContentSize ( ) const <nl> { <nl> return _normalTextureSize ; <nl> } <nl> <nl> - Node * UIButton : : getVirtualRenderer ( ) <nl> + cocos2d : : Node * UIButton : : getVirtualRenderer ( ) <nl> { <nl> if ( _bright ) <nl> { <nl> void UIButton : : normalTextureScaleChangedWithSize ( ) <nl> { <nl> if ( _scale9Enabled ) <nl> { <nl> - dynamic_cast < Scale9Sprite * > ( _buttonNormalRenderer ) - > setPreferredSize ( _size ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonNormalRenderer ) - > setPreferredSize ( _size ) ; <nl> } <nl> else <nl> { <nl> - Size textureSize = _normalTextureSize ; <nl> + cocos2d : : Size textureSize = _normalTextureSize ; <nl> if ( textureSize . width < = 0 . 0f | | textureSize . height < = 0 . 0f ) <nl> { <nl> _buttonNormalRenderer - > setScale ( 1 . 0f ) ; <nl> void UIButton : : pressedTextureScaleChangedWithSize ( ) <nl> { <nl> if ( _scale9Enabled ) <nl> { <nl> - dynamic_cast < Scale9Sprite * > ( _buttonClickedRenderer ) - > setPreferredSize ( _size ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonClickedRenderer ) - > setPreferredSize ( _size ) ; <nl> } <nl> else <nl> { <nl> - Size textureSize = _pressedTextureSize ; <nl> + cocos2d : : Size textureSize = _pressedTextureSize ; <nl> if ( textureSize . width < = 0 . 0f | | textureSize . height < = 0 . 0f ) <nl> { <nl> _buttonClickedRenderer - > setScale ( 1 . 0f ) ; <nl> void UIButton : : disabledTextureScaleChangedWithSize ( ) <nl> { <nl> if ( _scale9Enabled ) <nl> { <nl> - dynamic_cast < Scale9Sprite * > ( _buttonDisableRenderer ) - > setPreferredSize ( _size ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonDisableRenderer ) - > setPreferredSize ( _size ) ; <nl> } <nl> else <nl> { <nl> - Size textureSize = _disabledTextureSize ; <nl> + cocos2d : : Size textureSize = _disabledTextureSize ; <nl> if ( textureSize . width < = 0 . 0f | | textureSize . height < = 0 . 0f ) <nl> { <nl> _buttonDisableRenderer - > setScale ( 1 . 0f ) ; <nl> const char * UIButton : : getTitleText ( ) const <nl> return _titleRenderer - > getString ( ) ; <nl> } <nl> <nl> - void UIButton : : setTitleColor ( const Color3B & color ) <nl> + void UIButton : : setTitleColor ( const cocos2d : : Color3B & color ) <nl> { <nl> _titleColor = color ; <nl> _titleRenderer - > setColor ( color ) ; <nl> } <nl> <nl> - const Color3B & UIButton : : getTitleColor ( ) const <nl> + const cocos2d : : Color3B & UIButton : : getTitleColor ( ) const <nl> { <nl> return _titleRenderer - > getColor ( ) ; <nl> } <nl> const char * UIButton : : getTitleFontName ( ) const <nl> return _titleRenderer - > getFontName ( ) ; <nl> } <nl> <nl> - void UIButton : : setColor ( const Color3B & color ) <nl> + void UIButton : : setColor ( const cocos2d : : Color3B & color ) <nl> { <nl> UIWidget : : setColor ( color ) ; <nl> setTitleColor ( _titleColor ) ; <nl> const char * UIButton : : getDescription ( ) const <nl> return " Button " ; <nl> } <nl> <nl> + UIWidget * UIButton : : createCloneInstance ( ) <nl> + { <nl> + return UIButton : : create ( ) ; <nl> + } <nl> + <nl> + void UIButton : : copySpecialProperties ( UIWidget * widget ) <nl> + { <nl> + UIButton * button = dynamic_cast < UIButton * > ( widget ) ; <nl> + if ( button ) <nl> + { <nl> + _prevIgnoreSize = button - > _prevIgnoreSize ; <nl> + setScale9Enabled ( button - > _scale9Enabled ) ; <nl> + loadTextureNormal ( button - > _normalFileName . c_str ( ) , button - > _normalTexType ) ; <nl> + loadTexturePressed ( button - > _clickedFileName . c_str ( ) , button - > _pressedTexType ) ; <nl> + loadTextureDisabled ( button - > _disabledFileName . c_str ( ) , button - > _disabledTexType ) ; <nl> + setCapInsetsNormalRenderer ( button - > _capInsetsNormal ) ; <nl> + setCapInsetsPressedRenderer ( button - > _capInsetsPressed ) ; <nl> + setCapInsetsDisabledRenderer ( button - > _capInsetsDisabled ) ; <nl> + setTitleText ( button - > getTitleText ( ) ) ; <nl> + setTitleFontName ( button - > getTitleFontName ( ) ) ; <nl> + setTitleFontSize ( button - > getTitleFontSize ( ) ) ; <nl> + setTitleColor ( button - > getTitleColor ( ) ) ; <nl> + setPressedActionEnabled ( button - > _pressedActionEnabled ) ; <nl> + } <nl> + } <nl> + <nl> } <nl> \ No newline at end of file <nl> mmm a / cocos / gui / UIButton . h <nl> ppp b / cocos / gui / UIButton . h <nl> <nl> <nl> # include " gui / UIWidget . h " <nl> <nl> - namespace gui { <nl> + namespace gui { <nl> <nl> + / * * <nl> + * @ js NA <nl> + * @ lua NA <nl> + * / <nl> class UIButton : public UIWidget <nl> { <nl> public : <nl> class UIButton : public UIWidget <nl> * / <nl> virtual void setColor ( const cocos2d : : Color3B & color ) ; <nl> <nl> + / * * <nl> + * Returns the " class name " of widget . <nl> + * / <nl> + virtual const char * getDescription ( ) const ; <nl> + <nl> void setTitleText ( const char * text ) ; <nl> const char * getTitleText ( ) const ; <nl> void setTitleColor ( const cocos2d : : Color3B & color ) ; <nl> class UIButton : public UIWidget <nl> float getTitleFontSize ( ) const ; <nl> void setTitleFontName ( const char * fontName ) ; <nl> const char * getTitleFontName ( ) const ; <nl> - <nl> - / * * <nl> - * Returns the " class name " of widget . <nl> - * / <nl> - virtual const char * getDescription ( ) const ; <nl> + <nl> protected : <nl> virtual bool init ( ) ; <nl> virtual void initRenderer ( ) ; <nl> class UIButton : public UIWidget <nl> void normalTextureScaleChangedWithSize ( ) ; <nl> void pressedTextureScaleChangedWithSize ( ) ; <nl> void disabledTextureScaleChangedWithSize ( ) ; <nl> + virtual UIWidget * createCloneInstance ( ) ; <nl> + virtual void copySpecialProperties ( UIWidget * model ) ; <nl> protected : <nl> cocos2d : : Node * _buttonNormalRenderer ; <nl> cocos2d : : Node * _buttonClickedRenderer ; <nl> mmm a / cocos / gui / UICheckBox . cpp <nl> ppp b / cocos / gui / UICheckBox . cpp <nl> <nl> <nl> # include " gui / UICheckBox . h " <nl> <nl> - using namespace cocos2d ; <nl> - <nl> namespace gui { <nl> <nl> + <nl> UICheckBox : : UICheckBox ( ) : <nl> _backGroundBoxRenderer ( NULL ) , <nl> _backGroundSelectedBoxRenderer ( NULL ) , <nl> _backGroundTexType ( UI_TEX_TYPE_LOCAL ) , <nl> _backGroundSelectedTexType ( UI_TEX_TYPE_LOCAL ) , <nl> _frontCrossTexType ( UI_TEX_TYPE_LOCAL ) , <nl> _backGroundDisabledTexType ( UI_TEX_TYPE_LOCAL ) , <nl> - _frontCrossDisabledTexType ( UI_TEX_TYPE_LOCAL ) <nl> + _frontCrossDisabledTexType ( UI_TEX_TYPE_LOCAL ) , <nl> + _backGroundFileName ( " " ) , <nl> + _backGroundSelectedFileName ( " " ) , <nl> + _frontCrossFileName ( " " ) , <nl> + _backGroundDisabledFileName ( " " ) , <nl> + _frontCrossDisabledFileName ( " " ) <nl> { <nl> } <nl> <nl> bool UICheckBox : : init ( ) <nl> void UICheckBox : : initRenderer ( ) <nl> { <nl> UIWidget : : initRenderer ( ) ; <nl> - _backGroundBoxRenderer = Sprite : : create ( ) ; <nl> - _backGroundSelectedBoxRenderer = Sprite : : create ( ) ; <nl> - _frontCrossRenderer = Sprite : : create ( ) ; <nl> - _backGroundBoxDisabledRenderer = Sprite : : create ( ) ; <nl> - _frontCrossDisabledRenderer = Sprite : : create ( ) ; <nl> + _backGroundBoxRenderer = cocos2d : : Sprite : : create ( ) ; <nl> + _backGroundSelectedBoxRenderer = cocos2d : : Sprite : : create ( ) ; <nl> + _frontCrossRenderer = cocos2d : : Sprite : : create ( ) ; <nl> + _backGroundBoxDisabledRenderer = cocos2d : : Sprite : : create ( ) ; <nl> + _frontCrossDisabledRenderer = cocos2d : : Sprite : : create ( ) ; <nl> _renderer - > addChild ( _backGroundBoxRenderer ) ; <nl> _renderer - > addChild ( _backGroundSelectedBoxRenderer ) ; <nl> _renderer - > addChild ( _frontCrossRenderer ) ; <nl> void UICheckBox : : loadTextureBackGround ( const char * backGround , TextureResType tex <nl> { <nl> return ; <nl> } <nl> + _backGroundFileName = backGround ; <nl> _backGroundTexType = texType ; <nl> switch ( _backGroundTexType ) <nl> { <nl> void UICheckBox : : loadTextureBackGroundSelected ( const char * backGroundSelected , Te <nl> { <nl> return ; <nl> } <nl> + _backGroundSelectedFileName = backGroundSelected ; <nl> _backGroundSelectedTexType = texType ; <nl> switch ( _backGroundSelectedTexType ) <nl> { <nl> void UICheckBox : : loadTextureFrontCross ( const char * cross , TextureResType texType ) <nl> { <nl> return ; <nl> } <nl> + _frontCrossFileName = cross ; <nl> _frontCrossTexType = texType ; <nl> switch ( _frontCrossTexType ) <nl> { <nl> void UICheckBox : : loadTextureBackGroundDisabled ( const char * backGroundDisabled , Te <nl> { <nl> return ; <nl> } <nl> + _backGroundDisabledFileName = backGroundDisabled ; <nl> _backGroundDisabledTexType = texType ; <nl> switch ( _backGroundDisabledTexType ) <nl> { <nl> void UICheckBox : : loadTextureFrontCrossDisabled ( const char * frontCrossDisabled , Te <nl> { <nl> return ; <nl> } <nl> + _frontCrossDisabledFileName = frontCrossDisabled ; <nl> _frontCrossDisabledTexType = texType ; <nl> switch ( _frontCrossDisabledTexType ) <nl> { <nl> void UICheckBox : : loadTextureFrontCrossDisabled ( const char * frontCrossDisabled , Te <nl> frontCrossDisabledTextureScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - void UICheckBox : : onTouchEnded ( const Point & touchPoint ) <nl> + void UICheckBox : : onTouchEnded ( const cocos2d : : Point & touchPoint ) <nl> { <nl> if ( _focus ) <nl> { <nl> void UICheckBox : : unSelectedEvent ( ) <nl> } <nl> } <nl> <nl> - void UICheckBox : : addEventListener ( Object * target , SEL_SelectedStateEvent selector ) <nl> + void UICheckBox : : addEventListener ( cocos2d : : Object * target , SEL_SelectedStateEvent selector ) <nl> { <nl> _selectedStateEventListener = target ; <nl> _selectedStateEventSelector = selector ; <nl> bool UICheckBox : : isFlipY ( ) <nl> return _backGroundBoxRenderer - > isFlippedY ( ) ; <nl> } <nl> <nl> - void UICheckBox : : setAnchorPoint ( const Point & pt ) <nl> + void UICheckBox : : setAnchorPoint ( const cocos2d : : Point & pt ) <nl> { <nl> UIWidget : : setAnchorPoint ( pt ) ; <nl> _backGroundBoxRenderer - > setAnchorPoint ( pt ) ; <nl> void UICheckBox : : onSizeChanged ( ) <nl> frontCrossDisabledTextureScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - const Size & UICheckBox : : getContentSize ( ) const <nl> + const cocos2d : : Size & UICheckBox : : getContentSize ( ) const <nl> { <nl> return _backGroundBoxRenderer - > getContentSize ( ) ; <nl> } <nl> <nl> - Node * UICheckBox : : getVirtualRenderer ( ) <nl> + cocos2d : : Node * UICheckBox : : getVirtualRenderer ( ) <nl> { <nl> return _backGroundBoxRenderer ; <nl> } <nl> void UICheckBox : : backGroundTextureScaleChangedWithSize ( ) <nl> } <nl> else <nl> { <nl> - Size textureSize = _backGroundBoxRenderer - > getContentSize ( ) ; <nl> + cocos2d : : Size textureSize = _backGroundBoxRenderer - > getContentSize ( ) ; <nl> if ( textureSize . width < = 0 . 0f | | textureSize . height < = 0 . 0f ) <nl> { <nl> _backGroundBoxRenderer - > setScale ( 1 . 0f ) ; <nl> void UICheckBox : : backGroundSelectedTextureScaleChangedWithSize ( ) <nl> } <nl> else <nl> { <nl> - Size textureSize = _backGroundSelectedBoxRenderer - > getContentSize ( ) ; <nl> + cocos2d : : Size textureSize = _backGroundSelectedBoxRenderer - > getContentSize ( ) ; <nl> if ( textureSize . width < = 0 . 0f | | textureSize . height < = 0 . 0f ) <nl> { <nl> _backGroundSelectedBoxRenderer - > setScale ( 1 . 0f ) ; <nl> void UICheckBox : : frontCrossTextureScaleChangedWithSize ( ) <nl> } <nl> else <nl> { <nl> - Size textureSize = _frontCrossRenderer - > getContentSize ( ) ; <nl> + cocos2d : : Size textureSize = _frontCrossRenderer - > getContentSize ( ) ; <nl> if ( textureSize . width < = 0 . 0f | | textureSize . height < = 0 . 0f ) <nl> { <nl> _frontCrossRenderer - > setScale ( 1 . 0f ) ; <nl> void UICheckBox : : backGroundDisabledTextureScaleChangedWithSize ( ) <nl> } <nl> else <nl> { <nl> - Size textureSize = _backGroundBoxDisabledRenderer - > getContentSize ( ) ; <nl> + cocos2d : : Size textureSize = _backGroundBoxDisabledRenderer - > getContentSize ( ) ; <nl> if ( textureSize . width < = 0 . 0f | | textureSize . height < = 0 . 0f ) <nl> { <nl> _backGroundBoxDisabledRenderer - > setScale ( 1 . 0f ) ; <nl> void UICheckBox : : frontCrossDisabledTextureScaleChangedWithSize ( ) <nl> } <nl> else <nl> { <nl> - Size textureSize = _frontCrossDisabledRenderer - > getContentSize ( ) ; <nl> + cocos2d : : Size textureSize = _frontCrossDisabledRenderer - > getContentSize ( ) ; <nl> if ( textureSize . width < = 0 . 0f | | textureSize . height < = 0 . 0f ) <nl> { <nl> _frontCrossDisabledRenderer - > setScale ( 1 . 0f ) ; <nl> const char * UICheckBox : : getDescription ( ) const <nl> return " CheckBox " ; <nl> } <nl> <nl> + UIWidget * UICheckBox : : createCloneInstance ( ) <nl> + { <nl> + return UICheckBox : : create ( ) ; <nl> + } <nl> + <nl> + void UICheckBox : : copySpecialProperties ( UIWidget * widget ) <nl> + { <nl> + UICheckBox * checkBox = dynamic_cast < UICheckBox * > ( widget ) ; <nl> + if ( checkBox ) <nl> + { <nl> + loadTextureBackGround ( checkBox - > _backGroundFileName . c_str ( ) , checkBox - > _backGroundTexType ) ; <nl> + loadTextureBackGroundSelected ( checkBox - > _backGroundSelectedFileName . c_str ( ) , checkBox - > _backGroundSelectedTexType ) ; <nl> + loadTextureFrontCross ( checkBox - > _frontCrossFileName . c_str ( ) , checkBox - > _frontCrossTexType ) ; <nl> + loadTextureBackGroundDisabled ( checkBox - > _backGroundDisabledFileName . c_str ( ) , checkBox - > _backGroundDisabledTexType ) ; <nl> + loadTextureFrontCrossDisabled ( checkBox - > _frontCrossDisabledFileName . c_str ( ) , checkBox - > _frontCrossDisabledTexType ) ; <nl> + setSelectedState ( checkBox - > _isSelected ) ; <nl> + } <nl> + } <nl> + <nl> } <nl> \ No newline at end of file <nl> mmm a / cocos / gui / UICheckBox . h <nl> ppp b / cocos / gui / UICheckBox . h <nl> typedef enum <nl> CHECKBOX_STATE_EVENT_UNSELECTED <nl> } CheckBoxEventType ; <nl> <nl> - typedef void ( cocos2d : : CCObject : : * SEL_SelectedStateEvent ) ( cocos2d : : Object * , CheckBoxEventType ) ; <nl> + typedef void ( cocos2d : : Object : : * SEL_SelectedStateEvent ) ( cocos2d : : Object * , CheckBoxEventType ) ; <nl> # define checkboxselectedeventselector ( _SELECTOR ) ( SEL_SelectedStateEvent ) ( & _SELECTOR ) <nl> <nl> + / * * <nl> + * @ js NA <nl> + * @ lua NA <nl> + * / <nl> class UICheckBox : public UIWidget <nl> { <nl> public : <nl> class UICheckBox : public UIWidget <nl> <nl> / / override " getVirtualRenderer " method of widget . <nl> virtual cocos2d : : Node * getVirtualRenderer ( ) ; <nl> - <nl> + <nl> / * * <nl> * Returns the " class name " of widget . <nl> * / <nl> virtual const char * getDescription ( ) const ; <nl> + <nl> protected : <nl> virtual bool init ( ) ; <nl> virtual void initRenderer ( ) ; <nl> class UICheckBox : public UIWidget <nl> void frontCrossTextureScaleChangedWithSize ( ) ; <nl> void backGroundDisabledTextureScaleChangedWithSize ( ) ; <nl> void frontCrossDisabledTextureScaleChangedWithSize ( ) ; <nl> + virtual UIWidget * createCloneInstance ( ) ; <nl> + virtual void copySpecialProperties ( UIWidget * model ) ; <nl> protected : <nl> cocos2d : : Sprite * _backGroundBoxRenderer ; <nl> cocos2d : : Sprite * _backGroundSelectedBoxRenderer ; <nl> class UICheckBox : public UIWidget <nl> TextureResType _frontCrossTexType ; <nl> TextureResType _backGroundDisabledTexType ; <nl> TextureResType _frontCrossDisabledTexType ; <nl> + <nl> + std : : string _backGroundFileName ; <nl> + std : : string _backGroundSelectedFileName ; <nl> + std : : string _frontCrossFileName ; <nl> + std : : string _backGroundDisabledFileName ; <nl> + std : : string _frontCrossDisabledFileName ; <nl> } ; <nl> <nl> } <nl> deleted file mode 100644 <nl> index 7c717c063675 . . 000000000000 <nl> mmm a / cocos / gui / UIDragPanel . 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 " gui / UIDragPanel . h " <nl> - # include " gui / UILayer . h " <nl> - <nl> - using namespace cocos2d ; <nl> - <nl> - namespace gui { <nl> - <nl> - UIDragPanel : : UIDragPanel ( ) <nl> - : _innerContainer ( NULL ) <nl> - , _touchPressed ( false ) <nl> - , _touchMoved ( false ) <nl> - , _touchReleased ( false ) <nl> - , _touchCanceld ( false ) <nl> - , _touchStartNodeSpace ( Point : : ZERO ) <nl> - , _touchStartWorldSpace ( Point : : ZERO ) <nl> - , _touchEndWorldSpace ( Point : : ZERO ) <nl> - , _slidTime ( 0 . 0f ) <nl> - , _moveType ( DRAGPANEL_MOVE_TYPE_AUTOMOVE ) <nl> - , _autoMoveDuration ( 0 . 5f ) <nl> - , _autoMoveEaseRate ( 2 . 0f ) <nl> - , _eventLister ( NULL ) <nl> - , _eventSelector ( NULL ) <nl> - , _berthDirection ( DRAGPANEL_BERTH_DIR_NONE ) <nl> - , _bounceEnable ( false ) <nl> - , _bounceDirection ( DRAGPANEL_BOUNCE_DIR_NONE ) <nl> - , _bounceDuration ( 0 . 5f ) <nl> - , _bounceEaseRate ( 2 . 0f ) <nl> - , _runningAction ( false ) <nl> - , _actionType ( 0 ) <nl> - , _actionWidget ( NULL ) <nl> - , _duration ( 0 . 0f ) <nl> - , _elapsed ( 0 . 0f ) <nl> - , _firstTick ( false ) <nl> - , _positionDelta ( Point : : ZERO ) <nl> - , _startPosition ( Point : : ZERO ) <nl> - , _previousPosition ( Point : : ZERO ) <nl> - , _endPosition ( Point : : ZERO ) <nl> - { <nl> - <nl> - } <nl> - <nl> - UIDragPanel : : ~ UIDragPanel ( ) <nl> - { <nl> - <nl> - } <nl> - <nl> - UIDragPanel * UIDragPanel : : create ( ) <nl> - { <nl> - UIDragPanel * widget = new UIDragPanel ( ) ; <nl> - if ( widget & & widget - > init ( ) ) <nl> - { <nl> - widget - > autorelease ( ) ; <nl> - return widget ; <nl> - } <nl> - CC_SAFE_DELETE ( widget ) ; <nl> - return NULL ; <nl> - } <nl> - <nl> - bool UIDragPanel : : init ( ) <nl> - { <nl> - if ( Layout : : init ( ) ) <nl> - { <nl> - setUpdateEnabled ( true ) ; <nl> - setTouchEnabled ( true ) ; <nl> - setClippingEnabled ( true ) ; <nl> - return true ; <nl> - } <nl> - return false ; <nl> - } <nl> - <nl> - void UIDragPanel : : initRenderer ( ) <nl> - { <nl> - Layout : : initRenderer ( ) ; <nl> - <nl> - _innerContainer = Layout : : create ( ) ; <nl> - Layout : : addChild ( _innerContainer ) ; <nl> - <nl> - } <nl> - <nl> - void UIDragPanel : : releaseResoures ( ) <nl> - { <nl> - setUpdateEnabled ( false ) ; <nl> - removeAllChildren ( ) ; <nl> - _renderer - > removeAllChildrenWithCleanup ( true ) ; <nl> - _renderer - > removeFromParentAndCleanup ( true ) ; <nl> - _renderer - > release ( ) ; <nl> - <nl> - Layout : : removeChild ( _innerContainer ) ; <nl> - <nl> - _children - > release ( ) ; <nl> - } <nl> - <nl> - bool UIDragPanel : : onTouchBegan ( const Point & touchPoint ) <nl> - { <nl> - bool pass = Layout : : onTouchBegan ( touchPoint ) ; <nl> - handlePressLogic ( touchPoint ) ; <nl> - return pass ; <nl> - } <nl> - <nl> - void UIDragPanel : : onTouchMoved ( const Point & touchPoint ) <nl> - { <nl> - Layout : : onTouchMoved ( touchPoint ) ; <nl> - handleMoveLogic ( touchPoint ) ; <nl> - } <nl> - <nl> - void UIDragPanel : : onTouchEnded ( const Point & touchPoint ) <nl> - { <nl> - Layout : : onTouchEnded ( touchPoint ) ; <nl> - handleReleaseLogic ( touchPoint ) ; <nl> - } <nl> - <nl> - void UIDragPanel : : onTouchCancelled ( const Point & touchPoint ) <nl> - { <nl> - Layout : : onTouchCancelled ( touchPoint ) ; <nl> - } <nl> - <nl> - void UIDragPanel : : onTouchLongClicked ( const Point & touchPoint ) <nl> - { <nl> - <nl> - } <nl> - <nl> - void UIDragPanel : : update ( float dt ) <nl> - { <nl> - / / widget action <nl> - if ( _runningAction ) <nl> - { <nl> - if ( actionIsDone ( ) ) <nl> - { <nl> - actionDone ( ) ; <nl> - actionStop ( ) ; <nl> - } <nl> - else <nl> - { <nl> - actionStep ( dt ) ; <nl> - } <nl> - } <nl> - <nl> - recordSlidTime ( dt ) ; <nl> - } <nl> - <nl> - bool UIDragPanel : : addChild ( UIWidget * widget ) <nl> - { <nl> - _innerContainer - > addChild ( widget ) ; <nl> - return true ; <nl> - } <nl> - <nl> - bool UIDragPanel : : removeChild ( UIWidget * child ) <nl> - { <nl> - bool value = false ; <nl> - if ( _innerContainer - > removeChild ( child ) ) <nl> - { <nl> - value = true ; <nl> - } <nl> - <nl> - return value ; <nl> - } <nl> - <nl> - void UIDragPanel : : removeAllChildren ( ) <nl> - { <nl> - _innerContainer - > removeAllChildren ( ) ; <nl> - } <nl> - <nl> - Array * UIDragPanel : : getChildren ( ) <nl> - { <nl> - return _innerContainer - > getChildren ( ) ; <nl> - } <nl> - <nl> - void UIDragPanel : : onSizeChanged ( ) <nl> - { <nl> - Layout : : onSizeChanged ( ) ; <nl> - Size innerSize = _innerContainer - > getSize ( ) ; <nl> - float orginInnerSizeWidth = innerSize . width ; <nl> - float orginInnerSizeHeight = innerSize . height ; <nl> - float innerSizeWidth = MAX ( orginInnerSizeWidth , _size . width ) ; <nl> - float innerSizeHeight = MAX ( orginInnerSizeHeight , _size . height ) ; <nl> - _innerContainer - > setSize ( Size ( innerSizeWidth , innerSizeHeight ) ) ; <nl> - } <nl> - <nl> - const Size & UIDragPanel : : getInnerContainerSize ( ) const <nl> - { <nl> - return _innerContainer - > getContentSize ( ) ; <nl> - } <nl> - <nl> - void UIDragPanel : : setInnerContainerSize ( const cocos2d : : Size & size ) <nl> - { <nl> - float innerSizeWidth = _size . width ; <nl> - float innerSizeHeight = _size . height ; <nl> - if ( size . width < _size . width ) <nl> - { <nl> - CCLOG ( " Inner width < = scrollview width , it will be force sized ! " ) ; <nl> - } <nl> - else <nl> - { <nl> - innerSizeWidth = size . width ; <nl> - } <nl> - if ( size . height < _size . height ) <nl> - { <nl> - CCLOG ( " Inner height < = scrollview height , it will be force sized ! " ) ; <nl> - } <nl> - else <nl> - { <nl> - innerSizeHeight = size . height ; <nl> - } <nl> - _innerContainer - > setSize ( Size ( innerSizeWidth , innerSizeHeight ) ) ; <nl> - _innerContainer - > setPosition ( Point ( 0 , _size . height - _innerContainer - > getSize ( ) . height ) ) ; <nl> - } <nl> - <nl> - const Point & UIDragPanel : : getInnerContainerPosition ( ) const <nl> - { <nl> - return _innerContainer - > getPosition ( ) ; <nl> - } <nl> - <nl> - void UIDragPanel : : setInnerContainerPosition ( const Point & point , bool animated ) <nl> - { <nl> - Point delta = point - _innerContainer - > getPosition ( ) ; <nl> - <nl> - / / Point delta = ccpSub ( point , _innerContainer - > getPosition ( ) ) ; <nl> - setInnerContainerOffset ( delta , animated ) ; <nl> - } <nl> - <nl> - void UIDragPanel : : setInnerContainerOffset ( const Point & offset , bool animated ) <nl> - { <nl> - if ( animated ) <nl> - { <nl> - Point delta = offset ; <nl> - <nl> - if ( checkToBoundaryWithDeltaPosition ( delta ) ) <nl> - { <nl> - delta = calculateToBoundaryDeltaPosition ( delta ) ; <nl> - } <nl> - actionStartWithWidget ( _innerContainer ) ; <nl> - moveByWithDuration ( _autoMoveDuration , delta ) ; <nl> - } <nl> - else <nl> - { <nl> - setInnerContainerOffset ( offset ) ; <nl> - } <nl> - } <nl> - <nl> - void UIDragPanel : : setInnerContainerOffset ( const Point & offset ) <nl> - { <nl> - Point delta = offset ; <nl> - <nl> - if ( checkToBoundaryWithDeltaPosition ( delta ) ) <nl> - { <nl> - delta = calculateToBoundaryDeltaPosition ( delta ) ; <nl> - } <nl> - moveWithDelta ( delta ) ; <nl> - if ( checkBerth ( ) ) <nl> - { <nl> - berthEvent ( ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - void UIDragPanel : : handlePressLogic ( const Point & touchPoint ) <nl> - { <nl> - / / check inner rect < drag panel rect <nl> - if ( checkContainInnerRect ( ) ) <nl> - { <nl> - _touchPressed = false ; <nl> - return ; <nl> - } <nl> - <nl> - _touchPressed = true ; <nl> - _touchMoved = false ; <nl> - _touchReleased = false ; <nl> - _touchCanceld = false ; <nl> - <nl> - if ( _runningAction ) <nl> - { <nl> - switch ( _moveType ) <nl> - { <nl> - case DRAGPANEL_MOVE_TYPE_AUTOMOVE : <nl> - stopAutoMove ( ) ; <nl> - actionStop ( ) ; <nl> - break ; <nl> - <nl> - case DRAGPANEL_MOVE_TYPE_BOUNCE : <nl> - _touchPressed = false ; <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - Point nsp = _renderer - > convertToNodeSpace ( touchPoint ) ; <nl> - _touchStartNodeSpace = nsp ; <nl> - <nl> - _touchStartWorldSpace = touchPoint ; <nl> - } <nl> - <nl> - void UIDragPanel : : handleMoveLogic ( const Point & touchPoint ) <nl> - { <nl> - if ( ! _touchPressed ) <nl> - { <nl> - return ; <nl> - } <nl> - <nl> - / / check touch out of drag panel boundary <nl> - if ( _touchCanceld ) <nl> - { <nl> - return ; <nl> - } <nl> - <nl> - _touchMoved = true ; <nl> - <nl> - Point nsp = _renderer - > convertToNodeSpace ( touchPoint ) ; <nl> - Point delta = nsp - _touchStartNodeSpace ; <nl> - / / Point delta = ccpSub ( nsp , _touchStartNodeSpace ) ; <nl> - _touchStartNodeSpace = nsp ; <nl> - <nl> - / / reset berth dir to none <nl> - if ( ! _bounceEnable ) <nl> - { <nl> - _berthDirection = DRAGPANEL_BERTH_DIR_NONE ; <nl> - } <nl> - <nl> - / / check will berth ( bounce disable ) <nl> - if ( ! _bounceEnable ) <nl> - { <nl> - if ( checkToBoundaryWithDeltaPosition ( delta ) ) <nl> - { <nl> - delta = calculateToBoundaryDeltaPosition ( delta ) ; <nl> - } <nl> - } <nl> - / / move <nl> - moveWithDelta ( delta ) ; <nl> - / / check bounce or berth <nl> - if ( _bounceEnable ) <nl> - { <nl> - / / bounce <nl> - if ( ! hitTest ( touchPoint ) ) <nl> - { <nl> - _touchMoved = false ; <nl> - <nl> - if ( checkNeedBounce ( ) ) <nl> - { <nl> - _touchCanceld = true ; <nl> - startBounce ( ) ; <nl> - } <nl> - } <nl> - } <nl> - else <nl> - { <nl> - / / berth <nl> - if ( checkBerth ( ) ) <nl> - { <nl> - berthEvent ( ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - void UIDragPanel : : handleReleaseLogic ( const Point & touchPoint ) <nl> - { <nl> - if ( ! _touchPressed ) <nl> - { <nl> - return ; <nl> - } <nl> - <nl> - _touchPressed = false ; <nl> - _touchMoved = false ; <nl> - _touchReleased = true ; <nl> - _touchCanceld = false ; <nl> - <nl> - / / check touch out of drag panel boundary <nl> - if ( _touchCanceld ) <nl> - { <nl> - return ; <nl> - } <nl> - <nl> - if ( hitTest ( touchPoint ) ) <nl> - { <nl> - _touchEndWorldSpace = touchPoint ; <nl> - startAutoMove ( ) ; <nl> - } <nl> - } <nl> - <nl> - void UIDragPanel : : checkChildInfo ( int handleState , UIWidget * sender , const Point & touchPoint ) <nl> - { <nl> - interceptTouchEvent ( handleState , sender , touchPoint ) ; <nl> - } <nl> - <nl> - void UIDragPanel : : interceptTouchEvent ( int handleState , UIWidget * sender , const Point & touchPoint ) <nl> - { <nl> - switch ( handleState ) <nl> - { <nl> - case 0 : <nl> - handlePressLogic ( touchPoint ) ; <nl> - break ; <nl> - <nl> - case 1 : <nl> - { <nl> - / / float offset = ccpDistance ( sender - > getTouchStartPos ( ) , touchPoint ) ; <nl> - float offset = sender - > getTouchStartPos ( ) . getDistance ( touchPoint ) ; <nl> - if ( offset > 5 . 0 ) <nl> - { <nl> - sender - > setFocused ( false ) ; <nl> - handleMoveLogic ( touchPoint ) ; <nl> - } <nl> - } <nl> - break ; <nl> - <nl> - case 2 : <nl> - handleReleaseLogic ( touchPoint ) ; <nl> - break ; <nl> - <nl> - case 3 : <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - void UIDragPanel : : recordSlidTime ( float dt ) <nl> - { <nl> - if ( _touchPressed ) <nl> - { <nl> - _slidTime + = dt ; <nl> - } <nl> - } <nl> - <nl> - / / check if dragpanel rect contain inner rect <nl> - bool UIDragPanel : : checkContainInnerRect ( ) <nl> - { <nl> - float width = _size . width ; <nl> - float height = _size . height ; <nl> - float innerWidth = _innerContainer - > getSize ( ) . width ; <nl> - float innerHeight = _innerContainer - > getSize ( ) . height ; <nl> - <nl> - if ( innerWidth < = width & & innerHeight < = height ) <nl> - { <nl> - return true ; <nl> - } <nl> - <nl> - return false ; <nl> - } <nl> - <nl> - / / move <nl> - void UIDragPanel : : moveWithDelta ( const Point & delta ) <nl> - { <nl> - Point newPos = _innerContainer - > getPosition ( ) + delta ; <nl> - / / Point newPos = ccpAdd ( _innerContainer - > getPosition ( ) , delta ) ; <nl> - _innerContainer - > setPosition ( newPos ) ; <nl> - } <nl> - <nl> - / / auto move <nl> - void UIDragPanel : : autoMove ( ) <nl> - { <nl> - if ( _bounceEnable ) <nl> - { <nl> - if ( checkNeedBounce ( ) ) <nl> - { <nl> - stopAutoMove ( ) ; <nl> - startBounce ( ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - void UIDragPanel : : autoMoveOver ( ) <nl> - { <nl> - stopAutoMove ( ) ; <nl> - <nl> - if ( checkBerth ( ) ) <nl> - { <nl> - berthEvent ( ) ; <nl> - _berthDirection = DRAGPANEL_BERTH_DIR_NONE ; <nl> - } <nl> - } <nl> - <nl> - void UIDragPanel : : startAutoMove ( ) <nl> - { <nl> - _moveType = DRAGPANEL_MOVE_TYPE_AUTOMOVE ; <nl> - <nl> - actionStop ( ) ; <nl> - <nl> - Point delta = _touchEndWorldSpace - _touchStartWorldSpace ; <nl> - / / Point delta = ccpSub ( m_touchEndWorldSpace , _touchStartWorldSpace ) ; <nl> - delta . x / = _slidTime * 60 ; <nl> - delta . y / = _slidTime * 60 ; <nl> - _slidTime = 0 . 0 ; <nl> - <nl> - / / bounceEnable is disable <nl> - if ( ! _bounceEnable ) <nl> - { <nl> - if ( checkToBoundaryWithDeltaPosition ( delta ) ) <nl> - { <nl> - delta = calculateToBoundaryDeltaPosition ( delta ) ; <nl> - } <nl> - } <nl> - actionStartWithWidget ( _innerContainer ) ; <nl> - moveByWithDuration ( _autoMoveDuration , delta ) ; <nl> - } <nl> - <nl> - void UIDragPanel : : stopAutoMove ( ) <nl> - { <nl> - _moveType = DRAGPANEL_MOVE_TYPE_NONE ; <nl> - } <nl> - <nl> - void UIDragPanel : : setAutoMoveDuration ( float duration ) <nl> - { <nl> - _autoMoveDuration = duration ; <nl> - } <nl> - <nl> - void UIDragPanel : : setAutoMoveEaseRate ( float rate ) <nl> - { <nl> - _autoMoveEaseRate = rate ; <nl> - } <nl> - <nl> - / / berth <nl> - <nl> - / / check if move to boundary <nl> - <nl> - bool UIDragPanel : : checkToBoundaryWithDeltaPosition ( const Point & delta ) <nl> - { <nl> - float innerLeft = _innerContainer - > getLeftInParent ( ) ; <nl> - float innerTop = _innerContainer - > getTopInParent ( ) ; <nl> - float innerRight = _innerContainer - > getRightInParent ( ) ; <nl> - float innerBottom = _innerContainer - > getBottomInParent ( ) ; <nl> - <nl> - float left = 0 ; <nl> - float top = _size . height ; <nl> - float right = _size . width ; <nl> - float bottom = 0 ; <nl> - <nl> - bool toLeftBottom = false ; <nl> - bool toLeftTop = false ; <nl> - bool toRightBottom = false ; <nl> - bool toRightTop = false ; <nl> - bool toLeft = false ; <nl> - bool toRight = false ; <nl> - bool toTop = false ; <nl> - bool toBottom = false ; <nl> - <nl> - if ( innerLeft + delta . x > left & & innerBottom + delta . y > bottom ) / / left bottom <nl> - { <nl> - toLeftBottom = true ; <nl> - } <nl> - else if ( innerLeft + delta . x > left & & innerTop + delta . y < top ) / / left top <nl> - { <nl> - toLeftTop = true ; <nl> - } <nl> - else if ( innerRight + delta . x < right & & innerBottom + delta . y > bottom ) / / right bottom <nl> - { <nl> - toRightBottom = true ; <nl> - } <nl> - else if ( innerRight + delta . x < right & & innerTop + delta . y < top ) / / right top <nl> - { <nl> - toRightTop = true ; <nl> - } <nl> - else if ( innerLeft + delta . x > left ) / / left <nl> - { <nl> - toLeft = true ; <nl> - } <nl> - else if ( innerRight + delta . x < right ) / / right <nl> - { <nl> - toRight = true ; <nl> - } <nl> - else if ( innerTop + delta . y < top ) / / top <nl> - { <nl> - toTop = true ; <nl> - } <nl> - else if ( innerBottom + delta . y > bottom ) / / bottom <nl> - { <nl> - toBottom = true ; <nl> - } <nl> - <nl> - if ( toLeft | | toTop | | toRight | | toBottom <nl> - | | toLeftBottom | | toLeftTop | | toRightBottom | | toRightTop ) <nl> - { <nl> - return true ; <nl> - } <nl> - <nl> - return false ; <nl> - } <nl> - <nl> - Point UIDragPanel : : calculateToBoundaryDeltaPosition ( const Point & paramDelta ) <nl> - { <nl> - float innerLeft = _innerContainer - > getLeftInParent ( ) ; <nl> - float innerTop = _innerContainer - > getTopInParent ( ) ; <nl> - float innerRight = _innerContainer - > getRightInParent ( ) ; <nl> - float innerBottom = _innerContainer - > getBottomInParent ( ) ; <nl> - <nl> - float left = 0 ; <nl> - float top = _size . height ; <nl> - float right = _size . width ; <nl> - float bottom = 0 ; <nl> - <nl> - Point delta = paramDelta ; <nl> - <nl> - if ( innerLeft + delta . x > left & & innerBottom + delta . y > bottom ) / / left bottom <nl> - { <nl> - delta . x = left - innerLeft ; <nl> - delta . y = bottom - innerBottom ; <nl> - } <nl> - else if ( innerLeft + delta . x > left & & innerTop + delta . y < top ) / / left top <nl> - { <nl> - delta . x = left - innerLeft ; <nl> - delta . y = top - innerTop ; <nl> - } <nl> - else if ( innerRight + delta . x < right & & innerBottom + delta . y > bottom ) / / right bottom <nl> - { <nl> - delta . x = right - innerRight ; <nl> - delta . y = bottom - innerBottom ; <nl> - } <nl> - else if ( innerRight + delta . x < right & & innerTop + delta . y < top ) / / right bottom <nl> - { <nl> - delta . x = right - innerRight ; <nl> - delta . y = top - innerTop ; <nl> - } <nl> - else if ( innerLeft + delta . x > left ) / / left <nl> - { <nl> - delta . x = left - innerLeft ; <nl> - } <nl> - else if ( innerRight + delta . x < right ) / / right <nl> - { <nl> - delta . x = right - innerRight ; <nl> - } <nl> - else if ( innerTop + delta . y < top ) / / top <nl> - { <nl> - delta . y = top - innerTop ; <nl> - } <nl> - else if ( innerBottom + delta . y > bottom ) / / bottom <nl> - { <nl> - delta . y = bottom - innerBottom ; <nl> - } <nl> - <nl> - return delta ; <nl> - } <nl> - <nl> - bool UIDragPanel : : isBerth ( ) <nl> - { <nl> - return _berthDirection ! = DRAGPANEL_BERTH_DIR_NONE ; <nl> - } <nl> - <nl> - / / check berth <nl> - bool UIDragPanel : : checkBerth ( ) <nl> - { <nl> - float innerLeft = _innerContainer - > getLeftInParent ( ) ; <nl> - float innerTop = _innerContainer - > getTopInParent ( ) ; <nl> - float innerRight = _innerContainer - > getRightInParent ( ) ; <nl> - float innerBottom = _innerContainer - > getBottomInParent ( ) ; <nl> - <nl> - float left = 0 ; <nl> - float top = _size . height ; <nl> - float right = _size . width ; <nl> - float bottom = 0 ; <nl> - <nl> - if ( innerLeft = = left & & innerBottom = = bottom ) / / left bottom <nl> - { <nl> - _berthDirection = DRAGPANEL_BERTH_DIR_LEFTBOTTOM ; <nl> - } <nl> - else if ( innerLeft = = left & & innerTop = = top ) / / left top <nl> - { <nl> - _berthDirection = DRAGPANEL_BERTH_DIR_LFETTOP ; <nl> - } <nl> - else if ( innerRight = = right & & innerBottom = = bottom ) / / right bottom <nl> - { <nl> - _berthDirection = DRAGPANEL_BERTH_DIR_RIGHTBOTTOM ; <nl> - } <nl> - else if ( innerRight = = right & & innerTop = = top ) / / right top <nl> - { <nl> - _berthDirection = DRAGPANEL_BERTH_DIR_RIGHTTOP ; <nl> - } <nl> - else if ( innerLeft = = left ) / / left <nl> - { <nl> - _berthDirection = DRAGPANEL_BERTH_DIR_LEFT ; <nl> - } <nl> - else if ( innerRight = = right ) / / right <nl> - { <nl> - _berthDirection = DRAGPANEL_BERTH_DIR_RIGHT ; <nl> - } <nl> - else if ( innerTop = = top ) / / top <nl> - { <nl> - _berthDirection = DRAGPANEL_BERTH_DIR_TOP ; <nl> - } <nl> - else if ( innerBottom = = bottom ) / / bottom <nl> - { <nl> - _berthDirection = DRAGPANEL_BERTH_DIR_BOTTOM ; <nl> - } <nl> - <nl> - if ( _berthDirection ! = DRAGPANEL_BERTH_DIR_NONE ) <nl> - { <nl> - return true ; <nl> - } <nl> - <nl> - return false ; <nl> - } <nl> - <nl> - void UIDragPanel : : berthEvent ( ) <nl> - { <nl> - switch ( _berthDirection ) <nl> - { <nl> - case DRAGPANEL_BERTH_DIR_LEFTBOTTOM : <nl> - berthToLeftBottomEvent ( ) ; <nl> - break ; <nl> - <nl> - case DRAGPANEL_BERTH_DIR_LFETTOP : <nl> - berthToLeftTopEvent ( ) ; <nl> - break ; <nl> - <nl> - case DRAGPANEL_BERTH_DIR_RIGHTBOTTOM : <nl> - berthToRightBottomEvent ( ) ; <nl> - break ; <nl> - <nl> - case DRAGPANEL_BERTH_DIR_RIGHTTOP : <nl> - berthToRightTopEvent ( ) ; <nl> - break ; <nl> - <nl> - case DRAGPANEL_BERTH_DIR_LEFT : <nl> - berthToLeftEvent ( ) ; <nl> - break ; <nl> - <nl> - case DRAGPANEL_BERTH_DIR_TOP : <nl> - berthToTopEvent ( ) ; <nl> - break ; <nl> - <nl> - case DRAGPANEL_BERTH_DIR_RIGHT : <nl> - berthToRightEvent ( ) ; <nl> - break ; <nl> - <nl> - case DRAGPANEL_BERTH_DIR_BOTTOM : <nl> - berthToBottomEvent ( ) ; <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - void UIDragPanel : : berthToLeftBottomEvent ( ) <nl> - { <nl> - if ( _eventLister & & _eventSelector ) <nl> - { <nl> - ( _eventLister - > * _eventSelector ) ( this , DRAGPANEL_EVENT_BERTH_LEFTBOTTOM ) ; <nl> - } <nl> - } <nl> - <nl> - void UIDragPanel : : berthToLeftTopEvent ( ) <nl> - { <nl> - if ( _eventLister & & _eventSelector ) <nl> - { <nl> - ( _eventLister - > * _eventSelector ) ( this , DRAGPANEL_EVENT_BERTH_LFETTOP ) ; <nl> - } <nl> - } <nl> - <nl> - void UIDragPanel : : berthToRightBottomEvent ( ) <nl> - { <nl> - if ( _eventLister & & _eventSelector ) <nl> - { <nl> - ( _eventLister - > * _eventSelector ) ( this , DRAGPANEL_EVENT_BERTH_RIGHTBOTTOM ) ; <nl> - } <nl> - } <nl> - <nl> - void UIDragPanel : : berthToRightTopEvent ( ) <nl> - { <nl> - if ( _eventLister & & _eventSelector ) <nl> - { <nl> - ( _eventLister - > * _eventSelector ) ( this , DRAGPANEL_EVENT_BERTH_RIGHTTOP ) ; <nl> - } <nl> - } <nl> - <nl> - void UIDragPanel : : berthToLeftEvent ( ) <nl> - { <nl> - if ( _eventLister & & _eventSelector ) <nl> - { <nl> - ( _eventLister - > * _eventSelector ) ( this , DRAGPANEL_EVENT_BERTH_LEFT ) ; <nl> - } <nl> - } <nl> - <nl> - void UIDragPanel : : berthToTopEvent ( ) <nl> - { <nl> - if ( _eventLister & & _eventSelector ) <nl> - { <nl> - ( _eventLister - > * _eventSelector ) ( this , DRAGPANEL_EVENT_BERTH_TOP ) ; <nl> - } <nl> - } <nl> - <nl> - void UIDragPanel : : berthToRightEvent ( ) <nl> - { <nl> - if ( _eventLister & & _eventSelector ) <nl> - { <nl> - ( _eventLister - > * _eventSelector ) ( this , DRAGPANEL_EVENT_BERTH_RIGHT ) ; <nl> - } <nl> - } <nl> - <nl> - void UIDragPanel : : berthToBottomEvent ( ) <nl> - { <nl> - if ( _eventLister & & _eventSelector ) <nl> - { <nl> - ( _eventLister - > * _eventSelector ) ( this , DRAGPANEL_EVENT_BERTH_BOTTOM ) ; <nl> - } <nl> - } <nl> - <nl> - void UIDragPanel : : addEventListener ( Object * target , SEL_DragPanelEvent selector ) <nl> - { <nl> - _eventLister = target ; <nl> - _eventSelector = selector ; <nl> - } <nl> - <nl> - / / bounce <nl> - bool UIDragPanel : : isBounceEnable ( ) <nl> - { <nl> - return _bounceEnable ; <nl> - } <nl> - <nl> - void UIDragPanel : : setBounceEnable ( bool bounce ) <nl> - { <nl> - _bounceEnable = bounce ; <nl> - } <nl> - <nl> - bool UIDragPanel : : checkNeedBounce ( ) <nl> - { <nl> - float innerLeft = _innerContainer - > getLeftInParent ( ) ; <nl> - float innerTop = _innerContainer - > getTopInParent ( ) ; <nl> - float innerRight = _innerContainer - > getRightInParent ( ) ; <nl> - float innerBottom = _innerContainer - > getBottomInParent ( ) ; <nl> - <nl> - float left = 0 ; <nl> - float top = _size . height ; <nl> - float right = _size . width ; <nl> - float bottom = 0 ; <nl> - <nl> - bool need = ( ( innerLeft > left & & innerBottom > bottom ) <nl> - | | ( innerLeft > left & & innerTop < top ) <nl> - | | ( innerRight < right & & innerBottom > bottom ) <nl> - | | ( innerRight < right & & innerTop < top ) <nl> - | | ( innerLeft > left ) <nl> - | | ( innerTop < top ) <nl> - | | ( innerRight < right ) <nl> - | | ( innerBottom > bottom ) ) ; <nl> - return need ; <nl> - } <nl> - <nl> - void UIDragPanel : : startBounce ( ) <nl> - { <nl> - if ( _moveType = = DRAGPANEL_MOVE_TYPE_BOUNCE ) <nl> - { <nl> - return ; <nl> - } <nl> - <nl> - actionStop ( ) ; <nl> - _moveType = DRAGPANEL_MOVE_TYPE_BOUNCE ; <nl> - bounceToCorner ( ) ; <nl> - } <nl> - <nl> - void UIDragPanel : : stopBounce ( ) <nl> - { <nl> - _moveType = DRAGPANEL_MOVE_TYPE_NONE ; <nl> - } <nl> - <nl> - void UIDragPanel : : bounceToCorner ( ) <nl> - { <nl> - float innerLeft = _innerContainer - > getLeftInParent ( ) ; <nl> - float innerTop = _innerContainer - > getTopInParent ( ) ; <nl> - float innerRight = _innerContainer - > getRightInParent ( ) ; <nl> - float innerBottom = _innerContainer - > getBottomInParent ( ) ; <nl> - <nl> - float width = _size . width ; <nl> - float height = _size . height ; <nl> - float left = 0 ; <nl> - float top = height ; <nl> - float right = width ; <nl> - float bottom = 0 ; <nl> - <nl> - float from_x = 0 ; <nl> - float from_y = 0 ; <nl> - float to_x = 0 ; <nl> - float to_y = 0 ; <nl> - Point delta = Point : : ZERO ; <nl> - <nl> - if ( innerLeft > left & & innerBottom > bottom ) / / left bottom <nl> - { <nl> - from_x = innerLeft ; <nl> - from_y = innerBottom ; <nl> - to_x = left ; <nl> - to_y = bottom ; <nl> - <nl> - _bounceDirection = DRAGPANEL_BOUNCE_DIR_LEFTBOTTOM ; <nl> - } <nl> - else if ( innerLeft > left & & innerTop < top ) / / left top <nl> - { <nl> - from_x = innerLeft ; <nl> - from_y = innerTop ; <nl> - to_x = left ; <nl> - to_y = top ; <nl> - <nl> - _bounceDirection = DRAGPANEL_BOUNCE_DIR_LEFTTOP ; <nl> - } <nl> - else if ( innerRight < right & & innerBottom > bottom ) / / right bottom <nl> - { <nl> - from_x = innerRight ; <nl> - from_y = innerBottom ; <nl> - to_x = right ; <nl> - to_y = bottom ; <nl> - <nl> - _bounceDirection = DRAGPANEL_BOUNCE_DIR_RIGHTBOTTOM ; <nl> - } <nl> - else if ( innerRight < right & & innerTop < top ) / / right top <nl> - { <nl> - from_x = innerRight ; <nl> - from_y = innerTop ; <nl> - to_x = right ; <nl> - to_y = top ; <nl> - <nl> - _bounceDirection = DRAGPANEL_BOUNCE_DIR_RIGHTTOP ; <nl> - } <nl> - else if ( innerLeft > left ) / / left <nl> - { <nl> - from_x = innerLeft ; <nl> - from_y = innerBottom ; <nl> - to_x = left ; <nl> - to_y = from_y ; <nl> - <nl> - _bounceDirection = DRAGPANEL_BOUNCE_DIR_LEFT ; <nl> - } <nl> - else if ( innerTop < top ) / / top <nl> - { <nl> - from_x = innerLeft ; <nl> - from_y = innerTop ; <nl> - to_x = from_x ; <nl> - to_y = top ; <nl> - <nl> - _bounceDirection = DRAGPANEL_BOUNCE_DIR_TOP ; <nl> - } <nl> - else if ( innerRight < right ) / / right <nl> - { <nl> - from_x = innerRight ; <nl> - from_y = innerBottom ; <nl> - to_x = right ; <nl> - to_y = from_y ; <nl> - <nl> - _bounceDirection = DRAGPANEL_BOUNCE_DIR_RIGHT ; <nl> - } <nl> - else if ( innerBottom > bottom ) / / bottom <nl> - { <nl> - from_x = innerLeft ; <nl> - from_y = innerBottom ; <nl> - to_x = from_x ; <nl> - to_y = bottom ; <nl> - <nl> - _bounceDirection = DRAGPANEL_BOUNCE_DIR_BOTTOM ; <nl> - } <nl> - delta = Point ( to_x , to_y ) - Point ( from_x , from_y ) ; <nl> - / / delta = ccpSub ( ccp ( to_x , to_y ) , ccp ( from_x , from_y ) ) ; <nl> - <nl> - actionStartWithWidget ( _innerContainer ) ; <nl> - moveByWithDuration ( _bounceDuration , delta ) ; <nl> - } <nl> - <nl> - void UIDragPanel : : bounceOver ( ) <nl> - { <nl> - stopBounce ( ) ; <nl> - <nl> - switch ( _bounceDirection ) <nl> - { <nl> - case DRAGPANEL_BOUNCE_DIR_LEFTBOTTOM : <nl> - bounceToLeftBottomEvent ( ) ; <nl> - break ; <nl> - <nl> - case DRAGPANEL_BOUNCE_DIR_LEFTTOP : <nl> - bounceToLeftTopEvent ( ) ; <nl> - break ; <nl> - <nl> - case DRAGPANEL_BOUNCE_DIR_RIGHTBOTTOM : <nl> - bounceToRightBottomEvent ( ) ; <nl> - break ; <nl> - <nl> - case DRAGPANEL_BOUNCE_DIR_RIGHTTOP : <nl> - bounceToRightTopEvent ( ) ; <nl> - break ; <nl> - <nl> - case DRAGPANEL_BOUNCE_DIR_LEFT : <nl> - bounceToLeftEvent ( ) ; <nl> - break ; <nl> - <nl> - case DRAGPANEL_BOUNCE_DIR_TOP : <nl> - bounceToTopEvent ( ) ; <nl> - break ; <nl> - <nl> - case DRAGPANEL_BOUNCE_DIR_RIGHT : <nl> - bounceToRightEvent ( ) ; <nl> - break ; <nl> - <nl> - case DRAGPANEL_BOUNCE_DIR_BOTTOM : <nl> - bounceToBottomEvent ( ) ; <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - <nl> - _bounceDirection = DRAGPANEL_BOUNCE_DIR_NONE ; <nl> - } <nl> - <nl> - void UIDragPanel : : bounceToLeftBottomEvent ( ) <nl> - { <nl> - if ( _eventLister & & _eventSelector ) <nl> - { <nl> - ( _eventLister - > * _eventSelector ) ( this , DRAGPANEL_EVENT_BOUNCE_LEFTBOTTOM ) ; <nl> - } <nl> - } <nl> - <nl> - void UIDragPanel : : bounceToLeftTopEvent ( ) <nl> - { <nl> - if ( _eventLister & & _eventSelector ) <nl> - { <nl> - ( _eventLister - > * _eventSelector ) ( this , DRAGPANEL_EVENT_BOUNCE_LEFTTOP ) ; <nl> - } <nl> - } <nl> - <nl> - void UIDragPanel : : bounceToRightBottomEvent ( ) <nl> - { <nl> - if ( _eventLister & & _eventSelector ) <nl> - { <nl> - ( _eventLister - > * _eventSelector ) ( this , DRAGPANEL_EVENT_BOUNCE_RIGHTBOTTOM ) ; <nl> - } <nl> - } <nl> - <nl> - void UIDragPanel : : bounceToRightTopEvent ( ) <nl> - { <nl> - if ( _eventLister & & _eventSelector ) <nl> - { <nl> - ( _eventLister - > * _eventSelector ) ( this , DRAGPANEL_EVENT_BOUNCE_RIGHTTOP ) ; <nl> - } <nl> - } <nl> - <nl> - void UIDragPanel : : bounceToLeftEvent ( ) <nl> - { <nl> - if ( _eventLister & & _eventSelector ) <nl> - { <nl> - ( _eventLister - > * _eventSelector ) ( this , DRAGPANEL_EVENT_BOUNCE_LEFT ) ; <nl> - } <nl> - } <nl> - <nl> - void UIDragPanel : : bounceToTopEvent ( ) <nl> - { <nl> - if ( _eventLister & & _eventSelector ) <nl> - { <nl> - ( _eventLister - > * _eventSelector ) ( this , DRAGPANEL_EVENT_BOUNCE_TOP ) ; <nl> - } <nl> - } <nl> - <nl> - void UIDragPanel : : bounceToRightEvent ( ) <nl> - { <nl> - if ( _eventLister & & _eventSelector ) <nl> - { <nl> - ( _eventLister - > * _eventSelector ) ( this , DRAGPANEL_EVENT_BOUNCE_RIGHT ) ; <nl> - } <nl> - } <nl> - <nl> - void UIDragPanel : : bounceToBottomEvent ( ) <nl> - { <nl> - if ( _eventLister & & _eventSelector ) <nl> - { <nl> - ( _eventLister - > * _eventSelector ) ( this , DRAGPANEL_EVENT_BOUNCE_BOTTOM ) ; <nl> - } <nl> - } <nl> - <nl> - / / widget action <nl> - void UIDragPanel : : actionWithDuration ( float duration ) <nl> - { <nl> - _duration = duration ; <nl> - <nl> - if ( _duration = = 0 ) <nl> - { <nl> - _duration = FLT_EPSILON ; <nl> - } <nl> - <nl> - _elapsed = 0 ; <nl> - _firstTick = true ; <nl> - } <nl> - <nl> - bool UIDragPanel : : actionIsDone ( ) <nl> - { <nl> - bool value = ( _elapsed > = _duration ) ; <nl> - return value ; <nl> - } <nl> - <nl> - void UIDragPanel : : actionStartWithWidget ( UIWidget * widget ) <nl> - { <nl> - _runningAction = true ; <nl> - _actionWidget = widget ; <nl> - } <nl> - <nl> - void UIDragPanel : : actionStep ( float dt ) <nl> - { <nl> - if ( _firstTick ) <nl> - { <nl> - _firstTick = false ; <nl> - _elapsed = 0 ; <nl> - } <nl> - else <nl> - { <nl> - _elapsed + = dt ; <nl> - } <nl> - <nl> - actionUpdate ( MAX ( 0 , <nl> - MIN ( 1 , _elapsed / <nl> - MAX ( _duration , FLT_EPSILON ) <nl> - ) <nl> - ) <nl> - ) ; <nl> - } <nl> - <nl> - void UIDragPanel : : actionUpdate ( float dt ) <nl> - { <nl> - switch ( _actionType ) <nl> - { <nl> - case 1 : / / move by <nl> - moveByUpdate ( dt ) ; <nl> - break ; <nl> - <nl> - case 2 : / / move to <nl> - moveToUpdate ( dt ) ; <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - void UIDragPanel : : actionStop ( ) <nl> - { <nl> - _runningAction = false ; <nl> - } <nl> - <nl> - void UIDragPanel : : actionDone ( ) <nl> - { <nl> - switch ( _moveType ) <nl> - { <nl> - case DRAGPANEL_MOVE_TYPE_AUTOMOVE : <nl> - autoMoveOver ( ) ; <nl> - break ; <nl> - <nl> - case DRAGPANEL_MOVE_TYPE_BOUNCE : <nl> - bounceOver ( ) ; <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - / / move by <nl> - void UIDragPanel : : moveByWithDuration ( float duration , const Point & deltaPosition ) <nl> - { <nl> - actionWithDuration ( duration ) ; <nl> - _positionDelta = deltaPosition ; <nl> - moveByInit ( ) ; <nl> - _actionType = 1 ; <nl> - } <nl> - <nl> - void UIDragPanel : : moveByInit ( ) <nl> - { <nl> - _previousPosition = _startPosition = _actionWidget - > getPosition ( ) ; <nl> - } <nl> - <nl> - void UIDragPanel : : moveByUpdate ( float t ) <nl> - { <nl> - float easeRate = 0 . 0f ; <nl> - switch ( _moveType ) <nl> - { <nl> - case DRAGPANEL_MOVE_TYPE_AUTOMOVE : <nl> - easeRate = _autoMoveEaseRate ; <nl> - break ; <nl> - <nl> - case DRAGPANEL_MOVE_TYPE_BOUNCE : <nl> - easeRate = _bounceEaseRate ; <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - t = powf ( t , 1 / easeRate ) ; <nl> - <nl> - Point currentPos = _actionWidget - > getPosition ( ) ; <nl> - Point diff = currentPos - _previousPosition ; <nl> - _startPosition = _startPosition + diff ; <nl> - / / Point diff = ccpSub ( currentPos , _previousPosition ) ; <nl> - / / _startPosition = ccpAdd ( _startPosition , diff ) ; <nl> - <nl> - / / Point newPos = ccpAdd ( _startPosition , ccpMult ( _positionDelta , t ) ) ; <nl> - Point newPos = _startPosition + ( _positionDelta * t ) ; <nl> - <nl> - _actionWidget - > setPosition ( newPos ) ; <nl> - _previousPosition = newPos ; <nl> - <nl> - switch ( _moveType ) <nl> - { <nl> - case DRAGPANEL_MOVE_TYPE_AUTOMOVE : <nl> - autoMove ( ) ; <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - / / move to <nl> - void UIDragPanel : : moveToWithDuration ( float duration , const Point & position ) <nl> - { <nl> - actionWithDuration ( duration ) ; <nl> - _endPosition = position ; <nl> - moveToInit ( ) ; <nl> - _actionType = 2 ; <nl> - } <nl> - <nl> - void UIDragPanel : : moveToInit ( ) <nl> - { <nl> - moveByInit ( ) ; <nl> - _positionDelta = _endPosition - _actionWidget - > getPosition ( ) ; <nl> - / / _positionDelta = ccpSub ( _endPosition , _actionWidget - > getPosition ( ) ) ; <nl> - } <nl> - <nl> - void UIDragPanel : : moveToUpdate ( float t ) <nl> - { <nl> - moveByUpdate ( t ) ; <nl> - } <nl> - <nl> - Layout * UIDragPanel : : getInnerContainer ( ) <nl> - { <nl> - return _innerContainer ; <nl> - } <nl> - <nl> - void UIDragPanel : : setLayoutType ( LayoutType type ) <nl> - { <nl> - _innerContainer - > setLayoutType ( type ) ; <nl> - } <nl> - <nl> - LayoutType UIDragPanel : : getLayoutType ( ) const <nl> - { <nl> - return _innerContainer - > getLayoutType ( ) ; <nl> - } <nl> - <nl> - void UIDragPanel : : doLayout ( ) <nl> - { <nl> - _innerContainer - > doLayout ( ) ; <nl> - } <nl> - <nl> - const char * UIDragPanel : : getDescription ( ) const <nl> - { <nl> - return " DragPanel " ; <nl> - } <nl> - <nl> - } <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index d6b4f0b62cc0 . . 000000000000 <nl> mmm a / cocos / gui / UIDragPanel . 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 __UIDRAGPANEL_H__ <nl> - # define __UIDRAGPANEL_H__ <nl> - <nl> - # include " gui / Layout . h " <nl> - # include " gui / UIScrollInterface . h " <nl> - <nl> - namespace gui { <nl> - <nl> - / * * <nl> - * drag panel move type <nl> - * / <nl> - enum DRAGPANEL_MOVE_TYPE <nl> - { <nl> - DRAGPANEL_MOVE_TYPE_NONE , <nl> - DRAGPANEL_MOVE_TYPE_AUTOMOVE , <nl> - DRAGPANEL_MOVE_TYPE_BOUNCE , <nl> - } ; <nl> - <nl> - / * * <nl> - * dragpanel berth direction <nl> - * / <nl> - enum DRAGPANEL_BERTH_DIR <nl> - { <nl> - DRAGPANEL_BERTH_DIR_NONE , <nl> - DRAGPANEL_BERTH_DIR_LEFTBOTTOM , <nl> - DRAGPANEL_BERTH_DIR_LFETTOP , <nl> - DRAGPANEL_BERTH_DIR_RIGHTBOTTOM , <nl> - DRAGPANEL_BERTH_DIR_RIGHTTOP , <nl> - DRAGPANEL_BERTH_DIR_LEFT , <nl> - DRAGPANEL_BERTH_DIR_TOP , <nl> - DRAGPANEL_BERTH_DIR_RIGHT , <nl> - DRAGPANEL_BERTH_DIR_BOTTOM , <nl> - } ; <nl> - <nl> - / * * <nl> - * dragpanel bounce direction <nl> - * / <nl> - enum DRAGPANEL_BOUNCE_DIR <nl> - { <nl> - DRAGPANEL_BOUNCE_DIR_NONE , <nl> - DRAGPANEL_BOUNCE_DIR_LEFTBOTTOM , <nl> - DRAGPANEL_BOUNCE_DIR_LEFTTOP , <nl> - DRAGPANEL_BOUNCE_DIR_RIGHTBOTTOM , <nl> - DRAGPANEL_BOUNCE_DIR_RIGHTTOP , <nl> - DRAGPANEL_BOUNCE_DIR_LEFT , <nl> - DRAGPANEL_BOUNCE_DIR_TOP , <nl> - DRAGPANEL_BOUNCE_DIR_RIGHT , <nl> - DRAGPANEL_BOUNCE_DIR_BOTTOM , <nl> - } ; <nl> - <nl> - typedef enum <nl> - { <nl> - DRAGPANEL_EVENT_BERTH_LEFTBOTTOM , <nl> - DRAGPANEL_EVENT_BERTH_LFETTOP , <nl> - DRAGPANEL_EVENT_BERTH_RIGHTBOTTOM , <nl> - DRAGPANEL_EVENT_BERTH_RIGHTTOP , <nl> - DRAGPANEL_EVENT_BERTH_LEFT , <nl> - DRAGPANEL_EVENT_BERTH_TOP , <nl> - DRAGPANEL_EVENT_BERTH_RIGHT , <nl> - DRAGPANEL_EVENT_BERTH_BOTTOM , <nl> - DRAGPANEL_EVENT_BOUNCE_LEFTBOTTOM , <nl> - DRAGPANEL_EVENT_BOUNCE_LEFTTOP , <nl> - DRAGPANEL_EVENT_BOUNCE_RIGHTBOTTOM , <nl> - DRAGPANEL_EVENT_BOUNCE_RIGHTTOP , <nl> - DRAGPANEL_EVENT_BOUNCE_LEFT , <nl> - DRAGPANEL_EVENT_BOUNCE_TOP , <nl> - DRAGPANEL_EVENT_BOUNCE_RIGHT , <nl> - DRAGPANEL_EVENT_BOUNCE_BOTTOM , <nl> - } DragPanelEventType ; <nl> - <nl> - / * * <nl> - * dragpanel event <nl> - * / <nl> - typedef void ( cocos2d : : Object : : * SEL_DragPanelEvent ) ( cocos2d : : Object * , DragPanelEventType ) ; <nl> - # define dragpaneleventselector ( _SELECTOR ) ( SEL_DragPanelEvent ) ( & _SELECTOR ) <nl> - <nl> - class UIDragPanel : public Layout , public UIScrollInterface <nl> - { <nl> - public : <nl> - UIDragPanel ( ) ; <nl> - virtual ~ UIDragPanel ( ) ; <nl> - <nl> - static UIDragPanel * create ( ) ; <nl> - <nl> - virtual bool onTouchBegan ( const cocos2d : : Point & touchPoint ) ; <nl> - virtual void onTouchMoved ( const cocos2d : : Point & touchPoint ) ; <nl> - virtual void onTouchEnded ( const cocos2d : : Point & touchPoint ) ; <nl> - virtual void onTouchCancelled ( const cocos2d : : Point & touchPoint ) ; <nl> - virtual void onTouchLongClicked ( const cocos2d : : Point & touchPoint ) ; <nl> - <nl> - virtual void update ( float dt ) ; <nl> - <nl> - / * * <nl> - * add widget child override <nl> - * / <nl> - virtual bool addChild ( UIWidget * widget ) ; <nl> - / * * <nl> - * remove widget child override <nl> - * / <nl> - virtual bool removeChild ( UIWidget * child ) ; <nl> - / * * <nl> - * remove all widget children override <nl> - * / <nl> - virtual void removeAllChildren ( ) ; <nl> - / * * <nl> - * get widget children of inner container <nl> - * / <nl> - virtual cocos2d : : Array * getChildren ( ) ; <nl> - / * gui mark * / <nl> - / * * <nl> - * get and set inner container size <nl> - * / <nl> - const cocos2d : : Size & getInnerContainerSize ( ) const ; <nl> - void setInnerContainerSize ( const cocos2d : : Size & size ) ; <nl> - / * * <nl> - * get and set inner container position <nl> - * / <nl> - const cocos2d : : Point & getInnerContainerPosition ( ) const ; <nl> - void setInnerContainerPosition ( const cocos2d : : Point & point , bool animated ) ; <nl> - / * * <nl> - * set inner container offset <nl> - * / <nl> - void setInnerContainerOffset ( const cocos2d : : Point & offset , bool animated ) ; <nl> - / * * / <nl> - <nl> - / / auto move <nl> - / * * <nl> - * set auto move duration <nl> - * / <nl> - void setAutoMoveDuration ( float duration ) ; <nl> - / * * <nl> - * set auto move ease rate <nl> - * / <nl> - void setAutoMoveEaseRate ( float rate ) ; <nl> - <nl> - / / berth <nl> - / * * <nl> - * get berth or not <nl> - * / <nl> - bool isBerth ( ) ; <nl> - <nl> - / * * <nl> - * event <nl> - * / <nl> - void addEventListener ( cocos2d : : Object * target , SEL_DragPanelEvent selector ) ; <nl> - <nl> - / * * <nl> - * get and set bounce enable <nl> - * / <nl> - bool isBounceEnable ( ) ; <nl> - void setBounceEnable ( bool bounce ) ; <nl> - / * * <nl> - * set bounce duration <nl> - * / <nl> - void setBounceDuratoin ( float duration ) ; <nl> - / * * <nl> - * set bounce ease rate <nl> - * / <nl> - void setBounceEaseRate ( float rate ) ; <nl> - <nl> - / * * <nl> - * Gets inner container of dragpanel . <nl> - * <nl> - * Inner container is the container of dragpanel ' s children . <nl> - * <nl> - * @ return inner container . <nl> - * / <nl> - Layout * getInnerContainer ( ) ; <nl> - <nl> - / * * <nl> - * Sets LayoutType . <nl> - * <nl> - * @ see LayoutType <nl> - * <nl> - * @ param LayoutType <nl> - * / <nl> - virtual void setLayoutType ( LayoutType type ) ; <nl> - <nl> - / * * <nl> - * Gets LayoutType . <nl> - * <nl> - * @ see LayoutType <nl> - * <nl> - * @ return LayoutType <nl> - * / <nl> - virtual LayoutType getLayoutType ( ) const ; <nl> - <nl> - virtual void doLayout ( ) ; <nl> - <nl> - / * * <nl> - * Returns the " class name " of widget . <nl> - * / <nl> - virtual const char * getDescription ( ) const ; <nl> - <nl> - protected : <nl> - virtual bool init ( ) ; <nl> - virtual void initRenderer ( ) ; <nl> - virtual void releaseResoures ( ) ; <nl> - <nl> - virtual void handlePressLogic ( const cocos2d : : Point & touchPoint ) ; <nl> - virtual void handleMoveLogic ( const cocos2d : : Point & touchPoint ) ; <nl> - virtual void handleReleaseLogic ( const cocos2d : : Point & touchPoint ) ; <nl> - virtual void interceptTouchEvent ( int handleState , UIWidget * sender , const cocos2d : : Point & touchPoint ) ; <nl> - / * gui mark * / <nl> - / / virtual bool isInScrollDegreeRange ( UIWidget * widget ) ; <nl> - / * * / <nl> - virtual void checkChildInfo ( int handleState , UIWidget * sender , const cocos2d : : Point & touchPoint ) ; <nl> - / / void updateWidthAndHeight ( ) ; <nl> - void recordSlidTime ( float dt ) ; <nl> - <nl> - / * gui mark * / <nl> - void setInnerContainerOffset ( const cocos2d : : Point & offset ) ; <nl> - / * * / <nl> - <nl> - / / check if dragpanel rect contain inner rect <nl> - bool checkContainInnerRect ( ) ; <nl> - <nl> - / / move <nl> - void moveWithDelta ( const cocos2d : : Point & delta ) ; <nl> - <nl> - / / auto move <nl> - void autoMove ( ) ; <nl> - void autoMoveOver ( ) ; <nl> - void startAutoMove ( ) ; <nl> - void stopAutoMove ( ) ; <nl> - <nl> - / / berth <nl> - / / check if move to boundary with update <nl> - bool checkToBoundaryWithDeltaPosition ( const cocos2d : : Point & delta ) ; <nl> - <nl> - / / calculate to boundary delta <nl> - cocos2d : : Point calculateToBoundaryDeltaPosition ( const cocos2d : : Point & paramDelta ) ; <nl> - <nl> - / / check berth <nl> - bool checkBerth ( ) ; <nl> - <nl> - / / berth event <nl> - void berthEvent ( ) ; <nl> - void berthToLeftEvent ( ) ; <nl> - void berthToRightEvent ( ) ; <nl> - void berthToTopEvent ( ) ; <nl> - void berthToBottomEvent ( ) ; <nl> - void berthToLeftBottomEvent ( ) ; <nl> - void berthToLeftTopEvent ( ) ; <nl> - void berthToRightBottomEvent ( ) ; <nl> - void berthToRightTopEvent ( ) ; <nl> - <nl> - / / bounce <nl> - bool checkNeedBounce ( ) ; <nl> - void startBounce ( ) ; <nl> - void stopBounce ( ) ; <nl> - void bounceToCorner ( ) ; <nl> - void bounceOver ( ) ; <nl> - / / bounce event <nl> - void bounceToLeftBottomEvent ( ) ; <nl> - void bounceToRightBottomEvent ( ) ; <nl> - void bounceToLeftTopEvent ( ) ; <nl> - void bounceToRightTopEvent ( ) ; <nl> - void bounceToLeftEvent ( ) ; <nl> - void bounceToTopEvent ( ) ; <nl> - void bounceToRightEvent ( ) ; <nl> - void bounceToBottomEvent ( ) ; <nl> - <nl> - void actionWithDuration ( float duration ) ; <nl> - bool actionIsDone ( ) ; <nl> - void actionStartWithWidget ( UIWidget * widget ) ; <nl> - void actionStep ( float dt ) ; <nl> - void actionUpdate ( float dt ) ; <nl> - void actionStop ( ) ; <nl> - void actionDone ( ) ; <nl> - void moveByWithDuration ( float duration , const cocos2d : : Point & deltaPosition ) ; <nl> - void moveByInit ( ) ; <nl> - void moveByUpdate ( float t ) ; <nl> - void moveToWithDuration ( float duration , const cocos2d : : Point & position ) ; <nl> - void moveToInit ( ) ; <nl> - void moveToUpdate ( float t ) ; <nl> - virtual void onSizeChanged ( ) ; <nl> - / * compatible * / <nl> - / * * <nl> - * These methods will be removed <nl> - * / <nl> - virtual void setClippingEnable ( bool is ) { setClippingEnabled ( is ) ; } ; <nl> - / * * * * * * * * * * * * / <nl> - virtual void setClippingEnabled ( bool able ) { Layout : : setClippingEnabled ( able ) ; } ; <nl> - protected : <nl> - Layout * _innerContainer ; <nl> - <nl> - / * <nl> - DRAGPANEL_DIR m_eDirection ; <nl> - DRAGPANEL_MOVE_DIR m_eMoveDirection ; <nl> - * / <nl> - <nl> - bool _touchPressed ; <nl> - bool _touchMoved ; <nl> - bool _touchReleased ; <nl> - bool _touchCanceld ; / / check touch out of drag panel boundary <nl> - <nl> - cocos2d : : Point _touchStartNodeSpace ; <nl> - cocos2d : : Point _touchStartWorldSpace ; <nl> - cocos2d : : Point _touchEndWorldSpace ; <nl> - <nl> - float _slidTime ; <nl> - <nl> - / / move type <nl> - DRAGPANEL_MOVE_TYPE _moveType ; <nl> - <nl> - / / auto move <nl> - float _autoMoveDuration ; <nl> - float _autoMoveEaseRate ; <nl> - <nl> - / / event <nl> - cocos2d : : Object * _eventLister ; <nl> - SEL_DragPanelEvent _eventSelector ; <nl> - <nl> - / / berth <nl> - DRAGPANEL_BERTH_DIR _berthDirection ; <nl> - <nl> - / / bounce <nl> - bool _bounceEnable ; <nl> - DRAGPANEL_BOUNCE_DIR _bounceDirection ; <nl> - float _bounceDuration ; <nl> - float _bounceEaseRate ; <nl> - <nl> - <nl> - float _runningAction ; <nl> - int _actionType ; <nl> - <nl> - UIWidget * _actionWidget ; <nl> - <nl> - float _duration ; <nl> - float _elapsed ; <nl> - bool _firstTick ; <nl> - <nl> - cocos2d : : Point _positionDelta ; <nl> - cocos2d : : Point _startPosition ; <nl> - cocos2d : : Point _previousPosition ; <nl> - <nl> - cocos2d : : Point _endPosition ; <nl> - } ; <nl> - <nl> - } <nl> - <nl> - # endif / * defined ( __TestCpp__UIDragPanel__ ) * / <nl> mmm a / cocos / gui / UIHelper . cpp <nl> ppp b / cocos / gui / UIHelper . cpp <nl> <nl> THE SOFTWARE . <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> <nl> - # include " gui / UIHelper . h " <nl> - # include " cocos2d . h " <nl> - # include " cocostudio / DictionaryHelper . h " <nl> - # include " cocostudio / CCSGUIReader . h " <nl> - <nl> - <nl> - using namespace cocos2d ; <nl> - using namespace cocostudio ; <nl> + # include " CocosGUI . h " <nl> <nl> namespace gui { <nl> - <nl> - static UIHelper * helperInstance = NULL ; <nl> - <nl> - UIHelper * UIHelper : : instance ( ) <nl> - { <nl> - if ( ! helperInstance ) <nl> - { <nl> - helperInstance = new UIHelper ( ) ; <nl> - } <nl> - return helperInstance ; <nl> - } <nl> - <nl> - void UIHelper : : purgeUIHelper ( ) <nl> - { <nl> - CC_SAFE_DELETE ( helperInstance ) ; <nl> - } <nl> - <nl> - UIHelper : : UIHelper ( ) : <nl> - _textureFiles ( NULL ) , <nl> - _fileDesignHeight ( 0 . 0f ) , <nl> - _fileDesignWidth ( 0 . 0f ) <nl> - { <nl> - Size winSize = Director : : getInstance ( ) - > getWinSize ( ) ; <nl> - _fileDesignWidth = winSize . width ; <nl> - _fileDesignHeight = winSize . height ; <nl> - init ( ) ; <nl> - } <nl> - <nl> - UIHelper : : ~ UIHelper ( ) <nl> - { <nl> - cocostudio : : CCSGUIReader : : purgeCCSGUIReader ( ) ; <nl> - } <nl> - <nl> - void UIHelper : : init ( ) <nl> - { <nl> - _textureFiles = CCArray : : create ( ) ; <nl> - _textureFiles - > retain ( ) ; <nl> - } <nl> - <nl> - UIWidget * UIHelper : : createWidgetFromJsonFile ( const char * fileName ) <nl> - { <nl> - return CCSGUIReader : : shareReader ( ) - > widgetFromJsonFile ( fileName ) ; <nl> - } <nl> - <nl> - void UIHelper : : addSpriteFrame ( const char * fileName ) <nl> - { <nl> - if ( ! fileName | | strcmp ( fileName , " " ) = = 0 ) <nl> - { <nl> - return ; <nl> - } <nl> - ccArray * arrayTextures = _textureFiles - > data ; <nl> - int length = arrayTextures - > num ; <nl> - for ( int i = 0 ; i < length ; i + + ) <nl> - { <nl> - String * file = ( String * ) ( arrayTextures - > arr [ i ] ) ; <nl> - if ( strcmp ( file - > _string . c_str ( ) , fileName ) = = 0 ) <nl> - { <nl> - return ; <nl> - } <nl> - } <nl> - _textureFiles - > addObject ( CCString : : create ( fileName ) ) ; <nl> - SpriteFrameCache : : getInstance ( ) - > addSpriteFramesWithFile ( fileName ) ; <nl> - } <nl> - <nl> - void UIHelper : : removeSpriteFrame ( const char * fileName ) <nl> - { <nl> - if ( ! fileName | | strcmp ( fileName , " " ) = = 0 ) <nl> - { <nl> - return ; <nl> - } <nl> - ccArray * arrayTextures = _textureFiles - > data ; <nl> - int length = arrayTextures - > num ; <nl> - for ( int i = 0 ; i < length ; i + + ) <nl> - { <nl> - String * file = ( String * ) ( arrayTextures - > arr [ i ] ) ; <nl> - if ( strcmp ( file - > _string . c_str ( ) , fileName ) = = 0 ) <nl> - { <nl> - SpriteFrameCache : : getInstance ( ) - > removeSpriteFrameByName ( fileName ) ; <nl> - _textureFiles - > removeObject ( file ) ; <nl> - return ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - void UIHelper : : removeAllSpriteFrame ( ) <nl> - { <nl> - ccArray * arrayTextures = _textureFiles - > data ; <nl> - int length = arrayTextures - > num ; <nl> - for ( int i = 0 ; i < length ; i + + ) <nl> - { <nl> - String * file = ( String * ) ( arrayTextures - > arr [ i ] ) ; <nl> - SpriteFrameCache : : getInstance ( ) - > removeSpriteFrameByName ( file - > _string . c_str ( ) ) ; <nl> - } <nl> - _textureFiles - > removeAllObjects ( ) ; <nl> - } <nl> <nl> UIWidget * UIHelper : : seekWidgetByTag ( UIWidget * root , int tag ) <nl> { <nl> UIWidget * UIHelper : : seekWidgetByTag ( UIWidget * root , int tag ) <nl> { <nl> return root ; <nl> } <nl> - ccArray * arrayRootChildren = root - > getChildren ( ) - > data ; <nl> + cocos2d : : ccArray * arrayRootChildren = root - > getChildren ( ) - > data ; <nl> int length = arrayRootChildren - > num ; <nl> for ( int i = 0 ; i < length ; i + + ) <nl> { <nl> UIWidget * UIHelper : : seekWidgetByName ( UIWidget * root , const char * name ) <nl> { <nl> return root ; <nl> } <nl> - ccArray * arrayRootChildren = root - > getChildren ( ) - > data ; <nl> + cocos2d : : ccArray * arrayRootChildren = root - > getChildren ( ) - > data ; <nl> int length = arrayRootChildren - > num ; <nl> for ( int i = 0 ; i < length ; i + + ) <nl> { <nl> UIWidget * UIHelper : : seekWidgetByRelativeName ( UIWidget * root , const char * name ) <nl> { <nl> return NULL ; <nl> } <nl> - ccArray * arrayRootChildren = root - > getChildren ( ) - > data ; <nl> + cocos2d : : ccArray * arrayRootChildren = root - > getChildren ( ) - > data ; <nl> int length = arrayRootChildren - > num ; <nl> for ( int i = 0 ; i < length ; i + + ) <nl> { <nl> UIWidget * child = ( UIWidget * ) ( arrayRootChildren - > arr [ i ] ) ; <nl> - RelativeLayoutParameter * layoutParameter = dynamic_cast < RelativeLayoutParameter * > ( child - > getLayoutParameter ( ) ) ; <nl> + UIRelativeLayoutParameter * layoutParameter = dynamic_cast < UIRelativeLayoutParameter * > ( child - > getLayoutParameter ( LAYOUT_PARAMETER_RELATIVE ) ) ; <nl> if ( layoutParameter & & strcmp ( layoutParameter - > getRelativeName ( ) , name ) = = 0 ) <nl> { <nl> return child ; <nl> UIWidget * UIHelper : : seekWidgetByRelativeName ( UIWidget * root , const char * name ) <nl> return NULL ; <nl> } <nl> <nl> - void UIHelper : : setFileDesignWidth ( float width ) <nl> - { <nl> - _fileDesignWidth = width ; <nl> - } <nl> - <nl> - float UIHelper : : getFileDesignWidth ( ) <nl> - { <nl> - return _fileDesignWidth ; <nl> - } <nl> - <nl> - void UIHelper : : setFileDesignHeight ( float height ) <nl> - { <nl> - _fileDesignHeight = height ; <nl> - } <nl> - <nl> - float UIHelper : : getFileDesignHeight ( ) <nl> - { <nl> - return _fileDesignHeight ; <nl> - } <nl> - <nl> / * temp action * / <nl> UIWidget * UIHelper : : seekActionWidgetByActionTag ( UIWidget * root , int tag ) <nl> { <nl> UIWidget * UIHelper : : seekActionWidgetByActionTag ( UIWidget * root , int tag ) <nl> { <nl> return root ; <nl> } <nl> - ccArray * arrayRootChildren = root - > getChildren ( ) - > data ; <nl> + cocos2d : : ccArray * arrayRootChildren = root - > getChildren ( ) - > data ; <nl> int length = arrayRootChildren - > num ; <nl> for ( int i = 0 ; i < length ; i + + ) <nl> { <nl> mmm a / cocos / gui / UIHelper . h <nl> ppp b / cocos / gui / UIHelper . h <nl> <nl> # ifndef __UIHELPER_H__ <nl> # define __UIHELPER_H__ <nl> <nl> - # include " gui / UIInputManager . h " <nl> - # include " cocostudio / CSContentJsonDictionary . h " <nl> - <nl> - <nl> - # define CCUIHELPER gui : : UIHelper : : instance ( ) <nl> - <nl> namespace gui { <nl> <nl> + / * * <nl> + * @ js NA <nl> + * @ lua NA <nl> + * / <nl> class UIHelper <nl> { <nl> public : <nl> - / * * <nl> - * Default constructor <nl> - * / <nl> - UIHelper ( ) ; <nl> - <nl> - / * * <nl> - * Default destructor <nl> - * / <nl> - ~ UIHelper ( ) ; <nl> - <nl> - / / initializes state of UIHelper . <nl> - void init ( ) ; <nl> - <nl> - / * * <nl> - * Load a widget with json file . <nl> - * <nl> - * @ return a widget created with json file . <nl> - * / <nl> - UIWidget * createWidgetFromJsonFile ( const char * fileName ) ; <nl> - <nl> - / / get instance <nl> - static UIHelper * instance ( ) ; <nl> - <nl> - / / release instance <nl> - static void purgeUIHelper ( ) ; <nl> - <nl> - / / add a plist file for loading widget ' s texture . <nl> - void addSpriteFrame ( const char * fileName ) ; <nl> - <nl> - / / remove a plist file for loading widget ' s texture . <nl> - void removeSpriteFrame ( const char * fileName ) ; <nl> - <nl> - / / remove all plist files for loading widget ' s texture . <nl> - void removeAllSpriteFrame ( ) ; <nl> - <nl> + <nl> / * * <nl> * Finds a widget whose tag equals to param tag from root widget . <nl> * <nl> class UIHelper <nl> * <nl> * @ return finded result . <nl> * / <nl> - UIWidget * seekWidgetByTag ( UIWidget * root , int tag ) ; <nl> + static UIWidget * seekWidgetByTag ( UIWidget * root , int tag ) ; <nl> <nl> / * * <nl> * Finds a widget whose name equals to param name from root widget . <nl> class UIHelper <nl> * <nl> * @ return finded result . <nl> * / <nl> - UIWidget * seekWidgetByName ( UIWidget * root , const char * name ) ; <nl> + static UIWidget * seekWidgetByName ( UIWidget * root , const char * name ) ; <nl> <nl> / * * <nl> * Finds a widget whose name equals to param name from root widget . <nl> class UIHelper <nl> * <nl> * @ return finded result . <nl> * / <nl> - UIWidget * seekWidgetByRelativeName ( UIWidget * root , const char * name ) ; <nl> - void setFileDesignWidth ( float width ) ; <nl> - float getFileDesignWidth ( ) ; <nl> - void setFileDesignHeight ( float height ) ; <nl> - float getFileDesignHeight ( ) ; <nl> - / * temp action * / <nl> - UIWidget * seekActionWidgetByActionTag ( UIWidget * root , int tag ) ; <nl> - protected : <nl> + static UIWidget * seekWidgetByRelativeName ( UIWidget * root , const char * name ) ; <nl> <nl> - float _fileDesignWidth ; <nl> - float _fileDesignHeight ; <nl> - / / texture <nl> - cocos2d : : Array * _textureFiles ; <nl> + / * temp action * / <nl> + static UIWidget * seekActionWidgetByActionTag ( UIWidget * root , int tag ) ; <nl> } ; <nl> <nl> } <nl> mmm a / cocos / gui / UIImageView . cpp <nl> ppp b / cocos / gui / UIImageView . cpp <nl> <nl> # include " gui / UIImageView . h " <nl> # include " extensions / GUI / CCControlExtension / CCScale9Sprite . h " <nl> <nl> - using namespace cocos2d ; <nl> - using namespace cocos2d : : extension ; <nl> - <nl> namespace gui { <nl> <nl> + <nl> # define DYNAMIC_CAST_CCSPRITE dynamic_cast < cocos2d : : Sprite * > ( _imageRenderer ) <nl> # define DYNAMIC_CAST_SCALE9SPRITE dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _imageRenderer ) <nl> <nl> _touchRelease ( false ) , <nl> _doubleClickEnabled ( false ) , <nl> _scale9Enabled ( false ) , <nl> _prevIgnoreSize ( true ) , <nl> - _capInsets ( Rect : : ZERO ) , <nl> + _capInsets ( cocos2d : : Rect : : ZERO ) , <nl> _imageRenderer ( NULL ) , <nl> _textureFile ( " " ) , <nl> _imageTexType ( UI_TEX_TYPE_LOCAL ) , <nl> UIImageView * UIImageView : : create ( ) <nl> void UIImageView : : initRenderer ( ) <nl> { <nl> UIWidget : : initRenderer ( ) ; <nl> - _imageRenderer = Sprite : : create ( ) ; <nl> + _imageRenderer = cocos2d : : Sprite : : create ( ) ; <nl> _renderer - > addChild ( _imageRenderer ) ; <nl> } <nl> <nl> void UIImageView : : loadTexture ( const char * fileName , TextureResType texType ) <nl> DYNAMIC_CAST_SCALE9SPRITE - > initWithFile ( fileName ) ; <nl> DYNAMIC_CAST_SCALE9SPRITE - > setColor ( getColor ( ) ) ; <nl> DYNAMIC_CAST_SCALE9SPRITE - > setOpacity ( getOpacity ( ) ) ; <nl> + DYNAMIC_CAST_SCALE9SPRITE - > setCapInsets ( _capInsets ) ; <nl> } <nl> else <nl> { <nl> void UIImageView : : loadTexture ( const char * fileName , TextureResType texType ) <nl> DYNAMIC_CAST_SCALE9SPRITE - > initWithSpriteFrameName ( fileName ) ; <nl> DYNAMIC_CAST_SCALE9SPRITE - > setColor ( getColor ( ) ) ; <nl> DYNAMIC_CAST_SCALE9SPRITE - > setOpacity ( getOpacity ( ) ) ; <nl> + DYNAMIC_CAST_SCALE9SPRITE - > setCapInsets ( _capInsets ) ; <nl> } <nl> else <nl> { <nl> void UIImageView : : loadTexture ( const char * fileName , TextureResType texType ) <nl> imageTextureScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - void UIImageView : : setTextureRect ( const Rect & rect ) <nl> + void UIImageView : : setTextureRect ( const cocos2d : : Rect & rect ) <nl> { <nl> if ( _scale9Enabled ) <nl> { <nl> void UIImageView : : setTextureRect ( const Rect & rect ) <nl> } <nl> } <nl> <nl> - bool UIImageView : : onTouchBegan ( const Point & touchPoint ) <nl> + bool UIImageView : : onTouchBegan ( const cocos2d : : Point & touchPoint ) <nl> { <nl> setFocused ( true ) ; <nl> _touchStartPos . x = touchPoint . x ; <nl> bool UIImageView : : onTouchBegan ( const Point & touchPoint ) <nl> return _touchPassedEnabled ; <nl> } <nl> <nl> - void UIImageView : : onTouchEnded ( const Point & touchPoint ) <nl> + void UIImageView : : onTouchEnded ( const cocos2d : : Point & touchPoint ) <nl> { <nl> if ( _doubleClickEnabled ) <nl> { <nl> void UIImageView : : setScale9Enabled ( bool able ) <nl> _imageRenderer = NULL ; <nl> if ( _scale9Enabled ) <nl> { <nl> - _imageRenderer = extension : : Scale9Sprite : : create ( ) ; <nl> + _imageRenderer = cocos2d : : extension : : Scale9Sprite : : create ( ) ; <nl> } <nl> else <nl> { <nl> - _imageRenderer = CCSprite : : create ( ) ; <nl> + _imageRenderer = cocos2d : : Sprite : : create ( ) ; <nl> } <nl> loadTexture ( _textureFile . c_str ( ) , _imageTexType ) ; <nl> _renderer - > addChild ( _imageRenderer ) ; <nl> void UIImageView : : ignoreContentAdaptWithSize ( bool ignore ) <nl> } <nl> } <nl> <nl> - void UIImageView : : setCapInsets ( const Rect & capInsets ) <nl> + void UIImageView : : setCapInsets ( const cocos2d : : Rect & capInsets ) <nl> { <nl> _capInsets = capInsets ; <nl> if ( ! _scale9Enabled ) <nl> void UIImageView : : setCapInsets ( const Rect & capInsets ) <nl> DYNAMIC_CAST_SCALE9SPRITE - > setCapInsets ( capInsets ) ; <nl> } <nl> <nl> - void UIImageView : : setAnchorPoint ( const Point & pt ) <nl> + void UIImageView : : setAnchorPoint ( const cocos2d : : Point & pt ) <nl> { <nl> UIWidget : : setAnchorPoint ( pt ) ; <nl> _imageRenderer - > setAnchorPoint ( pt ) ; <nl> void UIImageView : : onSizeChanged ( ) <nl> imageTextureScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - const Size & UIImageView : : getContentSize ( ) const <nl> + const cocos2d : : Size & UIImageView : : getContentSize ( ) const <nl> { <nl> return _imageTextureSize ; <nl> } <nl> <nl> - Node * UIImageView : : getVirtualRenderer ( ) <nl> + cocos2d : : Node * UIImageView : : getVirtualRenderer ( ) <nl> { <nl> return _imageRenderer ; <nl> } <nl> void UIImageView : : imageTextureScaleChangedWithSize ( ) <nl> { <nl> if ( _scale9Enabled ) <nl> { <nl> - dynamic_cast < Scale9Sprite * > ( _imageRenderer ) - > setPreferredSize ( _size ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _imageRenderer ) - > setPreferredSize ( _size ) ; <nl> } <nl> else <nl> { <nl> - Size textureSize = _imageRenderer - > getContentSize ( ) ; <nl> + cocos2d : : Size textureSize = _imageRenderer - > getContentSize ( ) ; <nl> if ( textureSize . width < = 0 . 0f | | textureSize . height < = 0 . 0f ) <nl> { <nl> _imageRenderer - > setScale ( 1 . 0f ) ; <nl> const char * UIImageView : : getDescription ( ) const <nl> return " ImageView " ; <nl> } <nl> <nl> + UIWidget * UIImageView : : createCloneInstance ( ) <nl> + { <nl> + return UIImageView : : create ( ) ; <nl> + } <nl> + <nl> + void UIImageView : : copySpecialProperties ( UIWidget * widget ) <nl> + { <nl> + UIImageView * imageView = dynamic_cast < UIImageView * > ( widget ) ; <nl> + if ( imageView ) <nl> + { <nl> + _prevIgnoreSize = imageView - > _prevIgnoreSize ; <nl> + setScale9Enabled ( imageView - > _scale9Enabled ) ; <nl> + loadTexture ( imageView - > _textureFile . c_str ( ) , imageView - > _imageTexType ) ; <nl> + setCapInsets ( imageView - > _capInsets ) ; <nl> + } <nl> + } <nl> + <nl> } <nl> \ No newline at end of file <nl> mmm a / cocos / gui / UIImageView . h <nl> ppp b / cocos / gui / UIImageView . h <nl> <nl> <nl> namespace gui { <nl> <nl> + / * * <nl> + * @ js NA <nl> + * @ lua NA <nl> + * / <nl> class UIImageView : public UIWidget <nl> { <nl> public : <nl> class UIImageView : public UIWidget <nl> / / override " ignoreContentAdaptWithSize " method of widget . <nl> virtual void ignoreContentAdaptWithSize ( bool ignore ) ; <nl> <nl> - <nl> + / * * <nl> + * Returns the " class name " of widget . <nl> + * / <nl> + virtual const char * getDescription ( ) const ; <nl> <nl> void setDoubleClickEnabled ( bool able ) ; <nl> void doubleClickEvent ( ) ; <nl> void checkDoubleClick ( float dt ) ; <nl> virtual const cocos2d : : Size & getContentSize ( ) const ; <nl> virtual cocos2d : : Node * getVirtualRenderer ( ) ; <nl> - <nl> - / * * <nl> - * Returns the " class name " of widget . <nl> - * / <nl> - virtual const char * getDescription ( ) const ; <nl> protected : <nl> virtual void initRenderer ( ) ; <nl> virtual void onSizeChanged ( ) ; <nl> void imageTextureScaleChangedWithSize ( ) ; <nl> + virtual UIWidget * createCloneInstance ( ) ; <nl> + virtual void copySpecialProperties ( UIWidget * model ) ; <nl> protected : <nl> int _clickCount ; <nl> float _clickTimeInterval ; <nl> mmm a / cocos / gui / UIInputManager . cpp <nl> ppp b / cocos / gui / UIInputManager . cpp <nl> _longClickRecordTime ( 0 . 0 ) , <nl> _checkedDoubleClickWidget ( NULL ) , <nl> _rootWidget ( NULL ) <nl> { <nl> - _manageredWidget = CCArray : : create ( ) ; <nl> + _manageredWidget = Array : : create ( ) ; <nl> _manageredWidget - > retain ( ) ; <nl> - _checkedDoubleClickWidget = CCArray : : create ( ) ; <nl> + _checkedDoubleClickWidget = Array : : create ( ) ; <nl> _checkedDoubleClickWidget - > retain ( ) ; <nl> - _selectedWidgets = CCArray : : create ( ) ; <nl> + _selectedWidgets = Array : : create ( ) ; <nl> _selectedWidgets - > retain ( ) ; <nl> } <nl> <nl> mmm a / cocos / gui / UIInputManager . h <nl> ppp b / cocos / gui / UIInputManager . h <nl> <nl> # define __UIINPUTMANAGER_H__ <nl> <nl> # include " cocos2d . h " <nl> - # include " gui / Layout . h " <nl> + # include " gui / UILayout . h " <nl> <nl> namespace gui { <nl> <nl> class UIInputManager <nl> / * * <nl> * Default destructor <nl> * / <nl> - ~ UIInputManager ( ) ; <nl> + virtual ~ UIInputManager ( ) ; <nl> <nl> / * * <nl> * Regist a widget to input manager . <nl> mmm a / cocos / gui / UILabel . cpp <nl> ppp b / cocos / gui / UILabel . cpp <nl> <nl> <nl> # include " gui / UILabel . h " <nl> <nl> - using namespace cocos2d ; <nl> - <nl> namespace gui { <nl> <nl> + <nl> UILabel : : UILabel ( ) : <nl> _touchScaleChangeEnabled ( false ) , <nl> _normalScaleValue ( 1 . 0f ) , <nl> bool UILabel : : init ( ) <nl> void UILabel : : initRenderer ( ) <nl> { <nl> UIWidget : : initRenderer ( ) ; <nl> - _labelRenderer = CCLabelTTF : : create ( ) ; <nl> + _labelRenderer = cocos2d : : LabelTTF : : create ( ) ; <nl> _renderer - > addChild ( _labelRenderer ) ; <nl> } <nl> <nl> int UILabel : : getStringLength ( ) <nl> <nl> void UILabel : : setFontSize ( int size ) <nl> { <nl> + _fontSize = size ; <nl> _labelRenderer - > setFontSize ( size ) ; <nl> labelScaleChangedWithSize ( ) ; <nl> } <nl> <nl> void UILabel : : setFontName ( const char * name ) <nl> { <nl> + _fontName = name ; <nl> _labelRenderer - > setFontName ( name ) ; <nl> labelScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - void UILabel : : setTextAreaSize ( const Size & size ) <nl> + void UILabel : : setTextAreaSize ( const cocos2d : : Size & size ) <nl> { <nl> _labelRenderer - > setDimensions ( size ) ; <nl> labelScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - void UILabel : : setTextHorizontalAlignment ( TextHAlignment alignment ) <nl> + void UILabel : : setTextHorizontalAlignment ( cocos2d : : TextHAlignment alignment ) <nl> { <nl> _labelRenderer - > setHorizontalAlignment ( alignment ) ; <nl> labelScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - void UILabel : : setTextVerticalAlignment ( TextVAlignment alignment ) <nl> + void UILabel : : setTextVerticalAlignment ( cocos2d : : TextVAlignment alignment ) <nl> { <nl> _labelRenderer - > setVerticalAlignment ( alignment ) ; <nl> labelScaleChangedWithSize ( ) ; <nl> bool UILabel : : isFlipY ( ) <nl> return _labelRenderer - > isFlippedY ( ) ; <nl> } <nl> <nl> - void UILabel : : setAnchorPoint ( const Point & pt ) <nl> + void UILabel : : setAnchorPoint ( const cocos2d : : Point & pt ) <nl> { <nl> UIWidget : : setAnchorPoint ( pt ) ; <nl> _labelRenderer - > setAnchorPoint ( pt ) ; <nl> void UILabel : : onSizeChanged ( ) <nl> labelScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - const Size & UILabel : : getContentSize ( ) const <nl> + const cocos2d : : Size & UILabel : : getContentSize ( ) const <nl> { <nl> return _labelRenderer - > getContentSize ( ) ; <nl> } <nl> <nl> - Node * UILabel : : getVirtualRenderer ( ) <nl> + cocos2d : : Node * UILabel : : getVirtualRenderer ( ) <nl> { <nl> return _labelRenderer ; <nl> } <nl> void UILabel : : labelScaleChangedWithSize ( ) <nl> } <nl> else <nl> { <nl> - Size textureSize = _labelRenderer - > getContentSize ( ) ; <nl> + cocos2d : : Size textureSize = _labelRenderer - > getContentSize ( ) ; <nl> if ( textureSize . width < = 0 . 0f | | textureSize . height < = 0 . 0f ) <nl> { <nl> _labelRenderer - > setScale ( 1 . 0f ) ; <nl> void UILabel : : labelScaleChangedWithSize ( ) <nl> _labelRenderer - > setScaleX ( scaleX ) ; <nl> _labelRenderer - > setScaleY ( scaleY ) ; <nl> } <nl> + <nl> } <nl> <nl> const char * UILabel : : getDescription ( ) const <nl> const char * UILabel : : getDescription ( ) const <nl> return " Label " ; <nl> } <nl> <nl> + UIWidget * UILabel : : createCloneInstance ( ) <nl> + { <nl> + return UILabel : : create ( ) ; <nl> + } <nl> + <nl> + void UILabel : : copySpecialProperties ( UIWidget * widget ) <nl> + { <nl> + UILabel * label = dynamic_cast < UILabel * > ( widget ) ; <nl> + if ( label ) <nl> + { <nl> + setFontName ( label - > _fontName . c_str ( ) ) ; <nl> + setFontSize ( label - > _labelRenderer - > getFontSize ( ) ) ; <nl> + setText ( label - > getStringValue ( ) ) ; <nl> + setTouchScaleChangeEnabled ( label - > _touchScaleChangeEnabled ) ; <nl> + } <nl> + } <nl> + <nl> } <nl> \ No newline at end of file <nl> mmm a / cocos / gui / UILabel . h <nl> ppp b / cocos / gui / UILabel . h <nl> <nl> <nl> # include " gui / UIWidget . h " <nl> <nl> + <nl> namespace gui { <nl> <nl> + / * * <nl> + * @ js NA <nl> + * @ lua NA <nl> + * / <nl> class UILabel : public UIWidget <nl> { <nl> public : <nl> class UILabel : public UIWidget <nl> <nl> void setTextAreaSize ( const cocos2d : : Size & size ) ; <nl> void setTextHorizontalAlignment ( cocos2d : : TextHAlignment alignment ) ; <nl> - void setTextVerticalAlignment ( cocos2d : : TextVAlignment alignment ) ; <nl> - <nl> - <nl> - void setTouchScaleChangeAble ( bool able ) { setTouchScaleChangeEnabled ( able ) ; } ; <nl> - bool getTouchScaleChangeAble ( ) { return isTouchScaleChangeEnabled ( ) ; } ; <nl> + void setTextVerticalAlignment ( cocos2d : : TextVAlignment alignment ) ; <nl> protected : <nl> virtual bool init ( ) ; <nl> virtual void initRenderer ( ) ; <nl> class UILabel : public UIWidget <nl> virtual void onSizeChanged ( ) ; <nl> void clickScale ( float scale ) ; <nl> void labelScaleChangedWithSize ( ) ; <nl> + virtual UIWidget * createCloneInstance ( ) ; <nl> + virtual void copySpecialProperties ( UIWidget * model ) ; <nl> protected : <nl> bool _touchScaleChangeEnabled ; <nl> float _normalScaleValue ; <nl> mmm a / cocos / gui / UILabelAtlas . cpp <nl> ppp b / cocos / gui / UILabelAtlas . cpp <nl> <nl> <nl> # include " gui / UILabelAtlas . h " <nl> <nl> - using namespace cocos2d ; <nl> - <nl> namespace gui { <nl> <nl> + <nl> UICCLabelAtlas : : UICCLabelAtlas ( ) <nl> { <nl> <nl> void UICCLabelAtlas : : setProperty ( const char * string , const char * charMapFile , un <nl> initWithString ( string , charMapFile , itemWidth , itemHeight , startCharMap ) ; <nl> } <nl> <nl> - void UICCLabelAtlas : : setProperty ( const char * string , Texture2D * texture , unsigned int itemWidth , unsigned int itemHeight , unsigned int startCharMap ) <nl> + void UICCLabelAtlas : : setProperty ( const char * string , cocos2d : : Texture2D * texture , unsigned int itemWidth , unsigned int itemHeight , unsigned int startCharMap ) <nl> { <nl> initWithString ( string , texture , itemWidth , itemHeight , startCharMap ) ; <nl> } <nl> void UICCLabelAtlas : : draw ( ) <nl> return ; <nl> } <nl> <nl> - CCAtlasNode : : draw ( ) ; <nl> + cocos2d : : AtlasNode : : draw ( ) ; <nl> } <nl> <nl> void UICCLabelAtlas : : updateDisplayedOpacity ( GLubyte opacity ) <nl> { <nl> - CCAtlasNode : : setOpacity ( opacity ) ; <nl> + cocos2d : : AtlasNode : : setOpacity ( opacity ) ; <nl> } <nl> <nl> <nl> <nl> <nl> UILabelAtlas : : UILabelAtlas ( ) : <nl> - _laberAtlasRenderer ( NULL ) <nl> + _laberAtlasRenderer ( NULL ) , <nl> + _stringValue ( " " ) , <nl> + _charMapFileName ( " " ) , <nl> + _itemWidth ( 0 ) , <nl> + _itemHeight ( 0 ) , <nl> + _startCharMap ( " " ) <nl> { <nl> + <nl> } <nl> <nl> UILabelAtlas : : ~ UILabelAtlas ( ) <nl> void UILabelAtlas : : initRenderer ( ) <nl> _renderer - > addChild ( _laberAtlasRenderer ) ; <nl> } <nl> <nl> - void UILabelAtlas : : setProperty ( const char * stringValue , const char * charMapFile , int itemWidth , int itemHeight , const char * startCharMap , bool useSpriteFrame ) <nl> + void UILabelAtlas : : setProperty ( const char * stringValue , const char * charMapFile , int itemWidth , int itemHeight , const char * startCharMap ) <nl> { <nl> + _stringValue = stringValue ; <nl> + _charMapFileName = charMapFile ; <nl> + _itemWidth = itemWidth ; <nl> + _itemHeight = itemHeight ; <nl> + _startCharMap = startCharMap ; <nl> _laberAtlasRenderer - > setProperty ( stringValue , charMapFile , itemWidth , itemHeight , ( int ) ( startCharMap [ 0 ] ) ) ; <nl> updateAnchorPoint ( ) ; <nl> labelAtlasScaleChangedWithSize ( ) ; <nl> void UILabelAtlas : : setProperty ( const char * stringValue , const char * charMapFile , <nl> <nl> void UILabelAtlas : : setStringValue ( const char * value ) <nl> { <nl> + _stringValue = value ; <nl> _laberAtlasRenderer - > setString ( value ) ; <nl> labelAtlasScaleChangedWithSize ( ) ; <nl> } <nl> const char * UILabelAtlas : : getStringValue ( ) <nl> return _laberAtlasRenderer - > getString ( ) ; <nl> } <nl> <nl> - void UILabelAtlas : : setAnchorPoint ( const Point & pt ) <nl> + void UILabelAtlas : : setAnchorPoint ( const cocos2d : : Point & pt ) <nl> { <nl> UIWidget : : setAnchorPoint ( pt ) ; <nl> - _laberAtlasRenderer - > setAnchorPoint ( Point ( pt . x , pt . y ) ) ; <nl> + _laberAtlasRenderer - > setAnchorPoint ( cocos2d : : Point ( pt . x , pt . y ) ) ; <nl> } <nl> <nl> void UILabelAtlas : : onSizeChanged ( ) <nl> void UILabelAtlas : : onSizeChanged ( ) <nl> labelAtlasScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - const Size & UILabelAtlas : : getContentSize ( ) const <nl> + const cocos2d : : Size & UILabelAtlas : : getContentSize ( ) const <nl> { <nl> return _laberAtlasRenderer - > getContentSize ( ) ; <nl> } <nl> <nl> - Node * UILabelAtlas : : getVirtualRenderer ( ) <nl> + cocos2d : : Node * UILabelAtlas : : getVirtualRenderer ( ) <nl> { <nl> return _laberAtlasRenderer ; <nl> } <nl> void UILabelAtlas : : labelAtlasScaleChangedWithSize ( ) <nl> } <nl> else <nl> { <nl> - Size textureSize = _laberAtlasRenderer - > getContentSize ( ) ; <nl> + cocos2d : : Size textureSize = _laberAtlasRenderer - > getContentSize ( ) ; <nl> if ( textureSize . width < = 0 . 0f | | textureSize . height < = 0 . 0f ) <nl> { <nl> _laberAtlasRenderer - > setScale ( 1 . 0f ) ; <nl> void UILabelAtlas : : labelAtlasScaleChangedWithSize ( ) <nl> <nl> const char * UILabelAtlas : : getDescription ( ) const <nl> { <nl> - return " LabelAtlase " ; <nl> + return " LabelAtlas " ; <nl> + } <nl> + <nl> + UIWidget * UILabelAtlas : : createCloneInstance ( ) <nl> + { <nl> + return UILabelAtlas : : create ( ) ; <nl> } <nl> <nl> + void UILabelAtlas : : copySpecialProperties ( UIWidget * widget ) <nl> + { <nl> + UILabelAtlas * labelAtlas = dynamic_cast < UILabelAtlas * > ( widget ) ; <nl> + if ( labelAtlas ) <nl> + { <nl> + setProperty ( labelAtlas - > _stringValue . c_str ( ) , labelAtlas - > _charMapFileName . c_str ( ) , labelAtlas - > _itemWidth , labelAtlas - > _itemHeight , labelAtlas - > _startCharMap . c_str ( ) ) ; <nl> + } <nl> + } <nl> + <nl> } <nl> \ No newline at end of file <nl> mmm a / cocos / gui / UILabelAtlas . h <nl> ppp b / cocos / gui / UILabelAtlas . h <nl> <nl> <nl> namespace gui { <nl> <nl> + / * * <nl> + * @ js NA <nl> + * @ lua NA <nl> + * / <nl> class UICCLabelAtlas : public cocos2d : : LabelAtlas <nl> { <nl> public : <nl> class UICCLabelAtlas : public cocos2d : : LabelAtlas <nl> virtual void updateDisplayedOpacity ( GLubyte opacity ) ; <nl> virtual void draw ( void ) ; <nl> } ; <nl> - <nl> + / * * <nl> + * @ js NA <nl> + * @ lua NA <nl> + * / <nl> class UILabelAtlas : public UIWidget <nl> { <nl> public : <nl> class UILabelAtlas : public UIWidget <nl> static UILabelAtlas * create ( ) ; <nl> <nl> / * * initializes the UILabelAtlas with a string , a char map file ( the atlas ) , the width and height of each element and the starting char of the atlas * / <nl> - void setProperty ( const char * stringValue , const char * charMapFile , int itemWidth , int itemHeight , const char * startCharMap , bool useSpriteFrame = false ) ; <nl> + void setProperty ( const char * stringValue , const char * charMapFile , int itemWidth , int itemHeight , const char * startCharMap ) ; <nl> <nl> / / set string value for labelatlas . <nl> void setStringValue ( const char * value ) ; <nl> class UILabelAtlas : public UIWidget <nl> * Returns the " class name " of widget . <nl> * / <nl> virtual const char * getDescription ( ) const ; <nl> + <nl> protected : <nl> virtual void initRenderer ( ) ; <nl> virtual void onSizeChanged ( ) ; <nl> void labelAtlasScaleChangedWithSize ( ) ; <nl> + virtual UIWidget * createCloneInstance ( ) ; <nl> + virtual void copySpecialProperties ( UIWidget * model ) ; <nl> protected : <nl> UICCLabelAtlas * _laberAtlasRenderer ; <nl> + std : : string _stringValue ; <nl> + std : : string _charMapFileName ; <nl> + int _itemWidth ; <nl> + int _itemHeight ; <nl> + std : : string _startCharMap ; <nl> } ; <nl> <nl> } <nl> mmm a / cocos / gui / UILabelBMFont . cpp <nl> ppp b / cocos / gui / UILabelBMFont . cpp <nl> <nl> <nl> # include " gui / UILabelBMFont . h " <nl> <nl> - using namespace cocos2d ; <nl> - <nl> namespace gui { <nl> <nl> UILabelBMFont : : UILabelBMFont ( ) : <nl> _labelBMFontRenderer ( NULL ) , <nl> - _fntFileHasInit ( false ) <nl> + _fntFileHasInit ( false ) , <nl> + _fntFileName ( " " ) , <nl> + _stringValue ( " " ) <nl> { <nl> } <nl> <nl> UILabelBMFont * UILabelBMFont : : create ( ) <nl> void UILabelBMFont : : initRenderer ( ) <nl> { <nl> UIWidget : : initRenderer ( ) ; <nl> - _labelBMFontRenderer = CCLabelBMFont : : create ( ) ; <nl> + _labelBMFontRenderer = cocos2d : : LabelBMFont : : create ( ) ; <nl> _renderer - > addChild ( _labelBMFontRenderer ) ; <nl> } <nl> <nl> void UILabelBMFont : : setFntFile ( const char * fileName ) <nl> { <nl> - if ( ! fileName | | strcmp ( fileName , " " ) = = 0 ) <nl> + if ( ! fileName | | std : : strcmp ( fileName , " " ) = = 0 ) <nl> { <nl> return ; <nl> } <nl> + _fntFileName = fileName ; <nl> _labelBMFontRenderer - > initWithString ( " " , fileName ) ; <nl> updateAnchorPoint ( ) ; <nl> labelBMFontScaleChangedWithSize ( ) ; <nl> _fntFileHasInit = true ; <nl> + setText ( _stringValue . c_str ( ) ) ; <nl> } <nl> <nl> void UILabelBMFont : : setText ( const char * value ) <nl> { <nl> - if ( ! value | | ! _fntFileHasInit ) <nl> + if ( ! value ) <nl> { <nl> return ; <nl> } <nl> - _labelBMFontRenderer - > setString ( value ) ; <nl> + _stringValue = value ; <nl> + if ( ! _fntFileHasInit ) <nl> + { <nl> + return ; <nl> + } <nl> + _labelBMFontRenderer - > setString ( value ) ; <nl> labelBMFontScaleChangedWithSize ( ) ; <nl> } <nl> <nl> const char * UILabelBMFont : : getStringValue ( ) <nl> { <nl> - return _labelBMFontRenderer - > getString ( ) ; <nl> + return _stringValue . c_str ( ) ; <nl> } <nl> <nl> - void UILabelBMFont : : setAnchorPoint ( const Point & pt ) <nl> + void UILabelBMFont : : setAnchorPoint ( const cocos2d : : Point & pt ) <nl> { <nl> UIWidget : : setAnchorPoint ( pt ) ; <nl> _labelBMFontRenderer - > setAnchorPoint ( pt ) ; <nl> void UILabelBMFont : : onSizeChanged ( ) <nl> labelBMFontScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - const Size & UILabelBMFont : : getContentSize ( ) const <nl> + const cocos2d : : Size & UILabelBMFont : : getContentSize ( ) const <nl> { <nl> return _labelBMFontRenderer - > getContentSize ( ) ; <nl> } <nl> <nl> - Node * UILabelBMFont : : getVirtualRenderer ( ) <nl> + cocos2d : : Node * UILabelBMFont : : getVirtualRenderer ( ) <nl> { <nl> return _labelBMFontRenderer ; <nl> } <nl> void UILabelBMFont : : labelBMFontScaleChangedWithSize ( ) <nl> } <nl> else <nl> { <nl> - Size textureSize = _labelBMFontRenderer - > getContentSize ( ) ; <nl> + cocos2d : : Size textureSize = _labelBMFontRenderer - > getContentSize ( ) ; <nl> if ( textureSize . width < = 0 . 0f | | textureSize . height < = 0 . 0f ) <nl> { <nl> _labelBMFontRenderer - > setScale ( 1 . 0f ) ; <nl> const char * UILabelBMFont : : getDescription ( ) const <nl> return " LabelBMFont " ; <nl> } <nl> <nl> + UIWidget * UILabelBMFont : : createCloneInstance ( ) <nl> + { <nl> + return UILabelBMFont : : create ( ) ; <nl> + } <nl> + <nl> + void UILabelBMFont : : copySpecialProperties ( UIWidget * widget ) <nl> + { <nl> + UILabelBMFont * labelBMFont = dynamic_cast < UILabelBMFont * > ( widget ) ; <nl> + if ( labelBMFont ) <nl> + { <nl> + setFntFile ( labelBMFont - > _fntFileName . c_str ( ) ) ; <nl> + setText ( labelBMFont - > _stringValue . c_str ( ) ) ; <nl> + } <nl> + } <nl> <nl> } <nl> \ No newline at end of file <nl> mmm a / cocos / gui / UILabelBMFont . h <nl> ppp b / cocos / gui / UILabelBMFont . h <nl> <nl> <nl> namespace gui { <nl> <nl> + / * * <nl> + * @ js NA <nl> + * @ lua NA <nl> + * / <nl> class UILabelBMFont : public UIWidget <nl> { <nl> public : <nl> class UILabelBMFont : public UIWidget <nl> virtual void setAnchorPoint ( const cocos2d : : Point & pt ) ; <nl> virtual const cocos2d : : Size & getContentSize ( ) const ; <nl> virtual cocos2d : : Node * getVirtualRenderer ( ) ; <nl> - <nl> / * * <nl> * Returns the " class name " of widget . <nl> * / <nl> class UILabelBMFont : public UIWidget <nl> virtual void initRenderer ( ) ; <nl> virtual void onSizeChanged ( ) ; <nl> void labelBMFontScaleChangedWithSize ( ) ; <nl> + virtual UIWidget * createCloneInstance ( ) ; <nl> + virtual void copySpecialProperties ( UIWidget * model ) ; <nl> protected : <nl> cocos2d : : LabelBMFont * _labelBMFontRenderer ; <nl> bool _fntFileHasInit ; <nl> + std : : string _fntFileName ; <nl> + std : : string _stringValue ; <nl> } ; <nl> <nl> } <nl> mmm a / cocos / gui / UILayer . cpp <nl> ppp b / cocos / gui / UILayer . cpp <nl> UIWidget * UILayer : : getWidgetByTag ( int tag ) <nl> { <nl> return NULL ; <nl> } <nl> - return CCUIHELPER - > seekWidgetByTag ( _rootWidget , tag ) ; <nl> + return UIHelper : : seekWidgetByTag ( _rootWidget , tag ) ; <nl> } <nl> <nl> UIWidget * UILayer : : getWidgetByName ( const char * name ) <nl> UIWidget * UILayer : : getWidgetByName ( const char * name ) <nl> { <nl> return NULL ; <nl> } <nl> - return CCUIHELPER - > seekWidgetByName ( _rootWidget , name ) ; <nl> + return UIHelper : : seekWidgetByName ( _rootWidget , name ) ; <nl> } <nl> <nl> UIRootWidget * UILayer : : getRootWidget ( ) <nl> new file mode 100644 <nl> index 000000000000 . . 70b66a0b565c <nl> mmm / dev / null <nl> ppp b / cocos / gui / UILayout . cpp <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 " gui / UILayout . h " <nl> + # include " gui / UILayer . h " <nl> + # include " gui / UIHelper . h " <nl> + # include " extensions / GUI / CCControlExtension / CCScale9Sprite . h " <nl> + <nl> + namespace gui { <nl> + <nl> + <nl> + # define DYNAMIC_CAST_CLIPPINGLAYER dynamic_cast < UIRectClippingNode * > ( _renderer ) <nl> + <nl> + UILayout : : UILayout ( ) : <nl> + _clippingEnabled ( false ) , <nl> + _backGroundScale9Enabled ( false ) , <nl> + _backGroundImage ( NULL ) , <nl> + _backGroundImageFileName ( " " ) , <nl> + _backGroundImageCapInsets ( cocos2d : : Rect : : ZERO ) , <nl> + _colorType ( LAYOUT_COLOR_NONE ) , <nl> + _bgImageTexType ( UI_TEX_TYPE_LOCAL ) , <nl> + _colorRender ( NULL ) , <nl> + _gradientRender ( NULL ) , <nl> + _cColor ( cocos2d : : Color3B : : WHITE ) , <nl> + _gStartColor ( cocos2d : : Color3B : : WHITE ) , <nl> + _gEndColor ( cocos2d : : Color3B : : WHITE ) , <nl> + _alongVector ( cocos2d : : Point ( 0 . 0f , - 1 . 0f ) ) , <nl> + _cOpacity ( 255 ) , <nl> + _backGroundImageTextureSize ( cocos2d : : Size : : ZERO ) , <nl> + _layoutType ( LAYOUT_ABSOLUTE ) <nl> + { <nl> + _widgetType = WidgetTypeContainer ; <nl> + } <nl> + <nl> + UILayout : : ~ UILayout ( ) <nl> + { <nl> + } <nl> + <nl> + UILayout * UILayout : : create ( ) <nl> + { <nl> + UILayout * layout = new UILayout ( ) ; <nl> + if ( layout & & layout - > init ( ) ) <nl> + { <nl> + layout - > autorelease ( ) ; <nl> + return layout ; <nl> + } <nl> + CC_SAFE_DELETE ( layout ) ; <nl> + return NULL ; <nl> + } <nl> + <nl> + bool UILayout : : init ( ) <nl> + { <nl> + _children = cocos2d : : Array : : create ( ) ; <nl> + _children - > retain ( ) ; <nl> + _layoutParameterDictionary = cocos2d : : Dictionary : : create ( ) ; <nl> + CC_SAFE_RETAIN ( _layoutParameterDictionary ) ; <nl> + initRenderer ( ) ; <nl> + _renderer - > retain ( ) ; <nl> + _renderer - > setZOrder ( _widgetZOrder ) ; <nl> + cocos2d : : RGBAProtocol * renderRGBA = dynamic_cast < cocos2d : : RGBAProtocol * > ( _renderer ) ; <nl> + if ( renderRGBA ) <nl> + { <nl> + renderRGBA - > setCascadeColorEnabled ( false ) ; <nl> + renderRGBA - > setCascadeOpacityEnabled ( false ) ; <nl> + } <nl> + ignoreContentAdaptWithSize ( false ) ; <nl> + setSize ( cocos2d : : Size : : ZERO ) ; <nl> + setBright ( true ) ; <nl> + setAnchorPoint ( cocos2d : : Point ( 0 , 0 ) ) ; <nl> + _scheduler = cocos2d : : Director : : getInstance ( ) - > getScheduler ( ) ; <nl> + CC_SAFE_RETAIN ( _scheduler ) ; <nl> + return true ; <nl> + } <nl> + <nl> + void UILayout : : initRenderer ( ) <nl> + { <nl> + _renderer = UIRectClippingNode : : create ( ) ; <nl> + } <nl> + <nl> + bool UILayout : : addChild ( UIWidget * child ) <nl> + { <nl> + supplyTheLayoutParameterLackToChild ( child ) ; <nl> + return UIWidget : : addChild ( child ) ; <nl> + } <nl> + <nl> + bool UILayout : : isClippingEnabled ( ) <nl> + { <nl> + return _clippingEnabled ; <nl> + } <nl> + <nl> + bool UILayout : : hitTest ( const cocos2d : : Point & pt ) <nl> + { <nl> + cocos2d : : Point nsp = _renderer - > convertToNodeSpace ( pt ) ; <nl> + cocos2d : : Rect bb = cocos2d : : Rect ( 0 . 0f , 0 . 0f , _size . width , _size . height ) ; <nl> + if ( nsp . x > = bb . origin . x & & nsp . x < = bb . origin . x + bb . size . width & & nsp . y > = bb . origin . y & & nsp . y < = bb . origin . y + bb . size . height ) <nl> + { <nl> + return true ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + void UILayout : : setClippingEnabled ( bool able ) <nl> + { <nl> + _clippingEnabled = able ; <nl> + DYNAMIC_CAST_CLIPPINGLAYER - > setClippingEnabled ( able ) ; <nl> + } <nl> + <nl> + void UILayout : : onSizeChanged ( ) <nl> + { <nl> + DYNAMIC_CAST_CLIPPINGLAYER - > setClippingSize ( _size ) ; <nl> + doLayout ( ) ; <nl> + if ( _backGroundImage ) <nl> + { <nl> + _backGroundImage - > setPosition ( cocos2d : : Point ( _size . width / 2 . 0f , _size . height / 2 . 0f ) ) ; <nl> + if ( _backGroundScale9Enabled ) <nl> + { <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _backGroundImage ) - > setPreferredSize ( _size ) ; <nl> + } <nl> + } <nl> + if ( _colorRender ) <nl> + { <nl> + _colorRender - > setContentSize ( _size ) ; <nl> + } <nl> + if ( _gradientRender ) <nl> + { <nl> + _gradientRender - > setContentSize ( _size ) ; <nl> + } <nl> + } <nl> + <nl> + void UILayout : : setBackGroundImageScale9Enabled ( bool able ) <nl> + { <nl> + if ( _backGroundScale9Enabled = = able ) <nl> + { <nl> + return ; <nl> + } <nl> + _renderer - > removeChild ( _backGroundImage , true ) ; <nl> + _backGroundImage = NULL ; <nl> + _backGroundScale9Enabled = able ; <nl> + if ( _backGroundScale9Enabled ) <nl> + { <nl> + _backGroundImage = cocos2d : : extension : : Scale9Sprite : : create ( ) ; <nl> + _renderer - > addChild ( _backGroundImage ) ; <nl> + } <nl> + else <nl> + { <nl> + _backGroundImage = cocos2d : : Sprite : : create ( ) ; <nl> + _renderer - > addChild ( _backGroundImage ) ; <nl> + } <nl> + _backGroundImage - > setZOrder ( - 1 ) ; <nl> + setBackGroundImage ( _backGroundImageFileName . c_str ( ) , _bgImageTexType ) ; <nl> + setBackGroundImageCapInsets ( _backGroundImageCapInsets ) ; <nl> + } <nl> + <nl> + void UILayout : : setBackGroundImage ( const char * fileName , TextureResType texType ) <nl> + { <nl> + if ( ! fileName | | strcmp ( fileName , " " ) = = 0 ) <nl> + { <nl> + return ; <nl> + } <nl> + if ( _backGroundImage = = NULL ) <nl> + { <nl> + addBackGroundImage ( ) ; <nl> + } <nl> + _backGroundImageFileName = fileName ; <nl> + _bgImageTexType = texType ; <nl> + if ( _backGroundScale9Enabled ) <nl> + { <nl> + switch ( _bgImageTexType ) <nl> + { <nl> + case UI_TEX_TYPE_LOCAL : <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _backGroundImage ) - > initWithFile ( fileName ) ; <nl> + break ; <nl> + case UI_TEX_TYPE_PLIST : <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _backGroundImage ) - > initWithSpriteFrameName ( fileName ) ; <nl> + break ; <nl> + default : <nl> + break ; <nl> + } <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _backGroundImage ) - > setPreferredSize ( _size ) ; <nl> + } <nl> + else <nl> + { <nl> + switch ( _bgImageTexType ) <nl> + { <nl> + case UI_TEX_TYPE_LOCAL : <nl> + dynamic_cast < cocos2d : : Sprite * > ( _backGroundImage ) - > initWithFile ( fileName ) ; <nl> + break ; <nl> + case UI_TEX_TYPE_PLIST : <nl> + dynamic_cast < cocos2d : : Sprite * > ( _backGroundImage ) - > initWithSpriteFrameName ( fileName ) ; <nl> + break ; <nl> + default : <nl> + break ; <nl> + } <nl> + } <nl> + if ( _backGroundScale9Enabled ) <nl> + { <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _backGroundImage ) - > setColor ( getColor ( ) ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _backGroundImage ) - > setOpacity ( getOpacity ( ) ) ; <nl> + } <nl> + else <nl> + { <nl> + dynamic_cast < cocos2d : : Sprite * > ( _backGroundImage ) - > setColor ( getColor ( ) ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _backGroundImage ) - > setOpacity ( getOpacity ( ) ) ; <nl> + } <nl> + _backGroundImageTextureSize = _backGroundImage - > getContentSize ( ) ; <nl> + _backGroundImage - > setPosition ( cocos2d : : Point ( _size . width / 2 . 0f , _size . height / 2 . 0f ) ) ; <nl> + } <nl> + <nl> + void UILayout : : setBackGroundImageCapInsets ( const cocos2d : : Rect & capInsets ) <nl> + { <nl> + _backGroundImageCapInsets = capInsets ; <nl> + if ( _backGroundScale9Enabled ) <nl> + { <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _backGroundImage ) - > setCapInsets ( capInsets ) ; <nl> + } <nl> + } <nl> + <nl> + void UILayout : : supplyTheLayoutParameterLackToChild ( UIWidget * child ) <nl> + { <nl> + if ( ! child ) <nl> + { <nl> + return ; <nl> + } <nl> + switch ( _layoutType ) <nl> + { <nl> + case LAYOUT_ABSOLUTE : <nl> + break ; <nl> + case LAYOUT_LINEAR_HORIZONTAL : <nl> + case LAYOUT_LINEAR_VERTICAL : <nl> + { <nl> + UILinearLayoutParameter * layoutParameter = dynamic_cast < UILinearLayoutParameter * > ( child - > getLayoutParameter ( LAYOUT_PARAMETER_LINEAR ) ) ; <nl> + if ( ! layoutParameter ) <nl> + { <nl> + child - > setLayoutParameter ( UILinearLayoutParameter : : create ( ) ) ; <nl> + } <nl> + break ; <nl> + } <nl> + case LAYOUT_RELATIVE : <nl> + { <nl> + UIRelativeLayoutParameter * layoutParameter = dynamic_cast < UIRelativeLayoutParameter * > ( child - > getLayoutParameter ( LAYOUT_PARAMETER_RELATIVE ) ) ; <nl> + if ( ! layoutParameter ) <nl> + { <nl> + child - > setLayoutParameter ( UIRelativeLayoutParameter : : create ( ) ) ; <nl> + } <nl> + break ; <nl> + } <nl> + default : <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + void UILayout : : addBackGroundImage ( ) <nl> + { <nl> + if ( _backGroundScale9Enabled ) <nl> + { <nl> + _backGroundImage = cocos2d : : extension : : Scale9Sprite : : create ( ) ; <nl> + _backGroundImage - > setZOrder ( - 1 ) ; <nl> + _renderer - > addChild ( _backGroundImage ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _backGroundImage ) - > setPreferredSize ( _size ) ; <nl> + } <nl> + else <nl> + { <nl> + _backGroundImage = cocos2d : : Sprite : : create ( ) ; <nl> + _backGroundImage - > setZOrder ( - 1 ) ; <nl> + _renderer - > addChild ( _backGroundImage ) ; <nl> + } <nl> + _backGroundImage - > setPosition ( cocos2d : : Point ( _size . width / 2 . 0f , _size . height / 2 . 0f ) ) ; <nl> + } <nl> + <nl> + void UILayout : : removeBackGroundImage ( ) <nl> + { <nl> + if ( ! _backGroundImage ) <nl> + { <nl> + return ; <nl> + } <nl> + _renderer - > removeChild ( _backGroundImage , true ) ; <nl> + _backGroundImage = NULL ; <nl> + _backGroundImageFileName = " " ; <nl> + _backGroundImageTextureSize = cocos2d : : Size : : ZERO ; <nl> + } <nl> + <nl> + void UILayout : : setBackGroundColorType ( LayoutBackGroundColorType type ) <nl> + { <nl> + if ( _colorType = = type ) <nl> + { <nl> + return ; <nl> + } <nl> + switch ( _colorType ) <nl> + { <nl> + case LAYOUT_COLOR_NONE : <nl> + if ( _colorRender ) <nl> + { <nl> + _renderer - > removeChild ( _colorRender , true ) ; <nl> + _colorRender = NULL ; <nl> + } <nl> + if ( _gradientRender ) <nl> + { <nl> + _renderer - > removeChild ( _gradientRender , true ) ; <nl> + _gradientRender = NULL ; <nl> + } <nl> + break ; <nl> + case LAYOUT_COLOR_SOLID : <nl> + if ( _colorRender ) <nl> + { <nl> + _renderer - > removeChild ( _colorRender , true ) ; <nl> + _colorRender = NULL ; <nl> + } <nl> + break ; <nl> + case LAYOUT_COLOR_GRADIENT : <nl> + if ( _gradientRender ) <nl> + { <nl> + _renderer - > removeChild ( _gradientRender , true ) ; <nl> + _gradientRender = NULL ; <nl> + } <nl> + break ; <nl> + default : <nl> + break ; <nl> + } <nl> + _colorType = type ; <nl> + switch ( _colorType ) <nl> + { <nl> + case LAYOUT_COLOR_NONE : <nl> + break ; <nl> + case LAYOUT_COLOR_SOLID : <nl> + _colorRender = cocos2d : : LayerColor : : create ( ) ; <nl> + _colorRender - > setContentSize ( _size ) ; <nl> + _colorRender - > setOpacity ( _cOpacity ) ; <nl> + _colorRender - > setColor ( _cColor ) ; <nl> + _renderer - > addChild ( _colorRender , - 2 ) ; <nl> + break ; <nl> + case LAYOUT_COLOR_GRADIENT : <nl> + _gradientRender = cocos2d : : LayerGradient : : create ( ) ; <nl> + _gradientRender - > setContentSize ( _size ) ; <nl> + _gradientRender - > setOpacity ( _cOpacity ) ; <nl> + _gradientRender - > setStartColor ( _gStartColor ) ; <nl> + _gradientRender - > setEndColor ( _gEndColor ) ; <nl> + _gradientRender - > setVector ( _alongVector ) ; <nl> + _renderer - > addChild ( _gradientRender , - 2 ) ; <nl> + break ; <nl> + default : <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + void UILayout : : setBackGroundColor ( const cocos2d : : Color3B & color ) <nl> + { <nl> + _cColor = color ; <nl> + if ( _colorRender ) <nl> + { <nl> + _colorRender - > setColor ( color ) ; <nl> + } <nl> + } <nl> + <nl> + void UILayout : : setBackGroundColor ( const cocos2d : : Color3B & startColor , const cocos2d : : Color3B & endColor ) <nl> + { <nl> + _gStartColor = startColor ; <nl> + if ( _gradientRender ) <nl> + { <nl> + _gradientRender - > setStartColor ( startColor ) ; <nl> + } <nl> + _gEndColor = endColor ; <nl> + if ( _gradientRender ) <nl> + { <nl> + _gradientRender - > setEndColor ( endColor ) ; <nl> + } <nl> + } <nl> + <nl> + void UILayout : : setBackGroundColorOpacity ( int opacity ) <nl> + { <nl> + _cOpacity = opacity ; <nl> + switch ( _colorType ) <nl> + { <nl> + case LAYOUT_COLOR_NONE : <nl> + break ; <nl> + case LAYOUT_COLOR_SOLID : <nl> + _colorRender - > setOpacity ( opacity ) ; <nl> + break ; <nl> + case LAYOUT_COLOR_GRADIENT : <nl> + _gradientRender - > setOpacity ( opacity ) ; <nl> + break ; <nl> + default : <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + void UILayout : : setBackGroundColorVector ( const cocos2d : : Point & vector ) <nl> + { <nl> + _alongVector = vector ; <nl> + if ( _gradientRender ) <nl> + { <nl> + _gradientRender - > setVector ( vector ) ; <nl> + } <nl> + } <nl> + <nl> + void UILayout : : setColor ( const cocos2d : : Color3B & color ) <nl> + { <nl> + UIWidget : : setColor ( color ) ; <nl> + if ( _backGroundImage ) <nl> + { <nl> + cocos2d : : RGBAProtocol * rgbap = dynamic_cast < cocos2d : : RGBAProtocol * > ( _backGroundImage ) ; <nl> + if ( rgbap ) <nl> + { <nl> + rgbap - > setColor ( color ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + void UILayout : : setOpacity ( int opacity ) <nl> + { <nl> + UIWidget : : setOpacity ( opacity ) ; <nl> + if ( _backGroundImage ) <nl> + { <nl> + cocos2d : : RGBAProtocol * rgbap = dynamic_cast < cocos2d : : RGBAProtocol * > ( _backGroundImage ) ; <nl> + if ( rgbap ) <nl> + { <nl> + rgbap - > setOpacity ( opacity ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + const cocos2d : : Size & UILayout : : getBackGroundImageTextureSize ( ) const <nl> + { <nl> + return _backGroundImageTextureSize ; <nl> + } <nl> + <nl> + const cocos2d : : Size & UILayout : : getContentSize ( ) const <nl> + { <nl> + return _renderer - > getContentSize ( ) ; <nl> + } <nl> + <nl> + void UILayout : : setLayoutType ( LayoutType type ) <nl> + { <nl> + _layoutType = type ; <nl> + <nl> + cocos2d : : ccArray * layoutChildrenArray = getChildren ( ) - > data ; <nl> + int length = layoutChildrenArray - > num ; <nl> + for ( int i = 0 ; i < length ; i + + ) <nl> + { <nl> + UIWidget * child = dynamic_cast < UIWidget * > ( layoutChildrenArray - > arr [ i ] ) ; <nl> + supplyTheLayoutParameterLackToChild ( child ) ; <nl> + } <nl> + } <nl> + <nl> + LayoutType UILayout : : getLayoutType ( ) const <nl> + { <nl> + return _layoutType ; <nl> + } <nl> + <nl> + void UILayout : : doLayout ( ) <nl> + { <nl> + switch ( _layoutType ) <nl> + { <nl> + case LAYOUT_ABSOLUTE : <nl> + break ; <nl> + case LAYOUT_LINEAR_VERTICAL : <nl> + { <nl> + cocos2d : : ccArray * layoutChildrenArray = getChildren ( ) - > data ; <nl> + int length = layoutChildrenArray - > num ; <nl> + cocos2d : : Size layoutSize = getSize ( ) ; <nl> + float topBoundary = layoutSize . height ; <nl> + for ( int i = 0 ; i < length ; + + i ) <nl> + { <nl> + UIWidget * child = dynamic_cast < UIWidget * > ( layoutChildrenArray - > arr [ i ] ) ; <nl> + UILinearLayoutParameter * layoutParameter = dynamic_cast < UILinearLayoutParameter * > ( child - > getLayoutParameter ( LAYOUT_PARAMETER_LINEAR ) ) ; <nl> + <nl> + if ( layoutParameter ) <nl> + { <nl> + UILinearGravity childGravity = layoutParameter - > getGravity ( ) ; <nl> + cocos2d : : Point ap = child - > getAnchorPoint ( ) ; <nl> + cocos2d : : Size cs = child - > getSize ( ) ; <nl> + float finalPosX = ap . x * cs . width ; <nl> + float finalPosY = topBoundary - ( ( 1 . 0f - ap . y ) * cs . height ) ; <nl> + switch ( childGravity ) <nl> + { <nl> + case LINEAR_GRAVITY_NONE : <nl> + case LINEAR_GRAVITY_LEFT : <nl> + break ; <nl> + case LINEAR_GRAVITY_RIGHT : <nl> + finalPosX = layoutSize . width - ( ( 1 . 0f - ap . x ) * cs . width ) ; <nl> + break ; <nl> + case LINEAR_GRAVITY_CENTER_HORIZONTAL : <nl> + finalPosX = layoutSize . width / 2 . 0f - cs . width * ( 0 . 5f - ap . x ) ; <nl> + break ; <nl> + default : <nl> + break ; <nl> + } <nl> + UIMargin mg = layoutParameter - > getMargin ( ) ; <nl> + finalPosX + = mg . left ; <nl> + finalPosY - = mg . top ; <nl> + child - > setPosition ( cocos2d : : Point ( finalPosX , finalPosY ) ) ; <nl> + topBoundary = child - > getBottomInParent ( ) - mg . bottom ; <nl> + } <nl> + } <nl> + break ; <nl> + } <nl> + case LAYOUT_LINEAR_HORIZONTAL : <nl> + { <nl> + cocos2d : : ccArray * layoutChildrenArray = getChildren ( ) - > data ; <nl> + int length = layoutChildrenArray - > num ; <nl> + cocos2d : : Size layoutSize = getSize ( ) ; <nl> + float leftBoundary = 0 . 0f ; <nl> + for ( int i = 0 ; i < length ; + + i ) <nl> + { <nl> + UIWidget * child = dynamic_cast < UIWidget * > ( layoutChildrenArray - > arr [ i ] ) ; <nl> + UILinearLayoutParameter * layoutParameter = dynamic_cast < UILinearLayoutParameter * > ( child - > getLayoutParameter ( LAYOUT_PARAMETER_LINEAR ) ) ; <nl> + <nl> + if ( layoutParameter ) <nl> + { <nl> + UILinearGravity childGravity = layoutParameter - > getGravity ( ) ; <nl> + cocos2d : : Point ap = child - > getAnchorPoint ( ) ; <nl> + cocos2d : : Size cs = child - > getSize ( ) ; <nl> + float finalPosX = leftBoundary + ( ap . x * cs . width ) ; <nl> + float finalPosY = layoutSize . height - ( 1 . 0f - ap . y ) * cs . height ; <nl> + switch ( childGravity ) <nl> + { <nl> + case LINEAR_GRAVITY_NONE : <nl> + case LINEAR_GRAVITY_TOP : <nl> + break ; <nl> + case LINEAR_GRAVITY_BOTTOM : <nl> + finalPosY = ap . y * cs . height ; <nl> + break ; <nl> + case LINEAR_GRAVITY_CENTER_VERTICAL : <nl> + finalPosY = layoutSize . height / 2 . 0f - cs . height * ( 0 . 5f - ap . y ) ; <nl> + break ; <nl> + default : <nl> + break ; <nl> + } <nl> + UIMargin mg = layoutParameter - > getMargin ( ) ; <nl> + finalPosX + = mg . left ; <nl> + finalPosY - = mg . top ; <nl> + child - > setPosition ( cocos2d : : Point ( finalPosX , finalPosY ) ) ; <nl> + leftBoundary = child - > getRightInParent ( ) + mg . right ; <nl> + } <nl> + } <nl> + break ; <nl> + } <nl> + case LAYOUT_RELATIVE : <nl> + { <nl> + cocos2d : : ccArray * layoutChildrenArray = getChildren ( ) - > data ; <nl> + int length = layoutChildrenArray - > num ; <nl> + int unlayoutChildCount = length ; <nl> + cocos2d : : Size layoutSize = getSize ( ) ; <nl> + <nl> + for ( int i = 0 ; i < length ; i + + ) <nl> + { <nl> + UIWidget * child = dynamic_cast < UIWidget * > ( layoutChildrenArray - > arr [ i ] ) ; <nl> + UIRelativeLayoutParameter * layoutParameter = dynamic_cast < UIRelativeLayoutParameter * > ( child - > getLayoutParameter ( LAYOUT_PARAMETER_RELATIVE ) ) ; <nl> + layoutParameter - > _put = false ; <nl> + } <nl> + <nl> + while ( unlayoutChildCount > 0 ) <nl> + { <nl> + for ( int i = 0 ; i < length ; i + + ) <nl> + { <nl> + UIWidget * child = dynamic_cast < UIWidget * > ( layoutChildrenArray - > arr [ i ] ) ; <nl> + UIRelativeLayoutParameter * layoutParameter = dynamic_cast < UIRelativeLayoutParameter * > ( child - > getLayoutParameter ( LAYOUT_PARAMETER_RELATIVE ) ) ; <nl> + <nl> + if ( layoutParameter ) <nl> + { <nl> + if ( layoutParameter - > _put ) <nl> + { <nl> + continue ; <nl> + } <nl> + cocos2d : : Point ap = child - > getAnchorPoint ( ) ; <nl> + cocos2d : : Size cs = child - > getSize ( ) ; <nl> + UIRelativeAlign align = layoutParameter - > getAlign ( ) ; <nl> + const char * relativeName = layoutParameter - > getRelativeToWidgetName ( ) ; <nl> + UIWidget * relativeWidget = NULL ; <nl> + UIRelativeLayoutParameter * relativeWidgetLP = NULL ; <nl> + float finalPosX = 0 . 0f ; <nl> + float finalPosY = 0 . 0f ; <nl> + if ( relativeName & & strcmp ( relativeName , " " ) ) <nl> + { <nl> + relativeWidget = UIHelper : : seekWidgetByRelativeName ( this , relativeName ) ; <nl> + if ( relativeWidget ) <nl> + { <nl> + relativeWidgetLP = dynamic_cast < UIRelativeLayoutParameter * > ( relativeWidget - > getLayoutParameter ( LAYOUT_PARAMETER_RELATIVE ) ) ; <nl> + } <nl> + } <nl> + switch ( align ) <nl> + { <nl> + case RELATIVE_ALIGN_NONE : <nl> + case RELATIVE_ALIGN_PARENT_TOP_LEFT : <nl> + finalPosX = ap . x * cs . width ; <nl> + finalPosY = layoutSize . height - ( ( 1 . 0f - ap . y ) * cs . height ) ; <nl> + break ; <nl> + case RELATIVE_ALIGN_PARENT_TOP_CENTER_HORIZONTAL : <nl> + finalPosX = layoutSize . width * 0 . 5f - cs . width * ( 0 . 5f - ap . x ) ; <nl> + finalPosY = layoutSize . height - ( ( 1 . 0f - ap . y ) * cs . height ) ; <nl> + break ; <nl> + case RELATIVE_ALIGN_PARENT_TOP_RIGHT : <nl> + finalPosX = layoutSize . width - ( ( 1 . 0f - ap . x ) * cs . width ) ; <nl> + finalPosY = layoutSize . height - ( ( 1 . 0f - ap . y ) * cs . height ) ; <nl> + break ; <nl> + case RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL : <nl> + finalPosX = ap . x * cs . width ; <nl> + finalPosY = layoutSize . height * 0 . 5f - cs . height * ( 0 . 5f - ap . y ) ; <nl> + break ; <nl> + case RELATIVE_CENTER_IN_PARENT : <nl> + finalPosX = layoutSize . width * 0 . 5f - cs . width * ( 0 . 5f - ap . x ) ; <nl> + finalPosY = layoutSize . height * 0 . 5f - cs . height * ( 0 . 5f - ap . y ) ; <nl> + break ; <nl> + case RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL : <nl> + finalPosX = layoutSize . width - ( ( 1 . 0f - ap . x ) * cs . width ) ; <nl> + finalPosY = layoutSize . height * 0 . 5f - cs . height * ( 0 . 5f - ap . y ) ; <nl> + break ; <nl> + case RELATIVE_ALIGN_PARENT_LEFT_BOTTOM : <nl> + finalPosX = ap . x * cs . width ; <nl> + finalPosY = ap . y * cs . height ; <nl> + break ; <nl> + case RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL : <nl> + finalPosX = layoutSize . width * 0 . 5f - cs . width * ( 0 . 5f - ap . x ) ; <nl> + finalPosY = ap . y * cs . height ; <nl> + break ; <nl> + case RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM : <nl> + finalPosX = layoutSize . width - ( ( 1 . 0f - ap . x ) * cs . width ) ; <nl> + finalPosY = ap . y * cs . height ; <nl> + break ; <nl> + <nl> + case RELATIVE_LOCATION_ABOVE_LEFTALIGN : <nl> + if ( relativeWidget ) <nl> + { <nl> + if ( relativeWidgetLP & & ! relativeWidgetLP - > _put ) <nl> + { <nl> + continue ; <nl> + } <nl> + float locationBottom = relativeWidget - > getTopInParent ( ) ; <nl> + float locationLeft = relativeWidget - > getLeftInParent ( ) ; <nl> + finalPosY = locationBottom + ap . y * cs . height ; <nl> + finalPosX = locationLeft + ap . x * cs . width ; <nl> + } <nl> + break ; <nl> + case RELATIVE_LOCATION_ABOVE_CENTER : <nl> + if ( relativeWidget ) <nl> + { <nl> + if ( relativeWidgetLP & & ! relativeWidgetLP - > _put ) <nl> + { <nl> + continue ; <nl> + } <nl> + cocos2d : : Size rbs = relativeWidget - > getSize ( ) ; <nl> + float locationBottom = relativeWidget - > getTopInParent ( ) ; <nl> + <nl> + finalPosY = locationBottom + ap . y * cs . height ; <nl> + finalPosX = relativeWidget - > getLeftInParent ( ) + rbs . width * 0 . 5f + ap . x * cs . width - cs . width * 0 . 5f ; <nl> + } <nl> + break ; <nl> + case RELATIVE_LOCATION_ABOVE_RIGHTALIGN : <nl> + if ( relativeWidget ) <nl> + { <nl> + if ( relativeWidgetLP & & ! relativeWidgetLP - > _put ) <nl> + { <nl> + continue ; <nl> + } <nl> + float locationBottom = relativeWidget - > getTopInParent ( ) ; <nl> + float locationRight = relativeWidget - > getRightInParent ( ) ; <nl> + finalPosY = locationBottom + ap . y * cs . height ; <nl> + finalPosX = locationRight - ( 1 . 0f - ap . x ) * cs . width ; <nl> + } <nl> + break ; <nl> + case RELATIVE_LOCATION_LEFT_OF_TOPALIGN : <nl> + if ( relativeWidget ) <nl> + { <nl> + if ( relativeWidgetLP & & ! relativeWidgetLP - > _put ) <nl> + { <nl> + continue ; <nl> + } <nl> + float locationTop = relativeWidget - > getTopInParent ( ) ; <nl> + float locationRight = relativeWidget - > getLeftInParent ( ) ; <nl> + finalPosY = locationTop - ( 1 . 0f - ap . y ) * cs . height ; <nl> + finalPosX = locationRight - ( 1 . 0f - ap . x ) * cs . width ; <nl> + } <nl> + break ; <nl> + case RELATIVE_LOCATION_LEFT_OF_CENTER : <nl> + if ( relativeWidget ) <nl> + { <nl> + if ( relativeWidgetLP & & ! relativeWidgetLP - > _put ) <nl> + { <nl> + continue ; <nl> + } <nl> + cocos2d : : Size rbs = relativeWidget - > getSize ( ) ; <nl> + float locationRight = relativeWidget - > getLeftInParent ( ) ; <nl> + finalPosX = locationRight - ( 1 . 0f - ap . x ) * cs . width ; <nl> + <nl> + finalPosY = relativeWidget - > getBottomInParent ( ) + rbs . height * 0 . 5f + ap . y * cs . height - cs . height * 0 . 5f ; <nl> + } <nl> + break ; <nl> + case RELATIVE_LOCATION_LEFT_OF_BOTTOMALIGN : <nl> + if ( relativeWidget ) <nl> + { <nl> + if ( relativeWidgetLP & & ! relativeWidgetLP - > _put ) <nl> + { <nl> + continue ; <nl> + } <nl> + float locationBottom = relativeWidget - > getBottomInParent ( ) ; <nl> + float locationRight = relativeWidget - > getLeftInParent ( ) ; <nl> + finalPosY = locationBottom + ap . y * cs . height ; <nl> + finalPosX = locationRight - ( 1 . 0f - ap . x ) * cs . width ; <nl> + } <nl> + break ; <nl> + case RELATIVE_LOCATION_RIGHT_OF_TOPALIGN : <nl> + if ( relativeWidget ) <nl> + { <nl> + if ( relativeWidgetLP & & ! relativeWidgetLP - > _put ) <nl> + { <nl> + continue ; <nl> + } <nl> + float locationTop = relativeWidget - > getTopInParent ( ) ; <nl> + float locationLeft = relativeWidget - > getRightInParent ( ) ; <nl> + finalPosY = locationTop - ( 1 . 0f - ap . y ) * cs . height ; <nl> + finalPosX = locationLeft + ap . x * cs . width ; <nl> + } <nl> + break ; <nl> + case RELATIVE_LOCATION_RIGHT_OF_CENTER : <nl> + if ( relativeWidget ) <nl> + { <nl> + if ( relativeWidgetLP & & ! relativeWidgetLP - > _put ) <nl> + { <nl> + continue ; <nl> + } <nl> + cocos2d : : Size rbs = relativeWidget - > getSize ( ) ; <nl> + float locationLeft = relativeWidget - > getRightInParent ( ) ; <nl> + finalPosX = locationLeft + ap . x * cs . width ; <nl> + <nl> + finalPosY = relativeWidget - > getBottomInParent ( ) + rbs . height * 0 . 5f + ap . y * cs . height - cs . height * 0 . 5f ; <nl> + } <nl> + break ; <nl> + case RELATIVE_LOCATION_RIGHT_OF_BOTTOMALIGN : <nl> + if ( relativeWidget ) <nl> + { <nl> + if ( relativeWidgetLP & & ! relativeWidgetLP - > _put ) <nl> + { <nl> + continue ; <nl> + } <nl> + float locationBottom = relativeWidget - > getBottomInParent ( ) ; <nl> + float locationLeft = relativeWidget - > getRightInParent ( ) ; <nl> + finalPosY = locationBottom + ap . y * cs . height ; <nl> + finalPosX = locationLeft + ap . x * cs . width ; <nl> + } <nl> + break ; <nl> + case RELATIVE_LOCATION_BELOW_LEFTALIGN : <nl> + if ( relativeWidget ) <nl> + { <nl> + if ( relativeWidgetLP & & ! relativeWidgetLP - > _put ) <nl> + { <nl> + continue ; <nl> + } <nl> + float locationTop = relativeWidget - > getBottomInParent ( ) ; <nl> + float locationLeft = relativeWidget - > getLeftInParent ( ) ; <nl> + finalPosY = locationTop - ( 1 . 0f - ap . y ) * cs . height ; <nl> + finalPosX = locationLeft + ap . x * cs . width ; <nl> + } <nl> + break ; <nl> + case RELATIVE_LOCATION_BELOW_CENTER : <nl> + if ( relativeWidget ) <nl> + { <nl> + if ( relativeWidgetLP & & ! relativeWidgetLP - > _put ) <nl> + { <nl> + continue ; <nl> + } <nl> + cocos2d : : Size rbs = relativeWidget - > getSize ( ) ; <nl> + float locationTop = relativeWidget - > getBottomInParent ( ) ; <nl> + <nl> + finalPosY = locationTop - ( 1 . 0f - ap . y ) * cs . height ; <nl> + finalPosX = relativeWidget - > getLeftInParent ( ) + rbs . width * 0 . 5f + ap . x * cs . width - cs . width * 0 . 5f ; <nl> + } <nl> + break ; <nl> + case RELATIVE_LOCATION_BELOW_RIGHTALIGN : <nl> + if ( relativeWidget ) <nl> + { <nl> + if ( relativeWidgetLP & & ! relativeWidgetLP - > _put ) <nl> + { <nl> + continue ; <nl> + } <nl> + float locationTop = relativeWidget - > getBottomInParent ( ) ; <nl> + float locationRight = relativeWidget - > getRightInParent ( ) ; <nl> + finalPosY = locationTop - ( 1 . 0f - ap . y ) * cs . height ; <nl> + finalPosX = locationRight - ( 1 . 0f - ap . x ) * cs . width ; <nl> + } <nl> + break ; <nl> + default : <nl> + break ; <nl> + } <nl> + UIMargin relativeWidgetMargin ; <nl> + UIMargin mg = layoutParameter - > getMargin ( ) ; <nl> + if ( relativeWidget ) <nl> + { <nl> + relativeWidgetMargin = relativeWidget - > getLayoutParameter ( LAYOUT_PARAMETER_RELATIVE ) - > getMargin ( ) ; <nl> + } <nl> + / / handle margin <nl> + switch ( align ) <nl> + { <nl> + case RELATIVE_ALIGN_NONE : <nl> + case RELATIVE_ALIGN_PARENT_TOP_LEFT : <nl> + finalPosX + = mg . left ; <nl> + finalPosY - = mg . top ; <nl> + break ; <nl> + case RELATIVE_ALIGN_PARENT_TOP_CENTER_HORIZONTAL : <nl> + finalPosY - = mg . top ; <nl> + break ; <nl> + case RELATIVE_ALIGN_PARENT_TOP_RIGHT : <nl> + finalPosX - = mg . right ; <nl> + finalPosY - = mg . top ; <nl> + break ; <nl> + case RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL : <nl> + finalPosX + = mg . left ; <nl> + break ; <nl> + case RELATIVE_CENTER_IN_PARENT : <nl> + break ; <nl> + case RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL : <nl> + finalPosX - = mg . right ; <nl> + break ; <nl> + case RELATIVE_ALIGN_PARENT_LEFT_BOTTOM : <nl> + finalPosX + = mg . left ; <nl> + finalPosY + = mg . bottom ; <nl> + break ; <nl> + case RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL : <nl> + finalPosY + = mg . bottom ; <nl> + break ; <nl> + case RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM : <nl> + finalPosX - = mg . right ; <nl> + finalPosY + = mg . bottom ; <nl> + break ; <nl> + <nl> + case RELATIVE_LOCATION_ABOVE_LEFTALIGN : <nl> + case RELATIVE_LOCATION_ABOVE_CENTER : <nl> + case RELATIVE_LOCATION_ABOVE_RIGHTALIGN : <nl> + finalPosY + = mg . bottom ; <nl> + finalPosY + = relativeWidgetMargin . top ; <nl> + break ; <nl> + case RELATIVE_LOCATION_LEFT_OF_TOPALIGN : <nl> + case RELATIVE_LOCATION_LEFT_OF_CENTER : <nl> + case RELATIVE_LOCATION_LEFT_OF_BOTTOMALIGN : <nl> + finalPosX - = mg . right ; <nl> + finalPosX - = relativeWidgetMargin . left ; <nl> + break ; <nl> + case RELATIVE_LOCATION_RIGHT_OF_TOPALIGN : <nl> + case RELATIVE_LOCATION_RIGHT_OF_CENTER : <nl> + case RELATIVE_LOCATION_RIGHT_OF_BOTTOMALIGN : <nl> + finalPosX + = mg . left ; <nl> + finalPosX + = relativeWidgetMargin . right ; <nl> + break ; <nl> + case RELATIVE_LOCATION_BELOW_LEFTALIGN : <nl> + case RELATIVE_LOCATION_BELOW_CENTER : <nl> + case RELATIVE_LOCATION_BELOW_RIGHTALIGN : <nl> + finalPosY - = mg . top ; <nl> + finalPosY - = relativeWidgetMargin . bottom ; <nl> + break ; <nl> + default : <nl> + break ; <nl> + } <nl> + child - > setPosition ( cocos2d : : Point ( finalPosX , finalPosY ) ) ; <nl> + layoutParameter - > _put = true ; <nl> + unlayoutChildCount - - ; <nl> + } <nl> + } <nl> + } <nl> + break ; <nl> + } <nl> + default : <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + const char * UILayout : : getDescription ( ) const <nl> + { <nl> + return " Layout " ; <nl> + } <nl> + <nl> + UIWidget * UILayout : : createCloneInstance ( ) <nl> + { <nl> + return UILayout : : create ( ) ; <nl> + } <nl> + <nl> + void UILayout : : copyClonedWidgetChildren ( UIWidget * model ) <nl> + { <nl> + UIWidget : : copyClonedWidgetChildren ( model ) ; <nl> + doLayout ( ) ; <nl> + } <nl> + <nl> + void UILayout : : copySpecialProperties ( UIWidget * widget ) <nl> + { <nl> + UILayout * layout = dynamic_cast < UILayout * > ( widget ) ; <nl> + if ( layout ) <nl> + { <nl> + setBackGroundImageScale9Enabled ( layout - > _backGroundScale9Enabled ) ; <nl> + setBackGroundImage ( layout - > _backGroundImageFileName . c_str ( ) , layout - > _bgImageTexType ) ; <nl> + setBackGroundImageCapInsets ( layout - > _backGroundImageCapInsets ) ; <nl> + setBackGroundColorType ( layout - > _colorType ) ; <nl> + setBackGroundColor ( layout - > _cColor ) ; <nl> + setBackGroundColor ( layout - > _gStartColor , layout - > _gEndColor ) ; <nl> + setBackGroundColorOpacity ( layout - > _cOpacity ) ; <nl> + setBackGroundColorVector ( layout - > _alongVector ) ; <nl> + setLayoutType ( layout - > _layoutType ) ; <nl> + setClippingEnabled ( layout - > _clippingEnabled ) ; <nl> + } <nl> + } <nl> + <nl> + UIRectClippingNode : : UIRectClippingNode ( ) : <nl> + _innerStencil ( NULL ) , <nl> + _enabled ( true ) , <nl> + _clippingSize ( cocos2d : : Size ( 50 . 0f , 50 . 0f ) ) , <nl> + _clippingEnabled ( false ) <nl> + { <nl> + <nl> + } <nl> + <nl> + UIRectClippingNode : : ~ UIRectClippingNode ( ) <nl> + { <nl> + <nl> + } <nl> + <nl> + UIRectClippingNode * UIRectClippingNode : : create ( ) <nl> + { <nl> + UIRectClippingNode * pRet = new UIRectClippingNode ( ) ; <nl> + if ( pRet & & pRet - > init ( ) ) <nl> + { <nl> + pRet - > autorelease ( ) ; <nl> + } <nl> + else <nl> + { <nl> + CC_SAFE_DELETE ( pRet ) ; <nl> + } <nl> + <nl> + return pRet ; <nl> + } <nl> + <nl> + bool UIRectClippingNode : : init ( ) <nl> + { <nl> + _innerStencil = cocos2d : : DrawNode : : create ( ) ; <nl> + rect [ 0 ] = cocos2d : : Point ( 0 , 0 ) ; <nl> + rect [ 1 ] = cocos2d : : Point ( _clippingSize . width , 0 ) ; <nl> + rect [ 2 ] = cocos2d : : Point ( _clippingSize . width , _clippingSize . height ) ; <nl> + rect [ 3 ] = cocos2d : : Point ( 0 , _clippingSize . height ) ; <nl> + <nl> + cocos2d : : Color4F green = { 0 , 1 , 0 , 1 } ; <nl> + _innerStencil - > drawPolygon ( rect , 4 , green , 0 , green ) ; <nl> + if ( cocos2d : : ClippingNode : : init ( _innerStencil ) ) <nl> + { <nl> + return true ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + <nl> + void UIRectClippingNode : : setClippingSize ( const cocos2d : : Size & size ) <nl> + { <nl> + setContentSize ( size ) ; <nl> + _clippingSize = size ; <nl> + rect [ 0 ] = cocos2d : : Point ( 0 , 0 ) ; <nl> + rect [ 1 ] = cocos2d : : Point ( _clippingSize . width , 0 ) ; <nl> + rect [ 2 ] = cocos2d : : Point ( _clippingSize . width , _clippingSize . height ) ; <nl> + rect [ 3 ] = cocos2d : : Point ( 0 , _clippingSize . height ) ; <nl> + cocos2d : : Color4F green = { 0 , 1 , 0 , 1 } ; <nl> + _innerStencil - > clear ( ) ; <nl> + _innerStencil - > drawPolygon ( rect , 4 , green , 0 , green ) ; <nl> + } <nl> + <nl> + void UIRectClippingNode : : setClippingEnabled ( bool enabled ) <nl> + { <nl> + _clippingEnabled = enabled ; <nl> + } <nl> + <nl> + void UIRectClippingNode : : visit ( ) <nl> + { <nl> + if ( ! _enabled ) <nl> + { <nl> + return ; <nl> + } <nl> + if ( _clippingEnabled ) <nl> + { <nl> + cocos2d : : ClippingNode : : visit ( ) ; <nl> + } <nl> + else <nl> + { <nl> + cocos2d : : Node : : visit ( ) ; <nl> + } <nl> + } <nl> + <nl> + void UIRectClippingNode : : setEnabled ( bool enabled ) <nl> + { <nl> + _enabled = enabled ; <nl> + } <nl> + <nl> + bool UIRectClippingNode : : isEnabled ( ) const <nl> + { <nl> + return _enabled ; <nl> + } <nl> + <nl> + } <nl> \ No newline at end of file <nl> similarity index 89 % <nl> rename from cocos / gui / Layout . h <nl> rename to cocos / gui / UILayout . h <nl> mmm a / cocos / gui / Layout . h <nl> ppp b / cocos / gui / UILayout . h <nl> typedef enum <nl> LAYOUT_RELATIVE <nl> } LayoutType ; <nl> <nl> - class Layout : public UIWidget <nl> + <nl> + / * * <nl> + * @ js NA <nl> + * @ lua NA <nl> + * / <nl> + class UILayout : public UIWidget <nl> { <nl> public : <nl> / * * <nl> * Default constructor <nl> * / <nl> - Layout ( ) ; <nl> + UILayout ( ) ; <nl> <nl> / * * <nl> * Default destructor <nl> * / <nl> - virtual ~ Layout ( ) ; <nl> + virtual ~ UILayout ( ) ; <nl> <nl> / * * <nl> * Allocates and initializes a layout . <nl> * / <nl> - static Layout * create ( ) ; <nl> + static UILayout * create ( ) ; <nl> <nl> / / override " hitTest " method of widget . <nl> virtual bool hitTest ( const cocos2d : : Point & pt ) ; <nl> class Layout : public UIWidget <nl> * / <nl> virtual const cocos2d : : Size & getContentSize ( ) const ; <nl> <nl> + / * * <nl> + * Returns the " class name " of widget . <nl> + * / <nl> + virtual const char * getDescription ( ) const ; <nl> + <nl> / * * <nl> * Sets LayoutType . <nl> * <nl> class Layout : public UIWidget <nl> virtual LayoutType getLayoutType ( ) const ; <nl> <nl> virtual void doLayout ( ) ; <nl> - <nl> + <nl> / * * <nl> - * Returns the " class name " of widget . <nl> + * Adds a child to the container . <nl> + * <nl> + * @ param child A child widget <nl> * / <nl> - virtual const char * getDescription ( ) const ; <nl> + virtual bool addChild ( UIWidget * child ) ; <nl> + <nl> protected : <nl> / / override " init " method of widget . <nl> virtual bool init ( ) ; <nl> class Layout : public UIWidget <nl> <nl> / / init background image renderer . <nl> void addBackGroundImage ( ) ; <nl> + <nl> + void supplyTheLayoutParameterLackToChild ( UIWidget * child ) ; <nl> + virtual UIWidget * createCloneInstance ( ) ; <nl> + virtual void copySpecialProperties ( UIWidget * model ) ; <nl> + virtual void copyClonedWidgetChildren ( UIWidget * model ) ; <nl> protected : <nl> bool _clippingEnabled ; <nl> <nl> class Layout : public UIWidget <nl> cocos2d : : Size _backGroundImageTextureSize ; <nl> LayoutType _layoutType ; <nl> } ; <nl> - <nl> - class RectClippingNode : public cocos2d : : ClippingNode <nl> + / * * <nl> + * @ js NA <nl> + * @ lua NA <nl> + * / <nl> + class UIRectClippingNode : public cocos2d : : ClippingNode <nl> { <nl> public : <nl> - virtual ~ RectClippingNode ( ) ; <nl> + virtual ~ UIRectClippingNode ( ) ; <nl> virtual bool init ( ) ; <nl> - static RectClippingNode * create ( ) ; <nl> + static UIRectClippingNode * create ( ) ; <nl> void setClippingSize ( const cocos2d : : Size & size ) ; <nl> void setClippingEnabled ( bool enabled ) ; <nl> virtual void visit ( ) ; <nl> void setEnabled ( bool enabled ) ; <nl> bool isEnabled ( ) const ; <nl> protected : <nl> - cocos2d : : DrawNode * m_pInnerStencil ; <nl> + cocos2d : : DrawNode * _innerStencil ; <nl> bool _enabled ; <nl> private : <nl> - RectClippingNode ( ) ; <nl> + UIRectClippingNode ( ) ; <nl> cocos2d : : Point rect [ 4 ] ; <nl> cocos2d : : Size _clippingSize ; <nl> bool _clippingEnabled ; <nl> mmm a / cocos / gui / UILayoutDefine . cpp <nl> ppp b / cocos / gui / UILayoutDefine . cpp <nl> <nl> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> THE SOFTWARE . <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - # include " gui / UILayoutDefine . h " <nl> + # include " UILayoutDefine . h " <nl> <nl> namespace gui { <nl> <nl> mmm a / cocos / gui / UILayoutDefine . h <nl> ppp b / cocos / gui / UILayoutDefine . h <nl> <nl> # define __UILAYOUTDEFINE_H__ <nl> <nl> # include " cocos2d . h " <nl> + # include " ExtensionMacros . h " <nl> <nl> namespace gui { <nl> - <nl> + / * * <nl> + * @ js NA <nl> + * @ lua NA <nl> + * / <nl> class UIMargin <nl> { <nl> public : <nl> class UIMargin <nl> bool equals ( const UIMargin & target ) const ; <nl> } ; <nl> <nl> + const UIMargin UIMarginZero = UIMargin ( ) ; <nl> <nl> typedef enum <nl> { <nl> typedef enum <nl> typedef enum <nl> { <nl> RELATIVE_ALIGN_NONE , <nl> - RELATIVE_ALIGN_PARENT_LEFT , <nl> - RELATIVE_ALIGN_PARENT_TOP , <nl> - RELATIVE_ALIGN_PARENT_RIGHT , <nl> - RELATIVE_ALIGN_PARENT_BOTTOM , <nl> + RELATIVE_ALIGN_PARENT_TOP_LEFT , <nl> + RELATIVE_ALIGN_PARENT_TOP_CENTER_HORIZONTAL , <nl> + RELATIVE_ALIGN_PARENT_TOP_RIGHT , <nl> + RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL , <nl> RELATIVE_CENTER_IN_PARENT , <nl> - RELATIVE_CENTER_HORIZONTAL , <nl> - RELATIVE_CENTER_VERTICAL , <nl> + RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL , <nl> + RELATIVE_ALIGN_PARENT_LEFT_BOTTOM , <nl> + RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL , <nl> + RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM , <nl> + <nl> + RELATIVE_LOCATION_ABOVE_LEFTALIGN , <nl> + RELATIVE_LOCATION_ABOVE_CENTER , <nl> + RELATIVE_LOCATION_ABOVE_RIGHTALIGN , <nl> RELATIVE_LOCATION_LEFT_OF_TOPALIGN , <nl> RELATIVE_LOCATION_LEFT_OF_CENTER , <nl> RELATIVE_LOCATION_LEFT_OF_BOTTOMALIGN , <nl> RELATIVE_LOCATION_RIGHT_OF_TOPALIGN , <nl> RELATIVE_LOCATION_RIGHT_OF_CENTER , <nl> RELATIVE_LOCATION_RIGHT_OF_BOTTOMALIGN , <nl> - RELATIVE_LOCATION_ABOVE_LEFTALIGN , <nl> - RELATIVE_LOCATION_ABOVE_CENTER , <nl> - RELATIVE_LOCATION_ABOVE_RIGHTALIGN , <nl> RELATIVE_LOCATION_BELOW_LEFTALIGN , <nl> RELATIVE_LOCATION_BELOW_CENTER , <nl> RELATIVE_LOCATION_BELOW_RIGHTALIGN <nl> similarity index 65 % <nl> rename from cocos / gui / LayoutParameter . cpp <nl> rename to cocos / gui / UILayoutParameter . cpp <nl> mmm a / cocos / gui / LayoutParameter . cpp <nl> ppp b / cocos / gui / UILayoutParameter . cpp <nl> <nl> THE SOFTWARE . <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> <nl> - # include " gui / LayoutParameter . h " <nl> - # include " gui / Layout . h " <nl> + # include " gui / UILayoutParameter . h " <nl> + # include " gui / UILayout . h " <nl> <nl> namespace gui { <nl> <nl> - LayoutParameter * LayoutParameter : : create ( ) <nl> + <nl> + UILayoutParameter * UILayoutParameter : : create ( ) <nl> { <nl> - LayoutParameter * parameter = new LayoutParameter ( ) ; <nl> + UILayoutParameter * parameter = new UILayoutParameter ( ) ; <nl> if ( parameter ) <nl> { <nl> parameter - > autorelease ( ) ; <nl> LayoutParameter * LayoutParameter : : create ( ) <nl> return NULL ; <nl> } <nl> <nl> - void LayoutParameter : : setMargin ( const UIMargin & margin ) <nl> + void UILayoutParameter : : setMargin ( const UIMargin & margin ) <nl> { <nl> _margin = margin ; <nl> } <nl> <nl> - const UIMargin & LayoutParameter : : getMargin ( ) const <nl> + const UIMargin & UILayoutParameter : : getMargin ( ) const <nl> { <nl> return _margin ; <nl> } <nl> <nl> - LayoutParameterType LayoutParameter : : getLayoutType ( ) const <nl> + LayoutParameterType UILayoutParameter : : getLayoutType ( ) const <nl> { <nl> return _layoutParameterType ; <nl> } <nl> <nl> - LinearLayoutParameter * LinearLayoutParameter : : create ( ) <nl> + UILinearLayoutParameter * UILinearLayoutParameter : : create ( ) <nl> { <nl> - LinearLayoutParameter * parameter = new LinearLayoutParameter ( ) ; <nl> + UILinearLayoutParameter * parameter = new UILinearLayoutParameter ( ) ; <nl> if ( parameter ) <nl> { <nl> parameter - > autorelease ( ) ; <nl> LinearLayoutParameter * LinearLayoutParameter : : create ( ) <nl> return NULL ; <nl> } <nl> <nl> - void LinearLayoutParameter : : setGravity ( UILinearGravity gravity ) <nl> + void UILinearLayoutParameter : : setGravity ( UILinearGravity gravity ) <nl> { <nl> _linearGravity = gravity ; <nl> } <nl> <nl> - UILinearGravity LinearLayoutParameter : : getGravity ( ) const <nl> + UILinearGravity UILinearLayoutParameter : : getGravity ( ) const <nl> { <nl> return _linearGravity ; <nl> } <nl> <nl> - RelativeLayoutParameter * RelativeLayoutParameter : : create ( ) <nl> + UIRelativeLayoutParameter * UIRelativeLayoutParameter : : create ( ) <nl> { <nl> - RelativeLayoutParameter * parameter = new RelativeLayoutParameter ( ) ; <nl> + UIRelativeLayoutParameter * parameter = new UIRelativeLayoutParameter ( ) ; <nl> if ( parameter ) <nl> { <nl> parameter - > autorelease ( ) ; <nl> RelativeLayoutParameter * RelativeLayoutParameter : : create ( ) <nl> return NULL ; <nl> } <nl> <nl> - void RelativeLayoutParameter : : setAlign ( UIRelativeAlign align ) <nl> + void UIRelativeLayoutParameter : : setAlign ( UIRelativeAlign align ) <nl> { <nl> _relativeAlign = align ; <nl> } <nl> <nl> - UIRelativeAlign RelativeLayoutParameter : : getAlign ( ) const <nl> + UIRelativeAlign UIRelativeLayoutParameter : : getAlign ( ) const <nl> { <nl> return _relativeAlign ; <nl> } <nl> <nl> - void RelativeLayoutParameter : : setRelativeToWidgetName ( const char * name ) <nl> + void UIRelativeLayoutParameter : : setRelativeToWidgetName ( const char * name ) <nl> { <nl> _relativeWidgetName = name ; <nl> } <nl> <nl> - const char * RelativeLayoutParameter : : getRelativeToWidgetName ( ) const <nl> + const char * UIRelativeLayoutParameter : : getRelativeToWidgetName ( ) const <nl> { <nl> return _relativeWidgetName . c_str ( ) ; <nl> } <nl> <nl> - void RelativeLayoutParameter : : setRelativeName ( const char * name ) <nl> + void UIRelativeLayoutParameter : : setRelativeName ( const char * name ) <nl> { <nl> _relativeLayoutName = name ; <nl> } <nl> <nl> - const char * RelativeLayoutParameter : : getRelativeName ( ) const <nl> + const char * UIRelativeLayoutParameter : : getRelativeName ( ) const <nl> { <nl> return _relativeLayoutName . c_str ( ) ; <nl> } <nl> similarity index 82 % <nl> rename from cocos / gui / LayoutParameter . h <nl> rename to cocos / gui / UILayoutParameter . h <nl> mmm a / cocos / gui / LayoutParameter . h <nl> ppp b / cocos / gui / UILayoutParameter . h <nl> typedef enum <nl> LAYOUT_PARAMETER_LINEAR , <nl> LAYOUT_PARAMETER_RELATIVE <nl> } LayoutParameterType ; <nl> - <nl> - class LayoutParameter : public cocos2d : : Object <nl> + / * * <nl> + * @ js NA <nl> + * @ lua NA <nl> + * / <nl> + class UILayoutParameter : public cocos2d : : Object <nl> { <nl> public : <nl> / * * <nl> * Default constructor <nl> * / <nl> - LayoutParameter ( ) : _margin ( UIMargin ( ) ) { _layoutParameterType = LAYOUT_PARAMETER_NONE ; } ; <nl> + UILayoutParameter ( ) : _margin ( UIMargin ( ) ) { _layoutParameterType = LAYOUT_PARAMETER_NONE ; } ; <nl> <nl> / * * <nl> * Default destructor <nl> * / <nl> - virtual ~ LayoutParameter ( ) { } ; <nl> + virtual ~ UILayoutParameter ( ) { } ; <nl> <nl> / * * <nl> * Allocates and initializes . <nl> * @ return A initialized LayoutParameter which is marked as " autorelease " . <nl> * / <nl> - static LayoutParameter * create ( ) ; <nl> + static UILayoutParameter * create ( ) ; <nl> <nl> / * * <nl> * Sets Margin parameter for LayoutParameter . <nl> class LayoutParameter : public cocos2d : : Object <nl> UIMargin _margin ; <nl> LayoutParameterType _layoutParameterType ; <nl> } ; <nl> - <nl> - class LinearLayoutParameter : public LayoutParameter <nl> + / * * <nl> + * @ js NA <nl> + * @ lua NA <nl> + * / <nl> + class UILinearLayoutParameter : public UILayoutParameter <nl> { <nl> public : <nl> / * * <nl> * Default constructor <nl> * / <nl> - LinearLayoutParameter ( ) : _linearGravity ( LINEAR_GRAVITY_NONE ) { _layoutParameterType = LAYOUT_PARAMETER_LINEAR ; } ; <nl> + UILinearLayoutParameter ( ) : _linearGravity ( LINEAR_GRAVITY_NONE ) { _layoutParameterType = LAYOUT_PARAMETER_LINEAR ; } ; <nl> <nl> / * * <nl> * Default destructor <nl> * / <nl> - virtual ~ LinearLayoutParameter ( ) { } ; <nl> + virtual ~ UILinearLayoutParameter ( ) { } ; <nl> <nl> / * * <nl> * Allocates and initializes . <nl> * @ return A initialized LayoutParameter which is marked as " autorelease " . <nl> * / <nl> - static LinearLayoutParameter * create ( ) ; <nl> + static UILinearLayoutParameter * create ( ) ; <nl> <nl> / * * <nl> * Sets UILinearGravity parameter for LayoutParameter . <nl> class LinearLayoutParameter : public LayoutParameter <nl> protected : <nl> UILinearGravity _linearGravity ; <nl> } ; <nl> + / * * <nl> + * @ js NA <nl> + * @ lua NA <nl> + * / <nl> + <nl> + class UILayout ; <nl> <nl> - class RelativeLayoutParameter : public LayoutParameter <nl> + class UIRelativeLayoutParameter : public UILayoutParameter <nl> { <nl> public : <nl> / * * <nl> * Default constructor <nl> * / <nl> - RelativeLayoutParameter ( ) : _relativeAlign ( RELATIVE_ALIGN_NONE ) , _relativeWidgetName ( " " ) , _relativeLayoutName ( " " ) { _layoutParameterType = LAYOUT_PARAMETER_RELATIVE ; } ; <nl> + UIRelativeLayoutParameter ( ) : _relativeAlign ( RELATIVE_ALIGN_NONE ) , _relativeWidgetName ( " " ) , _relativeLayoutName ( " " ) , _put ( false ) { _layoutParameterType = LAYOUT_PARAMETER_RELATIVE ; } ; <nl> <nl> / * * <nl> * Default destructor <nl> * / <nl> - virtual ~ RelativeLayoutParameter ( ) { } ; <nl> + virtual ~ UIRelativeLayoutParameter ( ) { } ; <nl> <nl> / * * <nl> * Allocates and initializes . <nl> * @ return A initialized LayoutParameter which is marked as " autorelease " . <nl> * / <nl> - static RelativeLayoutParameter * create ( ) ; <nl> + static UIRelativeLayoutParameter * create ( ) ; <nl> <nl> / * * <nl> * Sets UIRelativeAlign parameter for LayoutParameter . <nl> class RelativeLayoutParameter : public LayoutParameter <nl> UIRelativeAlign _relativeAlign ; <nl> std : : string _relativeWidgetName ; <nl> std : : string _relativeLayoutName ; <nl> + bool _put ; <nl> + friend class UILayout ; <nl> } ; <nl> <nl> } <nl> mmm a / cocos / gui / UIListView . cpp <nl> ppp b / cocos / gui / UIListView . cpp <nl> <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> <nl> # include " gui / UIListView . h " <nl> - <nl> - using namespace cocos2d ; <nl> + # include " gui / UIHelper . h " <nl> + # include " extensions / GUI / CCControlExtension / CCScale9Sprite . h " <nl> <nl> namespace gui { <nl> <nl> - UIListView : : UIListView ( ) <nl> - : _direction ( LISTVIEW_DIR_VERTICAL ) <nl> - , _moveDirection ( LISTVIEW_MOVE_DIR_NONE ) <nl> - , _touchStartLocation ( 0 . 0f ) <nl> - , _touchEndLocation ( 0 . 0f ) <nl> - , _touchMoveStartLocation ( 0 . 0f ) <nl> - , _topBoundary ( 0 . 0f ) <nl> - , _bottomBoundary ( 0 . 0f ) <nl> - , _leftBoundary ( 0 . 0f ) <nl> - , _rightBoundary ( 0 . 0f ) <nl> - , _autoScroll ( false ) <nl> - , _autoScrollOriginalSpeed ( 0 . 0f ) <nl> - , _autoScrollAcceleration ( 600 . 0f ) <nl> - , _bePressed ( false ) <nl> - , _slidTime ( 0 . 0f ) <nl> - , _childFocusCancelOffset ( 5 . 0f ) <nl> - , _eventListener ( NULL ) <nl> - , _eventSelector ( NULL ) <nl> - , _childPool ( NULL ) <nl> - , _updatePool ( NULL ) <nl> - , _dataLength ( 0 ) <nl> - , _begin ( 0 ) <nl> - , _end ( 0 ) <nl> - , _updateChild ( NULL ) <nl> - , _updateDataIndex ( - 1 ) <nl> - , _updateSuccess ( false ) <nl> - , _overTopArray ( NULL ) <nl> - , _overBottomArray ( NULL ) <nl> - , _overLeftArray ( NULL ) <nl> - , _overRightArray ( NULL ) <nl> - , _disBoundaryToChild_0 ( 0 . 0f ) <nl> - , _disBetweenChild ( 0 . 0f ) <nl> - , _scrollDegreeRange ( 45 . 0f ) <nl> + UIListView : : UIListView ( ) : <nl> + _model ( NULL ) , <nl> + _items ( NULL ) , <nl> + _gravity ( LISTVIEW_GRAVITY_CENTER_HORIZONTAL ) , <nl> + _itemsMargin ( 0 . 0f ) <nl> { <nl> + <nl> } <nl> <nl> UIListView : : ~ UIListView ( ) <nl> { <nl> - CC_SAFE_RELEASE_NULL ( _childPool ) ; <nl> - CC_SAFE_RELEASE_NULL ( _updatePool ) ; <nl> - CC_SAFE_RELEASE_NULL ( _overTopArray ) ; <nl> - CC_SAFE_RELEASE_NULL ( _overBottomArray ) ; <nl> - CC_SAFE_RELEASE_NULL ( _overLeftArray ) ; <nl> - CC_SAFE_RELEASE_NULL ( _overRightArray ) ; <nl> + _items - > removeAllObjects ( ) ; <nl> + CC_SAFE_RELEASE ( _items ) ; <nl> } <nl> <nl> UIListView * UIListView : : create ( ) <nl> UIListView * UIListView : : create ( ) <nl> <nl> bool UIListView : : init ( ) <nl> { <nl> - if ( Layout : : init ( ) ) <nl> + if ( UIScrollView : : init ( ) ) <nl> { <nl> - setUpdateEnabled ( true ) ; <nl> - setTouchEnabled ( true ) ; <nl> - setClippingEnabled ( true ) ; <nl> - <nl> - _childPool = CCArray : : create ( ) ; <nl> - _updatePool = CCArray : : create ( ) ; <nl> - CC_SAFE_RETAIN ( _childPool ) ; <nl> - CC_SAFE_RETAIN ( _updatePool ) ; <nl> - _overTopArray = cocos2d : : CCArray : : create ( ) ; <nl> - _overBottomArray = cocos2d : : CCArray : : create ( ) ; <nl> - _overLeftArray = cocos2d : : CCArray : : create ( ) ; <nl> - _overRightArray = cocos2d : : CCArray : : create ( ) ; <nl> - CC_SAFE_RETAIN ( _overTopArray ) ; <nl> - CC_SAFE_RETAIN ( _overBottomArray ) ; <nl> - CC_SAFE_RETAIN ( _overLeftArray ) ; <nl> - CC_SAFE_RETAIN ( _overRightArray ) ; <nl> - <nl> + _items = cocos2d : : Array : : create ( ) ; <nl> + CC_SAFE_RETAIN ( _items ) ; <nl> + setLayoutType ( LAYOUT_LINEAR_VERTICAL ) ; <nl> return true ; <nl> } <nl> return false ; <nl> } <nl> <nl> - void UIListView : : onSizeChanged ( ) <nl> - { <nl> - Layout : : onSizeChanged ( ) ; <nl> - _topBoundary = _size . height ; <nl> - _rightBoundary = _size . width ; <nl> - } <nl> - <nl> - bool UIListView : : addChild ( UIWidget * widget ) <nl> - { <nl> - Layout : : addChild ( widget ) ; <nl> - resetProperty ( ) ; <nl> - return true ; <nl> - } <nl> - <nl> - void UIListView : : removeAllChildren ( ) <nl> - { <nl> - _updatePool - > removeAllObjects ( ) ; <nl> - _childPool - > removeAllObjects ( ) ; <nl> - Layout : : removeAllChildren ( ) ; <nl> - } <nl> - <nl> - bool UIListView : : removeChild ( UIWidget * child ) <nl> - { <nl> - bool value = false ; <nl> - <nl> - if ( Layout : : removeChild ( child ) ) <nl> - { <nl> - value = true ; <nl> - resetProperty ( ) ; <nl> - } <nl> - <nl> - return value ; <nl> - } <nl> - <nl> - bool UIListView : : onTouchBegan ( const Point & touchPoint ) <nl> - { <nl> - bool pass = Layout : : onTouchBegan ( touchPoint ) ; <nl> - handlePressLogic ( touchPoint ) ; <nl> - return pass ; <nl> - } <nl> - <nl> - void UIListView : : onTouchMoved ( const Point & touchPoint ) <nl> - { <nl> - Layout : : onTouchMoved ( touchPoint ) ; <nl> - handleMoveLogic ( touchPoint ) ; <nl> - } <nl> - <nl> - void UIListView : : onTouchEnded ( const Point & touchPoint ) <nl> - { <nl> - Layout : : onTouchEnded ( touchPoint ) ; <nl> - handleReleaseLogic ( touchPoint ) ; <nl> - } <nl> - <nl> - void UIListView : : onTouchCancelled ( const Point & touchPoint ) <nl> + void UIListView : : setItemModel ( UIWidget * model ) <nl> { <nl> - Layout : : onTouchCancelled ( touchPoint ) ; <nl> - } <nl> - <nl> - void UIListView : : onTouchLongClicked ( const Point & touchPoint ) <nl> - { <nl> - <nl> - } <nl> - <nl> - void UIListView : : update ( float dt ) <nl> - { <nl> - if ( _autoScroll ) <nl> + if ( ! model ) <nl> { <nl> - autoScrollChildren ( dt ) ; <nl> + return ; <nl> } <nl> - recordSlidTime ( dt ) ; <nl> - } <nl> - <nl> - void UIListView : : setDirection ( ListViewDirection dir ) <nl> - { <nl> - _direction = dir ; <nl> + CC_SAFE_RELEASE_NULL ( _model ) ; <nl> + _model = model ; <nl> + CC_SAFE_RETAIN ( _model ) ; <nl> } <nl> <nl> - ListViewDirection UIListView : : getDirection ( ) <nl> + void UIListView : : updateInnerContainerSize ( ) <nl> { <nl> - return _direction ; <nl> - } <nl> - <nl> - void UIListView : : resetProperty ( ) <nl> - { <nl> - ccArray * arrayChildren = _children - > data ; <nl> - <nl> - if ( arrayChildren - > num < = 0 ) <nl> + if ( ! _model ) <nl> { <nl> return ; <nl> - } <nl> - <nl> - switch ( _direction ) <nl> - { <nl> - case LISTVIEW_DIR_VERTICAL : / / vertical <nl> - if ( _topBoundary = = 0 ) <nl> - { <nl> - return ; <nl> - } <nl> - break ; <nl> - <nl> - case LISTVIEW_DIR_HORIZONTAL : / / horizontal <nl> - if ( _rightBoundary = = 0 ) <nl> - { <nl> - return ; <nl> - } <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> } <nl> - <nl> - float scroll_top = _topBoundary ; <nl> - float scroll_left = _leftBoundary ; <nl> - <nl> - switch ( _children - > count ( ) ) <nl> - { <nl> - case 1 : <nl> + switch ( _direction ) { <nl> + case SCROLLVIEW_DIR_VERTICAL : <nl> { <nl> - UIWidget * child_0 = dynamic_cast < UIWidget * > ( arrayChildren - > arr [ 0 ] ) ; <nl> - <nl> - switch ( _direction ) <nl> - { <nl> - case LISTVIEW_DIR_VERTICAL : / / vertical <nl> - { <nl> - float child_0_top = child_0 - > getTopInParent ( ) ; <nl> - _disBoundaryToChild_0 = scroll_top - child_0_top ; <nl> - } <nl> - break ; <nl> - <nl> - case LISTVIEW_DIR_HORIZONTAL : / / horizontal <nl> - { <nl> - float child_0_left = child_0 - > getLeftInParent ( ) ; <nl> - _disBoundaryToChild_0 = child_0_left - scroll_left ; <nl> - } <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - } <nl> + int childrenCount = _items - > count ( ) ; <nl> + float totalHeight = _model - > getSize ( ) . height * childrenCount + ( childrenCount - 1 ) * _itemsMargin ; <nl> + float finalWidth = _size . width ; <nl> + float finalHeight = totalHeight ; <nl> + setInnerContainerSize ( cocos2d : : Size ( finalWidth , finalHeight ) ) ; <nl> break ; <nl> - <nl> - default : <nl> - { <nl> - UIWidget * child_0 = dynamic_cast < UIWidget * > ( arrayChildren - > arr [ 0 ] ) ; <nl> - UIWidget * child_1 = dynamic_cast < UIWidget * > ( arrayChildren - > arr [ 1 ] ) ; <nl> - <nl> - switch ( _direction ) <nl> - { <nl> - case LISTVIEW_DIR_VERTICAL : / / vertical <nl> - { <nl> - float child_0_top = child_0 - > getTopInParent ( ) ; <nl> - _disBoundaryToChild_0 = scroll_top - child_0_top ; <nl> - _disBetweenChild = child_0 - > getPosition ( ) . y - child_1 - > getPosition ( ) . y ; <nl> - } <nl> - break ; <nl> - <nl> - case LISTVIEW_DIR_HORIZONTAL : / / horizontal <nl> - { <nl> - float child_0_left = child_0 - > getLeftInParent ( ) ; <nl> - _disBoundaryToChild_0 = child_0_left - scroll_left ; <nl> - _disBetweenChild = child_1 - > getPosition ( ) . x - child_0 - > getPosition ( ) . x ; <nl> - } <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> } <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - void UIListView : : handlePressLogic ( const Point & touchPoint ) <nl> - { <nl> - Point nsp = _renderer - > convertToNodeSpace ( touchPoint ) ; <nl> - <nl> - switch ( _direction ) <nl> - { <nl> - case LISTVIEW_DIR_VERTICAL : / / vertical <nl> - _touchMoveStartLocation = nsp . y ; <nl> - _touchStartLocation = nsp . y ; <nl> - break ; <nl> - <nl> - case LISTVIEW_DIR_HORIZONTAL : / / horizontal <nl> - _touchMoveStartLocation = nsp . x ; <nl> - _touchStartLocation = nsp . x ; <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - startRecordSlidAction ( ) ; <nl> - clearCollectOverArray ( ) ; <nl> - } <nl> - <nl> - void UIListView : : handleMoveLogic ( const Point & touchPoint ) <nl> - { <nl> - Point nsp = _renderer - > convertToNodeSpace ( touchPoint ) ; <nl> - float offset = 0 . 0f ; <nl> - <nl> - switch ( _direction ) <nl> - { <nl> - case LISTVIEW_DIR_VERTICAL : / / vertical <nl> + case SCROLLVIEW_DIR_HORIZONTAL : <nl> { <nl> - float moveY = nsp . y ; <nl> - offset = moveY - _touchMoveStartLocation ; <nl> - _touchMoveStartLocation = moveY ; <nl> - <nl> - if ( offset < 0 . 0f ) <nl> - { <nl> - _moveDirection = LISTVIEW_MOVE_DIR_DOWN ; / / down <nl> - } <nl> - else if ( offset > 0 . 0f ) <nl> - { <nl> - _moveDirection = LISTVIEW_MOVE_DIR_UP ; / / up <nl> - } <nl> - } <nl> + int childrenCount = _items - > count ( ) ; <nl> + float totalWidth = _model - > getSize ( ) . width * childrenCount + ( childrenCount - 1 ) * _itemsMargin ; <nl> + float finalWidth = totalWidth ; <nl> + float finalHeight = _size . height ; <nl> + setInnerContainerSize ( cocos2d : : Size ( finalWidth , finalHeight ) ) ; <nl> break ; <nl> - <nl> - case LISTVIEW_DIR_HORIZONTAL : / / horizontal <nl> - { <nl> - float moveX = nsp . x ; <nl> - offset = moveX - _touchMoveStartLocation ; <nl> - _touchMoveStartLocation = moveX ; <nl> - <nl> - if ( offset < 0 ) <nl> - { <nl> - _moveDirection = LISTVIEW_MOVE_DIR_LEFT ; / / left <nl> - } <nl> - else if ( offset > 0 ) <nl> - { <nl> - _moveDirection = LISTVIEW_MOVE_DIR_RIGHT ; / / right <nl> - } <nl> } <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - scrollChildren ( offset ) ; <nl> - } <nl> - <nl> - void UIListView : : handleReleaseLogic ( const Point & touchPoint ) <nl> - { <nl> - Point nsp = _renderer - > convertToNodeSpace ( touchPoint ) ; <nl> - <nl> - switch ( _direction ) <nl> - { <nl> - case LISTVIEW_DIR_VERTICAL : / / vertical <nl> - _touchEndLocation = nsp . y ; <nl> - break ; <nl> - <nl> - case LISTVIEW_DIR_HORIZONTAL : / / horizontal <nl> - _touchEndLocation = nsp . x ; <nl> - break ; <nl> - <nl> default : <nl> break ; <nl> } <nl> - endRecordSlidAction ( ) ; <nl> } <nl> <nl> - void UIListView : : interceptTouchEvent ( int handleState , UIWidget * sender , const Point & touchPoint ) <nl> + void UIListView : : remedyLayoutParameter ( UIWidget * item ) <nl> { <nl> - switch ( handleState ) <nl> + if ( ! item ) <nl> { <nl> - case 0 : <nl> - handlePressLogic ( touchPoint ) ; <nl> - break ; <nl> - <nl> - case 1 : <nl> - { <nl> - float offset = 0 ; <nl> - switch ( _direction ) <nl> - { <nl> - case LISTVIEW_DIR_VERTICAL : / / vertical <nl> - offset = fabs ( sender - > getTouchStartPos ( ) . y - touchPoint . y ) ; <nl> - break ; <nl> - <nl> - case LISTVIEW_DIR_HORIZONTAL : / / horizontal <nl> - offset = fabs ( sender - > getTouchStartPos ( ) . x - touchPoint . x ) ; <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - if ( offset > _childFocusCancelOffset ) <nl> - { <nl> - sender - > setFocused ( false ) ; <nl> - handleMoveLogic ( touchPoint ) ; <nl> - } <nl> - } <nl> - break ; <nl> - <nl> - case 2 : <nl> - handleReleaseLogic ( touchPoint ) ; <nl> - break ; <nl> - <nl> - case 3 : <nl> - break ; <nl> + return ; <nl> } <nl> - } <nl> - <nl> - void UIListView : : checkChildInfo ( int handleState , UIWidget * sender , const Point & touchPoint ) <nl> - { <nl> - interceptTouchEvent ( handleState , sender , touchPoint ) ; <nl> - } <nl> - <nl> - void UIListView : : moveChildren ( float offset ) <nl> - { <nl> - switch ( _direction ) <nl> - { <nl> - case LISTVIEW_DIR_VERTICAL : / / vertical <nl> - { <nl> - ccArray * arrayChildren = _children - > data ; <nl> - int childrenCount = arrayChildren - > num ; <nl> - for ( int i = 0 ; i < childrenCount ; i + + ) <nl> - { <nl> - UIWidget * child = ( UIWidget * ) ( arrayChildren - > arr [ i ] ) ; <nl> - _moveChildPoint . x = child - > getPosition ( ) . x ; <nl> - _moveChildPoint . y = child - > getPosition ( ) . y + offset ; <nl> - child - > setPosition ( _moveChildPoint ) ; <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - case LISTVIEW_DIR_HORIZONTAL : / / horizontal <nl> + switch ( _direction ) { <nl> + case SCROLLVIEW_DIR_VERTICAL : <nl> { <nl> - ccArray * arrayChildren = _children - > data ; <nl> - int childrenCount = arrayChildren - > num ; <nl> - for ( int i = 0 ; i < childrenCount ; i + + ) <nl> + UILinearLayoutParameter * llp = ( UILinearLayoutParameter * ) ( item - > getLayoutParameter ( LAYOUT_PARAMETER_LINEAR ) ) ; <nl> + if ( ! llp ) <nl> { <nl> - UIWidget * child = ( UIWidget * ) ( arrayChildren - > arr [ i ] ) ; <nl> - _moveChildPoint . x = child - > getPosition ( ) . x + offset ; <nl> - _moveChildPoint . y = child - > getPosition ( ) . y ; <nl> - child - > setPosition ( _moveChildPoint ) ; <nl> - } <nl> - break ; <nl> - } <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - bool UIListView : : scrollChildren ( float touchOffset ) <nl> - { <nl> - float realOffset = touchOffset ; <nl> - <nl> - switch ( _direction ) <nl> - { <nl> - case LISTVIEW_DIR_VERTICAL : / / vertical <nl> - switch ( _moveDirection ) <nl> - { <nl> - case LISTVIEW_MOVE_DIR_UP : / / up <nl> - { <nl> - realOffset = MIN ( realOffset , _disBetweenChild ) ; <nl> - <nl> - UIWidget * child_last = dynamic_cast < UIWidget * > ( _childPool - > getLastObject ( ) ) ; <nl> - float child_last_bottom = child_last - > getBottomInParent ( ) ; <nl> - float scroll_bottom = _bottomBoundary ; <nl> - <nl> - if ( _end = = _dataLength - 1 ) <nl> - { <nl> - if ( realOffset > scroll_bottom + _disBoundaryToChild_0 - child_last_bottom ) <nl> - { <nl> - realOffset = scroll_bottom + _disBoundaryToChild_0 - child_last_bottom ; <nl> - } <nl> - moveChildren ( realOffset ) ; <nl> - return false ; <nl> - } <nl> - moveChildren ( realOffset ) ; <nl> - <nl> - if ( _end < _dataLength - 1 ) <nl> - { <nl> - collectOverTopChild ( ) ; <nl> - unsigned int count = _overTopArray - > count ( ) ; <nl> - if ( count > 0 ) <nl> - { <nl> - updateChild ( ) ; <nl> - setLoopPosition ( ) ; <nl> - _overTopArray - > removeAllObjects ( ) ; <nl> - } <nl> - } <nl> - } <nl> - break ; <nl> - <nl> - case LISTVIEW_MOVE_DIR_DOWN : / / down <nl> - { <nl> - realOffset = MAX ( realOffset , - _disBetweenChild ) ; <nl> - <nl> - UIWidget * child_0 = dynamic_cast < UIWidget * > ( _childPool - > getObjectAtIndex ( 0 ) ) ; <nl> - float child_0_top = child_0 - > getTopInParent ( ) ; <nl> - float scroll_top = _topBoundary ; <nl> - <nl> - if ( _begin = = 0 ) <nl> - { <nl> - if ( realOffset < scroll_top - _disBoundaryToChild_0 - child_0_top ) <nl> - { <nl> - realOffset = scroll_top - _disBoundaryToChild_0 - child_0_top ; <nl> - } <nl> - moveChildren ( realOffset ) ; <nl> - return false ; <nl> - } <nl> - moveChildren ( realOffset ) ; <nl> - <nl> - if ( _begin > 0 ) <nl> - { <nl> - collectOverBottomChild ( ) ; <nl> - int count = _overBottomArray - > count ( ) ; <nl> - if ( count > 0 ) <nl> - { <nl> - updateChild ( ) ; <nl> - setLoopPosition ( ) ; <nl> - _overBottomArray - > removeAllObjects ( ) ; <nl> - } <nl> - } <nl> - } <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - return true ; <nl> - break ; <nl> - <nl> - case LISTVIEW_DIR_HORIZONTAL : / / horizontal <nl> - switch ( _moveDirection ) <nl> - { <nl> - case LISTVIEW_MOVE_DIR_LEFT : / / left <nl> - { <nl> - realOffset = MAX ( realOffset , - _disBetweenChild ) ; <nl> - <nl> - UIWidget * child_last = dynamic_cast < UIWidget * > ( _childPool - > getLastObject ( ) ) ; <nl> - float child_last_right = child_last - > getRightInParent ( ) ; <nl> - float scroll_right = _rightBoundary ; <nl> - <nl> - if ( _end = = _dataLength - 1 ) <nl> - { <nl> - if ( realOffset < scroll_right - _disBoundaryToChild_0 - child_last_right ) <nl> - { <nl> - realOffset = scroll_right - _disBoundaryToChild_0 - child_last_right ; <nl> - } <nl> - moveChildren ( realOffset ) ; <nl> - return false ; <nl> - } <nl> - moveChildren ( realOffset ) ; <nl> - <nl> - if ( _end < _dataLength - 1 ) <nl> - { <nl> - collectOverLeftChild ( ) ; <nl> - int count = _overLeftArray - > count ( ) ; <nl> - if ( count > 0 ) <nl> - { <nl> - updateChild ( ) ; <nl> - setLoopPosition ( ) ; <nl> - _overLeftArray - > removeAllObjects ( ) ; <nl> - } <nl> - } <nl> - } <nl> - break ; <nl> - <nl> - case LISTVIEW_MOVE_DIR_RIGHT : / / right <nl> - { <nl> - realOffset = MIN ( realOffset , _disBetweenChild ) ; <nl> - <nl> - UIWidget * child_0 = dynamic_cast < UIWidget * > ( _childPool - > getObjectAtIndex ( 0 ) ) ; <nl> - float child_0_left = child_0 - > getLeftInParent ( ) ; <nl> - float scroll_left = _leftBoundary ; <nl> - <nl> - if ( _begin = = 0 ) <nl> - { <nl> - if ( realOffset > scroll_left + _disBoundaryToChild_0 - child_0_left ) <nl> - { <nl> - realOffset = scroll_left + _disBoundaryToChild_0 - child_0_left ; <nl> - } <nl> - moveChildren ( realOffset ) ; <nl> - return false ; <nl> - } <nl> - moveChildren ( realOffset ) ; <nl> - <nl> - collectOverRightChild ( ) ; <nl> - int count = _overRightArray - > count ( ) ; <nl> - if ( count > 0 ) <nl> - { <nl> - updateChild ( ) ; <nl> - setLoopPosition ( ) ; <nl> - _overRightArray - > removeAllObjects ( ) ; <nl> - } <nl> - } <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - return true ; <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - <nl> - return false ; <nl> - } <nl> - <nl> - void UIListView : : autoScrollChildren ( float dt ) <nl> - { <nl> - switch ( _direction ) <nl> - { <nl> - case LISTVIEW_DIR_VERTICAL : / / vertical <nl> - switch ( _moveDirection ) <nl> - { <nl> - case LISTVIEW_MOVE_DIR_UP : / / up <nl> - { <nl> - float curDis = getCurAutoScrollDistance ( dt ) ; <nl> - if ( curDis < = 0 ) <nl> + UILinearLayoutParameter * defaultLp = UILinearLayoutParameter : : create ( ) ; <nl> + switch ( _gravity ) { <nl> + case LISTVIEW_GRAVITY_LEFT : <nl> + defaultLp - > setGravity ( LINEAR_GRAVITY_LEFT ) ; <nl> + break ; <nl> + case LISTVIEW_GRAVITY_RIGHT : <nl> + defaultLp - > setGravity ( LINEAR_GRAVITY_RIGHT ) ; <nl> + break ; <nl> + case LISTVIEW_GRAVITY_CENTER_HORIZONTAL : <nl> + defaultLp - > setGravity ( LINEAR_GRAVITY_CENTER_HORIZONTAL ) ; <nl> + break ; <nl> + default : <nl> + break ; <nl> + } <nl> + if ( getIndex ( item ) = = 0 ) <nl> { <nl> - curDis = 0 ; <nl> - stopAutoScrollChildren ( ) ; <nl> + defaultLp - > setMargin ( UIMarginZero ) ; <nl> } <nl> - if ( ! scrollChildren ( curDis ) ) <nl> + else <nl> { <nl> - stopAutoScrollChildren ( ) ; <nl> + defaultLp - > setMargin ( UIMargin ( 0 . 0f , _itemsMargin , 0 . 0f , 0 . 0f ) ) ; <nl> } <nl> + item - > setLayoutParameter ( defaultLp ) ; <nl> } <nl> - break ; <nl> - <nl> - case LISTVIEW_MOVE_DIR_DOWN : / / down <nl> + else <nl> { <nl> - float curDis = getCurAutoScrollDistance ( dt ) ; <nl> - if ( curDis < = 0 ) <nl> + if ( getIndex ( item ) = = 0 ) <nl> { <nl> - curDis = 0 ; <nl> - stopAutoScrollChildren ( ) ; <nl> + llp - > setMargin ( UIMarginZero ) ; <nl> } <nl> - if ( ! scrollChildren ( - curDis ) ) <nl> + else <nl> { <nl> - stopAutoScrollChildren ( ) ; <nl> + llp - > setMargin ( UIMargin ( 0 . 0f , _itemsMargin , 0 . 0f , 0 . 0f ) ) ; <nl> + } <nl> + switch ( _gravity ) { <nl> + case LISTVIEW_GRAVITY_LEFT : <nl> + llp - > setGravity ( LINEAR_GRAVITY_LEFT ) ; <nl> + break ; <nl> + case LISTVIEW_GRAVITY_RIGHT : <nl> + llp - > setGravity ( LINEAR_GRAVITY_RIGHT ) ; <nl> + break ; <nl> + case LISTVIEW_GRAVITY_CENTER_HORIZONTAL : <nl> + llp - > setGravity ( LINEAR_GRAVITY_CENTER_HORIZONTAL ) ; <nl> + break ; <nl> + default : <nl> + break ; <nl> } <nl> } <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> break ; <nl> - <nl> - case LISTVIEW_DIR_HORIZONTAL : / / horizontal <nl> - switch ( _moveDirection ) <nl> + } <nl> + case SCROLLVIEW_DIR_HORIZONTAL : <nl> { <nl> - case LISTVIEW_MOVE_DIR_LEFT : / / left <nl> + UILinearLayoutParameter * llp = ( UILinearLayoutParameter * ) ( item - > getLayoutParameter ( LAYOUT_PARAMETER_LINEAR ) ) ; <nl> + if ( ! llp ) <nl> { <nl> - float curDis = getCurAutoScrollDistance ( dt ) ; <nl> - if ( curDis < = 0 ) <nl> + UILinearLayoutParameter * defaultLp = UILinearLayoutParameter : : create ( ) ; <nl> + switch ( _gravity ) { <nl> + case LISTVIEW_GRAVITY_TOP : <nl> + defaultLp - > setGravity ( LINEAR_GRAVITY_TOP ) ; <nl> + break ; <nl> + case LISTVIEW_GRAVITY_BOTTOM : <nl> + defaultLp - > setGravity ( LINEAR_GRAVITY_BOTTOM ) ; <nl> + break ; <nl> + case LISTVIEW_GRAVITY_CENTER_VERTICAL : <nl> + defaultLp - > setGravity ( LINEAR_GRAVITY_CENTER_VERTICAL ) ; <nl> + break ; <nl> + default : <nl> + break ; <nl> + } <nl> + if ( getIndex ( item ) = = 0 ) <nl> { <nl> - curDis = 0 ; <nl> - stopAutoScrollChildren ( ) ; <nl> + defaultLp - > setMargin ( UIMarginZero ) ; <nl> } <nl> - if ( ! scrollChildren ( - curDis ) ) <nl> + else <nl> { <nl> - stopAutoScrollChildren ( ) ; <nl> + defaultLp - > setMargin ( UIMargin ( _itemsMargin , 0 . 0f , 0 . 0f , 0 . 0f ) ) ; <nl> } <nl> + item - > setLayoutParameter ( defaultLp ) ; <nl> } <nl> - break ; <nl> - <nl> - case LISTVIEW_MOVE_DIR_RIGHT : / / right <nl> + else <nl> { <nl> - float curDis = getCurAutoScrollDistance ( dt ) ; <nl> - if ( curDis < = 0 ) <nl> + if ( getIndex ( item ) = = 0 ) <nl> { <nl> - curDis = 0 ; <nl> - stopAutoScrollChildren ( ) ; <nl> + llp - > setMargin ( UIMarginZero ) ; <nl> } <nl> - if ( ! scrollChildren ( curDis ) ) <nl> + else <nl> { <nl> - stopAutoScrollChildren ( ) ; <nl> + llp - > setMargin ( UIMargin ( _itemsMargin , 0 . 0f , 0 . 0f , 0 . 0f ) ) ; <nl> + } <nl> + switch ( _gravity ) { <nl> + case LISTVIEW_GRAVITY_TOP : <nl> + llp - > setGravity ( LINEAR_GRAVITY_TOP ) ; <nl> + break ; <nl> + case LISTVIEW_GRAVITY_BOTTOM : <nl> + llp - > setGravity ( LINEAR_GRAVITY_BOTTOM ) ; <nl> + break ; <nl> + case LISTVIEW_GRAVITY_CENTER_VERTICAL : <nl> + llp - > setGravity ( LINEAR_GRAVITY_CENTER_VERTICAL ) ; <nl> + break ; <nl> + default : <nl> + break ; <nl> } <nl> } <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> break ; <nl> - <nl> + } <nl> default : <nl> break ; <nl> } <nl> + <nl> } <nl> <nl> - float UIListView : : getCurAutoScrollDistance ( float time ) <nl> - { <nl> - float dt = time ; <nl> - _autoScrollOriginalSpeed - = _autoScrollAcceleration * dt ; <nl> - return _autoScrollOriginalSpeed * dt ; <nl> - } <nl> - <nl> - void UIListView : : startAutoScrollChildren ( float v ) <nl> - { <nl> - _autoScrollOriginalSpeed = v ; <nl> - _autoScroll = true ; <nl> - } <nl> - <nl> - void UIListView : : stopAutoScrollChildren ( ) <nl> - { <nl> - _autoScroll = false ; <nl> - _autoScrollOriginalSpeed = 0 . 0f ; <nl> - } <nl> - <nl> - void UIListView : : recordSlidTime ( float dt ) <nl> - { <nl> - if ( _bePressed ) <nl> - { <nl> - _slidTime + = dt ; <nl> - } <nl> - } <nl> - <nl> - void UIListView : : startRecordSlidAction ( ) <nl> + void UIListView : : pushBackDefaultItem ( ) <nl> { <nl> - if ( _children - > count ( ) < = 0 ) <nl> + if ( ! _model ) <nl> { <nl> return ; <nl> } <nl> - if ( _autoScroll ) <nl> - { <nl> - stopAutoScrollChildren ( ) ; <nl> - } <nl> - _bePressed = true ; <nl> - _slidTime = 0 . 0 ; <nl> + UIWidget * newItem = _model - > clone ( ) ; <nl> + _items - > addObject ( newItem ) ; <nl> + remedyLayoutParameter ( newItem ) ; <nl> + addChild ( newItem ) ; <nl> } <nl> <nl> - void UIListView : : endRecordSlidAction ( ) <nl> + void UIListView : : insertDefaultItem ( int index ) <nl> { <nl> - if ( _children - > count ( ) < = 0 ) <nl> + if ( ! _items ) <nl> { <nl> return ; <nl> } <nl> - if ( _slidTime < = 0 . 016f ) <nl> + if ( ! _model ) <nl> { <nl> return ; <nl> } <nl> - float totalDis = 0 ; <nl> - totalDis = _touchEndLocation - _touchStartLocation ; <nl> - float orSpeed = fabs ( totalDis ) / ( _slidTime ) ; <nl> - startAutoScrollChildren ( orSpeed / 4 ) ; <nl> - <nl> - _bePressed = false ; <nl> - _slidTime = 0 . 0 ; <nl> + UIWidget * newItem = _model - > clone ( ) ; <nl> + _items - > insertObject ( newItem , index ) ; <nl> + remedyLayoutParameter ( newItem ) ; <nl> + addChild ( newItem ) ; <nl> } <nl> <nl> - UIWidget * UIListView : : getCheckPositionChild ( ) <nl> + void UIListView : : pushBackCustomItem ( UIWidget * item ) <nl> { <nl> - UIWidget * child = NULL ; <nl> - <nl> - switch ( _direction ) <nl> - { <nl> - case LISTVIEW_DIR_VERTICAL : / / vertical <nl> - switch ( _moveDirection ) <nl> - { <nl> - case LISTVIEW_MOVE_DIR_UP : / / up <nl> - child = dynamic_cast < UIWidget * > ( _childPool - > getLastObject ( ) ) ; <nl> - break ; <nl> - <nl> - case LISTVIEW_MOVE_DIR_DOWN : / / down <nl> - child = dynamic_cast < UIWidget * > ( _childPool - > getObjectAtIndex ( 0 ) ) ; <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - break ; <nl> - <nl> - case LISTVIEW_DIR_HORIZONTAL : / / horizontal <nl> - switch ( _moveDirection ) <nl> - { <nl> - case LISTVIEW_MOVE_DIR_LEFT : / / left <nl> - child = dynamic_cast < UIWidget * > ( _childPool - > getLastObject ( ) ) ; <nl> - break ; <nl> - <nl> - case LISTVIEW_MOVE_DIR_RIGHT : / / right <nl> - child = dynamic_cast < UIWidget * > ( _childPool - > getObjectAtIndex ( 0 ) ) ; <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - <nl> - return child ; <nl> + _items - > addObject ( item ) ; <nl> + remedyLayoutParameter ( item ) ; <nl> + addChild ( item ) ; <nl> } <nl> <nl> - void UIListView : : initChildWithDataLength ( int length ) <nl> + void UIListView : : insertCustomItem ( UIWidget * item , int index ) <nl> { <nl> - _dataLength = length ; <nl> - _begin = 0 ; <nl> - _end = 0 ; <nl> - <nl> - / / init child pool <nl> - ccArray * arrayChildren = _children - > data ; <nl> - int times = arrayChildren - > num ; <nl> - for ( int i = 0 ; i < times ; + + i ) <nl> - { <nl> - UIWidget * child = dynamic_cast < UIWidget * > ( arrayChildren - > arr [ i ] ) ; <nl> - setUpdateChild ( child ) ; <nl> - setUpdateDataIndex ( i ) ; <nl> - initChildEvent ( ) ; <nl> - _childPool - > addObject ( child ) ; <nl> - _end = i ; <nl> - } <nl> - } <nl> - <nl> - UIWidget * UIListView : : getChildFromUpdatePool ( ) <nl> - { <nl> - UIWidget * child = dynamic_cast < UIWidget * > ( _updatePool - > getLastObject ( ) ) ; <nl> - _updatePool - > removeLastObject ( ) ; <nl> - return child ; <nl> - } <nl> - <nl> - void UIListView : : pushChildToPool ( ) <nl> - { <nl> - switch ( _direction ) <nl> - { <nl> - case LISTVIEW_DIR_VERTICAL : / / vertical <nl> - switch ( _moveDirection ) <nl> - { <nl> - case LISTVIEW_MOVE_DIR_UP : / / up <nl> - { <nl> - UIWidget * child = dynamic_cast < UIWidget * > ( _childPool - > getObjectAtIndex ( 0 ) ) ; <nl> - _updatePool - > insertObject ( child , 0 ) ; <nl> - _childPool - > removeObjectAtIndex ( 0 ) ; <nl> - } <nl> - break ; <nl> - <nl> - case LISTVIEW_MOVE_DIR_DOWN : / / down <nl> - { <nl> - UIWidget * child = dynamic_cast < UIWidget * > ( _childPool - > getLastObject ( ) ) ; <nl> - _updatePool - > insertObject ( child , 0 ) ; <nl> - _childPool - > removeLastObject ( ) ; <nl> - <nl> - } <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - break ; <nl> - <nl> - case LISTVIEW_DIR_HORIZONTAL : / / horizontal <nl> - switch ( _moveDirection ) <nl> - { <nl> - case LISTVIEW_MOVE_DIR_LEFT : / / left <nl> - { <nl> - UIWidget * child = dynamic_cast < UIWidget * > ( _childPool - > getObjectAtIndex ( 0 ) ) ; <nl> - _updatePool - > insertObject ( child , 0 ) ; <nl> - _childPool - > removeObjectAtIndex ( 0 ) ; <nl> - } <nl> - break ; <nl> - <nl> - case LISTVIEW_MOVE_DIR_RIGHT : / / right <nl> - { <nl> - UIWidget * child = dynamic_cast < UIWidget * > ( _childPool - > getLastObject ( ) ) ; <nl> - _updatePool - > insertObject ( child , 0 ) ; <nl> - _childPool - > removeLastObject ( ) ; <nl> - } <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> + _items - > insertObject ( item , index ) ; <nl> + remedyLayoutParameter ( item ) ; <nl> + addChild ( item ) ; <nl> } <nl> <nl> - void UIListView : : getAndCallback ( ) <nl> + void UIListView : : removeItem ( int index ) <nl> { <nl> - UIWidget * child = getChildFromUpdatePool ( ) ; <nl> - <nl> - if ( child = = NULL ) <nl> + if ( ! _items ) <nl> { <nl> return ; <nl> } <nl> - <nl> - switch ( _direction ) <nl> + UIWidget * item = getItem ( index ) ; <nl> + if ( ! item ) <nl> { <nl> - case LISTVIEW_DIR_VERTICAL : / / vertical <nl> - switch ( _moveDirection ) <nl> - { <nl> - case LISTVIEW_MOVE_DIR_UP : / / up <nl> - + + _end ; <nl> - setUpdateChild ( child ) ; <nl> - setUpdateDataIndex ( _end ) ; <nl> - updateChildEvent ( ) ; <nl> - <nl> - if ( _updateSuccess = = false ) <nl> - { <nl> - - - _end ; <nl> - _childPool - > insertObject ( child , 0 ) ; <nl> - return ; <nl> - } <nl> - + + _begin ; <nl> - break ; <nl> - <nl> - case LISTVIEW_MOVE_DIR_DOWN : / / down <nl> - - - _begin ; <nl> - setUpdateChild ( child ) ; <nl> - setUpdateDataIndex ( _begin ) ; <nl> - updateChildEvent ( ) ; <nl> - <nl> - if ( _updateSuccess = = false ) <nl> - { <nl> - + + _begin ; <nl> - _childPool - > addObject ( child ) ; <nl> - return ; <nl> - } <nl> - - - _end ; <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - break ; <nl> - <nl> - case LISTVIEW_DIR_HORIZONTAL : / / horizontal <nl> - switch ( _moveDirection ) <nl> - { <nl> - case LISTVIEW_MOVE_DIR_LEFT : / / left <nl> - + + _end ; <nl> - setUpdateChild ( child ) ; <nl> - setUpdateDataIndex ( _end ) ; <nl> - updateChildEvent ( ) ; <nl> - <nl> - if ( _updateSuccess = = false ) <nl> - { <nl> - - - _end ; <nl> - _childPool - > insertObject ( child , 0 ) ; <nl> - return ; <nl> - } <nl> - + + _begin ; <nl> - break ; <nl> - <nl> - case LISTVIEW_MOVE_DIR_RIGHT : / / right <nl> - - - _begin ; <nl> - setUpdateChild ( child ) ; <nl> - setUpdateDataIndex ( _begin ) ; <nl> - updateChildEvent ( ) ; <nl> - <nl> - if ( _updateSuccess = = false ) <nl> - { <nl> - + + _begin ; <nl> - _childPool - > addObject ( child ) ; <nl> - return ; <nl> - } <nl> - - - _end ; <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - <nl> - switch ( _direction ) <nl> - { <nl> - case LISTVIEW_DIR_VERTICAL : / / vertical <nl> - switch ( _moveDirection ) <nl> - { <nl> - case LISTVIEW_MOVE_DIR_UP : / / up <nl> - _childPool - > addObject ( child ) ; <nl> - break ; <nl> - <nl> - case LISTVIEW_MOVE_DIR_DOWN : / / down <nl> - _childPool - > insertObject ( child , 0 ) ; <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - break ; <nl> - <nl> - case LISTVIEW_DIR_HORIZONTAL : / / horizontal <nl> - switch ( _moveDirection ) <nl> - { <nl> - case LISTVIEW_MOVE_DIR_LEFT : / / left <nl> - _childPool - > addObject ( child ) ; <nl> - break ; <nl> - case LISTVIEW_MOVE_DIR_RIGHT : / / right <nl> - _childPool - > insertObject ( child , 0 ) ; <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> + return ; <nl> + <nl> } <nl> + _items - > removeObject ( item ) ; <nl> + removeChild ( item ) ; <nl> } <nl> <nl> - int UIListView : : getDataLength ( ) <nl> - { <nl> - return _dataLength ; <nl> - } <nl> - <nl> - UIWidget * UIListView : : getUpdateChild ( ) <nl> + void UIListView : : removeLastItem ( ) <nl> { <nl> - return _updateChild ; <nl> + removeItem ( _items - > count ( ) - 1 ) ; <nl> } <nl> <nl> - void UIListView : : setUpdateChild ( UIWidget * child ) <nl> + UIWidget * UIListView : : getItem ( unsigned int index ) <nl> { <nl> - _updateChild = child ; <nl> + if ( ( int ) index < 0 | | index > = _items - > count ( ) ) <nl> + { <nl> + return NULL ; <nl> + } <nl> + return ( UIWidget * ) ( _items - > data - > arr [ index ] ) ; <nl> } <nl> <nl> - int UIListView : : getUpdateDataIndex ( ) <nl> + cocos2d : : Array * UIListView : : getItems ( ) <nl> { <nl> - return _updateDataIndex ; <nl> + return _items ; <nl> } <nl> <nl> - void UIListView : : setUpdateDataIndex ( int index ) <nl> + unsigned int UIListView : : getIndex ( UIWidget * item ) const <nl> { <nl> - _updateDataIndex = index ; <nl> + if ( ! _items ) <nl> + { <nl> + return - 1 ; <nl> + } <nl> + if ( ! item ) <nl> + { <nl> + return - 1 ; <nl> + } <nl> + return _items - > getIndexOfObject ( item ) ; <nl> } <nl> <nl> - bool UIListView : : getUpdateSuccess ( ) <nl> + void UIListView : : setGravity ( ListViewGravity gravity ) <nl> { <nl> - return _updateSuccess ; <nl> + if ( _gravity = = gravity ) <nl> + { <nl> + return ; <nl> + } <nl> + _gravity = gravity ; <nl> + refreshView ( ) ; <nl> } <nl> <nl> - void UIListView : : setUpdateSuccess ( bool sucess ) <nl> + void UIListView : : setItemsMargin ( float margin ) <nl> { <nl> - _updateSuccess = sucess ; <nl> + if ( _itemsMargin = = margin ) <nl> + { <nl> + return ; <nl> + } <nl> + _itemsMargin = margin ; <nl> + refreshView ( ) ; <nl> } <nl> <nl> - void UIListView : : clearCollectOverArray ( ) <nl> + void UIListView : : setDirection ( SCROLLVIEW_DIR dir ) <nl> { <nl> - switch ( _direction ) <nl> + switch ( dir ) <nl> { <nl> - case LISTVIEW_DIR_VERTICAL : <nl> - _overTopArray - > removeAllObjects ( ) ; <nl> - _overBottomArray - > removeAllObjects ( ) ; <nl> + case SCROLLVIEW_DIR_VERTICAL : <nl> + setLayoutType ( LAYOUT_LINEAR_VERTICAL ) ; <nl> break ; <nl> - <nl> - case LISTVIEW_DIR_HORIZONTAL : <nl> - _overLeftArray - > removeAllObjects ( ) ; <nl> - _overRightArray - > removeAllObjects ( ) ; <nl> + case SCROLLVIEW_DIR_HORIZONTAL : <nl> + setLayoutType ( LAYOUT_LINEAR_HORIZONTAL ) ; <nl> break ; <nl> - <nl> + case SCROLLVIEW_DIR_BOTH : <nl> + return ; <nl> default : <nl> + return ; <nl> break ; <nl> } <nl> - } <nl> - <nl> - void UIListView : : collectOverTopChild ( ) <nl> - { <nl> - float scroll_top = _topBoundary ; <nl> + UIScrollView : : setDirection ( dir ) ; <nl> <nl> - ccArray * arrayChildren = _children - > data ; <nl> - int times = arrayChildren - > num ; <nl> - for ( int i = 0 ; i < times ; + + i ) <nl> - { <nl> - UIWidget * child = dynamic_cast < UIWidget * > ( arrayChildren - > arr [ i ] ) ; <nl> - float child_bottom = child - > getBottomInParent ( ) ; <nl> - <nl> - if ( child_bottom > = scroll_top ) <nl> - { <nl> - _overTopArray - > addObject ( child ) ; <nl> - } <nl> - } <nl> } <nl> <nl> - void UIListView : : collectOverBottomChild ( ) <nl> + void UIListView : : refreshView ( ) <nl> { <nl> - float scroll_bottom = _bottomBoundary ; <nl> - <nl> - ccArray * arrayChildren = _children - > data ; <nl> - int times = arrayChildren - > num ; <nl> - for ( int i = 0 ; i < times ; + + i ) <nl> + if ( ! _items ) <nl> { <nl> - UIWidget * child = dynamic_cast < UIWidget * > ( arrayChildren - > arr [ i ] ) ; <nl> - float child_top = child - > getTopInParent ( ) ; <nl> - <nl> - if ( child_top < = scroll_bottom ) <nl> - { <nl> - _overBottomArray - > addObject ( child ) ; <nl> - } <nl> + return ; <nl> } <nl> - } <nl> - <nl> - void UIListView : : collectOverLeftChild ( ) <nl> - { <nl> - float scroll_left = _leftBoundary ; <nl> - <nl> - ccArray * arrayChildren = _children - > data ; <nl> - int times = arrayChildren - > num ; <nl> - for ( int i = 0 ; i < times ; + + i ) <nl> + cocos2d : : ccArray * arrayItems = _items - > data ; <nl> + int length = arrayItems - > num ; <nl> + for ( int i = 0 ; i < length ; i + + ) <nl> { <nl> - UIWidget * child = dynamic_cast < UIWidget * > ( arrayChildren - > arr [ i ] ) ; <nl> - float child_right = child - > getRightInParent ( ) ; <nl> - <nl> - if ( child_right < = scroll_left ) <nl> - { <nl> - _overLeftArray - > addObject ( child ) ; <nl> - } <nl> + UIWidget * item = ( UIWidget * ) ( arrayItems - > arr [ i ] ) ; <nl> + item - > setZOrder ( i ) ; <nl> + remedyLayoutParameter ( item ) ; <nl> } <nl> + updateInnerContainerSize ( ) ; <nl> + doLayout ( ) ; <nl> } <nl> <nl> - void UIListView : : collectOverRightChild ( ) <nl> + void UIListView : : onSizeChanged ( ) <nl> { <nl> - float scroll_right = _rightBoundary ; <nl> - <nl> - ccArray * arrayChildren = _children - > data ; <nl> - int times = arrayChildren - > num ; <nl> - for ( int i = 0 ; i < times ; + + i ) <nl> - { <nl> - UIWidget * child = dynamic_cast < UIWidget * > ( arrayChildren - > arr [ i ] ) ; <nl> - float child_left = child - > getLeftInParent ( ) ; <nl> - if ( child_left > = scroll_right ) <nl> - { <nl> - _overRightArray - > addObject ( child ) ; <nl> - } <nl> - } <nl> + UIScrollView : : onSizeChanged ( ) ; <nl> + refreshView ( ) ; <nl> } <nl> <nl> - void UIListView : : setLoopPosition ( ) <nl> + const char * UIListView : : getDescription ( ) const <nl> { <nl> - switch ( _direction ) <nl> - { <nl> - case LISTVIEW_DIR_VERTICAL : / / vertical <nl> - switch ( _moveDirection ) <nl> - { <nl> - case LISTVIEW_MOVE_DIR_UP : / / up <nl> - { <nl> - ccArray * arrayChildren = _children - > data ; <nl> - unsigned int childrenCount = arrayChildren - > num ; <nl> - <nl> - if ( _overTopArray - > count ( ) = = childrenCount ) <nl> - { <nl> - unsigned int count = childrenCount ; <nl> - for ( unsigned int i = 0 ; i < count ; + + i ) <nl> - { <nl> - UIWidget * child = dynamic_cast < UIWidget * > ( _overTopArray - > getObjectAtIndex ( i ) ) ; <nl> - <nl> - if ( i = = 0 ) <nl> - { <nl> - float height = child - > getSize ( ) . height ; <nl> - float offset = ( child - > getWidgetType ( ) = = WidgetTypeWidget ) ? height / 2 : height ; <nl> - float y = _topBoundary - _disBoundaryToChild_0 - offset ; <nl> - child - > setPosition ( Point ( child - > getPosition ( ) . x , y ) ) ; <nl> - } <nl> - else <nl> - { <nl> - UIWidget * prev_child = dynamic_cast < UIWidget * > ( _overTopArray - > getObjectAtIndex ( i - 1 ) ) ; <nl> - child - > setPosition ( Point ( child - > getPosition ( ) . x , prev_child - > getPosition ( ) . y - _disBetweenChild ) ) ; <nl> - } <nl> - } <nl> - } <nl> - else <nl> - { <nl> - float scroll_top = _topBoundary ; <nl> - <nl> - ccArray * arrayChildren = _children - > data ; <nl> - int count = arrayChildren - > num ; <nl> - for ( int i = 0 ; i < count ; + + i ) <nl> - { <nl> - UIWidget * child = dynamic_cast < UIWidget * > ( arrayChildren - > arr [ i ] ) ; <nl> - float child_bottom = child - > getBottomInParent ( ) ; <nl> - <nl> - if ( child_bottom > = scroll_top ) <nl> - { <nl> - int index = ( i = = 0 ) ? ( count - 1 ) : ( i - 1 ) ; <nl> - UIWidget * prev_child = dynamic_cast < UIWidget * > ( arrayChildren - > arr [ index ] ) ; <nl> - child - > setPosition ( Point ( child - > getPosition ( ) . x , prev_child - > getPosition ( ) . y - _disBetweenChild ) ) ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - break ; <nl> - <nl> - case LISTVIEW_MOVE_DIR_DOWN : / / down <nl> - { <nl> - ccArray * arrayChildren = _children - > data ; <nl> - unsigned int childrenCount = arrayChildren - > num ; <nl> - <nl> - if ( _overBottomArray - > count ( ) = = childrenCount ) <nl> - { <nl> - unsigned int count = childrenCount ; <nl> - for ( unsigned int i = 0 ; i < count ; + + i ) <nl> - { <nl> - UIWidget * child = dynamic_cast < UIWidget * > ( _overBottomArray - > getObjectAtIndex ( i ) ) ; <nl> - <nl> - if ( i = = 0 ) <nl> - { <nl> - float y = _bottomBoundary + _disBoundaryToChild_0 - _disBetweenChild ; <nl> - child - > setPosition ( Point ( child - > getPosition ( ) . x , y ) ) ; <nl> - } <nl> - else <nl> - { <nl> - UIWidget * prev_child = dynamic_cast < UIWidget * > ( _overBottomArray - > getObjectAtIndex ( i - 1 ) ) ; <nl> - child - > setPosition ( Point ( child - > getPosition ( ) . x , prev_child - > getPosition ( ) . y + _disBetweenChild ) ) ; <nl> - } <nl> - } <nl> - } <nl> - else <nl> - { <nl> - float scroll_bottom = _bottomBoundary ; <nl> - <nl> - ccArray * arrayChildren = _children - > data ; <nl> - int count = arrayChildren - > num ; <nl> - for ( int i = count - 1 ; i > = 0 ; - - i ) <nl> - { <nl> - UIWidget * child = dynamic_cast < UIWidget * > ( arrayChildren - > arr [ i ] ) ; <nl> - float child_top = child - > getTopInParent ( ) ; <nl> - <nl> - if ( child_top < = scroll_bottom ) <nl> - { <nl> - int index = ( i = = count - 1 ) ? 0 : ( i + 1 ) ; <nl> - UIWidget * next_child = dynamic_cast < UIWidget * > ( arrayChildren - > arr [ index ] ) ; <nl> - child - > setPosition ( Point ( child - > getPosition ( ) . x , next_child - > getPosition ( ) . y + _disBetweenChild ) ) ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - break ; <nl> - <nl> - case LISTVIEW_DIR_HORIZONTAL : / / horizontal <nl> - switch ( _moveDirection ) <nl> - { <nl> - case LISTVIEW_MOVE_DIR_LEFT : / / left <nl> - { <nl> - ccArray * arrayChildren = _children - > data ; <nl> - unsigned int childrenCount = arrayChildren - > num ; <nl> - <nl> - if ( _overLeftArray - > count ( ) = = childrenCount ) <nl> - { <nl> - unsigned int count = childrenCount ; <nl> - for ( unsigned int i = 0 ; i < count ; + + i ) <nl> - { <nl> - UIWidget * child = dynamic_cast < UIWidget * > ( _overLeftArray - > getObjectAtIndex ( i ) ) ; <nl> - <nl> - if ( i = = 0 ) <nl> - { <nl> - float width = child - > getSize ( ) . width ; <nl> - float offset = ( child - > getWidgetType ( ) = = WidgetTypeWidget ) ? ( width / 2 ) : 0 ; <nl> - float x = _leftBoundary + _disBoundaryToChild_0 + width + offset ; <nl> - child - > setPosition ( Point ( x , child - > getPosition ( ) . y ) ) ; <nl> - } <nl> - else <nl> - { <nl> - UIWidget * prev_child = dynamic_cast < UIWidget * > ( _overLeftArray - > getObjectAtIndex ( i - 1 ) ) ; <nl> - child - > setPosition ( Point ( prev_child - > getPosition ( ) . x + _disBetweenChild , child - > getPosition ( ) . y ) ) ; <nl> - } <nl> - } <nl> - } <nl> - else <nl> - { <nl> - float scroll_left = _leftBoundary ; <nl> - <nl> - ccArray * arrayChildren = _children - > data ; <nl> - int count = arrayChildren - > num ; <nl> - for ( int i = 0 ; i < count ; + + i ) <nl> - { <nl> - UIWidget * child = dynamic_cast < UIWidget * > ( arrayChildren - > arr [ i ] ) ; <nl> - float child_right = child - > getRightInParent ( ) ; <nl> - <nl> - if ( child_right < = scroll_left ) <nl> - { <nl> - int index = ( i = = 0 ) ? ( count - 1 ) : ( i - 1 ) ; <nl> - UIWidget * prev_child = dynamic_cast < UIWidget * > ( arrayChildren - > arr [ index ] ) ; <nl> - child - > setPosition ( Point ( prev_child - > getPosition ( ) . x + _disBetweenChild , child - > getPosition ( ) . y ) ) ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - break ; <nl> - <nl> - case LISTVIEW_MOVE_DIR_RIGHT : / / right <nl> - { <nl> - ccArray * arrayChildren = _children - > data ; <nl> - unsigned int childrenCount = arrayChildren - > num ; <nl> - <nl> - if ( _overRightArray - > count ( ) = = childrenCount ) <nl> - { <nl> - unsigned int count = childrenCount ; <nl> - for ( unsigned int i = 0 ; i < count ; + + i ) <nl> - { <nl> - UIWidget * child = dynamic_cast < UIWidget * > ( _overRightArray - > getObjectAtIndex ( i ) ) ; <nl> - <nl> - if ( i = = 0 ) <nl> - { <nl> - float x = _rightBoundary - _disBoundaryToChild_0 + _disBetweenChild ; <nl> - child - > setPosition ( Point ( x , child - > getPosition ( ) . y ) ) ; <nl> - } <nl> - else <nl> - { <nl> - UIWidget * prev_child = dynamic_cast < UIWidget * > ( _overRightArray - > getObjectAtIndex ( i - 1 ) ) ; <nl> - child - > setPosition ( Point ( prev_child - > getPosition ( ) . x - _disBetweenChild , child - > getPosition ( ) . y ) ) ; <nl> - } <nl> - } <nl> - } <nl> - else <nl> - { <nl> - float scroll_right = _rightBoundary ; <nl> - <nl> - ccArray * arrayChildren = _children - > data ; <nl> - int count = arrayChildren - > num ; <nl> - for ( int i = count - 1 ; i > = 0 ; - - i ) <nl> - { <nl> - UIWidget * child = dynamic_cast < UIWidget * > ( arrayChildren - > arr [ i ] ) ; <nl> - float child_left = child - > getLeftInParent ( ) ; <nl> - <nl> - if ( child_left > = scroll_right ) <nl> - { <nl> - int index = ( i = = count - 1 ) ? 0 : ( i + 1 ) ; <nl> - UIWidget * next_child = dynamic_cast < UIWidget * > ( arrayChildren - > arr [ index ] ) ; <nl> - child - > setPosition ( Point ( next_child - > getPosition ( ) . x - _disBetweenChild , child - > getPosition ( ) . y ) ) ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> + return " ListViewEx " ; <nl> } <nl> <nl> - void UIListView : : updateChild ( ) <nl> + UIWidget * UIListView : : createCloneInstance ( ) <nl> { <nl> - switch ( _direction ) <nl> - { <nl> - case LISTVIEW_DIR_VERTICAL : / / vertical <nl> - switch ( _moveDirection ) <nl> - { <nl> - case LISTVIEW_MOVE_DIR_UP : / / up <nl> - { <nl> - int count = _overTopArray - > count ( ) ; <nl> - for ( int i = 0 ; i < count ; + + i ) <nl> - { <nl> - pushChildToPool ( ) ; <nl> - getAndCallback ( ) ; <nl> - } <nl> - } <nl> - break ; <nl> - <nl> - case LISTVIEW_MOVE_DIR_DOWN : / / down <nl> - { <nl> - int count = _overBottomArray - > count ( ) ; <nl> - for ( int i = 0 ; i < count ; + + i ) <nl> - { <nl> - pushChildToPool ( ) ; <nl> - getAndCallback ( ) ; <nl> - } <nl> - } <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - break ; <nl> - <nl> - case LISTVIEW_DIR_HORIZONTAL : / / horizontal <nl> - switch ( _moveDirection ) <nl> - { <nl> - case LISTVIEW_MOVE_DIR_LEFT : / / left <nl> - { <nl> - int count = _overLeftArray - > count ( ) ; <nl> - for ( int i = 0 ; i < count ; + + i ) <nl> - { <nl> - pushChildToPool ( ) ; <nl> - getAndCallback ( ) ; <nl> - } <nl> - } <nl> - break ; <nl> - <nl> - case LISTVIEW_MOVE_DIR_RIGHT : / / right <nl> - { <nl> - int count = _overRightArray - > count ( ) ; <nl> - for ( int i = 0 ; i < count ; + + i ) <nl> - { <nl> - pushChildToPool ( ) ; <nl> - getAndCallback ( ) ; <nl> - } <nl> - } <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> + return UIListView : : create ( ) ; <nl> } <nl> <nl> - void UIListView : : initChildEvent ( ) <nl> + void UIListView : : copyClonedWidgetChildren ( UIWidget * model ) <nl> { <nl> - if ( _eventListener & & _eventSelector ) <nl> + cocos2d : : ccArray * arrayItems = dynamic_cast < UIListView * > ( model ) - > getItems ( ) - > data ; <nl> + int length = arrayItems - > num ; <nl> + for ( int i = 0 ; i < length ; i + + ) <nl> { <nl> - ( _eventListener - > * _eventSelector ) ( this , LISTVIEW_EVENT_INIT_CHILD ) ; <nl> + UIWidget * item = ( UIWidget * ) ( arrayItems - > arr [ i ] ) ; <nl> + pushBackCustomItem ( item - > clone ( ) ) ; <nl> } <nl> } <nl> <nl> - void UIListView : : updateChildEvent ( ) <nl> + void UIListView : : copySpecialProperties ( UIWidget * widget ) <nl> { <nl> - if ( _eventListener & & _eventSelector ) <nl> + UIListView * listViewEx = dynamic_cast < UIListView * > ( widget ) ; <nl> + if ( listViewEx ) <nl> { <nl> - ( _eventListener - > * _eventSelector ) ( this , LISTVIEW_EVENT_UPDATE_CHILD ) ; <nl> + UIScrollView : : copySpecialProperties ( widget ) ; <nl> + setItemModel ( listViewEx - > _model ) ; <nl> + setItemsMargin ( listViewEx - > _itemsMargin ) ; <nl> + setGravity ( listViewEx - > _gravity ) ; <nl> } <nl> } <nl> <nl> - void UIListView : : addEventListenter ( Object * target , SEL_ListViewEvent selector ) <nl> - { <nl> - _eventListener = target ; <nl> - _eventSelector = selector ; <nl> } <nl> - <nl> - const char * UIListView : : getDescription ( ) const <nl> - { <nl> - return " ListView " ; <nl> - } <nl> - <nl> - <nl> - } <nl> \ No newline at end of file <nl> mmm a / cocos / gui / UIListView . h <nl> ppp b / cocos / gui / UIListView . h <nl> <nl> THE SOFTWARE . <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> <nl> + <nl> # ifndef __UILISTVIEW_H__ <nl> # define __UILISTVIEW_H__ <nl> <nl> - / * gui mark * / <nl> - # include " gui / Layout . h " <nl> - / * * / <nl> - <nl> - namespace gui { <nl> - <nl> - / * * <nl> - * list view direction <nl> - * / <nl> - typedef enum LISTVIEW_DIR <nl> - { <nl> - LISTVIEW_DIR_NONE , <nl> - LISTVIEW_DIR_VERTICAL , <nl> - LISTVIEW_DIR_HORIZONTAL <nl> - } ListViewDirection ; <nl> + # include " gui / UIScrollView . h " <nl> <nl> - / * * <nl> - * list view scroll direction <nl> - * / <nl> - typedef enum LISTVIEW_MOVE_DIR <nl> - { <nl> - LISTVIEW_MOVE_DIR_NONE , <nl> - LISTVIEW_MOVE_DIR_UP , <nl> - LISTVIEW_MOVE_DIR_DOWN , <nl> - LISTVIEW_MOVE_DIR_LEFT , <nl> - LISTVIEW_MOVE_DIR_RIGHT , <nl> - } ListViewMoveDirection ; <nl> + namespace gui { <nl> <nl> typedef enum <nl> { <nl> - LISTVIEW_EVENT_INIT_CHILD , <nl> - LISTVIEW_EVENT_UPDATE_CHILD , <nl> - } ListViewEventType ; <nl> - <nl> - / * * <nl> - * list view event <nl> - * / <nl> - typedef void ( cocos2d : : Object : : * SEL_ListViewEvent ) ( cocos2d : : Object * , ListViewEventType ) ; <nl> - # define listvieweventselector ( _SELECTOR ) ( SEL_ListViewEvent ) ( & _SELECTOR ) <nl> + LISTVIEW_GRAVITY_LEFT , <nl> + LISTVIEW_GRAVITY_RIGHT , <nl> + LISTVIEW_GRAVITY_CENTER_HORIZONTAL , <nl> + <nl> + LISTVIEW_GRAVITY_TOP , <nl> + LISTVIEW_GRAVITY_BOTTOM , <nl> + LISTVIEW_GRAVITY_CENTER_VERTICAL , <nl> + } ListViewGravity ; <nl> <nl> - class UIListView : public Layout <nl> + class UIListView : public UIScrollView <nl> { <nl> + <nl> public : <nl> + <nl> + / * * <nl> + * Default constructor <nl> + * / <nl> UIListView ( ) ; <nl> - virtual ~ UIListView ( ) ; <nl> - static UIListView * create ( ) ; <nl> <nl> / * * <nl> - * add widget child override <nl> + * Default destructor <nl> * / <nl> - virtual bool addChild ( UIWidget * widget ) ; <nl> + virtual ~ UIListView ( ) ; <nl> + <nl> / * * <nl> - * remove all widget children override <nl> + * Allocates and initializes . <nl> * / <nl> - virtual void removeAllChildren ( ) ; <nl> + static UIListView * create ( ) ; <nl> + <nl> / * * <nl> - * remove widget child override <nl> + * Sets a item model for listview <nl> + * <nl> + * A model will be cloned for adding default item . <nl> + * <nl> + * @ param model item model for listview <nl> * / <nl> - virtual bool removeChild ( UIWidget * child ) ; <nl> + void setItemModel ( UIWidget * model ) ; <nl> <nl> - virtual bool onTouchBegan ( const cocos2d : : Point & touchPoint ) ; <nl> - virtual void onTouchMoved ( const cocos2d : : Point & touchPoint ) ; <nl> - virtual void onTouchEnded ( const cocos2d : : Point & touchPoint ) ; <nl> - virtual void onTouchCancelled ( const cocos2d : : Point & touchPoint ) ; <nl> - virtual void onTouchLongClicked ( const cocos2d : : Point & touchPoint ) ; <nl> + / * * <nl> + * Push back a default item ( create by a cloned model ) into listview . <nl> + * / <nl> + void pushBackDefaultItem ( ) ; <nl> <nl> / * * <nl> - * set and get direction <nl> + * Insert a default item ( create by a cloned model ) into listview . <nl> * / <nl> - void setDirection ( ListViewDirection dir ) ; <nl> - ListViewDirection getDirection ( ) ; <nl> + void insertDefaultItem ( int index ) ; <nl> <nl> / * * <nl> - * initialze data length <nl> - * and create children with parameter length <nl> + * Push back custom item into listview . <nl> * / <nl> - void initChildWithDataLength ( int length ) ; <nl> + void pushBackCustomItem ( UIWidget * item ) ; <nl> + <nl> / * * <nl> - * get data length <nl> + * Insert custom item into listview . <nl> * / <nl> - int getDataLength ( ) ; <nl> + void insertCustomItem ( UIWidget * item , int index ) ; <nl> <nl> / * * <nl> - * update child function whetn trigger update child event <nl> + * Removes the last item of listview . <nl> * / <nl> + void removeLastItem ( ) ; <nl> + <nl> / * * <nl> - * get update widget child <nl> + * Removes a item whose index is same as the parameter . <nl> + * <nl> + * @ param index of item . <nl> * / <nl> - UIWidget * getUpdateChild ( ) ; <nl> + void removeItem ( int index ) ; <nl> + <nl> / * * <nl> - * get update data index <nl> + * Returns a item whose index is same as the parameter . <nl> + * <nl> + * @ param index of item . <nl> + * <nl> + * @ return the item widget . <nl> * / <nl> - int getUpdateDataIndex ( ) ; <nl> + UIWidget * getItem ( unsigned int index ) ; <nl> + <nl> / * * <nl> - * get and set update success or not <nl> + * Returns the item container . <nl> * / <nl> - bool getUpdateSuccess ( ) ; <nl> - void setUpdateSuccess ( bool sucess ) ; <nl> + cocos2d : : Array * getItems ( ) ; <nl> <nl> / * * <nl> - * add event call - back function <nl> + * Returns the index of item . <nl> + * <nl> + * @ param item the item which need to be checked . <nl> + * <nl> + * @ return the index of item . <nl> * / <nl> + unsigned int getIndex ( UIWidget * item ) const ; <nl> + <nl> / * * <nl> - * add event <nl> + * Changes the gravity of listview . <nl> + * @ see ListViewGravity <nl> * / <nl> - void addEventListenter ( cocos2d : : Object * target , SEL_ListViewEvent selector ) ; <nl> + void setGravity ( ListViewGravity gravity ) ; <nl> <nl> - / * gui mark * / <nl> / * * <nl> - * get and set degree range for checking move or not with scrolling <nl> + * Changes the margin between each item . <nl> + * <nl> + * @ param margin <nl> * / <nl> - / * * / <nl> - virtual void update ( float dt ) ; <nl> + void setItemsMargin ( float margin ) ; <nl> <nl> - virtual void doLayout ( ) { } ; <nl> + / * * <nl> + * Refresh the view of list . <nl> + * <nl> + * If you change the data , you need to call this mathod . <nl> + * / <nl> + void refreshView ( ) ; <nl> <nl> / * * <nl> - * Returns the " class name " of widget . <nl> + * Changes scroll direction of scrollview . <nl> + * <nl> + * @ see SCROLLVIEW_DIR SCROLLVIEW_DIR_VERTICAL means vertical scroll , SCROLLVIEW_DIR_HORIZONTAL means horizontal scroll <nl> + * <nl> + * @ param SCROLLVIEW_DIR <nl> * / <nl> + virtual void setDirection ( SCROLLVIEW_DIR dir ) ; <nl> + <nl> virtual const char * getDescription ( ) const ; <nl> + <nl> protected : <nl> virtual bool init ( ) ; <nl> - <nl> + void updateInnerContainerSize ( ) ; <nl> + void remedyLayoutParameter ( UIWidget * item ) ; <nl> virtual void onSizeChanged ( ) ; <nl> - <nl> - void setMoveDirection ( ListViewMoveDirection dir ) ; <nl> - ListViewMoveDirection getMoveDirection ( ) ; <nl> - <nl> - virtual void resetProperty ( ) ; <nl> - <nl> - virtual void handlePressLogic ( const cocos2d : : Point & touchPoint ) ; <nl> - virtual void handleMoveLogic ( const cocos2d : : Point & touchPoint ) ; <nl> - virtual void handleReleaseLogic ( const cocos2d : : Point & touchPoint ) ; <nl> - virtual void interceptTouchEvent ( int handleState , UIWidget * sender , const cocos2d : : Point & touchPoint ) ; <nl> - / * gui mark * / <nl> - / / virtual bool isInScrollDegreeRange ( UIWidget * widget ) ; <nl> - / * * / <nl> - virtual void checkChildInfo ( int handleState , UIWidget * sender , const cocos2d : : Point & touchPoint ) ; <nl> - <nl> - void moveChildren ( float offset ) ; <nl> - virtual bool scrollChildren ( float touchOffset ) ; <nl> - void autoScrollChildren ( float dt ) ; <nl> - float getCurAutoScrollDistance ( float time ) ; <nl> - void startAutoScrollChildren ( float v ) ; <nl> - void stopAutoScrollChildren ( ) ; <nl> - void recordSlidTime ( float dt ) ; <nl> - void startRecordSlidAction ( ) ; <nl> - virtual void endRecordSlidAction ( ) ; <nl> - <nl> - UIWidget * getCheckPositionChild ( ) ; <nl> - UIWidget * getChildFromUpdatePool ( ) ; <nl> - void pushChildToPool ( ) ; <nl> - void getAndCallback ( ) ; <nl> - <nl> - void setUpdateChild ( UIWidget * child ) ; <nl> - void setUpdateDataIndex ( int index ) ; <nl> - void clearCollectOverArray ( ) ; <nl> - void collectOverTopChild ( ) ; <nl> - void collectOverBottomChild ( ) ; <nl> - void collectOverLeftChild ( ) ; <nl> - void collectOverRightChild ( ) ; <nl> - void setLoopPosition ( ) ; <nl> - void updateChild ( ) ; <nl> - <nl> - void initChildEvent ( ) ; <nl> - void updateChildEvent ( ) ; <nl> - <nl> - virtual void setClippingEnabled ( bool able ) { Layout : : setClippingEnabled ( able ) ; } ; <nl> + virtual UIWidget * createCloneInstance ( ) ; <nl> + virtual void copySpecialProperties ( UIWidget * model ) ; <nl> + virtual void copyClonedWidgetChildren ( UIWidget * model ) ; <nl> protected : <nl> - ListViewDirection _direction ; <nl> - ListViewMoveDirection _moveDirection ; <nl> - <nl> - float _touchStartLocation ; <nl> - float _touchEndLocation ; <nl> - float _touchMoveStartLocation ; <nl> - float _topBoundary ; / / test <nl> - float _bottomBoundary ; / / test <nl> - float _leftBoundary ; <nl> - float _rightBoundary ; <nl> - <nl> - bool _autoScroll ; <nl> - <nl> - float _autoScrollOriginalSpeed ; <nl> - float _autoScrollAcceleration ; <nl> - <nl> - bool _bePressed ; <nl> - float _slidTime ; <nl> - cocos2d : : Point _moveChildPoint ; <nl> - float _childFocusCancelOffset ; <nl> - <nl> - cocos2d : : Object * _eventListener ; <nl> - SEL_ListViewEvent _eventSelector ; <nl> - <nl> - cocos2d : : Array * _childPool ; <nl> - cocos2d : : Array * _updatePool ; <nl> - <nl> - int _dataLength ; <nl> - int _begin ; <nl> - int _end ; <nl> - UIWidget * _updateChild ; <nl> - int _updateDataIndex ; <nl> - bool _updateSuccess ; <nl> - <nl> - cocos2d : : Array * _overTopArray ; <nl> - cocos2d : : Array * _overBottomArray ; <nl> - cocos2d : : Array * _overLeftArray ; <nl> - cocos2d : : Array * _overRightArray ; <nl> - <nl> - float _disBoundaryToChild_0 ; <nl> - float _disBetweenChild ; <nl> - <nl> - / * gui mark * / <nl> - float _scrollDegreeRange ; <nl> - / * * / <nl> + <nl> + UIWidget * _model ; <nl> + cocos2d : : Array * _items ; <nl> + ListViewGravity _gravity ; <nl> + float _itemsMargin ; <nl> } ; <nl> <nl> } <nl> <nl> - <nl> - # endif / * defined ( __Test__UIListView__ ) * / <nl> + # endif / * defined ( __UIListView__ ) * / <nl> mmm a / cocos / gui / UILoadingBar . cpp <nl> ppp b / cocos / gui / UILoadingBar . cpp <nl> <nl> # include " gui / UILoadingBar . h " <nl> # include " extensions / GUI / CCControlExtension / CCScale9Sprite . h " <nl> <nl> - using namespace cocos2d ; <nl> - using namespace cocos2d : : extension ; <nl> - <nl> namespace gui { <nl> <nl> + <nl> # define DYNAMIC_CAST_CCSPRITE dynamic_cast < cocos2d : : Sprite * > ( _barRenderer ) <nl> <nl> UILoadingBar : : UILoadingBar ( ) : <nl> _percent ( 100 ) , <nl> _totalLength ( 0 ) , <nl> _barRenderer ( NULL ) , <nl> _renderBarTexType ( UI_TEX_TYPE_LOCAL ) , <nl> - _barRendererTextureSize ( Size : : ZERO ) , <nl> + _barRendererTextureSize ( cocos2d : : Size : : ZERO ) , <nl> _scale9Enabled ( false ) , <nl> _prevIgnoreSize ( true ) , <nl> - _capInsets ( Rect : : ZERO ) , <nl> + _capInsets ( cocos2d : : Rect : : ZERO ) , <nl> _textureFile ( " " ) <nl> { <nl> } <nl> UILoadingBar * UILoadingBar : : create ( ) <nl> void UILoadingBar : : initRenderer ( ) <nl> { <nl> UIWidget : : initRenderer ( ) ; <nl> - _barRenderer = CCSprite : : create ( ) ; <nl> + _barRenderer = cocos2d : : Sprite : : create ( ) ; <nl> _renderer - > addChild ( _barRenderer ) ; <nl> - _barRenderer - > setAnchorPoint ( Point ( 0 . 0f , 0 . 5f ) ) ; <nl> + _barRenderer - > setAnchorPoint ( cocos2d : : Point ( 0 . 0 , 0 . 5 ) ) ; <nl> } <nl> <nl> void UILoadingBar : : setDirection ( LoadingBarType dir ) <nl> void UILoadingBar : : setDirection ( LoadingBarType dir ) <nl> switch ( _barType ) <nl> { <nl> case LoadingBarTypeLeft : <nl> - _barRenderer - > setAnchorPoint ( Point ( 0 . 0f , 0 . 5f ) ) ; <nl> - _barRenderer - > setPosition ( Point ( - _totalLength * 0 . 5f , 0 . 0f ) ) ; <nl> + _barRenderer - > setAnchorPoint ( cocos2d : : Point ( 0 . 0f , 0 . 5f ) ) ; <nl> + _barRenderer - > setPosition ( cocos2d : : Point ( - _totalLength * 0 . 5f , 0 . 0f ) ) ; <nl> if ( ! _scale9Enabled ) <nl> { <nl> - dynamic_cast < Sprite * > ( _barRenderer ) - > setFlippedX ( false ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _barRenderer ) - > setFlippedX ( false ) ; <nl> } <nl> break ; <nl> case LoadingBarTypeRight : <nl> - _barRenderer - > setAnchorPoint ( Point ( 1 . 0f , 0 . 5f ) ) ; <nl> - _barRenderer - > setPosition ( Point ( _totalLength * 0 . 5f , 0 . 0f ) ) ; <nl> + _barRenderer - > setAnchorPoint ( cocos2d : : Point ( 1 . 0f , 0 . 5f ) ) ; <nl> + _barRenderer - > setPosition ( cocos2d : : Point ( _totalLength * 0 . 5f , 0 . 0f ) ) ; <nl> if ( ! _scale9Enabled ) <nl> { <nl> - dynamic_cast < Sprite * > ( _barRenderer ) - > setFlippedX ( true ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _barRenderer ) - > setFlippedX ( true ) ; <nl> } <nl> break ; <nl> } <nl> void UILoadingBar : : loadTexture ( const char * texture , TextureResType texType ) <nl> case UI_TEX_TYPE_LOCAL : <nl> if ( _scale9Enabled ) <nl> { <nl> - dynamic_cast < Scale9Sprite * > ( _barRenderer ) - > initWithFile ( texture ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _barRenderer ) - > initWithFile ( texture ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _barRenderer ) - > setCapInsets ( _capInsets ) ; <nl> } <nl> else <nl> { <nl> - dynamic_cast < Sprite * > ( _barRenderer ) - > initWithFile ( texture ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _barRenderer ) - > initWithFile ( texture ) ; <nl> } <nl> break ; <nl> case UI_TEX_TYPE_PLIST : <nl> if ( _scale9Enabled ) <nl> { <nl> - dynamic_cast < Scale9Sprite * > ( _barRenderer ) - > initWithSpriteFrameName ( texture ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _barRenderer ) - > initWithSpriteFrameName ( texture ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _barRenderer ) - > setCapInsets ( _capInsets ) ; <nl> } <nl> else <nl> { <nl> - dynamic_cast < Sprite * > ( _barRenderer ) - > initWithSpriteFrameName ( texture ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _barRenderer ) - > initWithSpriteFrameName ( texture ) ; <nl> } <nl> break ; <nl> default : <nl> void UILoadingBar : : loadTexture ( const char * texture , TextureResType texType ) <nl> } <nl> if ( _scale9Enabled ) <nl> { <nl> - dynamic_cast < Scale9Sprite * > ( _barRenderer ) - > setColor ( getColor ( ) ) ; <nl> - dynamic_cast < Scale9Sprite * > ( _barRenderer ) - > setOpacity ( getOpacity ( ) ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _barRenderer ) - > setColor ( getColor ( ) ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _barRenderer ) - > setOpacity ( getOpacity ( ) ) ; <nl> + <nl> } <nl> else <nl> { <nl> - dynamic_cast < Sprite * > ( _barRenderer ) - > setColor ( getColor ( ) ) ; <nl> - dynamic_cast < Sprite * > ( _barRenderer ) - > setOpacity ( getOpacity ( ) ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _barRenderer ) - > setColor ( getColor ( ) ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _barRenderer ) - > setOpacity ( getOpacity ( ) ) ; <nl> } <nl> - _barRendererTextureSize . width = _barRenderer - > getContentSize ( ) . width ; <nl> - _barRendererTextureSize . height = _barRenderer - > getContentSize ( ) . height ; <nl> + _barRendererTextureSize = _barRenderer - > getContentSize ( ) ; <nl> <nl> switch ( _barType ) <nl> { <nl> case LoadingBarTypeLeft : <nl> - _barRenderer - > setAnchorPoint ( Point ( 0 . 0f , 0 . 5f ) ) ; <nl> + _barRenderer - > setAnchorPoint ( cocos2d : : Point ( 0 . 0f , 0 . 5f ) ) ; <nl> if ( ! _scale9Enabled ) <nl> { <nl> - dynamic_cast < Sprite * > ( _barRenderer ) - > setFlippedX ( false ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _barRenderer ) - > setFlippedX ( false ) ; <nl> } <nl> break ; <nl> case LoadingBarTypeRight : <nl> - _barRenderer - > setAnchorPoint ( Point ( 1 . 0f , 0 . 5f ) ) ; <nl> + _barRenderer - > setAnchorPoint ( cocos2d : : Point ( 1 . 0f , 0 . 5f ) ) ; <nl> if ( ! _scale9Enabled ) <nl> { <nl> - dynamic_cast < Sprite * > ( _barRenderer ) - > setFlippedX ( true ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _barRenderer ) - > setFlippedX ( true ) ; <nl> } <nl> break ; <nl> } <nl> void UILoadingBar : : setScale9Enabled ( bool enabled ) <nl> _barRenderer = NULL ; <nl> if ( _scale9Enabled ) <nl> { <nl> - _barRenderer = Scale9Sprite : : create ( ) ; <nl> + _barRenderer = cocos2d : : extension : : Scale9Sprite : : create ( ) ; <nl> } <nl> else <nl> { <nl> - _barRenderer = CCSprite : : create ( ) ; <nl> + _barRenderer = cocos2d : : Sprite : : create ( ) ; <nl> } <nl> loadTexture ( _textureFile . c_str ( ) , _renderBarTexType ) ; <nl> _renderer - > addChild ( _barRenderer ) ; <nl> void UILoadingBar : : setScale9Enabled ( bool enabled ) <nl> setCapInsets ( _capInsets ) ; <nl> } <nl> <nl> - void UILoadingBar : : setCapInsets ( const Rect & capInsets ) <nl> + void UILoadingBar : : setCapInsets ( const cocos2d : : Rect & capInsets ) <nl> { <nl> _capInsets = capInsets ; <nl> if ( ! _scale9Enabled ) <nl> { <nl> return ; <nl> } <nl> - dynamic_cast < Scale9Sprite * > ( _barRenderer ) - > setCapInsets ( capInsets ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _barRenderer ) - > setCapInsets ( capInsets ) ; <nl> } <nl> <nl> void UILoadingBar : : setPercent ( int percent ) <nl> void UILoadingBar : : setPercent ( int percent ) <nl> { <nl> case UI_TEX_TYPE_PLIST : <nl> { <nl> - Sprite * barNode = DYNAMIC_CAST_CCSPRITE ; <nl> + cocos2d : : Sprite * barNode = DYNAMIC_CAST_CCSPRITE ; <nl> if ( barNode ) <nl> { <nl> - Point to = barNode - > getTextureRect ( ) . origin ; <nl> + cocos2d : : Point to = barNode - > getTextureRect ( ) . origin ; <nl> x = to . x ; <nl> y = to . y ; <nl> } <nl> void UILoadingBar : : setPercent ( int percent ) <nl> } <nl> else <nl> { <nl> - dynamic_cast < Sprite * > ( _barRenderer ) - > setTextureRect ( Rect ( x , y , _barRendererTextureSize . width * res , _barRendererTextureSize . height ) ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _barRenderer ) - > setTextureRect ( cocos2d : : Rect ( x , y , _barRendererTextureSize . width * res , _barRendererTextureSize . height ) ) ; <nl> } <nl> } <nl> <nl> void UILoadingBar : : ignoreContentAdaptWithSize ( bool ignore ) <nl> } <nl> } <nl> <nl> - const Size & UILoadingBar : : getContentSize ( ) const <nl> + const cocos2d : : Size & UILoadingBar : : getContentSize ( ) const <nl> { <nl> return _barRendererTextureSize ; <nl> } <nl> <nl> - Node * UILoadingBar : : getVirtualRenderer ( ) <nl> + cocos2d : : Node * UILoadingBar : : getVirtualRenderer ( ) <nl> { <nl> return _barRenderer ; <nl> } <nl> void UILoadingBar : : barRendererScaleChangedWithSize ( ) <nl> else <nl> { <nl> <nl> - Size textureSize = _barRenderer - > getContentSize ( ) ; <nl> + cocos2d : : Size textureSize = _barRendererTextureSize ; <nl> if ( textureSize . width < = 0 . 0f | | textureSize . height < = 0 . 0f ) <nl> { <nl> _barRenderer - > setScale ( 1 . 0f ) ; <nl> void UILoadingBar : : barRendererScaleChangedWithSize ( ) <nl> switch ( _barType ) <nl> { <nl> case LoadingBarTypeLeft : <nl> - _barRenderer - > setPosition ( Point ( - _totalLength * 0 . 5f , 0 . 0f ) ) ; <nl> + _barRenderer - > setPosition ( cocos2d : : Point ( - _totalLength * 0 . 5f , 0 . 0f ) ) ; <nl> break ; <nl> case LoadingBarTypeRight : <nl> - _barRenderer - > setPosition ( Point ( _totalLength * 0 . 5f , 0 . 0f ) ) ; <nl> + _barRenderer - > setPosition ( cocos2d : : Point ( _totalLength * 0 . 5f , 0 . 0f ) ) ; <nl> break ; <nl> default : <nl> break ; <nl> void UILoadingBar : : barRendererScaleChangedWithSize ( ) <nl> void UILoadingBar : : setScale9Scale ( ) <nl> { <nl> float width = ( float ) ( _percent ) / 100 * _totalLength ; <nl> - dynamic_cast < Scale9Sprite * > ( _barRenderer ) - > setPreferredSize ( Size ( width , _barRendererTextureSize . height ) ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _barRenderer ) - > setPreferredSize ( cocos2d : : Size ( width , _size . height ) ) ; <nl> } <nl> <nl> const char * UILoadingBar : : getDescription ( ) const <nl> const char * UILoadingBar : : getDescription ( ) const <nl> return " LoadingBar " ; <nl> } <nl> <nl> + UIWidget * UILoadingBar : : createCloneInstance ( ) <nl> + { <nl> + return UILoadingBar : : create ( ) ; <nl> + } <nl> + <nl> + void UILoadingBar : : copySpecialProperties ( UIWidget * widget ) <nl> + { <nl> + UILoadingBar * loadingBar = dynamic_cast < UILoadingBar * > ( widget ) ; <nl> + if ( loadingBar ) <nl> + { <nl> + _prevIgnoreSize = loadingBar - > _prevIgnoreSize ; <nl> + setScale9Enabled ( loadingBar - > _scale9Enabled ) ; <nl> + loadTexture ( loadingBar - > _textureFile . c_str ( ) , loadingBar - > _renderBarTexType ) ; <nl> + setCapInsets ( loadingBar - > _capInsets ) ; <nl> + setPercent ( loadingBar - > _percent ) ; <nl> + } <nl> + } <nl> + <nl> } <nl> \ No newline at end of file <nl> mmm a / cocos / gui / UILoadingBar . h <nl> ppp b / cocos / gui / UILoadingBar . h <nl> typedef enum <nl> LoadingBarTypeLeft , <nl> LoadingBarTypeRight <nl> } LoadingBarType ; <nl> - <nl> + / * * <nl> + * @ js NA <nl> + * @ lua NA <nl> + * / <nl> class UILoadingBar : public UIWidget <nl> { <nl> public : <nl> class UILoadingBar : public UIWidget <nl> virtual void onSizeChanged ( ) ; <nl> void setScale9Scale ( ) ; <nl> void barRendererScaleChangedWithSize ( ) ; <nl> + virtual UIWidget * createCloneInstance ( ) ; <nl> + virtual void copySpecialProperties ( UIWidget * model ) ; <nl> protected : <nl> LoadingBarType _barType ; <nl> int _percent ; <nl> mmm a / cocos / gui / UIPageView . cpp <nl> ppp b / cocos / gui / UIPageView . cpp <nl> <nl> <nl> # include " gui / UIPageView . h " <nl> <nl> - using namespace cocos2d ; <nl> - <nl> namespace gui { <nl> <nl> UIPageView : : UIPageView ( ) : <nl> _curPageIdx ( 0 ) , <nl> _pages ( NULL ) , <nl> _touchMoveDir ( PAGEVIEW_TOUCHLEFT ) , <nl> _touchStartLocation ( 0 . 0f ) , <nl> - _touchEndLocation ( 0 . 0f ) , <nl> _touchMoveStartLocation ( 0 . 0f ) , <nl> - _movePagePoint ( Point : : ZERO ) , <nl> + _movePagePoint ( cocos2d : : Point : : ZERO ) , <nl> _leftChild ( NULL ) , <nl> _rightChild ( NULL ) , <nl> _leftBoundary ( 0 . 0f ) , <nl> _eventSelector ( NULL ) <nl> <nl> UIPageView : : ~ UIPageView ( ) <nl> { <nl> - _pages - > release ( ) ; <nl> + _pages - > removeAllObjects ( ) ; <nl> + CC_SAFE_RELEASE ( _pages ) ; <nl> } <nl> <nl> UIPageView * UIPageView : : create ( ) <nl> UIPageView * UIPageView : : create ( ) <nl> <nl> bool UIPageView : : init ( ) <nl> { <nl> - if ( Layout : : init ( ) ) <nl> + if ( UILayout : : init ( ) ) <nl> { <nl> - _pages = CCArray : : create ( ) ; <nl> + _pages = cocos2d : : Array : : create ( ) ; <nl> _pages - > retain ( ) ; <nl> setClippingEnabled ( true ) ; <nl> setUpdateEnabled ( true ) ; <nl> + setTouchEnabled ( true ) ; <nl> return true ; <nl> } <nl> return false ; <nl> void UIPageView : : addWidgetToPage ( UIWidget * widget , int pageIdx , bool forceCreate <nl> { <nl> return ; <nl> } <nl> + if ( pageIdx < 0 ) <nl> + { <nl> + return ; <nl> + } <nl> int pageCount = _pages - > count ( ) ; <nl> if ( pageIdx < 0 | | pageIdx > = pageCount ) <nl> { <nl> void UIPageView : : addWidgetToPage ( UIWidget * widget , int pageIdx , bool forceCreate <nl> { <nl> CCLOG ( " pageIdx is % d , it will be added as page id [ % d ] " , pageIdx , pageCount ) ; <nl> } <nl> - Layout * newPage = createPage ( ) ; <nl> + UILayout * newPage = createPage ( ) ; <nl> newPage - > addChild ( widget ) ; <nl> addPage ( newPage ) ; <nl> } <nl> } <nl> else <nl> { <nl> - Layout * page = dynamic_cast < Layout * > ( _pages - > getObjectAtIndex ( pageIdx ) ) ; <nl> + UILayout * page = dynamic_cast < UILayout * > ( _pages - > getObjectAtIndex ( pageIdx ) ) ; <nl> if ( page ) <nl> { <nl> page - > addChild ( widget ) ; <nl> } <nl> } <nl> - <nl> } <nl> <nl> - Layout * UIPageView : : createPage ( ) <nl> + UILayout * UIPageView : : createPage ( ) <nl> { <nl> - Layout * newPage = Layout : : create ( ) ; <nl> + UILayout * newPage = UILayout : : create ( ) ; <nl> newPage - > setSize ( getSize ( ) ) ; <nl> return newPage ; <nl> } <nl> <nl> - void UIPageView : : addPage ( Layout * page ) <nl> + void UIPageView : : addPage ( UILayout * page ) <nl> { <nl> if ( ! page ) <nl> { <nl> void UIPageView : : addPage ( Layout * page ) <nl> { <nl> return ; <nl> } <nl> - Size pSize = page - > getSize ( ) ; <nl> - Size pvSize = getSize ( ) ; <nl> + cocos2d : : Size pSize = page - > getSize ( ) ; <nl> + cocos2d : : Size pvSize = getSize ( ) ; <nl> if ( ! pSize . equals ( pvSize ) ) <nl> { <nl> CCLOG ( " page size does not match pageview size , it will be force sized ! " ) ; <nl> page - > setSize ( pvSize ) ; <nl> } <nl> - page - > setPosition ( Point ( getPositionXByIndex ( _pages - > count ( ) ) , 0 ) ) ; <nl> + page - > setPosition ( cocos2d : : Point ( getPositionXByIndex ( _pages - > count ( ) ) , 0 ) ) ; <nl> _pages - > addObject ( page ) ; <nl> addChild ( page ) ; <nl> updateBoundaryPages ( ) ; <nl> } <nl> <nl> - void UIPageView : : insertPage ( Layout * page , int idx ) <nl> + void UIPageView : : insertPage ( UILayout * page , int idx ) <nl> { <nl> if ( idx < 0 ) <nl> { <nl> void UIPageView : : insertPage ( Layout * page , int idx ) <nl> else <nl> { <nl> _pages - > insertObject ( page , idx ) ; <nl> - page - > setPosition ( Point ( getPositionXByIndex ( idx ) , 0 ) ) ; <nl> + page - > setPosition ( cocos2d : : Point ( getPositionXByIndex ( idx ) , 0 ) ) ; <nl> addChild ( page ) ; <nl> - Size pSize = page - > getSize ( ) ; <nl> - Size pvSize = getSize ( ) ; <nl> + cocos2d : : Size pSize = page - > getSize ( ) ; <nl> + cocos2d : : Size pvSize = getSize ( ) ; <nl> if ( ! pSize . equals ( pvSize ) ) <nl> { <nl> CCLOG ( " page size does not match pageview size , it will be force sized ! " ) ; <nl> page - > setSize ( pvSize ) ; <nl> } <nl> - ccArray * arrayPages = _pages - > data ; <nl> + cocos2d : : ccArray * arrayPages = _pages - > data ; <nl> int length = arrayPages - > num ; <nl> for ( int i = ( idx + 1 ) ; i < length ; i + + ) { <nl> UIWidget * behindPage = dynamic_cast < UIWidget * > ( arrayPages - > arr [ i ] ) ; <nl> - Point formerPos = behindPage - > getPosition ( ) ; <nl> - behindPage - > setPosition ( Point ( formerPos . x + getSize ( ) . width , 0 ) ) ; <nl> + cocos2d : : Point formerPos = behindPage - > getPosition ( ) ; <nl> + behindPage - > setPosition ( cocos2d : : Point ( formerPos . x + getSize ( ) . width , 0 ) ) ; <nl> } <nl> updateBoundaryPages ( ) ; <nl> } <nl> } <nl> <nl> - void UIPageView : : removePage ( Layout * page ) <nl> + void UIPageView : : removePage ( UILayout * page ) <nl> { <nl> if ( ! page ) <nl> { <nl> void UIPageView : : removePageAtIndex ( int index ) <nl> { <nl> return ; <nl> } <nl> - Layout * page = dynamic_cast < Layout * > ( _pages - > getObjectAtIndex ( index ) ) ; <nl> + UILayout * page = dynamic_cast < UILayout * > ( _pages - > getObjectAtIndex ( index ) ) ; <nl> if ( page ) <nl> { <nl> removePage ( page ) ; <nl> void UIPageView : : updateBoundaryPages ( ) <nl> { <nl> _leftChild = NULL ; <nl> _rightChild = NULL ; <nl> + return ; <nl> } <nl> _leftChild = dynamic_cast < UIWidget * > ( _pages - > getObjectAtIndex ( 0 ) ) ; <nl> _rightChild = dynamic_cast < UIWidget * > ( _pages - > getLastObject ( ) ) ; <nl> float UIPageView : : getPositionXByIndex ( int idx ) <nl> <nl> bool UIPageView : : addChild ( UIWidget * widget ) <nl> { <nl> - return Layout : : addChild ( widget ) ; <nl> + return UILayout : : addChild ( widget ) ; <nl> } <nl> <nl> bool UIPageView : : removeChild ( UIWidget * widget ) <nl> bool UIPageView : : removeChild ( UIWidget * widget ) <nl> if ( _pages - > containsObject ( widget ) ) <nl> { <nl> _pages - > removeObject ( widget ) ; <nl> - return Layout : : removeChild ( widget ) ; <nl> + return UILayout : : removeChild ( widget ) ; <nl> } <nl> return false ; <nl> } <nl> <nl> void UIPageView : : onSizeChanged ( ) <nl> { <nl> - Layout : : onSizeChanged ( ) ; <nl> + UILayout : : onSizeChanged ( ) ; <nl> _rightBoundary = getSize ( ) . width ; <nl> updateChildrenSize ( ) ; <nl> updateChildrenPosition ( ) ; <nl> void UIPageView : : updateChildrenSize ( ) <nl> return ; <nl> } <nl> <nl> - Size selfSize = getSize ( ) ; <nl> - for ( int i = 0 ; i < _pages - > count ( ) ; i + + ) <nl> + cocos2d : : Size selfSize = getSize ( ) ; <nl> + for ( unsigned int i = 0 ; i < _pages - > count ( ) ; i + + ) <nl> { <nl> - Layout * page = dynamic_cast < Layout * > ( _pages - > getObjectAtIndex ( i ) ) ; <nl> + UILayout * page = dynamic_cast < UILayout * > ( _pages - > getObjectAtIndex ( i ) ) ; <nl> page - > setSize ( selfSize ) ; <nl> } <nl> } <nl> void UIPageView : : updateChildrenPosition ( ) <nl> _curPageIdx = pageCount - 1 ; <nl> } <nl> float pageWidth = getSize ( ) . width ; <nl> - ccArray * arrayPages = _pages - > data ; <nl> + cocos2d : : ccArray * arrayPages = _pages - > data ; <nl> for ( int i = 0 ; i < pageCount ; i + + ) <nl> { <nl> - Layout * page = dynamic_cast < Layout * > ( arrayPages - > arr [ i ] ) ; <nl> - page - > setPosition ( Point ( ( i - _curPageIdx ) * pageWidth , 0 ) ) ; <nl> + UILayout * page = dynamic_cast < UILayout * > ( arrayPages - > arr [ i ] ) ; <nl> + page - > setPosition ( cocos2d : : Point ( ( i - _curPageIdx ) * pageWidth , 0 ) ) ; <nl> } <nl> } <nl> <nl> void UIPageView : : removeAllChildren ( ) <nl> { <nl> _pages - > removeAllObjects ( ) ; <nl> - Layout : : removeAllChildren ( ) ; <nl> + UILayout : : removeAllChildren ( ) ; <nl> } <nl> <nl> void UIPageView : : scrollToPage ( int idx ) <nl> void UIPageView : : update ( float dt ) <nl> step = - _autoScrollDistance ; <nl> _autoScrollDistance = 0 . 0f ; <nl> _isAutoScrolling = false ; <nl> - pageTurningEvent ( ) ; <nl> } <nl> else <nl> { <nl> _autoScrollDistance + = step ; <nl> } <nl> scrollPages ( - step ) ; <nl> + if ( ! _isAutoScrolling ) <nl> + { <nl> + pageTurningEvent ( ) ; <nl> + } <nl> break ; <nl> } <nl> break ; <nl> void UIPageView : : update ( float dt ) <nl> step = _autoScrollDistance ; <nl> _autoScrollDistance = 0 . 0f ; <nl> _isAutoScrolling = false ; <nl> - pageTurningEvent ( ) ; <nl> } <nl> else <nl> { <nl> _autoScrollDistance - = step ; <nl> } <nl> scrollPages ( step ) ; <nl> + if ( ! _isAutoScrolling ) <nl> + { <nl> + pageTurningEvent ( ) ; <nl> + } <nl> break ; <nl> } <nl> default : <nl> void UIPageView : : update ( float dt ) <nl> } <nl> } <nl> <nl> - bool UIPageView : : onTouchBegan ( const Point & touchPoint ) <nl> + bool UIPageView : : onTouchBegan ( const cocos2d : : Point & touchPoint ) <nl> { <nl> - bool pass = Layout : : onTouchBegan ( touchPoint ) ; <nl> + bool pass = UILayout : : onTouchBegan ( touchPoint ) ; <nl> handlePressLogic ( touchPoint ) ; <nl> return pass ; <nl> } <nl> <nl> - void UIPageView : : onTouchMoved ( const Point & touchPoint ) <nl> + void UIPageView : : onTouchMoved ( const cocos2d : : Point & touchPoint ) <nl> { <nl> _touchMovePos . x = touchPoint . x ; <nl> _touchMovePos . y = touchPoint . y ; <nl> void UIPageView : : onTouchMoved ( const Point & touchPoint ) <nl> } <nl> } <nl> <nl> - void UIPageView : : onTouchEnded ( const Point & touchPoint ) <nl> + void UIPageView : : onTouchEnded ( const cocos2d : : Point & touchPoint ) <nl> { <nl> - Layout : : onTouchEnded ( touchPoint ) ; <nl> + UILayout : : onTouchEnded ( touchPoint ) ; <nl> handleReleaseLogic ( touchPoint ) ; <nl> } <nl> <nl> void UIPageView : : movePages ( float offset ) <nl> { <nl> - ccArray * arrayPages = _pages - > data ; <nl> + cocos2d : : ccArray * arrayPages = _pages - > data ; <nl> int length = arrayPages - > num ; <nl> for ( int i = 0 ; i < length ; i + + ) <nl> { <nl> bool UIPageView : : scrollPages ( float touchOffset ) <nl> return true ; <nl> } <nl> <nl> - void UIPageView : : onTouchCancelled ( const Point & touchPoint ) <nl> + void UIPageView : : onTouchCancelled ( const cocos2d : : Point & touchPoint ) <nl> { <nl> - Layout : : onTouchCancelled ( touchPoint ) ; <nl> + UILayout : : onTouchCancelled ( touchPoint ) ; <nl> } <nl> <nl> - void UIPageView : : handlePressLogic ( const Point & touchPoint ) <nl> + void UIPageView : : handlePressLogic ( const cocos2d : : Point & touchPoint ) <nl> { <nl> - Point nsp = _renderer - > convertToNodeSpace ( touchPoint ) ; <nl> + cocos2d : : Point nsp = _renderer - > convertToNodeSpace ( touchPoint ) ; <nl> _touchMoveStartLocation = nsp . x ; <nl> _touchStartLocation = nsp . x ; <nl> } <nl> <nl> - void UIPageView : : handleMoveLogic ( const Point & touchPoint ) <nl> + void UIPageView : : handleMoveLogic ( const cocos2d : : Point & touchPoint ) <nl> { <nl> - Point nsp = _renderer - > convertToNodeSpace ( touchPoint ) ; <nl> + cocos2d : : Point nsp = _renderer - > convertToNodeSpace ( touchPoint ) ; <nl> float offset = 0 . 0 ; <nl> float moveX = nsp . x ; <nl> offset = moveX - _touchMoveStartLocation ; <nl> void UIPageView : : handleMoveLogic ( const Point & touchPoint ) <nl> scrollPages ( offset ) ; <nl> } <nl> <nl> - void UIPageView : : handleReleaseLogic ( const Point & touchPoint ) <nl> + void UIPageView : : handleReleaseLogic ( const cocos2d : : Point & touchPoint ) <nl> { <nl> + if ( _pages - > count ( ) < = 0 ) <nl> + { <nl> + return ; <nl> + } <nl> UIWidget * curPage = dynamic_cast < UIWidget * > ( _pages - > getObjectAtIndex ( _curPageIdx ) ) ; <nl> if ( curPage ) <nl> { <nl> - Point curPagePos = curPage - > getPosition ( ) ; <nl> + cocos2d : : Point curPagePos = curPage - > getPosition ( ) ; <nl> int pageCount = _pages - > count ( ) ; <nl> float curPageLocation = curPagePos . x ; <nl> float pageWidth = getSize ( ) . width ; <nl> void UIPageView : : handleReleaseLogic ( const Point & touchPoint ) <nl> } <nl> } <nl> <nl> - void UIPageView : : checkChildInfo ( int handleState , UIWidget * sender , const Point & touchPoint ) <nl> + void UIPageView : : checkChildInfo ( int handleState , UIWidget * sender , const cocos2d : : Point & touchPoint ) <nl> { <nl> interceptTouchEvent ( handleState , sender , touchPoint ) ; <nl> } <nl> <nl> - void UIPageView : : interceptTouchEvent ( int handleState , UIWidget * sender , const Point & touchPoint ) <nl> + void UIPageView : : interceptTouchEvent ( int handleState , UIWidget * sender , const cocos2d : : Point & touchPoint ) <nl> { <nl> switch ( handleState ) <nl> { <nl> void UIPageView : : pageTurningEvent ( ) <nl> } <nl> } <nl> <nl> - void UIPageView : : addEventListener ( Object * target , SEL_PageViewEvent selector ) <nl> + void UIPageView : : addEventListener ( cocos2d : : Object * target , SEL_PageViewEvent selector ) <nl> { <nl> _eventListener = target ; <nl> _eventSelector = selector ; <nl> int UIPageView : : getCurPageIndex ( ) const <nl> return _curPageIdx ; <nl> } <nl> <nl> + cocos2d : : Array * UIPageView : : getPages ( ) <nl> + { <nl> + return _pages ; <nl> + } <nl> + <nl> const char * UIPageView : : getDescription ( ) const <nl> { <nl> return " PageView " ; <nl> } <nl> <nl> + UIWidget * UIPageView : : createCloneInstance ( ) <nl> + { <nl> + return UIPageView : : create ( ) ; <nl> + } <nl> + <nl> + void UIPageView : : copyClonedWidgetChildren ( UIWidget * model ) <nl> + { <nl> + cocos2d : : ccArray * arrayPages = dynamic_cast < UIPageView * > ( model ) - > getPages ( ) - > data ; <nl> + int length = arrayPages - > num ; <nl> + for ( int i = 0 ; i < length ; i + + ) <nl> + { <nl> + UILayout * page = ( UILayout * ) ( arrayPages - > arr [ i ] ) ; <nl> + addPage ( dynamic_cast < UILayout * > ( page - > clone ( ) ) ) ; <nl> + } <nl> + } <nl> + <nl> + void UIPageView : : copySpecialProperties ( UIWidget * widget ) <nl> + { <nl> + UIPageView * pageView = dynamic_cast < UIPageView * > ( widget ) ; <nl> + if ( pageView ) <nl> + { <nl> + UILayout : : copySpecialProperties ( widget ) ; <nl> + } <nl> + } <nl> + <nl> } <nl> \ No newline at end of file <nl> mmm a / cocos / gui / UIPageView . h <nl> ppp b / cocos / gui / UIPageView . h <nl> <nl> # ifndef __UIPAGEVIEW_H__ <nl> # define __UIPAGEVIEW_H__ <nl> <nl> - # include " gui / Layout . h " <nl> + # include " gui / UILayout . h " <nl> # include " gui / UIScrollInterface . h " <nl> <nl> namespace gui { <nl> typedef enum { <nl> PAGEVIEW_TOUCHRIGHT <nl> } PVTouchDir ; <nl> <nl> - class UIPageView : public Layout , public UIScrollInterface <nl> + class UIPageView : public UILayout , public UIScrollInterface <nl> { <nl> <nl> public : <nl> class UIPageView : public Layout , public UIScrollInterface <nl> * <nl> * @ param page page to be added to pageview . <nl> * / <nl> - void addPage ( Layout * page ) ; <nl> + void addPage ( UILayout * page ) ; <nl> <nl> / * * <nl> * Inert a page to pageview . <nl> * <nl> * @ param page page to be added to pageview . <nl> * / <nl> - void insertPage ( Layout * page , int idx ) ; <nl> + void insertPage ( UILayout * page , int idx ) ; <nl> <nl> / * * <nl> * Remove a page of pageview . <nl> * <nl> * @ param page page which will be removed . <nl> * / <nl> - void removePage ( Layout * page ) ; <nl> + void removePage ( UILayout * page ) ; <nl> <nl> / * * <nl> * Remove a page at index of pageview . <nl> class UIPageView : public Layout , public UIScrollInterface <nl> * / <nl> int getCurPageIndex ( ) const ; <nl> <nl> + cocos2d : : Array * getPages ( ) ; <nl> + <nl> / / event <nl> void addEventListener ( cocos2d : : Object * target , SEL_PageViewEvent selector ) ; <nl> + <nl> <nl> / / override " removeChild " method of widget . <nl> virtual bool removeChild ( UIWidget * widget ) ; <nl> class UIPageView : public Layout , public UIScrollInterface <nl> virtual void update ( float dt ) ; <nl> <nl> virtual void doLayout ( ) { } ; <nl> - <nl> + <nl> / * * <nl> * Returns the " class name " of widget . <nl> * / <nl> virtual const char * getDescription ( ) const ; <nl> + <nl> protected : <nl> virtual bool addChild ( UIWidget * widget ) ; <nl> virtual bool init ( ) ; <nl> - Layout * createPage ( ) ; <nl> + UILayout * createPage ( ) ; <nl> float getPositionXByIndex ( int idx ) ; <nl> void updateBoundaryPages ( ) ; <nl> virtual void handlePressLogic ( const cocos2d : : Point & touchPoint ) ; <nl> class UIPageView : public Layout , public UIScrollInterface <nl> void updateChildrenSize ( ) ; <nl> void updateChildrenPosition ( ) ; <nl> virtual void onSizeChanged ( ) ; <nl> - <nl> - virtual void setClippingEnabled ( bool able ) { Layout : : setClippingEnabled ( able ) ; } ; <nl> + virtual UIWidget * createCloneInstance ( ) ; <nl> + virtual void copySpecialProperties ( UIWidget * model ) ; <nl> + virtual void copyClonedWidgetChildren ( UIWidget * model ) ; <nl> + virtual void setClippingEnabled ( bool able ) { UILayout : : setClippingEnabled ( able ) ; } ; <nl> protected : <nl> int _curPageIdx ; <nl> cocos2d : : Array * _pages ; <nl> PVTouchDir _touchMoveDir ; <nl> float _touchStartLocation ; <nl> - float _touchEndLocation ; <nl> float _touchMoveStartLocation ; <nl> cocos2d : : Point _movePagePoint ; <nl> UIWidget * _leftChild ; <nl> class UIPageView : public Layout , public UIScrollInterface <nl> float _childFocusCancelOffset ; <nl> cocos2d : : Object * _eventListener ; <nl> SEL_PageViewEvent _eventSelector ; <nl> + <nl> } ; <nl> <nl> } <nl> mmm a / cocos / gui / UIRootWidget . cpp <nl> ppp b / cocos / gui / UIRootWidget . cpp <nl> <nl> <nl> # include " gui / UIRootWidget . h " <nl> <nl> - using namespace cocos2d ; <nl> - <nl> namespace gui { <nl> <nl> UIRootWidget : : UIRootWidget ( ) <nl> UIRootWidget * UIRootWidget : : create ( ) <nl> <nl> bool UIRootWidget : : init ( ) <nl> { <nl> - if ( Layout : : init ( ) ) <nl> + if ( UILayout : : init ( ) ) <nl> { <nl> - setSize ( Director : : getInstance ( ) - > getWinSize ( ) ) ; <nl> + setSize ( cocos2d : : Director : : getInstance ( ) - > getWinSize ( ) ) ; <nl> return true ; <nl> } <nl> return false ; <nl> mmm a / cocos / gui / UIRootWidget . h <nl> ppp b / cocos / gui / UIRootWidget . h <nl> <nl> # ifndef __UIROOTWIDGET_H__ <nl> # define __UIROOTWIDGET_H__ <nl> <nl> - # include " gui / Layout . h " <nl> + # include " gui / UILayout . h " <nl> <nl> namespace gui { <nl> - <nl> - class UIRootWidget : public Layout <nl> + <nl> + / * * <nl> + * @ js NA <nl> + * @ lua NA <nl> + * / <nl> + class UIRootWidget : public UILayout <nl> { <nl> public : <nl> / * * <nl> mmm a / cocos / gui / UIScrollInterface . h <nl> ppp b / cocos / gui / UIScrollInterface . h <nl> class UIScrollInterface <nl> virtual void handleMoveLogic ( const cocos2d : : Point & touchPoint ) = 0 ; <nl> virtual void handleReleaseLogic ( const cocos2d : : Point & touchPoint ) = 0 ; <nl> virtual void interceptTouchEvent ( int handleState , UIWidget * sender , const cocos2d : : Point & touchPoint ) = 0 ; <nl> - / / virtual bool isInScrollDegreeRange ( UIWidget * widget ) = 0 ; <nl> } ; <nl> <nl> } <nl> mmm a / cocos / gui / UIScrollView . cpp <nl> ppp b / cocos / gui / UIScrollView . cpp <nl> <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> <nl> # include " gui / UIScrollView . h " <nl> - # include " gui / UILayer . h " <nl> - <nl> - using namespace cocos2d ; <nl> <nl> namespace gui { <nl> <nl> + # define AUTOSCROLLMAXSPEED 1000 . 0f <nl> + <nl> + const cocos2d : : Point SCROLLDIR_UP = cocos2d : : Point ( 0 . 0f , 1 . 0f ) ; <nl> + const cocos2d : : Point SCROLLDIR_DOWN = cocos2d : : Point ( 0 . 0f , - 1 . 0f ) ; <nl> + const cocos2d : : Point SCROLLDIR_LEFT = cocos2d : : Point ( - 1 . 0f , 0 . 0f ) ; <nl> + const cocos2d : : Point SCROLLDIR_RIGHT = cocos2d : : Point ( 1 . 0f , 0 . 0f ) ; <nl> + <nl> UIScrollView : : UIScrollView ( ) : <nl> _innerContainer ( NULL ) , <nl> _direction ( SCROLLVIEW_DIR_VERTICAL ) , <nl> - _moveDirection ( SCROLLVIEW_MOVE_DIR_NONE ) , <nl> - _touchStartLocation ( 0 . 0f ) , <nl> - _touchEndLocation ( 0 . 0f ) , <nl> - _touchMoveStartLocation ( 0 . 0f ) , <nl> + _touchBeganPoint ( cocos2d : : Point : : ZERO ) , <nl> + _touchMovedPoint ( cocos2d : : Point : : ZERO ) , <nl> + _touchEndedPoint ( cocos2d : : Point : : ZERO ) , <nl> + _touchMovingPoint ( cocos2d : : Point : : ZERO ) , <nl> + _autoScrollDir ( cocos2d : : Point : : ZERO ) , <nl> _topBoundary ( 0 . 0f ) , <nl> _bottomBoundary ( 0 . 0f ) , <nl> _leftBoundary ( 0 . 0f ) , <nl> _rightBoundary ( 0 . 0f ) , <nl> - _topEnd ( false ) , <nl> - _bottomEnd ( false ) , <nl> - _leftEnd ( false ) , <nl> - _rightEnd ( false ) , <nl> + _bounceTopBoundary ( 0 . 0f ) , <nl> + _bounceBottomBoundary ( 0 . 0f ) , <nl> + _bounceLeftBoundary ( 0 . 0f ) , <nl> + _bounceRightBoundary ( 0 . 0f ) , <nl> _autoScroll ( false ) , <nl> + _autoScrollAddUpTime ( 0 . 0f ) , <nl> _autoScrollOriginalSpeed ( 0 . 0f ) , <nl> - _autoScrollAcceleration ( 600 . 0f ) , <nl> + _autoScrollAcceleration ( - 1000 . 0f ) , <nl> + _isAutoScrollSpeedAttenuated ( false ) , <nl> + _needCheckAutoScrollDestination ( false ) , <nl> + _autoScrollDestination ( cocos2d : : Point : : ZERO ) , <nl> _bePressed ( false ) , <nl> _slidTime ( 0 . 0f ) , <nl> - _moveChildPoint ( Point : : ZERO ) , <nl> + _moveChildPoint ( cocos2d : : Point : : ZERO ) , <nl> _childFocusCancelOffset ( 5 . 0f ) , <nl> + _leftBounceNeeded ( false ) , <nl> + _topBounceNeeded ( false ) , <nl> + _rightBounceNeeded ( false ) , <nl> + _bottomBounceNeeded ( false ) , <nl> + _bounceEnabled ( false ) , <nl> + _bouncing ( false ) , <nl> + _bounceDir ( cocos2d : : Point : : ZERO ) , <nl> + _bounceOriginalSpeed ( 0 . 0f ) , <nl> + _inertiaScrollEnabled ( true ) , <nl> _eventListener ( NULL ) , <nl> _eventSelector ( NULL ) <nl> { <nl> UIScrollView * UIScrollView : : create ( ) <nl> return NULL ; <nl> } <nl> <nl> - void UIScrollView : : releaseResoures ( ) <nl> + bool UIScrollView : : init ( ) <nl> { <nl> - setUpdateEnabled ( false ) ; <nl> - removeAllChildren ( ) ; <nl> - _renderer - > removeAllChildrenWithCleanup ( true ) ; <nl> - _renderer - > removeFromParentAndCleanup ( true ) ; <nl> - _renderer - > release ( ) ; <nl> - <nl> - Layout : : removeChild ( _innerContainer ) ; <nl> + if ( UILayout : : init ( ) ) <nl> + { <nl> + setUpdateEnabled ( true ) ; <nl> + setTouchEnabled ( true ) ; <nl> + setClippingEnabled ( true ) ; <nl> + _innerContainer - > setTouchEnabled ( false ) ; <nl> + return true ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + void UIScrollView : : initRenderer ( ) <nl> + { <nl> + UILayout : : initRenderer ( ) ; <nl> + _innerContainer = UILayout : : create ( ) ; <nl> + UILayout : : addChild ( _innerContainer ) ; <nl> + } <nl> + <nl> + void UIScrollView : : onSizeChanged ( ) <nl> + { <nl> + UILayout : : onSizeChanged ( ) ; <nl> + _topBoundary = _size . height ; <nl> + _rightBoundary = _size . width ; <nl> + float bounceBoundaryParameterX = _size . width / 3 . 0f ; <nl> + float bounceBoundaryParameterY = _size . height / 3 . 0f ; <nl> + _bounceTopBoundary = _size . height - bounceBoundaryParameterY ; <nl> + _bounceBottomBoundary = bounceBoundaryParameterY ; <nl> + _bounceLeftBoundary = bounceBoundaryParameterX ; <nl> + _bounceRightBoundary = _size . width - bounceBoundaryParameterX ; <nl> + cocos2d : : Size innerSize = _innerContainer - > getSize ( ) ; <nl> + float orginInnerSizeWidth = innerSize . width ; <nl> + float orginInnerSizeHeight = innerSize . height ; <nl> + float innerSizeWidth = MAX ( orginInnerSizeWidth , _size . width ) ; <nl> + float innerSizeHeight = MAX ( orginInnerSizeHeight , _size . height ) ; <nl> + _innerContainer - > setSize ( cocos2d : : Size ( innerSizeWidth , innerSizeHeight ) ) ; <nl> + _innerContainer - > setPosition ( cocos2d : : Point ( 0 , _size . height - _innerContainer - > getSize ( ) . height ) ) ; <nl> + } <nl> + <nl> + void UIScrollView : : setInnerContainerSize ( const cocos2d : : Size & size ) <nl> + { <nl> + float innerSizeWidth = _size . width ; <nl> + float innerSizeHeight = _size . height ; <nl> + cocos2d : : Size originalInnerSize = _innerContainer - > getSize ( ) ; <nl> + if ( size . width < _size . width ) <nl> + { <nl> + CCLOG ( " Inner width < = scrollview width , it will be force sized ! " ) ; <nl> + } <nl> + else <nl> + { <nl> + innerSizeWidth = size . width ; <nl> + } <nl> + if ( size . height < _size . height ) <nl> + { <nl> + CCLOG ( " Inner height < = scrollview height , it will be force sized ! " ) ; <nl> + } <nl> + else <nl> + { <nl> + innerSizeHeight = size . height ; <nl> + } <nl> + _innerContainer - > setSize ( cocos2d : : Size ( innerSizeWidth , innerSizeHeight ) ) ; <nl> + <nl> + switch ( _direction ) <nl> + { <nl> + case SCROLLVIEW_DIR_VERTICAL : <nl> + { <nl> + cocos2d : : Size newInnerSize = _innerContainer - > getSize ( ) ; <nl> + float offset = originalInnerSize . height - newInnerSize . height ; <nl> + scrollChildren ( 0 . 0f , offset ) ; <nl> + break ; <nl> + } <nl> + case SCROLLVIEW_DIR_HORIZONTAL : <nl> + { <nl> + if ( _innerContainer - > getRightInParent ( ) < = _size . width ) <nl> + { <nl> + cocos2d : : Size newInnerSize = _innerContainer - > getSize ( ) ; <nl> + float offset = originalInnerSize . width - newInnerSize . width ; <nl> + scrollChildren ( offset , 0 . 0f ) ; <nl> + } <nl> + break ; <nl> + } <nl> + case SCROLLVIEW_DIR_BOTH : <nl> + { <nl> + cocos2d : : Size newInnerSize = _innerContainer - > getSize ( ) ; <nl> + float offsetY = originalInnerSize . height - newInnerSize . height ; <nl> + float offsetX = 0 . 0f ; <nl> + if ( _innerContainer - > getRightInParent ( ) < = _size . width ) <nl> + { <nl> + offsetX = originalInnerSize . width - newInnerSize . width ; <nl> + } <nl> + scrollChildren ( offsetX , offsetY ) ; <nl> + break ; <nl> + } <nl> + default : <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + const cocos2d : : Size & UIScrollView : : getInnerContainerSize ( ) const <nl> + { <nl> + return _innerContainer - > getSize ( ) ; <nl> + } <nl> + <nl> + bool UIScrollView : : addChild ( UIWidget * widget ) <nl> + { <nl> + return _innerContainer - > addChild ( widget ) ; <nl> + } <nl> + <nl> + void UIScrollView : : removeAllChildren ( ) <nl> + { <nl> + _innerContainer - > removeAllChildren ( ) ; <nl> + } <nl> + <nl> + bool UIScrollView : : removeChild ( UIWidget * child ) <nl> + { <nl> + return _innerContainer - > removeChild ( child ) ; <nl> + } <nl> + <nl> + cocos2d : : Array * UIScrollView : : getChildren ( ) <nl> + { <nl> + return _innerContainer - > getChildren ( ) ; <nl> + } <nl> + <nl> + void UIScrollView : : moveChildren ( float offsetX , float offsetY ) <nl> + { <nl> + _moveChildPoint = _innerContainer - > getPosition ( ) + cocos2d : : Point ( offsetX , offsetY ) ; <nl> + _innerContainer - > setPosition ( _moveChildPoint ) ; <nl> + } <nl> + <nl> + void UIScrollView : : autoScrollChildren ( float dt ) <nl> + { <nl> + float lastTime = _autoScrollAddUpTime ; <nl> + _autoScrollAddUpTime + = dt ; <nl> + if ( _isAutoScrollSpeedAttenuated ) <nl> + { <nl> + float nowSpeed = _autoScrollOriginalSpeed + _autoScrollAcceleration * _autoScrollAddUpTime ; <nl> + if ( nowSpeed < = 0 . 0f ) <nl> + { <nl> + stopAutoScrollChildren ( ) ; <nl> + checkNeedBounce ( ) ; <nl> + } <nl> + else <nl> + { <nl> + float timeParam = lastTime * 2 + dt ; <nl> + float offset = ( _autoScrollOriginalSpeed + _autoScrollAcceleration * timeParam * 0 . 5f ) * dt ; <nl> + float offsetX = offset * _autoScrollDir . x ; <nl> + float offsetY = offset * _autoScrollDir . y ; <nl> + if ( ! scrollChildren ( offsetX , offsetY ) ) <nl> + { <nl> + stopAutoScrollChildren ( ) ; <nl> + checkNeedBounce ( ) ; <nl> + } <nl> + } <nl> + } <nl> + else <nl> + { <nl> + if ( _needCheckAutoScrollDestination ) <nl> + { <nl> + float xOffset = _autoScrollDir . x * dt * _autoScrollOriginalSpeed ; <nl> + float yOffset = _autoScrollDir . y * dt * _autoScrollOriginalSpeed ; <nl> + bool notDone = checkCustomScrollDestination ( & xOffset , & yOffset ) ; <nl> + bool scrollCheck = scrollChildren ( xOffset , yOffset ) ; <nl> + if ( ! notDone | | ! scrollCheck ) <nl> + { <nl> + stopAutoScrollChildren ( ) ; <nl> + checkNeedBounce ( ) ; <nl> + } <nl> + } <nl> + else <nl> + { <nl> + if ( ! scrollChildren ( _autoScrollDir . x * dt * _autoScrollOriginalSpeed , _autoScrollDir . y * dt * _autoScrollOriginalSpeed ) ) <nl> + { <nl> + stopAutoScrollChildren ( ) ; <nl> + checkNeedBounce ( ) ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + <nl> + void UIScrollView : : bounceChildren ( float dt ) <nl> + { <nl> + if ( _bounceOriginalSpeed < = 0 . 0f ) <nl> + { <nl> + stopBounceChildren ( ) ; <nl> + } <nl> + if ( ! bounceScrollChildren ( _bounceDir . x * dt * _bounceOriginalSpeed , _bounceDir . y * dt * _bounceOriginalSpeed ) ) <nl> + { <nl> + stopBounceChildren ( ) ; <nl> + } <nl> + } <nl> + <nl> + bool UIScrollView : : checkNeedBounce ( ) <nl> + { <nl> + if ( ! _bounceEnabled ) <nl> + { <nl> + return false ; <nl> + } <nl> + checkBounceBoundary ( ) ; <nl> + if ( _topBounceNeeded | | _bottomBounceNeeded | | _leftBounceNeeded | | _rightBounceNeeded ) <nl> + { <nl> + if ( _topBounceNeeded & & _leftBounceNeeded ) <nl> + { <nl> + cocos2d : : Point scrollVector = cocos2d : : Point ( 0 . 0f , _size . height ) - cocos2d : : Point ( _innerContainer - > getLeftInParent ( ) , _innerContainer - > getTopInParent ( ) ) ; <nl> + float orSpeed = scrollVector . getLength ( ) / ( 0 . 2f ) ; <nl> + _bounceDir = scrollVector . normalize ( ) ; <nl> + startBounceChildren ( orSpeed ) ; <nl> + } <nl> + else if ( _topBounceNeeded & & _rightBounceNeeded ) <nl> + { <nl> + cocos2d : : Point scrollVector = cocos2d : : Point ( _size . width , _size . height ) - cocos2d : : Point ( _innerContainer - > getRightInParent ( ) , _innerContainer - > getTopInParent ( ) ) ; <nl> + float orSpeed = scrollVector . getLength ( ) / ( 0 . 2f ) ; <nl> + _bounceDir = scrollVector . normalize ( ) ; <nl> + startBounceChildren ( orSpeed ) ; <nl> + } <nl> + else if ( _bottomBounceNeeded & & _leftBounceNeeded ) <nl> + { <nl> + cocos2d : : Point scrollVector = cocos2d : : Point : : ZERO - cocos2d : : Point ( _innerContainer - > getLeftInParent ( ) , _innerContainer - > getBottomInParent ( ) ) ; <nl> + float orSpeed = scrollVector . getLength ( ) / ( 0 . 2f ) ; <nl> + _bounceDir = scrollVector . normalize ( ) ; <nl> + startBounceChildren ( orSpeed ) ; <nl> + } <nl> + else if ( _bottomBounceNeeded & & _rightBounceNeeded ) <nl> + { <nl> + cocos2d : : Point scrollVector = cocos2d : : Point ( _size . width , 0 . 0f ) - cocos2d : : Point ( _innerContainer - > getRightInParent ( ) , _innerContainer - > getBottomInParent ( ) ) ; <nl> + float orSpeed = scrollVector . getLength ( ) / ( 0 . 2f ) ; <nl> + _bounceDir = scrollVector . normalize ( ) ; <nl> + startBounceChildren ( orSpeed ) ; <nl> + } <nl> + else if ( _topBounceNeeded ) <nl> + { <nl> + cocos2d : : Point scrollVector = cocos2d : : Point ( 0 . 0f , _size . height ) - cocos2d : : Point ( 0 . 0f , _innerContainer - > getTopInParent ( ) ) ; <nl> + float orSpeed = scrollVector . getLength ( ) / ( 0 . 2f ) ; <nl> + _bounceDir = scrollVector . normalize ( ) ; <nl> + startBounceChildren ( orSpeed ) ; <nl> + } <nl> + else if ( _bottomBounceNeeded ) <nl> + { <nl> + cocos2d : : Point scrollVector = cocos2d : : Point : : ZERO - cocos2d : : Point ( 0 . 0f , _innerContainer - > getBottomInParent ( ) ) ; <nl> + float orSpeed = scrollVector . getLength ( ) / ( 0 . 2f ) ; <nl> + _bounceDir = scrollVector . normalize ( ) ; <nl> + startBounceChildren ( orSpeed ) ; <nl> + } <nl> + else if ( _leftBounceNeeded ) <nl> + { <nl> + cocos2d : : Point scrollVector = cocos2d : : Point : : ZERO - cocos2d : : Point ( _innerContainer - > getLeftInParent ( ) , 0 . 0f ) ; <nl> + float orSpeed = scrollVector . getLength ( ) / ( 0 . 2f ) ; <nl> + _bounceDir = scrollVector . normalize ( ) ; <nl> + startBounceChildren ( orSpeed ) ; <nl> + } <nl> + else if ( _rightBounceNeeded ) <nl> + { <nl> + cocos2d : : Point scrollVector = cocos2d : : Point ( _size . width , 0 . 0f ) - cocos2d : : Point ( _innerContainer - > getRightInParent ( ) , 0 . 0f ) ; <nl> + float orSpeed = scrollVector . getLength ( ) / ( 0 . 2f ) ; <nl> + _bounceDir = scrollVector . normalize ( ) ; <nl> + startBounceChildren ( orSpeed ) ; <nl> + } <nl> + return true ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + void UIScrollView : : checkBounceBoundary ( ) <nl> + { <nl> + float icBottomPos = _innerContainer - > getBottomInParent ( ) ; <nl> + if ( icBottomPos > _bottomBoundary ) <nl> + { <nl> + scrollToBottomEvent ( ) ; <nl> + _bottomBounceNeeded = true ; <nl> + } <nl> + else <nl> + { <nl> + _bottomBounceNeeded = false ; <nl> + } <nl> + float icTopPos = _innerContainer - > getTopInParent ( ) ; <nl> + if ( icTopPos < _topBoundary ) <nl> + { <nl> + scrollToTopEvent ( ) ; <nl> + _topBounceNeeded = true ; <nl> + } <nl> + else <nl> + { <nl> + _topBounceNeeded = false ; <nl> + } <nl> + float icRightPos = _innerContainer - > getRightInParent ( ) ; <nl> + if ( icRightPos < _rightBoundary ) <nl> + { <nl> + scrollToRightEvent ( ) ; <nl> + _rightBounceNeeded = true ; <nl> + } <nl> + else <nl> + { <nl> + _rightBounceNeeded = false ; <nl> + } <nl> + float icLeftPos = _innerContainer - > getLeftInParent ( ) ; <nl> + if ( icLeftPos > _leftBoundary ) <nl> + { <nl> + scrollToLeftEvent ( ) ; <nl> + _leftBounceNeeded = true ; <nl> + } <nl> + else <nl> + { <nl> + _leftBounceNeeded = false ; <nl> + } <nl> + } <nl> + <nl> + void UIScrollView : : startBounceChildren ( float v ) <nl> + { <nl> + _bounceOriginalSpeed = v ; <nl> + _bouncing = true ; <nl> + } <nl> + <nl> + void UIScrollView : : stopBounceChildren ( ) <nl> + { <nl> + _bouncing = false ; <nl> + _bounceOriginalSpeed = 0 . 0f ; <nl> + _leftBounceNeeded = false ; <nl> + _rightBounceNeeded = false ; <nl> + _topBounceNeeded = false ; <nl> + _bottomBounceNeeded = false ; <nl> + } <nl> + <nl> + void UIScrollView : : startAutoScrollChildrenWithOriginalSpeed ( const cocos2d : : Point & dir , float v , bool attenuated , float acceleration ) <nl> + { <nl> + stopAutoScrollChildren ( ) ; <nl> + _autoScrollDir = dir ; <nl> + _isAutoScrollSpeedAttenuated = attenuated ; <nl> + _autoScrollOriginalSpeed = v ; <nl> + _autoScroll = true ; <nl> + _autoScrollAcceleration = acceleration ; <nl> + } <nl> + <nl> + void UIScrollView : : startAutoScrollChildrenWithDestination ( const cocos2d : : Point & des , float time , bool attenuated ) <nl> + { <nl> + _needCheckAutoScrollDestination = false ; <nl> + _autoScrollDestination = des ; <nl> + cocos2d : : Point dis = des - _innerContainer - > getPosition ( ) ; <nl> + cocos2d : : Point dir = dis . normalize ( ) ; <nl> + float orSpeed = 0 . 0f ; <nl> + float acceleration = - 1000 . 0f ; <nl> + if ( attenuated ) <nl> + { <nl> + acceleration = ( - ( 2 * dis . getLength ( ) ) ) / ( time * time ) ; <nl> + orSpeed = 2 * dis . getLength ( ) / time ; <nl> + } <nl> + else <nl> + { <nl> + _needCheckAutoScrollDestination = true ; <nl> + orSpeed = dis . getLength ( ) / time ; <nl> + } <nl> + startAutoScrollChildrenWithOriginalSpeed ( dir , orSpeed , attenuated , acceleration ) ; <nl> + } <nl> + <nl> + void UIScrollView : : jumpToDestination ( const cocos2d : : Point & des ) <nl> + { <nl> + float finalOffsetX = des . x ; <nl> + float finalOffsetY = des . y ; <nl> + switch ( _direction ) <nl> + { <nl> + case SCROLLVIEW_DIR_VERTICAL : <nl> + if ( des . y < = 0 ) <nl> + { <nl> + finalOffsetY = MAX ( des . y , _size . height - _innerContainer - > getSize ( ) . height ) ; <nl> + } <nl> + break ; <nl> + case SCROLLVIEW_DIR_HORIZONTAL : <nl> + if ( des . x < = 0 ) <nl> + { <nl> + finalOffsetX = MAX ( des . x , _size . width - _innerContainer - > getSize ( ) . width ) ; <nl> + } <nl> + break ; <nl> + case SCROLLVIEW_DIR_BOTH : <nl> + if ( des . y < = 0 ) <nl> + { <nl> + finalOffsetY = MAX ( des . y , _size . height - _innerContainer - > getSize ( ) . height ) ; <nl> + } <nl> + if ( des . x < = 0 ) <nl> + { <nl> + finalOffsetX = MAX ( des . x , _size . width - _innerContainer - > getSize ( ) . width ) ; <nl> + } <nl> + break ; <nl> + default : <nl> + break ; <nl> + } <nl> + _innerContainer - > setPosition ( cocos2d : : Point ( finalOffsetX , finalOffsetY ) ) ; <nl> + } <nl> + <nl> + void UIScrollView : : stopAutoScrollChildren ( ) <nl> + { <nl> + _autoScroll = false ; <nl> + _autoScrollOriginalSpeed = 0 . 0f ; <nl> + _autoScrollAddUpTime = 0 . 0f ; <nl> + } <nl> + <nl> + bool UIScrollView : : bounceScrollChildren ( float touchOffsetX , float touchOffsetY ) <nl> + { <nl> + bool scrollenabled = true ; <nl> + if ( touchOffsetX > 0 . 0f & & touchOffsetY > 0 . 0f ) / / first quadrant / / bounce to top - right <nl> + { <nl> + float realOffsetX = touchOffsetX ; <nl> + float realOffsetY = touchOffsetY ; <nl> + float icRightPos = _innerContainer - > getRightInParent ( ) ; <nl> + if ( icRightPos + realOffsetX > = _rightBoundary ) <nl> + { <nl> + realOffsetX = _rightBoundary - icRightPos ; <nl> + bounceRightEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + float icTopPos = _innerContainer - > getTopInParent ( ) ; <nl> + if ( icTopPos + touchOffsetY > = _topBoundary ) <nl> + { <nl> + realOffsetY = _topBoundary - icTopPos ; <nl> + bounceTopEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + moveChildren ( realOffsetX , realOffsetY ) ; <nl> + } <nl> + else if ( touchOffsetX < 0 . 0f & & touchOffsetY > 0 . 0f ) / / second quadrant / / bounce to top - left <nl> + { <nl> + float realOffsetX = touchOffsetX ; <nl> + float realOffsetY = touchOffsetY ; <nl> + float icLefrPos = _innerContainer - > getLeftInParent ( ) ; <nl> + if ( icLefrPos + realOffsetX < = _leftBoundary ) <nl> + { <nl> + realOffsetX = _leftBoundary - icLefrPos ; <nl> + bounceLeftEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + float icTopPos = _innerContainer - > getTopInParent ( ) ; <nl> + if ( icTopPos + touchOffsetY > = _topBoundary ) <nl> + { <nl> + realOffsetY = _topBoundary - icTopPos ; <nl> + bounceTopEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + moveChildren ( realOffsetX , realOffsetY ) ; <nl> + } <nl> + else if ( touchOffsetX < 0 . 0f & & touchOffsetY < 0 . 0f ) / / third quadrant / / bounce to bottom - left <nl> + { <nl> + float realOffsetX = touchOffsetX ; <nl> + float realOffsetY = touchOffsetY ; <nl> + float icLefrPos = _innerContainer - > getLeftInParent ( ) ; <nl> + if ( icLefrPos + realOffsetX < = _leftBoundary ) <nl> + { <nl> + realOffsetX = _leftBoundary - icLefrPos ; <nl> + bounceLeftEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + float icBottomPos = _innerContainer - > getBottomInParent ( ) ; <nl> + if ( icBottomPos + touchOffsetY < = _bottomBoundary ) <nl> + { <nl> + realOffsetY = _bottomBoundary - icBottomPos ; <nl> + bounceBottomEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + moveChildren ( realOffsetX , realOffsetY ) ; <nl> + } <nl> + else if ( touchOffsetX > 0 . 0f & & touchOffsetY < 0 . 0f ) / / forth quadrant / / bounce to bottom - right <nl> + { <nl> + float realOffsetX = touchOffsetX ; <nl> + float realOffsetY = touchOffsetY ; <nl> + float icRightPos = _innerContainer - > getRightInParent ( ) ; <nl> + if ( icRightPos + realOffsetX > = _rightBoundary ) <nl> + { <nl> + realOffsetX = _rightBoundary - icRightPos ; <nl> + bounceRightEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + float icBottomPos = _innerContainer - > getBottomInParent ( ) ; <nl> + if ( icBottomPos + touchOffsetY < = _bottomBoundary ) <nl> + { <nl> + realOffsetY = _bottomBoundary - icBottomPos ; <nl> + bounceBottomEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + moveChildren ( realOffsetX , realOffsetY ) ; <nl> + } <nl> + else if ( touchOffsetX = = 0 . 0f & & touchOffsetY > 0 . 0f ) / / bounce to top <nl> + { <nl> + float realOffsetY = touchOffsetY ; <nl> + float icTopPos = _innerContainer - > getTopInParent ( ) ; <nl> + if ( icTopPos + touchOffsetY > = _topBoundary ) <nl> + { <nl> + realOffsetY = _topBoundary - icTopPos ; <nl> + bounceTopEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + moveChildren ( 0 . 0f , realOffsetY ) ; <nl> + } <nl> + else if ( touchOffsetX = = 0 . 0f & & touchOffsetY < 0 . 0f ) / / bounce to bottom <nl> + { <nl> + float realOffsetY = touchOffsetY ; <nl> + float icBottomPos = _innerContainer - > getBottomInParent ( ) ; <nl> + if ( icBottomPos + touchOffsetY < = _bottomBoundary ) <nl> + { <nl> + realOffsetY = _bottomBoundary - icBottomPos ; <nl> + bounceBottomEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + moveChildren ( 0 . 0f , realOffsetY ) ; <nl> + } <nl> + else if ( touchOffsetX > 0 . 0f & & touchOffsetY = = 0 . 0f ) / / bounce to right <nl> + { <nl> + float realOffsetX = touchOffsetX ; <nl> + float icRightPos = _innerContainer - > getRightInParent ( ) ; <nl> + if ( icRightPos + realOffsetX > = _rightBoundary ) <nl> + { <nl> + realOffsetX = _rightBoundary - icRightPos ; <nl> + bounceRightEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + moveChildren ( realOffsetX , 0 . 0f ) ; <nl> + } <nl> + else if ( touchOffsetX < 0 . 0f & & touchOffsetY = = 0 . 0f ) / / bounce to left <nl> + { <nl> + float realOffsetX = touchOffsetX ; <nl> + float icLeftPos = _innerContainer - > getLeftInParent ( ) ; <nl> + if ( icLeftPos + realOffsetX < = _leftBoundary ) <nl> + { <nl> + realOffsetX = _leftBoundary - icLeftPos ; <nl> + bounceLeftEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + moveChildren ( realOffsetX , 0 . 0f ) ; <nl> + } <nl> + return scrollenabled ; <nl> + } <nl> + <nl> + bool UIScrollView : : checkCustomScrollDestination ( float * touchOffsetX , float * touchOffsetY ) <nl> + { <nl> + bool scrollenabled = true ; <nl> + switch ( _direction ) <nl> + { <nl> + case SCROLLVIEW_DIR_VERTICAL : / / vertical <nl> + { <nl> + if ( _autoScrollDir . y > 0 ) <nl> + { <nl> + float icBottomPos = _innerContainer - > getBottomInParent ( ) ; <nl> + if ( icBottomPos + * touchOffsetY > = _autoScrollDestination . y ) <nl> + { <nl> + * touchOffsetY = _autoScrollDestination . y - icBottomPos ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else <nl> + { <nl> + float icBottomPos = _innerContainer - > getBottomInParent ( ) ; <nl> + if ( icBottomPos + * touchOffsetY < = _autoScrollDestination . y ) <nl> + { <nl> + * touchOffsetY = _autoScrollDestination . y - icBottomPos ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + break ; <nl> + } <nl> + case SCROLLVIEW_DIR_HORIZONTAL : / / horizontal <nl> + { <nl> + if ( _autoScrollDir . x > 0 ) <nl> + { <nl> + float icLeftPos = _innerContainer - > getLeftInParent ( ) ; <nl> + if ( icLeftPos + * touchOffsetX > = _autoScrollDestination . x ) <nl> + { <nl> + * touchOffsetX = _autoScrollDestination . x - icLeftPos ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else <nl> + { <nl> + float icLeftPos = _innerContainer - > getLeftInParent ( ) ; <nl> + if ( icLeftPos + * touchOffsetX < = _autoScrollDestination . x ) <nl> + { <nl> + * touchOffsetX = _autoScrollDestination . x - icLeftPos ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + break ; <nl> + } <nl> + case SCROLLVIEW_DIR_BOTH : <nl> + { <nl> + if ( * touchOffsetX > 0 . 0f & & * touchOffsetY > 0 . 0f ) / / up right <nl> + { <nl> + float icLeftPos = _innerContainer - > getLeftInParent ( ) ; <nl> + if ( icLeftPos + * touchOffsetX > = _autoScrollDestination . x ) <nl> + { <nl> + * touchOffsetX = _autoScrollDestination . x - icLeftPos ; <nl> + scrollenabled = false ; <nl> + } <nl> + float icBottomPos = _innerContainer - > getBottomInParent ( ) ; <nl> + if ( icBottomPos + * touchOffsetY > = _autoScrollDestination . y ) <nl> + { <nl> + * touchOffsetY = _autoScrollDestination . y - icBottomPos ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else if ( * touchOffsetX < 0 . 0f & & * touchOffsetY > 0 . 0f ) / / up left <nl> + { <nl> + float icRightPos = _innerContainer - > getRightInParent ( ) ; <nl> + if ( icRightPos + * touchOffsetX < = _autoScrollDestination . x ) <nl> + { <nl> + * touchOffsetX = _autoScrollDestination . x - icRightPos ; <nl> + scrollenabled = false ; <nl> + } <nl> + float icBottomPos = _innerContainer - > getBottomInParent ( ) ; <nl> + if ( icBottomPos + * touchOffsetY > = _autoScrollDestination . y ) <nl> + { <nl> + * touchOffsetY = _autoScrollDestination . y - icBottomPos ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else if ( * touchOffsetX < 0 . 0f & & * touchOffsetY < 0 . 0f ) / / down left <nl> + { <nl> + float icRightPos = _innerContainer - > getRightInParent ( ) ; <nl> + if ( icRightPos + * touchOffsetX < = _autoScrollDestination . x ) <nl> + { <nl> + * touchOffsetX = _autoScrollDestination . x - icRightPos ; <nl> + scrollenabled = false ; <nl> + } <nl> + float icTopPos = _innerContainer - > getTopInParent ( ) ; <nl> + if ( icTopPos + * touchOffsetY < = _autoScrollDestination . y ) <nl> + { <nl> + * touchOffsetY = _autoScrollDestination . y - icTopPos ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else if ( * touchOffsetX > 0 . 0f & & * touchOffsetY < 0 . 0f ) / / down right <nl> + { <nl> + float icLeftPos = _innerContainer - > getLeftInParent ( ) ; <nl> + if ( icLeftPos + * touchOffsetX > = _autoScrollDestination . x ) <nl> + { <nl> + * touchOffsetX = _autoScrollDestination . x - icLeftPos ; <nl> + scrollenabled = false ; <nl> + } <nl> + float icTopPos = _innerContainer - > getTopInParent ( ) ; <nl> + if ( icTopPos + * touchOffsetY < = _autoScrollDestination . y ) <nl> + { <nl> + * touchOffsetY = _autoScrollDestination . y - icTopPos ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else if ( * touchOffsetX = = 0 . 0f & & * touchOffsetY > 0 . 0f ) / / up <nl> + { <nl> + float icBottomPos = _innerContainer - > getBottomInParent ( ) ; <nl> + if ( icBottomPos + * touchOffsetY > = _autoScrollDestination . y ) <nl> + { <nl> + * touchOffsetY = _autoScrollDestination . y - icBottomPos ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else if ( * touchOffsetX < 0 . 0f & & * touchOffsetY = = 0 . 0f ) / / left <nl> + { <nl> + float icRightPos = _innerContainer - > getRightInParent ( ) ; <nl> + if ( icRightPos + * touchOffsetX < = _autoScrollDestination . x ) <nl> + { <nl> + * touchOffsetX = _autoScrollDestination . x - icRightPos ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else if ( * touchOffsetX = = 0 . 0f & & * touchOffsetY < 0 . 0f ) / / down <nl> + { <nl> + float icTopPos = _innerContainer - > getTopInParent ( ) ; <nl> + if ( icTopPos + * touchOffsetY < = _autoScrollDestination . y ) <nl> + { <nl> + * touchOffsetY = _autoScrollDestination . y - icTopPos ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else if ( * touchOffsetX > 0 . 0f & & * touchOffsetY = = 0 . 0f ) / / right <nl> + { <nl> + float icLeftPos = _innerContainer - > getLeftInParent ( ) ; <nl> + if ( icLeftPos + * touchOffsetX > = _autoScrollDestination . x ) <nl> + { <nl> + * touchOffsetX = _autoScrollDestination . x - icLeftPos ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + break ; <nl> + } <nl> + default : <nl> + break ; <nl> + } <nl> + return scrollenabled ; <nl> + } <nl> <nl> - _children - > release ( ) ; <nl> + bool UIScrollView : : scrollChildren ( float touchOffsetX , float touchOffsetY ) <nl> + { <nl> + bool scrollenabled = true ; <nl> + scrollingEvent ( ) ; <nl> + switch ( _direction ) <nl> + { <nl> + case SCROLLVIEW_DIR_VERTICAL : / / vertical <nl> + { <nl> + float realOffset = touchOffsetY ; <nl> + if ( _bounceEnabled ) <nl> + { <nl> + float icBottomPos = _innerContainer - > getBottomInParent ( ) ; <nl> + if ( icBottomPos + touchOffsetY > = _bounceBottomBoundary ) <nl> + { <nl> + realOffset = _bounceBottomBoundary - icBottomPos ; <nl> + scrollToBottomEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + float icTopPos = _innerContainer - > getTopInParent ( ) ; <nl> + if ( icTopPos + touchOffsetY < = _bounceTopBoundary ) <nl> + { <nl> + realOffset = _bounceTopBoundary - icTopPos ; <nl> + scrollToTopEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else <nl> + { <nl> + float icBottomPos = _innerContainer - > getBottomInParent ( ) ; <nl> + if ( icBottomPos + touchOffsetY > = _bottomBoundary ) <nl> + { <nl> + realOffset = _bottomBoundary - icBottomPos ; <nl> + scrollToBottomEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + float icTopPos = _innerContainer - > getTopInParent ( ) ; <nl> + if ( icTopPos + touchOffsetY < = _topBoundary ) <nl> + { <nl> + realOffset = _topBoundary - icTopPos ; <nl> + scrollToTopEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + moveChildren ( 0 . 0f , realOffset ) ; <nl> + break ; <nl> + } <nl> + case SCROLLVIEW_DIR_HORIZONTAL : / / horizontal <nl> + { <nl> + float realOffset = touchOffsetX ; <nl> + if ( _bounceEnabled ) <nl> + { <nl> + float icRightPos = _innerContainer - > getRightInParent ( ) ; <nl> + if ( icRightPos + touchOffsetX < = _bounceRightBoundary ) <nl> + { <nl> + realOffset = _bounceRightBoundary - icRightPos ; <nl> + scrollToRightEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + float icLeftPos = _innerContainer - > getLeftInParent ( ) ; <nl> + if ( icLeftPos + touchOffsetX > = _bounceLeftBoundary ) <nl> + { <nl> + realOffset = _bounceLeftBoundary - icLeftPos ; <nl> + scrollToLeftEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else <nl> + { <nl> + float icRightPos = _innerContainer - > getRightInParent ( ) ; <nl> + if ( icRightPos + touchOffsetX < = _rightBoundary ) <nl> + { <nl> + realOffset = _rightBoundary - icRightPos ; <nl> + scrollToRightEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + float icLeftPos = _innerContainer - > getLeftInParent ( ) ; <nl> + if ( icLeftPos + touchOffsetX > = _leftBoundary ) <nl> + { <nl> + realOffset = _leftBoundary - icLeftPos ; <nl> + scrollToLeftEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + moveChildren ( realOffset , 0 . 0f ) ; <nl> + break ; <nl> + } <nl> + case SCROLLVIEW_DIR_BOTH : <nl> + { <nl> + float realOffsetX = touchOffsetX ; <nl> + float realOffsetY = touchOffsetY ; <nl> + if ( _bounceEnabled ) <nl> + { <nl> + if ( touchOffsetX > 0 . 0f & & touchOffsetY > 0 . 0f ) / / up right <nl> + { <nl> + float icLeftPos = _innerContainer - > getLeftInParent ( ) ; <nl> + if ( icLeftPos + touchOffsetX > = _bounceLeftBoundary ) <nl> + { <nl> + realOffsetX = _bounceLeftBoundary - icLeftPos ; <nl> + scrollToLeftEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + float icBottomPos = _innerContainer - > getBottomInParent ( ) ; <nl> + if ( icBottomPos + touchOffsetY > = _bounceBottomBoundary ) <nl> + { <nl> + realOffsetY = _bounceBottomBoundary - icBottomPos ; <nl> + scrollToBottomEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else if ( touchOffsetX < 0 . 0f & & touchOffsetY > 0 . 0f ) / / up left <nl> + { <nl> + float icRightPos = _innerContainer - > getRightInParent ( ) ; <nl> + if ( icRightPos + touchOffsetX < = _bounceRightBoundary ) <nl> + { <nl> + realOffsetX = _bounceRightBoundary - icRightPos ; <nl> + scrollToRightEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + float icBottomPos = _innerContainer - > getBottomInParent ( ) ; <nl> + if ( icBottomPos + touchOffsetY > = _bounceBottomBoundary ) <nl> + { <nl> + realOffsetY = _bounceBottomBoundary - icBottomPos ; <nl> + scrollToBottomEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else if ( touchOffsetX < 0 . 0f & & touchOffsetY < 0 . 0f ) / / down left <nl> + { <nl> + float icRightPos = _innerContainer - > getRightInParent ( ) ; <nl> + if ( icRightPos + touchOffsetX < = _bounceRightBoundary ) <nl> + { <nl> + realOffsetX = _bounceRightBoundary - icRightPos ; <nl> + scrollToRightEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + float icTopPos = _innerContainer - > getTopInParent ( ) ; <nl> + if ( icTopPos + touchOffsetY < = _bounceTopBoundary ) <nl> + { <nl> + realOffsetY = _bounceTopBoundary - icTopPos ; <nl> + scrollToTopEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else if ( touchOffsetX > 0 . 0f & & touchOffsetY < 0 . 0f ) / / down right <nl> + { <nl> + float icLeftPos = _innerContainer - > getLeftInParent ( ) ; <nl> + if ( icLeftPos + touchOffsetX > = _bounceLeftBoundary ) <nl> + { <nl> + realOffsetX = _bounceLeftBoundary - icLeftPos ; <nl> + scrollToLeftEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + float icTopPos = _innerContainer - > getTopInParent ( ) ; <nl> + if ( icTopPos + touchOffsetY < = _bounceTopBoundary ) <nl> + { <nl> + realOffsetY = _bounceTopBoundary - icTopPos ; <nl> + scrollToTopEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else if ( touchOffsetX = = 0 . 0f & & touchOffsetY > 0 . 0f ) / / up <nl> + { <nl> + float icBottomPos = _innerContainer - > getBottomInParent ( ) ; <nl> + if ( icBottomPos + touchOffsetY > = _bounceBottomBoundary ) <nl> + { <nl> + realOffsetY = _bounceBottomBoundary - icBottomPos ; <nl> + scrollToBottomEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else if ( touchOffsetX < 0 . 0f & & touchOffsetY = = 0 . 0f ) / / left <nl> + { <nl> + float icRightPos = _innerContainer - > getRightInParent ( ) ; <nl> + if ( icRightPos + touchOffsetX < = _bounceRightBoundary ) <nl> + { <nl> + realOffsetX = _bounceRightBoundary - icRightPos ; <nl> + scrollToRightEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else if ( touchOffsetX = = 0 . 0f & & touchOffsetY < 0 . 0f ) / / down <nl> + { <nl> + float icTopPos = _innerContainer - > getTopInParent ( ) ; <nl> + if ( icTopPos + touchOffsetY < = _bounceTopBoundary ) <nl> + { <nl> + realOffsetY = _bounceTopBoundary - icTopPos ; <nl> + scrollToTopEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else if ( touchOffsetX > 0 . 0f & & touchOffsetY = = 0 . 0f ) / / right <nl> + { <nl> + float icLeftPos = _innerContainer - > getLeftInParent ( ) ; <nl> + if ( icLeftPos + touchOffsetX > = _bounceLeftBoundary ) <nl> + { <nl> + realOffsetX = _bounceLeftBoundary - icLeftPos ; <nl> + scrollToLeftEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + } <nl> + else <nl> + { <nl> + if ( touchOffsetX > 0 . 0f & & touchOffsetY > 0 . 0f ) / / up right <nl> + { <nl> + float icLeftPos = _innerContainer - > getLeftInParent ( ) ; <nl> + if ( icLeftPos + touchOffsetX > = _leftBoundary ) <nl> + { <nl> + realOffsetX = _leftBoundary - icLeftPos ; <nl> + scrollToLeftEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + float icBottomPos = _innerContainer - > getBottomInParent ( ) ; <nl> + if ( icBottomPos + touchOffsetY > = _bottomBoundary ) <nl> + { <nl> + realOffsetY = _bottomBoundary - icBottomPos ; <nl> + scrollToBottomEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else if ( touchOffsetX < 0 . 0f & & touchOffsetY > 0 . 0f ) / / up left <nl> + { <nl> + float icRightPos = _innerContainer - > getRightInParent ( ) ; <nl> + if ( icRightPos + touchOffsetX < = _rightBoundary ) <nl> + { <nl> + realOffsetX = _rightBoundary - icRightPos ; <nl> + scrollToRightEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + float icBottomPos = _innerContainer - > getBottomInParent ( ) ; <nl> + if ( icBottomPos + touchOffsetY > = _bottomBoundary ) <nl> + { <nl> + realOffsetY = _bottomBoundary - icBottomPos ; <nl> + scrollToBottomEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else if ( touchOffsetX < 0 . 0f & & touchOffsetY < 0 . 0f ) / / down left <nl> + { <nl> + float icRightPos = _innerContainer - > getRightInParent ( ) ; <nl> + if ( icRightPos + touchOffsetX < = _rightBoundary ) <nl> + { <nl> + realOffsetX = _rightBoundary - icRightPos ; <nl> + scrollToRightEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + float icTopPos = _innerContainer - > getTopInParent ( ) ; <nl> + if ( icTopPos + touchOffsetY < = _topBoundary ) <nl> + { <nl> + realOffsetY = _topBoundary - icTopPos ; <nl> + scrollToTopEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else if ( touchOffsetX > 0 . 0f & & touchOffsetY < 0 . 0f ) / / down right <nl> + { <nl> + float icLeftPos = _innerContainer - > getLeftInParent ( ) ; <nl> + if ( icLeftPos + touchOffsetX > = _leftBoundary ) <nl> + { <nl> + realOffsetX = _leftBoundary - icLeftPos ; <nl> + scrollToLeftEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + float icTopPos = _innerContainer - > getTopInParent ( ) ; <nl> + if ( icTopPos + touchOffsetY < = _topBoundary ) <nl> + { <nl> + realOffsetY = _topBoundary - icTopPos ; <nl> + scrollToTopEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else if ( touchOffsetX = = 0 . 0f & & touchOffsetY > 0 . 0f ) / / up <nl> + { <nl> + float icBottomPos = _innerContainer - > getBottomInParent ( ) ; <nl> + if ( icBottomPos + touchOffsetY > = _bottomBoundary ) <nl> + { <nl> + realOffsetY = _bottomBoundary - icBottomPos ; <nl> + scrollToBottomEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else if ( touchOffsetX < 0 . 0f & & touchOffsetY = = 0 . 0f ) / / left <nl> + { <nl> + float icRightPos = _innerContainer - > getRightInParent ( ) ; <nl> + if ( icRightPos + touchOffsetX < = _rightBoundary ) <nl> + { <nl> + realOffsetX = _rightBoundary - icRightPos ; <nl> + scrollToRightEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else if ( touchOffsetX = = 0 . 0f & & touchOffsetY < 0 . 0f ) / / down <nl> + { <nl> + float icTopPos = _innerContainer - > getTopInParent ( ) ; <nl> + if ( icTopPos + touchOffsetY < = _topBoundary ) <nl> + { <nl> + realOffsetY = _topBoundary - icTopPos ; <nl> + scrollToTopEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else if ( touchOffsetX > 0 . 0f & & touchOffsetY = = 0 . 0f ) / / right <nl> + { <nl> + float icLeftPos = _innerContainer - > getLeftInParent ( ) ; <nl> + if ( icLeftPos + touchOffsetX > = _leftBoundary ) <nl> + { <nl> + realOffsetX = _leftBoundary - icLeftPos ; <nl> + scrollToLeftEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + } <nl> + moveChildren ( realOffsetX , realOffsetY ) ; <nl> + break ; <nl> + } <nl> + default : <nl> + break ; <nl> + } <nl> + return scrollenabled ; <nl> + } <nl> + <nl> + void UIScrollView : : scrollToBottom ( float time , bool attenuated ) <nl> + { <nl> + startAutoScrollChildrenWithDestination ( cocos2d : : Point ( _innerContainer - > getPosition ( ) . x , 0 . 0f ) , time , attenuated ) ; <nl> } <nl> <nl> - bool UIScrollView : : init ( ) <nl> + void UIScrollView : : scrollToTop ( float time , bool attenuated ) <nl> { <nl> - if ( Layout : : init ( ) ) <nl> - { <nl> - setUpdateEnabled ( true ) ; <nl> - setTouchEnabled ( true ) ; <nl> - setClippingEnabled ( true ) ; <nl> - _innerContainer - > setTouchEnabled ( false ) ; <nl> - return true ; <nl> - } <nl> - return false ; <nl> + startAutoScrollChildrenWithDestination ( cocos2d : : Point ( _innerContainer - > getPosition ( ) . x , _size . height - _innerContainer - > getSize ( ) . height ) , time , attenuated ) ; <nl> } <nl> <nl> - void UIScrollView : : initRenderer ( ) <nl> + void UIScrollView : : scrollToLeft ( float time , bool attenuated ) <nl> { <nl> - Layout : : initRenderer ( ) ; <nl> - _innerContainer = Layout : : create ( ) ; <nl> - Layout : : addChild ( _innerContainer ) ; <nl> + startAutoScrollChildrenWithDestination ( cocos2d : : Point ( 0 . 0f , _innerContainer - > getPosition ( ) . y ) , time , attenuated ) ; <nl> } <nl> <nl> - void UIScrollView : : onSizeChanged ( ) <nl> + void UIScrollView : : scrollToRight ( float time , bool attenuated ) <nl> { <nl> - Layout : : onSizeChanged ( ) ; <nl> - _topBoundary = _size . height ; <nl> - _rightBoundary = _size . width ; <nl> - Size innerSize = _innerContainer - > getSize ( ) ; <nl> - float orginInnerSizeWidth = innerSize . width ; <nl> - float orginInnerSizeHeight = innerSize . height ; <nl> - float innerSizeWidth = MAX ( orginInnerSizeWidth , _size . width ) ; <nl> - float innerSizeHeight = MAX ( orginInnerSizeHeight , _size . height ) ; <nl> - _innerContainer - > setSize ( Size ( innerSizeWidth , innerSizeHeight ) ) ; <nl> - _innerContainer - > setPosition ( Point ( 0 , _size . height - _innerContainer - > getSize ( ) . height ) ) ; <nl> + startAutoScrollChildrenWithDestination ( cocos2d : : Point ( _size . width - _innerContainer - > getSize ( ) . width , _innerContainer - > getPosition ( ) . y ) , time , attenuated ) ; <nl> } <nl> <nl> - void UIScrollView : : setInnerContainerSize ( const Size & size ) <nl> + void UIScrollView : : scrollToTopLeft ( float time , bool attenuated ) <nl> { <nl> - float innerSizeWidth = _size . width ; <nl> - float innerSizeHeight = _size . height ; <nl> - if ( size . width < _size . width ) <nl> + if ( _direction ! = SCROLLVIEW_DIR_BOTH ) <nl> { <nl> - CCLOG ( " Inner width < = scrollview width , it will be force sized ! " ) ; <nl> + CCLOG ( " Scroll diretion is not both ! " ) ; <nl> + return ; <nl> } <nl> - else <nl> + startAutoScrollChildrenWithDestination ( cocos2d : : Point ( 0 . 0f , _size . height - _innerContainer - > getSize ( ) . height ) , time , attenuated ) ; <nl> + } <nl> + <nl> + void UIScrollView : : scrollToTopRight ( float time , bool attenuated ) <nl> + { <nl> + if ( _direction ! = SCROLLVIEW_DIR_BOTH ) <nl> { <nl> - innerSizeWidth = size . width ; <nl> + CCLOG ( " Scroll diretion is not both ! " ) ; <nl> + return ; <nl> } <nl> - if ( size . height < _size . height ) <nl> + startAutoScrollChildrenWithDestination ( cocos2d : : Point ( _size . width - _innerContainer - > getSize ( ) . width , _size . height - _innerContainer - > getSize ( ) . height ) , time , attenuated ) ; <nl> + } <nl> + <nl> + void UIScrollView : : scrollToBottomLeft ( float time , bool attenuated ) <nl> + { <nl> + if ( _direction ! = SCROLLVIEW_DIR_BOTH ) <nl> { <nl> - CCLOG ( " Inner height < = scrollview height , it will be force sized ! " ) ; <nl> + CCLOG ( " Scroll diretion is not both ! " ) ; <nl> + return ; <nl> } <nl> - else <nl> + startAutoScrollChildrenWithDestination ( cocos2d : : Point : : ZERO , time , attenuated ) ; <nl> + } <nl> + <nl> + void UIScrollView : : scrollToBottomRight ( float time , bool attenuated ) <nl> + { <nl> + if ( _direction ! = SCROLLVIEW_DIR_BOTH ) <nl> { <nl> - innerSizeHeight = size . height ; <nl> + CCLOG ( " Scroll diretion is not both ! " ) ; <nl> + return ; <nl> } <nl> - _innerContainer - > setSize ( Size ( innerSizeWidth , innerSizeHeight ) ) ; <nl> - _innerContainer - > setPosition ( Point ( 0 , _size . height - _innerContainer - > getSize ( ) . height ) ) ; <nl> + startAutoScrollChildrenWithDestination ( cocos2d : : Point ( _size . width - _innerContainer - > getSize ( ) . width , 0 . 0f ) , time , attenuated ) ; <nl> } <nl> <nl> - const Size & UIScrollView : : getInnerContainerSize ( ) const <nl> + void UIScrollView : : scrollToPercentVertical ( float percent , float time , bool attenuated ) <nl> { <nl> - return _innerContainer - > getSize ( ) ; <nl> + float minY = _size . height - _innerContainer - > getSize ( ) . height ; <nl> + float h = - minY ; <nl> + startAutoScrollChildrenWithDestination ( cocos2d : : Point ( _innerContainer - > getPosition ( ) . x , minY + percent * h / 100 . 0f ) , time , attenuated ) ; <nl> } <nl> <nl> - bool UIScrollView : : addChild ( UIWidget * widget ) <nl> + void UIScrollView : : scrollToPercentHorizontal ( float percent , float time , bool attenuated ) <nl> { <nl> - return _innerContainer - > addChild ( widget ) ; <nl> + float w = _innerContainer - > getSize ( ) . width - _size . width ; <nl> + startAutoScrollChildrenWithDestination ( cocos2d : : Point ( - ( percent * w / 100 . 0f ) , _innerContainer - > getPosition ( ) . y ) , time , attenuated ) ; <nl> } <nl> <nl> - void UIScrollView : : removeAllChildren ( ) <nl> + void UIScrollView : : scrollToPercentBothDirection ( const cocos2d : : Point & percent , float time , bool attenuated ) <nl> { <nl> - _innerContainer - > removeAllChildren ( ) ; <nl> + if ( _direction ! = SCROLLVIEW_DIR_BOTH ) <nl> + { <nl> + return ; <nl> + } <nl> + float minY = _size . height - _innerContainer - > getSize ( ) . height ; <nl> + float h = - minY ; <nl> + float w = _innerContainer - > getSize ( ) . width - _size . width ; <nl> + startAutoScrollChildrenWithDestination ( cocos2d : : Point ( - ( percent . x * w / 100 . 0f ) , minY + percent . y * h / 100 . 0f ) , time , attenuated ) ; <nl> } <nl> <nl> - bool UIScrollView : : removeChild ( UIWidget * child ) <nl> + void UIScrollView : : jumpToBottom ( ) <nl> { <nl> - return _innerContainer - > removeChild ( child ) ; <nl> + jumpToDestination ( cocos2d : : Point ( _innerContainer - > getPosition ( ) . x , 0 . 0f ) ) ; <nl> } <nl> <nl> - Array * UIScrollView : : getChildren ( ) <nl> + void UIScrollView : : jumpToTop ( ) <nl> { <nl> - return _innerContainer - > getChildren ( ) ; <nl> + jumpToDestination ( cocos2d : : Point ( _innerContainer - > getPosition ( ) . x , _size . height - _innerContainer - > getSize ( ) . height ) ) ; <nl> } <nl> <nl> - void UIScrollView : : moveChildren ( float offset ) <nl> + void UIScrollView : : jumpToLeft ( ) <nl> { <nl> - switch ( _direction ) <nl> - { <nl> - case SCROLLVIEW_DIR_VERTICAL : / / vertical <nl> - { <nl> - _moveChildPoint . x = _innerContainer - > getPosition ( ) . x ; <nl> - _moveChildPoint . y = _innerContainer - > getPosition ( ) . y + offset ; <nl> - _innerContainer - > setPosition ( _moveChildPoint ) ; <nl> - break ; <nl> - } <nl> - case SCROLLVIEW_DIR_HORIZONTAL : / / horizontal <nl> - { <nl> - _moveChildPoint . x = _innerContainer - > getPosition ( ) . x + offset ; <nl> - _moveChildPoint . y = _innerContainer - > getPosition ( ) . y ; <nl> - _innerContainer - > setPosition ( _moveChildPoint ) ; <nl> - break ; <nl> - } <nl> - default : <nl> - break ; <nl> - } <nl> + jumpToDestination ( cocos2d : : Point ( 0 . 0f , _innerContainer - > getPosition ( ) . y ) ) ; <nl> } <nl> <nl> - void UIScrollView : : autoScrollChildren ( float dt ) <nl> + void UIScrollView : : jumpToRight ( ) <nl> { <nl> - switch ( _direction ) <nl> - { <nl> - case SCROLLVIEW_DIR_VERTICAL : / / vertical <nl> - switch ( _moveDirection ) <nl> - { <nl> - case SCROLLVIEW_MOVE_DIR_UP : / / up <nl> - { <nl> - float curDis = getCurAutoScrollDistance ( dt ) ; <nl> - if ( curDis < = 0 ) <nl> - { <nl> - curDis = 0 ; <nl> - stopAutoScrollChildren ( ) ; <nl> - } <nl> - if ( ! scrollChildren ( curDis ) ) <nl> - { <nl> - stopAutoScrollChildren ( ) ; <nl> - } <nl> - } <nl> - break ; <nl> - case SCROLLVIEW_MOVE_DIR_DOWN : / / down <nl> - { <nl> - float curDis = getCurAutoScrollDistance ( dt ) ; <nl> - if ( curDis < = 0 ) <nl> - { <nl> - curDis = 0 ; <nl> - stopAutoScrollChildren ( ) ; <nl> - } <nl> - if ( ! scrollChildren ( - curDis ) ) <nl> - { <nl> - stopAutoScrollChildren ( ) ; <nl> - } <nl> - } <nl> - break ; <nl> - default : <nl> - break ; <nl> - } <nl> - break ; <nl> - <nl> - case SCROLLVIEW_DIR_HORIZONTAL : / / horizontal <nl> - switch ( _moveDirection ) <nl> - { <nl> - case SCROLLVIEW_MOVE_DIR_LEFT : / / left <nl> - { <nl> - float curDis = getCurAutoScrollDistance ( dt ) ; <nl> - if ( curDis < = 0 ) <nl> - { <nl> - curDis = 0 ; <nl> - stopAutoScrollChildren ( ) ; <nl> - } <nl> - if ( ! scrollChildren ( - curDis ) ) <nl> - { <nl> - stopAutoScrollChildren ( ) ; <nl> - } <nl> - } <nl> - break ; <nl> - <nl> - case SCROLLVIEW_MOVE_DIR_RIGHT : / / right <nl> - { <nl> - float curDis = getCurAutoScrollDistance ( dt ) ; <nl> - if ( curDis < = 0 ) <nl> - { <nl> - curDis = 0 ; <nl> - stopAutoScrollChildren ( ) ; <nl> - } <nl> - if ( ! scrollChildren ( curDis ) ) <nl> - { <nl> - stopAutoScrollChildren ( ) ; <nl> - } <nl> - } <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> + jumpToDestination ( cocos2d : : Point ( _size . width - _innerContainer - > getSize ( ) . width , _innerContainer - > getPosition ( ) . y ) ) ; <nl> } <nl> <nl> - void UIScrollView : : startAutoScrollChildren ( float v ) <nl> + void UIScrollView : : jumpToTopLeft ( ) <nl> { <nl> - _autoScrollOriginalSpeed = v ; <nl> - _autoScroll = true ; <nl> + if ( _direction ! = SCROLLVIEW_DIR_BOTH ) <nl> + { <nl> + CCLOG ( " Scroll diretion is not both ! " ) ; <nl> + return ; <nl> + } <nl> + jumpToDestination ( cocos2d : : Point ( 0 . 0f , _size . height - _innerContainer - > getSize ( ) . height ) ) ; <nl> } <nl> <nl> - void UIScrollView : : stopAutoScrollChildren ( ) <nl> + void UIScrollView : : jumpToTopRight ( ) <nl> { <nl> - _autoScroll = false ; <nl> - _autoScrollOriginalSpeed = 0 . 0f ; <nl> + if ( _direction ! = SCROLLVIEW_DIR_BOTH ) <nl> + { <nl> + CCLOG ( " Scroll diretion is not both ! " ) ; <nl> + return ; <nl> + } <nl> + jumpToDestination ( cocos2d : : Point ( _size . width - _innerContainer - > getSize ( ) . width , _size . height - _innerContainer - > getSize ( ) . height ) ) ; <nl> } <nl> <nl> - float UIScrollView : : getCurAutoScrollDistance ( float time ) <nl> + void UIScrollView : : jumpToBottomLeft ( ) <nl> { <nl> - float dt = time ; <nl> - _autoScrollOriginalSpeed - = _autoScrollAcceleration * dt ; <nl> - return _autoScrollOriginalSpeed * dt ; <nl> + if ( _direction ! = SCROLLVIEW_DIR_BOTH ) <nl> + { <nl> + CCLOG ( " Scroll diretion is not both ! " ) ; <nl> + return ; <nl> + } <nl> + jumpToDestination ( cocos2d : : Point : : ZERO ) ; <nl> } <nl> <nl> - bool UIScrollView : : scrollChildren ( float touchOffset ) <nl> - { <nl> - float realOffset = touchOffset ; <nl> - <nl> - switch ( _direction ) <nl> + void UIScrollView : : jumpToBottomRight ( ) <nl> + { <nl> + if ( _direction ! = SCROLLVIEW_DIR_BOTH ) <nl> { <nl> - case SCROLLVIEW_DIR_VERTICAL : / / vertical <nl> - switch ( _moveDirection ) <nl> - { <nl> - case SCROLLVIEW_MOVE_DIR_UP : / / up <nl> - { <nl> - float icBottomPos = _innerContainer - > getBottomInParent ( ) ; <nl> - if ( icBottomPos + touchOffset > = _bottomBoundary ) <nl> - { <nl> - realOffset = _bottomBoundary - icBottomPos ; <nl> - moveChildren ( realOffset ) ; <nl> - _bottomEnd = true ; <nl> - scrollToBottomEvent ( ) ; <nl> - return false ; <nl> - } <nl> - break ; <nl> - } <nl> - case SCROLLVIEW_MOVE_DIR_DOWN : / / down <nl> - { <nl> - float icTopPos = _innerContainer - > getTopInParent ( ) ; <nl> - if ( icTopPos + touchOffset < = _topBoundary ) <nl> - { <nl> - realOffset = _topBoundary - icTopPos ; <nl> - moveChildren ( realOffset ) ; <nl> - _topEnd = true ; <nl> - scrollToTopEvent ( ) ; <nl> - return false ; <nl> - } <nl> - break ; <nl> - } <nl> - default : <nl> - break ; <nl> - } <nl> - moveChildren ( realOffset ) ; <nl> - _topEnd = false ; <nl> - _bottomEnd = false ; <nl> - return true ; <nl> - break ; <nl> - case SCROLLVIEW_DIR_HORIZONTAL : / / horizontal <nl> - switch ( _moveDirection ) <nl> - { <nl> - case SCROLLVIEW_MOVE_DIR_LEFT : / / left <nl> - { <nl> - float icRightPos = _innerContainer - > getRightInParent ( ) ; <nl> - if ( icRightPos + touchOffset < = _rightBoundary ) <nl> - { <nl> - realOffset = _rightBoundary - icRightPos ; <nl> - moveChildren ( realOffset ) ; <nl> - _rightEnd = true ; <nl> - scrollToRightEvent ( ) ; <nl> - return false ; <nl> - } <nl> - break ; <nl> - } <nl> - case SCROLLVIEW_MOVE_DIR_RIGHT : / / right <nl> - { <nl> - float icLeftPos = _innerContainer - > getLeftInParent ( ) ; <nl> - if ( icLeftPos + touchOffset > = _leftBoundary ) <nl> - { <nl> - realOffset = _leftBoundary - icLeftPos ; <nl> - moveChildren ( realOffset ) ; <nl> - _leftEnd = true ; <nl> - scrollToLeftEvent ( ) ; <nl> - return false ; <nl> - } <nl> - break ; <nl> - } <nl> - default : <nl> - break ; <nl> - } <nl> - moveChildren ( realOffset ) ; <nl> - _leftEnd = false ; <nl> - _rightEnd = false ; <nl> - return true ; <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> + CCLOG ( " Scroll diretion is not both ! " ) ; <nl> + return ; <nl> } <nl> - <nl> - return false ; <nl> + jumpToDestination ( cocos2d : : Point ( _size . width - _innerContainer - > getSize ( ) . width , 0 . 0f ) ) ; <nl> } <nl> <nl> - void UIScrollView : : scrollToBottom ( ) <nl> + void UIScrollView : : jumpToPercentVertical ( float percent ) <nl> { <nl> - _moveDirection = SCROLLVIEW_MOVE_DIR_UP ; / / up <nl> - scrollChildren ( _innerContainer - > getSize ( ) . height ) ; <nl> + float minY = _size . height - _innerContainer - > getSize ( ) . height ; <nl> + float h = - minY ; <nl> + jumpToDestination ( cocos2d : : Point ( _innerContainer - > getPosition ( ) . x , minY + percent * h / 100 . 0f ) ) ; <nl> } <nl> <nl> - void UIScrollView : : scrollToTop ( ) <nl> + void UIScrollView : : jumpToPercentHorizontal ( float percent ) <nl> { <nl> - _moveDirection = SCROLLVIEW_MOVE_DIR_DOWN ; / / down <nl> - scrollChildren ( - _innerContainer - > getSize ( ) . height ) ; <nl> + float w = _innerContainer - > getSize ( ) . width - _size . width ; <nl> + jumpToDestination ( cocos2d : : Point ( - ( percent * w / 100 . 0f ) , _innerContainer - > getPosition ( ) . y ) ) ; <nl> } <nl> <nl> - void UIScrollView : : startRecordSlidAction ( ) <nl> + void UIScrollView : : jumpToPercentBothDirection ( const cocos2d : : Point & percent ) <nl> { <nl> - if ( _children - > count ( ) < = 0 ) <nl> + if ( _direction ! = SCROLLVIEW_DIR_BOTH ) <nl> { <nl> return ; <nl> } <nl> - if ( _autoScroll ) { <nl> - stopAutoScrollChildren ( ) ; <nl> - } <nl> - _bePressed = true ; <nl> - _slidTime = 0 . 0 ; <nl> + float minY = _size . height - _innerContainer - > getSize ( ) . height ; <nl> + float h = - minY ; <nl> + float w = _innerContainer - > getSize ( ) . width - _size . width ; <nl> + jumpToDestination ( cocos2d : : Point ( - ( percent . x * w / 100 . 0f ) , minY + percent . y * h / 100 . 0f ) ) ; <nl> } <nl> <nl> - void UIScrollView : : endRecordSlidAction ( ) <nl> + void UIScrollView : : startRecordSlidAction ( ) <nl> { <nl> - if ( _children - > count ( ) < = 0 ) <nl> - { <nl> - return ; <nl> - } <nl> - if ( _slidTime < = 0 . 016f ) <nl> + if ( _autoScroll ) <nl> { <nl> - return ; <nl> + stopAutoScrollChildren ( ) ; <nl> } <nl> - float totalDis = 0 ; <nl> - totalDis = _touchEndLocation - _touchStartLocation ; <nl> - float orSpeed = fabs ( totalDis ) / ( _slidTime ) ; <nl> - startAutoScrollChildren ( orSpeed ) ; <nl> - <nl> - _bePressed = false ; <nl> - _slidTime = 0 . 0 ; <nl> - } <nl> - <nl> - void UIScrollView : : handlePressLogic ( const Point & touchPoint ) <nl> - { <nl> - Point nsp = _renderer - > convertToNodeSpace ( touchPoint ) ; <nl> - switch ( _direction ) <nl> + if ( _bouncing ) <nl> { <nl> - case SCROLLVIEW_DIR_VERTICAL : / / vertical <nl> - _touchMoveStartLocation = nsp . y ; <nl> - _touchStartLocation = nsp . y ; <nl> - break ; <nl> - case SCROLLVIEW_DIR_HORIZONTAL : / / horizontal <nl> - _touchMoveStartLocation = nsp . x ; <nl> - _touchStartLocation = nsp . x ; <nl> - break ; <nl> - default : <nl> - break ; <nl> + stopBounceChildren ( ) ; <nl> } <nl> - startRecordSlidAction ( ) ; <nl> + _slidTime = 0 . 0f ; <nl> } <nl> <nl> - void UIScrollView : : handleMoveLogic ( const Point & touchPoint ) <nl> + void UIScrollView : : endRecordSlidAction ( ) <nl> { <nl> - Point nsp = _renderer - > convertToNodeSpace ( touchPoint ) ; <nl> - float offset = 0 . 0f ; <nl> - <nl> - switch ( _direction ) <nl> + if ( ! checkNeedBounce ( ) & & _inertiaScrollEnabled ) <nl> { <nl> - case SCROLLVIEW_DIR_VERTICAL : / / vertical <nl> - { <nl> - float moveY = nsp . y ; <nl> - offset = moveY - _touchMoveStartLocation ; <nl> - _touchMoveStartLocation = moveY ; <nl> - <nl> - if ( offset < 0 . 0f ) <nl> + if ( _slidTime < = 0 . 016f ) <nl> + { <nl> + return ; <nl> + } <nl> + float totalDis = 0 . 0f ; <nl> + cocos2d : : Point dir ; <nl> + switch ( _direction ) <nl> + { <nl> + case SCROLLVIEW_DIR_VERTICAL : <nl> + totalDis = _touchEndedPoint . y - _touchBeganPoint . y ; <nl> + if ( totalDis < 0 . 0f ) <nl> { <nl> - _moveDirection = SCROLLVIEW_MOVE_DIR_DOWN ; / / down <nl> + dir = SCROLLDIR_DOWN ; <nl> } <nl> - else if ( offset > 0 . 0f ) <nl> + else <nl> { <nl> - _moveDirection = SCROLLVIEW_MOVE_DIR_UP ; / / up <nl> + dir = SCROLLDIR_UP ; <nl> } <nl> - } <nl> - break ; <nl> - <nl> - case SCROLLVIEW_DIR_HORIZONTAL : / / horizontal <nl> - { <nl> - float moveX = nsp . x ; <nl> - offset = moveX - _touchMoveStartLocation ; <nl> - _touchMoveStartLocation = moveX ; <nl> - <nl> - if ( offset < 0 ) <nl> + break ; <nl> + case SCROLLVIEW_DIR_HORIZONTAL : <nl> + totalDis = _touchEndedPoint . x - _touchBeganPoint . x ; <nl> + if ( totalDis < 0 . 0f ) <nl> { <nl> - _moveDirection = SCROLLVIEW_MOVE_DIR_LEFT ; / / left <nl> + dir = SCROLLDIR_LEFT ; <nl> } <nl> - else if ( offset > 0 ) <nl> + else <nl> { <nl> - _moveDirection = SCROLLVIEW_MOVE_DIR_RIGHT ; / / right <nl> + dir = SCROLLDIR_RIGHT ; <nl> } <nl> + break ; <nl> + case SCROLLVIEW_DIR_BOTH : <nl> + { <nl> + cocos2d : : Point subVector = _touchEndedPoint - _touchBeganPoint ; <nl> + totalDis = subVector . getLength ( ) ; <nl> + dir = subVector . normalize ( ) ; <nl> + break ; <nl> } <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> + default : <nl> + break ; <nl> + } <nl> + float orSpeed = MIN ( fabs ( totalDis ) / ( _slidTime ) , AUTOSCROLLMAXSPEED ) ; <nl> + startAutoScrollChildrenWithOriginalSpeed ( dir , orSpeed , true , - 1000 ) ; <nl> + _slidTime = 0 . 0f ; <nl> } <nl> - scrollChildren ( offset ) ; <nl> } <nl> <nl> - void UIScrollView : : handleReleaseLogic ( const Point & touchPoint ) <nl> + void UIScrollView : : handlePressLogic ( const cocos2d : : Point & touchPoint ) <nl> + { <nl> + _touchBeganPoint = _renderer - > convertToNodeSpace ( touchPoint ) ; <nl> + _touchMovingPoint = _touchBeganPoint ; <nl> + startRecordSlidAction ( ) ; <nl> + _bePressed = true ; <nl> + } <nl> + <nl> + void UIScrollView : : handleMoveLogic ( const cocos2d : : Point & touchPoint ) <nl> { <nl> - Point nsp = _renderer - > convertToNodeSpace ( touchPoint ) ; <nl> + _touchMovedPoint = _renderer - > convertToNodeSpace ( touchPoint ) ; <nl> + cocos2d : : Point delta = _touchMovedPoint - _touchMovingPoint ; <nl> + _touchMovingPoint = _touchMovedPoint ; <nl> switch ( _direction ) <nl> { <nl> case SCROLLVIEW_DIR_VERTICAL : / / vertical <nl> - _touchEndLocation = nsp . y ; <nl> + { <nl> + scrollChildren ( 0 . 0f , delta . y ) ; <nl> break ; <nl> - <nl> + } <nl> case SCROLLVIEW_DIR_HORIZONTAL : / / horizontal <nl> - _touchEndLocation = nsp . x ; <nl> + { <nl> + scrollChildren ( delta . x , 0 . 0f ) ; <nl> break ; <nl> - <nl> + } <nl> + case SCROLLVIEW_DIR_BOTH : / / both <nl> + { <nl> + scrollChildren ( delta . x , delta . y ) ; <nl> + break ; <nl> + } <nl> default : <nl> break ; <nl> } <nl> + } <nl> + <nl> + void UIScrollView : : handleReleaseLogic ( const cocos2d : : Point & touchPoint ) <nl> + { <nl> + _touchEndedPoint = _renderer - > convertToNodeSpace ( touchPoint ) ; <nl> endRecordSlidAction ( ) ; <nl> + _bePressed = false ; <nl> } <nl> <nl> - bool UIScrollView : : onTouchBegan ( const Point & touchPoint ) <nl> + bool UIScrollView : : onTouchBegan ( const cocos2d : : Point & touchPoint ) <nl> { <nl> - bool pass = Layout : : onTouchBegan ( touchPoint ) ; <nl> + bool pass = UILayout : : onTouchBegan ( touchPoint ) ; <nl> handlePressLogic ( touchPoint ) ; <nl> return pass ; <nl> } <nl> <nl> - void UIScrollView : : onTouchMoved ( const Point & touchPoint ) <nl> + void UIScrollView : : onTouchMoved ( const cocos2d : : Point & touchPoint ) <nl> { <nl> - Layout : : onTouchMoved ( touchPoint ) ; <nl> + UILayout : : onTouchMoved ( touchPoint ) ; <nl> handleMoveLogic ( touchPoint ) ; <nl> } <nl> <nl> - void UIScrollView : : onTouchEnded ( const Point & touchPoint ) <nl> + void UIScrollView : : onTouchEnded ( const cocos2d : : Point & touchPoint ) <nl> { <nl> - Layout : : onTouchEnded ( touchPoint ) ; <nl> + UILayout : : onTouchEnded ( touchPoint ) ; <nl> handleReleaseLogic ( touchPoint ) ; <nl> } <nl> <nl> - void UIScrollView : : onTouchCancelled ( const Point & touchPoint ) <nl> + void UIScrollView : : onTouchCancelled ( const cocos2d : : Point & touchPoint ) <nl> { <nl> - Layout : : onTouchCancelled ( touchPoint ) ; <nl> + UILayout : : onTouchCancelled ( touchPoint ) ; <nl> + handleReleaseLogic ( touchPoint ) ; <nl> } <nl> <nl> - void UIScrollView : : onTouchLongClicked ( const Point & touchPoint ) <nl> + void UIScrollView : : onTouchLongClicked ( const cocos2d : : Point & touchPoint ) <nl> { <nl> <nl> } <nl> void UIScrollView : : update ( float dt ) <nl> { <nl> autoScrollChildren ( dt ) ; <nl> } <nl> + if ( _bouncing ) <nl> + { <nl> + bounceChildren ( dt ) ; <nl> + } <nl> recordSlidTime ( dt ) ; <nl> } <nl> <nl> void UIScrollView : : recordSlidTime ( float dt ) <nl> } <nl> } <nl> <nl> - void UIScrollView : : interceptTouchEvent ( int handleState , UIWidget * sender , const Point & touchPoint ) <nl> + void UIScrollView : : interceptTouchEvent ( int handleState , UIWidget * sender , const cocos2d : : Point & touchPoint ) <nl> { <nl> switch ( handleState ) <nl> { <nl> void UIScrollView : : interceptTouchEvent ( int handleState , UIWidget * sender , const <nl> <nl> case 1 : <nl> { <nl> - float offset = 0 ; <nl> - switch ( _direction ) <nl> - { <nl> - case SCROLLVIEW_DIR_VERTICAL : / / vertical <nl> - offset = fabs ( sender - > getTouchStartPos ( ) . y - touchPoint . y ) ; <nl> - break ; <nl> - <nl> - case SCROLLVIEW_DIR_HORIZONTAL : / / horizontal <nl> - offset = fabs ( sender - > getTouchStartPos ( ) . x - touchPoint . x ) ; <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> + float offset = ( sender - > getTouchStartPos ( ) - touchPoint ) . getLength ( ) ; <nl> if ( offset > _childFocusCancelOffset ) <nl> { <nl> sender - > setFocused ( false ) ; <nl> void UIScrollView : : interceptTouchEvent ( int handleState , UIWidget * sender , const <nl> break ; <nl> <nl> case 3 : <nl> + handleReleaseLogic ( touchPoint ) ; <nl> break ; <nl> } <nl> } <nl> <nl> - void UIScrollView : : checkChildInfo ( int handleState , UIWidget * sender , const Point & touchPoint ) <nl> + void UIScrollView : : checkChildInfo ( int handleState , UIWidget * sender , const cocos2d : : Point & touchPoint ) <nl> { <nl> interceptTouchEvent ( handleState , sender , touchPoint ) ; <nl> } <nl> void UIScrollView : : scrollToRightEvent ( ) <nl> } <nl> } <nl> <nl> - void UIScrollView : : addEventListener ( Object * target , SEL_ScrollViewEvent selector ) <nl> + void UIScrollView : : scrollingEvent ( ) <nl> + { <nl> + if ( _eventListener & & _eventSelector ) <nl> + { <nl> + ( _eventListener - > * _eventSelector ) ( this , SCROLLVIEW_EVENT_SCROLLING ) ; <nl> + } <nl> + } <nl> + <nl> + void UIScrollView : : bounceTopEvent ( ) <nl> + { <nl> + if ( _eventListener & & _eventSelector ) <nl> + { <nl> + ( _eventListener - > * _eventSelector ) ( this , SCROLLVIEW_EVENT_BOUNCE_TOP ) ; <nl> + } <nl> + } <nl> + <nl> + void UIScrollView : : bounceBottomEvent ( ) <nl> + { <nl> + if ( _eventListener & & _eventSelector ) <nl> + { <nl> + ( _eventListener - > * _eventSelector ) ( this , SCROLLVIEW_EVENT_BOUNCE_BOTTOM ) ; <nl> + } <nl> + } <nl> + <nl> + void UIScrollView : : bounceLeftEvent ( ) <nl> + { <nl> + if ( _eventListener & & _eventSelector ) <nl> + { <nl> + ( _eventListener - > * _eventSelector ) ( this , SCROLLVIEW_EVENT_BOUNCE_LEFT ) ; <nl> + } <nl> + } <nl> + <nl> + void UIScrollView : : bounceRightEvent ( ) <nl> + { <nl> + if ( _eventListener & & _eventSelector ) <nl> + { <nl> + ( _eventListener - > * _eventSelector ) ( this , SCROLLVIEW_EVENT_BOUNCE_RIGHT ) ; <nl> + } <nl> + } <nl> + <nl> + void UIScrollView : : addEventListener ( cocos2d : : Object * target , SEL_ScrollViewEvent selector ) <nl> { <nl> _eventListener = target ; <nl> _eventSelector = selector ; <nl> SCROLLVIEW_DIR UIScrollView : : getDirection ( ) <nl> return _direction ; <nl> } <nl> <nl> - void UIScrollView : : setMoveDirection ( SCROLLVIEW_MOVE_DIR dir ) <nl> + void UIScrollView : : setBounceEnabled ( bool enabled ) <nl> + { <nl> + _bounceEnabled = enabled ; <nl> + } <nl> + <nl> + bool UIScrollView : : isBounceEnabled ( ) const <nl> + { <nl> + return _bounceEnabled ; <nl> + } <nl> + <nl> + void UIScrollView : : setInertiaScrollEnabled ( bool enabled ) <nl> { <nl> - _moveDirection = dir ; <nl> + _inertiaScrollEnabled = enabled ; <nl> } <nl> <nl> - SCROLLVIEW_MOVE_DIR UIScrollView : : getMoveDirection ( ) <nl> + bool UIScrollView : : isInertiaScrollEnabled ( ) const <nl> { <nl> - return _moveDirection ; <nl> + return _inertiaScrollEnabled ; <nl> } <nl> <nl> - Layout * UIScrollView : : getInnerContainer ( ) <nl> + UILayout * UIScrollView : : getInnerContainer ( ) <nl> { <nl> return _innerContainer ; <nl> } <nl> const char * UIScrollView : : getDescription ( ) const <nl> return " ScrollView " ; <nl> } <nl> <nl> + UIWidget * UIScrollView : : createCloneInstance ( ) <nl> + { <nl> + return UIScrollView : : create ( ) ; <nl> + } <nl> + <nl> + void UIScrollView : : copyClonedWidgetChildren ( UIWidget * model ) <nl> + { <nl> + UILayout : : copyClonedWidgetChildren ( model ) ; <nl> + } <nl> + <nl> + void UIScrollView : : copySpecialProperties ( UIWidget * widget ) <nl> + { <nl> + UIScrollView * scrollView = dynamic_cast < UIScrollView * > ( widget ) ; <nl> + if ( scrollView ) <nl> + { <nl> + UILayout : : copySpecialProperties ( widget ) ; <nl> + setInnerContainerSize ( scrollView - > getInnerContainerSize ( ) ) ; <nl> + setDirection ( scrollView - > _direction ) ; <nl> + setBounceEnabled ( scrollView - > _bounceEnabled ) ; <nl> + setInertiaScrollEnabled ( scrollView - > _inertiaScrollEnabled ) ; <nl> + } <nl> + } <nl> + <nl> } <nl> \ No newline at end of file <nl> mmm a / cocos / gui / UIScrollView . h <nl> ppp b / cocos / gui / UIScrollView . h <nl> <nl> # ifndef __UISCROLLVIEW_H__ <nl> # define __UISCROLLVIEW_H__ <nl> <nl> - # include " gui / / Layout . h " <nl> + # include " gui / UILayout . h " <nl> # include " gui / UIScrollInterface . h " <nl> <nl> namespace gui { <nl> enum SCROLLVIEW_DIR <nl> { <nl> SCROLLVIEW_DIR_NONE , <nl> SCROLLVIEW_DIR_VERTICAL , <nl> - SCROLLVIEW_DIR_HORIZONTAL <nl> - } ; <nl> - <nl> - enum SCROLLVIEW_MOVE_DIR <nl> - { <nl> - SCROLLVIEW_MOVE_DIR_NONE , <nl> - SCROLLVIEW_MOVE_DIR_UP , <nl> - SCROLLVIEW_MOVE_DIR_DOWN , <nl> - SCROLLVIEW_MOVE_DIR_LEFT , <nl> - SCROLLVIEW_MOVE_DIR_RIGHT , <nl> + SCROLLVIEW_DIR_HORIZONTAL , <nl> + SCROLLVIEW_DIR_BOTH <nl> } ; <nl> <nl> typedef enum <nl> typedef enum <nl> SCROLLVIEW_EVENT_SCROLL_TO_BOTTOM , <nl> SCROLLVIEW_EVENT_SCROLL_TO_LEFT , <nl> SCROLLVIEW_EVENT_SCROLL_TO_RIGHT , <nl> + SCROLLVIEW_EVENT_SCROLLING , <nl> + SCROLLVIEW_EVENT_BOUNCE_TOP , <nl> + SCROLLVIEW_EVENT_BOUNCE_BOTTOM , <nl> + SCROLLVIEW_EVENT_BOUNCE_LEFT , <nl> + SCROLLVIEW_EVENT_BOUNCE_RIGHT <nl> } ScrollviewEventType ; <nl> <nl> - typedef void ( cocos2d : : Object : : * SEL_ScrollViewEvent ) ( cocos2d : : Object * , ScrollviewEventType ) ; <nl> + typedef void ( cocos2d : : CCObject : : * SEL_ScrollViewEvent ) ( cocos2d : : Object * , ScrollviewEventType ) ; <nl> # define scrollvieweventselector ( _SELECTOR ) ( SEL_ScrollViewEvent ) ( & _SELECTOR ) <nl> <nl> <nl> - class UIScrollView : public Layout , public UIScrollInterface <nl> + class UIScrollView : public UILayout , public UIScrollInterface <nl> { <nl> public : <nl> / * * <nl> class UIScrollView : public Layout , public UIScrollInterface <nl> * <nl> * @ param SCROLLVIEW_DIR <nl> * / <nl> - void setDirection ( SCROLLVIEW_DIR dir ) ; <nl> + virtual void setDirection ( SCROLLVIEW_DIR dir ) ; <nl> <nl> / * * <nl> * Gets scroll direction of scrollview . <nl> class UIScrollView : public Layout , public UIScrollInterface <nl> * <nl> * @ return inner container . <nl> * / <nl> - Layout * getInnerContainer ( ) ; <nl> + UILayout * getInnerContainer ( ) ; <nl> <nl> / * * <nl> * Scroll inner container to bottom boundary of scrollview . <nl> * / <nl> - void scrollToBottom ( ) ; <nl> + void scrollToBottom ( float time , bool attenuated ) ; <nl> <nl> / * * <nl> * Scroll inner container to top boundary of scrollview . <nl> * / <nl> - void scrollToTop ( ) ; <nl> + void scrollToTop ( float time , bool attenuated ) ; <nl> + <nl> + / * * <nl> + * Scroll inner container to left boundary of scrollview . <nl> + * / <nl> + void scrollToLeft ( float time , bool attenuated ) ; <nl> + <nl> + / * * <nl> + * Scroll inner container to right boundary of scrollview . <nl> + * / <nl> + void scrollToRight ( float time , bool attenuated ) ; <nl> + <nl> + / * * <nl> + * Scroll inner container to top and left boundary of scrollview . <nl> + * / <nl> + void scrollToTopLeft ( float time , bool attenuated ) ; <nl> + <nl> + / * * <nl> + * Scroll inner container to top and right boundary of scrollview . <nl> + * / <nl> + void scrollToTopRight ( float time , bool attenuated ) ; <nl> + <nl> + / * * <nl> + * Scroll inner container to bottom and left boundary of scrollview . <nl> + * / <nl> + void scrollToBottomLeft ( float time , bool attenuated ) ; <nl> + <nl> + / * * <nl> + * Scroll inner container to bottom and right boundary of scrollview . <nl> + * / <nl> + void scrollToBottomRight ( float time , bool attenuated ) ; <nl> + <nl> + / * * <nl> + * Scroll inner container to vertical percent position of scrollview . <nl> + * / <nl> + void scrollToPercentVertical ( float percent , float time , bool attenuated ) ; <nl> + <nl> + / * * <nl> + * Scroll inner container to horizontal percent position of scrollview . <nl> + * / <nl> + void scrollToPercentHorizontal ( float percent , float time , bool attenuated ) ; <nl> + <nl> + / * * <nl> + * Scroll inner container to both direction percent position of scrollview . <nl> + * / <nl> + void scrollToPercentBothDirection ( const cocos2d : : Point & percent , float time , bool attenuated ) ; <nl> + <nl> + / * * <nl> + * Move inner container to bottom boundary of scrollview . <nl> + * / <nl> + void jumpToBottom ( ) ; <nl> + <nl> + / * * <nl> + * Move inner container to top boundary of scrollview . <nl> + * / <nl> + void jumpToTop ( ) ; <nl> + <nl> + / * * <nl> + * Move inner container to left boundary of scrollview . <nl> + * / <nl> + void jumpToLeft ( ) ; <nl> + <nl> + / * * <nl> + * Move inner container to right boundary of scrollview . <nl> + * / <nl> + void jumpToRight ( ) ; <nl> + <nl> + / * * <nl> + * Move inner container to top and left boundary of scrollview . <nl> + * / <nl> + void jumpToTopLeft ( ) ; <nl> + <nl> + / * * <nl> + * Move inner container to top and right boundary of scrollview . <nl> + * / <nl> + void jumpToTopRight ( ) ; <nl> + <nl> + / * * <nl> + * Move inner container to bottom and left boundary of scrollview . <nl> + * / <nl> + void jumpToBottomLeft ( ) ; <nl> + <nl> + / * * <nl> + * Move inner container to bottom and right boundary of scrollview . <nl> + * / <nl> + void jumpToBottomRight ( ) ; <nl> + <nl> + / * * <nl> + * Move inner container to vertical percent position of scrollview . <nl> + * / <nl> + void jumpToPercentVertical ( float percent ) ; <nl> + <nl> + / * * <nl> + * Move inner container to horizontal percent position of scrollview . <nl> + * / <nl> + void jumpToPercentHorizontal ( float percent ) ; <nl> + <nl> + / * * <nl> + * Move inner container to both direction percent position of scrollview . <nl> + * / <nl> + void jumpToPercentBothDirection ( const cocos2d : : Point & percent ) ; <nl> <nl> / * * <nl> * Changes inner container size of scrollview . <nl> class UIScrollView : public Layout , public UIScrollInterface <nl> / * * <nl> * Add call back function called scrollview event triggered <nl> * / <nl> - void addEventListener ( cocos2d : : Object * target , SEL_ScrollViewEvent selector ) ; <nl> + void addEventListener ( cocos2d : : Object * target , SEL_ScrollViewEvent selector ) ; <nl> <nl> / / override " addChild " method of widget . <nl> virtual bool addChild ( UIWidget * widget ) ; <nl> class UIScrollView : public Layout , public UIScrollInterface <nl> <nl> virtual void update ( float dt ) ; <nl> <nl> + void setBounceEnabled ( bool enabled ) ; <nl> + <nl> + bool isBounceEnabled ( ) const ; <nl> + <nl> + void setInertiaScrollEnabled ( bool enabled ) ; <nl> + <nl> + bool isInertiaScrollEnabled ( ) const ; <nl> + <nl> / * * <nl> * Sets LayoutType . <nl> * <nl> class UIScrollView : public Layout , public UIScrollInterface <nl> protected : <nl> virtual bool init ( ) ; <nl> virtual void initRenderer ( ) ; <nl> - void moveChildren ( float offset ) ; <nl> + void moveChildren ( float offsetX , float offsetY ) ; <nl> void autoScrollChildren ( float dt ) ; <nl> - void startAutoScrollChildren ( float v ) ; <nl> + void bounceChildren ( float dt ) ; <nl> + void checkBounceBoundary ( ) ; <nl> + bool checkNeedBounce ( ) ; <nl> + void startAutoScrollChildrenWithOriginalSpeed ( const cocos2d : : Point & dir , float v , bool attenuated , float acceleration ) ; <nl> + void startAutoScrollChildrenWithDestination ( const cocos2d : : Point & des , float time , bool attenuated ) ; <nl> + void jumpToDestination ( const cocos2d : : Point & des ) ; <nl> void stopAutoScrollChildren ( ) ; <nl> - float getCurAutoScrollDistance ( float time ) ; <nl> - virtual bool scrollChildren ( float touchOffset ) ; <nl> + void startBounceChildren ( float v ) ; <nl> + void stopBounceChildren ( ) ; <nl> + bool checkCustomScrollDestination ( float * touchOffsetX , float * touchOffsetY ) ; <nl> + virtual bool scrollChildren ( float touchOffsetX , float touchOffsetY ) ; <nl> + bool bounceScrollChildren ( float touchOffsetX , float touchOffsetY ) ; <nl> void startRecordSlidAction ( ) ; <nl> virtual void endRecordSlidAction ( ) ; <nl> virtual void handlePressLogic ( const cocos2d : : Point & touchPoint ) ; <nl> class UIScrollView : public Layout , public UIScrollInterface <nl> virtual void interceptTouchEvent ( int handleState , UIWidget * sender , const cocos2d : : Point & touchPoint ) ; <nl> virtual void checkChildInfo ( int handleState , UIWidget * sender , const cocos2d : : Point & touchPoint ) ; <nl> void recordSlidTime ( float dt ) ; <nl> - / / override " releaseResoures " method of widget . <nl> - virtual void releaseResoures ( ) ; <nl> - <nl> void scrollToTopEvent ( ) ; <nl> void scrollToBottomEvent ( ) ; <nl> void scrollToLeftEvent ( ) ; <nl> void scrollToRightEvent ( ) ; <nl> - void setMoveDirection ( SCROLLVIEW_MOVE_DIR dir ) ; <nl> - SCROLLVIEW_MOVE_DIR getMoveDirection ( ) ; <nl> + void scrollingEvent ( ) ; <nl> + void bounceTopEvent ( ) ; <nl> + void bounceBottomEvent ( ) ; <nl> + void bounceLeftEvent ( ) ; <nl> + void bounceRightEvent ( ) ; <nl> virtual void onSizeChanged ( ) ; <nl> - virtual void setClippingEnabled ( bool able ) { Layout : : setClippingEnabled ( able ) ; } ; <nl> + virtual UIWidget * createCloneInstance ( ) ; <nl> + virtual void copySpecialProperties ( UIWidget * model ) ; <nl> + virtual void copyClonedWidgetChildren ( UIWidget * model ) ; <nl> + virtual void setClippingEnabled ( bool able ) { UILayout : : setClippingEnabled ( able ) ; } ; <nl> protected : <nl> - Layout * _innerContainer ; <nl> + UILayout * _innerContainer ; <nl> <nl> SCROLLVIEW_DIR _direction ; <nl> - SCROLLVIEW_MOVE_DIR _moveDirection ; <nl> - float _touchStartLocation ; <nl> - float _touchEndLocation ; <nl> - float _touchMoveStartLocation ; <nl> - float _topBoundary ; / / test <nl> - float _bottomBoundary ; / / test <nl> + <nl> + cocos2d : : Point _touchBeganPoint ; <nl> + cocos2d : : Point _touchMovedPoint ; <nl> + cocos2d : : Point _touchEndedPoint ; <nl> + cocos2d : : Point _touchMovingPoint ; <nl> + cocos2d : : Point _autoScrollDir ; <nl> + <nl> + float _topBoundary ; <nl> + float _bottomBoundary ; <nl> float _leftBoundary ; <nl> float _rightBoundary ; <nl> <nl> - bool _topEnd ; <nl> - bool _bottomEnd ; <nl> - bool _leftEnd ; <nl> - bool _rightEnd ; <nl> + float _bounceTopBoundary ; <nl> + float _bounceBottomBoundary ; <nl> + float _bounceLeftBoundary ; <nl> + float _bounceRightBoundary ; <nl> + <nl> <nl> bool _autoScroll ; <nl> + float _autoScrollAddUpTime ; <nl> <nl> float _autoScrollOriginalSpeed ; <nl> float _autoScrollAcceleration ; <nl> + bool _isAutoScrollSpeedAttenuated ; <nl> + bool _needCheckAutoScrollDestination ; <nl> + cocos2d : : Point _autoScrollDestination ; <nl> <nl> bool _bePressed ; <nl> float _slidTime ; <nl> cocos2d : : Point _moveChildPoint ; <nl> float _childFocusCancelOffset ; <nl> <nl> + bool _leftBounceNeeded ; <nl> + bool _topBounceNeeded ; <nl> + bool _rightBounceNeeded ; <nl> + bool _bottomBounceNeeded ; <nl> + <nl> + bool _bounceEnabled ; <nl> + bool _bouncing ; <nl> + cocos2d : : Point _bounceDir ; <nl> + float _bounceOriginalSpeed ; <nl> + bool _inertiaScrollEnabled ; <nl> + <nl> + <nl> + <nl> cocos2d : : Object * _eventListener ; <nl> SEL_ScrollViewEvent _eventSelector ; <nl> - <nl> } ; <nl> <nl> } <nl> mmm a / cocos / gui / UISlider . cpp <nl> ppp b / cocos / gui / UISlider . cpp <nl> <nl> # include " gui / UISlider . h " <nl> # include " extensions / GUI / CCControlExtension / CCScale9Sprite . h " <nl> <nl> - using namespace cocos2d ; <nl> - using namespace cocos2d : : extension ; <nl> - <nl> namespace gui { <nl> <nl> UISlider : : UISlider ( ) : <nl> _barRenderer ( NULL ) , <nl> _progressBarRenderer ( NULL ) , <nl> - _progressBarTextureSize ( Size : : ZERO ) , <nl> + _progressBarTextureSize ( cocos2d : : Size : : ZERO ) , <nl> _slidBallNormalRenderer ( NULL ) , <nl> _slidBallPressedRenderer ( NULL ) , <nl> _slidBallDisabledRenderer ( NULL ) , <nl> _progressBarTextureFile ( " " ) , <nl> _slidBallNormalTextureFile ( " " ) , <nl> _slidBallPressedTextureFile ( " " ) , <nl> _slidBallDisabledTextureFile ( " " ) , <nl> - _capInsetsBarRenderer ( Rect : : ZERO ) , <nl> - _capInsetsProgressBarRenderer ( Rect : : ZERO ) , <nl> + _capInsetsBarRenderer ( cocos2d : : Rect : : ZERO ) , <nl> + _capInsetsProgressBarRenderer ( cocos2d : : Rect : : ZERO ) , <nl> _slidPercentListener ( NULL ) , <nl> _slidPercentSelector ( NULL ) , <nl> _barTexType ( UI_TEX_TYPE_LOCAL ) , <nl> UISlider * UISlider : : create ( ) <nl> void UISlider : : initRenderer ( ) <nl> { <nl> UIWidget : : initRenderer ( ) ; <nl> - _barRenderer = CCSprite : : create ( ) ; <nl> - _progressBarRenderer = CCSprite : : create ( ) ; <nl> - _progressBarRenderer - > setAnchorPoint ( Point ( 0 . 0f , 0 . 5f ) ) ; <nl> + _barRenderer = cocos2d : : Sprite : : create ( ) ; <nl> + _progressBarRenderer = cocos2d : : Sprite : : create ( ) ; <nl> + _progressBarRenderer - > setAnchorPoint ( cocos2d : : Point ( 0 . 0f , 0 . 5f ) ) ; <nl> _renderer - > addChild ( _barRenderer , - 1 ) ; <nl> _renderer - > addChild ( _progressBarRenderer , - 1 ) ; <nl> - _slidBallNormalRenderer = CCSprite : : create ( ) ; <nl> - _slidBallPressedRenderer = CCSprite : : create ( ) ; <nl> + _slidBallNormalRenderer = cocos2d : : Sprite : : create ( ) ; <nl> + _slidBallPressedRenderer = cocos2d : : Sprite : : create ( ) ; <nl> _slidBallPressedRenderer - > setVisible ( false ) ; <nl> - _slidBallDisabledRenderer = CCSprite : : create ( ) ; <nl> + _slidBallDisabledRenderer = cocos2d : : Sprite : : create ( ) ; <nl> _slidBallDisabledRenderer - > setVisible ( false ) ; <nl> - _slidBallRenderer = CCNode : : create ( ) ; <nl> + _slidBallRenderer = cocos2d : : Node : : create ( ) ; <nl> _slidBallRenderer - > addChild ( _slidBallNormalRenderer ) ; <nl> _slidBallRenderer - > addChild ( _slidBallPressedRenderer ) ; <nl> _slidBallRenderer - > addChild ( _slidBallDisabledRenderer ) ; <nl> void UISlider : : loadBarTexture ( const char * fileName , TextureResType texType ) <nl> case UI_TEX_TYPE_LOCAL : <nl> if ( _scale9Enabled ) <nl> { <nl> - dynamic_cast < Scale9Sprite * > ( _barRenderer ) - > initWithFile ( fileName ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _barRenderer ) - > initWithFile ( fileName ) ; <nl> } <nl> else <nl> { <nl> - dynamic_cast < Sprite * > ( _barRenderer ) - > initWithFile ( fileName ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _barRenderer ) - > initWithFile ( fileName ) ; <nl> } <nl> break ; <nl> case UI_TEX_TYPE_PLIST : <nl> if ( _scale9Enabled ) <nl> { <nl> - dynamic_cast < Scale9Sprite * > ( _barRenderer ) - > initWithSpriteFrameName ( fileName ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _barRenderer ) - > initWithSpriteFrameName ( fileName ) ; <nl> } <nl> else <nl> { <nl> - dynamic_cast < Sprite * > ( _barRenderer ) - > initWithSpriteFrameName ( fileName ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _barRenderer ) - > initWithSpriteFrameName ( fileName ) ; <nl> } <nl> break ; <nl> default : <nl> void UISlider : : loadBarTexture ( const char * fileName , TextureResType texType ) <nl> } <nl> if ( _scale9Enabled ) <nl> { <nl> - dynamic_cast < Scale9Sprite * > ( _barRenderer ) - > setColor ( getColor ( ) ) ; <nl> - dynamic_cast < Scale9Sprite * > ( _barRenderer ) - > setOpacity ( getOpacity ( ) ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _barRenderer ) - > setColor ( getColor ( ) ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _barRenderer ) - > setOpacity ( getOpacity ( ) ) ; <nl> } <nl> else <nl> { <nl> - dynamic_cast < Sprite * > ( _barRenderer ) - > setColor ( getColor ( ) ) ; <nl> - dynamic_cast < Sprite * > ( _barRenderer ) - > setOpacity ( getOpacity ( ) ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _barRenderer ) - > setColor ( getColor ( ) ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _barRenderer ) - > setOpacity ( getOpacity ( ) ) ; <nl> } <nl> barRendererScaleChangedWithSize ( ) ; <nl> } <nl> void UISlider : : loadProgressBarTexture ( const char * fileName , TextureResType texTy <nl> case UI_TEX_TYPE_LOCAL : <nl> if ( _scale9Enabled ) <nl> { <nl> - dynamic_cast < Scale9Sprite * > ( _progressBarRenderer ) - > initWithFile ( fileName ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _progressBarRenderer ) - > initWithFile ( fileName ) ; <nl> } <nl> else <nl> { <nl> - dynamic_cast < Sprite * > ( _progressBarRenderer ) - > initWithFile ( fileName ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _progressBarRenderer ) - > initWithFile ( fileName ) ; <nl> } <nl> break ; <nl> case UI_TEX_TYPE_PLIST : <nl> if ( _scale9Enabled ) <nl> { <nl> - dynamic_cast < Scale9Sprite * > ( _progressBarRenderer ) - > initWithSpriteFrameName ( fileName ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _progressBarRenderer ) - > initWithSpriteFrameName ( fileName ) ; <nl> } <nl> else <nl> { <nl> - dynamic_cast < Sprite * > ( _progressBarRenderer ) - > initWithSpriteFrameName ( fileName ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _progressBarRenderer ) - > initWithSpriteFrameName ( fileName ) ; <nl> } <nl> break ; <nl> default : <nl> void UISlider : : loadProgressBarTexture ( const char * fileName , TextureResType texTy <nl> } <nl> if ( _scale9Enabled ) <nl> { <nl> - dynamic_cast < Scale9Sprite * > ( _progressBarRenderer ) - > setColor ( getColor ( ) ) ; <nl> - dynamic_cast < Scale9Sprite * > ( _progressBarRenderer ) - > setOpacity ( getOpacity ( ) ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _progressBarRenderer ) - > setColor ( getColor ( ) ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _progressBarRenderer ) - > setOpacity ( getOpacity ( ) ) ; <nl> } <nl> else <nl> { <nl> - dynamic_cast < Sprite * > ( _progressBarRenderer ) - > setColor ( getColor ( ) ) ; <nl> - dynamic_cast < Sprite * > ( _progressBarRenderer ) - > setOpacity ( getOpacity ( ) ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _progressBarRenderer ) - > setColor ( getColor ( ) ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _progressBarRenderer ) - > setOpacity ( getOpacity ( ) ) ; <nl> } <nl> - _progressBarRenderer - > setAnchorPoint ( Point ( 0 . 0f , 0 . 5f ) ) ; <nl> + _progressBarRenderer - > setAnchorPoint ( cocos2d : : Point ( 0 . 0f , 0 . 5f ) ) ; <nl> _progressBarTextureSize = _progressBarRenderer - > getContentSize ( ) ; <nl> progressBarRendererScaleChangedWithSize ( ) ; <nl> } <nl> void UISlider : : setScale9Enabled ( bool able ) <nl> _progressBarRenderer = NULL ; <nl> if ( _scale9Enabled ) <nl> { <nl> - _barRenderer = Scale9Sprite : : create ( ) ; <nl> - _progressBarRenderer = Scale9Sprite : : create ( ) ; <nl> + _barRenderer = cocos2d : : extension : : Scale9Sprite : : create ( ) ; <nl> + _progressBarRenderer = cocos2d : : extension : : Scale9Sprite : : create ( ) ; <nl> } <nl> else <nl> { <nl> - _barRenderer = CCSprite : : create ( ) ; <nl> - _progressBarRenderer = CCSprite : : create ( ) ; <nl> + _barRenderer = cocos2d : : Sprite : : create ( ) ; <nl> + _progressBarRenderer = cocos2d : : Sprite : : create ( ) ; <nl> } <nl> loadBarTexture ( _textureFile . c_str ( ) , _barTexType ) ; <nl> loadProgressBarTexture ( _progressBarTextureFile . c_str ( ) , _progressBarTexType ) ; <nl> void UISlider : : ignoreContentAdaptWithSize ( bool ignore ) <nl> } <nl> } <nl> <nl> - void UISlider : : setCapInsets ( const Rect & capInsets ) <nl> + void UISlider : : setCapInsets ( const cocos2d : : Rect & capInsets ) <nl> { <nl> setCapInsetsBarRenderer ( capInsets ) ; <nl> setCapInsetProgressBarRebderer ( capInsets ) ; <nl> } <nl> <nl> - void UISlider : : setCapInsetsBarRenderer ( const Rect & capInsets ) <nl> + void UISlider : : setCapInsetsBarRenderer ( const cocos2d : : Rect & capInsets ) <nl> { <nl> _capInsetsBarRenderer = capInsets ; <nl> if ( ! _scale9Enabled ) <nl> { <nl> return ; <nl> } <nl> - dynamic_cast < Scale9Sprite * > ( _barRenderer ) - > setCapInsets ( capInsets ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _barRenderer ) - > setCapInsets ( capInsets ) ; <nl> } <nl> <nl> - void UISlider : : setCapInsetProgressBarRebderer ( const Rect & capInsets ) <nl> + void UISlider : : setCapInsetProgressBarRebderer ( const cocos2d : : Rect & capInsets ) <nl> { <nl> _capInsetsProgressBarRenderer = capInsets ; <nl> if ( ! _scale9Enabled ) <nl> { <nl> return ; <nl> } <nl> - dynamic_cast < Scale9Sprite * > ( _progressBarRenderer ) - > setCapInsets ( capInsets ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _progressBarRenderer ) - > setCapInsets ( capInsets ) ; <nl> } <nl> <nl> void UISlider : : loadSlidBallTextures ( const char * normal , const char * pressed , const char * disabled , TextureResType texType ) <nl> void UISlider : : setPercent ( int percent ) <nl> } <nl> _percent = percent ; <nl> float dis = _barLength * ( percent / 100 . 0f ) ; <nl> - _slidBallRenderer - > setPosition ( Point ( - _barLength / 2 . 0f + dis , 0 . 0f ) ) ; <nl> + _slidBallRenderer - > setPosition ( cocos2d : : Point ( - _barLength / 2 . 0f + dis , 0 . 0f ) ) ; <nl> if ( _scale9Enabled ) <nl> { <nl> - dynamic_cast < Scale9Sprite * > ( _progressBarRenderer ) - > setPreferredSize ( Size ( dis , _progressBarTextureSize . height ) ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _progressBarRenderer ) - > setPreferredSize ( cocos2d : : Size ( dis , _progressBarTextureSize . height ) ) ; <nl> } <nl> else <nl> { <nl> void UISlider : : setPercent ( int percent ) <nl> { <nl> case UI_TEX_TYPE_PLIST : <nl> { <nl> - Sprite * barNode = dynamic_cast < Sprite * > ( _progressBarRenderer ) ; <nl> + cocos2d : : Sprite * barNode = dynamic_cast < cocos2d : : Sprite * > ( _progressBarRenderer ) ; <nl> if ( barNode ) <nl> { <nl> - Point to = barNode - > getTextureRect ( ) . origin ; <nl> + cocos2d : : Point to = barNode - > getTextureRect ( ) . origin ; <nl> x = to . x ; <nl> y = to . y ; <nl> } <nl> void UISlider : : setPercent ( int percent ) <nl> default : <nl> break ; <nl> } <nl> - dynamic_cast < Sprite * > ( _progressBarRenderer ) - > setTextureRect ( Rect ( x , y , _progressBarTextureSize . width * ( percent / 100 . 0f ) , _progressBarTextureSize . height ) ) ; <nl> + dynamic_cast < cocos2d : : Sprite * > ( _progressBarRenderer ) - > setTextureRect ( cocos2d : : Rect ( x , y , _progressBarTextureSize . width * ( percent / 100 . 0f ) , _progressBarTextureSize . height ) ) ; <nl> } <nl> } <nl> <nl> - bool UISlider : : onTouchBegan ( const Point & touchPoint ) <nl> + bool UISlider : : onTouchBegan ( const cocos2d : : Point & touchPoint ) <nl> { <nl> bool pass = UIWidget : : onTouchBegan ( touchPoint ) ; <nl> - Point nsp = _renderer - > convertToNodeSpace ( touchPoint ) ; <nl> + cocos2d : : Point nsp = _renderer - > convertToNodeSpace ( touchPoint ) ; <nl> setPercent ( getPercentWithBallPos ( nsp . x ) ) ; <nl> percentChangedEvent ( ) ; <nl> return pass ; <nl> } <nl> <nl> - void UISlider : : onTouchMoved ( const Point & touchPoint ) <nl> + void UISlider : : onTouchMoved ( const cocos2d : : Point & touchPoint ) <nl> { <nl> - Point nsp = _renderer - > convertToNodeSpace ( touchPoint ) ; <nl> - _slidBallRenderer - > setPosition ( Point ( nsp . x , 0 ) ) ; <nl> + cocos2d : : Point nsp = _renderer - > convertToNodeSpace ( touchPoint ) ; <nl> + _slidBallRenderer - > setPosition ( cocos2d : : Point ( nsp . x , 0 ) ) ; <nl> setPercent ( getPercentWithBallPos ( nsp . x ) ) ; <nl> percentChangedEvent ( ) ; <nl> } <nl> <nl> - void UISlider : : onTouchEnded ( const Point & touchPoint ) <nl> + void UISlider : : onTouchEnded ( const cocos2d : : Point & touchPoint ) <nl> { <nl> UIWidget : : onTouchEnded ( touchPoint ) ; <nl> } <nl> <nl> - void UISlider : : onTouchCancelled ( const Point & touchPoint ) <nl> + void UISlider : : onTouchCancelled ( const cocos2d : : Point & touchPoint ) <nl> { <nl> UIWidget : : onTouchCancelled ( touchPoint ) ; <nl> } <nl> float UISlider : : getPercentWithBallPos ( float px ) <nl> return ( ( ( px - ( - _barLength / 2 . 0f ) ) / _barLength ) * 100 . 0f ) ; <nl> } <nl> <nl> - void UISlider : : addEventListener ( Object * target , SEL_SlidPercentChangedEvent selector ) <nl> + void UISlider : : addEventListener ( cocos2d : : Object * target , SEL_SlidPercentChangedEvent selector ) <nl> { <nl> _slidPercentListener = target ; <nl> _slidPercentSelector = selector ; <nl> void UISlider : : onSizeChanged ( ) <nl> progressBarRendererScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - const Size & UISlider : : getContentSize ( ) const <nl> + const cocos2d : : Size & UISlider : : getContentSize ( ) const <nl> { <nl> return _barRenderer - > getContentSize ( ) ; <nl> } <nl> <nl> - Node * UISlider : : getVirtualRenderer ( ) <nl> + cocos2d : : Node * UISlider : : getVirtualRenderer ( ) <nl> { <nl> return _barRenderer ; <nl> } <nl> void UISlider : : barRendererScaleChangedWithSize ( ) <nl> _barLength = _size . width ; <nl> if ( _scale9Enabled ) <nl> { <nl> - dynamic_cast < Scale9Sprite * > ( _barRenderer ) - > setPreferredSize ( _size ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _barRenderer ) - > setPreferredSize ( _size ) ; <nl> } <nl> else <nl> { <nl> - Size btextureSize = _barRenderer - > getContentSize ( ) ; <nl> + cocos2d : : Size btextureSize = _barRenderer - > getContentSize ( ) ; <nl> if ( btextureSize . width < = 0 . 0f | | btextureSize . height < = 0 . 0f ) <nl> { <nl> _barRenderer - > setScale ( 1 . 0f ) ; <nl> void UISlider : : progressBarRendererScaleChangedWithSize ( ) <nl> { <nl> if ( ! _scale9Enabled ) <nl> { <nl> - Size ptextureSize = _progressBarTextureSize ; <nl> + cocos2d : : Size ptextureSize = _progressBarTextureSize ; <nl> float pscaleX = _size . width / ptextureSize . width ; <nl> float pscaleY = _size . height / ptextureSize . height ; <nl> _progressBarRenderer - > setScaleX ( pscaleX ) ; <nl> void UISlider : : progressBarRendererScaleChangedWithSize ( ) <nl> { <nl> if ( _scale9Enabled ) <nl> { <nl> - dynamic_cast < Scale9Sprite * > ( _progressBarRenderer ) - > setPreferredSize ( _size ) ; <nl> + dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _progressBarRenderer ) - > setPreferredSize ( _size ) ; <nl> } <nl> else <nl> { <nl> - Size ptextureSize = _progressBarTextureSize ; <nl> + cocos2d : : Size ptextureSize = _progressBarTextureSize ; <nl> if ( ptextureSize . width < = 0 . 0f | | ptextureSize . height < = 0 . 0f ) <nl> { <nl> _progressBarRenderer - > setScale ( 1 . 0f ) ; <nl> void UISlider : : progressBarRendererScaleChangedWithSize ( ) <nl> _progressBarRenderer - > setScaleY ( pscaleY ) ; <nl> } <nl> } <nl> - _progressBarRenderer - > setPosition ( Point ( - _barLength * 0 . 5f , 0 . 0f ) ) ; <nl> + _progressBarRenderer - > setPosition ( cocos2d : : Point ( - _barLength * 0 . 5f , 0 . 0f ) ) ; <nl> setPercent ( _percent ) ; <nl> } <nl> <nl> const char * UISlider : : getDescription ( ) const <nl> return " Slider " ; <nl> } <nl> <nl> + UIWidget * UISlider : : createCloneInstance ( ) <nl> + { <nl> + return UISlider : : create ( ) ; <nl> + } <nl> + <nl> + void UISlider : : copySpecialProperties ( UIWidget * widget ) <nl> + { <nl> + UISlider * slider = dynamic_cast < UISlider * > ( widget ) ; <nl> + if ( slider ) <nl> + { <nl> + _prevIgnoreSize = slider - > _prevIgnoreSize ; <nl> + setScale9Enabled ( slider - > _scale9Enabled ) ; <nl> + loadBarTexture ( slider - > _textureFile . c_str ( ) , slider - > _barTexType ) ; <nl> + loadProgressBarTexture ( slider - > _progressBarTextureFile . c_str ( ) , slider - > _progressBarTexType ) ; <nl> + loadSlidBallTextureNormal ( slider - > _slidBallNormalTextureFile . c_str ( ) , slider - > _ballNTexType ) ; <nl> + loadSlidBallTexturePressed ( slider - > _slidBallPressedTextureFile . c_str ( ) , slider - > _ballPTexType ) ; <nl> + loadSlidBallTextureDisabled ( slider - > _slidBallDisabledTextureFile . c_str ( ) , slider - > _ballDTexType ) ; <nl> + setPercent ( slider - > getPercent ( ) ) ; <nl> + } <nl> + } <nl> + <nl> } <nl> \ No newline at end of file <nl> mmm a / cocos / gui / UISlider . h <nl> ppp b / cocos / gui / UISlider . h <nl> typedef enum <nl> SLIDER_PERCENTCHANGED <nl> } SliderEventType ; <nl> <nl> - typedef void ( cocos2d : : CCObject : : * SEL_SlidPercentChangedEvent ) ( cocos2d : : Object * , SliderEventType ) ; <nl> + typedef void ( cocos2d : : Object : : * SEL_SlidPercentChangedEvent ) ( cocos2d : : Object * , SliderEventType ) ; <nl> # define sliderpercentchangedselector ( _SELECTOR ) ( SEL_SlidPercentChangedEvent ) ( & _SELECTOR ) <nl> <nl> + / * * <nl> + * @ js NA <nl> + * @ lua NA <nl> + * / <nl> class UISlider : public UIWidget <nl> { <nl> public : <nl> class UISlider : public UIWidget <nl> * Returns the " class name " of widget . <nl> * / <nl> virtual const char * getDescription ( ) const ; <nl> + <nl> protected : <nl> virtual void initRenderer ( ) ; <nl> float getPercentWithBallPos ( float location ) ; <nl> class UISlider : public UIWidget <nl> virtual void onSizeChanged ( ) ; <nl> void barRendererScaleChangedWithSize ( ) ; <nl> void progressBarRendererScaleChangedWithSize ( ) ; <nl> + virtual UIWidget * createCloneInstance ( ) ; <nl> + virtual void copySpecialProperties ( UIWidget * model ) ; <nl> protected : <nl> cocos2d : : Node * _barRenderer ; <nl> cocos2d : : Node * _progressBarRenderer ; <nl> mmm a / cocos / gui / UITextField . cpp <nl> ppp b / cocos / gui / UITextField . cpp <nl> <nl> <nl> # include " gui / UITextField . h " <nl> <nl> - using namespace cocos2d ; <nl> - <nl> namespace gui { <nl> <nl> UICCTextField : : UICCTextField ( ) <nl> - : m_bMaxLengthEnabled ( false ) <nl> - , m_nMaxLength ( 0 ) <nl> - , m_bPasswordEnabled ( false ) <nl> - , m_strPasswordStyleText ( " * " ) <nl> - , m_bAttachWithIME ( false ) <nl> - , m_bDetachWithIME ( false ) <nl> - , m_bInsertText ( false ) <nl> - , m_bDeleteBackward ( false ) <nl> + : _maxLengthEnabled ( false ) <nl> + , _maxLength ( 0 ) <nl> + , _passwordEnabled ( false ) <nl> + , _passwordStyleText ( " * " ) <nl> + , _attachWithIME ( false ) <nl> + , _detachWithIME ( false ) <nl> + , _insertText ( false ) <nl> + , _deleteBackward ( false ) <nl> { <nl> } <nl> <nl> UICCTextField * UICCTextField : : create ( const char * placeholder , const char * fontN <nl> <nl> void UICCTextField : : onEnter ( ) <nl> { <nl> - CCTextFieldTTF : : setDelegate ( this ) ; <nl> + cocos2d : : TextFieldTTF : : setDelegate ( this ) ; <nl> } <nl> <nl> <nl> - bool UICCTextField : : onTextFieldAttachWithIME ( TextFieldTTF * pSender ) <nl> + bool UICCTextField : : onTextFieldAttachWithIME ( cocos2d : : TextFieldTTF * pSender ) <nl> { <nl> setAttachWithIME ( true ) ; <nl> return false ; <nl> } <nl> <nl> - bool UICCTextField : : onTextFieldInsertText ( TextFieldTTF * pSender , const char * text , int nLen ) <nl> + bool UICCTextField : : onTextFieldInsertText ( cocos2d : : TextFieldTTF * pSender , const char * text , int nLen ) <nl> { <nl> if ( nLen = = 1 & & strcmp ( text , " \ n " ) = = 0 ) <nl> { <nl> return false ; <nl> } <nl> setInsertText ( true ) ; <nl> - if ( m_bMaxLengthEnabled ) <nl> + if ( _maxLengthEnabled ) <nl> { <nl> - if ( CCTextFieldTTF : : getCharCount ( ) > = m_nMaxLength ) <nl> + if ( cocos2d : : TextFieldTTF : : getCharCount ( ) > = _maxLength ) <nl> { <nl> return true ; <nl> } <nl> bool UICCTextField : : onTextFieldInsertText ( TextFieldTTF * pSender , const char * tex <nl> return false ; <nl> } <nl> <nl> - bool UICCTextField : : onTextFieldDeleteBackward ( TextFieldTTF * pSender , const char * delText , int nLen ) <nl> + bool UICCTextField : : onTextFieldDeleteBackward ( cocos2d : : TextFieldTTF * pSender , const char * delText , int nLen ) <nl> { <nl> setDeleteBackward ( true ) ; <nl> return false ; <nl> } <nl> <nl> - bool UICCTextField : : onTextFieldDetachWithIME ( TextFieldTTF * pSender ) <nl> + bool UICCTextField : : onTextFieldDetachWithIME ( cocos2d : : TextFieldTTF * pSender ) <nl> { <nl> setDetachWithIME ( true ) ; <nl> return false ; <nl> bool UICCTextField : : onTextFieldDetachWithIME ( TextFieldTTF * pSender ) <nl> void UICCTextField : : insertText ( const char * text , int len ) <nl> { <nl> std : : string str_text = text ; <nl> - int str_len = strlen ( CCTextFieldTTF : : getString ( ) ) ; <nl> + int str_len = strlen ( cocos2d : : TextFieldTTF : : getString ( ) ) ; <nl> <nl> if ( strcmp ( text , " \ n " ) ! = 0 ) <nl> { <nl> - if ( m_bMaxLengthEnabled ) <nl> + if ( _maxLengthEnabled ) <nl> { <nl> int multiple = 1 ; <nl> char value = text [ 0 ] ; <nl> void UICCTextField : : insertText ( const char * text , int len ) <nl> multiple = 3 ; <nl> } <nl> <nl> - if ( str_len + len > m_nMaxLength * multiple ) <nl> + if ( str_len + len > _maxLength * multiple ) <nl> { <nl> - str_text = str_text . substr ( 0 , m_nMaxLength * multiple ) ; <nl> - len = m_nMaxLength * multiple ; <nl> + str_text = str_text . substr ( 0 , _maxLength * multiple ) ; <nl> + len = _maxLength * multiple ; <nl> / * <nl> int mod = str_len % 3 ; <nl> int offset = ( mod = = 0 ) ? 0 : ( 3 - mod ) ; <nl> int amount = str_len + offset ; <nl> - str_text = str_text . substr ( 0 , m_nMaxLength - amount ) ; <nl> + str_text = str_text . substr ( 0 , _maxLength - amount ) ; <nl> / / CCLOG ( " str_test = % s " , str_text . c_str ( ) ) ; <nl> * / <nl> } <nl> } <nl> } <nl> - CCTextFieldTTF : : insertText ( str_text . c_str ( ) , len ) ; <nl> + cocos2d : : TextFieldTTF : : insertText ( str_text . c_str ( ) , len ) ; <nl> <nl> / / password <nl> - if ( m_bPasswordEnabled ) <nl> + if ( _passwordEnabled ) <nl> { <nl> - if ( CCTextFieldTTF : : getCharCount ( ) > 0 ) <nl> + if ( cocos2d : : TextFieldTTF : : getCharCount ( ) > 0 ) <nl> { <nl> setPasswordText ( _inputText - > c_str ( ) ) ; <nl> } <nl> void UICCTextField : : insertText ( const char * text , int len ) <nl> <nl> void UICCTextField : : deleteBackward ( ) <nl> { <nl> - CCTextFieldTTF : : deleteBackward ( ) ; <nl> + cocos2d : : TextFieldTTF : : deleteBackward ( ) ; <nl> <nl> - if ( CCTextFieldTTF : : getCharCount ( ) > 0 ) <nl> + if ( cocos2d : : TextFieldTTF : : getCharCount ( ) > 0 ) <nl> { <nl> / / password <nl> - if ( m_bPasswordEnabled ) <nl> + if ( _passwordEnabled ) <nl> { <nl> setPasswordText ( _inputText - > c_str ( ) ) ; <nl> } <nl> void UICCTextField : : deleteBackward ( ) <nl> <nl> void UICCTextField : : openIME ( ) <nl> { <nl> - CCTextFieldTTF : : attachWithIME ( ) ; <nl> + cocos2d : : TextFieldTTF : : attachWithIME ( ) ; <nl> } <nl> <nl> void UICCTextField : : closeIME ( ) <nl> { <nl> - CCTextFieldTTF : : detachWithIME ( ) ; <nl> + cocos2d : : TextFieldTTF : : detachWithIME ( ) ; <nl> } <nl> <nl> void UICCTextField : : setMaxLengthEnabled ( bool enable ) <nl> { <nl> - m_bMaxLengthEnabled = enable ; <nl> + _maxLengthEnabled = enable ; <nl> } <nl> <nl> bool UICCTextField : : isMaxLengthEnabled ( ) <nl> { <nl> - return m_bMaxLengthEnabled ; <nl> + return _maxLengthEnabled ; <nl> } <nl> <nl> void UICCTextField : : setMaxLength ( int length ) <nl> { <nl> - m_nMaxLength = length ; <nl> + _maxLength = length ; <nl> } <nl> <nl> int UICCTextField : : getMaxLength ( ) <nl> { <nl> - return m_nMaxLength ; <nl> + return _maxLength ; <nl> } <nl> <nl> int UICCTextField : : getCharCount ( ) <nl> { <nl> - return CCTextFieldTTF : : getCharCount ( ) ; <nl> + return cocos2d : : TextFieldTTF : : getCharCount ( ) ; <nl> } <nl> <nl> void UICCTextField : : setPasswordEnabled ( bool enable ) <nl> { <nl> - m_bPasswordEnabled = enable ; <nl> + _passwordEnabled = enable ; <nl> } <nl> <nl> bool UICCTextField : : isPasswordEnabled ( ) <nl> { <nl> - return m_bPasswordEnabled ; <nl> + return _passwordEnabled ; <nl> } <nl> <nl> void UICCTextField : : setPasswordStyleText ( const char * styleText ) <nl> void UICCTextField : : setPasswordStyleText ( const char * styleText ) <nl> { <nl> return ; <nl> } <nl> - m_strPasswordStyleText = styleText ; <nl> + _passwordStyleText = styleText ; <nl> } <nl> <nl> void UICCTextField : : setPasswordText ( const char * text ) <nl> void UICCTextField : : setPasswordText ( const char * text ) <nl> std : : string tempStr ; <nl> for ( size_t i = 0 ; i < strlen ( text ) ; + + i ) <nl> { <nl> - tempStr . append ( m_strPasswordStyleText ) ; <nl> + tempStr . append ( _passwordStyleText ) ; <nl> } <nl> - CCLabelTTF : : setString ( tempStr . c_str ( ) ) ; <nl> + cocos2d : : LabelTTF : : setString ( tempStr . c_str ( ) ) ; <nl> } <nl> <nl> void UICCTextField : : setAttachWithIME ( bool attach ) <nl> { <nl> - m_bAttachWithIME = attach ; <nl> + _attachWithIME = attach ; <nl> } <nl> <nl> bool UICCTextField : : getAttachWithIME ( ) <nl> { <nl> - return m_bAttachWithIME ; <nl> + return _attachWithIME ; <nl> } <nl> <nl> void UICCTextField : : setDetachWithIME ( bool detach ) <nl> { <nl> - m_bDetachWithIME = detach ; <nl> + _detachWithIME = detach ; <nl> } <nl> <nl> bool UICCTextField : : getDetachWithIME ( ) <nl> { <nl> - return m_bDetachWithIME ; <nl> + return _detachWithIME ; <nl> } <nl> <nl> void UICCTextField : : setInsertText ( bool insert ) <nl> { <nl> - m_bInsertText = insert ; <nl> + _insertText = insert ; <nl> } <nl> <nl> bool UICCTextField : : getInsertText ( ) <nl> { <nl> - return m_bInsertText ; <nl> + return _insertText ; <nl> } <nl> <nl> void UICCTextField : : setDeleteBackward ( bool deleteBackward ) <nl> { <nl> - m_bDeleteBackward = deleteBackward ; <nl> + _deleteBackward = deleteBackward ; <nl> } <nl> <nl> bool UICCTextField : : getDeleteBackward ( ) <nl> { <nl> - return m_bDeleteBackward ; <nl> + return _deleteBackward ; <nl> } <nl> <nl> <nl> _touchWidth ( 0 . 0f ) , <nl> _touchHeight ( 0 . 0f ) , <nl> _useTouchArea ( false ) , <nl> _eventListener ( NULL ) , <nl> - _eventSelector ( NULL ) <nl> + _eventSelector ( NULL ) , <nl> + _passwordStyleText ( " " ) <nl> { <nl> } <nl> <nl> void UITextField : : initRenderer ( ) <nl> _renderer - > addChild ( _textFieldRenderer ) ; <nl> } <nl> <nl> - void UITextField : : setTouchSize ( const Size & size ) <nl> + void UITextField : : setTouchSize ( const cocos2d : : Size & size ) <nl> { <nl> _useTouchArea = true ; <nl> _touchWidth = size . width ; <nl> const char * UITextField : : getStringValue ( ) <nl> return _textFieldRenderer - > getString ( ) ; <nl> } <nl> <nl> - bool UITextField : : onTouchBegan ( const Point & touchPoint ) <nl> + bool UITextField : : onTouchBegan ( const cocos2d : : Point & touchPoint ) <nl> { <nl> bool pass = UIWidget : : onTouchBegan ( touchPoint ) ; <nl> _textFieldRenderer - > attachWithIME ( ) ; <nl> bool UITextField : : isPasswordEnabled ( ) <nl> void UITextField : : setPasswordStyleText ( const char * styleText ) <nl> { <nl> _textFieldRenderer - > setPasswordStyleText ( styleText ) ; <nl> + <nl> + _passwordStyleText = styleText ; <nl> } <nl> <nl> void UITextField : : update ( float dt ) <nl> void UITextField : : insertTextEvent ( ) <nl> { <nl> if ( _eventListener & & _eventSelector ) <nl> { <nl> - ( _eventListener - > * _eventSelector ) ( this , TEXTFIELD_EVENT_INDERT_TEXT ) ; <nl> + ( _eventListener - > * _eventSelector ) ( this , TEXTFIELD_EVENT_INSERT_TEXT ) ; <nl> } <nl> } <nl> <nl> void UITextField : : deleteBackwardEvent ( ) <nl> } <nl> } <nl> <nl> - void UITextField : : addEventListener ( Object * target , SEL_TextFieldEvent selecor ) <nl> + void UITextField : : addEventListener ( cocos2d : : Object * target , SEL_TextFieldEvent selecor ) <nl> { <nl> _eventListener = target ; <nl> _eventSelector = selecor ; <nl> } <nl> <nl> - void UITextField : : setAnchorPoint ( const Point & pt ) <nl> + void UITextField : : setAnchorPoint ( const cocos2d : : Point & pt ) <nl> { <nl> UIWidget : : setAnchorPoint ( pt ) ; <nl> _textFieldRenderer - > setAnchorPoint ( pt ) ; <nl> } <nl> <nl> - void UITextField : : setColor ( const Color3B & color ) <nl> + void UITextField : : setColor ( const cocos2d : : Color3B & color ) <nl> { <nl> UIWidget : : setColor ( color ) ; <nl> _textFieldRenderer - > setColor ( color ) ; <nl> void UITextField : : textfieldRendererScaleChangedWithSize ( ) <nl> } <nl> else <nl> { <nl> - Size textureSize = getContentSize ( ) ; <nl> + cocos2d : : Size textureSize = getContentSize ( ) ; <nl> if ( textureSize . width < = 0 . 0f | | textureSize . height < = 0 . 0f ) <nl> { <nl> _textFieldRenderer - > setScale ( 1 . 0f ) ; <nl> void UITextField : : textfieldRendererScaleChangedWithSize ( ) <nl> } <nl> } <nl> <nl> - const Size & UITextField : : getContentSize ( ) const <nl> + const cocos2d : : Size & UITextField : : getContentSize ( ) const <nl> { <nl> return _textFieldRenderer - > getContentSize ( ) ; <nl> } <nl> <nl> - Node * UITextField : : getVirtualRenderer ( ) <nl> + cocos2d : : Node * UITextField : : getVirtualRenderer ( ) <nl> { <nl> return _textFieldRenderer ; <nl> } <nl> const char * UITextField : : getDescription ( ) const <nl> return " TextField " ; <nl> } <nl> <nl> + void UITextField : : attachWithIME ( ) <nl> + { <nl> + _textFieldRenderer - > attachWithIME ( ) ; <nl> + } <nl> + <nl> + UIWidget * UITextField : : createCloneInstance ( ) <nl> + { <nl> + return UITextField : : create ( ) ; <nl> + } <nl> + <nl> + void UITextField : : copySpecialProperties ( UIWidget * widget ) <nl> + { <nl> + UITextField * textField = dynamic_cast < UITextField * > ( widget ) ; <nl> + if ( textField ) <nl> + { <nl> + setText ( textField - > _textFieldRenderer - > getString ( ) ) ; <nl> + setPlaceHolder ( textField - > getStringValue ( ) ) ; <nl> + setFontSize ( textField - > _textFieldRenderer - > getFontSize ( ) ) ; <nl> + setFontName ( textField - > _textFieldRenderer - > getFontName ( ) ) ; <nl> + setMaxLengthEnabled ( textField - > isMaxLengthEnabled ( ) ) ; <nl> + setMaxLength ( textField - > getMaxLength ( ) ) ; <nl> + setPasswordEnabled ( textField - > isPasswordEnabled ( ) ) ; <nl> + setPasswordStyleText ( textField - > _passwordStyleText . c_str ( ) ) ; <nl> + setAttachWithIME ( textField - > getAttachWithIME ( ) ) ; <nl> + setDetachWithIME ( textField - > getDetachWithIME ( ) ) ; <nl> + setInsertText ( textField - > getInsertText ( ) ) ; <nl> + setDeleteBackward ( textField - > getDeleteBackward ( ) ) ; <nl> + } <nl> + } <nl> + <nl> } <nl> \ No newline at end of file <nl> mmm a / cocos / gui / UITextField . h <nl> ppp b / cocos / gui / UITextField . h <nl> <nl> <nl> namespace gui { <nl> <nl> + / * * <nl> + * @ js NA <nl> + * @ lua NA <nl> + * / <nl> class UICCTextField : public cocos2d : : TextFieldTTF , public cocos2d : : TextFieldDelegate <nl> { <nl> public : <nl> class UICCTextField : public cocos2d : : TextFieldTTF , public cocos2d : : TextFieldDele <nl> bool getInsertText ( ) ; <nl> void setDeleteBackward ( bool deleteBackward ) ; <nl> bool getDeleteBackward ( ) ; <nl> - <nl> - <nl> protected : <nl> - bool m_bMaxLengthEnabled ; <nl> - int m_nMaxLength ; <nl> - bool m_bPasswordEnabled ; <nl> - std : : string m_strPasswordStyleText ; <nl> - bool m_bAttachWithIME ; <nl> - bool m_bDetachWithIME ; <nl> - bool m_bInsertText ; <nl> - bool m_bDeleteBackward ; <nl> + bool _maxLengthEnabled ; <nl> + int _maxLength ; <nl> + bool _passwordEnabled ; <nl> + std : : string _passwordStyleText ; <nl> + bool _attachWithIME ; <nl> + bool _detachWithIME ; <nl> + bool _insertText ; <nl> + bool _deleteBackward ; <nl> } ; <nl> <nl> - <nl> typedef enum <nl> { <nl> TEXTFIELD_EVENT_ATTACH_WITH_IME , <nl> TEXTFIELD_EVENT_DETACH_WITH_IME , <nl> - TEXTFIELD_EVENT_INDERT_TEXT , <nl> + TEXTFIELD_EVENT_INSERT_TEXT , <nl> TEXTFIELD_EVENT_DELETE_BACKWARD , <nl> } TextFiledEventType ; <nl> <nl> typedef void ( cocos2d : : Object : : * SEL_TextFieldEvent ) ( cocos2d : : Object * , TextFiledEventType ) ; <nl> # define textfieldeventselector ( _SELECTOR ) ( SEL_TextFieldEvent ) ( & _SELECTOR ) <nl> <nl> - / / class UITextField : public UIWidget <nl> + / * * class UITextField : public UIWidget <nl> + * @ js NA <nl> + * @ lua NA <nl> + * / <nl> class UITextField : public UIWidget <nl> { <nl> public : <nl> class UITextField : public UIWidget <nl> bool getDeleteBackward ( ) ; <nl> void setDeleteBackward ( bool deleteBackward ) ; <nl> void addEventListener ( cocos2d : : Object * target , SEL_TextFieldEvent selecor ) ; <nl> + <nl> virtual void setAnchorPoint ( const cocos2d : : Point & pt ) ; <nl> virtual void setColor ( const cocos2d : : Color3B & color ) ; <nl> virtual void setOpacity ( int opacity ) ; <nl> + <nl> / * * <nl> * Returns the " class name " of widget . <nl> * / <nl> virtual const char * getDescription ( ) const ; <nl> - / * compatibel * / <nl> - / * * <nl> - * These methods will be removed <nl> - * / <nl> - void setMaxLengthEnable ( bool is ) { setMaxLengthEnabled ( is ) ; } ; <nl> - void setPasswordEnable ( bool is ) { setPasswordEnabled ( is ) ; } ; <nl> - / * * * * * * * * * * * * / <nl> + <nl> virtual const cocos2d : : Size & getContentSize ( ) const ; <nl> virtual cocos2d : : Node * getVirtualRenderer ( ) ; <nl> + void attachWithIME ( ) ; <nl> protected : <nl> / / event <nl> void attachWithIMEEvent ( ) ; <nl> class UITextField : public UIWidget <nl> void deleteBackwardEvent ( ) ; <nl> virtual void onSizeChanged ( ) ; <nl> void textfieldRendererScaleChangedWithSize ( ) ; <nl> + virtual UIWidget * createCloneInstance ( ) ; <nl> + virtual void copySpecialProperties ( UIWidget * model ) ; <nl> protected : <nl> UICCTextField * _textFieldRenderer ; <nl> - <nl> + <nl> float _touchWidth ; <nl> float _touchHeight ; <nl> bool _useTouchArea ; <nl> class UITextField : public UIWidget <nl> cocos2d : : Object * _eventListener ; <nl> SEL_TextFieldEvent _eventSelector ; <nl> <nl> + std : : string _passwordStyleText ; <nl> } ; <nl> <nl> } <nl> mmm a / cocos / gui / UIWidget . cpp <nl> ppp b / cocos / gui / UIWidget . cpp <nl> <nl> <nl> # include " gui / UIWidget . h " <nl> # include " gui / UILayer . h " <nl> - # include " gui / Layout . h " <nl> + # include " gui / UILayout . h " <nl> # include " gui / UIHelper . h " <nl> <nl> - using namespace cocos2d ; <nl> - <nl> namespace gui { <nl> <nl> # define DYNAMIC_CAST_CCBLENDPROTOCOL dynamic_cast < cocos2d : : BlendProtocol * > ( _renderer ) <nl> _touchEnabled ( false ) , <nl> _touchPassedEnabled ( false ) , <nl> _focus ( false ) , <nl> _widgetZOrder ( 0 ) , <nl> - _anchorPoint ( Point ( 0 . 5f , 0 . 5f ) ) , <nl> + _anchorPoint ( cocos2d : : Point ( 0 . 5f , 0 . 5f ) ) , <nl> _widgetParent ( NULL ) , <nl> _brightStyle ( BRIGHT_NONE ) , <nl> _updateEnabled ( false ) , <nl> _renderer ( NULL ) , <nl> - _touchStartPos ( Point : : ZERO ) , <nl> - _touchMovePos ( Point : : ZERO ) , <nl> - _touchEndPos ( Point : : ZERO ) , <nl> + _touchStartPos ( cocos2d : : Point : : ZERO ) , <nl> + _touchMovePos ( cocos2d : : Point : : ZERO ) , <nl> + _touchEndPos ( cocos2d : : Point : : ZERO ) , <nl> _touchEventListener ( NULL ) , <nl> _touchEventSelector ( NULL ) , <nl> _widgetTag ( - 1 ) , <nl> _name ( " default " ) , <nl> _widgetType ( WidgetTypeWidget ) , <nl> _actionTag ( 0 ) , <nl> - _size ( Size : : ZERO ) , <nl> - _customSize ( Size : : ZERO ) , <nl> - _layoutParameter ( NULL ) , <nl> + _size ( cocos2d : : Size : : ZERO ) , <nl> + _customSize ( cocos2d : : Size : : ZERO ) , <nl> + _layoutParameterDictionary ( NULL ) , <nl> _ignoreSize ( false ) , <nl> _children ( NULL ) , <nl> _affectByClipping ( false ) , <nl> _scheduler ( NULL ) , <nl> _sizeType ( SIZE_ABSOLUTE ) , <nl> - _sizePercent ( Point : : ZERO ) , <nl> + _sizePercent ( cocos2d : : Point : : ZERO ) , <nl> _positionType ( POSITION_ABSOLUTE ) , <nl> - _positionPercent ( Point : : ZERO ) , <nl> + _positionPercent ( cocos2d : : Point : : ZERO ) , <nl> _isRunning ( false ) <nl> { <nl> <nl> UIWidget : : ~ UIWidget ( ) <nl> { <nl> releaseResoures ( ) ; <nl> setParent ( NULL ) ; <nl> - CC_SAFE_RELEASE_NULL ( _layoutParameter ) ; <nl> + _layoutParameterDictionary - > removeAllObjects ( ) ; <nl> + CC_SAFE_RELEASE ( _layoutParameterDictionary ) ; <nl> CC_SAFE_RELEASE ( _scheduler ) ; <nl> } <nl> <nl> UIWidget * UIWidget : : create ( ) <nl> <nl> bool UIWidget : : init ( ) <nl> { <nl> - _children = Array : : create ( ) ; <nl> + _children = cocos2d : : Array : : create ( ) ; <nl> _children - > retain ( ) ; <nl> + _layoutParameterDictionary = cocos2d : : Dictionary : : create ( ) ; <nl> + CC_SAFE_RETAIN ( _layoutParameterDictionary ) ; <nl> initRenderer ( ) ; <nl> _renderer - > retain ( ) ; <nl> _renderer - > setZOrder ( _widgetZOrder ) ; <nl> - RGBAProtocol * renderRGBA = DYNAMIC_CAST_CCRGBAPROTOCOL ; <nl> + cocos2d : : RGBAProtocol * renderRGBA = DYNAMIC_CAST_CCRGBAPROTOCOL ; <nl> if ( renderRGBA ) <nl> { <nl> renderRGBA - > setCascadeColorEnabled ( true ) ; <nl> bool UIWidget : : init ( ) <nl> } <nl> setBright ( true ) ; <nl> ignoreContentAdaptWithSize ( true ) ; <nl> - _scheduler = Director : : getInstance ( ) - > getScheduler ( ) ; <nl> + _scheduler = cocos2d : : Director : : getInstance ( ) - > getScheduler ( ) ; <nl> CC_SAFE_RETAIN ( _scheduler ) ; <nl> return true ; <nl> } <nl> <nl> void UIWidget : : releaseResoures ( ) <nl> { <nl> - setUpdateEnabled ( false ) ; <nl> removeAllChildren ( ) ; <nl> _children - > release ( ) ; <nl> _renderer - > removeAllChildrenWithCleanup ( true ) ; <nl> bool UIWidget : : addChild ( UIWidget * child ) <nl> else <nl> { <nl> bool seekSucceed = false ; <nl> - ccArray * arrayChildren = _children - > data ; <nl> + cocos2d : : ccArray * arrayChildren = _children - > data ; <nl> for ( int i = childrenCount - 1 ; i > = 0 ; - - i ) <nl> { <nl> UIWidget * widget = ( UIWidget * ) ( arrayChildren - > arr [ i ] ) ; <nl> bool UIWidget : : removeChild ( UIWidget * child ) <nl> { <nl> child - > onExit ( ) ; <nl> } <nl> - child - > disableUpdate ( ) ; <nl> + child - > setUpdateEnabled ( false ) ; <nl> child - > setParent ( NULL ) ; <nl> _renderer - > removeChild ( child - > getRenderer ( ) ) ; <nl> _children - > removeObject ( child ) ; <nl> void UIWidget : : reorderChild ( UIWidget * child ) <nl> else <nl> { <nl> bool seekSucceed = false ; <nl> - ccArray * arrayChildren = _children - > data ; <nl> + cocos2d : : ccArray * arrayChildren = _children - > data ; <nl> for ( int i = childrenCount - 1 ; i > = 0 ; - - i ) <nl> { <nl> UIWidget * widget = ( UIWidget * ) ( arrayChildren - > arr [ i ] ) ; <nl> void UIWidget : : reorderChild ( UIWidget * child ) <nl> CC_SAFE_RELEASE ( child ) ; <nl> } <nl> <nl> - void UIWidget : : disableUpdate ( ) <nl> - { <nl> - if ( _scheduler ) <nl> - { <nl> - _scheduler - > unscheduleUpdateForTarget ( this ) ; <nl> - } <nl> - int childrenCount = _children - > data - > num ; <nl> - ccArray * arrayChildren = _children - > data ; <nl> - for ( int i = 0 ; i < childrenCount ; i + + ) <nl> - { <nl> - UIWidget * child = ( UIWidget * ) ( arrayChildren - > arr [ i ] ) ; <nl> - child - > disableUpdate ( ) ; <nl> - } <nl> - } <nl> - <nl> void UIWidget : : setEnabled ( bool enabled ) <nl> { <nl> _enabled = enabled ; <nl> void UIWidget : : setEnabled ( bool enabled ) <nl> } <nl> else <nl> { <nl> - dynamic_cast < RectClippingNode * > ( _renderer ) - > setEnabled ( enabled ) ; <nl> + dynamic_cast < UIRectClippingNode * > ( _renderer ) - > setEnabled ( enabled ) ; <nl> } <nl> - ccArray * arrayChildren = _children - > data ; <nl> + cocos2d : : ccArray * arrayChildren = _children - > data ; <nl> int childrenCount = arrayChildren - > num ; <nl> for ( int i = 0 ; i < childrenCount ; i + + ) <nl> { <nl> void UIWidget : : setEnabled ( bool enabled ) <nl> <nl> UIWidget * UIWidget : : getChildByName ( const char * name ) <nl> { <nl> - return CCUIHELPER - > seekWidgetByName ( this , name ) ; <nl> + return UIHelper : : seekWidgetByName ( this , name ) ; <nl> } <nl> <nl> UIWidget * UIWidget : : getChildByTag ( int tag ) <nl> { <nl> - return CCUIHELPER - > seekWidgetByTag ( this , tag ) ; <nl> + return UIHelper : : seekWidgetByTag ( this , tag ) ; <nl> } <nl> <nl> - Array * UIWidget : : getChildren ( ) <nl> + cocos2d : : Array * UIWidget : : getChildren ( ) <nl> { <nl> return _children ; <nl> } <nl> void UIWidget : : initRenderer ( ) <nl> _renderer = GUIRenderer : : create ( ) ; <nl> } <nl> <nl> - void UIWidget : : setSize ( const Size & size ) <nl> + void UIWidget : : setSize ( const cocos2d : : Size & size ) <nl> { <nl> _customSize = size ; <nl> if ( _ignoreSize ) <nl> void UIWidget : : setSize ( const Size & size ) <nl> } <nl> if ( _isRunning ) <nl> { <nl> - _sizePercent = ( _widgetParent = = NULL ) ? Point : : ZERO : Point ( _customSize . width / _widgetParent - > getSize ( ) . width , _customSize . height / _widgetParent - > getSize ( ) . height ) ; <nl> + _sizePercent = ( _widgetParent = = NULL ) ? cocos2d : : Point : : ZERO : cocos2d : : Point ( _customSize . width / _widgetParent - > getSize ( ) . width , _customSize . height / _widgetParent - > getSize ( ) . height ) ; <nl> } <nl> onSizeChanged ( ) ; <nl> } <nl> <nl> - void UIWidget : : setSizePercent ( const Point & percent ) <nl> + void UIWidget : : setSizePercent ( const cocos2d : : Point & percent ) <nl> { <nl> _sizePercent = percent ; <nl> if ( ! _isRunning ) <nl> { <nl> return ; <nl> } <nl> - Size cSize = ( _widgetParent = = NULL ) ? Size : : ZERO : Size ( _widgetParent - > getSize ( ) . width * percent . x , _widgetParent - > getSize ( ) . height * percent . y ) ; <nl> + cocos2d : : Size cSize = ( _widgetParent = = NULL ) ? cocos2d : : Size : : ZERO : cocos2d : : Size ( _widgetParent - > getSize ( ) . width * percent . x , _widgetParent - > getSize ( ) . height * percent . y ) ; <nl> if ( _ignoreSize ) <nl> { <nl> _size = getContentSize ( ) ; <nl> void UIWidget : : updateSizeAndPosition ( ) <nl> { <nl> _size = _customSize ; <nl> } <nl> - _sizePercent = ( _widgetParent = = NULL ) ? Point : : ZERO : Point ( _customSize . width / _widgetParent - > getSize ( ) . width , _customSize . height / _widgetParent - > getSize ( ) . height ) ; <nl> + _sizePercent = ( _widgetParent = = NULL ) ? cocos2d : : Point : : ZERO : cocos2d : : Point ( _customSize . width / _widgetParent - > getSize ( ) . width , _customSize . height / _widgetParent - > getSize ( ) . height ) ; <nl> break ; <nl> case SIZE_PERCENT : <nl> { <nl> - Size cSize = ( _widgetParent = = NULL ) ? Size : : ZERO : Size ( _widgetParent - > getSize ( ) . width * _sizePercent . x , _widgetParent - > getSize ( ) . height * _sizePercent . y ) ; <nl> + cocos2d : : Size cSize = ( _widgetParent = = NULL ) ? cocos2d : : Size : : ZERO : cocos2d : : Size ( _widgetParent - > getSize ( ) . width * _sizePercent . x , _widgetParent - > getSize ( ) . height * _sizePercent . y ) ; <nl> if ( _ignoreSize ) <nl> { <nl> _size = getContentSize ( ) ; <nl> void UIWidget : : updateSizeAndPosition ( ) <nl> break ; <nl> } <nl> onSizeChanged ( ) ; <nl> - Point absPos = getPosition ( ) ; <nl> + cocos2d : : Point absPos = getPosition ( ) ; <nl> switch ( _positionType ) <nl> { <nl> case POSITION_ABSOLUTE : <nl> - _positionPercent = ( _widgetParent = = NULL ) ? Point : : ZERO : Point ( absPos . x / _widgetParent - > getSize ( ) . width , absPos . y / _widgetParent - > getSize ( ) . height ) ; <nl> + _positionPercent = ( _widgetParent = = NULL ) ? cocos2d : : Point : : ZERO : cocos2d : : Point ( absPos . x / _widgetParent - > getSize ( ) . width , absPos . y / _widgetParent - > getSize ( ) . height ) ; <nl> break ; <nl> case POSITION_PERCENT : <nl> { <nl> - Size parentSize = _widgetParent - > getSize ( ) ; <nl> - absPos = Point ( parentSize . width * _positionPercent . x , parentSize . height * _positionPercent . y ) ; <nl> + cocos2d : : Size parentSize = _widgetParent - > getSize ( ) ; <nl> + absPos = cocos2d : : Point ( parentSize . width * _positionPercent . x , parentSize . height * _positionPercent . y ) ; <nl> } <nl> break ; <nl> default : <nl> void UIWidget : : ignoreContentAdaptWithSize ( bool ignore ) <nl> _ignoreSize = ignore ; <nl> if ( _ignoreSize ) <nl> { <nl> - Size s = getContentSize ( ) ; <nl> + cocos2d : : Size s = getContentSize ( ) ; <nl> _size = s ; <nl> } <nl> else <nl> bool UIWidget : : isIgnoreContentAdaptWithSize ( ) const <nl> return _ignoreSize ; <nl> } <nl> <nl> - const Size & UIWidget : : getSize ( ) const <nl> + const cocos2d : : Size & UIWidget : : getSize ( ) const <nl> { <nl> return _size ; <nl> } <nl> <nl> - const Point & UIWidget : : getSizePercent ( ) const <nl> + const cocos2d : : Point & UIWidget : : getSizePercent ( ) const <nl> { <nl> return _sizePercent ; <nl> } <nl> <nl> - Point UIWidget : : getWorldPosition ( ) <nl> + cocos2d : : Point UIWidget : : getWorldPosition ( ) <nl> { <nl> - return _renderer - > convertToWorldSpace ( Point : : ZERO ) ; <nl> + return _renderer - > convertToWorldSpace ( cocos2d : : Point : : ZERO ) ; <nl> } <nl> <nl> - Point UIWidget : : convertToWorldSpace ( const Point & pt ) <nl> + cocos2d : : Point UIWidget : : convertToWorldSpace ( const cocos2d : : Point & pt ) <nl> { <nl> return _renderer - > convertToWorldSpace ( pt ) ; <nl> } <nl> <nl> - Node * UIWidget : : getVirtualRenderer ( ) <nl> + cocos2d : : Node * UIWidget : : getVirtualRenderer ( ) <nl> { <nl> return _renderer ; <nl> } <nl> void UIWidget : : onSizeChanged ( ) <nl> <nl> } <nl> <nl> - const Size & UIWidget : : getContentSize ( ) const <nl> + const cocos2d : : Size & UIWidget : : getContentSize ( ) const <nl> { <nl> return _size ; <nl> } <nl> bool UIWidget : : isTouchEnabled ( ) const <nl> <nl> void UIWidget : : setUpdateEnabled ( bool enable ) <nl> { <nl> + if ( enable = = _updateEnabled ) <nl> + { <nl> + return ; <nl> + } <nl> _updateEnabled = enable ; <nl> if ( enable ) <nl> { <nl> void UIWidget : : didNotSelectSelf ( ) <nl> <nl> } <nl> <nl> - bool UIWidget : : onTouchBegan ( const Point & touchPoint ) <nl> + bool UIWidget : : onTouchBegan ( const cocos2d : : Point & touchPoint ) <nl> { <nl> setFocused ( true ) ; <nl> _touchStartPos . x = touchPoint . x ; <nl> bool UIWidget : : onTouchBegan ( const Point & touchPoint ) <nl> return _touchPassedEnabled ; <nl> } <nl> <nl> - void UIWidget : : onTouchMoved ( const Point & touchPoint ) <nl> + void UIWidget : : onTouchMoved ( const cocos2d : : Point & touchPoint ) <nl> { <nl> _touchMovePos . x = touchPoint . x ; <nl> _touchMovePos . y = touchPoint . y ; <nl> void UIWidget : : onTouchMoved ( const Point & touchPoint ) <nl> moveEvent ( ) ; <nl> } <nl> <nl> - void UIWidget : : onTouchEnded ( const Point & touchPoint ) <nl> + void UIWidget : : onTouchEnded ( const cocos2d : : Point & touchPoint ) <nl> { <nl> _touchEndPos . x = touchPoint . x ; <nl> _touchEndPos . y = touchPoint . y ; <nl> void UIWidget : : onTouchEnded ( const Point & touchPoint ) <nl> } <nl> } <nl> <nl> - void UIWidget : : onTouchCancelled ( const Point & touchPoint ) <nl> + void UIWidget : : onTouchCancelled ( const cocos2d : : Point & touchPoint ) <nl> { <nl> setFocused ( false ) ; <nl> cancelUpEvent ( ) ; <nl> } <nl> <nl> - void UIWidget : : onTouchLongClicked ( const Point & touchPoint ) <nl> + void UIWidget : : onTouchLongClicked ( const cocos2d : : Point & touchPoint ) <nl> { <nl> longClickEvent ( ) ; <nl> } <nl> void UIWidget : : longClickEvent ( ) <nl> <nl> } <nl> <nl> - void UIWidget : : addTouchEventListener ( Object * target , SEL_TouchEvent selector ) <nl> + void UIWidget : : addTouchEventListener ( cocos2d : : Object * target , SEL_TouchEvent selector ) <nl> { <nl> _touchEventListener = target ; <nl> _touchEventSelector = selector ; <nl> } <nl> <nl> - Node * UIWidget : : getRenderer ( ) <nl> + cocos2d : : Node * UIWidget : : getRenderer ( ) <nl> { <nl> return _renderer ; <nl> } <nl> <nl> - void UIWidget : : addRenderer ( Node * renderer , int zOrder ) <nl> + void UIWidget : : addRenderer ( cocos2d : : Node * renderer , int zOrder ) <nl> { <nl> _renderer - > addChild ( renderer , zOrder ) ; <nl> } <nl> <nl> - void UIWidget : : removeRenderer ( Node * renderer , bool cleanup ) <nl> + void UIWidget : : removeRenderer ( cocos2d : : Node * renderer , bool cleanup ) <nl> { <nl> _renderer - > removeChild ( renderer , cleanup ) ; <nl> } <nl> <nl> - bool UIWidget : : hitTest ( const Point & pt ) <nl> + bool UIWidget : : hitTest ( const cocos2d : : Point & pt ) <nl> { <nl> - Point nsp = _renderer - > convertToNodeSpace ( pt ) ; <nl> - Rect bb = Rect ( - _size . width * _anchorPoint . x , - _size . height * _anchorPoint . y , _size . width , _size . height ) ; <nl> + cocos2d : : Point nsp = _renderer - > convertToNodeSpace ( pt ) ; <nl> + cocos2d : : Rect bb = cocos2d : : Rect ( - _size . width * _anchorPoint . x , - _size . height * _anchorPoint . y , _size . width , _size . height ) ; <nl> if ( nsp . x > = bb . origin . x & & nsp . x < = bb . origin . x + bb . size . width & & nsp . y > = bb . origin . y & & nsp . y < = bb . origin . y + bb . size . height ) <nl> { <nl> return true ; <nl> bool UIWidget : : hitTest ( const Point & pt ) <nl> return false ; <nl> } <nl> <nl> - bool UIWidget : : clippingParentAreaContainPoint ( const Point & pt ) <nl> + bool UIWidget : : clippingParentAreaContainPoint ( const cocos2d : : Point & pt ) <nl> { <nl> _affectByClipping = false ; <nl> UIWidget * parent = getParent ( ) ; <nl> UIWidget * clippingParent = NULL ; <nl> while ( parent ) <nl> { <nl> - Layout * layoutParent = dynamic_cast < Layout * > ( parent ) ; <nl> + UILayout * layoutParent = dynamic_cast < UILayout * > ( parent ) ; <nl> if ( layoutParent ) <nl> { <nl> if ( layoutParent - > isClippingEnabled ( ) ) <nl> bool UIWidget : : clippingParentAreaContainPoint ( const Point & pt ) <nl> return true ; <nl> } <nl> <nl> - void UIWidget : : checkChildInfo ( int handleState , UIWidget * sender , const Point & touchPoint ) <nl> + void UIWidget : : checkChildInfo ( int handleState , UIWidget * sender , const cocos2d : : Point & touchPoint ) <nl> { <nl> if ( _widgetParent ) <nl> { <nl> void UIWidget : : checkChildInfo ( int handleState , UIWidget * sender , const Point & to <nl> } <nl> } <nl> <nl> - void UIWidget : : setPosition ( const Point & pos ) <nl> + void UIWidget : : setPosition ( const cocos2d : : Point & pos ) <nl> { <nl> if ( _isRunning ) <nl> { <nl> - _positionPercent = ( _widgetParent = = NULL ) ? Point : : ZERO : Point ( pos . x / _widgetParent - > getSize ( ) . width , pos . y / _widgetParent - > getSize ( ) . height ) ; <nl> + _positionPercent = ( _widgetParent = = NULL ) ? cocos2d : : Point : : ZERO : cocos2d : : Point ( pos . x / _widgetParent - > getSize ( ) . width , pos . y / _widgetParent - > getSize ( ) . height ) ; <nl> } <nl> _renderer - > setPosition ( pos ) ; <nl> } <nl> <nl> - void UIWidget : : setPositionPercent ( const Point & percent ) <nl> + void UIWidget : : setPositionPercent ( const cocos2d : : Point & percent ) <nl> { <nl> _positionPercent = percent ; <nl> if ( _isRunning ) <nl> { <nl> - Size parentSize = _widgetParent - > getSize ( ) ; <nl> - Point absPos = Point ( parentSize . width * _positionPercent . x , parentSize . height * _positionPercent . y ) ; <nl> + cocos2d : : Size parentSize = _widgetParent - > getSize ( ) ; <nl> + cocos2d : : Point absPos = cocos2d : : Point ( parentSize . width * _positionPercent . x , parentSize . height * _positionPercent . y ) ; <nl> _renderer - > setPosition ( absPos ) ; <nl> } <nl> } <nl> <nl> - void UIWidget : : setAnchorPoint ( const Point & pt ) <nl> + void UIWidget : : setAnchorPoint ( const cocos2d : : Point & pt ) <nl> { <nl> _anchorPoint = pt ; <nl> _renderer - > setAnchorPoint ( pt ) ; <nl> void UIWidget : : updateAnchorPoint ( ) <nl> setAnchorPoint ( _anchorPoint ) ; <nl> } <nl> <nl> - const Point & UIWidget : : getPosition ( ) <nl> + const cocos2d : : Point & UIWidget : : getPosition ( ) <nl> { <nl> return _renderer - > getPosition ( ) ; <nl> } <nl> <nl> - const Point & UIWidget : : getPositionPercent ( ) <nl> + const cocos2d : : Point & UIWidget : : getPositionPercent ( ) <nl> { <nl> return _positionPercent ; <nl> } <nl> PositionType UIWidget : : getPositionType ( ) const <nl> return _positionType ; <nl> } <nl> <nl> - const Point & UIWidget : : getAnchorPoint ( ) <nl> + const cocos2d : : Point & UIWidget : : getAnchorPoint ( ) <nl> { <nl> return _anchorPoint ; <nl> } <nl> bool UIWidget : : isEnabled ( ) const <nl> <nl> float UIWidget : : getLeftInParent ( ) <nl> { <nl> - float leftPos = 0 . 0f ; <nl> - switch ( _widgetType ) <nl> - { <nl> - case WidgetTypeWidget : <nl> - leftPos = getPosition ( ) . x - getAnchorPoint ( ) . x * _size . width ; <nl> - break ; <nl> - case WidgetTypeContainer : <nl> - leftPos = getPosition ( ) . x ; <nl> - break ; <nl> - default : <nl> - break ; <nl> - } <nl> - return leftPos ; <nl> + return getPosition ( ) . x - getAnchorPoint ( ) . x * _size . width ; ; <nl> } <nl> <nl> float UIWidget : : getBottomInParent ( ) <nl> { <nl> - float bottomPos = 0 . 0f ; <nl> - switch ( _widgetType ) <nl> - { <nl> - case WidgetTypeWidget : <nl> - bottomPos = getPosition ( ) . y - getAnchorPoint ( ) . y * _size . height ; <nl> - break ; <nl> - case WidgetTypeContainer : <nl> - bottomPos = getPosition ( ) . y ; <nl> - break ; <nl> - default : <nl> - break ; <nl> - } <nl> - return bottomPos ; <nl> + return getPosition ( ) . y - getAnchorPoint ( ) . y * _size . height ; ; <nl> } <nl> <nl> float UIWidget : : getRightInParent ( ) <nl> void UIWidget : : setParent ( UIWidget * parent ) <nl> _widgetParent = parent ; <nl> } <nl> <nl> - Action * UIWidget : : runAction ( Action * action ) <nl> + cocos2d : : Action * UIWidget : : runAction ( cocos2d : : Action * action ) <nl> { <nl> return _renderer - > runAction ( action ) ; <nl> } <nl> <nl> - void UIWidget : : setActionManager ( ActionManager * actionManager ) <nl> + void UIWidget : : setActionManager ( cocos2d : : ActionManager * actionManager ) <nl> { <nl> _renderer - > setActionManager ( actionManager ) ; <nl> } <nl> <nl> - ActionManager * UIWidget : : getActionManager ( ) <nl> + cocos2d : : ActionManager * UIWidget : : getActionManager ( ) <nl> { <nl> return _renderer - > getActionManager ( ) ; <nl> } <nl> void UIWidget : : stopAllActions ( ) <nl> _renderer - > stopAllActions ( ) ; <nl> } <nl> <nl> - void UIWidget : : stopAction ( Action * action ) <nl> + void UIWidget : : stopAction ( cocos2d : : Action * action ) <nl> { <nl> _renderer - > stopAction ( action ) ; <nl> } <nl> void UIWidget : : stopActionByTag ( int tag ) <nl> _renderer - > stopActionByTag ( tag ) ; <nl> } <nl> <nl> - Action * UIWidget : : getActionByTag ( int tag ) <nl> + cocos2d : : Action * UIWidget : : getActionByTag ( int tag ) <nl> { <nl> return _renderer - > getActionByTag ( tag ) ; <nl> } <nl> <nl> - void UIWidget : : setColor ( const Color3B & color ) <nl> + void UIWidget : : setColor ( const cocos2d : : Color3B & color ) <nl> { <nl> - RGBAProtocol * rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL ; <nl> + cocos2d : : RGBAProtocol * rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL ; <nl> if ( rgbap ) <nl> { <nl> rgbap - > setColor ( color ) ; <nl> } <nl> } <nl> <nl> - const Color3B & UIWidget : : getColor ( ) <nl> + const cocos2d : : Color3B & UIWidget : : getColor ( ) <nl> { <nl> - RGBAProtocol * rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL ; <nl> + cocos2d : : RGBAProtocol * rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL ; <nl> if ( rgbap ) <nl> { <nl> return rgbap - > getColor ( ) ; <nl> } <nl> - return Color3B : : WHITE ; <nl> + return cocos2d : : Color3B : : WHITE ; <nl> } <nl> <nl> void UIWidget : : setOpacity ( int opacity ) <nl> { <nl> - RGBAProtocol * rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL ; <nl> + cocos2d : : RGBAProtocol * rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL ; <nl> if ( rgbap ) <nl> { <nl> rgbap - > setOpacity ( opacity ) ; <nl> void UIWidget : : setOpacity ( int opacity ) <nl> <nl> int UIWidget : : getOpacity ( ) <nl> { <nl> - RGBAProtocol * rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL ; <nl> + cocos2d : : RGBAProtocol * rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL ; <nl> if ( rgbap ) <nl> { <nl> return rgbap - > getOpacity ( ) ; <nl> int UIWidget : : getOpacity ( ) <nl> <nl> bool UIWidget : : isCascadeOpacityEnabled ( ) <nl> { <nl> - RGBAProtocol * rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL ; <nl> + cocos2d : : RGBAProtocol * rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL ; <nl> if ( rgbap ) <nl> { <nl> return rgbap - > isCascadeOpacityEnabled ( ) ; <nl> bool UIWidget : : isCascadeOpacityEnabled ( ) <nl> <nl> void UIWidget : : setCascadeOpacityEnabled ( bool cascadeOpacityEnabled ) <nl> { <nl> - RGBAProtocol * rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL ; <nl> + cocos2d : : RGBAProtocol * rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL ; <nl> if ( rgbap ) <nl> { <nl> rgbap - > setCascadeOpacityEnabled ( cascadeOpacityEnabled ) ; <nl> void UIWidget : : setCascadeOpacityEnabled ( bool cascadeOpacityEnabled ) <nl> <nl> bool UIWidget : : isCascadeColorEnabled ( ) <nl> { <nl> - RGBAProtocol * rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL ; <nl> + cocos2d : : RGBAProtocol * rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL ; <nl> if ( rgbap ) <nl> { <nl> return rgbap - > isCascadeColorEnabled ( ) ; <nl> bool UIWidget : : isCascadeColorEnabled ( ) <nl> <nl> void UIWidget : : setCascadeColorEnabled ( bool cascadeColorEnabled ) <nl> { <nl> - RGBAProtocol * rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL ; <nl> + cocos2d : : RGBAProtocol * rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL ; <nl> if ( rgbap ) <nl> { <nl> rgbap - > setCascadeColorEnabled ( cascadeColorEnabled ) ; <nl> } <nl> } <nl> <nl> - void UIWidget : : setBlendFunc ( BlendFunc blendFunc ) <nl> + void UIWidget : : setBlendFunc ( cocos2d : : BlendFunc blendFunc ) <nl> { <nl> - BlendProtocol * blendNode = DYNAMIC_CAST_CCBLENDPROTOCOL ; <nl> + cocos2d : : BlendProtocol * blendNode = DYNAMIC_CAST_CCBLENDPROTOCOL ; <nl> if ( blendNode ) <nl> { <nl> blendNode - > setBlendFunc ( blendFunc ) ; <nl> } <nl> } <nl> <nl> - const Point & UIWidget : : getTouchStartPos ( ) <nl> + const cocos2d : : Point & UIWidget : : getTouchStartPos ( ) <nl> { <nl> return _touchStartPos ; <nl> } <nl> <nl> - const Point & UIWidget : : getTouchMovePos ( ) <nl> + const cocos2d : : Point & UIWidget : : getTouchMovePos ( ) <nl> { <nl> return _touchMovePos ; <nl> } <nl> <nl> - const Point & UIWidget : : getTouchEndPos ( ) <nl> + const cocos2d : : Point & UIWidget : : getTouchEndPos ( ) <nl> { <nl> return _touchEndPos ; <nl> } <nl> WidgetType UIWidget : : getWidgetType ( ) const <nl> return _widgetType ; <nl> } <nl> <nl> - void UIWidget : : setLayoutParameter ( LayoutParameter * parameter ) <nl> + void UIWidget : : setLayoutParameter ( UILayoutParameter * parameter ) <nl> { <nl> - if ( _layoutParameter ) <nl> - { <nl> - CC_SAFE_RELEASE_NULL ( _layoutParameter ) ; <nl> - } <nl> - _layoutParameter = parameter ; <nl> - CC_SAFE_RETAIN ( _layoutParameter ) ; <nl> + _layoutParameterDictionary - > setObject ( parameter , parameter - > getLayoutType ( ) ) ; <nl> } <nl> <nl> - LayoutParameter * UIWidget : : getLayoutParameter ( ) <nl> + UILayoutParameter * UIWidget : : getLayoutParameter ( LayoutParameterType type ) <nl> { <nl> - return _layoutParameter ; <nl> + return dynamic_cast < UILayoutParameter * > ( _layoutParameterDictionary - > objectForKey ( type ) ) ; <nl> } <nl> <nl> const char * UIWidget : : getDescription ( ) const <nl> const char * UIWidget : : getDescription ( ) const <nl> return " Widget " ; <nl> } <nl> <nl> + UIWidget * UIWidget : : clone ( ) <nl> + { <nl> + UIWidget * clonedWidget = createCloneInstance ( ) ; <nl> + clonedWidget - > copyProperties ( this ) ; <nl> + clonedWidget - > copyClonedWidgetChildren ( this ) ; <nl> + return clonedWidget ; <nl> + } <nl> + <nl> + UIWidget * UIWidget : : createCloneInstance ( ) <nl> + { <nl> + return UIWidget : : create ( ) ; <nl> + } <nl> + <nl> + void UIWidget : : copyClonedWidgetChildren ( UIWidget * model ) <nl> + { <nl> + cocos2d : : ccArray * arrayWidgetChildren = model - > getChildren ( ) - > data ; <nl> + int length = arrayWidgetChildren - > num ; <nl> + for ( int i = 0 ; i < length ; i + + ) <nl> + { <nl> + UIWidget * child = ( UIWidget * ) ( arrayWidgetChildren - > arr [ i ] ) ; <nl> + addChild ( child - > clone ( ) ) ; <nl> + } <nl> + } <nl> + <nl> + void UIWidget : : copySpecialProperties ( UIWidget * model ) <nl> + { <nl> + <nl> + } <nl> + <nl> + void UIWidget : : copyProperties ( UIWidget * widget ) <nl> + { <nl> + setEnabled ( widget - > isEnabled ( ) ) ; <nl> + setVisible ( widget - > isVisible ( ) ) ; <nl> + setBright ( widget - > isBright ( ) ) ; <nl> + setTouchEnabled ( widget - > isTouchEnabled ( ) ) ; <nl> + _touchPassedEnabled = false ; <nl> + setZOrder ( widget - > getZOrder ( ) ) ; <nl> + setUpdateEnabled ( widget - > isUpdateEnabled ( ) ) ; <nl> + setTag ( widget - > getTag ( ) ) ; <nl> + setName ( widget - > getName ( ) ) ; <nl> + setActionTag ( widget - > getActionTag ( ) ) ; <nl> + _ignoreSize = widget - > _ignoreSize ; <nl> + _size = widget - > _size ; <nl> + _customSize = widget - > _customSize ; <nl> + copySpecialProperties ( widget ) ; <nl> + _sizeType = widget - > getSizeType ( ) ; <nl> + _sizePercent = widget - > _sizePercent ; <nl> + _positionType = widget - > _positionType ; <nl> + _positionPercent = widget - > _positionPercent ; <nl> + setPosition ( widget - > getPosition ( ) ) ; <nl> + setAnchorPoint ( widget - > getAnchorPoint ( ) ) ; <nl> + setScaleX ( widget - > getScaleX ( ) ) ; <nl> + setScaleY ( widget - > getScaleY ( ) ) ; <nl> + setRotation ( widget - > getRotation ( ) ) ; <nl> + setRotationX ( widget - > getRotationX ( ) ) ; <nl> + setRotationY ( widget - > getRotationY ( ) ) ; <nl> + setFlipX ( widget - > isFlipX ( ) ) ; <nl> + setFlipY ( widget - > isFlipY ( ) ) ; <nl> + setColor ( widget - > getColor ( ) ) ; <nl> + setOpacity ( widget - > getOpacity ( ) ) ; <nl> + setCascadeOpacityEnabled ( widget - > isCascadeOpacityEnabled ( ) ) ; <nl> + setCascadeColorEnabled ( widget - > isCascadeColorEnabled ( ) ) ; <nl> + onSizeChanged ( ) ; <nl> + } <nl> + <nl> / * temp action * / <nl> void UIWidget : : setActionTag ( int tag ) <nl> { <nl> void GUIRenderer : : visit ( ) <nl> { <nl> return ; <nl> } <nl> - NodeRGBA : : visit ( ) ; <nl> + cocos2d : : NodeRGBA : : visit ( ) ; <nl> } <nl> - <nl> + <nl> } <nl> mmm a / cocos / gui / UIWidget . h <nl> ppp b / cocos / gui / UIWidget . h <nl> <nl> <nl> # include " cocos2d . h " <nl> # include " gui / UILayoutDefine . h " <nl> - # include " gui / LayoutParameter . h " <nl> - namespace gui { <nl> + # include " gui / UILayoutParameter . h " <nl> <nl> + namespace gui { <nl> <nl> typedef enum <nl> { <nl> typedef enum <nl> <nl> typedef void ( cocos2d : : Object : : * SEL_TouchEvent ) ( cocos2d : : Object * , TouchEventType ) ; <nl> # define toucheventselector ( _SELECTOR ) ( SEL_TouchEvent ) ( & _SELECTOR ) <nl> - <nl> - / / class UILayer ; <nl> - / * temp action * / <nl> - class UIActionNode ; <nl> - <nl> + / * * <nl> + * @ js NA <nl> + * @ lua NA <nl> + * / <nl> class UIWidget : public cocos2d : : Object <nl> { <nl> public : <nl> class UIWidget : public cocos2d : : Object <nl> * Removes all children from the container , and do a cleanup to all running actions depending on the cleanup parameter . <nl> * / <nl> virtual void removeAllChildren ( ) ; <nl> - <nl> - / * * <nl> - * Unschedules the " update " method . <nl> - * / <nl> - void disableUpdate ( ) ; <nl> - <nl> + <nl> / * * <nl> * Reorders a child according to a new z value . <nl> * <nl> class UIWidget : public cocos2d : : Object <nl> / * * <nl> * Gets the renderer of widget <nl> * <nl> - * renderer is a CCNode , it ' s for drawing <nl> + * renderer is a Node , it ' s for drawing <nl> * <nl> - * @ return a CCNode object <nl> + * @ return a Node object <nl> * / <nl> cocos2d : : Node * getRenderer ( ) ; <nl> <nl> / * * <nl> - * Add a CCNode for rendering . <nl> + * Add a Node for rendering . <nl> * <nl> - * renderer is a CCNode , it ' s for drawing <nl> + * renderer is a Node , it ' s for drawing <nl> * <nl> * @ param renderer A render node <nl> * <nl> - * @ param zOrder Z order for drawing priority . Please refer to CCNode : : setZOrder ( int ) <nl> + * @ param zOrder Z order for drawing priority . Please refer to Node : : setZOrder ( int ) <nl> * / <nl> void addRenderer ( cocos2d : : Node * renderer , int zOrder ) ; <nl> <nl> / * * <nl> - * Remove a CCNode from widget . <nl> + * Remove a Node from widget . <nl> * <nl> - * renderer is a CCNode , it ' s for drawing <nl> + * renderer is a Node , it ' s for drawing <nl> * <nl> * @ param renderer A render node which needs to be removed <nl> * <nl> class UIWidget : public cocos2d : : Object <nl> / * * <nl> * Changes the position ( x , y ) of the widget in OpenGL coordinates <nl> * <nl> - * Usually we use ccp ( x , y ) to compose Point object . <nl> + * Usually we use p ( x , y ) to compose Point object . <nl> * The original point ( 0 , 0 ) is at the left - bottom corner of screen . <nl> * <nl> * @ param position The position ( x , y ) of the widget in OpenGL coordinates <nl> class UIWidget : public cocos2d : : Object <nl> / * * <nl> * Changes the position ( x , y ) of the widget in OpenGL coordinates <nl> * <nl> - * Usually we use ccp ( x , y ) to compose Point object . <nl> + * Usually we use p ( x , y ) to compose Point object . <nl> * The original point ( 0 , 0 ) is at the left - bottom corner of screen . <nl> * <nl> * @ param percent The percent ( x , y ) of the widget in OpenGL coordinates <nl> class UIWidget : public cocos2d : : Object <nl> * @ see LayoutParameter <nl> * <nl> * @ param LayoutParameter pointer <nl> + * <nl> + * @ param type Relative or Linear <nl> * / <nl> - void setLayoutParameter ( LayoutParameter * parameter ) ; <nl> + void setLayoutParameter ( UILayoutParameter * parameter ) ; <nl> <nl> / * * <nl> * Gets LayoutParameter of widget . <nl> * <nl> * @ see LayoutParameter <nl> + * <nl> + * @ param type Relative or Linear <nl> + * <nl> + * @ return LayoutParameter <nl> * / <nl> - LayoutParameter * getLayoutParameter ( ) ; <nl> + UILayoutParameter * getLayoutParameter ( LayoutParameterType type ) ; <nl> <nl> / * * <nl> * Ignore the widget size <nl> class UIWidget : public cocos2d : : Object <nl> * <nl> * For example , a button ' s Virtual Renderer is it ' s texture renderer . <nl> * <nl> - * @ return CCNode pointer . <nl> + * @ return Node pointer . <nl> * / <nl> virtual cocos2d : : Node * getVirtualRenderer ( ) ; <nl> <nl> class UIWidget : public cocos2d : : Object <nl> * / <nl> virtual const cocos2d : : Size & getContentSize ( ) const ; <nl> <nl> - virtual void onEnter ( ) ; <nl> - virtual void onExit ( ) ; <nl> - <nl> / * * <nl> * Returns the " class name " of widget . <nl> * / <nl> virtual const char * getDescription ( ) const ; <nl> <nl> + UIWidget * clone ( ) ; <nl> + <nl> + virtual void onEnter ( ) ; <nl> + virtual void onExit ( ) ; <nl> / * temp action * / <nl> void setActionTag ( int tag ) ; <nl> int getActionTag ( ) ; <nl> class UIWidget : public cocos2d : : Object <nl> * / <nl> virtual void releaseResoures ( ) ; <nl> void updateSizeAndPosition ( ) ; <nl> + void copyProperties ( UIWidget * model ) ; <nl> + virtual UIWidget * createCloneInstance ( ) ; <nl> + virtual void copySpecialProperties ( UIWidget * model ) ; <nl> + virtual void copyClonedWidgetChildren ( UIWidget * model ) ; <nl> protected : <nl> bool _enabled ; / / / < Highest control of widget <nl> bool _visible ; / / / < is this widget visible <nl> class UIWidget : public cocos2d : : Object <nl> cocos2d : : Point _touchMovePos ; / / / < touch moved point <nl> cocos2d : : Point _touchEndPos ; / / / < touch ended point <nl> <nl> - cocos2d : : Object * _touchEventListener ; <nl> + Object * _touchEventListener ; <nl> SEL_TouchEvent _touchEventSelector ; <nl> <nl> <nl> class UIWidget : public cocos2d : : Object <nl> int _actionTag ; <nl> cocos2d : : Size _size ; <nl> cocos2d : : Size _customSize ; <nl> - LayoutParameter * _layoutParameter ; <nl> + cocos2d : : Dictionary * _layoutParameterDictionary ; <nl> bool _ignoreSize ; <nl> cocos2d : : Array * _children ; <nl> bool _affectByClipping ; <nl> class UIWidget : public cocos2d : : Object <nl> cocos2d : : Point _positionPercent ; <nl> bool _isRunning ; <nl> } ; <nl> - <nl> + / * * <nl> + * @ js NA <nl> + * @ lua NA <nl> + * / <nl> class GUIRenderer : public cocos2d : : NodeRGBA <nl> { <nl> public : <nl> class GUIRenderer : public cocos2d : : NodeRGBA <nl> } ; <nl> <nl> } <nl> - <nl> # endif / * defined ( __UIWidget__ ) * / <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / CocosGUIScene . cpp <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / CocosGUIScene . cpp <nl> CocosGUITestScene : : ~ CocosGUITestScene ( ) <nl> { <nl> cocostudio : : SceneReader : : getInstance ( ) - > purgeSceneReader ( ) ; <nl> cocostudio : : ActionManagerEx : : purgeActionManager ( ) ; <nl> - gui : : UIHelper : : purgeUIHelper ( ) ; <nl> } <nl> <nl> void CocosGUITestScene : : runThisTest ( ) <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIDragPanelTest / UIDragPanelTest . cpp <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIDragPanelTest / UIDragPanelTest . cpp <nl> bool UIDragPanelTest : : init ( ) <nl> alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 925 ) ) ; <nl> m_pUiLayer - > addWidget ( alert ) ; <nl> <nl> - Layout * background = dynamic_cast < Layout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> - <nl> - / / Create the dragpanel <nl> - UIDragPanel * dragPanel = UIDragPanel : : create ( ) ; <nl> - dragPanel - > setTouchEnabled ( true ) ; <nl> - dragPanel - > setBackGroundImageScale9Enabled ( true ) ; <nl> - dragPanel - > setBackGroundImage ( " cocosgui / scrollviewbg . png " ) ; <nl> - dragPanel - > setSize ( Size ( 210 , 122 . 5 ) ) ; <nl> - Size backgroundSize = background - > getContentSize ( ) ; <nl> - dragPanel - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 + <nl> - ( backgroundSize . width - dragPanel - > getSize ( ) . width ) / 2 , <nl> - ( widgetSize . height - backgroundSize . height ) / 2 + <nl> - ( backgroundSize . height - dragPanel - > getSize ( ) . height ) / 2 ) ) ; <nl> - dragPanel - > addEventListener ( this , dragpaneleventselector ( UIDragPanelTest : : dragPanelEvent ) ) ; <nl> - <nl> - UIImageView * imageView = UIImageView : : create ( ) ; <nl> - imageView - > setTouchEnabled ( true ) ; <nl> - imageView - > loadTexture ( " cocosgui / b11 . png " ) ; <nl> - dragPanel - > addChild ( imageView ) ; <nl> - <nl> - dragPanel - > setInnerContainerSize ( imageView - > getContentSize ( ) ) ; <nl> - Size innerSize = dragPanel - > getInnerContainerSize ( ) ; <nl> - imageView - > setPosition ( Point ( innerSize . width / 2 , innerSize . height / 2 ) ) ; <nl> - <nl> - m_pUiLayer - > addWidget ( dragPanel ) ; <nl> + UIScrollView * sc = UIScrollView : : create ( ) ; <nl> + sc - > setBackGroundColor ( Color3B : : GREEN ) ; <nl> + sc - > setBackGroundColorType ( LAYOUT_COLOR_SOLID ) ; <nl> + sc - > setDirection ( SCROLLVIEW_DIR_BOTH ) ; <nl> + sc - > setInnerContainerSize ( Size ( 480 , 320 ) ) ; <nl> + sc - > setSize ( Size ( 100 , 100 ) ) ; <nl> + sc - > setPosition ( Point ( 100 , 100 ) ) ; <nl> + sc - > scrollToPercentBothDirection ( Point ( 50 , 50 ) , 1 , true ) ; <nl> + UIImageView * iv = UIImageView : : create ( ) ; <nl> + iv - > loadTexture ( " cocosgui / Hello . png " ) ; <nl> + iv - > setPosition ( Point ( 240 , 160 ) ) ; <nl> + sc - > addChild ( iv ) ; <nl> + m_pUiLayer - > addWidget ( sc ) ; <nl> <nl> return true ; <nl> } <nl> return false ; <nl> } <nl> <nl> - void UIDragPanelTest : : dragPanelEvent ( Object * pSender , DragPanelEventType type ) <nl> - { <nl> - switch ( type ) <nl> - { <nl> - case DRAGPANEL_EVENT_BERTH_LEFTBOTTOM : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Berth To Left Bottom " ) - > getCString ( ) ) ; <nl> - break ; <nl> - <nl> - case DRAGPANEL_EVENT_BERTH_LFETTOP : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Berth To Left Top " ) - > getCString ( ) ) ; <nl> - break ; <nl> - <nl> - case DRAGPANEL_EVENT_BERTH_RIGHTBOTTOM : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Berth To Right Bottom " ) - > getCString ( ) ) ; <nl> - break ; <nl> - <nl> - case DRAGPANEL_EVENT_BERTH_RIGHTTOP : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Berth To Right Top " ) - > getCString ( ) ) ; <nl> - break ; <nl> - <nl> - case DRAGPANEL_EVENT_BERTH_LEFT : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Berth To Left " ) - > getCString ( ) ) ; <nl> - break ; <nl> - <nl> - case DRAGPANEL_EVENT_BERTH_TOP : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Berth To Top " ) - > getCString ( ) ) ; <nl> - break ; <nl> - <nl> - case DRAGPANEL_EVENT_BERTH_RIGHT : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Berth To Right " ) - > getCString ( ) ) ; <nl> - break ; <nl> - <nl> - case DRAGPANEL_EVENT_BERTH_BOTTOM : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Berth To Bottom " ) - > getCString ( ) ) ; <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - } <nl> - <nl> / / UIDragPanelTest_Bounce <nl> UIDragPanelTest_Bounce : : UIDragPanelTest_Bounce ( ) <nl> : m_pDisplayValueLabel ( NULL ) <nl> bool UIDragPanelTest_Bounce : : init ( ) <nl> alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 925 ) ) ; <nl> m_pUiLayer - > addWidget ( alert ) ; <nl> <nl> - Layout * background = dynamic_cast < Layout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> - <nl> - / / Create the dragpanel <nl> - UIDragPanel * dragPanel = UIDragPanel : : create ( ) ; <nl> - dragPanel - > setTouchEnabled ( true ) ; <nl> - dragPanel - > setBounceEnable ( true ) ; <nl> - dragPanel - > setBackGroundImageScale9Enabled ( true ) ; <nl> - dragPanel - > setBackGroundImage ( " cocosgui / green_edit . png " ) ; <nl> - dragPanel - > setSize ( Size ( 210 , 122 . 5 ) ) ; <nl> - Size backgroundSize = background - > getContentSize ( ) ; <nl> - dragPanel - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 + <nl> - ( backgroundSize . width - dragPanel - > getSize ( ) . width ) / 2 , <nl> - ( widgetSize . height - backgroundSize . height ) / 2 + <nl> - ( backgroundSize . height - dragPanel - > getSize ( ) . height ) / 2 ) ) ; <nl> - dragPanel - > addEventListener ( this , dragpaneleventselector ( UIDragPanelTest_Bounce : : dragPanelEvent ) ) ; <nl> - <nl> - UIImageView * imageView = UIImageView : : create ( ) ; <nl> - imageView - > setTouchEnabled ( true ) ; <nl> - imageView - > loadTexture ( " cocosgui / b11 . png " ) ; <nl> - dragPanel - > addChild ( imageView ) ; <nl> - <nl> - dragPanel - > setInnerContainerSize ( imageView - > getContentSize ( ) ) ; <nl> - Size innerSize = dragPanel - > getInnerContainerSize ( ) ; <nl> - imageView - > setPosition ( Point ( innerSize . width / 2 , innerSize . height / 2 ) ) ; <nl> - <nl> - m_pUiLayer - > addWidget ( dragPanel ) ; <nl> - <nl> + UIScrollView * sc = UIScrollView : : create ( ) ; <nl> + sc - > setBackGroundColor ( Color3B : : GREEN ) ; <nl> + sc - > setBackGroundColorType ( LAYOUT_COLOR_SOLID ) ; <nl> + sc - > setBounceEnabled ( true ) ; <nl> + sc - > setDirection ( SCROLLVIEW_DIR_BOTH ) ; <nl> + sc - > setInnerContainerSize ( Size ( 480 , 320 ) ) ; <nl> + sc - > setSize ( Size ( 100 , 100 ) ) ; <nl> + sc - > setPosition ( Point ( 100 , 100 ) ) ; <nl> + sc - > scrollToPercentBothDirection ( Point ( 50 , 50 ) , 1 , true ) ; <nl> + UIImageView * iv = UIImageView : : create ( ) ; <nl> + iv - > loadTexture ( " cocosgui / Hello . png " ) ; <nl> + iv - > setPosition ( Point ( 240 , 160 ) ) ; <nl> + sc - > addChild ( iv ) ; <nl> + m_pUiLayer - > addWidget ( sc ) ; <nl> return true ; <nl> } <nl> <nl> return false ; <nl> } <nl> <nl> - void UIDragPanelTest_Bounce : : dragPanelEvent ( Object * pSender , DragPanelEventType type ) <nl> - { <nl> - switch ( type ) <nl> - { <nl> - case DRAGPANEL_EVENT_BOUNCE_LEFTBOTTOM : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Bounce To Left Bottom " ) - > getCString ( ) ) ; <nl> - break ; <nl> - <nl> - case DRAGPANEL_EVENT_BOUNCE_LEFTTOP : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Bounce To Left Top " ) - > getCString ( ) ) ; <nl> - break ; <nl> - <nl> - case DRAGPANEL_EVENT_BOUNCE_RIGHTBOTTOM : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Bounce To Right Bottom " ) - > getCString ( ) ) ; <nl> - break ; <nl> - <nl> - case DRAGPANEL_EVENT_BOUNCE_RIGHTTOP : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Bounce To Right Top " ) - > getCString ( ) ) ; <nl> - break ; <nl> - <nl> - case DRAGPANEL_EVENT_BOUNCE_LEFT : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Bounce To Left " ) - > getCString ( ) ) ; <nl> - break ; <nl> - <nl> - case DRAGPANEL_EVENT_BOUNCE_TOP : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Bounce To Top " ) - > getCString ( ) ) ; <nl> - break ; <nl> - <nl> - case DRAGPANEL_EVENT_BOUNCE_RIGHT : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Bounce To Right " ) - > getCString ( ) ) ; <nl> - break ; <nl> - <nl> - case DRAGPANEL_EVENT_BOUNCE_BOTTOM : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Bounce To Bottom " ) - > getCString ( ) ) ; <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - } <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIDragPanelTest / UIDragPanelTest . h <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIDragPanelTest / UIDragPanelTest . h <nl> class UIDragPanelTest : public UIScene <nl> UIDragPanelTest ( ) ; <nl> ~ UIDragPanelTest ( ) ; <nl> bool init ( ) ; <nl> - void dragPanelEvent ( Object * pSender , DragPanelEventType type ) ; <nl> <nl> protected : <nl> UI_SCENE_CREATE_FUNC ( UIDragPanelTest ) <nl> class UIDragPanelTest_Bounce : public UIScene <nl> UIDragPanelTest_Bounce ( ) ; <nl> ~ UIDragPanelTest_Bounce ( ) ; <nl> bool init ( ) ; <nl> - void dragPanelEvent ( Object * pSender , DragPanelEventType type ) ; <nl> <nl> protected : <nl> UI_SCENE_CREATE_FUNC ( UIDragPanelTest_Bounce ) <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIListViewTest / UIListViewTest . cpp <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIListViewTest / UIListViewTest . cpp <nl> bool UIListViewTest_Vertical : : init ( ) <nl> alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 925 ) ) ; <nl> m_pUiLayer - > addWidget ( alert ) ; <nl> <nl> - Layout * background = dynamic_cast < Layout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> <nl> - / / Create the list view <nl> - m_nCount = 0 ; <nl> - m_array = CCArray : : create ( ) ; <nl> - m_array - > retain ( ) ; <nl> - for ( int i = 0 ; i < 20 ; + + i ) <nl> - { <nl> - String * ccstr = String : : createWithFormat ( " object_ % d " , i ) ; <nl> - m_array - > addObject ( ccstr ) ; <nl> - } <nl> + UIListView * lv = UIListView : : create ( ) ; <nl> + UIButton * model = UIButton : : create ( ) ; <nl> + model - > loadTextures ( " cocosgui / animationbuttonnormal . png " , " cocosgui / animationbuttonpressed . png " , " " ) ; <nl> + lv - > setItemModel ( model ) ; <nl> <nl> - UIListView * listView = UIListView : : create ( ) ; <nl> - listView - > setTouchEnabled ( true ) ; <nl> - listView - > setBackGroundImageScale9Enabled ( true ) ; <nl> - listView - > setBackGroundImage ( " cocosgui / green_edit . png " ) ; <nl> - listView - > setSize ( Size ( 240 , 130 ) ) ; <nl> - Size backgroundSize = background - > getContentSize ( ) ; <nl> - listView - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 + <nl> - ( backgroundSize . width - listView - > getSize ( ) . width ) / 2 , <nl> - ( widgetSize . height - backgroundSize . height ) / 2 + <nl> - ( backgroundSize . height - listView - > getSize ( ) . height ) / 2 ) ) ; <nl> - <nl> - float listWidth = listView - > getSize ( ) . width ; <nl> - float listHeight = listView - > getSize ( ) . height ; <nl> - <nl> - for ( int i = 0 ; i < 5 ; + + i ) <nl> + for ( int i = 0 ; i < 20 ; i + + ) <nl> { <nl> - UIButton * textButton = UIButton : : create ( ) ; <nl> - textButton - > setName ( " TextButton " ) ; <nl> - textButton - > setTouchEnabled ( true ) ; <nl> - textButton - > loadTextures ( " cocosgui / backtotoppressed . png " , " cocosgui / backtotopnormal . png " , " " ) ; <nl> - <nl> - Layout * layout = Layout : : create ( ) ; <nl> - layout - > setName ( String : : createWithFormat ( " panel_ % i " , i ) - > getCString ( ) ) ; <nl> - layout - > setSize ( Size ( textButton - > getSize ( ) . width , textButton - > getSize ( ) . height ) ) ; <nl> - textButton - > setPosition ( Point ( layout - > getSize ( ) . width / 2 , layout - > getSize ( ) . height / 2 ) ) ; <nl> - layout - > addChild ( textButton ) ; <nl> - <nl> - Size panel_size = layout - > getSize ( ) ; <nl> - layout - > setPosition ( Point ( ( listWidth - panel_size . width ) / 2 , <nl> - ( listHeight - ( panel_size . height + panel_size . height * 0 . 25 ) ) - i * ( panel_size . height + panel_size . height * 0 . 25 ) ) ) ; <nl> - <nl> - listView - > addChild ( layout ) ; <nl> + lv - > pushBackDefaultItem ( ) ; <nl> } <nl> - listView - > addEventListenter ( this , listvieweventselector ( UIListViewTest_Vertical : : listViewEvent ) ) ; <nl> - listView - > initChildWithDataLength ( m_array - > count ( ) ) ; <nl> - m_pUiLayer - > addWidget ( listView ) ; <nl> + lv - > setItemsMargin ( 10 ) ; <nl> + lv - > setGravity ( LISTVIEW_GRAVITY_CENTER_HORIZONTAL ) ; <nl> + lv - > setSize ( Size ( 100 , 100 ) ) ; <nl> + lv - > setBackGroundColorType ( LAYOUT_COLOR_SOLID ) ; <nl> + lv - > setBackGroundColor ( Color3B : : GREEN ) ; <nl> + lv - > setPosition ( Point ( 100 , 100 ) ) ; <nl> + m_pUiLayer - > addWidget ( lv ) ; <nl> <nl> return true ; <nl> } <nl> bool UIListViewTest_Vertical : : init ( ) <nl> return false ; <nl> } <nl> <nl> - void UIListViewTest_Vertical : : listViewEvent ( Object * pSender , ListViewEventType type ) <nl> - { <nl> - switch ( type ) <nl> - { <nl> - case LISTVIEW_EVENT_INIT_CHILD : <nl> - { <nl> - String * ccstr = static_cast < String * > ( m_array - > getObjectAtIndex ( m_nCount ) ) ; <nl> - UIListView * list = dynamic_cast < UIListView * > ( pSender ) ; <nl> - <nl> - Layout * layout = dynamic_cast < Layout * > ( list - > getUpdateChild ( ) ) ; <nl> - UIButton * textButton = dynamic_cast < UIButton * > ( layout - > getChildByName ( " TextButton " ) ) ; <nl> - textButton - > setTitleText ( ccstr - > getCString ( ) ) ; <nl> - <nl> - m_nCount + + ; <nl> - } <nl> - break ; <nl> - <nl> - case LISTVIEW_EVENT_UPDATE_CHILD : <nl> - { <nl> - UIListView * list = dynamic_cast < UIListView * > ( pSender ) ; <nl> - int index = list - > getUpdateDataIndex ( ) ; <nl> - <nl> - if ( index < 0 | | index > = list - > getDataLength ( ) ) <nl> - { <nl> - list - > setUpdateSuccess ( false ) ; <nl> - } <nl> - <nl> - String * ccstr = static_cast < String * > ( m_array - > getObjectAtIndex ( index ) ) ; <nl> - Layout * layout = dynamic_cast < Layout * > ( list - > getUpdateChild ( ) ) ; <nl> - UIButton * textButton = dynamic_cast < UIButton * > ( layout - > getChildByName ( " TextButton " ) ) ; <nl> - textButton - > setTitleText ( ccstr - > getCString ( ) ) ; <nl> - list - > setUpdateSuccess ( true ) ; <nl> - } <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - } <nl> - <nl> / / UIListViewTest_Horizontal <nl> <nl> UIListViewTest_Horizontal : : UIListViewTest_Horizontal ( ) <nl> bool UIListViewTest_Horizontal : : init ( ) <nl> alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 925 ) ) ; <nl> m_pUiLayer - > addWidget ( alert ) ; <nl> <nl> - Layout * background = dynamic_cast < Layout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> - <nl> - / / Create the list view <nl> - m_nCount = 0 ; <nl> - m_array = CCArray : : create ( ) ; <nl> - m_array - > retain ( ) ; <nl> - for ( int i = 0 ; i < 20 ; + + i ) <nl> - { <nl> - String * ccstr = String : : createWithFormat ( " object_ % d " , i ) ; <nl> - m_array - > addObject ( ccstr ) ; <nl> - } <nl> - <nl> - UIListView * listView = UIListView : : create ( ) ; <nl> - listView - > setDirection ( LISTVIEW_DIR_HORIZONTAL ) ; <nl> - listView - > setTouchEnabled ( true ) ; <nl> - listView - > setBackGroundImageScale9Enabled ( true ) ; <nl> - listView - > setBackGroundImage ( " cocosgui / green_edit . png " ) ; <nl> - listView - > setSize ( Size ( 240 , 130 ) ) ; <nl> - Size backgroundSize = background - > getContentSize ( ) ; <nl> - listView - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 + <nl> - ( backgroundSize . width - listView - > getSize ( ) . width ) / 2 , <nl> - ( widgetSize . height - backgroundSize . height ) / 2 + <nl> - ( backgroundSize . height - listView - > getSize ( ) . height ) / 2 ) ) ; <nl> - <nl> - float listHeight = listView - > getSize ( ) . height ; <nl> + <nl> + UIListView * lv = UIListView : : create ( ) ; <nl> + lv - > setDirection ( SCROLLVIEW_DIR_HORIZONTAL ) ; <nl> + UIButton * model = UIButton : : create ( ) ; <nl> + model - > loadTextures ( " cocosgui / animationbuttonnormal . png " , " cocosgui / animationbuttonpressed . png " , " " ) ; <nl> + lv - > setItemModel ( model ) ; <nl> <nl> - for ( int i = 0 ; i < 3 ; + + i ) <nl> + for ( int i = 0 ; i < 20 ; i + + ) <nl> { <nl> - UIButton * textButton = UIButton : : create ( ) ; <nl> - textButton - > setName ( " TextButton " ) ; <nl> - textButton - > setTouchEnabled ( true ) ; <nl> - textButton - > loadTextures ( " cocosgui / backtotoppressed . png " , " cocosgui / backtotopnormal . png " , " " ) ; <nl> - <nl> - Layout * layout = Layout : : create ( ) ; <nl> - layout - > setName ( String : : createWithFormat ( " panel_ % i " , i ) - > getCString ( ) ) ; <nl> - layout - > setSize ( Size ( textButton - > getSize ( ) . width , textButton - > getSize ( ) . height ) ) ; <nl> - textButton - > setPosition ( Point ( layout - > getSize ( ) . width / 2 , layout - > getSize ( ) . height / 2 ) ) ; <nl> - layout - > addChild ( textButton ) ; <nl> - <nl> - Size layout_size = layout - > getSize ( ) ; <nl> - layout - > setPosition ( Point ( 0 + ( layout_size . width * 0 . 2 ) + i * ( layout_size . width + layout_size . width * 0 . 2 ) , <nl> - ( listHeight - layout_size . height ) / 2 ) ) ; <nl> - <nl> - listView - > addChild ( layout ) ; <nl> + lv - > pushBackDefaultItem ( ) ; <nl> } <nl> - listView - > addEventListenter ( this , listvieweventselector ( UIListViewTest_Horizontal : : listViewEvent ) ) ; <nl> - listView - > initChildWithDataLength ( m_array - > count ( ) ) ; <nl> - m_pUiLayer - > addWidget ( listView ) ; <nl> - <nl> + lv - > setItemsMargin ( 10 ) ; <nl> + lv - > setGravity ( LISTVIEW_GRAVITY_CENTER_VERTICAL ) ; <nl> + lv - > setSize ( Size ( 100 , 100 ) ) ; <nl> + lv - > setBackGroundColorType ( LAYOUT_COLOR_SOLID ) ; <nl> + lv - > setBackGroundColor ( Color3B : : GREEN ) ; <nl> + lv - > setPosition ( Point ( 100 , 100 ) ) ; <nl> + m_pUiLayer - > addWidget ( lv ) ; <nl> return true ; <nl> } <nl> <nl> return false ; <nl> - } <nl> - <nl> - void UIListViewTest_Horizontal : : listViewEvent ( Object * pSender , ListViewEventType type ) <nl> - { <nl> - switch ( type ) <nl> - { <nl> - case LISTVIEW_EVENT_INIT_CHILD : <nl> - { <nl> - String * ccstr = static_cast < String * > ( m_array - > getObjectAtIndex ( m_nCount ) ) ; <nl> - UIListView * list = dynamic_cast < UIListView * > ( pSender ) ; <nl> - <nl> - Layout * layout = dynamic_cast < Layout * > ( list - > getUpdateChild ( ) ) ; <nl> - UIButton * textButton = dynamic_cast < UIButton * > ( layout - > getChildByName ( " TextButton " ) ) ; <nl> - textButton - > setTitleText ( ccstr - > getCString ( ) ) ; <nl> - <nl> - m_nCount + + ; <nl> - } <nl> - break ; <nl> - <nl> - case LISTVIEW_EVENT_UPDATE_CHILD : <nl> - { <nl> - UIListView * list = dynamic_cast < UIListView * > ( pSender ) ; <nl> - int index = list - > getUpdateDataIndex ( ) ; <nl> - <nl> - if ( index < 0 | | index > = list - > getDataLength ( ) ) <nl> - { <nl> - list - > setUpdateSuccess ( false ) ; <nl> - } <nl> - <nl> - String * ccstr = static_cast < String * > ( m_array - > getObjectAtIndex ( index ) ) ; <nl> - Layout * layout = dynamic_cast < Layout * > ( list - > getUpdateChild ( ) ) ; <nl> - UIButton * textButton = dynamic_cast < UIButton * > ( layout - > getChildByName ( " TextButton " ) ) ; <nl> - textButton - > setTitleText ( ccstr - > getCString ( ) ) ; <nl> - list - > setUpdateSuccess ( true ) ; <nl> - } <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - } <nl> + } <nl> \ No newline at end of file <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIListViewTest / UIListViewTest . h <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIListViewTest / UIListViewTest . h <nl> class UIListViewTest_Vertical : public UIScene <nl> UIListViewTest_Vertical ( ) ; <nl> ~ UIListViewTest_Vertical ( ) ; <nl> bool init ( ) ; <nl> - void listViewEvent ( Object * pSender , ListViewEventType type ) ; <nl> <nl> protected : <nl> UI_SCENE_CREATE_FUNC ( UIListViewTest_Vertical ) <nl> class UIListViewTest_Horizontal : public UIScene <nl> UIListViewTest_Horizontal ( ) ; <nl> ~ UIListViewTest_Horizontal ( ) ; <nl> bool init ( ) ; <nl> - void listViewEvent ( Object * pSender , ListViewEventType type ) ; <nl> <nl> protected : <nl> UI_SCENE_CREATE_FUNC ( UIListViewTest_Horizontal ) <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIPageViewTest / UIPageViewTest . cpp <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIPageViewTest / UIPageViewTest . cpp <nl> bool UIPageViewTest : : init ( ) <nl> alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 925 ) ) ; <nl> m_pUiLayer - > addWidget ( alert ) ; <nl> <nl> - Layout * background = dynamic_cast < Layout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> + UILayout * background = dynamic_cast < UILayout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> <nl> / / Create the page view <nl> UIPageView * pageView = UIPageView : : create ( ) ; <nl> bool UIPageViewTest : : init ( ) <nl> <nl> for ( int i = 0 ; i < 3 ; + + i ) <nl> { <nl> - Layout * layout = Layout : : create ( ) ; <nl> + UILayout * layout = UILayout : : create ( ) ; <nl> layout - > setSize ( Size ( 240 , 130 ) ) ; <nl> <nl> UIImageView * imageView = UIImageView : : create ( ) ; <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIPanelTest / UIPanelTest . cpp <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIPanelTest / UIPanelTest . cpp <nl> bool UIPanelTest : : init ( ) <nl> alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 925 ) ) ; <nl> m_pUiLayer - > addWidget ( alert ) ; <nl> <nl> - Layout * background = dynamic_cast < Layout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> + UILayout * background = dynamic_cast < UILayout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> <nl> / / Create the layout <nl> - Layout * layout = Layout : : create ( ) ; <nl> + UILayout * layout = UILayout : : create ( ) ; <nl> layout - > setSize ( Size ( 280 , 150 ) ) ; <nl> Size backgroundSize = background - > getSize ( ) ; <nl> layout - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 + <nl> bool UIPanelTest_Color : : init ( ) <nl> alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 925 ) ) ; <nl> m_pUiLayer - > addWidget ( alert ) ; <nl> <nl> - Layout * background = dynamic_cast < Layout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> + UILayout * background = dynamic_cast < UILayout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> <nl> / / Create the layout with color render <nl> - Layout * layout = Layout : : create ( ) ; <nl> + UILayout * layout = UILayout : : create ( ) ; <nl> layout - > setBackGroundColorType ( LAYOUT_COLOR_SOLID ) ; <nl> layout - > setBackGroundColor ( Color3B ( 128 , 128 , 128 ) ) ; <nl> layout - > setSize ( Size ( 280 , 150 ) ) ; <nl> bool UIPanelTest_Gradient : : init ( ) <nl> alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 925 ) ) ; <nl> m_pUiLayer - > addWidget ( alert ) ; <nl> <nl> - Layout * background = dynamic_cast < Layout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> + UILayout * background = dynamic_cast < UILayout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> <nl> / / Create the layout with gradient render <nl> - Layout * layout = Layout : : create ( ) ; <nl> + UILayout * layout = UILayout : : create ( ) ; <nl> layout - > setBackGroundColorType ( LAYOUT_COLOR_GRADIENT ) ; <nl> layout - > setBackGroundColor ( Color3B ( 64 , 64 , 64 ) , Color3B ( 192 , 192 , 192 ) ) ; <nl> layout - > setSize ( Size ( 280 , 150 ) ) ; <nl> bool UIPanelTest_BackGroundImage : : init ( ) <nl> alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 925 ) ) ; <nl> m_pUiLayer - > addWidget ( alert ) ; <nl> <nl> - Layout * background = dynamic_cast < Layout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> + UILayout * background = dynamic_cast < UILayout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> <nl> / / Create the layout with background image <nl> - Layout * layout = Layout : : create ( ) ; <nl> + UILayout * layout = UILayout : : create ( ) ; <nl> layout - > setClippingEnabled ( true ) ; <nl> layout - > setBackGroundImage ( " cocosgui / Hello . png " ) ; <nl> layout - > setSize ( Size ( 280 , 150 ) ) ; <nl> bool UIPanelTest_BackGroundImage_Scale9 : : init ( ) <nl> alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 925 ) ) ; <nl> m_pUiLayer - > addWidget ( alert ) ; <nl> <nl> - Layout * background = dynamic_cast < Layout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> + UILayout * background = dynamic_cast < UILayout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> <nl> / / Create the layout with background image <nl> - Layout * layout = Layout : : create ( ) ; <nl> + UILayout * layout = UILayout : : create ( ) ; <nl> layout - > setBackGroundImageScale9Enabled ( true ) ; <nl> layout - > setBackGroundImage ( " cocosgui / green_edit . png " ) ; <nl> layout - > setSize ( Size ( 280 , 150 ) ) ; <nl> bool UIPanelTest_Layout_Linear_Vertical : : init ( ) <nl> alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 925 ) ) ; <nl> m_pUiLayer - > addWidget ( alert ) ; <nl> <nl> - Layout * background = dynamic_cast < Layout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> + UILayout * background = dynamic_cast < UILayout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> <nl> / / Create the layout <nl> - Layout * layout = Layout : : create ( ) ; <nl> + UILayout * layout = UILayout : : create ( ) ; <nl> layout - > setLayoutType ( LAYOUT_LINEAR_VERTICAL ) ; <nl> layout - > setSize ( Size ( 280 , 150 ) ) ; <nl> Size backgroundSize = background - > getSize ( ) ; <nl> bool UIPanelTest_Layout_Linear_Vertical : : init ( ) <nl> button - > loadTextures ( " cocosgui / animationbuttonnormal . png " , " cocosgui / animationbuttonpressed . png " , " " ) ; <nl> layout - > addChild ( button ) ; <nl> <nl> - LinearLayoutParameter * lp1 = LinearLayoutParameter : : create ( ) ; <nl> + UILinearLayoutParameter * lp1 = UILinearLayoutParameter : : create ( ) ; <nl> button - > setLayoutParameter ( lp1 ) ; <nl> lp1 - > setGravity ( LINEAR_GRAVITY_CENTER_HORIZONTAL ) ; <nl> lp1 - > setMargin ( UIMargin ( 0 , 5 , 0 , 10 ) ) ; <nl> bool UIPanelTest_Layout_Linear_Vertical : : init ( ) <nl> textButton - > setTitleText ( " Text Button " ) ; <nl> layout - > addChild ( textButton ) ; <nl> <nl> - LinearLayoutParameter * lp2 = LinearLayoutParameter : : create ( ) ; <nl> + UILinearLayoutParameter * lp2 = UILinearLayoutParameter : : create ( ) ; <nl> textButton - > setLayoutParameter ( lp2 ) ; <nl> lp2 - > setGravity ( LINEAR_GRAVITY_CENTER_HORIZONTAL ) ; <nl> lp2 - > setMargin ( UIMargin ( 0 , 10 , 0 , 10 ) ) ; <nl> bool UIPanelTest_Layout_Linear_Vertical : : init ( ) <nl> button_scale9 - > setSize ( Size ( 100 , button_scale9 - > getContentSize ( ) . height ) ) ; <nl> layout - > addChild ( button_scale9 ) ; <nl> <nl> - LinearLayoutParameter * lp3 = LinearLayoutParameter : : create ( ) ; <nl> + UILinearLayoutParameter * lp3 = UILinearLayoutParameter : : create ( ) ; <nl> button_scale9 - > setLayoutParameter ( lp3 ) ; <nl> lp3 - > setGravity ( LINEAR_GRAVITY_CENTER_HORIZONTAL ) ; <nl> lp3 - > setMargin ( UIMargin ( 0 , 10 , 0 , 10 ) ) ; <nl> bool UIPanelTest_Layout_Linear_Horizontal : : init ( ) <nl> alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 925 ) ) ; <nl> m_pUiLayer - > addWidget ( alert ) ; <nl> <nl> - Layout * background = dynamic_cast < Layout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> + UILayout * background = dynamic_cast < UILayout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> <nl> / / Create the layout <nl> - Layout * layout = Layout : : create ( ) ; <nl> + UILayout * layout = UILayout : : create ( ) ; <nl> layout - > setLayoutType ( LAYOUT_LINEAR_HORIZONTAL ) ; <nl> layout - > setClippingEnabled ( true ) ; <nl> layout - > setSize ( Size ( 280 , 150 ) ) ; <nl> bool UIPanelTest_Layout_Linear_Horizontal : : init ( ) <nl> button - > loadTextures ( " cocosgui / animationbuttonnormal . png " , " cocosgui / animationbuttonpressed . png " , " " ) ; <nl> layout - > addChild ( button ) ; <nl> <nl> - LinearLayoutParameter * lp1 = LinearLayoutParameter : : create ( ) ; <nl> + UILinearLayoutParameter * lp1 = UILinearLayoutParameter : : create ( ) ; <nl> button - > setLayoutParameter ( lp1 ) ; <nl> lp1 - > setGravity ( LINEAR_GRAVITY_CENTER_VERTICAL ) ; <nl> lp1 - > setMargin ( UIMargin ( 0 , 10 , 0 , 10 ) ) ; <nl> bool UIPanelTest_Layout_Linear_Horizontal : : init ( ) <nl> textButton - > setTitleText ( " Text Button " ) ; <nl> layout - > addChild ( textButton ) ; <nl> <nl> - LinearLayoutParameter * lp2 = LinearLayoutParameter : : create ( ) ; <nl> + UILinearLayoutParameter * lp2 = UILinearLayoutParameter : : create ( ) ; <nl> textButton - > setLayoutParameter ( lp2 ) ; <nl> lp2 - > setGravity ( LINEAR_GRAVITY_CENTER_VERTICAL ) ; <nl> lp2 - > setMargin ( UIMargin ( 0 , 10 , 0 , 10 ) ) ; <nl> bool UIPanelTest_Layout_Linear_Horizontal : : init ( ) <nl> button_scale9 - > setSize ( Size ( 100 , button_scale9 - > getContentSize ( ) . height ) ) ; <nl> layout - > addChild ( button_scale9 ) ; <nl> <nl> - LinearLayoutParameter * lp3 = LinearLayoutParameter : : create ( ) ; <nl> + UILinearLayoutParameter * lp3 = UILinearLayoutParameter : : create ( ) ; <nl> button_scale9 - > setLayoutParameter ( lp3 ) ; <nl> lp3 - > setGravity ( LINEAR_GRAVITY_CENTER_VERTICAL ) ; <nl> lp3 - > setMargin ( UIMargin ( 0 , 10 , 0 , 10 ) ) ; <nl> bool UIPanelTest_Layout_Relative : : init ( ) <nl> alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 925 ) ) ; <nl> m_pUiLayer - > addWidget ( alert ) ; <nl> <nl> - Layout * background = dynamic_cast < Layout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> + UILayout * background = dynamic_cast < UILayout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> <nl> / / Create the layout <nl> - Layout * layout = Layout : : create ( ) ; <nl> + UILayout * layout = UILayout : : create ( ) ; <nl> layout - > setLayoutType ( LAYOUT_RELATIVE ) ; <nl> layout - > setSize ( Size ( 280 , 150 ) ) ; <nl> layout - > setBackGroundColorType ( LAYOUT_COLOR_SOLID ) ; <nl> bool UIPanelTest_Layout_Relative : : init ( ) <nl> button - > loadTextures ( " cocosgui / animationbuttonnormal . png " , " cocosgui / animationbuttonpressed . png " , " " ) ; <nl> layout - > addChild ( button ) ; <nl> <nl> - RelativeLayoutParameter * rp1 = RelativeLayoutParameter : : create ( ) ; <nl> + UIRelativeLayoutParameter * rp1 = UIRelativeLayoutParameter : : create ( ) ; <nl> button - > setLayoutParameter ( rp1 ) ; <nl> - rp1 - > setAlign ( RELATIVE_ALIGN_PARENT_BOTTOM ) ; <nl> + rp1 - > setAlign ( RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL ) ; <nl> / / rp1 - > setMargin ( UIMargin ( 0 , 10 , 0 , 10 ) ) ; <nl> <nl> <nl> bool UIPanelTest_Layout_Relative : : init ( ) <nl> textButton - > setTitleText ( " Text Button " ) ; <nl> layout - > addChild ( textButton ) ; <nl> <nl> - RelativeLayoutParameter * rp2 = RelativeLayoutParameter : : create ( ) ; <nl> + UIRelativeLayoutParameter * rp2 = UIRelativeLayoutParameter : : create ( ) ; <nl> textButton - > setLayoutParameter ( rp2 ) ; <nl> - rp2 - > setAlign ( RELATIVE_ALIGN_PARENT_LEFT ) ; <nl> + rp2 - > setAlign ( RELATIVE_ALIGN_PARENT_LEFT_BOTTOM ) ; <nl> <nl> <nl> UIButton * button_scale9 = UIButton : : create ( ) ; <nl> bool UIPanelTest_Layout_Relative : : init ( ) <nl> button_scale9 - > setSize ( Size ( 100 , button_scale9 - > getContentSize ( ) . height ) ) ; <nl> layout - > addChild ( button_scale9 ) ; <nl> <nl> - RelativeLayoutParameter * rp3 = RelativeLayoutParameter : : create ( ) ; <nl> + UIRelativeLayoutParameter * rp3 = UIRelativeLayoutParameter : : create ( ) ; <nl> textButton - > setLayoutParameter ( rp3 ) ; <nl> - rp3 - > setAlign ( RELATIVE_ALIGN_PARENT_RIGHT ) ; <nl> + rp3 - > setAlign ( RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM ) ; <nl> <nl> <nl> layout - > doLayout ( ) ; <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIScene . cpp <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIScene . cpp <nl> <nl> # include " UIScene . h " <nl> # include " UISceneManager . h " <nl> # include " . . / ExtensionsTest . h " <nl> + # include " editor - support / cocostudio / CCSGUIReader . h " <nl> <nl> using namespace gui ; <nl> <nl> bool UIScene : : init ( ) <nl> m_pUiLayer = UILayer : : create ( ) ; <nl> addChild ( m_pUiLayer ) ; <nl> <nl> - m_pWidget = dynamic_cast < Layout * > ( CCUIHELPER - > createWidgetFromJsonFile ( " cocosgui / UITest / UITest . json " ) ) ; <nl> + m_pWidget = dynamic_cast < UILayout * > ( cocostudio : : CCSGUIReader : : shareReader ( ) - > widgetFromJsonFile ( " cocosgui / UITest / UITest . json " ) ) ; <nl> m_pUiLayer - > addWidget ( m_pWidget ) ; <nl> <nl> m_pSceneTitle = dynamic_cast < UILabel * > ( m_pUiLayer - > getWidgetByName ( " UItest " ) ) ; <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIScene . h <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIScene . h <nl> class UIScene : public Layer <nl> <nl> protected : <nl> UILayer * m_pUiLayer ; <nl> - Layout * m_pWidget ; <nl> + UILayout * m_pWidget ; <nl> } ; <nl> <nl> # endif / * defined ( __TestCpp__UIScene__ ) * / <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIScrollViewTest / UIScrollViewTest . cpp <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIScrollViewTest / UIScrollViewTest . cpp <nl> bool UIScrollViewTest_Vertical : : init ( ) <nl> alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 925 ) ) ; <nl> m_pUiLayer - > addWidget ( alert ) ; <nl> <nl> - Layout * background = dynamic_cast < Layout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> + UILayout * background = dynamic_cast < UILayout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> <nl> / / Create the scrollview by vertical <nl> UIScrollView * scrollView = UIScrollView : : create ( ) ; <nl> bool UIScrollViewTest_Horizontal : : init ( ) <nl> alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 925 ) ) ; <nl> m_pUiLayer - > addWidget ( alert ) ; <nl> <nl> - Layout * background = dynamic_cast < Layout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> + UILayout * background = dynamic_cast < UILayout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> <nl> / / Create the scrollview by horizontal <nl> - UIScrollView * scrollView = UIScrollView : : create ( ) ; <nl> + UIScrollView * scrollView = UIScrollView : : create ( ) ; <nl> + scrollView - > setBounceEnabled ( true ) ; <nl> scrollView - > setDirection ( SCROLLVIEW_DIR_HORIZONTAL ) ; <nl> scrollView - > setTouchEnabled ( true ) ; <nl> scrollView - > setSize ( Size ( 280 , 150 ) ) ; <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UITextFieldTest / UITextFieldTest . cpp <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UITextFieldTest / UITextFieldTest . cpp <nl> void UITextFieldTest : : textFieldEvent ( Object * pSender , TextFiledEventType type ) <nl> } <nl> break ; <nl> <nl> - case TEXTFIELD_EVENT_INDERT_TEXT : <nl> + case TEXTFIELD_EVENT_INSERT_TEXT : <nl> m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " insert words " ) - > getCString ( ) ) ; <nl> break ; <nl> <nl> bool UITextFieldTest_MaxLength : : init ( ) <nl> <nl> / / Create the textfield <nl> UITextField * textField = UITextField : : create ( ) ; <nl> - textField - > setMaxLengthEnable ( true ) ; <nl> + textField - > setMaxLengthEnabled ( true ) ; <nl> textField - > setMaxLength ( 3 ) ; <nl> textField - > setTouchEnabled ( true ) ; <nl> textField - > setFontName ( font_UITextFieldTest ) ; <nl> void UITextFieldTest_MaxLength : : textFieldEvent ( Object * pSender , TextFiledEventTy <nl> } <nl> break ; <nl> <nl> - case TEXTFIELD_EVENT_INDERT_TEXT : <nl> + case TEXTFIELD_EVENT_INSERT_TEXT : <nl> { <nl> UITextField * textField = dynamic_cast < UITextField * > ( pSender ) ; <nl> m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " insert words max length % d " , textField - > getMaxLength ( ) ) - > getCString ( ) ) ; <nl> bool UITextFieldTest_Password : : init ( ) <nl> <nl> / / Create the textfield <nl> UITextField * textField = UITextField : : create ( ) ; <nl> - textField - > setPasswordEnable ( true ) ; <nl> + textField - > setPasswordEnabled ( true ) ; <nl> textField - > setPasswordStyleText ( " * " ) ; <nl> textField - > setTouchEnabled ( true ) ; <nl> textField - > setFontName ( font_UITextFieldTest ) ; <nl> void UITextFieldTest_Password : : textFieldEvent ( Object * pSender , TextFiledEventTyp <nl> } <nl> break ; <nl> <nl> - case TEXTFIELD_EVENT_INDERT_TEXT : <nl> + case TEXTFIELD_EVENT_INSERT_TEXT : <nl> m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " insert words password " ) - > getCString ( ) ) ; <nl> break ; <nl> <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioSceneTest / SceneEditorTest . cpp <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioSceneTest / SceneEditorTest . cpp <nl> SceneEditorTestLayer : : ~ SceneEditorTestLayer ( ) <nl> ArmatureDataManager : : getInstance ( ) - > destoryInstance ( ) ; <nl> SceneReader : : getInstance ( ) - > purgeSceneReader ( ) ; <nl> ActionManagerEx : : shareManager ( ) - > purgeActionManager ( ) ; <nl> - UIHelper : : instance ( ) - > purgeUIHelper ( ) ; <nl> } <nl> <nl> SceneEditorTestLayer : : SceneEditorTestLayer ( ) <nl> | Merge master branch to develop branch | cocos2d/cocos2d-x | e0aa82da138c7a789e3335eac249143b23f78e91 | 2013-11-06T08:04:06Z |
mmm a / src / debug . cc <nl> ppp b / src / debug . cc <nl> void Debug : : PrepareForBreakPoints ( ) { <nl> Heap * heap = isolate_ - > heap ( ) ; <nl> heap - > CollectAllGarbage ( Heap : : kMakeHeapIterableMask , <nl> " preparing for breakpoints " ) ; <nl> + HeapIterator iterator ( heap ) ; <nl> <nl> / / Ensure no GC in this scope as we are going to use gc_metadata <nl> / / field in the Code object to mark active functions . <nl> void Debug : : PrepareForBreakPoints ( ) { <nl> / / Scan the heap for all non - optimized functions which have no <nl> / / debug break slots and are not active or inlined into an active <nl> / / function and mark them for lazy compilation . <nl> - HeapIterator iterator ( heap ) ; <nl> HeapObject * obj = NULL ; <nl> while ( ( ( obj = iterator . next ( ) ) ! = NULL ) ) { <nl> if ( obj - > IsJSFunction ( ) ) { <nl> Object * Debug : : FindSharedFunctionInfoInScript ( Handle < Script > script , <nl> Handle < SharedFunctionInfo > target ; <nl> Heap * heap = isolate_ - > heap ( ) ; <nl> while ( ! done ) { <nl> - { / / Extra scope for iterator and no - allocation . <nl> - heap - > EnsureHeapIsIterable ( ) ; <nl> - DisallowHeapAllocation no_alloc_during_heap_iteration ; <nl> + { / / Extra scope for iterator . <nl> HeapIterator iterator ( heap ) ; <nl> for ( HeapObject * obj = iterator . next ( ) ; <nl> obj ! = NULL ; obj = iterator . next ( ) ) { <nl> void Debug : : CreateScriptCache ( ) { <nl> / / scripts which are no longer referenced . The second also sweeps precisely , <nl> / / which saves us doing yet another GC to make the heap iterable . <nl> heap - > CollectAllGarbage ( Heap : : kNoGCFlags , " Debug : : CreateScriptCache " ) ; <nl> - heap - > CollectAllGarbage ( Heap : : kMakeHeapIterableMask , <nl> - " Debug : : CreateScriptCache " ) ; <nl> <nl> ASSERT ( script_cache_ = = NULL ) ; <nl> script_cache_ = new ScriptCache ( isolate_ ) ; <nl> void Debug : : CreateScriptCache ( ) { <nl> / / Scan heap for Script objects . <nl> int count = 0 ; <nl> HeapIterator iterator ( heap ) ; <nl> - DisallowHeapAllocation no_allocation ; <nl> <nl> for ( HeapObject * obj = iterator . next ( ) ; obj ! = NULL ; obj = iterator . next ( ) ) { <nl> if ( obj - > IsScript ( ) & & Script : : cast ( obj ) - > HasValidSource ( ) ) { <nl> mmm a / src / heap - profiler . cc <nl> ppp b / src / heap - profiler . cc <nl> void HeapProfiler : : SetRetainedObjectInfo ( UniqueId id , <nl> <nl> <nl> Handle < HeapObject > HeapProfiler : : FindHeapObjectById ( SnapshotObjectId id ) { <nl> - heap ( ) - > CollectAllGarbage ( Heap : : kMakeHeapIterableMask , <nl> - " HeapProfiler : : FindHeapObjectById " ) ; <nl> - DisallowHeapAllocation no_allocation ; <nl> HeapObject * object = NULL ; <nl> HeapIterator iterator ( heap ( ) , HeapIterator : : kFilterUnreachable ) ; <nl> / / Make sure that object with the given id is still reachable . <nl> mmm a / src / heap - snapshot - generator . cc <nl> ppp b / src / heap - snapshot - generator . cc <nl> bool HeapSnapshotGenerator : : GenerateSnapshot ( ) { <nl> CHECK ( ! debug_heap - > map_space ( ) - > was_swept_conservatively ( ) ) ; <nl> # endif <nl> <nl> - / / The following code uses heap iterators , so we want the heap to be <nl> - / / stable . It should follow TagGlobalObjects as that can allocate . <nl> - DisallowHeapAllocation no_alloc ; <nl> - <nl> # ifdef VERIFY_HEAP <nl> debug_heap - > Verify ( ) ; <nl> # endif <nl> mmm a / src / heap . cc <nl> ppp b / src / heap . cc <nl> STRUCT_LIST ( MAKE_CASE ) <nl> <nl> bool Heap : : IsHeapIterable ( ) { <nl> return ( ! old_pointer_space ( ) - > was_swept_conservatively ( ) & & <nl> - ! old_data_space ( ) - > was_swept_conservatively ( ) ) ; <nl> + ! old_data_space ( ) - > was_swept_conservatively ( ) & & <nl> + new_space ( ) - > bottom ( ) = = new_space ( ) - > top ( ) ) ; <nl> } <nl> <nl> <nl> - void Heap : : EnsureHeapIsIterable ( ) { <nl> + void Heap : : MakeHeapIterable ( ) { <nl> ASSERT ( AllowHeapAllocation : : IsAllowed ( ) ) ; <nl> if ( ! IsHeapIterable ( ) ) { <nl> - CollectAllGarbage ( kMakeHeapIterableMask , " Heap : : EnsureHeapIsIterable " ) ; <nl> + CollectAllGarbage ( kMakeHeapIterableMask , " Heap : : MakeHeapIterable " ) ; <nl> } <nl> ASSERT ( IsHeapIterable ( ) ) ; <nl> } <nl> class UnreachableObjectsFilter : public HeapObjectsFilter { <nl> <nl> <nl> HeapIterator : : HeapIterator ( Heap * heap ) <nl> - : heap_ ( heap ) , <nl> + : make_heap_iterable_helper_ ( heap ) , <nl> + no_heap_allocation_ ( ) , <nl> + heap_ ( heap ) , <nl> filtering_ ( HeapIterator : : kNoFiltering ) , <nl> filter_ ( NULL ) { <nl> Init ( ) ; <nl> HeapIterator : : HeapIterator ( Heap * heap ) <nl> <nl> HeapIterator : : HeapIterator ( Heap * heap , <nl> HeapIterator : : HeapObjectsFiltering filtering ) <nl> - : heap_ ( heap ) , <nl> + : make_heap_iterable_helper_ ( heap ) , <nl> + no_heap_allocation_ ( ) , <nl> + heap_ ( heap ) , <nl> filtering_ ( filtering ) , <nl> filter_ ( NULL ) { <nl> Init ( ) ; <nl> mmm a / src / heap . h <nl> ppp b / src / heap . h <nl> class Heap { <nl> <nl> / / Ensure that we have swept all spaces in such a way that we can iterate <nl> / / over all objects . May cause a GC . <nl> - void EnsureHeapIsIterable ( ) ; <nl> + void MakeHeapIterable ( ) ; <nl> <nl> / / Notify the heap that a context has been disposed . <nl> int NotifyContextDisposed ( ) ; <nl> class SpaceIterator : public Malloced { <nl> / / aggregates the specific iterators for the different spaces as <nl> / / these can only iterate over one space only . <nl> / / <nl> + / / HeapIterator ensures there is no allocation during its lifetime <nl> + / / ( using an embedded DisallowHeapAllocation instance ) . <nl> + / / <nl> / / HeapIterator can skip free list nodes ( that is , de - allocated heap <nl> / / objects that still remain in the heap ) . As implementation of free <nl> / / nodes filtering uses GC marks , it can ' t be used during MS / MC GC <nl> class HeapIterator BASE_EMBEDDED { <nl> void reset ( ) ; <nl> <nl> private : <nl> + struct MakeHeapIterableHelper { <nl> + explicit MakeHeapIterableHelper ( Heap * heap ) { heap - > MakeHeapIterable ( ) ; } <nl> + } ; <nl> + <nl> / / Perform the initialization . <nl> void Init ( ) ; <nl> / / Perform all necessary shutdown ( destruction ) work . <nl> void Shutdown ( ) ; <nl> HeapObject * NextObject ( ) ; <nl> <nl> + MakeHeapIterableHelper make_heap_iterable_helper_ ; <nl> + DisallowHeapAllocation no_heap_allocation_ ; <nl> Heap * heap_ ; <nl> HeapObjectsFiltering filtering_ ; <nl> HeapObjectsFilter * filter_ ; <nl> mmm a / src / liveedit . cc <nl> ppp b / src / liveedit . cc <nl> static void ReplaceCodeObject ( Handle < Code > original , <nl> / / to code objects ( that are never in new space ) without worrying about <nl> / / write barriers . <nl> Heap * heap = original - > GetHeap ( ) ; <nl> - heap - > CollectAllGarbage ( Heap : : kMakeHeapIterableMask , <nl> - " liveedit . cc ReplaceCodeObject " ) ; <nl> + HeapIterator iterator ( heap ) ; <nl> <nl> ASSERT ( ! heap - > InNewSpace ( * substitution ) ) ; <nl> <nl> - DisallowHeapAllocation no_allocation ; <nl> - <nl> ReplacingVisitor visitor ( * original , * substitution ) ; <nl> <nl> / / Iterate over all roots . Stack frames may have pointer into original code , <nl> static void ReplaceCodeObject ( Handle < Code > original , <nl> <nl> / / Now iterate over all pointers of all objects , including code_target <nl> / / implicit pointers . <nl> - HeapIterator iterator ( heap ) ; <nl> for ( HeapObject * obj = iterator . next ( ) ; obj ! = NULL ; obj = iterator . next ( ) ) { <nl> obj - > Iterate ( & visitor ) ; <nl> } <nl> class LiteralFixer { <nl> template < typename Visitor > <nl> static void IterateJSFunctions ( SharedFunctionInfo * shared_info , <nl> Visitor * visitor ) { <nl> - DisallowHeapAllocation no_allocation ; <nl> - <nl> HeapIterator iterator ( shared_info - > GetHeap ( ) ) ; <nl> for ( HeapObject * obj = iterator . next ( ) ; obj ! = NULL ; <nl> obj = iterator . next ( ) ) { <nl> void LiveEdit : : ReplaceFunctionCode ( <nl> <nl> Handle < SharedFunctionInfo > shared_info = shared_info_wrapper . GetInfo ( ) ; <nl> <nl> - isolate - > heap ( ) - > EnsureHeapIsIterable ( ) ; <nl> + isolate - > heap ( ) - > MakeHeapIterable ( ) ; <nl> <nl> if ( IsJSFunctionCode ( shared_info - > code ( ) ) ) { <nl> Handle < Code > code = compile_info_wrapper . GetFunctionCode ( ) ; <nl> void LiveEdit : : PatchFunctionPositions ( Handle < JSArray > shared_info_array , <nl> info - > set_end_position ( new_function_end ) ; <nl> info - > set_function_token_position ( new_function_token_pos ) ; <nl> <nl> - info - > GetIsolate ( ) - > heap ( ) - > EnsureHeapIsIterable ( ) ; <nl> + info - > GetIsolate ( ) - > heap ( ) - > MakeHeapIterable ( ) ; <nl> <nl> if ( IsJSFunctionCode ( info - > code ( ) ) ) { <nl> / / Patch relocation info section of the code . <nl> mmm a / src / runtime . cc <nl> ppp b / src / runtime . cc <nl> RUNTIME_FUNCTION ( Runtime_DebugReferencedBy ) { <nl> HandleScope scope ( isolate ) ; <nl> ASSERT ( args . length ( ) = = 3 ) ; <nl> <nl> - / / First perform a full GC in order to avoid references from dead objects . <nl> - Heap * heap = isolate - > heap ( ) ; <nl> - heap - > CollectAllGarbage ( Heap : : kMakeHeapIterableMask , " % DebugReferencedBy " ) ; <nl> - / / The heap iterator reserves the right to do a GC to make the heap iterable . <nl> - / / Due to the GC above we know it won ' t need to do that , but it seems cleaner <nl> - / / to get the heap iterator constructed before we start having unprotected <nl> - / / Object * locals that are not protected by handles . <nl> - <nl> / / Check parameters . <nl> CONVERT_ARG_HANDLE_CHECKED ( JSObject , target , 0 ) ; <nl> CONVERT_ARG_HANDLE_CHECKED ( Object , instance_filter , 1 ) ; <nl> RUNTIME_FUNCTION ( Runtime_DebugReferencedBy ) { <nl> <nl> / / Get the number of referencing objects . <nl> int count ; <nl> - HeapIterator heap_iterator ( heap ) ; <nl> - count = DebugReferencedBy ( & heap_iterator , <nl> - * target , * instance_filter , max_references , <nl> - NULL , 0 , * arguments_function ) ; <nl> + / / First perform a full GC in order to avoid dead objects and to make the heap <nl> + / / iterable . <nl> + Heap * heap = isolate - > heap ( ) ; <nl> + heap - > CollectAllGarbage ( Heap : : kMakeHeapIterableMask , " % DebugConstructedBy " ) ; <nl> + { <nl> + HeapIterator heap_iterator ( heap ) ; <nl> + count = DebugReferencedBy ( & heap_iterator , <nl> + * target , * instance_filter , max_references , <nl> + NULL , 0 , * arguments_function ) ; <nl> + } <nl> <nl> / / Allocate an array to hold the result . <nl> Handle < FixedArray > instances = isolate - > factory ( ) - > NewFixedArray ( count ) ; <nl> <nl> / / Fill the referencing objects . <nl> - / / AllocateFixedArray above does not make the heap non - iterable . <nl> - ASSERT ( heap - > IsHeapIterable ( ) ) ; <nl> - HeapIterator heap_iterator2 ( heap ) ; <nl> - count = DebugReferencedBy ( & heap_iterator2 , <nl> - * target , * instance_filter , max_references , <nl> - * instances , count , * arguments_function ) ; <nl> + { <nl> + HeapIterator heap_iterator ( heap ) ; <nl> + count = DebugReferencedBy ( & heap_iterator , <nl> + * target , * instance_filter , max_references , <nl> + * instances , count , * arguments_function ) ; <nl> + } <nl> <nl> / / Return result as JS array . <nl> Handle < JSFunction > constructor ( <nl> RUNTIME_FUNCTION ( Runtime_DebugConstructedBy ) { <nl> HandleScope scope ( isolate ) ; <nl> ASSERT ( args . length ( ) = = 2 ) ; <nl> <nl> - / / First perform a full GC in order to avoid dead objects . <nl> - Heap * heap = isolate - > heap ( ) ; <nl> - heap - > CollectAllGarbage ( Heap : : kMakeHeapIterableMask , " % DebugConstructedBy " ) ; <nl> <nl> / / Check parameters . <nl> CONVERT_ARG_HANDLE_CHECKED ( JSFunction , constructor , 0 ) ; <nl> RUNTIME_FUNCTION ( Runtime_DebugConstructedBy ) { <nl> <nl> / / Get the number of referencing objects . <nl> int count ; <nl> - HeapIterator heap_iterator ( heap ) ; <nl> - count = DebugConstructedBy ( & heap_iterator , <nl> - * constructor , <nl> - max_references , <nl> - NULL , <nl> - 0 ) ; <nl> + / / First perform a full GC in order to avoid dead objects and to make the heap <nl> + / / iterable . <nl> + Heap * heap = isolate - > heap ( ) ; <nl> + heap - > CollectAllGarbage ( Heap : : kMakeHeapIterableMask , " % DebugConstructedBy " ) ; <nl> + { <nl> + HeapIterator heap_iterator ( heap ) ; <nl> + count = DebugConstructedBy ( & heap_iterator , <nl> + * constructor , <nl> + max_references , <nl> + NULL , <nl> + 0 ) ; <nl> + } <nl> <nl> / / Allocate an array to hold the result . <nl> Handle < FixedArray > instances = isolate - > factory ( ) - > NewFixedArray ( count ) ; <nl> <nl> - ASSERT ( heap - > IsHeapIterable ( ) ) ; <nl> / / Fill the referencing objects . <nl> - HeapIterator heap_iterator2 ( heap ) ; <nl> - count = DebugConstructedBy ( & heap_iterator2 , <nl> - * constructor , <nl> - max_references , <nl> - * instances , <nl> - count ) ; <nl> + { <nl> + HeapIterator heap_iterator2 ( heap ) ; <nl> + count = DebugConstructedBy ( & heap_iterator2 , <nl> + * constructor , <nl> + max_references , <nl> + * instances , <nl> + count ) ; <nl> + } <nl> <nl> / / Return result as JS array . <nl> Handle < JSFunction > array_function ( <nl> RUNTIME_FUNCTION ( Runtime_LiveEditFindSharedFunctionInfosForScript ) { <nl> int number ; <nl> Heap * heap = isolate - > heap ( ) ; <nl> { <nl> - heap - > EnsureHeapIsIterable ( ) ; <nl> - DisallowHeapAllocation no_allocation ; <nl> HeapIterator heap_iterator ( heap ) ; <nl> Script * scr = * script ; <nl> FixedArray * arr = * array ; <nl> RUNTIME_FUNCTION ( Runtime_LiveEditFindSharedFunctionInfosForScript ) { <nl> } <nl> if ( number > kBufferSize ) { <nl> array = isolate - > factory ( ) - > NewFixedArray ( number ) ; <nl> - heap - > EnsureHeapIsIterable ( ) ; <nl> - DisallowHeapAllocation no_allocation ; <nl> HeapIterator heap_iterator ( heap ) ; <nl> Script * scr = * script ; <nl> FixedArray * arr = * array ; <nl> static Handle < Object > Runtime_GetScriptFromScriptName ( <nl> Handle < Script > script ; <nl> Factory * factory = script_name - > GetIsolate ( ) - > factory ( ) ; <nl> Heap * heap = script_name - > GetHeap ( ) ; <nl> - heap - > EnsureHeapIsIterable ( ) ; <nl> - DisallowHeapAllocation no_allocation_during_heap_iteration ; <nl> HeapIterator iterator ( heap ) ; <nl> HeapObject * obj = NULL ; <nl> while ( script . is_null ( ) & & ( ( obj = iterator . next ( ) ) ! = NULL ) ) { <nl> mmm a / test / cctest / test - api . cc <nl> ppp b / test / cctest / test - api . cc <nl> THREADED_TEST ( LockUnlockLock ) { <nl> <nl> <nl> static int GetGlobalObjectsCount ( ) { <nl> - CcTest : : heap ( ) - > EnsureHeapIsIterable ( ) ; <nl> int count = 0 ; <nl> i : : HeapIterator it ( CcTest : : heap ( ) ) ; <nl> for ( i : : HeapObject * object = it . next ( ) ; object ! = NULL ; object = it . next ( ) ) <nl> mmm a / test / cctest / test - heap . cc <nl> ppp b / test / cctest / test - heap . cc <nl> TEST ( StringAllocation ) { <nl> static int ObjectsFoundInHeap ( Heap * heap , Handle < Object > objs [ ] , int size ) { <nl> / / Count the number of objects found in the heap . <nl> int found_count = 0 ; <nl> - heap - > EnsureHeapIsIterable ( ) ; <nl> HeapIterator iterator ( heap ) ; <nl> for ( HeapObject * obj = iterator . next ( ) ; obj ! = NULL ; obj = iterator . next ( ) ) { <nl> for ( int i = 0 ; i < size ; i + + ) { <nl> TEST ( TestSizeOfObjects ) { <nl> <nl> TEST ( TestSizeOfObjectsVsHeapIteratorPrecision ) { <nl> CcTest : : InitializeVM ( ) ; <nl> - CcTest : : heap ( ) - > EnsureHeapIsIterable ( ) ; <nl> - intptr_t size_of_objects_1 = CcTest : : heap ( ) - > SizeOfObjects ( ) ; <nl> HeapIterator iterator ( CcTest : : heap ( ) ) ; <nl> + intptr_t size_of_objects_1 = CcTest : : heap ( ) - > SizeOfObjects ( ) ; <nl> intptr_t size_of_objects_2 = 0 ; <nl> for ( HeapObject * obj = iterator . next ( ) ; <nl> obj ! = NULL ; <nl> mmm a / test / cctest / test - object - observe . cc <nl> ppp b / test / cctest / test - object - observe . cc <nl> TEST ( GetNotifierFromSameOrigin ) { <nl> <nl> <nl> static int GetGlobalObjectsCount ( ) { <nl> - CcTest : : heap ( ) - > EnsureHeapIsIterable ( ) ; <nl> int count = 0 ; <nl> i : : HeapIterator it ( CcTest : : heap ( ) ) ; <nl> for ( i : : HeapObject * object = it . next ( ) ; object ! = NULL ; object = it . next ( ) ) <nl> new file mode 100644 <nl> index 00000000000 . . 20cee4d808e <nl> mmm / dev / null <nl> ppp b / test / mjsunit / regress / regress - 373283 . js <nl> <nl> + / / Copyright 2014 the V8 project authors . All rights reserved . <nl> + / / Use of this source code is governed by a BSD - style license that can be <nl> + / / found in the LICENSE file . <nl> + <nl> + / / Flags : - - allow - natives - syntax - - deopt - every - n - times = 1 <nl> + <nl> + function __f_0 ( ) { <nl> + var x = [ ] ; <nl> + x [ 21 ] = 1 ; <nl> + x [ 21 ] + 0 ; <nl> + } <nl> + <nl> + for ( var i = 0 ; i < 3 ; i + + ) __f_0 ( ) ; <nl> + % OptimizeFunctionOnNextCall ( __f_0 ) ; <nl> + for ( var i = 0 ; i < 10 ; i + + ) __f_0 ( ) ; <nl> + % OptimizeFunctionOnNextCall ( __f_0 ) ; <nl> + __f_0 ( ) ; <nl> + % GetScript ( " foo " ) ; <nl> | Fix Heap : : IsHeapIterable . | v8/v8 | dd4c82bbb3c3e51a610892c4285cbad3e7ee978c | 2014-05-20T13:19:21Z |
mmm a / SConstruct <nl> ppp b / SConstruct <nl> MKSNAPSHOT_EXTRA_FLAGS = { <nl> } , <nl> ' msvc ' : { <nl> ' all ' : { <nl> + ' CPPDEFINES ' : [ ' _HAS_EXCEPTIONS = 0 ' ] , <nl> ' LIBS ' : [ ' winmm ' , ' ws2_32 ' ] <nl> } <nl> } <nl> | Fix building of snapshots on Windows . | v8/v8 | b34db3d241acddde2542a9abe2b76d79567d5b5a | 2009-04-17T00:15:12Z |
mmm a / src / mongo / db / mongod . vcxproj <nl> ppp b / src / mongo / db / mongod . vcxproj <nl> cscript / / Nologo " $ ( ProjectDir ) . . \ shell \ createCPPfromJavaScriptFiles . js " " $ ( Proj <nl> < ObjectFileName Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Win2008PlusRelease | x64 ' " > $ ( IntDir ) matcher2 . obj < / ObjectFileName > <nl> < / ClCompile > <nl> < ClCompile Include = " matcher \ match_details . cpp " / > <nl> - < ClCompile Include = " matcher_old . cpp " > <nl> - < ExcludedFromBuild Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | Win32 ' " > true < / ExcludedFromBuild > <nl> - < ExcludedFromBuild Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Release | Win32 ' " > true < / ExcludedFromBuild > <nl> - < ExcludedFromBuild Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Win2008PlusDebug | Win32 ' " > true < / ExcludedFromBuild > <nl> - < ExcludedFromBuild Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Win2008PlusRelease | Win32 ' " > true < / ExcludedFromBuild > <nl> - < ExcludedFromBuild Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | x64 ' " > true < / ExcludedFromBuild > <nl> - < ExcludedFromBuild Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Release | x64 ' " > true < / ExcludedFromBuild > <nl> - < ExcludedFromBuild Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Win2008PlusDebug | x64 ' " > true < / ExcludedFromBuild > <nl> - < ExcludedFromBuild Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Win2008PlusRelease | x64 ' " > true < / ExcludedFromBuild > <nl> - < / ClCompile > <nl> < ClCompile Include = " ops \ field_checker . cpp " / > <nl> < ClCompile Include = " ops \ field_checker_test . cpp " > <nl> < ExcludedFromBuild Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | Win32 ' " > true < / ExcludedFromBuild > <nl> cscript / / Nologo " $ ( ProjectDir ) . . \ shell \ createCPPfromJavaScriptFiles . js " " $ ( Proj <nl> < ClInclude Include = " matcher \ matcher . h " / > <nl> < ClInclude Include = " matcher \ match_details . h " / > <nl> < ClInclude Include = " matcher_covered . h " / > <nl> - < ClInclude Include = " matcher_old . h " / > <nl> < ClInclude Include = " memconcept . h " / > <nl> < ClInclude Include = " minilex . h " / > <nl> < ClInclude Include = " module . h " / > <nl> cscript / / Nologo " $ ( ProjectDir ) . . \ shell \ createCPPfromJavaScriptFiles . js " " $ ( Proj <nl> < ClCompile Include = " jsobj . cpp " / > <nl> < ClCompile Include = " json . cpp " / > <nl> < ClCompile Include = " lasterror . cpp " / > <nl> - < ClCompile Include = " matcher . cpp " / > <nl> < ClCompile Include = " matcher_covered . cpp " / > <nl> < ClCompile Include = " . . \ util \ mmap_win . cpp " / > <nl> < ClCompile Include = " module . cpp " / > <nl> mmm a / src / mongo / db / mongod . vcxproj . filters <nl> ppp b / src / mongo / db / mongod . vcxproj . filters <nl> <nl> < ClCompile Include = " lasterror . cpp " > <nl> < Filter > db \ Source Files \ e to n < / Filter > <nl> < / ClCompile > <nl> - < ClCompile Include = " matcher . cpp " > <nl> - < Filter > db \ Source Files \ e to n < / Filter > <nl> - < / ClCompile > <nl> < ClCompile Include = " matcher_covered . cpp " > <nl> < Filter > db \ Source Files \ e to n < / Filter > <nl> < / ClCompile > <nl> <nl> < ClCompile Include = " ops \ modifier_unset_test . cpp " > <nl> < Filter > db \ ops < / Filter > <nl> < / ClCompile > <nl> - < ClCompile Include = " matcher_old . cpp " > <nl> - < Filter > db \ Source Files \ e to n < / Filter > <nl> - < / ClCompile > <nl> < ClCompile Include = " ops \ modifier_inc . cpp " > <nl> < Filter > db \ ops < / Filter > <nl> < / ClCompile > <nl> <nl> < ClInclude Include = " matcher_covered . h " > <nl> < Filter > db \ Header Files \ e to n < / Filter > <nl> < / ClInclude > <nl> - < ClInclude Include = " matcher_old . h " > <nl> - < Filter > db \ Header Files \ e to n < / Filter > <nl> - < / ClInclude > <nl> < ClInclude Include = " . . \ util \ safe_num - inl . h " > <nl> < Filter > util \ Header Files < / Filter > <nl> < / ClInclude > <nl> mmm a / src / mongo / dbtests / test . vcxproj <nl> ppp b / src / mongo / dbtests / test . vcxproj <nl> cscript / / Nologo " $ ( ProjectDir ) . . \ shell \ createCPPfromJavaScriptFiles . js " " $ ( Proj <nl> < ClInclude Include = " . . \ db \ matcher \ matcher . h " / > <nl> < ClInclude Include = " . . \ db \ matcher \ match_details . h " / > <nl> < ClInclude Include = " . . \ db \ matcher_covered . h " / > <nl> - < ClInclude Include = " . . \ db \ matcher_old . h " / > <nl> < ClInclude Include = " . . \ db \ memconcept . h " / > <nl> < ClInclude Include = " . . \ db \ module . h " / > <nl> < ClInclude Include = " . . \ db \ mongommf . h " / > <nl> cscript / / Nologo " $ ( ProjectDir ) . . \ shell \ createCPPfromJavaScriptFiles . js " " $ ( Proj <nl> < ExcludedFromBuild Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Win2008PlusDebug | x64 ' " > true < / ExcludedFromBuild > <nl> < ExcludedFromBuild Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Win2008PlusRelease | x64 ' " > true < / ExcludedFromBuild > <nl> < / ClCompile > <nl> - < ClCompile Include = " . . \ db \ matcher_old . cpp " > <nl> - < ExcludedFromBuild Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | Win32 ' " > true < / ExcludedFromBuild > <nl> - < ExcludedFromBuild Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Release | Win32 ' " > true < / ExcludedFromBuild > <nl> - < ExcludedFromBuild Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Win2008PlusDebug | Win32 ' " > true < / ExcludedFromBuild > <nl> - < ExcludedFromBuild Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Win2008PlusRelease | Win32 ' " > true < / ExcludedFromBuild > <nl> - < ExcludedFromBuild Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | x64 ' " > true < / ExcludedFromBuild > <nl> - < ExcludedFromBuild Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Release | x64 ' " > true < / ExcludedFromBuild > <nl> - < ExcludedFromBuild Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Win2008PlusDebug | x64 ' " > true < / ExcludedFromBuild > <nl> - < ExcludedFromBuild Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Win2008PlusRelease | x64 ' " > true < / ExcludedFromBuild > <nl> - < / ClCompile > <nl> < ClCompile Include = " . . \ db \ mongommf . cpp " / > <nl> < ClCompile Include = " . . \ db \ namespace_details . cpp " / > <nl> < ClCompile Include = " . . \ db \ ops \ count . cpp " / > <nl> cscript / / Nologo " $ ( ProjectDir ) . . \ shell \ createCPPfromJavaScriptFiles . js " " $ ( Proj <nl> < ClCompile Include = " . . \ db \ jsobj . cpp " / > <nl> < ClCompile Include = " . . \ db \ json . cpp " / > <nl> < ClCompile Include = " . . \ db \ lasterror . cpp " / > <nl> - < ClCompile Include = " . . \ db \ matcher . cpp " / > <nl> < ClCompile Include = " . . \ scripting \ bench . cpp " / > <nl> < ClCompile Include = " . . \ s \ chunk . cpp " / > <nl> < ClCompile Include = " . . \ s \ config . cpp " / > <nl> mmm a / src / mongo / dbtests / test . vcxproj . filters <nl> ppp b / src / mongo / dbtests / test . vcxproj . filters <nl> <nl> < ClInclude Include = " . . \ db \ matcher_covered . h " > <nl> < Filter > db \ Header Files \ e to n < / Filter > <nl> < / ClInclude > <nl> - < ClInclude Include = " . . \ db \ matcher_old . h " > <nl> - < Filter > db \ Header Files \ e to n < / Filter > <nl> - < / ClInclude > <nl> < ClInclude Include = " . . \ db \ ops \ modifier_inc . h " > <nl> < Filter > db \ ops < / Filter > <nl> < / ClInclude > <nl> <nl> < ClCompile Include = " . . \ db \ lasterror . cpp " > <nl> < Filter > db \ Source Files \ e to n < / Filter > <nl> < / ClCompile > <nl> - < ClCompile Include = " . . \ db \ matcher . cpp " > <nl> - < Filter > db \ Source Files \ e to n < / Filter > <nl> - < / ClCompile > <nl> < ClCompile Include = " . . \ db \ matcher_covered . cpp " > <nl> < Filter > db \ Source Files \ e to n < / Filter > <nl> < / ClCompile > <nl> <nl> < ClCompile Include = " . . \ db \ ops \ modifier_unset_test . cpp " > <nl> < Filter > db \ ops < / Filter > <nl> < / ClCompile > <nl> - < ClCompile Include = " . . \ db \ matcher_old . cpp " > <nl> - < Filter > db \ Source Files \ e to n < / Filter > <nl> - < / ClCompile > <nl> < ClCompile Include = " . . \ db \ ops \ modifier_inc . cpp " > <nl> < Filter > db \ ops < / Filter > <nl> < / ClCompile > <nl> mmm a / src / mongo / s / mongos . vcxproj <nl> ppp b / src / mongo / s / mongos . vcxproj <nl> cscript / / Nologo " $ ( ProjectDir ) . . \ shell \ createCPPfromJavaScriptFiles . js " " $ ( Proj <nl> < ClCompile Include = " . . \ db \ jsobj . cpp " / > <nl> < ClCompile Include = " . . \ db \ json . cpp " / > <nl> < ClCompile Include = " . . \ db \ lasterror . cpp " / > <nl> - < ClCompile Include = " . . \ db \ matcher . cpp " / > <nl> < ClCompile Include = " . . \ util \ md5 . cpp " / > <nl> < ClCompile Include = " . . \ util \ md5main . cpp " / > <nl> < ClCompile Include = " . . \ util \ net \ message . cpp " / > <nl> mmm a / src / mongo / s / mongos . vcxproj . filters <nl> ppp b / src / mongo / s / mongos . vcxproj . filters <nl> <nl> < ClCompile Include = " . . \ db \ lasterror . cpp " > <nl> < Filter > db \ Source Files < / Filter > <nl> < / ClCompile > <nl> - < ClCompile Include = " . . \ db \ matcher . cpp " > <nl> - < Filter > db \ Source Files < / Filter > <nl> - < / ClCompile > <nl> < ClCompile Include = " . . \ db \ projection . cpp " > <nl> < Filter > db \ Source Files < / Filter > <nl> < / ClCompile > <nl> | Visual Studio - - remove db / matcher_old . { cpp , h } and leftover reference | mongodb/mongo | 76803bccc0206503b1641fe4222c90bcb82331d0 | 2013-06-25T10:30:05Z |
new file mode 100644 <nl> index 000000000000 . . 9f65ff65739f <nl> mmm / dev / null <nl> ppp b / validation - test / compiler_crashers_2 / 0124 - sr5825 . swift <nl> <nl> + / / RUN : not - - crash % target - swift - frontend % s - emit - ir <nl> + <nl> + struct DefaultAssociatedType { <nl> + } <nl> + <nl> + protocol Protocol { <nl> + associatedtype AssociatedType = DefaultAssociatedType <nl> + init ( object : AssociatedType ) <nl> + } <nl> + <nl> + final class Conformance : Protocol { <nl> + private let object : AssociatedType <nl> + init ( object : AssociatedType ) { <nl> + self . object = object <nl> + } <nl> + } <nl> | Add compiler crasher from SR - 5825 | apple/swift | 9c3d6ce26517b73e7cdaf393c57a56fdf493b72a | 2017-10-03T17:24:26Z |
mmm a / modules / dnn / src / torch / torch_importer . cpp <nl> ppp b / modules / dnn / src / torch / torch_importer . cpp <nl> struct TorchImporter <nl> return CV_16S ; <nl> else if ( typeStr = = " Int " ) <nl> return CV_32S ; <nl> - else if ( typeStr = = " Long " ) / / Carefully ! CV_64S type coded as CV_USRTYPE1 <nl> - return CV_USRTYPE1 ; <nl> + else if ( typeStr = = " Long " ) / / Carefully ! CV_64S type coded as CV_32SC2 <nl> + return CV_32SC2 ; <nl> else <nl> CV_Error ( Error : : StsNotImplemented , " Unknown type \ " " + typeStr + " \ " of torch class \ " " + str + " \ " " ) ; <nl> } <nl> struct TorchImporter <nl> void readTorchStorage ( int index , int type = - 1 ) <nl> { <nl> long size = readLong ( ) ; <nl> - Mat storageMat ( 1 , size , ( type ! = CV_USRTYPE1 ) ? type : CV_64F ) ; / / handle LongStorage as CV_64F Mat <nl> + Mat storageMat ( 1 , size , ( type ! = CV_32SC2 ) ? type : CV_64F ) ; / / handle LongStorage as CV_64F Mat <nl> <nl> switch ( type ) <nl> { <nl> struct TorchImporter <nl> case CV_32S : <nl> THFile_readIntRaw ( file , ( int * ) storageMat . data , size ) ; <nl> break ; <nl> - case CV_USRTYPE1 : <nl> + case CV_32SC2 : <nl> { <nl> double * buf = storageMat . ptr < double > ( ) ; <nl> THFile_readLongRaw ( file , ( int64 * ) buf , size ) ; <nl> | Replace CV_USRTYPE1 for int64 to CV_32SC2 in Torch importer | opencv/opencv | a7b3d2581fe22f2afb9a87782eb1ca1215b5b606 | 2018-09-17T09:31:09Z |
mmm a / core / ustring . h <nl> ppp b / core / ustring . h <nl> class CharString : public Vector < char > { <nl> operator const char * ( ) { return get_data ( ) ; } ; <nl> } ; <nl> <nl> - # ifndef CHARTYPE_16BITS <nl> + <nl> typedef wchar_t CharType ; <nl> - # else <nl> - typedef wchar_t uint16_t ; <nl> - # endif <nl> + <nl> <nl> struct StrRange { <nl> <nl> mmm a / core / variant . cpp <nl> ppp b / core / variant . cpp <nl> Variant : : operator unsigned char ( ) const { <nl> <nl> return 0 ; <nl> } <nl> - # ifndef CHARTYPE_16BITS <nl> + <nl> Variant : : operator CharType ( ) const { <nl> <nl> return operator unsigned int ( ) ; <nl> } <nl> - # endif <nl> + <nl> <nl> Variant : : operator float ( ) const { <nl> <nl> mmm a / core / variant . h <nl> ppp b / core / variant . h <nl> class Variant { <nl> operator unsigned long ( ) const ; <nl> # endif <nl> <nl> - # ifndef CHARTYPE_16BITS <nl> + <nl> operator CharType ( ) const ; <nl> - # endif <nl> operator float ( ) const ; <nl> operator double ( ) const ; <nl> operator String ( ) const ; <nl> | Remove CHARTYPE_16BITS unused checks | godotengine/godot | a95a1f47a45a5d8595c6681c28abd31ab0635479 | 2016-06-18T22:12:31Z |
mmm a / lib / timidity / timidity / readmidi . c <nl> ppp b / lib / timidity / timidity / readmidi . c <nl> static int set_xg_reverb_type ( int msb , int lsb ) <nl> break ; <nl> case 0x03 : <nl> type = 3 ; / * Stage 1 - > Hall 1 * / <nl> + break ; <nl> case 0x04 : <nl> type = 5 ; / * Plate * / <nl> break ; <nl> | timidity : Fix " Stage 1 - > Hall 1 " reverb effect type | xbmc/xbmc | 167b438cab3a66794a82429c533cb979bebc6368 | 2014-08-25T19:18:54Z |
mmm a / docs / LangRef . html <nl> ppp b / docs / LangRef . html <nl> < h2 id = " expr " > Expressions < / h2 > <nl> < a href = " # expr - cast " > cast operator < / a > . <nl> <nl> < ! - - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = - - > <nl> - < h3 id = " expr - cast " > Cast Operators < / h3 > <nl> + < h3 id = " expr - binary " > Binary Operators < / h3 > <nl> < ! - - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = - - > <nl> <nl> + < div class = " commentary " > <nl> + Should this use the expr - identifier production to allow qualified <nl> + identifiers ? This would allow " foo swift . + bar " . Is ADL or something <nl> + like it enough ? < br > < br > <nl> + < / div > <nl> + <nl> < pre class = " grammar " > <nl> + expr - binary : : = op - binary - or - ternary < a href = " # expr - unary " > expr - unary < / a > expr - cast ? <nl> + <nl> + op - binary - or - ternary : : = < a href = " # operator " > operator - binary < / a > <nl> + op - binary - or - ternary : : = ' = ' <nl> + op - binary - or - ternary : : = ' ? ' < a href = " # expr " > expr - sequence < / a > ' : ' <nl> + <nl> expr - cast : : = ' is ' < a href = " # type " > type < / a > <nl> expr - cast : : = ' as ' < a href = " # type " > type < / a > <nl> expr - cast : : = ' as ' ' ! ' < a href = " # type " > type < / a > <nl> < / pre > <nl> <nl> - Cast expressions influence the types of their subexpressions . <nl> + < p > Infix binary expressions are not formed during parsing . Instead , <nl> + they are formed after name resolution by building a tree from an <nl> + operator - delimited sequence of unary expressions . Precedence and <nl> + associativity are determined by the < a href = " # attribute - infix " > infix < / a > <nl> + attribute on the resolved names , which must fully agree . < / p > <nl> + <nl> + < p > If an operator is used as a binary operator , but name resolution <nl> + does not find at least one function of binary operator type , the <nl> + expression is ill - formed . < / p > <nl> + <nl> + < p > A simple example is : < / p > <nl> + <nl> + < pre class = " example " > <nl> + 4 + 5 * 123 <nl> + < / pre > <nl> + <nl> + < ! - - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = - - > <nl> + < h3 id = " expr - binary - builtin " > Builtin Binary Operators < / h3 > <nl> + < ! - - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = - - > <nl> + <nl> + < p > In addition to user - defined operators , a handful of builtin operators are <nl> + defined that parse inside binary expressions with predefined precedence and <nl> + associativity . <nl> + <nl> + < h4 id = " expr - assign " > Assignment operator < / h4 > <nl> + <nl> + < p > The assignment operator < tt > a = b < / tt > updates the value of < tt > a < / tt > with <nl> + the value of < tt > b < / tt > . Its precedence is hardcoded as if declared as <nl> + follows : < / p > <nl> + <nl> + < pre class = " example " > <nl> + / / Not valid Swift code <nl> + operator infix = { <nl> + precedence 90 <nl> + associativity right <nl> + } <nl> + < / pre > <nl> + <nl> + The left - hand operand must be an lvalue , or a tuple of lvalues . Assigning to <nl> + a tuple of lvalues performs destructuring reassignment . <nl> + <nl> + < pre class = " example " > <nl> + var ( a , b ) = ( 1 , 2 ) <nl> + <nl> + / / Swap two values . <nl> + ( a , b ) = ( b , a ) <nl> + <nl> + / / Reassign two values . <nl> + ( a , b ) = ( 11 , 22 ) <nl> + <nl> + / / Reassign two values by destructuring a tuple . <nl> + var tuple = ( 111 , 222 ) <nl> + ( a , b ) = tuple <nl> + < / pre > <nl> + <nl> + < h4 id = " expr - ternary " > Ternary operator < / h4 > <nl> + <nl> + < p > The ternary operator < tt > a ? b : c < / tt > conditionally evaluates its middle <nl> + or right operand based on the value of its left operand . Its precedence is <nl> + hardcoded as if the middle < tt > ? b : < / tt > subexpression were a binary operator <nl> + declared as follows : < / p > <nl> + <nl> + < pre class = " example " > <nl> + / / Not valid Swift code <nl> + operator infix ? . . . : { <nl> + precedence 100 <nl> + associativity right <nl> + } <nl> + < / pre > <nl> + <nl> + < p > The subexpression to the left of the <nl> + ' ? ' is evaluated , and is converted to ' Bool ' using the result ' s <nl> + ' getLogicValue ' method if it is not already ' Bool ' . If the condition is <nl> + true , the subexpression to the right of ' ? ' is evaluated , and its result <nl> + becomes the result of the expression . If the <nl> + condition is false , the subexpression to the right of ' : ' is evaluated , and <nl> + its result becomes the result of the expression . Only one of the <nl> + ' ? ' or ' : ' subexpressions will be evaluated . The results of the <nl> + ' ? ' and ' : ' subexpressions must be implicitly convertible to a common type , <nl> + which becomes the type of the ternary expression . <nl> + <nl> + < pre class = " example " > <nl> + x + = b ? y : z <nl> + x + = a ? b ? y : z : w <nl> + <nl> + for i in 1 . . 101 { <nl> + println ( i % 15 ? " fizzbuzz " <nl> + : i % 3 = = 0 ? " fizz " <nl> + : i % 5 = = 0 ? " buzz " <nl> + : " \ ( i ) " ) <nl> + } <nl> + < / pre > <nl> + <nl> + < h4 id = " expr - cast " > Cast Operators < / h4 > <nl> + <nl> + < p > Cast expressions influence the types of their subexpressions . They can appear <nl> + at the end of a binary operator sequence ; their left operand is parsed as if <nl> + the cast operator has a fixed precedence of 95 ( above assignment , but below <nl> + the ternary ) and no associativity , as if declared : < / p > <nl> + <nl> + < pre class = " example " > <nl> + / / Not valid Swift code <nl> + operator infix as { <nl> + precedence 95 <nl> + associativity none <nl> + } <nl> + < / pre > <nl> + <nl> + < p > The right operand of all operators is parsed as a type . < / p > <nl> <nl> < ul > <nl> < li > < tt > x as T < / tt > will coerce the expression < tt > x < / tt > to the type T . <nl> < h3 id = " expr - cast " > Cast Operators < / h3 > <nl> ( b is D ) ? ( b as ! D ) : new D <nl> < / pre > <nl> <nl> - < ! - - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = - - > <nl> - < h3 id = " expr - binary " > Binary Operators < / h3 > <nl> - < ! - - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = - - > <nl> - <nl> - < div class = " commentary " > <nl> - Should this use the expr - identifier production to allow qualified <nl> - identifiers ? This would allow " foo swift . + bar " . Is ADL or something <nl> - like it enough ? < br > < br > <nl> - < / div > <nl> - <nl> - < pre class = " grammar " > <nl> - expr - binary : : = operator - binary - or - ternary < a href = " # expr - unary " > expr - unary < / a > <nl> - <nl> - op - binary - or - ternary : : = < a href = " # operator " > operator - binary < / a > <nl> - op - binary - or - ternary : : = ' ? ' < a href = " # expr " > expr - sequence < / a > ' : ' <nl> - < / pre > <nl> - <nl> - < p > Infix binary expressions are not formed during parsing . Instead , <nl> - they are formed after name resolution by building a tree from an <nl> - operator - delimited sequence of unary expressions . Precedence and <nl> - associativity are determined by the < a href = " # attribute - infix " > infix < / a > <nl> - attribute on the resolved names , which must fully agree . < / p > <nl> - <nl> - < p > If an operator is used as a binary operator , but name resolution <nl> - does not find at least one function of binary operator type , the <nl> - expression is ill - formed . < / p > <nl> - <nl> - < p > A simple example is : < / p > <nl> - <nl> - < pre class = " example " > <nl> - 4 + 5 * 123 <nl> - < / pre > <nl> - <nl> - < h4 id = " expr - ternary " > Ternary operator < / h4 > <nl> - <nl> - < p > The ternary operator < tt > a ? b : c < / tt > is hardcoded as a conditional <nl> - operator . The subexpression to the left of the <nl> - ' ? ' is evaluated , and is converted to ' Bool ' using the result ' s <nl> - ' getLogicValue ' method if it is not already ' Bool ' . If the condition is <nl> - true , the subexpression to the right of ' ? ' is evaluated , and its result <nl> - becomes the result of the expression . If the <nl> - condition is false , the subexpression to the right of ' : ' is evaluated , and <nl> - its result becomes the result of the expression . Only one of the <nl> - ' ? ' or ' : ' subexpressions will be evaluated . The results of the <nl> - ' ? ' and ' : ' subexpressions must be implicitly convertible to a common type , <nl> - which becomes the type of the ternary expression . <nl> - <nl> - < p > Ternary parsing is handled as part of sequence expression folding . The <nl> - middle arm of the ternary is parsed maximal - munch as a sequence <nl> - expression from the ' ? ' up to the matching ' : ' . The < tt > ? . . . : < / tt > sequence <nl> - then participates in binary operator folding as if it were a single binary <nl> - operator with fixed precedence of 100 and right associativity . < / p > <nl> - <nl> - < pre class = " example " > <nl> - x + = b ? y : z <nl> - x + = a ? b ? y : z : w <nl> - <nl> - for i in 1 . . 101 { <nl> - println ( i % 15 ? " fizzbuzz " <nl> - : i % 3 = = 0 ? " fizz " <nl> - : i % 5 = = 0 ? " buzz " <nl> - : " \ ( i ) " ) <nl> - } <nl> - < / pre > <nl> - <nl> < ! - - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = - - > <nl> < h3 id = " expr - unary " > Unary Operators < / h3 > <nl> < ! - - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = - - > <nl> < h2 id = " stmt " > Statements < / h2 > <nl> <nl> < pre class = " grammar " > <nl> stmt : : = < a href = " # stmt - semicolon " > stmt - semicolon < / a > <nl> - stmt : : = < a href = " # stmt - assign " > stmt - assign < / a > <nl> stmt : : = < a href = " # stmt - return " > stmt - return < / a > <nl> stmt : : = < a href = " # stmt - if " > stmt - if < / a > <nl> stmt : : = < a href = " # stmt - while " > stmt - while < / a > <nl> < h3 id = " stmt - semicolon " > Semicolon Statement < / h3 > <nl> <nl> < p > The semicolon statement has no effect . < / p > <nl> <nl> - < ! - - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = - - > <nl> - < h3 id = " stmt - assign " > Assignment Statement < / h3 > <nl> - < ! - - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = - - > <nl> - <nl> - < div class = " commentary " > <nl> - The requirement that ' = ' can only be used as a statement means that the <nl> - following is inherently illegal : <nl> - <nl> - < pre > if ( x = 1 ) < / pre > <nl> - <nl> - It also implies that nested assignments are also illegal : <nl> - <nl> - < pre > x = y = z < / pre > <nl> - <nl> - < / div > <nl> - <nl> - < pre class = " grammar " > <nl> - stmt - assign : : = < a href = " # expr " > expr < / a > ' = ' < a href = " # expr " > expr < / a > <nl> - stmt - assign - basic : : = < a href = " # expr " > expr - basic < / a > ' = ' < a href = " # expr " > expr - basic < / a > <nl> - < / pre > <nl> - <nl> - < p > The assignment statement evaluates its left hand side as some sort of <nl> - lvalue , then evaluates the right hand side , the assigns one to the other . <nl> - FIXME : The requirements for lvalues should be described , and tied into a <nl> - description of lvalue types . <nl> - < / p > <nl> - <nl> - <nl> < ! - - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = - - > <nl> < h3 id = " stmt - return " > ' return ' Statement < / h3 > <nl> < ! - - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = - - > <nl> < h3 id = " stmt - for - c - style " > C - Style ' for ' Statement < / h3 > <nl> < ! - - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = - - > <nl> <nl> < pre class = " grammar " > <nl> - stmt - for - c - style : : = ' for ' stmt - for - c - style - init ? ' ; ' < a href = " # expr " > expr < / a > ? ' ; ' expr - or - stmt - assign - basic ? < a href = " # brace - item - list " > brace - item - list < / a > <nl> - expr - or - stmt - assign - basic : : = < a href = " # expr " > expr - basic < / a > | < a href = " # stmt - assign " > stmt - assign - basic < / a > <nl> + stmt - for - c - style : : = ' for ' stmt - for - c - style - init ? ' ; ' < a href = " # expr " > expr < / a > ? ' ; ' expr - basic ? < a href = " # brace - item - list " > brace - item - list < / a > <nl> stmt - for - c - style - init : : = < a href = " # decl - var " > decl - var < / a > <nl> - stmt - for - c - style - init : : = expr - or - stmt - assign <nl> + stmt - for - c - style - init : : = expr <nl> < / pre > <nl> <nl> < p > C - Style ' for ' statements provide simple loop construct which evaluates the <nl> | LangRef : Update assign / cast operator descriptions . | apple/swift | 44790622c62ab2709f56e1441586ccee0c4a0e27 | 2013-06-10T16:20:39Z |
mmm a / test / mjsunit / count - based - osr . js <nl> ppp b / test / mjsunit / count - based - osr . js <nl> <nl> <nl> function osr_this ( ) { <nl> var a = 1 ; <nl> - / / Trigger OSR . First check if optimization is disabled . <nl> - if ( % GetOptimizationStatus ( osr_this ) = = 4 ) return 1 ; <nl> - while ( % GetOptimizationCount ( osr_this ) = = 0 ) { } <nl> + while ( % GetOptimizationCount ( osr_this ) = = 2 ) ; <nl> return a ; <nl> } <nl> assertEquals ( 1 , osr_this ( ) ) ; <nl> + assertEquals ( 1 , osr_this ( ) ) ; <nl> mmm a / test / mjsunit / regress / binop - in - effect - context - deopt . js <nl> ppp b / test / mjsunit / regress / binop - in - effect - context - deopt . js <nl> <nl> function f ( a , deopt , osr ) { <nl> var result = ( a + 10 , " result " ) ; <nl> var dummy = deopt + 0 ; <nl> - if ( osr ) while ( % GetOptimizationStatus ( f ) = = 2 ) { } <nl> + for ( var i = 0 ; osr & & i < 2 ; i + + ) % OptimizeOsr ( ) ; <nl> return result ; <nl> } <nl> <nl> mmm a / test / mjsunit / regress / call - function - in - effect - context - deopt . js <nl> ppp b / test / mjsunit / regress / call - function - in - effect - context - deopt . js <nl> function f ( deopt , osr ) { <nl> var result = " result " ; <nl> % _CallFunction ( 0 , 0 , function ( ) { } ) ; <nl> var dummy = deopt + 0 ; <nl> - if ( osr ) while ( % GetOptimizationStatus ( f ) = = 2 ) { } <nl> + for ( var i = 0 ; osr & & i < 2 ; i + + ) % OptimizeOsr ( ) ; <nl> return result ; <nl> } <nl> <nl> mmm a / test / mjsunit / regress / regress - 1118 . js <nl> ppp b / test / mjsunit / regress / regress - 1118 . js <nl> var o = new A ( ) ; <nl> / / inlined . <nl> function g ( ) { try { return o . f ( ) ; } finally { } } <nl> <nl> - / / Optimization status ( see runtime . cc ) : <nl> - / / 1 - yes , 2 - no , 3 - always , 4 - never . <nl> - <nl> / / This function should be optimized via OSR . <nl> function h ( ) { <nl> - var optstatus = % GetOptimizationStatus ( h ) ; <nl> - if ( optstatus = = 4 ) { <nl> - / / Optimizations are globally disabled ; just run once . <nl> - g ( ) ; <nl> - } else { <nl> - / / Run for a bit as long as h is unoptimized . <nl> - if ( % GetOptimizationStatus ( h ) ! = 4 ) { <nl> - while ( % GetOptimizationCount ( h ) = = 0 ) { <nl> - for ( var j = 0 ; j < 100 ; j + + ) g ( ) ; <nl> - } <nl> - } <nl> - g ( ) ; <nl> - } <nl> + for ( var i = 0 ; i < 10 ; i + + ) % OptimizeOsr ( ) ; <nl> + g ( ) ; <nl> } <nl> <nl> h ( ) ; <nl> mmm a / test / mjsunit / regress / regress - 2618 . js <nl> ppp b / test / mjsunit / regress / regress - 2618 . js <nl> <nl> function f ( ) { <nl> do { <nl> do { <nl> - for ( var i = 0 ; i < 10000000 ; i + + ) { <nl> - / / This should run long enough to trigger OSR . <nl> - } <nl> + for ( var i = 0 ; i < 10 ; i + + ) % OptimizeOsr ( ) ; <nl> } while ( false ) ; <nl> } while ( false ) ; <nl> } <nl> function g ( ) { <nl> do { <nl> do { <nl> do { <nl> - for ( var i = 0 ; i < 10000000 ; i + + ) { } <nl> + for ( var i = 0 ; i < 10 ; i + + ) % OptimizeOsr ( ) ; <nl> } while ( false ) ; <nl> } while ( false ) ; <nl> } while ( false ) ; <nl> mmm a / test / mjsunit / regress / regress - crbug - 150545 . js <nl> ppp b / test / mjsunit / regress / regress - crbug - 150545 . js <nl> <nl> <nl> function outer ( ) { <nl> inner ( 1 , 2 , 3 ) ; <nl> - / / Trigger OSR , if optimization is not disabled . <nl> - if ( % GetOptimizationStatus ( outer ) ! = 4 ) { <nl> - while ( % GetOptimizationCount ( outer ) = = 0 ) { } <nl> - } <nl> + for ( var i = 0 ; i < 3 ; i + + ) % OptimizeOsr ( ) ; <nl> } <nl> <nl> outer ( ) ; <nl> mmm a / test / mjsunit / regress / string - set - char - deopt . js <nl> ppp b / test / mjsunit / regress / string - set - char - deopt . js <nl> <nl> var world = " world " ; <nl> % _OneByteSeqStringSetChar ( 0 , ( deopt ( ) , 0x48 ) , string ) ; <nl> <nl> - if ( osr ) while ( % GetOptimizationStatus ( f ) = = 2 ) { } <nl> + for ( var i = 0 ; osr & & i < 2 ; i + + ) % OptimizeOsr ( ) ; <nl> <nl> return string + world ; <nl> } <nl> | Remove some busy - OSR loops from tests using % OptimizeOsr ( ) . | v8/v8 | 9030a2674ba6a1e1b3d9cc88299e2d5aebd22660 | 2015-02-09T14:11:23Z |
mmm a / cocos / audio / android / AudioEngine - inl . cpp <nl> ppp b / cocos / audio / android / AudioEngine - inl . cpp <nl> void AudioEngineImpl : : preload ( const std : : string & filePath , std : : function < void ( bo <nl> CCLOG ( " Preload not support on Anroid " ) ; <nl> if ( callback ) <nl> { <nl> - callback ( false ) ; <nl> + callback ( true ) ; <nl> } <nl> } <nl> <nl> | Merge pull request from minggo / andriod - preload | cocos2d/cocos2d-x | 7828b505fe80e7a2e7f1a32609d1841ce88f2f27 | 2016-06-22T10:19:09Z |
mmm a / xbmc / pvr / epg / Epg . cpp <nl> ppp b / xbmc / pvr / epg / Epg . cpp <nl> bool CPVREpg : : FixOverlappingEvents ( bool bUpdateDb / * = false * / ) <nl> <nl> bool CPVREpg : : UpdateFromScraper ( time_t start , time_t end ) <nl> { <nl> - bool bGrabSuccess = false ; <nl> - if ( ScraperName ( ) = = " client " ) <nl> + if ( m_strScraperName . empty ( ) ) <nl> + { <nl> + CLog : : Log ( LOGERROR , " EPG - % s - no EPG scraper defined for table ' % s ' " , __FUNCTION__ , m_strName . c_str ( ) ) ; <nl> + } <nl> + else if ( m_strScraperName = = " client " ) <nl> { <nl> const CPVRChannelPtr channel = Channel ( ) ; <nl> - if ( ! channel ) <nl> - { <nl> - CLog : : Log ( LOGWARNING , " EPG - % s - channel not found , can ' t update " , __FUNCTION__ ) ; <nl> - return bGrabSuccess ; <nl> - } <nl> - <nl> - const CPVRClientPtr client = CServiceBroker : : GetPVRManager ( ) . GetClient ( channel - > ClientID ( ) ) ; <nl> - if ( ! channel - > EPGEnabled ( ) ) <nl> - { <nl> - bGrabSuccess = true ; <nl> - } <nl> - else if ( channel - > IsHidden ( ) ) <nl> + if ( channel ) <nl> { <nl> - bGrabSuccess = true ; <nl> - } <nl> - <nl> + if ( ! channel - > EPGEnabled ( ) | | channel - > IsHidden ( ) ) <nl> + { <nl> + / / ignore . not interested in any updates . <nl> + return true ; <nl> + } <nl> <nl> - else if ( client & & ! client - > GetClientCapabilities ( ) . SupportsEPG ( ) ) <nl> - { <nl> - CLog : : Log ( LOGDEBUG , " EPG - % s - the backend for channel ' % s ' on client ' % i ' does not support EPGs " , __FUNCTION__ , channel - > ChannelName ( ) . c_str ( ) , channel - > ClientID ( ) ) ; <nl> + const CPVRClientPtr client = CServiceBroker : : GetPVRManager ( ) . GetClient ( channel - > ClientID ( ) ) ; <nl> + if ( client ) <nl> + { <nl> + if ( ! client - > GetClientCapabilities ( ) . SupportsEPG ( ) ) <nl> + { <nl> + CLog : : Log ( LOGERROR , " EPG - % s - the backend for channel ' % s ' on client ' % i ' does not support EPGs " , __FUNCTION__ , channel - > ChannelName ( ) . c_str ( ) , channel - > ClientID ( ) ) ; <nl> + } <nl> + else <nl> + { <nl> + CLog : : Log ( LOGDEBUG , " EPG - % s - updating EPG for channel ' % s ' from client ' % i ' " , __FUNCTION__ , channel - > ChannelName ( ) . c_str ( ) , channel - > ClientID ( ) ) ; <nl> + return ( client - > GetEPGForChannel ( channel , this , start , end ) = = PVR_ERROR_NO_ERROR ) ; <nl> + } <nl> + } <nl> + else <nl> + { <nl> + CLog : : Log ( LOGERROR , " EPG - % s - client ' % i ' not found , can ' t update " , __FUNCTION__ , channel - > ClientID ( ) ) ; <nl> + } <nl> } <nl> - else if ( client ) <nl> + else <nl> { <nl> - CLog : : Log ( LOGDEBUG , " EPG - % s - updating EPG for channel ' % s ' from client ' % i ' " , __FUNCTION__ , channel - > ChannelName ( ) . c_str ( ) , channel - > ClientID ( ) ) ; <nl> - bGrabSuccess = ( client - > GetEPGForChannel ( channel , this , start , end ) = = PVR_ERROR_NO_ERROR ) ; <nl> + CLog : : Log ( LOGERROR , " EPG - % s - channel not found , can ' t update " , __FUNCTION__ ) ; <nl> } <nl> } <nl> - else if ( m_strScraperName . empty ( ) ) / * no grabber defined * / <nl> - CLog : : Log ( LOGWARNING , " EPG - % s - no EPG scraper defined for table ' % s ' " , __FUNCTION__ , m_strName . c_str ( ) ) ; <nl> - else <nl> + else / / other non - empty scraper name . . . <nl> { <nl> - CLog : : Log ( LOGINFO , " EPG - % s - updating EPG table ' % s ' with scraper ' % s ' " , __FUNCTION__ , m_strName . c_str ( ) , m_strScraperName . c_str ( ) ) ; <nl> - CLog : : Log ( LOGWARNING , " loading the EPG via scraper has not been implemented yet " ) ; <nl> + CLog : : Log ( LOGERROR , " Loading the EPG via scraper has not been implemented yet ! " ) ; <nl> / / ! @ todo Add Support for Web EPG Scrapers here <nl> } <nl> <nl> - return bGrabSuccess ; <nl> + return false ; <nl> } <nl> <nl> / / @ } <nl> | [ PVR ] Rewrite CPVREpg : : UpdateFromScraper for better readability . | xbmc/xbmc | 2e6530b49299c9f559177e0d92abe2d3ada7bb10 | 2018-06-13T13:43:59Z |
mmm a / 3rdParty / V8 / CMakeLists . txt <nl> ppp b / 3rdParty / V8 / CMakeLists . txt <nl> elseif ( WIN32 ) <nl> <nl> list ( APPEND V8_GYP_ARGS " - GGYP_GENERATORS = msvs " ) <nl> list ( APPEND V8_GYP_ARGS " - Dmsvs_cygwin_shell = 0 " ) <nl> + list ( APPEND V8_GYP_ARGS " - Dv8_use_snapshot = false " ) <nl> <nl> if ( " $ { BITS } " STREQUAL " 64 " ) <nl> set ( MS_TARGET_PLATFORM x64 ) <nl> elseif ( WIN32 ) <nl> SOURCE_DIR <nl> " $ { V8_DIR } " <nl> CONFIGURE_COMMAND <nl> - $ { PYTHON_EXECUTABLE } $ { GYP_MAIN } $ { V8_GYP_ARGS } - Dmode = $ { MS_TARGET_CONF_LOWER } <nl> + $ { CMAKE_COMMAND } - E env GYP_GENERATORS = msvs GYP_MSVS_VERSION = 2015 DEPOT_TOOLS_WIN_TOOLCHAIN = 0 $ { PYTHON_EXECUTABLE } $ { GYP_MAIN } $ { V8_GYP_ARGS } - Dmode = $ { MS_TARGET_CONF_LOWER } <nl> BUILD_COMMAND <nl> " " <nl> INSTALL_COMMAND <nl> | fix windows compile | arangodb/arangodb | 1025b29b1a492bf7e795fa361c177d56561daf09 | 2017-02-07T16:14:05Z |
mmm a / editor / project_manager . cpp <nl> ppp b / editor / project_manager . cpp <nl> class ProjectDialog : public ConfirmationDialog { <nl> get_ok ( ) - > set_text ( TTR ( " Create & Edit " ) ) ; <nl> name_container - > show ( ) ; <nl> install_path_container - > hide ( ) ; <nl> - project_name - > grab_focus ( ) ; <nl> + project_name - > call_deferred ( " grab_focus " ) ; <nl> + project_name - > call_deferred ( " select_all " ) ; <nl> <nl> } else if ( mode = = MODE_INSTALL ) { <nl> <nl> | Merge pull request from qichunren / fixed_line_edit_lost_focus_when_create_new_project | godotengine/godot | efefe0be95a34eda142df9e2d051284b8fde4d96 | 2018-12-06T13:06:43Z |
mmm a / tools / cocos2d - console <nl> ppp b / tools / cocos2d - console <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit 41a1468b229eb1d93e382e54c70457940129cdc0 <nl> + Subproject commit d0208ac730d517dd5f9d4edb4c680933f7948fe9 <nl> | Merge pull request from SunLightJuly / v3_fix | cocos2d/cocos2d-x | f1429d21f8845a15a2e3eb29d4685906083bc618 | 2015-04-08T03:46:14Z |
mmm a / cocos / renderer / ccShader_3D_Terrain . frag <nl> ppp b / cocos / renderer / ccShader_3D_Terrain . frag <nl> <nl> <nl> const char * cc3D_Terrain_frag = STRINGIFY ( <nl> \ n # ifdef GL_ES \ n <nl> - precision lowp float ; <nl> + precision mediump float ; <nl> \ n # endif \ n <nl> uniform vec3 u_color ; \ n <nl> varying vec2 v_texCoord ; \ n <nl> varying vec3 v_normal ; \ n <nl> - uniform int u_has_alpha ; \ n <nl> - uniform int u_has_light_map ; \ n <nl> + uniform lowp int u_has_alpha ; \ n <nl> + uniform lowp int u_has_light_map ; \ n <nl> uniform sampler2D u_alphaMap ; \ n <nl> uniform sampler2D u_texture0 ; \ n <nl> uniform sampler2D u_texture1 ; \ n <nl> | correct wrong presion , which leads to failed on some devices | cocos2d/cocos2d-x | 907189ed14d1048c51205365ea5ffccdc5824d95 | 2015-10-15T03:59:38Z |
mmm a / src / gui / options_imp . cpp <nl> ppp b / src / gui / options_imp . cpp <nl> <nl> <nl> / / Constructor <nl> options_imp : : options_imp ( QWidget * parent ) <nl> - : QDialog ( parent ) , <nl> - m_refreshingIpFilter ( false ) <nl> + : QDialog ( parent ) <nl> + , m_refreshingIpFilter ( false ) <nl> { <nl> qDebug ( " - > Constructing Options " ) ; <nl> setupUi ( this ) ; <nl> options_imp : : options_imp ( QWidget * parent ) <nl> connect ( confirmDeletion , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ; <nl> connect ( checkAltRowColors , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ; <nl> connect ( checkHideZero , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ; <nl> + connect ( checkHideZero , SIGNAL ( toggled ( bool ) ) , comboHideZero , SLOT ( setEnabled ( bool ) ) ) ; <nl> connect ( comboHideZero , SIGNAL ( currentIndexChanged ( int ) ) , this , SLOT ( enableApplyButton ( ) ) ) ; <nl> connect ( checkShowSystray , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ; <nl> connect ( checkCloseToSystray , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ; <nl> options_imp : : options_imp ( QWidget * parent ) <nl> connect ( schedule_to , SIGNAL ( timeChanged ( QTime ) ) , this , SLOT ( enableApplyButton ( ) ) ) ; <nl> connect ( schedule_days , SIGNAL ( currentIndexChanged ( int ) ) , this , SLOT ( enableApplyButton ( ) ) ) ; <nl> connect ( checkuTP , SIGNAL ( toggled ( bool ) ) , SLOT ( enableApplyButton ( ) ) ) ; <nl> + connect ( checkuTP , SIGNAL ( toggled ( bool ) ) , checkLimituTPConnections , SLOT ( setEnabled ( bool ) ) ) ; <nl> connect ( checkLimituTPConnections , SIGNAL ( toggled ( bool ) ) , SLOT ( enableApplyButton ( ) ) ) ; <nl> connect ( checkLimitTransportOverhead , SIGNAL ( toggled ( bool ) ) , SLOT ( enableApplyButton ( ) ) ) ; <nl> connect ( checkLimitLocalPeerRate , SIGNAL ( toggled ( bool ) ) , SLOT ( enableApplyButton ( ) ) ) ; <nl> void options_imp : : loadOptions ( ) <nl> confirmDeletion - > setChecked ( pref - > confirmTorrentDeletion ( ) ) ; <nl> checkAltRowColors - > setChecked ( pref - > useAlternatingRowColors ( ) ) ; <nl> checkHideZero - > setChecked ( pref - > getHideZeroValues ( ) ) ; <nl> + comboHideZero - > setEnabled ( checkHideZero - > isChecked ( ) ) ; <nl> comboHideZero - > setCurrentIndex ( pref - > getHideZeroComboValues ( ) ) ; <nl> <nl> checkShowSplash - > setChecked ( ! pref - > isSplashScreenDisabled ( ) ) ; <nl> void options_imp : : loadOptions ( ) <nl> } <nl> <nl> checkuTP - > setChecked ( pref - > isuTPEnabled ( ) ) ; <nl> + checkLimituTPConnections - > setEnabled ( checkuTP - > isChecked ( ) ) ; <nl> checkLimituTPConnections - > setChecked ( pref - > isuTPRateLimited ( ) ) ; <nl> checkLimitTransportOverhead - > setChecked ( pref - > includeOverheadInLimits ( ) ) ; <nl> checkLimitLocalPeerRate - > setChecked ( ! pref - > getIgnoreLimitsOnLAN ( ) ) ; <nl> | Disable ` comboHideZero ` when ` checkHideZero ` is unchecked . | qbittorrent/qBittorrent | 2c2638c1fe78c8ad78156a0be80740c028d17278 | 2016-04-19T08:52:25Z |
mmm a / . ci / test . sh <nl> ppp b / . ci / test . sh <nl> if [ [ $ TASK = = " if - else " ] ] ; then <nl> exit 0 <nl> fi <nl> <nl> + if [ [ $ TASK = = " r - package " ] ] ; then <nl> + bash $ { BUILD_DIRECTORY } / . ci / test_r_package . sh | | exit - 1 <nl> + exit 0 <nl> + fi <nl> + <nl> conda install - q - y - n $ CONDA_ENV joblib matplotlib numpy pandas psutil pytest python - graphviz scikit - learn scipy <nl> <nl> if [ [ $ OS_NAME = = " macos " ] ] & & [ [ $ COMPILER = = " clang " ] ] ; then <nl> new file mode 100755 <nl> index 0000000000 . . 1570bdf021 <nl> mmm / dev / null <nl> ppp b / . ci / test_r_package . sh <nl> <nl> + # ! / bin / bash <nl> + <nl> + # set up R environment <nl> + R_LIB_PATH = ~ / Rlib <nl> + mkdir - p $ R_LIB_PATH <nl> + echo " R_LIBS = $ R_LIB_PATH " > $ { HOME } / . Renviron <nl> + echo ' options ( repos = " https : / / cran . rstudio . com " ) ' > $ { HOME } / . Rprofile <nl> + export PATH = " $ R_LIB_PATH / R / bin : $ PATH " <nl> + <nl> + # installing precompiled R for Ubuntu <nl> + # https : / / cran . r - project . org / bin / linux / ubuntu / # installation <nl> + # adding steps from https : / / stackoverflow . com / a / 56378217 / 3986677 to get latest version <nl> + # <nl> + # This only needs to get run on Travis because R environment for Linux <nl> + # used by Azure pipelines is set up in https : / / github . com / guolinke / lightgbm - ci - docker <nl> + if [ [ $ TRAVIS = = " true " ] ] & & [ [ $ OS_NAME = = " linux " ] ] ; then <nl> + sudo add - apt - repository \ <nl> + " deb https : / / cloud . r - project . org / bin / linux / ubuntu bionic - cran35 / " <nl> + sudo apt - key adv \ <nl> + - - keyserver keyserver . ubuntu . com \ <nl> + - - recv - keys E298A3A825C0D65DFD57CBB651716619E084DAB9 <nl> + sudo apt - get update <nl> + sudo apt - get install \ <nl> + - - no - install - recommends \ <nl> + - y \ <nl> + r - base - dev = $ { R_TRAVIS_LINUX_VERSION } \ <nl> + texinfo \ <nl> + texlive - latex - recommended \ <nl> + texlive - fonts - recommended \ <nl> + texlive - fonts - extra \ <nl> + qpdf \ <nl> + | | exit - 1 <nl> + fi <nl> + <nl> + # Installing R precompiled for Mac OS 10 . 11 or higher <nl> + if [ [ $ OS_NAME = = " macos " ] ] ; then <nl> + <nl> + brew install qpdf <nl> + brew cask install basictex <nl> + export PATH = " / Library / TeX / texbin : $ PATH " <nl> + sudo tlmgr update - - self <nl> + sudo tlmgr install inconsolata helvetic <nl> + <nl> + wget - q https : / / cran . r - project . org / bin / macosx / R - $ { R_MAC_VERSION } . pkg - O R . pkg <nl> + sudo installer \ <nl> + - pkg $ ( pwd ) / R . pkg \ <nl> + - target / <nl> + <nl> + # Fix " duplicate libomp versions " issue on Mac <nl> + # by replacing the R libomp . dylib with a symlink to the one installed with brew <nl> + if [ [ $ COMPILER = = " clang " ] ] ; then <nl> + ver_arr = ( $ { R_MAC_VERSION / / . / } ) <nl> + R_MAJOR_MINOR = " $ { ver_arr [ 0 ] } . $ { ver_arr [ 1 ] } " <nl> + sudo ln - sf \ <nl> + " $ ( brew - - cellar libomp ) " / * / lib / libomp . dylib \ <nl> + / Library / Frameworks / R . framework / Versions / $ { R_MAJOR_MINOR } / Resources / lib / libomp . dylib <nl> + fi <nl> + fi <nl> + <nl> + conda install \ <nl> + - y \ <nl> + - q \ <nl> + - - no - deps \ <nl> + pandoc <nl> + <nl> + # Manually install Depends and Imports libraries + ' testthat ' <nl> + # to avoid a CI - time dependency on devtools ( for devtools : : install_deps ( ) ) <nl> + Rscript - e " install . packages ( c ( ' data . table ' , ' jsonlite ' , ' Matrix ' , ' R6 ' , ' testthat ' ) ) " | | exit - 1 <nl> + <nl> + cd $ { BUILD_DIRECTORY } <nl> + Rscript build_r . R | | exit - 1 <nl> + <nl> + PKG_TARBALL = " lightgbm_ $ { LGB_VER } . tar . gz " <nl> + LOG_FILE_NAME = " lightgbm . Rcheck / 00check . log " <nl> + <nl> + # suppress R CMD check warning from Suggests dependencies not being available <nl> + export _R_CHECK_FORCE_SUGGESTS_ = 0 <nl> + <nl> + # fails tests if either ERRORs or WARNINGs are thrown by <nl> + # R CMD CHECK <nl> + R CMD check $ { PKG_TARBALL } \ <nl> + - - as - cran \ <nl> + | | exit - 1 <nl> + <nl> + if grep - q - R " WARNING " " $ LOG_FILE_NAME " ; then <nl> + echo " WARNINGS have been found by R CMD check ! " <nl> + exit - 1 <nl> + fi <nl> + <nl> + exit 0 <nl> mmm a / . travis . yml <nl> ppp b / . travis . yml <nl> env : <nl> - TASK = mpi METHOD = pip <nl> - TASK = gpu METHOD = source PYTHON_VERSION = 3 . 5 <nl> - TASK = gpu METHOD = pip PYTHON_VERSION = 3 . 6 <nl> + - TASK = r - package <nl> <nl> matrix : <nl> exclude : <nl> before_install : <nl> - if [ [ $ TRAVIS_OS_NAME = = " osx " ] ] ; then <nl> export OS_NAME = " macos " ; <nl> export COMPILER = " gcc " ; <nl> + export R_MAC_VERSION = 3 . 6 . 1 ; <nl> else <nl> export OS_NAME = " linux " ; <nl> export COMPILER = " clang " ; <nl> + export R_TRAVIS_LINUX_VERSION = 3 . 6 . 1 - 3bionic ; <nl> fi <nl> - export CONDA = " $ HOME / miniconda " <nl> - export PATH = " $ CONDA / bin : $ PATH " <nl> mmm a / . vsts - ci . yml <nl> ppp b / . vsts - ci . yml <nl> jobs : <nl> TASK : gpu <nl> METHOD : source <nl> PYTHON_VERSION : 3 . 6 <nl> + r_package : <nl> + TASK : r - package <nl> steps : <nl> - script : | <nl> echo " # # vso [ task . setvariable variable = HOME_DIRECTORY ] $ AGENT_HOMEDIRECTORY " <nl> jobs : <nl> PYTHON_VERSION : 3 . 5 <nl> bdist : <nl> TASK : bdist <nl> + r_package : <nl> + TASK : r - package <nl> steps : <nl> - script : | <nl> echo " # # vso [ task . setvariable variable = HOME_DIRECTORY ] $ AGENT_HOMEDIRECTORY " <nl> jobs : <nl> echo " # # vso [ task . setvariable variable = CONDA ] $ CONDA " <nl> echo " # # vso [ task . prependpath ] $ CONDA / bin " <nl> echo " # # vso [ task . setvariable variable = JAVA_HOME ] $ JAVA_HOME_8_X64 " <nl> + echo " # # vso [ task . setvariable variable = R_MAC_VERSION ] 3 . 6 . 1 " <nl> displayName : ' Set variables ' <nl> - bash : $ ( Build . SourcesDirectory ) / . ci / setup . sh <nl> displayName : Setup <nl> mmm a / R - package / . Rbuildignore <nl> ppp b / R - package / . Rbuildignore <nl> <nl> <nl> # Code copied in at build time <nl> ^ src / CMakeLists . txt $ <nl> + <nl> + # unnecessary files from submodules <nl> + ^ src / compute / . appveyor . yml $ <nl> + ^ src / compute / . coveralls . yml $ <nl> + ^ src / compute / . travis . yml $ <nl> + ^ src / compute / test / $ <nl> + ^ src / compute / index . html $ <nl> + ^ src / compute / . git $ <nl> + ^ src / compute / . gitignore $ <nl> + ^ src / compute / CONTRIBUTING . md $ <nl> + ^ src / compute / README . md $ <nl> mmm a / R - package / DESCRIPTION <nl> ppp b / R - package / DESCRIPTION <nl> Imports : <nl> jsonlite ( > = 1 . 0 ) , <nl> Matrix ( > = 1 . 1 - 0 ) , <nl> methods <nl> - RoxygenNote : 6 . 0 . 1 <nl> + RoxygenNote : 7 . 0 . 2 <nl> mmm a / R - package / man / lgb . cv . Rd <nl> ppp b / R - package / man / lgb . cv . Rd <nl> lgb . cv ( <nl> <nl> \ item { eval_freq } { evaluation output frequency , only effect when verbose > 0 } <nl> <nl> + \ item { showsd } { \ code { boolean } , whether to show standard deviation of cross validation } <nl> + <nl> \ item { stratified } { a \ code { boolean } indicating whether sampling of folds should be stratified <nl> by the values of outcome labels . } <nl> <nl> into a predictor model which frees up memory and the original datasets } <nl> the number of real CPU cores , not the number of threads ( most <nl> CPU using hyper - threading to generate 2 threads per CPU core ) . } <nl> } } <nl> - <nl> - \ item { showsd } { \ code { boolean } , whether to show standard deviation of cross validation } <nl> } <nl> \ value { <nl> a trained model \ code { lgb . CVBooster } . <nl> mmm a / R - package / man / lgb . prepare_rules2 . Rd <nl> ppp b / R - package / man / lgb . prepare_rules2 . Rd <nl> This is useful if you have a specific need for integer dataset instead of numeri <nl> Note that there are programs which do not support integer - only input . <nl> Consider this as a half memory technique which is dangerous , especially for LightGBM . <nl> } <nl> + \ examples { <nl> + library ( lightgbm ) <nl> + data ( iris ) <nl> + <nl> + str ( iris ) <nl> + <nl> + new_iris < - lgb . prepare_rules2 ( data = iris ) # Autoconverter <nl> + str ( new_iris $ data ) <nl> + <nl> + data ( iris ) # Erase iris dataset <nl> + iris $ Species [ 1L ] < - " NEW FACTOR " # Introduce junk factor ( NA ) <nl> + <nl> + # Use conversion using known rules <nl> + # Unknown factors become 0 , excellent for sparse datasets <nl> + newer_iris < - lgb . prepare_rules2 ( data = iris , rules = new_iris $ rules ) <nl> + <nl> + # Unknown factor is now zero , perfect for sparse datasets <nl> + newer_iris $ data [ 1L , ] # Species became 0 as it is an unknown factor <nl> + <nl> + newer_iris $ data [ 1L , 5L ] < - 1 . 0 # Put back real initial value <nl> + <nl> + # Is the newly created dataset equal ? YES ! <nl> + all . equal ( new_iris $ data , newer_iris $ data ) <nl> + <nl> + # Can we test our own rules ? <nl> + data ( iris ) # Erase iris dataset <nl> + <nl> + # We remapped values differently <nl> + personal_rules < - list ( <nl> + Species = c ( <nl> + " setosa " = 3L <nl> + , " versicolor " = 2L <nl> + , " virginica " = 1L <nl> + ) <nl> + ) <nl> + newest_iris < - lgb . prepare_rules2 ( data = iris , rules = personal_rules ) <nl> + str ( newest_iris $ data ) # SUCCESS ! <nl> + <nl> + } <nl> mmm a / R - package / src / install . libs . R <nl> ppp b / R - package / src / install . libs . R <nl> if ( ! use_precompile ) { <nl> <nl> # Install <nl> system ( paste0 ( cmake_cmd , " . . " ) ) <nl> + <nl> + # R CMD check complains about the . NOTPARALLEL directive created in the cmake <nl> + # Makefile . We don ' t need it here anyway since targets are built serially , so trying <nl> + # to remove it with this hack <nl> + generated_makefile < - file . path ( <nl> + R_PACKAGE_SOURCE <nl> + , " src " <nl> + , " build " <nl> + , " Makefile " <nl> + ) <nl> + if ( file . exists ( generated_makefile ) ) { <nl> + makefile_txt < - readLines ( <nl> + con = generated_makefile <nl> + ) <nl> + makefile_txt < - gsub ( <nl> + pattern = " . * NOTPARALLEL . * " <nl> + , replacement = " " <nl> + , x = makefile_txt <nl> + ) <nl> + writeLines ( <nl> + text = makefile_txt <nl> + , con = generated_makefile <nl> + , sep = " \ n " <nl> + ) <nl> + } <nl> + <nl> system ( build_cmd ) <nl> src < - file . path ( lib_folder , paste0 ( " lib_lightgbm " , SHLIB_EXT ) , fsep = " / " ) <nl> <nl> mmm a / R - package / tests / testthat . R <nl> ppp b / R - package / tests / testthat . R <nl> <nl> library ( testthat ) <nl> library ( lightgbm ) <nl> <nl> - test_check ( " lightgbm " ) <nl> + test_check ( <nl> + package = " lightgbm " <nl> + , stop_on_failure = TRUE <nl> + , stop_on_warning = FALSE <nl> + ) <nl> mmm a / build_r . R <nl> ppp b / build_r . R <nl> version < - gsub ( <nl> ) <nl> tarball < - file . path ( getwd ( ) , sprintf ( " lightgbm_ % s . tar . gz " , version ) ) <nl> <nl> - cmd < - sprintf ( " R CMD INSTALL % s - - no - multiarch " , tarball ) <nl> + cmd < - sprintf ( " R CMD INSTALL % s - - no - multiarch - - with - keep . source " , tarball ) <nl> . run_shell_command ( cmd ) <nl> | [ R - package ] [ ci ] added CI stage for R package ( fixes , fixes ) ( ) | microsoft/LightGBM | 86ca4845088cad210a8dcac9ca9bced7ea923b7c | 2019-12-15T18:01:01Z |
mmm a / torch / quantization / quantize . py <nl> ppp b / torch / quantization / quantize . py <nl> def _observer_forward_hook ( self , input , output ) : <nl> " " " <nl> return self . observer ( output ) <nl> <nl> - # TODO ( jerryzh ) : remove_observer ? <nl> - def add_observer ( module ) : <nl> + DEFAULT_SKIP_LIST = [ nn . Identity , nn . MaxPool2d ] <nl> + <nl> + def add_observer ( module , skip_list = DEFAULT_SKIP_LIST ) : <nl> r " " " Add observer for the leaf child of the module . <nl> <nl> This function insert observer module to all leaf child module that <nl> def add_observer ( module ) : <nl> <nl> # Insert observers only for leaf nodes , note that this observer is for <nl> # the output of the module , for input QuantStub will observe them <nl> - if hasattr ( module , ' qconfig ' ) and module . qconfig is not None and len ( module . _modules ) = = 0 : <nl> + if hasattr ( module , ' qconfig ' ) and module . qconfig is not None and \ <nl> + len ( module . _modules ) = = 0 and type ( module ) not in skip_list : <nl> # observer and hook will be gone after we swap the module <nl> module . add_module ( ' observer ' , module . qconfig . activation ( ) ) <nl> module . register_forward_hook ( _observer_forward_hook ) <nl> | skip nn . Identity in add_observer | pytorch/pytorch | 7364aa796d9c7a6c46cb6210c99b723efffc6600 | 2019-07-30T18:00:36Z |
deleted file mode 100755 <nl> index 3cde6494142 . . 00000000000 <nl> mmm a / test / cpp / qps / run_authenticated_test . sh <nl> ppp / dev / null <nl> <nl> - # ! / bin / sh <nl> - <nl> - CLIENT_ID = ' 1018396037782 - tv81fshn76nemr24uuhuginceb9hni2m . apps . googleusercontent . com ' <nl> - CLIENT_SECRET = ' _HGHXg4DAA59r4w4x8p6ARzD ' <nl> - GRANT_TYPE = ' http : / / oauth . net / grant_type / device / 1 . 0 ' <nl> - ACCESS_TOKENS_DIR = ' / tmp / auth_lead_access_tokens ' <nl> - AUTH_TOKEN_LINK = ' https : / / www . googleapis . com / oauth2 / v3 / token ' <nl> - GOOGLE_ACCOUNTS_LINK = ' https : / / accounts . google . com / o / oauth2 / device / code ' <nl> - USER_INFO_LINK = ' https : / / www . googleapis . com / oauth2 / v1 / userinfo ' <nl> - # Performs first time authentication <nl> - # Or re - authentication if refresh token expires <nl> - RE_AUTHENTICATE ( ) { <nl> - INIT_AUTH_JSON = $ ( curl - s - d " client_id = $ CLIENT_ID & scope = email profile " $ GOOGLE_ACCOUNTS_LINK ) <nl> - <nl> - USER_CODE = $ ( echo $ INIT_AUTH_JSON | jq . user_code | sed - e ' s / ^ " / / ' - e ' s / " $ / / ' ) <nl> - echo ' Please use the following user code in the browser : ' $ USER_CODE <nl> - echo <nl> - <nl> - VERIFICATION_URL = $ ( echo $ INIT_AUTH_JSON | jq ' . verification_url ' | sed - e ' s / ^ " / / ' - e ' s / " $ / / ' ) <nl> - echo ' Verification URL : ' $ VERIFICATION_URL <nl> - echo <nl> - <nl> - xdg - open $ VERIFICATION_URL <nl> - <nl> - DEVICE_CODE = $ ( echo $ INIT_AUTH_JSON | jq ' . device_code ' | sed - e ' s / ^ " / / ' - e ' s / " $ / / ' ) <nl> - INTERVAL = $ ( echo $ INIT_AUTH_JSON | jq ' . interval ' | sed - e ' s / ^ " / / ' - e ' s / " $ / / ' ) <nl> - <nl> - AUTH_JSON = $ ( curl - s - d " client_id = $ CLIENT_ID & client_secret = $ CLIENT_SECRET & code = $ DEVICE_CODE & grant_type = $ GRANT_TYPE " $ AUTH_TOKEN_LINK ) <nl> - ACCESS_TOKEN = $ ( echo $ AUTH_JSON | jq ' . access_token ' | sed - e ' s / ^ " / / ' - e ' s / " $ / / ' ) <nl> - <nl> - while [ $ ACCESS_TOKEN = = ' null ' ] <nl> - do <nl> - sleep $ INTERVAL <nl> - AUTH_JSON = $ ( curl - s - d " client_id = $ CLIENT_ID & client_secret = $ CLIENT_SECRET & code = $ DEVICE_CODE & grant_type = $ GRANT_TYPE " $ AUTH_TOKEN_LINK ) <nl> - ACCESS_TOKEN = $ ( echo $ AUTH_JSON | jq ' . access_token ' | sed - e ' s / ^ " / / ' - e ' s / " $ / / ' ) <nl> - done <nl> - <nl> - USER_DETAILS = $ ( curl - s $ USER_INFO_LINK ? access_token = $ ACCESS_TOKEN ) <nl> - USER_ID = $ ( echo $ USER_DETAILS | jq ' . email ' | sed - e ' s / ^ " / / ' - e ' s / " $ / / ' | awk - F " @ " ' { print $ 1 } ' | sed - e ' s / \ . / / g ' | awk ' { print tolower ( $ 0 ) } ' ) <nl> - echo $ AUTH_JSON > $ ACCESS_TOKENS_DIR / $ USER_ID <nl> - } <nl> - <nl> - # Use existing access token <nl> - USE_ACCESS_TOKEN ( ) { <nl> - ACCESS_TOKEN = $ ( jq ' . access_token ' $ ACCESS_TOKENS_DIR / $ USER_ID | sed - e ' s / ^ " / / ' - e ' s / " $ / / ' ) <nl> - <nl> - USER_DETAILS = $ ( curl - s $ USER_INFO_LINK ? access_token = $ ACCESS_TOKEN ) <nl> - <nl> - ID = $ ( echo $ USER_DETAILS | jq ' . id ' | sed - e ' s / ^ " / / ' - e ' s / " $ / / ' ) <nl> - <nl> - if [ $ ID = = ' null ' ] ; then <nl> - REFRESH_ACCESS_TOKEN <nl> - fi <nl> - } <nl> - <nl> - # Obtain new access token using refresh token <nl> - REFRESH_ACCESS_TOKEN ( ) { <nl> - REFRESH_TOKEN = $ ( jq ' . refresh_token ' $ ACCESS_TOKENS_DIR / $ USER_ID | sed - e ' s / ^ " / / ' - e ' s / " $ / / ' ) <nl> - if [ $ REFRESH_TOKEN = = ' null ' ] ; then <nl> - RE_AUTHENTICATE <nl> - else <nl> - REFRESH_JSON = $ ( curl - s - d " refresh_token = $ REFRESH_TOKEN & client_id = $ CLIENT_ID & client_secret = $ CLIENT_SECRET & grant_type = refresh_token " $ AUTH_TOKEN_LINK ) <nl> - <nl> - ACCESS_TOKEN = $ ( echo $ REFRESH_JSON | jq ' . access_token ' ) <nl> - if [ $ ACCESS_TOKEN = = ' null ' ] ; then <nl> - RE_AUTHENTICATE <nl> - else <nl> - NEW_AUTH_JSON = $ ( jq " . access_token = $ ACCESS_TOKEN " $ ACCESS_TOKENS_DIR / $ USER_ID ) <nl> - echo $ NEW_AUTH_JSON > $ ACCESS_TOKENS_DIR / $ USER_ID <nl> - fi <nl> - fi <nl> - } <nl> - <nl> - # create directory to store tokens , if not already present <nl> - [ ! - d $ ACCESS_TOKENS_DIR ] & & mkdir $ ACCESS_TOKENS_DIR <nl> - <nl> - # Convert user entered email id to unique string by converting to splitting on ' @ ' symbol , if present , <nl> - # removing ' . ' s and converting to lowercase <nl> - USER_ID = $ ( echo $ 2 | awk - F " @ " ' { print $ 1 } ' | sed - e ' s / \ . / / g ' | awk ' { print tolower ( $ 0 ) } ' ) <nl> - <nl> - if [ - s $ ACCESS_TOKENS_DIR / $ USER_ID ] ; then <nl> - USE_ACCESS_TOKEN <nl> - else <nl> - RE_AUTHENTICATE <nl> - fi <nl> - <nl> - . / $ 1 - - access_token = $ ACCESS_TOKEN <nl> \ No newline at end of file <nl> | removed shell script | grpc/grpc | 0acc25ad15163008015e1ef6e8848ad312c6dc08 | 2015-06-08T22:53:55Z |
mmm a / docs / tutorial / mac - app - store - submission - guide . md <nl> ppp b / docs / tutorial / mac - app - store - submission - guide . md <nl> more details . <nl> See the [ Enabling User - Selected File Access documentation ] [ user - selected ] for <nl> more details . <nl> <nl> + # # Known issues <nl> + <nl> + # # # ` shell . openItem ( filePath ) ` <nl> + <nl> + This will fail when the app is signed for distribution in the Mac App Store . <nl> + Subscribe to [ # 9005 ] ( https : / / github . com / electron / electron / issues / 9005 ) for updates . <nl> + <nl> + # # # # Workaround <nl> + <nl> + ` shell . openExternal ( ' file : / / ' + filePath ) ` will open the file in the default application as long as the extension is associated with an installed app . <nl> + <nl> # # Cryptographic Algorithms Used by Electron <nl> <nl> Depending on the country and region you are located , Mac App Store may require <nl> | Merge pull request from njbmartin / patch - 1 | electron/electron | 42496e12317260f6b20e28bc69cce6ba9aff1f3f | 2017-07-14T21:10:22Z |
mmm a / js / actions / api - index . js <nl> ppp b / js / actions / api - index . js <nl> var API = " _api / index " ; <nl> / / / <nl> / / / Return information about all indexes : <nl> / / / <nl> - / / / @ verbinclude api - index - all - indexes <nl> + / / / @ EXAMPLE_ARANGOSH_RUN { RestIndexAllIndexes } <nl> + / / / var cn = " products " ; <nl> + / / / db . _drop ( cn ) ; <nl> + / / / db . _create ( cn , { waitForSync : true } ) ; <nl> + / / / <nl> + / / / var url = " / _api / index ? collection = " + cn ; <nl> + / / / <nl> + / / / var response = logCurlRequest ( ' GET ' , url ) ; <nl> + / / / <nl> + / / / assert ( response . code = = = 200 ) ; <nl> + / / / <nl> + / / / logJsonResponse ( response ) ; <nl> + / / / @ END_EXAMPLE_ARANGOSH_RUN <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> function GET_api_indexes ( req , res ) { <nl> function GET_api_indexes ( req , res ) { <nl> / / / <nl> / / / All other attributes are type - dependent . <nl> / / / <nl> + / / / @ RESTRETURNCODES <nl> + / / / <nl> + / / / @ RESTRETURNCODE { 200 } <nl> + / / / If the index exists , then a ` HTTP 200 ` is <nl> + / / / returned . <nl> + / / / <nl> + / / / @ RESTRETURNCODE { 404 } <nl> + / / / If the index does not exist , then a ` HTTP 404 ` <nl> + / / / is returned . <nl> + / / / <nl> / / / @ EXAMPLES <nl> / / / <nl> - / / / @ verbinclude api - index - primary - index <nl> + / / / @ EXAMPLE_ARANGOSH_RUN { RestIndexPrimaryIndex } <nl> + / / / var cn = " products " ; <nl> + / / / db . _drop ( cn ) ; <nl> + / / / db . _create ( cn ) ; <nl> + / / / <nl> + / / / var url = " / _api / index / " + cn + " / 0 " ; <nl> + / / / var response = logCurlRequest ( ' GET ' , url ) ; <nl> + / / / <nl> + / / / assert ( response . code = = = 200 ) ; <nl> + / / / <nl> + / / / logJsonResponse ( response ) ; <nl> + / / / @ END_EXAMPLE_ARANGOSH_RUN <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> function GET_api_index ( req , res ) { <nl> function GET_api_index ( req , res ) { <nl> / / / <nl> / / / Creating a cap collection <nl> / / / <nl> - / / / @ verbinclude api - index - create - new - cap - constraint <nl> + / / / @ EXAMPLE_ARANGOSH_RUN { RestIndexCreateNewCapConstraint } <nl> + / / / var cn = " products " ; <nl> + / / / db . _drop ( cn ) ; <nl> + / / / db . _create ( cn , { waitForSync : true } ) ; <nl> + / / / <nl> + / / / var url = " / _api / index ? collection = " + cn ; <nl> + / / / var body = ' { " type " : " cap " , " size " : 10 } ' ; <nl> + / / / <nl> + / / / var response = logCurlRequest ( ' POST ' , url , body ) ; <nl> + / / / <nl> + / / / assert ( response . code = = = 201 ) ; <nl> + / / / <nl> + / / / logJsonResponse ( response ) ; <nl> + / / / @ END_EXAMPLE_ARANGOSH_RUN <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> function POST_api_index_cap ( req , res , collection , body ) { <nl> function POST_api_index_cap ( req , res , collection , body ) { <nl> / / / <nl> / / / Creating a geo index with a location attribute : <nl> / / / <nl> - / / / @ verbinclude api - index - create - geo - location <nl> + / / / @ EXAMPLE_ARANGOSH_RUN { RestIndexCreateGeoLocation } <nl> + / / / var cn = " products " ; <nl> + / / / db . _drop ( cn ) ; <nl> + / / / db . _create ( cn , { waitForSync : true } ) ; <nl> + / / / <nl> + / / / var url = " / _api / index ? collection = " + cn ; <nl> + / / / var body = ' { " type " : " geo " , " fields " : [ " b " ] } ' ; <nl> + / / / <nl> + / / / var response = logCurlRequest ( ' POST ' , url , body ) ; <nl> + / / / <nl> + / / / assert ( response . code = = = 201 ) ; <nl> + / / / <nl> + / / / logJsonResponse ( response ) ; <nl> + / / / @ END_EXAMPLE_ARANGOSH_RUN <nl> / / / <nl> / / / Creating a geo index with latitude and longitude attributes : <nl> / / / <nl> - / / / @ verbinclude api - index - create - geo - latitude - longitude <nl> + / / / @ EXAMPLE_ARANGOSH_RUN { RestIndexCreateGeoLatitudeLongitude } <nl> + / / / var cn = " products " ; <nl> + / / / db . _drop ( cn ) ; <nl> + / / / db . _create ( cn , { waitForSync : true } ) ; <nl> + / / / <nl> + / / / var url = " / _api / index ? collection = " + cn ; <nl> + / / / var body = ' { " type " : " geo " , " fields " : [ " e " , " f " ] } ' ; <nl> + / / / <nl> + / / / var response = logCurlRequest ( ' POST ' , url , body ) ; <nl> + / / / <nl> + / / / assert ( response . code = = = 201 ) ; <nl> + / / / <nl> + / / / logJsonResponse ( response ) ; <nl> + / / / @ END_EXAMPLE_ARANGOSH_RUN <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> function POST_api_index_geo ( req , res , collection , body ) { <nl> function POST_api_index_geo ( req , res , collection , body ) { <nl> / / / <nl> / / / Creating an unique constraint : <nl> / / / <nl> - / / / @ verbinclude api - index - create - new - unique - constraint <nl> + / / / @ EXAMPLE_ARANGOSH_RUN { RestIndexCreateNewUniqueConstraint } <nl> + / / / var cn = " products " ; <nl> + / / / db . _drop ( cn ) ; <nl> + / / / db . _create ( cn , { waitForSync : true } ) ; <nl> + / / / <nl> + / / / var url = " / _api / index ? collection = " + cn ; <nl> + / / / var body = ' { " type " : " hash " , " unique " : true , " fields " : [ " a " , " b " ] } ' ; <nl> + / / / <nl> + / / / var response = logCurlRequest ( ' POST ' , url , body ) ; <nl> + / / / <nl> + / / / assert ( response . code = = = 201 ) ; <nl> + / / / <nl> + / / / logJsonResponse ( response ) ; <nl> + / / / @ END_EXAMPLE_ARANGOSH_RUN <nl> / / / <nl> / / / Creating a hash index : <nl> / / / <nl> - / / / @ verbinclude api - index - create - new - hash - index <nl> + / / / @ EXAMPLE_ARANGOSH_RUN { RestIndexCreateNewHashIndex } <nl> + / / / var cn = " products " ; <nl> + / / / db . _drop ( cn ) ; <nl> + / / / db . _create ( cn , { waitForSync : true } ) ; <nl> + / / / <nl> + / / / var url = " / _api / index ? collection = " + cn ; <nl> + / / / var body = ' { " type " : " hash " , " unique " : false , " fields " : [ " a " , " b " ] } ' ; <nl> + / / / <nl> + / / / var response = logCurlRequest ( ' POST ' , url , body ) ; <nl> + / / / <nl> + / / / assert ( response . code = = = 201 ) ; <nl> + / / / <nl> + / / / logJsonResponse ( response ) ; <nl> + / / / @ END_EXAMPLE_ARANGOSH_RUN <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> function POST_api_index_hash ( req , res , collection , body ) { <nl> function POST_api_index_hash ( req , res , collection , body ) { <nl> / / / <nl> / / / Creating a skiplist : <nl> / / / <nl> - / / / @ verbinclude api - index - create - new - skiplist <nl> + / / / @ EXAMPLE_ARANGOSH_RUN { RestIndexCreateNewSkiplist } <nl> + / / / var cn = " products " ; <nl> + / / / db . _drop ( cn ) ; <nl> + / / / db . _create ( cn , { waitForSync : true } ) ; <nl> + / / / <nl> + / / / var url = " / _api / index ? collection = " + cn ; <nl> + / / / var body = ' { " type " : " skiplist " , " unique " : false , " fields " : [ " a " , " b " ] } ' ; <nl> + / / / <nl> + / / / var response = logCurlRequest ( ' POST ' , url , body ) ; <nl> + / / / <nl> + / / / assert ( response . code = = = 201 ) ; <nl> + / / / <nl> + / / / logJsonResponse ( response ) ; <nl> + / / / @ END_EXAMPLE_ARANGOSH_RUN <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> function POST_api_index_skiplist ( req , res , collection , body ) { <nl> function POST_api_index_skiplist ( req , res , collection , body ) { <nl> / / / <nl> / / / Creating a fulltext index : <nl> / / / <nl> - / / / @ verbinclude api - index - create - new - fulltext <nl> + / / / @ EXAMPLE_ARANGOSH_RUN { RestIndexCreateNewFulltext } <nl> + / / / var cn = " products " ; <nl> + / / / db . _drop ( cn ) ; <nl> + / / / db . _create ( cn , { waitForSync : true } ) ; <nl> + / / / <nl> + / / / var url = " / _api / index ? collection = " + cn ; <nl> + / / / var body = ' { " type " : " fulltext " , " fields " : [ " text " ] } ' ; <nl> + / / / <nl> + / / / var response = logCurlRequest ( ' POST ' , url , body ) ; <nl> + / / / <nl> + / / / assert ( response . code = = = 201 ) ; <nl> + / / / <nl> + / / / logJsonResponse ( response ) ; <nl> + / / / @ END_EXAMPLE_ARANGOSH_RUN <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> function POST_api_index_fulltext ( req , res , collection , body ) { <nl> function POST_api_index_fulltext ( req , res , collection , body ) { <nl> / / / <nl> / / / Creating a bitarray index : <nl> / / / <nl> - / / / @ verbinclude api - index - create - new - bitarray <nl> + / / / @ EXAMPLE_ARANGOSH_RUN { RestIndexCreateNewBitarray } <nl> + / / / var cn = " products " ; <nl> + / / / db . _drop ( cn ) ; <nl> + / / / db . _create ( cn , { waitForSync : true } ) ; <nl> + / / / <nl> + / / / var url = " / _api / index ? collection = " + cn ; <nl> + / / / var body = ' { " type " : " bitarray " , " unique " : false , " fields " : [ " x " , [ 0 , 1 , [ ] ] , " y " , [ " a " , " b " , [ ] ] ] } ' ; <nl> + / / / <nl> + / / / var response = logCurlRequest ( ' POST ' , url , body ) ; <nl> + / / / <nl> + / / / assert ( response . code = = = 201 ) ; <nl> + / / / <nl> + / / / logJsonResponse ( response ) ; <nl> + / / / @ END_EXAMPLE_ARANGOSH_RUN <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> function POST_api_index_bitarray ( req , res , collection , body ) { <nl> function POST_api_index_bitarray ( req , res , collection , body ) { <nl> / / / <nl> / / / @ RESTRETURNCODE { 404 } <nl> / / / If the ` collection - name ` is unknown , then a ` HTTP 404 ` is returned . <nl> - / / / <nl> - / / / @ EXAMPLES <nl> - / / / <nl> - / / / Creating a unique constraint : <nl> - / / / <nl> - / / / @ verbinclude api - index - create - new - unique - constraint <nl> - / / / <nl> - / / / Creating a hash index : <nl> - / / / <nl> - / / / @ verbinclude api - index - create - new - hash - index <nl> - / / / <nl> - / / / Creating a skip - list : <nl> - / / / <nl> - / / / @ verbinclude api - index - create - new - skiplist <nl> - / / / <nl> - / / / Creating a unique skip - list : <nl> - / / / <nl> - / / / @ verbinclude api - index - create - new - unique - skiplist <nl> - / / / <nl> - / / / Creating a fulltext index : <nl> - / / / <nl> - / / / @ verbinclude api - index - create - new - fulltext <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> function POST_api_index ( req , res ) { <nl> function POST_api_index ( req , res ) { <nl> / / / If the ` index - handle ` is unknown , then a ` HTTP 404 ` is returned . <nl> / / / @ EXAMPLES <nl> / / / <nl> - / / / @ verbinclude api - index - delete - unique - skiplist <nl> + / / / @ EXAMPLE_ARANGOSH_RUN { RestIndexDeleteUniqueSkiplist } <nl> + / / / var cn = " products " ; <nl> + / / / db . _drop ( cn ) ; <nl> + / / / db . _create ( cn , { waitForSync : true } ) ; <nl> + / / / <nl> + / / / var url = " / _api / index / " + db . products . ensureSkiplist ( " a " , " b " ) . id ; <nl> + / / / <nl> + / / / var response = logCurlRequest ( ' DELETE ' , url ) ; <nl> + / / / <nl> + / / / assert ( response . code = = = 200 ) ; <nl> + / / / <nl> + / / / logJsonResponse ( response ) ; <nl> + / / / @ END_EXAMPLE_ARANGOSH_RUN <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> function DELETE_api_index ( req , res ) { <nl> | generated examples for api - index . js | arangodb/arangodb | b3f43831173732c38676ef2d788a7688f5630478 | 2013-06-07T15:20:40Z |
mmm a / modules / planning / math / curve_math_test . cc <nl> ppp b / modules / planning / math / curve_math_test . cc <nl> TEST ( TestSuite , curvature_math_test ) { <nl> CurveMath : : ComputeCurvatureDerivative ( 1 . 0 , 0 . 0 , 0 . 0 , 1 . 0 , 0 . 0 , 0 . 0 ) ; <nl> EXPECT_NEAR ( curvature_derivative , 0 . 0 , 1e - 6 ) ; <nl> <nl> - / / Unit circle , x = sin ( t ) , y = cos ( t ) <nl> - / / at t = 0 <nl> - curvature = CurveMath : : ComputeCurvature ( 1 . 0 , 0 . 0 , 0 . 0 , - 1 . 0 ) ; <nl> - EXPECT_NEAR ( curvature , - 1 . 0 , 1e - 6 ) ; <nl> + / / Unit circle X = ( cos ( t ) , sin ( t ) ) , at t = 0 . 0 <nl> + curvature = CurveMath : : ComputeCurvature ( 0 . 0 , - 1 , 1 . 0 , 0 . 0 ) ; <nl> + EXPECT_NEAR ( curvature , 1 . 0 , 1e - 6 ) ; <nl> <nl> - / / Unit circle , at t = PI / 4 <nl> - double sin_angle = sin ( M_PI / 4 ) ; <nl> + / / Unit circle X = ( cos ( t ) , sin ( t ) ) , at t = PI / 4 , <nl> double cos_angle = cos ( M_PI / 4 ) ; <nl> - curvature = CurveMath : : ComputeCurvature ( cos_angle , - sin_angle , - sin_angle , <nl> - - cos_angle ) ; <nl> - EXPECT_NEAR ( curvature , - 1 . 0 , 1e - 6 ) ; <nl> + double sin_angle = sin ( M_PI / 4 ) ; <nl> + curvature = CurveMath : : ComputeCurvature ( - sin_angle , - cos_angle , cos_angle , <nl> + - sin_angle ) ; <nl> + EXPECT_NEAR ( curvature , 1 . 0 , 1e - 6 ) ; <nl> <nl> curvature_derivative = CurveMath : : ComputeCurvatureDerivative ( <nl> - cos_angle , - sin_angle , - cos_angle , - sin_angle , - cos_angle , sin_angle ) ; <nl> + - sin_angle , - cos_angle , sin_angle , cos_angle , - sin_angle , - cos_angle ) ; <nl> EXPECT_NEAR ( curvature_derivative , 0 . 0 , 1e - 6 ) ; <nl> } <nl> <nl> | planning : bug fix for curvature_math_test | ApolloAuto/apollo | d37e4239ce169949daad43209e414e4493a9add8 | 2017-08-15T21:58:28Z |
mmm a / Documentation / Books / Users / HttpGharial / Management . mdpp <nl> ppp b / Documentation / Books / Users / HttpGharial / Management . mdpp <nl> A list of additional vertex collections . <nl> Returned if the graph could be listed created . <nl> The body contains the graph configuration that has been stored . <nl> <nl> - @ RESTRETURNCODE { 400 } <nl> + @ RESTRETURNCODE { 409 } <nl> Returned if there is a conflict storing the graph . <nl> This can occur either if a graph with this name is already stored , or if there is one edge definition with a the same edge collection but a different signature used in any other graph . <nl> <nl> | Fixed a wrong return code in gharial documentation | arangodb/arangodb | 23bf64a5514612a0c4a771faa8a842d842887c22 | 2014-07-08T15:30:43Z |
mmm a / plugins / trace_api_plugin / include / eosio / trace_api / chain_extraction . hpp <nl> ppp b / plugins / trace_api_plugin / include / eosio / trace_api / chain_extraction . hpp <nl> class chain_extraction_impl_type { <nl> on_irreversible_block ( bsp ) ; <nl> } <nl> <nl> + / / / connect to chain controller block_start signal <nl> + void signal_block_start ( uint32_t block_num ) { <nl> + on_block_start ( block_num ) ; <nl> + } <nl> + <nl> private : <nl> <nl> void on_applied_transaction ( const chain : : transaction_trace_ptr & trace , const chain : : signed_transaction & t ) { <nl> class chain_extraction_impl_type { <nl> store_lib ( block_state ) ; <nl> } <nl> <nl> + void on_block_start ( uint32_t block_num ) { <nl> + cached_traces . clear ( ) ; <nl> + onblock_trace . reset ( ) ; <nl> + } <nl> + <nl> void store_block_trace ( const chain : : block_state_ptr & block_state ) { <nl> try { <nl> block_trace_v1 bt = create_block_trace_v1 ( block_state ) ; <nl> mmm a / plugins / trace_api_plugin / trace_api_plugin . cpp <nl> ppp b / plugins / trace_api_plugin / trace_api_plugin . cpp <nl> struct trace_api_plugin_impl { <nl> } ) ; <nl> } ) ) ; <nl> <nl> + block_start_connection . emplace ( <nl> + chain . block_start . connect ( [ this ] ( uint32_t block_num ) { <nl> + emit_killer ( [ & ] ( ) { <nl> + extraction - > signal_block_start ( block_num ) ; <nl> + } ) ; <nl> + } ) ) ; <nl> + <nl> accepted_block_connection . emplace ( <nl> chain . accepted_block . connect ( [ this ] ( const chain : : block_state_ptr & p ) { <nl> emit_killer ( [ & ] ( ) { <nl> struct trace_api_plugin_impl { <nl> std : : shared_ptr < chain_extraction_t > extraction ; <nl> <nl> fc : : optional < scoped_connection > applied_transaction_connection ; <nl> + fc : : optional < scoped_connection > block_start_connection ; <nl> fc : : optional < scoped_connection > accepted_block_connection ; <nl> fc : : optional < scoped_connection > irreversible_block_connection ; <nl> } ; <nl> | Use new block_start signal as reliable way to clear out cached transaction state | EOSIO/eos | 3d671bf2f6cf54ef285e55c99e3ad14e223a35b9 | 2020-06-03T15:43:31Z |
mmm a / tensorflow / compiler / mlir / tensorflow / ir / tf_op_base . td <nl> ppp b / tensorflow / compiler / mlir / tensorflow / ir / tf_op_base . td <nl> class TF_Op < string mnemonic , list < OpTrait > traits = [ ] > : <nl> def TF_TFDialectType : <nl> Type < CPred < " $ _self . isa < TensorFlowType > ( ) " > , " TensorFlow type " > ; <nl> <nl> + / / Class for any TensorFlow dialect specific type <nl> + class TF_TensorFlowType < string name , string description > : <nl> + Type < CPred < " $ _self . isa < mlir : : TF : : " # name # " Type > ( ) " > , <nl> + " TensorFlow " # description # " type " > , <nl> + BuildableType < " getType < mlir : : TF : : " # name # " Type > ( ) " > ; <nl> + <nl> / / Any tensor element type allowed in TensorFlow ops <nl> def TF_ElementType : Type < Or < [ AnyFloat . predicate , AnyInteger . predicate , <nl> TF_TFDialectType . predicate ] > , <nl> def TF_I32Or64 : IntOfWidths < [ 32 , 64 ] > ; <nl> <nl> def TF_I32OrI64Tensor : TensorOf < [ TF_I32Or64 ] > ; <nl> <nl> - def TF_Uint8 : Type < CPred < " $ _self . isa < mlir : : TF : : Uint8Type > ( ) " > , <nl> - " TensorFlow uint8 type " > , <nl> - BuildableType < " getType < mlir : : TF : : Uint8Type > ( ) " > ; <nl> - <nl> - def TF_Uint16 : Type < CPred < " $ _self . isa < mlir : : TF : : Uint16Type > ( ) " > , <nl> - " TensorFlow uint16 type " > , <nl> - BuildableType < " getType < mlir : : TF : : Uint16Type > ( ) " > ; <nl> - <nl> - def TF_Uint32 : Type < CPred < " $ _self . isa < mlir : : TF : : Uint32Type > ( ) " > , <nl> - " TensorFlow uint32 type " > , <nl> - BuildableType < " getType < mlir : : TF : : Uint32Type > ( ) " > ; <nl> - <nl> - def TF_Uint64 : Type < CPred < " $ _self . isa < mlir : : TF : : Uint64Type > ( ) " > , <nl> - " TensorFlow uint64 type " > , <nl> - BuildableType < " getType < mlir : : TF : : Uint64Type > ( ) " > ; <nl> + def TF_Uint8 : TF_TensorFlowType < " Uint8 " , " uint8 " > ; <nl> + def TF_Uint16 : TF_TensorFlowType < " Uint16 " , " uint16 " > ; <nl> + def TF_Uint32 : TF_TensorFlowType < " Uint32 " , " uint32 " > ; <nl> + def TF_Uint64 : TF_TensorFlowType < " Uint64 " , " uint64 " > ; <nl> <nl> / / Any unsigned integer type <nl> def TF_UInt : AnyTypeOf < [ TF_Uint8 , TF_Uint16 , TF_Uint32 , TF_Uint64 ] > ; <nl> def TF_Int : AnyTypeOf < [ TF_SInt , TF_UInt ] > ; <nl> / / Any integer tensor types <nl> def TF_IntTensor : TensorOf < [ TF_Int ] > ; <nl> <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + / / Quantized types <nl> + def TF_Qint8 : TF_TensorFlowType < " Qint8 " , " qint8 " > ; <nl> + def TF_Qint16 : TF_TensorFlowType < " Qint16 " , " qint16 " > ; <nl> + def TF_Qint32 : TF_TensorFlowType < " Qint32 " , " qint32 " > ; <nl> + def TF_Quint8 : TF_TensorFlowType < " Quint8 " , " quint8 " > ; <nl> + def TF_Quint16 : TF_TensorFlowType < " Quint16 " , " quint16 " > ; <nl> + <nl> + / / Any quantized type <nl> + def TF_AnyQuantized : AnyTypeOf < [ TF_Qint8 , TF_Qint16 , TF_Qint32 , TF_Quint8 , <nl> + TF_Quint16 ] > ; <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> / / Floating - point types <nl> <nl> def TF_FpTensor : TensorOf < [ AnyFloat ] > ; <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> / / Complex types <nl> <nl> - def TF_Complex64 : <nl> - Type < CPred < " $ _self . isa < TF : : Complex64Type > ( ) " > , " complex64 type " > ; <nl> + def TF_Complex64 : TF_TensorFlowType < " Complex64 " , " complex64 " > ; <nl> def TF_Complex64Tensor : TensorOf < [ TF_Complex64 ] > ; <nl> <nl> - def TF_Complex128 : <nl> - Type < CPred < " $ _self . isa < TF : : Complex128Type > ( ) " > , " complex128 type " > ; <nl> + def TF_Complex128 : TF_TensorFlowType < " Complex128 " , " complex128 " > ; <nl> def TF_Complex128Tensor : TensorOf < [ TF_Complex128 ] > ; <nl> <nl> def TF_AnyComplex : AnyTypeOf < [ TF_Complex64 , TF_Complex128 ] , <nl> def TF_ComplexTensor : TensorOf < [ TF_AnyComplex ] > ; <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> / / String / variant / resource types <nl> <nl> - def TF_Str : Type < CPred < " $ _self . isa < mlir : : TF : : StringType > ( ) " > , <nl> - " TensorFlow string type " > , <nl> - BuildableType < " getType < mlir : : TF : : StringType > ( ) " > ; <nl> + def TF_Str : TF_TensorFlowType < " String " , " string " > ; <nl> def TF_StrTensor : TensorOf < [ TF_Str ] > ; <nl> <nl> - def TF_Variant : Type < CPred < " $ _self . isa < mlir : : TF : : VariantType > ( ) " > , <nl> - " TensorFlow variant type " > , <nl> - BuildableType < " getType < mlir : : TF : : VariantType > ( ) " > ; <nl> + def TF_Variant : TF_TensorFlowType < " Variant " , " variant " > ; <nl> def TF_VariantTensor : TensorOf < [ TF_Variant ] > ; <nl> <nl> - def TF_Resource : Type < CPred < " $ _self . isa < mlir : : TF : : ResourceType > ( ) " > , <nl> - " TensorFlow variant type " > , <nl> - BuildableType < " getType < mlir : : TF : : ResourceType > ( ) " > ; <nl> + def TF_Resource : TF_TensorFlowType < " Resource " , " resource " > ; <nl> def TF_ResourceTensor : TensorOf < [ TF_Resource ] > ; <nl> <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> def TF_IntOrFpTensor : TensorOf < [ TF_Int , AnyFloat ] > ; <nl> <nl> def TF_FpOrComplexTensor : TensorOf < [ AnyFloat , TF_AnyComplex ] > ; <nl> <nl> - def TF_AnyNumber : AnyTypeOf < [ TF_Int , AnyFloat , TF_AnyComplex ] , " number " > ; <nl> + def TF_AnyNumber : AnyTypeOf < [ TF_Int , AnyFloat , TF_AnyQuantized , TF_AnyComplex ] , <nl> + " number " > ; <nl> <nl> def TF_NumberTensor : TensorOf < [ TF_AnyNumber ] > ; <nl> <nl> mmm a / tensorflow / compiler / mlir / tensorflow / tests / tf - ops . mlir <nl> ppp b / tensorflow / compiler / mlir / tensorflow / tests / tf - ops . mlir <nl> func @ testIdentity ( % arg0 : tensor < 4x2x ! tf . stringref > ) - > tensor < 4x2x ! tf . string > { <nl> <nl> / / mmm - - <nl> <nl> + / / CHECK - LABEL : func @ testBitcast <nl> + func @ testBitcast ( % arg0 : tensor < 3x4x ! tf . uint16 > ) - > tensor < 3x4x ! tf . quint16 > { <nl> + / / CHECK : tf . Bitcast <nl> + % 0 = " tf . Bitcast " ( % arg0 ) : ( tensor < 3x4x ! tf . uint16 > ) - > tensor < 3x4x ! tf . quint16 > <nl> + return % 0 : tensor < 3x4x ! tf . quint16 > <nl> + } <nl> + <nl> + / / mmm - - <nl> + <nl> func @ testIdentityWrongType ( % arg0 : tensor < 4x2x ! tf . string > ) - > tensor < 4x2x ! tf . stringref > { <nl> / / expected - error @ + 1 { { requires all operands to be either same as or ref type of results } } <nl> % 0 = " tf . Identity " ( % arg0 ) : ( tensor < 4x2x ! tf . string > ) - > tensor < 4x2x ! tf . stringref > <nl> | Add support for quantized types in tf dialect op constraints . | tensorflow/tensorflow | 88fdaabf58ef76677791a53bd410e3933818992d | 2019-08-28T16:47:55Z |
mmm a / . travis . yml <nl> ppp b / . travis . yml <nl> env : <nl> # bitcoind <nl> - HOST = x86_64 - unknown - linux - gnu PACKAGES = " bc python3 - zmq " DEP_OPTS = " NO_QT = 1 NO_UPNP = 1 DEBUG = 1 " RUN_TESTS = true GOAL = " install " BITCOIN_CONFIG = " - - enable - zmq - - enable - glibc - back - compat - - enable - reduce - exports CPPFLAGS = - DDEBUG_LOCKORDER " <nl> # No wallet <nl> - - HOST = x86_64 - unknown - linux - gnu PACKAGES = " python3 xvfb " DEP_OPTS = " NO_WALLET = 1 " RUN_TESTS = true GOAL = " install " BITCOIN_CONFIG = " - - enable - glibc - back - compat - - enable - reduce - exports " <nl> + - HOST = x86_64 - unknown - linux - gnu PACKAGES = " python3 " DEP_OPTS = " NO_WALLET = 1 " RUN_TESTS = true GOAL = " install " BITCOIN_CONFIG = " - - enable - glibc - back - compat - - enable - reduce - exports " <nl> # Cross - Mac <nl> - HOST = x86_64 - apple - darwin11 PACKAGES = " cmake imagemagick libcap - dev librsvg2 - bin libz - dev libbz2 - dev libtiff - tools python - dev " BITCOIN_CONFIG = " - - enable - gui - - enable - reduce - exports " OSX_SDK = 10 . 11 GOAL = " deploy " <nl> <nl> before_script : <nl> - if [ - n " $ OSX_SDK " - a ! - f depends / sdk - sources / MacOSX $ { OSX_SDK } . sdk . tar . gz ] ; then curl - - location - - fail $ SDK_URL / MacOSX $ { OSX_SDK } . sdk . tar . gz - o depends / sdk - sources / MacOSX $ { OSX_SDK } . sdk . tar . gz ; fi <nl> - if [ - n " $ OSX_SDK " - a - f depends / sdk - sources / MacOSX $ { OSX_SDK } . sdk . tar . gz ] ; then tar - C depends / SDKs - xf depends / sdk - sources / MacOSX $ { OSX_SDK } . sdk . tar . gz ; fi <nl> - make $ MAKEJOBS - C depends HOST = $ HOST $ DEP_OPTS <nl> - # Start xvfb if needed , as documented at https : / / docs . travis - ci . com / user / gui - and - headless - browsers / # Using - xvfb - to - Run - Tests - That - Require - a - GUI <nl> - - if [ " $ RUN_TESTS " = " true " - a " $ { DEP_OPTS # * NO_QT = 1 } " = " $ DEP_OPTS " ] ; then export DISPLAY = : 99 . 0 ; / sbin / start - stop - daemon - - start - - pidfile / tmp / custom_xvfb_99 . pid - - make - pidfile - - background - - exec / usr / bin / Xvfb - - : 99 - ac ; fi <nl> script : <nl> - if [ " $ CHECK_DOC " = 1 - a " $ TRAVIS_REPO_SLUG " = " bitcoin / bitcoin " - a " $ TRAVIS_PULL_REQUEST " = " false " ] ; then while read LINE ; do travis_retry gpg - - keyserver hkp : / / subset . pool . sks - keyservers . net - - recv - keys $ LINE ; done < contrib / verify - commits / trusted - keys ; fi <nl> - if [ " $ CHECK_DOC " = 1 - a " $ TRAVIS_REPO_SLUG " = " bitcoin / bitcoin " - a " $ TRAVIS_PULL_REQUEST " = " false " ] ; then git fetch - - unshallow ; fi <nl> | Remove xvfb configuration from travis | bitcoin/bitcoin | e4bc19f6f89d54483d0e69cb507956f42c197837 | 2017-06-02T13:32:04Z |
mmm a / src / h5 - render / src / components / loading . js <nl> ppp b / src / h5 - render / src / components / loading . js <nl> Loading . prototype . attr = { <nl> display : function ( val ) { <nl> if ( val = = = true | | val = = = ' true ' ) { <nl> setTimeout ( function ( ) { <nl> - this . show ( ) <nl> + this . show ( ) <nl> } . bind ( this ) , 0 ) <nl> } else { <nl> setTimeout ( function ( ) { <nl> - this . hide ( ) <nl> + this . hide ( ) <nl> } . bind ( this ) , 0 ) <nl> } <nl> } <nl> mmm a / src / h5 - render / src / components / refresh . js <nl> ppp b / src / h5 - render / src / components / refresh . js <nl> Refresh . prototype . attr = { <nl> display : function ( val ) { <nl> if ( val = = = true | | val = = = ' true ' ) { <nl> setTimeout ( function ( ) { <nl> - this . show ( ) <nl> + this . show ( ) <nl> } . bind ( this ) , 0 ) <nl> } else { <nl> setTimeout ( function ( ) { <nl> - this . hide ( ) <nl> + this . hide ( ) <nl> } . bind ( this ) , 0 ) <nl> } <nl> } <nl> | * [ html5 ] fix indent | apache/incubator-weex | 98a9c1bcbd04122feb460dc97f86907c2ebd530a | 2016-05-10T14:33:22Z |
mmm a / tests / test_other . py <nl> ppp b / tests / test_other . py <nl> def is_python3_version_supported ( ) : <nl> if not python3 : <nl> return False <nl> output = run_process ( [ python3 , ' - - version ' ] , stdout = PIPE ) . stdout <nl> - # strip out ' rc1 ' etc . , we don ' t care about release candidates <nl> - if ' rc ' in output : <nl> - output = output . split ( ' rc ' ) [ 0 ] <nl> - version = [ int ( x ) for x in output . split ( ' ' ) [ 1 ] . split ( ' . ' ) ] <nl> - return version > = [ 3 , 5 , 0 ] <nl> + output = output . split ( ' ' ) [ 1 ] <nl> + # ignore final component which can contains non - integers ( e . g ' rc1 ' ) <nl> + version = [ int ( x ) for x in output . split ( ' . ' ) [ : 2 ] ] <nl> + return version > = [ 3 , 5 ] <nl> <nl> <nl> def encode_leb ( number ) : <nl> | Ignore third component of python version ( ) | emscripten-core/emscripten | a05bff9efe4d9f8d2752d00c03fae0dc5d341cdd | 2019-08-08T15:29:04Z |
mmm a / xbmc / interfaces / json - rpc / InputOperations . cpp <nl> ppp b / xbmc / interfaces / json - rpc / InputOperations . cpp <nl> JSONRPC_STATUS CInputOperations : : ShowCodec ( const std : : string & method , ITransport <nl> return MethodNotFound ; <nl> } <nl> <nl> - JSONRPC_STATUS CInputOperations : : ShowPlayerProcessInfo ( const std : : string & method , ITransportLayer * transport , IClient * client , const CVariant & parameterObject , CVariant & result ) <nl> + JSONRPC_STATUS CInputOperations : : ShowOSD ( const std : : string & method , ITransportLayer * transport , IClient * client , const CVariant & parameterObject , CVariant & result ) <nl> { <nl> - return SendAction ( ACTION_PLAYER_PROCESS_INFO ) ; <nl> + return SendAction ( ACTION_SHOW_OSD ) ; <nl> } <nl> <nl> - JSONRPC_STATUS CInputOperations : : ShowOSD ( const std : : string & method , ITransportLayer * transport , IClient * client , const CVariant & parameterObject , CVariant & result ) <nl> + JSONRPC_STATUS CInputOperations : : ShowPlayerProcessInfo ( const std : : string & method , ITransportLayer * transport , IClient * client , const CVariant & parameterObject , CVariant & result ) <nl> { <nl> - return SendAction ( ACTION_SHOW_OSD ) ; <nl> + return SendAction ( ACTION_PLAYER_PROCESS_INFO ) ; <nl> } <nl> mmm a / xbmc / interfaces / json - rpc / InputOperations . h <nl> ppp b / xbmc / interfaces / json - rpc / InputOperations . h <nl> namespace JSONRPC <nl> static JSONRPC_STATUS Home ( const std : : string & method , ITransportLayer * transport , IClient * client , const CVariant & parameterObject , CVariant & result ) ; <nl> <nl> static JSONRPC_STATUS ShowCodec ( const std : : string & method , ITransportLayer * transport , IClient * client , const CVariant & parameterObject , CVariant & result ) ; <nl> - static JSONRPC_STATUS ShowPlayerProcessInfo ( const std : : string & method , ITransportLayer * transport , IClient * client , const CVariant & parameterObject , CVariant & result ) ; <nl> static JSONRPC_STATUS ShowOSD ( const std : : string & method , ITransportLayer * transport , IClient * client , const CVariant & parameterObject , CVariant & result ) ; <nl> + static JSONRPC_STATUS ShowPlayerProcessInfo ( const std : : string & method , ITransportLayer * transport , IClient * client , const CVariant & parameterObject , CVariant & result ) ; <nl> <nl> static JSONRPC_STATUS SendAction ( int actionID , bool wakeScreensaver = true , bool waitResult = false ) ; <nl> <nl> | [ json ] Respect existing method order ( oldest on top ) | xbmc/xbmc | 555c9df8bf74b926b23c32c4cde64b4fe5336171 | 2016-11-14T16:14:33Z |
mmm a / docs / configuration / http_conn_man / headers . rst <nl> ppp b / docs / configuration / http_conn_man / headers . rst <nl> x - ot - span - context <nl> mmmmmmmmmmmmmmm - - <nl> <nl> The * x - ot - span - context * HTTP header is used by Envoy to establish proper parent - child relationships <nl> - between tracing spans . For the Lightstep tracer , * x - ot - span - context * is a base64 encoded <nl> - ` binary OT < https : / / github . com / opentracing / basictracer - go / blob / master / wire / wire . proto > ` _ <nl> - carrier . For the Zipkin tracer , * x - ot - span - context * contains information <nl> - about ` client - send ` , ` server - receive ` , ` server - send ` and ` client - receive ` annotations . <nl> - In all cases , Envoy relies on data from the * x - ot - span - context * header to extract the parent <nl> - context for the current span . For example , an egress span is a child of an ingress <nl> + between tracing spans . This header can be used with both LightStep and Zipkin tracers . <nl> + For example , an egress span is a child of an ingress <nl> span ( if the ingress span was present ) . Envoy injects the * x - ot - span - context * header on ingress requests and <nl> forwards it to the local service . Envoy relies on the application to propagate * x - ot - span - context * on <nl> the egress call to an upstream . See more on tracing : ref : ` here < arch_overview_tracing > ` . <nl> mmm a / docs / intro / arch_overview / tracing . rst <nl> ppp b / docs / intro / arch_overview / tracing . rst <nl> sources of latency . Envoy supports three features related to system wide tracing <nl> : ref : ` config_http_conn_man_headers_x - request - id ` HTTP header . Applications can forward the <nl> x - request - id header for unified logging as well as tracing . <nl> * * * External trace service integration * * : Envoy supports pluggable external trace visualization <nl> - providers . Currently Envoy supports ` LightStep < http : / / lightstep . com / > ` _ and ` Zipkin < http : / / zipkin . io / > ` _ . <nl> - However , support for other tracing providers would not be not be difficult to add . <nl> + providers . Currently Envoy supports ` LightStep < http : / / lightstep . com / > ` _ , ` Zipkin < http : / / zipkin . io / > ` _ <nl> + or any Zipkin compatible backends ( e . g . ` Jaeger < https : / / github . com / jaegertracing / > ` _ ) . <nl> + However , support for other tracing providers would not be difficult to add . <nl> * * * Client trace ID joining * * : The : ref : ` config_http_conn_man_headers_x - client - trace - id ` header can <nl> be used to join untrusted request IDs to the trusted internal <nl> : ref : ` config_http_conn_man_headers_x - request - id ` . <nl> <nl> - When using the LightStep tracer , Envoy relies on a service to propagate <nl> - : ref : ` config_http_conn_man_headers_x - request - id ` and <nl> - : ref : ` config_http_conn_man_headers_x - ot - span - context ` HTTP headers <nl> - while sending HTTP requests to other services . When using the Zipkin <nl> - tracer , Envoy relies on the service to <nl> - propagate : ref : ` config_http_conn_man_headers_x - request - id ` , <nl> - : ref : ` config_http_conn_man_headers_x - ot - span - context ` , <nl> - : ref : ` config_http_conn_man_headers_x - b3 - traceid ` , <nl> - : ref : ` config_http_conn_man_headers_x - b3 - spanid ` , <nl> - : ref : ` config_http_conn_man_headers_x - b3 - parentspanid ` , <nl> - : ref : ` config_http_conn_man_headers_x - b3 - sampled ` , and <nl> - : ref : ` config_http_conn_man_headers_x - b3 - flags ` HTTP headers . <nl> - <nl> How to initiate a trace <nl> mmmmmmmmmmmmmmmmmmmmm - - <nl> The HTTP connection manager that handles the request must have the : ref : ` tracing <nl> initiated : <nl> * Randomly sampled via the : ref : ` random_sampling < config_http_conn_man_runtime_random_sampling > ` <nl> runtime setting . <nl> <nl> + Trace context propagation <nl> + mmmmmmmmmmmmmmmmmmmmmmmm - <nl> + Envoy provides the capability for reporting tracing information regarding communications between <nl> + services in the mesh . However , to be able to correlate the pieces of tracing information generated by the <nl> + various proxies within a call flow , the services must propagate certain trace context between the inbound <nl> + and outbound requests . <nl> + <nl> + Whichever tracing provider is being used , the service should propagate the <nl> + : ref : ` config_http_conn_man_headers_x - request - id ` to enable logging across the invoked services <nl> + to be correlated . <nl> + <nl> + The tracing providers also require additional context , to enable the parent / child relationships <nl> + between the spans ( logical units of work ) to be understood . <nl> + This can be achieved by using the LightStep ( via OpenTracing API ) or Zipkin tracer directly within the service itself , <nl> + to extract the trace context from the inbound request and inject it into any subsequent outbound requests . <nl> + This approach would also enable the service to create additional spans , describing work being done internally <nl> + within the service , that may be useful when examining the end - to - end trace . <nl> + <nl> + Alternatively the trace context can be manually propagated by the service : <nl> + <nl> + * When using the LightStep tracer , Envoy relies on the service to propagate the <nl> + : ref : ` config_http_conn_man_headers_x - ot - span - context ` HTTP header <nl> + while sending HTTP requests to other services . <nl> + <nl> + * When using the Zipkin tracer , Envoy relies on the service to propagate either the <nl> + official B3 HTTP headers ( <nl> + : ref : ` config_http_conn_man_headers_x - b3 - traceid ` , <nl> + : ref : ` config_http_conn_man_headers_x - b3 - spanid ` , <nl> + : ref : ` config_http_conn_man_headers_x - b3 - parentspanid ` , <nl> + : ref : ` config_http_conn_man_headers_x - b3 - sampled ` , and <nl> + : ref : ` config_http_conn_man_headers_x - b3 - flags ` ) or for convenience it is <nl> + also possible to just propagate the <nl> + : ref : ` config_http_conn_man_headers_x - ot - span - context ` HTTP header . <nl> + <nl> + NOTE : Work is currently underway in the distributed tracing community to define a standard <nl> + for trace context propagation . Once a suitable approach has been adopted , the use of the non - standard <nl> + single header : ref : ` config_http_conn_man_headers_x - ot - span - context ` for propagating Zipkin trace <nl> + context will be replaced . <nl> + <nl> + <nl> What data each trace contains <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> An end - to - end trace is comprised of one or more spans . A <nl> associated with it . Each span generated by Envoy contains the following data : <nl> * Originating host set via : option : ` - - service - node ` . <nl> * Downstream cluster set via the : ref : ` config_http_conn_man_headers_downstream - service - cluster ` <nl> header . <nl> - * HTTP request line . <nl> + * HTTP URL . <nl> + * HTTP method . <nl> * HTTP response code . <nl> * Tracing system - specific metadata . <nl> <nl> + The span also includes a name ( or operation ) which by default is defined as the host of the invoked service . <nl> + However this can be customized using a : ref : ` config_http_conn_man_route_table_decorator ` on the route . <nl> + <nl> Envoy automatically sends spans to tracing collectors . Depending on the tracing collector , <nl> multiple spans are stitched together using common information such as the globally unique <nl> request ID : ref : ` config_http_conn_man_headers_x - request - id ` ( LightStep ) or <nl> | tracing : Update docs to clarify situation with trace context propagation ( ) | envoyproxy/envoy | c52afae2f54ebc5dddc545300d030e9d1e41349c | 2017-09-27T21:07:17Z |
mmm a / build / cocos2d_tests . xcodeproj / project . pbxproj <nl> ppp b / build / cocos2d_tests . xcodeproj / project . pbxproj <nl> <nl> " COCOS2D_DEBUG = 1 " , <nl> USE_FILE32API , <nl> " CC_ENABLE_CHIPMUNK_INTEGRATION = 1 " , <nl> - DEBUG , <nl> ) ; <nl> GCC_SYMBOLS_PRIVATE_EXTERN = YES ; <nl> GCC_TREAT_WARNINGS_AS_ERRORS = YES ; <nl> mmm a / cocos / scripting / js - bindings / manual / ScriptingCore . cpp <nl> ppp b / cocos / scripting / js - bindings / manual / ScriptingCore . cpp <nl> void ScriptingCore : : createGlobalContext ( ) { <nl> <nl> JS_SetErrorReporter ( _cx , ScriptingCore : : reportError ) ; <nl> # if defined ( JS_GC_ZEAL ) & & defined ( DEBUG ) <nl> - / / JS_SetGCZeal ( this - > _cx , 2 , JS_DEFAULT_ZEAL_FREQ ) ; <nl> + JS_SetGCZeal ( this - > _cx , 2 , JS_DEFAULT_ZEAL_FREQ ) ; <nl> # endif <nl> <nl> _global . construct ( _cx ) ; <nl> mmm a / cocos / scripting / js - bindings / manual / chipmunk / js_bindings_chipmunk_manual . cpp <nl> ppp b / cocos / scripting / js - bindings / manual / chipmunk / js_bindings_chipmunk_manual . cpp <nl> struct collision_handler { <nl> cpCollisionType typeA ; <nl> cpCollisionType typeB ; <nl> <nl> - JS : : Heap < JSObject * > begin ; <nl> - JS : : Heap < JSObject * > pre ; <nl> - JS : : Heap < JSObject * > post ; <nl> - JS : : Heap < JSObject * > separate ; <nl> - JS : : Heap < JSObject * > jsthis ; <nl> + mozilla : : Maybe < JS : : PersistentRootedObject > begin ; <nl> + mozilla : : Maybe < JS : : PersistentRootedObject > pre ; <nl> + mozilla : : Maybe < JS : : PersistentRootedObject > post ; <nl> + mozilla : : Maybe < JS : : PersistentRootedObject > separate ; <nl> + mozilla : : Maybe < JS : : PersistentRootedObject > jsthis ; <nl> JSContext * cx ; <nl> <nl> / / " owner " of the collision handler <nl> struct collision_handler { <nl> <nl> unsigned int is_oo ; / / Objected oriented API ? <nl> UT_hash_handle hh ; <nl> + <nl> + collision_handler ( ) <nl> + { <nl> + JSContext * globalcx = ScriptingCore : : getInstance ( ) - > getGlobalContext ( ) ; <nl> + begin . construct ( globalcx ) ; <nl> + pre . construct ( globalcx ) ; <nl> + post . construct ( globalcx ) ; <nl> + separate . construct ( globalcx ) ; <nl> + jsthis . construct ( globalcx ) ; <nl> + } <nl> } ; <nl> <nl> / / hash <nl> static cpBool myCollisionBegin ( cpArbiter * arb , cpSpace * space , void * data ) <nl> args [ 0 ] = c_class_to_jsval ( handler - > cx , arb , arbiterProto , JSB_cpArbiter_class , " cpArbiter " ) ; <nl> args [ 1 ] = c_class_to_jsval ( handler - > cx , space , spaceProto , JSB_cpSpace_class , " cpArbiter " ) ; <nl> } else { <nl> - args [ 0 ] = opaque_to_jsval ( handler - > cx , arb ) ; <nl> - args [ 1 ] = opaque_to_jsval ( handler - > cx , space ) ; <nl> + args [ 0 ] = opaque_to_jsval ( handler - > cx , arb ) ; <nl> + args [ 1 ] = opaque_to_jsval ( handler - > cx , space ) ; <nl> } <nl> <nl> JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET <nl> <nl> JS : : RootedValue rval ( handler - > cx ) ; <nl> - JS : : RootedObject jsthis ( handler - > cx , handler - > jsthis ) ; <nl> - JS : : RootedValue jsbegin ( handler - > cx , OBJECT_TO_JSVAL ( handler - > begin ) ) ; <nl> - bool ok = JS_CallFunctionValue ( handler - > cx , jsthis , jsbegin , JS : : HandleValueArray : : fromMarkedLocation ( 2 , args ) , & rval ) ; <nl> + JS : : RootedObject jsthis ( handler - > cx , handler - > jsthis . ref ( ) ) ; <nl> + JS : : RootedValue jsbegin ( handler - > cx , OBJECT_TO_JSVAL ( handler - > begin . ref ( ) ) ) ; <nl> + bool ok = JS_CallFunctionValue ( handler - > cx , jsthis , jsbegin , JS : : HandleValueArray : : fromMarkedLocation ( 2 , args ) , & rval ) ; <nl> JSB_PRECONDITION2 ( ok , handler - > cx , cpFalse , " Error calling collision callback : begin " ) ; <nl> <nl> if ( rval . isBoolean ( ) ) { <nl> static cpBool myCollisionPre ( cpArbiter * arb , cpSpace * space , void * data ) <nl> JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET <nl> <nl> JS : : RootedValue rval ( handler - > cx ) ; <nl> - JS : : RootedObject jsthis ( handler - > cx , handler - > jsthis ) ; <nl> - JS : : RootedValue jspre ( handler - > cx , OBJECT_TO_JSVAL ( handler - > pre ) ) ; <nl> + JS : : RootedObject jsthis ( handler - > cx , handler - > jsthis . ref ( ) ) ; <nl> + JS : : RootedValue jspre ( handler - > cx , OBJECT_TO_JSVAL ( handler - > pre . ref ( ) ) ) ; <nl> bool ok = JS_CallFunctionValue ( handler - > cx , jsthis , jspre , JS : : HandleValueArray : : fromMarkedLocation ( 2 , args ) , & rval ) ; <nl> JSB_PRECONDITION2 ( ok , handler - > cx , false , " Error calling collision callback : pre " ) ; <nl> <nl> static void myCollisionPost ( cpArbiter * arb , cpSpace * space , void * data ) <nl> JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET <nl> <nl> JS : : RootedValue ignore ( handler - > cx ) ; <nl> - JS : : RootedObject jsthis ( handler - > cx , handler - > jsthis ) ; <nl> - JS : : RootedValue jspost ( handler - > cx , OBJECT_TO_JSVAL ( handler - > post ) ) ; <nl> + JS : : RootedObject jsthis ( handler - > cx , handler - > jsthis . ref ( ) ) ; <nl> + JS : : RootedValue jspost ( handler - > cx , OBJECT_TO_JSVAL ( handler - > post . ref ( ) ) ) ; <nl> bool ok = JS_CallFunctionValue ( handler - > cx , jsthis , jspost , JS : : HandleValueArray : : fromMarkedLocation ( 2 , args ) , & ignore ) ; <nl> JSB_PRECONDITION2 ( ok , handler - > cx , , " Error calling collision callback : Post " ) ; <nl> } <nl> static void myCollisionSeparate ( cpArbiter * arb , cpSpace * space , void * data ) <nl> JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET <nl> <nl> JS : : RootedValue ignore ( handler - > cx ) ; <nl> - JS : : RootedObject jsthis ( handler - > cx , handler - > jsthis ) ; <nl> - JS : : RootedValue jssep ( handler - > cx , OBJECT_TO_JSVAL ( handler - > separate ) ) ; <nl> + JS : : RootedObject jsthis ( handler - > cx , handler - > jsthis . ref ( ) ) ; <nl> + JS : : RootedValue jssep ( handler - > cx , OBJECT_TO_JSVAL ( handler - > separate . ref ( ) ) ) ; <nl> bool ok = JS_CallFunctionValue ( handler - > cx , jsthis , jssep , JS : : HandleValueArray : : fromMarkedLocation ( 2 , args ) , & ignore ) ; <nl> JSB_PRECONDITION2 ( ok , handler - > cx , , " Error calling collision callback : Separate " ) ; } <nl> <nl> void JSB_cpSpace_finalize ( JSFreeOp * fop , JSObject * jsthis ) <nl> struct collision_handler * current = nullptr , * tmp = nullptr ; <nl> HASH_ITER ( hh , collision_handler_hash , current , tmp ) { <nl> if ( current - > space = = space ) { <nl> - <nl> - JSContext * cx = current - > cx ; <nl> - <nl> - / / unroot it <nl> - if ( current - > begin ) { <nl> - JS : : RemoveObjectRoot ( cx , & current - > begin ) ; <nl> - } <nl> - if ( current - > pre ) <nl> - JS : : RemoveObjectRoot ( cx , & current - > pre ) ; <nl> - if ( current - > post ) <nl> - JS : : RemoveObjectRoot ( cx , & current - > post ) ; <nl> - if ( current - > separate ) <nl> - JS : : RemoveObjectRoot ( cx , & current - > separate ) ; <nl> - <nl> HASH_DEL ( collision_handler_hash , current ) ; / * delete ; users advances to next * / <nl> - free ( current ) ; / * optional - if you want to free * / <nl> + delete current ; / * optional - if you want to free * / <nl> } <nl> } <nl> <nl> void JSB_cpSpace_finalize ( JSFreeOp * fop , JSObject * jsthis ) <nl> # pragma mark addCollisionHandler <nl> <nl> static <nl> - bool __jsb_cpSpace_addCollisionHandler ( JSContext * cx , jsval * vp , jsval * argvp , cpSpace * space , unsigned int is_oo ) <nl> + bool __jsb_cpSpace_addCollisionHandler ( JSContext * cx , jsval * vp , jsval * argvp , JS : : HandleObject jsspace , cpSpace * space , unsigned int is_oo ) <nl> { <nl> - struct collision_handler * handler = ( struct collision_handler * ) malloc ( sizeof ( * handler ) ) ; <nl> + struct collision_handler * handler = new collision_handler ( ) ; <nl> handler - > typeA = 0 ; <nl> handler - > typeB = 0 ; <nl> <nl> JSB_PRECONDITION ( handler , " Error allocating memory " ) ; <nl> + <nl> + handler - > jsthis . ref ( ) = jsspace ; <nl> <nl> bool ok = true ; <nl> <nl> bool __jsb_cpSpace_addCollisionHandler ( JSContext * cx , jsval * vp , jsval * argvp , c <nl> ok & = jsval_to_int ( cx , jstypeA , ( int32_t * ) & handler - > typeA ) ; <nl> ok & = jsval_to_int ( cx , jstypeB , ( int32_t * ) & handler - > typeB ) ; <nl> <nl> - handler - > begin = argvp - > toObjectOrNull ( ) ; <nl> + handler - > begin . ref ( ) = argvp - > toObjectOrNull ( ) ; <nl> argvp + + ; <nl> - handler - > pre = argvp - > toObjectOrNull ( ) ; <nl> + handler - > pre . ref ( ) = argvp - > toObjectOrNull ( ) ; <nl> argvp + + ; <nl> - handler - > post = argvp - > toObjectOrNull ( ) ; <nl> + handler - > post . ref ( ) = argvp - > toObjectOrNull ( ) ; <nl> argvp + + ; <nl> - handler - > separate = argvp - > toObjectOrNull ( ) ; <nl> + handler - > separate . ref ( ) = argvp - > toObjectOrNull ( ) ; <nl> argvp + + ; <nl> <nl> JSB_PRECONDITION ( ok , " Error parsing arguments " ) ; <nl> <nl> / / Object Oriented API ? <nl> handler - > is_oo = is_oo ; <nl> - <nl> / / owner of the collision handler <nl> handler - > space = space ; <nl> - <nl> - / / Root it <nl> - if ( handler - > begin ) <nl> - JS : : AddNamedObjectRoot ( cx , & handler - > begin , " begin collision_handler " ) ; <nl> - if ( handler - > pre ) <nl> - JS : : AddNamedObjectRoot ( cx , & handler - > pre , " pre collision_handler " ) ; <nl> - if ( handler - > post ) <nl> - JS : : AddNamedObjectRoot ( cx , & handler - > post , " post collision_handler " ) ; <nl> - if ( handler - > separate ) <nl> - JS : : AddNamedObjectRoot ( cx , & handler - > separate , " separate collision_handler " ) ; <nl> - <nl> handler - > cx = cx ; <nl> <nl> cpSpaceAddCollisionHandler ( space , handler - > typeA , handler - > typeB , <nl> - ! handler - > begin ? NULL : & myCollisionBegin , <nl> - ! handler - > pre ? NULL : & myCollisionPre , <nl> - ! handler - > post ? NULL : & myCollisionPost , <nl> - ! handler - > separate ? NULL : & myCollisionSeparate , <nl> + ! handler - > begin . ref ( ) ? NULL : & myCollisionBegin , <nl> + ! handler - > pre . ref ( ) ? NULL : & myCollisionPre , <nl> + ! handler - > post . ref ( ) ? NULL : & myCollisionPost , <nl> + ! handler - > separate . ref ( ) ? NULL : & myCollisionSeparate , <nl> handler ) ; <nl> <nl> <nl> bool __jsb_cpSpace_addCollisionHandler ( JSContext * cx , jsval * vp , jsval * argvp , c <nl> HASH_FIND_INT ( collision_handler_hash , & paired_key , hashElement ) ; <nl> if ( hashElement ) { <nl> HASH_DEL ( collision_handler_hash , hashElement ) ; <nl> - free ( hashElement ) ; <nl> + delete hashElement ; <nl> } <nl> <nl> handler - > hash_key = paired_key ; <nl> bool JSB_cpSpaceAddCollisionHandler ( JSContext * cx , uint32_t argc , jsval * vp ) <nl> bool ok = jsval_to_opaque ( cx , jsarg , ( void * * ) & space ) ; <nl> JSB_PRECONDITION ( ok , " Error parsing arguments " ) ; <nl> <nl> - return __jsb_cpSpace_addCollisionHandler ( cx , vp , argvp , space , 0 ) ; <nl> + JS : : RootedObject jsspace ( cx , jsarg . toObjectOrNull ( ) ) ; <nl> + return __jsb_cpSpace_addCollisionHandler ( cx , vp , argvp , jsspace , space , 0 ) ; <nl> } <nl> <nl> / / method <nl> bool JSB_cpSpace_addCollisionHandler ( JSContext * cx , uint32_t argc , jsval * vp ) <nl> struct jsb_c_proxy_s * proxy = jsb_get_c_proxy_for_jsobject ( jsthis ) ; <nl> void * handle = proxy - > handle ; <nl> <nl> - return __jsb_cpSpace_addCollisionHandler ( cx , vp , args . array ( ) , ( cpSpace * ) handle , 1 ) ; <nl> + return __jsb_cpSpace_addCollisionHandler ( cx , vp , args . array ( ) , jsthis , ( cpSpace * ) handle , 1 ) ; <nl> } <nl> <nl> bool JSB_cpSpace_setDefaultCollisionHandler ( JSContext * cx , uint32_t argc , jsval * vp ) <nl> bool JSB_cpSpace_setDefaultCollisionHandler ( JSContext * cx , uint32_t argc , jsval <nl> struct jsb_c_proxy_s * proxy = jsb_get_c_proxy_for_jsobject ( jsthis ) ; <nl> cpSpace * space = ( cpSpace * ) proxy - > handle ; <nl> <nl> - collision_handler * handler = ( collision_handler * ) malloc ( sizeof ( collision_handler ) ) ; <nl> + collision_handler * handler = new collision_handler ( ) ; <nl> JSB_PRECONDITION ( handler , " Error allocating memory " ) ; <nl> <nl> handler - > typeA = 0 ; <nl> handler - > typeB = 0 ; <nl> - handler - > jsthis = jsthis ; <nl> - <nl> - handler - > begin = args . get ( 0 ) . toObjectOrNull ( ) ; <nl> - handler - > pre = args . get ( 1 ) . toObjectOrNull ( ) ; <nl> - handler - > post = args . get ( 2 ) . toObjectOrNull ( ) ; <nl> - handler - > separate = args . get ( 3 ) . toObjectOrNull ( ) ; <nl> + handler - > jsthis . ref ( ) = jsthis ; <nl> + handler - > begin . ref ( ) = args . get ( 0 ) . toObjectOrNull ( ) ; <nl> + handler - > pre . ref ( ) = args . get ( 1 ) . toObjectOrNull ( ) ; <nl> + handler - > post . ref ( ) = args . get ( 2 ) . toObjectOrNull ( ) ; <nl> + handler - > separate . ref ( ) = args . get ( 3 ) . toObjectOrNull ( ) ; <nl> <nl> / / Object Oriented API ? <nl> handler - > is_oo = 1 ; <nl> - <nl> / / owner of the collision handler <nl> handler - > space = space ; <nl> handler - > cx = cx ; <nl> <nl> cpSpaceSetDefaultCollisionHandler ( space , <nl> - ! handler - > begin ? NULL : & myCollisionBegin , <nl> - ! handler - > pre ? NULL : & myCollisionPre , <nl> - ! handler - > post ? NULL : & myCollisionPost , <nl> - ! handler - > separate ? NULL : & myCollisionSeparate , <nl> + ! handler - > begin . ref ( ) ? NULL : & myCollisionBegin , <nl> + ! handler - > pre . ref ( ) ? NULL : & myCollisionPre , <nl> + ! handler - > post . ref ( ) ? NULL : & myCollisionPost , <nl> + ! handler - > separate . ref ( ) ? NULL : & myCollisionSeparate , <nl> handler ) ; <nl> <nl> / / <nl> bool JSB_cpSpace_setDefaultCollisionHandler ( JSContext * cx , uint32_t argc , jsval <nl> unsigned long paired_key = pair_ints ( handler - > typeA , handler - > typeB ) ; <nl> HASH_FIND_INT ( collision_handler_hash , & paired_key , hashElement ) ; <nl> if ( hashElement ) { <nl> - if ( hashElement - > begin ) { <nl> - JS : : RemoveObjectRoot ( cx , & hashElement - > begin ) ; <nl> - } <nl> - if ( hashElement - > pre ) <nl> - JS : : RemoveObjectRoot ( cx , & hashElement - > pre ) ; <nl> - if ( hashElement - > post ) <nl> - JS : : RemoveObjectRoot ( cx , & hashElement - > post ) ; <nl> - if ( hashElement - > separate ) <nl> - JS : : RemoveObjectRoot ( cx , & hashElement - > separate ) ; <nl> HASH_DEL ( collision_handler_hash , hashElement ) ; <nl> - free ( hashElement ) ; <nl> + delete hashElement ; <nl> } <nl> <nl> handler - > hash_key = paired_key ; <nl> HASH_ADD_INT ( collision_handler_hash , hash_key , handler ) ; <nl> <nl> - / / Root it <nl> - if ( handler - > begin ) <nl> - JS : : AddNamedObjectRoot ( cx , & handler - > begin , " begin collision_handler " ) ; <nl> - if ( handler - > pre ) <nl> - JS : : AddNamedObjectRoot ( cx , & handler - > pre , " pre collision_handler " ) ; <nl> - if ( handler - > post ) <nl> - JS : : AddNamedObjectRoot ( cx , & handler - > post , " post collision_handler " ) ; <nl> - if ( handler - > separate ) <nl> - JS : : AddNamedObjectRoot ( cx , & handler - > separate , " separate collision_handler " ) ; <nl> - <nl> args . rval ( ) . setUndefined ( ) ; <nl> - <nl> return true ; <nl> } <nl> <nl> bool __jsb_cpSpace_removeCollisionHandler ( JSContext * cx , jsval * vp , jsval * argvp <nl> unsigned long key = pair_ints ( typeA , typeB ) ; <nl> HASH_FIND_INT ( collision_handler_hash , & key , hashElement ) ; <nl> if ( hashElement ) { <nl> - <nl> - / / unroot it <nl> - if ( hashElement - > begin ) <nl> - JS : : RemoveObjectRoot ( cx , & hashElement - > begin ) ; <nl> - if ( hashElement - > pre ) <nl> - JS : : RemoveObjectRoot ( cx , & hashElement - > pre ) ; <nl> - if ( hashElement - > post ) <nl> - JS : : RemoveObjectRoot ( cx , & hashElement - > post ) ; <nl> - if ( hashElement - > separate ) <nl> - JS : : RemoveObjectRoot ( cx , & hashElement - > separate ) ; <nl> - <nl> HASH_DEL ( collision_handler_hash , hashElement ) ; <nl> - free ( hashElement ) ; <nl> + delete hashElement ; <nl> } <nl> <nl> return true ; <nl> mmm a / cocos / scripting / js - bindings / proj . ios_mac / cocos2d_js_bindings . xcodeproj / project . pbxproj <nl> ppp b / cocos / scripting / js - bindings / proj . ios_mac / cocos2d_js_bindings . xcodeproj / project . pbxproj <nl> <nl> " COCOS2D_DEBUG = 1 " , <nl> USE_FILE32API , <nl> " CC_ENABLE_CHIPMUNK_INTEGRATION = 1 " , <nl> - DEBUG , <nl> ) ; <nl> GCC_SYMBOLS_PRIVATE_EXTERN = NO ; <nl> GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES ; <nl> mmm a / tools / bindings - generator <nl> ppp b / tools / bindings - generator <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit 3dd232b790e85b2cc4a0a0a0e2fb1fc103f57249 <nl> + Subproject commit 250673608e23c9644b96a8e9ef886ab4db96aaf7 <nl> | Fix Chipmunk bindings issue | cocos2d/cocos2d-x | 43c68aa16bf4a5ac08e36a87045c7c3db8920d59 | 2015-11-27T14:38:16Z |
mmm a / . circleci / config . yml <nl> ppp b / . circleci / config . yml <nl> jobs : <nl> - image : ossrs / dev <nl> steps : <nl> - checkout <nl> - - cd trunk & & . / configure - - without - ssl - - without - valgrind & & make <nl> + - run : cd trunk & & . / configure - - without - ssl - - without - valgrind & & make <nl> test : <nl> docker : <nl> - image : ossrs / dev <nl> steps : <nl> - checkout <nl> - - cd trunk & & . / configure - - without - ssl - - without - valgrind & & make & & . / objs / srs_utest <nl> + - run : cd trunk & & . / configure - - without - ssl - - without - valgrind & & make & & . / objs / srs_utest <nl> workflows : <nl> version : 2 <nl> build_and_test : <nl> | CI : Migrate to Circle2 . 0 | ossrs/srs | 4ceef56f1a7655cf1435cc2f14487c6b995831fb | 2019-02-02T12:00:17Z |
mmm a / db / db_impl_readonly . cc <nl> ppp b / db / db_impl_readonly . cc <nl> Status DBImplReadOnly : : Get ( const ReadOptions & read_options , <nl> ColumnFamilyHandle * column_family , const Slice & key , <nl> PinnableSlice * pinnable_val ) { <nl> assert ( pinnable_val ! = nullptr ) ; <nl> + / / TODO : stopwatch DB_GET needed ? , perf timer needed ? <nl> + PERF_TIMER_GUARD ( get_snapshot_time ) ; <nl> Status s ; <nl> SequenceNumber snapshot = versions_ - > LastSequence ( ) ; <nl> auto cfh = reinterpret_cast < ColumnFamilyHandleImpl * > ( column_family ) ; <nl> Status DBImplReadOnly : : Get ( const ReadOptions & read_options , <nl> MergeContext merge_context ; <nl> RangeDelAggregator range_del_agg ( cfd - > internal_comparator ( ) , snapshot ) ; <nl> LookupKey lkey ( key , snapshot ) ; <nl> + PERF_TIMER_STOP ( get_snapshot_time ) ; <nl> if ( super_version - > mem - > Get ( lkey , pinnable_val - > GetSelf ( ) , & s , & merge_context , <nl> & range_del_agg , read_options ) ) { <nl> pinnable_val - > PinSelf ( ) ; <nl> + RecordTick ( stats_ , MEMTABLE_HIT ) ; <nl> } else { <nl> PERF_TIMER_GUARD ( get_from_output_files_time ) ; <nl> super_version - > current - > Get ( read_options , lkey , pinnable_val , & s , <nl> & merge_context , & range_del_agg ) ; <nl> + RecordTick ( stats_ , MEMTABLE_MISS ) ; <nl> } <nl> + RecordTick ( stats_ , NUMBER_KEYS_READ ) ; <nl> + size_t size = pinnable_val - > size ( ) ; <nl> + RecordTick ( stats_ , BYTES_READ , size ) ; <nl> + MeasureTime ( stats_ , BYTES_PER_READ , size ) ; <nl> + PERF_COUNTER_ADD ( get_read_bytes , size ) ; <nl> return s ; <nl> } <nl> <nl> mmm a / db / perf_context_test . cc <nl> ppp b / db / perf_context_test . cc <nl> void ProfileQueries ( bool enabled_time = false ) { <nl> ASSERT_GT ( hist_num_memtable_checked . Average ( ) , 0 ) ; <nl> / / In read - only mode Get ( ) , no super version operation is needed <nl> ASSERT_EQ ( hist_get_post_process . Average ( ) , 0 ) ; <nl> - ASSERT_EQ ( hist_get_snapshot . Average ( ) , 0 ) ; <nl> + ASSERT_GT ( hist_get_snapshot . Average ( ) , 0 ) ; <nl> <nl> ASSERT_GT ( hist_mget . Average ( ) , 0 ) ; <nl> ASSERT_GT ( hist_mget_snapshot . Average ( ) , 0 ) ; <nl> | add missing counters in readonly mode ( ) | facebook/rocksdb | f1f5ba085fa28e3dbcd5202d6451d2b98a1492a9 | 2018-08-23T05:43:13Z |
mmm a / tensorflow / core / framework / tensor_testutil . cc <nl> ppp b / tensorflow / core / framework / tensor_testutil . cc <nl> void ExpectClose ( const Tensor & x , const Tensor & y , double atol , double rtol ) { <nl> switch ( x . dtype ( ) ) { <nl> case DT_HALF : <nl> return ExpectClose < Eigen : : half > ( x , y , atol , rtol ) ; <nl> + case DT_BFLOAT16 : <nl> + return ExpectClose < Eigen : : bfloat16 > ( x , y , atol , rtol ) ; <nl> case DT_FLOAT : <nl> return ExpectClose < float > ( x , y , atol , rtol ) ; <nl> case DT_DOUBLE : <nl> mmm a / tensorflow / core / grappler / optimizers / remapper_test . cc <nl> ppp b / tensorflow / core / grappler / optimizers / remapper_test . cc <nl> class RemapperFuseMatMulWithBiasTest : public RemapperTest { <nl> ASSERT_EQ ( tensors_expected . size ( ) , 1 ) ; <nl> auto tensors = EvaluateNodes ( output , item . fetch , item . feed ) ; <nl> ASSERT_EQ ( tensors . size ( ) , 1 ) ; <nl> - typedef typename EnumToDataType < DTYPE > : : Type T ; <nl> - test : : ExpectTensorNear < T > ( tensors [ 0 ] , tensors_expected [ 0 ] , 1e - 6 ) ; <nl> + if ( DTYPE = = DT_BFLOAT16 ) <nl> + test : : ExpectClose ( tensors [ 0 ] , tensors_expected [ 0 ] , 1e - 2 , 1e - 2 ) ; <nl> + else <nl> + test : : ExpectClose ( tensors [ 0 ] , tensors_expected [ 0 ] , 1e - 6 ) ; <nl> } <nl> } ; <nl> <nl> class RemapperFuseMatMulWithBiasAndActivationTest : public RemapperTest { <nl> ASSERT_EQ ( tensors_expected . size ( ) , 1 ) ; <nl> auto tensors = EvaluateNodes ( output , item . fetch , item . feed ) ; <nl> ASSERT_EQ ( tensors . size ( ) , 1 ) ; <nl> - typedef typename EnumToDataType < DTYPE > : : Type T ; <nl> - test : : ExpectTensorNear < T > ( tensors [ 0 ] , tensors_expected [ 0 ] , 1e - 6 ) ; <nl> + if ( DTYPE = = DT_BFLOAT16 ) <nl> + test : : ExpectClose ( tensors [ 0 ] , tensors_expected [ 0 ] , 1e - 2 , 1e - 2 ) ; <nl> + else <nl> + test : : ExpectClose ( tensors [ 0 ] , tensors_expected [ 0 ] , 1e - 6 ) ; <nl> } <nl> } <nl> } ; <nl> mmm a / tensorflow / core / kernels / relu_op . cc <nl> ppp b / tensorflow / core / kernels / relu_op . cc <nl> limitations under the License . <nl> # define EIGEN_USE_THREADS <nl> <nl> # include " tensorflow / core / kernels / relu_op . h " <nl> - # include " third_party / eigen3 / unsupported / Eigen / CXX11 / Tensor " <nl> # include " tensorflow / core / framework / numeric_op . h " <nl> # include " tensorflow / core / framework / op_kernel . h " <nl> # include " tensorflow / core / framework / register_types . h " <nl> # include " tensorflow / core / framework / tensor . h " <nl> # include " tensorflow / core / lib / core / errors . h " <nl> + # include " third_party / eigen3 / unsupported / Eigen / CXX11 / Tensor " <nl> <nl> namespace tensorflow { <nl> <nl> TF_CALL_REAL_NUMBER_TYPES ( REGISTER_RELU_KERNELS ) ; <nl> SeluGradOp < CPUDevice , type > ) <nl> <nl> / / Elu and Selu only make sense with float or double . <nl> - TF_CALL_GPU_NUMBER_TYPES ( REGISTER_ELU_KERNELS ) ; <nl> + TF_CALL_FLOAT_TYPES ( REGISTER_ELU_KERNELS ) ; <nl> # undef REGISTER_ELU_KERNELS <nl> <nl> # if GOOGLE_CUDA | | TENSORFLOW_USE_ROCM <nl> REGISTER_KERNEL_BUILDER ( <nl> <nl> # endif / / GOOGLE_CUDA | | TENSORFLOW_USE_ROCM <nl> <nl> - <nl> } / / namespace tensorflow <nl> | Bug fix for remapper test | tensorflow/tensorflow | e77349d7e286c5adbaf5e93eef0b0866cd80ec02 | 2020-09-25T06:36:52Z |
mmm a / folly / experimental / coro / AsyncScope . h <nl> ppp b / folly / experimental / coro / AsyncScope . h <nl> class AsyncScope { <nl> <nl> try { <nl> co_await std : : move ( awaitable ) ; <nl> - } catch ( const std : : exception & e ) { <nl> + } catch ( const OperationCancelled & ) { <nl> + } catch ( . . . ) { <nl> LOG ( DFATAL ) <nl> < < " Unhandled exception thrown from task added to AsyncScope : " <nl> - < < e . what ( ) ; <nl> - } catch ( . . . ) { <nl> - LOG ( DFATAL ) < < " Unhandled exception thrown from task added to AsyncScope " ; <nl> + < < folly : : exceptionStr ( std : : current_exception ( ) ) ; <nl> } <nl> } <nl> <nl> mmm a / folly / experimental / coro / Sleep - inl . h <nl> ppp b / folly / experimental / coro / Sleep - inl . h <nl> namespace folly { <nl> namespace coro { <nl> <nl> inline Task < void > sleep ( Duration d , Timekeeper * tk ) { <nl> + bool cancelled { false } ; <nl> folly : : coro : : Baton baton ; <nl> - auto future = <nl> - folly : : futures : : sleep ( d , tk ) . toUnsafeFuture ( ) . ensure ( [ & ] ( ) noexcept { <nl> + Try < Unit > result ; <nl> + auto future = folly : : futures : : sleep ( d , tk ) . toUnsafeFuture ( ) ; <nl> + future . setCallback_ ( <nl> + [ & result , & baton ] ( Executor : : KeepAlive < > & & , Try < Unit > & & t ) { <nl> + result = std : : move ( t ) ; <nl> baton . post ( ) ; <nl> } ) ; <nl> <nl> - CancellationCallback cancelCallback ( <nl> - co_await co_current_cancellation_token , [ & ] ( ) noexcept { <nl> - future . cancel ( ) ; <nl> - } ) ; <nl> - co_await baton ; <nl> + { <nl> + CancellationCallback cancelCallback ( <nl> + co_await co_current_cancellation_token , [ & ] ( ) noexcept { <nl> + cancelled = true ; <nl> + future . cancel ( ) ; <nl> + } ) ; <nl> + co_await baton ; <nl> + } <nl> + if ( cancelled ) { <nl> + co_yield co_error ( OperationCancelled ( ) ) ; <nl> + } <nl> + co_yield co_result ( std : : move ( result ) ) ; <nl> + } <nl> + <nl> + inline Task < void > sleepReturnEarlyOnCancel ( Duration d , Timekeeper * tk ) { <nl> + auto result = co_await co_awaitTry ( sleep ( d , tk ) ) ; <nl> + if ( result . hasException < OperationCancelled > ( ) ) { <nl> + co_return ; <nl> + } <nl> + co_yield co_result ( std : : move ( result ) ) ; <nl> } <nl> <nl> } / / namespace coro <nl> mmm a / folly / experimental / coro / Sleep . h <nl> ppp b / folly / experimental / coro / Sleep . h <nl> namespace coro { <nl> <nl> / / / Return a task that , when awaited , will sleep for the specified duration . <nl> / / / <nl> - / / / May complete sooner that the specified duration if cancellation is requested <nl> + / / / Throws folly : : OperationCancelled if cancellation is requested <nl> / / / on the awaiting coroutine ' s associated CancellationToken . <nl> Task < void > sleep ( Duration d , Timekeeper * tk = nullptr ) ; <nl> <nl> + / / / Return a task that , when awaited , will sleep for the specified duration . <nl> + / / / <nl> + / / / May complete sooner that the specified duration if cancellation is <nl> + / / / requested on the awaiting coroutine ' s associated CancellationToken . <nl> + Task < void > sleepReturnEarlyOnCancel ( Duration d , Timekeeper * tk = nullptr ) ; <nl> + <nl> } / / namespace coro <nl> } / / namespace folly <nl> <nl> mmm a / folly / experimental / coro / test / CollectTest . cpp <nl> ppp b / folly / experimental / coro / test / CollectTest . cpp <nl> <nl> # include < string > <nl> # include < vector > <nl> <nl> + folly : : coro : : Task < void > sleepThatShouldBeCancelled ( <nl> + std : : chrono : : milliseconds dur ) { <nl> + EXPECT_THROW ( co_await folly : : coro : : sleep ( dur ) , folly : : OperationCancelled ) ; <nl> + } <nl> + <nl> class CollectAllTest : public testing : : Test { } ; <nl> <nl> TEST_F ( CollectAllTest , WithNoArgs ) { <nl> TEST_F ( CollectAllTest , CollectAllCancelsSubtasksWhenParentTaskCancelled ) { <nl> cancelSource . getToken ( ) , <nl> folly : : coro : : collectAll ( <nl> [ & ] ( ) - > folly : : coro : : Task < int > { <nl> - co_await folly : : coro : : sleep ( 10s ) ; <nl> + co_await sleepThatShouldBeCancelled ( 10s ) ; <nl> co_return 42 ; <nl> } ( ) , <nl> [ & ] ( ) - > folly : : coro : : Task < float > { <nl> - co_await folly : : coro : : sleep ( 5s ) ; <nl> + co_await sleepThatShouldBeCancelled ( 5s ) ; <nl> co_return 3 . 14f ; <nl> } ( ) , <nl> [ & ] ( ) - > folly : : coro : : Task < void > { <nl> TEST_F ( CollectAllTryTest , CollectAllCancelsSubtasksWhenParentTaskCancelled ) { <nl> cancelSource . getToken ( ) , <nl> folly : : coro : : collectAllTry ( <nl> [ & ] ( ) - > folly : : coro : : Task < int > { <nl> - co_await folly : : coro : : sleep ( 10s ) ; <nl> + co_await sleepThatShouldBeCancelled ( 10s ) ; <nl> co_return 42 ; <nl> } ( ) , <nl> [ & ] ( ) - > folly : : coro : : Task < float > { <nl> - co_await folly : : coro : : sleep ( 5s ) ; <nl> + co_await sleepThatShouldBeCancelled ( 5s ) ; <nl> co_return 3 . 14f ; <nl> } ( ) , <nl> [ & ] ( ) - > folly : : coro : : Task < void > { <nl> TEST_F ( CollectAllTryRangeTest , SubtasksCancelledWhenParentTaskCancelled ) { <nl> auto generateTasks = [ & ] ( ) <nl> - > folly : : coro : : Generator < folly : : coro : : Task < void > & & > { <nl> for ( int i = 0 ; i < 10 ; + + i ) { <nl> - co_yield folly : : coro : : sleep ( 10s ) ; <nl> + co_yield sleepThatShouldBeCancelled ( 10s ) ; <nl> } <nl> <nl> co_yield [ & ] ( ) - > folly : : coro : : Task < void > { <nl> TEST_F ( CollectAllWindowedTest , SubtasksCancelledWhenParentTaskCancelled ) { <nl> bool consumedAllTasks = false ; <nl> auto generateTasks = [ & ] ( ) <nl> - > folly : : coro : : Generator < folly : : coro : : Task < void > & & > { <nl> - co_yield folly : : coro : : sleep ( 10s ) ; <nl> - co_yield folly : : coro : : sleep ( 10s ) ; <nl> + co_yield sleepThatShouldBeCancelled ( 10s ) ; <nl> + co_yield sleepThatShouldBeCancelled ( 10s ) ; <nl> <nl> co_yield [ & ] ( ) - > folly : : coro : : Task < void > { <nl> co_await folly : : coro : : co_reschedule_on_current_executor ; <nl> TEST_F ( CollectAllWindowedTest , SubtasksCancelledWhenParentTaskCancelled ) { <nl> } <nl> ( ) ; <nl> <nl> - co_yield folly : : coro : : sleep ( 10s ) ; <nl> - co_yield folly : : coro : : sleep ( 10s ) ; <nl> + co_yield sleepThatShouldBeCancelled ( 10s ) ; <nl> + co_yield sleepThatShouldBeCancelled ( 10s ) ; <nl> <nl> consumedAllTasks = true ; <nl> } ; <nl> TEST_F ( CollectAllTryWindowedTest , SubtasksCancelledWhenParentTaskCancelled ) { <nl> bool consumedAllTasks = false ; <nl> auto generateTasks = [ & ] ( ) <nl> - > folly : : coro : : Generator < folly : : coro : : Task < void > & & > { <nl> - co_yield folly : : coro : : sleep ( 10s ) ; <nl> - co_yield folly : : coro : : sleep ( 10s ) ; <nl> + co_yield sleepThatShouldBeCancelled ( 10s ) ; <nl> + co_yield sleepThatShouldBeCancelled ( 10s ) ; <nl> <nl> co_yield [ & ] ( ) - > folly : : coro : : Task < void > { <nl> co_await folly : : coro : : co_reschedule_on_current_executor ; <nl> TEST_F ( CollectAllTryWindowedTest , SubtasksCancelledWhenParentTaskCancelled ) { <nl> } <nl> ( ) ; <nl> <nl> - co_yield folly : : coro : : sleep ( 10s ) ; <nl> - co_yield folly : : coro : : sleep ( 10s ) ; <nl> + co_yield sleepThatShouldBeCancelled ( 10s ) ; <nl> + co_yield sleepThatShouldBeCancelled ( 10s ) ; <nl> <nl> consumedAllTasks = true ; <nl> } ; <nl> mmm a / folly / experimental / coro / test / CoroTest . cpp <nl> ppp b / folly / experimental / coro / test / CoroTest . cpp <nl> TEST_F ( CoroTest , CancellableSleep ) { <nl> CancellationSource cancelSrc ; <nl> <nl> auto start = steady_clock : : now ( ) ; <nl> - coro : : blockingWait ( [ & ] ( ) - > coro : : Task < void > { <nl> - co_await coro : : collectAll ( <nl> - [ & ] ( ) - > coro : : Task < void > { <nl> - co_await coro : : co_withCancellation ( <nl> - cancelSrc . getToken ( ) , coro : : sleep ( 10s ) ) ; <nl> - } ( ) , <nl> - [ & ] ( ) - > coro : : Task < void > { <nl> - co_await coro : : co_reschedule_on_current_executor ; <nl> - co_await coro : : co_reschedule_on_current_executor ; <nl> - co_await coro : : co_reschedule_on_current_executor ; <nl> - cancelSrc . requestCancellation ( ) ; <nl> - } ( ) ) ; <nl> - } ( ) ) ; <nl> + EXPECT_THROW ( <nl> + coro : : blockingWait ( [ & ] ( ) - > coro : : Task < void > { <nl> + co_await coro : : collectAll ( <nl> + [ & ] ( ) - > coro : : Task < void > { <nl> + co_await coro : : co_withCancellation ( <nl> + cancelSrc . getToken ( ) , coro : : sleep ( 10s ) ) ; <nl> + } ( ) , <nl> + [ & ] ( ) - > coro : : Task < void > { <nl> + co_await coro : : co_reschedule_on_current_executor ; <nl> + co_await coro : : co_reschedule_on_current_executor ; <nl> + co_await coro : : co_reschedule_on_current_executor ; <nl> + cancelSrc . requestCancellation ( ) ; <nl> + } ( ) ) ; <nl> + } ( ) ) , <nl> + OperationCancelled ) ; <nl> auto end = steady_clock : : now ( ) ; <nl> CHECK ( ( end - start ) < 1s ) ; <nl> } <nl> mmm a / folly / experimental / coro / test / TimeoutTest . cpp <nl> ppp b / folly / experimental / coro / test / TimeoutTest . cpp <nl> TEST ( Timeout , CancelParent ) { <nl> cancelSource . getToken ( ) , <nl> coro : : timeout ( <nl> [ ] ( ) - > coro : : Task < bool > { <nl> - co_await coro : : sleep ( 5s ) ; <nl> - co_return ( co_await coro : : co_current_cancellation_token ) <nl> - . isCancellationRequested ( ) ; <nl> + auto result = co_await coro : : co_awaitTry ( coro : : sleep ( 5s ) ) ; <nl> + co_return result . hasException < OperationCancelled > ( ) ; <nl> } ( ) , <nl> 10s ) ) , <nl> [ & ] ( ) - > coro : : Task < void > { <nl> | Make coro : : sleep throw when cancelled | facebook/folly | 8dfce3ec7ee740cc2a7e45b4738d61daa87e5c54 | 2020-11-05T03:29:23Z |
mmm a / lib / Sema / TypeCheckType . cpp <nl> ppp b / lib / Sema / TypeCheckType . cpp <nl> static void maybeDiagnoseBadConformanceRef ( DeclContext * dc , <nl> SourceLoc loc , <nl> TypeDecl * typeDecl ) { <nl> auto protocol = dyn_cast < ProtocolDecl > ( typeDecl - > getDeclContext ( ) ) ; <nl> - if ( ! protocol ) <nl> - return ; <nl> <nl> / / If we weren ' t given a conformance , go look it up . <nl> ProtocolConformance * conformance = nullptr ; <nl> - if ( auto conformanceRef = TypeChecker : : conformsToProtocol ( <nl> - parentTy , protocol , dc , <nl> - ( ConformanceCheckFlags : : InExpression | <nl> - ConformanceCheckFlags : : SuppressDependencyTracking | <nl> - ConformanceCheckFlags : : SkipConditionalRequirements ) ) ) { <nl> - if ( conformanceRef - > isConcrete ( ) ) <nl> - conformance = conformanceRef - > getConcrete ( ) ; <nl> - } <nl> + if ( protocol ) <nl> + if ( auto conformanceRef = TypeChecker : : conformsToProtocol ( <nl> + parentTy , protocol , dc , <nl> + ( ConformanceCheckFlags : : InExpression | <nl> + ConformanceCheckFlags : : SuppressDependencyTracking | <nl> + ConformanceCheckFlags : : SkipConditionalRequirements ) ) ) { <nl> + if ( conformanceRef - > isConcrete ( ) ) <nl> + conformance = conformanceRef - > getConcrete ( ) ; <nl> + } <nl> <nl> / / If any errors have occurred , don ' t bother diagnosing this cross - file <nl> / / issue . <nl> static void maybeDiagnoseBadConformanceRef ( DeclContext * dc , <nl> return ; <nl> <nl> auto diagCode = <nl> - ( conformance & & ! conformance - > getConditionalRequirementsIfAvailable ( ) ) <nl> + ( ! protocol | | ( conformance & & ! conformance - > getConditionalRequirementsIfAvailable ( ) ) ) <nl> ? diag : : unsupported_recursion_in_associated_type_reference <nl> : diag : : broken_associated_type_witness ; <nl> <nl> new file mode 100644 <nl> index 000000000000 . . 8460975c7d20 <nl> mmm / dev / null <nl> ppp b / validation - test / compiler_crashers_2_fixed / sr11052 - typealias . swift <nl> <nl> + / / RUN : % target - typecheck - verify - swift <nl> + <nl> + protocol ProtoA { <nl> + associatedtype AType1 <nl> + } <nl> + <nl> + protocol ProtoB { <nl> + associatedtype AType2 : ProtoA <nl> + func protoFunc ( ) - > AType2 . AType1 <nl> + } <nl> + <nl> + extension ProtoB { <nl> + typealias Alias = AType2 . AType1 <nl> + } <nl> + <nl> + struct Concrete < AType2 : ProtoA > : ProtoB { <nl> + <nl> + func concreteFunc ( ) - > Alias { <nl> + fatalError ( ) <nl> + } <nl> + <nl> + func protoFunc ( ) - > Alias { / / expected - error { { unsupported recursion for reference to type alias ' Alias ' of type ' Concrete < AType2 > ' } } <nl> + fatalError ( ) <nl> + } <nl> + } <nl> | Fix compiler crasher on typealias with a cycle in the constraints | apple/swift | 6166b222e28b1259198a8e463ccd533d0557d0f7 | 2019-08-13T17:20:40Z |
mmm a / src / gui / search / searchwidget . cpp <nl> ppp b / src / gui / search / searchwidget . cpp <nl> <nl> # include < QRegularExpression > <nl> # include < QShortcut > <nl> # include < QTextStream > <nl> + # include < QVector > <nl> <nl> # include " base / global . h " <nl> # include " base / search / searchpluginmanager . h " <nl> void SearchWidget : : fillCatCombobox ( ) <nl> m_ui - > comboCategory - > addItem ( SearchPluginManager : : categoryFullName ( " all " ) , QVariant ( " all " ) ) ; <nl> <nl> using QStrPair = QPair < QString , QString > ; <nl> - QList < QStrPair > tmpList ; <nl> + QVector < QStrPair > tmpList ; <nl> for ( const QString & cat : asConst ( SearchPluginManager : : instance ( ) - > getPluginCategories ( selectedPlugin ( ) ) ) ) <nl> tmpList < < qMakePair ( SearchPluginManager : : categoryFullName ( cat ) , cat ) ; <nl> std : : sort ( tmpList . begin ( ) , tmpList . end ( ) , [ ] ( const QStrPair & l , const QStrPair & r ) { return ( QString : : localeAwareCompare ( l . first , r . first ) < 0 ) ; } ) ; <nl> void SearchWidget : : fillPluginComboBox ( ) <nl> m_ui - > selectPlugin - > addItem ( tr ( " Select . . . " ) , QVariant ( " multi " ) ) ; <nl> <nl> using QStrPair = QPair < QString , QString > ; <nl> - QList < QStrPair > tmpList ; <nl> + QVector < QStrPair > tmpList ; <nl> for ( const QString & name : asConst ( SearchPluginManager : : instance ( ) - > enabledPlugins ( ) ) ) <nl> tmpList < < qMakePair ( SearchPluginManager : : instance ( ) - > pluginFullName ( name ) , name ) ; <nl> std : : sort ( tmpList . begin ( ) , tmpList . end ( ) , [ ] ( const QStrPair & l , const QStrPair & r ) { return ( l . first < r . first ) ; } ) ; <nl> | Replace QList by QVector | qbittorrent/qBittorrent | da2bfd24575e151ebb0690e258867600070a55a3 | 2019-06-26T12:30:07Z |
mmm a / include / swift / SIL / AbstractionPattern . h <nl> ppp b / include / swift / SIL / AbstractionPattern . h <nl> class AbstractionPattern { <nl> llvm_unreachable ( " bad kind " ) ; <nl> } <nl> <nl> - class TupleElementRange ; <nl> - <nl> - / / / Return a range over the tuple elements . <nl> - TupleElementRange getTupleElements ( ) const ; <nl> - <nl> / / / Given that the value being abstracted is a tuple type , return <nl> / / / the abstraction pattern for its object type . <nl> AbstractionPattern getTupleElementType ( unsigned index ) const ; <nl> class AbstractionPattern { <nl> void print ( raw_ostream & OS ) const ; <nl> } ; <nl> <nl> - / / / A range of abstraction patterns for the tuple elements of an <nl> - / / / abstraction pattern . <nl> - class AbstractionPattern : : TupleElementRange { <nl> - AbstractionPattern Parent ; <nl> - unsigned NumElements ; <nl> - public : <nl> - TupleElementRange ( AbstractionPattern parent , unsigned numElements ) <nl> - : Parent ( parent ) , NumElements ( numElements ) { } <nl> - <nl> - struct iterator { <nl> - const TupleElementRange * Range ; <nl> - unsigned Index ; <nl> - <nl> - AbstractionPattern operator * ( ) const { <nl> - return Range - > Parent . getTupleElementType ( Index ) ; <nl> - } <nl> - <nl> - iterator & operator + + ( ) { <nl> - assert ( Index < Range - > NumElements ) ; <nl> - Index + + ; <nl> - return * this ; <nl> - } <nl> - iterator operator + + ( int _ ) { <nl> - iterator saved = * this ; <nl> - operator + + ( ) ; <nl> - return saved ; <nl> - } <nl> - <nl> - bool operator = = ( const iterator & other ) const { <nl> - assert ( Range = = other . Range ) ; <nl> - return Index = = other . Index ; <nl> - } <nl> - bool operator ! = ( const iterator & other ) const { <nl> - return ! operator = = ( other ) ; <nl> - } <nl> - } ; <nl> - <nl> - iterator begin ( ) const { return { this , 0 } ; } <nl> - iterator end ( ) const { return { this , NumElements } ; } <nl> - } ; <nl> - <nl> inline llvm : : raw_ostream & operator < < ( llvm : : raw_ostream & out , <nl> const AbstractionPattern & pattern ) { <nl> pattern . print ( out ) ; <nl> return out ; <nl> } <nl> <nl> - inline AbstractionPattern : : TupleElementRange <nl> - AbstractionPattern : : getTupleElements ( ) const { <nl> - return TupleElementRange ( * this , getNumTupleElements ( ) ) ; <nl> - } <nl> - <nl> } <nl> } <nl> <nl> | SIL : Remove AbstractionPattern : : getTupleElements ( ) | apple/swift | 55814b530d7ba9cedec1ef4f2d4447d926a8b2a4 | 2018-09-25T05:59:07Z |
mmm a / dbms / src / Core / Settings . h <nl> ppp b / dbms / src / Core / Settings . h <nl> struct Settings <nl> M ( SettingBool , parallel_view_processing , false , " Enables pushing to attached views concurrently instead of sequentially . " ) \ <nl> M ( SettingBool , enable_debug_queries , false , " Enables debug queries such as AST . " ) \ <nl> M ( SettingBool , enable_unaligned_array_join , false , " Allow ARRAY JOIN with multiple arrays that have different sizes . When this settings is enabled , arrays will be resized to the longest one . " ) \ <nl> + M ( SettingBool , optimize_pk_order , false , " Enable group by optimization in reading in primary key order . " ) \ <nl> M ( SettingBool , low_cardinality_allow_in_native_format , true , " Use LowCardinality type in Native format . Otherwise , convert LowCardinality columns to ordinary for select query , and convert ordinary columns to required LowCardinality for insert query . " ) \ <nl> M ( SettingBool , allow_experimental_multiple_joins_emulation , true , " Emulate multiple joins using subselects " ) \ <nl> M ( SettingBool , allow_experimental_cross_to_join_conversion , true , " Convert CROSS JOIN to INNER JOIN if possible " ) \ <nl> mmm a / dbms / src / Interpreters / InterpreterSelectQuery . cpp <nl> ppp b / dbms / src / Interpreters / InterpreterSelectQuery . cpp <nl> <nl> # include < DataStreams / ExpressionBlockInputStream . h > <nl> # include < DataStreams / FilterBlockInputStream . h > <nl> + # include < DataStreams / FinishSortingBlockInputStream . h > <nl> # include < DataStreams / LimitBlockInputStream . h > <nl> # include < DataStreams / LimitByBlockInputStream . h > <nl> # include < DataStreams / PartialSortingBlockInputStream . h > <nl> void InterpreterSelectQuery : : executeOrder ( Pipeline & pipeline , SelectQueryInfo & <nl> { <nl> auto & query = getSelectQuery ( ) ; <nl> SortDescription order_descr = getSortDescription ( query ) ; <nl> - UInt64 limit = getLimitForSorting ( query , context ) ; <nl> <nl> + UInt64 limit = getLimitForSorting ( query , context ) ; <nl> const Settings & settings = context . getSettingsRef ( ) ; <nl> <nl> const auto & order_direction = order_descr . at ( 0 ) . direction ; <nl> <nl> - if ( auto storage_merge_tree = dynamic_cast < StorageReplicatedMergeTree * > ( storage . get ( ) ) ) <nl> + auto optimize_pk_order = [ & ] ( auto & merge_tree ) <nl> { <nl> - bool need_sorting = false ; <nl> - const auto & sorting_key_order = storage_merge_tree - > getSortingKeyColumns ( ) ; <nl> - if ( ! ( sorting_key_order . size ( ) < order_descr . size ( ) ) & & ! query . limitByValue ( ) & & ! query . groupBy ( ) ) <nl> + ASTPtr order_by_ptr = merge_tree . getSortingKeyAST ( ) ; <nl> + SortDescription prefix_order_descr ; <nl> + bool need_sorting = order_by_ptr - > children . size ( ) < order_descr . size ( ) ; <nl> + for ( size_t i = 0 ; i < std : : min ( order_descr . size ( ) , order_by_ptr - > children . size ( ) ) ; + + i ) <nl> { <nl> - for ( size_t i = 0 ; i < order_descr . size ( ) ; + + i ) <nl> + String name = order_by_ptr - > children [ i ] - > getAliasOrColumnName ( ) ; <nl> + if ( order_descr [ i ] . column_name ! = name <nl> + | | order_direction ! = order_descr [ i ] . direction ) <nl> { <nl> - if ( order_descr [ i ] . column_name ! = sorting_key_order [ i ] <nl> - | | order_direction ! = order_descr [ i ] . direction ) <nl> - { <nl> - need_sorting = true ; <nl> - break ; <nl> - } <nl> + need_sorting = true ; <nl> + break ; <nl> + } else { <nl> + prefix_order_descr . push_back ( order_descr [ i ] ) ; <nl> } <nl> + } <nl> <nl> - if ( ! need_sorting ) <nl> + query_info . do_not_steal_task = true ; <nl> + if ( need_sorting ) <nl> + { <nl> + if ( ! prefix_order_descr . empty ( ) ) <nl> { <nl> - query_info . do_not_steal_task = true ; <nl> - <nl> - pipeline . transform ( [ & ] ( auto & stream ) <nl> + pipeline . transform ( [ & ] ( auto & stream ) <nl> { <nl> - stream = std : : make_shared < AsynchronousBlockInputStream > ( stream ) ; <nl> + stream = std : : make_shared < FinishSortingBlockInputStream > ( <nl> + stream , <nl> + prefix_order_descr , <nl> + order_descr , <nl> + settings . max_block_size , <nl> + limit ) ; <nl> } ) ; <nl> - <nl> - if ( order_direction = = - 1 ) <nl> + } else <nl> + { <nl> + pipeline . transform ( [ & ] ( auto & stream ) <nl> { <nl> - pipeline . transform ( [ & ] ( auto & stream ) <nl> - { <nl> - stream = std : : make_shared < ReverseBlockInputStream > ( stream ) ; <nl> - } ) ; <nl> - } <nl> - executeUnion ( pipeline ) ; <nl> - pipeline . firstStream ( ) = std : : make_shared < MergeSortingBlockInputStream > ( <nl> - pipeline . firstStream ( ) , order_descr , settings . max_block_size , limit , <nl> - settings . max_bytes_before_remerge_sort , <nl> - settings . max_bytes_before_external_sort , context . getTemporaryPath ( ) ) ; <nl> - return ; <nl> + auto sorting_stream = std : : make_shared < PartialSortingBlockInputStream > ( stream , order_descr , limit ) ; <nl> + <nl> + / / / Limits on sorting <nl> + IBlockInputStream : : LocalLimits limits ; <nl> + limits . mode = IBlockInputStream : : LIMITS_TOTAL ; <nl> + limits . size_limits = SizeLimits ( settings . max_rows_to_sort , settings . max_bytes_to_sort , settings . sort_overflow_mode ) ; <nl> + sorting_stream - > setLimits ( limits ) ; <nl> + <nl> + stream = sorting_stream ; <nl> + } ) ; <nl> } <nl> + } <nl> + <nl> + if ( order_direction = = - 1 ) <nl> + { <nl> + pipeline . transform ( [ & ] ( auto & stream ) <nl> + { <nl> + stream = std : : make_shared < AsynchronousBlockInputStream > ( stream ) ; <nl> + } ) ; <nl> + pipeline . transform ( [ & ] ( auto & stream ) <nl> + { <nl> + stream = std : : make_shared < ReverseBlockInputStream > ( stream ) ; <nl> + } ) ; <nl> + } <nl> + executeUnion ( pipeline ) ; <nl> + pipeline . firstStream ( ) = std : : make_shared < MergeSortingBlockInputStream > ( <nl> + pipeline . firstStream ( ) , order_descr , settings . max_block_size , limit , <nl> + settings . max_bytes_before_remerge_sort , <nl> + settings . max_bytes_before_external_sort , context . getTemporaryPath ( ) ) ; <nl> + } ; <nl> + <nl> + if ( settings . optimize_pk_order ) <nl> + { <nl> + if ( const StorageMergeTree * merge_tree = dynamic_cast < const StorageMergeTree * > ( storage . get ( ) ) ) <nl> + { <nl> + optimize_pk_order ( * merge_tree ) ; <nl> + } else if ( const StorageReplicatedMergeTree * replicated_merge_tree = dynamic_cast < const StorageReplicatedMergeTree * > ( storage . get ( ) ) ) <nl> + { <nl> + optimize_pk_order ( * replicated_merge_tree ) ; <nl> } <nl> + return ; <nl> } <nl> <nl> pipeline . transform ( [ & ] ( auto & stream ) <nl> void InterpreterSelectQuery : : executeOrder ( Pipeline & pipeline , SelectQueryInfo & <nl> settings . max_bytes_before_external_sort , context . getTemporaryPath ( ) ) ; <nl> } <nl> <nl> - <nl> void InterpreterSelectQuery : : executeMergeSorted ( Pipeline & pipeline ) <nl> { <nl> auto & query = getSelectQuery ( ) ; <nl> deleted file mode 100644 <nl> index 5aeb76986fc . . 00000000000 <nl> mmm a / dbms / tests / queries / 0_stateless / 00911_group_by_pk_order . sql <nl> ppp / dev / null <nl> <nl> - CREATE DATABASE IF NOT EXISTS test ; <nl> - DROP TABLE IF EXISTS test . pk_order ; <nl> - <nl> - CREATE TABLE test . pk_order ( a UInt64 , b UInt64 , c UInt64 , d UInt64 ) ENGINE = MergeTree ( ) ORDER BY ( a , b ) ; <nl> - INSERT INTO test . pk_order ( a , b , c , d ) VALUES ( 1 , 1 , 101 , 1 ) , ( 1 , 2 , 102 , 1 ) , ( 1 , 3 , 103 , 1 ) , ( 1 , 4 , 104 , 1 ) ; ; <nl> - INSERT INTO test . pk_order ( a , b , c , d ) VALUES ( 1 , 5 , 104 , 1 ) , ( 1 , 6 , 105 , 1 ) , ( 2 , 1 , 106 , 2 ) , ( 2 , 1 , 107 , 2 ) ; <nl> - <nl> - INSERT INTO test . pk_order ( a , b , c , d ) VALUES ( 2 , 2 , 107 , 2 ) , ( 2 , 3 , 108 , 2 ) , ( 2 , 4 , 109 , 2 ) ; <nl> - <nl> - SELECT b FROM test . pk_order ORDER BY ( a , b ) ; <nl> - SELECT a FROM test . pk_order ORDER BY ( a , b ) ; <nl> - SELECT c FROM test . pk_order ORDER BY ( a , b ) ; <nl> - SELECT d FROM test . pk_order ORDER BY ( a , b ) ; <nl> - SELECT d FROM test . pk_order ORDER BY a ; <nl> - <nl> - SELECT b FROM test . pk_order ORDER BY ( a , b ) DESC ; <nl> - SELECT a FROM test . pk_order ORDER BY ( a , b ) DESC ; <nl> - SELECT c FROM test . pk_order ORDER BY ( a , b ) DESC ; <nl> - SELECT d FROM test . pk_order ORDER BY ( a , b ) DESC ; <nl> - SELECT d FROM test . pk_order ORDER BY a DESC ; <nl> - <nl> - SET max_threads = 1 ; <nl> - <nl> - SELECT b FROM test . pk_order ORDER BY a ; <nl> - SELECT a FROM test . pk_order ORDER BY a ; <nl> - SELECT c FROM test . pk_order ORDER BY ( a , b ) ; <nl> - <nl> - SELECT b FROM test . pk_order ORDER BY a DESC ; <nl> - SELECT a FROM test . pk_order ORDER BY a DESC ; <nl> - SELECT c FROM test . pk_order ORDER BY ( a , b ) DESC ; <nl> - <nl> - DROP TABLE IF EXISTS test . pk_order ; <nl> similarity index 60 % <nl> rename from dbms / tests / queries / 0_stateless / 00911_group_by_pk_order . reference <nl> rename to dbms / tests / queries / 0_stateless / 00940_order_by_pk_order . reference <nl> mmm a / dbms / tests / queries / 0_stateless / 00911_group_by_pk_order . reference <nl> ppp b / dbms / tests / queries / 0_stateless / 00940_order_by_pk_order . reference <nl> <nl> 2 <nl> 2 <nl> 2 <nl> - 4 <nl> - 3 <nl> - 2 <nl> - 1 <nl> - 1 <nl> 6 <nl> 5 <nl> 4 <nl> 3 <nl> 2 <nl> 1 <nl> + 4 <nl> + 3 <nl> 2 <nl> - 2 <nl> - 2 <nl> - 2 <nl> - 2 <nl> - 1 <nl> 1 <nl> 1 <nl> 1 <nl> 1 <nl> 1 <nl> - 109 <nl> - 108 <nl> - 107 <nl> - 106 <nl> - 107 <nl> - 105 <nl> - 104 <nl> - 104 <nl> - 103 <nl> - 102 <nl> - 101 <nl> - 2 <nl> - 2 <nl> - 2 <nl> - 2 <nl> - 2 <nl> - 1 <nl> - 1 <nl> - 1 <nl> 1 <nl> 1 <nl> 1 <nl> <nl> 2 <nl> 2 <nl> 2 <nl> + 105 <nl> + 104 <nl> + 104 <nl> + 103 <nl> + 102 <nl> + 101 <nl> + 109 <nl> + 108 <nl> + 107 <nl> + 106 <nl> + 107 <nl> 1 <nl> 1 <nl> 1 <nl> 1 <nl> 1 <nl> 1 <nl> - 1 <nl> - 5 <nl> - 2 <nl> - 6 <nl> - 3 <nl> - 4 <nl> - 1 <nl> - 2 <nl> - 1 <nl> - 3 <nl> - 4 <nl> - 1 <nl> - 1 <nl> - 1 <nl> - 1 <nl> - 1 <nl> - 1 <nl> - 2 <nl> - 2 <nl> 2 <nl> 2 <nl> 2 <nl> - 101 <nl> - 102 <nl> - 103 <nl> - 104 <nl> - 104 <nl> - 105 <nl> - 106 <nl> - 107 <nl> - 107 <nl> - 108 <nl> - 109 <nl> - 1 <nl> 2 <nl> - 1 <nl> - 3 <nl> - 4 <nl> - 5 <nl> - 1 <nl> - 6 <nl> 2 <nl> - 3 <nl> - 4 <nl> 2 <nl> 2 <nl> 2 <nl> <nl> 1 <nl> 1 <nl> 1 <nl> - 109 <nl> - 108 <nl> - 107 <nl> - 106 <nl> - 107 <nl> - 105 <nl> - 104 <nl> - 104 <nl> - 103 <nl> - 102 <nl> - 101 <nl> new file mode 100644 <nl> index 00000000000 . . b3089bf16ba <nl> mmm / dev / null <nl> ppp b / dbms / tests / queries / 0_stateless / 00940_order_by_pk_order . sql <nl> <nl> + CREATE DATABASE IF NOT EXISTS test ; <nl> + DROP TABLE IF EXISTS test . pk_order ; <nl> + <nl> + SET optimize_pk_order = 1 ; <nl> + <nl> + CREATE TABLE test . pk_order ( a UInt64 , b UInt64 , c UInt64 , d UInt64 ) ENGINE = MergeTree ( ) ORDER BY ( a , b ) ; <nl> + INSERT INTO test . pk_order ( a , b , c , d ) VALUES ( 1 , 1 , 101 , 1 ) , ( 1 , 2 , 102 , 1 ) , ( 1 , 3 , 103 , 1 ) , ( 1 , 4 , 104 , 1 ) ; ; <nl> + INSERT INTO test . pk_order ( a , b , c , d ) VALUES ( 1 , 5 , 104 , 1 ) , ( 1 , 6 , 105 , 1 ) , ( 2 , 1 , 106 , 2 ) , ( 2 , 1 , 107 , 2 ) ; <nl> + <nl> + INSERT INTO test . pk_order ( a , b , c , d ) VALUES ( 2 , 2 , 107 , 2 ) , ( 2 , 3 , 108 , 2 ) , ( 2 , 4 , 109 , 2 ) ; <nl> + <nl> + SELECT b FROM test . pk_order ORDER BY a , b ; <nl> + SELECT a FROM test . pk_order ORDER BY a , b ; <nl> + SELECT c FROM test . pk_order ORDER BY a , b ; <nl> + SELECT d FROM test . pk_order ORDER BY a , b ; <nl> + SELECT d FROM test . pk_order ORDER BY a ; <nl> + <nl> + <nl> + SELECT b FROM test . pk_order ORDER BY a , b DESC ; <nl> + SELECT a FROM test . pk_order ORDER BY a , b DESC ; <nl> + SELECT c FROM test . pk_order ORDER BY a , b DESC ; <nl> + SELECT d FROM test . pk_order ORDER BY a , b DESC ; <nl> + SELECT d FROM test . pk_order ORDER BY a DESC ; <nl> + <nl> + DROP TABLE IF EXISTS test . pk_order ; <nl> | Change pipeline + add optimize stuff into Settings . h | ClickHouse/ClickHouse | 747d2e0d3a943def736e7c7f580c71c6e43d8b04 | 2019-04-27T09:39:03Z |
mmm a / include / spdlog / details / async_log_helper . h <nl> ppp b / include / spdlog / details / async_log_helper . h <nl> class async_log_helper <nl> <nl> <nl> private : <nl> - std : : atomic < bool > _active ; <nl> formatter_ptr _formatter ; <nl> std : : vector < std : : shared_ptr < sinks : : sink > > _sinks ; <nl> q_type _q ; <nl> class async_log_helper <nl> / / async_sink class implementation <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> inline spdlog : : details : : async_log_helper : : async_log_helper ( formatter_ptr formatter , const std : : vector < sink_ptr > & sinks , size_t queue_size ) : <nl> - _active ( true ) , <nl> _formatter ( formatter ) , <nl> _sinks ( sinks ) , <nl> _q ( queue_size ) , <nl> inline spdlog : : details : : async_log_helper : : async_log_helper ( formatter_ptr formatt <nl> / / and wait for it to finish gracefully <nl> inline spdlog : : details : : async_log_helper : : ~ async_log_helper ( ) <nl> { <nl> - log ( log_msg ( level : : off ) ) ; <nl> + <nl> try <nl> { <nl> + log ( log_msg ( level : : off ) ) ; <nl> _worker_thread . join ( ) ; <nl> } <nl> - catch ( const std : : system_error & ) / / Dont crash if thread not joinable <nl> + catch ( . . . ) / / Dont crash if thread not joinable <nl> { } <nl> } <nl> <nl> inline void spdlog : : details : : async_log_helper : : log ( const details : : log_msg & msg ) <nl> <nl> inline void spdlog : : details : : async_log_helper : : worker_loop ( ) <nl> { <nl> - clock : : time_point last_pop = clock : : now ( ) ; <nl> - while ( _active ) <nl> + try <nl> + { <nl> + clock : : time_point last_pop = clock : : now ( ) ; <nl> + while ( process_next_msg ( last_pop ) ) ; <nl> + } <nl> + catch ( const std : : exception & ex ) <nl> { <nl> - / / Dont die if there are still messages in the q to process <nl> - while ( process_next_msg ( last_pop ) ) ; <nl> + _last_workerthread_ex = std : : make_shared < spdlog_ex > ( std : : string ( " async_logger worker thread exception : " ) + ex . what ( ) ) ; <nl> } <nl> + catch ( . . . ) <nl> + { <nl> + _last_workerthread_ex = std : : make_shared < spdlog_ex > ( " async_logger worker thread exception " ) ; <nl> + } <nl> } <nl> <nl> - / / Process next message in the queue <nl> - / / Return true if message was processed in the queue , or false if queue was empty <nl> - / / Will set _active to be false upon receiving log_msg with level = = off ( idicating the worker need to die ) <nl> + / / Process next message in the queue <nl> + / / Return true if this thread should still be active ( no msg with level : : off was received ) <nl> inline bool spdlog : : details : : async_log_helper : : process_next_msg ( clock : : time_point & last_pop ) <nl> { <nl> <nl> inline bool spdlog : : details : : async_log_helper : : process_next_msg ( clock : : time_poin <nl> <nl> if ( _q . dequeue ( incoming_async_msg ) ) <nl> { <nl> - last_pop = clock : : now ( ) ; <nl> - try <nl> - { <nl> - incoming_async_msg . fill_log_msg ( incoming_log_msg ) ; <nl> - if ( incoming_log_msg . level = = level : : off ) <nl> - { <nl> - _active = false ; <nl> - return false ; <nl> - } <nl> - _formatter - > format ( incoming_log_msg ) ; <nl> - for ( auto & s : _sinks ) <nl> - s - > log ( incoming_log_msg ) ; <nl> - } <nl> - catch ( const std : : exception & ex ) <nl> - { <nl> - _last_workerthread_ex = std : : make_shared < spdlog_ex > ( std : : string ( " async_logger worker thread exception : " ) + ex . what ( ) ) ; <nl> - } <nl> - catch ( . . . ) <nl> - { <nl> - _last_workerthread_ex = std : : make_shared < spdlog_ex > ( " async_logger worker thread exception " ) ; <nl> - } <nl> - return true ; <nl> - } <nl> - / / sleep or yield if queue is empty . <nl> - else <nl> + last_pop = clock : : now ( ) ; <nl> + <nl> + if ( incoming_async_msg . level = = level : : off ) <nl> + return false ; <nl> + <nl> + incoming_async_msg . fill_log_msg ( incoming_log_msg ) ; <nl> + _formatter - > format ( incoming_log_msg ) ; <nl> + for ( auto & s : _sinks ) <nl> + s - > log ( incoming_log_msg ) ; <nl> + } <nl> + else / / empty queue <nl> { <nl> - sleep_or_yield ( last_pop ) ; <nl> - return false ; <nl> + sleep_or_yield ( last_pop ) ; <nl> } <nl> + return true ; <nl> } <nl> <nl> inline void spdlog : : details : : async_log_helper : : set_formatter ( formatter_ptr msg_formatter ) <nl> inline void spdlog : : details : : async_log_helper : : throw_if_bad_worker ( ) <nl> auto ex = std : : move ( _last_workerthread_ex ) ; <nl> throw * ex ; <nl> } <nl> - if ( ! _active ) <nl> - throw ( spdlog_ex ( " async logger is not active " ) ) ; <nl> } <nl> <nl> <nl> | simplified worker thread in async logger | gabime/spdlog | 616cce5b7114c9dcab017ec57f836f2cc308ff5d | 2014-12-21T00:26:53Z |
mmm a / editor / code_editor . cpp <nl> ppp b / editor / code_editor . cpp <nl> void FindReplaceBar : : _replace_all ( ) { <nl> <nl> text_edit - > begin_complex_operation ( ) ; <nl> <nl> - while ( search_next ( ) ) { <nl> - <nl> - / / replace area <nl> - Point2i match_from ( result_line , result_col ) ; <nl> - Point2i match_to ( result_line , result_col + search_text_len ) ; <nl> - <nl> - if ( match_from < prev_match ) <nl> - break ; / / done <nl> + if ( search_current ( ) ) { <nl> + do { <nl> + / / replace area <nl> + Point2i match_from ( result_line , result_col ) ; <nl> + Point2i match_to ( result_line , result_col + search_text_len ) ; <nl> + <nl> + if ( match_from < prev_match ) { <nl> + break ; / / done <nl> + } <nl> <nl> - prev_match = Point2i ( result_line , result_col + replace_text . length ( ) ) ; <nl> + prev_match = Point2i ( result_line , result_col + replace_text . length ( ) ) ; <nl> <nl> - text_edit - > unfold_line ( result_line ) ; <nl> - text_edit - > select ( result_line , result_col , result_line , match_to . y ) ; <nl> + text_edit - > unfold_line ( result_line ) ; <nl> + text_edit - > select ( result_line , result_col , result_line , match_to . y ) ; <nl> <nl> - if ( selection_enabled & & is_selection_only ( ) ) { <nl> + if ( selection_enabled & & is_selection_only ( ) ) { <nl> + if ( match_from < selection_begin | | match_to > selection_end ) { <nl> + continue ; <nl> + } <nl> <nl> - if ( match_from < selection_begin | | match_to > selection_end ) <nl> - continue ; <nl> + / / replace but adjust selection bounds <nl> + text_edit - > insert_text_at_cursor ( replace_text ) ; <nl> + if ( match_to . x = = selection_end . x ) { <nl> + selection_end . y + = replace_text . length ( ) - search_text_len ; <nl> + } <nl> <nl> - / / replace but adjust selection bounds <nl> - text_edit - > insert_text_at_cursor ( replace_text ) ; <nl> - if ( match_to . x = = selection_end . x ) <nl> - selection_end . y + = replace_text . length ( ) - search_text_len ; <nl> - } else { <nl> - / / just replace <nl> - text_edit - > insert_text_at_cursor ( replace_text ) ; <nl> - } <nl> + } else { <nl> + / / just replace <nl> + text_edit - > insert_text_at_cursor ( replace_text ) ; <nl> + } <nl> <nl> - rc + + ; <nl> + rc + + ; <nl> + } while ( search_next ( ) ) ; <nl> } <nl> <nl> text_edit - > end_complex_operation ( ) ; <nl> | Merge pull request from Crazy - P / Resloves_Replace_all_doesnt_replace_all | godotengine/godot | b6bf26a549b163ae35ff208223a6ce6b59489b0b | 2018-04-07T19:33:31Z |
mmm a / hphp / hack / src / typing / typing . ml <nl> ppp b / hphp / hack / src / typing / typing . ml <nl> and obj_get_concrete_ty ~ is_method ~ valkind ? ( explicit_tparams = [ ] ) <nl> <nl> | Some class_info when not is_method <nl> & & not ( Env . is_strict env ) <nl> + & & not ( Partial . should_check_error ( Env . get_mode env ) 4053 ) <nl> & & ( Cls . name class_info ) = SN . Classes . cStdClass - > <nl> default ( ) <nl> <nl> | Support 4053 in error_codes_treated_strictly | facebook/hhvm | 861ed5aaa8f1dd126e5bd6bc0c96281c84a6c750 | 2019-07-01T19:58:57Z |
mmm a / tests / lua - tests / src / Physics3DTest / Physics3DTest . lua <nl> ppp b / tests / lua - tests / src / Physics3DTest / Physics3DTest . lua <nl> function Physics3DConstraintDemo : extend ( ) <nl> component : syncNodeToPhysics ( ) <nl> <nl> local frameInA = cc . mat4 . createRotationZ ( cc . mat4 . createIdentity ( ) , math . pi / 2 ) <nl> - local frameInB = frameInA <nl> + local frameInB = { } <nl> + for i = 1 , 16 do <nl> + frameInB [ i ] = frameInA [ i ] <nl> + end <nl> frameInA [ 14 ] = - 5 . 0 <nl> frameInB [ 14 ] = 5 . 0 <nl> constraint = cc . Physics3DSliderConstraint : create ( rigidBody , rigidBodyB , frameInA , frameInB , false ) <nl> | Fix the bugs about the Physics3DTest for Lua . | cocos2d/cocos2d-x | 6c749a77f2c2fa2ac0d1200e4a3cd7dd71c7b443 | 2015-06-18T03:17:08Z |
mmm a / hphp / hack / src / hhbc / emit_program . rs <nl> ppp b / hphp / hack / src / hhbc / emit_program . rs <nl> use emit_fatal_rust : : emit_fatal ; <nl> use emit_file_attributes_rust : : emit_file_attributes_from_program ; <nl> use emit_function_rust : : emit_functions_from_program ; <nl> use emit_record_def_rust : : emit_record_defs_from_program ; <nl> + use emit_typedef_rust : : emit_typedefs_from_program ; <nl> use env : : { self , emitter : : Emitter } ; <nl> use hhas_body_rust : : HhasBody ; <nl> use hhas_program_rust : : HhasProgram ; <nl> fn emit_program_ < ' p > ( <nl> let classes = emit_classes_from_program ( & mut emitter , prog ) ? ; <nl> let file_attributes = emit_file_attributes_from_program ( & mut emitter , prog ) ? ; <nl> let functions = emit_functions_from_program ( & mut emitter , ast_defs ) ? ; <nl> + let typedefs = emit_typedefs_from_program ( & mut emitter , prog ) ? ; <nl> <nl> Ok ( HhasProgram { <nl> main , <nl> record_defs , <nl> classes , <nl> functions , <nl> + typedefs , <nl> is_hh : flags . contains ( FromAstFlags : : IS_HH_FILE ) , <nl> file_attributes , <nl> . . HhasProgram : : default ( ) <nl> mmm a / hphp / hack / src / hhbc / emit_type_constant . rs <nl> ppp b / hphp / hack / src / hhbc / emit_type_constant . rs <nl> fn vec_or_varray ( opts : & Options , l : Vec < TypedValue > ) - > TypedValue { <nl> if hack_arr_dv_arrs ( opts ) { <nl> TypedValue : : Vec ( ( l , None ) ) <nl> } else { <nl> - TypedValue : : VArray ( l ) <nl> + TypedValue : : VArray ( ( l , None ) ) <nl> } <nl> } <nl> <nl> fn hint_to_type_constant_list ( <nl> Happly ( s , hints ) = > { <nl> let ast_defs : : Id ( _ , name ) = s ; <nl> if hints . is_empty ( ) { <nl> - let id = * targ_map <nl> - . get ( & name . as_str ( ) ) <nl> - . expect ( " Hints not available on the original AST " ) ; <nl> - [ <nl> - vec ! [ ( TypedValue : : String ( " id " . into ( ) ) , TypedValue : : Int ( id ) ) ] , <nl> - get_kind ( tparams , " $ $ internal $ $ reifiedtype " ) , <nl> - ] <nl> - . concat ( ) <nl> - } else { <nl> - let generic_types = if name . eq_ignore_ascii_case ( classes : : CLASS_NAME ) <nl> - | | name . eq_ignore_ascii_case ( classes : : TYPE_NAME ) <nl> - { <nl> - vec ! [ ] <nl> - } else { <nl> - get_generic_types ( opts , tparams , targ_map , hints ) ? <nl> - } ; <nl> - let ( classname , kind ) = resolve_classname ( tparams , name . to_owned ( ) ) ; <nl> - [ generic_types , classname , kind ] . concat ( ) <nl> + if let Some ( id ) = targ_map . get ( name . as_str ( ) ) { <nl> + let mut r = get_kind ( tparams , " $ $ internal $ $ reifiedtype " ) ; <nl> + r . push ( ( TypedValue : : String ( " id " . into ( ) ) , TypedValue : : Int ( * id ) ) ) ; <nl> + return Ok ( r ) ; <nl> + } <nl> } <nl> + let ( mut classname , kind ) = resolve_classname ( tparams , name . to_owned ( ) ) ; <nl> + let mut r = kind ; <nl> + r . append ( & mut classname ) ; <nl> + if ! ( name . eq_ignore_ascii_case ( classes : : CLASS_NAME ) <nl> + | | name . eq_ignore_ascii_case ( classes : : TYPE_NAME ) ) <nl> + { <nl> + r . append ( & mut get_generic_types ( opts , tparams , targ_map , hints ) ? ) ; <nl> + } ; <nl> + r <nl> } <nl> Hshape ( si ) = > [ <nl> vec ! [ ( <nl> fn hint_to_type_constant_list ( <nl> TypedValue : : String ( " param_types " . into ( ) ) , <nl> hints_to_type_constant ( opts , tparams , targ_map , & hf . param_tys ) ? , <nl> ) ] ; <nl> - [ variadic_type , param_types , return_type , kind ] . concat ( ) <nl> + [ kind , return_type , param_types , variadic_type ] . concat ( ) <nl> } <nl> } <nl> Htuple ( hints ) = > { <nl> fn hint_to_type_constant_list ( <nl> TypedValue : : String ( " elem_types " . into ( ) ) , <nl> hints_to_type_constant ( opts , tparams , targ_map , hints ) ? , <nl> ) ] ; <nl> - [ elem_types , kind ] . concat ( ) <nl> + [ kind , elem_types ] . concat ( ) <nl> } <nl> Hoption ( h ) = > [ <nl> hint_to_type_constant_list ( opts , tparams , targ_map , h ) ? , <nl> fn hint_to_type_constant_list ( <nl> ] <nl> . concat ( ) , <nl> Hsoft ( h ) = > [ <nl> - hint_to_type_constant_list ( opts , tparams , targ_map , h ) ? , <nl> vec ! [ ( TypedValue : : String ( " soft " . into ( ) ) , TypedValue : : Bool ( true ) ) ] , <nl> + hint_to_type_constant_list ( opts , tparams , targ_map , h ) ? , <nl> ] <nl> . concat ( ) , <nl> Hlike ( h ) = > [ <nl> - hint_to_type_constant_list ( opts , tparams , targ_map , h ) ? , <nl> vec ! [ ( TypedValue : : String ( " like " . into ( ) ) , TypedValue : : Bool ( true ) ) ] , <nl> + hint_to_type_constant_list ( opts , tparams , targ_map , h ) ? , <nl> ] <nl> . concat ( ) , <nl> HpuAccess ( _ , _ , _ ) = > { <nl> mmm a / hphp / hack / src / hhbc / emit_type_hint . rs <nl> ppp b / hphp / hack / src / hhbc / emit_type_hint . rs <nl> fn hint_to_type_constraint ( <nl> } <nl> _ = > ( ) , <nl> } ; <nl> - happly_helper ( tparams , kind , pos , s ) . unwrap ( ) <nl> + happly_helper ( tparams , kind , pos , s ) ? <nl> } <nl> - h = > happly_helper ( tparams , kind , pos , & hint_to_string ( h ) ) . unwrap ( ) , <nl> + h = > happly_helper ( tparams , kind , pos , & hint_to_string ( h ) ) ? , <nl> } ) <nl> } <nl> <nl> fn make_tc_with_flags_if_non_empty_flags ( <nl> fn happly_helper ( tparams : & [ & str ] , kind : & Kind , pos : & Pos , name : & str ) - > Result < constraint : : Type > { <nl> use constraint : : { Flags , Type } ; <nl> if tparams . contains ( & name ) { <nl> - Ok ( Type : : make_with_raw_str ( <nl> - " " , <nl> + Ok ( Type : : make ( <nl> + Some ( " " . into ( ) ) , <nl> Flags : : EXTENDED_HINT | Flags : : TYPE_VAR , <nl> ) ) <nl> } else if string_utils : : is_self ( & name ) | | string_utils : : is_parent ( name ) { <nl> fn make_type_info ( <nl> Ok ( Info : : make ( type_info_user_type , type_info_type_constraint ) ) <nl> } <nl> <nl> - pub fn hint_to_type_info ( <nl> + fn param_hint_to_type_info ( <nl> kind : & Kind , <nl> skipawaitable : bool , <nl> nullable : bool , <nl> tparams : & [ & str ] , <nl> hint : & Hint , <nl> ) - > Result < Info > { <nl> + let Hint ( _ , h ) = hint ; <nl> + let is_simple_hint = match h . as_ref ( ) { <nl> + Hsoft ( _ ) <nl> + | Hoption ( _ ) <nl> + | Haccess ( _ , _ ) <nl> + | Hfun ( _ ) <nl> + | Hdynamic <nl> + | Hnonnull <nl> + | Hmixed <nl> + | Harray ( Some ( _ ) , Some ( _ ) ) <nl> + | Hdarray ( _ , _ ) = > false , <nl> + Happly ( Id ( _ , s ) , hs ) = > { <nl> + if ! hs . is_empty ( ) { <nl> + false <nl> + } else if s = = " \ \ HH \ \ dynamic " | | s = = " \ \ HH \ \ nonnull " | | s = = " \ \ HH \ \ mixed " { <nl> + false <nl> + } else { <nl> + ! tparams . contains ( & s . as_str ( ) ) <nl> + } <nl> + } <nl> + Habstr ( s ) = > ! tparams . contains ( & s . as_str ( ) ) , <nl> + Herr | Hany = > { <nl> + return Err ( Unrecoverable ( <nl> + " Expected error on Tany in naming : param_hint_to_type_info " . into ( ) , <nl> + ) ) <nl> + } <nl> + _ = > true , <nl> + } ; <nl> let tc = hint_to_type_constraint ( kind , tparams , skipawaitable , hint ) ? ; <nl> - if let Kind : : Param = kind { <nl> - return make_type_info ( <nl> - tparams , <nl> + make_type_info ( <nl> + tparams , <nl> + hint , <nl> + tc . name , <nl> + try_add_nullable ( <nl> + nullable , <nl> hint , <nl> - tc . name , <nl> - try_add_nullable ( nullable , hint , tc . flags ) , <nl> - ) ; <nl> + if is_simple_hint { <nl> + constraint : : Flags : : empty ( ) <nl> + } else { <nl> + tc . flags <nl> + } , <nl> + ) , <nl> + ) <nl> + } <nl> + <nl> + pub fn hint_to_type_info ( <nl> + kind : & Kind , <nl> + skipawaitable : bool , <nl> + nullable : bool , <nl> + tparams : & [ & str ] , <nl> + hint : & Hint , <nl> + ) - > Result < Info > { <nl> + if let Kind : : Param = kind { <nl> + return param_hint_to_type_info ( kind , skipawaitable , nullable , tparams , hint ) ; <nl> } ; <nl> + let tc = hint_to_type_constraint ( kind , tparams , skipawaitable , hint ) ? ; <nl> let flags = match kind { <nl> Kind : : Return | Kind : : Property if tc . name . is_some ( ) = > { <nl> constraint : : Flags : : EXTENDED_HINT | tc . flags <nl> mmm a / hphp / hack / src / hhbc / hhbc_hhas . ml <nl> ppp b / hphp / hack / src / hhbc / hhbc_hhas . ml <nl> let string_of_typedef_info ti = <nl> let flags = <nl> List . filter ~ f : ( fun f - > f = Hhas_type_constraint . Nullable ) flags <nl> in <nl> - let flags_text = string_of_type_flags flags in <nl> - " < " <nl> - ^ SU . quote_string ( Option . value ~ default : " " name ) <nl> - ^ " " <nl> - ^ flags_text <nl> - ^ " > " <nl> + let flags_text = <nl> + if not ( List . is_empty flags ) then <nl> + " " ^ string_of_type_flags flags ^ " " <nl> + else <nl> + " " <nl> + in <nl> + " < " ^ SU . quote_string ( Option . value ~ default : " " name ) ^ flags_text ^ " > " <nl> <nl> let string_of_type_info_option tio = <nl> match tio with <nl> mmm a / hphp / hack / src / hhbc / instruction_sequence . rs <nl> ppp b / hphp / hack / src / hhbc / instruction_sequence . rs <nl> impl InstrSeq { <nl> Self : : make_instr ( Instruct : : ILitConst ( l ) ) <nl> } <nl> <nl> - pub fn make_lit_empty_varray ( ) - > Self { <nl> + / * TODO ( hrust ) : re - enable it with arg <nl> + pub fn make_lit_empty_varray ( ) - > Self { <nl> Self : : make_lit_const ( InstructLitConst : : TypedValue ( TypedValue : : VArray ( vec ! [ ] ) ) ) <nl> - } <nl> + } * / <nl> <nl> pub fn make_iterinit ( args : IterArgs , label : Label ) - > Self { <nl> Self : : make_instr ( Instruct : : IIterator ( InstructIterator : : IterInit ( args , label ) ) ) <nl> mmm a / hphp / hack / src / hhbc / print . rs <nl> ppp b / hphp / hack / src / hhbc / print . rs <nl> use hhas_property_rust : : HhasProperty ; <nl> use hhas_record_def_rust : : { Field , HhasRecord } ; <nl> use hhas_type : : { constraint , Info as HhasTypeInfo } ; <nl> use hhas_type_const : : HhasTypeConstant ; <nl> + use hhas_typedef_rust : : Typedef as HhasTypedef ; <nl> use hhbc_ast_rust : : * ; <nl> use hhbc_id_rust : : { class , Id } ; <nl> use hhbc_string_utils_rust : : { <nl> - float , integer , lstrip , quote_string_with_escape , strip_global_ns , strip_ns , <nl> + float , integer , lstrip , quote_string , quote_string_with_escape , strip_global_ns , strip_ns , <nl> triple_quote_string , types , <nl> } ; <nl> use instruction_sequence_rust : : InstrSeq ; <nl> fn print_program_ < W : Write > ( <nl> concat ( w , & prog . functions , | w , f | print_fun_def ( ctx , w , f ) ) ? ; <nl> concat ( w , & prog . record_defs , | w , rd | print_record_def ( ctx , w , rd ) ) ? ; <nl> concat ( w , & prog . classes , | w , cd | print_class_def ( ctx , w , cd ) ) ? ; <nl> + concat ( w , & prog . typedefs , | w , td | print_typedef ( ctx , w , td ) ) ? ; <nl> print_file_attributes ( ctx , w , & prog . file_attributes ) ? ; <nl> <nl> if ctx . dump_symbol_refs ( ) { <nl> fn print_program_ < W : Write > ( <nl> Ok ( ( ) ) <nl> } <nl> <nl> + fn print_typedef < W : Write > ( ctx : & mut Context , w : & mut W , td : & HhasTypedef ) - > Result < ( ) , W : : Error > { <nl> + newline ( w ) ? ; <nl> + w . write ( " . alias " ) ? ; <nl> + print_typedef_attributes ( ctx , w , td ) ? ; <nl> + w . write ( td . name . to_raw_string ( ) ) ? ; <nl> + w . write ( " = " ) ? ; <nl> + print_typedef_info ( w , & td . type_info ) ? ; <nl> + w . write ( " " ) ? ; <nl> + wrap_by_triple_quotes ( w , | w | print_adata ( ctx , w , & td . type_structure ) ) ? ; <nl> + w . write ( " ; " ) <nl> + } <nl> + <nl> + fn print_typedef_attributes < W : Write > ( <nl> + ctx : & mut Context , <nl> + w : & mut W , <nl> + td : & HhasTypedef , <nl> + ) - > Result < ( ) , W : : Error > { <nl> + let mut specials = vec ! [ ] ; <nl> + if ctx . is_system_lib ( ) { <nl> + specials . push ( " persistent " ) ; <nl> + } <nl> + print_special_and_user_attrs ( ctx , w , & specials [ . . ] , td . attributes . as_slice ( ) ) <nl> + } <nl> + <nl> fn print_data_region_element < W : Write > ( w : & mut W , fake_elem : usize ) - > Result < ( ) , W : : Error > { <nl> not_impl ! ( ) <nl> } <nl> fn print_adata < W : Write > ( ctx : & mut Context , w : & mut W , tv : & TypedValue ) - > Resul <nl> TypedValue : : Keyset ( values ) = > { <nl> print_adata_collection_argument ( ctx , w , ADATA_KEYSET_PREFIX , & None , values ) <nl> } <nl> - _ = > not_impl ! ( ) , <nl> + TypedValue : : VArray ( ( values , loc ) ) = > { <nl> + print_adata_collection_argument ( ctx , w , ADATA_VARRAY_PREFIX , loc , values ) <nl> + } <nl> + TypedValue : : HhasAdata ( _ ) = > not_impl ! ( ) , <nl> } <nl> } <nl> <nl> fn print_include_eval_define < W : Write > ( <nl> DefCls ( n ) = > concat_str_by ( w , " " , [ " DefCls " , n . to_string ( ) . as_str ( ) ] ) , <nl> DefClsNop ( n ) = > concat_str_by ( w , " " , [ " DefClsNop " , n . to_string ( ) . as_str ( ) ] ) , <nl> DefRecord ( n ) = > concat_str_by ( w , " " , [ " DefRecord " , n . to_string ( ) . as_str ( ) ] ) , <nl> - DefCns ( _ ) = > not_impl ! ( ) , <nl> - DefTypeAlias ( _ ) = > not_impl ! ( ) , <nl> + DefCns ( id ) = > { <nl> + w . write ( " DefCns " ) ? ; <nl> + print_hhbc_id ( w , id ) <nl> + } <nl> + DefTypeAlias ( id ) = > w . write ( format ! ( " DefTypeAlias { } " , id ) ) , <nl> } <nl> } <nl> <nl> fn print_lit_const < W : Write > ( w : & mut W , lit : & InstructLitConst ) - > Result < ( ) , W : <nl> Int ( i ) = > concat_str_by ( w , " " , [ " Int " , i . to_string ( ) . as_str ( ) ] ) , <nl> String ( s ) = > { <nl> w . write ( " String " ) ? ; <nl> - wrap_by_quotes ( w , | w | w . write ( s ) ) <nl> + wrap_by_quotes ( w , | w | w . write ( escape ( s ) ) ) <nl> } <nl> _ = > not_impl ! ( ) , <nl> } <nl> } <nl> <nl> fn print_op < W : Write > ( w : & mut W , op : & InstructOperator ) - > Result < ( ) , W : : Error > { <nl> - use InstructOperator : : * ; <nl> + use InstructOperator as I ; <nl> match op { <nl> - Fatal ( fatal_op ) = > print_fatal_op ( w , fatal_op ) , <nl> + I : : Fatal ( fatal_op ) = > print_fatal_op ( w , fatal_op ) , <nl> _ = > not_impl ! ( ) , <nl> } <nl> } <nl> <nl> fn print_fatal_op < W : Write > ( w : & mut W , f : & FatalOp ) - > Result < ( ) , W : : Error > { <nl> - use FatalOp : : * ; <nl> match f { <nl> - Parse = > w . write ( " Fatal Parse " ) , <nl> - Runtime = > w . write ( " Fatal Runtime " ) , <nl> - RuntimeOmitFrame = > w . write ( " Fatal RuntimeOmitFrame " ) , <nl> + FatalOp : : Parse = > w . write ( " Fatal Parse " ) , <nl> + FatalOp : : Runtime = > w . write ( " Fatal Runtime " ) , <nl> + FatalOp : : RuntimeOmitFrame = > w . write ( " Fatal RuntimeOmitFrame " ) , <nl> } <nl> } <nl> <nl> fn print_type_info < W : Write > ( w : & mut W , ti : & HhasTypeInfo ) - > Result < ( ) , W : : Erro <nl> print_type_info_ ( w , false , ti ) <nl> } <nl> <nl> - fn print_type_info_ < W : Write > ( w : & mut W , is_enum : bool , ti : & HhasTypeInfo ) - > Result < ( ) , W : : Error > { <nl> - let print_flag = | w : & mut W , flag : constraint : : Flags | { <nl> - let mut first = true ; <nl> - let mut print_space = | w : & mut W | - > Result < ( ) , W : : Error > { <nl> - if ! first { <nl> - w . write ( " " ) <nl> - } else { <nl> - Ok ( first = false ) <nl> - } <nl> - } ; <nl> - use constraint : : Flags as F ; <nl> - if flag . contains ( F : : DISPLAY_NULLABLE ) { <nl> - print_space ( w ) ? ; <nl> - w . write ( " display_nullable " ) ? ; <nl> - } <nl> - if flag . contains ( F : : EXTENDED_HINT ) { <nl> - print_space ( w ) ? ; <nl> - w . write ( " extended_hint " ) ? ; <nl> - } <nl> - if flag . contains ( F : : NULLABLE ) { <nl> - print_space ( w ) ? ; <nl> - w . write ( " nullable " ) ? ; <nl> + fn print_type_flags < W : Write > ( w : & mut W , flag : constraint : : Flags ) - > Result < ( ) , W : : Error > { <nl> + let mut first = true ; <nl> + let mut print_space = | w : & mut W | - > Result < ( ) , W : : Error > { <nl> + if ! first { <nl> + w . write ( " " ) <nl> + } else { <nl> + Ok ( first = false ) <nl> } <nl> + } ; <nl> + use constraint : : Flags as F ; <nl> + if flag . contains ( F : : DISPLAY_NULLABLE ) { <nl> + print_space ( w ) ? ; <nl> + w . write ( " display_nullable " ) ? ; <nl> + } <nl> + if flag . contains ( F : : EXTENDED_HINT ) { <nl> + print_space ( w ) ? ; <nl> + w . write ( " extended_hint " ) ? ; <nl> + } <nl> + if flag . contains ( F : : NULLABLE ) { <nl> + print_space ( w ) ? ; <nl> + w . write ( " nullable " ) ? ; <nl> + } <nl> <nl> - if flag . contains ( F : : SOFT ) { <nl> - print_space ( w ) ? ; <nl> - w . write ( " soft " ) ? ; <nl> - } <nl> - if flag . contains ( F : : TYPE_CONSTANT ) { <nl> - print_space ( w ) ? ; <nl> - w . write ( " type_constant " ) ? ; <nl> - } <nl> + if flag . contains ( F : : SOFT ) { <nl> + print_space ( w ) ? ; <nl> + w . write ( " soft " ) ? ; <nl> + } <nl> + if flag . contains ( F : : TYPE_CONSTANT ) { <nl> + print_space ( w ) ? ; <nl> + w . write ( " type_constant " ) ? ; <nl> + } <nl> <nl> - if flag . contains ( F : : TYPE_VAR ) { <nl> - print_space ( w ) ? ; <nl> - w . write ( " type_var " ) ? ; <nl> - } <nl> + if flag . contains ( F : : TYPE_VAR ) { <nl> + print_space ( w ) ? ; <nl> + w . write ( " type_var " ) ? ; <nl> + } <nl> <nl> - if flag . contains ( F : : UPPERBOUND ) { <nl> - print_space ( w ) ? ; <nl> - w . write ( " upperbound " ) ? ; <nl> - } <nl> - Ok ( ( ) ) <nl> - } ; <nl> + if flag . contains ( F : : UPPERBOUND ) { <nl> + print_space ( w ) ? ; <nl> + w . write ( " upperbound " ) ? ; <nl> + } <nl> + Ok ( ( ) ) <nl> + } <nl> + <nl> + fn print_type_info_ < W : Write > ( w : & mut W , is_enum : bool , ti : & HhasTypeInfo ) - > Result < ( ) , W : : Error > { <nl> let print_quote_str = | w : & mut W , opt : & Option < String > | { <nl> option_or ( <nl> w , <nl> fn print_type_info_ < W : Write > ( w : & mut W , is_enum : bool , ti : & HhasTypeInfo ) - > Re <nl> print_quote_str ( w , & ti . type_constraint . name ) ? ; <nl> w . write ( " " ) ? ; <nl> } <nl> - print_flag ( w , ti . type_constraint . flags ) <nl> + print_type_flags ( w , ti . type_constraint . flags ) <nl> + } ) <nl> + } <nl> + <nl> + fn print_typedef_info < W : Write > ( w : & mut W , ti : & HhasTypeInfo ) - > Result < ( ) , W : : Error > { <nl> + wrap_by_angle ( w , | w | { <nl> + w . write ( quote_string ( <nl> + ti . type_constraint . name . as_ref ( ) . map_or ( " " , | n | n . as_str ( ) ) , <nl> + ) ) ? ; <nl> + let flags = ti . type_constraint . flags & constraint : : Flags : : NULLABLE ; <nl> + if ! flags . is_empty ( ) { <nl> + wrap_by ( w , " " , | w | { <nl> + print_type_flags ( w , ti . type_constraint . flags & constraint : : Flags : : NULLABLE ) <nl> + } ) ? ; <nl> + } <nl> + Ok ( ( ) ) <nl> } ) <nl> } <nl> <nl> fn print_record_field < W : Write > ( <nl> c . newline ( w ) ? ; <nl> match intial_value { <nl> None = > w . write ( " uninit " ) ? , <nl> - Some ( value ) = > wrap_by_quotes ( w , | w | print_adata ( c , w , value ) ) ? , <nl> + Some ( value ) = > wrap_by_triple_quotes ( w , | w | print_adata ( c , w , value ) ) ? , <nl> } <nl> w . write ( " ; " ) <nl> } ) <nl> fn print_record_def < W : Write > ( <nl> } ) ? ; <nl> newline ( w ) <nl> } <nl> + <nl> + fn print_hhbc_id < ' a , W : Write , I : Id < ' a > > ( w : & mut W , id : & I ) - > Result < ( ) , W : : Error > { <nl> + wrap_by_quotes ( w , | w | w . write ( escape ( id . to_raw_string ( ) ) ) ) <nl> + } <nl> mmm a / hphp / hack / src / hhbc / string_utils . rs <nl> ppp b / hphp / hack / src / hhbc / string_utils . rs <nl> pub fn mangle ( mut name : String ) - > String { <nl> } <nl> <nl> pub fn quote_string ( s : & str ) - > String { <nl> - format ! ( " \ \ { } \ \ " , escape ( s ) ) <nl> + format ! ( " \ " { } \ " " , escape ( s ) ) <nl> } <nl> <nl> pub fn quote_string_with_escape ( s : & str ) - > String { <nl> mod string_utils_tests { <nl> # [ test ] <nl> fn quote_string_test ( ) { <nl> let some_string = " test " ; <nl> - assert_eq ! ( super : : quote_string ( & some_string ) , " \ \ test \ \ " ) ; <nl> + assert_eq ! ( super : : quote_string ( & some_string ) , " \ " test \ " " ) ; <nl> } <nl> <nl> # [ test ] <nl> mmm a / hphp / hack / src / hhbc / typed_value . rs <nl> ppp b / hphp / hack / src / hhbc / typed_value . rs <nl> pub enum TypedValue { <nl> / / Classic PHP arrays with explicit ( key , value ) entries <nl> HhasAdata ( String ) , <nl> Array ( Vec < ( TypedValue , TypedValue ) > ) , <nl> - VArray ( Vec < Self > ) , <nl> + VArray ( ( Vec < Self > , ProvTag ) ) , <nl> DArray ( ( Vec < ( TypedValue , TypedValue ) > , ProvTag ) ) , <nl> / / Hack arrays : vectors , keysets , and dictionaries <nl> Vec ( ( Vec < TypedValue > , ProvTag ) ) , <nl> impl From < TypedValue > for bool { <nl> TypedValue : : Float ( f ) = > f ! = 0 . 0 , <nl> / / Empty collections cast to false if empty , otherwise true <nl> TypedValue : : Array ( v ) = > ! v . is_empty ( ) , <nl> - TypedValue : : VArray ( v ) = > ! v . is_empty ( ) , <nl> + TypedValue : : VArray ( ( v , _ ) ) = > ! v . is_empty ( ) , <nl> TypedValue : : DArray ( ( v , _ ) ) = > ! v . is_empty ( ) , <nl> TypedValue : : Vec ( ( v , _ ) ) = > ! v . is_empty ( ) , <nl> TypedValue : : Keyset ( v ) = > ! v . is_empty ( ) , <nl> | enable emitting typedef ( . alias ) | facebook/hhvm | 1b0051a0037d096956ca3150f43c84f588343fab | 2020-02-19T08:34:55Z |
mmm a / lib / Basics / fpconv . cpp <nl> ppp b / lib / Basics / fpconv . cpp <nl> static int generate_digits ( Fp * fp , Fp * upper , Fp * lower , char * digits , int * K ) <nl> for ( divp = tens + 10 ; kappa > 0 ; divp + + ) { <nl> <nl> uint64_t div = * divp ; <nl> - unsigned digit = part1 / div ; <nl> + unsigned digit = static_cast < unsigned > ( part1 / div ) ; <nl> <nl> if ( digit | | idx ) { <nl> digits [ idx + + ] = digit + ' 0 ' ; <nl> static int generate_digits ( Fp * fp , Fp * upper , Fp * lower , char * digits , int * K ) <nl> delta * = 10 ; <nl> kappa - - ; <nl> <nl> - unsigned digit = part2 > > - one . exp ; <nl> + unsigned digit = static_cast < unsigned > ( part2 > > - one . exp ) ; <nl> if ( digit | | idx ) { <nl> digits [ idx + + ] = digit + ' 0 ' ; <nl> } <nl> mmm a / lib / Basics / powers . h <nl> ppp b / lib / Basics / powers . h <nl> static Fp find_cachedpow10 ( int exp , int * k ) <nl> { <nl> const double one_log_ten = 0 . 30102999566398114 ; <nl> <nl> - int approx = - ( exp + npowers ) * one_log_ten ; <nl> + int approx = static_cast < int > ( - ( exp + npowers ) * one_log_ten ) ; <nl> int idx = ( approx - firstpower ) / steppowers ; <nl> <nl> while ( 1 ) { <nl> | fixed Visual Studio compile warnings | arangodb/arangodb | ff8cd454fa2c680bba47799248cd8431a047ffb4 | 2015-02-25T08:23:42Z |
mmm a / . gitignore <nl> ppp b / . gitignore <nl> <nl> * ~ <nl> * . swp <nl> <nl> - * . diff <nl> + # Compiled python files <nl> * . pyc <nl> - * . bc <nl> <nl> # Ignore only the root node_modules , but not any further down the path <nl> / node_modules / <nl> <nl> - # Ignore generated files <nl> + # Python coverage tool output <nl> + . coverage * <nl> + tools / coverage / <nl> + htmlcov / <nl> + coverage . xml <nl> <nl> + # Files generated by test code ( TODO : generate these elsewhere and remove ) <nl> tests / fake / <nl> + tests / fake1 / <nl> + tests / fake2 / <nl> tests / freetype / objs / * . o <nl> tests / freetype / objs / * . lo <nl> <nl> third_party / lzma . js / lzip / * . o <nl> third_party / lzma . js / lzma - native <nl> third_party / lzma . js / lzma - native . exe <nl> <nl> - tools / optimizer_build / <nl> - <nl> . DS_Store <nl> - <nl> - . coverage * <nl> - tools / coverage / <nl> - htmlcov / <nl> - coverage . xml <nl> mmm a / tests / test_other . py <nl> ppp b / tests / test_other . py <nl> def make_js_command ( filename , engine ) : <nl> engine = tools . shared . JS_ENGINES [ 0 ] <nl> return jsrun . make_command ( filename , engine ) <nl> <nl> - def _test ( ) : <nl> + def run_test ( ) : <nl> for engine in JS_ENGINES : <nl> if engine = = V8_ENGINE : <nl> continue # no stdin support in v8 shell <nl> def _test ( ) : <nl> Building . emcc ( path_from_root ( ' tests ' , ' module ' , ' test_stdin . c ' ) , output_filename = ' a . out . js ' ) <nl> create_test_file ( ' in . txt ' , ' abcdef \ nghijkl ' ) <nl> exe = ' a . out . js ' <nl> - _test ( ) <nl> + run_test ( ) <nl> Building . emcc ( path_from_root ( ' tests ' , ' module ' , ' test_stdin . c ' ) , <nl> [ ' - O2 ' , ' - - closure ' , ' 1 ' ] , <nl> output_filename = ' a . out . js ' ) <nl> - _test ( ) <nl> + run_test ( ) <nl> <nl> def test_ungetc_fscanf ( self ) : <nl> create_test_file ( ' main . cpp ' , r ' ' ' <nl> def test_module_exports_with_closure ( self ) : <nl> self . clear ( ) <nl> <nl> # compile with - O2 - - closure 0 <nl> - run_process ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' Module - exports ' , ' test . c ' ) , ' - o ' , ' test . js ' , ' - O2 ' , ' - - closure ' , ' 0 ' , ' - - pre - js ' , path_from_root ( ' tests ' , ' Module - exports ' , ' setup . js ' ) , ' - s ' , ' EXPORTED_FUNCTIONS = [ " _bufferTest " ] ' , ' - s ' , ' EXTRA_EXPORTED_RUNTIME_METHODS = [ " ccall " , " cwrap " ] ' , ' - s ' , ' WASM_ASYNC_COMPILATION = 0 ' ] , stdout = PIPE , stderr = PIPE ) <nl> + run_process ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' Module - exports ' , ' test . c ' ) , <nl> + ' - o ' , ' test . js ' , ' - O2 ' , ' - - closure ' , ' 0 ' , <nl> + ' - - pre - js ' , path_from_root ( ' tests ' , ' Module - exports ' , ' setup . js ' ) , <nl> + ' - s ' , ' EXPORTED_FUNCTIONS = [ " _bufferTest " ] ' , <nl> + ' - s ' , ' EXTRA_EXPORTED_RUNTIME_METHODS = [ " ccall " , " cwrap " ] ' , <nl> + ' - s ' , ' WASM_ASYNC_COMPILATION = 0 ' ] ) <nl> <nl> # Check that compilation was successful <nl> self . assertExists ( ' test . js ' ) <nl> def test_module_exports_with_closure ( self ) : <nl> self . assertContained ( ' bufferTest finished ' , run_js ( ' main . js ' , engine = NODE_JS ) ) <nl> <nl> # Delete test . js again and check it ' s gone . <nl> - try_delete ( path_from_root ( ' tests ' , ' Module - exports ' , ' test . js ' ) ) <nl> - assert not os . path . exists ( path_from_root ( ' tests ' , ' Module - exports ' , ' test . js ' ) ) <nl> + try_delete ( ' test . js ' ) <nl> + self . assertNotExists ( ' test . js ' ) <nl> <nl> # compile with - O2 - - closure 1 <nl> - run_process ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' Module - exports ' , ' test . c ' ) , ' - o ' , path_from_root ( ' tests ' , ' Module - exports ' , ' test . js ' ) , ' - O2 ' , ' - - closure ' , ' 1 ' , ' - - pre - js ' , path_from_root ( ' tests ' , ' Module - exports ' , ' setup . js ' ) , ' - s ' , ' EXPORTED_FUNCTIONS = [ " _bufferTest " ] ' , ' - s ' , ' WASM_ASYNC_COMPILATION = 0 ' ] , stdout = PIPE , stderr = PIPE ) <nl> + run_process ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' Module - exports ' , ' test . c ' ) , <nl> + ' - o ' , ' test . js ' , ' - O2 ' , ' - - closure ' , ' 1 ' , <nl> + ' - - pre - js ' , path_from_root ( ' tests ' , ' Module - exports ' , ' setup . js ' ) , <nl> + ' - s ' , ' EXPORTED_FUNCTIONS = [ " _bufferTest " ] ' , <nl> + ' - s ' , ' EXTRA_EXPORTED_RUNTIME_METHODS = [ " ccall " , " cwrap " ] ' , <nl> + ' - s ' , ' WASM_ASYNC_COMPILATION = 0 ' ] ) <nl> <nl> # Check that compilation was successful <nl> - self . assertExists ( path_from_root ( ' tests ' , ' Module - exports ' , ' test . js ' ) ) <nl> - test_js_closure_1 = open ( path_from_root ( ' tests ' , ' Module - exports ' , ' test . js ' ) ) . read ( ) <nl> + self . assertExists ( ' test . js ' ) <nl> + test_js_closure_1 = open ( ' test . js ' ) . read ( ) <nl> <nl> # Check that test . js compiled with - - closure 1 contains " module . exports " , we want to verify that <nl> # " module [ ' exports ' ] " got minified to " module . exports " when compiling with - - closure 1 <nl> def test_wasm_producers_section ( self ) : <nl> <nl> def test_html_preprocess ( self ) : <nl> test_file = path_from_root ( ' tests ' , ' module ' , ' test_stdin . c ' ) <nl> - output_file = path_from_root ( ' tests ' , ' module ' , ' test_stdin . html ' ) <nl> + output_file = ' test_stdin . html ' <nl> shell_file = path_from_root ( ' tests ' , ' module ' , ' test_html_preprocess . html ' ) <nl> <nl> run_process ( [ PYTHON , EMCC , ' - o ' , output_file , test_file , ' - - shell - file ' , shell_file , ' - s ' , ' ASSERTIONS = 0 ' ] , stdout = PIPE , stderr = PIPE ) <nl> | Fix remaining tests that leak files in the source tree ( ) | emscripten-core/emscripten | f30f7c190571617f6f8713a1dd07554e3f365356 | 2019-08-22T17:23:16Z |
mmm a / README . md <nl> ppp b / README . md <nl> pip3 install deepspeech - gpu <nl> deepspeech - - model models / output_graph . pbmm - - alphabet models / alphabet . txt - - lm models / lm . binary - - trie models / trie - - audio my_audio_file . wav <nl> ` ` ` <nl> <nl> + Please ensure you have the required [ CUDA dependency ] ( # cuda - dependency ) . <nl> + <nl> See the output of ` deepspeech - h ` for more information on the use of ` deepspeech ` . ( If you experience problems running ` deepspeech ` , please check [ required runtime dependencies ] ( native_client / README . md # required - dependencies ) ) . <nl> <nl> * * Table of Contents * * <nl> See the output of ` deepspeech - h ` for more information on the use of ` deepspeech <nl> - [ Prerequisites ] ( # prerequisites ) <nl> - [ Getting the code ] ( # getting - the - code ) <nl> - [ Getting the pre - trained model ] ( # getting - the - pre - trained - model ) <nl> + - [ CUDA dependency ] ( # cuda - dependency ) <nl> - [ Using the model ] ( # using - the - model ) <nl> - [ Using the Python package ] ( # using - the - python - package ) <nl> - [ Using the command line client ] ( # using - the - command - line - client ) <nl> There are three ways to use DeepSpeech inference : <nl> - [ The Node . JS package ] ( # using - the - nodejs - package ) <nl> <nl> <nl> + # # # CUDA dependency <nl> + <nl> + The GPU capable builds ( Python , NodeJS , C + + etc ) depend on the same CUDA runtime as upstream TensorFlow . Currently with TensorFlow r1 . 12 it depends on CUDA 9 . 0 and CuDNN v7 . 2 . <nl> + <nl> # # # Using the Python package <nl> <nl> Pre - built binaries that can be used for performing inference with a trained model can be installed with ` pip3 ` . You can then use the ` deepspeech ` binary to do speech - to - text on an audio file : <nl> $ pip3 install - - upgrade deepspeech - gpu <nl> <nl> In both cases , it should take care of installing all the required dependencies . Once it is done , you should be able to call the sample binary using ` deepspeech ` on your command - line . <nl> <nl> + Please ensure you have the required [ CUDA dependency ] ( # cuda - dependency ) . <nl> + <nl> Note : the following command assumes you [ downloaded the pre - trained model ] ( # getting - the - pre - trained - model ) . <nl> <nl> ` ` ` bash <nl> npm install deepspeech - gpu <nl> <nl> See [ client . js ] ( native_client / javascript / client . js ) for an example of how to use the bindings . <nl> <nl> + Please ensure you have the required [ CUDA dependency ] ( # cuda - dependency ) . <nl> + <nl> # # # Installing bindings from source <nl> <nl> If pre - built binaries aren ' t available for your system , you ' ll need to install them from scratch . Follow [ these instructions ] ( native_client / README . md ) . <nl> pip3 uninstall tensorflow <nl> pip3 install ' tensorflow - gpu = = 1 . 12 . 0 ' <nl> ` ` ` <nl> <nl> + Please ensure you have the required [ CUDA dependency ] ( # cuda - dependency ) . <nl> + <nl> # # # Common Voice training data <nl> <nl> The Common Voice corpus consists of voice samples that were donated through [ Common Voice ] ( https : / / voice . mozilla . org / ) . <nl> | Improve first user experience for CUDA deps | mozilla/DeepSpeech | 924c144927cd0c6a14c7c63edf364dad4e05fe16 | 2018-12-19T12:32:40Z |
mmm a / util / version . cpp <nl> ppp b / util / version . cpp <nl> namespace mongo { <nl> / / <nl> <nl> void show_32_warning ( ) { <nl> - # if BOOST_VERSION < 103500 <nl> - cout < < " \ nwarning : built with boost version < = 1 . 34 , limited concurrency " < < endl ; <nl> - # endif <nl> - <nl> { <nl> const char * foo = strchr ( versionString , ' . ' ) + 1 ; <nl> int bar = atoi ( foo ) ; <nl> | remove old boost warning since we use pthread for old boost versions now | mongodb/mongo | 32dcad0fea3847028dd0e9430d1a697894c98795 | 2010-06-03T14:15:44Z |
mmm a / html5 / render / vue / modules / dom . js <nl> ppp b / html5 / render / vue / modules / dom . js <nl> export default { <nl> * / <nl> scrollToElement : function ( vnode , options ) { <nl> const scroller = getParentScroller ( vnode ) <nl> + const scrollDirection = scroller . scrollDirection | | ' vertical ' <nl> <nl> if ( scroller & & scroller . $ el & & vnode . $ el ) { <nl> / / get the ' weex - scroller - inner ' div . <nl> export default { <nl> const dSuffix = ( { <nl> horizontal : ' Left ' , <nl> vertical : ' Top ' <nl> - } ) [ scroller . scrollDirection | | ' vertical ' ] <nl> + } ) [ scrollDirection ] <nl> let offset = vnode . $ el [ ` offset $ { dSuffix } ` ] <nl> <nl> + const scrollCt = scrollDirection = = = ' horizontal ' ? innerScroller : scroller . $ el <nl> + <nl> if ( options ) { <nl> offset + = Number ( options . offset ) | | 0 <nl> } <nl> export default { <nl> } <nl> <nl> / / TODO : add animation <nl> - innerScroller [ ` scroll $ { dSuffix } ` ] = offset <nl> + scrollCt [ ` scroll $ { dSuffix } ` ] = offset <nl> } <nl> } , <nl> <nl> | * [ html5 ] scroll container is not the same for horizontal and vertical scrollers . | apache/incubator-weex | f714db9c7cad519d370163364fa4c2eb5f0262af | 2017-02-21T03:58:29Z |
mmm a / include / spdlog / common . h <nl> ppp b / include / spdlog / common . h <nl> <nl> # define SPDLOG_CONSTEXPR constexpr <nl> # endif <nl> <nl> - / / See tweakme . h <nl> - # if ! defined ( SPDLOG_FINAL ) <nl> + / / final keyword support . On by default . See tweakme . h <nl> + # if defined ( SPDLOG_NO_FINAL ) <nl> # define SPDLOG_FINAL <nl> + # else <nl> + # define SPDLOG_FINAL final <nl> # endif <nl> <nl> # if defined ( __GNUC__ ) | | defined ( __clang__ ) <nl> mmm a / include / spdlog / tweakme . h <nl> ppp b / include / spdlog / tweakme . h <nl> <nl> <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / Uncomment to mark some types as final , allowing more optimizations in release <nl> + / / Uncomment if your compiler doesn ' t support the " final " keyword . <nl> + / / The final keyword allows more optimizations in release <nl> / / mode with recent compilers . See GCC ' s documentation for - Wsuggest - final - types <nl> / / for instance . <nl> / / <nl> - / / # define SPDLOG_FINAL final <nl> + / / # define SPDLOG_NO_FINAL <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> <nl> <nl> / / # define SPDLOG_ENABLE_MESSAGE_COUNTER <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> + <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / Uncomment to customize level names ( e . g . " MT TRACE " ) <nl> / / <nl> | enable final keyword by default . Can be disabled in tweakme . h for older compilers | gabime/spdlog | adbc22096a6587ece7fd539122b184583f2aa5e2 | 2017-11-25T13:53:35Z |
mmm a / tensorflow / go / op / wrappers . go <nl> ppp b / tensorflow / go / op / wrappers . go <nl> func EncodePng ( scope * Scope , image tf . Output , optional . . . EncodePngAttr ) ( conten <nl> return op . Output ( 0 ) <nl> } <nl> <nl> + / / Invert ( flip ) each bit of supported types ; for example , type ` uint8 ` value 01010101 becomes 10101010 . <nl> + / / <nl> + / / Flip each bit of supported types . For example , type ` int8 ` ( decimal 2 ) binary 00000010 becomes ( decimal - 3 ) binary 11111101 . <nl> + / / This operation is performed on each element of the tensor argument ` x ` . <nl> + / / <nl> + / / Example : <nl> + / / ` ` ` python <nl> + / / import tensorflow as tf <nl> + / / from tensorflow . python . ops import bitwise_ops <nl> + / / <nl> + / / # flip 2 ( 00000010 ) to - 3 ( 11111101 ) <nl> + / / tf . assert_equal ( - 3 , bitwise_ops . invert ( 2 ) ) <nl> + / / <nl> + / / dtype_list = [ dtypes . int8 , dtypes . int16 , dtypes . int32 , dtypes . int64 , <nl> + / / dtypes . uint8 , dtypes . uint16 , dtypes . uint32 , dtypes . uint64 ] <nl> + / / <nl> + / / inputs = [ 0 , 5 , 3 , 14 ] <nl> + / / for dtype in dtype_list : <nl> + / / # Because of issues with negative numbers , let ' s test this indirectly . <nl> + / / # 1 . invert ( a ) and a = 0 <nl> + / / # 2 . invert ( a ) or a = invert ( 0 ) <nl> + / / input_tensor = tf . constant ( [ 0 , 5 , 3 , 14 ] , dtype = dtype ) <nl> + / / not_a_and_a , not_a_or_a , not_0 = [ bitwise_ops . bitwise_and ( <nl> + / / input_tensor , bitwise_ops . invert ( input_tensor ) ) , <nl> + / / bitwise_ops . bitwise_or ( <nl> + / / input_tensor , bitwise_ops . invert ( input_tensor ) ) , <nl> + / / bitwise_ops . invert ( <nl> + / / tf . constant ( 0 , dtype = dtype ) ) ] <nl> + / / <nl> + / / expected = tf . constant ( [ 0 , 0 , 0 , 0 ] , dtype = tf . float32 ) <nl> + / / tf . assert_equal ( tf . cast ( not_a_and_a , tf . float32 ) , expected ) <nl> + / / <nl> + / / expected = tf . cast ( [ not_0 ] * 4 , tf . float32 ) <nl> + / / tf . assert_equal ( tf . cast ( not_a_or_a , tf . float32 ) , expected ) <nl> + / / <nl> + / / # For unsigned dtypes let ' s also check the result directly . <nl> + / / if dtype . is_unsigned : <nl> + / / inverted = bitwise_ops . invert ( input_tensor ) <nl> + / / expected = tf . constant ( [ dtype . max - x for x in inputs ] , dtype = tf . float32 ) <nl> + / / tf . assert_equal ( tf . cast ( inverted , tf . float32 ) , tf . cast ( expected , tf . float32 ) ) <nl> + / / ` ` ` <nl> + func Invert ( scope * Scope , x tf . Output ) ( y tf . Output ) { <nl> + if scope . Err ( ) ! = nil { <nl> + return <nl> + } <nl> + opspec : = tf . OpSpec { <nl> + Type : " Invert " , <nl> + Input : [ ] tf . Input { <nl> + x , <nl> + } , <nl> + } <nl> + op : = scope . AddOperation ( opspec ) <nl> + return op . Output ( 0 ) <nl> + } <nl> + <nl> + / / DecodePngAttr is an optional argument to DecodePng . <nl> + type DecodePngAttr func ( optionalAttr ) <nl> + <nl> + / / DecodePngChannels sets the optional channels attribute to value . <nl> + / / <nl> + / / value : Number of color channels for the decoded image . <nl> + / / If not specified , defaults to 0 <nl> + func DecodePngChannels ( value int64 ) DecodePngAttr { <nl> + return func ( m optionalAttr ) { <nl> + m [ " channels " ] = value <nl> + } <nl> + } <nl> + <nl> + / / DecodePngDtype sets the optional dtype attribute to value . <nl> + / / If not specified , defaults to DT_UINT8 <nl> + func DecodePngDtype ( value tf . DataType ) DecodePngAttr { <nl> + return func ( m optionalAttr ) { <nl> + m [ " dtype " ] = value <nl> + } <nl> + } <nl> + <nl> + / / Decode a PNG - encoded image to a uint8 or uint16 tensor . <nl> + / / <nl> + / / The attr ` channels ` indicates the desired number of color channels for the <nl> + / / decoded image . <nl> + / / <nl> + / / Accepted values are : <nl> + / / <nl> + / / * 0 : Use the number of channels in the PNG - encoded image . <nl> + / / * 1 : output a grayscale image . <nl> + / / * 3 : output an RGB image . <nl> + / / * 4 : output an RGBA image . <nl> + / / <nl> + / / If needed , the PNG - encoded image is transformed to match the requested number <nl> + / / of color channels . <nl> + / / <nl> + / / This op also supports decoding JPEGs and non - animated GIFs since the interface <nl> + / / is the same , though it is cleaner to use ` tf . io . decode_image ` . <nl> + / / <nl> + / / Arguments : <nl> + / / contents : 0 - D . The PNG - encoded image . <nl> + / / <nl> + / / Returns 3 - D with shape ` [ height , width , channels ] ` . <nl> + func DecodePng ( scope * Scope , contents tf . Output , optional . . . DecodePngAttr ) ( image tf . Output ) { <nl> + if scope . Err ( ) ! = nil { <nl> + return <nl> + } <nl> + attrs : = map [ string ] interface { } { } <nl> + for _ , a : = range optional { <nl> + a ( attrs ) <nl> + } <nl> + opspec : = tf . OpSpec { <nl> + Type : " DecodePng " , <nl> + Input : [ ] tf . Input { <nl> + contents , <nl> + } , <nl> + Attrs : attrs , <nl> + } <nl> + op : = scope . AddOperation ( opspec ) <nl> + return op . Output ( 0 ) <nl> + } <nl> + <nl> + / / Adjust the saturation of one or more images . <nl> + / / <nl> + / / ` images ` is a tensor of at least 3 dimensions . The last dimension is <nl> + / / interpreted as channels , and must be three . <nl> + / / <nl> + / / The input image is considered in the RGB colorspace . Conceptually , the RGB <nl> + / / colors are first mapped into HSV . A scale is then applied all the saturation <nl> + / / values , and then remapped back to RGB colorspace . <nl> + / / <nl> + / / Arguments : <nl> + / / images : Images to adjust . At least 3 - D . <nl> + / / scale : A float scale to add to the saturation . <nl> + / / <nl> + / / Returns The hue - adjusted image or images . <nl> + func AdjustSaturation ( scope * Scope , images tf . Output , scale tf . Output ) ( output tf . Output ) { <nl> + if scope . Err ( ) ! = nil { <nl> + return <nl> + } <nl> + opspec : = tf . OpSpec { <nl> + Type : " AdjustSaturation " , <nl> + Input : [ ] tf . Input { <nl> + images , scale , <nl> + } , <nl> + } <nl> + op : = scope . AddOperation ( opspec ) <nl> + return op . Output ( 0 ) <nl> + } <nl> + <nl> / / ExtractJpegShapeAttr is an optional argument to ExtractJpegShape . <nl> type ExtractJpegShapeAttr func ( optionalAttr ) <nl> <nl> func TensorSummaryV2 ( scope * Scope , tag tf . Output , tensor tf . Output , serialized_s <nl> return op . Output ( 0 ) <nl> } <nl> <nl> - / / Invert ( flip ) each bit of supported types ; for example , type ` uint8 ` value 01010101 becomes 10101010 . <nl> - / / <nl> - / / Flip each bit of supported types . For example , type ` int8 ` ( decimal 2 ) binary 00000010 becomes ( decimal - 3 ) binary 11111101 . <nl> - / / This operation is performed on each element of the tensor argument ` x ` . <nl> - / / <nl> - / / Example : <nl> - / / ` ` ` python <nl> - / / import tensorflow as tf <nl> - / / from tensorflow . python . ops import bitwise_ops <nl> - / / <nl> - / / # flip 2 ( 00000010 ) to - 3 ( 11111101 ) <nl> - / / tf . assert_equal ( - 3 , bitwise_ops . invert ( 2 ) ) <nl> - / / <nl> - / / dtype_list = [ dtypes . int8 , dtypes . int16 , dtypes . int32 , dtypes . int64 , <nl> - / / dtypes . uint8 , dtypes . uint16 , dtypes . uint32 , dtypes . uint64 ] <nl> - / / <nl> - / / inputs = [ 0 , 5 , 3 , 14 ] <nl> - / / for dtype in dtype_list : <nl> - / / # Because of issues with negative numbers , let ' s test this indirectly . <nl> - / / # 1 . invert ( a ) and a = 0 <nl> - / / # 2 . invert ( a ) or a = invert ( 0 ) <nl> - / / input_tensor = tf . constant ( [ 0 , 5 , 3 , 14 ] , dtype = dtype ) <nl> - / / not_a_and_a , not_a_or_a , not_0 = [ bitwise_ops . bitwise_and ( <nl> - / / input_tensor , bitwise_ops . invert ( input_tensor ) ) , <nl> - / / bitwise_ops . bitwise_or ( <nl> - / / input_tensor , bitwise_ops . invert ( input_tensor ) ) , <nl> - / / bitwise_ops . invert ( <nl> - / / tf . constant ( 0 , dtype = dtype ) ) ] <nl> - / / <nl> - / / expected = tf . constant ( [ 0 , 0 , 0 , 0 ] , dtype = tf . float32 ) <nl> - / / tf . assert_equal ( tf . cast ( not_a_and_a , tf . float32 ) , expected ) <nl> - / / <nl> - / / expected = tf . cast ( [ not_0 ] * 4 , tf . float32 ) <nl> - / / tf . assert_equal ( tf . cast ( not_a_or_a , tf . float32 ) , expected ) <nl> - / / <nl> - / / # For unsigned dtypes let ' s also check the result directly . <nl> - / / if dtype . is_unsigned : <nl> - / / inverted = bitwise_ops . invert ( input_tensor ) <nl> - / / expected = tf . constant ( [ dtype . max - x for x in inputs ] , dtype = tf . float32 ) <nl> - / / tf . assert_equal ( tf . cast ( inverted , tf . float32 ) , tf . cast ( expected , tf . float32 ) ) <nl> - / / ` ` ` <nl> - func Invert ( scope * Scope , x tf . Output ) ( y tf . Output ) { <nl> - if scope . Err ( ) ! = nil { <nl> - return <nl> - } <nl> - opspec : = tf . OpSpec { <nl> - Type : " Invert " , <nl> - Input : [ ] tf . Input { <nl> - x , <nl> - } , <nl> - } <nl> - op : = scope . AddOperation ( opspec ) <nl> - return op . Output ( 0 ) <nl> - } <nl> - <nl> - / / DecodePngAttr is an optional argument to DecodePng . <nl> - type DecodePngAttr func ( optionalAttr ) <nl> - <nl> - / / DecodePngChannels sets the optional channels attribute to value . <nl> - / / <nl> - / / value : Number of color channels for the decoded image . <nl> - / / If not specified , defaults to 0 <nl> - func DecodePngChannels ( value int64 ) DecodePngAttr { <nl> - return func ( m optionalAttr ) { <nl> - m [ " channels " ] = value <nl> - } <nl> - } <nl> - <nl> - / / DecodePngDtype sets the optional dtype attribute to value . <nl> - / / If not specified , defaults to DT_UINT8 <nl> - func DecodePngDtype ( value tf . DataType ) DecodePngAttr { <nl> - return func ( m optionalAttr ) { <nl> - m [ " dtype " ] = value <nl> - } <nl> - } <nl> - <nl> - / / Decode a PNG - encoded image to a uint8 or uint16 tensor . <nl> - / / <nl> - / / The attr ` channels ` indicates the desired number of color channels for the <nl> - / / decoded image . <nl> - / / <nl> - / / Accepted values are : <nl> - / / <nl> - / / * 0 : Use the number of channels in the PNG - encoded image . <nl> - / / * 1 : output a grayscale image . <nl> - / / * 3 : output an RGB image . <nl> - / / * 4 : output an RGBA image . <nl> - / / <nl> - / / If needed , the PNG - encoded image is transformed to match the requested number <nl> - / / of color channels . <nl> - / / <nl> - / / This op also supports decoding JPEGs and non - animated GIFs since the interface <nl> - / / is the same , though it is cleaner to use ` tf . io . decode_image ` . <nl> - / / <nl> - / / Arguments : <nl> - / / contents : 0 - D . The PNG - encoded image . <nl> - / / <nl> - / / Returns 3 - D with shape ` [ height , width , channels ] ` . <nl> - func DecodePng ( scope * Scope , contents tf . Output , optional . . . DecodePngAttr ) ( image tf . Output ) { <nl> - if scope . Err ( ) ! = nil { <nl> - return <nl> - } <nl> - attrs : = map [ string ] interface { } { } <nl> - for _ , a : = range optional { <nl> - a ( attrs ) <nl> - } <nl> - opspec : = tf . OpSpec { <nl> - Type : " DecodePng " , <nl> - Input : [ ] tf . Input { <nl> - contents , <nl> - } , <nl> - Attrs : attrs , <nl> - } <nl> - op : = scope . AddOperation ( opspec ) <nl> - return op . Output ( 0 ) <nl> - } <nl> - <nl> / / Computes the gradient for the sqrt of ` x ` wrt its input . <nl> / / <nl> / / Specifically , ` grad = dy * 0 . 5 / y ` , where ` y = sqrt ( x ) ` , and ` dy ` <nl> func TensorListPopBack ( scope * Scope , input_handle tf . Output , element_shape tf . Ou <nl> return op . Output ( 0 ) , op . Output ( 1 ) <nl> } <nl> <nl> - / / Adjust the saturation of one or more images . <nl> - / / <nl> - / / ` images ` is a tensor of at least 3 dimensions . The last dimension is <nl> - / / interpreted as channels , and must be three . <nl> - / / <nl> - / / The input image is considered in the RGB colorspace . Conceptually , the RGB <nl> - / / colors are first mapped into HSV . A scale is then applied all the saturation <nl> - / / values , and then remapped back to RGB colorspace . <nl> - / / <nl> - / / Arguments : <nl> - / / images : Images to adjust . At least 3 - D . <nl> - / / scale : A float scale to add to the saturation . <nl> - / / <nl> - / / Returns The hue - adjusted image or images . <nl> - func AdjustSaturation ( scope * Scope , images tf . Output , scale tf . Output ) ( output tf . Output ) { <nl> - if scope . Err ( ) ! = nil { <nl> - return <nl> - } <nl> - opspec : = tf . OpSpec { <nl> - Type : " AdjustSaturation " , <nl> - Input : [ ] tf . Input { <nl> - images , scale , <nl> - } , <nl> - } <nl> - op : = scope . AddOperation ( opspec ) <nl> - return op . Output ( 0 ) <nl> - } <nl> - <nl> / / QueueDequeueManyV2Attr is an optional argument to QueueDequeueManyV2 . <nl> type QueueDequeueManyV2Attr func ( optionalAttr ) <nl> <nl> func Conv2DBackpropFilter ( scope * Scope , input tf . Output , filter_sizes tf . Output , <nl> return op . Output ( 0 ) <nl> } <nl> <nl> - / / ConfigureDistributedTPUAttr is an optional argument to ConfigureDistributedTPU . <nl> - type ConfigureDistributedTPUAttr func ( optionalAttr ) <nl> - <nl> - / / ConfigureDistributedTPUEmbeddingConfig sets the optional embedding_config attribute to value . <nl> + / / Returns the truth value of x OR y element - wise . <nl> / / <nl> - / / value : Reserved . Do not use . <nl> - / / If not specified , defaults to " " <nl> - func ConfigureDistributedTPUEmbeddingConfig ( value string ) ConfigureDistributedTPUAttr { <nl> - return func ( m optionalAttr ) { <nl> - m [ " embedding_config " ] = value <nl> + / / * NOTE * : ` LogicalOr ` supports broadcasting . More about broadcasting <nl> + / / [ here ] ( http : / / docs . scipy . org / doc / numpy / user / basics . broadcasting . html ) <nl> + func LogicalOr ( scope * Scope , x tf . Output , y tf . Output ) ( z tf . Output ) { <nl> + if scope . Err ( ) ! = nil { <nl> + return <nl> } <nl> - } <nl> - <nl> - / / ConfigureDistributedTPUTpuEmbeddingConfig sets the optional tpu_embedding_config attribute to value . <nl> - / / <nl> - / / value : Serialized tensorflow . tpu . TPUEmbeddingConfiguration that <nl> - / / describes the embedding lookups of the program . <nl> - / / If not specified , defaults to " " <nl> - func ConfigureDistributedTPUTpuEmbeddingConfig ( value string ) ConfigureDistributedTPUAttr { <nl> - return func ( m optionalAttr ) { <nl> - m [ " tpu_embedding_config " ] = value <nl> + opspec : = tf . OpSpec { <nl> + Type : " LogicalOr " , <nl> + Input : [ ] tf . Input { <nl> + x , y , <nl> + } , <nl> } <nl> + op : = scope . AddOperation ( opspec ) <nl> + return op . Output ( 0 ) <nl> } <nl> <nl> - / / ConfigureDistributedTPUIsGlobalInit sets the optional is_global_init attribute to value . <nl> + / / Adds ` bias ` to ` value ` . <nl> / / <nl> - / / value : Reserved . Do not use . <nl> - / / If not specified , defaults to false <nl> - func ConfigureDistributedTPUIsGlobalInit ( value bool ) ConfigureDistributedTPUAttr { <nl> - return func ( m optionalAttr ) { <nl> - m [ " is_global_init " ] = value <nl> - } <nl> - } <nl> - <nl> - / / ConfigureDistributedTPUEnableWholeMeshCompilations sets the optional enable_whole_mesh_compilations attribute to value . <nl> - / / If not specified , defaults to false <nl> - func ConfigureDistributedTPUEnableWholeMeshCompilations ( value bool ) ConfigureDistributedTPUAttr { <nl> - return func ( m optionalAttr ) { <nl> - m [ " enable_whole_mesh_compilations " ] = value <nl> - } <nl> - } <nl> - <nl> - / / ConfigureDistributedTPUCompilationFailureClosesChips sets the optional compilation_failure_closes_chips attribute to value . <nl> - / / If not specified , defaults to true <nl> - func ConfigureDistributedTPUCompilationFailureClosesChips ( value bool ) ConfigureDistributedTPUAttr { <nl> - return func ( m optionalAttr ) { <nl> - m [ " compilation_failure_closes_chips " ] = value <nl> - } <nl> - } <nl> - <nl> - / / Sets up the centralized structures for a distributed TPU system . <nl> + / / This is a deprecated version of BiasAdd and will be soon removed . <nl> / / <nl> - / / Returns A serialized tensorflow . tpu . TopologyProto that describes the TPU <nl> - / / topology . <nl> - func ConfigureDistributedTPU ( scope * Scope , optional . . . ConfigureDistributedTPUAttr ) ( topology tf . Output ) { <nl> + / / This is a special case of ` tf . add ` where ` bias ` is restricted to be 1 - D . <nl> + / / Broadcasting is supported , so ` value ` may have any number of dimensions . <nl> + / / <nl> + / / Arguments : <nl> + / / value : Any number of dimensions . <nl> + / / bias : 1 - D with size the last dimension of ` value ` . <nl> + / / <nl> + / / Returns Broadcasted sum of ` value ` and ` bias ` . <nl> + func BiasAddV1 ( scope * Scope , value tf . Output , bias tf . Output ) ( output tf . Output ) { <nl> if scope . Err ( ) ! = nil { <nl> return <nl> } <nl> - attrs : = map [ string ] interface { } { } <nl> - for _ , a : = range optional { <nl> - a ( attrs ) <nl> - } <nl> opspec : = tf . OpSpec { <nl> - Type : " ConfigureDistributedTPU " , <nl> - <nl> - Attrs : attrs , <nl> + Type : " BiasAddV1 " , <nl> + Input : [ ] tf . Input { <nl> + value , bias , <nl> + } , <nl> } <nl> op : = scope . AddOperation ( opspec ) <nl> return op . Output ( 0 ) <nl> func RandomPoissonV2 ( scope * Scope , shape tf . Output , rate tf . Output , optional . . . <nl> return op . Output ( 0 ) <nl> } <nl> <nl> - / / Computes the derivative of a Gamma random sample w . r . t . ` alpha ` . <nl> - func RandomGammaGrad ( scope * Scope , alpha tf . Output , sample tf . Output ) ( output tf . Output ) { <nl> - if scope . Err ( ) ! = nil { <nl> - return <nl> - } <nl> - opspec : = tf . OpSpec { <nl> - Type : " RandomGammaGrad " , <nl> - Input : [ ] tf . Input { <nl> - alpha , sample , <nl> - } , <nl> - } <nl> - op : = scope . AddOperation ( opspec ) <nl> - return op . Output ( 0 ) <nl> - } <nl> - <nl> / / Creates a dataset that takes a Bernoulli sample of the contents of another dataset . <nl> / / <nl> / / There is no transformation in the ` tf . data ` Python API for creating this dataset . <nl> func SparseSliceGrad ( scope * Scope , backprop_val_grad tf . Output , input_indices tf <nl> return op . Output ( 0 ) <nl> } <nl> <nl> - / / Returns the truth value of x OR y element - wise . <nl> - / / <nl> - / / * NOTE * : ` LogicalOr ` supports broadcasting . More about broadcasting <nl> - / / [ here ] ( http : / / docs . scipy . org / doc / numpy / user / basics . broadcasting . html ) <nl> - func LogicalOr ( scope * Scope , x tf . Output , y tf . Output ) ( z tf . Output ) { <nl> - if scope . Err ( ) ! = nil { <nl> - return <nl> - } <nl> - opspec : = tf . OpSpec { <nl> - Type : " LogicalOr " , <nl> - Input : [ ] tf . Input { <nl> - x , y , <nl> - } , <nl> - } <nl> - op : = scope . AddOperation ( opspec ) <nl> - return op . Output ( 0 ) <nl> - } <nl> - <nl> - / / Adds ` bias ` to ` value ` . <nl> - / / <nl> - / / This is a deprecated version of BiasAdd and will be soon removed . <nl> - / / <nl> - / / This is a special case of ` tf . add ` where ` bias ` is restricted to be 1 - D . <nl> - / / Broadcasting is supported , so ` value ` may have any number of dimensions . <nl> - / / <nl> - / / Arguments : <nl> - / / value : Any number of dimensions . <nl> - / / bias : 1 - D with size the last dimension of ` value ` . <nl> - / / <nl> - / / Returns Broadcasted sum of ` value ` and ` bias ` . <nl> - func BiasAddV1 ( scope * Scope , value tf . Output , bias tf . Output ) ( output tf . Output ) { <nl> - if scope . Err ( ) ! = nil { <nl> - return <nl> - } <nl> - opspec : = tf . OpSpec { <nl> - Type : " BiasAddV1 " , <nl> - Input : [ ] tf . Input { <nl> - value , bias , <nl> - } , <nl> - } <nl> - op : = scope . AddOperation ( opspec ) <nl> - return op . Output ( 0 ) <nl> - } <nl> - <nl> / / Generates sparse cross from a list of sparse and dense tensors . <nl> / / <nl> / / The op takes two lists , one of 2D ` SparseTensor ` and one of 2D ` Tensor ` , each <nl> func RecvTPUEmbeddingActivations ( scope * Scope , num_outputs int64 , config string ) <nl> return outputs <nl> } <nl> <nl> + / / Computes the derivative of a Gamma random sample w . r . t . ` alpha ` . <nl> + func RandomGammaGrad ( scope * Scope , alpha tf . Output , sample tf . Output ) ( output tf . Output ) { <nl> + if scope . Err ( ) ! = nil { <nl> + return <nl> + } <nl> + opspec : = tf . OpSpec { <nl> + Type : " RandomGammaGrad " , <nl> + Input : [ ] tf . Input { <nl> + alpha , sample , <nl> + } , <nl> + } <nl> + op : = scope . AddOperation ( opspec ) <nl> + return op . Output ( 0 ) <nl> + } <nl> + <nl> + / / LRNGradAttr is an optional argument to LRNGrad . <nl> + type LRNGradAttr func ( optionalAttr ) <nl> + <nl> + / / LRNGradDepthRadius sets the optional depth_radius attribute to value . <nl> + / / <nl> + / / value : A depth radius . <nl> + / / If not specified , defaults to 5 <nl> + func LRNGradDepthRadius ( value int64 ) LRNGradAttr { <nl> + return func ( m optionalAttr ) { <nl> + m [ " depth_radius " ] = value <nl> + } <nl> + } <nl> + <nl> + / / LRNGradBias sets the optional bias attribute to value . <nl> + / / <nl> + / / value : An offset ( usually > 0 to avoid dividing by 0 ) . <nl> + / / If not specified , defaults to 1 <nl> + func LRNGradBias ( value float32 ) LRNGradAttr { <nl> + return func ( m optionalAttr ) { <nl> + m [ " bias " ] = value <nl> + } <nl> + } <nl> + <nl> + / / LRNGradAlpha sets the optional alpha attribute to value . <nl> + / / <nl> + / / value : A scale factor , usually positive . <nl> + / / If not specified , defaults to 1 <nl> + func LRNGradAlpha ( value float32 ) LRNGradAttr { <nl> + return func ( m optionalAttr ) { <nl> + m [ " alpha " ] = value <nl> + } <nl> + } <nl> + <nl> + / / LRNGradBeta sets the optional beta attribute to value . <nl> + / / <nl> + / / value : An exponent . <nl> + / / If not specified , defaults to 0 . 5 <nl> + func LRNGradBeta ( value float32 ) LRNGradAttr { <nl> + return func ( m optionalAttr ) { <nl> + m [ " beta " ] = value <nl> + } <nl> + } <nl> + <nl> + / / Gradients for Local Response Normalization . <nl> + / / <nl> + / / Arguments : <nl> + / / input_grads : 4 - D with shape ` [ batch , height , width , channels ] ` . <nl> + / / input_image : 4 - D with shape ` [ batch , height , width , channels ] ` . <nl> + / / output_image : 4 - D with shape ` [ batch , height , width , channels ] ` . <nl> + / / <nl> + / / Returns The gradients for LRN . <nl> + func LRNGrad ( scope * Scope , input_grads tf . Output , input_image tf . Output , output_image tf . Output , optional . . . LRNGradAttr ) ( output tf . Output ) { <nl> + if scope . Err ( ) ! = nil { <nl> + return <nl> + } <nl> + attrs : = map [ string ] interface { } { } <nl> + for _ , a : = range optional { <nl> + a ( attrs ) <nl> + } <nl> + opspec : = tf . OpSpec { <nl> + Type : " LRNGrad " , <nl> + Input : [ ] tf . Input { <nl> + input_grads , input_image , output_image , <nl> + } , <nl> + Attrs : attrs , <nl> + } <nl> + op : = scope . AddOperation ( opspec ) <nl> + return op . Output ( 0 ) <nl> + } <nl> + <nl> + / / PrelinearizeAttr is an optional argument to Prelinearize . <nl> + type PrelinearizeAttr func ( optionalAttr ) <nl> + <nl> + / / PrelinearizeShape sets the optional shape attribute to value . <nl> + / / <nl> + / / value : The shape of the tensor . <nl> + / / If not specified , defaults to < > <nl> + func PrelinearizeShape ( value tf . Shape ) PrelinearizeAttr { <nl> + return func ( m optionalAttr ) { <nl> + m [ " shape " ] = value <nl> + } <nl> + } <nl> + <nl> + / / PrelinearizeLayout sets the optional layout attribute to value . <nl> + / / <nl> + / / value : A vector holding the requested layout in minor - to - major sequence . If a layout <nl> + / / attribute is passed but its values are all - 1 the layout will be computed by <nl> + / / the infeed operation . <nl> + / / If not specified , defaults to < > <nl> + func PrelinearizeLayout ( value [ ] int64 ) PrelinearizeAttr { <nl> + return func ( m optionalAttr ) { <nl> + m [ " layout " ] = value <nl> + } <nl> + } <nl> + <nl> + / / An op which linearizes one Tensor value to an opaque variant tensor . <nl> + / / <nl> + / / Arguments : <nl> + / / input : A tensor that will be linearized . <nl> + func Prelinearize ( scope * Scope , input tf . Output , optional . . . PrelinearizeAttr ) ( output tf . Output ) { <nl> + if scope . Err ( ) ! = nil { <nl> + return <nl> + } <nl> + attrs : = map [ string ] interface { } { } <nl> + for _ , a : = range optional { <nl> + a ( attrs ) <nl> + } <nl> + opspec : = tf . OpSpec { <nl> + Type : " Prelinearize " , <nl> + Input : [ ] tf . Input { <nl> + input , <nl> + } , <nl> + Attrs : attrs , <nl> + } <nl> + op : = scope . AddOperation ( opspec ) <nl> + return op . Output ( 0 ) <nl> + } <nl> + <nl> / / Computes the sparse Cholesky decomposition of ` input ` . <nl> / / <nl> / / Computes the Sparse Cholesky decomposition of a sparse matrix , with the given <nl> func RetrieveTPUEmbeddingMomentumParameters ( scope * Scope , num_shards int64 , shar <nl> return op . Output ( 0 ) , op . Output ( 1 ) <nl> } <nl> <nl> + / / ConfigureDistributedTPUAttr is an optional argument to ConfigureDistributedTPU . <nl> + type ConfigureDistributedTPUAttr func ( optionalAttr ) <nl> + <nl> + / / ConfigureDistributedTPUEmbeddingConfig sets the optional embedding_config attribute to value . <nl> + / / <nl> + / / value : Reserved . Do not use . <nl> + / / If not specified , defaults to " " <nl> + func ConfigureDistributedTPUEmbeddingConfig ( value string ) ConfigureDistributedTPUAttr { <nl> + return func ( m optionalAttr ) { <nl> + m [ " embedding_config " ] = value <nl> + } <nl> + } <nl> + <nl> + / / ConfigureDistributedTPUTpuEmbeddingConfig sets the optional tpu_embedding_config attribute to value . <nl> + / / <nl> + / / value : Serialized tensorflow . tpu . TPUEmbeddingConfiguration that <nl> + / / describes the embedding lookups of the program . <nl> + / / If not specified , defaults to " " <nl> + func ConfigureDistributedTPUTpuEmbeddingConfig ( value string ) ConfigureDistributedTPUAttr { <nl> + return func ( m optionalAttr ) { <nl> + m [ " tpu_embedding_config " ] = value <nl> + } <nl> + } <nl> + <nl> + / / ConfigureDistributedTPUIsGlobalInit sets the optional is_global_init attribute to value . <nl> + / / <nl> + / / value : Reserved . Do not use . <nl> + / / If not specified , defaults to false <nl> + func ConfigureDistributedTPUIsGlobalInit ( value bool ) ConfigureDistributedTPUAttr { <nl> + return func ( m optionalAttr ) { <nl> + m [ " is_global_init " ] = value <nl> + } <nl> + } <nl> + <nl> + / / ConfigureDistributedTPUEnableWholeMeshCompilations sets the optional enable_whole_mesh_compilations attribute to value . <nl> + / / If not specified , defaults to false <nl> + func ConfigureDistributedTPUEnableWholeMeshCompilations ( value bool ) ConfigureDistributedTPUAttr { <nl> + return func ( m optionalAttr ) { <nl> + m [ " enable_whole_mesh_compilations " ] = value <nl> + } <nl> + } <nl> + <nl> + / / ConfigureDistributedTPUCompilationFailureClosesChips sets the optional compilation_failure_closes_chips attribute to value . <nl> + / / If not specified , defaults to true <nl> + func ConfigureDistributedTPUCompilationFailureClosesChips ( value bool ) ConfigureDistributedTPUAttr { <nl> + return func ( m optionalAttr ) { <nl> + m [ " compilation_failure_closes_chips " ] = value <nl> + } <nl> + } <nl> + <nl> + / / Sets up the centralized structures for a distributed TPU system . <nl> + / / <nl> + / / Returns A serialized tensorflow . tpu . TopologyProto that describes the TPU <nl> + / / topology . <nl> + func ConfigureDistributedTPU ( scope * Scope , optional . . . ConfigureDistributedTPUAttr ) ( topology tf . Output ) { <nl> + if scope . Err ( ) ! = nil { <nl> + return <nl> + } <nl> + attrs : = map [ string ] interface { } { } <nl> + for _ , a : = range optional { <nl> + a ( attrs ) <nl> + } <nl> + opspec : = tf . OpSpec { <nl> + Type : " ConfigureDistributedTPU " , <nl> + <nl> + Attrs : attrs , <nl> + } <nl> + op : = scope . AddOperation ( opspec ) <nl> + return op . Output ( 0 ) <nl> + } <nl> + <nl> / / Combines ( nests of ) input elements into a dataset of ( nests of ) windows . <nl> / / <nl> / / A " window " is a finite dataset of flat elements of size ` size ` ( or possibly <nl> func RetrieveTPUEmbeddingFTRLParameters ( scope * Scope , num_shards int64 , shard_id <nl> return op . Output ( 0 ) , op . Output ( 1 ) , op . Output ( 2 ) <nl> } <nl> <nl> - / / LRNGradAttr is an optional argument to LRNGrad . <nl> - type LRNGradAttr func ( optionalAttr ) <nl> - <nl> - / / LRNGradDepthRadius sets the optional depth_radius attribute to value . <nl> - / / <nl> - / / value : A depth radius . <nl> - / / If not specified , defaults to 5 <nl> - func LRNGradDepthRadius ( value int64 ) LRNGradAttr { <nl> - return func ( m optionalAttr ) { <nl> - m [ " depth_radius " ] = value <nl> - } <nl> - } <nl> - <nl> - / / LRNGradBias sets the optional bias attribute to value . <nl> - / / <nl> - / / value : An offset ( usually > 0 to avoid dividing by 0 ) . <nl> - / / If not specified , defaults to 1 <nl> - func LRNGradBias ( value float32 ) LRNGradAttr { <nl> - return func ( m optionalAttr ) { <nl> - m [ " bias " ] = value <nl> - } <nl> - } <nl> - <nl> - / / LRNGradAlpha sets the optional alpha attribute to value . <nl> - / / <nl> - / / value : A scale factor , usually positive . <nl> - / / If not specified , defaults to 1 <nl> - func LRNGradAlpha ( value float32 ) LRNGradAttr { <nl> - return func ( m optionalAttr ) { <nl> - m [ " alpha " ] = value <nl> - } <nl> - } <nl> - <nl> - / / LRNGradBeta sets the optional beta attribute to value . <nl> - / / <nl> - / / value : An exponent . <nl> - / / If not specified , defaults to 0 . 5 <nl> - func LRNGradBeta ( value float32 ) LRNGradAttr { <nl> - return func ( m optionalAttr ) { <nl> - m [ " beta " ] = value <nl> - } <nl> - } <nl> - <nl> - / / Gradients for Local Response Normalization . <nl> - / / <nl> - / / Arguments : <nl> - / / input_grads : 4 - D with shape ` [ batch , height , width , channels ] ` . <nl> - / / input_image : 4 - D with shape ` [ batch , height , width , channels ] ` . <nl> - / / output_image : 4 - D with shape ` [ batch , height , width , channels ] ` . <nl> - / / <nl> - / / Returns The gradients for LRN . <nl> - func LRNGrad ( scope * Scope , input_grads tf . Output , input_image tf . Output , output_image tf . Output , optional . . . LRNGradAttr ) ( output tf . Output ) { <nl> - if scope . Err ( ) ! = nil { <nl> - return <nl> - } <nl> - attrs : = map [ string ] interface { } { } <nl> - for _ , a : = range optional { <nl> - a ( attrs ) <nl> - } <nl> - opspec : = tf . OpSpec { <nl> - Type : " LRNGrad " , <nl> - Input : [ ] tf . Input { <nl> - input_grads , input_image , output_image , <nl> - } , <nl> - Attrs : attrs , <nl> - } <nl> - op : = scope . AddOperation ( opspec ) <nl> - return op . Output ( 0 ) <nl> - } <nl> - <nl> - / / PrelinearizeAttr is an optional argument to Prelinearize . <nl> - type PrelinearizeAttr func ( optionalAttr ) <nl> - <nl> - / / PrelinearizeShape sets the optional shape attribute to value . <nl> - / / <nl> - / / value : The shape of the tensor . <nl> - / / If not specified , defaults to < > <nl> - func PrelinearizeShape ( value tf . Shape ) PrelinearizeAttr { <nl> - return func ( m optionalAttr ) { <nl> - m [ " shape " ] = value <nl> - } <nl> - } <nl> - <nl> - / / PrelinearizeLayout sets the optional layout attribute to value . <nl> - / / <nl> - / / value : A vector holding the requested layout in minor - to - major sequence . If a layout <nl> - / / attribute is passed but its values are all - 1 the layout will be computed by <nl> - / / the infeed operation . <nl> - / / If not specified , defaults to < > <nl> - func PrelinearizeLayout ( value [ ] int64 ) PrelinearizeAttr { <nl> - return func ( m optionalAttr ) { <nl> - m [ " layout " ] = value <nl> - } <nl> - } <nl> - <nl> - / / An op which linearizes one Tensor value to an opaque variant tensor . <nl> - / / <nl> - / / Arguments : <nl> - / / input : A tensor that will be linearized . <nl> - func Prelinearize ( scope * Scope , input tf . Output , optional . . . PrelinearizeAttr ) ( output tf . Output ) { <nl> - if scope . Err ( ) ! = nil { <nl> - return <nl> - } <nl> - attrs : = map [ string ] interface { } { } <nl> - for _ , a : = range optional { <nl> - a ( attrs ) <nl> - } <nl> - opspec : = tf . OpSpec { <nl> - Type : " Prelinearize " , <nl> - Input : [ ] tf . Input { <nl> - input , <nl> - } , <nl> - Attrs : attrs , <nl> - } <nl> - op : = scope . AddOperation ( opspec ) <nl> - return op . Output ( 0 ) <nl> - } <nl> - <nl> / / Returns the result of a TPU compilation . <nl> / / <nl> / / This operation returns the result of a TPU compilation as a serialized <nl> | Go : Update generated wrapper functions for TensorFlow ops . | tensorflow/tensorflow | 895709e1a8341638015db193053f24d4f987ca75 | 2020-06-02T19:04:18Z |
mmm a / benchmark / single - source / Hash . swift <nl> ppp b / benchmark / single - source / Hash . swift <nl> import TestsUtils <nl> public let HashTest = BenchmarkInfo ( <nl> name : " HashTest " , <nl> runFunction : run_HashTest , <nl> - tags : [ . validation , . algorithm ] ) <nl> + tags : [ . validation , . algorithm ] , <nl> + legacyFactor : 10 ) <nl> <nl> class Hash { <nl> / / / C ' tor . <nl> public func run_HashTest ( _ N : Int ) { <nl> " The quick brown fox jumps over the lazy dog . " : " ef537f25c895bfa782526529a9b63d97aa631564d5d789c2b765448c8635fb6c " ] <nl> let size = 50 <nl> <nl> - for _ in 1 . . . 10 * N { <nl> + for _ in 1 . . . N { <nl> / / Check for precomputed values . <nl> let MD = MD5 ( ) <nl> for ( K , V ) in TestMD5 { <nl> | [ benchmark ] HashTest Legacy Factor | apple/swift | f10ef5eb1ad9578c93a927ebde3829fcd053840e | 2019-01-22T08:26:05Z |
mmm a / modules / planning / conf / planning_config . pb . txt <nl> ppp b / modules / planning / conf / planning_config . pb . txt <nl> standard_planning_config { <nl> default_task_config : { <nl> task_type : DECIDER_RULE_BASED_STOP <nl> decider_rule_based_stop_config : { <nl> - stop_distance : 1 . 0 <nl> - traffic_light_signal_expire_time_sec : 5 . 0 <nl> + crosswalk : { <nl> + enabled : true <nl> + stop_distance : 1 . 0 <nl> + } <nl> + stop_sign : { <nl> + enabled : true <nl> + stop_distance : 1 . 0 <nl> + } <nl> + traffic_light : { <nl> + enabled : true <nl> + stop_distance : 1 . 0 <nl> + signal_expire_time_sec : 5 . 0 <nl> + } <nl> } <nl> } <nl> default_task_config : { <nl> mmm a / modules / planning / proto / decider_config . proto <nl> ppp b / modules / planning / proto / decider_config . proto <nl> message DeciderCreepConfig { <nl> optional double min_boundary_t = 4 [ default = 6 . 0 ] ; / / second <nl> } <nl> <nl> - message DeciderRuleBasedStopConfig { <nl> + message RuleCrosswalkConfig { <nl> + optional bool enabled = 1 [ default = true ] ; <nl> + / / stop distance ( m ) to the stop line of the crosswalk <nl> + optional double stop_distance = 2 [ default = 1 . 0 ] ; / / meter <nl> + } <nl> + <nl> + message RuleStopSignConfig { <nl> + optional bool enabled = 1 [ default = true ] ; <nl> / / stop distance ( m ) to the stop line of the stop sign <nl> - optional double stop_distance = 1 [ default = 1 . 0 ] ; / / meter <nl> - optional double traffic_light_signal_expire_time_sec = 2 [ default = 5 . 0 ] ; / / second <nl> + optional double stop_distance = 2 [ default = 1 . 0 ] ; / / meter <nl> + } <nl> + <nl> + message RuleTrafficLightConfig { <nl> + optional bool enabled = 1 [ default = true ] ; <nl> + / / stop distance ( m ) to the stop line of the traffic light <nl> + optional double stop_distance = 2 [ default = 1 . 0 ] ; / / meter <nl> + optional double signal_expire_time_sec = 3 [ default = 5 . 0 ] ; / / second <nl> + } <nl> + <nl> + message DeciderRuleBasedStopConfig { <nl> + optional RuleCrosswalkConfig crosswalk = 1 ; <nl> + optional RuleStopSignConfig stop_sign = 2 ; <nl> + optional RuleTrafficLightConfig traffic_light = 3 ; <nl> } <nl> <nl> message SidePassSafetyConfig { <nl> mmm a / modules / planning / toolkits / deciders / decider_rule_based_stop . cc <nl> ppp b / modules / planning / toolkits / deciders / decider_rule_based_stop . cc <nl> void DeciderRuleBasedStop : : CheckStopSign ( <nl> CHECK_NOTNULL ( frame ) ; <nl> CHECK_NOTNULL ( reference_line_info ) ; <nl> <nl> + if ( ! config_ . decider_rule_based_stop_config ( ) . stop_sign ( ) . enabled ( ) ) { <nl> + return ; <nl> + } <nl> + <nl> const std : : string stop_sign_id = <nl> PlanningContext : : GetScenarioInfo ( ) - > next_stop_sign_overlap . object_id ; <nl> if ( stop_sign_id . empty ( ) ) { <nl> void DeciderRuleBasedStop : : CheckStopSign ( <nl> const double stop_line_s = <nl> PlanningContext : : GetScenarioInfo ( ) - > next_stop_sign_overlap . start_s ; <nl> const double stop_distance = <nl> - config_ . decider_rule_based_stop_config ( ) . stop_distance ( ) ; <nl> + config_ . decider_rule_based_stop_config ( ) . stop_sign ( ) . stop_distance ( ) ; <nl> ADEBUG < < " DeciderRuleBasedStop : stop_wall_id [ " < < stop_wall_id <nl> < < " ] stop_line_s [ " < < stop_line_s < < " ] " ; <nl> <nl> void DeciderRuleBasedStop : : CheckTrafficLight ( <nl> CHECK_NOTNULL ( frame ) ; <nl> CHECK_NOTNULL ( reference_line_info ) ; <nl> <nl> + if ( ! config_ . decider_rule_based_stop_config ( ) . traffic_light ( ) . enabled ( ) ) { <nl> + return ; <nl> + } <nl> + <nl> const std : : string traffic_light_id = <nl> PlanningContext : : GetScenarioInfo ( ) - > next_traffic_light_overlap . object_id ; <nl> if ( traffic_light_id . empty ( ) ) { <nl> void DeciderRuleBasedStop : : CheckTrafficLight ( <nl> const double stop_line_s = <nl> PlanningContext : : GetScenarioInfo ( ) - > next_traffic_light_overlap . start_s ; <nl> const double stop_distance = <nl> - config_ . decider_rule_based_stop_config ( ) . stop_distance ( ) ; <nl> + config_ . decider_rule_based_stop_config ( ) . traffic_light ( ) . stop_distance ( ) ; <nl> <nl> ADEBUG < < " DeciderRuleBasedStop : stop_wall_id [ " < < stop_wall_id <nl> < < " ] stop_line_s [ " < < stop_line_s < < " ] " ; <nl> TrafficLight DeciderRuleBasedStop : : ReadTrafficLight ( <nl> } else { <nl> const double delay = traffic_light_detection - > header ( ) . timestamp_sec ( ) - <nl> Clock : : NowInSeconds ( ) ; <nl> - if ( delay > config_ . decider_rule_based_stop_config ( ) . <nl> - traffic_light_signal_expire_time_sec ( ) ) { <nl> + if ( delay > config_ . decider_rule_based_stop_config ( ) . traffic_light ( ) . <nl> + signal_expire_time_sec ( ) ) { <nl> ADEBUG < < " traffic signal is expired , delay [ " < < delay < < " ] seconds . " ; <nl> } else { <nl> for ( int i = 0 ; i < traffic_light_detection - > traffic_light_size ( ) ; i + + ) { <nl> | planning : update conf for decider_rule_based_stop task | ApolloAuto/apollo | bc67798650a77ce4aa28027fcc9e1fb0a292fdea | 2018-12-13T23:19:48Z |
mmm a / cocos / scripting / js - bindings / manual / ScriptingCore . cpp <nl> ppp b / cocos / scripting / js - bindings / manual / ScriptingCore . cpp <nl> static void serverEntryPoint ( unsigned int port ) <nl> <nl> listen ( s , 1 ) ; <nl> <nl> + <nl> + # define MAX_RECEIVED_SIZE 1024 <nl> + # define BUF_SIZE MAX_RECEIVED_SIZE + 1 <nl> + <nl> + char buf [ BUF_SIZE ] = { 0 } ; <nl> + int readBytes = 0 ; <nl> while ( true ) { <nl> clientSocket = accept ( s , NULL , NULL ) ; <nl> <nl> static void serverEntryPoint ( unsigned int port ) <nl> inData = " connected " ; <nl> / / process any input , send any output <nl> clearBuffers ( ) ; <nl> - <nl> - char buf [ 1024 ] = { 0 } ; <nl> - int readBytes = 0 ; <nl> - while ( ( readBytes = ( int ) : : recv ( clientSocket , buf , sizeof ( buf ) , 0 ) ) > 0 ) <nl> + <nl> + while ( ( readBytes = ( int ) : : recv ( clientSocket , buf , MAX_RECEIVED_SIZE , 0 ) ) > 0 ) <nl> { <nl> buf [ readBytes ] = ' \ 0 ' ; <nl> / / TRACE_DEBUGGER_SERVER ( " debug server : received command > % s " , buf ) ; <nl> static void serverEntryPoint ( unsigned int port ) <nl> cc_closesocket ( clientSocket ) ; <nl> } <nl> } / / while ( true ) <nl> + <nl> + # undef BUF_SIZE <nl> + # undef MAX_RECEIVED_SIZE <nl> } <nl> <nl> bool JSBDebug_BufferWrite ( JSContext * cx , unsigned argc , jsval * vp ) <nl> | avoid to access invalid memory when received data length is the same as buffer size | cocos2d/cocos2d-x | b7b74f2328a11ba5abb230b8747ee73f2a235105 | 2016-06-03T03:39:01Z |
mmm a / core / SCsub <nl> ppp b / core / SCsub <nl> thirdparty_minizip_sources = [ <nl> thirdparty_minizip_sources = [ thirdparty_minizip_dir + file for file in thirdparty_minizip_sources ] <nl> env . add_source_files ( env . core_sources , thirdparty_minizip_sources ) <nl> <nl> + thirdparty_zstd_dir = " # thirdparty / zstd / " <nl> + thirdparty_zstd_sources = [ <nl> + " common / entropy_common . c " , <nl> + " common / error_private . c " , <nl> + " common / fse_decompress . c " , <nl> + " common / pool . c " , <nl> + " common / threading . c " , <nl> + " common / xxhash . c " , <nl> + " common / zstd_common . c " , <nl> + " compress / fse_compress . c " , <nl> + " compress / huf_compress . c " , <nl> + " compress / zstd_compress . c " , <nl> + " compress / zstdmt_compress . c " , <nl> + " decompress / huf_decompress . c " , <nl> + " decompress / zstd_decompress . c " , <nl> + ] <nl> + thirdparty_zstd_sources = [ thirdparty_zstd_dir + file for file in thirdparty_zstd_sources ] <nl> + env . add_source_files ( env . core_sources , thirdparty_zstd_sources ) <nl> + <nl> <nl> # Godot ' s own sources <nl> env . add_source_files ( env . core_sources , " * . cpp " ) <nl> SConscript ( ' helper / SCsub ' ) <nl> # Build it all as a library <nl> lib = env . Library ( " core " , env . core_sources ) <nl> env . Prepend ( LIBS = [ lib ] ) <nl> - <nl> + env . Append ( CPPPATH = [ " # thirdparty / zstd " , " # thirdparty / zstd / common " ] ) <nl> Export ( ' env ' ) <nl> mmm a / core / io / compression . cpp <nl> ppp b / core / io / compression . cpp <nl> <nl> # include " zip_io . h " <nl> <nl> # include " thirdparty / misc / fastlz . h " <nl> + # include " thirdparty / zstd / zstd . h " <nl> <nl> # include < zlib . h > <nl> <nl> + # define ZSTD_DEFAULT_COMPRESSION 3 <nl> + <nl> int Compression : : compress ( uint8_t * p_dst , const uint8_t * p_src , int p_src_size , Mode p_mode ) { <nl> <nl> switch ( p_mode ) { <nl> int Compression : : compress ( uint8_t * p_dst , const uint8_t * p_src , int p_src_size , <nl> return aout ; <nl> <nl> } break ; <nl> + case MODE_ZSTD : { <nl> + <nl> + int max_dst_size = get_max_compressed_buffer_size ( p_src_size , MODE_ZSTD ) ; <nl> + return ZSTD_compress ( p_dst , max_dst_size , p_src , p_src_size , ZSTD_DEFAULT_COMPRESSION ) ; <nl> + } break ; <nl> } <nl> <nl> ERR_FAIL_V ( - 1 ) ; <nl> int Compression : : get_max_compressed_buffer_size ( int p_src_size , Mode p_mode ) { <nl> deflateEnd ( & strm ) ; <nl> return aout ; <nl> } break ; <nl> + case MODE_ZSTD : { <nl> + <nl> + return ZSTD_compressBound ( p_src_size ) ; <nl> + } break ; <nl> } <nl> <nl> ERR_FAIL_V ( - 1 ) ; <nl> int Compression : : decompress ( uint8_t * p_dst , int p_dst_max_size , const uint8_t * p <nl> ERR_FAIL_COND_V ( err ! = Z_STREAM_END , - 1 ) ; <nl> return total ; <nl> } break ; <nl> + case MODE_ZSTD : { <nl> + <nl> + return ZSTD_decompress ( p_dst , p_dst_max_size , p_src , p_src_size ) ; <nl> + } break ; <nl> } <nl> <nl> ERR_FAIL_V ( - 1 ) ; <nl> mmm a / core / io / compression . h <nl> ppp b / core / io / compression . h <nl> class Compression { <nl> public : <nl> enum Mode { <nl> MODE_FASTLZ , <nl> - MODE_DEFLATE <nl> + MODE_DEFLATE , <nl> + MODE_ZSTD <nl> } ; <nl> <nl> - static int compress ( uint8_t * p_dst , const uint8_t * p_src , int p_src_size , Mode p_mode = MODE_FASTLZ ) ; <nl> - static int get_max_compressed_buffer_size ( int p_src_size , Mode p_mode = MODE_FASTLZ ) ; <nl> - static int decompress ( uint8_t * p_dst , int p_dst_max_size , const uint8_t * p_src , int p_src_size , Mode p_mode = MODE_FASTLZ ) ; <nl> + static int compress ( uint8_t * p_dst , const uint8_t * p_src , int p_src_size , Mode p_mode = MODE_ZSTD ) ; <nl> + static int get_max_compressed_buffer_size ( int p_src_size , Mode p_mode = MODE_ZSTD ) ; <nl> + static int decompress ( uint8_t * p_dst , int p_dst_max_size , const uint8_t * p_src , int p_src_size , Mode p_mode = MODE_ZSTD ) ; <nl> <nl> Compression ( ) ; <nl> } ; <nl> mmm a / core / io / file_access_compressed . cpp <nl> ppp b / core / io / file_access_compressed . cpp <nl> FileAccessCompressed : : FileAccessCompressed ( ) { <nl> f = NULL ; <nl> magic = " GCMP " ; <nl> block_size = 16384 ; <nl> - cmode = Compression : : MODE_DEFLATE ; <nl> + cmode = Compression : : MODE_ZSTD ; <nl> writing = false ; <nl> write_ptr = 0 ; <nl> write_buffer_size = 0 ; <nl> mmm a / core / io / file_access_compressed . h <nl> ppp b / core / io / file_access_compressed . h <nl> class FileAccessCompressed : public FileAccess { <nl> FileAccess * f ; <nl> <nl> public : <nl> - void configure ( const String & p_magic , Compression : : Mode p_mode = Compression : : MODE_FASTLZ , int p_block_size = 4096 ) ; <nl> + void configure ( const String & p_magic , Compression : : Mode p_mode = Compression : : MODE_ZSTD , int p_block_size = 4096 ) ; <nl> <nl> Error open_after_magic ( FileAccess * p_base ) ; <nl> <nl> mmm a / doc / base / classes . xml <nl> ppp b / doc / base / classes . xml <nl> <nl> < / constant > <nl> < constant name = " COMPRESS_ZLIB " value = " 3 " > <nl> < / constant > <nl> + < constant name = " COMPRESS_ZSTD " value = " 4 " > <nl> + < / constant > <nl> < / constants > <nl> < / class > <nl> < class name = " NetworkedMultiplayerPeer " inherits = " PacketPeer " category = " Core " > <nl> do_property ] . <nl> Sets environment properties for the entire scene <nl> < / brief_description > <nl> < description > <nl> - The [ WorldEnvironment ] node can be added to a scene in order to set default [ Environment ] variables for the scene . The [ WorldEnvironment ] can be overridden by an [ Environment ] node set on the current [ Camera ] . Additionally , only one [ WorldEnvironment ] may be instanced in a given scene at a time . The [ WorldEnvironment ] allows the user to specify default lighting parameters ( e . g . ambient lighting ) , various post - processing effects ( e . g . SSAO , DOF , Tonemapping ) , and how to draw the background ( e . g . solid color , skybox ) . <nl> + The [ WorldEnvironment ] node can be added to a scene in order to set default [ Environment ] variables for the scene . The [ WorldEnvironment ] can be overridden by an [ Environment ] node set on the current [ Camera ] . Additionally , only one [ WorldEnvironment ] may be instanced in a given scene at a time . The [ WorldEnvironment ] allows the user to specify default lighting parameters ( e . g . ambient lighting ) , various post - processing effects ( e . g . SSAO , DOF , Tonemapping ) , and how to draw the background ( e . g . solid color , skybox ) . <nl> < / description > <nl> < methods > <nl> < method name = " get_environment " qualifiers = " const " > <nl> mmm a / modules / enet / networked_multiplayer_enet . cpp <nl> ppp b / modules / enet / networked_multiplayer_enet . cpp <nl> size_t NetworkedMultiplayerENet : : enet_compress ( void * context , const ENetBuffer * <nl> case COMPRESS_ZLIB : { <nl> mode = Compression : : MODE_DEFLATE ; <nl> } break ; <nl> + case COMPRESS_ZSTD : { <nl> + mode = Compression : : MODE_ZSTD ; <nl> + } break ; <nl> default : { ERR_FAIL_V ( 0 ) ; } <nl> } <nl> <nl> size_t NetworkedMultiplayerENet : : enet_decompress ( void * context , const enet_uint8 <nl> <nl> ret = Compression : : decompress ( outData , outLimit , inData , inLimit , Compression : : MODE_DEFLATE ) ; <nl> } break ; <nl> + case COMPRESS_ZSTD : { <nl> + <nl> + ret = Compression : : decompress ( outData , outLimit , inData , inLimit , Compression : : MODE_ZSTD ) ; <nl> + } break ; <nl> default : { } <nl> } <nl> if ( ret < 0 ) { <nl> void NetworkedMultiplayerENet : : _setup_compressor ( ) { <nl> enet_host_compress_with_range_coder ( host ) ; <nl> } break ; <nl> case COMPRESS_FASTLZ : <nl> - case COMPRESS_ZLIB : { <nl> + case COMPRESS_ZLIB : <nl> + case COMPRESS_ZSTD : { <nl> <nl> enet_host_compress ( host , & enet_compressor ) ; <nl> } break ; <nl> void NetworkedMultiplayerENet : : _bind_methods ( ) { <nl> BIND_CONSTANT ( COMPRESS_RANGE_CODER ) ; <nl> BIND_CONSTANT ( COMPRESS_FASTLZ ) ; <nl> BIND_CONSTANT ( COMPRESS_ZLIB ) ; <nl> + BIND_CONSTANT ( COMPRESS_ZSTD ) ; <nl> } <nl> <nl> NetworkedMultiplayerENet : : NetworkedMultiplayerENet ( ) { <nl> mmm a / modules / enet / networked_multiplayer_enet . h <nl> ppp b / modules / enet / networked_multiplayer_enet . h <nl> class NetworkedMultiplayerENet : public NetworkedMultiplayerPeer { <nl> COMPRESS_NONE , <nl> COMPRESS_RANGE_CODER , <nl> COMPRESS_FASTLZ , <nl> - COMPRESS_ZLIB <nl> + COMPRESS_ZLIB , <nl> + COMPRESS_ZSTD <nl> } ; <nl> <nl> private : <nl> mmm a / thirdparty / README . md <nl> ppp b / thirdparty / README . md <nl> https : / / github . com / godotengine / godot / commit / 37f5e1dcd94611dd5b670f013abf0323e8b4 <nl> Files extracted from upstream source : <nl> <nl> - all . c and . h files <nl> + <nl> + # # zstd <nl> + <nl> + - Upstream : https : / / github . com / facebook / zstd <nl> + - Version : 1 . 2 . 0 <nl> + - License : BSD - 3 - Clause <nl> + <nl> + Files extracted from upstream source : <nl> + <nl> + - all . c and . h under lib / <nl> + - README . md , LICENSE , PATENTS <nl> new file mode 100644 <nl> index 00000000000 . . a793a802892 <nl> mmm / dev / null <nl> ppp b / thirdparty / zstd / LICENSE <nl> <nl> + BSD License <nl> + <nl> + For Zstandard software <nl> + <nl> + Copyright ( c ) 2016 - present , Facebook , Inc . All rights reserved . <nl> + <nl> + Redistribution and use in source and binary forms , with or without modification , <nl> + are permitted provided that the following conditions are met : <nl> + <nl> + * Redistributions of source code must retain the above copyright notice , this <nl> + list of conditions and the following disclaimer . <nl> + <nl> + * Redistributions in binary form must reproduce the above copyright notice , <nl> + this list of conditions and the following disclaimer in the documentation <nl> + and / or other materials provided with the distribution . <nl> + <nl> + * Neither the name Facebook nor the names of its contributors may be used to <nl> + endorse or promote products derived from this software without specific <nl> + prior written permission . <nl> + <nl> + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS " AS IS " AND <nl> + ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT LIMITED TO , THE IMPLIED <nl> + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE <nl> + DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR <nl> + ANY DIRECT , INDIRECT , INCIDENTAL , SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES <nl> + ( INCLUDING , BUT NOT LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; <nl> + LOSS OF USE , DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON <nl> + ANY THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF THIS <nl> + SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> new file mode 100644 <nl> index 00000000000 . . 15b4a2ea5ca <nl> mmm / dev / null <nl> ppp b / thirdparty / zstd / PATENTS <nl> <nl> + Additional Grant of Patent Rights Version 2 <nl> + <nl> + " Software " means the Zstandard software distributed by Facebook , Inc . <nl> + <nl> + Facebook , Inc . ( " Facebook " ) hereby grants to each recipient of the Software <nl> + ( " you " ) a perpetual , worldwide , royalty - free , non - exclusive , irrevocable <nl> + ( subject to the termination provision below ) license under any Necessary <nl> + Claims , to make , have made , use , sell , offer to sell , import , and otherwise <nl> + transfer the Software . For avoidance of doubt , no license is granted under <nl> + Facebook ’ s rights in any patent claims that are infringed by ( i ) modifications <nl> + to the Software made by you or any third party or ( ii ) the Software in <nl> + combination with any software or other technology . <nl> + <nl> + The license granted hereunder will terminate , automatically and without notice , <nl> + if you ( or any of your subsidiaries , corporate affiliates or agents ) initiate <nl> + directly or indirectly , or take a direct financial interest in , any Patent <nl> + Assertion : ( i ) against Facebook or any of its subsidiaries or corporate <nl> + affiliates , ( ii ) against any party if such Patent Assertion arises in whole or <nl> + in part from any software , technology , product or service of Facebook or any of <nl> + its subsidiaries or corporate affiliates , or ( iii ) against any party relating <nl> + to the Software . Notwithstanding the foregoing , if Facebook or any of its <nl> + subsidiaries or corporate affiliates files a lawsuit alleging patent <nl> + infringement against you in the first instance , and you respond by filing a <nl> + patent infringement counterclaim in that lawsuit against that party that is <nl> + unrelated to the Software , the license granted hereunder will not terminate <nl> + under section ( i ) of this paragraph due to such counterclaim . <nl> + <nl> + A " Necessary Claim " is a claim of a patent owned by Facebook that is <nl> + necessarily infringed by the Software standing alone . <nl> + <nl> + A " Patent Assertion " is any lawsuit or other action alleging direct , indirect , <nl> + or contributory infringement or inducement to infringe any patent , including a <nl> + cross - claim or counterclaim . <nl> new file mode 100644 <nl> index 00000000000 . . 7caee5fd3f6 <nl> mmm / dev / null <nl> ppp b / thirdparty / zstd / README . md <nl> <nl> + __Zstandard__ , or ` zstd ` as short version , is a fast lossless compression algorithm , <nl> + targeting real - time compression scenarios at zlib - level and better compression ratios . <nl> + <nl> + It is provided as an open - source BSD - licensed * * C * * library , <nl> + and a command line utility producing and decoding ` . zst ` and ` . gz ` files . <nl> + For other programming languages , <nl> + you can consult a list of known ports on [ Zstandard homepage ] ( http : / / www . zstd . net / # other - languages ) . <nl> + <nl> + | Branch | Status | <nl> + | mmmmmmmmmmmm | mmmmmmmmm | <nl> + | master | [ ! [ Build Status ] ( https : / / travis - ci . org / facebook / zstd . svg ? branch = master ) ] ( https : / / travis - ci . org / facebook / zstd ) | <nl> + | dev | [ ! [ Build Status ] ( https : / / travis - ci . org / facebook / zstd . svg ? branch = dev ) ] ( https : / / travis - ci . org / facebook / zstd ) | <nl> + <nl> + As a reference , several fast compression algorithms were tested and compared <nl> + on a server running Linux Debian ( ` Linux version 4 . 8 . 0 - 1 - amd64 ` ) , <nl> + with a Core i7 - 6700K CPU @ 4 . 0GHz , <nl> + using [ lzbench ] , an open - source in - memory benchmark by @ inikep <nl> + compiled with GCC 6 . 3 . 0 , <nl> + on the [ Silesia compression corpus ] . <nl> + <nl> + [ lzbench ] : https : / / github . com / inikep / lzbench <nl> + [ Silesia compression corpus ] : http : / / sun . aei . polsl . pl / ~ sdeor / index . php ? page = silesia <nl> + <nl> + | Compressor name | Ratio | Compression | Decompress . | <nl> + | mmmmmmmmmmmmmmm | mmmmmm | mmmmmmmmm - - | mmmmmmmmm - | <nl> + | * * zstd 1 . 1 . 3 - 1 * * | 2 . 877 | 430 MB / s | 1110 MB / s | <nl> + | zlib 1 . 2 . 8 - 1 | 2 . 743 | 110 MB / s | 400 MB / s | <nl> + | brotli 0 . 5 . 2 - 0 | 2 . 708 | 400 MB / s | 430 MB / s | <nl> + | quicklz 1 . 5 . 0 - 1 | 2 . 238 | 550 MB / s | 710 MB / s | <nl> + | lzo1x 2 . 09 - 1 | 2 . 108 | 650 MB / s | 830 MB / s | <nl> + | lz4 1 . 7 . 5 | 2 . 101 | 720 MB / s | 3600 MB / s | <nl> + | snappy 1 . 1 . 3 | 2 . 091 | 500 MB / s | 1650 MB / s | <nl> + | lzf 3 . 6 - 1 | 2 . 077 | 400 MB / s | 860 MB / s | <nl> + <nl> + [ zlib ] : http : / / www . zlib . net / <nl> + [ LZ4 ] : http : / / www . lz4 . org / <nl> + <nl> + Zstd can also offer stronger compression ratios at the cost of compression speed . <nl> + Speed vs Compression trade - off is configurable by small increments . Decompression speed is preserved and remains roughly the same at all settings , a property shared by most LZ compression algorithms , such as [ zlib ] or lzma . <nl> + <nl> + The following tests were run <nl> + on a server running Linux Debian ( ` Linux version 4 . 8 . 0 - 1 - amd64 ` ) <nl> + with a Core i7 - 6700K CPU @ 4 . 0GHz , <nl> + using [ lzbench ] , an open - source in - memory benchmark by @ inikep <nl> + compiled with GCC 6 . 3 . 0 , <nl> + on the [ Silesia compression corpus ] . <nl> + <nl> + Compression Speed vs Ratio | Decompression Speed <nl> + mmmmmmmmmmmmmmmmmmmmmmmmmmm | mmmmmmmmmmmmmmmmmm - - <nl> + ! [ Compression Speed vs Ratio ] ( doc / images / Cspeed4 . png " Compression Speed vs Ratio " ) | ! [ Decompression Speed ] ( doc / images / Dspeed4 . png " Decompression Speed " ) <nl> + <nl> + Several algorithms can produce higher compression ratios , but at slower speeds , falling outside of the graph . <nl> + For a larger picture including very slow modes , [ click on this link ] ( doc / images / DCspeed5 . png ) . <nl> + <nl> + <nl> + # # # The case for Small Data compression <nl> + <nl> + Previous charts provide results applicable to typical file and stream scenarios ( several MB ) . Small data comes with different perspectives . <nl> + <nl> + The smaller the amount of data to compress , the more difficult it is to compress . This problem is common to all compression algorithms , and reason is , compression algorithms learn from past data how to compress future data . But at the beginning of a new data set , there is no " past " to build upon . <nl> + <nl> + To solve this situation , Zstd offers a __training mode__ , which can be used to tune the algorithm for a selected type of data . <nl> + Training Zstandard is achieved by provide it with a few samples ( one file per sample ) . The result of this training is stored in a file called " dictionary " , which must be loaded before compression and decompression . <nl> + Using this dictionary , the compression ratio achievable on small data improves dramatically . <nl> + <nl> + The following example uses the ` github - users ` [ sample set ] ( https : / / github . com / facebook / zstd / releases / tag / v1 . 1 . 3 ) , created from [ github public API ] ( https : / / developer . github . com / v3 / users / # get - all - users ) . <nl> + It consists of roughly 10K records weighting about 1KB each . <nl> + <nl> + Compression Ratio | Compression Speed | Decompression Speed <nl> + mmmmmmmmmmmmmmmmmm | mmmmmmmmmmmmmmmmmm - | mmmmmmmmmmmmmmmmmm - - <nl> + ! [ Compression Ratio ] ( doc / images / dict - cr . png " Compression Ratio " ) | ! [ Compression Speed ] ( doc / images / dict - cs . png " Compression Speed " ) | ! [ Decompression Speed ] ( doc / images / dict - ds . png " Decompression Speed " ) <nl> + <nl> + <nl> + These compression gains are achieved while simultaneously providing _faster_ compression and decompression speeds . <nl> + <nl> + Training works if there is some correlation in a family of small data samples . The more data - specific a dictionary is , the more efficient it is ( there is no _universal dictionary_ ) . <nl> + Hence , deploying one dictionary per type of data will provide the greatest benefits . <nl> + Dictionary gains are mostly effective in the first few KB . Then , the compression algorithm will gradually use previously decoded content to better compress the rest of the file . <nl> + <nl> + # # # # Dictionary compression How To : <nl> + <nl> + 1 ) Create the dictionary <nl> + <nl> + ` zstd - - train FullPathToTrainingSet / * - o dictionaryName ` <nl> + <nl> + 2 ) Compress with dictionary <nl> + <nl> + ` zstd - D dictionaryName FILE ` <nl> + <nl> + 3 ) Decompress with dictionary <nl> + <nl> + ` zstd - D dictionaryName - - decompress FILE . zst ` <nl> + <nl> + <nl> + # # # Build <nl> + <nl> + Once you have the repository cloned , there are multiple ways provided to build Zstandard . <nl> + <nl> + # # # # Makefile <nl> + <nl> + If your system is compatible with a standard ` make ` ( or ` gmake ` ) binary generator , <nl> + you can simply run it at the root directory . <nl> + It will generate ` zstd ` within root directory . <nl> + <nl> + Other available options include : <nl> + - ` make install ` : create and install zstd binary , library and man page <nl> + - ` make test ` : create and run ` zstd ` and test tools on local platform <nl> + <nl> + # # # # cmake <nl> + <nl> + A ` cmake ` project generator is provided within ` build / cmake ` . <nl> + It can generate Makefiles or other build scripts <nl> + to create ` zstd ` binary , and ` libzstd ` dynamic and static libraries . <nl> + <nl> + # # # # Meson <nl> + <nl> + A Meson project is provided within ` contrib / meson ` . <nl> + <nl> + # # # # Visual Studio ( Windows ) <nl> + <nl> + Going into ` build ` directory , you will find additional possibilities : <nl> + - Projects for Visual Studio 2005 , 2008 and 2010 <nl> + + VS2010 project is compatible with VS2012 , VS2013 and VS2015 <nl> + - Automated build scripts for Visual compiler by @ KrzysFR , in ` build / VS_scripts ` , <nl> + which will build ` zstd ` cli and ` libzstd ` library without any need to open Visual Studio solution . <nl> + <nl> + <nl> + # # # Status <nl> + <nl> + Zstandard is currently deployed within Facebook . It is used daily to compress and decompress very large amounts of data in multiple formats and use cases . <nl> + Zstandard is considered safe for production environments . <nl> + <nl> + # # # License <nl> + <nl> + Zstandard is [ BSD - licensed ] ( LICENSE ) . We also provide an [ additional patent grant ] ( PATENTS ) . <nl> + <nl> + # # # Contributing <nl> + <nl> + The " dev " branch is the one where all contributions will be merged before reaching " master " . <nl> + If you plan to propose a patch , please commit into the " dev " branch or its own feature branch . <nl> + Direct commit to " master " are not permitted . <nl> + For more information , please read [ CONTRIBUTING ] ( CONTRIBUTING . md ) . <nl> + <nl> + # # # Miscellaneous <nl> + <nl> + Zstd entropy stage is provided by [ Huff0 and FSE , from Finite State Entropy library ] ( https : / / github . com / Cyan4973 / FiniteStateEntropy ) . <nl> new file mode 100644 <nl> index 00000000000 . . ca42850df32 <nl> mmm / dev / null <nl> ppp b / thirdparty / zstd / common / bitstream . h <nl> <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + bitstream <nl> + Part of FSE library <nl> + header file ( to include ) <nl> + Copyright ( C ) 2013 - 2017 , Yann Collet . <nl> + <nl> + BSD 2 - Clause License ( http : / / www . opensource . org / licenses / bsd - license . php ) <nl> + <nl> + Redistribution and use in source and binary forms , with or without <nl> + modification , are permitted provided that the following conditions are <nl> + met : <nl> + <nl> + * Redistributions of source code must retain the above copyright <nl> + notice , this list of conditions and the following disclaimer . <nl> + * Redistributions in binary form must reproduce the above <nl> + copyright notice , this list of conditions and the following disclaimer <nl> + in the documentation and / or other materials provided with the <nl> + distribution . <nl> + <nl> + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + <nl> + You can contact the author at : <nl> + - Source repository : https : / / github . com / Cyan4973 / FiniteStateEntropy <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # ifndef BITSTREAM_H_MODULE <nl> + # define BITSTREAM_H_MODULE <nl> + <nl> + # if defined ( __cplusplus ) <nl> + extern " C " { <nl> + # endif <nl> + <nl> + <nl> + / * <nl> + * This API consists of small unitary functions , which must be inlined for best performance . <nl> + * Since link - time - optimization is not available for all compilers , <nl> + * these functions are defined into a . h to be included . <nl> + * / <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Dependencies <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # include " mem . h " / * unaligned access routines * / <nl> + # include " error_private . h " / * error codes and messages * / <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Debug <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # if defined ( BIT_DEBUG ) & & ( BIT_DEBUG > = 1 ) <nl> + # include < assert . h > <nl> + # else <nl> + # define assert ( condition ) ( ( void ) 0 ) <nl> + # endif <nl> + <nl> + <nl> + / * = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + * Target specific <nl> + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> + # if defined ( __BMI__ ) & & defined ( __GNUC__ ) <nl> + # include < immintrin . h > / * support for bextr ( experimental ) * / <nl> + # endif <nl> + <nl> + # define STREAM_ACCUMULATOR_MIN_32 25 <nl> + # define STREAM_ACCUMULATOR_MIN_64 57 <nl> + # define STREAM_ACCUMULATOR_MIN ( ( U32 ) ( MEM_32bits ( ) ? STREAM_ACCUMULATOR_MIN_32 : STREAM_ACCUMULATOR_MIN_64 ) ) <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * bitStream encoding API ( write forward ) <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * bitStream can mix input from multiple sources . <nl> + * A critical property of these streams is that they encode and decode in * * reverse * * direction . <nl> + * So the first bit sequence you add will be the last to be read , like a LIFO stack . <nl> + * / <nl> + typedef struct <nl> + { <nl> + size_t bitContainer ; <nl> + unsigned bitPos ; <nl> + char * startPtr ; <nl> + char * ptr ; <nl> + char * endPtr ; <nl> + } BIT_CStream_t ; <nl> + <nl> + MEM_STATIC size_t BIT_initCStream ( BIT_CStream_t * bitC , void * dstBuffer , size_t dstCapacity ) ; <nl> + MEM_STATIC void BIT_addBits ( BIT_CStream_t * bitC , size_t value , unsigned nbBits ) ; <nl> + MEM_STATIC void BIT_flushBits ( BIT_CStream_t * bitC ) ; <nl> + MEM_STATIC size_t BIT_closeCStream ( BIT_CStream_t * bitC ) ; <nl> + <nl> + / * Start with initCStream , providing the size of buffer to write into . <nl> + * bitStream will never write outside of this buffer . <nl> + * ` dstCapacity ` must be > = sizeof ( bitD - > bitContainer ) , otherwise @ return will be an error code . <nl> + * <nl> + * bits are first added to a local register . <nl> + * Local register is size_t , hence 64 - bits on 64 - bits systems , or 32 - bits on 32 - bits systems . <nl> + * Writing data into memory is an explicit operation , performed by the flushBits function . <nl> + * Hence keep track how many bits are potentially stored into local register to avoid register overflow . <nl> + * After a flushBits , a maximum of 7 bits might still be stored into local register . <nl> + * <nl> + * Avoid storing elements of more than 24 bits if you want compatibility with 32 - bits bitstream readers . <nl> + * <nl> + * Last operation is to close the bitStream . <nl> + * The function returns the final size of CStream in bytes . <nl> + * If data couldn ' t fit into ` dstBuffer ` , it will return a 0 ( = = not storable ) <nl> + * / <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * bitStream decoding API ( read backward ) <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + typedef struct <nl> + { <nl> + size_t bitContainer ; <nl> + unsigned bitsConsumed ; <nl> + const char * ptr ; <nl> + const char * start ; <nl> + const char * limitPtr ; <nl> + } BIT_DStream_t ; <nl> + <nl> + typedef enum { BIT_DStream_unfinished = 0 , <nl> + BIT_DStream_endOfBuffer = 1 , <nl> + BIT_DStream_completed = 2 , <nl> + BIT_DStream_overflow = 3 } BIT_DStream_status ; / * result of BIT_reloadDStream ( ) * / <nl> + / * 1 , 2 , 4 , 8 would be better for bitmap combinations , but slows down performance a bit . . . : ( * / <nl> + <nl> + MEM_STATIC size_t BIT_initDStream ( BIT_DStream_t * bitD , const void * srcBuffer , size_t srcSize ) ; <nl> + MEM_STATIC size_t BIT_readBits ( BIT_DStream_t * bitD , unsigned nbBits ) ; <nl> + MEM_STATIC BIT_DStream_status BIT_reloadDStream ( BIT_DStream_t * bitD ) ; <nl> + MEM_STATIC unsigned BIT_endOfDStream ( const BIT_DStream_t * bitD ) ; <nl> + <nl> + <nl> + / * Start by invoking BIT_initDStream ( ) . <nl> + * A chunk of the bitStream is then stored into a local register . <nl> + * Local register size is 64 - bits on 64 - bits systems , 32 - bits on 32 - bits systems ( size_t ) . <nl> + * You can then retrieve bitFields stored into the local register , * * in reverse order * * . <nl> + * Local register is explicitly reloaded from memory by the BIT_reloadDStream ( ) method . <nl> + * A reload guarantee a minimum of ( ( 8 * sizeof ( bitD - > bitContainer ) ) - 7 ) bits when its result is BIT_DStream_unfinished . <nl> + * Otherwise , it can be less than that , so proceed accordingly . <nl> + * Checking if DStream has reached its end can be performed with BIT_endOfDStream ( ) . <nl> + * / <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * unsafe API <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + MEM_STATIC void BIT_addBitsFast ( BIT_CStream_t * bitC , size_t value , unsigned nbBits ) ; <nl> + / * faster , but works only if value is " clean " , meaning all high bits above nbBits are 0 * / <nl> + <nl> + MEM_STATIC void BIT_flushBitsFast ( BIT_CStream_t * bitC ) ; <nl> + / * unsafe version ; does not check buffer overflow * / <nl> + <nl> + MEM_STATIC size_t BIT_readBitsFast ( BIT_DStream_t * bitD , unsigned nbBits ) ; <nl> + / * faster , but works only if nbBits > = 1 * / <nl> + <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Internal functions <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + MEM_STATIC unsigned BIT_highbit32 ( register U32 val ) <nl> + { <nl> + # if defined ( _MSC_VER ) / * Visual * / <nl> + unsigned long r = 0 ; <nl> + _BitScanReverse ( & r , val ) ; <nl> + return ( unsigned ) r ; <nl> + # elif defined ( __GNUC__ ) & & ( __GNUC__ > = 3 ) / * Use GCC Intrinsic * / <nl> + return 31 - __builtin_clz ( val ) ; <nl> + # else / * Software version * / <nl> + static const unsigned DeBruijnClz [ 32 ] = { 0 , 9 , 1 , 10 , 13 , 21 , 2 , 29 , <nl> + 11 , 14 , 16 , 18 , 22 , 25 , 3 , 30 , <nl> + 8 , 12 , 20 , 28 , 15 , 17 , 24 , 7 , <nl> + 19 , 27 , 23 , 6 , 26 , 5 , 4 , 31 } ; <nl> + U32 v = val ; <nl> + v | = v > > 1 ; <nl> + v | = v > > 2 ; <nl> + v | = v > > 4 ; <nl> + v | = v > > 8 ; <nl> + v | = v > > 16 ; <nl> + return DeBruijnClz [ ( U32 ) ( v * 0x07C4ACDDU ) > > 27 ] ; <nl> + # endif <nl> + } <nl> + <nl> + / * = = = = = Local Constants = = = = = * / <nl> + static const unsigned BIT_mask [ ] = { 0 , 1 , 3 , 7 , 0xF , 0x1F , 0x3F , 0x7F , <nl> + 0xFF , 0x1FF , 0x3FF , 0x7FF , 0xFFF , 0x1FFF , 0x3FFF , 0x7FFF , <nl> + 0xFFFF , 0x1FFFF , 0x3FFFF , 0x7FFFF , 0xFFFFF , 0x1FFFFF , 0x3FFFFF , 0x7FFFFF , <nl> + 0xFFFFFF , 0x1FFFFFF , 0x3FFFFFF } ; / * up to 26 bits * / <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * bitStream encoding <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * ! BIT_initCStream ( ) : <nl> + * ` dstCapacity ` must be > sizeof ( size_t ) <nl> + * @ return : 0 if success , <nl> + otherwise an error code ( can be tested using ERR_isError ( ) ) * / <nl> + MEM_STATIC size_t BIT_initCStream ( BIT_CStream_t * bitC , <nl> + void * startPtr , size_t dstCapacity ) <nl> + { <nl> + bitC - > bitContainer = 0 ; <nl> + bitC - > bitPos = 0 ; <nl> + bitC - > startPtr = ( char * ) startPtr ; <nl> + bitC - > ptr = bitC - > startPtr ; <nl> + bitC - > endPtr = bitC - > startPtr + dstCapacity - sizeof ( bitC - > bitContainer ) ; <nl> + if ( dstCapacity < = sizeof ( bitC - > bitContainer ) ) return ERROR ( dstSize_tooSmall ) ; <nl> + return 0 ; <nl> + } <nl> + <nl> + / * ! BIT_addBits ( ) : <nl> + can add up to 26 bits into ` bitC ` . <nl> + Does not check for register overflow ! * / <nl> + MEM_STATIC void BIT_addBits ( BIT_CStream_t * bitC , <nl> + size_t value , unsigned nbBits ) <nl> + { <nl> + bitC - > bitContainer | = ( value & BIT_mask [ nbBits ] ) < < bitC - > bitPos ; <nl> + bitC - > bitPos + = nbBits ; <nl> + } <nl> + <nl> + / * ! BIT_addBitsFast ( ) : <nl> + * works only if ` value ` is _clean_ , meaning all high bits above nbBits are 0 * / <nl> + MEM_STATIC void BIT_addBitsFast ( BIT_CStream_t * bitC , <nl> + size_t value , unsigned nbBits ) <nl> + { <nl> + assert ( ( value > > nbBits ) = = 0 ) ; <nl> + bitC - > bitContainer | = value < < bitC - > bitPos ; <nl> + bitC - > bitPos + = nbBits ; <nl> + } <nl> + <nl> + / * ! BIT_flushBitsFast ( ) : <nl> + * assumption : bitContainer has not overflowed <nl> + * unsafe version ; does not check buffer overflow * / <nl> + MEM_STATIC void BIT_flushBitsFast ( BIT_CStream_t * bitC ) <nl> + { <nl> + size_t const nbBytes = bitC - > bitPos > > 3 ; <nl> + assert ( bitC - > bitPos < = ( sizeof ( bitC - > bitContainer ) * 8 ) ) ; <nl> + MEM_writeLEST ( bitC - > ptr , bitC - > bitContainer ) ; <nl> + bitC - > ptr + = nbBytes ; <nl> + assert ( bitC - > ptr < = bitC - > endPtr ) ; <nl> + bitC - > bitPos & = 7 ; <nl> + bitC - > bitContainer > > = nbBytes * 8 ; <nl> + } <nl> + <nl> + / * ! BIT_flushBits ( ) : <nl> + * assumption : bitContainer has not overflowed <nl> + * safe version ; check for buffer overflow , and prevents it . <nl> + * note : does not signal buffer overflow . <nl> + * overflow will be revealed later on using BIT_closeCStream ( ) * / <nl> + MEM_STATIC void BIT_flushBits ( BIT_CStream_t * bitC ) <nl> + { <nl> + size_t const nbBytes = bitC - > bitPos > > 3 ; <nl> + assert ( bitC - > bitPos < = ( sizeof ( bitC - > bitContainer ) * 8 ) ) ; <nl> + MEM_writeLEST ( bitC - > ptr , bitC - > bitContainer ) ; <nl> + bitC - > ptr + = nbBytes ; <nl> + if ( bitC - > ptr > bitC - > endPtr ) bitC - > ptr = bitC - > endPtr ; <nl> + bitC - > bitPos & = 7 ; <nl> + bitC - > bitContainer > > = nbBytes * 8 ; <nl> + } <nl> + <nl> + / * ! BIT_closeCStream ( ) : <nl> + * @ return : size of CStream , in bytes , <nl> + or 0 if it could not fit into dstBuffer * / <nl> + MEM_STATIC size_t BIT_closeCStream ( BIT_CStream_t * bitC ) <nl> + { <nl> + BIT_addBitsFast ( bitC , 1 , 1 ) ; / * endMark * / <nl> + BIT_flushBits ( bitC ) ; <nl> + if ( bitC - > ptr > = bitC - > endPtr ) return 0 ; / * overflow detected * / <nl> + return ( bitC - > ptr - bitC - > startPtr ) + ( bitC - > bitPos > 0 ) ; <nl> + } <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * bitStream decoding <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * ! BIT_initDStream ( ) : <nl> + * Initialize a BIT_DStream_t . <nl> + * ` bitD ` : a pointer to an already allocated BIT_DStream_t structure . <nl> + * ` srcSize ` must be the * exact * size of the bitStream , in bytes . <nl> + * @ return : size of stream ( = = srcSize ) or an errorCode if a problem is detected <nl> + * / <nl> + MEM_STATIC size_t BIT_initDStream ( BIT_DStream_t * bitD , const void * srcBuffer , size_t srcSize ) <nl> + { <nl> + if ( srcSize < 1 ) { memset ( bitD , 0 , sizeof ( * bitD ) ) ; return ERROR ( srcSize_wrong ) ; } <nl> + <nl> + bitD - > start = ( const char * ) srcBuffer ; <nl> + bitD - > limitPtr = bitD - > start + sizeof ( bitD - > bitContainer ) ; <nl> + <nl> + if ( srcSize > = sizeof ( bitD - > bitContainer ) ) { / * normal case * / <nl> + bitD - > ptr = ( const char * ) srcBuffer + srcSize - sizeof ( bitD - > bitContainer ) ; <nl> + bitD - > bitContainer = MEM_readLEST ( bitD - > ptr ) ; <nl> + { BYTE const lastByte = ( ( const BYTE * ) srcBuffer ) [ srcSize - 1 ] ; <nl> + bitD - > bitsConsumed = lastByte ? 8 - BIT_highbit32 ( lastByte ) : 0 ; / * ensures bitsConsumed is always set * / <nl> + if ( lastByte = = 0 ) return ERROR ( GENERIC ) ; / * endMark not present * / } <nl> + } else { <nl> + bitD - > ptr = bitD - > start ; <nl> + bitD - > bitContainer = * ( const BYTE * ) ( bitD - > start ) ; <nl> + switch ( srcSize ) <nl> + { <nl> + case 7 : bitD - > bitContainer + = ( size_t ) ( ( ( const BYTE * ) ( srcBuffer ) ) [ 6 ] ) < < ( sizeof ( bitD - > bitContainer ) * 8 - 16 ) ; <nl> + case 6 : bitD - > bitContainer + = ( size_t ) ( ( ( const BYTE * ) ( srcBuffer ) ) [ 5 ] ) < < ( sizeof ( bitD - > bitContainer ) * 8 - 24 ) ; <nl> + case 5 : bitD - > bitContainer + = ( size_t ) ( ( ( const BYTE * ) ( srcBuffer ) ) [ 4 ] ) < < ( sizeof ( bitD - > bitContainer ) * 8 - 32 ) ; <nl> + case 4 : bitD - > bitContainer + = ( size_t ) ( ( ( const BYTE * ) ( srcBuffer ) ) [ 3 ] ) < < 24 ; <nl> + case 3 : bitD - > bitContainer + = ( size_t ) ( ( ( const BYTE * ) ( srcBuffer ) ) [ 2 ] ) < < 16 ; <nl> + case 2 : bitD - > bitContainer + = ( size_t ) ( ( ( const BYTE * ) ( srcBuffer ) ) [ 1 ] ) < < 8 ; <nl> + default : ; <nl> + } <nl> + { BYTE const lastByte = ( ( const BYTE * ) srcBuffer ) [ srcSize - 1 ] ; <nl> + bitD - > bitsConsumed = lastByte ? 8 - BIT_highbit32 ( lastByte ) : 0 ; <nl> + if ( lastByte = = 0 ) return ERROR ( GENERIC ) ; / * endMark not present * / } <nl> + bitD - > bitsConsumed + = ( U32 ) ( sizeof ( bitD - > bitContainer ) - srcSize ) * 8 ; <nl> + } <nl> + <nl> + return srcSize ; <nl> + } <nl> + <nl> + MEM_STATIC size_t BIT_getUpperBits ( size_t bitContainer , U32 const start ) <nl> + { <nl> + return bitContainer > > start ; <nl> + } <nl> + <nl> + MEM_STATIC size_t BIT_getMiddleBits ( size_t bitContainer , U32 const start , U32 const nbBits ) <nl> + { <nl> + # if defined ( __BMI__ ) & & defined ( __GNUC__ ) & & __GNUC__ * 1000 + __GNUC_MINOR__ > = 4008 / * experimental * / <nl> + # if defined ( __x86_64__ ) <nl> + if ( sizeof ( bitContainer ) = = 8 ) <nl> + return _bextr_u64 ( bitContainer , start , nbBits ) ; <nl> + else <nl> + # endif <nl> + return _bextr_u32 ( bitContainer , start , nbBits ) ; <nl> + # else <nl> + return ( bitContainer > > start ) & BIT_mask [ nbBits ] ; <nl> + # endif <nl> + } <nl> + <nl> + MEM_STATIC size_t BIT_getLowerBits ( size_t bitContainer , U32 const nbBits ) <nl> + { <nl> + return bitContainer & BIT_mask [ nbBits ] ; <nl> + } <nl> + <nl> + / * ! BIT_lookBits ( ) : <nl> + * Provides next n bits from local register . <nl> + * local register is not modified . <nl> + * On 32 - bits , maxNbBits = = 24 . <nl> + * On 64 - bits , maxNbBits = = 56 . <nl> + * @ return : value extracted <nl> + * / <nl> + MEM_STATIC size_t BIT_lookBits ( const BIT_DStream_t * bitD , U32 nbBits ) <nl> + { <nl> + # if defined ( __BMI__ ) & & defined ( __GNUC__ ) / * experimental ; fails if bitD - > bitsConsumed + nbBits > sizeof ( bitD - > bitContainer ) * 8 * / <nl> + return BIT_getMiddleBits ( bitD - > bitContainer , ( sizeof ( bitD - > bitContainer ) * 8 ) - bitD - > bitsConsumed - nbBits , nbBits ) ; <nl> + # else <nl> + U32 const regMask = sizeof ( bitD - > bitContainer ) * 8 - 1 ; <nl> + return ( ( bitD - > bitContainer < < ( bitD - > bitsConsumed & regMask ) ) > > 1 ) > > ( ( regMask - nbBits ) & regMask ) ; <nl> + # endif <nl> + } <nl> + <nl> + / * ! BIT_lookBitsFast ( ) : <nl> + * unsafe version ; only works if nbBits > = 1 * / <nl> + MEM_STATIC size_t BIT_lookBitsFast ( const BIT_DStream_t * bitD , U32 nbBits ) <nl> + { <nl> + U32 const regMask = sizeof ( bitD - > bitContainer ) * 8 - 1 ; <nl> + assert ( nbBits > = 1 ) ; <nl> + return ( bitD - > bitContainer < < ( bitD - > bitsConsumed & regMask ) ) > > ( ( ( regMask + 1 ) - nbBits ) & regMask ) ; <nl> + } <nl> + <nl> + MEM_STATIC void BIT_skipBits ( BIT_DStream_t * bitD , U32 nbBits ) <nl> + { <nl> + bitD - > bitsConsumed + = nbBits ; <nl> + } <nl> + <nl> + / * ! BIT_readBits ( ) : <nl> + * Read ( consume ) next n bits from local register and update . <nl> + * Pay attention to not read more than nbBits contained into local register . <nl> + * @ return : extracted value . <nl> + * / <nl> + MEM_STATIC size_t BIT_readBits ( BIT_DStream_t * bitD , U32 nbBits ) <nl> + { <nl> + size_t const value = BIT_lookBits ( bitD , nbBits ) ; <nl> + BIT_skipBits ( bitD , nbBits ) ; <nl> + return value ; <nl> + } <nl> + <nl> + / * ! BIT_readBitsFast ( ) : <nl> + * unsafe version ; only works only if nbBits > = 1 * / <nl> + MEM_STATIC size_t BIT_readBitsFast ( BIT_DStream_t * bitD , U32 nbBits ) <nl> + { <nl> + size_t const value = BIT_lookBitsFast ( bitD , nbBits ) ; <nl> + assert ( nbBits > = 1 ) ; <nl> + BIT_skipBits ( bitD , nbBits ) ; <nl> + return value ; <nl> + } <nl> + <nl> + / * ! BIT_reloadDStream ( ) : <nl> + * Refill ` bitD ` from buffer previously set in BIT_initDStream ( ) . <nl> + * This function is safe , it guarantees it will not read beyond src buffer . <nl> + * @ return : status of ` BIT_DStream_t ` internal register . <nl> + if status = = BIT_DStream_unfinished , internal register is filled with > = ( sizeof ( bitD - > bitContainer ) * 8 - 7 ) bits * / <nl> + MEM_STATIC BIT_DStream_status BIT_reloadDStream ( BIT_DStream_t * bitD ) <nl> + { <nl> + if ( bitD - > bitsConsumed > ( sizeof ( bitD - > bitContainer ) * 8 ) ) / * overflow detected , like end of stream * / <nl> + return BIT_DStream_overflow ; <nl> + <nl> + if ( bitD - > ptr > = bitD - > limitPtr ) { <nl> + bitD - > ptr - = bitD - > bitsConsumed > > 3 ; <nl> + bitD - > bitsConsumed & = 7 ; <nl> + bitD - > bitContainer = MEM_readLEST ( bitD - > ptr ) ; <nl> + return BIT_DStream_unfinished ; <nl> + } <nl> + if ( bitD - > ptr = = bitD - > start ) { <nl> + if ( bitD - > bitsConsumed < sizeof ( bitD - > bitContainer ) * 8 ) return BIT_DStream_endOfBuffer ; <nl> + return BIT_DStream_completed ; <nl> + } <nl> + / * start < ptr < limitPtr * / <nl> + { U32 nbBytes = bitD - > bitsConsumed > > 3 ; <nl> + BIT_DStream_status result = BIT_DStream_unfinished ; <nl> + if ( bitD - > ptr - nbBytes < bitD - > start ) { <nl> + nbBytes = ( U32 ) ( bitD - > ptr - bitD - > start ) ; / * ptr > start * / <nl> + result = BIT_DStream_endOfBuffer ; <nl> + } <nl> + bitD - > ptr - = nbBytes ; <nl> + bitD - > bitsConsumed - = nbBytes * 8 ; <nl> + bitD - > bitContainer = MEM_readLEST ( bitD - > ptr ) ; / * reminder : srcSize > sizeof ( bitD - > bitContainer ) , otherwise bitD - > ptr = = bitD - > start * / <nl> + return result ; <nl> + } <nl> + } <nl> + <nl> + / * ! BIT_endOfDStream ( ) : <nl> + * @ return Tells if DStream has exactly reached its end ( all bits consumed ) . <nl> + * / <nl> + MEM_STATIC unsigned BIT_endOfDStream ( const BIT_DStream_t * DStream ) <nl> + { <nl> + return ( ( DStream - > ptr = = DStream - > start ) & & ( DStream - > bitsConsumed = = sizeof ( DStream - > bitContainer ) * 8 ) ) ; <nl> + } <nl> + <nl> + # if defined ( __cplusplus ) <nl> + } <nl> + # endif <nl> + <nl> + # endif / * BITSTREAM_H_MODULE * / <nl> new file mode 100644 <nl> index 00000000000 . . b37a082fee2 <nl> mmm / dev / null <nl> ppp b / thirdparty / zstd / common / entropy_common . c <nl> <nl> + / * <nl> + Common functions of New Generation Entropy library <nl> + Copyright ( C ) 2016 , Yann Collet . <nl> + <nl> + BSD 2 - Clause License ( http : / / www . opensource . org / licenses / bsd - license . php ) <nl> + <nl> + Redistribution and use in source and binary forms , with or without <nl> + modification , are permitted provided that the following conditions are <nl> + met : <nl> + <nl> + * Redistributions of source code must retain the above copyright <nl> + notice , this list of conditions and the following disclaimer . <nl> + * Redistributions in binary form must reproduce the above <nl> + copyright notice , this list of conditions and the following disclaimer <nl> + in the documentation and / or other materials provided with the <nl> + distribution . <nl> + <nl> + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + <nl> + You can contact the author at : <nl> + - FSE + HUF source repository : https : / / github . com / Cyan4973 / FiniteStateEntropy <nl> + - Public forum : https : / / groups . google . com / forum / # ! forum / lz4c <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Dependencies <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # include " mem . h " <nl> + # include " error_private . h " / * ERR_ * , ERROR * / <nl> + # define FSE_STATIC_LINKING_ONLY / * FSE_MIN_TABLELOG * / <nl> + # include " fse . h " <nl> + # define HUF_STATIC_LINKING_ONLY / * HUF_TABLELOG_ABSOLUTEMAX * / <nl> + # include " huf . h " <nl> + <nl> + <nl> + / * = = = Version = = = * / <nl> + unsigned FSE_versionNumber ( void ) { return FSE_VERSION_NUMBER ; } <nl> + <nl> + <nl> + / * = = = Error Management = = = * / <nl> + unsigned FSE_isError ( size_t code ) { return ERR_isError ( code ) ; } <nl> + const char * FSE_getErrorName ( size_t code ) { return ERR_getErrorName ( code ) ; } <nl> + <nl> + unsigned HUF_isError ( size_t code ) { return ERR_isError ( code ) ; } <nl> + const char * HUF_getErrorName ( size_t code ) { return ERR_getErrorName ( code ) ; } <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * FSE NCount encoding - decoding <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + size_t FSE_readNCount ( short * normalizedCounter , unsigned * maxSVPtr , unsigned * tableLogPtr , <nl> + const void * headerBuffer , size_t hbSize ) <nl> + { <nl> + const BYTE * const istart = ( const BYTE * ) headerBuffer ; <nl> + const BYTE * const iend = istart + hbSize ; <nl> + const BYTE * ip = istart ; <nl> + int nbBits ; <nl> + int remaining ; <nl> + int threshold ; <nl> + U32 bitStream ; <nl> + int bitCount ; <nl> + unsigned charnum = 0 ; <nl> + int previous0 = 0 ; <nl> + <nl> + if ( hbSize < 4 ) return ERROR ( srcSize_wrong ) ; <nl> + bitStream = MEM_readLE32 ( ip ) ; <nl> + nbBits = ( bitStream & 0xF ) + FSE_MIN_TABLELOG ; / * extract tableLog * / <nl> + if ( nbBits > FSE_TABLELOG_ABSOLUTE_MAX ) return ERROR ( tableLog_tooLarge ) ; <nl> + bitStream > > = 4 ; <nl> + bitCount = 4 ; <nl> + * tableLogPtr = nbBits ; <nl> + remaining = ( 1 < < nbBits ) + 1 ; <nl> + threshold = 1 < < nbBits ; <nl> + nbBits + + ; <nl> + <nl> + while ( ( remaining > 1 ) & ( charnum < = * maxSVPtr ) ) { <nl> + if ( previous0 ) { <nl> + unsigned n0 = charnum ; <nl> + while ( ( bitStream & 0xFFFF ) = = 0xFFFF ) { <nl> + n0 + = 24 ; <nl> + if ( ip < iend - 5 ) { <nl> + ip + = 2 ; <nl> + bitStream = MEM_readLE32 ( ip ) > > bitCount ; <nl> + } else { <nl> + bitStream > > = 16 ; <nl> + bitCount + = 16 ; <nl> + } } <nl> + while ( ( bitStream & 3 ) = = 3 ) { <nl> + n0 + = 3 ; <nl> + bitStream > > = 2 ; <nl> + bitCount + = 2 ; <nl> + } <nl> + n0 + = bitStream & 3 ; <nl> + bitCount + = 2 ; <nl> + if ( n0 > * maxSVPtr ) return ERROR ( maxSymbolValue_tooSmall ) ; <nl> + while ( charnum < n0 ) normalizedCounter [ charnum + + ] = 0 ; <nl> + if ( ( ip < = iend - 7 ) | | ( ip + ( bitCount > > 3 ) < = iend - 4 ) ) { <nl> + ip + = bitCount > > 3 ; <nl> + bitCount & = 7 ; <nl> + bitStream = MEM_readLE32 ( ip ) > > bitCount ; <nl> + } else { <nl> + bitStream > > = 2 ; <nl> + } } <nl> + { int const max = ( 2 * threshold - 1 ) - remaining ; <nl> + int count ; <nl> + <nl> + if ( ( bitStream & ( threshold - 1 ) ) < ( U32 ) max ) { <nl> + count = bitStream & ( threshold - 1 ) ; <nl> + bitCount + = nbBits - 1 ; <nl> + } else { <nl> + count = bitStream & ( 2 * threshold - 1 ) ; <nl> + if ( count > = threshold ) count - = max ; <nl> + bitCount + = nbBits ; <nl> + } <nl> + <nl> + count - - ; / * extra accuracy * / <nl> + remaining - = count < 0 ? - count : count ; / * - 1 means + 1 * / <nl> + normalizedCounter [ charnum + + ] = ( short ) count ; <nl> + previous0 = ! count ; <nl> + while ( remaining < threshold ) { <nl> + nbBits - - ; <nl> + threshold > > = 1 ; <nl> + } <nl> + <nl> + if ( ( ip < = iend - 7 ) | | ( ip + ( bitCount > > 3 ) < = iend - 4 ) ) { <nl> + ip + = bitCount > > 3 ; <nl> + bitCount & = 7 ; <nl> + } else { <nl> + bitCount - = ( int ) ( 8 * ( iend - 4 - ip ) ) ; <nl> + ip = iend - 4 ; <nl> + } <nl> + bitStream = MEM_readLE32 ( ip ) > > ( bitCount & 31 ) ; <nl> + } } / * while ( ( remaining > 1 ) & ( charnum < = * maxSVPtr ) ) * / <nl> + if ( remaining ! = 1 ) return ERROR ( corruption_detected ) ; <nl> + if ( bitCount > 32 ) return ERROR ( corruption_detected ) ; <nl> + * maxSVPtr = charnum - 1 ; <nl> + <nl> + ip + = ( bitCount + 7 ) > > 3 ; <nl> + return ip - istart ; <nl> + } <nl> + <nl> + <nl> + / * ! HUF_readStats ( ) : <nl> + Read compact Huffman tree , saved by HUF_writeCTable ( ) . <nl> + ` huffWeight ` is destination buffer . <nl> + ` rankStats ` is assumed to be a table of at least HUF_TABLELOG_MAX U32 . <nl> + @ return : size read from ` src ` , or an error Code . <nl> + Note : Needed by HUF_readCTable ( ) and HUF_readDTableX ? ( ) . <nl> + * / <nl> + size_t HUF_readStats ( BYTE * huffWeight , size_t hwSize , U32 * rankStats , <nl> + U32 * nbSymbolsPtr , U32 * tableLogPtr , <nl> + const void * src , size_t srcSize ) <nl> + { <nl> + U32 weightTotal ; <nl> + const BYTE * ip = ( const BYTE * ) src ; <nl> + size_t iSize ; <nl> + size_t oSize ; <nl> + <nl> + if ( ! srcSize ) return ERROR ( srcSize_wrong ) ; <nl> + iSize = ip [ 0 ] ; <nl> + / * memset ( huffWeight , 0 , hwSize ) ; * / / * is not necessary , even though some analyzer complain . . . * / <nl> + <nl> + if ( iSize > = 128 ) { / * special header * / <nl> + oSize = iSize - 127 ; <nl> + iSize = ( ( oSize + 1 ) / 2 ) ; <nl> + if ( iSize + 1 > srcSize ) return ERROR ( srcSize_wrong ) ; <nl> + if ( oSize > = hwSize ) return ERROR ( corruption_detected ) ; <nl> + ip + = 1 ; <nl> + { U32 n ; <nl> + for ( n = 0 ; n < oSize ; n + = 2 ) { <nl> + huffWeight [ n ] = ip [ n / 2 ] > > 4 ; <nl> + huffWeight [ n + 1 ] = ip [ n / 2 ] & 15 ; <nl> + } } } <nl> + else { / * header compressed with FSE ( normal case ) * / <nl> + FSE_DTable fseWorkspace [ FSE_DTABLE_SIZE_U32 ( 6 ) ] ; / * 6 is max possible tableLog for HUF header ( maybe even 5 , to be tested ) * / <nl> + if ( iSize + 1 > srcSize ) return ERROR ( srcSize_wrong ) ; <nl> + oSize = FSE_decompress_wksp ( huffWeight , hwSize - 1 , ip + 1 , iSize , fseWorkspace , 6 ) ; / * max ( hwSize - 1 ) values decoded , as last one is implied * / <nl> + if ( FSE_isError ( oSize ) ) return oSize ; <nl> + } <nl> + <nl> + / * collect weight stats * / <nl> + memset ( rankStats , 0 , ( HUF_TABLELOG_MAX + 1 ) * sizeof ( U32 ) ) ; <nl> + weightTotal = 0 ; <nl> + { U32 n ; for ( n = 0 ; n < oSize ; n + + ) { <nl> + if ( huffWeight [ n ] > = HUF_TABLELOG_MAX ) return ERROR ( corruption_detected ) ; <nl> + rankStats [ huffWeight [ n ] ] + + ; <nl> + weightTotal + = ( 1 < < huffWeight [ n ] ) > > 1 ; <nl> + } } <nl> + if ( weightTotal = = 0 ) return ERROR ( corruption_detected ) ; <nl> + <nl> + / * get last non - null symbol weight ( implied , total must be 2 ^ n ) * / <nl> + { U32 const tableLog = BIT_highbit32 ( weightTotal ) + 1 ; <nl> + if ( tableLog > HUF_TABLELOG_MAX ) return ERROR ( corruption_detected ) ; <nl> + * tableLogPtr = tableLog ; <nl> + / * determine last weight * / <nl> + { U32 const total = 1 < < tableLog ; <nl> + U32 const rest = total - weightTotal ; <nl> + U32 const verif = 1 < < BIT_highbit32 ( rest ) ; <nl> + U32 const lastWeight = BIT_highbit32 ( rest ) + 1 ; <nl> + if ( verif ! = rest ) return ERROR ( corruption_detected ) ; / * last value must be a clean power of 2 * / <nl> + huffWeight [ oSize ] = ( BYTE ) lastWeight ; <nl> + rankStats [ lastWeight ] + + ; <nl> + } } <nl> + <nl> + / * check tree construction validity * / <nl> + if ( ( rankStats [ 1 ] < 2 ) | | ( rankStats [ 1 ] & 1 ) ) return ERROR ( corruption_detected ) ; / * by construction : at least 2 elts of rank 1 , must be even * / <nl> + <nl> + / * results * / <nl> + * nbSymbolsPtr = ( U32 ) ( oSize + 1 ) ; <nl> + return iSize + 1 ; <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . b3287245f1e <nl> mmm / dev / null <nl> ppp b / thirdparty / zstd / common / error_private . c <nl> <nl> + / * * <nl> + * Copyright ( c ) 2016 - present , Yann Collet , Facebook , Inc . <nl> + * All rights reserved . <nl> + * <nl> + * This source code is licensed under the BSD - style license found in the <nl> + * LICENSE file in the root directory of this source tree . An additional grant <nl> + * of patent rights can be found in the PATENTS file in the same directory . <nl> + * / <nl> + <nl> + / * The purpose of this file is to have a single list of error strings embedded in binary * / <nl> + <nl> + # include " error_private . h " <nl> + <nl> + const char * ERR_getErrorString ( ERR_enum code ) <nl> + { <nl> + static const char * const notErrorCode = " Unspecified error code " ; <nl> + switch ( code ) <nl> + { <nl> + case PREFIX ( no_error ) : return " No error detected " ; <nl> + case PREFIX ( GENERIC ) : return " Error ( generic ) " ; <nl> + case PREFIX ( prefix_unknown ) : return " Unknown frame descriptor " ; <nl> + case PREFIX ( version_unsupported ) : return " Version not supported " ; <nl> + case PREFIX ( parameter_unknown ) : return " Unknown parameter type " ; <nl> + case PREFIX ( frameParameter_unsupported ) : return " Unsupported frame parameter " ; <nl> + case PREFIX ( frameParameter_unsupportedBy32bits ) : return " Frame parameter unsupported in 32 - bits mode " ; <nl> + case PREFIX ( frameParameter_windowTooLarge ) : return " Frame requires too much memory for decoding " ; <nl> + case PREFIX ( compressionParameter_unsupported ) : return " Compression parameter is out of bound " ; <nl> + case PREFIX ( init_missing ) : return " Context should be init first " ; <nl> + case PREFIX ( memory_allocation ) : return " Allocation error : not enough memory " ; <nl> + case PREFIX ( stage_wrong ) : return " Operation not authorized at current processing stage " ; <nl> + case PREFIX ( dstSize_tooSmall ) : return " Destination buffer is too small " ; <nl> + case PREFIX ( srcSize_wrong ) : return " Src size is incorrect " ; <nl> + case PREFIX ( corruption_detected ) : return " Corrupted block detected " ; <nl> + case PREFIX ( checksum_wrong ) : return " Restored data doesn ' t match checksum " ; <nl> + case PREFIX ( tableLog_tooLarge ) : return " tableLog requires too much memory : unsupported " ; <nl> + case PREFIX ( maxSymbolValue_tooLarge ) : return " Unsupported max Symbol Value : too large " ; <nl> + case PREFIX ( maxSymbolValue_tooSmall ) : return " Specified maxSymbolValue is too small " ; <nl> + case PREFIX ( dictionary_corrupted ) : return " Dictionary is corrupted " ; <nl> + case PREFIX ( dictionary_wrong ) : return " Dictionary mismatch " ; <nl> + case PREFIX ( dictionaryCreation_failed ) : return " Cannot create Dictionary from provided samples " ; <nl> + case PREFIX ( maxCode ) : <nl> + default : return notErrorCode ; <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 1bc2e495481 <nl> mmm / dev / null <nl> ppp b / thirdparty / zstd / common / error_private . h <nl> <nl> + / * * <nl> + * Copyright ( c ) 2016 - present , Yann Collet , Facebook , Inc . <nl> + * All rights reserved . <nl> + * <nl> + * This source code is licensed under the BSD - style license found in the <nl> + * LICENSE file in the root directory of this source tree . An additional grant <nl> + * of patent rights can be found in the PATENTS file in the same directory . <nl> + * / <nl> + <nl> + / * Note : this module is expected to remain private , do not expose it * / <nl> + <nl> + # ifndef ERROR_H_MODULE <nl> + # define ERROR_H_MODULE <nl> + <nl> + # if defined ( __cplusplus ) <nl> + extern " C " { <nl> + # endif <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Dependencies <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # include < stddef . h > / * size_t * / <nl> + # include " zstd_errors . h " / * enum list * / <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Compiler - specific <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # if defined ( __GNUC__ ) <nl> + # define ERR_STATIC static __attribute__ ( ( unused ) ) <nl> + # elif defined ( __cplusplus ) | | ( defined ( __STDC_VERSION__ ) & & ( __STDC_VERSION__ > = 199901L ) / * C99 * / ) <nl> + # define ERR_STATIC static inline <nl> + # elif defined ( _MSC_VER ) <nl> + # define ERR_STATIC static __inline <nl> + # else <nl> + # define ERR_STATIC static / * this version may generate warnings for unused static functions ; disable the relevant warning * / <nl> + # endif <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Customization ( error_public . h ) <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + typedef ZSTD_ErrorCode ERR_enum ; <nl> + # define PREFIX ( name ) ZSTD_error_ # # name <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Error codes handling <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # ifdef ERROR <nl> + # undef ERROR / * reported already defined on VS 2015 ( Rich Geldreich ) * / <nl> + # endif <nl> + # define ERROR ( name ) ( ( size_t ) - PREFIX ( name ) ) <nl> + <nl> + ERR_STATIC unsigned ERR_isError ( size_t code ) { return ( code > ERROR ( maxCode ) ) ; } <nl> + <nl> + ERR_STATIC ERR_enum ERR_getErrorCode ( size_t code ) { if ( ! ERR_isError ( code ) ) return ( ERR_enum ) 0 ; return ( ERR_enum ) ( 0 - code ) ; } <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Error Strings <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + const char * ERR_getErrorString ( ERR_enum code ) ; / * error_private . c * / <nl> + <nl> + ERR_STATIC const char * ERR_getErrorName ( size_t code ) <nl> + { <nl> + return ERR_getErrorString ( ERR_getErrorCode ( code ) ) ; <nl> + } <nl> + <nl> + # if defined ( __cplusplus ) <nl> + } <nl> + # endif <nl> + <nl> + # endif / * ERROR_H_MODULE * / <nl> new file mode 100644 <nl> index 00000000000 . . 6d5d41def19 <nl> mmm / dev / null <nl> ppp b / thirdparty / zstd / common / fse . h <nl> <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + FSE : Finite State Entropy codec <nl> + Public Prototypes declaration <nl> + Copyright ( C ) 2013 - 2016 , Yann Collet . <nl> + <nl> + BSD 2 - Clause License ( http : / / www . opensource . org / licenses / bsd - license . php ) <nl> + <nl> + Redistribution and use in source and binary forms , with or without <nl> + modification , are permitted provided that the following conditions are <nl> + met : <nl> + <nl> + * Redistributions of source code must retain the above copyright <nl> + notice , this list of conditions and the following disclaimer . <nl> + * Redistributions in binary form must reproduce the above <nl> + copyright notice , this list of conditions and the following disclaimer <nl> + in the documentation and / or other materials provided with the <nl> + distribution . <nl> + <nl> + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + <nl> + You can contact the author at : <nl> + - Source repository : https : / / github . com / Cyan4973 / FiniteStateEntropy <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # ifndef FSE_H <nl> + # define FSE_H <nl> + <nl> + # if defined ( __cplusplus ) <nl> + extern " C " { <nl> + # endif <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Dependencies <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # include < stddef . h > / * size_t , ptrdiff_t * / <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * FSE_PUBLIC_API : control library symbols visibility <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # if defined ( FSE_DLL_EXPORT ) & & ( FSE_DLL_EXPORT = = 1 ) & & defined ( __GNUC__ ) & & ( __GNUC__ > = 4 ) <nl> + # define FSE_PUBLIC_API __attribute__ ( ( visibility ( " default " ) ) ) <nl> + # elif defined ( FSE_DLL_EXPORT ) & & ( FSE_DLL_EXPORT = = 1 ) / * Visual expected * / <nl> + # define FSE_PUBLIC_API __declspec ( dllexport ) <nl> + # elif defined ( FSE_DLL_IMPORT ) & & ( FSE_DLL_IMPORT = = 1 ) <nl> + # define FSE_PUBLIC_API __declspec ( dllimport ) / * It isn ' t required but allows to generate better code , saving a function pointer load from the IAT and an indirect jump . * / <nl> + # else <nl> + # define FSE_PUBLIC_API <nl> + # endif <nl> + <nl> + / * mmmmmm Version mmmmmm * / <nl> + # define FSE_VERSION_MAJOR 0 <nl> + # define FSE_VERSION_MINOR 9 <nl> + # define FSE_VERSION_RELEASE 0 <nl> + <nl> + # define FSE_LIB_VERSION FSE_VERSION_MAJOR . FSE_VERSION_MINOR . FSE_VERSION_RELEASE <nl> + # define FSE_QUOTE ( str ) # str <nl> + # define FSE_EXPAND_AND_QUOTE ( str ) FSE_QUOTE ( str ) <nl> + # define FSE_VERSION_STRING FSE_EXPAND_AND_QUOTE ( FSE_LIB_VERSION ) <nl> + <nl> + # define FSE_VERSION_NUMBER ( FSE_VERSION_MAJOR * 100 * 100 + FSE_VERSION_MINOR * 100 + FSE_VERSION_RELEASE ) <nl> + FSE_PUBLIC_API unsigned FSE_versionNumber ( void ) ; / * * < library version number ; to be used when checking dll version * / <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * FSE simple functions <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * ! FSE_compress ( ) : <nl> + Compress content of buffer ' src ' , of size ' srcSize ' , into destination buffer ' dst ' . <nl> + ' dst ' buffer must be already allocated . Compression runs faster is dstCapacity > = FSE_compressBound ( srcSize ) . <nl> + @ return : size of compressed data ( < = dstCapacity ) . <nl> + Special values : if return = = 0 , srcData is not compressible = > Nothing is stored within dst ! ! ! <nl> + if return = = 1 , srcData is a single byte symbol * srcSize times . Use RLE compression instead . <nl> + if FSE_isError ( return ) , compression failed ( more details using FSE_getErrorName ( ) ) <nl> + * / <nl> + FSE_PUBLIC_API size_t FSE_compress ( void * dst , size_t dstCapacity , <nl> + const void * src , size_t srcSize ) ; <nl> + <nl> + / * ! FSE_decompress ( ) : <nl> + Decompress FSE data from buffer ' cSrc ' , of size ' cSrcSize ' , <nl> + into already allocated destination buffer ' dst ' , of size ' dstCapacity ' . <nl> + @ return : size of regenerated data ( < = maxDstSize ) , <nl> + or an error code , which can be tested using FSE_isError ( ) . <nl> + <nl> + * * Important * * : FSE_decompress ( ) does not decompress non - compressible nor RLE data ! ! ! <nl> + Why ? : making this distinction requires a header . <nl> + Header management is intentionally delegated to the user layer , which can better manage special cases . <nl> + * / <nl> + FSE_PUBLIC_API size_t FSE_decompress ( void * dst , size_t dstCapacity , <nl> + const void * cSrc , size_t cSrcSize ) ; <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Tool functions <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + FSE_PUBLIC_API size_t FSE_compressBound ( size_t size ) ; / * maximum compressed size * / <nl> + <nl> + / * Error Management * / <nl> + FSE_PUBLIC_API unsigned FSE_isError ( size_t code ) ; / * tells if a return value is an error code * / <nl> + FSE_PUBLIC_API const char * FSE_getErrorName ( size_t code ) ; / * provides error code string ( useful for debugging ) * / <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * FSE advanced functions <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * ! FSE_compress2 ( ) : <nl> + Same as FSE_compress ( ) , but allows the selection of ' maxSymbolValue ' and ' tableLog ' <nl> + Both parameters can be defined as ' 0 ' to mean : use default value <nl> + @ return : size of compressed data <nl> + Special values : if return = = 0 , srcData is not compressible = > Nothing is stored within cSrc ! ! ! <nl> + if return = = 1 , srcData is a single byte symbol * srcSize times . Use RLE compression . <nl> + if FSE_isError ( return ) , it ' s an error code . <nl> + * / <nl> + FSE_PUBLIC_API size_t FSE_compress2 ( void * dst , size_t dstSize , const void * src , size_t srcSize , unsigned maxSymbolValue , unsigned tableLog ) ; <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * FSE detailed API <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * ! <nl> + FSE_compress ( ) does the following : <nl> + 1 . count symbol occurrence from source [ ] into table count [ ] <nl> + 2 . normalize counters so that sum ( count [ ] ) = = Power_of_2 ( 2 ^ tableLog ) <nl> + 3 . save normalized counters to memory buffer using writeNCount ( ) <nl> + 4 . build encoding table ' CTable ' from normalized counters <nl> + 5 . encode the data stream using encoding table ' CTable ' <nl> + <nl> + FSE_decompress ( ) does the following : <nl> + 1 . read normalized counters with readNCount ( ) <nl> + 2 . build decoding table ' DTable ' from normalized counters <nl> + 3 . decode the data stream using decoding table ' DTable ' <nl> + <nl> + The following API allows targeting specific sub - functions for advanced tasks . <nl> + For example , it ' s possible to compress several blocks using the same ' CTable ' , <nl> + or to save and provide normalized distribution using external method . <nl> + * / <nl> + <nl> + / * * * * COMPRESSION * * * * / <nl> + <nl> + / * ! FSE_count ( ) : <nl> + Provides the precise count of each byte within a table ' count ' . <nl> + ' count ' is a table of unsigned int , of minimum size ( * maxSymbolValuePtr + 1 ) . <nl> + * maxSymbolValuePtr will be updated if detected smaller than initial value . <nl> + @ return : the count of the most frequent symbol ( which is not identified ) . <nl> + if return = = srcSize , there is only one symbol . <nl> + Can also return an error code , which can be tested with FSE_isError ( ) . * / <nl> + FSE_PUBLIC_API size_t FSE_count ( unsigned * count , unsigned * maxSymbolValuePtr , const void * src , size_t srcSize ) ; <nl> + <nl> + / * ! FSE_optimalTableLog ( ) : <nl> + dynamically downsize ' tableLog ' when conditions are met . <nl> + It saves CPU time , by using smaller tables , while preserving or even improving compression ratio . <nl> + @ return : recommended tableLog ( necessarily < = ' maxTableLog ' ) * / <nl> + FSE_PUBLIC_API unsigned FSE_optimalTableLog ( unsigned maxTableLog , size_t srcSize , unsigned maxSymbolValue ) ; <nl> + <nl> + / * ! FSE_normalizeCount ( ) : <nl> + normalize counts so that sum ( count [ ] ) = = Power_of_2 ( 2 ^ tableLog ) <nl> + ' normalizedCounter ' is a table of short , of minimum size ( maxSymbolValue + 1 ) . <nl> + @ return : tableLog , <nl> + or an errorCode , which can be tested using FSE_isError ( ) * / <nl> + FSE_PUBLIC_API size_t FSE_normalizeCount ( short * normalizedCounter , unsigned tableLog , const unsigned * count , size_t srcSize , unsigned maxSymbolValue ) ; <nl> + <nl> + / * ! FSE_NCountWriteBound ( ) : <nl> + Provides the maximum possible size of an FSE normalized table , given ' maxSymbolValue ' and ' tableLog ' . <nl> + Typically useful for allocation purpose . * / <nl> + FSE_PUBLIC_API size_t FSE_NCountWriteBound ( unsigned maxSymbolValue , unsigned tableLog ) ; <nl> + <nl> + / * ! FSE_writeNCount ( ) : <nl> + Compactly save ' normalizedCounter ' into ' buffer ' . <nl> + @ return : size of the compressed table , <nl> + or an errorCode , which can be tested using FSE_isError ( ) . * / <nl> + FSE_PUBLIC_API size_t FSE_writeNCount ( void * buffer , size_t bufferSize , const short * normalizedCounter , unsigned maxSymbolValue , unsigned tableLog ) ; <nl> + <nl> + <nl> + / * ! Constructor and Destructor of FSE_CTable . <nl> + Note that FSE_CTable size depends on ' tableLog ' and ' maxSymbolValue ' * / <nl> + typedef unsigned FSE_CTable ; / * don ' t allocate that . It ' s only meant to be more restrictive than void * * / <nl> + FSE_PUBLIC_API FSE_CTable * FSE_createCTable ( unsigned tableLog , unsigned maxSymbolValue ) ; <nl> + FSE_PUBLIC_API void FSE_freeCTable ( FSE_CTable * ct ) ; <nl> + <nl> + / * ! FSE_buildCTable ( ) : <nl> + Builds ` ct ` , which must be already allocated , using FSE_createCTable ( ) . <nl> + @ return : 0 , or an errorCode , which can be tested using FSE_isError ( ) * / <nl> + FSE_PUBLIC_API size_t FSE_buildCTable ( FSE_CTable * ct , const short * normalizedCounter , unsigned maxSymbolValue , unsigned tableLog ) ; <nl> + <nl> + / * ! FSE_compress_usingCTable ( ) : <nl> + Compress ` src ` using ` ct ` into ` dst ` which must be already allocated . <nl> + @ return : size of compressed data ( < = ` dstCapacity ` ) , <nl> + or 0 if compressed data could not fit into ` dst ` , <nl> + or an errorCode , which can be tested using FSE_isError ( ) * / <nl> + FSE_PUBLIC_API size_t FSE_compress_usingCTable ( void * dst , size_t dstCapacity , const void * src , size_t srcSize , const FSE_CTable * ct ) ; <nl> + <nl> + / * ! <nl> + Tutorial : <nl> + mmmmmmmmm - <nl> + The first step is to count all symbols . FSE_count ( ) does this job very fast . <nl> + Result will be saved into ' count ' , a table of unsigned int , which must be already allocated , and have ' maxSymbolValuePtr [ 0 ] + 1 ' cells . <nl> + ' src ' is a table of bytes of size ' srcSize ' . All values within ' src ' MUST be < = maxSymbolValuePtr [ 0 ] <nl> + maxSymbolValuePtr [ 0 ] will be updated , with its real value ( necessarily < = original value ) <nl> + FSE_count ( ) will return the number of occurrence of the most frequent symbol . <nl> + This can be used to know if there is a single symbol within ' src ' , and to quickly evaluate its compressibility . <nl> + If there is an error , the function will return an ErrorCode ( which can be tested using FSE_isError ( ) ) . <nl> + <nl> + The next step is to normalize the frequencies . <nl> + FSE_normalizeCount ( ) will ensure that sum of frequencies is = = 2 ^ ' tableLog ' . <nl> + It also guarantees a minimum of 1 to any Symbol with frequency > = 1 . <nl> + You can use ' tableLog ' = = 0 to mean " use default tableLog value " . <nl> + If you are unsure of which tableLog value to use , you can ask FSE_optimalTableLog ( ) , <nl> + which will provide the optimal valid tableLog given sourceSize , maxSymbolValue , and a user - defined maximum ( 0 means " default " ) . <nl> + <nl> + The result of FSE_normalizeCount ( ) will be saved into a table , <nl> + called ' normalizedCounter ' , which is a table of signed short . <nl> + ' normalizedCounter ' must be already allocated , and have at least ' maxSymbolValue + 1 ' cells . <nl> + The return value is tableLog if everything proceeded as expected . <nl> + It is 0 if there is a single symbol within distribution . <nl> + If there is an error ( ex : invalid tableLog value ) , the function will return an ErrorCode ( which can be tested using FSE_isError ( ) ) . <nl> + <nl> + ' normalizedCounter ' can be saved in a compact manner to a memory area using FSE_writeNCount ( ) . <nl> + ' buffer ' must be already allocated . <nl> + For guaranteed success , buffer size must be at least FSE_headerBound ( ) . <nl> + The result of the function is the number of bytes written into ' buffer ' . <nl> + If there is an error , the function will return an ErrorCode ( which can be tested using FSE_isError ( ) ; ex : buffer size too small ) . <nl> + <nl> + ' normalizedCounter ' can then be used to create the compression table ' CTable ' . <nl> + The space required by ' CTable ' must be already allocated , using FSE_createCTable ( ) . <nl> + You can then use FSE_buildCTable ( ) to fill ' CTable ' . <nl> + If there is an error , both functions will return an ErrorCode ( which can be tested using FSE_isError ( ) ) . <nl> + <nl> + ' CTable ' can then be used to compress ' src ' , with FSE_compress_usingCTable ( ) . <nl> + Similar to FSE_count ( ) , the convention is that ' src ' is assumed to be a table of char of size ' srcSize ' <nl> + The function returns the size of compressed data ( without header ) , necessarily < = ` dstCapacity ` . <nl> + If it returns ' 0 ' , compressed data could not fit into ' dst ' . <nl> + If there is an error , the function will return an ErrorCode ( which can be tested using FSE_isError ( ) ) . <nl> + * / <nl> + <nl> + <nl> + / * * * * DECOMPRESSION * * * * / <nl> + <nl> + / * ! FSE_readNCount ( ) : <nl> + Read compactly saved ' normalizedCounter ' from ' rBuffer ' . <nl> + @ return : size read from ' rBuffer ' , <nl> + or an errorCode , which can be tested using FSE_isError ( ) . <nl> + maxSymbolValuePtr [ 0 ] and tableLogPtr [ 0 ] will also be updated with their respective values * / <nl> + FSE_PUBLIC_API size_t FSE_readNCount ( short * normalizedCounter , unsigned * maxSymbolValuePtr , unsigned * tableLogPtr , const void * rBuffer , size_t rBuffSize ) ; <nl> + <nl> + / * ! Constructor and Destructor of FSE_DTable . <nl> + Note that its size depends on ' tableLog ' * / <nl> + typedef unsigned FSE_DTable ; / * don ' t allocate that . It ' s just a way to be more restrictive than void * * / <nl> + FSE_PUBLIC_API FSE_DTable * FSE_createDTable ( unsigned tableLog ) ; <nl> + FSE_PUBLIC_API void FSE_freeDTable ( FSE_DTable * dt ) ; <nl> + <nl> + / * ! FSE_buildDTable ( ) : <nl> + Builds ' dt ' , which must be already allocated , using FSE_createDTable ( ) . <nl> + return : 0 , or an errorCode , which can be tested using FSE_isError ( ) * / <nl> + FSE_PUBLIC_API size_t FSE_buildDTable ( FSE_DTable * dt , const short * normalizedCounter , unsigned maxSymbolValue , unsigned tableLog ) ; <nl> + <nl> + / * ! FSE_decompress_usingDTable ( ) : <nl> + Decompress compressed source ` cSrc ` of size ` cSrcSize ` using ` dt ` <nl> + into ` dst ` which must be already allocated . <nl> + @ return : size of regenerated data ( necessarily < = ` dstCapacity ` ) , <nl> + or an errorCode , which can be tested using FSE_isError ( ) * / <nl> + FSE_PUBLIC_API size_t FSE_decompress_usingDTable ( void * dst , size_t dstCapacity , const void * cSrc , size_t cSrcSize , const FSE_DTable * dt ) ; <nl> + <nl> + / * ! <nl> + Tutorial : <nl> + mmmmmmmmm - <nl> + ( Note : these functions only decompress FSE - compressed blocks . <nl> + If block is uncompressed , use memcpy ( ) instead <nl> + If block is a single repeated byte , use memset ( ) instead ) <nl> + <nl> + The first step is to obtain the normalized frequencies of symbols . <nl> + This can be performed by FSE_readNCount ( ) if it was saved using FSE_writeNCount ( ) . <nl> + ' normalizedCounter ' must be already allocated , and have at least ' maxSymbolValuePtr [ 0 ] + 1 ' cells of signed short . <nl> + In practice , that means it ' s necessary to know ' maxSymbolValue ' beforehand , <nl> + or size the table to handle worst case situations ( typically 256 ) . <nl> + FSE_readNCount ( ) will provide ' tableLog ' and ' maxSymbolValue ' . <nl> + The result of FSE_readNCount ( ) is the number of bytes read from ' rBuffer ' . <nl> + Note that ' rBufferSize ' must be at least 4 bytes , even if useful information is less than that . <nl> + If there is an error , the function will return an error code , which can be tested using FSE_isError ( ) . <nl> + <nl> + The next step is to build the decompression tables ' FSE_DTable ' from ' normalizedCounter ' . <nl> + This is performed by the function FSE_buildDTable ( ) . <nl> + The space required by ' FSE_DTable ' must be already allocated using FSE_createDTable ( ) . <nl> + If there is an error , the function will return an error code , which can be tested using FSE_isError ( ) . <nl> + <nl> + ` FSE_DTable ` can then be used to decompress ` cSrc ` , with FSE_decompress_usingDTable ( ) . <nl> + ` cSrcSize ` must be strictly correct , otherwise decompression will fail . <nl> + FSE_decompress_usingDTable ( ) result will tell how many bytes were regenerated ( < = ` dstCapacity ` ) . <nl> + If there is an error , the function will return an error code , which can be tested using FSE_isError ( ) . ( ex : dst buffer too small ) <nl> + * / <nl> + <nl> + <nl> + # ifdef FSE_STATIC_LINKING_ONLY <nl> + <nl> + / * * * * Dependency * * * * / <nl> + # include " bitstream . h " <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Static allocation <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * FSE buffer bounds * / <nl> + # define FSE_NCOUNTBOUND 512 <nl> + # define FSE_BLOCKBOUND ( size ) ( size + ( size > > 7 ) ) <nl> + # define FSE_COMPRESSBOUND ( size ) ( FSE_NCOUNTBOUND + FSE_BLOCKBOUND ( size ) ) / * Macro version , useful for static allocation * / <nl> + <nl> + / * It is possible to statically allocate FSE CTable / DTable as a table of FSE_CTable / FSE_DTable using below macros * / <nl> + # define FSE_CTABLE_SIZE_U32 ( maxTableLog , maxSymbolValue ) ( 1 + ( 1 < < ( maxTableLog - 1 ) ) + ( ( maxSymbolValue + 1 ) * 2 ) ) <nl> + # define FSE_DTABLE_SIZE_U32 ( maxTableLog ) ( 1 + ( 1 < < maxTableLog ) ) <nl> + <nl> + / * or use the size to malloc ( ) space directly . Pay attention to alignment restrictions though * / <nl> + # define FSE_CTABLE_SIZE ( maxTableLog , maxSymbolValue ) ( FSE_CTABLE_SIZE_U32 ( maxTableLog , maxSymbolValue ) * sizeof ( FSE_CTable ) ) <nl> + # define FSE_DTABLE_SIZE ( maxTableLog ) ( FSE_DTABLE_SIZE_U32 ( maxTableLog ) * sizeof ( FSE_DTable ) ) <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * FSE advanced API <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * FSE_count_wksp ( ) : <nl> + * Same as FSE_count ( ) , but using an externally provided scratch buffer . <nl> + * ` workSpace ` size must be table of > = ` 1024 ` unsigned <nl> + * / <nl> + size_t FSE_count_wksp ( unsigned * count , unsigned * maxSymbolValuePtr , <nl> + const void * source , size_t sourceSize , unsigned * workSpace ) ; <nl> + <nl> + / * * FSE_countFast ( ) : <nl> + * same as FSE_count ( ) , but blindly trusts that all byte values within src are < = * maxSymbolValuePtr <nl> + * / <nl> + size_t FSE_countFast ( unsigned * count , unsigned * maxSymbolValuePtr , const void * src , size_t srcSize ) ; <nl> + <nl> + / * FSE_countFast_wksp ( ) : <nl> + * Same as FSE_countFast ( ) , but using an externally provided scratch buffer . <nl> + * ` workSpace ` must be a table of minimum ` 1024 ` unsigned <nl> + * / <nl> + size_t FSE_countFast_wksp ( unsigned * count , unsigned * maxSymbolValuePtr , const void * src , size_t srcSize , unsigned * workSpace ) ; <nl> + <nl> + / * ! FSE_count_simple <nl> + * Same as FSE_countFast ( ) , but does not use any additional memory ( not even on stack ) . <nl> + * This function is unsafe , and will segfault if any value within ` src ` is ` > * maxSymbolValuePtr ` ( presuming it ' s also the size of ` count ` ) . <nl> + * / <nl> + size_t FSE_count_simple ( unsigned * count , unsigned * maxSymbolValuePtr , const void * src , size_t srcSize ) ; <nl> + <nl> + <nl> + <nl> + unsigned FSE_optimalTableLog_internal ( unsigned maxTableLog , size_t srcSize , unsigned maxSymbolValue , unsigned minus ) ; <nl> + / * * < same as FSE_optimalTableLog ( ) , which used ` minus = = 2 ` * / <nl> + <nl> + / * FSE_compress_wksp ( ) : <nl> + * Same as FSE_compress2 ( ) , but using an externally allocated scratch buffer ( ` workSpace ` ) . <nl> + * FSE_WKSP_SIZE_U32 ( ) provides the minimum size required for ` workSpace ` as a table of FSE_CTable . <nl> + * / <nl> + # define FSE_WKSP_SIZE_U32 ( maxTableLog , maxSymbolValue ) ( FSE_CTABLE_SIZE_U32 ( maxTableLog , maxSymbolValue ) + ( ( maxTableLog > 12 ) ? ( 1 < < ( maxTableLog - 2 ) ) : 1024 ) ) <nl> + size_t FSE_compress_wksp ( void * dst , size_t dstSize , const void * src , size_t srcSize , unsigned maxSymbolValue , unsigned tableLog , void * workSpace , size_t wkspSize ) ; <nl> + <nl> + size_t FSE_buildCTable_raw ( FSE_CTable * ct , unsigned nbBits ) ; <nl> + / * * < build a fake FSE_CTable , designed for a flat distribution , where each symbol uses nbBits * / <nl> + <nl> + size_t FSE_buildCTable_rle ( FSE_CTable * ct , unsigned char symbolValue ) ; <nl> + / * * < build a fake FSE_CTable , designed to compress always the same symbolValue * / <nl> + <nl> + / * FSE_buildCTable_wksp ( ) : <nl> + * Same as FSE_buildCTable ( ) , but using an externally allocated scratch buffer ( ` workSpace ` ) . <nl> + * ` wkspSize ` must be > = ` ( 1 < < tableLog ) ` . <nl> + * / <nl> + size_t FSE_buildCTable_wksp ( FSE_CTable * ct , const short * normalizedCounter , unsigned maxSymbolValue , unsigned tableLog , void * workSpace , size_t wkspSize ) ; <nl> + <nl> + size_t FSE_buildDTable_raw ( FSE_DTable * dt , unsigned nbBits ) ; <nl> + / * * < build a fake FSE_DTable , designed to read a flat distribution where each symbol uses nbBits * / <nl> + <nl> + size_t FSE_buildDTable_rle ( FSE_DTable * dt , unsigned char symbolValue ) ; <nl> + / * * < build a fake FSE_DTable , designed to always generate the same symbolValue * / <nl> + <nl> + size_t FSE_decompress_wksp ( void * dst , size_t dstCapacity , const void * cSrc , size_t cSrcSize , FSE_DTable * workSpace , unsigned maxLog ) ; <nl> + / * * < same as FSE_decompress ( ) , using an externally allocated ` workSpace ` produced with ` FSE_DTABLE_SIZE_U32 ( maxLog ) ` * / <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * FSE symbol compression API <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * ! <nl> + This API consists of small unitary functions , which highly benefit from being inlined . <nl> + Hence their body are included in next section . <nl> + * / <nl> + typedef struct { <nl> + ptrdiff_t value ; <nl> + const void * stateTable ; <nl> + const void * symbolTT ; <nl> + unsigned stateLog ; <nl> + } FSE_CState_t ; <nl> + <nl> + static void FSE_initCState ( FSE_CState_t * CStatePtr , const FSE_CTable * ct ) ; <nl> + <nl> + static void FSE_encodeSymbol ( BIT_CStream_t * bitC , FSE_CState_t * CStatePtr , unsigned symbol ) ; <nl> + <nl> + static void FSE_flushCState ( BIT_CStream_t * bitC , const FSE_CState_t * CStatePtr ) ; <nl> + <nl> + / * * < <nl> + These functions are inner components of FSE_compress_usingCTable ( ) . <nl> + They allow the creation of custom streams , mixing multiple tables and bit sources . <nl> + <nl> + A key property to keep in mind is that encoding and decoding are done * * in reverse direction * * . <nl> + So the first symbol you will encode is the last you will decode , like a LIFO stack . <nl> + <nl> + You will need a few variables to track your CStream . They are : <nl> + <nl> + FSE_CTable ct ; / / Provided by FSE_buildCTable ( ) <nl> + BIT_CStream_t bitStream ; / / bitStream tracking structure <nl> + FSE_CState_t state ; / / State tracking structure ( can have several ) <nl> + <nl> + <nl> + The first thing to do is to init bitStream and state . <nl> + size_t errorCode = BIT_initCStream ( & bitStream , dstBuffer , maxDstSize ) ; <nl> + FSE_initCState ( & state , ct ) ; <nl> + <nl> + Note that BIT_initCStream ( ) can produce an error code , so its result should be tested , using FSE_isError ( ) ; <nl> + You can then encode your input data , byte after byte . <nl> + FSE_encodeSymbol ( ) outputs a maximum of ' tableLog ' bits at a time . <nl> + Remember decoding will be done in reverse direction . <nl> + FSE_encodeByte ( & bitStream , & state , symbol ) ; <nl> + <nl> + At any time , you can also add any bit sequence . <nl> + Note : maximum allowed nbBits is 25 , for compatibility with 32 - bits decoders <nl> + BIT_addBits ( & bitStream , bitField , nbBits ) ; <nl> + <nl> + The above methods don ' t commit data to memory , they just store it into local register , for speed . <nl> + Local register size is 64 - bits on 64 - bits systems , 32 - bits on 32 - bits systems ( size_t ) . <nl> + Writing data to memory is a manual operation , performed by the flushBits function . <nl> + BIT_flushBits ( & bitStream ) ; <nl> + <nl> + Your last FSE encoding operation shall be to flush your last state value ( s ) . <nl> + FSE_flushState ( & bitStream , & state ) ; <nl> + <nl> + Finally , you must close the bitStream . <nl> + The function returns the size of CStream in bytes . <nl> + If data couldn ' t fit into dstBuffer , it will return a 0 ( = = not compressible ) <nl> + If there is an error , it returns an errorCode ( which can be tested using FSE_isError ( ) ) . <nl> + size_t size = BIT_closeCStream ( & bitStream ) ; <nl> + * / <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * FSE symbol decompression API <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + typedef struct { <nl> + size_t state ; <nl> + const void * table ; / * precise table may vary , depending on U16 * / <nl> + } FSE_DState_t ; <nl> + <nl> + <nl> + static void FSE_initDState ( FSE_DState_t * DStatePtr , BIT_DStream_t * bitD , const FSE_DTable * dt ) ; <nl> + <nl> + static unsigned char FSE_decodeSymbol ( FSE_DState_t * DStatePtr , BIT_DStream_t * bitD ) ; <nl> + <nl> + static unsigned FSE_endOfDState ( const FSE_DState_t * DStatePtr ) ; <nl> + <nl> + / * * < <nl> + Let ' s now decompose FSE_decompress_usingDTable ( ) into its unitary components . <nl> + You will decode FSE - encoded symbols from the bitStream , <nl> + and also any other bitFields you put in , * * in reverse order * * . <nl> + <nl> + You will need a few variables to track your bitStream . They are : <nl> + <nl> + BIT_DStream_t DStream ; / / Stream context <nl> + FSE_DState_t DState ; / / State context . Multiple ones are possible <nl> + FSE_DTable * DTablePtr ; / / Decoding table , provided by FSE_buildDTable ( ) <nl> + <nl> + The first thing to do is to init the bitStream . <nl> + errorCode = BIT_initDStream ( & DStream , srcBuffer , srcSize ) ; <nl> + <nl> + You should then retrieve your initial state ( s ) <nl> + ( in reverse flushing order if you have several ones ) : <nl> + errorCode = FSE_initDState ( & DState , & DStream , DTablePtr ) ; <nl> + <nl> + You can then decode your data , symbol after symbol . <nl> + For information the maximum number of bits read by FSE_decodeSymbol ( ) is ' tableLog ' . <nl> + Keep in mind that symbols are decoded in reverse order , like a LIFO stack ( last in , first out ) . <nl> + unsigned char symbol = FSE_decodeSymbol ( & DState , & DStream ) ; <nl> + <nl> + You can retrieve any bitfield you eventually stored into the bitStream ( in reverse order ) <nl> + Note : maximum allowed nbBits is 25 , for 32 - bits compatibility <nl> + size_t bitField = BIT_readBits ( & DStream , nbBits ) ; <nl> + <nl> + All above operations only read from local register ( which size depends on size_t ) . <nl> + Refueling the register from memory is manually performed by the reload method . <nl> + endSignal = FSE_reloadDStream ( & DStream ) ; <nl> + <nl> + BIT_reloadDStream ( ) result tells if there is still some more data to read from DStream . <nl> + BIT_DStream_unfinished : there is still some data left into the DStream . <nl> + BIT_DStream_endOfBuffer : Dstream reached end of buffer . Its container may no longer be completely filled . <nl> + BIT_DStream_completed : Dstream reached its exact end , corresponding in general to decompression completed . <nl> + BIT_DStream_tooFar : Dstream went too far . Decompression result is corrupted . <nl> + <nl> + When reaching end of buffer ( BIT_DStream_endOfBuffer ) , progress slowly , notably if you decode multiple symbols per loop , <nl> + to properly detect the exact end of stream . <nl> + After each decoded symbol , check if DStream is fully consumed using this simple test : <nl> + BIT_reloadDStream ( & DStream ) > = BIT_DStream_completed <nl> + <nl> + When it ' s done , verify decompression is fully completed , by checking both DStream and the relevant states . <nl> + Checking if DStream has reached its end is performed by : <nl> + BIT_endOfDStream ( & DStream ) ; <nl> + Check also the states . There might be some symbols left there , if some high probability ones ( > 50 % ) are possible . <nl> + FSE_endOfDState ( & DState ) ; <nl> + * / <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * FSE unsafe API <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + static unsigned char FSE_decodeSymbolFast ( FSE_DState_t * DStatePtr , BIT_DStream_t * bitD ) ; <nl> + / * faster , but works only if nbBits is always > = 1 ( otherwise , result will be corrupted ) * / <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Implementation of inlined functions <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + typedef struct { <nl> + int deltaFindState ; <nl> + U32 deltaNbBits ; <nl> + } FSE_symbolCompressionTransform ; / * total 8 bytes * / <nl> + <nl> + MEM_STATIC void FSE_initCState ( FSE_CState_t * statePtr , const FSE_CTable * ct ) <nl> + { <nl> + const void * ptr = ct ; <nl> + const U16 * u16ptr = ( const U16 * ) ptr ; <nl> + const U32 tableLog = MEM_read16 ( ptr ) ; <nl> + statePtr - > value = ( ptrdiff_t ) 1 < < tableLog ; <nl> + statePtr - > stateTable = u16ptr + 2 ; <nl> + statePtr - > symbolTT = ( ( const U32 * ) ct + 1 + ( tableLog ? ( 1 < < ( tableLog - 1 ) ) : 1 ) ) ; <nl> + statePtr - > stateLog = tableLog ; <nl> + } <nl> + <nl> + <nl> + / * ! FSE_initCState2 ( ) : <nl> + * Same as FSE_initCState ( ) , but the first symbol to include ( which will be the last to be read ) <nl> + * uses the smallest state value possible , saving the cost of this symbol * / <nl> + MEM_STATIC void FSE_initCState2 ( FSE_CState_t * statePtr , const FSE_CTable * ct , U32 symbol ) <nl> + { <nl> + FSE_initCState ( statePtr , ct ) ; <nl> + { const FSE_symbolCompressionTransform symbolTT = ( ( const FSE_symbolCompressionTransform * ) ( statePtr - > symbolTT ) ) [ symbol ] ; <nl> + const U16 * stateTable = ( const U16 * ) ( statePtr - > stateTable ) ; <nl> + U32 nbBitsOut = ( U32 ) ( ( symbolTT . deltaNbBits + ( 1 < < 15 ) ) > > 16 ) ; <nl> + statePtr - > value = ( nbBitsOut < < 16 ) - symbolTT . deltaNbBits ; <nl> + statePtr - > value = stateTable [ ( statePtr - > value > > nbBitsOut ) + symbolTT . deltaFindState ] ; <nl> + } <nl> + } <nl> + <nl> + MEM_STATIC void FSE_encodeSymbol ( BIT_CStream_t * bitC , FSE_CState_t * statePtr , U32 symbol ) <nl> + { <nl> + FSE_symbolCompressionTransform const symbolTT = ( ( const FSE_symbolCompressionTransform * ) ( statePtr - > symbolTT ) ) [ symbol ] ; <nl> + const U16 * const stateTable = ( const U16 * ) ( statePtr - > stateTable ) ; <nl> + U32 const nbBitsOut = ( U32 ) ( ( statePtr - > value + symbolTT . deltaNbBits ) > > 16 ) ; <nl> + BIT_addBits ( bitC , statePtr - > value , nbBitsOut ) ; <nl> + statePtr - > value = stateTable [ ( statePtr - > value > > nbBitsOut ) + symbolTT . deltaFindState ] ; <nl> + } <nl> + <nl> + MEM_STATIC void FSE_flushCState ( BIT_CStream_t * bitC , const FSE_CState_t * statePtr ) <nl> + { <nl> + BIT_addBits ( bitC , statePtr - > value , statePtr - > stateLog ) ; <nl> + BIT_flushBits ( bitC ) ; <nl> + } <nl> + <nl> + <nl> + / * = = = = = = Decompression = = = = = = * / <nl> + <nl> + typedef struct { <nl> + U16 tableLog ; <nl> + U16 fastMode ; <nl> + } FSE_DTableHeader ; / * sizeof U32 * / <nl> + <nl> + typedef struct <nl> + { <nl> + unsigned short newState ; <nl> + unsigned char symbol ; <nl> + unsigned char nbBits ; <nl> + } FSE_decode_t ; / * size = = U32 * / <nl> + <nl> + MEM_STATIC void FSE_initDState ( FSE_DState_t * DStatePtr , BIT_DStream_t * bitD , const FSE_DTable * dt ) <nl> + { <nl> + const void * ptr = dt ; <nl> + const FSE_DTableHeader * const DTableH = ( const FSE_DTableHeader * ) ptr ; <nl> + DStatePtr - > state = BIT_readBits ( bitD , DTableH - > tableLog ) ; <nl> + BIT_reloadDStream ( bitD ) ; <nl> + DStatePtr - > table = dt + 1 ; <nl> + } <nl> + <nl> + MEM_STATIC BYTE FSE_peekSymbol ( const FSE_DState_t * DStatePtr ) <nl> + { <nl> + FSE_decode_t const DInfo = ( ( const FSE_decode_t * ) ( DStatePtr - > table ) ) [ DStatePtr - > state ] ; <nl> + return DInfo . symbol ; <nl> + } <nl> + <nl> + MEM_STATIC void FSE_updateState ( FSE_DState_t * DStatePtr , BIT_DStream_t * bitD ) <nl> + { <nl> + FSE_decode_t const DInfo = ( ( const FSE_decode_t * ) ( DStatePtr - > table ) ) [ DStatePtr - > state ] ; <nl> + U32 const nbBits = DInfo . nbBits ; <nl> + size_t const lowBits = BIT_readBits ( bitD , nbBits ) ; <nl> + DStatePtr - > state = DInfo . newState + lowBits ; <nl> + } <nl> + <nl> + MEM_STATIC BYTE FSE_decodeSymbol ( FSE_DState_t * DStatePtr , BIT_DStream_t * bitD ) <nl> + { <nl> + FSE_decode_t const DInfo = ( ( const FSE_decode_t * ) ( DStatePtr - > table ) ) [ DStatePtr - > state ] ; <nl> + U32 const nbBits = DInfo . nbBits ; <nl> + BYTE const symbol = DInfo . symbol ; <nl> + size_t const lowBits = BIT_readBits ( bitD , nbBits ) ; <nl> + <nl> + DStatePtr - > state = DInfo . newState + lowBits ; <nl> + return symbol ; <nl> + } <nl> + <nl> + / * ! FSE_decodeSymbolFast ( ) : <nl> + unsafe , only works if no symbol has a probability > 50 % * / <nl> + MEM_STATIC BYTE FSE_decodeSymbolFast ( FSE_DState_t * DStatePtr , BIT_DStream_t * bitD ) <nl> + { <nl> + FSE_decode_t const DInfo = ( ( const FSE_decode_t * ) ( DStatePtr - > table ) ) [ DStatePtr - > state ] ; <nl> + U32 const nbBits = DInfo . nbBits ; <nl> + BYTE const symbol = DInfo . symbol ; <nl> + size_t const lowBits = BIT_readBitsFast ( bitD , nbBits ) ; <nl> + <nl> + DStatePtr - > state = DInfo . newState + lowBits ; <nl> + return symbol ; <nl> + } <nl> + <nl> + MEM_STATIC unsigned FSE_endOfDState ( const FSE_DState_t * DStatePtr ) <nl> + { <nl> + return DStatePtr - > state = = 0 ; <nl> + } <nl> + <nl> + <nl> + <nl> + # ifndef FSE_COMMONDEFS_ONLY <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Tuning parameters <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * ! MEMORY_USAGE : <nl> + * Memory usage formula : N - > 2 ^ N Bytes ( examples : 10 - > 1KB ; 12 - > 4KB ; 16 - > 64KB ; 20 - > 1MB ; etc . ) <nl> + * Increasing memory usage improves compression ratio <nl> + * Reduced memory usage can improve speed , due to cache effect <nl> + * Recommended max value is 14 , for 16KB , which nicely fits into Intel x86 L1 cache * / <nl> + # ifndef FSE_MAX_MEMORY_USAGE <nl> + # define FSE_MAX_MEMORY_USAGE 14 <nl> + # endif <nl> + # ifndef FSE_DEFAULT_MEMORY_USAGE <nl> + # define FSE_DEFAULT_MEMORY_USAGE 13 <nl> + # endif <nl> + <nl> + / * ! FSE_MAX_SYMBOL_VALUE : <nl> + * Maximum symbol value authorized . <nl> + * Required for proper stack allocation * / <nl> + # ifndef FSE_MAX_SYMBOL_VALUE <nl> + # define FSE_MAX_SYMBOL_VALUE 255 <nl> + # endif <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * template functions type & suffix <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # define FSE_FUNCTION_TYPE BYTE <nl> + # define FSE_FUNCTION_EXTENSION <nl> + # define FSE_DECODE_TYPE FSE_decode_t <nl> + <nl> + <nl> + # endif / * ! FSE_COMMONDEFS_ONLY * / <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Constants <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # define FSE_MAX_TABLELOG ( FSE_MAX_MEMORY_USAGE - 2 ) <nl> + # define FSE_MAX_TABLESIZE ( 1U < < FSE_MAX_TABLELOG ) <nl> + # define FSE_MAXTABLESIZE_MASK ( FSE_MAX_TABLESIZE - 1 ) <nl> + # define FSE_DEFAULT_TABLELOG ( FSE_DEFAULT_MEMORY_USAGE - 2 ) <nl> + # define FSE_MIN_TABLELOG 5 <nl> + <nl> + # define FSE_TABLELOG_ABSOLUTE_MAX 15 <nl> + # if FSE_MAX_TABLELOG > FSE_TABLELOG_ABSOLUTE_MAX <nl> + # error " FSE_MAX_TABLELOG > FSE_TABLELOG_ABSOLUTE_MAX is not supported " <nl> + # endif <nl> + <nl> + # define FSE_TABLESTEP ( tableSize ) ( ( tableSize > > 1 ) + ( tableSize > > 3 ) + 3 ) <nl> + <nl> + <nl> + # endif / * FSE_STATIC_LINKING_ONLY * / <nl> + <nl> + <nl> + # if defined ( __cplusplus ) <nl> + } <nl> + # endif <nl> + <nl> + # endif / * FSE_H * / <nl> new file mode 100644 <nl> index 00000000000 . . 8474a4c079b <nl> mmm / dev / null <nl> ppp b / thirdparty / zstd / common / fse_decompress . c <nl> <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + FSE : Finite State Entropy decoder <nl> + Copyright ( C ) 2013 - 2015 , Yann Collet . <nl> + <nl> + BSD 2 - Clause License ( http : / / www . opensource . org / licenses / bsd - license . php ) <nl> + <nl> + Redistribution and use in source and binary forms , with or without <nl> + modification , are permitted provided that the following conditions are <nl> + met : <nl> + <nl> + * Redistributions of source code must retain the above copyright <nl> + notice , this list of conditions and the following disclaimer . <nl> + * Redistributions in binary form must reproduce the above <nl> + copyright notice , this list of conditions and the following disclaimer <nl> + in the documentation and / or other materials provided with the <nl> + distribution . <nl> + <nl> + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + <nl> + You can contact the author at : <nl> + - FSE source repository : https : / / github . com / Cyan4973 / FiniteStateEntropy <nl> + - Public forum : https : / / groups . google . com / forum / # ! forum / lz4c <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Compiler specifics <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # ifdef _MSC_VER / * Visual Studio * / <nl> + # define FORCE_INLINE static __forceinline <nl> + # include < intrin . h > / * For Visual 2005 * / <nl> + # pragma warning ( disable : 4127 ) / * disable : C4127 : conditional expression is constant * / <nl> + # pragma warning ( disable : 4214 ) / * disable : C4214 : non - int bitfields * / <nl> + # else <nl> + # if defined ( __cplusplus ) | | defined ( __STDC_VERSION__ ) & & __STDC_VERSION__ > = 199901L / * C99 * / <nl> + # ifdef __GNUC__ <nl> + # define FORCE_INLINE static inline __attribute__ ( ( always_inline ) ) <nl> + # else <nl> + # define FORCE_INLINE static inline <nl> + # endif <nl> + # else <nl> + # define FORCE_INLINE static <nl> + # endif / * __STDC_VERSION__ * / <nl> + # endif <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Includes <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # include < stdlib . h > / * malloc , free , qsort * / <nl> + # include < string . h > / * memcpy , memset * / <nl> + # include " bitstream . h " <nl> + # define FSE_STATIC_LINKING_ONLY <nl> + # include " fse . h " <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Error Management <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # define FSE_isError ERR_isError <nl> + # define FSE_STATIC_ASSERT ( c ) { enum { FSE_static_assert = 1 / ( int ) ( ! ! ( c ) ) } ; } / * use only * after * variable declarations * / <nl> + <nl> + / * check and forward error code * / <nl> + # define CHECK_F ( f ) { size_t const e = f ; if ( FSE_isError ( e ) ) return e ; } <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Templates <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * <nl> + designed to be included <nl> + for type - specific functions ( template emulation in C ) <nl> + Objective is to write these functions only once , for improved maintenance <nl> + * / <nl> + <nl> + / * safety checks * / <nl> + # ifndef FSE_FUNCTION_EXTENSION <nl> + # error " FSE_FUNCTION_EXTENSION must be defined " <nl> + # endif <nl> + # ifndef FSE_FUNCTION_TYPE <nl> + # error " FSE_FUNCTION_TYPE must be defined " <nl> + # endif <nl> + <nl> + / * Function names * / <nl> + # define FSE_CAT ( X , Y ) X # # Y <nl> + # define FSE_FUNCTION_NAME ( X , Y ) FSE_CAT ( X , Y ) <nl> + # define FSE_TYPE_NAME ( X , Y ) FSE_CAT ( X , Y ) <nl> + <nl> + <nl> + / * Function templates * / <nl> + FSE_DTable * FSE_createDTable ( unsigned tableLog ) <nl> + { <nl> + if ( tableLog > FSE_TABLELOG_ABSOLUTE_MAX ) tableLog = FSE_TABLELOG_ABSOLUTE_MAX ; <nl> + return ( FSE_DTable * ) malloc ( FSE_DTABLE_SIZE_U32 ( tableLog ) * sizeof ( U32 ) ) ; <nl> + } <nl> + <nl> + void FSE_freeDTable ( FSE_DTable * dt ) <nl> + { <nl> + free ( dt ) ; <nl> + } <nl> + <nl> + size_t FSE_buildDTable ( FSE_DTable * dt , const short * normalizedCounter , unsigned maxSymbolValue , unsigned tableLog ) <nl> + { <nl> + void * const tdPtr = dt + 1 ; / * because * dt is unsigned , 32 - bits aligned on 32 - bits * / <nl> + FSE_DECODE_TYPE * const tableDecode = ( FSE_DECODE_TYPE * ) ( tdPtr ) ; <nl> + U16 symbolNext [ FSE_MAX_SYMBOL_VALUE + 1 ] ; <nl> + <nl> + U32 const maxSV1 = maxSymbolValue + 1 ; <nl> + U32 const tableSize = 1 < < tableLog ; <nl> + U32 highThreshold = tableSize - 1 ; <nl> + <nl> + / * Sanity Checks * / <nl> + if ( maxSymbolValue > FSE_MAX_SYMBOL_VALUE ) return ERROR ( maxSymbolValue_tooLarge ) ; <nl> + if ( tableLog > FSE_MAX_TABLELOG ) return ERROR ( tableLog_tooLarge ) ; <nl> + <nl> + / * Init , lay down lowprob symbols * / <nl> + { FSE_DTableHeader DTableH ; <nl> + DTableH . tableLog = ( U16 ) tableLog ; <nl> + DTableH . fastMode = 1 ; <nl> + { S16 const largeLimit = ( S16 ) ( 1 < < ( tableLog - 1 ) ) ; <nl> + U32 s ; <nl> + for ( s = 0 ; s < maxSV1 ; s + + ) { <nl> + if ( normalizedCounter [ s ] = = - 1 ) { <nl> + tableDecode [ highThreshold - - ] . symbol = ( FSE_FUNCTION_TYPE ) s ; <nl> + symbolNext [ s ] = 1 ; <nl> + } else { <nl> + if ( normalizedCounter [ s ] > = largeLimit ) DTableH . fastMode = 0 ; <nl> + symbolNext [ s ] = normalizedCounter [ s ] ; <nl> + } } } <nl> + memcpy ( dt , & DTableH , sizeof ( DTableH ) ) ; <nl> + } <nl> + <nl> + / * Spread symbols * / <nl> + { U32 const tableMask = tableSize - 1 ; <nl> + U32 const step = FSE_TABLESTEP ( tableSize ) ; <nl> + U32 s , position = 0 ; <nl> + for ( s = 0 ; s < maxSV1 ; s + + ) { <nl> + int i ; <nl> + for ( i = 0 ; i < normalizedCounter [ s ] ; i + + ) { <nl> + tableDecode [ position ] . symbol = ( FSE_FUNCTION_TYPE ) s ; <nl> + position = ( position + step ) & tableMask ; <nl> + while ( position > highThreshold ) position = ( position + step ) & tableMask ; / * lowprob area * / <nl> + } } <nl> + if ( position ! = 0 ) return ERROR ( GENERIC ) ; / * position must reach all cells once , otherwise normalizedCounter is incorrect * / <nl> + } <nl> + <nl> + / * Build Decoding table * / <nl> + { U32 u ; <nl> + for ( u = 0 ; u < tableSize ; u + + ) { <nl> + FSE_FUNCTION_TYPE const symbol = ( FSE_FUNCTION_TYPE ) ( tableDecode [ u ] . symbol ) ; <nl> + U16 nextState = symbolNext [ symbol ] + + ; <nl> + tableDecode [ u ] . nbBits = ( BYTE ) ( tableLog - BIT_highbit32 ( ( U32 ) nextState ) ) ; <nl> + tableDecode [ u ] . newState = ( U16 ) ( ( nextState < < tableDecode [ u ] . nbBits ) - tableSize ) ; <nl> + } } <nl> + <nl> + return 0 ; <nl> + } <nl> + <nl> + <nl> + # ifndef FSE_COMMONDEFS_ONLY <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Decompression ( Byte symbols ) <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + size_t FSE_buildDTable_rle ( FSE_DTable * dt , BYTE symbolValue ) <nl> + { <nl> + void * ptr = dt ; <nl> + FSE_DTableHeader * const DTableH = ( FSE_DTableHeader * ) ptr ; <nl> + void * dPtr = dt + 1 ; <nl> + FSE_decode_t * const cell = ( FSE_decode_t * ) dPtr ; <nl> + <nl> + DTableH - > tableLog = 0 ; <nl> + DTableH - > fastMode = 0 ; <nl> + <nl> + cell - > newState = 0 ; <nl> + cell - > symbol = symbolValue ; <nl> + cell - > nbBits = 0 ; <nl> + <nl> + return 0 ; <nl> + } <nl> + <nl> + <nl> + size_t FSE_buildDTable_raw ( FSE_DTable * dt , unsigned nbBits ) <nl> + { <nl> + void * ptr = dt ; <nl> + FSE_DTableHeader * const DTableH = ( FSE_DTableHeader * ) ptr ; <nl> + void * dPtr = dt + 1 ; <nl> + FSE_decode_t * const dinfo = ( FSE_decode_t * ) dPtr ; <nl> + const unsigned tableSize = 1 < < nbBits ; <nl> + const unsigned tableMask = tableSize - 1 ; <nl> + const unsigned maxSV1 = tableMask + 1 ; <nl> + unsigned s ; <nl> + <nl> + / * Sanity checks * / <nl> + if ( nbBits < 1 ) return ERROR ( GENERIC ) ; / * min size * / <nl> + <nl> + / * Build Decoding Table * / <nl> + DTableH - > tableLog = ( U16 ) nbBits ; <nl> + DTableH - > fastMode = 1 ; <nl> + for ( s = 0 ; s < maxSV1 ; s + + ) { <nl> + dinfo [ s ] . newState = 0 ; <nl> + dinfo [ s ] . symbol = ( BYTE ) s ; <nl> + dinfo [ s ] . nbBits = ( BYTE ) nbBits ; <nl> + } <nl> + <nl> + return 0 ; <nl> + } <nl> + <nl> + FORCE_INLINE size_t FSE_decompress_usingDTable_generic ( <nl> + void * dst , size_t maxDstSize , <nl> + const void * cSrc , size_t cSrcSize , <nl> + const FSE_DTable * dt , const unsigned fast ) <nl> + { <nl> + BYTE * const ostart = ( BYTE * ) dst ; <nl> + BYTE * op = ostart ; <nl> + BYTE * const omax = op + maxDstSize ; <nl> + BYTE * const olimit = omax - 3 ; <nl> + <nl> + BIT_DStream_t bitD ; <nl> + FSE_DState_t state1 ; <nl> + FSE_DState_t state2 ; <nl> + <nl> + / * Init * / <nl> + CHECK_F ( BIT_initDStream ( & bitD , cSrc , cSrcSize ) ) ; <nl> + <nl> + FSE_initDState ( & state1 , & bitD , dt ) ; <nl> + FSE_initDState ( & state2 , & bitD , dt ) ; <nl> + <nl> + # define FSE_GETSYMBOL ( statePtr ) fast ? FSE_decodeSymbolFast ( statePtr , & bitD ) : FSE_decodeSymbol ( statePtr , & bitD ) <nl> + <nl> + / * 4 symbols per loop * / <nl> + for ( ; ( BIT_reloadDStream ( & bitD ) = = BIT_DStream_unfinished ) & ( op < olimit ) ; op + = 4 ) { <nl> + op [ 0 ] = FSE_GETSYMBOL ( & state1 ) ; <nl> + <nl> + if ( FSE_MAX_TABLELOG * 2 + 7 > sizeof ( bitD . bitContainer ) * 8 ) / * This test must be static * / <nl> + BIT_reloadDStream ( & bitD ) ; <nl> + <nl> + op [ 1 ] = FSE_GETSYMBOL ( & state2 ) ; <nl> + <nl> + if ( FSE_MAX_TABLELOG * 4 + 7 > sizeof ( bitD . bitContainer ) * 8 ) / * This test must be static * / <nl> + { if ( BIT_reloadDStream ( & bitD ) > BIT_DStream_unfinished ) { op + = 2 ; break ; } } <nl> + <nl> + op [ 2 ] = FSE_GETSYMBOL ( & state1 ) ; <nl> + <nl> + if ( FSE_MAX_TABLELOG * 2 + 7 > sizeof ( bitD . bitContainer ) * 8 ) / * This test must be static * / <nl> + BIT_reloadDStream ( & bitD ) ; <nl> + <nl> + op [ 3 ] = FSE_GETSYMBOL ( & state2 ) ; <nl> + } <nl> + <nl> + / * tail * / <nl> + / * note : BIT_reloadDStream ( & bitD ) > = FSE_DStream_partiallyFilled ; Ends at exactly BIT_DStream_completed * / <nl> + while ( 1 ) { <nl> + if ( op > ( omax - 2 ) ) return ERROR ( dstSize_tooSmall ) ; <nl> + * op + + = FSE_GETSYMBOL ( & state1 ) ; <nl> + if ( BIT_reloadDStream ( & bitD ) = = BIT_DStream_overflow ) { <nl> + * op + + = FSE_GETSYMBOL ( & state2 ) ; <nl> + break ; <nl> + } <nl> + <nl> + if ( op > ( omax - 2 ) ) return ERROR ( dstSize_tooSmall ) ; <nl> + * op + + = FSE_GETSYMBOL ( & state2 ) ; <nl> + if ( BIT_reloadDStream ( & bitD ) = = BIT_DStream_overflow ) { <nl> + * op + + = FSE_GETSYMBOL ( & state1 ) ; <nl> + break ; <nl> + } } <nl> + <nl> + return op - ostart ; <nl> + } <nl> + <nl> + <nl> + size_t FSE_decompress_usingDTable ( void * dst , size_t originalSize , <nl> + const void * cSrc , size_t cSrcSize , <nl> + const FSE_DTable * dt ) <nl> + { <nl> + const void * ptr = dt ; <nl> + const FSE_DTableHeader * DTableH = ( const FSE_DTableHeader * ) ptr ; <nl> + const U32 fastMode = DTableH - > fastMode ; <nl> + <nl> + / * select fast mode ( static ) * / <nl> + if ( fastMode ) return FSE_decompress_usingDTable_generic ( dst , originalSize , cSrc , cSrcSize , dt , 1 ) ; <nl> + return FSE_decompress_usingDTable_generic ( dst , originalSize , cSrc , cSrcSize , dt , 0 ) ; <nl> + } <nl> + <nl> + <nl> + size_t FSE_decompress_wksp ( void * dst , size_t dstCapacity , const void * cSrc , size_t cSrcSize , FSE_DTable * workSpace , unsigned maxLog ) <nl> + { <nl> + const BYTE * const istart = ( const BYTE * ) cSrc ; <nl> + const BYTE * ip = istart ; <nl> + short counting [ FSE_MAX_SYMBOL_VALUE + 1 ] ; <nl> + unsigned tableLog ; <nl> + unsigned maxSymbolValue = FSE_MAX_SYMBOL_VALUE ; <nl> + <nl> + / * normal FSE decoding mode * / <nl> + size_t const NCountLength = FSE_readNCount ( counting , & maxSymbolValue , & tableLog , istart , cSrcSize ) ; <nl> + if ( FSE_isError ( NCountLength ) ) return NCountLength ; <nl> + / / if ( NCountLength > = cSrcSize ) return ERROR ( srcSize_wrong ) ; / * too small input size ; supposed to be already checked in NCountLength , only remaining case : NCountLength = = cSrcSize * / <nl> + if ( tableLog > maxLog ) return ERROR ( tableLog_tooLarge ) ; <nl> + ip + = NCountLength ; <nl> + cSrcSize - = NCountLength ; <nl> + <nl> + CHECK_F ( FSE_buildDTable ( workSpace , counting , maxSymbolValue , tableLog ) ) ; <nl> + <nl> + return FSE_decompress_usingDTable ( dst , dstCapacity , ip , cSrcSize , workSpace ) ; / * always return , even if it is an error code * / <nl> + } <nl> + <nl> + <nl> + typedef FSE_DTable DTable_max_t [ FSE_DTABLE_SIZE_U32 ( FSE_MAX_TABLELOG ) ] ; <nl> + <nl> + size_t FSE_decompress ( void * dst , size_t dstCapacity , const void * cSrc , size_t cSrcSize ) <nl> + { <nl> + DTable_max_t dt ; / * Static analyzer seems unable to understand this table will be properly initialized later * / <nl> + return FSE_decompress_wksp ( dst , dstCapacity , cSrc , cSrcSize , dt , FSE_MAX_TABLELOG ) ; <nl> + } <nl> + <nl> + <nl> + <nl> + # endif / * FSE_COMMONDEFS_ONLY * / <nl> new file mode 100644 <nl> index 00000000000 . . 7873ca3d42a <nl> mmm / dev / null <nl> ppp b / thirdparty / zstd / common / huf . h <nl> <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + Huffman coder , part of New Generation Entropy library <nl> + header file <nl> + Copyright ( C ) 2013 - 2016 , Yann Collet . <nl> + <nl> + BSD 2 - Clause License ( http : / / www . opensource . org / licenses / bsd - license . php ) <nl> + <nl> + Redistribution and use in source and binary forms , with or without <nl> + modification , are permitted provided that the following conditions are <nl> + met : <nl> + <nl> + * Redistributions of source code must retain the above copyright <nl> + notice , this list of conditions and the following disclaimer . <nl> + * Redistributions in binary form must reproduce the above <nl> + copyright notice , this list of conditions and the following disclaimer <nl> + in the documentation and / or other materials provided with the <nl> + distribution . <nl> + <nl> + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + <nl> + You can contact the author at : <nl> + - Source repository : https : / / github . com / Cyan4973 / FiniteStateEntropy <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # ifndef HUF_H_298734234 <nl> + # define HUF_H_298734234 <nl> + <nl> + # if defined ( __cplusplus ) <nl> + extern " C " { <nl> + # endif <nl> + <nl> + <nl> + / * * * * Dependencies * * * * / <nl> + # include < stddef . h > / * size_t * / <nl> + <nl> + <nl> + / * * * * library symbols visibility * * * * / <nl> + / * Note : when linking with - fvisibility = hidden on gcc , or by default on Visual , <nl> + * HUF symbols remain " private " ( internal symbols for library only ) . <nl> + * Set macro FSE_DLL_EXPORT to 1 if you want HUF symbols visible on DLL interface * / <nl> + # if defined ( FSE_DLL_EXPORT ) & & ( FSE_DLL_EXPORT = = 1 ) & & defined ( __GNUC__ ) & & ( __GNUC__ > = 4 ) <nl> + # define HUF_PUBLIC_API __attribute__ ( ( visibility ( " default " ) ) ) <nl> + # elif defined ( FSE_DLL_EXPORT ) & & ( FSE_DLL_EXPORT = = 1 ) / * Visual expected * / <nl> + # define HUF_PUBLIC_API __declspec ( dllexport ) <nl> + # elif defined ( FSE_DLL_IMPORT ) & & ( FSE_DLL_IMPORT = = 1 ) <nl> + # define HUF_PUBLIC_API __declspec ( dllimport ) / * not required , just to generate faster code ( saves a function pointer load from IAT and an indirect jump ) * / <nl> + # else <nl> + # define HUF_PUBLIC_API <nl> + # endif <nl> + <nl> + <nl> + / * * * * simple functions * * * * / <nl> + / * * <nl> + HUF_compress ( ) : <nl> + Compress content from buffer ' src ' , of size ' srcSize ' , into buffer ' dst ' . <nl> + ' dst ' buffer must be already allocated . <nl> + Compression runs faster if ` dstCapacity ` > = HUF_compressBound ( srcSize ) . <nl> + ` srcSize ` must be < = ` HUF_BLOCKSIZE_MAX ` = = 128 KB . <nl> + @ return : size of compressed data ( < = ` dstCapacity ` ) . <nl> + Special values : if return = = 0 , srcData is not compressible = > Nothing is stored within dst ! ! ! <nl> + if return = = 1 , srcData is a single repeated byte symbol ( RLE compression ) . <nl> + if HUF_isError ( return ) , compression failed ( more details using HUF_getErrorName ( ) ) <nl> + * / <nl> + HUF_PUBLIC_API size_t HUF_compress ( void * dst , size_t dstCapacity , <nl> + const void * src , size_t srcSize ) ; <nl> + <nl> + / * * <nl> + HUF_decompress ( ) : <nl> + Decompress HUF data from buffer ' cSrc ' , of size ' cSrcSize ' , <nl> + into already allocated buffer ' dst ' , of minimum size ' dstSize ' . <nl> + ` originalSize ` : * * must * * be the * * * exact * * * size of original ( uncompressed ) data . <nl> + Note : in contrast with FSE , HUF_decompress can regenerate <nl> + RLE ( cSrcSize = = 1 ) and uncompressed ( cSrcSize = = dstSize ) data , <nl> + because it knows size to regenerate . <nl> + @ return : size of regenerated data ( = = originalSize ) , <nl> + or an error code , which can be tested using HUF_isError ( ) <nl> + * / <nl> + HUF_PUBLIC_API size_t HUF_decompress ( void * dst , size_t originalSize , <nl> + const void * cSrc , size_t cSrcSize ) ; <nl> + <nl> + <nl> + / * * * * Tool functions * * * * / <nl> + # define HUF_BLOCKSIZE_MAX ( 128 * 1024 ) / * * < maximum input size for a single block compressed with HUF_compress * / <nl> + HUF_PUBLIC_API size_t HUF_compressBound ( size_t size ) ; / * * < maximum compressed size ( worst case ) * / <nl> + <nl> + / * Error Management * / <nl> + HUF_PUBLIC_API unsigned HUF_isError ( size_t code ) ; / * * < tells if a return value is an error code * / <nl> + HUF_PUBLIC_API const char * HUF_getErrorName ( size_t code ) ; / * * < provides error code string ( useful for debugging ) * / <nl> + <nl> + <nl> + / * * * * Advanced function * * * * / <nl> + <nl> + / * * HUF_compress2 ( ) : <nl> + * Same as HUF_compress ( ) , but offers direct control over ` maxSymbolValue ` and ` tableLog ` . <nl> + * ` tableLog ` must be ` < = HUF_TABLELOG_MAX ` . * / <nl> + HUF_PUBLIC_API size_t HUF_compress2 ( void * dst , size_t dstCapacity , const void * src , size_t srcSize , unsigned maxSymbolValue , unsigned tableLog ) ; <nl> + <nl> + / * * HUF_compress4X_wksp ( ) : <nl> + * Same as HUF_compress2 ( ) , but uses externally allocated ` workSpace ` . <nl> + * ` workspace ` must have minimum alignment of 4 , and be at least as large as following macro * / <nl> + # define HUF_WORKSPACE_SIZE ( 6 < < 10 ) <nl> + # define HUF_WORKSPACE_SIZE_U32 ( HUF_WORKSPACE_SIZE / sizeof ( U32 ) ) <nl> + HUF_PUBLIC_API size_t HUF_compress4X_wksp ( void * dst , size_t dstCapacity , const void * src , size_t srcSize , unsigned maxSymbolValue , unsigned tableLog , void * workSpace , size_t wkspSize ) ; <nl> + <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * WARNING ! ! <nl> + * The following section contains advanced and experimental definitions <nl> + * which shall never be used in the context of dll <nl> + * because they are not guaranteed to remain stable in the future . <nl> + * Only consider them in association with static linking . <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # ifdef HUF_STATIC_LINKING_ONLY <nl> + <nl> + / * * * * Dependencies * * * * / <nl> + # include " mem . h " / * U32 * / <nl> + <nl> + <nl> + / * * * * Constants * * * * / <nl> + # define HUF_TABLELOG_MAX 12 / * max configured tableLog ( for static allocation ) ; can be modified up to HUF_ABSOLUTEMAX_TABLELOG * / <nl> + # define HUF_TABLELOG_DEFAULT 11 / * tableLog by default , when not specified * / <nl> + # define HUF_SYMBOLVALUE_MAX 255 <nl> + <nl> + # define HUF_TABLELOG_ABSOLUTEMAX 15 / * absolute limit of HUF_MAX_TABLELOG . Beyond that value , code does not work * / <nl> + # if ( HUF_TABLELOG_MAX > HUF_TABLELOG_ABSOLUTEMAX ) <nl> + # error " HUF_TABLELOG_MAX is too large ! " <nl> + # endif <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Static allocation <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * HUF buffer bounds * / <nl> + # define HUF_CTABLEBOUND 129 <nl> + # define HUF_BLOCKBOUND ( size ) ( size + ( size > > 8 ) + 8 ) / * only true when incompressible is pre - filtered with fast heuristic * / <nl> + # define HUF_COMPRESSBOUND ( size ) ( HUF_CTABLEBOUND + HUF_BLOCKBOUND ( size ) ) / * Macro version , useful for static allocation * / <nl> + <nl> + / * static allocation of HUF ' s Compression Table * / <nl> + # define HUF_CTABLE_SIZE_U32 ( maxSymbolValue ) ( ( maxSymbolValue ) + 1 ) / * Use tables of U32 , for proper alignment * / <nl> + # define HUF_CTABLE_SIZE ( maxSymbolValue ) ( HUF_CTABLE_SIZE_U32 ( maxSymbolValue ) * sizeof ( U32 ) ) <nl> + # define HUF_CREATE_STATIC_CTABLE ( name , maxSymbolValue ) \ <nl> + U32 name # # hb [ HUF_CTABLE_SIZE_U32 ( maxSymbolValue ) ] ; \ <nl> + void * name # # hv = & ( name # # hb ) ; \ <nl> + HUF_CElt * name = ( HUF_CElt * ) ( name # # hv ) / * no final ; * / <nl> + <nl> + / * static allocation of HUF ' s DTable * / <nl> + typedef U32 HUF_DTable ; <nl> + # define HUF_DTABLE_SIZE ( maxTableLog ) ( 1 + ( 1 < < ( maxTableLog ) ) ) <nl> + # define HUF_CREATE_STATIC_DTABLEX2 ( DTable , maxTableLog ) \ <nl> + HUF_DTable DTable [ HUF_DTABLE_SIZE ( ( maxTableLog ) - 1 ) ] = { ( ( U32 ) ( ( maxTableLog ) - 1 ) * 0x01000001 ) } <nl> + # define HUF_CREATE_STATIC_DTABLEX4 ( DTable , maxTableLog ) \ <nl> + HUF_DTable DTable [ HUF_DTABLE_SIZE ( maxTableLog ) ] = { ( ( U32 ) ( maxTableLog ) * 0x01000001 ) } <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Advanced decompression functions <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + size_t HUF_decompress4X2 ( void * dst , size_t dstSize , const void * cSrc , size_t cSrcSize ) ; / * * < single - symbol decoder * / <nl> + size_t HUF_decompress4X4 ( void * dst , size_t dstSize , const void * cSrc , size_t cSrcSize ) ; / * * < double - symbols decoder * / <nl> + <nl> + size_t HUF_decompress4X_DCtx ( HUF_DTable * dctx , void * dst , size_t dstSize , const void * cSrc , size_t cSrcSize ) ; / * * < decodes RLE and uncompressed * / <nl> + size_t HUF_decompress4X_hufOnly ( HUF_DTable * dctx , void * dst , size_t dstSize , const void * cSrc , size_t cSrcSize ) ; / * * < considers RLE and uncompressed as errors * / <nl> + size_t HUF_decompress4X2_DCtx ( HUF_DTable * dctx , void * dst , size_t dstSize , const void * cSrc , size_t cSrcSize ) ; / * * < single - symbol decoder * / <nl> + size_t HUF_decompress4X4_DCtx ( HUF_DTable * dctx , void * dst , size_t dstSize , const void * cSrc , size_t cSrcSize ) ; / * * < double - symbols decoder * / <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * HUF detailed API <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * ! <nl> + HUF_compress ( ) does the following : <nl> + 1 . count symbol occurrence from source [ ] into table count [ ] using FSE_count ( ) <nl> + 2 . ( optional ) refine tableLog using HUF_optimalTableLog ( ) <nl> + 3 . build Huffman table from count using HUF_buildCTable ( ) <nl> + 4 . save Huffman table to memory buffer using HUF_writeCTable ( ) <nl> + 5 . encode the data stream using HUF_compress4X_usingCTable ( ) <nl> + <nl> + The following API allows targeting specific sub - functions for advanced tasks . <nl> + For example , it ' s possible to compress several blocks using the same ' CTable ' , <nl> + or to save and regenerate ' CTable ' using external methods . <nl> + * / <nl> + / * FSE_count ( ) : find it within " fse . h " * / <nl> + unsigned HUF_optimalTableLog ( unsigned maxTableLog , size_t srcSize , unsigned maxSymbolValue ) ; <nl> + typedef struct HUF_CElt_s HUF_CElt ; / * incomplete type * / <nl> + size_t HUF_buildCTable ( HUF_CElt * CTable , const unsigned * count , unsigned maxSymbolValue , unsigned maxNbBits ) ; <nl> + size_t HUF_writeCTable ( void * dst , size_t maxDstSize , const HUF_CElt * CTable , unsigned maxSymbolValue , unsigned huffLog ) ; <nl> + size_t HUF_compress4X_usingCTable ( void * dst , size_t dstSize , const void * src , size_t srcSize , const HUF_CElt * CTable ) ; <nl> + <nl> + typedef enum { <nl> + HUF_repeat_none , / * * < Cannot use the previous table * / <nl> + HUF_repeat_check , / * * < Can use the previous table but it must be checked . Note : The previous table must have been constructed by HUF_compress { 1 , 4 } X_repeat * / <nl> + HUF_repeat_valid / * * < Can use the previous table and it is asumed to be valid * / <nl> + } HUF_repeat ; <nl> + / * * HUF_compress4X_repeat ( ) : <nl> + * Same as HUF_compress4X_wksp ( ) , but considers using hufTable if * repeat ! = HUF_repeat_none . <nl> + * If it uses hufTable it does not modify hufTable or repeat . <nl> + * If it doesn ' t , it sets * repeat = HUF_repeat_none , and it sets hufTable to the table used . <nl> + * If preferRepeat then the old table will always be used if valid . * / <nl> + size_t HUF_compress4X_repeat ( void * dst , size_t dstSize , const void * src , size_t srcSize , unsigned maxSymbolValue , unsigned tableLog , void * workSpace , size_t wkspSize , HUF_CElt * hufTable , HUF_repeat * repeat , int preferRepeat ) ; / * * < ` workSpace ` must be a table of at least HUF_WORKSPACE_SIZE_U32 unsigned * / <nl> + <nl> + / * * HUF_buildCTable_wksp ( ) : <nl> + * Same as HUF_buildCTable ( ) , but using externally allocated scratch buffer . <nl> + * ` workSpace ` must be aligned on 4 - bytes boundaries , and be at least as large as a table of 1024 unsigned . <nl> + * / <nl> + size_t HUF_buildCTable_wksp ( HUF_CElt * tree , const U32 * count , U32 maxSymbolValue , U32 maxNbBits , void * workSpace , size_t wkspSize ) ; <nl> + <nl> + / * ! HUF_readStats ( ) : <nl> + Read compact Huffman tree , saved by HUF_writeCTable ( ) . <nl> + ` huffWeight ` is destination buffer . <nl> + @ return : size read from ` src ` , or an error Code . <nl> + Note : Needed by HUF_readCTable ( ) and HUF_readDTableXn ( ) . * / <nl> + size_t HUF_readStats ( BYTE * huffWeight , size_t hwSize , U32 * rankStats , <nl> + U32 * nbSymbolsPtr , U32 * tableLogPtr , <nl> + const void * src , size_t srcSize ) ; <nl> + <nl> + / * * HUF_readCTable ( ) : <nl> + * Loading a CTable saved with HUF_writeCTable ( ) * / <nl> + size_t HUF_readCTable ( HUF_CElt * CTable , unsigned maxSymbolValue , const void * src , size_t srcSize ) ; <nl> + <nl> + <nl> + / * <nl> + HUF_decompress ( ) does the following : <nl> + 1 . select the decompression algorithm ( X2 , X4 ) based on pre - computed heuristics <nl> + 2 . build Huffman table from save , using HUF_readDTableXn ( ) <nl> + 3 . decode 1 or 4 segments in parallel using HUF_decompressSXn_usingDTable <nl> + * / <nl> + <nl> + / * * HUF_selectDecoder ( ) : <nl> + * Tells which decoder is likely to decode faster , <nl> + * based on a set of pre - determined metrics . <nl> + * @ return : 0 = = HUF_decompress4X2 , 1 = = HUF_decompress4X4 . <nl> + * Assumption : 0 < cSrcSize < dstSize < = 128 KB * / <nl> + U32 HUF_selectDecoder ( size_t dstSize , size_t cSrcSize ) ; <nl> + <nl> + size_t HUF_readDTableX2 ( HUF_DTable * DTable , const void * src , size_t srcSize ) ; <nl> + size_t HUF_readDTableX4 ( HUF_DTable * DTable , const void * src , size_t srcSize ) ; <nl> + <nl> + size_t HUF_decompress4X_usingDTable ( void * dst , size_t maxDstSize , const void * cSrc , size_t cSrcSize , const HUF_DTable * DTable ) ; <nl> + size_t HUF_decompress4X2_usingDTable ( void * dst , size_t maxDstSize , const void * cSrc , size_t cSrcSize , const HUF_DTable * DTable ) ; <nl> + size_t HUF_decompress4X4_usingDTable ( void * dst , size_t maxDstSize , const void * cSrc , size_t cSrcSize , const HUF_DTable * DTable ) ; <nl> + <nl> + <nl> + / * single stream variants * / <nl> + <nl> + size_t HUF_compress1X ( void * dst , size_t dstSize , const void * src , size_t srcSize , unsigned maxSymbolValue , unsigned tableLog ) ; <nl> + size_t HUF_compress1X_wksp ( void * dst , size_t dstSize , const void * src , size_t srcSize , unsigned maxSymbolValue , unsigned tableLog , void * workSpace , size_t wkspSize ) ; / * * < ` workSpace ` must be a table of at least HUF_WORKSPACE_SIZE_U32 unsigned * / <nl> + size_t HUF_compress1X_usingCTable ( void * dst , size_t dstSize , const void * src , size_t srcSize , const HUF_CElt * CTable ) ; <nl> + / * * HUF_compress1X_repeat ( ) : <nl> + * Same as HUF_compress1X_wksp ( ) , but considers using hufTable if * repeat ! = HUF_repeat_none . <nl> + * If it uses hufTable it does not modify hufTable or repeat . <nl> + * If it doesn ' t , it sets * repeat = HUF_repeat_none , and it sets hufTable to the table used . <nl> + * If preferRepeat then the old table will always be used if valid . * / <nl> + size_t HUF_compress1X_repeat ( void * dst , size_t dstSize , const void * src , size_t srcSize , unsigned maxSymbolValue , unsigned tableLog , void * workSpace , size_t wkspSize , HUF_CElt * hufTable , HUF_repeat * repeat , int preferRepeat ) ; / * * < ` workSpace ` must be a table of at least HUF_WORKSPACE_SIZE_U32 unsigned * / <nl> + <nl> + size_t HUF_decompress1X2 ( void * dst , size_t dstSize , const void * cSrc , size_t cSrcSize ) ; / * single - symbol decoder * / <nl> + size_t HUF_decompress1X4 ( void * dst , size_t dstSize , const void * cSrc , size_t cSrcSize ) ; / * double - symbol decoder * / <nl> + <nl> + size_t HUF_decompress1X_DCtx ( HUF_DTable * dctx , void * dst , size_t dstSize , const void * cSrc , size_t cSrcSize ) ; <nl> + size_t HUF_decompress1X2_DCtx ( HUF_DTable * dctx , void * dst , size_t dstSize , const void * cSrc , size_t cSrcSize ) ; / * * < single - symbol decoder * / <nl> + size_t HUF_decompress1X4_DCtx ( HUF_DTable * dctx , void * dst , size_t dstSize , const void * cSrc , size_t cSrcSize ) ; / * * < double - symbols decoder * / <nl> + <nl> + size_t HUF_decompress1X_usingDTable ( void * dst , size_t maxDstSize , const void * cSrc , size_t cSrcSize , const HUF_DTable * DTable ) ; / * * < automatic selection of sing or double symbol decoder , based on DTable * / <nl> + size_t HUF_decompress1X2_usingDTable ( void * dst , size_t maxDstSize , const void * cSrc , size_t cSrcSize , const HUF_DTable * DTable ) ; <nl> + size_t HUF_decompress1X4_usingDTable ( void * dst , size_t maxDstSize , const void * cSrc , size_t cSrcSize , const HUF_DTable * DTable ) ; <nl> + <nl> + # endif / * HUF_STATIC_LINKING_ONLY * / <nl> + <nl> + <nl> + # if defined ( __cplusplus ) <nl> + } <nl> + # endif <nl> + <nl> + # endif / * HUF_H_298734234 * / <nl> new file mode 100644 <nl> index 00000000000 . . 4773a8b9309 <nl> mmm / dev / null <nl> ppp b / thirdparty / zstd / common / mem . h <nl> <nl> + / * * <nl> + * Copyright ( c ) 2016 - present , Yann Collet , Facebook , Inc . <nl> + * All rights reserved . <nl> + * <nl> + * This source code is licensed under the BSD - style license found in the <nl> + * LICENSE file in the root directory of this source tree . An additional grant <nl> + * of patent rights can be found in the PATENTS file in the same directory . <nl> + * / <nl> + <nl> + # ifndef MEM_H_MODULE <nl> + # define MEM_H_MODULE <nl> + <nl> + # if defined ( __cplusplus ) <nl> + extern " C " { <nl> + # endif <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Dependencies <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # include < stddef . h > / * size_t , ptrdiff_t * / <nl> + # include < string . h > / * memcpy * / <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Compiler specifics <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # if defined ( _MSC_VER ) / * Visual Studio * / <nl> + # include < stdlib . h > / * _byteswap_ulong * / <nl> + # include < intrin . h > / * _byteswap_ * * / <nl> + # endif <nl> + # if defined ( __GNUC__ ) <nl> + # define MEM_STATIC static __inline __attribute__ ( ( unused ) ) <nl> + # elif defined ( __cplusplus ) | | ( defined ( __STDC_VERSION__ ) & & ( __STDC_VERSION__ > = 199901L ) / * C99 * / ) <nl> + # define MEM_STATIC static inline <nl> + # elif defined ( _MSC_VER ) <nl> + # define MEM_STATIC static __inline <nl> + # else <nl> + # define MEM_STATIC static / * this version may generate warnings for unused static functions ; disable the relevant warning * / <nl> + # endif <nl> + <nl> + / * code only tested on 32 and 64 bits systems * / <nl> + # define MEM_STATIC_ASSERT ( c ) { enum { MEM_static_assert = 1 / ( int ) ( ! ! ( c ) ) } ; } <nl> + MEM_STATIC void MEM_check ( void ) { MEM_STATIC_ASSERT ( ( sizeof ( size_t ) = = 4 ) | | ( sizeof ( size_t ) = = 8 ) ) ; } <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Basic Types <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # if ! defined ( __VMS ) & & ( defined ( __cplusplus ) | | ( defined ( __STDC_VERSION__ ) & & ( __STDC_VERSION__ > = 199901L ) / * C99 * / ) ) <nl> + # include < stdint . h > <nl> + typedef uint8_t BYTE ; <nl> + typedef uint16_t U16 ; <nl> + typedef int16_t S16 ; <nl> + typedef uint32_t U32 ; <nl> + typedef int32_t S32 ; <nl> + typedef uint64_t U64 ; <nl> + typedef int64_t S64 ; <nl> + typedef intptr_t iPtrDiff ; <nl> + typedef uintptr_t uPtrDiff ; <nl> + # else <nl> + typedef unsigned char BYTE ; <nl> + typedef unsigned short U16 ; <nl> + typedef signed short S16 ; <nl> + typedef unsigned int U32 ; <nl> + typedef signed int S32 ; <nl> + typedef unsigned long long U64 ; <nl> + typedef signed long long S64 ; <nl> + typedef ptrdiff_t iPtrDiff ; <nl> + typedef size_t uPtrDiff ; <nl> + # endif <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Memory I / O <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * MEM_FORCE_MEMORY_ACCESS : <nl> + * By default , access to unaligned memory is controlled by ` memcpy ( ) ` , which is safe and portable . <nl> + * Unfortunately , on some target / compiler combinations , the generated assembly is sub - optimal . <nl> + * The below switch allow to select different access method for improved performance . <nl> + * Method 0 ( default ) : use ` memcpy ( ) ` . Safe and portable . <nl> + * Method 1 : ` __packed ` statement . It depends on compiler extension ( i . e . , not portable ) . <nl> + * This method is safe if your compiler supports it , and * generally * as fast or faster than ` memcpy ` . <nl> + * Method 2 : direct access . This method is portable but violate C standard . <nl> + * It can generate buggy code on targets depending on alignment . <nl> + * In some circumstances , it ' s the only known way to get the most performance ( i . e . GCC + ARMv6 ) <nl> + * See http : / / fastcompression . blogspot . fr / 2015 / 08 / accessing - unaligned - memory . html for details . <nl> + * Prefer these methods in priority order ( 0 > 1 > 2 ) <nl> + * / <nl> + # ifndef MEM_FORCE_MEMORY_ACCESS / * can be defined externally , on command line for example * / <nl> + # if defined ( __GNUC__ ) & & ( defined ( __ARM_ARCH_6__ ) | | defined ( __ARM_ARCH_6J__ ) | | defined ( __ARM_ARCH_6K__ ) | | defined ( __ARM_ARCH_6Z__ ) | | defined ( __ARM_ARCH_6ZK__ ) | | defined ( __ARM_ARCH_6T2__ ) ) <nl> + # define MEM_FORCE_MEMORY_ACCESS 2 <nl> + # elif defined ( __INTEL_COMPILER ) | | defined ( __GNUC__ ) <nl> + # define MEM_FORCE_MEMORY_ACCESS 1 <nl> + # endif <nl> + # endif <nl> + <nl> + MEM_STATIC unsigned MEM_32bits ( void ) { return sizeof ( size_t ) = = 4 ; } <nl> + MEM_STATIC unsigned MEM_64bits ( void ) { return sizeof ( size_t ) = = 8 ; } <nl> + <nl> + MEM_STATIC unsigned MEM_isLittleEndian ( void ) <nl> + { <nl> + const union { U32 u ; BYTE c [ 4 ] ; } one = { 1 } ; / * don ' t use static : performance detrimental * / <nl> + return one . c [ 0 ] ; <nl> + } <nl> + <nl> + # if defined ( MEM_FORCE_MEMORY_ACCESS ) & & ( MEM_FORCE_MEMORY_ACCESS = = 2 ) <nl> + <nl> + / * violates C standard , by lying on structure alignment . <nl> + Only use if no other choice to achieve best performance on target platform * / <nl> + MEM_STATIC U16 MEM_read16 ( const void * memPtr ) { return * ( const U16 * ) memPtr ; } <nl> + MEM_STATIC U32 MEM_read32 ( const void * memPtr ) { return * ( const U32 * ) memPtr ; } <nl> + MEM_STATIC U64 MEM_read64 ( const void * memPtr ) { return * ( const U64 * ) memPtr ; } <nl> + MEM_STATIC U64 MEM_readST ( const void * memPtr ) { return * ( const size_t * ) memPtr ; } <nl> + <nl> + MEM_STATIC void MEM_write16 ( void * memPtr , U16 value ) { * ( U16 * ) memPtr = value ; } <nl> + MEM_STATIC void MEM_write32 ( void * memPtr , U32 value ) { * ( U32 * ) memPtr = value ; } <nl> + MEM_STATIC void MEM_write64 ( void * memPtr , U64 value ) { * ( U64 * ) memPtr = value ; } <nl> + <nl> + # elif defined ( MEM_FORCE_MEMORY_ACCESS ) & & ( MEM_FORCE_MEMORY_ACCESS = = 1 ) <nl> + <nl> + / * __pack instructions are safer , but compiler specific , hence potentially problematic for some compilers * / <nl> + / * currently only defined for gcc and icc * / <nl> + # if defined ( _MSC_VER ) | | ( defined ( __INTEL_COMPILER ) & & defined ( WIN32 ) ) <nl> + __pragma ( pack ( push , 1 ) ) <nl> + typedef union { U16 u16 ; U32 u32 ; U64 u64 ; size_t st ; } unalign ; <nl> + __pragma ( pack ( pop ) ) <nl> + # else <nl> + typedef union { U16 u16 ; U32 u32 ; U64 u64 ; size_t st ; } __attribute__ ( ( packed ) ) unalign ; <nl> + # endif <nl> + <nl> + MEM_STATIC U16 MEM_read16 ( const void * ptr ) { return ( ( const unalign * ) ptr ) - > u16 ; } <nl> + MEM_STATIC U32 MEM_read32 ( const void * ptr ) { return ( ( const unalign * ) ptr ) - > u32 ; } <nl> + MEM_STATIC U64 MEM_read64 ( const void * ptr ) { return ( ( const unalign * ) ptr ) - > u64 ; } <nl> + MEM_STATIC U64 MEM_readST ( const void * ptr ) { return ( ( const unalign * ) ptr ) - > st ; } <nl> + <nl> + MEM_STATIC void MEM_write16 ( void * memPtr , U16 value ) { ( ( unalign * ) memPtr ) - > u16 = value ; } <nl> + MEM_STATIC void MEM_write32 ( void * memPtr , U32 value ) { ( ( unalign * ) memPtr ) - > u32 = value ; } <nl> + MEM_STATIC void MEM_write64 ( void * memPtr , U64 value ) { ( ( unalign * ) memPtr ) - > u64 = value ; } <nl> + <nl> + # else <nl> + <nl> + / * default method , safe and standard . <nl> + can sometimes prove slower * / <nl> + <nl> + MEM_STATIC U16 MEM_read16 ( const void * memPtr ) <nl> + { <nl> + U16 val ; memcpy ( & val , memPtr , sizeof ( val ) ) ; return val ; <nl> + } <nl> + <nl> + MEM_STATIC U32 MEM_read32 ( const void * memPtr ) <nl> + { <nl> + U32 val ; memcpy ( & val , memPtr , sizeof ( val ) ) ; return val ; <nl> + } <nl> + <nl> + MEM_STATIC U64 MEM_read64 ( const void * memPtr ) <nl> + { <nl> + U64 val ; memcpy ( & val , memPtr , sizeof ( val ) ) ; return val ; <nl> + } <nl> + <nl> + MEM_STATIC size_t MEM_readST ( const void * memPtr ) <nl> + { <nl> + size_t val ; memcpy ( & val , memPtr , sizeof ( val ) ) ; return val ; <nl> + } <nl> + <nl> + MEM_STATIC void MEM_write16 ( void * memPtr , U16 value ) <nl> + { <nl> + memcpy ( memPtr , & value , sizeof ( value ) ) ; <nl> + } <nl> + <nl> + MEM_STATIC void MEM_write32 ( void * memPtr , U32 value ) <nl> + { <nl> + memcpy ( memPtr , & value , sizeof ( value ) ) ; <nl> + } <nl> + <nl> + MEM_STATIC void MEM_write64 ( void * memPtr , U64 value ) <nl> + { <nl> + memcpy ( memPtr , & value , sizeof ( value ) ) ; <nl> + } <nl> + <nl> + # endif / * MEM_FORCE_MEMORY_ACCESS * / <nl> + <nl> + MEM_STATIC U32 MEM_swap32 ( U32 in ) <nl> + { <nl> + # if defined ( _MSC_VER ) / * Visual Studio * / <nl> + return _byteswap_ulong ( in ) ; <nl> + # elif defined ( __GNUC__ ) & & ( __GNUC__ * 100 + __GNUC_MINOR__ > = 403 ) <nl> + return __builtin_bswap32 ( in ) ; <nl> + # else <nl> + return ( ( in < < 24 ) & 0xff000000 ) | <nl> + ( ( in < < 8 ) & 0x00ff0000 ) | <nl> + ( ( in > > 8 ) & 0x0000ff00 ) | <nl> + ( ( in > > 24 ) & 0x000000ff ) ; <nl> + # endif <nl> + } <nl> + <nl> + MEM_STATIC U64 MEM_swap64 ( U64 in ) <nl> + { <nl> + # if defined ( _MSC_VER ) / * Visual Studio * / <nl> + return _byteswap_uint64 ( in ) ; <nl> + # elif defined ( __GNUC__ ) & & ( __GNUC__ * 100 + __GNUC_MINOR__ > = 403 ) <nl> + return __builtin_bswap64 ( in ) ; <nl> + # else <nl> + return ( ( in < < 56 ) & 0xff00000000000000ULL ) | <nl> + ( ( in < < 40 ) & 0x00ff000000000000ULL ) | <nl> + ( ( in < < 24 ) & 0x0000ff0000000000ULL ) | <nl> + ( ( in < < 8 ) & 0x000000ff00000000ULL ) | <nl> + ( ( in > > 8 ) & 0x00000000ff000000ULL ) | <nl> + ( ( in > > 24 ) & 0x0000000000ff0000ULL ) | <nl> + ( ( in > > 40 ) & 0x000000000000ff00ULL ) | <nl> + ( ( in > > 56 ) & 0x00000000000000ffULL ) ; <nl> + # endif <nl> + } <nl> + <nl> + MEM_STATIC size_t MEM_swapST ( size_t in ) <nl> + { <nl> + if ( MEM_32bits ( ) ) <nl> + return ( size_t ) MEM_swap32 ( ( U32 ) in ) ; <nl> + else <nl> + return ( size_t ) MEM_swap64 ( ( U64 ) in ) ; <nl> + } <nl> + <nl> + / * = = = Little endian r / w = = = * / <nl> + <nl> + MEM_STATIC U16 MEM_readLE16 ( const void * memPtr ) <nl> + { <nl> + if ( MEM_isLittleEndian ( ) ) <nl> + return MEM_read16 ( memPtr ) ; <nl> + else { <nl> + const BYTE * p = ( const BYTE * ) memPtr ; <nl> + return ( U16 ) ( p [ 0 ] + ( p [ 1 ] < < 8 ) ) ; <nl> + } <nl> + } <nl> + <nl> + MEM_STATIC void MEM_writeLE16 ( void * memPtr , U16 val ) <nl> + { <nl> + if ( MEM_isLittleEndian ( ) ) { <nl> + MEM_write16 ( memPtr , val ) ; <nl> + } else { <nl> + BYTE * p = ( BYTE * ) memPtr ; <nl> + p [ 0 ] = ( BYTE ) val ; <nl> + p [ 1 ] = ( BYTE ) ( val > > 8 ) ; <nl> + } <nl> + } <nl> + <nl> + MEM_STATIC U32 MEM_readLE24 ( const void * memPtr ) <nl> + { <nl> + return MEM_readLE16 ( memPtr ) + ( ( ( const BYTE * ) memPtr ) [ 2 ] < < 16 ) ; <nl> + } <nl> + <nl> + MEM_STATIC void MEM_writeLE24 ( void * memPtr , U32 val ) <nl> + { <nl> + MEM_writeLE16 ( memPtr , ( U16 ) val ) ; <nl> + ( ( BYTE * ) memPtr ) [ 2 ] = ( BYTE ) ( val > > 16 ) ; <nl> + } <nl> + <nl> + MEM_STATIC U32 MEM_readLE32 ( const void * memPtr ) <nl> + { <nl> + if ( MEM_isLittleEndian ( ) ) <nl> + return MEM_read32 ( memPtr ) ; <nl> + else <nl> + return MEM_swap32 ( MEM_read32 ( memPtr ) ) ; <nl> + } <nl> + <nl> + MEM_STATIC void MEM_writeLE32 ( void * memPtr , U32 val32 ) <nl> + { <nl> + if ( MEM_isLittleEndian ( ) ) <nl> + MEM_write32 ( memPtr , val32 ) ; <nl> + else <nl> + MEM_write32 ( memPtr , MEM_swap32 ( val32 ) ) ; <nl> + } <nl> + <nl> + MEM_STATIC U64 MEM_readLE64 ( const void * memPtr ) <nl> + { <nl> + if ( MEM_isLittleEndian ( ) ) <nl> + return MEM_read64 ( memPtr ) ; <nl> + else <nl> + return MEM_swap64 ( MEM_read64 ( memPtr ) ) ; <nl> + } <nl> + <nl> + MEM_STATIC void MEM_writeLE64 ( void * memPtr , U64 val64 ) <nl> + { <nl> + if ( MEM_isLittleEndian ( ) ) <nl> + MEM_write64 ( memPtr , val64 ) ; <nl> + else <nl> + MEM_write64 ( memPtr , MEM_swap64 ( val64 ) ) ; <nl> + } <nl> + <nl> + MEM_STATIC size_t MEM_readLEST ( const void * memPtr ) <nl> + { <nl> + if ( MEM_32bits ( ) ) <nl> + return ( size_t ) MEM_readLE32 ( memPtr ) ; <nl> + else <nl> + return ( size_t ) MEM_readLE64 ( memPtr ) ; <nl> + } <nl> + <nl> + MEM_STATIC void MEM_writeLEST ( void * memPtr , size_t val ) <nl> + { <nl> + if ( MEM_32bits ( ) ) <nl> + MEM_writeLE32 ( memPtr , ( U32 ) val ) ; <nl> + else <nl> + MEM_writeLE64 ( memPtr , ( U64 ) val ) ; <nl> + } <nl> + <nl> + / * = = = Big endian r / w = = = * / <nl> + <nl> + MEM_STATIC U32 MEM_readBE32 ( const void * memPtr ) <nl> + { <nl> + if ( MEM_isLittleEndian ( ) ) <nl> + return MEM_swap32 ( MEM_read32 ( memPtr ) ) ; <nl> + else <nl> + return MEM_read32 ( memPtr ) ; <nl> + } <nl> + <nl> + MEM_STATIC void MEM_writeBE32 ( void * memPtr , U32 val32 ) <nl> + { <nl> + if ( MEM_isLittleEndian ( ) ) <nl> + MEM_write32 ( memPtr , MEM_swap32 ( val32 ) ) ; <nl> + else <nl> + MEM_write32 ( memPtr , val32 ) ; <nl> + } <nl> + <nl> + MEM_STATIC U64 MEM_readBE64 ( const void * memPtr ) <nl> + { <nl> + if ( MEM_isLittleEndian ( ) ) <nl> + return MEM_swap64 ( MEM_read64 ( memPtr ) ) ; <nl> + else <nl> + return MEM_read64 ( memPtr ) ; <nl> + } <nl> + <nl> + MEM_STATIC void MEM_writeBE64 ( void * memPtr , U64 val64 ) <nl> + { <nl> + if ( MEM_isLittleEndian ( ) ) <nl> + MEM_write64 ( memPtr , MEM_swap64 ( val64 ) ) ; <nl> + else <nl> + MEM_write64 ( memPtr , val64 ) ; <nl> + } <nl> + <nl> + MEM_STATIC size_t MEM_readBEST ( const void * memPtr ) <nl> + { <nl> + if ( MEM_32bits ( ) ) <nl> + return ( size_t ) MEM_readBE32 ( memPtr ) ; <nl> + else <nl> + return ( size_t ) MEM_readBE64 ( memPtr ) ; <nl> + } <nl> + <nl> + MEM_STATIC void MEM_writeBEST ( void * memPtr , size_t val ) <nl> + { <nl> + if ( MEM_32bits ( ) ) <nl> + MEM_writeBE32 ( memPtr , ( U32 ) val ) ; <nl> + else <nl> + MEM_writeBE64 ( memPtr , ( U64 ) val ) ; <nl> + } <nl> + <nl> + <nl> + / * function safe only for comparisons * / <nl> + MEM_STATIC U32 MEM_readMINMATCH ( const void * memPtr , U32 length ) <nl> + { <nl> + switch ( length ) <nl> + { <nl> + default : <nl> + case 4 : return MEM_read32 ( memPtr ) ; <nl> + case 3 : if ( MEM_isLittleEndian ( ) ) <nl> + return MEM_read32 ( memPtr ) < < 8 ; <nl> + else <nl> + return MEM_read32 ( memPtr ) > > 8 ; <nl> + } <nl> + } <nl> + <nl> + # if defined ( __cplusplus ) <nl> + } <nl> + # endif <nl> + <nl> + # endif / * MEM_H_MODULE * / <nl> new file mode 100644 <nl> index 00000000000 . . e439fe1b0dd <nl> mmm / dev / null <nl> ppp b / thirdparty / zstd / common / pool . c <nl> <nl> + / * * <nl> + * Copyright ( c ) 2016 - present , Facebook , Inc . <nl> + * All rights reserved . <nl> + * <nl> + * This source code is licensed under the BSD - style license found in the <nl> + * LICENSE file in the root directory of this source tree . An additional grant <nl> + * of patent rights can be found in the PATENTS file in the same directory . <nl> + * / <nl> + <nl> + <nl> + / * = = = = = = Dependencies = = = = = = = * / <nl> + # include < stddef . h > / * size_t * / <nl> + # include < stdlib . h > / * malloc , calloc , free * / <nl> + # include " pool . h " <nl> + <nl> + / * = = = = = = Compiler specifics = = = = = = * / <nl> + # if defined ( _MSC_VER ) <nl> + # pragma warning ( disable : 4204 ) / * disable : C4204 : non - constant aggregate initializer * / <nl> + # endif <nl> + <nl> + <nl> + # ifdef ZSTD_MULTITHREAD <nl> + <nl> + # include " threading . h " / * pthread adaptation * / <nl> + <nl> + / * A job is a function and an opaque argument * / <nl> + typedef struct POOL_job_s { <nl> + POOL_function function ; <nl> + void * opaque ; <nl> + } POOL_job ; <nl> + <nl> + struct POOL_ctx_s { <nl> + / * Keep track of the threads * / <nl> + pthread_t * threads ; <nl> + size_t numThreads ; <nl> + <nl> + / * The queue is a circular buffer * / <nl> + POOL_job * queue ; <nl> + size_t queueHead ; <nl> + size_t queueTail ; <nl> + size_t queueSize ; <nl> + / * The mutex protects the queue * / <nl> + pthread_mutex_t queueMutex ; <nl> + / * Condition variable for pushers to wait on when the queue is full * / <nl> + pthread_cond_t queuePushCond ; <nl> + / * Condition variables for poppers to wait on when the queue is empty * / <nl> + pthread_cond_t queuePopCond ; <nl> + / * Indicates if the queue is shutting down * / <nl> + int shutdown ; <nl> + } ; <nl> + <nl> + / * POOL_thread ( ) : <nl> + Work thread for the thread pool . <nl> + Waits for jobs and executes them . <nl> + @ returns : NULL on failure else non - null . <nl> + * / <nl> + static void * POOL_thread ( void * opaque ) { <nl> + POOL_ctx * const ctx = ( POOL_ctx * ) opaque ; <nl> + if ( ! ctx ) { return NULL ; } <nl> + for ( ; ; ) { <nl> + / * Lock the mutex and wait for a non - empty queue or until shutdown * / <nl> + pthread_mutex_lock ( & ctx - > queueMutex ) ; <nl> + while ( ctx - > queueHead = = ctx - > queueTail & & ! ctx - > shutdown ) { <nl> + pthread_cond_wait ( & ctx - > queuePopCond , & ctx - > queueMutex ) ; <nl> + } <nl> + / * empty = > shutting down : so stop * / <nl> + if ( ctx - > queueHead = = ctx - > queueTail ) { <nl> + pthread_mutex_unlock ( & ctx - > queueMutex ) ; <nl> + return opaque ; <nl> + } <nl> + / * Pop a job off the queue * / <nl> + { POOL_job const job = ctx - > queue [ ctx - > queueHead ] ; <nl> + ctx - > queueHead = ( ctx - > queueHead + 1 ) % ctx - > queueSize ; <nl> + / * Unlock the mutex , signal a pusher , and run the job * / <nl> + pthread_mutex_unlock ( & ctx - > queueMutex ) ; <nl> + pthread_cond_signal ( & ctx - > queuePushCond ) ; <nl> + job . function ( job . opaque ) ; <nl> + } <nl> + } <nl> + / * Unreachable * / <nl> + } <nl> + <nl> + POOL_ctx * POOL_create ( size_t numThreads , size_t queueSize ) { <nl> + POOL_ctx * ctx ; <nl> + / * Check the parameters * / <nl> + if ( ! numThreads | | ! queueSize ) { return NULL ; } <nl> + / * Allocate the context and zero initialize * / <nl> + ctx = ( POOL_ctx * ) calloc ( 1 , sizeof ( POOL_ctx ) ) ; <nl> + if ( ! ctx ) { return NULL ; } <nl> + / * Initialize the job queue . <nl> + * It needs one extra space since one space is wasted to differentiate empty <nl> + * and full queues . <nl> + * / <nl> + ctx - > queueSize = queueSize + 1 ; <nl> + ctx - > queue = ( POOL_job * ) malloc ( ctx - > queueSize * sizeof ( POOL_job ) ) ; <nl> + ctx - > queueHead = 0 ; <nl> + ctx - > queueTail = 0 ; <nl> + pthread_mutex_init ( & ctx - > queueMutex , NULL ) ; <nl> + pthread_cond_init ( & ctx - > queuePushCond , NULL ) ; <nl> + pthread_cond_init ( & ctx - > queuePopCond , NULL ) ; <nl> + ctx - > shutdown = 0 ; <nl> + / * Allocate space for the thread handles * / <nl> + ctx - > threads = ( pthread_t * ) malloc ( numThreads * sizeof ( pthread_t ) ) ; <nl> + ctx - > numThreads = 0 ; <nl> + / * Check for errors * / <nl> + if ( ! ctx - > threads | | ! ctx - > queue ) { POOL_free ( ctx ) ; return NULL ; } <nl> + / * Initialize the threads * / <nl> + { size_t i ; <nl> + for ( i = 0 ; i < numThreads ; + + i ) { <nl> + if ( pthread_create ( & ctx - > threads [ i ] , NULL , & POOL_thread , ctx ) ) { <nl> + ctx - > numThreads = i ; <nl> + POOL_free ( ctx ) ; <nl> + return NULL ; <nl> + } } <nl> + ctx - > numThreads = numThreads ; <nl> + } <nl> + return ctx ; <nl> + } <nl> + <nl> + / * ! POOL_join ( ) : <nl> + Shutdown the queue , wake any sleeping threads , and join all of the threads . <nl> + * / <nl> + static void POOL_join ( POOL_ctx * ctx ) { <nl> + / * Shut down the queue * / <nl> + pthread_mutex_lock ( & ctx - > queueMutex ) ; <nl> + ctx - > shutdown = 1 ; <nl> + pthread_mutex_unlock ( & ctx - > queueMutex ) ; <nl> + / * Wake up sleeping threads * / <nl> + pthread_cond_broadcast ( & ctx - > queuePushCond ) ; <nl> + pthread_cond_broadcast ( & ctx - > queuePopCond ) ; <nl> + / * Join all of the threads * / <nl> + { size_t i ; <nl> + for ( i = 0 ; i < ctx - > numThreads ; + + i ) { <nl> + pthread_join ( ctx - > threads [ i ] , NULL ) ; <nl> + } } <nl> + } <nl> + <nl> + void POOL_free ( POOL_ctx * ctx ) { <nl> + if ( ! ctx ) { return ; } <nl> + POOL_join ( ctx ) ; <nl> + pthread_mutex_destroy ( & ctx - > queueMutex ) ; <nl> + pthread_cond_destroy ( & ctx - > queuePushCond ) ; <nl> + pthread_cond_destroy ( & ctx - > queuePopCond ) ; <nl> + if ( ctx - > queue ) free ( ctx - > queue ) ; <nl> + if ( ctx - > threads ) free ( ctx - > threads ) ; <nl> + free ( ctx ) ; <nl> + } <nl> + <nl> + void POOL_add ( void * ctxVoid , POOL_function function , void * opaque ) { <nl> + POOL_ctx * ctx = ( POOL_ctx * ) ctxVoid ; <nl> + if ( ! ctx ) { return ; } <nl> + <nl> + pthread_mutex_lock ( & ctx - > queueMutex ) ; <nl> + { POOL_job const job = { function , opaque } ; <nl> + / * Wait until there is space in the queue for the new job * / <nl> + size_t newTail = ( ctx - > queueTail + 1 ) % ctx - > queueSize ; <nl> + while ( ctx - > queueHead = = newTail & & ! ctx - > shutdown ) { <nl> + pthread_cond_wait ( & ctx - > queuePushCond , & ctx - > queueMutex ) ; <nl> + newTail = ( ctx - > queueTail + 1 ) % ctx - > queueSize ; <nl> + } <nl> + / * The queue is still going = > there is space * / <nl> + if ( ! ctx - > shutdown ) { <nl> + ctx - > queue [ ctx - > queueTail ] = job ; <nl> + ctx - > queueTail = newTail ; <nl> + } <nl> + } <nl> + pthread_mutex_unlock ( & ctx - > queueMutex ) ; <nl> + pthread_cond_signal ( & ctx - > queuePopCond ) ; <nl> + } <nl> + <nl> + # else / * ZSTD_MULTITHREAD not defined * / <nl> + / * No multi - threading support * / <nl> + <nl> + / * We don ' t need any data , but if it is empty malloc ( ) might return NULL . * / <nl> + struct POOL_ctx_s { <nl> + int data ; <nl> + } ; <nl> + <nl> + POOL_ctx * POOL_create ( size_t numThreads , size_t queueSize ) { <nl> + ( void ) numThreads ; <nl> + ( void ) queueSize ; <nl> + return ( POOL_ctx * ) malloc ( sizeof ( POOL_ctx ) ) ; <nl> + } <nl> + <nl> + void POOL_free ( POOL_ctx * ctx ) { <nl> + if ( ctx ) free ( ctx ) ; <nl> + } <nl> + <nl> + void POOL_add ( void * ctx , POOL_function function , void * opaque ) { <nl> + ( void ) ctx ; <nl> + function ( opaque ) ; <nl> + } <nl> + <nl> + # endif / * ZSTD_MULTITHREAD * / <nl> new file mode 100644 <nl> index 00000000000 . . 50cb25b12c9 <nl> mmm / dev / null <nl> ppp b / thirdparty / zstd / common / pool . h <nl> <nl> + / * * <nl> + * Copyright ( c ) 2016 - present , Facebook , Inc . <nl> + * All rights reserved . <nl> + * <nl> + * This source code is licensed under the BSD - style license found in the <nl> + * LICENSE file in the root directory of this source tree . An additional grant <nl> + * of patent rights can be found in the PATENTS file in the same directory . <nl> + * / <nl> + # ifndef POOL_H <nl> + # define POOL_H <nl> + <nl> + # if defined ( __cplusplus ) <nl> + extern " C " { <nl> + # endif <nl> + <nl> + <nl> + # include < stddef . h > / * size_t * / <nl> + <nl> + typedef struct POOL_ctx_s POOL_ctx ; <nl> + <nl> + / * ! POOL_create ( ) : <nl> + Create a thread pool with at most ` numThreads ` threads . <nl> + ` numThreads ` must be at least 1 . <nl> + The maximum number of queued jobs before blocking is ` queueSize ` . <nl> + ` queueSize ` must be at least 1 . <nl> + @ return : The POOL_ctx pointer on success else NULL . <nl> + * / <nl> + POOL_ctx * POOL_create ( size_t numThreads , size_t queueSize ) ; <nl> + <nl> + / * ! POOL_free ( ) : <nl> + Free a thread pool returned by POOL_create ( ) . <nl> + * / <nl> + void POOL_free ( POOL_ctx * ctx ) ; <nl> + <nl> + / * ! POOL_function : <nl> + The function type that can be added to a thread pool . <nl> + * / <nl> + typedef void ( * POOL_function ) ( void * ) ; <nl> + / * ! POOL_add_function : <nl> + The function type for a generic thread pool add function . <nl> + * / <nl> + typedef void ( * POOL_add_function ) ( void * , POOL_function , void * ) ; <nl> + <nl> + / * ! POOL_add ( ) : <nl> + Add the job ` function ( opaque ) ` to the thread pool . <nl> + Possibly blocks until there is room in the queue . <nl> + Note : The function may be executed asynchronously , so ` opaque ` must live until the function has been completed . <nl> + * / <nl> + void POOL_add ( void * ctx , POOL_function function , void * opaque ) ; <nl> + <nl> + <nl> + # if defined ( __cplusplus ) <nl> + } <nl> + # endif <nl> + <nl> + # endif <nl> new file mode 100644 <nl> index 00000000000 . . 32d58796a9e <nl> mmm / dev / null <nl> ppp b / thirdparty / zstd / common / threading . c <nl> <nl> + <nl> + / * * <nl> + * Copyright ( c ) 2016 Tino Reichardt <nl> + * All rights reserved . <nl> + * <nl> + * This source code is licensed under the BSD - style license found in the <nl> + * LICENSE file in the root directory of this source tree . An additional grant <nl> + * of patent rights can be found in the PATENTS file in the same directory . <nl> + * <nl> + * You can contact the author at : <nl> + * - zstdmt source repository : https : / / github . com / mcmilk / zstdmt <nl> + * / <nl> + <nl> + / * * <nl> + * This file will hold wrapper for systems , which do not support pthreads <nl> + * / <nl> + <nl> + / * When ZSTD_MULTITHREAD is not defined , this file would become an empty translation unit . <nl> + * Include some ISO C header code to prevent this and portably avoid related warnings . <nl> + * ( Visual C + + : C4206 / GCC : - Wpedantic / Clang : - Wempty - translation - unit ) <nl> + * / <nl> + # include < stddef . h > <nl> + <nl> + <nl> + # if defined ( ZSTD_MULTITHREAD ) & & defined ( _WIN32 ) <nl> + <nl> + / * * <nl> + * Windows minimalist Pthread Wrapper , based on : <nl> + * http : / / www . cse . wustl . edu / ~ schmidt / win32 - cv - 1 . html <nl> + * / <nl> + <nl> + <nl> + / * = = = Dependencies = = = * / <nl> + # include < process . h > <nl> + # include < errno . h > <nl> + # include " threading . h " <nl> + <nl> + <nl> + / * = = = Implementation = = = * / <nl> + <nl> + static unsigned __stdcall worker ( void * arg ) <nl> + { <nl> + pthread_t * const thread = ( pthread_t * ) arg ; <nl> + thread - > arg = thread - > start_routine ( thread - > arg ) ; <nl> + return 0 ; <nl> + } <nl> + <nl> + int pthread_create ( pthread_t * thread , const void * unused , <nl> + void * ( * start_routine ) ( void * ) , void * arg ) <nl> + { <nl> + ( void ) unused ; <nl> + thread - > arg = arg ; <nl> + thread - > start_routine = start_routine ; <nl> + thread - > handle = ( HANDLE ) _beginthreadex ( NULL , 0 , worker , thread , 0 , NULL ) ; <nl> + <nl> + if ( ! thread - > handle ) <nl> + return errno ; <nl> + else <nl> + return 0 ; <nl> + } <nl> + <nl> + int _pthread_join ( pthread_t * thread , void * * value_ptr ) <nl> + { <nl> + DWORD result ; <nl> + <nl> + if ( ! thread - > handle ) return 0 ; <nl> + <nl> + result = WaitForSingleObject ( thread - > handle , INFINITE ) ; <nl> + switch ( result ) { <nl> + case WAIT_OBJECT_0 : <nl> + if ( value_ptr ) * value_ptr = thread - > arg ; <nl> + return 0 ; <nl> + case WAIT_ABANDONED : <nl> + return EINVAL ; <nl> + default : <nl> + return GetLastError ( ) ; <nl> + } <nl> + } <nl> + <nl> + # endif / * ZSTD_MULTITHREAD * / <nl> new file mode 100644 <nl> index 00000000000 . . c0086139ea3 <nl> mmm / dev / null <nl> ppp b / thirdparty / zstd / common / threading . h <nl> <nl> + <nl> + / * * <nl> + * Copyright ( c ) 2016 Tino Reichardt <nl> + * All rights reserved . <nl> + * <nl> + * This source code is licensed under the BSD - style license found in the <nl> + * LICENSE file in the root directory of this source tree . An additional grant <nl> + * of patent rights can be found in the PATENTS file in the same directory . <nl> + * <nl> + * You can contact the author at : <nl> + * - zstdmt source repository : https : / / github . com / mcmilk / zstdmt <nl> + * / <nl> + <nl> + # ifndef THREADING_H_938743 <nl> + # define THREADING_H_938743 <nl> + <nl> + # if defined ( __cplusplus ) <nl> + extern " C " { <nl> + # endif <nl> + <nl> + # if defined ( ZSTD_MULTITHREAD ) & & defined ( _WIN32 ) <nl> + <nl> + / * * <nl> + * Windows minimalist Pthread Wrapper , based on : <nl> + * http : / / www . cse . wustl . edu / ~ schmidt / win32 - cv - 1 . html <nl> + * / <nl> + # ifdef WINVER <nl> + # undef WINVER <nl> + # endif <nl> + # define WINVER 0x0600 <nl> + <nl> + # ifdef _WIN32_WINNT <nl> + # undef _WIN32_WINNT <nl> + # endif <nl> + # define _WIN32_WINNT 0x0600 <nl> + <nl> + # ifndef WIN32_LEAN_AND_MEAN <nl> + # define WIN32_LEAN_AND_MEAN <nl> + # endif <nl> + <nl> + # include < windows . h > <nl> + <nl> + / * mutex * / <nl> + # define pthread_mutex_t CRITICAL_SECTION <nl> + # define pthread_mutex_init ( a , b ) InitializeCriticalSection ( ( a ) ) <nl> + # define pthread_mutex_destroy ( a ) DeleteCriticalSection ( ( a ) ) <nl> + # define pthread_mutex_lock ( a ) EnterCriticalSection ( ( a ) ) <nl> + # define pthread_mutex_unlock ( a ) LeaveCriticalSection ( ( a ) ) <nl> + <nl> + / * condition variable * / <nl> + # define pthread_cond_t CONDITION_VARIABLE <nl> + # define pthread_cond_init ( a , b ) InitializeConditionVariable ( ( a ) ) <nl> + # define pthread_cond_destroy ( a ) / * No delete * / <nl> + # define pthread_cond_wait ( a , b ) SleepConditionVariableCS ( ( a ) , ( b ) , INFINITE ) <nl> + # define pthread_cond_signal ( a ) WakeConditionVariable ( ( a ) ) <nl> + # define pthread_cond_broadcast ( a ) WakeAllConditionVariable ( ( a ) ) <nl> + <nl> + / * pthread_create ( ) and pthread_join ( ) * / <nl> + typedef struct { <nl> + HANDLE handle ; <nl> + void * ( * start_routine ) ( void * ) ; <nl> + void * arg ; <nl> + } pthread_t ; <nl> + <nl> + int pthread_create ( pthread_t * thread , const void * unused , <nl> + void * ( * start_routine ) ( void * ) , void * arg ) ; <nl> + <nl> + # define pthread_join ( a , b ) _pthread_join ( & ( a ) , ( b ) ) <nl> + int _pthread_join ( pthread_t * thread , void * * value_ptr ) ; <nl> + <nl> + / * * <nl> + * add here more wrappers as required <nl> + * / <nl> + <nl> + <nl> + # elif defined ( ZSTD_MULTITHREAD ) / * posix assumed ; need a better detection method * / <nl> + / * = = = POSIX Systems = = = * / <nl> + # include < pthread . h > <nl> + <nl> + # else / * ZSTD_MULTITHREAD not defined * / <nl> + / * No multithreading support * / <nl> + <nl> + # define pthread_mutex_t int / * # define rather than typedef , as sometimes pthread support is implicit , resulting in duplicated symbols * / <nl> + # define pthread_mutex_init ( a , b ) <nl> + # define pthread_mutex_destroy ( a ) <nl> + # define pthread_mutex_lock ( a ) <nl> + # define pthread_mutex_unlock ( a ) <nl> + <nl> + # define pthread_cond_t int <nl> + # define pthread_cond_init ( a , b ) <nl> + # define pthread_cond_destroy ( a ) <nl> + # define pthread_cond_wait ( a , b ) <nl> + # define pthread_cond_signal ( a ) <nl> + # define pthread_cond_broadcast ( a ) <nl> + <nl> + / * do not use pthread_t * / <nl> + <nl> + # endif / * ZSTD_MULTITHREAD * / <nl> + <nl> + # if defined ( __cplusplus ) <nl> + } <nl> + # endif <nl> + <nl> + # endif / * THREADING_H_938743 * / <nl> new file mode 100644 <nl> index 00000000000 . . eb44222c5fc <nl> mmm / dev / null <nl> ppp b / thirdparty / zstd / common / xxhash . c <nl> <nl> + / * <nl> + * xxHash - Fast Hash algorithm <nl> + * Copyright ( C ) 2012 - 2016 , Yann Collet <nl> + * <nl> + * BSD 2 - Clause License ( http : / / www . opensource . org / licenses / bsd - license . php ) <nl> + * <nl> + * Redistribution and use in source and binary forms , with or without <nl> + * modification , are permitted provided that the following conditions are <nl> + * met : <nl> + * <nl> + * * Redistributions of source code must retain the above copyright <nl> + * notice , this list of conditions and the following disclaimer . <nl> + * * Redistributions in binary form must reproduce the above <nl> + * copyright notice , this list of conditions and the following disclaimer <nl> + * in the documentation and / or other materials provided with the <nl> + * distribution . <nl> + * <nl> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + * " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + * LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + * A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + * SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + * LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + * DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + * THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + * ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + * OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + * <nl> + * You can contact the author at : <nl> + * - xxHash homepage : http : / / www . xxhash . com <nl> + * - xxHash source repository : https : / / github . com / Cyan4973 / xxHash <nl> + * / <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Tuning parameters <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * ! XXH_FORCE_MEMORY_ACCESS : <nl> + * By default , access to unaligned memory is controlled by ` memcpy ( ) ` , which is safe and portable . <nl> + * Unfortunately , on some target / compiler combinations , the generated assembly is sub - optimal . <nl> + * The below switch allow to select different access method for improved performance . <nl> + * Method 0 ( default ) : use ` memcpy ( ) ` . Safe and portable . <nl> + * Method 1 : ` __packed ` statement . It depends on compiler extension ( ie , not portable ) . <nl> + * This method is safe if your compiler supports it , and * generally * as fast or faster than ` memcpy ` . <nl> + * Method 2 : direct access . This method doesn ' t depend on compiler but violate C standard . <nl> + * It can generate buggy code on targets which do not support unaligned memory accesses . <nl> + * But in some circumstances , it ' s the only known way to get the most performance ( ie GCC + ARMv6 ) <nl> + * See http : / / stackoverflow . com / a / 32095106 / 646947 for details . <nl> + * Prefer these methods in priority order ( 0 > 1 > 2 ) <nl> + * / <nl> + # ifndef XXH_FORCE_MEMORY_ACCESS / * can be defined externally , on command line for example * / <nl> + # if defined ( __GNUC__ ) & & ( defined ( __ARM_ARCH_6__ ) | | defined ( __ARM_ARCH_6J__ ) | | defined ( __ARM_ARCH_6K__ ) | | defined ( __ARM_ARCH_6Z__ ) | | defined ( __ARM_ARCH_6ZK__ ) | | defined ( __ARM_ARCH_6T2__ ) ) <nl> + # define XXH_FORCE_MEMORY_ACCESS 2 <nl> + # elif ( defined ( __INTEL_COMPILER ) & & ! defined ( WIN32 ) ) | | \ <nl> + ( defined ( __GNUC__ ) & & ( defined ( __ARM_ARCH_7__ ) | | defined ( __ARM_ARCH_7A__ ) | | defined ( __ARM_ARCH_7R__ ) | | defined ( __ARM_ARCH_7M__ ) | | defined ( __ARM_ARCH_7S__ ) ) ) <nl> + # define XXH_FORCE_MEMORY_ACCESS 1 <nl> + # endif <nl> + # endif <nl> + <nl> + / * ! XXH_ACCEPT_NULL_INPUT_POINTER : <nl> + * If the input pointer is a null pointer , xxHash default behavior is to trigger a memory access error , since it is a bad pointer . <nl> + * When this option is enabled , xxHash output for null input pointers will be the same as a null - length input . <nl> + * By default , this option is disabled . To enable it , uncomment below define : <nl> + * / <nl> + / * # define XXH_ACCEPT_NULL_INPUT_POINTER 1 * / <nl> + <nl> + / * ! XXH_FORCE_NATIVE_FORMAT : <nl> + * By default , xxHash library provides endian - independant Hash values , based on little - endian convention . <nl> + * Results are therefore identical for little - endian and big - endian CPU . <nl> + * This comes at a performance cost for big - endian CPU , since some swapping is required to emulate little - endian format . <nl> + * Should endian - independance be of no importance for your application , you may set the # define below to 1 , <nl> + * to improve speed for Big - endian CPU . <nl> + * This option has no impact on Little_Endian CPU . <nl> + * / <nl> + # ifndef XXH_FORCE_NATIVE_FORMAT / * can be defined externally * / <nl> + # define XXH_FORCE_NATIVE_FORMAT 0 <nl> + # endif <nl> + <nl> + / * ! XXH_FORCE_ALIGN_CHECK : <nl> + * This is a minor performance trick , only useful with lots of very small keys . <nl> + * It means : check for aligned / unaligned input . <nl> + * The check costs one initial branch per hash ; set to 0 when the input data <nl> + * is guaranteed to be aligned . <nl> + * / <nl> + # ifndef XXH_FORCE_ALIGN_CHECK / * can be defined externally * / <nl> + # if defined ( __i386 ) | | defined ( _M_IX86 ) | | defined ( __x86_64__ ) | | defined ( _M_X64 ) <nl> + # define XXH_FORCE_ALIGN_CHECK 0 <nl> + # else <nl> + # define XXH_FORCE_ALIGN_CHECK 1 <nl> + # endif <nl> + # endif <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Includes & Memory related functions <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * Modify the local functions below should you wish to use some other memory routines * / <nl> + / * for malloc ( ) , free ( ) * / <nl> + # include < stdlib . h > <nl> + static void * XXH_malloc ( size_t s ) { return malloc ( s ) ; } <nl> + static void XXH_free ( void * p ) { free ( p ) ; } <nl> + / * for memcpy ( ) * / <nl> + # include < string . h > <nl> + static void * XXH_memcpy ( void * dest , const void * src , size_t size ) { return memcpy ( dest , src , size ) ; } <nl> + <nl> + # ifndef XXH_STATIC_LINKING_ONLY <nl> + # define XXH_STATIC_LINKING_ONLY <nl> + # endif <nl> + # include " xxhash . h " <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Compiler Specific Options <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # ifdef _MSC_VER / * Visual Studio * / <nl> + # pragma warning ( disable : 4127 ) / * disable : C4127 : conditional expression is constant * / <nl> + # define FORCE_INLINE static __forceinline <nl> + # else <nl> + # if defined ( __cplusplus ) | | defined ( __STDC_VERSION__ ) & & __STDC_VERSION__ > = 199901L / * C99 * / <nl> + # ifdef __GNUC__ <nl> + # define FORCE_INLINE static inline __attribute__ ( ( always_inline ) ) <nl> + # else <nl> + # define FORCE_INLINE static inline <nl> + # endif <nl> + # else <nl> + # define FORCE_INLINE static <nl> + # endif / * __STDC_VERSION__ * / <nl> + # endif <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Basic Types <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # ifndef MEM_MODULE <nl> + # define MEM_MODULE <nl> + # if ! defined ( __VMS ) & & ( defined ( __cplusplus ) | | ( defined ( __STDC_VERSION__ ) & & ( __STDC_VERSION__ > = 199901L ) / * C99 * / ) ) <nl> + # include < stdint . h > <nl> + typedef uint8_t BYTE ; <nl> + typedef uint16_t U16 ; <nl> + typedef uint32_t U32 ; <nl> + typedef int32_t S32 ; <nl> + typedef uint64_t U64 ; <nl> + # else <nl> + typedef unsigned char BYTE ; <nl> + typedef unsigned short U16 ; <nl> + typedef unsigned int U32 ; <nl> + typedef signed int S32 ; <nl> + typedef unsigned long long U64 ; / * if your compiler doesn ' t support unsigned long long , replace by another 64 - bit type here . Note that xxhash . h will also need to be updated . * / <nl> + # endif <nl> + # endif <nl> + <nl> + <nl> + # if ( defined ( XXH_FORCE_MEMORY_ACCESS ) & & ( XXH_FORCE_MEMORY_ACCESS = = 2 ) ) <nl> + <nl> + / * Force direct memory access . Only works on CPU which support unaligned memory access in hardware * / <nl> + static U32 XXH_read32 ( const void * memPtr ) { return * ( const U32 * ) memPtr ; } <nl> + static U64 XXH_read64 ( const void * memPtr ) { return * ( const U64 * ) memPtr ; } <nl> + <nl> + # elif ( defined ( XXH_FORCE_MEMORY_ACCESS ) & & ( XXH_FORCE_MEMORY_ACCESS = = 1 ) ) <nl> + <nl> + / * __pack instructions are safer , but compiler specific , hence potentially problematic for some compilers * / <nl> + / * currently only defined for gcc and icc * / <nl> + typedef union { U32 u32 ; U64 u64 ; } __attribute__ ( ( packed ) ) unalign ; <nl> + <nl> + static U32 XXH_read32 ( const void * ptr ) { return ( ( const unalign * ) ptr ) - > u32 ; } <nl> + static U64 XXH_read64 ( const void * ptr ) { return ( ( const unalign * ) ptr ) - > u64 ; } <nl> + <nl> + # else <nl> + <nl> + / * portable and safe solution . Generally efficient . <nl> + * see : http : / / stackoverflow . com / a / 32095106 / 646947 <nl> + * / <nl> + <nl> + static U32 XXH_read32 ( const void * memPtr ) <nl> + { <nl> + U32 val ; <nl> + memcpy ( & val , memPtr , sizeof ( val ) ) ; <nl> + return val ; <nl> + } <nl> + <nl> + static U64 XXH_read64 ( const void * memPtr ) <nl> + { <nl> + U64 val ; <nl> + memcpy ( & val , memPtr , sizeof ( val ) ) ; <nl> + return val ; <nl> + } <nl> + <nl> + # endif / * XXH_FORCE_DIRECT_MEMORY_ACCESS * / <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Compiler - specific Functions and Macros <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # define GCC_VERSION ( __GNUC__ * 100 + __GNUC_MINOR__ ) <nl> + <nl> + / * Note : although _rotl exists for minGW ( GCC under windows ) , performance seems poor * / <nl> + # if defined ( _MSC_VER ) <nl> + # define XXH_rotl32 ( x , r ) _rotl ( x , r ) <nl> + # define XXH_rotl64 ( x , r ) _rotl64 ( x , r ) <nl> + # else <nl> + # define XXH_rotl32 ( x , r ) ( ( x < < r ) | ( x > > ( 32 - r ) ) ) <nl> + # define XXH_rotl64 ( x , r ) ( ( x < < r ) | ( x > > ( 64 - r ) ) ) <nl> + # endif <nl> + <nl> + # if defined ( _MSC_VER ) / * Visual Studio * / <nl> + # define XXH_swap32 _byteswap_ulong <nl> + # define XXH_swap64 _byteswap_uint64 <nl> + # elif GCC_VERSION > = 403 <nl> + # define XXH_swap32 __builtin_bswap32 <nl> + # define XXH_swap64 __builtin_bswap64 <nl> + # else <nl> + static U32 XXH_swap32 ( U32 x ) <nl> + { <nl> + return ( ( x < < 24 ) & 0xff000000 ) | <nl> + ( ( x < < 8 ) & 0x00ff0000 ) | <nl> + ( ( x > > 8 ) & 0x0000ff00 ) | <nl> + ( ( x > > 24 ) & 0x000000ff ) ; <nl> + } <nl> + static U64 XXH_swap64 ( U64 x ) <nl> + { <nl> + return ( ( x < < 56 ) & 0xff00000000000000ULL ) | <nl> + ( ( x < < 40 ) & 0x00ff000000000000ULL ) | <nl> + ( ( x < < 24 ) & 0x0000ff0000000000ULL ) | <nl> + ( ( x < < 8 ) & 0x000000ff00000000ULL ) | <nl> + ( ( x > > 8 ) & 0x00000000ff000000ULL ) | <nl> + ( ( x > > 24 ) & 0x0000000000ff0000ULL ) | <nl> + ( ( x > > 40 ) & 0x000000000000ff00ULL ) | <nl> + ( ( x > > 56 ) & 0x00000000000000ffULL ) ; <nl> + } <nl> + # endif <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Architecture Macros <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + typedef enum { XXH_bigEndian = 0 , XXH_littleEndian = 1 } XXH_endianess ; <nl> + <nl> + / * XXH_CPU_LITTLE_ENDIAN can be defined externally , for example on the compiler command line * / <nl> + # ifndef XXH_CPU_LITTLE_ENDIAN <nl> + static const int g_one = 1 ; <nl> + # define XXH_CPU_LITTLE_ENDIAN ( * ( const char * ) ( & g_one ) ) <nl> + # endif <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Memory reads <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + typedef enum { XXH_aligned , XXH_unaligned } XXH_alignment ; <nl> + <nl> + FORCE_INLINE U32 XXH_readLE32_align ( const void * ptr , XXH_endianess endian , XXH_alignment align ) <nl> + { <nl> + if ( align = = XXH_unaligned ) <nl> + return endian = = XXH_littleEndian ? XXH_read32 ( ptr ) : XXH_swap32 ( XXH_read32 ( ptr ) ) ; <nl> + else <nl> + return endian = = XXH_littleEndian ? * ( const U32 * ) ptr : XXH_swap32 ( * ( const U32 * ) ptr ) ; <nl> + } <nl> + <nl> + FORCE_INLINE U32 XXH_readLE32 ( const void * ptr , XXH_endianess endian ) <nl> + { <nl> + return XXH_readLE32_align ( ptr , endian , XXH_unaligned ) ; <nl> + } <nl> + <nl> + static U32 XXH_readBE32 ( const void * ptr ) <nl> + { <nl> + return XXH_CPU_LITTLE_ENDIAN ? XXH_swap32 ( XXH_read32 ( ptr ) ) : XXH_read32 ( ptr ) ; <nl> + } <nl> + <nl> + FORCE_INLINE U64 XXH_readLE64_align ( const void * ptr , XXH_endianess endian , XXH_alignment align ) <nl> + { <nl> + if ( align = = XXH_unaligned ) <nl> + return endian = = XXH_littleEndian ? XXH_read64 ( ptr ) : XXH_swap64 ( XXH_read64 ( ptr ) ) ; <nl> + else <nl> + return endian = = XXH_littleEndian ? * ( const U64 * ) ptr : XXH_swap64 ( * ( const U64 * ) ptr ) ; <nl> + } <nl> + <nl> + FORCE_INLINE U64 XXH_readLE64 ( const void * ptr , XXH_endianess endian ) <nl> + { <nl> + return XXH_readLE64_align ( ptr , endian , XXH_unaligned ) ; <nl> + } <nl> + <nl> + static U64 XXH_readBE64 ( const void * ptr ) <nl> + { <nl> + return XXH_CPU_LITTLE_ENDIAN ? XXH_swap64 ( XXH_read64 ( ptr ) ) : XXH_read64 ( ptr ) ; <nl> + } <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Macros <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # define XXH_STATIC_ASSERT ( c ) { enum { XXH_static_assert = 1 / ( int ) ( ! ! ( c ) ) } ; } / * use only * after * variable declarations * / <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Constants <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + static const U32 PRIME32_1 = 2654435761U ; <nl> + static const U32 PRIME32_2 = 2246822519U ; <nl> + static const U32 PRIME32_3 = 3266489917U ; <nl> + static const U32 PRIME32_4 = 668265263U ; <nl> + static const U32 PRIME32_5 = 374761393U ; <nl> + <nl> + static const U64 PRIME64_1 = 11400714785074694791ULL ; <nl> + static const U64 PRIME64_2 = 14029467366897019727ULL ; <nl> + static const U64 PRIME64_3 = 1609587929392839161ULL ; <nl> + static const U64 PRIME64_4 = 9650029242287828579ULL ; <nl> + static const U64 PRIME64_5 = 2870177450012600261ULL ; <nl> + <nl> + XXH_PUBLIC_API unsigned XXH_versionNumber ( void ) { return XXH_VERSION_NUMBER ; } <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Utils <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + XXH_PUBLIC_API void XXH32_copyState ( XXH32_state_t * restrict dstState , const XXH32_state_t * restrict srcState ) <nl> + { <nl> + memcpy ( dstState , srcState , sizeof ( * dstState ) ) ; <nl> + } <nl> + <nl> + XXH_PUBLIC_API void XXH64_copyState ( XXH64_state_t * restrict dstState , const XXH64_state_t * restrict srcState ) <nl> + { <nl> + memcpy ( dstState , srcState , sizeof ( * dstState ) ) ; <nl> + } <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Simple Hash Functions <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + static U32 XXH32_round ( U32 seed , U32 input ) <nl> + { <nl> + seed + = input * PRIME32_2 ; <nl> + seed = XXH_rotl32 ( seed , 13 ) ; <nl> + seed * = PRIME32_1 ; <nl> + return seed ; <nl> + } <nl> + <nl> + FORCE_INLINE U32 XXH32_endian_align ( const void * input , size_t len , U32 seed , XXH_endianess endian , XXH_alignment align ) <nl> + { <nl> + const BYTE * p = ( const BYTE * ) input ; <nl> + const BYTE * bEnd = p + len ; <nl> + U32 h32 ; <nl> + # define XXH_get32bits ( p ) XXH_readLE32_align ( p , endian , align ) <nl> + <nl> + # ifdef XXH_ACCEPT_NULL_INPUT_POINTER <nl> + if ( p = = NULL ) { <nl> + len = 0 ; <nl> + bEnd = p = ( const BYTE * ) ( size_t ) 16 ; <nl> + } <nl> + # endif <nl> + <nl> + if ( len > = 16 ) { <nl> + const BYTE * const limit = bEnd - 16 ; <nl> + U32 v1 = seed + PRIME32_1 + PRIME32_2 ; <nl> + U32 v2 = seed + PRIME32_2 ; <nl> + U32 v3 = seed + 0 ; <nl> + U32 v4 = seed - PRIME32_1 ; <nl> + <nl> + do { <nl> + v1 = XXH32_round ( v1 , XXH_get32bits ( p ) ) ; p + = 4 ; <nl> + v2 = XXH32_round ( v2 , XXH_get32bits ( p ) ) ; p + = 4 ; <nl> + v3 = XXH32_round ( v3 , XXH_get32bits ( p ) ) ; p + = 4 ; <nl> + v4 = XXH32_round ( v4 , XXH_get32bits ( p ) ) ; p + = 4 ; <nl> + } while ( p < = limit ) ; <nl> + <nl> + h32 = XXH_rotl32 ( v1 , 1 ) + XXH_rotl32 ( v2 , 7 ) + XXH_rotl32 ( v3 , 12 ) + XXH_rotl32 ( v4 , 18 ) ; <nl> + } else { <nl> + h32 = seed + PRIME32_5 ; <nl> + } <nl> + <nl> + h32 + = ( U32 ) len ; <nl> + <nl> + while ( p + 4 < = bEnd ) { <nl> + h32 + = XXH_get32bits ( p ) * PRIME32_3 ; <nl> + h32 = XXH_rotl32 ( h32 , 17 ) * PRIME32_4 ; <nl> + p + = 4 ; <nl> + } <nl> + <nl> + while ( p < bEnd ) { <nl> + h32 + = ( * p ) * PRIME32_5 ; <nl> + h32 = XXH_rotl32 ( h32 , 11 ) * PRIME32_1 ; <nl> + p + + ; <nl> + } <nl> + <nl> + h32 ^ = h32 > > 15 ; <nl> + h32 * = PRIME32_2 ; <nl> + h32 ^ = h32 > > 13 ; <nl> + h32 * = PRIME32_3 ; <nl> + h32 ^ = h32 > > 16 ; <nl> + <nl> + return h32 ; <nl> + } <nl> + <nl> + <nl> + XXH_PUBLIC_API unsigned int XXH32 ( const void * input , size_t len , unsigned int seed ) <nl> + { <nl> + # if 0 <nl> + / * Simple version , good for code maintenance , but unfortunately slow for small inputs * / <nl> + XXH32_CREATESTATE_STATIC ( state ) ; <nl> + XXH32_reset ( state , seed ) ; <nl> + XXH32_update ( state , input , len ) ; <nl> + return XXH32_digest ( state ) ; <nl> + # else <nl> + XXH_endianess endian_detected = ( XXH_endianess ) XXH_CPU_LITTLE_ENDIAN ; <nl> + <nl> + if ( XXH_FORCE_ALIGN_CHECK ) { <nl> + if ( ( ( ( size_t ) input ) & 3 ) = = 0 ) { / * Input is 4 - bytes aligned , leverage the speed benefit * / <nl> + if ( ( endian_detected = = XXH_littleEndian ) | | XXH_FORCE_NATIVE_FORMAT ) <nl> + return XXH32_endian_align ( input , len , seed , XXH_littleEndian , XXH_aligned ) ; <nl> + else <nl> + return XXH32_endian_align ( input , len , seed , XXH_bigEndian , XXH_aligned ) ; <nl> + } } <nl> + <nl> + if ( ( endian_detected = = XXH_littleEndian ) | | XXH_FORCE_NATIVE_FORMAT ) <nl> + return XXH32_endian_align ( input , len , seed , XXH_littleEndian , XXH_unaligned ) ; <nl> + else <nl> + return XXH32_endian_align ( input , len , seed , XXH_bigEndian , XXH_unaligned ) ; <nl> + # endif <nl> + } <nl> + <nl> + <nl> + static U64 XXH64_round ( U64 acc , U64 input ) <nl> + { <nl> + acc + = input * PRIME64_2 ; <nl> + acc = XXH_rotl64 ( acc , 31 ) ; <nl> + acc * = PRIME64_1 ; <nl> + return acc ; <nl> + } <nl> + <nl> + static U64 XXH64_mergeRound ( U64 acc , U64 val ) <nl> + { <nl> + val = XXH64_round ( 0 , val ) ; <nl> + acc ^ = val ; <nl> + acc = acc * PRIME64_1 + PRIME64_4 ; <nl> + return acc ; <nl> + } <nl> + <nl> + FORCE_INLINE U64 XXH64_endian_align ( const void * input , size_t len , U64 seed , XXH_endianess endian , XXH_alignment align ) <nl> + { <nl> + const BYTE * p = ( const BYTE * ) input ; <nl> + const BYTE * const bEnd = p + len ; <nl> + U64 h64 ; <nl> + # define XXH_get64bits ( p ) XXH_readLE64_align ( p , endian , align ) <nl> + <nl> + # ifdef XXH_ACCEPT_NULL_INPUT_POINTER <nl> + if ( p = = NULL ) { <nl> + len = 0 ; <nl> + bEnd = p = ( const BYTE * ) ( size_t ) 32 ; <nl> + } <nl> + # endif <nl> + <nl> + if ( len > = 32 ) { <nl> + const BYTE * const limit = bEnd - 32 ; <nl> + U64 v1 = seed + PRIME64_1 + PRIME64_2 ; <nl> + U64 v2 = seed + PRIME64_2 ; <nl> + U64 v3 = seed + 0 ; <nl> + U64 v4 = seed - PRIME64_1 ; <nl> + <nl> + do { <nl> + v1 = XXH64_round ( v1 , XXH_get64bits ( p ) ) ; p + = 8 ; <nl> + v2 = XXH64_round ( v2 , XXH_get64bits ( p ) ) ; p + = 8 ; <nl> + v3 = XXH64_round ( v3 , XXH_get64bits ( p ) ) ; p + = 8 ; <nl> + v4 = XXH64_round ( v4 , XXH_get64bits ( p ) ) ; p + = 8 ; <nl> + } while ( p < = limit ) ; <nl> + <nl> + h64 = XXH_rotl64 ( v1 , 1 ) + XXH_rotl64 ( v2 , 7 ) + XXH_rotl64 ( v3 , 12 ) + XXH_rotl64 ( v4 , 18 ) ; <nl> + h64 = XXH64_mergeRound ( h64 , v1 ) ; <nl> + h64 = XXH64_mergeRound ( h64 , v2 ) ; <nl> + h64 = XXH64_mergeRound ( h64 , v3 ) ; <nl> + h64 = XXH64_mergeRound ( h64 , v4 ) ; <nl> + <nl> + } else { <nl> + h64 = seed + PRIME64_5 ; <nl> + } <nl> + <nl> + h64 + = ( U64 ) len ; <nl> + <nl> + while ( p + 8 < = bEnd ) { <nl> + U64 const k1 = XXH64_round ( 0 , XXH_get64bits ( p ) ) ; <nl> + h64 ^ = k1 ; <nl> + h64 = XXH_rotl64 ( h64 , 27 ) * PRIME64_1 + PRIME64_4 ; <nl> + p + = 8 ; <nl> + } <nl> + <nl> + if ( p + 4 < = bEnd ) { <nl> + h64 ^ = ( U64 ) ( XXH_get32bits ( p ) ) * PRIME64_1 ; <nl> + h64 = XXH_rotl64 ( h64 , 23 ) * PRIME64_2 + PRIME64_3 ; <nl> + p + = 4 ; <nl> + } <nl> + <nl> + while ( p < bEnd ) { <nl> + h64 ^ = ( * p ) * PRIME64_5 ; <nl> + h64 = XXH_rotl64 ( h64 , 11 ) * PRIME64_1 ; <nl> + p + + ; <nl> + } <nl> + <nl> + h64 ^ = h64 > > 33 ; <nl> + h64 * = PRIME64_2 ; <nl> + h64 ^ = h64 > > 29 ; <nl> + h64 * = PRIME64_3 ; <nl> + h64 ^ = h64 > > 32 ; <nl> + <nl> + return h64 ; <nl> + } <nl> + <nl> + <nl> + XXH_PUBLIC_API unsigned long long XXH64 ( const void * input , size_t len , unsigned long long seed ) <nl> + { <nl> + # if 0 <nl> + / * Simple version , good for code maintenance , but unfortunately slow for small inputs * / <nl> + XXH64_CREATESTATE_STATIC ( state ) ; <nl> + XXH64_reset ( state , seed ) ; <nl> + XXH64_update ( state , input , len ) ; <nl> + return XXH64_digest ( state ) ; <nl> + # else <nl> + XXH_endianess endian_detected = ( XXH_endianess ) XXH_CPU_LITTLE_ENDIAN ; <nl> + <nl> + if ( XXH_FORCE_ALIGN_CHECK ) { <nl> + if ( ( ( ( size_t ) input ) & 7 ) = = 0 ) { / * Input is aligned , let ' s leverage the speed advantage * / <nl> + if ( ( endian_detected = = XXH_littleEndian ) | | XXH_FORCE_NATIVE_FORMAT ) <nl> + return XXH64_endian_align ( input , len , seed , XXH_littleEndian , XXH_aligned ) ; <nl> + else <nl> + return XXH64_endian_align ( input , len , seed , XXH_bigEndian , XXH_aligned ) ; <nl> + } } <nl> + <nl> + if ( ( endian_detected = = XXH_littleEndian ) | | XXH_FORCE_NATIVE_FORMAT ) <nl> + return XXH64_endian_align ( input , len , seed , XXH_littleEndian , XXH_unaligned ) ; <nl> + else <nl> + return XXH64_endian_align ( input , len , seed , XXH_bigEndian , XXH_unaligned ) ; <nl> + # endif <nl> + } <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Advanced Hash Functions <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + XXH_PUBLIC_API XXH32_state_t * XXH32_createState ( void ) <nl> + { <nl> + return ( XXH32_state_t * ) XXH_malloc ( sizeof ( XXH32_state_t ) ) ; <nl> + } <nl> + XXH_PUBLIC_API XXH_errorcode XXH32_freeState ( XXH32_state_t * statePtr ) <nl> + { <nl> + XXH_free ( statePtr ) ; <nl> + return XXH_OK ; <nl> + } <nl> + <nl> + XXH_PUBLIC_API XXH64_state_t * XXH64_createState ( void ) <nl> + { <nl> + return ( XXH64_state_t * ) XXH_malloc ( sizeof ( XXH64_state_t ) ) ; <nl> + } <nl> + XXH_PUBLIC_API XXH_errorcode XXH64_freeState ( XXH64_state_t * statePtr ) <nl> + { <nl> + XXH_free ( statePtr ) ; <nl> + return XXH_OK ; <nl> + } <nl> + <nl> + <nl> + / * * * Hash feed * * * / <nl> + <nl> + XXH_PUBLIC_API XXH_errorcode XXH32_reset ( XXH32_state_t * statePtr , unsigned int seed ) <nl> + { <nl> + XXH32_state_t state ; / * using a local state to memcpy ( ) in order to avoid strict - aliasing warnings * / <nl> + memset ( & state , 0 , sizeof ( state ) - 4 ) ; / * do not write into reserved , for future removal * / <nl> + state . v1 = seed + PRIME32_1 + PRIME32_2 ; <nl> + state . v2 = seed + PRIME32_2 ; <nl> + state . v3 = seed + 0 ; <nl> + state . v4 = seed - PRIME32_1 ; <nl> + memcpy ( statePtr , & state , sizeof ( state ) ) ; <nl> + return XXH_OK ; <nl> + } <nl> + <nl> + <nl> + XXH_PUBLIC_API XXH_errorcode XXH64_reset ( XXH64_state_t * statePtr , unsigned long long seed ) <nl> + { <nl> + XXH64_state_t state ; / * using a local state to memcpy ( ) in order to avoid strict - aliasing warnings * / <nl> + memset ( & state , 0 , sizeof ( state ) - 8 ) ; / * do not write into reserved , for future removal * / <nl> + state . v1 = seed + PRIME64_1 + PRIME64_2 ; <nl> + state . v2 = seed + PRIME64_2 ; <nl> + state . v3 = seed + 0 ; <nl> + state . v4 = seed - PRIME64_1 ; <nl> + memcpy ( statePtr , & state , sizeof ( state ) ) ; <nl> + return XXH_OK ; <nl> + } <nl> + <nl> + <nl> + FORCE_INLINE XXH_errorcode XXH32_update_endian ( XXH32_state_t * state , const void * input , size_t len , XXH_endianess endian ) <nl> + { <nl> + const BYTE * p = ( const BYTE * ) input ; <nl> + const BYTE * const bEnd = p + len ; <nl> + <nl> + # ifdef XXH_ACCEPT_NULL_INPUT_POINTER <nl> + if ( input = = NULL ) return XXH_ERROR ; <nl> + # endif <nl> + <nl> + state - > total_len_32 + = ( unsigned ) len ; <nl> + state - > large_len | = ( len > = 16 ) | ( state - > total_len_32 > = 16 ) ; <nl> + <nl> + if ( state - > memsize + len < 16 ) { / * fill in tmp buffer * / <nl> + XXH_memcpy ( ( BYTE * ) ( state - > mem32 ) + state - > memsize , input , len ) ; <nl> + state - > memsize + = ( unsigned ) len ; <nl> + return XXH_OK ; <nl> + } <nl> + <nl> + if ( state - > memsize ) { / * some data left from previous update * / <nl> + XXH_memcpy ( ( BYTE * ) ( state - > mem32 ) + state - > memsize , input , 16 - state - > memsize ) ; <nl> + { const U32 * p32 = state - > mem32 ; <nl> + state - > v1 = XXH32_round ( state - > v1 , XXH_readLE32 ( p32 , endian ) ) ; p32 + + ; <nl> + state - > v2 = XXH32_round ( state - > v2 , XXH_readLE32 ( p32 , endian ) ) ; p32 + + ; <nl> + state - > v3 = XXH32_round ( state - > v3 , XXH_readLE32 ( p32 , endian ) ) ; p32 + + ; <nl> + state - > v4 = XXH32_round ( state - > v4 , XXH_readLE32 ( p32 , endian ) ) ; p32 + + ; <nl> + } <nl> + p + = 16 - state - > memsize ; <nl> + state - > memsize = 0 ; <nl> + } <nl> + <nl> + if ( p < = bEnd - 16 ) { <nl> + const BYTE * const limit = bEnd - 16 ; <nl> + U32 v1 = state - > v1 ; <nl> + U32 v2 = state - > v2 ; <nl> + U32 v3 = state - > v3 ; <nl> + U32 v4 = state - > v4 ; <nl> + <nl> + do { <nl> + v1 = XXH32_round ( v1 , XXH_readLE32 ( p , endian ) ) ; p + = 4 ; <nl> + v2 = XXH32_round ( v2 , XXH_readLE32 ( p , endian ) ) ; p + = 4 ; <nl> + v3 = XXH32_round ( v3 , XXH_readLE32 ( p , endian ) ) ; p + = 4 ; <nl> + v4 = XXH32_round ( v4 , XXH_readLE32 ( p , endian ) ) ; p + = 4 ; <nl> + } while ( p < = limit ) ; <nl> + <nl> + state - > v1 = v1 ; <nl> + state - > v2 = v2 ; <nl> + state - > v3 = v3 ; <nl> + state - > v4 = v4 ; <nl> + } <nl> + <nl> + if ( p < bEnd ) { <nl> + XXH_memcpy ( state - > mem32 , p , ( size_t ) ( bEnd - p ) ) ; <nl> + state - > memsize = ( unsigned ) ( bEnd - p ) ; <nl> + } <nl> + <nl> + return XXH_OK ; <nl> + } <nl> + <nl> + XXH_PUBLIC_API XXH_errorcode XXH32_update ( XXH32_state_t * state_in , const void * input , size_t len ) <nl> + { <nl> + XXH_endianess endian_detected = ( XXH_endianess ) XXH_CPU_LITTLE_ENDIAN ; <nl> + <nl> + if ( ( endian_detected = = XXH_littleEndian ) | | XXH_FORCE_NATIVE_FORMAT ) <nl> + return XXH32_update_endian ( state_in , input , len , XXH_littleEndian ) ; <nl> + else <nl> + return XXH32_update_endian ( state_in , input , len , XXH_bigEndian ) ; <nl> + } <nl> + <nl> + <nl> + <nl> + FORCE_INLINE U32 XXH32_digest_endian ( const XXH32_state_t * state , XXH_endianess endian ) <nl> + { <nl> + const BYTE * p = ( const BYTE * ) state - > mem32 ; <nl> + const BYTE * const bEnd = ( const BYTE * ) ( state - > mem32 ) + state - > memsize ; <nl> + U32 h32 ; <nl> + <nl> + if ( state - > large_len ) { <nl> + h32 = XXH_rotl32 ( state - > v1 , 1 ) + XXH_rotl32 ( state - > v2 , 7 ) + XXH_rotl32 ( state - > v3 , 12 ) + XXH_rotl32 ( state - > v4 , 18 ) ; <nl> + } else { <nl> + h32 = state - > v3 / * = = seed * / + PRIME32_5 ; <nl> + } <nl> + <nl> + h32 + = state - > total_len_32 ; <nl> + <nl> + while ( p + 4 < = bEnd ) { <nl> + h32 + = XXH_readLE32 ( p , endian ) * PRIME32_3 ; <nl> + h32 = XXH_rotl32 ( h32 , 17 ) * PRIME32_4 ; <nl> + p + = 4 ; <nl> + } <nl> + <nl> + while ( p < bEnd ) { <nl> + h32 + = ( * p ) * PRIME32_5 ; <nl> + h32 = XXH_rotl32 ( h32 , 11 ) * PRIME32_1 ; <nl> + p + + ; <nl> + } <nl> + <nl> + h32 ^ = h32 > > 15 ; <nl> + h32 * = PRIME32_2 ; <nl> + h32 ^ = h32 > > 13 ; <nl> + h32 * = PRIME32_3 ; <nl> + h32 ^ = h32 > > 16 ; <nl> + <nl> + return h32 ; <nl> + } <nl> + <nl> + <nl> + XXH_PUBLIC_API unsigned int XXH32_digest ( const XXH32_state_t * state_in ) <nl> + { <nl> + XXH_endianess endian_detected = ( XXH_endianess ) XXH_CPU_LITTLE_ENDIAN ; <nl> + <nl> + if ( ( endian_detected = = XXH_littleEndian ) | | XXH_FORCE_NATIVE_FORMAT ) <nl> + return XXH32_digest_endian ( state_in , XXH_littleEndian ) ; <nl> + else <nl> + return XXH32_digest_endian ( state_in , XXH_bigEndian ) ; <nl> + } <nl> + <nl> + <nl> + <nl> + / * * * * * XXH64 * * * * * / <nl> + <nl> + FORCE_INLINE XXH_errorcode XXH64_update_endian ( XXH64_state_t * state , const void * input , size_t len , XXH_endianess endian ) <nl> + { <nl> + const BYTE * p = ( const BYTE * ) input ; <nl> + const BYTE * const bEnd = p + len ; <nl> + <nl> + # ifdef XXH_ACCEPT_NULL_INPUT_POINTER <nl> + if ( input = = NULL ) return XXH_ERROR ; <nl> + # endif <nl> + <nl> + state - > total_len + = len ; <nl> + <nl> + if ( state - > memsize + len < 32 ) { / * fill in tmp buffer * / <nl> + XXH_memcpy ( ( ( BYTE * ) state - > mem64 ) + state - > memsize , input , len ) ; <nl> + state - > memsize + = ( U32 ) len ; <nl> + return XXH_OK ; <nl> + } <nl> + <nl> + if ( state - > memsize ) { / * tmp buffer is full * / <nl> + XXH_memcpy ( ( ( BYTE * ) state - > mem64 ) + state - > memsize , input , 32 - state - > memsize ) ; <nl> + state - > v1 = XXH64_round ( state - > v1 , XXH_readLE64 ( state - > mem64 + 0 , endian ) ) ; <nl> + state - > v2 = XXH64_round ( state - > v2 , XXH_readLE64 ( state - > mem64 + 1 , endian ) ) ; <nl> + state - > v3 = XXH64_round ( state - > v3 , XXH_readLE64 ( state - > mem64 + 2 , endian ) ) ; <nl> + state - > v4 = XXH64_round ( state - > v4 , XXH_readLE64 ( state - > mem64 + 3 , endian ) ) ; <nl> + p + = 32 - state - > memsize ; <nl> + state - > memsize = 0 ; <nl> + } <nl> + <nl> + if ( p + 32 < = bEnd ) { <nl> + const BYTE * const limit = bEnd - 32 ; <nl> + U64 v1 = state - > v1 ; <nl> + U64 v2 = state - > v2 ; <nl> + U64 v3 = state - > v3 ; <nl> + U64 v4 = state - > v4 ; <nl> + <nl> + do { <nl> + v1 = XXH64_round ( v1 , XXH_readLE64 ( p , endian ) ) ; p + = 8 ; <nl> + v2 = XXH64_round ( v2 , XXH_readLE64 ( p , endian ) ) ; p + = 8 ; <nl> + v3 = XXH64_round ( v3 , XXH_readLE64 ( p , endian ) ) ; p + = 8 ; <nl> + v4 = XXH64_round ( v4 , XXH_readLE64 ( p , endian ) ) ; p + = 8 ; <nl> + } while ( p < = limit ) ; <nl> + <nl> + state - > v1 = v1 ; <nl> + state - > v2 = v2 ; <nl> + state - > v3 = v3 ; <nl> + state - > v4 = v4 ; <nl> + } <nl> + <nl> + if ( p < bEnd ) { <nl> + XXH_memcpy ( state - > mem64 , p , ( size_t ) ( bEnd - p ) ) ; <nl> + state - > memsize = ( unsigned ) ( bEnd - p ) ; <nl> + } <nl> + <nl> + return XXH_OK ; <nl> + } <nl> + <nl> + XXH_PUBLIC_API XXH_errorcode XXH64_update ( XXH64_state_t * state_in , const void * input , size_t len ) <nl> + { <nl> + XXH_endianess endian_detected = ( XXH_endianess ) XXH_CPU_LITTLE_ENDIAN ; <nl> + <nl> + if ( ( endian_detected = = XXH_littleEndian ) | | XXH_FORCE_NATIVE_FORMAT ) <nl> + return XXH64_update_endian ( state_in , input , len , XXH_littleEndian ) ; <nl> + else <nl> + return XXH64_update_endian ( state_in , input , len , XXH_bigEndian ) ; <nl> + } <nl> + <nl> + <nl> + <nl> + FORCE_INLINE U64 XXH64_digest_endian ( const XXH64_state_t * state , XXH_endianess endian ) <nl> + { <nl> + const BYTE * p = ( const BYTE * ) state - > mem64 ; <nl> + const BYTE * const bEnd = ( const BYTE * ) state - > mem64 + state - > memsize ; <nl> + U64 h64 ; <nl> + <nl> + if ( state - > total_len > = 32 ) { <nl> + U64 const v1 = state - > v1 ; <nl> + U64 const v2 = state - > v2 ; <nl> + U64 const v3 = state - > v3 ; <nl> + U64 const v4 = state - > v4 ; <nl> + <nl> + h64 = XXH_rotl64 ( v1 , 1 ) + XXH_rotl64 ( v2 , 7 ) + XXH_rotl64 ( v3 , 12 ) + XXH_rotl64 ( v4 , 18 ) ; <nl> + h64 = XXH64_mergeRound ( h64 , v1 ) ; <nl> + h64 = XXH64_mergeRound ( h64 , v2 ) ; <nl> + h64 = XXH64_mergeRound ( h64 , v3 ) ; <nl> + h64 = XXH64_mergeRound ( h64 , v4 ) ; <nl> + } else { <nl> + h64 = state - > v3 + PRIME64_5 ; <nl> + } <nl> + <nl> + h64 + = ( U64 ) state - > total_len ; <nl> + <nl> + while ( p + 8 < = bEnd ) { <nl> + U64 const k1 = XXH64_round ( 0 , XXH_readLE64 ( p , endian ) ) ; <nl> + h64 ^ = k1 ; <nl> + h64 = XXH_rotl64 ( h64 , 27 ) * PRIME64_1 + PRIME64_4 ; <nl> + p + = 8 ; <nl> + } <nl> + <nl> + if ( p + 4 < = bEnd ) { <nl> + h64 ^ = ( U64 ) ( XXH_readLE32 ( p , endian ) ) * PRIME64_1 ; <nl> + h64 = XXH_rotl64 ( h64 , 23 ) * PRIME64_2 + PRIME64_3 ; <nl> + p + = 4 ; <nl> + } <nl> + <nl> + while ( p < bEnd ) { <nl> + h64 ^ = ( * p ) * PRIME64_5 ; <nl> + h64 = XXH_rotl64 ( h64 , 11 ) * PRIME64_1 ; <nl> + p + + ; <nl> + } <nl> + <nl> + h64 ^ = h64 > > 33 ; <nl> + h64 * = PRIME64_2 ; <nl> + h64 ^ = h64 > > 29 ; <nl> + h64 * = PRIME64_3 ; <nl> + h64 ^ = h64 > > 32 ; <nl> + <nl> + return h64 ; <nl> + } <nl> + <nl> + <nl> + XXH_PUBLIC_API unsigned long long XXH64_digest ( const XXH64_state_t * state_in ) <nl> + { <nl> + XXH_endianess endian_detected = ( XXH_endianess ) XXH_CPU_LITTLE_ENDIAN ; <nl> + <nl> + if ( ( endian_detected = = XXH_littleEndian ) | | XXH_FORCE_NATIVE_FORMAT ) <nl> + return XXH64_digest_endian ( state_in , XXH_littleEndian ) ; <nl> + else <nl> + return XXH64_digest_endian ( state_in , XXH_bigEndian ) ; <nl> + } <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Canonical representation <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + / * ! Default XXH result types are basic unsigned 32 and 64 bits . <nl> + * The canonical representation follows human - readable write convention , aka big - endian ( large digits first ) . <nl> + * These functions allow transformation of hash result into and from its canonical format . <nl> + * This way , hash values can be written into a file or buffer , and remain comparable across different systems and programs . <nl> + * / <nl> + <nl> + XXH_PUBLIC_API void XXH32_canonicalFromHash ( XXH32_canonical_t * dst , XXH32_hash_t hash ) <nl> + { <nl> + XXH_STATIC_ASSERT ( sizeof ( XXH32_canonical_t ) = = sizeof ( XXH32_hash_t ) ) ; <nl> + if ( XXH_CPU_LITTLE_ENDIAN ) hash = XXH_swap32 ( hash ) ; <nl> + memcpy ( dst , & hash , sizeof ( * dst ) ) ; <nl> + } <nl> + <nl> + XXH_PUBLIC_API void XXH64_canonicalFromHash ( XXH64_canonical_t * dst , XXH64_hash_t hash ) <nl> + { <nl> + XXH_STATIC_ASSERT ( sizeof ( XXH64_canonical_t ) = = sizeof ( XXH64_hash_t ) ) ; <nl> + if ( XXH_CPU_LITTLE_ENDIAN ) hash = XXH_swap64 ( hash ) ; <nl> + memcpy ( dst , & hash , sizeof ( * dst ) ) ; <nl> + } <nl> + <nl> + XXH_PUBLIC_API XXH32_hash_t XXH32_hashFromCanonical ( const XXH32_canonical_t * src ) <nl> + { <nl> + return XXH_readBE32 ( src ) ; <nl> + } <nl> + <nl> + XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical ( const XXH64_canonical_t * src ) <nl> + { <nl> + return XXH_readBE64 ( src ) ; <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 9bad1f59f63 <nl> mmm / dev / null <nl> ppp b / thirdparty / zstd / common / xxhash . h <nl> <nl> + / * <nl> + xxHash - Extremely Fast Hash algorithm <nl> + Header File <nl> + Copyright ( C ) 2012 - 2016 , Yann Collet . <nl> + <nl> + BSD 2 - Clause License ( http : / / www . opensource . org / licenses / bsd - license . php ) <nl> + <nl> + Redistribution and use in source and binary forms , with or without <nl> + modification , are permitted provided that the following conditions are <nl> + met : <nl> + <nl> + * Redistributions of source code must retain the above copyright <nl> + notice , this list of conditions and the following disclaimer . <nl> + * Redistributions in binary form must reproduce the above <nl> + copyright notice , this list of conditions and the following disclaimer <nl> + in the documentation and / or other materials provided with the <nl> + distribution . <nl> + <nl> + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + <nl> + You can contact the author at : <nl> + - xxHash source repository : https : / / github . com / Cyan4973 / xxHash <nl> + * / <nl> + <nl> + / * Notice extracted from xxHash homepage : <nl> + <nl> + xxHash is an extremely fast Hash algorithm , running at RAM speed limits . <nl> + It also successfully passes all tests from the SMHasher suite . <nl> + <nl> + Comparison ( single thread , Windows Seven 32 bits , using SMHasher on a Core 2 Duo @ 3GHz ) <nl> + <nl> + Name Speed Q . Score Author <nl> + xxHash 5 . 4 GB / s 10 <nl> + CrapWow 3 . 2 GB / s 2 Andrew <nl> + MumurHash 3a 2 . 7 GB / s 10 Austin Appleby <nl> + SpookyHash 2 . 0 GB / s 10 Bob Jenkins <nl> + SBox 1 . 4 GB / s 9 Bret Mulvey <nl> + Lookup3 1 . 2 GB / s 9 Bob Jenkins <nl> + SuperFastHash 1 . 2 GB / s 1 Paul Hsieh <nl> + CityHash64 1 . 05 GB / s 10 Pike & Alakuijala <nl> + FNV 0 . 55 GB / s 5 Fowler , Noll , Vo <nl> + CRC32 0 . 43 GB / s 9 <nl> + MD5 - 32 0 . 33 GB / s 10 Ronald L . Rivest <nl> + SHA1 - 32 0 . 28 GB / s 10 <nl> + <nl> + Q . Score is a measure of quality of the hash function . <nl> + It depends on successfully passing SMHasher test set . <nl> + 10 is a perfect score . <nl> + <nl> + A 64 - bits version , named XXH64 , is available since r35 . <nl> + It offers much better speed , but for 64 - bits applications only . <nl> + Name Speed on 64 bits Speed on 32 bits <nl> + XXH64 13 . 8 GB / s 1 . 9 GB / s <nl> + XXH32 6 . 8 GB / s 6 . 0 GB / s <nl> + * / <nl> + <nl> + # if defined ( __cplusplus ) <nl> + extern " C " { <nl> + # endif <nl> + <nl> + # ifndef XXHASH_H_5627135585666179 <nl> + # define XXHASH_H_5627135585666179 1 <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Definitions <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # include < stddef . h > / * size_t * / <nl> + typedef enum { XXH_OK = 0 , XXH_ERROR } XXH_errorcode ; <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * API modifier <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * * XXH_PRIVATE_API <nl> + * This is useful if you want to include xxhash functions in ` static ` mode <nl> + * in order to inline them , and remove their symbol from the public list . <nl> + * Methodology : <nl> + * # define XXH_PRIVATE_API <nl> + * # include " xxhash . h " <nl> + * ` xxhash . c ` is automatically included . <nl> + * It ' s not useful to compile and link it as a separate module anymore . <nl> + * / <nl> + # ifdef XXH_PRIVATE_API <nl> + # ifndef XXH_STATIC_LINKING_ONLY <nl> + # define XXH_STATIC_LINKING_ONLY <nl> + # endif <nl> + # if defined ( __GNUC__ ) <nl> + # define XXH_PUBLIC_API static __inline __attribute__ ( ( unused ) ) <nl> + # elif defined ( __cplusplus ) | | ( defined ( __STDC_VERSION__ ) & & ( __STDC_VERSION__ > = 199901L ) / * C99 * / ) <nl> + # define XXH_PUBLIC_API static inline <nl> + # elif defined ( _MSC_VER ) <nl> + # define XXH_PUBLIC_API static __inline <nl> + # else <nl> + # define XXH_PUBLIC_API static / * this version may generate warnings for unused static functions ; disable the relevant warning * / <nl> + # endif <nl> + # else <nl> + # define XXH_PUBLIC_API / * do nothing * / <nl> + # endif / * XXH_PRIVATE_API * / <nl> + <nl> + / * ! XXH_NAMESPACE , aka Namespace Emulation : <nl> + <nl> + If you want to include _and expose_ xxHash functions from within your own library , <nl> + but also want to avoid symbol collisions with another library which also includes xxHash , <nl> + <nl> + you can use XXH_NAMESPACE , to automatically prefix any public symbol from xxhash library <nl> + with the value of XXH_NAMESPACE ( so avoid to keep it NULL and avoid numeric values ) . <nl> + <nl> + Note that no change is required within the calling program as long as it includes ` xxhash . h ` : <nl> + regular symbol name will be automatically translated by this header . <nl> + * / <nl> + # ifdef XXH_NAMESPACE <nl> + # define XXH_CAT ( A , B ) A # # B <nl> + # define XXH_NAME2 ( A , B ) XXH_CAT ( A , B ) <nl> + # define XXH32 XXH_NAME2 ( XXH_NAMESPACE , XXH32 ) <nl> + # define XXH64 XXH_NAME2 ( XXH_NAMESPACE , XXH64 ) <nl> + # define XXH_versionNumber XXH_NAME2 ( XXH_NAMESPACE , XXH_versionNumber ) <nl> + # define XXH32_createState XXH_NAME2 ( XXH_NAMESPACE , XXH32_createState ) <nl> + # define XXH64_createState XXH_NAME2 ( XXH_NAMESPACE , XXH64_createState ) <nl> + # define XXH32_freeState XXH_NAME2 ( XXH_NAMESPACE , XXH32_freeState ) <nl> + # define XXH64_freeState XXH_NAME2 ( XXH_NAMESPACE , XXH64_freeState ) <nl> + # define XXH32_reset XXH_NAME2 ( XXH_NAMESPACE , XXH32_reset ) <nl> + # define XXH64_reset XXH_NAME2 ( XXH_NAMESPACE , XXH64_reset ) <nl> + # define XXH32_update XXH_NAME2 ( XXH_NAMESPACE , XXH32_update ) <nl> + # define XXH64_update XXH_NAME2 ( XXH_NAMESPACE , XXH64_update ) <nl> + # define XXH32_digest XXH_NAME2 ( XXH_NAMESPACE , XXH32_digest ) <nl> + # define XXH64_digest XXH_NAME2 ( XXH_NAMESPACE , XXH64_digest ) <nl> + # define XXH32_copyState XXH_NAME2 ( XXH_NAMESPACE , XXH32_copyState ) <nl> + # define XXH64_copyState XXH_NAME2 ( XXH_NAMESPACE , XXH64_copyState ) <nl> + # define XXH32_canonicalFromHash XXH_NAME2 ( XXH_NAMESPACE , XXH32_canonicalFromHash ) <nl> + # define XXH64_canonicalFromHash XXH_NAME2 ( XXH_NAMESPACE , XXH64_canonicalFromHash ) <nl> + # define XXH32_hashFromCanonical XXH_NAME2 ( XXH_NAMESPACE , XXH32_hashFromCanonical ) <nl> + # define XXH64_hashFromCanonical XXH_NAME2 ( XXH_NAMESPACE , XXH64_hashFromCanonical ) <nl> + # endif <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Version <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # define XXH_VERSION_MAJOR 0 <nl> + # define XXH_VERSION_MINOR 6 <nl> + # define XXH_VERSION_RELEASE 2 <nl> + # define XXH_VERSION_NUMBER ( XXH_VERSION_MAJOR * 100 * 100 + XXH_VERSION_MINOR * 100 + XXH_VERSION_RELEASE ) <nl> + XXH_PUBLIC_API unsigned XXH_versionNumber ( void ) ; <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Simple Hash Functions <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + typedef unsigned int XXH32_hash_t ; <nl> + typedef unsigned long long XXH64_hash_t ; <nl> + <nl> + XXH_PUBLIC_API XXH32_hash_t XXH32 ( const void * input , size_t length , unsigned int seed ) ; <nl> + XXH_PUBLIC_API XXH64_hash_t XXH64 ( const void * input , size_t length , unsigned long long seed ) ; <nl> + <nl> + / * ! <nl> + XXH32 ( ) : <nl> + Calculate the 32 - bits hash of sequence " length " bytes stored at memory address " input " . <nl> + The memory between input & input + length must be valid ( allocated and read - accessible ) . <nl> + " seed " can be used to alter the result predictably . <nl> + Speed on Core 2 Duo @ 3 GHz ( single thread , SMHasher benchmark ) : 5 . 4 GB / s <nl> + XXH64 ( ) : <nl> + Calculate the 64 - bits hash of sequence of length " len " stored at memory address " input " . <nl> + " seed " can be used to alter the result predictably . <nl> + This function runs 2x faster on 64 - bits systems , but slower on 32 - bits systems ( see benchmark ) . <nl> + * / <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Streaming Hash Functions <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + typedef struct XXH32_state_s XXH32_state_t ; / * incomplete type * / <nl> + typedef struct XXH64_state_s XXH64_state_t ; / * incomplete type * / <nl> + <nl> + / * ! State allocation , compatible with dynamic libraries * / <nl> + <nl> + XXH_PUBLIC_API XXH32_state_t * XXH32_createState ( void ) ; <nl> + XXH_PUBLIC_API XXH_errorcode XXH32_freeState ( XXH32_state_t * statePtr ) ; <nl> + <nl> + XXH_PUBLIC_API XXH64_state_t * XXH64_createState ( void ) ; <nl> + XXH_PUBLIC_API XXH_errorcode XXH64_freeState ( XXH64_state_t * statePtr ) ; <nl> + <nl> + <nl> + / * hash streaming * / <nl> + <nl> + XXH_PUBLIC_API XXH_errorcode XXH32_reset ( XXH32_state_t * statePtr , unsigned int seed ) ; <nl> + XXH_PUBLIC_API XXH_errorcode XXH32_update ( XXH32_state_t * statePtr , const void * input , size_t length ) ; <nl> + XXH_PUBLIC_API XXH32_hash_t XXH32_digest ( const XXH32_state_t * statePtr ) ; <nl> + <nl> + XXH_PUBLIC_API XXH_errorcode XXH64_reset ( XXH64_state_t * statePtr , unsigned long long seed ) ; <nl> + XXH_PUBLIC_API XXH_errorcode XXH64_update ( XXH64_state_t * statePtr , const void * input , size_t length ) ; <nl> + XXH_PUBLIC_API XXH64_hash_t XXH64_digest ( const XXH64_state_t * statePtr ) ; <nl> + <nl> + / * <nl> + These functions generate the xxHash of an input provided in multiple segments . <nl> + Note that , for small input , they are slower than single - call functions , due to state management . <nl> + For small input , prefer ` XXH32 ( ) ` and ` XXH64 ( ) ` . <nl> + <nl> + XXH state must first be allocated , using XXH * _createState ( ) . <nl> + <nl> + Start a new hash by initializing state with a seed , using XXH * _reset ( ) . <nl> + <nl> + Then , feed the hash state by calling XXH * _update ( ) as many times as necessary . <nl> + Obviously , input must be allocated and read accessible . <nl> + The function returns an error code , with 0 meaning OK , and any other value meaning there is an error . <nl> + <nl> + Finally , a hash value can be produced anytime , by using XXH * _digest ( ) . <nl> + This function returns the nn - bits hash as an int or long long . <nl> + <nl> + It ' s still possible to continue inserting input into the hash state after a digest , <nl> + and generate some new hashes later on , by calling again XXH * _digest ( ) . <nl> + <nl> + When done , free XXH state space if it was allocated dynamically . <nl> + * / <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Utils <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # if ! ( defined ( __STDC_VERSION__ ) & & ( __STDC_VERSION__ > = 199901L ) ) / * ! C99 * / <nl> + # define restrict / * disable restrict * / <nl> + # endif <nl> + <nl> + XXH_PUBLIC_API void XXH32_copyState ( XXH32_state_t * restrict dst_state , const XXH32_state_t * restrict src_state ) ; <nl> + XXH_PUBLIC_API void XXH64_copyState ( XXH64_state_t * restrict dst_state , const XXH64_state_t * restrict src_state ) ; <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Canonical representation <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * Default result type for XXH functions are primitive unsigned 32 and 64 bits . <nl> + * The canonical representation uses human - readable write convention , aka big - endian ( large digits first ) . <nl> + * These functions allow transformation of hash result into and from its canonical format . <nl> + * This way , hash values can be written into a file / memory , and remain comparable on different systems and programs . <nl> + * / <nl> + typedef struct { unsigned char digest [ 4 ] ; } XXH32_canonical_t ; <nl> + typedef struct { unsigned char digest [ 8 ] ; } XXH64_canonical_t ; <nl> + <nl> + XXH_PUBLIC_API void XXH32_canonicalFromHash ( XXH32_canonical_t * dst , XXH32_hash_t hash ) ; <nl> + XXH_PUBLIC_API void XXH64_canonicalFromHash ( XXH64_canonical_t * dst , XXH64_hash_t hash ) ; <nl> + <nl> + XXH_PUBLIC_API XXH32_hash_t XXH32_hashFromCanonical ( const XXH32_canonical_t * src ) ; <nl> + XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical ( const XXH64_canonical_t * src ) ; <nl> + <nl> + # endif / * XXHASH_H_5627135585666179 * / <nl> + <nl> + <nl> + <nl> + / * = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + This section contains definitions which are not guaranteed to remain stable . <nl> + They may change in future versions , becoming incompatible with a different version of the library . <nl> + They shall only be used with static linking . <nl> + Never use these definitions in association with dynamic linking ! <nl> + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> + # if defined ( XXH_STATIC_LINKING_ONLY ) & & ! defined ( XXH_STATIC_H_3543687687345 ) <nl> + # define XXH_STATIC_H_3543687687345 <nl> + <nl> + / * These definitions are only meant to allow allocation of XXH state <nl> + statically , on stack , or in a struct for example . <nl> + Do not use members directly . * / <nl> + <nl> + struct XXH32_state_s { <nl> + unsigned total_len_32 ; <nl> + unsigned large_len ; <nl> + unsigned v1 ; <nl> + unsigned v2 ; <nl> + unsigned v3 ; <nl> + unsigned v4 ; <nl> + unsigned mem32 [ 4 ] ; / * buffer defined as U32 for alignment * / <nl> + unsigned memsize ; <nl> + unsigned reserved ; / * never read nor write , will be removed in a future version * / <nl> + } ; / * typedef ' d to XXH32_state_t * / <nl> + <nl> + struct XXH64_state_s { <nl> + unsigned long long total_len ; <nl> + unsigned long long v1 ; <nl> + unsigned long long v2 ; <nl> + unsigned long long v3 ; <nl> + unsigned long long v4 ; <nl> + unsigned long long mem64 [ 4 ] ; / * buffer defined as U64 for alignment * / <nl> + unsigned memsize ; <nl> + unsigned reserved [ 2 ] ; / * never read nor write , will be removed in a future version * / <nl> + } ; / * typedef ' d to XXH64_state_t * / <nl> + <nl> + <nl> + # ifdef XXH_PRIVATE_API <nl> + # include " xxhash . c " / * include xxhash functions as ` static ` , for inlining * / <nl> + # endif <nl> + <nl> + # endif / * XXH_STATIC_LINKING_ONLY & & XXH_STATIC_H_3543687687345 * / <nl> + <nl> + <nl> + # if defined ( __cplusplus ) <nl> + } <nl> + # endif <nl> new file mode 100644 <nl> index 00000000000 . . 8408a589ae8 <nl> mmm / dev / null <nl> ppp b / thirdparty / zstd / common / zstd_common . c <nl> <nl> + / * * <nl> + * Copyright ( c ) 2016 - present , Yann Collet , Facebook , Inc . <nl> + * All rights reserved . <nl> + * <nl> + * This source code is licensed under the BSD - style license found in the <nl> + * LICENSE file in the root directory of this source tree . An additional grant <nl> + * of patent rights can be found in the PATENTS file in the same directory . <nl> + * / <nl> + <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Dependencies <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # include < stdlib . h > / * malloc * / <nl> + # include " error_private . h " <nl> + # define ZSTD_STATIC_LINKING_ONLY <nl> + # include " zstd . h " / * declaration of ZSTD_isError , ZSTD_getErrorName , ZSTD_getErrorCode , ZSTD_getErrorString , ZSTD_versionNumber * / <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Version <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + unsigned ZSTD_versionNumber ( void ) { return ZSTD_VERSION_NUMBER ; } <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * ZSTD Error Management <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * ! ZSTD_isError ( ) : <nl> + * tells if a return value is an error code * / <nl> + unsigned ZSTD_isError ( size_t code ) { return ERR_isError ( code ) ; } <nl> + <nl> + / * ! ZSTD_getErrorName ( ) : <nl> + * provides error code string from function result ( useful for debugging ) * / <nl> + const char * ZSTD_getErrorName ( size_t code ) { return ERR_getErrorName ( code ) ; } <nl> + <nl> + / * ! ZSTD_getError ( ) : <nl> + * convert a ` size_t ` function result into a proper ZSTD_errorCode enum * / <nl> + ZSTD_ErrorCode ZSTD_getErrorCode ( size_t code ) { return ERR_getErrorCode ( code ) ; } <nl> + <nl> + / * ! ZSTD_getErrorString ( ) : <nl> + * provides error code string from enum * / <nl> + const char * ZSTD_getErrorString ( ZSTD_ErrorCode code ) { return ERR_getErrorString ( code ) ; } <nl> + <nl> + <nl> + / * = * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Custom allocator <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * default uses stdlib * / <nl> + void * ZSTD_defaultAllocFunction ( void * opaque , size_t size ) <nl> + { <nl> + void * address = malloc ( size ) ; <nl> + ( void ) opaque ; <nl> + return address ; <nl> + } <nl> + <nl> + void ZSTD_defaultFreeFunction ( void * opaque , void * address ) <nl> + { <nl> + ( void ) opaque ; <nl> + free ( address ) ; <nl> + } <nl> + <nl> + void * ZSTD_malloc ( size_t size , ZSTD_customMem customMem ) <nl> + { <nl> + return customMem . customAlloc ( customMem . opaque , size ) ; <nl> + } <nl> + <nl> + void ZSTD_free ( void * ptr , ZSTD_customMem customMem ) <nl> + { <nl> + if ( ptr ! = NULL ) <nl> + customMem . customFree ( customMem . opaque , ptr ) ; <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 3d579d96936 <nl> mmm / dev / null <nl> ppp b / thirdparty / zstd / common / zstd_errors . h <nl> <nl> + / * * <nl> + * Copyright ( c ) 2016 - present , Yann Collet , Facebook , Inc . <nl> + * All rights reserved . <nl> + * <nl> + * This source code is licensed under the BSD - style license found in the <nl> + * LICENSE file in the root directory of this source tree . An additional grant <nl> + * of patent rights can be found in the PATENTS file in the same directory . <nl> + * / <nl> + <nl> + # ifndef ZSTD_ERRORS_H_398273423 <nl> + # define ZSTD_ERRORS_H_398273423 <nl> + <nl> + # if defined ( __cplusplus ) <nl> + extern " C " { <nl> + # endif <nl> + <nl> + / * = = = = = dependency = = = = = * / <nl> + # include < stddef . h > / * size_t * / <nl> + <nl> + <nl> + / * = = = = = ZSTDERRORLIB_API : control library symbols visibility = = = = = * / <nl> + # if defined ( __GNUC__ ) & & ( __GNUC__ > = 4 ) <nl> + # define ZSTDERRORLIB_VISIBILITY __attribute__ ( ( visibility ( " default " ) ) ) <nl> + # else <nl> + # define ZSTDERRORLIB_VISIBILITY <nl> + # endif <nl> + # if defined ( ZSTD_DLL_EXPORT ) & & ( ZSTD_DLL_EXPORT = = 1 ) <nl> + # define ZSTDERRORLIB_API __declspec ( dllexport ) ZSTDERRORLIB_VISIBILITY <nl> + # elif defined ( ZSTD_DLL_IMPORT ) & & ( ZSTD_DLL_IMPORT = = 1 ) <nl> + # define ZSTDERRORLIB_API __declspec ( dllimport ) ZSTDERRORLIB_VISIBILITY / * It isn ' t required but allows to generate better code , saving a function pointer load from the IAT and an indirect jump . * / <nl> + # else <nl> + # define ZSTDERRORLIB_API ZSTDERRORLIB_VISIBILITY <nl> + # endif <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * error codes list <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + typedef enum { <nl> + ZSTD_error_no_error , <nl> + ZSTD_error_GENERIC , <nl> + ZSTD_error_prefix_unknown , <nl> + ZSTD_error_version_unsupported , <nl> + ZSTD_error_parameter_unknown , <nl> + ZSTD_error_frameParameter_unsupported , <nl> + ZSTD_error_frameParameter_unsupportedBy32bits , <nl> + ZSTD_error_frameParameter_windowTooLarge , <nl> + ZSTD_error_compressionParameter_unsupported , <nl> + ZSTD_error_init_missing , <nl> + ZSTD_error_memory_allocation , <nl> + ZSTD_error_stage_wrong , <nl> + ZSTD_error_dstSize_tooSmall , <nl> + ZSTD_error_srcSize_wrong , <nl> + ZSTD_error_corruption_detected , <nl> + ZSTD_error_checksum_wrong , <nl> + ZSTD_error_tableLog_tooLarge , <nl> + ZSTD_error_maxSymbolValue_tooLarge , <nl> + ZSTD_error_maxSymbolValue_tooSmall , <nl> + ZSTD_error_dictionary_corrupted , <nl> + ZSTD_error_dictionary_wrong , <nl> + ZSTD_error_dictionaryCreation_failed , <nl> + ZSTD_error_maxCode <nl> + } ZSTD_ErrorCode ; <nl> + <nl> + / * ! ZSTD_getErrorCode ( ) : <nl> + convert a ` size_t ` function result into a ` ZSTD_ErrorCode ` enum type , <nl> + which can be used to compare directly with enum list published into " error_public . h " * / <nl> + ZSTDERRORLIB_API ZSTD_ErrorCode ZSTD_getErrorCode ( size_t functionResult ) ; <nl> + ZSTDERRORLIB_API const char * ZSTD_getErrorString ( ZSTD_ErrorCode code ) ; <nl> + <nl> + <nl> + # if defined ( __cplusplus ) <nl> + } <nl> + # endif <nl> + <nl> + # endif / * ZSTD_ERRORS_H_398273423 * / <nl> new file mode 100644 <nl> index 00000000000 . . 2533333ba83 <nl> mmm / dev / null <nl> ppp b / thirdparty / zstd / common / zstd_internal . h <nl> <nl> + / * * <nl> + * Copyright ( c ) 2016 - present , Yann Collet , Facebook , Inc . <nl> + * All rights reserved . <nl> + * <nl> + * This source code is licensed under the BSD - style license found in the <nl> + * LICENSE file in the root directory of this source tree . An additional grant <nl> + * of patent rights can be found in the PATENTS file in the same directory . <nl> + * / <nl> + <nl> + # ifndef ZSTD_CCOMMON_H_MODULE <nl> + # define ZSTD_CCOMMON_H_MODULE <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Compiler specifics <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # ifdef _MSC_VER / * Visual Studio * / <nl> + # define FORCE_INLINE static __forceinline <nl> + # include < intrin . h > / * For Visual 2005 * / <nl> + # pragma warning ( disable : 4100 ) / * disable : C4100 : unreferenced formal parameter * / <nl> + # pragma warning ( disable : 4127 ) / * disable : C4127 : conditional expression is constant * / <nl> + # pragma warning ( disable : 4324 ) / * disable : C4324 : padded structure * / <nl> + # else <nl> + # if defined ( __cplusplus ) | | defined ( __STDC_VERSION__ ) & & __STDC_VERSION__ > = 199901L / * C99 * / <nl> + # ifdef __GNUC__ <nl> + # define FORCE_INLINE static inline __attribute__ ( ( always_inline ) ) <nl> + # else <nl> + # define FORCE_INLINE static inline <nl> + # endif <nl> + # else <nl> + # define FORCE_INLINE static <nl> + # endif / * __STDC_VERSION__ * / <nl> + # endif <nl> + <nl> + # ifdef _MSC_VER <nl> + # define FORCE_NOINLINE static __declspec ( noinline ) <nl> + # else <nl> + # ifdef __GNUC__ <nl> + # define FORCE_NOINLINE static __attribute__ ( ( __noinline__ ) ) <nl> + # else <nl> + # define FORCE_NOINLINE static <nl> + # endif <nl> + # endif <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Dependencies <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # include " mem . h " <nl> + # include " error_private . h " <nl> + # define ZSTD_STATIC_LINKING_ONLY <nl> + # include " zstd . h " <nl> + # ifndef XXH_STATIC_LINKING_ONLY <nl> + # define XXH_STATIC_LINKING_ONLY / * XXH64_state_t * / <nl> + # endif <nl> + # include " xxhash . h " / * XXH_reset , update , digest * / <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * shared macros <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # undef MIN <nl> + # undef MAX <nl> + # define MIN ( a , b ) ( ( a ) < ( b ) ? ( a ) : ( b ) ) <nl> + # define MAX ( a , b ) ( ( a ) > ( b ) ? ( a ) : ( b ) ) <nl> + # define CHECK_F ( f ) { size_t const errcod = f ; if ( ERR_isError ( errcod ) ) return errcod ; } / * check and Forward error code * / <nl> + # define CHECK_E ( f , e ) { size_t const errcod = f ; if ( ERR_isError ( errcod ) ) return ERROR ( e ) ; } / * check and send Error code * / <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Common constants <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # define ZSTD_OPT_NUM ( 1 < < 12 ) <nl> + # define ZSTD_DICT_MAGIC 0xEC30A437 / * v0 . 7 + * / <nl> + <nl> + # define ZSTD_REP_NUM 3 / * number of repcodes * / <nl> + # define ZSTD_REP_CHECK ( ZSTD_REP_NUM ) / * number of repcodes to check by the optimal parser * / <nl> + # define ZSTD_REP_MOVE ( ZSTD_REP_NUM - 1 ) <nl> + # define ZSTD_REP_MOVE_OPT ( ZSTD_REP_NUM ) <nl> + static const U32 repStartValue [ ZSTD_REP_NUM ] = { 1 , 4 , 8 } ; <nl> + <nl> + # define KB * ( 1 < < 10 ) <nl> + # define MB * ( 1 < < 20 ) <nl> + # define GB * ( 1U < < 30 ) <nl> + <nl> + # define BIT7 128 <nl> + # define BIT6 64 <nl> + # define BIT5 32 <nl> + # define BIT4 16 <nl> + # define BIT1 2 <nl> + # define BIT0 1 <nl> + <nl> + # define ZSTD_WINDOWLOG_ABSOLUTEMIN 10 <nl> + static const size_t ZSTD_fcs_fieldSize [ 4 ] = { 0 , 2 , 4 , 8 } ; <nl> + static const size_t ZSTD_did_fieldSize [ 4 ] = { 0 , 1 , 2 , 4 } ; <nl> + <nl> + # define ZSTD_BLOCKHEADERSIZE 3 / * C standard doesn ' t allow ` static const ` variable to be init using another ` static const ` variable * / <nl> + static const size_t ZSTD_blockHeaderSize = ZSTD_BLOCKHEADERSIZE ; <nl> + typedef enum { bt_raw , bt_rle , bt_compressed , bt_reserved } blockType_e ; <nl> + <nl> + # define MIN_SEQUENCES_SIZE 1 / * nbSeq = = 0 * / <nl> + # define MIN_CBLOCK_SIZE ( 1 / * litCSize * / + 1 / * RLE or RAW * / + MIN_SEQUENCES_SIZE / * nbSeq = = 0 * / ) / * for a non - null block * / <nl> + <nl> + # define HufLog 12 <nl> + typedef enum { set_basic , set_rle , set_compressed , set_repeat } symbolEncodingType_e ; <nl> + <nl> + # define LONGNBSEQ 0x7F00 <nl> + <nl> + # define MINMATCH 3 <nl> + <nl> + # define Litbits 8 <nl> + # define MaxLit ( ( 1 < < Litbits ) - 1 ) <nl> + # define MaxML 52 <nl> + # define MaxLL 35 <nl> + # define MaxOff 28 <nl> + # define MaxSeq MAX ( MaxLL , MaxML ) / * Assumption : MaxOff < MaxLL , MaxML * / <nl> + # define MLFSELog 9 <nl> + # define LLFSELog 9 <nl> + # define OffFSELog 8 <nl> + <nl> + static const U32 LL_bits [ MaxLL + 1 ] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 1 , 1 , 1 , 1 , 2 , 2 , 3 , 3 , 4 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , <nl> + 13 , 14 , 15 , 16 } ; <nl> + static const S16 LL_defaultNorm [ MaxLL + 1 ] = { 4 , 3 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 1 , 1 , 1 , <nl> + 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 3 , 2 , 1 , 1 , 1 , 1 , 1 , <nl> + - 1 , - 1 , - 1 , - 1 } ; <nl> + # define LL_DEFAULTNORMLOG 6 / * for static allocation * / <nl> + static const U32 LL_defaultNormLog = LL_DEFAULTNORMLOG ; <nl> + <nl> + static const U32 ML_bits [ MaxML + 1 ] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 1 , 1 , 1 , 1 , 2 , 2 , 3 , 3 , 4 , 4 , 5 , 7 , 8 , 9 , 10 , 11 , <nl> + 12 , 13 , 14 , 15 , 16 } ; <nl> + static const S16 ML_defaultNorm [ MaxML + 1 ] = { 1 , 4 , 3 , 2 , 2 , 2 , 2 , 2 , 2 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , <nl> + 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , <nl> + 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , - 1 , - 1 , <nl> + - 1 , - 1 , - 1 , - 1 , - 1 } ; <nl> + # define ML_DEFAULTNORMLOG 6 / * for static allocation * / <nl> + static const U32 ML_defaultNormLog = ML_DEFAULTNORMLOG ; <nl> + <nl> + static const S16 OF_defaultNorm [ MaxOff + 1 ] = { 1 , 1 , 1 , 1 , 1 , 1 , 2 , 2 , 2 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , <nl> + 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , - 1 , - 1 , - 1 , - 1 , - 1 } ; <nl> + # define OF_DEFAULTNORMLOG 5 / * for static allocation * / <nl> + static const U32 OF_defaultNormLog = OF_DEFAULTNORMLOG ; <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Shared functions to include for inlining <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + static void ZSTD_copy8 ( void * dst , const void * src ) { memcpy ( dst , src , 8 ) ; } <nl> + # define COPY8 ( d , s ) { ZSTD_copy8 ( d , s ) ; d + = 8 ; s + = 8 ; } <nl> + <nl> + / * ! ZSTD_wildcopy ( ) : <nl> + * custom version of memcpy ( ) , can copy up to 7 bytes too many ( 8 bytes if length = = 0 ) * / <nl> + # define WILDCOPY_OVERLENGTH 8 <nl> + MEM_STATIC void ZSTD_wildcopy ( void * dst , const void * src , ptrdiff_t length ) <nl> + { <nl> + const BYTE * ip = ( const BYTE * ) src ; <nl> + BYTE * op = ( BYTE * ) dst ; <nl> + BYTE * const oend = op + length ; <nl> + do <nl> + COPY8 ( op , ip ) <nl> + while ( op < oend ) ; <nl> + } <nl> + <nl> + MEM_STATIC void ZSTD_wildcopy_e ( void * dst , const void * src , void * dstEnd ) / * should be faster for decoding , but strangely , not verified on all platform * / <nl> + { <nl> + const BYTE * ip = ( const BYTE * ) src ; <nl> + BYTE * op = ( BYTE * ) dst ; <nl> + BYTE * const oend = ( BYTE * ) dstEnd ; <nl> + do <nl> + COPY8 ( op , ip ) <nl> + while ( op < oend ) ; <nl> + } <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Private interfaces <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + typedef struct ZSTD_stats_s ZSTD_stats_t ; <nl> + <nl> + typedef struct { <nl> + U32 off ; <nl> + U32 len ; <nl> + } ZSTD_match_t ; <nl> + <nl> + typedef struct { <nl> + U32 price ; <nl> + U32 off ; <nl> + U32 mlen ; <nl> + U32 litlen ; <nl> + U32 rep [ ZSTD_REP_NUM ] ; <nl> + } ZSTD_optimal_t ; <nl> + <nl> + <nl> + typedef struct seqDef_s { <nl> + U32 offset ; <nl> + U16 litLength ; <nl> + U16 matchLength ; <nl> + } seqDef ; <nl> + <nl> + <nl> + typedef struct { <nl> + seqDef * sequencesStart ; <nl> + seqDef * sequences ; <nl> + BYTE * litStart ; <nl> + BYTE * lit ; <nl> + BYTE * llCode ; <nl> + BYTE * mlCode ; <nl> + BYTE * ofCode ; <nl> + U32 longLengthID ; / * 0 = = no longLength ; 1 = = Lit . longLength ; 2 = = Match . longLength ; * / <nl> + U32 longLengthPos ; <nl> + / * opt * / <nl> + ZSTD_optimal_t * priceTable ; <nl> + ZSTD_match_t * matchTable ; <nl> + U32 * matchLengthFreq ; <nl> + U32 * litLengthFreq ; <nl> + U32 * litFreq ; <nl> + U32 * offCodeFreq ; <nl> + U32 matchLengthSum ; <nl> + U32 matchSum ; <nl> + U32 litLengthSum ; <nl> + U32 litSum ; <nl> + U32 offCodeSum ; <nl> + U32 log2matchLengthSum ; <nl> + U32 log2matchSum ; <nl> + U32 log2litLengthSum ; <nl> + U32 log2litSum ; <nl> + U32 log2offCodeSum ; <nl> + U32 factor ; <nl> + U32 staticPrices ; <nl> + U32 cachedPrice ; <nl> + U32 cachedLitLength ; <nl> + const BYTE * cachedLiterals ; <nl> + } seqStore_t ; <nl> + <nl> + const seqStore_t * ZSTD_getSeqStore ( const ZSTD_CCtx * ctx ) ; <nl> + void ZSTD_seqToCodes ( const seqStore_t * seqStorePtr ) ; <nl> + int ZSTD_isSkipFrame ( ZSTD_DCtx * dctx ) ; <nl> + <nl> + / * custom memory allocation functions * / <nl> + void * ZSTD_defaultAllocFunction ( void * opaque , size_t size ) ; <nl> + void ZSTD_defaultFreeFunction ( void * opaque , void * address ) ; <nl> + # ifndef ZSTD_DLL_IMPORT <nl> + static const ZSTD_customMem defaultCustomMem = { ZSTD_defaultAllocFunction , ZSTD_defaultFreeFunction , NULL } ; <nl> + # endif <nl> + void * ZSTD_malloc ( size_t size , ZSTD_customMem customMem ) ; <nl> + void ZSTD_free ( void * ptr , ZSTD_customMem customMem ) ; <nl> + <nl> + <nl> + / * = = = = = = common function = = = = = = * / <nl> + <nl> + MEM_STATIC U32 ZSTD_highbit32 ( U32 val ) <nl> + { <nl> + # if defined ( _MSC_VER ) / * Visual * / <nl> + unsigned long r = 0 ; <nl> + _BitScanReverse ( & r , val ) ; <nl> + return ( unsigned ) r ; <nl> + # elif defined ( __GNUC__ ) & & ( __GNUC__ > = 3 ) / * GCC Intrinsic * / <nl> + return 31 - __builtin_clz ( val ) ; <nl> + # else / * Software version * / <nl> + static const int DeBruijnClz [ 32 ] = { 0 , 9 , 1 , 10 , 13 , 21 , 2 , 29 , 11 , 14 , 16 , 18 , 22 , 25 , 3 , 30 , 8 , 12 , 20 , 28 , 15 , 17 , 24 , 7 , 19 , 27 , 23 , 6 , 26 , 5 , 4 , 31 } ; <nl> + U32 v = val ; <nl> + int r ; <nl> + v | = v > > 1 ; <nl> + v | = v > > 2 ; <nl> + v | = v > > 4 ; <nl> + v | = v > > 8 ; <nl> + v | = v > > 16 ; <nl> + r = DeBruijnClz [ ( U32 ) ( v * 0x07C4ACDDU ) > > 27 ] ; <nl> + return r ; <nl> + # endif <nl> + } <nl> + <nl> + <nl> + / * hidden functions * / <nl> + <nl> + / * ZSTD_invalidateRepCodes ( ) : <nl> + * ensures next compression will not use repcodes from previous block . <nl> + * Note : only works with regular variant ; <nl> + * do not use with extDict variant ! * / <nl> + void ZSTD_invalidateRepCodes ( ZSTD_CCtx * cctx ) ; <nl> + <nl> + <nl> + # endif / * ZSTD_CCOMMON_H_MODULE * / <nl> new file mode 100644 <nl> index 00000000000 . . 26e8052ddcc <nl> mmm / dev / null <nl> ppp b / thirdparty / zstd / compress / fse_compress . c <nl> <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + FSE : Finite State Entropy encoder <nl> + Copyright ( C ) 2013 - 2015 , Yann Collet . <nl> + <nl> + BSD 2 - Clause License ( http : / / www . opensource . org / licenses / bsd - license . php ) <nl> + <nl> + Redistribution and use in source and binary forms , with or without <nl> + modification , are permitted provided that the following conditions are <nl> + met : <nl> + <nl> + * Redistributions of source code must retain the above copyright <nl> + notice , this list of conditions and the following disclaimer . <nl> + * Redistributions in binary form must reproduce the above <nl> + copyright notice , this list of conditions and the following disclaimer <nl> + in the documentation and / or other materials provided with the <nl> + distribution . <nl> + <nl> + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + <nl> + You can contact the author at : <nl> + - FSE source repository : https : / / github . com / Cyan4973 / FiniteStateEntropy <nl> + - Public forum : https : / / groups . google . com / forum / # ! forum / lz4c <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Compiler specifics <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # ifdef _MSC_VER / * Visual Studio * / <nl> + # define FORCE_INLINE static __forceinline <nl> + # include < intrin . h > / * For Visual 2005 * / <nl> + # pragma warning ( disable : 4127 ) / * disable : C4127 : conditional expression is constant * / <nl> + # pragma warning ( disable : 4214 ) / * disable : C4214 : non - int bitfields * / <nl> + # else <nl> + # if defined ( __cplusplus ) | | defined ( __STDC_VERSION__ ) & & __STDC_VERSION__ > = 199901L / * C99 * / <nl> + # ifdef __GNUC__ <nl> + # define FORCE_INLINE static inline __attribute__ ( ( always_inline ) ) <nl> + # else <nl> + # define FORCE_INLINE static inline <nl> + # endif <nl> + # else <nl> + # define FORCE_INLINE static <nl> + # endif / * __STDC_VERSION__ * / <nl> + # endif <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Includes <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # include < stdlib . h > / * malloc , free , qsort * / <nl> + # include < string . h > / * memcpy , memset * / <nl> + # include < stdio . h > / * printf ( debug ) * / <nl> + # include " bitstream . h " <nl> + # define FSE_STATIC_LINKING_ONLY <nl> + # include " fse . h " <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Error Management <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # define FSE_STATIC_ASSERT ( c ) { enum { FSE_static_assert = 1 / ( int ) ( ! ! ( c ) ) } ; } / * use only * after * variable declarations * / <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Templates <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * <nl> + designed to be included <nl> + for type - specific functions ( template emulation in C ) <nl> + Objective is to write these functions only once , for improved maintenance <nl> + * / <nl> + <nl> + / * safety checks * / <nl> + # ifndef FSE_FUNCTION_EXTENSION <nl> + # error " FSE_FUNCTION_EXTENSION must be defined " <nl> + # endif <nl> + # ifndef FSE_FUNCTION_TYPE <nl> + # error " FSE_FUNCTION_TYPE must be defined " <nl> + # endif <nl> + <nl> + / * Function names * / <nl> + # define FSE_CAT ( X , Y ) X # # Y <nl> + # define FSE_FUNCTION_NAME ( X , Y ) FSE_CAT ( X , Y ) <nl> + # define FSE_TYPE_NAME ( X , Y ) FSE_CAT ( X , Y ) <nl> + <nl> + <nl> + / * Function templates * / <nl> + <nl> + / * FSE_buildCTable_wksp ( ) : <nl> + * Same as FSE_buildCTable ( ) , but using an externally allocated scratch buffer ( ` workSpace ` ) . <nl> + * wkspSize should be sized to handle worst case situation , which is ` 1 < < max_tableLog * sizeof ( FSE_FUNCTION_TYPE ) ` <nl> + * workSpace must also be properly aligned with FSE_FUNCTION_TYPE requirements <nl> + * / <nl> + size_t FSE_buildCTable_wksp ( FSE_CTable * ct , const short * normalizedCounter , unsigned maxSymbolValue , unsigned tableLog , void * workSpace , size_t wkspSize ) <nl> + { <nl> + U32 const tableSize = 1 < < tableLog ; <nl> + U32 const tableMask = tableSize - 1 ; <nl> + void * const ptr = ct ; <nl> + U16 * const tableU16 = ( ( U16 * ) ptr ) + 2 ; <nl> + void * const FSCT = ( ( U32 * ) ptr ) + 1 / * header * / + ( tableLog ? tableSize > > 1 : 1 ) ; <nl> + FSE_symbolCompressionTransform * const symbolTT = ( FSE_symbolCompressionTransform * ) ( FSCT ) ; <nl> + U32 const step = FSE_TABLESTEP ( tableSize ) ; <nl> + U32 cumul [ FSE_MAX_SYMBOL_VALUE + 2 ] ; <nl> + <nl> + FSE_FUNCTION_TYPE * const tableSymbol = ( FSE_FUNCTION_TYPE * ) workSpace ; <nl> + U32 highThreshold = tableSize - 1 ; <nl> + <nl> + / * CTable header * / <nl> + if ( ( ( size_t ) 1 < < tableLog ) * sizeof ( FSE_FUNCTION_TYPE ) > wkspSize ) return ERROR ( tableLog_tooLarge ) ; <nl> + tableU16 [ - 2 ] = ( U16 ) tableLog ; <nl> + tableU16 [ - 1 ] = ( U16 ) maxSymbolValue ; <nl> + <nl> + / * For explanations on how to distribute symbol values over the table : <nl> + * http : / / fastcompression . blogspot . fr / 2014 / 02 / fse - distributing - symbol - values . html * / <nl> + <nl> + / * symbol start positions * / <nl> + { U32 u ; <nl> + cumul [ 0 ] = 0 ; <nl> + for ( u = 1 ; u < = maxSymbolValue + 1 ; u + + ) { <nl> + if ( normalizedCounter [ u - 1 ] = = - 1 ) { / * Low proba symbol * / <nl> + cumul [ u ] = cumul [ u - 1 ] + 1 ; <nl> + tableSymbol [ highThreshold - - ] = ( FSE_FUNCTION_TYPE ) ( u - 1 ) ; <nl> + } else { <nl> + cumul [ u ] = cumul [ u - 1 ] + normalizedCounter [ u - 1 ] ; <nl> + } } <nl> + cumul [ maxSymbolValue + 1 ] = tableSize + 1 ; <nl> + } <nl> + <nl> + / * Spread symbols * / <nl> + { U32 position = 0 ; <nl> + U32 symbol ; <nl> + for ( symbol = 0 ; symbol < = maxSymbolValue ; symbol + + ) { <nl> + int nbOccurences ; <nl> + for ( nbOccurences = 0 ; nbOccurences < normalizedCounter [ symbol ] ; nbOccurences + + ) { <nl> + tableSymbol [ position ] = ( FSE_FUNCTION_TYPE ) symbol ; <nl> + position = ( position + step ) & tableMask ; <nl> + while ( position > highThreshold ) position = ( position + step ) & tableMask ; / * Low proba area * / <nl> + } } <nl> + <nl> + if ( position ! = 0 ) return ERROR ( GENERIC ) ; / * Must have gone through all positions * / <nl> + } <nl> + <nl> + / * Build table * / <nl> + { U32 u ; for ( u = 0 ; u < tableSize ; u + + ) { <nl> + FSE_FUNCTION_TYPE s = tableSymbol [ u ] ; / * note : static analyzer may not understand tableSymbol is properly initialized * / <nl> + tableU16 [ cumul [ s ] + + ] = ( U16 ) ( tableSize + u ) ; / * TableU16 : sorted by symbol order ; gives next state value * / <nl> + } } <nl> + <nl> + / * Build Symbol Transformation Table * / <nl> + { unsigned total = 0 ; <nl> + unsigned s ; <nl> + for ( s = 0 ; s < = maxSymbolValue ; s + + ) { <nl> + switch ( normalizedCounter [ s ] ) <nl> + { <nl> + case 0 : break ; <nl> + <nl> + case - 1 : <nl> + case 1 : <nl> + symbolTT [ s ] . deltaNbBits = ( tableLog < < 16 ) - ( 1 < < tableLog ) ; <nl> + symbolTT [ s ] . deltaFindState = total - 1 ; <nl> + total + + ; <nl> + break ; <nl> + default : <nl> + { <nl> + U32 const maxBitsOut = tableLog - BIT_highbit32 ( normalizedCounter [ s ] - 1 ) ; <nl> + U32 const minStatePlus = normalizedCounter [ s ] < < maxBitsOut ; <nl> + symbolTT [ s ] . deltaNbBits = ( maxBitsOut < < 16 ) - minStatePlus ; <nl> + symbolTT [ s ] . deltaFindState = total - normalizedCounter [ s ] ; <nl> + total + = normalizedCounter [ s ] ; <nl> + } } } } <nl> + <nl> + return 0 ; <nl> + } <nl> + <nl> + <nl> + size_t FSE_buildCTable ( FSE_CTable * ct , const short * normalizedCounter , unsigned maxSymbolValue , unsigned tableLog ) <nl> + { <nl> + FSE_FUNCTION_TYPE tableSymbol [ FSE_MAX_TABLESIZE ] ; / * memset ( ) is not necessary , even if static analyzer complain about it * / <nl> + return FSE_buildCTable_wksp ( ct , normalizedCounter , maxSymbolValue , tableLog , tableSymbol , sizeof ( tableSymbol ) ) ; <nl> + } <nl> + <nl> + <nl> + <nl> + # ifndef FSE_COMMONDEFS_ONLY <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * FSE NCount encoding - decoding <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + size_t FSE_NCountWriteBound ( unsigned maxSymbolValue , unsigned tableLog ) <nl> + { <nl> + size_t const maxHeaderSize = ( ( ( maxSymbolValue + 1 ) * tableLog ) > > 3 ) + 3 ; <nl> + return maxSymbolValue ? maxHeaderSize : FSE_NCOUNTBOUND ; / * maxSymbolValue = = 0 ? use default * / <nl> + } <nl> + <nl> + static size_t FSE_writeNCount_generic ( void * header , size_t headerBufferSize , <nl> + const short * normalizedCounter , unsigned maxSymbolValue , unsigned tableLog , <nl> + unsigned writeIsSafe ) <nl> + { <nl> + BYTE * const ostart = ( BYTE * ) header ; <nl> + BYTE * out = ostart ; <nl> + BYTE * const oend = ostart + headerBufferSize ; <nl> + int nbBits ; <nl> + const int tableSize = 1 < < tableLog ; <nl> + int remaining ; <nl> + int threshold ; <nl> + U32 bitStream ; <nl> + int bitCount ; <nl> + unsigned charnum = 0 ; <nl> + int previous0 = 0 ; <nl> + <nl> + bitStream = 0 ; <nl> + bitCount = 0 ; <nl> + / * Table Size * / <nl> + bitStream + = ( tableLog - FSE_MIN_TABLELOG ) < < bitCount ; <nl> + bitCount + = 4 ; <nl> + <nl> + / * Init * / <nl> + remaining = tableSize + 1 ; / * + 1 for extra accuracy * / <nl> + threshold = tableSize ; <nl> + nbBits = tableLog + 1 ; <nl> + <nl> + while ( remaining > 1 ) { / * stops at 1 * / <nl> + if ( previous0 ) { <nl> + unsigned start = charnum ; <nl> + while ( ! normalizedCounter [ charnum ] ) charnum + + ; <nl> + while ( charnum > = start + 24 ) { <nl> + start + = 24 ; <nl> + bitStream + = 0xFFFFU < < bitCount ; <nl> + if ( ( ! writeIsSafe ) & & ( out > oend - 2 ) ) return ERROR ( dstSize_tooSmall ) ; / * Buffer overflow * / <nl> + out [ 0 ] = ( BYTE ) bitStream ; <nl> + out [ 1 ] = ( BYTE ) ( bitStream > > 8 ) ; <nl> + out + = 2 ; <nl> + bitStream > > = 16 ; <nl> + } <nl> + while ( charnum > = start + 3 ) { <nl> + start + = 3 ; <nl> + bitStream + = 3 < < bitCount ; <nl> + bitCount + = 2 ; <nl> + } <nl> + bitStream + = ( charnum - start ) < < bitCount ; <nl> + bitCount + = 2 ; <nl> + if ( bitCount > 16 ) { <nl> + if ( ( ! writeIsSafe ) & & ( out > oend - 2 ) ) return ERROR ( dstSize_tooSmall ) ; / * Buffer overflow * / <nl> + out [ 0 ] = ( BYTE ) bitStream ; <nl> + out [ 1 ] = ( BYTE ) ( bitStream > > 8 ) ; <nl> + out + = 2 ; <nl> + bitStream > > = 16 ; <nl> + bitCount - = 16 ; <nl> + } } <nl> + { int count = normalizedCounter [ charnum + + ] ; <nl> + int const max = ( 2 * threshold - 1 ) - remaining ; <nl> + remaining - = count < 0 ? - count : count ; <nl> + count + + ; / * + 1 for extra accuracy * / <nl> + if ( count > = threshold ) count + = max ; / * [ 0 . . max [ [ max . . threshold [ ( . . . ) [ threshold + max 2 * threshold [ * / <nl> + bitStream + = count < < bitCount ; <nl> + bitCount + = nbBits ; <nl> + bitCount - = ( count < max ) ; <nl> + previous0 = ( count = = 1 ) ; <nl> + if ( remaining < 1 ) return ERROR ( GENERIC ) ; <nl> + while ( remaining < threshold ) nbBits - - , threshold > > = 1 ; <nl> + } <nl> + if ( bitCount > 16 ) { <nl> + if ( ( ! writeIsSafe ) & & ( out > oend - 2 ) ) return ERROR ( dstSize_tooSmall ) ; / * Buffer overflow * / <nl> + out [ 0 ] = ( BYTE ) bitStream ; <nl> + out [ 1 ] = ( BYTE ) ( bitStream > > 8 ) ; <nl> + out + = 2 ; <nl> + bitStream > > = 16 ; <nl> + bitCount - = 16 ; <nl> + } } <nl> + <nl> + / * flush remaining bitStream * / <nl> + if ( ( ! writeIsSafe ) & & ( out > oend - 2 ) ) return ERROR ( dstSize_tooSmall ) ; / * Buffer overflow * / <nl> + out [ 0 ] = ( BYTE ) bitStream ; <nl> + out [ 1 ] = ( BYTE ) ( bitStream > > 8 ) ; <nl> + out + = ( bitCount + 7 ) / 8 ; <nl> + <nl> + if ( charnum > maxSymbolValue + 1 ) return ERROR ( GENERIC ) ; <nl> + <nl> + return ( out - ostart ) ; <nl> + } <nl> + <nl> + <nl> + size_t FSE_writeNCount ( void * buffer , size_t bufferSize , const short * normalizedCounter , unsigned maxSymbolValue , unsigned tableLog ) <nl> + { <nl> + if ( tableLog > FSE_MAX_TABLELOG ) return ERROR ( tableLog_tooLarge ) ; / * Unsupported * / <nl> + if ( tableLog < FSE_MIN_TABLELOG ) return ERROR ( GENERIC ) ; / * Unsupported * / <nl> + <nl> + if ( bufferSize < FSE_NCountWriteBound ( maxSymbolValue , tableLog ) ) <nl> + return FSE_writeNCount_generic ( buffer , bufferSize , normalizedCounter , maxSymbolValue , tableLog , 0 ) ; <nl> + <nl> + return FSE_writeNCount_generic ( buffer , bufferSize , normalizedCounter , maxSymbolValue , tableLog , 1 ) ; <nl> + } <nl> + <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Counting histogram <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * ! FSE_count_simple <nl> + This function counts byte values within ` src ` , and store the histogram into table ` count ` . <nl> + It doesn ' t use any additional memory . <nl> + But this function is unsafe : it doesn ' t check that all values within ` src ` can fit into ` count ` . <nl> + For this reason , prefer using a table ` count ` with 256 elements . <nl> + @ return : count of most numerous element <nl> + * / <nl> + size_t FSE_count_simple ( unsigned * count , unsigned * maxSymbolValuePtr , <nl> + const void * src , size_t srcSize ) <nl> + { <nl> + const BYTE * ip = ( const BYTE * ) src ; <nl> + const BYTE * const end = ip + srcSize ; <nl> + unsigned maxSymbolValue = * maxSymbolValuePtr ; <nl> + unsigned max = 0 ; <nl> + <nl> + memset ( count , 0 , ( maxSymbolValue + 1 ) * sizeof ( * count ) ) ; <nl> + if ( srcSize = = 0 ) { * maxSymbolValuePtr = 0 ; return 0 ; } <nl> + <nl> + while ( ip < end ) count [ * ip + + ] + + ; <nl> + <nl> + while ( ! count [ maxSymbolValue ] ) maxSymbolValue - - ; <nl> + * maxSymbolValuePtr = maxSymbolValue ; <nl> + <nl> + { U32 s ; for ( s = 0 ; s < = maxSymbolValue ; s + + ) if ( count [ s ] > max ) max = count [ s ] ; } <nl> + <nl> + return ( size_t ) max ; <nl> + } <nl> + <nl> + <nl> + / * FSE_count_parallel_wksp ( ) : <nl> + * Same as FSE_count_parallel ( ) , but using an externally provided scratch buffer . <nl> + * ` workSpace ` size must be a minimum of ` 1024 * sizeof ( unsigned ) ` ` * / <nl> + static size_t FSE_count_parallel_wksp ( <nl> + unsigned * count , unsigned * maxSymbolValuePtr , <nl> + const void * source , size_t sourceSize , <nl> + unsigned checkMax , unsigned * const workSpace ) <nl> + { <nl> + const BYTE * ip = ( const BYTE * ) source ; <nl> + const BYTE * const iend = ip + sourceSize ; <nl> + unsigned maxSymbolValue = * maxSymbolValuePtr ; <nl> + unsigned max = 0 ; <nl> + U32 * const Counting1 = workSpace ; <nl> + U32 * const Counting2 = Counting1 + 256 ; <nl> + U32 * const Counting3 = Counting2 + 256 ; <nl> + U32 * const Counting4 = Counting3 + 256 ; <nl> + <nl> + memset ( Counting1 , 0 , 4 * 256 * sizeof ( unsigned ) ) ; <nl> + <nl> + / * safety checks * / <nl> + if ( ! sourceSize ) { <nl> + memset ( count , 0 , maxSymbolValue + 1 ) ; <nl> + * maxSymbolValuePtr = 0 ; <nl> + return 0 ; <nl> + } <nl> + if ( ! maxSymbolValue ) maxSymbolValue = 255 ; / * 0 = = default * / <nl> + <nl> + / * by stripes of 16 bytes * / <nl> + { U32 cached = MEM_read32 ( ip ) ; ip + = 4 ; <nl> + while ( ip < iend - 15 ) { <nl> + U32 c = cached ; cached = MEM_read32 ( ip ) ; ip + = 4 ; <nl> + Counting1 [ ( BYTE ) c ] + + ; <nl> + Counting2 [ ( BYTE ) ( c > > 8 ) ] + + ; <nl> + Counting3 [ ( BYTE ) ( c > > 16 ) ] + + ; <nl> + Counting4 [ c > > 24 ] + + ; <nl> + c = cached ; cached = MEM_read32 ( ip ) ; ip + = 4 ; <nl> + Counting1 [ ( BYTE ) c ] + + ; <nl> + Counting2 [ ( BYTE ) ( c > > 8 ) ] + + ; <nl> + Counting3 [ ( BYTE ) ( c > > 16 ) ] + + ; <nl> + Counting4 [ c > > 24 ] + + ; <nl> + c = cached ; cached = MEM_read32 ( ip ) ; ip + = 4 ; <nl> + Counting1 [ ( BYTE ) c ] + + ; <nl> + Counting2 [ ( BYTE ) ( c > > 8 ) ] + + ; <nl> + Counting3 [ ( BYTE ) ( c > > 16 ) ] + + ; <nl> + Counting4 [ c > > 24 ] + + ; <nl> + c = cached ; cached = MEM_read32 ( ip ) ; ip + = 4 ; <nl> + Counting1 [ ( BYTE ) c ] + + ; <nl> + Counting2 [ ( BYTE ) ( c > > 8 ) ] + + ; <nl> + Counting3 [ ( BYTE ) ( c > > 16 ) ] + + ; <nl> + Counting4 [ c > > 24 ] + + ; <nl> + } <nl> + ip - = 4 ; <nl> + } <nl> + <nl> + / * finish last symbols * / <nl> + while ( ip < iend ) Counting1 [ * ip + + ] + + ; <nl> + <nl> + if ( checkMax ) { / * verify stats will fit into destination table * / <nl> + U32 s ; for ( s = 255 ; s > maxSymbolValue ; s - - ) { <nl> + Counting1 [ s ] + = Counting2 [ s ] + Counting3 [ s ] + Counting4 [ s ] ; <nl> + if ( Counting1 [ s ] ) return ERROR ( maxSymbolValue_tooSmall ) ; <nl> + } } <nl> + <nl> + { U32 s ; for ( s = 0 ; s < = maxSymbolValue ; s + + ) { <nl> + count [ s ] = Counting1 [ s ] + Counting2 [ s ] + Counting3 [ s ] + Counting4 [ s ] ; <nl> + if ( count [ s ] > max ) max = count [ s ] ; <nl> + } } <nl> + <nl> + while ( ! count [ maxSymbolValue ] ) maxSymbolValue - - ; <nl> + * maxSymbolValuePtr = maxSymbolValue ; <nl> + return ( size_t ) max ; <nl> + } <nl> + <nl> + / * FSE_countFast_wksp ( ) : <nl> + * Same as FSE_countFast ( ) , but using an externally provided scratch buffer . <nl> + * ` workSpace ` size must be table of > = ` 1024 ` unsigned * / <nl> + size_t FSE_countFast_wksp ( unsigned * count , unsigned * maxSymbolValuePtr , <nl> + const void * source , size_t sourceSize , unsigned * workSpace ) <nl> + { <nl> + if ( sourceSize < 1500 ) return FSE_count_simple ( count , maxSymbolValuePtr , source , sourceSize ) ; <nl> + return FSE_count_parallel_wksp ( count , maxSymbolValuePtr , source , sourceSize , 0 , workSpace ) ; <nl> + } <nl> + <nl> + / * fast variant ( unsafe : won ' t check if src contains values beyond count [ ] limit ) * / <nl> + size_t FSE_countFast ( unsigned * count , unsigned * maxSymbolValuePtr , <nl> + const void * source , size_t sourceSize ) <nl> + { <nl> + unsigned tmpCounters [ 1024 ] ; <nl> + return FSE_countFast_wksp ( count , maxSymbolValuePtr , source , sourceSize , tmpCounters ) ; <nl> + } <nl> + <nl> + / * FSE_count_wksp ( ) : <nl> + * Same as FSE_count ( ) , but using an externally provided scratch buffer . <nl> + * ` workSpace ` size must be table of > = ` 1024 ` unsigned * / <nl> + size_t FSE_count_wksp ( unsigned * count , unsigned * maxSymbolValuePtr , <nl> + const void * source , size_t sourceSize , unsigned * workSpace ) <nl> + { <nl> + if ( * maxSymbolValuePtr < 255 ) <nl> + return FSE_count_parallel_wksp ( count , maxSymbolValuePtr , source , sourceSize , 1 , workSpace ) ; <nl> + * maxSymbolValuePtr = 255 ; <nl> + return FSE_countFast_wksp ( count , maxSymbolValuePtr , source , sourceSize , workSpace ) ; <nl> + } <nl> + <nl> + size_t FSE_count ( unsigned * count , unsigned * maxSymbolValuePtr , <nl> + const void * src , size_t srcSize ) <nl> + { <nl> + unsigned tmpCounters [ 1024 ] ; <nl> + return FSE_count_wksp ( count , maxSymbolValuePtr , src , srcSize , tmpCounters ) ; <nl> + } <nl> + <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * FSE Compression Code <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * ! FSE_sizeof_CTable ( ) : <nl> + FSE_CTable is a variable size structure which contains : <nl> + ` U16 tableLog ; ` <nl> + ` U16 maxSymbolValue ; ` <nl> + ` U16 nextStateNumber [ 1 < < tableLog ] ; ` / / This size is variable <nl> + ` FSE_symbolCompressionTransform symbolTT [ maxSymbolValue + 1 ] ; ` / / This size is variable <nl> + Allocation is manual ( C standard does not support variable - size structures ) . <nl> + * / <nl> + size_t FSE_sizeof_CTable ( unsigned maxSymbolValue , unsigned tableLog ) <nl> + { <nl> + if ( tableLog > FSE_MAX_TABLELOG ) return ERROR ( tableLog_tooLarge ) ; <nl> + return FSE_CTABLE_SIZE_U32 ( tableLog , maxSymbolValue ) * sizeof ( U32 ) ; <nl> + } <nl> + <nl> + FSE_CTable * FSE_createCTable ( unsigned maxSymbolValue , unsigned tableLog ) <nl> + { <nl> + size_t size ; <nl> + if ( tableLog > FSE_TABLELOG_ABSOLUTE_MAX ) tableLog = FSE_TABLELOG_ABSOLUTE_MAX ; <nl> + size = FSE_CTABLE_SIZE_U32 ( tableLog , maxSymbolValue ) * sizeof ( U32 ) ; <nl> + return ( FSE_CTable * ) malloc ( size ) ; <nl> + } <nl> + <nl> + void FSE_freeCTable ( FSE_CTable * ct ) { free ( ct ) ; } <nl> + <nl> + / * provides the minimum logSize to safely represent a distribution * / <nl> + static unsigned FSE_minTableLog ( size_t srcSize , unsigned maxSymbolValue ) <nl> + { <nl> + U32 minBitsSrc = BIT_highbit32 ( ( U32 ) ( srcSize - 1 ) ) + 1 ; <nl> + U32 minBitsSymbols = BIT_highbit32 ( maxSymbolValue ) + 2 ; <nl> + U32 minBits = minBitsSrc < minBitsSymbols ? minBitsSrc : minBitsSymbols ; <nl> + return minBits ; <nl> + } <nl> + <nl> + unsigned FSE_optimalTableLog_internal ( unsigned maxTableLog , size_t srcSize , unsigned maxSymbolValue , unsigned minus ) <nl> + { <nl> + U32 maxBitsSrc = BIT_highbit32 ( ( U32 ) ( srcSize - 1 ) ) - minus ; <nl> + U32 tableLog = maxTableLog ; <nl> + U32 minBits = FSE_minTableLog ( srcSize , maxSymbolValue ) ; <nl> + if ( tableLog = = 0 ) tableLog = FSE_DEFAULT_TABLELOG ; <nl> + if ( maxBitsSrc < tableLog ) tableLog = maxBitsSrc ; / * Accuracy can be reduced * / <nl> + if ( minBits > tableLog ) tableLog = minBits ; / * Need a minimum to safely represent all symbol values * / <nl> + if ( tableLog < FSE_MIN_TABLELOG ) tableLog = FSE_MIN_TABLELOG ; <nl> + if ( tableLog > FSE_MAX_TABLELOG ) tableLog = FSE_MAX_TABLELOG ; <nl> + return tableLog ; <nl> + } <nl> + <nl> + unsigned FSE_optimalTableLog ( unsigned maxTableLog , size_t srcSize , unsigned maxSymbolValue ) <nl> + { <nl> + return FSE_optimalTableLog_internal ( maxTableLog , srcSize , maxSymbolValue , 2 ) ; <nl> + } <nl> + <nl> + <nl> + / * Secondary normalization method . <nl> + To be used when primary method fails . * / <nl> + <nl> + static size_t FSE_normalizeM2 ( short * norm , U32 tableLog , const unsigned * count , size_t total , U32 maxSymbolValue ) <nl> + { <nl> + short const NOT_YET_ASSIGNED = - 2 ; <nl> + U32 s ; <nl> + U32 distributed = 0 ; <nl> + U32 ToDistribute ; <nl> + <nl> + / * Init * / <nl> + U32 const lowThreshold = ( U32 ) ( total > > tableLog ) ; <nl> + U32 lowOne = ( U32 ) ( ( total * 3 ) > > ( tableLog + 1 ) ) ; <nl> + <nl> + for ( s = 0 ; s < = maxSymbolValue ; s + + ) { <nl> + if ( count [ s ] = = 0 ) { <nl> + norm [ s ] = 0 ; <nl> + continue ; <nl> + } <nl> + if ( count [ s ] < = lowThreshold ) { <nl> + norm [ s ] = - 1 ; <nl> + distributed + + ; <nl> + total - = count [ s ] ; <nl> + continue ; <nl> + } <nl> + if ( count [ s ] < = lowOne ) { <nl> + norm [ s ] = 1 ; <nl> + distributed + + ; <nl> + total - = count [ s ] ; <nl> + continue ; <nl> + } <nl> + <nl> + norm [ s ] = NOT_YET_ASSIGNED ; <nl> + } <nl> + ToDistribute = ( 1 < < tableLog ) - distributed ; <nl> + <nl> + if ( ( total / ToDistribute ) > lowOne ) { <nl> + / * risk of rounding to zero * / <nl> + lowOne = ( U32 ) ( ( total * 3 ) / ( ToDistribute * 2 ) ) ; <nl> + for ( s = 0 ; s < = maxSymbolValue ; s + + ) { <nl> + if ( ( norm [ s ] = = NOT_YET_ASSIGNED ) & & ( count [ s ] < = lowOne ) ) { <nl> + norm [ s ] = 1 ; <nl> + distributed + + ; <nl> + total - = count [ s ] ; <nl> + continue ; <nl> + } } <nl> + ToDistribute = ( 1 < < tableLog ) - distributed ; <nl> + } <nl> + <nl> + if ( distributed = = maxSymbolValue + 1 ) { <nl> + / * all values are pretty poor ; <nl> + probably incompressible data ( should have already been detected ) ; <nl> + find max , then give all remaining points to max * / <nl> + U32 maxV = 0 , maxC = 0 ; <nl> + for ( s = 0 ; s < = maxSymbolValue ; s + + ) <nl> + if ( count [ s ] > maxC ) maxV = s , maxC = count [ s ] ; <nl> + norm [ maxV ] + = ( short ) ToDistribute ; <nl> + return 0 ; <nl> + } <nl> + <nl> + if ( total = = 0 ) { <nl> + / * all of the symbols were low enough for the lowOne or lowThreshold * / <nl> + for ( s = 0 ; ToDistribute > 0 ; s = ( s + 1 ) % ( maxSymbolValue + 1 ) ) <nl> + if ( norm [ s ] > 0 ) ToDistribute - - , norm [ s ] + + ; <nl> + return 0 ; <nl> + } <nl> + <nl> + { U64 const vStepLog = 62 - tableLog ; <nl> + U64 const mid = ( 1ULL < < ( vStepLog - 1 ) ) - 1 ; <nl> + U64 const rStep = ( ( ( ( U64 ) 1 < < vStepLog ) * ToDistribute ) + mid ) / total ; / * scale on remaining * / <nl> + U64 tmpTotal = mid ; <nl> + for ( s = 0 ; s < = maxSymbolValue ; s + + ) { <nl> + if ( norm [ s ] = = NOT_YET_ASSIGNED ) { <nl> + U64 const end = tmpTotal + ( count [ s ] * rStep ) ; <nl> + U32 const sStart = ( U32 ) ( tmpTotal > > vStepLog ) ; <nl> + U32 const sEnd = ( U32 ) ( end > > vStepLog ) ; <nl> + U32 const weight = sEnd - sStart ; <nl> + if ( weight < 1 ) <nl> + return ERROR ( GENERIC ) ; <nl> + norm [ s ] = ( short ) weight ; <nl> + tmpTotal = end ; <nl> + } } } <nl> + <nl> + return 0 ; <nl> + } <nl> + <nl> + <nl> + size_t FSE_normalizeCount ( short * normalizedCounter , unsigned tableLog , <nl> + const unsigned * count , size_t total , <nl> + unsigned maxSymbolValue ) <nl> + { <nl> + / * Sanity checks * / <nl> + if ( tableLog = = 0 ) tableLog = FSE_DEFAULT_TABLELOG ; <nl> + if ( tableLog < FSE_MIN_TABLELOG ) return ERROR ( GENERIC ) ; / * Unsupported size * / <nl> + if ( tableLog > FSE_MAX_TABLELOG ) return ERROR ( tableLog_tooLarge ) ; / * Unsupported size * / <nl> + if ( tableLog < FSE_minTableLog ( total , maxSymbolValue ) ) return ERROR ( GENERIC ) ; / * Too small tableLog , compression potentially impossible * / <nl> + <nl> + { U32 const rtbTable [ ] = { 0 , 473195 , 504333 , 520860 , 550000 , 700000 , 750000 , 830000 } ; <nl> + U64 const scale = 62 - tableLog ; <nl> + U64 const step = ( ( U64 ) 1 < < 62 ) / total ; / * < = = here , one division ! * / <nl> + U64 const vStep = 1ULL < < ( scale - 20 ) ; <nl> + int stillToDistribute = 1 < < tableLog ; <nl> + unsigned s ; <nl> + unsigned largest = 0 ; <nl> + short largestP = 0 ; <nl> + U32 lowThreshold = ( U32 ) ( total > > tableLog ) ; <nl> + <nl> + for ( s = 0 ; s < = maxSymbolValue ; s + + ) { <nl> + if ( count [ s ] = = total ) return 0 ; / * rle special case * / <nl> + if ( count [ s ] = = 0 ) { normalizedCounter [ s ] = 0 ; continue ; } <nl> + if ( count [ s ] < = lowThreshold ) { <nl> + normalizedCounter [ s ] = - 1 ; <nl> + stillToDistribute - - ; <nl> + } else { <nl> + short proba = ( short ) ( ( count [ s ] * step ) > > scale ) ; <nl> + if ( proba < 8 ) { <nl> + U64 restToBeat = vStep * rtbTable [ proba ] ; <nl> + proba + = ( count [ s ] * step ) - ( ( U64 ) proba < < scale ) > restToBeat ; <nl> + } <nl> + if ( proba > largestP ) largestP = proba , largest = s ; <nl> + normalizedCounter [ s ] = proba ; <nl> + stillToDistribute - = proba ; <nl> + } } <nl> + if ( - stillToDistribute > = ( normalizedCounter [ largest ] > > 1 ) ) { <nl> + / * corner case , need another normalization method * / <nl> + size_t const errorCode = FSE_normalizeM2 ( normalizedCounter , tableLog , count , total , maxSymbolValue ) ; <nl> + if ( FSE_isError ( errorCode ) ) return errorCode ; <nl> + } <nl> + else normalizedCounter [ largest ] + = ( short ) stillToDistribute ; <nl> + } <nl> + <nl> + # if 0 <nl> + { / * Print Table ( debug ) * / <nl> + U32 s ; <nl> + U32 nTotal = 0 ; <nl> + for ( s = 0 ; s < = maxSymbolValue ; s + + ) <nl> + printf ( " % 3i : % 4i \ n " , s , normalizedCounter [ s ] ) ; <nl> + for ( s = 0 ; s < = maxSymbolValue ; s + + ) <nl> + nTotal + = abs ( normalizedCounter [ s ] ) ; <nl> + if ( nTotal ! = ( 1U < < tableLog ) ) <nl> + printf ( " Warning ! ! ! Total = = % u ! = % u ! ! ! " , nTotal , 1U < < tableLog ) ; <nl> + getchar ( ) ; <nl> + } <nl> + # endif <nl> + <nl> + return tableLog ; <nl> + } <nl> + <nl> + <nl> + / * fake FSE_CTable , for raw ( uncompressed ) input * / <nl> + size_t FSE_buildCTable_raw ( FSE_CTable * ct , unsigned nbBits ) <nl> + { <nl> + const unsigned tableSize = 1 < < nbBits ; <nl> + const unsigned tableMask = tableSize - 1 ; <nl> + const unsigned maxSymbolValue = tableMask ; <nl> + void * const ptr = ct ; <nl> + U16 * const tableU16 = ( ( U16 * ) ptr ) + 2 ; <nl> + void * const FSCT = ( ( U32 * ) ptr ) + 1 / * header * / + ( tableSize > > 1 ) ; / * assumption : tableLog > = 1 * / <nl> + FSE_symbolCompressionTransform * const symbolTT = ( FSE_symbolCompressionTransform * ) ( FSCT ) ; <nl> + unsigned s ; <nl> + <nl> + / * Sanity checks * / <nl> + if ( nbBits < 1 ) return ERROR ( GENERIC ) ; / * min size * / <nl> + <nl> + / * header * / <nl> + tableU16 [ - 2 ] = ( U16 ) nbBits ; <nl> + tableU16 [ - 1 ] = ( U16 ) maxSymbolValue ; <nl> + <nl> + / * Build table * / <nl> + for ( s = 0 ; s < tableSize ; s + + ) <nl> + tableU16 [ s ] = ( U16 ) ( tableSize + s ) ; <nl> + <nl> + / * Build Symbol Transformation Table * / <nl> + { const U32 deltaNbBits = ( nbBits < < 16 ) - ( 1 < < nbBits ) ; <nl> + for ( s = 0 ; s < = maxSymbolValue ; s + + ) { <nl> + symbolTT [ s ] . deltaNbBits = deltaNbBits ; <nl> + symbolTT [ s ] . deltaFindState = s - 1 ; <nl> + } } <nl> + <nl> + return 0 ; <nl> + } <nl> + <nl> + / * fake FSE_CTable , for rle input ( always same symbol ) * / <nl> + size_t FSE_buildCTable_rle ( FSE_CTable * ct , BYTE symbolValue ) <nl> + { <nl> + void * ptr = ct ; <nl> + U16 * tableU16 = ( ( U16 * ) ptr ) + 2 ; <nl> + void * FSCTptr = ( U32 * ) ptr + 2 ; <nl> + FSE_symbolCompressionTransform * symbolTT = ( FSE_symbolCompressionTransform * ) FSCTptr ; <nl> + <nl> + / * header * / <nl> + tableU16 [ - 2 ] = ( U16 ) 0 ; <nl> + tableU16 [ - 1 ] = ( U16 ) symbolValue ; <nl> + <nl> + / * Build table * / <nl> + tableU16 [ 0 ] = 0 ; <nl> + tableU16 [ 1 ] = 0 ; / * just in case * / <nl> + <nl> + / * Build Symbol Transformation Table * / <nl> + symbolTT [ symbolValue ] . deltaNbBits = 0 ; <nl> + symbolTT [ symbolValue ] . deltaFindState = 0 ; <nl> + <nl> + return 0 ; <nl> + } <nl> + <nl> + <nl> + static size_t FSE_compress_usingCTable_generic ( void * dst , size_t dstSize , <nl> + const void * src , size_t srcSize , <nl> + const FSE_CTable * ct , const unsigned fast ) <nl> + { <nl> + const BYTE * const istart = ( const BYTE * ) src ; <nl> + const BYTE * const iend = istart + srcSize ; <nl> + const BYTE * ip = iend ; <nl> + <nl> + BIT_CStream_t bitC ; <nl> + FSE_CState_t CState1 , CState2 ; <nl> + <nl> + / * init * / <nl> + if ( srcSize < = 2 ) return 0 ; <nl> + { size_t const initError = BIT_initCStream ( & bitC , dst , dstSize ) ; <nl> + if ( FSE_isError ( initError ) ) return 0 ; / * not enough space available to write a bitstream * / } <nl> + <nl> + # define FSE_FLUSHBITS ( s ) ( fast ? BIT_flushBitsFast ( s ) : BIT_flushBits ( s ) ) <nl> + <nl> + if ( srcSize & 1 ) { <nl> + FSE_initCState2 ( & CState1 , ct , * - - ip ) ; <nl> + FSE_initCState2 ( & CState2 , ct , * - - ip ) ; <nl> + FSE_encodeSymbol ( & bitC , & CState1 , * - - ip ) ; <nl> + FSE_FLUSHBITS ( & bitC ) ; <nl> + } else { <nl> + FSE_initCState2 ( & CState2 , ct , * - - ip ) ; <nl> + FSE_initCState2 ( & CState1 , ct , * - - ip ) ; <nl> + } <nl> + <nl> + / * join to mod 4 * / <nl> + srcSize - = 2 ; <nl> + if ( ( sizeof ( bitC . bitContainer ) * 8 > FSE_MAX_TABLELOG * 4 + 7 ) & & ( srcSize & 2 ) ) { / * test bit 2 * / <nl> + FSE_encodeSymbol ( & bitC , & CState2 , * - - ip ) ; <nl> + FSE_encodeSymbol ( & bitC , & CState1 , * - - ip ) ; <nl> + FSE_FLUSHBITS ( & bitC ) ; <nl> + } <nl> + <nl> + / * 2 or 4 encoding per loop * / <nl> + while ( ip > istart ) { <nl> + <nl> + FSE_encodeSymbol ( & bitC , & CState2 , * - - ip ) ; <nl> + <nl> + if ( sizeof ( bitC . bitContainer ) * 8 < FSE_MAX_TABLELOG * 2 + 7 ) / * this test must be static * / <nl> + FSE_FLUSHBITS ( & bitC ) ; <nl> + <nl> + FSE_encodeSymbol ( & bitC , & CState1 , * - - ip ) ; <nl> + <nl> + if ( sizeof ( bitC . bitContainer ) * 8 > FSE_MAX_TABLELOG * 4 + 7 ) { / * this test must be static * / <nl> + FSE_encodeSymbol ( & bitC , & CState2 , * - - ip ) ; <nl> + FSE_encodeSymbol ( & bitC , & CState1 , * - - ip ) ; <nl> + } <nl> + <nl> + FSE_FLUSHBITS ( & bitC ) ; <nl> + } <nl> + <nl> + FSE_flushCState ( & bitC , & CState2 ) ; <nl> + FSE_flushCState ( & bitC , & CState1 ) ; <nl> + return BIT_closeCStream ( & bitC ) ; <nl> + } <nl> + <nl> + size_t FSE_compress_usingCTable ( void * dst , size_t dstSize , <nl> + const void * src , size_t srcSize , <nl> + const FSE_CTable * ct ) <nl> + { <nl> + unsigned const fast = ( dstSize > = FSE_BLOCKBOUND ( srcSize ) ) ; <nl> + <nl> + if ( fast ) <nl> + return FSE_compress_usingCTable_generic ( dst , dstSize , src , srcSize , ct , 1 ) ; <nl> + else <nl> + return FSE_compress_usingCTable_generic ( dst , dstSize , src , srcSize , ct , 0 ) ; <nl> + } <nl> + <nl> + <nl> + size_t FSE_compressBound ( size_t size ) { return FSE_COMPRESSBOUND ( size ) ; } <nl> + <nl> + # define CHECK_V_F ( e , f ) size_t const e = f ; if ( ERR_isError ( e ) ) return f <nl> + # define CHECK_F ( f ) { CHECK_V_F ( _var_err__ , f ) ; } <nl> + <nl> + / * FSE_compress_wksp ( ) : <nl> + * Same as FSE_compress2 ( ) , but using an externally allocated scratch buffer ( ` workSpace ` ) . <nl> + * ` wkspSize ` size must be ` ( 1 < < tableLog ) ` . <nl> + * / <nl> + size_t FSE_compress_wksp ( void * dst , size_t dstSize , const void * src , size_t srcSize , unsigned maxSymbolValue , unsigned tableLog , void * workSpace , size_t wkspSize ) <nl> + { <nl> + BYTE * const ostart = ( BYTE * ) dst ; <nl> + BYTE * op = ostart ; <nl> + BYTE * const oend = ostart + dstSize ; <nl> + <nl> + U32 count [ FSE_MAX_SYMBOL_VALUE + 1 ] ; <nl> + S16 norm [ FSE_MAX_SYMBOL_VALUE + 1 ] ; <nl> + FSE_CTable * CTable = ( FSE_CTable * ) workSpace ; <nl> + size_t const CTableSize = FSE_CTABLE_SIZE_U32 ( tableLog , maxSymbolValue ) ; <nl> + void * scratchBuffer = ( void * ) ( CTable + CTableSize ) ; <nl> + size_t const scratchBufferSize = wkspSize - ( CTableSize * sizeof ( FSE_CTable ) ) ; <nl> + <nl> + / * init conditions * / <nl> + if ( wkspSize < FSE_WKSP_SIZE_U32 ( tableLog , maxSymbolValue ) ) return ERROR ( tableLog_tooLarge ) ; <nl> + if ( srcSize < = 1 ) return 0 ; / * Not compressible * / <nl> + if ( ! maxSymbolValue ) maxSymbolValue = FSE_MAX_SYMBOL_VALUE ; <nl> + if ( ! tableLog ) tableLog = FSE_DEFAULT_TABLELOG ; <nl> + <nl> + / * Scan input and build symbol stats * / <nl> + { CHECK_V_F ( maxCount , FSE_count_wksp ( count , & maxSymbolValue , src , srcSize , ( unsigned * ) scratchBuffer ) ) ; <nl> + if ( maxCount = = srcSize ) return 1 ; / * only a single symbol in src : rle * / <nl> + if ( maxCount = = 1 ) return 0 ; / * each symbol present maximum once = > not compressible * / <nl> + if ( maxCount < ( srcSize > > 7 ) ) return 0 ; / * Heuristic : not compressible enough * / <nl> + } <nl> + <nl> + tableLog = FSE_optimalTableLog ( tableLog , srcSize , maxSymbolValue ) ; <nl> + CHECK_F ( FSE_normalizeCount ( norm , tableLog , count , srcSize , maxSymbolValue ) ) ; <nl> + <nl> + / * Write table description header * / <nl> + { CHECK_V_F ( nc_err , FSE_writeNCount ( op , oend - op , norm , maxSymbolValue , tableLog ) ) ; <nl> + op + = nc_err ; <nl> + } <nl> + <nl> + / * Compress * / <nl> + CHECK_F ( FSE_buildCTable_wksp ( CTable , norm , maxSymbolValue , tableLog , scratchBuffer , scratchBufferSize ) ) ; <nl> + { CHECK_V_F ( cSize , FSE_compress_usingCTable ( op , oend - op , src , srcSize , CTable ) ) ; <nl> + if ( cSize = = 0 ) return 0 ; / * not enough space for compressed data * / <nl> + op + = cSize ; <nl> + } <nl> + <nl> + / * check compressibility * / <nl> + if ( ( size_t ) ( op - ostart ) > = srcSize - 1 ) return 0 ; <nl> + <nl> + return op - ostart ; <nl> + } <nl> + <nl> + typedef struct { <nl> + FSE_CTable CTable_max [ FSE_CTABLE_SIZE_U32 ( FSE_MAX_TABLELOG , FSE_MAX_SYMBOL_VALUE ) ] ; <nl> + BYTE scratchBuffer [ 1 < < FSE_MAX_TABLELOG ] ; <nl> + } fseWkspMax_t ; <nl> + <nl> + size_t FSE_compress2 ( void * dst , size_t dstCapacity , const void * src , size_t srcSize , unsigned maxSymbolValue , unsigned tableLog ) <nl> + { <nl> + fseWkspMax_t scratchBuffer ; <nl> + FSE_STATIC_ASSERT ( sizeof ( scratchBuffer ) > = FSE_WKSP_SIZE_U32 ( FSE_MAX_TABLELOG , FSE_MAX_SYMBOL_VALUE ) ) ; / * compilation failures here means scratchBuffer is not large enough * / <nl> + if ( tableLog > FSE_MAX_TABLELOG ) return ERROR ( tableLog_tooLarge ) ; <nl> + return FSE_compress_wksp ( dst , dstCapacity , src , srcSize , maxSymbolValue , tableLog , & scratchBuffer , sizeof ( scratchBuffer ) ) ; <nl> + } <nl> + <nl> + size_t FSE_compress ( void * dst , size_t dstCapacity , const void * src , size_t srcSize ) <nl> + { <nl> + return FSE_compress2 ( dst , dstCapacity , src , srcSize , FSE_MAX_SYMBOL_VALUE , FSE_DEFAULT_TABLELOG ) ; <nl> + } <nl> + <nl> + <nl> + # endif / * FSE_COMMONDEFS_ONLY * / <nl> new file mode 100644 <nl> index 00000000000 . . fe11aafb8f1 <nl> mmm / dev / null <nl> ppp b / thirdparty / zstd / compress / huf_compress . c <nl> <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + Huffman encoder , part of New Generation Entropy library <nl> + Copyright ( C ) 2013 - 2016 , Yann Collet . <nl> + <nl> + BSD 2 - Clause License ( http : / / www . opensource . org / licenses / bsd - license . php ) <nl> + <nl> + Redistribution and use in source and binary forms , with or without <nl> + modification , are permitted provided that the following conditions are <nl> + met : <nl> + <nl> + * Redistributions of source code must retain the above copyright <nl> + notice , this list of conditions and the following disclaimer . <nl> + * Redistributions in binary form must reproduce the above <nl> + copyright notice , this list of conditions and the following disclaimer <nl> + in the documentation and / or other materials provided with the <nl> + distribution . <nl> + <nl> + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + <nl> + You can contact the author at : <nl> + - FSE + HUF source repository : https : / / github . com / Cyan4973 / FiniteStateEntropy <nl> + - Public forum : https : / / groups . google . com / forum / # ! forum / lz4c <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Compiler specifics <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # ifdef _MSC_VER / * Visual Studio * / <nl> + # pragma warning ( disable : 4127 ) / * disable : C4127 : conditional expression is constant * / <nl> + # endif <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Includes <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # include < string . h > / * memcpy , memset * / <nl> + # include < stdio . h > / * printf ( debug ) * / <nl> + # include " bitstream . h " <nl> + # define FSE_STATIC_LINKING_ONLY / * FSE_optimalTableLog_internal * / <nl> + # include " fse . h " / * header compression * / <nl> + # define HUF_STATIC_LINKING_ONLY <nl> + # include " huf . h " <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Error Management <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # define HUF_STATIC_ASSERT ( c ) { enum { HUF_static_assert = 1 / ( int ) ( ! ! ( c ) ) } ; } / * use only * after * variable declarations * / <nl> + # define CHECK_V_F ( e , f ) size_t const e = f ; if ( ERR_isError ( e ) ) return f <nl> + # define CHECK_F ( f ) { CHECK_V_F ( _var_err__ , f ) ; } <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Utils <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + unsigned HUF_optimalTableLog ( unsigned maxTableLog , size_t srcSize , unsigned maxSymbolValue ) <nl> + { <nl> + return FSE_optimalTableLog_internal ( maxTableLog , srcSize , maxSymbolValue , 1 ) ; <nl> + } <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * HUF : Huffman block compression <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * HUF_compressWeights ( ) : <nl> + * Same as FSE_compress ( ) , but dedicated to huff0 ' s weights compression . <nl> + * The use case needs much less stack memory . <nl> + * Note : all elements within weightTable are supposed to be < = HUF_TABLELOG_MAX . <nl> + * / <nl> + # define MAX_FSE_TABLELOG_FOR_HUFF_HEADER 6 <nl> + size_t HUF_compressWeights ( void * dst , size_t dstSize , const void * weightTable , size_t wtSize ) <nl> + { <nl> + BYTE * const ostart = ( BYTE * ) dst ; <nl> + BYTE * op = ostart ; <nl> + BYTE * const oend = ostart + dstSize ; <nl> + <nl> + U32 maxSymbolValue = HUF_TABLELOG_MAX ; <nl> + U32 tableLog = MAX_FSE_TABLELOG_FOR_HUFF_HEADER ; <nl> + <nl> + FSE_CTable CTable [ FSE_CTABLE_SIZE_U32 ( MAX_FSE_TABLELOG_FOR_HUFF_HEADER , HUF_TABLELOG_MAX ) ] ; <nl> + BYTE scratchBuffer [ 1 < < MAX_FSE_TABLELOG_FOR_HUFF_HEADER ] ; <nl> + <nl> + U32 count [ HUF_TABLELOG_MAX + 1 ] ; <nl> + S16 norm [ HUF_TABLELOG_MAX + 1 ] ; <nl> + <nl> + / * init conditions * / <nl> + if ( wtSize < = 1 ) return 0 ; / * Not compressible * / <nl> + <nl> + / * Scan input and build symbol stats * / <nl> + { CHECK_V_F ( maxCount , FSE_count_simple ( count , & maxSymbolValue , weightTable , wtSize ) ) ; <nl> + if ( maxCount = = wtSize ) return 1 ; / * only a single symbol in src : rle * / <nl> + if ( maxCount = = 1 ) return 0 ; / * each symbol present maximum once = > not compressible * / <nl> + } <nl> + <nl> + tableLog = FSE_optimalTableLog ( tableLog , wtSize , maxSymbolValue ) ; <nl> + CHECK_F ( FSE_normalizeCount ( norm , tableLog , count , wtSize , maxSymbolValue ) ) ; <nl> + <nl> + / * Write table description header * / <nl> + { CHECK_V_F ( hSize , FSE_writeNCount ( op , oend - op , norm , maxSymbolValue , tableLog ) ) ; <nl> + op + = hSize ; <nl> + } <nl> + <nl> + / * Compress * / <nl> + CHECK_F ( FSE_buildCTable_wksp ( CTable , norm , maxSymbolValue , tableLog , scratchBuffer , sizeof ( scratchBuffer ) ) ) ; <nl> + { CHECK_V_F ( cSize , FSE_compress_usingCTable ( op , oend - op , weightTable , wtSize , CTable ) ) ; <nl> + if ( cSize = = 0 ) return 0 ; / * not enough space for compressed data * / <nl> + op + = cSize ; <nl> + } <nl> + <nl> + return op - ostart ; <nl> + } <nl> + <nl> + <nl> + struct HUF_CElt_s { <nl> + U16 val ; <nl> + BYTE nbBits ; <nl> + } ; / * typedef ' d to HUF_CElt within " huf . h " * / <nl> + <nl> + / * ! HUF_writeCTable ( ) : <nl> + ` CTable ` : Huffman tree to save , using huf representation . <nl> + @ return : size of saved CTable * / <nl> + size_t HUF_writeCTable ( void * dst , size_t maxDstSize , <nl> + const HUF_CElt * CTable , U32 maxSymbolValue , U32 huffLog ) <nl> + { <nl> + BYTE bitsToWeight [ HUF_TABLELOG_MAX + 1 ] ; / * precomputed conversion table * / <nl> + BYTE huffWeight [ HUF_SYMBOLVALUE_MAX ] ; <nl> + BYTE * op = ( BYTE * ) dst ; <nl> + U32 n ; <nl> + <nl> + / * check conditions * / <nl> + if ( maxSymbolValue > HUF_SYMBOLVALUE_MAX ) return ERROR ( maxSymbolValue_tooLarge ) ; <nl> + <nl> + / * convert to weight * / <nl> + bitsToWeight [ 0 ] = 0 ; <nl> + for ( n = 1 ; n < huffLog + 1 ; n + + ) <nl> + bitsToWeight [ n ] = ( BYTE ) ( huffLog + 1 - n ) ; <nl> + for ( n = 0 ; n < maxSymbolValue ; n + + ) <nl> + huffWeight [ n ] = bitsToWeight [ CTable [ n ] . nbBits ] ; <nl> + <nl> + / * attempt weights compression by FSE * / <nl> + { CHECK_V_F ( hSize , HUF_compressWeights ( op + 1 , maxDstSize - 1 , huffWeight , maxSymbolValue ) ) ; <nl> + if ( ( hSize > 1 ) & ( hSize < maxSymbolValue / 2 ) ) { / * FSE compressed * / <nl> + op [ 0 ] = ( BYTE ) hSize ; <nl> + return hSize + 1 ; <nl> + } } <nl> + <nl> + / * write raw values as 4 - bits ( max : 15 ) * / <nl> + if ( maxSymbolValue > ( 256 - 128 ) ) return ERROR ( GENERIC ) ; / * should not happen : likely means source cannot be compressed * / <nl> + if ( ( ( maxSymbolValue + 1 ) / 2 ) + 1 > maxDstSize ) return ERROR ( dstSize_tooSmall ) ; / * not enough space within dst buffer * / <nl> + op [ 0 ] = ( BYTE ) ( 128 / * special case * / + ( maxSymbolValue - 1 ) ) ; <nl> + huffWeight [ maxSymbolValue ] = 0 ; / * to be sure it doesn ' t cause msan issue in final combination * / <nl> + for ( n = 0 ; n < maxSymbolValue ; n + = 2 ) <nl> + op [ ( n / 2 ) + 1 ] = ( BYTE ) ( ( huffWeight [ n ] < < 4 ) + huffWeight [ n + 1 ] ) ; <nl> + return ( ( maxSymbolValue + 1 ) / 2 ) + 1 ; <nl> + } <nl> + <nl> + <nl> + size_t HUF_readCTable ( HUF_CElt * CTable , U32 maxSymbolValue , const void * src , size_t srcSize ) <nl> + { <nl> + BYTE huffWeight [ HUF_SYMBOLVALUE_MAX + 1 ] ; / * init not required , even though some static analyzer may complain * / <nl> + U32 rankVal [ HUF_TABLELOG_ABSOLUTEMAX + 1 ] ; / * large enough for values from 0 to 16 * / <nl> + U32 tableLog = 0 ; <nl> + U32 nbSymbols = 0 ; <nl> + <nl> + / * get symbol weights * / <nl> + CHECK_V_F ( readSize , HUF_readStats ( huffWeight , HUF_SYMBOLVALUE_MAX + 1 , rankVal , & nbSymbols , & tableLog , src , srcSize ) ) ; <nl> + <nl> + / * check result * / <nl> + if ( tableLog > HUF_TABLELOG_MAX ) return ERROR ( tableLog_tooLarge ) ; <nl> + if ( nbSymbols > maxSymbolValue + 1 ) return ERROR ( maxSymbolValue_tooSmall ) ; <nl> + <nl> + / * Prepare base value per rank * / <nl> + { U32 n , nextRankStart = 0 ; <nl> + for ( n = 1 ; n < = tableLog ; n + + ) { <nl> + U32 current = nextRankStart ; <nl> + nextRankStart + = ( rankVal [ n ] < < ( n - 1 ) ) ; <nl> + rankVal [ n ] = current ; <nl> + } } <nl> + <nl> + / * fill nbBits * / <nl> + { U32 n ; for ( n = 0 ; n < nbSymbols ; n + + ) { <nl> + const U32 w = huffWeight [ n ] ; <nl> + CTable [ n ] . nbBits = ( BYTE ) ( tableLog + 1 - w ) ; <nl> + } } <nl> + <nl> + / * fill val * / <nl> + { U16 nbPerRank [ HUF_TABLELOG_MAX + 2 ] = { 0 } ; / * support w = 0 = > n = tableLog + 1 * / <nl> + U16 valPerRank [ HUF_TABLELOG_MAX + 2 ] = { 0 } ; <nl> + { U32 n ; for ( n = 0 ; n < nbSymbols ; n + + ) nbPerRank [ CTable [ n ] . nbBits ] + + ; } <nl> + / * determine stating value per rank * / <nl> + valPerRank [ tableLog + 1 ] = 0 ; / * for w = = 0 * / <nl> + { U16 min = 0 ; <nl> + U32 n ; for ( n = tableLog ; n > 0 ; n - - ) { / * start at n = tablelog < - > w = 1 * / <nl> + valPerRank [ n ] = min ; / * get starting value within each rank * / <nl> + min + = nbPerRank [ n ] ; <nl> + min > > = 1 ; <nl> + } } <nl> + / * assign value within rank , symbol order * / <nl> + { U32 n ; for ( n = 0 ; n < = maxSymbolValue ; n + + ) CTable [ n ] . val = valPerRank [ CTable [ n ] . nbBits ] + + ; } <nl> + } <nl> + <nl> + return readSize ; <nl> + } <nl> + <nl> + <nl> + typedef struct nodeElt_s { <nl> + U32 count ; <nl> + U16 parent ; <nl> + BYTE byte ; <nl> + BYTE nbBits ; <nl> + } nodeElt ; <nl> + <nl> + static U32 HUF_setMaxHeight ( nodeElt * huffNode , U32 lastNonNull , U32 maxNbBits ) <nl> + { <nl> + const U32 largestBits = huffNode [ lastNonNull ] . nbBits ; <nl> + if ( largestBits < = maxNbBits ) return largestBits ; / * early exit : no elt > maxNbBits * / <nl> + <nl> + / * there are several too large elements ( at least > = 2 ) * / <nl> + { int totalCost = 0 ; <nl> + const U32 baseCost = 1 < < ( largestBits - maxNbBits ) ; <nl> + U32 n = lastNonNull ; <nl> + <nl> + while ( huffNode [ n ] . nbBits > maxNbBits ) { <nl> + totalCost + = baseCost - ( 1 < < ( largestBits - huffNode [ n ] . nbBits ) ) ; <nl> + huffNode [ n ] . nbBits = ( BYTE ) maxNbBits ; <nl> + n - - ; <nl> + } / * n stops at huffNode [ n ] . nbBits < = maxNbBits * / <nl> + while ( huffNode [ n ] . nbBits = = maxNbBits ) n - - ; / * n end at index of smallest symbol using < maxNbBits * / <nl> + <nl> + / * renorm totalCost * / <nl> + totalCost > > = ( largestBits - maxNbBits ) ; / * note : totalCost is necessarily a multiple of baseCost * / <nl> + <nl> + / * repay normalized cost * / <nl> + { U32 const noSymbol = 0xF0F0F0F0 ; <nl> + U32 rankLast [ HUF_TABLELOG_MAX + 2 ] ; <nl> + int pos ; <nl> + <nl> + / * Get pos of last ( smallest ) symbol per rank * / <nl> + memset ( rankLast , 0xF0 , sizeof ( rankLast ) ) ; <nl> + { U32 currentNbBits = maxNbBits ; <nl> + for ( pos = n ; pos > = 0 ; pos - - ) { <nl> + if ( huffNode [ pos ] . nbBits > = currentNbBits ) continue ; <nl> + currentNbBits = huffNode [ pos ] . nbBits ; / * < maxNbBits * / <nl> + rankLast [ maxNbBits - currentNbBits ] = pos ; <nl> + } } <nl> + <nl> + while ( totalCost > 0 ) { <nl> + U32 nBitsToDecrease = BIT_highbit32 ( totalCost ) + 1 ; <nl> + for ( ; nBitsToDecrease > 1 ; nBitsToDecrease - - ) { <nl> + U32 highPos = rankLast [ nBitsToDecrease ] ; <nl> + U32 lowPos = rankLast [ nBitsToDecrease - 1 ] ; <nl> + if ( highPos = = noSymbol ) continue ; <nl> + if ( lowPos = = noSymbol ) break ; <nl> + { U32 const highTotal = huffNode [ highPos ] . count ; <nl> + U32 const lowTotal = 2 * huffNode [ lowPos ] . count ; <nl> + if ( highTotal < = lowTotal ) break ; <nl> + } } <nl> + / * only triggered when no more rank 1 symbol left = > find closest one ( note : there is necessarily at least one ! ) * / <nl> + while ( ( nBitsToDecrease < = HUF_TABLELOG_MAX ) & & ( rankLast [ nBitsToDecrease ] = = noSymbol ) ) / * HUF_MAX_TABLELOG test just to please gcc 5 + ; but it should not be necessary * / <nl> + nBitsToDecrease + + ; <nl> + totalCost - = 1 < < ( nBitsToDecrease - 1 ) ; <nl> + if ( rankLast [ nBitsToDecrease - 1 ] = = noSymbol ) <nl> + rankLast [ nBitsToDecrease - 1 ] = rankLast [ nBitsToDecrease ] ; / * this rank is no longer empty * / <nl> + huffNode [ rankLast [ nBitsToDecrease ] ] . nbBits + + ; <nl> + if ( rankLast [ nBitsToDecrease ] = = 0 ) / * special case , reached largest symbol * / <nl> + rankLast [ nBitsToDecrease ] = noSymbol ; <nl> + else { <nl> + rankLast [ nBitsToDecrease ] - - ; <nl> + if ( huffNode [ rankLast [ nBitsToDecrease ] ] . nbBits ! = maxNbBits - nBitsToDecrease ) <nl> + rankLast [ nBitsToDecrease ] = noSymbol ; / * this rank is now empty * / <nl> + } } / * while ( totalCost > 0 ) * / <nl> + <nl> + while ( totalCost < 0 ) { / * Sometimes , cost correction overshoot * / <nl> + if ( rankLast [ 1 ] = = noSymbol ) { / * special case : no rank 1 symbol ( using maxNbBits - 1 ) ; let ' s create one from largest rank 0 ( using maxNbBits ) * / <nl> + while ( huffNode [ n ] . nbBits = = maxNbBits ) n - - ; <nl> + huffNode [ n + 1 ] . nbBits - - ; <nl> + rankLast [ 1 ] = n + 1 ; <nl> + totalCost + + ; <nl> + continue ; <nl> + } <nl> + huffNode [ rankLast [ 1 ] + 1 ] . nbBits - - ; <nl> + rankLast [ 1 ] + + ; <nl> + totalCost + + ; <nl> + } } } / * there are several too large elements ( at least > = 2 ) * / <nl> + <nl> + return maxNbBits ; <nl> + } <nl> + <nl> + <nl> + typedef struct { <nl> + U32 base ; <nl> + U32 current ; <nl> + } rankPos ; <nl> + <nl> + static void HUF_sort ( nodeElt * huffNode , const U32 * count , U32 maxSymbolValue ) <nl> + { <nl> + rankPos rank [ 32 ] ; <nl> + U32 n ; <nl> + <nl> + memset ( rank , 0 , sizeof ( rank ) ) ; <nl> + for ( n = 0 ; n < = maxSymbolValue ; n + + ) { <nl> + U32 r = BIT_highbit32 ( count [ n ] + 1 ) ; <nl> + rank [ r ] . base + + ; <nl> + } <nl> + for ( n = 30 ; n > 0 ; n - - ) rank [ n - 1 ] . base + = rank [ n ] . base ; <nl> + for ( n = 0 ; n < 32 ; n + + ) rank [ n ] . current = rank [ n ] . base ; <nl> + for ( n = 0 ; n < = maxSymbolValue ; n + + ) { <nl> + U32 const c = count [ n ] ; <nl> + U32 const r = BIT_highbit32 ( c + 1 ) + 1 ; <nl> + U32 pos = rank [ r ] . current + + ; <nl> + while ( ( pos > rank [ r ] . base ) & & ( c > huffNode [ pos - 1 ] . count ) ) huffNode [ pos ] = huffNode [ pos - 1 ] , pos - - ; <nl> + huffNode [ pos ] . count = c ; <nl> + huffNode [ pos ] . byte = ( BYTE ) n ; <nl> + } <nl> + } <nl> + <nl> + <nl> + / * * HUF_buildCTable_wksp ( ) : <nl> + * Same as HUF_buildCTable ( ) , but using externally allocated scratch buffer . <nl> + * ` workSpace ` must be aligned on 4 - bytes boundaries , and be at least as large as a table of 1024 unsigned . <nl> + * / <nl> + # define STARTNODE ( HUF_SYMBOLVALUE_MAX + 1 ) <nl> + typedef nodeElt huffNodeTable [ 2 * HUF_SYMBOLVALUE_MAX + 1 + 1 ] ; <nl> + size_t HUF_buildCTable_wksp ( HUF_CElt * tree , const U32 * count , U32 maxSymbolValue , U32 maxNbBits , void * workSpace , size_t wkspSize ) <nl> + { <nl> + nodeElt * const huffNode0 = ( nodeElt * ) workSpace ; <nl> + nodeElt * const huffNode = huffNode0 + 1 ; <nl> + U32 n , nonNullRank ; <nl> + int lowS , lowN ; <nl> + U16 nodeNb = STARTNODE ; <nl> + U32 nodeRoot ; <nl> + <nl> + / * safety checks * / <nl> + if ( wkspSize < sizeof ( huffNodeTable ) ) return ERROR ( GENERIC ) ; / * workSpace is not large enough * / <nl> + if ( maxNbBits = = 0 ) maxNbBits = HUF_TABLELOG_DEFAULT ; <nl> + if ( maxSymbolValue > HUF_SYMBOLVALUE_MAX ) return ERROR ( GENERIC ) ; <nl> + memset ( huffNode0 , 0 , sizeof ( huffNodeTable ) ) ; <nl> + <nl> + / * sort , decreasing order * / <nl> + HUF_sort ( huffNode , count , maxSymbolValue ) ; <nl> + <nl> + / * init for parents * / <nl> + nonNullRank = maxSymbolValue ; <nl> + while ( huffNode [ nonNullRank ] . count = = 0 ) nonNullRank - - ; <nl> + lowS = nonNullRank ; nodeRoot = nodeNb + lowS - 1 ; lowN = nodeNb ; <nl> + huffNode [ nodeNb ] . count = huffNode [ lowS ] . count + huffNode [ lowS - 1 ] . count ; <nl> + huffNode [ lowS ] . parent = huffNode [ lowS - 1 ] . parent = nodeNb ; <nl> + nodeNb + + ; lowS - = 2 ; <nl> + for ( n = nodeNb ; n < = nodeRoot ; n + + ) huffNode [ n ] . count = ( U32 ) ( 1U < < 30 ) ; <nl> + huffNode0 [ 0 ] . count = ( U32 ) ( 1U < < 31 ) ; / * fake entry , strong barrier * / <nl> + <nl> + / * create parents * / <nl> + while ( nodeNb < = nodeRoot ) { <nl> + U32 n1 = ( huffNode [ lowS ] . count < huffNode [ lowN ] . count ) ? lowS - - : lowN + + ; <nl> + U32 n2 = ( huffNode [ lowS ] . count < huffNode [ lowN ] . count ) ? lowS - - : lowN + + ; <nl> + huffNode [ nodeNb ] . count = huffNode [ n1 ] . count + huffNode [ n2 ] . count ; <nl> + huffNode [ n1 ] . parent = huffNode [ n2 ] . parent = nodeNb ; <nl> + nodeNb + + ; <nl> + } <nl> + <nl> + / * distribute weights ( unlimited tree height ) * / <nl> + huffNode [ nodeRoot ] . nbBits = 0 ; <nl> + for ( n = nodeRoot - 1 ; n > = STARTNODE ; n - - ) <nl> + huffNode [ n ] . nbBits = huffNode [ huffNode [ n ] . parent ] . nbBits + 1 ; <nl> + for ( n = 0 ; n < = nonNullRank ; n + + ) <nl> + huffNode [ n ] . nbBits = huffNode [ huffNode [ n ] . parent ] . nbBits + 1 ; <nl> + <nl> + / * enforce maxTableLog * / <nl> + maxNbBits = HUF_setMaxHeight ( huffNode , nonNullRank , maxNbBits ) ; <nl> + <nl> + / * fill result into tree ( val , nbBits ) * / <nl> + { U16 nbPerRank [ HUF_TABLELOG_MAX + 1 ] = { 0 } ; <nl> + U16 valPerRank [ HUF_TABLELOG_MAX + 1 ] = { 0 } ; <nl> + if ( maxNbBits > HUF_TABLELOG_MAX ) return ERROR ( GENERIC ) ; / * check fit into table * / <nl> + for ( n = 0 ; n < = nonNullRank ; n + + ) <nl> + nbPerRank [ huffNode [ n ] . nbBits ] + + ; <nl> + / * determine stating value per rank * / <nl> + { U16 min = 0 ; <nl> + for ( n = maxNbBits ; n > 0 ; n - - ) { <nl> + valPerRank [ n ] = min ; / * get starting value within each rank * / <nl> + min + = nbPerRank [ n ] ; <nl> + min > > = 1 ; <nl> + } } <nl> + for ( n = 0 ; n < = maxSymbolValue ; n + + ) <nl> + tree [ huffNode [ n ] . byte ] . nbBits = huffNode [ n ] . nbBits ; / * push nbBits per symbol , symbol order * / <nl> + for ( n = 0 ; n < = maxSymbolValue ; n + + ) <nl> + tree [ n ] . val = valPerRank [ tree [ n ] . nbBits ] + + ; / * assign value within rank , symbol order * / <nl> + } <nl> + <nl> + return maxNbBits ; <nl> + } <nl> + <nl> + / * * HUF_buildCTable ( ) : <nl> + * Note : count is used before tree is written , so they can safely overlap <nl> + * / <nl> + size_t HUF_buildCTable ( HUF_CElt * tree , const U32 * count , U32 maxSymbolValue , U32 maxNbBits ) <nl> + { <nl> + huffNodeTable nodeTable ; <nl> + return HUF_buildCTable_wksp ( tree , count , maxSymbolValue , maxNbBits , nodeTable , sizeof ( nodeTable ) ) ; <nl> + } <nl> + <nl> + static size_t HUF_estimateCompressedSize ( HUF_CElt * CTable , const unsigned * count , unsigned maxSymbolValue ) <nl> + { <nl> + size_t nbBits = 0 ; <nl> + int s ; <nl> + for ( s = 0 ; s < = ( int ) maxSymbolValue ; + + s ) { <nl> + nbBits + = CTable [ s ] . nbBits * count [ s ] ; <nl> + } <nl> + return nbBits > > 3 ; <nl> + } <nl> + <nl> + static int HUF_validateCTable ( const HUF_CElt * CTable , const unsigned * count , unsigned maxSymbolValue ) { <nl> + int bad = 0 ; <nl> + int s ; <nl> + for ( s = 0 ; s < = ( int ) maxSymbolValue ; + + s ) { <nl> + bad | = ( count [ s ] ! = 0 ) & ( CTable [ s ] . nbBits = = 0 ) ; <nl> + } <nl> + return ! bad ; <nl> + } <nl> + <nl> + static void HUF_encodeSymbol ( BIT_CStream_t * bitCPtr , U32 symbol , const HUF_CElt * CTable ) <nl> + { <nl> + BIT_addBitsFast ( bitCPtr , CTable [ symbol ] . val , CTable [ symbol ] . nbBits ) ; <nl> + } <nl> + <nl> + size_t HUF_compressBound ( size_t size ) { return HUF_COMPRESSBOUND ( size ) ; } <nl> + <nl> + # define HUF_FLUSHBITS ( s ) ( fast ? BIT_flushBitsFast ( s ) : BIT_flushBits ( s ) ) <nl> + <nl> + # define HUF_FLUSHBITS_1 ( stream ) \ <nl> + if ( sizeof ( ( stream ) - > bitContainer ) * 8 < HUF_TABLELOG_MAX * 2 + 7 ) HUF_FLUSHBITS ( stream ) <nl> + <nl> + # define HUF_FLUSHBITS_2 ( stream ) \ <nl> + if ( sizeof ( ( stream ) - > bitContainer ) * 8 < HUF_TABLELOG_MAX * 4 + 7 ) HUF_FLUSHBITS ( stream ) <nl> + <nl> + size_t HUF_compress1X_usingCTable ( void * dst , size_t dstSize , const void * src , size_t srcSize , const HUF_CElt * CTable ) <nl> + { <nl> + const BYTE * ip = ( const BYTE * ) src ; <nl> + BYTE * const ostart = ( BYTE * ) dst ; <nl> + BYTE * const oend = ostart + dstSize ; <nl> + BYTE * op = ostart ; <nl> + size_t n ; <nl> + const unsigned fast = ( dstSize > = HUF_BLOCKBOUND ( srcSize ) ) ; <nl> + BIT_CStream_t bitC ; <nl> + <nl> + / * init * / <nl> + if ( dstSize < 8 ) return 0 ; / * not enough space to compress * / <nl> + { size_t const initErr = BIT_initCStream ( & bitC , op , oend - op ) ; <nl> + if ( HUF_isError ( initErr ) ) return 0 ; } <nl> + <nl> + n = srcSize & ~ 3 ; / * join to mod 4 * / <nl> + switch ( srcSize & 3 ) <nl> + { <nl> + case 3 : HUF_encodeSymbol ( & bitC , ip [ n + 2 ] , CTable ) ; <nl> + HUF_FLUSHBITS_2 ( & bitC ) ; <nl> + case 2 : HUF_encodeSymbol ( & bitC , ip [ n + 1 ] , CTable ) ; <nl> + HUF_FLUSHBITS_1 ( & bitC ) ; <nl> + case 1 : HUF_encodeSymbol ( & bitC , ip [ n + 0 ] , CTable ) ; <nl> + HUF_FLUSHBITS ( & bitC ) ; <nl> + case 0 : <nl> + default : ; <nl> + } <nl> + <nl> + for ( ; n > 0 ; n - = 4 ) { / * note : n & 3 = = 0 at this stage * / <nl> + HUF_encodeSymbol ( & bitC , ip [ n - 1 ] , CTable ) ; <nl> + HUF_FLUSHBITS_1 ( & bitC ) ; <nl> + HUF_encodeSymbol ( & bitC , ip [ n - 2 ] , CTable ) ; <nl> + HUF_FLUSHBITS_2 ( & bitC ) ; <nl> + HUF_encodeSymbol ( & bitC , ip [ n - 3 ] , CTable ) ; <nl> + HUF_FLUSHBITS_1 ( & bitC ) ; <nl> + HUF_encodeSymbol ( & bitC , ip [ n - 4 ] , CTable ) ; <nl> + HUF_FLUSHBITS ( & bitC ) ; <nl> + } <nl> + <nl> + return BIT_closeCStream ( & bitC ) ; <nl> + } <nl> + <nl> + <nl> + size_t HUF_compress4X_usingCTable ( void * dst , size_t dstSize , const void * src , size_t srcSize , const HUF_CElt * CTable ) <nl> + { <nl> + size_t const segmentSize = ( srcSize + 3 ) / 4 ; / * first 3 segments * / <nl> + const BYTE * ip = ( const BYTE * ) src ; <nl> + const BYTE * const iend = ip + srcSize ; <nl> + BYTE * const ostart = ( BYTE * ) dst ; <nl> + BYTE * const oend = ostart + dstSize ; <nl> + BYTE * op = ostart ; <nl> + <nl> + if ( dstSize < 6 + 1 + 1 + 1 + 8 ) return 0 ; / * minimum space to compress successfully * / <nl> + if ( srcSize < 12 ) return 0 ; / * no saving possible : too small input * / <nl> + op + = 6 ; / * jumpTable * / <nl> + <nl> + { CHECK_V_F ( cSize , HUF_compress1X_usingCTable ( op , oend - op , ip , segmentSize , CTable ) ) ; <nl> + if ( cSize = = 0 ) return 0 ; <nl> + MEM_writeLE16 ( ostart , ( U16 ) cSize ) ; <nl> + op + = cSize ; <nl> + } <nl> + <nl> + ip + = segmentSize ; <nl> + { CHECK_V_F ( cSize , HUF_compress1X_usingCTable ( op , oend - op , ip , segmentSize , CTable ) ) ; <nl> + if ( cSize = = 0 ) return 0 ; <nl> + MEM_writeLE16 ( ostart + 2 , ( U16 ) cSize ) ; <nl> + op + = cSize ; <nl> + } <nl> + <nl> + ip + = segmentSize ; <nl> + { CHECK_V_F ( cSize , HUF_compress1X_usingCTable ( op , oend - op , ip , segmentSize , CTable ) ) ; <nl> + if ( cSize = = 0 ) return 0 ; <nl> + MEM_writeLE16 ( ostart + 4 , ( U16 ) cSize ) ; <nl> + op + = cSize ; <nl> + } <nl> + <nl> + ip + = segmentSize ; <nl> + { CHECK_V_F ( cSize , HUF_compress1X_usingCTable ( op , oend - op , ip , iend - ip , CTable ) ) ; <nl> + if ( cSize = = 0 ) return 0 ; <nl> + op + = cSize ; <nl> + } <nl> + <nl> + return op - ostart ; <nl> + } <nl> + <nl> + <nl> + static size_t HUF_compressCTable_internal ( <nl> + BYTE * const ostart , BYTE * op , BYTE * const oend , <nl> + const void * src , size_t srcSize , <nl> + unsigned singleStream , const HUF_CElt * CTable ) <nl> + { <nl> + size_t const cSize = singleStream ? <nl> + HUF_compress1X_usingCTable ( op , oend - op , src , srcSize , CTable ) : <nl> + HUF_compress4X_usingCTable ( op , oend - op , src , srcSize , CTable ) ; <nl> + if ( HUF_isError ( cSize ) ) { return cSize ; } <nl> + if ( cSize = = 0 ) { return 0 ; } / * uncompressible * / <nl> + op + = cSize ; <nl> + / * check compressibility * / <nl> + if ( ( size_t ) ( op - ostart ) > = srcSize - 1 ) { return 0 ; } <nl> + return op - ostart ; <nl> + } <nl> + <nl> + <nl> + / * ` workSpace ` must a table of at least 1024 unsigned * / <nl> + static size_t HUF_compress_internal ( <nl> + void * dst , size_t dstSize , <nl> + const void * src , size_t srcSize , <nl> + unsigned maxSymbolValue , unsigned huffLog , <nl> + unsigned singleStream , <nl> + void * workSpace , size_t wkspSize , <nl> + HUF_CElt * oldHufTable , HUF_repeat * repeat , int preferRepeat ) <nl> + { <nl> + BYTE * const ostart = ( BYTE * ) dst ; <nl> + BYTE * const oend = ostart + dstSize ; <nl> + BYTE * op = ostart ; <nl> + <nl> + U32 * count ; <nl> + size_t const countSize = sizeof ( U32 ) * ( HUF_SYMBOLVALUE_MAX + 1 ) ; <nl> + HUF_CElt * CTable ; <nl> + size_t const CTableSize = sizeof ( HUF_CElt ) * ( HUF_SYMBOLVALUE_MAX + 1 ) ; <nl> + <nl> + / * checks & inits * / <nl> + if ( wkspSize < sizeof ( huffNodeTable ) + countSize + CTableSize ) return ERROR ( GENERIC ) ; <nl> + if ( ! srcSize ) return 0 ; / * Uncompressed ( note : 1 means rle , so first byte must be correct ) * / <nl> + if ( ! dstSize ) return 0 ; / * cannot fit within dst budget * / <nl> + if ( srcSize > HUF_BLOCKSIZE_MAX ) return ERROR ( srcSize_wrong ) ; / * current block size limit * / <nl> + if ( huffLog > HUF_TABLELOG_MAX ) return ERROR ( tableLog_tooLarge ) ; <nl> + if ( ! maxSymbolValue ) maxSymbolValue = HUF_SYMBOLVALUE_MAX ; <nl> + if ( ! huffLog ) huffLog = HUF_TABLELOG_DEFAULT ; <nl> + <nl> + count = ( U32 * ) workSpace ; <nl> + workSpace = ( BYTE * ) workSpace + countSize ; <nl> + wkspSize - = countSize ; <nl> + CTable = ( HUF_CElt * ) workSpace ; <nl> + workSpace = ( BYTE * ) workSpace + CTableSize ; <nl> + wkspSize - = CTableSize ; <nl> + <nl> + / * Heuristic : If we don ' t need to check the validity of the old table use the old table for small inputs * / <nl> + if ( preferRepeat & & repeat & & * repeat = = HUF_repeat_valid ) { <nl> + return HUF_compressCTable_internal ( ostart , op , oend , src , srcSize , singleStream , oldHufTable ) ; <nl> + } <nl> + <nl> + / * Scan input and build symbol stats * / <nl> + { CHECK_V_F ( largest , FSE_count_wksp ( count , & maxSymbolValue , ( const BYTE * ) src , srcSize , ( U32 * ) workSpace ) ) ; <nl> + if ( largest = = srcSize ) { * ostart = ( ( const BYTE * ) src ) [ 0 ] ; return 1 ; } / * single symbol , rle * / <nl> + if ( largest < = ( srcSize > > 7 ) + 1 ) return 0 ; / * Fast heuristic : not compressible enough * / <nl> + } <nl> + <nl> + / * Check validity of previous table * / <nl> + if ( repeat & & * repeat = = HUF_repeat_check & & ! HUF_validateCTable ( oldHufTable , count , maxSymbolValue ) ) { <nl> + * repeat = HUF_repeat_none ; <nl> + } <nl> + / * Heuristic : use existing table for small inputs * / <nl> + if ( preferRepeat & & repeat & & * repeat ! = HUF_repeat_none ) { <nl> + return HUF_compressCTable_internal ( ostart , op , oend , src , srcSize , singleStream , oldHufTable ) ; <nl> + } <nl> + <nl> + / * Build Huffman Tree * / <nl> + huffLog = HUF_optimalTableLog ( huffLog , srcSize , maxSymbolValue ) ; <nl> + { CHECK_V_F ( maxBits , HUF_buildCTable_wksp ( CTable , count , maxSymbolValue , huffLog , workSpace , wkspSize ) ) ; <nl> + huffLog = ( U32 ) maxBits ; <nl> + / * Zero the unused symbols so we can check it for validity * / <nl> + memset ( CTable + maxSymbolValue + 1 , 0 , CTableSize - ( maxSymbolValue + 1 ) * sizeof ( HUF_CElt ) ) ; <nl> + } <nl> + <nl> + / * Write table description header * / <nl> + { CHECK_V_F ( hSize , HUF_writeCTable ( op , dstSize , CTable , maxSymbolValue , huffLog ) ) ; <nl> + / * Check if using the previous table will be beneficial * / <nl> + if ( repeat & & * repeat ! = HUF_repeat_none ) { <nl> + size_t const oldSize = HUF_estimateCompressedSize ( oldHufTable , count , maxSymbolValue ) ; <nl> + size_t const newSize = HUF_estimateCompressedSize ( CTable , count , maxSymbolValue ) ; <nl> + if ( oldSize < = hSize + newSize | | hSize + 12 > = srcSize ) { <nl> + return HUF_compressCTable_internal ( ostart , op , oend , src , srcSize , singleStream , oldHufTable ) ; <nl> + } <nl> + } <nl> + / * Use the new table * / <nl> + if ( hSize + 12ul > = srcSize ) { return 0 ; } <nl> + op + = hSize ; <nl> + if ( repeat ) { * repeat = HUF_repeat_none ; } <nl> + if ( oldHufTable ) { memcpy ( oldHufTable , CTable , CTableSize ) ; } / * Save the new table * / <nl> + } <nl> + return HUF_compressCTable_internal ( ostart , op , oend , src , srcSize , singleStream , CTable ) ; <nl> + } <nl> + <nl> + <nl> + size_t HUF_compress1X_wksp ( void * dst , size_t dstSize , <nl> + const void * src , size_t srcSize , <nl> + unsigned maxSymbolValue , unsigned huffLog , <nl> + void * workSpace , size_t wkspSize ) <nl> + { <nl> + return HUF_compress_internal ( dst , dstSize , src , srcSize , maxSymbolValue , huffLog , 1 / * single stream * / , workSpace , wkspSize , NULL , NULL , 0 ) ; <nl> + } <nl> + <nl> + size_t HUF_compress1X_repeat ( void * dst , size_t dstSize , <nl> + const void * src , size_t srcSize , <nl> + unsigned maxSymbolValue , unsigned huffLog , <nl> + void * workSpace , size_t wkspSize , <nl> + HUF_CElt * hufTable , HUF_repeat * repeat , int preferRepeat ) <nl> + { <nl> + return HUF_compress_internal ( dst , dstSize , src , srcSize , maxSymbolValue , huffLog , 1 / * single stream * / , workSpace , wkspSize , hufTable , repeat , preferRepeat ) ; <nl> + } <nl> + <nl> + size_t HUF_compress1X ( void * dst , size_t dstSize , <nl> + const void * src , size_t srcSize , <nl> + unsigned maxSymbolValue , unsigned huffLog ) <nl> + { <nl> + unsigned workSpace [ 1024 ] ; <nl> + return HUF_compress1X_wksp ( dst , dstSize , src , srcSize , maxSymbolValue , huffLog , workSpace , sizeof ( workSpace ) ) ; <nl> + } <nl> + <nl> + size_t HUF_compress4X_wksp ( void * dst , size_t dstSize , <nl> + const void * src , size_t srcSize , <nl> + unsigned maxSymbolValue , unsigned huffLog , <nl> + void * workSpace , size_t wkspSize ) <nl> + { <nl> + return HUF_compress_internal ( dst , dstSize , src , srcSize , maxSymbolValue , huffLog , 0 / * 4 streams * / , workSpace , wkspSize , NULL , NULL , 0 ) ; <nl> + } <nl> + <nl> + size_t HUF_compress4X_repeat ( void * dst , size_t dstSize , <nl> + const void * src , size_t srcSize , <nl> + unsigned maxSymbolValue , unsigned huffLog , <nl> + void * workSpace , size_t wkspSize , <nl> + HUF_CElt * hufTable , HUF_repeat * repeat , int preferRepeat ) <nl> + { <nl> + return HUF_compress_internal ( dst , dstSize , src , srcSize , maxSymbolValue , huffLog , 0 / * 4 streams * / , workSpace , wkspSize , hufTable , repeat , preferRepeat ) ; <nl> + } <nl> + <nl> + size_t HUF_compress2 ( void * dst , size_t dstSize , <nl> + const void * src , size_t srcSize , <nl> + unsigned maxSymbolValue , unsigned huffLog ) <nl> + { <nl> + unsigned workSpace [ 1024 ] ; <nl> + return HUF_compress4X_wksp ( dst , dstSize , src , srcSize , maxSymbolValue , huffLog , workSpace , sizeof ( workSpace ) ) ; <nl> + } <nl> + <nl> + size_t HUF_compress ( void * dst , size_t maxDstSize , const void * src , size_t srcSize ) <nl> + { <nl> + return HUF_compress2 ( dst , maxDstSize , src , ( U32 ) srcSize , 255 , HUF_TABLELOG_DEFAULT ) ; <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . c08b315dab9 <nl> mmm / dev / null <nl> ppp b / thirdparty / zstd / compress / zstd_compress . c <nl> <nl> + / * * <nl> + * Copyright ( c ) 2016 - present , Yann Collet , Facebook , Inc . <nl> + * All rights reserved . <nl> + * <nl> + * This source code is licensed under the BSD - style license found in the <nl> + * LICENSE file in the root directory of this source tree . An additional grant <nl> + * of patent rights can be found in the PATENTS file in the same directory . <nl> + * / <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Dependencies <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # include < string . h > / * memset * / <nl> + # include " mem . h " <nl> + # define FSE_STATIC_LINKING_ONLY / * FSE_encodeSymbol * / <nl> + # include " fse . h " <nl> + # define HUF_STATIC_LINKING_ONLY <nl> + # include " huf . h " <nl> + # include " zstd_internal . h " / * includes zstd . h * / <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Debug <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # if defined ( ZSTD_DEBUG ) & & ( ZSTD_DEBUG > = 1 ) <nl> + # include < assert . h > <nl> + # else <nl> + # define assert ( condition ) ( ( void ) 0 ) <nl> + # endif <nl> + <nl> + # define ZSTD_STATIC_ASSERT ( c ) { enum { ZSTD_static_assert = 1 / ( int ) ( ! ! ( c ) ) } ; } <nl> + <nl> + # if defined ( ZSTD_DEBUG ) & & ( ZSTD_DEBUG > = 2 ) <nl> + # include < stdio . h > <nl> + static unsigned g_debugLevel = ZSTD_DEBUG ; <nl> + # define DEBUGLOG ( l , . . . ) if ( l < = g_debugLevel ) { fprintf ( stderr , __FILE__ " : " ) ; fprintf ( stderr , __VA_ARGS__ ) ; fprintf ( stderr , " \ n " ) ; } <nl> + # else <nl> + # define DEBUGLOG ( l , . . . ) { } / * disabled * / <nl> + # endif <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Constants <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + static const U32 g_searchStrength = 8 ; / * control skip over incompressible data * / <nl> + # define HASH_READ_SIZE 8 <nl> + typedef enum { ZSTDcs_created = 0 , ZSTDcs_init , ZSTDcs_ongoing , ZSTDcs_ending } ZSTD_compressionStage_e ; <nl> + <nl> + / * entropy tables always have same size * / <nl> + static size_t const hufCTable_size = HUF_CTABLE_SIZE ( 255 ) ; <nl> + static size_t const litlengthCTable_size = FSE_CTABLE_SIZE ( LLFSELog , MaxLL ) ; <nl> + static size_t const offcodeCTable_size = FSE_CTABLE_SIZE ( OffFSELog , MaxOff ) ; <nl> + static size_t const matchlengthCTable_size = FSE_CTABLE_SIZE ( MLFSELog , MaxML ) ; <nl> + static size_t const entropyScratchSpace_size = HUF_WORKSPACE_SIZE ; <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Helper functions <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + size_t ZSTD_compressBound ( size_t srcSize ) { <nl> + size_t const lowLimit = 256 KB ; <nl> + size_t const margin = ( srcSize < lowLimit ) ? ( lowLimit - srcSize ) > > 12 : 0 ; / * from 64 to 0 * / <nl> + return srcSize + ( srcSize > > 8 ) + margin ; <nl> + } <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Sequence storage <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + static void ZSTD_resetSeqStore ( seqStore_t * ssPtr ) <nl> + { <nl> + ssPtr - > lit = ssPtr - > litStart ; <nl> + ssPtr - > sequences = ssPtr - > sequencesStart ; <nl> + ssPtr - > longLengthID = 0 ; <nl> + } <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Context memory management <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + struct ZSTD_CCtx_s { <nl> + const BYTE * nextSrc ; / * next block here to continue on current prefix * / <nl> + const BYTE * base ; / * All regular indexes relative to this position * / <nl> + const BYTE * dictBase ; / * extDict indexes relative to this position * / <nl> + U32 dictLimit ; / * below that point , need extDict * / <nl> + U32 lowLimit ; / * below that point , no more data * / <nl> + U32 nextToUpdate ; / * index from which to continue dictionary update * / <nl> + U32 nextToUpdate3 ; / * index from which to continue dictionary update * / <nl> + U32 hashLog3 ; / * dispatch table : larger = = faster , more memory * / <nl> + U32 loadedDictEnd ; / * index of end of dictionary * / <nl> + U32 forceWindow ; / * force back - references to respect limit of 1 < < wLog , even for dictionary * / <nl> + U32 forceRawDict ; / * Force loading dictionary in " content - only " mode ( no header analysis ) * / <nl> + ZSTD_compressionStage_e stage ; <nl> + U32 rep [ ZSTD_REP_NUM ] ; <nl> + U32 repToConfirm [ ZSTD_REP_NUM ] ; <nl> + U32 dictID ; <nl> + ZSTD_parameters params ; <nl> + void * workSpace ; <nl> + size_t workSpaceSize ; <nl> + size_t blockSize ; <nl> + U64 frameContentSize ; <nl> + U64 consumedSrcSize ; <nl> + XXH64_state_t xxhState ; <nl> + ZSTD_customMem customMem ; <nl> + <nl> + seqStore_t seqStore ; / * sequences storage ptrs * / <nl> + U32 * hashTable ; <nl> + U32 * hashTable3 ; <nl> + U32 * chainTable ; <nl> + HUF_repeat hufCTable_repeatMode ; <nl> + HUF_CElt * hufCTable ; <nl> + U32 fseCTables_ready ; <nl> + FSE_CTable * offcodeCTable ; <nl> + FSE_CTable * matchlengthCTable ; <nl> + FSE_CTable * litlengthCTable ; <nl> + unsigned * entropyScratchSpace ; <nl> + } ; <nl> + <nl> + ZSTD_CCtx * ZSTD_createCCtx ( void ) <nl> + { <nl> + return ZSTD_createCCtx_advanced ( defaultCustomMem ) ; <nl> + } <nl> + <nl> + ZSTD_CCtx * ZSTD_createCCtx_advanced ( ZSTD_customMem customMem ) <nl> + { <nl> + ZSTD_CCtx * cctx ; <nl> + <nl> + if ( ! customMem . customAlloc & & ! customMem . customFree ) customMem = defaultCustomMem ; <nl> + if ( ! customMem . customAlloc | | ! customMem . customFree ) return NULL ; <nl> + <nl> + cctx = ( ZSTD_CCtx * ) ZSTD_malloc ( sizeof ( ZSTD_CCtx ) , customMem ) ; <nl> + if ( ! cctx ) return NULL ; <nl> + memset ( cctx , 0 , sizeof ( ZSTD_CCtx ) ) ; <nl> + cctx - > customMem = customMem ; <nl> + return cctx ; <nl> + } <nl> + <nl> + size_t ZSTD_freeCCtx ( ZSTD_CCtx * cctx ) <nl> + { <nl> + if ( cctx = = NULL ) return 0 ; / * support free on NULL * / <nl> + ZSTD_free ( cctx - > workSpace , cctx - > customMem ) ; <nl> + ZSTD_free ( cctx , cctx - > customMem ) ; <nl> + return 0 ; / * reserved as a potential error code in the future * / <nl> + } <nl> + <nl> + size_t ZSTD_sizeof_CCtx ( const ZSTD_CCtx * cctx ) <nl> + { <nl> + if ( cctx = = NULL ) return 0 ; / * support sizeof on NULL * / <nl> + return sizeof ( * cctx ) + cctx - > workSpaceSize ; <nl> + } <nl> + <nl> + size_t ZSTD_setCCtxParameter ( ZSTD_CCtx * cctx , ZSTD_CCtxParameter param , unsigned value ) <nl> + { <nl> + switch ( param ) <nl> + { <nl> + case ZSTD_p_forceWindow : cctx - > forceWindow = value > 0 ; cctx - > loadedDictEnd = 0 ; return 0 ; <nl> + case ZSTD_p_forceRawDict : cctx - > forceRawDict = value > 0 ; return 0 ; <nl> + default : return ERROR ( parameter_unknown ) ; <nl> + } <nl> + } <nl> + <nl> + const seqStore_t * ZSTD_getSeqStore ( const ZSTD_CCtx * ctx ) / * hidden interface * / <nl> + { <nl> + return & ( ctx - > seqStore ) ; <nl> + } <nl> + <nl> + static ZSTD_parameters ZSTD_getParamsFromCCtx ( const ZSTD_CCtx * cctx ) <nl> + { <nl> + return cctx - > params ; <nl> + } <nl> + <nl> + <nl> + / * * ZSTD_checkParams ( ) : <nl> + ensure param values remain within authorized range . <nl> + @ return : 0 , or an error code if one value is beyond authorized range * / <nl> + size_t ZSTD_checkCParams ( ZSTD_compressionParameters cParams ) <nl> + { <nl> + # define CLAMPCHECK ( val , min , max ) { if ( ( val < min ) | ( val > max ) ) return ERROR ( compressionParameter_unsupported ) ; } <nl> + CLAMPCHECK ( cParams . windowLog , ZSTD_WINDOWLOG_MIN , ZSTD_WINDOWLOG_MAX ) ; <nl> + CLAMPCHECK ( cParams . chainLog , ZSTD_CHAINLOG_MIN , ZSTD_CHAINLOG_MAX ) ; <nl> + CLAMPCHECK ( cParams . hashLog , ZSTD_HASHLOG_MIN , ZSTD_HASHLOG_MAX ) ; <nl> + CLAMPCHECK ( cParams . searchLog , ZSTD_SEARCHLOG_MIN , ZSTD_SEARCHLOG_MAX ) ; <nl> + CLAMPCHECK ( cParams . searchLength , ZSTD_SEARCHLENGTH_MIN , ZSTD_SEARCHLENGTH_MAX ) ; <nl> + CLAMPCHECK ( cParams . targetLength , ZSTD_TARGETLENGTH_MIN , ZSTD_TARGETLENGTH_MAX ) ; <nl> + if ( ( U32 ) ( cParams . strategy ) > ( U32 ) ZSTD_btopt2 ) return ERROR ( compressionParameter_unsupported ) ; <nl> + return 0 ; <nl> + } <nl> + <nl> + <nl> + / * * ZSTD_cycleLog ( ) : <nl> + * condition for correct operation : hashLog > 1 * / <nl> + static U32 ZSTD_cycleLog ( U32 hashLog , ZSTD_strategy strat ) <nl> + { <nl> + U32 const btScale = ( ( U32 ) strat > = ( U32 ) ZSTD_btlazy2 ) ; <nl> + return hashLog - btScale ; <nl> + } <nl> + <nl> + / * * ZSTD_adjustCParams ( ) : <nl> + optimize ` cPar ` for a given input ( ` srcSize ` and ` dictSize ` ) . <nl> + mostly downsizing to reduce memory consumption and initialization . <nl> + Both ` srcSize ` and ` dictSize ` are optional ( use 0 if unknown ) , <nl> + but if both are 0 , no optimization can be done . <nl> + Note : cPar is considered validated at this stage . Use ZSTD_checkParams ( ) to ensure that . * / <nl> + ZSTD_compressionParameters ZSTD_adjustCParams ( ZSTD_compressionParameters cPar , unsigned long long srcSize , size_t dictSize ) <nl> + { <nl> + if ( srcSize + dictSize = = 0 ) return cPar ; / * no size information available : no adjustment * / <nl> + <nl> + / * resize params , to use less memory when necessary * / <nl> + { U32 const minSrcSize = ( srcSize = = 0 ) ? 500 : 0 ; <nl> + U64 const rSize = srcSize + dictSize + minSrcSize ; <nl> + if ( rSize < ( ( U64 ) 1 < < ZSTD_WINDOWLOG_MAX ) ) { <nl> + U32 const srcLog = MAX ( ZSTD_HASHLOG_MIN , ZSTD_highbit32 ( ( U32 ) ( rSize ) - 1 ) + 1 ) ; <nl> + if ( cPar . windowLog > srcLog ) cPar . windowLog = srcLog ; <nl> + } } <nl> + if ( cPar . hashLog > cPar . windowLog ) cPar . hashLog = cPar . windowLog ; <nl> + { U32 const cycleLog = ZSTD_cycleLog ( cPar . chainLog , cPar . strategy ) ; <nl> + if ( cycleLog > cPar . windowLog ) cPar . chainLog - = ( cycleLog - cPar . windowLog ) ; <nl> + } <nl> + <nl> + if ( cPar . windowLog < ZSTD_WINDOWLOG_ABSOLUTEMIN ) cPar . windowLog = ZSTD_WINDOWLOG_ABSOLUTEMIN ; / * required for frame header * / <nl> + <nl> + return cPar ; <nl> + } <nl> + <nl> + <nl> + size_t ZSTD_estimateCCtxSize ( ZSTD_compressionParameters cParams ) <nl> + { <nl> + size_t const blockSize = MIN ( ZSTD_BLOCKSIZE_ABSOLUTEMAX , ( size_t ) 1 < < cParams . windowLog ) ; <nl> + U32 const divider = ( cParams . searchLength = = 3 ) ? 3 : 4 ; <nl> + size_t const maxNbSeq = blockSize / divider ; <nl> + size_t const tokenSpace = blockSize + 11 * maxNbSeq ; <nl> + <nl> + size_t const chainSize = ( cParams . strategy = = ZSTD_fast ) ? 0 : ( 1 < < cParams . chainLog ) ; <nl> + size_t const hSize = ( ( size_t ) 1 ) < < cParams . hashLog ; <nl> + U32 const hashLog3 = ( cParams . searchLength > 3 ) ? 0 : MIN ( ZSTD_HASHLOG3_MAX , cParams . windowLog ) ; <nl> + size_t const h3Size = ( ( size_t ) 1 ) < < hashLog3 ; <nl> + size_t const entropySpace = hufCTable_size + litlengthCTable_size <nl> + + offcodeCTable_size + matchlengthCTable_size <nl> + + entropyScratchSpace_size ; <nl> + size_t const tableSpace = ( chainSize + hSize + h3Size ) * sizeof ( U32 ) ; <nl> + <nl> + size_t const optSpace = ( ( MaxML + 1 ) + ( MaxLL + 1 ) + ( MaxOff + 1 ) + ( 1 < < Litbits ) ) * sizeof ( U32 ) <nl> + + ( ZSTD_OPT_NUM + 1 ) * ( sizeof ( ZSTD_match_t ) + sizeof ( ZSTD_optimal_t ) ) ; <nl> + size_t const neededSpace = entropySpace + tableSpace + tokenSpace <nl> + + ( ( ( cParams . strategy = = ZSTD_btopt ) | | ( cParams . strategy = = ZSTD_btopt2 ) ) ? optSpace : 0 ) ; <nl> + <nl> + return sizeof ( ZSTD_CCtx ) + neededSpace ; <nl> + } <nl> + <nl> + <nl> + static U32 ZSTD_equivalentParams ( ZSTD_parameters param1 , ZSTD_parameters param2 ) <nl> + { <nl> + return ( param1 . cParams . hashLog = = param2 . cParams . hashLog ) <nl> + & ( param1 . cParams . chainLog = = param2 . cParams . chainLog ) <nl> + & ( param1 . cParams . strategy = = param2 . cParams . strategy ) <nl> + & ( ( param1 . cParams . searchLength = = 3 ) = = ( param2 . cParams . searchLength = = 3 ) ) ; <nl> + } <nl> + <nl> + / * ! ZSTD_continueCCtx ( ) : <nl> + reuse CCtx without reset ( note : requires no dictionary ) * / <nl> + static size_t ZSTD_continueCCtx ( ZSTD_CCtx * cctx , ZSTD_parameters params , U64 frameContentSize ) <nl> + { <nl> + U32 const end = ( U32 ) ( cctx - > nextSrc - cctx - > base ) ; <nl> + cctx - > params = params ; <nl> + cctx - > frameContentSize = frameContentSize ; <nl> + cctx - > consumedSrcSize = 0 ; <nl> + cctx - > lowLimit = end ; <nl> + cctx - > dictLimit = end ; <nl> + cctx - > nextToUpdate = end + 1 ; <nl> + cctx - > stage = ZSTDcs_init ; <nl> + cctx - > dictID = 0 ; <nl> + cctx - > loadedDictEnd = 0 ; <nl> + { int i ; for ( i = 0 ; i < ZSTD_REP_NUM ; i + + ) cctx - > rep [ i ] = repStartValue [ i ] ; } <nl> + cctx - > seqStore . litLengthSum = 0 ; / * force reset of btopt stats * / <nl> + XXH64_reset ( & cctx - > xxhState , 0 ) ; <nl> + return 0 ; <nl> + } <nl> + <nl> + typedef enum { ZSTDcrp_continue , ZSTDcrp_noMemset , ZSTDcrp_fullReset } ZSTD_compResetPolicy_e ; <nl> + <nl> + / * ! ZSTD_resetCCtx_internal ( ) : <nl> + note : ` params ` must be validated * / <nl> + static size_t ZSTD_resetCCtx_internal ( ZSTD_CCtx * zc , <nl> + ZSTD_parameters params , U64 frameContentSize , <nl> + ZSTD_compResetPolicy_e const crp ) <nl> + { <nl> + if ( crp = = ZSTDcrp_continue ) <nl> + if ( ZSTD_equivalentParams ( params , zc - > params ) ) { <nl> + zc - > fseCTables_ready = 0 ; <nl> + zc - > hufCTable_repeatMode = HUF_repeat_none ; <nl> + return ZSTD_continueCCtx ( zc , params , frameContentSize ) ; <nl> + } <nl> + <nl> + { size_t const blockSize = MIN ( ZSTD_BLOCKSIZE_ABSOLUTEMAX , ( size_t ) 1 < < params . cParams . windowLog ) ; <nl> + U32 const divider = ( params . cParams . searchLength = = 3 ) ? 3 : 4 ; <nl> + size_t const maxNbSeq = blockSize / divider ; <nl> + size_t const tokenSpace = blockSize + 11 * maxNbSeq ; <nl> + size_t const chainSize = ( params . cParams . strategy = = ZSTD_fast ) ? 0 : ( 1 < < params . cParams . chainLog ) ; <nl> + size_t const hSize = ( ( size_t ) 1 ) < < params . cParams . hashLog ; <nl> + U32 const hashLog3 = ( params . cParams . searchLength > 3 ) ? 0 : MIN ( ZSTD_HASHLOG3_MAX , params . cParams . windowLog ) ; <nl> + size_t const h3Size = ( ( size_t ) 1 ) < < hashLog3 ; <nl> + size_t const tableSpace = ( chainSize + hSize + h3Size ) * sizeof ( U32 ) ; <nl> + void * ptr ; <nl> + <nl> + / * Check if workSpace is large enough , alloc a new one if needed * / <nl> + { size_t const entropySpace = hufCTable_size + litlengthCTable_size <nl> + + offcodeCTable_size + matchlengthCTable_size <nl> + + entropyScratchSpace_size ; <nl> + size_t const optPotentialSpace = ( ( MaxML + 1 ) + ( MaxLL + 1 ) + ( MaxOff + 1 ) + ( 1 < < Litbits ) ) * sizeof ( U32 ) <nl> + + ( ZSTD_OPT_NUM + 1 ) * ( sizeof ( ZSTD_match_t ) + sizeof ( ZSTD_optimal_t ) ) ; <nl> + size_t const optSpace = ( ( params . cParams . strategy = = ZSTD_btopt ) | | ( params . cParams . strategy = = ZSTD_btopt2 ) ) ? optPotentialSpace : 0 ; <nl> + size_t const neededSpace = entropySpace + optSpace + tableSpace + tokenSpace ; <nl> + if ( zc - > workSpaceSize < neededSpace ) { <nl> + zc - > workSpaceSize = 0 ; <nl> + ZSTD_free ( zc - > workSpace , zc - > customMem ) ; <nl> + zc - > workSpace = ZSTD_malloc ( neededSpace , zc - > customMem ) ; <nl> + if ( zc - > workSpace = = NULL ) return ERROR ( memory_allocation ) ; <nl> + zc - > workSpaceSize = neededSpace ; <nl> + ptr = zc - > workSpace ; <nl> + <nl> + / * entropy space * / <nl> + zc - > hufCTable = ( HUF_CElt * ) ptr ; <nl> + ptr = ( char * ) zc - > hufCTable + hufCTable_size ; / * note : HUF_CElt * is incomplete type , size is estimated via macro * / <nl> + zc - > offcodeCTable = ( FSE_CTable * ) ptr ; <nl> + ptr = ( char * ) ptr + offcodeCTable_size ; <nl> + zc - > matchlengthCTable = ( FSE_CTable * ) ptr ; <nl> + ptr = ( char * ) ptr + matchlengthCTable_size ; <nl> + zc - > litlengthCTable = ( FSE_CTable * ) ptr ; <nl> + ptr = ( char * ) ptr + litlengthCTable_size ; <nl> + assert ( ( ( size_t ) ptr & 3 ) = = 0 ) ; / * ensure correct alignment * / <nl> + zc - > entropyScratchSpace = ( unsigned * ) ptr ; <nl> + } } <nl> + <nl> + / * init params * / <nl> + zc - > params = params ; <nl> + zc - > blockSize = blockSize ; <nl> + zc - > frameContentSize = frameContentSize ; <nl> + zc - > consumedSrcSize = 0 ; <nl> + <nl> + XXH64_reset ( & zc - > xxhState , 0 ) ; <nl> + zc - > stage = ZSTDcs_init ; <nl> + zc - > dictID = 0 ; <nl> + zc - > loadedDictEnd = 0 ; <nl> + zc - > fseCTables_ready = 0 ; <nl> + zc - > hufCTable_repeatMode = HUF_repeat_none ; <nl> + zc - > nextToUpdate = 1 ; <nl> + zc - > nextSrc = NULL ; <nl> + zc - > base = NULL ; <nl> + zc - > dictBase = NULL ; <nl> + zc - > dictLimit = 0 ; <nl> + zc - > lowLimit = 0 ; <nl> + { int i ; for ( i = 0 ; i < ZSTD_REP_NUM ; i + + ) zc - > rep [ i ] = repStartValue [ i ] ; } <nl> + zc - > hashLog3 = hashLog3 ; <nl> + zc - > seqStore . litLengthSum = 0 ; <nl> + <nl> + / * ensure entropy tables are close together at the beginning * / <nl> + assert ( ( void * ) zc - > hufCTable = = zc - > workSpace ) ; <nl> + assert ( ( char * ) zc - > offcodeCTable = = ( char * ) zc - > hufCTable + hufCTable_size ) ; <nl> + assert ( ( char * ) zc - > matchlengthCTable = = ( char * ) zc - > offcodeCTable + offcodeCTable_size ) ; <nl> + assert ( ( char * ) zc - > litlengthCTable = = ( char * ) zc - > matchlengthCTable + matchlengthCTable_size ) ; <nl> + assert ( ( char * ) zc - > entropyScratchSpace = = ( char * ) zc - > litlengthCTable + litlengthCTable_size ) ; <nl> + ptr = ( char * ) zc - > entropyScratchSpace + entropyScratchSpace_size ; <nl> + <nl> + / * opt parser space * / <nl> + if ( ( params . cParams . strategy = = ZSTD_btopt ) | | ( params . cParams . strategy = = ZSTD_btopt2 ) ) { <nl> + assert ( ( ( size_t ) ptr & 3 ) = = 0 ) ; / * ensure ptr is properly aligned * / <nl> + zc - > seqStore . litFreq = ( U32 * ) ptr ; <nl> + zc - > seqStore . litLengthFreq = zc - > seqStore . litFreq + ( 1 < < Litbits ) ; <nl> + zc - > seqStore . matchLengthFreq = zc - > seqStore . litLengthFreq + ( MaxLL + 1 ) ; <nl> + zc - > seqStore . offCodeFreq = zc - > seqStore . matchLengthFreq + ( MaxML + 1 ) ; <nl> + ptr = zc - > seqStore . offCodeFreq + ( MaxOff + 1 ) ; <nl> + zc - > seqStore . matchTable = ( ZSTD_match_t * ) ptr ; <nl> + ptr = zc - > seqStore . matchTable + ZSTD_OPT_NUM + 1 ; <nl> + zc - > seqStore . priceTable = ( ZSTD_optimal_t * ) ptr ; <nl> + ptr = zc - > seqStore . priceTable + ZSTD_OPT_NUM + 1 ; <nl> + } <nl> + <nl> + / * table Space * / <nl> + if ( crp ! = ZSTDcrp_noMemset ) memset ( ptr , 0 , tableSpace ) ; / * reset tables only * / <nl> + assert ( ( ( size_t ) ptr & 3 ) = = 0 ) ; / * ensure ptr is properly aligned * / <nl> + zc - > hashTable = ( U32 * ) ( ptr ) ; <nl> + zc - > chainTable = zc - > hashTable + hSize ; <nl> + zc - > hashTable3 = zc - > chainTable + chainSize ; <nl> + ptr = zc - > hashTable3 + h3Size ; <nl> + <nl> + / * sequences storage * / <nl> + zc - > seqStore . sequencesStart = ( seqDef * ) ptr ; <nl> + ptr = zc - > seqStore . sequencesStart + maxNbSeq ; <nl> + zc - > seqStore . llCode = ( BYTE * ) ptr ; <nl> + zc - > seqStore . mlCode = zc - > seqStore . llCode + maxNbSeq ; <nl> + zc - > seqStore . ofCode = zc - > seqStore . mlCode + maxNbSeq ; <nl> + zc - > seqStore . litStart = zc - > seqStore . ofCode + maxNbSeq ; <nl> + <nl> + return 0 ; <nl> + } <nl> + } <nl> + <nl> + / * ZSTD_invalidateRepCodes ( ) : <nl> + * ensures next compression will not use repcodes from previous block . <nl> + * Note : only works with regular variant ; <nl> + * do not use with extDict variant ! * / <nl> + void ZSTD_invalidateRepCodes ( ZSTD_CCtx * cctx ) { <nl> + int i ; <nl> + for ( i = 0 ; i < ZSTD_REP_NUM ; i + + ) cctx - > rep [ i ] = 0 ; <nl> + } <nl> + <nl> + <nl> + / * ! ZSTD_copyCCtx_internal ( ) : <nl> + * Duplicate an existing context ` srcCCtx ` into another one ` dstCCtx ` . <nl> + * Only works during stage ZSTDcs_init ( i . e . after creation , but before first call to ZSTD_compressContinue ( ) ) . <nl> + * pledgedSrcSize = 0 means " empty " if fParams . contentSizeFlag = 1 <nl> + * @ return : 0 , or an error code * / <nl> + size_t ZSTD_copyCCtx_internal ( ZSTD_CCtx * dstCCtx , const ZSTD_CCtx * srcCCtx , <nl> + ZSTD_frameParameters fParams , unsigned long long pledgedSrcSize ) <nl> + { <nl> + if ( srcCCtx - > stage ! = ZSTDcs_init ) return ERROR ( stage_wrong ) ; <nl> + <nl> + memcpy ( & dstCCtx - > customMem , & srcCCtx - > customMem , sizeof ( ZSTD_customMem ) ) ; <nl> + { ZSTD_parameters params = srcCCtx - > params ; <nl> + params . fParams = fParams ; <nl> + DEBUGLOG ( 5 , " ZSTD_resetCCtx_internal : dictIDFlag : % u \ n " , ! fParams . noDictIDFlag ) ; <nl> + ZSTD_resetCCtx_internal ( dstCCtx , params , pledgedSrcSize , ZSTDcrp_noMemset ) ; <nl> + } <nl> + <nl> + / * copy tables * / <nl> + { size_t const chainSize = ( srcCCtx - > params . cParams . strategy = = ZSTD_fast ) ? 0 : ( 1 < < srcCCtx - > params . cParams . chainLog ) ; <nl> + size_t const hSize = ( size_t ) 1 < < srcCCtx - > params . cParams . hashLog ; <nl> + size_t const h3Size = ( size_t ) 1 < < srcCCtx - > hashLog3 ; <nl> + size_t const tableSpace = ( chainSize + hSize + h3Size ) * sizeof ( U32 ) ; <nl> + assert ( ( U32 * ) dstCCtx - > chainTable = = ( U32 * ) dstCCtx - > hashTable + hSize ) ; / * chainTable must follow hashTable * / <nl> + assert ( ( U32 * ) dstCCtx - > hashTable3 = = ( U32 * ) dstCCtx - > chainTable + chainSize ) ; <nl> + memcpy ( dstCCtx - > hashTable , srcCCtx - > hashTable , tableSpace ) ; / * presumes all tables follow each other * / <nl> + } <nl> + <nl> + / * copy dictionary offsets * / <nl> + dstCCtx - > nextToUpdate = srcCCtx - > nextToUpdate ; <nl> + dstCCtx - > nextToUpdate3 = srcCCtx - > nextToUpdate3 ; <nl> + dstCCtx - > nextSrc = srcCCtx - > nextSrc ; <nl> + dstCCtx - > base = srcCCtx - > base ; <nl> + dstCCtx - > dictBase = srcCCtx - > dictBase ; <nl> + dstCCtx - > dictLimit = srcCCtx - > dictLimit ; <nl> + dstCCtx - > lowLimit = srcCCtx - > lowLimit ; <nl> + dstCCtx - > loadedDictEnd = srcCCtx - > loadedDictEnd ; <nl> + dstCCtx - > dictID = srcCCtx - > dictID ; <nl> + <nl> + / * copy entropy tables * / <nl> + dstCCtx - > fseCTables_ready = srcCCtx - > fseCTables_ready ; <nl> + if ( srcCCtx - > fseCTables_ready ) { <nl> + memcpy ( dstCCtx - > litlengthCTable , srcCCtx - > litlengthCTable , litlengthCTable_size ) ; <nl> + memcpy ( dstCCtx - > matchlengthCTable , srcCCtx - > matchlengthCTable , matchlengthCTable_size ) ; <nl> + memcpy ( dstCCtx - > offcodeCTable , srcCCtx - > offcodeCTable , offcodeCTable_size ) ; <nl> + } <nl> + dstCCtx - > hufCTable_repeatMode = srcCCtx - > hufCTable_repeatMode ; <nl> + if ( srcCCtx - > hufCTable_repeatMode ) { <nl> + memcpy ( dstCCtx - > hufCTable , srcCCtx - > hufCTable , hufCTable_size ) ; <nl> + } <nl> + <nl> + return 0 ; <nl> + } <nl> + <nl> + / * ! ZSTD_copyCCtx ( ) : <nl> + * Duplicate an existing context ` srcCCtx ` into another one ` dstCCtx ` . <nl> + * Only works during stage ZSTDcs_init ( i . e . after creation , but before first call to ZSTD_compressContinue ( ) ) . <nl> + * pledgedSrcSize = = 0 means " unknown " . <nl> + * @ return : 0 , or an error code * / <nl> + size_t ZSTD_copyCCtx ( ZSTD_CCtx * dstCCtx , const ZSTD_CCtx * srcCCtx , unsigned long long pledgedSrcSize ) <nl> + { <nl> + ZSTD_frameParameters fParams = { 1 / * content * / , 0 / * checksum * / , 0 / * noDictID * / } ; <nl> + fParams . contentSizeFlag = pledgedSrcSize > 0 ; <nl> + <nl> + return ZSTD_copyCCtx_internal ( dstCCtx , srcCCtx , fParams , pledgedSrcSize ) ; <nl> + } <nl> + <nl> + <nl> + / * ! ZSTD_reduceTable ( ) : <nl> + * reduce table indexes by ` reducerValue ` * / <nl> + static void ZSTD_reduceTable ( U32 * const table , U32 const size , U32 const reducerValue ) <nl> + { <nl> + U32 u ; <nl> + for ( u = 0 ; u < size ; u + + ) { <nl> + if ( table [ u ] < reducerValue ) table [ u ] = 0 ; <nl> + else table [ u ] - = reducerValue ; <nl> + } <nl> + } <nl> + <nl> + / * ! ZSTD_reduceIndex ( ) : <nl> + * rescale all indexes to avoid future overflow ( indexes are U32 ) * / <nl> + static void ZSTD_reduceIndex ( ZSTD_CCtx * zc , const U32 reducerValue ) <nl> + { <nl> + { U32 const hSize = 1 < < zc - > params . cParams . hashLog ; <nl> + ZSTD_reduceTable ( zc - > hashTable , hSize , reducerValue ) ; } <nl> + <nl> + { U32 const chainSize = ( zc - > params . cParams . strategy = = ZSTD_fast ) ? 0 : ( 1 < < zc - > params . cParams . chainLog ) ; <nl> + ZSTD_reduceTable ( zc - > chainTable , chainSize , reducerValue ) ; } <nl> + <nl> + { U32 const h3Size = ( zc - > hashLog3 ) ? 1 < < zc - > hashLog3 : 0 ; <nl> + ZSTD_reduceTable ( zc - > hashTable3 , h3Size , reducerValue ) ; } <nl> + } <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Block entropic compression <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + / * See doc / zstd_compression_format . md for detailed format description * / <nl> + <nl> + size_t ZSTD_noCompressBlock ( void * dst , size_t dstCapacity , const void * src , size_t srcSize ) <nl> + { <nl> + if ( srcSize + ZSTD_blockHeaderSize > dstCapacity ) return ERROR ( dstSize_tooSmall ) ; <nl> + memcpy ( ( BYTE * ) dst + ZSTD_blockHeaderSize , src , srcSize ) ; <nl> + MEM_writeLE24 ( dst , ( U32 ) ( srcSize < < 2 ) + ( U32 ) bt_raw ) ; <nl> + return ZSTD_blockHeaderSize + srcSize ; <nl> + } <nl> + <nl> + <nl> + static size_t ZSTD_noCompressLiterals ( void * dst , size_t dstCapacity , const void * src , size_t srcSize ) <nl> + { <nl> + BYTE * const ostart = ( BYTE * const ) dst ; <nl> + U32 const flSize = 1 + ( srcSize > 31 ) + ( srcSize > 4095 ) ; <nl> + <nl> + if ( srcSize + flSize > dstCapacity ) return ERROR ( dstSize_tooSmall ) ; <nl> + <nl> + switch ( flSize ) <nl> + { <nl> + case 1 : / * 2 - 1 - 5 * / <nl> + ostart [ 0 ] = ( BYTE ) ( ( U32 ) set_basic + ( srcSize < < 3 ) ) ; <nl> + break ; <nl> + case 2 : / * 2 - 2 - 12 * / <nl> + MEM_writeLE16 ( ostart , ( U16 ) ( ( U32 ) set_basic + ( 1 < < 2 ) + ( srcSize < < 4 ) ) ) ; <nl> + break ; <nl> + default : / * note : should not be necessary : flSize is within { 1 , 2 , 3 } * / <nl> + case 3 : / * 2 - 2 - 20 * / <nl> + MEM_writeLE32 ( ostart , ( U32 ) ( ( U32 ) set_basic + ( 3 < < 2 ) + ( srcSize < < 4 ) ) ) ; <nl> + break ; <nl> + } <nl> + <nl> + memcpy ( ostart + flSize , src , srcSize ) ; <nl> + return srcSize + flSize ; <nl> + } <nl> + <nl> + static size_t ZSTD_compressRleLiteralsBlock ( void * dst , size_t dstCapacity , const void * src , size_t srcSize ) <nl> + { <nl> + BYTE * const ostart = ( BYTE * const ) dst ; <nl> + U32 const flSize = 1 + ( srcSize > 31 ) + ( srcSize > 4095 ) ; <nl> + <nl> + ( void ) dstCapacity ; / * dstCapacity already guaranteed to be > = 4 , hence large enough * / <nl> + <nl> + switch ( flSize ) <nl> + { <nl> + case 1 : / * 2 - 1 - 5 * / <nl> + ostart [ 0 ] = ( BYTE ) ( ( U32 ) set_rle + ( srcSize < < 3 ) ) ; <nl> + break ; <nl> + case 2 : / * 2 - 2 - 12 * / <nl> + MEM_writeLE16 ( ostart , ( U16 ) ( ( U32 ) set_rle + ( 1 < < 2 ) + ( srcSize < < 4 ) ) ) ; <nl> + break ; <nl> + default : / * note : should not be necessary : flSize is necessarily within { 1 , 2 , 3 } * / <nl> + case 3 : / * 2 - 2 - 20 * / <nl> + MEM_writeLE32 ( ostart , ( U32 ) ( ( U32 ) set_rle + ( 3 < < 2 ) + ( srcSize < < 4 ) ) ) ; <nl> + break ; <nl> + } <nl> + <nl> + ostart [ flSize ] = * ( const BYTE * ) src ; <nl> + return flSize + 1 ; <nl> + } <nl> + <nl> + <nl> + static size_t ZSTD_minGain ( size_t srcSize ) { return ( srcSize > > 6 ) + 2 ; } <nl> + <nl> + static size_t ZSTD_compressLiterals ( ZSTD_CCtx * zc , <nl> + void * dst , size_t dstCapacity , <nl> + const void * src , size_t srcSize ) <nl> + { <nl> + size_t const minGain = ZSTD_minGain ( srcSize ) ; <nl> + size_t const lhSize = 3 + ( srcSize > = 1 KB ) + ( srcSize > = 16 KB ) ; <nl> + BYTE * const ostart = ( BYTE * ) dst ; <nl> + U32 singleStream = srcSize < 256 ; <nl> + symbolEncodingType_e hType = set_compressed ; <nl> + size_t cLitSize ; <nl> + <nl> + <nl> + / * small ? don ' t even attempt compression ( speed opt ) * / <nl> + # define LITERAL_NOENTROPY 63 <nl> + { size_t const minLitSize = zc - > hufCTable_repeatMode = = HUF_repeat_valid ? 6 : LITERAL_NOENTROPY ; <nl> + if ( srcSize < = minLitSize ) return ZSTD_noCompressLiterals ( dst , dstCapacity , src , srcSize ) ; <nl> + } <nl> + <nl> + if ( dstCapacity < lhSize + 1 ) return ERROR ( dstSize_tooSmall ) ; / * not enough space for compression * / <nl> + { HUF_repeat repeat = zc - > hufCTable_repeatMode ; <nl> + int const preferRepeat = zc - > params . cParams . strategy < ZSTD_lazy ? srcSize < = 1024 : 0 ; <nl> + if ( repeat = = HUF_repeat_valid & & lhSize = = 3 ) singleStream = 1 ; <nl> + cLitSize = singleStream ? HUF_compress1X_repeat ( ostart + lhSize , dstCapacity - lhSize , src , srcSize , 255 , 11 , <nl> + zc - > entropyScratchSpace , entropyScratchSpace_size , zc - > hufCTable , & repeat , preferRepeat ) <nl> + : HUF_compress4X_repeat ( ostart + lhSize , dstCapacity - lhSize , src , srcSize , 255 , 11 , <nl> + zc - > entropyScratchSpace , entropyScratchSpace_size , zc - > hufCTable , & repeat , preferRepeat ) ; <nl> + if ( repeat ! = HUF_repeat_none ) { hType = set_repeat ; } / * reused the existing table * / <nl> + else { zc - > hufCTable_repeatMode = HUF_repeat_check ; } / * now have a table to reuse * / <nl> + } <nl> + <nl> + if ( ( cLitSize = = 0 ) | ( cLitSize > = srcSize - minGain ) ) { <nl> + zc - > hufCTable_repeatMode = HUF_repeat_none ; <nl> + return ZSTD_noCompressLiterals ( dst , dstCapacity , src , srcSize ) ; <nl> + } <nl> + if ( cLitSize = = 1 ) { <nl> + zc - > hufCTable_repeatMode = HUF_repeat_none ; <nl> + return ZSTD_compressRleLiteralsBlock ( dst , dstCapacity , src , srcSize ) ; <nl> + } <nl> + <nl> + / * Build header * / <nl> + switch ( lhSize ) <nl> + { <nl> + case 3 : / * 2 - 2 - 10 - 10 * / <nl> + { U32 const lhc = hType + ( ( ! singleStream ) < < 2 ) + ( ( U32 ) srcSize < < 4 ) + ( ( U32 ) cLitSize < < 14 ) ; <nl> + MEM_writeLE24 ( ostart , lhc ) ; <nl> + break ; <nl> + } <nl> + case 4 : / * 2 - 2 - 14 - 14 * / <nl> + { U32 const lhc = hType + ( 2 < < 2 ) + ( ( U32 ) srcSize < < 4 ) + ( ( U32 ) cLitSize < < 18 ) ; <nl> + MEM_writeLE32 ( ostart , lhc ) ; <nl> + break ; <nl> + } <nl> + default : / * should not be necessary , lhSize is only { 3 , 4 , 5 } * / <nl> + case 5 : / * 2 - 2 - 18 - 18 * / <nl> + { U32 const lhc = hType + ( 3 < < 2 ) + ( ( U32 ) srcSize < < 4 ) + ( ( U32 ) cLitSize < < 22 ) ; <nl> + MEM_writeLE32 ( ostart , lhc ) ; <nl> + ostart [ 4 ] = ( BYTE ) ( cLitSize > > 10 ) ; <nl> + break ; <nl> + } <nl> + } <nl> + return lhSize + cLitSize ; <nl> + } <nl> + <nl> + static const BYTE LL_Code [ 64 ] = { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , <nl> + 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , <nl> + 16 , 16 , 17 , 17 , 18 , 18 , 19 , 19 , <nl> + 20 , 20 , 20 , 20 , 21 , 21 , 21 , 21 , <nl> + 22 , 22 , 22 , 22 , 22 , 22 , 22 , 22 , <nl> + 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , <nl> + 24 , 24 , 24 , 24 , 24 , 24 , 24 , 24 , <nl> + 24 , 24 , 24 , 24 , 24 , 24 , 24 , 24 } ; <nl> + <nl> + static const BYTE ML_Code [ 128 ] = { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , <nl> + 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , <nl> + 32 , 32 , 33 , 33 , 34 , 34 , 35 , 35 , 36 , 36 , 36 , 36 , 37 , 37 , 37 , 37 , <nl> + 38 , 38 , 38 , 38 , 38 , 38 , 38 , 38 , 39 , 39 , 39 , 39 , 39 , 39 , 39 , 39 , <nl> + 40 , 40 , 40 , 40 , 40 , 40 , 40 , 40 , 40 , 40 , 40 , 40 , 40 , 40 , 40 , 40 , <nl> + 41 , 41 , 41 , 41 , 41 , 41 , 41 , 41 , 41 , 41 , 41 , 41 , 41 , 41 , 41 , 41 , <nl> + 42 , 42 , 42 , 42 , 42 , 42 , 42 , 42 , 42 , 42 , 42 , 42 , 42 , 42 , 42 , 42 , <nl> + 42 , 42 , 42 , 42 , 42 , 42 , 42 , 42 , 42 , 42 , 42 , 42 , 42 , 42 , 42 , 42 } ; <nl> + <nl> + <nl> + void ZSTD_seqToCodes ( const seqStore_t * seqStorePtr ) <nl> + { <nl> + BYTE const LL_deltaCode = 19 ; <nl> + BYTE const ML_deltaCode = 36 ; <nl> + const seqDef * const sequences = seqStorePtr - > sequencesStart ; <nl> + BYTE * const llCodeTable = seqStorePtr - > llCode ; <nl> + BYTE * const ofCodeTable = seqStorePtr - > ofCode ; <nl> + BYTE * const mlCodeTable = seqStorePtr - > mlCode ; <nl> + U32 const nbSeq = ( U32 ) ( seqStorePtr - > sequences - seqStorePtr - > sequencesStart ) ; <nl> + U32 u ; <nl> + for ( u = 0 ; u < nbSeq ; u + + ) { <nl> + U32 const llv = sequences [ u ] . litLength ; <nl> + U32 const mlv = sequences [ u ] . matchLength ; <nl> + llCodeTable [ u ] = ( llv > 63 ) ? ( BYTE ) ZSTD_highbit32 ( llv ) + LL_deltaCode : LL_Code [ llv ] ; <nl> + ofCodeTable [ u ] = ( BYTE ) ZSTD_highbit32 ( sequences [ u ] . offset ) ; <nl> + mlCodeTable [ u ] = ( mlv > 127 ) ? ( BYTE ) ZSTD_highbit32 ( mlv ) + ML_deltaCode : ML_Code [ mlv ] ; <nl> + } <nl> + if ( seqStorePtr - > longLengthID = = 1 ) <nl> + llCodeTable [ seqStorePtr - > longLengthPos ] = MaxLL ; <nl> + if ( seqStorePtr - > longLengthID = = 2 ) <nl> + mlCodeTable [ seqStorePtr - > longLengthPos ] = MaxML ; <nl> + } <nl> + <nl> + MEM_STATIC size_t ZSTD_compressSequences ( ZSTD_CCtx * zc , <nl> + void * dst , size_t dstCapacity , <nl> + size_t srcSize ) <nl> + { <nl> + const int longOffsets = zc - > params . cParams . windowLog > STREAM_ACCUMULATOR_MIN ; <nl> + const seqStore_t * seqStorePtr = & ( zc - > seqStore ) ; <nl> + U32 count [ MaxSeq + 1 ] ; <nl> + S16 norm [ MaxSeq + 1 ] ; <nl> + FSE_CTable * CTable_LitLength = zc - > litlengthCTable ; <nl> + FSE_CTable * CTable_OffsetBits = zc - > offcodeCTable ; <nl> + FSE_CTable * CTable_MatchLength = zc - > matchlengthCTable ; <nl> + U32 LLtype , Offtype , MLtype ; / * compressed , raw or rle * / <nl> + const seqDef * const sequences = seqStorePtr - > sequencesStart ; <nl> + const BYTE * const ofCodeTable = seqStorePtr - > ofCode ; <nl> + const BYTE * const llCodeTable = seqStorePtr - > llCode ; <nl> + const BYTE * const mlCodeTable = seqStorePtr - > mlCode ; <nl> + BYTE * const ostart = ( BYTE * ) dst ; <nl> + BYTE * const oend = ostart + dstCapacity ; <nl> + BYTE * op = ostart ; <nl> + size_t const nbSeq = seqStorePtr - > sequences - seqStorePtr - > sequencesStart ; <nl> + BYTE * seqHead ; <nl> + BYTE scratchBuffer [ 1 < < MAX ( MLFSELog , LLFSELog ) ] ; <nl> + <nl> + / * Compress literals * / <nl> + { const BYTE * const literals = seqStorePtr - > litStart ; <nl> + size_t const litSize = seqStorePtr - > lit - literals ; <nl> + size_t const cSize = ZSTD_compressLiterals ( zc , op , dstCapacity , literals , litSize ) ; <nl> + if ( ZSTD_isError ( cSize ) ) return cSize ; <nl> + op + = cSize ; <nl> + } <nl> + <nl> + / * Sequences Header * / <nl> + if ( ( oend - op ) < 3 / * max nbSeq Size * / + 1 / * seqHead * / ) return ERROR ( dstSize_tooSmall ) ; <nl> + if ( nbSeq < 0x7F ) * op + + = ( BYTE ) nbSeq ; <nl> + else if ( nbSeq < LONGNBSEQ ) op [ 0 ] = ( BYTE ) ( ( nbSeq > > 8 ) + 0x80 ) , op [ 1 ] = ( BYTE ) nbSeq , op + = 2 ; <nl> + else op [ 0 ] = 0xFF , MEM_writeLE16 ( op + 1 , ( U16 ) ( nbSeq - LONGNBSEQ ) ) , op + = 3 ; <nl> + if ( nbSeq = = 0 ) goto _check_compressibility ; <nl> + <nl> + / * seqHead : flags for FSE encoding type * / <nl> + seqHead = op + + ; <nl> + <nl> + # define MIN_SEQ_FOR_DYNAMIC_FSE 64 <nl> + # define MAX_SEQ_FOR_STATIC_FSE 1000 <nl> + <nl> + / * convert length / distances into codes * / <nl> + ZSTD_seqToCodes ( seqStorePtr ) ; <nl> + <nl> + / * CTable for Literal Lengths * / <nl> + { U32 max = MaxLL ; <nl> + size_t const mostFrequent = FSE_countFast_wksp ( count , & max , llCodeTable , nbSeq , zc - > entropyScratchSpace ) ; <nl> + if ( ( mostFrequent = = nbSeq ) & & ( nbSeq > 2 ) ) { <nl> + * op + + = llCodeTable [ 0 ] ; <nl> + FSE_buildCTable_rle ( CTable_LitLength , ( BYTE ) max ) ; <nl> + LLtype = set_rle ; <nl> + } else if ( ( zc - > fseCTables_ready ) & & ( nbSeq < MAX_SEQ_FOR_STATIC_FSE ) ) { <nl> + LLtype = set_repeat ; <nl> + } else if ( ( nbSeq < MIN_SEQ_FOR_DYNAMIC_FSE ) | | ( mostFrequent < ( nbSeq > > ( LL_defaultNormLog - 1 ) ) ) ) { <nl> + FSE_buildCTable_wksp ( CTable_LitLength , LL_defaultNorm , MaxLL , LL_defaultNormLog , scratchBuffer , sizeof ( scratchBuffer ) ) ; <nl> + LLtype = set_basic ; <nl> + } else { <nl> + size_t nbSeq_1 = nbSeq ; <nl> + const U32 tableLog = FSE_optimalTableLog ( LLFSELog , nbSeq , max ) ; <nl> + if ( count [ llCodeTable [ nbSeq - 1 ] ] > 1 ) { count [ llCodeTable [ nbSeq - 1 ] ] - - ; nbSeq_1 - - ; } <nl> + FSE_normalizeCount ( norm , tableLog , count , nbSeq_1 , max ) ; <nl> + { size_t const NCountSize = FSE_writeNCount ( op , oend - op , norm , max , tableLog ) ; / * overflow protected * / <nl> + if ( FSE_isError ( NCountSize ) ) return NCountSize ; <nl> + op + = NCountSize ; } <nl> + FSE_buildCTable_wksp ( CTable_LitLength , norm , max , tableLog , scratchBuffer , sizeof ( scratchBuffer ) ) ; <nl> + LLtype = set_compressed ; <nl> + } } <nl> + <nl> + / * CTable for Offsets * / <nl> + { U32 max = MaxOff ; <nl> + size_t const mostFrequent = FSE_countFast_wksp ( count , & max , ofCodeTable , nbSeq , zc - > entropyScratchSpace ) ; <nl> + if ( ( mostFrequent = = nbSeq ) & & ( nbSeq > 2 ) ) { <nl> + * op + + = ofCodeTable [ 0 ] ; <nl> + FSE_buildCTable_rle ( CTable_OffsetBits , ( BYTE ) max ) ; <nl> + Offtype = set_rle ; <nl> + } else if ( ( zc - > fseCTables_ready ) & & ( nbSeq < MAX_SEQ_FOR_STATIC_FSE ) ) { <nl> + Offtype = set_repeat ; <nl> + } else if ( ( nbSeq < MIN_SEQ_FOR_DYNAMIC_FSE ) | | ( mostFrequent < ( nbSeq > > ( OF_defaultNormLog - 1 ) ) ) ) { <nl> + FSE_buildCTable_wksp ( CTable_OffsetBits , OF_defaultNorm , MaxOff , OF_defaultNormLog , scratchBuffer , sizeof ( scratchBuffer ) ) ; <nl> + Offtype = set_basic ; <nl> + } else { <nl> + size_t nbSeq_1 = nbSeq ; <nl> + const U32 tableLog = FSE_optimalTableLog ( OffFSELog , nbSeq , max ) ; <nl> + if ( count [ ofCodeTable [ nbSeq - 1 ] ] > 1 ) { count [ ofCodeTable [ nbSeq - 1 ] ] - - ; nbSeq_1 - - ; } <nl> + FSE_normalizeCount ( norm , tableLog , count , nbSeq_1 , max ) ; <nl> + { size_t const NCountSize = FSE_writeNCount ( op , oend - op , norm , max , tableLog ) ; / * overflow protected * / <nl> + if ( FSE_isError ( NCountSize ) ) return NCountSize ; <nl> + op + = NCountSize ; } <nl> + FSE_buildCTable_wksp ( CTable_OffsetBits , norm , max , tableLog , scratchBuffer , sizeof ( scratchBuffer ) ) ; <nl> + Offtype = set_compressed ; <nl> + } } <nl> + <nl> + / * CTable for MatchLengths * / <nl> + { U32 max = MaxML ; <nl> + size_t const mostFrequent = FSE_countFast_wksp ( count , & max , mlCodeTable , nbSeq , zc - > entropyScratchSpace ) ; <nl> + if ( ( mostFrequent = = nbSeq ) & & ( nbSeq > 2 ) ) { <nl> + * op + + = * mlCodeTable ; <nl> + FSE_buildCTable_rle ( CTable_MatchLength , ( BYTE ) max ) ; <nl> + MLtype = set_rle ; <nl> + } else if ( ( zc - > fseCTables_ready ) & & ( nbSeq < MAX_SEQ_FOR_STATIC_FSE ) ) { <nl> + MLtype = set_repeat ; <nl> + } else if ( ( nbSeq < MIN_SEQ_FOR_DYNAMIC_FSE ) | | ( mostFrequent < ( nbSeq > > ( ML_defaultNormLog - 1 ) ) ) ) { <nl> + FSE_buildCTable_wksp ( CTable_MatchLength , ML_defaultNorm , MaxML , ML_defaultNormLog , scratchBuffer , sizeof ( scratchBuffer ) ) ; <nl> + MLtype = set_basic ; <nl> + } else { <nl> + size_t nbSeq_1 = nbSeq ; <nl> + const U32 tableLog = FSE_optimalTableLog ( MLFSELog , nbSeq , max ) ; <nl> + if ( count [ mlCodeTable [ nbSeq - 1 ] ] > 1 ) { count [ mlCodeTable [ nbSeq - 1 ] ] - - ; nbSeq_1 - - ; } <nl> + FSE_normalizeCount ( norm , tableLog , count , nbSeq_1 , max ) ; <nl> + { size_t const NCountSize = FSE_writeNCount ( op , oend - op , norm , max , tableLog ) ; / * overflow protected * / <nl> + if ( FSE_isError ( NCountSize ) ) return NCountSize ; <nl> + op + = NCountSize ; } <nl> + FSE_buildCTable_wksp ( CTable_MatchLength , norm , max , tableLog , scratchBuffer , sizeof ( scratchBuffer ) ) ; <nl> + MLtype = set_compressed ; <nl> + } } <nl> + <nl> + * seqHead = ( BYTE ) ( ( LLtype < < 6 ) + ( Offtype < < 4 ) + ( MLtype < < 2 ) ) ; <nl> + zc - > fseCTables_ready = 0 ; <nl> + <nl> + / * Encoding Sequences * / <nl> + { BIT_CStream_t blockStream ; <nl> + FSE_CState_t stateMatchLength ; <nl> + FSE_CState_t stateOffsetBits ; <nl> + FSE_CState_t stateLitLength ; <nl> + <nl> + CHECK_E ( BIT_initCStream ( & blockStream , op , oend - op ) , dstSize_tooSmall ) ; / * not enough space remaining * / <nl> + <nl> + / * first symbols * / <nl> + FSE_initCState2 ( & stateMatchLength , CTable_MatchLength , mlCodeTable [ nbSeq - 1 ] ) ; <nl> + FSE_initCState2 ( & stateOffsetBits , CTable_OffsetBits , ofCodeTable [ nbSeq - 1 ] ) ; <nl> + FSE_initCState2 ( & stateLitLength , CTable_LitLength , llCodeTable [ nbSeq - 1 ] ) ; <nl> + BIT_addBits ( & blockStream , sequences [ nbSeq - 1 ] . litLength , LL_bits [ llCodeTable [ nbSeq - 1 ] ] ) ; <nl> + if ( MEM_32bits ( ) ) BIT_flushBits ( & blockStream ) ; <nl> + BIT_addBits ( & blockStream , sequences [ nbSeq - 1 ] . matchLength , ML_bits [ mlCodeTable [ nbSeq - 1 ] ] ) ; <nl> + if ( MEM_32bits ( ) ) BIT_flushBits ( & blockStream ) ; <nl> + if ( longOffsets ) { <nl> + U32 const ofBits = ofCodeTable [ nbSeq - 1 ] ; <nl> + int const extraBits = ofBits - MIN ( ofBits , STREAM_ACCUMULATOR_MIN - 1 ) ; <nl> + if ( extraBits ) { <nl> + BIT_addBits ( & blockStream , sequences [ nbSeq - 1 ] . offset , extraBits ) ; <nl> + BIT_flushBits ( & blockStream ) ; <nl> + } <nl> + BIT_addBits ( & blockStream , sequences [ nbSeq - 1 ] . offset > > extraBits , <nl> + ofBits - extraBits ) ; <nl> + } else { <nl> + BIT_addBits ( & blockStream , sequences [ nbSeq - 1 ] . offset , ofCodeTable [ nbSeq - 1 ] ) ; <nl> + } <nl> + BIT_flushBits ( & blockStream ) ; <nl> + <nl> + { size_t n ; <nl> + for ( n = nbSeq - 2 ; n < nbSeq ; n - - ) { / * intentional underflow * / <nl> + BYTE const llCode = llCodeTable [ n ] ; <nl> + BYTE const ofCode = ofCodeTable [ n ] ; <nl> + BYTE const mlCode = mlCodeTable [ n ] ; <nl> + U32 const llBits = LL_bits [ llCode ] ; <nl> + U32 const ofBits = ofCode ; / * 32b * / / * 64b * / <nl> + U32 const mlBits = ML_bits [ mlCode ] ; <nl> + / * ( 7 ) * / / * ( 7 ) * / <nl> + FSE_encodeSymbol ( & blockStream , & stateOffsetBits , ofCode ) ; / * 15 * / / * 15 * / <nl> + FSE_encodeSymbol ( & blockStream , & stateMatchLength , mlCode ) ; / * 24 * / / * 24 * / <nl> + if ( MEM_32bits ( ) ) BIT_flushBits ( & blockStream ) ; / * ( 7 ) * / <nl> + FSE_encodeSymbol ( & blockStream , & stateLitLength , llCode ) ; / * 16 * / / * 33 * / <nl> + if ( MEM_32bits ( ) | | ( ofBits + mlBits + llBits > = 64 - 7 - ( LLFSELog + MLFSELog + OffFSELog ) ) ) <nl> + BIT_flushBits ( & blockStream ) ; / * ( 7 ) * / <nl> + BIT_addBits ( & blockStream , sequences [ n ] . litLength , llBits ) ; <nl> + if ( MEM_32bits ( ) & & ( ( llBits + mlBits ) > 24 ) ) BIT_flushBits ( & blockStream ) ; <nl> + BIT_addBits ( & blockStream , sequences [ n ] . matchLength , mlBits ) ; <nl> + if ( MEM_32bits ( ) ) BIT_flushBits ( & blockStream ) ; / * ( 7 ) * / <nl> + if ( longOffsets ) { <nl> + int const extraBits = ofBits - MIN ( ofBits , STREAM_ACCUMULATOR_MIN - 1 ) ; <nl> + if ( extraBits ) { <nl> + BIT_addBits ( & blockStream , sequences [ n ] . offset , extraBits ) ; <nl> + BIT_flushBits ( & blockStream ) ; / * ( 7 ) * / <nl> + } <nl> + BIT_addBits ( & blockStream , sequences [ n ] . offset > > extraBits , <nl> + ofBits - extraBits ) ; / * 31 * / <nl> + } else { <nl> + BIT_addBits ( & blockStream , sequences [ n ] . offset , ofBits ) ; / * 31 * / <nl> + } <nl> + BIT_flushBits ( & blockStream ) ; / * ( 7 ) * / <nl> + } } <nl> + <nl> + FSE_flushCState ( & blockStream , & stateMatchLength ) ; <nl> + FSE_flushCState ( & blockStream , & stateOffsetBits ) ; <nl> + FSE_flushCState ( & blockStream , & stateLitLength ) ; <nl> + <nl> + { size_t const streamSize = BIT_closeCStream ( & blockStream ) ; <nl> + if ( streamSize = = 0 ) return ERROR ( dstSize_tooSmall ) ; / * not enough space * / <nl> + op + = streamSize ; <nl> + } } <nl> + <nl> + / * check compressibility * / <nl> + _check_compressibility : <nl> + { size_t const minGain = ZSTD_minGain ( srcSize ) ; <nl> + size_t const maxCSize = srcSize - minGain ; <nl> + if ( ( size_t ) ( op - ostart ) > = maxCSize ) { <nl> + zc - > hufCTable_repeatMode = HUF_repeat_none ; <nl> + return 0 ; <nl> + } } <nl> + <nl> + / * confirm repcodes * / <nl> + { int i ; for ( i = 0 ; i < ZSTD_REP_NUM ; i + + ) zc - > rep [ i ] = zc - > repToConfirm [ i ] ; } <nl> + <nl> + return op - ostart ; <nl> + } <nl> + <nl> + # if 0 / * for debug * / <nl> + # define STORESEQ_DEBUG <nl> + # include < stdio . h > / * fprintf * / <nl> + U32 g_startDebug = 0 ; <nl> + const BYTE * g_start = NULL ; <nl> + # endif <nl> + <nl> + / * ! ZSTD_storeSeq ( ) : <nl> + Store a sequence ( literal length , literals , offset code and match length code ) into seqStore_t . <nl> + ` offsetCode ` : distance to match , or 0 = = repCode . <nl> + ` matchCode ` : matchLength - MINMATCH <nl> + * / <nl> + MEM_STATIC void ZSTD_storeSeq ( seqStore_t * seqStorePtr , size_t litLength , const void * literals , U32 offsetCode , size_t matchCode ) <nl> + { <nl> + # ifdef STORESEQ_DEBUG <nl> + if ( g_startDebug ) { <nl> + const U32 pos = ( U32 ) ( ( const BYTE * ) literals - g_start ) ; <nl> + if ( g_start = = NULL ) g_start = ( const BYTE * ) literals ; <nl> + if ( ( pos > 1895000 ) & & ( pos < 1895300 ) ) <nl> + DEBUGLOG ( 5 , " Cpos % 6u : % 5u literals & match % 3u bytes at distance % 6u \ n " , <nl> + pos , ( U32 ) litLength , ( U32 ) matchCode + MINMATCH , ( U32 ) offsetCode ) ; <nl> + } <nl> + # endif <nl> + / * copy Literals * / <nl> + ZSTD_wildcopy ( seqStorePtr - > lit , literals , litLength ) ; <nl> + seqStorePtr - > lit + = litLength ; <nl> + <nl> + / * literal Length * / <nl> + if ( litLength > 0xFFFF ) { <nl> + seqStorePtr - > longLengthID = 1 ; <nl> + seqStorePtr - > longLengthPos = ( U32 ) ( seqStorePtr - > sequences - seqStorePtr - > sequencesStart ) ; <nl> + } <nl> + seqStorePtr - > sequences [ 0 ] . litLength = ( U16 ) litLength ; <nl> + <nl> + / * match offset * / <nl> + seqStorePtr - > sequences [ 0 ] . offset = offsetCode + 1 ; <nl> + <nl> + / * match Length * / <nl> + if ( matchCode > 0xFFFF ) { <nl> + seqStorePtr - > longLengthID = 2 ; <nl> + seqStorePtr - > longLengthPos = ( U32 ) ( seqStorePtr - > sequences - seqStorePtr - > sequencesStart ) ; <nl> + } <nl> + seqStorePtr - > sequences [ 0 ] . matchLength = ( U16 ) matchCode ; <nl> + <nl> + seqStorePtr - > sequences + + ; <nl> + } <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Match length counter <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + static unsigned ZSTD_NbCommonBytes ( register size_t val ) <nl> + { <nl> + if ( MEM_isLittleEndian ( ) ) { <nl> + if ( MEM_64bits ( ) ) { <nl> + # if defined ( _MSC_VER ) & & defined ( _WIN64 ) <nl> + unsigned long r = 0 ; <nl> + _BitScanForward64 ( & r , ( U64 ) val ) ; <nl> + return ( unsigned ) ( r > > 3 ) ; <nl> + # elif defined ( __GNUC__ ) & & ( __GNUC__ > = 3 ) <nl> + return ( __builtin_ctzll ( ( U64 ) val ) > > 3 ) ; <nl> + # else <nl> + static const int DeBruijnBytePos [ 64 ] = { 0 , 0 , 0 , 0 , 0 , 1 , 1 , 2 , <nl> + 0 , 3 , 1 , 3 , 1 , 4 , 2 , 7 , <nl> + 0 , 2 , 3 , 6 , 1 , 5 , 3 , 5 , <nl> + 1 , 3 , 4 , 4 , 2 , 5 , 6 , 7 , <nl> + 7 , 0 , 1 , 2 , 3 , 3 , 4 , 6 , <nl> + 2 , 6 , 5 , 5 , 3 , 4 , 5 , 6 , <nl> + 7 , 1 , 2 , 4 , 6 , 4 , 4 , 5 , <nl> + 7 , 2 , 6 , 5 , 7 , 6 , 7 , 7 } ; <nl> + return DeBruijnBytePos [ ( ( U64 ) ( ( val & - ( long long ) val ) * 0x0218A392CDABBD3FULL ) ) > > 58 ] ; <nl> + # endif <nl> + } else { / * 32 bits * / <nl> + # if defined ( _MSC_VER ) <nl> + unsigned long r = 0 ; <nl> + _BitScanForward ( & r , ( U32 ) val ) ; <nl> + return ( unsigned ) ( r > > 3 ) ; <nl> + # elif defined ( __GNUC__ ) & & ( __GNUC__ > = 3 ) <nl> + return ( __builtin_ctz ( ( U32 ) val ) > > 3 ) ; <nl> + # else <nl> + static const int DeBruijnBytePos [ 32 ] = { 0 , 0 , 3 , 0 , 3 , 1 , 3 , 0 , <nl> + 3 , 2 , 2 , 1 , 3 , 2 , 0 , 1 , <nl> + 3 , 3 , 1 , 2 , 2 , 2 , 2 , 0 , <nl> + 3 , 1 , 2 , 0 , 1 , 0 , 1 , 1 } ; <nl> + return DeBruijnBytePos [ ( ( U32 ) ( ( val & - ( S32 ) val ) * 0x077CB531U ) ) > > 27 ] ; <nl> + # endif <nl> + } <nl> + } else { / * Big Endian CPU * / <nl> + if ( MEM_64bits ( ) ) { <nl> + # if defined ( _MSC_VER ) & & defined ( _WIN64 ) <nl> + unsigned long r = 0 ; <nl> + _BitScanReverse64 ( & r , val ) ; <nl> + return ( unsigned ) ( r > > 3 ) ; <nl> + # elif defined ( __GNUC__ ) & & ( __GNUC__ > = 3 ) <nl> + return ( __builtin_clzll ( val ) > > 3 ) ; <nl> + # else <nl> + unsigned r ; <nl> + const unsigned n32 = sizeof ( size_t ) * 4 ; / * calculate this way due to compiler complaining in 32 - bits mode * / <nl> + if ( ! ( val > > n32 ) ) { r = 4 ; } else { r = 0 ; val > > = n32 ; } <nl> + if ( ! ( val > > 16 ) ) { r + = 2 ; val > > = 8 ; } else { val > > = 24 ; } <nl> + r + = ( ! val ) ; <nl> + return r ; <nl> + # endif <nl> + } else { / * 32 bits * / <nl> + # if defined ( _MSC_VER ) <nl> + unsigned long r = 0 ; <nl> + _BitScanReverse ( & r , ( unsigned long ) val ) ; <nl> + return ( unsigned ) ( r > > 3 ) ; <nl> + # elif defined ( __GNUC__ ) & & ( __GNUC__ > = 3 ) <nl> + return ( __builtin_clz ( ( U32 ) val ) > > 3 ) ; <nl> + # else <nl> + unsigned r ; <nl> + if ( ! ( val > > 16 ) ) { r = 2 ; val > > = 8 ; } else { r = 0 ; val > > = 24 ; } <nl> + r + = ( ! val ) ; <nl> + return r ; <nl> + # endif <nl> + } } <nl> + } <nl> + <nl> + <nl> + static size_t ZSTD_count ( const BYTE * pIn , const BYTE * pMatch , const BYTE * const pInLimit ) <nl> + { <nl> + const BYTE * const pStart = pIn ; <nl> + const BYTE * const pInLoopLimit = pInLimit - ( sizeof ( size_t ) - 1 ) ; <nl> + <nl> + while ( pIn < pInLoopLimit ) { <nl> + size_t const diff = MEM_readST ( pMatch ) ^ MEM_readST ( pIn ) ; <nl> + if ( ! diff ) { pIn + = sizeof ( size_t ) ; pMatch + = sizeof ( size_t ) ; continue ; } <nl> + pIn + = ZSTD_NbCommonBytes ( diff ) ; <nl> + return ( size_t ) ( pIn - pStart ) ; <nl> + } <nl> + if ( MEM_64bits ( ) ) if ( ( pIn < ( pInLimit - 3 ) ) & & ( MEM_read32 ( pMatch ) = = MEM_read32 ( pIn ) ) ) { pIn + = 4 ; pMatch + = 4 ; } <nl> + if ( ( pIn < ( pInLimit - 1 ) ) & & ( MEM_read16 ( pMatch ) = = MEM_read16 ( pIn ) ) ) { pIn + = 2 ; pMatch + = 2 ; } <nl> + if ( ( pIn < pInLimit ) & & ( * pMatch = = * pIn ) ) pIn + + ; <nl> + return ( size_t ) ( pIn - pStart ) ; <nl> + } <nl> + <nl> + / * * ZSTD_count_2segments ( ) : <nl> + * can count match length with ` ip ` & ` match ` in 2 different segments . <nl> + * convention : on reaching mEnd , match count continue starting from iStart <nl> + * / <nl> + static size_t ZSTD_count_2segments ( const BYTE * ip , const BYTE * match , const BYTE * iEnd , const BYTE * mEnd , const BYTE * iStart ) <nl> + { <nl> + const BYTE * const vEnd = MIN ( ip + ( mEnd - match ) , iEnd ) ; <nl> + size_t const matchLength = ZSTD_count ( ip , match , vEnd ) ; <nl> + if ( match + matchLength ! = mEnd ) return matchLength ; <nl> + return matchLength + ZSTD_count ( ip + matchLength , iStart , iEnd ) ; <nl> + } <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Hashes <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + static const U32 prime3bytes = 506832829U ; <nl> + static U32 ZSTD_hash3 ( U32 u , U32 h ) { return ( ( u < < ( 32 - 24 ) ) * prime3bytes ) > > ( 32 - h ) ; } <nl> + MEM_STATIC size_t ZSTD_hash3Ptr ( const void * ptr , U32 h ) { return ZSTD_hash3 ( MEM_readLE32 ( ptr ) , h ) ; } / * only in zstd_opt . h * / <nl> + <nl> + static const U32 prime4bytes = 2654435761U ; <nl> + static U32 ZSTD_hash4 ( U32 u , U32 h ) { return ( u * prime4bytes ) > > ( 32 - h ) ; } <nl> + static size_t ZSTD_hash4Ptr ( const void * ptr , U32 h ) { return ZSTD_hash4 ( MEM_read32 ( ptr ) , h ) ; } <nl> + <nl> + static const U64 prime5bytes = 889523592379ULL ; <nl> + static size_t ZSTD_hash5 ( U64 u , U32 h ) { return ( size_t ) ( ( ( u < < ( 64 - 40 ) ) * prime5bytes ) > > ( 64 - h ) ) ; } <nl> + static size_t ZSTD_hash5Ptr ( const void * p , U32 h ) { return ZSTD_hash5 ( MEM_readLE64 ( p ) , h ) ; } <nl> + <nl> + static const U64 prime6bytes = 227718039650203ULL ; <nl> + static size_t ZSTD_hash6 ( U64 u , U32 h ) { return ( size_t ) ( ( ( u < < ( 64 - 48 ) ) * prime6bytes ) > > ( 64 - h ) ) ; } <nl> + static size_t ZSTD_hash6Ptr ( const void * p , U32 h ) { return ZSTD_hash6 ( MEM_readLE64 ( p ) , h ) ; } <nl> + <nl> + static const U64 prime7bytes = 58295818150454627ULL ; <nl> + static size_t ZSTD_hash7 ( U64 u , U32 h ) { return ( size_t ) ( ( ( u < < ( 64 - 56 ) ) * prime7bytes ) > > ( 64 - h ) ) ; } <nl> + static size_t ZSTD_hash7Ptr ( const void * p , U32 h ) { return ZSTD_hash7 ( MEM_readLE64 ( p ) , h ) ; } <nl> + <nl> + static const U64 prime8bytes = 0xCF1BBCDCB7A56463ULL ; <nl> + static size_t ZSTD_hash8 ( U64 u , U32 h ) { return ( size_t ) ( ( ( u ) * prime8bytes ) > > ( 64 - h ) ) ; } <nl> + static size_t ZSTD_hash8Ptr ( const void * p , U32 h ) { return ZSTD_hash8 ( MEM_readLE64 ( p ) , h ) ; } <nl> + <nl> + static size_t ZSTD_hashPtr ( const void * p , U32 hBits , U32 mls ) <nl> + { <nl> + switch ( mls ) <nl> + { <nl> + default : <nl> + case 4 : return ZSTD_hash4Ptr ( p , hBits ) ; <nl> + case 5 : return ZSTD_hash5Ptr ( p , hBits ) ; <nl> + case 6 : return ZSTD_hash6Ptr ( p , hBits ) ; <nl> + case 7 : return ZSTD_hash7Ptr ( p , hBits ) ; <nl> + case 8 : return ZSTD_hash8Ptr ( p , hBits ) ; <nl> + } <nl> + } <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Fast Scan <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + static void ZSTD_fillHashTable ( ZSTD_CCtx * zc , const void * end , const U32 mls ) <nl> + { <nl> + U32 * const hashTable = zc - > hashTable ; <nl> + U32 const hBits = zc - > params . cParams . hashLog ; <nl> + const BYTE * const base = zc - > base ; <nl> + const BYTE * ip = base + zc - > nextToUpdate ; <nl> + const BYTE * const iend = ( ( const BYTE * ) end ) - HASH_READ_SIZE ; <nl> + const size_t fastHashFillStep = 3 ; <nl> + <nl> + while ( ip < = iend ) { <nl> + hashTable [ ZSTD_hashPtr ( ip , hBits , mls ) ] = ( U32 ) ( ip - base ) ; <nl> + ip + = fastHashFillStep ; <nl> + } <nl> + } <nl> + <nl> + <nl> + FORCE_INLINE <nl> + void ZSTD_compressBlock_fast_generic ( ZSTD_CCtx * cctx , <nl> + const void * src , size_t srcSize , <nl> + const U32 mls ) <nl> + { <nl> + U32 * const hashTable = cctx - > hashTable ; <nl> + U32 const hBits = cctx - > params . cParams . hashLog ; <nl> + seqStore_t * seqStorePtr = & ( cctx - > seqStore ) ; <nl> + const BYTE * const base = cctx - > base ; <nl> + const BYTE * const istart = ( const BYTE * ) src ; <nl> + const BYTE * ip = istart ; <nl> + const BYTE * anchor = istart ; <nl> + const U32 lowestIndex = cctx - > dictLimit ; <nl> + const BYTE * const lowest = base + lowestIndex ; <nl> + const BYTE * const iend = istart + srcSize ; <nl> + const BYTE * const ilimit = iend - HASH_READ_SIZE ; <nl> + U32 offset_1 = cctx - > rep [ 0 ] , offset_2 = cctx - > rep [ 1 ] ; <nl> + U32 offsetSaved = 0 ; <nl> + <nl> + / * init * / <nl> + ip + = ( ip = = lowest ) ; <nl> + { U32 const maxRep = ( U32 ) ( ip - lowest ) ; <nl> + if ( offset_2 > maxRep ) offsetSaved = offset_2 , offset_2 = 0 ; <nl> + if ( offset_1 > maxRep ) offsetSaved = offset_1 , offset_1 = 0 ; <nl> + } <nl> + <nl> + / * Main Search Loop * / <nl> + while ( ip < ilimit ) { / * < instead of < = , because repcode check at ( ip + 1 ) * / <nl> + size_t mLength ; <nl> + size_t const h = ZSTD_hashPtr ( ip , hBits , mls ) ; <nl> + U32 const current = ( U32 ) ( ip - base ) ; <nl> + U32 const matchIndex = hashTable [ h ] ; <nl> + const BYTE * match = base + matchIndex ; <nl> + hashTable [ h ] = current ; / * update hash table * / <nl> + <nl> + if ( ( offset_1 > 0 ) & ( MEM_read32 ( ip + 1 - offset_1 ) = = MEM_read32 ( ip + 1 ) ) ) { <nl> + mLength = ZSTD_count ( ip + 1 + 4 , ip + 1 + 4 - offset_1 , iend ) + 4 ; <nl> + ip + + ; <nl> + ZSTD_storeSeq ( seqStorePtr , ip - anchor , anchor , 0 , mLength - MINMATCH ) ; <nl> + } else { <nl> + U32 offset ; <nl> + if ( ( matchIndex < = lowestIndex ) | | ( MEM_read32 ( match ) ! = MEM_read32 ( ip ) ) ) { <nl> + ip + = ( ( ip - anchor ) > > g_searchStrength ) + 1 ; <nl> + continue ; <nl> + } <nl> + mLength = ZSTD_count ( ip + 4 , match + 4 , iend ) + 4 ; <nl> + offset = ( U32 ) ( ip - match ) ; <nl> + while ( ( ( ip > anchor ) & ( match > lowest ) ) & & ( ip [ - 1 ] = = match [ - 1 ] ) ) { ip - - ; match - - ; mLength + + ; } / * catch up * / <nl> + offset_2 = offset_1 ; <nl> + offset_1 = offset ; <nl> + <nl> + ZSTD_storeSeq ( seqStorePtr , ip - anchor , anchor , offset + ZSTD_REP_MOVE , mLength - MINMATCH ) ; <nl> + } <nl> + <nl> + / * match found * / <nl> + ip + = mLength ; <nl> + anchor = ip ; <nl> + <nl> + if ( ip < = ilimit ) { <nl> + / * Fill Table * / <nl> + hashTable [ ZSTD_hashPtr ( base + current + 2 , hBits , mls ) ] = current + 2 ; / * here because current + 2 could be > iend - 8 * / <nl> + hashTable [ ZSTD_hashPtr ( ip - 2 , hBits , mls ) ] = ( U32 ) ( ip - 2 - base ) ; <nl> + / * check immediate repcode * / <nl> + while ( ( ip < = ilimit ) <nl> + & & ( ( offset_2 > 0 ) <nl> + & ( MEM_read32 ( ip ) = = MEM_read32 ( ip - offset_2 ) ) ) ) { <nl> + / * store sequence * / <nl> + size_t const rLength = ZSTD_count ( ip + 4 , ip + 4 - offset_2 , iend ) + 4 ; <nl> + { U32 const tmpOff = offset_2 ; offset_2 = offset_1 ; offset_1 = tmpOff ; } / * swap offset_2 < = > offset_1 * / <nl> + hashTable [ ZSTD_hashPtr ( ip , hBits , mls ) ] = ( U32 ) ( ip - base ) ; <nl> + ZSTD_storeSeq ( seqStorePtr , 0 , anchor , 0 , rLength - MINMATCH ) ; <nl> + ip + = rLength ; <nl> + anchor = ip ; <nl> + continue ; / * faster when present . . . ( ? ) * / <nl> + } } } <nl> + <nl> + / * save reps for next block * / <nl> + cctx - > repToConfirm [ 0 ] = offset_1 ? offset_1 : offsetSaved ; <nl> + cctx - > repToConfirm [ 1 ] = offset_2 ? offset_2 : offsetSaved ; <nl> + <nl> + / * Last Literals * / <nl> + { size_t const lastLLSize = iend - anchor ; <nl> + memcpy ( seqStorePtr - > lit , anchor , lastLLSize ) ; <nl> + seqStorePtr - > lit + = lastLLSize ; <nl> + } <nl> + } <nl> + <nl> + <nl> + static void ZSTD_compressBlock_fast ( ZSTD_CCtx * ctx , <nl> + const void * src , size_t srcSize ) <nl> + { <nl> + const U32 mls = ctx - > params . cParams . searchLength ; <nl> + switch ( mls ) <nl> + { <nl> + default : / * includes case 3 * / <nl> + case 4 : <nl> + ZSTD_compressBlock_fast_generic ( ctx , src , srcSize , 4 ) ; return ; <nl> + case 5 : <nl> + ZSTD_compressBlock_fast_generic ( ctx , src , srcSize , 5 ) ; return ; <nl> + case 6 : <nl> + ZSTD_compressBlock_fast_generic ( ctx , src , srcSize , 6 ) ; return ; <nl> + case 7 : <nl> + ZSTD_compressBlock_fast_generic ( ctx , src , srcSize , 7 ) ; return ; <nl> + } <nl> + } <nl> + <nl> + <nl> + static void ZSTD_compressBlock_fast_extDict_generic ( ZSTD_CCtx * ctx , <nl> + const void * src , size_t srcSize , <nl> + const U32 mls ) <nl> + { <nl> + U32 * hashTable = ctx - > hashTable ; <nl> + const U32 hBits = ctx - > params . cParams . hashLog ; <nl> + seqStore_t * seqStorePtr = & ( ctx - > seqStore ) ; <nl> + const BYTE * const base = ctx - > base ; <nl> + const BYTE * const dictBase = ctx - > dictBase ; <nl> + const BYTE * const istart = ( const BYTE * ) src ; <nl> + const BYTE * ip = istart ; <nl> + const BYTE * anchor = istart ; <nl> + const U32 lowestIndex = ctx - > lowLimit ; <nl> + const BYTE * const dictStart = dictBase + lowestIndex ; <nl> + const U32 dictLimit = ctx - > dictLimit ; <nl> + const BYTE * const lowPrefixPtr = base + dictLimit ; <nl> + const BYTE * const dictEnd = dictBase + dictLimit ; <nl> + const BYTE * const iend = istart + srcSize ; <nl> + const BYTE * const ilimit = iend - 8 ; <nl> + U32 offset_1 = ctx - > rep [ 0 ] , offset_2 = ctx - > rep [ 1 ] ; <nl> + <nl> + / * Search Loop * / <nl> + while ( ip < ilimit ) { / * < instead of < = , because ( ip + 1 ) * / <nl> + const size_t h = ZSTD_hashPtr ( ip , hBits , mls ) ; <nl> + const U32 matchIndex = hashTable [ h ] ; <nl> + const BYTE * matchBase = matchIndex < dictLimit ? dictBase : base ; <nl> + const BYTE * match = matchBase + matchIndex ; <nl> + const U32 current = ( U32 ) ( ip - base ) ; <nl> + const U32 repIndex = current + 1 - offset_1 ; / * offset_1 expected < = current + 1 * / <nl> + const BYTE * repBase = repIndex < dictLimit ? dictBase : base ; <nl> + const BYTE * repMatch = repBase + repIndex ; <nl> + size_t mLength ; <nl> + hashTable [ h ] = current ; / * update hash table * / <nl> + <nl> + if ( ( ( ( U32 ) ( ( dictLimit - 1 ) - repIndex ) > = 3 ) / * intentional underflow * / & ( repIndex > lowestIndex ) ) <nl> + & & ( MEM_read32 ( repMatch ) = = MEM_read32 ( ip + 1 ) ) ) { <nl> + const BYTE * repMatchEnd = repIndex < dictLimit ? dictEnd : iend ; <nl> + mLength = ZSTD_count_2segments ( ip + 1 + 4 , repMatch + 4 , iend , repMatchEnd , lowPrefixPtr ) + 4 ; <nl> + ip + + ; <nl> + ZSTD_storeSeq ( seqStorePtr , ip - anchor , anchor , 0 , mLength - MINMATCH ) ; <nl> + } else { <nl> + if ( ( matchIndex < lowestIndex ) | | <nl> + ( MEM_read32 ( match ) ! = MEM_read32 ( ip ) ) ) { <nl> + ip + = ( ( ip - anchor ) > > g_searchStrength ) + 1 ; <nl> + continue ; <nl> + } <nl> + { const BYTE * matchEnd = matchIndex < dictLimit ? dictEnd : iend ; <nl> + const BYTE * lowMatchPtr = matchIndex < dictLimit ? dictStart : lowPrefixPtr ; <nl> + U32 offset ; <nl> + mLength = ZSTD_count_2segments ( ip + 4 , match + 4 , iend , matchEnd , lowPrefixPtr ) + 4 ; <nl> + while ( ( ( ip > anchor ) & ( match > lowMatchPtr ) ) & & ( ip [ - 1 ] = = match [ - 1 ] ) ) { ip - - ; match - - ; mLength + + ; } / * catch up * / <nl> + offset = current - matchIndex ; <nl> + offset_2 = offset_1 ; <nl> + offset_1 = offset ; <nl> + ZSTD_storeSeq ( seqStorePtr , ip - anchor , anchor , offset + ZSTD_REP_MOVE , mLength - MINMATCH ) ; <nl> + } } <nl> + <nl> + / * found a match : store it * / <nl> + ip + = mLength ; <nl> + anchor = ip ; <nl> + <nl> + if ( ip < = ilimit ) { <nl> + / * Fill Table * / <nl> + hashTable [ ZSTD_hashPtr ( base + current + 2 , hBits , mls ) ] = current + 2 ; <nl> + hashTable [ ZSTD_hashPtr ( ip - 2 , hBits , mls ) ] = ( U32 ) ( ip - 2 - base ) ; <nl> + / * check immediate repcode * / <nl> + while ( ip < = ilimit ) { <nl> + U32 const current2 = ( U32 ) ( ip - base ) ; <nl> + U32 const repIndex2 = current2 - offset_2 ; <nl> + const BYTE * repMatch2 = repIndex2 < dictLimit ? dictBase + repIndex2 : base + repIndex2 ; <nl> + if ( ( ( ( U32 ) ( ( dictLimit - 1 ) - repIndex2 ) > = 3 ) & ( repIndex2 > lowestIndex ) ) / * intentional overflow * / <nl> + & & ( MEM_read32 ( repMatch2 ) = = MEM_read32 ( ip ) ) ) { <nl> + const BYTE * const repEnd2 = repIndex2 < dictLimit ? dictEnd : iend ; <nl> + size_t const repLength2 = ZSTD_count_2segments ( ip + 4 , repMatch2 + 4 , iend , repEnd2 , lowPrefixPtr ) + 4 ; <nl> + U32 tmpOffset = offset_2 ; offset_2 = offset_1 ; offset_1 = tmpOffset ; / * swap offset_2 < = > offset_1 * / <nl> + ZSTD_storeSeq ( seqStorePtr , 0 , anchor , 0 , repLength2 - MINMATCH ) ; <nl> + hashTable [ ZSTD_hashPtr ( ip , hBits , mls ) ] = current2 ; <nl> + ip + = repLength2 ; <nl> + anchor = ip ; <nl> + continue ; <nl> + } <nl> + break ; <nl> + } } } <nl> + <nl> + / * save reps for next block * / <nl> + ctx - > repToConfirm [ 0 ] = offset_1 ; ctx - > repToConfirm [ 1 ] = offset_2 ; <nl> + <nl> + / * Last Literals * / <nl> + { size_t const lastLLSize = iend - anchor ; <nl> + memcpy ( seqStorePtr - > lit , anchor , lastLLSize ) ; <nl> + seqStorePtr - > lit + = lastLLSize ; <nl> + } <nl> + } <nl> + <nl> + <nl> + static void ZSTD_compressBlock_fast_extDict ( ZSTD_CCtx * ctx , <nl> + const void * src , size_t srcSize ) <nl> + { <nl> + U32 const mls = ctx - > params . cParams . searchLength ; <nl> + switch ( mls ) <nl> + { <nl> + default : / * includes case 3 * / <nl> + case 4 : <nl> + ZSTD_compressBlock_fast_extDict_generic ( ctx , src , srcSize , 4 ) ; return ; <nl> + case 5 : <nl> + ZSTD_compressBlock_fast_extDict_generic ( ctx , src , srcSize , 5 ) ; return ; <nl> + case 6 : <nl> + ZSTD_compressBlock_fast_extDict_generic ( ctx , src , srcSize , 6 ) ; return ; <nl> + case 7 : <nl> + ZSTD_compressBlock_fast_extDict_generic ( ctx , src , srcSize , 7 ) ; return ; <nl> + } <nl> + } <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Double Fast <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + static void ZSTD_fillDoubleHashTable ( ZSTD_CCtx * cctx , const void * end , const U32 mls ) <nl> + { <nl> + U32 * const hashLarge = cctx - > hashTable ; <nl> + U32 const hBitsL = cctx - > params . cParams . hashLog ; <nl> + U32 * const hashSmall = cctx - > chainTable ; <nl> + U32 const hBitsS = cctx - > params . cParams . chainLog ; <nl> + const BYTE * const base = cctx - > base ; <nl> + const BYTE * ip = base + cctx - > nextToUpdate ; <nl> + const BYTE * const iend = ( ( const BYTE * ) end ) - HASH_READ_SIZE ; <nl> + const size_t fastHashFillStep = 3 ; <nl> + <nl> + while ( ip < = iend ) { <nl> + hashSmall [ ZSTD_hashPtr ( ip , hBitsS , mls ) ] = ( U32 ) ( ip - base ) ; <nl> + hashLarge [ ZSTD_hashPtr ( ip , hBitsL , 8 ) ] = ( U32 ) ( ip - base ) ; <nl> + ip + = fastHashFillStep ; <nl> + } <nl> + } <nl> + <nl> + <nl> + FORCE_INLINE <nl> + void ZSTD_compressBlock_doubleFast_generic ( ZSTD_CCtx * cctx , <nl> + const void * src , size_t srcSize , <nl> + const U32 mls ) <nl> + { <nl> + U32 * const hashLong = cctx - > hashTable ; <nl> + const U32 hBitsL = cctx - > params . cParams . hashLog ; <nl> + U32 * const hashSmall = cctx - > chainTable ; <nl> + const U32 hBitsS = cctx - > params . cParams . chainLog ; <nl> + seqStore_t * seqStorePtr = & ( cctx - > seqStore ) ; <nl> + const BYTE * const base = cctx - > base ; <nl> + const BYTE * const istart = ( const BYTE * ) src ; <nl> + const BYTE * ip = istart ; <nl> + const BYTE * anchor = istart ; <nl> + const U32 lowestIndex = cctx - > dictLimit ; <nl> + const BYTE * const lowest = base + lowestIndex ; <nl> + const BYTE * const iend = istart + srcSize ; <nl> + const BYTE * const ilimit = iend - HASH_READ_SIZE ; <nl> + U32 offset_1 = cctx - > rep [ 0 ] , offset_2 = cctx - > rep [ 1 ] ; <nl> + U32 offsetSaved = 0 ; <nl> + <nl> + / * init * / <nl> + ip + = ( ip = = lowest ) ; <nl> + { U32 const maxRep = ( U32 ) ( ip - lowest ) ; <nl> + if ( offset_2 > maxRep ) offsetSaved = offset_2 , offset_2 = 0 ; <nl> + if ( offset_1 > maxRep ) offsetSaved = offset_1 , offset_1 = 0 ; <nl> + } <nl> + <nl> + / * Main Search Loop * / <nl> + while ( ip < ilimit ) { / * < instead of < = , because repcode check at ( ip + 1 ) * / <nl> + size_t mLength ; <nl> + size_t const h2 = ZSTD_hashPtr ( ip , hBitsL , 8 ) ; <nl> + size_t const h = ZSTD_hashPtr ( ip , hBitsS , mls ) ; <nl> + U32 const current = ( U32 ) ( ip - base ) ; <nl> + U32 const matchIndexL = hashLong [ h2 ] ; <nl> + U32 const matchIndexS = hashSmall [ h ] ; <nl> + const BYTE * matchLong = base + matchIndexL ; <nl> + const BYTE * match = base + matchIndexS ; <nl> + hashLong [ h2 ] = hashSmall [ h ] = current ; / * update hash tables * / <nl> + <nl> + assert ( offset_1 < = current ) ; / * supposed guaranteed by construction * / <nl> + if ( ( offset_1 > 0 ) & ( MEM_read32 ( ip + 1 - offset_1 ) = = MEM_read32 ( ip + 1 ) ) ) { <nl> + / * favor repcode * / <nl> + mLength = ZSTD_count ( ip + 1 + 4 , ip + 1 + 4 - offset_1 , iend ) + 4 ; <nl> + ip + + ; <nl> + ZSTD_storeSeq ( seqStorePtr , ip - anchor , anchor , 0 , mLength - MINMATCH ) ; <nl> + } else { <nl> + U32 offset ; <nl> + if ( ( matchIndexL > lowestIndex ) & & ( MEM_read64 ( matchLong ) = = MEM_read64 ( ip ) ) ) { <nl> + mLength = ZSTD_count ( ip + 8 , matchLong + 8 , iend ) + 8 ; <nl> + offset = ( U32 ) ( ip - matchLong ) ; <nl> + while ( ( ( ip > anchor ) & ( matchLong > lowest ) ) & & ( ip [ - 1 ] = = matchLong [ - 1 ] ) ) { ip - - ; matchLong - - ; mLength + + ; } / * catch up * / <nl> + } else if ( ( matchIndexS > lowestIndex ) & & ( MEM_read32 ( match ) = = MEM_read32 ( ip ) ) ) { <nl> + size_t const hl3 = ZSTD_hashPtr ( ip + 1 , hBitsL , 8 ) ; <nl> + U32 const matchIndexL3 = hashLong [ hl3 ] ; <nl> + const BYTE * matchL3 = base + matchIndexL3 ; <nl> + hashLong [ hl3 ] = current + 1 ; <nl> + if ( ( matchIndexL3 > lowestIndex ) & & ( MEM_read64 ( matchL3 ) = = MEM_read64 ( ip + 1 ) ) ) { <nl> + mLength = ZSTD_count ( ip + 9 , matchL3 + 8 , iend ) + 8 ; <nl> + ip + + ; <nl> + offset = ( U32 ) ( ip - matchL3 ) ; <nl> + while ( ( ( ip > anchor ) & ( matchL3 > lowest ) ) & & ( ip [ - 1 ] = = matchL3 [ - 1 ] ) ) { ip - - ; matchL3 - - ; mLength + + ; } / * catch up * / <nl> + } else { <nl> + mLength = ZSTD_count ( ip + 4 , match + 4 , iend ) + 4 ; <nl> + offset = ( U32 ) ( ip - match ) ; <nl> + while ( ( ( ip > anchor ) & ( match > lowest ) ) & & ( ip [ - 1 ] = = match [ - 1 ] ) ) { ip - - ; match - - ; mLength + + ; } / * catch up * / <nl> + } <nl> + } else { <nl> + ip + = ( ( ip - anchor ) > > g_searchStrength ) + 1 ; <nl> + continue ; <nl> + } <nl> + <nl> + offset_2 = offset_1 ; <nl> + offset_1 = offset ; <nl> + <nl> + ZSTD_storeSeq ( seqStorePtr , ip - anchor , anchor , offset + ZSTD_REP_MOVE , mLength - MINMATCH ) ; <nl> + } <nl> + <nl> + / * match found * / <nl> + ip + = mLength ; <nl> + anchor = ip ; <nl> + <nl> + if ( ip < = ilimit ) { <nl> + / * Fill Table * / <nl> + hashLong [ ZSTD_hashPtr ( base + current + 2 , hBitsL , 8 ) ] = <nl> + hashSmall [ ZSTD_hashPtr ( base + current + 2 , hBitsS , mls ) ] = current + 2 ; / * here because current + 2 could be > iend - 8 * / <nl> + hashLong [ ZSTD_hashPtr ( ip - 2 , hBitsL , 8 ) ] = <nl> + hashSmall [ ZSTD_hashPtr ( ip - 2 , hBitsS , mls ) ] = ( U32 ) ( ip - 2 - base ) ; <nl> + <nl> + / * check immediate repcode * / <nl> + while ( ( ip < = ilimit ) <nl> + & & ( ( offset_2 > 0 ) <nl> + & ( MEM_read32 ( ip ) = = MEM_read32 ( ip - offset_2 ) ) ) ) { <nl> + / * store sequence * / <nl> + size_t const rLength = ZSTD_count ( ip + 4 , ip + 4 - offset_2 , iend ) + 4 ; <nl> + { U32 const tmpOff = offset_2 ; offset_2 = offset_1 ; offset_1 = tmpOff ; } / * swap offset_2 < = > offset_1 * / <nl> + hashSmall [ ZSTD_hashPtr ( ip , hBitsS , mls ) ] = ( U32 ) ( ip - base ) ; <nl> + hashLong [ ZSTD_hashPtr ( ip , hBitsL , 8 ) ] = ( U32 ) ( ip - base ) ; <nl> + ZSTD_storeSeq ( seqStorePtr , 0 , anchor , 0 , rLength - MINMATCH ) ; <nl> + ip + = rLength ; <nl> + anchor = ip ; <nl> + continue ; / * faster when present . . . ( ? ) * / <nl> + } } } <nl> + <nl> + / * save reps for next block * / <nl> + cctx - > repToConfirm [ 0 ] = offset_1 ? offset_1 : offsetSaved ; <nl> + cctx - > repToConfirm [ 1 ] = offset_2 ? offset_2 : offsetSaved ; <nl> + <nl> + / * Last Literals * / <nl> + { size_t const lastLLSize = iend - anchor ; <nl> + memcpy ( seqStorePtr - > lit , anchor , lastLLSize ) ; <nl> + seqStorePtr - > lit + = lastLLSize ; <nl> + } <nl> + } <nl> + <nl> + <nl> + static void ZSTD_compressBlock_doubleFast ( ZSTD_CCtx * ctx , const void * src , size_t srcSize ) <nl> + { <nl> + const U32 mls = ctx - > params . cParams . searchLength ; <nl> + switch ( mls ) <nl> + { <nl> + default : / * includes case 3 * / <nl> + case 4 : <nl> + ZSTD_compressBlock_doubleFast_generic ( ctx , src , srcSize , 4 ) ; return ; <nl> + case 5 : <nl> + ZSTD_compressBlock_doubleFast_generic ( ctx , src , srcSize , 5 ) ; return ; <nl> + case 6 : <nl> + ZSTD_compressBlock_doubleFast_generic ( ctx , src , srcSize , 6 ) ; return ; <nl> + case 7 : <nl> + ZSTD_compressBlock_doubleFast_generic ( ctx , src , srcSize , 7 ) ; return ; <nl> + } <nl> + } <nl> + <nl> + <nl> + static void ZSTD_compressBlock_doubleFast_extDict_generic ( ZSTD_CCtx * ctx , <nl> + const void * src , size_t srcSize , <nl> + const U32 mls ) <nl> + { <nl> + U32 * const hashLong = ctx - > hashTable ; <nl> + U32 const hBitsL = ctx - > params . cParams . hashLog ; <nl> + U32 * const hashSmall = ctx - > chainTable ; <nl> + U32 const hBitsS = ctx - > params . cParams . chainLog ; <nl> + seqStore_t * seqStorePtr = & ( ctx - > seqStore ) ; <nl> + const BYTE * const base = ctx - > base ; <nl> + const BYTE * const dictBase = ctx - > dictBase ; <nl> + const BYTE * const istart = ( const BYTE * ) src ; <nl> + const BYTE * ip = istart ; <nl> + const BYTE * anchor = istart ; <nl> + const U32 lowestIndex = ctx - > lowLimit ; <nl> + const BYTE * const dictStart = dictBase + lowestIndex ; <nl> + const U32 dictLimit = ctx - > dictLimit ; <nl> + const BYTE * const lowPrefixPtr = base + dictLimit ; <nl> + const BYTE * const dictEnd = dictBase + dictLimit ; <nl> + const BYTE * const iend = istart + srcSize ; <nl> + const BYTE * const ilimit = iend - 8 ; <nl> + U32 offset_1 = ctx - > rep [ 0 ] , offset_2 = ctx - > rep [ 1 ] ; <nl> + <nl> + / * Search Loop * / <nl> + while ( ip < ilimit ) { / * < instead of < = , because ( ip + 1 ) * / <nl> + const size_t hSmall = ZSTD_hashPtr ( ip , hBitsS , mls ) ; <nl> + const U32 matchIndex = hashSmall [ hSmall ] ; <nl> + const BYTE * matchBase = matchIndex < dictLimit ? dictBase : base ; <nl> + const BYTE * match = matchBase + matchIndex ; <nl> + <nl> + const size_t hLong = ZSTD_hashPtr ( ip , hBitsL , 8 ) ; <nl> + const U32 matchLongIndex = hashLong [ hLong ] ; <nl> + const BYTE * matchLongBase = matchLongIndex < dictLimit ? dictBase : base ; <nl> + const BYTE * matchLong = matchLongBase + matchLongIndex ; <nl> + <nl> + const U32 current = ( U32 ) ( ip - base ) ; <nl> + const U32 repIndex = current + 1 - offset_1 ; / * offset_1 expected < = current + 1 * / <nl> + const BYTE * repBase = repIndex < dictLimit ? dictBase : base ; <nl> + const BYTE * repMatch = repBase + repIndex ; <nl> + size_t mLength ; <nl> + hashSmall [ hSmall ] = hashLong [ hLong ] = current ; / * update hash table * / <nl> + <nl> + if ( ( ( ( U32 ) ( ( dictLimit - 1 ) - repIndex ) > = 3 ) / * intentional underflow * / & ( repIndex > lowestIndex ) ) <nl> + & & ( MEM_read32 ( repMatch ) = = MEM_read32 ( ip + 1 ) ) ) { <nl> + const BYTE * repMatchEnd = repIndex < dictLimit ? dictEnd : iend ; <nl> + mLength = ZSTD_count_2segments ( ip + 1 + 4 , repMatch + 4 , iend , repMatchEnd , lowPrefixPtr ) + 4 ; <nl> + ip + + ; <nl> + ZSTD_storeSeq ( seqStorePtr , ip - anchor , anchor , 0 , mLength - MINMATCH ) ; <nl> + } else { <nl> + if ( ( matchLongIndex > lowestIndex ) & & ( MEM_read64 ( matchLong ) = = MEM_read64 ( ip ) ) ) { <nl> + const BYTE * matchEnd = matchLongIndex < dictLimit ? dictEnd : iend ; <nl> + const BYTE * lowMatchPtr = matchLongIndex < dictLimit ? dictStart : lowPrefixPtr ; <nl> + U32 offset ; <nl> + mLength = ZSTD_count_2segments ( ip + 8 , matchLong + 8 , iend , matchEnd , lowPrefixPtr ) + 8 ; <nl> + offset = current - matchLongIndex ; <nl> + while ( ( ( ip > anchor ) & ( matchLong > lowMatchPtr ) ) & & ( ip [ - 1 ] = = matchLong [ - 1 ] ) ) { ip - - ; matchLong - - ; mLength + + ; } / * catch up * / <nl> + offset_2 = offset_1 ; <nl> + offset_1 = offset ; <nl> + ZSTD_storeSeq ( seqStorePtr , ip - anchor , anchor , offset + ZSTD_REP_MOVE , mLength - MINMATCH ) ; <nl> + <nl> + } else if ( ( matchIndex > lowestIndex ) & & ( MEM_read32 ( match ) = = MEM_read32 ( ip ) ) ) { <nl> + size_t const h3 = ZSTD_hashPtr ( ip + 1 , hBitsL , 8 ) ; <nl> + U32 const matchIndex3 = hashLong [ h3 ] ; <nl> + const BYTE * const match3Base = matchIndex3 < dictLimit ? dictBase : base ; <nl> + const BYTE * match3 = match3Base + matchIndex3 ; <nl> + U32 offset ; <nl> + hashLong [ h3 ] = current + 1 ; <nl> + if ( ( matchIndex3 > lowestIndex ) & & ( MEM_read64 ( match3 ) = = MEM_read64 ( ip + 1 ) ) ) { <nl> + const BYTE * matchEnd = matchIndex3 < dictLimit ? dictEnd : iend ; <nl> + const BYTE * lowMatchPtr = matchIndex3 < dictLimit ? dictStart : lowPrefixPtr ; <nl> + mLength = ZSTD_count_2segments ( ip + 9 , match3 + 8 , iend , matchEnd , lowPrefixPtr ) + 8 ; <nl> + ip + + ; <nl> + offset = current + 1 - matchIndex3 ; <nl> + while ( ( ( ip > anchor ) & ( match3 > lowMatchPtr ) ) & & ( ip [ - 1 ] = = match3 [ - 1 ] ) ) { ip - - ; match3 - - ; mLength + + ; } / * catch up * / <nl> + } else { <nl> + const BYTE * matchEnd = matchIndex < dictLimit ? dictEnd : iend ; <nl> + const BYTE * lowMatchPtr = matchIndex < dictLimit ? dictStart : lowPrefixPtr ; <nl> + mLength = ZSTD_count_2segments ( ip + 4 , match + 4 , iend , matchEnd , lowPrefixPtr ) + 4 ; <nl> + offset = current - matchIndex ; <nl> + while ( ( ( ip > anchor ) & ( match > lowMatchPtr ) ) & & ( ip [ - 1 ] = = match [ - 1 ] ) ) { ip - - ; match - - ; mLength + + ; } / * catch up * / <nl> + } <nl> + offset_2 = offset_1 ; <nl> + offset_1 = offset ; <nl> + ZSTD_storeSeq ( seqStorePtr , ip - anchor , anchor , offset + ZSTD_REP_MOVE , mLength - MINMATCH ) ; <nl> + <nl> + } else { <nl> + ip + = ( ( ip - anchor ) > > g_searchStrength ) + 1 ; <nl> + continue ; <nl> + } } <nl> + <nl> + / * found a match : store it * / <nl> + ip + = mLength ; <nl> + anchor = ip ; <nl> + <nl> + if ( ip < = ilimit ) { <nl> + / * Fill Table * / <nl> + hashSmall [ ZSTD_hashPtr ( base + current + 2 , hBitsS , mls ) ] = current + 2 ; <nl> + hashLong [ ZSTD_hashPtr ( base + current + 2 , hBitsL , 8 ) ] = current + 2 ; <nl> + hashSmall [ ZSTD_hashPtr ( ip - 2 , hBitsS , mls ) ] = ( U32 ) ( ip - 2 - base ) ; <nl> + hashLong [ ZSTD_hashPtr ( ip - 2 , hBitsL , 8 ) ] = ( U32 ) ( ip - 2 - base ) ; <nl> + / * check immediate repcode * / <nl> + while ( ip < = ilimit ) { <nl> + U32 const current2 = ( U32 ) ( ip - base ) ; <nl> + U32 const repIndex2 = current2 - offset_2 ; <nl> + const BYTE * repMatch2 = repIndex2 < dictLimit ? dictBase + repIndex2 : base + repIndex2 ; <nl> + if ( ( ( ( U32 ) ( ( dictLimit - 1 ) - repIndex2 ) > = 3 ) & ( repIndex2 > lowestIndex ) ) / * intentional overflow * / <nl> + & & ( MEM_read32 ( repMatch2 ) = = MEM_read32 ( ip ) ) ) { <nl> + const BYTE * const repEnd2 = repIndex2 < dictLimit ? dictEnd : iend ; <nl> + size_t const repLength2 = ZSTD_count_2segments ( ip + 4 , repMatch2 + 4 , iend , repEnd2 , lowPrefixPtr ) + 4 ; <nl> + U32 tmpOffset = offset_2 ; offset_2 = offset_1 ; offset_1 = tmpOffset ; / * swap offset_2 < = > offset_1 * / <nl> + ZSTD_storeSeq ( seqStorePtr , 0 , anchor , 0 , repLength2 - MINMATCH ) ; <nl> + hashSmall [ ZSTD_hashPtr ( ip , hBitsS , mls ) ] = current2 ; <nl> + hashLong [ ZSTD_hashPtr ( ip , hBitsL , 8 ) ] = current2 ; <nl> + ip + = repLength2 ; <nl> + anchor = ip ; <nl> + continue ; <nl> + } <nl> + break ; <nl> + } } } <nl> + <nl> + / * save reps for next block * / <nl> + ctx - > repToConfirm [ 0 ] = offset_1 ; ctx - > repToConfirm [ 1 ] = offset_2 ; <nl> + <nl> + / * Last Literals * / <nl> + { size_t const lastLLSize = iend - anchor ; <nl> + memcpy ( seqStorePtr - > lit , anchor , lastLLSize ) ; <nl> + seqStorePtr - > lit + = lastLLSize ; <nl> + } <nl> + } <nl> + <nl> + <nl> + static void ZSTD_compressBlock_doubleFast_extDict ( ZSTD_CCtx * ctx , <nl> + const void * src , size_t srcSize ) <nl> + { <nl> + U32 const mls = ctx - > params . cParams . searchLength ; <nl> + switch ( mls ) <nl> + { <nl> + default : / * includes case 3 * / <nl> + case 4 : <nl> + ZSTD_compressBlock_doubleFast_extDict_generic ( ctx , src , srcSize , 4 ) ; return ; <nl> + case 5 : <nl> + ZSTD_compressBlock_doubleFast_extDict_generic ( ctx , src , srcSize , 5 ) ; return ; <nl> + case 6 : <nl> + ZSTD_compressBlock_doubleFast_extDict_generic ( ctx , src , srcSize , 6 ) ; return ; <nl> + case 7 : <nl> + ZSTD_compressBlock_doubleFast_extDict_generic ( ctx , src , srcSize , 7 ) ; return ; <nl> + } <nl> + } <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Binary Tree search <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * * ZSTD_insertBt1 ( ) : add one or multiple positions to tree . <nl> + * ip : assumed < = iend - 8 . <nl> + * @ return : nb of positions added * / <nl> + static U32 ZSTD_insertBt1 ( ZSTD_CCtx * zc , const BYTE * const ip , const U32 mls , const BYTE * const iend , U32 nbCompares , <nl> + U32 extDict ) <nl> + { <nl> + U32 * const hashTable = zc - > hashTable ; <nl> + U32 const hashLog = zc - > params . cParams . hashLog ; <nl> + size_t const h = ZSTD_hashPtr ( ip , hashLog , mls ) ; <nl> + U32 * const bt = zc - > chainTable ; <nl> + U32 const btLog = zc - > params . cParams . chainLog - 1 ; <nl> + U32 const btMask = ( 1 < < btLog ) - 1 ; <nl> + U32 matchIndex = hashTable [ h ] ; <nl> + size_t commonLengthSmaller = 0 , commonLengthLarger = 0 ; <nl> + const BYTE * const base = zc - > base ; <nl> + const BYTE * const dictBase = zc - > dictBase ; <nl> + const U32 dictLimit = zc - > dictLimit ; <nl> + const BYTE * const dictEnd = dictBase + dictLimit ; <nl> + const BYTE * const prefixStart = base + dictLimit ; <nl> + const BYTE * match ; <nl> + const U32 current = ( U32 ) ( ip - base ) ; <nl> + const U32 btLow = btMask > = current ? 0 : current - btMask ; <nl> + U32 * smallerPtr = bt + 2 * ( current & btMask ) ; <nl> + U32 * largerPtr = smallerPtr + 1 ; <nl> + U32 dummy32 ; / * to be nullified at the end * / <nl> + U32 const windowLow = zc - > lowLimit ; <nl> + U32 matchEndIdx = current + 8 ; <nl> + size_t bestLength = 8 ; <nl> + # ifdef ZSTD_C_PREDICT <nl> + U32 predictedSmall = * ( bt + 2 * ( ( current - 1 ) & btMask ) + 0 ) ; <nl> + U32 predictedLarge = * ( bt + 2 * ( ( current - 1 ) & btMask ) + 1 ) ; <nl> + predictedSmall + = ( predictedSmall > 0 ) ; <nl> + predictedLarge + = ( predictedLarge > 0 ) ; <nl> + # endif / * ZSTD_C_PREDICT * / <nl> + <nl> + hashTable [ h ] = current ; / * Update Hash Table * / <nl> + <nl> + while ( nbCompares - - & & ( matchIndex > windowLow ) ) { <nl> + U32 * const nextPtr = bt + 2 * ( matchIndex & btMask ) ; <nl> + size_t matchLength = MIN ( commonLengthSmaller , commonLengthLarger ) ; / * guaranteed minimum nb of common bytes * / <nl> + <nl> + # ifdef ZSTD_C_PREDICT / * note : can create issues when hlog small < = 11 * / <nl> + const U32 * predictPtr = bt + 2 * ( ( matchIndex - 1 ) & btMask ) ; / * written this way , as bt is a roll buffer * / <nl> + if ( matchIndex = = predictedSmall ) { <nl> + / * no need to check length , result known * / <nl> + * smallerPtr = matchIndex ; <nl> + if ( matchIndex < = btLow ) { smallerPtr = & dummy32 ; break ; } / * beyond tree size , stop the search * / <nl> + smallerPtr = nextPtr + 1 ; / * new " smaller " = > larger of match * / <nl> + matchIndex = nextPtr [ 1 ] ; / * new matchIndex larger than previous ( closer to current ) * / <nl> + predictedSmall = predictPtr [ 1 ] + ( predictPtr [ 1 ] > 0 ) ; <nl> + continue ; <nl> + } <nl> + if ( matchIndex = = predictedLarge ) { <nl> + * largerPtr = matchIndex ; <nl> + if ( matchIndex < = btLow ) { largerPtr = & dummy32 ; break ; } / * beyond tree size , stop the search * / <nl> + largerPtr = nextPtr ; <nl> + matchIndex = nextPtr [ 0 ] ; <nl> + predictedLarge = predictPtr [ 0 ] + ( predictPtr [ 0 ] > 0 ) ; <nl> + continue ; <nl> + } <nl> + # endif <nl> + if ( ( ! extDict ) | | ( matchIndex + matchLength > = dictLimit ) ) { <nl> + match = base + matchIndex ; <nl> + if ( match [ matchLength ] = = ip [ matchLength ] ) <nl> + matchLength + = ZSTD_count ( ip + matchLength + 1 , match + matchLength + 1 , iend ) + 1 ; <nl> + } else { <nl> + match = dictBase + matchIndex ; <nl> + matchLength + = ZSTD_count_2segments ( ip + matchLength , match + matchLength , iend , dictEnd , prefixStart ) ; <nl> + if ( matchIndex + matchLength > = dictLimit ) <nl> + match = base + matchIndex ; / * to prepare for next usage of match [ matchLength ] * / <nl> + } <nl> + <nl> + if ( matchLength > bestLength ) { <nl> + bestLength = matchLength ; <nl> + if ( matchLength > matchEndIdx - matchIndex ) <nl> + matchEndIdx = matchIndex + ( U32 ) matchLength ; <nl> + } <nl> + <nl> + if ( ip + matchLength = = iend ) / * equal : no way to know if inf or sup * / <nl> + break ; / * drop , to guarantee consistency ; miss a bit of compression , but other solutions can corrupt the tree * / <nl> + <nl> + if ( match [ matchLength ] < ip [ matchLength ] ) { / * necessarily within correct buffer * / <nl> + / * match is smaller than current * / <nl> + * smallerPtr = matchIndex ; / * update smaller idx * / <nl> + commonLengthSmaller = matchLength ; / * all smaller will now have at least this guaranteed common length * / <nl> + if ( matchIndex < = btLow ) { smallerPtr = & dummy32 ; break ; } / * beyond tree size , stop the search * / <nl> + smallerPtr = nextPtr + 1 ; / * new " smaller " = > larger of match * / <nl> + matchIndex = nextPtr [ 1 ] ; / * new matchIndex larger than previous ( closer to current ) * / <nl> + } else { <nl> + / * match is larger than current * / <nl> + * largerPtr = matchIndex ; <nl> + commonLengthLarger = matchLength ; <nl> + if ( matchIndex < = btLow ) { largerPtr = & dummy32 ; break ; } / * beyond tree size , stop the search * / <nl> + largerPtr = nextPtr ; <nl> + matchIndex = nextPtr [ 0 ] ; <nl> + } } <nl> + <nl> + * smallerPtr = * largerPtr = 0 ; <nl> + if ( bestLength > 384 ) return MIN ( 192 , ( U32 ) ( bestLength - 384 ) ) ; / * speed optimization * / <nl> + if ( matchEndIdx > current + 8 ) return matchEndIdx - current - 8 ; <nl> + return 1 ; <nl> + } <nl> + <nl> + <nl> + static size_t ZSTD_insertBtAndFindBestMatch ( <nl> + ZSTD_CCtx * zc , <nl> + const BYTE * const ip , const BYTE * const iend , <nl> + size_t * offsetPtr , <nl> + U32 nbCompares , const U32 mls , <nl> + U32 extDict ) <nl> + { <nl> + U32 * const hashTable = zc - > hashTable ; <nl> + U32 const hashLog = zc - > params . cParams . hashLog ; <nl> + size_t const h = ZSTD_hashPtr ( ip , hashLog , mls ) ; <nl> + U32 * const bt = zc - > chainTable ; <nl> + U32 const btLog = zc - > params . cParams . chainLog - 1 ; <nl> + U32 const btMask = ( 1 < < btLog ) - 1 ; <nl> + U32 matchIndex = hashTable [ h ] ; <nl> + size_t commonLengthSmaller = 0 , commonLengthLarger = 0 ; <nl> + const BYTE * const base = zc - > base ; <nl> + const BYTE * const dictBase = zc - > dictBase ; <nl> + const U32 dictLimit = zc - > dictLimit ; <nl> + const BYTE * const dictEnd = dictBase + dictLimit ; <nl> + const BYTE * const prefixStart = base + dictLimit ; <nl> + const U32 current = ( U32 ) ( ip - base ) ; <nl> + const U32 btLow = btMask > = current ? 0 : current - btMask ; <nl> + const U32 windowLow = zc - > lowLimit ; <nl> + U32 * smallerPtr = bt + 2 * ( current & btMask ) ; <nl> + U32 * largerPtr = bt + 2 * ( current & btMask ) + 1 ; <nl> + U32 matchEndIdx = current + 8 ; <nl> + U32 dummy32 ; / * to be nullified at the end * / <nl> + size_t bestLength = 0 ; <nl> + <nl> + hashTable [ h ] = current ; / * Update Hash Table * / <nl> + <nl> + while ( nbCompares - - & & ( matchIndex > windowLow ) ) { <nl> + U32 * const nextPtr = bt + 2 * ( matchIndex & btMask ) ; <nl> + size_t matchLength = MIN ( commonLengthSmaller , commonLengthLarger ) ; / * guaranteed minimum nb of common bytes * / <nl> + const BYTE * match ; <nl> + <nl> + if ( ( ! extDict ) | | ( matchIndex + matchLength > = dictLimit ) ) { <nl> + match = base + matchIndex ; <nl> + if ( match [ matchLength ] = = ip [ matchLength ] ) <nl> + matchLength + = ZSTD_count ( ip + matchLength + 1 , match + matchLength + 1 , iend ) + 1 ; <nl> + } else { <nl> + match = dictBase + matchIndex ; <nl> + matchLength + = ZSTD_count_2segments ( ip + matchLength , match + matchLength , iend , dictEnd , prefixStart ) ; <nl> + if ( matchIndex + matchLength > = dictLimit ) <nl> + match = base + matchIndex ; / * to prepare for next usage of match [ matchLength ] * / <nl> + } <nl> + <nl> + if ( matchLength > bestLength ) { <nl> + if ( matchLength > matchEndIdx - matchIndex ) <nl> + matchEndIdx = matchIndex + ( U32 ) matchLength ; <nl> + if ( ( 4 * ( int ) ( matchLength - bestLength ) ) > ( int ) ( ZSTD_highbit32 ( current - matchIndex + 1 ) - ZSTD_highbit32 ( ( U32 ) offsetPtr [ 0 ] + 1 ) ) ) <nl> + bestLength = matchLength , * offsetPtr = ZSTD_REP_MOVE + current - matchIndex ; <nl> + if ( ip + matchLength = = iend ) / * equal : no way to know if inf or sup * / <nl> + break ; / * drop , to guarantee consistency ( miss a little bit of compression ) * / <nl> + } <nl> + <nl> + if ( match [ matchLength ] < ip [ matchLength ] ) { <nl> + / * match is smaller than current * / <nl> + * smallerPtr = matchIndex ; / * update smaller idx * / <nl> + commonLengthSmaller = matchLength ; / * all smaller will now have at least this guaranteed common length * / <nl> + if ( matchIndex < = btLow ) { smallerPtr = & dummy32 ; break ; } / * beyond tree size , stop the search * / <nl> + smallerPtr = nextPtr + 1 ; / * new " smaller " = > larger of match * / <nl> + matchIndex = nextPtr [ 1 ] ; / * new matchIndex larger than previous ( closer to current ) * / <nl> + } else { <nl> + / * match is larger than current * / <nl> + * largerPtr = matchIndex ; <nl> + commonLengthLarger = matchLength ; <nl> + if ( matchIndex < = btLow ) { largerPtr = & dummy32 ; break ; } / * beyond tree size , stop the search * / <nl> + largerPtr = nextPtr ; <nl> + matchIndex = nextPtr [ 0 ] ; <nl> + } } <nl> + <nl> + * smallerPtr = * largerPtr = 0 ; <nl> + <nl> + zc - > nextToUpdate = ( matchEndIdx > current + 8 ) ? matchEndIdx - 8 : current + 1 ; <nl> + return bestLength ; <nl> + } <nl> + <nl> + <nl> + static void ZSTD_updateTree ( ZSTD_CCtx * zc , const BYTE * const ip , const BYTE * const iend , const U32 nbCompares , const U32 mls ) <nl> + { <nl> + const BYTE * const base = zc - > base ; <nl> + const U32 target = ( U32 ) ( ip - base ) ; <nl> + U32 idx = zc - > nextToUpdate ; <nl> + <nl> + while ( idx < target ) <nl> + idx + = ZSTD_insertBt1 ( zc , base + idx , mls , iend , nbCompares , 0 ) ; <nl> + } <nl> + <nl> + / * * ZSTD_BtFindBestMatch ( ) : Tree updater , providing best match * / <nl> + static size_t ZSTD_BtFindBestMatch ( <nl> + ZSTD_CCtx * zc , <nl> + const BYTE * const ip , const BYTE * const iLimit , <nl> + size_t * offsetPtr , <nl> + const U32 maxNbAttempts , const U32 mls ) <nl> + { <nl> + if ( ip < zc - > base + zc - > nextToUpdate ) return 0 ; / * skipped area * / <nl> + ZSTD_updateTree ( zc , ip , iLimit , maxNbAttempts , mls ) ; <nl> + return ZSTD_insertBtAndFindBestMatch ( zc , ip , iLimit , offsetPtr , maxNbAttempts , mls , 0 ) ; <nl> + } <nl> + <nl> + <nl> + static size_t ZSTD_BtFindBestMatch_selectMLS ( <nl> + ZSTD_CCtx * zc , / * Index table will be updated * / <nl> + const BYTE * ip , const BYTE * const iLimit , <nl> + size_t * offsetPtr , <nl> + const U32 maxNbAttempts , const U32 matchLengthSearch ) <nl> + { <nl> + switch ( matchLengthSearch ) <nl> + { <nl> + default : / * includes case 3 * / <nl> + case 4 : return ZSTD_BtFindBestMatch ( zc , ip , iLimit , offsetPtr , maxNbAttempts , 4 ) ; <nl> + case 5 : return ZSTD_BtFindBestMatch ( zc , ip , iLimit , offsetPtr , maxNbAttempts , 5 ) ; <nl> + case 7 : <nl> + case 6 : return ZSTD_BtFindBestMatch ( zc , ip , iLimit , offsetPtr , maxNbAttempts , 6 ) ; <nl> + } <nl> + } <nl> + <nl> + <nl> + static void ZSTD_updateTree_extDict ( ZSTD_CCtx * zc , const BYTE * const ip , const BYTE * const iend , const U32 nbCompares , const U32 mls ) <nl> + { <nl> + const BYTE * const base = zc - > base ; <nl> + const U32 target = ( U32 ) ( ip - base ) ; <nl> + U32 idx = zc - > nextToUpdate ; <nl> + <nl> + while ( idx < target ) idx + = ZSTD_insertBt1 ( zc , base + idx , mls , iend , nbCompares , 1 ) ; <nl> + } <nl> + <nl> + <nl> + / * * Tree updater , providing best match * / <nl> + static size_t ZSTD_BtFindBestMatch_extDict ( <nl> + ZSTD_CCtx * zc , <nl> + const BYTE * const ip , const BYTE * const iLimit , <nl> + size_t * offsetPtr , <nl> + const U32 maxNbAttempts , const U32 mls ) <nl> + { <nl> + if ( ip < zc - > base + zc - > nextToUpdate ) return 0 ; / * skipped area * / <nl> + ZSTD_updateTree_extDict ( zc , ip , iLimit , maxNbAttempts , mls ) ; <nl> + return ZSTD_insertBtAndFindBestMatch ( zc , ip , iLimit , offsetPtr , maxNbAttempts , mls , 1 ) ; <nl> + } <nl> + <nl> + <nl> + static size_t ZSTD_BtFindBestMatch_selectMLS_extDict ( <nl> + ZSTD_CCtx * zc , / * Index table will be updated * / <nl> + const BYTE * ip , const BYTE * const iLimit , <nl> + size_t * offsetPtr , <nl> + const U32 maxNbAttempts , const U32 matchLengthSearch ) <nl> + { <nl> + switch ( matchLengthSearch ) <nl> + { <nl> + default : / * includes case 3 * / <nl> + case 4 : return ZSTD_BtFindBestMatch_extDict ( zc , ip , iLimit , offsetPtr , maxNbAttempts , 4 ) ; <nl> + case 5 : return ZSTD_BtFindBestMatch_extDict ( zc , ip , iLimit , offsetPtr , maxNbAttempts , 5 ) ; <nl> + case 7 : <nl> + case 6 : return ZSTD_BtFindBestMatch_extDict ( zc , ip , iLimit , offsetPtr , maxNbAttempts , 6 ) ; <nl> + } <nl> + } <nl> + <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Hash Chain <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # define NEXT_IN_CHAIN ( d , mask ) chainTable [ ( d ) & mask ] <nl> + <nl> + / * Update chains up to ip ( excluded ) <nl> + Assumption : always within prefix ( i . e . not within extDict ) * / <nl> + FORCE_INLINE <nl> + U32 ZSTD_insertAndFindFirstIndex ( ZSTD_CCtx * zc , const BYTE * ip , U32 mls ) <nl> + { <nl> + U32 * const hashTable = zc - > hashTable ; <nl> + const U32 hashLog = zc - > params . cParams . hashLog ; <nl> + U32 * const chainTable = zc - > chainTable ; <nl> + const U32 chainMask = ( 1 < < zc - > params . cParams . chainLog ) - 1 ; <nl> + const BYTE * const base = zc - > base ; <nl> + const U32 target = ( U32 ) ( ip - base ) ; <nl> + U32 idx = zc - > nextToUpdate ; <nl> + <nl> + while ( idx < target ) { / * catch up * / <nl> + size_t const h = ZSTD_hashPtr ( base + idx , hashLog , mls ) ; <nl> + NEXT_IN_CHAIN ( idx , chainMask ) = hashTable [ h ] ; <nl> + hashTable [ h ] = idx ; <nl> + idx + + ; <nl> + } <nl> + <nl> + zc - > nextToUpdate = target ; <nl> + return hashTable [ ZSTD_hashPtr ( ip , hashLog , mls ) ] ; <nl> + } <nl> + <nl> + <nl> + <nl> + FORCE_INLINE / * inlining is important to hardwire a hot branch ( template emulation ) * / <nl> + size_t ZSTD_HcFindBestMatch_generic ( <nl> + ZSTD_CCtx * zc , / * Index table will be updated * / <nl> + const BYTE * const ip , const BYTE * const iLimit , <nl> + size_t * offsetPtr , <nl> + const U32 maxNbAttempts , const U32 mls , const U32 extDict ) <nl> + { <nl> + U32 * const chainTable = zc - > chainTable ; <nl> + const U32 chainSize = ( 1 < < zc - > params . cParams . chainLog ) ; <nl> + const U32 chainMask = chainSize - 1 ; <nl> + const BYTE * const base = zc - > base ; <nl> + const BYTE * const dictBase = zc - > dictBase ; <nl> + const U32 dictLimit = zc - > dictLimit ; <nl> + const BYTE * const prefixStart = base + dictLimit ; <nl> + const BYTE * const dictEnd = dictBase + dictLimit ; <nl> + const U32 lowLimit = zc - > lowLimit ; <nl> + const U32 current = ( U32 ) ( ip - base ) ; <nl> + const U32 minChain = current > chainSize ? current - chainSize : 0 ; <nl> + int nbAttempts = maxNbAttempts ; <nl> + size_t ml = 4 - 1 ; <nl> + <nl> + / * HC4 match finder * / <nl> + U32 matchIndex = ZSTD_insertAndFindFirstIndex ( zc , ip , mls ) ; <nl> + <nl> + for ( ; ( matchIndex > lowLimit ) & ( nbAttempts > 0 ) ; nbAttempts - - ) { <nl> + const BYTE * match ; <nl> + size_t currentMl = 0 ; <nl> + if ( ( ! extDict ) | | matchIndex > = dictLimit ) { <nl> + match = base + matchIndex ; <nl> + if ( match [ ml ] = = ip [ ml ] ) / * potentially better * / <nl> + currentMl = ZSTD_count ( ip , match , iLimit ) ; <nl> + } else { <nl> + match = dictBase + matchIndex ; <nl> + if ( MEM_read32 ( match ) = = MEM_read32 ( ip ) ) / * assumption : matchIndex < = dictLimit - 4 ( by table construction ) * / <nl> + currentMl = ZSTD_count_2segments ( ip + 4 , match + 4 , iLimit , dictEnd , prefixStart ) + 4 ; <nl> + } <nl> + <nl> + / * save best solution * / <nl> + if ( currentMl > ml ) { <nl> + ml = currentMl ; <nl> + * offsetPtr = current - matchIndex + ZSTD_REP_MOVE ; <nl> + if ( ip + currentMl = = iLimit ) break ; / * best possible , avoids read overflow on next attempt * / <nl> + } <nl> + <nl> + if ( matchIndex < = minChain ) break ; <nl> + matchIndex = NEXT_IN_CHAIN ( matchIndex , chainMask ) ; <nl> + } <nl> + <nl> + return ml ; <nl> + } <nl> + <nl> + <nl> + FORCE_INLINE size_t ZSTD_HcFindBestMatch_selectMLS ( <nl> + ZSTD_CCtx * zc , <nl> + const BYTE * ip , const BYTE * const iLimit , <nl> + size_t * offsetPtr , <nl> + const U32 maxNbAttempts , const U32 matchLengthSearch ) <nl> + { <nl> + switch ( matchLengthSearch ) <nl> + { <nl> + default : / * includes case 3 * / <nl> + case 4 : return ZSTD_HcFindBestMatch_generic ( zc , ip , iLimit , offsetPtr , maxNbAttempts , 4 , 0 ) ; <nl> + case 5 : return ZSTD_HcFindBestMatch_generic ( zc , ip , iLimit , offsetPtr , maxNbAttempts , 5 , 0 ) ; <nl> + case 7 : <nl> + case 6 : return ZSTD_HcFindBestMatch_generic ( zc , ip , iLimit , offsetPtr , maxNbAttempts , 6 , 0 ) ; <nl> + } <nl> + } <nl> + <nl> + <nl> + FORCE_INLINE size_t ZSTD_HcFindBestMatch_extDict_selectMLS ( <nl> + ZSTD_CCtx * zc , <nl> + const BYTE * ip , const BYTE * const iLimit , <nl> + size_t * offsetPtr , <nl> + const U32 maxNbAttempts , const U32 matchLengthSearch ) <nl> + { <nl> + switch ( matchLengthSearch ) <nl> + { <nl> + default : / * includes case 3 * / <nl> + case 4 : return ZSTD_HcFindBestMatch_generic ( zc , ip , iLimit , offsetPtr , maxNbAttempts , 4 , 1 ) ; <nl> + case 5 : return ZSTD_HcFindBestMatch_generic ( zc , ip , iLimit , offsetPtr , maxNbAttempts , 5 , 1 ) ; <nl> + case 7 : <nl> + case 6 : return ZSTD_HcFindBestMatch_generic ( zc , ip , iLimit , offsetPtr , maxNbAttempts , 6 , 1 ) ; <nl> + } <nl> + } <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Common parser - lazy strategy <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + FORCE_INLINE <nl> + void ZSTD_compressBlock_lazy_generic ( ZSTD_CCtx * ctx , <nl> + const void * src , size_t srcSize , <nl> + const U32 searchMethod , const U32 depth ) <nl> + { <nl> + seqStore_t * seqStorePtr = & ( ctx - > seqStore ) ; <nl> + const BYTE * const istart = ( const BYTE * ) src ; <nl> + const BYTE * ip = istart ; <nl> + const BYTE * anchor = istart ; <nl> + const BYTE * const iend = istart + srcSize ; <nl> + const BYTE * const ilimit = iend - 8 ; <nl> + const BYTE * const base = ctx - > base + ctx - > dictLimit ; <nl> + <nl> + U32 const maxSearches = 1 < < ctx - > params . cParams . searchLog ; <nl> + U32 const mls = ctx - > params . cParams . searchLength ; <nl> + <nl> + typedef size_t ( * searchMax_f ) ( ZSTD_CCtx * zc , const BYTE * ip , const BYTE * iLimit , <nl> + size_t * offsetPtr , <nl> + U32 maxNbAttempts , U32 matchLengthSearch ) ; <nl> + searchMax_f const searchMax = searchMethod ? ZSTD_BtFindBestMatch_selectMLS : ZSTD_HcFindBestMatch_selectMLS ; <nl> + U32 offset_1 = ctx - > rep [ 0 ] , offset_2 = ctx - > rep [ 1 ] , savedOffset = 0 ; <nl> + <nl> + / * init * / <nl> + ip + = ( ip = = base ) ; <nl> + ctx - > nextToUpdate3 = ctx - > nextToUpdate ; <nl> + { U32 const maxRep = ( U32 ) ( ip - base ) ; <nl> + if ( offset_2 > maxRep ) savedOffset = offset_2 , offset_2 = 0 ; <nl> + if ( offset_1 > maxRep ) savedOffset = offset_1 , offset_1 = 0 ; <nl> + } <nl> + <nl> + / * Match Loop * / <nl> + while ( ip < ilimit ) { <nl> + size_t matchLength = 0 ; <nl> + size_t offset = 0 ; <nl> + const BYTE * start = ip + 1 ; <nl> + <nl> + / * check repCode * / <nl> + if ( ( offset_1 > 0 ) & ( MEM_read32 ( ip + 1 ) = = MEM_read32 ( ip + 1 - offset_1 ) ) ) { <nl> + / * repcode : we take it * / <nl> + matchLength = ZSTD_count ( ip + 1 + 4 , ip + 1 + 4 - offset_1 , iend ) + 4 ; <nl> + if ( depth = = 0 ) goto _storeSequence ; <nl> + } <nl> + <nl> + / * first search ( depth 0 ) * / <nl> + { size_t offsetFound = 99999999 ; <nl> + size_t const ml2 = searchMax ( ctx , ip , iend , & offsetFound , maxSearches , mls ) ; <nl> + if ( ml2 > matchLength ) <nl> + matchLength = ml2 , start = ip , offset = offsetFound ; <nl> + } <nl> + <nl> + if ( matchLength < 4 ) { <nl> + ip + = ( ( ip - anchor ) > > g_searchStrength ) + 1 ; / * jump faster over incompressible sections * / <nl> + continue ; <nl> + } <nl> + <nl> + / * let ' s try to find a better solution * / <nl> + if ( depth > = 1 ) <nl> + while ( ip < ilimit ) { <nl> + ip + + ; <nl> + if ( ( offset ) & & ( ( offset_1 > 0 ) & ( MEM_read32 ( ip ) = = MEM_read32 ( ip - offset_1 ) ) ) ) { <nl> + size_t const mlRep = ZSTD_count ( ip + 4 , ip + 4 - offset_1 , iend ) + 4 ; <nl> + int const gain2 = ( int ) ( mlRep * 3 ) ; <nl> + int const gain1 = ( int ) ( matchLength * 3 - ZSTD_highbit32 ( ( U32 ) offset + 1 ) + 1 ) ; <nl> + if ( ( mlRep > = 4 ) & & ( gain2 > gain1 ) ) <nl> + matchLength = mlRep , offset = 0 , start = ip ; <nl> + } <nl> + { size_t offset2 = 99999999 ; <nl> + size_t const ml2 = searchMax ( ctx , ip , iend , & offset2 , maxSearches , mls ) ; <nl> + int const gain2 = ( int ) ( ml2 * 4 - ZSTD_highbit32 ( ( U32 ) offset2 + 1 ) ) ; / * raw approx * / <nl> + int const gain1 = ( int ) ( matchLength * 4 - ZSTD_highbit32 ( ( U32 ) offset + 1 ) + 4 ) ; <nl> + if ( ( ml2 > = 4 ) & & ( gain2 > gain1 ) ) { <nl> + matchLength = ml2 , offset = offset2 , start = ip ; <nl> + continue ; / * search a better one * / <nl> + } } <nl> + <nl> + / * let ' s find an even better one * / <nl> + if ( ( depth = = 2 ) & & ( ip < ilimit ) ) { <nl> + ip + + ; <nl> + if ( ( offset ) & & ( ( offset_1 > 0 ) & ( MEM_read32 ( ip ) = = MEM_read32 ( ip - offset_1 ) ) ) ) { <nl> + size_t const ml2 = ZSTD_count ( ip + 4 , ip + 4 - offset_1 , iend ) + 4 ; <nl> + int const gain2 = ( int ) ( ml2 * 4 ) ; <nl> + int const gain1 = ( int ) ( matchLength * 4 - ZSTD_highbit32 ( ( U32 ) offset + 1 ) + 1 ) ; <nl> + if ( ( ml2 > = 4 ) & & ( gain2 > gain1 ) ) <nl> + matchLength = ml2 , offset = 0 , start = ip ; <nl> + } <nl> + { size_t offset2 = 99999999 ; <nl> + size_t const ml2 = searchMax ( ctx , ip , iend , & offset2 , maxSearches , mls ) ; <nl> + int const gain2 = ( int ) ( ml2 * 4 - ZSTD_highbit32 ( ( U32 ) offset2 + 1 ) ) ; / * raw approx * / <nl> + int const gain1 = ( int ) ( matchLength * 4 - ZSTD_highbit32 ( ( U32 ) offset + 1 ) + 7 ) ; <nl> + if ( ( ml2 > = 4 ) & & ( gain2 > gain1 ) ) { <nl> + matchLength = ml2 , offset = offset2 , start = ip ; <nl> + continue ; <nl> + } } } <nl> + break ; / * nothing found : store previous solution * / <nl> + } <nl> + <nl> + / * catch up * / <nl> + if ( offset ) { <nl> + while ( ( start > anchor ) <nl> + & & ( start > base + offset - ZSTD_REP_MOVE ) <nl> + & & ( start [ - 1 ] = = start [ - 1 - offset + ZSTD_REP_MOVE ] ) ) / * only search for offset within prefix * / <nl> + { start - - ; matchLength + + ; } <nl> + offset_2 = offset_1 ; offset_1 = ( U32 ) ( offset - ZSTD_REP_MOVE ) ; <nl> + } <nl> + <nl> + / * store sequence * / <nl> + _storeSequence : <nl> + { size_t const litLength = start - anchor ; <nl> + ZSTD_storeSeq ( seqStorePtr , litLength , anchor , ( U32 ) offset , matchLength - MINMATCH ) ; <nl> + anchor = ip = start + matchLength ; <nl> + } <nl> + <nl> + / * check immediate repcode * / <nl> + while ( ( ip < = ilimit ) <nl> + & & ( ( offset_2 > 0 ) <nl> + & ( MEM_read32 ( ip ) = = MEM_read32 ( ip - offset_2 ) ) ) ) { <nl> + / * store sequence * / <nl> + matchLength = ZSTD_count ( ip + 4 , ip + 4 - offset_2 , iend ) + 4 ; <nl> + offset = offset_2 ; offset_2 = offset_1 ; offset_1 = ( U32 ) offset ; / * swap repcodes * / <nl> + ZSTD_storeSeq ( seqStorePtr , 0 , anchor , 0 , matchLength - MINMATCH ) ; <nl> + ip + = matchLength ; <nl> + anchor = ip ; <nl> + continue ; / * faster when present . . . ( ? ) * / <nl> + } } <nl> + <nl> + / * Save reps for next block * / <nl> + ctx - > repToConfirm [ 0 ] = offset_1 ? offset_1 : savedOffset ; <nl> + ctx - > repToConfirm [ 1 ] = offset_2 ? offset_2 : savedOffset ; <nl> + <nl> + / * Last Literals * / <nl> + { size_t const lastLLSize = iend - anchor ; <nl> + memcpy ( seqStorePtr - > lit , anchor , lastLLSize ) ; <nl> + seqStorePtr - > lit + = lastLLSize ; <nl> + } <nl> + } <nl> + <nl> + <nl> + static void ZSTD_compressBlock_btlazy2 ( ZSTD_CCtx * ctx , const void * src , size_t srcSize ) <nl> + { <nl> + ZSTD_compressBlock_lazy_generic ( ctx , src , srcSize , 1 , 2 ) ; <nl> + } <nl> + <nl> + static void ZSTD_compressBlock_lazy2 ( ZSTD_CCtx * ctx , const void * src , size_t srcSize ) <nl> + { <nl> + ZSTD_compressBlock_lazy_generic ( ctx , src , srcSize , 0 , 2 ) ; <nl> + } <nl> + <nl> + static void ZSTD_compressBlock_lazy ( ZSTD_CCtx * ctx , const void * src , size_t srcSize ) <nl> + { <nl> + ZSTD_compressBlock_lazy_generic ( ctx , src , srcSize , 0 , 1 ) ; <nl> + } <nl> + <nl> + static void ZSTD_compressBlock_greedy ( ZSTD_CCtx * ctx , const void * src , size_t srcSize ) <nl> + { <nl> + ZSTD_compressBlock_lazy_generic ( ctx , src , srcSize , 0 , 0 ) ; <nl> + } <nl> + <nl> + <nl> + FORCE_INLINE <nl> + void ZSTD_compressBlock_lazy_extDict_generic ( ZSTD_CCtx * ctx , <nl> + const void * src , size_t srcSize , <nl> + const U32 searchMethod , const U32 depth ) <nl> + { <nl> + seqStore_t * seqStorePtr = & ( ctx - > seqStore ) ; <nl> + const BYTE * const istart = ( const BYTE * ) src ; <nl> + const BYTE * ip = istart ; <nl> + const BYTE * anchor = istart ; <nl> + const BYTE * const iend = istart + srcSize ; <nl> + const BYTE * const ilimit = iend - 8 ; <nl> + const BYTE * const base = ctx - > base ; <nl> + const U32 dictLimit = ctx - > dictLimit ; <nl> + const U32 lowestIndex = ctx - > lowLimit ; <nl> + const BYTE * const prefixStart = base + dictLimit ; <nl> + const BYTE * const dictBase = ctx - > dictBase ; <nl> + const BYTE * const dictEnd = dictBase + dictLimit ; <nl> + const BYTE * const dictStart = dictBase + ctx - > lowLimit ; <nl> + <nl> + const U32 maxSearches = 1 < < ctx - > params . cParams . searchLog ; <nl> + const U32 mls = ctx - > params . cParams . searchLength ; <nl> + <nl> + typedef size_t ( * searchMax_f ) ( ZSTD_CCtx * zc , const BYTE * ip , const BYTE * iLimit , <nl> + size_t * offsetPtr , <nl> + U32 maxNbAttempts , U32 matchLengthSearch ) ; <nl> + searchMax_f searchMax = searchMethod ? ZSTD_BtFindBestMatch_selectMLS_extDict : ZSTD_HcFindBestMatch_extDict_selectMLS ; <nl> + <nl> + U32 offset_1 = ctx - > rep [ 0 ] , offset_2 = ctx - > rep [ 1 ] ; <nl> + <nl> + / * init * / <nl> + ctx - > nextToUpdate3 = ctx - > nextToUpdate ; <nl> + ip + = ( ip = = prefixStart ) ; <nl> + <nl> + / * Match Loop * / <nl> + while ( ip < ilimit ) { <nl> + size_t matchLength = 0 ; <nl> + size_t offset = 0 ; <nl> + const BYTE * start = ip + 1 ; <nl> + U32 current = ( U32 ) ( ip - base ) ; <nl> + <nl> + / * check repCode * / <nl> + { const U32 repIndex = ( U32 ) ( current + 1 - offset_1 ) ; <nl> + const BYTE * const repBase = repIndex < dictLimit ? dictBase : base ; <nl> + const BYTE * const repMatch = repBase + repIndex ; <nl> + if ( ( ( U32 ) ( ( dictLimit - 1 ) - repIndex ) > = 3 ) & ( repIndex > lowestIndex ) ) / * intentional overflow * / <nl> + if ( MEM_read32 ( ip + 1 ) = = MEM_read32 ( repMatch ) ) { <nl> + / * repcode detected we should take it * / <nl> + const BYTE * const repEnd = repIndex < dictLimit ? dictEnd : iend ; <nl> + matchLength = ZSTD_count_2segments ( ip + 1 + 4 , repMatch + 4 , iend , repEnd , prefixStart ) + 4 ; <nl> + if ( depth = = 0 ) goto _storeSequence ; <nl> + } } <nl> + <nl> + / * first search ( depth 0 ) * / <nl> + { size_t offsetFound = 99999999 ; <nl> + size_t const ml2 = searchMax ( ctx , ip , iend , & offsetFound , maxSearches , mls ) ; <nl> + if ( ml2 > matchLength ) <nl> + matchLength = ml2 , start = ip , offset = offsetFound ; <nl> + } <nl> + <nl> + if ( matchLength < 4 ) { <nl> + ip + = ( ( ip - anchor ) > > g_searchStrength ) + 1 ; / * jump faster over incompressible sections * / <nl> + continue ; <nl> + } <nl> + <nl> + / * let ' s try to find a better solution * / <nl> + if ( depth > = 1 ) <nl> + while ( ip < ilimit ) { <nl> + ip + + ; <nl> + current + + ; <nl> + / * check repCode * / <nl> + if ( offset ) { <nl> + const U32 repIndex = ( U32 ) ( current - offset_1 ) ; <nl> + const BYTE * const repBase = repIndex < dictLimit ? dictBase : base ; <nl> + const BYTE * const repMatch = repBase + repIndex ; <nl> + if ( ( ( U32 ) ( ( dictLimit - 1 ) - repIndex ) > = 3 ) & ( repIndex > lowestIndex ) ) / * intentional overflow * / <nl> + if ( MEM_read32 ( ip ) = = MEM_read32 ( repMatch ) ) { <nl> + / * repcode detected * / <nl> + const BYTE * const repEnd = repIndex < dictLimit ? dictEnd : iend ; <nl> + size_t const repLength = ZSTD_count_2segments ( ip + 4 , repMatch + 4 , iend , repEnd , prefixStart ) + 4 ; <nl> + int const gain2 = ( int ) ( repLength * 3 ) ; <nl> + int const gain1 = ( int ) ( matchLength * 3 - ZSTD_highbit32 ( ( U32 ) offset + 1 ) + 1 ) ; <nl> + if ( ( repLength > = 4 ) & & ( gain2 > gain1 ) ) <nl> + matchLength = repLength , offset = 0 , start = ip ; <nl> + } } <nl> + <nl> + / * search match , depth 1 * / <nl> + { size_t offset2 = 99999999 ; <nl> + size_t const ml2 = searchMax ( ctx , ip , iend , & offset2 , maxSearches , mls ) ; <nl> + int const gain2 = ( int ) ( ml2 * 4 - ZSTD_highbit32 ( ( U32 ) offset2 + 1 ) ) ; / * raw approx * / <nl> + int const gain1 = ( int ) ( matchLength * 4 - ZSTD_highbit32 ( ( U32 ) offset + 1 ) + 4 ) ; <nl> + if ( ( ml2 > = 4 ) & & ( gain2 > gain1 ) ) { <nl> + matchLength = ml2 , offset = offset2 , start = ip ; <nl> + continue ; / * search a better one * / <nl> + } } <nl> + <nl> + / * let ' s find an even better one * / <nl> + if ( ( depth = = 2 ) & & ( ip < ilimit ) ) { <nl> + ip + + ; <nl> + current + + ; <nl> + / * check repCode * / <nl> + if ( offset ) { <nl> + const U32 repIndex = ( U32 ) ( current - offset_1 ) ; <nl> + const BYTE * const repBase = repIndex < dictLimit ? dictBase : base ; <nl> + const BYTE * const repMatch = repBase + repIndex ; <nl> + if ( ( ( U32 ) ( ( dictLimit - 1 ) - repIndex ) > = 3 ) & ( repIndex > lowestIndex ) ) / * intentional overflow * / <nl> + if ( MEM_read32 ( ip ) = = MEM_read32 ( repMatch ) ) { <nl> + / * repcode detected * / <nl> + const BYTE * const repEnd = repIndex < dictLimit ? dictEnd : iend ; <nl> + size_t const repLength = ZSTD_count_2segments ( ip + 4 , repMatch + 4 , iend , repEnd , prefixStart ) + 4 ; <nl> + int const gain2 = ( int ) ( repLength * 4 ) ; <nl> + int const gain1 = ( int ) ( matchLength * 4 - ZSTD_highbit32 ( ( U32 ) offset + 1 ) + 1 ) ; <nl> + if ( ( repLength > = 4 ) & & ( gain2 > gain1 ) ) <nl> + matchLength = repLength , offset = 0 , start = ip ; <nl> + } } <nl> + <nl> + / * search match , depth 2 * / <nl> + { size_t offset2 = 99999999 ; <nl> + size_t const ml2 = searchMax ( ctx , ip , iend , & offset2 , maxSearches , mls ) ; <nl> + int const gain2 = ( int ) ( ml2 * 4 - ZSTD_highbit32 ( ( U32 ) offset2 + 1 ) ) ; / * raw approx * / <nl> + int const gain1 = ( int ) ( matchLength * 4 - ZSTD_highbit32 ( ( U32 ) offset + 1 ) + 7 ) ; <nl> + if ( ( ml2 > = 4 ) & & ( gain2 > gain1 ) ) { <nl> + matchLength = ml2 , offset = offset2 , start = ip ; <nl> + continue ; <nl> + } } } <nl> + break ; / * nothing found : store previous solution * / <nl> + } <nl> + <nl> + / * catch up * / <nl> + if ( offset ) { <nl> + U32 const matchIndex = ( U32 ) ( ( start - base ) - ( offset - ZSTD_REP_MOVE ) ) ; <nl> + const BYTE * match = ( matchIndex < dictLimit ) ? dictBase + matchIndex : base + matchIndex ; <nl> + const BYTE * const mStart = ( matchIndex < dictLimit ) ? dictStart : prefixStart ; <nl> + while ( ( start > anchor ) & & ( match > mStart ) & & ( start [ - 1 ] = = match [ - 1 ] ) ) { start - - ; match - - ; matchLength + + ; } / * catch up * / <nl> + offset_2 = offset_1 ; offset_1 = ( U32 ) ( offset - ZSTD_REP_MOVE ) ; <nl> + } <nl> + <nl> + / * store sequence * / <nl> + _storeSequence : <nl> + { size_t const litLength = start - anchor ; <nl> + ZSTD_storeSeq ( seqStorePtr , litLength , anchor , ( U32 ) offset , matchLength - MINMATCH ) ; <nl> + anchor = ip = start + matchLength ; <nl> + } <nl> + <nl> + / * check immediate repcode * / <nl> + while ( ip < = ilimit ) { <nl> + const U32 repIndex = ( U32 ) ( ( ip - base ) - offset_2 ) ; <nl> + const BYTE * const repBase = repIndex < dictLimit ? dictBase : base ; <nl> + const BYTE * const repMatch = repBase + repIndex ; <nl> + if ( ( ( U32 ) ( ( dictLimit - 1 ) - repIndex ) > = 3 ) & ( repIndex > lowestIndex ) ) / * intentional overflow * / <nl> + if ( MEM_read32 ( ip ) = = MEM_read32 ( repMatch ) ) { <nl> + / * repcode detected we should take it * / <nl> + const BYTE * const repEnd = repIndex < dictLimit ? dictEnd : iend ; <nl> + matchLength = ZSTD_count_2segments ( ip + 4 , repMatch + 4 , iend , repEnd , prefixStart ) + 4 ; <nl> + offset = offset_2 ; offset_2 = offset_1 ; offset_1 = ( U32 ) offset ; / * swap offset history * / <nl> + ZSTD_storeSeq ( seqStorePtr , 0 , anchor , 0 , matchLength - MINMATCH ) ; <nl> + ip + = matchLength ; <nl> + anchor = ip ; <nl> + continue ; / * faster when present . . . ( ? ) * / <nl> + } <nl> + break ; <nl> + } } <nl> + <nl> + / * Save reps for next block * / <nl> + ctx - > repToConfirm [ 0 ] = offset_1 ; ctx - > repToConfirm [ 1 ] = offset_2 ; <nl> + <nl> + / * Last Literals * / <nl> + { size_t const lastLLSize = iend - anchor ; <nl> + memcpy ( seqStorePtr - > lit , anchor , lastLLSize ) ; <nl> + seqStorePtr - > lit + = lastLLSize ; <nl> + } <nl> + } <nl> + <nl> + <nl> + void ZSTD_compressBlock_greedy_extDict ( ZSTD_CCtx * ctx , const void * src , size_t srcSize ) <nl> + { <nl> + ZSTD_compressBlock_lazy_extDict_generic ( ctx , src , srcSize , 0 , 0 ) ; <nl> + } <nl> + <nl> + static void ZSTD_compressBlock_lazy_extDict ( ZSTD_CCtx * ctx , const void * src , size_t srcSize ) <nl> + { <nl> + ZSTD_compressBlock_lazy_extDict_generic ( ctx , src , srcSize , 0 , 1 ) ; <nl> + } <nl> + <nl> + static void ZSTD_compressBlock_lazy2_extDict ( ZSTD_CCtx * ctx , const void * src , size_t srcSize ) <nl> + { <nl> + ZSTD_compressBlock_lazy_extDict_generic ( ctx , src , srcSize , 0 , 2 ) ; <nl> + } <nl> + <nl> + static void ZSTD_compressBlock_btlazy2_extDict ( ZSTD_CCtx * ctx , const void * src , size_t srcSize ) <nl> + { <nl> + ZSTD_compressBlock_lazy_extDict_generic ( ctx , src , srcSize , 1 , 2 ) ; <nl> + } <nl> + <nl> + <nl> + / * The optimal parser * / <nl> + # include " zstd_opt . h " <nl> + <nl> + static void ZSTD_compressBlock_btopt ( ZSTD_CCtx * ctx , const void * src , size_t srcSize ) <nl> + { <nl> + # ifdef ZSTD_OPT_H_91842398743 <nl> + ZSTD_compressBlock_opt_generic ( ctx , src , srcSize , 0 ) ; <nl> + # else <nl> + ( void ) ctx ; ( void ) src ; ( void ) srcSize ; <nl> + return ; <nl> + # endif <nl> + } <nl> + <nl> + static void ZSTD_compressBlock_btopt2 ( ZSTD_CCtx * ctx , const void * src , size_t srcSize ) <nl> + { <nl> + # ifdef ZSTD_OPT_H_91842398743 <nl> + ZSTD_compressBlock_opt_generic ( ctx , src , srcSize , 1 ) ; <nl> + # else <nl> + ( void ) ctx ; ( void ) src ; ( void ) srcSize ; <nl> + return ; <nl> + # endif <nl> + } <nl> + <nl> + static void ZSTD_compressBlock_btopt_extDict ( ZSTD_CCtx * ctx , const void * src , size_t srcSize ) <nl> + { <nl> + # ifdef ZSTD_OPT_H_91842398743 <nl> + ZSTD_compressBlock_opt_extDict_generic ( ctx , src , srcSize , 0 ) ; <nl> + # else <nl> + ( void ) ctx ; ( void ) src ; ( void ) srcSize ; <nl> + return ; <nl> + # endif <nl> + } <nl> + <nl> + static void ZSTD_compressBlock_btopt2_extDict ( ZSTD_CCtx * ctx , const void * src , size_t srcSize ) <nl> + { <nl> + # ifdef ZSTD_OPT_H_91842398743 <nl> + ZSTD_compressBlock_opt_extDict_generic ( ctx , src , srcSize , 1 ) ; <nl> + # else <nl> + ( void ) ctx ; ( void ) src ; ( void ) srcSize ; <nl> + return ; <nl> + # endif <nl> + } <nl> + <nl> + <nl> + typedef void ( * ZSTD_blockCompressor ) ( ZSTD_CCtx * ctx , const void * src , size_t srcSize ) ; <nl> + <nl> + static ZSTD_blockCompressor ZSTD_selectBlockCompressor ( ZSTD_strategy strat , int extDict ) <nl> + { <nl> + static const ZSTD_blockCompressor blockCompressor [ 2 ] [ 8 ] = { <nl> + { ZSTD_compressBlock_fast , ZSTD_compressBlock_doubleFast , ZSTD_compressBlock_greedy , <nl> + ZSTD_compressBlock_lazy , ZSTD_compressBlock_lazy2 , ZSTD_compressBlock_btlazy2 , <nl> + ZSTD_compressBlock_btopt , ZSTD_compressBlock_btopt2 } , <nl> + { ZSTD_compressBlock_fast_extDict , ZSTD_compressBlock_doubleFast_extDict , ZSTD_compressBlock_greedy_extDict , <nl> + ZSTD_compressBlock_lazy_extDict , ZSTD_compressBlock_lazy2_extDict , ZSTD_compressBlock_btlazy2_extDict , <nl> + ZSTD_compressBlock_btopt_extDict , ZSTD_compressBlock_btopt2_extDict } <nl> + } ; <nl> + <nl> + return blockCompressor [ extDict ] [ ( U32 ) strat ] ; <nl> + } <nl> + <nl> + <nl> + static size_t ZSTD_compressBlock_internal ( ZSTD_CCtx * zc , void * dst , size_t dstCapacity , const void * src , size_t srcSize ) <nl> + { <nl> + ZSTD_blockCompressor const blockCompressor = ZSTD_selectBlockCompressor ( zc - > params . cParams . strategy , zc - > lowLimit < zc - > dictLimit ) ; <nl> + const BYTE * const base = zc - > base ; <nl> + const BYTE * const istart = ( const BYTE * ) src ; <nl> + const U32 current = ( U32 ) ( istart - base ) ; <nl> + if ( srcSize < MIN_CBLOCK_SIZE + ZSTD_blockHeaderSize + 1 ) return 0 ; / * don ' t even attempt compression below a certain srcSize * / <nl> + ZSTD_resetSeqStore ( & ( zc - > seqStore ) ) ; <nl> + if ( current > zc - > nextToUpdate + 384 ) <nl> + zc - > nextToUpdate = current - MIN ( 192 , ( U32 ) ( current - zc - > nextToUpdate - 384 ) ) ; / * limited update after finding a very long match * / <nl> + blockCompressor ( zc , src , srcSize ) ; <nl> + return ZSTD_compressSequences ( zc , dst , dstCapacity , srcSize ) ; <nl> + } <nl> + <nl> + <nl> + / * ! ZSTD_compress_generic ( ) : <nl> + * Compress a chunk of data into one or multiple blocks . <nl> + * All blocks will be terminated , all input will be consumed . <nl> + * Function will issue an error if there is not enough ` dstCapacity ` to hold the compressed content . <nl> + * Frame is supposed already started ( header already produced ) <nl> + * @ return : compressed size , or an error code <nl> + * / <nl> + static size_t ZSTD_compress_generic ( ZSTD_CCtx * cctx , <nl> + void * dst , size_t dstCapacity , <nl> + const void * src , size_t srcSize , <nl> + U32 lastFrameChunk ) <nl> + { <nl> + size_t blockSize = cctx - > blockSize ; <nl> + size_t remaining = srcSize ; <nl> + const BYTE * ip = ( const BYTE * ) src ; <nl> + BYTE * const ostart = ( BYTE * ) dst ; <nl> + BYTE * op = ostart ; <nl> + U32 const maxDist = 1 < < cctx - > params . cParams . windowLog ; <nl> + <nl> + if ( cctx - > params . fParams . checksumFlag & & srcSize ) <nl> + XXH64_update ( & cctx - > xxhState , src , srcSize ) ; <nl> + <nl> + while ( remaining ) { <nl> + U32 const lastBlock = lastFrameChunk & ( blockSize > = remaining ) ; <nl> + size_t cSize ; <nl> + <nl> + if ( dstCapacity < ZSTD_blockHeaderSize + MIN_CBLOCK_SIZE ) <nl> + return ERROR ( dstSize_tooSmall ) ; / * not enough space to store compressed block * / <nl> + if ( remaining < blockSize ) blockSize = remaining ; <nl> + <nl> + / * preemptive overflow correction * / <nl> + if ( cctx - > lowLimit > ( 3U < < 29 ) ) { <nl> + U32 const cycleMask = ( 1 < < ZSTD_cycleLog ( cctx - > params . cParams . hashLog , cctx - > params . cParams . strategy ) ) - 1 ; <nl> + U32 const current = ( U32 ) ( ip - cctx - > base ) ; <nl> + U32 const newCurrent = ( current & cycleMask ) + ( 1 < < cctx - > params . cParams . windowLog ) ; <nl> + U32 const correction = current - newCurrent ; <nl> + ZSTD_STATIC_ASSERT ( ZSTD_WINDOWLOG_MAX_64 < = 30 ) ; <nl> + ZSTD_reduceIndex ( cctx , correction ) ; <nl> + cctx - > base + = correction ; <nl> + cctx - > dictBase + = correction ; <nl> + cctx - > lowLimit - = correction ; <nl> + cctx - > dictLimit - = correction ; <nl> + if ( cctx - > nextToUpdate < correction ) cctx - > nextToUpdate = 0 ; <nl> + else cctx - > nextToUpdate - = correction ; <nl> + } <nl> + <nl> + if ( ( U32 ) ( ip + blockSize - cctx - > base ) > cctx - > loadedDictEnd + maxDist ) { <nl> + / * enforce maxDist * / <nl> + U32 const newLowLimit = ( U32 ) ( ip + blockSize - cctx - > base ) - maxDist ; <nl> + if ( cctx - > lowLimit < newLowLimit ) cctx - > lowLimit = newLowLimit ; <nl> + if ( cctx - > dictLimit < cctx - > lowLimit ) cctx - > dictLimit = cctx - > lowLimit ; <nl> + } <nl> + <nl> + cSize = ZSTD_compressBlock_internal ( cctx , op + ZSTD_blockHeaderSize , dstCapacity - ZSTD_blockHeaderSize , ip , blockSize ) ; <nl> + if ( ZSTD_isError ( cSize ) ) return cSize ; <nl> + <nl> + if ( cSize = = 0 ) { / * block is not compressible * / <nl> + U32 const cBlockHeader24 = lastBlock + ( ( ( U32 ) bt_raw ) < < 1 ) + ( U32 ) ( blockSize < < 3 ) ; <nl> + if ( blockSize + ZSTD_blockHeaderSize > dstCapacity ) return ERROR ( dstSize_tooSmall ) ; <nl> + MEM_writeLE32 ( op , cBlockHeader24 ) ; / * no pb , 4th byte will be overwritten * / <nl> + memcpy ( op + ZSTD_blockHeaderSize , ip , blockSize ) ; <nl> + cSize = ZSTD_blockHeaderSize + blockSize ; <nl> + } else { <nl> + U32 const cBlockHeader24 = lastBlock + ( ( ( U32 ) bt_compressed ) < < 1 ) + ( U32 ) ( cSize < < 3 ) ; <nl> + MEM_writeLE24 ( op , cBlockHeader24 ) ; <nl> + cSize + = ZSTD_blockHeaderSize ; <nl> + } <nl> + <nl> + remaining - = blockSize ; <nl> + dstCapacity - = cSize ; <nl> + ip + = blockSize ; <nl> + op + = cSize ; <nl> + } <nl> + <nl> + if ( lastFrameChunk & & ( op > ostart ) ) cctx - > stage = ZSTDcs_ending ; <nl> + return op - ostart ; <nl> + } <nl> + <nl> + <nl> + static size_t ZSTD_writeFrameHeader ( void * dst , size_t dstCapacity , <nl> + ZSTD_parameters params , U64 pledgedSrcSize , U32 dictID ) <nl> + { BYTE * const op = ( BYTE * ) dst ; <nl> + U32 const dictIDSizeCodeLength = ( dictID > 0 ) + ( dictID > = 256 ) + ( dictID > = 65536 ) ; / * 0 - 3 * / <nl> + U32 const dictIDSizeCode = params . fParams . noDictIDFlag ? 0 : dictIDSizeCodeLength ; / * 0 - 3 * / <nl> + U32 const checksumFlag = params . fParams . checksumFlag > 0 ; <nl> + U32 const windowSize = 1U < < params . cParams . windowLog ; <nl> + U32 const singleSegment = params . fParams . contentSizeFlag & & ( windowSize > = pledgedSrcSize ) ; <nl> + BYTE const windowLogByte = ( BYTE ) ( ( params . cParams . windowLog - ZSTD_WINDOWLOG_ABSOLUTEMIN ) < < 3 ) ; <nl> + U32 const fcsCode = params . fParams . contentSizeFlag ? <nl> + ( pledgedSrcSize > = 256 ) + ( pledgedSrcSize > = 65536 + 256 ) + ( pledgedSrcSize > = 0xFFFFFFFFU ) : / * 0 - 3 * / <nl> + 0 ; <nl> + BYTE const frameHeaderDecriptionByte = ( BYTE ) ( dictIDSizeCode + ( checksumFlag < < 2 ) + ( singleSegment < < 5 ) + ( fcsCode < < 6 ) ) ; <nl> + size_t pos ; <nl> + <nl> + if ( dstCapacity < ZSTD_frameHeaderSize_max ) return ERROR ( dstSize_tooSmall ) ; <nl> + DEBUGLOG ( 5 , " ZSTD_writeFrameHeader : dictIDFlag : % u \ n " , ! params . fParams . noDictIDFlag ) ; <nl> + DEBUGLOG ( 5 , " ZSTD_writeFrameHeader : dictID : % u \ n " , dictID ) ; <nl> + DEBUGLOG ( 5 , " ZSTD_writeFrameHeader : dictIDSizeCode : % u \ n " , dictIDSizeCode ) ; <nl> + <nl> + MEM_writeLE32 ( dst , ZSTD_MAGICNUMBER ) ; <nl> + op [ 4 ] = frameHeaderDecriptionByte ; pos = 5 ; <nl> + if ( ! singleSegment ) op [ pos + + ] = windowLogByte ; <nl> + switch ( dictIDSizeCode ) <nl> + { <nl> + default : / * impossible * / <nl> + case 0 : break ; <nl> + case 1 : op [ pos ] = ( BYTE ) ( dictID ) ; pos + + ; break ; <nl> + case 2 : MEM_writeLE16 ( op + pos , ( U16 ) dictID ) ; pos + = 2 ; break ; <nl> + case 3 : MEM_writeLE32 ( op + pos , dictID ) ; pos + = 4 ; break ; <nl> + } <nl> + switch ( fcsCode ) <nl> + { <nl> + default : / * impossible * / <nl> + case 0 : if ( singleSegment ) op [ pos + + ] = ( BYTE ) ( pledgedSrcSize ) ; break ; <nl> + case 1 : MEM_writeLE16 ( op + pos , ( U16 ) ( pledgedSrcSize - 256 ) ) ; pos + = 2 ; break ; <nl> + case 2 : MEM_writeLE32 ( op + pos , ( U32 ) ( pledgedSrcSize ) ) ; pos + = 4 ; break ; <nl> + case 3 : MEM_writeLE64 ( op + pos , ( U64 ) ( pledgedSrcSize ) ) ; pos + = 8 ; break ; <nl> + } <nl> + return pos ; <nl> + } <nl> + <nl> + <nl> + static size_t ZSTD_compressContinue_internal ( ZSTD_CCtx * cctx , <nl> + void * dst , size_t dstCapacity , <nl> + const void * src , size_t srcSize , <nl> + U32 frame , U32 lastFrameChunk ) <nl> + { <nl> + const BYTE * const ip = ( const BYTE * ) src ; <nl> + size_t fhSize = 0 ; <nl> + <nl> + if ( cctx - > stage = = ZSTDcs_created ) return ERROR ( stage_wrong ) ; / * missing init ( ZSTD_compressBegin ) * / <nl> + <nl> + if ( frame & & ( cctx - > stage = = ZSTDcs_init ) ) { <nl> + fhSize = ZSTD_writeFrameHeader ( dst , dstCapacity , cctx - > params , cctx - > frameContentSize , cctx - > dictID ) ; <nl> + if ( ZSTD_isError ( fhSize ) ) return fhSize ; <nl> + dstCapacity - = fhSize ; <nl> + dst = ( char * ) dst + fhSize ; <nl> + cctx - > stage = ZSTDcs_ongoing ; <nl> + } <nl> + <nl> + / * Check if blocks follow each other * / <nl> + if ( src ! = cctx - > nextSrc ) { <nl> + / * not contiguous * / <nl> + ptrdiff_t const delta = cctx - > nextSrc - ip ; <nl> + cctx - > lowLimit = cctx - > dictLimit ; <nl> + cctx - > dictLimit = ( U32 ) ( cctx - > nextSrc - cctx - > base ) ; <nl> + cctx - > dictBase = cctx - > base ; <nl> + cctx - > base - = delta ; <nl> + cctx - > nextToUpdate = cctx - > dictLimit ; <nl> + if ( cctx - > dictLimit - cctx - > lowLimit < HASH_READ_SIZE ) cctx - > lowLimit = cctx - > dictLimit ; / * too small extDict * / <nl> + } <nl> + <nl> + / * if input and dictionary overlap : reduce dictionary ( area presumed modified by input ) * / <nl> + if ( ( ip + srcSize > cctx - > dictBase + cctx - > lowLimit ) & ( ip < cctx - > dictBase + cctx - > dictLimit ) ) { <nl> + ptrdiff_t const highInputIdx = ( ip + srcSize ) - cctx - > dictBase ; <nl> + U32 const lowLimitMax = ( highInputIdx > ( ptrdiff_t ) cctx - > dictLimit ) ? cctx - > dictLimit : ( U32 ) highInputIdx ; <nl> + cctx - > lowLimit = lowLimitMax ; <nl> + } <nl> + <nl> + cctx - > nextSrc = ip + srcSize ; <nl> + <nl> + if ( srcSize ) { <nl> + size_t const cSize = frame ? <nl> + ZSTD_compress_generic ( cctx , dst , dstCapacity , src , srcSize , lastFrameChunk ) : <nl> + ZSTD_compressBlock_internal ( cctx , dst , dstCapacity , src , srcSize ) ; <nl> + if ( ZSTD_isError ( cSize ) ) return cSize ; <nl> + cctx - > consumedSrcSize + = srcSize ; <nl> + return cSize + fhSize ; <nl> + } else <nl> + return fhSize ; <nl> + } <nl> + <nl> + <nl> + size_t ZSTD_compressContinue ( ZSTD_CCtx * cctx , <nl> + void * dst , size_t dstCapacity , <nl> + const void * src , size_t srcSize ) <nl> + { <nl> + return ZSTD_compressContinue_internal ( cctx , dst , dstCapacity , src , srcSize , 1 / * frame mode * / , 0 / * last chunk * / ) ; <nl> + } <nl> + <nl> + <nl> + size_t ZSTD_getBlockSizeMax ( ZSTD_CCtx * cctx ) <nl> + { <nl> + return MIN ( ZSTD_BLOCKSIZE_ABSOLUTEMAX , 1 < < cctx - > params . cParams . windowLog ) ; <nl> + } <nl> + <nl> + size_t ZSTD_compressBlock ( ZSTD_CCtx * cctx , void * dst , size_t dstCapacity , const void * src , size_t srcSize ) <nl> + { <nl> + size_t const blockSizeMax = ZSTD_getBlockSizeMax ( cctx ) ; <nl> + if ( srcSize > blockSizeMax ) return ERROR ( srcSize_wrong ) ; <nl> + return ZSTD_compressContinue_internal ( cctx , dst , dstCapacity , src , srcSize , 0 / * frame mode * / , 0 / * last chunk * / ) ; <nl> + } <nl> + <nl> + / * ! ZSTD_loadDictionaryContent ( ) : <nl> + * @ return : 0 , or an error code <nl> + * / <nl> + static size_t ZSTD_loadDictionaryContent ( ZSTD_CCtx * zc , const void * src , size_t srcSize ) <nl> + { <nl> + const BYTE * const ip = ( const BYTE * ) src ; <nl> + const BYTE * const iend = ip + srcSize ; <nl> + <nl> + / * input becomes current prefix * / <nl> + zc - > lowLimit = zc - > dictLimit ; <nl> + zc - > dictLimit = ( U32 ) ( zc - > nextSrc - zc - > base ) ; <nl> + zc - > dictBase = zc - > base ; <nl> + zc - > base + = ip - zc - > nextSrc ; <nl> + zc - > nextToUpdate = zc - > dictLimit ; <nl> + zc - > loadedDictEnd = zc - > forceWindow ? 0 : ( U32 ) ( iend - zc - > base ) ; <nl> + <nl> + zc - > nextSrc = iend ; <nl> + if ( srcSize < = HASH_READ_SIZE ) return 0 ; <nl> + <nl> + switch ( zc - > params . cParams . strategy ) <nl> + { <nl> + case ZSTD_fast : <nl> + ZSTD_fillHashTable ( zc , iend , zc - > params . cParams . searchLength ) ; <nl> + break ; <nl> + <nl> + case ZSTD_dfast : <nl> + ZSTD_fillDoubleHashTable ( zc , iend , zc - > params . cParams . searchLength ) ; <nl> + break ; <nl> + <nl> + case ZSTD_greedy : <nl> + case ZSTD_lazy : <nl> + case ZSTD_lazy2 : <nl> + if ( srcSize > = HASH_READ_SIZE ) <nl> + ZSTD_insertAndFindFirstIndex ( zc , iend - HASH_READ_SIZE , zc - > params . cParams . searchLength ) ; <nl> + break ; <nl> + <nl> + case ZSTD_btlazy2 : <nl> + case ZSTD_btopt : <nl> + case ZSTD_btopt2 : <nl> + if ( srcSize > = HASH_READ_SIZE ) <nl> + ZSTD_updateTree ( zc , iend - HASH_READ_SIZE , iend , 1 < < zc - > params . cParams . searchLog , zc - > params . cParams . searchLength ) ; <nl> + break ; <nl> + <nl> + default : <nl> + return ERROR ( GENERIC ) ; / * strategy doesn ' t exist ; impossible * / <nl> + } <nl> + <nl> + zc - > nextToUpdate = ( U32 ) ( iend - zc - > base ) ; <nl> + return 0 ; <nl> + } <nl> + <nl> + <nl> + / * Dictionaries that assign zero probability to symbols that show up causes problems <nl> + when FSE encoding . Refuse dictionaries that assign zero probability to symbols <nl> + that we may encounter during compression . <nl> + NOTE : This behavior is not standard and could be improved in the future . * / <nl> + static size_t ZSTD_checkDictNCount ( short * normalizedCounter , unsigned dictMaxSymbolValue , unsigned maxSymbolValue ) { <nl> + U32 s ; <nl> + if ( dictMaxSymbolValue < maxSymbolValue ) return ERROR ( dictionary_corrupted ) ; <nl> + for ( s = 0 ; s < = maxSymbolValue ; + + s ) { <nl> + if ( normalizedCounter [ s ] = = 0 ) return ERROR ( dictionary_corrupted ) ; <nl> + } <nl> + return 0 ; <nl> + } <nl> + <nl> + <nl> + / * Dictionary format : <nl> + * See : <nl> + * https : / / github . com / facebook / zstd / blob / master / doc / zstd_compression_format . md # dictionary - format <nl> + * / <nl> + / * ! ZSTD_loadZstdDictionary ( ) : <nl> + * @ return : 0 , or an error code <nl> + * assumptions : magic number supposed already checked <nl> + * dictSize supposed > 8 <nl> + * / <nl> + static size_t ZSTD_loadZstdDictionary ( ZSTD_CCtx * cctx , const void * dict , size_t dictSize ) <nl> + { <nl> + const BYTE * dictPtr = ( const BYTE * ) dict ; <nl> + const BYTE * const dictEnd = dictPtr + dictSize ; <nl> + short offcodeNCount [ MaxOff + 1 ] ; <nl> + unsigned offcodeMaxValue = MaxOff ; <nl> + BYTE scratchBuffer [ 1 < < MAX ( MLFSELog , LLFSELog ) ] ; <nl> + <nl> + dictPtr + = 4 ; / * skip magic number * / <nl> + cctx - > dictID = cctx - > params . fParams . noDictIDFlag ? 0 : MEM_readLE32 ( dictPtr ) ; <nl> + dictPtr + = 4 ; <nl> + <nl> + { size_t const hufHeaderSize = HUF_readCTable ( cctx - > hufCTable , 255 , dictPtr , dictEnd - dictPtr ) ; <nl> + if ( HUF_isError ( hufHeaderSize ) ) return ERROR ( dictionary_corrupted ) ; <nl> + dictPtr + = hufHeaderSize ; <nl> + } <nl> + <nl> + { unsigned offcodeLog ; <nl> + size_t const offcodeHeaderSize = FSE_readNCount ( offcodeNCount , & offcodeMaxValue , & offcodeLog , dictPtr , dictEnd - dictPtr ) ; <nl> + if ( FSE_isError ( offcodeHeaderSize ) ) return ERROR ( dictionary_corrupted ) ; <nl> + if ( offcodeLog > OffFSELog ) return ERROR ( dictionary_corrupted ) ; <nl> + / * Defer checking offcodeMaxValue because we need to know the size of the dictionary content * / <nl> + CHECK_E ( FSE_buildCTable_wksp ( cctx - > offcodeCTable , offcodeNCount , offcodeMaxValue , offcodeLog , scratchBuffer , sizeof ( scratchBuffer ) ) , <nl> + dictionary_corrupted ) ; <nl> + dictPtr + = offcodeHeaderSize ; <nl> + } <nl> + <nl> + { short matchlengthNCount [ MaxML + 1 ] ; <nl> + unsigned matchlengthMaxValue = MaxML , matchlengthLog ; <nl> + size_t const matchlengthHeaderSize = FSE_readNCount ( matchlengthNCount , & matchlengthMaxValue , & matchlengthLog , dictPtr , dictEnd - dictPtr ) ; <nl> + if ( FSE_isError ( matchlengthHeaderSize ) ) return ERROR ( dictionary_corrupted ) ; <nl> + if ( matchlengthLog > MLFSELog ) return ERROR ( dictionary_corrupted ) ; <nl> + / * Every match length code must have non - zero probability * / <nl> + CHECK_F ( ZSTD_checkDictNCount ( matchlengthNCount , matchlengthMaxValue , MaxML ) ) ; <nl> + CHECK_E ( FSE_buildCTable_wksp ( cctx - > matchlengthCTable , matchlengthNCount , matchlengthMaxValue , matchlengthLog , scratchBuffer , sizeof ( scratchBuffer ) ) , <nl> + dictionary_corrupted ) ; <nl> + dictPtr + = matchlengthHeaderSize ; <nl> + } <nl> + <nl> + { short litlengthNCount [ MaxLL + 1 ] ; <nl> + unsigned litlengthMaxValue = MaxLL , litlengthLog ; <nl> + size_t const litlengthHeaderSize = FSE_readNCount ( litlengthNCount , & litlengthMaxValue , & litlengthLog , dictPtr , dictEnd - dictPtr ) ; <nl> + if ( FSE_isError ( litlengthHeaderSize ) ) return ERROR ( dictionary_corrupted ) ; <nl> + if ( litlengthLog > LLFSELog ) return ERROR ( dictionary_corrupted ) ; <nl> + / * Every literal length code must have non - zero probability * / <nl> + CHECK_F ( ZSTD_checkDictNCount ( litlengthNCount , litlengthMaxValue , MaxLL ) ) ; <nl> + CHECK_E ( FSE_buildCTable_wksp ( cctx - > litlengthCTable , litlengthNCount , litlengthMaxValue , litlengthLog , scratchBuffer , sizeof ( scratchBuffer ) ) , <nl> + dictionary_corrupted ) ; <nl> + dictPtr + = litlengthHeaderSize ; <nl> + } <nl> + <nl> + if ( dictPtr + 12 > dictEnd ) return ERROR ( dictionary_corrupted ) ; <nl> + cctx - > rep [ 0 ] = MEM_readLE32 ( dictPtr + 0 ) ; <nl> + cctx - > rep [ 1 ] = MEM_readLE32 ( dictPtr + 4 ) ; <nl> + cctx - > rep [ 2 ] = MEM_readLE32 ( dictPtr + 8 ) ; <nl> + dictPtr + = 12 ; <nl> + <nl> + { size_t const dictContentSize = ( size_t ) ( dictEnd - dictPtr ) ; <nl> + U32 offcodeMax = MaxOff ; <nl> + if ( dictContentSize < = ( ( U32 ) - 1 ) - 128 KB ) { <nl> + U32 const maxOffset = ( U32 ) dictContentSize + 128 KB ; / * The maximum offset that must be supported * / <nl> + offcodeMax = ZSTD_highbit32 ( maxOffset ) ; / * Calculate minimum offset code required to represent maxOffset * / <nl> + } <nl> + / * All offset values < = dictContentSize + 128 KB must be representable * / <nl> + CHECK_F ( ZSTD_checkDictNCount ( offcodeNCount , offcodeMaxValue , MIN ( offcodeMax , MaxOff ) ) ) ; <nl> + / * All repCodes must be < = dictContentSize and ! = 0 * / <nl> + { U32 u ; <nl> + for ( u = 0 ; u < 3 ; u + + ) { <nl> + if ( cctx - > rep [ u ] = = 0 ) return ERROR ( dictionary_corrupted ) ; <nl> + if ( cctx - > rep [ u ] > dictContentSize ) return ERROR ( dictionary_corrupted ) ; <nl> + } } <nl> + <nl> + cctx - > fseCTables_ready = 1 ; <nl> + cctx - > hufCTable_repeatMode = HUF_repeat_valid ; <nl> + return ZSTD_loadDictionaryContent ( cctx , dictPtr , dictContentSize ) ; <nl> + } <nl> + } <nl> + <nl> + / * * ZSTD_compress_insertDictionary ( ) : <nl> + * @ return : 0 , or an error code * / <nl> + static size_t ZSTD_compress_insertDictionary ( ZSTD_CCtx * cctx , const void * dict , size_t dictSize ) <nl> + { <nl> + if ( ( dict = = NULL ) | | ( dictSize < = 8 ) ) return 0 ; <nl> + <nl> + / * dict as pure content * / <nl> + if ( ( MEM_readLE32 ( dict ) ! = ZSTD_DICT_MAGIC ) | | ( cctx - > forceRawDict ) ) <nl> + return ZSTD_loadDictionaryContent ( cctx , dict , dictSize ) ; <nl> + <nl> + / * dict as zstd dictionary * / <nl> + return ZSTD_loadZstdDictionary ( cctx , dict , dictSize ) ; <nl> + } <nl> + <nl> + / * ! ZSTD_compressBegin_internal ( ) : <nl> + * @ return : 0 , or an error code * / <nl> + static size_t ZSTD_compressBegin_internal ( ZSTD_CCtx * cctx , <nl> + const void * dict , size_t dictSize , <nl> + ZSTD_parameters params , U64 pledgedSrcSize ) <nl> + { <nl> + ZSTD_compResetPolicy_e const crp = dictSize ? ZSTDcrp_fullReset : ZSTDcrp_continue ; <nl> + assert ( ! ZSTD_isError ( ZSTD_checkCParams ( params . cParams ) ) ) ; <nl> + CHECK_F ( ZSTD_resetCCtx_internal ( cctx , params , pledgedSrcSize , crp ) ) ; <nl> + return ZSTD_compress_insertDictionary ( cctx , dict , dictSize ) ; <nl> + } <nl> + <nl> + <nl> + / * ! ZSTD_compressBegin_advanced ( ) : <nl> + * @ return : 0 , or an error code * / <nl> + size_t ZSTD_compressBegin_advanced ( ZSTD_CCtx * cctx , <nl> + const void * dict , size_t dictSize , <nl> + ZSTD_parameters params , unsigned long long pledgedSrcSize ) <nl> + { <nl> + / * compression parameters verification and optimization * / <nl> + CHECK_F ( ZSTD_checkCParams ( params . cParams ) ) ; <nl> + return ZSTD_compressBegin_internal ( cctx , dict , dictSize , params , pledgedSrcSize ) ; <nl> + } <nl> + <nl> + <nl> + size_t ZSTD_compressBegin_usingDict ( ZSTD_CCtx * cctx , const void * dict , size_t dictSize , int compressionLevel ) <nl> + { <nl> + ZSTD_parameters const params = ZSTD_getParams ( compressionLevel , 0 , dictSize ) ; <nl> + return ZSTD_compressBegin_internal ( cctx , dict , dictSize , params , 0 ) ; <nl> + } <nl> + <nl> + <nl> + size_t ZSTD_compressBegin ( ZSTD_CCtx * cctx , int compressionLevel ) <nl> + { <nl> + return ZSTD_compressBegin_usingDict ( cctx , NULL , 0 , compressionLevel ) ; <nl> + } <nl> + <nl> + <nl> + / * ! ZSTD_writeEpilogue ( ) : <nl> + * Ends a frame . <nl> + * @ return : nb of bytes written into dst ( or an error code ) * / <nl> + static size_t ZSTD_writeEpilogue ( ZSTD_CCtx * cctx , void * dst , size_t dstCapacity ) <nl> + { <nl> + BYTE * const ostart = ( BYTE * ) dst ; <nl> + BYTE * op = ostart ; <nl> + size_t fhSize = 0 ; <nl> + <nl> + if ( cctx - > stage = = ZSTDcs_created ) return ERROR ( stage_wrong ) ; / * init missing * / <nl> + <nl> + / * special case : empty frame * / <nl> + if ( cctx - > stage = = ZSTDcs_init ) { <nl> + fhSize = ZSTD_writeFrameHeader ( dst , dstCapacity , cctx - > params , 0 , 0 ) ; <nl> + if ( ZSTD_isError ( fhSize ) ) return fhSize ; <nl> + dstCapacity - = fhSize ; <nl> + op + = fhSize ; <nl> + cctx - > stage = ZSTDcs_ongoing ; <nl> + } <nl> + <nl> + if ( cctx - > stage ! = ZSTDcs_ending ) { <nl> + / * write one last empty block , make it the " last " block * / <nl> + U32 const cBlockHeader24 = 1 / * last block * / + ( ( ( U32 ) bt_raw ) < < 1 ) + 0 ; <nl> + if ( dstCapacity < 4 ) return ERROR ( dstSize_tooSmall ) ; <nl> + MEM_writeLE32 ( op , cBlockHeader24 ) ; <nl> + op + = ZSTD_blockHeaderSize ; <nl> + dstCapacity - = ZSTD_blockHeaderSize ; <nl> + } <nl> + <nl> + if ( cctx - > params . fParams . checksumFlag ) { <nl> + U32 const checksum = ( U32 ) XXH64_digest ( & cctx - > xxhState ) ; <nl> + if ( dstCapacity < 4 ) return ERROR ( dstSize_tooSmall ) ; <nl> + MEM_writeLE32 ( op , checksum ) ; <nl> + op + = 4 ; <nl> + } <nl> + <nl> + cctx - > stage = ZSTDcs_created ; / * return to " created but no init " status * / <nl> + return op - ostart ; <nl> + } <nl> + <nl> + <nl> + size_t ZSTD_compressEnd ( ZSTD_CCtx * cctx , <nl> + void * dst , size_t dstCapacity , <nl> + const void * src , size_t srcSize ) <nl> + { <nl> + size_t endResult ; <nl> + size_t const cSize = ZSTD_compressContinue_internal ( cctx , dst , dstCapacity , src , srcSize , 1 / * frame mode * / , 1 / * last chunk * / ) ; <nl> + if ( ZSTD_isError ( cSize ) ) return cSize ; <nl> + endResult = ZSTD_writeEpilogue ( cctx , ( char * ) dst + cSize , dstCapacity - cSize ) ; <nl> + if ( ZSTD_isError ( endResult ) ) return endResult ; <nl> + if ( cctx - > params . fParams . contentSizeFlag ) { / * control src size * / <nl> + if ( cctx - > frameContentSize ! = cctx - > consumedSrcSize ) return ERROR ( srcSize_wrong ) ; <nl> + } <nl> + return cSize + endResult ; <nl> + } <nl> + <nl> + <nl> + static size_t ZSTD_compress_internal ( ZSTD_CCtx * cctx , <nl> + void * dst , size_t dstCapacity , <nl> + const void * src , size_t srcSize , <nl> + const void * dict , size_t dictSize , <nl> + ZSTD_parameters params ) <nl> + { <nl> + CHECK_F ( ZSTD_compressBegin_internal ( cctx , dict , dictSize , params , srcSize ) ) ; <nl> + return ZSTD_compressEnd ( cctx , dst , dstCapacity , src , srcSize ) ; <nl> + } <nl> + <nl> + size_t ZSTD_compress_advanced ( ZSTD_CCtx * ctx , <nl> + void * dst , size_t dstCapacity , <nl> + const void * src , size_t srcSize , <nl> + const void * dict , size_t dictSize , <nl> + ZSTD_parameters params ) <nl> + { <nl> + CHECK_F ( ZSTD_checkCParams ( params . cParams ) ) ; <nl> + return ZSTD_compress_internal ( ctx , dst , dstCapacity , src , srcSize , dict , dictSize , params ) ; <nl> + } <nl> + <nl> + size_t ZSTD_compress_usingDict ( ZSTD_CCtx * ctx , void * dst , size_t dstCapacity , const void * src , size_t srcSize , <nl> + const void * dict , size_t dictSize , int compressionLevel ) <nl> + { <nl> + ZSTD_parameters params = ZSTD_getParams ( compressionLevel , srcSize , dict ? dictSize : 0 ) ; <nl> + params . fParams . contentSizeFlag = 1 ; <nl> + return ZSTD_compress_internal ( ctx , dst , dstCapacity , src , srcSize , dict , dictSize , params ) ; <nl> + } <nl> + <nl> + size_t ZSTD_compressCCtx ( ZSTD_CCtx * ctx , void * dst , size_t dstCapacity , const void * src , size_t srcSize , int compressionLevel ) <nl> + { <nl> + return ZSTD_compress_usingDict ( ctx , dst , dstCapacity , src , srcSize , NULL , 0 , compressionLevel ) ; <nl> + } <nl> + <nl> + size_t ZSTD_compress ( void * dst , size_t dstCapacity , const void * src , size_t srcSize , int compressionLevel ) <nl> + { <nl> + size_t result ; <nl> + ZSTD_CCtx ctxBody ; <nl> + memset ( & ctxBody , 0 , sizeof ( ctxBody ) ) ; <nl> + memcpy ( & ctxBody . customMem , & defaultCustomMem , sizeof ( ZSTD_customMem ) ) ; <nl> + result = ZSTD_compressCCtx ( & ctxBody , dst , dstCapacity , src , srcSize , compressionLevel ) ; <nl> + ZSTD_free ( ctxBody . workSpace , defaultCustomMem ) ; / * can ' t free ctxBody itself , as it ' s on stack ; free only heap content * / <nl> + return result ; <nl> + } <nl> + <nl> + <nl> + / * = = = = = Dictionary API = = = = = * / <nl> + <nl> + struct ZSTD_CDict_s { <nl> + void * dictBuffer ; <nl> + const void * dictContent ; <nl> + size_t dictContentSize ; <nl> + ZSTD_CCtx * refContext ; <nl> + } ; / * typedef ' d tp ZSTD_CDict within " zstd . h " * / <nl> + <nl> + size_t ZSTD_sizeof_CDict ( const ZSTD_CDict * cdict ) <nl> + { <nl> + if ( cdict = = NULL ) return 0 ; / * support sizeof on NULL * / <nl> + return ZSTD_sizeof_CCtx ( cdict - > refContext ) + ( cdict - > dictBuffer ? cdict - > dictContentSize : 0 ) + sizeof ( * cdict ) ; <nl> + } <nl> + <nl> + static ZSTD_parameters ZSTD_makeParams ( ZSTD_compressionParameters cParams , ZSTD_frameParameters fParams ) <nl> + { <nl> + ZSTD_parameters params ; <nl> + params . cParams = cParams ; <nl> + params . fParams = fParams ; <nl> + return params ; <nl> + } <nl> + <nl> + ZSTD_CDict * ZSTD_createCDict_advanced ( const void * dictBuffer , size_t dictSize , unsigned byReference , <nl> + ZSTD_compressionParameters cParams , ZSTD_customMem customMem ) <nl> + { <nl> + if ( ! customMem . customAlloc & & ! customMem . customFree ) customMem = defaultCustomMem ; <nl> + if ( ! customMem . customAlloc | | ! customMem . customFree ) return NULL ; <nl> + <nl> + { ZSTD_CDict * const cdict = ( ZSTD_CDict * ) ZSTD_malloc ( sizeof ( ZSTD_CDict ) , customMem ) ; <nl> + ZSTD_CCtx * const cctx = ZSTD_createCCtx_advanced ( customMem ) ; <nl> + <nl> + if ( ! cdict | | ! cctx ) { <nl> + ZSTD_free ( cdict , customMem ) ; <nl> + ZSTD_freeCCtx ( cctx ) ; <nl> + return NULL ; <nl> + } <nl> + <nl> + if ( ( byReference ) | | ( ! dictBuffer ) | | ( ! dictSize ) ) { <nl> + cdict - > dictBuffer = NULL ; <nl> + cdict - > dictContent = dictBuffer ; <nl> + } else { <nl> + void * const internalBuffer = ZSTD_malloc ( dictSize , customMem ) ; <nl> + if ( ! internalBuffer ) { ZSTD_free ( cctx , customMem ) ; ZSTD_free ( cdict , customMem ) ; return NULL ; } <nl> + memcpy ( internalBuffer , dictBuffer , dictSize ) ; <nl> + cdict - > dictBuffer = internalBuffer ; <nl> + cdict - > dictContent = internalBuffer ; <nl> + } <nl> + <nl> + { ZSTD_frameParameters const fParams = { 0 / * contentSizeFlag * / , 0 / * checksumFlag * / , 0 / * noDictIDFlag * / } ; / * dummy * / <nl> + ZSTD_parameters const params = ZSTD_makeParams ( cParams , fParams ) ; <nl> + size_t const errorCode = ZSTD_compressBegin_advanced ( cctx , cdict - > dictContent , dictSize , params , 0 ) ; <nl> + if ( ZSTD_isError ( errorCode ) ) { <nl> + ZSTD_free ( cdict - > dictBuffer , customMem ) ; <nl> + ZSTD_free ( cdict , customMem ) ; <nl> + ZSTD_freeCCtx ( cctx ) ; <nl> + return NULL ; <nl> + } } <nl> + <nl> + cdict - > refContext = cctx ; <nl> + cdict - > dictContentSize = dictSize ; <nl> + return cdict ; <nl> + } <nl> + } <nl> + <nl> + ZSTD_CDict * ZSTD_createCDict ( const void * dict , size_t dictSize , int compressionLevel ) <nl> + { <nl> + ZSTD_customMem const allocator = { NULL , NULL , NULL } ; <nl> + ZSTD_compressionParameters cParams = ZSTD_getCParams ( compressionLevel , 0 , dictSize ) ; <nl> + return ZSTD_createCDict_advanced ( dict , dictSize , 0 , cParams , allocator ) ; <nl> + } <nl> + <nl> + ZSTD_CDict * ZSTD_createCDict_byReference ( const void * dict , size_t dictSize , int compressionLevel ) <nl> + { <nl> + ZSTD_customMem const allocator = { NULL , NULL , NULL } ; <nl> + ZSTD_compressionParameters cParams = ZSTD_getCParams ( compressionLevel , 0 , dictSize ) ; <nl> + return ZSTD_createCDict_advanced ( dict , dictSize , 1 , cParams , allocator ) ; <nl> + } <nl> + <nl> + size_t ZSTD_freeCDict ( ZSTD_CDict * cdict ) <nl> + { <nl> + if ( cdict = = NULL ) return 0 ; / * support free on NULL * / <nl> + { ZSTD_customMem const cMem = cdict - > refContext - > customMem ; <nl> + ZSTD_freeCCtx ( cdict - > refContext ) ; <nl> + ZSTD_free ( cdict - > dictBuffer , cMem ) ; <nl> + ZSTD_free ( cdict , cMem ) ; <nl> + return 0 ; <nl> + } <nl> + } <nl> + <nl> + static ZSTD_parameters ZSTD_getParamsFromCDict ( const ZSTD_CDict * cdict ) { <nl> + return ZSTD_getParamsFromCCtx ( cdict - > refContext ) ; <nl> + } <nl> + <nl> + / * ZSTD_compressBegin_usingCDict_advanced ( ) : <nl> + * cdict must be ! = NULL * / <nl> + size_t ZSTD_compressBegin_usingCDict_advanced ( <nl> + ZSTD_CCtx * const cctx , const ZSTD_CDict * const cdict , <nl> + ZSTD_frameParameters const fParams , unsigned long long const pledgedSrcSize ) <nl> + { <nl> + if ( cdict = = NULL ) return ERROR ( GENERIC ) ; / * does not support NULL cdict * / <nl> + DEBUGLOG ( 5 , " ZSTD_compressBegin_usingCDict_advanced : dictIDFlag = = % u \ n " , ! fParams . noDictIDFlag ) ; <nl> + if ( cdict - > dictContentSize ) <nl> + CHECK_F ( ZSTD_copyCCtx_internal ( cctx , cdict - > refContext , fParams , pledgedSrcSize ) ) <nl> + else { <nl> + ZSTD_parameters params = cdict - > refContext - > params ; <nl> + params . fParams = fParams ; <nl> + CHECK_F ( ZSTD_compressBegin_internal ( cctx , NULL , 0 , params , pledgedSrcSize ) ) ; <nl> + } <nl> + return 0 ; <nl> + } <nl> + <nl> + / * ZSTD_compressBegin_usingCDict ( ) : <nl> + * pledgedSrcSize = 0 means " unknown " <nl> + * if pledgedSrcSize > 0 , it will enable contentSizeFlag * / <nl> + size_t ZSTD_compressBegin_usingCDict ( ZSTD_CCtx * cctx , const ZSTD_CDict * cdict ) <nl> + { <nl> + ZSTD_frameParameters const fParams = { 0 / * content * / , 0 / * checksum * / , 0 / * noDictID * / } ; <nl> + DEBUGLOG ( 5 , " ZSTD_compressBegin_usingCDict : dictIDFlag = = % u \ n " , ! fParams . noDictIDFlag ) ; <nl> + return ZSTD_compressBegin_usingCDict_advanced ( cctx , cdict , fParams , 0 ) ; <nl> + } <nl> + <nl> + size_t ZSTD_compress_usingCDict_advanced ( ZSTD_CCtx * cctx , <nl> + void * dst , size_t dstCapacity , <nl> + const void * src , size_t srcSize , <nl> + const ZSTD_CDict * cdict , ZSTD_frameParameters fParams ) <nl> + { <nl> + CHECK_F ( ZSTD_compressBegin_usingCDict_advanced ( cctx , cdict , fParams , srcSize ) ) ; / * will check if cdict ! = NULL * / <nl> + return ZSTD_compressEnd ( cctx , dst , dstCapacity , src , srcSize ) ; <nl> + } <nl> + <nl> + / * ! ZSTD_compress_usingCDict ( ) : <nl> + * Compression using a digested Dictionary . <nl> + * Faster startup than ZSTD_compress_usingDict ( ) , recommended when same dictionary is used multiple times . <nl> + * Note that compression parameters are decided at CDict creation time <nl> + * while frame parameters are hardcoded * / <nl> + size_t ZSTD_compress_usingCDict ( ZSTD_CCtx * cctx , <nl> + void * dst , size_t dstCapacity , <nl> + const void * src , size_t srcSize , <nl> + const ZSTD_CDict * cdict ) <nl> + { <nl> + ZSTD_frameParameters const fParams = { 1 / * content * / , 0 / * checksum * / , 0 / * noDictID * / } ; <nl> + return ZSTD_compress_usingCDict_advanced ( cctx , dst , dstCapacity , src , srcSize , cdict , fParams ) ; <nl> + } <nl> + <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Streaming <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + typedef enum { zcss_init , zcss_load , zcss_flush , zcss_final } ZSTD_cStreamStage ; <nl> + <nl> + struct ZSTD_CStream_s { <nl> + ZSTD_CCtx * cctx ; <nl> + ZSTD_CDict * cdictLocal ; <nl> + const ZSTD_CDict * cdict ; <nl> + char * inBuff ; <nl> + size_t inBuffSize ; <nl> + size_t inToCompress ; <nl> + size_t inBuffPos ; <nl> + size_t inBuffTarget ; <nl> + size_t blockSize ; <nl> + char * outBuff ; <nl> + size_t outBuffSize ; <nl> + size_t outBuffContentSize ; <nl> + size_t outBuffFlushedSize ; <nl> + ZSTD_cStreamStage stage ; <nl> + U32 checksum ; <nl> + U32 frameEnded ; <nl> + U64 pledgedSrcSize ; <nl> + ZSTD_parameters params ; <nl> + ZSTD_customMem customMem ; <nl> + } ; / * typedef ' d to ZSTD_CStream within " zstd . h " * / <nl> + <nl> + ZSTD_CStream * ZSTD_createCStream ( void ) <nl> + { <nl> + return ZSTD_createCStream_advanced ( defaultCustomMem ) ; <nl> + } <nl> + <nl> + ZSTD_CStream * ZSTD_createCStream_advanced ( ZSTD_customMem customMem ) <nl> + { <nl> + ZSTD_CStream * zcs ; <nl> + <nl> + if ( ! customMem . customAlloc & & ! customMem . customFree ) customMem = defaultCustomMem ; <nl> + if ( ! customMem . customAlloc | | ! customMem . customFree ) return NULL ; <nl> + <nl> + zcs = ( ZSTD_CStream * ) ZSTD_malloc ( sizeof ( ZSTD_CStream ) , customMem ) ; <nl> + if ( zcs = = NULL ) return NULL ; <nl> + memset ( zcs , 0 , sizeof ( ZSTD_CStream ) ) ; <nl> + memcpy ( & zcs - > customMem , & customMem , sizeof ( ZSTD_customMem ) ) ; <nl> + zcs - > cctx = ZSTD_createCCtx_advanced ( customMem ) ; <nl> + if ( zcs - > cctx = = NULL ) { ZSTD_freeCStream ( zcs ) ; return NULL ; } <nl> + return zcs ; <nl> + } <nl> + <nl> + size_t ZSTD_freeCStream ( ZSTD_CStream * zcs ) <nl> + { <nl> + if ( zcs = = NULL ) return 0 ; / * support free on NULL * / <nl> + { ZSTD_customMem const cMem = zcs - > customMem ; <nl> + ZSTD_freeCCtx ( zcs - > cctx ) ; <nl> + zcs - > cctx = NULL ; <nl> + ZSTD_freeCDict ( zcs - > cdictLocal ) ; <nl> + zcs - > cdictLocal = NULL ; <nl> + ZSTD_free ( zcs - > inBuff , cMem ) ; <nl> + zcs - > inBuff = NULL ; <nl> + ZSTD_free ( zcs - > outBuff , cMem ) ; <nl> + zcs - > outBuff = NULL ; <nl> + ZSTD_free ( zcs , cMem ) ; <nl> + return 0 ; <nl> + } <nl> + } <nl> + <nl> + <nl> + / * = = = = = = Initialization = = = = = = * / <nl> + <nl> + size_t ZSTD_CStreamInSize ( void ) { return ZSTD_BLOCKSIZE_ABSOLUTEMAX ; } <nl> + <nl> + size_t ZSTD_CStreamOutSize ( void ) <nl> + { <nl> + return ZSTD_compressBound ( ZSTD_BLOCKSIZE_ABSOLUTEMAX ) + ZSTD_blockHeaderSize + 4 / * 32 - bits hash * / ; <nl> + } <nl> + <nl> + static size_t ZSTD_resetCStream_internal ( ZSTD_CStream * zcs , unsigned long long pledgedSrcSize ) <nl> + { <nl> + if ( zcs - > inBuffSize = = 0 ) return ERROR ( stage_wrong ) ; / * zcs has not been init at least once = > can ' t reset * / <nl> + <nl> + DEBUGLOG ( 5 , " ZSTD_resetCStream_internal : dictIDFlag = = % u \ n " , ! zcs - > params . fParams . noDictIDFlag ) ; <nl> + <nl> + if ( zcs - > cdict ) CHECK_F ( ZSTD_compressBegin_usingCDict_advanced ( zcs - > cctx , zcs - > cdict , zcs - > params . fParams , pledgedSrcSize ) ) <nl> + else CHECK_F ( ZSTD_compressBegin_internal ( zcs - > cctx , NULL , 0 , zcs - > params , pledgedSrcSize ) ) ; <nl> + <nl> + zcs - > inToCompress = 0 ; <nl> + zcs - > inBuffPos = 0 ; <nl> + zcs - > inBuffTarget = zcs - > blockSize ; <nl> + zcs - > outBuffContentSize = zcs - > outBuffFlushedSize = 0 ; <nl> + zcs - > stage = zcss_load ; <nl> + zcs - > frameEnded = 0 ; <nl> + zcs - > pledgedSrcSize = pledgedSrcSize ; <nl> + return 0 ; / * ready to go * / <nl> + } <nl> + <nl> + size_t ZSTD_resetCStream ( ZSTD_CStream * zcs , unsigned long long pledgedSrcSize ) <nl> + { <nl> + <nl> + zcs - > params . fParams . contentSizeFlag = ( pledgedSrcSize > 0 ) ; <nl> + DEBUGLOG ( 5 , " ZSTD_resetCStream : dictIDFlag = = % u \ n " , ! zcs - > params . fParams . noDictIDFlag ) ; <nl> + return ZSTD_resetCStream_internal ( zcs , pledgedSrcSize ) ; <nl> + } <nl> + <nl> + / * ZSTD_initCStream_internal ( ) : <nl> + * params are supposed validated at this stage <nl> + * and zcs - > cdict is supposed to be correct * / <nl> + static size_t ZSTD_initCStream_stage2 ( ZSTD_CStream * zcs , <nl> + const ZSTD_parameters params , <nl> + unsigned long long pledgedSrcSize ) <nl> + { <nl> + assert ( ! ZSTD_isError ( ZSTD_checkCParams ( params . cParams ) ) ) ; <nl> + <nl> + / * allocate buffers * / <nl> + { size_t const neededInBuffSize = ( size_t ) 1 < < params . cParams . windowLog ; <nl> + if ( zcs - > inBuffSize < neededInBuffSize ) { <nl> + zcs - > inBuffSize = 0 ; <nl> + ZSTD_free ( zcs - > inBuff , zcs - > customMem ) ; <nl> + zcs - > inBuff = ( char * ) ZSTD_malloc ( neededInBuffSize , zcs - > customMem ) ; <nl> + if ( zcs - > inBuff = = NULL ) return ERROR ( memory_allocation ) ; <nl> + zcs - > inBuffSize = neededInBuffSize ; <nl> + } <nl> + zcs - > blockSize = MIN ( ZSTD_BLOCKSIZE_ABSOLUTEMAX , neededInBuffSize ) ; <nl> + } <nl> + if ( zcs - > outBuffSize < ZSTD_compressBound ( zcs - > blockSize ) + 1 ) { <nl> + size_t const outBuffSize = ZSTD_compressBound ( zcs - > blockSize ) + 1 ; <nl> + zcs - > outBuffSize = 0 ; <nl> + ZSTD_free ( zcs - > outBuff , zcs - > customMem ) ; <nl> + zcs - > outBuff = ( char * ) ZSTD_malloc ( outBuffSize , zcs - > customMem ) ; <nl> + if ( zcs - > outBuff = = NULL ) return ERROR ( memory_allocation ) ; <nl> + zcs - > outBuffSize = outBuffSize ; <nl> + } <nl> + <nl> + zcs - > checksum = params . fParams . checksumFlag > 0 ; <nl> + zcs - > params = params ; <nl> + <nl> + DEBUGLOG ( 5 , " ZSTD_initCStream_stage2 : dictIDFlag = = % u \ n " , ! params . fParams . noDictIDFlag ) ; <nl> + return ZSTD_resetCStream_internal ( zcs , pledgedSrcSize ) ; <nl> + } <nl> + <nl> + / * ZSTD_initCStream_usingCDict_advanced ( ) : <nl> + * same as ZSTD_initCStream_usingCDict ( ) , with control over frame parameters * / <nl> + size_t ZSTD_initCStream_usingCDict_advanced ( ZSTD_CStream * zcs , const ZSTD_CDict * cdict , unsigned long long pledgedSrcSize , ZSTD_frameParameters fParams ) <nl> + { <nl> + if ( ! cdict ) return ERROR ( GENERIC ) ; / * cannot handle NULL cdict ( does not know what to do ) * / <nl> + { ZSTD_parameters params = ZSTD_getParamsFromCDict ( cdict ) ; <nl> + params . fParams = fParams ; <nl> + zcs - > cdict = cdict ; <nl> + return ZSTD_initCStream_stage2 ( zcs , params , pledgedSrcSize ) ; <nl> + } <nl> + } <nl> + <nl> + / * note : cdict must outlive compression session * / <nl> + size_t ZSTD_initCStream_usingCDict ( ZSTD_CStream * zcs , const ZSTD_CDict * cdict ) <nl> + { <nl> + ZSTD_frameParameters const fParams = { 0 / * content * / , 0 / * checksum * / , 0 / * noDictID * / } ; <nl> + return ZSTD_initCStream_usingCDict_advanced ( zcs , cdict , 0 , fParams ) ; <nl> + } <nl> + <nl> + static size_t ZSTD_initCStream_internal ( ZSTD_CStream * zcs , <nl> + const void * dict , size_t dictSize , <nl> + ZSTD_parameters params , unsigned long long pledgedSrcSize ) <nl> + { <nl> + assert ( ! ZSTD_isError ( ZSTD_checkCParams ( params . cParams ) ) ) ; <nl> + zcs - > cdict = NULL ; <nl> + <nl> + if ( dict & & dictSize > = 8 ) { <nl> + ZSTD_freeCDict ( zcs - > cdictLocal ) ; <nl> + zcs - > cdictLocal = ZSTD_createCDict_advanced ( dict , dictSize , 0 / * copy * / , params . cParams , zcs - > customMem ) ; <nl> + if ( zcs - > cdictLocal = = NULL ) return ERROR ( memory_allocation ) ; <nl> + zcs - > cdict = zcs - > cdictLocal ; <nl> + } <nl> + <nl> + DEBUGLOG ( 5 , " ZSTD_initCStream_internal : dictIDFlag = = % u \ n " , ! params . fParams . noDictIDFlag ) ; <nl> + return ZSTD_initCStream_stage2 ( zcs , params , pledgedSrcSize ) ; <nl> + } <nl> + <nl> + size_t ZSTD_initCStream_advanced ( ZSTD_CStream * zcs , <nl> + const void * dict , size_t dictSize , <nl> + ZSTD_parameters params , unsigned long long pledgedSrcSize ) <nl> + { <nl> + CHECK_F ( ZSTD_checkCParams ( params . cParams ) ) ; <nl> + DEBUGLOG ( 5 , " ZSTD_initCStream_advanced : dictIDFlag = = % u \ n " , ! params . fParams . noDictIDFlag ) ; <nl> + return ZSTD_initCStream_internal ( zcs , dict , dictSize , params , pledgedSrcSize ) ; <nl> + } <nl> + <nl> + size_t ZSTD_initCStream_usingDict ( ZSTD_CStream * zcs , const void * dict , size_t dictSize , int compressionLevel ) <nl> + { <nl> + ZSTD_parameters const params = ZSTD_getParams ( compressionLevel , 0 , dictSize ) ; <nl> + return ZSTD_initCStream_internal ( zcs , dict , dictSize , params , 0 ) ; <nl> + } <nl> + <nl> + size_t ZSTD_initCStream_srcSize ( ZSTD_CStream * zcs , int compressionLevel , unsigned long long pledgedSrcSize ) <nl> + { <nl> + ZSTD_parameters params = ZSTD_getParams ( compressionLevel , pledgedSrcSize , 0 ) ; <nl> + params . fParams . contentSizeFlag = ( pledgedSrcSize > 0 ) ; <nl> + return ZSTD_initCStream_internal ( zcs , NULL , 0 , params , pledgedSrcSize ) ; <nl> + } <nl> + <nl> + size_t ZSTD_initCStream ( ZSTD_CStream * zcs , int compressionLevel ) <nl> + { <nl> + ZSTD_parameters const params = ZSTD_getParams ( compressionLevel , 0 , 0 ) ; <nl> + return ZSTD_initCStream_internal ( zcs , NULL , 0 , params , 0 ) ; <nl> + } <nl> + <nl> + size_t ZSTD_sizeof_CStream ( const ZSTD_CStream * zcs ) <nl> + { <nl> + if ( zcs = = NULL ) return 0 ; / * support sizeof on NULL * / <nl> + return sizeof ( * zcs ) + ZSTD_sizeof_CCtx ( zcs - > cctx ) + ZSTD_sizeof_CDict ( zcs - > cdictLocal ) + zcs - > outBuffSize + zcs - > inBuffSize ; <nl> + } <nl> + <nl> + / * = = = = = = Compression = = = = = = * / <nl> + <nl> + typedef enum { zsf_gather , zsf_flush , zsf_end } ZSTD_flush_e ; <nl> + <nl> + MEM_STATIC size_t ZSTD_limitCopy ( void * dst , size_t dstCapacity , const void * src , size_t srcSize ) <nl> + { <nl> + size_t const length = MIN ( dstCapacity , srcSize ) ; <nl> + memcpy ( dst , src , length ) ; <nl> + return length ; <nl> + } <nl> + <nl> + static size_t ZSTD_compressStream_generic ( ZSTD_CStream * zcs , <nl> + void * dst , size_t * dstCapacityPtr , <nl> + const void * src , size_t * srcSizePtr , <nl> + ZSTD_flush_e const flush ) <nl> + { <nl> + U32 someMoreWork = 1 ; <nl> + const char * const istart = ( const char * ) src ; <nl> + const char * const iend = istart + * srcSizePtr ; <nl> + const char * ip = istart ; <nl> + char * const ostart = ( char * ) dst ; <nl> + char * const oend = ostart + * dstCapacityPtr ; <nl> + char * op = ostart ; <nl> + <nl> + while ( someMoreWork ) { <nl> + switch ( zcs - > stage ) <nl> + { <nl> + case zcss_init : return ERROR ( init_missing ) ; / * call ZBUFF_compressInit ( ) first ! * / <nl> + <nl> + case zcss_load : <nl> + / * complete inBuffer * / <nl> + { size_t const toLoad = zcs - > inBuffTarget - zcs - > inBuffPos ; <nl> + size_t const loaded = ZSTD_limitCopy ( zcs - > inBuff + zcs - > inBuffPos , toLoad , ip , iend - ip ) ; <nl> + zcs - > inBuffPos + = loaded ; <nl> + ip + = loaded ; <nl> + if ( ( zcs - > inBuffPos = = zcs - > inToCompress ) | | ( ! flush & & ( toLoad ! = loaded ) ) ) { <nl> + someMoreWork = 0 ; break ; / * not enough input to get a full block : stop there , wait for more * / <nl> + } } <nl> + / * compress current block ( note : this stage cannot be stopped in the middle ) * / <nl> + { void * cDst ; <nl> + size_t cSize ; <nl> + size_t const iSize = zcs - > inBuffPos - zcs - > inToCompress ; <nl> + size_t oSize = oend - op ; <nl> + if ( oSize > = ZSTD_compressBound ( iSize ) ) <nl> + cDst = op ; / * compress directly into output buffer ( avoid flush stage ) * / <nl> + else <nl> + cDst = zcs - > outBuff , oSize = zcs - > outBuffSize ; <nl> + cSize = ( flush = = zsf_end ) ? <nl> + ZSTD_compressEnd ( zcs - > cctx , cDst , oSize , zcs - > inBuff + zcs - > inToCompress , iSize ) : <nl> + ZSTD_compressContinue ( zcs - > cctx , cDst , oSize , zcs - > inBuff + zcs - > inToCompress , iSize ) ; <nl> + if ( ZSTD_isError ( cSize ) ) return cSize ; <nl> + if ( flush = = zsf_end ) zcs - > frameEnded = 1 ; <nl> + / * prepare next block * / <nl> + zcs - > inBuffTarget = zcs - > inBuffPos + zcs - > blockSize ; <nl> + if ( zcs - > inBuffTarget > zcs - > inBuffSize ) <nl> + zcs - > inBuffPos = 0 , zcs - > inBuffTarget = zcs - > blockSize ; / * note : inBuffSize > = blockSize * / <nl> + zcs - > inToCompress = zcs - > inBuffPos ; <nl> + if ( cDst = = op ) { op + = cSize ; break ; } / * no need to flush * / <nl> + zcs - > outBuffContentSize = cSize ; <nl> + zcs - > outBuffFlushedSize = 0 ; <nl> + zcs - > stage = zcss_flush ; / * pass - through to flush stage * / <nl> + } <nl> + <nl> + case zcss_flush : <nl> + { size_t const toFlush = zcs - > outBuffContentSize - zcs - > outBuffFlushedSize ; <nl> + size_t const flushed = ZSTD_limitCopy ( op , oend - op , zcs - > outBuff + zcs - > outBuffFlushedSize , toFlush ) ; <nl> + op + = flushed ; <nl> + zcs - > outBuffFlushedSize + = flushed ; <nl> + if ( toFlush ! = flushed ) { someMoreWork = 0 ; break ; } / * dst too small to store flushed data : stop there * / <nl> + zcs - > outBuffContentSize = zcs - > outBuffFlushedSize = 0 ; <nl> + zcs - > stage = zcss_load ; <nl> + break ; <nl> + } <nl> + <nl> + case zcss_final : <nl> + someMoreWork = 0 ; / * do nothing * / <nl> + break ; <nl> + <nl> + default : <nl> + return ERROR ( GENERIC ) ; / * impossible * / <nl> + } <nl> + } <nl> + <nl> + * srcSizePtr = ip - istart ; <nl> + * dstCapacityPtr = op - ostart ; <nl> + if ( zcs - > frameEnded ) return 0 ; <nl> + { size_t hintInSize = zcs - > inBuffTarget - zcs - > inBuffPos ; <nl> + if ( hintInSize = = 0 ) hintInSize = zcs - > blockSize ; <nl> + return hintInSize ; <nl> + } <nl> + } <nl> + <nl> + size_t ZSTD_compressStream ( ZSTD_CStream * zcs , ZSTD_outBuffer * output , ZSTD_inBuffer * input ) <nl> + { <nl> + size_t sizeRead = input - > size - input - > pos ; <nl> + size_t sizeWritten = output - > size - output - > pos ; <nl> + size_t const result = ZSTD_compressStream_generic ( zcs , <nl> + ( char * ) ( output - > dst ) + output - > pos , & sizeWritten , <nl> + ( const char * ) ( input - > src ) + input - > pos , & sizeRead , zsf_gather ) ; <nl> + input - > pos + = sizeRead ; <nl> + output - > pos + = sizeWritten ; <nl> + return result ; <nl> + } <nl> + <nl> + <nl> + / * = = = = = = Finalize = = = = = = * / <nl> + <nl> + / * ! ZSTD_flushStream ( ) : <nl> + * @ return : amount of data remaining to flush * / <nl> + size_t ZSTD_flushStream ( ZSTD_CStream * zcs , ZSTD_outBuffer * output ) <nl> + { <nl> + size_t srcSize = 0 ; <nl> + size_t sizeWritten = output - > size - output - > pos ; <nl> + size_t const result = ZSTD_compressStream_generic ( zcs , <nl> + ( char * ) ( output - > dst ) + output - > pos , & sizeWritten , <nl> + & srcSize , & srcSize , / * use a valid src address instead of NULL * / <nl> + zsf_flush ) ; <nl> + output - > pos + = sizeWritten ; <nl> + if ( ZSTD_isError ( result ) ) return result ; <nl> + return zcs - > outBuffContentSize - zcs - > outBuffFlushedSize ; / * remaining to flush * / <nl> + } <nl> + <nl> + <nl> + size_t ZSTD_endStream ( ZSTD_CStream * zcs , ZSTD_outBuffer * output ) <nl> + { <nl> + BYTE * const ostart = ( BYTE * ) ( output - > dst ) + output - > pos ; <nl> + BYTE * const oend = ( BYTE * ) ( output - > dst ) + output - > size ; <nl> + BYTE * op = ostart ; <nl> + <nl> + if ( zcs - > stage ! = zcss_final ) { <nl> + / * flush whatever remains * / <nl> + size_t srcSize = 0 ; <nl> + size_t sizeWritten = output - > size - output - > pos ; <nl> + size_t const notEnded = ZSTD_compressStream_generic ( zcs , ostart , & sizeWritten , <nl> + & srcSize / * use a valid src address instead of NULL * / , & srcSize , zsf_end ) ; <nl> + size_t const remainingToFlush = zcs - > outBuffContentSize - zcs - > outBuffFlushedSize ; <nl> + op + = sizeWritten ; <nl> + if ( remainingToFlush ) { <nl> + output - > pos + = sizeWritten ; <nl> + return remainingToFlush + ZSTD_BLOCKHEADERSIZE / * final empty block * / + ( zcs - > checksum * 4 ) ; <nl> + } <nl> + / * create epilogue * / <nl> + zcs - > stage = zcss_final ; <nl> + zcs - > outBuffContentSize = ! notEnded ? 0 : <nl> + / * write epilogue , including final empty block , into outBuff * / <nl> + ZSTD_compressEnd ( zcs - > cctx , zcs - > outBuff , zcs - > outBuffSize , NULL , 0 ) ; <nl> + if ( ZSTD_isError ( zcs - > outBuffContentSize ) ) return zcs - > outBuffContentSize ; <nl> + } <nl> + <nl> + / * flush epilogue * / <nl> + { size_t const toFlush = zcs - > outBuffContentSize - zcs - > outBuffFlushedSize ; <nl> + size_t const flushed = ZSTD_limitCopy ( op , oend - op , zcs - > outBuff + zcs - > outBuffFlushedSize , toFlush ) ; <nl> + op + = flushed ; <nl> + zcs - > outBuffFlushedSize + = flushed ; <nl> + output - > pos + = op - ostart ; <nl> + if ( toFlush = = flushed ) zcs - > stage = zcss_init ; / * end reached * / <nl> + return toFlush - flushed ; <nl> + } <nl> + } <nl> + <nl> + <nl> + <nl> + / * - = = = = = Pre - defined compression levels = = = = = - * / <nl> + <nl> + # define ZSTD_DEFAULT_CLEVEL 1 <nl> + # define ZSTD_MAX_CLEVEL 22 <nl> + int ZSTD_maxCLevel ( void ) { return ZSTD_MAX_CLEVEL ; } <nl> + <nl> + static const ZSTD_compressionParameters ZSTD_defaultCParameters [ 4 ] [ ZSTD_MAX_CLEVEL + 1 ] = { <nl> + { / * " default " * / <nl> + / * W , C , H , S , L , TL , strat * / <nl> + { 18 , 12 , 12 , 1 , 7 , 16 , ZSTD_fast } , / * level 0 - never used * / <nl> + { 19 , 13 , 14 , 1 , 7 , 16 , ZSTD_fast } , / * level 1 * / <nl> + { 19 , 15 , 16 , 1 , 6 , 16 , ZSTD_fast } , / * level 2 * / <nl> + { 20 , 16 , 17 , 1 , 5 , 16 , ZSTD_dfast } , / * level 3 . * / <nl> + { 20 , 18 , 18 , 1 , 5 , 16 , ZSTD_dfast } , / * level 4 . * / <nl> + { 20 , 15 , 18 , 3 , 5 , 16 , ZSTD_greedy } , / * level 5 * / <nl> + { 21 , 16 , 19 , 2 , 5 , 16 , ZSTD_lazy } , / * level 6 * / <nl> + { 21 , 17 , 20 , 3 , 5 , 16 , ZSTD_lazy } , / * level 7 * / <nl> + { 21 , 18 , 20 , 3 , 5 , 16 , ZSTD_lazy2 } , / * level 8 * / <nl> + { 21 , 20 , 20 , 3 , 5 , 16 , ZSTD_lazy2 } , / * level 9 * / <nl> + { 21 , 19 , 21 , 4 , 5 , 16 , ZSTD_lazy2 } , / * level 10 * / <nl> + { 22 , 20 , 22 , 4 , 5 , 16 , ZSTD_lazy2 } , / * level 11 * / <nl> + { 22 , 20 , 22 , 5 , 5 , 16 , ZSTD_lazy2 } , / * level 12 * / <nl> + { 22 , 21 , 22 , 5 , 5 , 16 , ZSTD_lazy2 } , / * level 13 * / <nl> + { 22 , 21 , 22 , 6 , 5 , 16 , ZSTD_lazy2 } , / * level 14 * / <nl> + { 22 , 21 , 21 , 5 , 5 , 16 , ZSTD_btlazy2 } , / * level 15 * / <nl> + { 23 , 22 , 22 , 5 , 5 , 16 , ZSTD_btlazy2 } , / * level 16 * / <nl> + { 23 , 21 , 22 , 4 , 5 , 24 , ZSTD_btopt } , / * level 17 * / <nl> + { 23 , 22 , 22 , 5 , 4 , 32 , ZSTD_btopt } , / * level 18 * / <nl> + { 23 , 23 , 22 , 6 , 3 , 48 , ZSTD_btopt } , / * level 19 * / <nl> + { 25 , 25 , 23 , 7 , 3 , 64 , ZSTD_btopt2 } , / * level 20 * / <nl> + { 26 , 26 , 23 , 7 , 3 , 256 , ZSTD_btopt2 } , / * level 21 * / <nl> + { 27 , 27 , 25 , 9 , 3 , 512 , ZSTD_btopt2 } , / * level 22 * / <nl> + } , <nl> + { / * for srcSize < = 256 KB * / <nl> + / * W , C , H , S , L , T , strat * / <nl> + { 0 , 0 , 0 , 0 , 0 , 0 , ZSTD_fast } , / * level 0 - not used * / <nl> + { 18 , 13 , 14 , 1 , 6 , 8 , ZSTD_fast } , / * level 1 * / <nl> + { 18 , 14 , 13 , 1 , 5 , 8 , ZSTD_dfast } , / * level 2 * / <nl> + { 18 , 16 , 15 , 1 , 5 , 8 , ZSTD_dfast } , / * level 3 * / <nl> + { 18 , 15 , 17 , 1 , 5 , 8 , ZSTD_greedy } , / * level 4 . * / <nl> + { 18 , 16 , 17 , 4 , 5 , 8 , ZSTD_greedy } , / * level 5 . * / <nl> + { 18 , 16 , 17 , 3 , 5 , 8 , ZSTD_lazy } , / * level 6 . * / <nl> + { 18 , 17 , 17 , 4 , 4 , 8 , ZSTD_lazy } , / * level 7 * / <nl> + { 18 , 17 , 17 , 4 , 4 , 8 , ZSTD_lazy2 } , / * level 8 * / <nl> + { 18 , 17 , 17 , 5 , 4 , 8 , ZSTD_lazy2 } , / * level 9 * / <nl> + { 18 , 17 , 17 , 6 , 4 , 8 , ZSTD_lazy2 } , / * level 10 * / <nl> + { 18 , 18 , 17 , 6 , 4 , 8 , ZSTD_lazy2 } , / * level 11 . * / <nl> + { 18 , 18 , 17 , 7 , 4 , 8 , ZSTD_lazy2 } , / * level 12 . * / <nl> + { 18 , 19 , 17 , 6 , 4 , 8 , ZSTD_btlazy2 } , / * level 13 * / <nl> + { 18 , 18 , 18 , 4 , 4 , 16 , ZSTD_btopt } , / * level 14 . * / <nl> + { 18 , 18 , 18 , 4 , 3 , 16 , ZSTD_btopt } , / * level 15 . * / <nl> + { 18 , 19 , 18 , 6 , 3 , 32 , ZSTD_btopt } , / * level 16 . * / <nl> + { 18 , 19 , 18 , 8 , 3 , 64 , ZSTD_btopt } , / * level 17 . * / <nl> + { 18 , 19 , 18 , 9 , 3 , 128 , ZSTD_btopt } , / * level 18 . * / <nl> + { 18 , 19 , 18 , 10 , 3 , 256 , ZSTD_btopt } , / * level 19 . * / <nl> + { 18 , 19 , 18 , 11 , 3 , 512 , ZSTD_btopt2 } , / * level 20 . * / <nl> + { 18 , 19 , 18 , 12 , 3 , 512 , ZSTD_btopt2 } , / * level 21 . * / <nl> + { 18 , 19 , 18 , 13 , 3 , 512 , ZSTD_btopt2 } , / * level 22 . * / <nl> + } , <nl> + { / * for srcSize < = 128 KB * / <nl> + / * W , C , H , S , L , T , strat * / <nl> + { 17 , 12 , 12 , 1 , 7 , 8 , ZSTD_fast } , / * level 0 - not used * / <nl> + { 17 , 12 , 13 , 1 , 6 , 8 , ZSTD_fast } , / * level 1 * / <nl> + { 17 , 13 , 16 , 1 , 5 , 8 , ZSTD_fast } , / * level 2 * / <nl> + { 17 , 16 , 16 , 2 , 5 , 8 , ZSTD_dfast } , / * level 3 * / <nl> + { 17 , 13 , 15 , 3 , 4 , 8 , ZSTD_greedy } , / * level 4 * / <nl> + { 17 , 15 , 17 , 4 , 4 , 8 , ZSTD_greedy } , / * level 5 * / <nl> + { 17 , 16 , 17 , 3 , 4 , 8 , ZSTD_lazy } , / * level 6 * / <nl> + { 17 , 15 , 17 , 4 , 4 , 8 , ZSTD_lazy2 } , / * level 7 * / <nl> + { 17 , 17 , 17 , 4 , 4 , 8 , ZSTD_lazy2 } , / * level 8 * / <nl> + { 17 , 17 , 17 , 5 , 4 , 8 , ZSTD_lazy2 } , / * level 9 * / <nl> + { 17 , 17 , 17 , 6 , 4 , 8 , ZSTD_lazy2 } , / * level 10 * / <nl> + { 17 , 17 , 17 , 7 , 4 , 8 , ZSTD_lazy2 } , / * level 11 * / <nl> + { 17 , 17 , 17 , 8 , 4 , 8 , ZSTD_lazy2 } , / * level 12 * / <nl> + { 17 , 18 , 17 , 6 , 4 , 8 , ZSTD_btlazy2 } , / * level 13 . * / <nl> + { 17 , 17 , 17 , 7 , 3 , 8 , ZSTD_btopt } , / * level 14 . * / <nl> + { 17 , 17 , 17 , 7 , 3 , 16 , ZSTD_btopt } , / * level 15 . * / <nl> + { 17 , 18 , 17 , 7 , 3 , 32 , ZSTD_btopt } , / * level 16 . * / <nl> + { 17 , 18 , 17 , 7 , 3 , 64 , ZSTD_btopt } , / * level 17 . * / <nl> + { 17 , 18 , 17 , 7 , 3 , 256 , ZSTD_btopt } , / * level 18 . * / <nl> + { 17 , 18 , 17 , 8 , 3 , 256 , ZSTD_btopt } , / * level 19 . * / <nl> + { 17 , 18 , 17 , 9 , 3 , 256 , ZSTD_btopt2 } , / * level 20 . * / <nl> + { 17 , 18 , 17 , 10 , 3 , 256 , ZSTD_btopt2 } , / * level 21 . * / <nl> + { 17 , 18 , 17 , 11 , 3 , 512 , ZSTD_btopt2 } , / * level 22 . * / <nl> + } , <nl> + { / * for srcSize < = 16 KB * / <nl> + / * W , C , H , S , L , T , strat * / <nl> + { 14 , 12 , 12 , 1 , 7 , 6 , ZSTD_fast } , / * level 0 - not used * / <nl> + { 14 , 14 , 14 , 1 , 6 , 6 , ZSTD_fast } , / * level 1 * / <nl> + { 14 , 14 , 14 , 1 , 4 , 6 , ZSTD_fast } , / * level 2 * / <nl> + { 14 , 14 , 14 , 1 , 4 , 6 , ZSTD_dfast } , / * level 3 . * / <nl> + { 14 , 14 , 14 , 4 , 4 , 6 , ZSTD_greedy } , / * level 4 . * / <nl> + { 14 , 14 , 14 , 3 , 4 , 6 , ZSTD_lazy } , / * level 5 . * / <nl> + { 14 , 14 , 14 , 4 , 4 , 6 , ZSTD_lazy2 } , / * level 6 * / <nl> + { 14 , 14 , 14 , 5 , 4 , 6 , ZSTD_lazy2 } , / * level 7 * / <nl> + { 14 , 14 , 14 , 6 , 4 , 6 , ZSTD_lazy2 } , / * level 8 . * / <nl> + { 14 , 15 , 14 , 6 , 4 , 6 , ZSTD_btlazy2 } , / * level 9 . * / <nl> + { 14 , 15 , 14 , 3 , 3 , 6 , ZSTD_btopt } , / * level 10 . * / <nl> + { 14 , 15 , 14 , 6 , 3 , 8 , ZSTD_btopt } , / * level 11 . * / <nl> + { 14 , 15 , 14 , 6 , 3 , 16 , ZSTD_btopt } , / * level 12 . * / <nl> + { 14 , 15 , 14 , 6 , 3 , 24 , ZSTD_btopt } , / * level 13 . * / <nl> + { 14 , 15 , 15 , 6 , 3 , 48 , ZSTD_btopt } , / * level 14 . * / <nl> + { 14 , 15 , 15 , 6 , 3 , 64 , ZSTD_btopt } , / * level 15 . * / <nl> + { 14 , 15 , 15 , 6 , 3 , 96 , ZSTD_btopt } , / * level 16 . * / <nl> + { 14 , 15 , 15 , 6 , 3 , 128 , ZSTD_btopt } , / * level 17 . * / <nl> + { 14 , 15 , 15 , 6 , 3 , 256 , ZSTD_btopt } , / * level 18 . * / <nl> + { 14 , 15 , 15 , 7 , 3 , 256 , ZSTD_btopt } , / * level 19 . * / <nl> + { 14 , 15 , 15 , 8 , 3 , 256 , ZSTD_btopt2 } , / * level 20 . * / <nl> + { 14 , 15 , 15 , 9 , 3 , 256 , ZSTD_btopt2 } , / * level 21 . * / <nl> + { 14 , 15 , 15 , 10 , 3 , 256 , ZSTD_btopt2 } , / * level 22 . * / <nl> + } , <nl> + } ; <nl> + <nl> + / * ! ZSTD_getCParams ( ) : <nl> + * @ return ZSTD_compressionParameters structure for a selected compression level , ` srcSize ` and ` dictSize ` . <nl> + * Size values are optional , provide 0 if not known or unused * / <nl> + ZSTD_compressionParameters ZSTD_getCParams ( int compressionLevel , unsigned long long srcSize , size_t dictSize ) <nl> + { <nl> + ZSTD_compressionParameters cp ; <nl> + size_t const addedSize = srcSize ? 0 : 500 ; <nl> + U64 const rSize = srcSize + dictSize ? srcSize + dictSize + addedSize : ( U64 ) - 1 ; <nl> + U32 const tableID = ( rSize < = 256 KB ) + ( rSize < = 128 KB ) + ( rSize < = 16 KB ) ; / * intentional underflow for srcSizeHint = = 0 * / <nl> + if ( compressionLevel < = 0 ) compressionLevel = ZSTD_DEFAULT_CLEVEL ; / * 0 = = default ; no negative compressionLevel yet * / <nl> + if ( compressionLevel > ZSTD_MAX_CLEVEL ) compressionLevel = ZSTD_MAX_CLEVEL ; <nl> + cp = ZSTD_defaultCParameters [ tableID ] [ compressionLevel ] ; <nl> + if ( MEM_32bits ( ) ) { / * auto - correction , for 32 - bits mode * / <nl> + if ( cp . windowLog > ZSTD_WINDOWLOG_MAX ) cp . windowLog = ZSTD_WINDOWLOG_MAX ; <nl> + if ( cp . chainLog > ZSTD_CHAINLOG_MAX ) cp . chainLog = ZSTD_CHAINLOG_MAX ; <nl> + if ( cp . hashLog > ZSTD_HASHLOG_MAX ) cp . hashLog = ZSTD_HASHLOG_MAX ; <nl> + } <nl> + cp = ZSTD_adjustCParams ( cp , srcSize , dictSize ) ; <nl> + return cp ; <nl> + } <nl> + <nl> + / * ! ZSTD_getParams ( ) : <nl> + * same as ZSTD_getCParams ( ) , but @ return a ` ZSTD_parameters ` object ( instead of ` ZSTD_compressionParameters ` ) . <nl> + * All fields of ` ZSTD_frameParameters ` are set to default ( 0 ) * / <nl> + ZSTD_parameters ZSTD_getParams ( int compressionLevel , unsigned long long srcSize , size_t dictSize ) { <nl> + ZSTD_parameters params ; <nl> + ZSTD_compressionParameters const cParams = ZSTD_getCParams ( compressionLevel , srcSize , dictSize ) ; <nl> + memset ( & params , 0 , sizeof ( params ) ) ; <nl> + params . cParams = cParams ; <nl> + return params ; <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 54376119121 <nl> mmm / dev / null <nl> ppp b / thirdparty / zstd / compress / zstd_opt . h <nl> <nl> + / * * <nl> + * Copyright ( c ) 2016 - present , Przemyslaw Skibinski , Yann Collet , Facebook , Inc . <nl> + * All rights reserved . <nl> + * <nl> + * This source code is licensed under the BSD - style license found in the <nl> + * LICENSE file in the root directory of this source tree . An additional grant <nl> + * of patent rights can be found in the PATENTS file in the same directory . <nl> + * / <nl> + <nl> + <nl> + / * Note : this file is intended to be included within zstd_compress . c * / <nl> + <nl> + <nl> + # ifndef ZSTD_OPT_H_91842398743 <nl> + # define ZSTD_OPT_H_91842398743 <nl> + <nl> + <nl> + # define ZSTD_LITFREQ_ADD 2 <nl> + # define ZSTD_FREQ_DIV 4 <nl> + # define ZSTD_MAX_PRICE ( 1 < < 30 ) <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Price functions for optimal parser <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + FORCE_INLINE void ZSTD_setLog2Prices ( seqStore_t * ssPtr ) <nl> + { <nl> + ssPtr - > log2matchLengthSum = ZSTD_highbit32 ( ssPtr - > matchLengthSum + 1 ) ; <nl> + ssPtr - > log2litLengthSum = ZSTD_highbit32 ( ssPtr - > litLengthSum + 1 ) ; <nl> + ssPtr - > log2litSum = ZSTD_highbit32 ( ssPtr - > litSum + 1 ) ; <nl> + ssPtr - > log2offCodeSum = ZSTD_highbit32 ( ssPtr - > offCodeSum + 1 ) ; <nl> + ssPtr - > factor = 1 + ( ( ssPtr - > litSum > > 5 ) / ssPtr - > litLengthSum ) + ( ( ssPtr - > litSum < < 1 ) / ( ssPtr - > litSum + ssPtr - > matchSum ) ) ; <nl> + } <nl> + <nl> + <nl> + MEM_STATIC void ZSTD_rescaleFreqs ( seqStore_t * ssPtr , const BYTE * src , size_t srcSize ) <nl> + { <nl> + unsigned u ; <nl> + <nl> + ssPtr - > cachedLiterals = NULL ; <nl> + ssPtr - > cachedPrice = ssPtr - > cachedLitLength = 0 ; <nl> + ssPtr - > staticPrices = 0 ; <nl> + <nl> + if ( ssPtr - > litLengthSum = = 0 ) { <nl> + if ( srcSize < = 1024 ) ssPtr - > staticPrices = 1 ; <nl> + <nl> + for ( u = 0 ; u < = MaxLit ; u + + ) <nl> + ssPtr - > litFreq [ u ] = 0 ; <nl> + for ( u = 0 ; u < srcSize ; u + + ) <nl> + ssPtr - > litFreq [ src [ u ] ] + + ; <nl> + <nl> + ssPtr - > litSum = 0 ; <nl> + ssPtr - > litLengthSum = MaxLL + 1 ; <nl> + ssPtr - > matchLengthSum = MaxML + 1 ; <nl> + ssPtr - > offCodeSum = ( MaxOff + 1 ) ; <nl> + ssPtr - > matchSum = ( ZSTD_LITFREQ_ADD < < Litbits ) ; <nl> + <nl> + for ( u = 0 ; u < = MaxLit ; u + + ) { <nl> + ssPtr - > litFreq [ u ] = 1 + ( ssPtr - > litFreq [ u ] > > ZSTD_FREQ_DIV ) ; <nl> + ssPtr - > litSum + = ssPtr - > litFreq [ u ] ; <nl> + } <nl> + for ( u = 0 ; u < = MaxLL ; u + + ) <nl> + ssPtr - > litLengthFreq [ u ] = 1 ; <nl> + for ( u = 0 ; u < = MaxML ; u + + ) <nl> + ssPtr - > matchLengthFreq [ u ] = 1 ; <nl> + for ( u = 0 ; u < = MaxOff ; u + + ) <nl> + ssPtr - > offCodeFreq [ u ] = 1 ; <nl> + } else { <nl> + ssPtr - > matchLengthSum = 0 ; <nl> + ssPtr - > litLengthSum = 0 ; <nl> + ssPtr - > offCodeSum = 0 ; <nl> + ssPtr - > matchSum = 0 ; <nl> + ssPtr - > litSum = 0 ; <nl> + <nl> + for ( u = 0 ; u < = MaxLit ; u + + ) { <nl> + ssPtr - > litFreq [ u ] = 1 + ( ssPtr - > litFreq [ u ] > > ( ZSTD_FREQ_DIV + 1 ) ) ; <nl> + ssPtr - > litSum + = ssPtr - > litFreq [ u ] ; <nl> + } <nl> + for ( u = 0 ; u < = MaxLL ; u + + ) { <nl> + ssPtr - > litLengthFreq [ u ] = 1 + ( ssPtr - > litLengthFreq [ u ] > > ( ZSTD_FREQ_DIV + 1 ) ) ; <nl> + ssPtr - > litLengthSum + = ssPtr - > litLengthFreq [ u ] ; <nl> + } <nl> + for ( u = 0 ; u < = MaxML ; u + + ) { <nl> + ssPtr - > matchLengthFreq [ u ] = 1 + ( ssPtr - > matchLengthFreq [ u ] > > ZSTD_FREQ_DIV ) ; <nl> + ssPtr - > matchLengthSum + = ssPtr - > matchLengthFreq [ u ] ; <nl> + ssPtr - > matchSum + = ssPtr - > matchLengthFreq [ u ] * ( u + 3 ) ; <nl> + } <nl> + ssPtr - > matchSum * = ZSTD_LITFREQ_ADD ; <nl> + for ( u = 0 ; u < = MaxOff ; u + + ) { <nl> + ssPtr - > offCodeFreq [ u ] = 1 + ( ssPtr - > offCodeFreq [ u ] > > ZSTD_FREQ_DIV ) ; <nl> + ssPtr - > offCodeSum + = ssPtr - > offCodeFreq [ u ] ; <nl> + } <nl> + } <nl> + <nl> + ZSTD_setLog2Prices ( ssPtr ) ; <nl> + } <nl> + <nl> + <nl> + FORCE_INLINE U32 ZSTD_getLiteralPrice ( seqStore_t * ssPtr , U32 litLength , const BYTE * literals ) <nl> + { <nl> + U32 price , u ; <nl> + <nl> + if ( ssPtr - > staticPrices ) <nl> + return ZSTD_highbit32 ( ( U32 ) litLength + 1 ) + ( litLength * 6 ) ; <nl> + <nl> + if ( litLength = = 0 ) <nl> + return ssPtr - > log2litLengthSum - ZSTD_highbit32 ( ssPtr - > litLengthFreq [ 0 ] + 1 ) ; <nl> + <nl> + / * literals * / <nl> + if ( ssPtr - > cachedLiterals = = literals ) { <nl> + U32 const additional = litLength - ssPtr - > cachedLitLength ; <nl> + const BYTE * literals2 = ssPtr - > cachedLiterals + ssPtr - > cachedLitLength ; <nl> + price = ssPtr - > cachedPrice + additional * ssPtr - > log2litSum ; <nl> + for ( u = 0 ; u < additional ; u + + ) <nl> + price - = ZSTD_highbit32 ( ssPtr - > litFreq [ literals2 [ u ] ] + 1 ) ; <nl> + ssPtr - > cachedPrice = price ; <nl> + ssPtr - > cachedLitLength = litLength ; <nl> + } else { <nl> + price = litLength * ssPtr - > log2litSum ; <nl> + for ( u = 0 ; u < litLength ; u + + ) <nl> + price - = ZSTD_highbit32 ( ssPtr - > litFreq [ literals [ u ] ] + 1 ) ; <nl> + <nl> + if ( litLength > = 12 ) { <nl> + ssPtr - > cachedLiterals = literals ; <nl> + ssPtr - > cachedPrice = price ; <nl> + ssPtr - > cachedLitLength = litLength ; <nl> + } <nl> + } <nl> + <nl> + / * literal Length * / <nl> + { const BYTE LL_deltaCode = 19 ; <nl> + const BYTE llCode = ( litLength > 63 ) ? ( BYTE ) ZSTD_highbit32 ( litLength ) + LL_deltaCode : LL_Code [ litLength ] ; <nl> + price + = LL_bits [ llCode ] + ssPtr - > log2litLengthSum - ZSTD_highbit32 ( ssPtr - > litLengthFreq [ llCode ] + 1 ) ; <nl> + } <nl> + <nl> + return price ; <nl> + } <nl> + <nl> + <nl> + FORCE_INLINE U32 ZSTD_getPrice ( seqStore_t * seqStorePtr , U32 litLength , const BYTE * literals , U32 offset , U32 matchLength , const int ultra ) <nl> + { <nl> + / * offset * / <nl> + U32 price ; <nl> + BYTE const offCode = ( BYTE ) ZSTD_highbit32 ( offset + 1 ) ; <nl> + <nl> + if ( seqStorePtr - > staticPrices ) <nl> + return ZSTD_getLiteralPrice ( seqStorePtr , litLength , literals ) + ZSTD_highbit32 ( ( U32 ) matchLength + 1 ) + 16 + offCode ; <nl> + <nl> + price = offCode + seqStorePtr - > log2offCodeSum - ZSTD_highbit32 ( seqStorePtr - > offCodeFreq [ offCode ] + 1 ) ; <nl> + if ( ! ultra & & offCode > = 20 ) price + = ( offCode - 19 ) * 2 ; <nl> + <nl> + / * match Length * / <nl> + { const BYTE ML_deltaCode = 36 ; <nl> + const BYTE mlCode = ( matchLength > 127 ) ? ( BYTE ) ZSTD_highbit32 ( matchLength ) + ML_deltaCode : ML_Code [ matchLength ] ; <nl> + price + = ML_bits [ mlCode ] + seqStorePtr - > log2matchLengthSum - ZSTD_highbit32 ( seqStorePtr - > matchLengthFreq [ mlCode ] + 1 ) ; <nl> + } <nl> + <nl> + return price + ZSTD_getLiteralPrice ( seqStorePtr , litLength , literals ) + seqStorePtr - > factor ; <nl> + } <nl> + <nl> + <nl> + MEM_STATIC void ZSTD_updatePrice ( seqStore_t * seqStorePtr , U32 litLength , const BYTE * literals , U32 offset , U32 matchLength ) <nl> + { <nl> + U32 u ; <nl> + <nl> + / * literals * / <nl> + seqStorePtr - > litSum + = litLength * ZSTD_LITFREQ_ADD ; <nl> + for ( u = 0 ; u < litLength ; u + + ) <nl> + seqStorePtr - > litFreq [ literals [ u ] ] + = ZSTD_LITFREQ_ADD ; <nl> + <nl> + / * literal Length * / <nl> + { const BYTE LL_deltaCode = 19 ; <nl> + const BYTE llCode = ( litLength > 63 ) ? ( BYTE ) ZSTD_highbit32 ( litLength ) + LL_deltaCode : LL_Code [ litLength ] ; <nl> + seqStorePtr - > litLengthFreq [ llCode ] + + ; <nl> + seqStorePtr - > litLengthSum + + ; <nl> + } <nl> + <nl> + / * match offset * / <nl> + { BYTE const offCode = ( BYTE ) ZSTD_highbit32 ( offset + 1 ) ; <nl> + seqStorePtr - > offCodeSum + + ; <nl> + seqStorePtr - > offCodeFreq [ offCode ] + + ; <nl> + } <nl> + <nl> + / * match Length * / <nl> + { const BYTE ML_deltaCode = 36 ; <nl> + const BYTE mlCode = ( matchLength > 127 ) ? ( BYTE ) ZSTD_highbit32 ( matchLength ) + ML_deltaCode : ML_Code [ matchLength ] ; <nl> + seqStorePtr - > matchLengthFreq [ mlCode ] + + ; <nl> + seqStorePtr - > matchLengthSum + + ; <nl> + } <nl> + <nl> + ZSTD_setLog2Prices ( seqStorePtr ) ; <nl> + } <nl> + <nl> + <nl> + # define SET_PRICE ( pos , mlen_ , offset_ , litlen_ , price_ ) \ <nl> + { \ <nl> + while ( last_pos < pos ) { opt [ last_pos + 1 ] . price = ZSTD_MAX_PRICE ; last_pos + + ; } \ <nl> + opt [ pos ] . mlen = mlen_ ; \ <nl> + opt [ pos ] . off = offset_ ; \ <nl> + opt [ pos ] . litlen = litlen_ ; \ <nl> + opt [ pos ] . price = price_ ; \ <nl> + } <nl> + <nl> + <nl> + <nl> + / * Update hashTable3 up to ip ( excluded ) <nl> + Assumption : always within prefix ( i . e . not within extDict ) * / <nl> + FORCE_INLINE <nl> + U32 ZSTD_insertAndFindFirstIndexHash3 ( ZSTD_CCtx * zc , const BYTE * ip ) <nl> + { <nl> + U32 * const hashTable3 = zc - > hashTable3 ; <nl> + U32 const hashLog3 = zc - > hashLog3 ; <nl> + const BYTE * const base = zc - > base ; <nl> + U32 idx = zc - > nextToUpdate3 ; <nl> + const U32 target = zc - > nextToUpdate3 = ( U32 ) ( ip - base ) ; <nl> + const size_t hash3 = ZSTD_hash3Ptr ( ip , hashLog3 ) ; <nl> + <nl> + while ( idx < target ) { <nl> + hashTable3 [ ZSTD_hash3Ptr ( base + idx , hashLog3 ) ] = idx ; <nl> + idx + + ; <nl> + } <nl> + <nl> + return hashTable3 [ hash3 ] ; <nl> + } <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Binary Tree search <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + static U32 ZSTD_insertBtAndGetAllMatches ( <nl> + ZSTD_CCtx * zc , <nl> + const BYTE * const ip , const BYTE * const iLimit , <nl> + U32 nbCompares , const U32 mls , <nl> + U32 extDict , ZSTD_match_t * matches , const U32 minMatchLen ) <nl> + { <nl> + const BYTE * const base = zc - > base ; <nl> + const U32 current = ( U32 ) ( ip - base ) ; <nl> + const U32 hashLog = zc - > params . cParams . hashLog ; <nl> + const size_t h = ZSTD_hashPtr ( ip , hashLog , mls ) ; <nl> + U32 * const hashTable = zc - > hashTable ; <nl> + U32 matchIndex = hashTable [ h ] ; <nl> + U32 * const bt = zc - > chainTable ; <nl> + const U32 btLog = zc - > params . cParams . chainLog - 1 ; <nl> + const U32 btMask = ( 1U < < btLog ) - 1 ; <nl> + size_t commonLengthSmaller = 0 , commonLengthLarger = 0 ; <nl> + const BYTE * const dictBase = zc - > dictBase ; <nl> + const U32 dictLimit = zc - > dictLimit ; <nl> + const BYTE * const dictEnd = dictBase + dictLimit ; <nl> + const BYTE * const prefixStart = base + dictLimit ; <nl> + const U32 btLow = btMask > = current ? 0 : current - btMask ; <nl> + const U32 windowLow = zc - > lowLimit ; <nl> + U32 * smallerPtr = bt + 2 * ( current & btMask ) ; <nl> + U32 * largerPtr = bt + 2 * ( current & btMask ) + 1 ; <nl> + U32 matchEndIdx = current + 8 ; <nl> + U32 dummy32 ; / * to be nullified at the end * / <nl> + U32 mnum = 0 ; <nl> + <nl> + const U32 minMatch = ( mls = = 3 ) ? 3 : 4 ; <nl> + size_t bestLength = minMatchLen - 1 ; <nl> + <nl> + if ( minMatch = = 3 ) { / * HC3 match finder * / <nl> + U32 const matchIndex3 = ZSTD_insertAndFindFirstIndexHash3 ( zc , ip ) ; <nl> + if ( matchIndex3 > windowLow & & ( current - matchIndex3 < ( 1 < < 18 ) ) ) { <nl> + const BYTE * match ; <nl> + size_t currentMl = 0 ; <nl> + if ( ( ! extDict ) | | matchIndex3 > = dictLimit ) { <nl> + match = base + matchIndex3 ; <nl> + if ( match [ bestLength ] = = ip [ bestLength ] ) currentMl = ZSTD_count ( ip , match , iLimit ) ; <nl> + } else { <nl> + match = dictBase + matchIndex3 ; <nl> + if ( MEM_readMINMATCH ( match , MINMATCH ) = = MEM_readMINMATCH ( ip , MINMATCH ) ) / * assumption : matchIndex3 < = dictLimit - 4 ( by table construction ) * / <nl> + currentMl = ZSTD_count_2segments ( ip + MINMATCH , match + MINMATCH , iLimit , dictEnd , prefixStart ) + MINMATCH ; <nl> + } <nl> + <nl> + / * save best solution * / <nl> + if ( currentMl > bestLength ) { <nl> + bestLength = currentMl ; <nl> + matches [ mnum ] . off = ZSTD_REP_MOVE_OPT + current - matchIndex3 ; <nl> + matches [ mnum ] . len = ( U32 ) currentMl ; <nl> + mnum + + ; <nl> + if ( currentMl > ZSTD_OPT_NUM ) goto update ; <nl> + if ( ip + currentMl = = iLimit ) goto update ; / * best possible , and avoid read overflow * / <nl> + } <nl> + } <nl> + } <nl> + <nl> + hashTable [ h ] = current ; / * Update Hash Table * / <nl> + <nl> + while ( nbCompares - - & & ( matchIndex > windowLow ) ) { <nl> + U32 * nextPtr = bt + 2 * ( matchIndex & btMask ) ; <nl> + size_t matchLength = MIN ( commonLengthSmaller , commonLengthLarger ) ; / * guaranteed minimum nb of common bytes * / <nl> + const BYTE * match ; <nl> + <nl> + if ( ( ! extDict ) | | ( matchIndex + matchLength > = dictLimit ) ) { <nl> + match = base + matchIndex ; <nl> + if ( match [ matchLength ] = = ip [ matchLength ] ) { <nl> + matchLength + = ZSTD_count ( ip + matchLength + 1 , match + matchLength + 1 , iLimit ) + 1 ; <nl> + } <nl> + } else { <nl> + match = dictBase + matchIndex ; <nl> + matchLength + = ZSTD_count_2segments ( ip + matchLength , match + matchLength , iLimit , dictEnd , prefixStart ) ; <nl> + if ( matchIndex + matchLength > = dictLimit ) <nl> + match = base + matchIndex ; / * to prepare for next usage of match [ matchLength ] * / <nl> + } <nl> + <nl> + if ( matchLength > bestLength ) { <nl> + if ( matchLength > matchEndIdx - matchIndex ) matchEndIdx = matchIndex + ( U32 ) matchLength ; <nl> + bestLength = matchLength ; <nl> + matches [ mnum ] . off = ZSTD_REP_MOVE_OPT + current - matchIndex ; <nl> + matches [ mnum ] . len = ( U32 ) matchLength ; <nl> + mnum + + ; <nl> + if ( matchLength > ZSTD_OPT_NUM ) break ; <nl> + if ( ip + matchLength = = iLimit ) / * equal : no way to know if inf or sup * / <nl> + break ; / * drop , to guarantee consistency ( miss a little bit of compression ) * / <nl> + } <nl> + <nl> + if ( match [ matchLength ] < ip [ matchLength ] ) { <nl> + / * match is smaller than current * / <nl> + * smallerPtr = matchIndex ; / * update smaller idx * / <nl> + commonLengthSmaller = matchLength ; / * all smaller will now have at least this guaranteed common length * / <nl> + if ( matchIndex < = btLow ) { smallerPtr = & dummy32 ; break ; } / * beyond tree size , stop the search * / <nl> + smallerPtr = nextPtr + 1 ; / * new " smaller " = > larger of match * / <nl> + matchIndex = nextPtr [ 1 ] ; / * new matchIndex larger than previous ( closer to current ) * / <nl> + } else { <nl> + / * match is larger than current * / <nl> + * largerPtr = matchIndex ; <nl> + commonLengthLarger = matchLength ; <nl> + if ( matchIndex < = btLow ) { largerPtr = & dummy32 ; break ; } / * beyond tree size , stop the search * / <nl> + largerPtr = nextPtr ; <nl> + matchIndex = nextPtr [ 0 ] ; <nl> + } } <nl> + <nl> + * smallerPtr = * largerPtr = 0 ; <nl> + <nl> + update : <nl> + zc - > nextToUpdate = ( matchEndIdx > current + 8 ) ? matchEndIdx - 8 : current + 1 ; <nl> + return mnum ; <nl> + } <nl> + <nl> + <nl> + / * * Tree updater , providing best match * / <nl> + static U32 ZSTD_BtGetAllMatches ( <nl> + ZSTD_CCtx * zc , <nl> + const BYTE * const ip , const BYTE * const iLimit , <nl> + const U32 maxNbAttempts , const U32 mls , ZSTD_match_t * matches , const U32 minMatchLen ) <nl> + { <nl> + if ( ip < zc - > base + zc - > nextToUpdate ) return 0 ; / * skipped area * / <nl> + ZSTD_updateTree ( zc , ip , iLimit , maxNbAttempts , mls ) ; <nl> + return ZSTD_insertBtAndGetAllMatches ( zc , ip , iLimit , maxNbAttempts , mls , 0 , matches , minMatchLen ) ; <nl> + } <nl> + <nl> + <nl> + static U32 ZSTD_BtGetAllMatches_selectMLS ( <nl> + ZSTD_CCtx * zc , / * Index table will be updated * / <nl> + const BYTE * ip , const BYTE * const iHighLimit , <nl> + const U32 maxNbAttempts , const U32 matchLengthSearch , ZSTD_match_t * matches , const U32 minMatchLen ) <nl> + { <nl> + switch ( matchLengthSearch ) <nl> + { <nl> + case 3 : return ZSTD_BtGetAllMatches ( zc , ip , iHighLimit , maxNbAttempts , 3 , matches , minMatchLen ) ; <nl> + default : <nl> + case 4 : return ZSTD_BtGetAllMatches ( zc , ip , iHighLimit , maxNbAttempts , 4 , matches , minMatchLen ) ; <nl> + case 5 : return ZSTD_BtGetAllMatches ( zc , ip , iHighLimit , maxNbAttempts , 5 , matches , minMatchLen ) ; <nl> + case 7 : <nl> + case 6 : return ZSTD_BtGetAllMatches ( zc , ip , iHighLimit , maxNbAttempts , 6 , matches , minMatchLen ) ; <nl> + } <nl> + } <nl> + <nl> + / * * Tree updater , providing best match * / <nl> + static U32 ZSTD_BtGetAllMatches_extDict ( <nl> + ZSTD_CCtx * zc , <nl> + const BYTE * const ip , const BYTE * const iLimit , <nl> + const U32 maxNbAttempts , const U32 mls , ZSTD_match_t * matches , const U32 minMatchLen ) <nl> + { <nl> + if ( ip < zc - > base + zc - > nextToUpdate ) return 0 ; / * skipped area * / <nl> + ZSTD_updateTree_extDict ( zc , ip , iLimit , maxNbAttempts , mls ) ; <nl> + return ZSTD_insertBtAndGetAllMatches ( zc , ip , iLimit , maxNbAttempts , mls , 1 , matches , minMatchLen ) ; <nl> + } <nl> + <nl> + <nl> + static U32 ZSTD_BtGetAllMatches_selectMLS_extDict ( <nl> + ZSTD_CCtx * zc , / * Index table will be updated * / <nl> + const BYTE * ip , const BYTE * const iHighLimit , <nl> + const U32 maxNbAttempts , const U32 matchLengthSearch , ZSTD_match_t * matches , const U32 minMatchLen ) <nl> + { <nl> + switch ( matchLengthSearch ) <nl> + { <nl> + case 3 : return ZSTD_BtGetAllMatches_extDict ( zc , ip , iHighLimit , maxNbAttempts , 3 , matches , minMatchLen ) ; <nl> + default : <nl> + case 4 : return ZSTD_BtGetAllMatches_extDict ( zc , ip , iHighLimit , maxNbAttempts , 4 , matches , minMatchLen ) ; <nl> + case 5 : return ZSTD_BtGetAllMatches_extDict ( zc , ip , iHighLimit , maxNbAttempts , 5 , matches , minMatchLen ) ; <nl> + case 7 : <nl> + case 6 : return ZSTD_BtGetAllMatches_extDict ( zc , ip , iHighLimit , maxNbAttempts , 6 , matches , minMatchLen ) ; <nl> + } <nl> + } <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Optimal parser <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + FORCE_INLINE <nl> + void ZSTD_compressBlock_opt_generic ( ZSTD_CCtx * ctx , <nl> + const void * src , size_t srcSize , const int ultra ) <nl> + { <nl> + seqStore_t * seqStorePtr = & ( ctx - > seqStore ) ; <nl> + const BYTE * const istart = ( const BYTE * ) src ; <nl> + const BYTE * ip = istart ; <nl> + const BYTE * anchor = istart ; <nl> + const BYTE * const iend = istart + srcSize ; <nl> + const BYTE * const ilimit = iend - 8 ; <nl> + const BYTE * const base = ctx - > base ; <nl> + const BYTE * const prefixStart = base + ctx - > dictLimit ; <nl> + <nl> + const U32 maxSearches = 1U < < ctx - > params . cParams . searchLog ; <nl> + const U32 sufficient_len = ctx - > params . cParams . targetLength ; <nl> + const U32 mls = ctx - > params . cParams . searchLength ; <nl> + const U32 minMatch = ( ctx - > params . cParams . searchLength = = 3 ) ? 3 : 4 ; <nl> + <nl> + ZSTD_optimal_t * opt = seqStorePtr - > priceTable ; <nl> + ZSTD_match_t * matches = seqStorePtr - > matchTable ; <nl> + const BYTE * inr ; <nl> + U32 offset , rep [ ZSTD_REP_NUM ] ; <nl> + <nl> + / * init * / <nl> + ctx - > nextToUpdate3 = ctx - > nextToUpdate ; <nl> + ZSTD_rescaleFreqs ( seqStorePtr , ( const BYTE * ) src , srcSize ) ; <nl> + ip + = ( ip = = prefixStart ) ; <nl> + { U32 i ; for ( i = 0 ; i < ZSTD_REP_NUM ; i + + ) rep [ i ] = ctx - > rep [ i ] ; } <nl> + <nl> + / * Match Loop * / <nl> + while ( ip < ilimit ) { <nl> + U32 cur , match_num , last_pos , litlen , price ; <nl> + U32 u , mlen , best_mlen , best_off , litLength ; <nl> + memset ( opt , 0 , sizeof ( ZSTD_optimal_t ) ) ; <nl> + last_pos = 0 ; <nl> + litlen = ( U32 ) ( ip - anchor ) ; <nl> + <nl> + / * check repCode * / <nl> + { U32 i , last_i = ZSTD_REP_CHECK + ( ip = = anchor ) ; <nl> + for ( i = ( ip = = anchor ) ; i < last_i ; i + + ) { <nl> + const S32 repCur = ( i = = ZSTD_REP_MOVE_OPT ) ? ( rep [ 0 ] - 1 ) : rep [ i ] ; <nl> + if ( ( repCur > 0 ) & & ( repCur < ( S32 ) ( ip - prefixStart ) ) <nl> + & & ( MEM_readMINMATCH ( ip , minMatch ) = = MEM_readMINMATCH ( ip - repCur , minMatch ) ) ) { <nl> + mlen = ( U32 ) ZSTD_count ( ip + minMatch , ip + minMatch - repCur , iend ) + minMatch ; <nl> + if ( mlen > sufficient_len | | mlen > = ZSTD_OPT_NUM ) { <nl> + best_mlen = mlen ; best_off = i ; cur = 0 ; last_pos = 1 ; <nl> + goto _storeSequence ; <nl> + } <nl> + best_off = i - ( ip = = anchor ) ; <nl> + do { <nl> + price = ZSTD_getPrice ( seqStorePtr , litlen , anchor , best_off , mlen - MINMATCH , ultra ) ; <nl> + if ( mlen > last_pos | | price < opt [ mlen ] . price ) <nl> + SET_PRICE ( mlen , mlen , i , litlen , price ) ; / * note : macro modifies last_pos * / <nl> + mlen - - ; <nl> + } while ( mlen > = minMatch ) ; <nl> + } } } <nl> + <nl> + match_num = ZSTD_BtGetAllMatches_selectMLS ( ctx , ip , iend , maxSearches , mls , matches , minMatch ) ; <nl> + <nl> + if ( ! last_pos & & ! match_num ) { ip + + ; continue ; } <nl> + <nl> + if ( match_num & & ( matches [ match_num - 1 ] . len > sufficient_len | | matches [ match_num - 1 ] . len > = ZSTD_OPT_NUM ) ) { <nl> + best_mlen = matches [ match_num - 1 ] . len ; <nl> + best_off = matches [ match_num - 1 ] . off ; <nl> + cur = 0 ; <nl> + last_pos = 1 ; <nl> + goto _storeSequence ; <nl> + } <nl> + <nl> + / * set prices using matches at position = 0 * / <nl> + best_mlen = ( last_pos ) ? last_pos : minMatch ; <nl> + for ( u = 0 ; u < match_num ; u + + ) { <nl> + mlen = ( u > 0 ) ? matches [ u - 1 ] . len + 1 : best_mlen ; <nl> + best_mlen = matches [ u ] . len ; <nl> + while ( mlen < = best_mlen ) { <nl> + price = ZSTD_getPrice ( seqStorePtr , litlen , anchor , matches [ u ] . off - 1 , mlen - MINMATCH , ultra ) ; <nl> + if ( mlen > last_pos | | price < opt [ mlen ] . price ) <nl> + SET_PRICE ( mlen , mlen , matches [ u ] . off , litlen , price ) ; / * note : macro modifies last_pos * / <nl> + mlen + + ; <nl> + } } <nl> + <nl> + if ( last_pos < minMatch ) { ip + + ; continue ; } <nl> + <nl> + / * initialize opt [ 0 ] * / <nl> + { U32 i ; for ( i = 0 ; i < ZSTD_REP_NUM ; i + + ) opt [ 0 ] . rep [ i ] = rep [ i ] ; } <nl> + opt [ 0 ] . mlen = 1 ; <nl> + opt [ 0 ] . litlen = litlen ; <nl> + <nl> + / * check further positions * / <nl> + for ( cur = 1 ; cur < = last_pos ; cur + + ) { <nl> + inr = ip + cur ; <nl> + <nl> + if ( opt [ cur - 1 ] . mlen = = 1 ) { <nl> + litlen = opt [ cur - 1 ] . litlen + 1 ; <nl> + if ( cur > litlen ) { <nl> + price = opt [ cur - litlen ] . price + ZSTD_getLiteralPrice ( seqStorePtr , litlen , inr - litlen ) ; <nl> + } else <nl> + price = ZSTD_getLiteralPrice ( seqStorePtr , litlen , anchor ) ; <nl> + } else { <nl> + litlen = 1 ; <nl> + price = opt [ cur - 1 ] . price + ZSTD_getLiteralPrice ( seqStorePtr , litlen , inr - 1 ) ; <nl> + } <nl> + <nl> + if ( cur > last_pos | | price < = opt [ cur ] . price ) <nl> + SET_PRICE ( cur , 1 , 0 , litlen , price ) ; <nl> + <nl> + if ( cur = = last_pos ) break ; <nl> + <nl> + if ( inr > ilimit ) / * last match must start at a minimum distance of 8 from oend * / <nl> + continue ; <nl> + <nl> + mlen = opt [ cur ] . mlen ; <nl> + if ( opt [ cur ] . off > ZSTD_REP_MOVE_OPT ) { <nl> + opt [ cur ] . rep [ 2 ] = opt [ cur - mlen ] . rep [ 1 ] ; <nl> + opt [ cur ] . rep [ 1 ] = opt [ cur - mlen ] . rep [ 0 ] ; <nl> + opt [ cur ] . rep [ 0 ] = opt [ cur ] . off - ZSTD_REP_MOVE_OPT ; <nl> + } else { <nl> + opt [ cur ] . rep [ 2 ] = ( opt [ cur ] . off > 1 ) ? opt [ cur - mlen ] . rep [ 1 ] : opt [ cur - mlen ] . rep [ 2 ] ; <nl> + opt [ cur ] . rep [ 1 ] = ( opt [ cur ] . off > 0 ) ? opt [ cur - mlen ] . rep [ 0 ] : opt [ cur - mlen ] . rep [ 1 ] ; <nl> + opt [ cur ] . rep [ 0 ] = ( ( opt [ cur ] . off = = ZSTD_REP_MOVE_OPT ) & & ( mlen ! = 1 ) ) ? ( opt [ cur - mlen ] . rep [ 0 ] - 1 ) : ( opt [ cur - mlen ] . rep [ opt [ cur ] . off ] ) ; <nl> + } <nl> + <nl> + best_mlen = minMatch ; <nl> + { U32 i , last_i = ZSTD_REP_CHECK + ( mlen ! = 1 ) ; <nl> + for ( i = ( opt [ cur ] . mlen ! = 1 ) ; i < last_i ; i + + ) { / * check rep * / <nl> + const S32 repCur = ( i = = ZSTD_REP_MOVE_OPT ) ? ( opt [ cur ] . rep [ 0 ] - 1 ) : opt [ cur ] . rep [ i ] ; <nl> + if ( ( repCur > 0 ) & & ( repCur < ( S32 ) ( inr - prefixStart ) ) <nl> + & & ( MEM_readMINMATCH ( inr , minMatch ) = = MEM_readMINMATCH ( inr - repCur , minMatch ) ) ) { <nl> + mlen = ( U32 ) ZSTD_count ( inr + minMatch , inr + minMatch - repCur , iend ) + minMatch ; <nl> + <nl> + if ( mlen > sufficient_len | | cur + mlen > = ZSTD_OPT_NUM ) { <nl> + best_mlen = mlen ; best_off = i ; last_pos = cur + 1 ; <nl> + goto _storeSequence ; <nl> + } <nl> + <nl> + best_off = i - ( opt [ cur ] . mlen ! = 1 ) ; <nl> + if ( mlen > best_mlen ) best_mlen = mlen ; <nl> + <nl> + do { <nl> + if ( opt [ cur ] . mlen = = 1 ) { <nl> + litlen = opt [ cur ] . litlen ; <nl> + if ( cur > litlen ) { <nl> + price = opt [ cur - litlen ] . price + ZSTD_getPrice ( seqStorePtr , litlen , inr - litlen , best_off , mlen - MINMATCH , ultra ) ; <nl> + } else <nl> + price = ZSTD_getPrice ( seqStorePtr , litlen , anchor , best_off , mlen - MINMATCH , ultra ) ; <nl> + } else { <nl> + litlen = 0 ; <nl> + price = opt [ cur ] . price + ZSTD_getPrice ( seqStorePtr , 0 , NULL , best_off , mlen - MINMATCH , ultra ) ; <nl> + } <nl> + <nl> + if ( cur + mlen > last_pos | | price < = opt [ cur + mlen ] . price ) <nl> + SET_PRICE ( cur + mlen , mlen , i , litlen , price ) ; <nl> + mlen - - ; <nl> + } while ( mlen > = minMatch ) ; <nl> + } } } <nl> + <nl> + match_num = ZSTD_BtGetAllMatches_selectMLS ( ctx , inr , iend , maxSearches , mls , matches , best_mlen ) ; <nl> + <nl> + if ( match_num > 0 & & ( matches [ match_num - 1 ] . len > sufficient_len | | cur + matches [ match_num - 1 ] . len > = ZSTD_OPT_NUM ) ) { <nl> + best_mlen = matches [ match_num - 1 ] . len ; <nl> + best_off = matches [ match_num - 1 ] . off ; <nl> + last_pos = cur + 1 ; <nl> + goto _storeSequence ; <nl> + } <nl> + <nl> + / * set prices using matches at position = cur * / <nl> + for ( u = 0 ; u < match_num ; u + + ) { <nl> + mlen = ( u > 0 ) ? matches [ u - 1 ] . len + 1 : best_mlen ; <nl> + best_mlen = matches [ u ] . len ; <nl> + <nl> + while ( mlen < = best_mlen ) { <nl> + if ( opt [ cur ] . mlen = = 1 ) { <nl> + litlen = opt [ cur ] . litlen ; <nl> + if ( cur > litlen ) <nl> + price = opt [ cur - litlen ] . price + ZSTD_getPrice ( seqStorePtr , litlen , ip + cur - litlen , matches [ u ] . off - 1 , mlen - MINMATCH , ultra ) ; <nl> + else <nl> + price = ZSTD_getPrice ( seqStorePtr , litlen , anchor , matches [ u ] . off - 1 , mlen - MINMATCH , ultra ) ; <nl> + } else { <nl> + litlen = 0 ; <nl> + price = opt [ cur ] . price + ZSTD_getPrice ( seqStorePtr , 0 , NULL , matches [ u ] . off - 1 , mlen - MINMATCH , ultra ) ; <nl> + } <nl> + <nl> + if ( cur + mlen > last_pos | | ( price < opt [ cur + mlen ] . price ) ) <nl> + SET_PRICE ( cur + mlen , mlen , matches [ u ] . off , litlen , price ) ; <nl> + <nl> + mlen + + ; <nl> + } } } <nl> + <nl> + best_mlen = opt [ last_pos ] . mlen ; <nl> + best_off = opt [ last_pos ] . off ; <nl> + cur = last_pos - best_mlen ; <nl> + <nl> + / * store sequence * / <nl> + _storeSequence : / * cur , last_pos , best_mlen , best_off have to be set * / <nl> + opt [ 0 ] . mlen = 1 ; <nl> + <nl> + while ( 1 ) { <nl> + mlen = opt [ cur ] . mlen ; <nl> + offset = opt [ cur ] . off ; <nl> + opt [ cur ] . mlen = best_mlen ; <nl> + opt [ cur ] . off = best_off ; <nl> + best_mlen = mlen ; <nl> + best_off = offset ; <nl> + if ( mlen > cur ) break ; <nl> + cur - = mlen ; <nl> + } <nl> + <nl> + for ( u = 0 ; u < = last_pos ; ) { <nl> + u + = opt [ u ] . mlen ; <nl> + } <nl> + <nl> + for ( cur = 0 ; cur < last_pos ; ) { <nl> + mlen = opt [ cur ] . mlen ; <nl> + if ( mlen = = 1 ) { ip + + ; cur + + ; continue ; } <nl> + offset = opt [ cur ] . off ; <nl> + cur + = mlen ; <nl> + litLength = ( U32 ) ( ip - anchor ) ; <nl> + <nl> + if ( offset > ZSTD_REP_MOVE_OPT ) { <nl> + rep [ 2 ] = rep [ 1 ] ; <nl> + rep [ 1 ] = rep [ 0 ] ; <nl> + rep [ 0 ] = offset - ZSTD_REP_MOVE_OPT ; <nl> + offset - - ; <nl> + } else { <nl> + if ( offset ! = 0 ) { <nl> + best_off = ( offset = = ZSTD_REP_MOVE_OPT ) ? ( rep [ 0 ] - 1 ) : ( rep [ offset ] ) ; <nl> + if ( offset ! = 1 ) rep [ 2 ] = rep [ 1 ] ; <nl> + rep [ 1 ] = rep [ 0 ] ; <nl> + rep [ 0 ] = best_off ; <nl> + } <nl> + if ( litLength = = 0 ) offset - - ; <nl> + } <nl> + <nl> + ZSTD_updatePrice ( seqStorePtr , litLength , anchor , offset , mlen - MINMATCH ) ; <nl> + ZSTD_storeSeq ( seqStorePtr , litLength , anchor , offset , mlen - MINMATCH ) ; <nl> + anchor = ip = ip + mlen ; <nl> + } } / * for ( cur = 0 ; cur < last_pos ; ) * / <nl> + <nl> + / * Save reps for next block * / <nl> + { int i ; for ( i = 0 ; i < ZSTD_REP_NUM ; i + + ) ctx - > repToConfirm [ i ] = rep [ i ] ; } <nl> + <nl> + / * Last Literals * / <nl> + { size_t const lastLLSize = iend - anchor ; <nl> + memcpy ( seqStorePtr - > lit , anchor , lastLLSize ) ; <nl> + seqStorePtr - > lit + = lastLLSize ; <nl> + } <nl> + } <nl> + <nl> + <nl> + FORCE_INLINE <nl> + void ZSTD_compressBlock_opt_extDict_generic ( ZSTD_CCtx * ctx , <nl> + const void * src , size_t srcSize , const int ultra ) <nl> + { <nl> + seqStore_t * seqStorePtr = & ( ctx - > seqStore ) ; <nl> + const BYTE * const istart = ( const BYTE * ) src ; <nl> + const BYTE * ip = istart ; <nl> + const BYTE * anchor = istart ; <nl> + const BYTE * const iend = istart + srcSize ; <nl> + const BYTE * const ilimit = iend - 8 ; <nl> + const BYTE * const base = ctx - > base ; <nl> + const U32 lowestIndex = ctx - > lowLimit ; <nl> + const U32 dictLimit = ctx - > dictLimit ; <nl> + const BYTE * const prefixStart = base + dictLimit ; <nl> + const BYTE * const dictBase = ctx - > dictBase ; <nl> + const BYTE * const dictEnd = dictBase + dictLimit ; <nl> + <nl> + const U32 maxSearches = 1U < < ctx - > params . cParams . searchLog ; <nl> + const U32 sufficient_len = ctx - > params . cParams . targetLength ; <nl> + const U32 mls = ctx - > params . cParams . searchLength ; <nl> + const U32 minMatch = ( ctx - > params . cParams . searchLength = = 3 ) ? 3 : 4 ; <nl> + <nl> + ZSTD_optimal_t * opt = seqStorePtr - > priceTable ; <nl> + ZSTD_match_t * matches = seqStorePtr - > matchTable ; <nl> + const BYTE * inr ; <nl> + <nl> + / * init * / <nl> + U32 offset , rep [ ZSTD_REP_NUM ] ; <nl> + { U32 i ; for ( i = 0 ; i < ZSTD_REP_NUM ; i + + ) rep [ i ] = ctx - > rep [ i ] ; } <nl> + <nl> + ctx - > nextToUpdate3 = ctx - > nextToUpdate ; <nl> + ZSTD_rescaleFreqs ( seqStorePtr , ( const BYTE * ) src , srcSize ) ; <nl> + ip + = ( ip = = prefixStart ) ; <nl> + <nl> + / * Match Loop * / <nl> + while ( ip < ilimit ) { <nl> + U32 cur , match_num , last_pos , litlen , price ; <nl> + U32 u , mlen , best_mlen , best_off , litLength ; <nl> + U32 current = ( U32 ) ( ip - base ) ; <nl> + memset ( opt , 0 , sizeof ( ZSTD_optimal_t ) ) ; <nl> + last_pos = 0 ; <nl> + opt [ 0 ] . litlen = ( U32 ) ( ip - anchor ) ; <nl> + <nl> + / * check repCode * / <nl> + { U32 i , last_i = ZSTD_REP_CHECK + ( ip = = anchor ) ; <nl> + for ( i = ( ip = = anchor ) ; i < last_i ; i + + ) { <nl> + const S32 repCur = ( i = = ZSTD_REP_MOVE_OPT ) ? ( rep [ 0 ] - 1 ) : rep [ i ] ; <nl> + const U32 repIndex = ( U32 ) ( current - repCur ) ; <nl> + const BYTE * const repBase = repIndex < dictLimit ? dictBase : base ; <nl> + const BYTE * const repMatch = repBase + repIndex ; <nl> + if ( ( repCur > 0 & & repCur < = ( S32 ) current ) <nl> + & & ( ( ( U32 ) ( ( dictLimit - 1 ) - repIndex ) > = 3 ) & ( repIndex > lowestIndex ) ) / * intentional overflow * / <nl> + & & ( MEM_readMINMATCH ( ip , minMatch ) = = MEM_readMINMATCH ( repMatch , minMatch ) ) ) { <nl> + / * repcode detected we should take it * / <nl> + const BYTE * const repEnd = repIndex < dictLimit ? dictEnd : iend ; <nl> + mlen = ( U32 ) ZSTD_count_2segments ( ip + minMatch , repMatch + minMatch , iend , repEnd , prefixStart ) + minMatch ; <nl> + <nl> + if ( mlen > sufficient_len | | mlen > = ZSTD_OPT_NUM ) { <nl> + best_mlen = mlen ; best_off = i ; cur = 0 ; last_pos = 1 ; <nl> + goto _storeSequence ; <nl> + } <nl> + <nl> + best_off = i - ( ip = = anchor ) ; <nl> + litlen = opt [ 0 ] . litlen ; <nl> + do { <nl> + price = ZSTD_getPrice ( seqStorePtr , litlen , anchor , best_off , mlen - MINMATCH , ultra ) ; <nl> + if ( mlen > last_pos | | price < opt [ mlen ] . price ) <nl> + SET_PRICE ( mlen , mlen , i , litlen , price ) ; / * note : macro modifies last_pos * / <nl> + mlen - - ; <nl> + } while ( mlen > = minMatch ) ; <nl> + } } } <nl> + <nl> + match_num = ZSTD_BtGetAllMatches_selectMLS_extDict ( ctx , ip , iend , maxSearches , mls , matches , minMatch ) ; / * first search ( depth 0 ) * / <nl> + <nl> + if ( ! last_pos & & ! match_num ) { ip + + ; continue ; } <nl> + <nl> + { U32 i ; for ( i = 0 ; i < ZSTD_REP_NUM ; i + + ) opt [ 0 ] . rep [ i ] = rep [ i ] ; } <nl> + opt [ 0 ] . mlen = 1 ; <nl> + <nl> + if ( match_num & & ( matches [ match_num - 1 ] . len > sufficient_len | | matches [ match_num - 1 ] . len > = ZSTD_OPT_NUM ) ) { <nl> + best_mlen = matches [ match_num - 1 ] . len ; <nl> + best_off = matches [ match_num - 1 ] . off ; <nl> + cur = 0 ; <nl> + last_pos = 1 ; <nl> + goto _storeSequence ; <nl> + } <nl> + <nl> + best_mlen = ( last_pos ) ? last_pos : minMatch ; <nl> + <nl> + / * set prices using matches at position = 0 * / <nl> + for ( u = 0 ; u < match_num ; u + + ) { <nl> + mlen = ( u > 0 ) ? matches [ u - 1 ] . len + 1 : best_mlen ; <nl> + best_mlen = matches [ u ] . len ; <nl> + litlen = opt [ 0 ] . litlen ; <nl> + while ( mlen < = best_mlen ) { <nl> + price = ZSTD_getPrice ( seqStorePtr , litlen , anchor , matches [ u ] . off - 1 , mlen - MINMATCH , ultra ) ; <nl> + if ( mlen > last_pos | | price < opt [ mlen ] . price ) <nl> + SET_PRICE ( mlen , mlen , matches [ u ] . off , litlen , price ) ; <nl> + mlen + + ; <nl> + } } <nl> + <nl> + if ( last_pos < minMatch ) { <nl> + ip + + ; continue ; <nl> + } <nl> + <nl> + / * check further positions * / <nl> + for ( cur = 1 ; cur < = last_pos ; cur + + ) { <nl> + inr = ip + cur ; <nl> + <nl> + if ( opt [ cur - 1 ] . mlen = = 1 ) { <nl> + litlen = opt [ cur - 1 ] . litlen + 1 ; <nl> + if ( cur > litlen ) { <nl> + price = opt [ cur - litlen ] . price + ZSTD_getLiteralPrice ( seqStorePtr , litlen , inr - litlen ) ; <nl> + } else <nl> + price = ZSTD_getLiteralPrice ( seqStorePtr , litlen , anchor ) ; <nl> + } else { <nl> + litlen = 1 ; <nl> + price = opt [ cur - 1 ] . price + ZSTD_getLiteralPrice ( seqStorePtr , litlen , inr - 1 ) ; <nl> + } <nl> + <nl> + if ( cur > last_pos | | price < = opt [ cur ] . price ) <nl> + SET_PRICE ( cur , 1 , 0 , litlen , price ) ; <nl> + <nl> + if ( cur = = last_pos ) break ; <nl> + <nl> + if ( inr > ilimit ) / * last match must start at a minimum distance of 8 from oend * / <nl> + continue ; <nl> + <nl> + mlen = opt [ cur ] . mlen ; <nl> + if ( opt [ cur ] . off > ZSTD_REP_MOVE_OPT ) { <nl> + opt [ cur ] . rep [ 2 ] = opt [ cur - mlen ] . rep [ 1 ] ; <nl> + opt [ cur ] . rep [ 1 ] = opt [ cur - mlen ] . rep [ 0 ] ; <nl> + opt [ cur ] . rep [ 0 ] = opt [ cur ] . off - ZSTD_REP_MOVE_OPT ; <nl> + } else { <nl> + opt [ cur ] . rep [ 2 ] = ( opt [ cur ] . off > 1 ) ? opt [ cur - mlen ] . rep [ 1 ] : opt [ cur - mlen ] . rep [ 2 ] ; <nl> + opt [ cur ] . rep [ 1 ] = ( opt [ cur ] . off > 0 ) ? opt [ cur - mlen ] . rep [ 0 ] : opt [ cur - mlen ] . rep [ 1 ] ; <nl> + opt [ cur ] . rep [ 0 ] = ( ( opt [ cur ] . off = = ZSTD_REP_MOVE_OPT ) & & ( mlen ! = 1 ) ) ? ( opt [ cur - mlen ] . rep [ 0 ] - 1 ) : ( opt [ cur - mlen ] . rep [ opt [ cur ] . off ] ) ; <nl> + } <nl> + <nl> + best_mlen = minMatch ; <nl> + { U32 i , last_i = ZSTD_REP_CHECK + ( mlen ! = 1 ) ; <nl> + for ( i = ( mlen ! = 1 ) ; i < last_i ; i + + ) { <nl> + const S32 repCur = ( i = = ZSTD_REP_MOVE_OPT ) ? ( opt [ cur ] . rep [ 0 ] - 1 ) : opt [ cur ] . rep [ i ] ; <nl> + const U32 repIndex = ( U32 ) ( current + cur - repCur ) ; <nl> + const BYTE * const repBase = repIndex < dictLimit ? dictBase : base ; <nl> + const BYTE * const repMatch = repBase + repIndex ; <nl> + if ( ( repCur > 0 & & repCur < = ( S32 ) ( current + cur ) ) <nl> + & & ( ( ( U32 ) ( ( dictLimit - 1 ) - repIndex ) > = 3 ) & ( repIndex > lowestIndex ) ) / * intentional overflow * / <nl> + & & ( MEM_readMINMATCH ( inr , minMatch ) = = MEM_readMINMATCH ( repMatch , minMatch ) ) ) { <nl> + / * repcode detected * / <nl> + const BYTE * const repEnd = repIndex < dictLimit ? dictEnd : iend ; <nl> + mlen = ( U32 ) ZSTD_count_2segments ( inr + minMatch , repMatch + minMatch , iend , repEnd , prefixStart ) + minMatch ; <nl> + <nl> + if ( mlen > sufficient_len | | cur + mlen > = ZSTD_OPT_NUM ) { <nl> + best_mlen = mlen ; best_off = i ; last_pos = cur + 1 ; <nl> + goto _storeSequence ; <nl> + } <nl> + <nl> + best_off = i - ( opt [ cur ] . mlen ! = 1 ) ; <nl> + if ( mlen > best_mlen ) best_mlen = mlen ; <nl> + <nl> + do { <nl> + if ( opt [ cur ] . mlen = = 1 ) { <nl> + litlen = opt [ cur ] . litlen ; <nl> + if ( cur > litlen ) { <nl> + price = opt [ cur - litlen ] . price + ZSTD_getPrice ( seqStorePtr , litlen , inr - litlen , best_off , mlen - MINMATCH , ultra ) ; <nl> + } else <nl> + price = ZSTD_getPrice ( seqStorePtr , litlen , anchor , best_off , mlen - MINMATCH , ultra ) ; <nl> + } else { <nl> + litlen = 0 ; <nl> + price = opt [ cur ] . price + ZSTD_getPrice ( seqStorePtr , 0 , NULL , best_off , mlen - MINMATCH , ultra ) ; <nl> + } <nl> + <nl> + if ( cur + mlen > last_pos | | price < = opt [ cur + mlen ] . price ) <nl> + SET_PRICE ( cur + mlen , mlen , i , litlen , price ) ; <nl> + mlen - - ; <nl> + } while ( mlen > = minMatch ) ; <nl> + } } } <nl> + <nl> + match_num = ZSTD_BtGetAllMatches_selectMLS_extDict ( ctx , inr , iend , maxSearches , mls , matches , minMatch ) ; <nl> + <nl> + if ( match_num > 0 & & ( matches [ match_num - 1 ] . len > sufficient_len | | cur + matches [ match_num - 1 ] . len > = ZSTD_OPT_NUM ) ) { <nl> + best_mlen = matches [ match_num - 1 ] . len ; <nl> + best_off = matches [ match_num - 1 ] . off ; <nl> + last_pos = cur + 1 ; <nl> + goto _storeSequence ; <nl> + } <nl> + <nl> + / * set prices using matches at position = cur * / <nl> + for ( u = 0 ; u < match_num ; u + + ) { <nl> + mlen = ( u > 0 ) ? matches [ u - 1 ] . len + 1 : best_mlen ; <nl> + best_mlen = matches [ u ] . len ; <nl> + <nl> + while ( mlen < = best_mlen ) { <nl> + if ( opt [ cur ] . mlen = = 1 ) { <nl> + litlen = opt [ cur ] . litlen ; <nl> + if ( cur > litlen ) <nl> + price = opt [ cur - litlen ] . price + ZSTD_getPrice ( seqStorePtr , litlen , ip + cur - litlen , matches [ u ] . off - 1 , mlen - MINMATCH , ultra ) ; <nl> + else <nl> + price = ZSTD_getPrice ( seqStorePtr , litlen , anchor , matches [ u ] . off - 1 , mlen - MINMATCH , ultra ) ; <nl> + } else { <nl> + litlen = 0 ; <nl> + price = opt [ cur ] . price + ZSTD_getPrice ( seqStorePtr , 0 , NULL , matches [ u ] . off - 1 , mlen - MINMATCH , ultra ) ; <nl> + } <nl> + <nl> + if ( cur + mlen > last_pos | | ( price < opt [ cur + mlen ] . price ) ) <nl> + SET_PRICE ( cur + mlen , mlen , matches [ u ] . off , litlen , price ) ; <nl> + <nl> + mlen + + ; <nl> + } } } / * for ( cur = 1 ; cur < = last_pos ; cur + + ) * / <nl> + <nl> + best_mlen = opt [ last_pos ] . mlen ; <nl> + best_off = opt [ last_pos ] . off ; <nl> + cur = last_pos - best_mlen ; <nl> + <nl> + / * store sequence * / <nl> + _storeSequence : / * cur , last_pos , best_mlen , best_off have to be set * / <nl> + opt [ 0 ] . mlen = 1 ; <nl> + <nl> + while ( 1 ) { <nl> + mlen = opt [ cur ] . mlen ; <nl> + offset = opt [ cur ] . off ; <nl> + opt [ cur ] . mlen = best_mlen ; <nl> + opt [ cur ] . off = best_off ; <nl> + best_mlen = mlen ; <nl> + best_off = offset ; <nl> + if ( mlen > cur ) break ; <nl> + cur - = mlen ; <nl> + } <nl> + <nl> + for ( u = 0 ; u < = last_pos ; ) { <nl> + u + = opt [ u ] . mlen ; <nl> + } <nl> + <nl> + for ( cur = 0 ; cur < last_pos ; ) { <nl> + mlen = opt [ cur ] . mlen ; <nl> + if ( mlen = = 1 ) { ip + + ; cur + + ; continue ; } <nl> + offset = opt [ cur ] . off ; <nl> + cur + = mlen ; <nl> + litLength = ( U32 ) ( ip - anchor ) ; <nl> + <nl> + if ( offset > ZSTD_REP_MOVE_OPT ) { <nl> + rep [ 2 ] = rep [ 1 ] ; <nl> + rep [ 1 ] = rep [ 0 ] ; <nl> + rep [ 0 ] = offset - ZSTD_REP_MOVE_OPT ; <nl> + offset - - ; <nl> + } else { <nl> + if ( offset ! = 0 ) { <nl> + best_off = ( offset = = ZSTD_REP_MOVE_OPT ) ? ( rep [ 0 ] - 1 ) : ( rep [ offset ] ) ; <nl> + if ( offset ! = 1 ) rep [ 2 ] = rep [ 1 ] ; <nl> + rep [ 1 ] = rep [ 0 ] ; <nl> + rep [ 0 ] = best_off ; <nl> + } <nl> + <nl> + if ( litLength = = 0 ) offset - - ; <nl> + } <nl> + <nl> + ZSTD_updatePrice ( seqStorePtr , litLength , anchor , offset , mlen - MINMATCH ) ; <nl> + ZSTD_storeSeq ( seqStorePtr , litLength , anchor , offset , mlen - MINMATCH ) ; <nl> + anchor = ip = ip + mlen ; <nl> + } } / * for ( cur = 0 ; cur < last_pos ; ) * / <nl> + <nl> + / * Save reps for next block * / <nl> + { int i ; for ( i = 0 ; i < ZSTD_REP_NUM ; i + + ) ctx - > repToConfirm [ i ] = rep [ i ] ; } <nl> + <nl> + / * Last Literals * / <nl> + { size_t lastLLSize = iend - anchor ; <nl> + memcpy ( seqStorePtr - > lit , anchor , lastLLSize ) ; <nl> + seqStorePtr - > lit + = lastLLSize ; <nl> + } <nl> + } <nl> + <nl> + # endif / * ZSTD_OPT_H_91842398743 * / <nl> new file mode 100644 <nl> index 00000000000 . . fc7f52a2902 <nl> mmm / dev / null <nl> ppp b / thirdparty / zstd / compress / zstdmt_compress . c <nl> <nl> + / * * <nl> + * Copyright ( c ) 2016 - present , Yann Collet , Facebook , Inc . <nl> + * All rights reserved . <nl> + * <nl> + * This source code is licensed under the BSD - style license found in the <nl> + * LICENSE file in the root directory of this source tree . An additional grant <nl> + * of patent rights can be found in the PATENTS file in the same directory . <nl> + * / <nl> + <nl> + <nl> + / * = = = = = = Tuning parameters = = = = = = * / <nl> + # define ZSTDMT_NBTHREADS_MAX 128 <nl> + <nl> + <nl> + / * = = = = = = Compiler specifics = = = = = = * / <nl> + # if defined ( _MSC_VER ) <nl> + # pragma warning ( disable : 4204 ) / * disable : C4204 : non - constant aggregate initializer * / <nl> + # endif <nl> + <nl> + <nl> + / * = = = = = = Dependencies = = = = = = * / <nl> + # include < stdlib . h > / * malloc * / <nl> + # include < string . h > / * memcpy * / <nl> + # include " pool . h " / * threadpool * / <nl> + # include " threading . h " / * mutex * / <nl> + # include " zstd_internal . h " / * MIN , ERROR , ZSTD_ * , ZSTD_highbit32 * / <nl> + # include " zstdmt_compress . h " <nl> + <nl> + <nl> + / * = = = = = = Debug = = = = = = * / <nl> + # if 0 <nl> + <nl> + # include < stdio . h > <nl> + # include < unistd . h > <nl> + # include < sys / times . h > <nl> + static unsigned g_debugLevel = 5 ; <nl> + # define DEBUGLOGRAW ( l , . . . ) if ( l < = g_debugLevel ) { fprintf ( stderr , __VA_ARGS__ ) ; } <nl> + # define DEBUGLOG ( l , . . . ) if ( l < = g_debugLevel ) { fprintf ( stderr , __FILE__ " : " ) ; fprintf ( stderr , __VA_ARGS__ ) ; fprintf ( stderr , " \ n " ) ; } <nl> + <nl> + # define DEBUG_PRINTHEX ( l , p , n ) { \ <nl> + unsigned debug_u ; \ <nl> + for ( debug_u = 0 ; debug_u < ( n ) ; debug_u + + ) \ <nl> + DEBUGLOGRAW ( l , " % 02X " , ( ( const unsigned char * ) ( p ) ) [ debug_u ] ) ; \ <nl> + DEBUGLOGRAW ( l , " \ n " ) ; \ <nl> + } <nl> + <nl> + static unsigned long long GetCurrentClockTimeMicroseconds ( void ) <nl> + { <nl> + static clock_t _ticksPerSecond = 0 ; <nl> + if ( _ticksPerSecond < = 0 ) _ticksPerSecond = sysconf ( _SC_CLK_TCK ) ; <nl> + <nl> + { struct tms junk ; clock_t newTicks = ( clock_t ) times ( & junk ) ; <nl> + return ( ( ( ( unsigned long long ) newTicks ) * ( 1000000 ) ) / _ticksPerSecond ) ; } <nl> + } <nl> + <nl> + # define MUTEX_WAIT_TIME_DLEVEL 5 <nl> + # define PTHREAD_MUTEX_LOCK ( mutex ) \ <nl> + if ( g_debugLevel > = MUTEX_WAIT_TIME_DLEVEL ) { \ <nl> + unsigned long long const beforeTime = GetCurrentClockTimeMicroseconds ( ) ; \ <nl> + pthread_mutex_lock ( mutex ) ; \ <nl> + { unsigned long long const afterTime = GetCurrentClockTimeMicroseconds ( ) ; \ <nl> + unsigned long long const elapsedTime = ( afterTime - beforeTime ) ; \ <nl> + if ( elapsedTime > 1000 ) { / * or whatever threshold you like ; I ' m using 1 millisecond here * / \ <nl> + DEBUGLOG ( MUTEX_WAIT_TIME_DLEVEL , " Thread took % llu microseconds to acquire mutex % s \ n " , \ <nl> + elapsedTime , # mutex ) ; \ <nl> + } } \ <nl> + } else pthread_mutex_lock ( mutex ) ; <nl> + <nl> + # else <nl> + <nl> + # define DEBUGLOG ( l , . . . ) { } / * disabled * / <nl> + # define PTHREAD_MUTEX_LOCK ( m ) pthread_mutex_lock ( m ) <nl> + # define DEBUG_PRINTHEX ( l , p , n ) { } <nl> + <nl> + # endif <nl> + <nl> + <nl> + / * = = = = = Buffer Pool = = = = = * / <nl> + <nl> + typedef struct buffer_s { <nl> + void * start ; <nl> + size_t size ; <nl> + } buffer_t ; <nl> + <nl> + static const buffer_t g_nullBuffer = { NULL , 0 } ; <nl> + <nl> + typedef struct ZSTDMT_bufferPool_s { <nl> + unsigned totalBuffers ; <nl> + unsigned nbBuffers ; <nl> + buffer_t bTable [ 1 ] ; / * variable size * / <nl> + } ZSTDMT_bufferPool ; <nl> + <nl> + static ZSTDMT_bufferPool * ZSTDMT_createBufferPool ( unsigned nbThreads ) <nl> + { <nl> + unsigned const maxNbBuffers = 2 * nbThreads + 2 ; <nl> + ZSTDMT_bufferPool * const bufPool = ( ZSTDMT_bufferPool * ) calloc ( 1 , sizeof ( ZSTDMT_bufferPool ) + ( maxNbBuffers - 1 ) * sizeof ( buffer_t ) ) ; <nl> + if ( bufPool = = NULL ) return NULL ; <nl> + bufPool - > totalBuffers = maxNbBuffers ; <nl> + bufPool - > nbBuffers = 0 ; <nl> + return bufPool ; <nl> + } <nl> + <nl> + static void ZSTDMT_freeBufferPool ( ZSTDMT_bufferPool * bufPool ) <nl> + { <nl> + unsigned u ; <nl> + if ( ! bufPool ) return ; / * compatibility with free on NULL * / <nl> + for ( u = 0 ; u < bufPool - > totalBuffers ; u + + ) <nl> + free ( bufPool - > bTable [ u ] . start ) ; <nl> + free ( bufPool ) ; <nl> + } <nl> + <nl> + / * assumption : invocation from main thread only ! * / <nl> + static buffer_t ZSTDMT_getBuffer ( ZSTDMT_bufferPool * pool , size_t bSize ) <nl> + { <nl> + if ( pool - > nbBuffers ) { / * try to use an existing buffer * / <nl> + buffer_t const buf = pool - > bTable [ - - ( pool - > nbBuffers ) ] ; <nl> + size_t const availBufferSize = buf . size ; <nl> + if ( ( availBufferSize > = bSize ) & ( availBufferSize < = 10 * bSize ) ) / * large enough , but not too much * / <nl> + return buf ; <nl> + free ( buf . start ) ; / * size conditions not respected : scratch this buffer and create a new one * / <nl> + } <nl> + / * create new buffer * / <nl> + { buffer_t buffer ; <nl> + void * const start = malloc ( bSize ) ; <nl> + if ( start = = NULL ) bSize = 0 ; <nl> + buffer . start = start ; / * note : start can be NULL if malloc fails ! * / <nl> + buffer . size = bSize ; <nl> + return buffer ; <nl> + } <nl> + } <nl> + <nl> + / * store buffer for later re - use , up to pool capacity * / <nl> + static void ZSTDMT_releaseBuffer ( ZSTDMT_bufferPool * pool , buffer_t buf ) <nl> + { <nl> + if ( buf . start = = NULL ) return ; / * release on NULL * / <nl> + if ( pool - > nbBuffers < pool - > totalBuffers ) { <nl> + pool - > bTable [ pool - > nbBuffers + + ] = buf ; / * store for later re - use * / <nl> + return ; <nl> + } <nl> + / * Reached bufferPool capacity ( should not happen ) * / <nl> + free ( buf . start ) ; <nl> + } <nl> + <nl> + <nl> + / * = = = = = CCtx Pool = = = = = * / <nl> + <nl> + typedef struct { <nl> + unsigned totalCCtx ; <nl> + unsigned availCCtx ; <nl> + ZSTD_CCtx * cctx [ 1 ] ; / * variable size * / <nl> + } ZSTDMT_CCtxPool ; <nl> + <nl> + / * assumption : CCtxPool invocation only from main thread * / <nl> + <nl> + / * note : all CCtx borrowed from the pool should be released back to the pool _before_ freeing the pool * / <nl> + static void ZSTDMT_freeCCtxPool ( ZSTDMT_CCtxPool * pool ) <nl> + { <nl> + unsigned u ; <nl> + for ( u = 0 ; u < pool - > totalCCtx ; u + + ) <nl> + ZSTD_freeCCtx ( pool - > cctx [ u ] ) ; / * note : compatible with free on NULL * / <nl> + free ( pool ) ; <nl> + } <nl> + <nl> + / * ZSTDMT_createCCtxPool ( ) : <nl> + * implies nbThreads > = 1 , checked by caller ZSTDMT_createCCtx ( ) * / <nl> + static ZSTDMT_CCtxPool * ZSTDMT_createCCtxPool ( unsigned nbThreads ) <nl> + { <nl> + ZSTDMT_CCtxPool * const cctxPool = ( ZSTDMT_CCtxPool * ) calloc ( 1 , sizeof ( ZSTDMT_CCtxPool ) + ( nbThreads - 1 ) * sizeof ( ZSTD_CCtx * ) ) ; <nl> + if ( ! cctxPool ) return NULL ; <nl> + cctxPool - > totalCCtx = nbThreads ; <nl> + cctxPool - > availCCtx = 1 ; / * at least one cctx for single - thread mode * / <nl> + cctxPool - > cctx [ 0 ] = ZSTD_createCCtx ( ) ; <nl> + if ( ! cctxPool - > cctx [ 0 ] ) { ZSTDMT_freeCCtxPool ( cctxPool ) ; return NULL ; } <nl> + DEBUGLOG ( 1 , " cctxPool created , with % u threads " , nbThreads ) ; <nl> + return cctxPool ; <nl> + } <nl> + <nl> + static ZSTD_CCtx * ZSTDMT_getCCtx ( ZSTDMT_CCtxPool * pool ) <nl> + { <nl> + if ( pool - > availCCtx ) { <nl> + pool - > availCCtx - - ; <nl> + return pool - > cctx [ pool - > availCCtx ] ; <nl> + } <nl> + return ZSTD_createCCtx ( ) ; / * note : can be NULL , when creation fails ! * / <nl> + } <nl> + <nl> + static void ZSTDMT_releaseCCtx ( ZSTDMT_CCtxPool * pool , ZSTD_CCtx * cctx ) <nl> + { <nl> + if ( cctx = = NULL ) return ; / * compatibility with release on NULL * / <nl> + if ( pool - > availCCtx < pool - > totalCCtx ) <nl> + pool - > cctx [ pool - > availCCtx + + ] = cctx ; <nl> + else <nl> + / * pool overflow : should not happen , since totalCCtx = = nbThreads * / <nl> + ZSTD_freeCCtx ( cctx ) ; <nl> + } <nl> + <nl> + <nl> + / * = = = = = Thread worker = = = = = * / <nl> + <nl> + typedef struct { <nl> + buffer_t buffer ; <nl> + size_t filled ; <nl> + } inBuff_t ; <nl> + <nl> + typedef struct { <nl> + ZSTD_CCtx * cctx ; <nl> + buffer_t src ; <nl> + const void * srcStart ; <nl> + size_t srcSize ; <nl> + size_t dictSize ; <nl> + buffer_t dstBuff ; <nl> + size_t cSize ; <nl> + size_t dstFlushed ; <nl> + unsigned firstChunk ; <nl> + unsigned lastChunk ; <nl> + unsigned jobCompleted ; <nl> + unsigned jobScanned ; <nl> + pthread_mutex_t * jobCompleted_mutex ; <nl> + pthread_cond_t * jobCompleted_cond ; <nl> + ZSTD_parameters params ; <nl> + ZSTD_CDict * cdict ; <nl> + unsigned long long fullFrameSize ; <nl> + } ZSTDMT_jobDescription ; <nl> + <nl> + / * ZSTDMT_compressChunk ( ) : POOL_function type * / <nl> + void ZSTDMT_compressChunk ( void * jobDescription ) <nl> + { <nl> + ZSTDMT_jobDescription * const job = ( ZSTDMT_jobDescription * ) jobDescription ; <nl> + const void * const src = ( const char * ) job - > srcStart + job - > dictSize ; <nl> + buffer_t const dstBuff = job - > dstBuff ; <nl> + DEBUGLOG ( 3 , " job ( first : % u ) ( last : % u ) : dictSize % u , srcSize % u " , <nl> + job - > firstChunk , job - > lastChunk , ( U32 ) job - > dictSize , ( U32 ) job - > srcSize ) ; <nl> + if ( job - > cdict ) { / * should only happen for first segment * / <nl> + size_t const initError = ZSTD_compressBegin_usingCDict_advanced ( job - > cctx , job - > cdict , job - > params . fParams , job - > fullFrameSize ) ; <nl> + if ( job - > cdict ) DEBUGLOG ( 3 , " using CDict " ) ; <nl> + if ( ZSTD_isError ( initError ) ) { job - > cSize = initError ; goto _endJob ; } <nl> + } else { / * srcStart points at reloaded section * / <nl> + if ( ! job - > firstChunk ) job - > params . fParams . contentSizeFlag = 0 ; / * ensure no srcSize control * / <nl> + { size_t const dictModeError = ZSTD_setCCtxParameter ( job - > cctx , ZSTD_p_forceRawDict , 1 ) ; / * Force loading dictionary in " content - only " mode ( no header analysis ) * / <nl> + size_t const initError = ZSTD_compressBegin_advanced ( job - > cctx , job - > srcStart , job - > dictSize , job - > params , job - > fullFrameSize ) ; <nl> + if ( ZSTD_isError ( initError ) | | ZSTD_isError ( dictModeError ) ) { job - > cSize = initError ; goto _endJob ; } <nl> + ZSTD_setCCtxParameter ( job - > cctx , ZSTD_p_forceWindow , 1 ) ; <nl> + } } <nl> + if ( ! job - > firstChunk ) { / * flush and overwrite frame header when it ' s not first segment * / <nl> + size_t const hSize = ZSTD_compressContinue ( job - > cctx , dstBuff . start , dstBuff . size , src , 0 ) ; <nl> + if ( ZSTD_isError ( hSize ) ) { job - > cSize = hSize ; goto _endJob ; } <nl> + ZSTD_invalidateRepCodes ( job - > cctx ) ; <nl> + } <nl> + <nl> + DEBUGLOG ( 4 , " Compressing : " ) ; <nl> + DEBUG_PRINTHEX ( 4 , job - > srcStart , 12 ) ; <nl> + job - > cSize = ( job - > lastChunk ) ? <nl> + ZSTD_compressEnd ( job - > cctx , dstBuff . start , dstBuff . size , src , job - > srcSize ) : <nl> + ZSTD_compressContinue ( job - > cctx , dstBuff . start , dstBuff . size , src , job - > srcSize ) ; <nl> + DEBUGLOG ( 3 , " compressed % u bytes into % u bytes ( first : % u ) ( last : % u ) " , <nl> + ( unsigned ) job - > srcSize , ( unsigned ) job - > cSize , job - > firstChunk , job - > lastChunk ) ; <nl> + DEBUGLOG ( 5 , " dstBuff . size : % u ; = > % s " , ( U32 ) dstBuff . size , ZSTD_getErrorName ( job - > cSize ) ) ; <nl> + <nl> + _endJob : <nl> + PTHREAD_MUTEX_LOCK ( job - > jobCompleted_mutex ) ; <nl> + job - > jobCompleted = 1 ; <nl> + job - > jobScanned = 0 ; <nl> + pthread_cond_signal ( job - > jobCompleted_cond ) ; <nl> + pthread_mutex_unlock ( job - > jobCompleted_mutex ) ; <nl> + } <nl> + <nl> + <nl> + / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> + / * = = = = = Multi - threaded compression = = = = = * / <nl> + / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> + <nl> + struct ZSTDMT_CCtx_s { <nl> + POOL_ctx * factory ; <nl> + ZSTDMT_bufferPool * buffPool ; <nl> + ZSTDMT_CCtxPool * cctxPool ; <nl> + pthread_mutex_t jobCompleted_mutex ; <nl> + pthread_cond_t jobCompleted_cond ; <nl> + size_t targetSectionSize ; <nl> + size_t marginSize ; <nl> + size_t inBuffSize ; <nl> + size_t dictSize ; <nl> + size_t targetDictSize ; <nl> + inBuff_t inBuff ; <nl> + ZSTD_parameters params ; <nl> + XXH64_state_t xxhState ; <nl> + unsigned nbThreads ; <nl> + unsigned jobIDMask ; <nl> + unsigned doneJobID ; <nl> + unsigned nextJobID ; <nl> + unsigned frameEnded ; <nl> + unsigned allJobsCompleted ; <nl> + unsigned overlapRLog ; <nl> + unsigned long long frameContentSize ; <nl> + size_t sectionSize ; <nl> + ZSTD_CDict * cdict ; <nl> + ZSTD_CStream * cstream ; <nl> + ZSTDMT_jobDescription jobs [ 1 ] ; / * variable size ( must lies at the end ) * / <nl> + } ; <nl> + <nl> + ZSTDMT_CCtx * ZSTDMT_createCCtx ( unsigned nbThreads ) <nl> + { <nl> + ZSTDMT_CCtx * cctx ; <nl> + U32 const minNbJobs = nbThreads + 2 ; <nl> + U32 const nbJobsLog2 = ZSTD_highbit32 ( minNbJobs ) + 1 ; <nl> + U32 const nbJobs = 1 < < nbJobsLog2 ; <nl> + DEBUGLOG ( 5 , " nbThreads : % u ; minNbJobs : % u ; nbJobsLog2 : % u ; nbJobs : % u \ n " , <nl> + nbThreads , minNbJobs , nbJobsLog2 , nbJobs ) ; <nl> + if ( ( nbThreads < 1 ) | ( nbThreads > ZSTDMT_NBTHREADS_MAX ) ) return NULL ; <nl> + cctx = ( ZSTDMT_CCtx * ) calloc ( 1 , sizeof ( ZSTDMT_CCtx ) + nbJobs * sizeof ( ZSTDMT_jobDescription ) ) ; <nl> + if ( ! cctx ) return NULL ; <nl> + cctx - > nbThreads = nbThreads ; <nl> + cctx - > jobIDMask = nbJobs - 1 ; <nl> + cctx - > allJobsCompleted = 1 ; <nl> + cctx - > sectionSize = 0 ; <nl> + cctx - > overlapRLog = 3 ; <nl> + cctx - > factory = POOL_create ( nbThreads , 1 ) ; <nl> + cctx - > buffPool = ZSTDMT_createBufferPool ( nbThreads ) ; <nl> + cctx - > cctxPool = ZSTDMT_createCCtxPool ( nbThreads ) ; <nl> + if ( ! cctx - > factory | ! cctx - > buffPool | ! cctx - > cctxPool ) { / * one object was not created * / <nl> + ZSTDMT_freeCCtx ( cctx ) ; <nl> + return NULL ; <nl> + } <nl> + if ( nbThreads = = 1 ) { <nl> + cctx - > cstream = ZSTD_createCStream ( ) ; <nl> + if ( ! cctx - > cstream ) { <nl> + ZSTDMT_freeCCtx ( cctx ) ; return NULL ; <nl> + } } <nl> + pthread_mutex_init ( & cctx - > jobCompleted_mutex , NULL ) ; / * Todo : check init function return * / <nl> + pthread_cond_init ( & cctx - > jobCompleted_cond , NULL ) ; <nl> + DEBUGLOG ( 4 , " mt_cctx created , for % u threads \ n " , nbThreads ) ; <nl> + return cctx ; <nl> + } <nl> + <nl> + / * ZSTDMT_releaseAllJobResources ( ) : <nl> + * Ensure all workers are killed first . * / <nl> + static void ZSTDMT_releaseAllJobResources ( ZSTDMT_CCtx * mtctx ) <nl> + { <nl> + unsigned jobID ; <nl> + for ( jobID = 0 ; jobID < = mtctx - > jobIDMask ; jobID + + ) { <nl> + ZSTDMT_releaseBuffer ( mtctx - > buffPool , mtctx - > jobs [ jobID ] . dstBuff ) ; <nl> + mtctx - > jobs [ jobID ] . dstBuff = g_nullBuffer ; <nl> + ZSTDMT_releaseBuffer ( mtctx - > buffPool , mtctx - > jobs [ jobID ] . src ) ; <nl> + mtctx - > jobs [ jobID ] . src = g_nullBuffer ; <nl> + ZSTDMT_releaseCCtx ( mtctx - > cctxPool , mtctx - > jobs [ jobID ] . cctx ) ; <nl> + mtctx - > jobs [ jobID ] . cctx = NULL ; <nl> + } <nl> + memset ( mtctx - > jobs , 0 , ( mtctx - > jobIDMask + 1 ) * sizeof ( ZSTDMT_jobDescription ) ) ; <nl> + ZSTDMT_releaseBuffer ( mtctx - > buffPool , mtctx - > inBuff . buffer ) ; <nl> + mtctx - > inBuff . buffer = g_nullBuffer ; <nl> + mtctx - > allJobsCompleted = 1 ; <nl> + } <nl> + <nl> + size_t ZSTDMT_freeCCtx ( ZSTDMT_CCtx * mtctx ) <nl> + { <nl> + if ( mtctx = = NULL ) return 0 ; / * compatible with free on NULL * / <nl> + POOL_free ( mtctx - > factory ) ; <nl> + if ( ! mtctx - > allJobsCompleted ) ZSTDMT_releaseAllJobResources ( mtctx ) ; / * stop workers first * / <nl> + ZSTDMT_freeBufferPool ( mtctx - > buffPool ) ; / * release job resources into pools first * / <nl> + ZSTDMT_freeCCtxPool ( mtctx - > cctxPool ) ; <nl> + ZSTD_freeCDict ( mtctx - > cdict ) ; <nl> + ZSTD_freeCStream ( mtctx - > cstream ) ; <nl> + pthread_mutex_destroy ( & mtctx - > jobCompleted_mutex ) ; <nl> + pthread_cond_destroy ( & mtctx - > jobCompleted_cond ) ; <nl> + free ( mtctx ) ; <nl> + return 0 ; <nl> + } <nl> + <nl> + size_t ZSTDMT_setMTCtxParameter ( ZSTDMT_CCtx * mtctx , ZSDTMT_parameter parameter , unsigned value ) <nl> + { <nl> + switch ( parameter ) <nl> + { <nl> + case ZSTDMT_p_sectionSize : <nl> + mtctx - > sectionSize = value ; <nl> + return 0 ; <nl> + case ZSTDMT_p_overlapSectionLog : <nl> + DEBUGLOG ( 4 , " ZSTDMT_p_overlapSectionLog : % u " , value ) ; <nl> + mtctx - > overlapRLog = ( value > = 9 ) ? 0 : 9 - value ; <nl> + return 0 ; <nl> + default : <nl> + return ERROR ( compressionParameter_unsupported ) ; <nl> + } <nl> + } <nl> + <nl> + <nl> + / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> + / * = = = = = Multi - threaded compression = = = = = * / <nl> + / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> + <nl> + size_t ZSTDMT_compressCCtx ( ZSTDMT_CCtx * mtctx , <nl> + void * dst , size_t dstCapacity , <nl> + const void * src , size_t srcSize , <nl> + int compressionLevel ) <nl> + { <nl> + ZSTD_parameters params = ZSTD_getParams ( compressionLevel , srcSize , 0 ) ; <nl> + U32 const overlapLog = ( compressionLevel > = ZSTD_maxCLevel ( ) ) ? 0 : 3 ; <nl> + size_t const overlapSize = ( size_t ) 1 < < ( params . cParams . windowLog - overlapLog ) ; <nl> + size_t const chunkTargetSize = ( size_t ) 1 < < ( params . cParams . windowLog + 2 ) ; <nl> + unsigned const nbChunksMax = ( unsigned ) ( srcSize / chunkTargetSize ) + 1 ; <nl> + unsigned nbChunks = MIN ( nbChunksMax , mtctx - > nbThreads ) ; <nl> + size_t const proposedChunkSize = ( srcSize + ( nbChunks - 1 ) ) / nbChunks ; <nl> + size_t const avgChunkSize = ( ( proposedChunkSize & 0x1FFFF ) < 0xFFFF ) ? proposedChunkSize + 0xFFFF : proposedChunkSize ; / * avoid too small last block * / <nl> + size_t remainingSrcSize = srcSize ; <nl> + const char * const srcStart = ( const char * ) src ; <nl> + unsigned const compressWithinDst = ( dstCapacity > = ZSTD_compressBound ( srcSize ) ) ? nbChunks : ( unsigned ) ( dstCapacity / ZSTD_compressBound ( avgChunkSize ) ) ; / * presumes avgChunkSize > = 256 KB , which should be the case * / <nl> + size_t frameStartPos = 0 , dstBufferPos = 0 ; <nl> + <nl> + DEBUGLOG ( 3 , " windowLog : % 2u = > chunkTargetSize : % u bytes " , params . cParams . windowLog , ( U32 ) chunkTargetSize ) ; <nl> + DEBUGLOG ( 2 , " nbChunks : % 2u ( chunkSize : % u bytes ) " , nbChunks , ( U32 ) avgChunkSize ) ; <nl> + params . fParams . contentSizeFlag = 1 ; <nl> + <nl> + if ( nbChunks = = 1 ) { / * fallback to single - thread mode * / <nl> + ZSTD_CCtx * const cctx = mtctx - > cctxPool - > cctx [ 0 ] ; <nl> + return ZSTD_compressCCtx ( cctx , dst , dstCapacity , src , srcSize , compressionLevel ) ; <nl> + } <nl> + <nl> + { unsigned u ; <nl> + for ( u = 0 ; u < nbChunks ; u + + ) { <nl> + size_t const chunkSize = MIN ( remainingSrcSize , avgChunkSize ) ; <nl> + size_t const dstBufferCapacity = ZSTD_compressBound ( chunkSize ) ; <nl> + buffer_t const dstAsBuffer = { ( char * ) dst + dstBufferPos , dstBufferCapacity } ; <nl> + buffer_t const dstBuffer = u < compressWithinDst ? dstAsBuffer : ZSTDMT_getBuffer ( mtctx - > buffPool , dstBufferCapacity ) ; <nl> + ZSTD_CCtx * const cctx = ZSTDMT_getCCtx ( mtctx - > cctxPool ) ; <nl> + size_t dictSize = u ? overlapSize : 0 ; <nl> + <nl> + if ( ( cctx = = NULL ) | | ( dstBuffer . start = = NULL ) ) { <nl> + mtctx - > jobs [ u ] . cSize = ERROR ( memory_allocation ) ; / * job result * / <nl> + mtctx - > jobs [ u ] . jobCompleted = 1 ; <nl> + nbChunks = u + 1 ; <nl> + break ; / * let ' s wait for previous jobs to complete , but don ' t start new ones * / <nl> + } <nl> + <nl> + mtctx - > jobs [ u ] . srcStart = srcStart + frameStartPos - dictSize ; <nl> + mtctx - > jobs [ u ] . dictSize = dictSize ; <nl> + mtctx - > jobs [ u ] . srcSize = chunkSize ; <nl> + mtctx - > jobs [ u ] . fullFrameSize = srcSize ; <nl> + mtctx - > jobs [ u ] . params = params ; <nl> + mtctx - > jobs [ u ] . dstBuff = dstBuffer ; <nl> + mtctx - > jobs [ u ] . cctx = cctx ; <nl> + mtctx - > jobs [ u ] . firstChunk = ( u = = 0 ) ; <nl> + mtctx - > jobs [ u ] . lastChunk = ( u = = nbChunks - 1 ) ; <nl> + mtctx - > jobs [ u ] . jobCompleted = 0 ; <nl> + mtctx - > jobs [ u ] . jobCompleted_mutex = & mtctx - > jobCompleted_mutex ; <nl> + mtctx - > jobs [ u ] . jobCompleted_cond = & mtctx - > jobCompleted_cond ; <nl> + <nl> + DEBUGLOG ( 3 , " posting job % u ( % u bytes ) " , u , ( U32 ) chunkSize ) ; <nl> + DEBUG_PRINTHEX ( 3 , mtctx - > jobs [ u ] . srcStart , 12 ) ; <nl> + POOL_add ( mtctx - > factory , ZSTDMT_compressChunk , & mtctx - > jobs [ u ] ) ; <nl> + <nl> + frameStartPos + = chunkSize ; <nl> + dstBufferPos + = dstBufferCapacity ; <nl> + remainingSrcSize - = chunkSize ; <nl> + } } <nl> + / * note : since nbChunks < = nbThreads , all jobs should be running immediately in parallel * / <nl> + <nl> + { unsigned chunkID ; <nl> + size_t error = 0 , dstPos = 0 ; <nl> + for ( chunkID = 0 ; chunkID < nbChunks ; chunkID + + ) { <nl> + DEBUGLOG ( 3 , " waiting for chunk % u " , chunkID ) ; <nl> + PTHREAD_MUTEX_LOCK ( & mtctx - > jobCompleted_mutex ) ; <nl> + while ( mtctx - > jobs [ chunkID ] . jobCompleted = = 0 ) { <nl> + DEBUGLOG ( 4 , " waiting for jobCompleted signal from chunk % u " , chunkID ) ; <nl> + pthread_cond_wait ( & mtctx - > jobCompleted_cond , & mtctx - > jobCompleted_mutex ) ; <nl> + } <nl> + pthread_mutex_unlock ( & mtctx - > jobCompleted_mutex ) ; <nl> + DEBUGLOG ( 3 , " ready to write chunk % u " , chunkID ) ; <nl> + <nl> + ZSTDMT_releaseCCtx ( mtctx - > cctxPool , mtctx - > jobs [ chunkID ] . cctx ) ; <nl> + mtctx - > jobs [ chunkID ] . cctx = NULL ; <nl> + mtctx - > jobs [ chunkID ] . srcStart = NULL ; <nl> + { size_t const cSize = mtctx - > jobs [ chunkID ] . cSize ; <nl> + if ( ZSTD_isError ( cSize ) ) error = cSize ; <nl> + if ( ( ! error ) & & ( dstPos + cSize > dstCapacity ) ) error = ERROR ( dstSize_tooSmall ) ; <nl> + if ( chunkID ) { / * note : chunk 0 is already written directly into dst * / <nl> + if ( ! error ) <nl> + memmove ( ( char * ) dst + dstPos , mtctx - > jobs [ chunkID ] . dstBuff . start , cSize ) ; / * may overlap if chunk decompressed within dst * / <nl> + if ( chunkID > = compressWithinDst ) / * otherwise , it decompresses within dst * / <nl> + ZSTDMT_releaseBuffer ( mtctx - > buffPool , mtctx - > jobs [ chunkID ] . dstBuff ) ; <nl> + mtctx - > jobs [ chunkID ] . dstBuff = g_nullBuffer ; <nl> + } <nl> + dstPos + = cSize ; <nl> + } <nl> + } <nl> + if ( ! error ) DEBUGLOG ( 3 , " compressed size : % u " , ( U32 ) dstPos ) ; <nl> + return error ? error : dstPos ; <nl> + } <nl> + <nl> + } <nl> + <nl> + <nl> + / * = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> + / * = = = = = = = Streaming API = = = = = = = * / <nl> + / * = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> + <nl> + static void ZSTDMT_waitForAllJobsCompleted ( ZSTDMT_CCtx * zcs ) { <nl> + while ( zcs - > doneJobID < zcs - > nextJobID ) { <nl> + unsigned const jobID = zcs - > doneJobID & zcs - > jobIDMask ; <nl> + PTHREAD_MUTEX_LOCK ( & zcs - > jobCompleted_mutex ) ; <nl> + while ( zcs - > jobs [ jobID ] . jobCompleted = = 0 ) { <nl> + DEBUGLOG ( 4 , " waiting for jobCompleted signal from chunk % u " , zcs - > doneJobID ) ; / * we want to block when waiting for data to flush * / <nl> + pthread_cond_wait ( & zcs - > jobCompleted_cond , & zcs - > jobCompleted_mutex ) ; <nl> + } <nl> + pthread_mutex_unlock ( & zcs - > jobCompleted_mutex ) ; <nl> + zcs - > doneJobID + + ; <nl> + } <nl> + } <nl> + <nl> + <nl> + static size_t ZSTDMT_initCStream_internal ( ZSTDMT_CCtx * zcs , <nl> + const void * dict , size_t dictSize , unsigned updateDict , <nl> + ZSTD_parameters params , unsigned long long pledgedSrcSize ) <nl> + { <nl> + ZSTD_customMem const cmem = { NULL , NULL , NULL } ; <nl> + DEBUGLOG ( 3 , " Started new compression , with windowLog : % u " , params . cParams . windowLog ) ; <nl> + if ( zcs - > nbThreads = = 1 ) return ZSTD_initCStream_advanced ( zcs - > cstream , dict , dictSize , params , pledgedSrcSize ) ; <nl> + if ( zcs - > allJobsCompleted = = 0 ) { / * previous job not correctly finished * / <nl> + ZSTDMT_waitForAllJobsCompleted ( zcs ) ; <nl> + ZSTDMT_releaseAllJobResources ( zcs ) ; <nl> + zcs - > allJobsCompleted = 1 ; <nl> + } <nl> + zcs - > params = params ; <nl> + if ( updateDict ) { <nl> + ZSTD_freeCDict ( zcs - > cdict ) ; zcs - > cdict = NULL ; <nl> + if ( dict & & dictSize ) { <nl> + zcs - > cdict = ZSTD_createCDict_advanced ( dict , dictSize , 0 , params . cParams , cmem ) ; <nl> + if ( zcs - > cdict = = NULL ) return ERROR ( memory_allocation ) ; <nl> + } } <nl> + zcs - > frameContentSize = pledgedSrcSize ; <nl> + zcs - > targetDictSize = ( zcs - > overlapRLog > = 9 ) ? 0 : ( size_t ) 1 < < ( zcs - > params . cParams . windowLog - zcs - > overlapRLog ) ; <nl> + DEBUGLOG ( 4 , " overlapRLog : % u " , zcs - > overlapRLog ) ; <nl> + DEBUGLOG ( 3 , " overlap Size : % u KB " , ( U32 ) ( zcs - > targetDictSize > > 10 ) ) ; <nl> + zcs - > targetSectionSize = zcs - > sectionSize ? zcs - > sectionSize : ( size_t ) 1 < < ( zcs - > params . cParams . windowLog + 2 ) ; <nl> + zcs - > targetSectionSize = MAX ( ZSTDMT_SECTION_SIZE_MIN , zcs - > targetSectionSize ) ; <nl> + zcs - > targetSectionSize = MAX ( zcs - > targetDictSize , zcs - > targetSectionSize ) ; <nl> + DEBUGLOG ( 3 , " Section Size : % u KB " , ( U32 ) ( zcs - > targetSectionSize > > 10 ) ) ; <nl> + zcs - > marginSize = zcs - > targetSectionSize > > 2 ; <nl> + zcs - > inBuffSize = zcs - > targetDictSize + zcs - > targetSectionSize + zcs - > marginSize ; <nl> + zcs - > inBuff . buffer = ZSTDMT_getBuffer ( zcs - > buffPool , zcs - > inBuffSize ) ; <nl> + if ( zcs - > inBuff . buffer . start = = NULL ) return ERROR ( memory_allocation ) ; <nl> + zcs - > inBuff . filled = 0 ; <nl> + zcs - > dictSize = 0 ; <nl> + zcs - > doneJobID = 0 ; <nl> + zcs - > nextJobID = 0 ; <nl> + zcs - > frameEnded = 0 ; <nl> + zcs - > allJobsCompleted = 0 ; <nl> + if ( params . fParams . checksumFlag ) XXH64_reset ( & zcs - > xxhState , 0 ) ; <nl> + return 0 ; <nl> + } <nl> + <nl> + size_t ZSTDMT_initCStream_advanced ( ZSTDMT_CCtx * zcs , <nl> + const void * dict , size_t dictSize , <nl> + ZSTD_parameters params , unsigned long long pledgedSrcSize ) <nl> + { <nl> + return ZSTDMT_initCStream_internal ( zcs , dict , dictSize , 1 , params , pledgedSrcSize ) ; <nl> + } <nl> + <nl> + / * ZSTDMT_resetCStream ( ) : <nl> + * pledgedSrcSize is optional and can be zero = = unknown * / <nl> + size_t ZSTDMT_resetCStream ( ZSTDMT_CCtx * zcs , unsigned long long pledgedSrcSize ) <nl> + { <nl> + if ( zcs - > nbThreads = = 1 ) return ZSTD_resetCStream ( zcs - > cstream , pledgedSrcSize ) ; <nl> + return ZSTDMT_initCStream_internal ( zcs , NULL , 0 , 0 , zcs - > params , pledgedSrcSize ) ; <nl> + } <nl> + <nl> + size_t ZSTDMT_initCStream ( ZSTDMT_CCtx * zcs , int compressionLevel ) { <nl> + ZSTD_parameters const params = ZSTD_getParams ( compressionLevel , 0 , 0 ) ; <nl> + return ZSTDMT_initCStream_internal ( zcs , NULL , 0 , 1 , params , 0 ) ; <nl> + } <nl> + <nl> + <nl> + static size_t ZSTDMT_createCompressionJob ( ZSTDMT_CCtx * zcs , size_t srcSize , unsigned endFrame ) <nl> + { <nl> + size_t const dstBufferCapacity = ZSTD_compressBound ( srcSize ) ; <nl> + buffer_t const dstBuffer = ZSTDMT_getBuffer ( zcs - > buffPool , dstBufferCapacity ) ; <nl> + ZSTD_CCtx * const cctx = ZSTDMT_getCCtx ( zcs - > cctxPool ) ; <nl> + unsigned const jobID = zcs - > nextJobID & zcs - > jobIDMask ; <nl> + <nl> + if ( ( cctx = = NULL ) | | ( dstBuffer . start = = NULL ) ) { <nl> + zcs - > jobs [ jobID ] . jobCompleted = 1 ; <nl> + zcs - > nextJobID + + ; <nl> + ZSTDMT_waitForAllJobsCompleted ( zcs ) ; <nl> + ZSTDMT_releaseAllJobResources ( zcs ) ; <nl> + return ERROR ( memory_allocation ) ; <nl> + } <nl> + <nl> + DEBUGLOG ( 4 , " preparing job % u to compress % u bytes with % u preload " , zcs - > nextJobID , ( U32 ) srcSize , ( U32 ) zcs - > dictSize ) ; <nl> + zcs - > jobs [ jobID ] . src = zcs - > inBuff . buffer ; <nl> + zcs - > jobs [ jobID ] . srcStart = zcs - > inBuff . buffer . start ; <nl> + zcs - > jobs [ jobID ] . srcSize = srcSize ; <nl> + zcs - > jobs [ jobID ] . dictSize = zcs - > dictSize ; / * note : zcs - > inBuff . filled is presumed > = srcSize + dictSize * / <nl> + zcs - > jobs [ jobID ] . params = zcs - > params ; <nl> + if ( zcs - > nextJobID ) zcs - > jobs [ jobID ] . params . fParams . checksumFlag = 0 ; / * do not calculate checksum within sections , just keep it in header for first section * / <nl> + zcs - > jobs [ jobID ] . cdict = zcs - > nextJobID = = 0 ? zcs - > cdict : NULL ; <nl> + zcs - > jobs [ jobID ] . fullFrameSize = zcs - > frameContentSize ; <nl> + zcs - > jobs [ jobID ] . dstBuff = dstBuffer ; <nl> + zcs - > jobs [ jobID ] . cctx = cctx ; <nl> + zcs - > jobs [ jobID ] . firstChunk = ( zcs - > nextJobID = = 0 ) ; <nl> + zcs - > jobs [ jobID ] . lastChunk = endFrame ; <nl> + zcs - > jobs [ jobID ] . jobCompleted = 0 ; <nl> + zcs - > jobs [ jobID ] . dstFlushed = 0 ; <nl> + zcs - > jobs [ jobID ] . jobCompleted_mutex = & zcs - > jobCompleted_mutex ; <nl> + zcs - > jobs [ jobID ] . jobCompleted_cond = & zcs - > jobCompleted_cond ; <nl> + <nl> + / * get a new buffer for next input * / <nl> + if ( ! endFrame ) { <nl> + size_t const newDictSize = MIN ( srcSize + zcs - > dictSize , zcs - > targetDictSize ) ; <nl> + zcs - > inBuff . buffer = ZSTDMT_getBuffer ( zcs - > buffPool , zcs - > inBuffSize ) ; <nl> + if ( zcs - > inBuff . buffer . start = = NULL ) { / * not enough memory to allocate next input buffer * / <nl> + zcs - > jobs [ jobID ] . jobCompleted = 1 ; <nl> + zcs - > nextJobID + + ; <nl> + ZSTDMT_waitForAllJobsCompleted ( zcs ) ; <nl> + ZSTDMT_releaseAllJobResources ( zcs ) ; <nl> + return ERROR ( memory_allocation ) ; <nl> + } <nl> + DEBUGLOG ( 5 , " inBuff filled to % u " , ( U32 ) zcs - > inBuff . filled ) ; <nl> + zcs - > inBuff . filled - = srcSize + zcs - > dictSize - newDictSize ; <nl> + DEBUGLOG ( 5 , " new job : filled to % u , with % u dict and % u src " , ( U32 ) zcs - > inBuff . filled , ( U32 ) newDictSize , ( U32 ) ( zcs - > inBuff . filled - newDictSize ) ) ; <nl> + memmove ( zcs - > inBuff . buffer . start , ( const char * ) zcs - > jobs [ jobID ] . srcStart + zcs - > dictSize + srcSize - newDictSize , zcs - > inBuff . filled ) ; <nl> + DEBUGLOG ( 5 , " new inBuff pre - filled " ) ; <nl> + zcs - > dictSize = newDictSize ; <nl> + } else { <nl> + zcs - > inBuff . buffer = g_nullBuffer ; <nl> + zcs - > inBuff . filled = 0 ; <nl> + zcs - > dictSize = 0 ; <nl> + zcs - > frameEnded = 1 ; <nl> + if ( zcs - > nextJobID = = 0 ) <nl> + zcs - > params . fParams . checksumFlag = 0 ; / * single chunk : checksum is calculated directly within worker thread * / <nl> + } <nl> + <nl> + DEBUGLOG ( 3 , " posting job % u : % u bytes ( end : % u ) ( note : doneJob = % u = > % u ) " , zcs - > nextJobID , ( U32 ) zcs - > jobs [ jobID ] . srcSize , zcs - > jobs [ jobID ] . lastChunk , zcs - > doneJobID , zcs - > doneJobID & zcs - > jobIDMask ) ; <nl> + POOL_add ( zcs - > factory , ZSTDMT_compressChunk , & zcs - > jobs [ jobID ] ) ; / * this call is blocking when thread worker pool is exhausted * / <nl> + zcs - > nextJobID + + ; <nl> + return 0 ; <nl> + } <nl> + <nl> + <nl> + / * ZSTDMT_flushNextJob ( ) : <nl> + * output : will be updated with amount of data flushed . <nl> + * blockToFlush : if > 0 , the function will block and wait if there is no data available to flush . <nl> + * @ return : amount of data remaining within internal buffer , 1 if unknown but > 0 , 0 if no more , or an error code * / <nl> + static size_t ZSTDMT_flushNextJob ( ZSTDMT_CCtx * zcs , ZSTD_outBuffer * output , unsigned blockToFlush ) <nl> + { <nl> + unsigned const wJobID = zcs - > doneJobID & zcs - > jobIDMask ; <nl> + if ( zcs - > doneJobID = = zcs - > nextJobID ) return 0 ; / * all flushed ! * / <nl> + PTHREAD_MUTEX_LOCK ( & zcs - > jobCompleted_mutex ) ; <nl> + while ( zcs - > jobs [ wJobID ] . jobCompleted = = 0 ) { <nl> + DEBUGLOG ( 5 , " waiting for jobCompleted signal from job % u " , zcs - > doneJobID ) ; <nl> + if ( ! blockToFlush ) { pthread_mutex_unlock ( & zcs - > jobCompleted_mutex ) ; return 0 ; } / * nothing ready to be flushed = > skip * / <nl> + pthread_cond_wait ( & zcs - > jobCompleted_cond , & zcs - > jobCompleted_mutex ) ; / * block when nothing available to flush * / <nl> + } <nl> + pthread_mutex_unlock ( & zcs - > jobCompleted_mutex ) ; <nl> + / * compression job completed : output can be flushed * / <nl> + { ZSTDMT_jobDescription job = zcs - > jobs [ wJobID ] ; <nl> + if ( ! job . jobScanned ) { <nl> + if ( ZSTD_isError ( job . cSize ) ) { <nl> + DEBUGLOG ( 5 , " compression error detected " ) ; <nl> + ZSTDMT_waitForAllJobsCompleted ( zcs ) ; <nl> + ZSTDMT_releaseAllJobResources ( zcs ) ; <nl> + return job . cSize ; <nl> + } <nl> + ZSTDMT_releaseCCtx ( zcs - > cctxPool , job . cctx ) ; <nl> + zcs - > jobs [ wJobID ] . cctx = NULL ; <nl> + DEBUGLOG ( 5 , " zcs - > params . fParams . checksumFlag : % u " , zcs - > params . fParams . checksumFlag ) ; <nl> + if ( zcs - > params . fParams . checksumFlag ) { <nl> + XXH64_update ( & zcs - > xxhState , ( const char * ) job . srcStart + job . dictSize , job . srcSize ) ; <nl> + if ( zcs - > frameEnded & & ( zcs - > doneJobID + 1 = = zcs - > nextJobID ) ) { / * write checksum at end of last section * / <nl> + U32 const checksum = ( U32 ) XXH64_digest ( & zcs - > xxhState ) ; <nl> + DEBUGLOG ( 4 , " writing checksum : % 08X \ n " , checksum ) ; <nl> + MEM_writeLE32 ( ( char * ) job . dstBuff . start + job . cSize , checksum ) ; <nl> + job . cSize + = 4 ; <nl> + zcs - > jobs [ wJobID ] . cSize + = 4 ; <nl> + } } <nl> + ZSTDMT_releaseBuffer ( zcs - > buffPool , job . src ) ; <nl> + zcs - > jobs [ wJobID ] . srcStart = NULL ; <nl> + zcs - > jobs [ wJobID ] . src = g_nullBuffer ; <nl> + zcs - > jobs [ wJobID ] . jobScanned = 1 ; <nl> + } <nl> + { size_t const toWrite = MIN ( job . cSize - job . dstFlushed , output - > size - output - > pos ) ; <nl> + DEBUGLOG ( 4 , " Flushing % u bytes from job % u " , ( U32 ) toWrite , zcs - > doneJobID ) ; <nl> + memcpy ( ( char * ) output - > dst + output - > pos , ( const char * ) job . dstBuff . start + job . dstFlushed , toWrite ) ; <nl> + output - > pos + = toWrite ; <nl> + job . dstFlushed + = toWrite ; <nl> + } <nl> + if ( job . dstFlushed = = job . cSize ) { / * output buffer fully flushed = > move to next one * / <nl> + ZSTDMT_releaseBuffer ( zcs - > buffPool , job . dstBuff ) ; <nl> + zcs - > jobs [ wJobID ] . dstBuff = g_nullBuffer ; <nl> + zcs - > jobs [ wJobID ] . jobCompleted = 0 ; <nl> + zcs - > doneJobID + + ; <nl> + } else { <nl> + zcs - > jobs [ wJobID ] . dstFlushed = job . dstFlushed ; <nl> + } <nl> + / * return value : how many bytes left in buffer ; fake it to 1 if unknown but > 0 * / <nl> + if ( job . cSize > job . dstFlushed ) return ( job . cSize - job . dstFlushed ) ; <nl> + if ( zcs - > doneJobID < zcs - > nextJobID ) return 1 ; / * still some buffer to flush * / <nl> + zcs - > allJobsCompleted = zcs - > frameEnded ; / * frame completed and entirely flushed * / <nl> + return 0 ; / * everything flushed * / <nl> + } } <nl> + <nl> + <nl> + size_t ZSTDMT_compressStream ( ZSTDMT_CCtx * zcs , ZSTD_outBuffer * output , ZSTD_inBuffer * input ) <nl> + { <nl> + size_t const newJobThreshold = zcs - > dictSize + zcs - > targetSectionSize + zcs - > marginSize ; <nl> + if ( zcs - > frameEnded ) return ERROR ( stage_wrong ) ; / * current frame being ended . Only flush is allowed . Restart with init * / <nl> + if ( zcs - > nbThreads = = 1 ) return ZSTD_compressStream ( zcs - > cstream , output , input ) ; <nl> + <nl> + / * fill input buffer * / <nl> + { size_t const toLoad = MIN ( input - > size - input - > pos , zcs - > inBuffSize - zcs - > inBuff . filled ) ; <nl> + memcpy ( ( char * ) zcs - > inBuff . buffer . start + zcs - > inBuff . filled , input - > src , toLoad ) ; <nl> + input - > pos + = toLoad ; <nl> + zcs - > inBuff . filled + = toLoad ; <nl> + } <nl> + <nl> + if ( ( zcs - > inBuff . filled > = newJobThreshold ) / * filled enough : let ' s compress * / <nl> + & & ( zcs - > nextJobID < = zcs - > doneJobID + zcs - > jobIDMask ) ) { / * avoid overwriting job round buffer * / <nl> + CHECK_F ( ZSTDMT_createCompressionJob ( zcs , zcs - > targetSectionSize , 0 ) ) ; <nl> + } <nl> + <nl> + / * check for data to flush * / <nl> + CHECK_F ( ZSTDMT_flushNextJob ( zcs , output , ( zcs - > inBuff . filled = = zcs - > inBuffSize ) ) ) ; / * block if it wasn ' t possible to create new job due to saturation * / <nl> + <nl> + / * recommended next input size : fill current input buffer * / <nl> + return zcs - > inBuffSize - zcs - > inBuff . filled ; / * note : could be zero when input buffer is fully filled and no more availability to create new job * / <nl> + } <nl> + <nl> + <nl> + static size_t ZSTDMT_flushStream_internal ( ZSTDMT_CCtx * zcs , ZSTD_outBuffer * output , unsigned endFrame ) <nl> + { <nl> + size_t const srcSize = zcs - > inBuff . filled - zcs - > dictSize ; <nl> + <nl> + if ( srcSize ) DEBUGLOG ( 4 , " flushing : % u bytes left to compress " , ( U32 ) srcSize ) ; <nl> + if ( ( ( srcSize > 0 ) | | ( endFrame & & ! zcs - > frameEnded ) ) <nl> + & & ( zcs - > nextJobID < = zcs - > doneJobID + zcs - > jobIDMask ) ) { <nl> + CHECK_F ( ZSTDMT_createCompressionJob ( zcs , srcSize , endFrame ) ) ; <nl> + } <nl> + <nl> + / * check if there is any data available to flush * / <nl> + DEBUGLOG ( 5 , " zcs - > doneJobID : % u ; zcs - > nextJobID : % u " , zcs - > doneJobID , zcs - > nextJobID ) ; <nl> + return ZSTDMT_flushNextJob ( zcs , output , 1 ) ; <nl> + } <nl> + <nl> + <nl> + size_t ZSTDMT_flushStream ( ZSTDMT_CCtx * zcs , ZSTD_outBuffer * output ) <nl> + { <nl> + if ( zcs - > nbThreads = = 1 ) return ZSTD_flushStream ( zcs - > cstream , output ) ; <nl> + return ZSTDMT_flushStream_internal ( zcs , output , 0 ) ; <nl> + } <nl> + <nl> + size_t ZSTDMT_endStream ( ZSTDMT_CCtx * zcs , ZSTD_outBuffer * output ) <nl> + { <nl> + if ( zcs - > nbThreads = = 1 ) return ZSTD_endStream ( zcs - > cstream , output ) ; <nl> + return ZSTDMT_flushStream_internal ( zcs , output , 1 ) ; <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 27f78ee0314 <nl> mmm / dev / null <nl> ppp b / thirdparty / zstd / compress / zstdmt_compress . h <nl> <nl> + / * * <nl> + * Copyright ( c ) 2016 - present , Yann Collet , Facebook , Inc . <nl> + * All rights reserved . <nl> + * <nl> + * This source code is licensed under the BSD - style license found in the <nl> + * LICENSE file in the root directory of this source tree . An additional grant <nl> + * of patent rights can be found in the PATENTS file in the same directory . <nl> + * / <nl> + <nl> + # ifndef ZSTDMT_COMPRESS_H <nl> + # define ZSTDMT_COMPRESS_H <nl> + <nl> + # if defined ( __cplusplus ) <nl> + extern " C " { <nl> + # endif <nl> + <nl> + <nl> + / * Note : All prototypes defined in this file shall be considered experimental . <nl> + * There is no guarantee of API continuity ( yet ) on any of these prototypes * / <nl> + <nl> + / * = = = Dependencies = = = * / <nl> + # include < stddef . h > / * size_t * / <nl> + # define ZSTD_STATIC_LINKING_ONLY / * ZSTD_parameters * / <nl> + # include " zstd . h " / * ZSTD_inBuffer , ZSTD_outBuffer , ZSTDLIB_API * / <nl> + <nl> + <nl> + / * = = = Simple one - pass functions = = = * / <nl> + <nl> + typedef struct ZSTDMT_CCtx_s ZSTDMT_CCtx ; <nl> + ZSTDLIB_API ZSTDMT_CCtx * ZSTDMT_createCCtx ( unsigned nbThreads ) ; <nl> + ZSTDLIB_API size_t ZSTDMT_freeCCtx ( ZSTDMT_CCtx * cctx ) ; <nl> + <nl> + ZSTDLIB_API size_t ZSTDMT_compressCCtx ( ZSTDMT_CCtx * cctx , <nl> + void * dst , size_t dstCapacity , <nl> + const void * src , size_t srcSize , <nl> + int compressionLevel ) ; <nl> + <nl> + <nl> + / * = = = Streaming functions = = = * / <nl> + <nl> + ZSTDLIB_API size_t ZSTDMT_initCStream ( ZSTDMT_CCtx * mtctx , int compressionLevel ) ; <nl> + ZSTDLIB_API size_t ZSTDMT_resetCStream ( ZSTDMT_CCtx * mtctx , unsigned long long pledgedSrcSize ) ; / * * < pledgedSrcSize is optional and can be zero = = unknown * / <nl> + <nl> + ZSTDLIB_API size_t ZSTDMT_compressStream ( ZSTDMT_CCtx * mtctx , ZSTD_outBuffer * output , ZSTD_inBuffer * input ) ; <nl> + <nl> + ZSTDLIB_API size_t ZSTDMT_flushStream ( ZSTDMT_CCtx * mtctx , ZSTD_outBuffer * output ) ; / * * < @ return : 0 = = all flushed ; > 0 : still some data to be flushed ; or an error code ( ZSTD_isError ( ) ) * / <nl> + ZSTDLIB_API size_t ZSTDMT_endStream ( ZSTDMT_CCtx * mtctx , ZSTD_outBuffer * output ) ; / * * < @ return : 0 = = all flushed ; > 0 : still some data to be flushed ; or an error code ( ZSTD_isError ( ) ) * / <nl> + <nl> + <nl> + / * = = = Advanced functions and parameters = = = * / <nl> + <nl> + # ifndef ZSTDMT_SECTION_SIZE_MIN <nl> + # define ZSTDMT_SECTION_SIZE_MIN ( 1U < < 20 ) / * 1 MB - Minimum size of each compression job * / <nl> + # endif <nl> + <nl> + ZSTDLIB_API size_t ZSTDMT_initCStream_advanced ( ZSTDMT_CCtx * mtctx , const void * dict , size_t dictSize , / * * < dict can be released after init , a local copy is preserved within zcs * / <nl> + ZSTD_parameters params , unsigned long long pledgedSrcSize ) ; / * * < pledgedSrcSize is optional and can be zero = = unknown * / <nl> + <nl> + / * ZSDTMT_parameter : <nl> + * List of parameters that can be set using ZSTDMT_setMTCtxParameter ( ) * / <nl> + typedef enum { <nl> + ZSTDMT_p_sectionSize , / * size of input " section " . Each section is compressed in parallel . 0 means default , which is dynamically determined within compression functions * / <nl> + ZSTDMT_p_overlapSectionLog / * Log of overlapped section ; 0 = = no overlap , 6 ( default ) = = use 1 / 8th of window , > = 9 = = use full window * / <nl> + } ZSDTMT_parameter ; <nl> + <nl> + / * ZSTDMT_setMTCtxParameter ( ) : <nl> + * allow setting individual parameters , one at a time , among a list of enums defined in ZSTDMT_parameter . <nl> + * The function must be called typically after ZSTD_createCCtx ( ) . <nl> + * Parameters not explicitly reset by ZSTDMT_init * ( ) remain the same in consecutive compression sessions . <nl> + * @ return : 0 , or an error code ( which can be tested using ZSTD_isError ( ) ) * / <nl> + ZSTDLIB_API size_t ZSTDMT_setMTCtxParameter ( ZSTDMT_CCtx * mtctx , ZSDTMT_parameter parameter , unsigned value ) ; <nl> + <nl> + <nl> + # if defined ( __cplusplus ) <nl> + } <nl> + # endif <nl> + <nl> + # endif / * ZSTDMT_COMPRESS_H * / <nl> new file mode 100644 <nl> index 00000000000 . . ea35c362017 <nl> mmm / dev / null <nl> ppp b / thirdparty / zstd / decompress / huf_decompress . c <nl> <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + Huffman decoder , part of New Generation Entropy library <nl> + Copyright ( C ) 2013 - 2016 , Yann Collet . <nl> + <nl> + BSD 2 - Clause License ( http : / / www . opensource . org / licenses / bsd - license . php ) <nl> + <nl> + Redistribution and use in source and binary forms , with or without <nl> + modification , are permitted provided that the following conditions are <nl> + met : <nl> + <nl> + * Redistributions of source code must retain the above copyright <nl> + notice , this list of conditions and the following disclaimer . <nl> + * Redistributions in binary form must reproduce the above <nl> + copyright notice , this list of conditions and the following disclaimer <nl> + in the documentation and / or other materials provided with the <nl> + distribution . <nl> + <nl> + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + <nl> + You can contact the author at : <nl> + - FSE + HUF source repository : https : / / github . com / Cyan4973 / FiniteStateEntropy <nl> + - Public forum : https : / / groups . google . com / forum / # ! forum / lz4c <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Compiler specifics <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # ifdef _MSC_VER / * Visual Studio * / <nl> + # define FORCE_INLINE static __forceinline <nl> + # pragma warning ( disable : 4127 ) / * disable : C4127 : conditional expression is constant * / <nl> + # else <nl> + # if defined ( __cplusplus ) | | defined ( __STDC_VERSION__ ) & & __STDC_VERSION__ > = 199901L / * C99 * / <nl> + # ifdef __GNUC__ <nl> + # define FORCE_INLINE static inline __attribute__ ( ( always_inline ) ) <nl> + # else <nl> + # define FORCE_INLINE static inline <nl> + # endif <nl> + # else <nl> + # define FORCE_INLINE static <nl> + # endif / * __STDC_VERSION__ * / <nl> + # endif <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Dependencies <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # include < string . h > / * memcpy , memset * / <nl> + # include " bitstream . h " / * BIT_ * * / <nl> + # include " fse . h " / * header compression * / <nl> + # define HUF_STATIC_LINKING_ONLY <nl> + # include " huf . h " <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Error Management <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # define HUF_STATIC_ASSERT ( c ) { enum { HUF_static_assert = 1 / ( int ) ( ! ! ( c ) ) } ; } / * use only * after * variable declarations * / <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * generic DTableDesc * / <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + typedef struct { BYTE maxTableLog ; BYTE tableType ; BYTE tableLog ; BYTE reserved ; } DTableDesc ; <nl> + <nl> + static DTableDesc HUF_getDTableDesc ( const HUF_DTable * table ) <nl> + { <nl> + DTableDesc dtd ; <nl> + memcpy ( & dtd , table , sizeof ( dtd ) ) ; <nl> + return dtd ; <nl> + } <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * single - symbol decoding * / <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + typedef struct { BYTE byte ; BYTE nbBits ; } HUF_DEltX2 ; / * single - symbol decoding * / <nl> + <nl> + size_t HUF_readDTableX2 ( HUF_DTable * DTable , const void * src , size_t srcSize ) <nl> + { <nl> + BYTE huffWeight [ HUF_SYMBOLVALUE_MAX + 1 ] ; <nl> + U32 rankVal [ HUF_TABLELOG_ABSOLUTEMAX + 1 ] ; / * large enough for values from 0 to 16 * / <nl> + U32 tableLog = 0 ; <nl> + U32 nbSymbols = 0 ; <nl> + size_t iSize ; <nl> + void * const dtPtr = DTable + 1 ; <nl> + HUF_DEltX2 * const dt = ( HUF_DEltX2 * ) dtPtr ; <nl> + <nl> + HUF_STATIC_ASSERT ( sizeof ( DTableDesc ) = = sizeof ( HUF_DTable ) ) ; <nl> + / * memset ( huffWeight , 0 , sizeof ( huffWeight ) ) ; * / / * is not necessary , even though some analyzer complain . . . * / <nl> + <nl> + iSize = HUF_readStats ( huffWeight , HUF_SYMBOLVALUE_MAX + 1 , rankVal , & nbSymbols , & tableLog , src , srcSize ) ; <nl> + if ( HUF_isError ( iSize ) ) return iSize ; <nl> + <nl> + / * Table header * / <nl> + { DTableDesc dtd = HUF_getDTableDesc ( DTable ) ; <nl> + if ( tableLog > ( U32 ) ( dtd . maxTableLog + 1 ) ) return ERROR ( tableLog_tooLarge ) ; / * DTable too small , Huffman tree cannot fit in * / <nl> + dtd . tableType = 0 ; <nl> + dtd . tableLog = ( BYTE ) tableLog ; <nl> + memcpy ( DTable , & dtd , sizeof ( dtd ) ) ; <nl> + } <nl> + <nl> + / * Calculate starting value for each rank * / <nl> + { U32 n , nextRankStart = 0 ; <nl> + for ( n = 1 ; n < tableLog + 1 ; n + + ) { <nl> + U32 const current = nextRankStart ; <nl> + nextRankStart + = ( rankVal [ n ] < < ( n - 1 ) ) ; <nl> + rankVal [ n ] = current ; <nl> + } } <nl> + <nl> + / * fill DTable * / <nl> + { U32 n ; <nl> + for ( n = 0 ; n < nbSymbols ; n + + ) { <nl> + U32 const w = huffWeight [ n ] ; <nl> + U32 const length = ( 1 < < w ) > > 1 ; <nl> + U32 u ; <nl> + HUF_DEltX2 D ; <nl> + D . byte = ( BYTE ) n ; D . nbBits = ( BYTE ) ( tableLog + 1 - w ) ; <nl> + for ( u = rankVal [ w ] ; u < rankVal [ w ] + length ; u + + ) <nl> + dt [ u ] = D ; <nl> + rankVal [ w ] + = length ; <nl> + } } <nl> + <nl> + return iSize ; <nl> + } <nl> + <nl> + <nl> + static BYTE HUF_decodeSymbolX2 ( BIT_DStream_t * Dstream , const HUF_DEltX2 * dt , const U32 dtLog ) <nl> + { <nl> + size_t const val = BIT_lookBitsFast ( Dstream , dtLog ) ; / * note : dtLog > = 1 * / <nl> + BYTE const c = dt [ val ] . byte ; <nl> + BIT_skipBits ( Dstream , dt [ val ] . nbBits ) ; <nl> + return c ; <nl> + } <nl> + <nl> + # define HUF_DECODE_SYMBOLX2_0 ( ptr , DStreamPtr ) \ <nl> + * ptr + + = HUF_decodeSymbolX2 ( DStreamPtr , dt , dtLog ) <nl> + <nl> + # define HUF_DECODE_SYMBOLX2_1 ( ptr , DStreamPtr ) \ <nl> + if ( MEM_64bits ( ) | | ( HUF_TABLELOG_MAX < = 12 ) ) \ <nl> + HUF_DECODE_SYMBOLX2_0 ( ptr , DStreamPtr ) <nl> + <nl> + # define HUF_DECODE_SYMBOLX2_2 ( ptr , DStreamPtr ) \ <nl> + if ( MEM_64bits ( ) ) \ <nl> + HUF_DECODE_SYMBOLX2_0 ( ptr , DStreamPtr ) <nl> + <nl> + FORCE_INLINE size_t HUF_decodeStreamX2 ( BYTE * p , BIT_DStream_t * const bitDPtr , BYTE * const pEnd , const HUF_DEltX2 * const dt , const U32 dtLog ) <nl> + { <nl> + BYTE * const pStart = p ; <nl> + <nl> + / * up to 4 symbols at a time * / <nl> + while ( ( BIT_reloadDStream ( bitDPtr ) = = BIT_DStream_unfinished ) & & ( p < = pEnd - 4 ) ) { <nl> + HUF_DECODE_SYMBOLX2_2 ( p , bitDPtr ) ; <nl> + HUF_DECODE_SYMBOLX2_1 ( p , bitDPtr ) ; <nl> + HUF_DECODE_SYMBOLX2_2 ( p , bitDPtr ) ; <nl> + HUF_DECODE_SYMBOLX2_0 ( p , bitDPtr ) ; <nl> + } <nl> + <nl> + / * closer to the end * / <nl> + while ( ( BIT_reloadDStream ( bitDPtr ) = = BIT_DStream_unfinished ) & & ( p < pEnd ) ) <nl> + HUF_DECODE_SYMBOLX2_0 ( p , bitDPtr ) ; <nl> + <nl> + / * no more data to retrieve from bitstream , hence no need to reload * / <nl> + while ( p < pEnd ) <nl> + HUF_DECODE_SYMBOLX2_0 ( p , bitDPtr ) ; <nl> + <nl> + return pEnd - pStart ; <nl> + } <nl> + <nl> + static size_t HUF_decompress1X2_usingDTable_internal ( <nl> + void * dst , size_t dstSize , <nl> + const void * cSrc , size_t cSrcSize , <nl> + const HUF_DTable * DTable ) <nl> + { <nl> + BYTE * op = ( BYTE * ) dst ; <nl> + BYTE * const oend = op + dstSize ; <nl> + const void * dtPtr = DTable + 1 ; <nl> + const HUF_DEltX2 * const dt = ( const HUF_DEltX2 * ) dtPtr ; <nl> + BIT_DStream_t bitD ; <nl> + DTableDesc const dtd = HUF_getDTableDesc ( DTable ) ; <nl> + U32 const dtLog = dtd . tableLog ; <nl> + <nl> + { size_t const errorCode = BIT_initDStream ( & bitD , cSrc , cSrcSize ) ; <nl> + if ( HUF_isError ( errorCode ) ) return errorCode ; } <nl> + <nl> + HUF_decodeStreamX2 ( op , & bitD , oend , dt , dtLog ) ; <nl> + <nl> + / * check * / <nl> + if ( ! BIT_endOfDStream ( & bitD ) ) return ERROR ( corruption_detected ) ; <nl> + <nl> + return dstSize ; <nl> + } <nl> + <nl> + size_t HUF_decompress1X2_usingDTable ( <nl> + void * dst , size_t dstSize , <nl> + const void * cSrc , size_t cSrcSize , <nl> + const HUF_DTable * DTable ) <nl> + { <nl> + DTableDesc dtd = HUF_getDTableDesc ( DTable ) ; <nl> + if ( dtd . tableType ! = 0 ) return ERROR ( GENERIC ) ; <nl> + return HUF_decompress1X2_usingDTable_internal ( dst , dstSize , cSrc , cSrcSize , DTable ) ; <nl> + } <nl> + <nl> + size_t HUF_decompress1X2_DCtx ( HUF_DTable * DCtx , void * dst , size_t dstSize , const void * cSrc , size_t cSrcSize ) <nl> + { <nl> + const BYTE * ip = ( const BYTE * ) cSrc ; <nl> + <nl> + size_t const hSize = HUF_readDTableX2 ( DCtx , cSrc , cSrcSize ) ; <nl> + if ( HUF_isError ( hSize ) ) return hSize ; <nl> + if ( hSize > = cSrcSize ) return ERROR ( srcSize_wrong ) ; <nl> + ip + = hSize ; cSrcSize - = hSize ; <nl> + <nl> + return HUF_decompress1X2_usingDTable_internal ( dst , dstSize , ip , cSrcSize , DCtx ) ; <nl> + } <nl> + <nl> + size_t HUF_decompress1X2 ( void * dst , size_t dstSize , const void * cSrc , size_t cSrcSize ) <nl> + { <nl> + HUF_CREATE_STATIC_DTABLEX2 ( DTable , HUF_TABLELOG_MAX ) ; <nl> + return HUF_decompress1X2_DCtx ( DTable , dst , dstSize , cSrc , cSrcSize ) ; <nl> + } <nl> + <nl> + <nl> + static size_t HUF_decompress4X2_usingDTable_internal ( <nl> + void * dst , size_t dstSize , <nl> + const void * cSrc , size_t cSrcSize , <nl> + const HUF_DTable * DTable ) <nl> + { <nl> + / * Check * / <nl> + if ( cSrcSize < 10 ) return ERROR ( corruption_detected ) ; / * strict minimum : jump table + 1 byte per stream * / <nl> + <nl> + { const BYTE * const istart = ( const BYTE * ) cSrc ; <nl> + BYTE * const ostart = ( BYTE * ) dst ; <nl> + BYTE * const oend = ostart + dstSize ; <nl> + const void * const dtPtr = DTable + 1 ; <nl> + const HUF_DEltX2 * const dt = ( const HUF_DEltX2 * ) dtPtr ; <nl> + <nl> + / * Init * / <nl> + BIT_DStream_t bitD1 ; <nl> + BIT_DStream_t bitD2 ; <nl> + BIT_DStream_t bitD3 ; <nl> + BIT_DStream_t bitD4 ; <nl> + size_t const length1 = MEM_readLE16 ( istart ) ; <nl> + size_t const length2 = MEM_readLE16 ( istart + 2 ) ; <nl> + size_t const length3 = MEM_readLE16 ( istart + 4 ) ; <nl> + size_t const length4 = cSrcSize - ( length1 + length2 + length3 + 6 ) ; <nl> + const BYTE * const istart1 = istart + 6 ; / * jumpTable * / <nl> + const BYTE * const istart2 = istart1 + length1 ; <nl> + const BYTE * const istart3 = istart2 + length2 ; <nl> + const BYTE * const istart4 = istart3 + length3 ; <nl> + const size_t segmentSize = ( dstSize + 3 ) / 4 ; <nl> + BYTE * const opStart2 = ostart + segmentSize ; <nl> + BYTE * const opStart3 = opStart2 + segmentSize ; <nl> + BYTE * const opStart4 = opStart3 + segmentSize ; <nl> + BYTE * op1 = ostart ; <nl> + BYTE * op2 = opStart2 ; <nl> + BYTE * op3 = opStart3 ; <nl> + BYTE * op4 = opStart4 ; <nl> + U32 endSignal ; <nl> + DTableDesc const dtd = HUF_getDTableDesc ( DTable ) ; <nl> + U32 const dtLog = dtd . tableLog ; <nl> + <nl> + if ( length4 > cSrcSize ) return ERROR ( corruption_detected ) ; / * overflow * / <nl> + { size_t const errorCode = BIT_initDStream ( & bitD1 , istart1 , length1 ) ; <nl> + if ( HUF_isError ( errorCode ) ) return errorCode ; } <nl> + { size_t const errorCode = BIT_initDStream ( & bitD2 , istart2 , length2 ) ; <nl> + if ( HUF_isError ( errorCode ) ) return errorCode ; } <nl> + { size_t const errorCode = BIT_initDStream ( & bitD3 , istart3 , length3 ) ; <nl> + if ( HUF_isError ( errorCode ) ) return errorCode ; } <nl> + { size_t const errorCode = BIT_initDStream ( & bitD4 , istart4 , length4 ) ; <nl> + if ( HUF_isError ( errorCode ) ) return errorCode ; } <nl> + <nl> + / * 16 - 32 symbols per loop ( 4 - 8 symbols per stream ) * / <nl> + endSignal = BIT_reloadDStream ( & bitD1 ) | BIT_reloadDStream ( & bitD2 ) | BIT_reloadDStream ( & bitD3 ) | BIT_reloadDStream ( & bitD4 ) ; <nl> + for ( ; ( endSignal = = BIT_DStream_unfinished ) & & ( op4 < ( oend - 7 ) ) ; ) { <nl> + HUF_DECODE_SYMBOLX2_2 ( op1 , & bitD1 ) ; <nl> + HUF_DECODE_SYMBOLX2_2 ( op2 , & bitD2 ) ; <nl> + HUF_DECODE_SYMBOLX2_2 ( op3 , & bitD3 ) ; <nl> + HUF_DECODE_SYMBOLX2_2 ( op4 , & bitD4 ) ; <nl> + HUF_DECODE_SYMBOLX2_1 ( op1 , & bitD1 ) ; <nl> + HUF_DECODE_SYMBOLX2_1 ( op2 , & bitD2 ) ; <nl> + HUF_DECODE_SYMBOLX2_1 ( op3 , & bitD3 ) ; <nl> + HUF_DECODE_SYMBOLX2_1 ( op4 , & bitD4 ) ; <nl> + HUF_DECODE_SYMBOLX2_2 ( op1 , & bitD1 ) ; <nl> + HUF_DECODE_SYMBOLX2_2 ( op2 , & bitD2 ) ; <nl> + HUF_DECODE_SYMBOLX2_2 ( op3 , & bitD3 ) ; <nl> + HUF_DECODE_SYMBOLX2_2 ( op4 , & bitD4 ) ; <nl> + HUF_DECODE_SYMBOLX2_0 ( op1 , & bitD1 ) ; <nl> + HUF_DECODE_SYMBOLX2_0 ( op2 , & bitD2 ) ; <nl> + HUF_DECODE_SYMBOLX2_0 ( op3 , & bitD3 ) ; <nl> + HUF_DECODE_SYMBOLX2_0 ( op4 , & bitD4 ) ; <nl> + endSignal = BIT_reloadDStream ( & bitD1 ) | BIT_reloadDStream ( & bitD2 ) | BIT_reloadDStream ( & bitD3 ) | BIT_reloadDStream ( & bitD4 ) ; <nl> + } <nl> + <nl> + / * check corruption * / <nl> + if ( op1 > opStart2 ) return ERROR ( corruption_detected ) ; <nl> + if ( op2 > opStart3 ) return ERROR ( corruption_detected ) ; <nl> + if ( op3 > opStart4 ) return ERROR ( corruption_detected ) ; <nl> + / * note : op4 supposed already verified within main loop * / <nl> + <nl> + / * finish bitStreams one by one * / <nl> + HUF_decodeStreamX2 ( op1 , & bitD1 , opStart2 , dt , dtLog ) ; <nl> + HUF_decodeStreamX2 ( op2 , & bitD2 , opStart3 , dt , dtLog ) ; <nl> + HUF_decodeStreamX2 ( op3 , & bitD3 , opStart4 , dt , dtLog ) ; <nl> + HUF_decodeStreamX2 ( op4 , & bitD4 , oend , dt , dtLog ) ; <nl> + <nl> + / * check * / <nl> + endSignal = BIT_endOfDStream ( & bitD1 ) & BIT_endOfDStream ( & bitD2 ) & BIT_endOfDStream ( & bitD3 ) & BIT_endOfDStream ( & bitD4 ) ; <nl> + if ( ! endSignal ) return ERROR ( corruption_detected ) ; <nl> + <nl> + / * decoded size * / <nl> + return dstSize ; <nl> + } <nl> + } <nl> + <nl> + <nl> + size_t HUF_decompress4X2_usingDTable ( <nl> + void * dst , size_t dstSize , <nl> + const void * cSrc , size_t cSrcSize , <nl> + const HUF_DTable * DTable ) <nl> + { <nl> + DTableDesc dtd = HUF_getDTableDesc ( DTable ) ; <nl> + if ( dtd . tableType ! = 0 ) return ERROR ( GENERIC ) ; <nl> + return HUF_decompress4X2_usingDTable_internal ( dst , dstSize , cSrc , cSrcSize , DTable ) ; <nl> + } <nl> + <nl> + <nl> + size_t HUF_decompress4X2_DCtx ( HUF_DTable * dctx , void * dst , size_t dstSize , const void * cSrc , size_t cSrcSize ) <nl> + { <nl> + const BYTE * ip = ( const BYTE * ) cSrc ; <nl> + <nl> + size_t const hSize = HUF_readDTableX2 ( dctx , cSrc , cSrcSize ) ; <nl> + if ( HUF_isError ( hSize ) ) return hSize ; <nl> + if ( hSize > = cSrcSize ) return ERROR ( srcSize_wrong ) ; <nl> + ip + = hSize ; cSrcSize - = hSize ; <nl> + <nl> + return HUF_decompress4X2_usingDTable_internal ( dst , dstSize , ip , cSrcSize , dctx ) ; <nl> + } <nl> + <nl> + size_t HUF_decompress4X2 ( void * dst , size_t dstSize , const void * cSrc , size_t cSrcSize ) <nl> + { <nl> + HUF_CREATE_STATIC_DTABLEX2 ( DTable , HUF_TABLELOG_MAX ) ; <nl> + return HUF_decompress4X2_DCtx ( DTable , dst , dstSize , cSrc , cSrcSize ) ; <nl> + } <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * double - symbols decoding * / <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + typedef struct { U16 sequence ; BYTE nbBits ; BYTE length ; } HUF_DEltX4 ; / * double - symbols decoding * / <nl> + <nl> + typedef struct { BYTE symbol ; BYTE weight ; } sortedSymbol_t ; <nl> + <nl> + / * HUF_fillDTableX4Level2 ( ) : <nl> + * ` rankValOrigin ` must be a table of at least ( HUF_TABLELOG_MAX + 1 ) U32 * / <nl> + static void HUF_fillDTableX4Level2 ( HUF_DEltX4 * DTable , U32 sizeLog , const U32 consumed , <nl> + const U32 * rankValOrigin , const int minWeight , <nl> + const sortedSymbol_t * sortedSymbols , const U32 sortedListSize , <nl> + U32 nbBitsBaseline , U16 baseSeq ) <nl> + { <nl> + HUF_DEltX4 DElt ; <nl> + U32 rankVal [ HUF_TABLELOG_MAX + 1 ] ; <nl> + <nl> + / * get pre - calculated rankVal * / <nl> + memcpy ( rankVal , rankValOrigin , sizeof ( rankVal ) ) ; <nl> + <nl> + / * fill skipped values * / <nl> + if ( minWeight > 1 ) { <nl> + U32 i , skipSize = rankVal [ minWeight ] ; <nl> + MEM_writeLE16 ( & ( DElt . sequence ) , baseSeq ) ; <nl> + DElt . nbBits = ( BYTE ) ( consumed ) ; <nl> + DElt . length = 1 ; <nl> + for ( i = 0 ; i < skipSize ; i + + ) <nl> + DTable [ i ] = DElt ; <nl> + } <nl> + <nl> + / * fill DTable * / <nl> + { U32 s ; for ( s = 0 ; s < sortedListSize ; s + + ) { / * note : sortedSymbols already skipped * / <nl> + const U32 symbol = sortedSymbols [ s ] . symbol ; <nl> + const U32 weight = sortedSymbols [ s ] . weight ; <nl> + const U32 nbBits = nbBitsBaseline - weight ; <nl> + const U32 length = 1 < < ( sizeLog - nbBits ) ; <nl> + const U32 start = rankVal [ weight ] ; <nl> + U32 i = start ; <nl> + const U32 end = start + length ; <nl> + <nl> + MEM_writeLE16 ( & ( DElt . sequence ) , ( U16 ) ( baseSeq + ( symbol < < 8 ) ) ) ; <nl> + DElt . nbBits = ( BYTE ) ( nbBits + consumed ) ; <nl> + DElt . length = 2 ; <nl> + do { DTable [ i + + ] = DElt ; } while ( i < end ) ; / * since length > = 1 * / <nl> + <nl> + rankVal [ weight ] + = length ; <nl> + } } <nl> + } <nl> + <nl> + typedef U32 rankVal_t [ HUF_TABLELOG_MAX ] [ HUF_TABLELOG_MAX + 1 ] ; <nl> + <nl> + static void HUF_fillDTableX4 ( HUF_DEltX4 * DTable , const U32 targetLog , <nl> + const sortedSymbol_t * sortedList , const U32 sortedListSize , <nl> + const U32 * rankStart , rankVal_t rankValOrigin , const U32 maxWeight , <nl> + const U32 nbBitsBaseline ) <nl> + { <nl> + U32 rankVal [ HUF_TABLELOG_MAX + 1 ] ; <nl> + const int scaleLog = nbBitsBaseline - targetLog ; / * note : targetLog > = srcLog , hence scaleLog < = 1 * / <nl> + const U32 minBits = nbBitsBaseline - maxWeight ; <nl> + U32 s ; <nl> + <nl> + memcpy ( rankVal , rankValOrigin , sizeof ( rankVal ) ) ; <nl> + <nl> + / * fill DTable * / <nl> + for ( s = 0 ; s < sortedListSize ; s + + ) { <nl> + const U16 symbol = sortedList [ s ] . symbol ; <nl> + const U32 weight = sortedList [ s ] . weight ; <nl> + const U32 nbBits = nbBitsBaseline - weight ; <nl> + const U32 start = rankVal [ weight ] ; <nl> + const U32 length = 1 < < ( targetLog - nbBits ) ; <nl> + <nl> + if ( targetLog - nbBits > = minBits ) { / * enough room for a second symbol * / <nl> + U32 sortedRank ; <nl> + int minWeight = nbBits + scaleLog ; <nl> + if ( minWeight < 1 ) minWeight = 1 ; <nl> + sortedRank = rankStart [ minWeight ] ; <nl> + HUF_fillDTableX4Level2 ( DTable + start , targetLog - nbBits , nbBits , <nl> + rankValOrigin [ nbBits ] , minWeight , <nl> + sortedList + sortedRank , sortedListSize - sortedRank , <nl> + nbBitsBaseline , symbol ) ; <nl> + } else { <nl> + HUF_DEltX4 DElt ; <nl> + MEM_writeLE16 ( & ( DElt . sequence ) , symbol ) ; <nl> + DElt . nbBits = ( BYTE ) ( nbBits ) ; <nl> + DElt . length = 1 ; <nl> + { U32 const end = start + length ; <nl> + U32 u ; <nl> + for ( u = start ; u < end ; u + + ) DTable [ u ] = DElt ; <nl> + } } <nl> + rankVal [ weight ] + = length ; <nl> + } <nl> + } <nl> + <nl> + size_t HUF_readDTableX4 ( HUF_DTable * DTable , const void * src , size_t srcSize ) <nl> + { <nl> + BYTE weightList [ HUF_SYMBOLVALUE_MAX + 1 ] ; <nl> + sortedSymbol_t sortedSymbol [ HUF_SYMBOLVALUE_MAX + 1 ] ; <nl> + U32 rankStats [ HUF_TABLELOG_MAX + 1 ] = { 0 } ; <nl> + U32 rankStart0 [ HUF_TABLELOG_MAX + 2 ] = { 0 } ; <nl> + U32 * const rankStart = rankStart0 + 1 ; <nl> + rankVal_t rankVal ; <nl> + U32 tableLog , maxW , sizeOfSort , nbSymbols ; <nl> + DTableDesc dtd = HUF_getDTableDesc ( DTable ) ; <nl> + U32 const maxTableLog = dtd . maxTableLog ; <nl> + size_t iSize ; <nl> + void * dtPtr = DTable + 1 ; / * force compiler to avoid strict - aliasing * / <nl> + HUF_DEltX4 * const dt = ( HUF_DEltX4 * ) dtPtr ; <nl> + <nl> + HUF_STATIC_ASSERT ( sizeof ( HUF_DEltX4 ) = = sizeof ( HUF_DTable ) ) ; / * if compiler fails here , assertion is wrong * / <nl> + if ( maxTableLog > HUF_TABLELOG_MAX ) return ERROR ( tableLog_tooLarge ) ; <nl> + / * memset ( weightList , 0 , sizeof ( weightList ) ) ; * / / * is not necessary , even though some analyzer complain . . . * / <nl> + <nl> + iSize = HUF_readStats ( weightList , HUF_SYMBOLVALUE_MAX + 1 , rankStats , & nbSymbols , & tableLog , src , srcSize ) ; <nl> + if ( HUF_isError ( iSize ) ) return iSize ; <nl> + <nl> + / * check result * / <nl> + if ( tableLog > maxTableLog ) return ERROR ( tableLog_tooLarge ) ; / * DTable can ' t fit code depth * / <nl> + <nl> + / * find maxWeight * / <nl> + for ( maxW = tableLog ; rankStats [ maxW ] = = 0 ; maxW - - ) { } / * necessarily finds a solution before 0 * / <nl> + <nl> + / * Get start index of each weight * / <nl> + { U32 w , nextRankStart = 0 ; <nl> + for ( w = 1 ; w < maxW + 1 ; w + + ) { <nl> + U32 current = nextRankStart ; <nl> + nextRankStart + = rankStats [ w ] ; <nl> + rankStart [ w ] = current ; <nl> + } <nl> + rankStart [ 0 ] = nextRankStart ; / * put all 0w symbols at the end of sorted list * / <nl> + sizeOfSort = nextRankStart ; <nl> + } <nl> + <nl> + / * sort symbols by weight * / <nl> + { U32 s ; <nl> + for ( s = 0 ; s < nbSymbols ; s + + ) { <nl> + U32 const w = weightList [ s ] ; <nl> + U32 const r = rankStart [ w ] + + ; <nl> + sortedSymbol [ r ] . symbol = ( BYTE ) s ; <nl> + sortedSymbol [ r ] . weight = ( BYTE ) w ; <nl> + } <nl> + rankStart [ 0 ] = 0 ; / * forget 0w symbols ; this is beginning of weight ( 1 ) * / <nl> + } <nl> + <nl> + / * Build rankVal * / <nl> + { U32 * const rankVal0 = rankVal [ 0 ] ; <nl> + { int const rescale = ( maxTableLog - tableLog ) - 1 ; / * tableLog < = maxTableLog * / <nl> + U32 nextRankVal = 0 ; <nl> + U32 w ; <nl> + for ( w = 1 ; w < maxW + 1 ; w + + ) { <nl> + U32 current = nextRankVal ; <nl> + nextRankVal + = rankStats [ w ] < < ( w + rescale ) ; <nl> + rankVal0 [ w ] = current ; <nl> + } } <nl> + { U32 const minBits = tableLog + 1 - maxW ; <nl> + U32 consumed ; <nl> + for ( consumed = minBits ; consumed < maxTableLog - minBits + 1 ; consumed + + ) { <nl> + U32 * const rankValPtr = rankVal [ consumed ] ; <nl> + U32 w ; <nl> + for ( w = 1 ; w < maxW + 1 ; w + + ) { <nl> + rankValPtr [ w ] = rankVal0 [ w ] > > consumed ; <nl> + } } } } <nl> + <nl> + HUF_fillDTableX4 ( dt , maxTableLog , <nl> + sortedSymbol , sizeOfSort , <nl> + rankStart0 , rankVal , maxW , <nl> + tableLog + 1 ) ; <nl> + <nl> + dtd . tableLog = ( BYTE ) maxTableLog ; <nl> + dtd . tableType = 1 ; <nl> + memcpy ( DTable , & dtd , sizeof ( dtd ) ) ; <nl> + return iSize ; <nl> + } <nl> + <nl> + <nl> + static U32 HUF_decodeSymbolX4 ( void * op , BIT_DStream_t * DStream , const HUF_DEltX4 * dt , const U32 dtLog ) <nl> + { <nl> + size_t const val = BIT_lookBitsFast ( DStream , dtLog ) ; / * note : dtLog > = 1 * / <nl> + memcpy ( op , dt + val , 2 ) ; <nl> + BIT_skipBits ( DStream , dt [ val ] . nbBits ) ; <nl> + return dt [ val ] . length ; <nl> + } <nl> + <nl> + static U32 HUF_decodeLastSymbolX4 ( void * op , BIT_DStream_t * DStream , const HUF_DEltX4 * dt , const U32 dtLog ) <nl> + { <nl> + size_t const val = BIT_lookBitsFast ( DStream , dtLog ) ; / * note : dtLog > = 1 * / <nl> + memcpy ( op , dt + val , 1 ) ; <nl> + if ( dt [ val ] . length = = 1 ) BIT_skipBits ( DStream , dt [ val ] . nbBits ) ; <nl> + else { <nl> + if ( DStream - > bitsConsumed < ( sizeof ( DStream - > bitContainer ) * 8 ) ) { <nl> + BIT_skipBits ( DStream , dt [ val ] . nbBits ) ; <nl> + if ( DStream - > bitsConsumed > ( sizeof ( DStream - > bitContainer ) * 8 ) ) <nl> + DStream - > bitsConsumed = ( sizeof ( DStream - > bitContainer ) * 8 ) ; / * ugly hack ; works only because it ' s the last symbol . Note : can ' t easily extract nbBits from just this symbol * / <nl> + } } <nl> + return 1 ; <nl> + } <nl> + <nl> + <nl> + # define HUF_DECODE_SYMBOLX4_0 ( ptr , DStreamPtr ) \ <nl> + ptr + = HUF_decodeSymbolX4 ( ptr , DStreamPtr , dt , dtLog ) <nl> + <nl> + # define HUF_DECODE_SYMBOLX4_1 ( ptr , DStreamPtr ) \ <nl> + if ( MEM_64bits ( ) | | ( HUF_TABLELOG_MAX < = 12 ) ) \ <nl> + ptr + = HUF_decodeSymbolX4 ( ptr , DStreamPtr , dt , dtLog ) <nl> + <nl> + # define HUF_DECODE_SYMBOLX4_2 ( ptr , DStreamPtr ) \ <nl> + if ( MEM_64bits ( ) ) \ <nl> + ptr + = HUF_decodeSymbolX4 ( ptr , DStreamPtr , dt , dtLog ) <nl> + <nl> + FORCE_INLINE size_t HUF_decodeStreamX4 ( BYTE * p , BIT_DStream_t * bitDPtr , BYTE * const pEnd , const HUF_DEltX4 * const dt , const U32 dtLog ) <nl> + { <nl> + BYTE * const pStart = p ; <nl> + <nl> + / * up to 8 symbols at a time * / <nl> + while ( ( BIT_reloadDStream ( bitDPtr ) = = BIT_DStream_unfinished ) & ( p < pEnd - ( sizeof ( bitDPtr - > bitContainer ) - 1 ) ) ) { <nl> + HUF_DECODE_SYMBOLX4_2 ( p , bitDPtr ) ; <nl> + HUF_DECODE_SYMBOLX4_1 ( p , bitDPtr ) ; <nl> + HUF_DECODE_SYMBOLX4_2 ( p , bitDPtr ) ; <nl> + HUF_DECODE_SYMBOLX4_0 ( p , bitDPtr ) ; <nl> + } <nl> + <nl> + / * closer to end : up to 2 symbols at a time * / <nl> + while ( ( BIT_reloadDStream ( bitDPtr ) = = BIT_DStream_unfinished ) & ( p < = pEnd - 2 ) ) <nl> + HUF_DECODE_SYMBOLX4_0 ( p , bitDPtr ) ; <nl> + <nl> + while ( p < = pEnd - 2 ) <nl> + HUF_DECODE_SYMBOLX4_0 ( p , bitDPtr ) ; / * no need to reload : reached the end of DStream * / <nl> + <nl> + if ( p < pEnd ) <nl> + p + = HUF_decodeLastSymbolX4 ( p , bitDPtr , dt , dtLog ) ; <nl> + <nl> + return p - pStart ; <nl> + } <nl> + <nl> + <nl> + static size_t HUF_decompress1X4_usingDTable_internal ( <nl> + void * dst , size_t dstSize , <nl> + const void * cSrc , size_t cSrcSize , <nl> + const HUF_DTable * DTable ) <nl> + { <nl> + BIT_DStream_t bitD ; <nl> + <nl> + / * Init * / <nl> + { size_t const errorCode = BIT_initDStream ( & bitD , cSrc , cSrcSize ) ; <nl> + if ( HUF_isError ( errorCode ) ) return errorCode ; <nl> + } <nl> + <nl> + / * decode * / <nl> + { BYTE * const ostart = ( BYTE * ) dst ; <nl> + BYTE * const oend = ostart + dstSize ; <nl> + const void * const dtPtr = DTable + 1 ; / * force compiler to not use strict - aliasing * / <nl> + const HUF_DEltX4 * const dt = ( const HUF_DEltX4 * ) dtPtr ; <nl> + DTableDesc const dtd = HUF_getDTableDesc ( DTable ) ; <nl> + HUF_decodeStreamX4 ( ostart , & bitD , oend , dt , dtd . tableLog ) ; <nl> + } <nl> + <nl> + / * check * / <nl> + if ( ! BIT_endOfDStream ( & bitD ) ) return ERROR ( corruption_detected ) ; <nl> + <nl> + / * decoded size * / <nl> + return dstSize ; <nl> + } <nl> + <nl> + size_t HUF_decompress1X4_usingDTable ( <nl> + void * dst , size_t dstSize , <nl> + const void * cSrc , size_t cSrcSize , <nl> + const HUF_DTable * DTable ) <nl> + { <nl> + DTableDesc dtd = HUF_getDTableDesc ( DTable ) ; <nl> + if ( dtd . tableType ! = 1 ) return ERROR ( GENERIC ) ; <nl> + return HUF_decompress1X4_usingDTable_internal ( dst , dstSize , cSrc , cSrcSize , DTable ) ; <nl> + } <nl> + <nl> + size_t HUF_decompress1X4_DCtx ( HUF_DTable * DCtx , void * dst , size_t dstSize , const void * cSrc , size_t cSrcSize ) <nl> + { <nl> + const BYTE * ip = ( const BYTE * ) cSrc ; <nl> + <nl> + size_t const hSize = HUF_readDTableX4 ( DCtx , cSrc , cSrcSize ) ; <nl> + if ( HUF_isError ( hSize ) ) return hSize ; <nl> + if ( hSize > = cSrcSize ) return ERROR ( srcSize_wrong ) ; <nl> + ip + = hSize ; cSrcSize - = hSize ; <nl> + <nl> + return HUF_decompress1X4_usingDTable_internal ( dst , dstSize , ip , cSrcSize , DCtx ) ; <nl> + } <nl> + <nl> + size_t HUF_decompress1X4 ( void * dst , size_t dstSize , const void * cSrc , size_t cSrcSize ) <nl> + { <nl> + HUF_CREATE_STATIC_DTABLEX4 ( DTable , HUF_TABLELOG_MAX ) ; <nl> + return HUF_decompress1X4_DCtx ( DTable , dst , dstSize , cSrc , cSrcSize ) ; <nl> + } <nl> + <nl> + static size_t HUF_decompress4X4_usingDTable_internal ( <nl> + void * dst , size_t dstSize , <nl> + const void * cSrc , size_t cSrcSize , <nl> + const HUF_DTable * DTable ) <nl> + { <nl> + if ( cSrcSize < 10 ) return ERROR ( corruption_detected ) ; / * strict minimum : jump table + 1 byte per stream * / <nl> + <nl> + { const BYTE * const istart = ( const BYTE * ) cSrc ; <nl> + BYTE * const ostart = ( BYTE * ) dst ; <nl> + BYTE * const oend = ostart + dstSize ; <nl> + const void * const dtPtr = DTable + 1 ; <nl> + const HUF_DEltX4 * const dt = ( const HUF_DEltX4 * ) dtPtr ; <nl> + <nl> + / * Init * / <nl> + BIT_DStream_t bitD1 ; <nl> + BIT_DStream_t bitD2 ; <nl> + BIT_DStream_t bitD3 ; <nl> + BIT_DStream_t bitD4 ; <nl> + size_t const length1 = MEM_readLE16 ( istart ) ; <nl> + size_t const length2 = MEM_readLE16 ( istart + 2 ) ; <nl> + size_t const length3 = MEM_readLE16 ( istart + 4 ) ; <nl> + size_t const length4 = cSrcSize - ( length1 + length2 + length3 + 6 ) ; <nl> + const BYTE * const istart1 = istart + 6 ; / * jumpTable * / <nl> + const BYTE * const istart2 = istart1 + length1 ; <nl> + const BYTE * const istart3 = istart2 + length2 ; <nl> + const BYTE * const istart4 = istart3 + length3 ; <nl> + size_t const segmentSize = ( dstSize + 3 ) / 4 ; <nl> + BYTE * const opStart2 = ostart + segmentSize ; <nl> + BYTE * const opStart3 = opStart2 + segmentSize ; <nl> + BYTE * const opStart4 = opStart3 + segmentSize ; <nl> + BYTE * op1 = ostart ; <nl> + BYTE * op2 = opStart2 ; <nl> + BYTE * op3 = opStart3 ; <nl> + BYTE * op4 = opStart4 ; <nl> + U32 endSignal ; <nl> + DTableDesc const dtd = HUF_getDTableDesc ( DTable ) ; <nl> + U32 const dtLog = dtd . tableLog ; <nl> + <nl> + if ( length4 > cSrcSize ) return ERROR ( corruption_detected ) ; / * overflow * / <nl> + { size_t const errorCode = BIT_initDStream ( & bitD1 , istart1 , length1 ) ; <nl> + if ( HUF_isError ( errorCode ) ) return errorCode ; } <nl> + { size_t const errorCode = BIT_initDStream ( & bitD2 , istart2 , length2 ) ; <nl> + if ( HUF_isError ( errorCode ) ) return errorCode ; } <nl> + { size_t const errorCode = BIT_initDStream ( & bitD3 , istart3 , length3 ) ; <nl> + if ( HUF_isError ( errorCode ) ) return errorCode ; } <nl> + { size_t const errorCode = BIT_initDStream ( & bitD4 , istart4 , length4 ) ; <nl> + if ( HUF_isError ( errorCode ) ) return errorCode ; } <nl> + <nl> + / * 16 - 32 symbols per loop ( 4 - 8 symbols per stream ) * / <nl> + endSignal = BIT_reloadDStream ( & bitD1 ) | BIT_reloadDStream ( & bitD2 ) | BIT_reloadDStream ( & bitD3 ) | BIT_reloadDStream ( & bitD4 ) ; <nl> + for ( ; ( endSignal = = BIT_DStream_unfinished ) & ( op4 < ( oend - ( sizeof ( bitD4 . bitContainer ) - 1 ) ) ) ; ) { <nl> + HUF_DECODE_SYMBOLX4_2 ( op1 , & bitD1 ) ; <nl> + HUF_DECODE_SYMBOLX4_2 ( op2 , & bitD2 ) ; <nl> + HUF_DECODE_SYMBOLX4_2 ( op3 , & bitD3 ) ; <nl> + HUF_DECODE_SYMBOLX4_2 ( op4 , & bitD4 ) ; <nl> + HUF_DECODE_SYMBOLX4_1 ( op1 , & bitD1 ) ; <nl> + HUF_DECODE_SYMBOLX4_1 ( op2 , & bitD2 ) ; <nl> + HUF_DECODE_SYMBOLX4_1 ( op3 , & bitD3 ) ; <nl> + HUF_DECODE_SYMBOLX4_1 ( op4 , & bitD4 ) ; <nl> + HUF_DECODE_SYMBOLX4_2 ( op1 , & bitD1 ) ; <nl> + HUF_DECODE_SYMBOLX4_2 ( op2 , & bitD2 ) ; <nl> + HUF_DECODE_SYMBOLX4_2 ( op3 , & bitD3 ) ; <nl> + HUF_DECODE_SYMBOLX4_2 ( op4 , & bitD4 ) ; <nl> + HUF_DECODE_SYMBOLX4_0 ( op1 , & bitD1 ) ; <nl> + HUF_DECODE_SYMBOLX4_0 ( op2 , & bitD2 ) ; <nl> + HUF_DECODE_SYMBOLX4_0 ( op3 , & bitD3 ) ; <nl> + HUF_DECODE_SYMBOLX4_0 ( op4 , & bitD4 ) ; <nl> + <nl> + endSignal = BIT_reloadDStream ( & bitD1 ) | BIT_reloadDStream ( & bitD2 ) | BIT_reloadDStream ( & bitD3 ) | BIT_reloadDStream ( & bitD4 ) ; <nl> + } <nl> + <nl> + / * check corruption * / <nl> + if ( op1 > opStart2 ) return ERROR ( corruption_detected ) ; <nl> + if ( op2 > opStart3 ) return ERROR ( corruption_detected ) ; <nl> + if ( op3 > opStart4 ) return ERROR ( corruption_detected ) ; <nl> + / * note : op4 already verified within main loop * / <nl> + <nl> + / * finish bitStreams one by one * / <nl> + HUF_decodeStreamX4 ( op1 , & bitD1 , opStart2 , dt , dtLog ) ; <nl> + HUF_decodeStreamX4 ( op2 , & bitD2 , opStart3 , dt , dtLog ) ; <nl> + HUF_decodeStreamX4 ( op3 , & bitD3 , opStart4 , dt , dtLog ) ; <nl> + HUF_decodeStreamX4 ( op4 , & bitD4 , oend , dt , dtLog ) ; <nl> + <nl> + / * check * / <nl> + { U32 const endCheck = BIT_endOfDStream ( & bitD1 ) & BIT_endOfDStream ( & bitD2 ) & BIT_endOfDStream ( & bitD3 ) & BIT_endOfDStream ( & bitD4 ) ; <nl> + if ( ! endCheck ) return ERROR ( corruption_detected ) ; } <nl> + <nl> + / * decoded size * / <nl> + return dstSize ; <nl> + } <nl> + } <nl> + <nl> + <nl> + size_t HUF_decompress4X4_usingDTable ( <nl> + void * dst , size_t dstSize , <nl> + const void * cSrc , size_t cSrcSize , <nl> + const HUF_DTable * DTable ) <nl> + { <nl> + DTableDesc dtd = HUF_getDTableDesc ( DTable ) ; <nl> + if ( dtd . tableType ! = 1 ) return ERROR ( GENERIC ) ; <nl> + return HUF_decompress4X4_usingDTable_internal ( dst , dstSize , cSrc , cSrcSize , DTable ) ; <nl> + } <nl> + <nl> + <nl> + size_t HUF_decompress4X4_DCtx ( HUF_DTable * dctx , void * dst , size_t dstSize , const void * cSrc , size_t cSrcSize ) <nl> + { <nl> + const BYTE * ip = ( const BYTE * ) cSrc ; <nl> + <nl> + size_t hSize = HUF_readDTableX4 ( dctx , cSrc , cSrcSize ) ; <nl> + if ( HUF_isError ( hSize ) ) return hSize ; <nl> + if ( hSize > = cSrcSize ) return ERROR ( srcSize_wrong ) ; <nl> + ip + = hSize ; cSrcSize - = hSize ; <nl> + <nl> + return HUF_decompress4X4_usingDTable_internal ( dst , dstSize , ip , cSrcSize , dctx ) ; <nl> + } <nl> + <nl> + size_t HUF_decompress4X4 ( void * dst , size_t dstSize , const void * cSrc , size_t cSrcSize ) <nl> + { <nl> + HUF_CREATE_STATIC_DTABLEX4 ( DTable , HUF_TABLELOG_MAX ) ; <nl> + return HUF_decompress4X4_DCtx ( DTable , dst , dstSize , cSrc , cSrcSize ) ; <nl> + } <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * Generic decompression selector * / <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + size_t HUF_decompress1X_usingDTable ( void * dst , size_t maxDstSize , <nl> + const void * cSrc , size_t cSrcSize , <nl> + const HUF_DTable * DTable ) <nl> + { <nl> + DTableDesc const dtd = HUF_getDTableDesc ( DTable ) ; <nl> + return dtd . tableType ? HUF_decompress1X4_usingDTable_internal ( dst , maxDstSize , cSrc , cSrcSize , DTable ) : <nl> + HUF_decompress1X2_usingDTable_internal ( dst , maxDstSize , cSrc , cSrcSize , DTable ) ; <nl> + } <nl> + <nl> + size_t HUF_decompress4X_usingDTable ( void * dst , size_t maxDstSize , <nl> + const void * cSrc , size_t cSrcSize , <nl> + const HUF_DTable * DTable ) <nl> + { <nl> + DTableDesc const dtd = HUF_getDTableDesc ( DTable ) ; <nl> + return dtd . tableType ? HUF_decompress4X4_usingDTable_internal ( dst , maxDstSize , cSrc , cSrcSize , DTable ) : <nl> + HUF_decompress4X2_usingDTable_internal ( dst , maxDstSize , cSrc , cSrcSize , DTable ) ; <nl> + } <nl> + <nl> + <nl> + typedef struct { U32 tableTime ; U32 decode256Time ; } algo_time_t ; <nl> + static const algo_time_t algoTime [ 16 / * Quantization * / ] [ 3 / * single , double , quad * / ] = <nl> + { <nl> + / * single , double , quad * / <nl> + { { 0 , 0 } , { 1 , 1 } , { 2 , 2 } } , / * Q = = 0 : impossible * / <nl> + { { 0 , 0 } , { 1 , 1 } , { 2 , 2 } } , / * Q = = 1 : impossible * / <nl> + { { 38 , 130 } , { 1313 , 74 } , { 2151 , 38 } } , / * Q = = 2 : 12 - 18 % * / <nl> + { { 448 , 128 } , { 1353 , 74 } , { 2238 , 41 } } , / * Q = = 3 : 18 - 25 % * / <nl> + { { 556 , 128 } , { 1353 , 74 } , { 2238 , 47 } } , / * Q = = 4 : 25 - 32 % * / <nl> + { { 714 , 128 } , { 1418 , 74 } , { 2436 , 53 } } , / * Q = = 5 : 32 - 38 % * / <nl> + { { 883 , 128 } , { 1437 , 74 } , { 2464 , 61 } } , / * Q = = 6 : 38 - 44 % * / <nl> + { { 897 , 128 } , { 1515 , 75 } , { 2622 , 68 } } , / * Q = = 7 : 44 - 50 % * / <nl> + { { 926 , 128 } , { 1613 , 75 } , { 2730 , 75 } } , / * Q = = 8 : 50 - 56 % * / <nl> + { { 947 , 128 } , { 1729 , 77 } , { 3359 , 77 } } , / * Q = = 9 : 56 - 62 % * / <nl> + { { 1107 , 128 } , { 2083 , 81 } , { 4006 , 84 } } , / * Q = = 10 : 62 - 69 % * / <nl> + { { 1177 , 128 } , { 2379 , 87 } , { 4785 , 88 } } , / * Q = = 11 : 69 - 75 % * / <nl> + { { 1242 , 128 } , { 2415 , 93 } , { 5155 , 84 } } , / * Q = = 12 : 75 - 81 % * / <nl> + { { 1349 , 128 } , { 2644 , 106 } , { 5260 , 106 } } , / * Q = = 13 : 81 - 87 % * / <nl> + { { 1455 , 128 } , { 2422 , 124 } , { 4174 , 124 } } , / * Q = = 14 : 87 - 93 % * / <nl> + { { 722 , 128 } , { 1891 , 145 } , { 1936 , 146 } } , / * Q = = 15 : 93 - 99 % * / <nl> + } ; <nl> + <nl> + / * * HUF_selectDecoder ( ) : <nl> + * Tells which decoder is likely to decode faster , <nl> + * based on a set of pre - determined metrics . <nl> + * @ return : 0 = = HUF_decompress4X2 , 1 = = HUF_decompress4X4 . <nl> + * Assumption : 0 < cSrcSize < dstSize < = 128 KB * / <nl> + U32 HUF_selectDecoder ( size_t dstSize , size_t cSrcSize ) <nl> + { <nl> + / * decoder timing evaluation * / <nl> + U32 const Q = ( U32 ) ( cSrcSize * 16 / dstSize ) ; / * Q < 16 since dstSize > cSrcSize * / <nl> + U32 const D256 = ( U32 ) ( dstSize > > 8 ) ; <nl> + U32 const DTime0 = algoTime [ Q ] [ 0 ] . tableTime + ( algoTime [ Q ] [ 0 ] . decode256Time * D256 ) ; <nl> + U32 DTime1 = algoTime [ Q ] [ 1 ] . tableTime + ( algoTime [ Q ] [ 1 ] . decode256Time * D256 ) ; <nl> + DTime1 + = DTime1 > > 3 ; / * advantage to algorithm using less memory , for cache eviction * / <nl> + <nl> + return DTime1 < DTime0 ; <nl> + } <nl> + <nl> + <nl> + typedef size_t ( * decompressionAlgo ) ( void * dst , size_t dstSize , const void * cSrc , size_t cSrcSize ) ; <nl> + <nl> + size_t HUF_decompress ( void * dst , size_t dstSize , const void * cSrc , size_t cSrcSize ) <nl> + { <nl> + static const decompressionAlgo decompress [ 2 ] = { HUF_decompress4X2 , HUF_decompress4X4 } ; <nl> + <nl> + / * validation checks * / <nl> + if ( dstSize = = 0 ) return ERROR ( dstSize_tooSmall ) ; <nl> + if ( cSrcSize > dstSize ) return ERROR ( corruption_detected ) ; / * invalid * / <nl> + if ( cSrcSize = = dstSize ) { memcpy ( dst , cSrc , dstSize ) ; return dstSize ; } / * not compressed * / <nl> + if ( cSrcSize = = 1 ) { memset ( dst , * ( const BYTE * ) cSrc , dstSize ) ; return dstSize ; } / * RLE * / <nl> + <nl> + { U32 const algoNb = HUF_selectDecoder ( dstSize , cSrcSize ) ; <nl> + return decompress [ algoNb ] ( dst , dstSize , cSrc , cSrcSize ) ; <nl> + } <nl> + } <nl> + <nl> + size_t HUF_decompress4X_DCtx ( HUF_DTable * dctx , void * dst , size_t dstSize , const void * cSrc , size_t cSrcSize ) <nl> + { <nl> + / * validation checks * / <nl> + if ( dstSize = = 0 ) return ERROR ( dstSize_tooSmall ) ; <nl> + if ( cSrcSize > dstSize ) return ERROR ( corruption_detected ) ; / * invalid * / <nl> + if ( cSrcSize = = dstSize ) { memcpy ( dst , cSrc , dstSize ) ; return dstSize ; } / * not compressed * / <nl> + if ( cSrcSize = = 1 ) { memset ( dst , * ( const BYTE * ) cSrc , dstSize ) ; return dstSize ; } / * RLE * / <nl> + <nl> + { U32 const algoNb = HUF_selectDecoder ( dstSize , cSrcSize ) ; <nl> + return algoNb ? HUF_decompress4X4_DCtx ( dctx , dst , dstSize , cSrc , cSrcSize ) : <nl> + HUF_decompress4X2_DCtx ( dctx , dst , dstSize , cSrc , cSrcSize ) ; <nl> + } <nl> + } <nl> + <nl> + size_t HUF_decompress4X_hufOnly ( HUF_DTable * dctx , void * dst , size_t dstSize , const void * cSrc , size_t cSrcSize ) <nl> + { <nl> + / * validation checks * / <nl> + if ( dstSize = = 0 ) return ERROR ( dstSize_tooSmall ) ; <nl> + if ( ( cSrcSize > = dstSize ) | | ( cSrcSize < = 1 ) ) return ERROR ( corruption_detected ) ; / * invalid * / <nl> + <nl> + { U32 const algoNb = HUF_selectDecoder ( dstSize , cSrcSize ) ; <nl> + return algoNb ? HUF_decompress4X4_DCtx ( dctx , dst , dstSize , cSrc , cSrcSize ) : <nl> + HUF_decompress4X2_DCtx ( dctx , dst , dstSize , cSrc , cSrcSize ) ; <nl> + } <nl> + } <nl> + <nl> + size_t HUF_decompress1X_DCtx ( HUF_DTable * dctx , void * dst , size_t dstSize , const void * cSrc , size_t cSrcSize ) <nl> + { <nl> + / * validation checks * / <nl> + if ( dstSize = = 0 ) return ERROR ( dstSize_tooSmall ) ; <nl> + if ( cSrcSize > dstSize ) return ERROR ( corruption_detected ) ; / * invalid * / <nl> + if ( cSrcSize = = dstSize ) { memcpy ( dst , cSrc , dstSize ) ; return dstSize ; } / * not compressed * / <nl> + if ( cSrcSize = = 1 ) { memset ( dst , * ( const BYTE * ) cSrc , dstSize ) ; return dstSize ; } / * RLE * / <nl> + <nl> + { U32 const algoNb = HUF_selectDecoder ( dstSize , cSrcSize ) ; <nl> + return algoNb ? HUF_decompress1X4_DCtx ( dctx , dst , dstSize , cSrc , cSrcSize ) : <nl> + HUF_decompress1X2_DCtx ( dctx , dst , dstSize , cSrc , cSrcSize ) ; <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 910f9ab783c <nl> mmm / dev / null <nl> ppp b / thirdparty / zstd / decompress / zstd_decompress . c <nl> <nl> + / * * <nl> + * Copyright ( c ) 2016 - present , Yann Collet , Facebook , Inc . <nl> + * All rights reserved . <nl> + * <nl> + * This source code is licensed under the BSD - style license found in the <nl> + * LICENSE file in the root directory of this source tree . An additional grant <nl> + * of patent rights can be found in the PATENTS file in the same directory . <nl> + * / <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Tuning parameters <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * ! <nl> + * HEAPMODE : <nl> + * Select how default decompression function ZSTD_decompress ( ) will allocate memory , <nl> + * in memory stack ( 0 ) , or in memory heap ( 1 , requires malloc ( ) ) <nl> + * / <nl> + # ifndef ZSTD_HEAPMODE <nl> + # define ZSTD_HEAPMODE 1 <nl> + # endif <nl> + <nl> + / * ! <nl> + * LEGACY_SUPPORT : <nl> + * if set to 1 , ZSTD_decompress ( ) can decode older formats ( v0 . 1 + ) <nl> + * / <nl> + # ifndef ZSTD_LEGACY_SUPPORT <nl> + # define ZSTD_LEGACY_SUPPORT 0 <nl> + # endif <nl> + <nl> + / * ! <nl> + * MAXWINDOWSIZE_DEFAULT : <nl> + * maximum window size accepted by DStream , by default . <nl> + * Frames requiring more memory will be rejected . <nl> + * / <nl> + # ifndef ZSTD_MAXWINDOWSIZE_DEFAULT <nl> + # define ZSTD_MAXWINDOWSIZE_DEFAULT ( ( 1 < < ZSTD_WINDOWLOG_MAX ) + 1 ) / * defined within zstd . h * / <nl> + # endif <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Dependencies <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # include < string . h > / * memcpy , memmove , memset * / <nl> + # include " mem . h " / * low level memory routines * / <nl> + # define FSE_STATIC_LINKING_ONLY <nl> + # include " fse . h " <nl> + # define HUF_STATIC_LINKING_ONLY <nl> + # include " huf . h " <nl> + # include " zstd_internal . h " <nl> + <nl> + # if defined ( ZSTD_LEGACY_SUPPORT ) & & ( ZSTD_LEGACY_SUPPORT > = 1 ) <nl> + # include " zstd_legacy . h " <nl> + # endif <nl> + <nl> + <nl> + # if defined ( _MSC_VER ) <nl> + # include < mmintrin . h > / * https : / / msdn . microsoft . com / fr - fr / library / 84szxsww ( v = vs . 90 ) . aspx * / <nl> + # define ZSTD_PREFETCH ( ptr ) _mm_prefetch ( ( const char * ) ptr , _MM_HINT_T0 ) <nl> + # elif defined ( __GNUC__ ) <nl> + # define ZSTD_PREFETCH ( ptr ) __builtin_prefetch ( ptr , 0 , 0 ) <nl> + # else <nl> + # define ZSTD_PREFETCH ( ptr ) / * disabled * / <nl> + # endif <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Macros <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # define ZSTD_isError ERR_isError / * for inlining * / <nl> + # define FSE_isError ERR_isError <nl> + # define HUF_isError ERR_isError <nl> + <nl> + <nl> + / * _ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Memory operations <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + static void ZSTD_copy4 ( void * dst , const void * src ) { memcpy ( dst , src , 4 ) ; } <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Context management <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + typedef enum { ZSTDds_getFrameHeaderSize , ZSTDds_decodeFrameHeader , <nl> + ZSTDds_decodeBlockHeader , ZSTDds_decompressBlock , <nl> + ZSTDds_decompressLastBlock , ZSTDds_checkChecksum , <nl> + ZSTDds_decodeSkippableHeader , ZSTDds_skipFrame } ZSTD_dStage ; <nl> + <nl> + typedef struct { <nl> + FSE_DTable LLTable [ FSE_DTABLE_SIZE_U32 ( LLFSELog ) ] ; <nl> + FSE_DTable OFTable [ FSE_DTABLE_SIZE_U32 ( OffFSELog ) ] ; <nl> + FSE_DTable MLTable [ FSE_DTABLE_SIZE_U32 ( MLFSELog ) ] ; <nl> + HUF_DTable hufTable [ HUF_DTABLE_SIZE ( HufLog ) ] ; / * can accommodate HUF_decompress4X * / <nl> + U32 rep [ ZSTD_REP_NUM ] ; <nl> + } ZSTD_entropyTables_t ; <nl> + <nl> + struct ZSTD_DCtx_s <nl> + { <nl> + const FSE_DTable * LLTptr ; <nl> + const FSE_DTable * MLTptr ; <nl> + const FSE_DTable * OFTptr ; <nl> + const HUF_DTable * HUFptr ; <nl> + ZSTD_entropyTables_t entropy ; <nl> + const void * previousDstEnd ; / * detect continuity * / <nl> + const void * base ; / * start of current segment * / <nl> + const void * vBase ; / * virtual start of previous segment if it was just before current one * / <nl> + const void * dictEnd ; / * end of previous segment * / <nl> + size_t expected ; <nl> + ZSTD_frameParams fParams ; <nl> + blockType_e bType ; / * used in ZSTD_decompressContinue ( ) , to transfer blockType between header decoding and block decoding stages * / <nl> + ZSTD_dStage stage ; <nl> + U32 litEntropy ; <nl> + U32 fseEntropy ; <nl> + XXH64_state_t xxhState ; <nl> + size_t headerSize ; <nl> + U32 dictID ; <nl> + const BYTE * litPtr ; <nl> + ZSTD_customMem customMem ; <nl> + size_t litSize ; <nl> + size_t rleSize ; <nl> + BYTE litBuffer [ ZSTD_BLOCKSIZE_ABSOLUTEMAX + WILDCOPY_OVERLENGTH ] ; <nl> + BYTE headerBuffer [ ZSTD_FRAMEHEADERSIZE_MAX ] ; <nl> + } ; / * typedef ' d to ZSTD_DCtx within " zstd . h " * / <nl> + <nl> + size_t ZSTD_sizeof_DCtx ( const ZSTD_DCtx * dctx ) { return ( dctx = = NULL ) ? 0 : sizeof ( ZSTD_DCtx ) ; } <nl> + <nl> + size_t ZSTD_estimateDCtxSize ( void ) { return sizeof ( ZSTD_DCtx ) ; } <nl> + <nl> + size_t ZSTD_decompressBegin ( ZSTD_DCtx * dctx ) <nl> + { <nl> + dctx - > expected = ZSTD_frameHeaderSize_prefix ; <nl> + dctx - > stage = ZSTDds_getFrameHeaderSize ; <nl> + dctx - > previousDstEnd = NULL ; <nl> + dctx - > base = NULL ; <nl> + dctx - > vBase = NULL ; <nl> + dctx - > dictEnd = NULL ; <nl> + dctx - > entropy . hufTable [ 0 ] = ( HUF_DTable ) ( ( HufLog ) * 0x1000001 ) ; / * cover both little and big endian * / <nl> + dctx - > litEntropy = dctx - > fseEntropy = 0 ; <nl> + dctx - > dictID = 0 ; <nl> + MEM_STATIC_ASSERT ( sizeof ( dctx - > entropy . rep ) = = sizeof ( repStartValue ) ) ; <nl> + memcpy ( dctx - > entropy . rep , repStartValue , sizeof ( repStartValue ) ) ; / * initial repcodes * / <nl> + dctx - > LLTptr = dctx - > entropy . LLTable ; <nl> + dctx - > MLTptr = dctx - > entropy . MLTable ; <nl> + dctx - > OFTptr = dctx - > entropy . OFTable ; <nl> + dctx - > HUFptr = dctx - > entropy . hufTable ; <nl> + return 0 ; <nl> + } <nl> + <nl> + ZSTD_DCtx * ZSTD_createDCtx_advanced ( ZSTD_customMem customMem ) <nl> + { <nl> + ZSTD_DCtx * dctx ; <nl> + <nl> + if ( ! customMem . customAlloc & & ! customMem . customFree ) customMem = defaultCustomMem ; <nl> + if ( ! customMem . customAlloc | | ! customMem . customFree ) return NULL ; <nl> + <nl> + dctx = ( ZSTD_DCtx * ) ZSTD_malloc ( sizeof ( ZSTD_DCtx ) , customMem ) ; <nl> + if ( ! dctx ) return NULL ; <nl> + memcpy ( & dctx - > customMem , & customMem , sizeof ( customMem ) ) ; <nl> + ZSTD_decompressBegin ( dctx ) ; <nl> + return dctx ; <nl> + } <nl> + <nl> + ZSTD_DCtx * ZSTD_createDCtx ( void ) <nl> + { <nl> + return ZSTD_createDCtx_advanced ( defaultCustomMem ) ; <nl> + } <nl> + <nl> + size_t ZSTD_freeDCtx ( ZSTD_DCtx * dctx ) <nl> + { <nl> + if ( dctx = = NULL ) return 0 ; / * support free on NULL * / <nl> + ZSTD_free ( dctx , dctx - > customMem ) ; <nl> + return 0 ; / * reserved as a potential error code in the future * / <nl> + } <nl> + <nl> + void ZSTD_copyDCtx ( ZSTD_DCtx * dstDCtx , const ZSTD_DCtx * srcDCtx ) <nl> + { <nl> + size_t const workSpaceSize = ( ZSTD_BLOCKSIZE_ABSOLUTEMAX + WILDCOPY_OVERLENGTH ) + ZSTD_frameHeaderSize_max ; <nl> + memcpy ( dstDCtx , srcDCtx , sizeof ( ZSTD_DCtx ) - workSpaceSize ) ; / * no need to copy workspace * / <nl> + } <nl> + <nl> + static void ZSTD_refDDict ( ZSTD_DCtx * dstDCtx , const ZSTD_DDict * ddict ) ; <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Decompression section <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + / * ! ZSTD_isFrame ( ) : <nl> + * Tells if the content of ` buffer ` starts with a valid Frame Identifier . <nl> + * Note : Frame Identifier is 4 bytes . If ` size < 4 ` , @ return will always be 0 . <nl> + * Note 2 : Legacy Frame Identifiers are considered valid only if Legacy Support is enabled . <nl> + * Note 3 : Skippable Frame Identifiers are considered valid . * / <nl> + unsigned ZSTD_isFrame ( const void * buffer , size_t size ) <nl> + { <nl> + if ( size < 4 ) return 0 ; <nl> + { U32 const magic = MEM_readLE32 ( buffer ) ; <nl> + if ( magic = = ZSTD_MAGICNUMBER ) return 1 ; <nl> + if ( ( magic & 0xFFFFFFF0U ) = = ZSTD_MAGIC_SKIPPABLE_START ) return 1 ; <nl> + } <nl> + # if defined ( ZSTD_LEGACY_SUPPORT ) & & ( ZSTD_LEGACY_SUPPORT > = 1 ) <nl> + if ( ZSTD_isLegacy ( buffer , size ) ) return 1 ; <nl> + # endif <nl> + return 0 ; <nl> + } <nl> + <nl> + <nl> + / * * ZSTD_frameHeaderSize ( ) : <nl> + * srcSize must be > = ZSTD_frameHeaderSize_prefix . <nl> + * @ return : size of the Frame Header * / <nl> + static size_t ZSTD_frameHeaderSize ( const void * src , size_t srcSize ) <nl> + { <nl> + if ( srcSize < ZSTD_frameHeaderSize_prefix ) return ERROR ( srcSize_wrong ) ; <nl> + { BYTE const fhd = ( ( const BYTE * ) src ) [ 4 ] ; <nl> + U32 const dictID = fhd & 3 ; <nl> + U32 const singleSegment = ( fhd > > 5 ) & 1 ; <nl> + U32 const fcsId = fhd > > 6 ; <nl> + return ZSTD_frameHeaderSize_prefix + ! singleSegment + ZSTD_did_fieldSize [ dictID ] + ZSTD_fcs_fieldSize [ fcsId ] <nl> + + ( singleSegment & & ! fcsId ) ; <nl> + } <nl> + } <nl> + <nl> + <nl> + / * * ZSTD_getFrameParams ( ) : <nl> + * decode Frame Header , or require larger ` srcSize ` . <nl> + * @ return : 0 , ` fparamsPtr ` is correctly filled , <nl> + * > 0 , ` srcSize ` is too small , result is expected ` srcSize ` , <nl> + * or an error code , which can be tested using ZSTD_isError ( ) * / <nl> + size_t ZSTD_getFrameParams ( ZSTD_frameParams * fparamsPtr , const void * src , size_t srcSize ) <nl> + { <nl> + const BYTE * ip = ( const BYTE * ) src ; <nl> + <nl> + if ( srcSize < ZSTD_frameHeaderSize_prefix ) return ZSTD_frameHeaderSize_prefix ; <nl> + if ( MEM_readLE32 ( src ) ! = ZSTD_MAGICNUMBER ) { <nl> + if ( ( MEM_readLE32 ( src ) & 0xFFFFFFF0U ) = = ZSTD_MAGIC_SKIPPABLE_START ) { <nl> + if ( srcSize < ZSTD_skippableHeaderSize ) return ZSTD_skippableHeaderSize ; / * magic number + skippable frame length * / <nl> + memset ( fparamsPtr , 0 , sizeof ( * fparamsPtr ) ) ; <nl> + fparamsPtr - > frameContentSize = MEM_readLE32 ( ( const char * ) src + 4 ) ; <nl> + fparamsPtr - > windowSize = 0 ; / * windowSize = = 0 means a frame is skippable * / <nl> + return 0 ; <nl> + } <nl> + return ERROR ( prefix_unknown ) ; <nl> + } <nl> + <nl> + / * ensure there is enough ` srcSize ` to fully read / decode frame header * / <nl> + { size_t const fhsize = ZSTD_frameHeaderSize ( src , srcSize ) ; <nl> + if ( srcSize < fhsize ) return fhsize ; } <nl> + <nl> + { BYTE const fhdByte = ip [ 4 ] ; <nl> + size_t pos = 5 ; <nl> + U32 const dictIDSizeCode = fhdByte & 3 ; <nl> + U32 const checksumFlag = ( fhdByte > > 2 ) & 1 ; <nl> + U32 const singleSegment = ( fhdByte > > 5 ) & 1 ; <nl> + U32 const fcsID = fhdByte > > 6 ; <nl> + U32 const windowSizeMax = 1U < < ZSTD_WINDOWLOG_MAX ; <nl> + U32 windowSize = 0 ; <nl> + U32 dictID = 0 ; <nl> + U64 frameContentSize = 0 ; <nl> + if ( ( fhdByte & 0x08 ) ! = 0 ) return ERROR ( frameParameter_unsupported ) ; / * reserved bits , which must be zero * / <nl> + if ( ! singleSegment ) { <nl> + BYTE const wlByte = ip [ pos + + ] ; <nl> + U32 const windowLog = ( wlByte > > 3 ) + ZSTD_WINDOWLOG_ABSOLUTEMIN ; <nl> + if ( windowLog > ZSTD_WINDOWLOG_MAX ) return ERROR ( frameParameter_windowTooLarge ) ; / * avoids issue with 1 < < windowLog * / <nl> + windowSize = ( 1U < < windowLog ) ; <nl> + windowSize + = ( windowSize > > 3 ) * ( wlByte & 7 ) ; <nl> + } <nl> + <nl> + switch ( dictIDSizeCode ) <nl> + { <nl> + default : / * impossible * / <nl> + case 0 : break ; <nl> + case 1 : dictID = ip [ pos ] ; pos + + ; break ; <nl> + case 2 : dictID = MEM_readLE16 ( ip + pos ) ; pos + = 2 ; break ; <nl> + case 3 : dictID = MEM_readLE32 ( ip + pos ) ; pos + = 4 ; break ; <nl> + } <nl> + switch ( fcsID ) <nl> + { <nl> + default : / * impossible * / <nl> + case 0 : if ( singleSegment ) frameContentSize = ip [ pos ] ; break ; <nl> + case 1 : frameContentSize = MEM_readLE16 ( ip + pos ) + 256 ; break ; <nl> + case 2 : frameContentSize = MEM_readLE32 ( ip + pos ) ; break ; <nl> + case 3 : frameContentSize = MEM_readLE64 ( ip + pos ) ; break ; <nl> + } <nl> + if ( ! windowSize ) windowSize = ( U32 ) frameContentSize ; <nl> + if ( windowSize > windowSizeMax ) return ERROR ( frameParameter_windowTooLarge ) ; <nl> + fparamsPtr - > frameContentSize = frameContentSize ; <nl> + fparamsPtr - > windowSize = windowSize ; <nl> + fparamsPtr - > dictID = dictID ; <nl> + fparamsPtr - > checksumFlag = checksumFlag ; <nl> + } <nl> + return 0 ; <nl> + } <nl> + <nl> + / * * ZSTD_getFrameContentSize ( ) : <nl> + * compatible with legacy mode <nl> + * @ return : decompressed size of the single frame pointed to be ` src ` if known , otherwise <nl> + * - ZSTD_CONTENTSIZE_UNKNOWN if the size cannot be determined <nl> + * - ZSTD_CONTENTSIZE_ERROR if an error occurred ( e . g . invalid magic number , srcSize too small ) * / <nl> + unsigned long long ZSTD_getFrameContentSize ( const void * src , size_t srcSize ) <nl> + { <nl> + # if defined ( ZSTD_LEGACY_SUPPORT ) & & ( ZSTD_LEGACY_SUPPORT > = 1 ) <nl> + if ( ZSTD_isLegacy ( src , srcSize ) ) { <nl> + unsigned long long const ret = ZSTD_getDecompressedSize_legacy ( src , srcSize ) ; <nl> + return ret = = 0 ? ZSTD_CONTENTSIZE_UNKNOWN : ret ; <nl> + } <nl> + # endif <nl> + { <nl> + ZSTD_frameParams fParams ; <nl> + if ( ZSTD_getFrameParams ( & fParams , src , srcSize ) ! = 0 ) return ZSTD_CONTENTSIZE_ERROR ; <nl> + if ( fParams . windowSize = = 0 ) { <nl> + / * Either skippable or empty frame , size = = 0 either way * / <nl> + return 0 ; <nl> + } else if ( fParams . frameContentSize ! = 0 ) { <nl> + return fParams . frameContentSize ; <nl> + } else { <nl> + return ZSTD_CONTENTSIZE_UNKNOWN ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + / * * ZSTD_findDecompressedSize ( ) : <nl> + * compatible with legacy mode <nl> + * ` srcSize ` must be the exact length of some number of ZSTD compressed and / or <nl> + * skippable frames <nl> + * @ return : decompressed size of the frames contained * / <nl> + unsigned long long ZSTD_findDecompressedSize ( const void * src , size_t srcSize ) <nl> + { <nl> + { <nl> + unsigned long long totalDstSize = 0 ; <nl> + while ( srcSize > = ZSTD_frameHeaderSize_prefix ) { <nl> + const U32 magicNumber = MEM_readLE32 ( src ) ; <nl> + <nl> + if ( ( magicNumber & 0xFFFFFFF0U ) = = ZSTD_MAGIC_SKIPPABLE_START ) { <nl> + size_t skippableSize ; <nl> + if ( srcSize < ZSTD_skippableHeaderSize ) <nl> + return ERROR ( srcSize_wrong ) ; <nl> + skippableSize = MEM_readLE32 ( ( const BYTE * ) src + 4 ) + <nl> + ZSTD_skippableHeaderSize ; <nl> + if ( srcSize < skippableSize ) { <nl> + return ZSTD_CONTENTSIZE_ERROR ; <nl> + } <nl> + <nl> + src = ( const BYTE * ) src + skippableSize ; <nl> + srcSize - = skippableSize ; <nl> + continue ; <nl> + } <nl> + <nl> + { <nl> + unsigned long long const ret = ZSTD_getFrameContentSize ( src , srcSize ) ; <nl> + if ( ret > = ZSTD_CONTENTSIZE_ERROR ) return ret ; <nl> + <nl> + / * check for overflow * / <nl> + if ( totalDstSize + ret < totalDstSize ) return ZSTD_CONTENTSIZE_ERROR ; <nl> + totalDstSize + = ret ; <nl> + } <nl> + { <nl> + size_t const frameSrcSize = ZSTD_findFrameCompressedSize ( src , srcSize ) ; <nl> + if ( ZSTD_isError ( frameSrcSize ) ) { <nl> + return ZSTD_CONTENTSIZE_ERROR ; <nl> + } <nl> + <nl> + src = ( const BYTE * ) src + frameSrcSize ; <nl> + srcSize - = frameSrcSize ; <nl> + } <nl> + } <nl> + <nl> + if ( srcSize ) { <nl> + return ZSTD_CONTENTSIZE_ERROR ; <nl> + } <nl> + <nl> + return totalDstSize ; <nl> + } <nl> + } <nl> + <nl> + / * * ZSTD_getDecompressedSize ( ) : <nl> + * compatible with legacy mode <nl> + * @ return : decompressed size if known , 0 otherwise <nl> + note : 0 can mean any of the following : <nl> + - decompressed size is not present within frame header <nl> + - frame header unknown / not supported <nl> + - frame header not complete ( ` srcSize ` too small ) * / <nl> + unsigned long long ZSTD_getDecompressedSize ( const void * src , size_t srcSize ) <nl> + { <nl> + unsigned long long const ret = ZSTD_getFrameContentSize ( src , srcSize ) ; <nl> + return ret > = ZSTD_CONTENTSIZE_ERROR ? 0 : ret ; <nl> + } <nl> + <nl> + <nl> + / * * ZSTD_decodeFrameHeader ( ) : <nl> + * ` headerSize ` must be the size provided by ZSTD_frameHeaderSize ( ) . <nl> + * @ return : 0 if success , or an error code , which can be tested using ZSTD_isError ( ) * / <nl> + static size_t ZSTD_decodeFrameHeader ( ZSTD_DCtx * dctx , const void * src , size_t headerSize ) <nl> + { <nl> + size_t const result = ZSTD_getFrameParams ( & ( dctx - > fParams ) , src , headerSize ) ; <nl> + if ( ZSTD_isError ( result ) ) return result ; / * invalid header * / <nl> + if ( result > 0 ) return ERROR ( srcSize_wrong ) ; / * headerSize too small * / <nl> + if ( dctx - > fParams . dictID & & ( dctx - > dictID ! = dctx - > fParams . dictID ) ) return ERROR ( dictionary_wrong ) ; <nl> + if ( dctx - > fParams . checksumFlag ) XXH64_reset ( & dctx - > xxhState , 0 ) ; <nl> + return 0 ; <nl> + } <nl> + <nl> + <nl> + typedef struct <nl> + { <nl> + blockType_e blockType ; <nl> + U32 lastBlock ; <nl> + U32 origSize ; <nl> + } blockProperties_t ; <nl> + <nl> + / * ! ZSTD_getcBlockSize ( ) : <nl> + * Provides the size of compressed block from block header ` src ` * / <nl> + size_t ZSTD_getcBlockSize ( const void * src , size_t srcSize , <nl> + blockProperties_t * bpPtr ) <nl> + { <nl> + if ( srcSize < ZSTD_blockHeaderSize ) return ERROR ( srcSize_wrong ) ; <nl> + { U32 const cBlockHeader = MEM_readLE24 ( src ) ; <nl> + U32 const cSize = cBlockHeader > > 3 ; <nl> + bpPtr - > lastBlock = cBlockHeader & 1 ; <nl> + bpPtr - > blockType = ( blockType_e ) ( ( cBlockHeader > > 1 ) & 3 ) ; <nl> + bpPtr - > origSize = cSize ; / * only useful for RLE * / <nl> + if ( bpPtr - > blockType = = bt_rle ) return 1 ; <nl> + if ( bpPtr - > blockType = = bt_reserved ) return ERROR ( corruption_detected ) ; <nl> + return cSize ; <nl> + } <nl> + } <nl> + <nl> + <nl> + static size_t ZSTD_copyRawBlock ( void * dst , size_t dstCapacity , <nl> + const void * src , size_t srcSize ) <nl> + { <nl> + if ( srcSize > dstCapacity ) return ERROR ( dstSize_tooSmall ) ; <nl> + memcpy ( dst , src , srcSize ) ; <nl> + return srcSize ; <nl> + } <nl> + <nl> + <nl> + static size_t ZSTD_setRleBlock ( void * dst , size_t dstCapacity , <nl> + const void * src , size_t srcSize , <nl> + size_t regenSize ) <nl> + { <nl> + if ( srcSize ! = 1 ) return ERROR ( srcSize_wrong ) ; <nl> + if ( regenSize > dstCapacity ) return ERROR ( dstSize_tooSmall ) ; <nl> + memset ( dst , * ( const BYTE * ) src , regenSize ) ; <nl> + return regenSize ; <nl> + } <nl> + <nl> + / * ! ZSTD_decodeLiteralsBlock ( ) : <nl> + @ return : nb of bytes read from src ( < srcSize ) * / <nl> + size_t ZSTD_decodeLiteralsBlock ( ZSTD_DCtx * dctx , <nl> + const void * src , size_t srcSize ) / * note : srcSize < BLOCKSIZE * / <nl> + { <nl> + if ( srcSize < MIN_CBLOCK_SIZE ) return ERROR ( corruption_detected ) ; <nl> + <nl> + { const BYTE * const istart = ( const BYTE * ) src ; <nl> + symbolEncodingType_e const litEncType = ( symbolEncodingType_e ) ( istart [ 0 ] & 3 ) ; <nl> + <nl> + switch ( litEncType ) <nl> + { <nl> + case set_repeat : <nl> + if ( dctx - > litEntropy = = 0 ) return ERROR ( dictionary_corrupted ) ; <nl> + / * fall - through * / <nl> + case set_compressed : <nl> + if ( srcSize < 5 ) return ERROR ( corruption_detected ) ; / * srcSize > = MIN_CBLOCK_SIZE = = 3 ; here we need up to 5 for case 3 * / <nl> + { size_t lhSize , litSize , litCSize ; <nl> + U32 singleStream = 0 ; <nl> + U32 const lhlCode = ( istart [ 0 ] > > 2 ) & 3 ; <nl> + U32 const lhc = MEM_readLE32 ( istart ) ; <nl> + switch ( lhlCode ) <nl> + { <nl> + case 0 : case 1 : default : / * note : default is impossible , since lhlCode into [ 0 . . 3 ] * / <nl> + / * 2 - 2 - 10 - 10 * / <nl> + singleStream = ! lhlCode ; <nl> + lhSize = 3 ; <nl> + litSize = ( lhc > > 4 ) & 0x3FF ; <nl> + litCSize = ( lhc > > 14 ) & 0x3FF ; <nl> + break ; <nl> + case 2 : <nl> + / * 2 - 2 - 14 - 14 * / <nl> + lhSize = 4 ; <nl> + litSize = ( lhc > > 4 ) & 0x3FFF ; <nl> + litCSize = lhc > > 18 ; <nl> + break ; <nl> + case 3 : <nl> + / * 2 - 2 - 18 - 18 * / <nl> + lhSize = 5 ; <nl> + litSize = ( lhc > > 4 ) & 0x3FFFF ; <nl> + litCSize = ( lhc > > 22 ) + ( istart [ 4 ] < < 10 ) ; <nl> + break ; <nl> + } <nl> + if ( litSize > ZSTD_BLOCKSIZE_ABSOLUTEMAX ) return ERROR ( corruption_detected ) ; <nl> + if ( litCSize + lhSize > srcSize ) return ERROR ( corruption_detected ) ; <nl> + <nl> + if ( HUF_isError ( ( litEncType = = set_repeat ) ? <nl> + ( singleStream ? <nl> + HUF_decompress1X_usingDTable ( dctx - > litBuffer , litSize , istart + lhSize , litCSize , dctx - > HUFptr ) : <nl> + HUF_decompress4X_usingDTable ( dctx - > litBuffer , litSize , istart + lhSize , litCSize , dctx - > HUFptr ) ) : <nl> + ( singleStream ? <nl> + HUF_decompress1X2_DCtx ( dctx - > entropy . hufTable , dctx - > litBuffer , litSize , istart + lhSize , litCSize ) : <nl> + HUF_decompress4X_hufOnly ( dctx - > entropy . hufTable , dctx - > litBuffer , litSize , istart + lhSize , litCSize ) ) ) ) <nl> + return ERROR ( corruption_detected ) ; <nl> + <nl> + dctx - > litPtr = dctx - > litBuffer ; <nl> + dctx - > litSize = litSize ; <nl> + dctx - > litEntropy = 1 ; <nl> + if ( litEncType = = set_compressed ) dctx - > HUFptr = dctx - > entropy . hufTable ; <nl> + memset ( dctx - > litBuffer + dctx - > litSize , 0 , WILDCOPY_OVERLENGTH ) ; <nl> + return litCSize + lhSize ; <nl> + } <nl> + <nl> + case set_basic : <nl> + { size_t litSize , lhSize ; <nl> + U32 const lhlCode = ( ( istart [ 0 ] ) > > 2 ) & 3 ; <nl> + switch ( lhlCode ) <nl> + { <nl> + case 0 : case 2 : default : / * note : default is impossible , since lhlCode into [ 0 . . 3 ] * / <nl> + lhSize = 1 ; <nl> + litSize = istart [ 0 ] > > 3 ; <nl> + break ; <nl> + case 1 : <nl> + lhSize = 2 ; <nl> + litSize = MEM_readLE16 ( istart ) > > 4 ; <nl> + break ; <nl> + case 3 : <nl> + lhSize = 3 ; <nl> + litSize = MEM_readLE24 ( istart ) > > 4 ; <nl> + break ; <nl> + } <nl> + <nl> + if ( lhSize + litSize + WILDCOPY_OVERLENGTH > srcSize ) { / * risk reading beyond src buffer with wildcopy * / <nl> + if ( litSize + lhSize > srcSize ) return ERROR ( corruption_detected ) ; <nl> + memcpy ( dctx - > litBuffer , istart + lhSize , litSize ) ; <nl> + dctx - > litPtr = dctx - > litBuffer ; <nl> + dctx - > litSize = litSize ; <nl> + memset ( dctx - > litBuffer + dctx - > litSize , 0 , WILDCOPY_OVERLENGTH ) ; <nl> + return lhSize + litSize ; <nl> + } <nl> + / * direct reference into compressed stream * / <nl> + dctx - > litPtr = istart + lhSize ; <nl> + dctx - > litSize = litSize ; <nl> + return lhSize + litSize ; <nl> + } <nl> + <nl> + case set_rle : <nl> + { U32 const lhlCode = ( ( istart [ 0 ] ) > > 2 ) & 3 ; <nl> + size_t litSize , lhSize ; <nl> + switch ( lhlCode ) <nl> + { <nl> + case 0 : case 2 : default : / * note : default is impossible , since lhlCode into [ 0 . . 3 ] * / <nl> + lhSize = 1 ; <nl> + litSize = istart [ 0 ] > > 3 ; <nl> + break ; <nl> + case 1 : <nl> + lhSize = 2 ; <nl> + litSize = MEM_readLE16 ( istart ) > > 4 ; <nl> + break ; <nl> + case 3 : <nl> + lhSize = 3 ; <nl> + litSize = MEM_readLE24 ( istart ) > > 4 ; <nl> + if ( srcSize < 4 ) return ERROR ( corruption_detected ) ; / * srcSize > = MIN_CBLOCK_SIZE = = 3 ; here we need lhSize + 1 = 4 * / <nl> + break ; <nl> + } <nl> + if ( litSize > ZSTD_BLOCKSIZE_ABSOLUTEMAX ) return ERROR ( corruption_detected ) ; <nl> + memset ( dctx - > litBuffer , istart [ lhSize ] , litSize + WILDCOPY_OVERLENGTH ) ; <nl> + dctx - > litPtr = dctx - > litBuffer ; <nl> + dctx - > litSize = litSize ; <nl> + return lhSize + 1 ; <nl> + } <nl> + default : <nl> + return ERROR ( corruption_detected ) ; / * impossible * / <nl> + } <nl> + } <nl> + } <nl> + <nl> + <nl> + typedef union { <nl> + FSE_decode_t realData ; <nl> + U32 alignedBy4 ; <nl> + } FSE_decode_t4 ; <nl> + <nl> + / * Default FSE distribution table for Literal Lengths * / <nl> + static const FSE_decode_t4 LL_defaultDTable [ ( 1 < < LL_DEFAULTNORMLOG ) + 1 ] = { <nl> + { { LL_DEFAULTNORMLOG , 1 , 1 } } , / * header : tableLog , fastMode , fastMode * / <nl> + / * base , symbol , bits * / <nl> + { { 0 , 0 , 4 } } , { { 16 , 0 , 4 } } , { { 32 , 1 , 5 } } , { { 0 , 3 , 5 } } , <nl> + { { 0 , 4 , 5 } } , { { 0 , 6 , 5 } } , { { 0 , 7 , 5 } } , { { 0 , 9 , 5 } } , <nl> + { { 0 , 10 , 5 } } , { { 0 , 12 , 5 } } , { { 0 , 14 , 6 } } , { { 0 , 16 , 5 } } , <nl> + { { 0 , 18 , 5 } } , { { 0 , 19 , 5 } } , { { 0 , 21 , 5 } } , { { 0 , 22 , 5 } } , <nl> + { { 0 , 24 , 5 } } , { { 32 , 25 , 5 } } , { { 0 , 26 , 5 } } , { { 0 , 27 , 6 } } , <nl> + { { 0 , 29 , 6 } } , { { 0 , 31 , 6 } } , { { 32 , 0 , 4 } } , { { 0 , 1 , 4 } } , <nl> + { { 0 , 2 , 5 } } , { { 32 , 4 , 5 } } , { { 0 , 5 , 5 } } , { { 32 , 7 , 5 } } , <nl> + { { 0 , 8 , 5 } } , { { 32 , 10 , 5 } } , { { 0 , 11 , 5 } } , { { 0 , 13 , 6 } } , <nl> + { { 32 , 16 , 5 } } , { { 0 , 17 , 5 } } , { { 32 , 19 , 5 } } , { { 0 , 20 , 5 } } , <nl> + { { 32 , 22 , 5 } } , { { 0 , 23 , 5 } } , { { 0 , 25 , 4 } } , { { 16 , 25 , 4 } } , <nl> + { { 32 , 26 , 5 } } , { { 0 , 28 , 6 } } , { { 0 , 30 , 6 } } , { { 48 , 0 , 4 } } , <nl> + { { 16 , 1 , 4 } } , { { 32 , 2 , 5 } } , { { 32 , 3 , 5 } } , { { 32 , 5 , 5 } } , <nl> + { { 32 , 6 , 5 } } , { { 32 , 8 , 5 } } , { { 32 , 9 , 5 } } , { { 32 , 11 , 5 } } , <nl> + { { 32 , 12 , 5 } } , { { 0 , 15 , 6 } } , { { 32 , 17 , 5 } } , { { 32 , 18 , 5 } } , <nl> + { { 32 , 20 , 5 } } , { { 32 , 21 , 5 } } , { { 32 , 23 , 5 } } , { { 32 , 24 , 5 } } , <nl> + { { 0 , 35 , 6 } } , { { 0 , 34 , 6 } } , { { 0 , 33 , 6 } } , { { 0 , 32 , 6 } } , <nl> + } ; / * LL_defaultDTable * / <nl> + <nl> + / * Default FSE distribution table for Match Lengths * / <nl> + static const FSE_decode_t4 ML_defaultDTable [ ( 1 < < ML_DEFAULTNORMLOG ) + 1 ] = { <nl> + { { ML_DEFAULTNORMLOG , 1 , 1 } } , / * header : tableLog , fastMode , fastMode * / <nl> + / * base , symbol , bits * / <nl> + { { 0 , 0 , 6 } } , { { 0 , 1 , 4 } } , { { 32 , 2 , 5 } } , { { 0 , 3 , 5 } } , <nl> + { { 0 , 5 , 5 } } , { { 0 , 6 , 5 } } , { { 0 , 8 , 5 } } , { { 0 , 10 , 6 } } , <nl> + { { 0 , 13 , 6 } } , { { 0 , 16 , 6 } } , { { 0 , 19 , 6 } } , { { 0 , 22 , 6 } } , <nl> + { { 0 , 25 , 6 } } , { { 0 , 28 , 6 } } , { { 0 , 31 , 6 } } , { { 0 , 33 , 6 } } , <nl> + { { 0 , 35 , 6 } } , { { 0 , 37 , 6 } } , { { 0 , 39 , 6 } } , { { 0 , 41 , 6 } } , <nl> + { { 0 , 43 , 6 } } , { { 0 , 45 , 6 } } , { { 16 , 1 , 4 } } , { { 0 , 2 , 4 } } , <nl> + { { 32 , 3 , 5 } } , { { 0 , 4 , 5 } } , { { 32 , 6 , 5 } } , { { 0 , 7 , 5 } } , <nl> + { { 0 , 9 , 6 } } , { { 0 , 12 , 6 } } , { { 0 , 15 , 6 } } , { { 0 , 18 , 6 } } , <nl> + { { 0 , 21 , 6 } } , { { 0 , 24 , 6 } } , { { 0 , 27 , 6 } } , { { 0 , 30 , 6 } } , <nl> + { { 0 , 32 , 6 } } , { { 0 , 34 , 6 } } , { { 0 , 36 , 6 } } , { { 0 , 38 , 6 } } , <nl> + { { 0 , 40 , 6 } } , { { 0 , 42 , 6 } } , { { 0 , 44 , 6 } } , { { 32 , 1 , 4 } } , <nl> + { { 48 , 1 , 4 } } , { { 16 , 2 , 4 } } , { { 32 , 4 , 5 } } , { { 32 , 5 , 5 } } , <nl> + { { 32 , 7 , 5 } } , { { 32 , 8 , 5 } } , { { 0 , 11 , 6 } } , { { 0 , 14 , 6 } } , <nl> + { { 0 , 17 , 6 } } , { { 0 , 20 , 6 } } , { { 0 , 23 , 6 } } , { { 0 , 26 , 6 } } , <nl> + { { 0 , 29 , 6 } } , { { 0 , 52 , 6 } } , { { 0 , 51 , 6 } } , { { 0 , 50 , 6 } } , <nl> + { { 0 , 49 , 6 } } , { { 0 , 48 , 6 } } , { { 0 , 47 , 6 } } , { { 0 , 46 , 6 } } , <nl> + } ; / * ML_defaultDTable * / <nl> + <nl> + / * Default FSE distribution table for Offset Codes * / <nl> + static const FSE_decode_t4 OF_defaultDTable [ ( 1 < < OF_DEFAULTNORMLOG ) + 1 ] = { <nl> + { { OF_DEFAULTNORMLOG , 1 , 1 } } , / * header : tableLog , fastMode , fastMode * / <nl> + / * base , symbol , bits * / <nl> + { { 0 , 0 , 5 } } , { { 0 , 6 , 4 } } , <nl> + { { 0 , 9 , 5 } } , { { 0 , 15 , 5 } } , <nl> + { { 0 , 21 , 5 } } , { { 0 , 3 , 5 } } , <nl> + { { 0 , 7 , 4 } } , { { 0 , 12 , 5 } } , <nl> + { { 0 , 18 , 5 } } , { { 0 , 23 , 5 } } , <nl> + { { 0 , 5 , 5 } } , { { 0 , 8 , 4 } } , <nl> + { { 0 , 14 , 5 } } , { { 0 , 20 , 5 } } , <nl> + { { 0 , 2 , 5 } } , { { 16 , 7 , 4 } } , <nl> + { { 0 , 11 , 5 } } , { { 0 , 17 , 5 } } , <nl> + { { 0 , 22 , 5 } } , { { 0 , 4 , 5 } } , <nl> + { { 16 , 8 , 4 } } , { { 0 , 13 , 5 } } , <nl> + { { 0 , 19 , 5 } } , { { 0 , 1 , 5 } } , <nl> + { { 16 , 6 , 4 } } , { { 0 , 10 , 5 } } , <nl> + { { 0 , 16 , 5 } } , { { 0 , 28 , 5 } } , <nl> + { { 0 , 27 , 5 } } , { { 0 , 26 , 5 } } , <nl> + { { 0 , 25 , 5 } } , { { 0 , 24 , 5 } } , <nl> + } ; / * OF_defaultDTable * / <nl> + <nl> + / * ! ZSTD_buildSeqTable ( ) : <nl> + @ return : nb bytes read from src , <nl> + or an error code if it fails , testable with ZSTD_isError ( ) <nl> + * / <nl> + static size_t ZSTD_buildSeqTable ( FSE_DTable * DTableSpace , const FSE_DTable * * DTablePtr , <nl> + symbolEncodingType_e type , U32 max , U32 maxLog , <nl> + const void * src , size_t srcSize , <nl> + const FSE_decode_t4 * defaultTable , U32 flagRepeatTable ) <nl> + { <nl> + const void * const tmpPtr = defaultTable ; / * bypass strict aliasing * / <nl> + switch ( type ) <nl> + { <nl> + case set_rle : <nl> + if ( ! srcSize ) return ERROR ( srcSize_wrong ) ; <nl> + if ( ( * ( const BYTE * ) src ) > max ) return ERROR ( corruption_detected ) ; <nl> + FSE_buildDTable_rle ( DTableSpace , * ( const BYTE * ) src ) ; <nl> + * DTablePtr = DTableSpace ; <nl> + return 1 ; <nl> + case set_basic : <nl> + * DTablePtr = ( const FSE_DTable * ) tmpPtr ; <nl> + return 0 ; <nl> + case set_repeat : <nl> + if ( ! flagRepeatTable ) return ERROR ( corruption_detected ) ; <nl> + return 0 ; <nl> + default : / * impossible * / <nl> + case set_compressed : <nl> + { U32 tableLog ; <nl> + S16 norm [ MaxSeq + 1 ] ; <nl> + size_t const headerSize = FSE_readNCount ( norm , & max , & tableLog , src , srcSize ) ; <nl> + if ( FSE_isError ( headerSize ) ) return ERROR ( corruption_detected ) ; <nl> + if ( tableLog > maxLog ) return ERROR ( corruption_detected ) ; <nl> + FSE_buildDTable ( DTableSpace , norm , max , tableLog ) ; <nl> + * DTablePtr = DTableSpace ; <nl> + return headerSize ; <nl> + } } <nl> + } <nl> + <nl> + size_t ZSTD_decodeSeqHeaders ( ZSTD_DCtx * dctx , int * nbSeqPtr , <nl> + const void * src , size_t srcSize ) <nl> + { <nl> + const BYTE * const istart = ( const BYTE * const ) src ; <nl> + const BYTE * const iend = istart + srcSize ; <nl> + const BYTE * ip = istart ; <nl> + <nl> + / * check * / <nl> + if ( srcSize < MIN_SEQUENCES_SIZE ) return ERROR ( srcSize_wrong ) ; <nl> + <nl> + / * SeqHead * / <nl> + { int nbSeq = * ip + + ; <nl> + if ( ! nbSeq ) { * nbSeqPtr = 0 ; return 1 ; } <nl> + if ( nbSeq > 0x7F ) { <nl> + if ( nbSeq = = 0xFF ) { <nl> + if ( ip + 2 > iend ) return ERROR ( srcSize_wrong ) ; <nl> + nbSeq = MEM_readLE16 ( ip ) + LONGNBSEQ , ip + = 2 ; <nl> + } else { <nl> + if ( ip > = iend ) return ERROR ( srcSize_wrong ) ; <nl> + nbSeq = ( ( nbSeq - 0x80 ) < < 8 ) + * ip + + ; <nl> + } <nl> + } <nl> + * nbSeqPtr = nbSeq ; <nl> + } <nl> + <nl> + / * FSE table descriptors * / <nl> + if ( ip + 4 > iend ) return ERROR ( srcSize_wrong ) ; / * minimum possible size * / <nl> + { symbolEncodingType_e const LLtype = ( symbolEncodingType_e ) ( * ip > > 6 ) ; <nl> + symbolEncodingType_e const OFtype = ( symbolEncodingType_e ) ( ( * ip > > 4 ) & 3 ) ; <nl> + symbolEncodingType_e const MLtype = ( symbolEncodingType_e ) ( ( * ip > > 2 ) & 3 ) ; <nl> + ip + + ; <nl> + <nl> + / * Build DTables * / <nl> + { size_t const llhSize = ZSTD_buildSeqTable ( dctx - > entropy . LLTable , & dctx - > LLTptr , <nl> + LLtype , MaxLL , LLFSELog , <nl> + ip , iend - ip , LL_defaultDTable , dctx - > fseEntropy ) ; <nl> + if ( ZSTD_isError ( llhSize ) ) return ERROR ( corruption_detected ) ; <nl> + ip + = llhSize ; <nl> + } <nl> + { size_t const ofhSize = ZSTD_buildSeqTable ( dctx - > entropy . OFTable , & dctx - > OFTptr , <nl> + OFtype , MaxOff , OffFSELog , <nl> + ip , iend - ip , OF_defaultDTable , dctx - > fseEntropy ) ; <nl> + if ( ZSTD_isError ( ofhSize ) ) return ERROR ( corruption_detected ) ; <nl> + ip + = ofhSize ; <nl> + } <nl> + { size_t const mlhSize = ZSTD_buildSeqTable ( dctx - > entropy . MLTable , & dctx - > MLTptr , <nl> + MLtype , MaxML , MLFSELog , <nl> + ip , iend - ip , ML_defaultDTable , dctx - > fseEntropy ) ; <nl> + if ( ZSTD_isError ( mlhSize ) ) return ERROR ( corruption_detected ) ; <nl> + ip + = mlhSize ; <nl> + } <nl> + } <nl> + <nl> + return ip - istart ; <nl> + } <nl> + <nl> + <nl> + typedef struct { <nl> + size_t litLength ; <nl> + size_t matchLength ; <nl> + size_t offset ; <nl> + const BYTE * match ; <nl> + } seq_t ; <nl> + <nl> + typedef struct { <nl> + BIT_DStream_t DStream ; <nl> + FSE_DState_t stateLL ; <nl> + FSE_DState_t stateOffb ; <nl> + FSE_DState_t stateML ; <nl> + size_t prevOffset [ ZSTD_REP_NUM ] ; <nl> + const BYTE * base ; <nl> + size_t pos ; <nl> + uPtrDiff gotoDict ; <nl> + } seqState_t ; <nl> + <nl> + <nl> + FORCE_NOINLINE <nl> + size_t ZSTD_execSequenceLast7 ( BYTE * op , <nl> + BYTE * const oend , seq_t sequence , <nl> + const BYTE * * litPtr , const BYTE * const litLimit , <nl> + const BYTE * const base , const BYTE * const vBase , const BYTE * const dictEnd ) <nl> + { <nl> + BYTE * const oLitEnd = op + sequence . litLength ; <nl> + size_t const sequenceLength = sequence . litLength + sequence . matchLength ; <nl> + BYTE * const oMatchEnd = op + sequenceLength ; / * risk : address space overflow ( 32 - bits ) * / <nl> + BYTE * const oend_w = oend - WILDCOPY_OVERLENGTH ; <nl> + const BYTE * const iLitEnd = * litPtr + sequence . litLength ; <nl> + const BYTE * match = oLitEnd - sequence . offset ; <nl> + <nl> + / * check * / <nl> + if ( oMatchEnd > oend ) return ERROR ( dstSize_tooSmall ) ; / * last match must start at a minimum distance of WILDCOPY_OVERLENGTH from oend * / <nl> + if ( iLitEnd > litLimit ) return ERROR ( corruption_detected ) ; / * over - read beyond lit buffer * / <nl> + if ( oLitEnd < = oend_w ) return ERROR ( GENERIC ) ; / * Precondition * / <nl> + <nl> + / * copy literals * / <nl> + if ( op < oend_w ) { <nl> + ZSTD_wildcopy ( op , * litPtr , oend_w - op ) ; <nl> + * litPtr + = oend_w - op ; <nl> + op = oend_w ; <nl> + } <nl> + while ( op < oLitEnd ) * op + + = * ( * litPtr ) + + ; <nl> + <nl> + / * copy Match * / <nl> + if ( sequence . offset > ( size_t ) ( oLitEnd - base ) ) { <nl> + / * offset beyond prefix * / <nl> + if ( sequence . offset > ( size_t ) ( oLitEnd - vBase ) ) return ERROR ( corruption_detected ) ; <nl> + match = dictEnd - ( base - match ) ; <nl> + if ( match + sequence . matchLength < = dictEnd ) { <nl> + memmove ( oLitEnd , match , sequence . matchLength ) ; <nl> + return sequenceLength ; <nl> + } <nl> + / * span extDict & currentPrefixSegment * / <nl> + { size_t const length1 = dictEnd - match ; <nl> + memmove ( oLitEnd , match , length1 ) ; <nl> + op = oLitEnd + length1 ; <nl> + sequence . matchLength - = length1 ; <nl> + match = base ; <nl> + } } <nl> + while ( op < oMatchEnd ) * op + + = * match + + ; <nl> + return sequenceLength ; <nl> + } <nl> + <nl> + <nl> + static seq_t ZSTD_decodeSequence ( seqState_t * seqState ) <nl> + { <nl> + seq_t seq ; <nl> + <nl> + U32 const llCode = FSE_peekSymbol ( & seqState - > stateLL ) ; <nl> + U32 const mlCode = FSE_peekSymbol ( & seqState - > stateML ) ; <nl> + U32 const ofCode = FSE_peekSymbol ( & seqState - > stateOffb ) ; / * < = maxOff , by table construction * / <nl> + <nl> + U32 const llBits = LL_bits [ llCode ] ; <nl> + U32 const mlBits = ML_bits [ mlCode ] ; <nl> + U32 const ofBits = ofCode ; <nl> + U32 const totalBits = llBits + mlBits + ofBits ; <nl> + <nl> + static const U32 LL_base [ MaxLL + 1 ] = { <nl> + 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , <nl> + 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , <nl> + 16 , 18 , 20 , 22 , 24 , 28 , 32 , 40 , <nl> + 48 , 64 , 0x80 , 0x100 , 0x200 , 0x400 , 0x800 , 0x1000 , <nl> + 0x2000 , 0x4000 , 0x8000 , 0x10000 } ; <nl> + <nl> + static const U32 ML_base [ MaxML + 1 ] = { <nl> + 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , <nl> + 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , <nl> + 19 , 20 , 21 , 22 , 23 , 24 , 25 , 26 , <nl> + 27 , 28 , 29 , 30 , 31 , 32 , 33 , 34 , <nl> + 35 , 37 , 39 , 41 , 43 , 47 , 51 , 59 , <nl> + 67 , 83 , 99 , 0x83 , 0x103 , 0x203 , 0x403 , 0x803 , <nl> + 0x1003 , 0x2003 , 0x4003 , 0x8003 , 0x10003 } ; <nl> + <nl> + static const U32 OF_base [ MaxOff + 1 ] = { <nl> + 0 , 1 , 1 , 5 , 0xD , 0x1D , 0x3D , 0x7D , <nl> + 0xFD , 0x1FD , 0x3FD , 0x7FD , 0xFFD , 0x1FFD , 0x3FFD , 0x7FFD , <nl> + 0xFFFD , 0x1FFFD , 0x3FFFD , 0x7FFFD , 0xFFFFD , 0x1FFFFD , 0x3FFFFD , 0x7FFFFD , <nl> + 0xFFFFFD , 0x1FFFFFD , 0x3FFFFFD , 0x7FFFFFD , 0xFFFFFFD } ; <nl> + <nl> + / * sequence * / <nl> + { size_t offset ; <nl> + if ( ! ofCode ) <nl> + offset = 0 ; <nl> + else { <nl> + offset = OF_base [ ofCode ] + BIT_readBitsFast ( & seqState - > DStream , ofBits ) ; / * < = ( ZSTD_WINDOWLOG_MAX - 1 ) bits * / <nl> + if ( MEM_32bits ( ) ) BIT_reloadDStream ( & seqState - > DStream ) ; <nl> + } <nl> + <nl> + if ( ofCode < = 1 ) { <nl> + offset + = ( llCode = = 0 ) ; <nl> + if ( offset ) { <nl> + size_t temp = ( offset = = 3 ) ? seqState - > prevOffset [ 0 ] - 1 : seqState - > prevOffset [ offset ] ; <nl> + temp + = ! temp ; / * 0 is not valid ; input is corrupted ; force offset to 1 * / <nl> + if ( offset ! = 1 ) seqState - > prevOffset [ 2 ] = seqState - > prevOffset [ 1 ] ; <nl> + seqState - > prevOffset [ 1 ] = seqState - > prevOffset [ 0 ] ; <nl> + seqState - > prevOffset [ 0 ] = offset = temp ; <nl> + } else { <nl> + offset = seqState - > prevOffset [ 0 ] ; <nl> + } <nl> + } else { <nl> + seqState - > prevOffset [ 2 ] = seqState - > prevOffset [ 1 ] ; <nl> + seqState - > prevOffset [ 1 ] = seqState - > prevOffset [ 0 ] ; <nl> + seqState - > prevOffset [ 0 ] = offset ; <nl> + } <nl> + seq . offset = offset ; <nl> + } <nl> + <nl> + seq . matchLength = ML_base [ mlCode ] + ( ( mlCode > 31 ) ? BIT_readBitsFast ( & seqState - > DStream , mlBits ) : 0 ) ; / * < = 16 bits * / <nl> + if ( MEM_32bits ( ) & & ( mlBits + llBits > 24 ) ) BIT_reloadDStream ( & seqState - > DStream ) ; <nl> + <nl> + seq . litLength = LL_base [ llCode ] + ( ( llCode > 15 ) ? BIT_readBitsFast ( & seqState - > DStream , llBits ) : 0 ) ; / * < = 16 bits * / <nl> + if ( MEM_32bits ( ) | | <nl> + ( totalBits > 64 - 7 - ( LLFSELog + MLFSELog + OffFSELog ) ) ) BIT_reloadDStream ( & seqState - > DStream ) ; <nl> + <nl> + / * ANS state update * / <nl> + FSE_updateState ( & seqState - > stateLL , & seqState - > DStream ) ; / * < = 9 bits * / <nl> + FSE_updateState ( & seqState - > stateML , & seqState - > DStream ) ; / * < = 9 bits * / <nl> + if ( MEM_32bits ( ) ) BIT_reloadDStream ( & seqState - > DStream ) ; / * < = 18 bits * / <nl> + FSE_updateState ( & seqState - > stateOffb , & seqState - > DStream ) ; / * < = 8 bits * / <nl> + <nl> + return seq ; <nl> + } <nl> + <nl> + <nl> + FORCE_INLINE <nl> + size_t ZSTD_execSequence ( BYTE * op , <nl> + BYTE * const oend , seq_t sequence , <nl> + const BYTE * * litPtr , const BYTE * const litLimit , <nl> + const BYTE * const base , const BYTE * const vBase , const BYTE * const dictEnd ) <nl> + { <nl> + BYTE * const oLitEnd = op + sequence . litLength ; <nl> + size_t const sequenceLength = sequence . litLength + sequence . matchLength ; <nl> + BYTE * const oMatchEnd = op + sequenceLength ; / * risk : address space overflow ( 32 - bits ) * / <nl> + BYTE * const oend_w = oend - WILDCOPY_OVERLENGTH ; <nl> + const BYTE * const iLitEnd = * litPtr + sequence . litLength ; <nl> + const BYTE * match = oLitEnd - sequence . offset ; <nl> + <nl> + / * check * / <nl> + if ( oMatchEnd > oend ) return ERROR ( dstSize_tooSmall ) ; / * last match must start at a minimum distance of WILDCOPY_OVERLENGTH from oend * / <nl> + if ( iLitEnd > litLimit ) return ERROR ( corruption_detected ) ; / * over - read beyond lit buffer * / <nl> + if ( oLitEnd > oend_w ) return ZSTD_execSequenceLast7 ( op , oend , sequence , litPtr , litLimit , base , vBase , dictEnd ) ; <nl> + <nl> + / * copy Literals * / <nl> + ZSTD_copy8 ( op , * litPtr ) ; <nl> + if ( sequence . litLength > 8 ) <nl> + ZSTD_wildcopy ( op + 8 , ( * litPtr ) + 8 , sequence . litLength - 8 ) ; / * note : since oLitEnd < = oend - WILDCOPY_OVERLENGTH , no risk of overwrite beyond oend * / <nl> + op = oLitEnd ; <nl> + * litPtr = iLitEnd ; / * update for next sequence * / <nl> + <nl> + / * copy Match * / <nl> + if ( sequence . offset > ( size_t ) ( oLitEnd - base ) ) { <nl> + / * offset beyond prefix - > go into extDict * / <nl> + if ( sequence . offset > ( size_t ) ( oLitEnd - vBase ) ) return ERROR ( corruption_detected ) ; <nl> + match = dictEnd + ( match - base ) ; <nl> + if ( match + sequence . matchLength < = dictEnd ) { <nl> + memmove ( oLitEnd , match , sequence . matchLength ) ; <nl> + return sequenceLength ; <nl> + } <nl> + / * span extDict & currentPrefixSegment * / <nl> + { size_t const length1 = dictEnd - match ; <nl> + memmove ( oLitEnd , match , length1 ) ; <nl> + op = oLitEnd + length1 ; <nl> + sequence . matchLength - = length1 ; <nl> + match = base ; <nl> + if ( op > oend_w | | sequence . matchLength < MINMATCH ) { <nl> + U32 i ; <nl> + for ( i = 0 ; i < sequence . matchLength ; + + i ) op [ i ] = match [ i ] ; <nl> + return sequenceLength ; <nl> + } <nl> + } } <nl> + / * Requirement : op < = oend_w & & sequence . matchLength > = MINMATCH * / <nl> + <nl> + / * match within prefix * / <nl> + if ( sequence . offset < 8 ) { <nl> + / * close range match , overlap * / <nl> + static const U32 dec32table [ ] = { 0 , 1 , 2 , 1 , 4 , 4 , 4 , 4 } ; / * added * / <nl> + static const int dec64table [ ] = { 8 , 8 , 8 , 7 , 8 , 9 , 10 , 11 } ; / * subtracted * / <nl> + int const sub2 = dec64table [ sequence . offset ] ; <nl> + op [ 0 ] = match [ 0 ] ; <nl> + op [ 1 ] = match [ 1 ] ; <nl> + op [ 2 ] = match [ 2 ] ; <nl> + op [ 3 ] = match [ 3 ] ; <nl> + match + = dec32table [ sequence . offset ] ; <nl> + ZSTD_copy4 ( op + 4 , match ) ; <nl> + match - = sub2 ; <nl> + } else { <nl> + ZSTD_copy8 ( op , match ) ; <nl> + } <nl> + op + = 8 ; match + = 8 ; <nl> + <nl> + if ( oMatchEnd > oend - ( 16 - MINMATCH ) ) { <nl> + if ( op < oend_w ) { <nl> + ZSTD_wildcopy ( op , match , oend_w - op ) ; <nl> + match + = oend_w - op ; <nl> + op = oend_w ; <nl> + } <nl> + while ( op < oMatchEnd ) * op + + = * match + + ; <nl> + } else { <nl> + ZSTD_wildcopy ( op , match , ( ptrdiff_t ) sequence . matchLength - 8 ) ; / * works even if matchLength < 8 * / <nl> + } <nl> + return sequenceLength ; <nl> + } <nl> + <nl> + <nl> + static size_t ZSTD_decompressSequences ( <nl> + ZSTD_DCtx * dctx , <nl> + void * dst , size_t maxDstSize , <nl> + const void * seqStart , size_t seqSize ) <nl> + { <nl> + const BYTE * ip = ( const BYTE * ) seqStart ; <nl> + const BYTE * const iend = ip + seqSize ; <nl> + BYTE * const ostart = ( BYTE * const ) dst ; <nl> + BYTE * const oend = ostart + maxDstSize ; <nl> + BYTE * op = ostart ; <nl> + const BYTE * litPtr = dctx - > litPtr ; <nl> + const BYTE * const litEnd = litPtr + dctx - > litSize ; <nl> + const BYTE * const base = ( const BYTE * ) ( dctx - > base ) ; <nl> + const BYTE * const vBase = ( const BYTE * ) ( dctx - > vBase ) ; <nl> + const BYTE * const dictEnd = ( const BYTE * ) ( dctx - > dictEnd ) ; <nl> + int nbSeq ; <nl> + <nl> + / * Build Decoding Tables * / <nl> + { size_t const seqHSize = ZSTD_decodeSeqHeaders ( dctx , & nbSeq , ip , seqSize ) ; <nl> + if ( ZSTD_isError ( seqHSize ) ) return seqHSize ; <nl> + ip + = seqHSize ; <nl> + } <nl> + <nl> + / * Regen sequences * / <nl> + if ( nbSeq ) { <nl> + seqState_t seqState ; <nl> + dctx - > fseEntropy = 1 ; <nl> + { U32 i ; for ( i = 0 ; i < ZSTD_REP_NUM ; i + + ) seqState . prevOffset [ i ] = dctx - > entropy . rep [ i ] ; } <nl> + CHECK_E ( BIT_initDStream ( & seqState . DStream , ip , iend - ip ) , corruption_detected ) ; <nl> + FSE_initDState ( & seqState . stateLL , & seqState . DStream , dctx - > LLTptr ) ; <nl> + FSE_initDState ( & seqState . stateOffb , & seqState . DStream , dctx - > OFTptr ) ; <nl> + FSE_initDState ( & seqState . stateML , & seqState . DStream , dctx - > MLTptr ) ; <nl> + <nl> + for ( ; ( BIT_reloadDStream ( & ( seqState . DStream ) ) < = BIT_DStream_completed ) & & nbSeq ; ) { <nl> + nbSeq - - ; <nl> + { seq_t const sequence = ZSTD_decodeSequence ( & seqState ) ; <nl> + size_t const oneSeqSize = ZSTD_execSequence ( op , oend , sequence , & litPtr , litEnd , base , vBase , dictEnd ) ; <nl> + if ( ZSTD_isError ( oneSeqSize ) ) return oneSeqSize ; <nl> + op + = oneSeqSize ; <nl> + } } <nl> + <nl> + / * check if reached exact end * / <nl> + if ( nbSeq ) return ERROR ( corruption_detected ) ; <nl> + / * save reps for next block * / <nl> + { U32 i ; for ( i = 0 ; i < ZSTD_REP_NUM ; i + + ) dctx - > entropy . rep [ i ] = ( U32 ) ( seqState . prevOffset [ i ] ) ; } <nl> + } <nl> + <nl> + / * last literal segment * / <nl> + { size_t const lastLLSize = litEnd - litPtr ; <nl> + if ( lastLLSize > ( size_t ) ( oend - op ) ) return ERROR ( dstSize_tooSmall ) ; <nl> + memcpy ( op , litPtr , lastLLSize ) ; <nl> + op + = lastLLSize ; <nl> + } <nl> + <nl> + return op - ostart ; <nl> + } <nl> + <nl> + <nl> + FORCE_INLINE seq_t ZSTD_decodeSequenceLong_generic ( seqState_t * seqState , int const longOffsets ) <nl> + { <nl> + seq_t seq ; <nl> + <nl> + U32 const llCode = FSE_peekSymbol ( & seqState - > stateLL ) ; <nl> + U32 const mlCode = FSE_peekSymbol ( & seqState - > stateML ) ; <nl> + U32 const ofCode = FSE_peekSymbol ( & seqState - > stateOffb ) ; / * < = maxOff , by table construction * / <nl> + <nl> + U32 const llBits = LL_bits [ llCode ] ; <nl> + U32 const mlBits = ML_bits [ mlCode ] ; <nl> + U32 const ofBits = ofCode ; <nl> + U32 const totalBits = llBits + mlBits + ofBits ; <nl> + <nl> + static const U32 LL_base [ MaxLL + 1 ] = { <nl> + 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , <nl> + 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , <nl> + 16 , 18 , 20 , 22 , 24 , 28 , 32 , 40 , <nl> + 48 , 64 , 0x80 , 0x100 , 0x200 , 0x400 , 0x800 , 0x1000 , <nl> + 0x2000 , 0x4000 , 0x8000 , 0x10000 } ; <nl> + <nl> + static const U32 ML_base [ MaxML + 1 ] = { <nl> + 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , <nl> + 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , <nl> + 19 , 20 , 21 , 22 , 23 , 24 , 25 , 26 , <nl> + 27 , 28 , 29 , 30 , 31 , 32 , 33 , 34 , <nl> + 35 , 37 , 39 , 41 , 43 , 47 , 51 , 59 , <nl> + 67 , 83 , 99 , 0x83 , 0x103 , 0x203 , 0x403 , 0x803 , <nl> + 0x1003 , 0x2003 , 0x4003 , 0x8003 , 0x10003 } ; <nl> + <nl> + static const U32 OF_base [ MaxOff + 1 ] = { <nl> + 0 , 1 , 1 , 5 , 0xD , 0x1D , 0x3D , 0x7D , <nl> + 0xFD , 0x1FD , 0x3FD , 0x7FD , 0xFFD , 0x1FFD , 0x3FFD , 0x7FFD , <nl> + 0xFFFD , 0x1FFFD , 0x3FFFD , 0x7FFFD , 0xFFFFD , 0x1FFFFD , 0x3FFFFD , 0x7FFFFD , <nl> + 0xFFFFFD , 0x1FFFFFD , 0x3FFFFFD , 0x7FFFFFD , 0xFFFFFFD } ; <nl> + <nl> + / * sequence * / <nl> + { size_t offset ; <nl> + if ( ! ofCode ) <nl> + offset = 0 ; <nl> + else { <nl> + if ( longOffsets ) { <nl> + int const extraBits = ofBits - MIN ( ofBits , STREAM_ACCUMULATOR_MIN ) ; <nl> + offset = OF_base [ ofCode ] + ( BIT_readBitsFast ( & seqState - > DStream , ofBits - extraBits ) < < extraBits ) ; <nl> + if ( MEM_32bits ( ) | | extraBits ) BIT_reloadDStream ( & seqState - > DStream ) ; <nl> + if ( extraBits ) offset + = BIT_readBitsFast ( & seqState - > DStream , extraBits ) ; <nl> + } else { <nl> + offset = OF_base [ ofCode ] + BIT_readBitsFast ( & seqState - > DStream , ofBits ) ; / * < = ( ZSTD_WINDOWLOG_MAX - 1 ) bits * / <nl> + if ( MEM_32bits ( ) ) BIT_reloadDStream ( & seqState - > DStream ) ; <nl> + } <nl> + } <nl> + <nl> + if ( ofCode < = 1 ) { <nl> + offset + = ( llCode = = 0 ) ; <nl> + if ( offset ) { <nl> + size_t temp = ( offset = = 3 ) ? seqState - > prevOffset [ 0 ] - 1 : seqState - > prevOffset [ offset ] ; <nl> + temp + = ! temp ; / * 0 is not valid ; input is corrupted ; force offset to 1 * / <nl> + if ( offset ! = 1 ) seqState - > prevOffset [ 2 ] = seqState - > prevOffset [ 1 ] ; <nl> + seqState - > prevOffset [ 1 ] = seqState - > prevOffset [ 0 ] ; <nl> + seqState - > prevOffset [ 0 ] = offset = temp ; <nl> + } else { <nl> + offset = seqState - > prevOffset [ 0 ] ; <nl> + } <nl> + } else { <nl> + seqState - > prevOffset [ 2 ] = seqState - > prevOffset [ 1 ] ; <nl> + seqState - > prevOffset [ 1 ] = seqState - > prevOffset [ 0 ] ; <nl> + seqState - > prevOffset [ 0 ] = offset ; <nl> + } <nl> + seq . offset = offset ; <nl> + } <nl> + <nl> + seq . matchLength = ML_base [ mlCode ] + ( ( mlCode > 31 ) ? BIT_readBitsFast ( & seqState - > DStream , mlBits ) : 0 ) ; / * < = 16 bits * / <nl> + if ( MEM_32bits ( ) & & ( mlBits + llBits > 24 ) ) BIT_reloadDStream ( & seqState - > DStream ) ; <nl> + <nl> + seq . litLength = LL_base [ llCode ] + ( ( llCode > 15 ) ? BIT_readBitsFast ( & seqState - > DStream , llBits ) : 0 ) ; / * < = 16 bits * / <nl> + if ( MEM_32bits ( ) | | <nl> + ( totalBits > 64 - 7 - ( LLFSELog + MLFSELog + OffFSELog ) ) ) BIT_reloadDStream ( & seqState - > DStream ) ; <nl> + <nl> + { size_t const pos = seqState - > pos + seq . litLength ; <nl> + seq . match = seqState - > base + pos - seq . offset ; / * single memory segment * / <nl> + if ( seq . offset > pos ) seq . match + = seqState - > gotoDict ; / * separate memory segment * / <nl> + seqState - > pos = pos + seq . matchLength ; <nl> + } <nl> + <nl> + / * ANS state update * / <nl> + FSE_updateState ( & seqState - > stateLL , & seqState - > DStream ) ; / * < = 9 bits * / <nl> + FSE_updateState ( & seqState - > stateML , & seqState - > DStream ) ; / * < = 9 bits * / <nl> + if ( MEM_32bits ( ) ) BIT_reloadDStream ( & seqState - > DStream ) ; / * < = 18 bits * / <nl> + FSE_updateState ( & seqState - > stateOffb , & seqState - > DStream ) ; / * < = 8 bits * / <nl> + <nl> + return seq ; <nl> + } <nl> + <nl> + static seq_t ZSTD_decodeSequenceLong ( seqState_t * seqState , unsigned const windowSize ) { <nl> + if ( ZSTD_highbit32 ( windowSize ) > STREAM_ACCUMULATOR_MIN ) { <nl> + return ZSTD_decodeSequenceLong_generic ( seqState , 1 ) ; <nl> + } else { <nl> + return ZSTD_decodeSequenceLong_generic ( seqState , 0 ) ; <nl> + } <nl> + } <nl> + <nl> + FORCE_INLINE <nl> + size_t ZSTD_execSequenceLong ( BYTE * op , <nl> + BYTE * const oend , seq_t sequence , <nl> + const BYTE * * litPtr , const BYTE * const litLimit , <nl> + const BYTE * const base , const BYTE * const vBase , const BYTE * const dictEnd ) <nl> + { <nl> + BYTE * const oLitEnd = op + sequence . litLength ; <nl> + size_t const sequenceLength = sequence . litLength + sequence . matchLength ; <nl> + BYTE * const oMatchEnd = op + sequenceLength ; / * risk : address space overflow ( 32 - bits ) * / <nl> + BYTE * const oend_w = oend - WILDCOPY_OVERLENGTH ; <nl> + const BYTE * const iLitEnd = * litPtr + sequence . litLength ; <nl> + const BYTE * match = sequence . match ; <nl> + <nl> + / * check * / <nl> + # if 1 <nl> + if ( oMatchEnd > oend ) return ERROR ( dstSize_tooSmall ) ; / * last match must start at a minimum distance of WILDCOPY_OVERLENGTH from oend * / <nl> + if ( iLitEnd > litLimit ) return ERROR ( corruption_detected ) ; / * over - read beyond lit buffer * / <nl> + if ( oLitEnd > oend_w ) return ZSTD_execSequenceLast7 ( op , oend , sequence , litPtr , litLimit , base , vBase , dictEnd ) ; <nl> + # endif <nl> + <nl> + / * copy Literals * / <nl> + ZSTD_copy8 ( op , * litPtr ) ; <nl> + if ( sequence . litLength > 8 ) <nl> + ZSTD_wildcopy ( op + 8 , ( * litPtr ) + 8 , sequence . litLength - 8 ) ; / * note : since oLitEnd < = oend - WILDCOPY_OVERLENGTH , no risk of overwrite beyond oend * / <nl> + op = oLitEnd ; <nl> + * litPtr = iLitEnd ; / * update for next sequence * / <nl> + <nl> + / * copy Match * / <nl> + # if 1 <nl> + if ( sequence . offset > ( size_t ) ( oLitEnd - base ) ) { <nl> + / * offset beyond prefix * / <nl> + if ( sequence . offset > ( size_t ) ( oLitEnd - vBase ) ) return ERROR ( corruption_detected ) ; <nl> + if ( match + sequence . matchLength < = dictEnd ) { <nl> + memmove ( oLitEnd , match , sequence . matchLength ) ; <nl> + return sequenceLength ; <nl> + } <nl> + / * span extDict & currentPrefixSegment * / <nl> + { size_t const length1 = dictEnd - match ; <nl> + memmove ( oLitEnd , match , length1 ) ; <nl> + op = oLitEnd + length1 ; <nl> + sequence . matchLength - = length1 ; <nl> + match = base ; <nl> + if ( op > oend_w | | sequence . matchLength < MINMATCH ) { <nl> + U32 i ; <nl> + for ( i = 0 ; i < sequence . matchLength ; + + i ) op [ i ] = match [ i ] ; <nl> + return sequenceLength ; <nl> + } <nl> + } } <nl> + / * Requirement : op < = oend_w & & sequence . matchLength > = MINMATCH * / <nl> + # endif <nl> + <nl> + / * match within prefix * / <nl> + if ( sequence . offset < 8 ) { <nl> + / * close range match , overlap * / <nl> + static const U32 dec32table [ ] = { 0 , 1 , 2 , 1 , 4 , 4 , 4 , 4 } ; / * added * / <nl> + static const int dec64table [ ] = { 8 , 8 , 8 , 7 , 8 , 9 , 10 , 11 } ; / * subtracted * / <nl> + int const sub2 = dec64table [ sequence . offset ] ; <nl> + op [ 0 ] = match [ 0 ] ; <nl> + op [ 1 ] = match [ 1 ] ; <nl> + op [ 2 ] = match [ 2 ] ; <nl> + op [ 3 ] = match [ 3 ] ; <nl> + match + = dec32table [ sequence . offset ] ; <nl> + ZSTD_copy4 ( op + 4 , match ) ; <nl> + match - = sub2 ; <nl> + } else { <nl> + ZSTD_copy8 ( op , match ) ; <nl> + } <nl> + op + = 8 ; match + = 8 ; <nl> + <nl> + if ( oMatchEnd > oend - ( 16 - MINMATCH ) ) { <nl> + if ( op < oend_w ) { <nl> + ZSTD_wildcopy ( op , match , oend_w - op ) ; <nl> + match + = oend_w - op ; <nl> + op = oend_w ; <nl> + } <nl> + while ( op < oMatchEnd ) * op + + = * match + + ; <nl> + } else { <nl> + ZSTD_wildcopy ( op , match , ( ptrdiff_t ) sequence . matchLength - 8 ) ; / * works even if matchLength < 8 * / <nl> + } <nl> + return sequenceLength ; <nl> + } <nl> + <nl> + static size_t ZSTD_decompressSequencesLong ( <nl> + ZSTD_DCtx * dctx , <nl> + void * dst , size_t maxDstSize , <nl> + const void * seqStart , size_t seqSize ) <nl> + { <nl> + const BYTE * ip = ( const BYTE * ) seqStart ; <nl> + const BYTE * const iend = ip + seqSize ; <nl> + BYTE * const ostart = ( BYTE * const ) dst ; <nl> + BYTE * const oend = ostart + maxDstSize ; <nl> + BYTE * op = ostart ; <nl> + const BYTE * litPtr = dctx - > litPtr ; <nl> + const BYTE * const litEnd = litPtr + dctx - > litSize ; <nl> + const BYTE * const base = ( const BYTE * ) ( dctx - > base ) ; <nl> + const BYTE * const vBase = ( const BYTE * ) ( dctx - > vBase ) ; <nl> + const BYTE * const dictEnd = ( const BYTE * ) ( dctx - > dictEnd ) ; <nl> + unsigned const windowSize = dctx - > fParams . windowSize ; <nl> + int nbSeq ; <nl> + <nl> + / * Build Decoding Tables * / <nl> + { size_t const seqHSize = ZSTD_decodeSeqHeaders ( dctx , & nbSeq , ip , seqSize ) ; <nl> + if ( ZSTD_isError ( seqHSize ) ) return seqHSize ; <nl> + ip + = seqHSize ; <nl> + } <nl> + <nl> + / * Regen sequences * / <nl> + if ( nbSeq ) { <nl> + # define STORED_SEQS 4 <nl> + # define STOSEQ_MASK ( STORED_SEQS - 1 ) <nl> + # define ADVANCED_SEQS 4 <nl> + seq_t sequences [ STORED_SEQS ] ; <nl> + int const seqAdvance = MIN ( nbSeq , ADVANCED_SEQS ) ; <nl> + seqState_t seqState ; <nl> + int seqNb ; <nl> + dctx - > fseEntropy = 1 ; <nl> + { U32 i ; for ( i = 0 ; i < ZSTD_REP_NUM ; i + + ) seqState . prevOffset [ i ] = dctx - > entropy . rep [ i ] ; } <nl> + seqState . base = base ; <nl> + seqState . pos = ( size_t ) ( op - base ) ; <nl> + seqState . gotoDict = ( uPtrDiff ) dictEnd - ( uPtrDiff ) base ; / * cast to avoid undefined behaviour * / <nl> + CHECK_E ( BIT_initDStream ( & seqState . DStream , ip , iend - ip ) , corruption_detected ) ; <nl> + FSE_initDState ( & seqState . stateLL , & seqState . DStream , dctx - > LLTptr ) ; <nl> + FSE_initDState ( & seqState . stateOffb , & seqState . DStream , dctx - > OFTptr ) ; <nl> + FSE_initDState ( & seqState . stateML , & seqState . DStream , dctx - > MLTptr ) ; <nl> + <nl> + / * prepare in advance * / <nl> + for ( seqNb = 0 ; ( BIT_reloadDStream ( & seqState . DStream ) < = BIT_DStream_completed ) & & seqNb < seqAdvance ; seqNb + + ) { <nl> + sequences [ seqNb ] = ZSTD_decodeSequenceLong ( & seqState , windowSize ) ; <nl> + } <nl> + if ( seqNb < seqAdvance ) return ERROR ( corruption_detected ) ; <nl> + <nl> + / * decode and decompress * / <nl> + for ( ; ( BIT_reloadDStream ( & ( seqState . DStream ) ) < = BIT_DStream_completed ) & & seqNb < nbSeq ; seqNb + + ) { <nl> + seq_t const sequence = ZSTD_decodeSequenceLong ( & seqState , windowSize ) ; <nl> + size_t const oneSeqSize = ZSTD_execSequenceLong ( op , oend , sequences [ ( seqNb - ADVANCED_SEQS ) & STOSEQ_MASK ] , & litPtr , litEnd , base , vBase , dictEnd ) ; <nl> + if ( ZSTD_isError ( oneSeqSize ) ) return oneSeqSize ; <nl> + ZSTD_PREFETCH ( sequence . match ) ; <nl> + sequences [ seqNb & STOSEQ_MASK ] = sequence ; <nl> + op + = oneSeqSize ; <nl> + } <nl> + if ( seqNb < nbSeq ) return ERROR ( corruption_detected ) ; <nl> + <nl> + / * finish queue * / <nl> + seqNb - = seqAdvance ; <nl> + for ( ; seqNb < nbSeq ; seqNb + + ) { <nl> + size_t const oneSeqSize = ZSTD_execSequenceLong ( op , oend , sequences [ seqNb & STOSEQ_MASK ] , & litPtr , litEnd , base , vBase , dictEnd ) ; <nl> + if ( ZSTD_isError ( oneSeqSize ) ) return oneSeqSize ; <nl> + op + = oneSeqSize ; <nl> + } <nl> + <nl> + / * save reps for next block * / <nl> + { U32 i ; for ( i = 0 ; i < ZSTD_REP_NUM ; i + + ) dctx - > entropy . rep [ i ] = ( U32 ) ( seqState . prevOffset [ i ] ) ; } <nl> + } <nl> + <nl> + / * last literal segment * / <nl> + { size_t const lastLLSize = litEnd - litPtr ; <nl> + if ( lastLLSize > ( size_t ) ( oend - op ) ) return ERROR ( dstSize_tooSmall ) ; <nl> + memcpy ( op , litPtr , lastLLSize ) ; <nl> + op + = lastLLSize ; <nl> + } <nl> + <nl> + return op - ostart ; <nl> + } <nl> + <nl> + <nl> + static size_t ZSTD_decompressBlock_internal ( ZSTD_DCtx * dctx , <nl> + void * dst , size_t dstCapacity , <nl> + const void * src , size_t srcSize ) <nl> + { / * blockType = = blockCompressed * / <nl> + const BYTE * ip = ( const BYTE * ) src ; <nl> + <nl> + if ( srcSize > = ZSTD_BLOCKSIZE_ABSOLUTEMAX ) return ERROR ( srcSize_wrong ) ; <nl> + <nl> + / * Decode literals section * / <nl> + { size_t const litCSize = ZSTD_decodeLiteralsBlock ( dctx , src , srcSize ) ; <nl> + if ( ZSTD_isError ( litCSize ) ) return litCSize ; <nl> + ip + = litCSize ; <nl> + srcSize - = litCSize ; <nl> + } <nl> + if ( sizeof ( size_t ) > 4 ) / * do not enable prefetching on 32 - bits x86 , as it ' s performance detrimental * / <nl> + / * likely because of register pressure * / <nl> + / * if that ' s the correct cause , then 32 - bits ARM should be affected differently * / <nl> + / * it would be good to test this on ARM real hardware , to see if prefetch version improves speed * / <nl> + if ( dctx - > fParams . windowSize > ( 1 < < 23 ) ) <nl> + return ZSTD_decompressSequencesLong ( dctx , dst , dstCapacity , ip , srcSize ) ; <nl> + return ZSTD_decompressSequences ( dctx , dst , dstCapacity , ip , srcSize ) ; <nl> + } <nl> + <nl> + <nl> + static void ZSTD_checkContinuity ( ZSTD_DCtx * dctx , const void * dst ) <nl> + { <nl> + if ( dst ! = dctx - > previousDstEnd ) { / * not contiguous * / <nl> + dctx - > dictEnd = dctx - > previousDstEnd ; <nl> + dctx - > vBase = ( const char * ) dst - ( ( const char * ) ( dctx - > previousDstEnd ) - ( const char * ) ( dctx - > base ) ) ; <nl> + dctx - > base = dst ; <nl> + dctx - > previousDstEnd = dst ; <nl> + } <nl> + } <nl> + <nl> + size_t ZSTD_decompressBlock ( ZSTD_DCtx * dctx , <nl> + void * dst , size_t dstCapacity , <nl> + const void * src , size_t srcSize ) <nl> + { <nl> + size_t dSize ; <nl> + ZSTD_checkContinuity ( dctx , dst ) ; <nl> + dSize = ZSTD_decompressBlock_internal ( dctx , dst , dstCapacity , src , srcSize ) ; <nl> + dctx - > previousDstEnd = ( char * ) dst + dSize ; <nl> + return dSize ; <nl> + } <nl> + <nl> + <nl> + / * * ZSTD_insertBlock ( ) : <nl> + insert ` src ` block into ` dctx ` history . Useful to track uncompressed blocks . * / <nl> + ZSTDLIB_API size_t ZSTD_insertBlock ( ZSTD_DCtx * dctx , const void * blockStart , size_t blockSize ) <nl> + { <nl> + ZSTD_checkContinuity ( dctx , blockStart ) ; <nl> + dctx - > previousDstEnd = ( const char * ) blockStart + blockSize ; <nl> + return blockSize ; <nl> + } <nl> + <nl> + <nl> + size_t ZSTD_generateNxBytes ( void * dst , size_t dstCapacity , BYTE byte , size_t length ) <nl> + { <nl> + if ( length > dstCapacity ) return ERROR ( dstSize_tooSmall ) ; <nl> + memset ( dst , byte , length ) ; <nl> + return length ; <nl> + } <nl> + <nl> + / * * ZSTD_findFrameCompressedSize ( ) : <nl> + * compatible with legacy mode <nl> + * ` src ` must point to the start of a ZSTD frame , ZSTD legacy frame , or skippable frame <nl> + * ` srcSize ` must be at least as large as the frame contained <nl> + * @ return : the compressed size of the frame starting at ` src ` * / <nl> + size_t ZSTD_findFrameCompressedSize ( const void * src , size_t srcSize ) <nl> + { <nl> + # if defined ( ZSTD_LEGACY_SUPPORT ) & & ( ZSTD_LEGACY_SUPPORT > = 1 ) <nl> + if ( ZSTD_isLegacy ( src , srcSize ) ) return ZSTD_findFrameCompressedSizeLegacy ( src , srcSize ) ; <nl> + # endif <nl> + if ( srcSize > = ZSTD_skippableHeaderSize & & <nl> + ( MEM_readLE32 ( src ) & 0xFFFFFFF0U ) = = ZSTD_MAGIC_SKIPPABLE_START ) { <nl> + return ZSTD_skippableHeaderSize + MEM_readLE32 ( ( const BYTE * ) src + 4 ) ; <nl> + } else { <nl> + const BYTE * ip = ( const BYTE * ) src ; <nl> + const BYTE * const ipstart = ip ; <nl> + size_t remainingSize = srcSize ; <nl> + ZSTD_frameParams fParams ; <nl> + <nl> + size_t const headerSize = ZSTD_frameHeaderSize ( ip , remainingSize ) ; <nl> + if ( ZSTD_isError ( headerSize ) ) return headerSize ; <nl> + <nl> + / * Frame Header * / <nl> + { size_t const ret = ZSTD_getFrameParams ( & fParams , ip , remainingSize ) ; <nl> + if ( ZSTD_isError ( ret ) ) return ret ; <nl> + if ( ret > 0 ) return ERROR ( srcSize_wrong ) ; <nl> + } <nl> + <nl> + ip + = headerSize ; <nl> + remainingSize - = headerSize ; <nl> + <nl> + / * Loop on each block * / <nl> + while ( 1 ) { <nl> + blockProperties_t blockProperties ; <nl> + size_t const cBlockSize = ZSTD_getcBlockSize ( ip , remainingSize , & blockProperties ) ; <nl> + if ( ZSTD_isError ( cBlockSize ) ) return cBlockSize ; <nl> + <nl> + if ( ZSTD_blockHeaderSize + cBlockSize > remainingSize ) return ERROR ( srcSize_wrong ) ; <nl> + <nl> + ip + = ZSTD_blockHeaderSize + cBlockSize ; <nl> + remainingSize - = ZSTD_blockHeaderSize + cBlockSize ; <nl> + <nl> + if ( blockProperties . lastBlock ) break ; <nl> + } <nl> + <nl> + if ( fParams . checksumFlag ) { / * Frame content checksum * / <nl> + if ( remainingSize < 4 ) return ERROR ( srcSize_wrong ) ; <nl> + ip + = 4 ; <nl> + remainingSize - = 4 ; <nl> + } <nl> + <nl> + return ip - ipstart ; <nl> + } <nl> + } <nl> + <nl> + / * ! ZSTD_decompressFrame ( ) : <nl> + * @ dctx must be properly initialized * / <nl> + static size_t ZSTD_decompressFrame ( ZSTD_DCtx * dctx , <nl> + void * dst , size_t dstCapacity , <nl> + const void * * srcPtr , size_t * srcSizePtr ) <nl> + { <nl> + const BYTE * ip = ( const BYTE * ) ( * srcPtr ) ; <nl> + BYTE * const ostart = ( BYTE * const ) dst ; <nl> + BYTE * const oend = ostart + dstCapacity ; <nl> + BYTE * op = ostart ; <nl> + size_t remainingSize = * srcSizePtr ; <nl> + <nl> + / * check * / <nl> + if ( remainingSize < ZSTD_frameHeaderSize_min + ZSTD_blockHeaderSize ) return ERROR ( srcSize_wrong ) ; <nl> + <nl> + / * Frame Header * / <nl> + { size_t const frameHeaderSize = ZSTD_frameHeaderSize ( ip , ZSTD_frameHeaderSize_prefix ) ; <nl> + if ( ZSTD_isError ( frameHeaderSize ) ) return frameHeaderSize ; <nl> + if ( remainingSize < frameHeaderSize + ZSTD_blockHeaderSize ) return ERROR ( srcSize_wrong ) ; <nl> + CHECK_F ( ZSTD_decodeFrameHeader ( dctx , ip , frameHeaderSize ) ) ; <nl> + ip + = frameHeaderSize ; remainingSize - = frameHeaderSize ; <nl> + } <nl> + <nl> + / * Loop on each block * / <nl> + while ( 1 ) { <nl> + size_t decodedSize ; <nl> + blockProperties_t blockProperties ; <nl> + size_t const cBlockSize = ZSTD_getcBlockSize ( ip , remainingSize , & blockProperties ) ; <nl> + if ( ZSTD_isError ( cBlockSize ) ) return cBlockSize ; <nl> + <nl> + ip + = ZSTD_blockHeaderSize ; <nl> + remainingSize - = ZSTD_blockHeaderSize ; <nl> + if ( cBlockSize > remainingSize ) return ERROR ( srcSize_wrong ) ; <nl> + <nl> + switch ( blockProperties . blockType ) <nl> + { <nl> + case bt_compressed : <nl> + decodedSize = ZSTD_decompressBlock_internal ( dctx , op , oend - op , ip , cBlockSize ) ; <nl> + break ; <nl> + case bt_raw : <nl> + decodedSize = ZSTD_copyRawBlock ( op , oend - op , ip , cBlockSize ) ; <nl> + break ; <nl> + case bt_rle : <nl> + decodedSize = ZSTD_generateNxBytes ( op , oend - op , * ip , blockProperties . origSize ) ; <nl> + break ; <nl> + case bt_reserved : <nl> + default : <nl> + return ERROR ( corruption_detected ) ; <nl> + } <nl> + <nl> + if ( ZSTD_isError ( decodedSize ) ) return decodedSize ; <nl> + if ( dctx - > fParams . checksumFlag ) XXH64_update ( & dctx - > xxhState , op , decodedSize ) ; <nl> + op + = decodedSize ; <nl> + ip + = cBlockSize ; <nl> + remainingSize - = cBlockSize ; <nl> + if ( blockProperties . lastBlock ) break ; <nl> + } <nl> + <nl> + if ( dctx - > fParams . checksumFlag ) { / * Frame content checksum verification * / <nl> + U32 const checkCalc = ( U32 ) XXH64_digest ( & dctx - > xxhState ) ; <nl> + U32 checkRead ; <nl> + if ( remainingSize < 4 ) return ERROR ( checksum_wrong ) ; <nl> + checkRead = MEM_readLE32 ( ip ) ; <nl> + if ( checkRead ! = checkCalc ) return ERROR ( checksum_wrong ) ; <nl> + ip + = 4 ; <nl> + remainingSize - = 4 ; <nl> + } <nl> + <nl> + / * Allow caller to get size read * / <nl> + * srcPtr = ip ; <nl> + * srcSizePtr = remainingSize ; <nl> + return op - ostart ; <nl> + } <nl> + <nl> + static const void * ZSTD_DDictDictContent ( const ZSTD_DDict * ddict ) ; <nl> + static size_t ZSTD_DDictDictSize ( const ZSTD_DDict * ddict ) ; <nl> + <nl> + static size_t ZSTD_decompressMultiFrame ( ZSTD_DCtx * dctx , <nl> + void * dst , size_t dstCapacity , <nl> + const void * src , size_t srcSize , <nl> + const void * dict , size_t dictSize , <nl> + const ZSTD_DDict * ddict ) <nl> + { <nl> + void * const dststart = dst ; <nl> + <nl> + if ( ddict ) { <nl> + if ( dict ) { <nl> + / * programmer error , these two cases should be mutually exclusive * / <nl> + return ERROR ( GENERIC ) ; <nl> + } <nl> + <nl> + dict = ZSTD_DDictDictContent ( ddict ) ; <nl> + dictSize = ZSTD_DDictDictSize ( ddict ) ; <nl> + } <nl> + <nl> + while ( srcSize > = ZSTD_frameHeaderSize_prefix ) { <nl> + U32 magicNumber ; <nl> + <nl> + # if defined ( ZSTD_LEGACY_SUPPORT ) & & ( ZSTD_LEGACY_SUPPORT > = 1 ) <nl> + if ( ZSTD_isLegacy ( src , srcSize ) ) { <nl> + size_t decodedSize ; <nl> + size_t const frameSize = ZSTD_findFrameCompressedSizeLegacy ( src , srcSize ) ; <nl> + if ( ZSTD_isError ( frameSize ) ) return frameSize ; <nl> + <nl> + decodedSize = ZSTD_decompressLegacy ( dst , dstCapacity , src , frameSize , dict , dictSize ) ; <nl> + <nl> + dst = ( BYTE * ) dst + decodedSize ; <nl> + dstCapacity - = decodedSize ; <nl> + <nl> + src = ( const BYTE * ) src + frameSize ; <nl> + srcSize - = frameSize ; <nl> + <nl> + continue ; <nl> + } <nl> + # endif <nl> + <nl> + magicNumber = MEM_readLE32 ( src ) ; <nl> + if ( magicNumber ! = ZSTD_MAGICNUMBER ) { <nl> + if ( ( magicNumber & 0xFFFFFFF0U ) = = ZSTD_MAGIC_SKIPPABLE_START ) { <nl> + size_t skippableSize ; <nl> + if ( srcSize < ZSTD_skippableHeaderSize ) <nl> + return ERROR ( srcSize_wrong ) ; <nl> + skippableSize = MEM_readLE32 ( ( const BYTE * ) src + 4 ) + <nl> + ZSTD_skippableHeaderSize ; <nl> + if ( srcSize < skippableSize ) { <nl> + return ERROR ( srcSize_wrong ) ; <nl> + } <nl> + <nl> + src = ( const BYTE * ) src + skippableSize ; <nl> + srcSize - = skippableSize ; <nl> + continue ; <nl> + } else { <nl> + return ERROR ( prefix_unknown ) ; <nl> + } <nl> + } <nl> + <nl> + if ( ddict ) { <nl> + / * we were called from ZSTD_decompress_usingDDict * / <nl> + ZSTD_refDDict ( dctx , ddict ) ; <nl> + } else { <nl> + / * this will initialize correctly with no dict if dict = = NULL , so <nl> + * use this in all cases but ddict * / <nl> + CHECK_F ( ZSTD_decompressBegin_usingDict ( dctx , dict , dictSize ) ) ; <nl> + } <nl> + ZSTD_checkContinuity ( dctx , dst ) ; <nl> + <nl> + { const size_t res = ZSTD_decompressFrame ( dctx , dst , dstCapacity , <nl> + & src , & srcSize ) ; <nl> + if ( ZSTD_isError ( res ) ) return res ; <nl> + / * don ' t need to bounds check this , ZSTD_decompressFrame will have <nl> + * already * / <nl> + dst = ( BYTE * ) dst + res ; <nl> + dstCapacity - = res ; <nl> + } <nl> + } <nl> + <nl> + if ( srcSize ) return ERROR ( srcSize_wrong ) ; / * input not entirely consumed * / <nl> + <nl> + return ( BYTE * ) dst - ( BYTE * ) dststart ; <nl> + } <nl> + <nl> + size_t ZSTD_decompress_usingDict ( ZSTD_DCtx * dctx , <nl> + void * dst , size_t dstCapacity , <nl> + const void * src , size_t srcSize , <nl> + const void * dict , size_t dictSize ) <nl> + { <nl> + return ZSTD_decompressMultiFrame ( dctx , dst , dstCapacity , src , srcSize , dict , dictSize , NULL ) ; <nl> + } <nl> + <nl> + <nl> + size_t ZSTD_decompressDCtx ( ZSTD_DCtx * dctx , void * dst , size_t dstCapacity , const void * src , size_t srcSize ) <nl> + { <nl> + return ZSTD_decompress_usingDict ( dctx , dst , dstCapacity , src , srcSize , NULL , 0 ) ; <nl> + } <nl> + <nl> + <nl> + size_t ZSTD_decompress ( void * dst , size_t dstCapacity , const void * src , size_t srcSize ) <nl> + { <nl> + # if defined ( ZSTD_HEAPMODE ) & & ( ZSTD_HEAPMODE = = 1 ) <nl> + size_t regenSize ; <nl> + ZSTD_DCtx * const dctx = ZSTD_createDCtx ( ) ; <nl> + if ( dctx = = NULL ) return ERROR ( memory_allocation ) ; <nl> + regenSize = ZSTD_decompressDCtx ( dctx , dst , dstCapacity , src , srcSize ) ; <nl> + ZSTD_freeDCtx ( dctx ) ; <nl> + return regenSize ; <nl> + # else / * stack mode * / <nl> + ZSTD_DCtx dctx ; <nl> + return ZSTD_decompressDCtx ( & dctx , dst , dstCapacity , src , srcSize ) ; <nl> + # endif <nl> + } <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Advanced Streaming Decompression API <nl> + * Bufferless and synchronous <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + size_t ZSTD_nextSrcSizeToDecompress ( ZSTD_DCtx * dctx ) { return dctx - > expected ; } <nl> + <nl> + ZSTD_nextInputType_e ZSTD_nextInputType ( ZSTD_DCtx * dctx ) { <nl> + switch ( dctx - > stage ) <nl> + { <nl> + default : / * should not happen * / <nl> + case ZSTDds_getFrameHeaderSize : <nl> + case ZSTDds_decodeFrameHeader : <nl> + return ZSTDnit_frameHeader ; <nl> + case ZSTDds_decodeBlockHeader : <nl> + return ZSTDnit_blockHeader ; <nl> + case ZSTDds_decompressBlock : <nl> + return ZSTDnit_block ; <nl> + case ZSTDds_decompressLastBlock : <nl> + return ZSTDnit_lastBlock ; <nl> + case ZSTDds_checkChecksum : <nl> + return ZSTDnit_checksum ; <nl> + case ZSTDds_decodeSkippableHeader : <nl> + case ZSTDds_skipFrame : <nl> + return ZSTDnit_skippableFrame ; <nl> + } <nl> + } <nl> + <nl> + int ZSTD_isSkipFrame ( ZSTD_DCtx * dctx ) { return dctx - > stage = = ZSTDds_skipFrame ; } / * for zbuff * / <nl> + <nl> + / * * ZSTD_decompressContinue ( ) : <nl> + * @ return : nb of bytes generated into ` dst ` ( necessarily < = ` dstCapacity ) <nl> + * or an error code , which can be tested using ZSTD_isError ( ) * / <nl> + size_t ZSTD_decompressContinue ( ZSTD_DCtx * dctx , void * dst , size_t dstCapacity , const void * src , size_t srcSize ) <nl> + { <nl> + / * Sanity check * / <nl> + if ( srcSize ! = dctx - > expected ) return ERROR ( srcSize_wrong ) ; <nl> + if ( dstCapacity ) ZSTD_checkContinuity ( dctx , dst ) ; <nl> + <nl> + switch ( dctx - > stage ) <nl> + { <nl> + case ZSTDds_getFrameHeaderSize : <nl> + if ( srcSize ! = ZSTD_frameHeaderSize_prefix ) return ERROR ( srcSize_wrong ) ; / * impossible * / <nl> + if ( ( MEM_readLE32 ( src ) & 0xFFFFFFF0U ) = = ZSTD_MAGIC_SKIPPABLE_START ) { / * skippable frame * / <nl> + memcpy ( dctx - > headerBuffer , src , ZSTD_frameHeaderSize_prefix ) ; <nl> + dctx - > expected = ZSTD_skippableHeaderSize - ZSTD_frameHeaderSize_prefix ; / * magic number + skippable frame length * / <nl> + dctx - > stage = ZSTDds_decodeSkippableHeader ; <nl> + return 0 ; <nl> + } <nl> + dctx - > headerSize = ZSTD_frameHeaderSize ( src , ZSTD_frameHeaderSize_prefix ) ; <nl> + if ( ZSTD_isError ( dctx - > headerSize ) ) return dctx - > headerSize ; <nl> + memcpy ( dctx - > headerBuffer , src , ZSTD_frameHeaderSize_prefix ) ; <nl> + if ( dctx - > headerSize > ZSTD_frameHeaderSize_prefix ) { <nl> + dctx - > expected = dctx - > headerSize - ZSTD_frameHeaderSize_prefix ; <nl> + dctx - > stage = ZSTDds_decodeFrameHeader ; <nl> + return 0 ; <nl> + } <nl> + dctx - > expected = 0 ; / * not necessary to copy more * / <nl> + <nl> + case ZSTDds_decodeFrameHeader : <nl> + memcpy ( dctx - > headerBuffer + ZSTD_frameHeaderSize_prefix , src , dctx - > expected ) ; <nl> + CHECK_F ( ZSTD_decodeFrameHeader ( dctx , dctx - > headerBuffer , dctx - > headerSize ) ) ; <nl> + dctx - > expected = ZSTD_blockHeaderSize ; <nl> + dctx - > stage = ZSTDds_decodeBlockHeader ; <nl> + return 0 ; <nl> + <nl> + case ZSTDds_decodeBlockHeader : <nl> + { blockProperties_t bp ; <nl> + size_t const cBlockSize = ZSTD_getcBlockSize ( src , ZSTD_blockHeaderSize , & bp ) ; <nl> + if ( ZSTD_isError ( cBlockSize ) ) return cBlockSize ; <nl> + dctx - > expected = cBlockSize ; <nl> + dctx - > bType = bp . blockType ; <nl> + dctx - > rleSize = bp . origSize ; <nl> + if ( cBlockSize ) { <nl> + dctx - > stage = bp . lastBlock ? ZSTDds_decompressLastBlock : ZSTDds_decompressBlock ; <nl> + return 0 ; <nl> + } <nl> + / * empty block * / <nl> + if ( bp . lastBlock ) { <nl> + if ( dctx - > fParams . checksumFlag ) { <nl> + dctx - > expected = 4 ; <nl> + dctx - > stage = ZSTDds_checkChecksum ; <nl> + } else { <nl> + dctx - > expected = 0 ; / * end of frame * / <nl> + dctx - > stage = ZSTDds_getFrameHeaderSize ; <nl> + } <nl> + } else { <nl> + dctx - > expected = 3 ; / * go directly to next header * / <nl> + dctx - > stage = ZSTDds_decodeBlockHeader ; <nl> + } <nl> + return 0 ; <nl> + } <nl> + case ZSTDds_decompressLastBlock : <nl> + case ZSTDds_decompressBlock : <nl> + { size_t rSize ; <nl> + switch ( dctx - > bType ) <nl> + { <nl> + case bt_compressed : <nl> + rSize = ZSTD_decompressBlock_internal ( dctx , dst , dstCapacity , src , srcSize ) ; <nl> + break ; <nl> + case bt_raw : <nl> + rSize = ZSTD_copyRawBlock ( dst , dstCapacity , src , srcSize ) ; <nl> + break ; <nl> + case bt_rle : <nl> + rSize = ZSTD_setRleBlock ( dst , dstCapacity , src , srcSize , dctx - > rleSize ) ; <nl> + break ; <nl> + case bt_reserved : / * should never happen * / <nl> + default : <nl> + return ERROR ( corruption_detected ) ; <nl> + } <nl> + if ( ZSTD_isError ( rSize ) ) return rSize ; <nl> + if ( dctx - > fParams . checksumFlag ) XXH64_update ( & dctx - > xxhState , dst , rSize ) ; <nl> + <nl> + if ( dctx - > stage = = ZSTDds_decompressLastBlock ) { / * end of frame * / <nl> + if ( dctx - > fParams . checksumFlag ) { / * another round for frame checksum * / <nl> + dctx - > expected = 4 ; <nl> + dctx - > stage = ZSTDds_checkChecksum ; <nl> + } else { <nl> + dctx - > expected = 0 ; / * ends here * / <nl> + dctx - > stage = ZSTDds_getFrameHeaderSize ; <nl> + } <nl> + } else { <nl> + dctx - > stage = ZSTDds_decodeBlockHeader ; <nl> + dctx - > expected = ZSTD_blockHeaderSize ; <nl> + dctx - > previousDstEnd = ( char * ) dst + rSize ; <nl> + } <nl> + return rSize ; <nl> + } <nl> + case ZSTDds_checkChecksum : <nl> + { U32 const h32 = ( U32 ) XXH64_digest ( & dctx - > xxhState ) ; <nl> + U32 const check32 = MEM_readLE32 ( src ) ; / * srcSize = = 4 , guaranteed by dctx - > expected * / <nl> + if ( check32 ! = h32 ) return ERROR ( checksum_wrong ) ; <nl> + dctx - > expected = 0 ; <nl> + dctx - > stage = ZSTDds_getFrameHeaderSize ; <nl> + return 0 ; <nl> + } <nl> + case ZSTDds_decodeSkippableHeader : <nl> + { memcpy ( dctx - > headerBuffer + ZSTD_frameHeaderSize_prefix , src , dctx - > expected ) ; <nl> + dctx - > expected = MEM_readLE32 ( dctx - > headerBuffer + 4 ) ; <nl> + dctx - > stage = ZSTDds_skipFrame ; <nl> + return 0 ; <nl> + } <nl> + case ZSTDds_skipFrame : <nl> + { dctx - > expected = 0 ; <nl> + dctx - > stage = ZSTDds_getFrameHeaderSize ; <nl> + return 0 ; <nl> + } <nl> + default : <nl> + return ERROR ( GENERIC ) ; / * impossible * / <nl> + } <nl> + } <nl> + <nl> + <nl> + static size_t ZSTD_refDictContent ( ZSTD_DCtx * dctx , const void * dict , size_t dictSize ) <nl> + { <nl> + dctx - > dictEnd = dctx - > previousDstEnd ; <nl> + dctx - > vBase = ( const char * ) dict - ( ( const char * ) ( dctx - > previousDstEnd ) - ( const char * ) ( dctx - > base ) ) ; <nl> + dctx - > base = dict ; <nl> + dctx - > previousDstEnd = ( const char * ) dict + dictSize ; <nl> + return 0 ; <nl> + } <nl> + <nl> + / * ZSTD_loadEntropy ( ) : <nl> + * dict : must point at beginning of a valid zstd dictionary <nl> + * @ return : size of entropy tables read * / <nl> + static size_t ZSTD_loadEntropy ( ZSTD_entropyTables_t * entropy , const void * const dict , size_t const dictSize ) <nl> + { <nl> + const BYTE * dictPtr = ( const BYTE * ) dict ; <nl> + const BYTE * const dictEnd = dictPtr + dictSize ; <nl> + <nl> + if ( dictSize < = 8 ) return ERROR ( dictionary_corrupted ) ; <nl> + dictPtr + = 8 ; / * skip header = magic + dictID * / <nl> + <nl> + <nl> + { size_t const hSize = HUF_readDTableX4 ( entropy - > hufTable , dictPtr , dictEnd - dictPtr ) ; <nl> + if ( HUF_isError ( hSize ) ) return ERROR ( dictionary_corrupted ) ; <nl> + dictPtr + = hSize ; <nl> + } <nl> + <nl> + { short offcodeNCount [ MaxOff + 1 ] ; <nl> + U32 offcodeMaxValue = MaxOff , offcodeLog ; <nl> + size_t const offcodeHeaderSize = FSE_readNCount ( offcodeNCount , & offcodeMaxValue , & offcodeLog , dictPtr , dictEnd - dictPtr ) ; <nl> + if ( FSE_isError ( offcodeHeaderSize ) ) return ERROR ( dictionary_corrupted ) ; <nl> + if ( offcodeLog > OffFSELog ) return ERROR ( dictionary_corrupted ) ; <nl> + CHECK_E ( FSE_buildDTable ( entropy - > OFTable , offcodeNCount , offcodeMaxValue , offcodeLog ) , dictionary_corrupted ) ; <nl> + dictPtr + = offcodeHeaderSize ; <nl> + } <nl> + <nl> + { short matchlengthNCount [ MaxML + 1 ] ; <nl> + unsigned matchlengthMaxValue = MaxML , matchlengthLog ; <nl> + size_t const matchlengthHeaderSize = FSE_readNCount ( matchlengthNCount , & matchlengthMaxValue , & matchlengthLog , dictPtr , dictEnd - dictPtr ) ; <nl> + if ( FSE_isError ( matchlengthHeaderSize ) ) return ERROR ( dictionary_corrupted ) ; <nl> + if ( matchlengthLog > MLFSELog ) return ERROR ( dictionary_corrupted ) ; <nl> + CHECK_E ( FSE_buildDTable ( entropy - > MLTable , matchlengthNCount , matchlengthMaxValue , matchlengthLog ) , dictionary_corrupted ) ; <nl> + dictPtr + = matchlengthHeaderSize ; <nl> + } <nl> + <nl> + { short litlengthNCount [ MaxLL + 1 ] ; <nl> + unsigned litlengthMaxValue = MaxLL , litlengthLog ; <nl> + size_t const litlengthHeaderSize = FSE_readNCount ( litlengthNCount , & litlengthMaxValue , & litlengthLog , dictPtr , dictEnd - dictPtr ) ; <nl> + if ( FSE_isError ( litlengthHeaderSize ) ) return ERROR ( dictionary_corrupted ) ; <nl> + if ( litlengthLog > LLFSELog ) return ERROR ( dictionary_corrupted ) ; <nl> + CHECK_E ( FSE_buildDTable ( entropy - > LLTable , litlengthNCount , litlengthMaxValue , litlengthLog ) , dictionary_corrupted ) ; <nl> + dictPtr + = litlengthHeaderSize ; <nl> + } <nl> + <nl> + if ( dictPtr + 12 > dictEnd ) return ERROR ( dictionary_corrupted ) ; <nl> + { int i ; <nl> + size_t const dictContentSize = ( size_t ) ( dictEnd - ( dictPtr + 12 ) ) ; <nl> + for ( i = 0 ; i < 3 ; i + + ) { <nl> + U32 const rep = MEM_readLE32 ( dictPtr ) ; dictPtr + = 4 ; <nl> + if ( rep = = 0 | | rep > = dictContentSize ) return ERROR ( dictionary_corrupted ) ; <nl> + entropy - > rep [ i ] = rep ; <nl> + } } <nl> + <nl> + return dictPtr - ( const BYTE * ) dict ; <nl> + } <nl> + <nl> + static size_t ZSTD_decompress_insertDictionary ( ZSTD_DCtx * dctx , const void * dict , size_t dictSize ) <nl> + { <nl> + if ( dictSize < 8 ) return ZSTD_refDictContent ( dctx , dict , dictSize ) ; <nl> + { U32 const magic = MEM_readLE32 ( dict ) ; <nl> + if ( magic ! = ZSTD_DICT_MAGIC ) { <nl> + return ZSTD_refDictContent ( dctx , dict , dictSize ) ; / * pure content mode * / <nl> + } } <nl> + dctx - > dictID = MEM_readLE32 ( ( const char * ) dict + 4 ) ; <nl> + <nl> + / * load entropy tables * / <nl> + { size_t const eSize = ZSTD_loadEntropy ( & dctx - > entropy , dict , dictSize ) ; <nl> + if ( ZSTD_isError ( eSize ) ) return ERROR ( dictionary_corrupted ) ; <nl> + dict = ( const char * ) dict + eSize ; <nl> + dictSize - = eSize ; <nl> + } <nl> + dctx - > litEntropy = dctx - > fseEntropy = 1 ; <nl> + <nl> + / * reference dictionary content * / <nl> + return ZSTD_refDictContent ( dctx , dict , dictSize ) ; <nl> + } <nl> + <nl> + size_t ZSTD_decompressBegin_usingDict ( ZSTD_DCtx * dctx , const void * dict , size_t dictSize ) <nl> + { <nl> + CHECK_F ( ZSTD_decompressBegin ( dctx ) ) ; <nl> + if ( dict & & dictSize ) CHECK_E ( ZSTD_decompress_insertDictionary ( dctx , dict , dictSize ) , dictionary_corrupted ) ; <nl> + return 0 ; <nl> + } <nl> + <nl> + <nl> + / * = = = = = = ZSTD_DDict = = = = = = * / <nl> + <nl> + struct ZSTD_DDict_s { <nl> + void * dictBuffer ; <nl> + const void * dictContent ; <nl> + size_t dictSize ; <nl> + ZSTD_entropyTables_t entropy ; <nl> + U32 dictID ; <nl> + U32 entropyPresent ; <nl> + ZSTD_customMem cMem ; <nl> + } ; / * typedef ' d to ZSTD_DDict within " zstd . h " * / <nl> + <nl> + static const void * ZSTD_DDictDictContent ( const ZSTD_DDict * ddict ) <nl> + { <nl> + return ddict - > dictContent ; <nl> + } <nl> + <nl> + static size_t ZSTD_DDictDictSize ( const ZSTD_DDict * ddict ) <nl> + { <nl> + return ddict - > dictSize ; <nl> + } <nl> + <nl> + static void ZSTD_refDDict ( ZSTD_DCtx * dstDCtx , const ZSTD_DDict * ddict ) <nl> + { <nl> + ZSTD_decompressBegin ( dstDCtx ) ; / * init * / <nl> + if ( ddict ) { / * support refDDict on NULL * / <nl> + dstDCtx - > dictID = ddict - > dictID ; <nl> + dstDCtx - > base = ddict - > dictContent ; <nl> + dstDCtx - > vBase = ddict - > dictContent ; <nl> + dstDCtx - > dictEnd = ( const BYTE * ) ddict - > dictContent + ddict - > dictSize ; <nl> + dstDCtx - > previousDstEnd = dstDCtx - > dictEnd ; <nl> + if ( ddict - > entropyPresent ) { <nl> + dstDCtx - > litEntropy = 1 ; <nl> + dstDCtx - > fseEntropy = 1 ; <nl> + dstDCtx - > LLTptr = ddict - > entropy . LLTable ; <nl> + dstDCtx - > MLTptr = ddict - > entropy . MLTable ; <nl> + dstDCtx - > OFTptr = ddict - > entropy . OFTable ; <nl> + dstDCtx - > HUFptr = ddict - > entropy . hufTable ; <nl> + dstDCtx - > entropy . rep [ 0 ] = ddict - > entropy . rep [ 0 ] ; <nl> + dstDCtx - > entropy . rep [ 1 ] = ddict - > entropy . rep [ 1 ] ; <nl> + dstDCtx - > entropy . rep [ 2 ] = ddict - > entropy . rep [ 2 ] ; <nl> + } else { <nl> + dstDCtx - > litEntropy = 0 ; <nl> + dstDCtx - > fseEntropy = 0 ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + static size_t ZSTD_loadEntropy_inDDict ( ZSTD_DDict * ddict ) <nl> + { <nl> + ddict - > dictID = 0 ; <nl> + ddict - > entropyPresent = 0 ; <nl> + if ( ddict - > dictSize < 8 ) return 0 ; <nl> + { U32 const magic = MEM_readLE32 ( ddict - > dictContent ) ; <nl> + if ( magic ! = ZSTD_DICT_MAGIC ) return 0 ; / * pure content mode * / <nl> + } <nl> + ddict - > dictID = MEM_readLE32 ( ( const char * ) ddict - > dictContent + 4 ) ; <nl> + <nl> + / * load entropy tables * / <nl> + CHECK_E ( ZSTD_loadEntropy ( & ddict - > entropy , ddict - > dictContent , ddict - > dictSize ) , dictionary_corrupted ) ; <nl> + ddict - > entropyPresent = 1 ; <nl> + return 0 ; <nl> + } <nl> + <nl> + <nl> + ZSTD_DDict * ZSTD_createDDict_advanced ( const void * dict , size_t dictSize , unsigned byReference , ZSTD_customMem customMem ) <nl> + { <nl> + if ( ! customMem . customAlloc & & ! customMem . customFree ) customMem = defaultCustomMem ; <nl> + if ( ! customMem . customAlloc | | ! customMem . customFree ) return NULL ; <nl> + <nl> + { ZSTD_DDict * const ddict = ( ZSTD_DDict * ) ZSTD_malloc ( sizeof ( ZSTD_DDict ) , customMem ) ; <nl> + if ( ! ddict ) return NULL ; <nl> + ddict - > cMem = customMem ; <nl> + <nl> + if ( ( byReference ) | | ( ! dict ) | | ( ! dictSize ) ) { <nl> + ddict - > dictBuffer = NULL ; <nl> + ddict - > dictContent = dict ; <nl> + } else { <nl> + void * const internalBuffer = ZSTD_malloc ( dictSize , customMem ) ; <nl> + if ( ! internalBuffer ) { ZSTD_freeDDict ( ddict ) ; return NULL ; } <nl> + memcpy ( internalBuffer , dict , dictSize ) ; <nl> + ddict - > dictBuffer = internalBuffer ; <nl> + ddict - > dictContent = internalBuffer ; <nl> + } <nl> + ddict - > dictSize = dictSize ; <nl> + ddict - > entropy . hufTable [ 0 ] = ( HUF_DTable ) ( ( HufLog ) * 0x1000001 ) ; / * cover both little and big endian * / <nl> + / * parse dictionary content * / <nl> + { size_t const errorCode = ZSTD_loadEntropy_inDDict ( ddict ) ; <nl> + if ( ZSTD_isError ( errorCode ) ) { <nl> + ZSTD_freeDDict ( ddict ) ; <nl> + return NULL ; <nl> + } } <nl> + <nl> + return ddict ; <nl> + } <nl> + } <nl> + <nl> + / * ! ZSTD_createDDict ( ) : <nl> + * Create a digested dictionary , to start decompression without startup delay . <nl> + * ` dict ` content is copied inside DDict . <nl> + * Consequently , ` dict ` can be released after ` ZSTD_DDict ` creation * / <nl> + ZSTD_DDict * ZSTD_createDDict ( const void * dict , size_t dictSize ) <nl> + { <nl> + ZSTD_customMem const allocator = { NULL , NULL , NULL } ; <nl> + return ZSTD_createDDict_advanced ( dict , dictSize , 0 , allocator ) ; <nl> + } <nl> + <nl> + <nl> + / * ! ZSTD_createDDict_byReference ( ) : <nl> + * Create a digested dictionary , to start decompression without startup delay . <nl> + * Dictionary content is simply referenced , it will be accessed during decompression . <nl> + * Warning : dictBuffer must outlive DDict ( DDict must be freed before dictBuffer ) * / <nl> + ZSTD_DDict * ZSTD_createDDict_byReference ( const void * dictBuffer , size_t dictSize ) <nl> + { <nl> + ZSTD_customMem const allocator = { NULL , NULL , NULL } ; <nl> + return ZSTD_createDDict_advanced ( dictBuffer , dictSize , 1 , allocator ) ; <nl> + } <nl> + <nl> + <nl> + size_t ZSTD_freeDDict ( ZSTD_DDict * ddict ) <nl> + { <nl> + if ( ddict = = NULL ) return 0 ; / * support free on NULL * / <nl> + { ZSTD_customMem const cMem = ddict - > cMem ; <nl> + ZSTD_free ( ddict - > dictBuffer , cMem ) ; <nl> + ZSTD_free ( ddict , cMem ) ; <nl> + return 0 ; <nl> + } <nl> + } <nl> + <nl> + size_t ZSTD_sizeof_DDict ( const ZSTD_DDict * ddict ) <nl> + { <nl> + if ( ddict = = NULL ) return 0 ; / * support sizeof on NULL * / <nl> + return sizeof ( * ddict ) + ( ddict - > dictBuffer ? ddict - > dictSize : 0 ) ; <nl> + } <nl> + <nl> + / * ! ZSTD_getDictID_fromDict ( ) : <nl> + * Provides the dictID stored within dictionary . <nl> + * if @ return = = 0 , the dictionary is not conformant with Zstandard specification . <nl> + * It can still be loaded , but as a content - only dictionary . * / <nl> + unsigned ZSTD_getDictID_fromDict ( const void * dict , size_t dictSize ) <nl> + { <nl> + if ( dictSize < 8 ) return 0 ; <nl> + if ( MEM_readLE32 ( dict ) ! = ZSTD_DICT_MAGIC ) return 0 ; <nl> + return MEM_readLE32 ( ( const char * ) dict + 4 ) ; <nl> + } <nl> + <nl> + / * ! ZSTD_getDictID_fromDDict ( ) : <nl> + * Provides the dictID of the dictionary loaded into ` ddict ` . <nl> + * If @ return = = 0 , the dictionary is not conformant to Zstandard specification , or empty . <nl> + * Non - conformant dictionaries can still be loaded , but as content - only dictionaries . * / <nl> + unsigned ZSTD_getDictID_fromDDict ( const ZSTD_DDict * ddict ) <nl> + { <nl> + if ( ddict = = NULL ) return 0 ; <nl> + return ZSTD_getDictID_fromDict ( ddict - > dictContent , ddict - > dictSize ) ; <nl> + } <nl> + <nl> + / * ! ZSTD_getDictID_fromFrame ( ) : <nl> + * Provides the dictID required to decompresse frame stored within ` src ` . <nl> + * If @ return = = 0 , the dictID could not be decoded . <nl> + * This could for one of the following reasons : <nl> + * - The frame does not require a dictionary ( most common case ) . <nl> + * - The frame was built with dictID intentionally removed . <nl> + * Needed dictionary is a hidden information . <nl> + * Note : this use case also happens when using a non - conformant dictionary . <nl> + * - ` srcSize ` is too small , and as a result , frame header could not be decoded . <nl> + * Note : possible if ` srcSize < ZSTD_FRAMEHEADERSIZE_MAX ` . <nl> + * - This is not a Zstandard frame . <nl> + * When identifying the exact failure cause , it ' s possible to use <nl> + * ZSTD_getFrameParams ( ) , which will provide a more precise error code . * / <nl> + unsigned ZSTD_getDictID_fromFrame ( const void * src , size_t srcSize ) <nl> + { <nl> + ZSTD_frameParams zfp = { 0 , 0 , 0 , 0 } ; <nl> + size_t const hError = ZSTD_getFrameParams ( & zfp , src , srcSize ) ; <nl> + if ( ZSTD_isError ( hError ) ) return 0 ; <nl> + return zfp . dictID ; <nl> + } <nl> + <nl> + <nl> + / * ! ZSTD_decompress_usingDDict ( ) : <nl> + * Decompression using a pre - digested Dictionary <nl> + * Use dictionary without significant overhead . * / <nl> + size_t ZSTD_decompress_usingDDict ( ZSTD_DCtx * dctx , <nl> + void * dst , size_t dstCapacity , <nl> + const void * src , size_t srcSize , <nl> + const ZSTD_DDict * ddict ) <nl> + { <nl> + / * pass content and size in case legacy frames are encountered * / <nl> + return ZSTD_decompressMultiFrame ( dctx , dst , dstCapacity , src , srcSize , <nl> + NULL , 0 , <nl> + ddict ) ; <nl> + } <nl> + <nl> + <nl> + / * = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + * Streaming decompression <nl> + * = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> + <nl> + typedef enum { zdss_init , zdss_loadHeader , <nl> + zdss_read , zdss_load , zdss_flush } ZSTD_dStreamStage ; <nl> + <nl> + / * * * * Resource management * * * * / <nl> + struct ZSTD_DStream_s { <nl> + ZSTD_DCtx * dctx ; <nl> + ZSTD_DDict * ddictLocal ; <nl> + const ZSTD_DDict * ddict ; <nl> + ZSTD_frameParams fParams ; <nl> + ZSTD_dStreamStage stage ; <nl> + char * inBuff ; <nl> + size_t inBuffSize ; <nl> + size_t inPos ; <nl> + size_t maxWindowSize ; <nl> + char * outBuff ; <nl> + size_t outBuffSize ; <nl> + size_t outStart ; <nl> + size_t outEnd ; <nl> + size_t blockSize ; <nl> + BYTE headerBuffer [ ZSTD_FRAMEHEADERSIZE_MAX ] ; / * tmp buffer to store frame header * / <nl> + size_t lhSize ; <nl> + ZSTD_customMem customMem ; <nl> + void * legacyContext ; <nl> + U32 previousLegacyVersion ; <nl> + U32 legacyVersion ; <nl> + U32 hostageByte ; <nl> + } ; / * typedef ' d to ZSTD_DStream within " zstd . h " * / <nl> + <nl> + <nl> + ZSTD_DStream * ZSTD_createDStream ( void ) <nl> + { <nl> + return ZSTD_createDStream_advanced ( defaultCustomMem ) ; <nl> + } <nl> + <nl> + ZSTD_DStream * ZSTD_createDStream_advanced ( ZSTD_customMem customMem ) <nl> + { <nl> + ZSTD_DStream * zds ; <nl> + <nl> + if ( ! customMem . customAlloc & & ! customMem . customFree ) customMem = defaultCustomMem ; <nl> + if ( ! customMem . customAlloc | | ! customMem . customFree ) return NULL ; <nl> + <nl> + zds = ( ZSTD_DStream * ) ZSTD_malloc ( sizeof ( ZSTD_DStream ) , customMem ) ; <nl> + if ( zds = = NULL ) return NULL ; <nl> + memset ( zds , 0 , sizeof ( ZSTD_DStream ) ) ; <nl> + memcpy ( & zds - > customMem , & customMem , sizeof ( ZSTD_customMem ) ) ; <nl> + zds - > dctx = ZSTD_createDCtx_advanced ( customMem ) ; <nl> + if ( zds - > dctx = = NULL ) { ZSTD_freeDStream ( zds ) ; return NULL ; } <nl> + zds - > stage = zdss_init ; <nl> + zds - > maxWindowSize = ZSTD_MAXWINDOWSIZE_DEFAULT ; <nl> + return zds ; <nl> + } <nl> + <nl> + size_t ZSTD_freeDStream ( ZSTD_DStream * zds ) <nl> + { <nl> + if ( zds = = NULL ) return 0 ; / * support free on null * / <nl> + { ZSTD_customMem const cMem = zds - > customMem ; <nl> + ZSTD_freeDCtx ( zds - > dctx ) ; <nl> + zds - > dctx = NULL ; <nl> + ZSTD_freeDDict ( zds - > ddictLocal ) ; <nl> + zds - > ddictLocal = NULL ; <nl> + ZSTD_free ( zds - > inBuff , cMem ) ; <nl> + zds - > inBuff = NULL ; <nl> + ZSTD_free ( zds - > outBuff , cMem ) ; <nl> + zds - > outBuff = NULL ; <nl> + # if defined ( ZSTD_LEGACY_SUPPORT ) & & ( ZSTD_LEGACY_SUPPORT > = 1 ) <nl> + if ( zds - > legacyContext ) <nl> + ZSTD_freeLegacyStreamContext ( zds - > legacyContext , zds - > previousLegacyVersion ) ; <nl> + # endif <nl> + ZSTD_free ( zds , cMem ) ; <nl> + return 0 ; <nl> + } <nl> + } <nl> + <nl> + <nl> + / * * * * Initialization * * * * / <nl> + <nl> + size_t ZSTD_DStreamInSize ( void ) { return ZSTD_BLOCKSIZE_ABSOLUTEMAX + ZSTD_blockHeaderSize ; } <nl> + size_t ZSTD_DStreamOutSize ( void ) { return ZSTD_BLOCKSIZE_ABSOLUTEMAX ; } <nl> + <nl> + size_t ZSTD_initDStream_usingDict ( ZSTD_DStream * zds , const void * dict , size_t dictSize ) <nl> + { <nl> + zds - > stage = zdss_loadHeader ; <nl> + zds - > lhSize = zds - > inPos = zds - > outStart = zds - > outEnd = 0 ; <nl> + ZSTD_freeDDict ( zds - > ddictLocal ) ; <nl> + if ( dict & & dictSize > = 8 ) { <nl> + zds - > ddictLocal = ZSTD_createDDict ( dict , dictSize ) ; <nl> + if ( zds - > ddictLocal = = NULL ) return ERROR ( memory_allocation ) ; <nl> + } else zds - > ddictLocal = NULL ; <nl> + zds - > ddict = zds - > ddictLocal ; <nl> + zds - > legacyVersion = 0 ; <nl> + zds - > hostageByte = 0 ; <nl> + return ZSTD_frameHeaderSize_prefix ; <nl> + } <nl> + <nl> + size_t ZSTD_initDStream ( ZSTD_DStream * zds ) <nl> + { <nl> + return ZSTD_initDStream_usingDict ( zds , NULL , 0 ) ; <nl> + } <nl> + <nl> + / * ZSTD_initDStream_usingDDict ( ) : <nl> + * ddict will just be referenced , and must outlive decompression session * / <nl> + size_t ZSTD_initDStream_usingDDict ( ZSTD_DStream * zds , const ZSTD_DDict * ddict ) <nl> + { <nl> + size_t const initResult = ZSTD_initDStream ( zds ) ; <nl> + zds - > ddict = ddict ; <nl> + return initResult ; <nl> + } <nl> + <nl> + size_t ZSTD_resetDStream ( ZSTD_DStream * zds ) <nl> + { <nl> + zds - > stage = zdss_loadHeader ; <nl> + zds - > lhSize = zds - > inPos = zds - > outStart = zds - > outEnd = 0 ; <nl> + zds - > legacyVersion = 0 ; <nl> + zds - > hostageByte = 0 ; <nl> + return ZSTD_frameHeaderSize_prefix ; <nl> + } <nl> + <nl> + size_t ZSTD_setDStreamParameter ( ZSTD_DStream * zds , <nl> + ZSTD_DStreamParameter_e paramType , unsigned paramValue ) <nl> + { <nl> + switch ( paramType ) <nl> + { <nl> + default : return ERROR ( parameter_unknown ) ; <nl> + case DStream_p_maxWindowSize : zds - > maxWindowSize = paramValue ? paramValue : ( U32 ) ( - 1 ) ; break ; <nl> + } <nl> + return 0 ; <nl> + } <nl> + <nl> + <nl> + size_t ZSTD_sizeof_DStream ( const ZSTD_DStream * zds ) <nl> + { <nl> + if ( zds = = NULL ) return 0 ; / * support sizeof NULL * / <nl> + return sizeof ( * zds ) <nl> + + ZSTD_sizeof_DCtx ( zds - > dctx ) <nl> + + ZSTD_sizeof_DDict ( zds - > ddictLocal ) <nl> + + zds - > inBuffSize + zds - > outBuffSize ; <nl> + } <nl> + <nl> + <nl> + / * * * * * * Decompression * * * * * * / <nl> + <nl> + MEM_STATIC size_t ZSTD_limitCopy ( void * dst , size_t dstCapacity , const void * src , size_t srcSize ) <nl> + { <nl> + size_t const length = MIN ( dstCapacity , srcSize ) ; <nl> + memcpy ( dst , src , length ) ; <nl> + return length ; <nl> + } <nl> + <nl> + <nl> + size_t ZSTD_decompressStream ( ZSTD_DStream * zds , ZSTD_outBuffer * output , ZSTD_inBuffer * input ) <nl> + { <nl> + const char * const istart = ( const char * ) ( input - > src ) + input - > pos ; <nl> + const char * const iend = ( const char * ) ( input - > src ) + input - > size ; <nl> + const char * ip = istart ; <nl> + char * const ostart = ( char * ) ( output - > dst ) + output - > pos ; <nl> + char * const oend = ( char * ) ( output - > dst ) + output - > size ; <nl> + char * op = ostart ; <nl> + U32 someMoreWork = 1 ; <nl> + <nl> + # if defined ( ZSTD_LEGACY_SUPPORT ) & & ( ZSTD_LEGACY_SUPPORT > = 1 ) <nl> + if ( zds - > legacyVersion ) <nl> + return ZSTD_decompressLegacyStream ( zds - > legacyContext , zds - > legacyVersion , output , input ) ; <nl> + # endif <nl> + <nl> + while ( someMoreWork ) { <nl> + switch ( zds - > stage ) <nl> + { <nl> + case zdss_init : <nl> + ZSTD_resetDStream ( zds ) ; / * transparent reset on starting decoding a new frame * / <nl> + / * fall - through * / <nl> + <nl> + case zdss_loadHeader : <nl> + { size_t const hSize = ZSTD_getFrameParams ( & zds - > fParams , zds - > headerBuffer , zds - > lhSize ) ; <nl> + if ( ZSTD_isError ( hSize ) ) <nl> + # if defined ( ZSTD_LEGACY_SUPPORT ) & & ( ZSTD_LEGACY_SUPPORT > = 1 ) <nl> + { U32 const legacyVersion = ZSTD_isLegacy ( istart , iend - istart ) ; <nl> + if ( legacyVersion ) { <nl> + const void * const dict = zds - > ddict ? zds - > ddict - > dictContent : NULL ; <nl> + size_t const dictSize = zds - > ddict ? zds - > ddict - > dictSize : 0 ; <nl> + CHECK_F ( ZSTD_initLegacyStream ( & zds - > legacyContext , zds - > previousLegacyVersion , legacyVersion , <nl> + dict , dictSize ) ) ; <nl> + zds - > legacyVersion = zds - > previousLegacyVersion = legacyVersion ; <nl> + return ZSTD_decompressLegacyStream ( zds - > legacyContext , zds - > legacyVersion , output , input ) ; <nl> + } else { <nl> + return hSize ; / * error * / <nl> + } } <nl> + # else <nl> + return hSize ; <nl> + # endif <nl> + if ( hSize ! = 0 ) { / * need more input * / <nl> + size_t const toLoad = hSize - zds - > lhSize ; / * if hSize ! = 0 , hSize > zds - > lhSize * / <nl> + if ( toLoad > ( size_t ) ( iend - ip ) ) { / * not enough input to load full header * / <nl> + memcpy ( zds - > headerBuffer + zds - > lhSize , ip , iend - ip ) ; <nl> + zds - > lhSize + = iend - ip ; <nl> + input - > pos = input - > size ; <nl> + return ( MAX ( ZSTD_frameHeaderSize_min , hSize ) - zds - > lhSize ) + ZSTD_blockHeaderSize ; / * remaining header bytes + next block header * / <nl> + } <nl> + memcpy ( zds - > headerBuffer + zds - > lhSize , ip , toLoad ) ; zds - > lhSize = hSize ; ip + = toLoad ; <nl> + break ; <nl> + } } <nl> + <nl> + / * check for single - pass mode opportunity * / <nl> + if ( zds - > fParams . frameContentSize & & zds - > fParams . windowSize / * skippable frame if = = 0 * / <nl> + & & ( U64 ) ( size_t ) ( oend - op ) > = zds - > fParams . frameContentSize ) { <nl> + size_t const cSize = ZSTD_findFrameCompressedSize ( istart , iend - istart ) ; <nl> + if ( cSize < = ( size_t ) ( iend - istart ) ) { <nl> + size_t const decompressedSize = ZSTD_decompress_usingDDict ( zds - > dctx , op , oend - op , istart , cSize , zds - > ddict ) ; <nl> + if ( ZSTD_isError ( decompressedSize ) ) return decompressedSize ; <nl> + ip = istart + cSize ; <nl> + op + = decompressedSize ; <nl> + zds - > dctx - > expected = 0 ; <nl> + zds - > stage = zdss_init ; <nl> + someMoreWork = 0 ; <nl> + break ; <nl> + } } <nl> + <nl> + / * Consume header * / <nl> + ZSTD_refDDict ( zds - > dctx , zds - > ddict ) ; <nl> + { size_t const h1Size = ZSTD_nextSrcSizeToDecompress ( zds - > dctx ) ; / * = = ZSTD_frameHeaderSize_prefix * / <nl> + CHECK_F ( ZSTD_decompressContinue ( zds - > dctx , NULL , 0 , zds - > headerBuffer , h1Size ) ) ; <nl> + { size_t const h2Size = ZSTD_nextSrcSizeToDecompress ( zds - > dctx ) ; <nl> + CHECK_F ( ZSTD_decompressContinue ( zds - > dctx , NULL , 0 , zds - > headerBuffer + h1Size , h2Size ) ) ; <nl> + } } <nl> + <nl> + zds - > fParams . windowSize = MAX ( zds - > fParams . windowSize , 1U < < ZSTD_WINDOWLOG_ABSOLUTEMIN ) ; <nl> + if ( zds - > fParams . windowSize > zds - > maxWindowSize ) return ERROR ( frameParameter_windowTooLarge ) ; <nl> + <nl> + / * Adapt buffer sizes to frame header instructions * / <nl> + { size_t const blockSize = MIN ( zds - > fParams . windowSize , ZSTD_BLOCKSIZE_ABSOLUTEMAX ) ; <nl> + size_t const neededOutSize = zds - > fParams . windowSize + blockSize + WILDCOPY_OVERLENGTH * 2 ; <nl> + zds - > blockSize = blockSize ; <nl> + if ( zds - > inBuffSize < blockSize ) { <nl> + ZSTD_free ( zds - > inBuff , zds - > customMem ) ; <nl> + zds - > inBuffSize = 0 ; <nl> + zds - > inBuff = ( char * ) ZSTD_malloc ( blockSize , zds - > customMem ) ; <nl> + if ( zds - > inBuff = = NULL ) return ERROR ( memory_allocation ) ; <nl> + zds - > inBuffSize = blockSize ; <nl> + } <nl> + if ( zds - > outBuffSize < neededOutSize ) { <nl> + ZSTD_free ( zds - > outBuff , zds - > customMem ) ; <nl> + zds - > outBuffSize = 0 ; <nl> + zds - > outBuff = ( char * ) ZSTD_malloc ( neededOutSize , zds - > customMem ) ; <nl> + if ( zds - > outBuff = = NULL ) return ERROR ( memory_allocation ) ; <nl> + zds - > outBuffSize = neededOutSize ; <nl> + } } <nl> + zds - > stage = zdss_read ; <nl> + / * pass - through * / <nl> + <nl> + case zdss_read : <nl> + { size_t const neededInSize = ZSTD_nextSrcSizeToDecompress ( zds - > dctx ) ; <nl> + if ( neededInSize = = 0 ) { / * end of frame * / <nl> + zds - > stage = zdss_init ; <nl> + someMoreWork = 0 ; <nl> + break ; <nl> + } <nl> + if ( ( size_t ) ( iend - ip ) > = neededInSize ) { / * decode directly from src * / <nl> + const int isSkipFrame = ZSTD_isSkipFrame ( zds - > dctx ) ; <nl> + size_t const decodedSize = ZSTD_decompressContinue ( zds - > dctx , <nl> + zds - > outBuff + zds - > outStart , ( isSkipFrame ? 0 : zds - > outBuffSize - zds - > outStart ) , <nl> + ip , neededInSize ) ; <nl> + if ( ZSTD_isError ( decodedSize ) ) return decodedSize ; <nl> + ip + = neededInSize ; <nl> + if ( ! decodedSize & & ! isSkipFrame ) break ; / * this was just a header * / <nl> + zds - > outEnd = zds - > outStart + decodedSize ; <nl> + zds - > stage = zdss_flush ; <nl> + break ; <nl> + } <nl> + if ( ip = = iend ) { someMoreWork = 0 ; break ; } / * no more input * / <nl> + zds - > stage = zdss_load ; <nl> + / * pass - through * / <nl> + } <nl> + <nl> + case zdss_load : <nl> + { size_t const neededInSize = ZSTD_nextSrcSizeToDecompress ( zds - > dctx ) ; <nl> + size_t const toLoad = neededInSize - zds - > inPos ; / * should always be < = remaining space within inBuff * / <nl> + size_t loadedSize ; <nl> + if ( toLoad > zds - > inBuffSize - zds - > inPos ) return ERROR ( corruption_detected ) ; / * should never happen * / <nl> + loadedSize = ZSTD_limitCopy ( zds - > inBuff + zds - > inPos , toLoad , ip , iend - ip ) ; <nl> + ip + = loadedSize ; <nl> + zds - > inPos + = loadedSize ; <nl> + if ( loadedSize < toLoad ) { someMoreWork = 0 ; break ; } / * not enough input , wait for more * / <nl> + <nl> + / * decode loaded input * / <nl> + { const int isSkipFrame = ZSTD_isSkipFrame ( zds - > dctx ) ; <nl> + size_t const decodedSize = ZSTD_decompressContinue ( zds - > dctx , <nl> + zds - > outBuff + zds - > outStart , zds - > outBuffSize - zds - > outStart , <nl> + zds - > inBuff , neededInSize ) ; <nl> + if ( ZSTD_isError ( decodedSize ) ) return decodedSize ; <nl> + zds - > inPos = 0 ; / * input is consumed * / <nl> + if ( ! decodedSize & & ! isSkipFrame ) { zds - > stage = zdss_read ; break ; } / * this was just a header * / <nl> + zds - > outEnd = zds - > outStart + decodedSize ; <nl> + zds - > stage = zdss_flush ; <nl> + / * pass - through * / <nl> + } } <nl> + <nl> + case zdss_flush : <nl> + { size_t const toFlushSize = zds - > outEnd - zds - > outStart ; <nl> + size_t const flushedSize = ZSTD_limitCopy ( op , oend - op , zds - > outBuff + zds - > outStart , toFlushSize ) ; <nl> + op + = flushedSize ; <nl> + zds - > outStart + = flushedSize ; <nl> + if ( flushedSize = = toFlushSize ) { / * flush completed * / <nl> + zds - > stage = zdss_read ; <nl> + if ( zds - > outStart + zds - > blockSize > zds - > outBuffSize ) <nl> + zds - > outStart = zds - > outEnd = 0 ; <nl> + break ; <nl> + } <nl> + / * cannot complete flush * / <nl> + someMoreWork = 0 ; <nl> + break ; <nl> + } <nl> + default : return ERROR ( GENERIC ) ; / * impossible * / <nl> + } } <nl> + <nl> + / * result * / <nl> + input - > pos + = ( size_t ) ( ip - istart ) ; <nl> + output - > pos + = ( size_t ) ( op - ostart ) ; <nl> + { size_t nextSrcSizeHint = ZSTD_nextSrcSizeToDecompress ( zds - > dctx ) ; <nl> + if ( ! nextSrcSizeHint ) { / * frame fully decoded * / <nl> + if ( zds - > outEnd = = zds - > outStart ) { / * output fully flushed * / <nl> + if ( zds - > hostageByte ) { <nl> + if ( input - > pos > = input - > size ) { zds - > stage = zdss_read ; return 1 ; } / * can ' t release hostage ( not present ) * / <nl> + input - > pos + + ; / * release hostage * / <nl> + } <nl> + return 0 ; <nl> + } <nl> + if ( ! zds - > hostageByte ) { / * output not fully flushed ; keep last byte as hostage ; will be released when all output is flushed * / <nl> + input - > pos - - ; / * note : pos > 0 , otherwise , impossible to finish reading last block * / <nl> + zds - > hostageByte = 1 ; <nl> + } <nl> + return 1 ; <nl> + } <nl> + nextSrcSizeHint + = ZSTD_blockHeaderSize * ( ZSTD_nextInputType ( zds - > dctx ) = = ZSTDnit_block ) ; / * preload header of next block * / <nl> + if ( zds - > inPos > nextSrcSizeHint ) return ERROR ( GENERIC ) ; / * should never happen * / <nl> + nextSrcSizeHint - = zds - > inPos ; / * already loaded * / <nl> + return nextSrcSizeHint ; <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . f8050c13610 <nl> mmm / dev / null <nl> ppp b / thirdparty / zstd / zstd . h <nl> <nl> + / * <nl> + * Copyright ( c ) 2016 - present , Yann Collet , Facebook , Inc . <nl> + * All rights reserved . <nl> + * <nl> + * This source code is licensed under the BSD - style license found in the <nl> + * LICENSE file in the root directory of this source tree . An additional grant <nl> + * of patent rights can be found in the PATENTS file in the same directory . <nl> + * / <nl> + <nl> + # if defined ( __cplusplus ) <nl> + extern " C " { <nl> + # endif <nl> + <nl> + # ifndef ZSTD_H_235446 <nl> + # define ZSTD_H_235446 <nl> + <nl> + / * = = = = = = Dependency = = = = = = * / <nl> + # include < stddef . h > / * size_t * / <nl> + <nl> + <nl> + / * = = = = = ZSTDLIB_API : control library symbols visibility = = = = = * / <nl> + # if defined ( __GNUC__ ) & & ( __GNUC__ > = 4 ) <nl> + # define ZSTDLIB_VISIBILITY __attribute__ ( ( visibility ( " default " ) ) ) <nl> + # else <nl> + # define ZSTDLIB_VISIBILITY <nl> + # endif <nl> + # if defined ( ZSTD_DLL_EXPORT ) & & ( ZSTD_DLL_EXPORT = = 1 ) <nl> + # define ZSTDLIB_API __declspec ( dllexport ) ZSTDLIB_VISIBILITY <nl> + # elif defined ( ZSTD_DLL_IMPORT ) & & ( ZSTD_DLL_IMPORT = = 1 ) <nl> + # define ZSTDLIB_API __declspec ( dllimport ) ZSTDLIB_VISIBILITY / * It isn ' t required but allows to generate better code , saving a function pointer load from the IAT and an indirect jump . * / <nl> + # else <nl> + # define ZSTDLIB_API ZSTDLIB_VISIBILITY <nl> + # endif <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + Introduction <nl> + <nl> + zstd , short for Zstandard , is a fast lossless compression algorithm , targeting real - time compression scenarios <nl> + at zlib - level and better compression ratios . The zstd compression library provides in - memory compression and <nl> + decompression functions . The library supports compression levels from 1 up to ZSTD_maxCLevel ( ) which is 22 . <nl> + Levels > = 20 , labeled ` - - ultra ` , should be used with caution , as they require more memory . <nl> + Compression can be done in : <nl> + - a single step ( described as Simple API ) <nl> + - a single step , reusing a context ( described as Explicit memory management ) <nl> + - unbounded multiple steps ( described as Streaming compression ) <nl> + The compression ratio achievable on small data can be highly improved using compression with a dictionary in : <nl> + - a single step ( described as Simple dictionary API ) <nl> + - a single step , reusing a dictionary ( described as Fast dictionary API ) <nl> + <nl> + Advanced experimental functions can be accessed using # define ZSTD_STATIC_LINKING_ONLY before including zstd . h . <nl> + These APIs shall never be used with a dynamic library . <nl> + They are not " stable " , their definition may change in the future . Only static linking is allowed . <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + / * mmmmmm Version mmmmmm * / <nl> + # define ZSTD_VERSION_MAJOR 1 <nl> + # define ZSTD_VERSION_MINOR 2 <nl> + # define ZSTD_VERSION_RELEASE 0 <nl> + <nl> + # define ZSTD_LIB_VERSION ZSTD_VERSION_MAJOR . ZSTD_VERSION_MINOR . ZSTD_VERSION_RELEASE <nl> + # define ZSTD_QUOTE ( str ) # str <nl> + # define ZSTD_EXPAND_AND_QUOTE ( str ) ZSTD_QUOTE ( str ) <nl> + # define ZSTD_VERSION_STRING ZSTD_EXPAND_AND_QUOTE ( ZSTD_LIB_VERSION ) <nl> + <nl> + # define ZSTD_VERSION_NUMBER ( ZSTD_VERSION_MAJOR * 100 * 100 + ZSTD_VERSION_MINOR * 100 + ZSTD_VERSION_RELEASE ) <nl> + ZSTDLIB_API unsigned ZSTD_versionNumber ( void ) ; / * * < library version number ; to be used when checking dll version * / <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Simple API <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * ! ZSTD_compress ( ) : <nl> + * Compresses ` src ` content as a single zstd compressed frame into already allocated ` dst ` . <nl> + * Hint : compression runs faster if ` dstCapacity ` > = ` ZSTD_compressBound ( srcSize ) ` . <nl> + * @ return : compressed size written into ` dst ` ( < = ` dstCapacity ) , <nl> + * or an error code if it fails ( which can be tested using ZSTD_isError ( ) ) . * / <nl> + ZSTDLIB_API size_t ZSTD_compress ( void * dst , size_t dstCapacity , <nl> + const void * src , size_t srcSize , <nl> + int compressionLevel ) ; <nl> + <nl> + / * ! ZSTD_decompress ( ) : <nl> + * ` compressedSize ` : must be the _exact_ size of some number of compressed and / or skippable frames . <nl> + * ` dstCapacity ` is an upper bound of originalSize . <nl> + * If user cannot imply a maximum upper bound , it ' s better to use streaming mode to decompress data . <nl> + * @ return : the number of bytes decompressed into ` dst ` ( < = ` dstCapacity ` ) , <nl> + * or an errorCode if it fails ( which can be tested using ZSTD_isError ( ) ) . * / <nl> + ZSTDLIB_API size_t ZSTD_decompress ( void * dst , size_t dstCapacity , <nl> + const void * src , size_t compressedSize ) ; <nl> + <nl> + / * ! ZSTD_getDecompressedSize ( ) : <nl> + * NOTE : This function is planned to be obsolete , in favour of ZSTD_getFrameContentSize . <nl> + * ZSTD_getFrameContentSize functions the same way , returning the decompressed size of a single <nl> + * frame , but distinguishes empty frames from frames with an unknown size , or errors . <nl> + * <nl> + * Additionally , ZSTD_findDecompressedSize can be used instead . It can handle multiple <nl> + * concatenated frames in one buffer , and so is more general . <nl> + * As a result however , it requires more computation and entire frames to be passed to it , <nl> + * as opposed to ZSTD_getFrameContentSize which requires only a single frame ' s header . <nl> + * <nl> + * ' src ' is the start of a zstd compressed frame . <nl> + * @ return : content size to be decompressed , as a 64 - bits value _if known_ , 0 otherwise . <nl> + * note 1 : decompressed size is an optional field , that may not be present , especially in streaming mode . <nl> + * When ` return = = 0 ` , data to decompress could be any size . <nl> + * In which case , it ' s necessary to use streaming mode to decompress data . <nl> + * Optionally , application can still use ZSTD_decompress ( ) while relying on implied limits . <nl> + * ( For example , data may be necessarily cut into blocks < = 16 KB ) . <nl> + * note 2 : decompressed size is always present when compression is done with ZSTD_compress ( ) <nl> + * note 3 : decompressed size can be very large ( 64 - bits value ) , <nl> + * potentially larger than what local system can handle as a single memory segment . <nl> + * In which case , it ' s necessary to use streaming mode to decompress data . <nl> + * note 4 : If source is untrusted , decompressed size could be wrong or intentionally modified . <nl> + * Always ensure result fits within application ' s authorized limits . <nl> + * Each application can set its own limits . <nl> + * note 5 : when ` return = = 0 ` , if precise failure cause is needed , use ZSTD_getFrameParams ( ) to know more . * / <nl> + ZSTDLIB_API unsigned long long ZSTD_getDecompressedSize ( const void * src , size_t srcSize ) ; <nl> + <nl> + <nl> + / * = = = = = = Helper functions = = = = = = * / <nl> + ZSTDLIB_API int ZSTD_maxCLevel ( void ) ; / * ! < maximum compression level available * / <nl> + ZSTDLIB_API size_t ZSTD_compressBound ( size_t srcSize ) ; / * ! < maximum compressed size in worst case scenario * / <nl> + ZSTDLIB_API unsigned ZSTD_isError ( size_t code ) ; / * ! < tells if a ` size_t ` function result is an error code * / <nl> + ZSTDLIB_API const char * ZSTD_getErrorName ( size_t code ) ; / * ! < provides readable string from an error code * / <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Explicit memory management <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * = Compression context <nl> + * When compressing many times , <nl> + * it is recommended to allocate a context just once , and re - use it for each successive compression operation . <nl> + * This will make workload friendlier for system ' s memory . <nl> + * Use one context per thread for parallel execution in multi - threaded environments . * / <nl> + typedef struct ZSTD_CCtx_s ZSTD_CCtx ; <nl> + ZSTDLIB_API ZSTD_CCtx * ZSTD_createCCtx ( void ) ; <nl> + ZSTDLIB_API size_t ZSTD_freeCCtx ( ZSTD_CCtx * cctx ) ; <nl> + <nl> + / * ! ZSTD_compressCCtx ( ) : <nl> + * Same as ZSTD_compress ( ) , requires an allocated ZSTD_CCtx ( see ZSTD_createCCtx ( ) ) . * / <nl> + ZSTDLIB_API size_t ZSTD_compressCCtx ( ZSTD_CCtx * ctx , void * dst , size_t dstCapacity , const void * src , size_t srcSize , int compressionLevel ) ; <nl> + <nl> + / * = Decompression context <nl> + * When decompressing many times , <nl> + * it is recommended to allocate a context just once , and re - use it for each successive compression operation . <nl> + * This will make workload friendlier for system ' s memory . <nl> + * Use one context per thread for parallel execution in multi - threaded environments . * / <nl> + typedef struct ZSTD_DCtx_s ZSTD_DCtx ; <nl> + ZSTDLIB_API ZSTD_DCtx * ZSTD_createDCtx ( void ) ; <nl> + ZSTDLIB_API size_t ZSTD_freeDCtx ( ZSTD_DCtx * dctx ) ; <nl> + <nl> + / * ! ZSTD_decompressDCtx ( ) : <nl> + * Same as ZSTD_decompress ( ) , requires an allocated ZSTD_DCtx ( see ZSTD_createDCtx ( ) ) . * / <nl> + ZSTDLIB_API size_t ZSTD_decompressDCtx ( ZSTD_DCtx * ctx , void * dst , size_t dstCapacity , const void * src , size_t srcSize ) ; <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Simple dictionary API <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * ! ZSTD_compress_usingDict ( ) : <nl> + * Compression using a predefined Dictionary ( see dictBuilder / zdict . h ) . <nl> + * Note : This function loads the dictionary , resulting in significant startup delay . <nl> + * Note : When ` dict = = NULL | | dictSize < 8 ` no dictionary is used . * / <nl> + ZSTDLIB_API size_t ZSTD_compress_usingDict ( ZSTD_CCtx * ctx , <nl> + void * dst , size_t dstCapacity , <nl> + const void * src , size_t srcSize , <nl> + const void * dict , size_t dictSize , <nl> + int compressionLevel ) ; <nl> + <nl> + / * ! ZSTD_decompress_usingDict ( ) : <nl> + * Decompression using a predefined Dictionary ( see dictBuilder / zdict . h ) . <nl> + * Dictionary must be identical to the one used during compression . <nl> + * Note : This function loads the dictionary , resulting in significant startup delay . <nl> + * Note : When ` dict = = NULL | | dictSize < 8 ` no dictionary is used . * / <nl> + ZSTDLIB_API size_t ZSTD_decompress_usingDict ( ZSTD_DCtx * dctx , <nl> + void * dst , size_t dstCapacity , <nl> + const void * src , size_t srcSize , <nl> + const void * dict , size_t dictSize ) ; <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Fast dictionary API <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + typedef struct ZSTD_CDict_s ZSTD_CDict ; <nl> + <nl> + / * ! ZSTD_createCDict ( ) : <nl> + * When compressing multiple messages / blocks with the same dictionary , it ' s recommended to load it just once . <nl> + * ZSTD_createCDict ( ) will create a digested dictionary , ready to start future compression operations without startup delay . <nl> + * ZSTD_CDict can be created once and used by multiple threads concurrently , as its usage is read - only . <nl> + * ` dictBuffer ` can be released after ZSTD_CDict creation , as its content is copied within CDict * / <nl> + ZSTDLIB_API ZSTD_CDict * ZSTD_createCDict ( const void * dictBuffer , size_t dictSize , int compressionLevel ) ; <nl> + <nl> + / * ! ZSTD_freeCDict ( ) : <nl> + * Function frees memory allocated by ZSTD_createCDict ( ) . * / <nl> + ZSTDLIB_API size_t ZSTD_freeCDict ( ZSTD_CDict * CDict ) ; <nl> + <nl> + / * ! ZSTD_compress_usingCDict ( ) : <nl> + * Compression using a digested Dictionary . <nl> + * Faster startup than ZSTD_compress_usingDict ( ) , recommended when same dictionary is used multiple times . <nl> + * Note that compression level is decided during dictionary creation . <nl> + * Frame parameters are hardcoded ( dictID = yes , contentSize = yes , checksum = no ) * / <nl> + ZSTDLIB_API size_t ZSTD_compress_usingCDict ( ZSTD_CCtx * cctx , <nl> + void * dst , size_t dstCapacity , <nl> + const void * src , size_t srcSize , <nl> + const ZSTD_CDict * cdict ) ; <nl> + <nl> + <nl> + typedef struct ZSTD_DDict_s ZSTD_DDict ; <nl> + <nl> + / * ! ZSTD_createDDict ( ) : <nl> + * Create a digested dictionary , ready to start decompression operation without startup delay . <nl> + * dictBuffer can be released after DDict creation , as its content is copied inside DDict * / <nl> + ZSTDLIB_API ZSTD_DDict * ZSTD_createDDict ( const void * dictBuffer , size_t dictSize ) ; <nl> + <nl> + / * ! ZSTD_freeDDict ( ) : <nl> + * Function frees memory allocated with ZSTD_createDDict ( ) * / <nl> + ZSTDLIB_API size_t ZSTD_freeDDict ( ZSTD_DDict * ddict ) ; <nl> + <nl> + / * ! ZSTD_decompress_usingDDict ( ) : <nl> + * Decompression using a digested Dictionary . <nl> + * Faster startup than ZSTD_decompress_usingDict ( ) , recommended when same dictionary is used multiple times . * / <nl> + ZSTDLIB_API size_t ZSTD_decompress_usingDDict ( ZSTD_DCtx * dctx , <nl> + void * dst , size_t dstCapacity , <nl> + const void * src , size_t srcSize , <nl> + const ZSTD_DDict * ddict ) ; <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Streaming <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + typedef struct ZSTD_inBuffer_s { <nl> + const void * src ; / * * < start of input buffer * / <nl> + size_t size ; / * * < size of input buffer * / <nl> + size_t pos ; / * * < position where reading stopped . Will be updated . Necessarily 0 < = pos < = size * / <nl> + } ZSTD_inBuffer ; <nl> + <nl> + typedef struct ZSTD_outBuffer_s { <nl> + void * dst ; / * * < start of output buffer * / <nl> + size_t size ; / * * < size of output buffer * / <nl> + size_t pos ; / * * < position where writing stopped . Will be updated . Necessarily 0 < = pos < = size * / <nl> + } ZSTD_outBuffer ; <nl> + <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Streaming compression - HowTo <nl> + * <nl> + * A ZSTD_CStream object is required to track streaming operation . <nl> + * Use ZSTD_createCStream ( ) and ZSTD_freeCStream ( ) to create / release resources . <nl> + * ZSTD_CStream objects can be reused multiple times on consecutive compression operations . <nl> + * It is recommended to re - use ZSTD_CStream in situations where many streaming operations will be achieved consecutively , <nl> + * since it will play nicer with system ' s memory , by re - using already allocated memory . <nl> + * Use one separate ZSTD_CStream per thread for parallel execution . <nl> + * <nl> + * Start a new compression by initializing ZSTD_CStream . <nl> + * Use ZSTD_initCStream ( ) to start a new compression operation . <nl> + * Use ZSTD_initCStream_usingDict ( ) or ZSTD_initCStream_usingCDict ( ) for a compression which requires a dictionary ( experimental section ) <nl> + * <nl> + * Use ZSTD_compressStream ( ) repetitively to consume input stream . <nl> + * The function will automatically update both ` pos ` fields . <nl> + * Note that it may not consume the entire input , in which case ` pos < size ` , <nl> + * and it ' s up to the caller to present again remaining data . <nl> + * @ return : a size hint , preferred nb of bytes to use as input for next function call <nl> + * or an error code , which can be tested using ZSTD_isError ( ) . <nl> + * Note 1 : it ' s just a hint , to help latency a little , any other value will work fine . <nl> + * Note 2 : size hint is guaranteed to be < = ZSTD_CStreamInSize ( ) <nl> + * <nl> + * At any moment , it ' s possible to flush whatever data remains within internal buffer , using ZSTD_flushStream ( ) . <nl> + * ` output - > pos ` will be updated . <nl> + * Note that some content might still be left within internal buffer if ` output - > size ` is too small . <nl> + * @ return : nb of bytes still present within internal buffer ( 0 if it ' s empty ) <nl> + * or an error code , which can be tested using ZSTD_isError ( ) . <nl> + * <nl> + * ZSTD_endStream ( ) instructs to finish a frame . <nl> + * It will perform a flush and write frame epilogue . <nl> + * The epilogue is required for decoders to consider a frame completed . <nl> + * Similar to ZSTD_flushStream ( ) , it may not be able to flush the full content if ` output - > size ` is too small . <nl> + * In which case , call again ZSTD_endStream ( ) to complete the flush . <nl> + * @ return : nb of bytes still present within internal buffer ( 0 if it ' s empty , hence compression completed ) <nl> + * or an error code , which can be tested using ZSTD_isError ( ) . <nl> + * <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + typedef struct ZSTD_CStream_s ZSTD_CStream ; <nl> + / * = = = = = ZSTD_CStream management functions = = = = = * / <nl> + ZSTDLIB_API ZSTD_CStream * ZSTD_createCStream ( void ) ; <nl> + ZSTDLIB_API size_t ZSTD_freeCStream ( ZSTD_CStream * zcs ) ; <nl> + <nl> + / * = = = = = Streaming compression functions = = = = = * / <nl> + ZSTDLIB_API size_t ZSTD_initCStream ( ZSTD_CStream * zcs , int compressionLevel ) ; <nl> + ZSTDLIB_API size_t ZSTD_compressStream ( ZSTD_CStream * zcs , ZSTD_outBuffer * output , ZSTD_inBuffer * input ) ; <nl> + ZSTDLIB_API size_t ZSTD_flushStream ( ZSTD_CStream * zcs , ZSTD_outBuffer * output ) ; <nl> + ZSTDLIB_API size_t ZSTD_endStream ( ZSTD_CStream * zcs , ZSTD_outBuffer * output ) ; <nl> + <nl> + ZSTDLIB_API size_t ZSTD_CStreamInSize ( void ) ; / * * < recommended size for input buffer * / <nl> + ZSTDLIB_API size_t ZSTD_CStreamOutSize ( void ) ; / * * < recommended size for output buffer . Guarantee to successfully flush at least one complete compressed block in all circumstances . * / <nl> + <nl> + <nl> + <nl> + / * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Streaming decompression - HowTo <nl> + * <nl> + * A ZSTD_DStream object is required to track streaming operations . <nl> + * Use ZSTD_createDStream ( ) and ZSTD_freeDStream ( ) to create / release resources . <nl> + * ZSTD_DStream objects can be re - used multiple times . <nl> + * <nl> + * Use ZSTD_initDStream ( ) to start a new decompression operation , <nl> + * or ZSTD_initDStream_usingDict ( ) if decompression requires a dictionary . <nl> + * @ return : recommended first input size <nl> + * <nl> + * Use ZSTD_decompressStream ( ) repetitively to consume your input . <nl> + * The function will update both ` pos ` fields . <nl> + * If ` input . pos < input . size ` , some input has not been consumed . <nl> + * It ' s up to the caller to present again remaining data . <nl> + * If ` output . pos < output . size ` , decoder has flushed everything it could . <nl> + * @ return : 0 when a frame is completely decoded and fully flushed , <nl> + * an error code , which can be tested using ZSTD_isError ( ) , <nl> + * any other value > 0 , which means there is still some decoding to do to complete current frame . <nl> + * The return value is a suggested next input size ( a hint to improve latency ) that will never load more than the current frame . <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + typedef struct ZSTD_DStream_s ZSTD_DStream ; <nl> + / * = = = = = ZSTD_DStream management functions = = = = = * / <nl> + ZSTDLIB_API ZSTD_DStream * ZSTD_createDStream ( void ) ; <nl> + ZSTDLIB_API size_t ZSTD_freeDStream ( ZSTD_DStream * zds ) ; <nl> + <nl> + / * = = = = = Streaming decompression functions = = = = = * / <nl> + ZSTDLIB_API size_t ZSTD_initDStream ( ZSTD_DStream * zds ) ; <nl> + ZSTDLIB_API size_t ZSTD_decompressStream ( ZSTD_DStream * zds , ZSTD_outBuffer * output , ZSTD_inBuffer * input ) ; <nl> + <nl> + ZSTDLIB_API size_t ZSTD_DStreamInSize ( void ) ; / * ! < recommended size for input buffer * / <nl> + ZSTDLIB_API size_t ZSTD_DStreamOutSize ( void ) ; / * ! < recommended size for output buffer . Guarantee to successfully flush at least one complete block in all circumstances . * / <nl> + <nl> + # endif / * ZSTD_H_235446 * / <nl> + <nl> + <nl> + # if defined ( ZSTD_STATIC_LINKING_ONLY ) & & ! defined ( ZSTD_H_ZSTD_STATIC_LINKING_ONLY ) <nl> + # define ZSTD_H_ZSTD_STATIC_LINKING_ONLY <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * START OF ADVANCED AND EXPERIMENTAL FUNCTIONS <nl> + * The definitions in this section are considered experimental . <nl> + * They should never be used with a dynamic library , as they may change in the future . <nl> + * They are provided for advanced usages . <nl> + * Use them only in association with static linking . <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + / * mmm Constants mmm * / <nl> + # define ZSTD_MAGICNUMBER 0xFD2FB528 / * > = v0 . 8 . 0 * / <nl> + # define ZSTD_MAGIC_SKIPPABLE_START 0x184D2A50U <nl> + <nl> + # define ZSTD_CONTENTSIZE_UNKNOWN ( 0ULL - 1 ) <nl> + # define ZSTD_CONTENTSIZE_ERROR ( 0ULL - 2 ) <nl> + <nl> + # define ZSTD_WINDOWLOG_MAX_32 27 <nl> + # define ZSTD_WINDOWLOG_MAX_64 27 <nl> + # define ZSTD_WINDOWLOG_MAX ( ( unsigned ) ( sizeof ( size_t ) = = 4 ? ZSTD_WINDOWLOG_MAX_32 : ZSTD_WINDOWLOG_MAX_64 ) ) <nl> + # define ZSTD_WINDOWLOG_MIN 10 <nl> + # define ZSTD_HASHLOG_MAX ZSTD_WINDOWLOG_MAX <nl> + # define ZSTD_HASHLOG_MIN 6 <nl> + # define ZSTD_CHAINLOG_MAX ( ZSTD_WINDOWLOG_MAX + 1 ) <nl> + # define ZSTD_CHAINLOG_MIN ZSTD_HASHLOG_MIN <nl> + # define ZSTD_HASHLOG3_MAX 17 <nl> + # define ZSTD_SEARCHLOG_MAX ( ZSTD_WINDOWLOG_MAX - 1 ) <nl> + # define ZSTD_SEARCHLOG_MIN 1 <nl> + # define ZSTD_SEARCHLENGTH_MAX 7 / * only for ZSTD_fast , other strategies are limited to 6 * / <nl> + # define ZSTD_SEARCHLENGTH_MIN 3 / * only for ZSTD_btopt , other strategies are limited to 4 * / <nl> + # define ZSTD_TARGETLENGTH_MIN 4 <nl> + # define ZSTD_TARGETLENGTH_MAX 999 <nl> + <nl> + # define ZSTD_FRAMEHEADERSIZE_MAX 18 / * for static allocation * / <nl> + # define ZSTD_FRAMEHEADERSIZE_MIN 6 <nl> + static const size_t ZSTD_frameHeaderSize_prefix = 5 ; <nl> + static const size_t ZSTD_frameHeaderSize_min = ZSTD_FRAMEHEADERSIZE_MIN ; <nl> + static const size_t ZSTD_frameHeaderSize_max = ZSTD_FRAMEHEADERSIZE_MAX ; <nl> + static const size_t ZSTD_skippableHeaderSize = 8 ; / * magic number + skippable frame length * / <nl> + <nl> + <nl> + / * mmm Advanced types mmm * / <nl> + typedef enum { ZSTD_fast , ZSTD_dfast , ZSTD_greedy , ZSTD_lazy , ZSTD_lazy2 , ZSTD_btlazy2 , ZSTD_btopt , ZSTD_btopt2 } ZSTD_strategy ; / * from faster to stronger * / <nl> + <nl> + typedef struct { <nl> + unsigned windowLog ; / * * < largest match distance : larger = = more compression , more memory needed during decompression * / <nl> + unsigned chainLog ; / * * < fully searched segment : larger = = more compression , slower , more memory ( useless for fast ) * / <nl> + unsigned hashLog ; / * * < dispatch table : larger = = faster , more memory * / <nl> + unsigned searchLog ; / * * < nb of searches : larger = = more compression , slower * / <nl> + unsigned searchLength ; / * * < match length searched : larger = = faster decompression , sometimes less compression * / <nl> + unsigned targetLength ; / * * < acceptable match size for optimal parser ( only ) : larger = = more compression , slower * / <nl> + ZSTD_strategy strategy ; <nl> + } ZSTD_compressionParameters ; <nl> + <nl> + typedef struct { <nl> + unsigned contentSizeFlag ; / * * < 1 : content size will be in frame header ( when known ) * / <nl> + unsigned checksumFlag ; / * * < 1 : generate a 32 - bits checksum at end of frame , for error detection * / <nl> + unsigned noDictIDFlag ; / * * < 1 : no dictID will be saved into frame header ( if dictionary compression ) * / <nl> + } ZSTD_frameParameters ; <nl> + <nl> + typedef struct { <nl> + ZSTD_compressionParameters cParams ; <nl> + ZSTD_frameParameters fParams ; <nl> + } ZSTD_parameters ; <nl> + <nl> + / * = Custom memory allocation functions * / <nl> + typedef void * ( * ZSTD_allocFunction ) ( void * opaque , size_t size ) ; <nl> + typedef void ( * ZSTD_freeFunction ) ( void * opaque , void * address ) ; <nl> + typedef struct { ZSTD_allocFunction customAlloc ; ZSTD_freeFunction customFree ; void * opaque ; } ZSTD_customMem ; <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Compressed size functions <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + / * ! ZSTD_findFrameCompressedSize ( ) : <nl> + * ` src ` should point to the start of a ZSTD encoded frame or skippable frame <nl> + * ` srcSize ` must be at least as large as the frame <nl> + * @ return : the compressed size of the frame pointed to by ` src ` , suitable to pass to <nl> + * ` ZSTD_decompress ` or similar , or an error code if given invalid input . * / <nl> + ZSTDLIB_API size_t ZSTD_findFrameCompressedSize ( const void * src , size_t srcSize ) ; <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Decompressed size functions <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * ! ZSTD_getFrameContentSize ( ) : <nl> + * ` src ` should point to the start of a ZSTD encoded frame <nl> + * ` srcSize ` must be at least as large as the frame header . A value greater than or equal <nl> + * to ` ZSTD_frameHeaderSize_max ` is guaranteed to be large enough in all cases . <nl> + * @ return : decompressed size of the frame pointed to be ` src ` if known , otherwise <nl> + * - ZSTD_CONTENTSIZE_UNKNOWN if the size cannot be determined <nl> + * - ZSTD_CONTENTSIZE_ERROR if an error occurred ( e . g . invalid magic number , srcSize too small ) * / <nl> + ZSTDLIB_API unsigned long long ZSTD_getFrameContentSize ( const void * src , size_t srcSize ) ; <nl> + <nl> + / * ! ZSTD_findDecompressedSize ( ) : <nl> + * ` src ` should point the start of a series of ZSTD encoded and / or skippable frames <nl> + * ` srcSize ` must be the _exact_ size of this series <nl> + * ( i . e . there should be a frame boundary exactly ` srcSize ` bytes after ` src ` ) <nl> + * @ return : the decompressed size of all data in the contained frames , as a 64 - bit value _if known_ <nl> + * - if the decompressed size cannot be determined : ZSTD_CONTENTSIZE_UNKNOWN <nl> + * - if an error occurred : ZSTD_CONTENTSIZE_ERROR <nl> + * <nl> + * note 1 : decompressed size is an optional field , that may not be present , especially in streaming mode . <nl> + * When ` return = = ZSTD_CONTENTSIZE_UNKNOWN ` , data to decompress could be any size . <nl> + * In which case , it ' s necessary to use streaming mode to decompress data . <nl> + * Optionally , application can still use ZSTD_decompress ( ) while relying on implied limits . <nl> + * ( For example , data may be necessarily cut into blocks < = 16 KB ) . <nl> + * note 2 : decompressed size is always present when compression is done with ZSTD_compress ( ) <nl> + * note 3 : decompressed size can be very large ( 64 - bits value ) , <nl> + * potentially larger than what local system can handle as a single memory segment . <nl> + * In which case , it ' s necessary to use streaming mode to decompress data . <nl> + * note 4 : If source is untrusted , decompressed size could be wrong or intentionally modified . <nl> + * Always ensure result fits within application ' s authorized limits . <nl> + * Each application can set its own limits . <nl> + * note 5 : ZSTD_findDecompressedSize handles multiple frames , and so it must traverse the input to <nl> + * read each contained frame header . This is efficient as most of the data is skipped , <nl> + * however it does mean that all frame data must be present and valid . * / <nl> + ZSTDLIB_API unsigned long long ZSTD_findDecompressedSize ( const void * src , size_t srcSize ) ; <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Advanced compression functions <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * ! ZSTD_estimateCCtxSize ( ) : <nl> + * Gives the amount of memory allocated for a ZSTD_CCtx given a set of compression parameters . <nl> + * ` frameContentSize ` is an optional parameter , provide ` 0 ` if unknown * / <nl> + ZSTDLIB_API size_t ZSTD_estimateCCtxSize ( ZSTD_compressionParameters cParams ) ; <nl> + <nl> + / * ! ZSTD_createCCtx_advanced ( ) : <nl> + * Create a ZSTD compression context using external alloc and free functions * / <nl> + ZSTDLIB_API ZSTD_CCtx * ZSTD_createCCtx_advanced ( ZSTD_customMem customMem ) ; <nl> + <nl> + / * ! ZSTD_sizeofCCtx ( ) : <nl> + * Gives the amount of memory used by a given ZSTD_CCtx * / <nl> + ZSTDLIB_API size_t ZSTD_sizeof_CCtx ( const ZSTD_CCtx * cctx ) ; <nl> + <nl> + typedef enum { <nl> + ZSTD_p_forceWindow , / * Force back - references to remain < windowSize , even when referencing Dictionary content ( default : 0 ) * / <nl> + ZSTD_p_forceRawDict / * Force loading dictionary in " content - only " mode ( no header analysis ) * / <nl> + } ZSTD_CCtxParameter ; <nl> + / * ! ZSTD_setCCtxParameter ( ) : <nl> + * Set advanced parameters , selected through enum ZSTD_CCtxParameter <nl> + * @ result : 0 , or an error code ( which can be tested with ZSTD_isError ( ) ) * / <nl> + ZSTDLIB_API size_t ZSTD_setCCtxParameter ( ZSTD_CCtx * cctx , ZSTD_CCtxParameter param , unsigned value ) ; <nl> + <nl> + / * ! ZSTD_createCDict_byReference ( ) : <nl> + * Create a digested dictionary for compression <nl> + * Dictionary content is simply referenced , and therefore stays in dictBuffer . <nl> + * It is important that dictBuffer outlives CDict , it must remain read accessible throughout the lifetime of CDict * / <nl> + ZSTDLIB_API ZSTD_CDict * ZSTD_createCDict_byReference ( const void * dictBuffer , size_t dictSize , int compressionLevel ) ; <nl> + <nl> + / * ! ZSTD_createCDict_advanced ( ) : <nl> + * Create a ZSTD_CDict using external alloc and free , and customized compression parameters * / <nl> + ZSTDLIB_API ZSTD_CDict * ZSTD_createCDict_advanced ( const void * dict , size_t dictSize , unsigned byReference , <nl> + ZSTD_compressionParameters cParams , ZSTD_customMem customMem ) ; <nl> + <nl> + / * ! ZSTD_sizeof_CDict ( ) : <nl> + * Gives the amount of memory used by a given ZSTD_sizeof_CDict * / <nl> + ZSTDLIB_API size_t ZSTD_sizeof_CDict ( const ZSTD_CDict * cdict ) ; <nl> + <nl> + / * ! ZSTD_getCParams ( ) : <nl> + * @ return ZSTD_compressionParameters structure for a selected compression level and estimated srcSize . <nl> + * ` estimatedSrcSize ` value is optional , select 0 if not known * / <nl> + ZSTDLIB_API ZSTD_compressionParameters ZSTD_getCParams ( int compressionLevel , unsigned long long estimatedSrcSize , size_t dictSize ) ; <nl> + <nl> + / * ! ZSTD_getParams ( ) : <nl> + * same as ZSTD_getCParams ( ) , but @ return a full ` ZSTD_parameters ` object instead of sub - component ` ZSTD_compressionParameters ` . <nl> + * All fields of ` ZSTD_frameParameters ` are set to default ( 0 ) * / <nl> + ZSTDLIB_API ZSTD_parameters ZSTD_getParams ( int compressionLevel , unsigned long long estimatedSrcSize , size_t dictSize ) ; <nl> + <nl> + / * ! ZSTD_checkCParams ( ) : <nl> + * Ensure param values remain within authorized range * / <nl> + ZSTDLIB_API size_t ZSTD_checkCParams ( ZSTD_compressionParameters params ) ; <nl> + <nl> + / * ! ZSTD_adjustCParams ( ) : <nl> + * optimize params for a given ` srcSize ` and ` dictSize ` . <nl> + * both values are optional , select ` 0 ` if unknown . * / <nl> + ZSTDLIB_API ZSTD_compressionParameters ZSTD_adjustCParams ( ZSTD_compressionParameters cPar , unsigned long long srcSize , size_t dictSize ) ; <nl> + <nl> + / * ! ZSTD_compress_advanced ( ) : <nl> + * Same as ZSTD_compress_usingDict ( ) , with fine - tune control over each compression parameter * / <nl> + ZSTDLIB_API size_t ZSTD_compress_advanced ( ZSTD_CCtx * cctx , <nl> + void * dst , size_t dstCapacity , <nl> + const void * src , size_t srcSize , <nl> + const void * dict , size_t dictSize , <nl> + ZSTD_parameters params ) ; <nl> + <nl> + / * ! ZSTD_compress_usingCDict_advanced ( ) : <nl> + * Same as ZSTD_compress_usingCDict ( ) , with fine - tune control over frame parameters * / <nl> + ZSTDLIB_API size_t ZSTD_compress_usingCDict_advanced ( ZSTD_CCtx * cctx , <nl> + void * dst , size_t dstCapacity , <nl> + const void * src , size_t srcSize , <nl> + const ZSTD_CDict * cdict , ZSTD_frameParameters fParams ) ; <nl> + <nl> + <nl> + / * mmm Advanced decompression functions mmm * / <nl> + <nl> + / * ! ZSTD_isFrame ( ) : <nl> + * Tells if the content of ` buffer ` starts with a valid Frame Identifier . <nl> + * Note : Frame Identifier is 4 bytes . If ` size < 4 ` , @ return will always be 0 . <nl> + * Note 2 : Legacy Frame Identifiers are considered valid only if Legacy Support is enabled . <nl> + * Note 3 : Skippable Frame Identifiers are considered valid . * / <nl> + ZSTDLIB_API unsigned ZSTD_isFrame ( const void * buffer , size_t size ) ; <nl> + <nl> + / * ! ZSTD_estimateDCtxSize ( ) : <nl> + * Gives the potential amount of memory allocated to create a ZSTD_DCtx * / <nl> + ZSTDLIB_API size_t ZSTD_estimateDCtxSize ( void ) ; <nl> + <nl> + / * ! ZSTD_createDCtx_advanced ( ) : <nl> + * Create a ZSTD decompression context using external alloc and free functions * / <nl> + ZSTDLIB_API ZSTD_DCtx * ZSTD_createDCtx_advanced ( ZSTD_customMem customMem ) ; <nl> + <nl> + / * ! ZSTD_sizeof_DCtx ( ) : <nl> + * Gives the amount of memory used by a given ZSTD_DCtx * / <nl> + ZSTDLIB_API size_t ZSTD_sizeof_DCtx ( const ZSTD_DCtx * dctx ) ; <nl> + <nl> + / * ! ZSTD_createDDict_byReference ( ) : <nl> + * Create a digested dictionary , ready to start decompression operation without startup delay . <nl> + * Dictionary content is simply referenced , and therefore stays in dictBuffer . <nl> + * It is important that dictBuffer outlives DDict , it must remain read accessible throughout the lifetime of DDict * / <nl> + ZSTDLIB_API ZSTD_DDict * ZSTD_createDDict_byReference ( const void * dictBuffer , size_t dictSize ) ; <nl> + <nl> + / * ! ZSTD_createDDict_advanced ( ) : <nl> + * Create a ZSTD_DDict using external alloc and free , optionally by reference * / <nl> + ZSTDLIB_API ZSTD_DDict * ZSTD_createDDict_advanced ( const void * dict , size_t dictSize , <nl> + unsigned byReference , ZSTD_customMem customMem ) ; <nl> + <nl> + / * ! ZSTD_sizeof_DDict ( ) : <nl> + * Gives the amount of memory used by a given ZSTD_DDict * / <nl> + ZSTDLIB_API size_t ZSTD_sizeof_DDict ( const ZSTD_DDict * ddict ) ; <nl> + <nl> + / * ! ZSTD_getDictID_fromDict ( ) : <nl> + * Provides the dictID stored within dictionary . <nl> + * if @ return = = 0 , the dictionary is not conformant with Zstandard specification . <nl> + * It can still be loaded , but as a content - only dictionary . * / <nl> + ZSTDLIB_API unsigned ZSTD_getDictID_fromDict ( const void * dict , size_t dictSize ) ; <nl> + <nl> + / * ! ZSTD_getDictID_fromDDict ( ) : <nl> + * Provides the dictID of the dictionary loaded into ` ddict ` . <nl> + * If @ return = = 0 , the dictionary is not conformant to Zstandard specification , or empty . <nl> + * Non - conformant dictionaries can still be loaded , but as content - only dictionaries . * / <nl> + ZSTDLIB_API unsigned ZSTD_getDictID_fromDDict ( const ZSTD_DDict * ddict ) ; <nl> + <nl> + / * ! ZSTD_getDictID_fromFrame ( ) : <nl> + * Provides the dictID required to decompressed the frame stored within ` src ` . <nl> + * If @ return = = 0 , the dictID could not be decoded . <nl> + * This could for one of the following reasons : <nl> + * - The frame does not require a dictionary to be decoded ( most common case ) . <nl> + * - The frame was built with dictID intentionally removed . Whatever dictionary is necessary is a hidden information . <nl> + * Note : this use case also happens when using a non - conformant dictionary . <nl> + * - ` srcSize ` is too small , and as a result , the frame header could not be decoded ( only possible if ` srcSize < ZSTD_FRAMEHEADERSIZE_MAX ` ) . <nl> + * - This is not a Zstandard frame . <nl> + * When identifying the exact failure cause , it ' s possible to use ZSTD_getFrameParams ( ) , which will provide a more precise error code . * / <nl> + ZSTDLIB_API unsigned ZSTD_getDictID_fromFrame ( const void * src , size_t srcSize ) ; <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Advanced streaming functions <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + / * = = = = = Advanced Streaming compression functions = = = = = * / <nl> + ZSTDLIB_API ZSTD_CStream * ZSTD_createCStream_advanced ( ZSTD_customMem customMem ) ; <nl> + ZSTDLIB_API size_t ZSTD_sizeof_CStream ( const ZSTD_CStream * zcs ) ; / * * < size of CStream is variable , depending primarily on compression level * / <nl> + ZSTDLIB_API size_t ZSTD_initCStream_srcSize ( ZSTD_CStream * zcs , int compressionLevel , unsigned long long pledgedSrcSize ) ; / * * < pledgedSrcSize must be correct , a size of 0 means unknown . for a frame size of 0 use initCStream_advanced * / <nl> + ZSTDLIB_API size_t ZSTD_initCStream_usingDict ( ZSTD_CStream * zcs , const void * dict , size_t dictSize , int compressionLevel ) ; / * * < note : a dict will not be used if dict = = NULL or dictSize < 8 * / <nl> + ZSTDLIB_API size_t ZSTD_initCStream_advanced ( ZSTD_CStream * zcs , const void * dict , size_t dictSize , <nl> + ZSTD_parameters params , unsigned long long pledgedSrcSize ) ; / * * < pledgedSrcSize is optional and can be 0 ( meaning unknown ) . note : if the contentSizeFlag is set , pledgedSrcSize = = 0 means the source size is actually 0 * / <nl> + ZSTDLIB_API size_t ZSTD_initCStream_usingCDict ( ZSTD_CStream * zcs , const ZSTD_CDict * cdict ) ; / * * < note : cdict will just be referenced , and must outlive compression session * / <nl> + ZSTDLIB_API size_t ZSTD_initCStream_usingCDict_advanced ( ZSTD_CStream * zcs , const ZSTD_CDict * cdict , unsigned long long pledgedSrcSize , ZSTD_frameParameters fParams ) ; / * * < same as ZSTD_initCStream_usingCDict ( ) , with control over frame parameters * / <nl> + <nl> + / * ! ZSTD_resetCStream ( ) : <nl> + * start a new compression job , using same parameters from previous job . <nl> + * This is typically useful to skip dictionary loading stage , since it will re - use it in - place . . <nl> + * Note that zcs must be init at least once before using ZSTD_resetCStream ( ) . <nl> + * pledgedSrcSize = = 0 means " srcSize unknown " . <nl> + * If pledgedSrcSize > 0 , its value must be correct , as it will be written in header , and controlled at the end . <nl> + * @ return : 0 , or an error code ( which can be tested using ZSTD_isError ( ) ) * / <nl> + ZSTDLIB_API size_t ZSTD_resetCStream ( ZSTD_CStream * zcs , unsigned long long pledgedSrcSize ) ; <nl> + <nl> + <nl> + / * = = = = = Advanced Streaming decompression functions = = = = = * / <nl> + typedef enum { DStream_p_maxWindowSize } ZSTD_DStreamParameter_e ; <nl> + ZSTDLIB_API ZSTD_DStream * ZSTD_createDStream_advanced ( ZSTD_customMem customMem ) ; <nl> + ZSTDLIB_API size_t ZSTD_initDStream_usingDict ( ZSTD_DStream * zds , const void * dict , size_t dictSize ) ; / * * < note : a dict will not be used if dict = = NULL or dictSize < 8 * / <nl> + ZSTDLIB_API size_t ZSTD_setDStreamParameter ( ZSTD_DStream * zds , ZSTD_DStreamParameter_e paramType , unsigned paramValue ) ; <nl> + ZSTDLIB_API size_t ZSTD_initDStream_usingDDict ( ZSTD_DStream * zds , const ZSTD_DDict * ddict ) ; / * * < note : ddict will just be referenced , and must outlive decompression session * / <nl> + ZSTDLIB_API size_t ZSTD_resetDStream ( ZSTD_DStream * zds ) ; / * * < re - use decompression parameters from previous init ; saves dictionary loading * / <nl> + ZSTDLIB_API size_t ZSTD_sizeof_DStream ( const ZSTD_DStream * zds ) ; <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Buffer - less and synchronous inner streaming functions <nl> + * <nl> + * This is an advanced API , giving full control over buffer management , for users which need direct control over memory . <nl> + * But it ' s also a complex one , with many restrictions ( documented below ) . <nl> + * Prefer using normal streaming API for an easier experience <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + / * * <nl> + Buffer - less streaming compression ( synchronous mode ) <nl> + <nl> + A ZSTD_CCtx object is required to track streaming operations . <nl> + Use ZSTD_createCCtx ( ) / ZSTD_freeCCtx ( ) to manage resource . <nl> + ZSTD_CCtx object can be re - used multiple times within successive compression operations . <nl> + <nl> + Start by initializing a context . <nl> + Use ZSTD_compressBegin ( ) , or ZSTD_compressBegin_usingDict ( ) for dictionary compression , <nl> + or ZSTD_compressBegin_advanced ( ) , for finer parameter control . <nl> + It ' s also possible to duplicate a reference context which has already been initialized , using ZSTD_copyCCtx ( ) <nl> + <nl> + Then , consume your input using ZSTD_compressContinue ( ) . <nl> + There are some important considerations to keep in mind when using this advanced function : <nl> + - ZSTD_compressContinue ( ) has no internal buffer . It uses externally provided buffer only . <nl> + - Interface is synchronous : input is consumed entirely and produce 1 + ( or more ) compressed blocks . <nl> + - Caller must ensure there is enough space in ` dst ` to store compressed data under worst case scenario . <nl> + Worst case evaluation is provided by ZSTD_compressBound ( ) . <nl> + ZSTD_compressContinue ( ) doesn ' t guarantee recover after a failed compression . <nl> + - ZSTD_compressContinue ( ) presumes prior input * * * is still accessible and unmodified * * * ( up to maximum distance size , see WindowLog ) . <nl> + It remembers all previous contiguous blocks , plus one separated memory segment ( which can itself consists of multiple contiguous blocks ) <nl> + - ZSTD_compressContinue ( ) detects that prior input has been overwritten when ` src ` buffer overlaps . <nl> + In which case , it will " discard " the relevant memory section from its history . <nl> + <nl> + Finish a frame with ZSTD_compressEnd ( ) , which will write the last block ( s ) and optional checksum . <nl> + It ' s possible to use srcSize = = 0 , in which case , it will write a final empty block to end the frame . <nl> + Without last block mark , frames will be considered unfinished ( corrupted ) by decoders . <nl> + <nl> + ` ZSTD_CCtx ` object can be re - used ( ZSTD_compressBegin ( ) ) to compress some new frame . <nl> + * / <nl> + <nl> + / * = = = = = Buffer - less streaming compression functions = = = = = * / <nl> + ZSTDLIB_API size_t ZSTD_compressBegin ( ZSTD_CCtx * cctx , int compressionLevel ) ; <nl> + ZSTDLIB_API size_t ZSTD_compressBegin_usingDict ( ZSTD_CCtx * cctx , const void * dict , size_t dictSize , int compressionLevel ) ; <nl> + ZSTDLIB_API size_t ZSTD_compressBegin_advanced ( ZSTD_CCtx * cctx , const void * dict , size_t dictSize , ZSTD_parameters params , unsigned long long pledgedSrcSize ) ; / * * < pledgedSrcSize is optional and can be 0 ( meaning unknown ) . note : if the contentSizeFlag is set , pledgedSrcSize = = 0 means the source size is actually 0 * / <nl> + ZSTDLIB_API size_t ZSTD_compressBegin_usingCDict ( ZSTD_CCtx * cctx , const ZSTD_CDict * cdict ) ; / * * < note : fails if cdict = = NULL * / <nl> + ZSTDLIB_API size_t ZSTD_compressBegin_usingCDict_advanced ( ZSTD_CCtx * const cctx , const ZSTD_CDict * const cdict , ZSTD_frameParameters const fParams , unsigned long long const pledgedSrcSize ) ; / * compression parameters are already set within cdict . pledgedSrcSize = 0 means null - size * / <nl> + ZSTDLIB_API size_t ZSTD_copyCCtx ( ZSTD_CCtx * cctx , const ZSTD_CCtx * preparedCCtx , unsigned long long pledgedSrcSize ) ; / * * < note : if pledgedSrcSize can be 0 , indicating unknown size . if it is non - zero , it must be accurate . for 0 size frames , use compressBegin_advanced * / <nl> + <nl> + ZSTDLIB_API size_t ZSTD_compressContinue ( ZSTD_CCtx * cctx , void * dst , size_t dstCapacity , const void * src , size_t srcSize ) ; <nl> + ZSTDLIB_API size_t ZSTD_compressEnd ( ZSTD_CCtx * cctx , void * dst , size_t dstCapacity , const void * src , size_t srcSize ) ; <nl> + <nl> + <nl> + <nl> + / * - <nl> + Buffer - less streaming decompression ( synchronous mode ) <nl> + <nl> + A ZSTD_DCtx object is required to track streaming operations . <nl> + Use ZSTD_createDCtx ( ) / ZSTD_freeDCtx ( ) to manage it . <nl> + A ZSTD_DCtx object can be re - used multiple times . <nl> + <nl> + First typical operation is to retrieve frame parameters , using ZSTD_getFrameParams ( ) . <nl> + It fills a ZSTD_frameParams structure which provide important information to correctly decode the frame , <nl> + such as the minimum rolling buffer size to allocate to decompress data ( ` windowSize ` ) , <nl> + and the dictionary ID used . <nl> + ( Note : content size is optional , it may not be present . 0 means : content size unknown ) . <nl> + Note that these values could be wrong , either because of data malformation , or because an attacker is spoofing deliberate false information . <nl> + As a consequence , check that values remain within valid application range , especially ` windowSize ` , before allocation . <nl> + Each application can set its own limit , depending on local restrictions . For extended interoperability , it is recommended to support at least 8 MB . <nl> + Frame parameters are extracted from the beginning of the compressed frame . <nl> + Data fragment must be large enough to ensure successful decoding , typically ` ZSTD_frameHeaderSize_max ` bytes . <nl> + @ result : 0 : successful decoding , the ` ZSTD_frameParams ` structure is correctly filled . <nl> + > 0 : ` srcSize ` is too small , please provide at least @ result bytes on next attempt . <nl> + errorCode , which can be tested using ZSTD_isError ( ) . <nl> + <nl> + Start decompression , with ZSTD_decompressBegin ( ) or ZSTD_decompressBegin_usingDict ( ) . <nl> + Alternatively , you can copy a prepared context , using ZSTD_copyDCtx ( ) . <nl> + <nl> + Then use ZSTD_nextSrcSizeToDecompress ( ) and ZSTD_decompressContinue ( ) alternatively . <nl> + ZSTD_nextSrcSizeToDecompress ( ) tells how many bytes to provide as ' srcSize ' to ZSTD_decompressContinue ( ) . <nl> + ZSTD_decompressContinue ( ) requires this _exact_ amount of bytes , or it will fail . <nl> + <nl> + @ result of ZSTD_decompressContinue ( ) is the number of bytes regenerated within ' dst ' ( necessarily < = dstCapacity ) . <nl> + It can be zero , which is not an error ; it just means ZSTD_decompressContinue ( ) has decoded some metadata item . <nl> + It can also be an error code , which can be tested with ZSTD_isError ( ) . <nl> + <nl> + ZSTD_decompressContinue ( ) needs previous data blocks during decompression , up to ` windowSize ` . <nl> + They should preferably be located contiguously , prior to current block . <nl> + Alternatively , a round buffer of sufficient size is also possible . Sufficient size is determined by frame parameters . <nl> + ZSTD_decompressContinue ( ) is very sensitive to contiguity , <nl> + if 2 blocks don ' t follow each other , make sure that either the compressor breaks contiguity at the same place , <nl> + or that previous contiguous segment is large enough to properly handle maximum back - reference . <nl> + <nl> + A frame is fully decoded when ZSTD_nextSrcSizeToDecompress ( ) returns zero . <nl> + Context can then be reset to start a new decompression . <nl> + <nl> + Note : it ' s possible to know if next input to present is a header or a block , using ZSTD_nextInputType ( ) . <nl> + This information is not required to properly decode a frame . <nl> + <nl> + = = Special case : skippable frames = = <nl> + <nl> + Skippable frames allow integration of user - defined data into a flow of concatenated frames . <nl> + Skippable frames will be ignored ( skipped ) by a decompressor . The format of skippable frames is as follows : <nl> + a ) Skippable frame ID - 4 Bytes , Little endian format , any value from 0x184D2A50 to 0x184D2A5F <nl> + b ) Frame Size - 4 Bytes , Little endian format , unsigned 32 - bits <nl> + c ) Frame Content - any content ( User Data ) of length equal to Frame Size <nl> + For skippable frames ZSTD_decompressContinue ( ) always returns 0 . <nl> + For skippable frames ZSTD_getFrameParams ( ) returns fparamsPtr - > windowLog = = 0 what means that a frame is skippable . <nl> + Note : If fparamsPtr - > frameContentSize = = 0 , it is ambiguous : the frame might actually be a Zstd encoded frame with no content . <nl> + For purposes of decompression , it is valid in both cases to skip the frame using <nl> + ZSTD_findFrameCompressedSize to find its size in bytes . <nl> + It also returns Frame Size as fparamsPtr - > frameContentSize . <nl> + * / <nl> + <nl> + typedef struct { <nl> + unsigned long long frameContentSize ; <nl> + unsigned windowSize ; <nl> + unsigned dictID ; <nl> + unsigned checksumFlag ; <nl> + } ZSTD_frameParams ; <nl> + <nl> + / * = = = = = Buffer - less streaming decompression functions = = = = = * / <nl> + ZSTDLIB_API size_t ZSTD_getFrameParams ( ZSTD_frameParams * fparamsPtr , const void * src , size_t srcSize ) ; / * * < doesn ' t consume input , see details below * / <nl> + ZSTDLIB_API size_t ZSTD_decompressBegin ( ZSTD_DCtx * dctx ) ; <nl> + ZSTDLIB_API size_t ZSTD_decompressBegin_usingDict ( ZSTD_DCtx * dctx , const void * dict , size_t dictSize ) ; <nl> + ZSTDLIB_API void ZSTD_copyDCtx ( ZSTD_DCtx * dctx , const ZSTD_DCtx * preparedDCtx ) ; <nl> + ZSTDLIB_API size_t ZSTD_nextSrcSizeToDecompress ( ZSTD_DCtx * dctx ) ; <nl> + ZSTDLIB_API size_t ZSTD_decompressContinue ( ZSTD_DCtx * dctx , void * dst , size_t dstCapacity , const void * src , size_t srcSize ) ; <nl> + typedef enum { ZSTDnit_frameHeader , ZSTDnit_blockHeader , ZSTDnit_block , ZSTDnit_lastBlock , ZSTDnit_checksum , ZSTDnit_skippableFrame } ZSTD_nextInputType_e ; <nl> + ZSTDLIB_API ZSTD_nextInputType_e ZSTD_nextInputType ( ZSTD_DCtx * dctx ) ; <nl> + <nl> + / * * <nl> + Block functions <nl> + <nl> + Block functions produce and decode raw zstd blocks , without frame metadata . <nl> + Frame metadata cost is typically ~ 18 bytes , which can be non - negligible for very small blocks ( < 100 bytes ) . <nl> + User will have to take in charge required information to regenerate data , such as compressed and content sizes . <nl> + <nl> + A few rules to respect : <nl> + - Compressing and decompressing require a context structure <nl> + + Use ZSTD_createCCtx ( ) and ZSTD_createDCtx ( ) <nl> + - It is necessary to init context before starting <nl> + + compression : any ZSTD_compressBegin * ( ) variant , including with dictionary <nl> + + decompression : any ZSTD_decompressBegin * ( ) variant , including with dictionary <nl> + + copyCCtx ( ) and copyDCtx ( ) can be used too <nl> + - Block size is limited , it must be < = ZSTD_getBlockSizeMax ( ) < = ZSTD_BLOCKSIZE_ABSOLUTEMAX <nl> + + If input is larger than a block size , it ' s necessary to split input data into multiple blocks <nl> + + For inputs larger than a single block size , consider using the regular ZSTD_compress ( ) instead . <nl> + Frame metadata is not that costly , and quickly becomes negligible as source size grows larger . <nl> + - When a block is considered not compressible enough , ZSTD_compressBlock ( ) result will be zero . <nl> + In which case , nothing is produced into ` dst ` . <nl> + + User must test for such outcome and deal directly with uncompressed data <nl> + + ZSTD_decompressBlock ( ) doesn ' t accept uncompressed data as input ! ! ! <nl> + + In case of multiple successive blocks , should some of them be uncompressed , <nl> + decoder must be informed of their existence in order to follow proper history . <nl> + Use ZSTD_insertBlock ( ) for such a case . <nl> + * / <nl> + <nl> + # define ZSTD_BLOCKSIZE_ABSOLUTEMAX ( 128 * 1024 ) / * define , for static allocation * / <nl> + / * = = = = = Raw zstd block functions = = = = = * / <nl> + ZSTDLIB_API size_t ZSTD_getBlockSizeMax ( ZSTD_CCtx * cctx ) ; <nl> + ZSTDLIB_API size_t ZSTD_compressBlock ( ZSTD_CCtx * cctx , void * dst , size_t dstCapacity , const void * src , size_t srcSize ) ; <nl> + ZSTDLIB_API size_t ZSTD_decompressBlock ( ZSTD_DCtx * dctx , void * dst , size_t dstCapacity , const void * src , size_t srcSize ) ; <nl> + ZSTDLIB_API size_t ZSTD_insertBlock ( ZSTD_DCtx * dctx , const void * blockStart , size_t blockSize ) ; / * * < insert block into ` dctx ` history . Useful for uncompressed blocks * / <nl> + <nl> + <nl> + # endif / * ZSTD_H_ZSTD_STATIC_LINKING_ONLY * / <nl> + <nl> + # if defined ( __cplusplus ) <nl> + } <nl> + # endif <nl> | Merge pull request from tagcup / zstd | godotengine/godot | 12b2652ecbe4acfe1a0391b162629cb2a86c1a0b | 2017-06-11T21:41:56Z |
mmm a / API - Changes - 3 . 0 . md <nl> ppp b / API - Changes - 3 . 0 . md <nl> Overview <nl> 9 . < collection > . exists now throws an error if there is a revision <nl> conflict <nl> <nl> + 10 . replacing an edge in an edge collection now requires the specification <nl> + of both the ` _from ` and ` _to ` attributes . In 2 . 8 it was not required <nl> + to specify ` _from ` and ` _to ` when replacing an edge . <nl> + <nl> + 11 . / _api / collection / figures will not return the following result attributes : <nl> + - shapefiles . count <nl> + - shapes . fileSize <nl> + - shapes . count <nl> + - shapes . size <nl> + - attributes . count <nl> + - attributes . size <nl> + <nl> + 12 . the ` checksum ` attribute returned by GET / _api / collection / < collection > / figures <nl> + now is returned as a string value . It was returned as a number value in previous <nl> + versions . Additionally the checksum calculation algorithm was changed in 3 . 0 , <nl> + so 3 . 0 will create different checksums than previous versions for the same data . <nl> + <nl> # # # New capabilities : <nl> <nl> 1 . Babies for document queries . <nl> mmm a / UnitTests / HttpInterface / api - collection - noncluster - spec . rb <nl> ppp b / UnitTests / HttpInterface / api - collection - noncluster - spec . rb <nl> <nl> r1 . should be_kind_of ( String ) <nl> r1 . should_not eq ( " " ) ; <nl> c1 = doc . parsed_response [ ' checksum ' ] <nl> - c1 . should be_kind_of ( Integer ) <nl> - c1 . should eq ( 0 ) ; <nl> + c1 . should be_kind_of ( String ) <nl> + c1 . should eq ( " 0 " ) ; <nl> <nl> # create a new document <nl> body = " { \ " test \ " : 1 } " <nl> <nl> r2 . should_not eq ( " " ) ; <nl> r2 . should_not eq ( r1 ) ; <nl> c2 = doc . parsed_response [ ' checksum ' ] <nl> - c2 . should be_kind_of ( Integer ) <nl> + c2 . should be_kind_of ( String ) <nl> c2 . should_not eq ( 0 ) ; <nl> c2 . should_not eq ( c1 ) ; <nl> <nl> <nl> r3 . should_not eq ( r1 ) ; <nl> r3 . should_not eq ( r2 ) ; <nl> c3 = doc . parsed_response [ ' checksum ' ] <nl> - c3 . should be_kind_of ( Integer ) <nl> + c3 . should be_kind_of ( String ) <nl> c3 . should_not eq ( 0 ) ; <nl> c3 . should_not eq ( c1 ) ; <nl> c3 . should_not eq ( c2 ) ; <nl> <nl> r4 = doc . parsed_response [ ' revision ' ] <nl> r4 . should eq ( r3 ) ; <nl> c4 = doc . parsed_response [ ' checksum ' ] <nl> - c4 . should be_kind_of ( Integer ) <nl> + c4 . should be_kind_of ( String ) <nl> c4 . should_not eq ( 0 ) ; <nl> c4 . should_not eq ( c1 ) ; <nl> c4 . should_not eq ( c2 ) ; <nl> <nl> r5 . should_not eq ( r3 ) ; <nl> r5 . should_not eq ( r4 ) ; <nl> c5 = doc . parsed_response [ ' checksum ' ] <nl> - c5 . should be_kind_of ( Integer ) <nl> - c5 . should eq ( 0 ) ; <nl> + c5 . should be_kind_of ( String ) <nl> + c5 . should eq ( " 0 " ) ; <nl> end <nl> end <nl> <nl> mmm a / UnitTests / HttpInterface / api - collection - spec . rb <nl> ppp b / UnitTests / HttpInterface / api - collection - spec . rb <nl> <nl> doc . parsed_response [ ' figures ' ] [ ' dead ' ] [ ' count ' ] . should eq ( 0 ) <nl> doc . parsed_response [ ' figures ' ] [ ' alive ' ] [ ' count ' ] . should be_kind_of ( Integer ) <nl> doc . parsed_response [ ' figures ' ] [ ' alive ' ] [ ' count ' ] . should eq ( 0 ) <nl> - doc . parsed_response [ ' figures ' ] [ ' shapes ' ] [ ' count ' ] . should be_kind_of ( Integer ) <nl> - doc . parsed_response [ ' figures ' ] [ ' shapes ' ] [ ' count ' ] . should eq ( 0 ) <nl> - doc . parsed_response [ ' figures ' ] [ ' attributes ' ] [ ' count ' ] . should be_kind_of ( Integer ) <nl> - doc . parsed_response [ ' figures ' ] [ ' attributes ' ] [ ' count ' ] . should > = 0 <nl> doc . parsed_response [ ' figures ' ] [ ' datafiles ' ] [ ' count ' ] . should be_kind_of ( Integer ) <nl> doc . parsed_response [ ' figures ' ] [ ' datafiles ' ] [ ' fileSize ' ] . should be_kind_of ( Integer ) <nl> doc . parsed_response [ ' figures ' ] [ ' datafiles ' ] [ ' count ' ] . should eq ( 0 ) <nl> <nl> doc . parsed_response [ ' figures ' ] [ ' compactors ' ] [ ' count ' ] . should be_kind_of ( Integer ) <nl> doc . parsed_response [ ' figures ' ] [ ' compactors ' ] [ ' fileSize ' ] . should be_kind_of ( Integer ) <nl> doc . parsed_response [ ' figures ' ] [ ' compactors ' ] [ ' count ' ] . should eq ( 0 ) <nl> - doc . parsed_response [ ' figures ' ] [ ' shapefiles ' ] [ ' count ' ] . should be_kind_of ( Integer ) <nl> - doc . parsed_response [ ' figures ' ] [ ' shapefiles ' ] [ ' fileSize ' ] . should be_kind_of ( Integer ) <nl> - doc . parsed_response [ ' figures ' ] [ ' shapefiles ' ] [ ' count ' ] . should eq ( 0 ) <nl> doc . parsed_response [ ' journalSize ' ] . should be_kind_of ( Integer ) <nl> <nl> - # create a few documents , this should increase counts and number of shapes <nl> + # create a few documents , this should increase counts <nl> ( 0 . . . 10 ) . each { | i | <nl> body = " { \ " test \ " : " + i . to_s + " } " <nl> doc = ArangoDB . log_post ( " # { prefix } - get - collection - figures " , " / _api / document / ? collection = " + @ cn , : body = > body ) <nl> <nl> doc . parsed_response [ ' figures ' ] [ ' dead ' ] [ ' count ' ] . should eq ( 0 ) <nl> doc . parsed_response [ ' figures ' ] [ ' alive ' ] [ ' count ' ] . should be_kind_of ( Integer ) <nl> doc . parsed_response [ ' figures ' ] [ ' alive ' ] [ ' count ' ] . should eq ( 10 ) <nl> - doc . parsed_response [ ' figures ' ] [ ' shapes ' ] [ ' count ' ] . should be_kind_of ( Integer ) <nl> - doc . parsed_response [ ' figures ' ] [ ' shapes ' ] [ ' count ' ] . should eq ( 1 ) <nl> doc . parsed_response [ ' figures ' ] [ ' datafiles ' ] [ ' count ' ] . should eq ( 0 ) <nl> doc . parsed_response [ ' figures ' ] [ ' journals ' ] [ ' count ' ] . should eq ( 1 ) <nl> <nl> - # create a few different documents , this should increase counts and number of shapes <nl> + # create a few different documents , this should increase counts <nl> ( 0 . . . 10 ) . each { | i | <nl> body = " { \ " test " + i . to_s + " \ " : 1 } " <nl> doc = ArangoDB . log_post ( " # { prefix } - get - collection - figures " , " / _api / document / ? collection = " + @ cn , : body = > body ) <nl> <nl> doc . parsed_response [ ' figures ' ] [ ' dead ' ] [ ' count ' ] . should eq ( 0 ) <nl> doc . parsed_response [ ' figures ' ] [ ' alive ' ] [ ' count ' ] . should be_kind_of ( Integer ) <nl> doc . parsed_response [ ' figures ' ] [ ' alive ' ] [ ' count ' ] . should eq ( 20 ) <nl> - doc . parsed_response [ ' figures ' ] [ ' shapes ' ] [ ' count ' ] . should be_kind_of ( Integer ) <nl> - doc . parsed_response [ ' figures ' ] [ ' shapes ' ] [ ' count ' ] . should eq ( 11 ) <nl> doc . parsed_response [ ' figures ' ] [ ' datafiles ' ] [ ' count ' ] . should eq ( 0 ) <nl> doc . parsed_response [ ' figures ' ] [ ' journals ' ] [ ' count ' ] . should eq ( 1 ) <nl> <nl> <nl> doc . parsed_response [ ' figures ' ] [ ' dead ' ] [ ' count ' ] . should eq ( 2 ) <nl> doc . parsed_response [ ' figures ' ] [ ' alive ' ] [ ' count ' ] . should be_kind_of ( Integer ) <nl> doc . parsed_response [ ' figures ' ] [ ' alive ' ] [ ' count ' ] . should eq ( 18 ) <nl> - doc . parsed_response [ ' figures ' ] [ ' shapes ' ] [ ' count ' ] . should be_kind_of ( Integer ) <nl> - doc . parsed_response [ ' figures ' ] [ ' shapes ' ] [ ' count ' ] . should eq ( 11 ) <nl> doc . parsed_response [ ' figures ' ] [ ' datafiles ' ] [ ' count ' ] . should eq ( 0 ) <nl> doc . parsed_response [ ' figures ' ] [ ' journals ' ] [ ' count ' ] . should eq ( 1 ) <nl> end <nl> | test fixes | arangodb/arangodb | 4b46ff278a6402630e88df76b2afc984bc443334 | 2016-03-21T16:57:20Z |
mmm a / tensorflow / tools / pip_package / setup . py <nl> ppp b / tensorflow / tools / pip_package / setup . py <nl> <nl> ' numpy > = 1 . 14 . 5 , < 2 . 0 ' , <nl> ' six > = 1 . 10 . 0 ' , <nl> ' protobuf > = 3 . 6 . 1 ' , <nl> - ' tensorboard > = 1 . 12 . 0 , < 1 . 13 . 0 ' , <nl> + ' tensorboard > = 1 . 13 . 0 , < 1 . 14 . 0 ' , <nl> ' tensorflow_estimator > = 1 . 13 . 0rc0 , < 1 . 14 . 0rc0 ' , <nl> ' termcolor > = 1 . 1 . 0 ' , <nl> ] <nl> | Update tensorboard dependency to 1 . 13 . x | tensorflow/tensorflow | b6ed9186089de852c933244a7d772f836cc3eb27 | 2019-02-25T19:22:45Z |
mmm a / Code / CryEngine / CryPhysics / physicalworld . cpp <nl> ppp b / Code / CryEngine / CryPhysics / physicalworld . cpp <nl> void CPhysicalWorld : : GetMemoryStatistics ( ICrySizer * pSizer ) <nl> " areas " , " triggers " , " deleted entities " } ; <nl> int i , j , n ; <nl> CPhysicalEntity * pent ; <nl> + ReadLock lockStep ( m_lockStep ) ; <nl> <nl> # ifndef _LIB / / Only when compiling as dynamic library <nl> { <nl> void CPhysicalWorld : : GetMemoryStatistics ( ICrySizer * pSizer ) <nl> # endif * / <nl> <nl> { SIZER_COMPONENT_NAME ( pSizer , " world structures " ) ; <nl> + ReadLock lockGeo ( m_lockGeoman ) ; <nl> pSizer - > AddObject ( this , sizeof ( CPhysicalWorld ) ) ; <nl> pSizer - > AddObject ( m_pTmpEntList , m_nEntsAlloc * sizeof ( m_pTmpEntList [ 0 ] ) ) ; <nl> pSizer - > AddObject ( m_pTmpEntList1 , m_nEntsAlloc * sizeof ( m_pTmpEntList1 [ 0 ] ) ) ; <nl> | ! B ( HNT - 17203 ) ( Physics ) potential concurrency issue with saving world ' s stats | CRYTEK/CRYENGINE | a167024e1b0883b081b7f53bd7c5ec36114b23bc | 2017-12-20T11:13:36Z |
mmm a / src / protob / protob . hpp <nl> ppp b / src / protob / protob . hpp <nl> class http_conn_cache_t : public repeating_timer_callback_t { <nl> for ( auto it = cache . begin ( ) ; it ! = cache . end ( ) ; ) { <nl> auto tmp = it + + ; <nl> if ( tmp - > second - > is_expired ( ) ) { <nl> - / / We go through some rigamarole to make sure we erase from the <nl> + / / We go through some rigmarole to make sure we erase from the <nl> / / cache immediately and call the possibly - blocking destructor <nl> / / in a separate coroutine to satisfy the <nl> / / ` ASSERT_FINITE_CORO_WAITING ` in ` call_ringer ` in <nl> / / ` arch / timing . cc ` . <nl> boost : : shared_ptr < http_conn_t > conn = std : : move ( tmp - > second ) ; <nl> - cache . erase ( tmp ) ; <nl> conn - > pulse ( ) ; <nl> + cache . erase ( tmp ) ; <nl> coro_t : : spawn_now_dangerously ( [ & conn ] ( ) { <nl> boost : : shared_ptr < http_conn_t > conn2 ; <nl> conn2 . swap ( conn ) ; <nl> | minor fixes | rethinkdb/rethinkdb | b47c0ac993880f1e21ef6da6ac3b7a2130c1cae6 | 2015-01-24T04:48:03Z |
mmm a / tensorflow / contrib / cmake / tf_tests . cmake <nl> ppp b / tensorflow / contrib / cmake / tf_tests . cmake <nl> if ( tensorflow_BUILD_PYTHON_TESTS ) <nl> " $ { tensorflow_source_dir } / tensorflow / python / profiler / pprof_profiler_test . py " <nl> # flaky test <nl> " $ { tensorflow_source_dir } / tensorflow / python / profiler / internal / run_metadata_test . py " <nl> + " $ { tensorflow_source_dir } / tensorflow / python / profiler / model_analyzer_test . py " <nl> # Fails because uses data dependencies with bazel <nl> " $ { tensorflow_source_dir } / tensorflow / python / saved_model / saved_model_test . py " <nl> # requires scipy <nl> | Disable flaky model_analyzer_test on windows . | tensorflow/tensorflow | 425a71083fddcbdeaf415443e9c5bec2eb356a4b | 2018-01-02T23:16:30Z |
mmm a / fdbclient / BlobStore . h <nl> ppp b / fdbclient / BlobStore . h <nl> class BlobStoreEndpoint : public ReferenceCounted < BlobStoreEndpoint > { <nl> struct Stats { <nl> Stats ( ) : requests_successful ( 0 ) , requests_failed ( 0 ) , bytes_sent ( 0 ) { } <nl> Stats operator - ( const Stats & rhs ) ; <nl> - void clear ( ) { memset ( this , sizeof ( * this ) , 0 ) ; } <nl> + void clear ( ) { memset ( this , 0 , sizeof ( * this ) ) ; } <nl> json_spirit : : mObject getJSON ( ) ; <nl> <nl> int64_t requests_successful ; <nl> mmm a / fdbserver / VersionedBTree . actor . cpp <nl> ppp b / fdbserver / VersionedBTree . actor . cpp <nl> struct BTreePage { <nl> r + = format ( " [ ' % s ' ] " , c . getKeyRef ( ) . toHexString ( 20 ) . c_str ( ) ) ; <nl> <nl> r + = " - > " ; <nl> - if ( flags & & IS_LEAF ) <nl> + if ( flags & IS_LEAF ) <nl> r + = format ( " ' % s ' " , c . getValueRef ( ) . toHexString ( 20 ) . c_str ( ) ) ; <nl> else <nl> r + = format ( " Page id = % u " , * ( const uint32_t * ) c . getValueRef ( ) . begin ( ) ) ; <nl> | Fix issues that a newer compiler warned about . | apple/foundationdb | b4b7f382a7190a05a6e6e3f9485f53dd626c21f0 | 2018-12-14T22:43:50Z |
mmm a / modules / ocl / src / initialization . cpp <nl> ppp b / modules / ocl / src / initialization . cpp <nl> namespace cv <nl> filename = clCxt - > impl - > Binpath + kernelName + " _ " + clCxt - > impl - > devName + " . clb " ; <nl> } <nl> <nl> - FILE * fp ; <nl> - fp = fopen ( filename . c_str ( ) , " rb " ) ; <nl> - if ( fp = = NULL | | clCxt - > impl - > Binpath . size ( ) = = 0 ) / / we should genetate a binary file for the first time . <nl> + FILE * fp = fopen ( filename . c_str ( ) , " rb " ) ; <nl> + if ( fp = = NULL | | clCxt - > impl - > Binpath . size ( ) = = 0 ) / / we should generate a binary file for the first time . <nl> { <nl> + if ( fp ! = NULL ) <nl> + fclose ( fp ) ; <nl> + <nl> program = clCreateProgramWithSource ( <nl> clCxt - > impl - > clContext , 1 , source , NULL , & status ) ; <nl> openCLVerifyCall ( status ) ; <nl> | Merge pull request from asmaloney : missing_fclose | opencv/opencv | 5335c2f92047d5438a1cbe1fe3fc1dbc5296f957 | 2013-02-11T10:03:51Z |
mmm a / stdlib / objc / XCTest / XCTest . swift <nl> ppp b / stdlib / objc / XCTest / XCTest . swift <nl> func _XCTCheckEqualWithAccuracy_Float ( value1 : Float , value2 : Float , accuracy : Fl <nl> & & ( abs ( value1 - value2 ) < = accuracy ) <nl> } <nl> <nl> + func _XCTCheckEqualWithAccuracy_CGFloat ( value1 : CGFloat , value2 : CGFloat , accuracy : CGFloat ) - > Bool { <nl> + return ( ! value1 . isNaN & & ! value2 . isNaN ) <nl> + & & ( abs ( value1 - value2 ) < = accuracy ) <nl> + } <nl> + <nl> public func XCTAssertEqualWithAccuracy < T : FloatingPointType > ( expression1 : @ autoclosure ( ) - > T , expression2 : @ autoclosure ( ) - > T , accuracy : T , _ message : String = " " , file : String = __FILE__ , line : UInt = __LINE__ ) - > Void { <nl> let assertionType = _XCTAssertionType . EqualWithAccuracy <nl> <nl> public func XCTAssertEqualWithAccuracy < T : FloatingPointType > ( expression1 : @ autoc <nl> case let ( expressionValue1Float as Float , expressionValue2Float as Float , accuracyFloat as Float ) : <nl> equalWithAccuracy = _XCTCheckEqualWithAccuracy_Float ( expressionValue1Float , expressionValue2Float , accuracyFloat ) <nl> <nl> + case let ( expressionValue1CGFloat as CGFloat , expressionValue2CGFloat as CGFloat , accuracyCGFloat as CGFloat ) : <nl> + equalWithAccuracy = _XCTCheckEqualWithAccuracy_CGFloat ( expressionValue1CGFloat , expressionValue2CGFloat , accuracyCGFloat ) <nl> + <nl> default : <nl> / / unknown type , fail with prejudice <nl> _preconditionFailure ( " unsupported floating - point type passed to XCTAssertEqualWithAccuracy " ) <nl> func _XCTCheckNotEqualWithAccuracy_Float ( value1 : Float , value2 : Float , accuracy : <nl> | | ( abs ( value1 - value2 ) > accuracy ) <nl> } <nl> <nl> + func _XCTCheckNotEqualWithAccuracy_CGFloat ( value1 : CGFloat , value2 : CGFloat , accuracy : CGFloat ) - > Bool { <nl> + return ( value1 . isNaN | | value2 . isNaN ) <nl> + | | ( abs ( value1 - value2 ) > accuracy ) <nl> + } <nl> + <nl> public func XCTAssertNotEqualWithAccuracy < T : FloatingPointType > ( expression1 : @ autoclosure ( ) - > T , expression2 : @ autoclosure ( ) - > T , accuracy : T , _ message : String = " " , file : String = __FILE__ , line : UInt = __LINE__ ) - > Void { <nl> let assertionType = _XCTAssertionType . NotEqualWithAccuracy <nl> <nl> public func XCTAssertNotEqualWithAccuracy < T : FloatingPointType > ( expression1 : @ au <nl> case let ( expressionValue1Float as Float , expressionValue2Float as Float , accuracyFloat as Float ) : <nl> notEqualWithAccuracy = _XCTCheckNotEqualWithAccuracy_Float ( expressionValue1Float , expressionValue2Float , accuracyFloat ) <nl> <nl> + case let ( expressionValue1CGFloat as CGFloat , expressionValue2CGFloat as CGFloat , accuracyCGFloat as CGFloat ) : <nl> + notEqualWithAccuracy = _XCTCheckNotEqualWithAccuracy_CGFloat ( expressionValue1CGFloat , expressionValue2CGFloat , accuracyCGFloat ) <nl> + <nl> default : <nl> / / unknown type , fail with prejudice <nl> _preconditionFailure ( " unsupported floating - point type passed to XCTAssertNotEqualWithAccuracy " ) <nl> | Make XCTAssertEqualWithAccuracy work with CGFloat | apple/swift | 867429b0f485c620c2aa7ad85c8440af3110e7b7 | 2014-07-31T01:36:32Z |
mmm a / swoole_http . c <nl> ppp b / swoole_http . c <nl> static int http_request_on_query_string ( php_http_parser * parser , const char * at , <nl> array_init ( get ) ; <nl> zend_update_property ( swoole_http_request_class_entry_ptr , client - > zrequest , ZEND_STRL ( " get " ) , get TSRMLS_CC ) ; <nl> sapi_module . treat_data ( PARSE_STRING , query , get TSRMLS_CC ) ; <nl> + ZEND_SET_SYMBOL ( & EG ( symbol_table ) , " _GET " , get ) ; <nl> + zval * _request = zend_read_property ( swoole_http_request_class_entry_ptr , client - > zrequest , ZEND_STRL ( " request " ) , 1 TSRMLS_CC ) ; <nl> + zend_hash_copy ( Z_ARRVAL_P ( _request ) , Z_ARRVAL_P ( get ) , NULL , NULL , sizeof ( zval ) ) ; <nl> return 0 ; <nl> } <nl> <nl> static int http_request_on_header_value ( php_http_parser * parser , const char * at , <nl> memcpy ( keybuf , kv . k , kv . klen - 1 ) ; <nl> keybuf [ kv . klen - 1 ] = 0 ; <nl> add_assoc_stringl_ex ( cookie , keybuf , kv . klen , kv . v , kv . vlen , 1 ) ; <nl> + ZEND_SET_SYMBOL ( & EG ( symbol_table ) , " _COOKIE " , cookie ) ; <nl> + <nl> } <nl> else if ( memcmp ( header_name , ZEND_STRL ( " upgrade " ) ) = = 0 <nl> & & memcmp ( at , ZEND_STRL ( " websocket " ) ) = = 0 ) <nl> static int http_request_on_body ( php_http_parser * parser , const char * at , size_t <nl> array_init ( post ) ; <nl> zend_update_property ( swoole_http_request_class_entry_ptr , client - > zrequest , ZEND_STRL ( " post " ) , post TSRMLS_CC ) ; <nl> sapi_module . treat_data ( PARSE_STRING , body , post TSRMLS_CC ) ; <nl> + ZEND_SET_SYMBOL ( & EG ( symbol_table ) , " _POST " , post ) ; <nl> + zval * _request = zend_read_property ( swoole_http_request_class_entry_ptr , client - > zrequest , ZEND_STRL ( " request " ) , 1 TSRMLS_CC ) ; <nl> + zend_hash_copy ( Z_ARRVAL_P ( _request ) , Z_ARRVAL_P ( post ) , NULL , NULL , sizeof ( zval ) ) ; <nl> + <nl> } <nl> else <nl> { <nl> static int http_onReceive ( swFactory * factory , swEventData * req ) <nl> <nl> <nl> zval * zdata = php_swoole_get_data ( req TSRMLS_CC ) ; <nl> + / / server info <nl> + zval * _request ; <nl> + MAKE_STD_ZVAL ( _request ) ; <nl> + array_init ( _request ) ; <nl> + zend_update_property ( swoole_http_request_class_entry_ptr , client - > zrequest , ZEND_STRL ( " request " ) , _request TSRMLS_CC ) ; <nl> size_t n = php_http_parser_execute ( parser , & http_parser_settings , Z_STRVAL_P ( zdata ) , Z_STRLEN_P ( zdata ) ) ; <nl> zval_ptr_dtor ( & zdata ) ; <nl> if ( n < 0 ) <nl> static int http_onReceive ( swFactory * factory , swEventData * req ) <nl> zend_update_property ( swoole_http_request_class_entry_ptr , zrequest , ZEND_STRL ( " server " ) , zserver TSRMLS_CC ) ; <nl> <nl> switch ( parser - > method ) { <nl> - case PHP_HTTP_GET : add_assoc_string ( zserver , " request_method " , " GET " , 1 ) ; break ; <nl> - case PHP_HTTP_POST : add_assoc_string ( zserver , " request_method " , " POST " , 1 ) ; break ; <nl> - case PHP_HTTP_HEAD : add_assoc_string ( zserver , " request_method " , " HEAD " , 1 ) ; break ; <nl> - case PHP_HTTP_PUT : add_assoc_string ( zserver , " request_method " , " PUT " , 1 ) ; break ; <nl> - case PHP_HTTP_DELETE : add_assoc_string ( zserver , " request_method " , " DELETE " , 1 ) ; break ; <nl> - case PHP_HTTP_PATCH : add_assoc_string ( zserver , " request_method " , " PATCH " , 1 ) ; break ; <nl> + case PHP_HTTP_GET : add_assoc_string ( zserver , " REQUEST_METHOD " , " GET " , 1 ) ; break ; <nl> + case PHP_HTTP_POST : add_assoc_string ( zserver , " REQUEST_METHOD " , " POST " , 1 ) ; break ; <nl> + case PHP_HTTP_HEAD : add_assoc_string ( zserver , " REQUEST_METHOD " , " HEAD " , 1 ) ; break ; <nl> + case PHP_HTTP_PUT : add_assoc_string ( zserver , " REQUEST_METHOD " , " PUT " , 1 ) ; break ; <nl> + case PHP_HTTP_DELETE : add_assoc_string ( zserver , " REQUEST_METHOD " , " DELETE " , 1 ) ; break ; <nl> + case PHP_HTTP_PATCH : add_assoc_string ( zserver , " REQUEST_METHOD " , " PATCH " , 1 ) ; break ; <nl> / * pathological * / <nl> - case PHP_HTTP_CONNECT : add_assoc_string ( zserver , " request_method " , " CONNECT " , 1 ) ; break ; <nl> - case PHP_HTTP_OPTIONS : add_assoc_string ( zserver , " request_method " , " OPTIONS " , 1 ) ; break ; <nl> - case PHP_HTTP_TRACE : add_assoc_string ( zserver , " request_method " , " TRACE " , 1 ) ; break ; <nl> + case PHP_HTTP_CONNECT : add_assoc_string ( zserver , " REQUEST_METHOD " , " CONNECT " , 1 ) ; break ; <nl> + case PHP_HTTP_OPTIONS : add_assoc_string ( zserver , " REQUEST_METHOD " , " OPTIONS " , 1 ) ; break ; <nl> + case PHP_HTTP_TRACE : add_assoc_string ( zserver , " REQUEST_METHOD " , " TRACE " , 1 ) ; break ; <nl> / * webdav * / <nl> - case PHP_HTTP_COPY : add_assoc_string ( zserver , " request_method " , " COPY " , 1 ) ; break ; <nl> - case PHP_HTTP_LOCK : add_assoc_string ( zserver , " request_method " , " LOCK " , 1 ) ; break ; <nl> - case PHP_HTTP_MKCOL : add_assoc_string ( zserver , " request_method " , " MKCOL " , 1 ) ; break ; <nl> - case PHP_HTTP_MOVE : add_assoc_string ( zserver , " request_method " , " MOVE " , 1 ) ; break ; <nl> - case PHP_HTTP_PROPFIND : add_assoc_string ( zserver , " request_method " , " PROPFIND " , 1 ) ; break ; <nl> - case PHP_HTTP_PROPPATCH : add_assoc_string ( zserver , " request_method " , " PROPPATCH " , 1 ) ; break ; <nl> - case PHP_HTTP_UNLOCK : add_assoc_string ( zserver , " request_method " , " UNLOCK " , 1 ) ; break ; <nl> + case PHP_HTTP_COPY : add_assoc_string ( zserver , " REQUEST_METHOD " , " COPY " , 1 ) ; break ; <nl> + case PHP_HTTP_LOCK : add_assoc_string ( zserver , " REQUEST_METHOD " , " LOCK " , 1 ) ; break ; <nl> + case PHP_HTTP_MKCOL : add_assoc_string ( zserver , " REQUEST_METHOD " , " MKCOL " , 1 ) ; break ; <nl> + case PHP_HTTP_MOVE : add_assoc_string ( zserver , " REQUEST_METHOD " , " MOVE " , 1 ) ; break ; <nl> + case PHP_HTTP_PROPFIND : add_assoc_string ( zserver , " REQUEST_METHOD " , " PROPFIND " , 1 ) ; break ; <nl> + case PHP_HTTP_PROPPATCH : add_assoc_string ( zserver , " REQUEST_METHOD " , " PROPPATCH " , 1 ) ; break ; <nl> + case PHP_HTTP_UNLOCK : add_assoc_string ( zserver , " REQUEST_METHOD " , " UNLOCK " , 1 ) ; break ; <nl> / * subversion * / <nl> - case PHP_HTTP_REPORT : add_assoc_string ( zserver , " request_method " , " REPORT " , 1 ) ; break ; <nl> - case PHP_HTTP_MKACTIVITY : add_assoc_string ( zserver , " request_method " , " MKACTIVITY " , 1 ) ; break ; <nl> - case PHP_HTTP_CHECKOUT : add_assoc_string ( zserver , " request_method " , " CHECKOUT " , 1 ) ; break ; <nl> - case PHP_HTTP_MERGE : add_assoc_string ( zserver , " request_method " , " MERGE " , 1 ) ; break ; <nl> + case PHP_HTTP_REPORT : add_assoc_string ( zserver , " REQUEST_METHOD " , " REPORT " , 1 ) ; break ; <nl> + case PHP_HTTP_MKACTIVITY : add_assoc_string ( zserver , " REQUEST_METHOD " , " MKACTIVITY " , 1 ) ; break ; <nl> + case PHP_HTTP_CHECKOUT : add_assoc_string ( zserver , " REQUEST_METHOD " , " CHECKOUT " , 1 ) ; break ; <nl> + case PHP_HTTP_MERGE : add_assoc_string ( zserver , " REQUEST_METHOD " , " MERGE " , 1 ) ; break ; <nl> / * upnp * / <nl> - case PHP_HTTP_MSEARCH : add_assoc_string ( zserver , " request_method " , " MSEARCH " , 1 ) ; break ; <nl> - case PHP_HTTP_NOTIFY : add_assoc_string ( zserver , " request_method " , " NOTIFY " , 1 ) ; break ; <nl> - case PHP_HTTP_SUBSCRIBE : add_assoc_string ( zserver , " request_method " , " SUBSCRIBE " , 1 ) ; break ; <nl> - case PHP_HTTP_UNSUBSCRIBE : add_assoc_string ( zserver , " request_method " , " UNSUBSCRIBE " , 1 ) ; break ; <nl> - case PHP_HTTP_NOT_IMPLEMENTED : add_assoc_string ( zserver , " request_method " , " GET " , 1 ) ; break ; <nl> + case PHP_HTTP_MSEARCH : add_assoc_string ( zserver , " REQUEST_METHOD " , " MSEARCH " , 1 ) ; break ; <nl> + case PHP_HTTP_NOTIFY : add_assoc_string ( zserver , " REQUEST_METHOD " , " NOTIFY " , 1 ) ; break ; <nl> + case PHP_HTTP_SUBSCRIBE : add_assoc_string ( zserver , " REQUEST_METHOD " , " SUBSCRIBE " , 1 ) ; break ; <nl> + case PHP_HTTP_UNSUBSCRIBE : add_assoc_string ( zserver , " REQUEST_METHOD " , " UNSUBSCRIBE " , 1 ) ; break ; <nl> + case PHP_HTTP_NOT_IMPLEMENTED : add_assoc_string ( zserver , " REQUEST_METHOD " , " GET " , 1 ) ; break ; <nl> } <nl> <nl> / / if ( parser - > method = = PHP_HTTP_POST ) <nl> / / { <nl> - / / add_assoc_string ( zserver , " request_method " , " POST " , 1 ) ; <nl> + / / add_assoc_string ( zserver , " REQUEST_METHOD " , " POST " , 1 ) ; <nl> / / } <nl> / / else <nl> / / { <nl> - / / add_assoc_string ( zserver , " request_method " , " GET " , 1 ) ; <nl> + / / add_assoc_string ( zserver , " REQUEST_METHOD " , " GET " , 1 ) ; <nl> / / } <nl> <nl> - add_assoc_stringl ( zserver , " request_uri " , client - > request . path , client - > request . path_len , 1 ) ; <nl> - add_assoc_stringl ( zserver , " path_info " , client - > request . path , client - > request . path_len , 1 ) ; <nl> - add_assoc_long_ex ( zserver , ZEND_STRS ( " request_time " ) , SwooleGS - > now ) ; <nl> + add_assoc_stringl ( zserver , " REQUEST_URI " , client - > request . path , client - > request . path_len , 1 ) ; <nl> + add_assoc_stringl ( zserver , " PATH_INFO " , client - > request . path , client - > request . path_len , 1 ) ; <nl> + add_assoc_long_ex ( zserver , ZEND_STRS ( " REQUEST_TIME " ) , SwooleGS - > now ) ; <nl> <nl> swConnection * conn = swServer_connection_get ( SwooleG . serv , fd ) ; <nl> - add_assoc_long ( zserver , " server_port " , SwooleG . serv - > connection_list [ conn - > from_fd ] . addr . sin_port ) ; <nl> - add_assoc_long ( zserver , " remote_port " , ntohs ( conn - > addr . sin_port ) ) ; <nl> - add_assoc_string ( zserver , " remote_addr " , inet_ntoa ( conn - > addr . sin_addr ) , 1 ) ; <nl> + add_assoc_long ( zserver , " SERVER_PORT " , SwooleG . serv - > connection_list [ conn - > from_fd ] . addr . sin_port ) ; <nl> + add_assoc_long ( zserver , " REMOTE_PORT " , ntohs ( conn - > addr . sin_port ) ) ; <nl> + add_assoc_string ( zserver , " REMOTE_ADDR " , inet_ntoa ( conn - > addr . sin_addr ) , 1 ) ; <nl> <nl> if ( client - > request . version = = 101 ) <nl> { <nl> - add_assoc_string ( zserver , " server_protocol " , " HTTP / 1 . 1 " , 1 ) ; <nl> + add_assoc_string ( zserver , " SERVER_PROTOCOL " , " HTTP / 1 . 1 " , 1 ) ; <nl> } <nl> else <nl> { <nl> - add_assoc_string ( zserver , " server_protocol " , " HTTP / 1 . 0 " , 1 ) ; <nl> + add_assoc_string ( zserver , " SERVER_PROTOCOL " , " HTTP / 1 . 0 " , 1 ) ; <nl> } <nl> - add_assoc_string ( zserver , " server_software " , SW_HTTP_SERVER_SOFTWARE , 1 ) ; <nl> - add_assoc_string ( zserver , " gateway_interface " , SW_HTTP_SERVER_SOFTWARE , 1 ) ; <nl> + add_assoc_string ( zserver , " SERVER_SOFTWARE " , SW_HTTP_SERVER_SOFTWARE , 1 ) ; <nl> + add_assoc_string ( zserver , " GATEWAY_INTERFACE " , SW_HTTP_SERVER_SOFTWARE , 1 ) ; <nl> + / / ZEND_SET_SYMBOL ( & EG ( symbol_table ) , " _SERVER " , zserver ) ; <nl> + <nl> <nl> zval * zresponse ; <nl> MAKE_STD_ZVAL ( zresponse ) ; <nl> | _GET _POST _COOKIE | swoole/swoole-src | aa209e7342c574ed436fe2c0e544b16eea6caf79 | 2014-12-18T11:03:57Z |
mmm a / python_examples / face_detector . py <nl> ppp b / python_examples / face_detector . py <nl> <nl> # system so long as you have CMake and boost - python installed . <nl> # On Ubuntu , this can be done easily by running the command : <nl> # sudo apt - get install libboost - python - dev cmake <nl> + # <nl> + # Also note that this example requires scikit - image which can be installed <nl> + # via the command : <nl> + # pip install - U scikit - image <nl> + # Or downloaded from http : / / scikit - image . org / download . html . <nl> <nl> import sys <nl> <nl> mmm a / python_examples / face_landmark_detection . py <nl> ppp b / python_examples / face_landmark_detection . py <nl> <nl> # system so long as you have CMake and boost - python installed . <nl> # On Ubuntu , this can be done easily by running the command : <nl> # sudo apt - get install libboost - python - dev cmake <nl> + # <nl> + # Also note that this example requires scikit - image which can be installed <nl> + # via the command : <nl> + # pip install - U scikit - image <nl> + # Or downloaded from http : / / scikit - image . org / download . html . <nl> + <nl> import sys <nl> import os <nl> import dlib <nl> mmm a / python_examples / find_candidate_object_locations . py <nl> ppp b / python_examples / find_candidate_object_locations . py <nl> <nl> # the false alarms . Since find_candidate_object_locations ( ) will only generate <nl> # a few thousand rectangles it is much faster than scanning all possible <nl> # rectangles inside an image . <nl> + # <nl> + # Also note that this example requires scikit - image which can be installed <nl> + # via the command : <nl> + # pip install - U scikit - image <nl> + # Or downloaded from http : / / scikit - image . org / download . html . <nl> + <nl> <nl> <nl> import dlib <nl> mmm a / python_examples / train_object_detector . py <nl> ppp b / python_examples / train_object_detector . py <nl> <nl> # system so long as you have CMake and boost - python installed . <nl> # On Ubuntu , this can be done easily by running the command : <nl> # sudo apt - get install libboost - python - dev cmake <nl> + # <nl> + # Also note that this example requires scikit - image which can be installed <nl> + # via the command : <nl> + # pip install - U scikit - image <nl> + # Or downloaded from http : / / scikit - image . org / download . html . <nl> + <nl> import os <nl> import sys <nl> import glob <nl> mmm a / python_examples / train_shape_predictor . py <nl> ppp b / python_examples / train_shape_predictor . py <nl> <nl> # system so long as you have CMake and boost - python installed . <nl> # On Ubuntu , this can be done easily by running the command : <nl> # sudo apt - get install libboost - python - dev cmake <nl> + # <nl> + # Also note that this example requires scikit - image which can be installed <nl> + # via the command : <nl> + # pip install - U scikit - image <nl> + # Or downloaded from http : / / scikit - image . org / download . html . <nl> + <nl> import os <nl> import sys <nl> import glob <nl> | Added notes about installing skimage . | davisking/dlib | 154f435427e44f6dd23ea4a7df03445d13b68953 | 2015-03-07T19:14:47Z |
mmm a / src / compiler / arm64 / instruction - selector - arm64 . cc <nl> ppp b / src / compiler / arm64 / instruction - selector - arm64 . cc <nl> void VisitAtomicExchange ( InstructionSelector * selector , Node * node , <nl> Node * base = node - > InputAt ( 0 ) ; <nl> Node * index = node - > InputAt ( 1 ) ; <nl> Node * value = node - > InputAt ( 2 ) ; <nl> - InstructionOperand inputs [ 3 ] ; <nl> - size_t input_count = 0 ; <nl> - inputs [ input_count + + ] = g . UseRegister ( base ) ; <nl> - inputs [ input_count + + ] = g . UseRegister ( index ) ; <nl> - inputs [ input_count + + ] = g . UseUniqueRegister ( value ) ; <nl> - InstructionOperand outputs [ 1 ] ; <nl> - outputs [ 0 ] = g . DefineAsRegister ( node ) ; <nl> + InstructionOperand inputs [ ] = { g . UseRegister ( base ) , g . UseRegister ( index ) , <nl> + g . UseUniqueRegister ( value ) } ; <nl> + InstructionOperand outputs [ ] = { g . DefineAsRegister ( node ) } ; <nl> InstructionOperand temps [ ] = { g . TempRegister ( ) , g . TempRegister ( ) } ; <nl> InstructionCode code = opcode | AddressingModeField : : encode ( kMode_MRR ) ; <nl> - selector - > Emit ( code , 1 , outputs , input_count , inputs , arraysize ( temps ) , <nl> - temps ) ; <nl> + selector - > Emit ( code , arraysize ( outputs ) , outputs , arraysize ( inputs ) , inputs , <nl> + arraysize ( temps ) , temps ) ; <nl> } <nl> <nl> void VisitAtomicCompareExchange ( InstructionSelector * selector , Node * node , <nl> void VisitAtomicCompareExchange ( InstructionSelector * selector , Node * node , <nl> Node * index = node - > InputAt ( 1 ) ; <nl> Node * old_value = node - > InputAt ( 2 ) ; <nl> Node * new_value = node - > InputAt ( 3 ) ; <nl> - InstructionOperand inputs [ 4 ] ; <nl> - size_t input_count = 0 ; <nl> - inputs [ input_count + + ] = g . UseRegister ( base ) ; <nl> - inputs [ input_count + + ] = g . UseRegister ( index ) ; <nl> - inputs [ input_count + + ] = g . UseUniqueRegister ( old_value ) ; <nl> - inputs [ input_count + + ] = g . UseUniqueRegister ( new_value ) ; <nl> - InstructionOperand outputs [ 1 ] ; <nl> - outputs [ 0 ] = g . DefineAsRegister ( node ) ; <nl> + InstructionOperand inputs [ ] = { g . UseRegister ( base ) , g . UseRegister ( index ) , <nl> + g . UseUniqueRegister ( old_value ) , <nl> + g . UseUniqueRegister ( new_value ) } ; <nl> + InstructionOperand outputs [ ] = { g . DefineAsRegister ( node ) } ; <nl> InstructionOperand temps [ ] = { g . TempRegister ( ) , g . TempRegister ( ) } ; <nl> InstructionCode code = opcode | AddressingModeField : : encode ( kMode_MRR ) ; <nl> - selector - > Emit ( code , 1 , outputs , input_count , inputs , arraysize ( temps ) , <nl> - temps ) ; <nl> + selector - > Emit ( code , arraysize ( outputs ) , outputs , arraysize ( inputs ) , inputs , <nl> + arraysize ( temps ) , temps ) ; <nl> } <nl> <nl> void VisitAtomicLoad ( InstructionSelector * selector , Node * node , <nl> void VisitAtomicStore ( InstructionSelector * selector , Node * node , <nl> Node * base = node - > InputAt ( 0 ) ; <nl> Node * index = node - > InputAt ( 1 ) ; <nl> Node * value = node - > InputAt ( 2 ) ; <nl> - InstructionOperand inputs [ 3 ] ; <nl> - size_t input_count = 0 ; <nl> - inputs [ input_count + + ] = g . UseRegister ( base ) ; <nl> - inputs [ input_count + + ] = g . UseRegister ( index ) ; <nl> - inputs [ input_count + + ] = g . UseUniqueRegister ( value ) ; <nl> - InstructionCode code = opcode | AddressingModeField : : encode ( kMode_MRR ) ; <nl> + InstructionOperand inputs [ ] = { g . UseRegister ( base ) , g . UseRegister ( index ) , <nl> + g . UseUniqueRegister ( value ) } ; <nl> InstructionOperand temps [ ] = { g . TempRegister ( ) } ; <nl> - selector - > Emit ( code , 0 , nullptr , input_count , inputs , arraysize ( temps ) , <nl> + InstructionCode code = opcode | AddressingModeField : : encode ( kMode_MRR ) ; <nl> + selector - > Emit ( code , 0 , nullptr , arraysize ( inputs ) , inputs , arraysize ( temps ) , <nl> temps ) ; <nl> } <nl> <nl> | [ arm64 ] Cleanup visitors for Atomic operations | v8/v8 | 1bb5d012bbbe40c158a29033fb7a51b6adc8f84c | 2018-04-13T21:54:38Z |
mmm a / src / bailout - reason . h <nl> ppp b / src / bailout - reason . h <nl> namespace internal { <nl> V ( kExternalStringExpectedButNotFound , \ <nl> " External string expected , but not found " ) \ <nl> V ( kFailedBailedOutLastTime , " Failed / bailed out last time " ) \ <nl> - V ( kForInStatementIsNotFastCase , " ForInStatement is not fast case " ) \ <nl> V ( kForInStatementOptimizationIsDisabled , \ <nl> " ForInStatement optimization is disabled " ) \ <nl> V ( kForInStatementWithNonLocalEachVariable , \ <nl> | Remove kForInStatementIsNotFastCase bailout reason | v8/v8 | ba24e6769615d0ea7f7b5a31c5947769892f93a7 | 2015-04-13T11:37:10Z |
mmm a / dlib / bsp / bsp_abstract . h <nl> ppp b / dlib / bsp / bsp_abstract . h <nl> <nl> # ifdef DLIB_BsP_ABSTRACT_H__ <nl> <nl> # include " . . / noncopyable . h " <nl> + # include " . . / sockets / sockets_extensions_abstract . h " <nl> # include < vector > <nl> <nl> namespace dlib <nl> | updated spec | davisking/dlib | d00864cf5460076e6f3f92d6fbb329cfa28c7892 | 2012-10-22T00:23:17Z |
new file mode 100644 <nl> index 000000000000 . . 5d49ce486472 <nl> mmm / dev / null <nl> ppp b / validation - test / compiler_crashers / 28315 - swift - declcontext - iscascadingcontextforlookup . swift <nl> <nl> + / / This source file is part of the Swift . org open source project <nl> + / / Copyright ( c ) 2014 - 2016 Apple Inc . and the Swift project authors <nl> + / / Licensed under Apache License v2 . 0 with Runtime Library Exception <nl> + / / <nl> + / / See http : / / swift . org / LICENSE . txt for license information <nl> + / / See http : / / swift . org / CONTRIBUTORS . txt for the list of Swift project authors <nl> + <nl> + / / RUN : not - - crash % target - swift - frontend % s - parse <nl> + = b < T = class B <nl> + } { <nl> + func b { enum B : T = ( a <nl> + class <nl> + class <nl> + struct B : B { <nl> + class S < b < b { <nl> + struct B { <nl> + func a = b { enum B { for c <nl> + var e <nl> + class <nl> + case c <nl> + struct c <nl> + class A { map ( a < T . c <nl> + let a { typealias e { struct c < T . E <nl> + func ^ ( f . c < f : B : O { <nl> + " <nl> + func ^ <nl> + let a { <nl> + { <nl> + if true { <nl> + " <nl> + func g : O { typealias f <nl> + let : Int - > ( $ 0 <nl> + if true { struct Q < b < T = Swift . E = e <nl> + case c < f : T : O { [ ] as a { <nl> + func a = e = = { struct c < T where g : f : O { enum b <nl> + protocol B { <nl> + func g : T : O { enum B : O { <nl> + " <nl> + = e <nl> + if true { <nl> + { <nl> + var e <nl> + { func b <nl> + struct c <nl> + let : a = e { <nl> + protocol B <nl> + struct B : T = b < T where H : Boole <nl> + func ^ ( f : Int - > ( $ 0 <nl> + protocol B : a { <nl> + class A { typealias f <nl> + func g : B <nl> + func a ! <nl> + class b <nl> + } <nl> + let a <nl> + struct c < h { <nl> + let : B { <nl> + struct Q < T where T > <nl> + let a = class a { class S < h { struct Q < T > : B { enum B < h <nl> + protocol a { enum b < > <nl> + func g : T > : B : B { enum b { class c <nl> + protocol A { <nl> + let a { <nl> + struct B { <nl> + class b <nl> + protocol B <nl> + if true { protocol a { <nl> + class c <nl> + class b < T : a ! <nl> + struct B { enum b < T where g : O { <nl> + " <nl> + for c : a = class b { <nl> + let : A <nl> + if true { [ ] as a { enum b <nl> + struct B { enum B { struct Q < T where I = ( a <nl> + protocol A : a <nl> + protocol B <nl> + case c <nl> + func ^ ( f <nl> + if true { struct Q < > : d where H : Boole <nl> + struct c <nl> + } <nl> + if true { func i ( <nl> + class A <nl> + } class B <nl> + case c <nl> + struct Q < <nl> + func a <nl> + func ^ ( a ! <nl> + struct c < <nl> + struct c <nl> + struct Q { enum B < T where T . c < T where I = c <nl> + struct A { enum b { <nl> + let : T . c <nl> + if true { <nl> + protocol a = e = = class b { <nl> + func g : T : T . E = c <nl> + let : Boole <nl> + if case { <nl> + { <nl> + { <nl> + struct S { map ( f : C { func < { class B { struct c <nl> + func b <nl> + var b < f : C { <nl> + func < { { <nl> + class A { <nl> + struct c < h <nl> + protocol B < T . E <nl> + { <nl> + protocol B : B : B <nl> + let : T : a { <nl> + protocol B { struct c <nl> + let a ! <nl> + class S < T where H : Boole <nl> + struct c : { class a { <nl> + func g : B < T where I = e <nl> + if true { extension { <nl> + { <nl> + { for c < f : Int - > ( a { <nl> + struct c < T where g : B : B : A { typealias f : C { enum B : O { for c <nl> + struct Q { enum b < T where g : B : a ! <nl> + struct c , case { struct Q { struct Q { } <nl> + struct Q { <nl> + { func < { <nl> + { protocol B { <nl> + } <nl> + protocol A <nl> + case c < a <nl> + if true { struct Q < T where g : B : f : a ! <nl> + var b { case <nl> + } <nl> + struct c < T = c , <nl> + } <nl> + { class B : a { <nl> + var b < T : B < T where I = = e { enum b { class b { struct Q < T where I = e = class A <nl> + func b <nl> + struct c < > : b < > <nl> + protocol B < T . c <nl> + import a { struct S { <nl> + let : T = b <nl> + protocol a = e = c < T where B < T . E = class B { <nl> + class b < T where I = e { enum B { <nl> + case c < T where H : Int - > ( f <nl> + } <nl> + if true { <nl> + struct Q < h <nl> + let : a <nl> + protocol A { extension { <nl> + class b { enum B { typealias e <nl> + " <nl> + struct c <nl> + let : a <nl> + } <nl> + struct Q { <nl> + } <nl> + import a <nl> + class a where g : B <nl> | [ swiftc ] Add crash triggered in swift : : DeclContext : : isCascadingContextForLookup ( bool ) const . Bumps # of unresolved crash cases to 92 . | apple/swift | bc0d7b5193fc9e9578d237dd29e0e2ce204cc216 | 2016-06-16T06:13:38Z |
mmm a / docs / quickstart / apollo_3_5_map_collection_guidelines . md <nl> ppp b / docs / quickstart / apollo_3_5_map_collection_guidelines . md <nl> Confirm whether the sensors are ready . The button should be ` Green ` <nl> <nl> The only special case is that the additional front lidar 16 ( which is facing upwards ) which is installed for traffic lights , is not Green – this can be ignored when traffic light information is not being collected <nl> <nl> - ! [ ] ( images / map1 . png ) <nl> + ! [ ] ( images / map1 . png ) <nl> <nl> 2 . Go into your terminal , <nl> - Enter ` dev_docker ` on your terminal and type ` cyber_monitor ` <nl> | docs : broken link | ApolloAuto/apollo | 5ed6e0d2c19bece39c04afc472602e4c36b01674 | 2019-05-22T18:45:08Z |
mmm a / Editor / Scripts / Tests / Attachments . py <nl> ppp b / Editor / Scripts / Tests / Attachments . py <nl> def setUp ( self ) : <nl> trackview . set_recording ( False ) <nl> <nl> def test_basic_attachments ( self ) : <nl> - self . assertEqual ( general . get_object_parent ( " AnimObject2 " ) , " " ) <nl> - general . attach_object ( " AnimObject1 " , " AnimObject2 " , " " , " " ) <nl> - self . assertEqual ( general . get_object_parent ( " AnimObject2 " ) , " AnimObject1 " ) <nl> - self . assertEqual ( general . get_position ( " AnimObject2 " ) , ( 4 , 0 , 0 ) ) <nl> - self . assertEqual ( general . get_world_position ( " AnimObject2 " ) , ( 1028 , 1024 , 0 ) ) <nl> - general . set_position ( " AnimObject1 " , 1030 , 1030 , 0 ) <nl> - self . assertEqual ( general . get_world_position ( " AnimObject2 " ) , ( 1034 , 1030 , 0 ) ) <nl> - general . set_rotation ( " AnimObject1 " , 0 , 0 , - 90 ) <nl> - self . assertEqual ( general . get_world_position ( " AnimObject2 " ) , ( 1030 , 1026 , 0 ) ) <nl> - general . set_scale ( " AnimObject1 " , 0 . 5 , 0 . 5 , 0 . 5 ) <nl> - self . assertEqual ( general . get_world_position ( " AnimObject2 " ) , ( 1030 , 1028 , 0 ) ) <nl> - self . assertEqual ( general . get_position ( " AnimObject2 " ) , ( 4 , 0 , 0 ) ) <nl> + self . assertEqual ( object . get_object_parent ( " AnimObject2 " ) , " " ) <nl> + object . attach_object ( " AnimObject1 " , " AnimObject2 " , " " , " " ) <nl> + self . assertEqual ( object . get_object_parent ( " AnimObject2 " ) , " AnimObject1 " ) <nl> + self . assertEqual ( object . get_position ( " AnimObject2 " ) , ( 4 , 0 , 0 ) ) <nl> + self . assertEqual ( object . get_world_position ( " AnimObject2 " ) , ( 1028 , 1024 , 0 ) ) <nl> + object . set_position ( " AnimObject1 " , 1030 , 1030 , 0 ) <nl> + self . assertEqual ( object . get_world_position ( " AnimObject2 " ) , ( 1034 , 1030 , 0 ) ) <nl> + object . set_rotation ( " AnimObject1 " , 0 , 0 , - 90 ) <nl> + self . assertEqual ( object . get_world_position ( " AnimObject2 " ) , ( 1030 , 1026 , 0 ) ) <nl> + object . set_scale ( " AnimObject1 " , 0 . 5 , 0 . 5 , 0 . 5 ) <nl> + self . assertEqual ( object . get_world_position ( " AnimObject2 " ) , ( 1030 , 1028 , 0 ) ) <nl> + self . assertEqual ( object . get_position ( " AnimObject2 " ) , ( 4 , 0 , 0 ) ) <nl> <nl> def test_undo_redo ( self ) : <nl> - general . attach_object ( " AnimObject1 " , " AnimObject2 " , " " , " " ) <nl> + object . attach_object ( " AnimObject1 " , " AnimObject2 " , " " , " " ) <nl> general . undo ( ) <nl> - self . assertEqual ( general . get_object_parent ( " AnimObject2 " ) , " " ) <nl> - self . assertEqual ( general . get_position ( " AnimObject2 " ) , ( 1028 , 1024 , 0 ) ) <nl> + self . assertEqual ( object . get_object_parent ( " AnimObject2 " ) , " " ) <nl> + self . assertEqual ( object . get_position ( " AnimObject2 " ) , ( 1028 , 1024 , 0 ) ) <nl> general . redo ( ) <nl> - self . assertEqual ( general . get_object_parent ( " AnimObject2 " ) , " AnimObject1 " ) <nl> - self . assertEqual ( general . get_position ( " AnimObject2 " ) , ( 4 , 0 , 0 ) ) <nl> + self . assertEqual ( object . get_object_parent ( " AnimObject2 " ) , " AnimObject1 " ) <nl> + self . assertEqual ( object . get_position ( " AnimObject2 " ) , ( 4 , 0 , 0 ) ) <nl> general . undo ( ) <nl> - self . assertEqual ( general . get_object_parent ( " AnimObject2 " ) , " " ) <nl> - self . assertEqual ( general . get_position ( " AnimObject2 " ) , ( 1028 , 1024 , 0 ) ) <nl> - general . attach_object ( " AnimObject1 " , " AnimObject2 " , " " , " " ) <nl> - self . assertEqual ( general . get_object_parent ( " AnimObject2 " ) , " AnimObject1 " ) <nl> - general . detach_object ( " AnimObject2 " ) <nl> - self . assertEqual ( general . get_object_parent ( " AnimObject2 " ) , " " ) <nl> + self . assertEqual ( object . get_object_parent ( " AnimObject2 " ) , " " ) <nl> + self . assertEqual ( object . get_position ( " AnimObject2 " ) , ( 1028 , 1024 , 0 ) ) <nl> + object . attach_object ( " AnimObject1 " , " AnimObject2 " , " " , " " ) <nl> + self . assertEqual ( object . get_object_parent ( " AnimObject2 " ) , " AnimObject1 " ) <nl> + object . detach_object ( " AnimObject2 " ) <nl> + self . assertEqual ( object . get_object_parent ( " AnimObject2 " ) , " " ) <nl> general . undo ( ) <nl> - self . assertEqual ( general . get_object_parent ( " AnimObject2 " ) , " AnimObject1 " ) <nl> - self . assertEqual ( general . get_position ( " AnimObject2 " ) , ( 4 , 0 , 0 ) ) <nl> + self . assertEqual ( object . get_object_parent ( " AnimObject2 " ) , " AnimObject1 " ) <nl> + self . assertEqual ( object . get_position ( " AnimObject2 " ) , ( 4 , 0 , 0 ) ) <nl> general . redo ( ) <nl> - self . assertEqual ( general . get_object_parent ( " AnimObject2 " ) , " " ) <nl> - self . assertEqual ( general . get_position ( " AnimObject2 " ) , ( 1028 , 1024 , 0 ) ) <nl> + self . assertEqual ( object . get_object_parent ( " AnimObject2 " ) , " " ) <nl> + self . assertEqual ( object . get_position ( " AnimObject2 " ) , ( 1028 , 1024 , 0 ) ) <nl> <nl> unittest . main ( exit = False , verbosity = 2 , defaultTest = " TestAttachmentFunctions " ) <nl> \ No newline at end of file <nl> mmm a / Editor / Scripts / Tests / Misc . py <nl> ppp b / Editor / Scripts / Tests / Misc . py <nl> def setUp ( self ) : <nl> general . open_level_no_prompt ( " gamesdk / Levels / _TestMaps / Sandbox_Tests / Sandbox_Tests . cry " ) <nl> <nl> def test_add_entity_link ( self ) : <nl> - general . add_entity_link ( " AnimObject1 " , " AnimObject2 " , " TestLink " ) <nl> + entity . add_entity_link ( " AnimObject1 " , " AnimObject2 " , " TestLink " ) <nl> <nl> unittest . main ( exit = False , verbosity = 2 , defaultTest = " TestMiscFunctions " ) <nl> \ No newline at end of file <nl> mmm a / Editor / Scripts / Tests / TrackView . py <nl> ppp b / Editor / Scripts / Tests / TrackView . py <nl> def setUp ( self ) : <nl> trackview . set_recording ( False ) <nl> <nl> def test_base_anim_position ( self ) : <nl> - general . set_position ( " AnimObject1 " , 1030 , 1030 , 0 ) <nl> + object . set_position ( " AnimObject1 " , 1030 , 1030 , 0 ) <nl> <nl> trackview . set_current_sequence ( " TestSequence " ) <nl> trackview . set_time ( 10 ) <nl> - self . assertEqual ( general . get_position ( " AnimObject1 " ) , ( 1024 , 1031 , 0 ) ) <nl> - general . set_position ( " AnimObject1 " , 1000 , 1000 , 0 ) <nl> + self . assertEqual ( object . get_position ( " AnimObject1 " ) , ( 1024 , 1031 , 0 ) ) <nl> + object . set_position ( " AnimObject1 " , 1000 , 1000 , 0 ) <nl> <nl> trackview . set_current_sequence ( " " ) <nl> - self . assertEqual ( general . get_position ( " AnimObject1 " ) , ( 1030 , 1030 , 0 ) ) <nl> + self . assertEqual ( object . get_position ( " AnimObject1 " ) , ( 1030 , 1030 , 0 ) ) <nl> <nl> trackview . set_current_sequence ( " TestSequence " ) <nl> trackview . set_time ( 10 ) <nl> - self . assertEqual ( general . get_position ( " AnimObject1 " ) , ( 1000 , 1000 , 0 ) ) <nl> + self . assertEqual ( object . get_position ( " AnimObject1 " ) , ( 1000 , 1000 , 0 ) ) <nl> <nl> def test_recording ( self ) : <nl> trackview . set_current_sequence ( " TestSequence " ) <nl> def test_recording ( self ) : <nl> trackview . set_recording ( True ) <nl> <nl> # Recording only works on selected objects . Those should NOT add a new key to the track or move the object , because the object is not selected . <nl> - oldPosition = general . get_position ( " AnimObject1 " ) <nl> - general . set_position ( " AnimObject1 " , 0 , 0 , 0 ) <nl> - self . assertEqual ( general . get_position ( " AnimObject1 " ) , oldPosition ) <nl> + oldPosition = object . get_position ( " AnimObject1 " ) <nl> + object . set_position ( " AnimObject1 " , 0 , 0 , 0 ) <nl> + self . assertEqual ( object . get_position ( " AnimObject1 " ) , oldPosition ) <nl> <nl> - oldScale = general . get_scale ( " AnimObject1 " ) <nl> - general . set_scale ( " AnimObject1 " , 2 , 2 , 2 ) <nl> - self . assertEqual ( general . get_scale ( " AnimObject1 " ) , oldScale ) <nl> + oldScale = object . get_scale ( " AnimObject1 " ) <nl> + object . set_scale ( " AnimObject1 " , 2 , 2 , 2 ) <nl> + self . assertEqual ( object . get_scale ( " AnimObject1 " ) , oldScale ) <nl> <nl> - oldRotation = general . get_rotation ( " AnimObject1 " ) <nl> - general . set_rotation ( " AnimObject1 " , 30 , 30 , 30 ) <nl> - self . assertEqual ( general . get_rotation ( " AnimObject1 " ) , oldRotation ) <nl> + oldRotation = object . get_rotation ( " AnimObject1 " ) <nl> + object . set_rotation ( " AnimObject1 " , 30 , 30 , 30 ) <nl> + self . assertEqual ( object . get_rotation ( " AnimObject1 " ) , oldRotation ) <nl> <nl> # Now select the object and do that again <nl> - general . select_object ( " AnimObject1 " ) <nl> - general . set_position ( " AnimObject1 " , 1030 , 1030 , 0 ) <nl> - self . assertEqual ( general . get_position ( " AnimObject1 " ) , ( 1030 , 1030 , 0 ) ) <nl> + selection . select_object ( " AnimObject1 " ) <nl> + object . set_position ( " AnimObject1 " , 1030 , 1030 , 0 ) <nl> + self . assertEqual ( object . get_position ( " AnimObject1 " ) , ( 1030 , 1030 , 0 ) ) <nl> <nl> - general . set_scale ( " AnimObject1 " , 2 , 2 , 2 ) <nl> - self . assertEqual ( general . get_scale ( " AnimObject1 " ) , ( 2 , 2 , 2 ) ) <nl> + object . set_scale ( " AnimObject1 " , 2 , 2 , 2 ) <nl> + self . assertEqual ( object . get_scale ( " AnimObject1 " ) , ( 2 , 2 , 2 ) ) <nl> <nl> - general . set_rotation ( " AnimObject1 " , 30 , 30 , 30 ) <nl> - newRotation = tuple ( [ round ( x , 3 ) for x in general . get_rotation ( " AnimObject1 " ) ] ) <nl> + object . set_rotation ( " AnimObject1 " , 30 , 30 , 30 ) <nl> + newRotation = tuple ( [ round ( x , 3 ) for x in object . get_rotation ( " AnimObject1 " ) ] ) <nl> self . assertEqual ( newRotation , ( 30 , 30 , 30 ) ) <nl> <nl> # This should NOT add a new key to the track , because the time is still the same , but the object should still move . <nl> - general . set_position ( " AnimObject1 " , 1025 , 1027 , 0 ) <nl> - self . assertEqual ( general . get_position ( " AnimObject1 " ) , ( 1025 , 1027 , 0 ) ) <nl> + object . set_position ( " AnimObject1 " , 1025 , 1027 , 0 ) <nl> + self . assertEqual ( object . get_position ( " AnimObject1 " ) , ( 1025 , 1027 , 0 ) ) <nl> <nl> # Changing time should NOT add new keys <nl> trackview . set_time ( 3 ) <nl> def test_add_entities ( self ) : <nl> trackview . set_current_sequence ( " TestSequence " ) <nl> self . assertEqual ( trackview . get_num_nodes ( " " ) , 1 ) <nl> <nl> - general . clear_selection ( ) <nl> - general . select_objects ( [ " AnimObject1 " , " AnimObject2 " ] ) <nl> + selection . clear ( ) <nl> + selection . select_objects ( [ " AnimObject1 " , " AnimObject2 " ] ) <nl> trackview . add_selected_entities ( ) <nl> <nl> self . assertEqual ( trackview . get_num_track_keys ( " position " , 0 , " AnimObject2 " , " " ) , 0 ) <nl> def test_add_entities ( self ) : <nl> <nl> def test_move_without_recording ( self ) : <nl> trackview . set_current_sequence ( " TestSequence " ) <nl> - general . set_position ( " AnimObject1 " , 1030 , 1030 , 0 ) <nl> + object . set_position ( " AnimObject1 " , 1030 , 1030 , 0 ) <nl> self . assertEqual ( trackview . get_num_track_keys ( " position " , 0 , " AnimObject1 " , " " ) , 2 ) <nl> self . assertEqual ( trackview . get_key_value ( " position " , 0 , 0 , " AnimObject1 " , " " ) , ( 1030 , 1030 , 0 ) ) <nl> self . assertEqual ( trackview . get_key_value ( " position " , 0 , 1 , " AnimObject1 " , " " ) , ( 1030 , 1037 , 0 ) ) <nl> def test_undo_redo ( self ) : <nl> self . assertEqual ( trackview . get_sequence_time_range ( " TestSequence2 " ) , ( 0 , 20 ) ) <nl> <nl> trackview . set_current_sequence ( " TestSequence2 " ) <nl> - general . select_objects ( [ " AnimObject1 " , " AnimObject2 " ] ) <nl> + selection . select_objects ( [ " AnimObject1 " , " AnimObject2 " ] ) <nl> trackview . add_selected_entities ( ) <nl> <nl> self . assertEqual ( trackview . get_num_nodes ( " " ) , 2 ) <nl> def test_undo_redo ( self ) : <nl> self . assertEqual ( trackview . get_num_nodes ( " " ) , 2 ) <nl> <nl> def test_object_rename ( self ) : <nl> - general . rename_object ( " AnimObject1 " , " AnimObject3 " ) <nl> + object . rename_object ( " AnimObject1 " , " AnimObject3 " ) <nl> trackview . set_current_sequence ( " TestSequence " ) <nl> nodeName = trackview . get_node_name ( 0 , " " ) <nl> self . assertEqual ( nodeName , " AnimObject3 " ) <nl> mmm a / Editor / Scripts / rename_cgf . py <nl> ppp b / Editor / Scripts / rename_cgf . py <nl> <nl> # Copyright 2001 - 2016 Crytek GmbH / Crytek Group . All rights reserved . <nl> <nl> - objects = general . get_all_objects ( " " , " " ) # Get the name list of all objects in the level . <nl> + objects = object . get_all_objects ( " " , " " ) # Get the name list of all objects in the level . <nl> # If there is any object with the geometry file of " objects \ \ default \ \ primitive_box . cgf " , <nl> # change it to " objects \ \ default \ \ primitive_cube . cgf " . <nl> for obj in objects : <nl> - geometry_file = general . get_entity_geometry_file ( obj ) <nl> + geometry_file = entity . get_geometry_file ( obj ) <nl> if geometry_file = = " objects \ \ default \ \ primitive_box . cgf " : <nl> - general . set_entity_geometry_file ( obj , " objects \ \ default \ \ primitive_cube . cgf " ) <nl> + entity . set_geometry_file ( obj , " objects \ \ default \ \ primitive_cube . cgf " ) <nl> mmm a / Editor / Scripts / select_story_anim_objects . py <nl> ppp b / Editor / Scripts / select_story_anim_objects . py <nl> <nl> # Copyright 2001 - 2016 Crytek GmbH / Crytek Group . All rights reserved . <nl> <nl> - objects = general . get_all_objects ( " AnimObject " , " " ) # Get the name list of all anim objects in the level . <nl> - general . clear_selection ( ) <nl> + objects = object . get_all_objects ( " AnimObject " , " " ) # Get the name list of all anim objects in the level . <nl> + selection . clear ( ) <nl> # If there is any object with the geometry file whose name contains " \ \ story \ \ " , select it <nl> for obj in objects : <nl> - geometry_file = general . get_entity_geometry_file ( obj ) <nl> + geometry_file = entity . get_geometry_file ( obj ) <nl> if geometry_file . find ( " \ \ story \ \ " ) ! = - 1 : <nl> - general . select_object ( obj ) <nl> + selection . select_object ( obj ) <nl> mmm a / Editor / Scripts / tools_shelf_actions . py <nl> ppp b / Editor / Scripts / tools_shelf_actions . py <nl> def toggleHideByT ( mode , type , onValue , offValue , ctrlFile ) : <nl> hideByType ( type ) <nl> <nl> def hideByType ( type ) : <nl> - typeList = general . get_all_objects ( str ( type ) , " " ) <nl> + typeList = object . get_all_objects ( str ( type ) , " " ) <nl> # print typeList <nl> - # general . select_objects ( typeList ) <nl> + # selection . select_objects ( typeList ) <nl> for x in typeList : <nl> - general . hide_object ( x ) <nl> + object . hide ( x ) <nl> <nl> def unHideByType ( type ) : <nl> - typeList = general . get_all_objects ( str ( type ) , " " ) <nl> + typeList = object . get_all_objects ( str ( type ) , " " ) <nl> # print typeList <nl> - # general . select_objects ( typeList ) <nl> + # selection . select_objects ( typeList ) <nl> for x in typeList : <nl> - general . unhide_object ( x ) <nl> \ No newline at end of file <nl> + object . show ( x ) <nl> \ No newline at end of file <nl> mmm a / Editor / ToolBars / Constraints . json <nl> ppp b / Editor / ToolBars / Constraints . json <nl> <nl> { <nl> - " toolBar " : { <nl> - " Commands " : [ <nl> - { <nl> - " command " : " ui_action . actionLock_X_Axis " , <nl> - " custom " : false , <nl> - " uiName " : " Lock on X Axis " <nl> - } , <nl> - { <nl> - " command " : " ui_action . actionLock_Y_Axis " , <nl> - " custom " : false , <nl> - " uiName " : " Lock on Y Axis " <nl> - } , <nl> - { <nl> - " command " : " ui_action . actionLock_Z_Axis " , <nl> - " custom " : false , <nl> - " uiName " : " Lock on Z Axis " <nl> - } , <nl> - { <nl> - " command " : " ui_action . actionLock_XY_Axis " , <nl> - " custom " : false , <nl> - " uiName " : " Lock on XY Plane " <nl> - } <nl> - ] <nl> - } , <nl> - " version " : 1 <nl> + " toolBar " : [ <nl> + { <nl> + " command " : " tools . enable_x_axis_contraint " , <nl> + " iconPath " : " icons : Navigation / Axis_X . ico " , <nl> + " m_IsCustom " : false , <nl> + " name " : " enable_x_axis_contraint " , <nl> + " type " : 0 <nl> + } , <nl> + { <nl> + " command " : " tools . enable_y_axis_contraint " , <nl> + " iconPath " : " icons : Navigation / Axis_Y . ico " , <nl> + " m_IsCustom " : false , <nl> + " name " : " enable_y_axis_contraint " , <nl> + " type " : 0 <nl> + } , <nl> + { <nl> + " command " : " tools . enable_z_axis_contraint " , <nl> + " iconPath " : " icons : Navigation / Axis_Z . ico " , <nl> + " m_IsCustom " : false , <nl> + " name " : " enable_z_axis_contraint " , <nl> + " type " : 0 <nl> + } , <nl> + { <nl> + " command " : " tools . enable_xy_axis_contraint " , <nl> + " iconPath " : " icons : Navigation / Axis_XY . ico " , <nl> + " m_IsCustom " : false , <nl> + " name " : " enable_xy_axis_contraint " , <nl> + " type " : 0 <nl> + } <nl> + ] , <nl> + " version " : 2 <nl> } <nl> mmm a / Editor / ToolBars / Coordinates . json <nl> ppp b / Editor / ToolBars / Coordinates . json <nl> <nl> { <nl> - " toolBar " : { <nl> - " Commands " : [ <nl> - { <nl> - " command " : " general . set_world_coordinates " , <nl> - " custom " : false , <nl> - " uiName " : " World " <nl> - } , <nl> - { <nl> - " command " : " general . set_local_coordinates " , <nl> - " custom " : false , <nl> - " uiName " : " Local " <nl> - } , <nl> - { <nl> - " command " : " general . set_view_coordinates " , <nl> - " custom " : false , <nl> - " uiName " : " View " <nl> - } , <nl> - { <nl> - " command " : " general . set_parent_coordinates " , <nl> - " custom " : false , <nl> - " uiName " : " Parent " <nl> - } <nl> - ] <nl> - } , <nl> - " version " : 1 <nl> - } <nl> \ No newline at end of file <nl> + " toolBar " : [ <nl> + { <nl> + " command " : " level . set_world_coordinate_system " , <nl> + " iconPath " : " icons : Navigation / Coordinates_World . ico " , <nl> + " m_IsCustom " : false , <nl> + " name " : " set_world_coordinate_system " , <nl> + " type " : 0 <nl> + } , <nl> + { <nl> + " command " : " level . set_local_coordinate_system " , <nl> + " iconPath " : " icons : Navigation / Coordinates_Local . ico " , <nl> + " m_IsCustom " : false , <nl> + " name " : " set_local_coordinate_system " , <nl> + " type " : 0 <nl> + } , <nl> + { <nl> + " command " : " level . set_view_coordinate_system " , <nl> + " iconPath " : " icons : Navigation / Coordinates_View . ico " , <nl> + " m_IsCustom " : false , <nl> + " name " : " set_view_coordinate_system " , <nl> + " type " : 0 <nl> + } , <nl> + { <nl> + " command " : " level . set_parent_coordinate_system " , <nl> + " iconPath " : " icons : Navigation / Coordinates_Parent . ico " , <nl> + " m_IsCustom " : false , <nl> + " name " : " set_parent_coordinate_system " , <nl> + " type " : 0 <nl> + } <nl> + ] , <nl> + " version " : 2 <nl> + } <nl> diff - - git a / Editor / ToolBars / Edit Modes . json b / Editor / ToolBars / Edit Modes . json <nl> mmm a / Editor / ToolBars / Edit Modes . json <nl> ppp b / Editor / ToolBars / Edit Modes . json <nl> <nl> " toolBar " : { <nl> " Commands " : [ <nl> { <nl> - " command " : " ui_action . actionSelect_Mode " , <nl> + " command " : " tools . select " , <nl> " custom " : false , <nl> " uiName " : " Select Mode " <nl> } , <nl> { <nl> - " command " : " ui_action . actionMove " , <nl> + " command " : " tools . move " , <nl> " custom " : false , <nl> " uiName " : " Move " <nl> } , <nl> { <nl> - " command " : " ui_action . actionRotate " , <nl> + " command " : " tools . rotate " , <nl> " custom " : false , <nl> " uiName " : " Rotate " <nl> } , <nl> { <nl> - " command " : " ui_action . actionScale " , <nl> + " command " : " tools . scale " , <nl> " custom " : false , <nl> " uiName " : " Scale " <nl> } <nl> mmm a / Editor / ToolBars / Game . json <nl> ppp b / Editor / ToolBars / Game . json <nl> <nl> { <nl> - " toolBar " : { <nl> - " Commands " : [ <nl> - { <nl> - " command " : " ui_action . actionSwitch_to_Game " , <nl> - " custom " : false , <nl> - " uiName " : " Switch to Game " <nl> - } , <nl> - { <nl> - " command " : " ui_action . actionEnable_Physics_AI " , <nl> - " custom " : false , <nl> - " uiName " : " Enable Physics / AI " <nl> - } , <nl> - { <nl> - " command " : " physics . single_step " , <nl> - " custom " : false , <nl> - " uiName " : " Toggle single - step mode in physics " <nl> - } , <nl> - { <nl> - " command " : " physics . step " , <nl> - " custom " : false , <nl> - " uiName " : " Do a single physics step " <nl> - } <nl> - ] <nl> - } , <nl> - " version " : 1 <nl> + " toolBar " : [ <nl> + { <nl> + " command " : " game . toggle_game_mode " , <nl> + " iconPath " : " icons : Game / Game_Play . ico " , <nl> + " m_IsCustom " : false , <nl> + " name " : " toggle_game_mode " , <nl> + " type " : 0 <nl> + } , <nl> + { <nl> + " command " : " game . toggle_simulate_physics_ai " , <nl> + " iconPath " : " icons : common / general_physics_play . ico " , <nl> + " m_IsCustom " : false , <nl> + " name " : " toggle_simulate_physics_ai " , <nl> + " type " : 0 <nl> + } , <nl> + { <nl> + " command " : " physics . single_step " , <nl> + " iconPath " : " " , <nl> + " m_IsCustom " : false , <nl> + " name " : " Toggle single - step mode in physics " , <nl> + " type " : 0 <nl> + } , <nl> + { <nl> + " command " : " physics . step " , <nl> + " iconPath " : " " , <nl> + " m_IsCustom " : false , <nl> + " name " : " Do a single physics step " , <nl> + " type " : 0 <nl> + } <nl> + ] , <nl> + " version " : 2 <nl> } <nl> mmm a / Editor / ToolBars / Physics . json <nl> ppp b / Editor / ToolBars / Physics . json <nl> <nl> { <nl> - " toolBar " : { <nl> - " Commands " : [ <nl> - { <nl> - " command " : " ui_action . actionReset_Physics_State " , <nl> - " custom " : false , <nl> - " uiName " : " Reset Physics State " <nl> - } , <nl> - { <nl> - " command " : " ui_action . actionGet_Physics_State " , <nl> - " custom " : false , <nl> - " uiName " : " Get Physics State " <nl> - } , <nl> - { <nl> - " command " : " ui_action . actionPhysics_Simulate_Objects " , <nl> - " custom " : false , <nl> - " uiName " : " Simulate Objects " <nl> - } , <nl> - { <nl> - " command " : " physics . set_physics_tool " , <nl> - " custom " : false , <nl> - " uiName " : " Turns on physics tool mode ( Ctrl / Shift modify ) " <nl> - } <nl> - ] <nl> - } , <nl> - " version " : 1 <nl> + " toolBar " : [ <nl> + { <nl> + " command " : " physics . reset_state_selection " , <nl> + " iconPath " : " icons : General / Reset_Physics . ico " , <nl> + " m_IsCustom " : false , <nl> + " name " : " reset_state_selection " , <nl> + " type " : 0 <nl> + } , <nl> + { <nl> + " command " : " physics . get_state_selection " , <nl> + " iconPath " : " icons : General / Get_Physics . ico " , <nl> + " m_IsCustom " : false , <nl> + " name " : " get_state_selection " , <nl> + " type " : 0 <nl> + } , <nl> + { <nl> + " command " : " physics . simulate_objects " , <nl> + " iconPath " : " icons : General / Simulate_Physics . ico " , <nl> + " m_IsCustom " : false , <nl> + " name " : " simulate_objects " , <nl> + " type " : 0 <nl> + } , <nl> + { <nl> + " command " : " physics . set_physics_tool " , <nl> + " iconPath " : " " , <nl> + " m_IsCustom " : false , <nl> + " name " : " Turns on physics tool mode ( Ctrl / Shift modify ) " , <nl> + " type " : 0 <nl> + } <nl> + ] , <nl> + " version " : 2 <nl> } <nl> mmm a / Editor / ToolBars / Selection . json <nl> ppp b / Editor / ToolBars / Selection . json <nl> <nl> { <nl> - " toolBar " : { <nl> - " Commands " : [ <nl> - { <nl> - " command " : " level . go_to_selection " , <nl> - " custom " : false , <nl> - " uiName " : " Go to Selection " <nl> - } , <nl> - { <nl> - " command " : " general . find " , <nl> - " custom " : false , <nl> - " uiName " : " Find . . . " <nl> - } , <nl> - " separator " , <nl> - { <nl> - " command " : " ui_action . actionGroup " , <nl> - " custom " : false , <nl> - " uiName " : " Group " <nl> - } , <nl> - { <nl> - " command " : " ui_action . actionUngroup " , <nl> - " custom " : false , <nl> - " uiName " : " Ungroup " <nl> - } , <nl> - { <nl> - " command " : " ui_action . actionLink " , <nl> - " custom " : false , <nl> - " uiName " : " Link " <nl> - } , <nl> - { <nl> - " command " : " ui_action . actionUnlink " , <nl> - " custom " : false , <nl> - " uiName " : " Unlink " <nl> - } , <nl> - { <nl> - " command " : " prefab . create_from_selection " , <nl> - " custom " : false , <nl> - " uiName " : " Create Prefab from Selected Objects " <nl> - } , <nl> - " separator " , <nl> - { <nl> - " command " : " ui_action . actionFreeze_Selection " , <nl> - " custom " : false , <nl> - " uiName " : " Freeze Selection " <nl> - } , <nl> - { <nl> - " command " : " ui_action . actionUnfreeze_All " , <nl> - " custom " : false , <nl> - " uiName " : " Unfreeze All " <nl> - } <nl> - ] <nl> - } , <nl> - " version " : 1 <nl> + " toolBar " : [ <nl> + { <nl> + " command " : " selection . go_to " , <nl> + " iconPath " : " " , <nl> + " m_IsCustom " : false , <nl> + " name " : " Go to Selection " , <nl> + " type " : 0 <nl> + } , <nl> + { <nl> + " command " : " general . find " , <nl> + " iconPath " : " " , <nl> + " m_IsCustom " : false , <nl> + " name " : " Find . . . " , <nl> + " type " : 0 <nl> + } , <nl> + " separator " , <nl> + { <nl> + " command " : " group . create_from_selection " , <nl> + " iconPath " : " icons : General / Group . ico " , <nl> + " m_IsCustom " : false , <nl> + " name " : " create_from_selection " , <nl> + " type " : 0 <nl> + } , <nl> + { <nl> + " command " : " group . ungroup " , <nl> + " iconPath " : " icons : General / UnGroup . ico " , <nl> + " m_IsCustom " : false , <nl> + " name " : " ungroup " , <nl> + " type " : 0 <nl> + } , <nl> + { <nl> + " command " : " tools . link " , <nl> + " iconPath " : " " , <nl> + " m_IsCustom " : false , <nl> + " name " : " Link " , <nl> + " type " : 0 <nl> + } , <nl> + { <nl> + " command " : " tools . unlink " , <nl> + " iconPath " : " " , <nl> + " m_IsCustom " : false , <nl> + " name " : " Unlink " , <nl> + " type " : 0 <nl> + } , <nl> + { <nl> + " command " : " prefab . create_from_selection " , <nl> + " iconPath " : " " , <nl> + " m_IsCustom " : false , <nl> + " name " : " Create Prefab from Selected Objects " , <nl> + " type " : 0 <nl> + } , <nl> + " separator " , <nl> + { <nl> + " command " : " selection . make_objects_uneditable " , <nl> + " iconPath " : " " , <nl> + " m_IsCustom " : false , <nl> + " name " : " Freeze Selection " , <nl> + " type " : 0 <nl> + } , <nl> + { <nl> + " command " : " object . make_all_editable " , <nl> + " iconPath " : " " , <nl> + " m_IsCustom " : false , <nl> + " name " : " Unfreeze All " , <nl> + " type " : 0 <nl> + } <nl> + ] , <nl> + " version " : 2 <nl> } <nl> mmm a / Editor / ToolBars / Standard . json <nl> ppp b / Editor / ToolBars / Standard . json <nl> <nl> " uiName " : " & Open . . . " <nl> } , <nl> { <nl> - " command " : " ui_action . actionExport_to_Engine " , <nl> + " command " : " exporter . export_to_engine " , <nl> " custom " : false , <nl> " uiName " : " Export to Engine " <nl> } , <nl> | ! XI Copying task_sandbox_mainframe_cleanup to main | CRYTEK/CRYENGINE | 5ca1c432bb7a12f2ad0a3fb0c63251bbb0eebed1 | 2018-03-14T08:26:47Z |
mmm a / src / core / loader / deconstructed_rom_directory . cpp <nl> ppp b / src / core / loader / deconstructed_rom_directory . cpp <nl> AppLoader_DeconstructedRomDirectory : : LoadResult AppLoader_DeconstructedRomDirect <nl> } <nl> metadata . Print ( ) ; <nl> <nl> - const FileSys : : ProgramAddressSpaceType arch_bits { metadata . GetAddressSpaceType ( ) } ; <nl> - if ( arch_bits = = FileSys : : ProgramAddressSpaceType : : Is32Bit | | <nl> - arch_bits = = FileSys : : ProgramAddressSpaceType : : Is32BitNoMap ) { <nl> - return { ResultStatus : : Error32BitISA , { } } ; <nl> - } <nl> - <nl> if ( process . LoadFromMetadata ( metadata ) . IsError ( ) ) { <nl> return { ResultStatus : : ErrorUnableToParseKernelMetadata , { } } ; <nl> } <nl> | core : loader : Remove check for 32 - bit . | yuzu-emu/yuzu | 6fc485a6079038356f3f840e12c366d488caabc6 | 2020-03-03T02:43:15Z |
mmm a / modules / planning / constraint_checker / collision_checker . cc <nl> ppp b / modules / planning / constraint_checker / collision_checker . cc <nl> void CollisionChecker : : BuildPredictedEnvironment ( <nl> bool ego_vehicle_in_lane = IsEgoVehicleInLane ( ego_vehicle_d ) ; <nl> std : : vector < const Obstacle * > obstacles_considered ; <nl> for ( const Obstacle * obstacle : obstacles ) { <nl> + if ( obstacle - > IsVirtual ( ) ) { <nl> + continue ; <nl> + } <nl> if ( ego_vehicle_in_lane & & <nl> ShouldIgnore ( obstacle , ego_vehicle_s , discretized_reference_line ) ) { <nl> continue ; <nl> mmm a / modules / planning / lattice / behavior / path_time_graph . cc <nl> ppp b / modules / planning / lattice / behavior / path_time_graph . cc <nl> void PathTimeGraph : : SetupObstacles ( <nl> const std : : vector < const Obstacle * > & obstacles , <nl> const std : : vector < PathPoint > & discretized_ref_points ) { <nl> for ( const Obstacle * obstacle : obstacles ) { <nl> + if ( obstacle - > IsVirtual ( ) ) { <nl> + continue ; <nl> + } <nl> if ( ! obstacle - > HasTrajectory ( ) ) { <nl> SetStaticObstacle ( obstacle , discretized_ref_points ) ; <nl> continue ; <nl> | Planning : remove virtual obstacle from path_time_graph and collision checker | ApolloAuto/apollo | 2ea4fddc447c5086b5aa7c1e7b5d11583abf190e | 2018-03-09T02:57:42Z |
mmm a / test / test_autograd . py <nl> ppp b / test / test_autograd . py <nl> def index_variable ( num_indices , max_indices ) : <nl> ( ' dist ' , ( S , S , S ) , ( ( S , S , S ) , ) ) , <nl> ( ' dist ' , ( S , S , S ) , ( ( S , S , S ) , 4 ) , ' 4 ' ) , <nl> ( ' index_select ' , ( S , S , S ) , ( 0 , index_variable ( 2 , S ) ) ) , <nl> - ( ' cat ' , ( 1 , S , S ) , ( ( Variable ( torch . randn ( 2 , S , S ) ) , Variable ( torch . randn ( 3 , S , S ) ) ) , 0 ) ) , <nl> ( ' diag ' , ( M , M ) , ( ) , ' 2d ' ) , <nl> ( ' diag ' , ( M , ) , ( ) , ' 1d ' ) , <nl> ( ' tril ' , ( M , M ) , ( ) ) , <nl> mmm a / test / test_torch . py <nl> ppp b / test / test_torch . py <nl> def test_cat ( self ) : <nl> for dim in range ( 3 ) : <nl> x = torch . rand ( 13 , SIZE , SIZE ) . transpose ( 0 , dim ) <nl> y = torch . rand ( 17 , SIZE , SIZE ) . transpose ( 0 , dim ) <nl> - res1 = torch . cat ( x , y , dim ) <nl> + res1 = torch . cat ( ( x , y ) , dim ) <nl> self . assertEqual ( res1 . narrow ( dim , 0 , 13 ) , x , 0 ) <nl> self . assertEqual ( res1 . narrow ( dim , 13 , 17 ) , y , 0 ) <nl> <nl> - # Check stateless implementation <nl> - res2 = torch . Tensor ( ) <nl> - torch . cat ( res2 , x , y , dim ) <nl> - self . assertEqual ( res1 , res2 , 0 ) <nl> - <nl> # Check iterables <nl> for dim in range ( 3 ) : <nl> x = torch . rand ( 13 , SIZE , SIZE ) . transpose ( 0 , dim ) <nl> def test_cat ( self ) : <nl> self . assertEqual ( res1 . narrow ( dim , 30 , 19 ) , z , 0 ) <nl> self . assertRaises ( ValueError , lambda : torch . cat ( [ ] ) ) <nl> <nl> - res2 = torch . Tensor ( ) <nl> - torch . cat ( res2 , ( x , y , z ) , dim ) <nl> - self . assertEqual ( res1 , res2 , 0 ) <nl> - res2 = res2 . float ( ) <nl> - torch . cat ( res2 , ( x . float ( ) , y . float ( ) , z . float ( ) ) , dim ) <nl> - self . assertEqual ( res1 . float ( ) , res2 , 0 ) <nl> - res2 = res2 . double ( ) <nl> - torch . cat ( res2 , ( x . double ( ) , y . double ( ) , z . double ( ) ) , dim ) <nl> - self . assertEqual ( res1 . double ( ) , res2 , 0 ) <nl> - <nl> def test_linspace ( self ) : <nl> _from = random . random ( ) <nl> to = _from + random . random ( ) <nl> mmm a / torch / csrc / generic / TensorMethods . cwrap <nl> ppp b / torch / csrc / generic / TensorMethods . cwrap <nl> static const char * R = & __R ; <nl> ] ] <nl> <nl> <nl> - [ [ <nl> - name : THPTensor_ ( cat ) <nl> - python_name : cat <nl> - only_register : True <nl> - defined_if : CUDA_FLOAT | | ! IS_CUDA <nl> - ] ] <nl> [ [ <nl> name : THPTensor_stateless_ ( cat ) <nl> python_name : cat <nl> static const char * R = & __R ; <nl> defined_if : CUDA_FLOAT | | ! IS_CUDA <nl> ] ] <nl> # if ! IS_CUDA | | CUDA_FLOAT <nl> - static std : : pair < std : : vector < THPObjectPtr > , std : : vector < THTensor * > > <nl> - THPTensor_ ( _iterableTensors ) ( PyObject * iterable ) <nl> - { <nl> - THPObjectPtr iterator ; <nl> - THPObjectPtr item ; <nl> - std : : vector < THPObjectPtr > items ; <nl> - std : : vector < THTensor * > item_tensors ; <nl> - if ( ( iterator = PyObject_GetIter ( iterable ) ) ) { <nl> - while ( ( item = PyIter_Next ( iterator ) ) ) { <nl> - if ( ! THPTensor_ ( Check ) ( item ) ) { <nl> - THPUtils_setError ( " expected an iterable of " THPTensorStr " , but found % s in it " , Py_TYPE ( item ) - > tp_name ) ; <nl> - throw std : : exception ( ) ; <nl> - } <nl> - item_tensors . push_back ( ( ( THPTensor * ) item . get ( ) ) - > cdata ) ; <nl> - items . emplace_back ( std : : move ( item ) ) ; <nl> - } <nl> - } else { <nl> - throw std : : invalid_argument ( " " ) ; <nl> - } <nl> - return std : : make_pair ( std : : move ( items ) , std : : move ( item_tensors ) ) ; <nl> - } <nl> - <nl> - static PyObject * THPTensor_ ( cat ) ( THPTensor * self , PyObject * args ) <nl> + static PyObject * THPTensor_stateless_ ( cat ) ( THPTensor * _unused , PyObject * args ) <nl> { <nl> # if IS_CUDA & & THCP_AUTO_GPU <nl> THCPAutoGPU __autogpu_guard = THCPAutoGPU ( args ) ; <nl> # endif <nl> HANDLE_TH_ERRORS <nl> - THPTensor * tensor1 ; <nl> - THPTensor * tensor2 ; <nl> - long dimension ; <nl> - Py_ssize_t _argcount = PyTuple_Size ( args ) ; <nl> - if ( _argcount = = 2 ) { <nl> - PyObject * iterable = PyTuple_GET_ITEM ( args , 0 ) ; <nl> - PyObject * dim = PyTuple_GET_ITEM ( args , 1 ) ; <nl> - std : : vector < THPObjectPtr > items ; <nl> - std : : vector < THTensor * > item_tensors ; <nl> - if ( THPUtils_checkLong ( dim ) ) { <nl> - dimension = THPUtils_unpackLong ( dim ) ; <nl> - try { <nl> - std : : tie ( items , item_tensors ) = THPTensor_ ( _iterableTensors ) ( iterable ) ; <nl> - THTensor_ ( catArray ) ( LIBRARY_STATE self - > cdata , item_tensors . data ( ) , items . size ( ) , dimension ) ; <nl> - Py_INCREF ( self ) ; <nl> - return ( PyObject * ) self ; <nl> - <nl> - } catch ( std : : invalid_argument & e ) { <nl> - } catch ( std : : exception & e ) { <nl> - return NULL ; <nl> - } <nl> - } <nl> - } else if ( _argcount = = 3 ) { <nl> - if ( PyArg_ParseTuple ( args , " O ! O ! l " , THPTensorClass , & tensor1 , THPTensorClass , & tensor2 , & dimension ) ) { <nl> - THTensor_ ( cat ) ( LIBRARY_STATE self - > cdata , tensor1 - > cdata , tensor2 - > cdata , dimension ) ; <nl> - Py_INCREF ( self ) ; <nl> - return ( PyObject * ) self ; <nl> - } <nl> + Py_ssize_t _argcount = args ? PyTuple_Size ( args ) : 0 ; <nl> + std : : vector < THPObjectPtr > items ; <nl> + std : : vector < THTensor * > item_tensors ; <nl> + PyObject * sequence ; <nl> + Py_ssize_t seq_length ; <nl> + THTensorPtr _result ; <nl> + THPTensorPtr result ; <nl> + long dimension = - 1 ; <nl> + <nl> + if ( _argcount = = 0 | | _argcount > 2 | | ! PySequence_Check ( PyTuple_GET_ITEM ( args , 0 ) ) ) <nl> + goto invalid_arguments ; <nl> + sequence = PyTuple_GET_ITEM ( args , 0 ) ; <nl> + seq_length = PySequence_Length ( sequence ) ; <nl> + if ( seq_length < = 0 ) <nl> + goto invalid_arguments ; <nl> + <nl> + items . reserve ( seq_length ) ; <nl> + item_tensors . reserve ( seq_length ) ; <nl> + for ( int i = 0 ; i < seq_length ; i + + ) { <nl> + items . push_back ( PySequence_ITEM ( sequence , i ) ) ; <nl> + if ( ! THPTensor_ ( Check ) ( items [ i ] . get ( ) ) ) <nl> + goto invalid_arguments ; <nl> + item_tensors . push_back ( ( ( THPTensor * ) items [ i ] . get ( ) ) - > cdata ) ; <nl> } <nl> <nl> - / / TODO : describe args <nl> - THPUtils_invalidArguments ( args , " cat " , 1 , " ( TODO ) " ) ; <nl> - return NULL ; <nl> - END_HANDLE_TH_ERRORS <nl> - } <nl> - <nl> - static PyObject * THPTensor_stateless_ ( cat ) ( THPTensor * _unused , PyObject * args ) <nl> - { <nl> - # if IS_CUDA & & THCP_AUTO_GPU <nl> - THCPAutoGPU __autogpu_guard = THCPAutoGPU ( args ) ; <nl> - # endif <nl> - HANDLE_TH_ERRORS <nl> - THPTensor * tensor1 ; <nl> - THPTensor * tensor2 ; <nl> - long dimension ; <nl> - Py_ssize_t _argcount = PyTuple_Size ( args ) ; <nl> if ( _argcount = = 2 ) { <nl> - THTensorPtr _self = THTensor_ ( new ) ( LIBRARY_STATE_NOARGS ) ; <nl> - THPTensorPtr self = ( THPTensor * ) THPTensor_ ( New ) ( _self ) ; <nl> - if ( ! self ) <nl> - return NULL ; <nl> - _self . release ( ) ; <nl> - <nl> - PyObject * iterable = PyTuple_GET_ITEM ( args , 0 ) ; <nl> - PyObject * dim = PyTuple_GET_ITEM ( args , 1 ) ; <nl> - std : : vector < THPObjectPtr > items ; <nl> - std : : vector < THTensor * > item_tensors ; <nl> - if ( THPUtils_checkLong ( dim ) ) { <nl> - dimension = THPUtils_unpackLong ( dim ) ; <nl> - try { <nl> - std : : tie ( items , item_tensors ) = THPTensor_ ( _iterableTensors ) ( iterable ) ; <nl> - THTensor_ ( catArray ) ( LIBRARY_STATE self - > cdata , item_tensors . data ( ) , items . size ( ) , dimension ) ; <nl> - return ( PyObject * ) self . release ( ) ; <nl> - <nl> - } catch ( std : : invalid_argument & e ) { <nl> - } catch ( std : : exception & e ) { <nl> - return NULL ; <nl> - } <nl> - } <nl> - } else if ( _argcount = = 3 ) { <nl> - if ( PyArg_ParseTuple ( args , " O ! O ! l " , THPTensorClass , & tensor1 , THPTensorClass , & tensor2 , & dimension ) ) { <nl> - THTensorPtr _self = THTensor_ ( new ) ( LIBRARY_STATE_NOARGS ) ; <nl> - THPTensorPtr self = ( THPTensor * ) THPTensor_ ( New ) ( _self . get ( ) ) ; <nl> - if ( ! self ) <nl> - return NULL ; <nl> - _self . release ( ) ; <nl> - <nl> - THTensor_ ( cat ) ( LIBRARY_STATE self - > cdata , tensor1 - > cdata , tensor2 - > cdata , dimension ) ; <nl> - return ( PyObject * ) self . release ( ) ; <nl> - } else { <nl> - PyErr_Clear ( ) ; <nl> - THPTensor * self = ( THPTensor * ) PyTuple_GET_ITEM ( args , 0 ) ; <nl> - PyObject * iterable = PyTuple_GET_ITEM ( args , 1 ) ; <nl> - PyObject * dim = PyTuple_GET_ITEM ( args , 2 ) ; <nl> - <nl> - std : : vector < THPObjectPtr > items ; <nl> - std : : vector < THTensor * > item_tensors ; <nl> - if ( THPUtils_checkLong ( dim ) ) { <nl> - dimension = THPUtils_unpackLong ( dim ) ; <nl> - try { <nl> - std : : tie ( items , item_tensors ) = THPTensor_ ( _iterableTensors ) ( iterable ) ; <nl> - THTensor_ ( catArray ) ( LIBRARY_STATE self - > cdata , item_tensors . data ( ) , items . size ( ) , dimension ) ; <nl> - Py_INCREF ( self ) ; <nl> - return ( PyObject * ) self ; <nl> - <nl> - } catch ( std : : invalid_argument & e ) { <nl> - } catch ( std : : exception & e ) { <nl> - / / FIXME TODO : that ' s not a good way of handling errors <nl> - fprintf ( stderr , " e : % s \ n " , e . what ( ) ) ; <nl> - return NULL ; <nl> - } <nl> - } <nl> - } <nl> - } else if ( _argcount = = 4 ) { <nl> - THPTensor * self ; <nl> - if ( PyArg_ParseTuple ( args , " O ! O ! O ! l " , THPTensorClass , & self , THPTensorClass , & tensor1 , THPTensorClass , & tensor2 , & dimension ) ) { <nl> - THTensor_ ( cat ) ( LIBRARY_STATE self - > cdata , tensor1 - > cdata , tensor2 - > cdata , dimension ) ; <nl> - Py_INCREF ( self ) ; <nl> - return ( PyObject * ) self ; <nl> - } <nl> + if ( ! THPUtils_checkLong ( PyTuple_GET_ITEM ( args , 1 ) ) ) <nl> + goto invalid_arguments ; <nl> + dimension = THPUtils_unpackLong ( PyTuple_GET_ITEM ( args , 1 ) ) ; <nl> + } else { <nl> + dimension = THTensor_ ( size ) ( LIBRARY_STATE item_tensors [ 0 ] , <nl> + THTensor_ ( nDimension ) ( LIBRARY_STATE item_tensors [ 0 ] ) - 1 ) ; <nl> } <nl> <nl> - / / TODO : describe args <nl> - THPUtils_invalidArguments ( args , " cat " , 1 , " ( TODO ) " ) ; <nl> + _result = THTensor_ ( new ) ( LIBRARY_STATE_NOARGS ) ; <nl> + result = ( THPTensor * ) THPTensor_ ( New ) ( _result ) ; <nl> + if ( ! result ) <nl> + return NULL ; <nl> + _result . release ( ) ; <nl> + <nl> + THTensor_ ( catArray ) ( LIBRARY_STATE result - > cdata , item_tensors . data ( ) , <nl> + items . size ( ) , dimension ) ; <nl> + return ( PyObject * ) result . release ( ) ; <nl> + <nl> + invalid_arguments : <nl> + THPUtils_invalidArguments ( args , " cat " , 2 , <nl> + " ( sequence tensors ) " , <nl> + " ( sequence tensors , int dim ) " ) ; <nl> return NULL ; <nl> END_HANDLE_TH_ERRORS <nl> } <nl> mmm a / torch / legacy / nn / ClassSimplexCriterion . py <nl> ppp b / torch / legacy / nn / ClassSimplexCriterion . py <nl> def __init__ ( self , nClasses ) : <nl> # embedding the simplex in a space of dimension strictly greater than <nl> # the minimum possible ( nClasses - 1 ) is critical for effective training . <nl> simp = self . _regsplex ( nClasses - 1 ) <nl> - self . simplex = torch . cat ( simp , torch . zeros ( simp . size ( 0 ) , nClasses - simp . size ( 1 ) ) , 1 ) <nl> + self . simplex = torch . cat ( ( simp , torch . zeros ( simp . size ( 0 ) , nClasses - simp . size ( 1 ) ) ) , 1 ) <nl> self . _target = torch . Tensor ( nClasses ) <nl> <nl> self . output_tensor = None <nl> | Simplify torch . cat | pytorch/pytorch | 966adc62916326c9d43ee409a78a07c325c59ff9 | 2016-10-11T03:51:15Z |
mmm a / atom / browser / api / atom_api_web_contents . cc <nl> ppp b / atom / browser / api / atom_api_web_contents . cc <nl> void WebContents : : DidNavigateMainFrame ( <nl> <nl> void WebContents : : TitleWasSet ( content : : NavigationEntry * entry , <nl> bool explicit_set ) { <nl> - Emit ( " page - title - set " , entry - > GetTitle ( ) , explicit_set ) ; <nl> + / / Back / Forward navigation may have pruned entries . <nl> + if ( entry ) <nl> + Emit ( " page - title - set " , entry - > GetTitle ( ) , explicit_set ) ; <nl> } <nl> <nl> void WebContents : : DidUpdateFaviconURL ( <nl> | Merge pull request from deepak1556 / title_patch | electron/electron | 72f5381c31a807d7d1f87130c02eb90aad9a614d | 2015-04-30T08:54:14Z |
mmm a / CMakeLists . txt <nl> ppp b / CMakeLists . txt <nl> set ( CMAKE_CXX_STANDARD 14 ) <nl> <nl> set ( VERSION_MAJOR 2 ) <nl> set ( VERSION_MINOR 0 ) <nl> - set ( VERSION_PATCH 0 ) <nl> + set ( VERSION_PATCH 1 ) <nl> <nl> set ( CLI_CLIENT_EXECUTABLE_NAME eos_client ) <nl> set ( GUI_CLIENT_EXECUTABLE_NAME eos ) <nl> mmm a / docs / _r_e_a_d_m_e_8md . html <nl> ppp b / docs / _r_e_a_d_m_e_8md . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / annotated . html <nl> ppp b / docs / annotated . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / chain_8h . html <nl> ppp b / docs / chain_8h . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / chain_8h_source . html <nl> ppp b / docs / chain_8h_source . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / classes . html <nl> ppp b / docs / classes . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / crypto_8h . html <nl> ppp b / docs / crypto_8h . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / crypto_8h_source . html <nl> ppp b / docs / crypto_8h_source . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / currency_8cpp . html <nl> ppp b / docs / currency_8cpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / currency_8hpp . html <nl> ppp b / docs / currency_8hpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / currency_8hpp_source . html <nl> ppp b / docs / currency_8hpp_source . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / currency_8wast_8hpp . html <nl> ppp b / docs / currency_8wast_8hpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / currency_8wast_8hpp_source . html <nl> ppp b / docs / currency_8wast_8hpp_source . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / db_8h . html <nl> ppp b / docs / db_8h . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / db_8h_source . html <nl> ppp b / docs / db_8h_source . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / db_8hpp . html <nl> ppp b / docs / db_8hpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / db_8hpp_source . html <nl> ppp b / docs / db_8hpp_source . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / dice_8cpp . html <nl> ppp b / docs / dice_8cpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / dice_8hpp . html <nl> ppp b / docs / dice_8hpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / dice_8hpp_source . html <nl> ppp b / docs / dice_8hpp_source . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / dir_2f68902bd8ea4562ac77bb3db95ba614 . html <nl> ppp b / docs / dir_2f68902bd8ea4562ac77bb3db95ba614 . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / dir_322cd3c97a9c45f1dd8d138b04e20992 . html <nl> ppp b / docs / dir_322cd3c97a9c45f1dd8d138b04e20992 . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / dir_3680d2f7810f6721560f2a624729277d . html <nl> ppp b / docs / dir_3680d2f7810f6721560f2a624729277d . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / dir_3fea0bf1ce879ce73e6ecec98007efcd . html <nl> ppp b / docs / dir_3fea0bf1ce879ce73e6ecec98007efcd . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / dir_44e8454330c52effb0ef98d8f3108add . html <nl> ppp b / docs / dir_44e8454330c52effb0ef98d8f3108add . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / dir_4512a307eab2a9ca08d8433965f51830 . html <nl> ppp b / docs / dir_4512a307eab2a9ca08d8433965f51830 . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / dir_5dc13a1abd435123f7be5ea8dc751d1b . html <nl> ppp b / docs / dir_5dc13a1abd435123f7be5ea8dc751d1b . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / dir_6c7312813aa58ebc3dfdce40169e8db5 . html <nl> ppp b / docs / dir_6c7312813aa58ebc3dfdce40169e8db5 . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / dir_822c996966d1ea617c855d743c3f3186 . html <nl> ppp b / docs / dir_822c996966d1ea617c855d743c3f3186 . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / dir_a9257b511e702fbd3462fee4a063915c . html <nl> ppp b / docs / dir_a9257b511e702fbd3462fee4a063915c . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / dir_ae9b15dd87e066e1908bbd90e8f38627 . html <nl> ppp b / docs / dir_ae9b15dd87e066e1908bbd90e8f38627 . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / dir_da2258ea5bfae2641df967be076d9dbe . html <nl> ppp b / docs / dir_da2258ea5bfae2641df967be076d9dbe . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / dir_df9ec5dd3eb98ed2672871667d1ff010 . html <nl> ppp b / docs / dir_df9ec5dd3eb98ed2672871667d1ff010 . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / dir_ef94cdb01f4e9712d25c43b7c1d91b58 . html <nl> ppp b / docs / dir_ef94cdb01f4e9712d25c43b7c1d91b58 . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / eos_8cpp . html <nl> ppp b / docs / eos_8cpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / eos_8hpp . html <nl> ppp b / docs / eos_8hpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / eos_8hpp_source . html <nl> ppp b / docs / eos_8hpp_source . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / exchange_8cpp . html <nl> ppp b / docs / exchange_8cpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / exchange_8hpp . html <nl> ppp b / docs / exchange_8hpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / exchange_8hpp_source . html <nl> ppp b / docs / exchange_8hpp_source . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / exchange_8wast_8hpp . html <nl> ppp b / docs / exchange_8wast_8hpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / exchange_8wast_8hpp_source . html <nl> ppp b / docs / exchange_8wast_8hpp_source . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / files . html <nl> ppp b / docs / files . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions . html <nl> ppp b / docs / functions . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_0x7e . html <nl> ppp b / docs / functions_0x7e . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_b . html <nl> ppp b / docs / functions_b . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_c . html <nl> ppp b / docs / functions_c . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_d . html <nl> ppp b / docs / functions_d . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_e . html <nl> ppp b / docs / functions_e . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_f . html <nl> ppp b / docs / functions_f . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_func . html <nl> ppp b / docs / functions_func . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_func_0x7e . html <nl> ppp b / docs / functions_func_0x7e . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_func_b . html <nl> ppp b / docs / functions_func_b . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_func_c . html <nl> ppp b / docs / functions_func_c . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_func_f . html <nl> ppp b / docs / functions_func_f . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_func_g . html <nl> ppp b / docs / functions_func_g . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_func_i . html <nl> ppp b / docs / functions_func_i . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_func_k . html <nl> ppp b / docs / functions_func_k . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_func_l . html <nl> ppp b / docs / functions_func_l . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_func_m . html <nl> ppp b / docs / functions_func_m . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_func_n . html <nl> ppp b / docs / functions_func_n . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_func_o . html <nl> ppp b / docs / functions_func_o . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_func_p . html <nl> ppp b / docs / functions_func_p . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_func_r . html <nl> ppp b / docs / functions_func_r . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_func_s . html <nl> ppp b / docs / functions_func_s . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_func_t . html <nl> ppp b / docs / functions_func_t . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_func_u . html <nl> ppp b / docs / functions_func_u . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_g . html <nl> ppp b / docs / functions_g . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_h . html <nl> ppp b / docs / functions_h . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_i . html <nl> ppp b / docs / functions_i . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_k . html <nl> ppp b / docs / functions_k . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_l . html <nl> ppp b / docs / functions_l . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_m . html <nl> ppp b / docs / functions_m . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_n . html <nl> ppp b / docs / functions_n . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_o . html <nl> ppp b / docs / functions_o . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_p . html <nl> ppp b / docs / functions_p . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_q . html <nl> ppp b / docs / functions_q . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_r . html <nl> ppp b / docs / functions_r . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_rela . html <nl> ppp b / docs / functions_rela . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_s . html <nl> ppp b / docs / functions_s . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_t . html <nl> ppp b / docs / functions_t . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_type . html <nl> ppp b / docs / functions_type . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_u . html <nl> ppp b / docs / functions_u . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_v . html <nl> ppp b / docs / functions_v . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_vars . html <nl> ppp b / docs / functions_vars . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / functions_w . html <nl> ppp b / docs / functions_w . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / globals . html <nl> ppp b / docs / globals . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / globals_b . html <nl> ppp b / docs / globals_b . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / globals_c . html <nl> ppp b / docs / globals_c . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / globals_d . html <nl> ppp b / docs / globals_d . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / globals_defs . html <nl> ppp b / docs / globals_defs . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / globals_e . html <nl> ppp b / docs / globals_e . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / globals_f . html <nl> ppp b / docs / globals_f . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / globals_func . html <nl> ppp b / docs / globals_func . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / globals_g . html <nl> ppp b / docs / globals_g . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / globals_i . html <nl> ppp b / docs / globals_i . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / globals_l . html <nl> ppp b / docs / globals_l . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / globals_m . html <nl> ppp b / docs / globals_m . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / globals_n . html <nl> ppp b / docs / globals_n . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / globals_p . html <nl> ppp b / docs / globals_p . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / globals_r . html <nl> ppp b / docs / globals_r . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / globals_s . html <nl> ppp b / docs / globals_s . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / globals_t . html <nl> ppp b / docs / globals_t . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / globals_type . html <nl> ppp b / docs / globals_type . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / globals_u . html <nl> ppp b / docs / globals_u . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / globals_vars . html <nl> ppp b / docs / globals_vars . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / globals_w . html <nl> ppp b / docs / globals_w . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / group___singleindextable . html <nl> ppp b / docs / group___singleindextable . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> <nl> < div class = " summary " > <nl> < a href = " # nested - classes " > Classes < / a > < / div > <nl> < div class = " headertitle " > <nl> - < div class = " title " > Single Index table < div class = " ingroups " > < a class = " el " href = " group__contractdev . html " > How To Write Contracts < / a > & raquo ; < a class = " el " href = " group__database . html " > Database API < / a > & raquo ; < a class = " el " href = " group__database_cpp . html " > Database C + + API < / a > < / div > < / div > < / div > <nl> + < div class = " title " > Single Index table < div class = " ingroups " > < a class = " el " href = " group__database . html " > Database API < / a > & raquo ; < a class = " el " href = " group__database_cpp . html " > Database C + + API < / a > < / div > < / div > < / div > <nl> < / div > < ! - - header - - > <nl> < div class = " contents " > <nl> <nl> mmm a / docs / group__chaincapi . html <nl> ppp b / docs / group__chaincapi . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> <nl> <nl> < div class = " header " > <nl> < div class = " headertitle " > <nl> - < div class = " title " > Chain API < div class = " ingroups " > < a class = " el " href = " group__contractdev . html " > How To Write Contracts < / a > < / div > < / div > < / div > <nl> + < div class = " title " > Chain API < / div > < / div > <nl> < / div > < ! - - header - - > <nl> < div class = " contents " > <nl> <nl> mmm a / docs / group__console_cppapi . html <nl> ppp b / docs / group__console_cppapi . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> <nl> < a href = " # nested - classes " > Classes < / a > & # 124 ; <nl> < a href = " # func - members " > Functions < / a > < / div > <nl> < div class = " headertitle " > <nl> - < div class = " title " > Console C + + API < div class = " ingroups " > < a class = " el " href = " group__contractdev . html " > How To Write Contracts < / a > & raquo ; < a class = " el " href = " group__consoleapi . html " > Console API < / a > < / div > < / div > < / div > <nl> + < div class = " title " > Console C + + API < div class = " ingroups " > < a class = " el " href = " group__consoleapi . html " > Console API < / a > < / div > < / div > < / div > <nl> < / div > < ! - - header - - > <nl> < div class = " contents " > <nl> <nl> mmm a / docs / group__consoleapi . html <nl> ppp b / docs / group__consoleapi . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> <nl> < div class = " summary " > <nl> < a href = " # groups " > Modules < / a > < / div > <nl> < div class = " headertitle " > <nl> - < div class = " title " > Console API < div class = " ingroups " > < a class = " el " href = " group__contractdev . html " > How To Write Contracts < / a > < / div > < / div > < / div > <nl> + < div class = " title " > Console API < / div > < / div > <nl> < / div > < ! - - header - - > <nl> < div class = " contents " > <nl> <nl> mmm a / docs / group__consolecapi . html <nl> ppp b / docs / group__consolecapi . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> <nl> < div class = " summary " > <nl> < a href = " # func - members " > Functions < / a > < / div > <nl> < div class = " headertitle " > <nl> - < div class = " title " > Console C API < div class = " ingroups " > < a class = " el " href = " group__contractdev . html " > How To Write Contracts < / a > & raquo ; < a class = " el " href = " group__consoleapi . html " > Console API < / a > < / div > < / div > < / div > <nl> + < div class = " title " > Console C API < div class = " ingroups " > < a class = " el " href = " group__consoleapi . html " > Console API < / a > < / div > < / div > < / div > <nl> < / div > < ! - - header - - > <nl> < div class = " contents " > <nl> < table class = " memberdecls " > <nl> mmm a / docs / group__currencyapi . html <nl> ppp b / docs / group__currencyapi . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / group__database . html <nl> ppp b / docs / group__database . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> <nl> < div class = " summary " > <nl> < a href = " # groups " > Modules < / a > < / div > <nl> < div class = " headertitle " > <nl> - < div class = " title " > Database API < div class = " ingroups " > < a class = " el " href = " group__contractdev . html " > How To Write Contracts < / a > < / div > < / div > < / div > <nl> + < div class = " title " > Database API < / div > < / div > <nl> < / div > < ! - - header - - > <nl> < div class = " contents " > <nl> <nl> - < p > APIs that store and retreive data on the blockchainEOS . IO organizes data according to the following broad structure : <nl> + < p > APIs that store and retrieve data on the blockchain . <nl> < a href = " # details " > More . . . < / a > < / p > <nl> < table class = " memberdecls " > <nl> < tr class = " heading " > < td colspan = " 2 " > < h2 class = " groupheader " > < a name = " groups " > < / a > <nl> <nl> < tr class = " separator : " > < td class = " memSeparator " colspan = " 2 " > & # 160 ; < / td > < / tr > <nl> < / table > <nl> < a name = " details " id = " details " > < / a > < h2 class = " groupheader " > Detailed Description < / h2 > <nl> + < p > EOS . IO organizes data according to the following broad structure : < / p > <nl> < ul > <nl> < li > < b > scope < / b > - an account where the data is stored < ul > <nl> < li > < b > code < / b > - the account name which has write permission < ul > <nl> mmm a / docs / group__database_c . html <nl> ppp b / docs / group__database_c . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> <nl> < div class = " summary " > <nl> < a href = " # groups " > Modules < / a > < / div > <nl> < div class = " headertitle " > <nl> - < div class = " title " > Database C API < div class = " ingroups " > < a class = " el " href = " group__contractdev . html " > How To Write Contracts < / a > & raquo ; < a class = " el " href = " group__database . html " > Database API < / a > < / div > < / div > < / div > <nl> + < div class = " title " > Database C API < div class = " ingroups " > < a class = " el " href = " group__database . html " > Database API < / a > < / div > < / div > < / div > <nl> < / div > < ! - - header - - > <nl> < div class = " contents " > <nl> <nl> mmm a / docs / group__database_cpp . html <nl> ppp b / docs / group__database_cpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> <nl> < a href = " # groups " > Modules < / a > & # 124 ; <nl> < a href = " # nested - classes " > Classes < / a > < / div > <nl> < div class = " headertitle " > <nl> - < div class = " title " > Database C + + API < div class = " ingroups " > < a class = " el " href = " group__contractdev . html " > How To Write Contracts < / a > & raquo ; < a class = " el " href = " group__database . html " > Database API < / a > < / div > < / div > < / div > <nl> + < div class = " title " > Database C + + API < div class = " ingroups " > < a class = " el " href = " group__database . html " > Database API < / a > < / div > < / div > < / div > <nl> < / div > < ! - - header - - > <nl> < div class = " contents " > <nl> <nl> mmm a / docs / group__dbi128i128 . html <nl> ppp b / docs / group__dbi128i128 . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> <nl> < div class = " summary " > <nl> < a href = " # func - members " > Functions < / a > < / div > <nl> < div class = " headertitle " > <nl> - < div class = " title " > Dual 128 bit Index table < div class = " ingroups " > < a class = " el " href = " group__contractdev . html " > How To Write Contracts < / a > & raquo ; < a class = " el " href = " group__database . html " > Database API < / a > & raquo ; < a class = " el " href = " group__database_c . html " > Database C API < / a > < / div > < / div > < / div > <nl> + < div class = " title " > Dual 128 bit Index table < div class = " ingroups " > < a class = " el " href = " group__database . html " > Database API < / a > & raquo ; < a class = " el " href = " group__database_c . html " > Database C API < / a > < / div > < / div > < / div > <nl> < / div > < ! - - header - - > <nl> < div class = " contents " > <nl> <nl> mmm a / docs / group__dbi64 . html <nl> ppp b / docs / group__dbi64 . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> <nl> < div class = " summary " > <nl> < a href = " # func - members " > Functions < / a > < / div > <nl> < div class = " headertitle " > <nl> - < div class = " title " > Single 64 bit Index table < div class = " ingroups " > < a class = " el " href = " group__contractdev . html " > How To Write Contracts < / a > & raquo ; < a class = " el " href = " group__database . html " > Database API < / a > & raquo ; < a class = " el " href = " group__database_c . html " > Database C API < / a > < / div > < / div > < / div > <nl> + < div class = " title " > Single 64 bit Index table < div class = " ingroups " > < a class = " el " href = " group__database . html " > Database API < / a > & raquo ; < a class = " el " href = " group__database_c . html " > Database C API < / a > < / div > < / div > < / div > <nl> < / div > < ! - - header - - > <nl> < div class = " contents " > <nl> <nl> mmm a / docs / group__dbi64i64i64 . html <nl> ppp b / docs / group__dbi64i64i64 . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> <nl> < div class = " summary " > <nl> < a href = " # func - members " > Functions < / a > < / div > <nl> < div class = " headertitle " > <nl> - < div class = " title " > Triple 64 bit Index table < div class = " ingroups " > < a class = " el " href = " group__contractdev . html " > How To Write Contracts < / a > & raquo ; < a class = " el " href = " group__database . html " > Database API < / a > & raquo ; < a class = " el " href = " group__database_c . html " > Database C API < / a > < / div > < / div > < / div > <nl> + < div class = " title " > Triple 64 bit Index table < div class = " ingroups " > < a class = " el " href = " group__database . html " > Database API < / a > & raquo ; < a class = " el " href = " group__database_c . html " > Database C API < / a > < / div > < / div > < / div > <nl> < / div > < ! - - header - - > <nl> < div class = " contents " > <nl> <nl> mmm a / docs / group__dbstr . html <nl> ppp b / docs / group__dbstr . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> <nl> < div class = " summary " > <nl> < a href = " # func - members " > Functions < / a > < / div > <nl> < div class = " headertitle " > <nl> - < div class = " title " > Single String Index table < div class = " ingroups " > < a class = " el " href = " group__contractdev . html " > How To Write Contracts < / a > & raquo ; < a class = " el " href = " group__database . html " > Database API < / a > & raquo ; < a class = " el " href = " group__database_c . html " > Database C API < / a > < / div > < / div > < / div > <nl> + < div class = " title " > Single String Index table < div class = " ingroups " > < a class = " el " href = " group__database . html " > Database API < / a > & raquo ; < a class = " el " href = " group__database_c . html " > Database C API < / a > < / div > < / div > < / div > <nl> < / div > < ! - - header - - > <nl> < div class = " contents " > <nl> <nl> mmm a / docs / group__dual_index_table . html <nl> ppp b / docs / group__dual_index_table . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> <nl> < div class = " summary " > <nl> < a href = " # nested - classes " > Classes < / a > < / div > <nl> < div class = " headertitle " > <nl> - < div class = " title " > Dual Index table < div class = " ingroups " > < a class = " el " href = " group__contractdev . html " > How To Write Contracts < / a > & raquo ; < a class = " el " href = " group__database . html " > Database API < / a > & raquo ; < a class = " el " href = " group__database_cpp . html " > Database C + + API < / a > < / div > < / div > < / div > <nl> + < div class = " title " > Dual Index table < div class = " ingroups " > < a class = " el " href = " group__database . html " > Database API < / a > & raquo ; < a class = " el " href = " group__database_cpp . html " > Database C + + API < / a > < / div > < / div > < / div > <nl> < / div > < ! - - header - - > <nl> < div class = " contents " > <nl> <nl> mmm a / docs / group__eoscontract . html <nl> ppp b / docs / group__eoscontract . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / group__eosiorpc . html <nl> ppp b / docs / group__eosiorpc . html <nl> <nl> < meta http - equiv = " X - UA - Compatible " content = " IE = 9 " / > <nl> < meta name = " generator " content = " Doxygen 1 . 8 . 13 " / > <nl> < meta name = " viewport " content = " width = device - width , initial - scale = 1 " / > <nl> - < title > EOS . IO : eosd RPC Interface < / title > <nl> + < title > EOS . IO : RPC Interface < / title > <nl> < link href = " tabs . css " rel = " stylesheet " type = " text / css " / > <nl> < script type = " text / javascript " src = " jquery . js " > < / script > <nl> < script type = " text / javascript " src = " dynsections . js " > < / script > <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> <nl> <nl> < div class = " header " > <nl> < div class = " headertitle " > <nl> - < div class = " title " > eosd RPC Interface < / div > < / div > <nl> + < div class = " title " > RPC Interface < / div > < / div > <nl> < / div > < ! - - header - - > <nl> < div class = " contents " > <nl> <nl> < h1 > < a class = " anchor " id = " tableofcontent " > < / a > <nl> < li > < a href = " # v1chaingetrequiredkeys " > get_required_keys < / a > < / li > <nl> < / ul > <nl> < / li > <nl> + < li > < a href = " # walletrpc " > Wallet API < / a > < ul > <nl> + < li > < a href = " # v1walletcreate " > wallet_create < / a > < / li > <nl> + < li > < a href = " # v1walletopen " > wallet_open < / a > < / li > <nl> + < li > < a href = " # v1walletlock " > wallet_lock < / a > < / li > <nl> + < li > < a href = " # v1walletlockall " > wallet_lock_all < / a > < / li > <nl> + < li > < a href = " # v1walletimportkey " > wallet_import_key < / a > < / li > <nl> + < li > < a href = " # v1walletlist " > wallet_list < / a > < / li > <nl> + < li > < a href = " # v1walletlistkeys " > wallet_list_keys < / a > < / li > <nl> + < li > < a href = " # v1walletgetpublickeys " > wallet_get_public_keys < / a > < / li > <nl> + < li > < a href = " # v1walletsettimeout " > wallet_set_timeout < / a > < / li > <nl> + < li > < a href = " # v1walletsigntrx " > wallet_sign_trx < / a > < / li > <nl> + < / ul > <nl> + < / li > <nl> < / ul > <nl> < h1 > < a class = " anchor " id = " configuration " > < / a > <nl> Configuration < / h1 > <nl> < p > < code > eosd < / code > uses a REST RPC interface where plugins can register their own endpoints with the API server . This page will explain how to use some of the APIs to get information about the blockchain and send transactions . < / p > <nl> - < p > Before you can query < code > eosd < / code > you must first enable an API plugin . To do this add the following line to your < code > config . ini < / code > < / p > <nl> - < div class = " fragment " > < div class = " line " > plugin = eosio : : chain_api_plugin < / div > < / div > < ! - - fragment - - > < p > By default an HTTP server will start on < code > 127 . 0 . 0 . 1 : 8888 < / code > ; however , you can also change this with the following configuration line in your < code > config . ini < / code > : < / p > <nl> - < div class = " fragment " > < div class = " line " > http - server - endpoint = 127 . 0 . 0 . 1 : 8888 < / div > < / div > < ! - - fragment - - > < hr / > <nl> + < p > Before you can query < code > eosd < / code > you must first enable the necessary API plugin ( s ) . Depending on which API you want to enable , add the following line to your < code > eosd < / code > ' s < code > config . ini < / code > : < / p > < div class = " fragment " > < div class = " line " > plugin = eosio : : chain_api_plugin < span class = " comment " > / / Enable Chain API < / span > < / div > < div class = " line " > plugin = eosio : : wallet_api_plugin < span class = " comment " > / / Enable Wallet API < / span > < / div > < / div > < ! - - fragment - - > < p > Alternatively , for Wallet API , you can also have the wallet functionality separate from < code > eosd < / code > , by running < code > eos - walletd < / code > separately . < / p > <nl> + < p > For the following guide , we will assume that we have < code > eosd < / code > running on < code > 127 . 0 . 0 . 1 : 8888 < / code > ( Chain API Plugin enabled , Wallet API Plugin disabled ) and < code > eos - walletd < / code > running on < code > 127 . 0 . 0 . 1 : 8889 < / code > . < / p > < hr / > <nl> < h1 > < a class = " anchor " id = " chainrpc " > < / a > <nl> Chain API < / h1 > <nl> < h2 > < a class = " anchor " id = " v1chaingetinfo " > < / a > <nl> get_info < / h2 > <nl> - < p > The < code > get_info < / code > RPC command can be found at : < / p > <nl> - < div class = " fragment " > < div class = " line " > curl http : < span class = " comment " > / / 127 . 0 . 0 . 1 : 8888 / v1 / chain / get_info < / span > < / div > < / div > < ! - - fragment - - > < p > And it should return something like : < / p > < div class = " fragment " > < div class = " line " > { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; head_block_num & quot ; < / span > : 449 , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; last_irreversible_block_num & quot ; < / span > : 434 , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; head_block_id & quot ; < / span > : < span class = " stringliteral " > & quot ; 000001c1a0f072a5ca76831ac6c6e2988efcf162e953eb40046ec2ceca817a9f & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; head_block_time & quot ; < / span > : < span class = " stringliteral " > & quot ; 2017 - 07 - 18T21 : 02 : 24 & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; head_block_producer & quot ; < / span > : < span class = " stringliteral " > & quot ; initd & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; recent_slots & quot ; < / span > : < span class = " stringliteral " > & quot ; 0000000000000000000000000000000000000000000000000000000000001111 & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; participation_rate & quot ; < / span > : < span class = " stringliteral " > & quot ; 0 . 06250000000000000 & quot ; < / span > < / div > < div class = " line " > } < / div > < / div > < ! - - fragment - - > < h2 > < a class = " anchor " id = " v1chaingetblock " > < / a > <nl> + < p > Get latest information related to a node < / p > <nl> + < h3 > < a class = " anchor " id = " examplegetinfo " > < / a > <nl> + Example get_info Usage < / h3 > <nl> + < div class = " fragment " > < div class = " line " > curl http : < span class = " comment " > / / 127 . 0 . 0 . 1 : 8888 / v1 / chain / get_info < / span > < / div > < / div > < ! - - fragment - - > < h3 > < a class = " anchor " id = " examplegetinforesult " > < / a > <nl> + Example get_info Result < / h3 > <nl> + < div class = " fragment " > < div class = " line " > { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; server_version & quot ; < / span > : < span class = " stringliteral " > & quot ; b2eb1667 & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; head_block_num & quot ; < / span > : 259590 , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; last_irreversible_block_num & quot ; < / span > : 259573 , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; head_block_id & quot ; < / span > : < span class = " stringliteral " > & quot ; 0003f60677f3707f0704f16177bf5f007ebd45eb6efbb749fb1c468747f72046 & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; head_block_time & quot ; < / span > : < span class = " stringliteral " > & quot ; 2017 - 12 - 10T17 : 05 : 36 & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; head_block_producer & quot ; < / span > : < span class = " stringliteral " > & quot ; initp & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; recent_slots & quot ; < / span > : < span class = " stringliteral " > & quot ; 1111111111111111111111111111111111111111111111111111111111111111 & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; participation_rate & quot ; < / span > : < span class = " stringliteral " > & quot ; 1 . 00000000000000000 & quot ; < / span > < / div > < div class = " line " > } < / div > < / div > < ! - - fragment - - > < h2 > < a class = " anchor " id = " v1chaingetblock " > < / a > <nl> get_block < / h2 > <nl> < p > Get information related to a block . < / p > <nl> < h3 > < a class = " anchor " id = " examplegetblock " > < / a > <nl> Example get_block Usage < / h3 > <nl> - < div class = " fragment " > < div class = " line " > curl http : < span class = " comment " > / / localhost : 8888 / v1 / chain / get_block - X POST - d & # 39 ; { & quot ; block_num_or_id & quot ; : 5 } & # 39 ; < / span > < / div > < div class = " line " > curl http : < span class = " comment " > / / localhost : 8888 / v1 / chain / get_block - X POST - d & # 39 ; { & quot ; block_num_or_id & quot ; : 0000000445a9f27898383fd7de32835d5d6a978cc14ce40d9f327b5329de796b } & # 39 ; < / span > < / div > < / div > < ! - - fragment - - > < h3 > < a class = " anchor " id = " examplegetblockresult " > < / a > <nl> + < div class = " fragment " > < div class = " line " > $ curl http : < span class = " comment " > / / 127 . 0 . 0 . 1 : 8888 / v1 / chain / get_block - X POST - d & # 39 ; { & quot ; block_num_or_id & quot ; : 5 } & # 39 ; < / span > < / div > < div class = " line " > $ curl http : < span class = " comment " > / / 127 . 0 . 0 . 1 : 8888 / v1 / chain / get_block - X POST - d & # 39 ; { & quot ; block_num_or_id & quot ; : 0000000445a9f27898383fd7de32835d5d6a978cc14ce40d9f327b5329de796b } & # 39 ; < / span > < / div > < / div > < ! - - fragment - - > < h3 > < a class = " anchor " id = " examplegetblockresult " > < / a > <nl> Example get_block Result < / h3 > <nl> < div class = " fragment " > < div class = " line " > { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; previous & quot ; < / span > : < span class = " stringliteral " > & quot ; 0000000445a9f27898383fd7de32835d5d6a978cc14ce40d9f327b5329de796b & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; timestamp & quot ; < / span > : < span class = " stringliteral " > & quot ; 2017 - 07 - 18T20 : 16 : 36 & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; transaction_merkle_root & quot ; < / span > : < span class = " stringliteral " > & quot ; 0000000000000000000000000000000000000000000000000000000000000000 & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; producer & quot ; < / span > : < span class = " stringliteral " > & quot ; initf & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; producer_changes & quot ; < / span > : [ ] , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; producer_signature & quot ; < / span > : < span class = " stringliteral " > & quot ; 204cb94b3186c3b4a7f88be4e9db9f8af2ffdb7ef0f27a065c8177a5fcfacf876f684e59c39fb009903c0c59220b147bb07f1144df1c65d26c57b534a76dd29073 & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; cycles & quot ; < / span > : [ ] , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; id & quot ; < / span > : < span class = " stringliteral " > & quot ; 000000050c0175cbf218a70131ddc3c3fab8b6e954edef77e0bfe7c36b599b1d & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; block_num & quot ; < / span > : 5 , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; ref_block_prefix & quot ; < / span > : 27728114 < / div > < div class = " line " > } < / div > < / div > < ! - - fragment - - > < h2 > < a class = " anchor " id = " v1chaingetaccount " > < / a > <nl> get_account < / h2 > <nl> < p > Get information related to an account . < / p > <nl> < h3 > < a class = " anchor " id = " examplegetaccount " > < / a > <nl> Example get_account Usage < / h3 > <nl> - < div class = " fragment " > < div class = " line " > curl http : < span class = " comment " > / / localhost : 8888 / v1 / chain / get_account - X POST - d & # 39 ; { & quot ; name & quot ; : & quot ; inita & quot ; } & # 39 ; < / span > < / div > < / div > < ! - - fragment - - > < h3 > < a class = " anchor " id = " examplegetaccountresult " > < / a > <nl> + < div class = " fragment " > < div class = " line " > $ curl http : < span class = " comment " > / / 127 . 0 . 0 . 1 : 8888 / v1 / chain / get_account - X POST - d & # 39 ; { & quot ; name & quot ; : & quot ; inita & quot ; } & # 39 ; < / span > < / div > < / div > < ! - - fragment - - > < h3 > < a class = " anchor " id = " examplegetaccountresult " > < / a > <nl> Example get_account Result < / h3 > <nl> < div class = " fragment " > < div class = " line " > { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; name & quot ; < / span > : < span class = " stringliteral " > & quot ; inita & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; eos_balance & quot ; < / span > : < span class = " stringliteral " > & quot ; 999998 . 9574 EOS & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; staked_balance & quot ; < / span > : < span class = " stringliteral " > & quot ; 0 . 0000 EOS & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; unstaking_balance & quot ; < / span > : < span class = " stringliteral " > & quot ; 0 . 0000 EOS & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; last_unstaking_time & quot ; < / span > : < span class = " stringliteral " > & quot ; 2106 - 02 - 07T06 : 28 : 15 & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; permissions & quot ; < / span > : [ < / div > < div class = " line " > { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; name & quot ; < / span > : < span class = " stringliteral " > & quot ; active & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; parent & quot ; < / span > : < span class = " stringliteral " > & quot ; owner & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; required_auth & quot ; < / span > : { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; threshold & quot ; < / span > : 1 , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; keys & quot ; < / span > : [ < / div > < div class = " line " > { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; key & quot ; < / span > : < span class = " stringliteral " > & quot ; EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; weight & quot ; < / span > : 1 < / div > < div class = " line " > } < / div > < div class = " line " > ] , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; accounts & quot ; < / span > : [ ] < / div > < div class = " line " > } < / div > < div class = " line " > } , < / div > < div class = " line " > { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; name & quot ; < / span > : < span class = " stringliteral " > & quot ; owner & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; parent & quot ; < / span > : < span class = " stringliteral " > & quot ; owner & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; required_auth & quot ; < / span > : { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; threshold & quot ; < / span > : 1 , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; keys & quot ; < / span > : [ < / div > < div class = " line " > { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; key & quot ; < / span > : < span class = " stringliteral " > & quot ; EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; weight & quot ; < / span > : 1 < / div > < div class = " line " > } < / div > < div class = " line " > ] , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; accounts & quot ; < / span > : [ ] < / div > < div class = " line " > } < / div > < div class = " line " > } < / div > < div class = " line " > ] < / div > < div class = " line " > } < / div > < / div > < ! - - fragment - - > < h2 > < a class = " anchor " id = " v1chaingetcode " > < / a > <nl> get_code < / h2 > <nl> < p > Fetch smart contract code . < / p > <nl> < h3 > < a class = " anchor " id = " examplegetcode " > < / a > <nl> Example get_code Usage < / h3 > <nl> - < div class = " fragment " > < div class = " line " > curl http : < span class = " comment " > / / localhost : 8888 / v1 / chain / get_code - X POST - d & # 39 ; { & quot ; name & quot ; : & quot ; currency & quot ; } & # 39 ; < / span > < / div > < / div > < ! - - fragment - - > < h3 > < a class = " anchor " id = " examplegetcoderesult " > < / a > <nl> + < div class = " fragment " > < div class = " line " > $ curl http : < span class = " comment " > / / 127 . 0 . 0 . 1 : 8888 / v1 / chain / get_code - X POST - d & # 39 ; { & quot ; account_name & quot ; : & quot ; currency & quot ; } & # 39 ; < / span > < / div > < / div > < ! - - fragment - - > < h3 > < a class = " anchor " id = " examplegetcoderesult " > < / a > <nl> Example get_code Result < / h3 > <nl> - < div class = " fragment " > < div class = " line " > { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; name & quot ; < / span > : < span class = " stringliteral " > & quot ; currency & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; code_hash & quot ; < / span > : < span class = " stringliteral " > & quot ; a1c8c84b4700c09c8edb83522237439e33cf011a4d7ace51075998bd002e04c9 & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; wast & quot ; < / span > : < span class = " stringliteral " > & quot ; ( module \ n ( type $ 0 ( func ( param i64 i64 i32 ) ( result i32 ) ) ) \ n . . . & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; abi & quot ; < / span > : { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; types & quot ; < / span > : [ < / div > < div class = " line " > { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; new_type_name & quot ; < / span > : < span class = " stringliteral " > & quot ; account_name & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; type & quot ; < / span > : < span class = " stringliteral " > & quot ; name & quot ; < / span > < / div > < div class = " line " > } < / div > < div class = " line " > ] , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; structs & quot ; < / span > : [ < / div > < div class = " line " > { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; name & quot ; < / span > : < span class = " stringliteral " > & quot ; transfer & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; base & quot ; < / span > : < span class = " stringliteral " > & quot ; & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; fields & quot ; < / span > : { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; from & quot ; < / span > : < span class = " stringliteral " > & quot ; account_name & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; to & quot ; < / span > : < span class = " stringliteral " > & quot ; account_name & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; amount & quot ; < / span > : < span class = " stringliteral " > & quot ; uint64 & quot ; < / span > < / div > < div class = " line " > } < / div > < div class = " line " > } , < / div > < div class = " line " > { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; name & quot ; < / span > : < span class = " stringliteral " > & quot ; account & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; base & quot ; < / span > : < span class = " stringliteral " > & quot ; & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; fields & quot ; < / span > : { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; account & quot ; < / span > : < span class = " stringliteral " > & quot ; name & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; balance & quot ; < / span > : < span class = " stringliteral " > & quot ; uint64 & quot ; < / span > < / div > < div class = " line " > } < / div > < div class = " line " > } < / div > < div class = " line " > ] , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; actions & quot ; < / span > : [ < / div > < div class = " line " > { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; action_name & quot ; < / span > : < span class = " stringliteral " > & quot ; transfer & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; type & quot ; < / span > : < span class = " stringliteral " > & quot ; transfer & quot ; < / span > < / div > < div class = " line " > } < / div > < div class = " line " > ] , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; tables & quot ; < / span > : [ < / div > < div class = " line " > { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; table_name & quot ; < / span > : < span class = " stringliteral " > & quot ; account & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; index_type & quot ; < / span > : < span class = " stringliteral " > & quot ; i64 & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; key_names & quot ; < / span > : [ < / div > < div class = " line " > < span class = " stringliteral " > & quot ; account & quot ; < / span > < / div > < div class = " line " > ] , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; keytype & quot ; < / span > : [ ] , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; type & quot ; < / span > : < span class = " stringliteral " > & quot ; account & quot ; < / span > < / div > < div class = " line " > } < / div > < div class = " line " > ] < / div > < div class = " line " > } < / div > < div class = " line " > } < / div > < / div > < ! - - fragment - - > < h2 > < a class = " anchor " id = " v1chaingettablerows " > < / a > <nl> + < div class = " fragment " > < div class = " line " > { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; name & quot ; < / span > : < span class = " stringliteral " > & quot ; currency & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; code_hash & quot ; < / span > : < span class = " stringliteral " > & quot ; a1c8c84b4700c09c8edb83522237439e33cf011a4d7ace51075998bd002e04c9 & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; wast & quot ; < / span > : < span class = " stringliteral " > & quot ; ( module \ n ( type $ 0 ( func ( param i64 i64 i32 ) ( result i32 ) ) ) \ n . . . truncated & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; abi & quot ; < / span > : { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; types & quot ; < / span > : [ < / div > < div class = " line " > { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; new_type_name & quot ; < / span > : < span class = " stringliteral " > & quot ; account_name & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; type & quot ; < / span > : < span class = " stringliteral " > & quot ; name & quot ; < / span > < / div > < div class = " line " > } < / div > < div class = " line " > ] , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; structs & quot ; < / span > : [ < / div > < div class = " line " > { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; name & quot ; < / span > : < span class = " stringliteral " > & quot ; transfer & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; base & quot ; < / span > : < span class = " stringliteral " > & quot ; & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; fields & quot ; < / span > : { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; from & quot ; < / span > : < span class = " stringliteral " > & quot ; account_name & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; to & quot ; < / span > : < span class = " stringliteral " > & quot ; account_name & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; quantity & quot ; < / span > : < span class = " stringliteral " > & quot ; uint64 & quot ; < / span > < / div > < div class = " line " > } < / div > < div class = " line " > } , < / div > < div class = " line " > { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; name & quot ; < / span > : < span class = " stringliteral " > & quot ; account & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; base & quot ; < / span > : < span class = " stringliteral " > & quot ; & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; fields & quot ; < / span > : { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; key & quot ; < / span > : < span class = " stringliteral " > & quot ; name & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; balance & quot ; < / span > : < span class = " stringliteral " > & quot ; uint64 & quot ; < / span > < / div > < div class = " line " > } < / div > < div class = " line " > } < / div > < div class = " line " > ] , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; actions & quot ; < / span > : [ < / div > < div class = " line " > { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; action_name & quot ; < / span > : < span class = " stringliteral " > & quot ; transfer & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; type & quot ; < / span > : < span class = " stringliteral " > & quot ; transfer & quot ; < / span > < / div > < div class = " line " > } < / div > < div class = " line " > ] , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; tables & quot ; < / span > : [ < / div > < div class = " line " > { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; table_name & quot ; < / span > : < span class = " stringliteral " > & quot ; account & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; index_type & quot ; < / span > : < span class = " stringliteral " > & quot ; i64 & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; key_names & quot ; < / span > : [ < / div > < div class = " line " > < span class = " stringliteral " > & quot ; key & quot ; < / span > < / div > < div class = " line " > ] , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; key_types & quot ; < / span > : [ < / div > < div class = " line " > < span class = " stringliteral " > & quot ; name & quot ; < / span > < / div > < div class = " line " > ] , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; type & quot ; < / span > : < span class = " stringliteral " > & quot ; account & quot ; < / span > < / div > < div class = " line " > } < / div > < div class = " line " > ] < / div > < div class = " line " > } < / div > < div class = " line " > } < / div > < / div > < ! - - fragment - - > < h2 > < a class = " anchor " id = " v1chaingettablerows " > < / a > <nl> get_table_rows < / h2 > <nl> < p > Fetch smart contract data from an account . < / p > <nl> < h3 > < a class = " anchor " id = " examplegettablerows " > < / a > <nl> get_table_rows Usage < / h3 > <nl> - < div class = " fragment " > < div class = " line " > curl http : < span class = " comment " > / / localhost : 8888 / v1 / chain / get_table_rows - X POST - d & # 39 ; { & quot ; scope & quot ; : & quot ; inita & quot ; , & quot ; code & quot ; : & quot ; currency & quot ; , & quot ; table & quot ; : & quot ; account & quot ; , & quot ; json & quot ; : true } & # 39 ; < / span > < / div > < div class = " line " > curl http : < span class = " comment " > / / localhost : 8888 / v1 / chain / get_table_rows - X POST - d & # 39 ; { & quot ; scope & quot ; : & quot ; inita & quot ; , & quot ; code & quot ; : & quot ; currency & quot ; , & quot ; table & quot ; : & quot ; account & quot ; , & quot ; json & quot ; : true , & quot ; lower_bound & quot ; : 0 , & quot ; upper_bound & quot ; : - 1 , & quot ; limit & quot ; : 10 } & # 39 ; < / span > < / div > < / div > < ! - - fragment - - > < h3 > < a class = " anchor " id = " examplegettablerowsresult " > < / a > <nl> + < div class = " fragment " > < div class = " line " > $ curl http : < span class = " comment " > / / 127 . 0 . 0 . 1 : 8888 / v1 / chain / get_table_rows - X POST - d & # 39 ; { & quot ; scope & quot ; : & quot ; inita & quot ; , & quot ; code & quot ; : & quot ; currency & quot ; , & quot ; table & quot ; : & quot ; account & quot ; , & quot ; json & quot ; : true } & # 39 ; < / span > < / div > < div class = " line " > $ curl http : < span class = " comment " > / / 127 . 0 . 0 . 1 : 8888 / v1 / chain / get_table_rows - X POST - d & # 39 ; { & quot ; scope & quot ; : & quot ; inita & quot ; , & quot ; code & quot ; : & quot ; currency & quot ; , & quot ; table & quot ; : & quot ; account & quot ; , & quot ; json & quot ; : true , & quot ; lower_bound & quot ; : 0 , & quot ; upper_bound & quot ; : - 1 , & quot ; limit & quot ; : 10 } & # 39 ; < / span > < / div > < / div > < ! - - fragment - - > < h3 > < a class = " anchor " id = " examplegettablerowsresult " > < / a > <nl> Example get_table_rows Result < / h3 > <nl> < div class = " fragment " > < div class = " line " > { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; rows & quot ; < / span > : [ < / div > < div class = " line " > { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; account & quot ; < / span > : < span class = " stringliteral " > & quot ; account & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; balance & quot ; < / span > : 1000 < / div > < div class = " line " > } < / div > < div class = " line " > ] , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; more & quot ; < / span > : < span class = " keyword " > false < / span > < / div > < div class = " line " > } < / div > < / div > < ! - - fragment - - > < h2 > < a class = " anchor " id = " v1chaingeabijsontobin " > < / a > <nl> abi_json_to_bin < / h2 > <nl> < p > Serialize json to binary hex . The resulting binary hex is usually used for the data field in < a href = " # v1chainpushtransaction " > push_transaction < / a > . < / p > <nl> < h3 > < a class = " anchor " id = " exampleabijsontobin " > < / a > <nl> Example abi_json_to_bin Usage < / h3 > <nl> - < div class = " fragment " > < div class = " line " > curl http : < span class = " comment " > / / localhost : 8888 / v1 / chain / abi_json_to_bin - X POST - d & # 39 ; { & quot ; code & quot ; : & quot ; currency & quot ; , & quot ; action & quot ; : & quot ; transfer & quot ; , & quot ; args & quot ; : { & quot ; from & quot ; : & quot ; initb & quot ; , & quot ; to & quot ; : & quot ; initc & quot ; , & quot ; amount & quot ; : 1000 } } & # 39 ; < / span > < / div > < / div > < ! - - fragment - - > < h3 > < a class = " anchor " id = " exampleabijsontobinresult " > < / a > <nl> + < div class = " fragment " > < div class = " line " > $ curl http : < span class = " comment " > / / 127 . 0 . 0 . 1 : 8888 / v1 / chain / abi_json_to_bin - X POST - d & # 39 ; { & quot ; code & quot ; : & quot ; currency & quot ; , & quot ; action & quot ; : & quot ; transfer & quot ; , & quot ; args & quot ; : { & quot ; from & quot ; : & quot ; initb & quot ; , & quot ; to & quot ; : & quot ; initc & quot ; , & quot ; quantity & quot ; : 1000 } } & # 39 ; < / span > < / div > < / div > < ! - - fragment - - > < h3 > < a class = " anchor " id = " exampleabijsontobinresult " > < / a > <nl> Example abi_json_to_bin Result < / h3 > <nl> - < div class = " fragment " > < div class = " line " > { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; binargs & quot ; < / span > : < span class = " stringliteral " > & quot ; 000000000041934b000000008041934be803000000000000 & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; required_scope & quot ; < / span > : [ ] , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; required_auth & quot ; < / span > : [ ] < / div > < div class = " line " > } < / div > < / div > < ! - - fragment - - > < h2 > < a class = " anchor " id = " v1chaingeabibintojson " > < / a > <nl> + < div class = " fragment " > < div class = " line " > { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; binargs & quot ; < / span > : < span class = " stringliteral " > & quot ; 000000008093dd74000000000094dd74e803000000000000 & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; required_scope & quot ; < / span > : [ ] , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; required_auth & quot ; < / span > : [ ] < / div > < div class = " line " > } < / div > < / div > < ! - - fragment - - > < h2 > < a class = " anchor " id = " v1chaingeabibintojson " > < / a > <nl> abi_bin_to_json < / h2 > <nl> < p > Serialize back binary hex to json . < / p > <nl> < h3 > < a class = " anchor " id = " exampleabibintojson " > < / a > <nl> Example abi_bin_to_json Usage < / h3 > <nl> - < div class = " fragment " > < div class = " line " > curl http : < span class = " comment " > / / localhost : 8888 / v1 / chain / abi_bin_to_json - X POST - d & # 39 ; { & quot ; code & quot ; : & quot ; currency & quot ; , & quot ; action & quot ; : & quot ; transfer & quot ; , & quot ; binargs & quot ; : & quot ; 000000000041934b000000008041934be803000000000000 & quot ; } & # 39 ; < / span > < / div > < / div > < ! - - fragment - - > < h3 > < a class = " anchor " id = " exampleabibintojsonresult " > < / a > <nl> + < div class = " fragment " > < div class = " line " > $ curl http : < span class = " comment " > / / 127 . 0 . 0 . 1 : 8888 / v1 / chain / abi_bin_to_json - X POST - d & # 39 ; { & quot ; code & quot ; : & quot ; currency & quot ; , & quot ; action & quot ; : & quot ; transfer & quot ; , & quot ; binargs & quot ; : & quot ; 000000008093dd74000000000094dd74e803000000000000 & quot ; } & # 39 ; < / span > < / div > < / div > < ! - - fragment - - > < h3 > < a class = " anchor " id = " exampleabibintojsonresult " > < / a > <nl> Example abi_bin_to_json Result < / h3 > <nl> - < div class = " fragment " > < div class = " line " > { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; args & quot ; < / span > : { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; from & quot ; < / span > : < span class = " stringliteral " > & quot ; initb & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; to & quot ; < / span > : < span class = " stringliteral " > & quot ; initc & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; amount & quot ; < / span > : 1000 < / div > < div class = " line " > } , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; required_scope & quot ; < / span > : [ ] , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; required_auth & quot ; < / span > : [ ] < / div > < div class = " line " > } < / div > < / div > < ! - - fragment - - > < h2 > < a class = " anchor " id = " v1chainpushtransaction " > < / a > <nl> + < div class = " fragment " > < div class = " line " > { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; args & quot ; < / span > : { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; from & quot ; < / span > : < span class = " stringliteral " > & quot ; initb & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; to & quot ; < / span > : < span class = " stringliteral " > & quot ; initc & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; quantity & quot ; < / span > : 1000 < / div > < div class = " line " > } , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; required_scope & quot ; < / span > : [ ] , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; required_auth & quot ; < / span > : [ ] < / div > < div class = " line " > } < / div > < / div > < ! - - fragment - - > < h2 > < a class = " anchor " id = " v1chainpushtransaction " > < / a > <nl> push_transaction < / h2 > <nl> < p > This method expects a transaction in JSON format and will attempt to apply it to the blockchain , < / p > <nl> < p > < b > Success Response < / b > < / p > <nl> < h3 > < a class = " anchor " id = " exampleabibintojson " > < / a > <nl> < p > If an error occurs it will return either HTTP 400 ( Invalid arguments ) or 500 ( Internal Server Error ) < / p > <nl> < div class = " fragment " > < div class = " line " > HTTP / 1 . 1 500 Internal Server Error < / div > < div class = " line " > Content - Length : 1466 < / div > < div class = " line " > < / div > < div class = " line " > . . . error message . . . < / div > < / div > < ! - - fragment - - > < h3 > < a class = " anchor " id = " examplepushtrx " > < / a > <nl> Example push_transaction Usage < / h3 > <nl> - < p > This example assumes a transfer operation . The < code > ref_block_num < / code > and < code > ref_block_prefix < / code > are provided as a result of < code > / v1 / chain / get_block < / code > . < / p > < div class = " fragment " > < div class = " line " > curl http : < span class = " comment " > / / localhost : 8888 / v1 / chain / push_transaction - X POST - d & # 39 ; { & quot ; ref_block_num & quot ; : & quot ; 100 & quot ; , & quot ; ref_block_prefix & quot ; : & quot ; 137469861 & quot ; , & quot ; expiration & quot ; : & quot ; 2017 - 09 - 25T06 : 28 : 49 & quot ; , & quot ; scope & quot ; : [ & quot ; initb & quot ; , & quot ; initc & quot ; ] , & quot ; messages & quot ; : [ { & quot ; code & quot ; : & quot ; currency & quot ; , & quot ; type & quot ; : & quot ; transfer & quot ; , & quot ; recipients & quot ; : [ & quot ; initb & quot ; , & quot ; initc & quot ; ] , & quot ; authorization & quot ; : [ { & quot ; account & quot ; : & quot ; initb & quot ; , & quot ; permission & quot ; : & quot ; active & quot ; } ] , & quot ; data & quot ; : & quot ; 000000000041934b000000008041934be803000000000000 & quot ; } ] , & quot ; signatures & quot ; : [ ] , & quot ; authorizations & quot ; : [ ] } & # 39 ; < / span > < / div > < / div > < ! - - fragment - - > < h2 > < a class = " anchor " id = " v1chainpushtransactions " > < / a > <nl> + < p > This example assumes a transfer operation . The < code > ref_block_num < / code > and < code > ref_block_prefix < / code > here are provided as a result of < code > / v1 / chain / get_block < / code > of the last_irreversible_block . You also need to use / v1 / wallet / sign_transaction to get the right signature . < / p > < div class = " fragment " > < div class = " line " > $ curl http : < span class = " comment " > / / 127 . 0 . 0 . 1 : 8888 / v1 / chain / push_transaction - X POST - d & # 39 ; { & quot ; ref_block_num & quot ; : 21453 , & quot ; ref_block_prefix & quot ; : 3165644999 , & quot ; expiration & quot ; : & quot ; 2017 - 12 - 08T10 : 28 : 49 & quot ; , & quot ; scope & quot ; : [ & quot ; initb & quot ; , & quot ; initc & quot ; ] , & quot ; read_scope & quot ; : [ ] , & quot ; messages & quot ; : [ { & quot ; code & quot ; : & quot ; currency & quot ; , & quot ; type & quot ; : & quot ; transfer & quot ; , & quot ; authorization & quot ; : [ { & quot ; account & quot ; : & quot ; initb & quot ; , & quot ; permission & quot ; : & quot ; active & quot ; } ] , & quot ; data & quot ; : & quot ; 000000008093dd74000000000094dd74e803000000000000 & quot ; } ] , & quot ; signatures & quot ; : [ & quot ; 1f393cc5ce6a6951fb53b11812345bcf14ffd978b07be386fd639eaf440bca7dca16b14833ec661ca0703d15e55a2a599a36d55ce78c4539433f6ce8bcee0158c3 & quot ; ] } & # 39 ; < / span > < / div > < / div > < ! - - fragment - - > < h2 > < a class = " anchor " id = " v1chainpushtransactions " > < / a > <nl> push_transactions < / h2 > <nl> < p > This method push multiple transactions at once . < / p > <nl> < h3 > < a class = " anchor " id = " examplepushtrxs " > < / a > <nl> Example push_transactions Usage < / h3 > <nl> - < div class = " fragment " > < div class = " line " > curl http : < span class = " comment " > / / localhost : 8888 / v1 / chain / push_transaction - X POST - d & # 39 ; [ { & quot ; ref_block_num & quot ; : & quot ; 101 & quot ; , & quot ; ref_block_prefix & quot ; : & quot ; 4159312339 & quot ; , & quot ; expiration & quot ; : & quot ; 2017 - 09 - 25T06 : 28 : 49 & quot ; , & quot ; scope & quot ; : [ & quot ; initb & quot ; , & quot ; initc & quot ; ] , & quot ; messages & quot ; : [ { & quot ; code & quot ; : & quot ; currency & quot ; , & quot ; type & quot ; : & quot ; transfer & quot ; , & quot ; recipients & quot ; : [ & quot ; initb & quot ; , & quot ; initc & quot ; ] , & quot ; authorization & quot ; : [ { & quot ; account & quot ; : & quot ; initb & quot ; , & quot ; permission & quot ; : & quot ; active & quot ; } ] , & quot ; data & quot ; : & quot ; 000000000041934b000000008041934be803000000000000 & quot ; } ] , & quot ; signatures & quot ; : [ ] , & quot ; authorizations & quot ; : [ ] } , { & quot ; ref_block_num & quot ; : & quot ; 101 & quot ; , & quot ; ref_block_prefix & quot ; : & quot ; 4159312339 & quot ; , & quot ; expiration & quot ; : & quot ; 2017 - 09 - 25T06 : 28 : 49 & quot ; , & quot ; scope & quot ; : [ & quot ; inita & quot ; , & quot ; initc & quot ; ] , & quot ; messages & quot ; : [ { & quot ; code & quot ; : & quot ; currency & quot ; , & quot ; type & quot ; : & quot ; transfer & quot ; , & quot ; recipients & quot ; : [ & quot ; inita & quot ; , & quot ; initc & quot ; ] , & quot ; authorization & quot ; : [ { & quot ; account & quot ; : & quot ; inita & quot ; , & quot ; permission & quot ; : & quot ; active & quot ; } ] , & quot ; data & quot ; : & quot ; 000000008040934b000000008041934be803000000000000 & quot ; } ] , & quot ; signatures & quot ; : [ ] , & quot ; authorizations & quot ; : [ ] } ] & # 39 ; < / span > < / div > < / div > < ! - - fragment - - > < h2 > < a class = " anchor " id = " v1chaingetrequiredkeys " > < / a > <nl> + < div class = " fragment " > < div class = " line " > $ curl http : < span class = " comment " > / / 127 . 0 . 0 . 1 : 8888 / v1 / chain / push_transaction - X POST - d & # 39 ; [ { & quot ; ref_block_num & quot ; : 21453 , & quot ; ref_block_prefix & quot ; : 3165644999 , & quot ; expiration & quot ; : & quot ; 2017 - 12 - 08T10 : 28 : 49 & quot ; , & quot ; scope & quot ; : [ & quot ; initb & quot ; , & quot ; initc & quot ; ] , & quot ; read_scope & quot ; : [ ] , & quot ; messages & quot ; : [ { & quot ; code & quot ; : & quot ; currency & quot ; , & quot ; type & quot ; : & quot ; transfer & quot ; , & quot ; authorization & quot ; : [ { & quot ; account & quot ; : & quot ; initb & quot ; , & quot ; permission & quot ; : & quot ; active & quot ; } ] , & quot ; data & quot ; : & quot ; 000000008093dd74000000000094dd74e803000000000000 & quot ; } ] , & quot ; signatures & quot ; : [ & quot ; 1f393cc5ce6a6951fb53b11812345bcf14ffd978b07be386fd639eaf440bca7dca16b14833ec661ca0703d15e55a2a599a36d55ce78c4539433f6ce8bcee0158c3 & quot ; ] } , . . . ] & # 39 ; < / span > < / div > < / div > < ! - - fragment - - > < h2 > < a class = " anchor " id = " v1chaingetrequiredkeys " > < / a > <nl> get_required_keys < / h2 > <nl> < p > Get required keys to sign a transaction from list of your keys . < / p > <nl> < h3 > < a class = " anchor " id = " examplegetrequiredkeys " > < / a > <nl> Example get_required_keys Usage < / h3 > <nl> - < div class = " fragment " > < div class = " line " > curl http : < span class = " comment " > / / localhost : 8888 / v1 / chain / get_required_keys - X POST - d & # 39 ; { & quot ; transaction & quot ; : { & quot ; ref_block_num & quot ; : & quot ; 100 & quot ; , & quot ; ref_block_prefix & quot ; : & quot ; 137469861 & quot ; , & quot ; expiration & quot ; : & quot ; 2017 - 09 - 25T06 : 28 : 49 & quot ; , & quot ; scope & quot ; : [ & quot ; initb & quot ; , & quot ; initc & quot ; ] , & quot ; messages & quot ; : [ { & quot ; code & quot ; : & quot ; currency & quot ; , & quot ; type & quot ; : & quot ; transfer & quot ; , & quot ; recipients & quot ; : [ & quot ; initb & quot ; , & quot ; initc & quot ; ] , & quot ; authorization & quot ; : [ { & quot ; account & quot ; : & quot ; initb & quot ; , & quot ; permission & quot ; : & quot ; active & quot ; } ] , & quot ; data & quot ; : & quot ; 000000000041934b000000008041934be803000000000000 & quot ; } ] , & quot ; signatures & quot ; : [ ] , & quot ; authorizations & quot ; : [ ] } , & quot ; available_keys & quot ; : [ & quot ; EOS4toFS3YXEQCkuuw1aqDLrtHim86Gz9u3hBdcBw5KNPZcursVHq & quot ; , & quot ; EOS7d9A3uLe6As66jzN8j44TXJUqJSK3bFjjEEqR4oTvNAB3iM9SA & quot ; , & quot ; EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV & quot ; ] } & # 39 ; < / span > < / div > < / div > < ! - - fragment - - > < h3 > < a class = " anchor " id = " examplegetrequiredkeysresult " > < / a > <nl> + < div class = " fragment " > < div class = " line " > $ curl http : < span class = " comment " > / / 127 . 0 . 0 . 1 : 8888 / v1 / chain / get_required_keys - X POST - d & # 39 ; { & quot ; transaction & quot ; : { & quot ; ref_block_num & quot ; : & quot ; 100 & quot ; , & quot ; ref_block_prefix & quot ; : & quot ; 137469861 & quot ; , & quot ; expiration & quot ; : & quot ; 2017 - 09 - 25T06 : 28 : 49 & quot ; , & quot ; scope & quot ; : [ & quot ; initb & quot ; , & quot ; initc & quot ; ] , & quot ; messages & quot ; : [ { & quot ; code & quot ; : & quot ; currency & quot ; , & quot ; type & quot ; : & quot ; transfer & quot ; , & quot ; recipients & quot ; : [ & quot ; initb & quot ; , & quot ; initc & quot ; ] , & quot ; authorization & quot ; : [ { & quot ; account & quot ; : & quot ; initb & quot ; , & quot ; permission & quot ; : & quot ; active & quot ; } ] , & quot ; data & quot ; : & quot ; 000000000041934b000000008041934be803000000000000 & quot ; } ] , & quot ; signatures & quot ; : [ ] , & quot ; authorizations & quot ; : [ ] } , & quot ; available_keys & quot ; : [ & quot ; EOS4toFS3YXEQCkuuw1aqDLrtHim86Gz9u3hBdcBw5KNPZcursVHq & quot ; , & quot ; EOS7d9A3uLe6As66jzN8j44TXJUqJSK3bFjjEEqR4oTvNAB3iM9SA & quot ; , & quot ; EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV & quot ; ] } & # 39 ; < / span > < / div > < / div > < ! - - fragment - - > < h3 > < a class = " anchor " id = " examplegetrequiredkeysresult " > < / a > <nl> Example get_required_keys Result < / h3 > <nl> - < div class = " fragment " > < div class = " line " > { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; required_keys & quot ; < / span > : [ < / div > < div class = " line " > < span class = " stringliteral " > & quot ; EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV & quot ; < / span > < / div > < div class = " line " > ] < / div > < div class = " line " > } < / div > < / div > < ! - - fragment - - > < / div > < ! - - contents - - > <nl> + < div class = " fragment " > < div class = " line " > { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; required_keys & quot ; < / span > : [ < / div > < div class = " line " > < span class = " stringliteral " > & quot ; EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV & quot ; < / span > < / div > < div class = " line " > ] < / div > < div class = " line " > } < / div > < / div > < ! - - fragment - - > < h1 > < a class = " anchor " id = " walletrpc " > < / a > <nl> + Wallet API < / h1 > <nl> + < h2 > < a class = " anchor " id = " v1walletcreate " > < / a > <nl> + wallet_create < / h2 > <nl> + < p > Create a new wallet with the given name < / p > <nl> + < h3 > < a class = " anchor " id = " examplewalletcreate " > < / a > <nl> + Example wallet_create Usage < / h3 > <nl> + < div class = " fragment " > < div class = " line " > $ curl http : < span class = " comment " > / / localhost : 8889 / v1 / wallet / create - X POST - d & # 39 ; & quot ; default & quot ; & # 39 ; < / span > < / div > < / div > < ! - - fragment - - > < h3 > < a class = " anchor " id = " examplewalletcreateresult " > < / a > <nl> + Example wallet_create Result < / h3 > <nl> + < p > This command will return the password that can be used to unlock the wallet in the future < / p > < div class = " fragment " > < div class = " line " > PW5KFWYKqvt63d4iNvedfDEPVZL227D3RQ1zpVFzuUwhMAJmRAYyX < / div > < / div > < ! - - fragment - - > < h2 > < a class = " anchor " id = " v1walletopen " > < / a > <nl> + wallet_open < / h2 > <nl> + < p > Open an existing wallet of the given name < / p > <nl> + < h3 > < a class = " anchor " id = " examplewalletopen " > < / a > <nl> + Example wallet_open Usage < / h3 > <nl> + < div class = " fragment " > < div class = " line " > $ curl http : < span class = " comment " > / / localhost : 8889 / v1 / wallet / open - X POST - d & # 39 ; & quot ; default & quot ; & # 39 ; < / span > < / div > < / div > < ! - - fragment - - > < h3 > < a class = " anchor " id = " examplewalletopenresult " > < / a > <nl> + Example wallet_open Result < / h3 > <nl> + < div class = " fragment " > < div class = " line " > { } < / div > < / div > < ! - - fragment - - > < h2 > < a class = " anchor " id = " v1walletlock " > < / a > <nl> + wallet_lock < / h2 > <nl> + < p > Lock a wallet of the given name < / p > <nl> + < h3 > < a class = " anchor " id = " examplewalletlock " > < / a > <nl> + Example wallet_lock Usage < / h3 > <nl> + < div class = " fragment " > < div class = " line " > $ curl http : < span class = " comment " > / / localhost : 8889 / v1 / wallet / lock - X POST - d & # 39 ; & quot ; default & quot ; & # 39 ; < / span > < / div > < / div > < ! - - fragment - - > < h3 > < a class = " anchor " id = " examplewalletlockresult " > < / a > <nl> + Example wallet_lock Result < / h3 > <nl> + < div class = " fragment " > < div class = " line " > { } < / div > < / div > < ! - - fragment - - > < h2 > < a class = " anchor " id = " v1walletlockall " > < / a > <nl> + wallet_lock_all < / h2 > <nl> + < p > Lock all wallets < / p > <nl> + < h3 > < a class = " anchor " id = " examplewalletlockall " > < / a > <nl> + Example wallet_lock_all Usage < / h3 > <nl> + < div class = " fragment " > < div class = " line " > $ curl http : < span class = " comment " > / / localhost : 8889 / v1 / wallet / lock_all < / span > < / div > < / div > < ! - - fragment - - > < h3 > < a class = " anchor " id = " examplewalletlockallresult " > < / a > <nl> + Example wallet_lock_all Result < / h3 > <nl> + < div class = " fragment " > < div class = " line " > { } < / div > < / div > < ! - - fragment - - > < h2 > < a class = " anchor " id = " v1walletunlock " > < / a > <nl> + wallet_unlock < / h2 > <nl> + < p > Unlock a wallet with the given name and password < / p > <nl> + < h3 > < a class = " anchor " id = " examplewalletunlock " > < / a > <nl> + Example wallet_unlock Usage < / h3 > <nl> + < div class = " fragment " > < div class = " line " > $ curl http : < span class = " comment " > / / localhost : 8889 / v1 / wallet / unlock - X POST - d & # 39 ; [ & quot ; default & quot ; , & quot ; PW5KFWYKqvt63d4iNvedfDEPVZL227D3RQ1zpVFzuUwhMAJmRAYyX & quot ; ] & # 39 ; < / span > < / div > < / div > < ! - - fragment - - > < h3 > < a class = " anchor " id = " examplewalletunlockresult " > < / a > <nl> + Example wallet_unlock Result < / h3 > <nl> + < div class = " fragment " > < div class = " line " > { } < / div > < / div > < ! - - fragment - - > < h2 > < a class = " anchor " id = " v1walletimport " > < / a > <nl> + wallet_import_key < / h2 > <nl> + < p > Import a private key to the wallet of the given name < / p > <nl> + < h3 > < a class = " anchor " id = " examplewalletimport " > < / a > <nl> + Example wallet_import_key Usage < / h3 > <nl> + < div class = " fragment " > < div class = " line " > $ curl http : < span class = " comment " > / / localhost : 8889 / v1 / wallet / import_key - X POST - d & # 39 ; [ & quot ; default & quot ; , & quot ; 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3 & quot ; ] & # 39 ; < / span > < / div > < / div > < ! - - fragment - - > < h3 > < a class = " anchor " id = " examplewalletimportresult " > < / a > <nl> + Example wallet_import_key Result < / h3 > <nl> + < div class = " fragment " > < div class = " line " > { } < / div > < / div > < ! - - fragment - - > < h2 > < a class = " anchor " id = " v1walletlist " > < / a > <nl> + wallet_list < / h2 > <nl> + < p > List all wallets < / p > <nl> + < h3 > < a class = " anchor " id = " examplewalletlist " > < / a > <nl> + Example wallet_list Usage < / h3 > <nl> + < div class = " fragment " > < div class = " line " > $ curl http : < span class = " comment " > / / localhost : 8889 / v1 / wallet / list_wallets < / span > < / div > < / div > < ! - - fragment - - > < h3 > < a class = " anchor " id = " examplewalletlistresult " > < / a > <nl> + Example wallet_list Result < / h3 > <nl> + < div class = " fragment " > < div class = " line " > [ < span class = " stringliteral " > & quot ; default * & quot ; < / span > ] < / div > < / div > < ! - - fragment - - > < h2 > < a class = " anchor " id = " v1walletlistkeys " > < / a > <nl> + wallet_list_keys < / h2 > <nl> + < p > List all key pairs across all wallets < / p > <nl> + < h3 > < a class = " anchor " id = " examplewalletlistkeys " > < / a > <nl> + Example wallet_list_keys Usage < / h3 > <nl> + < div class = " fragment " > < div class = " line " > $ curl http : < span class = " comment " > / / localhost : 8889 / v1 / wallet / list_keys < / span > < / div > < / div > < ! - - fragment - - > < h3 > < a class = " anchor " id = " examplewalletlistkeysresult " > < / a > <nl> + Example wallet_list_keys Result < / h3 > <nl> + < div class = " fragment " > < div class = " line " > [ [ < span class = " stringliteral " > & quot ; EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV & quot ; < / span > , < span class = " stringliteral " > & quot ; 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3 & quot ; < / span > ] ] < / div > < / div > < ! - - fragment - - > < h2 > < a class = " anchor " id = " v1walletgetpublickeys " > < / a > <nl> + wallet_get_public_keys < / h2 > <nl> + < p > List all public keys across all wallets < / p > <nl> + < h3 > < a class = " anchor " id = " examplewalletgetpublickeys " > < / a > <nl> + Example wallet_get_public_keys Usage < / h3 > <nl> + < div class = " fragment " > < div class = " line " > $ curl http : < span class = " comment " > / / localhost : 8889 / v1 / wallet / get_public_keys < / span > < / div > < / div > < ! - - fragment - - > < h3 > < a class = " anchor " id = " examplewallegetpublickeysresult " > < / a > <nl> + Example wallet_get_public_keys Result < / h3 > <nl> + < div class = " fragment " > < div class = " line " > [ < span class = " stringliteral " > & quot ; EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV & quot ; < / span > ] < / div > < / div > < ! - - fragment - - > < h2 > < a class = " anchor " id = " v1walletsettimeout " > < / a > <nl> + wallet_set_timeout < / h2 > <nl> + < p > Set wallet auto lock timeout ( in seconds ) < / p > <nl> + < h3 > < a class = " anchor " id = " examplewalletsettimeout " > < / a > <nl> + Example wallet_set_timeout Usage < / h3 > <nl> + < div class = " fragment " > < div class = " line " > $ curl http : < span class = " comment " > / / localhost : 8889 / v1 / wallet / set_timeout - X POST - d & # 39 ; 10 & # 39 ; < / span > < / div > < / div > < ! - - fragment - - > < h3 > < a class = " anchor " id = " examplewalletsettimeoutresult " > < / a > <nl> + Example wallet_set_timeout Result < / h3 > <nl> + < div class = " fragment " > < div class = " line " > { } < / div > < / div > < ! - - fragment - - > < h2 > < a class = " anchor " id = " v1walletsigntrx " > < / a > <nl> + wallet_sign_trx < / h2 > <nl> + < p > Sign transaction given an array of transaction , require public keys , and chain id < / p > <nl> + < h3 > < a class = " anchor " id = " examplewalletsigntrx " > < / a > <nl> + Example wallet_sign_trx Usage < / h3 > <nl> + < div class = " fragment " > < div class = " line " > $ curl http : < span class = " comment " > / / localhost : 8889 / v1 / wallet / sign_transaction - X POST - d & # 39 ; [ { & quot ; ref_block_num & quot ; : 21453 , & quot ; ref_block_prefix & quot ; : 3165644999 , & quot ; expiration & quot ; : & quot ; 2017 - 12 - 08T10 : 28 : 49 & quot ; , & quot ; scope & quot ; : [ & quot ; initb & quot ; , & quot ; initc & quot ; ] , & quot ; read_scope & quot ; : [ ] , & quot ; messages & quot ; : [ { & quot ; code & quot ; : & quot ; currency & quot ; , & quot ; type & quot ; : & quot ; transfer & quot ; , & quot ; authorization & quot ; : [ { & quot ; account & quot ; : & quot ; initb & quot ; , & quot ; permission & quot ; : & quot ; active & quot ; } ] , & quot ; data & quot ; : & quot ; 000000008093dd74000000000094dd74e803000000000000 & quot ; } ] , & quot ; signatures & quot ; : [ ] } , [ & quot ; EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV & quot ; ] , & quot ; & quot ; ] & # 39 ; < / span > < / div > < / div > < ! - - fragment - - > < h3 > < a class = " anchor " id = " examplewalletsigntrxresult " > < / a > <nl> + Example wallet_sign_trx Result < / h3 > <nl> + < div class = " fragment " > < div class = " line " > { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; ref_block_num & quot ; < / span > : 21453 , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; ref_block_prefix & quot ; < / span > : 3165644999 , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; expiration & quot ; < / span > : < span class = " stringliteral " > & quot ; 2017 - 12 - 08T10 : 28 : 49 & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; scope & quot ; < / span > : [ < / div > < div class = " line " > < span class = " stringliteral " > & quot ; initb & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; initc & quot ; < / span > < / div > < div class = " line " > ] , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; read_scope & quot ; < / span > : [ ] , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; messages & quot ; < / span > : [ < / div > < div class = " line " > { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; code & quot ; < / span > : < span class = " stringliteral " > & quot ; currency & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; type & quot ; < / span > : < span class = " stringliteral " > & quot ; transfer & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; authorization & quot ; < / span > : [ < / div > < div class = " line " > { < / div > < div class = " line " > < span class = " stringliteral " > & quot ; account & quot ; < / span > : < span class = " stringliteral " > & quot ; initb & quot ; < / span > , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; permission & quot ; < / span > : < span class = " stringliteral " > & quot ; active & quot ; < / span > < / div > < div class = " line " > } < / div > < div class = " line " > ] , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; data & quot ; < / span > : < span class = " stringliteral " > & quot ; 000000008093dd74000000000094dd74e803000000000000 & quot ; < / span > < / div > < div class = " line " > } < / div > < div class = " line " > ] , < / div > < div class = " line " > < span class = " stringliteral " > & quot ; signatures & quot ; < / span > : [ < / div > < div class = " line " > < span class = " stringliteral " > & quot ; 1f393cc5ce6a6951fb53b11812345bcf14ffd978b07be386fd639eaf440bca7dca16b14833ec661ca0703d15e55a2a599a36d55ce78c4539433f6ce8bcee0158c3 & quot ; < / span > < / div > < div class = " line " > ] < / div > < div class = " line " > } < / div > < / div > < ! - - fragment - - > < / div > < ! - - contents - - > <nl> < ! - - start footer part - - > <nl> < hr class = " footer " / > < address class = " footer " > < small > <nl> Generated by & # 160 ; < a href = " http : / / www . doxygen . org / index . html " > <nl> mmm a / docs / group__examplecontract . html <nl> ppp b / docs / group__examplecontract . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / group__mathapi . html <nl> ppp b / docs / group__mathapi . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> <nl> < div class = " summary " > <nl> < a href = " # groups " > Modules < / a > < / div > <nl> < div class = " headertitle " > <nl> - < div class = " title " > Math API < div class = " ingroups " > < a class = " el " href = " group__contractdev . html " > How To Write Contracts < / a > < / div > < / div > < / div > <nl> + < div class = " title " > Math API < / div > < / div > <nl> < / div > < ! - - header - - > <nl> < div class = " contents " > <nl> <nl> mmm a / docs / group__mathcapi . html <nl> ppp b / docs / group__mathcapi . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> <nl> < div class = " summary " > <nl> < a href = " # func - members " > Functions < / a > < / div > <nl> < div class = " headertitle " > <nl> - < div class = " title " > Math C API < div class = " ingroups " > < a class = " el " href = " group__contractdev . html " > How To Write Contracts < / a > & raquo ; < a class = " el " href = " group__mathapi . html " > Math API < / a > < / div > < / div > < / div > <nl> + < div class = " title " > Math C API < div class = " ingroups " > < a class = " el " href = " group__mathapi . html " > Math API < / a > < / div > < / div > < / div > <nl> < / div > < ! - - header - - > <nl> < div class = " contents " > <nl> <nl> mmm a / docs / group__mathcppapi . html <nl> ppp b / docs / group__mathcppapi . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> <nl> < a href = " # nested - classes " > Classes < / a > & # 124 ; <nl> < a href = " # func - members " > Functions < / a > < / div > <nl> < div class = " headertitle " > <nl> - < div class = " title " > Math C + + API < div class = " ingroups " > < a class = " el " href = " group__contractdev . html " > How To Write Contracts < / a > & raquo ; < a class = " el " href = " group__mathapi . html " > Math API < / a > < / div > < / div > < / div > <nl> + < div class = " title " > Math C + + API < div class = " ingroups " > < a class = " el " href = " group__mathapi . html " > Math API < / a > < / div > < / div > < / div > <nl> < / div > < ! - - header - - > <nl> < div class = " contents " > <nl> <nl> mmm a / docs / group__memoryapi . html <nl> ppp b / docs / group__memoryapi . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> <nl> < div class = " summary " > <nl> < a href = " # groups " > Modules < / a > < / div > <nl> < div class = " headertitle " > <nl> - < div class = " title " > Memory API < div class = " ingroups " > < a class = " el " href = " group__contractdev . html " > How To Write Contracts < / a > < / div > < / div > < / div > <nl> + < div class = " title " > Memory API < / div > < / div > <nl> < / div > < ! - - header - - > <nl> < div class = " contents " > <nl> <nl> mmm a / docs / group__memorycapi . html <nl> ppp b / docs / group__memorycapi . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> <nl> < div class = " summary " > <nl> < a href = " # func - members " > Functions < / a > < / div > <nl> < div class = " headertitle " > <nl> - < div class = " title " > Memory C API < div class = " ingroups " > < a class = " el " href = " group__contractdev . html " > How To Write Contracts < / a > & raquo ; < a class = " el " href = " group__memoryapi . html " > Memory API < / a > < / div > < / div > < / div > <nl> + < div class = " title " > Memory C API < div class = " ingroups " > < a class = " el " href = " group__memoryapi . html " > Memory API < / a > < / div > < / div > < / div > <nl> < / div > < ! - - header - - > <nl> < div class = " contents " > <nl> <nl> mmm a / docs / group__memorycppapi . html <nl> ppp b / docs / group__memorycppapi . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> <nl> < a href = " # func - members " > Functions < / a > & # 124 ; <nl> < a href = " # var - members " > Variables < / a > < / div > <nl> < div class = " headertitle " > <nl> - < div class = " title " > Memory C + + API < div class = " ingroups " > < a class = " el " href = " group__contractdev . html " > How To Write Contracts < / a > & raquo ; < a class = " el " href = " group__memoryapi . html " > Memory API < / a > < / div > < / div > < / div > <nl> + < div class = " title " > Memory C + + API < div class = " ingroups " > < a class = " el " href = " group__memoryapi . html " > Memory API < / a > < / div > < / div > < / div > <nl> < / div > < ! - - header - - > <nl> < div class = " contents " > <nl> <nl> mmm a / docs / group__messageapi . html <nl> ppp b / docs / group__messageapi . html <nl> <nl> < meta http - equiv = " X - UA - Compatible " content = " IE = 9 " / > <nl> < meta name = " generator " content = " Doxygen 1 . 8 . 13 " / > <nl> < meta name = " viewport " content = " width = device - width , initial - scale = 1 " / > <nl> - < title > EOS . IO : message API < / title > <nl> + < title > EOS . IO : Message API < / title > <nl> < link href = " tabs . css " rel = " stylesheet " type = " text / css " / > <nl> < script type = " text / javascript " src = " jquery . js " > < / script > <nl> < script type = " text / javascript " src = " dynsections . js " > < / script > <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> <nl> < div class = " summary " > <nl> < a href = " # groups " > Modules < / a > < / div > <nl> < div class = " headertitle " > <nl> - < div class = " title " > message API < div class = " ingroups " > < a class = " el " href = " group__contractdev . html " > How To Write Contracts < / a > < / div > < / div > < / div > <nl> + < div class = " title " > Message API < / div > < / div > <nl> < / div > < ! - - header - - > <nl> < div class = " contents " > <nl> <nl> mmm a / docs / group__messagecapi . html <nl> ppp b / docs / group__messagecapi . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> <nl> < div class = " summary " > <nl> < a href = " # func - members " > Functions < / a > < / div > <nl> < div class = " headertitle " > <nl> - < div class = " title " > message C API < div class = " ingroups " > < a class = " el " href = " group__contractdev . html " > How To Write Contracts < / a > & raquo ; < a class = " el " href = " group__messageapi . html " > message API < / a > < / div > < / div > < / div > <nl> + < div class = " title " > message C API < div class = " ingroups " > < a class = " el " href = " group__messageapi . html " > Message API < / a > < / div > < / div > < / div > <nl> < / div > < ! - - header - - > <nl> < div class = " contents " > <nl> <nl> mmm a / docs / group__messagecppapi . html <nl> ppp b / docs / group__messagecppapi . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> <nl> < div class = " summary " > <nl> < a href = " # func - members " > Functions < / a > < / div > <nl> < div class = " headertitle " > <nl> - < div class = " title " > Message C + + API < div class = " ingroups " > < a class = " el " href = " group__contractdev . html " > How To Write Contracts < / a > & raquo ; < a class = " el " href = " group__messageapi . html " > message API < / a > < / div > < / div > < / div > <nl> + < div class = " title " > Message C + + API < div class = " ingroups " > < a class = " el " href = " group__messageapi . html " > Message API < / a > < / div > < / div > < / div > <nl> < / div > < ! - - header - - > <nl> < div class = " contents " > <nl> <nl> mmm a / docs / group__storageapi . html <nl> ppp b / docs / group__storageapi . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / group__systemapi . html <nl> ppp b / docs / group__systemapi . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> <nl> < div class = " summary " > <nl> < a href = " # groups " > Modules < / a > < / div > <nl> < div class = " headertitle " > <nl> - < div class = " title " > System API < div class = " ingroups " > < a class = " el " href = " group__contractdev . html " > How To Write Contracts < / a > < / div > < / div > < / div > <nl> + < div class = " title " > System API < / div > < / div > <nl> < / div > < ! - - header - - > <nl> < div class = " contents " > <nl> <nl> mmm a / docs / group__systemcapi . html <nl> ppp b / docs / group__systemcapi . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> <nl> < div class = " summary " > <nl> < a href = " # func - members " > Functions < / a > < / div > <nl> < div class = " headertitle " > <nl> - < div class = " title " > System C API < div class = " ingroups " > < a class = " el " href = " group__contractdev . html " > How To Write Contracts < / a > & raquo ; < a class = " el " href = " group__systemapi . html " > System API < / a > < / div > < / div > < / div > <nl> + < div class = " title " > System C API < div class = " ingroups " > < a class = " el " href = " group__systemapi . html " > System API < / a > < / div > < / div > < / div > <nl> < / div > < ! - - header - - > <nl> < div class = " contents " > <nl> <nl> mmm a / docs / group__tictactoecontract . html <nl> ppp b / docs / group__tictactoecontract . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / group__tokens . html <nl> ppp b / docs / group__tokens . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> <nl> < a href = " # nested - classes " > Classes < / a > & # 124 ; <nl> < a href = " # typedef - members " > Typedefs < / a > < / div > <nl> < div class = " headertitle " > <nl> - < div class = " title " > Token API < div class = " ingroups " > < a class = " el " href = " group__contractdev . html " > How To Write Contracts < / a > < / div > < / div > < / div > <nl> + < div class = " title " > Token API < / div > < / div > <nl> < / div > < ! - - header - - > <nl> < div class = " contents " > <nl> <nl> mmm a / docs / group__transactionapi . html <nl> ppp b / docs / group__transactionapi . html <nl> <nl> < meta http - equiv = " X - UA - Compatible " content = " IE = 9 " / > <nl> < meta name = " generator " content = " Doxygen 1 . 8 . 13 " / > <nl> < meta name = " viewport " content = " width = device - width , initial - scale = 1 " / > <nl> - < title > EOS . IO : transaction API < / title > <nl> + < title > EOS . IO : Transaction API < / title > <nl> < link href = " tabs . css " rel = " stylesheet " type = " text / css " / > <nl> < script type = " text / javascript " src = " jquery . js " > < / script > <nl> < script type = " text / javascript " src = " dynsections . js " > < / script > <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> <nl> < div class = " summary " > <nl> < a href = " # groups " > Modules < / a > < / div > <nl> < div class = " headertitle " > <nl> - < div class = " title " > transaction API < div class = " ingroups " > < a class = " el " href = " group__contractdev . html " > How To Write Contracts < / a > < / div > < / div > < / div > <nl> + < div class = " title " > Transaction API < / div > < / div > <nl> < / div > < ! - - header - - > <nl> < div class = " contents " > <nl> <nl> mmm a / docs / group__transactioncapi . html <nl> ppp b / docs / group__transactioncapi . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> <nl> < a href = " # typedef - members " > Typedefs < / a > & # 124 ; <nl> < a href = " # func - members " > Functions < / a > < / div > <nl> < div class = " headertitle " > <nl> - < div class = " title " > transaction C API < div class = " ingroups " > < a class = " el " href = " group__contractdev . html " > How To Write Contracts < / a > & raquo ; < a class = " el " href = " group__transactionapi . html " > transaction API < / a > < / div > < / div > < / div > <nl> + < div class = " title " > transaction C API < div class = " ingroups " > < a class = " el " href = " group__transactionapi . html " > Transaction API < / a > < / div > < / div > < / div > <nl> < / div > < ! - - header - - > <nl> < div class = " contents " > <nl> <nl> mmm a / docs / group__transactioncppapi . html <nl> ppp b / docs / group__transactioncppapi . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> <nl> < div class = " summary " > <nl> < a href = " # nested - classes " > Classes < / a > < / div > <nl> < div class = " headertitle " > <nl> - < div class = " title " > transaction C + + API < div class = " ingroups " > < a class = " el " href = " group__contractdev . html " > How To Write Contracts < / a > & raquo ; < a class = " el " href = " group__transactionapi . html " > transaction API < / a > < / div > < / div > < / div > <nl> + < div class = " title " > transaction C + + API < div class = " ingroups " > < a class = " el " href = " group__transactionapi . html " > Transaction API < / a > < / div > < / div > < / div > <nl> < / div > < ! - - header - - > <nl> < div class = " contents " > <nl> <nl> mmm a / docs / group__types . html <nl> ppp b / docs / group__types . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> <nl> < a href = " # define - members " > Macros < / a > & # 124 ; <nl> < a href = " # typedef - members " > Typedefs < / a > < / div > <nl> < div class = " headertitle " > <nl> - < div class = " title " > Builtin Types < div class = " ingroups " > < a class = " el " href = " group__contractdev . html " > How To Write Contracts < / a > < / div > < / div > < / div > <nl> + < div class = " title " > Builtin Types < / div > < / div > <nl> < / div > < ! - - header - - > <nl> < div class = " contents " > <nl> <nl> mmm a / docs / hierarchy . html <nl> ppp b / docs / hierarchy . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / index . html <nl> ppp b / docs / index . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> < h2 > EOS . IO < / h2 > <nl> < li > < a href = " https : / / github . com / EOSIO / Documentation / blob / master / Roadmap . md / " > Roadmap < / a > < / li > <nl> < li > < a href = " https : / / www . eos . io / chat / " > Telegram < / a > < / li > <nl> < li > < a href = " https : / / github . com / EOSIO / Documentation / blob / master / TechnicalWhitePaper . md / " > White Paper < / a > < / li > <nl> + < li > < a href = " https : / / github . com / EOSIO / eos / wiki / " > Wiki < / a > < / li > <nl> < / ul > <nl> < h2 > Environment Setup < / h2 > <nl> < ul > <nl> < h2 > Environment Setup < / h2 > <nl> < / li > <nl> < li > < a href = " https : / / github . com / EOSIO / eos / tree / master / Docker " > Docker < / a > < / li > <nl> < / ul > <nl> - < h2 > End User < / h2 > <nl> - < ul > <nl> - < li > Wallet Creation and Management < ul > <nl> - < li > < a href = " https : / / eosio . github . io / eos / group__eosc . html # createwallet " > Create a wallet < / a > < / li > <nl> - < li > < a href = " https : / / eosio . github . io / eos / group__eosc . html # importkey " > Import Key to Wallet < / a > < / li > <nl> - < li > < a href = " https : / / eosio . github . io / eos / group__eosc . html # lockwallets " > Locking and Unlocking Wallet < / a > < / li > <nl> - < li > < a href = " https : / / eosio . github . io / eos / group__eosc . html # createaccount " > Create an Account < / a > < / li > <nl> - < li > < a href = " https : / / eosio . github . io / eos / group__eosc . html # transfereos " > Transfer EOS < / a > < / li > <nl> - < li > < a href = " https : / / eosio . github . io / eos / group__eosc . html # gettingtransaction " > Getting Transaction < / a > < / li > <nl> - < / ul > <nl> - < / li > <nl> - < / ul > <nl> < h2 > Smart Contract Developers < / h2 > <nl> < ul > <nl> - < li > < a href = " https : / / eosio . github . io / eos / md_contracts_eoslib_tutorial . html " > Introduction to Contract Development Tutorial < / a > < / li > <nl> - < li > < a href = " https : / / github . com / EOSIO / eos # smartcontracts " > How to Deploy Smart Contracts < / a > < / li > <nl> < li > < a href = " https : / / eosio . github . io / eos / group__eosiorpc . html " > RPC Interface < / a > < / li > <nl> < li > < a href = " https : / / eosio . github . io / eos / group__contractdev . html " > API Reference < / a > < ul > <nl> < li > < a class = " el " href = " group__database . html " > Database API < / a > - APIs that store and retreive data on the blockchainEOS . IO organizes data according to the following broad structure < / li > <nl> < li > < a class = " el " href = " group__mathapi . html " > Math API < / a > - Defines common math function < / li > <nl> - < li > < a class = " el " href = " group__messageapi . html " > message API < / a > - Define API for querying message properties < / li > <nl> + < li > < a class = " el " href = " group__messageapi . html " > Message API < / a > - Define API for querying message properties < / li > <nl> < li > < a class = " el " href = " group__consoleapi . html " > Console API < / a > - Enables applications to log / print text messages < / li > <nl> < li > < a class = " el " href = " group__tokens . html " > Token API < / a > - Defines the ABI for interfacing with standard - compatible token messages and database tables < / li > <nl> < li > < a class = " el " href = " group__types . html " > Builtin Types < / a > - Specifies typedefs and aliases < / li > <nl> - < li > < a class = " el " href = " group__transactionapi . html " > transaction API < / a > - Define API for sending transactions and inline messages < / li > <nl> + < li > < a class = " el " href = " group__transactionapi . html " > Transaction API < / a > - Define API for sending transactions and inline messages < / li > <nl> < li > < a class = " el " href = " group__systemapi . html " > System API < / a > - Define API for interating with system level intrinsics < / li > <nl> < / ul > <nl> < / li > <nl> mmm a / docs / infinite_8cpp . html <nl> ppp b / docs / infinite_8cpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / infinite_8hpp . html <nl> ppp b / docs / infinite_8hpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / infinite_8hpp_source . html <nl> ppp b / docs / infinite_8hpp_source . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / infinite_8wast_8hpp . html <nl> ppp b / docs / infinite_8wast_8hpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / infinite_8wast_8hpp_source . html <nl> ppp b / docs / infinite_8wast_8hpp_source . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / mainpage_8md . html <nl> ppp b / docs / mainpage_8md . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / math_8h . html <nl> ppp b / docs / math_8h . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / math_8h_source . html <nl> ppp b / docs / math_8h_source . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / math_8hpp . html <nl> ppp b / docs / math_8hpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / math_8hpp_source . html <nl> ppp b / docs / math_8hpp_source . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / md_contracts_eoslib_tutorial . html <nl> ppp b / docs / md_contracts_eoslib_tutorial . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / memory_8h . html <nl> ppp b / docs / memory_8h . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / memory_8h_source . html <nl> ppp b / docs / memory_8h_source . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / memory_8hpp . html <nl> ppp b / docs / memory_8hpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / memory_8hpp_source . html <nl> ppp b / docs / memory_8hpp_source . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / message_8h . html <nl> ppp b / docs / message_8h . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / message_8h_source . html <nl> ppp b / docs / message_8h_source . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / message_8hpp . html <nl> ppp b / docs / message_8hpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / message_8hpp_source . html <nl> ppp b / docs / message_8hpp_source . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / modules . html <nl> ppp b / docs / modules . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> <nl> < / div > < ! - - header - - > <nl> < div class = " contents " > <nl> < div class = " textblock " > Here is a list of all modules : < / div > < div class = " directory " > <nl> - < div class = " levels " > [ detail level < span onclick = " javascript : toggleLevel ( 1 ) ; " > 1 < / span > < span onclick = " javascript : toggleLevel ( 2 ) ; " > 2 < / span > < span onclick = " javascript : toggleLevel ( 3 ) ; " > 3 < / span > < span onclick = " javascript : toggleLevel ( 4 ) ; " > 4 < / span > ] < / div > < table class = " directory " > <nl> + < div class = " levels " > [ detail level < span onclick = " javascript : toggleLevel ( 1 ) ; " > 1 < / span > < span onclick = " javascript : toggleLevel ( 2 ) ; " > 2 < / span > < span onclick = " javascript : toggleLevel ( 3 ) ; " > 3 < / span > ] < / div > < table class = " directory " > <nl> < tr id = " row_0_ " class = " even " > < td class = " entry " > < span style = " width : 0px ; display : inline - block ; " > & # 160 ; < / span > < span id = " arr_0_ " class = " arrow " onclick = " toggleFolder ( ' 0_ ' ) " > & # 9660 ; < / span > < a class = " el " href = " group__examplecontract . html " target = " _self " > Example Contract < / a > < / td > < td class = " desc " > Example Contract < / td > < / tr > <nl> < tr id = " row_0_0_ " > < td class = " entry " > < span style = " width : 32px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__currencyapi . html " target = " _self " > Currency Contract < / a > < / td > < td class = " desc " > Defines the curency contract example < / td > < / tr > <nl> < tr id = " row_0_1_ " class = " even " > < td class = " entry " > < span style = " width : 32px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__storageapi . html " target = " _self " > Storage Contract < / a > < / td > < td class = " desc " > Defines the storage contract example < / td > < / tr > <nl> < tr id = " row_0_2_ " > < td class = " entry " > < span style = " width : 32px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__tictactoecontract . html " target = " _self " > Tic Tac Toe Contract < / a > < / td > < td class = " desc " > Defines the PvP tic tac toe contract example < / td > < / tr > <nl> < tr id = " row_1_ " class = " even " > < td class = " entry " > < span style = " width : 16px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__eoscontract . html " target = " _self " > EOS Contract < / a > < / td > < td class = " desc " > Documents the interface to the EOS currency contract < / td > < / tr > <nl> - < tr id = " row_2_ " > < td class = " entry " > < span style = " width : 0px ; display : inline - block ; " > & # 160 ; < / span > < span id = " arr_2_ " class = " arrow " onclick = " toggleFolder ( ' 2_ ' ) " > & # 9660 ; < / span > < a class = " el " href = " group__contractdev . html " target = " _self " > How To Write Contracts < / a > < / td > < td class = " desc " > Introduction to writing contracts for EOS . IO < / td > < / tr > <nl> - < tr id = " row_2_0_ " class = " even " > < td class = " entry " > < span style = " width : 32px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__accountcapi . html " target = " _self " > Account API < / a > < / td > < td class = " desc " > Define API for querying account data < / td > < / tr > <nl> - < tr id = " row_2_1_ " > < td class = " entry " > < span style = " width : 32px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__account . html " target = " _self " > Account API < / a > < / td > < td class = " desc " > Defines the ABI for interfacing with account balances < / td > < / tr > <nl> - < tr id = " row_2_2_ " class = " even " > < td class = " entry " > < span style = " width : 32px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__chaincapi . html " target = " _self " > Chain API < / a > < / td > < td class = " desc " > Define API for querying internal chain state < / td > < / tr > <nl> - < tr id = " row_2_3_ " > < td class = " entry " > < span style = " width : 16px ; display : inline - block ; " > & # 160 ; < / span > < span id = " arr_2_3_ " class = " arrow " onclick = " toggleFolder ( ' 2_3_ ' ) " > & # 9660 ; < / span > < a class = " el " href = " group__database . html " target = " _self " > Database API < / a > < / td > < td class = " desc " > APIs that store and retreive data on the blockchainEOS . IO organizes data according to the following broad structure : < / td > < / tr > <nl> - < tr id = " row_2_3_0_ " class = " even " > < td class = " entry " > < span style = " width : 32px ; display : inline - block ; " > & # 160 ; < / span > < span id = " arr_2_3_0_ " class = " arrow " onclick = " toggleFolder ( ' 2_3_0_ ' ) " > & # 9660 ; < / span > < a class = " el " href = " group__database_c . html " target = " _self " > Database C API < / a > < / td > < td class = " desc " > C APIs for interfacing with the database < / td > < / tr > <nl> - < tr id = " row_2_3_0_0_ " > < td class = " entry " > < span style = " width : 64px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__dbi64 . html " target = " _self " > Single 64 bit Index table < / a > < / td > < td class = " desc " > These methods interface with a simple table with 64 bit unique primary key and arbitrary binary data value < / td > < / tr > <nl> - < tr id = " row_2_3_0_1_ " class = " even " > < td class = " entry " > < span style = " width : 64px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__dbstr . html " target = " _self " > Single String Index table < / a > < / td > < td class = " desc " > These methods interface with a simple table with String unique primary key and arbitrary binary data value < / td > < / tr > <nl> - < tr id = " row_2_3_0_2_ " > < td class = " entry " > < span style = " width : 64px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__dbi128i128 . html " target = " _self " > Dual 128 bit Index table < / a > < / td > < td class = " desc " > Interface to a database table with 128 bit primary and secondary keys and arbitary binary data value < / td > < / tr > <nl> - < tr id = " row_2_3_0_3_ " class = " even " > < td class = " entry " > < span style = " width : 64px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__dbi64i64i64 . html " target = " _self " > Triple 64 bit Index table < / a > < / td > < td class = " desc " > Interface to a database table with 64 bit primary , secondary and tertiary keys and arbitrary binary data value < / td > < / tr > <nl> - < tr id = " row_2_3_1_ " > < td class = " entry " > < span style = " width : 32px ; display : inline - block ; " > & # 160 ; < / span > < span id = " arr_2_3_1_ " class = " arrow " onclick = " toggleFolder ( ' 2_3_1_ ' ) " > & # 9660 ; < / span > < a class = " el " href = " group__database_cpp . html " target = " _self " > Database C + + API < / a > < / td > < td class = " desc " > C + + APIs for interfacing with the database < / td > < / tr > <nl> - < tr id = " row_2_3_1_0_ " class = " even " > < td class = " entry " > < span style = " width : 64px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__dual_index_table . html " target = " _self " > Dual Index table < / a > < / td > < td class = " desc " > Defines a type - safe C + + wrapper around the < a class = " el " href = " group__database_c . html " > Database C API < / a > < / td > < / tr > <nl> - < tr id = " row_2_3_1_1_ " > < td class = " entry " > < span style = " width : 64px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group___singleindextable . html " target = " _self " > Single Index table < / a > < / td > < td class = " desc " > This specialization of table is for single - index tables < / td > < / tr > <nl> - < tr id = " row_2_4_ " class = " even " > < td class = " entry " > < span style = " width : 32px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__fixed__point . html " target = " _self " > Template classes for Fixed Point representaton < / a > < / td > < td class = " desc " > 32 , 64 , 128 , 256 bits version of Fixed Point variables < / td > < / tr > <nl> - < tr id = " row_2_5_ " > < td class = " entry " > < span style = " width : 32px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__fixed . html " target = " _self " > point Fixed Point generic class < / a > < / td > < td class = " desc " > Implementation of fixed point template class < / td > < / tr > <nl> - < tr id = " row_2_6_ " class = " even " > < td class = " entry " > < span style = " width : 16px ; display : inline - block ; " > & # 160 ; < / span > < span id = " arr_2_6_ " class = " arrow " onclick = " toggleFolder ( ' 2_6_ ' ) " > & # 9660 ; < / span > < a class = " el " href = " group__mathapi . html " target = " _self " > Math API < / a > < / td > < td class = " desc " > Defines common math functions < / td > < / tr > <nl> - < tr id = " row_2_6_0_ " > < td class = " entry " > < span style = " width : 48px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__mathcapi . html " target = " _self " > Math C API < / a > < / td > < td class = " desc " > Defines basic mathematical operations for higher abstractions to use < / td > < / tr > <nl> - < tr id = " row_2_6_1_ " class = " even " > < td class = " entry " > < span style = " width : 48px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__mathcppapi . html " target = " _self " > Math C + + API < / a > < / td > < td class = " desc " > Defines common math functions and helper types < / td > < / tr > <nl> - < tr id = " row_2_7_ " > < td class = " entry " > < span style = " width : 16px ; display : inline - block ; " > & # 160 ; < / span > < span id = " arr_2_7_ " class = " arrow " onclick = " toggleFolder ( ' 2_7_ ' ) " > & # 9660 ; < / span > < a class = " el " href = " group__memoryapi . html " target = " _self " > Memory API < / a > < / td > < td class = " desc " > Defines common memory functions < / td > < / tr > <nl> - < tr id = " row_2_7_0_ " class = " even " > < td class = " entry " > < span style = " width : 48px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__memorycapi . html " target = " _self " > Memory C API < / a > < / td > < td class = " desc " > Defines common memory functions < / td > < / tr > <nl> - < tr id = " row_2_7_1_ " > < td class = " entry " > < span style = " width : 48px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__memorycppapi . html " target = " _self " > Memory C + + API < / a > < / td > < td class = " desc " > Defines common memory functions < / td > < / tr > <nl> - < tr id = " row_2_8_ " class = " even " > < td class = " entry " > < span style = " width : 16px ; display : inline - block ; " > & # 160 ; < / span > < span id = " arr_2_8_ " class = " arrow " onclick = " toggleFolder ( ' 2_8_ ' ) " > & # 9660 ; < / span > < a class = " el " href = " group__messageapi . html " target = " _self " > message API < / a > < / td > < td class = " desc " > Define API for querying message properties < / td > < / tr > <nl> - < tr id = " row_2_8_0_ " > < td class = " entry " > < span style = " width : 48px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__messagecapi . html " target = " _self " > message C API < / a > < / td > < td class = " desc " > Define API for querying message properties < / td > < / tr > <nl> - < tr id = " row_2_8_1_ " class = " even " > < td class = " entry " > < span style = " width : 48px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__messagecppapi . html " target = " _self " > Message C + + API < / a > < / td > < td class = " desc " > Type - safe C + + wrapers for Message C API < / td > < / tr > <nl> - < tr id = " row_2_9_ " > < td class = " entry " > < span style = " width : 16px ; display : inline - block ; " > & # 160 ; < / span > < span id = " arr_2_9_ " class = " arrow " onclick = " toggleFolder ( ' 2_9_ ' ) " > & # 9660 ; < / span > < a class = " el " href = " group__consoleapi . html " target = " _self " > Console API < / a > < / td > < td class = " desc " > Enables applications to log / print text messages < / td > < / tr > <nl> - < tr id = " row_2_9_0_ " class = " even " > < td class = " entry " > < span style = " width : 48px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__consolecapi . html " target = " _self " > Console C API < / a > < / td > < td class = " desc " > < / td > < / tr > <nl> - < tr id = " row_2_9_1_ " > < td class = " entry " > < span style = " width : 48px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__console_cppapi . html " target = " _self " > Console C + + API < / a > < / td > < td class = " desc " > C + + wrapper for Console C API < / td > < / tr > <nl> - < tr id = " row_2_10_ " class = " even " > < td class = " entry " > < span style = " width : 16px ; display : inline - block ; " > & # 160 ; < / span > < span id = " arr_2_10_ " class = " arrow " onclick = " toggleFolder ( ' 2_10_ ' ) " > & # 9660 ; < / span > < a class = " el " href = " group__systemapi . html " target = " _self " > System API < / a > < / td > < td class = " desc " > Define API for interating with system level intrinsics < / td > < / tr > <nl> - < tr id = " row_2_10_0_ " > < td class = " entry " > < span style = " width : 48px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__systemcapi . html " target = " _self " > System C API < / a > < / td > < td class = " desc " > Define API for interating with system level intrinsics < / td > < / tr > <nl> - < tr id = " row_2_11_ " class = " even " > < td class = " entry " > < span style = " width : 32px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__tokens . html " target = " _self " > Token API < / a > < / td > < td class = " desc " > Defines the ABI for interfacing with standard - compatible token messages and database tables < / td > < / tr > <nl> - < tr id = " row_2_12_ " > < td class = " entry " > < span style = " width : 16px ; display : inline - block ; " > & # 160 ; < / span > < span id = " arr_2_12_ " class = " arrow " onclick = " toggleFolder ( ' 2_12_ ' ) " > & # 9660 ; < / span > < a class = " el " href = " group__transactionapi . html " target = " _self " > transaction API < / a > < / td > < td class = " desc " > Define API for sending transactions and inline messages < / td > < / tr > <nl> - < tr id = " row_2_12_0_ " class = " even " > < td class = " entry " > < span style = " width : 48px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__transactioncapi . html " target = " _self " > transaction C API < / a > < / td > < td class = " desc " > Define API for sending transactions < / td > < / tr > <nl> - < tr id = " row_2_12_1_ " > < td class = " entry " > < span style = " width : 48px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__transactioncppapi . html " target = " _self " > transaction C + + API < / a > < / td > < td class = " desc " > Type - safe C + + wrappers for transaction C API < / td > < / tr > <nl> - < tr id = " row_2_13_ " class = " even " > < td class = " entry " > < span style = " width : 32px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__types . html " target = " _self " > Builtin Types < / a > < / td > < td class = " desc " > Specifies typedefs and aliases < / td > < / tr > <nl> - < tr id = " row_3_ " > < td class = " entry " > < span style = " width : 16px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__eoswallet . html " target = " _self " > EOS Wallet Process ( eos - walletd ) < / a > < / td > < td class = " desc " > Local process to store signatures used by eosd to verify signatures and authorize transactions < / td > < / tr > <nl> - < tr id = " row_4_ " class = " even " > < td class = " entry " > < span style = " width : 16px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__eosc . html " target = " _self " > EOS Command Line Client ( eosc ) < / a > < / td > < td class = " desc " > Tool for sending transactions and querying state from eosd < / td > < / tr > <nl> - < tr id = " row_5_ " > < td class = " entry " > < span style = " width : 16px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__howtobuild . html " target = " _self " > How To Build EOS . IO < / a > < / td > < td class = " desc " > Describes how to download , compile , and configure an EOS . IO node < / td > < / tr > <nl> - < tr id = " row_6_ " class = " even " > < td class = " entry " > < span style = " width : 16px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__eosiorpc . html " target = " _self " > eosd RPC Interface < / a > < / td > < td class = " desc " > Describes how to interface with eosd over HTTP RPC < / td > < / tr > <nl> + < tr id = " row_2_ " > < td class = " entry " > < span style = " width : 16px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__accountcapi . html " target = " _self " > Account API < / a > < / td > < td class = " desc " > Define API for querying account data < / td > < / tr > <nl> + < tr id = " row_3_ " class = " even " > < td class = " entry " > < span style = " width : 16px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__account . html " target = " _self " > Account API < / a > < / td > < td class = " desc " > Defines the ABI for interfacing with account balances < / td > < / tr > <nl> + < tr id = " row_4_ " > < td class = " entry " > < span style = " width : 16px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__chaincapi . html " target = " _self " > Chain API < / a > < / td > < td class = " desc " > Define API for querying internal chain state < / td > < / tr > <nl> + < tr id = " row_5_ " class = " even " > < td class = " entry " > < span style = " width : 0px ; display : inline - block ; " > & # 160 ; < / span > < span id = " arr_5_ " class = " arrow " onclick = " toggleFolder ( ' 5_ ' ) " > & # 9660 ; < / span > < a class = " el " href = " group__database . html " target = " _self " > Database API < / a > < / td > < td class = " desc " > APIs that store and retrieve data on the blockchain < / td > < / tr > <nl> + < tr id = " row_5_0_ " > < td class = " entry " > < span style = " width : 16px ; display : inline - block ; " > & # 160 ; < / span > < span id = " arr_5_0_ " class = " arrow " onclick = " toggleFolder ( ' 5_0_ ' ) " > & # 9660 ; < / span > < a class = " el " href = " group__database_c . html " target = " _self " > Database C API < / a > < / td > < td class = " desc " > C APIs for interfacing with the database < / td > < / tr > <nl> + < tr id = " row_5_0_0_ " class = " even " > < td class = " entry " > < span style = " width : 48px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__dbi64 . html " target = " _self " > Single 64 bit Index table < / a > < / td > < td class = " desc " > These methods interface with a simple table with 64 bit unique primary key and arbitrary binary data value < / td > < / tr > <nl> + < tr id = " row_5_0_1_ " > < td class = " entry " > < span style = " width : 48px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__dbstr . html " target = " _self " > Single String Index table < / a > < / td > < td class = " desc " > These methods interface with a simple table with String unique primary key and arbitrary binary data value < / td > < / tr > <nl> + < tr id = " row_5_0_2_ " class = " even " > < td class = " entry " > < span style = " width : 48px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__dbi128i128 . html " target = " _self " > Dual 128 bit Index table < / a > < / td > < td class = " desc " > Interface to a database table with 128 bit primary and secondary keys and arbitary binary data value < / td > < / tr > <nl> + < tr id = " row_5_0_3_ " > < td class = " entry " > < span style = " width : 48px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__dbi64i64i64 . html " target = " _self " > Triple 64 bit Index table < / a > < / td > < td class = " desc " > Interface to a database table with 64 bit primary , secondary and tertiary keys and arbitrary binary data value < / td > < / tr > <nl> + < tr id = " row_5_1_ " class = " even " > < td class = " entry " > < span style = " width : 16px ; display : inline - block ; " > & # 160 ; < / span > < span id = " arr_5_1_ " class = " arrow " onclick = " toggleFolder ( ' 5_1_ ' ) " > & # 9660 ; < / span > < a class = " el " href = " group__database_cpp . html " target = " _self " > Database C + + API < / a > < / td > < td class = " desc " > C + + APIs for interfacing with the database < / td > < / tr > <nl> + < tr id = " row_5_1_0_ " > < td class = " entry " > < span style = " width : 48px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__dual_index_table . html " target = " _self " > Dual Index table < / a > < / td > < td class = " desc " > Defines a type - safe C + + wrapper around the < a class = " el " href = " group__database_c . html " > Database C API < / a > < / td > < / tr > <nl> + < tr id = " row_5_1_1_ " class = " even " > < td class = " entry " > < span style = " width : 48px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group___singleindextable . html " target = " _self " > Single Index table < / a > < / td > < td class = " desc " > This specialization of table is for single - index tables < / td > < / tr > <nl> + < tr id = " row_6_ " > < td class = " entry " > < span style = " width : 16px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__fixed__point . html " target = " _self " > Template classes for Fixed Point representaton < / a > < / td > < td class = " desc " > 32 , 64 , 128 , 256 bits version of Fixed Point variables < / td > < / tr > <nl> + < tr id = " row_7_ " class = " even " > < td class = " entry " > < span style = " width : 16px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__fixed . html " target = " _self " > point Fixed Point generic class < / a > < / td > < td class = " desc " > Implementation of fixed point template class < / td > < / tr > <nl> + < tr id = " row_8_ " > < td class = " entry " > < span style = " width : 0px ; display : inline - block ; " > & # 160 ; < / span > < span id = " arr_8_ " class = " arrow " onclick = " toggleFolder ( ' 8_ ' ) " > & # 9660 ; < / span > < a class = " el " href = " group__mathapi . html " target = " _self " > Math API < / a > < / td > < td class = " desc " > Defines common math functions < / td > < / tr > <nl> + < tr id = " row_8_0_ " class = " even " > < td class = " entry " > < span style = " width : 32px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__mathcapi . html " target = " _self " > Math C API < / a > < / td > < td class = " desc " > Defines basic mathematical operations for higher abstractions to use < / td > < / tr > <nl> + < tr id = " row_8_1_ " > < td class = " entry " > < span style = " width : 32px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__mathcppapi . html " target = " _self " > Math C + + API < / a > < / td > < td class = " desc " > Defines common math functions and helper types < / td > < / tr > <nl> + < tr id = " row_9_ " class = " even " > < td class = " entry " > < span style = " width : 0px ; display : inline - block ; " > & # 160 ; < / span > < span id = " arr_9_ " class = " arrow " onclick = " toggleFolder ( ' 9_ ' ) " > & # 9660 ; < / span > < a class = " el " href = " group__memoryapi . html " target = " _self " > Memory API < / a > < / td > < td class = " desc " > Defines common memory functions < / td > < / tr > <nl> + < tr id = " row_9_0_ " > < td class = " entry " > < span style = " width : 32px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__memorycapi . html " target = " _self " > Memory C API < / a > < / td > < td class = " desc " > Defines common memory functions < / td > < / tr > <nl> + < tr id = " row_9_1_ " class = " even " > < td class = " entry " > < span style = " width : 32px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__memorycppapi . html " target = " _self " > Memory C + + API < / a > < / td > < td class = " desc " > Defines common memory functions < / td > < / tr > <nl> + < tr id = " row_10_ " > < td class = " entry " > < span style = " width : 0px ; display : inline - block ; " > & # 160 ; < / span > < span id = " arr_10_ " class = " arrow " onclick = " toggleFolder ( ' 10_ ' ) " > & # 9660 ; < / span > < a class = " el " href = " group__messageapi . html " target = " _self " > Message API < / a > < / td > < td class = " desc " > Define API for querying message properties < / td > < / tr > <nl> + < tr id = " row_10_0_ " class = " even " > < td class = " entry " > < span style = " width : 32px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__messagecapi . html " target = " _self " > message C API < / a > < / td > < td class = " desc " > Define API for querying message properties < / td > < / tr > <nl> + < tr id = " row_10_1_ " > < td class = " entry " > < span style = " width : 32px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__messagecppapi . html " target = " _self " > Message C + + API < / a > < / td > < td class = " desc " > Type - safe C + + wrapers for Message C API < / td > < / tr > <nl> + < tr id = " row_11_ " class = " even " > < td class = " entry " > < span style = " width : 0px ; display : inline - block ; " > & # 160 ; < / span > < span id = " arr_11_ " class = " arrow " onclick = " toggleFolder ( ' 11_ ' ) " > & # 9660 ; < / span > < a class = " el " href = " group__consoleapi . html " target = " _self " > Console API < / a > < / td > < td class = " desc " > Enables applications to log / print text messages < / td > < / tr > <nl> + < tr id = " row_11_0_ " > < td class = " entry " > < span style = " width : 32px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__consolecapi . html " target = " _self " > Console C API < / a > < / td > < td class = " desc " > < / td > < / tr > <nl> + < tr id = " row_11_1_ " class = " even " > < td class = " entry " > < span style = " width : 32px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__console_cppapi . html " target = " _self " > Console C + + API < / a > < / td > < td class = " desc " > C + + wrapper for Console C API < / td > < / tr > <nl> + < tr id = " row_12_ " > < td class = " entry " > < span style = " width : 16px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__eosiorpc . html " target = " _self " > RPC Interface < / a > < / td > < td class = " desc " > Describes how to interface with eosd over HTTP RPC < / td > < / tr > <nl> + < tr id = " row_13_ " class = " even " > < td class = " entry " > < span style = " width : 0px ; display : inline - block ; " > & # 160 ; < / span > < span id = " arr_13_ " class = " arrow " onclick = " toggleFolder ( ' 13_ ' ) " > & # 9660 ; < / span > < a class = " el " href = " group__systemapi . html " target = " _self " > System API < / a > < / td > < td class = " desc " > Define API for interating with system level intrinsics < / td > < / tr > <nl> + < tr id = " row_13_0_ " > < td class = " entry " > < span style = " width : 32px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__systemcapi . html " target = " _self " > System C API < / a > < / td > < td class = " desc " > Define API for interating with system level intrinsics < / td > < / tr > <nl> + < tr id = " row_14_ " class = " even " > < td class = " entry " > < span style = " width : 16px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__tokens . html " target = " _self " > Token API < / a > < / td > < td class = " desc " > Defines the ABI for interfacing with standard - compatible token messages and database tables < / td > < / tr > <nl> + < tr id = " row_15_ " > < td class = " entry " > < span style = " width : 0px ; display : inline - block ; " > & # 160 ; < / span > < span id = " arr_15_ " class = " arrow " onclick = " toggleFolder ( ' 15_ ' ) " > & # 9660 ; < / span > < a class = " el " href = " group__transactionapi . html " target = " _self " > Transaction API < / a > < / td > < td class = " desc " > Define API for sending transactions and inline messages < / td > < / tr > <nl> + < tr id = " row_15_0_ " class = " even " > < td class = " entry " > < span style = " width : 32px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__transactioncapi . html " target = " _self " > transaction C API < / a > < / td > < td class = " desc " > Define API for sending transactions < / td > < / tr > <nl> + < tr id = " row_15_1_ " > < td class = " entry " > < span style = " width : 32px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__transactioncppapi . html " target = " _self " > transaction C + + API < / a > < / td > < td class = " desc " > Type - safe C + + wrappers for transaction C API < / td > < / tr > <nl> + < tr id = " row_16_ " class = " even " > < td class = " entry " > < span style = " width : 16px ; display : inline - block ; " > & # 160 ; < / span > < a class = " el " href = " group__types . html " target = " _self " > Builtin Types < / a > < / td > < td class = " desc " > Specifies typedefs and aliases < / td > < / tr > <nl> < / table > <nl> < / div > < ! - - directory - - > <nl> < / div > < ! - - contents - - > <nl> mmm a / docs / namespace_t_o_k_e_n___n_a_m_e . html <nl> ppp b / docs / namespace_t_o_k_e_n___n_a_m_e . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / namespacedice . html <nl> ppp b / docs / namespacedice . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / namespaceexchange . html <nl> ppp b / docs / namespaceexchange . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / namespaceinfinite . html <nl> ppp b / docs / namespaceinfinite . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / namespacemembers . html <nl> ppp b / docs / namespacemembers . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / namespacemembers_func . html <nl> ppp b / docs / namespacemembers_func . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / namespacemembers_type . html <nl> ppp b / docs / namespacemembers_type . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / namespacemembers_vars . html <nl> ppp b / docs / namespacemembers_vars . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / namespacenative . html <nl> ppp b / docs / namespacenative . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / namespaceproxy . html <nl> ppp b / docs / namespaceproxy . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / namespaces . html <nl> ppp b / docs / namespaces . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / namespacetic__tac__toe . html <nl> ppp b / docs / namespacetic__tac__toe . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / pages . html <nl> ppp b / docs / pages . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / print_8h . html <nl> ppp b / docs / print_8h . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / print_8h_source . html <nl> ppp b / docs / print_8h_source . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / print_8hpp . html <nl> ppp b / docs / print_8hpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / print_8hpp_source . html <nl> ppp b / docs / print_8hpp_source . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / proxy_8cpp . html <nl> ppp b / docs / proxy_8cpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / proxy_8hpp . html <nl> ppp b / docs / proxy_8hpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / proxy_8hpp_source . html <nl> ppp b / docs / proxy_8hpp_source . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / rpc_8dox . html <nl> ppp b / docs / rpc_8dox . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / search / all_10 . js <nl> ppp b / docs / search / all_10 . js <nl> <nl> var searchData = <nl> [ <nl> + [ ' rpc_20interface ' , [ ' RPC Interface ' , [ ' . . / group__eosiorpc . html ' , 1 , ' ' ] ] ] , <nl> [ ' raw_2ehpp ' , [ ' raw . hpp ' , [ ' . . / raw_8hpp . html ' , 1 , ' ' ] ] ] , <nl> [ ' raw_5ffwd_2ehpp ' , [ ' raw_fwd . hpp ' , [ ' . . / raw__fwd_8hpp . html ' , 1 , ' ' ] ] ] , <nl> [ ' read ' , [ ' read ' , [ ' . . / classeosio_1_1datastream . html # ae1d8d46d5cf80745bbb00a6b8fee243a ' , 1 , ' eosio : : datastream ' ] ] ] , <nl> mmm a / docs / search / all_12 . js <nl> ppp b / docs / search / all_12 . js <nl> var searchData = <nl> [ ' transaction_5fhandle ' , [ ' transaction_handle ' , [ ' . . / group__transactioncapi . html # gaab096f894fc4b848e8bf87fa82535f4c ' , 1 , ' transaction . h ' ] ] ] , <nl> [ ' transaction_5frequire_5fscope ' , [ ' transaction_require_scope ' , [ ' . . / group__transactioncapi . html # gadbeefdb977e06363af03ada627ca18b4 ' , 1 , ' transaction . h ' ] ] ] , <nl> [ ' transaction_5fsend ' , [ ' transaction_send ' , [ ' . . / group__transactioncapi . html # ga91eadf9af6a7bceae96e7c798776f9b9 ' , 1 , ' transaction . h ' ] ] ] , <nl> - [ ' transaction_20api ' , [ ' transaction API ' , [ ' . . / group__transactionapi . html ' , 1 , ' ' ] ] ] , <nl> + [ ' transaction_20api ' , [ ' Transaction API ' , [ ' . . / group__transactionapi . html ' , 1 , ' ' ] ] ] , <nl> [ ' transaction_20c_20api ' , [ ' transaction C API ' , [ ' . . / group__transactioncapi . html ' , 1 , ' ' ] ] ] , <nl> [ ' transaction_20c_2b_2b_20api ' , [ ' transaction C + + API ' , [ ' . . / group__transactioncppapi . html ' , 1 , ' ' ] ] ] , <nl> [ ' transfer ' , [ ' transfer ' , [ ' . . / struct_t_o_k_e_n___n_a_m_e_1_1transfer . html ' , 1 , ' TOKEN_NAME : : transfer ' ] , [ ' . . / structinfinite_1_1transfer . html ' , 1 , ' infinite : : transfer ' ] , [ ' . . / structeosio_1_1transfer . html ' , 1 , ' eosio : : transfer ' ] , [ ' . . / structnative_1_1eos . html # a431e5dbd7faeb5dee21978d48126f197 ' , 1 , ' native : : eos : : transfer ( ) ' ] ] ] , <nl> mmm a / docs / search / all_2 . js <nl> ppp b / docs / search / all_2 . js <nl> var searchData = <nl> [ ' construct_5fwith_5fdata_5fpartially ' , [ ' construct_with_data_partially ' , [ ' . . / structtest__string . html # ac24a5db094956d97086947b306179107 ' , 1 , ' test_string ' ] ] ] , <nl> [ ' construct_5fwith_5fsize ' , [ ' construct_with_size ' , [ ' . . / structtest__string . html # af463e5d41672359e74b685ff7af34a02 ' , 1 , ' test_string ' ] ] ] , <nl> [ ' contract ' , [ ' contract ' , [ ' . . / structnative_1_1contract . html ' , 1 , ' native ' ] ] ] , <nl> - [ ' contracts_2edox ' , [ ' contracts . dox ' , [ ' . . / contracts_8dox . html ' , 1 , ' ' ] ] ] , <nl> [ ' copy_5fconstructor ' , [ ' copy_constructor ' , [ ' . . / structtest__string . html # a73ec8baa3460858dadeb60497865186d ' , 1 , ' test_string ' ] ] ] , <nl> [ ' create ' , [ ' create ' , [ ' . . / structtic__tac__toe_1_1create . html ' , 1 , ' tic_tac_toe ' ] ] ] , <nl> [ ' create_5finstances ' , [ ' create_instances ' , [ ' . . / structtest__fixedpoint . html # a852f2dd4018f32d6f8cd947e624d2133 ' , 1 , ' test_fixedpoint : : create_instances ( ) ' ] , [ ' . . / structtest__real . html # aca579342d00f60a8401dc397badd0d5a ' , 1 , ' test_real : : create_instances ( ) ' ] ] ] , <nl> mmm a / docs / search / all_4 . js <nl> ppp b / docs / search / all_4 . js <nl> var searchData = <nl> [ ' eos_2ehpp ' , [ ' eos . hpp ' , [ ' . . / eos_8hpp . html ' , 1 , ' ' ] ] ] , <nl> [ ' eos_5fsymbol ' , [ ' EOS_SYMBOL ' , [ ' . . / test__account_8cpp . html # ad13c26904f5934423eb89fdcf52c4c40 ' , 1 , ' test_account . cpp ' ] ] ] , <nl> [ ' eos_5ftokens ' , [ ' eos_tokens ' , [ ' . . / namespacedice . html # a4ae1a0587cb1215cd3f3f8b64fbd3761 ' , 1 , ' dice : : eos_tokens ( ) ' ] , [ ' . . / namespaceexchange . html # aba2864a28e50db2eb847731636ae9132 ' , 1 , ' exchange : : eos_tokens ( ) ' ] ] ] , <nl> - [ ' eos_5fwalletd_2edox ' , [ ' eos_walletd . dox ' , [ ' . . / eos__walletd_8dox . html ' , 1 , ' ' ] ] ] , <nl> - [ ' eos_20command_20line_20client_20_28eosc_29 ' , [ ' EOS Command Line Client ( eosc ) ' , [ ' . . / group__eosc . html ' , 1 , ' ' ] ] ] , <nl> - [ ' eosc_2edox ' , [ ' eosc . dox ' , [ ' . . / eosc_8dox . html ' , 1 , ' ' ] ] ] , <nl> [ ' eos_20contract ' , [ ' EOS Contract ' , [ ' . . / group__eoscontract . html ' , 1 , ' ' ] ] ] , <nl> [ ' eosio ' , [ ' eosio ' , [ ' . . / namespaceeosio . html ' , 1 , ' ' ] ] ] , <nl> - [ ' eosd_20rpc_20interface ' , [ ' eosd RPC Interface ' , [ ' . . / group__eosiorpc . html ' , 1 , ' ' ] ] ] , <nl> - [ ' eos_20wallet_20process_20_28eos_2dwalletd_29 ' , [ ' EOS Wallet Process ( eos - walletd ) ' , [ ' . . / group__eoswallet . html ' , 1 , ' ' ] ] ] , <nl> [ ' example_20contract ' , [ ' Example Contract ' , [ ' . . / group__examplecontract . html ' , 1 , ' ' ] ] ] , <nl> [ ' exchange ' , [ ' exchange ' , [ ' . . / namespaceexchange . html ' , 1 , ' ' ] ] ] , <nl> [ ' exchange_2ecpp ' , [ ' exchange . cpp ' , [ ' . . / exchange_8cpp . html ' , 1 , ' ' ] ] ] , <nl> mmm a / docs / search / all_7 . js <nl> ppp b / docs / search / all_7 . js <nl> <nl> var searchData = <nl> [ <nl> - [ ' how_20to_20write_20contracts ' , [ ' How To Write Contracts ' , [ ' . . / group__contractdev . html ' , 1 , ' ' ] ] ] , <nl> [ ' hash ' , [ ' hash ' , [ ' . . / structchecksum . html # ab4c89af532fcca9243fd58b8d3ea4fc2 ' , 1 , ' checksum ' ] ] ] , <nl> - [ ' host ' , [ ' host ' , [ ' . . / structtic__tac__toe_1_1create . html # ab8e7f2c676fe265e0484aa31763c2158 ' , 1 , ' tic_tac_toe : : create : : host ( ) ' ] , [ ' . . / structtic__tac__toe_1_1restart . html # ac60a6db5e59d93c09072308e0def074e ' , 1 , ' tic_tac_toe : : restart : : host ( ) ' ] , [ ' . . / structtic__tac__toe_1_1close . html # a1bbf00013c720755a34fb2ab9c870262 ' , 1 , ' tic_tac_toe : : close : : host ( ) ' ] , [ ' . . / structtic__tac__toe_1_1move . html # a74445a23dac04595342a9a5e910cf261 ' , 1 , ' tic_tac_toe : : move : : host ( ) ' ] ] ] , <nl> - [ ' howto_5fbuild_2edox ' , [ ' howto_build . dox ' , [ ' . . / howto__build_8dox . html ' , 1 , ' ' ] ] ] , <nl> - [ ' how_20to_20build_20eos_2eio ' , [ ' How To Build EOS . IO ' , [ ' . . / group__howtobuild . html ' , 1 , ' ' ] ] ] <nl> + [ ' host ' , [ ' host ' , [ ' . . / structtic__tac__toe_1_1create . html # ab8e7f2c676fe265e0484aa31763c2158 ' , 1 , ' tic_tac_toe : : create : : host ( ) ' ] , [ ' . . / structtic__tac__toe_1_1restart . html # ac60a6db5e59d93c09072308e0def074e ' , 1 , ' tic_tac_toe : : restart : : host ( ) ' ] , [ ' . . / structtic__tac__toe_1_1close . html # a1bbf00013c720755a34fb2ab9c870262 ' , 1 , ' tic_tac_toe : : close : : host ( ) ' ] , [ ' . . / structtic__tac__toe_1_1move . html # a74445a23dac04595342a9a5e910cf261 ' , 1 , ' tic_tac_toe : : move : : host ( ) ' ] ] ] <nl> ] ; <nl> mmm a / docs / search / all_b . js <nl> ppp b / docs / search / all_b . js <nl> var searchData = <nl> [ ' message_5frequire_5fpermission ' , [ ' message_require_permission ' , [ ' . . / group__transactioncapi . html # ga991711ff7c3569a3d3c6cd73dfe61420 ' , 1 , ' transaction . h ' ] ] ] , <nl> [ ' message_5fsend ' , [ ' message_send ' , [ ' . . / group__transactioncapi . html # gad76e0f13f4df1c6687f0eaea6379bd00 ' , 1 , ' transaction . h ' ] ] ] , <nl> [ ' message_5fsize ' , [ ' message_size ' , [ ' . . / group__messagecapi . html # ga4ebf6b7927fc900ae1fa8e06ceb5a16b ' , 1 , ' message . h ' ] ] ] , <nl> - [ ' message_20api ' , [ ' message API ' , [ ' . . / group__messageapi . html ' , 1 , ' ' ] ] ] , <nl> + [ ' message_20api ' , [ ' Message API ' , [ ' . . / group__messageapi . html ' , 1 , ' ' ] ] ] , <nl> [ ' message_20c_20api ' , [ ' message C API ' , [ ' . . / group__messagecapi . html ' , 1 , ' ' ] ] ] , <nl> [ ' message_20c_2b_2b_20api ' , [ ' Message C + + API ' , [ ' . . / group__messagecppapi . html ' , 1 , ' ' ] ] ] , <nl> [ ' min ' , [ ' min ' , [ ' . . / group__mathcppapi . html # gac459e1d6c24d9178441fed9163accc79 ' , 1 , ' eosio ' ] ] ] , <nl> mmm a / docs / search / files_1 . js <nl> ppp b / docs / search / files_1 . js <nl> <nl> var searchData = <nl> [ <nl> [ ' chain_2eh ' , [ ' chain . h ' , [ ' . . / chain_8h . html ' , 1 , ' ' ] ] ] , <nl> - [ ' contracts_2edox ' , [ ' contracts . dox ' , [ ' . . / contracts_8dox . html ' , 1 , ' ' ] ] ] , <nl> [ ' crypto_2eh ' , [ ' crypto . h ' , [ ' . . / crypto_8h . html ' , 1 , ' ' ] ] ] , <nl> [ ' currency_2ecpp ' , [ ' currency . cpp ' , [ ' . . / currency_8cpp . html ' , 1 , ' ' ] ] ] , <nl> [ ' currency_2ehpp ' , [ ' currency . hpp ' , [ ' . . / currency_8hpp . html ' , 1 , ' ' ] ] ] , <nl> mmm a / docs / search / files_3 . js <nl> ppp b / docs / search / files_3 . js <nl> var searchData = <nl> [ <nl> [ ' eos_2ecpp ' , [ ' eos . cpp ' , [ ' . . / eos_8cpp . html ' , 1 , ' ' ] ] ] , <nl> [ ' eos_2ehpp ' , [ ' eos . hpp ' , [ ' . . / eos_8hpp . html ' , 1 , ' ' ] ] ] , <nl> - [ ' eos_5fwalletd_2edox ' , [ ' eos_walletd . dox ' , [ ' . . / eos__walletd_8dox . html ' , 1 , ' ' ] ] ] , <nl> - [ ' eosc_2edox ' , [ ' eosc . dox ' , [ ' . . / eosc_8dox . html ' , 1 , ' ' ] ] ] , <nl> [ ' exchange_2ecpp ' , [ ' exchange . cpp ' , [ ' . . / exchange_8cpp . html ' , 1 , ' ' ] ] ] , <nl> [ ' exchange_2ehpp ' , [ ' exchange . hpp ' , [ ' . . / exchange_8hpp . html ' , 1 , ' ' ] ] ] , <nl> [ ' exchange_2ewast_2ehpp ' , [ ' exchange . wast . hpp ' , [ ' . . / exchange_8wast_8hpp . html ' , 1 , ' ' ] ] ] <nl> mmm a / docs / search / files_5 . js <nl> ppp b / docs / search / files_5 . js <nl> <nl> var searchData = <nl> [ <nl> - [ ' howto_5fbuild_2edox ' , [ ' howto_build . dox ' , [ ' . . / howto__build_8dox . html ' , 1 , ' ' ] ] ] <nl> + [ ' infinite_2ecpp ' , [ ' infinite . cpp ' , [ ' . . / infinite_8cpp . html ' , 1 , ' ' ] ] ] , <nl> + [ ' infinite_2ehpp ' , [ ' infinite . hpp ' , [ ' . . / infinite_8hpp . html ' , 1 , ' ' ] ] ] , <nl> + [ ' infinite_2ewast_2ehpp ' , [ ' infinite . wast . hpp ' , [ ' . . / infinite_8wast_8hpp . html ' , 1 , ' ' ] ] ] <nl> ] ; <nl> mmm a / docs / search / files_6 . js <nl> ppp b / docs / search / files_6 . js <nl> <nl> var searchData = <nl> [ <nl> - [ ' infinite_2ecpp ' , [ ' infinite . cpp ' , [ ' . . / infinite_8cpp . html ' , 1 , ' ' ] ] ] , <nl> - [ ' infinite_2ehpp ' , [ ' infinite . hpp ' , [ ' . . / infinite_8hpp . html ' , 1 , ' ' ] ] ] , <nl> - [ ' infinite_2ewast_2ehpp ' , [ ' infinite . wast . hpp ' , [ ' . . / infinite_8wast_8hpp . html ' , 1 , ' ' ] ] ] <nl> + [ ' mainpage_2emd ' , [ ' mainpage . md ' , [ ' . . / mainpage_8md . html ' , 1 , ' ' ] ] ] , <nl> + [ ' malicious_2ewast_2ehpp ' , [ ' malicious . wast . hpp ' , [ ' . . / malicious_8wast_8hpp . html ' , 1 , ' ' ] ] ] , <nl> + [ ' math_2eh ' , [ ' math . h ' , [ ' . . / math_8h . html ' , 1 , ' ' ] ] ] , <nl> + [ ' math_2ehpp ' , [ ' math . hpp ' , [ ' . . / math_8hpp . html ' , 1 , ' ' ] ] ] , <nl> + [ ' memory_2eh ' , [ ' memory . h ' , [ ' . . / memory_8h . html ' , 1 , ' ' ] ] ] , <nl> + [ ' memory_2ehpp ' , [ ' memory . hpp ' , [ ' . . / memory_8hpp . html ' , 1 , ' ' ] ] ] , <nl> + [ ' message_2eh ' , [ ' message . h ' , [ ' . . / message_8h . html ' , 1 , ' ' ] ] ] , <nl> + [ ' message_2ehpp ' , [ ' message . hpp ' , [ ' . . / message_8hpp . html ' , 1 , ' ' ] ] ] <nl> ] ; <nl> mmm a / docs / search / files_7 . js <nl> ppp b / docs / search / files_7 . js <nl> <nl> var searchData = <nl> [ <nl> - [ ' mainpage_2emd ' , [ ' mainpage . md ' , [ ' . . / mainpage_8md . html ' , 1 , ' ' ] ] ] , <nl> - [ ' malicious_2ewast_2ehpp ' , [ ' malicious . wast . hpp ' , [ ' . . / malicious_8wast_8hpp . html ' , 1 , ' ' ] ] ] , <nl> - [ ' math_2eh ' , [ ' math . h ' , [ ' . . / math_8h . html ' , 1 , ' ' ] ] ] , <nl> - [ ' math_2ehpp ' , [ ' math . hpp ' , [ ' . . / math_8hpp . html ' , 1 , ' ' ] ] ] , <nl> - [ ' memory_2eh ' , [ ' memory . h ' , [ ' . . / memory_8h . html ' , 1 , ' ' ] ] ] , <nl> - [ ' memory_2ehpp ' , [ ' memory . hpp ' , [ ' . . / memory_8hpp . html ' , 1 , ' ' ] ] ] , <nl> - [ ' message_2eh ' , [ ' message . h ' , [ ' . . / message_8h . html ' , 1 , ' ' ] ] ] , <nl> - [ ' message_2ehpp ' , [ ' message . hpp ' , [ ' . . / message_8hpp . html ' , 1 , ' ' ] ] ] <nl> + [ ' print_2eh ' , [ ' print . h ' , [ ' . . / print_8h . html ' , 1 , ' ' ] ] ] , <nl> + [ ' print_2ehpp ' , [ ' print . hpp ' , [ ' . . / print_8hpp . html ' , 1 , ' ' ] ] ] , <nl> + [ ' proxy_2ecpp ' , [ ' proxy . cpp ' , [ ' . . / proxy_8cpp . html ' , 1 , ' ' ] ] ] , <nl> + [ ' proxy_2ehpp ' , [ ' proxy . hpp ' , [ ' . . / proxy_8hpp . html ' , 1 , ' ' ] ] ] , <nl> + [ ' proxy_2ewast_2ehpp ' , [ ' proxy . wast . hpp ' , [ ' . . / proxy_8wast_8hpp . html ' , 1 , ' ' ] ] ] <nl> ] ; <nl> mmm a / docs / search / files_8 . js <nl> ppp b / docs / search / files_8 . js <nl> <nl> var searchData = <nl> [ <nl> - [ ' print_2eh ' , [ ' print . h ' , [ ' . . / print_8h . html ' , 1 , ' ' ] ] ] , <nl> - [ ' print_2ehpp ' , [ ' print . hpp ' , [ ' . . / print_8hpp . html ' , 1 , ' ' ] ] ] , <nl> - [ ' proxy_2ecpp ' , [ ' proxy . cpp ' , [ ' . . / proxy_8cpp . html ' , 1 , ' ' ] ] ] , <nl> - [ ' proxy_2ehpp ' , [ ' proxy . hpp ' , [ ' . . / proxy_8hpp . html ' , 1 , ' ' ] ] ] , <nl> - [ ' proxy_2ewast_2ehpp ' , [ ' proxy . wast . hpp ' , [ ' . . / proxy_8wast_8hpp . html ' , 1 , ' ' ] ] ] <nl> + [ ' raw_2ehpp ' , [ ' raw . hpp ' , [ ' . . / raw_8hpp . html ' , 1 , ' ' ] ] ] , <nl> + [ ' raw_5ffwd_2ehpp ' , [ ' raw_fwd . hpp ' , [ ' . . / raw__fwd_8hpp . html ' , 1 , ' ' ] ] ] , <nl> + [ ' readme_2emd ' , [ ' README . md ' , [ ' . . / _r_e_a_d_m_e_8md . html ' , 1 , ' ' ] ] ] , <nl> + [ ' real_2ehpp ' , [ ' real . hpp ' , [ ' . . / real_8hpp . html ' , 1 , ' ' ] ] ] , <nl> + [ ' rpc_2edox ' , [ ' rpc . dox ' , [ ' . . / rpc_8dox . html ' , 1 , ' ' ] ] ] <nl> ] ; <nl> mmm a / docs / search / files_9 . js <nl> ppp b / docs / search / files_9 . js <nl> <nl> var searchData = <nl> [ <nl> - [ ' raw_2ehpp ' , [ ' raw . hpp ' , [ ' . . / raw_8hpp . html ' , 1 , ' ' ] ] ] , <nl> - [ ' raw_5ffwd_2ehpp ' , [ ' raw_fwd . hpp ' , [ ' . . / raw__fwd_8hpp . html ' , 1 , ' ' ] ] ] , <nl> - [ ' readme_2emd ' , [ ' README . md ' , [ ' . . / _r_e_a_d_m_e_8md . html ' , 1 , ' ' ] ] ] , <nl> - [ ' real_2ehpp ' , [ ' real . hpp ' , [ ' . . / real_8hpp . html ' , 1 , ' ' ] ] ] , <nl> - [ ' rpc_2edox ' , [ ' rpc . dox ' , [ ' . . / rpc_8dox . html ' , 1 , ' ' ] ] ] <nl> + [ ' simpledb_2ecpp ' , [ ' simpledb . cpp ' , [ ' . . / simpledb_8cpp . html ' , 1 , ' ' ] ] ] , <nl> + [ ' simpledb_2egen_2ehpp ' , [ ' simpledb . gen . hpp ' , [ ' . . / simpledb_8gen_8hpp . html ' , 1 , ' ' ] ] ] , <nl> + [ ' simpledb_2ehpp ' , [ ' simpledb . hpp ' , [ ' . . / simpledb_8hpp . html ' , 1 , ' ' ] ] ] , <nl> + [ ' simpledb_2ewast_2ehpp ' , [ ' simpledb . wast . hpp ' , [ ' . . / simpledb_8wast_8hpp . html ' , 1 , ' ' ] ] ] , <nl> + [ ' skeleton_2ecpp ' , [ ' skeleton . cpp ' , [ ' . . / skeleton_8cpp . html ' , 1 , ' ' ] ] ] , <nl> + [ ' skeleton_2ehpp ' , [ ' skeleton . hpp ' , [ ' . . / skeleton_8hpp . html ' , 1 , ' ' ] ] ] , <nl> + [ ' social_2ecpp ' , [ ' social . cpp ' , [ ' . . / social_8cpp . html ' , 1 , ' ' ] ] ] , <nl> + [ ' storage_2ecpp ' , [ ' storage . cpp ' , [ ' . . / storage_8cpp . html ' , 1 , ' ' ] ] ] , <nl> + [ ' storage_2ehpp ' , [ ' storage . hpp ' , [ ' . . / storage_8hpp . html ' , 1 , ' ' ] ] ] , <nl> + [ ' storage_2ewast_2ehpp ' , [ ' storage . wast . hpp ' , [ ' . . / storage_8wast_8hpp . html ' , 1 , ' ' ] ] ] , <nl> + [ ' string_2eh ' , [ ' string . h ' , [ ' . . / string_8h . html ' , 1 , ' ' ] ] ] , <nl> + [ ' string_2ehpp ' , [ ' string . hpp ' , [ ' . . / string_8hpp . html ' , 1 , ' ' ] ] ] , <nl> + [ ' system_2eh ' , [ ' system . h ' , [ ' . . / system_8h . html ' , 1 , ' ' ] ] ] <nl> ] ; <nl> mmm a / docs / search / groups_4 . js <nl> ppp b / docs / search / groups_4 . js <nl> <nl> var searchData = <nl> [ <nl> - [ ' eos_20command_20line_20client_20_28eosc_29 ' , [ ' EOS Command Line Client ( eosc ) ' , [ ' . . / group__eosc . html ' , 1 , ' ' ] ] ] , <nl> [ ' eos_20contract ' , [ ' EOS Contract ' , [ ' . . / group__eoscontract . html ' , 1 , ' ' ] ] ] , <nl> - [ ' eosd_20rpc_20interface ' , [ ' eosd RPC Interface ' , [ ' . . / group__eosiorpc . html ' , 1 , ' ' ] ] ] , <nl> - [ ' eos_20wallet_20process_20_28eos_2dwalletd_29 ' , [ ' EOS Wallet Process ( eos - walletd ) ' , [ ' . . / group__eoswallet . html ' , 1 , ' ' ] ] ] , <nl> [ ' example_20contract ' , [ ' Example Contract ' , [ ' . . / group__examplecontract . html ' , 1 , ' ' ] ] ] <nl> ] ; <nl> mmm a / docs / search / groups_5 . js <nl> ppp b / docs / search / groups_5 . js <nl> <nl> var searchData = <nl> [ <nl> - [ ' how_20to_20write_20contracts ' , [ ' How To Write Contracts ' , [ ' . . / group__contractdev . html ' , 1 , ' ' ] ] ] , <nl> - [ ' how_20to_20build_20eos_2eio ' , [ ' How To Build EOS . IO ' , [ ' . . / group__howtobuild . html ' , 1 , ' ' ] ] ] <nl> + [ ' math_20api ' , [ ' Math API ' , [ ' . . / group__mathapi . html ' , 1 , ' ' ] ] ] , <nl> + [ ' math_20c_20api ' , [ ' Math C API ' , [ ' . . / group__mathcapi . html ' , 1 , ' ' ] ] ] , <nl> + [ ' math_20c_2b_2b_20api ' , [ ' Math C + + API ' , [ ' . . / group__mathcppapi . html ' , 1 , ' ' ] ] ] , <nl> + [ ' memory_20api ' , [ ' Memory API ' , [ ' . . / group__memoryapi . html ' , 1 , ' ' ] ] ] , <nl> + [ ' memory_20c_20api ' , [ ' Memory C API ' , [ ' . . / group__memorycapi . html ' , 1 , ' ' ] ] ] , <nl> + [ ' memory_20c_2b_2b_20api ' , [ ' Memory C + + API ' , [ ' . . / group__memorycppapi . html ' , 1 , ' ' ] ] ] , <nl> + [ ' message_20api ' , [ ' Message API ' , [ ' . . / group__messageapi . html ' , 1 , ' ' ] ] ] , <nl> + [ ' message_20c_20api ' , [ ' message C API ' , [ ' . . / group__messagecapi . html ' , 1 , ' ' ] ] ] , <nl> + [ ' message_20c_2b_2b_20api ' , [ ' Message C + + API ' , [ ' . . / group__messagecppapi . html ' , 1 , ' ' ] ] ] <nl> ] ; <nl> mmm a / docs / search / groups_6 . js <nl> ppp b / docs / search / groups_6 . js <nl> <nl> var searchData = <nl> [ <nl> - [ ' math_20api ' , [ ' Math API ' , [ ' . . / group__mathapi . html ' , 1 , ' ' ] ] ] , <nl> - [ ' math_20c_20api ' , [ ' Math C API ' , [ ' . . / group__mathcapi . html ' , 1 , ' ' ] ] ] , <nl> - [ ' math_20c_2b_2b_20api ' , [ ' Math C + + API ' , [ ' . . / group__mathcppapi . html ' , 1 , ' ' ] ] ] , <nl> - [ ' memory_20api ' , [ ' Memory API ' , [ ' . . / group__memoryapi . html ' , 1 , ' ' ] ] ] , <nl> - [ ' memory_20c_20api ' , [ ' Memory C API ' , [ ' . . / group__memorycapi . html ' , 1 , ' ' ] ] ] , <nl> - [ ' memory_20c_2b_2b_20api ' , [ ' Memory C + + API ' , [ ' . . / group__memorycppapi . html ' , 1 , ' ' ] ] ] , <nl> - [ ' message_20api ' , [ ' message API ' , [ ' . . / group__messageapi . html ' , 1 , ' ' ] ] ] , <nl> - [ ' message_20c_20api ' , [ ' message C API ' , [ ' . . / group__messagecapi . html ' , 1 , ' ' ] ] ] , <nl> - [ ' message_20c_2b_2b_20api ' , [ ' Message C + + API ' , [ ' . . / group__messagecppapi . html ' , 1 , ' ' ] ] ] <nl> + [ ' point_20fixed_20point_20generic_20class ' , [ ' point Fixed Point generic class ' , [ ' . . / group__fixed . html ' , 1 , ' ' ] ] ] <nl> ] ; <nl> mmm a / docs / search / groups_7 . js <nl> ppp b / docs / search / groups_7 . js <nl> <nl> var searchData = <nl> [ <nl> - [ ' point_20fixed_20point_20generic_20class ' , [ ' point Fixed Point generic class ' , [ ' . . / group__fixed . html ' , 1 , ' ' ] ] ] <nl> + [ ' rpc_20interface ' , [ ' RPC Interface ' , [ ' . . / group__eosiorpc . html ' , 1 , ' ' ] ] ] <nl> ] ; <nl> mmm a / docs / search / searchdata . js <nl> ppp b / docs / search / searchdata . js <nl> var indexSectionsWithContent = <nl> 0 : " abcdefghiklmnopqrstuvw ~ " , <nl> 1 : " abcdefikmnoprstuv " , <nl> 2 : " deinpt " , <nl> - 3 : " acdefhimprstv " , <nl> + 3 : " acdefimprstv " , <nl> 4 : " abcdfgiklmnoprstuvw ~ " , <nl> 5 : " abcdefghiklmnopqrstuvw " , <nl> 6 : " abcefgimopqstu " , <nl> 7 : " fmort " , <nl> 8 : " bcdeflnpstuw " , <nl> - 9 : " abcdehmpst " , <nl> + 9 : " abcdemprst " , <nl> 10 : " dw " <nl> } ; <nl> <nl> mmm a / docs / simpledb_8cpp . html <nl> ppp b / docs / simpledb_8cpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / simpledb_8hpp . html <nl> ppp b / docs / simpledb_8hpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / simpledb_8hpp_source . html <nl> ppp b / docs / simpledb_8hpp_source . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / simpledb_8wast_8hpp . html <nl> ppp b / docs / simpledb_8wast_8hpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / simpledb_8wast_8hpp_source . html <nl> ppp b / docs / simpledb_8wast_8hpp_source . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / skeleton_8cpp . html <nl> ppp b / docs / skeleton_8cpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / skeleton_8hpp . html <nl> ppp b / docs / skeleton_8hpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / skeleton_8hpp_source . html <nl> ppp b / docs / skeleton_8hpp_source . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / social_8cpp . html <nl> ppp b / docs / social_8cpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / storage_8cpp . html <nl> ppp b / docs / storage_8cpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / storage_8hpp . html <nl> ppp b / docs / storage_8hpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / storage_8hpp_source . html <nl> ppp b / docs / storage_8hpp_source . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / string_8hpp . html <nl> ppp b / docs / string_8hpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / string_8hpp_source . html <nl> ppp b / docs / string_8hpp_source . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / struct_test_model128x2 - members . html <nl> ppp b / docs / struct_test_model128x2 - members . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / struct_test_model128x2 . html <nl> ppp b / docs / struct_test_model128x2 . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / struct_test_model128x2___v2 - members . html <nl> ppp b / docs / struct_test_model128x2___v2 - members . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / struct_test_model128x2___v2 . html <nl> ppp b / docs / struct_test_model128x2___v2 . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / struct_test_model3xi64 - members . html <nl> ppp b / docs / struct_test_model3xi64 - members . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / struct_test_model3xi64 . html <nl> ppp b / docs / struct_test_model3xi64 . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / struct_test_model3xi64___v2 - members . html <nl> ppp b / docs / struct_test_model3xi64___v2 - members . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / struct_test_model3xi64___v2 . html <nl> ppp b / docs / struct_test_model3xi64___v2 . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / structdummy__message - members . html <nl> ppp b / docs / structdummy__message - members . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / structdummy__message . html <nl> ppp b / docs / structdummy__message . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / structnative_1_1contract - members . html <nl> ppp b / docs / structnative_1_1contract - members . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / structnative_1_1contract . html <nl> ppp b / docs / structnative_1_1contract . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / structnative_1_1eos . html <nl> ppp b / docs / structnative_1_1eos . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / structtest__chain - members . html <nl> ppp b / docs / structtest__chain - members . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / structtest__chain . html <nl> ppp b / docs / structtest__chain . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / structtest__crypto - members . html <nl> ppp b / docs / structtest__crypto - members . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / structtest__crypto . html <nl> ppp b / docs / structtest__crypto . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / structtest__db - members . html <nl> ppp b / docs / structtest__db - members . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / structtest__db . html <nl> ppp b / docs / structtest__db . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / structtest__math - members . html <nl> ppp b / docs / structtest__math - members . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / structtest__math . html <nl> ppp b / docs / structtest__math . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / structtest__message - members . html <nl> ppp b / docs / structtest__message - members . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / structtest__message . html <nl> ppp b / docs / structtest__message . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / structtest__print - members . html <nl> ppp b / docs / structtest__print - members . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / structtest__print . html <nl> ppp b / docs / structtest__print . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / structtest__string - members . html <nl> ppp b / docs / structtest__string - members . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / structtest__string . html <nl> ppp b / docs / structtest__string . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / structtest__transaction - members . html <nl> ppp b / docs / structtest__transaction - members . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / structtest__transaction . html <nl> ppp b / docs / structtest__transaction . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / structtest__types - members . html <nl> ppp b / docs / structtest__types - members . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / structtest__types . html <nl> ppp b / docs / structtest__types . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / structu128__msg - members . html <nl> ppp b / docs / structu128__msg - members . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / structu128__msg . html <nl> ppp b / docs / structu128__msg . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / structuint256 - members . html <nl> ppp b / docs / structuint256 - members . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / structuint256 . html <nl> ppp b / docs / structuint256 . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> <nl> < a href = " # pub - attribs " > Public Attributes < / a > & # 124 ; <nl> < a href = " structuint256 - members . html " > List of all members < / a > < / div > <nl> < div class = " headertitle " > <nl> - < div class = " title " > uint256 Struct Reference < div class = " ingroups " > < a class = " el " href = " group__contractdev . html " > How To Write Contracts < / a > & raquo ; < a class = " el " href = " group__types . html " > Builtin Types < / a > < / div > < / div > < / div > <nl> + < div class = " title " > uint256 Struct Reference < div class = " ingroups " > < a class = " el " href = " group__types . html " > Builtin Types < / a > < / div > < / div > < / div > <nl> < / div > < ! - - header - - > <nl> < div class = " contents " > <nl> <nl> mmm a / docs / system_8h . html <nl> ppp b / docs / system_8h . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / system_8h_source . html <nl> ppp b / docs / system_8h_source . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / test__api_8cpp . html <nl> ppp b / docs / test__api_8cpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / test__api_8hpp . html <nl> ppp b / docs / test__api_8hpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / test__api_8hpp_source . html <nl> ppp b / docs / test__api_8hpp_source . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / test__api_8wast_8hpp . html <nl> ppp b / docs / test__api_8wast_8hpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / test__api_8wast_8hpp_source . html <nl> ppp b / docs / test__api_8wast_8hpp_source . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / test__chain_8cpp . html <nl> ppp b / docs / test__chain_8cpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / test__crypto_8cpp . html <nl> ppp b / docs / test__crypto_8cpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / test__db_8cpp . html <nl> ppp b / docs / test__db_8cpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / test__math_8cpp . html <nl> ppp b / docs / test__math_8cpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / test__message_8cpp . html <nl> ppp b / docs / test__message_8cpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / test__print_8cpp . html <nl> ppp b / docs / test__print_8cpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / test__string_8cpp . html <nl> ppp b / docs / test__string_8cpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / test__transaction_8cpp . html <nl> ppp b / docs / test__transaction_8cpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / test__types_8cpp . html <nl> ppp b / docs / test__types_8cpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / tic__tac__toe_8cpp . html <nl> ppp b / docs / tic__tac__toe_8cpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / tic__tac__toe_8hpp . html <nl> ppp b / docs / tic__tac__toe_8hpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / tic__tac__toe_8hpp_source . html <nl> ppp b / docs / tic__tac__toe_8hpp_source . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / token_8hpp . html <nl> ppp b / docs / token_8hpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / token_8hpp_source . html <nl> ppp b / docs / token_8hpp_source . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / transaction_8h . html <nl> ppp b / docs / transaction_8h . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / transaction_8h_source . html <nl> ppp b / docs / transaction_8h_source . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / transaction_8hpp . html <nl> ppp b / docs / transaction_8hpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / transaction_8hpp_source . html <nl> ppp b / docs / transaction_8hpp_source . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / tutorial_8md . html <nl> ppp b / docs / tutorial_8md . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / types_8h . html <nl> ppp b / docs / types_8h . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / types_8h_source . html <nl> ppp b / docs / types_8h_source . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / types_8hpp . html <nl> ppp b / docs / types_8hpp . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> mmm a / docs / types_8hpp_source . html <nl> ppp b / docs / types_8hpp_source . html <nl> <nl> < td id = " projectlogo " > < img alt = " Logo " src = " eos - logo . png " / > < / td > <nl> < td id = " projectalign " style = " padding - left : 0 . 5em ; " > <nl> < div id = " projectname " > EOS . IO <nl> - & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 0 < / span > <nl> + & # 160 ; < span id = " projectnumber " > DAWN2 . 0 . 1 < / span > <nl> < / div > <nl> < / td > <nl> < / tr > <nl> | Merge pull request from EOSIO / dox - v2 . 0 . 1 | EOSIO/eos | 941fa2fb611f6cc835dcb53276dffa0e5cc896a3 | 2017-12-14T01:46:18Z |
mmm a / hphp / hack / src / client / clientCheck . ml <nl> ppp b / hphp / hack / src / client / clientCheck . ml <nl> let main args = <nl> Exit_status . No_error <nl> | MODE_STATUS - > <nl> let ignore_ide = ClientMessages . ignore_ide_from args . from in <nl> + if args . prechecked = Some false then rpc args ( Rpc . NO_PRECHECKED_FILES ) ; <nl> let status = rpc args ( Rpc . STATUS ignore_ide ) in <nl> ClientCheckStatus . go status args . output_json args . from <nl> | MODE_STATUS_SINGLE filename - > <nl> mmm a / hphp / hack / src / server / serverCommand . ml <nl> ppp b / hphp / hack / src / server / serverCommand . ml <nl> let rpc_command_needs_full_check : type a . a t - > bool = <nl> | RETRIEVE_CHECKPOINT _ - > true <nl> | DELETE_CHECKPOINT _ - > true <nl> | IN_MEMORY_DEP_TABLE_SIZE - > true <nl> + | NO_PRECHECKED_FILES - > true <nl> | STATS - > false <nl> | DISCONNECT - > false <nl> | STATUS_SINGLE _ - > false <nl> mmm a / hphp / hack / src / server / serverCommandTypes . ml <nl> ppp b / hphp / hack / src / server / serverCommandTypes . ml <nl> type _ t = <nl> | RAGE : ServerRageTypes . result t <nl> | DYNAMIC_VIEW : bool - > unit t <nl> | CST_SEARCH : cst_search_input - > ( Hh_json . json , string ) result t <nl> + | NO_PRECHECKED_FILES : unit t <nl> <nl> let is_disconnect_rpc : type a . a t - > bool = function <nl> | DISCONNECT - > true <nl> mmm a / hphp / hack / src / server / serverCommandTypesUtils . ml <nl> ppp b / hphp / hack / src / server / serverCommandTypesUtils . ml <nl> let debug_describe_t : type a . a t - > string = function <nl> | RAGE - > " RAGE " <nl> | DYNAMIC_VIEW _ - > " DYNAMIC_VIEW " <nl> | CST_SEARCH _ - > " CST_SEARCH " <nl> + | NO_PRECHECKED_FILES - > " NO_PRECHECKED_FILES " <nl> <nl> let debug_describe_cmd : type a . a command - > string = function <nl> | Rpc rpc - > debug_describe_t rpc <nl> mmm a / hphp / hack / src / server / serverPrecheckedFiles . ml <nl> ppp b / hphp / hack / src / server / serverPrecheckedFiles . ml <nl> let update_after_local_changes env changes = <nl> dirty_master_deps ; <nl> clean_local_deps ; <nl> } ) <nl> + <nl> + let expand_all env = <nl> + match env . prechecked_files with <nl> + | Prechecked_files_disabled - > env <nl> + | Initial_typechecking dirty_deps <nl> + | Prechecked_files_ready dirty_deps - > <nl> + let deps = Typing_deps . add_all_deps dirty_deps . dirty_master_deps in <nl> + let needs_recheck = Typing_deps . get_files deps in <nl> + let needs_recheck = <nl> + Relative_path . Set . diff needs_recheck dirty_deps . rechecked_files in <nl> + let env = if Relative_path . Set . is_empty needs_recheck then env else begin <nl> + Hh_logger . log " Adding % d files to recheck after expanding all master deps " <nl> + ( Relative_path . Set . cardinal needs_recheck ) ; <nl> + let needs_recheck = <nl> + Relative_path . Set . union env . needs_recheck needs_recheck in <nl> + { env with <nl> + needs_recheck ; <nl> + full_check = Full_check_started ; <nl> + } <nl> + end in <nl> + set env ( Prechecked_files_ready { dirty_deps with <nl> + dirty_master_deps = Typing_deps . DepSet . empty ; <nl> + } ) <nl> mmm a / hphp / hack / src / server / serverPrecheckedFiles . mli <nl> ppp b / hphp / hack / src / server / serverPrecheckedFiles . mli <nl> <nl> <nl> val should_use : ServerArgs . options - > ServerLocalConfig . t - > bool <nl> <nl> + val expand_all : ServerEnv . env - > ServerEnv . env <nl> + <nl> val set : <nl> ServerEnv . env - > ServerEnv . prechecked_files_status - > ServerEnv . env <nl> <nl> mmm a / hphp / hack / src / server / serverRpc . ml <nl> ppp b / hphp / hack / src / server / serverRpc . ml <nl> let handle : type a . genv - > env - > is_stale : bool - > a t - > env * a = <nl> env . tcopt env . popt class_name meth_name <nl> end <nl> | CST_SEARCH { sort_results ; input ; files_to_search } - > <nl> - try <nl> + begin try <nl> env , CstSearchService . go genv ~ sort_results ~ files_to_search input <nl> with <nl> | MultiThreadedCall . Coalesced_failures failures - > <nl> let handle : type a . genv - > env - > is_stale : bool - > a t - > env * a = <nl> let msg = Printexc . to_string e in <nl> let stack = Printexc . get_backtrace ( ) in <nl> env , Error ( Printf . sprintf " % s \ n % s " msg stack ) <nl> + end <nl> + | NO_PRECHECKED_FILES - > <nl> + ServerPrecheckedFiles . expand_all env , ( ) <nl> mmm a / hphp / hack / test / integration_ml / saved_state / test_prechecked_basic . ml <nl> ppp b / hphp / hack / test / integration_ml / saved_state / test_prechecked_basic . ml <nl> <nl> + open Integration_test_base_types <nl> + <nl> module Test = Integration_test_base <nl> ( * Simplest prechecked files scenario : master and local changes are completely <nl> * independent , and there is no incremental mode involved . * ) <nl> File " / c . php " , line 2 , characters 15 - 20 : <nl> It is incompatible with a string <nl> | } <nl> <nl> + let all_errors = { | <nl> + File " / b . php " , line 2 , characters 28 - 30 : <nl> + Invalid return type ( Typing [ 4110 ] ) <nl> + File " / b . php " , line 2 , characters 15 - 17 : <nl> + This is an int <nl> + File " / a . php " , line 2 , characters 15 - 20 : <nl> + It is incompatible with a string <nl> + <nl> + File " / d . php " , line 2 , characters 28 - 30 : <nl> + Invalid return type ( Typing [ 4110 ] ) <nl> + File " / d . php " , line 2 , characters 15 - 17 : <nl> + This is an int <nl> + File " / c . php " , line 2 , characters 15 - 20 : <nl> + It is incompatible with a string <nl> + | } <nl> + <nl> let ( ) = Tempfile . with_real_tempdir @ @ fun temp_dir - > <nl> let temp_dir = Path . to_string temp_dir in <nl> ( * - " b " depends on " a " <nl> let ( ) = Tempfile . with_real_tempdir @ @ fun temp_dir - > <nl> let env , _ = Test . ( run_loop_once env default_loop_input ) in <nl> <nl> Test . assert_env_errors env d_errors ; <nl> + <nl> + let env , _ = Test . ( run_loop_once env { default_loop_input with <nl> + new_client = Some ( RequestResponse ( ServerCommandTypes . NO_PRECHECKED_FILES ) ) <nl> + } ) in <nl> + <nl> + Test . assert_needs_recheck env " b . php " ; <nl> + <nl> + let env , _ = Test . full_check env in <nl> + <nl> + Test . assert_env_errors env all_errors ; <nl> ( ) <nl> | hh_client status - - no - prechecked flag in incremental mode | facebook/hhvm | 5b470e201ab608b7d1ad2f4359a3e9d561bd1473 | 2018-08-31T23:19:50Z |
mmm a / hphp / runtime / base / preg . cpp <nl> ppp b / hphp / runtime / base / preg . cpp <nl> static Variant php_pcre_replace ( const String & pattern , const String & subject , <nl> replace_end = replace + replace_len ; <nl> } <nl> <nl> - int alloc_len = 2 * subject . size ( ) + 1 ; <nl> - char * result = ( char * ) malloc ( alloc_len ) ; <nl> + StringBuffer result ( 2 * subject . size ( ) ) ; <nl> <nl> try { <nl> <nl> static Variant php_pcre_replace ( const String & pattern , const String & subject , <nl> pcre_extra * extra = pce - > extra ; <nl> set_extra_limits ( extra ) ; <nl> <nl> - int result_len = 0 ; <nl> - int new_len ; / / Length of needed storage <nl> const char * walk ; / / Used to walk the replacement string <nl> char walk_last ; / / Last walked character <nl> - char * walkbuf ; / / Location of current replacement in the result <nl> int match_len ; / / Length of the current match <nl> int backref ; / / Backreference number <nl> int g_notempty = 0 ; / / If the match should not be empty <nl> static Variant php_pcre_replace ( const String & pattern , const String & subject , <nl> } <nl> / * Set the match location in subject * / <nl> match = subject . data ( ) + offsets [ 0 ] ; <nl> - new_len = result_len + offsets [ 0 ] - start_offset ; / / part before the match <nl> <nl> / * If evaluating , do it and add the return string ' s length * / <nl> String eval_result ; <nl> static Variant php_pcre_replace ( const String & pattern , const String & subject , <nl> / * Use custom function to get replacement string and its length . * / <nl> eval_result = preg_do_repl_func ( replace_var , subject , offsets , <nl> subpat_names , count ) ; <nl> - new_len + = eval_result . size ( ) ; <nl> } else { / * do regular substitution * / <nl> walk = replace ; <nl> walk_last = 0 ; <nl> static Variant php_pcre_replace ( const String & pattern , const String & subject , <nl> ) ; <nl> match_len = esc_match . length ( ) ; <nl> } <nl> - new_len + = match_len ; <nl> } <nl> continue ; <nl> } <nl> } <nl> - new_len + + ; <nl> walk + + ; <nl> walk_last = walk [ - 1 ] ; <nl> } <nl> } <nl> <nl> - if ( new_len + 1 > alloc_len ) { <nl> - / / Allocate needed memory plus some extra so we don ' t have to realloc <nl> - / / too often <nl> - alloc_len = 1 + alloc_len + 2 * new_len ; <nl> - result = ( char * ) realloc ( result , alloc_len ) ; <nl> - } <nl> / * copy the part of the string before the match * / <nl> - memcpy ( & result [ result_len ] , piece , match - piece ) ; <nl> - result_len + = match - piece ; <nl> + result . append ( piece , match - piece ) ; <nl> <nl> / * copy replacement and backrefs * / <nl> - walkbuf = result + result_len ; <nl> + int result_len = result . size ( ) ; <nl> <nl> / * If evaluating or using custom function , copy result to the buffer <nl> * and clean up . * / <nl> if ( callable ) { <nl> - memcpy ( walkbuf , eval_result . data ( ) , eval_result . size ( ) ) ; <nl> + result . append ( eval_result . data ( ) , eval_result . size ( ) ) ; <nl> result_len + = eval_result . size ( ) ; <nl> } else { / * do regular backreference copying * / <nl> walk = replace ; <nl> walk_last = 0 ; <nl> Array params ; <nl> - const char * lastStart = nullptr ; <nl> + int lastStart = result . size ( ) ; <nl> while ( walk < replace_end ) { <nl> bool handleQuote = eval & & ' " ' = = * walk & & walk_last ! = ' \ \ ' ; <nl> - if ( handleQuote & & lastStart ! = nullptr ) { <nl> - String str ( lastStart , walkbuf - lastStart , CopyString ) ; <nl> + if ( handleQuote & & lastStart ! = result . size ( ) ) { <nl> + String str ( result . data ( ) + lastStart , result . size ( ) - lastStart , <nl> + CopyString ) ; <nl> params . append ( str ) ; <nl> - lastStart = nullptr ; <nl> + lastStart = result . size ( ) ; <nl> handleQuote = false ; <nl> } <nl> if ( ' \ \ ' = = * walk | | ' $ ' = = * walk ) { <nl> if ( walk_last = = ' \ \ ' ) { <nl> - * ( walkbuf - 1 ) = * walk + + ; <nl> + result . set ( result . size ( ) - 1 , * walk + + ) ; <nl> walk_last = 0 ; <nl> continue ; <nl> } <nl> static Variant php_pcre_replace ( const String & pattern , const String & subject , <nl> ) <nl> ) ; <nl> match_len = esc_match . length ( ) ; <nl> - memcpy ( walkbuf , esc_match . data ( ) , match_len ) ; <nl> + result . append ( esc_match . data ( ) , match_len ) ; <nl> } else { <nl> - memcpy ( <nl> - walkbuf , <nl> + result . append ( <nl> subject . data ( ) + offsets [ backref < < 1 ] , <nl> match_len <nl> ) ; <nl> } <nl> - walkbuf + = match_len ; <nl> } <nl> continue ; <nl> } <nl> } <nl> - * walkbuf + + = * walk + + ; <nl> + result . append ( * walk + + ) ; <nl> walk_last = walk [ - 1 ] ; <nl> - if ( handleQuote & & lastStart = = nullptr ) { <nl> - lastStart = walkbuf ; <nl> + if ( handleQuote & & lastStart ! = result . size ( ) ) { <nl> + lastStart = result . size ( ) ; <nl> } <nl> } <nl> - * walkbuf = ' \ 0 ' ; <nl> + int full_len = result . size ( ) ; <nl> + const char * data = result . data ( ) + result_len ; <nl> if ( eval ) { <nl> JIT : : VMRegAnchor _ ; <nl> - String prefixedCode = concat ( concat ( <nl> - " < ? php return " , result + result_len ) , " ; " ) ; <nl> + / / reserve space for " < ? php return " + code + " ; " <nl> + String prefixedCode ( full_len - result_len + 14 , ReserveString ) ; <nl> + prefixedCode + = " < ? php return " ; <nl> + prefixedCode + = StringSlice ( data , full_len - result_len ) ; <nl> + prefixedCode + = " ; " ; <nl> Unit * unit = g_context - > compileEvalString ( prefixedCode . get ( ) ) ; <nl> Variant v ; <nl> Func * func = unit - > getMain ( ) ; <nl> static Variant php_pcre_replace ( const String & pattern , const String & subject , <nl> ExecutionContext : : InvokePseudoMain ) ; <nl> eval_result = v ; <nl> <nl> - / / Make sure that we have enough space in result <nl> - new_len = result_len + eval_result . size ( ) ; <nl> - if ( new_len + 1 > alloc_len ) { <nl> - / / Allocate needed memory plus some extra so we don ' t have to <nl> - / / realloc too often <nl> - alloc_len = 1 + alloc_len + 2 * new_len ; <nl> - result = ( char * ) realloc ( result , alloc_len ) ; <nl> - } <nl> - <nl> - memcpy ( result + result_len , eval_result . data ( ) , eval_result . size ( ) ) ; <nl> - result_len + = eval_result . size ( ) ; <nl> - } else { <nl> - / / increment the result length by how much we ' ve added to the <nl> - / / string <nl> - result_len + = walkbuf - ( result + result_len ) ; <nl> + result . resize ( result_len ) ; <nl> + result . append ( eval_result . data ( ) , eval_result . size ( ) ) ; <nl> } <nl> } <nl> <nl> static Variant php_pcre_replace ( const String & pattern , const String & subject , <nl> if ( g_notempty ! = 0 & & start_offset < subject . size ( ) ) { <nl> offsets [ 0 ] = start_offset ; <nl> offsets [ 1 ] = start_offset + 1 ; <nl> - memcpy ( & result [ result_len ] , piece , 1 ) ; <nl> - ( result_len ) + + ; <nl> + result . append ( piece , 1 ) ; <nl> } else { <nl> - new_len = result_len + subject . size ( ) - start_offset ; <nl> - if ( new_len + 1 > alloc_len ) { <nl> - alloc_len = new_len + 1 ; / * now we know exactly how long it is * / <nl> - result = ( char * ) realloc ( result , alloc_len ) ; <nl> - } <nl> / * stick that last bit of string on our output * / <nl> - memcpy ( & result [ result_len ] , piece , subject . size ( ) - start_offset ) ; <nl> - result_len + = subject . size ( ) - start_offset ; <nl> - result [ result_len ] = ' \ 0 ' ; <nl> + result . append ( piece , subject . size ( ) - start_offset ) ; <nl> break ; <nl> } <nl> } else { <nl> static Variant php_pcre_replace ( const String & pattern , const String & subject , <nl> callable , limit , start_offset , g_notempty ) ; <nl> } <nl> pcre_handle_exec_error ( count ) ; <nl> - free ( result ) ; <nl> - result = nullptr ; <nl> - break ; <nl> + return String ( ) ; <nl> } <nl> <nl> / * If we have matched an empty string , mimic what Perl ' s / g options does . <nl> static Variant php_pcre_replace ( const String & pattern , const String & subject , <nl> start_offset = offsets [ 1 ] ; <nl> } <nl> <nl> - if ( result ) { <nl> - return String ( result , result_len , AttachString ) ; <nl> - } <nl> - return String ( ) ; <nl> + return result . detach ( ) ; <nl> } catch ( . . . ) { <nl> - free ( result ) ; <nl> throw ; <nl> } <nl> } <nl> mmm a / hphp / runtime / base / string - buffer . cpp <nl> ppp b / hphp / runtime / base / string - buffer . cpp <nl> StringBuffer : : StringBuffer ( int initialSize / * = SmallStringReserve * / ) <nl> , m_maxBytes ( kDefaultOutputLimit ) <nl> , m_len ( 0 ) <nl> { <nl> - assert ( initialSize > 0 ) ; <nl> + assert ( initialSize > = 0 ) ; <nl> m_str = StringData : : Make ( initialSize ) ; <nl> auto const s = m_str - > bufferSlice ( ) ; <nl> m_buffer = s . ptr ; <nl> mmm a / hphp / runtime / base / string - buffer . h <nl> ppp b / hphp / runtime / base / string - buffer . h <nl> struct StringBuffer { <nl> * / <nl> char * appendCursor ( int additionalBytes ) ; <nl> <nl> + / * <nl> + * Mutate a character in existing buffer . <nl> + * / <nl> + void set ( int offset , char c ) { <nl> + assert ( offset < m_len ) ; <nl> + m_buffer [ offset ] = c ; <nl> + } <nl> + <nl> / * <nl> * Append various types of things to this string . <nl> * / <nl> | Use String in php_pcre_replace | facebook/hhvm | 36369c528cb21dbcd2ac57e5bd651eea8dca88a7 | 2014-05-05T20:37:58Z |
mmm a / extensions / Particle3D / ParticleUniverse / ParticleRenders / CCPUParticle3DRender . cpp <nl> ppp b / extensions / Particle3D / ParticleUniverse / ParticleRenders / CCPUParticle3DRender . cpp <nl> void PUParticle3DModelRender : : render ( Renderer * renderer , const Mat4 & transform , <nl> <nl> if ( _spriteList . empty ( ) ) { <nl> for ( unsigned int i = 0 ; i < particleSystem - > getParticleQuota ( ) ; + + i ) { <nl> - Sprite3D * sprite = Sprite3D : : create ( _modelFile ) ; <nl> + auto sprite = Sprite3D : : create ( _modelFile ) ; <nl> + if ( sprite = = nullptr ) <nl> + { <nl> + CCLOG ( " failed to load file % s " , _modelFile . c_str ( ) ) ; <nl> + continue ; <nl> + } <nl> sprite - > setTexture ( _texFile ) ; <nl> sprite - > retain ( ) ; <nl> _spriteList . push_back ( sprite ) ; <nl> PUParticle3DModelRender : : PUParticle3DModelRender ( ) <nl> <nl> PUParticle3DModelRender : : ~ PUParticle3DModelRender ( ) <nl> { <nl> - <nl> + for ( auto it : _spriteList ) { <nl> + it - > release ( ) ; <nl> + } <nl> + _spriteList . clear ( ) ; <nl> } <nl> <nl> NS_CC_END <nl> | check ParticleModelRender to avoid crash | cocos2d/cocos2d-x | d34a9f68f2eaeb146bf96525e80f025c4b4431d5 | 2015-02-15T08:39:58Z |
mmm a / hphp / hack / src / client / clientCheck . ml <nl> ppp b / hphp / hack / src / client / clientCheck . ml <nl> let main args = <nl> Printf . eprintf " Invalid position \ n " ; <nl> raise Exit_status . ( Exit_with Input_error ) <nl> end in <nl> - let responses = rpc args @ @ Rpc . INFER_TYPE_BATCH positions in <nl> + let responses = rpc args @ @ Rpc . INFER_TYPE_BATCH ( positions , args . dynamic_view ) in <nl> List . iter responses print_endline ; <nl> Exit_status . No_error <nl> | MODE_AUTO_COMPLETE - > <nl> mmm a / hphp / hack / src / server / serverCommandTypes . ml <nl> ppp b / hphp / hack / src / server / serverCommandTypes . ml <nl> type _ t = <nl> | STATUS : bool - > Server_status . t t <nl> | INFER_TYPE : ServerUtils . file_input * int * int * bool - > <nl> InferAtPosService . result t <nl> - | INFER_TYPE_BATCH : ( string * int * int ) list - > string list t <nl> + | INFER_TYPE_BATCH : ( string * int * int ) list * bool - > string list t <nl> | IDE_HOVER : ServerUtils . file_input * int * int - > <nl> HoverService . result t <nl> | COVERAGE_LEVELS : ServerUtils . file_input - > Coverage_level . result t <nl> mmm a / hphp / hack / src / server / serverRpc . ml <nl> ppp b / hphp / hack / src / server / serverRpc . ml <nl> let handle : type a . genv - > env - > is_stale : bool - > a t - > env * a = <nl> | COVERAGE_LEVELS fn - > env , ServerColorFile . go env fn <nl> | INFER_TYPE ( fn , line , char , dynamic_view ) - > <nl> env , ServerInferType . go env ( fn , line , char , dynamic_view ) <nl> - | INFER_TYPE_BATCH positions - > <nl> + | INFER_TYPE_BATCH ( positions , dynamic_view ) - > <nl> + let tcopt = env . ServerEnv . tcopt in <nl> + let tcopt = { tcopt with GlobalOptions . tco_dynamic_view = dynamic_view } in <nl> + let env = { env with tcopt } in <nl> env , ServerInferTypeBatch . go genv . workers positions env <nl> | IDE_HOVER ( fn , line , char ) - > <nl> env , ServerHover . go env ( fn , line , char ) <nl> | Dynamic view for type - at - pos - batch | facebook/hhvm | 589a11903ff11b0138960d34aeb5f0aca4ef37e3 | 2018-03-15T23:03:14Z |
mmm a / test / full_test . py <nl> ppp b / test / full_test . py <nl> <nl> " cores " : cores , <nl> " slices " : slices } , <nl> repeat = 5 ) <nl> + <nl> + do_test ( " integration / extraction . py " , <nl> + { " auto " : True , <nl> + " mode " : mode , <nl> + " no - valgrind " : not checker , <nl> + " protocol " : protocol , <nl> + " cores " : cores , <nl> + " slices " : slices } , <nl> + repeat = 5 ) <nl> <nl> do_test ( " integration / pipeline . py " , <nl> { " auto " : True , <nl> mmm a / test / smoke_test . py <nl> ppp b / test / smoke_test . py <nl> <nl> " mode " : mode , <nl> " no - valgrind " : not checker , <nl> " protocol " : protocol } ) <nl> + <nl> + do_test ( " integration / extraction . py " , <nl> + { " auto " : True , <nl> + " mode " : mode , <nl> + " no - valgrind " : not checker , <nl> + " protocol " : protocol } ) <nl> <nl> # More advanced tests in various cores / slices configuration <nl> for ( cores , slices ) in [ ( 1 , 1 ) ] : <nl> | Added extraction to smoke_test and full_test . | rethinkdb/rethinkdb | cbf342980607a7e530df814bda6aa30aaf42daeb | 2010-11-02T00:42:30Z |
mmm a / src / compiler / ast - graph - builder . cc <nl> ppp b / src / compiler / ast - graph - builder . cc <nl> Node * AstGraphBuilder : : GetFunctionClosure ( ) { <nl> } <nl> <nl> <nl> - void AstGraphBuilder : : CreateFunctionContext ( bool constant_context ) { <nl> - function_context_ . set ( constant_context <nl> - ? jsgraph ( ) - > HeapConstant ( info ( ) - > context ( ) ) <nl> - : NewOuterContextParam ( ) ) ; <nl> - } <nl> - <nl> - <nl> - Node * AstGraphBuilder : : NewOuterContextParam ( ) { <nl> - / / Parameter ( arity + 1 ) is special for the outer context of the function <nl> - const Operator * op = <nl> - common ( ) - > Parameter ( info ( ) - > num_parameters_including_this ( ) , " % context " ) ; <nl> - return NewNode ( op , graph ( ) - > start ( ) ) ; <nl> + Node * AstGraphBuilder : : GetFunctionContext ( ) { <nl> + if ( ! function_context_ . is_set ( ) ) { <nl> + / / Parameter ( arity + 1 ) is special for the outer context of the function <nl> + const Operator * op = common ( ) - > Parameter ( <nl> + info ( ) - > num_parameters_including_this ( ) , " % context " ) ; <nl> + Node * node = NewNode ( op , graph ( ) - > start ( ) ) ; <nl> + function_context_ . set ( node ) ; <nl> + } <nl> + return function_context_ . get ( ) ; <nl> } <nl> <nl> <nl> - bool AstGraphBuilder : : CreateGraph ( bool constant_context , bool stack_check ) { <nl> + bool AstGraphBuilder : : CreateGraph ( bool stack_check ) { <nl> Scope * scope = info ( ) - > scope ( ) ; <nl> DCHECK ( graph ( ) ! = NULL ) ; <nl> <nl> bool AstGraphBuilder : : CreateGraph ( bool constant_context , bool stack_check ) { <nl> } <nl> <nl> / / Initialize the incoming context . <nl> - CreateFunctionContext ( constant_context ) ; <nl> - ContextScope incoming ( this , scope , function_context_ . get ( ) ) ; <nl> + ContextScope incoming ( this , scope , GetFunctionContext ( ) ) ; <nl> <nl> / / Initialize control scope . <nl> ControlScope control ( this ) ; <nl> bool AstGraphBuilder : : CreateGraph ( bool constant_context , bool stack_check ) { <nl> / / Build function context only if there are context allocated variables . <nl> if ( info ( ) - > num_heap_slots ( ) > 0 ) { <nl> / / Push a new inner context scope for the function . <nl> - Node * inner_context = BuildLocalFunctionContext ( function_context_ . get ( ) ) ; <nl> + Node * inner_context = BuildLocalFunctionContext ( GetFunctionContext ( ) ) ; <nl> ContextScope top_context ( this , scope , inner_context ) ; <nl> CreateGraphBody ( stack_check ) ; <nl> } else { <nl> Node * AstGraphBuilder : : BuildLoadBuiltinsObject ( ) { <nl> Node * AstGraphBuilder : : BuildLoadGlobalObject ( ) { <nl> const Operator * load_op = <nl> javascript ( ) - > LoadContext ( 0 , Context : : GLOBAL_OBJECT_INDEX , true ) ; <nl> - return NewNode ( load_op , function_context_ . get ( ) ) ; <nl> + return NewNode ( load_op , GetFunctionContext ( ) ) ; <nl> } <nl> <nl> <nl> void AstGraphBuilder : : Environment : : PrepareForLoop ( BitVector * assigned , <nl> <nl> if ( builder_ - > info ( ) - > is_osr ( ) ) { <nl> / / Introduce phis for all context values in the case of an OSR graph . <nl> - for ( int i = 0 ; i < static_cast < int > ( contexts ( ) - > size ( ) ) ; + + i ) { <nl> - Node * val = contexts ( ) - > at ( i ) ; <nl> - if ( ! IrOpcode : : IsConstantOpcode ( val - > opcode ( ) ) ) { <nl> - contexts ( ) - > at ( i ) = builder_ - > NewPhi ( 1 , val , control ) ; <nl> - } <nl> + for ( size_t i = 0 ; i < contexts ( ) - > size ( ) ; + + i ) { <nl> + Node * context = contexts ( ) - > at ( i ) ; <nl> + contexts ( ) - > at ( i ) = builder_ - > NewPhi ( 1 , context , control ) ; <nl> } <nl> } <nl> <nl> void AstGraphBuilder : : Environment : : PrepareForLoop ( BitVector * assigned , <nl> builder_ - > MergeEffect ( effect , osr_loop_entry , control ) ; <nl> <nl> for ( int i = 0 ; i < size ; + + i ) { <nl> - Node * val = values ( ) - > at ( i ) ; <nl> - if ( ! IrOpcode : : IsConstantOpcode ( val - > opcode ( ) ) ) { <nl> - Node * osr_value = <nl> - graph - > NewNode ( builder_ - > common ( ) - > OsrValue ( i ) , osr_loop_entry ) ; <nl> - values ( ) - > at ( i ) = builder_ - > MergeValue ( val , osr_value , control ) ; <nl> - } <nl> + Node * value = values ( ) - > at ( i ) ; <nl> + Node * osr_value = <nl> + graph - > NewNode ( builder_ - > common ( ) - > OsrValue ( i ) , osr_loop_entry ) ; <nl> + values ( ) - > at ( i ) = builder_ - > MergeValue ( value , osr_value , control ) ; <nl> } <nl> <nl> / / Rename all the contexts in the environment . <nl> void AstGraphBuilder : : Environment : : PrepareForLoop ( BitVector * assigned , <nl> builder_ - > common ( ) - > OsrValue ( Linkage : : kOsrContextSpillSlotIndex ) ; <nl> int last = static_cast < int > ( contexts ( ) - > size ( ) - 1 ) ; <nl> for ( int i = last ; i > = 0 ; i - - ) { <nl> - Node * val = contexts ( ) - > at ( i ) ; <nl> - if ( ! IrOpcode : : IsConstantOpcode ( val - > opcode ( ) ) ) { <nl> - osr_context = ( i = = last ) ? graph - > NewNode ( op_inner , osr_loop_entry ) <nl> - : graph - > NewNode ( op , osr_context , osr_context , <nl> - osr_loop_entry ) ; <nl> - contexts ( ) - > at ( i ) = builder_ - > MergeValue ( val , osr_context , control ) ; <nl> - } else { <nl> - osr_context = val ; <nl> - } <nl> + Node * context = contexts ( ) - > at ( i ) ; <nl> + osr_context = ( i = = last ) ? graph - > NewNode ( op_inner , osr_loop_entry ) <nl> + : graph - > NewNode ( op , osr_context , osr_context , <nl> + osr_loop_entry ) ; <nl> + contexts ( ) - > at ( i ) = builder_ - > MergeValue ( context , osr_context , control ) ; <nl> } <nl> } <nl> } <nl> mmm a / src / compiler / ast - graph - builder . h <nl> ppp b / src / compiler / ast - graph - builder . h <nl> class AstGraphBuilder : public AstVisitor { <nl> JSTypeFeedbackTable * js_type_feedback = NULL ) ; <nl> <nl> / / Creates a graph by visiting the entire AST . <nl> - bool CreateGraph ( bool constant_context , bool stack_check = true ) ; <nl> + bool CreateGraph ( bool stack_check = true ) ; <nl> <nl> / / Helpers to create new control nodes . <nl> Node * NewIfTrue ( ) { return NewNode ( common ( ) - > IfTrue ( ) ) ; } <nl> class AstGraphBuilder : public AstVisitor { <nl> / / Create the main graph body by visiting the AST . <nl> void CreateGraphBody ( bool stack_check ) ; <nl> <nl> - / / Create the node that represents the outer context of the function . <nl> - void CreateFunctionContext ( bool constant_context ) ; <nl> - <nl> / / Get or create the node that represents the outer function closure . <nl> Node * GetFunctionClosureForContext ( ) ; <nl> Node * GetFunctionClosure ( ) ; <nl> <nl> + / / Get or create the node that represents the outer function context . <nl> + Node * GetFunctionContext ( ) ; <nl> + <nl> / / Node creation helpers . <nl> Node * NewNode ( const Operator * op , bool incomplete = false ) { <nl> return MakeNode ( op , 0 , static_cast < Node * * > ( NULL ) , incomplete ) ; <nl> class AstGraphBuilder : public AstVisitor { <nl> Node * NewPhi ( int count , Node * input , Node * control ) ; <nl> Node * NewEffectPhi ( int count , Node * input , Node * control ) ; <nl> <nl> - Node * NewOuterContextParam ( ) ; <nl> - <nl> / / Helpers for merging control , effect or value dependencies . <nl> Node * MergeControl ( Node * control , Node * other ) ; <nl> Node * MergeEffect ( Node * value , Node * other , Node * control ) ; <nl> mmm a / src / compiler / js - context - specialization . cc <nl> ppp b / src / compiler / js - context - specialization . cc <nl> namespace v8 { <nl> namespace internal { <nl> namespace compiler { <nl> <nl> - Reduction JSContextSpecializer : : Reduce ( Node * node ) { <nl> - if ( node - > opcode ( ) = = IrOpcode : : kJSLoadContext ) { <nl> - return ReduceJSLoadContext ( node ) ; <nl> + Reduction JSContextSpecialization : : Reduce ( Node * node ) { <nl> + switch ( node - > opcode ( ) ) { <nl> + case IrOpcode : : kParameter : <nl> + return ReduceParameter ( node ) ; <nl> + case IrOpcode : : kJSLoadContext : <nl> + return ReduceJSLoadContext ( node ) ; <nl> + case IrOpcode : : kJSStoreContext : <nl> + return ReduceJSStoreContext ( node ) ; <nl> + default : <nl> + break ; <nl> } <nl> - if ( node - > opcode ( ) = = IrOpcode : : kJSStoreContext ) { <nl> - return ReduceJSStoreContext ( node ) ; <nl> + return NoChange ( ) ; <nl> + } <nl> + <nl> + <nl> + Reduction JSContextSpecialization : : ReduceParameter ( Node * node ) { <nl> + DCHECK_EQ ( IrOpcode : : kParameter , node - > opcode ( ) ) ; <nl> + Node * const start = NodeProperties : : GetValueInput ( node , 0 ) ; <nl> + DCHECK_EQ ( IrOpcode : : kStart , start - > opcode ( ) ) ; <nl> + int const index = ParameterIndexOf ( node - > op ( ) ) ; <nl> + / / The context is always the last parameter to a JavaScript function , and <nl> + / / { Parameter } indices start at - 1 , so value outputs of { Start } look like <nl> + / / this : closure , receiver , param0 , . . . , paramN , context . <nl> + if ( index = = start - > op ( ) - > ValueOutputCount ( ) - 2 ) { <nl> + Handle < Context > context_constant ; <nl> + if ( context ( ) . ToHandle ( & context_constant ) ) { <nl> + return Replace ( jsgraph ( ) - > Constant ( context_constant ) ) ; <nl> + } <nl> } <nl> return NoChange ( ) ; <nl> } <nl> <nl> <nl> - Reduction JSContextSpecializer : : ReduceJSLoadContext ( Node * node ) { <nl> + Reduction JSContextSpecialization : : ReduceJSLoadContext ( Node * node ) { <nl> DCHECK_EQ ( IrOpcode : : kJSLoadContext , node - > opcode ( ) ) ; <nl> <nl> HeapObjectMatcher m ( NodeProperties : : GetValueInput ( node , 0 ) ) ; <nl> Reduction JSContextSpecializer : : ReduceJSLoadContext ( Node * node ) { <nl> } <nl> <nl> <nl> - Reduction JSContextSpecializer : : ReduceJSStoreContext ( Node * node ) { <nl> + Reduction JSContextSpecialization : : ReduceJSStoreContext ( Node * node ) { <nl> DCHECK_EQ ( IrOpcode : : kJSStoreContext , node - > opcode ( ) ) ; <nl> <nl> HeapObjectMatcher m ( NodeProperties : : GetValueInput ( node , 0 ) ) ; <nl> Reduction JSContextSpecializer : : ReduceJSStoreContext ( Node * node ) { <nl> } <nl> <nl> <nl> - Isolate * JSContextSpecializer : : isolate ( ) const { return jsgraph ( ) - > isolate ( ) ; } <nl> + Isolate * JSContextSpecialization : : isolate ( ) const { <nl> + return jsgraph ( ) - > isolate ( ) ; <nl> + } <nl> <nl> <nl> - JSOperatorBuilder * JSContextSpecializer : : javascript ( ) const { <nl> + JSOperatorBuilder * JSContextSpecialization : : javascript ( ) const { <nl> return jsgraph ( ) - > javascript ( ) ; <nl> } <nl> <nl> mmm a / src / compiler / js - context - specialization . h <nl> ppp b / src / compiler / js - context - specialization . h <nl> class JSOperatorBuilder ; <nl> <nl> / / Specializes a given JSGraph to a given context , potentially constant folding <nl> / / some { LoadContext } nodes or strength reducing some { StoreContext } nodes . <nl> - class JSContextSpecializer : public AdvancedReducer { <nl> + class JSContextSpecialization final : public AdvancedReducer { <nl> public : <nl> - JSContextSpecializer ( Editor * editor , JSGraph * jsgraph ) <nl> - : AdvancedReducer ( editor ) , jsgraph_ ( jsgraph ) { } <nl> + JSContextSpecialization ( Editor * editor , JSGraph * jsgraph , <nl> + MaybeHandle < Context > context ) <nl> + : AdvancedReducer ( editor ) , jsgraph_ ( jsgraph ) , context_ ( context ) { } <nl> <nl> - Reduction Reduce ( Node * node ) override ; <nl> + Reduction Reduce ( Node * node ) final ; <nl> <nl> - / / Visible for unit testing . <nl> + private : <nl> + Reduction ReduceParameter ( Node * node ) ; <nl> Reduction ReduceJSLoadContext ( Node * node ) ; <nl> Reduction ReduceJSStoreContext ( Node * node ) ; <nl> <nl> - private : <nl> Isolate * isolate ( ) const ; <nl> JSOperatorBuilder * javascript ( ) const ; <nl> JSGraph * jsgraph ( ) const { return jsgraph_ ; } <nl> + MaybeHandle < Context > context ( ) const { return context_ ; } <nl> <nl> JSGraph * const jsgraph_ ; <nl> + MaybeHandle < Context > context_ ; <nl> <nl> - DISALLOW_COPY_AND_ASSIGN ( JSContextSpecializer ) ; <nl> + DISALLOW_COPY_AND_ASSIGN ( JSContextSpecialization ) ; <nl> } ; <nl> <nl> } / / namespace compiler <nl> mmm a / src / compiler / js - inlining . cc <nl> ppp b / src / compiler / js - inlining . cc <nl> class CopyVisitor { <nl> } ; <nl> <nl> <nl> - Reduction JSInliner : : InlineCall ( Node * call , Node * frame_state , Node * start , <nl> - Node * end ) { <nl> + Reduction JSInliner : : InlineCall ( Node * call , Node * context , Node * frame_state , <nl> + Node * start , Node * end ) { <nl> / / The scheduler is smart enough to place our code ; we just ensure { control } <nl> / / becomes the control input of the start of the inlinee , and { effect } becomes <nl> / / the effect input of the start of the inlinee . <nl> Reduction JSInliner : : InlineCall ( Node * call , Node * frame_state , Node * start , <nl> if ( index < inliner_inputs & & index < inlinee_context_index ) { <nl> / / There is an input from the call , and the index is a value <nl> / / projection but not the context , so rewire the input . <nl> - ReplaceWithValue ( use , call - > InputAt ( index ) ) ; <nl> + Replace ( use , call - > InputAt ( index ) ) ; <nl> } else if ( index = = inlinee_context_index ) { <nl> - / / TODO ( turbofan ) : We always context specialize inlinees currently , so <nl> - / / we should never get here . <nl> - UNREACHABLE ( ) ; <nl> + Replace ( use , context ) ; <nl> } else if ( index < inlinee_context_index ) { <nl> / / Call has fewer arguments than required , fill with undefined . <nl> - ReplaceWithValue ( use , jsgraph_ - > UndefinedConstant ( ) ) ; <nl> + Replace ( use , jsgraph_ - > UndefinedConstant ( ) ) ; <nl> } else { <nl> / / We got too many arguments , discard for now . <nl> / / TODO ( sigurds ) : Fix to treat arguments array correctly . <nl> Reduction JSInliner : : Reduce ( Node * node ) { <nl> Graph graph ( info . zone ( ) ) ; <nl> JSGraph jsgraph ( info . isolate ( ) , & graph , jsgraph_ - > common ( ) , <nl> jsgraph_ - > javascript ( ) , jsgraph_ - > machine ( ) ) ; <nl> + AstGraphBuilder graph_builder ( local_zone_ , & info , & jsgraph ) ; <nl> + graph_builder . CreateGraph ( false ) ; <nl> <nl> / / The inlinee specializes to the context from the JSFunction object . <nl> / / TODO ( turbofan ) : We might want to load the context from the JSFunction at <nl> / / runtime in case we only know the SharedFunctionInfo once we have dynamic <nl> / / type feedback in the compiler . <nl> - AstGraphBuilder graph_builder ( local_zone_ , & info , & jsgraph ) ; <nl> - graph_builder . CreateGraph ( true , false ) ; <nl> + Node * context = jsgraph_ - > Constant ( handle ( function - > context ( ) ) ) ; <nl> <nl> CopyVisitor visitor ( & graph , jsgraph_ - > graph ( ) , info . zone ( ) ) ; <nl> visitor . CopyGraph ( ) ; <nl> Reduction JSInliner : : Reduce ( Node * node ) { <nl> / / Remember that we inlined this function . <nl> info_ - > AddInlinedFunction ( info . shared_info ( ) ) ; <nl> <nl> - return InlineCall ( node , frame_state , start , end ) ; <nl> + return InlineCall ( node , context , frame_state , start , end ) ; <nl> } <nl> <nl> } / / namespace compiler <nl> mmm a / src / compiler / js - inlining . h <nl> ppp b / src / compiler / js - inlining . h <nl> class JSInliner final : public AdvancedReducer { <nl> Handle < SharedFunctionInfo > shared_info , <nl> Zone * temp_zone ) ; <nl> <nl> - Reduction InlineCall ( Node * call , Node * frame_state , Node * start , Node * end ) ; <nl> + Reduction InlineCall ( Node * call , Node * context , Node * frame_state , <nl> + Node * start , Node * end ) ; <nl> } ; <nl> <nl> } / / namespace compiler <nl> mmm a / src / compiler / pipeline . cc <nl> ppp b / src / compiler / pipeline . cc <nl> class AstGraphBuilderWithPositions final : public AstGraphBuilder { <nl> source_positions_ ( source_positions ) , <nl> start_position_ ( info - > shared_info ( ) - > start_position ( ) ) { } <nl> <nl> - bool CreateGraph ( bool constant_context , bool stack_check ) { <nl> + bool CreateGraph ( bool stack_check ) { <nl> SourcePositionTable : : Scope pos_scope ( source_positions_ , start_position_ ) ; <nl> - return AstGraphBuilder : : CreateGraph ( constant_context , stack_check ) ; <nl> + return AstGraphBuilder : : CreateGraph ( stack_check ) ; <nl> } <nl> <nl> # define DEF_VISIT ( type ) \ <nl> struct LoopAssignmentAnalysisPhase { <nl> struct GraphBuilderPhase { <nl> static const char * phase_name ( ) { return " graph builder " ; } <nl> <nl> - void Run ( PipelineData * data , Zone * temp_zone , bool constant_context ) { <nl> + void Run ( PipelineData * data , Zone * temp_zone ) { <nl> AstGraphBuilderWithPositions graph_builder ( <nl> temp_zone , data - > info ( ) , data - > jsgraph ( ) , data - > loop_assignment ( ) , <nl> data - > js_type_feedback ( ) , data - > source_positions ( ) ) ; <nl> bool stack_check = ! data - > info ( ) - > IsStub ( ) ; <nl> - if ( ! graph_builder . CreateGraph ( constant_context , stack_check ) ) { <nl> + if ( ! graph_builder . CreateGraph ( stack_check ) ) { <nl> data - > set_compilation_failed ( ) ; <nl> } <nl> } <nl> struct InliningPhase { <nl> data - > common ( ) ) ; <nl> CommonOperatorReducer common_reducer ( & graph_reducer , data - > graph ( ) , <nl> data - > common ( ) , data - > machine ( ) ) ; <nl> - JSContextSpecializer context_specializer ( & graph_reducer , data - > jsgraph ( ) ) ; <nl> + JSContextSpecialization context_specialization ( <nl> + & graph_reducer , data - > jsgraph ( ) , data - > info ( ) - > context ( ) ) ; <nl> JSFrameSpecialization frame_specialization ( data - > info ( ) - > osr_frame ( ) , <nl> data - > jsgraph ( ) ) ; <nl> JSInliner inliner ( & graph_reducer , data - > info ( ) - > is_inlining_enabled ( ) <nl> struct InliningPhase { <nl> AddReducer ( data , & graph_reducer , & frame_specialization ) ; <nl> } <nl> if ( data - > info ( ) - > is_context_specializing ( ) ) { <nl> - AddReducer ( data , & graph_reducer , & context_specializer ) ; <nl> + AddReducer ( data , & graph_reducer , & context_specialization ) ; <nl> } <nl> AddReducer ( data , & graph_reducer , & inliner ) ; <nl> graph_reducer . ReduceGraph ( ) ; <nl> Handle < Code > Pipeline : : GenerateCode ( ) { <nl> Run < LoopAssignmentAnalysisPhase > ( ) ; <nl> } <nl> <nl> - Run < GraphBuilderPhase > ( info ( ) - > is_context_specializing ( ) ) ; <nl> + Run < GraphBuilderPhase > ( ) ; <nl> if ( data . compilation_failed ( ) ) return Handle < Code > : : null ( ) ; <nl> RunPrintAndVerify ( " Initial untyped " , true ) ; <nl> <nl> mmm a / test / cctest / compiler / test - js - context - specialization . cc <nl> ppp b / test / cctest / compiler / test - js - context - specialization . cc <nl> class ContextSpecializationTester : public HandleAndZoneScope { <nl> simplified_ ( main_zone ( ) ) , <nl> jsgraph_ ( main_isolate ( ) , graph ( ) , common ( ) , & javascript_ , & machine_ ) , <nl> reducer_ ( main_zone ( ) , graph ( ) ) , <nl> - spec_ ( & reducer_ , jsgraph ( ) ) { } <nl> + spec_ ( & reducer_ , jsgraph ( ) , MaybeHandle < Context > ( ) ) { } <nl> <nl> - JSContextSpecializer * spec ( ) { return & spec_ ; } <nl> + JSContextSpecialization * spec ( ) { return & spec_ ; } <nl> Factory * factory ( ) { return main_isolate ( ) - > factory ( ) ; } <nl> CommonOperatorBuilder * common ( ) { return & common_ ; } <nl> JSOperatorBuilder * javascript ( ) { return & javascript_ ; } <nl> class ContextSpecializationTester : public HandleAndZoneScope { <nl> SimplifiedOperatorBuilder simplified_ ; <nl> JSGraph jsgraph_ ; <nl> GraphReducer reducer_ ; <nl> - JSContextSpecializer spec_ ; <nl> + JSContextSpecialization spec_ ; <nl> } ; <nl> <nl> <nl> TEST ( ReduceJSLoadContext ) { <nl> / / Mutable slot , constant context , depth = 0 = > do nothing . <nl> Node * load = t . graph ( ) - > NewNode ( t . javascript ( ) - > LoadContext ( 0 , 0 , false ) , <nl> const_context , const_context , start ) ; <nl> - Reduction r = t . spec ( ) - > ReduceJSLoadContext ( load ) ; <nl> + Reduction r = t . spec ( ) - > Reduce ( load ) ; <nl> CHECK ( ! r . Changed ( ) ) ; <nl> } <nl> <nl> TEST ( ReduceJSLoadContext ) { <nl> / / Mutable slot , non - constant context , depth = 0 = > do nothing . <nl> Node * load = t . graph ( ) - > NewNode ( t . javascript ( ) - > LoadContext ( 0 , 0 , false ) , <nl> param_context , param_context , start ) ; <nl> - Reduction r = t . spec ( ) - > ReduceJSLoadContext ( load ) ; <nl> + Reduction r = t . spec ( ) - > Reduce ( load ) ; <nl> CHECK ( ! r . Changed ( ) ) ; <nl> } <nl> <nl> TEST ( ReduceJSLoadContext ) { <nl> Node * load = t . graph ( ) - > NewNode ( <nl> t . javascript ( ) - > LoadContext ( 2 , Context : : GLOBAL_EVAL_FUN_INDEX , false ) , <nl> deep_const_context , deep_const_context , start ) ; <nl> - Reduction r = t . spec ( ) - > ReduceJSLoadContext ( load ) ; <nl> + Reduction r = t . spec ( ) - > Reduce ( load ) ; <nl> CHECK ( r . Changed ( ) ) ; <nl> Node * new_context_input = NodeProperties : : GetValueInput ( r . replacement ( ) , 0 ) ; <nl> CHECK_EQ ( IrOpcode : : kHeapConstant , new_context_input - > opcode ( ) ) ; <nl> TEST ( ReduceJSLoadContext ) { <nl> / / Immutable slot , constant context , depth = 0 = > specialize . <nl> Node * load = t . graph ( ) - > NewNode ( t . javascript ( ) - > LoadContext ( 0 , slot , true ) , <nl> const_context , const_context , start ) ; <nl> - Reduction r = t . spec ( ) - > ReduceJSLoadContext ( load ) ; <nl> + Reduction r = t . spec ( ) - > Reduce ( load ) ; <nl> CHECK ( r . Changed ( ) ) ; <nl> CHECK ( r . replacement ( ) ! = load ) ; <nl> <nl> TEST ( ReduceJSStoreContext ) { <nl> / / Mutable slot , constant context , depth = 0 = > do nothing . <nl> Node * load = t . graph ( ) - > NewNode ( t . javascript ( ) - > StoreContext ( 0 , 0 ) , <nl> const_context , const_context , start ) ; <nl> - Reduction r = t . spec ( ) - > ReduceJSStoreContext ( load ) ; <nl> + Reduction r = t . spec ( ) - > Reduce ( load ) ; <nl> CHECK ( ! r . Changed ( ) ) ; <nl> } <nl> <nl> TEST ( ReduceJSStoreContext ) { <nl> / / Mutable slot , non - constant context , depth = 0 = > do nothing . <nl> Node * load = t . graph ( ) - > NewNode ( t . javascript ( ) - > StoreContext ( 0 , 0 ) , <nl> param_context , param_context , start ) ; <nl> - Reduction r = t . spec ( ) - > ReduceJSStoreContext ( load ) ; <nl> + Reduction r = t . spec ( ) - > Reduce ( load ) ; <nl> CHECK ( ! r . Changed ( ) ) ; <nl> } <nl> <nl> TEST ( ReduceJSStoreContext ) { <nl> / / Immutable slot , constant context , depth = 0 = > do nothing . <nl> Node * load = t . graph ( ) - > NewNode ( t . javascript ( ) - > StoreContext ( 0 , slot ) , <nl> const_context , const_context , start ) ; <nl> - Reduction r = t . spec ( ) - > ReduceJSStoreContext ( load ) ; <nl> + Reduction r = t . spec ( ) - > Reduce ( load ) ; <nl> CHECK ( ! r . Changed ( ) ) ; <nl> } <nl> <nl> TEST ( ReduceJSStoreContext ) { <nl> Node * load = t . graph ( ) - > NewNode ( <nl> t . javascript ( ) - > StoreContext ( 2 , Context : : GLOBAL_EVAL_FUN_INDEX ) , <nl> deep_const_context , deep_const_context , start ) ; <nl> - Reduction r = t . spec ( ) - > ReduceJSStoreContext ( load ) ; <nl> + Reduction r = t . spec ( ) - > Reduce ( load ) ; <nl> CHECK ( r . Changed ( ) ) ; <nl> Node * new_context_input = NodeProperties : : GetValueInput ( r . replacement ( ) , 0 ) ; <nl> CHECK_EQ ( IrOpcode : : kHeapConstant , new_context_input - > opcode ( ) ) ; <nl> TEST ( SpecializeToContext ) { <nl> <nl> / / Perform the reduction on the entire graph . <nl> GraphReducer graph_reducer ( t . main_zone ( ) , t . graph ( ) ) ; <nl> - JSContextSpecializer spec ( & graph_reducer , t . jsgraph ( ) ) ; <nl> + JSContextSpecialization spec ( & graph_reducer , t . jsgraph ( ) , <nl> + MaybeHandle < Context > ( ) ) ; <nl> graph_reducer . AddReducer ( & spec ) ; <nl> graph_reducer . ReduceGraph ( ) ; <nl> <nl> | [ turbofan ] Context specialization is the job of the JSContextSpecialization . | v8/v8 | 069a47f6e5ed00d0f63fc845b62ad325f13b2c37 | 2015-07-06T12:56:28Z |
mmm a / src / mongo / s / commands_admin . cpp <nl> ppp b / src / mongo / s / commands_admin . cpp <nl> namespace mongo { <nl> out - > push_back ( Privilege ( AuthorizationManager : : CLUSTER_RESOURCE_NAME , actions ) ) ; <nl> } <nl> bool run ( const string & , BSONObj & cmdObj , int , string & errmsg , BSONObjBuilder & result , bool ) { <nl> - if ( ! ClientBasic : : getCurrent ( ) - > getAuthenticationInfo ( ) - > isAuthorized ( " admin " ) ) { <nl> - errmsg = " unauthorized . Need admin authentication for flushRouterConfig . " ; <nl> - return false ; <nl> - } <nl> - <nl> grid . flushConfig ( ) ; <nl> result . appendBool ( " flushed " , true ) ; <nl> return true ; <nl> namespace mongo { <nl> out - > push_back ( Privilege ( AuthorizationManager : : CLUSTER_RESOURCE_NAME , actions ) ) ; <nl> } <nl> bool run ( const string & , BSONObj & cmdObj , int , string & errmsg , BSONObjBuilder & result , bool ) { <nl> - if ( ! ClientBasic : : getCurrent ( ) - > getAuthenticationInfo ( ) - > isAuthorized ( " admin " ) ) { <nl> - errmsg = " unauthorized . Need admin authentication to enable sharding on a " <nl> - " database " ; <nl> - return false ; <nl> - } <nl> - <nl> string dbname = cmdObj . firstElement ( ) . valuestrsafe ( ) ; <nl> if ( dbname . size ( ) = = 0 ) { <nl> errmsg = " no db " ; <nl> namespace mongo { <nl> out - > push_back ( Privilege ( AuthorizationManager : : CLUSTER_RESOURCE_NAME , actions ) ) ; <nl> } <nl> bool run ( const string & , BSONObj & cmdObj , int , string & errmsg , BSONObjBuilder & result , bool ) { <nl> - if ( ! ClientBasic : : getCurrent ( ) - > getAuthenticationInfo ( ) - > isAuthorized ( " admin " ) ) { <nl> - errmsg = " unauthorized . Need admin authentication to shard a collection " ; <nl> - return false ; <nl> - } <nl> - <nl> const string ns = cmdObj . firstElement ( ) . valuestrsafe ( ) ; <nl> if ( ns . size ( ) = = 0 ) { <nl> errmsg = " no ns " ; <nl> namespace mongo { <nl> out - > push_back ( Privilege ( AuthorizationManager : : CLUSTER_RESOURCE_NAME , actions ) ) ; <nl> } <nl> bool run ( const string & , BSONObj & cmdObj , int , string & errmsg , BSONObjBuilder & result , bool ) { <nl> - if ( ! ClientBasic : : getCurrent ( ) - > getAuthenticationInfo ( ) - > isAuthorized ( " admin " ) ) { <nl> - errmsg = " unauthorized . Need admin authentication to split a chunk " ; <nl> - return false ; <nl> - } <nl> - <nl> if ( ! okForConfigChanges ( errmsg ) ) <nl> return false ; <nl> <nl> namespace mongo { <nl> out - > push_back ( Privilege ( AuthorizationManager : : CLUSTER_RESOURCE_NAME , actions ) ) ; <nl> } <nl> bool run ( const string & , BSONObj & cmdObj , int , string & errmsg , BSONObjBuilder & result , bool ) { <nl> - if ( ! ClientBasic : : getCurrent ( ) - > getAuthenticationInfo ( ) - > isAuthorized ( " admin " ) ) { <nl> - errmsg = " unauthorized . Need admin authentication to move a chunk " ; <nl> - return false ; <nl> - } <nl> - <nl> if ( ! okForConfigChanges ( errmsg ) ) <nl> return false ; <nl> <nl> namespace mongo { <nl> bool run ( const string & , BSONObj & cmdObj , int , string & errmsg , BSONObjBuilder & result , bool ) { <nl> errmsg . clear ( ) ; <nl> <nl> - if ( ! ClientBasic : : getCurrent ( ) - > getAuthenticationInfo ( ) - > isAuthorized ( " admin " ) ) { <nl> - errmsg = " unauthorized . Need admin authentication to add a shard " ; <nl> - log ( ) < < " addshard request " < < cmdObj < < " failed : " < < errmsg < < endl ; <nl> - return false ; <nl> - } <nl> - <nl> / / get replica set component hosts <nl> ConnectionString servers = ConnectionString : : parse ( cmdObj . firstElement ( ) . valuestrsafe ( ) , errmsg ) ; <nl> if ( ! errmsg . empty ( ) ) { <nl> namespace mongo { <nl> out - > push_back ( Privilege ( AuthorizationManager : : CLUSTER_RESOURCE_NAME , actions ) ) ; <nl> } <nl> bool run ( const string & , BSONObj & cmdObj , int , string & errmsg , BSONObjBuilder & result , bool ) { <nl> - if ( ! ClientBasic : : getCurrent ( ) - > getAuthenticationInfo ( ) - > isAuthorized ( " admin " ) ) { <nl> - errmsg = " unauthorized . Need admin authentication to remove a shard " ; <nl> - return false ; <nl> - } <nl> - <nl> string target = cmdObj . firstElement ( ) . valuestrsafe ( ) ; <nl> Shard s = Shard : : make ( target ) ; <nl> if ( ! grid . knowAboutShard ( s . getConnString ( ) ) ) { <nl> namespace mongo { <nl> } <nl> <nl> bool CmdShutdown : : run ( const string & dbname , BSONObj & cmdObj , int , string & errmsg , BSONObjBuilder & result , bool fromRepl ) { <nl> - if ( ! ClientBasic : : getCurrent ( ) - > getAuthenticationInfo ( ) - > isAuthorized ( " admin " ) ) { <nl> - errmsg = " unauthorized . Need admin authentication to run shutdown " ; <nl> - return false ; <nl> - } <nl> - <nl> return shutdownHelper ( ) ; <nl> } <nl> <nl> mmm a / src / mongo / s / commands_public . cpp <nl> ppp b / src / mongo / s / commands_public . cpp <nl> namespace mongo { <nl> return true ; <nl> } <nl> <nl> - / / Make sure you have write auth to the database , otherwise you ' ll delete the <nl> - / / database info from the config server before the command even reaches the shards . <nl> - if ( ! ClientBasic : : getCurrent ( ) - > getAuthenticationInfo ( ) - > isAuthorized ( dbName ) ) { <nl> - result . append ( " errmsg " , <nl> - str : : stream ( ) < < " Not authorized to drop db : " < < dbName ) ; <nl> - return false ; <nl> - } <nl> - <nl> / / <nl> / / Reload the database configuration so that we ' re sure a database entry exists <nl> / / TODO : This won ' t work with parallel dropping <nl> | SERVER - 7572 Remove old - style auth checking from several sharding commands | mongodb/mongo | 0f4e3a0d74c3d24b0139a36b8a8e049bd7617d79 | 2012-12-18T16:47:36Z |
mmm a / Code / CryEngine / CryCommon / CryFlowGraph / IFlowSystem . h <nl> ppp b / Code / CryEngine / CryCommon / CryFlowGraph / IFlowSystem . h <nl> class TFlowInputData <nl> { <nl> int index ; <nl> m_ser . Value ( " tag " , index ) ; <nl> - SerializeVariant ( var ) ; <nl> + if ( index > = 0 ) <nl> + SerializeVariant ( var ) ; <nl> } <nl> <nl> private : <nl> | ! XB ( CE - 10555 ) ( CryAction ) Assert triggered on respawn ( Approved by achim ) | CRYTEK/CRYENGINE | 5cae5879eef7da4727d79895a34cba62c10d8572 | 2016-09-20T13:20:23Z |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.