diff
stringlengths 41
2.03M
| msg
stringlengths 1
1.5k
⌀ | repo
stringlengths 5
40
| sha
stringlengths 40
40
| time
stringlengths 20
20
|
---|---|---|---|---|
mmm a / src / Storages / MergeTree / MergeTreeSettings . h <nl> ppp b / src / Storages / MergeTree / MergeTreeSettings . h <nl> struct Settings ; <nl> / * * Replication settings . * / \ <nl> M ( UInt64 , replicated_deduplication_window , 100 , " How many last blocks of hashes should be kept in ZooKeeper ( old blocks will be deleted ) . " , 0 ) \ <nl> M ( UInt64 , replicated_deduplication_window_seconds , 7 * 24 * 60 * 60 / * one week * / , " Similar to \ " replicated_deduplication_window \ " , but determines old blocks by their lifetime . Hash of an inserted block will be deleted ( and the block will not be deduplicated after ) if it outside of one \ " window \ " . You can set very big replicated_deduplication_window to avoid duplicating INSERTs during that period of time . " , 0 ) \ <nl> - M ( UInt64 , max_replicated_logs_to_keep , 100 , " How many records may be in log , if there is inactive replica . " , 0 ) \ <nl> + M ( UInt64 , max_replicated_logs_to_keep , 1000 , " How many records may be in log , if there is inactive replica . Inactive replica becomes lost when when this number exceed . " , 0 ) \ <nl> M ( UInt64 , min_replicated_logs_to_keep , 10 , " Keep about this number of last records in ZooKeeper log , even if they are obsolete . It doesn ' t affect work of tables : used only to diagnose ZooKeeper log before cleaning . " , 0 ) \ <nl> M ( Seconds , prefer_fetch_merged_part_time_threshold , 3600 , " If time passed after replication log entry creation exceeds this threshold and sum size of parts is greater than \ " prefer_fetch_merged_part_size_threshold \ " , prefer fetching merged part from replica instead of doing merge locally . To speed up very long merges . " , 0 ) \ <nl> M ( UInt64 , prefer_fetch_merged_part_size_threshold , 10ULL * 1024 * 1024 * 1024 , " If sum size of parts exceeds this threshold and time passed after replication log entry creation is greater than \ " prefer_fetch_merged_part_time_threshold \ " , prefer fetching merged part from replica instead of doing merge locally . To speed up very long merges . " , 0 ) \ <nl> struct Settings ; <nl> M ( UInt64 , replicated_max_parallel_sends_for_table , 0 , " Limit parallel sends for one table . " , 0 ) \ <nl> M ( Bool , replicated_can_become_leader , true , " If true , Replicated tables replicas on this node will try to acquire leadership . " , 0 ) \ <nl> M ( Seconds , zookeeper_session_expiration_check_period , 60 , " ZooKeeper session expiration check period , in seconds . " , 0 ) \ <nl> + M ( Bool , detach_old_local_parts_when_cloning_replica , 1 , " Do not remove old local parts when repairing lost replica . " , 0 ) \ <nl> \ <nl> / * * Check delay of replicas settings . * / \ <nl> M ( UInt64 , min_relative_delay_to_measure , 120 , " Calculate relative replica delay only if absolute delay is not less that this value . " , 0 ) \ <nl> mmm a / src / Storages / MergeTree / ReplicatedMergeTreeCleanupThread . cpp <nl> ppp b / src / Storages / MergeTree / ReplicatedMergeTreeCleanupThread . cpp <nl> void ReplicatedMergeTreeCleanupThread : : markLostReplicas ( const std : : unordered_map <nl> for ( const auto & pair : log_pointers_candidate_lost_replicas ) <nl> { <nl> String replica = pair . first ; <nl> + LOG_WARNING ( log , " Will mark replica { } as lost , because it has stale log pointer : { } " , replica , pair . second ) ; <nl> Coordination : : Requests ops ; <nl> / / / If host changed version we can not mark replicas , because replica started to be active . <nl> ops . emplace_back ( zkutil : : makeCheckRequest ( <nl> mmm a / src / Storages / StorageReplicatedMergeTree . cpp <nl> ppp b / src / Storages / StorageReplicatedMergeTree . cpp <nl> void StorageReplicatedMergeTree : : dropReplica ( zkutil : : ZooKeeperPtr zookeeper , con <nl> throw Exception ( " Table was not dropped because ZooKeeper session has expired . " , ErrorCodes : : TABLE_WAS_NOT_DROPPED ) ; <nl> <nl> auto remote_replica_path = zookeeper_path + " / replicas / " + replica ; <nl> - LOG_INFO ( logger , " Removing replica { } " , remote_replica_path ) ; <nl> + LOG_INFO ( logger , " Removing replica { } , marking it as lost " , remote_replica_path ) ; <nl> + / / / Mark itself lost before removing , because the following recursive removal may fail <nl> + / / / and partially dropped replica may be considered as alive one ( until someone will mark it lost ) <nl> + zookeeper - > trySet ( zookeeper_path + " / replicas / " + replica + " / is_lost " , " 1 " ) ; <nl> / / / It may left some garbage if replica_path subtree are concurrently modified <nl> zookeeper - > tryRemoveRecursive ( remote_replica_path ) ; <nl> if ( zookeeper - > exists ( remote_replica_path ) ) <nl> bool StorageReplicatedMergeTree : : executeReplaceRange ( const LogEntry & entry ) <nl> <nl> void StorageReplicatedMergeTree : : cloneReplica ( const String & source_replica , Coordination : : Stat source_is_lost_stat , zkutil : : ZooKeeperPtr & zookeeper ) <nl> { <nl> - LOG_INFO ( log , " Will mimic { } " , source_replica ) ; <nl> - <nl> String source_path = zookeeper_path + " / replicas / " + source_replica ; <nl> <nl> / * * TODO : it will be deleted ! ( It is only to support old version of CH server ) . <nl> void StorageReplicatedMergeTree : : cloneReplica ( const String & source_replica , Coo <nl> LOG_WARNING ( log , " Source replica does not have part { } . Removing it from working set . " , part - > name ) ; <nl> } <nl> } <nl> + <nl> + if ( getSettings ( ) - > detach_old_local_parts_when_cloning_replica ) <nl> + { <nl> + auto metadata_snapshot = getInMemoryMetadataPtr ( ) ; <nl> + for ( const auto & part : parts_to_remove_from_working_set ) <nl> + { <nl> + LOG_INFO ( log , " Detaching { } " , part - > relative_path ) ; <nl> + part - > makeCloneInDetached ( " clone " , metadata_snapshot ) ; <nl> + } <nl> + } <nl> + <nl> removePartsFromWorkingSet ( parts_to_remove_from_working_set , true ) ; <nl> <nl> for ( const String & name : active_parts ) <nl> void StorageReplicatedMergeTree : : cloneReplica ( const String & source_replica , Coo <nl> <nl> void StorageReplicatedMergeTree : : cloneReplicaIfNeeded ( zkutil : : ZooKeeperPtr zookeeper ) <nl> { <nl> + Coordination : : Stat is_lost_stat ; <nl> + bool is_new_replica = true ; <nl> String res ; <nl> - if ( zookeeper - > tryGet ( replica_path + " / is_lost " , res ) ) <nl> + if ( zookeeper - > tryGet ( replica_path + " / is_lost " , res , & is_lost_stat ) ) <nl> { <nl> if ( res = = " 0 " ) <nl> return ; <nl> + if ( is_lost_stat . version ) <nl> + is_new_replica = false ; <nl> } <nl> else <nl> { <nl> / / / Replica was created by old version of CH , so me must create " / is_lost " . <nl> / / / Note that in old version of CH there was no " lost " replicas possible . <nl> + / / / TODO is_lost node should always exist since v18 . 12 , maybe we can replace ` tryGet ` with ` get ` and remove old code ? <nl> zookeeper - > create ( replica_path + " / is_lost " , " 0 " , zkutil : : CreateMode : : Persistent ) ; <nl> return ; <nl> } <nl> <nl> / / / is_lost is " 1 " : it means that we are in repair mode . <nl> + / / / Try choose source replica to clone . <nl> + / / / Source replica must not be lost and should have minimal queue size and maximal log pointer . <nl> + Strings replicas = zookeeper - > getChildren ( zookeeper_path + " / replicas " ) ; <nl> + std : : vector < zkutil : : ZooKeeper : : FutureGet > futures ; <nl> + for ( const String & source_replica_name : replicas ) <nl> + { <nl> + / / / Do not clone from myself . <nl> + if ( source_replica_name = = replica_name ) <nl> + continue ; <nl> + <nl> + String source_replica_path = zookeeper_path + " / replicas / " + source_replica_name ; <nl> + <nl> + / / / Obviously the following get operations are not atomic , but it ' s ok to choose good enough replica , not the best one . <nl> + / / / NOTE : We may count some entries twice if log_pointer is moved . <nl> + futures . emplace_back ( zookeeper - > asyncTryGet ( source_replica_path + " / is_lost " ) ) ; <nl> + futures . emplace_back ( zookeeper - > asyncTryGet ( source_replica_path + " / log_pointer " ) ) ; <nl> + futures . emplace_back ( zookeeper - > asyncTryGet ( source_replica_path + " / queue " ) ) ; <nl> + } <nl> + <nl> + / / / Wait for results before getting log entries <nl> + for ( auto & future : futures ) <nl> + future . wait ( ) ; <nl> <nl> + Strings log_entries = zookeeper - > getChildren ( zookeeper_path + " / log " ) ; <nl> + size_t max_log_entry = 0 ; <nl> + if ( ! log_entries . empty ( ) ) <nl> + { <nl> + String last_entry = * std : : max_element ( log_entries . begin ( ) , log_entries . end ( ) ) ; <nl> + max_log_entry = parse < UInt64 > ( last_entry . substr ( strlen ( " log - " ) ) ) ; <nl> + } <nl> + / / / log_pointer can point to future entry , which was not created yet <nl> + + + max_log_entry ; <nl> + <nl> + size_t min_replication_lag = std : : numeric_limits < size_t > : : max ( ) ; <nl> String source_replica ; <nl> Coordination : : Stat source_is_lost_stat ; <nl> - source_is_lost_stat . version = - 1 ; <nl> + size_t future_num = 0 ; <nl> <nl> - for ( const String & source_replica_name : zookeeper - > getChildren ( zookeeper_path + " / replicas " ) ) <nl> + for ( const String & source_replica_name : replicas ) <nl> { <nl> - String source_replica_path = zookeeper_path + " / replicas / " + source_replica_name ; <nl> + if ( source_replica_name = = replica_name ) <nl> + continue ; <nl> <nl> - / / / Do not clone from myself . <nl> - if ( source_replica_path ! = replica_path ) <nl> + auto get_is_lost = futures [ future_num + + ] . get ( ) ; <nl> + auto get_log_pointer = futures [ future_num + + ] . get ( ) ; <nl> + auto get_queue = futures [ future_num + + ] . get ( ) ; <nl> + <nl> + if ( get_is_lost . error ! = Coordination : : Error : : ZOK ) <nl> { <nl> - / / / Do not clone from lost replicas . <nl> - String source_replica_is_lost_value ; <nl> - if ( ! zookeeper - > tryGet ( source_replica_path + " / is_lost " , source_replica_is_lost_value , & source_is_lost_stat ) <nl> - | | source_replica_is_lost_value = = " 0 " ) <nl> - { <nl> - source_replica = source_replica_name ; <nl> - break ; <nl> - } <nl> + LOG_INFO ( log , " Not cloning { } , cannot get ' / is_lost ' : { } " , Coordination : : errorMessage ( get_is_lost . error ) ) ; <nl> + continue ; <nl> + } <nl> + else if ( get_is_lost . data ! = " 0 " ) <nl> + { <nl> + LOG_INFO ( log , " Not cloning { } , it ' s lost " ) ; <nl> + continue ; <nl> + } <nl> + <nl> + if ( get_log_pointer . error ! = Coordination : : Error : : ZOK ) <nl> + { <nl> + LOG_INFO ( log , " Not cloning { } , cannot get ' / log_pointer ' : { } " , Coordination : : errorMessage ( get_log_pointer . error ) ) ; <nl> + continue ; <nl> + } <nl> + if ( get_queue . error ! = Coordination : : Error : : ZOK ) <nl> + { <nl> + LOG_INFO ( log , " Not cloning { } , cannot get ' / queue ' : { } " , Coordination : : errorMessage ( get_queue . error ) ) ; <nl> + continue ; <nl> + } <nl> + <nl> + / / / Replica is not lost and we can clone it . Let ' s calculate approx replication lag . <nl> + size_t source_log_pointer = get_log_pointer . data . empty ( ) ? 0 : parse < UInt64 > ( get_log_pointer . data ) ; <nl> + assert ( source_log_pointer < = max_log_entry ) ; <nl> + size_t replica_queue_lag = max_log_entry - source_log_pointer ; <nl> + size_t replica_queue_size = get_queue . stat . numChildren ; <nl> + size_t replication_lag = replica_queue_lag + replica_queue_size ; <nl> + LOG_INFO ( log , " Replica { } has log pointer ' { } ' , approximate { } queue lag and { } queue size " , <nl> + source_replica_name , get_log_pointer . data , replica_queue_lag , replica_queue_size ) ; <nl> + if ( replication_lag < min_replication_lag ) <nl> + { <nl> + source_replica = source_replica_name ; <nl> + source_is_lost_stat = get_is_lost . stat ; <nl> + min_replication_lag = replication_lag ; <nl> } <nl> } <nl> <nl> if ( source_replica . empty ( ) ) <nl> throw Exception ( " All replicas are lost " , ErrorCodes : : ALL_REPLICAS_LOST ) ; <nl> <nl> + if ( is_new_replica ) <nl> + LOG_INFO ( log , " Will mimic { } " , source_replica ) ; <nl> + else <nl> + LOG_WARNING ( log , " Will mimic { } " , source_replica ) ; <nl> + <nl> / / / Clear obsolete queue that we no longer need . <nl> zookeeper - > removeChildren ( replica_path + " / queue " ) ; <nl> <nl> deleted file mode 100644 <nl> index a6e80ce2b08 . . 00000000000 <nl> mmm a / tests / integration / test_recovery_replica / configs / remote_servers . xml <nl> ppp / dev / null <nl> <nl> - < yandex > <nl> - < remote_servers > <nl> - < test_cluster > <nl> - < shard > <nl> - < internal_replication > true < / internal_replication > <nl> - < replica > <nl> - < default_database > shard_0 < / default_database > <nl> - < host > node1 < / host > <nl> - < port > 9000 < / port > <nl> - < / replica > <nl> - < replica > <nl> - < default_database > shard_0 < / default_database > <nl> - < host > node2 < / host > <nl> - < port > 9000 < / port > <nl> - < / replica > <nl> - < / shard > <nl> - < / test_cluster > <nl> - < / remote_servers > <nl> - < / yandex > <nl> mmm a / tests / integration / test_recovery_replica / test . py <nl> ppp b / tests / integration / test_recovery_replica / test . py <nl> def fill_nodes ( nodes , shard ) : <nl> for node in nodes : <nl> node . query ( <nl> ' ' ' <nl> - CREATE DATABASE test ; <nl> - <nl> CREATE TABLE test_table ( date Date , id UInt32 ) <nl> - ENGINE = ReplicatedMergeTree ( ' / clickhouse / tables / test { shard } / replicated ' , ' { replica } ' ) ORDER BY id PARTITION BY toYYYYMM ( date ) SETTINGS min_replicated_logs_to_keep = 3 , max_replicated_logs_to_keep = 5 , cleanup_delay_period = 0 , cleanup_delay_period_random_add = 0 ; <nl> + ENGINE = ReplicatedMergeTree ( ' / clickhouse / tables / test / replicated ' , ' { replica } ' ) ORDER BY id PARTITION BY toYYYYMM ( date ) SETTINGS min_replicated_logs_to_keep = 3 , max_replicated_logs_to_keep = 5 , cleanup_delay_period = 0 , cleanup_delay_period_random_add = 0 ; <nl> ' ' ' . format ( shard = shard , replica = node . name ) ) <nl> <nl> <nl> cluster = ClickHouseCluster ( __file__ ) <nl> - node1 = cluster . add_instance ( ' node1 ' , main_configs = [ ' configs / remote_servers . xml ' ] , with_zookeeper = True ) <nl> - node2 = cluster . add_instance ( ' node2 ' , main_configs = [ ' configs / remote_servers . xml ' ] , with_zookeeper = True ) <nl> + node1 = cluster . add_instance ( ' node1 ' , with_zookeeper = True ) <nl> + node2 = cluster . add_instance ( ' node2 ' , with_zookeeper = True ) <nl> + node3 = cluster . add_instance ( ' node3 ' , with_zookeeper = True ) <nl> <nl> <nl> @ pytest . fixture ( scope = " module " ) <nl> def start_cluster ( ) : <nl> try : <nl> cluster . start ( ) <nl> <nl> - fill_nodes ( [ node1 , node2 ] , 1 ) <nl> + fill_nodes ( [ node1 , node2 , node3 ] , 1 ) <nl> <nl> yield cluster <nl> <nl> def test_recovery ( start_cluster ) : <nl> check_callback = lambda x : len ( node2 . query ( " select * from test_table " ) ) > 0 ) <nl> <nl> assert_eq_with_retry ( node2 , " SELECT count ( * ) FROM test_table " , node1 . query ( " SELECT count ( * ) FROM test_table " ) ) <nl> + lost_marker = " Will mark replica node2 as lost " <nl> + assert node1 . contains_in_log ( lost_marker ) or node3 . contains_in_log ( lost_marker ) <nl> + <nl> + def test_choose_source_replica ( start_cluster ) : <nl> + node3 . query ( " INSERT INTO test_table VALUES ( 2 , 1 ) " ) <nl> + time . sleep ( 1 ) <nl> + node2 . query ( " DETACH TABLE test_table " ) <nl> + node1 . query ( " SYSTEM STOP FETCHES test_table " ) # node1 will have many entries in queue , so node2 will clone node3 <nl> + <nl> + for i in range ( 100 ) : <nl> + node3 . query ( " INSERT INTO test_table VALUES ( 2 , { } ) " . format ( i ) ) <nl> + <nl> + node2 . query_with_retry ( " ATTACH TABLE test_table " , <nl> + check_callback = lambda x : len ( node2 . query ( " select * from test_table " ) ) > 0 ) <nl> + <nl> + node1 . query ( " SYSTEM START FETCHES test_table " ) <nl> + node1 . query ( " SYSTEM SYNC REPLICA test_table " ) <nl> + node2 . query ( " SYSTEM SYNC REPLICA test_table " ) <nl> + <nl> + assert node1 . query ( " SELECT count ( * ) FROM test_table " ) = = node3 . query ( " SELECT count ( * ) FROM test_table " ) <nl> + assert node2 . query ( " SELECT count ( * ) FROM test_table " ) = = node3 . query ( " SELECT count ( * ) FROM test_table " ) <nl> + <nl> + lost_marker = " Will mark replica node2 as lost " <nl> + assert node1 . contains_in_log ( lost_marker ) or node3 . contains_in_log ( lost_marker ) <nl> + assert node2 . contains_in_log ( " Will mimic node3 " ) <nl> + <nl> | Merge pull request from ClickHouse / better_clone_replica | ClickHouse/ClickHouse | 7b5f2b2bb02ac3c59614fe4f5307ba1095ddfa52 | 2020-10-08T20:19:23Z |
mmm a / samples / cpp / OpenEXRimages_HighDynamicRange_Retina_toneMapping . cpp <nl> ppp b / samples / cpp / OpenEXRimages_HighDynamicRange_Retina_toneMapping . cpp <nl> void drawPlot ( const cv : : Mat curve , const std : : string figureTitle , const int lowe <nl> int colorSaturationFactor ; <nl> void callback_saturateColors ( int , void * ) <nl> { <nl> - retina - > setColorSaturation ( true , colorSaturationFactor / 10 . 0f ) ; <nl> + retina - > setColorSaturation ( true , ( float ) colorSaturationFactor ) ; <nl> } <nl> <nl> int main ( int argc , char * argv [ ] ) { <nl> | corrected wrong parameter sent to retina module for color saturation | opencv/opencv | 5de07eb784088acc8132cfb89cbf50b8b8a9e55b | 2011-10-21T08:49:18Z |
mmm a / torch / lib / THNN / generic / LogSoftMax . c <nl> ppp b / torch / lib / THNN / generic / LogSoftMax . c <nl> void THNN_ ( LogSoftMax_updateOutput ) ( <nl> real * output_data = output_data_base + outer_idx * outer_stride + inner_idx ; <nl> <nl> real max_input = - THInf ; <nl> - for ( d = 1 ; d < LOG_SOFTMAX_CAST_TYPE dim_size ; d + + ) <nl> + for ( d = 0 ; d < LOG_SOFTMAX_CAST_TYPE dim_size ; d + + ) <nl> max_input = THMax ( max_input , input_data [ d * dim_stride ] ) ; <nl> <nl> accreal logsum = 0 ; <nl> | Fix LogSoftMax ( ) | pytorch/pytorch | 5795b173dedf42de77f1a589539bec149f7d216f | 2017-10-23T20:40:42Z |
mmm a / filament / src / IndirectLight . cpp <nl> ppp b / filament / src / IndirectLight . cpp <nl> IndirectLight * IndirectLight : : Builder : : build ( Engine & engine ) { <nl> return nullptr ; <nl> } <nl> if ( IBL_INTEGRATION = = IBL_INTEGRATION_IMPORTANCE_SAMPLING ) { <nl> + / / FIXME : this doesn ' t work because IBLs are encoded as RGBM with a gamma of 0 . 5 <nl> + / / this produces mipmap levels that are too dark <nl> mImpl - > mReflectionsMap - > generateMipmaps ( engine ) ; <nl> } <nl> } <nl> mmm a / shaders / src / light_indirect . fs <nl> ppp b / shaders / src / light_indirect . fs <nl> vec3 getReflectedVector ( const PixelParams pixel , const vec3 n ) { <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> <nl> # if IBL_INTEGRATION = = IBL_INTEGRATION_IMPORTANCE_SAMPLING <nl> - vec3 isEvaluateIBL ( const PixelParams pixel , mat3 tangentToWorld , vec3 v , float NoV ) { <nl> - vec3 n = tangentToWorld [ 2 ] ; <nl> + vec3 isEvaluateIBL ( const PixelParams pixel , vec3 n , vec3 v , float NoV ) { <nl> + <nl> + / / TODO : for a true anisotropic brdf , we need a real tangent space <nl> + mat3 tangentToWorld ; <nl> + vec3 up = abs ( n . z ) < 0 . 999 ? vec3 ( 0 . 0 , 0 . 0 , 1 . 0 ) : vec3 ( 1 . 0 , 0 . 0 , 0 . 0 ) ; <nl> + tangentToWorld [ 0 ] = normalize ( cross ( up , n ) ) ; <nl> + tangentToWorld [ 1 ] = cross ( n , tangentToWorld [ 0 ] ) ; <nl> + tangentToWorld [ 2 ] = n ; <nl> + <nl> float linearRoughness = pixel . linearRoughness ; <nl> float a2 = linearRoughness * linearRoughness ; <nl> <nl> vec3 isEvaluateIBL ( const PixelParams pixel , mat3 tangentToWorld , vec3 v , float N <nl> vec3 l = getReflectedVector ( pixel , v , h ) ; <nl> <nl> / / Compute this sample ' s contribution to the brdf <nl> - float NoL = 2 . 0 * cosTheta2 - 1 . 0 ; <nl> + float NoL = dot ( n , l ) ; <nl> if ( NoL > 0 . 0 ) { <nl> float LoH = max ( dot ( l , h ) , 0 . 0 ) ; <nl> float NoH = cosTheta ; <nl> void isEvaluateClearCoatIBL ( const PixelParams pixel , float specularAO , inout vec <nl> # if defined ( MATERIAL_HAS_NORMAL ) | | defined ( MATERIAL_HAS_CLEAR_COAT_NORMAL ) <nl> / / We want to use the geometric normal for the clear coat layer <nl> float clearCoatNoV = abs ( dot ( shading_clearCoatNormal , shading_view ) ) + FLT_EPS ; <nl> - / / compute clear coat tangent space <nl> - mat3 tangentToWorld ; <nl> - vec3 up = abs ( shading_clearCoatNormal . z ) < 0 . 999 ? vec3 ( 0 . 0 , 0 . 0 , 1 . 0 ) : vec3 ( 1 . 0 , 0 . 0 , 0 . 0 ) ; <nl> - tangentToWorld [ 0 ] = normalize ( cross ( up , shading_clearCoatNormal ) ) ; <nl> - tangentToWorld [ 1 ] = cross ( shading_clearCoatNormal , tangentToWorld [ 0 ] ) ; <nl> - tangentToWorld [ 2 ] = shading_clearCoatNormal ; <nl> + vec3 clearCoatNormal = shading_clearCoatNormal ; <nl> # else <nl> float clearCoatNoV = shading_NoV ; <nl> - mat3 tangentToWorld = shading_tangentToWorld ; <nl> + vec3 clearCoatNormal = shading_normal ; <nl> # endif <nl> / / The clear coat layer assumes an IOR of 1 . 5 ( 4 % reflectance ) <nl> float Fc = F_Schlick ( 0 . 04 , 1 . 0 , clearCoatNoV ) * pixel . clearCoat ; <nl> void isEvaluateClearCoatIBL ( const PixelParams pixel , float specularAO , inout vec <nl> p . f0 = vec3 ( 0 . 04 ) ; <nl> p . linearRoughness = p . roughness * p . roughness ; <nl> p . anisotropy = 0 . 0 ; <nl> - Fr + = isEvaluateIBL ( p , tangentToWorld , shading_view , clearCoatNoV ) * ( specularAO * pixel . clearCoat ) ; <nl> + Fr + = isEvaluateIBL ( p , clearCoatNormal , shading_view , clearCoatNoV ) * ( specularAO * pixel . clearCoat ) ; <nl> # endif <nl> } <nl> <nl> void evaluateIBL ( const MaterialInputs material , const PixelParams pixel , inout v <nl> Fr * = specularAO * pixel . energyCompensation ; <nl> evaluateClearCoatIBL ( pixel , specularAO , Fd , Fr ) ; <nl> # elif IBL_INTEGRATION = = IBL_INTEGRATION_IMPORTANCE_SAMPLING <nl> - Fr = isEvaluateIBL ( pixel , shading_tangentToWorld , shading_view , shading_NoV ) ; <nl> + Fr = isEvaluateIBL ( pixel , shading_normal , shading_view , shading_NoV ) ; <nl> Fr * = specularAO * pixel . energyCompensation ; <nl> isEvaluateClearCoatIBL ( pixel , specularAO , Fd , Fr ) ; <nl> # endif <nl> | more important sampling fixes | google/filament | 01a4f563e7aa32aca9aecea9600fd6dd6693e4ed | 2018-09-12T20:30:34Z |
mmm a / Marlin / Marlin . h <nl> ppp b / Marlin / Marlin . h <nl> inline void refresh_cmd_timeout ( ) { previous_cmd_ms = millis ( ) ; } <nl> <nl> extern float homing_feedrate [ ] ; <nl> extern bool axis_relative_modes [ ] ; <nl> - extern int feedmultiply ; <nl> + extern int feedrate_multiplier ; <nl> extern bool volumetric_enabled ; <nl> extern int extruder_multiply [ EXTRUDERS ] ; / / sets extrude multiply factor ( in percent ) for each extruder individually <nl> extern float filament_size [ EXTRUDERS ] ; / / cross - sectional area of filament ( in millimeters ) , typically around 1 . 75 or 2 . 85 , 0 disables the volumetric calculations for the extruder . <nl> extern int fanSpeed ; <nl> extern float retract_recover_length , retract_recover_length_swap , retract_recover_feedrate ; <nl> # endif <nl> <nl> - extern millis_t starttime ; <nl> - extern millis_t stoptime ; <nl> + extern millis_t print_job_start_ms ; <nl> + extern millis_t print_job_stop_ms ; <nl> <nl> / / Handling multiple extruders pins <nl> extern uint8_t active_extruder ; <nl> mmm a / Marlin / Marlin_main . cpp <nl> ppp b / Marlin / Marlin_main . cpp <nl> <nl> # include < SPI . h > <nl> # endif <nl> <nl> - / / look here for descriptions of G - codes : http : / / linuxcnc . org / handbook / gcode / g - code . html <nl> - / / http : / / objects . reprap . org / wiki / Mendel_User_Manual : _RepRapGCodes <nl> - <nl> - / / Implemented Codes <nl> - / / mmmmmmmmmmmmmmmmmm - <nl> - / / G0 - > G1 <nl> - / / G1 - Coordinated Movement X Y Z E <nl> - / / G2 - CW ARC <nl> - / / G3 - CCW ARC <nl> - / / G4 - Dwell S < seconds > or P < milliseconds > <nl> - / / G10 - retract filament according to settings of M207 <nl> - / / G11 - retract recover filament according to settings of M208 <nl> - / / G28 - Home one or more axes <nl> - / / G29 - Detailed Z - Probe , probes the bed at 3 or more points . Will fail if you haven ' t homed yet . <nl> - / / G30 - Single Z Probe , probes bed at current XY location . <nl> - / / G31 - Dock sled ( Z_PROBE_SLED only ) <nl> - / / G32 - Undock sled ( Z_PROBE_SLED only ) <nl> - / / G90 - Use Absolute Coordinates <nl> - / / G91 - Use Relative Coordinates <nl> - / / G92 - Set current position to coordinates given <nl> - <nl> - / / M Codes <nl> - / / M0 - Unconditional stop - Wait for user to press a button on the LCD ( Only if ULTRA_LCD is enabled ) <nl> - / / M1 - Same as M0 <nl> - / / M17 - Enable / Power all stepper motors <nl> - / / M18 - Disable all stepper motors ; same as M84 <nl> - / / M20 - List SD card <nl> - / / M21 - Init SD card <nl> - / / M22 - Release SD card <nl> - / / M23 - Select SD file ( M23 filename . g ) <nl> - / / M24 - Start / resume SD print <nl> - / / M25 - Pause SD print <nl> - / / M26 - Set SD position in bytes ( M26 S12345 ) <nl> - / / M27 - Report SD print status <nl> - / / M28 - Start SD write ( M28 filename . g ) <nl> - / / M29 - Stop SD write <nl> - / / M30 - Delete file from SD ( M30 filename . g ) <nl> - / / M31 - Output time since last M109 or SD card start to serial <nl> - / / M32 - Select file and start SD print ( Can be used _while_ printing from SD card files ) : <nl> - / / syntax " M32 / path / filename # " , or " M32 S < startpos bytes > ! filename # " <nl> - / / Call gcode file : " M32 P ! filename # " and return to caller file after finishing ( similar to # include ) . <nl> - / / The ' # ' is necessary when calling from within sd files , as it stops buffer prereading <nl> - / / M42 - Change pin status via gcode Use M42 Px Sy to set pin x to value y , when omitting Px the onboard led will be used . <nl> - / / M48 - Measure Z_Probe repeatability . M48 [ n # of points ] [ X position ] [ Y position ] [ V_erboseness # ] [ E_ngage Probe ] [ L # of legs of travel ] <nl> - / / M80 - Turn on Power Supply <nl> - / / M81 - Turn off Power Supply <nl> - / / M82 - Set E codes absolute ( default ) <nl> - / / M83 - Set E codes relative while in Absolute Coordinates ( G90 ) mode <nl> - / / M84 - Disable steppers until next move , <nl> - / / or use S < seconds > to specify an inactivity timeout , after which the steppers will be disabled . S0 to disable the timeout . <nl> - / / M85 - Set inactivity shutdown timer with parameter S < seconds > . To disable set zero ( default ) <nl> - / / M92 - Set axis_steps_per_unit - same syntax as G92 <nl> - / / M104 - Set extruder target temp <nl> - / / M105 - Read current temp <nl> - / / M106 - Fan on <nl> - / / M107 - Fan off <nl> - / / M109 - Sxxx Wait for extruder current temp to reach target temp . Waits only when heating <nl> - / / Rxxx Wait for extruder current temp to reach target temp . Waits when heating and cooling <nl> - / / IF AUTOTEMP is enabled , S < mintemp > B < maxtemp > F < factor > . Exit autotemp by any M109 without F <nl> - / / M112 - Emergency stop <nl> - / / M114 - Output current position to serial port <nl> - / / M115 - Capabilities string <nl> - / / M117 - display message <nl> - / / M119 - Output Endstop status to serial port <nl> - / / M120 - Enable endstop detection <nl> - / / M121 - Disable endstop detection <nl> - / / M126 - Solenoid Air Valve Open ( BariCUDA support by jmil ) <nl> - / / M127 - Solenoid Air Valve Closed ( BariCUDA vent to atmospheric pressure by jmil ) <nl> - / / M128 - EtoP Open ( BariCUDA EtoP = electricity to air pressure transducer by jmil ) <nl> - / / M129 - EtoP Closed ( BariCUDA EtoP = electricity to air pressure transducer by jmil ) <nl> - / / M140 - Set bed target temp <nl> - / / M150 - Set BlinkM Color Output R : Red < 0 - 255 > U ( ! ) : Green < 0 - 255 > B : Blue < 0 - 255 > over i2c , G for green does not work . <nl> - / / M190 - Sxxx Wait for bed current temp to reach target temp . Waits only when heating <nl> - / / Rxxx Wait for bed current temp to reach target temp . Waits when heating and cooling <nl> - / / M200 - set filament diameter and set E axis units to cubic millimeters ( use S0 to set back to millimeters ) . : D < millimeters > - <nl> - / / M201 - Set max acceleration in units / s ^ 2 for print moves ( M201 X1000 Y1000 ) <nl> - / / M202 - Set max acceleration in units / s ^ 2 for travel moves ( M202 X1000 Y1000 ) Unused in Marlin ! ! <nl> - / / M203 - Set maximum feedrate that your machine can sustain ( M203 X200 Y200 Z300 E10000 ) in mm / sec <nl> - / / M204 - Set default acceleration : P for Printing moves , R for Retract only ( no X , Y , Z ) moves and T for Travel ( non printing ) moves ( ex . M204 P800 T3000 R9000 ) in mm / sec ^ 2 <nl> - / / M205 - advanced settings : minimum travel speed S = while printing T = travel only , B = minimum segment time X = maximum xy jerk , Z = maximum Z jerk , E = maximum E jerk <nl> - / / M206 - Set additional homing offset <nl> - / / M207 - Set retract length S [ positive mm ] F [ feedrate mm / min ] Z [ additional zlift / hop ] , stays in mm regardless of M200 setting <nl> - / / M208 - Set recover = unretract length S [ positive mm surplus to the M207 S * ] F [ feedrate mm / sec ] <nl> - / / M209 - S < 1 = true / 0 = false > enable automatic retract detect if the slicer did not support G10 / 11 : every normal extrude - only move will be classified as retract depending on the direction . <nl> - / / M218 - Set hotend offset ( in mm ) : T < extruder_number > X < offset_on_X > Y < offset_on_Y > <nl> - / / M220 - Set speed factor override percentage : S < factor in percent > <nl> - / / M221 - Set extrude factor override percentage : S < factor in percent > <nl> - / / M226 - Wait until the specified pin reaches the state required : P < pin number > S < pin state > <nl> - / / M240 - Trigger a camera to take a photograph <nl> - / / M250 - Set LCD contrast C < contrast value > ( value 0 . . 63 ) <nl> - / / M280 - Set servo position absolute . P : servo index , S : angle or microseconds <nl> - / / M300 - Play beep sound S < frequency Hz > P < duration ms > <nl> - / / M301 - Set PID parameters P I and D <nl> - / / M302 - Allow cold extrudes , or set the minimum extrude S < temperature > . <nl> - / / M303 - PID relay autotune S < temperature > sets the target temperature . ( default target temperature = 150C ) <nl> - / / M304 - Set bed PID parameters P I and D <nl> - / / M380 - Activate solenoid on active extruder <nl> - / / M381 - Disable all solenoids <nl> - / / M400 - Finish all moves <nl> - / / M401 - Lower z - probe if present <nl> - / / M402 - Raise z - probe if present <nl> - / / M404 - N < dia in mm > Enter the nominal filament width ( 3mm , 1 . 75mm ) or will display nominal filament width without parameters <nl> - / / M405 - Turn on Filament Sensor extrusion control . Optional D < delay in cm > to set delay in centimeters between sensor and extruder <nl> - / / M406 - Turn off Filament Sensor extrusion control <nl> - / / M407 - Display measured filament diameter <nl> - / / M500 - Store parameters in EEPROM <nl> - / / M501 - Read parameters from EEPROM ( if you need reset them after you changed them temporarily ) . <nl> - / / M502 - Revert to the default " factory settings " . You still need to store them in EEPROM afterwards if you want to . <nl> - / / M503 - Print the current settings ( from memory not from EEPROM ) . Use S0 to leave off headings . <nl> - / / M540 - Use S [ 0 | 1 ] to enable or disable the stop SD card print on endstop hit ( requires ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED ) <nl> - / / M600 - Pause for filament change X [ pos ] Y [ pos ] Z [ relative lift ] E [ initial retract ] L [ later retract distance for removal ] <nl> - / / M665 - Set delta configurations : L < diagonal rod > R < delta radius > S < segments / s > <nl> - / / M666 - Set delta endstop adjustment <nl> - / / M605 - Set dual x - carriage movement mode : S < mode > [ X < duplication x - offset > R < duplication temp offset > ] <nl> - / / M907 - Set digital trimpot motor current using axis codes . <nl> - / / M908 - Control digital trimpot directly . <nl> - / / M350 - Set microstepping mode . <nl> - / / M351 - Toggle MS1 MS2 pins directly . <nl> - <nl> - / / * * * * * * * * * * * * SCARA Specific - This can change to suit future G - code regulations <nl> - / / M360 - SCARA calibration : Move to cal - position ThetaA ( 0 deg calibration ) <nl> - / / M361 - SCARA calibration : Move to cal - position ThetaB ( 90 deg calibration - steps per degree ) <nl> - / / M362 - SCARA calibration : Move to cal - position PsiA ( 0 deg calibration ) <nl> - / / M363 - SCARA calibration : Move to cal - position PsiB ( 90 deg calibration - steps per degree ) <nl> - / / M364 - SCARA calibration : Move to cal - position PSIC ( 90 deg to Theta calibration position ) <nl> - / / M365 - SCARA calibration : Scaling factor , X , Y , Z axis <nl> - / / * * * * * * * * * * * * * SCARA End * * * * * * * * * * * * * * * <nl> - <nl> - / / M928 - Start SD logging ( M928 filename . g ) - ended by M29 <nl> - / / M999 - Restart after being stopped by error <nl> + / * * <nl> + * Look here for descriptions of G - codes : <nl> + * - http : / / linuxcnc . org / handbook / gcode / g - code . html <nl> + * - http : / / objects . reprap . org / wiki / Mendel_User_Manual : _RepRapGCodes <nl> + * <nl> + * Help us document these G - codes online : <nl> + * - http : / / reprap . org / wiki / G - code <nl> + * - https : / / github . com / MarlinFirmware / Marlin / wiki / Marlin - G - Code <nl> + * / <nl> + <nl> + / * * <nl> + * Implemented Codes <nl> + * mmmmmmmmmmmmmmmmmm - <nl> + * <nl> + * " G " Codes <nl> + * <nl> + * G0 - > G1 <nl> + * G1 - Coordinated Movement X Y Z E <nl> + * G2 - CW ARC <nl> + * G3 - CCW ARC <nl> + * G4 - Dwell S < seconds > or P < milliseconds > <nl> + * G10 - retract filament according to settings of M207 <nl> + * G11 - retract recover filament according to settings of M208 <nl> + * G28 - Home one or more axes <nl> + * G29 - Detailed Z - Probe , probes the bed at 3 or more points . Will fail if you haven ' t homed yet . <nl> + * G30 - Single Z Probe , probes bed at current XY location . <nl> + * G31 - Dock sled ( Z_PROBE_SLED only ) <nl> + * G32 - Undock sled ( Z_PROBE_SLED only ) <nl> + * G90 - Use Absolute Coordinates <nl> + * G91 - Use Relative Coordinates <nl> + * G92 - Set current position to coordinates given <nl> + * <nl> + * " M " Codes <nl> + * <nl> + * M0 - Unconditional stop - Wait for user to press a button on the LCD ( Only if ULTRA_LCD is enabled ) <nl> + * M1 - Same as M0 <nl> + * M17 - Enable / Power all stepper motors <nl> + * M18 - Disable all stepper motors ; same as M84 <nl> + * M20 - List SD card <nl> + * M21 - Init SD card <nl> + * M22 - Release SD card <nl> + * M23 - Select SD file ( M23 filename . g ) <nl> + * M24 - Start / resume SD print <nl> + * M25 - Pause SD print <nl> + * M26 - Set SD position in bytes ( M26 S12345 ) <nl> + * M27 - Report SD print status <nl> + * M28 - Start SD write ( M28 filename . g ) <nl> + * M29 - Stop SD write <nl> + * M30 - Delete file from SD ( M30 filename . g ) <nl> + * M31 - Output time since last M109 or SD card start to serial <nl> + * M32 - Select file and start SD print ( Can be used _while_ printing from SD card files ) : <nl> + * syntax " M32 / path / filename # " , or " M32 S < startpos bytes > ! filename # " <nl> + * Call gcode file : " M32 P ! filename # " and return to caller file after finishing ( similar to # include ) . <nl> + * The ' # ' is necessary when calling from within sd files , as it stops buffer prereading <nl> + * M42 - Change pin status via gcode Use M42 Px Sy to set pin x to value y , when omitting Px the onboard led will be used . <nl> + * M48 - Measure Z_Probe repeatability . M48 [ n # of points ] [ X position ] [ Y position ] [ V_erboseness # ] [ E_ngage Probe ] [ L # of legs of travel ] <nl> + * M80 - Turn on Power Supply <nl> + * M81 - Turn off Power Supply <nl> + * M82 - Set E codes absolute ( default ) <nl> + * M83 - Set E codes relative while in Absolute Coordinates ( G90 ) mode <nl> + * M84 - Disable steppers until next move , <nl> + * or use S < seconds > to specify an inactivity timeout , after which the steppers will be disabled . S0 to disable the timeout . <nl> + * M85 - Set inactivity shutdown timer with parameter S < seconds > . To disable set zero ( default ) <nl> + * M92 - Set axis_steps_per_unit - same syntax as G92 <nl> + * M104 - Set extruder target temp <nl> + * M105 - Read current temp <nl> + * M106 - Fan on <nl> + * M107 - Fan off <nl> + * M109 - Sxxx Wait for extruder current temp to reach target temp . Waits only when heating <nl> + * Rxxx Wait for extruder current temp to reach target temp . Waits when heating and cooling <nl> + * IF AUTOTEMP is enabled , S < mintemp > B < maxtemp > F < factor > . Exit autotemp by any M109 without F <nl> + * M112 - Emergency stop <nl> + * M114 - Output current position to serial port <nl> + * M115 - Capabilities string <nl> + * M117 - display message <nl> + * M119 - Output Endstop status to serial port <nl> + * M120 - Enable endstop detection <nl> + * M121 - Disable endstop detection <nl> + * M126 - Solenoid Air Valve Open ( BariCUDA support by jmil ) <nl> + * M127 - Solenoid Air Valve Closed ( BariCUDA vent to atmospheric pressure by jmil ) <nl> + * M128 - EtoP Open ( BariCUDA EtoP = electricity to air pressure transducer by jmil ) <nl> + * M129 - EtoP Closed ( BariCUDA EtoP = electricity to air pressure transducer by jmil ) <nl> + * M140 - Set bed target temp <nl> + * M150 - Set BlinkM Color Output R : Red < 0 - 255 > U ( ! ) : Green < 0 - 255 > B : Blue < 0 - 255 > over i2c , G for green does not work . <nl> + * M190 - Sxxx Wait for bed current temp to reach target temp . Waits only when heating <nl> + * Rxxx Wait for bed current temp to reach target temp . Waits when heating and cooling <nl> + * M200 - set filament diameter and set E axis units to cubic millimeters ( use S0 to set back to millimeters ) . : D < millimeters > - <nl> + * M201 - Set max acceleration in units / s ^ 2 for print moves ( M201 X1000 Y1000 ) <nl> + * M202 - Set max acceleration in units / s ^ 2 for travel moves ( M202 X1000 Y1000 ) Unused in Marlin ! ! <nl> + * M203 - Set maximum feedrate that your machine can sustain ( M203 X200 Y200 Z300 E10000 ) in mm / sec <nl> + * M204 - Set default acceleration : P for Printing moves , R for Retract only ( no X , Y , Z ) moves and T for Travel ( non printing ) moves ( ex . M204 P800 T3000 R9000 ) in mm / sec ^ 2 <nl> + * M205 - advanced settings : minimum travel speed S = while printing T = travel only , B = minimum segment time X = maximum xy jerk , Z = maximum Z jerk , E = maximum E jerk <nl> + * M206 - Set additional homing offset <nl> + * M207 - Set retract length S [ positive mm ] F [ feedrate mm / min ] Z [ additional zlift / hop ] , stays in mm regardless of M200 setting <nl> + * M208 - Set recover = unretract length S [ positive mm surplus to the M207 S * ] F [ feedrate mm / sec ] <nl> + * M209 - S < 1 = true / 0 = false > enable automatic retract detect if the slicer did not support G10 / 11 : every normal extrude - only move will be classified as retract depending on the direction . <nl> + * M218 - Set hotend offset ( in mm ) : T < extruder_number > X < offset_on_X > Y < offset_on_Y > <nl> + * M220 - Set speed factor override percentage : S < factor in percent > <nl> + * M221 - Set extrude factor override percentage : S < factor in percent > <nl> + * M226 - Wait until the specified pin reaches the state required : P < pin number > S < pin state > <nl> + * M240 - Trigger a camera to take a photograph <nl> + * M250 - Set LCD contrast C < contrast value > ( value 0 . . 63 ) <nl> + * M280 - Set servo position absolute . P : servo index , S : angle or microseconds <nl> + * M300 - Play beep sound S < frequency Hz > P < duration ms > <nl> + * M301 - Set PID parameters P I and D <nl> + * M302 - Allow cold extrudes , or set the minimum extrude S < temperature > . <nl> + * M303 - PID relay autotune S < temperature > sets the target temperature . ( default target temperature = 150C ) <nl> + * M304 - Set bed PID parameters P I and D <nl> + * M380 - Activate solenoid on active extruder <nl> + * M381 - Disable all solenoids <nl> + * M400 - Finish all moves <nl> + * M401 - Lower z - probe if present <nl> + * M402 - Raise z - probe if present <nl> + * M404 - N < dia in mm > Enter the nominal filament width ( 3mm , 1 . 75mm ) or will display nominal filament width without parameters <nl> + * M405 - Turn on Filament Sensor extrusion control . Optional D < delay in cm > to set delay in centimeters between sensor and extruder <nl> + * M406 - Turn off Filament Sensor extrusion control <nl> + * M407 - Display measured filament diameter <nl> + * M500 - Store parameters in EEPROM <nl> + * M501 - Read parameters from EEPROM ( if you need reset them after you changed them temporarily ) . <nl> + * M502 - Revert to the default " factory settings " . You still need to store them in EEPROM afterwards if you want to . <nl> + * M503 - Print the current settings ( from memory not from EEPROM ) . Use S0 to leave off headings . <nl> + * M540 - Use S [ 0 | 1 ] to enable or disable the stop SD card print on endstop hit ( requires ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED ) <nl> + * M600 - Pause for filament change X [ pos ] Y [ pos ] Z [ relative lift ] E [ initial retract ] L [ later retract distance for removal ] <nl> + * M665 - Set delta configurations : L < diagonal rod > R < delta radius > S < segments / s > <nl> + * M666 - Set delta endstop adjustment <nl> + * M605 - Set dual x - carriage movement mode : S < mode > [ X < duplication x - offset > R < duplication temp offset > ] <nl> + * M907 - Set digital trimpot motor current using axis codes . <nl> + * M908 - Control digital trimpot directly . <nl> + * M350 - Set microstepping mode . <nl> + * M351 - Toggle MS1 MS2 pins directly . <nl> + * <nl> + * * * * * * * * * * * * * SCARA Specific - This can change to suit future G - code regulations <nl> + * M360 - SCARA calibration : Move to cal - position ThetaA ( 0 deg calibration ) <nl> + * M361 - SCARA calibration : Move to cal - position ThetaB ( 90 deg calibration - steps per degree ) <nl> + * M362 - SCARA calibration : Move to cal - position PsiA ( 0 deg calibration ) <nl> + * M363 - SCARA calibration : Move to cal - position PsiB ( 90 deg calibration - steps per degree ) <nl> + * M364 - SCARA calibration : Move to cal - position PSIC ( 90 deg to Theta calibration position ) <nl> + * M365 - SCARA calibration : Scaling factor , X , Y , Z axis <nl> + * * * * * * * * * * * * * * SCARA End * * * * * * * * * * * * * * * <nl> + * <nl> + * M928 - Start SD logging ( M928 filename . g ) - ended by M29 <nl> + * M999 - Restart after being stopped by error <nl> + * / <nl> <nl> # ifdef SDSUPPORT <nl> CardReader card ; <nl> static float destination [ NUM_AXIS ] = { 0 . 0 } ; <nl> bool axis_known_position [ 3 ] = { false } ; <nl> <nl> static long gcode_N , gcode_LastN , Stopped_gcode_LastN = 0 ; <nl> - static char cmdbuffer [ BUFSIZE ] [ MAX_CMD_SIZE ] ; <nl> + <nl> + static int cmd_queue_index_r = 0 ; <nl> + static int cmd_queue_index_w = 0 ; <nl> + static int commands_in_queue = 0 ; <nl> + static char command_queue [ BUFSIZE ] [ MAX_CMD_SIZE ] ; <nl> <nl> float homing_feedrate [ ] = HOMING_FEEDRATE ; <nl> bool axis_relative_modes [ ] = AXIS_RELATIVE_MODES ; <nl> - int feedmultiply = 100 ; / / 100 - > 1 200 - > 2 <nl> - int saved_feedmultiply ; <nl> + int feedrate_multiplier = 100 ; / / 100 - > 1 200 - > 2 <nl> + int saved_feedrate_multiplier ; <nl> int extruder_multiply [ EXTRUDERS ] = ARRAY_BY_EXTRUDERS ( 100 , 100 , 100 , 100 ) ; <nl> bool volumetric_enabled = false ; <nl> float filament_size [ EXTRUDERS ] = ARRAY_BY_EXTRUDERS ( DEFAULT_NOMINAL_FILAMENT_DIA , DEFAULT_NOMINAL_FILAMENT_DIA , DEFAULT_NOMINAL_FILAMENT_DIA , DEFAULT_NOMINAL_FILAMENT_DIA ) ; <nl> const char axis_codes [ NUM_AXIS ] = { ' X ' , ' Y ' , ' Z ' , ' E ' } ; <nl> <nl> static float offset [ 3 ] = { 0 } ; <nl> static bool relative_mode = false ; / / Determines Absolute or Relative Coordinates <nl> - static int bufindr = 0 ; <nl> - static int bufindw = 0 ; <nl> - static int buflen = 0 ; <nl> static char serial_char ; <nl> static int serial_count = 0 ; <nl> static boolean comment_mode = false ; <nl> const int sensitive_pins [ ] = SENSITIVE_PINS ; / / / < Sensitive pin list for M42 <nl> millis_t previous_cmd_ms = 0 ; <nl> static millis_t max_inactive_time = 0 ; <nl> static millis_t stepper_inactive_time = DEFAULT_STEPPER_DEACTIVE_TIME * 1000L ; <nl> - millis_t starttime = 0 ; / / / < Print job start time <nl> - millis_t stoptime = 0 ; / / / < Print job stop time <nl> + millis_t print_job_start_ms = 0 ; / / / < Print job start time <nl> + millis_t print_job_stop_ms = 0 ; / / / < Print job stop time <nl> static uint8_t target_extruder ; <nl> - bool CooldownNoWait = true ; <nl> + bool no_wait_for_cooling = true ; <nl> bool target_direction ; <nl> <nl> # ifdef ENABLE_AUTO_BED_LEVELING <nl> bool target_direction ; <nl> # endif <nl> <nl> # ifdef FILAMENT_RUNOUT_SENSOR <nl> - static bool filrunoutEnqued = false ; <nl> + static bool filrunoutEnqueued = false ; <nl> # endif <nl> <nl> # ifdef SDSUPPORT <nl> void serial_echopair_P ( const char * s_P , unsigned long v ) { serialprintPGM ( s_P ) ; <nl> } <nl> # endif / / ! SDSUPPORT <nl> <nl> - / / Injects the next command from the pending sequence of commands , when possible <nl> - / / Return false if and only if no command was pending <nl> + / * * <nl> + * Inject the next command from the command queue , when possible <nl> + * Return false only if no command was pending <nl> + * / <nl> static bool drain_queued_commands_P ( ) { <nl> if ( ! queued_commands_P ) return false ; <nl> <nl> static bool drain_queued_commands_P ( ) { <nl> char c ; <nl> while ( ( c = cmd [ i ] ) & & c ! = ' \ n ' ) i + + ; / / find the end of this gcode command <nl> cmd [ i ] = ' \ 0 ' ; <nl> - if ( enqueuecommand ( cmd ) ) { / / buffer was not full ( else we will retry later ) <nl> + if ( enqueuecommand ( cmd ) ) { / / buffer was not full ( else we will retry later ) <nl> if ( c ) <nl> queued_commands_P + = i + 1 ; / / move to next command <nl> else <nl> static bool drain_queued_commands_P ( ) { <nl> return true ; <nl> } <nl> <nl> - / / Record one or many commands to run from program memory . <nl> - / / Aborts the current queue , if any . <nl> - / / Note : drain_queued_commands_P ( ) must be called repeatedly to drain the commands afterwards <nl> + / * * <nl> + * Record one or many commands to run from program memory . <nl> + * Aborts the current queue , if any . <nl> + * Note : drain_queued_commands_P ( ) must be called repeatedly to drain the commands afterwards <nl> + * / <nl> void enqueuecommands_P ( const char * pgcode ) { <nl> - queued_commands_P = pgcode ; <nl> - drain_queued_commands_P ( ) ; / / first command executed asap ( when possible ) <nl> + queued_commands_P = pgcode ; <nl> + drain_queued_commands_P ( ) ; / / first command executed asap ( when possible ) <nl> } <nl> <nl> - / / adds a single command to the main command buffer , from RAM <nl> - / / that is really done in a non - safe way . <nl> - / / needs overworking someday <nl> - / / Returns false if it failed to do so <nl> - bool enqueuecommand ( const char * cmd ) <nl> - { <nl> - if ( * cmd = = ' ; ' ) <nl> - return false ; <nl> - if ( buflen > = BUFSIZE ) <nl> - return false ; <nl> - / / this is dangerous if a mixing of serial and this happens <nl> - strcpy ( & ( cmdbuffer [ bufindw ] [ 0 ] ) , cmd ) ; <nl> + / * * <nl> + * Copy a command directly into the main command buffer , from RAM . <nl> + * <nl> + * This is done in a non - safe way and needs a rework someday . <nl> + * Returns false if it doesn ' t add any command <nl> + * / <nl> + bool enqueuecommand ( const char * cmd ) { <nl> + <nl> + if ( * cmd = = ' ; ' | | commands_in_queue > = BUFSIZE ) return false ; <nl> + <nl> + / / This is dangerous if a mixing of serial and this happens <nl> + char * command = command_queue [ cmd_queue_index_w ] ; <nl> + strcpy ( command , cmd ) ; <nl> SERIAL_ECHO_START ; <nl> - SERIAL_ECHOPGM ( MSG_Enqueing ) ; <nl> - SERIAL_ECHO ( cmdbuffer [ bufindw ] ) ; <nl> + SERIAL_ECHOPGM ( MSG_Enqueueing ) ; <nl> + SERIAL_ECHO ( command ) ; <nl> SERIAL_ECHOLNPGM ( " \ " " ) ; <nl> - bufindw = ( bufindw + 1 ) % BUFSIZE ; <nl> - buflen + = 1 ; <nl> + cmd_queue_index_w = ( cmd_queue_index_w + 1 ) % BUFSIZE ; <nl> + commands_in_queue + + ; <nl> return true ; <nl> } <nl> <nl> - void setup_killpin ( ) <nl> - { <nl> + void setup_killpin ( ) { <nl> # if HAS_KILL <nl> SET_INPUT ( KILL_PIN ) ; <nl> WRITE ( KILL_PIN , HIGH ) ; <nl> # endif <nl> } <nl> <nl> - void setup_filrunoutpin ( ) <nl> - { <nl> + void setup_filrunoutpin ( ) { <nl> # if HAS_FILRUNOUT <nl> pinMode ( FILRUNOUT_PIN , INPUT ) ; <nl> # ifdef ENDSTOPPULLUP_FIL_RUNOUT <nl> void setup_filrunoutpin ( ) <nl> } <nl> <nl> / / Set home pin <nl> - void setup_homepin ( void ) <nl> - { <nl> + void setup_homepin ( void ) { <nl> # if HAS_HOME <nl> SET_INPUT ( HOME_PIN ) ; <nl> WRITE ( HOME_PIN , HIGH ) ; <nl> void setup_homepin ( void ) <nl> } <nl> <nl> <nl> - void setup_photpin ( ) <nl> - { <nl> + void setup_photpin ( ) { <nl> # if HAS_PHOTOGRAPH <nl> OUT_WRITE ( PHOTOGRAPH_PIN , LOW ) ; <nl> # endif <nl> } <nl> <nl> - void setup_powerhold ( ) <nl> - { <nl> + void setup_powerhold ( ) { <nl> # if HAS_SUICIDE <nl> OUT_WRITE ( SUICIDE_PIN , HIGH ) ; <nl> # endif <nl> void setup_powerhold ( ) <nl> # endif <nl> } <nl> <nl> - void suicide ( ) <nl> - { <nl> + void suicide ( ) { <nl> # if HAS_SUICIDE <nl> OUT_WRITE ( SUICIDE_PIN , LOW ) ; <nl> # endif <nl> } <nl> <nl> - void servo_init ( ) <nl> - { <nl> + void servo_init ( ) { <nl> # if NUM_SERVOS > = 1 & & HAS_SERVO_0 <nl> servos [ 0 ] . attach ( SERVO0_PIN ) ; <nl> # endif <nl> void servo_init ( ) <nl> # endif <nl> } <nl> <nl> + / * * <nl> + * Marlin entry - point : Set up before the program loop <nl> + * - Set up the kill pin , filament runout , power hold <nl> + * - Start the serial port <nl> + * - Print startup messages and diagnostics <nl> + * - Get EEPROM or default settings <nl> + * - Initialize managers for : <nl> + * • temperature <nl> + * • planner <nl> + * • watchdog <nl> + * • stepper <nl> + * • photo pin <nl> + * • servos <nl> + * • LCD controller <nl> + * • Digipot I2C <nl> + * • Z probe sled <nl> + * • status LEDs <nl> + * / <nl> void setup ( ) { <nl> setup_killpin ( ) ; <nl> setup_filrunoutpin ( ) ; <nl> void setup ( ) { <nl> <nl> # ifdef SDSUPPORT <nl> for ( int8_t i = 0 ; i < BUFSIZE ; i + + ) fromsd [ i ] = false ; <nl> - # endif / / ! SDSUPPORT <nl> + # endif <nl> <nl> / / loads data from EEPROM if available else uses defaults ( and resets step acceleration rate ) <nl> Config_RetrieveSettings ( ) ; <nl> void setup ( ) { <nl> # endif <nl> } <nl> <nl> - <nl> + / * * <nl> + * The main Marlin program loop <nl> + * <nl> + * - Save or log commands to SD <nl> + * - Process available commands ( if not saving ) <nl> + * - Call heater manager <nl> + * - Call inactivity manager <nl> + * - Call endstop manager <nl> + * - Call LCD update <nl> + * / <nl> void loop ( ) { <nl> - if ( buflen < BUFSIZE - 1 ) get_command ( ) ; <nl> + if ( commands_in_queue < BUFSIZE - 1 ) get_command ( ) ; <nl> <nl> # ifdef SDSUPPORT <nl> card . checkautostart ( false ) ; <nl> # endif <nl> <nl> - if ( buflen ) { <nl> + if ( commands_in_queue ) { <nl> + <nl> # ifdef SDSUPPORT <nl> + <nl> if ( card . saving ) { <nl> - if ( strstr_P ( cmdbuffer [ bufindr ] , PSTR ( " M29 " ) ) = = NULL ) { <nl> - card . write_command ( cmdbuffer [ bufindr ] ) ; <nl> + char * command = command_queue [ cmd_queue_index_r ] ; <nl> + if ( strstr_P ( command , PSTR ( " M29 " ) ) ) { <nl> + / / M29 closes the file <nl> + card . closefile ( ) ; <nl> + SERIAL_PROTOCOLLNPGM ( MSG_FILE_SAVED ) ; <nl> + } <nl> + else { <nl> + / / Write the string from the read buffer to SD <nl> + card . write_command ( command ) ; <nl> if ( card . logging ) <nl> - process_commands ( ) ; <nl> + process_commands ( ) ; / / The card is saving because it ' s logging <nl> else <nl> SERIAL_PROTOCOLLNPGM ( MSG_OK ) ; <nl> } <nl> - else { <nl> - card . closefile ( ) ; <nl> - SERIAL_PROTOCOLLNPGM ( MSG_FILE_SAVED ) ; <nl> - } <nl> } <nl> else <nl> process_commands ( ) ; <nl> + <nl> # else <nl> + <nl> process_commands ( ) ; <nl> + <nl> # endif / / SDSUPPORT <nl> - buflen - - ; <nl> - bufindr = ( bufindr + 1 ) % BUFSIZE ; <nl> + <nl> + commands_in_queue - - ; <nl> + cmd_queue_index_r = ( cmd_queue_index_r + 1 ) % BUFSIZE ; <nl> } <nl> / / Check heater every n milliseconds <nl> manage_heater ( ) ; <nl> void loop ( ) { <nl> lcd_update ( ) ; <nl> } <nl> <nl> + / * * <nl> + * Add to the circular command queue the next command from : <nl> + * - The command - injection queue ( queued_commands_P ) <nl> + * - The active serial input ( usually USB ) <nl> + * - The SD card file being actively printed <nl> + * / <nl> void get_command ( ) { <nl> <nl> if ( drain_queued_commands_P ( ) ) return ; / / priority is given to non - serial commands <nl> <nl> - while ( MYSERIAL . available ( ) > 0 & & buflen < BUFSIZE ) { <nl> + while ( MYSERIAL . available ( ) > 0 & & commands_in_queue < BUFSIZE ) { <nl> + <nl> serial_char = MYSERIAL . read ( ) ; <nl> + <nl> if ( serial_char = = ' \ n ' | | serial_char = = ' \ r ' | | <nl> serial_count > = ( MAX_CMD_SIZE - 1 ) <nl> ) { <nl> void get_command ( ) { <nl> <nl> if ( ! serial_count ) return ; / / shortcut for empty lines <nl> <nl> - cmdbuffer [ bufindw ] [ serial_count ] = 0 ; / / terminate string <nl> + char * command = command_queue [ cmd_queue_index_w ] ; <nl> + command [ serial_count ] = 0 ; / / terminate string <nl> <nl> # ifdef SDSUPPORT <nl> - fromsd [ bufindw ] = false ; <nl> + fromsd [ cmd_queue_index_w ] = false ; <nl> # endif <nl> <nl> - if ( strchr ( cmdbuffer [ bufindw ] , ' N ' ) ! = NULL ) { <nl> - strchr_pointer = strchr ( cmdbuffer [ bufindw ] , ' N ' ) ; <nl> + if ( strchr ( command , ' N ' ) ! = NULL ) { <nl> + strchr_pointer = strchr ( command , ' N ' ) ; <nl> gcode_N = ( strtol ( strchr_pointer + 1 , NULL , 10 ) ) ; <nl> - if ( gcode_N ! = gcode_LastN + 1 & & strstr_P ( cmdbuffer [ bufindw ] , PSTR ( " M110 " ) ) = = NULL ) { <nl> + if ( gcode_N ! = gcode_LastN + 1 & & strstr_P ( command , PSTR ( " M110 " ) ) = = NULL ) { <nl> SERIAL_ERROR_START ; <nl> SERIAL_ERRORPGM ( MSG_ERR_LINE_NO ) ; <nl> SERIAL_ERRORLN ( gcode_LastN ) ; <nl> void get_command ( ) { <nl> return ; <nl> } <nl> <nl> - if ( strchr ( cmdbuffer [ bufindw ] , ' * ' ) ! = NULL ) { <nl> + if ( strchr ( command , ' * ' ) ! = NULL ) { <nl> byte checksum = 0 ; <nl> byte count = 0 ; <nl> - while ( cmdbuffer [ bufindw ] [ count ] ! = ' * ' ) checksum ^ = cmdbuffer [ bufindw ] [ count + + ] ; <nl> - strchr_pointer = strchr ( cmdbuffer [ bufindw ] , ' * ' ) ; <nl> + while ( command [ count ] ! = ' * ' ) checksum ^ = command [ count + + ] ; <nl> + strchr_pointer = strchr ( command , ' * ' ) ; <nl> <nl> if ( strtol ( strchr_pointer + 1 , NULL , 10 ) ! = checksum ) { <nl> SERIAL_ERROR_START ; <nl> void get_command ( ) { <nl> / / if no errors , continue parsing <nl> } <nl> else { / / if we don ' t receive ' N ' but still see ' * ' <nl> - if ( ( strchr ( cmdbuffer [ bufindw ] , ' * ' ) ! = NULL ) ) { <nl> + if ( ( strchr ( command , ' * ' ) ! = NULL ) ) { <nl> SERIAL_ERROR_START ; <nl> SERIAL_ERRORPGM ( MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM ) ; <nl> SERIAL_ERRORLN ( gcode_LastN ) ; <nl> void get_command ( ) { <nl> } <nl> } <nl> <nl> - if ( strchr ( cmdbuffer [ bufindw ] , ' G ' ) ! = NULL ) { <nl> - strchr_pointer = strchr ( cmdbuffer [ bufindw ] , ' G ' ) ; <nl> + if ( strchr ( command , ' G ' ) ! = NULL ) { <nl> + strchr_pointer = strchr ( command , ' G ' ) ; <nl> switch ( strtol ( strchr_pointer + 1 , NULL , 10 ) ) { <nl> case 0 : <nl> case 1 : <nl> void get_command ( ) { <nl> } <nl> <nl> / / If command was e - stop process now <nl> - if ( strcmp ( cmdbuffer [ bufindw ] , " M112 " ) = = 0 ) kill ( ) ; <nl> + if ( strcmp ( command , " M112 " ) = = 0 ) kill ( ) ; <nl> <nl> - bufindw = ( bufindw + 1 ) % BUFSIZE ; <nl> - buflen + = 1 ; <nl> + cmd_queue_index_w = ( cmd_queue_index_w + 1 ) % BUFSIZE ; <nl> + commands_in_queue + = 1 ; <nl> <nl> serial_count = 0 ; / / clear buffer <nl> } <nl> else if ( serial_char = = ' \ \ ' ) { / / Handle escapes <nl> - if ( MYSERIAL . available ( ) > 0 & & buflen < BUFSIZE ) { <nl> + if ( MYSERIAL . available ( ) > 0 & & commands_in_queue < BUFSIZE ) { <nl> / / if we have one more character , copy it over <nl> serial_char = MYSERIAL . read ( ) ; <nl> - cmdbuffer [ bufindw ] [ serial_count + + ] = serial_char ; <nl> + command_queue [ cmd_queue_index_w ] [ serial_count + + ] = serial_char ; <nl> } <nl> / / otherwise do nothing <nl> } <nl> else { / / its not a newline , carriage return or escape char <nl> if ( serial_char = = ' ; ' ) comment_mode = true ; <nl> - if ( ! comment_mode ) cmdbuffer [ bufindw ] [ serial_count + + ] = serial_char ; <nl> + if ( ! comment_mode ) command_queue [ cmd_queue_index_w ] [ serial_count + + ] = serial_char ; <nl> } <nl> } <nl> <nl> void get_command ( ) { <nl> / / this character _can_ occur in serial com , due to checksums . however , no checksums are used in SD printing <nl> <nl> static bool stop_buffering = false ; <nl> - if ( buflen = = 0 ) stop_buffering = false ; <nl> + if ( commands_in_queue = = 0 ) stop_buffering = false ; <nl> <nl> - while ( ! card . eof ( ) & & buflen < BUFSIZE & & ! stop_buffering ) { <nl> + while ( ! card . eof ( ) & & commands_in_queue < BUFSIZE & & ! stop_buffering ) { <nl> int16_t n = card . get ( ) ; <nl> serial_char = ( char ) n ; <nl> if ( serial_char = = ' \ n ' | | serial_char = = ' \ r ' | | <nl> void get_command ( ) { <nl> ) { <nl> if ( card . eof ( ) ) { <nl> SERIAL_PROTOCOLLNPGM ( MSG_FILE_PRINTED ) ; <nl> - stoptime = millis ( ) ; <nl> + print_job_stop_ms = millis ( ) ; <nl> char time [ 30 ] ; <nl> - millis_t t = ( stoptime - starttime ) / 1000 ; <nl> + millis_t t = ( print_job_stop_ms - print_job_start_ms ) / 1000 ; <nl> int hours = t / 60 / 60 , minutes = ( t / 60 ) % 60 ; <nl> sprintf_P ( time , PSTR ( " % i " MSG_END_HOUR " % i " MSG_END_MINUTE ) , hours , minutes ) ; <nl> SERIAL_ECHO_START ; <nl> void get_command ( ) { <nl> comment_mode = false ; / / for new command <nl> return ; / / if empty line <nl> } <nl> - cmdbuffer [ bufindw ] [ serial_count ] = 0 ; / / terminate string <nl> + command_queue [ cmd_queue_index_w ] [ serial_count ] = 0 ; / / terminate string <nl> / / if ( ! comment_mode ) { <nl> - fromsd [ bufindw ] = true ; <nl> - buflen + = 1 ; <nl> - bufindw = ( bufindw + 1 ) % BUFSIZE ; <nl> + fromsd [ cmd_queue_index_w ] = true ; <nl> + commands_in_queue + = 1 ; <nl> + cmd_queue_index_w = ( cmd_queue_index_w + 1 ) % BUFSIZE ; <nl> / / } <nl> comment_mode = false ; / / for new command <nl> serial_count = 0 ; / / clear buffer <nl> } <nl> else { <nl> if ( serial_char = = ' ; ' ) comment_mode = true ; <nl> - if ( ! comment_mode ) cmdbuffer [ bufindw ] [ serial_count + + ] = serial_char ; <nl> + if ( ! comment_mode ) command_queue [ cmd_queue_index_w ] [ serial_count + + ] = serial_char ; <nl> } <nl> } <nl> <nl> long code_value_long ( ) { return strtol ( strchr_pointer + 1 , NULL , 10 ) ; } <nl> int16_t code_value_short ( ) { return ( int16_t ) strtol ( strchr_pointer + 1 , NULL , 10 ) ; } <nl> <nl> bool code_seen ( char code ) { <nl> - strchr_pointer = strchr ( cmdbuffer [ bufindr ] , code ) ; <nl> + strchr_pointer = strchr ( command_queue [ cmd_queue_index_r ] , code ) ; <nl> return ( strchr_pointer ! = NULL ) ; / / Return True if a character was found <nl> } <nl> <nl> inline void set_destination_to_current ( ) { memcpy ( destination , current_position , <nl> void prepare_move_raw ( ) { <nl> refresh_cmd_timeout ( ) ; <nl> calculate_delta ( destination ) ; <nl> - plan_buffer_line ( delta [ X_AXIS ] , delta [ Y_AXIS ] , delta [ Z_AXIS ] , destination [ E_AXIS ] , ( feedrate / 60 ) * ( feedmultiply / 100 . 0 ) , active_extruder ) ; <nl> + plan_buffer_line ( delta [ X_AXIS ] , delta [ Y_AXIS ] , delta [ Z_AXIS ] , destination [ E_AXIS ] , ( feedrate / 60 ) * ( feedrate_multiplier / 100 . 0 ) , active_extruder ) ; <nl> set_current_to_destination ( ) ; <nl> } <nl> # endif <nl> inline void set_destination_to_current ( ) { memcpy ( destination , current_position , <nl> <nl> static void setup_for_endstop_move ( ) { <nl> saved_feedrate = feedrate ; <nl> - saved_feedmultiply = feedmultiply ; <nl> - feedmultiply = 100 ; <nl> + saved_feedrate_multiplier = feedrate_multiplier ; <nl> + feedrate_multiplier = 100 ; <nl> refresh_cmd_timeout ( ) ; <nl> enable_endstops ( true ) ; <nl> } <nl> inline void set_destination_to_current ( ) { memcpy ( destination , current_position , <nl> enable_endstops ( false ) ; <nl> # endif <nl> feedrate = saved_feedrate ; <nl> - feedmultiply = saved_feedmultiply ; <nl> + feedrate_multiplier = saved_feedrate_multiplier ; <nl> refresh_cmd_timeout ( ) ; <nl> } <nl> <nl> static void homeaxis ( AxisEnum axis ) { <nl> # define SLED_DOCKING_OFFSET 0 <nl> # endif <nl> <nl> - / / <nl> - / / Method to dock / undock a sled designed by Charles Bell . <nl> - / / <nl> - / / dock [ in ] If true , move to MAX_X and engage the electromagnet <nl> - / / offset [ in ] The additional distance to move to adjust docking location <nl> - / / <nl> + / * * <nl> + * Method to dock / undock a sled designed by Charles Bell . <nl> + * <nl> + * dock [ in ] If true , move to MAX_X and engage the electromagnet <nl> + * offset [ in ] The additional distance to move to adjust docking location <nl> + * / <nl> static void dock_sled ( bool dock , int offset = 0 ) { <nl> if ( ! axis_known_position [ X_AXIS ] | | ! axis_known_position [ Y_AXIS ] ) { <nl> LCD_MESSAGEPGM ( MSG_POSITION_UNKNOWN ) ; <nl> static void homeaxis ( AxisEnum axis ) { <nl> inline void gcode_G0_G1 ( ) { <nl> if ( IsRunning ( ) ) { <nl> get_coordinates ( ) ; / / For X Y Z E F <nl> + <nl> # ifdef FWRETRACT <nl> - if ( autoretract_enabled ) <nl> - if ( ! ( code_seen ( ' X ' ) | | code_seen ( ' Y ' ) | | code_seen ( ' Z ' ) ) & & code_seen ( ' E ' ) ) { <nl> + <nl> + if ( autoretract_enabled & & ! ( code_seen ( ' X ' ) | | code_seen ( ' Y ' ) | | code_seen ( ' Z ' ) ) & & code_seen ( ' E ' ) ) { <nl> float echange = destination [ E_AXIS ] - current_position [ E_AXIS ] ; <nl> / / Is this move an attempt to retract or recover ? <nl> if ( ( echange < - MIN_RETRACT & & ! retracted [ active_extruder ] ) | | ( echange > MIN_RETRACT & & retracted [ active_extruder ] ) ) { <nl> inline void gcode_G0_G1 ( ) { <nl> return ; <nl> } <nl> } <nl> + <nl> # endif / / FWRETRACT <nl> + <nl> prepare_move ( ) ; <nl> / / ClearToSend ( ) ; <nl> } <nl> inline void gcode_G28 ( ) { <nl> # endif <nl> <nl> saved_feedrate = feedrate ; <nl> - saved_feedmultiply = feedmultiply ; <nl> - feedmultiply = 100 ; <nl> + saved_feedrate_multiplier = feedrate_multiplier ; <nl> + feedrate_multiplier = 100 ; <nl> refresh_cmd_timeout ( ) ; <nl> <nl> enable_endstops ( true ) ; <nl> inline void gcode_G28 ( ) { <nl> # endif <nl> <nl> feedrate = saved_feedrate ; <nl> - feedmultiply = saved_feedmultiply ; <nl> + feedrate_multiplier = saved_feedrate_multiplier ; <nl> refresh_cmd_timeout ( ) ; <nl> endstops_hit_on_purpose ( ) ; / / clear endstop hit flags <nl> } <nl> inline void gcode_M17 ( ) { <nl> * / <nl> inline void gcode_M24 ( ) { <nl> card . startFileprint ( ) ; <nl> - starttime = millis ( ) ; <nl> + print_job_start_ms = millis ( ) ; <nl> } <nl> <nl> / * * <nl> inline void gcode_M17 ( ) { <nl> char * codepos = strchr_pointer + 4 ; <nl> char * starpos = strchr ( codepos , ' * ' ) ; <nl> if ( starpos ) { <nl> - char * npos = strchr ( cmdbuffer [ bufindr ] , ' N ' ) ; <nl> + char * npos = strchr ( command_queue [ cmd_queue_index_r ] , ' N ' ) ; <nl> strchr_pointer = strchr ( npos , ' ' ) + 1 ; <nl> * ( starpos ) = ' \ 0 ' ; <nl> } <nl> inline void gcode_M17 ( ) { <nl> card . closefile ( ) ; <nl> char * starpos = strchr ( strchr_pointer + 4 , ' * ' ) ; <nl> if ( starpos ) { <nl> - char * npos = strchr ( cmdbuffer [ bufindr ] , ' N ' ) ; <nl> + char * npos = strchr ( command_queue [ cmd_queue_index_r ] , ' N ' ) ; <nl> strchr_pointer = strchr ( npos , ' ' ) + 1 ; <nl> * ( starpos ) = ' \ 0 ' ; <nl> } <nl> inline void gcode_M17 ( ) { <nl> * M31 : Get the time since the start of SD Print ( or last M109 ) <nl> * / <nl> inline void gcode_M31 ( ) { <nl> - stoptime = millis ( ) ; <nl> - millis_t t = ( stoptime - starttime ) / 1000 ; <nl> + print_job_stop_ms = millis ( ) ; <nl> + millis_t t = ( print_job_stop_ms - print_job_start_ms ) / 1000 ; <nl> int min = t / 60 , sec = t % 60 ; <nl> char time [ 30 ] ; <nl> sprintf_P ( time , PSTR ( " % i min , % i sec " ) , min , sec ) ; <nl> inline void gcode_M31 ( ) { <nl> <nl> card . startFileprint ( ) ; <nl> if ( ! call_procedure ) <nl> - starttime = millis ( ) ; / / procedure calls count as normal print time . <nl> + print_job_start_ms = millis ( ) ; / / procedure calls count as normal print time . <nl> } <nl> } <nl> <nl> inline void gcode_M31 ( ) { <nl> inline void gcode_M928 ( ) { <nl> char * starpos = strchr ( strchr_pointer + 5 , ' * ' ) ; <nl> if ( starpos ) { <nl> - char * npos = strchr ( cmdbuffer [ bufindr ] , ' N ' ) ; <nl> + char * npos = strchr ( command_queue [ cmd_queue_index_r ] , ' N ' ) ; <nl> strchr_pointer = strchr ( npos , ' ' ) + 1 ; <nl> * ( starpos ) = ' \ 0 ' ; <nl> } <nl> inline void gcode_M109 ( ) { <nl> <nl> LCD_MESSAGEPGM ( MSG_HEATING ) ; <nl> <nl> - CooldownNoWait = code_seen ( ' S ' ) ; <nl> - if ( CooldownNoWait | | code_seen ( ' R ' ) ) { <nl> + no_wait_for_cooling = code_seen ( ' S ' ) ; <nl> + if ( no_wait_for_cooling | | code_seen ( ' R ' ) ) { <nl> float temp = code_value ( ) ; <nl> setTargetHotend ( temp , target_extruder ) ; <nl> # ifdef DUAL_X_CARRIAGE <nl> inline void gcode_M109 ( ) { <nl> while ( ( ! cancel_heatup ) & & ( ( residency_start_ms = = - 1 ) | | <nl> ( residency_start_ms > = 0 & & ( ( ( unsigned int ) ( millis ( ) - residency_start_ms ) ) < ( TEMP_RESIDENCY_TIME * 1000UL ) ) ) ) ) <nl> # else <nl> - while ( target_direction ? ( isHeatingHotend ( target_extruder ) ) : ( isCoolingHotend ( target_extruder ) & & ( CooldownNoWait = = false ) ) ) <nl> + while ( target_direction ? ( isHeatingHotend ( target_extruder ) ) : ( isCoolingHotend ( target_extruder ) & & ( no_wait_for_cooling = = false ) ) ) <nl> # endif / / TEMP_RESIDENCY_TIME <nl> <nl> { / / while loop <nl> inline void gcode_M109 ( ) { <nl> <nl> LCD_MESSAGEPGM ( MSG_HEATING_COMPLETE ) ; <nl> refresh_cmd_timeout ( ) ; <nl> - starttime = previous_cmd_ms ; <nl> + print_job_start_ms = previous_cmd_ms ; <nl> } <nl> <nl> # if HAS_TEMP_BED <nl> inline void gcode_M109 ( ) { <nl> * / <nl> inline void gcode_M190 ( ) { <nl> LCD_MESSAGEPGM ( MSG_BED_HEATING ) ; <nl> - CooldownNoWait = code_seen ( ' S ' ) ; <nl> - if ( CooldownNoWait | | code_seen ( ' R ' ) ) <nl> + no_wait_for_cooling = code_seen ( ' S ' ) ; <nl> + if ( no_wait_for_cooling | | code_seen ( ' R ' ) ) <nl> setTargetBed ( code_value ( ) ) ; <nl> <nl> millis_t temp_ms = millis ( ) ; <nl> inline void gcode_M109 ( ) { <nl> cancel_heatup = false ; <nl> target_direction = isHeatingBed ( ) ; / / true if heating , false if cooling <nl> <nl> - while ( ( target_direction ) & & ( ! cancel_heatup ) ? ( isHeatingBed ( ) ) : ( isCoolingBed ( ) & & ( CooldownNoWait = = false ) ) ) { <nl> + while ( ( target_direction & & ! cancel_heatup ) ? isHeatingBed ( ) : isCoolingBed ( ) & & ! no_wait_for_cooling ) { <nl> millis_t ms = millis ( ) ; <nl> if ( ms > temp_ms + 1000UL ) { / / Print Temp Reading every 1 second while heating up . <nl> temp_ms = ms ; <nl> inline void gcode_M140 ( ) { <nl> * This code should ALWAYS be available for EMERGENCY SHUTDOWN ! <nl> * / <nl> inline void gcode_M81 ( ) { <nl> - disable_heater ( ) ; <nl> + disable_all_heaters ( ) ; <nl> st_synchronize ( ) ; <nl> disable_e0 ( ) ; <nl> disable_e1 ( ) ; <nl> inline void gcode_M206 ( ) { <nl> default : <nl> SERIAL_ECHO_START ; <nl> SERIAL_ECHOPGM ( MSG_UNKNOWN_COMMAND ) ; <nl> - SERIAL_ECHO ( cmdbuffer [ bufindr ] ) ; <nl> + SERIAL_ECHO ( command_queue [ cmd_queue_index_r ] ) ; <nl> SERIAL_ECHOLNPGM ( " \ " " ) ; <nl> return ; <nl> } <nl> inline void gcode_M206 ( ) { <nl> * M220 : Set speed percentage factor , aka " Feed Rate " ( M220 S95 ) <nl> * / <nl> inline void gcode_M220 ( ) { <nl> - if ( code_seen ( ' S ' ) ) feedmultiply = code_value ( ) ; <nl> + if ( code_seen ( ' S ' ) ) feedrate_multiplier = code_value ( ) ; <nl> } <nl> <nl> / * * <nl> inline void gcode_M503 ( ) { <nl> # endif <nl> <nl> # ifdef FILAMENT_RUNOUT_SENSOR <nl> - filrunoutEnqued = false ; <nl> + filrunoutEnqueued = false ; <nl> # endif <nl> <nl> } <nl> inline void gcode_M999 ( ) { <nl> FlushSerialRequestResend ( ) ; <nl> } <nl> <nl> + / * * <nl> + * T0 - T3 : Switch tool , usually switching extruders <nl> + * / <nl> inline void gcode_T ( ) { <nl> int tmp_extruder = code_value ( ) ; <nl> if ( tmp_extruder > = EXTRUDERS ) { <nl> void process_commands ( ) { <nl> else { <nl> SERIAL_ECHO_START ; <nl> SERIAL_ECHOPGM ( MSG_UNKNOWN_COMMAND ) ; <nl> - SERIAL_ECHO ( cmdbuffer [ bufindr ] ) ; <nl> + SERIAL_ECHO ( command_queue [ cmd_queue_index_r ] ) ; <nl> SERIAL_ECHOLNPGM ( " \ " " ) ; <nl> } <nl> <nl> void process_commands ( ) { <nl> } <nl> <nl> void FlushSerialRequestResend ( ) { <nl> - / / char cmdbuffer [ bufindr ] [ 100 ] = " Resend : " ; <nl> + / / char command_queue [ cmd_queue_index_r ] [ 100 ] = " Resend : " ; <nl> MYSERIAL . flush ( ) ; <nl> SERIAL_PROTOCOLPGM ( MSG_RESEND ) ; <nl> SERIAL_PROTOCOLLN ( gcode_LastN + 1 ) ; <nl> void FlushSerialRequestResend ( ) { <nl> void ClearToSend ( ) { <nl> refresh_cmd_timeout ( ) ; <nl> # ifdef SDSUPPORT <nl> - if ( fromsd [ bufindr ] ) return ; <nl> + if ( fromsd [ cmd_queue_index_r ] ) return ; <nl> # endif <nl> SERIAL_PROTOCOLLNPGM ( MSG_OK ) ; <nl> } <nl> void prepare_move ( ) { <nl> float cartesian_mm = sqrt ( sq ( difference [ X_AXIS ] ) + sq ( difference [ Y_AXIS ] ) + sq ( difference [ Z_AXIS ] ) ) ; <nl> if ( cartesian_mm < 0 . 000001 ) { cartesian_mm = abs ( difference [ E_AXIS ] ) ; } <nl> if ( cartesian_mm < 0 . 000001 ) { return ; } <nl> - float seconds = 6000 * cartesian_mm / feedrate / feedmultiply ; <nl> + float seconds = 6000 * cartesian_mm / feedrate / feedrate_multiplier ; <nl> int steps = max ( 1 , int ( scara_segments_per_second * seconds ) ) ; <nl> <nl> / / SERIAL_ECHOPGM ( " mm = " ) ; SERIAL_ECHO ( cartesian_mm ) ; <nl> void prepare_move ( ) { <nl> / / SERIAL_ECHOPGM ( " delta [ Y_AXIS ] = " ) ; SERIAL_ECHOLN ( delta [ Y_AXIS ] ) ; <nl> / / SERIAL_ECHOPGM ( " delta [ Z_AXIS ] = " ) ; SERIAL_ECHOLN ( delta [ Z_AXIS ] ) ; <nl> <nl> - plan_buffer_line ( delta [ X_AXIS ] , delta [ Y_AXIS ] , delta [ Z_AXIS ] , destination [ E_AXIS ] , feedrate / 60 * feedmultiply / 100 . 0 , active_extruder ) ; <nl> + plan_buffer_line ( delta [ X_AXIS ] , delta [ Y_AXIS ] , delta [ Z_AXIS ] , destination [ E_AXIS ] , feedrate / 60 * feedrate_multiplier / 100 . 0 , active_extruder ) ; <nl> } <nl> <nl> # endif / / SCARA <nl> void prepare_move ( ) { <nl> float cartesian_mm = sqrt ( sq ( difference [ X_AXIS ] ) + sq ( difference [ Y_AXIS ] ) + sq ( difference [ Z_AXIS ] ) ) ; <nl> if ( cartesian_mm < 0 . 000001 ) cartesian_mm = abs ( difference [ E_AXIS ] ) ; <nl> if ( cartesian_mm < 0 . 000001 ) return ; <nl> - float seconds = 6000 * cartesian_mm / feedrate / feedmultiply ; <nl> + float seconds = 6000 * cartesian_mm / feedrate / feedrate_multiplier ; <nl> int steps = max ( 1 , int ( delta_segments_per_second * seconds ) ) ; <nl> <nl> / / SERIAL_ECHOPGM ( " mm = " ) ; SERIAL_ECHO ( cartesian_mm ) ; <nl> void prepare_move ( ) { <nl> # ifdef ENABLE_AUTO_BED_LEVELING <nl> adjust_delta ( destination ) ; <nl> # endif <nl> - plan_buffer_line ( delta [ X_AXIS ] , delta [ Y_AXIS ] , delta [ Z_AXIS ] , destination [ E_AXIS ] , feedrate / 60 * feedmultiply / 100 . 0 , active_extruder ) ; <nl> + plan_buffer_line ( delta [ X_AXIS ] , delta [ Y_AXIS ] , delta [ Z_AXIS ] , destination [ E_AXIS ] , feedrate / 60 * feedrate_multiplier / 100 . 0 , active_extruder ) ; <nl> } <nl> <nl> # endif / / DELTA <nl> void prepare_move ( ) { <nl> # endif / / DUAL_X_CARRIAGE <nl> <nl> # if ! defined ( DELTA ) & & ! defined ( SCARA ) <nl> - / / Do not use feedmultiply for E or Z only moves <nl> + / / Do not use feedrate_multiplier for E or Z only moves <nl> if ( current_position [ X_AXIS ] = = destination [ X_AXIS ] & & current_position [ Y_AXIS ] = = destination [ Y_AXIS ] ) { <nl> line_to_destination ( ) ; <nl> } <nl> else { <nl> # ifdef MESH_BED_LEVELING <nl> - mesh_plan_buffer_line ( destination [ X_AXIS ] , destination [ Y_AXIS ] , destination [ Z_AXIS ] , destination [ E_AXIS ] , ( feedrate / 60 ) * ( feedmultiply / 100 . 0 ) , active_extruder ) ; <nl> + mesh_plan_buffer_line ( destination [ X_AXIS ] , destination [ Y_AXIS ] , destination [ Z_AXIS ] , destination [ E_AXIS ] , ( feedrate / 60 ) * ( feedrate_multiplier / 100 . 0 ) , active_extruder ) ; <nl> return ; <nl> # else <nl> - line_to_destination ( feedrate * feedmultiply / 100 . 0 ) ; <nl> + line_to_destination ( feedrate * feedrate_multiplier / 100 . 0 ) ; <nl> # endif / / MESH_BED_LEVELING <nl> } <nl> # endif / / ! ( DELTA | | SCARA ) <nl> void prepare_arc_move ( char isclockwise ) { <nl> float r = hypot ( offset [ X_AXIS ] , offset [ Y_AXIS ] ) ; / / Compute arc radius for mc_arc <nl> <nl> / / Trace the arc <nl> - mc_arc ( current_position , destination , offset , X_AXIS , Y_AXIS , Z_AXIS , feedrate * feedmultiply / 60 / 100 . 0 , r , isclockwise , active_extruder ) ; <nl> + mc_arc ( current_position , destination , offset , X_AXIS , Y_AXIS , Z_AXIS , feedrate * feedrate_multiplier / 60 / 100 . 0 , r , isclockwise , active_extruder ) ; <nl> <nl> / / As far as the parser is concerned , the position is now = = target . In reality the <nl> / / motion control system might still be processing the action and the real tool position <nl> void manage_inactivity ( bool ignore_stepper_queue / * = false * / ) { <nl> filrunout ( ) ; <nl> # endif <nl> <nl> - if ( buflen < BUFSIZE - 1 ) get_command ( ) ; <nl> + if ( commands_in_queue < BUFSIZE - 1 ) get_command ( ) ; <nl> <nl> millis_t ms = millis ( ) ; <nl> <nl> void manage_inactivity ( bool ignore_stepper_queue / * = false * / ) { <nl> void kill ( ) <nl> { <nl> cli ( ) ; / / Stop interrupts <nl> - disable_heater ( ) ; <nl> + disable_all_heaters ( ) ; <nl> <nl> disable_all_steppers ( ) ; <nl> <nl> void kill ( ) <nl> } <nl> <nl> # ifdef FILAMENT_RUNOUT_SENSOR <nl> - void filrunout ( ) <nl> - { <nl> - if ( filrunoutEnqued = = false ) { <nl> - filrunoutEnqued = true ; <nl> - enqueuecommand ( " M600 " ) ; <nl> - } <nl> - } <nl> + <nl> + void filrunout ( ) { <nl> + if ( ! filrunoutEnqueued ) { <nl> + filrunoutEnqueued = true ; <nl> + enqueuecommand ( " M600 " ) ; <nl> + } <nl> + } <nl> + <nl> # endif <nl> <nl> - void Stop ( ) <nl> - { <nl> - disable_heater ( ) ; <nl> + void Stop ( ) { <nl> + disable_all_heaters ( ) ; <nl> if ( IsRunning ( ) ) { <nl> Running = false ; <nl> Stopped_gcode_LastN = gcode_LastN ; / / Save last g_code for restart <nl> mmm a / Marlin / configurator / config / language . h <nl> ppp b / Marlin / configurator / config / language . h <nl> <nl> <nl> / / Serial Console Messages ( do not translate those ! ) <nl> <nl> - # define MSG_Enqueing " enqueing \ " " <nl> + # define MSG_Enqueueing " enqueueing \ " " <nl> # define MSG_POWERUP " PowerUp " <nl> # define MSG_EXTERNAL_RESET " External Reset " <nl> # define MSG_BROWNOUT_RESET " Brown out Reset " <nl> mmm a / Marlin / dogm_lcd_implementation . h <nl> ppp b / Marlin / dogm_lcd_implementation . h <nl> static void lcd_implementation_status_screen ( ) { <nl> } <nl> <nl> u8g . setPrintPos ( 80 , 48 ) ; <nl> - if ( starttime ! = 0 ) { <nl> - uint16_t time = ( millis ( ) - starttime ) / 60000 ; <nl> + if ( print_job_start_ms ! = 0 ) { <nl> + uint16_t time = ( millis ( ) - print_job_start_ms ) / 60000 ; <nl> lcd_print ( itostr2 ( time / 60 ) ) ; <nl> lcd_print ( ' : ' ) ; <nl> lcd_print ( itostr2 ( time % 60 ) ) ; <nl> static void lcd_implementation_status_screen ( ) { <nl> lcd_print ( LCD_STR_FEEDRATE [ 0 ] ) ; <nl> lcd_setFont ( FONT_STATUSMENU ) ; <nl> u8g . setPrintPos ( 12 , 49 ) ; <nl> - lcd_print ( itostr3 ( feedmultiply ) ) ; <nl> + lcd_print ( itostr3 ( feedrate_multiplier ) ) ; <nl> lcd_print ( ' % ' ) ; <nl> <nl> / / Status line <nl> mmm a / Marlin / language . h <nl> ppp b / Marlin / language . h <nl> <nl> <nl> / / Serial Console Messages ( do not translate those ! ) <nl> <nl> - # define MSG_Enqueing " enqueing \ " " <nl> + # define MSG_Enqueueing " enqueueing \ " " <nl> # define MSG_POWERUP " PowerUp " <nl> # define MSG_EXTERNAL_RESET " External Reset " <nl> # define MSG_BROWNOUT_RESET " Brown out Reset " <nl> mmm a / Marlin / temperature . cpp <nl> ppp b / Marlin / temperature . cpp <nl> void PID_autotune ( float temp , int extruder , int ncycles ) <nl> <nl> SERIAL_ECHOLN ( MSG_PID_AUTOTUNE_START ) ; <nl> <nl> - disable_heater ( ) ; / / switch off all heaters . <nl> + disable_all_heaters ( ) ; / / switch off all heaters . <nl> <nl> if ( extruder < 0 ) <nl> soft_pwm_bed = bias = d = MAX_BED_POWER / 2 ; <nl> inline void _temp_error ( int e , const char * msg1 , const char * msg2 ) { <nl> } <nl> <nl> void max_temp_error ( uint8_t e ) { <nl> - disable_heater ( ) ; <nl> + disable_all_heaters ( ) ; <nl> _temp_error ( e , PSTR ( MSG_MAXTEMP_EXTRUDER_OFF ) , PSTR ( MSG_ERR_MAXTEMP ) ) ; <nl> } <nl> void min_temp_error ( uint8_t e ) { <nl> - disable_heater ( ) ; <nl> + disable_all_heaters ( ) ; <nl> _temp_error ( e , PSTR ( MSG_MINTEMP_EXTRUDER_OFF ) , PSTR ( MSG_ERR_MINTEMP ) ) ; <nl> } <nl> void bed_max_temp_error ( void ) { <nl> float get_pid_output ( int e ) { <nl> } <nl> # endif <nl> <nl> + / * * <nl> + * Manage heating activities for extruder hot - ends and a heated bed <nl> + * - Acquire updated temperature readings <nl> + * - Invoke thermal runaway protection <nl> + * - Manage extruder auto - fan <nl> + * - Apply filament width to the extrusion rate ( may move ) <nl> + * - Update the heated bed PID output value <nl> + * / <nl> void manage_heater ( ) { <nl> <nl> if ( ! temp_meas_ready ) return ; <nl> void manage_heater ( ) { <nl> <nl> # ifdef TEMP_SENSOR_1_AS_REDUNDANT <nl> if ( fabs ( current_temperature [ 0 ] - redundant_temperature ) > MAX_REDUNDANT_TEMP_SENSOR_DIFF ) { <nl> - disable_heater ( ) ; <nl> + disable_all_heaters ( ) ; <nl> _temp_error ( 0 , PSTR ( MSG_EXTRUDER_SWITCHED_OFF ) , PSTR ( MSG_ERR_REDUNDANT_TEMP ) ) ; <nl> } <nl> # endif / / TEMP_SENSOR_1_AS_REDUNDANT <nl> void manage_heater ( ) { <nl> next_auto_fan_check_ms = ms + 2500 ; <nl> } <nl> # endif <nl> - <nl> + <nl> + / / Control the extruder rate based on the width sensor <nl> + # ifdef FILAMENT_SENSOR <nl> + if ( filament_sensor ) { <nl> + meas_shift_index = delay_index1 - meas_delay_cm ; <nl> + if ( meas_shift_index < 0 ) meas_shift_index + = MAX_MEASUREMENT_DELAY + 1 ; / / loop around buffer if needed <nl> + <nl> + / / Get the delayed info and add 100 to reconstitute to a percent of <nl> + / / the nominal filament diameter then square it to get an area <nl> + meas_shift_index = constrain ( meas_shift_index , 0 , MAX_MEASUREMENT_DELAY ) ; <nl> + float vm = pow ( ( measurement_delay [ meas_shift_index ] + 100 . 0 ) / 100 . 0 , 2 ) ; <nl> + if ( vm < 0 . 01 ) vm = 0 . 01 ; <nl> + volumetric_multiplier [ FILAMENT_SENSOR_EXTRUDER_NUM ] = vm ; <nl> + } <nl> + # endif / / FILAMENT_SENSOR <nl> + <nl> # ifndef PIDTEMPBED <nl> if ( ms < next_bed_check_ms ) return ; <nl> next_bed_check_ms = ms + BED_CHECK_INTERVAL ; <nl> void manage_heater ( ) { <nl> <nl> soft_pwm_bed = current_temperature_bed > BED_MINTEMP & & current_temperature_bed < BED_MAXTEMP ? ( int ) pid_output > > 1 : 0 ; <nl> <nl> - # elif ! defined ( BED_LIMIT_SWITCHING ) <nl> - / / Check if temperature is within the correct range <nl> + # elif defined ( BED_LIMIT_SWITCHING ) <nl> + / / Check if temperature is within the correct band <nl> if ( current_temperature_bed > BED_MINTEMP & & current_temperature_bed < BED_MAXTEMP ) { <nl> - soft_pwm_bed = current_temperature_bed < target_temperature_bed ? MAX_BED_POWER > > 1 : 0 ; <nl> + if ( current_temperature_bed > = target_temperature_bed + BED_HYSTERESIS ) <nl> + soft_pwm_bed = 0 ; <nl> + else if ( current_temperature_bed < = target_temperature_bed - BED_HYSTERESIS ) <nl> + soft_pwm_bed = MAX_BED_POWER > > 1 ; <nl> } <nl> else { <nl> soft_pwm_bed = 0 ; <nl> WRITE_HEATER_BED ( LOW ) ; <nl> } <nl> - # else / / # ifdef BED_LIMIT_SWITCHING <nl> - / / Check if temperature is within the correct band <nl> + # else / / BED_LIMIT_SWITCHING <nl> + / / Check if temperature is within the correct range <nl> if ( current_temperature_bed > BED_MINTEMP & & current_temperature_bed < BED_MAXTEMP ) { <nl> - if ( current_temperature_bed > = target_temperature_bed + BED_HYSTERESIS ) <nl> - soft_pwm_bed = 0 ; <nl> - else if ( current_temperature_bed < = target_temperature_bed - BED_HYSTERESIS ) <nl> - soft_pwm_bed = MAX_BED_POWER > > 1 ; <nl> + soft_pwm_bed = current_temperature_bed < target_temperature_bed ? MAX_BED_POWER > > 1 : 0 ; <nl> } <nl> else { <nl> soft_pwm_bed = 0 ; <nl> void manage_heater ( ) { <nl> } <nl> # endif <nl> # endif / / TEMP_SENSOR_BED ! = 0 <nl> - <nl> - / / Control the extruder rate based on the width sensor <nl> - # ifdef FILAMENT_SENSOR <nl> - if ( filament_sensor ) { <nl> - meas_shift_index = delay_index1 - meas_delay_cm ; <nl> - if ( meas_shift_index < 0 ) meas_shift_index + = MAX_MEASUREMENT_DELAY + 1 ; / / loop around buffer if needed <nl> - <nl> - / / Get the delayed info and add 100 to reconstitute to a percent of <nl> - / / the nominal filament diameter then square it to get an area <nl> - meas_shift_index = constrain ( meas_shift_index , 0 , MAX_MEASUREMENT_DELAY ) ; <nl> - float vm = pow ( ( measurement_delay [ meas_shift_index ] + 100 . 0 ) / 100 . 0 , 2 ) ; <nl> - if ( vm < 0 . 01 ) vm = 0 . 01 ; <nl> - volumetric_multiplier [ FILAMENT_SENSOR_EXTRUDER_NUM ] = vm ; <nl> - } <nl> - # endif / / FILAMENT_SENSOR <nl> } <nl> <nl> # define PGM_RD_W ( x ) ( short ) pgm_read_word ( & x ) <nl> / / Derived from RepRap FiveD extruder : : getTemperature ( ) <nl> / / For hot end temperature measurement . <nl> static float analog2temp ( int raw , uint8_t e ) { <nl> - # ifdef TEMP_SENSOR_1_AS_REDUNDANT <nl> - if ( e > EXTRUDERS ) <nl> - # else <nl> - if ( e > = EXTRUDERS ) <nl> - # endif <nl> - { <nl> + # ifdef TEMP_SENSOR_1_AS_REDUNDANT <nl> + if ( e > EXTRUDERS ) <nl> + # else <nl> + if ( e > = EXTRUDERS ) <nl> + # endif <nl> + { <nl> SERIAL_ERROR_START ; <nl> SERIAL_ERROR ( ( int ) e ) ; <nl> SERIAL_ERRORLNPGM ( MSG_INVALID_EXTRUDER_NUM ) ; <nl> kill ( ) ; <nl> return 0 . 0 ; <nl> - } <nl> + } <nl> + <nl> # ifdef HEATER_0_USES_MAX6675 <nl> - if ( e = = 0 ) <nl> - { <nl> - return 0 . 25 * raw ; <nl> - } <nl> + if ( e = = 0 ) return 0 . 25 * raw ; <nl> # endif <nl> <nl> - if ( heater_ttbl_map [ e ] ! = NULL ) <nl> - { <nl> + if ( heater_ttbl_map [ e ] ! = NULL ) { <nl> float celsius = 0 ; <nl> uint8_t i ; <nl> short ( * tt ) [ ] [ 2 ] = ( short ( * ) [ ] [ 2 ] ) ( heater_ttbl_map [ e ] ) ; <nl> <nl> - for ( i = 1 ; i < heater_ttbllen_map [ e ] ; i + + ) <nl> - { <nl> - if ( PGM_RD_W ( ( * tt ) [ i ] [ 0 ] ) > raw ) <nl> - { <nl> + for ( i = 1 ; i < heater_ttbllen_map [ e ] ; i + + ) { <nl> + if ( PGM_RD_W ( ( * tt ) [ i ] [ 0 ] ) > raw ) { <nl> celsius = PGM_RD_W ( ( * tt ) [ i - 1 ] [ 1 ] ) + <nl> ( raw - PGM_RD_W ( ( * tt ) [ i - 1 ] [ 0 ] ) ) * <nl> ( float ) ( PGM_RD_W ( ( * tt ) [ i ] [ 1 ] ) - PGM_RD_W ( ( * tt ) [ i - 1 ] [ 1 ] ) ) / <nl> static float analog2tempBed ( int raw ) { <nl> float celsius = 0 ; <nl> byte i ; <nl> <nl> - for ( i = 1 ; i < BEDTEMPTABLE_LEN ; i + + ) <nl> - { <nl> - if ( PGM_RD_W ( BEDTEMPTABLE [ i ] [ 0 ] ) > raw ) <nl> - { <nl> + for ( i = 1 ; i < BEDTEMPTABLE_LEN ; i + + ) { <nl> + if ( PGM_RD_W ( BEDTEMPTABLE [ i ] [ 0 ] ) > raw ) { <nl> celsius = PGM_RD_W ( BEDTEMPTABLE [ i - 1 ] [ 1 ] ) + <nl> ( raw - PGM_RD_W ( BEDTEMPTABLE [ i - 1 ] [ 0 ] ) ) * <nl> ( float ) ( PGM_RD_W ( BEDTEMPTABLE [ i ] [ 1 ] ) - PGM_RD_W ( BEDTEMPTABLE [ i - 1 ] [ 1 ] ) ) / <nl> static void updateTemperaturesFromRawValues ( ) { <nl> # endif <nl> <nl> <nl> - <nl> - <nl> - <nl> - void tp_init ( ) <nl> - { <nl> + / * * <nl> + * Initialize the temperature manager <nl> + * The manager is implemented by periodic calls to manage_heater ( ) <nl> + * / <nl> + void tp_init ( ) { <nl> # if MB ( RUMBA ) & & ( ( TEMP_SENSOR_0 = = - 1 ) | | ( TEMP_SENSOR_1 = = - 1 ) | | ( TEMP_SENSOR_2 = = - 1 ) | | ( TEMP_SENSOR_BED = = - 1 ) ) <nl> / / disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector <nl> MCUCR = BIT ( JTD ) ; <nl> void setWatch ( ) { <nl> SERIAL_ERRORLNPGM ( MSG_THERMAL_RUNAWAY_STOP ) ; <nl> if ( heater_id < 0 ) SERIAL_ERRORLNPGM ( " bed " ) ; else SERIAL_ERRORLN ( heater_id ) ; <nl> LCD_ALERTMESSAGEPGM ( MSG_THERMAL_RUNAWAY ) ; <nl> - disable_heater ( ) ; <nl> + disable_all_heaters ( ) ; <nl> disable_all_steppers ( ) ; <nl> for ( ; ; ) { <nl> manage_heater ( ) ; <nl> void setWatch ( ) { <nl> <nl> # endif / / HAS_HEATER_THERMAL_PROTECTION | | HAS_BED_THERMAL_PROTECTION <nl> <nl> - void disable_heater ( ) { <nl> + void disable_all_heaters ( ) { <nl> for ( int i = 0 ; i < EXTRUDERS ; i + + ) setTargetHotend ( 0 , i ) ; <nl> setTargetBed ( 0 ) ; <nl> <nl> static void set_current_temp_raw ( ) { <nl> temp_meas_ready = true ; <nl> } <nl> <nl> - / / <nl> - / / Timer 0 is shared with millies <nl> - / / <nl> + / * * <nl> + * Timer 0 is shared with millies <nl> + * - Manage PWM to all the heaters and fan <nl> + * - Update the raw temperature values <nl> + * - Check new temperature values for MIN / MAX errors <nl> + * - Step the babysteps value for each axis towards 0 <nl> + * / <nl> ISR ( TIMER0_COMPB_vect ) { <nl> - / / these variables are only accesible from the ISR , but static , so they don ' t lose their value <nl> + <nl> static unsigned char temp_count = 0 ; <nl> static TempState temp_state = StartupDelay ; <nl> static unsigned char pwm_count = BIT ( SOFT_PWM_SCALE ) ; <nl> ISR ( TIMER0_COMPB_vect ) { <nl> # define START_ADC ( pin ) ADCSRB = 0 ; SET_ADMUX_ADCSRA ( pin ) <nl> # endif <nl> <nl> + / / Prepare or measure a sensor , each one every 12th frame <nl> switch ( temp_state ) { <nl> case PrepareTemp_0 : <nl> # if HAS_TEMP_0 <nl> ISR ( TIMER0_COMPB_vect ) { <nl> } / / temp_count > = OVERSAMPLENR <nl> <nl> # ifdef BABYSTEPPING <nl> - for ( uint8_t axis = X_AXIS ; axis < = Z_AXIS ; axis + + ) { <nl> - int curTodo = babystepsTodo [ axis ] ; / / get rid of volatile for performance <nl> + for ( uint8_t axis = X_AXIS ; axis < = Z_AXIS ; axis + + ) { <nl> + int curTodo = babystepsTodo [ axis ] ; / / get rid of volatile for performance <nl> <nl> if ( curTodo > 0 ) { <nl> babystep ( axis , / * fwd * / true ) ; <nl> - babystepsTodo [ axis ] - - ; / / less to do next time <nl> + babystepsTodo [ axis ] - - ; / / fewer to do next time <nl> } <nl> - else if ( curTodo < 0 ) { <nl> + else if ( curTodo < 0 ) { <nl> babystep ( axis , / * fwd * / false ) ; <nl> - babystepsTodo [ axis ] + + ; / / less to do next time <nl> + babystepsTodo [ axis ] + + ; / / fewer to do next time <nl> } <nl> } <nl> # endif / / BABYSTEPPING <nl> mmm a / Marlin / temperature . h <nl> ppp b / Marlin / temperature . h <nl> HOTEND_ROUTINES ( 0 ) ; <nl> # endif <nl> <nl> int getHeaterPower ( int heater ) ; <nl> - void disable_heater ( ) ; <nl> + void disable_all_heaters ( ) ; <nl> void setWatch ( ) ; <nl> void updatePID ( ) ; <nl> <nl> mmm a / Marlin / ultralcd . cpp <nl> ppp b / Marlin / ultralcd . cpp <nl> static void lcd_status_screen ( ) ; <nl> * lcd_implementation_drawmenu_function ( sel , row , PSTR ( MSG_PAUSE_PRINT ) , lcd_sdcard_pause ) <nl> * menu_action_function ( lcd_sdcard_pause ) <nl> * <nl> - * MENU_ITEM_EDIT ( int3 , MSG_SPEED , & feedmultiply , 10 , 999 ) <nl> - * MENU_ITEM ( setting_edit_int3 , MSG_SPEED , PSTR ( MSG_SPEED ) , & feedmultiply , 10 , 999 ) <nl> - * lcd_implementation_drawmenu_setting_edit_int3 ( sel , row , PSTR ( MSG_SPEED ) , PSTR ( MSG_SPEED ) , & feedmultiply , 10 , 999 ) <nl> - * menu_action_setting_edit_int3 ( PSTR ( MSG_SPEED ) , & feedmultiply , 10 , 999 ) <nl> + * MENU_ITEM_EDIT ( int3 , MSG_SPEED , & feedrate_multiplier , 10 , 999 ) <nl> + * MENU_ITEM ( setting_edit_int3 , MSG_SPEED , PSTR ( MSG_SPEED ) , & feedrate_multiplier , 10 , 999 ) <nl> + * lcd_implementation_drawmenu_setting_edit_int3 ( sel , row , PSTR ( MSG_SPEED ) , PSTR ( MSG_SPEED ) , & feedrate_multiplier , 10 , 999 ) <nl> + * menu_action_setting_edit_int3 ( PSTR ( MSG_SPEED ) , & feedrate_multiplier , 10 , 999 ) <nl> * <nl> * / <nl> # define MENU_ITEM ( type , label , args . . . ) do { \ <nl> static void lcd_status_screen ( ) { <nl> <nl> # ifdef ULTIPANEL_FEEDMULTIPLY <nl> / / Dead zone at 100 % feedrate <nl> - if ( ( feedmultiply < 100 & & ( feedmultiply + int ( encoderPosition ) ) > 100 ) | | <nl> - ( feedmultiply > 100 & & ( feedmultiply + int ( encoderPosition ) ) < 100 ) ) { <nl> + if ( ( feedrate_multiplier < 100 & & ( feedrate_multiplier + int ( encoderPosition ) ) > 100 ) | | <nl> + ( feedrate_multiplier > 100 & & ( feedrate_multiplier + int ( encoderPosition ) ) < 100 ) ) { <nl> encoderPosition = 0 ; <nl> - feedmultiply = 100 ; <nl> + feedrate_multiplier = 100 ; <nl> } <nl> - if ( feedmultiply = = 100 ) { <nl> + if ( feedrate_multiplier = = 100 ) { <nl> if ( int ( encoderPosition ) > ENCODER_FEEDRATE_DEADZONE ) { <nl> - feedmultiply + = int ( encoderPosition ) - ENCODER_FEEDRATE_DEADZONE ; <nl> + feedrate_multiplier + = int ( encoderPosition ) - ENCODER_FEEDRATE_DEADZONE ; <nl> encoderPosition = 0 ; <nl> } <nl> else if ( int ( encoderPosition ) < - ENCODER_FEEDRATE_DEADZONE ) { <nl> - feedmultiply + = int ( encoderPosition ) + ENCODER_FEEDRATE_DEADZONE ; <nl> + feedrate_multiplier + = int ( encoderPosition ) + ENCODER_FEEDRATE_DEADZONE ; <nl> encoderPosition = 0 ; <nl> } <nl> } <nl> else { <nl> - feedmultiply + = int ( encoderPosition ) ; <nl> + feedrate_multiplier + = int ( encoderPosition ) ; <nl> encoderPosition = 0 ; <nl> } <nl> # endif / / ULTIPANEL_FEEDMULTIPLY <nl> <nl> - feedmultiply = constrain ( feedmultiply , 10 , 999 ) ; <nl> + feedrate_multiplier = constrain ( feedrate_multiplier , 10 , 999 ) ; <nl> <nl> # endif / / ULTIPANEL <nl> } <nl> void lcd_set_home_offsets ( ) { <nl> static void lcd_tune_menu ( ) { <nl> START_MENU ( ) ; <nl> MENU_ITEM ( back , MSG_MAIN , lcd_main_menu ) ; <nl> - MENU_ITEM_EDIT ( int3 , MSG_SPEED , & feedmultiply , 10 , 999 ) ; <nl> + MENU_ITEM_EDIT ( int3 , MSG_SPEED , & feedrate_multiplier , 10 , 999 ) ; <nl> # if TEMP_SENSOR_0 ! = 0 <nl> MENU_MULTIPLIER_ITEM_EDIT ( int3 , MSG_NOZZLE , & target_temperature [ 0 ] , 0 , HEATER_0_MAXTEMP - 15 ) ; <nl> # endif <nl> mmm a / Marlin / ultralcd_implementation_hitachi_HD44780 . h <nl> ppp b / Marlin / ultralcd_implementation_hitachi_HD44780 . h <nl> static void lcd_implementation_status_screen ( ) { <nl> <nl> lcd . setCursor ( 0 , 2 ) ; <nl> lcd . print ( LCD_STR_FEEDRATE [ 0 ] ) ; <nl> - lcd . print ( itostr3 ( feedmultiply ) ) ; <nl> + lcd . print ( itostr3 ( feedrate_multiplier ) ) ; <nl> lcd . print ( ' % ' ) ; <nl> <nl> # if LCD_WIDTH > 19 & & defined ( SDSUPPORT ) <nl> static void lcd_implementation_status_screen ( ) { <nl> <nl> lcd . setCursor ( LCD_WIDTH - 6 , 2 ) ; <nl> lcd . print ( LCD_STR_CLOCK [ 0 ] ) ; <nl> - if ( starttime ! = 0 ) { <nl> - uint16_t time = millis ( ) / 60000 - starttime / 60000 ; <nl> + if ( print_job_start_ms ! = 0 ) { <nl> + uint16_t time = millis ( ) / 60000 - print_job_start_ms / 60000 ; <nl> lcd . print ( itostr2 ( time / 60 ) ) ; <nl> lcd . print ( ' : ' ) ; <nl> lcd . print ( itostr2 ( time % 60 ) ) ; <nl> | Naming and code comments | MarlinFirmware/Marlin | 09d60e01280f622b75a098182fe3bb41d212fba8 | 2015-04-14T00:17:36Z |
mmm a / src / gui / options . ui <nl> ppp b / src / gui / options . ui <nl> <nl> < / widget > <nl> < / item > <nl> < item > <nl> - < spacer name = " horizontalSpacer_10 " > <nl> + < spacer name = " horizontalSpacer_100 " > <nl> < property name = " orientation " > <nl> < enum > Qt : : Horizontal < / enum > <nl> < / property > <nl> <nl> < / property > <nl> < layout class = " QVBoxLayout " name = " verticalLayout_25 " > <nl> < item > <nl> - < layout class = " QHBoxLayout " name = " horizontalLayout_7 " > <nl> + < layout class = " QHBoxLayout " name = " horizontalLayout_70 " > <nl> < property name = " spacing " > <nl> < number > 10 < / number > <nl> < / property > <nl> < item > <nl> - < widget class = " QLabel " name = " label_4 " > <nl> + < widget class = " QLabel " name = " label_40 " > <nl> < property name = " text " > <nl> < string > Default Saving Mode : < / string > <nl> < / property > <nl> <nl> < / widget > <nl> < / item > <nl> < item > <nl> - < spacer name = " horizontalSpacer_16 " > <nl> + < spacer name = " horizontalSpacer_160 " > <nl> < property name = " orientation " > <nl> < enum > Qt : : Horizontal < / enum > <nl> < / property > <nl> <nl> < / widget > <nl> < / item > <nl> < item > <nl> - < layout class = " QHBoxLayout " name = " horizontalLayout_8 " > <nl> + < layout class = " QHBoxLayout " name = " horizontalLayout_80 " > <nl> < property name = " spacing " > <nl> < number > 10 < / number > <nl> < / property > <nl> | Merge pull request from ngosang / warnings | qbittorrent/qBittorrent | 43d52026b790edb844dec1f23256fda0e7ff57ec | 2016-04-05T22:19:15Z |
mmm a / xbmc / cores / dvdplayer / DVDCodecs / Video / DVDVideoCodecCrystalHD . cpp <nl> ppp b / xbmc / cores / dvdplayer / DVDCodecs / Video / DVDVideoCodecCrystalHD . cpp <nl> int CDVDVideoCodecCrystalHD : : Decode ( BYTE * pData , int iSize , double dts , double p <nl> if ( ! ( ret & VC_PICTURE ) & & ! ( ret & VC_BUFFER ) ) <nl> m_Device - > WaitInput ( 100 ) ; <nl> <nl> - fprintf ( stdout , " GetInputCount ( % d ) , GetReadyCount ( % d ) \ n " , m_Device - > GetInputCount ( ) , m_Device - > GetReadyCount ( ) ) ; <nl> - <nl> return ret ; <nl> } <nl> <nl> | [ crystalhd ] remove stray debug output | xbmc/xbmc | badf469d73ec083ef05e4909fcbc0e7644ac4e22 | 2010-02-14T04:53:37Z |
mmm a / BUILD <nl> ppp b / BUILD <nl> cc_library ( <nl> " src / core / lib / tsi / transport_security_interface . h " , <nl> " src / core / ext / client_config / client_channel . h " , <nl> " src / core / ext / client_config / client_channel_factory . h " , <nl> - " src / core / ext / client_config / client_config . h " , <nl> " src / core / ext / client_config / connector . h " , <nl> " src / core / ext / client_config / initial_connect_string . h " , <nl> " src / core / ext / client_config / lb_policy . h " , <nl> cc_library ( <nl> " src / core / ext / client_config / resolver . h " , <nl> " src / core / ext / client_config / resolver_factory . h " , <nl> " src / core / ext / client_config / resolver_registry . h " , <nl> + " src / core / ext / client_config / resolver_result . h " , <nl> " src / core / ext / client_config / subchannel . h " , <nl> " src / core / ext / client_config / subchannel_call_holder . h " , <nl> " src / core / ext / client_config / subchannel_index . h " , <nl> cc_library ( <nl> " src / core / ext / client_config / channel_connectivity . c " , <nl> " src / core / ext / client_config / client_channel . c " , <nl> " src / core / ext / client_config / client_channel_factory . c " , <nl> - " src / core / ext / client_config / client_config . c " , <nl> " src / core / ext / client_config / client_config_plugin . c " , <nl> " src / core / ext / client_config / connector . c " , <nl> " src / core / ext / client_config / default_initial_connect_string . c " , <nl> cc_library ( <nl> " src / core / ext / client_config / resolver . c " , <nl> " src / core / ext / client_config / resolver_factory . c " , <nl> " src / core / ext / client_config / resolver_registry . c " , <nl> + " src / core / ext / client_config / resolver_result . c " , <nl> " src / core / ext / client_config / subchannel . c " , <nl> " src / core / ext / client_config / subchannel_call_holder . c " , <nl> " src / core / ext / client_config / subchannel_index . c " , <nl> cc_library ( <nl> " src / core / ext / transport / chttp2 / alpn / alpn . h " , <nl> " src / core / ext / client_config / client_channel . h " , <nl> " src / core / ext / client_config / client_channel_factory . h " , <nl> - " src / core / ext / client_config / client_config . h " , <nl> " src / core / ext / client_config / connector . h " , <nl> " src / core / ext / client_config / initial_connect_string . h " , <nl> " src / core / ext / client_config / lb_policy . h " , <nl> cc_library ( <nl> " src / core / ext / client_config / resolver . h " , <nl> " src / core / ext / client_config / resolver_factory . h " , <nl> " src / core / ext / client_config / resolver_registry . h " , <nl> + " src / core / ext / client_config / resolver_result . h " , <nl> " src / core / ext / client_config / subchannel . h " , <nl> " src / core / ext / client_config / subchannel_call_holder . h " , <nl> " src / core / ext / client_config / subchannel_index . h " , <nl> cc_library ( <nl> " src / core / ext / client_config / channel_connectivity . c " , <nl> " src / core / ext / client_config / client_channel . c " , <nl> " src / core / ext / client_config / client_channel_factory . c " , <nl> - " src / core / ext / client_config / client_config . c " , <nl> " src / core / ext / client_config / client_config_plugin . c " , <nl> " src / core / ext / client_config / connector . c " , <nl> " src / core / ext / client_config / default_initial_connect_string . c " , <nl> cc_library ( <nl> " src / core / ext / client_config / resolver . c " , <nl> " src / core / ext / client_config / resolver_factory . c " , <nl> " src / core / ext / client_config / resolver_registry . c " , <nl> + " src / core / ext / client_config / resolver_result . c " , <nl> " src / core / ext / client_config / subchannel . c " , <nl> " src / core / ext / client_config / subchannel_call_holder . c " , <nl> " src / core / ext / client_config / subchannel_index . c " , <nl> cc_library ( <nl> " src / core / ext / transport / chttp2 / alpn / alpn . h " , <nl> " src / core / ext / client_config / client_channel . h " , <nl> " src / core / ext / client_config / client_channel_factory . h " , <nl> - " src / core / ext / client_config / client_config . h " , <nl> " src / core / ext / client_config / connector . h " , <nl> " src / core / ext / client_config / initial_connect_string . h " , <nl> " src / core / ext / client_config / lb_policy . h " , <nl> cc_library ( <nl> " src / core / ext / client_config / resolver . h " , <nl> " src / core / ext / client_config / resolver_factory . h " , <nl> " src / core / ext / client_config / resolver_registry . h " , <nl> + " src / core / ext / client_config / resolver_result . h " , <nl> " src / core / ext / client_config / subchannel . h " , <nl> " src / core / ext / client_config / subchannel_call_holder . h " , <nl> " src / core / ext / client_config / subchannel_index . h " , <nl> cc_library ( <nl> " src / core / ext / client_config / channel_connectivity . c " , <nl> " src / core / ext / client_config / client_channel . c " , <nl> " src / core / ext / client_config / client_channel_factory . c " , <nl> - " src / core / ext / client_config / client_config . c " , <nl> " src / core / ext / client_config / client_config_plugin . c " , <nl> " src / core / ext / client_config / connector . c " , <nl> " src / core / ext / client_config / default_initial_connect_string . c " , <nl> cc_library ( <nl> " src / core / ext / client_config / resolver . c " , <nl> " src / core / ext / client_config / resolver_factory . c " , <nl> " src / core / ext / client_config / resolver_registry . c " , <nl> + " src / core / ext / client_config / resolver_result . c " , <nl> " src / core / ext / client_config / subchannel . c " , <nl> " src / core / ext / client_config / subchannel_call_holder . c " , <nl> " src / core / ext / client_config / subchannel_index . c " , <nl> objc_library ( <nl> " src / core / ext / client_config / channel_connectivity . c " , <nl> " src / core / ext / client_config / client_channel . c " , <nl> " src / core / ext / client_config / client_channel_factory . c " , <nl> - " src / core / ext / client_config / client_config . c " , <nl> " src / core / ext / client_config / client_config_plugin . c " , <nl> " src / core / ext / client_config / connector . c " , <nl> " src / core / ext / client_config / default_initial_connect_string . c " , <nl> objc_library ( <nl> " src / core / ext / client_config / resolver . c " , <nl> " src / core / ext / client_config / resolver_factory . c " , <nl> " src / core / ext / client_config / resolver_registry . c " , <nl> + " src / core / ext / client_config / resolver_result . c " , <nl> " src / core / ext / client_config / subchannel . c " , <nl> " src / core / ext / client_config / subchannel_call_holder . c " , <nl> " src / core / ext / client_config / subchannel_index . c " , <nl> objc_library ( <nl> " src / core / lib / tsi / transport_security_interface . h " , <nl> " src / core / ext / client_config / client_channel . h " , <nl> " src / core / ext / client_config / client_channel_factory . h " , <nl> - " src / core / ext / client_config / client_config . h " , <nl> " src / core / ext / client_config / connector . h " , <nl> " src / core / ext / client_config / initial_connect_string . h " , <nl> " src / core / ext / client_config / lb_policy . h " , <nl> objc_library ( <nl> " src / core / ext / client_config / resolver . h " , <nl> " src / core / ext / client_config / resolver_factory . h " , <nl> " src / core / ext / client_config / resolver_registry . h " , <nl> + " src / core / ext / client_config / resolver_result . h " , <nl> " src / core / ext / client_config / subchannel . h " , <nl> " src / core / ext / client_config / subchannel_call_holder . h " , <nl> " src / core / ext / client_config / subchannel_index . h " , <nl> mmm a / CMakeLists . txt <nl> ppp b / CMakeLists . txt <nl> add_library ( grpc <nl> src / core / ext / client_config / channel_connectivity . c <nl> src / core / ext / client_config / client_channel . c <nl> src / core / ext / client_config / client_channel_factory . c <nl> - src / core / ext / client_config / client_config . c <nl> src / core / ext / client_config / client_config_plugin . c <nl> src / core / ext / client_config / connector . c <nl> src / core / ext / client_config / default_initial_connect_string . c <nl> add_library ( grpc <nl> src / core / ext / client_config / resolver . c <nl> src / core / ext / client_config / resolver_factory . c <nl> src / core / ext / client_config / resolver_registry . c <nl> + src / core / ext / client_config / resolver_result . c <nl> src / core / ext / client_config / subchannel . c <nl> src / core / ext / client_config / subchannel_call_holder . c <nl> src / core / ext / client_config / subchannel_index . c <nl> add_library ( grpc_cronet <nl> src / core / ext / client_config / channel_connectivity . c <nl> src / core / ext / client_config / client_channel . c <nl> src / core / ext / client_config / client_channel_factory . c <nl> - src / core / ext / client_config / client_config . c <nl> src / core / ext / client_config / client_config_plugin . c <nl> src / core / ext / client_config / connector . c <nl> src / core / ext / client_config / default_initial_connect_string . c <nl> add_library ( grpc_cronet <nl> src / core / ext / client_config / resolver . c <nl> src / core / ext / client_config / resolver_factory . c <nl> src / core / ext / client_config / resolver_registry . c <nl> + src / core / ext / client_config / resolver_result . c <nl> src / core / ext / client_config / subchannel . c <nl> src / core / ext / client_config / subchannel_call_holder . c <nl> src / core / ext / client_config / subchannel_index . c <nl> add_library ( grpc_unsecure <nl> src / core / ext / client_config / channel_connectivity . c <nl> src / core / ext / client_config / client_channel . c <nl> src / core / ext / client_config / client_channel_factory . c <nl> - src / core / ext / client_config / client_config . c <nl> src / core / ext / client_config / client_config_plugin . c <nl> src / core / ext / client_config / connector . c <nl> src / core / ext / client_config / default_initial_connect_string . c <nl> add_library ( grpc_unsecure <nl> src / core / ext / client_config / resolver . c <nl> src / core / ext / client_config / resolver_factory . c <nl> src / core / ext / client_config / resolver_registry . c <nl> + src / core / ext / client_config / resolver_result . c <nl> src / core / ext / client_config / subchannel . c <nl> src / core / ext / client_config / subchannel_call_holder . c <nl> src / core / ext / client_config / subchannel_index . c <nl> mmm a / Makefile <nl> ppp b / Makefile <nl> LIBGRPC_SRC = \ <nl> src / core / ext / client_config / channel_connectivity . c \ <nl> src / core / ext / client_config / client_channel . c \ <nl> src / core / ext / client_config / client_channel_factory . c \ <nl> - src / core / ext / client_config / client_config . c \ <nl> src / core / ext / client_config / client_config_plugin . c \ <nl> src / core / ext / client_config / connector . c \ <nl> src / core / ext / client_config / default_initial_connect_string . c \ <nl> LIBGRPC_SRC = \ <nl> src / core / ext / client_config / resolver . c \ <nl> src / core / ext / client_config / resolver_factory . c \ <nl> src / core / ext / client_config / resolver_registry . c \ <nl> + src / core / ext / client_config / resolver_result . c \ <nl> src / core / ext / client_config / subchannel . c \ <nl> src / core / ext / client_config / subchannel_call_holder . c \ <nl> src / core / ext / client_config / subchannel_index . c \ <nl> LIBGRPC_CRONET_SRC = \ <nl> src / core / ext / client_config / channel_connectivity . c \ <nl> src / core / ext / client_config / client_channel . c \ <nl> src / core / ext / client_config / client_channel_factory . c \ <nl> - src / core / ext / client_config / client_config . c \ <nl> src / core / ext / client_config / client_config_plugin . c \ <nl> src / core / ext / client_config / connector . c \ <nl> src / core / ext / client_config / default_initial_connect_string . c \ <nl> LIBGRPC_CRONET_SRC = \ <nl> src / core / ext / client_config / resolver . c \ <nl> src / core / ext / client_config / resolver_factory . c \ <nl> src / core / ext / client_config / resolver_registry . c \ <nl> + src / core / ext / client_config / resolver_result . c \ <nl> src / core / ext / client_config / subchannel . c \ <nl> src / core / ext / client_config / subchannel_call_holder . c \ <nl> src / core / ext / client_config / subchannel_index . c \ <nl> LIBGRPC_UNSECURE_SRC = \ <nl> src / core / ext / client_config / channel_connectivity . c \ <nl> src / core / ext / client_config / client_channel . c \ <nl> src / core / ext / client_config / client_channel_factory . c \ <nl> - src / core / ext / client_config / client_config . c \ <nl> src / core / ext / client_config / client_config_plugin . c \ <nl> src / core / ext / client_config / connector . c \ <nl> src / core / ext / client_config / default_initial_connect_string . c \ <nl> LIBGRPC_UNSECURE_SRC = \ <nl> src / core / ext / client_config / resolver . c \ <nl> src / core / ext / client_config / resolver_factory . c \ <nl> src / core / ext / client_config / resolver_registry . c \ <nl> + src / core / ext / client_config / resolver_result . c \ <nl> src / core / ext / client_config / subchannel . c \ <nl> src / core / ext / client_config / subchannel_call_holder . c \ <nl> src / core / ext / client_config / subchannel_index . c \ <nl> mmm a / binding . gyp <nl> ppp b / binding . gyp <nl> <nl> ' src / core / ext / client_config / channel_connectivity . c ' , <nl> ' src / core / ext / client_config / client_channel . c ' , <nl> ' src / core / ext / client_config / client_channel_factory . c ' , <nl> - ' src / core / ext / client_config / client_config . c ' , <nl> ' src / core / ext / client_config / client_config_plugin . c ' , <nl> ' src / core / ext / client_config / connector . c ' , <nl> ' src / core / ext / client_config / default_initial_connect_string . c ' , <nl> <nl> ' src / core / ext / client_config / resolver . c ' , <nl> ' src / core / ext / client_config / resolver_factory . c ' , <nl> ' src / core / ext / client_config / resolver_registry . c ' , <nl> + ' src / core / ext / client_config / resolver_result . c ' , <nl> ' src / core / ext / client_config / subchannel . c ' , <nl> ' src / core / ext / client_config / subchannel_call_holder . c ' , <nl> ' src / core / ext / client_config / subchannel_index . c ' , <nl> mmm a / build . yaml <nl> ppp b / build . yaml <nl> filegroups : <nl> headers : <nl> - src / core / ext / client_config / client_channel . h <nl> - src / core / ext / client_config / client_channel_factory . h <nl> - - src / core / ext / client_config / client_config . h <nl> - src / core / ext / client_config / connector . h <nl> - src / core / ext / client_config / initial_connect_string . h <nl> - src / core / ext / client_config / lb_policy . h <nl> filegroups : <nl> - src / core / ext / client_config / resolver . h <nl> - src / core / ext / client_config / resolver_factory . h <nl> - src / core / ext / client_config / resolver_registry . h <nl> + - src / core / ext / client_config / resolver_result . h <nl> - src / core / ext / client_config / subchannel . h <nl> - src / core / ext / client_config / subchannel_call_holder . h <nl> - src / core / ext / client_config / subchannel_index . h <nl> filegroups : <nl> - src / core / ext / client_config / channel_connectivity . c <nl> - src / core / ext / client_config / client_channel . c <nl> - src / core / ext / client_config / client_channel_factory . c <nl> - - src / core / ext / client_config / client_config . c <nl> - src / core / ext / client_config / client_config_plugin . c <nl> - src / core / ext / client_config / connector . c <nl> - src / core / ext / client_config / default_initial_connect_string . c <nl> filegroups : <nl> - src / core / ext / client_config / resolver . c <nl> - src / core / ext / client_config / resolver_factory . c <nl> - src / core / ext / client_config / resolver_registry . c <nl> + - src / core / ext / client_config / resolver_result . c <nl> - src / core / ext / client_config / subchannel . c <nl> - src / core / ext / client_config / subchannel_call_holder . c <nl> - src / core / ext / client_config / subchannel_index . c <nl> mmm a / config . m4 <nl> ppp b / config . m4 <nl> if test " $ PHP_GRPC " ! = " no " ; then <nl> src / core / ext / client_config / channel_connectivity . c \ <nl> src / core / ext / client_config / client_channel . c \ <nl> src / core / ext / client_config / client_channel_factory . c \ <nl> - src / core / ext / client_config / client_config . c \ <nl> src / core / ext / client_config / client_config_plugin . c \ <nl> src / core / ext / client_config / connector . c \ <nl> src / core / ext / client_config / default_initial_connect_string . c \ <nl> if test " $ PHP_GRPC " ! = " no " ; then <nl> src / core / ext / client_config / resolver . c \ <nl> src / core / ext / client_config / resolver_factory . c \ <nl> src / core / ext / client_config / resolver_registry . c \ <nl> + src / core / ext / client_config / resolver_result . c \ <nl> src / core / ext / client_config / subchannel . c \ <nl> src / core / ext / client_config / subchannel_call_holder . c \ <nl> src / core / ext / client_config / subchannel_index . c \ <nl> mmm a / gRPC - Core . podspec <nl> ppp b / gRPC - Core . podspec <nl> Pod : : Spec . new do | s | <nl> ' src / core / lib / tsi / transport_security_interface . h ' , <nl> ' src / core / ext / client_config / client_channel . h ' , <nl> ' src / core / ext / client_config / client_channel_factory . h ' , <nl> - ' src / core / ext / client_config / client_config . h ' , <nl> ' src / core / ext / client_config / connector . h ' , <nl> ' src / core / ext / client_config / initial_connect_string . h ' , <nl> ' src / core / ext / client_config / lb_policy . h ' , <nl> Pod : : Spec . new do | s | <nl> ' src / core / ext / client_config / resolver . h ' , <nl> ' src / core / ext / client_config / resolver_factory . h ' , <nl> ' src / core / ext / client_config / resolver_registry . h ' , <nl> + ' src / core / ext / client_config / resolver_result . h ' , <nl> ' src / core / ext / client_config / subchannel . h ' , <nl> ' src / core / ext / client_config / subchannel_call_holder . h ' , <nl> ' src / core / ext / client_config / subchannel_index . h ' , <nl> Pod : : Spec . new do | s | <nl> ' src / core / ext / client_config / channel_connectivity . c ' , <nl> ' src / core / ext / client_config / client_channel . c ' , <nl> ' src / core / ext / client_config / client_channel_factory . c ' , <nl> - ' src / core / ext / client_config / client_config . c ' , <nl> ' src / core / ext / client_config / client_config_plugin . c ' , <nl> ' src / core / ext / client_config / connector . c ' , <nl> ' src / core / ext / client_config / default_initial_connect_string . c ' , <nl> Pod : : Spec . new do | s | <nl> ' src / core / ext / client_config / resolver . c ' , <nl> ' src / core / ext / client_config / resolver_factory . c ' , <nl> ' src / core / ext / client_config / resolver_registry . c ' , <nl> + ' src / core / ext / client_config / resolver_result . c ' , <nl> ' src / core / ext / client_config / subchannel . c ' , <nl> ' src / core / ext / client_config / subchannel_call_holder . c ' , <nl> ' src / core / ext / client_config / subchannel_index . c ' , <nl> Pod : : Spec . new do | s | <nl> ' src / core / lib / tsi / transport_security_interface . h ' , <nl> ' src / core / ext / client_config / client_channel . h ' , <nl> ' src / core / ext / client_config / client_channel_factory . h ' , <nl> - ' src / core / ext / client_config / client_config . h ' , <nl> ' src / core / ext / client_config / connector . h ' , <nl> ' src / core / ext / client_config / initial_connect_string . h ' , <nl> ' src / core / ext / client_config / lb_policy . h ' , <nl> Pod : : Spec . new do | s | <nl> ' src / core / ext / client_config / resolver . h ' , <nl> ' src / core / ext / client_config / resolver_factory . h ' , <nl> ' src / core / ext / client_config / resolver_registry . h ' , <nl> + ' src / core / ext / client_config / resolver_result . h ' , <nl> ' src / core / ext / client_config / subchannel . h ' , <nl> ' src / core / ext / client_config / subchannel_call_holder . h ' , <nl> ' src / core / ext / client_config / subchannel_index . h ' , <nl> mmm a / grpc . gemspec <nl> ppp b / grpc . gemspec <nl> Gem : : Specification . new do | s | <nl> s . files + = % w ( src / core / lib / tsi / transport_security_interface . h ) <nl> s . files + = % w ( src / core / ext / client_config / client_channel . h ) <nl> s . files + = % w ( src / core / ext / client_config / client_channel_factory . h ) <nl> - s . files + = % w ( src / core / ext / client_config / client_config . h ) <nl> s . files + = % w ( src / core / ext / client_config / connector . h ) <nl> s . files + = % w ( src / core / ext / client_config / initial_connect_string . h ) <nl> s . files + = % w ( src / core / ext / client_config / lb_policy . h ) <nl> Gem : : Specification . new do | s | <nl> s . files + = % w ( src / core / ext / client_config / resolver . h ) <nl> s . files + = % w ( src / core / ext / client_config / resolver_factory . h ) <nl> s . files + = % w ( src / core / ext / client_config / resolver_registry . h ) <nl> + s . files + = % w ( src / core / ext / client_config / resolver_result . h ) <nl> s . files + = % w ( src / core / ext / client_config / subchannel . h ) <nl> s . files + = % w ( src / core / ext / client_config / subchannel_call_holder . h ) <nl> s . files + = % w ( src / core / ext / client_config / subchannel_index . h ) <nl> Gem : : Specification . new do | s | <nl> s . files + = % w ( src / core / ext / client_config / channel_connectivity . c ) <nl> s . files + = % w ( src / core / ext / client_config / client_channel . c ) <nl> s . files + = % w ( src / core / ext / client_config / client_channel_factory . c ) <nl> - s . files + = % w ( src / core / ext / client_config / client_config . c ) <nl> s . files + = % w ( src / core / ext / client_config / client_config_plugin . c ) <nl> s . files + = % w ( src / core / ext / client_config / connector . c ) <nl> s . files + = % w ( src / core / ext / client_config / default_initial_connect_string . c ) <nl> Gem : : Specification . new do | s | <nl> s . files + = % w ( src / core / ext / client_config / resolver . c ) <nl> s . files + = % w ( src / core / ext / client_config / resolver_factory . c ) <nl> s . files + = % w ( src / core / ext / client_config / resolver_registry . c ) <nl> + s . files + = % w ( src / core / ext / client_config / resolver_result . c ) <nl> s . files + = % w ( src / core / ext / client_config / subchannel . c ) <nl> s . files + = % w ( src / core / ext / client_config / subchannel_call_holder . c ) <nl> s . files + = % w ( src / core / ext / client_config / subchannel_index . c ) <nl> mmm a / package . xml <nl> ppp b / package . xml <nl> <nl> < file baseinstalldir = " / " name = " src / core / lib / tsi / transport_security_interface . h " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / ext / client_config / client_channel . h " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / ext / client_config / client_channel_factory . h " role = " src " / > <nl> - < file baseinstalldir = " / " name = " src / core / ext / client_config / client_config . h " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / ext / client_config / connector . h " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / ext / client_config / initial_connect_string . h " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / ext / client_config / lb_policy . h " role = " src " / > <nl> <nl> < file baseinstalldir = " / " name = " src / core / ext / client_config / resolver . h " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / ext / client_config / resolver_factory . h " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / ext / client_config / resolver_registry . h " role = " src " / > <nl> + < file baseinstalldir = " / " name = " src / core / ext / client_config / resolver_result . h " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / ext / client_config / subchannel . h " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / ext / client_config / subchannel_call_holder . h " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / ext / client_config / subchannel_index . h " role = " src " / > <nl> <nl> < file baseinstalldir = " / " name = " src / core / ext / client_config / channel_connectivity . c " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / ext / client_config / client_channel . c " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / ext / client_config / client_channel_factory . c " role = " src " / > <nl> - < file baseinstalldir = " / " name = " src / core / ext / client_config / client_config . c " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / ext / client_config / client_config_plugin . c " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / ext / client_config / connector . c " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / ext / client_config / default_initial_connect_string . c " role = " src " / > <nl> <nl> < file baseinstalldir = " / " name = " src / core / ext / client_config / resolver . c " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / ext / client_config / resolver_factory . c " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / ext / client_config / resolver_registry . c " role = " src " / > <nl> + < file baseinstalldir = " / " name = " src / core / ext / client_config / resolver_result . c " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / ext / client_config / subchannel . c " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / ext / client_config / subchannel_call_holder . c " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / ext / client_config / subchannel_index . c " role = " src " / > <nl> mmm a / src / core / ext / client_config / README . md <nl> ppp b / src / core / ext / client_config / README . md <nl> data might include : <nl> - a load balancing policy to decide which server to send a request to <nl> - a set of filters to mutate outgoing requests ( say , by adding metadata ) <nl> <nl> - The resolver provides this data as a stream of grpc_client_config objects to <nl> + The resolver provides this data as a stream of grpc_resolver_result objects to <nl> the channel . We represent configuration as a stream so that it can be changed <nl> by the resolver during execution , by reacting to external events ( such as a <nl> new configuration file being pushed to some store ) . <nl> Load Balancing <nl> mmmmmmmmmmmm - - <nl> <nl> Load balancing configuration is provided by a grpc_lb_policy object , stored as <nl> - part of grpc_client_config . <nl> + part of grpc_resolver_result . <nl> <nl> The primary job of the load balancing policies is to pick a target server given only the <nl> initial metadata for a request . It does this by providing a grpc_subchannel <nl> mmm a / src / core / ext / client_config / client_channel . c <nl> ppp b / src / core / ext / client_config / client_channel . c <nl> typedef struct client_channel_channel_data { <nl> <nl> / * * mutex protecting client configuration , including all <nl> variables below in this data structure * / <nl> - gpr_mu mu_config ; <nl> - / * * currently active load balancer - guarded by mu_config * / <nl> + gpr_mu mu ; <nl> + / * * currently active load balancer - guarded by mu * / <nl> grpc_lb_policy * lb_policy ; <nl> - / * * incoming configuration - set by resolver . next <nl> - guarded by mu_config * / <nl> - grpc_client_config * incoming_configuration ; <nl> + / * * incoming resolver result - set by resolver . next ( ) , guarded by mu * / <nl> + grpc_resolver_result * resolver_result ; <nl> / * * a list of closures that are all waiting for config to come in * / <nl> grpc_closure_list waiting_for_config_closures ; <nl> / * * resolver callback * / <nl> - grpc_closure on_config_changed ; <nl> + grpc_closure on_resolver_result_changed ; <nl> / * * connectivity state being tracked * / <nl> grpc_connectivity_state_tracker state_tracker ; <nl> / * * when an lb_policy arrives , should we try to exit idle * / <nl> static void on_lb_policy_state_changed ( grpc_exec_ctx * exec_ctx , void * arg , <nl> grpc_error * error ) { <nl> lb_policy_connectivity_watcher * w = arg ; <nl> <nl> - gpr_mu_lock ( & w - > chand - > mu_config ) ; <nl> + gpr_mu_lock ( & w - > chand - > mu ) ; <nl> on_lb_policy_state_changed_locked ( exec_ctx , w , error ) ; <nl> - gpr_mu_unlock ( & w - > chand - > mu_config ) ; <nl> + gpr_mu_unlock ( & w - > chand - > mu ) ; <nl> <nl> GRPC_CHANNEL_STACK_UNREF ( exec_ctx , w - > chand - > owning_stack , " watch_lb_policy " ) ; <nl> gpr_free ( w ) ; <nl> static void watch_lb_policy ( grpc_exec_ctx * exec_ctx , channel_data * chand , <nl> & w - > on_changed ) ; <nl> } <nl> <nl> - static void cc_on_config_changed ( grpc_exec_ctx * exec_ctx , void * arg , <nl> - grpc_error * error ) { <nl> + static void cc_on_resolver_result_changed ( grpc_exec_ctx * exec_ctx , void * arg , <nl> + grpc_error * error ) { <nl> channel_data * chand = arg ; <nl> grpc_lb_policy * lb_policy = NULL ; <nl> grpc_lb_policy * old_lb_policy ; <nl> static void cc_on_config_changed ( grpc_exec_ctx * exec_ctx , void * arg , <nl> int exit_idle = 0 ; <nl> grpc_error * state_error = GRPC_ERROR_CREATE ( " No load balancing policy " ) ; <nl> <nl> - if ( chand - > incoming_configuration ! = NULL ) { <nl> - lb_policy = grpc_client_config_get_lb_policy ( chand - > incoming_configuration ) ; <nl> + if ( chand - > resolver_result ! = NULL ) { <nl> + lb_policy = <nl> + grpc_resolver_result_get_lb_policy ( chand - > resolver_result ) ; <nl> if ( lb_policy ! = NULL ) { <nl> GRPC_LB_POLICY_REF ( lb_policy , " channel " ) ; <nl> GRPC_LB_POLICY_REF ( lb_policy , " config_change " ) ; <nl> static void cc_on_config_changed ( grpc_exec_ctx * exec_ctx , void * arg , <nl> grpc_lb_policy_check_connectivity ( exec_ctx , lb_policy , & state_error ) ; <nl> } <nl> <nl> - grpc_client_config_unref ( exec_ctx , chand - > incoming_configuration ) ; <nl> + grpc_resolver_result_unref ( exec_ctx , chand - > resolver_result ) ; <nl> } <nl> <nl> - chand - > incoming_configuration = NULL ; <nl> + chand - > resolver_result = NULL ; <nl> <nl> if ( lb_policy ! = NULL ) { <nl> grpc_pollset_set_add_pollset_set ( exec_ctx , lb_policy - > interested_parties , <nl> chand - > interested_parties ) ; <nl> } <nl> <nl> - gpr_mu_lock ( & chand - > mu_config ) ; <nl> + gpr_mu_lock ( & chand - > mu ) ; <nl> old_lb_policy = chand - > lb_policy ; <nl> chand - > lb_policy = lb_policy ; <nl> if ( lb_policy ! = NULL ) { <nl> static void cc_on_config_changed ( grpc_exec_ctx * exec_ctx , void * arg , <nl> } <nl> GRPC_CHANNEL_STACK_REF ( chand - > owning_stack , " resolver " ) ; <nl> grpc_resolver_next ( exec_ctx , chand - > resolver , <nl> - & chand - > incoming_configuration , <nl> - & chand - > on_config_changed ) ; <nl> - gpr_mu_unlock ( & chand - > mu_config ) ; <nl> + & chand - > resolver_result , <nl> + & chand - > on_resolver_result_changed ) ; <nl> + gpr_mu_unlock ( & chand - > mu ) ; <nl> } else { <nl> if ( chand - > resolver ! = NULL ) { <nl> grpc_resolver_shutdown ( exec_ctx , chand - > resolver ) ; <nl> static void cc_on_config_changed ( grpc_exec_ctx * exec_ctx , void * arg , <nl> GRPC_ERROR_CREATE_REFERENCING ( " Got config after disconnection " , refs , <nl> GPR_ARRAY_SIZE ( refs ) ) , <nl> " resolver_gone " ) ; <nl> - gpr_mu_unlock ( & chand - > mu_config ) ; <nl> + gpr_mu_unlock ( & chand - > mu ) ; <nl> } <nl> <nl> if ( exit_idle ) { <nl> static void cc_start_transport_op ( grpc_exec_ctx * exec_ctx , <nl> op - > bind_pollset ) ; <nl> } <nl> <nl> - gpr_mu_lock ( & chand - > mu_config ) ; <nl> + gpr_mu_lock ( & chand - > mu ) ; <nl> if ( op - > on_connectivity_state_change ! = NULL ) { <nl> grpc_connectivity_state_notify_on_state_change ( <nl> exec_ctx , & chand - > state_tracker , op - > connectivity_state , <nl> static void cc_start_transport_op ( grpc_exec_ctx * exec_ctx , <nl> } <nl> GRPC_ERROR_UNREF ( op - > disconnect_with_error ) ; <nl> } <nl> - gpr_mu_unlock ( & chand - > mu_config ) ; <nl> + gpr_mu_unlock ( & chand - > mu ) ; <nl> } <nl> <nl> typedef struct { <nl> static int cc_pick_subchannel ( grpc_exec_ctx * exec_ctx , void * elemp , <nl> <nl> GPR_ASSERT ( connected_subchannel ) ; <nl> <nl> - gpr_mu_lock ( & chand - > mu_config ) ; <nl> + gpr_mu_lock ( & chand - > mu ) ; <nl> if ( initial_metadata = = NULL ) { <nl> if ( chand - > lb_policy ! = NULL ) { <nl> grpc_lb_policy_cancel_pick ( exec_ctx , chand - > lb_policy , <nl> static int cc_pick_subchannel ( grpc_exec_ctx * exec_ctx , void * elemp , <nl> GRPC_ERROR_CREATE ( " Pick cancelled " ) , NULL ) ; <nl> } <nl> } <nl> - gpr_mu_unlock ( & chand - > mu_config ) ; <nl> + gpr_mu_unlock ( & chand - > mu ) ; <nl> GPR_TIMER_END ( " cc_pick_subchannel " , 0 ) ; <nl> return 1 ; <nl> } <nl> static int cc_pick_subchannel ( grpc_exec_ctx * exec_ctx , void * elemp , <nl> grpc_lb_policy * lb_policy = chand - > lb_policy ; <nl> int r ; <nl> GRPC_LB_POLICY_REF ( lb_policy , " cc_pick_subchannel " ) ; <nl> - gpr_mu_unlock ( & chand - > mu_config ) ; <nl> + gpr_mu_unlock ( & chand - > mu ) ; <nl> r = grpc_lb_policy_pick ( exec_ctx , lb_policy , calld - > pollent , <nl> initial_metadata , initial_metadata_flags , <nl> connected_subchannel , on_ready ) ; <nl> static int cc_pick_subchannel ( grpc_exec_ctx * exec_ctx , void * elemp , <nl> chand - > started_resolving = 1 ; <nl> GRPC_CHANNEL_STACK_REF ( chand - > owning_stack , " resolver " ) ; <nl> grpc_resolver_next ( exec_ctx , chand - > resolver , <nl> - & chand - > incoming_configuration , <nl> - & chand - > on_config_changed ) ; <nl> + & chand - > resolver_result , <nl> + & chand - > on_resolver_result_changed ) ; <nl> } <nl> if ( chand - > resolver ! = NULL ) { <nl> cpa = gpr_malloc ( sizeof ( * cpa ) ) ; <nl> static int cc_pick_subchannel ( grpc_exec_ctx * exec_ctx , void * elemp , <nl> grpc_exec_ctx_sched ( exec_ctx , on_ready , GRPC_ERROR_CREATE ( " Disconnected " ) , <nl> NULL ) ; <nl> } <nl> - gpr_mu_unlock ( & chand - > mu_config ) ; <nl> + gpr_mu_unlock ( & chand - > mu ) ; <nl> <nl> GPR_TIMER_END ( " cc_pick_subchannel " , 0 ) ; <nl> return 0 ; <nl> static void init_channel_elem ( grpc_exec_ctx * exec_ctx , <nl> GPR_ASSERT ( args - > is_last ) ; <nl> GPR_ASSERT ( elem - > filter = = & grpc_client_channel_filter ) ; <nl> <nl> - gpr_mu_init ( & chand - > mu_config ) ; <nl> - grpc_closure_init ( & chand - > on_config_changed , cc_on_config_changed , chand ) ; <nl> + gpr_mu_init ( & chand - > mu ) ; <nl> + grpc_closure_init ( & chand - > on_resolver_result_changed , <nl> + cc_on_resolver_result_changed , chand ) ; <nl> chand - > owning_stack = args - > channel_stack ; <nl> <nl> grpc_connectivity_state_init ( & chand - > state_tracker , GRPC_CHANNEL_IDLE , <nl> static void destroy_channel_elem ( grpc_exec_ctx * exec_ctx , <nl> } <nl> grpc_connectivity_state_destroy ( exec_ctx , & chand - > state_tracker ) ; <nl> grpc_pollset_set_destroy ( chand - > interested_parties ) ; <nl> - gpr_mu_destroy ( & chand - > mu_config ) ; <nl> + gpr_mu_destroy ( & chand - > mu ) ; <nl> } <nl> <nl> static void cc_set_pollset_or_pollset_set ( grpc_exec_ctx * exec_ctx , <nl> void grpc_client_channel_set_resolver ( grpc_exec_ctx * exec_ctx , <nl> / * post construction initialization : set the transport setup pointer * / <nl> grpc_channel_element * elem = grpc_channel_stack_last_element ( channel_stack ) ; <nl> channel_data * chand = elem - > channel_data ; <nl> - gpr_mu_lock ( & chand - > mu_config ) ; <nl> + gpr_mu_lock ( & chand - > mu ) ; <nl> GPR_ASSERT ( ! chand - > resolver ) ; <nl> chand - > resolver = resolver ; <nl> GRPC_RESOLVER_REF ( resolver , " channel " ) ; <nl> void grpc_client_channel_set_resolver ( grpc_exec_ctx * exec_ctx , <nl> chand - > exit_idle_when_lb_policy_arrives ) { <nl> chand - > started_resolving = 1 ; <nl> GRPC_CHANNEL_STACK_REF ( chand - > owning_stack , " resolver " ) ; <nl> - grpc_resolver_next ( exec_ctx , resolver , & chand - > incoming_configuration , <nl> - & chand - > on_config_changed ) ; <nl> + grpc_resolver_next ( exec_ctx , resolver , & chand - > resolver_result , <nl> + & chand - > on_resolver_result_changed ) ; <nl> } <nl> - gpr_mu_unlock ( & chand - > mu_config ) ; <nl> + gpr_mu_unlock ( & chand - > mu ) ; <nl> } <nl> <nl> grpc_connectivity_state grpc_client_channel_check_connectivity_state ( <nl> grpc_exec_ctx * exec_ctx , grpc_channel_element * elem , int try_to_connect ) { <nl> channel_data * chand = elem - > channel_data ; <nl> grpc_connectivity_state out ; <nl> - gpr_mu_lock ( & chand - > mu_config ) ; <nl> + gpr_mu_lock ( & chand - > mu ) ; <nl> out = grpc_connectivity_state_check ( & chand - > state_tracker , NULL ) ; <nl> if ( out = = GRPC_CHANNEL_IDLE & & try_to_connect ) { <nl> if ( chand - > lb_policy ! = NULL ) { <nl> grpc_connectivity_state grpc_client_channel_check_connectivity_state ( <nl> GRPC_CHANNEL_STACK_REF ( chand - > owning_stack , " resolver " ) ; <nl> chand - > started_resolving = 1 ; <nl> grpc_resolver_next ( exec_ctx , chand - > resolver , <nl> - & chand - > incoming_configuration , <nl> - & chand - > on_config_changed ) ; <nl> + & chand - > resolver_result , <nl> + & chand - > on_resolver_result_changed ) ; <nl> } <nl> } <nl> } <nl> - gpr_mu_unlock ( & chand - > mu_config ) ; <nl> + gpr_mu_unlock ( & chand - > mu ) ; <nl> return out ; <nl> } <nl> <nl> void grpc_client_channel_watch_connectivity_state ( <nl> grpc_closure_init ( & w - > my_closure , on_external_watch_complete , w ) ; <nl> GRPC_CHANNEL_STACK_REF ( w - > chand - > owning_stack , <nl> " external_connectivity_watcher " ) ; <nl> - gpr_mu_lock ( & chand - > mu_config ) ; <nl> + gpr_mu_lock ( & chand - > mu ) ; <nl> grpc_connectivity_state_notify_on_state_change ( <nl> exec_ctx , & chand - > state_tracker , state , & w - > my_closure ) ; <nl> - gpr_mu_unlock ( & chand - > mu_config ) ; <nl> + gpr_mu_unlock ( & chand - > mu ) ; <nl> } <nl> mmm a / src / core / ext / client_config / lb_policy_factory . h <nl> ppp b / src / core / ext / client_config / lb_policy_factory . h <nl> <nl> typedef struct grpc_lb_policy_factory grpc_lb_policy_factory ; <nl> typedef struct grpc_lb_policy_factory_vtable grpc_lb_policy_factory_vtable ; <nl> <nl> - / * * grpc_lb_policy provides grpc_client_config objects to grpc_channel <nl> - objects * / <nl> struct grpc_lb_policy_factory { <nl> const grpc_lb_policy_factory_vtable * vtable ; <nl> } ; <nl> mmm a / src / core / ext / client_config / resolver . c <nl> ppp b / src / core / ext / client_config / resolver . c <nl> void grpc_resolver_channel_saw_error ( grpc_exec_ctx * exec_ctx , <nl> } <nl> <nl> void grpc_resolver_next ( grpc_exec_ctx * exec_ctx , grpc_resolver * resolver , <nl> - grpc_client_config * * target_config , <nl> + grpc_resolver_result * * result , <nl> grpc_closure * on_complete ) { <nl> - resolver - > vtable - > next ( exec_ctx , resolver , target_config , on_complete ) ; <nl> + resolver - > vtable - > next ( exec_ctx , resolver , result , on_complete ) ; <nl> } <nl> mmm a / src / core / ext / client_config / resolver . h <nl> ppp b / src / core / ext / client_config / resolver . h <nl> <nl> # ifndef GRPC_CORE_EXT_CLIENT_CONFIG_RESOLVER_H <nl> # define GRPC_CORE_EXT_CLIENT_CONFIG_RESOLVER_H <nl> <nl> - # include " src / core / ext / client_config / client_config . h " <nl> + # include " src / core / ext / client_config / resolver_result . h " <nl> # include " src / core / ext / client_config / subchannel . h " <nl> # include " src / core / lib / iomgr / iomgr . h " <nl> <nl> typedef struct grpc_resolver grpc_resolver ; <nl> typedef struct grpc_resolver_vtable grpc_resolver_vtable ; <nl> <nl> - / * * grpc_resolver provides grpc_client_config objects to grpc_channel <nl> + / * * grpc_resolver provides grpc_resolver_result objects to grpc_channel <nl> objects * / <nl> struct grpc_resolver { <nl> const grpc_resolver_vtable * vtable ; <nl> struct grpc_resolver_vtable { <nl> void ( * shutdown ) ( grpc_exec_ctx * exec_ctx , grpc_resolver * resolver ) ; <nl> void ( * channel_saw_error ) ( grpc_exec_ctx * exec_ctx , grpc_resolver * resolver ) ; <nl> void ( * next ) ( grpc_exec_ctx * exec_ctx , grpc_resolver * resolver , <nl> - grpc_client_config * * target_config , grpc_closure * on_complete ) ; <nl> + grpc_resolver_result * * result , grpc_closure * on_complete ) ; <nl> } ; <nl> <nl> # ifdef GRPC_RESOLVER_REFCOUNT_DEBUG <nl> void grpc_resolver_channel_saw_error ( grpc_exec_ctx * exec_ctx , <nl> grpc_resolver * resolver ) ; <nl> <nl> / * * Get the next client config . Called by the channel to fetch a new <nl> - configuration . Expected to set * target_config with a new configuration , <nl> + configuration . Expected to set * result with a new configuration , <nl> and then schedule on_complete for execution . <nl> <nl> - If resolution is fatally broken , set * target_config to NULL and <nl> + If resolution is fatally broken , set * result to NULL and <nl> schedule on_complete . * / <nl> void grpc_resolver_next ( grpc_exec_ctx * exec_ctx , grpc_resolver * resolver , <nl> - grpc_client_config * * target_config , <nl> + grpc_resolver_result * * result , <nl> grpc_closure * on_complete ) ; <nl> <nl> # endif / * GRPC_CORE_EXT_CLIENT_CONFIG_RESOLVER_H * / <nl> mmm a / src / core / ext / client_config / resolver_factory . h <nl> ppp b / src / core / ext / client_config / resolver_factory . h <nl> <nl> typedef struct grpc_resolver_factory grpc_resolver_factory ; <nl> typedef struct grpc_resolver_factory_vtable grpc_resolver_factory_vtable ; <nl> <nl> - / * * grpc_resolver provides grpc_client_config objects to grpc_channel <nl> + / * * grpc_resolver provides grpc_resolver_result objects to grpc_channel <nl> objects * / <nl> struct grpc_resolver_factory { <nl> const grpc_resolver_factory_vtable * vtable ; <nl> similarity index 73 % <nl> rename from src / core / ext / client_config / client_config . c <nl> rename to src / core / ext / client_config / resolver_result . c <nl> mmm a / src / core / ext / client_config / client_config . c <nl> ppp b / src / core / ext / client_config / resolver_result . c <nl> <nl> * <nl> * / <nl> <nl> - # include " src / core / ext / client_config / client_config . h " <nl> + # include " src / core / ext / client_config / resolver_result . h " <nl> <nl> # include < string . h > <nl> <nl> # include < grpc / support / alloc . h > <nl> <nl> - struct grpc_client_config { <nl> + struct grpc_resolver_result { <nl> gpr_refcount refs ; <nl> grpc_lb_policy * lb_policy ; <nl> } ; <nl> <nl> - grpc_client_config * grpc_client_config_create ( ) { <nl> - grpc_client_config * c = gpr_malloc ( sizeof ( * c ) ) ; <nl> + grpc_resolver_result * grpc_resolver_result_create ( ) { <nl> + grpc_resolver_result * c = gpr_malloc ( sizeof ( * c ) ) ; <nl> memset ( c , 0 , sizeof ( * c ) ) ; <nl> gpr_ref_init ( & c - > refs , 1 ) ; <nl> return c ; <nl> } <nl> <nl> - void grpc_client_config_ref ( grpc_client_config * c ) { gpr_ref ( & c - > refs ) ; } <nl> + void grpc_resolver_result_ref ( grpc_resolver_result * c ) { gpr_ref ( & c - > refs ) ; } <nl> <nl> - void grpc_client_config_unref ( grpc_exec_ctx * exec_ctx , grpc_client_config * c ) { <nl> + void grpc_resolver_result_unref ( grpc_exec_ctx * exec_ctx , <nl> + grpc_resolver_result * c ) { <nl> if ( gpr_unref ( & c - > refs ) ) { <nl> if ( c - > lb_policy ! = NULL ) { <nl> - GRPC_LB_POLICY_UNREF ( exec_ctx , c - > lb_policy , " client_config " ) ; <nl> + GRPC_LB_POLICY_UNREF ( exec_ctx , c - > lb_policy , " resolver_result " ) ; <nl> } <nl> gpr_free ( c ) ; <nl> } <nl> } <nl> <nl> - void grpc_client_config_set_lb_policy ( grpc_client_config * c , <nl> - grpc_lb_policy * lb_policy ) { <nl> + void grpc_resolver_result_set_lb_policy ( grpc_resolver_result * c , <nl> + grpc_lb_policy * lb_policy ) { <nl> GPR_ASSERT ( c - > lb_policy = = NULL ) ; <nl> if ( lb_policy ) { <nl> - GRPC_LB_POLICY_REF ( lb_policy , " client_config " ) ; <nl> + GRPC_LB_POLICY_REF ( lb_policy , " resolver_result " ) ; <nl> } <nl> c - > lb_policy = lb_policy ; <nl> } <nl> <nl> - grpc_lb_policy * grpc_client_config_get_lb_policy ( grpc_client_config * c ) { <nl> + grpc_lb_policy * grpc_resolver_result_get_lb_policy ( grpc_resolver_result * c ) { <nl> return c - > lb_policy ; <nl> } <nl> similarity index 68 % <nl> rename from src / core / ext / client_config / client_config . h <nl> rename to src / core / ext / client_config / resolver_result . h <nl> mmm a / src / core / ext / client_config / client_config . h <nl> ppp b / src / core / ext / client_config / resolver_result . h <nl> <nl> * <nl> * / <nl> <nl> - # ifndef GRPC_CORE_EXT_CLIENT_CONFIG_CLIENT_CONFIG_H <nl> - # define GRPC_CORE_EXT_CLIENT_CONFIG_CLIENT_CONFIG_H <nl> + # ifndef GRPC_CORE_EXT_CLIENT_CONFIG_RESOLVER_RESULT_H <nl> + # define GRPC_CORE_EXT_CLIENT_CONFIG_RESOLVER_RESULT_H <nl> <nl> # include " src / core / ext / client_config / lb_policy . h " <nl> <nl> - / * * Total configuration for a client . Provided , and updated , by <nl> - grpc_resolver * / <nl> - typedef struct grpc_client_config grpc_client_config ; <nl> + / * * Results reported from a grpc_resolver . * / <nl> + typedef struct grpc_resolver_result grpc_resolver_result ; <nl> <nl> - grpc_client_config * grpc_client_config_create ( ) ; <nl> - void grpc_client_config_ref ( grpc_client_config * client_config ) ; <nl> - void grpc_client_config_unref ( grpc_exec_ctx * exec_ctx , <nl> - grpc_client_config * client_config ) ; <nl> + grpc_resolver_result * grpc_resolver_result_create ( ) ; <nl> + void grpc_resolver_result_ref ( grpc_resolver_result * client_config ) ; <nl> + void grpc_resolver_result_unref ( grpc_exec_ctx * exec_ctx , <nl> + grpc_resolver_result * client_config ) ; <nl> <nl> - void grpc_client_config_set_lb_policy ( grpc_client_config * client_config , <nl> - grpc_lb_policy * lb_policy ) ; <nl> - grpc_lb_policy * grpc_client_config_get_lb_policy ( <nl> - grpc_client_config * client_config ) ; <nl> + void grpc_resolver_result_set_lb_policy ( grpc_resolver_result * client_config , <nl> + grpc_lb_policy * lb_policy ) ; <nl> + grpc_lb_policy * grpc_resolver_result_get_lb_policy ( <nl> + grpc_resolver_result * client_config ) ; <nl> <nl> - # endif / * GRPC_CORE_EXT_CLIENT_CONFIG_CLIENT_CONFIG_H * / <nl> + # endif / * GRPC_CORE_EXT_CLIENT_CONFIG_RESOLVER_RESULT_H * / <nl> mmm a / src / core / ext / resolver / dns / native / dns_resolver . c <nl> ppp b / src / core / ext / resolver / dns / native / dns_resolver . c <nl> typedef struct { <nl> gpr_mu mu ; <nl> / * * are we currently resolving ? * / <nl> int resolving ; <nl> - / * * which version of resolved_config have we published ? * / <nl> + / * * which version of the result have we published ? * / <nl> int published_version ; <nl> - / * * which version of resolved_config is current ? * / <nl> + / * * which version of the result is current ? * / <nl> int resolved_version ; <nl> / * * pending next completion , or NULL * / <nl> grpc_closure * next_completion ; <nl> - / * * target config address for next completion * / <nl> - grpc_client_config * * target_config ; <nl> - / * * current ( fully resolved ) config * / <nl> - grpc_client_config * resolved_config ; <nl> + / * * target result address for next completion * / <nl> + grpc_resolver_result * * target_result ; <nl> + / * * current ( fully resolved ) result * / <nl> + grpc_resolver_result * resolved_result ; <nl> / * * retry timer * / <nl> bool have_retry_timer ; <nl> grpc_timer retry_timer ; <nl> static void dns_maybe_finish_next_locked ( grpc_exec_ctx * exec_ctx , <nl> static void dns_shutdown ( grpc_exec_ctx * exec_ctx , grpc_resolver * r ) ; <nl> static void dns_channel_saw_error ( grpc_exec_ctx * exec_ctx , grpc_resolver * r ) ; <nl> static void dns_next ( grpc_exec_ctx * exec_ctx , grpc_resolver * r , <nl> - grpc_client_config * * target_config , <nl> + grpc_resolver_result * * target_result , <nl> grpc_closure * on_complete ) ; <nl> <nl> static const grpc_resolver_vtable dns_resolver_vtable = { <nl> static void dns_shutdown ( grpc_exec_ctx * exec_ctx , grpc_resolver * resolver ) { <nl> grpc_timer_cancel ( exec_ctx , & r - > retry_timer ) ; <nl> } <nl> if ( r - > next_completion ! = NULL ) { <nl> - * r - > target_config = NULL ; <nl> + * r - > target_result = NULL ; <nl> grpc_exec_ctx_sched ( exec_ctx , r - > next_completion , <nl> GRPC_ERROR_CREATE ( " Resolver Shutdown " ) , NULL ) ; <nl> r - > next_completion = NULL ; <nl> static void dns_channel_saw_error ( grpc_exec_ctx * exec_ctx , <nl> } <nl> <nl> static void dns_next ( grpc_exec_ctx * exec_ctx , grpc_resolver * resolver , <nl> - grpc_client_config * * target_config , <nl> + grpc_resolver_result * * target_result , <nl> grpc_closure * on_complete ) { <nl> dns_resolver * r = ( dns_resolver * ) resolver ; <nl> gpr_mu_lock ( & r - > mu ) ; <nl> GPR_ASSERT ( ! r - > next_completion ) ; <nl> r - > next_completion = on_complete ; <nl> - r - > target_config = target_config ; <nl> + r - > target_result = target_result ; <nl> if ( r - > resolved_version = = 0 & & ! r - > resolving ) { <nl> gpr_backoff_reset ( & r - > backoff_state ) ; <nl> dns_start_resolving_locked ( exec_ctx , r ) ; <nl> static void dns_on_retry_timer ( grpc_exec_ctx * exec_ctx , void * arg , <nl> static void dns_on_resolved ( grpc_exec_ctx * exec_ctx , void * arg , <nl> grpc_error * error ) { <nl> dns_resolver * r = arg ; <nl> - grpc_client_config * config = NULL ; <nl> + grpc_resolver_result * result = NULL ; <nl> grpc_lb_policy * lb_policy ; <nl> gpr_mu_lock ( & r - > mu ) ; <nl> GPR_ASSERT ( r - > resolving ) ; <nl> static void dns_on_resolved ( grpc_exec_ctx * exec_ctx , void * arg , <nl> grpc_resolved_addresses * addresses = r - > addresses ; <nl> if ( addresses ! = NULL ) { <nl> grpc_lb_policy_args lb_policy_args ; <nl> - config = grpc_client_config_create ( ) ; <nl> + result = grpc_resolver_result_create ( ) ; <nl> memset ( & lb_policy_args , 0 , sizeof ( lb_policy_args ) ) ; <nl> lb_policy_args . addresses = addresses ; <nl> lb_policy_args . client_channel_factory = r - > client_channel_factory ; <nl> lb_policy = <nl> grpc_lb_policy_create ( exec_ctx , r - > lb_policy_name , & lb_policy_args ) ; <nl> if ( lb_policy ! = NULL ) { <nl> - grpc_client_config_set_lb_policy ( config , lb_policy ) ; <nl> + grpc_resolver_result_set_lb_policy ( result , lb_policy ) ; <nl> GRPC_LB_POLICY_UNREF ( exec_ctx , lb_policy , " construction " ) ; <nl> } <nl> grpc_resolved_addresses_destroy ( addresses ) ; <nl> static void dns_on_resolved ( grpc_exec_ctx * exec_ctx , void * arg , <nl> grpc_timer_init ( exec_ctx , & r - > retry_timer , next_try , dns_on_retry_timer , r , <nl> now ) ; <nl> } <nl> - if ( r - > resolved_config ) { <nl> - grpc_client_config_unref ( exec_ctx , r - > resolved_config ) ; <nl> + if ( r - > resolved_result ) { <nl> + grpc_resolver_result_unref ( exec_ctx , r - > resolved_result ) ; <nl> } <nl> - r - > resolved_config = config ; <nl> + r - > resolved_result = result ; <nl> r - > resolved_version + + ; <nl> dns_maybe_finish_next_locked ( exec_ctx , r ) ; <nl> gpr_mu_unlock ( & r - > mu ) ; <nl> static void dns_maybe_finish_next_locked ( grpc_exec_ctx * exec_ctx , <nl> dns_resolver * r ) { <nl> if ( r - > next_completion ! = NULL & & <nl> r - > resolved_version ! = r - > published_version ) { <nl> - * r - > target_config = r - > resolved_config ; <nl> - if ( r - > resolved_config ) { <nl> - grpc_client_config_ref ( r - > resolved_config ) ; <nl> + * r - > target_result = r - > resolved_result ; <nl> + if ( r - > resolved_result ) { <nl> + grpc_resolver_result_ref ( r - > resolved_result ) ; <nl> } <nl> grpc_exec_ctx_sched ( exec_ctx , r - > next_completion , GRPC_ERROR_NONE , NULL ) ; <nl> r - > next_completion = NULL ; <nl> static void dns_maybe_finish_next_locked ( grpc_exec_ctx * exec_ctx , <nl> static void dns_destroy ( grpc_exec_ctx * exec_ctx , grpc_resolver * gr ) { <nl> dns_resolver * r = ( dns_resolver * ) gr ; <nl> gpr_mu_destroy ( & r - > mu ) ; <nl> - if ( r - > resolved_config ) { <nl> - grpc_client_config_unref ( exec_ctx , r - > resolved_config ) ; <nl> + if ( r - > resolved_result ) { <nl> + grpc_resolver_result_unref ( exec_ctx , r - > resolved_result ) ; <nl> } <nl> grpc_client_channel_factory_unref ( exec_ctx , r - > client_channel_factory ) ; <nl> gpr_free ( r - > name ) ; <nl> mmm a / src / core / ext / resolver / sockaddr / sockaddr_resolver . c <nl> ppp b / src / core / ext / resolver / sockaddr / sockaddr_resolver . c <nl> typedef struct { <nl> int published ; <nl> / * * pending next completion , or NULL * / <nl> grpc_closure * next_completion ; <nl> - / * * target config address for next completion * / <nl> - grpc_client_config * * target_config ; <nl> + / * * target result address for next completion * / <nl> + grpc_resolver_result * * target_result ; <nl> } sockaddr_resolver ; <nl> <nl> static void sockaddr_destroy ( grpc_exec_ctx * exec_ctx , grpc_resolver * r ) ; <nl> static void sockaddr_shutdown ( grpc_exec_ctx * exec_ctx , grpc_resolver * r ) ; <nl> static void sockaddr_channel_saw_error ( grpc_exec_ctx * exec_ctx , <nl> grpc_resolver * r ) ; <nl> static void sockaddr_next ( grpc_exec_ctx * exec_ctx , grpc_resolver * r , <nl> - grpc_client_config * * target_config , <nl> + grpc_resolver_result * * target_result , <nl> grpc_closure * on_complete ) ; <nl> <nl> static const grpc_resolver_vtable sockaddr_resolver_vtable = { <nl> static void sockaddr_shutdown ( grpc_exec_ctx * exec_ctx , <nl> sockaddr_resolver * r = ( sockaddr_resolver * ) resolver ; <nl> gpr_mu_lock ( & r - > mu ) ; <nl> if ( r - > next_completion ! = NULL ) { <nl> - * r - > target_config = NULL ; <nl> + * r - > target_result = NULL ; <nl> grpc_exec_ctx_sched ( exec_ctx , r - > next_completion , GRPC_ERROR_NONE , NULL ) ; <nl> r - > next_completion = NULL ; <nl> } <nl> static void sockaddr_channel_saw_error ( grpc_exec_ctx * exec_ctx , <nl> } <nl> <nl> static void sockaddr_next ( grpc_exec_ctx * exec_ctx , grpc_resolver * resolver , <nl> - grpc_client_config * * target_config , <nl> + grpc_resolver_result * * target_result , <nl> grpc_closure * on_complete ) { <nl> sockaddr_resolver * r = ( sockaddr_resolver * ) resolver ; <nl> gpr_mu_lock ( & r - > mu ) ; <nl> GPR_ASSERT ( ! r - > next_completion ) ; <nl> r - > next_completion = on_complete ; <nl> - r - > target_config = target_config ; <nl> + r - > target_result = target_result ; <nl> sockaddr_maybe_finish_next_locked ( exec_ctx , r ) ; <nl> gpr_mu_unlock ( & r - > mu ) ; <nl> } <nl> static void sockaddr_next ( grpc_exec_ctx * exec_ctx , grpc_resolver * resolver , <nl> static void sockaddr_maybe_finish_next_locked ( grpc_exec_ctx * exec_ctx , <nl> sockaddr_resolver * r ) { <nl> if ( r - > next_completion ! = NULL & & ! r - > published ) { <nl> - grpc_client_config * cfg = grpc_client_config_create ( ) ; <nl> + grpc_resolver_result * result = grpc_resolver_result_create ( ) ; <nl> grpc_lb_policy_args lb_policy_args ; <nl> memset ( & lb_policy_args , 0 , sizeof ( lb_policy_args ) ) ; <nl> lb_policy_args . addresses = r - > addresses ; <nl> lb_policy_args . client_channel_factory = r - > client_channel_factory ; <nl> grpc_lb_policy * lb_policy = <nl> grpc_lb_policy_create ( exec_ctx , r - > lb_policy_name , & lb_policy_args ) ; <nl> - grpc_client_config_set_lb_policy ( cfg , lb_policy ) ; <nl> + grpc_resolver_result_set_lb_policy ( result , lb_policy ) ; <nl> GRPC_LB_POLICY_UNREF ( exec_ctx , lb_policy , " sockaddr " ) ; <nl> r - > published = 1 ; <nl> - * r - > target_config = cfg ; <nl> + * r - > target_result = result ; <nl> grpc_exec_ctx_sched ( exec_ctx , r - > next_completion , GRPC_ERROR_NONE , NULL ) ; <nl> r - > next_completion = NULL ; <nl> } <nl> mmm a / src / python / grpcio / grpc_core_dependencies . py <nl> ppp b / src / python / grpcio / grpc_core_dependencies . py <nl> <nl> ' src / core / ext / client_config / channel_connectivity . c ' , <nl> ' src / core / ext / client_config / client_channel . c ' , <nl> ' src / core / ext / client_config / client_channel_factory . c ' , <nl> - ' src / core / ext / client_config / client_config . c ' , <nl> ' src / core / ext / client_config / client_config_plugin . c ' , <nl> ' src / core / ext / client_config / connector . c ' , <nl> ' src / core / ext / client_config / default_initial_connect_string . c ' , <nl> <nl> ' src / core / ext / client_config / resolver . c ' , <nl> ' src / core / ext / client_config / resolver_factory . c ' , <nl> ' src / core / ext / client_config / resolver_registry . c ' , <nl> + ' src / core / ext / client_config / resolver_result . c ' , <nl> ' src / core / ext / client_config / subchannel . c ' , <nl> ' src / core / ext / client_config / subchannel_call_holder . c ' , <nl> ' src / core / ext / client_config / subchannel_index . c ' , <nl> mmm a / tools / doxygen / Doxyfile . core . internal <nl> ppp b / tools / doxygen / Doxyfile . core . internal <nl> src / core / lib / tsi / transport_security . h \ <nl> src / core / lib / tsi / transport_security_interface . h \ <nl> src / core / ext / client_config / client_channel . h \ <nl> src / core / ext / client_config / client_channel_factory . h \ <nl> - src / core / ext / client_config / client_config . h \ <nl> src / core / ext / client_config / connector . h \ <nl> src / core / ext / client_config / initial_connect_string . h \ <nl> src / core / ext / client_config / lb_policy . h \ <nl> src / core / ext / client_config / parse_address . h \ <nl> src / core / ext / client_config / resolver . h \ <nl> src / core / ext / client_config / resolver_factory . h \ <nl> src / core / ext / client_config / resolver_registry . h \ <nl> + src / core / ext / client_config / resolver_result . h \ <nl> src / core / ext / client_config / subchannel . h \ <nl> src / core / ext / client_config / subchannel_call_holder . h \ <nl> src / core / ext / client_config / subchannel_index . h \ <nl> src / core / ext / transport / chttp2 / client / secure / secure_channel_create . c \ <nl> src / core / ext / client_config / channel_connectivity . c \ <nl> src / core / ext / client_config / client_channel . c \ <nl> src / core / ext / client_config / client_channel_factory . c \ <nl> - src / core / ext / client_config / client_config . c \ <nl> src / core / ext / client_config / client_config_plugin . c \ <nl> src / core / ext / client_config / connector . c \ <nl> src / core / ext / client_config / default_initial_connect_string . c \ <nl> src / core / ext / client_config / parse_address . c \ <nl> src / core / ext / client_config / resolver . c \ <nl> src / core / ext / client_config / resolver_factory . c \ <nl> src / core / ext / client_config / resolver_registry . c \ <nl> + src / core / ext / client_config / resolver_result . c \ <nl> src / core / ext / client_config / subchannel . c \ <nl> src / core / ext / client_config / subchannel_call_holder . c \ <nl> src / core / ext / client_config / subchannel_index . c \ <nl> mmm a / tools / run_tests / sources_and_headers . json <nl> ppp b / tools / run_tests / sources_and_headers . json <nl> <nl> " headers " : [ <nl> " src / core / ext / client_config / client_channel . h " , <nl> " src / core / ext / client_config / client_channel_factory . h " , <nl> - " src / core / ext / client_config / client_config . h " , <nl> " src / core / ext / client_config / connector . h " , <nl> " src / core / ext / client_config / initial_connect_string . h " , <nl> " src / core / ext / client_config / lb_policy . h " , <nl> <nl> " src / core / ext / client_config / resolver . h " , <nl> " src / core / ext / client_config / resolver_factory . h " , <nl> " src / core / ext / client_config / resolver_registry . h " , <nl> + " src / core / ext / client_config / resolver_result . h " , <nl> " src / core / ext / client_config / subchannel . h " , <nl> " src / core / ext / client_config / subchannel_call_holder . h " , <nl> " src / core / ext / client_config / subchannel_index . h " , <nl> <nl> " src / core / ext / client_config / client_channel . h " , <nl> " src / core / ext / client_config / client_channel_factory . c " , <nl> " src / core / ext / client_config / client_channel_factory . h " , <nl> - " src / core / ext / client_config / client_config . c " , <nl> - " src / core / ext / client_config / client_config . h " , <nl> " src / core / ext / client_config / client_config_plugin . c " , <nl> " src / core / ext / client_config / connector . c " , <nl> " src / core / ext / client_config / connector . h " , <nl> <nl> " src / core / ext / client_config / resolver_factory . h " , <nl> " src / core / ext / client_config / resolver_registry . c " , <nl> " src / core / ext / client_config / resolver_registry . h " , <nl> + " src / core / ext / client_config / resolver_result . c " , <nl> + " src / core / ext / client_config / resolver_result . h " , <nl> " src / core / ext / client_config / subchannel . c " , <nl> " src / core / ext / client_config / subchannel . h " , <nl> " src / core / ext / client_config / subchannel_call_holder . c " , <nl> mmm a / vsprojects / vcxproj / grpc / grpc . vcxproj <nl> ppp b / vsprojects / vcxproj / grpc / grpc . vcxproj <nl> <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ tsi \ transport_security_interface . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ client_channel . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ client_channel_factory . h " / > <nl> - < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ client_config . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ connector . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ initial_connect_string . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ lb_policy . h " / > <nl> <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ resolver . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ resolver_factory . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ resolver_registry . h " / > <nl> + < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ resolver_result . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ subchannel . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ subchannel_call_holder . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ subchannel_index . h " / > <nl> <nl> < / ClCompile > <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ client_channel_factory . c " > <nl> < / ClCompile > <nl> - < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ client_config . c " > <nl> - < / ClCompile > <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ client_config_plugin . c " > <nl> < / ClCompile > <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ connector . c " > <nl> <nl> < / ClCompile > <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ resolver_registry . c " > <nl> < / ClCompile > <nl> + < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ resolver_result . c " > <nl> + < / ClCompile > <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ subchannel . c " > <nl> < / ClCompile > <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ subchannel_call_holder . c " > <nl> mmm a / vsprojects / vcxproj / grpc / grpc . vcxproj . filters <nl> ppp b / vsprojects / vcxproj / grpc / grpc . vcxproj . filters <nl> <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ client_channel_factory . c " > <nl> < Filter > src \ core \ ext \ client_config < / Filter > <nl> < / ClCompile > <nl> - < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ client_config . c " > <nl> - < Filter > src \ core \ ext \ client_config < / Filter > <nl> - < / ClCompile > <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ client_config_plugin . c " > <nl> < Filter > src \ core \ ext \ client_config < / Filter > <nl> < / ClCompile > <nl> <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ resolver_registry . c " > <nl> < Filter > src \ core \ ext \ client_config < / Filter > <nl> < / ClCompile > <nl> + < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ resolver_result . c " > <nl> + < Filter > src \ core \ ext \ client_config < / Filter > <nl> + < / ClCompile > <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ subchannel . c " > <nl> < Filter > src \ core \ ext \ client_config < / Filter > <nl> < / ClCompile > <nl> <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ client_channel_factory . h " > <nl> < Filter > src \ core \ ext \ client_config < / Filter > <nl> < / ClInclude > <nl> - < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ client_config . h " > <nl> - < Filter > src \ core \ ext \ client_config < / Filter > <nl> - < / ClInclude > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ connector . h " > <nl> < Filter > src \ core \ ext \ client_config < / Filter > <nl> < / ClInclude > <nl> <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ resolver_registry . h " > <nl> < Filter > src \ core \ ext \ client_config < / Filter > <nl> < / ClInclude > <nl> + < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ resolver_result . h " > <nl> + < Filter > src \ core \ ext \ client_config < / Filter > <nl> + < / ClInclude > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ subchannel . h " > <nl> < Filter > src \ core \ ext \ client_config < / Filter > <nl> < / ClInclude > <nl> mmm a / vsprojects / vcxproj / grpc_unsecure / grpc_unsecure . vcxproj <nl> ppp b / vsprojects / vcxproj / grpc_unsecure / grpc_unsecure . vcxproj <nl> <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ transport \ chttp2 \ alpn \ alpn . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ client_channel . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ client_channel_factory . h " / > <nl> - < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ client_config . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ connector . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ initial_connect_string . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ lb_policy . h " / > <nl> <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ resolver . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ resolver_factory . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ resolver_registry . h " / > <nl> + < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ resolver_result . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ subchannel . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ subchannel_call_holder . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ subchannel_index . h " / > <nl> <nl> < / ClCompile > <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ client_channel_factory . c " > <nl> < / ClCompile > <nl> - < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ client_config . c " > <nl> - < / ClCompile > <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ client_config_plugin . c " > <nl> < / ClCompile > <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ connector . c " > <nl> <nl> < / ClCompile > <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ resolver_registry . c " > <nl> < / ClCompile > <nl> + < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ resolver_result . c " > <nl> + < / ClCompile > <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ subchannel . c " > <nl> < / ClCompile > <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ subchannel_call_holder . c " > <nl> mmm a / vsprojects / vcxproj / grpc_unsecure / grpc_unsecure . vcxproj . filters <nl> ppp b / vsprojects / vcxproj / grpc_unsecure / grpc_unsecure . vcxproj . filters <nl> <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ client_channel_factory . c " > <nl> < Filter > src \ core \ ext \ client_config < / Filter > <nl> < / ClCompile > <nl> - < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ client_config . c " > <nl> - < Filter > src \ core \ ext \ client_config < / Filter > <nl> - < / ClCompile > <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ client_config_plugin . c " > <nl> < Filter > src \ core \ ext \ client_config < / Filter > <nl> < / ClCompile > <nl> <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ resolver_registry . c " > <nl> < Filter > src \ core \ ext \ client_config < / Filter > <nl> < / ClCompile > <nl> + < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ resolver_result . c " > <nl> + < Filter > src \ core \ ext \ client_config < / Filter > <nl> + < / ClCompile > <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ subchannel . c " > <nl> < Filter > src \ core \ ext \ client_config < / Filter > <nl> < / ClCompile > <nl> <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ client_channel_factory . h " > <nl> < Filter > src \ core \ ext \ client_config < / Filter > <nl> < / ClInclude > <nl> - < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ client_config . h " > <nl> - < Filter > src \ core \ ext \ client_config < / Filter > <nl> - < / ClInclude > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ connector . h " > <nl> < Filter > src \ core \ ext \ client_config < / Filter > <nl> < / ClInclude > <nl> <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ resolver_registry . h " > <nl> < Filter > src \ core \ ext \ client_config < / Filter > <nl> < / ClInclude > <nl> + < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ resolver_result . h " > <nl> + < Filter > src \ core \ ext \ client_config < / Filter > <nl> + < / ClInclude > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ subchannel . h " > <nl> < Filter > src \ core \ ext \ client_config < / Filter > <nl> < / ClInclude > <nl> | Rename grpc_client_config to grpc_resolver_result . | grpc/grpc | ff4df06a663e1ed7c9e22392c61dcf982ab0f9ff | 2016-08-22T22:02:49Z |
mmm a / README . md <nl> ppp b / README . md <nl> libphonenumber project . We do not evaluate their quality or influence their <nl> maintenance processes . <nl> <nl> * C # : https : / / github . com / aidanbebbington / libphonenumber - csharp <nl> + * Javascript ( stripped - down version ) : https : / / github . com / halt - hammerzeit / libphonenumber - js <nl> + * Objective - c : https : / / github . com / iziz / libPhoneNumber - iOS <nl> * PHP : https : / / github . com / giggsey / libphonenumber - for - php <nl> + * PostgreSQL in - database types : https : / / github . com / blm768 / pg - libphonenumber <nl> * Python : https : / / github . com / daviddrysdale / python - phonenumbers <nl> * Ruby : https : / / github . com / mobi / telephone_number <nl> - * Javascript ( stripped - down version ) : https : / / github . com / halt - hammerzeit / libphonenumber - js <nl> - * Objective - c : https : / / github . com / iziz / libPhoneNumber - iOS <nl> | Update known ports , includes ( ) | google/libphonenumber | b31b4580421d2978fcad786caaaad418f43c5f9b | 2017-04-19T16:39:38Z |
mmm a / src / core / tsi / test_creds / README <nl> ppp b / src / core / tsi / test_creds / README <nl> src / python / grpcio_tests / tests / interop / credentials / <nl> src / python / grpcio_tests / tests / unit / credentials / <nl> src / ruby / spec / testdata / <nl> test / core / end2end / data / <nl> + <nl> + Please also append old ca . pem into new ca . pem so that tests in the old releases <nl> + are interopable with tests in the new releases . <nl> mmm a / src / core / tsi / test_creds / ca . pem <nl> ppp b / src / core / tsi / test_creds / ca . pem <nl> CVTtdJB4CYWpcNyXOdqefrbJW5QNljxgi6Fhvs7JJkBqdXIkWXtFk2eRgOIP2Eo9 <nl> bewb0l + MhRig0 / DVHamyVxrDRbqInU1 / GTNCwcZkXKYFWSf92U + kIcTth24Q1gcw <nl> eZiLl5FfrWokUNytFElXob0V0a5 / kbhiLc3yWmvWqHTpqCALbVyF + rKJo2f5Kw = = <nl> mmm - - END CERTIFICATEmmm - - <nl> + mmm - - BEGIN CERTIFICATEmmm - - <nl> + MIICSjCCAbOgAwIBAgIJAJHGGR4dGioHMA0GCSqGSIb3DQEBCwUAMFYxCzAJBgNV <nl> + BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX <nl> + aWRnaXRzIFB0eSBMdGQxDzANBgNVBAMTBnRlc3RjYTAeFw0xNDExMTEyMjMxMjla <nl> + Fw0yNDExMDgyMjMxMjlaMFYxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0 <nl> + YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxDzANBgNVBAMT <nl> + BnRlc3RjYTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAwEDfBV5MYdlHVHJ7 <nl> + + L4nxrZy7mBfAVXpOc5vMYztssUI7mL2 / iYujiIXM + weZYNTEpLdjyJdu7R5gGUu <nl> + g1jSVK / EPHfc74O7AyZU34PNIP4Sh33N + / A5YexrNgJlPY + E3GdVYi4ldWJjgkAd <nl> + Qah2PH5ACLrIIC6tRka9hcaBlIECAwEAAaMgMB4wDAYDVR0TBAUwAwEB / zAOBgNV <nl> + HQ8BAf8EBAMCAgQwDQYJKoZIhvcNAQELBQADgYEAHzC7jdYlzAVmddi / gdAeKPau <nl> + sPBG / C2HCWqHzpCUHcKuvMzDVkY / MP2o6JIW2DBbY64bO / FceExhjcykgaYtCH / m <nl> + oIU63 + CFOTtR7otyQAWHqXa7q4SbCDlG7DyRFxqG0txPtGvy12lgldA2 + RgcigQG <nl> + Dfcog5wrJytaQ6UA0wE = <nl> + mmm - - END CERTIFICATEmmm - - <nl> mmm a / src / csharp / Grpc . IntegrationTesting / data / ca . pem <nl> ppp b / src / csharp / Grpc . IntegrationTesting / data / ca . pem <nl> CVTtdJB4CYWpcNyXOdqefrbJW5QNljxgi6Fhvs7JJkBqdXIkWXtFk2eRgOIP2Eo9 <nl> bewb0l + MhRig0 / DVHamyVxrDRbqInU1 / GTNCwcZkXKYFWSf92U + kIcTth24Q1gcw <nl> eZiLl5FfrWokUNytFElXob0V0a5 / kbhiLc3yWmvWqHTpqCALbVyF + rKJo2f5Kw = = <nl> mmm - - END CERTIFICATEmmm - - <nl> + mmm - - BEGIN CERTIFICATEmmm - - <nl> + MIICSjCCAbOgAwIBAgIJAJHGGR4dGioHMA0GCSqGSIb3DQEBCwUAMFYxCzAJBgNV <nl> + BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX <nl> + aWRnaXRzIFB0eSBMdGQxDzANBgNVBAMTBnRlc3RjYTAeFw0xNDExMTEyMjMxMjla <nl> + Fw0yNDExMDgyMjMxMjlaMFYxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0 <nl> + YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxDzANBgNVBAMT <nl> + BnRlc3RjYTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAwEDfBV5MYdlHVHJ7 <nl> + + L4nxrZy7mBfAVXpOc5vMYztssUI7mL2 / iYujiIXM + weZYNTEpLdjyJdu7R5gGUu <nl> + g1jSVK / EPHfc74O7AyZU34PNIP4Sh33N + / A5YexrNgJlPY + E3GdVYi4ldWJjgkAd <nl> + Qah2PH5ACLrIIC6tRka9hcaBlIECAwEAAaMgMB4wDAYDVR0TBAUwAwEB / zAOBgNV <nl> + HQ8BAf8EBAMCAgQwDQYJKoZIhvcNAQELBQADgYEAHzC7jdYlzAVmddi / gdAeKPau <nl> + sPBG / C2HCWqHzpCUHcKuvMzDVkY / MP2o6JIW2DBbY64bO / FceExhjcykgaYtCH / m <nl> + oIU63 + CFOTtR7otyQAWHqXa7q4SbCDlG7DyRFxqG0txPtGvy12lgldA2 + RgcigQG <nl> + Dfcog5wrJytaQ6UA0wE = <nl> + mmm - - END CERTIFICATEmmm - - <nl> mmm a / src / objective - c / tests / TestCertificates . bundle / test - certificates . pem <nl> ppp b / src / objective - c / tests / TestCertificates . bundle / test - certificates . pem <nl> CVTtdJB4CYWpcNyXOdqefrbJW5QNljxgi6Fhvs7JJkBqdXIkWXtFk2eRgOIP2Eo9 <nl> bewb0l + MhRig0 / DVHamyVxrDRbqInU1 / GTNCwcZkXKYFWSf92U + kIcTth24Q1gcw <nl> eZiLl5FfrWokUNytFElXob0V0a5 / kbhiLc3yWmvWqHTpqCALbVyF + rKJo2f5Kw = = <nl> mmm - - END CERTIFICATEmmm - - <nl> + mmm - - BEGIN CERTIFICATEmmm - - <nl> + MIICSjCCAbOgAwIBAgIJAJHGGR4dGioHMA0GCSqGSIb3DQEBCwUAMFYxCzAJBgNV <nl> + BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX <nl> + aWRnaXRzIFB0eSBMdGQxDzANBgNVBAMTBnRlc3RjYTAeFw0xNDExMTEyMjMxMjla <nl> + Fw0yNDExMDgyMjMxMjlaMFYxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0 <nl> + YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxDzANBgNVBAMT <nl> + BnRlc3RjYTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAwEDfBV5MYdlHVHJ7 <nl> + + L4nxrZy7mBfAVXpOc5vMYztssUI7mL2 / iYujiIXM + weZYNTEpLdjyJdu7R5gGUu <nl> + g1jSVK / EPHfc74O7AyZU34PNIP4Sh33N + / A5YexrNgJlPY + E3GdVYi4ldWJjgkAd <nl> + Qah2PH5ACLrIIC6tRka9hcaBlIECAwEAAaMgMB4wDAYDVR0TBAUwAwEB / zAOBgNV <nl> + HQ8BAf8EBAMCAgQwDQYJKoZIhvcNAQELBQADgYEAHzC7jdYlzAVmddi / gdAeKPau <nl> + sPBG / C2HCWqHzpCUHcKuvMzDVkY / MP2o6JIW2DBbY64bO / FceExhjcykgaYtCH / m <nl> + oIU63 + CFOTtR7otyQAWHqXa7q4SbCDlG7DyRFxqG0txPtGvy12lgldA2 + RgcigQG <nl> + Dfcog5wrJytaQ6UA0wE = <nl> + mmm - - END CERTIFICATEmmm - - <nl> mmm a / src / php / tests / data / ca . pem <nl> ppp b / src / php / tests / data / ca . pem <nl> CVTtdJB4CYWpcNyXOdqefrbJW5QNljxgi6Fhvs7JJkBqdXIkWXtFk2eRgOIP2Eo9 <nl> bewb0l + MhRig0 / DVHamyVxrDRbqInU1 / GTNCwcZkXKYFWSf92U + kIcTth24Q1gcw <nl> eZiLl5FfrWokUNytFElXob0V0a5 / kbhiLc3yWmvWqHTpqCALbVyF + rKJo2f5Kw = = <nl> mmm - - END CERTIFICATEmmm - - <nl> + mmm - - BEGIN CERTIFICATEmmm - - <nl> + MIICSjCCAbOgAwIBAgIJAJHGGR4dGioHMA0GCSqGSIb3DQEBCwUAMFYxCzAJBgNV <nl> + BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX <nl> + aWRnaXRzIFB0eSBMdGQxDzANBgNVBAMTBnRlc3RjYTAeFw0xNDExMTEyMjMxMjla <nl> + Fw0yNDExMDgyMjMxMjlaMFYxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0 <nl> + YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxDzANBgNVBAMT <nl> + BnRlc3RjYTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAwEDfBV5MYdlHVHJ7 <nl> + + L4nxrZy7mBfAVXpOc5vMYztssUI7mL2 / iYujiIXM + weZYNTEpLdjyJdu7R5gGUu <nl> + g1jSVK / EPHfc74O7AyZU34PNIP4Sh33N + / A5YexrNgJlPY + E3GdVYi4ldWJjgkAd <nl> + Qah2PH5ACLrIIC6tRka9hcaBlIECAwEAAaMgMB4wDAYDVR0TBAUwAwEB / zAOBgNV <nl> + HQ8BAf8EBAMCAgQwDQYJKoZIhvcNAQELBQADgYEAHzC7jdYlzAVmddi / gdAeKPau <nl> + sPBG / C2HCWqHzpCUHcKuvMzDVkY / MP2o6JIW2DBbY64bO / FceExhjcykgaYtCH / m <nl> + oIU63 + CFOTtR7otyQAWHqXa7q4SbCDlG7DyRFxqG0txPtGvy12lgldA2 + RgcigQG <nl> + Dfcog5wrJytaQ6UA0wE = <nl> + mmm - - END CERTIFICATEmmm - - <nl> mmm a / src / python / grpcio_tests / tests / interop / credentials / ca . pem <nl> ppp b / src / python / grpcio_tests / tests / interop / credentials / ca . pem <nl> CVTtdJB4CYWpcNyXOdqefrbJW5QNljxgi6Fhvs7JJkBqdXIkWXtFk2eRgOIP2Eo9 <nl> bewb0l + MhRig0 / DVHamyVxrDRbqInU1 / GTNCwcZkXKYFWSf92U + kIcTth24Q1gcw <nl> eZiLl5FfrWokUNytFElXob0V0a5 / kbhiLc3yWmvWqHTpqCALbVyF + rKJo2f5Kw = = <nl> mmm - - END CERTIFICATEmmm - - <nl> + mmm - - BEGIN CERTIFICATEmmm - - <nl> + MIICSjCCAbOgAwIBAgIJAJHGGR4dGioHMA0GCSqGSIb3DQEBCwUAMFYxCzAJBgNV <nl> + BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX <nl> + aWRnaXRzIFB0eSBMdGQxDzANBgNVBAMTBnRlc3RjYTAeFw0xNDExMTEyMjMxMjla <nl> + Fw0yNDExMDgyMjMxMjlaMFYxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0 <nl> + YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxDzANBgNVBAMT <nl> + BnRlc3RjYTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAwEDfBV5MYdlHVHJ7 <nl> + + L4nxrZy7mBfAVXpOc5vMYztssUI7mL2 / iYujiIXM + weZYNTEpLdjyJdu7R5gGUu <nl> + g1jSVK / EPHfc74O7AyZU34PNIP4Sh33N + / A5YexrNgJlPY + E3GdVYi4ldWJjgkAd <nl> + Qah2PH5ACLrIIC6tRka9hcaBlIECAwEAAaMgMB4wDAYDVR0TBAUwAwEB / zAOBgNV <nl> + HQ8BAf8EBAMCAgQwDQYJKoZIhvcNAQELBQADgYEAHzC7jdYlzAVmddi / gdAeKPau <nl> + sPBG / C2HCWqHzpCUHcKuvMzDVkY / MP2o6JIW2DBbY64bO / FceExhjcykgaYtCH / m <nl> + oIU63 + CFOTtR7otyQAWHqXa7q4SbCDlG7DyRFxqG0txPtGvy12lgldA2 + RgcigQG <nl> + Dfcog5wrJytaQ6UA0wE = <nl> + mmm - - END CERTIFICATEmmm - - <nl> mmm a / src / python / grpcio_tests / tests / unit / credentials / ca . pem <nl> ppp b / src / python / grpcio_tests / tests / unit / credentials / ca . pem <nl> CVTtdJB4CYWpcNyXOdqefrbJW5QNljxgi6Fhvs7JJkBqdXIkWXtFk2eRgOIP2Eo9 <nl> bewb0l + MhRig0 / DVHamyVxrDRbqInU1 / GTNCwcZkXKYFWSf92U + kIcTth24Q1gcw <nl> eZiLl5FfrWokUNytFElXob0V0a5 / kbhiLc3yWmvWqHTpqCALbVyF + rKJo2f5Kw = = <nl> mmm - - END CERTIFICATEmmm - - <nl> + mmm - - BEGIN CERTIFICATEmmm - - <nl> + MIICSjCCAbOgAwIBAgIJAJHGGR4dGioHMA0GCSqGSIb3DQEBCwUAMFYxCzAJBgNV <nl> + BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX <nl> + aWRnaXRzIFB0eSBMdGQxDzANBgNVBAMTBnRlc3RjYTAeFw0xNDExMTEyMjMxMjla <nl> + Fw0yNDExMDgyMjMxMjlaMFYxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0 <nl> + YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxDzANBgNVBAMT <nl> + BnRlc3RjYTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAwEDfBV5MYdlHVHJ7 <nl> + + L4nxrZy7mBfAVXpOc5vMYztssUI7mL2 / iYujiIXM + weZYNTEpLdjyJdu7R5gGUu <nl> + g1jSVK / EPHfc74O7AyZU34PNIP4Sh33N + / A5YexrNgJlPY + E3GdVYi4ldWJjgkAd <nl> + Qah2PH5ACLrIIC6tRka9hcaBlIECAwEAAaMgMB4wDAYDVR0TBAUwAwEB / zAOBgNV <nl> + HQ8BAf8EBAMCAgQwDQYJKoZIhvcNAQELBQADgYEAHzC7jdYlzAVmddi / gdAeKPau <nl> + sPBG / C2HCWqHzpCUHcKuvMzDVkY / MP2o6JIW2DBbY64bO / FceExhjcykgaYtCH / m <nl> + oIU63 + CFOTtR7otyQAWHqXa7q4SbCDlG7DyRFxqG0txPtGvy12lgldA2 + RgcigQG <nl> + Dfcog5wrJytaQ6UA0wE = <nl> + mmm - - END CERTIFICATEmmm - - <nl> mmm a / src / ruby / spec / testdata / ca . pem <nl> ppp b / src / ruby / spec / testdata / ca . pem <nl> CVTtdJB4CYWpcNyXOdqefrbJW5QNljxgi6Fhvs7JJkBqdXIkWXtFk2eRgOIP2Eo9 <nl> bewb0l + MhRig0 / DVHamyVxrDRbqInU1 / GTNCwcZkXKYFWSf92U + kIcTth24Q1gcw <nl> eZiLl5FfrWokUNytFElXob0V0a5 / kbhiLc3yWmvWqHTpqCALbVyF + rKJo2f5Kw = = <nl> mmm - - END CERTIFICATEmmm - - <nl> + mmm - - BEGIN CERTIFICATEmmm - - <nl> + MIICSjCCAbOgAwIBAgIJAJHGGR4dGioHMA0GCSqGSIb3DQEBCwUAMFYxCzAJBgNV <nl> + BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX <nl> + aWRnaXRzIFB0eSBMdGQxDzANBgNVBAMTBnRlc3RjYTAeFw0xNDExMTEyMjMxMjla <nl> + Fw0yNDExMDgyMjMxMjlaMFYxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0 <nl> + YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxDzANBgNVBAMT <nl> + BnRlc3RjYTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAwEDfBV5MYdlHVHJ7 <nl> + + L4nxrZy7mBfAVXpOc5vMYztssUI7mL2 / iYujiIXM + weZYNTEpLdjyJdu7R5gGUu <nl> + g1jSVK / EPHfc74O7AyZU34PNIP4Sh33N + / A5YexrNgJlPY + E3GdVYi4ldWJjgkAd <nl> + Qah2PH5ACLrIIC6tRka9hcaBlIECAwEAAaMgMB4wDAYDVR0TBAUwAwEB / zAOBgNV <nl> + HQ8BAf8EBAMCAgQwDQYJKoZIhvcNAQELBQADgYEAHzC7jdYlzAVmddi / gdAeKPau <nl> + sPBG / C2HCWqHzpCUHcKuvMzDVkY / MP2o6JIW2DBbY64bO / FceExhjcykgaYtCH / m <nl> + oIU63 + CFOTtR7otyQAWHqXa7q4SbCDlG7DyRFxqG0txPtGvy12lgldA2 + RgcigQG <nl> + Dfcog5wrJytaQ6UA0wE = <nl> + mmm - - END CERTIFICATEmmm - - <nl> mmm a / test / core / end2end / data / test_root_cert . cc <nl> ppp b / test / core / end2end / data / test_root_cert . cc <nl> extern const char test_root_cert [ ] = { <nl> 0x70 , 0x71 , 0x43 , 0x41 , 0x4c , 0x62 , 0x56 , 0x79 , 0x46 , 0x2b , 0x72 , 0x4b , <nl> 0x4a , 0x6f , 0x32 , 0x66 , 0x35 , 0x4b , 0x77 , 0x3d , 0x3d , 0x0a , 0x2d , 0x2d , <nl> 0x2d , 0x2d , 0x2d , 0x45 , 0x4e , 0x44 , 0x20 , 0x43 , 0x45 , 0x52 , 0x54 , 0x49 , <nl> - 0x46 , 0x49 , 0x43 , 0x41 , 0x54 , 0x45 , 0x2d , 0x2d , 0x2d , 0x2d , 0x2d , 0x0a } ; <nl> + 0x46 , 0x49 , 0x43 , 0x41 , 0x54 , 0x45 , 0x2d , 0x2d , 0x2d , 0x2d , 0x2d , 0x0a , <nl> + 0x2d , 0x2d , 0x2d , 0x2d , 0x2d , 0x42 , 0x45 , 0x47 , 0x49 , 0x4e , 0x20 , 0x43 , <nl> + 0x45 , 0x52 , 0x54 , 0x49 , 0x46 , 0x49 , 0x43 , 0x41 , 0x54 , 0x45 , 0x2d , 0x2d , <nl> + 0x2d , 0x2d , 0x2d , 0x0a , 0x4d , 0x49 , 0x49 , 0x43 , 0x53 , 0x6a , 0x43 , 0x43 , <nl> + 0x41 , 0x62 , 0x4f , 0x67 , 0x41 , 0x77 , 0x49 , 0x42 , 0x41 , 0x67 , 0x49 , 0x4a , <nl> + 0x41 , 0x4a , 0x48 , 0x47 , 0x47 , 0x52 , 0x34 , 0x64 , 0x47 , 0x69 , 0x6f , 0x48 , <nl> + 0x4d , 0x41 , 0x30 , 0x47 , 0x43 , 0x53 , 0x71 , 0x47 , 0x53 , 0x49 , 0x62 , 0x33 , <nl> + 0x44 , 0x51 , 0x45 , 0x42 , 0x43 , 0x77 , 0x55 , 0x41 , 0x4d , 0x46 , 0x59 , 0x78 , <nl> + 0x43 , 0x7a , 0x41 , 0x4a , 0x42 , 0x67 , 0x4e , 0x56 , 0x0a , 0x42 , 0x41 , 0x59 , <nl> + 0x54 , 0x41 , 0x6b , 0x46 , 0x56 , 0x4d , 0x52 , 0x4d , 0x77 , 0x45 , 0x51 , 0x59 , <nl> + 0x44 , 0x56 , 0x51 , 0x51 , 0x49 , 0x45 , 0x77 , 0x70 , 0x54 , 0x62 , 0x32 , 0x31 , <nl> + 0x6c , 0x4c , 0x56 , 0x4e , 0x30 , 0x59 , 0x58 , 0x52 , 0x6c , 0x4d , 0x53 , 0x45 , <nl> + 0x77 , 0x48 , 0x77 , 0x59 , 0x44 , 0x56 , 0x51 , 0x51 , 0x4b , 0x45 , 0x78 , 0x68 , <nl> + 0x4a , 0x62 , 0x6e , 0x52 , 0x6c , 0x63 , 0x6d , 0x35 , 0x6c , 0x64 , 0x43 , 0x42 , <nl> + 0x58 , 0x0a , 0x61 , 0x57 , 0x52 , 0x6e , 0x61 , 0x58 , 0x52 , 0x7a , 0x49 , 0x46 , <nl> + 0x42 , 0x30 , 0x65 , 0x53 , 0x42 , 0x4d , 0x64 , 0x47 , 0x51 , 0x78 , 0x44 , 0x7a , <nl> + 0x41 , 0x4e , 0x42 , 0x67 , 0x4e , 0x56 , 0x42 , 0x41 , 0x4d , 0x54 , 0x42 , 0x6e , <nl> + 0x52 , 0x6c , 0x63 , 0x33 , 0x52 , 0x6a , 0x59 , 0x54 , 0x41 , 0x65 , 0x46 , 0x77 , <nl> + 0x30 , 0x78 , 0x4e , 0x44 , 0x45 , 0x78 , 0x4d , 0x54 , 0x45 , 0x79 , 0x4d , 0x6a , <nl> + 0x4d , 0x78 , 0x4d , 0x6a , 0x6c , 0x61 , 0x0a , 0x46 , 0x77 , 0x30 , 0x79 , 0x4e , <nl> + 0x44 , 0x45 , 0x78 , 0x4d , 0x44 , 0x67 , 0x79 , 0x4d , 0x6a , 0x4d , 0x78 , 0x4d , <nl> + 0x6a , 0x6c , 0x61 , 0x4d , 0x46 , 0x59 , 0x78 , 0x43 , 0x7a , 0x41 , 0x4a , 0x42 , <nl> + 0x67 , 0x4e , 0x56 , 0x42 , 0x41 , 0x59 , 0x54 , 0x41 , 0x6b , 0x46 , 0x56 , 0x4d , <nl> + 0x52 , 0x4d , 0x77 , 0x45 , 0x51 , 0x59 , 0x44 , 0x56 , 0x51 , 0x51 , 0x49 , 0x45 , <nl> + 0x77 , 0x70 , 0x54 , 0x62 , 0x32 , 0x31 , 0x6c , 0x4c , 0x56 , 0x4e , 0x30 , 0x0a , <nl> + 0x59 , 0x58 , 0x52 , 0x6c , 0x4d , 0x53 , 0x45 , 0x77 , 0x48 , 0x77 , 0x59 , 0x44 , <nl> + 0x56 , 0x51 , 0x51 , 0x4b , 0x45 , 0x78 , 0x68 , 0x4a , 0x62 , 0x6e , 0x52 , 0x6c , <nl> + 0x63 , 0x6d , 0x35 , 0x6c , 0x64 , 0x43 , 0x42 , 0x58 , 0x61 , 0x57 , 0x52 , 0x6e , <nl> + 0x61 , 0x58 , 0x52 , 0x7a , 0x49 , 0x46 , 0x42 , 0x30 , 0x65 , 0x53 , 0x42 , 0x4d , <nl> + 0x64 , 0x47 , 0x51 , 0x78 , 0x44 , 0x7a , 0x41 , 0x4e , 0x42 , 0x67 , 0x4e , 0x56 , <nl> + 0x42 , 0x41 , 0x4d , 0x54 , 0x0a , 0x42 , 0x6e , 0x52 , 0x6c , 0x63 , 0x33 , 0x52 , <nl> + 0x6a , 0x59 , 0x54 , 0x43 , 0x42 , 0x6e , 0x7a , 0x41 , 0x4e , 0x42 , 0x67 , 0x6b , <nl> + 0x71 , 0x68 , 0x6b , 0x69 , 0x47 , 0x39 , 0x77 , 0x30 , 0x42 , 0x41 , 0x51 , 0x45 , <nl> + 0x46 , 0x41 , 0x41 , 0x4f , 0x42 , 0x6a , 0x51 , 0x41 , 0x77 , 0x67 , 0x59 , 0x6b , <nl> + 0x43 , 0x67 , 0x59 , 0x45 , 0x41 , 0x77 , 0x45 , 0x44 , 0x66 , 0x42 , 0x56 , 0x35 , <nl> + 0x4d , 0x59 , 0x64 , 0x6c , 0x48 , 0x56 , 0x48 , 0x4a , 0x37 , 0x0a , 0x2b , 0x4c , <nl> + 0x34 , 0x6e , 0x78 , 0x72 , 0x5a , 0x79 , 0x37 , 0x6d , 0x42 , 0x66 , 0x41 , 0x56 , <nl> + 0x58 , 0x70 , 0x4f , 0x63 , 0x35 , 0x76 , 0x4d , 0x59 , 0x7a , 0x74 , 0x73 , 0x73 , <nl> + 0x55 , 0x49 , 0x37 , 0x6d , 0x4c , 0x32 , 0x2f , 0x69 , 0x59 , 0x75 , 0x6a , 0x69 , <nl> + 0x49 , 0x58 , 0x4d , 0x2b , 0x77 , 0x65 , 0x5a , 0x59 , 0x4e , 0x54 , 0x45 , 0x70 , <nl> + 0x4c , 0x64 , 0x6a , 0x79 , 0x4a , 0x64 , 0x75 , 0x37 , 0x52 , 0x35 , 0x67 , 0x47 , <nl> + 0x55 , 0x75 , 0x0a , 0x67 , 0x31 , 0x6a , 0x53 , 0x56 , 0x4b , 0x2f , 0x45 , 0x50 , <nl> + 0x48 , 0x66 , 0x63 , 0x37 , 0x34 , 0x4f , 0x37 , 0x41 , 0x79 , 0x5a , 0x55 , 0x33 , <nl> + 0x34 , 0x50 , 0x4e , 0x49 , 0x50 , 0x34 , 0x53 , 0x68 , 0x33 , 0x33 , 0x4e , 0x2b , <nl> + 0x2f , 0x41 , 0x35 , 0x59 , 0x65 , 0x78 , 0x72 , 0x4e , 0x67 , 0x4a , 0x6c , 0x50 , <nl> + 0x59 , 0x2b , 0x45 , 0x33 , 0x47 , 0x64 , 0x56 , 0x59 , 0x69 , 0x34 , 0x6c , 0x64 , <nl> + 0x57 , 0x4a , 0x6a , 0x67 , 0x6b , 0x41 , 0x64 , 0x0a , 0x51 , 0x61 , 0x68 , 0x32 , <nl> + 0x50 , 0x48 , 0x35 , 0x41 , 0x43 , 0x4c , 0x72 , 0x49 , 0x49 , 0x43 , 0x36 , 0x74 , <nl> + 0x52 , 0x6b , 0x61 , 0x39 , 0x68 , 0x63 , 0x61 , 0x42 , 0x6c , 0x49 , 0x45 , 0x43 , <nl> + 0x41 , 0x77 , 0x45 , 0x41 , 0x41 , 0x61 , 0x4d , 0x67 , 0x4d , 0x42 , 0x34 , 0x77 , <nl> + 0x44 , 0x41 , 0x59 , 0x44 , 0x56 , 0x52 , 0x30 , 0x54 , 0x42 , 0x41 , 0x55 , 0x77 , <nl> + 0x41 , 0x77 , 0x45 , 0x42 , 0x2f , 0x7a , 0x41 , 0x4f , 0x42 , 0x67 , 0x4e , 0x56 , <nl> + 0x0a , 0x48 , 0x51 , 0x38 , 0x42 , 0x41 , 0x66 , 0x38 , 0x45 , 0x42 , 0x41 , 0x4d , <nl> + 0x43 , 0x41 , 0x67 , 0x51 , 0x77 , 0x44 , 0x51 , 0x59 , 0x4a , 0x4b , 0x6f , 0x5a , <nl> + 0x49 , 0x68 , 0x76 , 0x63 , 0x4e , 0x41 , 0x51 , 0x45 , 0x4c , 0x42 , 0x51 , 0x41 , <nl> + 0x44 , 0x67 , 0x59 , 0x45 , 0x41 , 0x48 , 0x7a , 0x43 , 0x37 , 0x6a , 0x64 , 0x59 , <nl> + 0x6c , 0x7a , 0x41 , 0x56 , 0x6d , 0x64 , 0x64 , 0x69 , 0x2f , 0x67 , 0x64 , 0x41 , <nl> + 0x65 , 0x4b , 0x50 , 0x61 , 0x75 , 0x0a , 0x73 , 0x50 , 0x42 , 0x47 , 0x2f , 0x43 , <nl> + 0x32 , 0x48 , 0x43 , 0x57 , 0x71 , 0x48 , 0x7a , 0x70 , 0x43 , 0x55 , 0x48 , 0x63 , <nl> + 0x4b , 0x75 , 0x76 , 0x4d , 0x7a , 0x44 , 0x56 , 0x6b , 0x59 , 0x2f , 0x4d , 0x50 , <nl> + 0x32 , 0x6f , 0x36 , 0x4a , 0x49 , 0x57 , 0x32 , 0x44 , 0x42 , 0x62 , 0x59 , 0x36 , <nl> + 0x34 , 0x62 , 0x4f , 0x2f , 0x46 , 0x63 , 0x65 , 0x45 , 0x78 , 0x68 , 0x6a , 0x63 , <nl> + 0x79 , 0x6b , 0x67 , 0x61 , 0x59 , 0x74 , 0x43 , 0x48 , 0x2f , 0x6d , 0x0a , 0x6f , <nl> + 0x49 , 0x55 , 0x36 , 0x33 , 0x2b , 0x43 , 0x46 , 0x4f , 0x54 , 0x74 , 0x52 , 0x37 , <nl> + 0x6f , 0x74 , 0x79 , 0x51 , 0x41 , 0x57 , 0x48 , 0x71 , 0x58 , 0x61 , 0x37 , 0x71 , <nl> + 0x34 , 0x53 , 0x62 , 0x43 , 0x44 , 0x6c , 0x47 , 0x37 , 0x44 , 0x79 , 0x52 , 0x46 , <nl> + 0x78 , 0x71 , 0x47 , 0x30 , 0x74 , 0x78 , 0x50 , 0x74 , 0x47 , 0x76 , 0x79 , 0x31 , <nl> + 0x32 , 0x6c , 0x67 , 0x6c , 0x64 , 0x41 , 0x32 , 0x2b , 0x52 , 0x67 , 0x63 , 0x69 , <nl> + 0x67 , 0x51 , 0x47 , 0x0a , 0x44 , 0x66 , 0x63 , 0x6f , 0x67 , 0x35 , 0x77 , 0x72 , <nl> + 0x4a , 0x79 , 0x74 , 0x61 , 0x51 , 0x36 , 0x55 , 0x41 , 0x30 , 0x77 , 0x45 , 0x3d , <nl> + 0x0a , 0x2d , 0x2d , 0x2d , 0x2d , 0x2d , 0x45 , 0x4e , 0x44 , 0x20 , 0x43 , 0x45 , <nl> + 0x52 , 0x54 , 0x49 , 0x46 , 0x49 , 0x43 , 0x41 , 0x54 , 0x45 , 0x2d , 0x2d , 0x2d , <nl> + 0x2d , 0x2d , 0x0a } ; <nl> | Append old ca . pem | grpc/grpc | 13c6b6c612d0740e118e3e3139f81cd850bdd29f | 2020-03-20T21:48:02Z |
mmm a / tensorflow / core / framework / run_handler . cc <nl> ppp b / tensorflow / core / framework / run_handler . cc <nl> namespace { <nl> static constexpr int32 kMaxConcurrentHandlers = 128 ; <nl> / / LINT . ThenChange ( / / tensorflow / core / framework / run_handler_test . cc ) <nl> <nl> - / / TODO ( azaks ) : Refactor with thread : ThreadPool <nl> - class RunHandlerEnvironment { <nl> - typedef Thread EnvThread ; <nl> - struct TaskImpl { <nl> - std : : function < void ( ) > f ; <nl> - Context context ; <nl> - uint64 trace_id ; <nl> - } ; <nl> - Env * const env_ ; <nl> - const ThreadOptions thread_options_ ; <nl> - const string name_ ; <nl> - <nl> - public : <nl> - struct Task { <nl> - std : : unique_ptr < TaskImpl > f ; <nl> - } ; <nl> + typedef typename internal : : RunHandlerEnvironment : : Task Task ; <nl> + typedef Eigen : : RunQueue < Task , 1024 > Queue ; <nl> <nl> - RunHandlerEnvironment ( Env * env , const ThreadOptions & thread_options , <nl> - const string & name ) <nl> - : env_ ( env ) , thread_options_ ( thread_options ) , name_ ( name ) { } <nl> - <nl> - EnvThread * CreateThread ( std : : function < void ( ) > f ) { <nl> - return env_ - > StartThread ( thread_options_ , name_ , [ = ] ( ) { <nl> - / / Set the processor flag to flush denormals to zero . <nl> - port : : ScopedFlushDenormal flush ; <nl> - / / Set the processor rounding mode to ROUND TO NEAREST . <nl> - port : : ScopedSetRound round ( FE_TONEAREST ) ; <nl> - if ( thread_options_ . numa_node ! = port : : kNUMANoAffinity ) { <nl> - port : : NUMASetThreadNodeAffinity ( thread_options_ . numa_node ) ; <nl> - } <nl> - f ( ) ; <nl> - } ) ; <nl> - } <nl> + } / / namespace <nl> <nl> - Task CreateTask ( std : : function < void ( ) > f ) { <nl> - uint64 id = 0 ; <nl> - if ( tracing : : EventCollector : : IsEnabled ( ) ) { <nl> - id = tracing : : GetUniqueArg ( ) ; <nl> - tracing : : RecordEvent ( tracing : : EventCategory : : kScheduleClosure , id ) ; <nl> + namespace internal { <nl> + RunHandlerEnvironment : : RunHandlerEnvironment ( <nl> + Env * env , const ThreadOptions & thread_options , const string & name ) <nl> + : env_ ( env ) , thread_options_ ( thread_options ) , name_ ( name ) { } <nl> + <nl> + RunHandlerEnvironment : : EnvThread * RunHandlerEnvironment : : CreateThread ( <nl> + std : : function < void ( ) > f ) { <nl> + return env_ - > StartThread ( thread_options_ , name_ , [ = ] ( ) { <nl> + / / Set the processor flag to flush denormals to zero . <nl> + port : : ScopedFlushDenormal flush ; <nl> + / / Set the processor rounding mode to ROUND TO NEAREST . <nl> + port : : ScopedSetRound round ( FE_TONEAREST ) ; <nl> + if ( thread_options_ . numa_node ! = port : : kNUMANoAffinity ) { <nl> + port : : NUMASetThreadNodeAffinity ( thread_options_ . numa_node ) ; <nl> } <nl> - return Task { <nl> - std : : unique_ptr < TaskImpl > ( new TaskImpl { <nl> - std : : move ( f ) , <nl> - Context ( ContextKind : : kThread ) , <nl> - id , <nl> - } ) , <nl> - } ; <nl> - } <nl> + f ( ) ; <nl> + } ) ; <nl> + } <nl> <nl> - void ExecuteTask ( const Task & t ) { <nl> - WithContext wc ( t . f - > context ) ; <nl> - tracing : : ScopedRegion region ( tracing : : EventCategory : : kRunClosure , <nl> - t . f - > trace_id ) ; <nl> - t . f - > f ( ) ; <nl> + RunHandlerEnvironment : : Task RunHandlerEnvironment : : CreateTask ( <nl> + std : : function < void ( ) > f ) { <nl> + uint64 id = 0 ; <nl> + if ( tracing : : EventCollector : : IsEnabled ( ) ) { <nl> + id = tracing : : GetUniqueArg ( ) ; <nl> + tracing : : RecordEvent ( tracing : : EventCategory : : kScheduleClosure , id ) ; <nl> } <nl> - } ; <nl> - <nl> - typedef typename RunHandlerEnvironment : : Task Task ; <nl> - typedef Eigen : : RunQueue < Task , 1024 > Queue ; <nl> + return Task { <nl> + std : : unique_ptr < TaskImpl > ( new TaskImpl { <nl> + std : : move ( f ) , <nl> + Context ( ContextKind : : kThread ) , <nl> + id , <nl> + } ) , <nl> + } ; <nl> + } <nl> <nl> - / / To reduce cache misses , we use a doubly - linked list of Waiter structs and <nl> - / / queue them in LIFO order rather than the FIFO order used by a single <nl> - / / condition variable . <nl> - struct Waiter { <nl> - Waiter ( ) { <nl> - next = this ; <nl> - prev = this ; <nl> - } <nl> - condition_variable cv ; <nl> - mutex mu ; <nl> - Waiter * next ; <nl> - Waiter * prev ; <nl> - } ; <nl> + void RunHandlerEnvironment : : ExecuteTask ( const Task & t ) { <nl> + WithContext wc ( t . f - > context ) ; <nl> + tracing : : ScopedRegion region ( tracing : : EventCategory : : kRunClosure , <nl> + t . f - > trace_id ) ; <nl> + t . f - > f ( ) ; <nl> + } <nl> <nl> void WaitOnWaiter ( Waiter * waiter , Waiter * queue_head , mutex * mutex , <nl> int max_sleep_micros ) { <nl> void WaitOnWaiter ( Waiter * waiter , Waiter * queue_head , mutex * mutex , <nl> } <nl> } <nl> <nl> - class ThreadWorkSource { <nl> - public : <nl> - ThreadWorkSource ( ) <nl> - : non_blocking_work_sharding_factor_ ( <nl> - static_cast < int32 > ( ParamFromEnvWithDefault ( <nl> - " TF_RUN_HANDLER_NUM_OF_NON_BLOCKING_QUEUES " , 1 ) ) ) , <nl> - non_blocking_work_queues_ ( non_blocking_work_sharding_factor_ ) , <nl> - blocking_inflight_ ( 0 ) , <nl> - non_blocking_inflight_ ( 0 ) , <nl> - traceme_id_ ( 0 ) , <nl> - version_ ( 0 ) , <nl> - sub_thread_pool_waiter_ ( nullptr ) { <nl> - queue_waiters_ . next = & queue_waiters_ ; <nl> - queue_waiters_ . prev = & queue_waiters_ ; <nl> - for ( int i = 0 ; i < NonBlockingWorkShardingFactor ( ) ; + + i ) { <nl> - non_blocking_work_queues_ . emplace_back ( new NonBlockingQueue ( ) ) ; <nl> - } <nl> + ThreadWorkSource : : ThreadWorkSource ( ) <nl> + : non_blocking_work_sharding_factor_ ( <nl> + static_cast < int32 > ( ParamFromEnvWithDefault ( <nl> + " TF_RUN_HANDLER_NUM_OF_NON_BLOCKING_QUEUES " , 1 ) ) ) , <nl> + non_blocking_work_queues_ ( non_blocking_work_sharding_factor_ ) , <nl> + blocking_inflight_ ( 0 ) , <nl> + non_blocking_inflight_ ( 0 ) , <nl> + traceme_id_ ( 0 ) , <nl> + version_ ( 0 ) , <nl> + sub_thread_pool_waiter_ ( nullptr ) { <nl> + queue_waiters_ . next = & queue_waiters_ ; <nl> + queue_waiters_ . prev = & queue_waiters_ ; <nl> + for ( int i = 0 ; i < NonBlockingWorkShardingFactor ( ) ; + + i ) { <nl> + non_blocking_work_queues_ . emplace_back ( new NonBlockingQueue ( ) ) ; <nl> } <nl> + } <nl> <nl> - ~ ThreadWorkSource ( ) { <nl> - for ( int i = 0 ; i < non_blocking_work_queues_ . size ( ) ; + + i ) { <nl> - delete non_blocking_work_queues_ [ i ] ; <nl> - } <nl> + ThreadWorkSource : : ~ ThreadWorkSource ( ) { <nl> + for ( int i = 0 ; i < non_blocking_work_queues_ . size ( ) ; + + i ) { <nl> + delete non_blocking_work_queues_ [ i ] ; <nl> } <nl> + } <nl> <nl> - Task EnqueueTask ( Task t , bool is_blocking ) { <nl> - mutex * mu = nullptr ; <nl> - Queue * task_queue = nullptr ; <nl> - thread_local int64 closure_counter = 0 ; <nl> - <nl> - if ( ! is_blocking ) { <nl> - int queue_index = + + closure_counter % non_blocking_work_sharding_factor_ ; <nl> - task_queue = & ( non_blocking_work_queues_ [ queue_index ] - > queue ) ; <nl> - mu = & non_blocking_work_queues_ [ queue_index ] - > queue_op_mu ; <nl> - } else { <nl> - task_queue = & blocking_work_queue_ ; <nl> - mu = & blocking_queue_op_mu_ ; <nl> - } <nl> - <nl> - { <nl> - mutex_lock l ( * mu ) ; <nl> - / / For a given queue , only one thread can call PushFront . <nl> - t = task_queue - > PushFront ( std : : move ( t ) ) ; <nl> - } <nl> - <nl> - Waiter * w = nullptr ; <nl> - bool use_sub_thread_pool = ParamFromEnvBoolWithDefault ( <nl> - " TF_RUN_HANDLER_USE_SUB_THREAD_POOL " , false ) ; <nl> - <nl> - Waiter * waiter_queue ; <nl> - mutex * waiter_queue_mu ; <nl> - if ( use_sub_thread_pool ) { <nl> - / / When we use multiple sub thread pools , free threads wait on sub <nl> - / / thread pool waiting queues . Wake up threads from sub thread waiting <nl> - / / queues . <nl> - / / The waiting queues are defined at RunHandlerPool . <nl> - / / Get the waiter_queue and corresponding mutex . Note , the thread work <nl> - / / source may change afterwards if a new request comes or an old request <nl> - / / finishes . <nl> - tf_shared_lock lock ( run_handler_waiter_mu_ ) ; <nl> - waiter_queue = sub_thread_pool_waiter_ ; <nl> - waiter_queue_mu = sub_thread_pool_waiter_mu_ ; <nl> - } else { <nl> - waiter_queue = & queue_waiters_ ; <nl> - waiter_queue_mu = & waiters_mu_ ; <nl> - } <nl> - <nl> - { <nl> - mutex_lock l ( * waiter_queue_mu ) ; <nl> - if ( waiter_queue - > next ! = waiter_queue ) { <nl> - / / Remove waiter from the LIFO queue <nl> - w = waiter_queue - > next ; <nl> - <nl> - CHECK ( w - > prev ! = w ) ; <nl> - CHECK ( w - > next ! = w ) ; <nl> - <nl> - w - > next - > prev = w - > prev ; <nl> - w - > prev - > next = w - > next ; <nl> + Task ThreadWorkSource : : EnqueueTask ( Task t , bool is_blocking ) { <nl> + mutex * mu = nullptr ; <nl> + Queue * task_queue = nullptr ; <nl> + thread_local int64 closure_counter = 0 ; <nl> <nl> - / / Use ` w - > next = = & w ` to indicate that the waiter has been removed <nl> - / / from the queue . <nl> - w - > next = w ; <nl> - w - > prev = w ; <nl> - } <nl> - } <nl> - if ( w ! = nullptr ) { <nl> - / / We call notify_one ( ) without any locks , so we can miss notifications . <nl> - / / The wake up logic is best effort and a thread will wake in short <nl> - / / period of time in case a notification is missed . <nl> - w - > cv . notify_one ( ) ; <nl> - } <nl> - VLOG ( 3 ) < < " Added " < < ( is_blocking ? " inter " : " intra " ) < < " work from " <nl> - < < traceme_id_ . load ( std : : memory_order_relaxed ) ; <nl> - return t ; <nl> + if ( ! is_blocking ) { <nl> + int queue_index = + + closure_counter % non_blocking_work_sharding_factor_ ; <nl> + task_queue = & ( non_blocking_work_queues_ [ queue_index ] - > queue ) ; <nl> + mu = & non_blocking_work_queues_ [ queue_index ] - > queue_op_mu ; <nl> + } else { <nl> + task_queue = & blocking_work_queue_ ; <nl> + mu = & blocking_queue_op_mu_ ; <nl> } <nl> <nl> - Task PopBlockingTask ( ) { return blocking_work_queue_ . PopBack ( ) ; } <nl> - <nl> - Task PopNonBlockingTask ( int start_index , bool search_from_all_queue ) { <nl> - Task t ; <nl> - unsigned sharding_factor = NonBlockingWorkShardingFactor ( ) ; <nl> - for ( unsigned j = 0 ; j < sharding_factor ; + + j ) { <nl> - t = non_blocking_work_queues_ [ ( start_index + j ) % sharding_factor ] <nl> - - > queue . PopBack ( ) ; <nl> - if ( t . f ) { <nl> - return t ; <nl> - } <nl> - if ( ! search_from_all_queue ) { <nl> - break ; <nl> - } <nl> - } <nl> - return t ; <nl> + { <nl> + mutex_lock l ( * mu ) ; <nl> + / / For a given queue , only one thread can call PushFront . <nl> + t = task_queue - > PushFront ( std : : move ( t ) ) ; <nl> } <nl> <nl> - void WaitForWork ( int max_sleep_micros ) { <nl> - thread_local Waiter waiter ; <nl> - WaitOnWaiter ( & waiter , & queue_waiters_ , & waiters_mu_ , max_sleep_micros ) ; <nl> + Waiter * w = nullptr ; <nl> + bool use_sub_thread_pool = <nl> + ParamFromEnvBoolWithDefault ( " TF_RUN_HANDLER_USE_SUB_THREAD_POOL " , false ) ; <nl> + <nl> + Waiter * waiter_queue ; <nl> + mutex * waiter_queue_mu ; <nl> + if ( use_sub_thread_pool ) { <nl> + / / When we use multiple sub thread pools , free threads wait on sub <nl> + / / thread pool waiting queues . Wake up threads from sub thread waiting <nl> + / / queues . <nl> + / / The waiting queues are defined at RunHandlerPool . <nl> + / / Get the waiter_queue and corresponding mutex . Note , the thread work <nl> + / / source may change afterwards if a new request comes or an old request <nl> + / / finishes . <nl> + tf_shared_lock lock ( run_handler_waiter_mu_ ) ; <nl> + waiter_queue = sub_thread_pool_waiter_ ; <nl> + waiter_queue_mu = sub_thread_pool_waiter_mu_ ; <nl> + } else { <nl> + waiter_queue = & queue_waiters_ ; <nl> + waiter_queue_mu = & waiters_mu_ ; <nl> } <nl> + { <nl> + mutex_lock l ( * waiter_queue_mu ) ; <nl> + if ( waiter_queue - > next ! = waiter_queue ) { <nl> + / / Remove waiter from the LIFO queue <nl> + w = waiter_queue - > next ; <nl> <nl> - int TaskQueueSize ( bool is_blocking ) { <nl> - if ( is_blocking ) { <nl> - return blocking_work_queue_ . Size ( ) ; <nl> - } else { <nl> - unsigned total_size = 0 ; <nl> - for ( int i = 0 ; i < non_blocking_work_sharding_factor_ ; + + i ) { <nl> - total_size + = non_blocking_work_queues_ [ i ] - > queue . Size ( ) ; <nl> - } <nl> - return total_size ; <nl> + CHECK ( w - > prev ! = w ) ; / / Crash OK . <nl> + CHECK ( w - > next ! = w ) ; / / Crash OK . <nl> + <nl> + w - > next - > prev = w - > prev ; <nl> + w - > prev - > next = w - > next ; <nl> + <nl> + / / Use ` w - > next = = & w ` to indicate that the waiter has been removed <nl> + / / from the queue . <nl> + w - > next = w ; <nl> + w - > prev = w ; <nl> } <nl> } <nl> + if ( w ! = nullptr ) { <nl> + / / We call notify_one ( ) without any locks , so we can miss notifications . <nl> + / / The wake up logic is best effort and a thread will wake in short <nl> + / / period of time in case a notification is missed . <nl> + w - > cv . notify_one ( ) ; <nl> + } <nl> + VLOG ( 3 ) < < " Added " < < ( is_blocking ? " inter " : " intra " ) < < " work from " <nl> + < < traceme_id_ . load ( std : : memory_order_relaxed ) ; <nl> + return t ; <nl> + } <nl> <nl> - int64 GetTracemeId ( ) { return traceme_id_ . load ( std : : memory_order_relaxed ) ; } <nl> - <nl> - void SetTracemeId ( int64 value ) { traceme_id_ = value ; } <nl> + Task ThreadWorkSource : : PopBlockingTask ( ) { <nl> + return blocking_work_queue_ . PopBack ( ) ; <nl> + } <nl> <nl> - void SetWaiter ( uint64 version , Waiter * waiter , mutex * mutex ) { <nl> - { <nl> - tf_shared_lock lock ( run_handler_waiter_mu_ ) ; <nl> - / / Most of the request won ' t change sub pool for recomputation . <nl> - / / Optimization for avoiding holding exclusive lock to reduce contention . <nl> - if ( sub_thread_pool_waiter_ = = waiter ) { <nl> - return ; <nl> - } <nl> - / / If the current version is a newer version , no need to update . <nl> - if ( version_ > version ) { <nl> - return ; <nl> - } <nl> + Task ThreadWorkSource : : PopNonBlockingTask ( int start_index , <nl> + bool search_from_all_queue ) { <nl> + Task t ; <nl> + unsigned sharding_factor = NonBlockingWorkShardingFactor ( ) ; <nl> + for ( unsigned j = 0 ; j < sharding_factor ; + + j ) { <nl> + t = non_blocking_work_queues_ [ ( start_index + j ) % sharding_factor ] <nl> + - > queue . PopBack ( ) ; <nl> + if ( t . f ) { <nl> + return t ; <nl> + } <nl> + if ( ! search_from_all_queue ) { <nl> + break ; <nl> } <nl> - <nl> - mutex_lock l ( run_handler_waiter_mu_ ) ; <nl> - sub_thread_pool_waiter_ = waiter ; <nl> - sub_thread_pool_waiter_mu_ = mutex ; <nl> - version_ = version ; <nl> } <nl> + return t ; <nl> + } <nl> <nl> - int64 GetInflightTaskCount ( bool is_blocking ) { <nl> - std : : atomic < int64 > * counter = <nl> - is_blocking ? & blocking_inflight_ : & non_blocking_inflight_ ; <nl> - return counter - > load ( std : : memory_order_relaxed ) ; <nl> - } <nl> + void ThreadWorkSource : : WaitForWork ( int max_sleep_micros ) { <nl> + thread_local Waiter waiter ; <nl> + WaitOnWaiter ( & waiter , & queue_waiters_ , & waiters_mu_ , max_sleep_micros ) ; <nl> + } <nl> <nl> - void IncrementInflightTaskCount ( bool is_blocking ) { <nl> - std : : atomic < int64 > * counter = <nl> - is_blocking ? & blocking_inflight_ : & non_blocking_inflight_ ; <nl> - counter - > fetch_add ( 1 , std : : memory_order_relaxed ) ; <nl> + int ThreadWorkSource : : TaskQueueSize ( bool is_blocking ) { <nl> + if ( is_blocking ) { <nl> + return blocking_work_queue_ . Size ( ) ; <nl> + } else { <nl> + unsigned total_size = 0 ; <nl> + for ( int i = 0 ; i < non_blocking_work_sharding_factor_ ; + + i ) { <nl> + total_size + = non_blocking_work_queues_ [ i ] - > queue . Size ( ) ; <nl> + } <nl> + return total_size ; <nl> } <nl> + } <nl> <nl> - void DecrementInflightTaskCount ( bool is_blocking ) { <nl> - std : : atomic < int64 > * counter = <nl> - is_blocking ? & blocking_inflight_ : & non_blocking_inflight_ ; <nl> - counter - > fetch_sub ( 1 , std : : memory_order_relaxed ) ; <nl> - } <nl> + int64 ThreadWorkSource : : GetTracemeId ( ) { <nl> + return traceme_id_ . load ( std : : memory_order_relaxed ) ; <nl> + } <nl> <nl> - unsigned NonBlockingWorkShardingFactor ( ) { <nl> - return non_blocking_work_sharding_factor_ ; <nl> - } <nl> + void ThreadWorkSource : : SetTracemeId ( int64 value ) { traceme_id_ = value ; } <nl> <nl> - std : : string ToString ( ) { <nl> - return strings : : StrCat ( " traceme_id = " , GetTracemeId ( ) , <nl> - " , inter queue size = " , TaskQueueSize ( true ) , <nl> - " , inter inflight = " , GetInflightTaskCount ( true ) , <nl> - " , intra queue size = " , TaskQueueSize ( false ) , <nl> - " , intra inflight = " , GetInflightTaskCount ( false ) ) ; <nl> + void ThreadWorkSource : : SetWaiter ( uint64 version , Waiter * waiter , mutex * mutex ) { <nl> + { <nl> + tf_shared_lock lock ( run_handler_waiter_mu_ ) ; <nl> + / / Most of the request won ' t change sub pool for recomputation . <nl> + / / Optimization for avoiding holding exclusive lock to reduce contention . <nl> + if ( sub_thread_pool_waiter_ = = waiter ) { <nl> + return ; <nl> + } <nl> + / / If the current version is a newer version , no need to update . <nl> + if ( version_ > version ) { <nl> + return ; <nl> + } <nl> } <nl> <nl> - private : <nl> - struct NonBlockingQueue { <nl> - mutex queue_op_mu ; <nl> - char pad [ 128 ] ; <nl> - Queue queue ; <nl> - } ; <nl> + mutex_lock l ( run_handler_waiter_mu_ ) ; <nl> + sub_thread_pool_waiter_ = waiter ; <nl> + sub_thread_pool_waiter_mu_ = mutex ; <nl> + version_ = version ; <nl> + } <nl> <nl> - int32 non_blocking_work_sharding_factor_ ; <nl> - Eigen : : MaxSizeVector < NonBlockingQueue * > non_blocking_work_queues_ ; <nl> + int64 ThreadWorkSource : : GetInflightTaskCount ( bool is_blocking ) { <nl> + std : : atomic < int64 > * counter = <nl> + is_blocking ? & blocking_inflight_ : & non_blocking_inflight_ ; <nl> + return counter - > load ( std : : memory_order_relaxed ) ; <nl> + } <nl> <nl> - std : : atomic < int64 > blocking_inflight_ ; <nl> - std : : atomic < int64 > non_blocking_inflight_ ; <nl> + void ThreadWorkSource : : IncrementInflightTaskCount ( bool is_blocking ) { <nl> + std : : atomic < int64 > * counter = <nl> + is_blocking ? & blocking_inflight_ : & non_blocking_inflight_ ; <nl> + counter - > fetch_add ( 1 , std : : memory_order_relaxed ) ; <nl> + } <nl> <nl> - Queue blocking_work_queue_ ; <nl> - mutex blocking_queue_op_mu_ ; <nl> - char pad_ [ 128 ] ; <nl> - mutex waiters_mu_ ; <nl> - Waiter queue_waiters_ TF_GUARDED_BY ( waiters_mu_ ) ; <nl> - std : : atomic < int64 > traceme_id_ ; <nl> + void ThreadWorkSource : : DecrementInflightTaskCount ( bool is_blocking ) { <nl> + std : : atomic < int64 > * counter = <nl> + is_blocking ? & blocking_inflight_ : & non_blocking_inflight_ ; <nl> + counter - > fetch_sub ( 1 , std : : memory_order_relaxed ) ; <nl> + } <nl> <nl> - mutex run_handler_waiter_mu_ ; <nl> - uint64 version_ TF_GUARDED_BY ( run_handler_waiter_mu_ ) ; <nl> - mutex * sub_thread_pool_waiter_mu_ TF_GUARDED_BY ( run_handler_waiter_mu_ ) ; <nl> - Waiter * sub_thread_pool_waiter_ TF_GUARDED_BY ( run_handler_waiter_mu_ ) ; <nl> - } ; <nl> + unsigned ThreadWorkSource : : NonBlockingWorkShardingFactor ( ) { <nl> + return non_blocking_work_sharding_factor_ ; <nl> + } <nl> <nl> - class RunHandlerThreadPool { <nl> - public : <nl> - struct PerThread { <nl> - constexpr PerThread ( ) : pool ( nullptr ) , thread_id ( - 1 ) { } <nl> - RunHandlerThreadPool * pool ; / / Parent pool , or null for normal threads . <nl> - int thread_id ; / / Worker thread index in pool . <nl> - } ; <nl> + std : : string ThreadWorkSource : : ToString ( ) { <nl> + return strings : : StrCat ( " traceme_id = " , GetTracemeId ( ) , <nl> + " , inter queue size = " , TaskQueueSize ( true ) , <nl> + " , inter inflight = " , GetInflightTaskCount ( true ) , <nl> + " , intra queue size = " , TaskQueueSize ( false ) , <nl> + " , intra inflight = " , GetInflightTaskCount ( false ) ) ; <nl> + } <nl> <nl> - RunHandlerThreadPool ( int num_blocking_threads , int num_non_blocking_threads , <nl> - Env * env , const ThreadOptions & thread_options , <nl> - const string & name , <nl> - Eigen : : MaxSizeVector < mutex > * waiters_mu , <nl> - Eigen : : MaxSizeVector < Waiter > * queue_waiters ) <nl> - : num_threads_ ( num_blocking_threads + num_non_blocking_threads ) , <nl> - num_blocking_threads_ ( num_blocking_threads ) , <nl> - num_non_blocking_threads_ ( num_non_blocking_threads ) , <nl> - thread_data_ ( num_threads_ ) , <nl> - env_ ( env , thread_options , name ) , <nl> - name_ ( name ) , <nl> - waiters_mu_ ( waiters_mu ) , <nl> - queue_waiters_ ( queue_waiters ) , <nl> - use_sub_thread_pool_ ( ParamFromEnvBoolWithDefault ( <nl> - " TF_RUN_HANDLER_USE_SUB_THREAD_POOL " , false ) ) , <nl> - num_threads_in_sub_thread_pool_ ( ParamFromEnvWithDefault ( <nl> - " TF_RUN_HANDLER_NUM_THREADS_IN_SUB_THREAD_POOL " , <nl> - std : : vector < int > ( <nl> - { num_blocking_threads / 2 , <nl> - num_blocking_threads - num_blocking_threads / 2 } ) ) ) , <nl> - sub_thread_pool_start_request_percentage_ ( ParamFromEnvWithDefault ( <nl> - " TF_RUN_HANDLER_SUB_THREAD_POOL_START_REQUEST_PERCENTAGE " , <nl> - std : : vector < double > ( { 0 , 0 . 4 } ) ) ) , <nl> - sub_thread_pool_end_request_percentage_ ( ParamFromEnvWithDefault ( <nl> - " TF_RUN_HANDLER_SUB_THREAD_POOL_END_REQUEST_PERCENTAGE " , <nl> - std : : vector < double > ( { 0 . 4 , 1 } ) ) ) { <nl> - VLOG ( 1 ) < < " Creating RunHandlerThreadPool " < < name < < " with " <nl> - < < num_blocking_threads_ < < " blocking threads and " <nl> - < < num_non_blocking_threads_ < < " non - blocking threads . " ; <nl> - } <nl> + RunHandlerThreadPool : : RunHandlerThreadPool ( <nl> + int num_blocking_threads , int num_non_blocking_threads , Env * env , <nl> + const ThreadOptions & thread_options , const string & name , <nl> + Eigen : : MaxSizeVector < mutex > * waiters_mu , <nl> + Eigen : : MaxSizeVector < Waiter > * queue_waiters ) <nl> + : num_threads_ ( num_blocking_threads + num_non_blocking_threads ) , <nl> + num_blocking_threads_ ( num_blocking_threads ) , <nl> + num_non_blocking_threads_ ( num_non_blocking_threads ) , <nl> + thread_data_ ( num_threads_ ) , <nl> + env_ ( env , thread_options , name ) , <nl> + name_ ( name ) , <nl> + waiters_mu_ ( waiters_mu ) , <nl> + queue_waiters_ ( queue_waiters ) , <nl> + use_sub_thread_pool_ ( ParamFromEnvBoolWithDefault ( <nl> + " TF_RUN_HANDLER_USE_SUB_THREAD_POOL " , false ) ) , <nl> + num_threads_in_sub_thread_pool_ ( ParamFromEnvWithDefault ( <nl> + " TF_RUN_HANDLER_NUM_THREADS_IN_SUB_THREAD_POOL " , <nl> + std : : vector < int > ( { num_blocking_threads / 2 , <nl> + num_blocking_threads - num_blocking_threads / 2 } ) ) ) , <nl> + sub_thread_pool_start_request_percentage_ ( ParamFromEnvWithDefault ( <nl> + " TF_RUN_HANDLER_SUB_THREAD_POOL_START_REQUEST_PERCENTAGE " , <nl> + std : : vector < double > ( { 0 , 0 . 4 } ) ) ) , <nl> + sub_thread_pool_end_request_percentage_ ( ParamFromEnvWithDefault ( <nl> + " TF_RUN_HANDLER_SUB_THREAD_POOL_END_REQUEST_PERCENTAGE " , <nl> + std : : vector < double > ( { 0 . 4 , 1 } ) ) ) { <nl> + thread_data_ . resize ( num_threads_ ) ; <nl> + VLOG ( 1 ) < < " Creating RunHandlerThreadPool " < < name < < " with " <nl> + < < num_blocking_threads_ < < " blocking threads and " <nl> + < < num_non_blocking_threads_ < < " non - blocking threads . " ; <nl> + } <nl> <nl> - ~ RunHandlerThreadPool ( ) { <nl> - VLOG ( 1 ) < < " Exiting RunHandlerThreadPool " < < name_ ; <nl> + RunHandlerThreadPool : : ~ RunHandlerThreadPool ( ) { <nl> + VLOG ( 1 ) < < " Exiting RunHandlerThreadPool " < < name_ ; <nl> <nl> - cancelled_ = true ; <nl> - for ( size_t i = 0 ; i < thread_data_ . size ( ) ; + + i ) { <nl> - { <nl> - mutex_lock l ( thread_data_ [ i ] . mu ) ; <nl> - thread_data_ [ i ] . sources_not_empty . notify_all ( ) ; <nl> - } <nl> - thread_data_ [ i ] . thread . reset ( ) ; <nl> + cancelled_ = true ; <nl> + for ( size_t i = 0 ; i < thread_data_ . size ( ) ; + + i ) { <nl> + { <nl> + mutex_lock l ( thread_data_ [ i ] . mu ) ; <nl> + thread_data_ [ i ] . sources_not_empty . notify_all ( ) ; <nl> } <nl> + thread_data_ [ i ] . thread . reset ( ) ; <nl> } <nl> + } <nl> <nl> - void Start ( ) { <nl> - cancelled_ = false ; <nl> - thread_data_ . resize ( num_threads_ ) ; <nl> - int num_blocking_threads = num_blocking_threads_ ; <nl> - for ( int i = 0 ; i < num_threads_ ; i + + ) { <nl> - int sub_thread_pool_id = num_threads_in_sub_thread_pool_ . size ( ) - 1 ; <nl> - for ( int j = 0 ; j < num_threads_in_sub_thread_pool_ . size ( ) ; + + j ) { <nl> - if ( i < num_threads_in_sub_thread_pool_ [ j ] ) { <nl> - sub_thread_pool_id = j ; <nl> - break ; <nl> - } <nl> + void RunHandlerThreadPool : : Start ( ) { <nl> + cancelled_ = false ; <nl> + int num_blocking_threads = num_blocking_threads_ ; <nl> + for ( int i = 0 ; i < num_threads_ ; i + + ) { <nl> + int sub_thread_pool_id = num_threads_in_sub_thread_pool_ . size ( ) - 1 ; <nl> + for ( int j = 0 ; j < num_threads_in_sub_thread_pool_ . size ( ) ; + + j ) { <nl> + if ( i < num_threads_in_sub_thread_pool_ [ j ] ) { <nl> + sub_thread_pool_id = j ; <nl> + break ; <nl> } <nl> - thread_data_ [ i ] . sub_thread_pool_id = sub_thread_pool_id ; <nl> - thread_data_ [ i ] . thread . reset ( <nl> - env_ . CreateThread ( [ this , i , num_blocking_threads ] ( ) { <nl> - WorkerLoop ( i , i < num_blocking_threads ) ; <nl> - } ) ) ; <nl> } <nl> + thread_data_ [ i ] . sub_thread_pool_id = sub_thread_pool_id ; <nl> + thread_data_ [ i ] . thread . reset ( <nl> + env_ . CreateThread ( [ this , i , num_blocking_threads ] ( ) { <nl> + WorkerLoop ( i , i < num_blocking_threads ) ; <nl> + } ) ) ; <nl> } <nl> + } <nl> <nl> - void AddWorkToQueue ( ThreadWorkSource * tws , bool is_blocking , <nl> - std : : function < void ( ) > fn ) { <nl> - Task t = env_ . CreateTask ( std : : move ( fn ) ) ; <nl> - t = tws - > EnqueueTask ( std : : move ( t ) , is_blocking ) ; <nl> - if ( t . f ) { <nl> - VLOG ( 3 ) < < " Running " < < ( is_blocking ? " inter " : " intra " ) < < " work for " <nl> - < < tws - > GetTracemeId ( ) ; <nl> - env_ . ExecuteTask ( t ) ; <nl> - } <nl> - } <nl> + void RunHandlerThreadPool : : StartOneThreadForTesting ( ) { <nl> + cancelled_ = false ; <nl> + thread_data_ [ 0 ] . sub_thread_pool_id = 0 ; <nl> + thread_data_ [ 0 ] . thread . reset ( <nl> + env_ . CreateThread ( [ this ] ( ) { WorkerLoop ( 0 , true ) ; } ) ) ; <nl> + } <nl> <nl> - / / Set work queues from which the thread ' tid ' can steal its work . <nl> - / / The request with start_request_idx will be attempted first . Other requests <nl> - / / will be attempted in FIFO order based on their arrival time . <nl> - <nl> - / / TODO ( donglin ) Change the task steal order to be round - robin such that if <nl> - / / an attempt to steal task from request i failed , then attempt to steal task <nl> - / / from the next request in terms of the arrival time . This approach may <nl> - / / provide better performance due to less lock retention . The drawback is that <nl> - / / the profiler will be a bit harder to read . <nl> - void SetThreadWorkSources ( <nl> - int tid , int start_request_idx , uint64 version , <nl> - const Eigen : : MaxSizeVector < ThreadWorkSource * > & thread_work_sources ) { <nl> - mutex_lock l ( thread_data_ [ tid ] . mu ) ; <nl> - if ( version > thread_data_ [ tid ] . new_version ) { <nl> - thread_data_ [ tid ] . new_version = version ; <nl> - } else { <nl> - / / A newer version is already updated . No need to update . <nl> - return ; <nl> - } <nl> - thread_data_ [ tid ] . new_thread_work_sources - > resize ( 0 ) ; <nl> + void RunHandlerThreadPool : : AddWorkToQueue ( ThreadWorkSource * tws , <nl> + bool is_blocking , <nl> + std : : function < void ( ) > fn ) { <nl> + Task t = env_ . CreateTask ( std : : move ( fn ) ) ; <nl> + t = tws - > EnqueueTask ( std : : move ( t ) , is_blocking ) ; <nl> + if ( t . f ) { <nl> + VLOG ( 3 ) < < " Running " < < ( is_blocking ? " inter " : " intra " ) < < " work for " <nl> + < < tws - > GetTracemeId ( ) ; <nl> + env_ . ExecuteTask ( t ) ; <nl> + } <nl> + } <nl> <nl> - if ( use_sub_thread_pool_ ) { <nl> - for ( int i = 0 ; i < thread_work_sources . size ( ) ; + + i ) { <nl> - thread_data_ [ tid ] . new_thread_work_sources - > emplace_back ( <nl> - thread_work_sources [ i ] ) ; <nl> - } <nl> - } else { <nl> + / / TODO ( donglin ) Change the task steal order to be round - robin such that if <nl> + / / an attempt to steal task from request i failed , then attempt to steal task <nl> + / / from the next request in terms of the arrival time . This approach may <nl> + / / provide better performance due to less lock retention . The drawback is that <nl> + / / the profiler will be a bit harder to read . <nl> + void RunHandlerThreadPool : : SetThreadWorkSources ( <nl> + int tid , int start_request_idx , uint64 version , <nl> + const Eigen : : MaxSizeVector < ThreadWorkSource * > & thread_work_sources ) { <nl> + mutex_lock l ( thread_data_ [ tid ] . mu ) ; <nl> + if ( version > thread_data_ [ tid ] . new_version ) { <nl> + thread_data_ [ tid ] . new_version = version ; <nl> + } else { <nl> + / / A newer version is already updated . No need to update . <nl> + return ; <nl> + } <nl> + thread_data_ [ tid ] . new_thread_work_sources - > resize ( 0 ) ; <nl> + if ( use_sub_thread_pool_ ) { <nl> + for ( int i = 0 ; i < thread_work_sources . size ( ) ; + + i ) { <nl> thread_data_ [ tid ] . new_thread_work_sources - > emplace_back ( <nl> - thread_work_sources [ start_request_idx ] ) ; <nl> - / / The number of shards for the queue . Threads in each shard will <nl> - / / prioritize different thread_work_sources . Increase the number of shards <nl> - / / could decrease the contention in the queue . For example , when <nl> - / / num_shards = = 1 : thread_work_sources are ordered as start_request_idx , <nl> - / / 0 , 1 , 2 , 3 , 4 . . . for all threads . When num_shards = = 2 : <nl> - / / thread_work_sources are order as start_request_idx , 0 , 2 , 4 . . . 1 , 3 , <nl> - / / 5 . . . for half of the threads and start_request_idx , 1 , 3 , 5 . . . 0 , 2 , <nl> - / / 4 . . . for the other half of the threads . <nl> - int num_shards = <nl> - ParamFromEnvWithDefault ( " TF_RUN_HANDLER_QUEUE_SHARDS " , 1 ) ; <nl> - int token = tid % num_shards ; <nl> - for ( int i = 0 ; i < num_shards ; + + i ) { <nl> - for ( int j = token ; j < thread_work_sources . size ( ) ; j + = num_shards ) { <nl> - if ( j ! = start_request_idx ) { <nl> - thread_data_ [ tid ] . new_thread_work_sources - > emplace_back ( <nl> - thread_work_sources [ j ] ) ; <nl> - } <nl> + thread_work_sources [ i ] ) ; <nl> + } <nl> + } else { <nl> + thread_data_ [ tid ] . new_thread_work_sources - > emplace_back ( <nl> + thread_work_sources [ start_request_idx ] ) ; <nl> + / / The number of shards for the queue . Threads in each shard will <nl> + / / prioritize different thread_work_sources . Increase the number of shards <nl> + / / could decrease the contention in the queue . For example , when <nl> + / / num_shards = = 1 : thread_work_sources are ordered as start_request_idx , <nl> + / / 0 , 1 , 2 , 3 , 4 . . . for all threads . When num_shards = = 2 : <nl> + / / thread_work_sources are order as start_request_idx , 0 , 2 , 4 . . . 1 , 3 , <nl> + / / 5 . . . for half of the threads and start_request_idx , 1 , 3 , 5 . . . 0 , 2 , <nl> + / / 4 . . . for the other half of the threads . <nl> + int num_shards = ParamFromEnvWithDefault ( " TF_RUN_HANDLER_QUEUE_SHARDS " , 1 ) ; <nl> + int token = tid % num_shards ; <nl> + for ( int i = 0 ; i < num_shards ; + + i ) { <nl> + for ( int j = token ; j < thread_work_sources . size ( ) ; j + = num_shards ) { <nl> + if ( j ! = start_request_idx ) { <nl> + thread_data_ [ tid ] . new_thread_work_sources - > emplace_back ( <nl> + thread_work_sources [ j ] ) ; <nl> } <nl> - token = ( token + 1 ) % num_shards ; <nl> } <nl> - thread_data_ [ tid ] . sources_not_empty . notify_all ( ) ; <nl> + token = ( token + 1 ) % num_shards ; <nl> } <nl> + thread_data_ [ tid ] . sources_not_empty . notify_all ( ) ; <nl> } <nl> + } <nl> <nl> - PerThread * GetPerThread ( ) { <nl> - thread_local PerThread per_thread_ ; <nl> - PerThread * pt = & per_thread_ ; <nl> - return pt ; <nl> - } <nl> + RunHandlerThreadPool : : PerThread * RunHandlerThreadPool : : GetPerThread ( ) { <nl> + thread_local RunHandlerThreadPool : : PerThread per_thread_ ; <nl> + RunHandlerThreadPool : : PerThread * pt = & per_thread_ ; <nl> + return pt ; <nl> + } <nl> <nl> - int CurrentThreadId ( ) const { <nl> - const PerThread * pt = <nl> - const_cast < RunHandlerThreadPool * > ( this ) - > GetPerThread ( ) ; <nl> - if ( pt - > pool = = this ) { <nl> - return pt - > thread_id ; <nl> - } else { <nl> - return - 1 ; <nl> - } <nl> + int RunHandlerThreadPool : : CurrentThreadId ( ) const { <nl> + const PerThread * pt = const_cast < RunHandlerThreadPool * > ( this ) - > GetPerThread ( ) ; <nl> + if ( pt - > pool = = this ) { <nl> + return pt - > thread_id ; <nl> + } else { <nl> + return - 1 ; <nl> } <nl> + } <nl> <nl> - int NumThreads ( ) const { return num_threads_ ; } <nl> - <nl> - int NumBlockingThreads ( ) const { return num_blocking_threads_ ; } <nl> - <nl> - int NumNonBlockingThreads ( ) const { return num_non_blocking_threads_ ; } <nl> - <nl> - void WorkerLoop ( int thread_id , bool may_steal_blocking_work ) ; <nl> - <nl> - / / Search tasks from Requets range searching_range_start to <nl> - / / searching_range_end . If there is no tasks in the search range and <nl> - / / may_steal_blocking_work is true , then search from all requests . <nl> - Task FindTask ( <nl> - int searching_range_start , int searching_range_end , int thread_id , <nl> - int sub_thread_pool_id , int max_blocking_inflight , <nl> - bool may_steal_blocking_work , <nl> - const Eigen : : MaxSizeVector < ThreadWorkSource * > & thread_work_sources , <nl> - bool * task_from_blocking_queue , ThreadWorkSource * * tws ) ; <nl> - <nl> - void WaitForWork ( bool is_blocking , int thread_id , <nl> - int32 max_blocking_inflight ) ; <nl> - <nl> - void WaitForWorkInSubThreadPool ( bool is_blocking , int sub_thread_pool_id ) ; <nl> + int RunHandlerThreadPool : : NumThreads ( ) const { return num_threads_ ; } <nl> <nl> - private : <nl> - struct ThreadData { <nl> - ThreadData ( ) <nl> - : new_version ( 0 ) , <nl> - current_index ( 0 ) , <nl> - new_thread_work_sources ( new Eigen : : MaxSizeVector < ThreadWorkSource * > ( <nl> - static_cast < int32 > ( ParamFromEnvWithDefault ( <nl> - " TF_RUN_HANDLER_MAX_CONCURRENT_HANDLERS " , <nl> - kMaxConcurrentHandlers ) ) ) ) , <nl> - current_version ( 0 ) , <nl> - current_thread_work_sources ( <nl> - new Eigen : : MaxSizeVector < ThreadWorkSource * > ( <nl> - static_cast < int32 > ( ParamFromEnvWithDefault ( <nl> - " TF_RUN_HANDLER_MAX_CONCURRENT_HANDLERS " , <nl> - kMaxConcurrentHandlers ) ) ) ) { } <nl> - mutex mu ; <nl> - uint64 new_version ; <nl> - condition_variable sources_not_empty ; <nl> - std : : unique_ptr < Thread > thread ; <nl> - int current_index ; <nl> - std : : unique_ptr < Eigen : : MaxSizeVector < ThreadWorkSource * > > <nl> - new_thread_work_sources TF_GUARDED_BY ( mu ) ; <nl> - <nl> - uint64 current_version ; <nl> - / / Should only be accessed by one thread . <nl> - std : : unique_ptr < Eigen : : MaxSizeVector < ThreadWorkSource * > > <nl> - current_thread_work_sources ; <nl> + int RunHandlerThreadPool : : NumBlockingThreads ( ) const { <nl> + return num_blocking_threads_ ; <nl> + } <nl> <nl> - int sub_thread_pool_id ; <nl> - } ; <nl> + int RunHandlerThreadPool : : NumNonBlockingThreads ( ) const { <nl> + return num_non_blocking_threads_ ; <nl> + } <nl> <nl> - const int num_threads_ ; <nl> - const int num_blocking_threads_ ; <nl> - const int num_non_blocking_threads_ ; <nl> - Eigen : : MaxSizeVector < ThreadData > thread_data_ ; <nl> - RunHandlerEnvironment env_ ; <nl> - std : : atomic < bool > cancelled_ ; <nl> - string name_ ; <nl> - Eigen : : MaxSizeVector < mutex > * waiters_mu_ ; <nl> - Eigen : : MaxSizeVector < Waiter > * queue_waiters_ ; <nl> - <nl> - bool use_sub_thread_pool_ ; <nl> - std : : vector < int > num_threads_in_sub_thread_pool_ ; <nl> - <nl> - / / Threads in each sub thread pool will search tasks from the given <nl> - / / start_request_percentage to end_request_percentage in a round robin <nl> - / / fashion . <nl> - std : : vector < double > sub_thread_pool_start_request_percentage_ ; <nl> - std : : vector < double > sub_thread_pool_end_request_percentage_ ; <nl> - } ; <nl> + RunHandlerThreadPool : : ThreadData : : ThreadData ( ) <nl> + : new_version ( 0 ) , <nl> + current_index ( 0 ) , <nl> + new_thread_work_sources ( <nl> + new Eigen : : MaxSizeVector < ThreadWorkSource * > ( static_cast < int32 > ( <nl> + ParamFromEnvWithDefault ( " TF_RUN_HANDLER_MAX_CONCURRENT_HANDLERS " , <nl> + kMaxConcurrentHandlers ) ) ) ) , <nl> + current_version ( 0 ) , <nl> + current_thread_work_sources ( <nl> + new Eigen : : MaxSizeVector < ThreadWorkSource * > ( static_cast < int32 > ( <nl> + ParamFromEnvWithDefault ( " TF_RUN_HANDLER_MAX_CONCURRENT_HANDLERS " , <nl> + kMaxConcurrentHandlers ) ) ) ) { } <nl> <nl> Task RunHandlerThreadPool : : FindTask ( <nl> int searching_range_start , int searching_range_end , int thread_id , <nl> Task RunHandlerThreadPool : : FindTask ( <nl> int current_index = thread_data_ [ thread_id ] . current_index ; <nl> * task_from_blocking_queue = false ; <nl> <nl> - / / TODO ( chaox ) : Change the search algorithm from round robin to random <nl> - / / walk . <nl> for ( int i = 0 ; i < searching_range_end - searching_range_start ; + + i ) { <nl> - if ( current_index > = searching_range_end ) { <nl> + if ( current_index > = searching_range_end | | <nl> + current_index < searching_range_start ) { <nl> current_index = searching_range_start ; <nl> } <nl> * tws = thread_work_sources [ current_index ] ; <nl> void RunHandlerThreadPool : : WaitForWork ( bool is_blocking , int thread_id , <nl> tws - > WaitForWork ( kMaxSleepMicros ) ; <nl> } <nl> <nl> - } / / namespace <nl> + } / / namespace internal <nl> <nl> / / Contains the concrete implementation of the RunHandler . <nl> / / Externally visible RunHandler class simply forwards the work to this one . <nl> class RunHandler : : Impl { <nl> <nl> RunHandlerPool : : Impl * pool_impl ( ) { return pool_impl_ ; } <nl> <nl> - ThreadWorkSource * tws ( ) { return & tws_ ; } <nl> + internal : : ThreadWorkSource * tws ( ) { return & tws_ ; } <nl> <nl> int64 priority ( ) { return options_ . priority ( ) ; } <nl> <nl> class RunHandler : : Impl { <nl> uint64 start_time_us_ ; <nl> int64 step_id_ ; <nl> std : : unique_ptr < thread : : ThreadPoolInterface > thread_pool_interface_ ; <nl> - ThreadWorkSource tws_ ; <nl> + internal : : ThreadWorkSource tws_ ; <nl> RunOptions : : Experimental : : RunHandlerPoolOptions options_ ; <nl> } ; <nl> <nl> class RunHandlerPool : : Impl { <nl> ParamFromEnvWithDefault ( " TF_RUN_HANDLER_NUM_SUB_THREAD_POOL " , 2 ) ) , <nl> queue_waiters_ ( <nl> ParamFromEnvWithDefault ( " TF_RUN_HANDLER_NUM_SUB_THREAD_POOL " , 2 ) ) , <nl> - run_handler_thread_pool_ ( new RunHandlerThreadPool ( <nl> + run_handler_thread_pool_ ( new internal : : RunHandlerThreadPool ( <nl> num_inter_op_threads , num_intra_op_threads , Env : : Default ( ) , <nl> ThreadOptions ( ) , " tf_run_handler_pool " , & waiters_mu_ , <nl> & queue_waiters_ ) ) , <nl> class RunHandlerPool : : Impl { <nl> run_handler_thread_pool_ . reset ( ) ; <nl> } <nl> <nl> - RunHandlerThreadPool * run_handler_thread_pool ( ) { <nl> + internal : : RunHandlerThreadPool * run_handler_thread_pool ( ) { <nl> return run_handler_thread_pool_ . get ( ) ; <nl> } <nl> <nl> class RunHandlerPool : : Impl { <nl> int64 step_id , int64 timeout_in_ms , <nl> const RunOptions : : Experimental : : RunHandlerPoolOptions & options ) <nl> TF_LOCKS_EXCLUDED ( mu_ ) { <nl> - thread_local std : : unique_ptr < Eigen : : MaxSizeVector < ThreadWorkSource * > > <nl> + thread_local std : : unique_ptr < <nl> + Eigen : : MaxSizeVector < internal : : ThreadWorkSource * > > <nl> thread_work_sources = <nl> - std : : unique_ptr < Eigen : : MaxSizeVector < ThreadWorkSource * > > ( <nl> - new Eigen : : MaxSizeVector < ThreadWorkSource * > ( <nl> + std : : unique_ptr < Eigen : : MaxSizeVector < internal : : ThreadWorkSource * > > ( <nl> + new Eigen : : MaxSizeVector < internal : : ThreadWorkSource * > ( <nl> static_cast < int32 > ( ParamFromEnvWithDefault ( <nl> " TF_RUN_HANDLER_MAX_CONCURRENT_HANDLERS " , <nl> kMaxConcurrentHandlers ) ) ) ) ; <nl> class RunHandlerPool : : Impl { <nl> private : <nl> void RecomputePoolStats ( <nl> int num_active_requests , uint64 version , <nl> - const Eigen : : MaxSizeVector < ThreadWorkSource * > & thread_work_sources ) ; <nl> + const Eigen : : MaxSizeVector < internal : : ThreadWorkSource * > & <nl> + thread_work_sources ) ; <nl> <nl> void LogInfo ( ) TF_EXCLUSIVE_LOCKS_REQUIRED ( mu_ ) ; <nl> <nl> class RunHandlerPool : : Impl { <nl> const int max_handlers_ ; <nl> <nl> Eigen : : MaxSizeVector < mutex > waiters_mu_ ; <nl> - Eigen : : MaxSizeVector < Waiter > queue_waiters_ ; <nl> + Eigen : : MaxSizeVector < internal : : Waiter > queue_waiters_ ; <nl> <nl> - std : : unique_ptr < RunHandlerThreadPool > run_handler_thread_pool_ ; <nl> + std : : unique_ptr < internal : : RunHandlerThreadPool > run_handler_thread_pool_ ; <nl> / / Thread compatible part used only by lock under RunHandlerPool . <nl> / / Handlers are sorted by start time . <nl> / / TODO ( azaks ) : sort by the remaining latency budget . <nl> class RunHandlerPool : : Impl { <nl> <nl> void RunHandlerPool : : Impl : : RecomputePoolStats ( <nl> int num_active_requests , uint64 version , <nl> - const Eigen : : MaxSizeVector < ThreadWorkSource * > & thread_work_sources ) { <nl> + const Eigen : : MaxSizeVector < internal : : ThreadWorkSource * > & <nl> + thread_work_sources ) { <nl> if ( num_active_requests = = 0 ) return ; <nl> <nl> int sub_thread_pool_id = 0 ; <nl> mmm a / tensorflow / core / framework / run_handler . h <nl> ppp b / tensorflow / core / framework / run_handler . h <nl> limitations under the License . <nl> <nl> # include " tensorflow / core / lib / core / threadpool . h " <nl> # include " tensorflow / core / lib / histogram / histogram . h " <nl> + # include " tensorflow / core / platform / context . h " <nl> # include " tensorflow / core / platform / mutex . h " <nl> # include " tensorflow / core / platform / thread_annotations . h " <nl> # include " tensorflow / core / protobuf / config . pb . h " <nl> class RunHandler { <nl> Impl * impl_ ; / / NOT OWNED . <nl> } ; <nl> <nl> + namespace internal { <nl> + <nl> + / / TODO ( azaks ) : Refactor with thread : ThreadPool <nl> + class RunHandlerEnvironment { <nl> + typedef Thread EnvThread ; <nl> + struct TaskImpl { <nl> + std : : function < void ( ) > f ; <nl> + Context context ; <nl> + uint64 trace_id ; <nl> + } ; <nl> + Env * const env_ ; <nl> + const ThreadOptions thread_options_ ; <nl> + const string name_ ; <nl> + <nl> + public : <nl> + struct Task { <nl> + std : : unique_ptr < TaskImpl > f ; <nl> + } ; <nl> + <nl> + RunHandlerEnvironment ( Env * env , const ThreadOptions & thread_options , <nl> + const string & name ) ; <nl> + <nl> + EnvThread * CreateThread ( std : : function < void ( ) > f ) ; <nl> + <nl> + Task CreateTask ( std : : function < void ( ) > f ) ; <nl> + <nl> + void ExecuteTask ( const Task & t ) ; <nl> + } ; <nl> + <nl> + typedef typename RunHandlerEnvironment : : Task Task ; <nl> + typedef Eigen : : RunQueue < Task , 1024 > Queue ; <nl> + <nl> + / / To reduce cache misses , we use a doubly - linked list of Waiter structs and <nl> + / / queue them in LIFO order rather than the FIFO order used by a single <nl> + / / condition variable . <nl> + struct Waiter { <nl> + Waiter ( ) { <nl> + next = this ; <nl> + prev = this ; <nl> + } <nl> + condition_variable cv ; <nl> + mutex mu ; <nl> + Waiter * next ; <nl> + Waiter * prev ; <nl> + } ; <nl> + <nl> + class ThreadWorkSource { <nl> + public : <nl> + ThreadWorkSource ( ) ; <nl> + <nl> + ~ ThreadWorkSource ( ) ; <nl> + <nl> + Task EnqueueTask ( Task t , bool is_blocking ) ; <nl> + <nl> + Task PopBlockingTask ( ) ; <nl> + <nl> + Task PopNonBlockingTask ( int start_index , bool search_from_all_queue ) ; <nl> + <nl> + void WaitForWork ( int max_sleep_micros ) ; <nl> + <nl> + int TaskQueueSize ( bool is_blocking ) ; <nl> + <nl> + int64 GetTracemeId ( ) ; <nl> + <nl> + void SetTracemeId ( int64 value ) ; <nl> + <nl> + void SetWaiter ( uint64 version , Waiter * waiter , mutex * mutex ) ; <nl> + <nl> + int64 GetInflightTaskCount ( bool is_blocking ) ; <nl> + <nl> + void IncrementInflightTaskCount ( bool is_blocking ) ; <nl> + <nl> + void DecrementInflightTaskCount ( bool is_blocking ) ; <nl> + <nl> + unsigned NonBlockingWorkShardingFactor ( ) ; <nl> + <nl> + std : : string ToString ( ) ; <nl> + <nl> + private : <nl> + struct NonBlockingQueue { <nl> + mutex queue_op_mu ; <nl> + char pad [ 128 ] ; <nl> + Queue queue ; <nl> + } ; <nl> + <nl> + int32 non_blocking_work_sharding_factor_ ; <nl> + Eigen : : MaxSizeVector < NonBlockingQueue * > non_blocking_work_queues_ ; <nl> + <nl> + std : : atomic < int64 > blocking_inflight_ ; <nl> + std : : atomic < int64 > non_blocking_inflight_ ; <nl> + <nl> + Queue blocking_work_queue_ ; <nl> + mutex blocking_queue_op_mu_ ; <nl> + char pad_ [ 128 ] ; <nl> + mutex waiters_mu_ ; <nl> + Waiter queue_waiters_ TF_GUARDED_BY ( waiters_mu_ ) ; <nl> + std : : atomic < int64 > traceme_id_ ; <nl> + <nl> + mutex run_handler_waiter_mu_ ; <nl> + uint64 version_ TF_GUARDED_BY ( run_handler_waiter_mu_ ) ; <nl> + mutex * sub_thread_pool_waiter_mu_ TF_GUARDED_BY ( run_handler_waiter_mu_ ) ; <nl> + Waiter * sub_thread_pool_waiter_ TF_GUARDED_BY ( run_handler_waiter_mu_ ) ; <nl> + } ; <nl> + <nl> + class RunHandlerThreadPool { <nl> + public : <nl> + struct PerThread { <nl> + constexpr PerThread ( ) : pool ( nullptr ) , thread_id ( - 1 ) { } <nl> + RunHandlerThreadPool * pool ; / / Parent pool , or null for normal threads . <nl> + int thread_id ; / / Worker thread index in pool . <nl> + } ; <nl> + <nl> + RunHandlerThreadPool ( int num_blocking_threads , int num_non_blocking_threads , <nl> + Env * env , const ThreadOptions & thread_options , <nl> + const string & name , <nl> + Eigen : : MaxSizeVector < mutex > * waiters_mu , <nl> + Eigen : : MaxSizeVector < Waiter > * queue_waiters ) ; <nl> + <nl> + ~ RunHandlerThreadPool ( ) ; <nl> + <nl> + void Start ( ) ; <nl> + <nl> + void StartOneThreadForTesting ( ) ; <nl> + <nl> + void AddWorkToQueue ( ThreadWorkSource * tws , bool is_blocking , <nl> + std : : function < void ( ) > fn ) ; <nl> + <nl> + / / Set work queues from which the thread ' tid ' can steal its work . <nl> + / / The request with start_request_idx will be attempted first . Other requests <nl> + / / will be attempted in FIFO order based on their arrival time . <nl> + void SetThreadWorkSources ( <nl> + int tid , int start_request_idx , uint64 version , <nl> + const Eigen : : MaxSizeVector < ThreadWorkSource * > & thread_work_sources ) ; <nl> + <nl> + PerThread * GetPerThread ( ) ; <nl> + <nl> + int CurrentThreadId ( ) const ; <nl> + <nl> + int NumThreads ( ) const ; <nl> + <nl> + int NumBlockingThreads ( ) const ; <nl> + <nl> + int NumNonBlockingThreads ( ) const ; <nl> + <nl> + void WorkerLoop ( int thread_id , bool may_steal_blocking_work ) ; <nl> + <nl> + / / Search tasks from Requets range searching_range_start to <nl> + / / searching_range_end . If there is no tasks in the search range and <nl> + / / may_steal_blocking_work is true , then search from all requests . <nl> + Task FindTask ( <nl> + int searching_range_start , int searching_range_end , int thread_id , <nl> + int sub_thread_pool_id , int max_blocking_inflight , <nl> + bool may_steal_blocking_work , <nl> + const Eigen : : MaxSizeVector < ThreadWorkSource * > & thread_work_sources , <nl> + bool * task_from_blocking_queue , ThreadWorkSource * * tws ) ; <nl> + <nl> + void WaitForWork ( bool is_blocking , int thread_id , <nl> + int32 max_blocking_inflight ) ; <nl> + <nl> + void WaitForWorkInSubThreadPool ( bool is_blocking , int sub_thread_pool_id ) ; <nl> + <nl> + private : <nl> + struct ThreadData { <nl> + ThreadData ( ) ; <nl> + mutex mu ; <nl> + uint64 new_version ; <nl> + condition_variable sources_not_empty ; <nl> + std : : unique_ptr < Thread > thread ; <nl> + int current_index ; <nl> + std : : unique_ptr < Eigen : : MaxSizeVector < ThreadWorkSource * > > <nl> + new_thread_work_sources TF_GUARDED_BY ( mu ) ; <nl> + <nl> + uint64 current_version ; <nl> + / / Should only be accessed by one thread . <nl> + std : : unique_ptr < Eigen : : MaxSizeVector < ThreadWorkSource * > > <nl> + current_thread_work_sources ; <nl> + <nl> + int sub_thread_pool_id ; <nl> + } ; <nl> + <nl> + const int num_threads_ ; <nl> + const int num_blocking_threads_ ; <nl> + const int num_non_blocking_threads_ ; <nl> + Eigen : : MaxSizeVector < ThreadData > thread_data_ ; <nl> + internal : : RunHandlerEnvironment env_ ; <nl> + std : : atomic < bool > cancelled_ ; <nl> + string name_ ; <nl> + Eigen : : MaxSizeVector < mutex > * waiters_mu_ ; <nl> + Eigen : : MaxSizeVector < Waiter > * queue_waiters_ ; <nl> + <nl> + bool use_sub_thread_pool_ ; <nl> + std : : vector < int > num_threads_in_sub_thread_pool_ ; <nl> + <nl> + / / Threads in each sub thread pool will search tasks from the given <nl> + / / start_request_percentage to end_request_percentage in a round robin <nl> + / / fashion . <nl> + std : : vector < double > sub_thread_pool_start_request_percentage_ ; <nl> + std : : vector < double > sub_thread_pool_end_request_percentage_ ; <nl> + } ; <nl> + <nl> + } / / namespace internal <nl> + <nl> } / / end namespace tensorflow . <nl> <nl> # endif / / TENSORFLOW_CORE_FRAMEWORK_RUN_HANDLER_H_ <nl> mmm a / tensorflow / core / framework / run_handler_test . cc <nl> ppp b / tensorflow / core / framework / run_handler_test . cc <nl> TEST ( RunHandlerUtilTest , PrioritySchedulingTest ) { <nl> EXPECT_EQ ( sorted_active_list [ 3 ] , 1 ) ; <nl> } <nl> <nl> + TEST ( RunHandlerThreadPool , EnqueueTask ) { <nl> + Eigen : : MaxSizeVector < mutex > waiters_mu ( 2 ) ; <nl> + waiters_mu . resize ( 2 ) ; <nl> + Eigen : : MaxSizeVector < internal : : Waiter > waiters ( 2 ) ; <nl> + waiters . resize ( 2 ) ; <nl> + internal : : RunHandlerThreadPool run_handler_thread_pool ( <nl> + / * num_blocking_threads = * / 0 , / * num_non_blocking_threads = * / 0 , <nl> + Env : : Default ( ) , ThreadOptions ( ) , " tf_run_handler_pool " , & waiters_mu , <nl> + & waiters ) ; <nl> + internal : : ThreadWorkSource tws ; <nl> + <nl> + int result = 0 ; <nl> + std : : function < void ( ) > fn = [ & result ] { result = 1 ; } ; <nl> + std : : function < void ( ) > fn2 = [ & result ] { result = 2 ; } ; <nl> + run_handler_thread_pool . AddWorkToQueue ( & tws , / * is_blocking = * / true , fn ) ; <nl> + EXPECT_EQ ( tws . TaskQueueSize ( / * is_blocking = * / true ) , 1 ) ; <nl> + run_handler_thread_pool . AddWorkToQueue ( & tws , / * is_blocking = * / true , fn2 ) ; <nl> + EXPECT_EQ ( tws . TaskQueueSize ( / * is_blocking = * / true ) , 2 ) ; <nl> + tws . PopBlockingTask ( ) . f - > f ( ) ; <nl> + EXPECT_EQ ( result , 1 ) ; <nl> + tws . PopBlockingTask ( ) . f - > f ( ) ; <nl> + EXPECT_EQ ( result , 2 ) ; <nl> + <nl> + run_handler_thread_pool . AddWorkToQueue ( & tws , / * is_blocking = * / false , fn ) ; <nl> + EXPECT_EQ ( tws . TaskQueueSize ( / * is_blocking = * / false ) , 1 ) ; <nl> + run_handler_thread_pool . AddWorkToQueue ( & tws , / * is_blocking = * / false , fn2 ) ; <nl> + EXPECT_EQ ( tws . TaskQueueSize ( / * is_blocking = * / false ) , 2 ) ; <nl> + tws . PopNonBlockingTask ( 0 , true ) . f - > f ( ) ; <nl> + EXPECT_EQ ( result , 1 ) ; <nl> + tws . PopNonBlockingTask ( 0 , true ) . f - > f ( ) ; <nl> + EXPECT_EQ ( result , 2 ) ; <nl> + } <nl> + <nl> + TEST ( RunHandlerThreadPool , FindTask ) { <nl> + Eigen : : MaxSizeVector < mutex > waiters_mu ( 2 ) ; <nl> + waiters_mu . resize ( 2 ) ; <nl> + Eigen : : MaxSizeVector < internal : : Waiter > waiters ( 2 ) ; <nl> + waiters . resize ( 2 ) ; <nl> + internal : : RunHandlerThreadPool run_handler_thread_pool ( <nl> + / * num_blocking_threads = * / 1 , / * num_non_blocking_threads = * / 0 , <nl> + Env : : Default ( ) , ThreadOptions ( ) , " tf_run_handler_pool " , & waiters_mu , <nl> + & waiters ) ; <nl> + <nl> + Eigen : : MaxSizeVector < internal : : ThreadWorkSource * > thread_work_sources ( 5 ) ; <nl> + thread_work_sources . resize ( 5 ) ; <nl> + for ( int i = 0 ; i < 5 ; + + i ) { <nl> + thread_work_sources [ i ] = new internal : : ThreadWorkSource ( ) ; <nl> + } <nl> + <nl> + { <nl> + / / The thread should search the task following round robin fashion . <nl> + int result = - 1 ; <nl> + run_handler_thread_pool . AddWorkToQueue ( thread_work_sources [ 2 ] , <nl> + / * is_blocking = * / true , <nl> + [ & result ] { result = 2 ; } ) ; <nl> + run_handler_thread_pool . AddWorkToQueue ( thread_work_sources [ 2 ] , <nl> + / * is_blocking = * / true , <nl> + [ & result ] { result = 2 ; } ) ; <nl> + run_handler_thread_pool . AddWorkToQueue ( thread_work_sources [ 3 ] , <nl> + / * is_blocking = * / true , <nl> + [ & result ] { result = 3 ; } ) ; <nl> + run_handler_thread_pool . AddWorkToQueue ( thread_work_sources [ 3 ] , <nl> + / * is_blocking = * / true , <nl> + [ & result ] { result = 3 ; } ) ; <nl> + <nl> + const auto find_blocking_task_from_all_handlers = <nl> + [ & ] ( bool * task_from_blocking_queue , internal : : Task * t ) { <nl> + internal : : ThreadWorkSource * tws ; <nl> + * t = run_handler_thread_pool . FindTask ( <nl> + / * searching_range_start = * / 0 , / * searching_range_end = * / 5 , <nl> + / * thread_id = * / 0 , <nl> + / * sub_thread_pool_id = * / 0 , / * max_blocking_inflight = * / 10 , <nl> + / * may_steal_blocking_work = * / true , thread_work_sources , <nl> + task_from_blocking_queue , & tws ) ; <nl> + } ; <nl> + bool task_from_blocking_queue ; <nl> + internal : : Task t ; <nl> + find_blocking_task_from_all_handlers ( & task_from_blocking_queue , & t ) ; <nl> + EXPECT_EQ ( task_from_blocking_queue , true ) ; <nl> + t . f - > f ( ) ; <nl> + EXPECT_EQ ( result , 2 ) ; <nl> + <nl> + find_blocking_task_from_all_handlers ( & task_from_blocking_queue , & t ) ; <nl> + EXPECT_EQ ( task_from_blocking_queue , true ) ; <nl> + t . f - > f ( ) ; <nl> + EXPECT_EQ ( result , 3 ) ; <nl> + <nl> + find_blocking_task_from_all_handlers ( & task_from_blocking_queue , & t ) ; <nl> + EXPECT_EQ ( task_from_blocking_queue , true ) ; <nl> + t . f - > f ( ) ; <nl> + EXPECT_EQ ( result , 2 ) ; <nl> + <nl> + find_blocking_task_from_all_handlers ( & task_from_blocking_queue , & t ) ; <nl> + EXPECT_EQ ( task_from_blocking_queue , true ) ; <nl> + t . f - > f ( ) ; <nl> + EXPECT_EQ ( result , 3 ) ; <nl> + } <nl> + <nl> + { <nl> + / / Task out of searching range cannot be found . <nl> + int result = - 1 ; <nl> + run_handler_thread_pool . AddWorkToQueue ( thread_work_sources [ 3 ] , <nl> + / * is_blocking = * / true , <nl> + [ & result ] { result = 3 ; } ) ; <nl> + <nl> + const auto find_blocking_task_from_range = <nl> + [ & ] ( bool * task_from_blocking_queue , internal : : Task * t , int range_start , <nl> + int range_end ) { <nl> + internal : : ThreadWorkSource * tws ; <nl> + * t = run_handler_thread_pool . FindTask ( <nl> + range_start , range_end , <nl> + / * thread_id = * / 0 , <nl> + / * sub_thread_pool_id = * / 0 , / * max_blocking_inflight = * / 10 , <nl> + / * may_steal_blocking_work = * / true , thread_work_sources , <nl> + task_from_blocking_queue , & tws ) ; <nl> + } ; <nl> + <nl> + bool task_from_blocking_queue ; <nl> + internal : : Task t ; <nl> + find_blocking_task_from_range ( & task_from_blocking_queue , & t , 0 , 3 ) ; <nl> + EXPECT_EQ ( t . f , nullptr ) ; <nl> + <nl> + / / Clean up the queue . <nl> + find_blocking_task_from_range ( & task_from_blocking_queue , & t , 0 , 5 ) ; <nl> + } <nl> + <nl> + { <nl> + / / The thread should search from start range if the currrent index is <nl> + / / smaller . <nl> + int result = - 1 ; <nl> + run_handler_thread_pool . AddWorkToQueue ( thread_work_sources [ 2 ] , <nl> + / * is_blocking = * / true , <nl> + [ & result ] { result = 2 ; } ) ; <nl> + run_handler_thread_pool . AddWorkToQueue ( thread_work_sources [ 3 ] , <nl> + / * is_blocking = * / true , <nl> + [ & result ] { result = 3 ; } ) ; <nl> + <nl> + const auto find_blocking_task_from_range = <nl> + [ & ] ( bool * task_from_blocking_queue , internal : : Task * t , int range_start , <nl> + int range_end ) { <nl> + internal : : ThreadWorkSource * tws ; <nl> + * t = run_handler_thread_pool . FindTask ( <nl> + range_start , range_end , <nl> + / * thread_id = * / 0 , <nl> + / * sub_thread_pool_id = * / 0 , / * max_blocking_inflight = * / 10 , <nl> + / * may_steal_blocking_work = * / true , thread_work_sources , <nl> + task_from_blocking_queue , & tws ) ; <nl> + } ; <nl> + bool task_from_blocking_queue ; <nl> + internal : : Task t ; <nl> + find_blocking_task_from_range ( & task_from_blocking_queue , & t , 3 , 5 ) ; <nl> + EXPECT_EQ ( task_from_blocking_queue , true ) ; <nl> + t . f - > f ( ) ; <nl> + EXPECT_EQ ( result , 3 ) ; <nl> + <nl> + find_blocking_task_from_range ( & task_from_blocking_queue , & t , 0 , 5 ) ; <nl> + EXPECT_EQ ( task_from_blocking_queue , true ) ; <nl> + t . f - > f ( ) ; <nl> + EXPECT_EQ ( result , 2 ) ; <nl> + } <nl> + <nl> + { <nl> + / / The thread should search within the range even if the current index <nl> + / / is larger than searching_range_end ; <nl> + int result = - 1 ; <nl> + run_handler_thread_pool . AddWorkToQueue ( thread_work_sources [ 2 ] , <nl> + / * is_blocking = * / true , <nl> + [ & result ] { result = 2 ; } ) ; <nl> + <nl> + const auto find_blocking_task_from_range = <nl> + [ & ] ( bool * task_from_blocking_queue , internal : : Task * t , int range_start , <nl> + int range_end ) { <nl> + internal : : ThreadWorkSource * tws ; <nl> + * t = run_handler_thread_pool . FindTask ( <nl> + range_start , range_end , <nl> + / * thread_id = * / 0 , <nl> + / * sub_thread_pool_id = * / 0 , / * max_blocking_inflight = * / 10 , <nl> + / * may_steal_blocking_work = * / true , thread_work_sources , <nl> + task_from_blocking_queue , & tws ) ; <nl> + } ; <nl> + bool task_from_blocking_queue ; <nl> + / / Make the current index to be 3 . <nl> + internal : : Task t ; <nl> + find_blocking_task_from_range ( & task_from_blocking_queue , & t , 0 , 5 ) ; <nl> + EXPECT_EQ ( task_from_blocking_queue , true ) ; <nl> + t . f - > f ( ) ; <nl> + EXPECT_EQ ( result , 2 ) ; <nl> + <nl> + / / Search in a smaller range . <nl> + run_handler_thread_pool . AddWorkToQueue ( thread_work_sources [ 2 ] , <nl> + / * is_blocking = * / true , <nl> + [ & result ] { result = 2 ; } ) ; <nl> + run_handler_thread_pool . AddWorkToQueue ( thread_work_sources [ 3 ] , <nl> + / * is_blocking = * / true , <nl> + [ & result ] { result = 3 ; } ) ; <nl> + find_blocking_task_from_range ( & task_from_blocking_queue , & t , 0 , 3 ) ; <nl> + EXPECT_EQ ( task_from_blocking_queue , true ) ; <nl> + t . f - > f ( ) ; <nl> + EXPECT_EQ ( result , 2 ) ; <nl> + <nl> + / / Clean up the queue . <nl> + find_blocking_task_from_range ( & task_from_blocking_queue , & t , 0 , 5 ) ; <nl> + EXPECT_EQ ( task_from_blocking_queue , true ) ; <nl> + t . f - > f ( ) ; <nl> + EXPECT_EQ ( result , 3 ) ; <nl> + } <nl> + <nl> + { <nl> + / / We prefer blocking task for blocking threads . <nl> + int result = - 1 ; <nl> + run_handler_thread_pool . AddWorkToQueue ( thread_work_sources [ 2 ] , <nl> + / * is_blocking = * / false , <nl> + [ & result ] { result = 2 ; } ) ; <nl> + run_handler_thread_pool . AddWorkToQueue ( thread_work_sources [ 2 ] , <nl> + / * is_blocking = * / true , <nl> + [ & result ] { result = 2 ; } ) ; <nl> + const auto blocking_thread_find_task_from_all_handler = <nl> + [ & ] ( bool * task_from_blocking_queue , internal : : Task * t ) { <nl> + internal : : ThreadWorkSource * tws ; <nl> + * t = run_handler_thread_pool . FindTask ( <nl> + / * searching_range_start = * / 0 , / * searching_range_end = * / 5 , <nl> + / * thread_id = * / 0 , <nl> + / * sub_thread_pool_id = * / 0 , / * max_blocking_inflight = * / 10 , <nl> + / * may_steal_blocking_work = * / true , thread_work_sources , <nl> + task_from_blocking_queue , & tws ) ; <nl> + } ; <nl> + bool task_from_blocking_queue ; <nl> + internal : : Task t ; <nl> + blocking_thread_find_task_from_all_handler ( & task_from_blocking_queue , & t ) ; <nl> + EXPECT_EQ ( task_from_blocking_queue , true ) ; <nl> + t . f - > f ( ) ; <nl> + EXPECT_EQ ( result , 2 ) ; <nl> + <nl> + blocking_thread_find_task_from_all_handler ( & task_from_blocking_queue , & t ) ; <nl> + EXPECT_EQ ( task_from_blocking_queue , false ) ; <nl> + t . f - > f ( ) ; <nl> + EXPECT_EQ ( result , 2 ) ; <nl> + } <nl> + <nl> + { <nl> + / / Nonblocking threads can only pick up non - blocking task . <nl> + int result = - 1 ; <nl> + run_handler_thread_pool . AddWorkToQueue ( thread_work_sources [ 2 ] , <nl> + / * is_blocking = * / false , <nl> + [ & result ] { result = 2 ; } ) ; <nl> + run_handler_thread_pool . AddWorkToQueue ( thread_work_sources [ 2 ] , <nl> + / * is_blocking = * / true , <nl> + [ & result ] { result = 2 ; } ) ; <nl> + <nl> + const auto find_task_from_all_handler = [ & ] ( bool * task_from_blocking_queue , <nl> + internal : : Task * t , <nl> + bool is_blocking_thread ) { <nl> + internal : : ThreadWorkSource * tws ; <nl> + * t = run_handler_thread_pool . FindTask ( <nl> + / * searching_range_start = * / 0 , / * searching_range_end = * / 5 , <nl> + / * thread_id = * / 0 , <nl> + / * sub_thread_pool_id = * / 0 , / * max_blocking_inflight = * / 10 , <nl> + is_blocking_thread , thread_work_sources , task_from_blocking_queue , <nl> + & tws ) ; <nl> + } ; <nl> + bool task_from_blocking_queue ; <nl> + internal : : Task t ; <nl> + find_task_from_all_handler ( & task_from_blocking_queue , & t , <nl> + / * is_blocking_thread = * / false ) ; <nl> + EXPECT_EQ ( task_from_blocking_queue , false ) ; <nl> + t . f - > f ( ) ; <nl> + EXPECT_EQ ( result , 2 ) ; <nl> + <nl> + find_task_from_all_handler ( & task_from_blocking_queue , & t , <nl> + / * is_blocking_thread = * / false ) ; <nl> + EXPECT_EQ ( t . f , nullptr ) ; <nl> + <nl> + / / Clean up the queue . <nl> + find_task_from_all_handler ( & task_from_blocking_queue , & t , <nl> + / * is_blocking_thread = * / true ) ; <nl> + } <nl> + <nl> + { <nl> + / / There is a limit for max_blocking_inflight requests . <nl> + int result = - 1 ; <nl> + run_handler_thread_pool . AddWorkToQueue ( thread_work_sources [ 2 ] , <nl> + / * is_blocking = * / true , <nl> + [ & result ] { result = 2 ; } ) ; <nl> + <nl> + const auto find_task_from_all_handler = [ & ] ( bool * task_from_blocking_queue , <nl> + internal : : Task * t , <nl> + bool is_blocking_thread ) { <nl> + internal : : ThreadWorkSource * tws ; <nl> + * t = run_handler_thread_pool . FindTask ( <nl> + / * searching_range_start = * / 0 , / * searching_range_end = * / 5 , <nl> + / * thread_id = * / 0 , <nl> + / * sub_thread_pool_id = * / 0 , / * max_blocking_inflight = * / 10 , <nl> + is_blocking_thread , thread_work_sources , task_from_blocking_queue , <nl> + & tws ) ; <nl> + } ; <nl> + <nl> + bool task_from_blocking_queue ; <nl> + internal : : Task t ; <nl> + find_task_from_all_handler ( & task_from_blocking_queue , & t , <nl> + / * is_blocking_thread = * / false ) ; <nl> + EXPECT_EQ ( task_from_blocking_queue , false ) ; <nl> + EXPECT_EQ ( t . f , nullptr ) ; <nl> + <nl> + / / Clean up the queue . <nl> + find_task_from_all_handler ( & task_from_blocking_queue , & t , <nl> + / * is_blocking_thread = * / true ) ; <nl> + } <nl> + <nl> + for ( int i = 0 ; i < 5 ; + + i ) { <nl> + delete thread_work_sources [ i ] ; <nl> + } <nl> + } <nl> + <nl> + TEST ( RunHandlerThreadPool , RoundRobinExecution ) { <nl> + / / Set up environment for 1 sub thread pool . <nl> + setenv ( " TF_RUN_HANDLER_USE_SUB_THREAD_POOL " , " true " , true ) ; <nl> + setenv ( " TF_RUN_HANDLER_NUM_THREADS_IN_SUB_THREAD_POOL " , " 1 " , true ) ; <nl> + setenv ( " TF_RUN_HANDLER_SUB_THREAD_POOL_START_REQUEST_PERCENTAGE " , " 0 " , true ) ; <nl> + setenv ( " TF_RUN_HANDLER_SUB_THREAD_POOL_END_REQUEST_PERCENTAGE " , " 1 " , true ) ; <nl> + <nl> + Eigen : : MaxSizeVector < mutex > waiters_mu ( 1 ) ; <nl> + waiters_mu . resize ( 1 ) ; <nl> + Eigen : : MaxSizeVector < internal : : Waiter > waiters ( 1 ) ; <nl> + waiters . resize ( 1 ) ; <nl> + internal : : RunHandlerThreadPool * run_handler_thread_pool = <nl> + new internal : : RunHandlerThreadPool ( <nl> + / * num_blocking_threads = * / 1 , / * num_non_blocking_threads = * / 0 , <nl> + Env : : Default ( ) , ThreadOptions ( ) , " tf_run_handler_pool " , & waiters_mu , <nl> + & waiters ) ; <nl> + Eigen : : MaxSizeVector < internal : : ThreadWorkSource * > thread_work_sources ( 3 ) ; <nl> + thread_work_sources . resize ( 3 ) ; <nl> + internal : : ThreadWorkSource tws [ 3 ] ; <nl> + for ( int i = 0 ; i < 3 ; + + i ) { <nl> + tws [ i ] . SetWaiter ( 1 , & waiters [ 0 ] , & waiters_mu [ 0 ] ) ; <nl> + thread_work_sources [ i ] = & tws [ i ] ; <nl> + } <nl> + <nl> + int result = 0 ; <nl> + mutex mu ; <nl> + bool ok_to_execute = false ; <nl> + bool ok_to_validate = false ; <nl> + condition_variable function_start ; <nl> + condition_variable function_end ; <nl> + std : : vector < std : : function < void ( ) > > fns ; <nl> + for ( int i = 0 ; i < 3 ; + + i ) { <nl> + fns . push_back ( [ & result , & mu , & function_start , & function_end , & ok_to_execute , <nl> + & ok_to_validate , i ] { <nl> + mutex_lock l ( mu ) ; <nl> + while ( ! ok_to_execute ) { <nl> + function_start . wait ( l ) ; <nl> + } <nl> + result = i ; <nl> + ok_to_execute = false ; <nl> + ok_to_validate = true ; <nl> + function_end . notify_one ( ) ; <nl> + } ) ; <nl> + run_handler_thread_pool - > AddWorkToQueue ( & tws [ i ] , / * is_blocking = * / true , <nl> + fns [ i ] ) ; <nl> + run_handler_thread_pool - > AddWorkToQueue ( & tws [ i ] , / * is_blocking = * / true , <nl> + fns [ i ] ) ; <nl> + } <nl> + run_handler_thread_pool - > Start ( ) ; <nl> + run_handler_thread_pool - > SetThreadWorkSources ( <nl> + / * tid = * / 0 , / * start_request_idx = * / 0 , / * version = * / 1 , thread_work_sources ) ; <nl> + <nl> + / / Validate the execution should be roundrobin . <nl> + mutex_lock l ( mu ) ; <nl> + for ( int round = 0 ; round < 2 ; + + round ) { <nl> + for ( int i = 0 ; i < 3 ; + + i ) { <nl> + ok_to_execute = true ; <nl> + function_start . notify_one ( ) ; <nl> + while ( ! ok_to_validate ) { <nl> + function_end . wait ( l ) ; <nl> + } <nl> + ok_to_validate = false ; <nl> + EXPECT_EQ ( result , i ) ; <nl> + } <nl> + } <nl> + <nl> + delete run_handler_thread_pool ; <nl> + } <nl> + <nl> + TEST ( RunHandlerThreadPool , MultipleSubThreadPool ) { <nl> + / / Set up environment for 2 sub thread pools . <nl> + setenv ( " TF_RUN_HANDLER_USE_SUB_THREAD_POOL " , " true " , true ) ; <nl> + setenv ( " TF_RUN_HANDLER_NUM_THREADS_IN_SUB_THREAD_POOL " , " 2 " , true ) ; <nl> + setenv ( " TF_RUN_HANDLER_SUB_THREAD_POOL_START_REQUEST_PERCENTAGE " , " 0 , 0 . 5 " , <nl> + true ) ; <nl> + setenv ( " TF_RUN_HANDLER_SUB_THREAD_POOL_END_REQUEST_PERCENTAGE " , " 0 . 5 , 1 " , <nl> + true ) ; <nl> + <nl> + Eigen : : MaxSizeVector < mutex > waiters_mu ( 2 ) ; <nl> + waiters_mu . resize ( 2 ) ; <nl> + Eigen : : MaxSizeVector < internal : : Waiter > waiters ( 2 ) ; <nl> + waiters . resize ( 2 ) ; <nl> + internal : : RunHandlerThreadPool * run_handler_thread_pool = <nl> + new internal : : RunHandlerThreadPool ( <nl> + / * num_blocking_threads = * / 2 , / * num_non_blocking_threads = * / 0 , <nl> + Env : : Default ( ) , ThreadOptions ( ) , " tf_run_handler_pool " , & waiters_mu , <nl> + & waiters ) ; <nl> + Eigen : : MaxSizeVector < internal : : ThreadWorkSource * > thread_work_sources ( 4 ) ; <nl> + thread_work_sources . resize ( 4 ) ; <nl> + internal : : ThreadWorkSource tws [ 4 ] ; <nl> + for ( int i = 0 ; i < 4 ; + + i ) { <nl> + tws [ i ] . SetWaiter ( 1 , & waiters [ i / 2 ] , & waiters_mu [ i / 2 ] ) ; <nl> + thread_work_sources [ i ] = & tws [ i ] ; <nl> + } <nl> + <nl> + int result = 0 ; <nl> + mutex mu ; <nl> + bool ok_to_execute = false ; <nl> + bool ok_to_validate = false ; <nl> + condition_variable function_start ; <nl> + condition_variable function_end ; <nl> + <nl> + std : : vector < std : : function < void ( ) > > fns ; <nl> + for ( int i = 0 ; i < 4 ; + + i ) { <nl> + fns . push_back ( [ & result , & mu , & function_start , & function_end , & ok_to_execute , <nl> + & ok_to_validate , i ] { <nl> + mutex_lock l ( mu ) ; <nl> + while ( ! ok_to_execute ) { <nl> + function_start . wait ( l ) ; <nl> + } <nl> + result = i ; <nl> + ok_to_execute = false ; <nl> + ok_to_validate = true ; <nl> + function_end . notify_one ( ) ; <nl> + } ) ; <nl> + run_handler_thread_pool - > AddWorkToQueue ( & tws [ i ] , / * is_blocking = * / true , <nl> + fns [ i ] ) ; <nl> + run_handler_thread_pool - > AddWorkToQueue ( & tws [ i ] , / * is_blocking = * / true , <nl> + fns [ i ] ) ; <nl> + } <nl> + run_handler_thread_pool - > StartOneThreadForTesting ( ) ; <nl> + run_handler_thread_pool - > SetThreadWorkSources ( <nl> + / * tid = * / 0 , / * start_request_idx = * / 0 , / * version = * / 1 , thread_work_sources ) ; <nl> + run_handler_thread_pool - > SetThreadWorkSources ( <nl> + / * tid = * / 1 , / * start_request_idx = * / 0 , / * version = * / 1 , thread_work_sources ) ; <nl> + <nl> + / / Pick task from the given sub thread pool requests in a round robin fashion . <nl> + mutex_lock l ( mu ) ; <nl> + for ( int round = 0 ; round < 2 ; + + round ) { <nl> + for ( int i = 0 ; i < 2 ; + + i ) { <nl> + ok_to_execute = true ; <nl> + function_start . notify_one ( ) ; <nl> + while ( ! ok_to_validate ) { <nl> + function_end . wait ( l ) ; <nl> + } <nl> + ok_to_validate = false ; <nl> + EXPECT_EQ ( result , i ) ; <nl> + } <nl> + } <nl> + <nl> + / / Pick task from any task if there is no tasks from the requests in the sub <nl> + / / thread pool . <nl> + for ( int i = 0 ; i < 2 ; + + i ) { <nl> + for ( int round = 0 ; round < 2 ; + + round ) { <nl> + ok_to_execute = true ; <nl> + function_start . notify_one ( ) ; <nl> + while ( ! ok_to_validate ) { <nl> + function_end . wait ( l ) ; <nl> + } <nl> + ok_to_validate = false ; <nl> + EXPECT_EQ ( result , i + 2 ) ; <nl> + } <nl> + } <nl> + <nl> + delete run_handler_thread_pool ; <nl> + } <nl> + <nl> SessionOptions DefaultSessionOptions ( ) { <nl> SessionOptions options ; <nl> ( * options . config . mutable_device_count ( ) ) [ " CPU " ] = 2 ; <nl> | Refactor code for run handler thread pool , and add some unit tests . | tensorflow/tensorflow | f4cd9ee784ff10f1c8a494e1f6409fa72712dada | 2020-03-13T22:16:18Z |
mmm a / tensorflow / contrib / layers / python / layers / feature_column . py <nl> ppp b / tensorflow / contrib / layers / python / layers / feature_column . py <nl> def embedding_column ( sparse_id_column , <nl> <nl> Args : <nl> sparse_id_column : A _SparseColumn which is created by ` sparse_column_with_ * ` <nl> - functions . Note that ` combiner ` defined in ` sparse_id_column ` is ignored . <nl> + or crossed_column functions . Note that ` combiner ` defined in <nl> + ` sparse_id_column ` is ignored . <nl> dimension : An integer specifying dimension of the embedding . <nl> combiner : A string specifying how to reduce if there are multiple entries <nl> in a single row . Currently " mean " , " sqrtn " and " sum " are supported . Each <nl> def key ( self ) : <nl> " " " Returns a string which will be used as a key when we do sorting . " " " <nl> return " { } " . format ( self ) <nl> <nl> + def id_tensor ( self , input_tensor ) : <nl> + " " " Returns the id tensor from the given transformed input_tensor . " " " <nl> + return input_tensor <nl> + <nl> + # pylint : disable = unused - argument <nl> + def weight_tensor ( self , input_tensor ) : <nl> + " " " Returns the weight tensor from the given transformed input_tensor . " " " <nl> + return None <nl> + <nl> def insert_transformed_feature ( self , columns_to_tensors ) : <nl> " " " Handles cross transformation . " " " <nl> <nl> mmm a / tensorflow / contrib / layers / python / layers / feature_column_ops_test . py <nl> ppp b / tensorflow / contrib / layers / python / layers / feature_column_ops_test . py <nl> def testEmbeddingColumnWithWeightedSparseColumn ( self ) : <nl> tf . initialize_all_tables ( ) . run ( ) <nl> self . assertAllEqual ( output . eval ( ) . shape , [ 2 , 10 ] ) <nl> <nl> + def testEmbeddingColumnWitCrossedColumn ( self ) : <nl> + a = tf . contrib . layers . sparse_column_with_hash_bucket ( " aaa " , <nl> + hash_bucket_size = 100 ) <nl> + b = tf . contrib . layers . sparse_column_with_hash_bucket ( " bbb " , <nl> + hash_bucket_size = 100 ) <nl> + crossed = tf . contrib . layers . crossed_column ( <nl> + set ( [ a , b ] ) , hash_bucket_size = 10000 ) <nl> + wire_tensor = tf . SparseTensor ( values = [ " omar " , " stringer " , " marlo " ] , <nl> + indices = [ [ 0 , 0 ] , [ 1 , 0 ] , [ 1 , 1 ] ] , <nl> + shape = [ 2 , 2 ] ) <nl> + features = { " aaa " : wire_tensor , " bbb " : wire_tensor } <nl> + embeded_sparse = tf . contrib . layers . embedding_column ( crossed , 10 ) <nl> + output = tf . contrib . layers . input_from_feature_columns ( features , <nl> + [ embeded_sparse ] ) <nl> + with self . test_session ( ) : <nl> + tf . initialize_all_variables ( ) . run ( ) <nl> + self . assertAllEqual ( output . eval ( ) . shape , [ 2 , 10 ] ) <nl> + <nl> def testSparseColumn ( self ) : <nl> hashed_sparse = tf . contrib . layers . sparse_column_with_hash_bucket ( " wire " , 10 ) <nl> wire_tensor = tf . SparseTensor ( values = [ " omar " , " stringer " , " marlo " ] , <nl> | Support embedding of a crossed column . | tensorflow/tensorflow | f0b12832ea1e4cefb253a2cdcfa2d151d16f3641 | 2016-07-27T23:32:36Z |
mmm a / root . c <nl> ppp b / root . c <nl> <nl> # define ENOFOLLOWSYMLINK ELOOP <nl> # endif <nl> <nl> - void w_root_process_path ( struct write_locked_watchman_root * lock , <nl> - struct watchman_pending_collection * coll , w_string_t * full_path , <nl> - struct timeval now , int flags , <nl> - struct watchman_dir_ent * pre_stat ) <nl> - { <nl> - / * From a particular query ' s point of view , there are four sorts of cookies we <nl> - * can observe : <nl> - * 1 . Cookies that this query has created . This marks the end of this query ' s <nl> - * sync_to_now , so we hide it from the results . <nl> - * 2 . Cookies that another query on the same watch by the same process has <nl> - * created . This marks the end of that other query ' s sync_to_now , so from <nl> - * the point of view of this query we turn a blind eye to it . <nl> - * 3 . Cookies created by another process on the same watch . We ' re independent <nl> - * of other processes , so we report these . <nl> - * 4 . Cookies created by a nested watch by the same or a different process . <nl> - * We ' re independent of other watches , so we report these . <nl> - * <nl> - * The below condition is true for cases 1 and 2 and false for 3 and 4 . <nl> - * / <nl> - if ( w_string_startswith ( full_path , lock - > root - > query_cookie_prefix ) ) { <nl> - struct watchman_query_cookie * cookie ; <nl> - bool consider_cookie = <nl> - ( lock - > root - > watcher_ops - > flags & WATCHER_HAS_PER_FILE_NOTIFICATIONS ) <nl> - ? ( ( flags & W_PENDING_VIA_NOTIFY ) | | ! lock - > root - > done_initial ) <nl> - : true ; <nl> - <nl> - if ( ! consider_cookie ) { <nl> - / / Never allow cookie files to show up in the tree <nl> - return ; <nl> - } <nl> - <nl> - cookie = w_ht_val_ptr ( <nl> - w_ht_get ( lock - > root - > query_cookies , w_ht_ptr_val ( full_path ) ) ) ; <nl> - w_log ( W_LOG_DBG , " cookie ! % . * s cookie = % p \ n " , <nl> - full_path - > len , full_path - > buf , cookie ) ; <nl> - <nl> - if ( cookie ) { <nl> - cookie - > seen = true ; <nl> - pthread_cond_signal ( & cookie - > cond ) ; <nl> - } <nl> - <nl> - / / Never allow cookie files to show up in the tree <nl> - return ; <nl> - } <nl> - <nl> - if ( w_string_equal ( full_path , lock - > root - > root_path ) <nl> - | | ( flags & W_PENDING_CRAWL_ONLY ) = = W_PENDING_CRAWL_ONLY ) { <nl> - crawler ( lock , coll , full_path , now , <nl> - ( flags & W_PENDING_RECURSIVE ) = = W_PENDING_RECURSIVE ) ; <nl> - } else { <nl> - stat_path ( lock , coll , full_path , now , flags , pre_stat ) ; <nl> - } <nl> - } <nl> - <nl> void handle_open_errno ( struct write_locked_watchman_root * lock , <nl> struct watchman_dir * dir , struct timeval now , <nl> const char * syscall , int err , const char * reason ) { <nl> mmm a / root / iothread . c <nl> ppp b / root / iothread . c <nl> static void io_thread ( struct unlocked_watchman_root * unlocked ) <nl> w_pending_coll_destroy ( & pending ) ; <nl> } <nl> <nl> + void w_root_process_path ( struct write_locked_watchman_root * lock , <nl> + struct watchman_pending_collection * coll , <nl> + w_string_t * full_path , struct timeval now , int flags , <nl> + struct watchman_dir_ent * pre_stat ) { <nl> + / * From a particular query ' s point of view , there are four sorts of cookies we <nl> + * can observe : <nl> + * 1 . Cookies that this query has created . This marks the end of this query ' s <nl> + * sync_to_now , so we hide it from the results . <nl> + * 2 . Cookies that another query on the same watch by the same process has <nl> + * created . This marks the end of that other query ' s sync_to_now , so from <nl> + * the point of view of this query we turn a blind eye to it . <nl> + * 3 . Cookies created by another process on the same watch . We ' re independent <nl> + * of other processes , so we report these . <nl> + * 4 . Cookies created by a nested watch by the same or a different process . <nl> + * We ' re independent of other watches , so we report these . <nl> + * <nl> + * The below condition is true for cases 1 and 2 and false for 3 and 4 . <nl> + * / <nl> + if ( w_string_startswith ( full_path , lock - > root - > query_cookie_prefix ) ) { <nl> + struct watchman_query_cookie * cookie ; <nl> + bool consider_cookie = <nl> + ( lock - > root - > watcher_ops - > flags & WATCHER_HAS_PER_FILE_NOTIFICATIONS ) <nl> + ? ( ( flags & W_PENDING_VIA_NOTIFY ) | | ! lock - > root - > done_initial ) <nl> + : true ; <nl> + <nl> + if ( ! consider_cookie ) { <nl> + / / Never allow cookie files to show up in the tree <nl> + return ; <nl> + } <nl> + <nl> + cookie = w_ht_val_ptr ( <nl> + w_ht_get ( lock - > root - > query_cookies , w_ht_ptr_val ( full_path ) ) ) ; <nl> + w_log ( W_LOG_DBG , " cookie ! % . * s cookie = % p \ n " , <nl> + full_path - > len , full_path - > buf , cookie ) ; <nl> + <nl> + if ( cookie ) { <nl> + cookie - > seen = true ; <nl> + pthread_cond_signal ( & cookie - > cond ) ; <nl> + } <nl> + <nl> + / / Never allow cookie files to show up in the tree <nl> + return ; <nl> + } <nl> + <nl> + if ( w_string_equal ( full_path , lock - > root - > root_path ) <nl> + | | ( flags & W_PENDING_CRAWL_ONLY ) = = W_PENDING_CRAWL_ONLY ) { <nl> + crawler ( lock , coll , full_path , now , <nl> + ( flags & W_PENDING_RECURSIVE ) = = W_PENDING_RECURSIVE ) ; <nl> + } else { <nl> + stat_path ( lock , coll , full_path , now , flags , pre_stat ) ; <nl> + } <nl> + } <nl> + <nl> bool w_root_process_pending ( struct write_locked_watchman_root * lock , <nl> struct watchman_pending_collection * coll , <nl> bool pull_from_root ) <nl> | refactor : move more to iothread . c | facebook/watchman | a92081532ad8d5af2938facdf0b312dd5763b0dd | 2016-08-27T17:52:37Z |
mmm a / src / proto / grpc / testing / BUILD <nl> ppp b / src / proto / grpc / testing / BUILD <nl> grpc_proto_library ( <nl> ] , <nl> ) <nl> <nl> + proto_library ( <nl> + name = " benchmark_service_descriptor " , <nl> + srcs = [ " benchmark_service . proto " ] , <nl> + deps = [ " : messages_proto_descriptor " ] , <nl> + ) <nl> + <nl> + py_proto_library ( <nl> + name = " benchmark_service_py_pb2 " , <nl> + deps = [ " : benchmark_service_descriptor " ] , <nl> + ) <nl> + <nl> + py_grpc_library ( <nl> + name = " benchmark_service_py_pb2_grpc " , <nl> + srcs = [ " : benchmark_service_descriptor " ] , <nl> + deps = [ " : benchmark_service_py_pb2 " ] , <nl> + ) <nl> + <nl> grpc_proto_library ( <nl> name = " report_qps_scenario_service_proto " , <nl> srcs = [ " report_qps_scenario_service . proto " ] , <nl> mmm a / src / python / grpcio / grpc / _cython / BUILD . bazel <nl> ppp b / src / python / grpcio / grpc / _cython / BUILD . bazel <nl> pyx_library ( <nl> " _cygrpc / aio / iomgr / socket . pyx . pxi " , <nl> " _cygrpc / aio / iomgr / timer . pxd . pxi " , <nl> " _cygrpc / aio / iomgr / timer . pyx . pxi " , <nl> + " _cygrpc / aio / server . pxd . pxi " , <nl> + " _cygrpc / aio / server . pyx . pxi " , <nl> " _cygrpc / arguments . pxd . pxi " , <nl> " _cygrpc / arguments . pyx . pxi " , <nl> " _cygrpc / call . pxd . pxi " , <nl> mmm a / src / python / grpcio / grpc / _cython / _cygrpc / aio / iomgr / iomgr . pyx . pxi <nl> ppp b / src / python / grpcio / grpc / _cython / _cygrpc / aio / iomgr / iomgr . pyx . pxi <nl> <nl> <nl> <nl> from cpython cimport Py_INCREF , Py_DECREF <nl> - <nl> from libc cimport string <nl> <nl> + import socket as native_socket <nl> + <nl> cdef grpc_socket_vtable asyncio_socket_vtable <nl> cdef grpc_custom_resolver_vtable asyncio_resolver_vtable <nl> cdef grpc_custom_timer_vtable asyncio_timer_vtable <nl> cdef grpc_error * asyncio_socket_getpeername ( <nl> grpc_custom_socket * grpc_socket , <nl> const grpc_sockaddr * addr , <nl> int * length ) with gil : <nl> - raise NotImplemented ( ) <nl> + peer = ( < _AsyncioSocket > grpc_socket . impl ) . peername ( ) <nl> + <nl> + cdef grpc_resolved_address c_addr <nl> + hostname = str_to_bytes ( peer [ 0 ] ) <nl> + grpc_string_to_sockaddr ( & c_addr , hostname , peer [ 1 ] ) <nl> + string . memcpy ( < void * > addr , < void * > c_addr . addr , c_addr . len ) <nl> + length [ 0 ] = c_addr . len <nl> + return grpc_error_none ( ) <nl> <nl> <nl> cdef grpc_error * asyncio_socket_getsockname ( <nl> grpc_custom_socket * grpc_socket , <nl> const grpc_sockaddr * addr , <nl> int * length ) with gil : <nl> - raise NotImplemented ( ) <nl> + " " " Supplies sock_addr in add_socket_to_server . " " " <nl> + cdef grpc_resolved_address c_addr <nl> + socket = ( < _AsyncioSocket > grpc_socket . impl ) <nl> + if socket is None : <nl> + peer = ( ' 0 . 0 . 0 . 0 ' , 0 ) <nl> + else : <nl> + peer = socket . sockname ( ) <nl> + hostname = str_to_bytes ( peer [ 0 ] ) <nl> + grpc_string_to_sockaddr ( & c_addr , hostname , peer [ 1 ] ) <nl> + string . memcpy ( < void * > addr , < void * > c_addr . addr , c_addr . len ) <nl> + length [ 0 ] = c_addr . len <nl> + return grpc_error_none ( ) <nl> <nl> <nl> cdef grpc_error * asyncio_socket_listen ( grpc_custom_socket * grpc_socket ) with gil : <nl> - raise NotImplemented ( ) <nl> + ( < _AsyncioSocket > grpc_socket . impl ) . listen ( ) <nl> + return grpc_error_none ( ) <nl> + <nl> + <nl> + # TODO ( lidiz ) connects the so_reuse_port option to channel arguments <nl> + def _asyncio_apply_socket_options ( object s , so_reuse_port = False ) : <nl> + s . setsockopt ( native_socket . SOL_SOCKET , native_socket . SO_REUSEADDR , 1 ) <nl> + if so_reuse_port : <nl> + s . setsockopt ( native_socket . SOL_SOCKET , native_socket . SO_REUSEPORT , 1 ) <nl> + s . setsockopt ( native_socket . IPPROTO_TCP , native_socket . TCP_NODELAY , True ) <nl> <nl> <nl> cdef grpc_error * asyncio_socket_bind ( <nl> grpc_custom_socket * grpc_socket , <nl> const grpc_sockaddr * addr , <nl> size_t len , int flags ) with gil : <nl> - raise NotImplemented ( ) <nl> + host , port = sockaddr_to_tuple ( addr , len ) <nl> + try : <nl> + try : <nl> + socket = native_socket . socket ( family = native_socket . AF_INET6 ) <nl> + _asyncio_apply_socket_options ( socket ) <nl> + socket . bind ( ( host , port ) ) <nl> + except native_socket . gaierror : <nl> + socket = native_socket . socket ( family = native_socket . AF_INET ) <nl> + _asyncio_apply_socket_options ( socket ) <nl> + socket . bind ( ( host , port ) ) <nl> + except IOError as io_error : <nl> + return socket_error ( " bind " , str ( io_error ) ) <nl> + else : <nl> + aio_socket = _AsyncioSocket . create_with_py_socket ( grpc_socket , socket ) <nl> + cpython . Py_INCREF ( aio_socket ) <nl> + grpc_socket . impl = < void * > aio_socket <nl> + return grpc_error_none ( ) <nl> <nl> <nl> cdef void asyncio_socket_accept ( <nl> grpc_custom_socket * grpc_socket , <nl> grpc_custom_socket * grpc_socket_client , <nl> grpc_custom_accept_callback accept_cb ) with gil : <nl> - raise NotImplemented ( ) <nl> + ( < _AsyncioSocket > grpc_socket . impl ) . accept ( grpc_socket_client , accept_cb ) <nl> <nl> <nl> cdef grpc_error * asyncio_resolve ( <nl> char * host , <nl> char * port , <nl> grpc_resolved_addresses * * res ) with gil : <nl> - raise NotImplemented ( ) <nl> + result = native_socket . getaddrinfo ( host , port ) <nl> + res [ 0 ] = tuples_to_resolvaddr ( result ) <nl> <nl> <nl> cdef void asyncio_resolve_async ( <nl> mmm a / src / python / grpcio / grpc / _cython / _cygrpc / aio / iomgr / socket . pxd . pxi <nl> ppp b / src / python / grpcio / grpc / _cython / _cygrpc / aio / iomgr / socket . pxd . pxi <nl> <nl> <nl> cdef class _AsyncioSocket : <nl> cdef : <nl> + # Common attributes <nl> grpc_custom_socket * _grpc_socket <nl> - grpc_custom_connect_callback _grpc_connect_cb <nl> grpc_custom_read_callback _grpc_read_cb <nl> object _reader <nl> object _writer <nl> cdef class _AsyncioSocket : <nl> object _task_connect <nl> char * _read_buffer <nl> <nl> + # Client - side attributes <nl> + grpc_custom_connect_callback _grpc_connect_cb <nl> + <nl> + # Server - side attributes <nl> + grpc_custom_accept_callback _grpc_accept_cb <nl> + grpc_custom_socket * _grpc_client_socket <nl> + object _server <nl> + object _py_socket <nl> + object _peername <nl> + <nl> @ staticmethod <nl> cdef _AsyncioSocket create ( grpc_custom_socket * grpc_socket ) <nl> + @ staticmethod <nl> + cdef _AsyncioSocket create_with_py_socket ( grpc_custom_socket * grpc_socket , object py_socket ) <nl> <nl> cdef void connect ( self , object host , object port , grpc_custom_connect_callback grpc_connect_cb ) <nl> cdef void write ( self , grpc_slice_buffer * g_slice_buffer , grpc_custom_write_callback grpc_write_cb ) <nl> cdef void read ( self , char * buffer_ , size_t length , grpc_custom_read_callback grpc_read_cb ) <nl> cdef bint is_connected ( self ) <nl> cdef void close ( self ) <nl> + <nl> + cdef accept ( self , grpc_custom_socket * grpc_socket_client , grpc_custom_accept_callback grpc_accept_cb ) <nl> + cdef listen ( self ) <nl> + cdef tuple peername ( self ) <nl> + cdef tuple sockname ( self ) <nl> mmm a / src / python / grpcio / grpc / _cython / _cygrpc / aio / iomgr / socket . pyx . pxi <nl> ppp b / src / python / grpcio / grpc / _cython / _cygrpc / aio / iomgr / socket . pyx . pxi <nl> <nl> # See the License for the specific language governing permissions and <nl> # limitations under the License . <nl> <nl> - import socket <nl> + import socket as native_socket <nl> <nl> from libc cimport string <nl> <nl> cdef class _AsyncioSocket : <nl> self . _task_connect = None <nl> self . _task_read = None <nl> self . _read_buffer = NULL <nl> + self . _server = None <nl> + self . _py_socket = None <nl> <nl> @ staticmethod <nl> cdef _AsyncioSocket create ( grpc_custom_socket * grpc_socket ) : <nl> cdef class _AsyncioSocket : <nl> socket . _grpc_socket = grpc_socket <nl> return socket <nl> <nl> + @ staticmethod <nl> + cdef _AsyncioSocket create_with_py_socket ( grpc_custom_socket * grpc_socket , object py_socket ) : <nl> + socket = _AsyncioSocket ( ) <nl> + socket . _grpc_socket = grpc_socket <nl> + socket . _py_socket = py_socket <nl> + return socket <nl> + <nl> def __repr__ ( self ) : <nl> class_name = self . __class__ . __name__ <nl> id_ = id ( self ) <nl> cdef class _AsyncioSocket : <nl> # gRPC default posix implementation disables nagle <nl> # algorithm . <nl> sock = self . _writer . transport . get_extra_info ( ' socket ' ) <nl> - sock . setsockopt ( socket . IPPROTO_TCP , socket . TCP_NODELAY , True ) <nl> + sock . setsockopt ( native_socket . IPPROTO_TCP , native_socket . TCP_NODELAY , True ) <nl> <nl> self . _grpc_connect_cb ( <nl> < grpc_custom_socket * > self . _grpc_socket , <nl> cdef class _AsyncioSocket : <nl> cdef void close ( self ) : <nl> if self . is_connected ( ) : <nl> self . _writer . close ( ) <nl> + <nl> + def _new_connection_callback ( self , object reader , object writer ) : <nl> + client_socket = _AsyncioSocket . create ( self . _grpc_client_socket ) <nl> + client_socket . _reader = reader <nl> + client_socket . _writer = writer <nl> + client_socket . _peername = addr = writer . get_extra_info ( ' peername ' ) <nl> + <nl> + self . _grpc_client_socket . impl = < void * > client_socket <nl> + cpython . Py_INCREF ( client_socket ) <nl> + # Accept callback expects to be called with : <nl> + # * An grpc custom socket for server <nl> + # * An grpc custom socket for client ( with new Socket instance ) <nl> + # * An error object <nl> + self . _grpc_accept_cb ( self . _grpc_socket , self . _grpc_client_socket , grpc_error_none ( ) ) <nl> + <nl> + cdef listen ( self ) : <nl> + async def create_asyncio_server ( ) : <nl> + self . _server = await asyncio . start_server ( <nl> + self . _new_connection_callback , <nl> + sock = self . _py_socket , <nl> + ) <nl> + <nl> + asyncio . get_event_loop ( ) . create_task ( create_asyncio_server ( ) ) <nl> + <nl> + cdef accept ( self , <nl> + grpc_custom_socket * grpc_socket_client , <nl> + grpc_custom_accept_callback grpc_accept_cb ) : <nl> + self . _grpc_client_socket = grpc_socket_client <nl> + self . _grpc_accept_cb = grpc_accept_cb <nl> + <nl> + cdef tuple peername ( self ) : <nl> + return self . _peername <nl> + <nl> + cdef tuple sockname ( self ) : <nl> + return self . _py_socket . getsockname ( ) <nl> new file mode 100644 <nl> index 00000000000 . . ee5255213c8 <nl> mmm / dev / null <nl> ppp b / src / python / grpcio / grpc / _cython / _cygrpc / aio / server . pxd . pxi <nl> <nl> + # Copyright 2019 The gRPC Authors <nl> + # <nl> + # Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + # you may not use this file except in compliance with the License . <nl> + # You may obtain a copy of the License at <nl> + # <nl> + # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + # <nl> + # Unless required by applicable law or agreed to in writing , software <nl> + # distributed under the License is distributed on an " AS IS " BASIS , <nl> + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + # See the License for the specific language governing permissions and <nl> + # limitations under the License . <nl> + <nl> + cdef class _HandlerCallDetails : <nl> + cdef readonly str method <nl> + cdef readonly tuple invocation_metadata <nl> + <nl> + <nl> + cdef class RPCState : <nl> + cdef grpc_call * call , <nl> + cdef grpc_call_details details <nl> + cdef grpc_metadata_array request_metadata <nl> + <nl> + cdef bytes method ( self ) <nl> + <nl> + <nl> + cdef class _AioServerState : <nl> + cdef Server server <nl> + cdef grpc_completion_queue * cq <nl> + cdef list generic_handlers <nl> + <nl> + <nl> + cdef class AioServer : <nl> + cdef _AioServerState _state <nl> new file mode 100644 <nl> index 00000000000 . . e64f746118a <nl> mmm / dev / null <nl> ppp b / src / python / grpcio / grpc / _cython / _cygrpc / aio / server . pyx . pxi <nl> <nl> + # Copyright 2019 The gRPC Authors <nl> + # <nl> + # Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + # you may not use this file except in compliance with the License . <nl> + # You may obtain a copy of the License at <nl> + # <nl> + # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + # <nl> + # Unless required by applicable law or agreed to in writing , software <nl> + # distributed under the License is distributed on an " AS IS " BASIS , <nl> + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + # See the License for the specific language governing permissions and <nl> + # limitations under the License . <nl> + <nl> + cdef class _HandlerCallDetails : <nl> + def __cinit__ ( self , str method , tuple invocation_metadata ) : <nl> + self . method = method <nl> + self . invocation_metadata = invocation_metadata <nl> + <nl> + <nl> + class _ServicerContextPlaceHolder ( object ) : pass <nl> + <nl> + <nl> + cdef class CallbackWrapper : <nl> + cdef CallbackContext context <nl> + cdef object future <nl> + <nl> + def __cinit__ ( self , object future ) : <nl> + self . context . functor . functor_run = self . functor_run <nl> + self . context . waiter = < cpython . PyObject * > ( future ) <nl> + self . future = future <nl> + <nl> + @ staticmethod <nl> + cdef void functor_run ( <nl> + grpc_experimental_completion_queue_functor * functor , <nl> + int succeed ) : <nl> + cdef CallbackContext * context = < CallbackContext * > functor <nl> + ( < object > context . waiter ) . set_result ( None ) <nl> + <nl> + cdef grpc_experimental_completion_queue_functor * c_functor ( self ) : <nl> + return & self . context . functor <nl> + <nl> + <nl> + cdef class RPCState : <nl> + <nl> + def __cinit__ ( self ) : <nl> + grpc_metadata_array_init ( & self . request_metadata ) <nl> + grpc_call_details_init ( & self . details ) <nl> + <nl> + cdef bytes method ( self ) : <nl> + return _slice_bytes ( self . details . method ) <nl> + <nl> + def __dealloc__ ( self ) : <nl> + " " " Cleans the Core objects . " " " <nl> + grpc_call_details_destroy ( & self . details ) <nl> + grpc_metadata_array_destroy ( & self . request_metadata ) <nl> + if self . call : <nl> + grpc_call_unref ( self . call ) <nl> + <nl> + <nl> + cdef _find_method_handler ( RPCState rpc_state , list generic_handlers ) : <nl> + # TODO ( lidiz ) connects Metadata to call details <nl> + cdef _HandlerCallDetails handler_call_details = _HandlerCallDetails ( <nl> + rpc_state . method ( ) . decode ( ) , <nl> + tuple ( ) <nl> + ) <nl> + <nl> + for generic_handler in generic_handlers : <nl> + method_handler = generic_handler . service ( handler_call_details ) <nl> + if method_handler is not None : <nl> + return method_handler <nl> + return None <nl> + <nl> + <nl> + async def callback_start_batch ( RPCState rpc_state , tuple operations , object <nl> + loop ) : <nl> + " " " The callback version of start batch operations . " " " <nl> + cdef _BatchOperationTag batch_operation_tag = _BatchOperationTag ( None , operations , None ) <nl> + batch_operation_tag . prepare ( ) <nl> + <nl> + cdef object future = loop . create_future ( ) <nl> + cdef CallbackWrapper wrapper = CallbackWrapper ( future ) <nl> + # NOTE ( lidiz ) Without Py_INCREF , the wrapper object will be destructed <nl> + # when calling " await " . This is an over - optimization by Cython . <nl> + cpython . Py_INCREF ( wrapper ) <nl> + cdef grpc_call_error error = grpc_call_start_batch ( <nl> + rpc_state . call , <nl> + batch_operation_tag . c_ops , <nl> + batch_operation_tag . c_nops , <nl> + wrapper . c_functor ( ) , NULL ) <nl> + <nl> + if error ! = GRPC_CALL_OK : <nl> + raise RuntimeError ( " Error with callback_start_batch { } " . format ( error ) ) <nl> + <nl> + await future <nl> + cpython . Py_DECREF ( wrapper ) <nl> + cdef grpc_event c_event <nl> + batch_operation_tag . event ( c_event ) <nl> + <nl> + <nl> + async def _handle_rpc ( _AioServerState server_state , RPCState rpc_state , object loop ) : <nl> + # Finds the method handler ( application logic ) <nl> + cdef object method_handler = _find_method_handler ( <nl> + rpc_state , <nl> + server_state . generic_handlers <nl> + ) <nl> + if method_handler . request_streaming or method_handler . response_streaming : <nl> + raise NotImplementedError ( ) <nl> + <nl> + # Receives request message <nl> + cdef tuple receive_ops = ( <nl> + ReceiveMessageOperation ( _EMPTY_FLAGS ) , <nl> + ) <nl> + await callback_start_batch ( rpc_state , receive_ops , loop ) <nl> + <nl> + # Parses the request <nl> + cdef bytes request_raw = receive_ops [ 0 ] . message ( ) <nl> + cdef object request_message <nl> + if method_handler . request_deserializer : <nl> + request_message = method_handler . request_deserializer ( request_raw ) <nl> + else : <nl> + request_message = request_raw <nl> + <nl> + # Executes application logic & encodes response message <nl> + cdef object response_message = await method_handler . unary_unary ( request_message , _ServicerContextPlaceHolder ( ) ) <nl> + cdef bytes response_raw <nl> + if method_handler . response_serializer : <nl> + response_raw = method_handler . response_serializer ( response_message ) <nl> + else : <nl> + response_raw = response_message <nl> + <nl> + # Sends response message <nl> + cdef tuple send_ops = ( <nl> + SendStatusFromServerOperation ( <nl> + tuple ( ) , StatusCode . ok , b ' ' , _EMPTY_FLAGS ) , <nl> + SendInitialMetadataOperation ( tuple ( ) , _EMPTY_FLAGS ) , <nl> + SendMessageOperation ( response_raw , _EMPTY_FLAGS ) , <nl> + ) <nl> + await callback_start_batch ( rpc_state , send_ops , loop ) <nl> + <nl> + <nl> + async def _server_call_request_call ( _AioServerState server_state , object loop ) : <nl> + cdef grpc_call_error error <nl> + cdef RPCState rpc_state = RPCState ( ) <nl> + cdef object future = loop . create_future ( ) <nl> + cdef CallbackWrapper wrapper = CallbackWrapper ( future ) <nl> + # NOTE ( lidiz ) Without Py_INCREF , the wrapper object will be destructed <nl> + # when calling " await " . This is an over - optimization by Cython . <nl> + cpython . Py_INCREF ( wrapper ) <nl> + error = grpc_server_request_call ( <nl> + server_state . server . c_server , & rpc_state . call , & rpc_state . details , <nl> + & rpc_state . request_metadata , <nl> + server_state . cq , server_state . cq , <nl> + wrapper . c_functor ( ) <nl> + ) <nl> + if error ! = GRPC_CALL_OK : <nl> + raise RuntimeError ( " Error in _server_call_request_call : % s " % error ) <nl> + <nl> + await future <nl> + cpython . Py_DECREF ( wrapper ) <nl> + return rpc_state <nl> + <nl> + <nl> + async def _server_main_loop ( _AioServerState server_state ) : <nl> + cdef object loop = asyncio . get_event_loop ( ) <nl> + cdef RPCState rpc_state <nl> + cdef object waiter <nl> + <nl> + while True : <nl> + rpc_state = await _server_call_request_call ( <nl> + server_state , <nl> + loop ) <nl> + # await waiter <nl> + <nl> + loop . create_task ( _handle_rpc ( server_state , rpc_state , loop ) ) <nl> + await asyncio . sleep ( 0 ) <nl> + <nl> + <nl> + async def _server_start ( _AioServerState server_state ) : <nl> + server_state . server . start ( ) <nl> + await _server_main_loop ( server_state ) <nl> + <nl> + <nl> + cdef class _AioServerState : <nl> + def __cinit__ ( self ) : <nl> + self . server = None <nl> + self . cq = NULL <nl> + self . generic_handlers = [ ] <nl> + <nl> + <nl> + cdef class AioServer : <nl> + <nl> + def __init__ ( self , thread_pool , generic_handlers , interceptors , options , <nl> + maximum_concurrent_rpcs , compression ) : <nl> + self . _state = _AioServerState ( ) <nl> + self . _state . server = Server ( options ) <nl> + self . _state . cq = grpc_completion_queue_create_for_callback ( <nl> + NULL , <nl> + NULL <nl> + ) <nl> + grpc_server_register_completion_queue ( <nl> + self . _state . server . c_server , <nl> + self . _state . cq , <nl> + NULL <nl> + ) <nl> + self . add_generic_rpc_handlers ( generic_handlers ) <nl> + <nl> + if interceptors : <nl> + raise NotImplementedError ( ) <nl> + if maximum_concurrent_rpcs : <nl> + raise NotImplementedError ( ) <nl> + if compression : <nl> + raise NotImplementedError ( ) <nl> + if thread_pool : <nl> + raise NotImplementedError ( ) <nl> + <nl> + def add_generic_rpc_handlers ( self , generic_rpc_handlers ) : <nl> + for h in generic_rpc_handlers : <nl> + self . _state . generic_handlers . append ( h ) <nl> + <nl> + def add_insecure_port ( self , address ) : <nl> + return self . _state . server . add_http2_port ( address ) <nl> + <nl> + def add_secure_port ( self , address , server_credentials ) : <nl> + return self . _state . server . add_http2_port ( address , <nl> + server_credentials . _credentials ) <nl> + <nl> + async def start ( self ) : <nl> + loop = asyncio . get_event_loop ( ) <nl> + loop . create_task ( _server_start ( self . _state ) ) <nl> + await asyncio . sleep ( 0 ) <nl> + <nl> + def stop ( self , unused_grace ) : <nl> + pass <nl> mmm a / src / python / grpcio / grpc / _cython / cygrpc . pxd <nl> ppp b / src / python / grpcio / grpc / _cython / cygrpc . pxd <nl> include " _cygrpc / aio / grpc_aio . pxd . pxi " <nl> include " _cygrpc / aio / callbackcontext . pxd . pxi " <nl> include " _cygrpc / aio / call . pxd . pxi " <nl> include " _cygrpc / aio / channel . pxd . pxi " <nl> + include " _cygrpc / aio / server . pxd . pxi " <nl> mmm a / src / python / grpcio / grpc / _cython / cygrpc . pyx <nl> ppp b / src / python / grpcio / grpc / _cython / cygrpc . pyx <nl> include " _cygrpc / aio / grpc_aio . pyx . pxi " <nl> include " _cygrpc / aio / call . pyx . pxi " <nl> include " _cygrpc / aio / channel . pyx . pxi " <nl> include " _cygrpc / aio / rpc_error . pyx . pxi " <nl> + include " _cygrpc / aio / server . pyx . pxi " <nl> <nl> <nl> # <nl> mmm a / src / python / grpcio / grpc / experimental / BUILD . bazel <nl> ppp b / src / python / grpcio / grpc / experimental / BUILD . bazel <nl> py_library ( <nl> srcs = [ <nl> " aio / __init__ . py " , <nl> " aio / _channel . py " , <nl> + " aio / _server . py " , <nl> ] , <nl> deps = [ <nl> " / / src / python / grpcio / grpc / _cython : cygrpc " , <nl> mmm a / src / python / grpcio / grpc / experimental / aio / __init__ . py <nl> ppp b / src / python / grpcio / grpc / experimental / aio / __init__ . py <nl> <nl> import grpc <nl> from grpc . _cython import cygrpc <nl> from grpc . _cython . cygrpc import init_grpc_aio <nl> + from . _server import server <nl> <nl> <nl> class Channel ( six . with_metaclass ( abc . ABCMeta ) ) : <nl> new file mode 100644 <nl> index 00000000000 . . ae5bc900423 <nl> mmm / dev / null <nl> ppp b / src / python / grpcio / grpc / experimental / aio / _server . py <nl> <nl> + # Copyright 2019 The gRPC Authors <nl> + # <nl> + # Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + # you may not use this file except in compliance with the License . <nl> + # You may obtain a copy of the License at <nl> + # <nl> + # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + # <nl> + # Unless required by applicable law or agreed to in writing , software <nl> + # distributed under the License is distributed on an " AS IS " BASIS , <nl> + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + # See the License for the specific language governing permissions and <nl> + # limitations under the License . <nl> + " " " Server - side implementation of gRPC Asyncio Python . " " " <nl> + <nl> + from typing import Text , Optional <nl> + import asyncio <nl> + import grpc <nl> + from grpc . _cython import cygrpc <nl> + <nl> + class Server : <nl> + " " " Serves RPCs . " " " <nl> + <nl> + def __init__ ( self , thread_pool , generic_handlers , interceptors , options , <nl> + maximum_concurrent_rpcs , compression ) : <nl> + self . _server = cygrpc . AioServer ( thread_pool , generic_handlers , <nl> + interceptors , options , <nl> + maximum_concurrent_rpcs , compression ) <nl> + <nl> + def add_generic_rpc_handlers ( <nl> + self , <nl> + generic_rpc_handlers , <nl> + # generic_rpc_handlers : Iterable [ grpc . GenericRpcHandlers ] <nl> + ) - > None : <nl> + " " " Registers GenericRpcHandlers with this Server . <nl> + <nl> + This method is only safe to call before the server is started . <nl> + <nl> + Args : <nl> + generic_rpc_handlers : An iterable of GenericRpcHandlers that will be <nl> + used to service RPCs . <nl> + " " " <nl> + self . _server . add_generic_rpc_handlers ( generic_rpc_handlers ) <nl> + <nl> + def add_insecure_port ( self , address : Text ) - > int : <nl> + " " " Opens an insecure port for accepting RPCs . <nl> + <nl> + This method may only be called before starting the server . <nl> + <nl> + Args : <nl> + address : The address for which to open a port . If the port is 0 , <nl> + or not specified in the address , then gRPC runtime will choose a port . <nl> + <nl> + Returns : <nl> + An integer port on which server will accept RPC requests . <nl> + " " " <nl> + return self . _server . add_insecure_port ( address ) <nl> + <nl> + def add_secure_port ( self , address : Text , <nl> + server_credentials : grpc . ServerCredentials ) - > int : <nl> + " " " Opens a secure port for accepting RPCs . <nl> + <nl> + This method may only be called before starting the server . <nl> + <nl> + Args : <nl> + address : The address for which to open a port . <nl> + if the port is 0 , or not specified in the address , then gRPC <nl> + runtime will choose a port . <nl> + server_credentials : A ServerCredentials object . <nl> + <nl> + Returns : <nl> + An integer port on which server will accept RPC requests . <nl> + " " " <nl> + return self . _server . add_secure_port ( address , server_credentials ) <nl> + <nl> + async def start ( self ) - > None : <nl> + " " " Starts this Server . <nl> + <nl> + This method may only be called once . ( i . e . it is not idempotent ) . <nl> + " " " <nl> + await self . _server . start ( ) <nl> + <nl> + def stop ( self , grace : Optional [ float ] ) - > asyncio . Event : <nl> + " " " Stops this Server . <nl> + <nl> + This method immediately stop service of new RPCs in all cases . <nl> + <nl> + If a grace period is specified , this method returns immediately <nl> + and all RPCs active at the end of the grace period are aborted . <nl> + If a grace period is not specified ( by passing None for ` grace ` ) , <nl> + all existing RPCs are aborted immediately and this method <nl> + blocks until the last RPC handler terminates . <nl> + <nl> + This method is idempotent and may be called at any time . <nl> + Passing a smaller grace value in a subsequent call will have <nl> + the effect of stopping the Server sooner ( passing None will <nl> + have the effect of stopping the server immediately ) . Passing <nl> + a larger grace value in a subsequent call * will not * have the <nl> + effect of stopping the server later ( i . e . the most restrictive <nl> + grace value is used ) . <nl> + <nl> + Args : <nl> + grace : A duration of time in seconds or None . <nl> + <nl> + Returns : <nl> + A threading . Event that will be set when this Server has completely <nl> + stopped , i . e . when running RPCs either complete or are aborted and <nl> + all handlers have terminated . <nl> + " " " <nl> + raise NotImplementedError ( ) <nl> + <nl> + async def wait_for_termination ( self , <nl> + timeout : Optional [ float ] = None ) - > bool : <nl> + " " " Block current thread until the server stops . <nl> + <nl> + This is an EXPERIMENTAL API . <nl> + <nl> + The wait will not consume computational resources during blocking , and <nl> + it will block until one of the two following conditions are met : <nl> + <nl> + 1 ) The server is stopped or terminated ; <nl> + 2 ) A timeout occurs if timeout is not ` None ` . <nl> + <nl> + The timeout argument works in the same way as ` threading . Event . wait ( ) ` . <nl> + https : / / docs . python . org / 3 / library / threading . html # threading . Event . wait <nl> + <nl> + Args : <nl> + timeout : A floating point number specifying a timeout for the <nl> + operation in seconds . <nl> + <nl> + Returns : <nl> + A bool indicates if the operation times out . <nl> + " " " <nl> + if timeout : <nl> + raise NotImplementedError ( ) <nl> + # TODO ( lidiz ) replace this wait forever logic <nl> + future = asyncio . get_event_loop ( ) . create_future ( ) <nl> + await future <nl> + <nl> + <nl> + def server ( thread_pool = None , <nl> + handlers = None , <nl> + interceptors = None , <nl> + options = None , <nl> + maximum_concurrent_rpcs = None , <nl> + compression = None ) : <nl> + " " " Creates a Server with which RPCs can be serviced . <nl> + <nl> + Args : <nl> + thread_pool : A futures . ThreadPoolExecutor to be used by the Server <nl> + to execute RPC handlers . <nl> + handlers : An optional list of GenericRpcHandlers used for executing RPCs . <nl> + More handlers may be added by calling add_generic_rpc_handlers any time <nl> + before the server is started . <nl> + interceptors : An optional list of ServerInterceptor objects that observe <nl> + and optionally manipulate the incoming RPCs before handing them over to <nl> + handlers . The interceptors are given control in the order they are <nl> + specified . This is an EXPERIMENTAL API . <nl> + options : An optional list of key - value pairs ( channel args in gRPC runtime ) <nl> + to configure the channel . <nl> + maximum_concurrent_rpcs : The maximum number of concurrent RPCs this server <nl> + will service before returning RESOURCE_EXHAUSTED status , or None to <nl> + indicate no limit . <nl> + compression : An element of grpc . compression , e . g . <nl> + grpc . compression . Gzip . This compression algorithm will be used for the <nl> + lifetime of the server unless overridden . This is an EXPERIMENTAL option . <nl> + <nl> + Returns : <nl> + A Server object . <nl> + " " " <nl> + return Server ( thread_pool , ( ) if handlers is None else handlers , ( ) <nl> + if interceptors is None else interceptors , ( ) <nl> + if options is None else options , maximum_concurrent_rpcs , <nl> + compression ) <nl> new file mode 100644 <nl> index 00000000000 . . ef0a3f7ff2c <nl> mmm / dev / null <nl> ppp b / src / python / grpcio_tests / tests_aio / benchmark / server . py <nl> <nl> + # Copyright 2019 The gRPC Authors . <nl> + # <nl> + # Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + # you may not use this file except in compliance with the License . <nl> + # You may obtain a copy of the License at <nl> + # <nl> + # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + # <nl> + # Unless required by applicable law or agreed to in writing , software <nl> + # distributed under the License is distributed on an " AS IS " BASIS , <nl> + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + # See the License for the specific language governing permissions and <nl> + # limitations under the License . <nl> + <nl> + import asyncio <nl> + import logging <nl> + import unittest <nl> + <nl> + from grpc . experimental import aio <nl> + from src . proto . grpc . testing import messages_pb2 <nl> + from src . proto . grpc . testing import benchmark_service_pb2_grpc <nl> + <nl> + <nl> + class BenchmarkServer ( benchmark_service_pb2_grpc . BenchmarkServiceServicer ) : <nl> + <nl> + async def UnaryCall ( self , request , context ) : <nl> + payload = messages_pb2 . Payload ( body = b ' \ 0 ' * request . response_size ) <nl> + return messages_pb2 . SimpleResponse ( payload = payload ) <nl> + <nl> + <nl> + async def _start_async_server ( ) : <nl> + server = aio . server ( ) <nl> + <nl> + port = server . add_insecure_port ( ( ' localhost : % s ' % 50051 ) . encode ( ' ASCII ' ) ) <nl> + servicer = BenchmarkServer ( ) <nl> + benchmark_service_pb2_grpc . add_BenchmarkServiceServicer_to_server ( <nl> + servicer , server ) <nl> + <nl> + await server . start ( ) <nl> + await server . wait_for_termination ( ) <nl> + <nl> + <nl> + def main ( ) : <nl> + aio . init_grpc_aio ( ) <nl> + loop = asyncio . get_event_loop ( ) <nl> + loop . create_task ( _start_async_server ( ) ) <nl> + loop . run_forever ( ) <nl> + <nl> + <nl> + if __name__ = = ' __main__ ' : <nl> + logging . basicConfig ( ) <nl> + main ( ) <nl> new file mode 100644 <nl> index 00000000000 . . 80f578e6c03 <nl> mmm / dev / null <nl> ppp b / src / python / grpcio_tests / tests_aio / unit / BUILD . bazel <nl> <nl> + # Copyright 2019 The gRPC Authors <nl> + # <nl> + # Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + # you may not use this file except in compliance with the License . <nl> + # You may obtain a copy of the License at <nl> + # <nl> + # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + # <nl> + # Unless required by applicable law or agreed to in writing , software <nl> + # distributed under the License is distributed on an " AS IS " BASIS , <nl> + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + # See the License for the specific language governing permissions and <nl> + # limitations under the License . <nl> + <nl> + package ( <nl> + default_testonly = 1 , <nl> + default_visibility = [ " / / visibility : public " ] , <nl> + ) <nl> + <nl> + GRPC_ASYNC_TESTS = [ <nl> + " server_test . py " , <nl> + ] <nl> + <nl> + [ <nl> + py_test ( <nl> + name = test_file_name [ : - 3 ] , <nl> + size = " small " , <nl> + srcs = [ test_file_name ] , <nl> + main = test_file_name , <nl> + deps = [ <nl> + " / / src / python / grpcio / grpc : grpcio " , <nl> + " / / src / proto / grpc / testing : py_messages_proto " , <nl> + " / / src / proto / grpc / testing : benchmark_service_py_pb2_grpc " , <nl> + " / / src / proto / grpc / testing : benchmark_service_py_pb2 " , <nl> + " / / external : six " <nl> + ] , <nl> + imports = [ " . . / . . / " , ] , <nl> + data = [ <nl> + " / / src / python / grpcio_tests / tests / unit / credentials " , <nl> + ] , <nl> + ) for test_file_name in GRPC_ASYNC_TESTS <nl> + ] <nl> new file mode 100644 <nl> index 00000000000 . . 86beb02461a <nl> mmm / dev / null <nl> ppp b / src / python / grpcio_tests / tests_aio / unit / server_test . py <nl> <nl> + # Copyright 2019 The gRPC Authors . <nl> + # <nl> + # Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + # you may not use this file except in compliance with the License . <nl> + # You may obtain a copy of the License at <nl> + # <nl> + # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + # <nl> + # Unless required by applicable law or agreed to in writing , software <nl> + # distributed under the License is distributed on an " AS IS " BASIS , <nl> + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + # See the License for the specific language governing permissions and <nl> + # limitations under the License . <nl> + <nl> + import asyncio <nl> + import logging <nl> + import unittest <nl> + <nl> + from grpc . experimental import aio <nl> + from src . proto . grpc . testing import messages_pb2 <nl> + from src . proto . grpc . testing import benchmark_service_pb2_grpc <nl> + <nl> + <nl> + class BenchmarkServer ( benchmark_service_pb2_grpc . BenchmarkServiceServicer ) : <nl> + <nl> + async def UnaryCall ( self , request , context ) : <nl> + payload = messages_pb2 . Payload ( body = b ' \ 0 ' * request . response_size ) <nl> + return messages_pb2 . SimpleResponse ( payload = payload ) <nl> + <nl> + <nl> + class TestServer ( unittest . TestCase ) : <nl> + <nl> + def test_unary_unary ( self ) : <nl> + loop = asyncio . get_event_loop ( ) <nl> + <nl> + async def test_unary_unary_body ( ) : <nl> + server = aio . server ( ) <nl> + port = server . add_insecure_port ( ( ' [ : : ] : 0 ' ) . encode ( ' ASCII ' ) ) <nl> + benchmark_service_pb2_grpc . add_BenchmarkServiceServicer_to_server ( <nl> + BenchmarkServer ( ) , server ) <nl> + await server . start ( ) <nl> + <nl> + async with aio . insecure_channel ( f ' localhost : { port } ' ) as channel : <nl> + unary_call = channel . unary_unary ( <nl> + ' / grpc . testing . BenchmarkService / UnaryCall ' , <nl> + request_serializer = messages_pb2 . SimpleRequest . <nl> + SerializeToString , <nl> + response_deserializer = messages_pb2 . SimpleResponse . FromString <nl> + ) <nl> + response = await unary_call ( <nl> + messages_pb2 . SimpleRequest ( response_size = 1 ) ) <nl> + self . assertIsInstance ( response , messages_pb2 . SimpleResponse ) <nl> + self . assertEqual ( 1 , len ( response . payload . body ) ) <nl> + <nl> + loop . run_until_complete ( test_unary_unary_body ( ) ) <nl> + <nl> + <nl> + if __name__ = = ' __main__ ' : <nl> + aio . init_grpc_aio ( ) <nl> + logging . basicConfig ( ) <nl> + unittest . main ( verbosity = 2 ) <nl> | Minimal AsyncIO Server for gRPC | grpc/grpc | c6ae98d49a99d877c8a3bde01b221f70bb5babd9 | 2019-10-14T22:32:19Z |
similarity index 100 % <nl> rename from contrib / gitian - downloader / bitcoin - download - config <nl> rename to contrib / gitian - downloader / linux - download - config <nl> new file mode 100644 <nl> index 000000000000 . . c0de21c48f78 <nl> mmm / dev / null <nl> ppp b / contrib / gitian - downloader / win32 - download - config <nl> <nl> + mmm <nl> + name : bitcoin <nl> + urls : <nl> + - http : / / bitcoin . org / bitcoin - latest - win32 - gitian . zip <nl> + rss : <nl> + - url : http : / / sourceforge . net / api / file / index / project - id / 244765 / mtime / desc / limit / 100 / rss <nl> + xpath : / / item / link / text ( ) <nl> + pattern : bitcoin - \ d + . \ d + . \ d + - win32 - gitian . zip <nl> + signers : <nl> + 0A82509767C7D4A5D14DA2301AE1D35043E08E54 : <nl> + weight : 40 <nl> + name : BlueMatt <nl> + key : bluematt <nl> + BF6273FAEF7CC0BA1F562E50989F6B3048A116B5 : <nl> + weight : 40 <nl> + name : Devrandom <nl> + key : devrandom <nl> + D762373D24904A3E42F33B08B9A408E71DAAC974 : <nl> + weight : 40 <nl> + name : Sipa <nl> + key : sipa <nl> + 77E72E69DA7EE0A148C06B21B34821D4944DE5F7 : <nl> + weight : 40 <nl> + name : tcatm <nl> + key : tcatm <nl> + 01CDF4627A3B88AAE4A571C87588242FBE38D3A8 : <nl> + weight : 40 <nl> + name : " Gavin Andresen " <nl> + key : gavinandresen <nl> + minimum_weight : 120 <nl> | Merge pull request from TheBlueMatt / gitian - downloader | bitcoin/bitcoin | f8937b2d3bb545a0a6ff78031ce3cdcb3208ecbe | 2011-09-23T17:56:25Z |
mmm a / watcher / eden . cpp <nl> ppp b / watcher / eden . cpp <nl> <nl> # include < folly / String . h > <nl> # include < folly / io / async / EventBase . h > <nl> # include < folly / io / async / EventBaseManager . h > <nl> + # include < thrift / lib / cpp / async / TAsyncSocket . h > <nl> # include < thrift / lib / cpp2 / async / HeaderClientChannel . h > <nl> # include < algorithm > <nl> # include " eden / fs / service / gen - cpp2 / StreamingEdenService . h " <nl> | Small dependency cleanup | facebook/watchman | 4096124277fe94b63f35a447bb86cced68141799 | 2017-10-17T21:50:31Z |
mmm a / src / net . h <nl> ppp b / src / net . h <nl> class CConnman <nl> CConnman ( uint64_t seed0 , uint64_t seed1 ) ; <nl> ~ CConnman ( ) ; <nl> bool Start ( CScheduler & scheduler , const Options & options ) ; <nl> - void Stop ( ) ; <nl> + <nl> + / / TODO : Remove NO_THREAD_SAFETY_ANALYSIS . Lock cs_vNodes before reading the variable vNodes . <nl> + / / <nl> + / / When removing NO_THREAD_SAFETY_ANALYSIS be aware of the following lock order requirements : <nl> + / / * CheckForStaleTipAndEvictPeers locks cs_main before indirectly calling GetExtraOutboundCount <nl> + / / which locks cs_vNodes . <nl> + / / * ProcessMessage locks cs_main and g_cs_orphans before indirectly calling ForEachNode which <nl> + / / locks cs_vNodes . <nl> + / / <nl> + / / Thus the implicit locking order requirement is : ( 1 ) cs_main , ( 2 ) g_cs_orphans , ( 3 ) cs_vNodes . <nl> + void Stop ( ) NO_THREAD_SAFETY_ANALYSIS ; <nl> + <nl> void Interrupt ( ) ; <nl> bool GetNetworkActive ( ) const { return fNetworkActive ; } ; <nl> bool GetUseAddrmanOutgoing ( ) const { return m_use_addrman_outgoing ; } ; <nl> class CConnman <nl> CCriticalSection cs_vOneShots ; <nl> std : : vector < std : : string > vAddedNodes GUARDED_BY ( cs_vAddedNodes ) ; <nl> CCriticalSection cs_vAddedNodes ; <nl> - std : : vector < CNode * > vNodes ; <nl> + std : : vector < CNode * > vNodes GUARDED_BY ( cs_vNodes ) ; <nl> std : : list < CNode * > vNodesDisconnected ; <nl> mutable CCriticalSection cs_vNodes ; <nl> std : : atomic < NodeId > nLastNodeId { 0 } ; <nl> | Add locking annotation for vNodes . vNodes is guarded by cs_vNodes . | bitcoin/bitcoin | eea02be70ee37b845f2719b3c08e5baf4b6f51f6 | 2019-01-19T17:23:53Z |
mmm a / src / common / bit_set . h <nl> ppp b / src / common / bit_set . h <nl> class BitSet { <nl> class Iterator { <nl> public : <nl> Iterator ( const Iterator & other ) : m_val ( other . m_val ) , m_bit ( other . m_bit ) { } <nl> - Iterator ( IntTy val , int bit ) : m_val ( val ) , m_bit ( bit ) { } <nl> + Iterator ( IntTy val ) : m_val ( val ) , m_bit ( 0 ) { } <nl> Iterator & operator = ( Iterator other ) { <nl> new ( this ) Iterator ( other ) ; <nl> return * this ; <nl> } <nl> int operator * ( ) { <nl> - return m_bit ; <nl> + return m_bit + ComputeLsb ( ) ; <nl> } <nl> Iterator & operator + + ( ) { <nl> - if ( m_val = = 0 ) { <nl> - m_bit = - 1 ; <nl> - } else { <nl> - int bit = LeastSignificantSetBit ( m_val ) ; <nl> - m_val & = ~ ( 1 < < bit ) ; <nl> - m_bit = bit ; <nl> - } <nl> + int lsb = ComputeLsb ( ) ; <nl> + m_val > > = lsb + 1 ; <nl> + m_bit + = lsb + 1 ; <nl> + m_has_lsb = false ; <nl> return * this ; <nl> } <nl> Iterator operator + + ( int _ ) { <nl> class BitSet { <nl> return other ; <nl> } <nl> bool operator = = ( Iterator other ) const { <nl> - return m_bit = = other . m_bit ; <nl> + return m_val = = other . m_val ; <nl> } <nl> bool operator ! = ( Iterator other ) const { <nl> - return m_bit ! = other . m_bit ; <nl> + return m_val ! = other . m_val ; <nl> } <nl> <nl> private : <nl> + int ComputeLsb ( ) { <nl> + if ( ! m_has_lsb ) { <nl> + m_lsb = LeastSignificantSetBit ( m_val ) ; <nl> + m_has_lsb = true ; <nl> + } <nl> + return m_lsb ; <nl> + } <nl> IntTy m_val ; <nl> int m_bit ; <nl> + int m_lsb = - 1 ; <nl> + bool m_has_lsb = false ; <nl> } ; <nl> <nl> BitSet ( ) : m_val ( 0 ) { } <nl> class BitSet { <nl> } <nl> <nl> Iterator begin ( ) const { <nl> - Iterator it ( m_val , 0 ) ; <nl> - return + + it ; <nl> + return Iterator ( m_val ) ; <nl> } <nl> Iterator end ( ) const { <nl> - return Iterator ( m_val , - 1 ) ; <nl> + return Iterator ( 0 ) ; <nl> } <nl> <nl> IntTy m_val ; <nl> | Common : Optimize BitSet iterator | yuzu-emu/yuzu | d36ec905b1d9536198e584915024ed65f0342ab2 | 2017-01-30T05:31:38Z |
mmm a / include / swift / AST / ExistentialLayout . h <nl> ppp b / include / swift / AST / ExistentialLayout . h <nl> struct ExistentialLayout { <nl> ExistentialLayout ( ProtocolType * type ) ; <nl> ExistentialLayout ( ProtocolCompositionType * type ) ; <nl> <nl> - / / / The superclass constraint , if any . <nl> - Type superclass ; <nl> + / / / The explicit superclass constraint , if any . <nl> + Type explicitSuperclass ; <nl> <nl> / / / Whether the existential contains an explicit ' & AnyObject ' constraint . <nl> bool hasExplicitAnyObject : 1 ; <nl> struct ExistentialLayout { <nl> <nl> bool isObjC ( ) const { <nl> / / FIXME : Does the superclass have to be @ objc ? <nl> - return ( ( superclass | | hasExplicitAnyObject | | ! getProtocols ( ) . empty ( ) ) & & <nl> + return ( ( explicitSuperclass | | <nl> + hasExplicitAnyObject | | <nl> + ! getProtocols ( ) . empty ( ) ) & & <nl> ! containsNonObjCProtocol ) ; <nl> } <nl> <nl> struct ExistentialLayout { <nl> / / / ' & AnyObject ' member or because of a superclass or protocol constraint . <nl> bool requiresClass ( ) const ; <nl> <nl> - / / Does this existential contain the Error protocol ? <nl> + / / / Returns the existential ' s superclass , if any ; this is either an explicit <nl> + / / / superclass term in a composition type , or the superclass of one of the <nl> + / / / protocols . <nl> + Type getSuperclass ( ) const ; <nl> + <nl> + / / / Does this existential contain the Error protocol ? <nl> bool isExistentialWithError ( ASTContext & ctx ) const ; <nl> <nl> - / / Does this existential consist of an Error protocol only with no other <nl> - / / constraints ? <nl> + / / / Does this existential consist of an Error protocol only with no other <nl> + / / / constraints ? <nl> bool isErrorExistential ( ) const ; <nl> <nl> static inline ProtocolType * getProtocolType ( const Type & Ty ) { <nl> mmm a / lib / AST / ASTContext . cpp <nl> ppp b / lib / AST / ASTContext . cpp <nl> CanArchetypeType ArchetypeType : : getOpened ( Type existential , <nl> protos . push_back ( proto - > getDecl ( ) ) ; <nl> <nl> auto layoutConstraint = layout . getLayoutConstraint ( ) ; <nl> + auto layoutSuperclass = layout . getSuperclass ( ) ; <nl> <nl> auto arena = AllocationArena : : Permanent ; <nl> void * mem = ctx . Allocate ( <nl> totalSizeToAlloc < ProtocolDecl * , Type , LayoutConstraint , UUID > ( <nl> protos . size ( ) , <nl> - layout . superclass ? 1 : 0 , <nl> + layoutSuperclass ? 1 : 0 , <nl> layoutConstraint ? 1 : 0 , 1 ) , <nl> alignof ( ArchetypeType ) , arena ) ; <nl> <nl> / / FIXME : Pass in class layout constraint <nl> auto result = <nl> : : new ( mem ) ArchetypeType ( ctx , existential , <nl> - protos , layout . superclass , <nl> + protos , layoutSuperclass , <nl> layoutConstraint , * knownID ) ; <nl> openedExistentialArchetypes [ * knownID ] = result ; <nl> <nl> mmm a / lib / AST / ASTMangler . cpp <nl> ppp b / lib / AST / ASTMangler . cpp <nl> void ASTMangler : : appendType ( Type type ) { <nl> if ( First ) <nl> appendOperator ( " y " ) ; <nl> <nl> - if ( layout . superclass ) { <nl> - appendType ( layout . superclass ) ; <nl> + if ( auto superclass = layout . explicitSuperclass ) { <nl> + appendType ( superclass ) ; <nl> return appendOperator ( " Xc " ) ; <nl> } else if ( layout . hasExplicitAnyObject ) { <nl> return appendOperator ( " Xl " ) ; <nl> mmm a / lib / AST / ASTVerifier . cpp <nl> ppp b / lib / AST / ASTVerifier . cpp <nl> class Verifier : public ASTWalker { <nl> } <nl> <nl> auto layout = srcTy - > getExistentialLayout ( ) ; <nl> - if ( layout . superclass | | <nl> + if ( layout . explicitSuperclass | | <nl> ! layout . isObjC ( ) | | <nl> layout . getProtocols ( ) . size ( ) ! = 1 ) { <nl> Out < < " ProtocolMetatypeToObject with non - ObjC - protocol metatype : \ n " ; <nl> mmm a / lib / AST / ConformanceLookupTable . cpp <nl> ppp b / lib / AST / ConformanceLookupTable . cpp <nl> void ConformanceLookupTable : : inheritConformances ( ClassDecl * classDecl , <nl> } <nl> if ( inheritedType - > isExistentialType ( ) ) { <nl> auto layout = inheritedType - > getExistentialLayout ( ) ; <nl> - if ( layout . superclass ) { <nl> + if ( layout . explicitSuperclass ) { <nl> superclassLoc = inherited . getSourceRange ( ) . Start ; <nl> return superclassLoc ; <nl> } <nl> mmm a / lib / AST / Decl . cpp <nl> ppp b / lib / AST / Decl . cpp <nl> bool ProtocolDecl : : requiresClassSlow ( ) { <nl> return true ; <nl> } <nl> } <nl> + if ( type - > getClassOrBoundGenericClass ( ) ) { <nl> + Bits . ProtocolDecl . RequiresClass = true ; <nl> + return true ; <nl> + } <nl> } <nl> <nl> return Bits . ProtocolDecl . RequiresClass ; <nl> mmm a / lib / AST / GenericSignatureBuilder . cpp <nl> ppp b / lib / AST / GenericSignatureBuilder . cpp <nl> ConstraintResult GenericSignatureBuilder : : addTypeRequirement ( <nl> anyErrors = true ; <nl> } <nl> <nl> - if ( layout . superclass ) { <nl> + if ( auto superclass = layout . explicitSuperclass ) { <nl> if ( isErrorResult ( addSuperclassRequirementDirect ( resolvedSubject , <nl> - layout . superclass , <nl> + superclass , <nl> source ) ) ) <nl> anyErrors = true ; <nl> } <nl> mmm a / lib / AST / Module . cpp <nl> ppp b / lib / AST / Module . cpp <nl> ModuleDecl : : lookupConformance ( Type type , ProtocolDecl * protocol ) { <nl> <nl> / / If the existential is class - constrained , the class might conform <nl> / / concretely . <nl> - if ( layout . superclass ) { <nl> - if ( auto result = lookupConformance ( layout . superclass , protocol ) ) <nl> + if ( auto superclass = layout . explicitSuperclass ) { <nl> + if ( auto result = lookupConformance ( superclass , protocol ) ) <nl> return result ; <nl> } <nl> <nl> / / Otherwise , the existential might conform abstractly . <nl> for ( auto proto : layout . getProtocols ( ) ) { <nl> auto * protoDecl = proto - > getDecl ( ) ; <nl> - if ( protoDecl = = protocol | | protoDecl - > inheritsFrom ( protocol ) ) <nl> + <nl> + / / If we found the protocol we ' re looking for , return an abstract <nl> + / / conformance to it . <nl> + if ( protoDecl = = protocol ) <nl> + return ProtocolConformanceRef ( protocol ) ; <nl> + <nl> + / / If the protocol has a superclass constraint , we might conform <nl> + / / concretely . <nl> + if ( auto superclass = protoDecl - > getSuperclass ( ) ) { <nl> + if ( auto result = lookupConformance ( superclass , protocol ) ) <nl> + return result ; <nl> + } <nl> + <nl> + / / Now check refined protocols . <nl> + if ( protoDecl - > inheritsFrom ( protocol ) ) <nl> return ProtocolConformanceRef ( protocol ) ; <nl> } <nl> <nl> mmm a / lib / AST / NameLookup . cpp <nl> ppp b / lib / AST / NameLookup . cpp <nl> bool DeclContext : : lookupQualified ( Type type , <nl> stack . push_back ( proto ) ; <nl> <nl> / / Look into the superclasses of this archetype . <nl> - if ( auto superclassTy = archetypeTy - > getSuperclass ( ) ) <nl> - if ( auto superclassDecl = superclassTy - > getAnyNominal ( ) ) <nl> + if ( auto superclass = archetypeTy - > getSuperclass ( ) ) <nl> + if ( auto superclassDecl = superclass - > getClassOrBoundGenericClass ( ) ) <nl> if ( visited . insert ( superclassDecl ) . second ) <nl> stack . push_back ( superclassDecl ) ; <nl> } <nl> bool DeclContext : : lookupQualified ( Type type , <nl> stack . push_back ( protoDecl ) ; <nl> } <nl> <nl> - if ( layout . superclass ) { <nl> - auto * nominalDecl = layout . superclass - > getAnyNominal ( ) ; <nl> + if ( auto superclass = layout . explicitSuperclass ) { <nl> + auto * nominalDecl = superclass - > getClassOrBoundGenericClass ( ) ; <nl> if ( visited . insert ( nominalDecl ) . second ) <nl> stack . push_back ( nominalDecl ) ; <nl> } <nl> bool DeclContext : : lookupQualified ( Type type , <nl> } <nl> <nl> if ( visitSuperclass ) { <nl> - if ( auto superclassType = classDecl - > getSuperclass ( ) ) <nl> - if ( auto superclassDecl = superclassType - > getClassOrBoundGenericClass ( ) ) <nl> - if ( visited . insert ( superclassDecl ) . second ) <nl> - stack . push_back ( superclassDecl ) ; <nl> + if ( auto superclassDecl = classDecl - > getSuperclassDecl ( ) ) <nl> + if ( visited . insert ( superclassDecl ) . second ) <nl> + stack . push_back ( superclassDecl ) ; <nl> } <nl> } <nl> <nl> + if ( auto protocolDecl = dyn_cast < ProtocolDecl > ( current ) ) { <nl> + if ( auto superclassDecl = protocolDecl - > getSuperclassDecl ( ) ) <nl> + if ( visited . insert ( superclassDecl ) . second ) <nl> + stack . push_back ( superclassDecl ) ; <nl> + } <nl> + <nl> / / If we ' re not looking at a protocol and we ' re not supposed to <nl> / / visit the protocols that this type conforms to , skip the next <nl> / / step . <nl> mmm a / lib / AST / Type . cpp <nl> ppp b / lib / AST / Type . cpp <nl> ExistentialLayout : : ExistentialLayout ( ProtocolCompositionType * type ) { <nl> auto members = type - > getMembers ( ) ; <nl> if ( ! members . empty ( ) & & <nl> isa < ClassDecl > ( members [ 0 ] - > getAnyNominal ( ) ) ) { <nl> - superclass = members [ 0 ] ; <nl> + explicitSuperclass = members [ 0 ] ; <nl> members = members . slice ( 1 ) ; <nl> } <nl> <nl> ExistentialLayout CanType : : getExistentialLayout ( ) { <nl> } <nl> <nl> bool ExistentialLayout : : requiresClass ( ) const { <nl> - if ( hasExplicitAnyObject | | superclass ) <nl> + if ( hasExplicitAnyObject | | explicitSuperclass ) <nl> return true ; <nl> <nl> for ( auto proto : getProtocols ( ) ) { <nl> bool ExistentialLayout : : requiresClass ( ) const { <nl> return false ; <nl> } <nl> <nl> + Type ExistentialLayout : : getSuperclass ( ) const { <nl> + if ( explicitSuperclass ) <nl> + return explicitSuperclass ; <nl> + <nl> + for ( auto proto : getProtocols ( ) ) { <nl> + if ( auto superclass = proto - > getSuperclass ( ) ) <nl> + return superclass ; <nl> + } <nl> + <nl> + return Type ( ) ; <nl> + } <nl> + <nl> bool ExistentialLayout : : isAnyObject ( ) const { <nl> - return ( hasExplicitAnyObject & & ! superclass & & getProtocols ( ) . empty ( ) ) ; <nl> + return ( hasExplicitAnyObject & & ! explicitSuperclass & & getProtocols ( ) . empty ( ) ) ; <nl> } <nl> <nl> bool TypeBase : : isObjCExistentialType ( ) { <nl> bool TypeBase : : isAnyObject ( ) { <nl> bool ExistentialLayout : : isErrorExistential ( ) const { <nl> auto protocols = getProtocols ( ) ; <nl> return ( ! hasExplicitAnyObject & & <nl> - ! superclass & & <nl> + ! explicitSuperclass & & <nl> protocols . size ( ) = = 1 & & <nl> protocols [ 0 ] - > getDecl ( ) - > isSpecificProtocol ( KnownProtocolKind : : Error ) ) ; <nl> } <nl> Type TypeBase : : getSuperclass ( ) { <nl> if ( auto dynamicSelfTy = getAs < DynamicSelfType > ( ) ) <nl> return dynamicSelfTy - > getSelfType ( ) ; <nl> <nl> + if ( auto protocolTy = getAs < ProtocolType > ( ) ) <nl> + return protocolTy - > getDecl ( ) - > getSuperclass ( ) ; <nl> + <nl> if ( auto compositionTy = getAs < ProtocolCompositionType > ( ) ) <nl> - return compositionTy - > getExistentialLayout ( ) . superclass ; <nl> + return compositionTy - > getExistentialLayout ( ) . getSuperclass ( ) ; <nl> <nl> / / No other types have superclasses . <nl> return Type ( ) ; <nl> getObjCObjectRepresentable ( Type type , const DeclContext * dc ) { <nl> if ( type - > isExistentialType ( ) ) { <nl> auto layout = type - > getExistentialLayout ( ) ; <nl> if ( layout . isObjC ( ) & & <nl> - ( ! layout . superclass | | <nl> - getObjCObjectRepresentable ( layout . superclass , dc ) = = <nl> + ( ! layout . explicitSuperclass | | <nl> + getObjCObjectRepresentable ( layout . explicitSuperclass , dc ) = = <nl> ForeignRepresentableKind : : Object ) ) <nl> return ForeignRepresentableKind : : Object ; <nl> } <nl> static Type getConcreteTypeForSuperclassTraversing ( Type t ) { <nl> } else if ( auto dynamicSelfTy = t - > getAs < DynamicSelfType > ( ) ) { <nl> return dynamicSelfTy - > getSelfType ( ) ; <nl> } else if ( auto compositionTy = t - > getAs < ProtocolCompositionType > ( ) ) { <nl> - return compositionTy - > getExistentialLayout ( ) . superclass ; <nl> + return compositionTy - > getExistentialLayout ( ) . explicitSuperclass ; <nl> } <nl> } <nl> return t ; <nl> bool TypeBase : : usesNativeReferenceCounting ( ResilienceExpansion resilience ) { <nl> case TypeKind : : ProtocolComposition : { <nl> auto layout = getExistentialLayout ( ) ; <nl> assert ( layout . requiresClass ( ) & & " Opaque existentials don ' t use refcounting " ) ; <nl> - if ( layout . superclass ) <nl> - return layout . superclass - > usesNativeReferenceCounting ( resilience ) ; <nl> + if ( auto superclass = layout . getSuperclass ( ) ) <nl> + return superclass - > usesNativeReferenceCounting ( resilience ) ; <nl> return : : doesOpaqueClassUseNativeReferenceCounting ( type - > getASTContext ( ) ) ; <nl> } <nl> <nl> mmm a / lib / FrontendTool / ReferenceDependencies . cpp <nl> ppp b / lib / FrontendTool / ReferenceDependencies . cpp <nl> bool ProvidesEmitter : : extendedTypeIsPrivate ( TypeLoc inheritedType ) { <nl> } <nl> <nl> auto layout = type - > getExistentialLayout ( ) ; <nl> - assert ( ! layout . superclass & & " Should not have a subclass existential " <nl> - " in the inheritance clause of an extension " ) ; <nl> + assert ( ! layout . explicitSuperclass & & " Should not have a subclass existential " <nl> + " in the inheritance clause of an extension " ) ; <nl> for ( auto protoTy : layout . getProtocols ( ) ) { <nl> if ( ! declIsPrivate ( protoTy - > getDecl ( ) ) ) <nl> return false ; <nl> mmm a / lib / IRGen / GenCast . cpp <nl> ppp b / lib / IRGen / GenCast . cpp <nl> void irgen : : emitScalarExistentialDowncast ( IRGenFunction & IGF , <nl> bool hasClassConstraint = layout . requiresClass ( ) ; <nl> bool hasClassConstraintByProtocol = false ; <nl> <nl> - bool hasSuperclassConstraint = bool ( layout . superclass ) ; <nl> + bool hasSuperclassConstraint = bool ( layout . getSuperclass ( ) ) ; <nl> <nl> for ( auto protoTy : layout . getProtocols ( ) ) { <nl> auto * protoDecl = protoTy - > getDecl ( ) ; <nl> void irgen : : emitScalarExistentialDowncast ( IRGenFunction & IGF , <nl> / / The source of a scalar cast is statically known to be a class or a <nl> / / metatype , so we only have to check the class constraint in two cases : <nl> / / <nl> - / / 1 ) The destination type has an explicit superclass constraint that is <nl> + / / 1 ) The destination type has a superclass constraint that is <nl> / / more derived than what the source type is known to be . <nl> / / <nl> / / 2 ) We are casting between metatypes , in which case the source might <nl> void irgen : : emitScalarExistentialDowncast ( IRGenFunction & IGF , <nl> args . push_back ( metadataValue ) ; <nl> <nl> if ( checkSuperclassConstraint ) <nl> - args . push_back ( IGF . emitTypeMetadataRef ( CanType ( layout . superclass ) ) ) ; <nl> + args . push_back ( IGF . emitTypeMetadataRef ( CanType ( layout . getSuperclass ( ) ) ) ) ; <nl> <nl> for ( auto proto : witnessTableProtos ) <nl> args . push_back ( proto ) ; <nl> mmm a / lib / IRGen / GenClangType . cpp <nl> ppp b / lib / IRGen / GenClangType . cpp <nl> clang : : CanQualType GenClangType : : visitProtocolCompositionType ( <nl> return getClangIdType ( getClangASTContext ( ) ) ; <nl> <nl> auto superclassTy = clangCtx . ObjCBuiltinIdTy ; <nl> - if ( layout . superclass ) { <nl> + if ( auto layoutSuperclassTy = layout . getSuperclass ( ) ) { <nl> superclassTy = clangCtx . getCanonicalType ( <nl> cast < clang : : ObjCObjectPointerType > ( <nl> - Converter . convert ( IGM , CanType ( layout . superclass ) ) ) <nl> + Converter . convert ( IGM , CanType ( layoutSuperclassTy ) ) ) <nl> - > getPointeeType ( ) ) ; <nl> } <nl> <nl> mmm a / lib / IRGen / GenExistential . cpp <nl> ppp b / lib / IRGen / GenExistential . cpp <nl> static const TypeInfo * createExistentialTypeInfo ( IRGenModule & IGM , CanType T ) { <nl> ReferenceCounting refcounting = getReferenceCountingForType ( IGM , T ) ; <nl> <nl> llvm : : PointerType * reprTy = nullptr ; <nl> - if ( layout . superclass ) { <nl> - auto & superTI = IGM . getTypeInfoForUnlowered ( layout . superclass ) ; <nl> + if ( auto superclass = layout . getSuperclass ( ) ) { <nl> + auto & superTI = IGM . getTypeInfoForUnlowered ( superclass ) ; <nl> reprTy = cast < llvm : : PointerType > ( superTI . getStorageType ( ) ) ; <nl> } else if ( refcounting = = ReferenceCounting : : Native ) { <nl> reprTy = IGM . RefCountedPtrTy ; <nl> mmm a / lib / IRGen / IRGenMangler . cpp <nl> ppp b / lib / IRGen / IRGenMangler . cpp <nl> mangleProtocolForLLVMTypeName ( ProtocolCompositionType * type ) { <nl> if ( i = = 0 ) <nl> appendOperator ( " _ " ) ; <nl> } <nl> - if ( layout . superclass ) { <nl> - auto superclassTy = layout . superclass ; <nl> - <nl> + if ( auto superclass = layout . explicitSuperclass ) { <nl> / / We share type infos for different instantiations of a generic type <nl> / / when the archetypes have the same exemplars . We cannot mangle <nl> / / archetypes , and the mangling does not have to be unique , so we just <nl> / / mangle the unbound generic form of the type . <nl> - if ( superclassTy - > hasArchetype ( ) ) { <nl> - superclassTy = superclassTy - > getClassOrBoundGenericClass ( ) <nl> + if ( superclass - > hasArchetype ( ) ) { <nl> + superclass = superclass - > getClassOrBoundGenericClass ( ) <nl> - > getDeclaredType ( ) ; <nl> } <nl> <nl> - appendType ( CanType ( superclassTy ) ) ; <nl> + appendType ( CanType ( superclass ) ) ; <nl> appendOperator ( " Xc " ) ; <nl> } else if ( layout . getLayoutConstraint ( ) ) { <nl> appendOperator ( " Xl " ) ; <nl> mmm a / lib / IRGen / MetadataRequest . cpp <nl> ppp b / lib / IRGen / MetadataRequest . cpp <nl> namespace { <nl> ! layout . requiresClass ( ) ) ; <nl> llvm : : Value * superclassConstraint = <nl> llvm : : ConstantPointerNull : : get ( IGF . IGM . TypeMetadataPtrTy ) ; <nl> - if ( layout . superclass ) { <nl> + if ( auto superclass = layout . explicitSuperclass ) { <nl> superclassConstraint = IGF . emitAbstractTypeMetadataRef ( <nl> - CanType ( layout . superclass ) ) ; <nl> + CanType ( superclass ) ) ; <nl> } <nl> <nl> auto call = IGF . Builder . CreateCall ( IGF . IGM . getGetExistentialMetadataFn ( ) , <nl> mmm a / lib / PrintAsObjC / PrintAsObjC . cpp <nl> ppp b / lib / PrintAsObjC / PrintAsObjC . cpp <nl> class ObjCPrinter : private DeclVisitor < ObjCPrinter > , <nl> return ; <nl> } <nl> <nl> - if ( layout . superclass ) { <nl> - auto * CD = layout . superclass - > getClassOrBoundGenericClass ( ) ; <nl> + if ( auto superclass = layout . explicitSuperclass ) { <nl> + auto * CD = superclass - > getClassOrBoundGenericClass ( ) ; <nl> assert ( CD - > isObjC ( ) ) ; <nl> if ( isMetatype ) { <nl> os < < " SWIFT_METATYPE ( " < < getNameForObjC ( CD ) < < " ) " ; <nl> } else { <nl> os < < getNameForObjC ( CD ) ; <nl> - if ( auto * BGT = layout . superclass - > getAs < BoundGenericClassType > ( ) ) <nl> + if ( auto * BGT = superclass - > getAs < BoundGenericClassType > ( ) ) <nl> printGenericArgs ( BGT ) ; <nl> } <nl> } else { <nl> class ObjCPrinter : private DeclVisitor < ObjCPrinter > , <nl> protos . push_back ( proto - > getDecl ( ) ) ; <nl> printProtocols ( protos ) ; <nl> <nl> - if ( layout . superclass & & ! isMetatype ) <nl> + if ( layout . explicitSuperclass & & ! isMetatype ) <nl> os < < " * " ; <nl> <nl> printNullability ( optionalKind ) ; <nl> class ReferencedTypeFinder : public TypeVisitor < ReferencedTypeFinder > { <nl> <nl> void visitProtocolCompositionType ( ProtocolCompositionType * composition ) { <nl> auto layout = composition - > getExistentialLayout ( ) ; <nl> - if ( layout . superclass ) <nl> - visit ( layout . superclass ) ; <nl> + if ( auto superclass = layout . explicitSuperclass ) <nl> + visit ( superclass ) ; <nl> for ( auto proto : layout . getProtocols ( ) ) <nl> visit ( proto ) ; <nl> } <nl> mmm a / lib / SIL / SILVerifier . cpp <nl> ppp b / lib / SIL / SILVerifier . cpp <nl> class SILVerifier : public SILVerifierBase < SILVerifier > { <nl> " init_existential of class existential with non - class type " ) ; <nl> } <nl> <nl> - if ( layout . superclass ) { <nl> - require ( layout . superclass - > isExactSuperclassOf ( concreteType ) , <nl> + if ( auto superclass = layout . getSuperclass ( ) ) { <nl> + require ( superclass - > isExactSuperclassOf ( concreteType ) , <nl> " init_existential of subclass existential with wrong type " ) ; <nl> } <nl> <nl> mmm a / lib / SILGen / SILGenBridging . cpp <nl> ppp b / lib / SILGen / SILGenBridging . cpp <nl> static bool shouldBridgeThroughError ( SILGenModule & SGM , CanType type , <nl> <nl> / / They ' re also convertible to Error if they have a class bound that <nl> / / conforms to Error . <nl> - if ( auto cls = layout . superclass ) { <nl> - type = cls - > getCanonicalType ( ) ; <nl> + if ( auto superclass = layout . getSuperclass ( ) ) { <nl> + type = superclass - > getCanonicalType ( ) ; <nl> <nl> / / Otherwise , they are not convertible to Error . <nl> } else { <nl> mmm a / lib / SILGen / SILGenPoly . cpp <nl> ppp b / lib / SILGen / SILGenPoly . cpp <nl> ManagedValue Transform : : transform ( ManagedValue v , <nl> instanceType = metatypeType . getInstanceType ( ) ; <nl> <nl> auto layout = instanceType . getExistentialLayout ( ) ; <nl> - if ( layout . superclass ) { <nl> + if ( layout . explicitSuperclass ) { <nl> CanType openedType = ArchetypeType : : getAnyOpened ( inputSubstType ) ; <nl> SILType loweredOpenedType = SGF . getLoweredType ( openedType ) ; <nl> <nl> mmm a / lib / Sema / CSSimplify . cpp <nl> ppp b / lib / Sema / CSSimplify . cpp <nl> ConstraintSystem : : matchExistentialTypes ( Type type1 , Type type2 , <nl> } <nl> } <nl> <nl> - if ( layout . superclass ) { <nl> + if ( layout . explicitSuperclass ) { <nl> auto subKind = std : : min ( ConstraintKind : : Subtype , kind ) ; <nl> - auto result = matchTypes ( type1 , layout . superclass , subKind , subflags , <nl> - locator ) ; <nl> + auto result = matchTypes ( type1 , layout . explicitSuperclass , subKind , <nl> + subflags , locator ) ; <nl> if ( result . isFailure ( ) ) <nl> return result ; <nl> } <nl> ConstraintSystem : : matchExistentialTypes ( Type type1 , Type type2 , <nl> for ( auto * proto : layout . getProtocols ( ) ) { <nl> auto * protoDecl = proto - > getDecl ( ) ; <nl> <nl> + if ( auto superclass = protoDecl - > getSuperclass ( ) ) { <nl> + auto subKind = std : : min ( ConstraintKind : : Subtype , kind ) ; <nl> + auto result = matchTypes ( type1 , superclass , subKind , <nl> + subflags , locator ) ; <nl> + if ( result . isFailure ( ) ) <nl> + return result ; <nl> + } <nl> + <nl> switch ( simplifyConformsToConstraint ( type1 , protoDecl , kind , locator , <nl> subflags ) ) { <nl> case SolutionKind : : Solved : <nl> mmm a / lib / Sema / TypeCheckAccess . cpp <nl> ppp b / lib / Sema / TypeCheckAccess . cpp <nl> void AccessControlChecker : : check ( Decl * D ) { <nl> return false ; <nl> Type ty = inherited . getType ( ) ; <nl> if ( ty - > is < ProtocolCompositionType > ( ) ) <nl> - if ( auto superclass = ty - > getExistentialLayout ( ) . superclass ) <nl> + if ( auto superclass = ty - > getExistentialLayout ( ) . explicitSuperclass ) <nl> ty = superclass ; <nl> return ty - > getAnyNominal ( ) = = superclassDecl ; <nl> } ) ; <nl> void UsableFromInlineChecker : : check ( Decl * D ) { <nl> return false ; <nl> Type ty = inherited . getType ( ) ; <nl> if ( ty - > is < ProtocolCompositionType > ( ) ) <nl> - if ( auto superclass = ty - > getExistentialLayout ( ) . superclass ) <nl> + if ( auto superclass = ty - > getExistentialLayout ( ) . explicitSuperclass ) <nl> ty = superclass ; <nl> return ty - > getAnyNominal ( ) = = superclassDecl ; <nl> } ) ; <nl> mmm a / lib / Sema / TypeCheckDecl . cpp <nl> ppp b / lib / Sema / TypeCheckDecl . cpp <nl> class DenseMapInfo < RawValueKey > { <nl> <nl> } / / namespace llvm <nl> <nl> - / / / Determine whether the given declaration can inherit a class . <nl> - static bool canInheritClass ( Decl * decl ) { <nl> - / / Classes can inherit from a class . <nl> - if ( isa < ClassDecl > ( decl ) ) <nl> - return true ; <nl> - <nl> - / / Generic type parameters can inherit a class . <nl> - if ( isa < GenericTypeParamDecl > ( decl ) ) <nl> - return true ; <nl> - <nl> - / / Associated types can inherit a class . <nl> - if ( isa < AssociatedTypeDecl > ( decl ) ) <nl> - return true ; <nl> - <nl> - return false ; <nl> - } <nl> - <nl> - / / Add implicit conformances to the given declaration . <nl> - static void addImplicitConformances ( <nl> - TypeChecker & tc , Decl * decl , <nl> - llvm : : SmallSetVector < ProtocolDecl * , 4 > & allProtocols ) { <nl> - if ( auto nominal = dyn_cast < NominalTypeDecl > ( decl ) ) { <nl> - SmallVector < ProtocolDecl * , 2 > protocols ; <nl> - nominal - > getImplicitProtocols ( protocols ) ; <nl> - allProtocols . insert ( protocols . begin ( ) , protocols . end ( ) ) ; <nl> - } <nl> - } <nl> - <nl> / / / Check that the declaration attributes are ok . <nl> static void validateAttributes ( TypeChecker & TC , Decl * D ) ; <nl> <nl> void TypeChecker : : checkInheritanceClause ( Decl * decl , <nl> / / Check all of the types listed in the inheritance clause . <nl> Type superclassTy ; <nl> SourceRange superclassRange ; <nl> - llvm : : SmallSetVector < ProtocolDecl * , 4 > allProtocols ; <nl> llvm : : SmallDenseMap < CanType , std : : pair < unsigned , SourceRange > > inheritedTypes ; <nl> - addImplicitConformances ( * this , decl , allProtocols ) ; <nl> for ( unsigned i = 0 , n = inheritedClause . size ( ) ; i ! = n ; + + i ) { <nl> auto & inherited = inheritedClause [ i ] ; <nl> <nl> void TypeChecker : : checkInheritanceClause ( Decl * decl , <nl> / / Protocols , generic parameters and associated types can inherit <nl> / / from subclass existentials , which are " exploded " into their <nl> / / corresponding requirements . <nl> + / / <nl> + / / Classes can only inherit from subclass existentials that do not <nl> + / / have a superclass term . <nl> if ( isa < ProtocolDecl > ( decl ) | | <nl> isa < AbstractTypeParamDecl > ( decl ) | | <nl> ( ! layout . hasExplicitAnyObject & & <nl> - ! layout . superclass ) ) { <nl> - for ( auto proto : layout . getProtocols ( ) ) { <nl> - auto * protoDecl = proto - > getDecl ( ) ; <nl> - allProtocols . insert ( protoDecl ) ; <nl> - } <nl> + ! layout . explicitSuperclass ) ) { <nl> continue ; <nl> } <nl> <nl> void TypeChecker : : checkInheritanceClause ( Decl * decl , <nl> / / do not contain an explicit AnyObject member . <nl> if ( isa < ClassDecl > ( decl ) & & <nl> ! layout . hasExplicitAnyObject ) { <nl> - for ( auto proto : layout . getProtocols ( ) ) { <nl> - auto * protoDecl = proto - > getDecl ( ) ; <nl> - allProtocols . insert ( protoDecl ) ; <nl> - } <nl> - <nl> / / Superclass inheritance is handled below . <nl> - inheritedTy = layout . superclass ; <nl> + inheritedTy = layout . explicitSuperclass ; <nl> if ( ! inheritedTy ) <nl> continue ; <nl> } <nl> void TypeChecker : : checkInheritanceClause ( Decl * decl , <nl> / / Record the raw type . <nl> superclassTy = inheritedTy ; <nl> superclassRange = inherited . getSourceRange ( ) ; <nl> - <nl> - / / Add the RawRepresentable conformance implied by the raw type . <nl> - allProtocols . insert ( getProtocol ( decl - > getLoc ( ) , <nl> - KnownProtocolKind : : RawRepresentable ) ) ; <nl> continue ; <nl> } <nl> <nl> void TypeChecker : : checkInheritanceClause ( Decl * decl , <nl> <nl> / / If the declaration we ' re looking at doesn ' t allow a superclass , <nl> / / complain . <nl> - if ( ! canInheritClass ( decl ) ) { <nl> + if ( isa < StructDecl > ( decl ) | | isa < ExtensionDecl > ( decl ) ) { <nl> diagnose ( decl - > getLoc ( ) , <nl> isa < ExtensionDecl > ( decl ) <nl> ? diag : : extension_class_inheritance <nl> void TypeChecker : : checkInheritanceClause ( Decl * decl , <nl> } <nl> <nl> / / If this is not the first entry in the inheritance clause , complain . <nl> - if ( i > 0 ) { <nl> + if ( isa < ClassDecl > ( decl ) & & i > 0 ) { <nl> auto removeRange = getRemovalRange ( i ) ; <nl> diagnose ( inherited . getSourceRange ( ) . Start , <nl> diag : : superclass_not_first , inheritedTy ) <nl> void TypeChecker : : checkInheritanceClause ( Decl * decl , <nl> <nl> / / We can ' t inherit from a non - class , non - protocol type . <nl> diagnose ( decl - > getLoc ( ) , <nl> - canInheritClass ( decl ) <nl> - ? diag : : inheritance_from_non_protocol_or_class <nl> - : diag : : inheritance_from_non_protocol , <nl> + ( isa < StructDecl > ( decl ) | | isa < ExtensionDecl > ( decl ) ) <nl> + ? diag : : inheritance_from_non_protocol <nl> + : diag : : inheritance_from_non_protocol_or_class , <nl> inheritedTy ) ; <nl> / / FIXME : Note pointing to the declaration ' inheritedTy ' references ? <nl> inherited . setInvalidType ( Context ) ; <nl> } <nl> - <nl> - if ( auto proto = dyn_cast < ProtocolDecl > ( decl ) ) { <nl> - / / Check for circular inheritance . <nl> - / / FIXME : The diagnostics here should be improved . <nl> - bool diagnosedCircularity = false ; <nl> - for ( unsigned i = 0 , n = allProtocols . size ( ) ; i ! = n ; / * in loop * / ) { <nl> - if ( allProtocols [ i ] = = proto | | allProtocols [ i ] - > inheritsFrom ( proto ) ) { <nl> - if ( ! diagnosedCircularity ) { <nl> - diagnose ( proto , diag : : circular_protocol_def , proto - > getName ( ) ) ; <nl> - diagnosedCircularity = true ; <nl> - } <nl> - <nl> - allProtocols . remove ( allProtocols [ i ] ) ; <nl> - - - n ; <nl> - continue ; <nl> - } <nl> - <nl> - + + i ; <nl> - } <nl> - } <nl> } <nl> <nl> / / / Retrieve the set of protocols the given protocol inherits . <nl> static llvm : : TinyPtrVector < ProtocolDecl * > <nl> getInheritedForCycleCheck ( TypeChecker & tc , <nl> ProtocolDecl * proto , <nl> ProtocolDecl * * scratch ) { <nl> - tc . resolveInheritedProtocols ( proto ) ; <nl> - return proto - > getInheritedProtocols ( ) ; <nl> + TinyPtrVector < ProtocolDecl * > result ; <nl> + <nl> + for ( unsigned index : indices ( proto - > getInherited ( ) ) ) { <nl> + if ( auto type = proto - > getInheritedType ( index ) ) { <nl> + if ( type - > isExistentialType ( ) ) { <nl> + auto layout = type - > getExistentialLayout ( ) ; <nl> + for ( auto protoTy : layout . getProtocols ( ) ) { <nl> + auto * protoDecl = protoTy - > getDecl ( ) ; <nl> + result . push_back ( protoDecl ) ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + <nl> + return result ; <nl> } <nl> <nl> / / / Retrieve the superclass of the given class . <nl> class DeclChecker : public DeclVisitor < DeclChecker > { <nl> checkCircularity ( TC , PD , diag : : circular_protocol_def , <nl> DescriptiveDeclKind : : Protocol , path ) ; <nl> <nl> - / / Make sure the parent protocols have been fully validated . <nl> - for ( auto inherited : PD - > getLocalProtocols ( ) ) { <nl> - TC . validateDecl ( inherited ) ; <nl> - for ( auto * member : inherited - > getMembers ( ) ) <nl> - if ( auto * requirement = dyn_cast < ValueDecl > ( member ) ) <nl> - TC . validateDecl ( requirement ) ; <nl> - } <nl> - <nl> if ( auto * SF = PD - > getParentSourceFile ( ) ) { <nl> if ( auto * tracker = SF - > getReferencedNameTracker ( ) ) { <nl> bool isNonPrivate = <nl> class DeclChecker : public DeclVisitor < DeclChecker > { <nl> canRequirementSig - > print ( llvm : : errs ( ) ) ; <nl> llvm : : errs ( ) < < " \ n " ; <nl> } <nl> + <nl> + / / Explicitly calculate this bit . <nl> + ( void ) PD - > existentialTypeSupported ( & TC ) ; <nl> } <nl> <nl> void visitVarDecl ( VarDecl * VD ) { <nl> mmm a / lib / Sema / TypeCheckNameLookup . cpp <nl> ppp b / lib / Sema / TypeCheckNameLookup . cpp <nl> namespace { <nl> / / pull out the superclass instead , and use that below . <nl> if ( foundInType - > isExistentialType ( ) ) { <nl> auto layout = foundInType - > getExistentialLayout ( ) ; <nl> - if ( layout . superclass ) { <nl> - conformingType = layout . superclass ; <nl> + if ( auto superclass = layout . getSuperclass ( ) ) { <nl> + conformingType = superclass ; <nl> } else { <nl> / / Non - subclass existential : don ' t need to look for further <nl> / / conformance or witness . <nl> mmm a / lib / Sema / TypeCheckProtocol . cpp <nl> ppp b / lib / Sema / TypeCheckProtocol . cpp <nl> Optional < ProtocolConformanceRef > TypeChecker : : containsProtocol ( <nl> <nl> / / First , if we have a superclass constraint , the class may conform <nl> / / concretely . <nl> - if ( layout . superclass ) { <nl> - if ( auto result = conformsToProtocol ( layout . superclass , Proto , <nl> + if ( layout . explicitSuperclass ) { <nl> + if ( auto result = conformsToProtocol ( layout . explicitSuperclass , Proto , <nl> DC , options ) ) { <nl> return result ; <nl> } <nl> Optional < ProtocolConformanceRef > TypeChecker : : containsProtocol ( <nl> / / Next , check if the existential contains the protocol in question . <nl> for ( auto P : layout . getProtocols ( ) ) { <nl> auto * PD = P - > getDecl ( ) ; <nl> + <nl> / / If we found the protocol we ' re looking for , return an abstract <nl> / / conformance to it . <nl> - if ( PD = = Proto | | PD - > inheritsFrom ( Proto ) ) { <nl> + if ( PD = = Proto ) <nl> return ProtocolConformanceRef ( Proto ) ; <nl> + <nl> + / / If the protocol has a superclass constraint , we might conform <nl> + / / concretely . <nl> + if ( auto superclass = PD - > getSuperclass ( ) ) { <nl> + if ( auto result = conformsToProtocol ( superclass , Proto , <nl> + DC , options ) ) { <nl> + return result ; <nl> + } <nl> } <nl> + <nl> + / / Now check refined protocols . <nl> + if ( PD - > inheritsFrom ( Proto ) ) <nl> + return ProtocolConformanceRef ( Proto ) ; <nl> } <nl> <nl> return None ; <nl> mmm a / lib / Sema / TypeCheckRequestFunctions . cpp <nl> ppp b / lib / Sema / TypeCheckRequestFunctions . cpp <nl> Type SuperclassTypeRequest : : evaluate ( Evaluator & evaluator , <nl> / / If we found an existential with a superclass bound , return it . <nl> if ( inheritedType - > isExistentialType ( ) ) { <nl> if ( auto superclassType = <nl> - inheritedType - > getExistentialLayout ( ) . superclass ) { <nl> + inheritedType - > getExistentialLayout ( ) . explicitSuperclass ) { <nl> if ( superclassType - > getClassOrBoundGenericClass ( ) ) { <nl> if ( superclassType - > hasArchetype ( ) ) <nl> return superclassType - > mapTypeOutOfContext ( ) ; <nl> mmm a / lib / Sema / TypeCheckType . cpp <nl> ppp b / lib / Sema / TypeCheckType . cpp <nl> Type TypeResolver : : resolveCompositionType ( CompositionTypeRepr * repr , <nl> <nl> if ( ty - > isExistentialType ( ) ) { <nl> auto layout = ty - > getExistentialLayout ( ) ; <nl> - if ( layout . superclass ) <nl> - if ( checkSuperclass ( tyR - > getStartLoc ( ) , layout . superclass ) ) <nl> + if ( auto superclass = layout . explicitSuperclass ) <nl> + if ( checkSuperclass ( tyR - > getStartLoc ( ) , superclass ) ) <nl> continue ; <nl> if ( ! layout . getProtocols ( ) . empty ( ) ) <nl> HasProtocol = true ; <nl> void TypeChecker : : diagnoseTypeNotRepresentableInObjC ( const DeclContext * DC , <nl> auto layout = T - > getExistentialLayout ( ) ; <nl> <nl> / / See if the superclass is not @ objc . <nl> - if ( layout . superclass & & <nl> - ! layout . superclass - > getClassOrBoundGenericClass ( ) - > isObjC ( ) ) { <nl> - diagnose ( TypeRange . Start , diag : : not_objc_class_constraint , <nl> - layout . superclass ) ; <nl> - return ; <nl> + if ( auto superclass = layout . explicitSuperclass ) { <nl> + if ( ! superclass - > getClassOrBoundGenericClass ( ) - > isObjC ( ) ) { <nl> + diagnose ( TypeRange . Start , diag : : not_objc_class_constraint , <nl> + superclass ) ; <nl> + return ; <nl> + } <nl> } <nl> <nl> / / Find a protocol that is not @ objc . <nl> mmm a / test / Compatibility / anyobject_class . swift <nl> ppp b / test / Compatibility / anyobject_class . swift <nl> <nl> / / RUN : % target - typecheck - verify - swift - swift - version 4 <nl> - / / RUN : not % target - swift - frontend - tyepcheck - swift - version 5 <nl> + / / RUN : not % target - swift - frontend - typecheck - swift - version 5 <nl> <nl> protocol P : class , AnyObject { } / / expected - warning { { redundant inheritance from ' AnyObject ' and Swift 3 ' class ' keyword } } { { 14 - 21 = } } <nl> / / expected - warning @ - 1 { { redundant constraint ' Self ' : ' AnyObject ' } } <nl> mmm a / test / Generics / superclass_constraint . swift <nl> ppp b / test / Generics / superclass_constraint . swift <nl> func superclassConformance3 < T > ( t : T ) where T : C , T : P4 , T : C2 { } <nl> / / expected - warning @ - 3 { { redundant conformance constraint ' T ' : ' P4 ' } } <nl> / / expected - note @ - 4 { { conformance constraint ' T ' : ' P4 ' implied here } } <nl> <nl> - protocol P5 : A { } / / expected - error { { non - class type ' P5 ' cannot inherit from class ' A ' } } <nl> + protocol P5 : A { } <nl> <nl> protocol P6 : A , Other { } / / expected - error { { protocol ' P6 ' cannot be a subclass of both ' Other ' and ' A ' } } <nl> - / / expected - error @ - 1 { { non - class type ' P6 ' cannot inherit from class ' A ' } } <nl> - / / expected - error @ - 2 { { non - class type ' P6 ' cannot inherit from class ' Other ' } } <nl> - / / expected - note @ - 3 { { superclass constraint ' Self ' : ' A ' written here } } <nl> + / / expected - error @ - 1 { { multiple inheritance from classes ' A ' and ' Other ' } } <nl> + / / expected - note @ - 2 { { superclass constraint ' Self ' : ' A ' written here } } <nl> <nl> func takeA ( _ : A ) { } <nl> func takeP5 < T : P5 > ( _ t : T ) { <nl> mmm a / test / IDE / print_ast_tc_decls_errors . swift <nl> ppp b / test / IDE / print_ast_tc_decls_errors . swift <nl> protocol ProtocolWithInheritance2 : FooNonExistentProtocol , BarNonExistentProtoc <nl> / / NO - TYREPR : { { ^ } } protocol ProtocolWithInheritance2 : < < error type > > , < < error type > > { { { $ } } <nl> / / TYREPR : { { ^ } } protocol ProtocolWithInheritance2 : FooNonExistentProtocol , BarNonExistentProtocol { { { $ } } <nl> <nl> - protocol ProtocolWithInheritance3 : FooClass { } / / expected - error { { non - class type ' ProtocolWithInheritance3 ' cannot inherit from class ' FooClass ' } } <nl> - / / NO - TYREPR : { { ^ } } protocol ProtocolWithInheritance3 : < < error type > > { { { $ } } <nl> + protocol ProtocolWithInheritance3 : FooClass { } <nl> + / / NO - TYREPR : { { ^ } } protocol ProtocolWithInheritance3 : FooClass { { { $ } } <nl> / / TYREPR : { { ^ } } protocol ProtocolWithInheritance3 : FooClass { { { $ } } <nl> <nl> - protocol ProtocolWithInheritance4 : FooClass , FooProtocol { } / / expected - error { { non - class type ' ProtocolWithInheritance4 ' cannot inherit from class ' FooClass ' } } <nl> - / / NO - TYREPR : { { ^ } } protocol ProtocolWithInheritance4 : < < error type > > , FooProtocol { { { $ } } <nl> + protocol ProtocolWithInheritance4 : FooClass , FooProtocol { } <nl> + / / NO - TYREPR : { { ^ } } protocol ProtocolWithInheritance4 : FooClass , FooProtocol { { { $ } } <nl> / / TYREPR : { { ^ } } protocol ProtocolWithInheritance4 : FooClass , FooProtocol { { { $ } } <nl> <nl> - protocol ProtocolWithInheritance5 : FooClass , BarClass { } / / expected - error { { non - class type ' ProtocolWithInheritance5 ' cannot inherit from class ' FooClass ' } } expected - error { { non - class type ' ProtocolWithInheritance5 ' cannot inherit from class ' BarClass ' } } expected - error { { protocol ' ProtocolWithInheritance5 ' cannot be a subclass of both ' BarClass ' and ' FooClass ' } } / / expected - note { { superclass constraint ' Self ' : ' FooClass ' written here } } <nl> + protocol ProtocolWithInheritance5 : FooClass , BarClass { } / / expected - error { { multiple inheritance from classes ' FooClass ' and ' BarClass ' } } expected - error { { protocol ' ProtocolWithInheritance5 ' cannot be a subclass of both ' BarClass ' and ' FooClass ' } } / / expected - note { { superclass constraint ' Self ' : ' FooClass ' written here } } <nl> / / NO - TYREPR : { { ^ } } protocol ProtocolWithInheritance5 : < < error type > > , < < error type > > { { { $ } } <nl> / / TYREPR : { { ^ } } protocol ProtocolWithInheritance5 : FooClass , BarClass { { { $ } } <nl> <nl> mmm a / test / decl / inherit / inherit . swift <nl> ppp b / test / decl / inherit / inherit . swift <nl> class D4 : P & P1 , A { } / / expected - error { { superclass ' A ' must appear first in <nl> struct S : A { } / / expected - error { { non - class type ' S ' cannot inherit from class ' A ' } } <nl> <nl> / / Protocol inheriting a class <nl> - protocol Q : A { } / / expected - error { { non - class type ' Q ' cannot inherit from class ' A ' } } <nl> + protocol Q : A { } <nl> <nl> / / Extension inheriting a class <nl> extension C : A { } / / expected - error { { extension of type ' C ' cannot inherit from class ' A ' } } <nl> struct S2 : struct { } / / expected - error { { expected type } } <nl> <nl> / / Protocol composition in inheritance clauses <nl> struct S3 : P , P & Q { } / / expected - error { { redundant conformance of ' S3 ' to protocol ' P ' } } <nl> - / / expected - error @ - 1 { { ' Q ' requires that ' S3 ' inherit from ' A ' } } <nl> - / / expected - note @ - 2 { { requirement specified as ' Self ' : ' A ' [ with Self = S3 ] } } <nl> - / / expected - note @ - 3 { { ' S3 ' declares conformance to protocol ' P ' here } } <nl> + / / expected - error @ - 1 { { non - class type ' S3 ' cannot conform to class protocol ' Q ' } } <nl> + / / expected - note @ - 2 { { ' S3 ' declares conformance to protocol ' P ' here } } <nl> struct S4 : P , P { } / / expected - error { { duplicate inheritance from ' P ' } } <nl> struct S6 : P & { } / / expected - error { { expected identifier for type name } } <nl> struct S7 : protocol < P , Q > { } / / expected - error { { ' protocol < . . . > ' composition syntax has been removed ; join the protocols using ' & ' } } <nl> - / / expected - error @ - 1 { { ' Q ' requires that ' S7 ' inherit from ' A ' } } <nl> - / / expected - note @ - 2 { { requirement specified as ' Self ' : ' A ' [ with Self = S7 ] } } <nl> + / / expected - error @ - 1 { { non - class type ' S7 ' cannot conform to class protocol ' Q ' } } <nl> <nl> class GenericBase < T > { } <nl> <nl> mmm a / test / decl / nested / protocol . swift <nl> ppp b / test / decl / nested / protocol . swift <nl> enum OuterEnum { <nl> <nl> class OuterClass { <nl> protocol InnerProtocol : OuterClass { } <nl> - / / expected - error @ - 1 { { non - class type ' InnerProtocol ' cannot inherit from class ' OuterClass ' } } <nl> - / / expected - error @ - 2 { { protocol ' InnerProtocol ' cannot be nested inside another declaration } } <nl> + / / expected - error @ - 1 { { protocol ' InnerProtocol ' cannot be nested inside another declaration } } <nl> } <nl> <nl> class OtherGenericClass < T > { <nl> protocol InnerProtocol : OtherGenericClass { } <nl> - / / expected - error @ - 1 { { non - class type ' InnerProtocol ' cannot inherit from class ' OtherGenericClass < T > ' } } <nl> - / / expected - error @ - 2 { { protocol ' InnerProtocol ' cannot be nested inside another declaration } } <nl> + / / expected - error @ - 1 { { protocol ' InnerProtocol ' cannot be nested inside another declaration } } <nl> } <nl> mmm a / test / decl / protocol / protocols . swift <nl> ppp b / test / decl / protocol / protocols . swift <nl> func test1 ( ) { <nl> } <nl> <nl> protocol Bogus : Int { } <nl> - / / expected - error @ - 1 { { inheritance from non - protocol type ' Int ' } } <nl> + / / expected - error @ - 1 { { inheritance from non - protocol , non - class type ' Int ' } } <nl> / / expected - error @ - 2 { { type ' Self ' constrained to non - protocol , non - class type ' Int ' } } <nl> <nl> / / Explicit conformance checks ( successful ) . <nl> struct DoesNotConform : Up { <nl> <nl> / / Circular protocols <nl> <nl> - protocol CircleMiddle : CircleStart { func circle_middle ( ) } / / expected - error 2 { { protocol ' CircleMiddle ' refines itself } } <nl> + protocol CircleMiddle : CircleStart { func circle_middle ( ) } / / expected - error { { protocol ' CircleMiddle ' refines itself } } <nl> protocol CircleStart : CircleEnd { func circle_start ( ) } <nl> / / expected - note @ - 1 { { protocol ' CircleStart ' declared here } } <nl> - / / expected - error @ - 2 { { protocol ' CircleStart ' refines itself } } <nl> protocol CircleEnd : CircleMiddle { func circle_end ( ) } / / expected - note { { protocol ' CircleEnd ' declared here } } <nl> - / / expected - error @ - 1 { { protocol ' CircleEnd ' refines itself } } <nl> <nl> protocol CircleEntry : CircleTrivial { } <nl> - protocol CircleTrivial : CircleTrivial { } / / expected - error 2 { { protocol ' CircleTrivial ' refines itself } } <nl> + protocol CircleTrivial : CircleTrivial { } / / expected - error { { protocol ' CircleTrivial ' refines itself } } <nl> <nl> struct Circle { <nl> func circle_start ( ) { } <nl> mmm a / test / type / subclass_composition . swift <nl> ppp b / test / type / subclass_composition . swift <nl> func conformsTo < T1 : P2 , T2 : Base < Int > & P2 > ( <nl> <nl> protocol ProtoConstraintsSelfToClass where Self : Base < Int > { } <nl> <nl> - protocol ProtoRefinesClass : Base < Int > { } / / FIXME expected - error { { } } <nl> + protocol ProtoRefinesClass : Base < Int > { } <nl> protocol ProtoRefinesClassAndProtocolAlias : BaseIntAndP2 { } <nl> protocol ProtoRefinesClassAndProtocolDirect : Base < Int > & P2 { } <nl> - protocol ProtoRefinesClassAndProtocolExpanded : Base < Int > , P2 { } / / FIXME expected - error { { } } <nl> + protocol ProtoRefinesClassAndProtocolExpanded : Base < Int > , P2 { } <nl> <nl> class ClassConformsToClassProtocolBad1 : ProtoConstraintsSelfToClass { } <nl> / / expected - error @ - 1 { { ' ProtoConstraintsSelfToClass ' requires that ' ClassConformsToClassProtocolBad1 ' inherit from ' Base < Int > ' } } <nl> | Merge pull request from slavapestov / protocol - superclass - part - 2 | apple/swift | 0815449c1ada5edea09b08c1dd601868c1dcbf30 | 2018-07-03T21:05:36Z |
mmm a / test / common / upstream / health_check_corpus / grpc_Success <nl> ppp b / test / common / upstream / health_check_corpus / grpc_Success <nl> actions { <nl> } <nl> } <nl> } <nl> + upstream_cx_success : true <nl> mmm a / test / common / upstream / health_check_corpus / http_Success <nl> ppp b / test / common / upstream / health_check_corpus / http_Success <nl> actions { <nl> } <nl> } <nl> } <nl> + upstream_cx_success : true <nl> new file mode 100644 <nl> index 00000000000 . . f8c98fb6a7f <nl> mmm / dev / null <nl> ppp b / test / common / upstream / health_check_corpus / http_status - over - 600 <nl> <nl> + health_check_config { <nl> + timeout { <nl> + seconds : 1 <nl> + } <nl> + interval { <nl> + seconds : 1 <nl> + } <nl> + no_traffic_interval { <nl> + seconds : 1 <nl> + } <nl> + interval_jitter { <nl> + seconds : 1 <nl> + } <nl> + unhealthy_threshold { <nl> + value : 2 <nl> + } <nl> + healthy_threshold : { <nl> + value : 2 <nl> + } <nl> + http_health_check { <nl> + path : " / healthcheck " <nl> + service_name_matcher { <nl> + prefix : " locations " <nl> + } <nl> + expected_statuses { <nl> + start : 200 <nl> + end : 700 <nl> + } <nl> + } <nl> + } <nl> + actions { <nl> + respond { <nl> + http_respond { <nl> + headers { <nl> + headers { <nl> + key : " : status " <nl> + value : " 200 " <nl> + } <nl> + } <nl> + status : 200 <nl> + } <nl> + tcp_respond { <nl> + <nl> + } <nl> + grpc_respond { <nl> + grpc_respond_headers { <nl> + <nl> + } <nl> + } <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 441d9433ff5 <nl> mmm / dev / null <nl> ppp b / test / common / upstream / health_check_corpus / http_status - under - 100 <nl> <nl> + health_check_config { <nl> + timeout { <nl> + seconds : 1 <nl> + } <nl> + interval { <nl> + seconds : 1 <nl> + } <nl> + no_traffic_interval { <nl> + seconds : 1 <nl> + } <nl> + interval_jitter { <nl> + seconds : 1 <nl> + } <nl> + unhealthy_threshold { <nl> + value : 2 <nl> + } <nl> + healthy_threshold : { <nl> + value : 2 <nl> + } <nl> + http_health_check { <nl> + path : " / healthcheck " <nl> + service_name_matcher { <nl> + prefix : " locations " <nl> + } <nl> + expected_statuses { <nl> + start : 50 <nl> + end : 500 <nl> + } <nl> + } <nl> + } <nl> + actions { <nl> + respond { <nl> + http_respond { <nl> + headers { <nl> + headers { <nl> + key : " : status " <nl> + value : " 200 " <nl> + } <nl> + } <nl> + status : 200 <nl> + } <nl> + tcp_respond { <nl> + <nl> + } <nl> + grpc_respond { <nl> + grpc_respond_headers { <nl> + <nl> + } <nl> + } <nl> + } <nl> + } <nl> mmm a / test / common / upstream / health_check_corpus / tcp_Success <nl> ppp b / test / common / upstream / health_check_corpus / tcp_Success <nl> actions { <nl> } <nl> } <nl> } <nl> + upstream_cx_success : true <nl> mmm a / test / common / upstream / health_check_fuzz . cc <nl> ppp b / test / common / upstream / health_check_fuzz . cc <nl> void HttpHealthCheckFuzz : : initialize ( test : : common : : upstream : : HealthCheckTestCase <nl> . WillByDefault ( testing : : Return ( input . http_verify_cluster ( ) ) ) ; <nl> cluster_ - > prioritySet ( ) . getMockHostSet ( 0 ) - > hosts_ = { <nl> makeTestHost ( cluster_ - > info_ , " tcp : / / 127 . 0 . 0 . 1 : 80 " ) } ; <nl> + if ( input . upstream_cx_success ( ) ) { <nl> + cluster_ - > info_ - > stats ( ) . upstream_cx_total_ . inc ( ) ; <nl> + } <nl> expectSessionCreate ( ) ; <nl> expectStreamCreate ( 0 ) ; <nl> / / This sets up the possibility of testing hosts that never become healthy <nl> void TcpHealthCheckFuzz : : initialize ( test : : common : : upstream : : HealthCheckTestCase <nl> allocTcpHealthCheckerFromProto ( input . health_check_config ( ) ) ; <nl> cluster_ - > prioritySet ( ) . getMockHostSet ( 0 ) - > hosts_ = { <nl> makeTestHost ( cluster_ - > info_ , " tcp : / / 127 . 0 . 0 . 1 : 80 " ) } ; <nl> + if ( input . upstream_cx_success ( ) ) { <nl> + cluster_ - > info_ - > stats ( ) . upstream_cx_total_ . inc ( ) ; <nl> + } <nl> expectSessionCreate ( ) ; <nl> expectClientCreate ( ) ; <nl> health_checker_ - > start ( ) ; <nl> void GrpcHealthCheckFuzz : : initialize ( test : : common : : upstream : : HealthCheckTestCase <nl> allocGrpcHealthCheckerFromProto ( input . health_check_config ( ) ) ; <nl> cluster_ - > prioritySet ( ) . getMockHostSet ( 0 ) - > hosts_ = { <nl> makeTestHost ( cluster_ - > info_ , " tcp : / / 127 . 0 . 0 . 1 : 80 " ) } ; <nl> + if ( input . upstream_cx_success ( ) ) { <nl> + cluster_ - > info_ - > stats ( ) . upstream_cx_total_ . inc ( ) ; <nl> + } <nl> expectSessionCreate ( ) ; <nl> ON_CALL ( dispatcher_ , createClientConnection_ ( _ , _ , _ , _ ) ) <nl> . WillByDefault ( testing : : InvokeWithoutArgs ( <nl> mmm a / test / common / upstream / health_check_fuzz . proto <nl> ppp b / test / common / upstream / health_check_fuzz . proto <nl> message HealthCheckTestCase { <nl> repeated Action actions = 2 ; <nl> bool http_verify_cluster = 3 ; / / Determines if verify cluster setting is on <nl> bool start_failed = 4 ; <nl> + bool upstream_cx_success = 5 ; <nl> } <nl> | [ fuzz ] Increased fuzz coverage for health check fuzz ( ) | envoyproxy/envoy | 8def3cbf05fea33640cad08f9957f66d4bc772a3 | 2020-11-10T21:48:56Z |
mmm a / configure . in <nl> ppp b / configure . in <nl> if test " $ use_optimizations " = " yes " ; then <nl> CXXFLAGS = " $ CXXFLAGS " <nl> CFLAGS = " $ CFLAGS " <nl> else <nl> - CXXFLAGS = " $ CXXFLAGS - O2 " <nl> - CFLAGS = " $ CFLAGS - O2 " <nl> + CXXFLAGS = " - O2 $ CXXFLAGS " <nl> + CFLAGS = " - O2 $ CFLAGS " <nl> fi <nl> else <nl> final_message = " $ final_message \ n Optimization : \ tNo " <nl> | build : give env optim flags precedence | xbmc/xbmc | f8285a110b170da3ce98fd7772640c66b830ea70 | 2012-10-15T21:58:50Z |
mmm a / test / cctest / test - parsing . cc <nl> ppp b / test / cctest / test - parsing . cc <nl> TEST ( ScopePositions ) { <nl> i : : Handle < i : : String > FormatMessage ( i : : ScriptDataImpl * data ) { <nl> i : : Isolate * isolate = i : : Isolate : : Current ( ) ; <nl> i : : Factory * factory = isolate - > factory ( ) ; <nl> + const char * message = data - > BuildMessage ( ) ; <nl> i : : Handle < i : : String > format = v8 : : Utils : : OpenHandle ( <nl> - * v8 : : String : : New ( data - > BuildMessage ( ) ) ) ; <nl> + * v8 : : String : : New ( message ) ) ; <nl> i : : Vector < const char * > args = data - > BuildArgs ( ) ; <nl> i : : Handle < i : : JSArray > args_array = factory - > NewJSArray ( args . length ( ) ) ; <nl> for ( int i = 0 ; i < args . length ( ) ; i + + ) { <nl> i : : Handle < i : : String > FormatMessage ( i : : ScriptDataImpl * data ) { <nl> i : : Execution : : Call ( format_fun , builtins , 2 , arg_handles , & has_exception ) ; <nl> CHECK ( ! has_exception ) ; <nl> CHECK ( result - > IsString ( ) ) ; <nl> + for ( int i = 0 ; i < args . length ( ) ; i + + ) { <nl> + i : : DeleteArray ( args [ i ] ) ; <nl> + } <nl> + i : : DeleteArray ( args . start ( ) ) ; <nl> + i : : DeleteArray ( message ) ; <nl> return i : : Handle < i : : String > : : cast ( result ) ; <nl> } <nl> <nl> TEST ( ParserSync ) { <nl> + kSuffixLen + i : : StrLength ( " label : for ( ; ; ) { } " ) ; <nl> <nl> / / Plug the source code pieces together . <nl> - i : : Vector < char > program = i : : Vector < char > : : New ( kProgramSize + 1 ) ; <nl> + i : : ScopedVector < char > program ( kProgramSize + 1 ) ; <nl> int length = i : : OS : : SNPrintF ( program , <nl> " label : for ( ; ; ) { % s % s % s % s } " , <nl> context_data [ i ] [ 0 ] , <nl> | Plug some memory leaks in parser tests . | v8/v8 | 6d0394ac18b420ca18ca557c94e98a71d4be689b | 2013-07-04T15:57:43Z |
mmm a / xbmc / windowing / wayland / WinSystemWayland . cpp <nl> ppp b / xbmc / windowing / wayland / WinSystemWayland . cpp <nl> bool CWinSystemWayland : : CreateNewWindow ( const std : : string & name , <nl> / / Apply window decorations if necessary <nl> m_windowDecorator - > SetState ( m_configuredSize , m_scale , m_shellSurfaceState ) ; <nl> <nl> + / / Set initial opaque region and window geometry <nl> + ApplyOpaqueRegion ( ) ; <nl> + ApplyWindowGeometry ( ) ; <nl> + <nl> / / Update resolution with real size as it could have changed due to configure ( ) <nl> UpdateDesktopResolution ( res , 0 , m_bufferSize . Width ( ) , m_bufferSize . Height ( ) , res . fRefreshRate ) ; <nl> res . bFullScreen = fullScreen ; <nl> void CWinSystemWayland : : ApplySizeUpdate ( SizeUpdateInformation update ) <nl> } <nl> if ( update . surfaceSizeChanged ) <nl> { <nl> - / / Mark everything opaque so the compositor can render it faster <nl> - / / Do it here so size always matches the configured egl surface <nl> - CLog : : LogF ( LOGDEBUG , " Setting opaque region size % dx % d " , m_surfaceSize . Width ( ) , m_surfaceSize . Height ( ) ) ; <nl> - wayland : : region_t opaqueRegion { m_compositor . create_region ( ) } ; <nl> - opaqueRegion . add ( 0 , 0 , m_surfaceSize . Width ( ) , m_surfaceSize . Height ( ) ) ; <nl> - m_surface . set_opaque_region ( opaqueRegion ) ; <nl> + / / Update opaque region here so size always matches the configured egl surface <nl> + ApplyOpaqueRegion ( ) ; <nl> } <nl> if ( update . configuredSizeChanged ) <nl> { <nl> / / Update window decoration state <nl> m_windowDecorator - > SetState ( m_configuredSize , m_scale , m_shellSurfaceState ) ; <nl> - m_shellSurface - > SetWindowGeometry ( m_windowDecorator - > GetWindowGeometry ( ) ) ; <nl> + ApplyWindowGeometry ( ) ; <nl> } <nl> / / Set always , because of initialization order GL context has to keep track of <nl> / / whether the size changed . If we skip based on update . bufferSizeChanged here , <nl> void CWinSystemWayland : : ApplySizeUpdate ( SizeUpdateInformation update ) <nl> SetContextSize ( m_bufferSize ) ; <nl> } <nl> <nl> + void CWinSystemWayland : : ApplyOpaqueRegion ( ) <nl> + { <nl> + / / Mark everything opaque so the compositor can render it faster <nl> + CLog : : LogF ( LOGDEBUG , " Setting opaque region size % dx % d " , m_surfaceSize . Width ( ) , m_surfaceSize . Height ( ) ) ; <nl> + wayland : : region_t opaqueRegion { m_compositor . create_region ( ) } ; <nl> + opaqueRegion . add ( 0 , 0 , m_surfaceSize . Width ( ) , m_surfaceSize . Height ( ) ) ; <nl> + m_surface . set_opaque_region ( opaqueRegion ) ; <nl> + } <nl> + <nl> + void CWinSystemWayland : : ApplyWindowGeometry ( ) <nl> + { <nl> + m_shellSurface - > SetWindowGeometry ( m_windowDecorator - > GetWindowGeometry ( ) ) ; <nl> + } <nl> + <nl> void CWinSystemWayland : : ProcessMessages ( ) <nl> { <nl> if ( m_waitingForApply ) <nl> mmm a / xbmc / windowing / wayland / WinSystemWayland . h <nl> ppp b / xbmc / windowing / wayland / WinSystemWayland . h <nl> class CWinSystemWayland : public CWinSystemBase , IInputHandler , IWindowDecoratio <nl> void OnOutputDone ( std : : uint32_t name ) ; <nl> void UpdateBufferScale ( ) ; <nl> void ApplyBufferScale ( ) ; <nl> + void ApplyOpaqueRegion ( ) ; <nl> + void ApplyWindowGeometry ( ) ; <nl> void UpdateTouchDpi ( ) ; <nl> void ApplyShellSurfaceState ( IShellSurface : : StateBitset state ) ; <nl> <nl> | [ wayland ] Always set opaque region and geometry on startup | xbmc/xbmc | 709e9d1f32c0c008ffc6cfcb9596845b3d86fc3a | 2018-03-05T12:33:02Z |
mmm a / arangod / Cluster / DBServerAgencySync . h <nl> ppp b / arangod / Cluster / DBServerAgencySync . h <nl> <nl> # include " Basics / Exceptions . h " <nl> # include " Basics / Mutex . h " <nl> <nl> - / / struct TRI_server_t ; <nl> - <nl> namespace arangodb { <nl> class HeartbeatThread ; <nl> <nl> class DBServerAgencySync : public arangodb : : rest : : Job { <nl> <nl> HeartbeatThread * _heartbeat ; <nl> <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief server <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - / / TRI_server_t * _server ; <nl> - <nl> protected : <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief shutdown in progress <nl> mmm a / arangod / RestServer / VocbaseContext . h <nl> ppp b / arangod / RestServer / VocbaseContext . h <nl> <nl> # include " Rest / GeneralRequest . h " <nl> # include " Rest / GeneralResponse . h " <nl> <nl> - struct TRI_server_t ; <nl> struct TRI_vocbase_t ; <nl> <nl> namespace arangodb { <nl> | refactoring | arangodb/arangodb | 5993c1b094c5dbee8bc1727e3e1f12cce3d6ad2c | 2016-07-22T13:46:45Z |
mmm a / LRUCache . h <nl> ppp b / LRUCache . h <nl> <nl> # include < deque > <nl> # include < memory > <nl> # include < unordered_map > <nl> + # include " watchman_config . h " <nl> <nl> namespace watchman { <nl> <nl> class LRUCache { <nl> LRUCache ( size_t maxItems , std : : chrono : : milliseconds errorTTL ) <nl> : maxItems_ ( maxItems ) , errorTTL_ ( errorTTL ) { } <nl> <nl> + LRUCache ( <nl> + Configuration & & cfg , <nl> + const char * configPrefix , <nl> + size_t defaultMaxItems , <nl> + size_t errorTTLSeconds ) <nl> + : maxItems_ ( cfg . getInt ( <nl> + folly : : to < std : : string > ( configPrefix , " _cache_size " ) . c_str ( ) , <nl> + defaultMaxItems ) ) , <nl> + errorTTL_ ( std : : chrono : : seconds ( cfg . getInt ( <nl> + folly : : to < std : : string > ( configPrefix , " _cache_error_ttl_seconds " ) <nl> + . c_str ( ) , <nl> + errorTTLSeconds ) ) ) { } <nl> + <nl> / / No moving or copying <nl> LRUCache ( const LRUCache & ) = delete ; <nl> LRUCache & operator = ( const LRUCache & ) = delete ; <nl> mmm a / watchman_config . h <nl> ppp b / watchman_config . h <nl> <nl> / * Copyright 2012 - present Facebook , Inc . <nl> * Licensed under the Apache License , Version 2 . 0 * / <nl> + # include " thirdparty / jansson / jansson . h " <nl> # pragma once <nl> <nl> class w_string ; <nl> | watchman : add helper LRUCache constructor | facebook/watchman | a944041350c3eacbf54843e61155d217f74fbcf3 | 2020-08-28T19:30:56Z |
mmm a / tensorflow / python / ops / rnn_cell_impl . py <nl> ppp b / tensorflow / python / ops / rnn_cell_impl . py <nl> def _linear ( args , output_size , bias , bias_start = 0 . 0 , scope = None ) : <nl> raise ValueError ( " linear is expecting 2D arguments : % s " % shapes ) <nl> if shape [ 1 ] . value is None : <nl> raise ValueError ( " linear expects shape [ 1 ] to be provided for shape % s , " <nl> - " but saw % d " % ( shape , shape [ 1 ] ) ) <nl> + " but saw % s " % ( shape , shape [ 1 ] ) ) <nl> else : <nl> total_arg_size + = shape [ 1 ] . value <nl> <nl> | Correctly format a Dimension | tensorflow/tensorflow | c2bd4034aeb76ca8113083b1d96a2ffc7a840e11 | 2016-12-07T11:25:14Z |
mmm a / src / webGLClient . js <nl> ppp b / src / webGLClient . js <nl> function assert ( x ) { <nl> function WebGLClient ( ) { <nl> var objects = { } ; <nl> <nl> + var ctx = null ; <nl> + var buffer = null ; <nl> + var i = 0 ; <nl> + <nl> + function func0 ( name ) { <nl> + ctx [ name ] ( ) ; <nl> + } <nl> + function func1 ( name ) { <nl> + ctx [ name ] ( buffer [ i ] ) ; <nl> + i + + ; <nl> + } <nl> + function func2 ( name ) { <nl> + ctx [ name ] ( buffer [ i ] , buffer [ i + 1 ] ) ; <nl> + i + = 2 ; <nl> + } <nl> + function func3 ( name ) { <nl> + ctx [ name ] ( buffer [ i ] , buffer [ i + 1 ] , buffer [ i + 2 ] ) ; <nl> + i + = 3 ; <nl> + } <nl> + function func4 ( name ) { <nl> + ctx [ name ] ( buffer [ i ] , buffer [ i + 1 ] , buffer [ i + 2 ] , buffer [ i + 3 ] ) ; <nl> + i + = 4 ; <nl> + } <nl> + function func5 ( name ) { <nl> + ctx [ name ] ( buffer [ i ] , buffer [ i + 1 ] , buffer [ i + 2 ] , buffer [ i + 3 ] , buffer [ i + 4 ] ) ; <nl> + i + = 5 ; <nl> + } <nl> + function func6 ( name ) { <nl> + ctx [ name ] ( buffer [ i ] , buffer [ i + 1 ] , buffer [ i + 2 ] , buffer [ i + 3 ] , buffer [ i + 4 ] , buffer [ i + 5 ] ) ; <nl> + i + = 6 ; <nl> + } <nl> + function func7 ( name ) { <nl> + ctx [ name ] ( buffer [ i ] , buffer [ i + 1 ] , buffer [ i + 2 ] , buffer [ i + 3 ] , buffer [ i + 4 ] , buffer [ i + 5 ] , buffer [ i + 6 ] ) ; <nl> + i + = 7 ; <nl> + } <nl> + function func9 ( name ) { <nl> + ctx [ name ] ( buffer [ i ] , buffer [ i + 1 ] , buffer [ i + 2 ] , buffer [ i + 3 ] , buffer [ i + 4 ] , buffer [ i + 5 ] , buffer [ i + 6 ] , buffer [ i + 7 ] , buffer [ i + 8 ] ) ; <nl> + i + = 9 ; <nl> + } <nl> + <nl> + / / constructors , last argument is the id to save as <nl> + function funcC0 ( name ) { <nl> + var object = ctx [ name ] ( ) ; <nl> + var id = buffer [ i + + ] ; <nl> + objects [ id ] = object ; <nl> + } <nl> + function funcC1 ( name ) { <nl> + var object = ctx [ name ] ( buffer [ i + + ] ) ; <nl> + var id = buffer [ i + + ] ; <nl> + objects [ id ] = object ; <nl> + } <nl> + function funcC2 ( name ) { <nl> + var object = ctx [ name ] ( buffer [ i + + ] , buffer [ i + + ] ) ; <nl> + var id = buffer [ i + + ] ; <nl> + objects [ id ] = object ; <nl> + } <nl> + <nl> var calls = { <nl> - 0 : { name : ' NULL ' , args : 0 } , <nl> - 1 : { name : ' getExtension ' , args : 1 } , <nl> - 2 : { name : ' enable ' , args : 1 } , <nl> - 3 : { name : ' disable ' , args : 1 } , <nl> - 4 : { name : ' clear ' , args : 1 } , <nl> - 5 : { name : ' clearColor ' , args : 4 } , <nl> - 6 : { name : ' createShader ' , args : - 2 } , <nl> - 7 : { name : ' deleteShader ' , args : 1 } , <nl> - 8 : { name : ' shaderSource ' , args : 2 } , <nl> - 9 : { name : ' compileShader ' , args : 1 } , <nl> - 10 : { name : ' createProgram ' , args : - 1 } , <nl> - 11 : { name : ' deleteProgram ' , args : 1 } , <nl> - 12 : { name : ' attachShader ' , args : 2 } , <nl> - 13 : { name : ' bindAttribLocation ' , args : 3 } , <nl> - 14 : { name : ' linkProgram ' , args : 1 } , <nl> - 15 : { name : ' getProgramParameter ' , args : 2 } , <nl> - 16 : { name : ' getUniformLocation ' , args : - 3 } , <nl> - 17 : { name : ' useProgram ' , args : 1 } , <nl> - 18 : { name : ' uniform1i ' , args : 2 } , <nl> - 19 : { name : ' uniform1f ' , args : 2 } , <nl> - 20 : { name : ' uniform3fv ' , args : 2 } , <nl> - 21 : { name : ' uniform4fv ' , args : 2 } , <nl> - 22 : { name : ' uniformMatrix4fv ' , args : 3 } , <nl> - 23 : { name : ' vertexAttrib4fv ' , args : 2 } , <nl> - 24 : { name : ' createBuffer ' , args : - 1 } , <nl> - 25 : { name : ' deleteBuffer ' , args : 1 } , <nl> - 26 : { name : ' bindBuffer ' , args : 2 } , <nl> - 27 : { name : ' bufferData ' , args : 3 } , <nl> - 28 : { name : ' bufferSubData ' , args : 3 } , <nl> - 29 : { name : ' viewport ' , args : 4 } , <nl> - 30 : { name : ' vertexAttribPointer ' , args : 6 } , <nl> - 31 : { name : ' enableVertexAttribArray ' , args : 1 } , <nl> - 32 : { name : ' disableVertexAttribArray ' , args : 1 } , <nl> - 33 : { name : ' drawArrays ' , args : 3 } , <nl> - 34 : { name : ' drawElements ' , args : 4 } , <nl> - 35 : { name : ' getError ' , args : 0 } , <nl> - 36 : { name : ' createTexture ' , args : - 1 } , <nl> - 37 : { name : ' deleteTexture ' , args : 1 } , <nl> - 38 : { name : ' bindTexture ' , args : 2 } , <nl> - 39 : { name : ' texParameteri ' , args : 3 } , <nl> - 40 : { name : ' texImage2D ' , args : 9 } , <nl> - 41 : { name : ' compressedTexImage2D ' , args : 7 } , <nl> - 42 : { name : ' activeTexture ' , args : 1 } , <nl> - 43 : { name : ' getShaderParameter ' , args : 2 } , <nl> - 44 : { name : ' clearDepth ' , args : 1 } , <nl> - 45 : { name : ' depthFunc ' , args : 1 } , <nl> - 46 : { name : ' frontFace ' , args : 1 } , <nl> - 47 : { name : ' cullFace ' , args : 1 } , <nl> - 48 : { name : ' pixelStorei ' , args : 2 } , <nl> - 49 : { name : ' depthMask ' , args : 1 } , <nl> - 50 : { name : ' depthRange ' , args : 2 } , <nl> - 51 : { name : ' blendFunc ' , args : 2 } , <nl> - 52 : { name : ' scissor ' , args : 4 } , <nl> - 53 : { name : ' colorMask ' , args : 4 } , <nl> - 54 : { name : ' lineWidth ' , args : 1 } , <nl> - 55 : { name : ' createFramebuffer ' , args : - 1 } , <nl> - 56 : { name : ' deleteFramebuffer ' , args : 1 } , <nl> - 57 : { name : ' bindFramebuffer ' , args : 2 } , <nl> - 58 : { name : ' framebufferTexture2D ' , args : 5 } , <nl> - 59 : { name : ' createRenderbuffer ' , args : - 1 } , <nl> - 60 : { name : ' deleteRenderbuffer ' , args : 1 } , <nl> - 61 : { name : ' bindRenderbuffer ' , args : 2 } , <nl> - 62 : { name : ' renderbufferStorage ' , args : 4 } , <nl> - 63 : { name : ' framebufferRenderbuffer ' , args : 4 } , <nl> - 64 : { name : ' debugPrint ' , args : 1 } , <nl> + 0 : { name : ' NULL ' , func : func0 } , <nl> + 1 : { name : ' getExtension ' , func : func1 } , <nl> + 2 : { name : ' enable ' , func : func1 } , <nl> + 3 : { name : ' disable ' , func : func1 } , <nl> + 4 : { name : ' clear ' , func : func1 } , <nl> + 5 : { name : ' clearColor ' , func : func4 } , <nl> + 6 : { name : ' createShader ' , func : funcC1 } , <nl> + 7 : { name : ' deleteShader ' , func : func1 } , <nl> + 8 : { name : ' shaderSource ' , func : func2 } , <nl> + 9 : { name : ' compileShader ' , func : func1 } , <nl> + 10 : { name : ' createProgram ' , func : funcC0 } , <nl> + 11 : { name : ' deleteProgram ' , func : func1 } , <nl> + 12 : { name : ' attachShader ' , func : func2 } , <nl> + 13 : { name : ' bindAttribLocation ' , func : func3 } , <nl> + 14 : { name : ' linkProgram ' , func : func1 } , <nl> + 15 : { name : ' getProgramParameter ' , func : function ( ) { assert ( ctx . getProgramParameter ( buffer [ i + + ] , buffer [ i + + ] ) , ' we cannot handle errors , we are async proxied WebGL ' ) ; } } , <nl> + 16 : { name : ' getUniformLocation ' , func : funcC2 } , <nl> + 17 : { name : ' useProgram ' , func : func1 } , <nl> + 18 : { name : ' uniform1i ' , func : func2 } , <nl> + 19 : { name : ' uniform1f ' , func : func2 } , <nl> + 20 : { name : ' uniform3fv ' , func : func2 } , <nl> + 21 : { name : ' uniform4fv ' , func : func2 } , <nl> + 22 : { name : ' uniformMatrix4fv ' , func : func3 } , <nl> + 23 : { name : ' vertexAttrib4fv ' , func : func2 } , <nl> + 24 : { name : ' createBuffer ' , func : funcC0 } , <nl> + 25 : { name : ' deleteBuffer ' , func : func1 } , <nl> + 26 : { name : ' bindBuffer ' , func : func2 } , <nl> + 27 : { name : ' bufferData ' , func : func3 } , <nl> + 28 : { name : ' bufferSubData ' , func : func3 } , <nl> + 29 : { name : ' viewport ' , func : func4 } , <nl> + 30 : { name : ' vertexAttribPointer ' , func : func6 } , <nl> + 31 : { name : ' enableVertexAttribArray ' , func : func1 } , <nl> + 32 : { name : ' disableVertexAttribArray ' , func : func1 } , <nl> + 33 : { name : ' drawArrays ' , func : func3 } , <nl> + 34 : { name : ' drawElements ' , func : func4 } , <nl> + 35 : { name : ' getError ' , func : function ( ) { assert ( ctx . getError ( ) = = = ctx . NO_ERROR , ' we cannot handle errors , we are async proxied WebGL ' ) } } , <nl> + 36 : { name : ' createTexture ' , func : funcC0 } , <nl> + 37 : { name : ' deleteTexture ' , func : func1 } , <nl> + 38 : { name : ' bindTexture ' , func : func2 } , <nl> + 39 : { name : ' texParameteri ' , func : func3 } , <nl> + 40 : { name : ' texImage2D ' , func : func9 } , <nl> + 41 : { name : ' compressedTexImage2D ' , func : func7 } , <nl> + 42 : { name : ' activeTexture ' , func : func1 } , <nl> + 43 : { name : ' getShaderParameter ' , func : function ( ) { assert ( ctx . getShaderParameter ( buffer [ i + + ] , buffer [ i + + ] ) , ' we cannot handle errors , we are async proxied WebGL ' ) ; } } , <nl> + 44 : { name : ' clearDepth ' , func : func1 } , <nl> + 45 : { name : ' depthFunc ' , func : func1 } , <nl> + 46 : { name : ' frontFace ' , func : func1 } , <nl> + 47 : { name : ' cullFace ' , func : func1 } , <nl> + 48 : { name : ' pixelStorei ' , func : func2 } , <nl> + 49 : { name : ' depthMask ' , func : func1 } , <nl> + 50 : { name : ' depthRange ' , func : func2 } , <nl> + 51 : { name : ' blendFunc ' , func : func2 } , <nl> + 52 : { name : ' scissor ' , func : func4 } , <nl> + 53 : { name : ' colorMask ' , func : func4 } , <nl> + 54 : { name : ' lineWidth ' , func : func1 } , <nl> + 55 : { name : ' createFramebuffer ' , func : funcC0 } , <nl> + 56 : { name : ' deleteFramebuffer ' , func : func1 } , <nl> + 57 : { name : ' bindFramebuffer ' , func : func2 } , <nl> + 58 : { name : ' framebufferTexture2D ' , func : func5 } , <nl> + 59 : { name : ' createRenderbuffer ' , func : funcC0 } , <nl> + 60 : { name : ' deleteRenderbuffer ' , func : func1 } , <nl> + 61 : { name : ' bindRenderbuffer ' , func : func2 } , <nl> + 62 : { name : ' renderbufferStorage ' , func : func4 } , <nl> + 63 : { name : ' framebufferRenderbuffer ' , func : func4 } , <nl> + 64 : { name : ' debugPrint ' , func : func1 } , <nl> } ; <nl> <nl> - function fixArgs ( command , args ) { <nl> - switch ( command ) { <nl> + function fixArgs ( name , args ) { <nl> + switch ( name ) { <nl> case ' deleteFramebuffer ' : <nl> case ' deleteRenderbuffer ' : <nl> case ' deleteBuffer ' : <nl> case ' deleteShader ' : <nl> case ' deleteProgram ' : <nl> case ' deleteTexture ' : { <nl> - var id = args [ 0 ] ; <nl> - args [ 0 ] = objects [ id ] ; <nl> + var id = buffer [ i ] ; <nl> + buffer [ i ] = objects [ id ] ; <nl> objects [ id ] = null ; / / stop holding on to the object globally <nl> break ; <nl> } <nl> function WebGLClient ( ) { <nl> case ' linkProgram ' : <nl> case ' bindAttribLocation ' : <nl> case ' compileShader ' : <nl> - case ' shaderSource ' : args [ 0 ] = objects [ args [ 0 ] ] ; break ; <nl> - case ' attachShader ' : args [ 0 ] = objects [ args [ 0 ] ] ; args [ 1 ] = objects [ args [ 1 ] ] ; break ; <nl> + case ' shaderSource ' : buffer [ i ] = objects [ buffer [ i ] ] ; break ; <nl> + case ' attachShader ' : buffer [ i ] = objects [ buffer [ i ] ] ; buffer [ i + 1 ] = objects [ buffer [ i + 1 ] ] ; break ; <nl> case ' bindRenderbuffer ' : <nl> case ' bindFramebuffer ' : <nl> case ' bindTexture ' : <nl> - case ' bindBuffer ' : args [ 1 ] = args [ 1 ] ? objects [ args [ 1 ] ] : null ; break ; <nl> + case ' bindBuffer ' : buffer [ i + 1 ] = buffer [ i + 1 ] ? objects [ buffer [ i + 1 ] ] : null ; break ; <nl> case ' framebufferRenderbuffer ' : <nl> - case ' framebufferTexture2D ' : args [ 3 ] = args [ 3 ] ? objects [ args [ 3 ] ] : null ; break ; <nl> + case ' framebufferTexture2D ' : buffer [ i + 3 ] = buffer [ i + 3 ] ? objects [ buffer [ i + 3 ] ] : null ; break ; <nl> } <nl> - return args ; <nl> } <nl> <nl> - function renderCommands ( buffer ) { <nl> - var ctx = Module . ctx ; <nl> - var i = 0 ; <nl> + function renderCommands ( buf ) { <nl> + ctx = Module . ctx ; <nl> + i = 0 ; <nl> + buffer = buf ; <nl> var len = buffer . length ; <nl> / / dump ( ' issuing commands , buffer len : ' + len + ' \ n ' ) ; <nl> while ( i < len ) { <nl> var info = calls [ buffer [ i + + ] ] ; <nl> - var command = info . name ; <nl> - assert ( typeof command = = = ' string ' ) <nl> - var numArgs = info . args ; <nl> - assert ( typeof numArgs = = = ' number ' , command ) ; <nl> - / / dump ( ' issue ' + [ command , numArgs , ' peek : ' + buffer . slice ( i , i + 5 ) ] + ' \ n ' ) ; <nl> - if ( numArgs = = = 0 ) { <nl> - / / dump ( ' issue : ' + command + ' \ n ' ) ; <nl> - if ( command = = = ' getError ' ) { <nl> - assert ( ctx . getError ( ) = = = ctx . NO_ERROR , ' we cannot handle errors , we are async proxied WebGL ' ) ; <nl> - } else { <nl> - ctx [ command ] ( ) ; <nl> - } <nl> - } else if ( numArgs > 0 ) { <nl> - var args = fixArgs ( command , buffer . slice ( i , i + numArgs ) ) ; <nl> - i + = numArgs ; <nl> - / / dump ( ' issue + : ' + command + ' ( ' + args + ' ) , ' + numArgs + ' \ n ' ) ; <nl> - if ( command = = = ' getShaderParameter ' | | command = = = ' getProgramParameter ' ) { <nl> - assert ( ctx [ command ] ( args [ 0 ] , args [ 1 ] ) , ' we cannot handle errors , we are async proxied WebGL ' ) ; <nl> - / / } else if ( command = = = ' debugPrint ' ) { <nl> - / / dump ( args [ 0 ] + ' \ n ' ) ; <nl> - } else { <nl> - ctx [ command ] . apply ( ctx , args ) ; <nl> - } <nl> - } else { <nl> - / / negative means a constructor , last argument is the id to save as <nl> - numArgs = - numArgs - 1 ; <nl> - var args = fixArgs ( command , buffer . slice ( i , i + numArgs ) ) ; <nl> - i + = numArgs ; <nl> - var id = buffer [ i + + ] ; <nl> - / / dump ( ' issue - : ' + command + ' ( ' + args + ' ) , ' + numArgs + ' \ n ' ) ; <nl> - objects [ id ] = ctx [ command ] . apply ( ctx , args ) ; <nl> - } <nl> + var name = info . name ; <nl> + assert ( typeof name = = = ' string ' ) ; <nl> + fixArgs ( name ) ; <nl> + info . func ( name ) ; <nl> / / var err ; <nl> / / while ( ( err = ctx . getError ( ) ) ! = = ctx . NO_ERROR ) { <nl> / / dump ( ' warning : GL error ' + err + ' , after ' + [ command , numArgs ] + ' \ n ' ) ; <nl> | avoid creating slices for each command in gl proxy client | emscripten-core/emscripten | 704fbb93cb402a3255bfbfa8e8f41c6618cfe637 | 2014-06-23T20:43:12Z |
mmm a / imgui . cpp <nl> ppp b / imgui . cpp <nl> bool ImGui : : Begin ( const char * name , bool * p_open , const ImVec2 & size_on_first_us <nl> bool window_pos_set_by_api = false , window_size_set_by_api = false ; <nl> if ( g . SetNextWindowPosCond ) <nl> { <nl> - const ImVec2 backup_cursor_pos = window - > DC . CursorPos ; / / FIXME : not sure of the exact reason of this anymore : ( need to look into that . <nl> + const ImVec2 backup_cursor_pos = window - > DC . CursorPos ; / / FIXME : not sure of the exact reason of this saving / restore anymore : ( need to look into that . <nl> if ( ! window_was_active | | window_appearing_after_being_hidden ) window - > SetWindowPosAllowFlags | = ImGuiSetCond_Appearing ; <nl> window_pos_set_by_api = ( window - > SetWindowPosAllowFlags & g . SetNextWindowPosCond ) ! = 0 ; <nl> if ( window_pos_set_by_api & & ImLengthSqr ( g . SetNextWindowPosVal - ImVec2 ( - FLT_MAX , - FLT_MAX ) ) < 0 . 001f ) <nl> bool ImGui : : Begin ( const char * name , bool * p_open , const ImVec2 & size_on_first_us <nl> window - > Active = true ; <nl> window - > IndexWithinParent = 0 ; <nl> window - > BeginCount = 0 ; <nl> - window - > DrawList - > Clear ( ) ; <nl> window - > ClipRect = ImVec4 ( - FLT_MAX , - FLT_MAX , + FLT_MAX , + FLT_MAX ) ; <nl> window - > LastFrameActive = current_frame ; <nl> window - > IDStack . resize ( 1 ) ; <nl> <nl> - / / Setup texture , outer clipping rectangle <nl> + / / Clear draw list , setup texture , outer clipping rectangle <nl> + window - > DrawList - > Clear ( ) ; <nl> window - > DrawList - > PushTextureID ( g . Font - > ContainerAtlas - > TexID ) ; <nl> ImRect fullscreen_rect ( GetVisibleRect ( ) ) ; <nl> if ( ( flags & ImGuiWindowFlags_ChildWindow ) & & ! ( flags & ( ImGuiWindowFlags_ComboBox | ImGuiWindowFlags_Popup ) ) ) <nl> void ImGui : : FocusWindow ( ImGuiWindow * window ) <nl> / / Steal focus on active widgets <nl> if ( window - > Flags & ImGuiWindowFlags_Popup ) / / FIXME : This statement should be unnecessary . Need further testing before removing it . . <nl> if ( g . ActiveId ! = 0 & & g . ActiveIdWindow & & g . ActiveIdWindow - > RootWindow ! = window ) <nl> - ImGui : : SetActiveID ( 0 ) ; <nl> + SetActiveID ( 0 ) ; <nl> <nl> / / Bring to front <nl> if ( ( window - > Flags & ImGuiWindowFlags_NoBringToFrontOnFocus ) | | g . Windows . back ( ) = = window ) <nl> mmm a / imgui . h <nl> ppp b / imgui . h <nl> namespace ImGui <nl> IMGUI_API void BulletText ( const char * fmt , . . . ) IM_PRINTFARGS ( 1 ) ; <nl> IMGUI_API void BulletTextV ( const char * fmt , va_list args ) ; <nl> IMGUI_API bool Button ( const char * label , const ImVec2 & size = ImVec2 ( 0 , 0 ) ) ; <nl> - IMGUI_API bool SmallButton ( const char * label ) ; <nl> + IMGUI_API bool SmallButton ( const char * label ) ; / / button with FramePadding = ( 0 , 0 ) <nl> IMGUI_API bool InvisibleButton ( const char * str_id , const ImVec2 & size ) ; <nl> IMGUI_API void Image ( ImTextureID user_texture_id , const ImVec2 & size , const ImVec2 & uv0 = ImVec2 ( 0 , 0 ) , const ImVec2 & uv1 = ImVec2 ( 1 , 1 ) , const ImVec4 & tint_col = ImVec4 ( 1 , 1 , 1 , 1 ) , const ImVec4 & border_col = ImVec4 ( 0 , 0 , 0 , 0 ) ) ; <nl> IMGUI_API bool ImageButton ( ImTextureID user_texture_id , const ImVec2 & size , const ImVec2 & uv0 = ImVec2 ( 0 , 0 ) , const ImVec2 & uv1 = ImVec2 ( 1 , 1 ) , int frame_padding = - 1 , const ImVec4 & bg_col = ImVec4 ( 0 , 0 , 0 , 0 ) , const ImVec4 & tint_col = ImVec4 ( 1 , 1 , 1 , 1 ) ) ; / / < 0 frame_padding uses default frame padding settings . 0 for no padding <nl> | Minor bits | ocornut/imgui | 81bf5aeb09cd5cb45fc43711a7f33ef518b5cf21 | 2016-05-21T18:07:51Z |
mmm a / Makefile . include . in <nl> ppp b / Makefile . include . in <nl> <nl> AR = ar <nl> ARFLAGS = crus <nl> RM = rm - rf <nl> - SHELL = / bin / bash <nl> + SHELL = @ SHELL @ <nl> ARCH = @ ARCH @ <nl> abs_top_srcdir = @ abs_top_srcdir @ <nl> prefix = @ prefix @ <nl> mmm a / lib / Makefile . in <nl> ppp b / lib / Makefile . in <nl> <nl> CC = @ CC @ <nl> CXX = @ CXX @ <nl> - SHELL = / bin / bash <nl> + SHELL = @ SHELL @ <nl> LDFLAGS = - shared - fPIC - rdynamic <nl> ARCH = @ ARCH @ <nl> SYSDIR = @ abs_top_srcdir @ / system / players / dvdplayer <nl> mmm a / xbmc / interfaces / python / linux / Makefile . in <nl> ppp b / xbmc / interfaces / python / linux / Makefile . in <nl> ARCH = @ ARCH @ <nl> CC = @ CC @ <nl> CFLAGS = @ CFLAGS @ <nl> LDFLAGS = @ LDFLAGS @ <nl> - SHELL = / bin / bash <nl> + SHELL = @ SHELL @ <nl> SYSDIR = $ ( abs_top_srcdir ) / system / python <nl> <nl> ifeq ( @ USE_PYTHON2_6 @ , 1 ) <nl> | remove all / bin / bash and replace them by @ SHELL @ macro | xbmc/xbmc | eb7c46e51b2b7f54a93a7fbd3e7ebe6767b20ec8 | 2011-02-07T12:04:53Z |
mmm a / src / common / logging / backend . cpp <nl> ppp b / src / common / logging / backend . cpp <nl> void DebuggerBackend : : Write ( const Entry & entry ) { <nl> CLS ( Input ) \ <nl> CLS ( Network ) \ <nl> CLS ( Loader ) \ <nl> + CLS ( CheatEngine ) \ <nl> CLS ( Crypto ) \ <nl> CLS ( WebService ) <nl> <nl> mmm a / src / common / logging / log . h <nl> ppp b / src / common / logging / log . h <nl> enum class Class : ClassType { <nl> Audio_DSP , / / / < The HLE implementation of the DSP <nl> Audio_Sink , / / / < Emulator audio output backend <nl> Loader , / / / < ROM loader <nl> + CheatEngine , / / / < Memory manipulation and engine VM functions <nl> Crypto , / / / < Cryptographic engine / functions <nl> Input , / / / < Input emulation <nl> Network , / / / < Network emulation <nl> mmm a / src / core / CMakeLists . txt <nl> ppp b / src / core / CMakeLists . txt <nl> add_library ( core STATIC <nl> file_sys / bis_factory . h <nl> file_sys / card_image . cpp <nl> file_sys / card_image . h <nl> - file_sys / cheat_engine . cpp <nl> - file_sys / cheat_engine . h <nl> file_sys / content_archive . cpp <nl> file_sys / content_archive . h <nl> file_sys / control_metadata . cpp <nl> add_library ( core STATIC <nl> loader / nsp . h <nl> loader / xci . cpp <nl> loader / xci . h <nl> + memory / cheat_engine . cpp <nl> + memory / cheat_engine . h <nl> + memory / dmnt_cheat_types . h <nl> + memory / dmnt_cheat_vm . cpp <nl> + memory / dmnt_cheat_vm . h <nl> memory . cpp <nl> memory . h <nl> memory_setup . h <nl> mmm a / src / core / core . cpp <nl> ppp b / src / core / core . cpp <nl> <nl> # include " core / file_sys / bis_factory . h " <nl> # include " core / file_sys / card_image . h " <nl> # include " core / file_sys / mode . h " <nl> + # include " core / file_sys / patch_manager . h " <nl> # include " core / file_sys / registered_cache . h " <nl> # include " core / file_sys / romfs_factory . h " <nl> # include " core / file_sys / savedata_factory . h " <nl> <nl> # include " core / hle / service / service . h " <nl> # include " core / hle / service / sm / sm . h " <nl> # include " core / loader / loader . h " <nl> + # include " core / memory / cheat_engine . h " <nl> # include " core / perf_stats . h " <nl> # include " core / reporter . h " <nl> # include " core / settings . h " <nl> # include " core / telemetry_session . h " <nl> # include " core / tools / freezer . h " <nl> - # include " file_sys / cheat_engine . h " <nl> - # include " file_sys / patch_manager . h " <nl> # include " video_core / debug_utils / debug_utils . h " <nl> # include " video_core / renderer_base . h " <nl> # include " video_core / video_core . h " <nl> struct System : : Impl { <nl> gpu_core - > Start ( ) ; <nl> cpu_core_manager . StartThreads ( ) ; <nl> <nl> + / / Initialize cheat engine <nl> + if ( cheat_engine ) { <nl> + cheat_engine - > Initialize ( ) ; <nl> + } <nl> + <nl> / / All threads are started , begin main process execution , now that we ' re in the clear . <nl> main_process - > Run ( load_parameters - > main_thread_priority , <nl> load_parameters - > main_thread_stack_size ) ; <nl> struct System : : Impl { <nl> CpuCoreManager cpu_core_manager ; <nl> bool is_powered_on = false ; <nl> <nl> - std : : unique_ptr < FileSys : : CheatEngine > cheat_engine ; <nl> + std : : unique_ptr < Memory : : CheatEngine > cheat_engine ; <nl> std : : unique_ptr < Tools : : Freezer > memory_freezer ; <nl> <nl> / / / Frontend applets <nl> Tegra : : DebugContext * System : : GetGPUDebugContext ( ) const { <nl> return impl - > debug_context . get ( ) ; <nl> } <nl> <nl> - void System : : RegisterCheatList ( const std : : vector < FileSys : : CheatList > & list , <nl> - const std : : string & build_id , VAddr code_region_start , <nl> - VAddr code_region_end ) { <nl> - impl - > cheat_engine = std : : make_unique < FileSys : : CheatEngine > ( * this , list , build_id , <nl> - code_region_start , code_region_end ) ; <nl> - } <nl> - <nl> void System : : SetFilesystem ( std : : shared_ptr < FileSys : : VfsFilesystem > vfs ) { <nl> impl - > virtual_filesystem = std : : move ( vfs ) ; <nl> } <nl> std : : shared_ptr < FileSys : : VfsFilesystem > System : : GetFilesystem ( ) const { <nl> return impl - > virtual_filesystem ; <nl> } <nl> <nl> + void System : : RegisterCheatList ( const std : : vector < Memory : : CheatEntry > & list , <nl> + const std : : array < u8 , 32 > & build_id , VAddr main_region_begin , <nl> + u64 main_region_size ) { <nl> + impl - > cheat_engine = std : : make_unique < Memory : : CheatEngine > ( * this , list , build_id ) ; <nl> + impl - > cheat_engine - > SetMainMemoryParameters ( main_region_begin , main_region_size ) ; <nl> + } <nl> + <nl> void System : : SetAppletFrontendSet ( Service : : AM : : Applets : : AppletFrontendSet & & set ) { <nl> impl - > applet_manager . SetAppletFrontendSet ( std : : move ( set ) ) ; <nl> } <nl> mmm a / src / core / core . h <nl> ppp b / src / core / core . h <nl> class EmuWindow ; <nl> } / / namespace Core : : Frontend <nl> <nl> namespace FileSys { <nl> - class CheatList ; <nl> class ContentProvider ; <nl> class ContentProviderUnion ; <nl> enum class ContentProviderUnionSlot ; <nl> class AppLoader ; <nl> enum class ResultStatus : u16 ; <nl> } / / namespace Loader <nl> <nl> + namespace Memory { <nl> + struct CheatEntry ; <nl> + } / / namespace Memory <nl> + <nl> namespace Service { <nl> <nl> namespace AM : : Applets { <nl> class System { <nl> <nl> std : : shared_ptr < FileSys : : VfsFilesystem > GetFilesystem ( ) const ; <nl> <nl> - void RegisterCheatList ( const std : : vector < FileSys : : CheatList > & list , const std : : string & build_id , <nl> - VAddr code_region_start , VAddr code_region_end ) ; <nl> + void RegisterCheatList ( const std : : vector < Memory : : CheatEntry > & list , <nl> + const std : : array < u8 , 0x20 > & build_id , VAddr main_region_begin , <nl> + u64 main_region_size ) ; <nl> <nl> void SetAppletFrontendSet ( Service : : AM : : Applets : : AppletFrontendSet & & set ) ; <nl> <nl> deleted file mode 100644 <nl> index b06c2f20a31 . . 00000000000 <nl> mmm a / src / core / file_sys / cheat_engine . cpp <nl> ppp / dev / null <nl> <nl> - / / Copyright 2018 yuzu emulator team <nl> - / / Licensed under GPLv2 or any later version <nl> - / / Refer to the license . txt file included . <nl> - <nl> - # include < locale > <nl> - # include " common / hex_util . h " <nl> - # include " common / microprofile . h " <nl> - # include " common / swap . h " <nl> - # include " core / core . h " <nl> - # include " core / core_timing . h " <nl> - # include " core / core_timing_util . h " <nl> - # include " core / file_sys / cheat_engine . h " <nl> - # include " core / hle / kernel / process . h " <nl> - # include " core / hle / service / hid / controllers / npad . h " <nl> - # include " core / hle / service / hid / hid . h " <nl> - # include " core / hle / service / sm / sm . h " <nl> - <nl> - namespace FileSys { <nl> - <nl> - constexpr s64 CHEAT_ENGINE_TICKS = static_cast < s64 > ( Core : : Timing : : BASE_CLOCK_RATE / 60 ) ; <nl> - constexpr u32 KEYPAD_BITMASK = 0x3FFFFFF ; <nl> - <nl> - u64 Cheat : : Address ( ) const { <nl> - u64 out ; <nl> - std : : memcpy ( & out , raw . data ( ) , sizeof ( u64 ) ) ; <nl> - return Common : : swap64 ( out ) & 0xFFFFFFFFFF ; <nl> - } <nl> - <nl> - u64 Cheat : : ValueWidth ( u64 offset ) const { <nl> - return Value ( offset , width ) ; <nl> - } <nl> - <nl> - u64 Cheat : : Value ( u64 offset , u64 width ) const { <nl> - u64 out ; <nl> - std : : memcpy ( & out , raw . data ( ) + offset , sizeof ( u64 ) ) ; <nl> - out = Common : : swap64 ( out ) ; <nl> - if ( width = = 8 ) <nl> - return out ; <nl> - return out & ( ( 1ull < < ( width * CHAR_BIT ) ) - 1 ) ; <nl> - } <nl> - <nl> - u32 Cheat : : KeypadValue ( ) const { <nl> - u32 out ; <nl> - std : : memcpy ( & out , raw . data ( ) , sizeof ( u32 ) ) ; <nl> - return Common : : swap32 ( out ) & 0x0FFFFFFF ; <nl> - } <nl> - <nl> - void CheatList : : SetMemoryParameters ( VAddr main_begin , VAddr heap_begin , VAddr main_end , <nl> - VAddr heap_end , MemoryWriter writer , MemoryReader reader ) { <nl> - this - > main_region_begin = main_begin ; <nl> - this - > main_region_end = main_end ; <nl> - this - > heap_region_begin = heap_begin ; <nl> - this - > heap_region_end = heap_end ; <nl> - this - > writer = writer ; <nl> - this - > reader = reader ; <nl> - } <nl> - <nl> - MICROPROFILE_DEFINE ( Cheat_Engine , " Add - Ons " , " Cheat Engine " , MP_RGB ( 70 , 200 , 70 ) ) ; <nl> - <nl> - void CheatList : : Execute ( ) { <nl> - MICROPROFILE_SCOPE ( Cheat_Engine ) ; <nl> - <nl> - std : : fill ( scratch . begin ( ) , scratch . end ( ) , 0 ) ; <nl> - in_standard = false ; <nl> - for ( std : : size_t i = 0 ; i < master_list . size ( ) ; + + i ) { <nl> - LOG_DEBUG ( Common_Filesystem , " Executing block # { : 08X } ( { } ) " , i , master_list [ i ] . first ) ; <nl> - current_block = i ; <nl> - ExecuteBlock ( master_list [ i ] . second ) ; <nl> - } <nl> - <nl> - in_standard = true ; <nl> - for ( std : : size_t i = 0 ; i < standard_list . size ( ) ; + + i ) { <nl> - LOG_DEBUG ( Common_Filesystem , " Executing block # { : 08X } ( { } ) " , i , standard_list [ i ] . first ) ; <nl> - current_block = i ; <nl> - ExecuteBlock ( standard_list [ i ] . second ) ; <nl> - } <nl> - } <nl> - <nl> - CheatList : : CheatList ( const Core : : System & system_ , ProgramSegment master , ProgramSegment standard ) <nl> - : master_list { std : : move ( master ) } , standard_list { std : : move ( standard ) } , system { & system_ } { } <nl> - <nl> - bool CheatList : : EvaluateConditional ( const Cheat & cheat ) const { <nl> - using ComparisonFunction = bool ( * ) ( u64 , u64 ) ; <nl> - constexpr std : : array < ComparisonFunction , 6 > comparison_functions { <nl> - [ ] ( u64 a , u64 b ) { return a > b ; } , [ ] ( u64 a , u64 b ) { return a > = b ; } , <nl> - [ ] ( u64 a , u64 b ) { return a < b ; } , [ ] ( u64 a , u64 b ) { return a < = b ; } , <nl> - [ ] ( u64 a , u64 b ) { return a = = b ; } , [ ] ( u64 a , u64 b ) { return a ! = b ; } , <nl> - } ; <nl> - <nl> - if ( cheat . type = = CodeType : : ConditionalInput ) { <nl> - const auto applet_resource = <nl> - system - > ServiceManager ( ) . GetService < Service : : HID : : Hid > ( " hid " ) - > GetAppletResource ( ) ; <nl> - if ( applet_resource = = nullptr ) { <nl> - LOG_WARNING ( <nl> - Common_Filesystem , <nl> - " Attempted to evaluate input conditional , but applet resource is not initialized ! " ) ; <nl> - return false ; <nl> - } <nl> - <nl> - const auto press_state = <nl> - applet_resource <nl> - - > GetController < Service : : HID : : Controller_NPad > ( Service : : HID : : HidController : : NPad ) <nl> - . GetAndResetPressState ( ) ; <nl> - return ( ( press_state & cheat . KeypadValue ( ) ) & KEYPAD_BITMASK ) ! = 0 ; <nl> - } <nl> - <nl> - ASSERT ( cheat . type = = CodeType : : Conditional ) ; <nl> - <nl> - const auto offset = <nl> - cheat . memory_type = = MemoryType : : MainNSO ? main_region_begin : heap_region_begin ; <nl> - ASSERT ( static_cast < u8 > ( cheat . comparison_op . Value ( ) ) < 6 ) ; <nl> - auto * function = comparison_functions [ static_cast < u8 > ( cheat . comparison_op . Value ( ) ) ] ; <nl> - const auto addr = cheat . Address ( ) + offset ; <nl> - <nl> - return function ( reader ( cheat . width , SanitizeAddress ( addr ) ) , cheat . ValueWidth ( 8 ) ) ; <nl> - } <nl> - <nl> - void CheatList : : ProcessBlockPairs ( const Block & block ) { <nl> - block_pairs . clear ( ) ; <nl> - <nl> - u64 scope = 0 ; <nl> - std : : map < u64 , u64 > pairs ; <nl> - <nl> - for ( std : : size_t i = 0 ; i < block . size ( ) ; + + i ) { <nl> - const auto & cheat = block [ i ] ; <nl> - <nl> - switch ( cheat . type ) { <nl> - case CodeType : : Conditional : <nl> - case CodeType : : ConditionalInput : <nl> - pairs . insert_or_assign ( scope , i ) ; <nl> - + + scope ; <nl> - break ; <nl> - case CodeType : : EndConditional : { <nl> - - - scope ; <nl> - const auto idx = pairs . at ( scope ) ; <nl> - block_pairs . insert_or_assign ( idx , i ) ; <nl> - break ; <nl> - } <nl> - case CodeType : : Loop : { <nl> - if ( cheat . end_of_loop ) { <nl> - - - scope ; <nl> - const auto idx = pairs . at ( scope ) ; <nl> - block_pairs . insert_or_assign ( idx , i ) ; <nl> - } else { <nl> - pairs . insert_or_assign ( scope , i ) ; <nl> - + + scope ; <nl> - } <nl> - break ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - <nl> - void CheatList : : WriteImmediate ( const Cheat & cheat ) { <nl> - const auto offset = <nl> - cheat . memory_type = = MemoryType : : MainNSO ? main_region_begin : heap_region_begin ; <nl> - const auto & register_3 = scratch . at ( cheat . register_3 ) ; <nl> - <nl> - const auto addr = cheat . Address ( ) + offset + register_3 ; <nl> - LOG_DEBUG ( Common_Filesystem , " writing value = { : 016X } to addr = { : 016X } " , addr , <nl> - cheat . Value ( 8 , cheat . width ) ) ; <nl> - writer ( cheat . width , SanitizeAddress ( addr ) , cheat . ValueWidth ( 8 ) ) ; <nl> - } <nl> - <nl> - void CheatList : : BeginConditional ( const Cheat & cheat ) { <nl> - if ( EvaluateConditional ( cheat ) ) { <nl> - return ; <nl> - } <nl> - <nl> - const auto iter = block_pairs . find ( current_index ) ; <nl> - ASSERT ( iter ! = block_pairs . end ( ) ) ; <nl> - current_index = iter - > second - 1 ; <nl> - } <nl> - <nl> - void CheatList : : EndConditional ( const Cheat & cheat ) { <nl> - LOG_DEBUG ( Common_Filesystem , " Ending conditional block . " ) ; <nl> - } <nl> - <nl> - void CheatList : : Loop ( const Cheat & cheat ) { <nl> - if ( cheat . end_of_loop . Value ( ) ) <nl> - ASSERT ( ! cheat . end_of_loop . Value ( ) ) ; <nl> - <nl> - auto & register_3 = scratch . at ( cheat . register_3 ) ; <nl> - const auto iter = block_pairs . find ( current_index ) ; <nl> - ASSERT ( iter ! = block_pairs . end ( ) ) ; <nl> - ASSERT ( iter - > first < iter - > second ) ; <nl> - <nl> - const s32 initial_value = static_cast < s32 > ( cheat . Value ( 4 , sizeof ( s32 ) ) ) ; <nl> - for ( s32 i = initial_value ; i > = 0 ; - - i ) { <nl> - register_3 = static_cast < u64 > ( i ) ; <nl> - for ( std : : size_t c = iter - > first + 1 ; c < iter - > second ; + + c ) { <nl> - current_index = c ; <nl> - ExecuteSingleCheat ( <nl> - ( in_standard ? standard_list : master_list ) [ current_block ] . second [ c ] ) ; <nl> - } <nl> - } <nl> - <nl> - current_index = iter - > second ; <nl> - } <nl> - <nl> - void CheatList : : LoadImmediate ( const Cheat & cheat ) { <nl> - auto & register_3 = scratch . at ( cheat . register_3 ) ; <nl> - <nl> - LOG_DEBUG ( Common_Filesystem , " setting register = { : 01X } equal to value = { : 016X } " , cheat . register_3 , <nl> - cheat . Value ( 4 , 8 ) ) ; <nl> - register_3 = cheat . Value ( 4 , 8 ) ; <nl> - } <nl> - <nl> - void CheatList : : LoadIndexed ( const Cheat & cheat ) { <nl> - const auto offset = <nl> - cheat . memory_type = = MemoryType : : MainNSO ? main_region_begin : heap_region_begin ; <nl> - auto & register_3 = scratch . at ( cheat . register_3 ) ; <nl> - <nl> - const auto addr = ( cheat . load_from_register . Value ( ) ? register_3 : offset ) + cheat . Address ( ) ; <nl> - LOG_DEBUG ( Common_Filesystem , " writing indexed value to register = { : 01X } , addr = { : 016X } " , <nl> - cheat . register_3 , addr ) ; <nl> - register_3 = reader ( cheat . width , SanitizeAddress ( addr ) ) ; <nl> - } <nl> - <nl> - void CheatList : : StoreIndexed ( const Cheat & cheat ) { <nl> - const auto & register_3 = scratch . at ( cheat . register_3 ) ; <nl> - <nl> - const auto addr = <nl> - register_3 + ( cheat . add_additional_register . Value ( ) ? scratch . at ( cheat . register_6 ) : 0 ) ; <nl> - LOG_DEBUG ( Common_Filesystem , " writing value = { : 016X } to addr = { : 016X } " , <nl> - cheat . Value ( 4 , cheat . width ) , addr ) ; <nl> - writer ( cheat . width , SanitizeAddress ( addr ) , cheat . ValueWidth ( 4 ) ) ; <nl> - } <nl> - <nl> - void CheatList : : RegisterArithmetic ( const Cheat & cheat ) { <nl> - using ArithmeticFunction = u64 ( * ) ( u64 , u64 ) ; <nl> - constexpr std : : array < ArithmeticFunction , 5 > arithmetic_functions { <nl> - [ ] ( u64 a , u64 b ) { return a + b ; } , [ ] ( u64 a , u64 b ) { return a - b ; } , <nl> - [ ] ( u64 a , u64 b ) { return a * b ; } , [ ] ( u64 a , u64 b ) { return a < < b ; } , <nl> - [ ] ( u64 a , u64 b ) { return a > > b ; } , <nl> - } ; <nl> - <nl> - using ArithmeticOverflowCheck = bool ( * ) ( u64 , u64 ) ; <nl> - constexpr std : : array < ArithmeticOverflowCheck , 5 > arithmetic_overflow_checks { <nl> - [ ] ( u64 a , u64 b ) { return a > ( std : : numeric_limits < u64 > : : max ( ) - b ) ; } , / / a + b <nl> - [ ] ( u64 a , u64 b ) { return a > ( std : : numeric_limits < u64 > : : max ( ) + b ) ; } , / / a - b <nl> - [ ] ( u64 a , u64 b ) { return a > ( std : : numeric_limits < u64 > : : max ( ) / b ) ; } , / / a * b <nl> - [ ] ( u64 a , u64 b ) { return b > = 64 | | ( a & ~ ( ( 1ull < < ( 64 - b ) ) - 1 ) ) ! = 0 ; } , / / a < < b <nl> - [ ] ( u64 a , u64 b ) { return b > = 64 | | ( a & ( ( 1ull < < b ) - 1 ) ) ! = 0 ; } , / / a > > b <nl> - } ; <nl> - <nl> - static_assert ( sizeof ( arithmetic_functions ) = = sizeof ( arithmetic_overflow_checks ) , <nl> - " Missing or have extra arithmetic overflow checks compared to functions ! " ) ; <nl> - <nl> - auto & register_3 = scratch . at ( cheat . register_3 ) ; <nl> - <nl> - ASSERT ( static_cast < u8 > ( cheat . arithmetic_op . Value ( ) ) < 5 ) ; <nl> - auto * function = arithmetic_functions [ static_cast < u8 > ( cheat . arithmetic_op . Value ( ) ) ] ; <nl> - auto * overflow_function = <nl> - arithmetic_overflow_checks [ static_cast < u8 > ( cheat . arithmetic_op . Value ( ) ) ] ; <nl> - LOG_DEBUG ( Common_Filesystem , " performing arithmetic with register = { : 01X } , value = { : 016X } " , <nl> - cheat . register_3 , cheat . ValueWidth ( 4 ) ) ; <nl> - <nl> - if ( overflow_function ( register_3 , cheat . ValueWidth ( 4 ) ) ) { <nl> - LOG_WARNING ( Common_Filesystem , <nl> - " overflow will occur when performing arithmetic operation = { : 02X } with operands " <nl> - " a = { : 016X } , b = { : 016X } ! " , <nl> - static_cast < u8 > ( cheat . arithmetic_op . Value ( ) ) , register_3 , cheat . ValueWidth ( 4 ) ) ; <nl> - } <nl> - <nl> - register_3 = function ( register_3 , cheat . ValueWidth ( 4 ) ) ; <nl> - } <nl> - <nl> - void CheatList : : BeginConditionalInput ( const Cheat & cheat ) { <nl> - if ( EvaluateConditional ( cheat ) ) <nl> - return ; <nl> - <nl> - const auto iter = block_pairs . find ( current_index ) ; <nl> - ASSERT ( iter ! = block_pairs . end ( ) ) ; <nl> - current_index = iter - > second - 1 ; <nl> - } <nl> - <nl> - VAddr CheatList : : SanitizeAddress ( VAddr in ) const { <nl> - if ( ( in < main_region_begin | | in > = main_region_end ) & & <nl> - ( in < heap_region_begin | | in > = heap_region_end ) ) { <nl> - LOG_ERROR ( Common_Filesystem , <nl> - " Cheat attempting to access memory at invalid address = { : 016X } , if this persists , " <nl> - " the cheat may be incorrect . However , this may be normal early in execution if " <nl> - " the game has not properly set up yet . " , <nl> - in ) ; <nl> - return 0 ; / / / < Invalid addresses will hard crash <nl> - } <nl> - <nl> - return in ; <nl> - } <nl> - <nl> - void CheatList : : ExecuteSingleCheat ( const Cheat & cheat ) { <nl> - using CheatOperationFunction = void ( CheatList : : * ) ( const Cheat & ) ; <nl> - constexpr std : : array < CheatOperationFunction , 9 > cheat_operation_functions { <nl> - & CheatList : : WriteImmediate , & CheatList : : BeginConditional , <nl> - & CheatList : : EndConditional , & CheatList : : Loop , <nl> - & CheatList : : LoadImmediate , & CheatList : : LoadIndexed , <nl> - & CheatList : : StoreIndexed , & CheatList : : RegisterArithmetic , <nl> - & CheatList : : BeginConditionalInput , <nl> - } ; <nl> - <nl> - const auto index = static_cast < u8 > ( cheat . type . Value ( ) ) ; <nl> - ASSERT ( index < sizeof ( cheat_operation_functions ) ) ; <nl> - const auto op = cheat_operation_functions [ index ] ; <nl> - ( this - > * op ) ( cheat ) ; <nl> - } <nl> - <nl> - void CheatList : : ExecuteBlock ( const Block & block ) { <nl> - encountered_loops . clear ( ) ; <nl> - <nl> - ProcessBlockPairs ( block ) ; <nl> - for ( std : : size_t i = 0 ; i < block . size ( ) ; + + i ) { <nl> - current_index = i ; <nl> - ExecuteSingleCheat ( block [ i ] ) ; <nl> - i = current_index ; <nl> - } <nl> - } <nl> - <nl> - CheatParser : : ~ CheatParser ( ) = default ; <nl> - <nl> - CheatList CheatParser : : MakeCheatList ( const Core : : System & system , CheatList : : ProgramSegment master , <nl> - CheatList : : ProgramSegment standard ) const { <nl> - return { system , std : : move ( master ) , std : : move ( standard ) } ; <nl> - } <nl> - <nl> - TextCheatParser : : ~ TextCheatParser ( ) = default ; <nl> - <nl> - CheatList TextCheatParser : : Parse ( const Core : : System & system , const std : : vector < u8 > & data ) const { <nl> - std : : stringstream ss ; <nl> - ss . write ( reinterpret_cast < const char * > ( data . data ( ) ) , data . size ( ) ) ; <nl> - <nl> - std : : vector < std : : string > lines ; <nl> - std : : string stream_line ; <nl> - while ( std : : getline ( ss , stream_line ) ) { <nl> - / / Remove a trailing \ r <nl> - if ( ! stream_line . empty ( ) & & stream_line . back ( ) = = ' \ r ' ) <nl> - stream_line . pop_back ( ) ; <nl> - lines . push_back ( std : : move ( stream_line ) ) ; <nl> - } <nl> - <nl> - CheatList : : ProgramSegment master_list ; <nl> - CheatList : : ProgramSegment standard_list ; <nl> - <nl> - for ( std : : size_t i = 0 ; i < lines . size ( ) ; + + i ) { <nl> - auto line = lines [ i ] ; <nl> - <nl> - if ( ! line . empty ( ) & & ( line [ 0 ] = = ' [ ' | | line [ 0 ] = = ' { ' ) ) { <nl> - const auto master = line [ 0 ] = = ' { ' ; <nl> - const auto begin = master ? line . find ( ' { ' ) : line . find ( ' [ ' ) ; <nl> - const auto end = master ? line . rfind ( ' } ' ) : line . rfind ( ' ] ' ) ; <nl> - <nl> - ASSERT ( begin ! = std : : string : : npos & & end ! = std : : string : : npos ) ; <nl> - <nl> - const std : : string patch_name { line . begin ( ) + begin + 1 , line . begin ( ) + end } ; <nl> - CheatList : : Block block { } ; <nl> - <nl> - while ( i < lines . size ( ) - 1 ) { <nl> - line = lines [ + + i ] ; <nl> - if ( ! line . empty ( ) & & ( line [ 0 ] = = ' [ ' | | line [ 0 ] = = ' { ' ) ) { <nl> - - - i ; <nl> - break ; <nl> - } <nl> - <nl> - if ( line . size ( ) < 8 ) <nl> - continue ; <nl> - <nl> - Cheat out { } ; <nl> - out . raw = ParseSingleLineCheat ( line ) ; <nl> - block . push_back ( out ) ; <nl> - } <nl> - <nl> - ( master ? master_list : standard_list ) . emplace_back ( patch_name , block ) ; <nl> - } <nl> - } <nl> - <nl> - return MakeCheatList ( system , master_list , standard_list ) ; <nl> - } <nl> - <nl> - std : : array < u8 , 16 > TextCheatParser : : ParseSingleLineCheat ( const std : : string & line ) const { <nl> - std : : array < u8 , 16 > out { } ; <nl> - <nl> - if ( line . size ( ) < 8 ) <nl> - return out ; <nl> - <nl> - const auto word1 = Common : : HexStringToArray < sizeof ( u32 ) > ( std : : string_view { line . data ( ) , 8 } ) ; <nl> - std : : memcpy ( out . data ( ) , word1 . data ( ) , sizeof ( u32 ) ) ; <nl> - <nl> - if ( line . size ( ) < 17 | | line [ 8 ] ! = ' ' ) <nl> - return out ; <nl> - <nl> - const auto word2 = Common : : HexStringToArray < sizeof ( u32 ) > ( std : : string_view { line . data ( ) + 9 , 8 } ) ; <nl> - std : : memcpy ( out . data ( ) + sizeof ( u32 ) , word2 . data ( ) , sizeof ( u32 ) ) ; <nl> - <nl> - if ( line . size ( ) < 26 | | line [ 17 ] ! = ' ' ) { <nl> - / / Perform shifting in case value is truncated early . <nl> - const auto type = static_cast < CodeType > ( ( out [ 0 ] & 0xF0 ) > > 4 ) ; <nl> - if ( type = = CodeType : : Loop | | type = = CodeType : : LoadImmediate | | <nl> - type = = CodeType : : StoreIndexed | | type = = CodeType : : RegisterArithmetic ) { <nl> - std : : memcpy ( out . data ( ) + 8 , out . data ( ) + 4 , sizeof ( u32 ) ) ; <nl> - std : : memset ( out . data ( ) + 4 , 0 , sizeof ( u32 ) ) ; <nl> - } <nl> - <nl> - return out ; <nl> - } <nl> - <nl> - const auto word3 = Common : : HexStringToArray < sizeof ( u32 ) > ( std : : string_view { line . data ( ) + 18 , 8 } ) ; <nl> - std : : memcpy ( out . data ( ) + 2 * sizeof ( u32 ) , word3 . data ( ) , sizeof ( u32 ) ) ; <nl> - <nl> - if ( line . size ( ) < 35 | | line [ 26 ] ! = ' ' ) { <nl> - / / Perform shifting in case value is truncated early . <nl> - const auto type = static_cast < CodeType > ( ( out [ 0 ] & 0xF0 ) > > 4 ) ; <nl> - if ( type = = CodeType : : WriteImmediate | | type = = CodeType : : Conditional ) { <nl> - std : : memcpy ( out . data ( ) + 12 , out . data ( ) + 8 , sizeof ( u32 ) ) ; <nl> - std : : memset ( out . data ( ) + 8 , 0 , sizeof ( u32 ) ) ; <nl> - } <nl> - <nl> - return out ; <nl> - } <nl> - <nl> - const auto word4 = Common : : HexStringToArray < sizeof ( u32 ) > ( std : : string_view { line . data ( ) + 27 , 8 } ) ; <nl> - std : : memcpy ( out . data ( ) + 3 * sizeof ( u32 ) , word4 . data ( ) , sizeof ( u32 ) ) ; <nl> - <nl> - return out ; <nl> - } <nl> - <nl> - namespace { <nl> - u64 MemoryReadImpl ( u32 width , VAddr addr ) { <nl> - switch ( width ) { <nl> - case 1 : <nl> - return Memory : : Read8 ( addr ) ; <nl> - case 2 : <nl> - return Memory : : Read16 ( addr ) ; <nl> - case 4 : <nl> - return Memory : : Read32 ( addr ) ; <nl> - case 8 : <nl> - return Memory : : Read64 ( addr ) ; <nl> - default : <nl> - UNREACHABLE ( ) ; <nl> - return 0 ; <nl> - } <nl> - } <nl> - <nl> - void MemoryWriteImpl ( u32 width , VAddr addr , u64 value ) { <nl> - switch ( width ) { <nl> - case 1 : <nl> - Memory : : Write8 ( addr , static_cast < u8 > ( value ) ) ; <nl> - break ; <nl> - case 2 : <nl> - Memory : : Write16 ( addr , static_cast < u16 > ( value ) ) ; <nl> - break ; <nl> - case 4 : <nl> - Memory : : Write32 ( addr , static_cast < u32 > ( value ) ) ; <nl> - break ; <nl> - case 8 : <nl> - Memory : : Write64 ( addr , value ) ; <nl> - break ; <nl> - default : <nl> - UNREACHABLE ( ) ; <nl> - } <nl> - } <nl> - } / / Anonymous namespace <nl> - <nl> - CheatEngine : : CheatEngine ( Core : : System & system , std : : vector < CheatList > cheats_ , <nl> - const std : : string & build_id , VAddr code_region_start , <nl> - VAddr code_region_end ) <nl> - : cheats { std : : move ( cheats_ ) } , core_timing { system . CoreTiming ( ) } { <nl> - event = core_timing . RegisterEvent ( <nl> - " CheatEngine : : FrameCallback : : " + build_id , <nl> - [ this ] ( u64 userdata , s64 cycles_late ) { FrameCallback ( userdata , cycles_late ) ; } ) ; <nl> - core_timing . ScheduleEvent ( CHEAT_ENGINE_TICKS , event ) ; <nl> - <nl> - const auto & vm_manager = system . CurrentProcess ( ) - > VMManager ( ) ; <nl> - for ( auto & list : this - > cheats ) { <nl> - list . SetMemoryParameters ( code_region_start , vm_manager . GetHeapRegionBaseAddress ( ) , <nl> - code_region_end , vm_manager . GetHeapRegionEndAddress ( ) , <nl> - & MemoryWriteImpl , & MemoryReadImpl ) ; <nl> - } <nl> - } <nl> - <nl> - CheatEngine : : ~ CheatEngine ( ) { <nl> - core_timing . UnscheduleEvent ( event , 0 ) ; <nl> - } <nl> - <nl> - void CheatEngine : : FrameCallback ( u64 userdata , s64 cycles_late ) { <nl> - for ( auto & list : cheats ) { <nl> - list . Execute ( ) ; <nl> - } <nl> - <nl> - core_timing . ScheduleEvent ( CHEAT_ENGINE_TICKS - cycles_late , event ) ; <nl> - } <nl> - <nl> - } / / namespace FileSys <nl> deleted file mode 100644 <nl> index ac22a82cb1a . . 00000000000 <nl> mmm a / src / core / file_sys / cheat_engine . h <nl> ppp / dev / null <nl> <nl> - / / Copyright 2018 yuzu emulator team <nl> - / / Licensed under GPLv2 or any later version <nl> - / / Refer to the license . txt file included . <nl> - <nl> - # pragma once <nl> - <nl> - # include < map > <nl> - # include < set > <nl> - # include < vector > <nl> - # include " common / bit_field . h " <nl> - # include " common / common_types . h " <nl> - <nl> - namespace Core { <nl> - class System ; <nl> - } <nl> - <nl> - namespace Core : : Timing { <nl> - class CoreTiming ; <nl> - struct EventType ; <nl> - } / / namespace Core : : Timing <nl> - <nl> - namespace FileSys { <nl> - <nl> - enum class CodeType : u32 { <nl> - / / 0TMR00AA AAAAAAAA YYYYYYYY YYYYYYYY <nl> - / / Writes a T sized value Y to the address A added to the value of register R in memory domain M <nl> - WriteImmediate = 0 , <nl> - <nl> - / / 1TMC00AA AAAAAAAA YYYYYYYY YYYYYYYY <nl> - / / Compares the T sized value Y to the value at address A in memory domain M using the <nl> - / / conditional function C . If success , continues execution . If failure , jumps to the matching <nl> - / / EndConditional statement . <nl> - Conditional = 1 , <nl> - <nl> - / / 20000000 <nl> - / / Terminates a Conditional or ConditionalInput block . <nl> - EndConditional = 2 , <nl> - <nl> - / / 300R0000 VVVVVVVV <nl> - / / Starts looping V times , storing the current count in register R . <nl> - / / Loop block is terminated with a matching 310R0000 . <nl> - Loop = 3 , <nl> - <nl> - / / 400R0000 VVVVVVVV VVVVVVVV <nl> - / / Sets the value of register R to the value V . <nl> - LoadImmediate = 4 , <nl> - <nl> - / / 5TMRI0AA AAAAAAAA <nl> - / / Sets the value of register R to the value of width T at address A in memory domain M , with <nl> - / / the current value of R added to the address if I = = 1 . <nl> - LoadIndexed = 5 , <nl> - <nl> - / / 6T0RIFG0 VVVVVVVV VVVVVVVV <nl> - / / Writes the value V of width T to the memory address stored in register R . Adds the value of <nl> - / / register G to the final calculation if F is nonzero . Increments the value of register R by T <nl> - / / after operation if I is nonzero . <nl> - StoreIndexed = 6 , <nl> - <nl> - / / 7T0RA000 VVVVVVVV <nl> - / / Performs the arithmetic operation A on the value in register R and the value V of width T , <nl> - / / storing the result in register R . <nl> - RegisterArithmetic = 7 , <nl> - <nl> - / / 8KKKKKKK <nl> - / / Checks to see if any of the buttons defined by the bitmask K are pressed . If any are , <nl> - / / execution continues . If none are , execution skips to the next EndConditional command . <nl> - ConditionalInput = 8 , <nl> - } ; <nl> - <nl> - enum class MemoryType : u32 { <nl> - / / Addressed relative to start of main NSO <nl> - MainNSO = 0 , <nl> - <nl> - / / Addressed relative to start of heap <nl> - Heap = 1 , <nl> - } ; <nl> - <nl> - enum class ArithmeticOp : u32 { <nl> - Add = 0 , <nl> - Sub = 1 , <nl> - Mult = 2 , <nl> - LShift = 3 , <nl> - RShift = 4 , <nl> - } ; <nl> - <nl> - enum class ComparisonOp : u32 { <nl> - GreaterThan = 1 , <nl> - GreaterThanEqual = 2 , <nl> - LessThan = 3 , <nl> - LessThanEqual = 4 , <nl> - Equal = 5 , <nl> - Inequal = 6 , <nl> - } ; <nl> - <nl> - union Cheat { <nl> - std : : array < u8 , 16 > raw ; <nl> - <nl> - BitField < 4 , 4 , CodeType > type ; <nl> - BitField < 0 , 4 , u32 > width ; / / Can be 1 , 2 , 4 , or 8 . Measured in bytes . <nl> - BitField < 0 , 4 , u32 > end_of_loop ; <nl> - BitField < 12 , 4 , MemoryType > memory_type ; <nl> - BitField < 8 , 4 , u32 > register_3 ; <nl> - BitField < 8 , 4 , ComparisonOp > comparison_op ; <nl> - BitField < 20 , 4 , u32 > load_from_register ; <nl> - BitField < 20 , 4 , u32 > increment_register ; <nl> - BitField < 20 , 4 , ArithmeticOp > arithmetic_op ; <nl> - BitField < 16 , 4 , u32 > add_additional_register ; <nl> - BitField < 28 , 4 , u32 > register_6 ; <nl> - <nl> - u64 Address ( ) const ; <nl> - u64 ValueWidth ( u64 offset ) const ; <nl> - u64 Value ( u64 offset , u64 width ) const ; <nl> - u32 KeypadValue ( ) const ; <nl> - } ; <nl> - <nl> - class CheatParser ; <nl> - <nl> - / / Represents a full collection of cheats for a game . The Execute function should be called every <nl> - / / interval that all cheats should be executed . Clients should not directly instantiate this class <nl> - / / ( hence private constructor ) , they should instead receive an instance from CheatParser , which <nl> - / / guarantees the list is always in an acceptable state . <nl> - class CheatList { <nl> - public : <nl> - friend class CheatParser ; <nl> - <nl> - using Block = std : : vector < Cheat > ; <nl> - using ProgramSegment = std : : vector < std : : pair < std : : string , Block > > ; <nl> - <nl> - / / ( width in bytes , address , value ) <nl> - using MemoryWriter = void ( * ) ( u32 , VAddr , u64 ) ; <nl> - / / ( width in bytes , address ) - > value <nl> - using MemoryReader = u64 ( * ) ( u32 , VAddr ) ; <nl> - <nl> - void SetMemoryParameters ( VAddr main_begin , VAddr heap_begin , VAddr main_end , VAddr heap_end , <nl> - MemoryWriter writer , MemoryReader reader ) ; <nl> - <nl> - void Execute ( ) ; <nl> - <nl> - private : <nl> - CheatList ( const Core : : System & system_ , ProgramSegment master , ProgramSegment standard ) ; <nl> - <nl> - void ProcessBlockPairs ( const Block & block ) ; <nl> - void ExecuteSingleCheat ( const Cheat & cheat ) ; <nl> - <nl> - void ExecuteBlock ( const Block & block ) ; <nl> - <nl> - bool EvaluateConditional ( const Cheat & cheat ) const ; <nl> - <nl> - / / Individual cheat operations <nl> - void WriteImmediate ( const Cheat & cheat ) ; <nl> - void BeginConditional ( const Cheat & cheat ) ; <nl> - void EndConditional ( const Cheat & cheat ) ; <nl> - void Loop ( const Cheat & cheat ) ; <nl> - void LoadImmediate ( const Cheat & cheat ) ; <nl> - void LoadIndexed ( const Cheat & cheat ) ; <nl> - void StoreIndexed ( const Cheat & cheat ) ; <nl> - void RegisterArithmetic ( const Cheat & cheat ) ; <nl> - void BeginConditionalInput ( const Cheat & cheat ) ; <nl> - <nl> - VAddr SanitizeAddress ( VAddr in ) const ; <nl> - <nl> - / / Master Codes are defined as codes that cannot be disabled and are run prior to all <nl> - / / others . <nl> - ProgramSegment master_list ; <nl> - / / All other codes <nl> - ProgramSegment standard_list ; <nl> - <nl> - bool in_standard = false ; <nl> - <nl> - / / 16 ( 0x0 - 0xF ) scratch registers that can be used by cheats <nl> - std : : array < u64 , 16 > scratch { } ; <nl> - <nl> - MemoryWriter writer = nullptr ; <nl> - MemoryReader reader = nullptr ; <nl> - <nl> - u64 main_region_begin { } ; <nl> - u64 heap_region_begin { } ; <nl> - u64 main_region_end { } ; <nl> - u64 heap_region_end { } ; <nl> - <nl> - u64 current_block { } ; <nl> - / / The current index of the cheat within the current Block <nl> - u64 current_index { } ; <nl> - <nl> - / / The ' stack ' of the program . When a conditional or loop statement is encountered , its index is <nl> - / / pushed onto this queue . When a end block is encountered , the condition is checked . <nl> - std : : map < u64 , u64 > block_pairs ; <nl> - <nl> - std : : set < u64 > encountered_loops ; <nl> - <nl> - const Core : : System * system ; <nl> - } ; <nl> - <nl> - / / Intermediary class that parses a text file or other disk format for storing cheats into a <nl> - / / CheatList object , that can be used for execution . <nl> - class CheatParser { <nl> - public : <nl> - virtual ~ CheatParser ( ) ; <nl> - <nl> - virtual CheatList Parse ( const Core : : System & system , const std : : vector < u8 > & data ) const = 0 ; <nl> - <nl> - protected : <nl> - CheatList MakeCheatList ( const Core : : System & system_ , CheatList : : ProgramSegment master , <nl> - CheatList : : ProgramSegment standard ) const ; <nl> - } ; <nl> - <nl> - / / CheatParser implementation that parses text files <nl> - class TextCheatParser final : public CheatParser { <nl> - public : <nl> - ~ TextCheatParser ( ) override ; <nl> - <nl> - CheatList Parse ( const Core : : System & system , const std : : vector < u8 > & data ) const override ; <nl> - <nl> - private : <nl> - std : : array < u8 , 16 > ParseSingleLineCheat ( const std : : string & line ) const ; <nl> - } ; <nl> - <nl> - / / Class that encapsulates a CheatList and manages its interaction with memory and CoreTiming <nl> - class CheatEngine final { <nl> - public : <nl> - CheatEngine ( Core : : System & system_ , std : : vector < CheatList > cheats_ , const std : : string & build_id , <nl> - VAddr code_region_start , VAddr code_region_end ) ; <nl> - ~ CheatEngine ( ) ; <nl> - <nl> - private : <nl> - void FrameCallback ( u64 userdata , s64 cycles_late ) ; <nl> - <nl> - std : : vector < CheatList > cheats ; <nl> - <nl> - Core : : Timing : : EventType * event ; <nl> - Core : : Timing : : CoreTiming & core_timing ; <nl> - } ; <nl> - <nl> - } / / namespace FileSys <nl> mmm a / src / core / file_sys / patch_manager . cpp <nl> ppp b / src / core / file_sys / patch_manager . cpp <nl> <nl> # include " core / hle / service / filesystem / filesystem . h " <nl> # include " core / loader / loader . h " <nl> # include " core / loader / nso . h " <nl> + # include " core / memory / cheat_engine . h " <nl> # include " core / settings . h " <nl> <nl> namespace FileSys { <nl> bool PatchManager : : HasNSOPatch ( const std : : array < u8 , 32 > & build_id_ ) const { <nl> return ! CollectPatches ( patch_dirs , build_id ) . empty ( ) ; <nl> } <nl> <nl> - static std : : optional < CheatList > ReadCheatFileFromFolder ( const Core : : System & system , u64 title_id , <nl> - const std : : array < u8 , 0x20 > & build_id_ , <nl> - const VirtualDir & base_path , bool upper ) { <nl> + namespace { <nl> + std : : optional < std : : vector < Memory : : CheatEntry > > ReadCheatFileFromFolder ( <nl> + const Core : : System & system , u64 title_id , const std : : array < u8 , 0x20 > & build_id_ , <nl> + const VirtualDir & base_path , bool upper ) { <nl> const auto build_id_raw = Common : : HexToString ( build_id_ , upper ) ; <nl> const auto build_id = build_id_raw . substr ( 0 , sizeof ( u64 ) * 2 ) ; <nl> const auto file = base_path - > GetFile ( fmt : : format ( " { } . txt " , build_id ) ) ; <nl> static std : : optional < CheatList > ReadCheatFileFromFolder ( const Core : : System & syst <nl> return std : : nullopt ; <nl> } <nl> <nl> - TextCheatParser parser ; <nl> - return parser . Parse ( system , data ) ; <nl> + Memory : : TextCheatParser parser ; <nl> + return parser . Parse ( <nl> + system , std : : string_view ( reinterpret_cast < const char * const > ( data . data ( ) ) , data . size ( ) ) ) ; <nl> } <nl> <nl> - std : : vector < CheatList > PatchManager : : CreateCheatList ( const Core : : System & system , <nl> - const std : : array < u8 , 32 > & build_id_ ) const { <nl> - const auto load_dir = <nl> - Core : : System : : GetInstance ( ) . GetFileSystemController ( ) . GetModificationLoadRoot ( title_id ) ; <nl> + } / / Anonymous namespace <nl> + <nl> + std : : vector < Memory : : CheatEntry > PatchManager : : CreateCheatList ( <nl> + const Core : : System & system , const std : : array < u8 , 32 > & build_id_ ) const { <nl> + const auto load_dir = system . GetFileSystemController ( ) . GetModificationLoadRoot ( title_id ) ; <nl> if ( load_dir = = nullptr ) { <nl> LOG_ERROR ( Loader , " Cannot load mods for invalid title_id = { : 016X } " , title_id ) ; <nl> return { } ; <nl> std : : vector < CheatList > PatchManager : : CreateCheatList ( const Core : : System & system , <nl> std : : sort ( patch_dirs . begin ( ) , patch_dirs . end ( ) , <nl> [ ] ( const VirtualDir & l , const VirtualDir & r ) { return l - > GetName ( ) < r - > GetName ( ) ; } ) ; <nl> <nl> - std : : vector < CheatList > out ; <nl> - out . reserve ( patch_dirs . size ( ) ) ; <nl> + std : : vector < Memory : : CheatEntry > out ; <nl> for ( const auto & subdir : patch_dirs ) { <nl> auto cheats_dir = subdir - > GetSubdirectory ( " cheats " ) ; <nl> if ( cheats_dir ! = nullptr ) { <nl> auto res = ReadCheatFileFromFolder ( system , title_id , build_id_ , cheats_dir , true ) ; <nl> if ( res . has_value ( ) ) { <nl> - out . push_back ( std : : move ( * res ) ) ; <nl> + std : : copy ( res - > begin ( ) , res - > end ( ) , std : : back_inserter ( out ) ) ; <nl> continue ; <nl> } <nl> <nl> res = ReadCheatFileFromFolder ( system , title_id , build_id_ , cheats_dir , false ) ; <nl> - if ( res . has_value ( ) ) <nl> - out . push_back ( std : : move ( * res ) ) ; <nl> + if ( res . has_value ( ) ) { <nl> + std : : copy ( res - > begin ( ) , res - > end ( ) , std : : back_inserter ( out ) ) ; <nl> + } <nl> } <nl> } <nl> <nl> mmm a / src / core / file_sys / patch_manager . h <nl> ppp b / src / core / file_sys / patch_manager . h <nl> <nl> # include < memory > <nl> # include < string > <nl> # include " common / common_types . h " <nl> - # include " core / file_sys / cheat_engine . h " <nl> # include " core / file_sys / nca_metadata . h " <nl> # include " core / file_sys / vfs . h " <nl> + # include " core / memory / dmnt_cheat_types . h " <nl> <nl> namespace Core { <nl> class System ; <nl> class PatchManager { <nl> bool HasNSOPatch ( const std : : array < u8 , 0x20 > & build_id ) const ; <nl> <nl> / / Creates a CheatList object with all <nl> - std : : vector < CheatList > CreateCheatList ( const Core : : System & system , <nl> - const std : : array < u8 , 0x20 > & build_id ) const ; <nl> + std : : vector < Memory : : CheatEntry > CreateCheatList ( const Core : : System & system , <nl> + const std : : array < u8 , 0x20 > & build_id ) const ; <nl> <nl> / / Currently tracked RomFS patches : <nl> / / - Game Updates <nl> mmm a / src / core / loader / nso . cpp <nl> ppp b / src / core / loader / nso . cpp <nl> std : : optional < VAddr > AppLoader_NSO : : LoadModule ( Kernel : : Process & process , <nl> auto & system = Core : : System : : GetInstance ( ) ; <nl> const auto cheats = pm - > CreateCheatList ( system , nso_header . build_id ) ; <nl> if ( ! cheats . empty ( ) ) { <nl> - system . RegisterCheatList ( cheats , Common : : HexToString ( nso_header . build_id ) , load_base , <nl> - load_base + program_image . size ( ) ) ; <nl> + system . RegisterCheatList ( cheats , nso_header . build_id , load_base , image_size ) ; <nl> } <nl> } <nl> <nl> new file mode 100644 <nl> index 00000000000 . . b56cb06277f <nl> mmm / dev / null <nl> ppp b / src / core / memory / cheat_engine . cpp <nl> <nl> + / / Copyright 2018 yuzu emulator team <nl> + / / Licensed under GPLv2 or any later version <nl> + / / Refer to the license . txt file included . <nl> + <nl> + # include < locale > <nl> + # include " common / hex_util . h " <nl> + # include " common / microprofile . h " <nl> + # include " common / swap . h " <nl> + # include " core / core . h " <nl> + # include " core / core_timing . h " <nl> + # include " core / core_timing_util . h " <nl> + # include " core / hle / kernel / process . h " <nl> + # include " core / hle / service / hid / controllers / npad . h " <nl> + # include " core / hle / service / hid / hid . h " <nl> + # include " core / hle / service / sm / sm . h " <nl> + # include " core / memory / cheat_engine . h " <nl> + <nl> + namespace Memory { <nl> + <nl> + constexpr s64 CHEAT_ENGINE_TICKS = static_cast < s64 > ( Core : : Timing : : BASE_CLOCK_RATE / 12 ) ; <nl> + constexpr u32 KEYPAD_BITMASK = 0x3FFFFFF ; <nl> + <nl> + StandardVmCallbacks : : StandardVmCallbacks ( const Core : : System & system , <nl> + const CheatProcessMetadata & metadata ) <nl> + : system ( system ) , metadata ( metadata ) { } <nl> + <nl> + StandardVmCallbacks : : ~ StandardVmCallbacks ( ) = default ; <nl> + <nl> + void StandardVmCallbacks : : MemoryRead ( VAddr address , void * data , u64 size ) { <nl> + ReadBlock ( SanitizeAddress ( address ) , data , size ) ; <nl> + } <nl> + <nl> + void StandardVmCallbacks : : MemoryWrite ( VAddr address , const void * data , u64 size ) { <nl> + WriteBlock ( SanitizeAddress ( address ) , data , size ) ; <nl> + } <nl> + <nl> + u64 StandardVmCallbacks : : HidKeysDown ( ) { <nl> + const auto applet_resource = <nl> + system . ServiceManager ( ) . GetService < Service : : HID : : Hid > ( " hid " ) - > GetAppletResource ( ) ; <nl> + if ( applet_resource = = nullptr ) { <nl> + LOG_WARNING ( CheatEngine , <nl> + " Attempted to read input state , but applet resource is not initialized ! " ) ; <nl> + return false ; <nl> + } <nl> + <nl> + const auto press_state = <nl> + applet_resource <nl> + - > GetController < Service : : HID : : Controller_NPad > ( Service : : HID : : HidController : : NPad ) <nl> + . GetAndResetPressState ( ) ; <nl> + return press_state & KEYPAD_BITMASK ; <nl> + } <nl> + <nl> + void StandardVmCallbacks : : DebugLog ( u8 id , u64 value ) { <nl> + LOG_INFO ( CheatEngine , " Cheat triggered DebugLog : ID ' { : 01X } ' Value ' { : 016X } ' " , id , value ) ; <nl> + } <nl> + <nl> + void StandardVmCallbacks : : CommandLog ( std : : string_view data ) { <nl> + LOG_DEBUG ( CheatEngine , " [ DmntCheatVm ] : { } " , <nl> + data . back ( ) = = ' \ n ' ? data . substr ( 0 , data . size ( ) - 1 ) : data ) ; <nl> + } <nl> + <nl> + VAddr StandardVmCallbacks : : SanitizeAddress ( VAddr in ) const { <nl> + if ( ( in < metadata . main_nso_extents . base | | <nl> + in > = metadata . main_nso_extents . base + metadata . main_nso_extents . size ) & & <nl> + ( in < metadata . heap_extents . base | | <nl> + in > = metadata . heap_extents . base + metadata . heap_extents . size ) ) { <nl> + LOG_ERROR ( CheatEngine , <nl> + " Cheat attempting to access memory at invalid address = { : 016X } , if this " <nl> + " persists , " <nl> + " the cheat may be incorrect . However , this may be normal early in execution if " <nl> + " the game has not properly set up yet . " , <nl> + in ) ; <nl> + return 0 ; / / / < Invalid addresses will hard crash <nl> + } <nl> + <nl> + return in ; <nl> + } <nl> + <nl> + CheatParser : : ~ CheatParser ( ) = default ; <nl> + <nl> + TextCheatParser : : ~ TextCheatParser ( ) = default ; <nl> + <nl> + namespace { <nl> + template < char match > <nl> + std : : string_view ExtractName ( std : : string_view data , std : : size_t start_index ) { <nl> + auto end_index = start_index ; <nl> + while ( data [ end_index ] ! = match ) { <nl> + + + end_index ; <nl> + if ( end_index > data . size ( ) | | <nl> + ( end_index - start_index - 1 ) > sizeof ( CheatDefinition : : readable_name ) ) { <nl> + return { } ; <nl> + } <nl> + } <nl> + <nl> + return data . substr ( start_index , end_index - start_index ) ; <nl> + } <nl> + } / / Anonymous namespace <nl> + <nl> + std : : vector < CheatEntry > TextCheatParser : : Parse ( const Core : : System & system , <nl> + std : : string_view data ) const { <nl> + std : : vector < CheatEntry > out ( 1 ) ; <nl> + std : : optional < u64 > current_entry = std : : nullopt ; <nl> + <nl> + for ( std : : size_t i = 0 ; i < data . size ( ) ; + + i ) { <nl> + if ( : : isspace ( data [ i ] ) ) { <nl> + continue ; <nl> + } <nl> + <nl> + if ( data [ i ] = = ' { ' ) { <nl> + current_entry = 0 ; <nl> + <nl> + if ( out [ * current_entry ] . definition . num_opcodes > 0 ) { <nl> + return { } ; <nl> + } <nl> + <nl> + const auto name = ExtractName < ' } ' > ( data , i + 1 ) ; <nl> + if ( name . empty ( ) ) { <nl> + return { } ; <nl> + } <nl> + <nl> + std : : memcpy ( out [ * current_entry ] . definition . readable_name . data ( ) , name . data ( ) , <nl> + std : : min < std : : size_t > ( out [ * current_entry ] . definition . readable_name . size ( ) , <nl> + name . size ( ) ) ) ; <nl> + out [ * current_entry ] <nl> + . definition . readable_name [ out [ * current_entry ] . definition . readable_name . size ( ) - 1 ] = <nl> + ' \ 0 ' ; <nl> + <nl> + i + = name . length ( ) + 1 ; <nl> + } else if ( data [ i ] = = ' [ ' ) { <nl> + current_entry = out . size ( ) ; <nl> + out . emplace_back ( ) ; <nl> + <nl> + const auto name = ExtractName < ' ] ' > ( data , i + 1 ) ; <nl> + if ( name . empty ( ) ) { <nl> + return { } ; <nl> + } <nl> + <nl> + std : : memcpy ( out [ * current_entry ] . definition . readable_name . data ( ) , name . data ( ) , <nl> + std : : min < std : : size_t > ( out [ * current_entry ] . definition . readable_name . size ( ) , <nl> + name . size ( ) ) ) ; <nl> + out [ * current_entry ] <nl> + . definition . readable_name [ out [ * current_entry ] . definition . readable_name . size ( ) - 1 ] = <nl> + ' \ 0 ' ; <nl> + <nl> + i + = name . length ( ) + 1 ; <nl> + } else if ( : : isxdigit ( data [ i ] ) ) { <nl> + if ( ! current_entry | | out [ * current_entry ] . definition . num_opcodes > = <nl> + out [ * current_entry ] . definition . opcodes . size ( ) ) { <nl> + return { } ; <nl> + } <nl> + <nl> + const auto hex = std : : string ( data . substr ( i , 8 ) ) ; <nl> + if ( ! std : : all_of ( hex . begin ( ) , hex . end ( ) , : : isxdigit ) ) { <nl> + return { } ; <nl> + } <nl> + <nl> + out [ * current_entry ] . definition . opcodes [ out [ * current_entry ] . definition . num_opcodes + + ] = <nl> + std : : stoul ( hex , nullptr , 0x10 ) ; <nl> + <nl> + i + = 8 ; <nl> + } else { <nl> + return { } ; <nl> + } <nl> + } <nl> + <nl> + out [ 0 ] . enabled = out [ 0 ] . definition . num_opcodes > 0 ; <nl> + out [ 0 ] . cheat_id = 0 ; <nl> + <nl> + for ( u32 i = 1 ; i < out . size ( ) ; + + i ) { <nl> + out [ i ] . enabled = out [ i ] . definition . num_opcodes > 0 ; <nl> + out [ i ] . cheat_id = i ; <nl> + } <nl> + <nl> + return out ; <nl> + } <nl> + <nl> + CheatEngine : : CheatEngine ( Core : : System & system , std : : vector < CheatEntry > cheats , <nl> + const std : : array < u8 , 0x20 > & build_id ) <nl> + : system { system } , core_timing { system . CoreTiming ( ) } , vm { std : : make_unique < StandardVmCallbacks > ( <nl> + system , metadata ) } , <nl> + cheats ( std : : move ( cheats ) ) { <nl> + metadata . main_nso_build_id = build_id ; <nl> + } <nl> + <nl> + CheatEngine : : ~ CheatEngine ( ) { <nl> + core_timing . UnscheduleEvent ( event , 0 ) ; <nl> + } <nl> + <nl> + void CheatEngine : : Initialize ( ) { <nl> + event = core_timing . RegisterEvent ( <nl> + " CheatEngine : : FrameCallback : : " + Common : : HexToString ( metadata . main_nso_build_id ) , <nl> + [ this ] ( u64 userdata , s64 cycles_late ) { FrameCallback ( userdata , cycles_late ) ; } ) ; <nl> + core_timing . ScheduleEvent ( CHEAT_ENGINE_TICKS , event ) ; <nl> + <nl> + metadata . process_id = system . CurrentProcess ( ) - > GetProcessID ( ) ; <nl> + metadata . title_id = system . CurrentProcess ( ) - > GetTitleID ( ) ; <nl> + <nl> + const auto & vm_manager = system . CurrentProcess ( ) - > VMManager ( ) ; <nl> + metadata . heap_extents = { vm_manager . GetHeapRegionBaseAddress ( ) , vm_manager . GetHeapRegionSize ( ) } ; <nl> + metadata . address_space_extents = { vm_manager . GetAddressSpaceBaseAddress ( ) , <nl> + vm_manager . GetAddressSpaceSize ( ) } ; <nl> + metadata . alias_extents = { vm_manager . GetMapRegionBaseAddress ( ) , vm_manager . GetMapRegionSize ( ) } ; <nl> + <nl> + is_pending_reload . exchange ( true ) ; <nl> + } <nl> + <nl> + void CheatEngine : : SetMainMemoryParameters ( VAddr main_region_begin , u64 main_region_size ) { <nl> + metadata . main_nso_extents = { main_region_begin , main_region_size } ; <nl> + } <nl> + <nl> + void CheatEngine : : Reload ( std : : vector < CheatEntry > cheats ) { <nl> + this - > cheats = std : : move ( cheats ) ; <nl> + is_pending_reload . exchange ( true ) ; <nl> + } <nl> + <nl> + MICROPROFILE_DEFINE ( Cheat_Engine , " Add - Ons " , " Cheat Engine " , MP_RGB ( 70 , 200 , 70 ) ) ; <nl> + <nl> + void CheatEngine : : FrameCallback ( u64 userdata , s64 cycles_late ) { <nl> + if ( is_pending_reload . exchange ( false ) ) { <nl> + vm . LoadProgram ( cheats ) ; <nl> + } <nl> + <nl> + if ( vm . GetProgramSize ( ) = = 0 ) { <nl> + return ; <nl> + } <nl> + <nl> + MICROPROFILE_SCOPE ( Cheat_Engine ) ; <nl> + <nl> + vm . Execute ( metadata ) ; <nl> + <nl> + core_timing . ScheduleEvent ( CHEAT_ENGINE_TICKS - cycles_late , event ) ; <nl> + } <nl> + <nl> + } / / namespace Memory <nl> new file mode 100644 <nl> index 00000000000 . . 0f012e9b5c1 <nl> mmm / dev / null <nl> ppp b / src / core / memory / cheat_engine . h <nl> <nl> + / / Copyright 2018 yuzu emulator team <nl> + / / Licensed under GPLv2 or any later version <nl> + / / Refer to the license . txt file included . <nl> + <nl> + # pragma once <nl> + <nl> + # include < atomic > <nl> + # include < vector > <nl> + # include " common / common_types . h " <nl> + # include " core / memory / dmnt_cheat_types . h " <nl> + # include " core / memory / dmnt_cheat_vm . h " <nl> + <nl> + namespace Core { <nl> + class System ; <nl> + } <nl> + <nl> + namespace Core : : Timing { <nl> + class CoreTiming ; <nl> + struct EventType ; <nl> + } / / namespace Core : : Timing <nl> + <nl> + namespace Memory { <nl> + <nl> + class StandardVmCallbacks : public DmntCheatVm : : Callbacks { <nl> + public : <nl> + StandardVmCallbacks ( const Core : : System & system , const CheatProcessMetadata & metadata ) ; <nl> + ~ StandardVmCallbacks ( ) override ; <nl> + <nl> + void MemoryRead ( VAddr address , void * data , u64 size ) override ; <nl> + void MemoryWrite ( VAddr address , const void * data , u64 size ) override ; <nl> + u64 HidKeysDown ( ) override ; <nl> + void DebugLog ( u8 id , u64 value ) override ; <nl> + void CommandLog ( std : : string_view data ) override ; <nl> + <nl> + private : <nl> + VAddr SanitizeAddress ( VAddr address ) const ; <nl> + <nl> + const CheatProcessMetadata & metadata ; <nl> + const Core : : System & system ; <nl> + } ; <nl> + <nl> + / / Intermediary class that parses a text file or other disk format for storing cheats into a <nl> + / / CheatList object , that can be used for execution . <nl> + class CheatParser { <nl> + public : <nl> + virtual ~ CheatParser ( ) ; <nl> + <nl> + virtual std : : vector < CheatEntry > Parse ( const Core : : System & system , <nl> + std : : string_view data ) const = 0 ; <nl> + } ; <nl> + <nl> + / / CheatParser implementation that parses text files <nl> + class TextCheatParser final : public CheatParser { <nl> + public : <nl> + ~ TextCheatParser ( ) override ; <nl> + <nl> + std : : vector < CheatEntry > Parse ( const Core : : System & system , std : : string_view data ) const override ; <nl> + } ; <nl> + <nl> + / / Class that encapsulates a CheatList and manages its interaction with memory and CoreTiming <nl> + class CheatEngine final { <nl> + public : <nl> + CheatEngine ( Core : : System & system_ , std : : vector < CheatEntry > cheats_ , <nl> + const std : : array < u8 , 0x20 > & build_id ) ; <nl> + ~ CheatEngine ( ) ; <nl> + <nl> + void Initialize ( ) ; <nl> + void SetMainMemoryParameters ( VAddr main_region_begin , u64 main_region_size ) ; <nl> + <nl> + void Reload ( std : : vector < CheatEntry > cheats ) ; <nl> + <nl> + private : <nl> + void FrameCallback ( u64 userdata , s64 cycles_late ) ; <nl> + <nl> + DmntCheatVm vm ; <nl> + CheatProcessMetadata metadata ; <nl> + <nl> + std : : vector < CheatEntry > cheats ; <nl> + std : : atomic_bool is_pending_reload { false } ; <nl> + <nl> + Core : : Timing : : EventType * event { } ; <nl> + Core : : Timing : : CoreTiming & core_timing ; <nl> + Core : : System & system ; <nl> + } ; <nl> + <nl> + } / / namespace Memory <nl> new file mode 100644 <nl> index 00000000000 . . bf68fa0fe97 <nl> mmm / dev / null <nl> ppp b / src / core / memory / dmnt_cheat_types . h <nl> <nl> + / * <nl> + * Copyright ( c ) 2018 - 2019 Atmosphère - NX <nl> + * <nl> + * This program is free software ; you can redistribute it and / or modify it <nl> + * under the terms and conditions of the GNU General Public License , <nl> + * version 2 , as published by the Free Software Foundation . <nl> + * <nl> + * This program is distributed in the hope it will be useful , but WITHOUT <nl> + * ANY WARRANTY ; without even the implied warranty of MERCHANTABILITY or <nl> + * FITNESS FOR A PARTICULAR PURPOSE . See the GNU General Public License for <nl> + * more details . <nl> + * <nl> + * You should have received a copy of the GNU General Public License <nl> + * along with this program . If not , see < http : / / www . gnu . org / licenses / > . <nl> + * / <nl> + <nl> + / * <nl> + * Adapted by DarkLordZach for use / interaction with yuzu <nl> + * <nl> + * Modifications Copyright 2019 yuzu emulator team <nl> + * Licensed under GPLv2 or any later version <nl> + * Refer to the license . txt file included . <nl> + * / <nl> + <nl> + # pragma once <nl> + <nl> + # include " common / common_types . h " <nl> + <nl> + namespace Memory { <nl> + <nl> + struct MemoryRegionExtents { <nl> + u64 base { } ; <nl> + u64 size { } ; <nl> + } ; <nl> + <nl> + struct CheatProcessMetadata { <nl> + u64 process_id { } ; <nl> + u64 title_id { } ; <nl> + MemoryRegionExtents main_nso_extents { } ; <nl> + MemoryRegionExtents heap_extents { } ; <nl> + MemoryRegionExtents alias_extents { } ; <nl> + MemoryRegionExtents address_space_extents { } ; <nl> + std : : array < u8 , 0x20 > main_nso_build_id { } ; <nl> + } ; <nl> + <nl> + struct CheatDefinition { <nl> + std : : array < char , 0x40 > readable_name { } ; <nl> + u32 num_opcodes { } ; <nl> + std : : array < u32 , 0x100 > opcodes { } ; <nl> + } ; <nl> + <nl> + struct CheatEntry { <nl> + bool enabled { } ; <nl> + u32 cheat_id { } ; <nl> + CheatDefinition definition { } ; <nl> + } ; <nl> + <nl> + } / / namespace Memory <nl> new file mode 100644 <nl> index 00000000000 . . cc16d15a4c2 <nl> mmm / dev / null <nl> ppp b / src / core / memory / dmnt_cheat_vm . cpp <nl> <nl> + / * <nl> + * Copyright ( c ) 2018 - 2019 Atmosphère - NX <nl> + * <nl> + * This program is free software ; you can redistribute it and / or modify it <nl> + * under the terms and conditions of the GNU General Public License , <nl> + * version 2 , as published by the Free Software Foundation . <nl> + * <nl> + * This program is distributed in the hope it will be useful , but WITHOUT <nl> + * ANY WARRANTY ; without even the implied warranty of MERCHANTABILITY or <nl> + * FITNESS FOR A PARTICULAR PURPOSE . See the GNU General Public License for <nl> + * more details . <nl> + * <nl> + * You should have received a copy of the GNU General Public License <nl> + * along with this program . If not , see < http : / / www . gnu . org / licenses / > . <nl> + * / <nl> + <nl> + / * <nl> + * Adapted by DarkLordZach for use / interaction with yuzu <nl> + * <nl> + * Modifications Copyright 2019 yuzu emulator team <nl> + * Licensed under GPLv2 or any later version <nl> + * Refer to the license . txt file included . <nl> + * / <nl> + <nl> + # include " common / assert . h " <nl> + # include " common / scope_exit . h " <nl> + # include " core / memory / dmnt_cheat_types . h " <nl> + # include " core / memory / dmnt_cheat_vm . h " <nl> + <nl> + namespace Memory { <nl> + <nl> + DmntCheatVm : : DmntCheatVm ( std : : unique_ptr < Callbacks > callbacks ) : callbacks ( std : : move ( callbacks ) ) { } <nl> + <nl> + DmntCheatVm : : ~ DmntCheatVm ( ) = default ; <nl> + <nl> + void DmntCheatVm : : DebugLog ( u32 log_id , u64 value ) { <nl> + callbacks - > DebugLog ( static_cast < u8 > ( log_id ) , value ) ; <nl> + } <nl> + <nl> + void DmntCheatVm : : LogOpcode ( const CheatVmOpcode & opcode ) { <nl> + if ( auto store_static = std : : get_if < StoreStaticOpcode > ( & opcode . opcode ) ) { <nl> + callbacks - > CommandLog ( " Opcode : Store Static " ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Bit Width : { : X } " , store_static - > bit_width ) ) ; <nl> + callbacks - > CommandLog ( <nl> + fmt : : format ( " Mem Type : { : X } " , static_cast < u32 > ( store_static - > mem_type ) ) ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Reg Idx : { : X } " , store_static - > offset_register ) ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Rel Addr : { : X } " , store_static - > rel_address ) ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Value : { : X } " , store_static - > value . bit64 ) ) ; <nl> + } else if ( auto begin_cond = std : : get_if < BeginConditionalOpcode > ( & opcode . opcode ) ) { <nl> + callbacks - > CommandLog ( " Opcode : Begin Conditional " ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Bit Width : { : X } " , begin_cond - > bit_width ) ) ; <nl> + callbacks - > CommandLog ( <nl> + fmt : : format ( " Mem Type : { : X } " , static_cast < u32 > ( begin_cond - > mem_type ) ) ) ; <nl> + callbacks - > CommandLog ( <nl> + fmt : : format ( " Cond Type : { : X } " , static_cast < u32 > ( begin_cond - > cond_type ) ) ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Rel Addr : { : X } " , begin_cond - > rel_address ) ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Value : { : X } " , begin_cond - > value . bit64 ) ) ; <nl> + } else if ( auto end_cond = std : : get_if < EndConditionalOpcode > ( & opcode . opcode ) ) { <nl> + callbacks - > CommandLog ( " Opcode : End Conditional " ) ; <nl> + } else if ( auto ctrl_loop = std : : get_if < ControlLoopOpcode > ( & opcode . opcode ) ) { <nl> + if ( ctrl_loop - > start_loop ) { <nl> + callbacks - > CommandLog ( " Opcode : Start Loop " ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Reg Idx : { : X } " , ctrl_loop - > reg_index ) ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Num Iters : { : X } " , ctrl_loop - > num_iters ) ) ; <nl> + } else { <nl> + callbacks - > CommandLog ( " Opcode : End Loop " ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Reg Idx : { : X } " , ctrl_loop - > reg_index ) ) ; <nl> + } <nl> + } else if ( auto ldr_static = std : : get_if < LoadRegisterStaticOpcode > ( & opcode . opcode ) ) { <nl> + callbacks - > CommandLog ( " Opcode : Load Register Static " ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Reg Idx : { : X } " , ldr_static - > reg_index ) ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Value : { : X } " , ldr_static - > value ) ) ; <nl> + } else if ( auto ldr_memory = std : : get_if < LoadRegisterMemoryOpcode > ( & opcode . opcode ) ) { <nl> + callbacks - > CommandLog ( " Opcode : Load Register Memory " ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Bit Width : { : X } " , ldr_memory - > bit_width ) ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Reg Idx : { : X } " , ldr_memory - > reg_index ) ) ; <nl> + callbacks - > CommandLog ( <nl> + fmt : : format ( " Mem Type : { : X } " , static_cast < u32 > ( ldr_memory - > mem_type ) ) ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " From Reg : { : d } " , ldr_memory - > load_from_reg ) ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Rel Addr : { : X } " , ldr_memory - > rel_address ) ) ; <nl> + } else if ( auto str_static = std : : get_if < StoreStaticToAddressOpcode > ( & opcode . opcode ) ) { <nl> + callbacks - > CommandLog ( " Opcode : Store Static to Address " ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Bit Width : { : X } " , str_static - > bit_width ) ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Reg Idx : { : X } " , str_static - > reg_index ) ) ; <nl> + if ( str_static - > add_offset_reg ) { <nl> + callbacks - > CommandLog ( fmt : : format ( " O Reg Idx : { : X } " , str_static - > offset_reg_index ) ) ; <nl> + } <nl> + callbacks - > CommandLog ( fmt : : format ( " Incr Reg : { : d } " , str_static - > increment_reg ) ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Value : { : X } " , str_static - > value ) ) ; <nl> + } else if ( auto perform_math_static = <nl> + std : : get_if < PerformArithmeticStaticOpcode > ( & opcode . opcode ) ) { <nl> + callbacks - > CommandLog ( " Opcode : Perform Static Arithmetic " ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Bit Width : { : X } " , perform_math_static - > bit_width ) ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Reg Idx : { : X } " , perform_math_static - > reg_index ) ) ; <nl> + callbacks - > CommandLog ( <nl> + fmt : : format ( " Math Type : { : X } " , static_cast < u32 > ( perform_math_static - > math_type ) ) ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Value : { : X } " , perform_math_static - > value ) ) ; <nl> + } else if ( auto begin_keypress_cond = <nl> + std : : get_if < BeginKeypressConditionalOpcode > ( & opcode . opcode ) ) { <nl> + callbacks - > CommandLog ( " Opcode : Begin Keypress Conditional " ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Key Mask : { : X } " , begin_keypress_cond - > key_mask ) ) ; <nl> + } else if ( auto perform_math_reg = <nl> + std : : get_if < PerformArithmeticRegisterOpcode > ( & opcode . opcode ) ) { <nl> + callbacks - > CommandLog ( " Opcode : Perform Register Arithmetic " ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Bit Width : { : X } " , perform_math_reg - > bit_width ) ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Dst Idx : { : X } " , perform_math_reg - > dst_reg_index ) ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Src1 Idx : { : X } " , perform_math_reg - > src_reg_1_index ) ) ; <nl> + if ( perform_math_reg - > has_immediate ) { <nl> + callbacks - > CommandLog ( fmt : : format ( " Value : { : X } " , perform_math_reg - > value . bit64 ) ) ; <nl> + } else { <nl> + callbacks - > CommandLog ( <nl> + fmt : : format ( " Src2 Idx : { : X } " , perform_math_reg - > src_reg_2_index ) ) ; <nl> + } <nl> + } else if ( auto str_register = std : : get_if < StoreRegisterToAddressOpcode > ( & opcode . opcode ) ) { <nl> + callbacks - > CommandLog ( " Opcode : Store Register to Address " ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Bit Width : { : X } " , str_register - > bit_width ) ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " S Reg Idx : { : X } " , str_register - > str_reg_index ) ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " A Reg Idx : { : X } " , str_register - > addr_reg_index ) ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Incr Reg : { : d } " , str_register - > increment_reg ) ) ; <nl> + switch ( str_register - > ofs_type ) { <nl> + case StoreRegisterOffsetType : : None : <nl> + break ; <nl> + case StoreRegisterOffsetType : : Reg : <nl> + callbacks - > CommandLog ( fmt : : format ( " O Reg Idx : { : X } " , str_register - > ofs_reg_index ) ) ; <nl> + break ; <nl> + case StoreRegisterOffsetType : : Imm : <nl> + callbacks - > CommandLog ( fmt : : format ( " Rel Addr : { : X } " , str_register - > rel_address ) ) ; <nl> + break ; <nl> + case StoreRegisterOffsetType : : MemReg : <nl> + callbacks - > CommandLog ( <nl> + fmt : : format ( " Mem Type : { : X } " , static_cast < u32 > ( str_register - > mem_type ) ) ) ; <nl> + break ; <nl> + case StoreRegisterOffsetType : : MemImm : <nl> + case StoreRegisterOffsetType : : MemImmReg : <nl> + callbacks - > CommandLog ( <nl> + fmt : : format ( " Mem Type : { : X } " , static_cast < u32 > ( str_register - > mem_type ) ) ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Rel Addr : { : X } " , str_register - > rel_address ) ) ; <nl> + break ; <nl> + } <nl> + } else if ( auto begin_reg_cond = std : : get_if < BeginRegisterConditionalOpcode > ( & opcode . opcode ) ) { <nl> + callbacks - > CommandLog ( " Opcode : Begin Register Conditional " ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Bit Width : { : X } " , begin_reg_cond - > bit_width ) ) ; <nl> + callbacks - > CommandLog ( <nl> + fmt : : format ( " Cond Type : { : X } " , static_cast < u32 > ( begin_reg_cond - > cond_type ) ) ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " V Reg Idx : { : X } " , begin_reg_cond - > val_reg_index ) ) ; <nl> + switch ( begin_reg_cond - > comp_type ) { <nl> + case CompareRegisterValueType : : StaticValue : <nl> + callbacks - > CommandLog ( " Comp Type : Static Value " ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Value : { : X } " , begin_reg_cond - > value . bit64 ) ) ; <nl> + break ; <nl> + case CompareRegisterValueType : : OtherRegister : <nl> + callbacks - > CommandLog ( " Comp Type : Other Register " ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " X Reg Idx : { : X } " , begin_reg_cond - > other_reg_index ) ) ; <nl> + break ; <nl> + case CompareRegisterValueType : : MemoryRelAddr : <nl> + callbacks - > CommandLog ( " Comp Type : Memory Relative Address " ) ; <nl> + callbacks - > CommandLog ( <nl> + fmt : : format ( " Mem Type : { : X } " , static_cast < u32 > ( begin_reg_cond - > mem_type ) ) ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Rel Addr : { : X } " , begin_reg_cond - > rel_address ) ) ; <nl> + break ; <nl> + case CompareRegisterValueType : : MemoryOfsReg : <nl> + callbacks - > CommandLog ( " Comp Type : Memory Offset Register " ) ; <nl> + callbacks - > CommandLog ( <nl> + fmt : : format ( " Mem Type : { : X } " , static_cast < u32 > ( begin_reg_cond - > mem_type ) ) ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " O Reg Idx : { : X } " , begin_reg_cond - > ofs_reg_index ) ) ; <nl> + break ; <nl> + case CompareRegisterValueType : : RegisterRelAddr : <nl> + callbacks - > CommandLog ( " Comp Type : Register Relative Address " ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " A Reg Idx : { : X } " , begin_reg_cond - > addr_reg_index ) ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Rel Addr : { : X } " , begin_reg_cond - > rel_address ) ) ; <nl> + break ; <nl> + case CompareRegisterValueType : : RegisterOfsReg : <nl> + callbacks - > CommandLog ( " Comp Type : Register Offset Register " ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " A Reg Idx : { : X } " , begin_reg_cond - > addr_reg_index ) ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " O Reg Idx : { : X } " , begin_reg_cond - > ofs_reg_index ) ) ; <nl> + break ; <nl> + } <nl> + } else if ( auto save_restore_reg = std : : get_if < SaveRestoreRegisterOpcode > ( & opcode . opcode ) ) { <nl> + callbacks - > CommandLog ( " Opcode : Save or Restore Register " ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Dst Idx : { : X } " , save_restore_reg - > dst_index ) ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Src Idx : { : X } " , save_restore_reg - > src_index ) ) ; <nl> + callbacks - > CommandLog ( <nl> + fmt : : format ( " Op Type : { : d } " , static_cast < u32 > ( save_restore_reg - > op_type ) ) ) ; <nl> + } else if ( auto save_restore_regmask = <nl> + std : : get_if < SaveRestoreRegisterMaskOpcode > ( & opcode . opcode ) ) { <nl> + callbacks - > CommandLog ( " Opcode : Save or Restore Register Mask " ) ; <nl> + callbacks - > CommandLog ( <nl> + fmt : : format ( " Op Type : { : d } " , static_cast < u32 > ( save_restore_regmask - > op_type ) ) ) ; <nl> + for ( std : : size_t i = 0 ; i < NumRegisters ; i + + ) { <nl> + callbacks - > CommandLog ( <nl> + fmt : : format ( " Act [ { : 02X } ] : { : d } " , i , save_restore_regmask - > should_operate [ i ] ) ) ; <nl> + } <nl> + } else if ( auto debug_log = std : : get_if < DebugLogOpcode > ( & opcode . opcode ) ) { <nl> + callbacks - > CommandLog ( " Opcode : Debug Log " ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Bit Width : { : X } " , debug_log - > bit_width ) ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Log ID : { : X } " , debug_log - > log_id ) ) ; <nl> + callbacks - > CommandLog ( <nl> + fmt : : format ( " Val Type : { : X } " , static_cast < u32 > ( debug_log - > val_type ) ) ) ; <nl> + switch ( debug_log - > val_type ) { <nl> + case DebugLogValueType : : RegisterValue : <nl> + callbacks - > CommandLog ( " Val Type : Register Value " ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " X Reg Idx : { : X } " , debug_log - > val_reg_index ) ) ; <nl> + break ; <nl> + case DebugLogValueType : : MemoryRelAddr : <nl> + callbacks - > CommandLog ( " Val Type : Memory Relative Address " ) ; <nl> + callbacks - > CommandLog ( <nl> + fmt : : format ( " Mem Type : { : X } " , static_cast < u32 > ( debug_log - > mem_type ) ) ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Rel Addr : { : X } " , debug_log - > rel_address ) ) ; <nl> + break ; <nl> + case DebugLogValueType : : MemoryOfsReg : <nl> + callbacks - > CommandLog ( " Val Type : Memory Offset Register " ) ; <nl> + callbacks - > CommandLog ( <nl> + fmt : : format ( " Mem Type : { : X } " , static_cast < u32 > ( debug_log - > mem_type ) ) ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " O Reg Idx : { : X } " , debug_log - > ofs_reg_index ) ) ; <nl> + break ; <nl> + case DebugLogValueType : : RegisterRelAddr : <nl> + callbacks - > CommandLog ( " Val Type : Register Relative Address " ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " A Reg Idx : { : X } " , debug_log - > addr_reg_index ) ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Rel Addr : { : X } " , debug_log - > rel_address ) ) ; <nl> + break ; <nl> + case DebugLogValueType : : RegisterOfsReg : <nl> + callbacks - > CommandLog ( " Val Type : Register Offset Register " ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " A Reg Idx : { : X } " , debug_log - > addr_reg_index ) ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " O Reg Idx : { : X } " , debug_log - > ofs_reg_index ) ) ; <nl> + break ; <nl> + } <nl> + } else if ( auto instr = std : : get_if < UnrecognizedInstruction > ( & opcode . opcode ) ) { <nl> + callbacks - > CommandLog ( fmt : : format ( " Unknown opcode : { : X } " , static_cast < u32 > ( instr - > opcode ) ) ) ; <nl> + } <nl> + } <nl> + <nl> + DmntCheatVm : : Callbacks : : ~ Callbacks ( ) = default ; <nl> + <nl> + bool DmntCheatVm : : DecodeNextOpcode ( CheatVmOpcode & out ) { <nl> + / / If we ' ve ever seen a decode failure , return false . <nl> + bool valid = decode_success ; <nl> + CheatVmOpcode opcode = { } ; <nl> + SCOPE_EXIT ( { <nl> + decode_success & = valid ; <nl> + if ( valid ) { <nl> + out = opcode ; <nl> + } <nl> + } ) ; <nl> + <nl> + / / Helper function for getting instruction dwords . <nl> + const auto GetNextDword = [ & ] { <nl> + if ( instruction_ptr > = num_opcodes ) { <nl> + valid = false ; <nl> + return static_cast < u32 > ( 0 ) ; <nl> + } <nl> + return program [ instruction_ptr + + ] ; <nl> + } ; <nl> + <nl> + / / Helper function for parsing a VmInt . <nl> + const auto GetNextVmInt = [ & ] ( const u32 bit_width ) { <nl> + VmInt val { } ; <nl> + <nl> + const u32 first_dword = GetNextDword ( ) ; <nl> + switch ( bit_width ) { <nl> + case 1 : <nl> + val . bit8 = static_cast < u8 > ( first_dword ) ; <nl> + break ; <nl> + case 2 : <nl> + val . bit16 = static_cast < u16 > ( first_dword ) ; <nl> + break ; <nl> + case 4 : <nl> + val . bit32 = first_dword ; <nl> + break ; <nl> + case 8 : <nl> + val . bit64 = ( static_cast < u64 > ( first_dword ) < < 32ul ) | static_cast < u64 > ( GetNextDword ( ) ) ; <nl> + break ; <nl> + } <nl> + <nl> + return val ; <nl> + } ; <nl> + <nl> + / / Read opcode . <nl> + const u32 first_dword = GetNextDword ( ) ; <nl> + if ( ! valid ) { <nl> + return valid ; <nl> + } <nl> + <nl> + auto opcode_type = static_cast < CheatVmOpcodeType > ( ( ( first_dword > > 28 ) & 0xF ) ) ; <nl> + if ( opcode_type > = CheatVmOpcodeType : : ExtendedWidth ) { <nl> + opcode_type = static_cast < CheatVmOpcodeType > ( ( static_cast < u32 > ( opcode_type ) < < 4 ) | <nl> + ( ( first_dword > > 24 ) & 0xF ) ) ; <nl> + } <nl> + if ( opcode_type > = CheatVmOpcodeType : : DoubleExtendedWidth ) { <nl> + opcode_type = static_cast < CheatVmOpcodeType > ( ( static_cast < u32 > ( opcode_type ) < < 4 ) | <nl> + ( ( first_dword > > 20 ) & 0xF ) ) ; <nl> + } <nl> + <nl> + / / detect condition start . <nl> + switch ( opcode_type ) { <nl> + case CheatVmOpcodeType : : BeginConditionalBlock : <nl> + case CheatVmOpcodeType : : BeginKeypressConditionalBlock : <nl> + case CheatVmOpcodeType : : BeginRegisterConditionalBlock : <nl> + opcode . begin_conditional_block = true ; <nl> + break ; <nl> + default : <nl> + opcode . begin_conditional_block = false ; <nl> + break ; <nl> + } <nl> + <nl> + switch ( opcode_type ) { <nl> + case CheatVmOpcodeType : : StoreStatic : { <nl> + StoreStaticOpcode store_static { } ; <nl> + / / 0TMR00AA AAAAAAAA YYYYYYYY ( YYYYYYYY ) <nl> + / / Read additional words . <nl> + const u32 second_dword = GetNextDword ( ) ; <nl> + store_static . bit_width = ( first_dword > > 24 ) & 0xF ; <nl> + store_static . mem_type = static_cast < MemoryAccessType > ( ( first_dword > > 20 ) & 0xF ) ; <nl> + store_static . offset_register = ( ( first_dword > > 16 ) & 0xF ) ; <nl> + store_static . rel_address = <nl> + ( static_cast < u64 > ( first_dword & 0xFF ) < < 32ul ) | static_cast < u64 > ( second_dword ) ; <nl> + store_static . value = GetNextVmInt ( store_static . bit_width ) ; <nl> + opcode . opcode = store_static ; <nl> + } break ; <nl> + case CheatVmOpcodeType : : BeginConditionalBlock : { <nl> + BeginConditionalOpcode begin_cond { } ; <nl> + / / 1TMC00AA AAAAAAAA YYYYYYYY ( YYYYYYYY ) <nl> + / / Read additional words . <nl> + const u32 second_dword = GetNextDword ( ) ; <nl> + begin_cond . bit_width = ( first_dword > > 24 ) & 0xF ; <nl> + begin_cond . mem_type = static_cast < MemoryAccessType > ( ( first_dword > > 20 ) & 0xF ) ; <nl> + begin_cond . cond_type = static_cast < ConditionalComparisonType > ( ( first_dword > > 16 ) & 0xF ) ; <nl> + begin_cond . rel_address = <nl> + ( static_cast < u64 > ( first_dword & 0xFF ) < < 32ul ) | static_cast < u64 > ( second_dword ) ; <nl> + begin_cond . value = GetNextVmInt ( begin_cond . bit_width ) ; <nl> + opcode . opcode = begin_cond ; <nl> + } break ; <nl> + case CheatVmOpcodeType : : EndConditionalBlock : { <nl> + / / 20000000 <nl> + / / There ' s actually nothing left to process here ! <nl> + opcode . opcode = EndConditionalOpcode { } ; <nl> + } break ; <nl> + case CheatVmOpcodeType : : ControlLoop : { <nl> + ControlLoopOpcode ctrl_loop { } ; <nl> + / / 300R0000 VVVVVVVV <nl> + / / 310R0000 <nl> + / / Parse register , whether loop start or loop end . <nl> + ctrl_loop . start_loop = ( ( first_dword > > 24 ) & 0xF ) = = 0 ; <nl> + ctrl_loop . reg_index = ( ( first_dword > > 20 ) & 0xF ) ; <nl> + <nl> + / / Read number of iters if loop start . <nl> + if ( ctrl_loop . start_loop ) { <nl> + ctrl_loop . num_iters = GetNextDword ( ) ; <nl> + } <nl> + opcode . opcode = ctrl_loop ; <nl> + } break ; <nl> + case CheatVmOpcodeType : : LoadRegisterStatic : { <nl> + LoadRegisterStaticOpcode ldr_static { } ; <nl> + / / 400R0000 VVVVVVVV VVVVVVVV <nl> + / / Read additional words . <nl> + ldr_static . reg_index = ( ( first_dword > > 16 ) & 0xF ) ; <nl> + ldr_static . value = <nl> + ( static_cast < u64 > ( GetNextDword ( ) ) < < 32ul ) | static_cast < u64 > ( GetNextDword ( ) ) ; <nl> + opcode . opcode = ldr_static ; <nl> + } break ; <nl> + case CheatVmOpcodeType : : LoadRegisterMemory : { <nl> + LoadRegisterMemoryOpcode ldr_memory { } ; <nl> + / / 5TMRI0AA AAAAAAAA <nl> + / / Read additional words . <nl> + const u32 second_dword = GetNextDword ( ) ; <nl> + ldr_memory . bit_width = ( first_dword > > 24 ) & 0xF ; <nl> + ldr_memory . mem_type = static_cast < MemoryAccessType > ( ( first_dword > > 20 ) & 0xF ) ; <nl> + ldr_memory . reg_index = ( ( first_dword > > 16 ) & 0xF ) ; <nl> + ldr_memory . load_from_reg = ( ( first_dword > > 12 ) & 0xF ) ! = 0 ; <nl> + ldr_memory . rel_address = <nl> + ( static_cast < u64 > ( first_dword & 0xFF ) < < 32ul ) | static_cast < u64 > ( second_dword ) ; <nl> + opcode . opcode = ldr_memory ; <nl> + } break ; <nl> + case CheatVmOpcodeType : : StoreStaticToAddress : { <nl> + StoreStaticToAddressOpcode str_static { } ; <nl> + / / 6T0RIor0 VVVVVVVV VVVVVVVV <nl> + / / Read additional words . <nl> + str_static . bit_width = ( first_dword > > 24 ) & 0xF ; <nl> + str_static . reg_index = ( ( first_dword > > 16 ) & 0xF ) ; <nl> + str_static . increment_reg = ( ( first_dword > > 12 ) & 0xF ) ! = 0 ; <nl> + str_static . add_offset_reg = ( ( first_dword > > 8 ) & 0xF ) ! = 0 ; <nl> + str_static . offset_reg_index = ( ( first_dword > > 4 ) & 0xF ) ; <nl> + str_static . value = <nl> + ( static_cast < u64 > ( GetNextDword ( ) ) < < 32ul ) | static_cast < u64 > ( GetNextDword ( ) ) ; <nl> + opcode . opcode = str_static ; <nl> + } break ; <nl> + case CheatVmOpcodeType : : PerformArithmeticStatic : { <nl> + PerformArithmeticStaticOpcode perform_math_static { } ; <nl> + / / 7T0RC000 VVVVVVVV <nl> + / / Read additional words . <nl> + perform_math_static . bit_width = ( first_dword > > 24 ) & 0xF ; <nl> + perform_math_static . reg_index = ( ( first_dword > > 16 ) & 0xF ) ; <nl> + perform_math_static . math_type = <nl> + static_cast < RegisterArithmeticType > ( ( first_dword > > 12 ) & 0xF ) ; <nl> + perform_math_static . value = GetNextDword ( ) ; <nl> + opcode . opcode = perform_math_static ; <nl> + } break ; <nl> + case CheatVmOpcodeType : : BeginKeypressConditionalBlock : { <nl> + BeginKeypressConditionalOpcode begin_keypress_cond { } ; <nl> + / / 8kkkkkkk <nl> + / / Just parse the mask . <nl> + begin_keypress_cond . key_mask = first_dword & 0x0FFFFFFF ; <nl> + } break ; <nl> + case CheatVmOpcodeType : : PerformArithmeticRegister : { <nl> + PerformArithmeticRegisterOpcode perform_math_reg { } ; <nl> + / / 9TCRSIs0 ( VVVVVVVV ( VVVVVVVV ) ) <nl> + perform_math_reg . bit_width = ( first_dword > > 24 ) & 0xF ; <nl> + perform_math_reg . math_type = static_cast < RegisterArithmeticType > ( ( first_dword > > 20 ) & 0xF ) ; <nl> + perform_math_reg . dst_reg_index = ( ( first_dword > > 16 ) & 0xF ) ; <nl> + perform_math_reg . src_reg_1_index = ( ( first_dword > > 12 ) & 0xF ) ; <nl> + perform_math_reg . has_immediate = ( ( first_dword > > 8 ) & 0xF ) ! = 0 ; <nl> + if ( perform_math_reg . has_immediate ) { <nl> + perform_math_reg . src_reg_2_index = 0 ; <nl> + perform_math_reg . value = GetNextVmInt ( perform_math_reg . bit_width ) ; <nl> + } else { <nl> + perform_math_reg . src_reg_2_index = ( ( first_dword > > 4 ) & 0xF ) ; <nl> + } <nl> + opcode . opcode = perform_math_reg ; <nl> + } break ; <nl> + case CheatVmOpcodeType : : StoreRegisterToAddress : { <nl> + StoreRegisterToAddressOpcode str_register { } ; <nl> + / / ATSRIOxa ( aaaaaaaa ) <nl> + / / A = opcode 10 <nl> + / / T = bit width <nl> + / / S = src register index <nl> + / / R = address register index <nl> + / / I = 1 if increment address register , 0 if not increment address register <nl> + / / O = offset type , 0 = None , 1 = Register , 2 = Immediate , 3 = Memory Region , <nl> + / / 4 = Memory Region + Relative Address ( ignore address register ) , 5 = Memory Region + <nl> + / / Relative Address <nl> + / / x = offset register ( for offset type 1 ) , memory type ( for offset type 3 ) <nl> + / / a = relative address ( for offset type 2 + 3 ) <nl> + str_register . bit_width = ( first_dword > > 24 ) & 0xF ; <nl> + str_register . str_reg_index = ( ( first_dword > > 20 ) & 0xF ) ; <nl> + str_register . addr_reg_index = ( ( first_dword > > 16 ) & 0xF ) ; <nl> + str_register . increment_reg = ( ( first_dword > > 12 ) & 0xF ) ! = 0 ; <nl> + str_register . ofs_type = static_cast < StoreRegisterOffsetType > ( ( ( first_dword > > 8 ) & 0xF ) ) ; <nl> + str_register . ofs_reg_index = ( ( first_dword > > 4 ) & 0xF ) ; <nl> + switch ( str_register . ofs_type ) { <nl> + case StoreRegisterOffsetType : : None : <nl> + case StoreRegisterOffsetType : : Reg : <nl> + / / Nothing more to do <nl> + break ; <nl> + case StoreRegisterOffsetType : : Imm : <nl> + str_register . rel_address = <nl> + ( ( static_cast < u64 > ( first_dword & 0xF ) < < 32ul ) | static_cast < u64 > ( GetNextDword ( ) ) ) ; <nl> + break ; <nl> + case StoreRegisterOffsetType : : MemReg : <nl> + str_register . mem_type = static_cast < MemoryAccessType > ( ( first_dword > > 4 ) & 0xF ) ; <nl> + break ; <nl> + case StoreRegisterOffsetType : : MemImm : <nl> + case StoreRegisterOffsetType : : MemImmReg : <nl> + str_register . mem_type = static_cast < MemoryAccessType > ( ( first_dword > > 4 ) & 0xF ) ; <nl> + str_register . rel_address = <nl> + ( ( static_cast < u64 > ( first_dword & 0xF ) < < 32ul ) | static_cast < u64 > ( GetNextDword ( ) ) ) ; <nl> + break ; <nl> + default : <nl> + str_register . ofs_type = StoreRegisterOffsetType : : None ; <nl> + break ; <nl> + } <nl> + opcode . opcode = str_register ; <nl> + } break ; <nl> + case CheatVmOpcodeType : : BeginRegisterConditionalBlock : { <nl> + BeginRegisterConditionalOpcode begin_reg_cond { } ; <nl> + / / C0TcSX # # <nl> + / / C0TcS0Ma aaaaaaaa <nl> + / / C0TcS1Mr <nl> + / / C0TcS2Ra aaaaaaaa <nl> + / / C0TcS3Rr <nl> + / / C0TcS400 VVVVVVVV ( VVVVVVVV ) <nl> + / / C0TcS5X0 <nl> + / / C0 = opcode 0xC0 <nl> + / / T = bit width <nl> + / / c = condition type . <nl> + / / S = source register . <nl> + / / X = value operand type , 0 = main / heap with relative offset , 1 = main / heap with offset <nl> + / / register , <nl> + / / 2 = register with relative offset , 3 = register with offset register , 4 = static <nl> + / / value , 5 = other register . <nl> + / / M = memory type . <nl> + / / R = address register . <nl> + / / a = relative address . <nl> + / / r = offset register . <nl> + / / X = other register . <nl> + / / V = value . <nl> + begin_reg_cond . bit_width = ( first_dword > > 20 ) & 0xF ; <nl> + begin_reg_cond . cond_type = <nl> + static_cast < ConditionalComparisonType > ( ( first_dword > > 16 ) & 0xF ) ; <nl> + begin_reg_cond . val_reg_index = ( ( first_dword > > 12 ) & 0xF ) ; <nl> + begin_reg_cond . comp_type = static_cast < CompareRegisterValueType > ( ( first_dword > > 8 ) & 0xF ) ; <nl> + <nl> + switch ( begin_reg_cond . comp_type ) { <nl> + case CompareRegisterValueType : : StaticValue : <nl> + begin_reg_cond . value = GetNextVmInt ( begin_reg_cond . bit_width ) ; <nl> + break ; <nl> + case CompareRegisterValueType : : OtherRegister : <nl> + begin_reg_cond . other_reg_index = ( ( first_dword > > 4 ) & 0xF ) ; <nl> + break ; <nl> + case CompareRegisterValueType : : MemoryRelAddr : <nl> + begin_reg_cond . mem_type = static_cast < MemoryAccessType > ( ( first_dword > > 4 ) & 0xF ) ; <nl> + begin_reg_cond . rel_address = <nl> + ( ( static_cast < u64 > ( first_dword & 0xF ) < < 32ul ) | static_cast < u64 > ( GetNextDword ( ) ) ) ; <nl> + break ; <nl> + case CompareRegisterValueType : : MemoryOfsReg : <nl> + begin_reg_cond . mem_type = static_cast < MemoryAccessType > ( ( first_dword > > 4 ) & 0xF ) ; <nl> + begin_reg_cond . ofs_reg_index = ( first_dword & 0xF ) ; <nl> + break ; <nl> + case CompareRegisterValueType : : RegisterRelAddr : <nl> + begin_reg_cond . addr_reg_index = ( ( first_dword > > 4 ) & 0xF ) ; <nl> + begin_reg_cond . rel_address = <nl> + ( ( static_cast < u64 > ( first_dword & 0xF ) < < 32ul ) | static_cast < u64 > ( GetNextDword ( ) ) ) ; <nl> + break ; <nl> + case CompareRegisterValueType : : RegisterOfsReg : <nl> + begin_reg_cond . addr_reg_index = ( ( first_dword > > 4 ) & 0xF ) ; <nl> + begin_reg_cond . ofs_reg_index = ( first_dword & 0xF ) ; <nl> + break ; <nl> + } <nl> + opcode . opcode = begin_reg_cond ; <nl> + } break ; <nl> + case CheatVmOpcodeType : : SaveRestoreRegister : { <nl> + SaveRestoreRegisterOpcode save_restore_reg { } ; <nl> + / / C10D0Sx0 <nl> + / / C1 = opcode 0xC1 <nl> + / / D = destination index . <nl> + / / S = source index . <nl> + / / x = 3 if clearing reg , 2 if clearing saved value , 1 if saving a register , 0 if restoring <nl> + / / a register . <nl> + / / NOTE : If we add more save slots later , current encoding is backwards compatible . <nl> + save_restore_reg . dst_index = ( first_dword > > 16 ) & 0xF ; <nl> + save_restore_reg . src_index = ( first_dword > > 8 ) & 0xF ; <nl> + save_restore_reg . op_type = static_cast < SaveRestoreRegisterOpType > ( ( first_dword > > 4 ) & 0xF ) ; <nl> + opcode . opcode = save_restore_reg ; <nl> + } break ; <nl> + case CheatVmOpcodeType : : SaveRestoreRegisterMask : { <nl> + SaveRestoreRegisterMaskOpcode save_restore_regmask { } ; <nl> + / / C2x0XXXX <nl> + / / C2 = opcode 0xC2 <nl> + / / x = 3 if clearing reg , 2 if clearing saved value , 1 if saving , 0 if restoring . <nl> + / / X = 16 - bit bitmask , bit i - - > save or restore register i . <nl> + save_restore_regmask . op_type = <nl> + static_cast < SaveRestoreRegisterOpType > ( ( first_dword > > 20 ) & 0xF ) ; <nl> + for ( std : : size_t i = 0 ; i < NumRegisters ; i + + ) { <nl> + save_restore_regmask . should_operate [ i ] = ( first_dword & ( 1u < < i ) ) ! = 0 ; <nl> + } <nl> + opcode . opcode = save_restore_regmask ; <nl> + } break ; <nl> + case CheatVmOpcodeType : : DebugLog : { <nl> + DebugLogOpcode debug_log { } ; <nl> + / / FFFTIX # # <nl> + / / FFFTI0Ma aaaaaaaa <nl> + / / FFFTI1Mr <nl> + / / FFFTI2Ra aaaaaaaa <nl> + / / FFFTI3Rr <nl> + / / FFFTI4X0 <nl> + / / FFF = opcode 0xFFF <nl> + / / T = bit width . <nl> + / / I = log id . <nl> + / / X = value operand type , 0 = main / heap with relative offset , 1 = main / heap with offset <nl> + / / register , <nl> + / / 2 = register with relative offset , 3 = register with offset register , 4 = register <nl> + / / value . <nl> + / / M = memory type . <nl> + / / R = address register . <nl> + / / a = relative address . <nl> + / / r = offset register . <nl> + / / X = value register . <nl> + debug_log . bit_width = ( first_dword > > 16 ) & 0xF ; <nl> + debug_log . log_id = ( ( first_dword > > 12 ) & 0xF ) ; <nl> + debug_log . val_type = static_cast < DebugLogValueType > ( ( first_dword > > 8 ) & 0xF ) ; <nl> + <nl> + switch ( debug_log . val_type ) { <nl> + case DebugLogValueType : : RegisterValue : <nl> + debug_log . val_reg_index = ( ( first_dword > > 4 ) & 0xF ) ; <nl> + break ; <nl> + case DebugLogValueType : : MemoryRelAddr : <nl> + debug_log . mem_type = static_cast < MemoryAccessType > ( ( first_dword > > 4 ) & 0xF ) ; <nl> + debug_log . rel_address = <nl> + ( ( static_cast < u64 > ( first_dword & 0xF ) < < 32ul ) | static_cast < u64 > ( GetNextDword ( ) ) ) ; <nl> + break ; <nl> + case DebugLogValueType : : MemoryOfsReg : <nl> + debug_log . mem_type = static_cast < MemoryAccessType > ( ( first_dword > > 4 ) & 0xF ) ; <nl> + debug_log . ofs_reg_index = ( first_dword & 0xF ) ; <nl> + break ; <nl> + case DebugLogValueType : : RegisterRelAddr : <nl> + debug_log . addr_reg_index = ( ( first_dword > > 4 ) & 0xF ) ; <nl> + debug_log . rel_address = <nl> + ( ( static_cast < u64 > ( first_dword & 0xF ) < < 32ul ) | static_cast < u64 > ( GetNextDword ( ) ) ) ; <nl> + break ; <nl> + case DebugLogValueType : : RegisterOfsReg : <nl> + debug_log . addr_reg_index = ( ( first_dword > > 4 ) & 0xF ) ; <nl> + debug_log . ofs_reg_index = ( first_dword & 0xF ) ; <nl> + break ; <nl> + } <nl> + opcode . opcode = debug_log ; <nl> + } break ; <nl> + case CheatVmOpcodeType : : ExtendedWidth : <nl> + case CheatVmOpcodeType : : DoubleExtendedWidth : <nl> + default : <nl> + / / Unrecognized instruction cannot be decoded . <nl> + valid = false ; <nl> + opcode . opcode = UnrecognizedInstruction { opcode_type } ; <nl> + break ; <nl> + } <nl> + <nl> + / / End decoding . <nl> + return valid ; <nl> + } <nl> + <nl> + void DmntCheatVm : : SkipConditionalBlock ( ) { <nl> + if ( condition_depth > 0 ) { <nl> + / / We want to continue until we ' re out of the current block . <nl> + const std : : size_t desired_depth = condition_depth - 1 ; <nl> + <nl> + CheatVmOpcode skip_opcode { } ; <nl> + while ( condition_depth > desired_depth & & DecodeNextOpcode ( skip_opcode ) ) { <nl> + / / Decode instructions until we see end of the current conditional block . <nl> + / / NOTE : This is broken in gateway ' s implementation . <nl> + / / Gateway currently checks for " 0x2 " instead of " 0x20000000 " <nl> + / / In addition , they do a linear scan instead of correctly decoding opcodes . <nl> + / / This causes issues if " 0x2 " appears as an immediate in the conditional block . . . <nl> + <nl> + / / We also support nesting of conditional blocks , and Gateway does not . <nl> + if ( skip_opcode . begin_conditional_block ) { <nl> + condition_depth + + ; <nl> + } else if ( std : : holds_alternative < EndConditionalOpcode > ( skip_opcode . opcode ) ) { <nl> + condition_depth - - ; <nl> + } <nl> + } <nl> + } else { <nl> + / / Skipping , but condition_depth = 0 . <nl> + / / This is an error condition . <nl> + / / However , I don ' t actually believe it is possible for this to happen . <nl> + / / I guess we ' ll throw a fatal error here , so as to encourage me to fix the VM <nl> + / / in the event that someone triggers it ? I don ' t know how you ' d do that . <nl> + UNREACHABLE_MSG ( " Invalid condition depth in DMNT Cheat VM " ) ; <nl> + } <nl> + } <nl> + <nl> + u64 DmntCheatVm : : GetVmInt ( VmInt value , u32 bit_width ) { <nl> + switch ( bit_width ) { <nl> + case 1 : <nl> + return value . bit8 ; <nl> + case 2 : <nl> + return value . bit16 ; <nl> + case 4 : <nl> + return value . bit32 ; <nl> + case 8 : <nl> + return value . bit64 ; <nl> + default : <nl> + / / Invalid bit width - > return 0 . <nl> + return 0 ; <nl> + } <nl> + } <nl> + <nl> + u64 DmntCheatVm : : GetCheatProcessAddress ( const CheatProcessMetadata & metadata , <nl> + MemoryAccessType mem_type , u64 rel_address ) { <nl> + switch ( mem_type ) { <nl> + case MemoryAccessType : : MainNso : <nl> + default : <nl> + return metadata . main_nso_extents . base + rel_address ; <nl> + case MemoryAccessType : : Heap : <nl> + return metadata . heap_extents . base + rel_address ; <nl> + } <nl> + } <nl> + <nl> + void DmntCheatVm : : ResetState ( ) { <nl> + registers . fill ( 0 ) ; <nl> + saved_values . fill ( 0 ) ; <nl> + loop_tops . fill ( 0 ) ; <nl> + instruction_ptr = 0 ; <nl> + condition_depth = 0 ; <nl> + decode_success = true ; <nl> + } <nl> + <nl> + bool DmntCheatVm : : LoadProgram ( const std : : vector < CheatEntry > & entries ) { <nl> + / / Reset opcode count . <nl> + num_opcodes = 0 ; <nl> + <nl> + for ( std : : size_t i = 0 ; i < entries . size ( ) ; i + + ) { <nl> + if ( entries [ i ] . enabled ) { <nl> + / / Bounds check . <nl> + if ( entries [ i ] . definition . num_opcodes + num_opcodes > MaximumProgramOpcodeCount ) { <nl> + num_opcodes = 0 ; <nl> + return false ; <nl> + } <nl> + <nl> + for ( std : : size_t n = 0 ; n < entries [ i ] . definition . num_opcodes ; n + + ) { <nl> + program [ num_opcodes + + ] = entries [ i ] . definition . opcodes [ n ] ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + void DmntCheatVm : : Execute ( const CheatProcessMetadata & metadata ) { <nl> + CheatVmOpcode cur_opcode { } ; <nl> + <nl> + / / Get Keys down . <nl> + u64 kDown = callbacks - > HidKeysDown ( ) ; <nl> + <nl> + callbacks - > CommandLog ( " Started VM execution . " ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Main NSO : { : 012X } " , metadata . main_nso_extents . base ) ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Heap : { : 012X } " , metadata . main_nso_extents . base ) ) ; <nl> + callbacks - > CommandLog ( fmt : : format ( " Keys Down : { : 08X } " , static_cast < u32 > ( kDown & 0x0FFFFFFF ) ) ) ; <nl> + <nl> + / / Clear VM state . <nl> + ResetState ( ) ; <nl> + <nl> + / / Loop until program finishes . <nl> + while ( DecodeNextOpcode ( cur_opcode ) ) { <nl> + callbacks - > CommandLog ( <nl> + fmt : : format ( " Instruction Ptr : { : 04X } " , static_cast < u32 > ( instruction_ptr ) ) ) ; <nl> + <nl> + for ( std : : size_t i = 0 ; i < NumRegisters ; i + + ) { <nl> + callbacks - > CommandLog ( fmt : : format ( " Registers [ { : 02X } ] : { : 016X } " , i , registers [ i ] ) ) ; <nl> + } <nl> + <nl> + for ( std : : size_t i = 0 ; i < NumRegisters ; i + + ) { <nl> + callbacks - > CommandLog ( fmt : : format ( " SavedRegs [ { : 02X } ] : { : 016X } " , i , saved_values [ i ] ) ) ; <nl> + } <nl> + LogOpcode ( cur_opcode ) ; <nl> + <nl> + / / Increment conditional depth , if relevant . <nl> + if ( cur_opcode . begin_conditional_block ) { <nl> + condition_depth + + ; <nl> + } <nl> + <nl> + if ( auto store_static = std : : get_if < StoreStaticOpcode > ( & cur_opcode . opcode ) ) { <nl> + / / Calculate address , write value to memory . <nl> + u64 dst_address = GetCheatProcessAddress ( metadata , store_static - > mem_type , <nl> + store_static - > rel_address + <nl> + registers [ store_static - > offset_register ] ) ; <nl> + u64 dst_value = GetVmInt ( store_static - > value , store_static - > bit_width ) ; <nl> + switch ( store_static - > bit_width ) { <nl> + case 1 : <nl> + case 2 : <nl> + case 4 : <nl> + case 8 : <nl> + callbacks - > MemoryWrite ( dst_address , & dst_value , store_static - > bit_width ) ; <nl> + break ; <nl> + } <nl> + } else if ( auto begin_cond = std : : get_if < BeginConditionalOpcode > ( & cur_opcode . opcode ) ) { <nl> + / / Read value from memory . <nl> + u64 src_address = <nl> + GetCheatProcessAddress ( metadata , begin_cond - > mem_type , begin_cond - > rel_address ) ; <nl> + u64 src_value = 0 ; <nl> + switch ( store_static - > bit_width ) { <nl> + case 1 : <nl> + case 2 : <nl> + case 4 : <nl> + case 8 : <nl> + callbacks - > MemoryRead ( src_address , & src_value , begin_cond - > bit_width ) ; <nl> + break ; <nl> + } <nl> + / / Check against condition . <nl> + u64 cond_value = GetVmInt ( begin_cond - > value , begin_cond - > bit_width ) ; <nl> + bool cond_met = false ; <nl> + switch ( begin_cond - > cond_type ) { <nl> + case ConditionalComparisonType : : GT : <nl> + cond_met = src_value > cond_value ; <nl> + break ; <nl> + case ConditionalComparisonType : : GE : <nl> + cond_met = src_value > = cond_value ; <nl> + break ; <nl> + case ConditionalComparisonType : : LT : <nl> + cond_met = src_value < cond_value ; <nl> + break ; <nl> + case ConditionalComparisonType : : LE : <nl> + cond_met = src_value < = cond_value ; <nl> + break ; <nl> + case ConditionalComparisonType : : EQ : <nl> + cond_met = src_value = = cond_value ; <nl> + break ; <nl> + case ConditionalComparisonType : : NE : <nl> + cond_met = src_value ! = cond_value ; <nl> + break ; <nl> + } <nl> + / / Skip conditional block if condition not met . <nl> + if ( ! cond_met ) { <nl> + SkipConditionalBlock ( ) ; <nl> + } <nl> + } else if ( auto end_cond = std : : get_if < EndConditionalOpcode > ( & cur_opcode . opcode ) ) { <nl> + / / Decrement the condition depth . <nl> + / / We will assume , graciously , that mismatched conditional block ends are a nop . <nl> + if ( condition_depth > 0 ) { <nl> + condition_depth - - ; <nl> + } <nl> + } else if ( auto ctrl_loop = std : : get_if < ControlLoopOpcode > ( & cur_opcode . opcode ) ) { <nl> + if ( ctrl_loop - > start_loop ) { <nl> + / / Start a loop . <nl> + registers [ ctrl_loop - > reg_index ] = ctrl_loop - > num_iters ; <nl> + loop_tops [ ctrl_loop - > reg_index ] = instruction_ptr ; <nl> + } else { <nl> + / / End a loop . <nl> + registers [ ctrl_loop - > reg_index ] - - ; <nl> + if ( registers [ ctrl_loop - > reg_index ] ! = 0 ) { <nl> + instruction_ptr = loop_tops [ ctrl_loop - > reg_index ] ; <nl> + } <nl> + } <nl> + } else if ( auto ldr_static = std : : get_if < LoadRegisterStaticOpcode > ( & cur_opcode . opcode ) ) { <nl> + / / Set a register to a static value . <nl> + registers [ ldr_static - > reg_index ] = ldr_static - > value ; <nl> + } else if ( auto ldr_memory = std : : get_if < LoadRegisterMemoryOpcode > ( & cur_opcode . opcode ) ) { <nl> + / / Choose source address . <nl> + u64 src_address ; <nl> + if ( ldr_memory - > load_from_reg ) { <nl> + src_address = registers [ ldr_memory - > reg_index ] + ldr_memory - > rel_address ; <nl> + } else { <nl> + src_address = <nl> + GetCheatProcessAddress ( metadata , ldr_memory - > mem_type , ldr_memory - > rel_address ) ; <nl> + } <nl> + / / Read into register . Gateway only reads on valid bitwidth . <nl> + switch ( ldr_memory - > bit_width ) { <nl> + case 1 : <nl> + case 2 : <nl> + case 4 : <nl> + case 8 : <nl> + callbacks - > MemoryRead ( src_address , & registers [ ldr_memory - > reg_index ] , <nl> + ldr_memory - > bit_width ) ; <nl> + break ; <nl> + } <nl> + } else if ( auto str_static = std : : get_if < StoreStaticToAddressOpcode > ( & cur_opcode . opcode ) ) { <nl> + / / Calculate address . <nl> + u64 dst_address = registers [ str_static - > reg_index ] ; <nl> + u64 dst_value = str_static - > value ; <nl> + if ( str_static - > add_offset_reg ) { <nl> + dst_address + = registers [ str_static - > offset_reg_index ] ; <nl> + } <nl> + / / Write value to memory . Gateway only writes on valid bitwidth . <nl> + switch ( str_static - > bit_width ) { <nl> + case 1 : <nl> + case 2 : <nl> + case 4 : <nl> + case 8 : <nl> + callbacks - > MemoryWrite ( dst_address , & dst_value , str_static - > bit_width ) ; <nl> + break ; <nl> + } <nl> + / / Increment register if relevant . <nl> + if ( str_static - > increment_reg ) { <nl> + registers [ str_static - > reg_index ] + = str_static - > bit_width ; <nl> + } <nl> + } else if ( auto perform_math_static = <nl> + std : : get_if < PerformArithmeticStaticOpcode > ( & cur_opcode . opcode ) ) { <nl> + / / Do requested math . <nl> + switch ( perform_math_static - > math_type ) { <nl> + case RegisterArithmeticType : : Addition : <nl> + registers [ perform_math_static - > reg_index ] + = <nl> + static_cast < u64 > ( perform_math_static - > value ) ; <nl> + break ; <nl> + case RegisterArithmeticType : : Subtraction : <nl> + registers [ perform_math_static - > reg_index ] - = <nl> + static_cast < u64 > ( perform_math_static - > value ) ; <nl> + break ; <nl> + case RegisterArithmeticType : : Multiplication : <nl> + registers [ perform_math_static - > reg_index ] * = <nl> + static_cast < u64 > ( perform_math_static - > value ) ; <nl> + break ; <nl> + case RegisterArithmeticType : : LeftShift : <nl> + registers [ perform_math_static - > reg_index ] < < = <nl> + static_cast < u64 > ( perform_math_static - > value ) ; <nl> + break ; <nl> + case RegisterArithmeticType : : RightShift : <nl> + registers [ perform_math_static - > reg_index ] > > = <nl> + static_cast < u64 > ( perform_math_static - > value ) ; <nl> + break ; <nl> + default : <nl> + / / Do not handle extensions here . <nl> + break ; <nl> + } <nl> + / / Apply bit width . <nl> + switch ( perform_math_static - > bit_width ) { <nl> + case 1 : <nl> + registers [ perform_math_static - > reg_index ] = <nl> + static_cast < u8 > ( registers [ perform_math_static - > reg_index ] ) ; <nl> + break ; <nl> + case 2 : <nl> + registers [ perform_math_static - > reg_index ] = <nl> + static_cast < u16 > ( registers [ perform_math_static - > reg_index ] ) ; <nl> + break ; <nl> + case 4 : <nl> + registers [ perform_math_static - > reg_index ] = <nl> + static_cast < u32 > ( registers [ perform_math_static - > reg_index ] ) ; <nl> + break ; <nl> + case 8 : <nl> + registers [ perform_math_static - > reg_index ] = <nl> + static_cast < u64 > ( registers [ perform_math_static - > reg_index ] ) ; <nl> + break ; <nl> + } <nl> + } else if ( auto begin_keypress_cond = <nl> + std : : get_if < BeginKeypressConditionalOpcode > ( & cur_opcode . opcode ) ) { <nl> + / / Check for keypress . <nl> + if ( ( begin_keypress_cond - > key_mask & kDown ) ! = begin_keypress_cond - > key_mask ) { <nl> + / / Keys not pressed . Skip conditional block . <nl> + SkipConditionalBlock ( ) ; <nl> + } <nl> + } else if ( auto perform_math_reg = <nl> + std : : get_if < PerformArithmeticRegisterOpcode > ( & cur_opcode . opcode ) ) { <nl> + const u64 operand_1_value = registers [ perform_math_reg - > src_reg_1_index ] ; <nl> + const u64 operand_2_value = <nl> + perform_math_reg - > has_immediate <nl> + ? GetVmInt ( perform_math_reg - > value , perform_math_reg - > bit_width ) <nl> + : registers [ perform_math_reg - > src_reg_2_index ] ; <nl> + <nl> + u64 res_val = 0 ; <nl> + / / Do requested math . <nl> + switch ( perform_math_reg - > math_type ) { <nl> + case RegisterArithmeticType : : Addition : <nl> + res_val = operand_1_value + operand_2_value ; <nl> + break ; <nl> + case RegisterArithmeticType : : Subtraction : <nl> + res_val = operand_1_value - operand_2_value ; <nl> + break ; <nl> + case RegisterArithmeticType : : Multiplication : <nl> + res_val = operand_1_value * operand_2_value ; <nl> + break ; <nl> + case RegisterArithmeticType : : LeftShift : <nl> + res_val = operand_1_value < < operand_2_value ; <nl> + break ; <nl> + case RegisterArithmeticType : : RightShift : <nl> + res_val = operand_1_value > > operand_2_value ; <nl> + break ; <nl> + case RegisterArithmeticType : : LogicalAnd : <nl> + res_val = operand_1_value & operand_2_value ; <nl> + break ; <nl> + case RegisterArithmeticType : : LogicalOr : <nl> + res_val = operand_1_value | operand_2_value ; <nl> + break ; <nl> + case RegisterArithmeticType : : LogicalNot : <nl> + res_val = ~ operand_1_value ; <nl> + break ; <nl> + case RegisterArithmeticType : : LogicalXor : <nl> + res_val = operand_1_value ^ operand_2_value ; <nl> + break ; <nl> + case RegisterArithmeticType : : None : <nl> + res_val = operand_1_value ; <nl> + break ; <nl> + } <nl> + <nl> + / / Apply bit width . <nl> + switch ( perform_math_reg - > bit_width ) { <nl> + case 1 : <nl> + res_val = static_cast < u8 > ( res_val ) ; <nl> + break ; <nl> + case 2 : <nl> + res_val = static_cast < u16 > ( res_val ) ; <nl> + break ; <nl> + case 4 : <nl> + res_val = static_cast < u32 > ( res_val ) ; <nl> + break ; <nl> + case 8 : <nl> + res_val = static_cast < u64 > ( res_val ) ; <nl> + break ; <nl> + } <nl> + <nl> + / / Save to register . <nl> + registers [ perform_math_reg - > dst_reg_index ] = res_val ; <nl> + } else if ( auto str_register = <nl> + std : : get_if < StoreRegisterToAddressOpcode > ( & cur_opcode . opcode ) ) { <nl> + / / Calculate address . <nl> + u64 dst_value = registers [ str_register - > str_reg_index ] ; <nl> + u64 dst_address = registers [ str_register - > addr_reg_index ] ; <nl> + switch ( str_register - > ofs_type ) { <nl> + case StoreRegisterOffsetType : : None : <nl> + / / Nothing more to do <nl> + break ; <nl> + case StoreRegisterOffsetType : : Reg : <nl> + dst_address + = registers [ str_register - > ofs_reg_index ] ; <nl> + break ; <nl> + case StoreRegisterOffsetType : : Imm : <nl> + dst_address + = str_register - > rel_address ; <nl> + break ; <nl> + case StoreRegisterOffsetType : : MemReg : <nl> + dst_address = GetCheatProcessAddress ( metadata , str_register - > mem_type , <nl> + registers [ str_register - > addr_reg_index ] ) ; <nl> + break ; <nl> + case StoreRegisterOffsetType : : MemImm : <nl> + dst_address = GetCheatProcessAddress ( metadata , str_register - > mem_type , <nl> + str_register - > rel_address ) ; <nl> + break ; <nl> + case StoreRegisterOffsetType : : MemImmReg : <nl> + dst_address = GetCheatProcessAddress ( metadata , str_register - > mem_type , <nl> + registers [ str_register - > addr_reg_index ] + <nl> + str_register - > rel_address ) ; <nl> + break ; <nl> + } <nl> + <nl> + / / Write value to memory . Write only on valid bitwidth . <nl> + switch ( str_register - > bit_width ) { <nl> + case 1 : <nl> + case 2 : <nl> + case 4 : <nl> + case 8 : <nl> + callbacks - > MemoryWrite ( dst_address , & dst_value , str_register - > bit_width ) ; <nl> + break ; <nl> + } <nl> + <nl> + / / Increment register if relevant . <nl> + if ( str_register - > increment_reg ) { <nl> + registers [ str_register - > addr_reg_index ] + = str_register - > bit_width ; <nl> + } <nl> + } else if ( auto begin_reg_cond = <nl> + std : : get_if < BeginRegisterConditionalOpcode > ( & cur_opcode . opcode ) ) { <nl> + / / Get value from register . <nl> + u64 src_value = 0 ; <nl> + switch ( begin_reg_cond - > bit_width ) { <nl> + case 1 : <nl> + src_value = static_cast < u8 > ( registers [ begin_reg_cond - > val_reg_index ] & 0xFFul ) ; <nl> + break ; <nl> + case 2 : <nl> + src_value = static_cast < u16 > ( registers [ begin_reg_cond - > val_reg_index ] & 0xFFFFul ) ; <nl> + break ; <nl> + case 4 : <nl> + src_value = <nl> + static_cast < u32 > ( registers [ begin_reg_cond - > val_reg_index ] & 0xFFFFFFFFul ) ; <nl> + break ; <nl> + case 8 : <nl> + src_value = static_cast < u64 > ( registers [ begin_reg_cond - > val_reg_index ] & <nl> + 0xFFFFFFFFFFFFFFFFul ) ; <nl> + break ; <nl> + } <nl> + <nl> + / / Read value from memory . <nl> + u64 cond_value = 0 ; <nl> + if ( begin_reg_cond - > comp_type = = CompareRegisterValueType : : StaticValue ) { <nl> + cond_value = GetVmInt ( begin_reg_cond - > value , begin_reg_cond - > bit_width ) ; <nl> + } else if ( begin_reg_cond - > comp_type = = CompareRegisterValueType : : OtherRegister ) { <nl> + switch ( begin_reg_cond - > bit_width ) { <nl> + case 1 : <nl> + cond_value = <nl> + static_cast < u8 > ( registers [ begin_reg_cond - > other_reg_index ] & 0xFFul ) ; <nl> + break ; <nl> + case 2 : <nl> + cond_value = <nl> + static_cast < u16 > ( registers [ begin_reg_cond - > other_reg_index ] & 0xFFFFul ) ; <nl> + break ; <nl> + case 4 : <nl> + cond_value = <nl> + static_cast < u32 > ( registers [ begin_reg_cond - > other_reg_index ] & 0xFFFFFFFFul ) ; <nl> + break ; <nl> + case 8 : <nl> + cond_value = static_cast < u64 > ( registers [ begin_reg_cond - > other_reg_index ] & <nl> + 0xFFFFFFFFFFFFFFFFul ) ; <nl> + break ; <nl> + } <nl> + } else { <nl> + u64 cond_address = 0 ; <nl> + switch ( begin_reg_cond - > comp_type ) { <nl> + case CompareRegisterValueType : : MemoryRelAddr : <nl> + cond_address = GetCheatProcessAddress ( metadata , begin_reg_cond - > mem_type , <nl> + begin_reg_cond - > rel_address ) ; <nl> + break ; <nl> + case CompareRegisterValueType : : MemoryOfsReg : <nl> + cond_address = GetCheatProcessAddress ( metadata , begin_reg_cond - > mem_type , <nl> + registers [ begin_reg_cond - > ofs_reg_index ] ) ; <nl> + break ; <nl> + case CompareRegisterValueType : : RegisterRelAddr : <nl> + cond_address = <nl> + registers [ begin_reg_cond - > addr_reg_index ] + begin_reg_cond - > rel_address ; <nl> + break ; <nl> + case CompareRegisterValueType : : RegisterOfsReg : <nl> + cond_address = registers [ begin_reg_cond - > addr_reg_index ] + <nl> + registers [ begin_reg_cond - > ofs_reg_index ] ; <nl> + break ; <nl> + default : <nl> + break ; <nl> + } <nl> + switch ( begin_reg_cond - > bit_width ) { <nl> + case 1 : <nl> + case 2 : <nl> + case 4 : <nl> + case 8 : <nl> + callbacks - > MemoryRead ( cond_address , & cond_value , begin_reg_cond - > bit_width ) ; <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + / / Check against condition . <nl> + bool cond_met = false ; <nl> + switch ( begin_reg_cond - > cond_type ) { <nl> + case ConditionalComparisonType : : GT : <nl> + cond_met = src_value > cond_value ; <nl> + break ; <nl> + case ConditionalComparisonType : : GE : <nl> + cond_met = src_value > = cond_value ; <nl> + break ; <nl> + case ConditionalComparisonType : : LT : <nl> + cond_met = src_value < cond_value ; <nl> + break ; <nl> + case ConditionalComparisonType : : LE : <nl> + cond_met = src_value < = cond_value ; <nl> + break ; <nl> + case ConditionalComparisonType : : EQ : <nl> + cond_met = src_value = = cond_value ; <nl> + break ; <nl> + case ConditionalComparisonType : : NE : <nl> + cond_met = src_value ! = cond_value ; <nl> + break ; <nl> + } <nl> + <nl> + / / Skip conditional block if condition not met . <nl> + if ( ! cond_met ) { <nl> + SkipConditionalBlock ( ) ; <nl> + } <nl> + } else if ( auto save_restore_reg = <nl> + std : : get_if < SaveRestoreRegisterOpcode > ( & cur_opcode . opcode ) ) { <nl> + / / Save or restore a register . <nl> + switch ( save_restore_reg - > op_type ) { <nl> + case SaveRestoreRegisterOpType : : ClearRegs : <nl> + registers [ save_restore_reg - > dst_index ] = 0ul ; <nl> + break ; <nl> + case SaveRestoreRegisterOpType : : ClearSaved : <nl> + saved_values [ save_restore_reg - > dst_index ] = 0ul ; <nl> + break ; <nl> + case SaveRestoreRegisterOpType : : Save : <nl> + saved_values [ save_restore_reg - > dst_index ] = registers [ save_restore_reg - > src_index ] ; <nl> + break ; <nl> + case SaveRestoreRegisterOpType : : Restore : <nl> + default : <nl> + registers [ save_restore_reg - > dst_index ] = saved_values [ save_restore_reg - > src_index ] ; <nl> + break ; <nl> + } <nl> + } else if ( auto save_restore_regmask = <nl> + std : : get_if < SaveRestoreRegisterMaskOpcode > ( & cur_opcode . opcode ) ) { <nl> + / / Save or restore register mask . <nl> + u64 * src ; <nl> + u64 * dst ; <nl> + switch ( save_restore_regmask - > op_type ) { <nl> + case SaveRestoreRegisterOpType : : ClearSaved : <nl> + case SaveRestoreRegisterOpType : : Save : <nl> + src = registers . data ( ) ; <nl> + dst = saved_values . data ( ) ; <nl> + break ; <nl> + case SaveRestoreRegisterOpType : : ClearRegs : <nl> + case SaveRestoreRegisterOpType : : Restore : <nl> + default : <nl> + src = registers . data ( ) ; <nl> + dst = saved_values . data ( ) ; <nl> + break ; <nl> + } <nl> + for ( std : : size_t i = 0 ; i < NumRegisters ; i + + ) { <nl> + if ( save_restore_regmask - > should_operate [ i ] ) { <nl> + switch ( save_restore_regmask - > op_type ) { <nl> + case SaveRestoreRegisterOpType : : ClearSaved : <nl> + case SaveRestoreRegisterOpType : : ClearRegs : <nl> + dst [ i ] = 0ul ; <nl> + break ; <nl> + case SaveRestoreRegisterOpType : : Save : <nl> + case SaveRestoreRegisterOpType : : Restore : <nl> + default : <nl> + dst [ i ] = src [ i ] ; <nl> + break ; <nl> + } <nl> + } <nl> + } <nl> + } else if ( auto debug_log = std : : get_if < DebugLogOpcode > ( & cur_opcode . opcode ) ) { <nl> + / / Read value from memory . <nl> + u64 log_value = 0 ; <nl> + if ( debug_log - > val_type = = DebugLogValueType : : RegisterValue ) { <nl> + switch ( debug_log - > bit_width ) { <nl> + case 1 : <nl> + log_value = static_cast < u8 > ( registers [ debug_log - > val_reg_index ] & 0xFFul ) ; <nl> + break ; <nl> + case 2 : <nl> + log_value = static_cast < u16 > ( registers [ debug_log - > val_reg_index ] & 0xFFFFul ) ; <nl> + break ; <nl> + case 4 : <nl> + log_value = <nl> + static_cast < u32 > ( registers [ debug_log - > val_reg_index ] & 0xFFFFFFFFul ) ; <nl> + break ; <nl> + case 8 : <nl> + log_value = static_cast < u64 > ( registers [ debug_log - > val_reg_index ] & <nl> + 0xFFFFFFFFFFFFFFFFul ) ; <nl> + break ; <nl> + } <nl> + } else { <nl> + u64 val_address = 0 ; <nl> + switch ( debug_log - > val_type ) { <nl> + case DebugLogValueType : : MemoryRelAddr : <nl> + val_address = GetCheatProcessAddress ( metadata , debug_log - > mem_type , <nl> + debug_log - > rel_address ) ; <nl> + break ; <nl> + case DebugLogValueType : : MemoryOfsReg : <nl> + val_address = GetCheatProcessAddress ( metadata , debug_log - > mem_type , <nl> + registers [ debug_log - > ofs_reg_index ] ) ; <nl> + break ; <nl> + case DebugLogValueType : : RegisterRelAddr : <nl> + val_address = registers [ debug_log - > addr_reg_index ] + debug_log - > rel_address ; <nl> + break ; <nl> + case DebugLogValueType : : RegisterOfsReg : <nl> + val_address = <nl> + registers [ debug_log - > addr_reg_index ] + registers [ debug_log - > ofs_reg_index ] ; <nl> + break ; <nl> + default : <nl> + break ; <nl> + } <nl> + switch ( debug_log - > bit_width ) { <nl> + case 1 : <nl> + case 2 : <nl> + case 4 : <nl> + case 8 : <nl> + callbacks - > MemoryRead ( val_address , & log_value , debug_log - > bit_width ) ; <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + / / Log value . <nl> + DebugLog ( debug_log - > log_id , log_value ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + } / / namespace Memory <nl> new file mode 100644 <nl> index 00000000000 . . c36212cf12e <nl> mmm / dev / null <nl> ppp b / src / core / memory / dmnt_cheat_vm . h <nl> <nl> + / * <nl> + * Copyright ( c ) 2018 - 2019 Atmosphère - NX <nl> + * <nl> + * This program is free software ; you can redistribute it and / or modify it <nl> + * under the terms and conditions of the GNU General Public License , <nl> + * version 2 , as published by the Free Software Foundation . <nl> + * <nl> + * This program is distributed in the hope it will be useful , but WITHOUT <nl> + * ANY WARRANTY ; without even the implied warranty of MERCHANTABILITY or <nl> + * FITNESS FOR A PARTICULAR PURPOSE . See the GNU General Public License for <nl> + * more details . <nl> + * <nl> + * You should have received a copy of the GNU General Public License <nl> + * along with this program . If not , see < http : / / www . gnu . org / licenses / > . <nl> + * / <nl> + <nl> + / * <nl> + * Adapted by DarkLordZach for use / interaction with yuzu <nl> + * <nl> + * Modifications Copyright 2019 yuzu emulator team <nl> + * Licensed under GPLv2 or any later version <nl> + * Refer to the license . txt file included . <nl> + * / <nl> + <nl> + # pragma once <nl> + <nl> + # include < variant > <nl> + # include < vector > <nl> + # include < fmt / printf . h > <nl> + # include " common / common_types . h " <nl> + # include " core / memory / dmnt_cheat_types . h " <nl> + <nl> + namespace Memory { <nl> + <nl> + enum class CheatVmOpcodeType : u32 { <nl> + StoreStatic = 0 , <nl> + BeginConditionalBlock = 1 , <nl> + EndConditionalBlock = 2 , <nl> + ControlLoop = 3 , <nl> + LoadRegisterStatic = 4 , <nl> + LoadRegisterMemory = 5 , <nl> + StoreStaticToAddress = 6 , <nl> + PerformArithmeticStatic = 7 , <nl> + BeginKeypressConditionalBlock = 8 , <nl> + <nl> + / / These are not implemented by Gateway ' s VM . <nl> + PerformArithmeticRegister = 9 , <nl> + StoreRegisterToAddress = 10 , <nl> + Reserved11 = 11 , <nl> + <nl> + / / This is a meta entry , and not a real opcode . <nl> + / / This is to facilitate multi - nybble instruction decoding . <nl> + ExtendedWidth = 12 , <nl> + <nl> + / / Extended width opcodes . <nl> + BeginRegisterConditionalBlock = 0xC0 , <nl> + SaveRestoreRegister = 0xC1 , <nl> + SaveRestoreRegisterMask = 0xC2 , <nl> + <nl> + / / This is a meta entry , and not a real opcode . <nl> + / / This is to facilitate multi - nybble instruction decoding . <nl> + DoubleExtendedWidth = 0xF0 , <nl> + <nl> + / / Double - extended width opcodes . <nl> + DebugLog = 0xFFF , <nl> + } ; <nl> + <nl> + enum class MemoryAccessType : u32 { <nl> + MainNso = 0 , <nl> + Heap = 1 , <nl> + } ; <nl> + <nl> + enum class ConditionalComparisonType : u32 { <nl> + GT = 1 , <nl> + GE = 2 , <nl> + LT = 3 , <nl> + LE = 4 , <nl> + EQ = 5 , <nl> + NE = 6 , <nl> + } ; <nl> + <nl> + enum class RegisterArithmeticType : u32 { <nl> + Addition = 0 , <nl> + Subtraction = 1 , <nl> + Multiplication = 2 , <nl> + LeftShift = 3 , <nl> + RightShift = 4 , <nl> + <nl> + / / These are not supported by Gateway ' s VM . <nl> + LogicalAnd = 5 , <nl> + LogicalOr = 6 , <nl> + LogicalNot = 7 , <nl> + LogicalXor = 8 , <nl> + <nl> + None = 9 , <nl> + } ; <nl> + <nl> + enum class StoreRegisterOffsetType : u32 { <nl> + None = 0 , <nl> + Reg = 1 , <nl> + Imm = 2 , <nl> + MemReg = 3 , <nl> + MemImm = 4 , <nl> + MemImmReg = 5 , <nl> + } ; <nl> + <nl> + enum class CompareRegisterValueType : u32 { <nl> + MemoryRelAddr = 0 , <nl> + MemoryOfsReg = 1 , <nl> + RegisterRelAddr = 2 , <nl> + RegisterOfsReg = 3 , <nl> + StaticValue = 4 , <nl> + OtherRegister = 5 , <nl> + } ; <nl> + <nl> + enum class SaveRestoreRegisterOpType : u32 { <nl> + Restore = 0 , <nl> + Save = 1 , <nl> + ClearSaved = 2 , <nl> + ClearRegs = 3 , <nl> + } ; <nl> + <nl> + enum class DebugLogValueType : u32 { <nl> + MemoryRelAddr = 0 , <nl> + MemoryOfsReg = 1 , <nl> + RegisterRelAddr = 2 , <nl> + RegisterOfsReg = 3 , <nl> + RegisterValue = 4 , <nl> + } ; <nl> + <nl> + union VmInt { <nl> + u8 bit8 ; <nl> + u16 bit16 ; <nl> + u32 bit32 ; <nl> + u64 bit64 ; <nl> + } ; <nl> + <nl> + struct StoreStaticOpcode { <nl> + u32 bit_width { } ; <nl> + MemoryAccessType mem_type { } ; <nl> + u32 offset_register { } ; <nl> + u64 rel_address { } ; <nl> + VmInt value { } ; <nl> + } ; <nl> + <nl> + struct BeginConditionalOpcode { <nl> + u32 bit_width { } ; <nl> + MemoryAccessType mem_type { } ; <nl> + ConditionalComparisonType cond_type { } ; <nl> + u64 rel_address { } ; <nl> + VmInt value { } ; <nl> + } ; <nl> + <nl> + struct EndConditionalOpcode { } ; <nl> + <nl> + struct ControlLoopOpcode { <nl> + bool start_loop { } ; <nl> + u32 reg_index { } ; <nl> + u32 num_iters { } ; <nl> + } ; <nl> + <nl> + struct LoadRegisterStaticOpcode { <nl> + u32 reg_index { } ; <nl> + u64 value { } ; <nl> + } ; <nl> + <nl> + struct LoadRegisterMemoryOpcode { <nl> + u32 bit_width { } ; <nl> + MemoryAccessType mem_type { } ; <nl> + u32 reg_index { } ; <nl> + bool load_from_reg { } ; <nl> + u64 rel_address { } ; <nl> + } ; <nl> + <nl> + struct StoreStaticToAddressOpcode { <nl> + u32 bit_width { } ; <nl> + u32 reg_index { } ; <nl> + bool increment_reg { } ; <nl> + bool add_offset_reg { } ; <nl> + u32 offset_reg_index { } ; <nl> + u64 value { } ; <nl> + } ; <nl> + <nl> + struct PerformArithmeticStaticOpcode { <nl> + u32 bit_width { } ; <nl> + u32 reg_index { } ; <nl> + RegisterArithmeticType math_type { } ; <nl> + u32 value { } ; <nl> + } ; <nl> + <nl> + struct BeginKeypressConditionalOpcode { <nl> + u32 key_mask { } ; <nl> + } ; <nl> + <nl> + struct PerformArithmeticRegisterOpcode { <nl> + u32 bit_width { } ; <nl> + RegisterArithmeticType math_type { } ; <nl> + u32 dst_reg_index { } ; <nl> + u32 src_reg_1_index { } ; <nl> + u32 src_reg_2_index { } ; <nl> + bool has_immediate { } ; <nl> + VmInt value { } ; <nl> + } ; <nl> + <nl> + struct StoreRegisterToAddressOpcode { <nl> + u32 bit_width { } ; <nl> + u32 str_reg_index { } ; <nl> + u32 addr_reg_index { } ; <nl> + bool increment_reg { } ; <nl> + StoreRegisterOffsetType ofs_type { } ; <nl> + MemoryAccessType mem_type { } ; <nl> + u32 ofs_reg_index { } ; <nl> + u64 rel_address { } ; <nl> + } ; <nl> + <nl> + struct BeginRegisterConditionalOpcode { <nl> + u32 bit_width { } ; <nl> + ConditionalComparisonType cond_type { } ; <nl> + u32 val_reg_index { } ; <nl> + CompareRegisterValueType comp_type { } ; <nl> + MemoryAccessType mem_type { } ; <nl> + u32 addr_reg_index { } ; <nl> + u32 other_reg_index { } ; <nl> + u32 ofs_reg_index { } ; <nl> + u64 rel_address { } ; <nl> + VmInt value { } ; <nl> + } ; <nl> + <nl> + struct SaveRestoreRegisterOpcode { <nl> + u32 dst_index { } ; <nl> + u32 src_index { } ; <nl> + SaveRestoreRegisterOpType op_type { } ; <nl> + } ; <nl> + <nl> + struct SaveRestoreRegisterMaskOpcode { <nl> + SaveRestoreRegisterOpType op_type { } ; <nl> + std : : array < bool , 0x10 > should_operate { } ; <nl> + } ; <nl> + <nl> + struct DebugLogOpcode { <nl> + u32 bit_width { } ; <nl> + u32 log_id { } ; <nl> + DebugLogValueType val_type { } ; <nl> + MemoryAccessType mem_type { } ; <nl> + u32 addr_reg_index { } ; <nl> + u32 val_reg_index { } ; <nl> + u32 ofs_reg_index { } ; <nl> + u64 rel_address { } ; <nl> + } ; <nl> + <nl> + struct UnrecognizedInstruction { <nl> + CheatVmOpcodeType opcode { } ; <nl> + } ; <nl> + <nl> + struct CheatVmOpcode { <nl> + bool begin_conditional_block { } ; <nl> + std : : variant < StoreStaticOpcode , BeginConditionalOpcode , EndConditionalOpcode , ControlLoopOpcode , <nl> + LoadRegisterStaticOpcode , LoadRegisterMemoryOpcode , StoreStaticToAddressOpcode , <nl> + PerformArithmeticStaticOpcode , BeginKeypressConditionalOpcode , <nl> + PerformArithmeticRegisterOpcode , StoreRegisterToAddressOpcode , <nl> + BeginRegisterConditionalOpcode , SaveRestoreRegisterOpcode , <nl> + SaveRestoreRegisterMaskOpcode , DebugLogOpcode , UnrecognizedInstruction > <nl> + opcode { } ; <nl> + } ; <nl> + <nl> + class DmntCheatVm { <nl> + public : <nl> + / / / Helper Type for DmntCheatVm < = > yuzu Interface <nl> + class Callbacks { <nl> + public : <nl> + virtual ~ Callbacks ( ) ; <nl> + <nl> + virtual void MemoryRead ( VAddr address , void * data , u64 size ) = 0 ; <nl> + virtual void MemoryWrite ( VAddr address , const void * data , u64 size ) = 0 ; <nl> + <nl> + virtual u64 HidKeysDown ( ) = 0 ; <nl> + <nl> + virtual void DebugLog ( u8 id , u64 value ) = 0 ; <nl> + virtual void CommandLog ( std : : string_view data ) = 0 ; <nl> + } ; <nl> + <nl> + static constexpr std : : size_t MaximumProgramOpcodeCount = 0x400 ; <nl> + static constexpr std : : size_t NumRegisters = 0x10 ; <nl> + <nl> + explicit DmntCheatVm ( std : : unique_ptr < Callbacks > callbacks ) ; <nl> + ~ DmntCheatVm ( ) ; <nl> + <nl> + std : : size_t GetProgramSize ( ) const { <nl> + return this - > num_opcodes ; <nl> + } <nl> + <nl> + bool LoadProgram ( const std : : vector < CheatEntry > & cheats ) ; <nl> + void Execute ( const CheatProcessMetadata & metadata ) ; <nl> + <nl> + private : <nl> + std : : unique_ptr < Callbacks > callbacks ; <nl> + <nl> + std : : size_t num_opcodes = 0 ; <nl> + std : : size_t instruction_ptr = 0 ; <nl> + std : : size_t condition_depth = 0 ; <nl> + bool decode_success = false ; <nl> + std : : array < u32 , MaximumProgramOpcodeCount > program { } ; <nl> + std : : array < u64 , NumRegisters > registers { } ; <nl> + std : : array < u64 , NumRegisters > saved_values { } ; <nl> + std : : array < std : : size_t , NumRegisters > loop_tops { } ; <nl> + <nl> + bool DecodeNextOpcode ( CheatVmOpcode & out ) ; <nl> + void SkipConditionalBlock ( ) ; <nl> + void ResetState ( ) ; <nl> + <nl> + / / For implementing the DebugLog opcode . <nl> + void DebugLog ( u32 log_id , u64 value ) ; <nl> + <nl> + void LogOpcode ( const CheatVmOpcode & opcode ) ; <nl> + <nl> + static u64 GetVmInt ( VmInt value , u32 bit_width ) ; <nl> + static u64 GetCheatProcessAddress ( const CheatProcessMetadata & metadata , <nl> + MemoryAccessType mem_type , u64 rel_address ) ; <nl> + } ; <nl> + <nl> + } ; / / namespace Memory <nl> | Merge pull request from DarkLordZach / cheat - v2 | yuzu-emu/yuzu | 9187350b322c3140c2bec3938b91289ab55e9aae | 2019-09-22T06:24:42Z |
mmm a / src / webui / btjson . cpp <nl> ppp b / src / webui / btjson . cpp <nl> static QVariantMap toMap ( const QTorrentHandle & h ) <nl> ret [ KEY_TORRENT_RATIO ] = ( ratio > QBtSession : : MAX_RATIO ) ? - 1 : ratio ; <nl> ret [ KEY_TORRENT_STATE ] = h . torrentState ( ) . toString ( ) ; <nl> ret [ KEY_TORRENT_ETA ] = h . eta ( ) ; <nl> - if ( h . has_metadata ( ) ) { <nl> - if ( status . sequential_download ) <nl> - ret [ KEY_TORRENT_SEQUENTIAL_DOWNLOAD ] = true ; <nl> - if ( h . first_last_piece_first ( ) ) <nl> - ret [ KEY_TORRENT_FIRST_LAST_PIECE_PRIO ] = true ; <nl> - } <nl> + ret [ KEY_TORRENT_SEQUENTIAL_DOWNLOAD ] = status . sequential_download ; <nl> + if ( h . has_metadata ( ) ) <nl> + ret [ KEY_TORRENT_FIRST_LAST_PIECE_PRIO ] = h . first_last_piece_first ( ) ; <nl> <nl> return ret ; <nl> } <nl> mmm a / src / webui / www / public / scripts / client . js <nl> ppp b / src / webui / www / public / scripts / client . js <nl> var updateTransferInfo = function ( ) { } ; <nl> var updateTransferList = function ( ) { } ; <nl> var alternativeSpeedLimits = false ; <nl> <nl> - var stateToImg = function ( state ) { <nl> - if ( state = = " pausedUP " | | state = = " pausedDL " ) { <nl> - state = " paused " ; <nl> - } else { <nl> - if ( state = = " queuedUP " | | state = = " queuedDL " ) { <nl> - state = " queued " ; <nl> - } else { <nl> - if ( state = = " checkingUP " | | state = = " checkingDL " ) { <nl> - state = " checking " ; <nl> - } <nl> - } <nl> + selected_filter = getLocalStorageItem ( ' selected_filter ' , ' all ' ) ; <nl> + selected_label = null ; <nl> + <nl> + var loadSelectedLabel = function ( ) { <nl> + if ( getLocalStorageItem ( ' any_label ' , ' 1 ' ) = = ' 0 ' ) <nl> + selected_label = getLocalStorageItem ( ' selected_label ' , ' ' ) ; <nl> + else <nl> + selected_label = null ; <nl> + } <nl> + loadSelectedLabel ( ) ; <nl> + <nl> + var saveSelectedLabel = function ( ) { <nl> + if ( selected_label = = null ) <nl> + localStorage . setItem ( ' any_label ' , ' 1 ' ) ; <nl> + else { <nl> + localStorage . setItem ( ' any_label ' , ' 0 ' ) ; <nl> + localStorage . setItem ( ' selected_label ' , selected_label ) ; <nl> } <nl> - return ' images / skin / ' + state + ' . png ' ; <nl> - } ; <nl> + } <nl> <nl> - filter = getLocalStorageItem ( ' selected_filter ' , ' all ' ) ; <nl> <nl> window . addEvent ( ' load ' , function ( ) { <nl> <nl> window . addEvent ( ' load ' , function ( ) { <nl> $ ( " active_filter " ) . removeClass ( " selectedFilter " ) ; <nl> $ ( " inactive_filter " ) . removeClass ( " selectedFilter " ) ; <nl> $ ( f + " _filter " ) . addClass ( " selectedFilter " ) ; <nl> - filter = f ; <nl> + selected_filter = f ; <nl> localStorage . setItem ( ' selected_filter ' , f ) ; <nl> / / Reload torrents <nl> if ( typeof myTable . table ! = ' undefined ' ) <nl> window . addEvent ( ' load ' , function ( ) { <nl> loadMethod : ' xhr ' , <nl> contentURL : ' filters . html ' , <nl> onContentLoaded : function ( ) { <nl> - setFilter ( filter ) ; <nl> + setFilter ( selected_filter ) ; <nl> } , <nl> column : ' filtersColumn ' , <nl> height : 300 <nl> window . addEvent ( ' load ' , function ( ) { <nl> <nl> var loadTorrentsInfoTimer ; <nl> var loadTorrentsInfo = function ( ) { <nl> - var queueing_enabled = false ; <nl> var url = new URI ( ' json / torrents ' ) ; <nl> - url . setData ( ' filter ' , filter ) ; <nl> - url . setData ( ' sort ' , myTable . table . sortedColumn ) ; <nl> - url . setData ( ' reverse ' , myTable . table . reverseSort ) ; <nl> var request = new Request . JSON ( { <nl> url : url , <nl> noCache : true , <nl> window . addEvent ( ' load ' , function ( ) { <nl> clearTimeout ( loadTorrentsInfoTimer ) ; <nl> loadTorrentsInfoTimer = loadTorrentsInfo . delay ( 2000 ) ; <nl> } , <nl> - onSuccess : function ( events ) { <nl> + onSuccess : function ( response ) { <nl> $ ( ' error_div ' ) . set ( ' html ' , ' ' ) ; <nl> - if ( events ) { <nl> - / / Add new torrents or update them <nl> - torrent_hashes = myTable . getRowIds ( ) ; <nl> - events_hashes = new Array ( ) ; <nl> - pos = 0 ; <nl> - events . each ( function ( event ) { <nl> - events_hashes [ events_hashes . length ] = event . hash ; <nl> - var row = new Array ( ) ; <nl> - var data = new Array ( ) ; <nl> - row . length = 10 ; <nl> - row [ 0 ] = stateToImg ( event . state ) ; <nl> - row [ 1 ] = event . name ; <nl> - row [ 2 ] = event . priority > - 1 ? event . priority : null ; <nl> - data [ 2 ] = event . priority ; <nl> - row [ 3 ] = friendlyUnit ( event . size , false ) ; <nl> - data [ 3 ] = event . size ; <nl> - row [ 4 ] = ( event . progress * 100 ) . round ( 1 ) ; <nl> - if ( row [ 4 ] = = 100 . 0 & & event . progress ! = 1 . 0 ) <nl> - row [ 4 ] = 99 . 9 ; <nl> - data [ 4 ] = event . progress ; <nl> - row [ 5 ] = event . num_seeds ; <nl> - if ( event . num_complete ! = - 1 ) <nl> - row [ 5 ] + = " ( " + event . num_complete + " ) " ; <nl> - data [ 5 ] = event . num_seeds ; <nl> - row [ 6 ] = event . num_leechs ; <nl> - if ( event . num_incomplete ! = - 1 ) <nl> - row [ 6 ] + = " ( " + event . num_incomplete + " ) " ; <nl> - data [ 6 ] = event . num_leechs ; <nl> - row [ 7 ] = friendlyUnit ( event . dlspeed , true ) ; <nl> - data [ 7 ] = event . dlspeed ; <nl> - row [ 8 ] = friendlyUnit ( event . upspeed , true ) ; <nl> - data [ 8 ] = event . upspeed ; <nl> - row [ 9 ] = friendlyDuration ( event . eta ) ; <nl> - data [ 9 ] = event . eta ; <nl> - if ( event . ratio = = - 1 ) <nl> - row [ 10 ] = " ∞ " ; <nl> - else <nl> - row [ 10 ] = ( Math . floor ( 100 * event . ratio ) / 100 ) . toFixed ( 2 ) ; / / Don ' t round up <nl> - data [ 10 ] = event . ratio ; <nl> - if ( row [ 2 ] ! = null ) <nl> + if ( response ) { <nl> + var queueing_enabled = false ; <nl> + var torrents_hashes = new Array ( ) ; <nl> + for ( var i = 0 ; i < response . length ; i + + ) { <nl> + torrents_hashes . push ( response [ i ] . hash ) ; <nl> + if ( response [ i ] . priority > - 1 ) <nl> queueing_enabled = true ; <nl> + myTable . updateRowData ( response [ i ] ) <nl> + } <nl> + <nl> + var keys = myTable . rows . getKeys ( ) ; <nl> + for ( var i = 0 ; i < keys . length ; i + + ) { <nl> + if ( ! torrents_hashes . contains ( keys [ i ] ) ) <nl> + myTable . rows . erase ( keys [ i ] ) ; <nl> + } <nl> <nl> - attrs = { } ; <nl> - attrs [ ' downloaded ' ] = ( event . progress = = 1 . 0 ) ; <nl> - attrs [ ' state ' ] = event . state ; <nl> - attrs [ ' seq_dl ' ] = ( event . seq_dl = = true ) ; <nl> - attrs [ ' f_l_piece_prio ' ] = ( event . f_l_piece_prio = = true ) ; <nl> - <nl> - if ( ! torrent_hashes . contains ( event . hash ) ) { <nl> - / / New unfinished torrent <nl> - torrent_hashes [ torrent_hashes . length ] = event . hash ; <nl> - / / alert ( " Inserting row " ) ; <nl> - myTable . insertRow ( event . hash , row , data , attrs , pos ) ; <nl> - } else { <nl> - / / Update torrent data <nl> - myTable . updateRow ( event . hash , row , data , attrs , pos ) ; <nl> - } <nl> - <nl> - pos + + ; <nl> - } ) ; <nl> - / / Remove deleted torrents <nl> - torrent_hashes . each ( function ( hash ) { <nl> - if ( ! events_hashes . contains ( hash ) ) { <nl> - myTable . removeRow ( hash ) ; <nl> - } <nl> - } ) ; <nl> + myTable . columns [ ' priority ' ] . force_hide = ! queueing_enabled ; <nl> + myTable . updateColumn ( ' priority ' ) ; <nl> if ( queueing_enabled ) { <nl> $ ( ' queueingButtons ' ) . removeClass ( ' invisible ' ) ; <nl> $ ( ' queueingMenuItems ' ) . removeClass ( ' invisible ' ) ; <nl> - myTable . showPriority ( ) ; <nl> - } else { <nl> + } <nl> + else { <nl> $ ( ' queueingButtons ' ) . addClass ( ' invisible ' ) ; <nl> $ ( ' queueingMenuItems ' ) . addClass ( ' invisible ' ) ; <nl> - myTable . hidePriority ( ) ; <nl> } <nl> <nl> + myTable . updateTable ( true ) ; <nl> myTable . altRow ( ) ; <nl> } <nl> clearTimeout ( loadTorrentsInfoTimer ) ; <nl> window . addEvent ( ' load ' , function ( ) { <nl> } ; <nl> <nl> updateTransferList = function ( ) { <nl> + myTable . updateTable ( ) ; <nl> clearTimeout ( loadTorrentsInfoTimer ) ; <nl> - loadTorrentsInfo ( ) ; <nl> + loadTorrentsInfoTimer = loadTorrentsInfo . delay ( 30 ) ; <nl> } <nl> <nl> var loadTransferInfoTimer ; <nl> mmm a / src / webui / www / public / scripts / contextmenu . js <nl> ppp b / src / webui / www / public / scripts / contextmenu . js <nl> var ContextMenu = new Class ( { <nl> <nl> var h = myTable . selectedIds ( ) ; <nl> h . each ( function ( item , index ) { <nl> - tr = myTable . rows . get ( item ) ; <nl> + var data = myTable . rows . get ( item ) . full_data ; <nl> <nl> - if ( tr . getAttribute ( ' seq_dl ' ) ! = ' true ' ) <nl> + if ( data [ ' seq_dl ' ] ! = true ) <nl> all_are_seq_dl = false ; <nl> else <nl> there_are_seq_dl = true ; <nl> <nl> - if ( tr . getAttribute ( ' f_l_piece_prio ' ) ! = ' true ' ) <nl> + if ( data [ ' f_l_piece_prio ' ] ! = true ) <nl> all_are_f_l_piece_prio = false ; <nl> else <nl> there_are_f_l_piece_prio = true ; <nl> <nl> - if ( tr . getAttribute ( ' downloaded ' ) ! = ' true ' ) <nl> + if ( data [ ' progress ' ] ! = 1 . 0 ) / / not downloaded <nl> all_are_downloaded = false ; <nl> <nl> - state = tr . getAttribute ( ' state ' ) ; <nl> + state = data [ ' state ' ] ; <nl> if ( ( state ! = ' pausedUP ' ) & & ( state ! = ' pausedDL ' ) ) <nl> all_are_paused = false ; <nl> else <nl> mmm a / src / webui / www / public / scripts / dynamicTable . js <nl> ppp b / src / webui / www / public / scripts / dynamicTable . js <nl> var dynamicTable = new Class ( { <nl> <nl> initialize : function ( ) { } , <nl> <nl> - setup : function ( table , progressIndex , context_menu ) { <nl> + setup : function ( table , context_menu ) { <nl> this . table = $ ( table ) ; <nl> this . rows = new Hash ( ) ; <nl> this . cur = new Array ( ) ; <nl> - this . priority_hidden = false ; <nl> - this . progressIndex = progressIndex ; <nl> + this . columns = new Array ( ) ; <nl> this . context_menu = context_menu ; <nl> - this . table . sortedColumn = getLocalStorageItem ( ' sorted_column ' , ' name ' ) ; <nl> - this . table . reverseSort = getLocalStorageItem ( ' reverse_sort ' , ' false ' ) ; ; <nl> + this . sortedColumn = getLocalStorageItem ( ' sorted_column ' , ' name ' ) ; <nl> + this . reverseSort = getLocalStorageItem ( ' reverse_sort ' , ' 0 ' ) ; <nl> + this . initColumns ( ) ; <nl> + this . loadColumnsOrder ( ) ; <nl> + this . updateHeader ( ) ; <nl> + } , <nl> + <nl> + initColumns : function ( ) { <nl> + this . newColumn ( ' state_icon ' , ' width : 16px ' , ' ' ) ; <nl> + this . newColumn ( ' name ' , ' min - width : 200px ; cursor : pointer ' , ' QBT_TR ( Name ) QBT_TR ' ) ; <nl> + this . newColumn ( ' priority ' , ' width : 90px ; cursor : pointer ' , ' # ' ) ; <nl> + this . newColumn ( ' size ' , ' width : 100px ; cursor : pointer ' , ' QBT_TR ( Size ) QBT_TR ' ) ; <nl> + this . newColumn ( ' progress ' , ' width : 80px ; cursor : pointer ' , ' QBT_TR ( Done ) QBT_TR ' ) ; <nl> + this . newColumn ( ' num_seeds ' , ' width : 100px ; cursor : pointer ' , ' QBT_TR ( Seeds ) QBT_TR ' ) ; <nl> + this . newColumn ( ' num_leechs ' , ' width : 100px ; cursor : pointer ' , ' QBT_TR ( Peers ) QBT_TR ' ) ; <nl> + this . newColumn ( ' dlspeed ' , ' width : 100px ; cursor : pointer ' , ' QBT_TR ( Down Speed ) QBT_TR ' ) ; <nl> + this . newColumn ( ' upspeed ' , ' width : 100px ; cursor : pointer ' , ' QBT_TR ( Up Speed ) QBT_TR ' ) ; <nl> + this . newColumn ( ' eta ' , ' width : 100px ; cursor : pointer ' , ' QBT_TR ( ETA ) QBT_TR ' ) ; <nl> + this . newColumn ( ' ratio ' , ' width : 100px ; cursor : pointer ' , ' QBT_TR ( Ratio ) QBT_TR ' ) ; <nl> + <nl> + this . columns [ ' state_icon ' ] . onclick = ' ' ; <nl> + this . columns [ ' state_icon ' ] . dataProperties [ 0 ] = ' state ' ; <nl> + <nl> + this . columns [ ' num_seeds ' ] . dataProperties . push ( ' num_complete ' ) ; <nl> + <nl> + this . columns [ ' num_leechs ' ] . dataProperties . push ( ' num_incomplete ' ) ; <nl> + <nl> + this . initColumnsFunctions ( ) ; <nl> + } , <nl> + <nl> + newColumn : function ( name , style , caption ) { <nl> + var column = { } ; <nl> + column [ ' name ' ] = name ; <nl> + column [ ' visible ' ] = getLocalStorageItem ( ' column_ ' + name + ' _visible ' , ' 1 ' ) ; <nl> + column [ ' force_hide ' ] = false ; <nl> + column [ ' caption ' ] = caption ; <nl> + column [ ' style ' ] = style ; <nl> + column [ ' onclick ' ] = ' setSortedColumn ( \ ' ' + name + ' \ ' ) ; ' ; <nl> + column [ ' dataProperties ' ] = [ name ] ; <nl> + column [ ' getRowValue ' ] = function ( row , pos ) { <nl> + if ( pos = = undefined ) <nl> + pos = 0 ; <nl> + return row [ ' full_data ' ] [ this . dataProperties [ pos ] ] ; <nl> + } ; <nl> + column [ ' compareRows ' ] = function ( row1 , row2 ) { <nl> + if ( this . getRowValue ( row1 ) < this . getRowValue ( row2 ) ) <nl> + return - 1 ; <nl> + else if ( this . getRowValue ( row1 ) > this . getRowValue ( row2 ) ) <nl> + return 1 ; <nl> + else return 0 ; <nl> + } ; <nl> + column [ ' updateTd ' ] = function ( td , row ) { <nl> + td . innerHTML = this . getRowValue ( row ) ; <nl> + } ; <nl> + this . columns . push ( column ) ; <nl> + this . columns [ name ] = column ; <nl> + <nl> + $ ( ' torrentTableHeader ' ) . appendChild ( new Element ( ' th ' ) ) ; <nl> + } , <nl> + <nl> + loadColumnsOrder : function ( ) { <nl> + columnsOrder = [ ' state_icon ' ] ; / / status icon column is always the first <nl> + val = localStorage . getItem ( ' columns_order ' ) ; <nl> + if ( val = = = null | | val = = = undefined ) return ; <nl> + val . split ( ' , ' ) . forEach ( function ( v ) { <nl> + if ( ( v in this . columns ) & & ( ! columnsOrder . contains ( v ) ) ) <nl> + columnsOrder . push ( v ) ; <nl> + } . bind ( this ) ) ; <nl> + <nl> + for ( i = 0 ; i < this . columns . length ; i + + ) <nl> + if ( ! columnsOrder . contains ( this . columns [ i ] . name ) ) <nl> + columnsOrder . push ( this . columns [ i ] . name ) ; <nl> + <nl> + for ( i = 0 ; i < this . columns . length ; i + + ) <nl> + this . columns [ i ] = this . columns [ columnsOrder [ i ] ] ; <nl> + } , <nl> + <nl> + saveColumnsOrder : function ( ) { <nl> + val = ' ' ; <nl> + for ( i = 0 ; i < this . columns . length ; i + + ) { <nl> + if ( i > 0 ) <nl> + val + = ' , ' ; <nl> + val + = this . columns [ i ] . name ; <nl> + } <nl> + localStorage . setItem ( ' columns_order ' , val ) ; <nl> + } , <nl> + <nl> + updateHeader : function ( ) { <nl> + ths = $ ( ' torrentTableHeader ' ) . getElements ( ' th ' ) ; <nl> + <nl> + for ( var i = 0 ; i < ths . length ; i + + ) { <nl> + th = ths [ i ] ; <nl> + th . setAttribute ( ' onclick ' , this . columns [ i ] . onclick ) ; <nl> + th . innerHTML = this . columns [ i ] . caption ; <nl> + th . setAttribute ( ' style ' , this . columns [ i ] . style ) ; <nl> + if ( ( this . columns [ i ] . visible = = ' 0 ' ) | | this . columns [ i ] . force_hide ) <nl> + th . addClass ( ' invisible ' ) ; <nl> + else <nl> + th . removeClass ( ' invisible ' ) ; <nl> + } <nl> + } , <nl> + <nl> + getColumnPos : function ( columnName ) { <nl> + for ( var i = 0 ; i < this . columns . length ; i + + ) <nl> + if ( this . columns [ i ] . name = = columnName ) <nl> + return i ; <nl> + return - 1 ; <nl> + } , <nl> + <nl> + updateColumn : function ( columnName ) { <nl> + var pos = this . getColumnPos ( columnName ) ; <nl> + var visible = ( ( this . columns [ pos ] . visible ! = ' 0 ' ) & & ! this . columns [ pos ] . force_hide ) ; <nl> + var ths = $ ( ' torrentTableHeader ' ) . getElements ( ' th ' ) ; <nl> + if ( visible ) <nl> + ths [ pos ] . removeClass ( ' invisible ' ) ; <nl> + else <nl> + ths [ pos ] . addClass ( ' invisible ' ) ; <nl> + var trs = this . table . getElements ( ' tr ' ) ; <nl> + for ( var i = 0 ; i < trs . length ; i + + ) <nl> + if ( visible ) <nl> + trs [ i ] . getElements ( ' td ' ) [ pos ] . removeClass ( ' invisible ' ) ; <nl> + else <nl> + trs [ i ] . getElements ( ' td ' ) [ pos ] . addClass ( ' invisible ' ) ; <nl> } , <nl> <nl> setSortedColumn : function ( column ) { <nl> - if ( column ! = this . table . sortedColumn ) { <nl> - this . table . sortedColumn = column ; <nl> - this . table . reverseSort = ' false ' ; <nl> - } else { <nl> + if ( column ! = this . sortedColumn ) { <nl> + this . sortedColumn = column ; <nl> + this . reverseSort = ' 0 ' ; <nl> + } <nl> + else { <nl> / / Toggle sort order <nl> - this . table . reverseSort = this . table . reverseSort = = ' true ' ? ' false ' : ' true ' ; <nl> + this . reverseSort = this . reverseSort = = ' 0 ' ? ' 1 ' : ' 0 ' ; <nl> } <nl> localStorage . setItem ( ' sorted_column ' , column ) ; <nl> - localStorage . setItem ( ' reverse_sort ' , this . table . reverseSort ) ; <nl> + localStorage . setItem ( ' reverse_sort ' , this . reverseSort ) ; <nl> } , <nl> <nl> getCurrentTorrentHash : function ( ) { <nl> var dynamicTable = new Class ( { <nl> } . bind ( this ) ) ; <nl> } , <nl> <nl> - hidePriority : function ( ) { <nl> - if ( this . priority_hidden ) <nl> - return ; <nl> - $ ( ' prioHeader ' ) . addClass ( ' invisible ' ) ; <nl> + selectAll : function ( ) { <nl> + this . cur . empty ( ) ; <nl> + <nl> var trs = this . table . getElements ( ' tr ' ) ; <nl> - trs . each ( function ( tr , i ) { <nl> - var tds = tr . getElements ( ' td ' ) ; <nl> - tds [ 2 ] . addClass ( ' invisible ' ) ; <nl> - } . bind ( this ) ) ; <nl> - this . priority_hidden = true ; <nl> + for ( var i = 0 ; i < trs . length ; i + + ) { <nl> + var tr = trs [ i ] ; <nl> + this . cur . push ( tr . hash ) ; <nl> + if ( ! tr . hasClass ( ' selected ' ) ) <nl> + tr . addClass ( ' selected ' ) ; <nl> + } <nl> } , <nl> <nl> - showPriority : function ( ) { <nl> - if ( ! this . priority_hidden ) <nl> - return ; <nl> - $ ( ' prioHeader ' ) . removeClass ( ' invisible ' ) ; <nl> + selectRow : function ( hash ) { <nl> + this . cur . empty ( ) ; <nl> + this . cur . push ( hash ) ; <nl> var trs = this . table . getElements ( ' tr ' ) ; <nl> - trs . each ( function ( tr , i ) { <nl> - var tds = tr . getElements ( ' td ' ) ; <nl> - tds [ 2 ] . removeClass ( ' invisible ' ) ; <nl> - } . bind ( this ) ) ; <nl> - this . priority_hidden = false ; <nl> + for ( var i = 0 ; i < trs . length ; i + + ) { <nl> + var tr = trs [ i ] ; <nl> + if ( tr . hash = = hash ) { <nl> + if ( ! tr . hasClass ( ' selected ' ) ) <nl> + tr . addClass ( ' selected ' ) ; <nl> + } <nl> + else <nl> + if ( tr . hasClass ( ' selected ' ) ) <nl> + tr . removeClass ( ' selected ' ) ; <nl> + } <nl> } , <nl> <nl> - insertRow : function ( id , row , data , attrs , pos ) { <nl> - if ( this . rows . has ( id ) ) { <nl> - return ; <nl> + updateRowData : function ( data ) { <nl> + var hash = data [ ' hash ' ] ; <nl> + var row ; <nl> + <nl> + if ( ! this . rows . has ( hash ) ) { <nl> + row = { } ; <nl> + this . rows . set ( hash , row ) ; <nl> + row [ ' full_data ' ] = { } ; <nl> + row [ ' hash ' ] = hash ; <nl> } <nl> - var tr = new Element ( ' tr ' ) ; <nl> - for ( var a in attrs ) <nl> - tr . set ( a , attrs [ a ] ) ; <nl> - tr . addClass ( " menu - target " ) ; <nl> - this . rows . set ( id , tr ) ; <nl> - for ( var i = 0 ; i < row . length ; i + + ) { <nl> - var td = new Element ( ' td ' ) ; <nl> - if ( i = = this . progressIndex ) { <nl> - td . adopt ( new ProgressBar ( row [ i ] . toFloat ( ) , { <nl> - ' id ' : ' pb_ ' + id , <nl> - ' width ' : 80 <nl> - } ) ) ; <nl> - if ( typeof data [ i ] ! = ' undefined ' ) <nl> - td . set ( ' data - raw ' , data [ i ] ) <nl> - } else { <nl> - if ( i = = 0 ) { <nl> - td . adopt ( new Element ( ' img ' , { <nl> - ' src ' : row [ i ] , <nl> - ' class ' : ' statusIcon ' <nl> - } ) ) ; <nl> - } else { <nl> - if ( i = = 2 ) { <nl> - / / Priority <nl> - if ( this . priority_hidden ) <nl> - td . addClass ( ' invisible ' ) ; <nl> - } <nl> - td . set ( ' html ' , row [ i ] ) ; <nl> - if ( typeof data [ i ] ! = ' undefined ' ) <nl> - td . set ( ' data - raw ' , data [ i ] ) <nl> - } <nl> + else <nl> + row = this . rows . get ( hash ) ; <nl> + <nl> + row [ ' data ' ] = data ; <nl> + <nl> + for ( var x in data ) <nl> + row [ ' full_data ' ] [ x ] = data [ x ] ; <nl> + } , <nl> + <nl> + applyFilter : function ( row , filterName , labelName ) { <nl> + var state = row [ ' full_data ' ] . state ; <nl> + switch ( filterName ) { <nl> + case ' downloading ' : <nl> + if ( ( state ! = ' downloading ' ) & & ! ~ state . indexOf ( ' DL ' ) ) <nl> + return false ; <nl> + break ; <nl> + case ' completed ' : <nl> + if ( ( state ! = ' uploading ' ) & & ! ~ state . indexOf ( ' UP ' ) ) <nl> + return false ; <nl> + break ; <nl> + case ' paused ' : <nl> + if ( ! ~ state . indexOf ( ' paused ' ) ) <nl> + return false ; <nl> + break ; <nl> + case ' active ' : <nl> + if ( ( state ! = ' uploading ' ) & & ( state ! = ' downloading ' ) ) <nl> + return false ; <nl> + break ; <nl> + case ' inactive ' : <nl> + if ( ( state = = ' uploading ' ) | | ( state = = ' downloading ' ) ) <nl> + return false ; <nl> + break ; <nl> + } <nl> + <nl> + if ( labelName = = null ) <nl> + return true ; <nl> + <nl> + if ( labelName ! = row [ ' full_data ' ] . label ) <nl> + return false ; <nl> + <nl> + return true ; <nl> + } , <nl> + <nl> + getFilteredAndSortedRows : function ( ) { <nl> + var filteredRows = new Array ( ) ; <nl> + <nl> + var rows = this . rows . getValues ( ) ; <nl> + <nl> + for ( i = 0 ; i < rows . length ; i + + ) <nl> + if ( this . applyFilter ( rows [ i ] , selected_filter , selected_label ) ) { <nl> + filteredRows . push ( rows [ i ] ) ; <nl> + filteredRows [ rows [ i ] . hash ] = rows [ i ] ; <nl> } <nl> - td . injectInside ( tr ) ; <nl> - } ; <nl> <nl> - tr . addEvent ( ' mouseover ' , function ( e ) { <nl> - tr . addClass ( ' over ' ) ; <nl> - } . bind ( this ) ) ; <nl> - tr . addEvent ( ' mouseout ' , function ( e ) { <nl> - tr . removeClass ( ' over ' ) ; <nl> + filteredRows . sort ( function ( row1 , row2 ) { <nl> + column = this . columns [ this . sortedColumn ] ; <nl> + res = column . compareRows ( row1 , row2 ) ; <nl> + if ( this . reverseSort = = ' 0 ' ) <nl> + return res ; <nl> + else <nl> + return - res ; <nl> } . bind ( this ) ) ; <nl> - tr . addEvent ( ' contextmenu ' , function ( e ) { <nl> - if ( ! this . cur . contains ( id ) ) { <nl> - / / Remove selected style from previous ones <nl> - for ( i = 0 ; i < this . cur . length ; i + + ) { <nl> - if ( this . rows . has ( this . cur [ i ] ) ) { <nl> - var temptr = this . rows . get ( this . cur [ i ] ) ; <nl> - temptr . removeClass ( ' selected ' ) ; <nl> - } <nl> - } <nl> - this . cur . empty ( ) ; <nl> - this . cur [ this . cur . length ] = id ; <nl> - temptr = this . rows . get ( id ) ; <nl> - temptr . addClass ( " selected " ) ; <nl> + return filteredRows ; <nl> + } , <nl> + <nl> + getTrByHash : function ( hash ) { <nl> + trs = this . table . getElements ( ' tr ' ) ; <nl> + for ( var i = 0 ; i < trs . length ; i + + ) <nl> + if ( trs [ i ] . hash = = hash ) <nl> + return trs [ i ] ; <nl> + return null ; <nl> + } , <nl> + <nl> + updateTable : function ( fullUpdate ) { <nl> + if ( fullUpdate = = undefined ) <nl> + fullUpdate = false ; <nl> + <nl> + var rows = this . getFilteredAndSortedRows ( ) ; <nl> + <nl> + for ( var i = 0 ; i < this . cur . length ; i + + ) <nl> + if ( ! ( this . cur [ i ] in rows ) ) { <nl> + this . cur . splice ( i , 1 ) ; <nl> + i - - ; <nl> } <nl> - return true ; <nl> - } . bind ( this ) ) ; <nl> - tr . addEvent ( ' click ' , function ( e ) { <nl> - e . stop ( ) ; <nl> - if ( e . control ) { <nl> - / / CTRL key was pressed <nl> - if ( this . cur . contains ( id ) ) { <nl> - / / remove it <nl> - this . cur . erase ( id ) ; <nl> - / / Remove selected style <nl> - if ( this . rows . has ( id ) ) { <nl> - temptr = this . rows . get ( id ) ; <nl> - temptr . removeClass ( ' selected ' ) ; <nl> - } <nl> - } else { <nl> - this . cur [ this . cur . length ] = id ; <nl> - / / Add selected style <nl> - if ( this . rows . has ( id ) ) { <nl> - temptr = this . rows . get ( id ) ; <nl> - temptr . addClass ( ' selected ' ) ; <nl> - } <nl> + <nl> + var trs = this . table . getElements ( ' tr ' ) ; <nl> + <nl> + for ( var rowPos = 0 ; rowPos < rows . length ; rowPos + + ) { <nl> + var hash = rows [ rowPos ] [ ' hash ' ] ; <nl> + tr_found = false ; <nl> + for ( j = rowPos ; j < trs . length ; j + + ) <nl> + if ( trs [ j ] [ ' hash ' ] = = hash ) { <nl> + trs [ rowPos ] . removeClass ( ' over ' ) ; <nl> + tr_found = true ; <nl> + if ( rowPos = = j ) <nl> + break ; <nl> + trs [ j ] . inject ( trs [ rowPos ] , ' before ' ) ; <nl> + var tmpTr = trs [ j ] ; <nl> + trs . splice ( j , 1 ) ; <nl> + trs . splice ( rowPos , 0 , tmpTr ) ; <nl> + break ; <nl> } <nl> - } else { <nl> - if ( e . shift & & this . cur . length = = 1 ) { <nl> - / / Shift key was pressed <nl> - var first_id = this . cur [ 0 ] ; <nl> - var first_tr = this . rows . get ( first_id ) ; <nl> - var last_id = id ; <nl> - var last_tr = this . rows . get ( last_id ) ; <nl> - var all_trs = this . table . getChildren ( ' tr ' ) ; <nl> - var index_first_tr = all_trs . indexOf ( first_tr ) ; <nl> - var index_last_tr = all_trs . indexOf ( last_tr ) ; <nl> - var trs_to_select = all_trs . filter ( function ( item , index ) { <nl> - if ( index_first_tr < index_last_tr ) <nl> - return ( index > index_first_tr ) & & ( index < = index_last_tr ) ; <nl> - else <nl> - return ( index < index_first_tr ) & & ( index > = index_last_tr ) ; <nl> - } ) ; <nl> - trs_to_select . each ( function ( item , index ) { <nl> - / / Add to selection <nl> - this . cur [ this . cur . length ] = this . getRowId ( item ) ; <nl> - / / Select it visually <nl> - item . addClass ( ' selected ' ) ; <nl> - } . bind ( this ) ) ; <nl> - } else { <nl> - / / Simple selection <nl> - / / Remove selected style from previous ones <nl> - for ( i = 0 ; i < this . cur . length ; i + + ) { <nl> - if ( this . rows . has ( this . cur [ i ] ) ) { <nl> - var temptr = this . rows . get ( this . cur [ i ] ) ; <nl> - temptr . removeClass ( ' selected ' ) ; <nl> + if ( tr_found ) / / row already exists in the table <nl> + this . updateRow ( trs [ rowPos ] , fullUpdate ) ; <nl> + else { / / else create a new row in the table <nl> + var tr = new Element ( ' tr ' ) ; <nl> + <nl> + tr . addClass ( " menu - target " ) ; <nl> + tr [ ' hash ' ] = rows [ rowPos ] [ ' hash ' ] ; <nl> + <nl> + tr . addEvent ( ' contextmenu ' , function ( e ) { <nl> + if ( ! myTable . cur . contains ( this . hash ) ) <nl> + myTable . selectRow ( this . hash ) ; <nl> + return true ; <nl> + } ) ; <nl> + tr . addEvent ( ' click ' , function ( e ) { <nl> + e . stop ( ) ; <nl> + if ( e . control ) { <nl> + / / CTRL key was pressed <nl> + if ( myTable . cur . contains ( this . hash ) ) { <nl> + / / remove it <nl> + myTable . cur . erase ( this . hash ) ; <nl> + / / Remove selected style <nl> + this . removeClass ( ' selected ' ) ; <nl> + } <nl> + else { <nl> + myTable . cur . push ( this . hash ) ; <nl> + / / Add selected style <nl> + this . addClass ( ' selected ' ) ; <nl> } <nl> } <nl> - this . cur . empty ( ) ; <nl> - / / Add selected style to new one <nl> - if ( this . rows . has ( id ) ) { <nl> - temptr = this . rows . get ( id ) ; <nl> - temptr . addClass ( ' selected ' ) ; <nl> + else { <nl> + if ( e . shift & & myTable . cur . length = = 1 ) { <nl> + / / Shift key was pressed <nl> + var first_row_hash = myTable . cur [ 0 ] ; <nl> + var last_row_hash = this . hash ; <nl> + myTable . cur . empty ( ) ; <nl> + var trs = myTable . table . getElements ( ' tr ' ) ; <nl> + var select = false ; <nl> + for ( var i = 0 ; i < trs . length ; i + + ) { <nl> + var tr = trs [ i ] ; <nl> + <nl> + if ( ( tr . hash = = first_row_hash ) | | ( tr . hash = = last_row_hash ) ) { <nl> + myTable . cur . push ( tr . hash ) ; <nl> + tr . addClass ( ' selected ' ) ; <nl> + select = ! select ; <nl> + } <nl> + else { <nl> + if ( select ) { <nl> + myTable . cur . push ( tr . hash ) ; <nl> + tr . addClass ( ' selected ' ) ; <nl> + } <nl> + else <nl> + tr . removeClass ( ' selected ' ) <nl> + } <nl> + } <nl> + } else { <nl> + / / Simple selection <nl> + myTable . selectRow ( this . hash ) ; <nl> + updatePropertiesPanel ( ) ; <nl> + } <nl> } <nl> - this . cur [ 0 ] = id ; <nl> - updatePropertiesPanel ( ) ; <nl> + return false ; <nl> + } ) ; <nl> + <nl> + for ( var j = 0 ; j < this . columns . length ; j + + ) { <nl> + var td = new Element ( ' td ' ) ; <nl> + if ( ( this . columns [ j ] . visible = = ' 0 ' ) | | this . columns [ j ] . force_hide ) <nl> + td . addClass ( ' invisible ' ) ; <nl> + td . injectInside ( tr ) ; <nl> + } <nl> + <nl> + / / Insert <nl> + if ( rowPos > = trs . length ) { <nl> + tr . inject ( this . table ) ; <nl> + trs . push ( tr ) ; <nl> } <nl> + else { <nl> + tr . inject ( trs [ rowPos ] , ' before ' ) ; <nl> + trs . splice ( rowPos , 0 , tr ) ; <nl> + } <nl> + <nl> + / / Update context menu <nl> + this . context_menu . addTarget ( tr ) ; <nl> + <nl> + this . updateRow ( tr , true ) ; <nl> } <nl> - return false ; <nl> - } . bind ( this ) ) ; <nl> + } <nl> + <nl> + rowPos = rows . length ; <nl> <nl> - / / Insert <nl> - var trs = this . table . getChildren ( ' tr ' ) ; <nl> - if ( pos > = trs . length ) { <nl> - tr . inject ( this . table ) ; <nl> - } else { <nl> - tr . inject ( trs [ pos ] , ' before ' ) ; <nl> + while ( ( rowPos < trs . length ) & & ( trs . length > 0 ) ) { <nl> + trs [ trs . length - 1 ] . dispose ( ) ; <nl> + trs . pop ( ) ; <nl> } <nl> - / / tr . injectInside ( this . table ) ; <nl> - / / Update context menu <nl> - this . context_menu . addTarget ( tr ) ; <nl> } , <nl> <nl> - selectAll : function ( ) { <nl> - this . cur . empty ( ) ; <nl> - this . rows . each ( function ( tr , id ) { <nl> - this . cur [ this . cur . length ] = id ; <nl> - if ( ! tr . hasClass ( ' selected ' ) ) { <nl> - tr . addClass ( ' selected ' ) ; <nl> - } <nl> - } , this ) ; <nl> - } , <nl> + updateRow : function ( tr , fullUpdate ) { <nl> + var row = this . rows . get ( tr . hash ) ; <nl> + data = row [ fullUpdate ? ' full_data ' : ' data ' ] ; <nl> <nl> - updateRow : function ( id , row , data , attrs , newpos ) { <nl> - if ( ! this . rows . has ( id ) ) { <nl> - return false ; <nl> + tds = tr . getElements ( ' td ' ) ; <nl> + <nl> + for ( var prop in data ) <nl> + for ( var i = 0 ; i < this . columns . length ; i + + ) <nl> + for ( var j = 0 ; j < this . columns [ i ] . dataProperties . length ; j + + ) <nl> + if ( this . columns [ i ] . dataProperties [ j ] = = prop ) <nl> + this . columns [ i ] . updateTd ( tds [ i ] , row ) ; <nl> + <nl> + if ( this . cur . contains ( tr . hash ) ) { <nl> + if ( ! tr . hasClass ( ' selected ' ) ) <nl> + tr . addClass ( ' selected ' ) ; <nl> } <nl> - <nl> - var tr = this . rows . get ( id ) ; <nl> - for ( var a in attrs ) <nl> - tr . set ( a , attrs [ a ] ) ; <nl> - var tds = tr . getElements ( ' td ' ) ; <nl> - for ( var i = 0 ; i < row . length ; i + + ) { <nl> - if ( i = = 1 ) <nl> - continue ; / / Do not refresh name <nl> - if ( i = = this . progressIndex ) { <nl> - $ ( ' pb_ ' + id ) . setValue ( row [ i ] ) ; <nl> - } else { <nl> - if ( i = = 0 ) { <nl> - tds [ i ] . getChildren ( ' img ' ) [ 0 ] . set ( ' src ' , row [ i ] ) ; <nl> - } else { <nl> - tds [ i ] . set ( ' html ' , row [ i ] ) ; <nl> - } <nl> - } <nl> - if ( typeof data [ i ] ! = ' undefined ' ) <nl> - tds [ i ] . set ( ' data - raw ' , data [ i ] ) <nl> - } ; <nl> - <nl> - / / Prevent freezing of the backlight . <nl> - tr . removeClass ( ' over ' ) ; <nl> - <nl> - / / Move to ' newpos ' <nl> - var trs = this . table . getChildren ( ' tr ' ) ; <nl> - if ( newpos > = trs . length ) { <nl> - tr . inject ( this . table ) ; <nl> - } else { <nl> - tr . inject ( trs [ newpos ] , ' before ' ) ; <nl> + else { <nl> + if ( tr . hasClass ( ' selected ' ) ) <nl> + tr . removeClass ( ' selected ' ) ; <nl> } <nl> - <nl> - return true ; <nl> } , <nl> <nl> - removeRow : function ( id ) { <nl> - if ( this . cur . contains ( id ) ) { <nl> - this . cur . erase ( id ) ; <nl> - } <nl> - if ( this . rows . has ( id ) ) { <nl> - var tr = this . rows . get ( id ) ; <nl> + removeRow : function ( hash ) { <nl> + this . cur . erase ( hash ) ; <nl> + var tr = this . getTrByHash ( hash ) ; <nl> + if ( tr ! = null ) { <nl> tr . dispose ( ) ; <nl> - this . altRow ( ) ; <nl> - this . rows . erase ( id ) ; <nl> + this . rows . erase ( hash ) ; <nl> return true ; <nl> } <nl> return false ; <nl> var dynamicTable = new Class ( { <nl> return this . cur ; <nl> } , <nl> <nl> - getRowId : function ( tr ) { <nl> - return this . rows . keyOf ( tr ) ; <nl> - } , <nl> - <nl> getRowIds : function ( ) { <nl> return this . rows . getKeys ( ) ; <nl> + } , <nl> + <nl> + initColumnsFunctions : function ( ) { <nl> + <nl> + / / state_icon <nl> + <nl> + this . columns [ ' state_icon ' ] . updateTd = function ( td , row ) { <nl> + var state = this . getRowValue ( row ) ; <nl> + <nl> + if ( state = = " pausedUP " | | state = = " pausedDL " ) <nl> + state = " paused " ; <nl> + else if ( state = = " queuedUP " | | state = = " queuedDL " ) <nl> + state = " queued " ; <nl> + else if ( state = = " checkingUP " | | state = = " checkingDL " ) <nl> + state = " checking " ; <nl> + <nl> + var img_path = ' images / skin / ' + state + ' . png ' ; <nl> + <nl> + if ( td . getChildren ( ' img ' ) . length ) { <nl> + var img = td . getChildren ( ' img ' ) [ 0 ] ; <nl> + if ( img . src . indexOf ( img_path ) < 0 ) <nl> + img . set ( ' src ' , img_path ) ; <nl> + } <nl> + else <nl> + td . adopt ( new Element ( ' img ' , { <nl> + ' src ' : img_path , <nl> + ' class ' : ' statusIcon ' <nl> + } ) ) ; <nl> + } ; <nl> + <nl> + / / name <nl> + <nl> + this . columns [ ' name ' ] . updateTd = function ( td , row ) { <nl> + td . set ( ' html ' , escapeHtml ( this . getRowValue ( row ) ) ) ; <nl> + } ; <nl> + <nl> + / / priority <nl> + <nl> + this . columns [ ' priority ' ] . updateTd = function ( td , row ) { <nl> + var priority = this . getRowValue ( row ) ; <nl> + td . set ( ' html ' , priority < 0 ? null : priority ) ; <nl> + } ; <nl> + this . columns [ ' priority ' ] . compareRows = function ( row1 , row2 ) { <nl> + var row1_val = this . getRowValue ( row1 ) ; <nl> + var row2_val = this . getRowValue ( row2 ) ; <nl> + if ( row1_val = = - 1 ) <nl> + row1_val = 1000000 ; <nl> + if ( row2_val = = - 1 ) <nl> + row2_val = 1000000 ; <nl> + if ( row1_val < row2_val ) <nl> + return - 1 ; <nl> + else if ( row1_val > row2_val ) <nl> + return 1 ; <nl> + else return 0 ; <nl> + } ; <nl> + <nl> + / / size <nl> + <nl> + this . columns [ ' size ' ] . updateTd = function ( td , row ) { <nl> + var size = this . getRowValue ( row ) ; <nl> + td . set ( ' html ' , friendlyUnit ( size , false ) ) ; <nl> + } ; <nl> + <nl> + / / progress <nl> + <nl> + this . columns [ ' progress ' ] . updateTd = function ( td , row ) { <nl> + var progress = this . getRowValue ( row ) ; <nl> + var progressFormated = ( progress * 100 ) . round ( 1 ) ; <nl> + if ( progressFormated = = 100 . 0 & & progress ! = 1 . 0 ) <nl> + progressFormated = 99 . 9 ; <nl> + <nl> + if ( td . getChildren ( ' div ' ) . length ) { <nl> + var div = td . getChildren ( ' div ' ) [ 0 ] ; <nl> + if ( div . getValue ( ) ! = progressFormated ) <nl> + div . setValue ( progressFormated ) ; <nl> + } <nl> + else <nl> + td . adopt ( new ProgressBar ( progressFormated . toFloat ( ) , { <nl> + ' width ' : 80 <nl> + } ) ) ; <nl> + } ; <nl> + <nl> + / / num_seeds <nl> + <nl> + this . columns [ ' num_seeds ' ] . updateTd = function ( td , row ) { <nl> + var num_seeds = this . getRowValue ( row , 0 ) ; <nl> + var num_complete = this . getRowValue ( row , 1 ) ; <nl> + var html = num_seeds ; <nl> + if ( num_complete ! = - 1 ) <nl> + html + = ' ( ' + num_complete + ' ) ' ; <nl> + td . set ( ' html ' , html ) ; <nl> + } ; <nl> + this . columns [ ' num_seeds ' ] . compareRows = function ( row1 , row2 ) { <nl> + var num_seeds1 = this . getRowValue ( row1 , 0 ) ; <nl> + var num_complete1 = this . getRowValue ( row1 , 1 ) ; <nl> + <nl> + var num_seeds2 = this . getRowValue ( row2 , 0 ) ; <nl> + var num_complete2 = this . getRowValue ( row2 , 1 ) ; <nl> + <nl> + if ( num_complete1 < num_complete2 ) <nl> + return - 1 ; <nl> + else if ( num_complete1 > num_complete2 ) <nl> + return 1 ; <nl> + else if ( num_seeds1 < num_seeds2 ) <nl> + return - 1 ; <nl> + else if ( num_seeds1 > num_seeds2 ) <nl> + return 1 ; <nl> + else return 0 ; <nl> + } ; <nl> + <nl> + / / num_leechs <nl> + <nl> + this . columns [ ' num_leechs ' ] . updateTd = this . columns [ ' num_seeds ' ] . updateTd ; <nl> + this . columns [ ' num_leechs ' ] . compareRows = this . columns [ ' num_seeds ' ] . compareRows ; <nl> + <nl> + / / dlspeed <nl> + <nl> + this . columns [ ' dlspeed ' ] . updateTd = function ( td , row ) { <nl> + var speed = this . getRowValue ( row ) ; <nl> + td . set ( ' html ' , friendlyUnit ( speed , true ) ) ; <nl> + } ; <nl> + <nl> + / / upspeed <nl> + <nl> + this . columns [ ' upspeed ' ] . updateTd = this . columns [ ' dlspeed ' ] . updateTd ; <nl> + <nl> + / / eta <nl> + <nl> + this . columns [ ' eta ' ] . updateTd = function ( td , row ) { <nl> + var eta = this . getRowValue ( row ) ; <nl> + td . set ( ' html ' , friendlyDuration ( eta , true ) ) ; <nl> + } ; <nl> + <nl> + / / ratio <nl> + <nl> + this . columns [ ' ratio ' ] . updateTd = function ( td , row ) { <nl> + var ratio = this . getRowValue ( row ) ; <nl> + var html = null ; <nl> + if ( ratio = = - 1 ) <nl> + html = ' ∞ ' ; <nl> + else <nl> + html = ( Math . floor ( 100 * ratio ) / 100 ) . toFixed ( 2 ) ; / / Don ' t round up <nl> + td . set ( ' html ' , html ) ; <nl> + } ; <nl> } <nl> <nl> } ) ; <nl> mmm a / src / webui / www / public / scripts / misc . js <nl> ppp b / src / webui / www / public / scripts / misc . js <nl> function friendlyUnit ( value , isSpeed ) { <nl> while ( value > = 1024 . & & i + + < 6 ) <nl> value / = 1024 . ; <nl> var ret ; <nl> - ret = value . toFixed ( 1 ) + " " + units [ i ] ; <nl> + ret = ( Math . floor ( 10 * value ) / 10 ) . toFixed ( 1 ) / / Don ' t round up <nl> + + " " + units [ i ] ; <nl> if ( isSpeed ) <nl> ret + = " QBT_TR ( / s ) QBT_TR " ; <nl> return ret ; <nl> if ( ! Date . prototype . toISOString ) { <nl> <nl> } ( ) ) ; <nl> } <nl> + <nl> + function escapeHtml ( str ) { <nl> + var div = document . createElement ( ' div ' ) ; <nl> + div . appendChild ( document . createTextNode ( str ) ) ; <nl> + return div . innerHTML ; <nl> + } ; <nl> \ No newline at end of file <nl> mmm a / src / webui / www / public / transferlist . html <nl> ppp b / src / webui / www / public / transferlist . html <nl> <nl> - < table class = " torrentTable " cellpadding = " 0 " cellspacing = " 0 " > <nl> - < thead > <nl> - < tr > <nl> - < th style = " width : 16px " > < / th > <nl> - < th onClick = " setSortedColumn ( ' name ' ) ; " style = " min - width : 200px ; cursor : pointer " > QBT_TR ( Name ) QBT_TR < / th > <nl> - < th id = ' prioHeader ' onClick = " setSortedColumn ( ' priority ' ) ; " style = " width : 90px ; cursor : pointer " > # < / th > <nl> - < th onClick = " setSortedColumn ( ' size ' ) ; " style = " width : 100px ; cursor : pointer " > QBT_TR ( Size ) QBT_TR < / th > <nl> - < th onClick = " setSortedColumn ( ' progress ' ) ; " style = " width : 80px ; cursor : pointer " > QBT_TR ( Done ) QBT_TR < / th > <nl> - < th onClick = " setSortedColumn ( ' num_seeds ' ) ; " style = " width : 100px ; cursor : pointer " > QBT_TR ( Seeds ) QBT_TR < / th > <nl> - < th onClick = " setSortedColumn ( ' num_leechs ' ) ; " style = " width : 100px ; cursor : pointer " > QBT_TR ( Peers ) QBT_TR < / th > <nl> - < th onClick = " setSortedColumn ( ' dlspeed ' ) ; " style = " width : 100px ; cursor : pointer " > QBT_TR ( Down Speed ) QBT_TR < / th > <nl> - < th onClick = " setSortedColumn ( ' upspeed ' ) ; " style = " width : 100px ; cursor : pointer " > QBT_TR ( Up Speed ) QBT_TR < / th > <nl> - < th onClick = " setSortedColumn ( ' eta ' ) ; " style = " width : 100px ; cursor : pointer " > QBT_TR ( ETA ) QBT_TR < / th > <nl> - < th onClick = " setSortedColumn ( ' ratio ' ) ; " style = " width : 100px ; cursor : pointer " > QBT_TR ( Ratio ) QBT_TR < / th > <nl> - < / tr > <nl> - < / thead > <nl> - < tbody id = " myTable " > < / tbody > <nl> - < / table > <nl> + < table class = " torrentTable " cellpadding = " 0 " cellspacing = " 0 " style = " - webkit - touch - callout : none ; - webkit - user - select : none ; - khtml - user - select : none ; - moz - user - select : none ; - ms - user - select : none ; user - select : none ; " > <nl> + < thead > <nl> + < tr id = " torrentTableHeader " > <nl> + < / tr > <nl> + < / thead > <nl> + < tbody id = " myTable " > < / tbody > <nl> + < / table > <nl> <nl> < script type = " text / javascript " > <nl> <nl> <nl> } <nl> } ) ; <nl> <nl> - myTable . setup ( ' myTable ' , 4 , context_menu ) ; <nl> + myTable . setup ( ' myTable ' , context_menu ) ; <nl> < / script > <nl> | Merge pull request from buinsky / WebUI2 | qbittorrent/qBittorrent | 74fcee2d7d1557c3ab0d6034174efae04464a3a0 | 2015-01-10T14:37:26Z |
mmm a / modules / mono / SCsub <nl> ppp b / modules / mono / SCsub <nl> def find_msbuild_unix ( filename ) : <nl> def find_msbuild_windows ( ) : <nl> import mono_reg_utils as monoreg <nl> <nl> - msbuild_tools_path = monoreg . find_msbuild_tools_path_reg ( ) <nl> + bits = env [ ' bits ' ] <nl> <nl> - if msbuild_tools_path : <nl> - return ( os . path . join ( msbuild_tools_path , ' MSBuild . exe ' ) , ' ' ) <nl> + if bits = = ' 32 ' : <nl> + if os . getenv ( ' MONO32_PREFIX ' ) : <nl> + mono_root = os . getenv ( ' MONO32_PREFIX ' ) <nl> + else : <nl> + mono_root = monoreg . find_mono_root_dir ( bits ) <nl> else : <nl> - bits = env [ ' bits ' ] <nl> - <nl> - if bits = = ' 32 ' : <nl> - if os . getenv ( ' MONO32_PREFIX ' ) : <nl> - mono_root = os . getenv ( ' MONO32_PREFIX ' ) <nl> - else : <nl> - mono_root = monoreg . find_mono_root_dir ( bits ) <nl> + if os . getenv ( ' MONO64_PREFIX ' ) : <nl> + mono_root = os . getenv ( ' MONO64_PREFIX ' ) <nl> else : <nl> - if os . getenv ( ' MONO64_PREFIX ' ) : <nl> - mono_root = os . getenv ( ' MONO64_PREFIX ' ) <nl> - else : <nl> - mono_root = monoreg . find_mono_root_dir ( bits ) <nl> + mono_root = monoreg . find_mono_root_dir ( bits ) <nl> <nl> - if mono_root : <nl> - msbuild_mono = os . path . join ( mono_root , ' bin ' , ' msbuild . bat ' ) <nl> + if not mono_root : <nl> + raise RuntimeError ( ' Cannot find mono root directory ' ) <nl> + <nl> + msbuild_tools_path = monoreg . find_msbuild_tools_path_reg ( ) <nl> + <nl> + if msbuild_tools_path : <nl> + return ( os . path . join ( msbuild_tools_path , ' MSBuild . exe ' ) , os . path . join ( mono_root , ' lib ' , ' mono ' , ' 4 . 5 ' ) ) <nl> + else : <nl> + msbuild_mono = os . path . join ( mono_root , ' bin ' , ' msbuild . bat ' ) <nl> <nl> - if os . path . isfile ( msbuild_mono ) : <nl> - return ( msbuild_mono , os . path . join ( mono_root , ' lib ' , ' mono ' , ' 4 . 5 ' ) ) <nl> + if os . path . isfile ( msbuild_mono ) : <nl> + return ( msbuild_mono , ' ' ) <nl> <nl> return None <nl> <nl> mmm a / modules / mono / editor / godotsharp_builds . cpp <nl> ppp b / modules / mono / editor / godotsharp_builds . cpp <nl> <nl> # include " main / main . h " <nl> <nl> # include " . . / godotsharp_dirs . h " <nl> + # include " . . / mono_gd / gd_mono . h " <nl> # include " . . / mono_gd / gd_mono_class . h " <nl> # include " . . / mono_gd / gd_mono_marshal . h " <nl> # include " . . / utils / path_utils . h " <nl> void godot_icall_BuildInstance_get_MSBuildInfo ( MonoString * * r_msbuild_path , Mono <nl> if ( ! msbuild_tools_path . ends_with ( " \ \ " ) ) <nl> msbuild_tools_path + = " \ \ " ; <nl> <nl> - * r_msbuild_path = GDMonoMarshal : : mono_string_from_godot ( msbuild_tools_path + " MSBuild . exe " ) ; <nl> - <nl> / / FrameworkPathOverride <nl> - * r_framework_path = GDMonoMarshal : : mono_string_from_godot ( GDMono : : get_singleton ( ) - > get_mono_reg_info ( ) . assembly_dir ) ; <nl> + const MonoRegInfo & mono_reg_info = GDMono : : get_singleton ( ) - > get_mono_reg_info ( ) ; <nl> + if ( mono_reg_info . assembly_dir . length ( ) ) { <nl> + * r_msbuild_path = GDMonoMarshal : : mono_string_from_godot ( msbuild_tools_path + " MSBuild . exe " ) ; <nl> + <nl> + String framework_path = path_join ( mono_reg_info . assembly_dir , " mono " , " 4 . 5 " ) ; <nl> + * r_framework_path = GDMonoMarshal : : mono_string_from_godot ( framework_path ) ; <nl> + } else { <nl> + ERR_PRINT ( " Cannot find Mono ' s assemblies directory in the registry " ) ; <nl> + } <nl> <nl> return ; <nl> } <nl> void godot_icall_BuildInstance_get_MSBuildInfo ( MonoString * * r_msbuild_path , Mono <nl> <nl> return ; <nl> # else <nl> + ERR_PRINT ( " Not implemented on this platform " ) ; <nl> return ; <nl> # endif <nl> } <nl> mmm a / modules / mono / mono_gd / gd_mono_assembly . cpp <nl> ppp b / modules / mono / mono_gd / gd_mono_assembly . cpp <nl> MonoAssembly * GDMonoAssembly : : _preload_hook ( MonoAssemblyName * aname , char * * asse <nl> search_dirs . push_back ( String ( rootdir ) . plus_file ( " mono " ) . plus_file ( " 4 . 5 " ) ) ; <nl> } <nl> <nl> - while ( assemblies_path ) { <nl> - if ( * assemblies_path ) <nl> + if ( assemblies_path ) { <nl> + while ( * assemblies_path ) { <nl> search_dirs . push_back ( * assemblies_path ) ; <nl> - + + assemblies_path ; <nl> + + + assemblies_path ; <nl> + } <nl> } <nl> } <nl> <nl> | Fix FrameworkPathOverride and assemblies path loop | godotengine/godot | aa5a0b550f65710f7a9511661442c7fe0b8b41c2 | 2017-10-29T21:22:38Z |
mmm a / src / heap . h <nl> ppp b / src / heap . h <nl> namespace internal { <nl> V ( next_string , " next " ) \ <nl> V ( byte_length_string , " byteLength " ) \ <nl> V ( byte_offset_string , " byteOffset " ) \ <nl> - V ( buffer_string , " buffer " ) <nl> + V ( buffer_string , " buffer " ) \ <nl> + V ( intl_initialized_marker_string , " v8 : : intl_initialized_marker " ) \ <nl> + V ( intl_impl_object_string , " v8 : : intl_object " ) <nl> <nl> / / Forward declarations . <nl> class GCTracer ; <nl> mmm a / src / i18n . js <nl> ppp b / src / i18n . js <nl> var ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR = <nl> * / <nl> function addBoundMethod ( obj , methodName , implementation , length ) { <nl> function getter ( ) { <nl> - if ( ! this | | typeof this ! = = ' object ' | | <nl> - this . __initializedIntlObject = = = undefined ) { <nl> + if ( ! % IsInitializedIntlObject ( this ) ) { <nl> throw new $ TypeError ( ' Method ' + methodName + ' called on a ' + <nl> ' non - object or on a wrong type of object . ' ) ; <nl> } <nl> function BuildLanguageTagREs ( ) { <nl> * Useful for subclassing . <nl> * / <nl> function initializeCollator ( collator , locales , options ) { <nl> - if ( collator . hasOwnProperty ( ' __initializedIntlObject ' ) ) { <nl> + if ( % IsInitializedIntlObject ( collator ) ) { <nl> throw new $ TypeError ( ' Trying to re - initialize Collator object . ' ) ; <nl> } <nl> <nl> function initializeCollator ( collator , locales , options ) { <nl> resolved ) ; <nl> <nl> / / Writable , configurable and enumerable are set to false by default . <nl> - $ Object . defineProperty ( collator , ' collator ' , { value : internalCollator } ) ; <nl> - $ Object . defineProperty ( collator , ' __initializedIntlObject ' , <nl> - { value : ' collator ' } ) ; <nl> + % MarkAsInitializedIntlObjectOfType ( collator , ' collator ' , internalCollator ) ; <nl> $ Object . defineProperty ( collator , ' resolved ' , { value : resolved } ) ; <nl> <nl> return collator ; <nl> function initializeCollator ( collator , locales , options ) { <nl> throw new $ TypeError ( ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR ) ; <nl> } <nl> <nl> - if ( ! this | | typeof this ! = = ' object ' | | <nl> - this . __initializedIntlObject ! = = ' collator ' ) { <nl> + if ( ! % IsInitializedIntlObjectOfType ( this , ' collator ' ) ) { <nl> throw new $ TypeError ( ' resolvedOptions method called on a non - object ' + <nl> ' or on a object that is not Intl . Collator . ' ) ; <nl> } <nl> function initializeCollator ( collator , locales , options ) { <nl> * the sort order , or x comes after y in the sort order , respectively . <nl> * / <nl> function compare ( collator , x , y ) { <nl> - return % InternalCompare ( collator . collator , $ String ( x ) , $ String ( y ) ) ; <nl> + return % InternalCompare ( % GetImplFromInitializedIntlObject ( collator ) , <nl> + $ String ( x ) , $ String ( y ) ) ; <nl> } ; <nl> <nl> <nl> function getNumberOption ( options , property , min , max , fallback ) { <nl> * Useful for subclassing . <nl> * / <nl> function initializeNumberFormat ( numberFormat , locales , options ) { <nl> - if ( numberFormat . hasOwnProperty ( ' __initializedIntlObject ' ) ) { <nl> + if ( % IsInitializedIntlObject ( numberFormat ) ) { <nl> throw new $ TypeError ( ' Trying to re - initialize NumberFormat object . ' ) ; <nl> } <nl> <nl> function initializeNumberFormat ( numberFormat , locales , options ) { <nl> writable : true } ) ; <nl> } <nl> <nl> - $ Object . defineProperty ( numberFormat , ' formatter ' , { value : formatter } ) ; <nl> + % MarkAsInitializedIntlObjectOfType ( numberFormat , ' numberformat ' , formatter ) ; <nl> $ Object . defineProperty ( numberFormat , ' resolved ' , { value : resolved } ) ; <nl> - $ Object . defineProperty ( numberFormat , ' __initializedIntlObject ' , <nl> - { value : ' numberformat ' } ) ; <nl> <nl> return numberFormat ; <nl> } <nl> function initializeNumberFormat ( numberFormat , locales , options ) { <nl> throw new $ TypeError ( ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR ) ; <nl> } <nl> <nl> - if ( ! this | | typeof this ! = = ' object ' | | <nl> - this . __initializedIntlObject ! = = ' numberformat ' ) { <nl> + if ( ! % IsInitializedIntlObjectOfType ( this , ' numberformat ' ) ) { <nl> throw new $ TypeError ( ' resolvedOptions method called on a non - object ' + <nl> ' or on a object that is not Intl . NumberFormat . ' ) ; <nl> } <nl> function formatNumber ( formatter , value ) { <nl> / / Spec treats - 0 and + 0 as 0 . <nl> var number = $ Number ( value ) + 0 ; <nl> <nl> - return % InternalNumberFormat ( formatter . formatter , number ) ; <nl> + return % InternalNumberFormat ( % GetImplFromInitializedIntlObject ( formatter ) , <nl> + number ) ; <nl> } <nl> <nl> <nl> function formatNumber ( formatter , value ) { <nl> * Returns a Number that represents string value that was passed in . <nl> * / <nl> function parseNumber ( formatter , value ) { <nl> - return % InternalNumberParse ( formatter . formatter , $ String ( value ) ) ; <nl> + return % InternalNumberParse ( % GetImplFromInitializedIntlObject ( formatter ) , <nl> + $ String ( value ) ) ; <nl> } <nl> <nl> <nl> function toDateTimeOptions ( options , required , defaults ) { <nl> * / <nl> function initializeDateTimeFormat ( dateFormat , locales , options ) { <nl> <nl> - if ( dateFormat . hasOwnProperty ( ' __initializedIntlObject ' ) ) { <nl> + if ( % IsInitializedIntlObject ( dateFormat ) ) { <nl> throw new $ TypeError ( ' Trying to re - initialize DateTimeFormat object . ' ) ; <nl> } <nl> <nl> function initializeDateTimeFormat ( dateFormat , locales , options ) { <nl> throw new $ RangeError ( ' Unsupported time zone specified ' + tz ) ; <nl> } <nl> <nl> - $ Object . defineProperty ( dateFormat , ' formatter ' , { value : formatter } ) ; <nl> + % MarkAsInitializedIntlObjectOfType ( dateFormat , ' dateformat ' , formatter ) ; <nl> $ Object . defineProperty ( dateFormat , ' resolved ' , { value : resolved } ) ; <nl> - $ Object . defineProperty ( dateFormat , ' __initializedIntlObject ' , <nl> - { value : ' dateformat ' } ) ; <nl> <nl> return dateFormat ; <nl> } <nl> function initializeDateTimeFormat ( dateFormat , locales , options ) { <nl> throw new $ TypeError ( ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR ) ; <nl> } <nl> <nl> - if ( ! this | | typeof this ! = = ' object ' | | <nl> - this . __initializedIntlObject ! = = ' dateformat ' ) { <nl> + if ( ! % IsInitializedIntlObjectOfType ( this , ' dateformat ' ) ) { <nl> throw new $ TypeError ( ' resolvedOptions method called on a non - object or ' + <nl> ' on a object that is not Intl . DateTimeFormat . ' ) ; <nl> } <nl> function formatDate ( formatter , dateValue ) { <nl> throw new $ RangeError ( ' Provided date is not in valid range . ' ) ; <nl> } <nl> <nl> - return % InternalDateFormat ( formatter . formatter , new $ Date ( dateMs ) ) ; <nl> + return % InternalDateFormat ( % GetImplFromInitializedIntlObject ( formatter ) , <nl> + new $ Date ( dateMs ) ) ; <nl> } <nl> <nl> <nl> function formatDate ( formatter , dateValue ) { <nl> * Returns undefined if date string cannot be parsed . <nl> * / <nl> function parseDate ( formatter , value ) { <nl> - return % InternalDateParse ( formatter . formatter , $ String ( value ) ) ; <nl> + return % InternalDateParse ( % GetImplFromInitializedIntlObject ( formatter ) , <nl> + $ String ( value ) ) ; <nl> } <nl> <nl> <nl> function canonicalizeTimeZoneID ( tzID ) { <nl> * Useful for subclassing . <nl> * / <nl> function initializeBreakIterator ( iterator , locales , options ) { <nl> - if ( iterator . hasOwnProperty ( ' __initializedIntlObject ' ) ) { <nl> + if ( % IsInitializedIntlObject ( iterator ) ) { <nl> throw new $ TypeError ( ' Trying to re - initialize v8BreakIterator object . ' ) ; <nl> } <nl> <nl> function initializeBreakIterator ( iterator , locales , options ) { <nl> internalOptions , <nl> resolved ) ; <nl> <nl> - $ Object . defineProperty ( iterator , ' iterator ' , { value : internalIterator } ) ; <nl> + % MarkAsInitializedIntlObjectOfType ( iterator , ' breakiterator ' , <nl> + internalIterator ) ; <nl> $ Object . defineProperty ( iterator , ' resolved ' , { value : resolved } ) ; <nl> - $ Object . defineProperty ( iterator , ' __initializedIntlObject ' , <nl> - { value : ' breakiterator ' } ) ; <nl> <nl> return iterator ; <nl> } <nl> function initializeBreakIterator ( iterator , locales , options ) { <nl> throw new $ TypeError ( ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR ) ; <nl> } <nl> <nl> - if ( ! this | | typeof this ! = = ' object ' | | <nl> - this . __initializedIntlObject ! = = ' breakiterator ' ) { <nl> + if ( ! % IsInitializedIntlObjectOfType ( this , ' breakiterator ' ) ) { <nl> throw new $ TypeError ( ' resolvedOptions method called on a non - object or ' + <nl> ' on a object that is not Intl . v8BreakIterator . ' ) ; <nl> } <nl> function initializeBreakIterator ( iterator , locales , options ) { <nl> * gets discarded . <nl> * / <nl> function adoptText ( iterator , text ) { <nl> - % BreakIteratorAdoptText ( iterator . iterator , $ String ( text ) ) ; <nl> + % BreakIteratorAdoptText ( % GetImplFromInitializedIntlObject ( iterator ) , <nl> + $ String ( text ) ) ; <nl> } <nl> <nl> <nl> function adoptText ( iterator , text ) { <nl> * Returns index of the first break in the string and moves current pointer . <nl> * / <nl> function first ( iterator ) { <nl> - return % BreakIteratorFirst ( iterator . iterator ) ; <nl> + return % BreakIteratorFirst ( % GetImplFromInitializedIntlObject ( iterator ) ) ; <nl> } <nl> <nl> <nl> function first ( iterator ) { <nl> * Returns the index of the next break and moves the pointer . <nl> * / <nl> function next ( iterator ) { <nl> - return % BreakIteratorNext ( iterator . iterator ) ; <nl> + return % BreakIteratorNext ( % GetImplFromInitializedIntlObject ( iterator ) ) ; <nl> } <nl> <nl> <nl> function next ( iterator ) { <nl> * Returns index of the current break . <nl> * / <nl> function current ( iterator ) { <nl> - return % BreakIteratorCurrent ( iterator . iterator ) ; <nl> + return % BreakIteratorCurrent ( % GetImplFromInitializedIntlObject ( iterator ) ) ; <nl> } <nl> <nl> <nl> function current ( iterator ) { <nl> * Returns type of the current break . <nl> * / <nl> function breakType ( iterator ) { <nl> - return % BreakIteratorBreakType ( iterator . iterator ) ; <nl> + return % BreakIteratorBreakType ( % GetImplFromInitializedIntlObject ( iterator ) ) ; <nl> } <nl> <nl> <nl> mmm a / src / runtime . cc <nl> ppp b / src / runtime . cc <nl> RUNTIME_FUNCTION ( MaybeObject * , Runtime_GetLanguageTagVariants ) { <nl> } <nl> <nl> <nl> + RUNTIME_FUNCTION ( MaybeObject * , Runtime_IsInitializedIntlObject ) { <nl> + HandleScope scope ( isolate ) ; <nl> + <nl> + ASSERT ( args . length ( ) = = 1 ) ; <nl> + <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSObject , input , 0 ) ; <nl> + <nl> + Handle < String > marker = isolate - > factory ( ) - > intl_initialized_marker_string ( ) ; <nl> + Handle < Object > tag ( input - > GetHiddenProperty ( * marker ) , isolate ) ; <nl> + return isolate - > heap ( ) - > ToBoolean ( ! tag - > IsTheHole ( ) ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( MaybeObject * , Runtime_IsInitializedIntlObjectOfType ) { <nl> + HandleScope scope ( isolate ) ; <nl> + <nl> + ASSERT ( args . length ( ) = = 2 ) ; <nl> + <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSObject , input , 0 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( String , expected_type , 1 ) ; <nl> + <nl> + <nl> + Handle < String > marker = isolate - > factory ( ) - > intl_initialized_marker_string ( ) ; <nl> + Handle < Object > tag ( input - > GetHiddenProperty ( * marker ) , isolate ) ; <nl> + return isolate - > heap ( ) - > ToBoolean ( <nl> + tag - > IsString ( ) & & String : : cast ( * tag ) - > Equals ( * expected_type ) ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( MaybeObject * , Runtime_MarkAsInitializedIntlObjectOfType ) { <nl> + HandleScope scope ( isolate ) ; <nl> + <nl> + ASSERT ( args . length ( ) = = 3 ) ; <nl> + <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSObject , input , 0 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( String , type , 1 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSObject , impl , 2 ) ; <nl> + <nl> + Handle < String > marker = isolate - > factory ( ) - > intl_initialized_marker_string ( ) ; <nl> + JSObject : : SetHiddenProperty ( input , marker , type ) ; <nl> + <nl> + marker = isolate - > factory ( ) - > intl_impl_object_string ( ) ; <nl> + JSObject : : SetHiddenProperty ( input , marker , impl ) ; <nl> + <nl> + return isolate - > heap ( ) - > undefined_value ( ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( MaybeObject * , Runtime_GetImplFromInitializedIntlObject ) { <nl> + HandleScope scope ( isolate ) ; <nl> + <nl> + ASSERT ( args . length ( ) = = 1 ) ; <nl> + <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSObject , input , 0 ) ; <nl> + <nl> + Handle < String > marker = isolate - > factory ( ) - > intl_impl_object_string ( ) ; <nl> + Handle < Object > impl ( input - > GetHiddenProperty ( * marker ) , isolate ) ; <nl> + if ( impl - > IsTheHole ( ) ) return isolate - > heap ( ) - > undefined_value ( ) ; <nl> + return * impl ; <nl> + } <nl> + <nl> + <nl> RUNTIME_FUNCTION ( MaybeObject * , Runtime_CreateDateTimeFormat ) { <nl> HandleScope scope ( isolate ) ; <nl> <nl> mmm a / src / runtime . h <nl> ppp b / src / runtime . h <nl> namespace internal { <nl> F ( AvailableLocalesOf , 1 , 1 ) \ <nl> F ( GetDefaultICULocale , 0 , 1 ) \ <nl> F ( GetLanguageTagVariants , 1 , 1 ) \ <nl> + F ( IsInitializedIntlObject , 1 , 1 ) \ <nl> + F ( IsInitializedIntlObjectOfType , 2 , 1 ) \ <nl> + F ( MarkAsInitializedIntlObjectOfType , 3 , 1 ) \ <nl> + F ( GetImplFromInitializedIntlObject , 1 , 1 ) \ <nl> \ <nl> / * Date format and parse . * / \ <nl> F ( CreateDateTimeFormat , 3 , 1 ) \ <nl> deleted file mode 100644 <nl> index ad1dc54fbed . . 00000000000 <nl> mmm a / test / intl / break - iterator / protected - icu - internals . js <nl> ppp / dev / null <nl> <nl> - / / Copyright 2013 the V8 project authors . All rights reserved . <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 <nl> - / / disclaimer in the documentation and / or other materials provided <nl> - / / with the distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived <nl> - / / from this software without specific prior written permission . <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> - / / Internal object we got from native code should not be writable , <nl> - / / configurable or enumerable . One can still change its public properties , but <nl> - / / we don ' t use them to do actual work . <nl> - <nl> - var iterator = new Intl . v8BreakIterator ( [ ] ) ; <nl> - <nl> - / / Direct write should fail . <nl> - iterator . iterator = { ' zzz ' : ' some random object ' } ; <nl> - <nl> - assertFalse ( iterator . iterator . hasOwnProperty ( ' zzz ' ) ) ; <nl> - <nl> - / / Try redefining the property . <nl> - var didThrow = false ; <nl> - try { <nl> - Object . defineProperty ( iterator , ' iterator ' , { value : undefined } ) ; <nl> - } catch ( e ) { <nl> - didThrow = true ; <nl> - } <nl> - assertTrue ( didThrow ) ; <nl> - <nl> - / / Try deleting the property . <nl> - assertFalse ( delete iterator . iterator ) ; <nl> deleted file mode 100644 <nl> index 7acd35e4546 . . 00000000000 <nl> mmm a / test / intl / collator / protected - icu - internals . js <nl> ppp / dev / null <nl> <nl> - / / Copyright 2013 the V8 project authors . All rights reserved . <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 <nl> - / / disclaimer in the documentation and / or other materials provided <nl> - / / with the distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived <nl> - / / from this software without specific prior written permission . <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> - / / Internal object we got from native code should not be writable , <nl> - / / configurable or enumerable . One can still change its public properties , but <nl> - / / we don ' t use them to do actual work . <nl> - <nl> - var collator = new Intl . Collator ( [ ] ) ; <nl> - <nl> - / / Direct write should fail . <nl> - collator . collator = { ' zzz ' : ' some random object ' } ; <nl> - <nl> - assertFalse ( collator . collator . hasOwnProperty ( ' zzz ' ) ) ; <nl> - <nl> - / / Try redefining the property . <nl> - var didThrow = false ; <nl> - try { <nl> - Object . defineProperty ( collator , ' collator ' , { value : undefined } ) ; <nl> - } catch ( e ) { <nl> - didThrow = true ; <nl> - } <nl> - assertTrue ( didThrow ) ; <nl> - <nl> - / / Try deleting the property . <nl> - assertFalse ( delete collator . collator ) ; <nl> deleted file mode 100644 <nl> index 140f4b594d8 . . 00000000000 <nl> mmm a / test / intl / date - format / protected - icu - internals . js <nl> ppp / dev / null <nl> <nl> - / / Copyright 2013 the V8 project authors . All rights reserved . <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 <nl> - / / disclaimer in the documentation and / or other materials provided <nl> - / / with the distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived <nl> - / / from this software without specific prior written permission . <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> - / / Internal object we got from native code should not be writable , <nl> - / / configurable or enumerable . One can still change its public properties , but <nl> - / / we don ' t use them to do actual work . <nl> - <nl> - var format = new Intl . DateTimeFormat ( [ ] ) ; <nl> - <nl> - / / Direct write should fail . <nl> - format . formatter = { ' zzz ' : ' some random object ' } ; <nl> - <nl> - assertFalse ( format . formatter . hasOwnProperty ( ' zzz ' ) ) ; <nl> - <nl> - / / Try redefining the property . <nl> - var didThrow = false ; <nl> - try { <nl> - Object . defineProperty ( format , ' formatter ' , { value : undefined } ) ; <nl> - } catch ( e ) { <nl> - didThrow = true ; <nl> - } <nl> - assertTrue ( didThrow ) ; <nl> - <nl> - / / Try deleting the property . <nl> - assertFalse ( delete format . formatter ) ; <nl> deleted file mode 100644 <nl> index fc9b709c824 . . 00000000000 <nl> mmm a / test / intl / number - format / protected - icu - internals . js <nl> ppp / dev / null <nl> <nl> - / / Copyright 2013 the V8 project authors . All rights reserved . <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 <nl> - / / disclaimer in the documentation and / or other materials provided <nl> - / / with the distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived <nl> - / / from this software without specific prior written permission . <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> - / / Internal object we got from native code should not be writable , <nl> - / / configurable or enumerable . One can still change its public properties , but <nl> - / / we don ' t use them to do actual work . <nl> - <nl> - var format = new Intl . NumberFormat ( [ ] ) ; <nl> - <nl> - / / Direct write should fail . <nl> - format . formatter = { ' zzz ' : ' some random object ' } ; <nl> - <nl> - assertFalse ( format . formatter . hasOwnProperty ( ' zzz ' ) ) ; <nl> - <nl> - / / Try redefining the property . <nl> - var didThrow = false ; <nl> - try { <nl> - Object . defineProperty ( format , ' formatter ' , { value : undefined } ) ; <nl> - } catch ( e ) { <nl> - didThrow = true ; <nl> - } <nl> - assertTrue ( didThrow ) ; <nl> - <nl> - / / Try deleting the property . <nl> - assertFalse ( delete format . formatter ) ; <nl> | Store i18n meta data in hidden symbols instead of js accessible properties | v8/v8 | 0d04cba759f3cc61c652a0f33f5bac37d769fe55 | 2014-04-01T07:21:05Z |
mmm a / src / mips / macro - assembler - mips . cc <nl> ppp b / src / mips / macro - assembler - mips . cc <nl> void MacroAssembler : : EnsureNotWhite ( <nl> void MacroAssembler : : LoadInstanceDescriptors ( Register map , <nl> Register descriptors , <nl> Register scratch ) { <nl> - lw ( descriptors , <nl> - FieldMemOperand ( map , Map : : kInstanceDescriptorsOrBackPointerOffset ) ) ; <nl> + Register temp = descriptors ; <nl> + lw ( temp , FieldMemOperand ( map , Map : : kTransitionsOrBackPointerOffset ) ) ; <nl> <nl> Label ok , fail ; <nl> - CheckMap ( descriptors , <nl> + CheckMap ( temp , <nl> scratch , <nl> isolate ( ) - > factory ( ) - > fixed_array_map ( ) , <nl> & fail , <nl> DONT_DO_SMI_CHECK ) ; <nl> + lw ( descriptors , FieldMemOperand ( temp , TransitionArray : : kDescriptorsOffset ) ) ; <nl> jmp ( & ok ) ; <nl> bind ( & fail ) ; <nl> LoadRoot ( descriptors , Heap : : kEmptyDescriptorArrayRootIndex ) ; <nl> void MacroAssembler : : CheckEnumCache ( Register null_value , Label * call_runtime ) { <nl> / / Preload a couple of values used in the loop . <nl> Register empty_fixed_array_value = t2 ; <nl> LoadRoot ( empty_fixed_array_value , Heap : : kEmptyFixedArrayRootIndex ) ; <nl> - Register empty_descriptor_array_value = t3 ; <nl> - LoadRoot ( empty_descriptor_array_value , <nl> - Heap : : kEmptyDescriptorArrayRootIndex ) ; <nl> mov ( a1 , a0 ) ; <nl> bind ( & next ) ; <nl> <nl> void MacroAssembler : : CheckEnumCache ( Register null_value , Label * call_runtime ) { <nl> / / check for an enum cache . Leave the map in a2 for the subsequent <nl> / / prototype load . <nl> lw ( a2 , FieldMemOperand ( a1 , HeapObject : : kMapOffset ) ) ; <nl> - lw ( a3 , FieldMemOperand ( a2 , Map : : kInstanceDescriptorsOrBackPointerOffset ) ) ; <nl> + lw ( a3 , FieldMemOperand ( a2 , Map : : kTransitionsOrBackPointerOffset ) ) ; <nl> <nl> CheckMap ( a3 , <nl> t3 , <nl> void MacroAssembler : : CheckEnumCache ( Register null_value , Label * call_runtime ) { <nl> call_runtime , <nl> DONT_DO_SMI_CHECK ) ; <nl> <nl> + LoadRoot ( t3 , Heap : : kEmptyDescriptorArrayRootIndex ) ; <nl> + lw ( a3 , FieldMemOperand ( a3 , TransitionArray : : kDescriptorsOffset ) ) ; <nl> + Branch ( call_runtime , eq , a3 , Operand ( t3 ) ) ; <nl> + <nl> / / Check that there is an enum cache in the non - empty instance <nl> / / descriptors ( a3 ) . This is the case if the next enumeration <nl> / / index field does not contain a smi . <nl> | MIPS : Swapped transition array and descriptor array . | v8/v8 | aaf403e92c7b2dc2581f5ec8c8a11f8cee6f61e2 | 2012-08-16T11:42:02Z |
mmm a / dbms / src / Storages / Kafka / StorageKafka . cpp <nl> ppp b / dbms / src / Storages / Kafka / StorageKafka . cpp <nl> class KafkaBlockInputStream : public IProfilingBlockInputStream <nl> if ( isCancelledOrThrowIfKilled ( ) | | ! hasClaimed ( ) ) <nl> return { } ; <nl> <nl> + if ( ! reader ) <nl> + throw Exception ( " Logical error : reader is not initialized " , ErrorCodes : : LOGICAL_ERROR ) ; <nl> + <nl> return reader - > read ( ) ; <nl> } <nl> <nl> class KafkaBlockInputStream : public IProfilingBlockInputStream <nl> size_t max_block_size ; <nl> Block sample_block ; <nl> std : : unique_ptr < ReadBufferFromKafkaConsumer > read_buf ; <nl> - BlockInputStreamPtr reader = nullptr ; <nl> + BlockInputStreamPtr reader ; <nl> bool finalized = false ; <nl> <nl> / / Return true if consumer has been claimed by the stream <nl> | Added assertion [ # CLICKHOUSE - 2 ] | ClickHouse/ClickHouse | 661a117b91f2a296d97d4fde93f451e45306323c | 2018-12-21T16:03:40Z |
new file mode 100644 <nl> index 00000000000 . . b17f4a5c2b1 <nl> mmm / dev / null <nl> ppp b / hphp / hack / hhi / ext_hhjs . hhi <nl> <nl> + < ? hh <nl> + <nl> + namespace JSCompat \ Api { <nl> + async function invoke ( <nl> + ( function ( ) : mixed ) $ thunk , <nl> + mixed . . . $ args <nl> + ) : Awaitable < mixed > ; <nl> + } <nl> | Add invoke API | facebook/hhvm | 8893f45e5a1d595dd5128e6ef50f71ed2ab56d7d | 2019-04-10T04:04:46Z |
mmm a / libraries / ESP8266WiFi / src / CertStoreBearSSL . cpp <nl> ppp b / libraries / ESP8266WiFi / src / CertStoreBearSSL . cpp <nl> CertStore : : CertInfo CertStore : : _preprocessCert ( uint32_t length , uint32_t offset , <nl> <nl> / / The certs . ar file is a UNIX ar format file , concatenating all the <nl> / / individual certificates into a single blob in a space - efficient way . <nl> - int CertStore : : initCertStore ( FS & fs , const char * indexFileName , const char * dataFileName ) { <nl> + int CertStore : : initCertStore ( fs : : FS & fs , const char * indexFileName , const char * dataFileName ) { <nl> int count = 0 ; <nl> uint32_t offset = 0 ; <nl> <nl> int CertStore : : initCertStore ( FS & fs , const char * indexFileName , const char * data <nl> memcpy_P ( _indexName , indexFileName , strlen_P ( indexFileName ) + 1 ) ; <nl> memcpy_P ( _dataName , dataFileName , strlen_P ( dataFileName ) + 1 ) ; <nl> <nl> - File index = _fs - > open ( _indexName , " w " ) ; <nl> + fs : : File index = _fs - > open ( _indexName , " w " ) ; <nl> if ( ! index ) { <nl> return 0 ; <nl> } <nl> <nl> - File data = _fs - > open ( _dataName , " r " ) ; <nl> + fs : : File data = _fs - > open ( _dataName , " r " ) ; <nl> if ( ! data ) { <nl> index . close ( ) ; <nl> return 0 ; <nl> const br_x509_trust_anchor * CertStore : : findHashedTA ( void * ctx , void * hashed_dn , <nl> return nullptr ; <nl> } <nl> <nl> - File index = cs - > _fs - > open ( cs - > _indexName , " r " ) ; <nl> + fs : : File index = cs - > _fs - > open ( cs - > _indexName , " r " ) ; <nl> if ( ! index ) { <nl> return nullptr ; <nl> } <nl> const br_x509_trust_anchor * CertStore : : findHashedTA ( void * ctx , void * hashed_dn , <nl> if ( ! der ) { <nl> return nullptr ; <nl> } <nl> - File data = cs - > _fs - > open ( cs - > _dataName , " r " ) ; <nl> + fs : : File data = cs - > _fs - > open ( cs - > _dataName , " r " ) ; <nl> if ( ! data ) { <nl> free ( der ) ; <nl> return nullptr ; <nl> } <nl> - if ( ! data . seek ( ci . offset , SeekSet ) ) { <nl> + if ( ! data . seek ( ci . offset , fs : : SeekSet ) ) { <nl> data . close ( ) ; <nl> free ( der ) ; <nl> return nullptr ; <nl> | Compile failure fix with FS_NO_GLOBALS flag ( ) | esp8266/Arduino | 996211f132105a81bfb670a0365f12162a643498 | 2020-10-30T00:11:57Z |
mmm a / project / VS2010Express / XBMC . vcxproj <nl> ppp b / project / VS2010Express / XBMC . vcxproj <nl> <nl> < ClCompile Include = " . . \ . . \ xbmc \ utils \ UrlOptions . cpp " / > <nl> < ClCompile Include = " . . \ . . \ xbmc \ utils \ Variant . cpp " / > <nl> < ClCompile Include = " . . \ . . \ xbmc \ utils \ Weather . cpp " / > <nl> + < ClCompile Include = " . . \ . . \ xbmc \ utils \ Environment . cpp " / > <nl> < ClCompile Include = " . . \ . . \ xbmc \ utils \ XBMCTinyXML . cpp " / > <nl> < ClCompile Include = " . . \ . . \ xbmc \ utils \ XMLUtils . cpp " / > <nl> < ClCompile Include = " . . \ . . \ xbmc \ video \ Bookmark . cpp " / > <nl> <nl> < ClInclude Include = " . . \ . . \ xbmc \ utils \ UrlOptions . h " / > <nl> < ClInclude Include = " . . \ . . \ xbmc \ utils \ Variant . h " / > <nl> < ClInclude Include = " . . \ . . \ xbmc \ utils \ Weather . h " / > <nl> + < ClInclude Include = " . . \ . . \ xbmc \ utils \ Environment . h " / > <nl> < ClInclude Include = " . . \ . . \ xbmc \ utils \ XBMCTinyXML . h " / > <nl> < ClInclude Include = " . . \ . . \ xbmc \ utils \ XMLUtils . h " / > <nl> < ClInclude Include = " . . \ . . \ xbmc \ video \ Bookmark . h " / > <nl> mmm a / project / VS2010Express / XBMC . vcxproj . filters <nl> ppp b / project / VS2010Express / XBMC . vcxproj . filters <nl> <nl> < ClCompile Include = " . . \ . . \ xbmc \ cores \ dvdplayer \ DVDDemuxers \ DVDDemuxCDDA . cpp " > <nl> < Filter > cores \ dvdplayer \ DVDDemuxers < / Filter > <nl> < / ClCompile > <nl> + < ClCompile Include = " . . \ . . \ xbmc \ utils \ Environment . cpp " > <nl> + < Filter > utils < / Filter > <nl> + < / ClCompile > <nl> < / ItemGroup > <nl> < ItemGroup > <nl> < ClInclude Include = " . . \ . . \ xbmc \ win32 \ pch . h " > <nl> <nl> < ClInclude Include = " . . \ . . \ xbmc \ cores \ dvdplayer \ DVDDemuxers \ DVDDemuxCDDA . h " > <nl> < Filter > cores \ dvdplayer \ DVDDemuxers < / Filter > <nl> < / ClInclude > <nl> + < ClInclude Include = " . . \ . . \ xbmc \ utils \ Environment . h " > <nl> + < Filter > utils < / Filter > <nl> + < / ClInclude > <nl> < / ItemGroup > <nl> < ItemGroup > <nl> < ResourceCompile Include = " . . \ . . \ xbmc \ win32 \ XBMC_PC . rc " > <nl> mmm a / xbmc / Application . cpp <nl> ppp b / xbmc / Application . cpp <nl> <nl> # include " linux / LinuxTimezone . h " <nl> # endif <nl> <nl> + # ifdef TARGET_WINDOWS <nl> + # include " utils / Environment . h " <nl> + # endif <nl> + <nl> using namespace std ; <nl> using namespace ADDON ; <nl> using namespace XFILE ; <nl> bool CApplication : : Create ( ) <nl> # elif defined ( _LINUX ) <nl> setenv ( " OS " , " Linux " , true ) ; <nl> # elif defined ( _WIN32 ) <nl> - SetEnvironmentVariable ( " OS " , " win32 " ) ; <nl> + CEnvironment : : setenv ( " OS " , " win32 " ) ; <nl> # endif <nl> <nl> g_powerManager . Initialize ( ) ; <nl> bool CApplication : : InitDirectoriesWin32 ( ) <nl> CStdString xbmcPath ; <nl> <nl> CUtil : : GetHomePath ( xbmcPath ) ; <nl> - SetEnvironmentVariable ( " XBMC_HOME " , xbmcPath . c_str ( ) ) ; <nl> + CEnvironment : : setenv ( " XBMC_HOME " , xbmcPath ) ; <nl> CSpecialProtocol : : SetXBMCBinPath ( xbmcPath ) ; <nl> CSpecialProtocol : : SetXBMCPath ( xbmcPath ) ; <nl> <nl> bool CApplication : : InitDirectoriesWin32 ( ) <nl> CSpecialProtocol : : SetMasterProfilePath ( URIUtils : : AddFileToFolder ( strWin32UserFolder , " userdata " ) ) ; <nl> CSpecialProtocol : : SetTempPath ( URIUtils : : AddFileToFolder ( strWin32UserFolder , " cache " ) ) ; <nl> <nl> - SetEnvironmentVariable ( " XBMC_PROFILE_USERDATA " , CSpecialProtocol : : TranslatePath ( " special : / / masterprofile / " ) . c_str ( ) ) ; <nl> + CEnvironment : : setenv ( " XBMC_PROFILE_USERDATA " , CSpecialProtocol : : TranslatePath ( " special : / / masterprofile / " ) ) ; <nl> <nl> CreateUserDirs ( ) ; <nl> <nl> new file mode 100644 <nl> index 000000000000 . . e09505a68099 <nl> mmm / dev / null <nl> ppp b / xbmc / utils / Environment . cpp <nl> <nl> + / * <nl> + * Copyright ( C ) 2013 Team XBMC <nl> + * http : / / www . xbmc . org <nl> + * <nl> + * This Program is free software ; you can redistribute it and / or modify <nl> + * it under the terms of the GNU General Public License as published by <nl> + * the Free Software Foundation ; either version 2 , or ( at your option ) <nl> + * any later version . <nl> + * <nl> + * This Program is distributed in the hope that it will be useful , <nl> + * but WITHOUT ANY WARRANTY ; without even the implied warranty of <nl> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the <nl> + * GNU General Public License for more details . <nl> + * <nl> + * You should have received a copy of the GNU General Public License <nl> + * along with XBMC ; see the file COPYING . If not , see <nl> + * < http : / / www . gnu . org / licenses / > . <nl> + * <nl> + * / <nl> + <nl> + / * * <nl> + * \ file utils \ Environment . cpp <nl> + * \ brief Implements CEnvironment class functions . <nl> + * <nl> + * Some ideas were inspired by PostgreSQL ' s pgwin32_putenv function . <nl> + * Refined , updated , enhanced and modified for XBMC by Karlson2k . <nl> + * / <nl> + <nl> + # include " Environment . h " <nl> + # include < stdlib . h > <nl> + # ifdef TARGET_WINDOWS <nl> + # include < Windows . h > <nl> + # endif <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmm Helper Functions mmmmmmmmmmmmmmmmmmmmm <nl> + <nl> + # ifdef TARGET_WINDOWS <nl> + <nl> + std : : wstring CEnvironment : : win32ConvertUtf8ToW ( const std : : string & text , bool * resultSuccessful / * = NULL * / ) <nl> + { <nl> + if ( text . empty ( ) ) <nl> + { <nl> + if ( resultSuccessful ! = NULL ) <nl> + * resultSuccessful = true ; <nl> + return L " " ; <nl> + } <nl> + if ( resultSuccessful ! = NULL ) <nl> + * resultSuccessful = false ; <nl> + <nl> + int bufSize = MultiByteToWideChar ( CP_UTF8 , MB_ERR_INVALID_CHARS , text . c_str ( ) , - 1 , NULL , 0 ) ; <nl> + if ( bufSize = = 0 ) <nl> + return L " " ; <nl> + wchar_t * converted = new wchar_t [ bufSize ] ; <nl> + if ( MultiByteToWideChar ( CP_UTF8 , MB_ERR_INVALID_CHARS , text . c_str ( ) , - 1 , converted , bufSize ) ! = bufSize ) <nl> + { <nl> + delete [ ] converted ; <nl> + return L " " ; <nl> + } <nl> + <nl> + std : : wstring Wret ( converted ) ; <nl> + delete [ ] converted ; <nl> + <nl> + if ( resultSuccessful ! = NULL ) <nl> + * resultSuccessful = true ; <nl> + return Wret ; <nl> + } <nl> + <nl> + std : : string CEnvironment : : win32ConvertWToUtf8 ( const std : : wstring & text , bool * resultSuccessful / * = NULL * / ) <nl> + { <nl> + if ( text . empty ( ) ) <nl> + { <nl> + if ( resultSuccessful ! = NULL ) <nl> + * resultSuccessful = true ; <nl> + return " " ; <nl> + } <nl> + if ( resultSuccessful ! = NULL ) <nl> + * resultSuccessful = false ; <nl> + <nl> + int bufSize = WideCharToMultiByte ( CP_UTF8 , MB_ERR_INVALID_CHARS , text . c_str ( ) , - 1 , NULL , 0 , NULL , NULL ) ; <nl> + if ( bufSize = = 0 ) <nl> + return " " ; <nl> + char * converted = new char [ bufSize ] ; <nl> + if ( WideCharToMultiByte ( CP_UTF8 , MB_ERR_INVALID_CHARS , text . c_str ( ) , - 1 , converted , bufSize , NULL , NULL ) ! = bufSize ) <nl> + { <nl> + delete [ ] converted ; <nl> + return " " ; <nl> + } <nl> + <nl> + std : : string ret ( converted ) ; <nl> + delete [ ] converted ; <nl> + <nl> + if ( resultSuccessful ! = NULL ) <nl> + * resultSuccessful = true ; <nl> + return converted ; <nl> + } <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmm Internal Function mmmmmmmmmmmmmmmmmmmmm <nl> + <nl> + typedef int ( _cdecl * wputenvPtr ) ( const wchar_t * envstring ) ; <nl> + <nl> + / * * <nl> + * \ fn int CEnvironment : : win32_setenv ( const std : : wstring & name , const std : : wstring & value = L " " , <nl> + * updateAction action = autoDetect ) <nl> + * \ brief Internal function used to manipulate with environment variables on win32 . <nl> + * <nl> + * This function make all dirty work with setting , deleting and modifying environment variables . <nl> + * <nl> + * \ param name The environment variable name . <nl> + * \ param value ( optional ) the new value of environment variable . <nl> + * \ param action ( optional ) the action . <nl> + * \ return Zero on success , 2 if at least one external runtime update failed , 4 if process <nl> + * environment update failed , 8 if our runtime environment update failed or , in case of <nl> + * several errors , sum of all errors values ; non - zero in case of other errors . <nl> + * / <nl> + int CEnvironment : : win32_setenv ( const std : : string & name , const std : : string & value / * = " " * / , enum updateAction action / * = autoDetect * / ) <nl> + { <nl> + std : : wstring Wname ( win32ConvertUtf8ToW ( name ) ) ; <nl> + if ( Wname . empty ( ) | | name . find ( ' = ' ) ! = std : : wstring : : npos ) <nl> + return - 1 ; <nl> + if ( ( action = = addOnly | | action = = addOrUpdateOnly ) & & value . empty ( ) ) <nl> + return - 1 ; <nl> + if ( action = = addOnly & & ! ( getenv ( name ) . empty ( ) ) ) <nl> + return 0 ; <nl> + <nl> + bool convIsOK ; <nl> + std : : wstring Wvalue ( win32ConvertUtf8ToW ( value , & convIsOK ) ) ; <nl> + if ( ! convIsOK ) <nl> + return - 1 ; <nl> + <nl> + int retValue = 0 ; <nl> + std : : wstring EnvString ; <nl> + if ( action = = deleteVariable ) <nl> + EnvString = Wname + L " = " ; <nl> + else <nl> + EnvString = Wname + L " = " + Wvalue ; <nl> + <nl> + static const wchar_t * modulesList [ ] = <nl> + { <nl> + / * { L " msvcrt20 . dll " } , / / Visual C + + 2 . 0 / 2 . 1 / 2 . 2 <nl> + { L " msvcrt40 . dll " } , / / Visual C + + 4 . 0 / 4 . 1 * / / / too old and no UNICODE support - ignoring <nl> + { L " msvcrt . dll " } , / / Visual Studio 6 . 0 / MinGW [ - w64 ] <nl> + { L " msvcr70 . dll " } , / / Visual Studio 2002 <nl> + { L " msvcr71 . dll " } , / / Visual Studio 2003 <nl> + { L " msvcr80 . dll " } , / / Visual Studio 2005 <nl> + { L " msvcr90 . dll " } , / / Visual Studio 2008 <nl> + { L " msvcr100 . dll " } , / / Visual Studio 2010 <nl> + # ifdef _DEBUG <nl> + { L " msvcr100d . dll " } , / / Visual Studio 2010 ( debug ) <nl> + # endif <nl> + { L " msvcr110 . dll " } , / / Visual Studio 2012 <nl> + { NULL } / / Terminating NULL for list <nl> + } ; <nl> + <nl> + / / Check all modules each function run , because modules can be loaded / unloaded at runtime <nl> + for ( int i = 0 ; modulesList [ i ] ; i + + ) <nl> + { <nl> + HMODULE hModule ; <nl> + if ( ! GetModuleHandleExW ( 0 , modulesList [ i ] , & hModule ) | | hModule = = NULL ) / / Flag 0 ensures that module will be kept loaded until it ' ll be freed <nl> + continue ; / / Module not loaded <nl> + <nl> + wputenvPtr wputenvFunc = ( wputenvPtr ) GetProcAddress ( hModule , " _wputenv " ) ; <nl> + if ( wputenvFunc ! = NULL & & wputenvFunc ( EnvString . c_str ( ) ) ! = 0 ) <nl> + retValue | = 2 ; / / At lest one external runtime library Environment update failed <nl> + FreeLibrary ( hModule ) ; <nl> + } <nl> + <nl> + / / Update process Environment used for current process and for future new child processes <nl> + if ( action = = deleteVariable | | value . empty ( ) ) <nl> + retValue + = SetEnvironmentVariableW ( Wname . c_str ( ) , NULL ) ? 0 : 4 ; / / 4 if failed <nl> + else <nl> + retValue + = SetEnvironmentVariableW ( Wname . c_str ( ) , Wvalue . c_str ( ) ) ? 0 : 4 ; / / 4 if failed <nl> + <nl> + / / Finally update our runtime Environment <nl> + retValue + = ( : : _wputenv ( EnvString . c_str ( ) ) = = 0 ) ? 0 : 8 ; / / 8 if failed <nl> + <nl> + return retValue ; <nl> + } <nl> + # endif <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmm Main Functions mmmmmmmmmmmmmmmmmmmmm <nl> + <nl> + int CEnvironment : : setenv ( const std : : string & name , const std : : string & value , int overwrite / * = 1 * / ) <nl> + { <nl> + # ifdef TARGET_WINDOWS <nl> + return ( win32_setenv ( name , value , overwrite ? autoDetect : addOnly ) = = 0 ) ? 0 : - 1 ; <nl> + # else <nl> + if ( value . empty ( ) & & overwrite ! = 0 ) <nl> + return : : unsetenv ( name . c_str ( ) ) ; <nl> + return : : setenv ( name . c_str ( ) , value . c_str ( ) , overwrite ) ; <nl> + # endif <nl> + } <nl> + <nl> + std : : string CEnvironment : : getenv ( const std : : string & name ) <nl> + { <nl> + # ifdef TARGET_WINDOWS <nl> + std : : wstring Wname ( win32ConvertUtf8ToW ( name ) ) ; <nl> + if ( Wname . empty ( ) ) <nl> + return " " ; <nl> + <nl> + std : : wstring Wvalue ( : : _wgetenv ( Wname . c_str ( ) ) ) ; <nl> + if ( ! Wvalue . empty ( ) ) <nl> + return win32ConvertWToUtf8 ( Wvalue ) ; <nl> + <nl> + / / Not found in Environment of runtime library <nl> + / / Try Environment of process as fallback <nl> + int varSize = GetEnvironmentVariableW ( Wname . c_str ( ) , NULL , 0 ) ; <nl> + if ( varSize = = 0 ) <nl> + return " " ; / / Not found <nl> + wchar_t * valBuf = new wchar_t [ varSize ] ; <nl> + if ( GetEnvironmentVariableW ( Wname . c_str ( ) , valBuf , varSize ) ! = varSize - 1 ) <nl> + { <nl> + delete [ ] valBuf ; <nl> + return " " ; <nl> + } <nl> + Wvalue = valBuf ; <nl> + delete [ ] valBuf ; <nl> + <nl> + return win32ConvertWToUtf8 ( Wvalue ) ; <nl> + # else <nl> + return : : getenv ( name . c_str ( ) ) ; <nl> + # endif <nl> + } <nl> + <nl> + int CEnvironment : : unsetenv ( const std : : string & name ) <nl> + { <nl> + # ifdef TARGET_WINDOWS <nl> + return ( win32_setenv ( name , " " , deleteVariable ) ) = = 0 ? 0 : - 1 ; <nl> + # else <nl> + return : : unsetenv ( name . c_str ( ) ) ; <nl> + # endif <nl> + } <nl> + <nl> + int CEnvironment : : putenv ( const std : : string & envstring ) <nl> + { <nl> + if ( envstring . empty ( ) ) <nl> + return 0 ; <nl> + int pos = envstring . find ( ' = ' ) ; <nl> + if ( pos = = 0 ) / / ' = ' is the first character <nl> + return - 1 ; <nl> + if ( pos = = std : : string : : npos ) <nl> + return unsetenv ( envstring ) ; <nl> + if ( pos = = envstring . length ( ) - 1 ) / / ' = ' is in last position <nl> + { <nl> + std : : string name ( envstring ) ; <nl> + name . erase ( name . length ( ) - 1 , 1 ) ; <nl> + return unsetenv ( name ) ; <nl> + } <nl> + std : : string name ( envstring , 0 , pos ) , value ( envstring , pos + 1 ) ; <nl> + <nl> + return setenv ( name , value ) ; <nl> + } <nl> + <nl> new file mode 100644 <nl> index 000000000000 . . 62e0d1f0df61 <nl> mmm / dev / null <nl> ppp b / xbmc / utils / Environment . h <nl> <nl> + # pragma once <nl> + # ifndef XBMC_SETENV_H <nl> + # define XBMC_SETENV_H <nl> + / * <nl> + * Copyright ( C ) 2013 Team XBMC <nl> + * http : / / www . xbmc . org <nl> + * <nl> + * This Program is free software ; you can redistribute it and / or modify <nl> + * it under the terms of the GNU General Public License as published by <nl> + * the Free Software Foundation ; either version 2 , or ( at your option ) <nl> + * any later version . <nl> + * <nl> + * This Program is distributed in the hope that it will be useful , <nl> + * but WITHOUT ANY WARRANTY ; without even the implied warranty of <nl> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the <nl> + * GNU General Public License for more details . <nl> + * <nl> + * You should have received a copy of the GNU General Public License <nl> + * along with XBMC ; see the file COPYING . If not , see <nl> + * < http : / / www . gnu . org / licenses / > . <nl> + * <nl> + * / <nl> + <nl> + / * * <nl> + * \ file utils \ Environment . h <nl> + * \ brief Declares CEnvironment class for platform - independent environment variables manipulations . <nl> + * <nl> + * / <nl> + # include < string > <nl> + <nl> + / * * <nl> + * @ class CEnvironment <nl> + * <nl> + * @ brief Platform - independent environment variables manipulations . <nl> + * <nl> + * Provide analog for POSIX functions : <nl> + * + setenv <nl> + * + unsetenv <nl> + * + putenv <nl> + * + getenv <nl> + * <nl> + * You can generally use the functions as you would normally in POSIX - style . <nl> + * The differences below are just to make things more convenient through use of std : : string ( 2 , 3 ) , <nl> + * and to also allow the Win32 - style of unsetting variables ( 4 , 5 ) if wanted . <nl> + * 1 . CEnvironment : : setenv parameter ' overwrite ' is optional , set by default to 1 ( allow overwrite ) . <nl> + * 2 . CEnvironment : : putenv uses copy of provided string ( rather than string itself ) to change environment , <nl> + * so you can free parameter variable right after call of function . <nl> + * 3 . CEnvironment : : getenv returns a copy of environment variable value instead of pointer to value . <nl> + * 4 . CEnvironment : : setenv can be used to unset variables . Just pass empty string for ' value ' parameter . <nl> + * 5 . CEnvironment : : putenv can be used to unset variables . Set parameter to ' var = ' ( Windows style ) or <nl> + * just ' var ' ( POSIX style ) , and ' var ' will be unset . <nl> + * <nl> + * All ' std : : string ' types are supposed to be in UTF - 8 encoding . <nl> + * All functions work on all platforms . Special care is taken on Windows platform where Environment is changed for process itself , <nl> + * for process runtime library and for all runtime libraries ( MSVCRT ) loaded by third - party modules . <nl> + * Functions internally make all necessary UTF - 8 < - > wide conversions . * <nl> + * / <nl> + <nl> + class CEnvironment <nl> + { <nl> + public : <nl> + / * * <nl> + * \ fn static int CEnvironment : : setenv ( const std : : string & name , const std : : string & value , <nl> + * int overwrite = 1 ) ; <nl> + * \ brief Sets or unsets environment variable . <nl> + * \ param name The environment variable name to add / modify / delete . <nl> + * \ param value The environment variable new value . If set to empty string , variable will be <nl> + * deleted from the environment . <nl> + * \ param overwrite ( optional ) If set to non - zero , existing variable will be overwritten . If set to zero and <nl> + * variable is already present , then variable will be unchanged and function returns success . <nl> + * \ return Zero on success , non - zero on error . <nl> + * / <nl> + static int setenv ( const std : : string & name , const std : : string & value , int overwrite = 1 ) ; <nl> + / * * <nl> + * \ fn static int CEnvironment : : unsetenv ( const std : : string & name ) ; <nl> + * \ brief Deletes environment variable . <nl> + * \ param name The environment variable name to delete . <nl> + * \ return Zero on success , non - zero on error . <nl> + * / <nl> + static int unsetenv ( const std : : string & name ) ; <nl> + <nl> + / * * <nl> + * \ fn static int CEnvironment : putenv ( const std : : string & envstring ) ; <nl> + * \ brief Adds / modifies / deletes environment variable . <nl> + * \ param envstring The variable - value string in form ' var = value ' . If set to ' var = ' or ' var ' , then variable <nl> + * will be deleted from the environment . <nl> + * \ return Zero on success , non - zero on error . <nl> + * / <nl> + static int putenv ( const std : : string & envstring ) ; <nl> + / * * <nl> + * \ fn static std : : string CEnvironment : : getenv ( const std : : string & name ) ; <nl> + * \ brief Gets value of environment variable in UTF - 8 encoding . <nl> + * \ param name The name of environment variable . <nl> + * \ return Copy of of environment variable value or empty string if variable in not present in environment . <nl> + * \ sa xbmc_getenvUtf8 , xbmc_getenvW <nl> + * / <nl> + static std : : string getenv ( const std : : string & name ) ; <nl> + # ifdef TARGET_WINDOWS <nl> + private : <nl> + static std : : wstring win32ConvertUtf8ToW ( const std : : string & text , bool * resultSuccessful = NULL ) ; <nl> + static std : : string win32ConvertWToUtf8 ( const std : : wstring & text , bool * resultSuccessful = NULL ) ; <nl> + enum updateAction : int { addOrUpdateOnly = - 2 , deleteVariable = - 1 , addOnly = 0 , autoDetect = 1 } ; <nl> + static int win32_setenv ( const std : : string & name , const std : : string & value = " " , updateAction action = autoDetect ) ; <nl> + # endif / / TARGET_WINDOWS <nl> + } ; <nl> + # endif <nl> mmm a / xbmc / utils / Makefile . in <nl> ppp b / xbmc / utils / Makefile . in <nl> SRCS + = DownloadQueue . cpp <nl> SRCS + = DownloadQueueManager . cpp <nl> SRCS + = EndianSwap . cpp <nl> SRCS + = EdenVideoArtUpdater . cpp <nl> + SRCS + = Environment . cpp <nl> SRCS + = Fanart . cpp <nl> SRCS + = fastmemcpy . c <nl> SRCS + = fastmemcpy - arm . S <nl> | Merge pull request from Karlson2k / xbmc_setenv_clean | xbmc/xbmc | 1fb487ac6ae97d3a8978df7e647de982ad1fd92c | 2013-05-11T23:11:49Z |
mmm a / android / sdk / src / main / java / com / taobao / weex / utils / WXUtils . java <nl> ppp b / android / sdk / src / main / java / com / taobao / weex / utils / WXUtils . java <nl> private static int indexLineBreak ( String str , int fromIndex ) { <nl> } <nl> <nl> <nl> + / * * <nl> + * get number <nl> + * * / <nl> public static int getNumberInt ( Object value , int defaultValue ) { <nl> if ( value = = null ) { <nl> return defaultValue ; <nl> public static int getNumberInt ( Object value , int defaultValue ) { <nl> return ( ( Number ) value ) . intValue ( ) ; <nl> } <nl> try { <nl> - return ( int ) Float . parseFloat ( value . toString ( ) ) ; <nl> + String number = value . toString ( ) ; <nl> + if ( number . indexOf ( ' . ' ) > = 0 ) { <nl> + return ( int ) Float . parseFloat ( value . toString ( ) ) ; <nl> + } else { <nl> + return Integer . parseInt ( number ) ; <nl> + } <nl> } catch ( Exception e ) { return defaultValue ; } <nl> } <nl> <nl> | return number | apache/incubator-weex | 3c54e276446b7b4b36cb0182b02f72d5b3591d01 | 2017-09-04T14:09:43Z |
mmm a / src / frames . h <nl> ppp b / src / frames . h <nl> class StandardFrame : public StackFrame { <nl> <nl> private : <nl> friend class StackFrame ; <nl> + friend class StackFrameIterator ; <nl> } ; <nl> <nl> <nl> | Add friend declaration . | v8/v8 | 44c17de1b35ec351f3239193908c72cb203c7928 | 2010-05-08T06:54:36Z |
mmm a / html5 / default / core / dep . js <nl> ppp b / html5 / default / core / dep . js <nl> export default function Dep ( ) { <nl> / / this is globally unique because there could be only one <nl> / / watcher being evaluated at any time . <nl> Dep . target = null <nl> + const targetStack = [ ] <nl> + <nl> + export function pushTarget ( _target ) { <nl> + if ( Dep . target ) targetStack . push ( Dep . target ) <nl> + Dep . target = _target <nl> + } <nl> + <nl> + export function popTarget ( ) { <nl> + Dep . target = targetStack . pop ( ) <nl> + } <nl> <nl> / * * <nl> * Add a directive subscriber . <nl> mmm a / html5 / default / core / watcher . js <nl> ppp b / html5 / default / core / watcher . js <nl> <nl> / * eslint - disable * / <nl> <nl> - import Dep from ' . / dep ' <nl> + import Dep , { pushTarget , popTarget } from ' . / dep ' <nl> / / import { pushWatcher } from ' . / batcher ' <nl> import { <nl> warn , <nl> Watcher . prototype . get = function ( ) { <nl> * / <nl> <nl> Watcher . prototype . beforeGet = function ( ) { <nl> - prevTarget = Dep . target <nl> - Dep . target = this <nl> + pushTarget ( this ) <nl> } <nl> <nl> / * * <nl> Watcher . prototype . addDep = function ( dep ) { <nl> * / <nl> <nl> Watcher . prototype . afterGet = function ( ) { <nl> - Dep . target = prevTarget <nl> + popTarget ( ) <nl> let i = this . deps . length <nl> while ( i - - ) { <nl> const dep = this . deps [ i ] <nl> | * [ jsfm ] fix watcher dismatched bug between multi instance | apache/incubator-weex | 900305de79e34b808530aa6e76e3d957b7b060e5 | 2016-08-25T09:53:31Z |
mmm a / examples / rvm_regression_ex . cpp <nl> ppp b / examples / rvm_regression_ex . cpp <nl> int main ( ) <nl> / / Here we declare that our samples will be 1 dimensional column vectors . <nl> typedef matrix < double , 1 , 1 > sample_type ; <nl> <nl> - / / Now we are making a typedef for the kind of kernel we want to use . I picked the <nl> - / / radial basis kernel because it only has one parameter and generally gives good <nl> - / / results without much fiddling . <nl> - typedef radial_basis_kernel < sample_type > kernel_type ; <nl> - <nl> - / / Here we declare an instance of the rvm_regression_trainer object . This is the <nl> - / / object that we will later use to do the training . <nl> - rvm_regression_trainer < kernel_type > trainer ; <nl> - / / Here we set the kernel we want to use for training . The 0 . 05 is the gamma <nl> - / / parameter to the radial_basis_kernel . <nl> - trainer . set_kernel ( kernel_type ( 0 . 05 ) ) ; <nl> - <nl> / / Now sample some points from the sinc ( ) function <nl> sample_type m ; <nl> std : : vector < sample_type > samples ; <nl> int main ( ) <nl> labels . push_back ( sinc ( x ) ) ; <nl> } <nl> <nl> + / / Now we are making a typedef for the kind of kernel we want to use . I picked the <nl> + / / radial basis kernel because it only has one parameter and generally gives good <nl> + / / results without much fiddling . <nl> + typedef radial_basis_kernel < sample_type > kernel_type ; <nl> + <nl> + / / Here we declare an instance of the rvm_regression_trainer object . This is the <nl> + / / object that we will later use to do the training . <nl> + rvm_regression_trainer < kernel_type > trainer ; <nl> + <nl> + / / Here we set the kernel we want to use for training . The radial_basis_kernel <nl> + / / has a parameter called gamma that we need to determine . As a rule of thumb , a good <nl> + / / gamma to try is 1 . 0 / ( mean squared distance between your sample points ) . So <nl> + / / below we are using a similar value . Note also that using an inappropriately large <nl> + / / gamma will cause the RVM training algorithm to run extremely slowly . What <nl> + / / " large " means is relative to how spread out your data is . So it is important <nl> + / / to use a rule like this as a starting point for determining the gamma value <nl> + / / if you want to use the RVM . It is also probably a good idea to normalize your <nl> + / / samples as shown in the rvm_ex . cpp example program . <nl> + const double gamma = 2 . 0 / compute_mean_squared_distance ( samples ) ; <nl> + cout < < " using gamma of " < < gamma < < endl ; <nl> + trainer . set_kernel ( kernel_type ( gamma ) ) ; <nl> + <nl> / / now train a function based on our sample points <nl> decision_function < kernel_type > test = trainer . train ( samples , labels ) ; <nl> <nl> int main ( ) <nl> m ( 0 ) = 5 . 0 ; cout < < sinc ( m ( 0 ) ) < < " " < < test ( m ) < < endl ; <nl> <nl> / / The output is as follows : <nl> + / / using gamma of 0 . 05 <nl> / / 0 . 239389 0 . 240989 <nl> / / 0 . 998334 0 . 999538 <nl> / / - 0 . 189201 - 0 . 188453 <nl> | Added a comment about picking a reasonable gamma . | davisking/dlib | 9d09a8db3dfb3d0b039f92ec0b168707021a8198 | 2010-07-17T12:31:34Z |
mmm a / Marlin / Marlin . h <nl> ppp b / Marlin / Marlin . h <nl> extern int16_t code_value_short ( ) ; <nl> extern uint8_t host_keepalive_interval ; <nl> # endif <nl> <nl> - # if ENABLED ( PREVENT_DANGEROUS_EXTRUDE ) <nl> - extern float extrude_min_temp ; <nl> - # endif <nl> - <nl> # if FAN_COUNT > 0 <nl> extern int fanSpeeds [ FAN_COUNT ] ; <nl> # endif <nl> mmm a / Marlin / Marlin_main . cpp <nl> ppp b / Marlin / Marlin_main . cpp <nl> static void report_current_position ( ) ; <nl> } <nl> # endif <nl> <nl> - # if ENABLED ( PREVENT_DANGEROUS_EXTRUDE ) <nl> - float extrude_min_temp = EXTRUDE_MINTEMP ; <nl> - # endif <nl> - <nl> # if ENABLED ( SDSUPPORT ) <nl> # include " SdFatUtil . h " <nl> int freeMemory ( ) { return SdFatUtil : : FreeRam ( ) ; } <nl> void setup ( ) { <nl> <nl> lcd_init ( ) ; <nl> <nl> - tp_init ( ) ; / / Initialize temperature loop <nl> + thermalManager . init ( ) ; / / Initialize temperature loop <nl> <nl> # if ENABLED ( DELTA ) | | ENABLED ( SCARA ) <nl> / / Vital to init kinematic equivalent for X0 Y0 Z0 <nl> inline void gcode_M31 ( ) { <nl> SERIAL_ECHO_START ; <nl> SERIAL_ECHOLN ( time ) ; <nl> lcd_setstatus ( time ) ; <nl> - autotempShutdown ( ) ; <nl> + thermalManager . autotempShutdown ( ) ; <nl> } <nl> <nl> # if ENABLED ( SDSUPPORT ) <nl> inline void gcode_M104 ( ) { <nl> <nl> if ( code_seen ( ' S ' ) ) { <nl> float temp = code_value ( ) ; <nl> - setTargetHotend ( temp , target_extruder ) ; <nl> + thermalManager . setTargetHotend ( temp , target_extruder ) ; <nl> # if ENABLED ( DUAL_X_CARRIAGE ) <nl> if ( dual_x_carriage_mode = = DXC_DUPLICATION_MODE & & target_extruder = = 0 ) <nl> - setTargetHotend1 ( temp = = 0 . 0 ? 0 . 0 : temp + duplicate_extruder_temp_offset ) ; <nl> + thermalManager . setTargetHotend ( temp = = 0 . 0 ? 0 . 0 : temp + duplicate_extruder_temp_offset , 1 ) ; <nl> # endif <nl> <nl> / * * <nl> inline void gcode_M104 ( ) { <nl> * / <nl> else print_job_timer . start ( ) ; <nl> <nl> - if ( temp > degHotend ( target_extruder ) ) LCD_MESSAGEPGM ( MSG_HEATING ) ; <nl> + if ( temp > thermalManager . degHotend ( target_extruder ) ) LCD_MESSAGEPGM ( MSG_HEATING ) ; <nl> } <nl> } <nl> <nl> inline void gcode_M104 ( ) { <nl> void print_heaterstates ( ) { <nl> # if HAS_TEMP_HOTEND <nl> SERIAL_PROTOCOLPGM ( " T : " ) ; <nl> - SERIAL_PROTOCOL_F ( degHotend ( target_extruder ) , 1 ) ; <nl> + SERIAL_PROTOCOL_F ( thermalManager . degHotend ( target_extruder ) , 1 ) ; <nl> SERIAL_PROTOCOLPGM ( " / " ) ; <nl> - SERIAL_PROTOCOL_F ( degTargetHotend ( target_extruder ) , 1 ) ; <nl> + SERIAL_PROTOCOL_F ( thermalManager . degTargetHotend ( target_extruder ) , 1 ) ; <nl> # endif <nl> # if HAS_TEMP_BED <nl> SERIAL_PROTOCOLPGM ( " B : " ) ; <nl> - SERIAL_PROTOCOL_F ( degBed ( ) , 1 ) ; <nl> + SERIAL_PROTOCOL_F ( thermalManager . degBed ( ) , 1 ) ; <nl> SERIAL_PROTOCOLPGM ( " / " ) ; <nl> - SERIAL_PROTOCOL_F ( degTargetBed ( ) , 1 ) ; <nl> + SERIAL_PROTOCOL_F ( thermalManager . degTargetBed ( ) , 1 ) ; <nl> # endif <nl> # if EXTRUDERS > 1 <nl> for ( int8_t e = 0 ; e < EXTRUDERS ; + + e ) { <nl> SERIAL_PROTOCOLPGM ( " T " ) ; <nl> SERIAL_PROTOCOL ( e ) ; <nl> SERIAL_PROTOCOLCHAR ( ' : ' ) ; <nl> - SERIAL_PROTOCOL_F ( degHotend ( e ) , 1 ) ; <nl> + SERIAL_PROTOCOL_F ( thermalManager . degHotend ( e ) , 1 ) ; <nl> SERIAL_PROTOCOLPGM ( " / " ) ; <nl> - SERIAL_PROTOCOL_F ( degTargetHotend ( e ) , 1 ) ; <nl> + SERIAL_PROTOCOL_F ( thermalManager . degTargetHotend ( e ) , 1 ) ; <nl> } <nl> # endif <nl> # if HAS_TEMP_BED <nl> SERIAL_PROTOCOLPGM ( " B @ : " ) ; <nl> # ifdef BED_WATTS <nl> - SERIAL_PROTOCOL ( ( ( BED_WATTS ) * getHeaterPower ( - 1 ) ) / 127 ) ; <nl> + SERIAL_PROTOCOL ( ( ( BED_WATTS ) * thermalManager . getHeaterPower ( - 1 ) ) / 127 ) ; <nl> SERIAL_PROTOCOLCHAR ( ' W ' ) ; <nl> # else <nl> - SERIAL_PROTOCOL ( getHeaterPower ( - 1 ) ) ; <nl> + SERIAL_PROTOCOL ( thermalManager . getHeaterPower ( - 1 ) ) ; <nl> # endif <nl> # endif <nl> SERIAL_PROTOCOLPGM ( " @ : " ) ; <nl> # ifdef EXTRUDER_WATTS <nl> - SERIAL_PROTOCOL ( ( ( EXTRUDER_WATTS ) * getHeaterPower ( target_extruder ) ) / 127 ) ; <nl> + SERIAL_PROTOCOL ( ( ( EXTRUDER_WATTS ) * thermalManager . getHeaterPower ( target_extruder ) ) / 127 ) ; <nl> SERIAL_PROTOCOLCHAR ( ' W ' ) ; <nl> # else <nl> - SERIAL_PROTOCOL ( getHeaterPower ( target_extruder ) ) ; <nl> + SERIAL_PROTOCOL ( thermalManager . getHeaterPower ( target_extruder ) ) ; <nl> # endif <nl> # if EXTRUDERS > 1 <nl> for ( int8_t e = 0 ; e < EXTRUDERS ; + + e ) { <nl> inline void gcode_M104 ( ) { <nl> SERIAL_PROTOCOL ( e ) ; <nl> SERIAL_PROTOCOLCHAR ( ' : ' ) ; <nl> # ifdef EXTRUDER_WATTS <nl> - SERIAL_PROTOCOL ( ( ( EXTRUDER_WATTS ) * getHeaterPower ( e ) ) / 127 ) ; <nl> + SERIAL_PROTOCOL ( ( ( EXTRUDER_WATTS ) * thermalManager . getHeaterPower ( e ) ) / 127 ) ; <nl> SERIAL_PROTOCOLCHAR ( ' W ' ) ; <nl> # else <nl> - SERIAL_PROTOCOL ( getHeaterPower ( e ) ) ; <nl> + SERIAL_PROTOCOL ( thermalManager . getHeaterPower ( e ) ) ; <nl> # endif <nl> } <nl> # endif <nl> # if ENABLED ( SHOW_TEMP_ADC_VALUES ) <nl> # if HAS_TEMP_BED <nl> SERIAL_PROTOCOLPGM ( " ADC B : " ) ; <nl> - SERIAL_PROTOCOL_F ( degBed ( ) , 1 ) ; <nl> + SERIAL_PROTOCOL_F ( thermalManager . degBed ( ) , 1 ) ; <nl> SERIAL_PROTOCOLPGM ( " C - > " ) ; <nl> - SERIAL_PROTOCOL_F ( rawBedTemp ( ) / OVERSAMPLENR , 0 ) ; <nl> + SERIAL_PROTOCOL_F ( thermalManager . rawBedTemp ( ) / OVERSAMPLENR , 0 ) ; <nl> # endif <nl> for ( int8_t cur_extruder = 0 ; cur_extruder < EXTRUDERS ; + + cur_extruder ) { <nl> SERIAL_PROTOCOLPGM ( " T " ) ; <nl> SERIAL_PROTOCOL ( cur_extruder ) ; <nl> SERIAL_PROTOCOLCHAR ( ' : ' ) ; <nl> - SERIAL_PROTOCOL_F ( degHotend ( cur_extruder ) , 1 ) ; <nl> + SERIAL_PROTOCOL_F ( thermalManager . degHotend ( cur_extruder ) , 1 ) ; <nl> SERIAL_PROTOCOLPGM ( " C - > " ) ; <nl> - SERIAL_PROTOCOL_F ( rawHotendTemp ( cur_extruder ) / OVERSAMPLENR , 0 ) ; <nl> + SERIAL_PROTOCOL_F ( thermalManager . rawHotendTemp ( cur_extruder ) / OVERSAMPLENR , 0 ) ; <nl> } <nl> # endif <nl> } <nl> inline void gcode_M109 ( ) { <nl> bool no_wait_for_cooling = code_seen ( ' S ' ) ; <nl> if ( no_wait_for_cooling | | code_seen ( ' R ' ) ) { <nl> float temp = code_value ( ) ; <nl> - setTargetHotend ( temp , target_extruder ) ; <nl> + thermalManager . setTargetHotend ( temp , target_extruder ) ; <nl> # if ENABLED ( DUAL_X_CARRIAGE ) <nl> if ( dual_x_carriage_mode = = DXC_DUPLICATION_MODE & & target_extruder = = 0 ) <nl> - setTargetHotend1 ( temp = = 0 . 0 ? 0 . 0 : temp + duplicate_extruder_temp_offset ) ; <nl> + thermalManager . setTargetHotend ( temp = = 0 . 0 ? 0 . 0 : temp + duplicate_extruder_temp_offset , 1 ) ; <nl> # endif <nl> <nl> / * * <nl> inline void gcode_M109 ( ) { <nl> * / <nl> else print_job_timer . start ( ) ; <nl> <nl> - if ( temp > degHotend ( target_extruder ) ) LCD_MESSAGEPGM ( MSG_HEATING ) ; <nl> + if ( temp > thermalManager . degHotend ( target_extruder ) ) LCD_MESSAGEPGM ( MSG_HEATING ) ; <nl> } <nl> <nl> # if ENABLED ( AUTOTEMP ) <nl> inline void gcode_M109 ( ) { <nl> # define TEMP_CONDITIONS ( ! residency_start_ms | | PENDING ( now , residency_start_ms + ( TEMP_RESIDENCY_TIME ) * 1000UL ) ) <nl> # else <nl> / / Loop until the temperature is very close target <nl> - # define TEMP_CONDITIONS ( wants_to_cool ? isCoolingHotend ( target_extruder ) : isHeatingHotend ( target_extruder ) ) <nl> + # define TEMP_CONDITIONS ( wants_to_cool ? thermalManager . isCoolingHotend ( target_extruder ) : thermalManager . isHeatingHotend ( target_extruder ) ) <nl> # endif / / TEMP_RESIDENCY_TIME > 0 <nl> <nl> float theTarget = - 1 ; <nl> inline void gcode_M109 ( ) { <nl> KEEPALIVE_STATE ( NOT_BUSY ) ; <nl> <nl> do { <nl> - <nl> now = millis ( ) ; <nl> if ( ELAPSED ( now , next_temp_ms ) ) { / / Print temp & remaining time every 1s while waiting <nl> next_temp_ms = now + 1000UL ; <nl> inline void gcode_M109 ( ) { <nl> } <nl> <nl> / / Target temperature might be changed during the loop <nl> - if ( theTarget ! = degTargetHotend ( target_extruder ) ) { <nl> - theTarget = degTargetHotend ( target_extruder ) ; <nl> - wants_to_cool = isCoolingHotend ( target_extruder ) ; <nl> + if ( theTarget ! = thermalManager . degTargetHotend ( target_extruder ) ) { <nl> + wants_to_cool = thermalManager . isCoolingHotend ( target_extruder ) ; <nl> + theTarget = thermalManager . degTargetHotend ( target_extruder ) ; <nl> <nl> / / Exit if S < lower > , continue if S < higher > , R < lower > , or R < higher > <nl> if ( no_wait_for_cooling & & wants_to_cool ) break ; <nl> inline void gcode_M109 ( ) { <nl> <nl> # if TEMP_RESIDENCY_TIME > 0 <nl> <nl> - float temp_diff = fabs ( theTarget - degHotend ( target_extruder ) ) ; <nl> + float temp_diff = fabs ( theTarget - thermalManager . degHotend ( target_extruder ) ) ; <nl> <nl> if ( ! residency_start_ms ) { <nl> / / Start the TEMP_RESIDENCY_TIME timer when we reach target temp for the first time . <nl> inline void gcode_M109 ( ) { <nl> <nl> LCD_MESSAGEPGM ( MSG_BED_HEATING ) ; <nl> bool no_wait_for_cooling = code_seen ( ' S ' ) ; <nl> - if ( no_wait_for_cooling | | code_seen ( ' R ' ) ) setTargetBed ( code_value ( ) ) ; <nl> + if ( no_wait_for_cooling | | code_seen ( ' R ' ) ) thermalManager . setTargetBed ( code_value ( ) ) ; <nl> <nl> # if TEMP_BED_RESIDENCY_TIME > 0 <nl> millis_t residency_start_ms = 0 ; <nl> inline void gcode_M109 ( ) { <nl> # define TEMP_BED_CONDITIONS ( ! residency_start_ms | | PENDING ( now , residency_start_ms + ( TEMP_BED_RESIDENCY_TIME ) * 1000UL ) ) <nl> # else <nl> / / Loop until the temperature is very close target <nl> - # define TEMP_BED_CONDITIONS ( wants_to_cool ? isCoolingBed ( ) : isHeatingBed ( ) ) <nl> + # define TEMP_BED_CONDITIONS ( wants_to_cool ? thermalManager . isCoolingBed ( ) : thermalManager . isHeatingBed ( ) ) <nl> # endif / / TEMP_BED_RESIDENCY_TIME > 0 <nl> <nl> float theTarget = - 1 ; <nl> inline void gcode_M109 ( ) { <nl> } <nl> <nl> / / Target temperature might be changed during the loop <nl> - if ( theTarget ! = degTargetBed ( ) ) { <nl> - theTarget = degTargetBed ( ) ; <nl> - wants_to_cool = isCoolingBed ( ) ; <nl> + if ( theTarget ! = thermalManager . degTargetBed ( ) ) { <nl> + wants_to_cool = thermalManager . isCoolingBed ( ) ; <nl> + theTarget = thermalManager . degTargetBed ( ) ; <nl> <nl> / / Exit if S < lower > , continue if S < higher > , R < lower > , or R < higher > <nl> if ( no_wait_for_cooling & & wants_to_cool ) break ; <nl> <nl> / / Prevent a wait - forever situation if R is misused i . e . M190 R0 <nl> - / / Simply don ' t wait for cooling below 30C <nl> - if ( wants_to_cool & & theTarget < ( EXTRUDE_MINTEMP ) / 2 ) break ; <nl> + / / Simply don ' t wait to cool a bed under 30C <nl> + if ( wants_to_cool & & theTarget < 30 ) break ; <nl> } <nl> <nl> idle ( ) ; <nl> inline void gcode_M109 ( ) { <nl> <nl> # if TEMP_BED_RESIDENCY_TIME > 0 <nl> <nl> - float temp_diff = fabs ( degBed ( ) - degTargetBed ( ) ) ; <nl> + float temp_diff = fabs ( theTarget - thermalManager . degBed ( ) ) ; <nl> <nl> if ( ! residency_start_ms ) { <nl> / / Start the TEMP_BED_RESIDENCY_TIME timer when we reach target temp for the first time . <nl> inline void gcode_M112 ( ) { kill ( PSTR ( MSG_KILLED ) ) ; } <nl> * / <nl> inline void gcode_M140 ( ) { <nl> if ( DEBUGGING ( DRYRUN ) ) return ; <nl> - if ( code_seen ( ' S ' ) ) setTargetBed ( code_value ( ) ) ; <nl> + if ( code_seen ( ' S ' ) ) thermalManager . setTargetBed ( code_value ( ) ) ; <nl> } <nl> <nl> # if ENABLED ( ULTIPANEL ) <nl> inline void gcode_M140 ( ) { <nl> * This code should ALWAYS be available for EMERGENCY SHUTDOWN ! <nl> * / <nl> inline void gcode_M81 ( ) { <nl> - disable_all_heaters ( ) ; <nl> + thermalManager . disable_all_heaters ( ) ; <nl> stepper . finish_and_disable ( ) ; <nl> # if FAN_COUNT > 0 <nl> # if FAN_COUNT > 1 <nl> inline void gcode_M226 ( ) { <nl> NOMORE ( lpq_len , LPQ_MAX_LEN ) ; <nl> # endif <nl> <nl> - updatePID ( ) ; <nl> + thermalManager . updatePID ( ) ; <nl> SERIAL_ECHO_START ; <nl> # if ENABLED ( PID_PARAMS_PER_EXTRUDER ) <nl> SERIAL_ECHO ( " e : " ) ; / / specify extruder in serial output <nl> inline void gcode_M226 ( ) { <nl> # if ENABLED ( PIDTEMPBED ) <nl> <nl> inline void gcode_M304 ( ) { <nl> - if ( code_seen ( ' P ' ) ) bedKp = code_value ( ) ; <nl> - if ( code_seen ( ' I ' ) ) bedKi = scalePID_i ( code_value ( ) ) ; <nl> - if ( code_seen ( ' D ' ) ) bedKd = scalePID_d ( code_value ( ) ) ; <nl> + if ( code_seen ( ' P ' ) ) thermalManager . bedKp = code_value ( ) ; <nl> + if ( code_seen ( ' I ' ) ) thermalManager . bedKi = scalePID_i ( code_value ( ) ) ; <nl> + if ( code_seen ( ' D ' ) ) thermalManager . bedKd = scalePID_d ( code_value ( ) ) ; <nl> + <nl> + thermalManager . updatePID ( ) ; <nl> <nl> - updatePID ( ) ; <nl> SERIAL_ECHO_START ; <nl> SERIAL_ECHO ( " p : " ) ; <nl> - SERIAL_ECHO ( bedKp ) ; <nl> + SERIAL_ECHO ( thermalManager . bedKp ) ; <nl> SERIAL_ECHO ( " i : " ) ; <nl> - SERIAL_ECHO ( unscalePID_i ( bedKi ) ) ; <nl> + SERIAL_ECHO ( unscalePID_i ( thermalManager . bedKi ) ) ; <nl> SERIAL_ECHO ( " d : " ) ; <nl> - SERIAL_ECHOLN ( unscalePID_d ( bedKd ) ) ; <nl> + SERIAL_ECHOLN ( unscalePID_d ( thermalManager . bedKd ) ) ; <nl> } <nl> <nl> # endif / / PIDTEMPBED <nl> inline void gcode_M226 ( ) { <nl> <nl> # if ENABLED ( PREVENT_DANGEROUS_EXTRUDE ) <nl> <nl> - void set_extrude_min_temp ( float temp ) { extrude_min_temp = temp ; } <nl> - <nl> / * * <nl> * M302 : Allow cold extrudes , or set the minimum extrude S < temperature > . <nl> * / <nl> inline void gcode_M302 ( ) { <nl> - set_extrude_min_temp ( code_seen ( ' S ' ) ? code_value ( ) : 0 ) ; <nl> + thermalManager . extrude_min_temp = code_seen ( ' S ' ) ? code_value ( ) : 0 ; <nl> } <nl> <nl> # endif / / PREVENT_DANGEROUS_EXTRUDE <nl> inline void gcode_M303 ( ) { <nl> <nl> KEEPALIVE_STATE ( NOT_BUSY ) ; / / don ' t send " busy : processing " messages during autotune output <nl> <nl> - PID_autotune ( temp , e , c , u ) ; <nl> + thermalManager . PID_autotune ( temp , e , c , u ) ; <nl> <nl> KEEPALIVE_STATE ( IN_HANDLER ) ; <nl> # else <nl> inline void gcode_M400 ( ) { stepper . synchronize ( ) ; } <nl> NOMORE ( meas_delay_cm , MAX_MEASUREMENT_DELAY ) ; <nl> <nl> if ( filwidth_delay_index2 = = - 1 ) { / / Initialize the ring buffer if not done since startup <nl> - int temp_ratio = widthFil_to_size_ratio ( ) ; <nl> + int temp_ratio = thermalManager . widthFil_to_size_ratio ( ) ; <nl> <nl> for ( uint8_t i = 0 ; i < COUNT ( measurement_delay ) ; + + i ) <nl> measurement_delay [ i ] = temp_ratio - 100 ; / / Subtract 100 to scale within a signed byte <nl> inline void gcode_M503 ( ) { <nl> * / <nl> inline void gcode_M600 ( ) { <nl> <nl> - if ( degHotend ( active_extruder ) < extrude_min_temp ) { <nl> + if ( thermalManager . tooColdToExtrude ( active_extruder ) ) { <nl> SERIAL_ERROR_START ; <nl> SERIAL_ERRORLNPGM ( MSG_TOO_COLD_FOR_M600 ) ; <nl> return ; <nl> void mesh_buffer_line ( float x , float y , float z , const float e , float feed_rate , <nl> if ( DEBUGGING ( DRYRUN ) ) return ; <nl> float de = dest_e - curr_e ; <nl> if ( de ) { <nl> - if ( degHotend ( active_extruder ) < extrude_min_temp ) { <nl> + if ( thermalManager . tooColdToExtrude ( active_extruder ) ) { <nl> curr_e = dest_e ; / / Behave as if the move really took place , but ignore E part <nl> SERIAL_ECHO_START ; <nl> SERIAL_ECHOLNPGM ( MSG_ERR_COLD_EXTRUDE_STOP ) ; <nl> void plan_arc ( <nl> millis_t ms = millis ( ) ; <nl> if ( ELAPSED ( ms , nextMotorCheck ) ) { <nl> nextMotorCheck = ms + 2500UL ; / / Not a time critical function , so only check every 2 . 5s <nl> - if ( X_ENABLE_READ = = X_ENABLE_ON | | Y_ENABLE_READ = = Y_ENABLE_ON | | Z_ENABLE_READ = = Z_ENABLE_ON | | soft_pwm_bed > 0 <nl> + if ( X_ENABLE_READ = = X_ENABLE_ON | | Y_ENABLE_READ = = Y_ENABLE_ON | | Z_ENABLE_READ = = Z_ENABLE_ON | | thermalManager . soft_pwm_bed > 0 <nl> | | E0_ENABLE_READ = = E_ENABLE_ON / / If any of the drivers are enabled . . . <nl> # if EXTRUDERS > 1 <nl> | | E1_ENABLE_READ = = E_ENABLE_ON <nl> void plan_arc ( <nl> if ( ELAPSED ( millis ( ) , next_status_led_update_ms ) ) { <nl> next_status_led_update_ms + = 500 ; / / Update every 0 . 5s <nl> for ( int8_t cur_extruder = 0 ; cur_extruder < EXTRUDERS ; + + cur_extruder ) <nl> - max_temp = max ( max ( max_temp , degHotend ( cur_extruder ) ) , degTargetHotend ( cur_extruder ) ) ; <nl> + max_temp = max ( max ( max_temp , thermalManager . degHotend ( cur_extruder ) ) , thermalManager . degTargetHotend ( cur_extruder ) ) ; <nl> # if HAS_TEMP_BED <nl> - max_temp = max ( max ( max_temp , degTargetBed ( ) ) , degBed ( ) ) ; <nl> + max_temp = max ( max ( max_temp , thermalManager . degTargetBed ( ) ) , thermalManager . degBed ( ) ) ; <nl> # endif <nl> bool new_led = ( max_temp > 55 . 0 ) ? true : ( max_temp < 54 . 0 ) ? false : red_led ; <nl> if ( new_led ! = red_led ) { <nl> void idle ( <nl> bool no_stepper_sleep / * = false * / <nl> # endif <nl> ) { <nl> - manage_heater ( ) ; <nl> + thermalManager . manage_heater ( ) ; <nl> manage_inactivity ( <nl> # if ENABLED ( FILAMENTCHANGEENABLE ) <nl> no_stepper_sleep <nl> void manage_inactivity ( bool ignore_stepper_queue / * = false * / ) { <nl> <nl> # if ENABLED ( EXTRUDER_RUNOUT_PREVENT ) <nl> if ( ELAPSED ( ms , previous_cmd_ms + ( EXTRUDER_RUNOUT_SECONDS ) * 1000UL ) ) <nl> - if ( degHotend ( active_extruder ) > EXTRUDER_RUNOUT_MINTEMP ) { <nl> + if ( thermalManager . degHotend ( active_extruder ) > EXTRUDER_RUNOUT_MINTEMP ) { <nl> bool oldstatus ; <nl> switch ( active_extruder ) { <nl> case 0 : <nl> void kill ( const char * lcd_msg ) { <nl> # endif <nl> <nl> cli ( ) ; / / Stop interrupts <nl> - disable_all_heaters ( ) ; <nl> + thermalManager . disable_all_heaters ( ) ; <nl> disable_all_steppers ( ) ; <nl> <nl> # if HAS_POWER_SWITCH <nl> void kill ( const char * lcd_msg ) { <nl> # endif / / FAST_PWM_FAN <nl> <nl> void stop ( ) { <nl> - disable_all_heaters ( ) ; <nl> + thermalManager . disable_all_heaters ( ) ; <nl> if ( IsRunning ( ) ) { <nl> Running = false ; <nl> Stopped_gcode_LastN = gcode_LastN ; / / Save last g_code for restart <nl> mmm a / Marlin / cardreader . cpp <nl> ppp b / Marlin / cardreader . cpp <nl> void CardReader : : printingHasFinished ( ) { <nl> sdprinting = false ; <nl> if ( SD_FINISHED_STEPPERRELEASE ) <nl> enqueue_and_echo_commands_P ( PSTR ( SD_FINISHED_RELEASECOMMAND ) ) ; <nl> - autotempShutdown ( ) ; <nl> + thermalManager . autotempShutdown ( ) ; <nl> } <nl> } <nl> <nl> mmm a / Marlin / configuration_store . cpp <nl> ppp b / Marlin / configuration_store . cpp <nl> <nl> * 363 M301 L lpq_len ( int ) <nl> * <nl> * PIDTEMPBED : <nl> - * 365 M304 PID bedKp , bedKi , bedKd ( float x3 ) <nl> + * 365 M304 PID thermalManager . bedKp , thermalManager . bedKi , thermalManager . bedKd ( float x3 ) <nl> * <nl> * DOGLCD : <nl> * 377 M250 C lcd_contrast ( int ) <nl> void Config_StoreSettings ( ) { <nl> # endif / / ! PIDTEMP <nl> { <nl> dummy = DUMMY_PID_VALUE ; / / When read , will not change the existing value <nl> - EEPROM_WRITE_VAR ( i , dummy ) ; <nl> + EEPROM_WRITE_VAR ( i , dummy ) ; / / Kp <nl> dummy = 0 . 0f ; <nl> - for ( uint8_t q = 3 ; q - - ; ) EEPROM_WRITE_VAR ( i , dummy ) ; <nl> + for ( uint8_t q = 3 ; q - - ; ) EEPROM_WRITE_VAR ( i , dummy ) ; / / Ki , Kd , Kc <nl> } <nl> <nl> } / / Extruders Loop <nl> void Config_StoreSettings ( ) { <nl> EEPROM_WRITE_VAR ( i , lpq_len ) ; <nl> <nl> # if DISABLED ( PIDTEMPBED ) <nl> - float bedKp = DUMMY_PID_VALUE , bedKi = DUMMY_PID_VALUE , bedKd = DUMMY_PID_VALUE ; <nl> + dummy = DUMMY_PID_VALUE ; <nl> + for ( uint8_t q = 3 ; q - - ; ) EEPROM_WRITE_VAR ( i , dummy ) ; <nl> + # else <nl> + EEPROM_WRITE_VAR ( i , thermalManager . bedKp ) ; <nl> + EEPROM_WRITE_VAR ( i , thermalManager . bedKi ) ; <nl> + EEPROM_WRITE_VAR ( i , thermalManager . bedKd ) ; <nl> # endif <nl> <nl> - EEPROM_WRITE_VAR ( i , bedKp ) ; <nl> - EEPROM_WRITE_VAR ( i , bedKi ) ; <nl> - EEPROM_WRITE_VAR ( i , bedKd ) ; <nl> - <nl> # if DISABLED ( HAS_LCD_CONTRAST ) <nl> const int lcd_contrast = 32 ; <nl> # endif <nl> void Config_RetrieveSettings ( ) { <nl> # endif <nl> EEPROM_READ_VAR ( i , lpq_len ) ; <nl> <nl> - # if DISABLED ( PIDTEMPBED ) <nl> - float bedKp , bedKi , bedKd ; <nl> + # if ENABLED ( PIDTEMPBED ) <nl> + EEPROM_READ_VAR ( i , dummy ) ; / / bedKp <nl> + if ( dummy ! = DUMMY_PID_VALUE ) { <nl> + thermalManager . bedKp = dummy ; <nl> + EEPROM_READ_VAR ( i , thermalManager . bedKi ) ; <nl> + EEPROM_READ_VAR ( i , thermalManager . bedKd ) ; <nl> + } <nl> + # else <nl> + for ( uint8_t q = 3 ; q - - ; ) EEPROM_READ_VAR ( i , dummy ) ; / / bedKp , bedKi , bedKd <nl> # endif <nl> <nl> - EEPROM_READ_VAR ( i , dummy ) ; / / bedKp <nl> - if ( dummy ! = DUMMY_PID_VALUE ) { <nl> - bedKp = dummy ; UNUSED ( bedKp ) ; <nl> - EEPROM_READ_VAR ( i , bedKi ) ; <nl> - EEPROM_READ_VAR ( i , bedKd ) ; <nl> - } <nl> - else { <nl> - for ( uint8_t q = 2 ; q - - ; ) EEPROM_READ_VAR ( i , dummy ) ; / / bedKi , bedKd <nl> - } <nl> - <nl> # if DISABLED ( HAS_LCD_CONTRAST ) <nl> int lcd_contrast ; <nl> # endif <nl> void Config_RetrieveSettings ( ) { <nl> } <nl> <nl> calculate_volumetric_multipliers ( ) ; <nl> - / / Call updatePID ( similar to when we have processed M301 ) <nl> - updatePID ( ) ; <nl> + / / Call thermalManager . updatePID ( similar to when we have processed M301 ) <nl> + thermalManager . updatePID ( ) ; <nl> <nl> / / Report settings retrieved and length <nl> SERIAL_ECHO_START ; <nl> void Config_ResetDefault ( ) { <nl> # if ENABLED ( PID_ADD_EXTRUSION_RATE ) <nl> lpq_len = 20 ; / / default last - position - queue size <nl> # endif <nl> - / / call updatePID ( similar to when we have processed M301 ) <nl> - updatePID ( ) ; <nl> + / / call thermalManager . updatePID ( similar to when we have processed M301 ) <nl> + thermalManager . updatePID ( ) ; <nl> # endif / / PIDTEMP <nl> <nl> # if ENABLED ( PIDTEMPBED ) <nl> - bedKp = DEFAULT_bedKp ; <nl> - bedKi = scalePID_i ( DEFAULT_bedKi ) ; <nl> - bedKd = scalePID_d ( DEFAULT_bedKd ) ; <nl> + thermalManager . bedKp = DEFAULT_bedKp ; <nl> + thermalManager . bedKi = scalePID_i ( DEFAULT_bedKi ) ; <nl> + thermalManager . bedKd = scalePID_d ( DEFAULT_bedKd ) ; <nl> # endif <nl> <nl> # if ENABLED ( FWRETRACT ) <nl> void Config_PrintSettings ( bool forReplay ) { <nl> <nl> # if ENABLED ( PIDTEMPBED ) <nl> CONFIG_ECHO_START ; <nl> - SERIAL_ECHOPAIR ( " M304 P " , bedKp ) ; <nl> - SERIAL_ECHOPAIR ( " I " , unscalePID_i ( bedKi ) ) ; <nl> - SERIAL_ECHOPAIR ( " D " , unscalePID_d ( bedKd ) ) ; <nl> + SERIAL_ECHOPAIR ( " M304 P " , thermalManager . bedKp ) ; <nl> + SERIAL_ECHOPAIR ( " I " , unscalePID_i ( thermalManager . bedKi ) ) ; <nl> + SERIAL_ECHOPAIR ( " D " , unscalePID_d ( thermalManager . bedKd ) ) ; <nl> SERIAL_EOL ; <nl> # endif <nl> <nl> mmm a / Marlin / dogm_lcd_implementation . h <nl> ppp b / Marlin / dogm_lcd_implementation . h <nl> FORCE_INLINE void _draw_heater_status ( int x , int heater ) { <nl> const bool isBed = false ; <nl> # endif <nl> <nl> - _draw_centered_temp ( ( isBed ? degTargetBed ( ) : degTargetHotend ( heater ) ) + 0 . 5 , x , 7 ) ; <nl> + _draw_centered_temp ( ( isBed ? thermalManager . degTargetBed ( ) : thermalManager . degTargetHotend ( heater ) ) + 0 . 5 , x , 7 ) ; <nl> <nl> - _draw_centered_temp ( ( isBed ? degBed ( ) : degHotend ( heater ) ) + 0 . 5 , x , 28 ) ; <nl> + _draw_centered_temp ( ( isBed ? thermalManager . degBed ( ) : thermalManager . degHotend ( heater ) ) + 0 . 5 , x , 28 ) ; <nl> <nl> int h = isBed ? 7 : 8 , <nl> y = isBed ? 18 : 17 ; <nl> - if ( isBed ? isHeatingBed ( ) : isHeatingHotend ( heater ) ) { <nl> + if ( isBed ? thermalManager . isHeatingBed ( ) : thermalManager . isHeatingHotend ( heater ) ) { <nl> u8g . setColorIndex ( 0 ) ; / / white on black <nl> u8g . drawBox ( x + h , y , 2 , 2 ) ; <nl> u8g . setColorIndex ( 1 ) ; / / black on white <nl> mmm a / Marlin / endstops . cpp <nl> ppp b / Marlin / endstops . cpp <nl> void Endstops : : report_state ( ) { <nl> card . sdprinting = false ; <nl> card . closefile ( ) ; <nl> stepper . quick_stop ( ) ; <nl> - disable_all_heaters ( ) ; / / switch off all heaters . <nl> + thermalManager . disable_all_heaters ( ) ; / / switch off all heaters . <nl> } <nl> # endif <nl> } <nl> mmm a / Marlin / planner . cpp <nl> ppp b / Marlin / planner . cpp <nl> void Planner : : recalculate ( ) { <nl> static float oldt = 0 ; <nl> <nl> if ( ! autotemp_enabled ) return ; <nl> - if ( degTargetHotend0 ( ) + 2 < autotemp_min ) return ; / / probably temperature set to zero . <nl> + if ( thermalManager . degTargetHotend ( 0 ) + 2 < autotemp_min ) return ; / / probably temperature set to zero . <nl> <nl> float high = 0 . 0 ; <nl> for ( uint8_t b = block_buffer_tail ; b ! = block_buffer_head ; b = next_block_index ( b ) ) { <nl> void Planner : : recalculate ( ) { <nl> t + = ( AUTOTEMP_OLDWEIGHT ) * oldt ; <nl> } <nl> oldt = t ; <nl> - setTargetHotend0 ( t ) ; <nl> + thermalManager . setTargetHotend ( t , 0 ) ; <nl> } <nl> <nl> # endif / / AUTOTEMP <nl> void Planner : : check_axes_activity ( ) { <nl> / / The target position of the tool in absolute steps <nl> / / Calculate target position in absolute steps <nl> / / this should be done after the wait , because otherwise a M92 code within the gcode disrupts this calculation somehow <nl> - long target [ NUM_AXIS ] ; <nl> - target [ X_AXIS ] = lround ( x * axis_steps_per_unit [ X_AXIS ] ) ; <nl> - target [ Y_AXIS ] = lround ( y * axis_steps_per_unit [ Y_AXIS ] ) ; <nl> - target [ Z_AXIS ] = lround ( z * axis_steps_per_unit [ Z_AXIS ] ) ; <nl> - target [ E_AXIS ] = lround ( e * axis_steps_per_unit [ E_AXIS ] ) ; <nl> + long target [ NUM_AXIS ] = { <nl> + lround ( x * axis_steps_per_unit [ X_AXIS ] ) , <nl> + lround ( y * axis_steps_per_unit [ Y_AXIS ] ) , <nl> + lround ( z * axis_steps_per_unit [ Z_AXIS ] ) , <nl> + lround ( e * axis_steps_per_unit [ E_AXIS ] ) <nl> + } ; <nl> <nl> long dx = target [ X_AXIS ] - position [ X_AXIS ] , <nl> dy = target [ Y_AXIS ] - position [ Y_AXIS ] , <nl> void Planner : : check_axes_activity ( ) { <nl> <nl> # if ENABLED ( PREVENT_DANGEROUS_EXTRUDE ) <nl> if ( de ) { <nl> - if ( degHotend ( extruder ) < extrude_min_temp ) { <nl> + if ( thermalManager . tooColdToExtrude ( extruder ) ) { <nl> position [ E_AXIS ] = target [ E_AXIS ] ; / / Behave as if the move really took place , but ignore E part <nl> de = 0 ; / / no difference <nl> SERIAL_ECHO_START ; <nl> void Planner : : check_axes_activity ( ) { <nl> / / If the index has changed ( must have gone forward ) . . . <nl> if ( filwidth_delay_index1 ! = filwidth_delay_index2 ) { <nl> filwidth_e_count = 0 ; / / Reset the E movement counter <nl> - int8_t meas_sample = widthFil_to_size_ratio ( ) - 100 ; / / Subtract 100 to reduce magnitude - to store in a signed char <nl> + int8_t meas_sample = thermalManager . widthFil_to_size_ratio ( ) - 100 ; / / Subtract 100 to reduce magnitude - to store in a signed char <nl> do { <nl> filwidth_delay_index2 = ( filwidth_delay_index2 + 1 ) % MMD_CM ; / / The next unused slot <nl> measurement_delay [ filwidth_delay_index2 ] = meas_sample ; / / Store the measurement <nl> mmm a / Marlin / temperature . cpp <nl> ppp b / Marlin / temperature . cpp <nl> <nl> * / <nl> <nl> / * * <nl> - temperature . cpp - temperature control <nl> - Part of Marlin <nl> - <nl> - Copyright ( C ) 2011 Camiel Gubbels / Erik van der Zalm <nl> - <nl> - This program is free software : you can redistribute it and / or modify <nl> - it under the terms of the GNU General Public License as published by <nl> - the Free Software Foundation , either version 3 of the License , or <nl> - ( at your option ) any later version . <nl> - <nl> - This program is distributed in the hope that it will be useful , <nl> - but WITHOUT ANY WARRANTY ; without even the implied warranty of <nl> - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the <nl> - GNU General Public License for more details . <nl> - <nl> - You should have received a copy of the GNU General Public License <nl> - along with this program . If not , see < http : / / www . gnu . org / licenses / > . <nl> - * / <nl> + * temperature . cpp - temperature control <nl> + * / <nl> <nl> # include " Marlin . h " <nl> # include " ultralcd . h " <nl> <nl> # include " watchdog . h " <nl> # endif <nl> <nl> - / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = macros = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - <nl> # ifdef K1 / / Defined in Configuration . h in the PID settings <nl> # define K2 ( 1 . 0 - K1 ) <nl> # endif <nl> <nl> - # if ENABLED ( PIDTEMPBED ) | | ENABLED ( PIDTEMP ) <nl> - # define PID_dT ( ( OVERSAMPLENR * 12 . 0 ) / ( F_CPU / 64 . 0 / 256 . 0 ) ) <nl> - # endif <nl> - <nl> - / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = public variables = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - <nl> - int target_temperature [ 4 ] = { 0 } ; <nl> - int target_temperature_bed = 0 ; <nl> - int current_temperature_raw [ 4 ] = { 0 } ; <nl> - float current_temperature [ 4 ] = { 0 . 0 } ; <nl> - int current_temperature_bed_raw = 0 ; <nl> - float current_temperature_bed = 0 . 0 ; <nl> - # if ENABLED ( TEMP_SENSOR_1_AS_REDUNDANT ) <nl> - int redundant_temperature_raw = 0 ; <nl> - float redundant_temperature = 0 . 0 ; <nl> - # endif <nl> - <nl> - # if ENABLED ( PIDTEMPBED ) <nl> - float bedKp = DEFAULT_bedKp ; <nl> - float bedKi = ( DEFAULT_bedKi * PID_dT ) ; <nl> - float bedKd = ( DEFAULT_bedKd / PID_dT ) ; <nl> - # endif / / PIDTEMPBED <nl> - <nl> - # if ENABLED ( FAN_SOFT_PWM ) <nl> - unsigned char fanSpeedSoftPwm [ FAN_COUNT ] ; <nl> - # endif <nl> - <nl> - unsigned char soft_pwm_bed ; <nl> - <nl> - # if ENABLED ( BABYSTEPPING ) <nl> - volatile int babystepsTodo [ 3 ] = { 0 } ; <nl> - # endif <nl> - <nl> - # if ENABLED ( FILAMENT_WIDTH_SENSOR ) <nl> - int current_raw_filwidth = 0 ; / / Holds measured filament diameter - one extruder only <nl> - # endif <nl> - <nl> - # if ENABLED ( THERMAL_PROTECTION_HOTENDS ) | | ENABLED ( THERMAL_PROTECTION_BED ) <nl> - enum TRState { TRReset , TRInactive , TRFirstHeating , TRStable , TRRunaway } ; <nl> - void thermal_runaway_protection ( TRState * state , millis_t * timer , float temperature , float target_temperature , int heater_id , int period_seconds , int hysteresis_degc ) ; <nl> - # if ENABLED ( THERMAL_PROTECTION_HOTENDS ) <nl> - static TRState thermal_runaway_state_machine [ 4 ] = { TRReset , TRReset , TRReset , TRReset } ; <nl> - static millis_t thermal_runaway_timer [ 4 ] ; / / = { 0 , 0 , 0 , 0 } ; <nl> - # endif <nl> - # if ENABLED ( THERMAL_PROTECTION_BED ) & & TEMP_SENSOR_BED ! = 0 <nl> - static TRState thermal_runaway_bed_state_machine = TRReset ; <nl> - static millis_t thermal_runaway_bed_timer ; <nl> - # endif <nl> - # endif <nl> - <nl> - / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = private variables = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - <nl> - static volatile bool temp_meas_ready = false ; <nl> - <nl> - # if ENABLED ( PIDTEMP ) <nl> - / / static cannot be external : <nl> - static float temp_iState [ EXTRUDERS ] = { 0 } ; <nl> - static float temp_dState [ EXTRUDERS ] = { 0 } ; <nl> - static float pTerm [ EXTRUDERS ] ; <nl> - static float iTerm [ EXTRUDERS ] ; <nl> - static float dTerm [ EXTRUDERS ] ; <nl> - # if ENABLED ( PID_ADD_EXTRUSION_RATE ) <nl> - static float cTerm [ EXTRUDERS ] ; <nl> - static long last_position [ EXTRUDERS ] ; <nl> - static long lpq [ LPQ_MAX_LEN ] ; <nl> - static int lpq_ptr = 0 ; <nl> - # endif <nl> - / / int output ; <nl> - static float pid_error [ EXTRUDERS ] ; <nl> - static float temp_iState_min [ EXTRUDERS ] ; <nl> - static float temp_iState_max [ EXTRUDERS ] ; <nl> - static bool pid_reset [ EXTRUDERS ] ; <nl> - # endif / / PIDTEMP <nl> - # if ENABLED ( PIDTEMPBED ) <nl> - / / static cannot be external : <nl> - static float temp_iState_bed = { 0 } ; <nl> - static float temp_dState_bed = { 0 } ; <nl> - static float pTerm_bed ; <nl> - static float iTerm_bed ; <nl> - static float dTerm_bed ; <nl> - / / int output ; <nl> - static float pid_error_bed ; <nl> - static float temp_iState_min_bed ; <nl> - static float temp_iState_max_bed ; <nl> - # else / / PIDTEMPBED <nl> - static millis_t next_bed_check_ms ; <nl> - # endif / / PIDTEMPBED <nl> - static unsigned char soft_pwm [ EXTRUDERS ] ; <nl> - <nl> - # if ENABLED ( FAN_SOFT_PWM ) <nl> - static unsigned char soft_pwm_fan [ FAN_COUNT ] ; <nl> - # endif <nl> - # if HAS_AUTO_FAN <nl> - static millis_t next_auto_fan_check_ms ; <nl> - # endif <nl> - <nl> - # if ENABLED ( PIDTEMP ) <nl> - # if ENABLED ( PID_PARAMS_PER_EXTRUDER ) <nl> - float Kp [ EXTRUDERS ] = ARRAY_BY_EXTRUDERS1 ( DEFAULT_Kp ) ; <nl> - float Ki [ EXTRUDERS ] = ARRAY_BY_EXTRUDERS1 ( ( DEFAULT_Ki ) * ( PID_dT ) ) ; <nl> - float Kd [ EXTRUDERS ] = ARRAY_BY_EXTRUDERS1 ( ( DEFAULT_Kd ) / ( PID_dT ) ) ; <nl> - # if ENABLED ( PID_ADD_EXTRUSION_RATE ) <nl> - float Kc [ EXTRUDERS ] = ARRAY_BY_EXTRUDERS1 ( DEFAULT_Kc ) ; <nl> - # endif / / PID_ADD_EXTRUSION_RATE <nl> - # else / / PID_PARAMS_PER_EXTRUDER <nl> - float Kp = DEFAULT_Kp ; <nl> - float Ki = ( DEFAULT_Ki ) * ( PID_dT ) ; <nl> - float Kd = ( DEFAULT_Kd ) / ( PID_dT ) ; <nl> - # if ENABLED ( PID_ADD_EXTRUSION_RATE ) <nl> - float Kc = DEFAULT_Kc ; <nl> - # endif / / PID_ADD_EXTRUSION_RATE <nl> - # endif / / PID_PARAMS_PER_EXTRUDER <nl> - # endif / / PIDTEMP <nl> - <nl> - / / Init min and max temp with extreme values to prevent false errors during startup <nl> - static int minttemp_raw [ EXTRUDERS ] = ARRAY_BY_EXTRUDERS ( HEATER_0_RAW_LO_TEMP , HEATER_1_RAW_LO_TEMP , HEATER_2_RAW_LO_TEMP , HEATER_3_RAW_LO_TEMP ) ; <nl> - static int maxttemp_raw [ EXTRUDERS ] = ARRAY_BY_EXTRUDERS ( HEATER_0_RAW_HI_TEMP , HEATER_1_RAW_HI_TEMP , HEATER_2_RAW_HI_TEMP , HEATER_3_RAW_HI_TEMP ) ; <nl> - static int minttemp [ EXTRUDERS ] = { 0 } ; <nl> - static int maxttemp [ EXTRUDERS ] = ARRAY_BY_EXTRUDERS1 ( 16383 ) ; <nl> - # ifdef BED_MINTEMP <nl> - static int bed_minttemp_raw = HEATER_BED_RAW_LO_TEMP ; <nl> - # endif <nl> - # ifdef BED_MAXTEMP <nl> - static int bed_maxttemp_raw = HEATER_BED_RAW_HI_TEMP ; <nl> - # endif <nl> - <nl> # if ENABLED ( TEMP_SENSOR_1_AS_REDUNDANT ) <nl> static void * heater_ttbl_map [ 2 ] = { ( void * ) HEATER_0_TEMPTABLE , ( void * ) HEATER_1_TEMPTABLE } ; <nl> static uint8_t heater_ttbllen_map [ 2 ] = { HEATER_0_TEMPTABLE_LEN , HEATER_1_TEMPTABLE_LEN } ; <nl> static int maxttemp [ EXTRUDERS ] = ARRAY_BY_EXTRUDERS1 ( 16383 ) ; <nl> static uint8_t heater_ttbllen_map [ EXTRUDERS ] = ARRAY_BY_EXTRUDERS ( HEATER_0_TEMPTABLE_LEN , HEATER_1_TEMPTABLE_LEN , HEATER_2_TEMPTABLE_LEN , HEATER_3_TEMPTABLE_LEN ) ; <nl> # endif <nl> <nl> - static float analog2temp ( int raw , uint8_t e ) ; <nl> - static float analog2tempBed ( int raw ) ; <nl> - static void updateTemperaturesFromRawValues ( ) ; <nl> - <nl> - # if ENABLED ( THERMAL_PROTECTION_HOTENDS ) & & WATCH_TEMP_PERIOD > 0 <nl> - int watch_target_temp [ EXTRUDERS ] = { 0 } ; <nl> - millis_t watch_heater_next_ms [ EXTRUDERS ] = { 0 } ; <nl> - # endif <nl> - <nl> - # if ENABLED ( THERMAL_PROTECTION_BED ) & & WATCH_BED_TEMP_PERIOD > 0 <nl> - int watch_target_bed_temp = 0 ; <nl> - millis_t watch_bed_next_ms = 0 ; <nl> - # endif <nl> - <nl> - # ifndef SOFT_PWM_SCALE <nl> - # define SOFT_PWM_SCALE 0 <nl> - # endif <nl> - <nl> - # if ENABLED ( FILAMENT_WIDTH_SENSOR ) <nl> - static int meas_shift_index ; / / used to point to a delayed sample in buffer for filament width sensor <nl> - # endif <nl> - <nl> - # if ENABLED ( HEATER_0_USES_MAX6675 ) <nl> - static int read_max6675 ( ) ; <nl> - # endif <nl> - <nl> - / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = Functions = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + Temperature thermalManager ; <nl> <nl> # if HAS_PID_HEATING <nl> <nl> - void PID_autotune ( float temp , int extruder , int ncycles , bool set_result / * = false * / ) { <nl> + void Temperature : : PID_autotune ( float temp , int extruder , int ncycles , bool set_result / * = false * / ) { <nl> float input = 0 . 0 ; <nl> int cycles = 0 ; <nl> bool heating = true ; <nl> static void updateTemperaturesFromRawValues ( ) ; <nl> float max = 0 , min = 10000 ; <nl> <nl> # if HAS_AUTO_FAN <nl> - millis_t next_auto_fan_check_ms = temp_ms + 2500UL ; <nl> + next_auto_fan_check_ms = temp_ms + 2500UL ; <nl> # endif <nl> <nl> if ( false <nl> static void updateTemperaturesFromRawValues ( ) ; <nl> } <nl> } <nl> <nl> - # endif / / PIDTEMP <nl> + # endif / / HAS_PID_HEATING <nl> + <nl> + # if ENABLED ( PIDTEMP ) <nl> + <nl> + # if ENABLED ( PID_PARAMS_PER_EXTRUDER ) <nl> + <nl> + float Temperature : : Kp [ EXTRUDERS ] = ARRAY_BY_EXTRUDERS1 ( DEFAULT_Kp ) , <nl> + Temperature : : Ki [ EXTRUDERS ] = ARRAY_BY_EXTRUDERS1 ( ( DEFAULT_Ki ) * ( PID_dT ) ) , <nl> + Temperature : : Kd [ EXTRUDERS ] = ARRAY_BY_EXTRUDERS1 ( ( DEFAULT_Kd ) / ( PID_dT ) ) ; <nl> <nl> - void updatePID ( ) { <nl> + # if ENABLED ( PID_ADD_EXTRUSION_RATE ) <nl> + float Temperature : : Kc [ EXTRUDERS ] = ARRAY_BY_EXTRUDERS1 ( DEFAULT_Kc ) ; <nl> + # endif <nl> + <nl> + # else <nl> + <nl> + float Temperature : : Kp = DEFAULT_Kp , <nl> + Temperature : : Ki = ( DEFAULT_Ki ) * ( PID_dT ) , <nl> + Temperature : : Kd = ( DEFAULT_Kd ) / ( PID_dT ) ; <nl> + <nl> + # if ENABLED ( PID_ADD_EXTRUSION_RATE ) <nl> + float Temperature : : Kc = DEFAULT_Kc ; <nl> + # endif <nl> + <nl> + # endif <nl> + <nl> + # endif <nl> + <nl> + Temperature : : Temperature ( ) { } <nl> + <nl> + void Temperature : : updatePID ( ) { <nl> # if ENABLED ( PIDTEMP ) <nl> for ( int e = 0 ; e < EXTRUDERS ; e + + ) { <nl> temp_iState_max [ e ] = ( PID_INTEGRAL_DRIVE_MAX ) / PID_PARAM ( Ki , e ) ; <nl> void updatePID ( ) { <nl> # endif <nl> } <nl> <nl> - int getHeaterPower ( int heater ) { <nl> + int Temperature : : getHeaterPower ( int heater ) { <nl> return heater < 0 ? soft_pwm_bed : soft_pwm [ heater ] ; <nl> } <nl> <nl> # if HAS_AUTO_FAN <nl> <nl> - void setExtruderAutoFanState ( int pin , bool state ) { <nl> - unsigned char newFanSpeed = ( state ! = 0 ) ? EXTRUDER_AUTO_FAN_SPEED : 0 ; <nl> - / / this idiom allows both digital and PWM fan outputs ( see M42 handling ) . <nl> - digitalWrite ( pin , newFanSpeed ) ; <nl> - analogWrite ( pin , newFanSpeed ) ; <nl> - } <nl> - <nl> - void checkExtruderAutoFans ( ) { <nl> - uint8_t fanState = 0 ; <nl> - <nl> - / / which fan pins need to be turned on ? <nl> - # if HAS_AUTO_FAN_0 <nl> - if ( current_temperature [ 0 ] > EXTRUDER_AUTO_FAN_TEMPERATURE ) <nl> - fanState | = 1 ; <nl> - # endif <nl> - # if HAS_AUTO_FAN_1 <nl> - if ( current_temperature [ 1 ] > EXTRUDER_AUTO_FAN_TEMPERATURE ) { <nl> - if ( EXTRUDER_1_AUTO_FAN_PIN = = EXTRUDER_0_AUTO_FAN_PIN ) <nl> - fanState | = 1 ; <nl> - else <nl> - fanState | = 2 ; <nl> + void Temperature : : checkExtruderAutoFans ( ) { <nl> + const uint8_t fanPin [ ] = { EXTRUDER_0_AUTO_FAN_PIN , EXTRUDER_1_AUTO_FAN_PIN , EXTRUDER_2_AUTO_FAN_PIN , EXTRUDER_3_AUTO_FAN_PIN } ; <nl> + const int fanBit [ ] = { 0 , <nl> + EXTRUDER_1_AUTO_FAN_PIN = = EXTRUDER_0_AUTO_FAN_PIN ? 0 : 1 , <nl> + EXTRUDER_2_AUTO_FAN_PIN = = EXTRUDER_0_AUTO_FAN_PIN ? 0 : <nl> + EXTRUDER_2_AUTO_FAN_PIN = = EXTRUDER_1_AUTO_FAN_PIN ? 1 : 2 , <nl> + EXTRUDER_3_AUTO_FAN_PIN = = EXTRUDER_0_AUTO_FAN_PIN ? 0 : <nl> + EXTRUDER_3_AUTO_FAN_PIN = = EXTRUDER_1_AUTO_FAN_PIN ? 1 : <nl> + EXTRUDER_3_AUTO_FAN_PIN = = EXTRUDER_2_AUTO_FAN_PIN ? 2 : 3 <nl> + } ; <nl> + uint8_t fanState = 0 ; <nl> + for ( int f = 0 ; f < = 3 ; f + + ) { <nl> + if ( current_temperature [ f ] > EXTRUDER_AUTO_FAN_TEMPERATURE ) <nl> + SBI ( fanState , fanBit [ f ] ) ; <nl> } <nl> - # endif <nl> - # if HAS_AUTO_FAN_2 <nl> - if ( current_temperature [ 2 ] > EXTRUDER_AUTO_FAN_TEMPERATURE ) { <nl> - if ( EXTRUDER_2_AUTO_FAN_PIN = = EXTRUDER_0_AUTO_FAN_PIN ) <nl> - fanState | = 1 ; <nl> - else if ( EXTRUDER_2_AUTO_FAN_PIN = = EXTRUDER_1_AUTO_FAN_PIN ) <nl> - fanState | = 2 ; <nl> - else <nl> - fanState | = 4 ; <nl> - } <nl> - # endif <nl> - # if HAS_AUTO_FAN_3 <nl> - if ( current_temperature [ 3 ] > EXTRUDER_AUTO_FAN_TEMPERATURE ) { <nl> - if ( EXTRUDER_3_AUTO_FAN_PIN = = EXTRUDER_0_AUTO_FAN_PIN ) <nl> - fanState | = 1 ; <nl> - else if ( EXTRUDER_3_AUTO_FAN_PIN = = EXTRUDER_1_AUTO_FAN_PIN ) <nl> - fanState | = 2 ; <nl> - else if ( EXTRUDER_3_AUTO_FAN_PIN = = EXTRUDER_2_AUTO_FAN_PIN ) <nl> - fanState | = 4 ; <nl> - else <nl> - fanState | = 8 ; <nl> + for ( int f = 0 ; f < = 3 ; f + + ) { <nl> + unsigned char newFanSpeed = TEST ( fanState , f ) ? EXTRUDER_AUTO_FAN_SPEED : 0 ; <nl> + / / this idiom allows both digital and PWM fan outputs ( see M42 handling ) . <nl> + digitalWrite ( fanPin [ f ] , newFanSpeed ) ; <nl> + analogWrite ( fanPin [ f ] , newFanSpeed ) ; <nl> } <nl> - # endif <nl> - <nl> - / / update extruder auto fan states <nl> - # if HAS_AUTO_FAN_0 <nl> - setExtruderAutoFanState ( EXTRUDER_0_AUTO_FAN_PIN , ( fanState & 1 ) ! = 0 ) ; <nl> - # endif <nl> - # if HAS_AUTO_FAN_1 <nl> - if ( EXTRUDER_1_AUTO_FAN_PIN ! = EXTRUDER_0_AUTO_FAN_PIN ) <nl> - setExtruderAutoFanState ( EXTRUDER_1_AUTO_FAN_PIN , ( fanState & 2 ) ! = 0 ) ; <nl> - # endif <nl> - # if HAS_AUTO_FAN_2 <nl> - if ( EXTRUDER_2_AUTO_FAN_PIN ! = EXTRUDER_0_AUTO_FAN_PIN <nl> - & & EXTRUDER_2_AUTO_FAN_PIN ! = EXTRUDER_1_AUTO_FAN_PIN ) <nl> - setExtruderAutoFanState ( EXTRUDER_2_AUTO_FAN_PIN , ( fanState & 4 ) ! = 0 ) ; <nl> - # endif <nl> - # if HAS_AUTO_FAN_3 <nl> - if ( EXTRUDER_3_AUTO_FAN_PIN ! = EXTRUDER_0_AUTO_FAN_PIN <nl> - & & EXTRUDER_3_AUTO_FAN_PIN ! = EXTRUDER_1_AUTO_FAN_PIN <nl> - & & EXTRUDER_3_AUTO_FAN_PIN ! = EXTRUDER_2_AUTO_FAN_PIN ) <nl> - setExtruderAutoFanState ( EXTRUDER_3_AUTO_FAN_PIN , ( fanState & 8 ) ! = 0 ) ; <nl> - # endif <nl> - } <nl> + } <nl> <nl> # endif / / HAS_AUTO_FAN <nl> <nl> / / <nl> / / Temperature Error Handlers <nl> / / <nl> - inline void _temp_error ( int e , const char * serial_msg , const char * lcd_msg ) { <nl> + void Temperature : : _temp_error ( int e , const char * serial_msg , const char * lcd_msg ) { <nl> static bool killed = false ; <nl> if ( IsRunning ( ) ) { <nl> SERIAL_ERROR_START ; <nl> inline void _temp_error ( int e , const char * serial_msg , const char * lcd_msg ) { <nl> # endif <nl> } <nl> <nl> - void max_temp_error ( uint8_t e ) { <nl> + void Temperature : : max_temp_error ( uint8_t e ) { <nl> _temp_error ( e , PSTR ( MSG_T_MAXTEMP ) , PSTR ( MSG_ERR_MAXTEMP ) ) ; <nl> } <nl> - void min_temp_error ( uint8_t e ) { <nl> + void Temperature : : min_temp_error ( uint8_t e ) { <nl> _temp_error ( e , PSTR ( MSG_T_MINTEMP ) , PSTR ( MSG_ERR_MINTEMP ) ) ; <nl> } <nl> <nl> - float get_pid_output ( int e ) { <nl> + float Temperature : : get_pid_output ( int e ) { <nl> float pid_output ; <nl> # if ENABLED ( PIDTEMP ) <nl> # if DISABLED ( PID_OPENLOOP ) <nl> float get_pid_output ( int e ) { <nl> } <nl> <nl> # if ENABLED ( PIDTEMPBED ) <nl> - float get_pid_output_bed ( ) { <nl> + float Temperature : : get_pid_output_bed ( ) { <nl> float pid_output ; <nl> # if DISABLED ( PID_OPENLOOP ) <nl> pid_error_bed = target_temperature_bed - current_temperature_bed ; <nl> float get_pid_output ( int e ) { <nl> * - Apply filament width to the extrusion rate ( may move ) <nl> * - Update the heated bed PID output value <nl> * / <nl> - void manage_heater ( ) { <nl> + void Temperature : : manage_heater ( ) { <nl> <nl> if ( ! temp_meas_ready ) return ; <nl> <nl> void manage_heater ( ) { <nl> <nl> # if TEMP_SENSOR_BED ! = 0 <nl> <nl> - # if ENABLED ( THERMAL_PROTECTION_BED ) <nl> + # if HAS_THERMALLY_PROTECTED_BED <nl> thermal_runaway_protection ( & thermal_runaway_bed_state_machine , & thermal_runaway_bed_timer , current_temperature_bed , target_temperature_bed , - 1 , THERMAL_PROTECTION_BED_PERIOD , THERMAL_PROTECTION_BED_HYSTERESIS ) ; <nl> # endif <nl> <nl> void manage_heater ( ) { <nl> } <nl> <nl> # define PGM_RD_W ( x ) ( short ) pgm_read_word ( & x ) <nl> + <nl> / / Derived from RepRap FiveD extruder : : getTemperature ( ) <nl> / / For hot end temperature measurement . <nl> - static float analog2temp ( int raw , uint8_t e ) { <nl> + float Temperature : : analog2temp ( int raw , uint8_t e ) { <nl> # if ENABLED ( TEMP_SENSOR_1_AS_REDUNDANT ) <nl> if ( e > EXTRUDERS ) <nl> # else <nl> static float analog2temp ( int raw , uint8_t e ) { <nl> <nl> / / Derived from RepRap FiveD extruder : : getTemperature ( ) <nl> / / For bed temperature measurement . <nl> - static float analog2tempBed ( int raw ) { <nl> + float Temperature : : analog2tempBed ( int raw ) { <nl> # if ENABLED ( BED_USES_THERMISTOR ) <nl> float celsius = 0 ; <nl> byte i ; <nl> static float analog2tempBed ( int raw ) { <nl> # endif <nl> } <nl> <nl> - / * Called to get the raw values into the the actual temperatures . The raw values are created in interrupt context , <nl> - and this function is called from normal context as it is too slow to run in interrupts and will block the stepper routine otherwise * / <nl> - static void updateTemperaturesFromRawValues ( ) { <nl> + / * * <nl> + * Get the raw values into the actual temperatures . <nl> + * The raw values are created in interrupt context , <nl> + * and this function is called from normal context <nl> + * as it would block the stepper routine . <nl> + * / <nl> + void Temperature : : updateTemperaturesFromRawValues ( ) { <nl> # if ENABLED ( HEATER_0_USES_MAX6675 ) <nl> current_temperature_raw [ 0 ] = read_max6675 ( ) ; <nl> # endif <nl> for ( uint8_t e = 0 ; e < EXTRUDERS ; e + + ) { <nl> - current_temperature [ e ] = analog2temp ( current_temperature_raw [ e ] , e ) ; <nl> + current_temperature [ e ] = Temperature : : analog2temp ( current_temperature_raw [ e ] , e ) ; <nl> } <nl> - current_temperature_bed = analog2tempBed ( current_temperature_bed_raw ) ; <nl> + current_temperature_bed = Temperature : : analog2tempBed ( current_temperature_bed_raw ) ; <nl> # if ENABLED ( TEMP_SENSOR_1_AS_REDUNDANT ) <nl> - redundant_temperature = analog2temp ( redundant_temperature_raw , 1 ) ; <nl> + redundant_temperature = Temperature : : analog2temp ( redundant_temperature_raw , 1 ) ; <nl> # endif <nl> # if ENABLED ( FILAMENT_WIDTH_SENSOR ) <nl> filament_width_meas = analog2widthFil ( ) ; <nl> static void updateTemperaturesFromRawValues ( ) { <nl> # if ENABLED ( FILAMENT_WIDTH_SENSOR ) <nl> <nl> / / Convert raw Filament Width to millimeters <nl> - float analog2widthFil ( ) { <nl> + float Temperature : : analog2widthFil ( ) { <nl> return current_raw_filwidth / 16383 . 0 * 5 . 0 ; <nl> / / return current_raw_filwidth ; <nl> } <nl> <nl> / / Convert raw Filament Width to a ratio <nl> - int widthFil_to_size_ratio ( ) { <nl> + int Temperature : : widthFil_to_size_ratio ( ) { <nl> float temp = filament_width_meas ; <nl> if ( temp < MEASURED_LOWER_LIMIT ) temp = filament_width_nominal ; / / assume sensor cut out <nl> else NOMORE ( temp , MEASURED_UPPER_LIMIT ) ; <nl> static void updateTemperaturesFromRawValues ( ) { <nl> * Initialize the temperature manager <nl> * The manager is implemented by periodic calls to manage_heater ( ) <nl> * / <nl> - void tp_init ( ) { <nl> + void Temperature : : init ( ) { <nl> + <nl> # if MB ( RUMBA ) & & ( ( TEMP_SENSOR_0 = = - 1 ) | | ( TEMP_SENSOR_1 = = - 1 ) | | ( TEMP_SENSOR_2 = = - 1 ) | | ( TEMP_SENSOR_BED = = - 1 ) ) <nl> / / disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector <nl> MCUCR = _BV ( JTD ) ; <nl> void tp_init ( ) { <nl> * their target temperature by a configurable margin . <nl> * This is called when the temperature is set . ( M104 , M109 ) <nl> * / <nl> - void start_watching_heater ( int e ) { <nl> + void Temperature : : start_watching_heater ( int e ) { <nl> if ( degHotend ( e ) < degTargetHotend ( e ) - ( WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1 ) ) { <nl> watch_target_temp [ e ] = degHotend ( e ) + WATCH_TEMP_INCREASE ; <nl> watch_heater_next_ms [ e ] = millis ( ) + ( WATCH_TEMP_PERIOD ) * 1000UL ; <nl> void tp_init ( ) { <nl> * their target temperature by a configurable margin . <nl> * This is called when the temperature is set . ( M140 , M190 ) <nl> * / <nl> - void start_watching_bed ( ) { <nl> + void Temperature : : start_watching_bed ( ) { <nl> if ( degBed ( ) < degTargetBed ( ) - ( WATCH_BED_TEMP_INCREASE + TEMP_BED_HYSTERESIS + 1 ) ) { <nl> watch_target_bed_temp = degBed ( ) + WATCH_BED_TEMP_INCREASE ; <nl> watch_bed_next_ms = millis ( ) + ( WATCH_BED_TEMP_PERIOD ) * 1000UL ; <nl> void tp_init ( ) { <nl> } <nl> # endif <nl> <nl> - # if ENABLED ( THERMAL_PROTECTION_HOTENDS ) | | ENABLED ( THERMAL_PROTECTION_BED ) <nl> + # if ENABLED ( THERMAL_PROTECTION_HOTENDS ) | | HAS_THERMALLY_PROTECTED_BED <nl> <nl> - void thermal_runaway_protection ( TRState * state , millis_t * timer , float temperature , float target_temperature , int heater_id , int period_seconds , int hysteresis_degc ) { <nl> + void Temperature : : thermal_runaway_protection ( TRState * state , millis_t * timer , float temperature , float target_temperature , int heater_id , int period_seconds , int hysteresis_degc ) { <nl> <nl> static float tr_target_temperature [ EXTRUDERS + 1 ] = { 0 . 0 } ; <nl> <nl> void tp_init ( ) { <nl> <nl> # endif / / THERMAL_PROTECTION_HOTENDS | | THERMAL_PROTECTION_BED <nl> <nl> - void disable_all_heaters ( ) { <nl> + void Temperature : : disable_all_heaters ( ) { <nl> for ( int i = 0 ; i < EXTRUDERS ; i + + ) setTargetHotend ( 0 , i ) ; <nl> setTargetBed ( 0 ) ; <nl> <nl> void disable_all_heaters ( ) { <nl> # define MAX6675_DISCARD_BITS 3 <nl> # endif <nl> <nl> - static millis_t next_max6675_ms = 0 ; <nl> + int Temperature : : read_max6675 ( ) { <nl> <nl> - static int read_max6675 ( ) { <nl> + static millis_t next_max6675_ms = 0 ; <nl> <nl> millis_t ms = millis ( ) ; <nl> <nl> enum TempState { <nl> StartupDelay / / Startup , delay initial temp reading a tiny bit so the hardware can settle <nl> } ; <nl> <nl> - static unsigned long raw_temp_value [ 4 ] = { 0 } ; <nl> - static unsigned long raw_temp_bed_value = 0 ; <nl> - <nl> - static void set_current_temp_raw ( ) { <nl> + / * * <nl> + * Get raw temperatures <nl> + * / <nl> + void Temperature : : set_current_temp_raw ( ) { <nl> # if HAS_TEMP_0 & & DISABLED ( HEATER_0_USES_MAX6675 ) <nl> current_temperature_raw [ 0 ] = raw_temp_value [ 0 ] ; <nl> # endif <nl> static void set_current_temp_raw ( ) { <nl> * - Check new temperature values for MIN / MAX errors <nl> * - Step the babysteps value for each axis towards 0 <nl> * / <nl> - ISR ( TIMER0_COMPB_vect ) { <nl> + ISR ( TIMER0_COMPB_vect ) { thermalManager . isr ( ) ; } <nl> + <nl> + void Temperature : : isr ( ) { <nl> <nl> static unsigned char temp_count = 0 ; <nl> static TempState temp_state = StartupDelay ; <nl> ISR ( TIMER0_COMPB_vect ) { <nl> } <nl> # endif / / BABYSTEPPING <nl> } <nl> - <nl> - # if ENABLED ( PIDTEMP ) <nl> - / / Apply the scale factors to the PID values <nl> - float scalePID_i ( float i ) { return i * PID_dT ; } <nl> - float unscalePID_i ( float i ) { return i / PID_dT ; } <nl> - float scalePID_d ( float d ) { return d / PID_dT ; } <nl> - float unscalePID_d ( float d ) { return d * PID_dT ; } <nl> - # endif / / PIDTEMP <nl> mmm a / Marlin / temperature . h <nl> ppp b / Marlin / temperature . h <nl> <nl> * / <nl> <nl> / * * <nl> - temperature . h - temperature controller <nl> - Part of Marlin <nl> - <nl> - Copyright ( c ) 2011 Erik van der Zalm <nl> - <nl> - Grbl is free software : you can redistribute it and / or modify <nl> - it under the terms of the GNU General Public License as published by <nl> - the Free Software Foundation , either version 3 of the License , or <nl> - ( at your option ) any later version . <nl> - <nl> - Grbl is distributed in the hope that it will be useful , <nl> - but WITHOUT ANY WARRANTY ; without even the implied warranty of <nl> - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the <nl> - GNU General Public License for more details . <nl> - <nl> - You should have received a copy of the GNU General Public License <nl> - along with Grbl . If not , see < http : / / www . gnu . org / licenses / > . <nl> - * / <nl> + * temperature . h - temperature controller <nl> + * / <nl> <nl> # ifndef TEMPERATURE_H <nl> # define TEMPERATURE_H <nl> <nl> # include " Marlin . h " <nl> # include " planner . h " <nl> + <nl> # if ENABLED ( PID_ADD_EXTRUSION_RATE ) <nl> # include " stepper . h " <nl> # endif <nl> <nl> - / / public functions <nl> - void tp_init ( ) ; / / initialize the heating <nl> - void manage_heater ( ) ; / / it is critical that this is called periodically . <nl> + # ifndef SOFT_PWM_SCALE <nl> + # define SOFT_PWM_SCALE 0 <nl> + # endif <nl> <nl> - # if ENABLED ( FILAMENT_WIDTH_SENSOR ) <nl> - / / For converting raw Filament Width to milimeters <nl> - float analog2widthFil ( ) ; <nl> + class Temperature { <nl> <nl> - / / For converting raw Filament Width to an extrusion ratio <nl> - int widthFil_to_size_ratio ( ) ; <nl> - # endif <nl> + public : <nl> <nl> - / / low level conversion routines <nl> - / / do not use these routines and variables outside of temperature . cpp <nl> - extern int target_temperature [ 4 ] ; <nl> - extern float current_temperature [ 4 ] ; <nl> - # if ENABLED ( SHOW_TEMP_ADC_VALUES ) <nl> - extern int current_temperature_raw [ 4 ] ; <nl> - extern int current_temperature_bed_raw ; <nl> - # endif <nl> - extern int target_temperature_bed ; <nl> - extern float current_temperature_bed ; <nl> - # if ENABLED ( TEMP_SENSOR_1_AS_REDUNDANT ) <nl> - extern float redundant_temperature ; <nl> - # endif <nl> + int current_temperature_raw [ EXTRUDERS ] = { 0 } ; <nl> + float current_temperature [ EXTRUDERS ] = { 0 . 0 } ; <nl> + int target_temperature [ EXTRUDERS ] = { 0 } ; <nl> <nl> - # if HAS_CONTROLLERFAN <nl> - extern unsigned char soft_pwm_bed ; <nl> - # endif <nl> + int current_temperature_bed_raw = 0 ; <nl> + float current_temperature_bed = 0 . 0 ; <nl> + int target_temperature_bed = 0 ; <nl> <nl> - # if ENABLED ( FAN_SOFT_PWM ) <nl> - extern unsigned char fanSpeedSoftPwm [ FAN_COUNT ] ; <nl> - # endif <nl> + # if ENABLED ( TEMP_SENSOR_1_AS_REDUNDANT ) <nl> + float redundant_temperature = 0 . 0 ; <nl> + # endif <nl> <nl> - # if ENABLED ( PIDTEMP ) <nl> + unsigned char soft_pwm_bed ; <nl> <nl> - # if ENABLED ( PID_PARAMS_PER_EXTRUDER ) <nl> - extern float Kp [ EXTRUDERS ] , Ki [ EXTRUDERS ] , Kd [ EXTRUDERS ] ; / / one param per extruder <nl> - # if ENABLED ( PID_ADD_EXTRUSION_RATE ) <nl> - extern float Kc [ EXTRUDERS ] ; <nl> + # if ENABLED ( FAN_SOFT_PWM ) <nl> + unsigned char fanSpeedSoftPwm [ FAN_COUNT ] ; <nl> # endif <nl> - # define PID_PARAM ( param , e ) param [ e ] / / use macro to point to array value <nl> - # else <nl> - extern float Kp , Ki , Kd ; / / one param per extruder - saves 20 or 36 bytes of ram ( inc array pointer ) <nl> - # if ENABLED ( PID_ADD_EXTRUSION_RATE ) <nl> - extern float Kc ; <nl> + <nl> + # if ENABLED ( PIDTEMP ) | | ENABLED ( PIDTEMPBED ) <nl> + # define PID_dT ( ( OVERSAMPLENR * 12 . 0 ) / ( F_CPU / 64 . 0 / 256 . 0 ) ) <nl> # endif <nl> - # define PID_PARAM ( param , e ) param / / use macro to point directly to value <nl> - # endif / / PID_PARAMS_PER_EXTRUDER <nl> - float scalePID_i ( float i ) ; <nl> - float scalePID_d ( float d ) ; <nl> - float unscalePID_i ( float i ) ; <nl> - float unscalePID_d ( float d ) ; <nl> <nl> - # endif <nl> + # if ENABLED ( PIDTEMP ) <nl> <nl> - # if ENABLED ( PIDTEMPBED ) <nl> - extern float bedKp , bedKi , bedKd ; <nl> - # endif <nl> + # if ENABLED ( PID_PARAMS_PER_EXTRUDER ) <nl> <nl> - # if ENABLED ( BABYSTEPPING ) <nl> - extern volatile int babystepsTodo [ 3 ] ; <nl> - # endif <nl> + static float Kp [ EXTRUDERS ] , Ki [ EXTRUDERS ] , Kd [ EXTRUDERS ] ; <nl> + # if ENABLED ( PID_ADD_EXTRUSION_RATE ) <nl> + float Kc [ EXTRUDERS ] ; <nl> + # endif <nl> + # define PID_PARAM ( param , e ) Temperature : : param [ e ] <nl> <nl> - / / high level conversion routines , for use outside of temperature . cpp <nl> - / / inline so that there is no performance decrease . <nl> - / / deg = degreeCelsius <nl> + # else <nl> <nl> - FORCE_INLINE float degHotend ( uint8_t extruder ) { return current_temperature [ extruder ] ; } <nl> - FORCE_INLINE float degBed ( ) { return current_temperature_bed ; } <nl> + static float Kp , Ki , Kd ; <nl> + # if ENABLED ( PID_ADD_EXTRUSION_RATE ) <nl> + static float Kc ; <nl> + # endif <nl> + # define PID_PARAM ( param , e ) Temperature : : param <nl> <nl> - # if ENABLED ( SHOW_TEMP_ADC_VALUES ) <nl> - FORCE_INLINE float rawHotendTemp ( uint8_t extruder ) { return current_temperature_raw [ extruder ] ; } <nl> - FORCE_INLINE float rawBedTemp ( ) { return current_temperature_bed_raw ; } <nl> - # endif <nl> + # endif / / PID_PARAMS_PER_EXTRUDER <nl> <nl> - FORCE_INLINE float degTargetHotend ( uint8_t extruder ) { return target_temperature [ extruder ] ; } <nl> - FORCE_INLINE float degTargetBed ( ) { return target_temperature_bed ; } <nl> + / / Apply the scale factors to the PID values <nl> + # define scalePID_i ( i ) ( ( i ) * PID_dT ) <nl> + # define unscalePID_i ( i ) ( ( i ) / PID_dT ) <nl> + # define scalePID_d ( d ) ( ( d ) / PID_dT ) <nl> + # define unscalePID_d ( d ) ( ( d ) * PID_dT ) <nl> <nl> - # if ENABLED ( THERMAL_PROTECTION_HOTENDS ) & & WATCH_TEMP_PERIOD > 0 <nl> - void start_watching_heater ( int e = 0 ) ; <nl> - # endif <nl> + # endif <nl> <nl> - # if ENABLED ( THERMAL_PROTECTION_BED ) & & WATCH_BED_TEMP_PERIOD > 0 <nl> - void start_watching_bed ( ) ; <nl> - # endif <nl> + # if ENABLED ( PIDTEMPBED ) <nl> + float bedKp = DEFAULT_bedKp , <nl> + bedKi = ( ( DEFAULT_bedKi ) * PID_dT ) , <nl> + bedKd = ( ( DEFAULT_bedKd ) / PID_dT ) ; <nl> + # endif <nl> <nl> - FORCE_INLINE void setTargetHotend ( const float & celsius , uint8_t extruder ) { <nl> - target_temperature [ extruder ] = celsius ; <nl> - # if ENABLED ( THERMAL_PROTECTION_HOTENDS ) & & WATCH_TEMP_PERIOD > 0 <nl> - start_watching_heater ( extruder ) ; <nl> - # endif <nl> - } <nl> - FORCE_INLINE void setTargetBed ( const float & celsius ) { <nl> - target_temperature_bed = celsius ; <nl> - # if ENABLED ( THERMAL_PROTECTION_BED ) & & WATCH_BED_TEMP_PERIOD > 0 <nl> - start_watching_bed ( ) ; <nl> - # endif <nl> - } <nl> - <nl> - FORCE_INLINE bool isHeatingHotend ( uint8_t extruder ) { return target_temperature [ extruder ] > current_temperature [ extruder ] ; } <nl> - FORCE_INLINE bool isHeatingBed ( ) { return target_temperature_bed > current_temperature_bed ; } <nl> - <nl> - FORCE_INLINE bool isCoolingHotend ( uint8_t extruder ) { return target_temperature [ extruder ] < current_temperature [ extruder ] ; } <nl> - FORCE_INLINE bool isCoolingBed ( ) { return target_temperature_bed < current_temperature_bed ; } <nl> - <nl> - # define HOTEND_ROUTINES ( NR ) \ <nl> - FORCE_INLINE float degHotend # # NR ( ) { return degHotend ( NR ) ; } \ <nl> - FORCE_INLINE float degTargetHotend # # NR ( ) { return degTargetHotend ( NR ) ; } \ <nl> - FORCE_INLINE void setTargetHotend # # NR ( const float c ) { setTargetHotend ( c , NR ) ; } \ <nl> - FORCE_INLINE bool isHeatingHotend # # NR ( ) { return isHeatingHotend ( NR ) ; } \ <nl> - FORCE_INLINE bool isCoolingHotend # # NR ( ) { return isCoolingHotend ( NR ) ; } <nl> - HOTEND_ROUTINES ( 0 ) ; <nl> - # if EXTRUDERS > 1 <nl> - HOTEND_ROUTINES ( 1 ) ; <nl> - # else <nl> - # define setTargetHotend1 ( c ) do { } while ( 0 ) <nl> - # endif <nl> - # if EXTRUDERS > 2 <nl> - HOTEND_ROUTINES ( 2 ) ; <nl> - # else <nl> - # define setTargetHotend2 ( c ) do { } while ( 0 ) <nl> - # endif <nl> - # if EXTRUDERS > 3 <nl> - HOTEND_ROUTINES ( 3 ) ; <nl> - # else <nl> - # define setTargetHotend3 ( c ) do { } while ( 0 ) <nl> - # endif <nl> + # if ENABLED ( BABYSTEPPING ) <nl> + volatile int babystepsTodo [ 3 ] = { 0 } ; <nl> + # endif <nl> <nl> - int getHeaterPower ( int heater ) ; <nl> - void disable_all_heaters ( ) ; <nl> - void updatePID ( ) ; <nl> + # if ENABLED ( THERMAL_PROTECTION_HOTENDS ) & & WATCH_TEMP_PERIOD > 0 <nl> + int watch_target_temp [ EXTRUDERS ] = { 0 } ; <nl> + millis_t watch_heater_next_ms [ EXTRUDERS ] = { 0 } ; <nl> + # endif <nl> <nl> - # if ENABLED ( PIDTEMP ) <nl> - void PID_autotune ( float temp , int extruder , int ncycles , bool set_result = false ) ; <nl> - # endif <nl> + # if ENABLED ( THERMAL_PROTECTION_HOTENDS ) & & WATCH_BED_TEMP_PERIOD > 0 <nl> + int watch_target_bed_temp = 0 ; <nl> + millis_t watch_bed_next_ms = 0 ; <nl> + # endif <nl> + <nl> + # if ENABLED ( PREVENT_DANGEROUS_EXTRUDE ) <nl> + float extrude_min_temp = EXTRUDE_MINTEMP ; <nl> + FORCE_INLINE bool tooColdToExtrude ( uint8_t e ) { return degHotend ( e ) < extrude_min_temp ; } <nl> + # else <nl> + FORCE_INLINE bool tooColdToExtrude ( uint8_t e ) { UNUSED ( e ) ; return false ; } <nl> + # endif <nl> + <nl> + private : <nl> + <nl> + # if ENABLED ( TEMP_SENSOR_1_AS_REDUNDANT ) <nl> + int redundant_temperature_raw = 0 ; <nl> + float redundant_temperature = 0 . 0 ; <nl> + # endif <nl> + <nl> + volatile bool temp_meas_ready = false ; <nl> + <nl> + # if ENABLED ( PIDTEMP ) <nl> + float temp_iState [ EXTRUDERS ] = { 0 } ; <nl> + float temp_dState [ EXTRUDERS ] = { 0 } ; <nl> + float pTerm [ EXTRUDERS ] ; <nl> + float iTerm [ EXTRUDERS ] ; <nl> + float dTerm [ EXTRUDERS ] ; <nl> + <nl> + # if ENABLED ( PID_ADD_EXTRUSION_RATE ) <nl> + float cTerm [ EXTRUDERS ] ; <nl> + long last_position [ EXTRUDERS ] ; <nl> + long lpq [ LPQ_MAX_LEN ] ; <nl> + int lpq_ptr = 0 ; <nl> + # endif <nl> + <nl> + float pid_error [ EXTRUDERS ] ; <nl> + float temp_iState_min [ EXTRUDERS ] ; <nl> + float temp_iState_max [ EXTRUDERS ] ; <nl> + bool pid_reset [ EXTRUDERS ] ; <nl> + # endif <nl> + <nl> + # if ENABLED ( PIDTEMPBED ) <nl> + float temp_iState_bed = { 0 } ; <nl> + float temp_dState_bed = { 0 } ; <nl> + float pTerm_bed ; <nl> + float iTerm_bed ; <nl> + float dTerm_bed ; <nl> + float pid_error_bed ; <nl> + float temp_iState_min_bed ; <nl> + float temp_iState_max_bed ; <nl> + # else <nl> + millis_t next_bed_check_ms ; <nl> + # endif <nl> <nl> - void setExtruderAutoFanState ( int pin , bool state ) ; <nl> - void checkExtruderAutoFans ( ) ; <nl> + unsigned long raw_temp_value [ 4 ] = { 0 } ; <nl> + unsigned long raw_temp_bed_value = 0 ; <nl> + <nl> + / / Init min and max temp with extreme values to prevent false errors during startup <nl> + int minttemp_raw [ EXTRUDERS ] = ARRAY_BY_EXTRUDERS ( HEATER_0_RAW_LO_TEMP , HEATER_1_RAW_LO_TEMP , HEATER_2_RAW_LO_TEMP , HEATER_3_RAW_LO_TEMP ) ; <nl> + int maxttemp_raw [ EXTRUDERS ] = ARRAY_BY_EXTRUDERS ( HEATER_0_RAW_HI_TEMP , HEATER_1_RAW_HI_TEMP , HEATER_2_RAW_HI_TEMP , HEATER_3_RAW_HI_TEMP ) ; <nl> + int minttemp [ EXTRUDERS ] = { 0 } ; <nl> + int maxttemp [ EXTRUDERS ] = ARRAY_BY_EXTRUDERS1 ( 16383 ) ; <nl> + <nl> + # ifdef BED_MINTEMP <nl> + int bed_minttemp_raw = HEATER_BED_RAW_LO_TEMP ; <nl> + # endif <nl> + <nl> + # ifdef BED_MAXTEMP <nl> + int bed_maxttemp_raw = HEATER_BED_RAW_HI_TEMP ; <nl> + # endif <nl> + <nl> + # if ENABLED ( FILAMENT_WIDTH_SENSOR ) <nl> + int meas_shift_index ; / / Index of a delayed sample in buffer <nl> + # endif <nl> + <nl> + # if HAS_AUTO_FAN <nl> + millis_t next_auto_fan_check_ms ; <nl> + # endif <nl> + <nl> + unsigned char soft_pwm [ EXTRUDERS ] ; <nl> + <nl> + # if ENABLED ( FAN_SOFT_PWM ) <nl> + unsigned char soft_pwm_fan [ FAN_COUNT ] ; <nl> + # endif <nl> <nl> - FORCE_INLINE void autotempShutdown ( ) { <nl> - # if ENABLED ( AUTOTEMP ) <nl> - if ( planner . autotemp_enabled ) { <nl> - planner . autotemp_enabled = false ; <nl> - if ( degTargetHotend ( active_extruder ) > planner . autotemp_min ) <nl> - setTargetHotend ( 0 , active_extruder ) ; <nl> + # if ENABLED ( FILAMENT_WIDTH_SENSOR ) <nl> + int current_raw_filwidth = 0 ; / / Holds measured filament diameter - one extruder only <nl> + # endif <nl> + <nl> + public : <nl> + <nl> + / * * <nl> + * Static ( class ) methods <nl> + * / <nl> + static float analog2temp ( int raw , uint8_t e ) ; <nl> + static float analog2tempBed ( int raw ) ; <nl> + <nl> + / * * <nl> + * Instance Methods <nl> + * / <nl> + <nl> + Temperature ( ) ; <nl> + <nl> + void init ( ) ; <nl> + <nl> + / * * <nl> + * Called from the Temperature ISR <nl> + * / <nl> + void isr ( ) ; <nl> + <nl> + / * * <nl> + * Call periodically to manage heaters <nl> + * / <nl> + void manage_heater ( ) ; <nl> + <nl> + # if ENABLED ( FILAMENT_WIDTH_SENSOR ) <nl> + float analog2widthFil ( ) ; / / Convert raw Filament Width to millimeters <nl> + int widthFil_to_size_ratio ( ) ; / / Convert raw Filament Width to an extrusion ratio <nl> + # endif <nl> + <nl> + <nl> + / / high level conversion routines , for use outside of temperature . cpp <nl> + / / inline so that there is no performance decrease . <nl> + / / deg = degreeCelsius <nl> + <nl> + FORCE_INLINE float degHotend ( uint8_t extruder ) { return current_temperature [ extruder ] ; } <nl> + FORCE_INLINE float degBed ( ) { return current_temperature_bed ; } <nl> + <nl> + # if ENABLED ( SHOW_TEMP_ADC_VALUES ) <nl> + FORCE_INLINE float rawHotendTemp ( uint8_t extruder ) { return current_temperature_raw [ extruder ] ; } <nl> + FORCE_INLINE float rawBedTemp ( ) { return current_temperature_bed_raw ; } <nl> + # endif <nl> + <nl> + FORCE_INLINE float degTargetHotend ( uint8_t extruder ) { return target_temperature [ extruder ] ; } <nl> + FORCE_INLINE float degTargetBed ( ) { return target_temperature_bed ; } <nl> + <nl> + # if ENABLED ( THERMAL_PROTECTION_HOTENDS ) & & WATCH_TEMP_PERIOD > 0 <nl> + void start_watching_heater ( int e = 0 ) ; <nl> + # endif <nl> + <nl> + # if ENABLED ( THERMAL_PROTECTION_BED ) & & WATCH_BED_TEMP_PERIOD > 0 <nl> + void start_watching_bed ( ) ; <nl> + # endif <nl> + <nl> + FORCE_INLINE void setTargetHotend ( const float & celsius , uint8_t extruder ) { <nl> + target_temperature [ extruder ] = celsius ; <nl> + # if ENABLED ( THERMAL_PROTECTION_HOTENDS ) & & WATCH_TEMP_PERIOD > 0 <nl> + start_watching_heater ( extruder ) ; <nl> + # endif <nl> + } <nl> + <nl> + FORCE_INLINE void setTargetBed ( const float & celsius ) { <nl> + target_temperature_bed = celsius ; <nl> + # if ENABLED ( THERMAL_PROTECTION_BED ) & & WATCH_BED_TEMP_PERIOD > 0 <nl> + start_watching_bed ( ) ; <nl> + # endif <nl> } <nl> - # endif <nl> - } <nl> + <nl> + FORCE_INLINE bool isHeatingHotend ( uint8_t extruder ) { return target_temperature [ extruder ] > current_temperature [ extruder ] ; } <nl> + FORCE_INLINE bool isHeatingBed ( ) { return target_temperature_bed > current_temperature_bed ; } <nl> + <nl> + FORCE_INLINE bool isCoolingHotend ( uint8_t extruder ) { return target_temperature [ extruder ] < current_temperature [ extruder ] ; } <nl> + FORCE_INLINE bool isCoolingBed ( ) { return target_temperature_bed < current_temperature_bed ; } <nl> + <nl> + / * * <nl> + * The software PWM power for a heater <nl> + * / <nl> + int getHeaterPower ( int heater ) ; <nl> + <nl> + / * * <nl> + * Switch off all heaters , set all target temperatures to 0 <nl> + * / <nl> + void disable_all_heaters ( ) ; <nl> + <nl> + / * * <nl> + * Perform auto - tuning for hotend or bed in response to M303 <nl> + * / <nl> + # if HAS_PID_HEATING <nl> + void PID_autotune ( float temp , int extruder , int ncycles , bool set_result = false ) ; <nl> + # endif <nl> + <nl> + / * * <nl> + * Update the temp manager when PID values change <nl> + * / <nl> + void updatePID ( ) ; <nl> + <nl> + FORCE_INLINE void autotempShutdown ( ) { <nl> + # if ENABLED ( AUTOTEMP ) <nl> + if ( planner . autotemp_enabled ) { <nl> + planner . autotemp_enabled = false ; <nl> + if ( degTargetHotend ( active_extruder ) > planner . autotemp_min ) <nl> + setTargetHotend ( 0 , active_extruder ) ; <nl> + } <nl> + # endif <nl> + } <nl> + <nl> + private : <nl> + <nl> + void set_current_temp_raw ( ) ; <nl> + <nl> + void updateTemperaturesFromRawValues ( ) ; <nl> + <nl> + # if ENABLED ( HEATER_0_USES_MAX6675 ) <nl> + int read_max6675 ( ) ; <nl> + # endif <nl> + <nl> + void setExtruderAutoFanState ( int pin , bool state ) ; <nl> + void checkExtruderAutoFans ( ) ; <nl> + <nl> + float get_pid_output ( int e ) ; <nl> + <nl> + # if ENABLED ( PIDTEMPBED ) <nl> + float get_pid_output_bed ( ) ; <nl> + # endif <nl> + <nl> + void _temp_error ( int e , const char * serial_msg , const char * lcd_msg ) ; <nl> + void min_temp_error ( uint8_t e ) ; <nl> + void max_temp_error ( uint8_t e ) ; <nl> + <nl> + # if ENABLED ( THERMAL_PROTECTION_HOTENDS ) | | HAS_THERMALLY_PROTECTED_BED <nl> + <nl> + typedef enum TRState { TRReset , TRInactive , TRFirstHeating , TRStable , TRRunaway } TRstate ; <nl> + <nl> + void thermal_runaway_protection ( TRState * state , millis_t * timer , float temperature , float target_temperature , int heater_id , int period_seconds , int hysteresis_degc ) ; <nl> + <nl> + # if ENABLED ( THERMAL_PROTECTION_HOTENDS ) <nl> + TRState thermal_runaway_state_machine [ EXTRUDERS ] = { TRReset } ; <nl> + millis_t thermal_runaway_timer [ EXTRUDERS ] = { 0 } ; <nl> + # endif <nl> + <nl> + # if HAS_THERMALLY_PROTECTED_BED <nl> + TRState thermal_runaway_bed_state_machine = TRReset ; <nl> + millis_t thermal_runaway_bed_timer ; <nl> + # endif <nl> + <nl> + # endif / / THERMAL_PROTECTION <nl> + <nl> + } ; <nl> + <nl> + extern Temperature thermalManager ; <nl> <nl> # endif / / TEMPERATURE_H <nl> mmm a / Marlin / ultralcd . cpp <nl> ppp b / Marlin / ultralcd . cpp <nl> inline void line_to_current ( AxisEnum axis ) { <nl> stepper . quick_stop ( ) ; <nl> card . sdprinting = false ; <nl> card . closefile ( ) ; <nl> - autotempShutdown ( ) ; <nl> + thermalManager . autotempShutdown ( ) ; <nl> cancel_heatup = true ; <nl> lcd_setstatus ( MSG_PRINT_ABORTED , true ) ; <nl> } <nl> void lcd_set_home_offsets ( ) { <nl> * / <nl> # if ENABLED ( THERMAL_PROTECTION_HOTENDS ) & & WATCH_TEMP_PERIOD > 0 <nl> # if TEMP_SENSOR_0 ! = 0 <nl> - void watch_temp_callback_E0 ( ) { start_watching_heater ( 0 ) ; } <nl> + void watch_temp_callback_E0 ( ) { thermalManager . start_watching_heater ( 0 ) ; } <nl> # endif <nl> # if EXTRUDERS > 1 & & TEMP_SENSOR_1 ! = 0 <nl> - void watch_temp_callback_E1 ( ) { start_watching_heater ( 1 ) ; } <nl> + void watch_temp_callback_E1 ( ) { thermalManager . start_watching_heater ( 1 ) ; } <nl> # endif / / EXTRUDERS > 1 <nl> # if EXTRUDERS > 2 & & TEMP_SENSOR_2 ! = 0 <nl> - void watch_temp_callback_E2 ( ) { start_watching_heater ( 2 ) ; } <nl> + void watch_temp_callback_E2 ( ) { thermalManager . start_watching_heater ( 2 ) ; } <nl> # endif / / EXTRUDERS > 2 <nl> # if EXTRUDERS > 3 & & TEMP_SENSOR_3 ! = 0 <nl> - void watch_temp_callback_E3 ( ) { start_watching_heater ( 3 ) ; } <nl> + void watch_temp_callback_E3 ( ) { thermalManager . start_watching_heater ( 3 ) ; } <nl> # endif / / EXTRUDERS > 3 <nl> # else <nl> # if TEMP_SENSOR_0 ! = 0 <nl> void lcd_set_home_offsets ( ) { <nl> <nl> # if ENABLED ( THERMAL_PROTECTION_BED ) & & WATCH_BED_TEMP_PERIOD > 0 <nl> # if TEMP_SENSOR_BED ! = 0 <nl> - void watch_temp_callback_bed ( ) { start_watching_bed ( ) ; } <nl> + void watch_temp_callback_bed ( ) { thermalManager . start_watching_bed ( ) ; } <nl> # endif <nl> # else <nl> # if TEMP_SENSOR_BED ! = 0 <nl> static void lcd_tune_menu ( ) { <nl> / / <nl> # if EXTRUDERS = = 1 <nl> # if TEMP_SENSOR_0 ! = 0 <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( int3 , MSG_NOZZLE , & target_temperature [ 0 ] , 0 , HEATER_0_MAXTEMP - 15 , watch_temp_callback_E0 ) ; <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( int3 , MSG_NOZZLE , & thermalManager . target_temperature [ 0 ] , 0 , HEATER_0_MAXTEMP - 15 , watch_temp_callback_E0 ) ; <nl> # endif <nl> # else / / EXTRUDERS > 1 <nl> # if TEMP_SENSOR_0 ! = 0 <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( int3 , MSG_NOZZLE MSG_N1 , & target_temperature [ 0 ] , 0 , HEATER_0_MAXTEMP - 15 , watch_temp_callback_E0 ) ; <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( int3 , MSG_NOZZLE MSG_N1 , & thermalManager . target_temperature [ 0 ] , 0 , HEATER_0_MAXTEMP - 15 , watch_temp_callback_E0 ) ; <nl> # endif <nl> # if TEMP_SENSOR_1 ! = 0 <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( int3 , MSG_NOZZLE MSG_N2 , & target_temperature [ 1 ] , 0 , HEATER_1_MAXTEMP - 15 , watch_temp_callback_E1 ) ; <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( int3 , MSG_NOZZLE MSG_N2 , & thermalManager . target_temperature [ 1 ] , 0 , HEATER_1_MAXTEMP - 15 , watch_temp_callback_E1 ) ; <nl> # endif <nl> # if EXTRUDERS > 2 <nl> # if TEMP_SENSOR_2 ! = 0 <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( int3 , MSG_NOZZLE MSG_N3 , & target_temperature [ 2 ] , 0 , HEATER_2_MAXTEMP - 15 , watch_temp_callback_E2 ) ; <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( int3 , MSG_NOZZLE MSG_N3 , & thermalManager . target_temperature [ 2 ] , 0 , HEATER_2_MAXTEMP - 15 , watch_temp_callback_E2 ) ; <nl> # endif <nl> # if EXTRUDERS > 3 <nl> # if TEMP_SENSOR_3 ! = 0 <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( int3 , MSG_NOZZLE MSG_N4 , & target_temperature [ 3 ] , 0 , HEATER_3_MAXTEMP - 15 , watch_temp_callback_E3 ) ; <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( int3 , MSG_NOZZLE MSG_N4 , & thermalManager . target_temperature [ 3 ] , 0 , HEATER_3_MAXTEMP - 15 , watch_temp_callback_E3 ) ; <nl> # endif <nl> # endif / / EXTRUDERS > 3 <nl> # endif / / EXTRUDERS > 2 <nl> static void lcd_tune_menu ( ) { <nl> / / Bed : <nl> / / <nl> # if TEMP_SENSOR_BED ! = 0 <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( int3 , MSG_BED , & target_temperature_bed , 0 , BED_MAXTEMP - 15 , watch_temp_callback_bed ) ; <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( int3 , MSG_BED , & thermalManager . target_temperature_bed , 0 , BED_MAXTEMP - 15 , watch_temp_callback_bed ) ; <nl> # endif <nl> <nl> / / <nl> static void lcd_tune_menu ( ) { <nl> * <nl> * / <nl> void _lcd_preheat ( int endnum , const float temph , const float tempb , const int fan ) { <nl> - if ( temph > 0 ) setTargetHotend ( temph , endnum ) ; <nl> + if ( temph > 0 ) thermalManager . setTargetHotend ( temph , endnum ) ; <nl> # if TEMP_SENSOR_BED ! = 0 <nl> - setTargetBed ( tempb ) ; <nl> + thermalManager . setTargetBed ( tempb ) ; <nl> # else <nl> UNUSED ( tempb ) ; <nl> # endif <nl> void _lcd_preheat ( int endnum , const float temph , const float tempb , const int fa <nl> <nl> void lcd_preheat_pla0123 ( ) { <nl> # if EXTRUDERS > 1 <nl> - setTargetHotend0 ( plaPreheatHotendTemp ) ; <nl> - setTargetHotend1 ( plaPreheatHotendTemp ) ; <nl> - setTargetHotend2 ( plaPreheatHotendTemp ) ; <nl> + thermalManager . setTargetHotend ( plaPreheatHotendTemp , 1 ) ; <nl> + # if EXTRUDERS > 2 <nl> + thermalManager . setTargetHotend ( plaPreheatHotendTemp , 2 ) ; <nl> + # if EXTRUDERS > 3 <nl> + thermalManager . setTargetHotend ( plaPreheatHotendTemp , 3 ) ; <nl> + # endif <nl> + # endif <nl> # endif <nl> - _lcd_preheat ( EXTRUDERS - 1 , plaPreheatHotendTemp , plaPreheatHPBTemp , plaPreheatFanSpeed ) ; <nl> + lcd_preheat_pla0 ( ) ; <nl> } <nl> void lcd_preheat_abs0123 ( ) { <nl> # if EXTRUDERS > 1 <nl> - setTargetHotend0 ( absPreheatHotendTemp ) ; <nl> - setTargetHotend1 ( absPreheatHotendTemp ) ; <nl> - setTargetHotend2 ( absPreheatHotendTemp ) ; <nl> + thermalManager . setTargetHotend ( absPreheatHotendTemp , 1 ) ; <nl> + # if EXTRUDERS > 2 <nl> + thermalManager . setTargetHotend ( absPreheatHotendTemp , 2 ) ; <nl> + # if EXTRUDERS > 3 <nl> + thermalManager . setTargetHotend ( absPreheatHotendTemp , 3 ) ; <nl> + # endif <nl> + # endif <nl> # endif <nl> - _lcd_preheat ( EXTRUDERS - 1 , absPreheatHotendTemp , absPreheatHPBTemp , absPreheatFanSpeed ) ; <nl> + lcd_preheat_abs0 ( ) ; <nl> } <nl> <nl> # endif / / EXTRUDERS > 1 <nl> void lcd_cooldown ( ) { <nl> # if FAN_COUNT > 0 <nl> for ( uint8_t i = 0 ; i < FAN_COUNT ; i + + ) fanSpeeds [ i ] = 0 ; <nl> # endif <nl> - disable_all_heaters ( ) ; <nl> + thermalManager . disable_all_heaters ( ) ; <nl> lcd_return_to_status ( ) ; <nl> } <nl> <nl> static void lcd_control_menu ( ) { <nl> UNUSED ( e ) ; <nl> # endif <nl> PID_PARAM ( Ki , e ) = scalePID_i ( raw_Ki ) ; <nl> - updatePID ( ) ; <nl> + thermalManager . updatePID ( ) ; <nl> } <nl> void copy_and_scalePID_d ( int e ) { <nl> # if DISABLED ( PID_PARAMS_PER_EXTRUDER ) <nl> UNUSED ( e ) ; <nl> # endif <nl> PID_PARAM ( Kd , e ) = scalePID_d ( raw_Kd ) ; <nl> - updatePID ( ) ; <nl> + thermalManager . updatePID ( ) ; <nl> } <nl> # define _PIDTEMP_BASE_FUNCTIONS ( eindex ) \ <nl> void copy_and_scalePID_i_E # # eindex ( ) { copy_and_scalePID_i ( eindex ) ; } \ <nl> static void lcd_control_temperature_menu ( ) { <nl> / / <nl> # if EXTRUDERS = = 1 <nl> # if TEMP_SENSOR_0 ! = 0 <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( int3 , MSG_NOZZLE , & target_temperature [ 0 ] , 0 , HEATER_0_MAXTEMP - 15 , watch_temp_callback_E0 ) ; <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( int3 , MSG_NOZZLE , & thermalManager . target_temperature [ 0 ] , 0 , HEATER_0_MAXTEMP - 15 , watch_temp_callback_E0 ) ; <nl> # endif <nl> # else / / EXTRUDERS > 1 <nl> # if TEMP_SENSOR_0 ! = 0 <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( int3 , MSG_NOZZLE MSG_N1 , & target_temperature [ 0 ] , 0 , HEATER_0_MAXTEMP - 15 , watch_temp_callback_E0 ) ; <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( int3 , MSG_NOZZLE MSG_N1 , & thermalManager . target_temperature [ 0 ] , 0 , HEATER_0_MAXTEMP - 15 , watch_temp_callback_E0 ) ; <nl> # endif <nl> # if TEMP_SENSOR_1 ! = 0 <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( int3 , MSG_NOZZLE MSG_N2 , & target_temperature [ 1 ] , 0 , HEATER_1_MAXTEMP - 15 , watch_temp_callback_E1 ) ; <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( int3 , MSG_NOZZLE MSG_N2 , & thermalManager . target_temperature [ 1 ] , 0 , HEATER_1_MAXTEMP - 15 , watch_temp_callback_E1 ) ; <nl> # endif <nl> # if EXTRUDERS > 2 <nl> # if TEMP_SENSOR_2 ! = 0 <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( int3 , MSG_NOZZLE MSG_N3 , & target_temperature [ 2 ] , 0 , HEATER_2_MAXTEMP - 15 , watch_temp_callback_E2 ) ; <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( int3 , MSG_NOZZLE MSG_N3 , & thermalManager . target_temperature [ 2 ] , 0 , HEATER_2_MAXTEMP - 15 , watch_temp_callback_E2 ) ; <nl> # endif <nl> # if EXTRUDERS > 3 <nl> # if TEMP_SENSOR_3 ! = 0 <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( int3 , MSG_NOZZLE MSG_N4 , & target_temperature [ 3 ] , 0 , HEATER_3_MAXTEMP - 15 , watch_temp_callback_E3 ) ; <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( int3 , MSG_NOZZLE MSG_N4 , & thermalManager . target_temperature [ 3 ] , 0 , HEATER_3_MAXTEMP - 15 , watch_temp_callback_E3 ) ; <nl> # endif <nl> # endif / / EXTRUDERS > 3 <nl> # endif / / EXTRUDERS > 2 <nl> static void lcd_control_temperature_menu ( ) { <nl> / / Bed : <nl> / / <nl> # if TEMP_SENSOR_BED ! = 0 <nl> - MENU_MULTIPLIER_ITEM_EDIT ( int3 , MSG_BED , & target_temperature_bed , 0 , BED_MAXTEMP - 15 ) ; <nl> + MENU_MULTIPLIER_ITEM_EDIT ( int3 , MSG_BED , & thermalManager . target_temperature_bed , 0 , BED_MAXTEMP - 15 ) ; <nl> # endif <nl> <nl> / / <nl> mmm a / Marlin / ultralcd_implementation_hitachi_HD44780 . h <nl> ppp b / Marlin / ultralcd_implementation_hitachi_HD44780 . h <nl> static void lcd_implementation_status_screen ( ) { <nl> / / <nl> / / Hotend 0 Temperature <nl> / / <nl> - LCD_TEMP_ONLY ( degHotend ( 0 ) , degTargetHotend ( 0 ) ) ; <nl> + LCD_TEMP_ONLY ( thermalManager . degHotend ( 0 ) , thermalManager . degTargetHotend ( 0 ) ) ; <nl> <nl> / / <nl> / / Hotend 1 or Bed Temperature <nl> static void lcd_implementation_status_screen ( ) { <nl> lcd . setCursor ( 8 , 0 ) ; <nl> # if EXTRUDERS > 1 <nl> lcd . print ( LCD_STR_THERMOMETER [ 0 ] ) ; <nl> - LCD_TEMP_ONLY ( degHotend ( 1 ) , degTargetHotend ( 1 ) ) ; <nl> + LCD_TEMP_ONLY ( thermalManager . degHotend ( 1 ) , thermalManager . degTargetHotend ( 1 ) ) ; <nl> # else <nl> lcd . print ( LCD_STR_BEDTEMP [ 0 ] ) ; <nl> - LCD_TEMP_ONLY ( degBed ( ) , degTargetBed ( ) ) ; <nl> + LCD_TEMP_ONLY ( thermalManager . degBed ( ) , thermalManager . degTargetBed ( ) ) ; <nl> # endif <nl> <nl> # endif / / EXTRUDERS > 1 | | TEMP_SENSOR_BED ! = 0 <nl> static void lcd_implementation_status_screen ( ) { <nl> / / <nl> / / Hotend 0 Temperature <nl> / / <nl> - LCD_TEMP ( degHotend ( 0 ) , degTargetHotend ( 0 ) , LCD_STR_THERMOMETER [ 0 ] ) ; <nl> + LCD_TEMP ( thermalManager . degHotend ( 0 ) , thermalManager . degTargetHotend ( 0 ) , LCD_STR_THERMOMETER [ 0 ] ) ; <nl> <nl> / / <nl> / / Hotend 1 or Bed Temperature <nl> static void lcd_implementation_status_screen ( ) { <nl> # if EXTRUDERS > 1 | | TEMP_SENSOR_BED ! = 0 <nl> lcd . setCursor ( 10 , 0 ) ; <nl> # if EXTRUDERS > 1 <nl> - LCD_TEMP ( degHotend ( 1 ) , degTargetHotend ( 1 ) , LCD_STR_THERMOMETER [ 0 ] ) ; <nl> + LCD_TEMP ( thermalManager . degHotend ( 1 ) , thermalManager . degTargetHotend ( 1 ) , LCD_STR_THERMOMETER [ 0 ] ) ; <nl> # else <nl> - LCD_TEMP ( degBed ( ) , degTargetBed ( ) , LCD_STR_BEDTEMP [ 0 ] ) ; <nl> + LCD_TEMP ( thermalManager . degBed ( ) , thermalManager . degTargetBed ( ) , LCD_STR_BEDTEMP [ 0 ] ) ; <nl> # endif <nl> <nl> # endif / / EXTRUDERS > 1 | | TEMP_SENSOR_BED ! = 0 <nl> static void lcd_implementation_status_screen ( ) { <nl> / / If we both have a 2nd extruder and a heated bed , <nl> / / show the heated bed temp on the left , <nl> / / since the first line is filled with extruder temps <nl> - LCD_TEMP ( degBed ( ) , degTargetBed ( ) , LCD_STR_BEDTEMP [ 0 ] ) ; <nl> + LCD_TEMP ( thermalManager . degBed ( ) , thermalManager . degTargetBed ( ) , LCD_STR_BEDTEMP [ 0 ] ) ; <nl> <nl> # else <nl> / / Before homing the axis letters are blinking ' X ' < - > ' ? ' . <nl> void lcd_implementation_drawedit ( const char * pstr , const char * value = NULL ) { <nl> static uint8_t ledsprev = 0 ; <nl> uint8_t leds = 0 ; <nl> <nl> - if ( target_temperature_bed > 0 ) leds | = LED_A ; <nl> + if ( thermalManager . degTargetBed ( ) > 0 ) leds | = LED_A ; <nl> <nl> - if ( target_temperature [ 0 ] > 0 ) leds | = LED_B ; <nl> + if ( thermalManager . degTargetHotend ( 0 ) > 0 ) leds | = LED_B ; <nl> <nl> # if FAN_COUNT > 0 <nl> if ( 0 <nl> void lcd_implementation_drawedit ( const char * pstr , const char * value = NULL ) { <nl> # endif / / FAN_COUNT > 0 <nl> <nl> # if EXTRUDERS > 1 <nl> - if ( target_temperature [ 1 ] > 0 ) leds | = LED_C ; <nl> + if ( thermalManager . degTargetHotend ( 1 ) > 0 ) leds | = LED_C ; <nl> # endif <nl> <nl> if ( leds ! = ledsprev ) { <nl> | Temperature singleton class | MarlinFirmware/Marlin | 084f6b5b448cb9f67297dca40541127ea260f552 | 2016-05-05T02:42:12Z |
mmm a / src / ruby / lib / grpc / generic / active_call . rb <nl> ppp b / src / ruby / lib / grpc / generic / active_call . rb <nl> def server_streamer ( req , metadata : { } ) <nl> def bidi_streamer ( requests , metadata : { } , & blk ) <nl> raise_error_if_already_executed <nl> # Metadata might have already been sent if this is an operation view <nl> - merge_metadata_and_send_if_not_already_sent ( metadata ) <nl> + begin <nl> + merge_metadata_and_send_if_not_already_sent ( metadata ) <nl> + rescue GRPC : : Core : : CallError = > e <nl> + batch_result = @ call . run_batch ( RECV_STATUS_ON_CLIENT = > nil ) <nl> + set_input_stream_done <nl> + set_output_stream_done <nl> + attach_status_results_and_complete_call ( batch_result ) <nl> + raise e <nl> + rescue = > e <nl> + set_input_stream_done <nl> + set_output_stream_done <nl> + raise e <nl> + end <nl> + <nl> bd = BidiCall . new ( @ call , <nl> @ marshal , <nl> @ unmarshal , <nl> mmm a / src / ruby / spec / generic / client_stub_spec . rb <nl> ppp b / src / ruby / spec / generic / client_stub_spec . rb <nl> def run_op_view_metadata_test ( run_start_call_first ) <nl> th . join <nl> end <nl> <nl> - # TODO : add test for metadata - related ArgumentError in a bidi call once <nl> - # issue mentioned in https : / / github . com / grpc / grpc / issues / 10526 is fixed <nl> + it ' should raise ArgumentError if metadata contains invalid values ' do <nl> + @ metadata . merge ! ( k3 : 3 ) <nl> + stub = GRPC : : ClientStub . new ( @ host , : this_channel_is_insecure ) <nl> + expect do <nl> + get_responses ( stub ) . collect { | r | r } <nl> + end . to raise_error ( ArgumentError , <nl> + / Header values must be of type string or array / ) <nl> + end <nl> + <nl> + it ' terminates if the call fails to start ' do <nl> + # don ' t start the server <nl> + stub = GRPC : : ClientStub . new ( @ host , : this_channel_is_insecure ) <nl> + expect do <nl> + get_responses ( stub , deadline : from_relative_time ( 0 ) ) . collect { | r | r } <nl> + end . to raise_error ( GRPC : : BadStatus ) <nl> + end <nl> <nl> it ' should send metadata to the server ok ' do <nl> th = run_bidi_streamer_echo_ping_pong ( @ sent_msgs , @ pass , true , <nl> def run_op_view_metadata_test ( run_start_call_first ) <nl> end <nl> <nl> describe ' without a call operation ' do <nl> - def get_responses ( stub ) <nl> + def get_responses ( stub , deadline : nil ) <nl> e = stub . bidi_streamer ( @ method , @ sent_msgs , noop , noop , <nl> - metadata : @ metadata ) <nl> + metadata : @ metadata , deadline : deadline ) <nl> expect ( e ) . to be_a ( Enumerator ) <nl> e <nl> end <nl> def get_responses ( stub ) <nl> after ( : each ) do <nl> @ op . wait # make sure wait doesn ' t hang <nl> end <nl> - def get_responses ( stub , run_start_call_first : false ) <nl> + def get_responses ( stub , run_start_call_first : false , deadline : nil ) <nl> @ op = stub . bidi_streamer ( @ method , @ sent_msgs , noop , noop , <nl> return_op : true , <nl> - metadata : @ metadata ) <nl> + metadata : @ metadata , deadline : deadline ) <nl> expect ( @ op ) . to be_a ( GRPC : : ActiveCall : : Operation ) <nl> @ op . start_call if run_start_call_first <nl> e = @ op . execute <nl> | properly finish bidi calls when there is an initial error | grpc/grpc | cd22f11905dacc72f08b0255c1cf73d0cea4c7c2 | 2017-07-28T00:54:59Z |
mmm a / lstm / lstmtrainer . cpp <nl> ppp b / lstm / lstmtrainer . cpp <nl> bool LSTMTrainer : : SaveTrainingDump ( SerializeAmount serialize_amount , <nl> / / Reads previously saved trainer from memory . <nl> bool LSTMTrainer : : ReadTrainingDump ( const GenericVector < char > & data , <nl> LSTMTrainer * trainer ) { <nl> + if ( data . size ( ) = = 0 ) { <nl> + tprintf ( " Warning : data size is zero in LSTMTrainer : : ReadTrainingDump \ n " ) ; <nl> + return false ; <nl> + } <nl> return trainer - > ReadSizedTrainingDump ( & data [ 0 ] , data . size ( ) ) ; <nl> } <nl> <nl> STRING LSTMTrainer : : UpdateErrorGraph ( int iteration , double error_rate , <nl> if ( error_rate < best_error_rate_ ) { <nl> / / This is a new ( global ) minimum . <nl> if ( tester ! = NULL ) { <nl> - result = tester - > Run ( worst_iteration_ , worst_error_rates_ , <nl> - worst_model_data_ , CurrentTrainingStage ( ) ) ; <nl> + if ( worst_model_data_ . size ( ) ! = 0 ) <nl> + result = tester - > Run ( worst_iteration_ , worst_error_rates_ , <nl> + worst_model_data_ , CurrentTrainingStage ( ) ) ; <nl> worst_model_data_ . truncate ( 0 ) ; <nl> best_model_data_ = model_data ; <nl> } <nl> | LSTMTrainer : Catch empty vectors | tesseract-ocr/tesseract | 34d1e7331deb494bda0eadc3fd9abe705878cf2f | 2017-06-04T16:18:16Z |
mmm a / language / English / strings . xml <nl> ppp b / language / English / strings . xml <nl> <nl> < string id = " 35006 " > Device removed < / string > <nl> < string id = " 35007 " > Keymap to use for this device < / string > <nl> < string id = " 35008 " > Keymap enabled < / string > <nl> + < string id = " 35009 " > Do not use the custom keymap for this device < / string > <nl> <nl> < string id = " 35500 " > Location < / string > <nl> < string id = " 35501 " > Class < / string > <nl> mmm a / system / peripherals . xml <nl> ppp b / system / peripherals . xml <nl> <nl> < peripherals > <nl> < peripheral vendor_product = " 1915 : 003B , 22B8 : 003B " bus = " usb " name = " Motorola Nyxboard Hybrid " mapTo = " nyxboard " > <nl> - < setting key = " keymap_enabled " type = " bool " value = " 1 " label = " 35008 " order = " 1 " / > <nl> + < setting key = " do_not_use_custom_keymap " type = " bool " value = " 0 " label = " 35009 " order = " 1 " / > <nl> < setting key = " keymap " value = " nyxboard " label = " 35007 " configurable = " 0 " / > <nl> < setting key = " enable_flip_commands " type = " bool " value = " 1 " label = " 36005 " order = " 2 " / > <nl> < setting key = " flip_keyboard " value = " XBMC . VideoLibrary . Search " label = " 36002 " order = " 3 " / > <nl> mmm a / xbmc / peripherals / devices / Peripheral . cpp <nl> ppp b / xbmc / peripherals / devices / Peripheral . cpp <nl> void CPeripheral : : SetSetting ( const CStdString & strKey , float fValue ) <nl> } <nl> } <nl> <nl> + void CPeripheral : : SetSettingVisible ( const CStdString & strKey , bool bSetTo ) <nl> + { <nl> + map < CStdString , CSetting * > : : iterator it = m_settings . find ( strKey ) ; <nl> + if ( it ! = m_settings . end ( ) ) <nl> + ( * it ) . second - > SetVisible ( bSetTo ) ; <nl> + } <nl> + <nl> + bool CPeripheral : : IsSettingVisible ( const CStdString & strKey ) const <nl> + { <nl> + map < CStdString , CSetting * > : : const_iterator it = m_settings . find ( strKey ) ; <nl> + if ( it ! = m_settings . end ( ) ) <nl> + return ( * it ) . second - > IsVisible ( ) ; <nl> + return false ; <nl> + } <nl> + <nl> void CPeripheral : : SetSetting ( const CStdString & strKey , const CStdString & strValue ) <nl> { <nl> map < CStdString , CSetting * > : : iterator it = m_settings . find ( strKey ) ; <nl> mmm a / xbmc / peripherals / devices / Peripheral . h <nl> ppp b / xbmc / peripherals / devices / Peripheral . h <nl> namespace PERIPHERALS <nl> * / <nl> virtual const CStdString GetSettingString ( const CStdString & strKey ) const ; <nl> virtual void SetSetting ( const CStdString & strKey , const CStdString & strValue ) ; <nl> + virtual void SetSettingVisible ( const CStdString & strKey , bool bSetTo ) ; <nl> + virtual bool IsSettingVisible ( const CStdString & strKey ) const ; <nl> <nl> virtual int GetSettingInt ( const CStdString & strKey ) const ; <nl> virtual void SetSetting ( const CStdString & strKey , int iValue ) ; <nl> mmm a / xbmc / peripherals / devices / PeripheralHID . cpp <nl> ppp b / xbmc / peripherals / devices / PeripheralHID . cpp <nl> CPeripheralHID : : CPeripheralHID ( const PeripheralType type , const PeripheralBusTyp <nl> <nl> CPeripheralHID : : ~ CPeripheralHID ( void ) <nl> { <nl> - if ( ! m_strKeymap . IsEmpty ( ) & & GetSettingBool ( " keymap_enabled " ) ) <nl> + if ( ! m_strKeymap . IsEmpty ( ) & & ! GetSettingBool ( " do_not_use_custom_keymap " ) ) <nl> { <nl> CLog : : Log ( LOGDEBUG , " % s - switching active keymapping to : default " , __FUNCTION__ ) ; <nl> CButtonTranslator : : GetInstance ( ) . RemoveDevice ( m_strKeymap ) ; <nl> bool CPeripheralHID : : InitialiseFeature ( const PeripheralFeature feature ) <nl> SetSetting ( " keymap " , m_strKeymap ) ; <nl> } <nl> <nl> + if ( ! IsSettingVisible ( " keymap " ) ) <nl> + SetSettingVisible ( " do_not_use_custom_keymap " , false ) ; <nl> + <nl> if ( ! m_strKeymap . IsEmpty ( ) ) <nl> { <nl> - bool bKeymapEnabled ( GetSettingBool ( " keymap_enabled " ) ) ; <nl> + bool bKeymapEnabled ( ! GetSettingBool ( " do_not_use_custom_keymap " ) ) ; <nl> if ( bKeymapEnabled ) <nl> { <nl> CLog : : Log ( LOGDEBUG , " % s - adding keymapping for : % s " , __FUNCTION__ , m_strKeymap . c_str ( ) ) ; <nl> bool CPeripheralHID : : InitialiseFeature ( const PeripheralFeature feature ) <nl> <nl> void CPeripheralHID : : OnSettingChanged ( const CStdString & strChangedSetting ) <nl> { <nl> - if ( m_bInitialised & & ( ( strChangedSetting . Equals ( " keymap " ) & & GetSettingBool ( " keymap_enabled " ) ) | | strChangedSetting . Equals ( " keymap_enabled " ) ) ) <nl> + if ( m_bInitialised & & ( ( strChangedSetting . Equals ( " keymap " ) & & ! GetSettingBool ( " do_not_use_custom_keymap " ) ) | | strChangedSetting . Equals ( " keymap_enabled " ) ) ) <nl> { <nl> m_bInitialised = false ; <nl> InitialiseFeature ( FEATURE_HID ) ; <nl> | peripherals : change the ' keymap_enabled ' setting for HID devices into ' do_not_use_custom_keymap ' , and hide the setting when the keymap is not configurable | xbmc/xbmc | b4d5d219d71038e060d71354a0f1a511204a9204 | 2012-03-27T14:05:11Z |
mmm a / vnpy / trader / engine . py <nl> ppp b / vnpy / trader / engine . py <nl> def add_file_handler ( self ) : <nl> file_path = log_path . joinpath ( filename ) <nl> <nl> file_handler = logging . FileHandler ( <nl> - file_path , mode = " w " , encoding = " utf8 " <nl> + file_path , mode = " a " , encoding = " utf8 " <nl> ) <nl> file_handler . setLevel ( self . level ) <nl> file_handler . setFormatter ( self . formatter ) <nl> | [ Mod ] Close | vnpy/vnpy | fa9f06b2aafb16f2bf404bf9da85c37aebc2786c | 2019-06-10T06:54:41Z |
mmm a / ports / qscintilla / CONTROL <nl> ppp b / ports / qscintilla / CONTROL <nl> <nl> Source : qscintilla <nl> - Version : 2 . 10 - 4 <nl> + Version : 2 . 10 - 5 <nl> Description : QScintilla is a port to Qt of the Scintilla editing component . Features syntax highlighting , code - completion and much more ( Barebone build without python bindings ( missing dependeny PyQt ) and without QtDesigner plugin ) <nl> Build - Depends : qt5 - base <nl> mmm a / ports / qt5 - 3d / CONTROL <nl> ppp b / ports / qt5 - 3d / CONTROL <nl> <nl> Source : qt5 - 3d <nl> - Version : 5 . 9 . 2 - 0 <nl> + Version : 5 . 11 . 1 <nl> Description : Qt5 3d Module - Functionality for near - realtime simulation systems with support for 2D and 3D rendering <nl> Build - Depends : qt5 - modularscripts , qt5 - base , qt5 - declarative <nl> mmm a / ports / qt5 - 3d / portfile . cmake <nl> ppp b / ports / qt5 - 3d / portfile . cmake <nl> include ( vcpkg_common_functions ) <nl> <nl> include ( $ { CURRENT_INSTALLED_DIR } / share / qt5modularscripts / qt_modular_library . cmake ) <nl> <nl> - qt_modular_library ( qt3d 1c7dbd4e557cdd183ec6e929aae5727ce2ffcb519517942b588594bb81a78cb3d732cde4dae58085a70ec2968a8c2443eae96536125c25938222ff7c89f4f9a2 ) <nl> + qt_modular_library ( qt3d d1a07586d6b64ff3b1e85c41c8b3b86f6327e9e63f5f45344a65a6136179f6a8361ca9da80944b244d8edc53d8b0e9f8b646d613f6b42faac6cb724f49573a8a ) <nl> mmm a / ports / qt5 - activeqt / CONTROL <nl> ppp b / ports / qt5 - activeqt / CONTROL <nl> <nl> Source : qt5 - activeqt <nl> - Version : 5 . 9 . 2 - 0 <nl> + Version : 5 . 11 . 1 <nl> Description : Qt5 ActiveQt Module - ActiveX components <nl> Build - Depends : qt5 - modularscripts , qt5 - base <nl> mmm a / ports / qt5 - activeqt / portfile . cmake <nl> ppp b / ports / qt5 - activeqt / portfile . cmake <nl> include ( vcpkg_common_functions ) <nl> <nl> include ( $ { CURRENT_INSTALLED_DIR } / share / qt5modularscripts / qt_modular_library . cmake ) <nl> <nl> - qt_modular_library ( qtactiveqt c013e5cba0b11af88161d3cad21923c4b3bf04b0905e5b0c527c1984806d0eb39f31322ff464b139f5d36b5c9f4afefe70492fc1e1f0e964e6e0eaa3f6edaaf9 ) <nl> + qt_modular_library ( qtactiveqt a6fb4a3a53f5965e0913276a784f2fce81351a9c54cc190f15b431a497e04a4b823a8cec132713e382dc4e3ab2edef967e920c7aaa7392a72d7b12263c9f4876 ) <nl> <nl> file ( REMOVE_RECURSE $ { CURRENT_PACKAGES_DIR } / tools / qt5 - activeqt / platforminputcontexts ) <nl> mmm a / ports / qt5 - base / CONTROL <nl> ppp b / ports / qt5 - base / CONTROL <nl> <nl> Source : qt5 - base <nl> - Version : 5 . 9 . 2 - 7 <nl> + Version : 5 . 11 . 1 - 2 <nl> Description : Qt5 Application Framework Base Module . Includes Core , GUI , Widgets , Networking , SQL , Concurrent and other essential qt components . <nl> Build - Depends : zlib , libjpeg - turbo , libpng , freetype , pcre2 , harfbuzz , sqlite3 , libpq , double - conversion , openssl <nl> mmm a / ports / qt5 - base / configure_qt . cmake <nl> ppp b / ports / qt5 - base / configure_qt . cmake <nl> function ( configure_qt ) <nl> - debug <nl> - prefix $ { CURRENT_INSTALLED_DIR } / debug <nl> - extprefix $ { CURRENT_PACKAGES_DIR } / debug <nl> - - hostbindir $ { CURRENT_INSTALLED_DIR } / debug / tools / qt5 <nl> - - archdatadir $ { CURRENT_INSTALLED_DIR } / share / qt5 / debug <nl> - - datadir $ { CURRENT_INSTALLED_DIR } / share / qt5 / debug <nl> - - plugindir $ { CURRENT_INSTALLED_DIR } / debug / plugins <nl> - - qmldir $ { CURRENT_INSTALLED_DIR } / debug / qml <nl> + - hostbindir $ { CURRENT_PACKAGES_DIR } / debug / tools / qt5 <nl> + - archdatadir $ { CURRENT_PACKAGES_DIR } / share / qt5 / debug <nl> + - datadir $ { CURRENT_PACKAGES_DIR } / share / qt5 / debug <nl> + - plugindir $ { CURRENT_PACKAGES_DIR } / debug / plugins <nl> + - qmldir $ { CURRENT_PACKAGES_DIR } / debug / qml <nl> - headerdir $ { CURRENT_PACKAGES_DIR } / include <nl> - I $ { CURRENT_INSTALLED_DIR } / include <nl> - L $ { CURRENT_INSTALLED_DIR } / debug / lib <nl> function ( configure_qt ) <nl> - release <nl> - prefix $ { CURRENT_INSTALLED_DIR } <nl> - extprefix $ { CURRENT_PACKAGES_DIR } <nl> - - hostbindir $ { CURRENT_INSTALLED_DIR } / tools / qt5 <nl> - - archdatadir $ { CURRENT_INSTALLED_DIR } / share / qt5 <nl> - - datadir $ { CURRENT_INSTALLED_DIR } / share / qt5 <nl> - - plugindir $ { CURRENT_INSTALLED_DIR } / plugins <nl> - - qmldir $ { CURRENT_INSTALLED_DIR } / qml <nl> + - hostbindir $ { CURRENT_PACKAGES_DIR } / tools / qt5 <nl> + - archdatadir $ { CURRENT_PACKAGES_DIR } / share / qt5 <nl> + - datadir $ { CURRENT_PACKAGES_DIR } / share / qt5 <nl> + - plugindir $ { CURRENT_PACKAGES_DIR } / plugins <nl> + - qmldir $ { CURRENT_PACKAGES_DIR } / qml <nl> - I $ { CURRENT_INSTALLED_DIR } / include <nl> - L $ { CURRENT_INSTALLED_DIR } / lib <nl> - platform $ { _csc_PLATFORM } <nl> deleted file mode 100644 <nl> index c3976ced736 . . 00000000000 <nl> mmm a / ports / qt5 - base / fix - C3615 . patch <nl> ppp / dev / null <nl> <nl> - diff - - git a / src / corelib / tools / qalgorithms . h b / src / corelib / tools / qalgorithms . h <nl> - index c0f7709f . . 3784ceff 100644 <nl> mmm - a / src / corelib / tools / qalgorithms . h <nl> - ppp b / src / corelib / tools / qalgorithms . h <nl> - Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcountll ( quint64 v ) Q_DECL_NO <nl> - } <nl> - # elif defined ( Q_CC_MSVC ) & & ! defined ( Q_OS_WINCE ) & & ! defined ( Q_PROCESSOR_ARM ) <nl> - # define QT_POPCOUNT_CONSTEXPR <nl> - + # define QT_POPCOUNT_RELAXED_CONSTEXPR <nl> - # define QT_HAS_BUILTIN_CTZ <nl> - Q_ALWAYS_INLINE unsigned long qt_builtin_ctz ( quint32 val ) <nl> - { <nl> - Q_ALWAYS_INLINE uint qt_builtin_popcountll ( quint64 v ) Q_DECL_NOTHROW <nl> - <nl> - # ifndef QT_POPCOUNT_CONSTEXPR <nl> - # define QT_POPCOUNT_CONSTEXPR Q_DECL_CONSTEXPR <nl> - + # define QT_POPCOUNT_RELAXED_CONSTEXPR Q_DECL_RELAXED_CONSTEXPR <nl> - # endif <nl> - <nl> - } / / namespace QAlgorithmsPrivate <nl> - Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits ( quint32 v ) Q_DECL_NOT <nl> - # endif <nl> - } <nl> - <nl> - - Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits ( quint8 v ) Q_DECL_NOTHROW <nl> - + QT_POPCOUNT_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits ( quint8 v ) Q_DECL_NOTHROW <nl> - { <nl> - # if defined ( QT_HAS_BUILTIN_CLZ ) <nl> - return v ? QAlgorithmsPrivate : : qt_builtin_clz ( v ) - 24U : 8U ; <nl> - Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits ( quint8 v ) Q_DECL_NOTH <nl> - # endif <nl> - } <nl> - <nl> - - Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits ( quint16 v ) Q_DECL_NOTHROW <nl> - + QT_POPCOUNT_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits ( quint16 v ) Q_DECL_NOTHROW <nl> - { <nl> - # if defined ( QT_HAS_BUILTIN_CLZS ) <nl> - return v ? QAlgorithmsPrivate : : qt_builtin_clzs ( v ) : 16U ; <nl> - Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits ( quint16 v ) Q_DECL_NOT <nl> - # endif <nl> - } <nl> - <nl> - - Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits ( quint64 v ) Q_DECL_NOTHROW <nl> - + QT_POPCOUNT_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits ( quint64 v ) Q_DECL_NOTHROW <nl> - { <nl> - # if defined ( QT_HAS_BUILTIN_CLZLL ) <nl> - return v ? QAlgorithmsPrivate : : qt_builtin_clzll ( v ) : 64U ; <nl> - Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits ( quint64 v ) Q_DECL_NOT <nl> - # endif <nl> - } <nl> - <nl> - - Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits ( unsigned long v ) Q_DECL_NOTHROW <nl> - + QT_POPCOUNT_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits ( unsigned long v ) Q_DECL_NOTHROW <nl> - { <nl> - return qCountLeadingZeroBits ( QIntegerForSizeof < long > : : Unsigned ( v ) ) ; <nl> - } <nl> new file mode 100644 <nl> index 00000000000 . . c1f9254ff60 <nl> mmm / dev / null <nl> ppp b / ports / qt5 - base / fix - msvc2017 . patch <nl> <nl> + diff - Naur a / mkspecs / common / msvc - version . conf b / mkspecs / common / msvc - version . conf <nl> + mmm a / mkspecs / common / msvc - version . conf 2018 - 06 - 15 03 : 29 : 31 . 000000000 - 0400 <nl> ppp + b / mkspecs / common / msvc - version . conf 2018 - 08 - 23 00 : 26 : 46 . 436806400 - 0400 <nl> + <nl> + COMPAT_MKSPEC = <nl> + } <nl> + <nl> + + <nl> + + # MSVC 2017 15 . 8 + fixed std : : aligned_storage but compilation fails without <nl> + + # this flag since the fix breaks binary compatibility . <nl> + + greaterThan ( QMAKE_MSC_VER , 1914 ) { <nl> + + DEFINES + = _ENABLE_EXTENDED_ALIGNED_STORAGE <nl> + + } <nl> + + <nl> + ! isEmpty ( COMPAT_MKSPEC ) : ! $ $ COMPAT_MKSPEC : CONFIG + = $ $ COMPAT_MKSPEC <nl> + diff - Naur a / qmake / Makefile . win32 b / qmake / Makefile . win32 <nl> + mmm a / qmake / Makefile . win32 2018 - 06 - 15 03 : 29 : 31 . 000000000 - 0400 <nl> ppp + b / qmake / Makefile . win32 2018 - 08 - 23 00 : 27 : 45 . 764849600 - 0400 <nl> + <nl> + - D_CRT_SECURE_NO_WARNINGS - D_SCL_SECURE_NO_WARNINGS \ <nl> + - DQT_VERSION_STR = \ " $ ( QT_VERSION ) \ " - DQT_VERSION_MAJOR = $ ( QT_MAJOR_VERSION ) - DQT_VERSION_MINOR = $ ( QT_MINOR_VERSION ) - DQT_VERSION_PATCH = $ ( QT_PATCH_VERSION ) \ <nl> + - DQT_BUILD_QMAKE - DQT_BOOTSTRAPPED - DPROEVALUATOR_FULL \ <nl> + - - DQT_NO_FOREACH - DUNICODE <nl> + + - DQT_NO_FOREACH - DUNICODE - D_ENABLE_EXTENDED_ALIGNED_STORAGE <nl> + CFLAGS = $ ( CFLAGS_PCH ) $ ( CFLAGS_BARE ) $ ( CFLAGS ) <nl> + <nl> + CXXFLAGS_BARE = $ ( CFLAGS_BARE ) <nl> mmm a / ports / qt5 - base / fix - system - pcre2 - linux . patch <nl> ppp b / ports / qt5 - base / fix - system - pcre2 - linux . patch <nl> <nl> - diff - - git a / src / corelib / configure . json b / src / corelib / configure . json <nl> - index a5a1b66 . . 5a48a05 100644 <nl> mmm - a / src / corelib / configure . json <nl> - ppp b / src / corelib / configure . json <nl> - <nl> - " builds " : { <nl> - " debug " : " - lpcre2 - 16d " , <nl> - " release " : " - lpcre2 - 16 " <nl> - - } <nl> - - } <nl> - + } , <nl> - + " condition " : " config . win32 " <nl> - + } , <nl> - + { " libs " : " - lpcre2 - 16 " , " condition " : " ! config . win32 " } <nl> - ] <nl> - } , <nl> - " pps " : { <nl> + diff - Naur a / src / corelib / configure . json b / src / corelib / configure . json <nl> + mmm a / src / corelib / configure . json 2018 - 08 - 23 02 : 58 : 54 . 544949500 - 0400 <nl> ppp + b / src / corelib / configure . json 2018 - 08 - 23 02 : 59 : 31 . 481175300 - 0400 <nl> + <nl> + " builds " : { <nl> + " debug " : " - lpcre2 - 16d " , <nl> + " release " : " - lpcre2 - 16 " <nl> + - } <nl> + - } <nl> + + } , <nl> + + " condition " : " config . win32 " <nl> + + } , <nl> + + { " libs " : " - lpcre2 - 16 " , " condition " : " ! config . win32 " } <nl> + ] <nl> + } , <nl> + " pps " : { <nl> mmm a / ports / qt5 - base / fix - system - pcre2 . patch <nl> ppp b / ports / qt5 - base / fix - system - pcre2 . patch <nl> <nl> mmmmmm a / src / corelib / configure . json <nl> - ppp b / src / corelib / configure . json <nl> - <nl> - ] <nl> + diff - Naur a / src / corelib / configure . json b / src / corelib / configure . json <nl> + mmm a / src / corelib / configure . json 2018 - 06 - 15 03 : 29 : 31 . 000000000 - 0400 <nl> ppp + b / src / corelib / configure . json 2018 - 08 - 23 00 : 46 : 04 . 380187100 - 0400 <nl> + <nl> } , <nl> " sources " : [ <nl> + { " type " : " pkgConfig " , " args " : " libpcre2 - 16 " } , <nl> - " - lpcre2 - 16 " <nl> + { <nl> + " builds " : { <nl> mmm a / ports / qt5 - base / portfile . cmake <nl> ppp b / ports / qt5 - base / portfile . cmake <nl> if ( BUILDTREES_PATH_LENGTH GREATER 37 AND CMAKE_HOST_WIN32 ) <nl> ) <nl> endif ( ) <nl> <nl> - if ( ( NOT VCPKG_CMAKE_SYSTEM_NAME OR VCPKG_CMAKE_SYSTEM_NAME STREQUAL " WindowsStore " ) AND VCPKG_LIBRARY_LINKAGE STREQUAL static ) <nl> - message ( FATAL_ERROR " Qt5 doesn ' t currently support static builds . Please use a dynamic triplet instead . " ) <nl> - endif ( ) <nl> - <nl> list ( APPEND CMAKE_MODULE_PATH $ { CMAKE_CURRENT_LIST_DIR } ) <nl> include ( configure_qt ) <nl> include ( install_qt ) <nl> <nl> - set ( SRCDIR_NAME " qtbase - 5 . 9 . 2 " ) <nl> - set ( ARCHIVE_NAME " qtbase - opensource - src - 5 . 9 . 2 " ) <nl> - set ( ARCHIVE_EXTENSION " . tar . xz " ) <nl> + set ( MAJOR_MINOR 5 . 11 ) <nl> + set ( FULL_VERSION $ { MAJOR_MINOR } . 1 ) <nl> + set ( ARCHIVE_NAME " qtbase - everywhere - src - $ { FULL_VERSION } . tar . xz " ) <nl> <nl> - set ( SOURCE_PATH $ { CURRENT_BUILDTREES_DIR } / src / $ { SRCDIR_NAME } ) <nl> vcpkg_download_distfile ( ARCHIVE_FILE <nl> - URLS " http : / / download . qt . io / official_releases / qt / 5 . 9 / 5 . 9 . 2 / submodules / $ { ARCHIVE_NAME } $ { ARCHIVE_EXTENSION } " <nl> - FILENAME $ { SRCDIR_NAME } $ { ARCHIVE_EXTENSION } <nl> - SHA512 a2f965871645256f3d019f71f3febb875455a29d03fccc7a3371ddfeb193b0af12394e779df05adf69fd10fe7b0d966f3915a24528ec7eb3bc36c2db6af2b6e7 <nl> + URLS " http : / / download . qt . io / official_releases / qt / $ { MAJOR_MINOR } / $ { FULL_VERSION } / submodules / $ { ARCHIVE_NAME } " <nl> + FILENAME $ { ARCHIVE_NAME } <nl> + SHA512 5f45405872e541565d811c1973ae95b0f19593f4495375306917b72e21146e14fe8f7db5fbd629476476807f89ef1679aa59737ca5efdd9cbe6b14d7aa371b81 <nl> + ) <nl> + vcpkg_extract_source_archive_ex ( <nl> + OUT_SOURCE_PATH SOURCE_PATH <nl> + ARCHIVE " $ { ARCHIVE_FILE } " <nl> + REF $ { FULL_VERSION } <nl> + PATCHES <nl> + fix - system - freetype . patch <nl> + fix - system - pcre2 . patch <nl> + fix - system - pcre2 - linux . patch <nl> + fix - msvc2017 . patch <nl> ) <nl> - vcpkg_extract_source_archive ( $ { ARCHIVE_FILE } ) <nl> - if ( EXISTS $ { CURRENT_BUILDTREES_DIR } / src / $ { ARCHIVE_NAME } ) <nl> - file ( RENAME $ { CURRENT_BUILDTREES_DIR } / src / $ { ARCHIVE_NAME } $ { CURRENT_BUILDTREES_DIR } / src / $ { SRCDIR_NAME } ) <nl> - endif ( ) <nl> <nl> # Remove vendored dependencies to ensure they are not picked up by the build <nl> - foreach ( DEPENDENCY freetype zlib harfbuzzng libjpeg libpng double - conversion ) <nl> + foreach ( DEPENDENCY freetype zlib harfbuzzng libjpeg libpng double - conversion sqlite ) <nl> if ( EXISTS $ { SOURCE_PATH } / src / 3rdparty / $ { DEPENDENCY } ) <nl> file ( REMOVE_RECURSE $ { SOURCE_PATH } / src / 3rdparty / $ { DEPENDENCY } ) <nl> endif ( ) <nl> endforeach ( ) <nl> <nl> file ( REMOVE_RECURSE $ { SOURCE_PATH } / include / QtZlib ) <nl> <nl> - vcpkg_apply_patches ( <nl> - SOURCE_PATH $ { SOURCE_PATH } <nl> - PATCHES <nl> - " $ { CMAKE_CURRENT_LIST_DIR } / fix - system - pcre2 . patch " <nl> - " $ { CMAKE_CURRENT_LIST_DIR } / fix - system - freetype . patch " <nl> - " $ { CMAKE_CURRENT_LIST_DIR } / fix - system - pcre2 - linux . patch " <nl> - " $ { CMAKE_CURRENT_LIST_DIR } / fix - C3615 . patch " <nl> - ) <nl> - <nl> # This fixes issues on machines with default codepages that are not ASCII compatible , such as some CJK encodings <nl> set ( ENV { _CL_ } " / utf - 8 " ) <nl> <nl> set ( CORE_OPTIONS <nl> - system - pcre <nl> - system - harfbuzz <nl> - system - doubleconversion <nl> + - system - sqlite <nl> - no - fontconfig <nl> - - nomake examples - nomake tests <nl> + - nomake examples <nl> + - nomake tests <nl> ) <nl> <nl> + if ( VCPKG_LIBRARY_LINKAGE STREQUAL " static " ) <nl> + list ( APPEND CORE_OPTIONS <nl> + - static <nl> + ) <nl> + else ( ) <nl> + list ( APPEND CORE_OPTIONS <nl> + - sql - sqlite <nl> + - sql - psql <nl> + ) <nl> + endif ( ) <nl> + <nl> if ( NOT VCPKG_CMAKE_SYSTEM_NAME OR VCPKG_CMAKE_SYSTEM_NAME STREQUAL " WindowsStore " ) <nl> - if ( VCPKG_PLATFORM_TOOLSET MATCHES " v140 " ) <nl> - set ( PLATFORM " win32 - msvc2015 " ) <nl> - elseif ( VCPKG_PLATFORM_TOOLSET MATCHES " v141 " ) <nl> - set ( PLATFORM " win32 - msvc2017 " ) <nl> - elseif ( VCPKG_PLATFORM_TOOLSET MATCHES " v120 " ) <nl> - set ( PLATFORM " win32 - msvc2013 " ) <nl> - endif ( ) <nl> + set ( PLATFORM " win32 - msvc " ) <nl> + <nl> configure_qt ( <nl> SOURCE_PATH $ { SOURCE_PATH } <nl> PLATFORM $ { PLATFORM } <nl> OPTIONS <nl> $ { CORE_OPTIONS } <nl> - - sql - sqlite <nl> - - sql - psql <nl> - - system - sqlite <nl> - mp <nl> - opengl desktop # other options are " - no - opengl " , " - opengl angle " , and " - opengl desktop " <nl> LIBJPEG_LIBS = " - ljpeg " <nl> if ( NOT VCPKG_CMAKE_SYSTEM_NAME OR VCPKG_CMAKE_SYSTEM_NAME STREQUAL " WindowsStore <nl> ZLIB_LIBS = " - lzlib " <nl> LIBPNG_LIBS = " - llibpng16 " <nl> FREETYPE_LIBS = " - lfreetype " <nl> + PSQL_LIBS = " - llibpq " <nl> OPTIONS_DEBUG <nl> ZLIB_LIBS = " - lzlibd " <nl> LIBPNG_LIBS = " - llibpng16d " <nl> PSQL_LIBS = " - llibpqd " <nl> FREETYPE_LIBS = " - lfreetyped " <nl> ) <nl> + <nl> elseif ( VCPKG_CMAKE_SYSTEM_NAME STREQUAL " Linux " ) <nl> configure_qt ( <nl> SOURCE_PATH $ { SOURCE_PATH } <nl> if ( EXISTS $ { CURRENT_PACKAGES_DIR } / lib / qtmain . lib ) <nl> file ( COPY $ { CURRENT_PACKAGES_DIR } / debug / lib / qtmaind . prl DESTINATION $ { CURRENT_PACKAGES_DIR } / debug / lib / manual - link ) <nl> file ( REMOVE $ { CURRENT_PACKAGES_DIR } / debug / lib / qtmaind . lib ) <nl> file ( REMOVE $ { CURRENT_PACKAGES_DIR } / debug / lib / qtmaind . prl ) <nl> + <nl> + # mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + # Qt5Bootstrap : only used to bootstrap qmake dependencies <nl> + # mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + file ( REMOVE $ { CURRENT_PACKAGES_DIR } / debug / lib / Qt5Bootstrap . lib ) <nl> + file ( REMOVE $ { CURRENT_PACKAGES_DIR } / debug / lib / Qt5Bootstrap . prl ) <nl> + file ( RENAME $ { CURRENT_PACKAGES_DIR } / lib / Qt5Bootstrap . lib $ { CURRENT_PACKAGES_DIR } / tools / qt5 / Qt5Bootstrap . lib ) <nl> + file ( RENAME $ { CURRENT_PACKAGES_DIR } / lib / Qt5Bootstrap . prl $ { CURRENT_PACKAGES_DIR } / tools / qt5 / Qt5Bootstrap . prl ) <nl> + # mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> endif ( ) <nl> <nl> file ( GLOB_RECURSE PRL_FILES " $ { CURRENT_PACKAGES_DIR } / lib / * . prl " " $ { CURRENT_PACKAGES_DIR } / debug / lib / * . prl " ) <nl> mmm a / ports / qt5 - charts / CONTROL <nl> ppp b / ports / qt5 - charts / CONTROL <nl> <nl> Source : qt5 - charts <nl> - Version : 5 . 9 . 2 - 0 <nl> + Version : 5 . 11 . 1 <nl> Description : Qt5 Charts Module - UI components for displaying charts , driven by static or dynamic data models <nl> Build - Depends : qt5 - modularscripts , qt5 - base <nl> mmm a / ports / qt5 - charts / portfile . cmake <nl> ppp b / ports / qt5 - charts / portfile . cmake <nl> include ( vcpkg_common_functions ) <nl> <nl> include ( $ { CURRENT_INSTALLED_DIR } / share / qt5modularscripts / qt_modular_library . cmake ) <nl> <nl> - qt_modular_library ( qtcharts 297547b565dd71b05237bb05ecc1abf1a774a4909668417e78bd65e805c1e47a456a5a06898fe06d4c4614118e4129e19893d4c77598667a9354ab969307a293 ) <nl> + qt_modular_library ( qtcharts e3c02ea9bd985a8d051e305dd04e58711de3b666128a695011afd65271a2c7bcb11763c18fe201045ce03df96326490ca7322bdc0f77e97988ec59427505886b ) <nl> mmm a / ports / qt5 - datavis3d / CONTROL <nl> ppp b / ports / qt5 - datavis3d / CONTROL <nl> <nl> Source : qt5 - datavis3d <nl> - Version : 5 . 9 . 2 - 0 <nl> + Version : 5 . 11 . 1 <nl> Description : Qt5 Data Visualization 3d Module - UI Components for creating 3D data visualizations <nl> Build - Depends : qt5 - modularscripts , qt5 - base <nl> mmm a / ports / qt5 - datavis3d / portfile . cmake <nl> ppp b / ports / qt5 - datavis3d / portfile . cmake <nl> include ( vcpkg_common_functions ) <nl> <nl> include ( $ { CURRENT_INSTALLED_DIR } / share / qt5modularscripts / qt_modular_library . cmake ) <nl> <nl> - qt_modular_library ( qtdatavis3d 5f173401ba2f0ebb4bbb1ff65053f1ece44a97a8bf1d9fc8d81540709c588e140c533d5f317d6a9109d538e38aa742d42bf00906f63d433811bc1c8526788dc3 ) <nl> + qt_modular_library ( qtdatavis3d e88f2471fa39fd4f4c7900df5edadc568d000b537eb00f892fadc6cf1d7845987b9fd98adbea4c35c6469c9a9bfce087b26440a6419ca758451dbe3b669d19cd ) <nl> mmm a / ports / qt5 - declarative / CONTROL <nl> ppp b / ports / qt5 - declarative / CONTROL <nl> <nl> Source : qt5 - declarative <nl> - Version : 5 . 9 . 2 - 0 <nl> + Version : 5 . 11 . 1 <nl> Description : Qt5 Declarative ( Quick 2 ) Module . Includes QtQuick , QtQuickParticles , QtQuickWidgets , QtQml , and QtPacketProtocol . <nl> Build - Depends : qt5 - modularscripts , qt5 - base <nl> mmm a / ports / qt5 - declarative / portfile . cmake <nl> ppp b / ports / qt5 - declarative / portfile . cmake <nl> include ( vcpkg_common_functions ) <nl> <nl> include ( $ { CURRENT_INSTALLED_DIR } / share / qt5modularscripts / qt_modular_library . cmake ) <nl> <nl> - qt_modular_library ( qtdeclarative 49b8b50932b73ea39da14ac3425044193dfd64eabceadba379aa01cf2fc141177f9870c387caf1cf93ce09e8b197828a54b8d9fcefc4d9cdf400a6c6dd9a9e90 ) <nl> + qt_modular_library ( qtdeclarative d4252f58fcc811273b1a51f80167bca19f744d70c47362b631bbb7875473a808402d64b26475e2f5ff1813d8b8cc66b81cac1b8a4b5e36f7ca1fdbb15666f053 ) <nl> <nl> - file ( REMOVE_RECURSE $ { CURRENT_PACKAGES_DIR } / tools / qt5 - declarative / platforminputcontexts ) <nl> \ No newline at end of file <nl> + # file ( REMOVE_RECURSE $ { CURRENT_PACKAGES_DIR } / tools / qt5 - declarative / platforminputcontexts ) <nl> \ No newline at end of file <nl> mmm a / ports / qt5 - gamepad / CONTROL <nl> ppp b / ports / qt5 - gamepad / CONTROL <nl> <nl> Source : qt5 - gamepad <nl> - Version : 5 . 9 . 2 - 0 <nl> + Version : 5 . 11 . 1 <nl> Description : Qt5 Gamepad Module - Enables Qt applications to support the use of gamepad hardware <nl> Build - Depends : qt5 - modularscripts , qt5 - base <nl> mmm a / ports / qt5 - gamepad / portfile . cmake <nl> ppp b / ports / qt5 - gamepad / portfile . cmake <nl> include ( vcpkg_common_functions ) <nl> <nl> include ( $ { CURRENT_INSTALLED_DIR } / share / qt5modularscripts / qt_modular_library . cmake ) <nl> <nl> - qt_modular_library ( qtgamepad 398d6ff0268460358584a4ea8ba0588881970dcc1dff6c5aa91d1630065ba112c86d7a1fe96dceb8ff301b350aef7f74ad1ee6212048a4cdfb26ff5d944d6222 ) <nl> + qt_modular_library ( qtgamepad 47dfe1fdd693300520f9710d0a161936d8f1805b4558d6f692ed204f8d6784d45adb73bd472fb255deed792a610c94b35a72143deb0d8f227b8a9996dd1703cc ) <nl> mmm a / ports / qt5 - graphicaleffects / CONTROL <nl> ppp b / ports / qt5 - graphicaleffects / CONTROL <nl> <nl> Source : qt5 - graphicaleffects <nl> - Version : 5 . 9 . 2 - 0 <nl> + Version : 5 . 11 . 1 <nl> Description : Qt5 GraphicalEffects Module . <nl> Build - Depends : qt5 - modularscripts , qt5 - base <nl> mmm a / ports / qt5 - graphicaleffects / portfile . cmake <nl> ppp b / ports / qt5 - graphicaleffects / portfile . cmake <nl> include ( vcpkg_common_functions ) <nl> <nl> include ( $ { CURRENT_INSTALLED_DIR } / share / qt5modularscripts / qt_modular_library . cmake ) <nl> <nl> - qt_modular_library ( qtgraphicaleffects 66464c26c9cc78763fda18898cd9c424bc4c0a5cbffc83d68d388e53327aeb77ae0e3c2c4cea947c3b6b7ec5af7bf5124492fc9642ff3c4ba75b06b9fa3883a4 ) <nl> + qt_modular_library ( qtgraphicaleffects 0e79eac7debfd8904063d6b03938f62ed72194b5de164e0700d27bd2aac15e390cbdd337fa9afb62435862972e488fb01ae54f08d2a492719baa21a410272297 ) <nl> mmm a / ports / qt5 - imageformats / CONTROL <nl> ppp b / ports / qt5 - imageformats / CONTROL <nl> <nl> Source : qt5 - imageformats <nl> - Version : 5 . 9 . 2 - 0 <nl> + Version : 5 . 11 . 1 <nl> Description : Qt5 Image Formats Module - Plugins for additional image formats : TIFF , MNG , TGA , WBMP <nl> Build - Depends : qt5 - modularscripts , qt5 - base <nl> mmm a / ports / qt5 - imageformats / portfile . cmake <nl> ppp b / ports / qt5 - imageformats / portfile . cmake <nl> include ( vcpkg_common_functions ) <nl> <nl> include ( $ { CURRENT_INSTALLED_DIR } / share / qt5modularscripts / qt_modular_library . cmake ) <nl> <nl> - qt_modular_library ( qtimageformats 5f1b93c0e5fffa4c2c063d14c12ad97114a452b16814ca9ac45f00ec36308a09770b3b4d137cb5d19bd3aa3a6f576724084df5d0dad75236d49868af9243c9d2 ) <nl> + qt_modular_library ( qtimageformats 527bd6d324904d1c7c6d931fe96bfa43575a904d2b94cbda3129c4a883fb79b9bdf6f009b41d2747e8aec2c410a2b23bfa0e94fc4eea698d54a0878bc934514d ) <nl> <nl> set ( VCPKG_POLICY_EMPTY_PACKAGE enabled ) <nl> mmm a / ports / qt5 - modularscripts / CONTROL <nl> ppp b / ports / qt5 - modularscripts / CONTROL <nl> <nl> Source : qt5 - modularscripts <nl> - Version : 4 <nl> + Version : 2018 - 09 - 10 - 2 <nl> Description : Vcpkg helpers to package qt5 modules <nl> mmm a / ports / qt5 - modularscripts / qt_modular_library . cmake <nl> ppp b / ports / qt5 - modularscripts / qt_modular_library . cmake <nl> function ( qt_modular_library NAME HASH ) <nl> ) <nl> endif ( ) <nl> <nl> - if ( VCPKG_LIBRARY_LINKAGE STREQUAL static ) <nl> - message ( FATAL_ERROR " Qt5 doesn ' t currently support static builds . Please use a dynamic triplet instead . " ) <nl> - endif ( ) <nl> - <nl> - set ( SRCDIR_NAME " $ { NAME } - 5 . 9 . 2 " ) <nl> - set ( ARCHIVE_NAME " $ { NAME } - opensource - src - 5 . 9 . 2 " ) <nl> - set ( ARCHIVE_EXTENSION " . tar . xz " ) <nl> + set ( MAJOR_MINOR 5 . 11 ) <nl> + set ( FULL_VERSION $ { MAJOR_MINOR } . 1 ) <nl> + set ( ARCHIVE_NAME " $ { NAME } - everywhere - src - $ { FULL_VERSION } . tar . xz " ) <nl> <nl> - set ( SOURCE_PATH $ { CURRENT_BUILDTREES_DIR } / src / $ { SRCDIR_NAME } ) <nl> vcpkg_download_distfile ( ARCHIVE_FILE <nl> - URLS " http : / / download . qt . io / official_releases / qt / 5 . 9 / 5 . 9 . 2 / submodules / $ { ARCHIVE_NAME } $ { ARCHIVE_EXTENSION } " <nl> - FILENAME $ { SRCDIR_NAME } $ { ARCHIVE_EXTENSION } <nl> + URLS " http : / / download . qt . io / official_releases / qt / $ { MAJOR_MINOR } / $ { FULL_VERSION } / submodules / $ { ARCHIVE_NAME } " <nl> + FILENAME $ { ARCHIVE_NAME } <nl> SHA512 $ { HASH } <nl> ) <nl> - vcpkg_extract_source_archive ( $ { ARCHIVE_FILE } ) <nl> - if ( EXISTS $ { CURRENT_BUILDTREES_DIR } / src / $ { ARCHIVE_NAME } ) <nl> - file ( RENAME $ { CURRENT_BUILDTREES_DIR } / src / $ { ARCHIVE_NAME } $ { CURRENT_BUILDTREES_DIR } / src / $ { SRCDIR_NAME } ) <nl> - endif ( ) <nl> + vcpkg_extract_source_archive_ex ( <nl> + OUT_SOURCE_PATH SOURCE_PATH <nl> + ARCHIVE " $ { ARCHIVE_FILE } " <nl> + REF $ { FULL_VERSION } <nl> + ) <nl> <nl> # This fixes issues on machines with default codepages that are not ASCII compatible , such as some CJK encodings <nl> set ( ENV { _CL_ } " / utf - 8 " ) <nl> function ( qt_modular_library NAME HASH ) <nl> <nl> file ( GLOB_RECURSE MAKEFILES $ { DEBUG_DIR } / * Makefile * $ { RELEASE_DIR } / * Makefile * ) <nl> <nl> - # Set the correct install directory to packages <nl> foreach ( MAKEFILE $ { MAKEFILES } ) <nl> - vcpkg_replace_string ( $ { MAKEFILE } " ( INSTALL_ROOT ) $ { INSTALLED_DIR_WITHOUT_DRIVE } " " ( INSTALL_ROOT ) $ { PACKAGES_DIR_WITHOUT_DRIVE } " ) <nl> + file ( READ " $ { MAKEFILE } " _contents ) <nl> + # Set the correct install directory to packages <nl> + string ( REPLACE " ( INSTALL_ROOT ) $ { INSTALLED_DIR_WITHOUT_DRIVE } " " ( INSTALL_ROOT ) $ { PACKAGES_DIR_WITHOUT_DRIVE } " _contents " $ { _contents } " ) <nl> + file ( WRITE " $ { MAKEFILE } " " $ { _contents } " ) <nl> endforeach ( ) <nl> <nl> # Install the module files <nl> mmm a / ports / qt5 - multimedia / CONTROL <nl> ppp b / ports / qt5 - multimedia / CONTROL <nl> <nl> Source : qt5 - multimedia <nl> - Version : 5 . 9 . 2 - 0 <nl> + Version : 5 . 11 . 1 <nl> Description : Qt5 Multimedia Module - Classes and widgets for audio , video , radio and camera functionality <nl> Build - Depends : qt5 - modularscripts , qt5 - base , qt5 - declarative <nl> mmm a / ports / qt5 - multimedia / portfile . cmake <nl> ppp b / ports / qt5 - multimedia / portfile . cmake <nl> include ( vcpkg_common_functions ) <nl> <nl> include ( $ { CURRENT_INSTALLED_DIR } / share / qt5modularscripts / qt_modular_library . cmake ) <nl> <nl> - qt_modular_library ( qtmultimedia b9fab874706440e97185475bfd0ad769c23d5ddbff5086cc0da9783777e81ed8140fb06fa0e7536ebfb67f2c9db39e1b9f3c2241834e74a9e1fb6ffd5cb7af11 ) <nl> + qt_modular_library ( qtmultimedia cfce510f5f5825ce12207070ce34bbc97e5433b5174bbdd562befcd383c74459436dfce23e5fd8ee5c5a4c28573b85374383d17ca3d0c61daa51b50c915b324c ) <nl> mmm a / ports / qt5 - networkauth / CONTROL <nl> ppp b / ports / qt5 - networkauth / CONTROL <nl> <nl> Source : qt5 - networkauth <nl> - Version : 5 . 9 . 2 - 0 <nl> + Version : 5 . 11 . 1 <nl> Description : Qt5 Network Authorization Module <nl> Build - Depends : qt5 - modularscripts , qt5 - base <nl> mmm a / ports / qt5 - networkauth / portfile . cmake <nl> ppp b / ports / qt5 - networkauth / portfile . cmake <nl> include ( vcpkg_common_functions ) <nl> <nl> include ( $ { CURRENT_INSTALLED_DIR } / share / qt5modularscripts / qt_modular_library . cmake ) <nl> <nl> - qt_modular_library ( qtnetworkauth 2e83eefd5db62aa1cdbe451b432ba1937541e435dcc35205d3bb9b947f2ac7e31663dc069a6cfad5bbf34e1fa799d519820f7ed61b9c247016611a533385bebf ) <nl> \ No newline at end of file <nl> + qt_modular_library ( qtnetworkauth 1f2b55870d61027f4af00d54507baf4953f162ca63a4e571a9c6f4095daa0235c2a93f67515cac627ff0a6655d94b01a3b3ba759bbbf75f9b108efbf12777c0d ) <nl> \ No newline at end of file <nl> mmm a / ports / qt5 - quickcontrols / CONTROL <nl> ppp b / ports / qt5 - quickcontrols / CONTROL <nl> <nl> Source : qt5 - quickcontrols <nl> - Version : 5 . 9 . 2 - 1 <nl> + Version : 5 . 11 . 1 <nl> Description : Qt5 QuickControls Module . <nl> Build - Depends : qt5 - modularscripts , qt5 - base , qt5 - declarative <nl> mmm a / ports / qt5 - quickcontrols / portfile . cmake <nl> ppp b / ports / qt5 - quickcontrols / portfile . cmake <nl> include ( vcpkg_common_functions ) <nl> <nl> include ( $ { CURRENT_INSTALLED_DIR } / share / qt5modularscripts / qt_modular_library . cmake ) <nl> <nl> - qt_modular_library ( qtquickcontrols fd5833bd3823e3a53b54ac542857af5bb109952035869ad0a151e807abc9d304ef5d3fa04b75df3b59faf0b95412f593d86b56198f96734f3a75b1620688ba4f ) <nl> + qt_modular_library ( qtquickcontrols d12cffe5a91f10e37b2ebea435fa147508fa60dc83076a1fb1c26d4ea16666c13ced0c36a5222092b6c4d6c1c723bed5b881fc33557353e09cb9aca068dde26c ) <nl> mmm a / ports / qt5 - quickcontrols2 / CONTROL <nl> ppp b / ports / qt5 - quickcontrols2 / CONTROL <nl> <nl> Source : qt5 - quickcontrols2 <nl> - Version : 5 . 9 . 2 - 1 <nl> + Version : 5 . 11 . 1 <nl> Description : Qt5 QuickControls2 Module . <nl> Build - Depends : qt5 - modularscripts , qt5 - base , qt5 - declarative <nl> mmm a / ports / qt5 - quickcontrols2 / portfile . cmake <nl> ppp b / ports / qt5 - quickcontrols2 / portfile . cmake <nl> include ( vcpkg_common_functions ) <nl> <nl> include ( $ { CURRENT_INSTALLED_DIR } / share / qt5modularscripts / qt_modular_library . cmake ) <nl> <nl> - qt_modular_library ( qtquickcontrols2 e283320aabbaa153067c909804cb34bbcbf6fcb7246bb214957b6092ceb0f01c4fae2efd9d7a6cb011274deafff4aaf0a45dbda06a3fdce1154622e48740048c ) <nl> + qt_modular_library ( qtquickcontrols2 b4d42d5ec5abdd819badfef147492fecc8ed433b88705c418845d75d35ee5880b11afaf70f17e3913855ccaa9aa47b3a9d497350ecb105b4f0672cf29111eb68 ) <nl> mmm a / ports / qt5 - scxml / CONTROL <nl> ppp b / ports / qt5 - scxml / CONTROL <nl> <nl> Source : qt5 - scxml <nl> - Version : 5 . 9 . 2 - 0 <nl> + Version : 5 . 11 . 1 <nl> Description : Qt5 SCXML Module - Provides classes and tools for creating state machines from SCXML files and embedding them in applications <nl> Build - Depends : qt5 - modularscripts , qt5 - base , qt5 - declarative <nl> mmm a / ports / qt5 - scxml / portfile . cmake <nl> ppp b / ports / qt5 - scxml / portfile . cmake <nl> include ( vcpkg_common_functions ) <nl> <nl> include ( $ { CURRENT_INSTALLED_DIR } / share / qt5modularscripts / qt_modular_library . cmake ) <nl> <nl> - qt_modular_library ( qtscxml c33db992ab456e5dd8b9be65c5619c503048106bbb1839b0930f2d4df36eed0780dfa1fc2912d7758aa72195269e59cbe8826cbaa414c2f339ca66c565809c88 ) <nl> + qt_modular_library ( qtscxml d64dba323b009525078e999e0972fd09a16bb806980411ce7cc452aee0951632ee440f71c2b5124cfd6ed5020aa869d8490017aaba374a8d4b83f43c1f0b0689 ) <nl> mmm a / ports / qt5 - serialport / CONTROL <nl> ppp b / ports / qt5 - serialport / CONTROL <nl> <nl> Source : qt5 - serialport <nl> - Version : 5 . 9 . 2 - 0 <nl> + Version : 5 . 11 . 1 <nl> Description : Qt5 Serial Port - provides access to hardware and virtual serial ports <nl> Build - Depends : qt5 - modularscripts , qt5 - base <nl> mmm a / ports / qt5 - serialport / portfile . cmake <nl> ppp b / ports / qt5 - serialport / portfile . cmake <nl> include ( vcpkg_common_functions ) <nl> <nl> include ( $ { CURRENT_INSTALLED_DIR } / share / qt5modularscripts / qt_modular_library . cmake ) <nl> <nl> - qt_modular_library ( qtserialport cc8899c1ae2ed9fd8cf1c213ab7efaec12b3b16836006fdbf74cb7ea457705505a13e82c2f2873ee9426ae66473ec42259f4e728de64576ee44420f116cc433d ) <nl> + qt_modular_library ( qtserialport 2f13122438dfe91c6885534e4470e119abf1c7134b1d344e9c0700661c002566f483aa2bcdde53e4860df349fff4ff8ef05bfafb0aa1bb4484d3e5d07c989404 ) <nl> mmm a / ports / qt5 - speech / CONTROL <nl> ppp b / ports / qt5 - speech / CONTROL <nl> <nl> Source : qt5 - speech <nl> - Version : 5 . 9 . 2 - 0 <nl> + Version : 5 . 11 . 1 <nl> Description : Qt5 Speech Module <nl> Build - Depends : qt5 - modularscripts , qt5 - base , atlmfc ( windows ) <nl> mmm a / ports / qt5 - speech / portfile . cmake <nl> ppp b / ports / qt5 - speech / portfile . cmake <nl> include ( vcpkg_common_functions ) <nl> <nl> include ( $ { CURRENT_INSTALLED_DIR } / share / qt5modularscripts / qt_modular_library . cmake ) <nl> <nl> - qt_modular_library ( qtspeech 8213ad13d33732fee3fc5b5e408b870970a3003d461be24195222e1d1209210039d1d0cd2f3c537a0db62629fb297d88b33ed4734ecb6c8d74f5406a87e7e0c0 ) <nl> + qt_modular_library ( qtspeech d17a0ab62083b9a8cef5f458b649b7789b0e3394a660c71f9ea6e6311c5e37edda10b16692817b8e165dd66a38cf34560e37940a63beec99ece3e2ee862adf51 ) <nl> mmm a / ports / qt5 - svg / CONTROL <nl> ppp b / ports / qt5 - svg / CONTROL <nl> <nl> Source : qt5 - svg <nl> - Version : 5 . 9 . 2 - 0 <nl> + Version : 5 . 11 . 1 <nl> Description : Qt5 SVG Module - provides classes for displaying the contents of SVG files <nl> Build - Depends : qt5 - modularscripts , qt5 - base <nl> mmm a / ports / qt5 - svg / portfile . cmake <nl> ppp b / ports / qt5 - svg / portfile . cmake <nl> include ( vcpkg_common_functions ) <nl> <nl> include ( $ { CURRENT_INSTALLED_DIR } / share / qt5modularscripts / qt_modular_library . cmake ) <nl> <nl> - qt_modular_library ( qtsvg c21c5a12fa10ff9f91deda88c99c995ee2138bdffa21c793b0c42f25155f01f87ede5206624b9d82713649f8cf1cfdb95f1d5b7e792de62f3848d3a9ec665fdd ) <nl> + qt_modular_library ( qtsvg 2e9b126e72335b4b39296d033c6ea8761739148b812841797e1678135eaad944a5e4073010b5dbfb17708bd8fc8de0dd6b2b092330176b3b29c7637357353e39 ) <nl> mmm a / ports / qt5 - tools / CONTROL <nl> ppp b / ports / qt5 - tools / CONTROL <nl> <nl> Source : qt5 - tools <nl> - Version : 5 . 9 . 2 - 0 <nl> + Version : 5 . 11 . 1 <nl> Description : Qt5 Tools Module ; Includes deployment tools and helpers , Qt Designer , Assistant , and other applications <nl> Build - Depends : qt5 - modularscripts , qt5 - base , qt5 - declarative <nl> mmm a / ports / qt5 - tools / portfile . cmake <nl> ppp b / ports / qt5 - tools / portfile . cmake <nl> include ( vcpkg_common_functions ) <nl> <nl> include ( $ { CURRENT_INSTALLED_DIR } / share / qt5modularscripts / qt_modular_library . cmake ) <nl> <nl> - qt_modular_library ( qttools afce063e167de96dfa264cfd27dc8d80c23ef091a30f4f8119575cae83f39716c3b332427630b340f518b82d6396cca1893f28e00f3c667ba201d7e4fc2aefe1 ) <nl> + qt_modular_library ( qttools cf690c630db79b4cd86d5d608175fb2c5463a985d7cb8a592c0995db04593c2c2ddddb52a3dc21348462639efdd3f9c57d3897a8384708b912b42cf1ac2c7482 ) <nl> <nl> - file ( REMOVE_RECURSE $ { CURRENT_PACKAGES_DIR } / / tools / qt5 - tools / platforminputcontexts ) <nl> \ No newline at end of file <nl> + # file ( REMOVE_RECURSE $ { CURRENT_PACKAGES_DIR } / tools / qt5 - tools / platforminputcontexts ) <nl> \ No newline at end of file <nl> mmm a / ports / qt5 - virtualkeyboard / CONTROL <nl> ppp b / ports / qt5 - virtualkeyboard / CONTROL <nl> <nl> Source : qt5 - virtualkeyboard <nl> - Version : 5 . 9 . 2 - 0 <nl> + Version : 5 . 11 . 1 <nl> Description : Qt5 Virtual Keyboard Module - A framework for implementing different input methods . Supports localized keyboard layouts and custom visual themes <nl> Build - Depends : qt5 - modularscripts , qt5 - base <nl> mmm a / ports / qt5 - virtualkeyboard / portfile . cmake <nl> ppp b / ports / qt5 - virtualkeyboard / portfile . cmake <nl> include ( vcpkg_common_functions ) <nl> <nl> include ( $ { CURRENT_INSTALLED_DIR } / share / qt5modularscripts / qt_modular_library . cmake ) <nl> <nl> - qt_modular_library ( qtvirtualkeyboard f8c39b789e877e60389ee9aab4a5c17e6018093f72fc57f526ce2584183135206306d4d5a7c7551a6de45969aa6f55444bb39f4ea3324cdf10611533f0bc2b22 ) <nl> + qt_modular_library ( qtvirtualkeyboard e3010450553cad42850b4cf1b07e157b30e9a6a74b8c551e21ab45a04da76e55e83c08b4421c081eda44e8928c8e0b69f9c8146855a4e02bbf3779f5a0e290d0 ) <nl> <nl> set ( VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled ) <nl> mmm a / ports / qt5 - websockets / CONTROL <nl> ppp b / ports / qt5 - websockets / CONTROL <nl> <nl> Source : qt5 - websockets <nl> - Version : 5 . 9 . 2 - 0 <nl> + Version : 5 . 11 . 1 <nl> Description : Qt5 Web Sockets Module - provides WebSocket communication compliant with RFC 6455 <nl> Build - Depends : qt5 - modularscripts , qt5 - base <nl> mmm a / ports / qt5 - websockets / portfile . cmake <nl> ppp b / ports / qt5 - websockets / portfile . cmake <nl> include ( vcpkg_common_functions ) <nl> <nl> include ( $ { CURRENT_INSTALLED_DIR } / share / qt5modularscripts / qt_modular_library . cmake ) <nl> <nl> - qt_modular_library ( qtwebsockets 9330d6806251bc77d4c2a497a31b1b0e42a1e6bfe3ea7c00cee123052e9e1f9080e33cf4dfcd6ee6e4732c62f41257a77ec25ad607528f4e8ebe61ccaee3e159 ) <nl> + qt_modular_library ( qtwebsockets 01eb3fabfa0f46c6ecedc3cd9a05e504fef91926ffeab1f534557e50c15d7fd284edaa553f545d8363343a32c0c3187e77e3e5d6edea8331e9234c05c0e318fc ) <nl> mmm a / ports / qt5 - winextras / CONTROL <nl> ppp b / ports / qt5 - winextras / CONTROL <nl> <nl> Source : qt5 - winextras <nl> - Version : 5 . 9 . 2 - 0 <nl> + Version : 5 . 11 . 1 <nl> Description : Qt5 Windows Extras Module . Provides platform - specific APIs for Windows . <nl> Build - Depends : qt5 - modularscripts , qt5 - base , atlmfc <nl> mmm a / ports / qt5 - winextras / portfile . cmake <nl> ppp b / ports / qt5 - winextras / portfile . cmake <nl> include ( vcpkg_common_functions ) <nl> <nl> include ( $ { CURRENT_INSTALLED_DIR } / share / qt5modularscripts / qt_modular_library . cmake ) <nl> <nl> - qt_modular_library ( qtwinextras dbfb89833cc291fade8e9fe2ad9c7b7a78c2032de8dcbca1049d637f829811b99e1852ae39ca73a6eac2960df168765bee28023bb723e69c87e2f3bb50b7ef02 ) <nl> + qt_modular_library ( qtwinextras 6ba1ddb6ff467fc413bf6a3d111e449215b696949dcfb399c17de9eb6d2ca20f867dd0c57d467e2924452e1d3d429fcc3dd119cc7d8bbfbcf0feeb9f6ca92918 ) <nl> mmm a / ports / qt5 - xmlpatterns / CONTROL <nl> ppp b / ports / qt5 - xmlpatterns / CONTROL <nl> <nl> Source : qt5 - xmlpatterns <nl> - Version : 5 . 9 . 2 - 0 <nl> + Version : 5 . 11 . 1 <nl> Description : Qt5 XML Patterns Module - Support for XPath , XQuery , XSLT and XML schema validation <nl> Build - Depends : qt5 - modularscripts , qt5 - base <nl> mmm a / ports / qt5 - xmlpatterns / portfile . cmake <nl> ppp b / ports / qt5 - xmlpatterns / portfile . cmake <nl> include ( vcpkg_common_functions ) <nl> <nl> include ( $ { CURRENT_INSTALLED_DIR } / share / qt5modularscripts / qt_modular_library . cmake ) <nl> <nl> - qt_modular_library ( qtxmlpatterns c14dbd97988473ba73b4e21352c5560278aa4dbfdf2be1d12e9119c0b5dbe8a0e4eff9a682052024a01bb21dcf52d40ba00da98947901fb91518af92a225da83 ) <nl> + qt_modular_library ( qtxmlpatterns 207fda037fce412412909799ba7737764ebfa5d8cd4b0185f158791adbecd9a0e0db15bb7e40aaa5e664809b600e77a7a3398a35d2f4e087f1ab15a31e706066 ) <nl> mmm a / ports / qwt / CONTROL <nl> ppp b / ports / qwt / CONTROL <nl> <nl> Source : qwt <nl> - Version : 6 . 1 . 3 - 5 <nl> + Version : 6 . 1 . 3 - 6 <nl> Description : Qt widgets library for technical applications <nl> Build - Depends : qt5 - base , qt5 - svg , qt5 - tools <nl> mmm a / ports / sqlite3 / CMakeLists . txt <nl> ppp b / ports / sqlite3 / CMakeLists . txt <nl> target_compile_definitions ( <nl> $ { API } <nl> - DSQLITE_ENABLE_RTREE <nl> - DSQLITE_ENABLE_UNLOCK_NOTIFY <nl> + - DSQLITE_ENABLE_COLUMN_METADATA <nl> ) <nl> target_include_directories ( sqlite3 INTERFACE $ < INSTALL_INTERFACE : include > ) <nl> if ( NOT WIN32 ) <nl> mmm a / ports / sqlite3 / CONTROL <nl> ppp b / ports / sqlite3 / CONTROL <nl> <nl> Source : sqlite3 <nl> - Version : 3 . 24 . 0 - 1 <nl> + Version : 3 . 24 . 0 - 2 <nl> Description : SQLite is a software library that implements a self - contained , serverless , zero - configuration , transactional SQL database engine . <nl> <nl> Feature : tool <nl> mmm a / scripts / cmake / vcpkg_build_qmake . cmake <nl> ppp b / scripts / cmake / vcpkg_build_qmake . cmake <nl> function ( vcpkg_build_qmake ) <nl> string ( REPLACE " zlib . lib " " zlibd . lib " _contents " $ { _contents } " ) <nl> string ( REPLACE " installed \ \ $ { TARGET_TRIPLET } \ \ lib " " installed \ \ $ { TARGET_TRIPLET } \ \ debug \ \ lib " _contents " $ { _contents } " ) <nl> string ( REPLACE " / LIBPATH : $ { NATIVE_INSTALLED_DIR } \ \ debug \ \ lib qtmaind . lib " " shell32 . lib / LIBPATH : $ { NATIVE_INSTALLED_DIR } \ \ debug \ \ lib \ \ manual - link qtmaind . lib / LIBPATH : $ { NATIVE_INSTALLED_DIR } \ \ debug \ \ lib " _contents " $ { _contents } " ) <nl> + string ( REPLACE " tools \ \ qt5 \ \ qmlcachegen . exe " " tools \ \ qt5 - declarative \ \ qmlcachegen . exe " _contents " $ { _contents } " ) <nl> + string ( REPLACE " tools / qt5 / qmlcachegen " " tools / qt5 - declarative / qmlcachegen " _contents " $ { _contents } " ) <nl> + string ( REPLACE " debug \ \ lib \ \ Qt5Bootstrap . lib " " tools \ \ qt5 \ \ Qt5Bootstrap . lib " _contents " $ { _contents } " ) <nl> + string ( REPLACE " lib \ \ Qt5Bootstrap . lib " " tools \ \ qt5 \ \ Qt5Bootstrap . lib " _contents " $ { _contents } " ) <nl> + string ( REPLACE " Qt5Bootstrap . lib " " $ { NATIVE_INSTALLED_DIR } \ \ tools \ \ qt5 \ \ Qt5Bootstrap . lib Ole32 . lib Netapi32 . lib Advapi32 . lib $ { NATIVE_INSTALLED_DIR } \ \ lib \ \ zlib . lib Shell32 . lib " _contents " $ { _contents } " ) <nl> file ( WRITE " $ { DEBUG_MAKEFILE } " " $ { _contents } " ) <nl> endforeach ( ) <nl> endif ( ) <nl> function ( vcpkg_build_qmake ) <nl> foreach ( RELEASE_MAKEFILE $ { RELEASE_MAKEFILES } ) <nl> file ( READ " $ { RELEASE_MAKEFILE } " _contents ) <nl> string ( REPLACE " / LIBPATH : $ { NATIVE_INSTALLED_DIR } \ \ lib qtmain . lib " " shell32 . lib / LIBPATH : $ { NATIVE_INSTALLED_DIR } \ \ lib \ \ manual - link qtmain . lib / LIBPATH : $ { NATIVE_INSTALLED_DIR } \ \ lib " _contents " $ { _contents } " ) <nl> + string ( REPLACE " tools \ \ qt5 \ \ qmlcachegen . exe " " tools \ \ qt5 - declarative \ \ qmlcachegen . exe " _contents " $ { _contents } " ) <nl> + string ( REPLACE " tools / qt5 / qmlcachegen " " tools / qt5 - declarative / qmlcachegen " _contents " $ { _contents } " ) <nl> + string ( REPLACE " debug \ \ lib \ \ Qt5Bootstrap . lib " " tools \ \ qt5 \ \ Qt5Bootstrap . lib " _contents " $ { _contents } " ) <nl> + string ( REPLACE " lib \ \ Qt5Bootstrap . lib " " tools \ \ qt5 \ \ Qt5Bootstrap . lib " _contents " $ { _contents } " ) <nl> + string ( REPLACE " Qt5Bootstrap . lib " " $ { NATIVE_INSTALLED_DIR } \ \ tools \ \ qt5 \ \ Qt5Bootstrap . lib Ole32 . lib Netapi32 . lib Advapi32 . lib $ { NATIVE_INSTALLED_DIR } \ \ lib \ \ zlib . lib Shell32 . lib " _contents " $ { _contents } " ) <nl> file ( WRITE " $ { RELEASE_MAKEFILE } " " $ { _contents } " ) <nl> endforeach ( ) <nl> endif ( ) <nl> | Qt 5 . 11 and static build fixes ( ) | microsoft/vcpkg | 473d63c4edf1ab704b597abc4987372712b005f6 | 2018-10-22T17:49:16Z |
mmm a / hphp / hack / src / decl / decl . ml <nl> ppp b / hphp / hack / src / decl / decl . ml <nl> and fun_decl_in_env env f = <nl> ft_abstract = false ; <nl> ft_arity = arity ; <nl> ft_tparams = tparams ; <nl> + ft_locl_cstr = [ ] ; <nl> ft_params = params ; <nl> ft_ret = ret_ty ; <nl> } in <nl> and method_decl env m = <nl> | FVnonVariadic - > Fstandard ( arity_min , List . length m . m_params ) <nl> in <nl> let tparams = List . map m . m_tparams ( type_param env ) in <nl> + let locl_cstrs = List . map m . m_locl_cstrs ( type_param env ) in <nl> { <nl> ft_pos = fst m . m_name ; <nl> ft_deprecated = <nl> and method_decl env m = <nl> ft_abstract = m . m_abstract ; <nl> ft_arity = arity ; <nl> ft_tparams = tparams ; <nl> + ft_locl_cstr = locl_cstrs ; <nl> ft_params = params ; <nl> ft_ret = ret ; <nl> } <nl> mmm a / hphp / hack / src / decl / decl_hint . ml <nl> ppp b / hphp / hack / src / decl / decl_hint . ml <nl> and hint_ p env = function <nl> ft_abstract = false ; <nl> ft_arity = arity ; <nl> ft_tparams = [ ] ; <nl> + ft_locl_cstr = [ ] ; <nl> ft_params = paraml ; <nl> ft_ret = ret ; <nl> } <nl> mmm a / hphp / hack / src / emitter / emitter . ml <nl> ppp b / hphp / hack / src / emitter / emitter . ml <nl> let fun_to_method f = <nl> ( * Copy the rest over * ) <nl> m_name = f . f_name ; m_tparams = f . f_tparams ; m_variadic = f . f_variadic ; <nl> m_params = f . f_params ; m_body = f . f_body ; m_fun_kind = f . f_fun_kind ; <nl> - m_user_attributes = f . f_user_attributes ; m_ret = f . f_ret <nl> + m_user_attributes = f . f_user_attributes ; m_ret = f . f_ret ; m_locl_cstrs = [ ] <nl> } <nl> <nl> let emit_fun nenv env f = <nl> mmm a / hphp / hack / src / emitter / emitter_xhp . ml <nl> ppp b / hphp / hack / src / emitter / emitter_xhp . ml <nl> let named_body block = N . NamedBody { N . fnb_nast = block ; N . fnb_unsafe = false } <nl> let empty_method name = <nl> { <nl> N . m_final = false ; m_abstract = false ; m_visibility = N . Protected ; <nl> - m_tparams = [ ] ; m_variadic = N . FVnonVariadic ; <nl> + m_tparams = [ ] ; m_locl_cstrs = [ ] ; m_variadic = N . FVnonVariadic ; <nl> m_params = [ ] ; m_fun_kind = Ast . FSync ; <nl> m_user_attributes = [ ] ; m_ret = None ; <nl> m_body = named_body [ ] ; <nl> mmm a / hphp / hack / src / naming / naming . ml <nl> ppp b / hphp / hack / src / naming / naming . ml <nl> module Make ( GetLocals : GetLocals ) = struct <nl> param_name , <nl> List . map cstr_list ( constraint_ ~ forbid_this env ) <nl> <nl> + and type_locl_cstrl env locl_cstrl = <nl> + let cstrg = List . fold_left locl_cstrl ~ init : SMap . empty <nl> + ~ f : begin fun acc - > function <nl> + | ( _ , Happly ( ( pos , tn ) as _tv , [ ] ) ) , ck , ty - > <nl> + let _ , cstrl = try SMap . find tn acc with Not_found - > Pos . none , [ ] in <nl> + let cstr = constraint_ env ( ck , ty ) in <nl> + SMap . add tn ( pos , cstr : : cstrl ) acc <nl> + | ( pos , _ ) , _ , _ - > Errors . malformed_locl_cstr pos ; SMap . empty <nl> + end in <nl> + List . map ( SMap . bindings cstrg ) ~ f : ( fun ( k , ( p , vs ) ) - > Invariant , ( p , k ) , vs ) <nl> and class_use env x acc = <nl> match x with <nl> | Attributes _ - > acc <nl> module Make ( GetLocals : GetLocals ) = struct <nl> let final , abs , vis = List . fold_left ~ f : kind ~ init : acc m . m_kind in <nl> List . iter m . m_tparams check_constraint ; <nl> let tparam_l = type_paraml env m . m_tparams in <nl> + let locl_cstrs = type_locl_cstrl env m . m_constrs in <nl> let ret = Option . map m . m_ret ( hint ~ allow_retonly : true env ) in <nl> let f_kind = m . m_fun_kind in <nl> let body = ( match genv . in_mode with <nl> module Make ( GetLocals : GetLocals ) = struct <nl> N . m_abstract = abs ; <nl> N . m_name = m . Ast . m_name ; <nl> N . m_tparams = tparam_l ; <nl> + N . m_locl_cstrs = locl_cstrs ; <nl> N . m_params = paraml ; <nl> N . m_body = body ; <nl> N . m_fun_kind = f_kind ; <nl> mmm a / hphp / hack / src / naming / nast . ml <nl> ppp b / hphp / hack / src / naming / nast . ml <nl> and method_ = { <nl> m_visibility : visibility ; <nl> m_name : sid ; <nl> m_tparams : tparam list ; <nl> + m_locl_cstrs : tparam list ; <nl> m_variadic : fun_variadicity ; <nl> m_params : fun_param list ; <nl> m_body : func_body ; <nl> - m_fun_kind : Ast . fun_kind ; <nl> + m_fun_kind : Ast . fun_kind ; <nl> m_user_attributes : user_attribute list ; <nl> m_ret : hint option ; <nl> } <nl> mmm a / hphp / hack / src / typing / typing . ml <nl> ppp b / hphp / hack / src / typing / typing . ml <nl> and expr_ <nl> ft_abstract = false ; <nl> ft_arity = fun_arity ; <nl> ft_tparams = fty . ft_tparams ; <nl> + ft_locl_cstr = fty . ft_locl_cstr ; <nl> ft_params = fty . ft_params ; <nl> ft_ret = fty . ft_ret ; <nl> } in <nl> and dispatch_call p env call_type ( fpos , fun_expr as e ) el uel = <nl> ft_pos = fty . ft_pos ; <nl> ft_deprecated = None ; <nl> ft_abstract = false ; <nl> - ft_arity = Fstandard ( arity , arity ) ; ft_tparams = [ ] ; <nl> + ft_arity = Fstandard ( arity , arity ) ; <nl> + ft_tparams = [ ] ; <nl> + ft_locl_cstr = [ ] ; <nl> ft_params = List . map vars ( fun x - > ( None , x ) ) ; <nl> ft_ret = tr ; <nl> } <nl> and check_implements_tparaml ( env : Env . env ) ht = <nl> match ck with <nl> | Ast . Constraint_as - > <nl> ignore ( Type . sub_type_decl p Reason . URnone env ty cstr ) <nl> - | Ast . Constraint_eq - > raise ( TODODrphil " typing " ) <nl> + | Ast . Constraint_eq - > <nl> + ( * This code could well be unreachable , because we don ' t allow <nl> + * equality constraints on class generics . * ) <nl> + ignore ( Type . sub_type_decl p Reason . URnone env ty cstr ) ; <nl> + ignore ( Type . sub_type_decl p Reason . URnone env cstr ty ) <nl> | Ast . Constraint_super - > <nl> ignore ( Type . sub_type_decl p Reason . URnone env cstr ty ) <nl> end <nl> and method_def env m = <nl> Reason . expr_display_id_map : = IMap . empty ; <nl> Typing_hooks . dispatch_enter_method_def_hook m ; <nl> let env = Env . env_with_locals env Local_id . Map . empty in <nl> - let env = Phase . localize_generic_parameters_with_bounds env m . m_tparams <nl> + let todo = m . m_tparams @ m . m_locl_cstrs in <nl> + let env = Phase . localize_generic_parameters_with_bounds env todo <nl> ~ ety_env : ( { ( Phase . env_with_self env ) with from_class = Some CIstatic ; } ) in <nl> - TI . check_tparams_instantiable env m . m_tparams ; <nl> + TI . check_tparams_instantiable env todo ; <nl> let env = Env . set_local env this ( Env . get_self env ) in <nl> let env , ret = match m . m_ret with <nl> | None - > env , ( Reason . Rwitness ( fst m . m_name ) , Tany ) <nl> mmm a / hphp / hack / src / typing / typing_defs . ml <nl> ppp b / hphp / hack / src / typing / typing_defs . ml <nl> and shape_fields_known = <nl> ( * The type of a function AND a method . <nl> * A function has a min and max arity because of optional arguments * ) <nl> and ' phase fun_type = { <nl> - ft_pos : Pos . t ; <nl> - ft_deprecated : string option ; <nl> - ft_abstract : bool ; <nl> - ft_arity : ' phase fun_arity ; <nl> - ft_tparams : ' phase tparam list ; <nl> - ft_params : ' phase fun_params ; <nl> - ft_ret : ' phase ty ; <nl> + ft_pos : Pos . t ; <nl> + ft_deprecated : string option ; <nl> + ft_abstract : bool ; <nl> + ft_arity : ' phase fun_arity ; <nl> + ft_tparams : ' phase tparam list ; <nl> + ft_locl_cstr : ' phase tparam list ; <nl> + ft_params : ' phase fun_params ; <nl> + ft_ret : ' phase ty ; <nl> } <nl> <nl> ( * Arity information for a fun_type ; indicating the minimum number of <nl> mmm a / hphp / hack / src / typing / typing_env . ml <nl> ppp b / hphp / hack / src / typing / typing_env . ml <nl> let make_ft p params ret_ty = <nl> ft_abstract = false ; <nl> ft_arity = Fstandard ( arity , arity ) ; <nl> ft_tparams = [ ] ; <nl> + ft_locl_cstr = [ ] ; <nl> ft_params = params ; <nl> ft_ret = ret_ty ; <nl> } <nl> mmm a / hphp / hack / src / typing / typing_extends . ml <nl> ppp b / hphp / hack / src / typing / typing_extends . ml <nl> let default_constructor_ce class_ = <nl> ft_abstract = false ; <nl> ft_arity = Fstandard ( 0 , 0 ) ; <nl> ft_tparams = [ ] ; <nl> + ft_locl_cstr = [ ] ; <nl> ft_params = [ ] ; <nl> ft_ret = r , Tprim Nast . Tvoid ; <nl> } <nl> mmm a / hphp / hack / src / typing / typing_generic_constraint . ml <nl> ppp b / hphp / hack / src / typing / typing_generic_constraint . ml <nl> let check_constraint env ck cstr_ty ty = <nl> * expanded type . * ) <nl> TUtils . sub_type env ety cstr_ty <nl> | Ast . Constraint_eq - > <nl> - raise ( Core . TODODrphil " generic constraint " ) <nl> + ( * An equality constraint is the same as two commuting ` as ` <nl> + * constraints , i . e . X = Y is { X as Y , Y as X } . Thus , add <nl> + * add both expansions to the environment . We don ' t expand <nl> + * both sides of the equation simultaniously , to preserve an <nl> + * easier convergence indication . * ) <nl> + TUtils . sub_type ( TUtils . sub_type env ecstr_ty ty ) ety cstr_ty <nl> | Ast . Constraint_super - > <nl> ( * If cstr_ty is a Tvar , we don ' t want to unify that Tvar with <nl> * ty ; we merely want the constraint itself to be added to the <nl> mmm a / hphp / hack / src / typing / typing_phase . ml <nl> ppp b / hphp / hack / src / typing / typing_phase . ml <nl> and localize_ft ? ( instantiate_tparams = true ) ~ ety_env env ft = <nl> ( * Set the instantiated type parameter to initially point to unresolved , so <nl> * that it can grow and eventually be a subtype of something like " mixed " . <nl> * ) <nl> + let localize_tparam env ( var , name , cstrl ) = <nl> + let env , cstrl = List . map_env env cstrl begin fun env ( ck , ty ) - > <nl> + let env , ty = localize ~ ety_env env ty in <nl> + env , ( ck , ty ) <nl> + end in <nl> + env , ( var , name , cstrl ) <nl> + in <nl> let env , substs = <nl> if instantiate_tparams <nl> then <nl> and localize_ft ? ( instantiate_tparams = true ) ~ ety_env env ft = <nl> let env , param = localize ~ ety_env env param in <nl> env , ( name , param ) <nl> end in <nl> - let env , tparams = List . map_env env ft . ft_tparams <nl> - begin fun env ( var , name , cstrl ) - > <nl> - let env , cstrl = List . map_env env cstrl <nl> - ( fun env ( ck , ty ) - > <nl> - let env , ty = localize ~ ety_env env ty in <nl> - env , ( ck , ty ) ) in <nl> - env , ( var , name , cstrl ) <nl> - end in <nl> - <nl> + let env , tparams = List . map_env env ft . ft_tparams localize_tparam in <nl> + let env , locl_cstr = List . map_env env ft . ft_locl_cstr localize_tparam in <nl> let env , arity = match ft . ft_arity with <nl> | Fvariadic ( min , ( name , var_ty ) ) - > <nl> let env , var_ty = localize ~ ety_env env var_ty in <nl> and localize_ft ? ( instantiate_tparams = true ) ~ ety_env env ft = <nl> | Fellipsis _ | Fstandard ( _ , _ ) as x - > env , x in <nl> let env , ret = localize ~ ety_env env ft . ft_ret in <nl> env , { ft with ft_arity = arity ; ft_params = params ; <nl> - ft_ret = ret ; ft_tparams = tparams } <nl> + ft_ret = ret ; ft_tparams = tparams ; ft_locl_cstr = locl_cstr } <nl> <nl> let env_with_self env = <nl> { <nl> let localize_generic_parameters_with_bounds <nl> ~ ety_env ( env : Env . env ) ( tparams : Nast . tparam list ) = <nl> let env = Env . add_generic_parameters env tparams in <nl> let add_bound env ( ( _ , ( _ , id ) , cstrl ) : Nast . tparam ) = <nl> - List . fold_left cstrl ~ init : env ~ f : ( fun env ( ck , h ) - > <nl> + List . fold_left cstrl ~ init : env ~ f : begin fun env ( ck , h ) - > <nl> let env , ty = localize env ( Decl_hint . hint env . Env . decl_env h ) ~ ety_env in <nl> match ck with <nl> | Ast . Constraint_super - > Env . add_lower_bound env id ty <nl> + | Ast . Constraint_eq - > <nl> + let env = Env . add_upper_bound env id ty in <nl> + Env . add_lower_bound env id ty <nl> | Ast . Constraint_as - > Env . add_upper_bound env id ty <nl> - | _ - > raise ( TODODrphil " typing " ) ) in <nl> + end in <nl> List . fold_left tparams ~ f : add_bound ~ init : env <nl> <nl> <nl> mmm a / hphp / hack / src / typing / typing_print . ml <nl> ppp b / hphp / hack / src / typing / typing_print . ml <nl> module PrintClass = struct <nl> <nl> let constraint_ty = function <nl> | ( Ast . Constraint_as , ty ) - > " as " ^ ( Full . to_string_decl ty ) <nl> + | ( Ast . Constraint_eq , ty ) - > " = " ^ ( Full . to_string_decl ty ) <nl> | ( Ast . Constraint_super , ty ) - > " super " ^ ( Full . to_string_decl ty ) <nl> - | _ - > raise ( TODODrphil " typing " ) <nl> <nl> let variance = function <nl> | Ast . Covariant - > " + " <nl> mmm a / hphp / hack / src / typing / typing_subtype . ml <nl> ppp b / hphp / hack / src / typing / typing_subtype . ml <nl> let rec subtype_funs_generic ~ check_return env r_sub ft_sub r_super ft_super = <nl> match ck with <nl> | Ast . Constraint_super - > <nl> Env . add_lower_bound env name ty <nl> + | Ast . Constraint_eq - > <nl> + Env . add_upper_bound ( Env . add_lower_bound env name ty ) name ty <nl> | Ast . Constraint_as - > <nl> - Env . add_upper_bound env name ty <nl> - | _ - > raise ( TODODrphil " typing " ) ) in <nl> + Env . add_upper_bound env name ty ) in <nl> <nl> let env = List . fold_left ft_sub . ft_tparams ~ f : add_bound ~ init : env in <nl> <nl> mmm a / hphp / hack / src / typing / typing_variance . ml <nl> ppp b / hphp / hack / src / typing / typing_variance . ml <nl> type position_descr = <nl> * A < T1 , . . > , T1 is ( Rtype_argument " A " ) <nl> * ) <nl> | Rconstraint_as <nl> + | Rconstraint_eq <nl> | Rconstraint_super <nl> <nl> type position_variance = <nl> let reason_to_string ~ sign ( _ , descr , variance ) = <nl> " ` super ` constraints on method type parameters are covariant " <nl> | Rconstraint_as - > <nl> " ` as ` constraints on method type parameters are contravariant " <nl> + | Rconstraint_eq - > <nl> + " ` = ` constraints on method type parameters are invariant " <nl> <nl> let detailed_message variance pos stack = <nl> match stack with <nl> and type_ tcopt root variance env ( reason , ty ) = <nl> * however - - you can ' t imagine doing very much with a returned value that is <nl> * some ( unspecified ) supertype of a class . <nl> * ) <nl> - and constraint_ tcopt root env cstr = <nl> - match cstr with <nl> - | Ast . Constraint_as , ( r , _ as ty ) - > <nl> - let pos = Reason . to_pos r in <nl> - let reason = pos , Rconstraint_as , Pcontravariant in <nl> - type_ tcopt root ( Vcontravariant [ reason ] ) env ty <nl> - | Ast . Constraint_eq , _ - > <nl> - raise ( TODODrphil " variance " ) <nl> - | Ast . Constraint_super , ( r , _ as ty ) - > <nl> - let pos = Reason . to_pos r in <nl> - let reason = pos , Rconstraint_super , Pcovariant in <nl> - type_ tcopt root ( Vcovariant [ reason ] ) env ty <nl> + and constraint_ tcopt root env ( ck , ( r , _ as ty ) ) = <nl> + let pos = Reason . to_pos r in <nl> + let var = match ck with <nl> + | Ast . Constraint_as - > Vcontravariant [ pos , Rconstraint_as , Pcontravariant ] <nl> + | Ast . Constraint_eq - > <nl> + let reasons = [ pos , Rconstraint_eq , Pinvariant ] in <nl> + Vinvariant ( reasons , reasons ) <nl> + | Ast . Constraint_super - > Vcovariant [ pos , Rconstraint_super , Pcovariant ] <nl> + in <nl> + type_ tcopt root var env ty <nl> mmm a / hphp / hack / src / utils / core . ml <nl> ppp b / hphp / hack / src / utils / core . ml <nl> <nl> * <nl> * ) <nl> <nl> - exception TODODrphil of string <nl> - <nl> module List = struct <nl> include Core_list <nl> <nl> mmm a / hphp / hack / src / utils / errors . ml <nl> ppp b / hphp / hack / src / utils / errors . ml <nl> module NastCheck = struct <nl> let constructor_required = 3030 ( * DONT MODIFY ! ! ! ! * ) <nl> let interface_with_partial_typeconst = 3031 ( * DONT MODIFY ! ! ! ! * ) <nl> let multiple_xhp_category = 3032 ( * DONT MODIFY ! ! ! ! * ) <nl> + let malformed_locl_cstr = 3033 ( * DONT MODIFY ! ! ! ! * ) <nl> ( * EXTEND HERE WITH NEW VALUES IF NEEDED * ) <nl> end <nl> <nl> let multiple_xhp_category pos = <nl> add NastCheck . multiple_xhp_category pos <nl> " XHP classes can only contain one category declaration " <nl> <nl> + let malformed_locl_cstr pos = <nl> + add NastCheck . malformed_locl_cstr pos <nl> + " We currently only support a single generic on the LHS " <nl> + <nl> let return_in_gen p = <nl> add NastCheck . return_in_gen p <nl> ( " You cannot return a value in a generator ( a generator " ^ <nl> mmm a / hphp / hack / src / utils / errors_sig . ml <nl> ppp b / hphp / hack / src / utils / errors_sig . ml <nl> module type S = sig <nl> val generic_at_runtime : Pos . t - > unit <nl> val interface_with_partial_typeconst : Pos . t - > unit <nl> val multiple_xhp_category : Pos . t - > unit <nl> + val malformed_locl_cstr : Pos . t - > unit <nl> val not_abstract_without_typeconst : ( Pos . t * string ) - > unit <nl> val typeconst_depends_on_external_tparam : Pos . t - > Pos . t - > string - > unit <nl> val typeconst_assigned_tparam : Pos . t - > string - > unit <nl> mmm a / hphp / hack / test / typecheck / constraints / where_clause . php <nl> ppp b / hphp / hack / test / typecheck / constraints / where_clause . php <nl> public function bar < Tx > ( <nl> Tx = Vector < int > , <nl> { } <nl> <nl> - public function baz < Ta , Tb , Tc > ( ) : Foo < Ta > <nl> - where <nl> - KeyedTraversable < Ta , Tb > super Map < Tc , T > , <nl> - { <nl> - return new Foo ( ) ; <nl> - } <nl> - <nl> public function qux < Tx > ( Tx $ x ) : Tx where Tx = T { <nl> return $ x ; <nl> } <nl> new file mode 100644 <nl> index 00000000000 . . 5a204cacb29 <nl> mmm / dev / null <nl> ppp b / hphp / hack / test / typecheck / eq_constraint . php <nl> <nl> + < ? hh / / strict <nl> + <nl> + abstract class MyList < T > implements Traversable < T > { <nl> + private bool $ isSet = false ; <nl> + <nl> + public abstract function cons ( T $ x ) : MyList < T > ; <nl> + public abstract function head ( ) : T ; <nl> + public abstract function tail ( ) : MyList < T > ; <nl> + <nl> + public function compact < Tinner > ( ) : MyList < Tinner > where T = ? Tinner { <nl> + throw new Exception ( ' UNIMPLEMENTED ! ' ) ; <nl> + } <nl> + <nl> + public static function compactStatic < Tinner > ( <nl> + MyList < ? Tinner > $ xs , <nl> + ) : MyList < Tinner > { <nl> + return $ xs - > compact ( ) ; <nl> + } <nl> + <nl> + public static function fromTraversable ( Traversable < T > $ t ) : MyList < T > { <nl> + $ ret = new MyNil ( ) ; <nl> + foreach ( $ t as $ x ) { <nl> + $ ret - > cons ( $ x ) ; <nl> + } <nl> + return $ ret ; <nl> + } <nl> + <nl> + } <nl> + <nl> + class MyNil < T > extends MyList < T > { <nl> + public function cons ( T $ x ) : MyList < T > { <nl> + return new MyCons ( $ x , $ this ) ; <nl> + } <nl> + <nl> + public function head ( ) : T { <nl> + throw new Exception ( ' Can not consume from an empty list ' ) ; <nl> + } <nl> + <nl> + public function tail ( ) : MyList < T > { <nl> + throw new Exception ( ' Can not consume from an empty list ' ) ; <nl> + } <nl> + <nl> + public function compact < Tinner > ( ) : MyList < Tinner > where T = ? Tinner { <nl> + return new MyNil ( ) ; <nl> + } <nl> + <nl> + } <nl> + <nl> + class MyCons < T > extends MyList < T > { <nl> + public function __construct ( <nl> + private T $ head , <nl> + private MyList < T > $ tail , <nl> + ) { } <nl> + <nl> + public function cons ( T $ x ) : MyList < T > { <nl> + return new MyCons ( $ x , $ this ) ; <nl> + } <nl> + <nl> + public function head ( ) : T { <nl> + return $ this - > head ; <nl> + } <nl> + <nl> + public function tail ( ) : MyList < T > { <nl> + return $ this - > tail ; <nl> + } <nl> + <nl> + public function compact < Tinner > ( ) : MyList < Tinner > where T = ? Tinner { <nl> + $ compact_tail = $ this - > tail - > compact ( ) ; <nl> + return null = = = $ this - > head <nl> + ? $ compact_tail <nl> + : $ compact_tail - > cons ( $ this - > head ) ; <nl> + } <nl> + } <nl> + <nl> + class Tester { <nl> + public static function testCall ( ) : Vector < int > { <nl> + $ l = MyList : : fromTraversable ( array ( 42 , null ) ) ; <nl> + $ cle = $ l - > compact ( ) - > head ( ) ; <nl> + $ csle = MyList : : compactStatic ( $ l ) - > head ( ) ; <nl> + return Vector { $ cle , $ csle } ; <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 4269126fceb <nl> mmm / dev / null <nl> ppp b / hphp / hack / test / typecheck / eq_constraint . php . exp <nl> @ @ - 0 , 0 + 1 @ @ <nl> + No errors <nl> new file mode 100644 <nl> index 00000000000 . . e69de29bb2d <nl> | Typing for the where - clause AST additions for Hack | facebook/hhvm | 9c8611997bc708869e81dc60da8b7ba887a585ce | 2016-09-20T14:49:30Z |
mmm a / utils / build_swift / build_swift / versions . py <nl> ppp b / utils / build_swift / build_swift / versions . py <nl> def __init__ ( self , version , msg = None ) : <nl> <nl> @ functools . total_ordering <nl> class Version ( object ) : <nl> - " " " Similar to the standard distutils . versons . LooseVersion , but with a <nl> + " " " Similar to the standard distutils . version . LooseVersion , but with a <nl> little more wiggle - room for alpha characters . <nl> " " " <nl> <nl> | NFC : fix typo in build_swift / versions . py | apple/swift | 4b6bc60d23361b0801fd1d969b15b8136f0e22db | 2020-10-07T10:13:46Z |
mmm a / modules / perception / obstacle / camera / converter / geometry_camera_converter . cc <nl> ppp b / modules / perception / obstacle / camera / converter / geometry_camera_converter . cc <nl> bool GeometryCameraConverter : : Convert ( std : : vector < VisualObjectPtr > * objects ) { <nl> if ( obj - > trunc_width > 0 . 25f ) mass_center_pixel = trunc_center_pixel ; <nl> } else if ( distance_w > 40 . 0f | | distance_h > 40 . 0f | | <nl> obj - > trunc_width > 0 . 25f ) { <nl> - / / Reset alpha angle and redo again ( Model dependent issue ) <nl> + / / Reset alpha angle and do steps again <nl> obj - > distance = DecideDistance ( distance_h , distance_w , obj ) ; <nl> DecideAngle ( camera_model_ . unproject ( mass_center_pixel ) , obj ) ; <nl> deg_alpha = obj - > alpha * 180 . 0f / M_PI ; <nl> bool GeometryCameraConverter : : Convert ( std : : vector < VisualObjectPtr > * objects ) { <nl> obj - > center = camera_ray * scale ; <nl> <nl> / / Set 8 corner pixels <nl> - obj - > pts8 . resize ( 16 ) ; <nl> - if ( obj - > trunc_width < 0 . 25f & & obj - > trunc_height < 0 . 25f ) { <nl> - for ( int i = 0 ; i < 8 ; i + + ) { <nl> - obj - > pts8 [ i * 2 ] = pixel_corners_ [ i ] . x ( ) ; <nl> - obj - > pts8 [ i * 2 + 1 ] = pixel_corners_ [ i ] . y ( ) ; <nl> - } <nl> - } <nl> + SetBoxProjection ( obj ) ; <nl> } <nl> <nl> return true ; <nl> } <nl> <nl> - void GeometryCameraConverter : : SetDebug ( bool flag ) { debug_ = flag ; } <nl> - <nl> std : : string GeometryCameraConverter : : Name ( ) const { <nl> return " GeometryCameraConverter " ; <nl> } <nl> bool GeometryCameraConverter : : ConvertSingle ( <nl> camera_model_ . unproject ( * mass_center_pixel ) ; <nl> mass_center_v = MakeUnit ( mass_center_v ) ; <nl> <nl> - / / Binary search <nl> + / / Distance search <nl> * distance_w = SearchDistance ( pixel_width , true , mass_center_v ) ; <nl> * distance_h = SearchDistance ( pixel_height , false , mass_center_v ) ; <nl> <nl> bool GeometryCameraConverter : : ConvertSingle ( <nl> / / Mass center search <nl> SearchCenterDirection ( box_center_pixel , * distance_h , & mass_center_v , <nl> mass_center_pixel ) ; <nl> - <nl> - / / Binary search <nl> + / / Distance search <nl> * distance_w = SearchDistance ( pixel_width , true , mass_center_v ) ; <nl> * distance_h = SearchDistance ( pixel_height , false , mass_center_v ) ; <nl> } <nl> float GeometryCameraConverter : : DecideDistance ( const float & distance_h , <nl> const float & distance_w , <nl> VisualObjectPtr obj ) const { <nl> float distance = distance_h ; <nl> - <nl> - / / TODO ( later ) : Deal with truncation <nl> - <nl> return distance ; <nl> } <nl> <nl> void GeometryCameraConverter : : DecideAngle ( const Eigen : : Vector3f & camera_ray , <nl> } <nl> } <nl> <nl> + void GeometryCameraConverter : : SetBoxProjection ( VisualObjectPtr obj ) const { <nl> + obj - > pts8 . resize ( 16 ) ; <nl> + if ( obj - > trunc_width < 0 . 25f & & obj - > trunc_height < 0 . 25f ) { <nl> + for ( int i = 0 ; i < 8 ; i + + ) { <nl> + obj - > pts8 [ i * 2 ] = pixel_corners_ [ i ] . x ( ) ; <nl> + obj - > pts8 [ i * 2 + 1 ] = pixel_corners_ [ i ] . y ( ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> } / / namespace perception <nl> } / / namespace apollo <nl> mmm a / modules / perception / obstacle / camera / converter / geometry_camera_converter . h <nl> ppp b / modules / perception / obstacle / camera / converter / geometry_camera_converter . h <nl> class GeometryCameraConverter : public BaseCameraConverter { <nl> / / orientation <nl> bool Convert ( std : : vector < VisualObjectPtr > * objects ) override ; <nl> <nl> - void SetDebug ( bool flag ) ; <nl> - <nl> std : : string Name ( ) const override ; <nl> <nl> private : <nl> class GeometryCameraConverter : public BaseCameraConverter { <nl> void DecideAngle ( const Eigen : : Vector3f & camera_ray , <nl> VisualObjectPtr obj ) const ; <nl> <nl> + void SetBoxProjection ( VisualObjectPtr obj ) const ; <nl> + <nl> CameraDistort < float > camera_model_ ; <nl> std : : vector < Eigen : : Vector3f > corners_ ; <nl> std : : vector < Eigen : : Vector2f > pixel_corners_ ; <nl> static const int kMaxDistanceSearchDepth_ = 20 ; <nl> static const int kMaxCenterDirectionSearchDepth_ = 10 ; <nl> - bool debug_ = false ; <nl> <nl> DISALLOW_COPY_AND_ASSIGN ( GeometryCameraConverter ) ; <nl> } ; <nl> mmm a / modules / perception / obstacle / camera / detector / common / feature_extractor . cc <nl> ppp b / modules / perception / obstacle / camera / detector / common / feature_extractor . cc <nl> bool ReorgFeatureExtractor : : init ( <nl> <nl> skip_reorg_ = ref_height = = feat_height ; <nl> if ( skip_reorg_ ) { <nl> - AINFO < < " Skip reorg for " < < param . feat_blob ( ) ; <nl> + ADEBUG < < " Skip reorg for " < < param . feat_blob ( ) ; <nl> reorg_feat_blob_ = feat_blob ; <nl> return true ; <nl> } <nl> bool ReorgFeatureExtractor : : init ( <nl> auto * reorg_param = layer_param . mutable_reorg_param ( ) ; <nl> int reorg_stride = feat_height / ref_height ; <nl> reorg_param - > set_stride ( reorg_stride ) ; <nl> - AINFO < < " Use Reorg : stride = " < < reorg_param - > stride ( ) ; <nl> + ADEBUG < < " Use Reorg : stride = " < < reorg_param - > stride ( ) ; <nl> reorg_layer_ = caffe : : LayerRegistry < float > : : CreateLayer ( layer_param ) ; <nl> reorg_layer_ - > SetUp ( bottom_vec_ , top_vec_ ) ; <nl> <nl> - AINFO < < " Shape mismatch : feat_blob = " < < feat_blob <nl> - < < " , reorg_stride = " < < reorg_stride ; <nl> + ADEBUG < < " Shape mismatch : feat_blob = " < < feat_blob <nl> + < < " , reorg_stride = " < < reorg_stride ; <nl> <nl> return true ; <nl> } <nl> bool ReorgFeatureExtractor : : extract ( std : : vector < VisualObjectPtr > * objects ) { <nl> int offset = reorg_feat_blob_ - > offset ( 0 , 0 , y , x ) ; <nl> int feat_dim = reorg_feat_blob_ - > channels ( ) ; <nl> int spatial_dim = reorg_feat_blob_ - > count ( 2 ) ; <nl> - AINFO < < " feat_dim : " < < feat_dim < < " , spatial_dim : " < < spatial_dim ; <nl> + ADEBUG < < " feat_dim : " < < feat_dim < < " , spatial_dim : " < < spatial_dim ; <nl> const float * feat_data = reorg_feat_blob_ - > cpu_data ( ) + offset ; <nl> for ( int c = 0 ; c < feat_dim ; + + c ) { <nl> obj - > object_feature . push_back ( feat_data [ c * spatial_dim ] ) ; <nl> bool ROIPoolingFeatureExtractor : : init ( <nl> rp_param - > set_use_floor ( param . roi_pooling_param ( ) . use_floor ( ) ) ; <nl> rp_param - > set_spatial_scale ( static_cast < float > ( feat_height ) / input_height_ ) ; <nl> <nl> - AINFO < < " Use ROIPooling : pooled_h = " < < rp_param - > pooled_h ( ) <nl> - < < " , pooled_w = " < < rp_param - > pooled_w ( ) <nl> - < < " , spatial_scale = " < < rp_param - > spatial_scale ( ) ; <nl> + ADEBUG < < " Use ROIPooling : pooled_h = " < < rp_param - > pooled_h ( ) <nl> + < < " , pooled_w = " < < rp_param - > pooled_w ( ) <nl> + < < " , spatial_scale = " < < rp_param - > spatial_scale ( ) ; <nl> roi_pooling_layer_ = caffe : : LayerRegistry < float > : : CreateLayer ( layer_param ) ; <nl> rois_blob_ . Reshape ( { 1 , 5 } ) ; <nl> roi_pooling_layer_ - > SetUp ( bottom_vec_ , top_vec_ ) ; <nl> bool ROIPoolingFeatureExtractor : : extract ( <nl> rois_data [ 2 ] = obj - > upper_left [ 1 ] * input_height_ ; <nl> rois_data [ 3 ] = obj - > lower_right [ 0 ] * input_width_ ; <nl> rois_data [ 4 ] = obj - > lower_right [ 1 ] * input_height_ ; <nl> - AINFO < < rois_data [ 0 ] < < " " < < rois_data [ 1 ] < < " " < < rois_data [ 2 ] < < " " <nl> - < < rois_data [ 3 ] < < " " < < rois_data [ 4 ] ; <nl> + ADEBUG < < rois_data [ 0 ] < < " " < < rois_data [ 1 ] < < " " < < rois_data [ 2 ] < < " " <nl> + < < rois_data [ 3 ] < < " " < < rois_data [ 4 ] ; <nl> rois_data + = rois_blob_ . offset ( 1 ) ; <nl> } <nl> roi_pooling_layer_ - > Forward ( bottom_vec_ , top_vec_ ) ; <nl> mmm a / modules / perception / obstacle / camera / detector / yolo_camera_detector / yolo_camera_detector . cc <nl> ppp b / modules / perception / obstacle / camera / detector / yolo_camera_detector / yolo_camera_detector . cc <nl> void YoloCameraDetector : : load_intrinsic ( <nl> aligned_pixel ; <nl> height_ = static_cast < int > ( width_ * roi_ratio + aligned_pixel / 2 ) / <nl> aligned_pixel * aligned_pixel ; <nl> - AINFO < < " image_height = " < < image_height_ < < " , " <nl> - < < " image_width = " < < image_width_ < < " , " <nl> - < < " roi_ratio = " < < roi_ratio ; <nl> - AINFO < < " offset_y = " < < offset_y_ < < " , height = " < < height_ <nl> - < < " , width = " < < width_ ; <nl> + ADEBUG < < " image_height = " < < image_height_ < < " , " <nl> + < < " image_width = " < < image_width_ < < " , " <nl> + < < " roi_ratio = " < < roi_ratio ; <nl> + ADEBUG < < " offset_y = " < < offset_y_ < < " , height = " < < height_ <nl> + < < " , width = " < < width_ ; <nl> _min_2d_height / = height_ ; <nl> <nl> int roi_w = image_width_ ; <nl> int roi_h = image_height_ - offset_y_ ; <nl> <nl> - AINFO < < " roi_w = " < < roi_w < < " , " <nl> - < < " roi_h = " < < roi_h ; <nl> + ADEBUG < < " roi_w = " < < roi_w < < " , " <nl> + < < " roi_h = " < < roi_h ; <nl> <nl> int channel = 3 ; <nl> image_data_ . reset ( <nl> bool YoloCameraDetector : : init_cnn ( const string & yolo_root ) { <nl> } <nl> <nl> / / init Net <nl> - AINFO < < " model_type = " < < model_type ; <nl> + ADEBUG < < " model_type = " < < model_type ; <nl> switch ( model_type ) { <nl> case obstacle : : yolo : : ModelType : : Caffe : <nl> cnnadapter_ . reset ( new CNNCaffe ) ; <nl> bool YoloCameraDetector : : init_cnn ( const string & yolo_root ) { <nl> string track_model = feat_param . remap_model ( ) ; <nl> track_model = <nl> apollo : : common : : util : : GetAbsolutePath ( model_root , track_model ) ; <nl> - AINFO < < " Using tracking model : " < < track_model ; <nl> + ADEBUG < < " Using tracking model : " < < track_model ; <nl> projector_ . reset ( new MatrixProjector ( track_model ) ) ; <nl> } else { <nl> - AINFO < < " Using DummyProjector for tracking ! " ; <nl> + ADEBUG < < " Using DummyProjector for tracking ! " ; <nl> projector_ . reset ( new DummyProjector ) ; <nl> } <nl> extractors_ . resize ( feat_param . extractor_size ( ) ) ; <nl> bool YoloCameraDetector : : Detect ( const cv : : Mat & frame , <nl> resize ( frame ( roi ) , input_blob . get ( ) , image_data_ , 0 ) ; <nl> } <nl> pre_time . Stop ( ) ; <nl> - AINFO < < " Pre - processing : " < < pre_time . MilliSeconds ( ) < < " ms " ; <nl> + ADEBUG < < " Pre - processing : " < < pre_time . MilliSeconds ( ) < < " ms " ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / detection part / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> caffe : : Timer det_time ; <nl> det_time . Start ( ) ; <nl> cnnadapter_ - > forward ( ) ; <nl> - AINFO < < " Running detection : " < < det_time . MilliSeconds ( ) < < " ms " ; <nl> + ADEBUG < < " Running detection : " < < det_time . MilliSeconds ( ) < < " ms " ; <nl> caffe : : Timer post_time ; <nl> post_time . Start ( ) ; <nl> <nl> bool YoloCameraDetector : : Detect ( const cv : : Mat & frame , <nl> <nl> get_objects_cpu ( & temp_objects ) ; <nl> <nl> - AINFO < < " object size = " < < temp_objects . size ( ) ; <nl> + ADEBUG < < " object size = " < < temp_objects . size ( ) ; <nl> for ( int i = 0 ; i < static_cast < int > ( temp_objects . size ( ) ) ; + + i ) { <nl> VisualObjectPtr obj = ( temp_objects ) [ i ] ; <nl> - AINFO < < " type prob size for object " < < i < < " is " <nl> - < < sizeof ( obj - > type_probs ) < < " ( " < < obj < < " ) " ; <nl> - AINFO < < " prob : " < < obj - > type_probs [ static_cast < int > ( obj - > type ) ] ; <nl> - AINFO < < " object feature size for object " < < i < < " is " <nl> - < < obj - > object_feature . size ( ) ; <nl> - AINFO < < " internal type probs size for object " < < i < < " is " <nl> - < < sizeof ( obj - > internal_type_probs ) ; <nl> + ADEBUG < < " type prob size for object " < < i < < " is " <nl> + < < sizeof ( obj - > type_probs ) < < " ( " < < obj < < " ) " ; <nl> + ADEBUG < < " prob : " < < obj - > type_probs [ static_cast < int > ( obj - > type ) ] ; <nl> + ADEBUG < < " object feature size for object " < < i < < " is " <nl> + < < obj - > object_feature . size ( ) ; <nl> + ADEBUG < < " internal type probs size for object " < < i < < " is " <nl> + < < sizeof ( obj - > internal_type_probs ) ; <nl> } <nl> <nl> auto ori_blob = <nl> bool YoloCameraDetector : : Detect ( const cv : : Mat & frame , <nl> } <nl> + + total_obj_idx ; <nl> } <nl> - AINFO < < valid_obj_idx < < " of " < < total_obj_idx < < " obstacles kept " ; <nl> + ADEBUG < < valid_obj_idx < < " of " < < total_obj_idx < < " obstacles kept " ; <nl> } <nl> for ( size_t i = 0 ; i < temp_objects . size ( ) ; + + i ) { <nl> temp_objects [ i ] . reset ( ) ; <nl> } <nl> temp_objects . clear ( ) ; <nl> - AINFO < < " Post - processing : " < < post_time . MilliSeconds ( ) < < " ms " ; <nl> - AINFO < < " Number of detected obstacles : " < < objects - > size ( ) ; <nl> + ADEBUG < < " Post - processing : " < < post_time . MilliSeconds ( ) < < " ms " ; <nl> + ADEBUG < < " Number of detected obstacles : " < < objects - > size ( ) ; <nl> <nl> Extract ( objects ) ; <nl> yolo : : recover_bbox ( roi_w , roi_h , offset_y_ , objects ) ; <nl> bool YoloCameraDetector : : Detect ( const cv : : Mat & frame , <nl> obj - > score = std : : max ( obj - > score , prob ) ; <nl> } <nl> <nl> - AINFO < < " obj - " < < det_id < < " : " < < obj - > object_feature . size ( ) ; <nl> + ADEBUG < < " obj - " < < det_id < < " : " < < obj - > object_feature . size ( ) ; <nl> det_id + + ; <nl> } <nl> <nl> bool YoloCameraDetector : : get_objects_cpu ( <nl> conf_scores . insert ( std : : make_pair ( static_cast < int > ( types_ [ k ] ) , conf_score ) ) ; <nl> } <nl> if ( num_kept = = 0 ) { <nl> - AINFO < < " Couldn ' t find any detections " ; <nl> + ADEBUG < < " Couldn ' t find any detections " ; <nl> return true ; <nl> } <nl> <nl> mmm a / modules / perception / obstacle / camera / detector / yolo_camera_detector / yolo_camera_detector_test . cc <nl> ppp b / modules / perception / obstacle / camera / detector / yolo_camera_detector / yolo_camera_detector_test . cc <nl> TEST_F ( YoloCameraDetectorTest , yolo_camera_detector_roipooling_test ) { <nl> CHECK_EQ ( camera_detector - > Name ( ) , " YoloCameraDetector " ) ; <nl> <nl> const std : : string image_file = FLAGS_test_dir + " test . jpg " ; <nl> - AINFO < < " test image file : " < < image_file ; <nl> + ADEBUG < < " test image file : " < < image_file ; <nl> <nl> cv : : Mat frame = cv : : imread ( image_file , CV_LOAD_IMAGE_COLOR ) ; <nl> CHECK_NOTNULL ( frame . data ) ; <nl> TEST_F ( YoloCameraDetectorTest , yolo_camera_detector_roipooling_test ) { <nl> <nl> std : : vector < VisualObjectPtr > objects ; <nl> CHECK ( camera_detector - > Detect ( frame , options , & objects ) ) ; <nl> - AINFO < < " # objects detected = " < < objects . size ( ) ; <nl> + ADEBUG < < " # objects detected = " < < objects . size ( ) ; <nl> <nl> CHECK_EQ ( objects . size ( ) , 1 ) ; / / Related to current model and threshold <nl> <nl> int obj_idx = 0 ; <nl> for ( const auto & obj : objects ) { <nl> - AINFO < < " Obj - " < < obj_idx + + < < " : " < < GetObjectName ( obj - > type ) <nl> - < < " ( feat : " < < obj - > object_feature . size ( ) < < " - D ) " ; <nl> + ADEBUG < < " Obj - " < < obj_idx + + < < " : " < < GetObjectName ( obj - > type ) <nl> + < < " ( feat : " < < obj - > object_feature . size ( ) < < " - D ) " ; <nl> if ( obj - > object_feature . size ( ) > 0 ) { <nl> float sum_of_squares = 0 . 0 ; <nl> for ( const auto & f : obj - > object_feature ) { <nl> TEST_F ( YoloCameraDetectorTest , multi_task_test ) { <nl> CHECK_EQ ( camera_detector - > Name ( ) , " YoloCameraDetector " ) ; <nl> <nl> const std : : string image_file = FLAGS_test_dir + " test . jpg " ; <nl> - AINFO < < " test image file : " < < image_file ; <nl> + ADEBUG < < " test image file : " < < image_file ; <nl> <nl> cv : : Mat frame = cv : : imread ( image_file , CV_LOAD_IMAGE_COLOR ) ; <nl> CHECK_NOTNULL ( frame . data ) ; <nl> TEST_F ( YoloCameraDetectorTest , multi_task_test ) { <nl> std : : vector < VisualObjectPtr > objects ; <nl> cv : : Mat lane_map ( frame . rows , frame . cols , CV_32FC1 ) ; <nl> CHECK ( camera_detector - > Multitask ( frame , options , & objects , & lane_map ) ) ; <nl> - AINFO < < " # objects detected = " < < objects . size ( ) ; <nl> + ADEBUG < < " # objects detected = " < < objects . size ( ) ; <nl> <nl> CHECK_EQ ( objects . size ( ) , 1 ) ; / / Related to current model and threshold <nl> <nl> mmm a / modules / perception / obstacle / camera / transformer / flat_camera_transformer . cc <nl> ppp b / modules / perception / obstacle / camera / transformer / flat_camera_transformer . cc <nl> bool FlatCameraTransformer : : Transform ( std : : vector < VisualObjectPtr > * objects ) { <nl> if ( ! objects ) return false ; <nl> <nl> for ( auto obj_ptr : * objects ) { <nl> - / / Get 2D distance <nl> + / / Get flat 2D distance in meter <nl> float d = obj_ptr - > distance ; <nl> - float d_v = std : : abs ( kCameraHeight - obj_ptr - > height / 2 . 0f ) ; <nl> + float d_v = std : : abs ( camera2car_ ( 2 , 3 ) - obj_ptr - > height / 2 . 0f ) ; <nl> float d_flat = sqrt ( d * d - d_v * d_v ) ; <nl> <nl> - / / Get 2D vector <nl> + / / Get 2D vector of top down view <nl> Eigen : : Vector3f center = obj_ptr - > center ; <nl> Eigen : : Vector4f center_v ( center . x ( ) , center . y ( ) , center . z ( ) , 0 . 0f ) ; <nl> center_v = camera2car_ * center_v ; <nl> bool FlatCameraTransformer : : Transform ( std : : vector < VisualObjectPtr > * objects ) { <nl> <nl> / / 2D position in top - down view of ego - car space <nl> Eigen : : Vector3f pos_ground = unit_v_flat * d_flat ; <nl> - obj_ptr - > center = pos_ground + kCamera2CarFlatOffset ; <nl> + obj_ptr - > center = pos_ground + camera2car_flat_offset_ ; <nl> <nl> / / Orientation <nl> / / Camera space <nl> bool FlatCameraTransformer : : Transform ( std : : vector < VisualObjectPtr > * objects ) { <nl> bool FlatCameraTransformer : : SetExtrinsics ( <nl> const Eigen : : Matrix < double , 4 , 4 > & extrinsics ) { <nl> camera2car_ = extrinsics . cast < float > ( ) ; <nl> + camera2car_flat_offset_ = <nl> + Eigen : : Matrix < float , 3 , 1 > ( camera2car_ ( 0 , 3 ) , camera2car_ ( 1 , 3 ) , 0 . 0f ) ; <nl> return true ; <nl> } <nl> <nl> mmm a / modules / perception / obstacle / camera / transformer / flat_camera_transformer . h <nl> ppp b / modules / perception / obstacle / camera / transformer / flat_camera_transformer . h <nl> class FlatCameraTransformer : public BaseCameraTransformer { <nl> / / ( Pitch angle may differ in few degrees due to vehicle dynamics ) <nl> Eigen : : Matrix < float , 4 , 4 > camera2car_ ; <nl> <nl> - / / TODO ( later ) : Read from config of static calibration <nl> - const float kCameraHeight = 1 . 2f ; <nl> - const Eigen : : Matrix < float , 3 , 1 > kCamera2CarFlatOffset = <nl> - Eigen : : Matrix < float , 3 , 1 > ( 2 . 0f , 0 . 0f , 0 . 0f ) ; <nl> + Eigen : : Matrix < float , 3 , 1 > camera2car_flat_offset_ ; <nl> <nl> Eigen : : Matrix < float , 3 , 1 > MakeUnit ( <nl> const Eigen : : Matrix < float , 3 , 1 > & v ) const ; <nl> mmm a / modules / perception / obstacle / onboard / camera_process_subnode . cc <nl> ppp b / modules / perception / obstacle / onboard / camera_process_subnode . cc <nl> bool CameraProcessSubnode : : InitInternal ( ) { <nl> <nl> AdapterManager : : AddImageFrontCallback ( & CameraProcessSubnode : : ImgCallback , <nl> this ) ; <nl> - if ( publish_ ) <nl> + if ( publish_ ) { <nl> AdapterManager : : AddChassisCallback ( & CameraProcessSubnode : : ChassisCallback , <nl> this ) ; <nl> + } <nl> <nl> return true ; <nl> } <nl> bool CameraProcessSubnode : : InitCalibration ( ) { <nl> auto ccm = Singleton < CalibrationConfigManager > : : get ( ) ; <nl> CameraCalibrationPtr calibrator = ccm - > get_camera_calibration ( ) ; <nl> <nl> - / / calibrator - > get_image_height_width ( & image_height_ , & image_width_ ) ; <nl> + calibrator - > get_image_height_width ( & image_height_ , & image_width_ ) ; <nl> camera_to_car_ = calibrator - > get_camera_extrinsics ( ) ; <nl> intrinsics_ = calibrator - > get_camera_intrinsic ( ) ; <nl> - undistortion_handler_ = calibrator - > get_camera_undistort_handler ( ) ; <nl> return true ; <nl> } <nl> <nl> bool CameraProcessSubnode : : InitModules ( ) { <nl> <nl> void CameraProcessSubnode : : ImgCallback ( const sensor_msgs : : Image & message ) { <nl> double timestamp = message . header . stamp . toSec ( ) ; <nl> - ADEBUG < < " CameraProcessSubnode ImgCallback : " <nl> - < < " frame : " < < seq_num_ < < " timestamp : " ; <nl> + ADEBUG < < " CameraProcessSubnode ImgCallback : timestamp : " ; <nl> ADEBUG < < std : : fixed < < std : : setprecision ( 64 ) < < timestamp ; <nl> + double curr_timestamp = timestamp * 1e9 ; <nl> <nl> - if ( FLAGS_skip_camera_frame ) { <nl> - if ( timestamp_ns_ > 0 . 0 ) { <nl> - double curr_timestamp = timestamp * 1e9 ; <nl> - if ( ( curr_timestamp - timestamp_ns_ ) < ( 1e9 / FLAGS_camera_hz ) ) { <nl> - ADEBUG < < " CameraProcessSubnode Skip frame " ; <nl> - return ; <nl> - } <nl> - timestamp_ns_ = curr_timestamp ; <nl> - } else { <nl> - timestamp_ns_ = timestamp * 1e9 ; <nl> + if ( FLAGS_skip_camera_frame & & timestamp_ns_ > 0 . 0 ) { <nl> + if ( ( curr_timestamp - timestamp_ns_ ) < ( 1e9 / FLAGS_camera_hz ) ) { <nl> + ADEBUG < < " CameraProcessSubnode Skip frame " ; <nl> + return ; <nl> } <nl> - } else { <nl> - timestamp_ns_ = timestamp * 1e9 ; <nl> } <nl> <nl> - ADEBUG < < " CameraProcessSubnode ImgCallback : " <nl> - < < " frame : " < < + + seq_num_ < < " timestamp : " ; <nl> - ADEBUG < < std : : fixed < < std : : setprecision ( 64 ) < < timestamp ; <nl> + timestamp_ns_ = curr_timestamp ; <nl> + ADEBUG < < " CameraProcessSubnode Process : " < < " frame : " < < + + seq_num_ ; <nl> PERF_FUNCTION ( " CameraProcessSubnode " ) ; <nl> PERF_BLOCK_START ( ) ; <nl> <nl> void CameraProcessSubnode : : VisualObjToSensorObj ( <nl> <nl> if ( ! CameraFrameSupplement : : state_vars . initialized_ ) { <nl> CameraFrameSupplement : : state_vars . process_noise * = 10 ; <nl> - / / CameraFrameSupplement : : state_vars . measurement_noise * = 10 ; <nl> CameraFrameSupplement : : state_vars . trans_matrix . block ( 0 , 0 , 1 , 4 ) < < 1 . 0f , <nl> 0 . 0f , 0 . 33f , 0 . 0f ; <nl> CameraFrameSupplement : : state_vars . trans_matrix . block ( 1 , 0 , 1 , 4 ) < < 0 . 0f , <nl> 1 . 0f , 0 . 0f , 0 . 33f ; <nl> ADEBUG < < " state trans matrix in CameraFrameSupplement is \ n " <nl> - < < CameraFrameSupplement : : state_vars . trans_matrix ; <nl> + < < CameraFrameSupplement : : state_vars . trans_matrix < < std : : endl ; <nl> CameraFrameSupplement : : state_vars . initialized_ = true ; <nl> } <nl> <nl> void CameraProcessSubnode : : VisualObjToSensorObj ( <nl> obj - > tracking_time = vobj - > track_age ; <nl> obj - > latest_tracked_time = vobj - > last_track_timestamp ; <nl> obj - > velocity = vobj - > velocity . cast < double > ( ) ; <nl> - obj - > anchor_point = obj - > center . cast < double > ( ) ; <nl> + obj - > anchor_point = obj - > center ; <nl> + obj - > state_uncertainty = vobj - > state_uncertainty ; <nl> + <nl> ( obj - > camera_supplement ) . reset ( new CameraSupplement ( ) ) ; <nl> obj - > camera_supplement - > upper_left = vobj - > upper_left . cast < double > ( ) ; <nl> obj - > camera_supplement - > lower_right = vobj - > lower_right . cast < double > ( ) ; <nl> obj - > camera_supplement - > alpha = vobj - > alpha ; <nl> obj - > camera_supplement - > pts8 = vobj - > pts8 ; <nl> - obj - > state_uncertainty = vobj - > state_uncertainty ; <nl> - / / obj - > type_probs . assign ( vobj - > type_probs , <nl> - / / vobj - > type_probs + MAX_OBJECT_TYPE ) ; <nl> - / / obj - > camera_supplement - > pts8 . assign ( vobj - > pts8 , <nl> - / / vobj - > pts8 + 16 ) ; <nl> <nl> ( ( * sensor_objects ) - > objects ) . emplace_back ( obj ) ; <nl> } <nl> void CameraProcessSubnode : : VisualObjToSensorObj ( <nl> void CameraProcessSubnode : : PublishDataAndEvent ( <nl> const double & timestamp , const SharedDataPtr < SensorObjects > & sensor_objects , <nl> const SharedDataPtr < CameraItem > & camera_item ) { <nl> - / / std : : string key = " " ; <nl> - / / SubnodeHelper : : ProduceSharedDataKey ( timestamp , device_id_ , & key ) ; <nl> CommonSharedDataKey key ( timestamp , device_id_ ) ; <nl> cam_obj_data_ - > Add ( key , sensor_objects ) ; <nl> cam_shared_data_ - > Add ( key , camera_item ) ; <nl> void CameraProcessSubnode : : PublishDataAndEvent ( <nl> <nl> void CameraProcessSubnode : : PublishPerceptionPb ( <nl> const SharedDataPtr < SensorObjects > & sensor_objects ) { <nl> - AINFO < < " Camera publish perception pb data " ; <nl> + ADEBUG < < " Camera publish perception pb data " ; <nl> std : : lock_guard < std : : mutex > lock ( camera_mutex_ ) ; <nl> - <nl> PerceptionObstacles obstacles ; <nl> <nl> / / Header <nl> mmm a / modules / perception / obstacle / onboard / camera_process_subnode . h <nl> ppp b / modules / perception / obstacle / onboard / camera_process_subnode . h <nl> class CameraProcessSubnode : public Subnode { <nl> int32_t image_width_ = 1920 ; <nl> Eigen : : Matrix4d camera_to_car_ ; <nl> Eigen : : Matrix < double , 3 , 4 > intrinsics_ ; <nl> - CameraUndistortionPtr undistortion_handler_ ; <nl> <nl> / / Modules <nl> std : : unique_ptr < BaseCameraDetector > detector_ ; <nl> | Perception : Update camera subnode and related modules ( ) | ApolloAuto/apollo | 9ab00865fc421b259bbb86d47cef2c6fb92d1f07 | 2018-04-03T23:28:29Z |
mmm a / android / sdk / src / main / java / com / taobao / weex / utils / WXUtils . java <nl> ppp b / android / sdk / src / main / java / com / taobao / weex / utils / WXUtils . java <nl> public static double getDouble ( Object value ) { <nl> } <nl> <nl> public static boolean isTabletDevice ( ) { <nl> - return ( WXEnvironment . getApplication ( ) . getResources ( ) . getConfiguration ( ) . screenLayout & Configuration . SCREENLAYOUT_SIZE_MASK ) > = Configuration . SCREENLAYOUT_SIZE_LARGE ; <nl> + try { <nl> + return ( WXEnvironment . getApplication ( ) . getResources ( ) . getConfiguration ( ) . screenLayout & Configuration . SCREENLAYOUT_SIZE_MASK ) > = Configuration . SCREENLAYOUT_SIZE_LARGE ; <nl> + } catch ( Exception e ) { <nl> + WXLogUtils . e ( " [ WXUtils ] isTabletDevice : " + WXLogUtils . getStackTrace ( e ) ) ; <nl> + } <nl> + return true ; <nl> } <nl> } <nl> | * [ android ] bugfix | apache/incubator-weex | fd347c52c8473c48603a8de522f1bb590fb2f13f | 2016-04-29T06:18:21Z |
mmm a / test / pages / components / image - resize . vue <nl> ppp b / test / pages / components / image - resize . vue <nl> <nl> < text value = ' width > height ' > < / text > <nl> < div style = " flex - direction : row ; " > <nl> < div class = " cell " > <nl> - < image class = " wh200x100 border margin " : src = ' imgSrc ' > < / image > <nl> + < image class = " wh200x100 border margin " : src = ' imgSrc ' quality = ' original ' : placeholder = ' imgSrc ' > < / image > <nl> < / div > <nl> < div class = " cell " > <nl> - < image class = " wh200x100 border margin " resize = " cover " : src = ' imgSrc ' > < / image > <nl> + < image class = " wh200x100 border margin " : resize = " cover " : src = ' imgSrc ' > < / image > <nl> < / div > <nl> < div class = " cell " > <nl> - < image class = " wh200x100 border margin " resize = " contain " : src = ' imgSrc ' > < / image > <nl> + < image class = " wh200x100 border margin " : resize = " contain " : src = ' imgSrc ' > < / image > <nl> < / div > <nl> < / div > <nl> < text value = ' width = height ' > < / text > <nl> <nl> < / template > <nl> < script > <nl> module . exports = { <nl> - data : { <nl> - imgSrc : " http : / / gw . alicdn . com / tps / i2 / TB1DpsmMpXXXXabaXXX20ySQVXX - 512 - 512 . png_200x200 . jpg " <nl> - } , <nl> + data : function ( ) { <nl> + return { <nl> + imgSrc : " http : / / img . alicdn . com / tps / TB1zBLaPXXXXXXeXXXXXXXXXXXX - 121 - 59 . svg " , <nl> + cover : ' stretch ' , <nl> + contain : ' stretch ' , <nl> + } <nl> + } , <nl> components : { <nl> " wxc - desc " : require ( ' . . / include / wxc - desc . vue ' ) , <nl> panel : require ( ' . . / include / panel . vue ' ) , <nl> <nl> h3 : require ( ' . . / include / h3 . vue ' ) , <nl> } , <nl> methods : { <nl> + } , <nl> + created : function ( ) { <nl> + setTimeout ( ( ) = > { <nl> + this . cover = ' cover ' ; <nl> + this . contain = ' contain ' ; <nl> + this . imgSrc = ' http : / / gw . alicdn . com / tps / i2 / TB1DpsmMpXXXXabaXXX20ySQVXX - 512 - 512 . png_200x200 . jpg ' ; <nl> + } , 0 ) ; <nl> } <nl> } <nl> < / script > <nl> | * [ test ] image tc update | apache/incubator-weex | c8814a544c775897182b5a76d05430357c8d1b2e | 2017-08-31T09:05:41Z |
mmm a / tests / common . sh <nl> ppp b / tests / common . sh <nl> function build_sketches ( ) <nl> local build_arg = $ 3 <nl> local build_dir = build . tmp <nl> mkdir - p $ build_dir <nl> - rm - rf $ build_dir / * <nl> local build_cmd = " python tools / build . py - b generic - v - k - p $ PWD / $ build_dir $ build_arg " <nl> local sketches = $ ( find $ srcpath - name * . ino ) <nl> print_size_info > size . log <nl> export ARDUINO_IDE_PATH = $ arduino <nl> for sketch in $ sketches ; do <nl> + rm - rf $ build_dir / * <nl> local sketchdir = $ ( dirname $ sketch ) <nl> local sketchdirname = $ ( basename $ sketchdir ) <nl> local sketchname = $ ( basename $ sketch ) <nl> | Merge pull request from esp8266 / travis - build - fix | esp8266/Arduino | 44d22f30e327cba73d0de305f4943289654a9ac8 | 2016-03-27T21:48:39Z |
mmm a / python - package / xgboost / callback . py <nl> ppp b / python - package / xgboost / callback . py <nl> def init ( env ) : <nl> <nl> def callback ( env ) : <nl> " " " internal function " " " <nl> - score = env . evaluation_result_list [ - 1 ] [ 1 ] <nl> if not state : <nl> init ( env ) <nl> + score = env . evaluation_result_list [ - 1 ] [ 1 ] <nl> best_score = state [ ' best_score ' ] <nl> best_iteration = state [ ' best_iteration ' ] <nl> maximize_score = state [ ' maximize_score ' ] <nl> | Empty evaluation list in early stopping should produce meaningful error message ( ) | dmlc/xgboost | b7a1f22d24eb551cd9525e85c8c3ec98febcf429 | 2019-07-04T20:27:18Z |
mmm a / lib / SILGen / SILGenPoly . cpp <nl> ppp b / lib / SILGen / SILGenPoly . cpp <nl> RValue Transform : : transform ( RValue & & input , <nl> SmallVector < InitializationPtr , 4 > eltInitsBuffer ; <nl> MutableArrayRef < InitializationPtr > eltInits ; <nl> auto tupleInit = ctxt . getEmitInto ( ) ; <nl> - if ( ! ctxt . getEmitInto ( ) - > canSplitIntoTupleElements ( ) ) { <nl> + if ( ! ctxt . getEmitInto ( ) <nl> + | | ! ctxt . getEmitInto ( ) - > canSplitIntoTupleElements ( ) ) { <nl> tupleInit = nullptr ; <nl> } else { <nl> eltInits = tupleInit - > splitIntoTupleElements ( SGF , Loc , outputTupleType , <nl> new file mode 100644 <nl> index 000000000000 . . 22d26adf46ed <nl> mmm / dev / null <nl> ppp b / test / SILGen / reabstract - tuple . swift <nl> <nl> + / / RUN : % target - swift - frontend - emit - silgen - verify % s <nl> + <nl> + / / SR - 3090 : <nl> + <nl> + class Box < T > { <nl> + public let value : T <nl> + <nl> + public init ( _ value : T ) { <nl> + self . value = value <nl> + } <nl> + } <nl> + <nl> + let box = Box ( ( 22 , { ( ) in } ) ) <nl> + let foo = box . value . 0 <nl> + print ( foo ) <nl> | Merge pull request from jckarter / silgen - transform - null - context | apple/swift | 1ba8939b42b60b8141ef4ea5327d7693bb092cf5 | 2016-10-31T21:35:49Z |
mmm a / example / rnn / char_lstm . ipynb <nl> ppp b / example / rnn / char_lstm . ipynb <nl> <nl> " batch_size = batch_size , \ n " , <nl> " input_size = vocab , \ n " , <nl> " initializer = mx . initializer . Uniform ( 0 . 1 ) , \ n " , <nl> - " dropout = 0 . 5 ) \ n " <nl> + " dropout = 0 . ) \ n " <nl> ] <nl> } , <nl> { <nl> | Update char_lstm . ipynb | apache/incubator-mxnet | f606d86e83e423f501dd3954176345b2a2ac816a | 2015-10-22T03:19:11Z |
mmm a / benchmark / README . md <nl> ppp b / benchmark / README . md <nl> The following build options are available : <nl> The following build targets are available : <nl> <nl> * ` swift - benchmark - macosx - x86_64 ` <nl> + * ` swift - benchmark - macosx - arm64 ` <nl> * ` swift - benchmark - iphoneos - arm64e ` <nl> * ` swift - benchmark - iphoneos - arm64 ` <nl> * ` swift - benchmark - iphoneos - armv7 ` <nl> Build steps ( with example options ) : <nl> <nl> 1 . ` $ mkdir build ; cd build ` <nl> 2 . ` $ cmake [ path to swift src ] / benchmark - G Ninja - DSWIFT_EXEC = [ path to built swiftc ] ` <nl> - 3 . ` $ ninja swift - benchmark - macosx - x86_64 ` <nl> + 3 . ` $ ninja swift - benchmark - macosx - $ ( uname - m ) ` <nl> <nl> Benchmark binaries are placed in ` bin ` . <nl> <nl> relative to the benchmark binary at the time it was executed <nl> For example , to benchmark against a locally built ` swiftc ` , including <nl> any standard library changes in that build , you might configure using : <nl> <nl> - cmake < src > / benchmark - G Ninja - DSWIFT_EXEC = < build > / swift - macosx - x86_64 / bin / swiftc <nl> + cmake < src > / benchmark - G Ninja - DSWIFT_EXEC = < build > / swift - macosx - $ ( uname - m ) / bin / swiftc <nl> ninja swift - benchmark - iphoneos - arm64 <nl> <nl> To build against the installed Xcode , simply omit SWIFT_EXEC : <nl> swift - source $ . / swift / utils / build - script - R - B <nl> ` ` ` ` <nl> you can rebuild just the benchmarks : <nl> ` ` ` ` <nl> - swift - source $ export SWIFT_BUILD_DIR = ` pwd ` / build / Ninja - ReleaseAssert / swift - macosx - x86_64 <nl> - swift - source $ ninja - C $ { SWIFT_BUILD_DIR } swift - benchmark - macosx - x86_64 <nl> + swift - source $ export SWIFT_BUILD_DIR = ` pwd ` / build / Ninja - ReleaseAssert / swift - macosx - $ ( uname - m ) <nl> + swift - source $ ninja - C $ { SWIFT_BUILD_DIR } swift - benchmark - macosx - $ ( uname - m ) <nl> ` ` ` ` <nl> <nl> When modifying the testing infrastructure , you should verify that your changes <nl> pass all the tests : <nl> ` ` ` ` <nl> - swift - source $ . / llvm / utils / lit / lit . py - sv $ { SWIFT_BUILD_DIR } / test - macosx - x86_64 / benchmark <nl> + swift - source $ . / llvm / utils / lit / lit . py - sv $ { SWIFT_BUILD_DIR } / test - macosx - $ ( uname - m ) / benchmark <nl> ` ` ` ` <nl> mmm a / docs / DebuggingTheCompiler . md <nl> ppp b / docs / DebuggingTheCompiler . md <nl> well as cleanups / modernizations on a code - base . Swift ' s cmake invocation by <nl> default creates one of these json databases at the root path of the swift host <nl> build , for example on macOS : <nl> <nl> - $ PATH_TO_BUILD / swift - macosx - x86_64 / compile_commands . json <nl> + $ PATH_TO_BUILD / swift - macosx - $ ( uname - m ) / compile_commands . json <nl> <nl> Using this file , one invokes ` clang - tidy ` on a specific file in the codebase <nl> as follows : <nl> <nl> - clang - tidy - p = $ PATH_TO_BUILD / swift - macosx - x86_64 / compile_commands . json $ FULL_PATH_TO_FILE <nl> + clang - tidy - p = $ PATH_TO_BUILD / swift - macosx - $ ( uname - m ) / compile_commands . json $ FULL_PATH_TO_FILE <nl> <nl> One can also use shell regex to visit multiple files in the same directory . Example : <nl> <nl> - clang - tidy - p = $ PATH_TO_BUILD / swift - macosx - x86_64 / compile_commands . json $ FULL_PATH_TO_DIR / * . cpp <nl> + clang - tidy - p = $ PATH_TO_BUILD / swift - macosx - $ ( uname - m ) / compile_commands . json $ FULL_PATH_TO_DIR / * . cpp <nl> <nl> mmm a / utils / coverage / coverage - generate - data <nl> ppp b / utils / coverage / coverage - generate - data <nl> import logging <nl> import multiprocessing <nl> import os <nl> import pipes <nl> + import platform <nl> import subprocess <nl> import sys <nl> import timeit <nl> def dump_coverage_data ( merged_file ) : <nl> " " " Dump coverage data of file at path ` merged_file ` using llvm - cov " " " <nl> try : <nl> swift = os . path . join ( global_build_subdir , <nl> - ' swift - macosx - x86_64 / bin / swift ' ) <nl> + ' swift - macosx - { } / bin / swift ' . format ( platform . machine ( ) ) ) <nl> coverage_log = os . path . join ( os . path . dirname ( merged_file ) , <nl> ' coverage . log ' ) <nl> testname = os . path . basename ( os . path . dirname ( merged_file ) ) <nl> | Fix remaining hardcoded references to x86_64 | apple/swift | 33bc25be80baea456a75f92f2e651adca2313893 | 2020-12-08T17:12:23Z |
mmm a / examples / renderer_floor . py <nl> ppp b / examples / renderer_floor . py <nl> def sdf_normal ( p ) : <nl> <nl> <nl> @ ti . func <nl> - def next_hit ( pos , d , t ) : <nl> + def next_hit ( pos , d ) : <nl> closest = inf <nl> normal = ti . Vector ( [ 0 . 0 , 0 . 0 , 0 . 0 ] ) <nl> c = ti . Vector ( [ 0 . 0 , 0 . 0 , 0 . 0 ] ) <nl> <nl> - if d [ 2 ] ! = 0 : <nl> - ray_closest = - ( pos [ 2 ] + 5 . 5 ) / d [ 2 ] <nl> - if ray_closest > 0 and ray_closest < closest : <nl> - closest = ray_closest <nl> - normal = ti . Vector ( [ 0 . 0 , 0 . 0 , 1 . 0 ] ) <nl> - c = ti . Vector ( [ 0 . 6 , 0 . 7 , 0 . 7 ] ) <nl> - <nl> ray_march_dist = ray_march ( pos , d ) <nl> if ray_march_dist < dist_limit and ray_march_dist < closest : <nl> closest = ray_march_dist <nl> def next_hit ( pos , d , t ) : <nl> def render ( ) : <nl> for u , v in color_buffer : <nl> pos = camera_pos <nl> - d = ti . Vector ( [ ( <nl> - 2 * fov * ( u + ti . random ( ti . f32 ) ) / res [ 1 ] - fov * aspect_ratio - 1e - 5 ) , <nl> - 2 * fov * ( v + ti . random ( ti . f32 ) ) / res [ 1 ] - fov - 1e - 5 , <nl> - - 1 . 0 ] ) <nl> - d = ti . Matrix . normalized ( d ) <nl> - t = 0 <nl> - <nl> + <nl> contrib = ti . Vector ( [ 0 . 0 , 0 . 0 , 0 . 0 ] ) <nl> - throughput = ti . Vector ( [ 1 . 0 , 1 . 0 , 1 . 0 ] ) <nl> - <nl> - depth = 0 <nl> - <nl> - while depth < max_ray_depth : <nl> - closest , normal , c = next_hit ( pos , d , t ) <nl> - hit_pos = pos + closest * d <nl> - depth + = 1 <nl> - if normal . norm ( ) ! = 0 : <nl> - d = out_dir ( normal ) <nl> - pos = hit_pos + 1e - 4 * d <nl> - throughput * = c <nl> - <nl> - if ti . static ( use_directional_light ) : <nl> - dir_noise = ti . Vector ( <nl> - [ ti . random ( ) - 0 . 5 , <nl> - ti . random ( ) - 0 . 5 , <nl> - ti . random ( ) - 0 . 5 ] ) * light_direction_noise <nl> - direct = ti . Matrix . normalized ( <nl> - ti . Vector ( light_direction ) + dir_noise ) <nl> - dot = direct . dot ( normal ) <nl> - if dot > 0 : <nl> - dist , _ , _ = next_hit ( pos , direct , t ) <nl> - if dist > dist_limit : <nl> - contrib + = throughput * ti . Vector ( light_color ) * dot <nl> - else : # hit sky <nl> - depth = max_ray_depth <nl> + closest , normal , c = next_hit ( pos , ti . Vector ( [ 0 . 0 , 0 . 0 , - 1 . 0 ] ) ) <nl> + n = normal . norm ( ) <nl> + contrib = [ n , n , n ] <nl> <nl> color_buffer [ u , v ] = contrib <nl> <nl> | simplify renderer_floor | taichi-dev/taichi | e2e018ea379a7c16d776803932053658a9b1ef19 | 2020-01-18T05:51:03Z |
mmm a / src / net_processing . cpp <nl> ppp b / src / net_processing . cpp <nl> bool PeerManager : : SendMessages ( CNode * pto ) <nl> / / <nl> / / Message : getdata ( non - blocks ) <nl> / / <nl> - for ( const GenTxid & gtxid : m_txrequest . GetRequestable ( pto - > GetId ( ) , current_time ) ) { <nl> + std : : vector < std : : pair < NodeId , GenTxid > > expired ; <nl> + auto requestable = m_txrequest . GetRequestable ( pto - > GetId ( ) , current_time , & expired ) ; <nl> + for ( const auto & entry : expired ) { <nl> + LogPrint ( BCLog : : NET , " timeout of inflight % s % s from peer = % d \ n " , entry . second . IsWtxid ( ) ? " wtx " : " tx " , <nl> + entry . second . GetHash ( ) . ToString ( ) , entry . first ) ; <nl> + } <nl> + for ( const GenTxid & gtxid : requestable ) { <nl> if ( ! AlreadyHaveTx ( gtxid , m_mempool ) ) { <nl> LogPrint ( BCLog : : NET , " Requesting % s % s peer = % d \ n " , gtxid . IsWtxid ( ) ? " wtx " : " tx " , <nl> gtxid . GetHash ( ) . ToString ( ) , pto - > GetId ( ) ) ; <nl> mmm a / src / primitives / transaction . h <nl> ppp b / src / primitives / transaction . h <nl> template < typename Tx > static inline CTransactionRef MakeTransactionRef ( Tx & & txI <nl> / * * A generic txid reference ( txid or wtxid ) . * / <nl> class GenTxid <nl> { <nl> - const bool m_is_wtxid ; <nl> - const uint256 m_hash ; <nl> + bool m_is_wtxid ; <nl> + uint256 m_hash ; <nl> public : <nl> GenTxid ( bool is_wtxid , const uint256 & hash ) : m_is_wtxid ( is_wtxid ) , m_hash ( hash ) { } <nl> bool IsWtxid ( ) const { return m_is_wtxid ; } <nl> mmm a / src / test / fuzz / txrequest . cpp <nl> ppp b / src / test / fuzz / txrequest . cpp <nl> class Tester <nl> <nl> / / ! list of ( sequence number , txhash , is_wtxid ) tuples . <nl> std : : vector < std : : tuple < uint64_t , int , bool > > result ; <nl> + std : : vector < std : : pair < NodeId , GenTxid > > expected_expired ; <nl> for ( int txhash = 0 ; txhash < MAX_TXHASHES ; + + txhash ) { <nl> / / Mark any expired REQUESTED announcements as COMPLETED . <nl> for ( int peer2 = 0 ; peer2 < MAX_PEERS ; + + peer2 ) { <nl> Announcement & ann2 = m_announcements [ txhash ] [ peer2 ] ; <nl> if ( ann2 . m_state = = State : : REQUESTED & & ann2 . m_time < = m_now ) { <nl> + expected_expired . emplace_back ( peer2 , GenTxid { ann2 . m_is_wtxid , TXHASHES [ txhash ] } ) ; <nl> ann2 . m_state = State : : COMPLETED ; <nl> break ; <nl> } <nl> class Tester <nl> } <nl> / / Sort the results by sequence number . <nl> std : : sort ( result . begin ( ) , result . end ( ) ) ; <nl> + std : : sort ( expected_expired . begin ( ) , expected_expired . end ( ) ) ; <nl> <nl> / / Compare with TxRequestTracker ' s implementation . <nl> - const auto actual = m_tracker . GetRequestable ( peer , m_now ) ; <nl> + std : : vector < std : : pair < NodeId , GenTxid > > expired ; <nl> + const auto actual = m_tracker . GetRequestable ( peer , m_now , & expired ) ; <nl> + std : : sort ( expired . begin ( ) , expired . end ( ) ) ; <nl> + assert ( expired = = expected_expired ) ; <nl> <nl> m_tracker . PostGetRequestableSanityCheck ( m_now ) ; <nl> assert ( result . size ( ) = = actual . size ( ) ) ; <nl> mmm a / src / test / txrequest_tests . cpp <nl> ppp b / src / test / txrequest_tests . cpp <nl> struct Runner <nl> <nl> / * * Which txhashes have been assigned already ( to prevent reuse ) . * / <nl> std : : set < uint256 > txhashset ; <nl> + <nl> + / * * Which ( peer , gtxid ) combinations are known to be expired . These need to be accumulated here instead of <nl> + * checked directly in the GetRequestable return value to avoid introducing a dependency between the various <nl> + * parallel tests . * / <nl> + std : : multiset < std : : pair < NodeId , GenTxid > > expired ; <nl> } ; <nl> <nl> std : : chrono : : microseconds RandomTime8s ( ) { return std : : chrono : : microseconds { 1 + InsecureRandBits ( 23 ) } ; } <nl> class Scenario <nl> const auto now = m_now ; <nl> assert ( offset . count ( ) < = 0 ) ; <nl> runner . actions . emplace_back ( m_now , [ = , & runner ] ( ) { <nl> - auto ret = runner . txrequest . GetRequestable ( peer , now + offset ) ; <nl> + std : : vector < std : : pair < NodeId , GenTxid > > expired_now ; <nl> + auto ret = runner . txrequest . GetRequestable ( peer , now + offset , & expired_now ) ; <nl> + for ( const auto & entry : expired_now ) runner . expired . insert ( entry ) ; <nl> runner . txrequest . SanityCheck ( ) ; <nl> runner . txrequest . PostGetRequestableSanityCheck ( now + offset ) ; <nl> size_t total = candidates + inflight + completed ; <nl> class Scenario <nl> } ) ; <nl> } <nl> <nl> + / * * Verify that an announcement for gtxid by peer has expired some time before this check is scheduled . <nl> + * <nl> + * Every expected expiration should be accounted for through exactly one call to this function . <nl> + * / <nl> + void CheckExpired ( NodeId peer , GenTxid gtxid ) <nl> + { <nl> + const auto & testname = m_testname ; <nl> + auto & runner = m_runner ; <nl> + runner . actions . emplace_back ( m_now , [ = , & runner ] ( ) { <nl> + auto it = runner . expired . find ( std : : pair < NodeId , GenTxid > { peer , gtxid } ) ; <nl> + BOOST_CHECK_MESSAGE ( it ! = runner . expired . end ( ) , " [ " + testname + " ] missing expiration " ) ; <nl> + if ( it ! = runner . expired . end ( ) ) runner . expired . erase ( it ) ; <nl> + } ) ; <nl> + } <nl> + <nl> / * * Generate a random txhash , whose priorities for certain peers are constrained . <nl> * <nl> * For example , NewTxHash ( { { p1 , p2 , p3 } , { p2 , p4 , p5 } } ) will generate a txhash T such that both : <nl> void BuildSingleTest ( Scenario & scenario , int config ) <nl> scenario . Check ( peer , { } , 0 , 1 , 0 , " s7 " ) ; <nl> scenario . AdvanceTime ( MICROSECOND ) ; <nl> scenario . Check ( peer , { } , 0 , 0 , 0 , " s8 " ) ; <nl> + scenario . CheckExpired ( peer , gtxid ) ; <nl> return ; <nl> } else { <nl> scenario . AdvanceTime ( std : : chrono : : microseconds { InsecureRandRange ( expiry . count ( ) ) } ) ; <nl> void BuildSingleTest ( Scenario & scenario , int config ) <nl> } <nl> } <nl> <nl> - if ( InsecureRandBool ( ) ) scenario . AdvanceTime ( RandomTime8s ( ) ) ; <nl> if ( config & 4 ) { / / The peer will go offline <nl> scenario . DisconnectedPeer ( peer ) ; <nl> } else { / / The transaction is no longer needed <nl> void BuildWtxidTest ( Scenario & scenario , int config ) <nl> if ( config & 2 ) { <nl> scenario . Check ( peerT , { } , 0 , 0 , 1 , " w9 " ) ; <nl> scenario . Check ( peerW , { wtxid } , 1 , 0 , 0 , " w10 " ) ; <nl> + scenario . CheckExpired ( peerT , txid ) ; <nl> } else { <nl> scenario . Check ( peerT , { txid } , 1 , 0 , 0 , " w11 " ) ; <nl> scenario . Check ( peerW , { } , 0 , 0 , 1 , " w12 " ) ; <nl> + scenario . CheckExpired ( peerW , wtxid ) ; <nl> } <nl> <nl> / / If a good transaction with either that hash as wtxid or txid arrives , both <nl> void BuildTimeBackwardsTest ( Scenario & scenario ) <nl> scenario . AdvanceTime ( expiry - scenario . Now ( ) ) ; <nl> scenario . Check ( peer1 , { } , 0 , 0 , 1 , " r9 " ) ; <nl> scenario . Check ( peer2 , { gtxid } , 1 , 0 , 0 , " r10 " ) ; / / Request goes back to peer2 . <nl> + scenario . CheckExpired ( peer1 , gtxid ) ; <nl> scenario . Check ( peer1 , { } , 0 , 0 , 1 , " r11 " , - MICROSECOND ) ; / / Going back does not unexpire . <nl> scenario . Check ( peer2 , { gtxid } , 1 , 0 , 0 , " r12 " , - MICROSECOND ) ; <nl> <nl> void BuildWeirdRequestsTest ( Scenario & scenario ) <nl> scenario . AdvanceTime ( expiryA - scenario . Now ( ) ) ; <nl> scenario . Check ( peer1 , { } , 0 , 0 , 1 , " q12 " ) ; <nl> scenario . Check ( peer2 , { gtxid2 , gtxid1 } , 2 , 0 , 0 , " q13 " ) ; <nl> + scenario . CheckExpired ( peer1 , gtxid1 ) ; <nl> <nl> / / Requesting it yet again from peer1 doesn ' t do anything , as it ' s already COMPLETED . <nl> if ( InsecureRandBool ( ) ) scenario . AdvanceTime ( RandomTime8s ( ) ) ; <nl> void TestInterleavedScenarios ( ) <nl> } <nl> <nl> BOOST_CHECK_EQUAL ( runner . txrequest . Size ( ) , 0U ) ; <nl> + BOOST_CHECK ( runner . expired . empty ( ) ) ; <nl> } <nl> <nl> } / / namespace <nl> mmm a / src / txrequest . cpp <nl> ppp b / src / txrequest . cpp <nl> std : : map < uint256 , TxHashInfo > ComputeTxHashInfo ( const Index & index , const Priori <nl> return ret ; <nl> } <nl> <nl> + GenTxid ToGenTxid ( const Announcement & ann ) <nl> + { <nl> + return { ann . m_is_wtxid , ann . m_txhash } ; <nl> + } <nl> + <nl> } / / namespace <nl> <nl> / * * Actual implementation for TxRequestTracker ' s data structure . * / <nl> class TxRequestTracker : : Impl { <nl> / / ! - REQUESTED annoucements with expiry < = now are turned into COMPLETED . <nl> / / ! - CANDIDATE_DELAYED announcements with reqtime < = now are turned into CANDIDATE_ { READY , BEST } . <nl> / / ! - CANDIDATE_ { READY , BEST } announcements with reqtime > now are turned into CANDIDATE_DELAYED . <nl> - void SetTimePoint ( std : : chrono : : microseconds now ) <nl> + void SetTimePoint ( std : : chrono : : microseconds now , std : : vector < std : : pair < NodeId , GenTxid > > * expired ) <nl> { <nl> + if ( expired ) expired - > clear ( ) ; <nl> + <nl> / / Iterate over all CANDIDATE_DELAYED and REQUESTED from old to new , as long as they ' re in the past , <nl> / / and convert them to CANDIDATE_READY and COMPLETED respectively . <nl> while ( ! m_index . empty ( ) ) { <nl> class TxRequestTracker : : Impl { <nl> if ( it - > m_state = = State : : CANDIDATE_DELAYED & & it - > m_time < = now ) { <nl> PromoteCandidateReady ( m_index . project < ByTxHash > ( it ) ) ; <nl> } else if ( it - > m_state = = State : : REQUESTED & & it - > m_time < = now ) { <nl> + if ( expired ) expired - > emplace_back ( it - > m_peer , ToGenTxid ( * it ) ) ; <nl> MakeCompleted ( m_index . project < ByTxHash > ( it ) ) ; <nl> } else { <nl> break ; <nl> class TxRequestTracker : : Impl { <nl> } <nl> <nl> / / ! Find the GenTxids to request now from peer . <nl> - std : : vector < GenTxid > GetRequestable ( NodeId peer , std : : chrono : : microseconds now ) <nl> + std : : vector < GenTxid > GetRequestable ( NodeId peer , std : : chrono : : microseconds now , <nl> + std : : vector < std : : pair < NodeId , GenTxid > > * expired ) <nl> { <nl> / / Move time . <nl> - SetTimePoint ( now ) ; <nl> + SetTimePoint ( now , expired ) ; <nl> <nl> / / Find all CANDIDATE_BEST announcements for this peer . <nl> std : : vector < const Announcement * > selected ; <nl> class TxRequestTracker : : Impl { <nl> std : : vector < GenTxid > ret ; <nl> ret . reserve ( selected . size ( ) ) ; <nl> std : : transform ( selected . begin ( ) , selected . end ( ) , std : : back_inserter ( ret ) , [ ] ( const Announcement * ann ) { <nl> - return GenTxid { ann - > m_is_wtxid , ann - > m_txhash } ; <nl> + return ToGenTxid ( * ann ) ; <nl> } ) ; <nl> return ret ; <nl> } <nl> void TxRequestTracker : : ReceivedResponse ( NodeId peer , const uint256 & txhash ) <nl> m_impl - > ReceivedResponse ( peer , txhash ) ; <nl> } <nl> <nl> - std : : vector < GenTxid > TxRequestTracker : : GetRequestable ( NodeId peer , std : : chrono : : microseconds now ) <nl> + std : : vector < GenTxid > TxRequestTracker : : GetRequestable ( NodeId peer , std : : chrono : : microseconds now , <nl> + std : : vector < std : : pair < NodeId , GenTxid > > * expired ) <nl> { <nl> - return m_impl - > GetRequestable ( peer , now ) ; <nl> + return m_impl - > GetRequestable ( peer , now , expired ) ; <nl> } <nl> <nl> uint64_t TxRequestTracker : : ComputePriority ( const uint256 & txhash , NodeId peer , bool preferred ) const <nl> mmm a / src / txrequest . h <nl> ppp b / src / txrequest . h <nl> class TxRequestTracker { <nl> * <nl> * It does the following : <nl> * - Convert all REQUESTED announcements ( for all txhashes / peers ) with ( expiry < = now ) to COMPLETED ones . <nl> + * These are returned in expired , if non - nullptr . <nl> * - Requestable announcements are selected : CANDIDATE announcements from the specified peer with <nl> * ( reqtime < = now ) for which no existing REQUESTED announcement with the same txhash from a different peer <nl> * exists , and for which the specified peer is the best choice among all ( reqtime < = now ) CANDIDATE <nl> class TxRequestTracker { <nl> * out of order : if multiple dependent transactions are announced simultaneously by one peer , and end up <nl> * being requested from them , the requests will happen in announcement order . <nl> * / <nl> - std : : vector < GenTxid > GetRequestable ( NodeId peer , std : : chrono : : microseconds now ) ; <nl> + std : : vector < GenTxid > GetRequestable ( NodeId peer , std : : chrono : : microseconds now , <nl> + std : : vector < std : : pair < NodeId , GenTxid > > * expired = nullptr ) ; <nl> <nl> / * * Marks a transaction as requested , with a specified expiry . <nl> * <nl> | Report and verify expirations | bitcoin/bitcoin | fd9a0060f028a4c01bd88f58777dea34bdcbafd1 | 2020-10-12T19:14:53Z |
mmm a / xbmc / lib / UnrarXLib / SmartStr . h <nl> ppp b / xbmc / lib / UnrarXLib / SmartStr . h <nl> <nl> <nl> class CSmartStr <nl> { <nl> - char * m_szPtr ; <nl> + char * m_szPtr ; <nl> public : <nl> - CSmartStr ( int iCount ) : m_szPtr ( NULL ) <nl> - { <nl> - if ( iCount ) <nl> - { <nl> - m_szPtr = new char [ iCount ] ; <nl> - } <nl> - } <nl> - ~ CSmartStr ( ) <nl> - { <nl> - if ( m_szPtr ) <nl> - { <nl> - delete [ ] m_szPtr ; <nl> - } <nl> - } <nl> - operator char * ( ) { return m_szPtr ; } <nl> + CSmartStr ( int iCount ) : m_szPtr ( NULL ) <nl> + { <nl> + if ( iCount ) <nl> + { <nl> + m_szPtr = new char [ iCount ] ; <nl> + } <nl> + } <nl> + ~ CSmartStr ( ) <nl> + { <nl> + if ( m_szPtr ) <nl> + { <nl> + delete [ ] m_szPtr ; <nl> + } <nl> + } <nl> + operator char * ( ) { return m_szPtr ; } <nl> } ; <nl> <nl> class CSmartStrW <nl> { <nl> - wchar * m_szPtr ; <nl> + wchar * m_szPtr ; <nl> public : <nl> - CSmartStrW ( int iCount ) : m_szPtr ( NULL ) <nl> - { <nl> - if ( iCount ) <nl> - { <nl> - m_szPtr = new wchar [ iCount ] ; <nl> - } <nl> - } <nl> - ~ CSmartStrW ( ) <nl> - { <nl> - if ( m_szPtr ) <nl> - { <nl> - delete [ ] m_szPtr ; <nl> - } <nl> - } <nl> - operator wchar * ( ) { return m_szPtr ; } <nl> + CSmartStrW ( int iCount ) : m_szPtr ( NULL ) <nl> + { <nl> + if ( iCount ) <nl> + { <nl> + m_szPtr = new wchar [ iCount ] ; <nl> + } <nl> + } <nl> + ~ CSmartStrW ( ) <nl> + { <nl> + if ( m_szPtr ) <nl> + { <nl> + delete [ ] m_szPtr ; <nl> + } <nl> + } <nl> + operator wchar * ( ) { return m_szPtr ; } <nl> } ; <nl> <nl> | Cosmetic : Tabs to spaces in SmartStr . h | xbmc/xbmc | 3f6c28631e579a5a770003faa4e36b30249b8984 | 2010-01-02T04:35:09Z |
mmm a / tools / distpackages / build_deb_packages . sh <nl> ppp b / tools / distpackages / build_deb_packages . sh <nl> mkdir - p $ deb_dest <nl> <nl> version = ' 0 . 8 . 0 . 0 ' <nl> <nl> - arch = ` uname - p ` <nl> + if [ - f / . dockerinit ] ; then <nl> + # We ' re in Docker where uname - p returns " unknown " . <nl> + arch = x86_64 <nl> + else <nl> + arch = ` uname - p ` <nl> + fi <nl> + <nl> if [ $ arch ! = " x86_64 " ] <nl> then <nl> echo Unsupported architecture . <nl> do <nl> # create symlinks to shared libraries <nl> for libname in $ arch_lib_dir / * . a <nl> do <nl> - base = ` basename - s . a $ libname ` <nl> + base = ` basename $ libname . a ` <nl> ln - s $ base . so . $ version $ arch_lib_dir / $ base . so <nl> done <nl> fi <nl> <nl> # Adjust mode for some files in the package <nl> find $ tmp_dir / $ pkg_name - type d | xargs chmod 755 <nl> + find $ tmp_dir / $ pkg_name - type d | xargs chmod a - s <nl> find $ tmp_dir / $ pkg_name - type f | xargs chmod 644 <nl> chmod 755 $ tmp_dir / $ pkg_name / DEBIAN / { postinst , postrm } <nl> <nl> | Fixes to build_deb_packages script to allow running on Docker | grpc/grpc | 6b2b05ee1cf977c1fc3594d2c8f9dffce3db499e | 2015-02-21T23:09:00Z |
mmm a / readme . txt <nl> ppp b / readme . txt <nl> <nl> > Installation guide : <nl> 1 ) Download the latest ' qt_base_XXX . rar ' <nl> 2 ) Download the latest ' bin_base_XXX . rar ' <nl> - 3 ) Download the latest ' release_ ? . rar ' <nl> + 3 ) Download the latest ' release_xxx . rar ' <nl> 4 ) ( Optional ) Download the latest ' help_XXX . rar ' <nl> 5 ) Extract all in the same directory <nl> - 6 ) Run ' bin \ x64 \ x64_dbg . exe ' or ' bin \ x64 \ x64_dbg . exe ' <nl> + 6 ) Run ' bin \ x64 \ x64_dbg . exe ' or ' bin \ x32 \ x32_dbg . exe ' <nl> <nl> > Overview : <nl> This is a x64 / x32 debugger that is currently in active development . <nl> without having to update the code of the other parts . <nl> - user databases for labels / comments / breakpoints / bookmarks ( * . dd64 or * . dd32 files ) <nl> - easy context menu in disassembly ( to set breakpoints etc ) <nl> - plugin support <nl> + - ( manual ) function analysis <nl> + - easily follow calls / jumps / ret ( press ENTER in when selecting ) <nl> + - ( buggy ) dynamic commenting <nl> <nl> > Known bugs : <nl> - memory breakpoints sometimes fail ( TitanEngine bug ) <nl> | PROJECT : updated readme | x64dbg/x64dbg | 4dcc8bfb6257997f33acf9a7d8eb2c180ac9f286 | 2013-12-28T01:45:44Z |
mmm a / tests / queries / 0_stateless / 01428_hash_set_nan_key . sql <nl> ppp b / tests / queries / 0_stateless / 01428_hash_set_nan_key . sql <nl> SELECT DISTINCT number % inf FROM numbers ( 1000 ) ; <nl> <nl> SELECT topKWeightedMerge ( 1 ) ( initializeAggregation ( ' topKWeightedState ( 1 ) ' , nan , arrayJoin ( range ( 10 ) ) ) ) ; <nl> <nl> - select number % inf k from numbers ( 256 ) group by k ; <nl> + select number % inf k from numbers ( 256 ) group by k order by k ; <nl> <nl> - SELECT uniqExact ( reinterpretAsFloat64 ( reinterpretAsFixedString ( reinterpretAsUInt64 ( reinterpretAsFixedString ( nan ) ) + number ) ) ) FROM numbers ( 10 ) ; <nl> + SELECT uniqExact ( reinterpretAsFloat64 ( reinterpretAsFixedString ( reinterpretAsUInt64 ( reinterpretAsFixedString ( nan ) ) + number ) ) ) n FROM numbers ( 10 ) order by n ; <nl> | Fixed result order in hash set test | ClickHouse/ClickHouse | f9ef5e2833a89de7cb312eec04c18428e284b287 | 2020-08-11T16:23:06Z |
mmm a / arangod / Aql / Optimizer . cpp <nl> ppp b / arangod / Aql / Optimizer . cpp <nl> Optimizer : : Optimizer ( ) { <nl> <nl> / / remove filters from the query that are not necessary at all <nl> / / filters that are always true will be removed entirely <nl> - / / filters that are always false will get a hint <nl> + / / filters that are always false will be replaced with a NoResults node <nl> registerRule ( removeUnnecessaryFiltersRule , 10000 ) ; <nl> <nl> / / move calculations up the dependency chain ( to pull them out of inner loops etc . ) <nl> mmm a / arangod / Aql / OptimizerRules . cpp <nl> ppp b / arangod / Aql / OptimizerRules . cpp <nl> using Json = triagens : : basics : : Json ; <nl> / / / @ brief remove all unnecessary filters <nl> / / / this rule modifies the plan in place : <nl> / / / - filters that are always true are removed completely <nl> - / / / - filters that are always false will be removed plus their dependent nodes <nl> + / / / - filters that are always false will be replaced by a NoResults node <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> int triagens : : aql : : removeUnnecessaryFiltersRule ( Optimizer * opt , <nl> int triagens : : aql : : removeUnnecessaryFiltersRule ( Optimizer * opt , <nl> } <nl> else { <nl> / / filter is always false <nl> - / / TODO : insert a NoResults node below it <nl> - / / auto noResultsNode = plan - > registerNode ( new NoResultsNode ( plan - > nextId ( ) ) ) ; <nl> - / / TRI_ASSERT ( noResultsNode ! = nullptr ) ; <nl> + / / now insert a NoResults node below it <nl> + auto & & parents = n - > getParents ( ) ; <nl> + TRI_ASSERT ( parents . size ( ) = = 1 ) ; <nl> + <nl> + auto noResults = new NoResultsNode ( plan - > nextId ( ) ) ; <nl> + plan - > registerNode ( noResults ) ; <nl> + plan - > replaceNode ( n , noResults , parents [ 0 ] ) ; <nl> } <nl> } <nl> <nl> if ( ! toUnlink . empty ( ) ) { <nl> - std : : cout < < " Removing " < < toUnlink . size ( ) < < " unnecessary " <nl> - " nodes . . . " < < std : : endl ; <nl> plan - > unlinkNodes ( toUnlink ) ; <nl> } <nl> <nl> | fixed filter removal optimizer rule | arangodb/arangodb | 1d7807117630d7483c032f7c35f23e2f4243cf37 | 2014-08-21T11:57:08Z |
mmm a / cocos2dx / Android . mk <nl> ppp b / cocos2dx / Android . mk <nl> text_input_node / CCTextFieldTTF . cpp \ <nl> textures / CCTexture2D . cpp \ <nl> textures / CCTextureAtlas . cpp \ <nl> textures / CCTextureCache . cpp \ <nl> + textures / CCTextureETC . cpp \ <nl> textures / CCTexturePVR . cpp \ <nl> tilemap_parallax_nodes / CCParallaxNode . cpp \ <nl> tilemap_parallax_nodes / CCTMXLayer . cpp \ <nl> new file mode 100644 <nl> index 000000000000 . . a21cd23af28e <nl> mmm / dev / null <nl> ppp b / cocos2dx / platform / android / java / src / org / cocos2dx / lib / Cocos2dxETCLoader . java <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> + package org . cocos2dx . lib ; <nl> + <nl> + import java . io . FileInputStream ; <nl> + import java . io . InputStream ; <nl> + import java . nio . ByteBuffer ; <nl> + import java . nio . ByteOrder ; <nl> + <nl> + import android . content . Context ; <nl> + import android . content . res . AssetManager ; <nl> + import android . opengl . ETC1Util ; <nl> + import android . util . Log ; <nl> + <nl> + public class Cocos2dxETCLoader { <nl> + private static final String ASSETS_PATH = " assets / " ; <nl> + private static Context context ; <nl> + <nl> + public static boolean loadTexture ( String filePath ) { <nl> + if ( ! ETC1Util . isETC1Supported ( ) ) { <nl> + return false ; <nl> + } <nl> + <nl> + if ( filePath . length ( ) = = 0 ) { <nl> + return false ; <nl> + } <nl> + <nl> + / / Create ETC1Texture <nl> + InputStream inputStream = null ; <nl> + ETC1Util . ETC1Texture texture = null ; <nl> + AssetManager assetManager = null ; <nl> + try { <nl> + if ( filePath . charAt ( 0 ) = = ' / ' ) { <nl> + / / absolute path <nl> + inputStream = new FileInputStream ( filePath ) ; <nl> + } else { <nl> + / / remove prefix : " assets / " <nl> + if ( filePath . startsWith ( ASSETS_PATH ) ) { <nl> + filePath = filePath . substring ( ASSETS_PATH . length ( ) ) ; <nl> + } <nl> + assetManager = context . getAssets ( ) ; <nl> + inputStream = assetManager . open ( filePath ) ; <nl> + } <nl> + <nl> + texture = ETC1Util . createTexture ( inputStream ) ; <nl> + inputStream . close ( ) ; <nl> + assetManager . close ( ) ; <nl> + } catch ( Exception e ) { <nl> + Log . d ( " Cocos2dx " , " Unable to create texture for " + filePath ) ; <nl> + <nl> + texture = null ; <nl> + } <nl> + <nl> + if ( texture ! = null ) { <nl> + try { <nl> + int width = texture . getWidth ( ) ; <nl> + int height = texture . getHeight ( ) ; <nl> + <nl> + final byte [ ] data = new byte [ width * height * 3 ] ; <nl> + final ByteBuffer buf = ByteBuffer . wrap ( data ) ; <nl> + buf . order ( ByteOrder . nativeOrder ( ) ) ; <nl> + buf . put ( texture . getData ( ) ) ; <nl> + <nl> + nativeSetTextureInfo ( width , <nl> + height , <nl> + data ) ; <nl> + } catch ( Exception e ) <nl> + { <nl> + Log . d ( " invoke native function error " , e . toString ( ) ) ; <nl> + } <nl> + <nl> + return true ; <nl> + } else { <nl> + return false ; <nl> + } <nl> + } <nl> + <nl> + public static void setContext ( Context context ) { <nl> + Cocos2dxETCLoader . context = context ; <nl> + } <nl> + <nl> + private static native void nativeSetTextureInfo ( final int width , final int height , final byte [ ] data ) ; <nl> + } <nl> mmm a / cocos2dx / platform / android / java / src / org / cocos2dx / lib / Cocos2dxHelper . java <nl> ppp b / cocos2dx / platform / android / java / src / org / cocos2dx / lib / Cocos2dxHelper . java <nl> public static void init ( final Context pContext , final Cocos2dxHelperListener pCo <nl> Cocos2dxHelper . sCocos2dSound = new Cocos2dxSound ( pContext ) ; <nl> Cocos2dxHelper . sAssetManager = pContext . getAssets ( ) ; <nl> Cocos2dxBitmap . setContext ( pContext ) ; <nl> + Cocos2dxETCLoader . setContext ( pContext ) ; <nl> } <nl> <nl> / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> mmm a / cocos2dx / proj . ios / cocos2dx . xcodeproj / project . pbxproj . REMOVED . git - id <nl> ppp b / cocos2dx / proj . ios / cocos2dx . xcodeproj / project . pbxproj . REMOVED . git - id <nl> @ @ - 1 + 1 @ @ <nl> - 89741f647de6b40616d5c45625fcd3c2d8e9d20a <nl> \ No newline at end of file <nl> + 3a74fba6589c007b54123dfc2d385ab7d3d81919 <nl> \ No newline at end of file <nl> mmm a / cocos2dx / textures / CCTexture2D . cpp <nl> ppp b / cocos2dx / textures / CCTexture2D . cpp <nl> THE SOFTWARE . <nl> # include " support / ccUtils . h " <nl> # include " platform / CCPlatformMacros . h " <nl> # include " textures / CCTexturePVR . h " <nl> + # include " textures / CCTextureETC . h " <nl> # include " CCDirector . h " <nl> # include " shaders / CCGLProgram . h " <nl> # include " shaders / ccGLStateCache . h " <nl> bool CCTexture2D : : initWithPVRFile ( const char * file ) <nl> return bRet ; <nl> } <nl> <nl> + bool CCTexture2D : : initWithETCFile ( const char * file ) <nl> + { <nl> + bool bRet = false ; <nl> + / / nothing to do with CCObject : : init <nl> + <nl> + CCTextureETC * etc = new CCTextureETC ; <nl> + bRet = etc - > initWithFile ( file ) ; <nl> + <nl> + if ( bRet ) <nl> + { <nl> + m_uName = etc - > getName ( ) ; <nl> + m_fMaxS = 1 . 0f ; <nl> + m_fMaxT = 1 . 0f ; <nl> + m_uPixelsWide = etc - > getWidth ( ) ; <nl> + m_uPixelsHigh = etc - > getHeight ( ) ; <nl> + m_tContentSize = CCSizeMake ( ( float ) m_uPixelsWide , ( float ) m_uPixelsHigh ) ; <nl> + m_bHasPremultipliedAlpha = true ; <nl> + <nl> + etc - > release ( ) ; <nl> + } <nl> + else <nl> + { <nl> + CCLOG ( " cocos2d : Couldn ' t load ETC image % s " , file ) ; <nl> + } <nl> + <nl> + return bRet ; <nl> + } <nl> + <nl> void CCTexture2D : : PVRImagesHavePremultipliedAlpha ( bool haveAlphaPremultiplied ) <nl> { <nl> PVRHaveAlphaPremultiplied_ = haveAlphaPremultiplied ; <nl> mmm a / cocos2dx / textures / CCTexture2D . h <nl> ppp b / cocos2dx / textures / CCTexture2D . h <nl> class CC_DLL CCTexture2D : public CCObject <nl> <nl> / * * Initializes a texture from a PVR file * / <nl> bool initWithPVRFile ( const char * file ) ; <nl> + <nl> + / * * Initializes a texture from a ETC file * / <nl> + bool initWithETCFile ( const char * file ) ; <nl> <nl> / * * sets the min filter , mag filter , wrap s and wrap t texture parameters . <nl> If the texture size is NPOT ( non power of 2 ) , then in can only use GL_CLAMP_TO_EDGE in GL_TEXTURE_WRAP_ { S , T } . <nl> mmm a / cocos2dx / textures / CCTextureCache . cpp <nl> ppp b / cocos2dx / textures / CCTextureCache . cpp <nl> CCTexture2D * CCTextureCache : : addImage ( const char * path ) <nl> { <nl> texture = this - > addPVRImage ( fullpath . c_str ( ) ) ; <nl> } <nl> + else if ( std : : string : : npos ! = lowerCase . find ( " . pkm " ) ) <nl> + { <nl> + / / ETC1 file format , only supportted on Android <nl> + texture = this - > addETCImage ( fullpath . c_str ( ) ) ; <nl> + } <nl> else <nl> { <nl> CCImage : : EImageFormat eImageFormat = CCImage : : kFmtUnKnown ; <nl> CCTexture2D * CCTextureCache : : addPVRImage ( const char * path ) <nl> return texture ; <nl> } <nl> <nl> + CCTexture2D * CCTextureCache : : addETCImage ( const char * path ) <nl> + { <nl> + CCAssert ( path ! = NULL , " TextureCache : fileimage MUST not be nil " ) ; <nl> + <nl> + CCTexture2D * texture = NULL ; <nl> + std : : string key ( path ) ; <nl> + <nl> + if ( ( texture = ( CCTexture2D * ) m_pTextures - > objectForKey ( key . c_str ( ) ) ) ) <nl> + { <nl> + return texture ; <nl> + } <nl> + <nl> + / / Split up directory and filename <nl> + std : : string fullpath = CCFileUtils : : sharedFileUtils ( ) - > fullPathForFilename ( key . c_str ( ) ) ; <nl> + texture = new CCTexture2D ( ) ; <nl> + if ( texture ! = NULL & & texture - > initWithETCFile ( fullpath . c_str ( ) ) ) <nl> + { <nl> + m_pTextures - > setObject ( texture , key . c_str ( ) ) ; <nl> + texture - > autorelease ( ) ; <nl> + } <nl> + else <nl> + { <nl> + CCLOG ( " cocos2d : Couldn ' t add ETCImage : % s in CCTextureCache " , key . c_str ( ) ) ; <nl> + CC_SAFE_DELETE ( texture ) ; <nl> + } <nl> + <nl> + return texture ; <nl> + } <nl> + <nl> CCTexture2D * CCTextureCache : : addUIImage ( CCImage * image , const char * key ) <nl> { <nl> CCAssert ( image ! = NULL , " TextureCache : image MUST not be nil " ) ; <nl> mmm a / cocos2dx / textures / CCTextureCache . h <nl> ppp b / cocos2dx / textures / CCTextureCache . h <nl> class CC_DLL CCTextureCache : public CCObject <nl> * object and it will return it . Otherwise it will return a reference of a previously loaded image <nl> * / <nl> CCTexture2D * addPVRImage ( const char * filename ) ; <nl> + <nl> + / * * Returns a Texture2D object given an ETC filename <nl> + * If the file image was not previously loaded , it will create a new CCTexture2D <nl> + * object and it will return it . Otherwise it will return a reference of a previously loaded image <nl> + * / <nl> + CCTexture2D * addETCImage ( const char * filename ) ; <nl> <nl> / * * Reload all textures <nl> It ' s only useful when the value of CC_ENABLE_CACHE_TEXTURE_DATA is 1 <nl> new file mode 100644 <nl> index 000000000000 . . a6189aa19bac <nl> mmm / dev / null <nl> ppp b / cocos2dx / textures / CCTextureETC . 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 " CCTextureETC . h " <nl> + # include " platform / CCPlatformConfig . h " <nl> + # include " platform / CCFileUtils . h " <nl> + <nl> + # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_ANDROID ) <nl> + # include " platform / android / jni / JniHelper . h " <nl> + # endif <nl> + <nl> + <nl> + NS_CC_BEGIN <nl> + <nl> + CCTextureETC : : CCTextureETC ( ) <nl> + : _name ( 0 ) <nl> + , _width ( 0 ) <nl> + , _height ( 0 ) <nl> + { } <nl> + <nl> + CCTextureETC : : ~ CCTextureETC ( ) <nl> + { <nl> + } <nl> + <nl> + bool CCTextureETC : : initWithFile ( const char * file ) <nl> + { <nl> + / / Only Android supports ETC file format <nl> + # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_ANDROID ) <nl> + bool ret = loadTexture ( CCFileUtils : : sharedFileUtils ( ) - > fullPathForFilename ( file ) . c_str ( ) ) ; <nl> + return ret ; <nl> + # else <nl> + return false ; <nl> + # endif <nl> + } <nl> + <nl> + unsigned int CCTextureETC : : getName ( ) const <nl> + { <nl> + return _name ; <nl> + } <nl> + <nl> + unsigned int CCTextureETC : : getWidth ( ) const <nl> + { <nl> + return _width ; <nl> + } <nl> + <nl> + unsigned int CCTextureETC : : getHeight ( ) const <nl> + { <nl> + return _height ; <nl> + } <nl> + <nl> + / / Call back function for java <nl> + # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_ANDROID ) <nl> + # define LOG_TAG " CCTextureETC . cpp " <nl> + # define LOGD ( . . . ) __android_log_print ( ANDROID_LOG_DEBUG , LOG_TAG , __VA_ARGS__ ) <nl> + <nl> + static unsigned int sWidth = 0 ; <nl> + static unsigned int sHeight = 0 ; <nl> + static unsigned char * sData = NULL ; <nl> + static unsigned int sLength = 0 ; <nl> + <nl> + extern " C " <nl> + { <nl> + JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxETCLoader_nativeSetTextureInfo ( JNIEnv * env , jobject thiz , jint width , jint height , jbyteArray data ) <nl> + { <nl> + sWidth = ( unsigned int ) width ; <nl> + sHeight = ( unsigned int ) height ; <nl> + sLength = sWidth * sHeight * 3 ; <nl> + sData = new unsigned char [ sLength ] ; <nl> + env - > GetByteArrayRegion ( data , 0 , sLength , ( jbyte * ) sData ) ; <nl> + } <nl> + } <nl> + # endif <nl> + <nl> + bool CCTextureETC : : loadTexture ( const char * file ) <nl> + { <nl> + # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_ANDROID ) <nl> + JniMethodInfo t ; <nl> + if ( JniHelper : : getStaticMethodInfo ( t , " org / cocos2dx / lib / Cocos2dxETCLoader " , " loadTexture " , " ( Ljava / lang / String ; ) Z " ) ) <nl> + { <nl> + jstring stringArg1 = t . env - > NewStringUTF ( file ) ; <nl> + jboolean ret = t . env - > CallStaticBooleanMethod ( t . classID , t . methodID , stringArg1 ) ; <nl> + <nl> + t . env - > DeleteLocalRef ( stringArg1 ) ; <nl> + t . env - > DeleteLocalRef ( t . classID ) ; <nl> + <nl> + if ( ret ) <nl> + { <nl> + _width = sWidth ; <nl> + _height = sHeight ; <nl> + <nl> + <nl> + glGenTextures ( 1 , & _name ) ; <nl> + glBindTexture ( GL_TEXTURE_2D , _name ) ; <nl> + <nl> + glTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_MIN_FILTER , GL_LINEAR ) ; <nl> + glTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_WRAP_S , GL_CLAMP_TO_EDGE ) ; <nl> + glTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_WRAP_T , GL_CLAMP_TO_EDGE ) ; <nl> + <nl> + glCompressedTexImage2D ( GL_TEXTURE_2D , 0 , GL_ETC1_RGB8_OES , _width , _height , 0 , sLength , sData ) ; <nl> + <nl> + glBindTexture ( GL_TEXTURE_2D , 0 ) ; <nl> + <nl> + delete [ ] sData ; <nl> + sData = NULL ; <nl> + <nl> + GLenum err = glGetError ( ) ; <nl> + if ( err ! = GL_NO_ERROR ) <nl> + { <nl> + LOGD ( " width % d , height % d , lenght % d " , _width , _height , sLength ) ; <nl> + LOGD ( " cocos2d : TextureETC : Error uploading compressed texture % s glError : 0x % 04X " , file , err ) ; <nl> + return false ; <nl> + } <nl> + <nl> + return true ; <nl> + } <nl> + else <nl> + { <nl> + return false ; <nl> + } <nl> + } <nl> + # else <nl> + return false ; <nl> + # endif <nl> + } <nl> + <nl> + NS_CC_END <nl> new file mode 100644 <nl> index 000000000000 . . 69b0211c7cae <nl> mmm / dev / null <nl> ppp b / cocos2dx / textures / CCTextureETC . h <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 __CCETCTEXTURE_H__ <nl> + # define __CCETCTEXTURE_H__ <nl> + <nl> + # include " cocoa / CCObject . h " <nl> + # include " platform / CCPlatformMacros . h " <nl> + # include " CCGL . h " <nl> + <nl> + NS_CC_BEGIN <nl> + <nl> + class CC_DLL CCTextureETC : public CCObject <nl> + { <nl> + public : <nl> + CCTextureETC ( ) ; <nl> + virtual ~ CCTextureETC ( ) ; <nl> + <nl> + bool initWithFile ( const char * file ) ; <nl> + <nl> + unsigned int getName ( ) const ; <nl> + unsigned int getWidth ( ) const ; <nl> + unsigned int getHeight ( ) const ; <nl> + <nl> + private : <nl> + bool loadTexture ( const char * file ) ; <nl> + <nl> + private : <nl> + GLuint _name ; <nl> + unsigned int _width ; <nl> + unsigned int _height ; <nl> + } ; <nl> + <nl> + NS_CC_END <nl> + <nl> + # endif / * defined ( __CCETCTEXTURE_H__ ) * / <nl> mmm a / samples / Cpp / TestCpp / Classes / Texture2dTest / Texture2dTest . cpp <nl> ppp b / samples / Cpp / TestCpp / Classes / Texture2dTest / Texture2dTest . cpp <nl> TESTLAYER_CREATE_FUNC ( TextureCache1 ) ; <nl> TESTLAYER_CREATE_FUNC ( TextureDrawAtPoint ) ; <nl> TESTLAYER_CREATE_FUNC ( TextureDrawInRect ) ; <nl> <nl> + TESTLAYER_CREATE_FUNC ( TextureETC1 ) ; <nl> + <nl> static NEWTEXTURE2DTESTFUNC createFunctions [ ] = <nl> { <nl> createTextureMemoryAlloc , <nl> static NEWTEXTURE2DTESTFUNC createFunctions [ ] = <nl> createTextureCache1 , <nl> createTextureDrawAtPoint , <nl> createTextureDrawInRect , <nl> + <nl> + createTextureETC1 , <nl> } ; <nl> <nl> static unsigned int TEST_CASE_COUNT = sizeof ( createFunctions ) / sizeof ( createFunctions [ 0 ] ) ; <nl> void TexturePVRv3Premult : : transformSprite ( cocos2d : : CCSprite * sprite ) <nl> CCRepeatForever * repeat = CCRepeatForever : : create ( seq ) ; <nl> sprite - > runAction ( repeat ) ; <nl> } <nl> + <nl> + / / Implementation of ETC1 <nl> + <nl> + / * <nl> + class TextureETC1 : public TextureDemo <nl> + { <nl> + public : <nl> + TextureETC1 ( ) ; <nl> + <nl> + virtual std : : string title ( ) ; <nl> + virtual std : : string subtitle ( ) ; <nl> + } ; <nl> + * / <nl> + <nl> + TextureETC1 : : TextureETC1 ( ) <nl> + { <nl> + # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_ANDROID ) <nl> + CCSprite * sprite = CCSprite : : create ( " Images / ETC1 . pkm " ) ; <nl> + <nl> + CCSize size = CCDirector : : sharedDirector ( ) - > getWinSize ( ) ; <nl> + sprite - > setPosition ( ccp ( size . width / 2 , size . height / 2 ) ) ; <nl> + <nl> + addChild ( sprite ) ; <nl> + # endif <nl> + } <nl> + <nl> + std : : string TextureETC1 : : title ( ) <nl> + { <nl> + return " ETC1 texture " ; <nl> + } <nl> + <nl> + std : : string TextureETC1 : : subtitle ( ) <nl> + { <nl> + return " only supported on android " ; <nl> + } <nl> mmm a / samples / Cpp / TestCpp / Classes / Texture2dTest / Texture2dTest . h <nl> ppp b / samples / Cpp / TestCpp / Classes / Texture2dTest / Texture2dTest . h <nl> class TexturePVRv3Premult : public TextureDemo <nl> void transformSprite ( cocos2d : : CCSprite * sprite ) ; <nl> } ; <nl> <nl> + / / ETC1 texture format test <nl> + class TextureETC1 : public TextureDemo <nl> + { <nl> + public : <nl> + TextureETC1 ( ) ; <nl> + <nl> + virtual std : : string title ( ) ; <nl> + virtual std : : string subtitle ( ) ; <nl> + } ; <nl> + <nl> # endif / / __TEXTURE2D_TEST_H__ <nl> | issue : android supports ETC format now | cocos2d/cocos2d-x | beef61fc9060982d48ebfdfe17634197a7e7f7fc | 2013-05-27T06:42:22Z |
mmm a / docs / CallingConvention . rst <nl> ppp b / docs / CallingConvention . rst <nl> Pass - by - value <nl> <nl> In pass - by - value , if ` A ` is an l - value expression , ` foo ( A ) ` copies the <nl> current value there . Any modifications ` foo ` makes to its parameter <nl> - are make to this copy , not to the original l - value . <nl> + are made to this copy , not to the original l - value . <nl> <nl> Most modern languages are pass - by - value , with specific functions able <nl> to opt in to pass - by - reference semantics . This is exactly what Swift <nl> just add default arguments at each step ) have really awful performance <nl> because the compiler is adding retains and releases at every single <nl> level . It ' s just not a good convention to adopt by default . However , <nl> we might want to consider allowing specific function parameters to opt <nl> - into it ; sort comparators are an particularly interesting candidate <nl> + into it ; sort comparators are a particularly interesting candidate <nl> for this . ` unowned ` is very similar to C + + ' s ` const & ` for things <nl> like that . <nl> <nl> | Merge pull request from serejahh / fix_typos | apple/swift | 5d21900facdad2d9a9bbfd17875f00725fb8a9b4 | 2015-12-03T19:23:54Z |
mmm a / Makefile <nl> ppp b / Makefile <nl> TEST_HDRS : = $ ( shell find src / $ ( PROJECT ) - name " test_ * . hpp " ) <nl> TOOL_SRCS : = $ ( shell find tools - name " * . cpp " ) <nl> # EXAMPLE_SRCS are the source files for the example binaries <nl> EXAMPLE_SRCS : = $ ( shell find examples - name " * . cpp " ) <nl> + # BUILD_INCLUDE_DIR contains any generated header files we want to include . <nl> + BUILD_INCLUDE_DIR : = $ ( BUILD_DIR ) / include <nl> # PROTO_SRCS are the protocol buffer definitions <nl> - PROTO_SRCS : = $ ( wildcard src / $ ( PROJECT ) / proto / * . proto ) <nl> + PROTO_SRC_DIR : = src / $ ( PROJECT ) / proto <nl> + PROTO_SRCS : = $ ( wildcard $ ( PROTO_SRC_DIR ) / * . proto ) <nl> + # PROTO_BUILD_DIR will contain the . cc and obj files generated from <nl> + # PROTO_SRCS ; PROTO_BUILD_INCLUDE_DIR will contain the . h header files <nl> + PROTO_BUILD_DIR : = $ ( BUILD_DIR ) / $ ( PROTO_SRC_DIR ) <nl> + PROTO_BUILD_INCLUDE_DIR : = $ ( BUILD_INCLUDE_DIR ) / $ ( PROJECT ) / proto <nl> # NONGEN_CXX_SRCS includes all source / header files except those generated <nl> # automatically ( e . g . , by proto ) . <nl> NONGEN_CXX_SRCS : = $ ( shell find \ <nl> MAT $ ( PROJECT ) _SO : = matlab / $ ( PROJECT ) / $ ( PROJECT ) <nl> # Derive generated files <nl> # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> # The generated files for protocol buffers <nl> - PROTO_GEN_HEADER : = $ { PROTO_SRCS : . proto = . pb . h } <nl> - PROTO_GEN_CC : = $ { PROTO_SRCS : . proto = . pb . cc } <nl> + PROTO_GEN_HEADER : = $ ( addprefix $ ( BUILD_DIR ) / , $ { PROTO_SRCS : . proto = . pb . h } ) <nl> + PROTO_GEN_CC : = $ ( addprefix $ ( BUILD_DIR ) / , $ { PROTO_SRCS : . proto = . pb . cc } ) <nl> PROTO_GEN_PY : = $ { PROTO_SRCS : . proto = _pb2 . py } <nl> # The objects corresponding to the source files <nl> # These objects will be linked into the final shared library , so we <nl> # exclude the tool , example , and test objects . <nl> CXX_OBJS : = $ ( addprefix $ ( BUILD_DIR ) / , $ { CXX_SRCS : . cpp = . o } ) <nl> CU_OBJS : = $ ( addprefix $ ( BUILD_DIR ) / , $ { CU_SRCS : . cu = . cuo } ) <nl> - PROTO_OBJS : = $ ( addprefix $ ( BUILD_DIR ) / , $ { PROTO_GEN_CC : . cc = . o } ) <nl> + PROTO_OBJS : = $ { PROTO_GEN_CC : . cc = . o } <nl> OBJS : = $ ( PROTO_OBJS ) $ ( CXX_OBJS ) $ ( CU_OBJS ) <nl> # tool , example , and test objects <nl> TOOL_OBJS : = $ ( addprefix $ ( BUILD_DIR ) / , $ { TOOL_SRCS : . cpp = . o } ) <nl> MKL_INCLUDE_DIR : = $ ( MKL_DIR ) / include <nl> MKL_LIB_DIR : = $ ( MKL_DIR ) / lib $ ( MKL_DIR ) / lib / intel64 <nl> <nl> INCLUDE_DIRS + = . / src . / include $ ( CUDA_INCLUDE_DIR ) <nl> + INCLUDE_DIRS + = $ ( BUILD_INCLUDE_DIR ) <nl> LIBRARY_DIRS + = $ ( CUDA_LIB_DIR ) <nl> LIBRARIES : = cudart cublas curand \ <nl> pthread \ <nl> $ ( TEST_ALL_BIN ) : $ ( GTEST_OBJ ) $ ( STATIC_NAME ) $ ( TEST_OBJS ) testshortcut <nl> testshortcut : $ ( TEST_DIR_LINK ) <nl> <nl> $ ( TEST_DIR_LINK ) : $ ( TEST_DIR ) <nl> - @ ln - s $ ( TEST_BUILD_SUB_DIR ) $ ( TEST_DIR_LINK ) <nl> + ln - s $ ( TEST_BUILD_SUB_DIR ) $ ( TEST_DIR_LINK ) <nl> <nl> $ ( TEST_DIR ) : <nl> - @ mkdir - p $ ( TEST_DIR ) <nl> + mkdir - p $ ( TEST_DIR ) <nl> <nl> $ ( TOOL_BINS ) : % . bin : % . o $ ( STATIC_NAME ) <nl> $ ( CXX ) $ < $ ( STATIC_NAME ) - o $ @ $ ( CXXFLAGS ) $ ( LDFLAGS ) $ ( WARNINGS ) <nl> $ ( PROTO_GEN_PY ) : $ ( PROTO_SRCS ) <nl> protoc - - proto_path = src - - python_out = python $ ( PROTO_SRCS ) <nl> @ echo <nl> <nl> - proto : $ ( PROTO_GEN_CC ) <nl> + proto : init $ ( PROTO_GEN_CC ) <nl> <nl> - $ ( PROTO_GEN_CC ) : $ ( PROTO_SRCS ) <nl> - protoc - - proto_path = src - - cpp_out = src $ ( PROTO_SRCS ) <nl> - mkdir - p include / $ ( PROJECT ) / proto <nl> - cp $ ( PROTO_GEN_HEADER ) include / $ ( PROJECT ) / proto / <nl> + $ ( PROTO_GEN_CC ) : $ ( PROTO_SRCS ) $ ( PROTO_BUILD_DIR ) $ ( PROTO_BUILD_INCLUDE_DIR ) <nl> + protoc - - proto_path = src - - cpp_out = build / src $ ( PROTO_SRCS ) <nl> + cp $ ( PROTO_GEN_HEADER ) $ ( PROTO_BUILD_INCLUDE_DIR ) <nl> @ echo <nl> <nl> + $ ( PROTO_BUILD_DIR ) : <nl> + mkdir - p $ ( PROTO_BUILD_DIR ) <nl> + <nl> + $ ( PROTO_BUILD_INCLUDE_DIR ) : <nl> + mkdir - p $ ( PROTO_BUILD_INCLUDE_DIR ) <nl> + <nl> clean : <nl> @ - $ ( RM ) $ ( NAME ) $ ( STATIC_NAME ) <nl> @ - $ ( RM ) $ ( PROTO_GEN_HEADER ) $ ( PROTO_GEN_CC ) $ ( PROTO_GEN_PY ) <nl> | put proto - generated . cc and . h files in build directory | BVLC/caffe | e29838ddf14fcbc01e4d4925750eef7d75c09575 | 2014-04-02T17:58:49Z |
mmm a / tensorflow / contrib / learn / python / learn / graph_actions . py <nl> ppp b / tensorflow / contrib / learn / python / learn / graph_actions . py <nl> def evaluate ( graph , <nl> finally : <nl> # Make our own summary writer and write a summary to the eval dir <nl> if supervisor . summary_op is not None : <nl> + summary_writer = None <nl> try : <nl> summary_writer = SummaryWriter ( output_dir , <nl> graph_def = session . graph_def ) <nl> def evaluate ( graph , <nl> if summary_str : <nl> summary_writer . add_summary ( summary_str , current_global_step ) <nl> finally : <nl> - summary_writer . close ( ) <nl> + if summary_writer : <nl> + summary_writer . close ( ) <nl> <nl> # Call supervisor . Stop ( ) from within a try block because it re - raises <nl> # exceptions thrown by the supervised threads . <nl> | Add check to make sure errors inside SummaryWriter constructor are not hidden by other failures . | tensorflow/tensorflow | 0e861b3a2d67a5c33383e2f5970f3fef8bc53c5a | 2016-05-10T01:52:59Z |
new file mode 100644 <nl> index 000000000000 . . ea13f7d85f23 <nl> mmm / dev / null <nl> ppp b / cocos2dx / platform / third_party / mac / libraries / libwebp . a . REMOVED . git - id <nl> @ @ - 0 , 0 + 1 @ @ <nl> + 581d190d221ecc4ab65b7fd571266951e0c81602 <nl> \ No newline at end of file <nl> new file mode 100644 <nl> index 000000000000 . . 43b6c58f4f4b <nl> mmm / dev / null <nl> ppp b / cocos2dx / platform / third_party / mac / webp / decode . h <nl> <nl> + / / Copyright 2010 Google Inc . All Rights Reserved . <nl> + / / <nl> + / / This code is licensed under the same terms as WebM : <nl> + / / Software License Agreement : http : / / www . webmproject . org / license / software / <nl> + / / Additional IP Rights Grant : http : / / www . webmproject . org / license / additional / <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / <nl> + / / Main decoding functions for WebP images . <nl> + / / <nl> + / / Author : Skal ( pascal . massimino @ gmail . com ) <nl> + <nl> + # ifndef WEBP_WEBP_DECODE_H_ <nl> + # define WEBP_WEBP_DECODE_H_ <nl> + <nl> + # include " . / types . h " <nl> + <nl> + # if defined ( __cplusplus ) | | defined ( c_plusplus ) <nl> + extern " C " { <nl> + # endif <nl> + <nl> + # define WEBP_DECODER_ABI_VERSION 0x0200 / / MAJOR ( 8b ) + MINOR ( 8b ) <nl> + <nl> + / / Return the decoder ' s version number , packed in hexadecimal using 8bits for <nl> + / / each of major / minor / revision . E . g : v2 . 5 . 7 is 0x020507 . <nl> + WEBP_EXTERN ( int ) WebPGetDecoderVersion ( void ) ; <nl> + <nl> + / / Retrieve basic header information : width , height . <nl> + / / This function will also validate the header and return 0 in <nl> + / / case of formatting error . <nl> + / / Pointers ' width ' and ' height ' can be passed NULL if deemed irrelevant . <nl> + WEBP_EXTERN ( int ) WebPGetInfo ( const uint8_t * data , size_t data_size , <nl> + int * width , int * height ) ; <nl> + <nl> + / / Decodes WebP images pointed to by ' data ' and returns RGBA samples , along <nl> + / / with the dimensions in * width and * height . The ordering of samples in <nl> + / / memory is R , G , B , A , R , G , B , A . . . in scan order ( endian - independent ) . <nl> + / / The returned pointer should be deleted calling free ( ) . <nl> + / / Returns NULL in case of error . <nl> + WEBP_EXTERN ( uint8_t * ) WebPDecodeRGBA ( const uint8_t * data , size_t data_size , <nl> + int * width , int * height ) ; <nl> + <nl> + / / Same as WebPDecodeRGBA , but returning A , R , G , B , A , R , G , B . . . ordered data . <nl> + WEBP_EXTERN ( uint8_t * ) WebPDecodeARGB ( const uint8_t * data , size_t data_size , <nl> + int * width , int * height ) ; <nl> + <nl> + / / Same as WebPDecodeRGBA , but returning B , G , R , A , B , G , R , A . . . ordered data . <nl> + WEBP_EXTERN ( uint8_t * ) WebPDecodeBGRA ( const uint8_t * data , size_t data_size , <nl> + int * width , int * height ) ; <nl> + <nl> + / / Same as WebPDecodeRGBA , but returning R , G , B , R , G , B . . . ordered data . <nl> + / / If the bitstream contains transparency , it is ignored . <nl> + WEBP_EXTERN ( uint8_t * ) WebPDecodeRGB ( const uint8_t * data , size_t data_size , <nl> + int * width , int * height ) ; <nl> + <nl> + / / Same as WebPDecodeRGB , but returning B , G , R , B , G , R . . . ordered data . <nl> + WEBP_EXTERN ( uint8_t * ) WebPDecodeBGR ( const uint8_t * data , size_t data_size , <nl> + int * width , int * height ) ; <nl> + <nl> + <nl> + / / Decode WebP images pointed to by ' data ' to Y ' UV format ( * ) . The pointer <nl> + / / returned is the Y samples buffer . Upon return , * u and * v will point to <nl> + / / the U and V chroma data . These U and V buffers need NOT be free ( ) ' d , <nl> + / / unlike the returned Y luma one . The dimension of the U and V planes <nl> + / / are both ( * width + 1 ) / 2 and ( * height + 1 ) / 2 . <nl> + / / Upon return , the Y buffer has a stride returned as ' * stride ' , while U and V <nl> + / / have a common stride returned as ' * uv_stride ' . <nl> + / / Return NULL in case of error . <nl> + / / ( * ) Also named Y ' CbCr . See : http : / / en . wikipedia . org / wiki / YCbCr <nl> + WEBP_EXTERN ( uint8_t * ) WebPDecodeYUV ( const uint8_t * data , size_t data_size , <nl> + int * width , int * height , <nl> + uint8_t * * u , uint8_t * * v , <nl> + int * stride , int * uv_stride ) ; <nl> + <nl> + / / These five functions are variants of the above ones , that decode the image <nl> + / / directly into a pre - allocated buffer ' output_buffer ' . The maximum storage <nl> + / / available in this buffer is indicated by ' output_buffer_size ' . If this <nl> + / / storage is not sufficient ( or an error occurred ) , NULL is returned . <nl> + / / Otherwise , output_buffer is returned , for convenience . <nl> + / / The parameter ' output_stride ' specifies the distance ( in bytes ) <nl> + / / between scanlines . Hence , output_buffer_size is expected to be at least <nl> + / / output_stride x picture - height . <nl> + WEBP_EXTERN ( uint8_t * ) WebPDecodeRGBAInto ( <nl> + const uint8_t * data , size_t data_size , <nl> + uint8_t * output_buffer , size_t output_buffer_size , int output_stride ) ; <nl> + WEBP_EXTERN ( uint8_t * ) WebPDecodeARGBInto ( <nl> + const uint8_t * data , size_t data_size , <nl> + uint8_t * output_buffer , size_t output_buffer_size , int output_stride ) ; <nl> + WEBP_EXTERN ( uint8_t * ) WebPDecodeBGRAInto ( <nl> + const uint8_t * data , size_t data_size , <nl> + uint8_t * output_buffer , size_t output_buffer_size , int output_stride ) ; <nl> + <nl> + / / RGB and BGR variants . Here too the transparency information , if present , <nl> + / / will be dropped and ignored . <nl> + WEBP_EXTERN ( uint8_t * ) WebPDecodeRGBInto ( <nl> + const uint8_t * data , size_t data_size , <nl> + uint8_t * output_buffer , size_t output_buffer_size , int output_stride ) ; <nl> + WEBP_EXTERN ( uint8_t * ) WebPDecodeBGRInto ( <nl> + const uint8_t * data , size_t data_size , <nl> + uint8_t * output_buffer , size_t output_buffer_size , int output_stride ) ; <nl> + <nl> + / / WebPDecodeYUVInto ( ) is a variant of WebPDecodeYUV ( ) that operates directly <nl> + / / into pre - allocated luma / chroma plane buffers . This function requires the <nl> + / / strides to be passed : one for the luma plane and one for each of the <nl> + / / chroma ones . The size of each plane buffer is passed as ' luma_size ' , <nl> + / / ' u_size ' and ' v_size ' respectively . <nl> + / / Pointer to the luma plane ( ' * luma ' ) is returned or NULL if an error occurred <nl> + / / during decoding ( or because some buffers were found to be too small ) . <nl> + WEBP_EXTERN ( uint8_t * ) WebPDecodeYUVInto ( <nl> + const uint8_t * data , size_t data_size , <nl> + uint8_t * luma , size_t luma_size , int luma_stride , <nl> + uint8_t * u , size_t u_size , int u_stride , <nl> + uint8_t * v , size_t v_size , int v_stride ) ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + / / Output colorspaces and buffer <nl> + <nl> + / / Colorspaces <nl> + / / Note : the naming describes the byte - ordering of packed samples in memory . <nl> + / / For instance , MODE_BGRA relates to samples ordered as B , G , R , A , B , G , R , A , . . . <nl> + / / Non - capital names ( e . g . : MODE_Argb ) relates to pre - multiplied RGB channels . <nl> + / / RGB - 565 and RGBA - 4444 are also endian - agnostic and byte - oriented . <nl> + typedef enum { MODE_RGB = 0 , MODE_RGBA = 1 , <nl> + MODE_BGR = 2 , MODE_BGRA = 3 , <nl> + MODE_ARGB = 4 , MODE_RGBA_4444 = 5 , <nl> + MODE_RGB_565 = 6 , <nl> + / / RGB - premultiplied transparent modes ( alpha value is preserved ) <nl> + MODE_rgbA = 7 , <nl> + MODE_bgrA = 8 , <nl> + MODE_Argb = 9 , <nl> + MODE_rgbA_4444 = 10 , <nl> + / / YUV modes must come after RGB ones . <nl> + MODE_YUV = 11 , MODE_YUVA = 12 , / / yuv 4 : 2 : 0 <nl> + MODE_LAST = 13 <nl> + } WEBP_CSP_MODE ; <nl> + <nl> + / / Some useful macros : <nl> + static WEBP_INLINE int WebPIsPremultipliedMode ( WEBP_CSP_MODE mode ) { <nl> + return ( mode = = MODE_rgbA | | mode = = MODE_bgrA | | mode = = MODE_Argb | | <nl> + mode = = MODE_rgbA_4444 ) ; <nl> + } <nl> + <nl> + static WEBP_INLINE int WebPIsAlphaMode ( WEBP_CSP_MODE mode ) { <nl> + return ( mode = = MODE_RGBA | | mode = = MODE_BGRA | | mode = = MODE_ARGB | | <nl> + mode = = MODE_RGBA_4444 | | mode = = MODE_YUVA | | <nl> + WebPIsPremultipliedMode ( mode ) ) ; <nl> + } <nl> + <nl> + static WEBP_INLINE int WebPIsRGBMode ( WEBP_CSP_MODE mode ) { <nl> + return ( mode < MODE_YUV ) ; <nl> + } <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + / / WebPDecBuffer : Generic structure for describing the output sample buffer . <nl> + <nl> + typedef struct { / / view as RGBA <nl> + uint8_t * rgba ; / / pointer to RGBA samples <nl> + int stride ; / / stride in bytes from one scanline to the next . <nl> + size_t size ; / / total size of the * rgba buffer . <nl> + } WebPRGBABuffer ; <nl> + <nl> + typedef struct { / / view as YUVA <nl> + uint8_t * y , * u , * v , * a ; / / pointer to luma , chroma U / V , alpha samples <nl> + int y_stride ; / / luma stride <nl> + int u_stride , v_stride ; / / chroma strides <nl> + int a_stride ; / / alpha stride <nl> + size_t y_size ; / / luma plane size <nl> + size_t u_size , v_size ; / / chroma planes size <nl> + size_t a_size ; / / alpha - plane size <nl> + } WebPYUVABuffer ; <nl> + <nl> + / / Output buffer <nl> + typedef struct { <nl> + WEBP_CSP_MODE colorspace ; / / Colorspace . <nl> + int width , height ; / / Dimensions . <nl> + int is_external_memory ; / / If true , ' internal_memory ' pointer is not used . <nl> + union { <nl> + WebPRGBABuffer RGBA ; <nl> + WebPYUVABuffer YUVA ; <nl> + } u ; / / Nameless union of buffer parameters . <nl> + uint32_t pad [ 4 ] ; / / padding for later use <nl> + <nl> + uint8_t * private_memory ; / / Internally allocated memory ( only when <nl> + / / is_external_memory is false ) . Should not be used <nl> + / / externally , but accessed via the buffer union . <nl> + } WebPDecBuffer ; <nl> + <nl> + / / Internal , version - checked , entry point <nl> + WEBP_EXTERN ( int ) WebPInitDecBufferInternal ( WebPDecBuffer * , int ) ; <nl> + <nl> + / / Initialize the structure as empty . Must be called before any other use . <nl> + / / Returns false in case of version mismatch <nl> + static WEBP_INLINE int WebPInitDecBuffer ( WebPDecBuffer * buffer ) { <nl> + return WebPInitDecBufferInternal ( buffer , WEBP_DECODER_ABI_VERSION ) ; <nl> + } <nl> + <nl> + / / Free any memory associated with the buffer . Must always be called last . <nl> + / / Note : doesn ' t free the ' buffer ' structure itself . <nl> + WEBP_EXTERN ( void ) WebPFreeDecBuffer ( WebPDecBuffer * buffer ) ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + / / Enumeration of the status codes <nl> + <nl> + typedef enum { <nl> + VP8_STATUS_OK = 0 , <nl> + VP8_STATUS_OUT_OF_MEMORY , <nl> + VP8_STATUS_INVALID_PARAM , <nl> + VP8_STATUS_BITSTREAM_ERROR , <nl> + VP8_STATUS_UNSUPPORTED_FEATURE , <nl> + VP8_STATUS_SUSPENDED , <nl> + VP8_STATUS_USER_ABORT , <nl> + VP8_STATUS_NOT_ENOUGH_DATA <nl> + } VP8StatusCode ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + / / Incremental decoding <nl> + / / <nl> + / / This API allows streamlined decoding of partial data . <nl> + / / Picture can be incrementally decoded as data become available thanks to the <nl> + / / WebPIDecoder object . This object can be left in a SUSPENDED state if the <nl> + / / picture is only partially decoded , pending additional input . <nl> + / / Code example : <nl> + / / <nl> + / / WebPInitDecBuffer ( & buffer ) ; <nl> + / / buffer . colorspace = mode ; <nl> + / / . . . <nl> + / / WebPIDecoder * idec = WebPINewDecoder ( & buffer ) ; <nl> + / / while ( has_more_data ) { <nl> + / / / / . . . ( get additional data ) <nl> + / / status = WebPIAppend ( idec , new_data , new_data_size ) ; <nl> + / / if ( status ! = VP8_STATUS_SUSPENDED | | <nl> + / / break ; <nl> + / / } <nl> + / / <nl> + / / / / The above call decodes the current available buffer . <nl> + / / / / Part of the image can now be refreshed by calling to <nl> + / / / / WebPIDecGetRGB ( ) / WebPIDecGetYUVA ( ) etc . <nl> + / / } <nl> + / / WebPIDelete ( idec ) ; <nl> + <nl> + typedef struct WebPIDecoder WebPIDecoder ; <nl> + <nl> + / / Creates a new incremental decoder with the supplied buffer parameter . <nl> + / / This output_buffer can be passed NULL , in which case a default output buffer <nl> + / / is used ( with MODE_RGB ) . Otherwise , an internal reference to ' output_buffer ' <nl> + / / is kept , which means that the lifespan of ' output_buffer ' must be larger than <nl> + / / that of the returned WebPIDecoder object . <nl> + / / Returns NULL if the allocation failed . <nl> + WEBP_EXTERN ( WebPIDecoder * ) WebPINewDecoder ( WebPDecBuffer * output_buffer ) ; <nl> + <nl> + / / This function allocates and initializes an incremental - decoder object , which <nl> + / / will output the RGB / A samples specified by ' csp ' into a preallocated <nl> + / / buffer ' output_buffer ' . The size of this buffer is at least <nl> + / / ' output_buffer_size ' and the stride ( distance in bytes between two scanlines ) <nl> + / / is specified by ' output_stride ' . Returns NULL if the allocation failed . <nl> + WEBP_EXTERN ( WebPIDecoder * ) WebPINewRGB ( <nl> + WEBP_CSP_MODE csp , <nl> + uint8_t * output_buffer , size_t output_buffer_size , int output_stride ) ; <nl> + <nl> + / / This function allocates and initializes an incremental - decoder object , which <nl> + / / will output the raw luma / chroma samples into a preallocated planes . The luma <nl> + / / plane is specified by its pointer ' luma ' , its size ' luma_size ' and its stride <nl> + / / ' luma_stride ' . Similarly , the chroma - u plane is specified by the ' u ' , <nl> + / / ' u_size ' and ' u_stride ' parameters , and the chroma - v plane by ' v ' <nl> + / / and ' v_size ' . And same for the alpha - plane . The ' a ' pointer can be pass <nl> + / / NULL in case one is not interested in the transparency plane . <nl> + / / Returns NULL if the allocation failed . <nl> + WEBP_EXTERN ( WebPIDecoder * ) WebPINewYUVA ( <nl> + uint8_t * luma , size_t luma_size , int luma_stride , <nl> + uint8_t * u , size_t u_size , int u_stride , <nl> + uint8_t * v , size_t v_size , int v_stride , <nl> + uint8_t * a , size_t a_size , int a_stride ) ; <nl> + <nl> + / / Deprecated version of the above , without the alpha plane . <nl> + / / Kept for backward compatibility . <nl> + WEBP_EXTERN ( WebPIDecoder * ) WebPINewYUV ( <nl> + uint8_t * luma , size_t luma_size , int luma_stride , <nl> + uint8_t * u , size_t u_size , int u_stride , <nl> + uint8_t * v , size_t v_size , int v_stride ) ; <nl> + <nl> + / / Deletes the WebPIDecoder object and associated memory . Must always be called <nl> + / / if WebPINewDecoder , WebPINewRGB or WebPINewYUV succeeded . <nl> + WEBP_EXTERN ( void ) WebPIDelete ( WebPIDecoder * idec ) ; <nl> + <nl> + / / Copies and decodes the next available data . Returns VP8_STATUS_OK when <nl> + / / the image is successfully decoded . Returns VP8_STATUS_SUSPENDED when more <nl> + / / data is expected . Returns error in other cases . <nl> + WEBP_EXTERN ( VP8StatusCode ) WebPIAppend ( <nl> + WebPIDecoder * idec , const uint8_t * data , size_t data_size ) ; <nl> + <nl> + / / A variant of the above function to be used when data buffer contains <nl> + / / partial data from the beginning . In this case data buffer is not copied <nl> + / / to the internal memory . <nl> + / / Note that the value of the ' data ' pointer can change between calls to <nl> + / / WebPIUpdate , for instance when the data buffer is resized to fit larger data . <nl> + WEBP_EXTERN ( VP8StatusCode ) WebPIUpdate ( <nl> + WebPIDecoder * idec , const uint8_t * data , size_t data_size ) ; <nl> + <nl> + / / Returns the RGB / A image decoded so far . Returns NULL if output params <nl> + / / are not initialized yet . The RGB / A output type corresponds to the colorspace <nl> + / / specified during call to WebPINewDecoder ( ) or WebPINewRGB ( ) . <nl> + / / * last_y is the index of last decoded row in raster scan order . Some pointers <nl> + / / ( * last_y , * width etc . ) can be NULL if corresponding information is not <nl> + / / needed . <nl> + WEBP_EXTERN ( uint8_t * ) WebPIDecGetRGB ( <nl> + const WebPIDecoder * idec , int * last_y , <nl> + int * width , int * height , int * stride ) ; <nl> + <nl> + / / Same as above function to get a YUVA image . Returns pointer to the luma <nl> + / / plane or NULL in case of error . If there is no alpha information <nl> + / / the alpha pointer ' * a ' will be returned NULL . <nl> + WEBP_EXTERN ( uint8_t * ) WebPIDecGetYUVA ( <nl> + const WebPIDecoder * idec , int * last_y , <nl> + uint8_t * * u , uint8_t * * v , uint8_t * * a , <nl> + int * width , int * height , int * stride , int * uv_stride , int * a_stride ) ; <nl> + <nl> + / / Deprecated alpha - less version of WebPIDecGetYUVA ( ) : it will ignore the <nl> + / / alpha information ( if present ) . Kept for backward compatibility . <nl> + static WEBP_INLINE uint8_t * WebPIDecGetYUV ( <nl> + const WebPIDecoder * idec , int * last_y , uint8_t * * u , uint8_t * * v , <nl> + int * width , int * height , int * stride , int * uv_stride ) { <nl> + return WebPIDecGetYUVA ( idec , last_y , u , v , NULL , width , height , <nl> + stride , uv_stride , NULL ) ; <nl> + } <nl> + <nl> + / / Generic call to retrieve information about the displayable area . <nl> + / / If non NULL , the left / right / width / height pointers are filled with the visible <nl> + / / rectangular area so far . <nl> + / / Returns NULL in case the incremental decoder object is in an invalid state . <nl> + / / Otherwise returns the pointer to the internal representation . This structure <nl> + / / is read - only , tied to WebPIDecoder ' s lifespan and should not be modified . <nl> + WEBP_EXTERN ( const WebPDecBuffer * ) WebPIDecodedArea ( <nl> + const WebPIDecoder * idec , int * left , int * top , int * width , int * height ) ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + / / Advanced decoding parametrization <nl> + / / <nl> + / / Code sample for using the advanced decoding API <nl> + / * <nl> + / / A ) Init a configuration object <nl> + WebPDecoderConfig config ; <nl> + CHECK ( WebPInitDecoderConfig ( & config ) ) ; <nl> + <nl> + / / B ) optional : retrieve the bitstream ' s features . <nl> + CHECK ( WebPGetFeatures ( data , data_size , & config . input ) = = VP8_STATUS_OK ) ; <nl> + <nl> + / / C ) Adjust ' config ' , if needed <nl> + config . no_fancy = 1 ; <nl> + config . output . colorspace = MODE_BGRA ; <nl> + / / etc . <nl> + <nl> + / / Note that you can also make config . output point to an externally <nl> + / / supplied memory buffer , provided it ' s big enough to store the decoded <nl> + / / picture . Otherwise , config . output will just be used to allocate memory <nl> + / / and store the decoded picture . <nl> + <nl> + / / D ) Decode ! <nl> + CHECK ( WebPDecode ( data , data_size , & config ) = = VP8_STATUS_OK ) ; <nl> + <nl> + / / E ) Decoded image is now in config . output ( and config . output . u . RGBA ) <nl> + <nl> + / / F ) Reclaim memory allocated in config ' s object . It ' s safe to call <nl> + / / this function even if the memory is external and wasn ' t allocated <nl> + / / by WebPDecode ( ) . <nl> + WebPFreeDecBuffer ( & config . output ) ; <nl> + * / <nl> + <nl> + / / Features gathered from the bitstream <nl> + typedef struct { <nl> + int width ; / / Width in pixels , as read from the bitstream . <nl> + int height ; / / Height in pixels , as read from the bitstream . <nl> + int has_alpha ; / / True if the bitstream contains an alpha channel . <nl> + <nl> + / / Unused for now : <nl> + int bitstream_version ; / / should be 0 for now . TODO ( later ) <nl> + int no_incremental_decoding ; / / if true , using incremental decoding is not <nl> + / / recommended . <nl> + int rotate ; / / TODO ( later ) <nl> + int uv_sampling ; / / should be 0 for now . TODO ( later ) <nl> + uint32_t pad [ 3 ] ; / / padding for later use <nl> + } WebPBitstreamFeatures ; <nl> + <nl> + / / Internal , version - checked , entry point <nl> + WEBP_EXTERN ( VP8StatusCode ) WebPGetFeaturesInternal ( <nl> + const uint8_t * , size_t , WebPBitstreamFeatures * , int ) ; <nl> + <nl> + / / Retrieve features from the bitstream . The * features structure is filled <nl> + / / with information gathered from the bitstream . <nl> + / / Returns false in case of error or version mismatch . <nl> + / / In case of error , features - > bitstream_status will reflect the error code . <nl> + static WEBP_INLINE VP8StatusCode WebPGetFeatures ( <nl> + const uint8_t * data , size_t data_size , <nl> + WebPBitstreamFeatures * features ) { <nl> + return WebPGetFeaturesInternal ( data , data_size , features , <nl> + WEBP_DECODER_ABI_VERSION ) ; <nl> + } <nl> + <nl> + / / Decoding options <nl> + typedef struct { <nl> + int bypass_filtering ; / / if true , skip the in - loop filtering <nl> + int no_fancy_upsampling ; / / if true , use faster pointwise upsampler <nl> + int use_cropping ; / / if true , cropping is applied _first_ <nl> + int crop_left , crop_top ; / / top - left position for cropping . <nl> + / / Will be snapped to even values . <nl> + int crop_width , crop_height ; / / dimension of the cropping area <nl> + int use_scaling ; / / if true , scaling is applied _afterward_ <nl> + int scaled_width , scaled_height ; / / final resolution <nl> + int use_threads ; / / if true , use multi - threaded decoding <nl> + <nl> + / / Unused for now : <nl> + int force_rotation ; / / forced rotation ( to be applied _last_ ) <nl> + int no_enhancement ; / / if true , discard enhancement layer <nl> + uint32_t pad [ 6 ] ; / / padding for later use <nl> + } WebPDecoderOptions ; <nl> + <nl> + / / Main object storing the configuration for advanced decoding . <nl> + typedef struct { <nl> + WebPBitstreamFeatures input ; / / Immutable bitstream features ( optional ) <nl> + WebPDecBuffer output ; / / Output buffer ( can point to external mem ) <nl> + WebPDecoderOptions options ; / / Decoding options <nl> + } WebPDecoderConfig ; <nl> + <nl> + / / Internal , version - checked , entry point <nl> + WEBP_EXTERN ( int ) WebPInitDecoderConfigInternal ( WebPDecoderConfig * , int ) ; <nl> + <nl> + / / Initialize the configuration as empty . This function must always be <nl> + / / called first , unless WebPGetFeatures ( ) is to be called . <nl> + / / Returns false in case of mismatched version . <nl> + static WEBP_INLINE int WebPInitDecoderConfig ( WebPDecoderConfig * config ) { <nl> + return WebPInitDecoderConfigInternal ( config , WEBP_DECODER_ABI_VERSION ) ; <nl> + } <nl> + <nl> + / / Instantiate a new incremental decoder object with the requested <nl> + / / configuration . The bitstream can be passed using ' data ' and ' data_size ' <nl> + / / parameter , in which case the features will be parsed and stored into <nl> + / / config - > input . Otherwise , ' data ' can be NULL and no parsing will occur . <nl> + / / Note that ' config ' can be NULL too , in which case a default configuration <nl> + / / is used . <nl> + / / The return WebPIDecoder object must always be deleted calling WebPIDelete ( ) . <nl> + / / Returns NULL in case of error ( and config - > status will then reflect <nl> + / / the error condition ) . <nl> + WEBP_EXTERN ( WebPIDecoder * ) WebPIDecode ( const uint8_t * data , size_t data_size , <nl> + WebPDecoderConfig * config ) ; <nl> + <nl> + / / Non - incremental version . This version decodes the full data at once , taking <nl> + / / ' config ' into account . Returns decoding status ( which should be VP8_STATUS_OK <nl> + / / if the decoding was successful ) . <nl> + WEBP_EXTERN ( VP8StatusCode ) WebPDecode ( const uint8_t * data , size_t data_size , <nl> + WebPDecoderConfig * config ) ; <nl> + <nl> + # if defined ( __cplusplus ) | | defined ( c_plusplus ) <nl> + } / / extern " C " <nl> + # endif <nl> + <nl> + # endif / * WEBP_WEBP_DECODE_H_ * / <nl> new file mode 100644 <nl> index 000000000000 . . 2e37cfabe718 <nl> mmm / dev / null <nl> ppp b / cocos2dx / platform / third_party / mac / webp / encode . h <nl> <nl> + / / Copyright 2011 Google Inc . All Rights Reserved . <nl> + / / <nl> + / / This code is licensed under the same terms as WebM : <nl> + / / Software License Agreement : http : / / www . webmproject . org / license / software / <nl> + / / Additional IP Rights Grant : http : / / www . webmproject . org / license / additional / <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / <nl> + / / WebP encoder : main interface <nl> + / / <nl> + / / Author : Skal ( pascal . massimino @ gmail . com ) <nl> + <nl> + # ifndef WEBP_WEBP_ENCODE_H_ <nl> + # define WEBP_WEBP_ENCODE_H_ <nl> + <nl> + # include " . / types . h " <nl> + <nl> + # if defined ( __cplusplus ) | | defined ( c_plusplus ) <nl> + extern " C " { <nl> + # endif <nl> + <nl> + # define WEBP_ENCODER_ABI_VERSION 0x0200 / / MAJOR ( 8b ) + MINOR ( 8b ) <nl> + <nl> + / / Return the encoder ' s version number , packed in hexadecimal using 8bits for <nl> + / / each of major / minor / revision . E . g : v2 . 5 . 7 is 0x020507 . <nl> + WEBP_EXTERN ( int ) WebPGetEncoderVersion ( void ) ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + / / One - stop - shop call ! No questions asked : <nl> + <nl> + / / Returns the size of the compressed data ( pointed to by * output ) , or 0 if <nl> + / / an error occurred . The compressed data must be released by the caller <nl> + / / using the call ' free ( * output ) ' . <nl> + / / These functions compress using the lossy format , and the quality_factor <nl> + / / can go from 0 ( smaller output , lower quality ) to 100 ( best quality , <nl> + / / larger output ) . <nl> + WEBP_EXTERN ( size_t ) WebPEncodeRGB ( const uint8_t * rgb , <nl> + int width , int height , int stride , <nl> + float quality_factor , uint8_t * * output ) ; <nl> + WEBP_EXTERN ( size_t ) WebPEncodeBGR ( const uint8_t * bgr , <nl> + int width , int height , int stride , <nl> + float quality_factor , uint8_t * * output ) ; <nl> + WEBP_EXTERN ( size_t ) WebPEncodeRGBA ( const uint8_t * rgba , <nl> + int width , int height , int stride , <nl> + float quality_factor , uint8_t * * output ) ; <nl> + WEBP_EXTERN ( size_t ) WebPEncodeBGRA ( const uint8_t * bgra , <nl> + int width , int height , int stride , <nl> + float quality_factor , uint8_t * * output ) ; <nl> + <nl> + / / These functions are the equivalent of the above , but compressing in a <nl> + / / lossless manner . Files are usually larger than lossy format , but will <nl> + / / not suffer any compression loss . <nl> + WEBP_EXTERN ( size_t ) WebPEncodeLosslessRGB ( const uint8_t * rgb , <nl> + int width , int height , int stride , <nl> + uint8_t * * output ) ; <nl> + WEBP_EXTERN ( size_t ) WebPEncodeLosslessBGR ( const uint8_t * bgr , <nl> + int width , int height , int stride , <nl> + uint8_t * * output ) ; <nl> + WEBP_EXTERN ( size_t ) WebPEncodeLosslessRGBA ( const uint8_t * rgba , <nl> + int width , int height , int stride , <nl> + uint8_t * * output ) ; <nl> + WEBP_EXTERN ( size_t ) WebPEncodeLosslessBGRA ( const uint8_t * bgra , <nl> + int width , int height , int stride , <nl> + uint8_t * * output ) ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + / / Coding parameters <nl> + <nl> + / / Image characteristics hint for the underlying encoder . <nl> + typedef enum { <nl> + WEBP_HINT_DEFAULT = 0 , / / default preset . <nl> + WEBP_HINT_PICTURE , / / digital picture , like portrait , inner shot <nl> + WEBP_HINT_PHOTO , / / outdoor photograph , with natural lighting <nl> + WEBP_HINT_GRAPH , / / Discrete tone image ( graph , map - tile etc ) . <nl> + WEBP_HINT_LAST <nl> + } WebPImageHint ; <nl> + <nl> + typedef struct { <nl> + int lossless ; / / Lossless encoding ( 0 = lossy ( default ) , 1 = lossless ) . <nl> + float quality ; / / between 0 ( smallest file ) and 100 ( biggest ) <nl> + int method ; / / quality / speed trade - off ( 0 = fast , 6 = slower - better ) <nl> + <nl> + WebPImageHint image_hint ; / / Hint for image type ( lossless only for now ) . <nl> + <nl> + / / Parameters related to lossy compression only : <nl> + int target_size ; / / if non - zero , set the desired target size in bytes . <nl> + / / Takes precedence over the ' compression ' parameter . <nl> + float target_PSNR ; / / if non - zero , specifies the minimal distortion to <nl> + / / try to achieve . Takes precedence over target_size . <nl> + int segments ; / / maximum number of segments to use , in [ 1 . . 4 ] <nl> + int sns_strength ; / / Spatial Noise Shaping . 0 = off , 100 = maximum . <nl> + int filter_strength ; / / range : [ 0 = off . . 100 = strongest ] <nl> + int filter_sharpness ; / / range : [ 0 = off . . 7 = least sharp ] <nl> + int filter_type ; / / filtering type : 0 = simple , 1 = strong ( only used <nl> + / / if filter_strength > 0 or autofilter > 0 ) <nl> + int autofilter ; / / Auto adjust filter ' s strength [ 0 = off , 1 = on ] <nl> + int alpha_compression ; / / Algorithm for encoding the alpha plane ( 0 = none , <nl> + / / 1 = compressed with WebP lossless ) . Default is 1 . <nl> + int alpha_filtering ; / / Predictive filtering method for alpha plane . <nl> + / / 0 : none , 1 : fast , 2 : best . Default if 1 . <nl> + int alpha_quality ; / / Between 0 ( smallest size ) and 100 ( lossless ) . <nl> + / / Default is 100 . <nl> + int pass ; / / number of entropy - analysis passes ( in [ 1 . . 10 ] ) . <nl> + <nl> + int show_compressed ; / / if true , export the compressed picture back . <nl> + / / In - loop filtering is not applied . <nl> + int preprocessing ; / / preprocessing filter ( 0 = none , 1 = segment - smooth ) <nl> + int partitions ; / / log2 ( number of token partitions ) in [ 0 . . 3 ] . Default <nl> + / / is set to 0 for easier progressive decoding . <nl> + int partition_limit ; / / quality degradation allowed to fit the 512k limit <nl> + / / on prediction modes coding ( 0 : no degradation , <nl> + / / 100 : maximum possible degradation ) . <nl> + <nl> + uint32_t pad [ 8 ] ; / / padding for later use <nl> + } WebPConfig ; <nl> + <nl> + / / Enumerate some predefined settings for WebPConfig , depending on the type <nl> + / / of source picture . These presets are used when calling WebPConfigPreset ( ) . <nl> + typedef enum { <nl> + WEBP_PRESET_DEFAULT = 0 , / / default preset . <nl> + WEBP_PRESET_PICTURE , / / digital picture , like portrait , inner shot <nl> + WEBP_PRESET_PHOTO , / / outdoor photograph , with natural lighting <nl> + WEBP_PRESET_DRAWING , / / hand or line drawing , with high - contrast details <nl> + WEBP_PRESET_ICON , / / small - sized colorful images <nl> + WEBP_PRESET_TEXT / / text - like <nl> + } WebPPreset ; <nl> + <nl> + / / Internal , version - checked , entry point <nl> + WEBP_EXTERN ( int ) WebPConfigInitInternal ( WebPConfig * , WebPPreset , float , int ) ; <nl> + <nl> + / / Should always be called , to initialize a fresh WebPConfig structure before <nl> + / / modification . Returns false in case of version mismatch . WebPConfigInit ( ) <nl> + / / must have succeeded before using the ' config ' object . <nl> + / / Note that the default values are lossless = 0 and quality = 75 . <nl> + static WEBP_INLINE int WebPConfigInit ( WebPConfig * config ) { <nl> + return WebPConfigInitInternal ( config , WEBP_PRESET_DEFAULT , 75 . f , <nl> + WEBP_ENCODER_ABI_VERSION ) ; <nl> + } <nl> + <nl> + / / This function will initialize the configuration according to a predefined <nl> + / / set of parameters ( referred to by ' preset ' ) and a given quality factor . <nl> + / / This function can be called as a replacement to WebPConfigInit ( ) . Will <nl> + / / return false in case of error . <nl> + static WEBP_INLINE int WebPConfigPreset ( WebPConfig * config , <nl> + WebPPreset preset , float quality ) { <nl> + return WebPConfigInitInternal ( config , preset , quality , <nl> + WEBP_ENCODER_ABI_VERSION ) ; <nl> + } <nl> + <nl> + / / Returns true if ' config ' is non - NULL and all configuration parameters are <nl> + / / within their valid ranges . <nl> + WEBP_EXTERN ( int ) WebPValidateConfig ( const WebPConfig * config ) ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + / / Input / Output <nl> + <nl> + typedef struct WebPPicture WebPPicture ; / / main structure for I / O <nl> + <nl> + / / Structure for storing auxiliary statistics ( mostly for lossy encoding ) . <nl> + typedef struct { <nl> + int coded_size ; / / final size <nl> + <nl> + float PSNR [ 5 ] ; / / peak - signal - to - noise ratio for Y / U / V / All / Alpha <nl> + int block_count [ 3 ] ; / / number of intra4 / intra16 / skipped macroblocks <nl> + int header_bytes [ 2 ] ; / / approximate number of bytes spent for header <nl> + / / and mode - partition # 0 <nl> + int residual_bytes [ 3 ] [ 4 ] ; / / approximate number of bytes spent for <nl> + / / DC / AC / uv coefficients for each ( 0 . . 3 ) segments . <nl> + int segment_size [ 4 ] ; / / number of macroblocks in each segments <nl> + int segment_quant [ 4 ] ; / / quantizer values for each segments <nl> + int segment_level [ 4 ] ; / / filtering strength for each segments [ 0 . . 63 ] <nl> + <nl> + int alpha_data_size ; / / size of the transparency data <nl> + int layer_data_size ; / / size of the enhancement layer data <nl> + <nl> + / / lossless encoder statistics <nl> + uint32_t lossless_features ; / / bit0 : predictor bit1 : cross - color transform <nl> + / / bit2 : subtract - green bit3 : color indexing <nl> + int histogram_bits ; / / number of precision bits of histogram <nl> + int transform_bits ; / / precision bits for transform <nl> + int cache_bits ; / / number of bits for color cache lookup <nl> + int palette_size ; / / number of color in palette , if used <nl> + int lossless_size ; / / final lossless size <nl> + <nl> + uint32_t pad [ 4 ] ; / / padding for later use <nl> + } WebPAuxStats ; <nl> + <nl> + / / Signature for output function . Should return true if writing was successful . <nl> + / / data / data_size is the segment of data to write , and ' picture ' is for <nl> + / / reference ( and so one can make use of picture - > custom_ptr ) . <nl> + typedef int ( * WebPWriterFunction ) ( const uint8_t * data , size_t data_size , <nl> + const WebPPicture * picture ) ; <nl> + <nl> + / / WebPMemoryWrite : a special WebPWriterFunction that writes to memory using <nl> + / / the following WebPMemoryWriter object ( to be set as a custom_ptr ) . <nl> + typedef struct { <nl> + uint8_t * mem ; / / final buffer ( of size ' max_size ' , larger than ' size ' ) . <nl> + size_t size ; / / final size <nl> + size_t max_size ; / / total capacity <nl> + uint32_t pad [ 1 ] ; / / padding for later use <nl> + } WebPMemoryWriter ; <nl> + <nl> + / / The following must be called first before any use . <nl> + WEBP_EXTERN ( void ) WebPMemoryWriterInit ( WebPMemoryWriter * writer ) ; <nl> + <nl> + / / The custom writer to be used with WebPMemoryWriter as custom_ptr . Upon <nl> + / / completion , writer . mem and writer . size will hold the coded data . <nl> + WEBP_EXTERN ( int ) WebPMemoryWrite ( const uint8_t * data , size_t data_size , <nl> + const WebPPicture * picture ) ; <nl> + <nl> + / / Progress hook , called from time to time to report progress . It can return <nl> + / / false to request an abort of the encoding process , or true otherwise if <nl> + / / everything is OK . <nl> + typedef int ( * WebPProgressHook ) ( int percent , const WebPPicture * picture ) ; <nl> + <nl> + typedef enum { <nl> + / / chroma sampling <nl> + WEBP_YUV420 = 0 , / / 4 : 2 : 0 <nl> + WEBP_YUV422 = 1 , / / 4 : 2 : 2 <nl> + WEBP_YUV444 = 2 , / / 4 : 4 : 4 <nl> + WEBP_YUV400 = 3 , / / grayscale <nl> + WEBP_CSP_UV_MASK = 3 , / / bit - mask to get the UV sampling factors <nl> + / / alpha channel variants <nl> + WEBP_YUV420A = 4 , <nl> + WEBP_YUV422A = 5 , <nl> + WEBP_YUV444A = 6 , <nl> + WEBP_YUV400A = 7 , / / grayscale + alpha <nl> + WEBP_CSP_ALPHA_BIT = 4 / / bit that is set if alpha is present <nl> + } WebPEncCSP ; <nl> + <nl> + / / Encoding error conditions . <nl> + typedef enum { <nl> + VP8_ENC_OK = 0 , <nl> + VP8_ENC_ERROR_OUT_OF_MEMORY , / / memory error allocating objects <nl> + VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY , / / memory error while flushing bits <nl> + VP8_ENC_ERROR_NULL_PARAMETER , / / a pointer parameter is NULL <nl> + VP8_ENC_ERROR_INVALID_CONFIGURATION , / / configuration is invalid <nl> + VP8_ENC_ERROR_BAD_DIMENSION , / / picture has invalid width / height <nl> + VP8_ENC_ERROR_PARTITION0_OVERFLOW , / / partition is bigger than 512k <nl> + VP8_ENC_ERROR_PARTITION_OVERFLOW , / / partition is bigger than 16M <nl> + VP8_ENC_ERROR_BAD_WRITE , / / error while flushing bytes <nl> + VP8_ENC_ERROR_FILE_TOO_BIG , / / file is bigger than 4G <nl> + VP8_ENC_ERROR_USER_ABORT , / / abort request by user <nl> + VP8_ENC_ERROR_LAST / / list terminator . always last . <nl> + } WebPEncodingError ; <nl> + <nl> + / / maximum width / height allowed ( inclusive ) , in pixels <nl> + # define WEBP_MAX_DIMENSION 16383 <nl> + <nl> + / / Main exchange structure ( input samples , output bytes , statistics ) <nl> + struct WebPPicture { <nl> + <nl> + / / INPUT <nl> + / / / / / / / / / / / / / / <nl> + / / Main flag for encoder selecting between ARGB or YUV input . <nl> + / / It is recommended to use ARGB input ( * argb , argb_stride ) for lossless <nl> + / / compression , and YUV input ( * y , * u , * v , etc . ) for lossy compression <nl> + / / since these are the respective native colorspace for these formats . <nl> + int use_argb ; <nl> + <nl> + / / YUV input ( mostly used for input to lossy compression ) <nl> + WebPEncCSP colorspace ; / / colorspace : should be YUV420 for now ( = Y ' CbCr ) . <nl> + int width , height ; / / dimensions ( less or equal to WEBP_MAX_DIMENSION ) <nl> + uint8_t * y , * u , * v ; / / pointers to luma / chroma planes . <nl> + int y_stride , uv_stride ; / / luma / chroma strides . <nl> + uint8_t * a ; / / pointer to the alpha plane <nl> + int a_stride ; / / stride of the alpha plane <nl> + uint32_t pad1 [ 2 ] ; / / padding for later use <nl> + <nl> + / / ARGB input ( mostly used for input to lossless compression ) <nl> + uint32_t * argb ; / / Pointer to argb ( 32 bit ) plane . <nl> + int argb_stride ; / / This is stride in pixels units , not bytes . <nl> + uint32_t pad2 [ 3 ] ; / / padding for later use <nl> + <nl> + / / OUTPUT <nl> + / / / / / / / / / / / / / / / <nl> + / / Byte - emission hook , to store compressed bytes as they are ready . <nl> + WebPWriterFunction writer ; / / can be NULL <nl> + void * custom_ptr ; / / can be used by the writer . <nl> + <nl> + / / map for extra information ( only for lossy compression mode ) <nl> + int extra_info_type ; / / 1 : intra type , 2 : segment , 3 : quant <nl> + / / 4 : intra - 16 prediction mode , <nl> + / / 5 : chroma prediction mode , <nl> + / / 6 : bit cost , 7 : distortion <nl> + uint8_t * extra_info ; / / if not NULL , points to an array of size <nl> + / / ( ( width + 15 ) / 16 ) * ( ( height + 15 ) / 16 ) that <nl> + / / will be filled with a macroblock map , depending <nl> + / / on extra_info_type . <nl> + <nl> + / / STATS AND REPORTS <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / Pointer to side statistics ( updated only if not NULL ) <nl> + WebPAuxStats * stats ; <nl> + <nl> + / / Error code for the latest error encountered during encoding <nl> + WebPEncodingError error_code ; <nl> + <nl> + / / If not NULL , report progress during encoding . <nl> + WebPProgressHook progress_hook ; <nl> + <nl> + void * user_data ; / / this field is free to be set to any value and <nl> + / / used during callbacks ( like progress - report e . g . ) . <nl> + <nl> + uint32_t pad3 [ 3 ] ; / / padding for later use <nl> + <nl> + / / Unused for now : original samples ( for non - YUV420 modes ) <nl> + uint8_t * u0 , * v0 ; <nl> + int uv0_stride ; <nl> + <nl> + uint32_t pad4 [ 7 ] ; / / padding for later use <nl> + <nl> + / / PRIVATE FIELDS <nl> + / / / / / / / / / / / / / / / / / / / / <nl> + void * memory_ ; / / row chunk of memory for yuva planes <nl> + void * memory_argb_ ; / / and for argb too . <nl> + void * pad5 [ 2 ] ; / / padding for later use <nl> + } ; <nl> + <nl> + / / Internal , version - checked , entry point <nl> + WEBP_EXTERN ( int ) WebPPictureInitInternal ( WebPPicture * , int ) ; <nl> + <nl> + / / Should always be called , to initialize the structure . Returns false in case <nl> + / / of version mismatch . WebPPictureInit ( ) must have succeeded before using the <nl> + / / ' picture ' object . <nl> + / / Note that , by default , use_argb is false and colorspace is WEBP_YUV420 . <nl> + static WEBP_INLINE int WebPPictureInit ( WebPPicture * picture ) { <nl> + return WebPPictureInitInternal ( picture , WEBP_ENCODER_ABI_VERSION ) ; <nl> + } <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + / / WebPPicture utils <nl> + <nl> + / / Convenience allocation / deallocation based on picture - > width / height : <nl> + / / Allocate y / u / v buffers as per colorspace / width / height specification . <nl> + / / Note ! This function will free the previous buffer if needed . <nl> + / / Returns false in case of memory error . <nl> + WEBP_EXTERN ( int ) WebPPictureAlloc ( WebPPicture * picture ) ; <nl> + <nl> + / / Release the memory allocated by WebPPictureAlloc ( ) or WebPPictureImport * ( ) . <nl> + / / Note that this function does _not_ free the memory used by the ' picture ' <nl> + / / object itself . <nl> + / / Besides memory ( which is reclaimed ) all other fields of ' picture ' are <nl> + / / preserved . <nl> + WEBP_EXTERN ( void ) WebPPictureFree ( WebPPicture * picture ) ; <nl> + <nl> + / / Copy the pixels of * src into * dst , using WebPPictureAlloc . Upon return , <nl> + / / * dst will fully own the copied pixels ( this is not a view ) . <nl> + / / Returns false in case of memory allocation error . <nl> + WEBP_EXTERN ( int ) WebPPictureCopy ( const WebPPicture * src , WebPPicture * dst ) ; <nl> + <nl> + / / Compute PSNR or SSIM distortion between two pictures . <nl> + / / Result is in dB , stores in result [ ] in the Y / U / V / Alpha / All order . <nl> + / / Returns false in case of error ( pic1 and pic2 don ' t have same dimension , . . . ) <nl> + / / Warning : this function is rather CPU - intensive . <nl> + WEBP_EXTERN ( int ) WebPPictureDistortion ( <nl> + const WebPPicture * pic1 , const WebPPicture * pic2 , <nl> + int metric_type , / / 0 = PSNR , 1 = SSIM <nl> + float result [ 5 ] ) ; <nl> + <nl> + / / self - crops a picture to the rectangle defined by top / left / width / height . <nl> + / / Returns false in case of memory allocation error , or if the rectangle is <nl> + / / outside of the source picture . <nl> + / / The rectangle for the view is defined by the top - left corner pixel <nl> + / / coordinates ( left , top ) as well as its width and height . This rectangle <nl> + / / must be fully be comprised inside the ' src ' source picture . If the source <nl> + / / picture uses the YUV420 colorspace , the top and left coordinates will be <nl> + / / snapped to even values . <nl> + WEBP_EXTERN ( int ) WebPPictureCrop ( WebPPicture * picture , <nl> + int left , int top , int width , int height ) ; <nl> + <nl> + / / Extracts a view from ' src ' picture into ' dst ' . The rectangle for the view <nl> + / / is defined by the top - left corner pixel coordinates ( left , top ) as well <nl> + / / as its width and height . This rectangle must be fully be comprised inside <nl> + / / the ' src ' source picture . If the source picture uses the YUV420 colorspace , <nl> + / / the top and left coordinates will be snapped to even values . <nl> + / / Picture ' src ' must out - live ' dst ' picture . Self - extraction of view is allowed <nl> + / / ( ' src ' equal to ' dst ' ) as a mean of fast - cropping ( but note that doing so , <nl> + / / the original dimension will be lost ) . <nl> + / / Returns false in case of memory allocation error or invalid parameters . <nl> + WEBP_EXTERN ( int ) WebPPictureView ( const WebPPicture * src , <nl> + int left , int top , int width , int height , <nl> + WebPPicture * dst ) ; <nl> + <nl> + / / Returns true if the ' picture ' is actually a view and therefore does <nl> + / / not own the memory for pixels . <nl> + WEBP_EXTERN ( int ) WebPPictureIsView ( const WebPPicture * picture ) ; <nl> + <nl> + / / Rescale a picture to new dimension width x height . <nl> + / / Now gamma correction is applied . <nl> + / / Returns false in case of error ( invalid parameter or insufficient memory ) . <nl> + WEBP_EXTERN ( int ) WebPPictureRescale ( WebPPicture * pic , int width , int height ) ; <nl> + <nl> + / / Colorspace conversion function to import RGB samples . <nl> + / / Previous buffer will be free ' d , if any . <nl> + / / * rgb buffer should have a size of at least height * rgb_stride . <nl> + / / Returns false in case of memory error . <nl> + WEBP_EXTERN ( int ) WebPPictureImportRGB ( <nl> + WebPPicture * picture , const uint8_t * rgb , int rgb_stride ) ; <nl> + / / Same , but for RGBA buffer . <nl> + WEBP_EXTERN ( int ) WebPPictureImportRGBA ( <nl> + WebPPicture * picture , const uint8_t * rgba , int rgba_stride ) ; <nl> + / / Same , but for RGBA buffer . Imports the RGB direct from the 32 - bit format <nl> + / / input buffer ignoring the alpha channel . Avoids needing to copy the data <nl> + / / to a temporary 24 - bit RGB buffer to import the RGB only . <nl> + WEBP_EXTERN ( int ) WebPPictureImportRGBX ( <nl> + WebPPicture * picture , const uint8_t * rgbx , int rgbx_stride ) ; <nl> + <nl> + / / Variants of the above , but taking BGR ( A | X ) input . <nl> + WEBP_EXTERN ( int ) WebPPictureImportBGR ( <nl> + WebPPicture * picture , const uint8_t * bgr , int bgr_stride ) ; <nl> + WEBP_EXTERN ( int ) WebPPictureImportBGRA ( <nl> + WebPPicture * picture , const uint8_t * bgra , int bgra_stride ) ; <nl> + WEBP_EXTERN ( int ) WebPPictureImportBGRX ( <nl> + WebPPicture * picture , const uint8_t * bgrx , int bgrx_stride ) ; <nl> + <nl> + / / Converts picture - > argb data to the YUVA format specified by ' colorspace ' . <nl> + / / Upon return , picture - > use_argb is set to false . The presence of real <nl> + / / non - opaque transparent values is detected , and ' colorspace ' will be <nl> + / / adjusted accordingly . Note that this method is lossy . <nl> + / / Returns false in case of error . <nl> + WEBP_EXTERN ( int ) WebPPictureARGBToYUVA ( WebPPicture * picture , <nl> + WebPEncCSP colorspace ) ; <nl> + <nl> + / / Converts picture - > yuv to picture - > argb and sets picture - > use_argb to true . <nl> + / / The input format must be YUV_420 or YUV_420A . <nl> + / / Note that the use of this method is discouraged if one has access to the <nl> + / / raw ARGB samples , since using YUV420 is comparatively lossy . Also , the <nl> + / / conversion from YUV420 to ARGB incurs a small loss too . <nl> + / / Returns false in case of error . <nl> + WEBP_EXTERN ( int ) WebPPictureYUVAToARGB ( WebPPicture * picture ) ; <nl> + <nl> + / / Helper function : given a width x height plane of YUV ( A ) samples <nl> + / / ( with stride ' stride ' ) , clean - up the YUV samples under fully transparent <nl> + / / area , to help compressibility ( no guarantee , though ) . <nl> + WEBP_EXTERN ( void ) WebPCleanupTransparentArea ( WebPPicture * picture ) ; <nl> + <nl> + / / Scan the picture ' picture ' for the presence of non fully opaque alpha values . <nl> + / / Returns true in such case . Otherwise returns false ( indicating that the <nl> + / / alpha plane can be ignored altogether e . g . ) . <nl> + WEBP_EXTERN ( int ) WebPPictureHasTransparency ( const WebPPicture * picture ) ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + / / Main call <nl> + <nl> + / / Main encoding call , after config and picture have been initialized . <nl> + / / ' picture ' must be less than 16384x16384 in dimension ( cf WEBP_MAX_DIMENSION ) , <nl> + / / and the ' config ' object must be a valid one . <nl> + / / Returns false in case of error , true otherwise . <nl> + / / In case of error , picture - > error_code is updated accordingly . <nl> + / / ' picture ' can hold the source samples in both YUV ( A ) or ARGB input , depending <nl> + / / on the value of ' picture - > use_argb ' . It is highly recommended to use <nl> + / / the former for lossy encoding , and the latter for lossless encoding <nl> + / / ( when config . lossless is true ) . Automatic conversion from one format to <nl> + / / another is provided but they both incur some loss . <nl> + WEBP_EXTERN ( int ) WebPEncode ( const WebPConfig * config , WebPPicture * picture ) ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + <nl> + # if defined ( __cplusplus ) | | defined ( c_plusplus ) <nl> + } / / extern " C " <nl> + # endif <nl> + <nl> + # endif / * WEBP_WEBP_ENCODE_H_ * / <nl> new file mode 100644 <nl> index 000000000000 . . 3e27190bef06 <nl> mmm / dev / null <nl> ppp b / cocos2dx / platform / third_party / mac / webp / types . h <nl> <nl> + / / Copyright 2010 Google Inc . All Rights Reserved . <nl> + / / <nl> + / / This code is licensed under the same terms as WebM : <nl> + / / Software License Agreement : http : / / www . webmproject . org / license / software / <nl> + / / Additional IP Rights Grant : http : / / www . webmproject . org / license / additional / <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / <nl> + / / Common types <nl> + / / <nl> + / / Author : Skal ( pascal . massimino @ gmail . com ) <nl> + <nl> + # ifndef WEBP_WEBP_TYPES_H_ <nl> + # define WEBP_WEBP_TYPES_H_ <nl> + <nl> + # include < stddef . h > / / for size_t <nl> + <nl> + # ifndef _MSC_VER <nl> + # include < inttypes . h > <nl> + # ifdef __STRICT_ANSI__ <nl> + # define WEBP_INLINE <nl> + # else / * __STRICT_ANSI__ * / <nl> + # define WEBP_INLINE inline <nl> + # endif <nl> + # else <nl> + typedef signed char int8_t ; <nl> + typedef unsigned char uint8_t ; <nl> + typedef signed short int16_t ; <nl> + typedef unsigned short uint16_t ; <nl> + typedef signed int int32_t ; <nl> + typedef unsigned int uint32_t ; <nl> + typedef unsigned long long int uint64_t ; <nl> + typedef long long int int64_t ; <nl> + # define WEBP_INLINE __forceinline <nl> + # endif / * _MSC_VER * / <nl> + <nl> + # ifndef WEBP_EXTERN <nl> + / / This explicitly marks library functions and allows for changing the <nl> + / / signature for e . g . , Windows DLL builds . <nl> + # define WEBP_EXTERN ( type ) extern type <nl> + # endif / * WEBP_EXTERN * / <nl> + <nl> + / / Macro to check ABI compatibility ( same major revision number ) <nl> + # define WEBP_ABI_IS_INCOMPATIBLE ( a , b ) ( ( ( a ) > > 8 ) ! = ( ( b ) > > 8 ) ) <nl> + <nl> + # endif / * WEBP_WEBP_TYPES_H_ * / <nl> mmm a / cocos2dx / proj . ios / cocos2dx . xcodeproj / project . pbxproj . REMOVED . git - id <nl> ppp b / cocos2dx / proj . ios / cocos2dx . xcodeproj / project . pbxproj . REMOVED . git - id <nl> @ @ - 1 + 1 @ @ <nl> - c48e73ebc6c9294a25c1d62ee5199eceb85aac29 <nl> \ No newline at end of file <nl> + 9c70c4fcfd0e094b9bb09f4a8e7f7a82b76caac3 <nl> \ No newline at end of file <nl> mmm a / cocos2dx / proj . mac / cocos2dx . xcodeproj / project . pbxproj . REMOVED . git - id <nl> ppp b / cocos2dx / proj . mac / cocos2dx . xcodeproj / project . pbxproj . REMOVED . git - id <nl> @ @ - 1 + 1 @ @ <nl> - 12a69c77eb22b6724ec95864bd0aaf5547261873 <nl> \ No newline at end of file <nl> + 302344d8d667c49b09f5f558cd10008f0864c71f <nl> \ No newline at end of file <nl> mmm a / samples / Cpp / TestCpp / proj . mac / TestCpp . xcodeproj / project . pbxproj . REMOVED . git - id <nl> ppp b / samples / Cpp / TestCpp / proj . mac / TestCpp . xcodeproj / project . pbxproj . REMOVED . git - id <nl> @ @ - 1 + 1 @ @ <nl> - 3c6884ef6d8f01816d6bffe1a3bf124b35cf4432 <nl> \ No newline at end of file <nl> + 155467f627970bd2b6b5e1e8d67b520f7b5bcde0 <nl> \ No newline at end of file <nl> | issue : Adding webp support for mac port . | cocos2d/cocos2d-x | cc690c5a86d0d93c075ccafbefea2a4c5f034d07 | 2013-02-06T05:06:48Z |
mmm a / src / qt / forms / sendcoinsdialog . ui <nl> ppp b / src / qt / forms / sendcoinsdialog . ui <nl> <nl> < number > 30 < / number > <nl> < / property > <nl> < item > <nl> - < widget class = " QSlider " name = " sliderSmartFee " > <nl> - < property name = " minimum " > <nl> + < layout class = " QHBoxLayout " name = " horizontalLayoutConfTarget " > <nl> + < property name = " bottomMargin " > <nl> < number > 0 < / number > <nl> < / property > <nl> - < property name = " maximum " > <nl> - < number > 23 < / number > <nl> - < / property > <nl> - < property name = " pageStep " > <nl> - < number > 1 < / number > <nl> - < / property > <nl> - < property name = " value " > <nl> - < number > 0 < / number > <nl> - < / property > <nl> - < property name = " orientation " > <nl> - < enum > Qt : : Horizontal < / enum > <nl> - < / property > <nl> - < property name = " invertedAppearance " > <nl> - < bool > false < / bool > <nl> - < / property > <nl> - < property name = " invertedControls " > <nl> - < bool > false < / bool > <nl> - < / property > <nl> - < property name = " tickPosition " > <nl> - < enum > QSlider : : NoTicks < / enum > <nl> - < / property > <nl> - < / widget > <nl> - < / item > <nl> - < item > <nl> - < layout class = " QHBoxLayout " name = " horizontalLayoutFee10 " > <nl> < item > <nl> - < widget class = " QLabel " name = " labelSmartFeeNormal " > <nl> - < property name = " text " > <nl> - < string > normal < / string > <nl> - < / property > <nl> - < / widget > <nl> + < widget class = " QComboBox " name = " confTargetSelector " / > <nl> < / item > <nl> < item > <nl> - < spacer name = " horizontalSpacer_7 " > <nl> + < spacer name = " horizontalSpacerConfTarget " > <nl> < property name = " orientation " > <nl> < enum > Qt : : Horizontal < / enum > <nl> < / property > <nl> <nl> < / property > <nl> < / spacer > <nl> < / item > <nl> - < item > <nl> - < widget class = " QLabel " name = " confirmationTargetLabel " > <nl> - < property name = " text " > <nl> - < string notr = " true " > ( count ) < / string > <nl> - < / property > <nl> - < / widget > <nl> - < / item > <nl> - < item > <nl> - < spacer name = " horizontalSpacer_3 " > <nl> - < property name = " orientation " > <nl> - < enum > Qt : : Horizontal < / enum > <nl> - < / property > <nl> - < property name = " sizeHint " stdset = " 0 " > <nl> - < size > <nl> - < width > 40 < / width > <nl> - < height > 20 < / height > <nl> - < / size > <nl> - < / property > <nl> - < / spacer > <nl> - < / item > <nl> - < item > <nl> - < widget class = " QLabel " name = " labelSmartFeeFast " > <nl> - < property name = " text " > <nl> - < string > fast < / string > <nl> - < / property > <nl> - < / widget > <nl> - < / item > <nl> < / layout > <nl> < / item > <nl> < / layout > <nl> mmm a / src / qt / sendcoinsdialog . cpp <nl> ppp b / src / qt / sendcoinsdialog . cpp <nl> <nl> # include < QTextDocument > <nl> # include < QTimer > <nl> <nl> + static const std : : array < int , 9 > confTargets = { { 2 , 4 , 6 , 12 , 24 , 48 , 144 , 504 , 1008 } } ; <nl> + int getConfTargetForIndex ( int index ) { <nl> + if ( index + 1 > static_cast < int > ( confTargets . size ( ) ) ) { <nl> + return confTargets . back ( ) ; <nl> + } <nl> + if ( index < 0 ) { <nl> + return confTargets [ 0 ] ; <nl> + } <nl> + return confTargets [ index ] ; <nl> + } <nl> + int getIndexForConfTarget ( int target ) { <nl> + for ( unsigned int i = 0 ; i < confTargets . size ( ) ; i + + ) { <nl> + if ( confTargets [ i ] > = target ) { <nl> + return i ; <nl> + } <nl> + } <nl> + return confTargets . size ( ) - 1 ; <nl> + } <nl> + <nl> SendCoinsDialog : : SendCoinsDialog ( const PlatformStyle * _platformStyle , QWidget * parent ) : <nl> QDialog ( parent ) , <nl> ui ( new Ui : : SendCoinsDialog ) , <nl> void SendCoinsDialog : : setModel ( WalletModel * _model ) <nl> coinControlUpdateLabels ( ) ; <nl> <nl> / / fee section <nl> - connect ( ui - > sliderSmartFee , SIGNAL ( valueChanged ( int ) ) , this , SLOT ( updateSmartFeeLabel ( ) ) ) ; <nl> - connect ( ui - > sliderSmartFee , SIGNAL ( valueChanged ( int ) ) , this , SLOT ( updateGlobalFeeVariables ( ) ) ) ; <nl> - connect ( ui - > sliderSmartFee , SIGNAL ( valueChanged ( int ) ) , this , SLOT ( coinControlUpdateLabels ( ) ) ) ; <nl> + for ( const int & n : confTargets ) { <nl> + ui - > confTargetSelector - > addItem ( tr ( " % 1 ( % 2 blocks ) " ) . arg ( GUIUtil : : formatNiceTimeOffset ( n * Params ( ) . GetConsensus ( ) . nPowTargetSpacing ) ) . arg ( n ) ) ; <nl> + } <nl> + connect ( ui - > confTargetSelector , SIGNAL ( currentIndexChanged ( int ) ) , this , SLOT ( updateSmartFeeLabel ( ) ) ) ; <nl> + connect ( ui - > confTargetSelector , SIGNAL ( currentIndexChanged ( int ) ) , this , SLOT ( updateGlobalFeeVariables ( ) ) ) ; <nl> + connect ( ui - > confTargetSelector , SIGNAL ( currentIndexChanged ( int ) ) , this , SLOT ( coinControlUpdateLabels ( ) ) ) ; <nl> connect ( ui - > groupFee , SIGNAL ( buttonClicked ( int ) ) , this , SLOT ( updateFeeSectionControls ( ) ) ) ; <nl> connect ( ui - > groupFee , SIGNAL ( buttonClicked ( int ) ) , this , SLOT ( updateGlobalFeeVariables ( ) ) ) ; <nl> connect ( ui - > groupFee , SIGNAL ( buttonClicked ( int ) ) , this , SLOT ( coinControlUpdateLabels ( ) ) ) ; <nl> void SendCoinsDialog : : setModel ( WalletModel * _model ) <nl> <nl> / / set the smartfee - sliders default value ( wallets default conf . target or last stored value ) <nl> QSettings settings ; <nl> - if ( settings . value ( " nSmartFeeSliderPosition " ) . toInt ( ) = = 0 ) <nl> - ui - > sliderSmartFee - > setValue ( ui - > sliderSmartFee - > maximum ( ) - model - > getDefaultConfirmTarget ( ) + 2 ) ; <nl> + if ( settings . value ( " nSmartFeeSliderPosition " ) . toInt ( ) ! = 0 ) { <nl> + / / migrate nSmartFeeSliderPosition to nConfTarget <nl> + / / nConfTarget is available since 0 . 15 ( replaced nSmartFeeSliderPosition ) <nl> + int nConfirmTarget = 25 - settings . value ( " nSmartFeeSliderPosition " ) . toInt ( ) ; / / 25 = = old slider range <nl> + settings . setValue ( " nConfTarget " , nConfirmTarget ) ; <nl> + settings . remove ( " nSmartFeeSliderPosition " ) ; <nl> + } <nl> + if ( settings . value ( " nConfTarget " ) . toInt ( ) = = 0 ) <nl> + ui - > confTargetSelector - > setCurrentIndex ( getIndexForConfTarget ( model - > getDefaultConfirmTarget ( ) ) ) ; <nl> else <nl> - ui - > sliderSmartFee - > setValue ( settings . value ( " nSmartFeeSliderPosition " ) . toInt ( ) ) ; <nl> + ui - > confTargetSelector - > setCurrentIndex ( getIndexForConfTarget ( settings . value ( " nConfTarget " ) . toInt ( ) ) ) ; <nl> } <nl> } <nl> <nl> SendCoinsDialog : : ~ SendCoinsDialog ( ) <nl> settings . setValue ( " fFeeSectionMinimized " , fFeeMinimized ) ; <nl> settings . setValue ( " nFeeRadio " , ui - > groupFee - > checkedId ( ) ) ; <nl> settings . setValue ( " nCustomFeeRadio " , ui - > groupCustomFee - > checkedId ( ) ) ; <nl> - settings . setValue ( " nSmartFeeSliderPosition " , ui - > sliderSmartFee - > value ( ) ) ; <nl> + settings . setValue ( " nConfTarget " , getConfTargetForIndex ( ui - > confTargetSelector - > currentIndex ( ) ) ) ; <nl> settings . setValue ( " nTransactionFee " , ( qint64 ) ui - > customFee - > value ( ) ) ; <nl> settings . setValue ( " fPayOnlyMinFee " , ui - > checkBoxMinimumFee - > isChecked ( ) ) ; <nl> <nl> void SendCoinsDialog : : on_sendButton_clicked ( ) <nl> if ( model - > getOptionsModel ( ) - > getCoinControlFeatures ( ) ) <nl> ctrl = * CoinControlDialog : : coinControl ; <nl> if ( ui - > radioSmartFee - > isChecked ( ) ) <nl> - ctrl . nConfirmTarget = ui - > sliderSmartFee - > maximum ( ) - ui - > sliderSmartFee - > value ( ) + 2 ; <nl> + ctrl . nConfirmTarget = getConfTargetForIndex ( ui - > confTargetSelector - > currentIndex ( ) ) ; <nl> else <nl> ctrl . nConfirmTarget = 0 ; <nl> <nl> void SendCoinsDialog : : setMinimumFee ( ) <nl> <nl> void SendCoinsDialog : : updateFeeSectionControls ( ) <nl> { <nl> - ui - > sliderSmartFee - > setEnabled ( ui - > radioSmartFee - > isChecked ( ) ) ; <nl> + ui - > confTargetSelector - > setEnabled ( ui - > radioSmartFee - > isChecked ( ) ) ; <nl> ui - > labelSmartFee - > setEnabled ( ui - > radioSmartFee - > isChecked ( ) ) ; <nl> ui - > labelSmartFee2 - > setEnabled ( ui - > radioSmartFee - > isChecked ( ) ) ; <nl> ui - > labelSmartFee3 - > setEnabled ( ui - > radioSmartFee - > isChecked ( ) ) ; <nl> ui - > labelFeeEstimation - > setEnabled ( ui - > radioSmartFee - > isChecked ( ) ) ; <nl> - ui - > labelSmartFeeNormal - > setEnabled ( ui - > radioSmartFee - > isChecked ( ) ) ; <nl> - ui - > labelSmartFeeFast - > setEnabled ( ui - > radioSmartFee - > isChecked ( ) ) ; <nl> - ui - > confirmationTargetLabel - > setEnabled ( ui - > radioSmartFee - > isChecked ( ) ) ; <nl> ui - > checkBoxMinimumFee - > setEnabled ( ui - > radioCustomFee - > isChecked ( ) ) ; <nl> ui - > labelMinFeeWarning - > setEnabled ( ui - > radioCustomFee - > isChecked ( ) ) ; <nl> ui - > radioCustomPerKilobyte - > setEnabled ( ui - > radioCustomFee - > isChecked ( ) & & ! ui - > checkBoxMinimumFee - > isChecked ( ) ) ; <nl> void SendCoinsDialog : : updateGlobalFeeVariables ( ) <nl> { <nl> if ( ui - > radioSmartFee - > isChecked ( ) ) <nl> { <nl> - int nConfirmTarget = ui - > sliderSmartFee - > maximum ( ) - ui - > sliderSmartFee - > value ( ) + 2 ; <nl> payTxFee = CFeeRate ( 0 ) ; <nl> - <nl> - / / show the estimated required time for confirmation <nl> - ui - > confirmationTargetLabel - > setText ( GUIUtil : : formatDurationStr ( nConfirmTarget * Params ( ) . GetConsensus ( ) . nPowTargetSpacing ) + " / " + tr ( " % n block ( s ) " , " " , nConfirmTarget ) ) ; <nl> } <nl> else <nl> { <nl> void SendCoinsDialog : : updateSmartFeeLabel ( ) <nl> if ( ! model | | ! model - > getOptionsModel ( ) ) <nl> return ; <nl> <nl> - int nBlocksToConfirm = ui - > sliderSmartFee - > maximum ( ) - ui - > sliderSmartFee - > value ( ) + 2 ; <nl> + int nBlocksToConfirm = getConfTargetForIndex ( ui - > confTargetSelector - > currentIndex ( ) ) ; <nl> FeeCalculation feeCalc ; <nl> bool conservative_estimate = CalculateEstimateType ( FeeEstimateMode : : UNSET , ui - > optInRBF - > isChecked ( ) ) ; <nl> CFeeRate feeRate = : : feeEstimator . estimateSmartFee ( nBlocksToConfirm , & feeCalc , : : mempool , conservative_estimate ) ; <nl> void SendCoinsDialog : : coinControlUpdateLabels ( ) <nl> CoinControlDialog : : payAmounts . clear ( ) ; <nl> CoinControlDialog : : fSubtractFeeFromAmount = false ; <nl> if ( ui - > radioSmartFee - > isChecked ( ) ) { <nl> - CoinControlDialog : : coinControl - > nConfirmTarget = ui - > sliderSmartFee - > maximum ( ) - ui - > sliderSmartFee - > value ( ) + 2 ; <nl> + CoinControlDialog : : coinControl - > nConfirmTarget = getConfTargetForIndex ( ui - > confTargetSelector - > currentIndex ( ) ) ; <nl> } else { <nl> CoinControlDialog : : coinControl - > nConfirmTarget = model - > getDefaultConfirmTarget ( ) ; <nl> } <nl> | Merge : [ Qt ] replace fee slider with a Dropdown , extend conf . targets | bitcoin/bitcoin | 8fdd23a224ba236874ef662c4ca311b002dbcab3 | 2017-07-15T02:24:09Z |
mmm a / xbmc / utils / JobManager . cpp <nl> ppp b / xbmc / utils / JobManager . cpp <nl> CJobManager : : CJobManager ( ) <nl> m_jobCounter = 0 ; <nl> m_running = true ; <nl> m_pauseJobs = false ; <nl> + m_tangle = 0 ; <nl> } <nl> <nl> void CJobManager : : Restart ( ) <nl> void CJobManager : : CancelJob ( unsigned int jobID ) <nl> Processing : : iterator it = find ( m_processing . begin ( ) , m_processing . end ( ) , jobID ) ; <nl> if ( it ! = m_processing . end ( ) ) <nl> it - > m_callback = NULL ; / / job is in progress , so only thing to do is to remove callback <nl> + <nl> + / / wait for tangled callbacks to finish <nl> + while ( m_tangle ) <nl> + { <nl> + CLog : : Log ( LOGDEBUG , " CJobManager : : CancelJob - waiting for tangled callbacks " ) ; <nl> + m_tangle_cond . wait ( m_section ) ; <nl> + } <nl> } <nl> <nl> void CJobManager : : StartWorkers ( CJob : : PRIORITY priority ) <nl> CJob * CJobManager : : GetNextJob ( const CJobWorker * worker ) <nl> return NULL ; <nl> } <nl> <nl> - bool CJobManager : : OnJobProgress ( unsigned int progress , unsigned int total , const CJob * job ) const <nl> + bool CJobManager : : OnJobProgress ( unsigned int progress , unsigned int total , const CJob * job ) <nl> { <nl> CSingleLock lock ( m_section ) ; <nl> + <nl> / / find the job in the processing queue , and check whether it ' s cancelled ( no callback ) <nl> Processing : : const_iterator i = find ( m_processing . begin ( ) , m_processing . end ( ) , job ) ; <nl> if ( i ! = m_processing . end ( ) ) <nl> { <nl> CWorkItem item ( * i ) ; <nl> - lock . Leave ( ) ; / / leave section prior to call <nl> + <nl> if ( item . m_callback ) <nl> { <nl> + m_tangle + + ; <nl> + lock . Leave ( ) ; / / leave section prior to call <nl> item . m_callback - > OnJobProgress ( item . m_id , progress , total , job ) ; <nl> + lock . Enter ( ) ; <nl> + m_tangle - - ; <nl> + m_tangle_cond . notifyAll ( ) ; <nl> return false ; <nl> } <nl> } <nl> void CJobManager : : OnJobComplete ( bool success , CJob * job ) <nl> { <nl> / / tell any listeners we ' re done with the job , then delete it <nl> CWorkItem item ( * i ) ; <nl> + <nl> + m_tangle + + ; <nl> lock . Leave ( ) ; <nl> try <nl> { <nl> void CJobManager : : OnJobComplete ( bool success , CJob * job ) <nl> CLog : : Log ( LOGERROR , " % s error processing job % s " , __FUNCTION__ , item . m_job - > GetType ( ) ) ; <nl> } <nl> lock . Enter ( ) ; <nl> + m_tangle - - ; <nl> + m_tangle_cond . notifyAll ( ) ; <nl> + <nl> Processing : : iterator j = find ( m_processing . begin ( ) , m_processing . end ( ) , job ) ; <nl> if ( j ! = m_processing . end ( ) ) <nl> m_processing . erase ( j ) ; <nl> mmm a / xbmc / utils / JobManager . h <nl> ppp b / xbmc / utils / JobManager . h <nl> class CJobManager <nl> \ return true if the job has been cancelled , else returns false . <nl> \ sa IJobCallback , CJob <nl> * / <nl> - bool OnJobProgress ( unsigned int progress , unsigned int total , const CJob * job ) const ; <nl> + bool OnJobProgress ( unsigned int progress , unsigned int total , const CJob * job ) ; <nl> <nl> private : <nl> / / private construction , and no assignements ; use the provided singleton methods <nl> class CJobManager <nl> CCriticalSection m_section ; <nl> CEvent m_jobEvent ; <nl> bool m_running ; <nl> + <nl> + XbmcThreads : : ConditionVariable m_tangle_cond ; <nl> + unsigned int m_tangle ; / * ! < Active callbacks currently running * / <nl> } ; <nl> | Merge pull request from elupus / jobsegv | xbmc/xbmc | 85ea7a1e0b711a9cd0f8c91f3d67a6265683ea6a | 2014-11-20T00:04:18Z |
mmm a / src / butil / containers / pooled_map . h <nl> ppp b / src / butil / containers / pooled_map . h <nl> class PooledAllocator { <nl> void swap ( PooledAllocator & other ) { _pool . swap ( other . _pool ) ; } <nl> <nl> / / Convert references to pointers . <nl> - pointer address ( reference r ) const { return & r ; } ; <nl> - const_pointer address ( const_reference r ) const { return & r ; } ; <nl> + pointer address ( reference r ) const { return & r ; } <nl> + const_pointer address ( const_reference r ) const { return & r ; } <nl> <nl> / / Allocate storage for n values of T1 . <nl> pointer allocate ( size_type n , PooledAllocator < void , 0 > : : const_pointer = 0 ) { <nl> class PooledAllocator { <nl> } else { <nl> return ( pointer ) malloc ( n * sizeof ( T1 ) ) ; <nl> } <nl> - } ; <nl> + } <nl> <nl> / / Deallocate storage obtained by a call to allocate . <nl> void deallocate ( pointer p , size_type n ) { <nl> class PooledAllocator { <nl> } else { <nl> free ( p ) ; <nl> } <nl> - } ; <nl> + } <nl> <nl> / / Return the largest possible storage available through a call to allocate . <nl> - size_type max_size ( ) const { return 0xFFFFFFFF / sizeof ( T1 ) ; } ; <nl> + size_type max_size ( ) const { return 0xFFFFFFFF / sizeof ( T1 ) ; } <nl> <nl> - void construct ( pointer ptr ) { : : new ( ptr ) T1 ; } ; <nl> - void construct ( pointer ptr , const T1 & val ) { : : new ( ptr ) T1 ( val ) ; } ; <nl> + void construct ( pointer ptr ) { : : new ( ptr ) T1 ; } <nl> + void construct ( pointer ptr , const T1 & val ) { : : new ( ptr ) T1 ( val ) ; } <nl> template < class U1 > void construct ( pointer ptr , const U1 & val ) <nl> { : : new ( ptr ) T1 ( val ) ; } <nl> <nl> - void destroy ( pointer p ) { p - > T1 : : ~ T1 ( ) ; } ; <nl> + void destroy ( pointer p ) { p - > T1 : : ~ T1 ( ) ; } <nl> <nl> private : <nl> butil : : SingleThreadedPool < sizeof ( T1 ) , BLOCK_SIZE , 1 > _pool ; <nl> class PooledAllocator { <nl> / / and vice versa . It ' s clear that our allocator can ' t be exchanged . <nl> template < typename T1 , size_t S1 , typename T2 , size_t S2 > <nl> bool operator = = ( const PooledAllocator < T1 , S1 > & , const PooledAllocator < T2 , S2 > & ) <nl> - { return false ; } ; <nl> + { return false ; } <nl> template < typename T1 , size_t S1 , typename T2 , size_t S2 > <nl> bool operator ! = ( const PooledAllocator < T1 , S1 > & a , const PooledAllocator < T2 , S2 > & b ) <nl> - { return ! ( a = = b ) ; } ; <nl> + { return ! ( a = = b ) ; } <nl> <nl> } / / namespace details <nl> } / / namespace butil <nl> | Merge pull request from zjbztianya / dev | apache/incubator-brpc | 18a96d5b1033bde9d098f843eaece4b75957af99 | 2018-07-18T02:28:35Z |
mmm a / jstests / sharding / hash_shard_unique_compound . js <nl> ppp b / jstests / sharding / hash_shard_unique_compound . js <nl> <nl> - / / Basic test of sharding with a hashed shard key and other unique index <nl> - / / Does 2 things and checks for consistent error : <nl> - / / 1 . ) shard collection on hashed " a " , ensure unique index { a : 1 , b : 1 } <nl> - / / 2 . ) reverse order <nl> - <nl> - / / This test triggers a compiler bug that causes a crash when compiling with optimizations on , see <nl> - / / SERVER - 36321 . <nl> - / / @ tags : [ <nl> - / / blacklist_from_rhel_67_s390x , <nl> - / / need_fixing_for_46 <nl> - / / ] <nl> + / * * <nl> + * Basic test of sharding with a hashed shard key and other unique index . Does 2 things and checks <nl> + * for consistent error : <nl> + * 1 . shard collection on hashed " a " , ensure unique index { a : 1 , b : 1 } <nl> + * 2 . reverse order <nl> + * / <nl> ( function ( ) { <nl> ' use strict ' ; <nl> <nl> mmm a / jstests / sharding / move_chunk_critical_section_non_internal_client_abort . js <nl> ppp b / jstests / sharding / move_chunk_critical_section_non_internal_client_abort . js <nl> <nl> * Tests that a moveChunk operation is properly aborted when an index command is received from a <nl> * non - internal client while in the critical section . <nl> * <nl> - * @ tags : [ need_fixing_for_46 ] <nl> + * @ tags [ <nl> + * requires_fcv_46 , <nl> + * ] <nl> * / <nl> ( function ( ) { <nl> " use strict " ; <nl> mmm a / jstests / sharding / retryable_write_error_labels . js <nl> ppp b / jstests / sharding / retryable_write_error_labels . js <nl> <nl> * @ tags : [ <nl> * requires_find_command , <nl> * uses_transactions , <nl> - * need_fixing_for_46 <nl> * ] <nl> * / <nl> - <nl> ( function ( ) { <nl> " use strict " ; <nl> <nl> mmm a / jstests / sharding / transactions_multi_writes . js <nl> ppp b / jstests / sharding / transactions_multi_writes . js <nl> <nl> - / / Verifies multi - writes in transactions are sent with shard versions to only the targeted shards . <nl> - / / <nl> - / / @ tags : [ <nl> - / / requires_find_command , <nl> - / / requires_sharding , <nl> - / / uses_multi_shard_transaction , <nl> - / / uses_transactions , <nl> - / / need_fixing_for_46 <nl> - / / ] <nl> + / * * <nl> + * Verifies multi - writes in transactions are sent with shard versions to only the targeted shards . <nl> + * <nl> + * @ tags : [ <nl> + * requires_find_command , <nl> + * requires_sharding , <nl> + * uses_multi_shard_transaction , <nl> + * uses_transactions , <nl> + * ] <nl> + * / <nl> ( function ( ) { <nl> " use strict " ; <nl> <nl> mmm a / jstests / sharding / transactions_view_resolution . js <nl> ppp b / jstests / sharding / transactions_view_resolution . js <nl> <nl> - / / Tests mongos behavior when reading against views in a transaction . <nl> - / / <nl> - / / @ tags : [ <nl> - / / requires_find_command , <nl> - / / requires_sharding , <nl> - / / uses_multi_shard_transaction , <nl> - / / uses_transactions , <nl> - / / need_fixing_for_46 <nl> - / / ] <nl> + / * * <nl> + * Tests mongos behavior when reading against views in a transaction . <nl> + * <nl> + * @ tags : [ <nl> + * requires_find_command , <nl> + * requires_sharding , <nl> + * uses_multi_shard_transaction , <nl> + * uses_transactions , <nl> + * ] <nl> + * / <nl> ( function ( ) { <nl> " use strict " ; <nl> <nl> mmm a / jstests / sharding / update_compound_shard_key . js <nl> ppp b / jstests / sharding / update_compound_shard_key . js <nl> <nl> * sessionDB . coll . find ( ) will throw " Cannot run a legacy query on a session " . <nl> * <nl> * @ tags : [ <nl> - * requires_find_command , <nl> - * uses_multi_shard_transaction , <nl> - * uses_transactions , <nl> - * need_fixing_for_46 <nl> + * requires_find_command , <nl> + * uses_multi_shard_transaction , <nl> + * uses_transactions , <nl> * ] <nl> * / <nl> ( function ( ) { <nl> mmm a / jstests / sharding / update_shard_key_conflicting_writes . js <nl> ppp b / jstests / sharding / update_shard_key_conflicting_writes . js <nl> <nl> * sessionDB . coll . find ( ) will throw " Cannot run a legacy query on a session " . <nl> * <nl> * @ tags : [ <nl> - * requires_find_command , <nl> - * uses_transactions , <nl> - * uses_multi_shard_transaction , <nl> - * need_fixing_for_46 <nl> + * requires_find_command , <nl> + * uses_multi_shard_transaction , <nl> + * uses_transactions , <nl> * ] <nl> * / <nl> <nl> mmm a / jstests / sharding / update_sharded . js <nl> ppp b / jstests / sharding / update_sharded . js <nl> <nl> - / / Test simple updates issued through mongos . Updates have different constraints through mongos , <nl> - / / since shard key is immutable . <nl> - / / <nl> - / / Updating a shard key in a single statement may use a multi shard transaction . <nl> - / / Use the ' requires_find_command ' tag to skip this test in sharding_op_query suite . <nl> - / / Otherwise , sessionDb . coll . find ( ) will throw " Cannot run a legacy query on a session " . <nl> - / / <nl> - / / @ tags : [ <nl> - / / requires_find_command , <nl> - / / uses_multi_shard_transaction , <nl> - / / uses_transactions , <nl> - / / need_fixing_for_46 <nl> - / / ] <nl> + / * * <nl> + * Test simple updates issued through mongos . Updates have different constraints through mongos , <nl> + * since shard key is immutable . <nl> + * <nl> + * Updating a shard key in a single statement may use a multi shard transaction . Uses the <nl> + * ' requires_find_command ' tag to skip this test in sharding_op_query suite . Otherwise , <nl> + * sessionDb . coll . find ( ) will throw " Cannot run a legacy query on a session " . <nl> + * <nl> + * @ tags : [ <nl> + * requires_find_command , <nl> + * uses_multi_shard_transaction , <nl> + * uses_transactions , <nl> + * ] <nl> + * / <nl> ( function ( ) { <nl> <nl> load ( " jstests / sharding / libs / sharded_transactions_helpers . js " ) ; <nl> | SERVER - 48182 Enable tests dependent on the backport of SERVER - 46679 to run in multi - version suites | mongodb/mongo | c9a0717687ed1dc70efac8dbaff06b14551ee6f3 | 2020-05-14T14:10:26Z |
mmm a / Documentation / Scripts / generateExamples . py <nl> ppp b / Documentation / Scripts / generateExamples . py <nl> def analyzeFile ( f , filename ) : <nl> if line [ 0 ] = = " | " : <nl> if line . startswith ( " | " ) : <nl> line = line [ 2 : ] <nl> + elif line . startswith ( " | ~ " ) : <nl> + showCmd = False <nl> + line = line [ 3 : ] <nl> + elif line . startswith ( " | ~ " ) : <nl> + showCmd = False <nl> + line = line [ 2 : ] <nl> else : <nl> line = line [ 1 : ] <nl> <nl> | Handle combination of multiline and hidden lines | arangodb/arangodb | f07e146ad4f8d27117c04607b7329bdabe2ab07e | 2015-08-14T12:59:27Z |
mmm a / lib / IRGen / GenEnum . cpp <nl> ppp b / lib / IRGen / GenEnum . cpp <nl> EnumImplStrategy : : get ( TypeConverter & TC , SILType type , EnumDecl * theEnum ) { <nl> origArgType = theEnum - > mapTypeIntoContext ( origArgType ) ; <nl> <nl> auto origArgLoweredTy = TC . IGM . getLoweredType ( origArgType ) ; <nl> - auto origArgTI = TC . tryGetCompleteTypeInfo ( origArgLoweredTy . getASTType ( ) ) ; <nl> - assert ( origArgTI & & " didn ' t complete type info ? ! " ) ; <nl> + auto * origArgTI = & TC . getCompleteTypeInfo ( origArgLoweredTy . getASTType ( ) ) ; <nl> <nl> / / If the unsubstituted argument contains a generic parameter type , or <nl> / / is not fixed - size in all resilience domains that have knowledge of <nl> mmm a / lib / IRGen / GenRecord . h <nl> ppp b / lib / IRGen / GenRecord . h <nl> class RecordTypeBuilder { <nl> auto & astField = astFields [ i ] ; <nl> / / Compute the field ' s type info . <nl> auto & fieldTI = IGM . getTypeInfo ( asImpl ( ) - > getType ( astField ) ) ; <nl> - assert ( fieldTI . isComplete ( ) ) ; <nl> fieldTypesForLayout . push_back ( & fieldTI ) ; <nl> <nl> fields . push_back ( FieldImpl ( asImpl ( ) - > getFieldInfo ( i , astField , fieldTI ) ) ) ; <nl> mmm a / lib / IRGen / GenType . cpp <nl> ppp b / lib / IRGen / GenType . cpp <nl> const TypeInfo & IRGenModule : : getTypeInfoForLowered ( CanType T ) { <nl> const TypeInfo & TypeConverter : : getCompleteTypeInfo ( CanType T ) { <nl> auto entry = getTypeEntry ( T ) ; <nl> assert ( entry . is < const TypeInfo * > ( ) & & " getting TypeInfo recursively ! " ) ; <nl> - auto & ti = * entry . get < const TypeInfo * > ( ) ; <nl> - assert ( ti . isComplete ( ) ) ; <nl> - return ti ; <nl> - } <nl> - <nl> - const TypeInfo * TypeConverter : : tryGetCompleteTypeInfo ( CanType T ) { <nl> - auto entry = getTypeEntry ( T ) ; <nl> - if ( ! entry . is < const TypeInfo * > ( ) ) return nullptr ; <nl> - auto & ti = * entry . get < const TypeInfo * > ( ) ; <nl> - if ( ! ti . isComplete ( ) ) return nullptr ; <nl> - return & ti ; <nl> + return * entry . get < const TypeInfo * > ( ) ; <nl> } <nl> <nl> ArchetypeType * TypeConverter : : getExemplarArchetype ( ArchetypeType * t ) { <nl> mmm a / lib / IRGen / GenType . h <nl> ppp b / lib / IRGen / GenType . h <nl> class TypeConverter { <nl> <nl> TypeCacheEntry getTypeEntry ( CanType type ) ; <nl> const TypeInfo & getCompleteTypeInfo ( CanType type ) ; <nl> - const TypeInfo * tryGetCompleteTypeInfo ( CanType type ) ; <nl> const LoadableTypeInfo & getNativeObjectTypeInfo ( ) ; <nl> const LoadableTypeInfo & getUnknownObjectTypeInfo ( ) ; <nl> const LoadableTypeInfo & getBridgeObjectTypeInfo ( ) ; <nl> mmm a / lib / IRGen / TypeInfo . h <nl> ppp b / lib / IRGen / TypeInfo . h <nl> class TypeInfo { <nl> <nl> friend class TypeConverter ; <nl> <nl> - enum : unsigned { InvalidAlignmentShift = 63 } ; <nl> - <nl> protected : <nl> union { <nl> uint64_t OpaqueBits ; <nl> class TypeInfo { <nl> IsFixedSize_t alwaysFixedSize , <nl> SpecialTypeInfoKind stik ) : StorageType ( Type ) { <nl> assert ( stik > = SpecialTypeInfoKind : : Fixed | | ! alwaysFixedSize ) ; <nl> + assert ( ! A . isZero ( ) & & " Invalid alignment " ) ; <nl> Bits . OpaqueBits = 0 ; <nl> Bits . TypeInfo . Kind = unsigned ( stik ) ; <nl> - Bits . TypeInfo . AlignmentShift = A . isZero ( ) ? InvalidAlignmentShift <nl> - : llvm : : Log2_32 ( A . getValue ( ) ) ; <nl> + Bits . TypeInfo . AlignmentShift = llvm : : Log2_32 ( A . getValue ( ) ) ; <nl> Bits . TypeInfo . POD = pod ; <nl> Bits . TypeInfo . BitwiseTakable = bitwiseTakable ; <nl> Bits . TypeInfo . SubclassKind = InvalidSubclassKind ; <nl> class TypeInfo { <nl> return static_cast < const T & > ( * this ) ; <nl> } <nl> <nl> - / / / Whether this type info has been completely converted . <nl> - bool isComplete ( ) const { <nl> - return Bits . TypeInfo . AlignmentShift ! = InvalidAlignmentShift ; <nl> - } <nl> - <nl> / / / Whether this type is known to be empty . <nl> bool isKnownEmpty ( ResilienceExpansion expansion ) const ; <nl> <nl> class TypeInfo { <nl> <nl> Alignment getBestKnownAlignment ( ) const { <nl> auto Shift = Bits . TypeInfo . AlignmentShift ; <nl> - assert ( Shift ! = InvalidAlignmentShift ) ; <nl> return Alignment ( 1ull < < Shift ) ; <nl> } <nl> <nl> mmm a / lib / SIL / SILInstruction . cpp <nl> ppp b / lib / SIL / SILInstruction . cpp <nl> SILInstructionResultArray : : SILInstructionResultArray ( <nl> auto TRangeBegin = TypedRange . begin ( ) ; <nl> auto TRangeIter = TRangeBegin ; <nl> auto TRangeEnd = TypedRange . end ( ) ; <nl> - assert ( MVResults . size ( ) = = unsigned ( std : : distance ( VRangeBegin , VRangeEnd ) ) ) ; <nl> + assert ( MVResults . size ( ) = = unsigned ( std : : distance ( TRangeBegin , TRangeEnd ) ) ) ; <nl> for ( unsigned i : indices ( MVResults ) ) { <nl> assert ( SILValue ( & MVResults [ i ] ) = = ( * this ) [ i ] ) ; <nl> assert ( SILValue ( & MVResults [ i ] ) - > getType ( ) = = ( * this ) [ i ] - > getType ( ) ) ; <nl> mmm a / lib / SILOptimizer / SILCombiner / SILCombinerCastVisitors . cpp <nl> ppp b / lib / SILOptimizer / SILCombiner / SILCombinerCastVisitors . cpp <nl> visitPointerToAddressInst ( PointerToAddressInst * PTAI ) { <nl> SILInstruction * <nl> SILCombiner : : visitUncheckedAddrCastInst ( UncheckedAddrCastInst * UADCI ) { <nl> Builder . setCurrentDebugScope ( UADCI - > getDebugScope ( ) ) ; <nl> - SILModule & Mod = UADCI - > getModule ( ) ; <nl> <nl> / / ( unchecked - addr - cast ( unchecked - addr - cast x X - > Y ) Y - > Z ) <nl> / / - > <nl> | Merge pull request from slavapestov / sundry - fixes | apple/swift | 014f6f3c1233443f6d9d4604702a63014cdde908 | 2018-05-10T04:14:40Z |
mmm a / . travis . yml <nl> ppp b / . travis . yml <nl> matrix : <nl> - env : BUILD = Release STANDARD = 14 <nl> compiler : clang <nl> os : osx <nl> - # clang 6 . 0 on Linux with C + + 14 <nl> - - env : COMPILER = clang + + - 6 . 0 BUILD = Debug STANDARD = 14 <nl> + # clang 6 . 0 on Linux with C + + 14 ( builds the fuzzers as well ) <nl> + - env : COMPILER = clang + + - 6 . 0 BUILD = Debug STANDARD = 14 ENABLE_FUZZING = 1 <nl> compiler : clang <nl> addons : <nl> apt : <nl> mmm a / CMakeLists . txt <nl> ppp b / CMakeLists . txt <nl> option ( FMT_WERROR " Halt the compilation with an error on compiler warnings . " <nl> option ( FMT_DOC " Generate the doc target . " $ { MASTER_PROJECT } ) <nl> option ( FMT_INSTALL " Generate the install target . " $ { MASTER_PROJECT } ) <nl> option ( FMT_TEST " Generate the test target . " $ { MASTER_PROJECT } ) <nl> + option ( FMT_FUZZ " Generate the fuzz target . " OFF ) <nl> <nl> project ( FMT CXX ) <nl> <nl> endfunction ( ) <nl> <nl> # Define the fmt library , its includes and the needed defines . <nl> add_headers ( FMT_HEADERS chrono . h color . h core . h format . h format - inl . h locale . h <nl> - ostream . h prepare . h printf . h ranges . h ) <nl> + ostream . h prepare . h printf . h ranges . h safe - duration - cast . h ) <nl> set ( FMT_SOURCES src / format . cc ) <nl> if ( HAVE_OPEN ) <nl> add_headers ( FMT_HEADERS posix . h ) <nl> if ( BUILD_SHARED_LIBS ) <nl> endif ( ) <nl> target_compile_definitions ( fmt PRIVATE FMT_EXPORT INTERFACE FMT_SHARED ) <nl> endif ( ) <nl> + if ( FMT_SAFE_DURATION_CAST ) <nl> + target_compile_definitions ( fmt PUBLIC FMT_SAFE_DURATION_CAST ) <nl> + endif ( ) <nl> <nl> add_library ( fmt - header - only INTERFACE ) <nl> add_library ( fmt : : fmt - header - only ALIAS fmt - header - only ) <nl> if ( FMT_TEST ) <nl> add_subdirectory ( test ) <nl> endif ( ) <nl> <nl> + # control fuzzing independent of the unit tests <nl> + if ( FMT_FUZZ ) <nl> + add_subdirectory ( test / fuzzing ) <nl> + endif ( ) <nl> + <nl> set ( gitignore $ { PROJECT_SOURCE_DIR } / . gitignore ) <nl> if ( MASTER_PROJECT AND EXISTS $ { gitignore } ) <nl> # Get the list of ignored files from . gitignore . <nl> mmm a / include / fmt / chrono . h <nl> ppp b / include / fmt / chrono . h <nl> <nl> # include < locale > <nl> # include < sstream > <nl> <nl> + / / enable safe chrono durations , unless explicitly disabled <nl> + # ifndef FMT_SAFE_DURATION_CAST <nl> + # define FMT_SAFE_DURATION_CAST 1 <nl> + # endif <nl> + <nl> + # if FMT_SAFE_DURATION_CAST <nl> + # include " safe - duration - cast . h " <nl> + # endif <nl> + <nl> FMT_BEGIN_NAMESPACE <nl> <nl> / / Prevents expansion of a preceding token as a function - style macro . <nl> inline bool isnan ( T value ) { <nl> return std : : isnan ( value ) ; <nl> } <nl> <nl> + template < typename T , FMT_ENABLE_IF ( std : : is_integral < T > : : value ) > <nl> + inline bool isfinite ( T ) { <nl> + return true ; <nl> + } <nl> + template < typename T , FMT_ENABLE_IF ( std : : is_floating_point < T > : : value ) > <nl> + inline bool isfinite ( T value ) { <nl> + return std : : isfinite ( value ) ; <nl> + } <nl> + <nl> / / Convers value to int and checks that it ' s in the range [ 0 , upper ) . <nl> template < typename T , FMT_ENABLE_IF ( std : : is_integral < T > : : value ) > <nl> inline int to_nonnegative_int ( T value , int upper ) { <nl> template < typename T > struct make_unsigned_or_unchanged < T , true > { <nl> using type = typename std : : make_unsigned < T > : : type ; <nl> } ; <nl> <nl> + # if FMT_SAFE_DURATION_CAST <nl> + / / throwing version of safe_duration_cast <nl> + template < typename To , typename FromRep , typename FromPeriod > <nl> + To fmt_safe_duration_cast ( std : : chrono : : duration < FromRep , FromPeriod > from ) { <nl> + int ec ; <nl> + To to = safe_duration_cast : : safe_duration_cast < To > ( from , ec ) ; <nl> + if ( ec ) { <nl> + FMT_THROW ( format_error ( " cannot format duration " ) ) ; <nl> + } <nl> + return to ; <nl> + } <nl> + # endif <nl> + <nl> template < typename Rep , typename Period , <nl> FMT_ENABLE_IF ( std : : is_integral < Rep > : : value ) > <nl> inline std : : chrono : : duration < Rep , std : : milli > get_milliseconds ( <nl> std : : chrono : : duration < Rep , Period > d ) { <nl> + / / this may overflow and / or the result may not fit in the <nl> + / / target type . <nl> + # if FMT_SAFE_DURATION_CAST <nl> + using CommonSecondsType = <nl> + typename std : : common_type < decltype ( d ) , std : : chrono : : seconds > : : type ; <nl> + const auto d_as_common = fmt_safe_duration_cast < CommonSecondsType > ( d ) ; <nl> + const auto d_as_whole_seconds = <nl> + fmt_safe_duration_cast < std : : chrono : : seconds > ( d_as_common ) ; <nl> + / / this conversion should be nonproblematic <nl> + const auto diff = d_as_common - d_as_whole_seconds ; <nl> + const auto ms = <nl> + fmt_safe_duration_cast < std : : chrono : : duration < Rep , std : : milli > > ( diff ) ; <nl> + return ms ; <nl> + # else <nl> auto s = std : : chrono : : duration_cast < std : : chrono : : seconds > ( d ) ; <nl> return std : : chrono : : duration_cast < std : : chrono : : milliseconds > ( d - s ) ; <nl> + # endif <nl> } <nl> <nl> template < typename Rep , typename Period , <nl> struct chrono_formatter { <nl> val = - val ; <nl> negative = true ; <nl> } <nl> + <nl> + / / this may overflow and / or the result may not fit in the <nl> + / / target type . <nl> + # if FMT_SAFE_DURATION_CAST <nl> + / / might need checked conversion ( rep ! = Rep ) <nl> + auto tmpval = std : : chrono : : duration < rep , Period > ( val ) ; <nl> + s = fmt_safe_duration_cast < seconds > ( tmpval ) ; <nl> + # else <nl> s = std : : chrono : : duration_cast < seconds > ( <nl> std : : chrono : : duration < rep , Period > ( val ) ) ; <nl> + # endif <nl> + } <nl> + <nl> + / / returns true if nan or inf , writes to out . <nl> + bool handle_nan_inf ( ) { <nl> + if ( isfinite ( val ) ) { <nl> + return false ; <nl> + } <nl> + if ( isnan ( val ) ) { <nl> + write_nan ( ) ; <nl> + return true ; <nl> + } <nl> + / / must be + - inf <nl> + if ( val > 0 ) { <nl> + write_pinf ( ) ; <nl> + } else { <nl> + write_ninf ( ) ; <nl> + } <nl> + return true ; <nl> } <nl> <nl> Rep hour ( ) const { return static_cast < Rep > ( mod ( ( s . count ( ) / 3600 ) , 24 ) ) ; } <nl> struct chrono_formatter { <nl> } <nl> <nl> void write_nan ( ) { std : : copy_n ( " nan " , 3 , out ) ; } <nl> + void write_pinf ( ) { std : : copy_n ( " inf " , 3 , out ) ; } <nl> + void write_ninf ( ) { std : : copy_n ( " - inf " , 4 , out ) ; } <nl> <nl> void format_localized ( const tm & time , const char * format ) { <nl> if ( isnan ( val ) ) return write_nan ( ) ; <nl> struct chrono_formatter { <nl> void on_tz_name ( ) { } <nl> <nl> void on_24_hour ( numeric_system ns ) { <nl> + if ( handle_nan_inf ( ) ) { <nl> + return ; <nl> + } <nl> + <nl> if ( ns = = numeric_system : : standard ) return write ( hour ( ) , 2 ) ; <nl> auto time = tm ( ) ; <nl> time . tm_hour = to_nonnegative_int ( hour ( ) , 24 ) ; <nl> struct chrono_formatter { <nl> } <nl> <nl> void on_12_hour ( numeric_system ns ) { <nl> + if ( handle_nan_inf ( ) ) { <nl> + return ; <nl> + } <nl> + <nl> if ( ns = = numeric_system : : standard ) return write ( hour12 ( ) , 2 ) ; <nl> auto time = tm ( ) ; <nl> time . tm_hour = to_nonnegative_int ( hour12 ( ) , 12 ) ; <nl> struct chrono_formatter { <nl> } <nl> <nl> void on_minute ( numeric_system ns ) { <nl> + if ( handle_nan_inf ( ) ) { <nl> + return ; <nl> + } <nl> + <nl> if ( ns = = numeric_system : : standard ) return write ( minute ( ) , 2 ) ; <nl> auto time = tm ( ) ; <nl> time . tm_min = to_nonnegative_int ( minute ( ) , 60 ) ; <nl> struct chrono_formatter { <nl> } <nl> <nl> void on_second ( numeric_system ns ) { <nl> + if ( handle_nan_inf ( ) ) { <nl> + return ; <nl> + } <nl> + <nl> if ( ns = = numeric_system : : standard ) { <nl> write ( second ( ) , 2 ) ; <nl> - auto ms = get_milliseconds ( std : : chrono : : duration < Rep , Period > ( val ) ) ; <nl> + # if FMT_SAFE_DURATION_CAST <nl> + / / convert rep - > Rep <nl> + using duration_rep = std : : chrono : : duration < rep , Period > ; <nl> + using duration_Rep = std : : chrono : : duration < Rep , Period > ; <nl> + auto tmpval = fmt_safe_duration_cast < duration_Rep > ( duration_rep { val } ) ; <nl> + # else <nl> + auto tmpval = std : : chrono : : duration < Rep , Period > ( val ) ; <nl> + # endif <nl> + auto ms = get_milliseconds ( tmpval ) ; <nl> if ( ms ! = std : : chrono : : milliseconds ( 0 ) ) { <nl> * out + + = ' . ' ; <nl> write ( ms . count ( ) , 3 ) ; <nl> struct chrono_formatter { <nl> format_localized ( time , " % OS " ) ; <nl> } <nl> <nl> - void on_12_hour_time ( ) { format_localized ( time ( ) , " % r " ) ; } <nl> + void on_12_hour_time ( ) { <nl> + if ( handle_nan_inf ( ) ) { <nl> + return ; <nl> + } <nl> + <nl> + format_localized ( time ( ) , " % r " ) ; <nl> + } <nl> <nl> void on_24_hour_time ( ) { <nl> + if ( handle_nan_inf ( ) ) { <nl> + * out + + = ' : ' ; <nl> + handle_nan_inf ( ) ; <nl> + return ; <nl> + } <nl> + <nl> write ( hour ( ) , 2 ) ; <nl> * out + + = ' : ' ; <nl> write ( minute ( ) , 2 ) ; <nl> struct chrono_formatter { <nl> void on_iso_time ( ) { <nl> on_24_hour_time ( ) ; <nl> * out + + = ' : ' ; <nl> + if ( handle_nan_inf ( ) ) { <nl> + return ; <nl> + } <nl> write ( second ( ) , 2 ) ; <nl> } <nl> <nl> - void on_am_pm ( ) { format_localized ( time ( ) , " % p " ) ; } <nl> + void on_am_pm ( ) { <nl> + if ( handle_nan_inf ( ) ) { <nl> + return ; <nl> + } <nl> + <nl> + format_localized ( time ( ) , " % p " ) ; <nl> + } <nl> <nl> void on_duration_value ( ) { <nl> + if ( handle_nan_inf ( ) ) { <nl> + return ; <nl> + } <nl> write_sign ( ) ; <nl> out = format_chrono_duration_value ( out , val , precision ) ; <nl> } <nl> mmm a / include / fmt / format - inl . h <nl> ppp b / include / fmt / format - inl . h <nl> template < > FMT_FUNC int count_digits < 4 > ( internal : : fallback_uintptr n ) { <nl> template < typename T > <nl> int format_float ( char * buf , std : : size_t size , const char * format , int precision , <nl> T value ) { <nl> + # ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION <nl> + if ( precision > 100000 ) { <nl> + throw std : : runtime_error ( " fuzz mode - avoid large allocation inside snprintf " ) ; <nl> + } <nl> + # endif <nl> / / Suppress the warning about nonliteral format string . <nl> auto snprintf_ptr = FMT_SNPRINTF ; <nl> return precision < 0 ? snprintf_ptr ( buf , size , format , value ) <nl> mmm a / include / fmt / format . h <nl> ppp b / include / fmt / format . h <nl> class basic_memory_buffer : private Allocator , public internal : : buffer < T > { <nl> <nl> template < typename T , std : : size_t SIZE , typename Allocator > <nl> void basic_memory_buffer < T , SIZE , Allocator > : : grow ( std : : size_t size ) { <nl> + # ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION <nl> + if ( size > 1000 ) { <nl> + throw std : : runtime_error ( " fuzz mode - won ' t grow that much " ) ; <nl> + } <nl> + # endif <nl> std : : size_t old_capacity = this - > capacity ( ) ; <nl> std : : size_t new_capacity = old_capacity + old_capacity / 2 ; <nl> if ( size > new_capacity ) new_capacity = size ; <nl> It grisu_prettify ( const char * digits , int size , int exp , It it , <nl> int num_zeros = ( std : : max ) ( params . num_digits - full_exp , 1 ) ; <nl> if ( params . trailing_zeros ) { <nl> * it + + = static_cast < Char > ( ' . ' ) ; <nl> + # ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION <nl> + if ( num_zeros > 1000 ) { <nl> + throw std : : runtime_error ( " fuzz mode - avoiding excessive cpu use " ) ; <nl> + } <nl> + # endif <nl> it = std : : fill_n ( it , num_zeros , static_cast < Char > ( ' 0 ' ) ) ; <nl> } <nl> } else if ( full_exp > 0 ) { <nl> new file mode 100644 <nl> index 000000000 . . e69450f4e <nl> mmm / dev / null <nl> ppp b / include / fmt / safe - duration - cast . h <nl> <nl> + / * <nl> + * For conversion between std : : chrono : : durations without undefined <nl> + * behaviour or erroneous results . <nl> + * This is a stripped down version of duration_cast , for inclusion in fmt . <nl> + * See https : / / github . com / pauldreik / safe_duration_cast <nl> + * <nl> + * Copyright Paul Dreik 2019 <nl> + * <nl> + * This file is licensed under the fmt license , see format . h <nl> + * / <nl> + <nl> + # include < chrono > <nl> + # include < cmath > <nl> + # include < limits > <nl> + # include < type_traits > <nl> + <nl> + # include " format . h " <nl> + <nl> + FMT_BEGIN_NAMESPACE <nl> + <nl> + namespace safe_duration_cast { <nl> + <nl> + / * * <nl> + * converts From to To , without loss . If the dynamic value of from <nl> + * can ' t be converted to To without loss , ec is set . <nl> + * / <nl> + template < typename To , typename From , <nl> + FMT_ENABLE_IF ( ! std : : is_same < From , To > : : value ) > <nl> + FMT_CONSTEXPR To lossless_integral_conversion ( const From from , int & ec ) { <nl> + ec = 0 ; <nl> + using F = std : : numeric_limits < From > ; <nl> + using T = std : : numeric_limits < To > ; <nl> + static_assert ( F : : is_integer , " From must be integral " ) ; <nl> + static_assert ( T : : is_integer , " To must be integral " ) ; <nl> + <nl> + if ( F : : is_signed = = T : : is_signed ) { <nl> + / / A and B are both signed , or both unsigned . <nl> + if ( F : : digits < = T : : digits ) { <nl> + / / From fits in To without any problem <nl> + } else { <nl> + / / From does not always fit in To , resort to a dynamic check . <nl> + if ( from < T : : min ( ) | | from > T : : max ( ) ) { <nl> + / / outside range . <nl> + ec = 1 ; <nl> + return { } ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + if ( F : : is_signed & & ! T : : is_signed ) { <nl> + / / From may be negative , not allowed ! <nl> + if ( from < 0 ) { <nl> + ec = 1 ; <nl> + return { } ; <nl> + } <nl> + <nl> + / / From is positive . Can it always fit in To ? <nl> + if ( F : : digits < = T : : digits ) { <nl> + / / yes , From always fits in To . <nl> + } else { <nl> + / / from may not fit in To , we have to do a dynamic check <nl> + if ( from > T : : max ( ) ) { <nl> + ec = 1 ; <nl> + return { } ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + if ( ! F : : is_signed & & T : : is_signed ) { <nl> + / / can from be held in To ? <nl> + if ( F : : digits < T : : digits ) { <nl> + / / yes , From always fits in To . <nl> + } else { <nl> + / / from may not fit in To , we have to do a dynamic check <nl> + if ( from > T : : max ( ) ) { <nl> + / / outside range . <nl> + ec = 1 ; <nl> + return { } ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + / / reaching here means all is ok for lossless conversion . <nl> + return static_cast < To > ( from ) ; <nl> + <nl> + } / / function <nl> + <nl> + template < typename To , typename From , <nl> + FMT_ENABLE_IF ( std : : is_same < From , To > : : value ) > <nl> + FMT_CONSTEXPR To lossless_integral_conversion ( const From from , int & ec ) { <nl> + ec = 0 ; <nl> + return from ; <nl> + } / / function <nl> + <nl> + / / clang - format off <nl> + / * * <nl> + * converts From to To if possible , otherwise ec is set . <nl> + * <nl> + * input | output <nl> + * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm | mmmmmmmmmmmmmmm <nl> + * NaN | NaN <nl> + * Inf | Inf <nl> + * normal , fits in output | converted ( possibly lossy ) <nl> + * normal , does not fit in output | ec is set <nl> + * subnormal | best effort <nl> + * - Inf | - Inf <nl> + * / <nl> + / / clang - format on <nl> + template < typename To , typename From , <nl> + FMT_ENABLE_IF ( ! std : : is_same < From , To > : : value ) > <nl> + FMT_CONSTEXPR To safe_float_conversion ( const From from , int & ec ) { <nl> + ec = 0 ; <nl> + using T = std : : numeric_limits < To > ; <nl> + static_assert ( std : : is_floating_point < From > : : value , " From must be floating " ) ; <nl> + static_assert ( std : : is_floating_point < To > : : value , " To must be floating " ) ; <nl> + <nl> + / / catch the only happy case <nl> + if ( std : : isfinite ( from ) ) { <nl> + if ( from > = T : : lowest ( ) & & from < = T : : max ( ) ) { <nl> + return static_cast < To > ( from ) ; <nl> + } <nl> + / / not within range . <nl> + ec = 1 ; <nl> + return { } ; <nl> + } <nl> + <nl> + / / nan and inf will be preserved <nl> + return static_cast < To > ( from ) ; <nl> + } / / function <nl> + <nl> + template < typename To , typename From , <nl> + FMT_ENABLE_IF ( std : : is_same < From , To > : : value ) > <nl> + FMT_CONSTEXPR To safe_float_conversion ( const From from , int & ec ) { <nl> + ec = 0 ; <nl> + static_assert ( std : : is_floating_point < From > : : value , " From must be floating " ) ; <nl> + return from ; <nl> + } <nl> + <nl> + / * * <nl> + * safe duration cast between integral durations <nl> + * / <nl> + template < typename To , typename FromRep , typename FromPeriod , <nl> + FMT_ENABLE_IF ( std : : is_integral < FromRep > : : value ) , <nl> + FMT_ENABLE_IF ( std : : is_integral < typename To : : rep > : : value ) > <nl> + To safe_duration_cast ( std : : chrono : : duration < FromRep , FromPeriod > from , <nl> + int & ec ) { <nl> + using From = std : : chrono : : duration < FromRep , FromPeriod > ; <nl> + ec = 0 ; <nl> + / / the basic idea is that we need to convert from count ( ) in the from type <nl> + / / to count ( ) in the To type , by multiplying it with this : <nl> + using Factor = std : : ratio_divide < typename From : : period , typename To : : period > ; <nl> + <nl> + static_assert ( Factor : : num > 0 , " num must be positive " ) ; <nl> + static_assert ( Factor : : den > 0 , " den must be positive " ) ; <nl> + <nl> + / / the conversion is like this : multiply from . count ( ) with Factor : : num <nl> + / / / Factor : : den and convert it to To : : rep , all this without <nl> + / / overflow / underflow . let ' s start by finding a suitable type that can hold <nl> + / / both To , From and Factor : : num <nl> + using IntermediateRep = <nl> + typename std : : common_type < typename From : : rep , typename To : : rep , <nl> + decltype ( Factor : : num ) > : : type ; <nl> + <nl> + / / safe conversion to IntermediateRep <nl> + IntermediateRep count = <nl> + lossless_integral_conversion < IntermediateRep > ( from . count ( ) , ec ) ; <nl> + if ( ec ) { <nl> + return { } ; <nl> + } <nl> + / / multiply with Factor : : num without overflow or underflow <nl> + if ( Factor : : num ! = 1 ) { <nl> + constexpr auto max1 = <nl> + std : : numeric_limits < IntermediateRep > : : max ( ) / Factor : : num ; <nl> + if ( count > max1 ) { <nl> + ec = 1 ; <nl> + return { } ; <nl> + } <nl> + constexpr auto min1 = <nl> + std : : numeric_limits < IntermediateRep > : : min ( ) / Factor : : num ; <nl> + if ( count < min1 ) { <nl> + ec = 1 ; <nl> + return { } ; <nl> + } <nl> + count * = Factor : : num ; <nl> + } <nl> + <nl> + / / this can ' t go wrong , right ? den > 0 is checked earlier . <nl> + if ( Factor : : den ! = 1 ) { <nl> + count / = Factor : : den ; <nl> + } <nl> + / / convert to the to type , safely <nl> + using ToRep = typename To : : rep ; <nl> + const ToRep tocount = lossless_integral_conversion < ToRep > ( count , ec ) ; <nl> + if ( ec ) { <nl> + return { } ; <nl> + } <nl> + return To { tocount } ; <nl> + } <nl> + <nl> + / * * <nl> + * safe duration_cast between floating point durations <nl> + * / <nl> + template < typename To , typename FromRep , typename FromPeriod , <nl> + FMT_ENABLE_IF ( std : : is_floating_point < FromRep > : : value ) , <nl> + FMT_ENABLE_IF ( std : : is_floating_point < typename To : : rep > : : value ) > <nl> + To safe_duration_cast ( std : : chrono : : duration < FromRep , FromPeriod > from , <nl> + int & ec ) { <nl> + using From = std : : chrono : : duration < FromRep , FromPeriod > ; <nl> + ec = 0 ; <nl> + if ( std : : isnan ( from . count ( ) ) ) { <nl> + / / nan in , gives nan out . easy . <nl> + return To { std : : numeric_limits < typename To : : rep > : : quiet_NaN ( ) } ; <nl> + } <nl> + / / maybe we should also check if from is denormal , and decide what to do about <nl> + / / it . <nl> + <nl> + / / + - inf should be preserved . <nl> + if ( std : : isinf ( from . count ( ) ) ) { <nl> + return To { from . count ( ) } ; <nl> + } <nl> + <nl> + / / the basic idea is that we need to convert from count ( ) in the from type <nl> + / / to count ( ) in the To type , by multiplying it with this : <nl> + using Factor = std : : ratio_divide < typename From : : period , typename To : : period > ; <nl> + <nl> + static_assert ( Factor : : num > 0 , " num must be positive " ) ; <nl> + static_assert ( Factor : : den > 0 , " den must be positive " ) ; <nl> + <nl> + / / the conversion is like this : multiply from . count ( ) with Factor : : num <nl> + / / / Factor : : den and convert it to To : : rep , all this without <nl> + / / overflow / underflow . let ' s start by finding a suitable type that can hold <nl> + / / both To , From and Factor : : num <nl> + using IntermediateRep = <nl> + typename std : : common_type < typename From : : rep , typename To : : rep , <nl> + decltype ( Factor : : num ) > : : type ; <nl> + <nl> + / / force conversion of From : : rep - > IntermediateRep to be safe , <nl> + / / even if it will never happen be narrowing in this context . <nl> + IntermediateRep count = <nl> + safe_float_conversion < IntermediateRep > ( from . count ( ) , ec ) ; <nl> + if ( ec ) { <nl> + return { } ; <nl> + } <nl> + <nl> + / / multiply with Factor : : num without overflow or underflow <nl> + if ( Factor : : num ! = 1 ) { <nl> + constexpr auto max1 = <nl> + std : : numeric_limits < IntermediateRep > : : max ( ) / Factor : : num ; <nl> + if ( count > max1 ) { <nl> + ec = 1 ; <nl> + return { } ; <nl> + } <nl> + constexpr auto min1 = <nl> + std : : numeric_limits < IntermediateRep > : : lowest ( ) / Factor : : num ; <nl> + if ( count < min1 ) { <nl> + ec = 1 ; <nl> + return { } ; <nl> + } <nl> + count * = Factor : : num ; <nl> + } <nl> + <nl> + / / this can ' t go wrong , right ? den > 0 is checked earlier . <nl> + if ( Factor : : den ! = 1 ) { <nl> + count / = Factor : : den ; <nl> + } <nl> + <nl> + / / convert to the to type , safely <nl> + using ToRep = typename To : : rep ; <nl> + <nl> + const ToRep tocount = safe_float_conversion < ToRep > ( count , ec ) ; <nl> + if ( ec ) { <nl> + return { } ; <nl> + } <nl> + return To { tocount } ; <nl> + } <nl> + <nl> + } / / namespace safe_duration_cast <nl> + <nl> + FMT_END_NAMESPACE <nl> mmm a / support / travis - build . py <nl> ppp b / support / travis - build . py <nl> def install_dependencies ( ) : <nl> build_dir = os . path . join ( fmt_dir , " _build " ) <nl> test_build_dir = os . path . join ( fmt_dir , " _build_test " ) <nl> <nl> - # Configure library . <nl> + # Configure the library . <nl> makedirs_if_not_exist ( build_dir ) <nl> cmake_flags = [ <nl> ' - DCMAKE_INSTALL_PREFIX = ' + install_dir , ' - DCMAKE_BUILD_TYPE = ' + build , <nl> ' - DCMAKE_CXX_STANDARD = ' + standard <nl> ] <nl> + <nl> + # make sure the fuzzers still compile <nl> + if ' ENABLE_FUZZING ' in os . environ : <nl> + cmake_flags + = [ ' - DFMT_FUZZ = ON ' , ' - DFMT_FUZZ_LINKMAIN = On ' ] <nl> + <nl> check_call ( [ ' cmake ' , ' - DFMT_DOC = OFF ' , ' - DFMT_PEDANTIC = ON ' , ' - DFMT_WERROR = ON ' , fmt_dir ] + <nl> cmake_flags , cwd = build_dir ) <nl> <nl> - # Build library . <nl> - check_call ( [ ' make ' , ' - j4 ' ] , cwd = build_dir ) <nl> + # Build the library . <nl> + check_call ( [ ' cmake ' , ' - - build ' , ' . ' ] , cwd = build_dir ) <nl> <nl> - # Test library . <nl> + # Test the library . <nl> env = os . environ . copy ( ) <nl> env [ ' CTEST_OUTPUT_ON_FAILURE ' ] = ' 1 ' <nl> if call ( [ ' make ' , ' test ' ] , env = env , cwd = build_dir ) : <nl> def install_dependencies ( ) : <nl> print ( f . read ( ) ) <nl> sys . exit ( - 1 ) <nl> <nl> - # Install library . <nl> + # Install the library . <nl> check_call ( [ ' make ' , ' install ' ] , cwd = build_dir ) <nl> <nl> # Test installation . <nl> mmm a / test / chrono - test . cc <nl> ppp b / test / chrono - test . cc <nl> TEST ( ChronoTest , SpecialDurations ) { <nl> fmt : : format ( " { : % S } " , std : : chrono : : duration < double > ( 1e20 ) ) . substr ( 0 , 3 ) ) ; <nl> auto nan = std : : numeric_limits < double > : : quiet_NaN ( ) ; <nl> EXPECT_EQ ( <nl> - " nan nan nan nan . nan nan : nan nan " , <nl> + " nan nan nan nan nan : nan nan " , <nl> fmt : : format ( " { : % I % H % M % S % R % r } " , std : : chrono : : duration < double > ( nan ) ) ) ; <nl> fmt : : format ( " { : % S } " , <nl> std : : chrono : : duration < float , std : : atto > ( 1 . 79400457e + 31f ) ) ; <nl> new file mode 100644 <nl> index 000000000 . . ea4104026 <nl> mmm / dev / null <nl> ppp b / test / fuzzing / . gitignore <nl> <nl> + # ignore artifacts from the build . sh script <nl> + build - * / <nl> + <nl> new file mode 100644 <nl> index 000000000 . . 3f3868282 <nl> mmm / dev / null <nl> ppp b / test / fuzzing / CMakeLists . txt <nl> <nl> + # Copyright ( c ) 2019 , Paul Dreik <nl> + # License : see LICENSE . rst in the fmt root directory <nl> + <nl> + # settings this links in a main . useful for reproducing , <nl> + # kcov , gdb , afl , valgrind . <nl> + # ( note that libFuzzer can also reproduce , just pass it the files ) <nl> + option ( FMT_FUZZ_LINKMAIN " enables the reproduce mode , instead of libFuzzer " On ) <nl> + <nl> + # for oss - fuzz - insert $ LIB_FUZZING_ENGINE into the link flags , but only for <nl> + # the fuzz targets , otherwise the cmake configuration step fails . <nl> + set ( FMT_FUZZ_LDFLAGS " " CACHE STRING " LDFLAGS for the fuzz targets " ) <nl> + <nl> + # find all fuzzers . <nl> + set ( SOURCES <nl> + chrono_duration . cpp <nl> + named_arg . cpp <nl> + one_arg . cpp <nl> + sprintf . cpp <nl> + two_args . cpp <nl> + ) <nl> + <nl> + macro ( implement_fuzzer sourcefile ) <nl> + get_filename_component ( basename $ { sourcefile } NAME_WE ) <nl> + set ( name fuzzer_ $ { basename } ) <nl> + add_executable ( $ { name } $ { sourcefile } fuzzer_common . h ) <nl> + if ( FMT_FUZZ_LINKMAIN ) <nl> + target_sources ( $ { name } PRIVATE main . cpp ) <nl> + endif ( ) <nl> + target_link_libraries ( $ { name } PRIVATE fmt ) <nl> + if ( FMT_FUZZ_LDFLAGS ) <nl> + target_link_libraries ( $ { name } PRIVATE $ { FMT_FUZZ_LDFLAGS } ) <nl> + endif ( ) <nl> + target_compile_features ( $ { name } PRIVATE cxx_generic_lambdas ) <nl> + endmacro ( ) <nl> + <nl> + foreach ( X IN ITEMS $ { SOURCES } ) <nl> + implement_fuzzer ( $ { X } ) <nl> + endforeach ( ) <nl> new file mode 100644 <nl> index 000000000 . . d3ea270ba <nl> mmm / dev / null <nl> ppp b / test / fuzzing / README . md <nl> <nl> + # FMT Fuzzer <nl> + Fuzzing has revealed [ several bugs ] ( https : / / github . com / fmtlib / fmt / issues ? & q = is % 3Aissue + fuzz ) in fmt . It is a part of the continous fuzzing at [ oss - fuzz ] ( https : / / github . com / google / oss - fuzz ) <nl> + <nl> + The source code is modified to make the fuzzing possible without locking up on resource exhaustion : <nl> + ` ` ` cpp <nl> + # ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION <nl> + if ( spec . precision > 100000 ) { <nl> + throw std : : runtime_error ( " fuzz mode - avoiding large precision " ) ; <nl> + } <nl> + # endif <nl> + ` ` ` <nl> + This macro is the defacto standard for making fuzzing practically possible , see [ the libFuzzer documentation ] ( https : / / llvm . org / docs / LibFuzzer . html # fuzzer - friendly - build - mode ) . <nl> + <nl> + # # Running the fuzzers locally <nl> + There is a [ helper script ] ( build . sh ) to build the fuzzers , which has only been tested on Debian and Ubuntu linux so far . There should be no problems fuzzing on Windows ( using clang > = 8 ) or on Mac , but the script will probably not work out of the box . <nl> + <nl> + Something along <nl> + ` ` ` sh <nl> + mkdir build <nl> + cd build <nl> + export CXX = clang + + <nl> + export CXXFLAGS = " - fsanitize = fuzzer - no - link - DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION = - g " <nl> + cmake . . - DFMT_SAFE_DURATION_CAST = On - DFMT_FUZZ = On - DFMT_FUZZ_LINKMAIN = Off - DFMT_FUZZ_LDFLAGS = " - fsanitize = fuzzer " <nl> + cmake - - build . <nl> + ` ` ` <nl> + should work to build the fuzzers for all platforms which clang supports . <nl> + <nl> + Execute a fuzzer with for instance <nl> + ` ` ` sh <nl> + cd build <nl> + export UBSAN_OPTIONS = halt_on_error = 1 <nl> + mkdir out_chrono <nl> + bin / fuzzer_chrono_duration out_chrono <nl> + ` ` ` <nl> new file mode 100755 <nl> index 000000000 . . 141a50d95 <nl> mmm / dev / null <nl> ppp b / test / fuzzing / build . sh <nl> <nl> + # ! / bin / sh <nl> + # <nl> + # Creates fuzzer builds of various kinds <nl> + # - reproduce mode ( no fuzzing , just enables replaying data through the fuzzers ) <nl> + # - oss - fuzz emulated mode ( makes sure a simulated invocation by oss - fuzz works ) <nl> + # - libFuzzer build ( you will need clang ) <nl> + # - afl build ( you will need afl ) <nl> + # <nl> + # <nl> + # Copyright ( c ) 2019 Paul Dreik <nl> + # <nl> + # License : see LICENSE . rst in the fmt root directory <nl> + <nl> + set - e <nl> + me = $ ( basename $ 0 ) <nl> + root = $ ( readlink - f " $ ( dirname " $ 0 " ) / . . / . . " ) <nl> + <nl> + <nl> + echo $ me : root = $ root <nl> + <nl> + here = $ ( pwd ) <nl> + <nl> + CXXFLAGSALL = " - DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION = - g " <nl> + CMAKEFLAGSALL = " $ root - GNinja - DCMAKE_BUILD_TYPE = Debug - DFMT_DOC = Off - DFMT_TEST = Off - DFMT_FUZZ = On - DCMAKE_CXX_STANDARD = 17 " <nl> + <nl> + # builds the fuzzers as one would do if using afl or just making <nl> + # binaries for reproducing . <nl> + builddir = $ here / build - fuzzers - reproduce <nl> + mkdir - p $ builddir <nl> + cd $ builddir <nl> + CXX = " ccache g + + " CXXFLAGS = " $ CXXFLAGSALL " cmake \ <nl> + $ CMAKEFLAGSALL <nl> + cmake - - build $ builddir <nl> + <nl> + # for performance analysis of the fuzzers <nl> + builddir = $ here / build - fuzzers - perfanalysis <nl> + mkdir - p $ builddir <nl> + cd $ builddir <nl> + CXX = " ccache g + + " CXXFLAGS = " $ CXXFLAGSALL - g " cmake \ <nl> + $ CMAKEFLAGSALL \ <nl> + - DFMT_FUZZ_LINKMAIN = On \ <nl> + - DCMAKE_BUILD_TYPE = Release <nl> + <nl> + cmake - - build $ builddir <nl> + <nl> + # builds the fuzzers as oss - fuzz does <nl> + builddir = $ here / build - fuzzers - ossfuzz <nl> + mkdir - p $ builddir <nl> + cd $ builddir <nl> + CXX = " clang + + " \ <nl> + CXXFLAGS = " $ CXXFLAGSALL - fsanitize = fuzzer - no - link " cmake \ <nl> + cmake $ CMAKEFLAGSALL \ <nl> + - DFMT_FUZZ_LINKMAIN = Off \ <nl> + - DFMT_FUZZ_LDFLAGS = " - fsanitize = fuzzer " <nl> + <nl> + cmake - - build $ builddir <nl> + <nl> + <nl> + # builds fuzzers for local fuzzing with libfuzzer with asan + usan <nl> + builddir = $ here / build - fuzzers - libfuzzer <nl> + mkdir - p $ builddir <nl> + cd $ builddir <nl> + CXX = " clang + + " \ <nl> + CXXFLAGS = " $ CXXFLAGSALL - fsanitize = fuzzer - no - link , address , undefined " cmake \ <nl> + cmake $ CMAKEFLAGSALL \ <nl> + - DFMT_FUZZ_LINKMAIN = Off \ <nl> + - DFMT_FUZZ_LDFLAGS = " - fsanitize = fuzzer " <nl> + <nl> + cmake - - build $ builddir <nl> + <nl> + # builds fuzzers for local fuzzing with libfuzzer with asan only <nl> + builddir = $ here / build - fuzzers - libfuzzer - addr <nl> + mkdir - p $ builddir <nl> + cd $ builddir <nl> + CXX = " clang + + " \ <nl> + CXXFLAGS = " $ CXXFLAGSALL - fsanitize = fuzzer - no - link , undefined " cmake \ <nl> + cmake $ CMAKEFLAGSALL \ <nl> + - DFMT_FUZZ_LINKMAIN = Off \ <nl> + - DFMT_FUZZ_LDFLAGS = " - fsanitize = fuzzer " <nl> + <nl> + cmake - - build $ builddir <nl> + <nl> + # builds a fast fuzzer for making coverage fast <nl> + builddir = $ here / build - fuzzers - fast <nl> + mkdir - p $ builddir <nl> + cd $ builddir <nl> + CXX = " clang + + " \ <nl> + CXXFLAGS = " $ CXXFLAGSALL - fsanitize = fuzzer - no - link - O3 " cmake \ <nl> + cmake $ CMAKEFLAGSALL \ <nl> + - DFMT_FUZZ_LINKMAIN = Off \ <nl> + - DFMT_FUZZ_LDFLAGS = " - fsanitize = fuzzer " \ <nl> + - DCMAKE_BUILD_TYPE = Release <nl> + <nl> + cmake - - build $ builddir <nl> + <nl> + <nl> + # builds fuzzers for local fuzzing with afl <nl> + builddir = $ here / build - fuzzers - afl <nl> + mkdir - p $ builddir <nl> + cd $ builddir <nl> + CXX = " afl - g + + " \ <nl> + CXXFLAGS = " $ CXXFLAGSALL - fsanitize = address , undefined " \ <nl> + cmake $ CMAKEFLAGSALL \ <nl> + - DFMT_FUZZ_LINKMAIN = On <nl> + <nl> + cmake - - build $ builddir <nl> + <nl> + <nl> + echo $ me : all good <nl> + <nl> new file mode 100644 <nl> index 000000000 . . d1de9ae62 <nl> mmm / dev / null <nl> ppp b / test / fuzzing / chrono_duration . cpp <nl> <nl> + / / Copyright ( c ) 2019 , Paul Dreik <nl> + / / License : see LICENSE . rst in the fmt root directory <nl> + <nl> + # include < fmt / chrono . h > <nl> + # include < cstdint > <nl> + # include < limits > <nl> + # include < stdexcept > <nl> + # include < type_traits > <nl> + # include < vector > <nl> + # include " fuzzer_common . h " <nl> + <nl> + template < typename Item , typename Ratio > <nl> + void invoke_inner ( fmt : : string_view formatstring , const Item item ) { <nl> + const std : : chrono : : duration < Item , Ratio > value ( item ) ; <nl> + try { <nl> + # if FMT_FUZZ_FORMAT_TO_STRING <nl> + std : : string message = fmt : : format ( formatstring , value ) ; <nl> + # else <nl> + fmt : : memory_buffer buf ; <nl> + fmt : : format_to ( buf , formatstring , value ) ; <nl> + # endif <nl> + } catch ( std : : exception & / * e * / ) { <nl> + } <nl> + } <nl> + <nl> + / / Item is the underlying type for duration ( int , long etc ) <nl> + template < typename Item > <nl> + void invoke_outer ( const uint8_t * Data , std : : size_t Size , const int scaling ) { <nl> + / / always use a fixed location of the data <nl> + using fmt_fuzzer : : Nfixed ; <nl> + <nl> + constexpr auto N = sizeof ( Item ) ; <nl> + static_assert ( N < = Nfixed , " fixed size is too small " ) ; <nl> + if ( Size < = Nfixed + 1 ) { <nl> + return ; <nl> + } <nl> + <nl> + const Item item = fmt_fuzzer : : assignFromBuf < Item > ( Data ) ; <nl> + <nl> + / / fast forward <nl> + Data + = Nfixed ; <nl> + Size - = Nfixed ; <nl> + <nl> + / / Data is already allocated separately in libFuzzer so reading past <nl> + / / the end will most likely be detected anyway <nl> + const auto formatstring = fmt : : string_view ( fmt_fuzzer : : as_chars ( Data ) , Size ) ; <nl> + <nl> + / / doit_impl < Item , std : : yocto > ( buf . data ( ) , item ) ; <nl> + / / doit_impl < Item , std : : zepto > ( buf . data ( ) , item ) ; <nl> + switch ( scaling ) { <nl> + case 1 : <nl> + invoke_inner < Item , std : : atto > ( formatstring , item ) ; <nl> + break ; <nl> + case 2 : <nl> + invoke_inner < Item , std : : femto > ( formatstring , item ) ; <nl> + break ; <nl> + case 3 : <nl> + invoke_inner < Item , std : : pico > ( formatstring , item ) ; <nl> + break ; <nl> + case 4 : <nl> + invoke_inner < Item , std : : nano > ( formatstring , item ) ; <nl> + break ; <nl> + case 5 : <nl> + invoke_inner < Item , std : : micro > ( formatstring , item ) ; <nl> + break ; <nl> + case 6 : <nl> + invoke_inner < Item , std : : milli > ( formatstring , item ) ; <nl> + break ; <nl> + case 7 : <nl> + invoke_inner < Item , std : : centi > ( formatstring , item ) ; <nl> + break ; <nl> + case 8 : <nl> + invoke_inner < Item , std : : deci > ( formatstring , item ) ; <nl> + break ; <nl> + case 9 : <nl> + invoke_inner < Item , std : : deca > ( formatstring , item ) ; <nl> + break ; <nl> + case 10 : <nl> + invoke_inner < Item , std : : kilo > ( formatstring , item ) ; <nl> + break ; <nl> + case 11 : <nl> + invoke_inner < Item , std : : mega > ( formatstring , item ) ; <nl> + break ; <nl> + case 12 : <nl> + invoke_inner < Item , std : : giga > ( formatstring , item ) ; <nl> + break ; <nl> + case 13 : <nl> + invoke_inner < Item , std : : tera > ( formatstring , item ) ; <nl> + break ; <nl> + case 14 : <nl> + invoke_inner < Item , std : : peta > ( formatstring , item ) ; <nl> + break ; <nl> + case 15 : <nl> + invoke_inner < Item , std : : exa > ( formatstring , item ) ; <nl> + } <nl> + / / doit_impl < Item , std : : zeta > ( buf . data ( ) , item ) ; <nl> + / / doit_impl < Item , std : : yotta > ( buf . data ( ) , item ) ; <nl> + } <nl> + <nl> + extern " C " int LLVMFuzzerTestOneInput ( const uint8_t * Data , std : : size_t Size ) { <nl> + if ( Size < = 4 ) { <nl> + return 0 ; <nl> + } <nl> + <nl> + const auto representation = Data [ 0 ] ; <nl> + const auto scaling = Data [ 1 ] ; <nl> + Data + = 2 ; <nl> + Size - = 2 ; <nl> + <nl> + switch ( representation ) { <nl> + case 1 : <nl> + invoke_outer < char > ( Data , Size , scaling ) ; <nl> + break ; <nl> + case 2 : <nl> + invoke_outer < unsigned char > ( Data , Size , scaling ) ; <nl> + break ; <nl> + case 3 : <nl> + invoke_outer < signed char > ( Data , Size , scaling ) ; <nl> + break ; <nl> + case 4 : <nl> + invoke_outer < short > ( Data , Size , scaling ) ; <nl> + break ; <nl> + case 5 : <nl> + invoke_outer < unsigned short > ( Data , Size , scaling ) ; <nl> + break ; <nl> + case 6 : <nl> + invoke_outer < int > ( Data , Size , scaling ) ; <nl> + break ; <nl> + case 7 : <nl> + invoke_outer < unsigned int > ( Data , Size , scaling ) ; <nl> + break ; <nl> + case 8 : <nl> + invoke_outer < long > ( Data , Size , scaling ) ; <nl> + break ; <nl> + case 9 : <nl> + invoke_outer < unsigned long > ( Data , Size , scaling ) ; <nl> + break ; <nl> + case 10 : <nl> + invoke_outer < float > ( Data , Size , scaling ) ; <nl> + break ; <nl> + case 11 : <nl> + invoke_outer < double > ( Data , Size , scaling ) ; <nl> + break ; <nl> + case 12 : <nl> + invoke_outer < long double > ( Data , Size , scaling ) ; <nl> + break ; <nl> + default : <nl> + break ; <nl> + } <nl> + <nl> + return 0 ; <nl> + } <nl> new file mode 100644 <nl> index 000000000 . . 02b3910cb <nl> mmm / dev / null <nl> ppp b / test / fuzzing / fuzzer_common . h <nl> <nl> + # ifndef FUZZER_COMMON_H <nl> + # define FUZZER_COMMON_H <nl> + <nl> + / / Copyright ( c ) 2019 , Paul Dreik <nl> + / / License : see LICENSE . rst in the fmt root directory <nl> + <nl> + # include < cstring > / / memcpy <nl> + # include < type_traits > / / trivially copyable <nl> + # include < cstdint > / / std : : uint8_t <nl> + <nl> + / / one can format to either a string , or a buf . buf is faster , <nl> + / / but one may be interested in formatting to a string instead to <nl> + / / verify it works as intended . to avoid a combinatoric explosion , <nl> + / / select this at compile time instead of dynamically from the fuzz data <nl> + # define FMT_FUZZ_FORMAT_TO_STRING 0 <nl> + <nl> + / / if fmt is given a buffer that is separately allocated , <nl> + / / chances that address sanitizer detects out of bound reads is <nl> + / / much higher . However , it slows down the fuzzing . <nl> + # define FMT_FUZZ_SEPARATE_ALLOCATION 1 <nl> + <nl> + / / To let the the fuzzer mutation be efficient at cross pollinating <nl> + / / between different types , use a fixed size format . <nl> + / / The same bit pattern , interpreted as another type , <nl> + / / is likely interesting . <nl> + / / For this , we must know the size of the largest possible type in use . <nl> + <nl> + / / There are some problems on travis , claiming Nfixed is not a constant expression <nl> + / / which seems to be an issue with older versions of libstdc + + <nl> + # if _GLIBCXX_RELEASE > = 7 <nl> + # include < algorithm > <nl> + namespace fmt_fuzzer { <nl> + constexpr auto Nfixed = std : : max ( sizeof ( long double ) , sizeof ( std : : intmax_t ) ) ; <nl> + } <nl> + # else <nl> + namespace fmt_fuzzer { <nl> + constexpr auto Nfixed = 16 ; <nl> + } <nl> + # endif <nl> + <nl> + namespace fmt_fuzzer { <nl> + / / view data as a c char pointer . <nl> + template < typename T > <nl> + inline const char * as_chars ( const T * data ) { <nl> + return static_cast < const char * > ( static_cast < const void * > ( data ) ) ; <nl> + } <nl> + <nl> + / / view data as a byte pointer <nl> + template < typename T > <nl> + inline const std : : uint8_t * as_bytes ( const T * data ) { <nl> + return static_cast < const std : : uint8_t * > ( static_cast < const void * > ( data ) ) ; <nl> + } <nl> + <nl> + / / blits bytes from Data to form an ( assumed trivially constructible ) object <nl> + / / of type Item <nl> + template < class Item > <nl> + inline Item assignFromBuf ( const std : : uint8_t * Data ) { <nl> + Item item { } ; <nl> + std : : memcpy ( & item , Data , sizeof ( Item ) ) ; <nl> + return item ; <nl> + } <nl> + <nl> + / / reads a boolean value by looking at the first byte from Data <nl> + template < > inline bool assignFromBuf < bool > ( const std : : uint8_t * Data ) { <nl> + return ! ! Data [ 0 ] ; <nl> + } <nl> + <nl> + } / / namespace fmt_fuzzer <nl> + <nl> + <nl> + # endif / / FUZZER_COMMON_H <nl> new file mode 100644 <nl> index 000000000 . . 52f81f4b7 <nl> mmm / dev / null <nl> ppp b / test / fuzzing / main . cpp <nl> <nl> + # include < cassert > <nl> + # include < fstream > <nl> + # include < sstream > <nl> + # include < vector > <nl> + # include " fuzzer_common . h " <nl> + <nl> + extern " C " int LLVMFuzzerTestOneInput ( const uint8_t * Data , std : : size_t Size ) ; <nl> + int main ( int argc , char * argv [ ] ) { <nl> + for ( int i = 1 ; i < argc ; + + i ) { <nl> + std : : ifstream in ( argv [ i ] ) ; <nl> + assert ( in ) ; <nl> + in . seekg ( 0 , std : : ios_base : : end ) ; <nl> + const auto pos = in . tellg ( ) ; <nl> + assert ( pos > = 0 ) ; <nl> + in . seekg ( 0 , std : : ios_base : : beg ) ; <nl> + std : : vector < char > buf ( static_cast < std : : size_t > ( pos ) ) ; <nl> + in . read ( buf . data ( ) , static_cast < long > ( buf . size ( ) ) ) ; <nl> + assert ( in . gcount ( ) = = pos ) ; <nl> + LLVMFuzzerTestOneInput ( fmt_fuzzer : : as_bytes ( buf . data ( ) ) , buf . size ( ) ) ; <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 000000000 . . af9890e27 <nl> mmm / dev / null <nl> ppp b / test / fuzzing / named_arg . cpp <nl> <nl> + / / Copyright ( c ) 2019 , Paul Dreik <nl> + / / License : see LICENSE . rst in the fmt root directory <nl> + <nl> + # include < fmt / chrono . h > <nl> + # include < fmt / core . h > <nl> + # include < cstdint > <nl> + # include < stdexcept > <nl> + # include < type_traits > <nl> + # include < vector > <nl> + # include " fuzzer_common . h " <nl> + <nl> + template < typename Item1 > <nl> + void invoke_fmt ( const uint8_t * Data , std : : size_t Size , unsigned int argsize ) { <nl> + constexpr auto N1 = sizeof ( Item1 ) ; <nl> + static_assert ( N1 < = fmt_fuzzer : : Nfixed , " Nfixed too small " ) ; <nl> + if ( Size < = fmt_fuzzer : : Nfixed ) { <nl> + return ; <nl> + } <nl> + const Item1 item1 = fmt_fuzzer : : assignFromBuf < Item1 > ( Data ) ; <nl> + <nl> + Data + = fmt_fuzzer : : Nfixed ; <nl> + Size - = fmt_fuzzer : : Nfixed ; <nl> + <nl> + / / how many chars should be used for the argument name ? <nl> + if ( argsize < = 0 | | argsize > = Size ) { <nl> + return ; <nl> + } <nl> + <nl> + / / allocating buffers separately is slower , but increases chances <nl> + / / of detecting memory errors <nl> + # if FMT_FUZZ_SEPARATE_ALLOCATION <nl> + std : : vector < char > argnamebuffer ( argsize ) ; <nl> + std : : memcpy ( argnamebuffer . data ( ) , Data , argsize ) ; <nl> + auto argname = fmt : : string_view ( argnamebuffer . data ( ) , argsize ) ; <nl> + # else <nl> + auto argname = fmt : : string_view ( fmt_fuzzer : : as_chars ( Data ) , argsize ) ; <nl> + # endif <nl> + Data + = argsize ; <nl> + Size - = argsize ; <nl> + <nl> + # if FMT_FUZZ_SEPARATE_ALLOCATION <nl> + / / allocates as tight as possible , making it easier to catch buffer overruns . <nl> + std : : vector < char > fmtstringbuffer ( Size ) ; <nl> + std : : memcpy ( fmtstringbuffer . data ( ) , Data , Size ) ; <nl> + auto fmtstring = fmt : : string_view ( fmtstringbuffer . data ( ) , Size ) ; <nl> + # else <nl> + auto fmtstring = fmt : : string_view ( fmt_fuzzer : : as_chars ( Data ) , Size ) ; <nl> + # endif <nl> + <nl> + # if FMT_FUZZ_FORMAT_TO_STRING <nl> + std : : string message = fmt : : format ( fmtstring , fmt : : arg ( argname , item1 ) ) ; <nl> + # else <nl> + fmt : : memory_buffer outbuf ; <nl> + fmt : : format_to ( outbuf , fmtstring , fmt : : arg ( argname , item1 ) ) ; <nl> + # endif <nl> + } <nl> + <nl> + / / for dynamic dispatching to an explicit instantiation <nl> + template < typename Callback > void invoke ( int index , Callback callback ) { <nl> + switch ( index ) { <nl> + case 0 : <nl> + callback ( bool { } ) ; <nl> + break ; <nl> + case 1 : <nl> + callback ( char { } ) ; <nl> + break ; <nl> + case 2 : <nl> + using sc = signed char ; <nl> + callback ( sc { } ) ; <nl> + break ; <nl> + case 3 : <nl> + using uc = unsigned char ; <nl> + callback ( uc { } ) ; <nl> + break ; <nl> + case 4 : <nl> + callback ( short { } ) ; <nl> + break ; <nl> + case 5 : <nl> + using us = unsigned short ; <nl> + callback ( us { } ) ; <nl> + break ; <nl> + case 6 : <nl> + callback ( int { } ) ; <nl> + break ; <nl> + case 7 : <nl> + callback ( unsigned { } ) ; <nl> + break ; <nl> + case 8 : <nl> + callback ( long { } ) ; <nl> + break ; <nl> + case 9 : <nl> + using ul = unsigned long ; <nl> + callback ( ul { } ) ; <nl> + break ; <nl> + case 10 : <nl> + callback ( float { } ) ; <nl> + break ; <nl> + case 11 : <nl> + callback ( double { } ) ; <nl> + break ; <nl> + case 12 : <nl> + using LD = long double ; <nl> + callback ( LD { } ) ; <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + extern " C " int LLVMFuzzerTestOneInput ( const uint8_t * Data , std : : size_t Size ) { <nl> + if ( Size < = 3 ) { <nl> + return 0 ; <nl> + } <nl> + <nl> + / / switch types depending on the first byte of the input <nl> + const auto first = Data [ 0 ] & 0x0F ; <nl> + const unsigned int second = ( Data [ 0 ] & 0xF0 ) > > 4 ; <nl> + Data + + ; <nl> + Size - - ; <nl> + <nl> + auto outerfcn = [ = ] ( auto param1 ) { <nl> + invoke_fmt < decltype ( param1 ) > ( Data , Size , second ) ; <nl> + } ; <nl> + <nl> + try { <nl> + invoke ( first , outerfcn ) ; <nl> + } catch ( std : : exception & / * e * / ) { <nl> + } <nl> + return 0 ; <nl> + } <nl> + <nl> new file mode 100644 <nl> index 000000000 . . 70b06b9b5 <nl> mmm / dev / null <nl> ppp b / test / fuzzing / one_arg . cpp <nl> <nl> + / / Copyright ( c ) 2019 , Paul Dreik <nl> + / / License : see LICENSE . rst in the fmt root directory <nl> + <nl> + # include < fmt / core . h > <nl> + # include < cstdint > <nl> + # include < stdexcept > <nl> + # include < type_traits > <nl> + # include < vector > <nl> + <nl> + # include < fmt / chrono . h > <nl> + # include " fuzzer_common . h " <nl> + <nl> + using fmt_fuzzer : : Nfixed ; <nl> + <nl> + template < typename Item > <nl> + void invoke_fmt ( const uint8_t * Data , std : : size_t Size ) { <nl> + constexpr auto N = sizeof ( Item ) ; <nl> + static_assert ( N < = Nfixed , " Nfixed is too small " ) ; <nl> + if ( Size < = Nfixed ) { <nl> + return ; <nl> + } <nl> + const Item item = fmt_fuzzer : : assignFromBuf < Item > ( Data ) ; <nl> + Data + = Nfixed ; <nl> + Size - = Nfixed ; <nl> + <nl> + # if FMT_FUZZ_SEPARATE_ALLOCATION <nl> + / / allocates as tight as possible , making it easier to catch buffer overruns . <nl> + std : : vector < char > fmtstringbuffer ( Size ) ; <nl> + std : : memcpy ( fmtstringbuffer . data ( ) , Data , Size ) ; <nl> + auto fmtstring = fmt : : string_view ( fmtstringbuffer . data ( ) , Size ) ; <nl> + # else <nl> + auto fmtstring = fmt : : string_view ( fmt_fuzzer : : as_chars ( Data ) , Size ) ; <nl> + # endif <nl> + <nl> + # if FMT_FUZZ_FORMAT_TO_STRING <nl> + std : : string message = fmt : : format ( fmtstring , item ) ; <nl> + # else <nl> + fmt : : memory_buffer message ; <nl> + fmt : : format_to ( message , fmtstring , item ) ; <nl> + # endif <nl> + } <nl> + <nl> + void invoke_fmt_time ( const uint8_t * Data , std : : size_t Size ) { <nl> + using Item = std : : time_t ; <nl> + constexpr auto N = sizeof ( Item ) ; <nl> + static_assert ( N < = Nfixed , " Nfixed too small " ) ; <nl> + if ( Size < = Nfixed ) { <nl> + return ; <nl> + } <nl> + const Item item = fmt_fuzzer : : assignFromBuf < Item > ( Data ) ; <nl> + Data + = Nfixed ; <nl> + Size - = Nfixed ; <nl> + # if FMT_FUZZ_SEPARATE_ALLOCATION <nl> + / / allocates as tight as possible , making it easier to catch buffer overruns . <nl> + std : : vector < char > fmtstringbuffer ( Size ) ; <nl> + std : : memcpy ( fmtstringbuffer . data ( ) , Data , Size ) ; <nl> + auto fmtstring = fmt : : string_view ( fmtstringbuffer . data ( ) , Size ) ; <nl> + # else <nl> + auto fmtstring = fmt : : string_view ( fmt_fuzzer : : as_chars ( Data ) , Size ) ; <nl> + # endif <nl> + auto * b = std : : localtime ( & item ) ; <nl> + if ( b ) { <nl> + # if FMT_FUZZ_FORMAT_TO_STRING <nl> + std : : string message = fmt : : format ( fmtstring , * b ) ; <nl> + # else <nl> + fmt : : memory_buffer message ; <nl> + fmt : : format_to ( message , fmtstring , * b ) ; <nl> + # endif <nl> + } <nl> + } <nl> + <nl> + extern " C " int LLVMFuzzerTestOneInput ( const uint8_t * Data , std : : size_t Size ) { <nl> + if ( Size < = 3 ) { <nl> + return 0 ; <nl> + } <nl> + <nl> + const auto first = Data [ 0 ] ; <nl> + Data + + ; <nl> + Size - - ; <nl> + <nl> + try { <nl> + switch ( first ) { <nl> + case 0 : <nl> + invoke_fmt < bool > ( Data , Size ) ; <nl> + break ; <nl> + case 1 : <nl> + invoke_fmt < char > ( Data , Size ) ; <nl> + break ; <nl> + case 2 : <nl> + invoke_fmt < unsigned char > ( Data , Size ) ; <nl> + break ; <nl> + case 3 : <nl> + invoke_fmt < signed char > ( Data , Size ) ; <nl> + break ; <nl> + case 4 : <nl> + invoke_fmt < short > ( Data , Size ) ; <nl> + break ; <nl> + case 5 : <nl> + invoke_fmt < unsigned short > ( Data , Size ) ; <nl> + break ; <nl> + case 6 : <nl> + invoke_fmt < int > ( Data , Size ) ; <nl> + break ; <nl> + case 7 : <nl> + invoke_fmt < unsigned int > ( Data , Size ) ; <nl> + break ; <nl> + case 8 : <nl> + invoke_fmt < long > ( Data , Size ) ; <nl> + break ; <nl> + case 9 : <nl> + invoke_fmt < unsigned long > ( Data , Size ) ; <nl> + break ; <nl> + case 10 : <nl> + invoke_fmt < float > ( Data , Size ) ; <nl> + break ; <nl> + case 11 : <nl> + invoke_fmt < double > ( Data , Size ) ; <nl> + break ; <nl> + case 12 : <nl> + invoke_fmt < long double > ( Data , Size ) ; <nl> + break ; <nl> + case 13 : <nl> + invoke_fmt_time ( Data , Size ) ; <nl> + break ; <nl> + default : <nl> + break ; <nl> + } <nl> + } catch ( std : : exception & / * e * / ) { <nl> + } <nl> + return 0 ; <nl> + } <nl> new file mode 100644 <nl> index 000000000 . . 7dd022213 <nl> mmm / dev / null <nl> ppp b / test / fuzzing / sprintf . cpp <nl> <nl> + / / Copyright ( c ) 2019 , Paul Dreik <nl> + / / License : see LICENSE . rst in the fmt root directory <nl> + # include < fmt / format . h > <nl> + # include < fmt / printf . h > <nl> + # include < cstdint > <nl> + # include < stdexcept > <nl> + <nl> + # include " fuzzer_common . h " <nl> + <nl> + using fmt_fuzzer : : Nfixed ; <nl> + <nl> + template < typename Item1 , typename Item2 > <nl> + void invoke_fmt ( const uint8_t * Data , std : : size_t Size ) { <nl> + constexpr auto N1 = sizeof ( Item1 ) ; <nl> + constexpr auto N2 = sizeof ( Item2 ) ; <nl> + static_assert ( N1 < = Nfixed , " size1 exceeded " ) ; <nl> + static_assert ( N2 < = Nfixed , " size2 exceeded " ) ; <nl> + if ( Size < = Nfixed + Nfixed ) { <nl> + return ; <nl> + } <nl> + Item1 item1 = fmt_fuzzer : : assignFromBuf < Item1 > ( Data ) ; <nl> + Data + = Nfixed ; <nl> + Size - = Nfixed ; <nl> + <nl> + Item2 item2 = fmt_fuzzer : : assignFromBuf < Item2 > ( Data ) ; <nl> + Data + = Nfixed ; <nl> + Size - = Nfixed ; <nl> + <nl> + auto fmtstring = fmt : : string_view ( fmt_fuzzer : : as_chars ( Data ) , Size ) ; <nl> + <nl> + # if FMT_FUZZ_FORMAT_TO_STRING <nl> + std : : string message = fmt : : format ( fmtstring , item1 , item2 ) ; <nl> + # else <nl> + fmt : : memory_buffer message ; <nl> + fmt : : format_to ( message , fmtstring , item1 , item2 ) ; <nl> + # endif <nl> + } <nl> + <nl> + / / for dynamic dispatching to an explicit instantiation <nl> + template < typename Callback > void invoke ( int index , Callback callback ) { <nl> + switch ( index ) { <nl> + case 0 : <nl> + callback ( bool { } ) ; <nl> + break ; <nl> + case 1 : <nl> + callback ( char { } ) ; <nl> + break ; <nl> + case 2 : <nl> + using sc = signed char ; <nl> + callback ( sc { } ) ; <nl> + break ; <nl> + case 3 : <nl> + using uc = unsigned char ; <nl> + callback ( uc { } ) ; <nl> + break ; <nl> + case 4 : <nl> + callback ( short { } ) ; <nl> + break ; <nl> + case 5 : <nl> + using us = unsigned short ; <nl> + callback ( us { } ) ; <nl> + break ; <nl> + case 6 : <nl> + callback ( int { } ) ; <nl> + break ; <nl> + case 7 : <nl> + callback ( unsigned { } ) ; <nl> + break ; <nl> + case 8 : <nl> + callback ( long { } ) ; <nl> + break ; <nl> + case 9 : <nl> + using ul = unsigned long ; <nl> + callback ( ul { } ) ; <nl> + break ; <nl> + case 10 : <nl> + callback ( float { } ) ; <nl> + break ; <nl> + case 11 : <nl> + callback ( double { } ) ; <nl> + break ; <nl> + case 12 : <nl> + using LD = long double ; <nl> + callback ( LD { } ) ; <nl> + break ; <nl> + case 13 : <nl> + using ptr = void * ; <nl> + callback ( ptr { } ) ; <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + extern " C " int LLVMFuzzerTestOneInput ( const uint8_t * Data , std : : size_t Size ) { <nl> + if ( Size < = 3 ) { <nl> + return 0 ; <nl> + } <nl> + <nl> + / / switch types depending on the first byte of the input <nl> + const auto first = Data [ 0 ] & 0x0F ; <nl> + const auto second = ( Data [ 0 ] & 0xF0 ) > > 4 ; <nl> + Data + + ; <nl> + Size - - ; <nl> + <nl> + auto outer = [ = ] ( auto param1 ) { <nl> + auto inner = [ = ] ( auto param2 ) { <nl> + invoke_fmt < decltype ( param1 ) , decltype ( param2 ) > ( Data , Size ) ; <nl> + } ; <nl> + invoke ( second , inner ) ; <nl> + } ; <nl> + <nl> + try { <nl> + invoke ( first , outer ) ; <nl> + } catch ( std : : exception & / * e * / ) { <nl> + } <nl> + return 0 ; <nl> + } <nl> new file mode 100644 <nl> index 000000000 . . 8cfc4be89 <nl> mmm / dev / null <nl> ppp b / test / fuzzing / two_args . cpp <nl> <nl> + / / Copyright ( c ) 2019 , Paul Dreik <nl> + / / License : see LICENSE . rst in the fmt root directory <nl> + # include < fmt / format . h > <nl> + # include < cstdint > <nl> + # include < stdexcept > <nl> + # include < type_traits > <nl> + <nl> + # include " fuzzer_common . h " <nl> + <nl> + constexpr auto Nfixed = fmt_fuzzer : : Nfixed ; <nl> + <nl> + template < typename Item1 , typename Item2 > <nl> + void invoke_fmt ( const uint8_t * Data , std : : size_t Size ) { <nl> + constexpr auto N1 = sizeof ( Item1 ) ; <nl> + constexpr auto N2 = sizeof ( Item2 ) ; <nl> + static_assert ( N1 < = Nfixed , " size1 exceeded " ) ; <nl> + static_assert ( N2 < = Nfixed , " size2 exceeded " ) ; <nl> + if ( Size < = Nfixed + Nfixed ) { <nl> + return ; <nl> + } <nl> + const Item1 item1 = fmt_fuzzer : : assignFromBuf < Item1 > ( Data ) ; <nl> + Data + = Nfixed ; <nl> + Size - = Nfixed ; <nl> + <nl> + const Item2 item2 = fmt_fuzzer : : assignFromBuf < Item2 > ( Data ) ; <nl> + Data + = Nfixed ; <nl> + Size - = Nfixed ; <nl> + <nl> + auto fmtstring = fmt : : string_view ( fmt_fuzzer : : as_chars ( Data ) , Size ) ; <nl> + <nl> + # if FMT_FUZZ_FORMAT_TO_STRING <nl> + std : : string message = fmt : : format ( fmtstring , item1 , item2 ) ; <nl> + # else <nl> + fmt : : memory_buffer message ; <nl> + fmt : : format_to ( message , fmtstring , item1 , item2 ) ; <nl> + # endif <nl> + } <nl> + <nl> + / / for dynamic dispatching to an explicit instantiation <nl> + template < typename Callback > void invoke ( int index , Callback callback ) { <nl> + switch ( index ) { <nl> + case 0 : <nl> + callback ( bool { } ) ; <nl> + break ; <nl> + case 1 : <nl> + callback ( char { } ) ; <nl> + break ; <nl> + case 2 : <nl> + using sc = signed char ; <nl> + callback ( sc { } ) ; <nl> + break ; <nl> + case 3 : <nl> + using uc = unsigned char ; <nl> + callback ( uc { } ) ; <nl> + break ; <nl> + case 4 : <nl> + callback ( short { } ) ; <nl> + break ; <nl> + case 5 : <nl> + using us = unsigned short ; <nl> + callback ( us { } ) ; <nl> + break ; <nl> + case 6 : <nl> + callback ( int { } ) ; <nl> + break ; <nl> + case 7 : <nl> + callback ( unsigned { } ) ; <nl> + break ; <nl> + case 8 : <nl> + callback ( long { } ) ; <nl> + break ; <nl> + case 9 : <nl> + using ul = unsigned long ; <nl> + callback ( ul { } ) ; <nl> + break ; <nl> + case 10 : <nl> + callback ( float { } ) ; <nl> + break ; <nl> + case 11 : <nl> + callback ( double { } ) ; <nl> + break ; <nl> + case 12 : <nl> + using LD = long double ; <nl> + callback ( LD { } ) ; <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + extern " C " int LLVMFuzzerTestOneInput ( const uint8_t * Data , std : : size_t Size ) { <nl> + if ( Size < = 3 ) { <nl> + return 0 ; <nl> + } <nl> + <nl> + / / switch types depending on the first byte of the input <nl> + const auto first = Data [ 0 ] & 0x0F ; <nl> + const auto second = ( Data [ 0 ] & 0xF0 ) > > 4 ; <nl> + Data + + ; <nl> + Size - - ; <nl> + <nl> + auto outer = [ = ] ( auto param1 ) { <nl> + auto inner = [ = ] ( auto param2 ) { <nl> + invoke_fmt < decltype ( param1 ) , decltype ( param2 ) > ( Data , Size ) ; <nl> + } ; <nl> + invoke ( second , inner ) ; <nl> + } ; <nl> + <nl> + try { <nl> + invoke ( first , outer ) ; <nl> + } catch ( std : : exception & / * e * / ) { <nl> + } <nl> + return 0 ; <nl> + } <nl> | add oss - fuzz support | fmtlib/fmt | 9d97201ede17bf5df4e01b117449a162a66b19ad | 2019-06-30T13:10:07Z |
mmm a / imgui . h <nl> ppp b / imgui . h <nl> namespace ImGui <nl> <nl> / / Obsolete functions ( Will be removed ! Also see ' API BREAKING CHANGES ' section in imgui . cpp ) <nl> # ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS <nl> - static void SetNextWindowPosCenter ( ImGuiCond cond = 0 ) ; / / OBSOLETE 1 . 52 + <nl> + void SetNextWindowPosCenter ( ImGuiCond cond = 0 ) ; / / OBSOLETE 1 . 52 + <nl> static inline bool IsItemHoveredRect ( ) { return IsItemRectHovered ( ) ; } / / OBSOLETE 1 . 51 + <nl> static inline bool IsPosHoveringAnyWindow ( const ImVec2 & ) { IM_ASSERT ( 0 ) ; return false ; } / / OBSOLETE 1 . 51 + . This was partly broken . You probably wanted to use ImGui : : GetIO ( ) . WantCaptureMouse instead . <nl> static inline bool IsMouseHoveringAnyWindow ( ) { return IsAnyWindowHovered ( ) ; } / / OBSOLETE 1 . 51 + <nl> | Fix static misusage error with decent compilers . Error introduced in 4b82759598e34aed179177ecaa00e774c0d23484 | ocornut/imgui | 99b9f1c93c4fd8ae6edb707bd8e22c7ca58e3d7a | 2017-09-26T09:23:06Z |
mmm a / editor / connections_dialog . cpp <nl> ppp b / editor / connections_dialog . cpp <nl> ConnectDialog : : ConnectDialog ( ) { <nl> vbc_right - > add_margin_child ( TTR ( " Extra Call Arguments : " ) , bind_editor , true ) ; <nl> <nl> HBoxContainer * dstm_hb = memnew ( HBoxContainer ) ; <nl> - vbc_left - > add_margin_child ( " Receiver Method : " , dstm_hb ) ; <nl> + vbc_left - > add_margin_child ( TTR ( " Receiver Method : " ) , dstm_hb ) ; <nl> <nl> dst_method = memnew ( LineEdit ) ; <nl> dst_method - > set_h_size_flags ( SIZE_EXPAND_FILL ) ; <nl> mmm a / editor / editor_node . h <nl> ppp b / editor / editor_node . h <nl> class EditorNode : public Node { <nl> Ref < Texture > get_class_icon ( const String & p_class , const String & p_fallback = " Object " ) const ; <nl> <nl> void show_accept ( const String & p_text , const String & p_title ) ; <nl> - void show_warning ( const String & p_text , const String & p_title = " Warning ! " ) ; <nl> + void show_warning ( const String & p_text , const String & p_title = TTR ( " Warning ! " ) ) ; <nl> <nl> void _copy_warning ( const String & p_str ) ; <nl> <nl> mmm a / editor / groups_editor . cpp <nl> ppp b / editor / groups_editor . cpp <nl> GroupDialog : : GroupDialog ( ) { <nl> add_group_text - > connect ( " text_entered " , this , " _add_group_pressed " ) ; <nl> <nl> Button * add_group_button = memnew ( Button ) ; <nl> - add_group_button - > set_text ( " Add " ) ; <nl> + add_group_button - > set_text ( TTR ( " Add " ) ) ; <nl> chbc - > add_child ( add_group_button ) ; <nl> add_group_button - > connect ( " pressed " , this , " _add_group_pressed " , varray ( String ( ) ) ) ; <nl> <nl> mmm a / editor / plugins / animation_state_machine_editor . cpp <nl> ppp b / editor / plugins / animation_state_machine_editor . cpp <nl> AnimationNodeStateMachineEditor : : AnimationNodeStateMachineEditor ( ) { <nl> <nl> top_hb - > add_spacer ( ) ; <nl> <nl> - top_hb - > add_child ( memnew ( Label ( " Play Mode : " ) ) ) ; <nl> + top_hb - > add_child ( memnew ( Label ( TTR ( " Play Mode : " ) ) ) ) ; <nl> play_mode = memnew ( OptionButton ) ; <nl> top_hb - > add_child ( play_mode ) ; <nl> <nl> mmm a / editor / plugins / mesh_library_editor_plugin . cpp <nl> ppp b / editor / plugins / mesh_library_editor_plugin . cpp <nl> MeshLibraryEditor : : MeshLibraryEditor ( EditorNode * p_editor ) { <nl> menu = memnew ( MenuButton ) ; <nl> SpatialEditor : : get_singleton ( ) - > add_control_to_menu_panel ( menu ) ; <nl> menu - > set_position ( Point2 ( 1 , 1 ) ) ; <nl> - menu - > set_text ( " Mesh Library " ) ; <nl> + menu - > set_text ( TTR ( " Mesh Library " ) ) ; <nl> menu - > set_icon ( EditorNode : : get_singleton ( ) - > get_gui_base ( ) - > get_icon ( " MeshLibrary " , " EditorIcons " ) ) ; <nl> menu - > get_popup ( ) - > add_item ( TTR ( " Add Item " ) , MENU_OPTION_ADD_ITEM ) ; <nl> menu - > get_popup ( ) - > add_item ( TTR ( " Remove Selected Item " ) , MENU_OPTION_REMOVE_ITEM ) ; <nl> mmm a / editor / plugins / script_editor_plugin . cpp <nl> ppp b / editor / plugins / script_editor_plugin . cpp <nl> void ScriptEditor : : _menu_option ( int p_option ) { <nl> <nl> Ref < Script > scr = current - > get_edited_resource ( ) ; <nl> if ( scr = = NULL | | scr . is_null ( ) ) { <nl> - EditorNode : : get_singleton ( ) - > show_warning ( " Can ' t obtain the script for running . " ) ; <nl> + EditorNode : : get_singleton ( ) - > show_warning ( TTR ( " Can ' t obtain the script for running . " ) ) ; <nl> break ; <nl> } <nl> <nl> void ScriptEditor : : _menu_option ( int p_option ) { <nl> Error err = scr - > reload ( false ) ; / / hard reload script before running always <nl> <nl> if ( err ! = OK ) { <nl> - EditorNode : : get_singleton ( ) - > show_warning ( " Script failed reloading , check console for errors . " ) ; <nl> + EditorNode : : get_singleton ( ) - > show_warning ( TTR ( " Script failed reloading , check console for errors . " ) ) ; <nl> return ; <nl> } <nl> if ( ! scr - > is_tool ( ) ) { <nl> <nl> - EditorNode : : get_singleton ( ) - > show_warning ( " Script is not in tool mode , will not be able to run . " ) ; <nl> + EditorNode : : get_singleton ( ) - > show_warning ( TTR ( " Script is not in tool mode , will not be able to run . " ) ) ; <nl> return ; <nl> } <nl> <nl> if ( ! ClassDB : : is_parent_class ( scr - > get_instance_base_type ( ) , " EditorScript " ) ) { <nl> <nl> - EditorNode : : get_singleton ( ) - > show_warning ( " To run this script , it must inherit EditorScript and be set to tool mode . " ) ; <nl> + EditorNode : : get_singleton ( ) - > show_warning ( TTR ( " To run this script , it must inherit EditorScript and be set to tool mode . " ) ) ; <nl> return ; <nl> } <nl> <nl> mmm a / editor / plugins / tile_set_editor_plugin . cpp <nl> ppp b / editor / plugins / tile_set_editor_plugin . cpp <nl> TileSetEditor : : TileSetEditor ( EditorNode * p_editor ) { <nl> HBoxContainer * tool_hb = memnew ( HBoxContainer ) ; <nl> Ref < ButtonGroup > g ( memnew ( ButtonGroup ) ) ; <nl> <nl> - String workspace_label [ WORKSPACE_MODE_MAX ] = { " Edit " , " New Single Tile " , " New Autotile " , " New Atlas " } ; <nl> + String workspace_label [ WORKSPACE_MODE_MAX ] = { <nl> + TTR ( " Edit " ) , <nl> + TTR ( " New Single Tile " ) , <nl> + TTR ( " New Autotile " ) , <nl> + TTR ( " New Atlas " ) <nl> + } ; <nl> for ( int i = 0 ; i < ( int ) WORKSPACE_MODE_MAX ; i + + ) { <nl> tool_workspacemode [ i ] = memnew ( Button ) ; <nl> - tool_workspacemode [ i ] - > set_text ( TTR ( workspace_label [ i ] ) ) ; <nl> + tool_workspacemode [ i ] - > set_text ( workspace_label [ i ] ) ; <nl> tool_workspacemode [ i ] - > set_toggle_mode ( true ) ; <nl> tool_workspacemode [ i ] - > set_button_group ( g ) ; <nl> tool_workspacemode [ i ] - > connect ( " pressed " , this , " _on_workspace_mode_changed " , varray ( i ) ) ; <nl> TileSetEditor : : TileSetEditor ( EditorNode * p_editor ) { <nl> tool_hb = memnew ( HBoxContainer ) ; <nl> <nl> g = Ref < ButtonGroup > ( memnew ( ButtonGroup ) ) ; <nl> - String label [ EDITMODE_MAX ] = { " Region " , " Collision " , " Occlusion " , " Navigation " , " Bitmask " , " Priority " , " Icon " , " Z Index " } ; <nl> + String label [ EDITMODE_MAX ] = { <nl> + TTR ( " Region " ) , <nl> + TTR ( " Collision " ) , <nl> + TTR ( " Occlusion " ) , <nl> + TTR ( " Navigation " ) , <nl> + TTR ( " Bitmask " ) , <nl> + TTR ( " Priority " ) , <nl> + TTR ( " Icon " ) , <nl> + TTR ( " Z Index " ) <nl> + } ; <nl> for ( int i = 0 ; i < ( int ) EDITMODE_MAX ; i + + ) { <nl> tool_editmode [ i ] = memnew ( Button ) ; <nl> tool_editmode [ i ] - > set_text ( label [ i ] ) ; <nl> mmm a / modules / visual_script / visual_script_editor . cpp <nl> ppp b / modules / visual_script / visual_script_editor . cpp <nl> void VisualScriptEditor : : _update_graph ( int p_only_id ) { <nl> if ( nd_list - > is_input_port_editable ( ) ) { <nl> has_gnode_text = true ; <nl> Button * btn = memnew ( Button ) ; <nl> - btn - > set_text ( " Add Input Port " ) ; <nl> + btn - > set_text ( TTR ( " Add Input Port " ) ) ; <nl> hbnc - > add_child ( btn ) ; <nl> btn - > connect ( " pressed " , this , " _add_input_port " , varray ( E - > get ( ) ) ) ; <nl> } <nl> void VisualScriptEditor : : _update_graph ( int p_only_id ) { <nl> hbnc - > add_spacer ( ) ; <nl> has_gnode_text = true ; <nl> Button * btn = memnew ( Button ) ; <nl> - btn - > set_text ( " Add Output Port " ) ; <nl> + btn - > set_text ( TTR ( " Add Output Port " ) ) ; <nl> hbnc - > add_child ( btn ) ; <nl> btn - > connect ( " pressed " , this , " _add_output_port " , varray ( E - > get ( ) ) ) ; <nl> } <nl> | Merge pull request from timothyqiu / i18n | godotengine/godot | 78f1513928bd5a683f0a0b40d4a4fec42fb1d4f3 | 2019-12-21T13:41:18Z |
mmm a / examples / fasterrcnn . cpp <nl> ppp b / examples / fasterrcnn . cpp <nl> static void draw_objects ( const cv : : Mat & bgr , const std : : vector < Object > & objects ) <nl> <nl> cv : : rectangle ( image , cv : : Rect ( cv : : Point ( x , y ) , <nl> cv : : Size ( label_size . width , label_size . height + baseLine ) ) , <nl> - cv : : Scalar ( 255 , 255 , 255 ) , CV_FILLED ) ; <nl> + cv : : Scalar ( 255 , 255 , 255 ) , - 1 ) ; <nl> <nl> cv : : putText ( image , text , cv : : Point ( x , y + label_size . height ) , <nl> cv : : FONT_HERSHEY_SIMPLEX , 0 . 5 , cv : : Scalar ( 0 , 0 , 0 ) ) ; <nl> int main ( int argc , char * * argv ) <nl> <nl> const char * imagepath = argv [ 1 ] ; <nl> <nl> - cv : : Mat m = cv : : imread ( imagepath , CV_LOAD_IMAGE_COLOR ) ; <nl> + cv : : Mat m = cv : : imread ( imagepath , 1 ) ; <nl> if ( m . empty ( ) ) <nl> { <nl> fprintf ( stderr , " cv : : imread % s failed \ n " , imagepath ) ; <nl> mmm a / examples / mobilenetssd . cpp <nl> ppp b / examples / mobilenetssd . cpp <nl> static void draw_objects ( const cv : : Mat & bgr , const std : : vector < Object > & objects ) <nl> <nl> cv : : rectangle ( image , cv : : Rect ( cv : : Point ( x , y ) , <nl> cv : : Size ( label_size . width , label_size . height + baseLine ) ) , <nl> - cv : : Scalar ( 255 , 255 , 255 ) , CV_FILLED ) ; <nl> + cv : : Scalar ( 255 , 255 , 255 ) , - 1 ) ; <nl> <nl> cv : : putText ( image , text , cv : : Point ( x , y + label_size . height ) , <nl> cv : : FONT_HERSHEY_SIMPLEX , 0 . 5 , cv : : Scalar ( 0 , 0 , 0 ) ) ; <nl> int main ( int argc , char * * argv ) <nl> <nl> const char * imagepath = argv [ 1 ] ; <nl> <nl> - cv : : Mat m = cv : : imread ( imagepath , CV_LOAD_IMAGE_COLOR ) ; <nl> + cv : : Mat m = cv : : imread ( imagepath , 1 ) ; <nl> if ( m . empty ( ) ) <nl> { <nl> fprintf ( stderr , " cv : : imread % s failed \ n " , imagepath ) ; <nl> mmm a / examples / mobilenetv2ssdlite . cpp <nl> ppp b / examples / mobilenetv2ssdlite . cpp <nl> static void draw_objects ( const cv : : Mat & bgr , const std : : vector < Object > & objects ) <nl> <nl> cv : : rectangle ( image , cv : : Rect ( cv : : Point ( x , y ) , <nl> cv : : Size ( label_size . width , label_size . height + baseLine ) ) , <nl> - cv : : Scalar ( 255 , 255 , 255 ) , CV_FILLED ) ; <nl> + cv : : Scalar ( 255 , 255 , 255 ) , - 1 ) ; <nl> <nl> cv : : putText ( image , text , cv : : Point ( x , y + label_size . height ) , <nl> cv : : FONT_HERSHEY_SIMPLEX , 0 . 5 , cv : : Scalar ( 0 , 0 , 0 ) ) ; <nl> int main ( int argc , char * * argv ) <nl> <nl> const char * imagepath = argv [ 1 ] ; <nl> <nl> - cv : : Mat m = cv : : imread ( imagepath , CV_LOAD_IMAGE_COLOR ) ; <nl> + cv : : Mat m = cv : : imread ( imagepath , 1 ) ; <nl> if ( m . empty ( ) ) <nl> { <nl> fprintf ( stderr , " cv : : imread % s failed \ n " , imagepath ) ; <nl> mmm a / examples / rfcn . cpp <nl> ppp b / examples / rfcn . cpp <nl> static void draw_objects ( const cv : : Mat & bgr , const std : : vector < Object > & objects ) <nl> <nl> cv : : rectangle ( image , cv : : Rect ( cv : : Point ( x , y ) , <nl> cv : : Size ( label_size . width , label_size . height + baseLine ) ) , <nl> - cv : : Scalar ( 255 , 255 , 255 ) , CV_FILLED ) ; <nl> + cv : : Scalar ( 255 , 255 , 255 ) , - 1 ) ; <nl> <nl> cv : : putText ( image , text , cv : : Point ( x , y + label_size . height ) , <nl> cv : : FONT_HERSHEY_SIMPLEX , 0 . 5 , cv : : Scalar ( 0 , 0 , 0 ) ) ; <nl> int main ( int argc , char * * argv ) <nl> <nl> const char * imagepath = argv [ 1 ] ; <nl> <nl> - cv : : Mat m = cv : : imread ( imagepath , CV_LOAD_IMAGE_COLOR ) ; <nl> + cv : : Mat m = cv : : imread ( imagepath , 1 ) ; <nl> if ( m . empty ( ) ) <nl> { <nl> fprintf ( stderr , " cv : : imread % s failed \ n " , imagepath ) ; <nl> mmm a / examples / shufflenetv2 . cpp <nl> ppp b / examples / shufflenetv2 . cpp <nl> int main ( int argc , char * * argv ) <nl> <nl> const char * imagepath = argv [ 1 ] ; <nl> <nl> - cv : : Mat m = cv : : imread ( imagepath , CV_LOAD_IMAGE_COLOR ) ; <nl> + cv : : Mat m = cv : : imread ( imagepath , 1 ) ; <nl> if ( m . empty ( ) ) <nl> { <nl> fprintf ( stderr , " cv : : imread % s failed \ n " , imagepath ) ; <nl> mmm a / examples / squeezenet . cpp <nl> ppp b / examples / squeezenet . cpp <nl> int main ( int argc , char * * argv ) <nl> <nl> const char * imagepath = argv [ 1 ] ; <nl> <nl> - cv : : Mat m = cv : : imread ( imagepath , CV_LOAD_IMAGE_COLOR ) ; <nl> + cv : : Mat m = cv : : imread ( imagepath , 1 ) ; <nl> if ( m . empty ( ) ) <nl> { <nl> fprintf ( stderr , " cv : : imread % s failed \ n " , imagepath ) ; <nl> mmm a / examples / squeezenetssd . cpp <nl> ppp b / examples / squeezenetssd . cpp <nl> static void draw_objects ( const cv : : Mat & bgr , const std : : vector < Object > & objects ) <nl> <nl> cv : : rectangle ( image , cv : : Rect ( cv : : Point ( x , y ) , <nl> cv : : Size ( label_size . width , label_size . height + baseLine ) ) , <nl> - cv : : Scalar ( 255 , 255 , 255 ) , CV_FILLED ) ; <nl> + cv : : Scalar ( 255 , 255 , 255 ) , - 1 ) ; <nl> <nl> cv : : putText ( image , text , cv : : Point ( x , y + label_size . height ) , <nl> cv : : FONT_HERSHEY_SIMPLEX , 0 . 5 , cv : : Scalar ( 0 , 0 , 0 ) ) ; <nl> int main ( int argc , char * * argv ) <nl> <nl> const char * imagepath = argv [ 1 ] ; <nl> <nl> - cv : : Mat m = cv : : imread ( imagepath , CV_LOAD_IMAGE_COLOR ) ; <nl> + cv : : Mat m = cv : : imread ( imagepath , 1 ) ; <nl> if ( m . empty ( ) ) <nl> { <nl> fprintf ( stderr , " cv : : imread % s failed \ n " , imagepath ) ; <nl> mmm a / examples / yolov2 . cpp <nl> ppp b / examples / yolov2 . cpp <nl> static void draw_objects ( const cv : : Mat & bgr , const std : : vector < Object > & objects ) <nl> <nl> cv : : rectangle ( image , cv : : Rect ( cv : : Point ( x , y ) , <nl> cv : : Size ( label_size . width , label_size . height + baseLine ) ) , <nl> - cv : : Scalar ( 255 , 255 , 255 ) , CV_FILLED ) ; <nl> + cv : : Scalar ( 255 , 255 , 255 ) , - 1 ) ; <nl> <nl> cv : : putText ( image , text , cv : : Point ( x , y + label_size . height ) , <nl> cv : : FONT_HERSHEY_SIMPLEX , 0 . 5 , cv : : Scalar ( 0 , 0 , 0 ) ) ; <nl> int main ( int argc , char * * argv ) <nl> <nl> const char * imagepath = argv [ 1 ] ; <nl> <nl> - cv : : Mat m = cv : : imread ( imagepath , CV_LOAD_IMAGE_COLOR ) ; <nl> + cv : : Mat m = cv : : imread ( imagepath , 1 ) ; <nl> if ( m . empty ( ) ) <nl> { <nl> fprintf ( stderr , " cv : : imread % s failed \ n " , imagepath ) ; <nl> mmm a / examples / yolov3 . cpp <nl> ppp b / examples / yolov3 . cpp <nl> static void draw_objects ( const cv : : Mat & bgr , const std : : vector < Object > & objects ) <nl> <nl> cv : : rectangle ( image , cv : : Rect ( cv : : Point ( x , y ) , <nl> cv : : Size ( label_size . width , label_size . height + baseLine ) ) , <nl> - cv : : Scalar ( 255 , 255 , 255 ) , CV_FILLED ) ; <nl> + cv : : Scalar ( 255 , 255 , 255 ) , - 1 ) ; <nl> <nl> cv : : putText ( image , text , cv : : Point ( x , y + label_size . height ) , <nl> cv : : FONT_HERSHEY_SIMPLEX , 0 . 5 , cv : : Scalar ( 0 , 0 , 0 ) ) ; <nl> int main ( int argc , char * * argv ) <nl> <nl> const char * imagepath = argv [ 1 ] ; <nl> <nl> - cv : : Mat m = cv : : imread ( imagepath , CV_LOAD_IMAGE_COLOR ) ; <nl> + cv : : Mat m = cv : : imread ( imagepath , 1 ) ; <nl> if ( m . empty ( ) ) <nl> { <nl> fprintf ( stderr , " cv : : imread % s failed \ n " , imagepath ) ; <nl> | use number instead of enum for compability with opencv 2 . x and opencv 4 . x | Tencent/ncnn | 26e64cac4123741c1fa2802bea5a05cff51e2377 | 2019-03-12T08:46:52Z |
new file mode 100644 <nl> index 000000000000 . . 0a3c1833c121 <nl> mmm / dev / null <nl> ppp b / docs / proposals / Initialization . rst <nl> <nl> + Initialization <nl> + = = = = = = = = = = = = = = <nl> + <nl> + . . contents : : <nl> + <nl> + Superclass Delegation <nl> + mmmmmmmmmmmmmmmmmmmmm <nl> + The initializer for a class that has a superclass must ensure that its <nl> + superclass subobject gets initialized . The typical way to do so is <nl> + through the use of superclass delegation : : <nl> + <nl> + class A { <nl> + var x : Int <nl> + <nl> + init ( x : Int ) { <nl> + self . x = x <nl> + } <nl> + } <nl> + <nl> + class B : A { <nl> + var value : String <nl> + <nl> + init ( ) { <nl> + value = " Hello " <nl> + super . init ( 5 ) / / superclass delegation <nl> + } <nl> + } <nl> + <nl> + Swift implements two - phase initialization , which requires that all of <nl> + the instance variables of the subclass be initialized ( either within <nl> + the class or within the initializer ) before delegating to the <nl> + superclass initializer with ` ` super . init ` ` . <nl> + <nl> + If the superclass is a Swift class , superclass delegation is a direct <nl> + call to the named initializer in the superclass . If the superclass is <nl> + an Objective - C class , superclass delegation uses dynamic dispatch via <nl> + ` ` objc_msgSendSuper ` ` ( and its variants ) . <nl> + <nl> + Peer Delegation <nl> + mmmmmmmmmmmmmmm <nl> + An initializer can delegate to one of its peer initializers , which <nl> + then takes responsibility for initializing this subobject and any <nl> + superclass subobjects : : <nl> + <nl> + extension A { <nl> + init fromString ( s : String ) { <nl> + self . init ( Int ( s ) ) / / peer delegation to init ( Int ) <nl> + } <nl> + } <nl> + <nl> + One cannot access any of the instance variables of ` ` self ` ` nor invoke <nl> + any instance methods on ` ` self ` ` before delegating to the peer <nl> + initializer , because the object has not yet been <nl> + constructed . Additionally , one cannot initialize the instance <nl> + variables of ` ` self ` ` , prior to delegating to the peer , because doing <nl> + so would lead to double initializations . <nl> + <nl> + Peer delegation is always a direct call to the named initializer , and <nl> + always calls an initializer defined for the same type as the <nl> + delegating initializer . Despite the syntactic similarities , this is <nl> + very different from Objective - C ' s ` ` [ self init . . . ] ` ` , which can call <nl> + methods in either the superclass or subclass . <nl> + <nl> + Peer delegation is primarily useful when providing convenience <nl> + initializers without having to duplicate initialization code . However , <nl> + peer delegation is also the only viable way to implement an <nl> + initializer for a type within an extension that resides in a different <nl> + resilience domain than the definition of the type itself . For example , <nl> + consider the following extension of ` ` A ` ` : : <nl> + <nl> + extension A { <nl> + init ( i : Int , j : Int ) { <nl> + x = i + j / / initialize x <nl> + } <nl> + } <nl> + <nl> + If this extension is in a different resilience domain than the <nl> + definition of ` ` A ` ` , there is no way to ensure that this initializer <nl> + is initializing all of the instance variables of ` ` A ` ` : new instance <nl> + variables could be added to ` ` A ` ` in a future version ( these would not <nl> + be properly initialized ) and existing instance variables could become <nl> + computed properties ( these would be initialized when they shouldn ' t <nl> + be ) . <nl> + <nl> + Initializer Inheritance <nl> + mmmmmmmmmmmmmmmmmmmmm - - <nl> + Initializers are * not * inherited by default . Each subclass takes <nl> + responsibility for its own initialization by declaring the <nl> + initializers one can use to create it . To make a superclass ' s <nl> + initializer available in a subclass , one can re - declare the <nl> + initializer and then use superclass delegation to call it : : <nl> + <nl> + class C : A { <nl> + var value = " Hello " <nl> + <nl> + init ( x : Int ) { <nl> + super . init ( x ) / / superclass delegation <nl> + } <nl> + } <nl> + <nl> + Although ` ` C ` ` ' s initializer has the same parameters as ` ` A ` ` ' s <nl> + initializer , it does not " override " ` ` A ` ` ' s initializer because there <nl> + is no dynamic dispatch for initializers ( but see below ) . <nl> + <nl> + We could syntax - optimize initializer inheritance if this becomes <nl> + onerous . DaveA provides a reasonable suggestion : : <nl> + <nl> + class C : A { <nl> + var value = " Hello " <nl> + <nl> + @ inherit init <nl> + @ inherit init : withFoo : <nl> + } <nl> + <nl> + * Note * : one can only inherit an initializer into a class ` ` C ` ` if all <nl> + of the instance variables in that class have in - class initializers . <nl> + <nl> + Virtual Initializers <nl> + mmmmmmmmmmmmmmmmmm - - <nl> + The initializer model above only safely permits initialization when we <nl> + statically know the type of the complete object being initialized . For <nl> + example , this permits the construction ` ` A ( 5 ) ` ` but not the <nl> + following : : <nl> + <nl> + def createAnA ( aClass : A . metatype ) - > A { <nl> + return aClass ( 5 ) / / error : no complete initializer accepting an ` ` Int ` ` <nl> + } <nl> + <nl> + The issue here is that , while ` ` A ` ` has an initializer accepting an <nl> + ` ` Int ` ` , it ' s not guaranteed that an arbitrary subclass of ` ` A ` ` will <nl> + have such an initializer . Even if we had that guarantee , there <nl> + wouldn ' t necessarily be any way to call the initializer , because ( as <nl> + noted above ) , there is no dynamic dispatch for initializers . <nl> + <nl> + This is an unacceptable limitation for a few reasons . The most obvious <nl> + reason is that ` ` NSCoding ` ` depends on dynamic dispatch to <nl> + ` ` - initWithCoder : ` ` to deserialize an object of a class type that is <nl> + dynamically determined , and Swift classes must safely support this <nl> + paradigm . To address this limitation , we can add the ` ` virtual ` ` <nl> + attribute to turn an initializer into a virtual initializer : : <nl> + <nl> + class A { <nl> + @ virtual init ( x : Int ) { . . . } <nl> + } <nl> + <nl> + Virtual initializers can be invoked when constructing an object using <nl> + an arbitrary value of metatype type ( as in the ` ` createAnA ` ` example <nl> + above ) , using dynamic dispatch . Therefore , we need to ensure that a <nl> + virtual initializer is always a complete object initializer , which <nl> + requires that every subclass provide a definition for each virtual <nl> + initializer defined in its superclass . For example , the following <nl> + class definition would be ill - formed : : <nl> + <nl> + class D : A { <nl> + var floating : Double <nl> + } <nl> + <nl> + because ` ` D ` ` does not provide an initializer accepting an ` ` Int ` ` . To <nl> + address this issue , one would add : : <nl> + <nl> + class D : A { <nl> + var floating : Double <nl> + <nl> + / * @ virtual optional * / init ( x : Int ) { <nl> + floating = 3 . 14159 <nl> + super . init ( x ) <nl> + } <nl> + } <nl> + <nl> + As a convenience , the compiler could synthesize virtual initializer <nl> + definitions when all of the instance variables in the subclass have <nl> + in - class initializers : : <nl> + <nl> + class D2 : A { <nl> + var floating = 3 . 14159 <nl> + <nl> + / * compiler - synthesized * / <nl> + / * @ virtual optional * / init ( x : Int ) { <nl> + super . init ( x ) <nl> + } <nl> + } <nl> + <nl> + This looks a lot like inherited initializers , and can eliminate some <nl> + boilerplate for simple subclasses . The primary downside is that the <nl> + synthesized implementation might not be the right one , e . g . , it will <nl> + almost surely be wrong for an inherited ` ` - initWithCoder : ` ` . <nl> + <nl> + * Note * : as a somewhat unfortunate side effect of the terminology , the <nl> + initializers for structs and enums are considered to be virtual , <nl> + because they are guaranteed to be complete object initializers . If <nl> + this bothers us , we could use the term ( and attribute ) " complete " <nl> + instead of " virtual " . I ' d prefer to stick with " virtual " and accept <nl> + the corner case . <nl> + <nl> + Initializers in Protocols <nl> + mmmmmmmmmmmmmmmmmmmmmmmm - <nl> + We currently ban initializers in protocols because we didn ' t have an <nl> + implementation model for them . Protocols , whether used via generics or <nl> + via existentials , use dynamic dispatch through the witness table . More <nl> + importantly , one of the important aspects of protocols is that , when a <nl> + given class ` ` A ` ` conforms to a protocol ` ` P ` ` , all of the subclasses <nl> + of ` ` A ` ` also conform to ` ` P ` ` . This property interacts directly with <nl> + initializers : : <nl> + <nl> + protocol NSCoding { <nl> + init withCoder ( coder : NSCoder ) <nl> + } <nl> + <nl> + class A : NSCoding { <nl> + init withCoder ( coder : NSCoder ) { / * . . . * / } <nl> + } <nl> + <nl> + class B : A { <nl> + / / conforms to NSCoding ? <nl> + } <nl> + <nl> + Here , ` ` A ` ` appears to conform to ` ` NSCoding ` ` because it provides a <nl> + matching initializer . ` ` B ` ` should conform to ` ` NSCoding ` ` , because it <nl> + should inherit its conformance from ` ` A ` ` , but the lack of an <nl> + ` ` initWithCoder : ` ` initializer causes problems . The fix here is to <nl> + require that the witness be a virtual initializer , which guarantees <nl> + that all of the subclasses will have the same initializer . Thus , the <nl> + definition of ` ` A ` ` above will be ill - formed unless ` ` initWithCoder : ` ` <nl> + is made virtual : : <nl> + <nl> + protocol NSCoding { <nl> + init withCoder ( coder : NSCoder ) <nl> + } <nl> + <nl> + class A : NSCoding { <nl> + @ virtual init withCoder ( coder : NSCoder ) { / * . . . * / } <nl> + } <nl> + <nl> + class B : A { <nl> + / / either error ( due to missing initWithCoder ) or synthesized initWithCoder : <nl> + } <nl> + <nl> + As noted earlier , the initializers of structs and enums are considered <nl> + virtual . <nl> + <nl> + Objective - C Interoperability <nl> + mmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + The initialization model described above guarantees that objects are <nl> + properly initialized before they are used , covering all of the major <nl> + use cases for initialization while maintaining soundness . Objective - C <nl> + has a very different initialization model with which Swift must <nl> + interoperate . <nl> + <nl> + Objective - C Entrypoints <nl> + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ <nl> + Each Swift initializer definition produces a corresponding Objective - C <nl> + init method . The existence of this init method allows object <nl> + construction from Objective - C ( both directly via ` ` [ [ A alloc ] <nl> + init : 5 ] ` ` and indirectly via , e . g . , ` ` [ obj initWithCoder : coder ] ` ` ) <nl> + and initialization of the superclass subobject when an Objective - C class <nl> + inherits from a Swift class ( e . g . , ` ` [ super initWithCoder : coder ] ` ` ) . <nl> + <nl> + Note that , while Swift ' s initializers are not inherited and cannot <nl> + override , this is only true * in Swift code * . If a subclass defines an <nl> + initializer with the same Objective - C selector as an initializer in <nl> + its superclass , the Objective - C init method produced for the former <nl> + will override the Objective - C init method produced for the <nl> + latter . <nl> + <nl> + Objective - C Restrictions <nl> + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ <nl> + The emission of Objective - C init methods for Swift initializers open <nl> + up a few soundness problems , illustrated here : : <nl> + <nl> + @ interface A <nl> + @ end <nl> + <nl> + @ implementation A <nl> + - init { <nl> + return [ self initWithInt : 5 ] ; <nl> + } <nl> + <nl> + - initWithInt : ( int ) x { <nl> + / / initialize me <nl> + } <nl> + <nl> + - initWithString : ( NSString * ) s { <nl> + / / initialize me <nl> + } <nl> + @ end <nl> + <nl> + class B1 : A { <nl> + var dict : NSDictionary <nl> + <nl> + init withInt ( x : Int ) { <nl> + dict = [ ] <nl> + super . init ( ) / / loops forever , initializing dict repeatedly <nl> + } <nl> + } <nl> + <nl> + class B2 : A { <nl> + } <nl> + <nl> + @ interface C : B2 <nl> + @ end <nl> + <nl> + @ implementation C <nl> + @ end <nl> + <nl> + void getCFromString ( NSString * str ) { <nl> + return [ C initWithString : str ] ; / / doesn ' t initialize B ' s dict ivar <nl> + } <nl> + <nl> + The first problem , with ` ` B1 ` ` , comes from ` ` A ` ` ' s dispatched <nl> + delegation to ` ` - initWithInt : ` ` , which is overridden by ` ` B1 ` ` ' s <nl> + initializer with the same selector . We can address this problem by <nl> + enforcing that superclass delegation to an Objective - C superclass <nl> + initializer refer to a designated initializer of that superclass when <nl> + that class has at least one initializer marked as a designated <nl> + initializer . <nl> + <nl> + The second problem , with ` ` C ` ` , comes from Objective - C ' s implicit <nl> + inheritance of initializers . We can address this problem by specifying <nl> + that init methods in Objective - C are never visible through Swift <nl> + classes , making the message send ` ` [ C initWithString : str ] ` ` <nl> + ill - formed . This is a relatively small Clang - side change . <nl> + <nl> + Remaining Soundness Holes <nl> + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ <nl> + Neither of the above " fixes " are complete . The first depends entirely <nl> + on the adoption of a not - yet - implemented Clang attribute to mark the <nl> + designated initializers for Objective - C classes , while the second is <nl> + ( almost trivially ) defeated by passing the ` ` - initWithString : ` ` <nl> + message to an object of type ` ` id ` ` or using some other dynamic <nl> + reflection . <nl> + <nl> + If we want to close these holes tighter , we could stop emitting <nl> + Objective - C init methods for Swift initializers . Instead , we would <nl> + fake the init method declarations when importing Swift modules into <nl> + Clang , and teach Clang ' s CodeGen to emit calls directly to the Swift <nl> + initializers . It would still not be perfect ( e . g . , some variant of the <nl> + problem with ` ` C ` ` would persist ) , but it would be closer . I suspect <nl> + that this is far more work than it is worth , and that the " fixes " <nl> + described above are sufficient . <nl> | Draft initialization proposal . | apple/swift | 218d0224e91538b7ce2e09f63dcc17ef066f0505 | 2013-11-11T18:15:01Z |
mmm a / ports / catch2 / CONTROL <nl> ppp b / ports / catch2 / CONTROL <nl> <nl> Source : catch2 <nl> - Version : 2 . 5 . 0 <nl> + Version : 2 . 6 . 0 <nl> Description : A modern , header - only test framework for unit testing . <nl> Issues , PRs and changelogs can be found at https : / / github . com / catchorg / Catch2 <nl> mmm a / ports / catch2 / portfile . cmake <nl> ppp b / ports / catch2 / portfile . cmake <nl> include ( vcpkg_common_functions ) <nl> vcpkg_from_github ( <nl> OUT_SOURCE_PATH SOURCE_PATH <nl> REPO catchorg / Catch2 <nl> - REF v2 . 5 . 0 <nl> - SHA512 420f1d1a5ea7b69be9fb316a8abe1fb7c7e78d44a982e883748f1e0c8d2a435c1518b6022742716019558a740f8b31977ed6a786b0293e0504206b016801cfe8 <nl> + REF v2 . 6 . 0 <nl> + SHA512 8d693cce413421ca747a0a3864d72c20f30fb8e432eb1f13e69605a71cc4e536d6710561f989cce6783d28f8b667b8da42c624056c4d412852885a8cf0df1e5d <nl> HEAD_REF master <nl> ) <nl> <nl> | [ Catch2 ] Upgrade to 2 . 6 . 0 ( ) | microsoft/vcpkg | e1d0090697753e72a2a9fcf5eaf9421fd7aaa51f | 2019-02-07T20:07:20Z |
mmm a / Marlin / src / lcd / extui / lib / ftdi_eve_touch_ui / ftdi_eve_lib / extended / screen_types . h <nl> ppp b / Marlin / src / lcd / extui / lib / ftdi_eve_touch_ui / ftdi_eve_lib / extended / screen_types . h <nl> class UIScreen { <nl> static bool onTouchEnd ( uint8_t ) { return true ; } <nl> } ; <nl> <nl> - # define PUSH_SCREEN ( screen ) current_screen . push ( screen : : onRedraw ) ; <nl> - # define GOTO_SCREEN ( screen ) current_screen . goTo ( screen : : onRedraw ) ; <nl> + # define PUSH_SCREEN ( screen ) current_screen . push ( screen : : onRedraw ) <nl> + # define GOTO_SCREEN ( screen ) current_screen . goTo ( screen : : onRedraw ) <nl> # define GOTO_PREVIOUS ( ) current_screen . goBack ( ) ; <nl> # define AT_SCREEN ( screen ) ( current_screen . getType ( ) = = current_screen . lookupScreen ( screen : : onRedraw ) ) <nl> # define IS_PARENT_SCREEN ( screen ) ( current_screen . peek ( ) = = current_screen . lookupScreen ( screen : : onRedraw ) ) <nl> mmm a / Marlin / src / lcd / extui / lib / ftdi_eve_touch_ui / language / language_en . h <nl> ppp b / Marlin / src / lcd / extui / lib / ftdi_eve_touch_ui / language / language_en . h <nl> namespace Language_en { <nl> PROGMEM Language_Str MSG_UNITS_STEP_MM = u8 " st / mm " ; <nl> PROGMEM Language_Str MSG_UNITS_PERCENT = u8 " % " ; <nl> PROGMEM Language_Str MSG_UNITS_C = DEGREE_SIGN u8 " C " ; <nl> - PROGMEM Language_Str MSG_MATERIAL_PLA = u8 " PLA " ; <nl> - PROGMEM Language_Str MSG_MATERIAL_ABS = u8 " ABS " ; <nl> - PROGMEM Language_Str MSG_MATERIAL_HIGH_TEMP = u8 " High " ; <nl> PROGMEM Language_Str MSG_IDLE = u8 " idle " ; <nl> PROGMEM Language_Str MSG_SET_MAXIMUM = u8 " Set Maximum " ; <nl> PROGMEM Language_Str MSG_PRINT_SPEED = u8 " Print Speed " ; <nl> mmm a / Marlin / src / lcd / extui / lib / ftdi_eve_touch_ui / marlin_events . cpp <nl> ppp b / Marlin / src / lcd / extui / lib / ftdi_eve_touch_ui / marlin_events . cpp <nl> namespace ExtUI { <nl> char lcd_msg [ 30 ] ; <nl> sprintf_P ( lcd_msg , PSTR ( " Extruder % d Filament Error " ) , extruder + 1 ) ; <nl> StatusScreen : : setStatusMessage ( lcd_msg ) ; <nl> - InterfaceSoundsScreen : : playEventSound ( InterfaceSoundsScreen : : PRINTING_FAILED ) ; <nl> + InterfaceSoundsScreen : : playEventSound ( InterfaceSoundsScreen : : PRINTING_FAILED , FTDI : : PLAY_SYNCHRONOUS ) ; <nl> } <nl> <nl> void onFactoryReset ( ) { <nl> mmm a / Marlin / src / lcd / extui / lib / ftdi_eve_touch_ui / screens / about_screen . cpp <nl> ppp b / Marlin / src / lcd / extui / lib / ftdi_eve_touch_ui / screens / about_screen . cpp <nl> void AboutScreen : : onRedraw ( draw_mode_t ) { <nl> # endif <nl> , OPT_CENTER , font_xlarge <nl> ) ; <nl> + cmd . tag ( 3 ) ; <nl> draw_text_box ( cmd , FW_VERS_POS , <nl> # ifdef TOUCH_UI_VERSION <nl> F ( TOUCH_UI_VERSION ) <nl> void AboutScreen : : onRedraw ( draw_mode_t ) { <nl> progmem_str ( getFirmwareName_str ( ) ) <nl> # endif <nl> , OPT_CENTER , font_medium ) ; <nl> + cmd . tag ( 0 ) ; <nl> draw_text_box ( cmd , FW_INFO_POS , about_str , OPT_CENTER , font_medium ) ; <nl> draw_text_box ( cmd , INSET_POS ( LICENSE_POS ) , GET_TEXT_F ( MSG_LICENSE ) , OPT_CENTER , font_tiny ) ; <nl> <nl> mmm a / Marlin / src / lcd / extui / lib / ftdi_eve_touch_ui / screens / change_filament_screen . cpp <nl> ppp b / Marlin / src / lcd / extui / lib / ftdi_eve_touch_ui / screens / change_filament_screen . cpp <nl> void ChangeFilamentScreen : : onRedraw ( draw_mode_t what ) { <nl> { <nl> char str [ 30 ] ; <nl> <nl> - format_temp_and_material ( str , LOW_TEMP , GET_TEXT ( MSG_MATERIAL_PLA ) ) ; <nl> + format_temp ( str , LOW_TEMP ) ; <nl> cmd . tag ( 2 ) . TOG_STYLE ( tog2 ) . button ( BTN_POS ( 2 , 6 ) , BTN_SIZE ( 1 , 1 ) , str ) ; <nl> <nl> - format_temp_and_material ( str , MED_TEMP , GET_TEXT ( MSG_MATERIAL_ABS ) ) ; <nl> + format_temp ( str , MED_TEMP ) ; <nl> cmd . tag ( 3 ) . TOG_STYLE ( tog3 ) . button ( BTN_POS ( 2 , 5 ) , BTN_SIZE ( 1 , 1 ) , str ) ; <nl> <nl> - format_temp_and_material ( str , HIGH_TEMP , GET_TEXT ( MSG_MATERIAL_HIGH_TEMP ) ) ; <nl> + format_temp ( str , HIGH_TEMP ) ; <nl> cmd . tag ( 4 ) . TOG_STYLE ( tog4 ) . button ( BTN_POS ( 2 , 4 ) , BTN_SIZE ( 1 , 1 ) , str ) ; <nl> } <nl> cmd . colors ( normal_btn ) <nl> mmm a / Marlin / src / lcd / extui / lib / ftdi_eve_touch_ui / screens / confirm_auto_calibration_dialog_box . cpp <nl> ppp b / Marlin / src / lcd / extui / lib / ftdi_eve_touch_ui / screens / confirm_auto_calibration_dialog_box . cpp <nl> bool ConfirmAutoCalibrationDialogBox : : onTouchEnd ( uint8_t tag ) { <nl> switch ( tag ) { <nl> case 1 : <nl> GOTO_SCREEN ( StatusScreen ) ; <nl> - injectCommands_P ( PSTR ( CALIBRATION_COMMANDS ) ) ; <nl> + injectCommands_P ( PSTR ( " G425 " ) ) ; <nl> return true ; <nl> default : <nl> return DialogBoxBaseClass : : onTouchEnd ( tag ) ; <nl> mmm a / Marlin / src / lcd / extui / lib / ftdi_eve_touch_ui / screens / status_screen . cpp <nl> ppp b / Marlin / src / lcd / extui / lib / ftdi_eve_touch_ui / screens / status_screen . cpp <nl> void StatusScreen : : draw_axis_position ( draw_mode_t what ) { <nl> strcpy_P ( y_str , PSTR ( " ? " ) ) ; <nl> <nl> if ( isAxisPositionKnown ( Z ) ) <nl> - format_position ( z_str , getAxisPosition_mm ( Z ) ) ; <nl> + format_position ( z_str , getAxisPosition_mm ( Z ) , 2 ) ; <nl> else <nl> strcpy_P ( z_str , PSTR ( " ? " ) ) ; <nl> <nl> mmm a / Marlin / src / lcd / extui / lib / ftdi_eve_touch_ui / screens / string_format . cpp <nl> ppp b / Marlin / src / lcd / extui / lib / ftdi_eve_touch_ui / screens / string_format . cpp <nl> void format_temp_and_material ( char * str , float t1 , const char * material ) { <nl> / * * <nl> * Formats a position value ( e . g . " 10 mm " ) <nl> * / <nl> - void format_position ( char * str , float p ) { <nl> - dtostrf ( p , 5 , 1 , str ) ; <nl> + void format_position ( char * str , float p , uint8_t decimals ) { <nl> + dtostrf ( p , 4 + decimals , decimals , str ) ; <nl> strcat_P ( str , PSTR ( " " ) ) ; <nl> strcat_P ( str , GET_TEXT ( MSG_UNITS_MM ) ) ; <nl> } <nl> mmm a / Marlin / src / lcd / extui / lib / ftdi_eve_touch_ui / screens / string_format . h <nl> ppp b / Marlin / src / lcd / extui / lib / ftdi_eve_touch_ui / screens / string_format . h <nl> void format_temp ( char * str , float t1 ) ; <nl> void format_temp_and_idle ( char * str , float t1 ) ; <nl> void format_temp_and_temp ( char * str , float t1 , float t2 ) ; <nl> void format_temp_and_material ( char * str , float t1 , const char * material ) ; <nl> - void format_position ( char * str , float p ) ; <nl> + void format_position ( char * str , float p , uint8_t decimals = 1 ) ; <nl> void format_position ( char * str , float x , float y , float z ) ; <nl> mmm a / Marlin / src / lcd / language / language_en . h <nl> ppp b / Marlin / src / lcd / language / language_en . h <nl> namespace Language_en { <nl> <nl> PROGMEM Language_Str MSG_LEVEL_X_AXIS = _UxGT ( " Level X Axis " ) ; <nl> PROGMEM Language_Str MSG_AUTO_CALIBRATE = _UxGT ( " Auto Calibrate " ) ; <nl> - PROGMEM Language_Str MSG_HEATER_TIMEOUT = _UxGT ( " Heater Timeout " ) ; <nl> + # if ENABLED ( TOUCH_UI_FTDI_EVE ) <nl> + PROGMEM Language_Str MSG_HEATER_TIMEOUT = _UxGT ( " Idle timeout , temperature decreased . Press Okay to reheat and again to resume . " ) ; <nl> + # else <nl> + PROGMEM Language_Str MSG_HEATER_TIMEOUT = _UxGT ( " Heater Timeout " ) ; <nl> + # endif <nl> PROGMEM Language_Str MSG_REHEAT = _UxGT ( " Reheat " ) ; <nl> PROGMEM Language_Str MSG_REHEATING = _UxGT ( " Reheating . . . " ) ; <nl> } <nl> | Fixes to FTDI Touch UI ( ) | MarlinFirmware/Marlin | b07dd44ec21ce6f622591cd96a1f709588f409b9 | 2020-08-26T05:59:06Z |
mmm a / src / net_processing . cpp <nl> ppp b / src / net_processing . cpp <nl> bool PeerLogicValidation : : SendMessages ( CNode * pto ) <nl> if ( ret . second ) { <nl> vRelayExpiration . push_back ( std : : make_pair ( nNow + std : : chrono : : microseconds { RELAY_TX_CACHE_TIME } . count ( ) , ret . first ) ) ; <nl> } <nl> + / / Add wtxid - based lookup into mapRelay as well , so that peers can request by wtxid <nl> + auto ret2 = mapRelay . emplace ( ret . first - > second - > GetWitnessHash ( ) , ret . first - > second ) ; <nl> + if ( ret2 . second ) { <nl> + vRelayExpiration . emplace_back ( nNow + std : : chrono : : microseconds { RELAY_TX_CACHE_TIME } . count ( ) , ret2 . first ) ; <nl> + } <nl> } <nl> if ( vInv . size ( ) = = MAX_INV_SZ ) { <nl> connman - > PushMessage ( pto , msgMaker . Make ( NetMsgType : : INV , vInv ) ) ; <nl> | Add a wtxid - index to mapRelay | bitcoin/bitcoin | 08b39955ec7f84e835ab0b1366f0dd28dfd6ce03 | 2020-07-18T23:00:02Z |
mmm a / PowerEditor / src / NppCommands . cpp <nl> ppp b / PowerEditor / src / NppCommands . cpp <nl> void Notepad_plus : : macroPlayback ( Macro macro ) <nl> <nl> for ( Macro : : iterator step = macro . begin ( ) ; step ! = macro . end ( ) ; + + step ) <nl> { <nl> - if ( step - > isPlayable ( ) ) <nl> + if ( step - > isScintillaMacro ( ) ) <nl> step - > PlayBack ( this - > _pPublicInterface , _pEditView ) ; <nl> else <nl> _findReplaceDlg . execSavedCommand ( step - > _message , step - > _lParameter , step - > _sParameter ) ; <nl> mmm a / PowerEditor / src / WinControls / shortcut / shortcut . cpp <nl> ppp b / PowerEditor / src / WinControls / shortcut / shortcut . cpp <nl> recordedMacroStep : : recordedMacroStep ( int iMessage , uptr_t wParam , uptr_t lParam , <nl> <nl> / / code comes from Scintilla ' s Editor . cxx : <nl> / / void Editor : : NotifyMacroRecord ( unsigned int iMessage , uptr_t wParam , sptr_t lParam ) <nl> - bool recordedMacroStep : : isMacroable ( unsigned int iMessage ) <nl> + bool recordedMacroStep : : isMacroable ( ) const <nl> { <nl> / / Enumerates all macroable messages <nl> - switch ( iMessage ) <nl> + switch ( _message ) <nl> { <nl> + case SCI_REPLACESEL : / / ( < unused > , const char * text ) <nl> + case SCI_ADDTEXT : / / ( int length , const char * s ) <nl> + case SCI_INSERTTEXT : / / ( int pos , const char * text ) <nl> + case SCI_APPENDTEXT : / / ( int length , const char * s ) <nl> + case SCI_SEARCHNEXT : / / ( int searchFlags , const char * text ) <nl> + case SCI_SEARCHPREV : / / ( int searchFlags , const char * text ) <nl> + { <nl> + if ( _macroType = = mtUseSParameter ) <nl> + return true ; <nl> + else <nl> + return false ; <nl> + } <nl> + <nl> + case SCI_GOTOLINE : / / ( int line ) <nl> + case SCI_GOTOPOS : / / ( int position ) <nl> + case SCI_SETSELECTIONMODE : / / ( int mode ) <nl> case SCI_CUT : <nl> case SCI_COPY : <nl> case SCI_PASTE : <nl> case SCI_CLEAR : <nl> - case SCI_REPLACESEL : <nl> - case SCI_ADDTEXT : <nl> - case SCI_INSERTTEXT : <nl> - case SCI_APPENDTEXT : <nl> case SCI_CLEARALL : <nl> case SCI_SELECTALL : <nl> - case SCI_GOTOLINE : <nl> - case SCI_GOTOPOS : <nl> case SCI_SEARCHANCHOR : <nl> - case SCI_SEARCHNEXT : <nl> - case SCI_SEARCHPREV : <nl> case SCI_LINEDOWN : <nl> case SCI_LINEDOWNEXTEND : <nl> case SCI_PARADOWN : <nl> bool recordedMacroStep : : isMacroable ( unsigned int iMessage ) <nl> case SCI_HOMEDISPLAYEXTEND : <nl> case SCI_LINEENDDISPLAY : <nl> case SCI_LINEENDDISPLAYEXTEND : <nl> - case SCI_SETSELECTIONMODE : <nl> case SCI_LINEDOWNRECTEXTEND : <nl> case SCI_LINEUPRECTEXTEND : <nl> case SCI_CHARLEFTRECTEXTEND : <nl> bool recordedMacroStep : : isMacroable ( unsigned int iMessage ) <nl> case SCI_MOVESELECTEDLINESDOWN : <nl> case SCI_SCROLLTOSTART : <nl> case SCI_SCROLLTOEND : <nl> - return true ; <nl> + { <nl> + if ( _macroType = = mtUseLParameter ) <nl> + return true ; <nl> + else <nl> + return false ; <nl> + } <nl> <nl> / / Filter out all others like display changes . Also , newlines are redundant <nl> / / with char insert messages . <nl> mmm a / PowerEditor / src / WinControls / shortcut / shortcut . h <nl> ppp b / PowerEditor / src / WinControls / shortcut / shortcut . h <nl> struct recordedMacroStep { <nl> bool isValid ( ) const { <nl> return true ; <nl> } ; <nl> - bool isPlayable ( ) const { return _macroType < = mtMenuCommand ; } ; <nl> - bool isMacroable ( unsigned int iMessage ) ; <nl> + bool isScintillaMacro ( ) const { return _macroType < = mtMenuCommand ; } ; <nl> + bool isMacroable ( ) const ; <nl> <nl> void PlayBack ( Window * pNotepad , ScintillaEditView * pEditView ) ; <nl> } ; <nl> | [ EU - FOSSA ] Enhance the macroable detection to avoid crash | notepad-plus-plus/notepad-plus-plus | da2d14436ca8a6a07b8c979bb14d099038c0cf00 | 2019-02-24T10:34:27Z |
mmm a / code / sorting / src / topological_sort / readme . md <nl> ppp b / code / sorting / src / topological_sort / readme . md <nl> <nl> # Topological Sort <nl> <nl> - It is a simple algorithm that outputs linear ordering of vertices / nodes of DAG ( Directed Acyclic Graph ) , where for each directed edge from node A to node B ( a : arrow_right : B ) , node A appears before node B in ordering . <nl> + A topological sort is a simple algorithm that outputs the linear ordering of vertices / nodes of a DAG ( Directed Acyclic Graph ) , where for each directed edge from node A to node B ( A : arrow_right : B ) , node A appears before node B in ordering . <nl> <nl> # # Condition : <nl> - 1 . The graphs should be * * directed * * : otherwise for any two vertices a & b , <nl> - there would be two paths from a to b & vice - versa , and hence they cannot be ordered . <nl> + 1 . The graphs should be * * directed * * , otherwise for any two vertices a & b , there would be two paths from a to b & vice - versa , & hence they cannot be ordered . <nl> <nl> - 2 . The graphs should be * * acyclic * * : otherwise for any three vertices a , b , c on a cycle , there will not be any starting point , & hence , linear ordering can ' t be done . <nl> + 2 . The graphs should be * * acyclic * * , otherwise for any three vertices a , b , c on a cycle , there will not be any starting point , & hence , linear ordering can ' t be done . <nl> <nl> > Note : Via this algorithm , multiple orderings are possible . <nl> <nl> For example : <nl> ! [ visualization ] ( http : / / faculty . simpson . edu / lydia . sinapova / www / cmsc250 / LN250_Weiss / L20 - TopSortFig01 . jpg ) <nl> + > Image Credits : Simpson College Computer Science Faculty <nl> <nl> Here , V1 , V2 , V3 , V4 and V1 , V3 , V2 , V4 are possible orderings . <nl> <nl> # # Time Complexity : <nl> - It ' s time comlexity is : O ( | V | + | E | ) & this is the case , when we use slightly modified adjacency linked list . <nl> + The time comlexity of this algorithm is : O ( | V | + | E | ) & this is the case , when we use slightly modified adjacency linked list . <nl> Where , V : No . of vertices & E : No . of edges . <nl> <nl> To be more precise , we can get topologically sorted list in two ways : <nl> 1 . * * Adjacency matrix : * * <nl> - In this case , it ' ll take ( | V | ^ 2 ) time to find all vertices in graph with no predecessors . <nl> + In this case , it ' ll take O ( | V | ^ 2 ) time to find all vertices in graph with no predecessors . <nl> 2 . * * Adjacency list : * * <nl> - Here , we ’ ll need O ( | E | ) time . So , in worst case , it again takes ( | V | ^ 2 ) time for the same . <nl> + In this case , we ’ ll need O ( | E | ) time . Thus , in worst case , it again takes ( | V | ^ 2 ) time for the same . <nl> <nl> - So , to optimize the algorithm , we slightly modify adjacency list implementation , by adding two lists to store both outgoing & incoming edges , inorder to find nodes with no predecessors . And , hence , we get better performance with time complexity : O ( | V | + | E | ) . <nl> + So , to optimize the algorithm , we slightly modify adjacency list implementation , by adding two lists to store both outgoing & incoming edges , inorder to find nodes with no predecessors & hence , we get better performance with time complexity : O ( | V | + | E | ) . <nl> <nl> mmm <nl> A large scale collaboration of [ OpenGenus ] ( https : / / github . com / opengenus ) <nl> | Made the required changes | OpenGenus/cosmos | bc5e97be0d9a83827a575f6a166374c735b99188 | 2018-02-09T05:34:57Z |
mmm a / cmake / TaichiCXXFlags . cmake <nl> ppp b / cmake / TaichiCXXFlags . cmake <nl> set ( CMAKE_CXX_FLAGS " $ { CMAKE_CXX_FLAGS } - DTC_PASS_EXCEPTION_TO_PYTHON " ) <nl> <nl> set ( CMAKE_CXX_FLAGS " $ { CMAKE_CXX_FLAGS } - DTC_INCLUDED " ) <nl> <nl> - if ( TC_USE_DOUBLE ) <nl> + if ( $ ENV { TC_USE_DOUBLE } ) <nl> set ( CMAKE_CXX_FLAGS " $ { CMAKE_CXX_FLAGS } - DTC_USE_DOUBLE " ) <nl> message ( " Using float64 precision " ) <nl> endif ( ) <nl> mmm a / docs / installation . rst <nl> ppp b / docs / installation . rst <nl> Additional environment variables : ( assuming taichi is installed in ` ` DIR / taichi ` <nl> <nl> Add ` ` DIR / taichi / python ` ` to ` ` PYTHONPATH ` ` and ` ` DIR / taichi / bin ` ` to ` ` PATH ` ` <nl> <nl> + Build with Double Precision ( 64 bit ) Float Point <nl> + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + . . code - block : : bash <nl> + <nl> + export TC_USE_DOUBLE = 1 <nl> + ti build <nl> + <nl> Examples <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> Please see ` examples < https : / / github . com / yuanming - hu / taichi / tree / master / projects / examples > ` _ . <nl> mmm a / include / taichi / io / ply_writer . h <nl> ppp b / include / taichi / io / ply_writer . h <nl> class PLYWriter { <nl> FILE * file ; <nl> <nl> struct Vertex { <nl> - Vector3f position ; <nl> - Vector3f color ; <nl> - Vertex ( Vector3f position , Vector3f color ) <nl> + Vector3 position ; <nl> + Vector3 color ; <nl> + Vertex ( Vector3 position , Vector3 color ) <nl> : position ( position ) , color ( color ) { <nl> } <nl> } ; <nl> class PLYWriter { <nl> face_vertices_count . push_back ( vert . size ( ) ) ; <nl> } <nl> <nl> - void add_face ( const std : : vector < Vector3f > & vert_ ) { <nl> + void add_face ( const std : : vector < Vector3 > & vert_ ) { <nl> std : : vector < Vertex > vert ; <nl> for ( auto v : vert_ ) { <nl> - vert . push_back ( Vertex ( v , Vector3f ( 0 , 1 , 0 ) ) ) ; <nl> + vert . push_back ( Vertex ( v , Vector3 ( 0 , 1 , 0 ) ) ) ; <nl> } <nl> vertices . insert ( vertices . end ( ) , vert . begin ( ) , vert . end ( ) ) ; <nl> face_vertices_count . push_back ( vert . size ( ) ) ; <nl> class PLYWriter { <nl> fmt : : print ( file , header , vertices . size ( ) , face_vertices_count . size ( ) ) ; <nl> <nl> for ( auto v : vertices ) { <nl> - Vector3i color = ( v . color * 255 . 0f ) . template cast < int > ( ) ; <nl> + Vector3i color = ( v . color * 255 . 0_f ) . template cast < int > ( ) ; <nl> fmt : : print ( file , " { } { } { } { } { } { } \ n " , v . position . x , v . position . y , <nl> v . position . z , color . x , color . y , color . z ) ; <nl> } <nl> mmm a / include / taichi / math / vector . h <nl> ppp b / include / taichi / math / vector . h <nl> TC_FORCE_INLINE float64 inversed ( const float64 & a ) { <nl> <nl> template < InstSetExt ISE , typename T > <nl> TC_FORCE_INLINE MatrixND < 2 , T , ISE > inversed ( const MatrixND < 2 , T , ISE > & mat ) { <nl> - real det = determinant ( mat ) ; <nl> + T det = determinant ( mat ) ; <nl> return static_cast < T > ( 1 ) / det * <nl> MatrixND < 2 , T , ISE > ( VectorND < 2 , T , ISE > ( mat [ 1 ] [ 1 ] , - mat [ 0 ] [ 1 ] ) , <nl> VectorND < 2 , T , ISE > ( - mat [ 1 ] [ 0 ] , mat [ 0 ] [ 0 ] ) ) ; <nl> mmm a / src / io / ply . cpp <nl> ppp b / src / io / ply . cpp <nl> class TestPLY : public Task { <nl> using Vert = PLYWriter : : Vertex ; <nl> <nl> for ( int i = 0 ; i < 10 ; i + + ) { <nl> - ply . add_face ( { Vert ( Vector3f ( 1 + i , 0 , 0 ) , Vector3f ( 1 , 0 , 0 ) ) , <nl> - Vert ( Vector3f ( 0 , 1 + i , 0 ) , Vector3f ( 0 , 1 , 0 ) ) , <nl> - Vert ( Vector3f ( 0 , 0 , 1 + i ) , Vector3f ( 0 , 0 , i % 5 * 0 . 2f ) ) } ) ; <nl> + ply . add_face ( { Vert ( Vector3 ( 1 + i , 0 , 0 ) , Vector3 ( 1 , 0 , 0 ) ) , <nl> + Vert ( Vector3 ( 0 , 1 + i , 0 ) , Vector3 ( 0 , 1 , 0 ) ) , <nl> + Vert ( Vector3 ( 0 , 0 , 1 + i ) , Vector3 ( 0 , 0 , i % 5 * 0 . 2f ) ) } ) ; <nl> } <nl> } <nl> } ; <nl> | Fixed double build | taichi-dev/taichi | 46558edc0d55a53a5a983cb8d0567345e979d48e | 2018-04-26T23:23:09Z |
mmm a / googlemock / CMakeLists . txt <nl> ppp b / googlemock / CMakeLists . txt <nl> $ env : Path = \ " $ project_bin ; $ env : Path \ " <nl> & $ args " ) <nl> endif ( ) <nl> <nl> + if ( MINGW OR CYGWIN ) <nl> + if ( CMAKE_VERSION VERSION_LESS " 2 . 8 . 12 " ) <nl> + add_compile_options ( " - Wa , - mbig - obj " ) <nl> + else ( ) <nl> + add_definitions ( " - Wa , - mbig - obj " ) <nl> + endif ( ) <nl> + endif ( ) <nl> + <nl> # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> # C + + tests built with standard compiler flags . <nl> <nl> $ env : Path = \ " $ project_bin ; $ env : Path \ " <nl> cxx_test ( gmock - generated - matchers_test gmock_main ) <nl> cxx_test ( gmock - internal - utils_test gmock_main ) <nl> cxx_test ( gmock - matchers_test gmock_main ) <nl> - if ( MINGW OR CYGWIN ) <nl> - target_compile_options ( gmock - matchers_test PRIVATE " - Wa , - mbig - obj " ) <nl> - endif ( ) <nl> cxx_test ( gmock - more - actions_test gmock_main ) <nl> cxx_test ( gmock - nice - strict_test gmock_main ) <nl> cxx_test ( gmock - port_test gmock_main ) <nl> | Merge pull request from adambadura : FixCygwin | google/googletest | 4083746e61ae8ca9c06c1d4a5a759920095dd209 | 2019-08-15T21:34:27Z |
mmm a / tensorflow / python / util / nest . py <nl> ppp b / tensorflow / python / util / nest . py <nl> def _is_namedtuple ( instance , strict = False ) : <nl> <nl> <nl> # See the swig file ( util . i ) for documentation . <nl> - _is_mapping = _pywrap_utils . IsMapping <nl> _is_mapping_view = _pywrap_utils . IsMappingView <nl> _is_attrs = _pywrap_utils . IsAttrs <nl> _is_composite_tensor = _pywrap_utils . IsCompositeTensor <nl> def _sequence_like ( instance , args ) : <nl> result = dict ( zip ( _sorted ( instance ) , args ) ) <nl> instance_type = type ( instance ) <nl> if instance_type = = _collections . defaultdict : <nl> - d = instance_type ( ) <nl> - for key in instance : <nl> - d [ key ] = result [ key ] <nl> - return d <nl> - elif _is_mapping ( instance ) : <nl> - result = dict ( zip ( _sorted ( instance ) , args ) ) <nl> - instance_type = type ( instance ) <nl> - if instance_type = = _collections . defaultdict : <nl> - d = _collections . defaultdict ( instance . default_factory ) <nl> + d = instance_type ( _collections . defaultdict ( instance . default_factory ) ) <nl> for key in instance : <nl> d [ key ] = result [ key ] <nl> return d <nl> def sequence_fn ( instance , args ) : <nl> <nl> <nl> _pywrap_utils . RegisterType ( " Mapping " , _collections_abc . Mapping ) <nl> + _pywrap_utils . RegisterType ( " MutableMapping " , _collections_abc . MutableMapping ) <nl> _pywrap_utils . RegisterType ( " Sequence " , _collections_abc . Sequence ) <nl> _pywrap_utils . RegisterType ( " MappingView " , _collections_abc . MappingView ) <nl> _pywrap_utils . RegisterType ( " ObjectProxy " , _wrapt . ObjectProxy ) <nl> mmm a / tensorflow / python / util / util . cc <nl> ppp b / tensorflow / python / util / util . cc <nl> bool AssertSameStructureHelper ( <nl> <nl> bool IsSequence ( PyObject * o ) { return IsSequenceHelper ( o ) = = 1 ; } <nl> bool IsMapping ( PyObject * o ) { return IsMappingHelper ( o ) = = 1 ; } <nl> + bool IsMutableMapping ( PyObject * o ) { return IsMutableMappingHelper ( o ) = = 1 ; } <nl> bool IsMappingView ( PyObject * o ) { return IsMappingViewHelper ( o ) = = 1 ; } <nl> bool IsAttrs ( PyObject * o ) { return IsAttrsHelper ( o ) = = 1 ; } <nl> bool IsTensor ( PyObject * o ) { return IsTensorHelper ( o ) = = 1 ; } <nl> mmm a / tensorflow / tools / def_file_filter / symbols_pybind . txt <nl> ppp b / tensorflow / tools / def_file_filter / symbols_pybind . txt <nl> tensorflow : : swig : : IsCompositeTensor <nl> tensorflow : : swig : : IsTypeSpec <nl> tensorflow : : swig : : IsNamedtuple <nl> tensorflow : : swig : : IsMapping <nl> + tensorflow : : swig : : IsMutableMapping <nl> tensorflow : : swig : : IsMappingView <nl> tensorflow : : swig : : IsAttrs <nl> tensorflow : : swig : : IsTensor <nl> | Added support for MutableMapping | tensorflow/tensorflow | 5234f66ecfcfa3835d7d86a47932838642c07c5b | 2020-02-10T15:50:12Z |
Binary files a / PowerEditor / bin / npp . pdb and b / PowerEditor / bin / npp . pdb differ <nl> | [ TEST ] npp . pdb | notepad-plus-plus/notepad-plus-plus | 549200335555e7e9c41167d216f3b72394ddc072 | 2015-04-15T20:22:23Z |
mmm a / js / server / modules / org / arangodb / foxx / arangoApp . js <nl> ppp b / js / server / modules / org / arangodb / foxx / arangoApp . js <nl> var isSystemMount = function ( mount ) { <nl> / / / @ brief returns the root path for application . Knows about system apps <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - var computeRootAppPath = function ( mount ) { <nl> + var computeRootAppPath = function ( mount , isValidation ) { <nl> + if ( isValidation ) { <nl> + return " " ; <nl> + } <nl> if ( isSystemMount ( mount ) ) { <nl> return module . systemAppPath ( ) ; <nl> } <nl> var computeRootAppPath = function ( mount ) { <nl> } <nl> this . _name = this . _manifest . name ; <nl> this . _version = this . _manifest . version ; <nl> - this . _root = computeRootAppPath ( config . mount ) ; <nl> + this . _root = computeRootAppPath ( config . mount , config . id = = = " __internal " ) ; <nl> this . _path = config . path ; <nl> this . _options = config . options ; <nl> this . _mount = config . mount ; <nl> mmm a / js / server / modules / org / arangodb / foxx / manager . js <nl> ppp b / js / server / modules / org / arangodb / foxx / manager . js <nl> <nl> var fakeAppConfig = function ( path ) { <nl> var file = fs . join ( path , " manifest . json " ) ; <nl> return { <nl> - id : " / internal " , <nl> + id : " __internal " , <nl> root : " " , <nl> path : path , <nl> options : { } , <nl> | Changed internal app validation path to be absolute and not relative to the user defined js app path | arangodb/arangodb | 6adbab0bf63c860db57d37c26280bf93eb53145f | 2015-03-09T13:46:00Z |
mmm a / cocos2dx / CCConfiguration . cpp <nl> ppp b / cocos2dx / CCConfiguration . cpp <nl> void CCConfiguration : : loadConfigFile ( const char * filename ) <nl> CCDictionary * dict = CCDictionary : : createWithContentsOfFile ( filename ) ; <nl> CCAssert ( dict , " cannot create dictionary " ) ; <nl> <nl> + / / search for metadata <nl> + bool metadata_ok = false ; <nl> + CCObject * metadata = dict - > objectForKey ( " metadata " ) ; <nl> + if ( metadata & & dynamic_cast < CCDictionary * > ( metadata ) ) { <nl> + CCObject * format_o = static_cast < CCDictionary * > ( metadata ) - > objectForKey ( " format " ) ; <nl> + <nl> + / / XXX : cocos2d - x returns CCStrings when importing from . plist . This bug will be addressed in cocos2d - x v3 . x <nl> + if ( format_o & & dynamic_cast < CCString * > ( format_o ) ) { <nl> + int format = static_cast < CCString * > ( format_o ) - > intValue ( ) ; <nl> + <nl> + / / Support format : 1 <nl> + if ( format = = 1 ) { <nl> + metadata_ok = true ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + if ( ! metadata_ok ) { <nl> + CCLOG ( " Invalid config format for file : % s " , filename ) ; <nl> + return ; <nl> + } <nl> + <nl> + CCObject * data = dict - > objectForKey ( " data " ) ; <nl> + if ( ! data | | ! dynamic_cast < CCDictionary * > ( data ) ) { <nl> + CCLOG ( " Expected ' data ' dict , but not found . Config file : % s " , filename ) ; <nl> + return ; <nl> + } <nl> + <nl> / / Add all keys in the existing dictionary <nl> + CCDictionary * data_dict = static_cast < CCDictionary * > ( data ) ; <nl> CCDictElement * element ; <nl> - CCDICT_FOREACH ( dict , element ) <nl> + CCDICT_FOREACH ( data_dict , element ) <nl> { <nl> if ( ! m_pDefaults - > objectForKey ( element - > getStrKey ( ) ) ) <nl> m_pDefaults - > setObject ( element - > getObject ( ) , element - > getStrKey ( ) ) ; <nl> mmm a / samples / Cpp / TestCpp / Classes / ConfigurationTest / ConfigurationTest . cpp <nl> ppp b / samples / Cpp / TestCpp / Classes / ConfigurationTest / ConfigurationTest . cpp <nl> <nl> <nl> TESTLAYER_CREATE_FUNC ( ConfigurationLoadConfig ) ; <nl> TESTLAYER_CREATE_FUNC ( ConfigurationQuery ) ; <nl> + TESTLAYER_CREATE_FUNC ( ConfigurationInvalid ) ; <nl> <nl> static NEWTESTFUNC createFunctions [ ] = { <nl> CF ( ConfigurationLoadConfig ) , <nl> - CF ( ConfigurationQuery ) <nl> + CF ( ConfigurationQuery ) , <nl> + CF ( ConfigurationInvalid ) <nl> } ; <nl> <nl> static int sceneIdx = - 1 ; <nl> void ConfigurationLoadConfig : : onEnter ( ) <nl> { <nl> ConfigurationBase : : onEnter ( ) ; <nl> <nl> - CCConfiguration : : sharedConfiguration ( ) - > loadConfigFile ( " animations / animations . plist " ) ; <nl> + CCConfiguration : : sharedConfiguration ( ) - > loadConfigFile ( " configs / config - test - ok . plist " ) ; <nl> CCConfiguration : : sharedConfiguration ( ) - > dumpInfo ( ) ; <nl> <nl> } <nl> std : : string ConfigurationQuery : : subtitle ( ) <nl> { <nl> return " Using getCString ( ) . Check the console " ; <nl> } <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + / / <nl> + / / ConfigurationInvalid <nl> + / / <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + void ConfigurationInvalid : : onEnter ( ) <nl> + { <nl> + ConfigurationBase : : onEnter ( ) ; <nl> + <nl> + CCConfiguration : : sharedConfiguration ( ) - > loadConfigFile ( " configs / config - test - invalid . plist " ) ; <nl> + } <nl> + <nl> + std : : string ConfigurationInvalid : : subtitle ( ) <nl> + { <nl> + return " Loading an invalid config file " ; <nl> + } <nl> mmm a / samples / Cpp / TestCpp / Classes / ConfigurationTest / ConfigurationTest . h <nl> ppp b / samples / Cpp / TestCpp / Classes / ConfigurationTest / ConfigurationTest . h <nl> class ConfigurationQuery : public ConfigurationBase <nl> virtual std : : string subtitle ( ) ; <nl> } ; <nl> <nl> + class ConfigurationInvalid : public ConfigurationBase <nl> + { <nl> + public : <nl> + virtual void onEnter ( ) ; <nl> + virtual std : : string subtitle ( ) ; <nl> + } ; <nl> + <nl> # endif / / __CONFIGURATIONTEST_H__ <nl> | CCConfiguration has format | cocos2d/cocos2d-x | a219f9c520425caf8674793060fef685b5d2f477 | 2013-05-29T09:09:04Z |
mmm a / Tools / CryVersionSelector / cryregistry . py <nl> ppp b / Tools / CryVersionSelector / cryregistry . py <nl> def save_engines ( database , register_action = True , silent = False ) : <nl> return 630 <nl> <nl> <nl> - def engine_file ( database , engine_version ) : <nl> + def engine_file ( database , engine_id ) : <nl> " " " <nl> Returns the path to the . cryengine file of the specified engine <nl> version , or None if the engine version is not in the database . <nl> " " " <nl> - path = database . get ( engine_version , { ' uri ' : None } ) [ ' uri ' ] <nl> + path = database . get ( engine_id , { ' uri ' : None } ) [ ' uri ' ] <nl> return path if path else None <nl> <nl> <nl> - def engine_path ( database , engine_version ) : <nl> + def engine_path ( database , engine_id ) : <nl> " " " <nl> Returns the path to the root - folder of the specified engine version , <nl> or None if the engine version is not in the database . <nl> " " " <nl> - path = engine_file ( database , engine_version ) <nl> + path = engine_file ( database , engine_id ) <nl> <nl> root = os . path . dirname ( path ) <nl> return root if root else None <nl> mmm a / Tools / CryVersionSelector / cryrun . py <nl> ppp b / Tools / CryVersionSelector / cryrun . py <nl> def main ( ) : <nl> <nl> parser_upgrade = subparsers . add_parser ( ' upgrade ' ) <nl> parser_upgrade . add_argument ( ' project_file ' ) <nl> - parser_upgrade . add_argument ( ' - - engine_version ' ) <nl> + parser_upgrade . add_argument ( ' - - engine_id ' ) <nl> parser_upgrade . set_defaults ( func = cmd_upgrade ) <nl> <nl> parser_require = subparsers . add_parser ( ' require ' ) <nl> mmm a / Tools / CryVersionSelector / cryselect . py <nl> ppp b / Tools / CryVersionSelector / cryselect . py <nl> def error_engine_json_decode ( engine_file , silent ) : <nl> sys . exit ( 604 ) <nl> <nl> <nl> - def error_engine_path_not_found ( args , engine_version ) : <nl> + def error_engine_path_not_found ( args , engine_id ) : <nl> " " " <nl> Error to specify that the engine path could not be found , <nl> because the engine was not registered . <nl> " " " <nl> message = " CryEngine ' { } ' has not been registered locally . \ n " . format ( <nl> - engine_version ) <nl> + engine_id ) <nl> if not args . silent and HAS_WIN_MODULES : <nl> MESSAGEBOX ( None , message , command_title ( args ) , <nl> win32con . MB_OK | win32con . MB_ICONERROR ) <nl> def cmd_add ( args ) : <nl> sys . exit ( add_engines ( * args . engine_files , silent = args . silent ) ) <nl> <nl> <nl> - def add_plugins ( engine_version , plugin_files ) : <nl> + def add_plugins ( engine_id , plugin_files ) : <nl> " " " <nl> Adds the collection of plugins to the registered engine . <nl> " " " <nl> engine_registry = cryregistry . load_engines ( ) <nl> <nl> - engine = engine_registry [ engine_version ] <nl> + engine = engine_registry [ engine_id ] <nl> plugins = engine . get ( ' plugins ' , { } ) <nl> <nl> for plugin_file in plugin_files : <nl> def cmd_add_plugins ( args ) : <nl> " " " <nl> Adds the plugins to the registered engine . <nl> " " " <nl> - if args . engine_id is None : <nl> - app = crygui . CryWindowAddPlugin ( args . plugin_files ) <nl> - app . mainloop ( ) <nl> - else : <nl> - sys . exit ( add_plugins ( args . engine_version , args . plugin_files ) ) <nl> + sys . exit ( add_plugins ( args . engine_id , args . plugin_files ) ) <nl> <nl> <nl> def cmd_add_plugin_gui ( args ) : <nl> def cmd_remove ( args ) : <nl> engine_registry , register_action = False , silent = args . silent ) ) <nl> <nl> <nl> - def remove_plugins ( engine_version , plugin_files ) : <nl> + def remove_plugins ( engine_id , plugin_files ) : <nl> " " " <nl> Removes the plugins from the registered engine . <nl> " " " <nl> def remove_plugins ( engine_version , plugin_files ) : <nl> sys . excepthook ( * sys . exc_info ( ) ) <nl> return <nl> <nl> - remove_plugin_by_guid ( engine_version , plugin . guid ( ) ) <nl> + remove_plugin_by_guid ( engine_id , plugin . guid ( ) ) <nl> <nl> <nl> - def remove_plugin_by_guid ( engine_version , guid ) : <nl> + def remove_plugin_by_guid ( engine_id , guid ) : <nl> " " " <nl> Removes the plugin from the registered engine . <nl> " " " <nl> engine_registry = cryregistry . load_engines ( ) <nl> <nl> - engine = engine_registry [ engine_version ] <nl> + engine = engine_registry [ engine_id ] <nl> plugins = engine . get ( ' plugins ' , { } ) <nl> <nl> del plugins [ guid ] <nl> def cmd_remove_plugins ( args ) : <nl> " " " <nl> Removes the plugins from the registered engine . <nl> " " " <nl> - sys . exit ( remove_plugins ( args . engine_version , args . plugin_files ) ) <nl> + sys . exit ( remove_plugins ( args . engine_id , args . plugin_files ) ) <nl> <nl> <nl> def cmd_remove_plugin_gui ( args ) : <nl> def cmd_switch ( args ) : <nl> error_project_json_decode ( args ) <nl> <nl> # If the engine version is already specified than set it and return early . <nl> - if args . engine_version is not None : <nl> - sys . exit ( switch_engine ( args . project_file , <nl> - args . engine_version , args . silent ) ) <nl> + if args . engine_id is not None : <nl> + sys . exit ( switch_engine ( args . project_file , args . engine_id , args . silent ) ) <nl> <nl> engine_list = [ ] <nl> engine_version = [ ] <nl> def cmd_upgrade ( args ) : <nl> Upgrades the project by calling it ' s engines cryrun . exe . <nl> " " " <nl> registry = cryregistry . load_engines ( ) <nl> - engine_path = cryregistry . engine_path ( registry , args . engine_version ) <nl> + engine_path = cryregistry . engine_path ( registry , args . engine_id ) <nl> if engine_path is None : <nl> - error_engine_path_not_found ( args , args . engine_version ) <nl> + error_engine_path_not_found ( args , args . engine_id ) <nl> <nl> if getattr ( sys , ' frozen ' , False ) : <nl> subcmd = [ <nl> def main ( ) : <nl> parser_add . set_defaults ( func = cmd_add ) <nl> <nl> parser_add_plugins = subparsers . add_parser ( ' add_plugins ' ) <nl> - parser_add_plugins . add_argument ( ' engine_version ' ) <nl> + parser_add_plugins . add_argument ( ' engine_id ' ) <nl> parser_add_plugins . add_argument ( ' plugin_files ' , nargs = ' + ' ) <nl> parser_add_plugins . set_defaults ( func = cmd_add_plugins ) <nl> <nl> def main ( ) : <nl> parser_remove . set_defaults ( func = cmd_remove ) <nl> <nl> parser_remove_plugins = subparsers . add_parser ( ' remove_plugins ' ) <nl> - parser_remove_plugins . add_argument ( ' engine_version ' ) <nl> + parser_remove_plugins . add_argument ( ' engine_id ' ) <nl> parser_remove_plugins . add_argument ( ' plugin_files ' , nargs = ' + ' ) <nl> parser_remove_plugins . set_defaults ( func = cmd_remove_plugins ) <nl> <nl> def main ( ) : <nl> <nl> parser_switch = subparsers . add_parser ( ' switch ' ) <nl> parser_switch . add_argument ( ' project_file ' ) <nl> - parser_switch . add_argument ( ' engine_version ' , nargs = ' ? ' ) <nl> + parser_switch . add_argument ( ' engine_id ' , nargs = ' ? ' ) <nl> parser_switch . set_defaults ( func = cmd_switch ) <nl> <nl> parser_backup = subparsers . add_parser ( ' backup ' ) <nl> def main ( ) : <nl> # mmm <nl> <nl> parser_upgrade = subparsers . add_parser ( ' upgrade ' ) <nl> - parser_upgrade . add_argument ( ' - - engine_version ' , default = ' ' ) <nl> + parser_upgrade . add_argument ( ' - - engine_id ' , default = ' ' ) <nl> parser_upgrade . add_argument ( ' project_file ' ) <nl> parser_upgrade . set_defaults ( func = cmd_upgrade ) <nl> <nl> mmm a / Tools / CryVersionSelector / release_project . py <nl> ppp b / Tools / CryVersionSelector / release_project . py <nl> <nl> " linux_x64_gcc : Release " : " Linux " , <nl> } <nl> <nl> + CONFIGURATION_BUILD_TARGET_LOOKUP = { <nl> + " win_x64 : Profile " : " win_x64 " , <nl> + " win_x64 : Release " : " win_x64 " , <nl> + " win_x86 : Profile " : " win_x86 " , <nl> + " win_x86 : Release " : " win_x86 " , <nl> + " linux_x64_clang : Profile " : " win_x64 " , <nl> + " linux_x64_clang : Release " : " win_x64 " , <nl> + " linux_x64_gcc : Profile " : " win_x64 " , <nl> + " linux_x64_gcc : Release " : " win_x64 " , <nl> + } <nl> + <nl> # " \ \ \ \ ? \ \ " is added to make sure copying doesn ' t crash on Windows <nl> # because the path gets too long for some files . <nl> # This is a requirement to copy the Mono folder on Windows . <nl> def run ( project_file ) : <nl> config_type = configuration [ 1 ] <nl> bin_path = os . path . normpath ( configuration [ 2 ] ) <nl> include_symbols = configuration [ 3 ] <nl> + bit_type = CONFIGURATION_BUILD_TARGET_LOOKUP [ config_type ] <nl> <nl> print ( " Packaging project { } " . format ( project . name ( ) ) ) <nl> print ( " Configuration : { } " . format ( config_type ) ) <nl> def run ( project_file ) : <nl> project_path , export_path , bin_path , config_type , include_symbols ) ) <nl> task_list . append ( ( <nl> " Copying shared libraries . . . " , copy_libs , <nl> - project , project_path , export_path , include_symbols ) ) <nl> + project , project_path , export_path , bin_path , bit_type , include_symbols ) ) <nl> task_list . append ( ( <nl> " Copying existing game asset packages . . . " , <nl> copy_assets , project , project_path_long , export_path_long ) ) <nl> def copy_project_plugins ( <nl> shutil . copyfile ( src_file , dst_file ) <nl> else : <nl> print ( " Failed to copy plugin file ' { } ' from { } ! " . format ( <nl> - path , src_file ) ) <nl> + path , src_file ) ) <nl> <nl> # Also copy the assembly generated from C # assets <nl> asset_assembly = os . path . join ( " bin " , " CRYENGINE . CSharp . dll " ) <nl> def copy_project_plugins ( <nl> shutil . copyfile ( src_file , dst_file ) <nl> <nl> <nl> - def copy_libs ( project , project_path , export_path , include_symbols ) : <nl> + def copy_libs ( project , project_path , export_path , bin_path , config , include_symbols ) : <nl> " " " <nl> Searches the bin folder for files that fit the name of the shared libs , <nl> and copies them to the export directory . <nl> def copy_libs ( project , project_path , export_path , include_symbols ) : <nl> if not libs : <nl> return <nl> <nl> - bin_dir = os . path . join ( project_path , " bin " ) <nl> - if not os . path . isdir ( bin_dir ) : <nl> + src_path = os . path . join ( project_path , bin_path ) <nl> + if not os . path . isdir ( src_path ) : <nl> return <nl> <nl> - export_bin = os . path . join ( export_path , " bin " ) <nl> + dst_path = os . path . join ( export_path , bin_path ) <nl> <nl> exclude = [ " * . mdb " , " * . xml " , " * . ilk " ] <nl> if not include_symbols : <nl> def copy_libs ( project , project_path , export_path , include_symbols ) : <nl> continue <nl> <nl> any_config = shared . get ( " any " , None ) <nl> - win86 = shared . get ( " win_x86 " , None ) <nl> - win64 = shared . get ( " win_x64 " , None ) <nl> + specific_config = shared . get ( config , None ) <nl> + if specific_config = = any_config : <nl> + specific_config = None <nl> <nl> if any_config : <nl> include = [ " { } * " . format ( any_config ) ] <nl> - copy_directory_contents ( bin_dir , export_bin , include , exclude ) <nl> + copy_directory_contents ( src_path , dst_path , include , exclude ) <nl> <nl> - if win86 : <nl> - include = [ " { } * " . format ( win86 ) ] <nl> - copy_directory_contents ( <nl> - os . path . join ( bin_dir , " win_x86 " ) , <nl> - os . path . join ( export_bin , " win_x86 " ) , include , exclude ) <nl> - <nl> - if win64 : <nl> - include = [ " { } * " . format ( win64 ) ] <nl> - copy_directory_contents ( <nl> - os . path . join ( bin_dir , " win_x64 " ) , <nl> - os . path . join ( export_bin , " win_x64 " ) , include , exclude ) <nl> + if specific_config : <nl> + include = [ " { } * " . format ( specific_config ) ] <nl> + copy_directory_contents ( src_path , dst_path , include , exclude ) <nl> | ! I integrate from / / ce / main . . . | CRYTEK/CRYENGINE | a21bef780b8dd7ae456d7306f0fdb6830e57abdd | 2018-08-17T13:02:12Z |
mmm a / js / apps / system / aardvark / frontend / js / views / dashboardView . js <nl> ppp b / js / apps / system / aardvark / frontend / js / views / dashboardView . js <nl> var dashboardView = Backbone . View . extend ( { <nl> updateFrequency : 5 , / / the actual update rate ( 5 s ) <nl> updateFrequencyR : 5 , / / the actual update rate ( 5 s ) REPLICATION <nl> updateCounter : 0 , <nl> + updateCounterR : 0 , <nl> arraySize : 20 , / / how many values will we keep per figure ? <nl> seriesData : { } , <nl> charts : { } , <nl> var dashboardView = Backbone . View . extend ( { <nl> <nl> window . setInterval ( function ( ) { <nl> self . updateCounter + + ; <nl> + self . updateCounterR + + ; <nl> <nl> if ( self . updateNOW = = = true ) { <nl> self . calculateSeries ( ) ; <nl> var dashboardView = Backbone . View . extend ( { <nl> self . updateNOW = false ; <nl> } <nl> <nl> - if ( self . updateCounter < self . updateFrequency ) { <nl> - return false ; <nl> + if ( window . location . hash = = = ' ' & & self . updateCounterR > self . updateFrequencyR ) { <nl> + console . log ( self . updateCounter ) ; <nl> + console . log ( self . updateFrequencyR ) ; <nl> + self . getReplicationStatus ( ) ; <nl> + self . updateCounterR = 0 ; <nl> } <nl> <nl> - / / need other solution here - > split repl & graph update interval <nl> - if ( window . location . hash = = = ' ' & & self . updateCounter > = self . updateFrequencyR ) { <nl> - self . getReplicationStatus ( ) ; <nl> + if ( self . updateCounter < self . updateFrequency ) { <nl> + return false ; <nl> } <nl> <nl> self . updateCounter = 0 ; <nl> var dashboardView = Backbone . View . extend ( { <nl> this . renderCharts ( ) ; <nl> } , <nl> checkIntervalR : function ( a ) { <nl> - this . updateFrequencyR = a . target . value ; <nl> - self . getReplicationStatus ( ) ; <nl> - console . log ( " asd " ) ; <nl> + if ( a . target . value ) { <nl> + this . updateFrequencyR = a . target . value ; <nl> + this . getReplicationStatus ( ) ; <nl> + } <nl> } , <nl> <nl> checkEnabled : function ( a ) { <nl> var dashboardView = Backbone . View . extend ( { <nl> renderCharts : function ( ) { <nl> var self = this ; <nl> $ ( ' # every ' + self . updateFrequency + ' seconds ' ) . prop ( ' checked ' , true ) ; <nl> - $ ( ' # every ' + self . updateFrequency + ' secondsR ' ) . prop ( ' checked ' , true ) ; <nl> + $ ( ' # every ' + self . updateFrequencyR + ' secondsR ' ) . prop ( ' checked ' , true ) ; <nl> <nl> $ . each ( self . options . description . models [ 0 ] . attributes . figures , function ( ) { <nl> var figure = this ; <nl> | single update interval for graphs and replication | arangodb/arangodb | 73052275e5c9f280f092fa8155dc8ae0735f2b99 | 2013-10-25T12:55:30Z |
mmm a / include / mlir / IR / Function . h <nl> ppp b / include / mlir / IR / Function . h <nl> <nl> # define MLIR_IR_FUNCTION_H <nl> <nl> # include " mlir / IR / Block . h " <nl> + # include " mlir / IR / FunctionSupport . h " <nl> # include " mlir / IR / OpDefinition . h " <nl> - # include " llvm / ADT / SmallString . h " <nl> <nl> namespace mlir { <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - = = = / / <nl> namespace mlir { <nl> / / / Function arguments or attributes that establish a symbolic connection ( e . g . <nl> / / / symbols referenced by name via a string attribute ) . <nl> class FuncOp : public Op < FuncOp , OpTrait : : ZeroOperands , OpTrait : : ZeroResult , <nl> - OpTrait : : IsIsolatedFromAbove > { <nl> + OpTrait : : IsIsolatedFromAbove , OpTrait : : FunctionLike > { <nl> public : <nl> using Op : : Op ; <nl> using Op : : print ; <nl> class FuncOp : public Op < FuncOp , OpTrait : : ZeroOperands , OpTrait : : ZeroResult , <nl> void print ( OpAsmPrinter * p ) ; <nl> LogicalResult verify ( ) ; <nl> <nl> - / / / Returns the name of this function . <nl> - StringRef getName ( ) ; <nl> - <nl> - / / / Set the name of this function . <nl> - void setName ( StringRef name ) ; <nl> - <nl> / / / Returns the type of this function . <nl> FunctionType getType ( ) { <nl> - return getAttrOfType < TypeAttr > ( " type " ) . getValue ( ) . cast < FunctionType > ( ) ; <nl> + return getAttrOfType < TypeAttr > ( getTypeAttrName ( ) ) <nl> + . getValue ( ) <nl> + . cast < FunctionType > ( ) ; <nl> } <nl> <nl> / / / Change the type of this function in place . This is an extremely dangerous <nl> class FuncOp : public Op < FuncOp , OpTrait : : ZeroOperands , OpTrait : : ZeroResult , <nl> / / / parameters we drop the extra attributes , if there are more parameters <nl> / / / they won ' t have any attributes . <nl> void setType ( FunctionType newType ) { <nl> - setAttr ( " type " , TypeAttr : : get ( newType ) ) ; <nl> + setAttr ( getTypeAttrName ( ) , TypeAttr : : get ( newType ) ) ; <nl> } <nl> <nl> - / / / Returns true if this function is external , i . e . it has no body . <nl> - bool isExternal ( ) { return empty ( ) ; } <nl> - <nl> / / / Create a deep copy of this function and all of its blocks , remapping <nl> / / / any operands that use values outside of the function using the map that is <nl> / / / provided ( leaving them alone if no entry is present ) . If the mapper <nl> class FuncOp : public Op < FuncOp , OpTrait : : ZeroOperands , OpTrait : : ZeroResult , <nl> / / Body Handling <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - = = = / / <nl> <nl> - Region & getBody ( ) { return getOperation ( ) - > getRegion ( 0 ) ; } <nl> - <nl> - / / / Delete all blocks from this function . <nl> - void eraseBody ( ) ; <nl> - <nl> - / / / This is the list of blocks in the function . <nl> - using RegionType = Region : : RegionType ; <nl> - RegionType & getBlocks ( ) { return getBody ( ) . getBlocks ( ) ; } <nl> - <nl> - / / Iteration over the block in the function . <nl> - using iterator = RegionType : : iterator ; <nl> - using reverse_iterator = RegionType : : reverse_iterator ; <nl> - <nl> - iterator begin ( ) { return getBody ( ) . begin ( ) ; } <nl> - iterator end ( ) { return getBody ( ) . end ( ) ; } <nl> - reverse_iterator rbegin ( ) { return getBody ( ) . rbegin ( ) ; } <nl> - reverse_iterator rend ( ) { return getBody ( ) . rend ( ) ; } <nl> - <nl> - bool empty ( ) { return getBody ( ) . empty ( ) ; } <nl> - void push_back ( Block * block ) { getBody ( ) . push_back ( block ) ; } <nl> - void push_front ( Block * block ) { getBody ( ) . push_front ( block ) ; } <nl> - <nl> - Block & back ( ) { return getBody ( ) . back ( ) ; } <nl> - Block & front ( ) { return getBody ( ) . front ( ) ; } <nl> - <nl> / / / Add an entry block to an empty function , and set up the block arguments <nl> / / / to match the signature of the function . <nl> void addEntryBlock ( ) ; <nl> <nl> - / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - = = = / / <nl> - / / Argument Handling <nl> - / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - = = = / / <nl> - <nl> - / / / Returns number of arguments . <nl> - unsigned getNumArguments ( ) { return getType ( ) . getInputs ( ) . size ( ) ; } <nl> - <nl> - / / / Gets argument . <nl> - BlockArgument * getArgument ( unsigned idx ) { <nl> - return getBlocks ( ) . front ( ) . getArgument ( idx ) ; <nl> - } <nl> - <nl> - / / Supports non - const operand iteration . <nl> - using args_iterator = Block : : args_iterator ; <nl> - args_iterator args_begin ( ) { return front ( ) . args_begin ( ) ; } <nl> - args_iterator args_end ( ) { return front ( ) . args_end ( ) ; } <nl> - llvm : : iterator_range < args_iterator > getArguments ( ) { <nl> - return { args_begin ( ) , args_end ( ) } ; <nl> - } <nl> - <nl> - / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - = = = / / <nl> - / / Argument Attributes <nl> - / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - = = = / / <nl> - <nl> - / / / FuncOp allows for attaching attributes to each of the respective function <nl> - / / / arguments . These argument attributes are stored as DictionaryAttrs in the <nl> - / / / main operation attribute dictionary . The name of these entries is ` arg ` <nl> - / / / followed by the index of the argument . These argument attribute <nl> - / / / dictionaries are optional , and will generally only exist if they are <nl> - / / / non - empty . <nl> - <nl> - / / / Return all of the attributes for the argument at ' index ' . <nl> - ArrayRef < NamedAttribute > getArgAttrs ( unsigned index ) { <nl> - auto argDict = getArgAttrDict ( index ) ; <nl> - return argDict ? argDict . getValue ( ) : llvm : : None ; <nl> - } <nl> - <nl> - / / / Return all argument attributes of this function . <nl> - void getAllArgAttrs ( SmallVectorImpl < NamedAttributeList > & result ) { <nl> - for ( unsigned i = 0 , e = getNumArguments ( ) ; i ! = e ; + + i ) <nl> - result . emplace_back ( getArgAttrDict ( i ) ) ; <nl> - } <nl> - <nl> - / / / Return the specified attribute , if present , for the argument at ' index ' , <nl> - / / / null otherwise . <nl> - Attribute getArgAttr ( unsigned index , Identifier name ) { <nl> - auto argDict = getArgAttrDict ( index ) ; <nl> - return argDict ? argDict . get ( name ) : nullptr ; <nl> - } <nl> - Attribute getArgAttr ( unsigned index , StringRef name ) { <nl> - auto argDict = getArgAttrDict ( index ) ; <nl> - return argDict ? argDict . get ( name ) : nullptr ; <nl> - } <nl> - <nl> - template < typename AttrClass > <nl> - AttrClass getArgAttrOfType ( unsigned index , Identifier name ) { <nl> - return getArgAttr ( index , name ) . dyn_cast_or_null < AttrClass > ( ) ; <nl> - } <nl> - template < typename AttrClass > <nl> - AttrClass getArgAttrOfType ( unsigned index , StringRef name ) { <nl> - return getArgAttr ( index , name ) . dyn_cast_or_null < AttrClass > ( ) ; <nl> - } <nl> - <nl> - / / / Set the attributes held by the argument at ' index ' . <nl> - void setArgAttrs ( unsigned index , ArrayRef < NamedAttribute > attributes ) ; <nl> - void setArgAttrs ( unsigned index , NamedAttributeList attributes ) ; <nl> - void setAllArgAttrs ( ArrayRef < NamedAttributeList > attributes ) { <nl> - assert ( attributes . size ( ) = = getNumArguments ( ) ) ; <nl> - for ( unsigned i = 0 , e = attributes . size ( ) ; i ! = e ; + + i ) <nl> - setArgAttrs ( i , attributes [ i ] ) ; <nl> - } <nl> - <nl> - / / / If the an attribute exists with the specified name , change it to the new <nl> - / / / value . Otherwise , add a new attribute with the specified name / value . <nl> - void setArgAttr ( unsigned index , Identifier name , Attribute value ) ; <nl> - void setArgAttr ( unsigned index , StringRef name , Attribute value ) { <nl> - setArgAttr ( index , Identifier : : get ( name , getContext ( ) ) , value ) ; <nl> - } <nl> - <nl> - / / / Remove the attribute ' name ' from the argument at ' index ' . <nl> - NamedAttributeList : : RemoveResult removeArgAttr ( unsigned index , <nl> - Identifier name ) ; <nl> - <nl> private : <nl> - / / / Returns the attribute entry name for the set of argument attributes at <nl> - / / / index ' arg ' . <nl> - static StringRef getArgAttrName ( unsigned arg , SmallVectorImpl < char > & out ) ; <nl> - <nl> - / / / Returns the dictionary attribute corresponding to the argument at ' index ' . <nl> - / / / If there are no argument attributes at ' index ' , a null attribute is <nl> - / / / returned . <nl> - DictionaryAttr getArgAttrDict ( unsigned index ) { <nl> - assert ( index < getNumArguments ( ) & & " invalid argument number " ) ; <nl> - SmallString < 8 > nameOut ; <nl> - return getAttrOfType < DictionaryAttr > ( getArgAttrName ( index , nameOut ) ) ; <nl> + / / This trait needs access to ` getNumFuncArguments ` and ` verifyType ` hooks <nl> + / / defined below . <nl> + friend class OpTrait : : FunctionLike < FuncOp > ; <nl> + <nl> + / / / Returns the number of arguments . This is a hook for OpTrait : : FunctionLike . <nl> + unsigned getNumFuncArguments ( ) { return getType ( ) . getInputs ( ) . size ( ) ; } <nl> + <nl> + / / / Hook for OpTrait : : FunctionLike , called after verifying that the ' type ' <nl> + / / / attribute is present and checks if it holds a function type . Ensures <nl> + / / / getType and getNumFuncArguments can be called safely . <nl> + LogicalResult verifyType ( ) { <nl> + auto type = getTypeAttr ( ) . getValue ( ) ; <nl> + if ( ! type . isa < FunctionType > ( ) ) <nl> + return emitOpError ( " requires ' " + getTypeAttrName ( ) + <nl> + " ' attribute of function type " ) ; <nl> + return success ( ) ; <nl> } <nl> } ; <nl> } / / end namespace mlir <nl> new file mode 100644 <nl> index 0000000000000 . . 953fc6cac6a96 <nl> mmm / dev / null <nl> ppp b / include / mlir / IR / FunctionSupport . h <nl> <nl> + / / = = = - FunctionSupport . h - Utility types for function - like ops - - * - C + + - * - = = = / / <nl> + / / <nl> + / / Copyright 2019 The MLIR Authors . <nl> + / / <nl> + / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / you may not use this file except in compliance with the License . <nl> + / / You may obtain a copy of the License at <nl> + / / <nl> + / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / <nl> + / / Unless required by applicable law or agreed to in writing , software <nl> + / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / See the License for the specific language governing permissions and <nl> + / / limitations under the License . <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + / / <nl> + / / This file defines support types for Operations that represent function - like <nl> + / / constructs to use . <nl> + / / <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + <nl> + # ifndef MLIR_IR_FUNCTIONSUPPORT_H <nl> + # define MLIR_IR_FUNCTIONSUPPORT_H <nl> + <nl> + # include " mlir / IR / OpDefinition . h " <nl> + # include " mlir / IR / SymbolTable . h " <nl> + # include " llvm / ADT / SmallString . h " <nl> + <nl> + namespace mlir { <nl> + namespace OpTrait { <nl> + <nl> + / / / This trait provides APIs for Ops that behave like functions . In particular : <nl> + / / / - Ops can be used with SymbolTable in the parent Op and have names ; <nl> + / / / - Ops have a single region with multiple blocks that corresponds to the body <nl> + / / / of the function ; <nl> + / / / - the absence of a region corresonds to an external function ; <nl> + / / / - arguments of the first block of the region are treated as function <nl> + / / / arguments ; <nl> + / / / - they can have argument attributes that are stored in a dictionary <nl> + / / / attribute on the Op itself . <nl> + / / / This trait does * NOT * provide type support for the functions , meaning that <nl> + / / / concrete Ops must handle the type of the declared or defined function . <nl> + / / / ` getTypeAttrName ( ) ` is a convenience function that returns the name of the <nl> + / / / attribute that can be used to store the function type , but the trait makes <nl> + / / / no assumption based on it . <nl> + / / / <nl> + / / / - Concrete ops * must * define a member function ` getNumFuncArguments ( ) ` that <nl> + / / / returns the number of function arguments based exclusively on type ( so that <nl> + / / / it can be called on function declarations ) . <nl> + / / / - To verify that the type respects op - specific invariants , concrete ops may <nl> + / / / redefine the ` verifyType ( ) ` hook that will be called after verifying the <nl> + / / / presence of the ` type ` attribute and before any call to <nl> + / / / ` getNumFuncArguments ` from the verifier . <nl> + template < typename ConcreteType > <nl> + class FunctionLike : public OpTrait : : TraitBase < ConcreteType , FunctionLike > { <nl> + public : <nl> + / / / Verify that all of the argument attributes are dialect attributes . <nl> + static LogicalResult verifyTrait ( Operation * op ) ; <nl> + <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - = = = / / <nl> + / / Name Handling . <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - = = = / / <nl> + <nl> + / / / Returns the name of this function . <nl> + StringRef getName ( ) { <nl> + return this - > getOperation ( ) <nl> + - > template getAttrOfType < StringAttr > ( <nl> + mlir : : SymbolTable : : getSymbolAttrName ( ) ) <nl> + . getValue ( ) ; <nl> + } <nl> + <nl> + / / / Set the name of this function . <nl> + void setName ( StringRef name ) { <nl> + this - > getOperation ( ) - > setAttr ( <nl> + mlir : : SymbolTable : : getSymbolAttrName ( ) , <nl> + StringAttr : : get ( name , this - > getOperation ( ) - > getContext ( ) ) ) ; <nl> + } <nl> + <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - = = = / / <nl> + / / Body Handling <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - = = = / / <nl> + <nl> + / / / Returns true if this function is external , i . e . it has no body . <nl> + bool isExternal ( ) { return empty ( ) ; } <nl> + <nl> + Region & getBody ( ) { return this - > getOperation ( ) - > getRegion ( 0 ) ; } <nl> + <nl> + / / / Delete all blocks from this function . <nl> + void eraseBody ( ) { <nl> + getBody ( ) . dropAllReferences ( ) ; <nl> + getBody ( ) . getBlocks ( ) . clear ( ) ; <nl> + } <nl> + <nl> + / / / This is the list of blocks in the function . <nl> + using RegionType = Region : : RegionType ; <nl> + RegionType & getBlocks ( ) { return getBody ( ) . getBlocks ( ) ; } <nl> + <nl> + / / Iteration over the block in the function . <nl> + using iterator = RegionType : : iterator ; <nl> + using reverse_iterator = RegionType : : reverse_iterator ; <nl> + <nl> + iterator begin ( ) { return getBody ( ) . begin ( ) ; } <nl> + iterator end ( ) { return getBody ( ) . end ( ) ; } <nl> + reverse_iterator rbegin ( ) { return getBody ( ) . rbegin ( ) ; } <nl> + reverse_iterator rend ( ) { return getBody ( ) . rend ( ) ; } <nl> + <nl> + bool empty ( ) { return getBody ( ) . empty ( ) ; } <nl> + void push_back ( Block * block ) { getBody ( ) . push_back ( block ) ; } <nl> + void push_front ( Block * block ) { getBody ( ) . push_front ( block ) ; } <nl> + <nl> + Block & back ( ) { return getBody ( ) . back ( ) ; } <nl> + Block & front ( ) { return getBody ( ) . front ( ) ; } <nl> + <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - = = = / / <nl> + / / Type Attribute Handling <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - = = = / / <nl> + <nl> + / / / Return the name of the attribute used for function types . <nl> + static StringRef getTypeAttrName ( ) { return " type " ; } <nl> + <nl> + TypeAttr getTypeAttr ( ) { <nl> + return this - > getOperation ( ) - > template getAttrOfType < TypeAttr > ( <nl> + getTypeAttrName ( ) ) ; <nl> + } <nl> + <nl> + bool isTypeAttrValid ( ) { <nl> + auto typeAttr = getTypeAttr ( ) ; <nl> + if ( ! typeAttr ) <nl> + return false ; <nl> + return typeAttr . getValue ( ) ! = Type { } ; <nl> + } <nl> + <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - = = = / / <nl> + / / Argument Handling <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - = = = / / <nl> + <nl> + unsigned getNumArguments ( ) { <nl> + return static_cast < ConcreteType * > ( this ) - > getNumFuncArguments ( ) ; <nl> + } <nl> + <nl> + / / / Gets argument . <nl> + BlockArgument * getArgument ( unsigned idx ) { <nl> + return getBlocks ( ) . front ( ) . getArgument ( idx ) ; <nl> + } <nl> + <nl> + / / Supports non - const operand iteration . <nl> + using args_iterator = Block : : args_iterator ; <nl> + args_iterator args_begin ( ) { return front ( ) . args_begin ( ) ; } <nl> + args_iterator args_end ( ) { return front ( ) . args_end ( ) ; } <nl> + llvm : : iterator_range < args_iterator > getArguments ( ) { <nl> + return { args_begin ( ) , args_end ( ) } ; <nl> + } <nl> + <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - = = = / / <nl> + / / Argument Attributes <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - = = = / / <nl> + <nl> + / / / FunctionLike operations allow for attaching attributes to each of the <nl> + / / / respective function arguments . These argument attributes are stored as <nl> + / / / DictionaryAttrs in the main operation attribute dictionary . The name of <nl> + / / / these entries is ` arg ` followed by the index of the argument . These <nl> + / / / argument attribute dictionaries are optional , and will generally only <nl> + / / / exist if they are non - empty . <nl> + <nl> + / / / Return all of the attributes for the argument at ' index ' . <nl> + ArrayRef < NamedAttribute > getArgAttrs ( unsigned index ) { <nl> + auto argDict = getArgAttrDict ( index ) ; <nl> + return argDict ? argDict . getValue ( ) : llvm : : None ; <nl> + } <nl> + <nl> + / / / Return all argument attributes of this function . <nl> + void getAllArgAttrs ( SmallVectorImpl < NamedAttributeList > & result ) { <nl> + for ( unsigned i = 0 , e = getNumArguments ( ) ; i ! = e ; + + i ) <nl> + result . emplace_back ( getArgAttrDict ( i ) ) ; <nl> + } <nl> + <nl> + / / / Return the specified attribute , if present , for the argument at ' index ' , <nl> + / / / null otherwise . <nl> + Attribute getArgAttr ( unsigned index , Identifier name ) { <nl> + auto argDict = getArgAttrDict ( index ) ; <nl> + return argDict ? argDict . get ( name ) : nullptr ; <nl> + } <nl> + Attribute getArgAttr ( unsigned index , StringRef name ) { <nl> + auto argDict = getArgAttrDict ( index ) ; <nl> + return argDict ? argDict . get ( name ) : nullptr ; <nl> + } <nl> + <nl> + template < typename AttrClass > <nl> + AttrClass getArgAttrOfType ( unsigned index , Identifier name ) { <nl> + return getArgAttr ( index , name ) . template dyn_cast_or_null < AttrClass > ( ) ; <nl> + } <nl> + template < typename AttrClass > <nl> + AttrClass getArgAttrOfType ( unsigned index , StringRef name ) { <nl> + return getArgAttr ( index , name ) . template dyn_cast_or_null < AttrClass > ( ) ; <nl> + } <nl> + <nl> + / / / Set the attributes held by the argument at ' index ' . <nl> + void setArgAttrs ( unsigned index , ArrayRef < NamedAttribute > attributes ) ; <nl> + void setArgAttrs ( unsigned index , NamedAttributeList attributes ) ; <nl> + void setAllArgAttrs ( ArrayRef < NamedAttributeList > attributes ) { <nl> + assert ( attributes . size ( ) = = getNumArguments ( ) ) ; <nl> + for ( unsigned i = 0 , e = attributes . size ( ) ; i ! = e ; + + i ) <nl> + setArgAttrs ( i , attributes [ i ] ) ; <nl> + } <nl> + <nl> + / / / If the an attribute exists with the specified name , change it to the new <nl> + / / / value . Otherwise , add a new attribute with the specified name / value . <nl> + void setArgAttr ( unsigned index , Identifier name , Attribute value ) ; <nl> + void setArgAttr ( unsigned index , StringRef name , Attribute value ) { <nl> + setArgAttr ( index , Identifier : : get ( name , this - > getOperation ( ) - > getContext ( ) ) , <nl> + value ) ; <nl> + } <nl> + <nl> + / / / Remove the attribute ' name ' from the argument at ' index ' . <nl> + NamedAttributeList : : RemoveResult removeArgAttr ( unsigned index , <nl> + Identifier name ) ; <nl> + <nl> + protected : <nl> + / / / Returns the attribute entry name for the set of argument attributes at <nl> + / / / index ' arg ' . <nl> + static StringRef getArgAttrName ( unsigned arg , SmallVectorImpl < char > & out ) ; <nl> + <nl> + / / / Returns the dictionary attribute corresponding to the argument at ' index ' . <nl> + / / / If there are no argument attributes at ' index ' , a null attribute is <nl> + / / / returned . <nl> + DictionaryAttr getArgAttrDict ( unsigned index ) { <nl> + assert ( index < getNumArguments ( ) & & " invalid argument number " ) ; <nl> + SmallString < 8 > nameOut ; <nl> + return this - > getOperation ( ) - > template getAttrOfType < DictionaryAttr > ( <nl> + getArgAttrName ( index , nameOut ) ) ; <nl> + } <nl> + <nl> + / / / Hook for concrete classes to verify that the type attribute respects <nl> + / / / op - specific invariants . Default implementation always succeeds . <nl> + LogicalResult verifyType ( ) { return success ( ) ; } <nl> + } ; <nl> + <nl> + template < typename ConcreteType > <nl> + LogicalResult FunctionLike < ConcreteType > : : verifyTrait ( Operation * op ) { <nl> + MLIRContext * ctx = op - > getContext ( ) ; <nl> + auto funcOp = cast < ConcreteType > ( op ) ; <nl> + <nl> + if ( ! funcOp . isTypeAttrValid ( ) ) <nl> + return funcOp . emitOpError ( " requires a type attribute ' " ) <nl> + < < getTypeAttrName ( ) < < ' \ ' ' ; <nl> + <nl> + if ( failed ( funcOp . verifyType ( ) ) ) <nl> + return failure ( ) ; <nl> + <nl> + for ( unsigned i = 0 , e = funcOp . getNumArguments ( ) ; i ! = e ; + + i ) { <nl> + / / Verify that all of the argument attributes are dialect attributes , i . e . <nl> + / / that they contain a dialect prefix in their name . Call the dialect , if <nl> + / / registered , to verify the attributes themselves . <nl> + for ( auto attr : funcOp . getArgAttrs ( i ) ) { <nl> + if ( ! attr . first . strref ( ) . contains ( ' . ' ) ) <nl> + return funcOp . emitOpError ( " arguments may only have dialect attributes " ) ; <nl> + auto dialectNamePair = attr . first . strref ( ) . split ( ' . ' ) ; <nl> + if ( auto * dialect = ctx - > getRegisteredDialect ( dialectNamePair . first ) ) { <nl> + if ( failed ( dialect - > verifyRegionArgAttribute ( op , / * regionIndex = * / 0 , <nl> + / * argIndex = * / i , attr ) ) ) <nl> + return failure ( ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + / / Check that the op has exactly one region for the body . <nl> + if ( op - > getNumRegions ( ) ! = 1 ) <nl> + return funcOp . emitOpError ( " expects one region " ) ; <nl> + <nl> + / / Check that if the entry block exists , it has the same number of arguments <nl> + / / as the function - like operation . <nl> + if ( funcOp . isExternal ( ) ) <nl> + return success ( ) ; <nl> + <nl> + unsigned numArguments = funcOp . getNumArguments ( ) ; <nl> + if ( funcOp . front ( ) . getNumArguments ( ) ! = numArguments ) <nl> + return funcOp . emitOpError ( " entry block must have " ) <nl> + < < numArguments < < " arguments to match function signature " ; <nl> + <nl> + return success ( ) ; <nl> + } <nl> + <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + / / Function Argument Attribute . <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + <nl> + / / / Set the attributes held by the argument at ' index ' . <nl> + template < typename ConcreteType > <nl> + void FunctionLike < ConcreteType > : : setArgAttrs ( <nl> + unsigned index , ArrayRef < NamedAttribute > attributes ) { <nl> + assert ( index < getNumArguments ( ) & & " invalid argument number " ) ; <nl> + SmallString < 8 > nameOut ; <nl> + getArgAttrName ( index , nameOut ) ; <nl> + Operation * op = this - > getOperation ( ) ; <nl> + <nl> + if ( attributes . empty ( ) ) <nl> + return ( void ) static_cast < ConcreteType * > ( this ) - > removeAttr ( nameOut ) ; <nl> + op - > setAttr ( nameOut , DictionaryAttr : : get ( attributes , op - > getContext ( ) ) ) ; <nl> + } <nl> + <nl> + template < typename ConcreteType > <nl> + void FunctionLike < ConcreteType > : : setArgAttrs ( unsigned index , <nl> + NamedAttributeList attributes ) { <nl> + assert ( index < getNumArguments ( ) & & " invalid argument number " ) ; <nl> + SmallString < 8 > nameOut ; <nl> + if ( auto newAttr = attributes . getDictionary ( ) ) <nl> + return this - > getOperation ( ) - > setAttr ( getArgAttrName ( index , nameOut ) , <nl> + newAttr ) ; <nl> + static_cast < ConcreteType * > ( this ) - > removeAttr ( getArgAttrName ( index , nameOut ) ) ; <nl> + } <nl> + <nl> + / / / If the an attribute exists with the specified name , change it to the new <nl> + / / / value . Otherwise , add a new attribute with the specified name / value . <nl> + template < typename ConcreteType > <nl> + void FunctionLike < ConcreteType > : : setArgAttr ( unsigned index , Identifier name , <nl> + Attribute value ) { <nl> + auto curAttr = getArgAttrDict ( index ) ; <nl> + NamedAttributeList attrList ( curAttr ) ; <nl> + attrList . set ( name , value ) ; <nl> + <nl> + / / If the attribute changed , then set the new arg attribute list . <nl> + if ( curAttr ! = attrList . getDictionary ( ) ) <nl> + setArgAttrs ( index , attrList ) ; <nl> + } <nl> + <nl> + / / / Remove the attribute ' name ' from the argument at ' index ' . <nl> + template < typename ConcreteType > <nl> + NamedAttributeList : : RemoveResult <nl> + FunctionLike < ConcreteType > : : removeArgAttr ( unsigned index , Identifier name ) { <nl> + / / Build an attribute list and remove the attribute at ' name ' . <nl> + NamedAttributeList attrList ( getArgAttrDict ( index ) ) ; <nl> + auto result = attrList . remove ( name ) ; <nl> + <nl> + / / If the attribute was removed , then update the argument dictionary . <nl> + if ( result = = NamedAttributeList : : RemoveResult : : Removed ) <nl> + setArgAttrs ( index , attrList ) ; <nl> + return result ; <nl> + } <nl> + <nl> + / / / Returns the attribute entry name for the set of argument attributes at index <nl> + / / / ' arg ' . <nl> + template < typename ConcreteType > <nl> + StringRef <nl> + FunctionLike < ConcreteType > : : getArgAttrName ( unsigned arg , <nl> + SmallVectorImpl < char > & out ) { <nl> + out . clear ( ) ; <nl> + return ( " arg " + Twine ( arg ) ) . toStringRef ( out ) ; <nl> + } <nl> + <nl> + } / / end namespace OpTrait <nl> + <nl> + } / / end namespace mlir <nl> + <nl> + # endif / / MLIR_IR_FUNCTIONSUPPORT_H <nl> mmm a / include / mlir / LLVMIR / LLVMOps . td <nl> ppp b / include / mlir / LLVMIR / LLVMOps . td <nl> def LLVM_ReturnOp : LLVM_TerminatorOp < " return " , [ ] > { <nl> <nl> / / Pseudo - operations ( do not appear in LLVM IR but necessary for the dialect to <nl> / / work correctly ) . <nl> + def LLVM_LLVMFuncOp : LLVM_ZeroResultOp < " func " , <nl> + [ NativeOpTrait < " IsIsolatedFromAbove " > , NativeOpTrait < " FunctionLike " > ] > { <nl> + let summary = " LLVM dialect function , has wrapped LLVM IR function type " ; <nl> + <nl> + let regions = ( region AnyRegion : $ body ) ; <nl> + <nl> + let skipDefaultBuilders = 1 ; <nl> + <nl> + let builders = [ <nl> + OpBuilder < " Builder * builder , OperationState * result , StringRef name , " <nl> + " LLVMType type , ArrayRef < NamedAttribute > attrs , " <nl> + " ArrayRef < NamedAttributeList > argAttrs = { } " > <nl> + ] ; <nl> + <nl> + let extraClassDeclaration = [ { <nl> + LLVMType getType ( ) { <nl> + return getAttrOfType < TypeAttr > ( getTypeAttrName ( ) ) <nl> + . getValue ( ) . cast < LLVMType > ( ) ; <nl> + } <nl> + bool isVarArg ( ) { <nl> + return getType ( ) . getUnderlyingType ( ) - > isFunctionVarArg ( ) ; <nl> + } <nl> + <nl> + / / Hook for OpTrait : : FunctionLike , returns the number of function arguments . <nl> + / / Depends on the type attribute being correct as checked by verifyType . <nl> + unsigned getNumFuncArguments ( ) ; <nl> + <nl> + / / Hook for OpTrait : : FunctionLike , called after verifying that the ' type ' <nl> + / / attribute is present . This can check for preconditions of the <nl> + / / getNumArguments hook not failing . <nl> + LogicalResult verifyType ( ) ; <nl> + } ] ; <nl> + <nl> + let verifier = [ { return : : verify ( * this ) ; } ] ; <nl> + } <nl> + <nl> def LLVM_UndefOp : LLVM_OneResultOp < " undef " , [ NoSideEffect ] > , <nl> LLVM_Builder < " $ res = llvm : : UndefValue : : get ( $ _resultType ) ; " > { <nl> let parser = [ { return parseUndefOp ( parser , result ) ; } ] ; <nl> mmm a / lib / IR / Function . cpp <nl> ppp b / lib / IR / Function . cpp <nl> void FuncOp : : build ( Builder * builder , OperationState * result , StringRef name , <nl> FunctionType type , ArrayRef < NamedAttribute > attrs ) { <nl> result - > addAttribute ( SymbolTable : : getSymbolAttrName ( ) , <nl> builder - > getStringAttr ( name ) ) ; <nl> - result - > addAttribute ( " type " , builder - > getTypeAttr ( type ) ) ; <nl> + result - > addAttribute ( getTypeAttrName ( ) , builder - > getTypeAttr ( type ) ) ; <nl> result - > attributes . append ( attrs . begin ( ) , attrs . end ( ) ) ; <nl> result - > addRegion ( ) ; <nl> } <nl> ParseResult FuncOp : : parse ( OpAsmParser * parser , OperationState * result ) { <nl> / / Parse the function signature . <nl> if ( parseFunctionSignature ( parser , type , entryArgs , argAttrs ) ) <nl> return failure ( ) ; <nl> - result - > addAttribute ( " type " , builder . getTypeAttr ( type ) ) ; <nl> + result - > addAttribute ( getTypeAttrName ( ) , builder . getTypeAttr ( type ) ) ; <nl> <nl> / / If function attributes are present , parse them . <nl> if ( succeeded ( parser - > parseOptionalKeyword ( " attributes " ) ) ) <nl> void FuncOp : : print ( OpAsmPrinter * p ) { <nl> <nl> / / Print out function attributes , if present . <nl> SmallVector < StringRef , 2 > ignoredAttrs = { SymbolTable : : getSymbolAttrName ( ) , <nl> - " type " } ; <nl> + getTypeAttrName ( ) } ; <nl> <nl> / / Ignore any argument attributes . <nl> std : : vector < SmallString < 8 > > argAttrStorage ; <nl> void FuncOp : : print ( OpAsmPrinter * p ) { <nl> } <nl> <nl> LogicalResult FuncOp : : verify ( ) { <nl> - auto fnInputTypes = getType ( ) . getInputs ( ) ; <nl> - auto * ctx = getContext ( ) ; <nl> - <nl> - / / / Verify that all of the argument attributes are dialect attributes . <nl> - for ( unsigned i = 0 , e = fnInputTypes . size ( ) ; i ! = e ; + + i ) { <nl> - for ( auto attr : getArgAttrs ( i ) ) { <nl> - if ( ! attr . first . strref ( ) . contains ( ' . ' ) ) <nl> - return emitOpError ( " arguments may only have dialect attributes " ) ; <nl> - auto dialectNamePair = attr . first . strref ( ) . split ( ' . ' ) ; <nl> - if ( auto * dialect = ctx - > getRegisteredDialect ( dialectNamePair . first ) ) { <nl> - if ( failed ( dialect - > verifyRegionArgAttribute ( * this , / * regionIndex = * / 0 , <nl> - / * argIndex = * / i , attr ) ) ) <nl> - return failure ( ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> / / If this function is external there is nothing to do . <nl> if ( isExternal ( ) ) <nl> return success ( ) ; <nl> <nl> / / Verify that the argument list of the function and the arg list of the entry <nl> - / / block line up . <nl> + / / block line up . The trait already verified that the number of arguments is <nl> + / / the same between the signature and the block . <nl> + auto fnInputTypes = getType ( ) . getInputs ( ) ; <nl> Block & entryBlock = front ( ) ; <nl> - if ( fnInputTypes . size ( ) ! = entryBlock . getNumArguments ( ) ) <nl> - return emitOpError ( " entry block must have " ) <nl> - < < fnInputTypes . size ( ) < < " arguments to match function signature " ; <nl> - <nl> for ( unsigned i = 0 , e = entryBlock . getNumArguments ( ) ; i ! = e ; + + i ) <nl> if ( fnInputTypes [ i ] ! = entryBlock . getArgument ( i ) - > getType ( ) ) <nl> return emitOpError ( " type of entry block argument # " ) <nl> LogicalResult FuncOp : : verify ( ) { <nl> return success ( ) ; <nl> } <nl> <nl> - / / / Returns the name of this function . <nl> - StringRef FuncOp : : getName ( ) { <nl> - return getAttrOfType < StringAttr > ( SymbolTable : : getSymbolAttrName ( ) ) . getValue ( ) ; <nl> - } <nl> - <nl> - / / / Set the name of this function . <nl> - void FuncOp : : setName ( StringRef name ) { <nl> - return setAttr ( SymbolTable : : getSymbolAttrName ( ) , <nl> - StringAttr : : get ( name , getContext ( ) ) ) ; <nl> - } <nl> - <nl> / / / Add an entry block to an empty function , and set up the block arguments <nl> / / / to match the signature of the function . <nl> void FuncOp : : addEntryBlock ( ) { <nl> void FuncOp : : cloneInto ( FuncOp dest , BlockAndValueMapping & mapper ) { <nl> getBody ( ) . cloneInto ( & dest . getBody ( ) , mapper ) ; <nl> } <nl> <nl> - / / / Delete all blocks from this function . <nl> - void FuncOp : : eraseBody ( ) { <nl> - / / First , drop all references in the blocks because they may point to values <nl> - / / defined in the dominating blocks . <nl> - getBody ( ) . dropAllReferences ( ) ; <nl> - getBody ( ) . getBlocks ( ) . clear ( ) ; <nl> - } <nl> - <nl> / / / Create a deep copy of this function and all of its blocks , remapping <nl> / / / any operands that use values outside of the function using the map that is <nl> / / / provided ( leaving them alone if no entry is present ) . Replaces references <nl> FuncOp FuncOp : : clone ( ) { <nl> BlockAndValueMapping mapper ; <nl> return clone ( mapper ) ; <nl> } <nl> - <nl> - / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> - / / Function Argument Attribute . <nl> - / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> - <nl> - / / / Set the attributes held by the argument at ' index ' . <nl> - void FuncOp : : setArgAttrs ( unsigned index , ArrayRef < NamedAttribute > attributes ) { <nl> - assert ( index < getNumArguments ( ) & & " invalid argument number " ) ; <nl> - SmallString < 8 > nameOut ; <nl> - getArgAttrName ( index , nameOut ) ; <nl> - <nl> - if ( attributes . empty ( ) ) <nl> - return ( void ) removeAttr ( nameOut ) ; <nl> - setAttr ( nameOut , DictionaryAttr : : get ( attributes , getContext ( ) ) ) ; <nl> - } <nl> - <nl> - void FuncOp : : setArgAttrs ( unsigned index , NamedAttributeList attributes ) { <nl> - assert ( index < getNumArguments ( ) & & " invalid argument number " ) ; <nl> - SmallString < 8 > nameOut ; <nl> - if ( auto newAttr = attributes . getDictionary ( ) ) <nl> - return setAttr ( getArgAttrName ( index , nameOut ) , newAttr ) ; <nl> - removeAttr ( getArgAttrName ( index , nameOut ) ) ; <nl> - } <nl> - <nl> - / / / If the an attribute exists with the specified name , change it to the new <nl> - / / / value . Otherwise , add a new attribute with the specified name / value . <nl> - void FuncOp : : setArgAttr ( unsigned index , Identifier name , Attribute value ) { <nl> - auto curAttr = getArgAttrDict ( index ) ; <nl> - NamedAttributeList attrList ( curAttr ) ; <nl> - attrList . set ( name , value ) ; <nl> - <nl> - / / If the attribute changed , then set the new arg attribute list . <nl> - if ( curAttr ! = attrList . getDictionary ( ) ) <nl> - setArgAttrs ( index , attrList ) ; <nl> - } <nl> - <nl> - / / / Remove the attribute ' name ' from the argument at ' index ' . <nl> - NamedAttributeList : : RemoveResult FuncOp : : removeArgAttr ( unsigned index , <nl> - Identifier name ) { <nl> - / / Build an attribute list and remove the attribute at ' name ' . <nl> - NamedAttributeList attrList ( getArgAttrDict ( index ) ) ; <nl> - auto result = attrList . remove ( name ) ; <nl> - <nl> - / / If the attribute was removed , then update the argument dictionary . <nl> - if ( result = = NamedAttributeList : : RemoveResult : : Removed ) <nl> - setArgAttrs ( index , attrList ) ; <nl> - return result ; <nl> - } <nl> - <nl> - / / / Returns the attribute entry name for the set of argument attributes at index <nl> - / / / ' arg ' . <nl> - StringRef FuncOp : : getArgAttrName ( unsigned arg , SmallVectorImpl < char > & out ) { <nl> - out . clear ( ) ; <nl> - return ( " arg " + Twine ( arg ) ) . toStringRef ( out ) ; <nl> - } <nl> mmm a / lib / LLVMIR / IR / LLVMDialect . cpp <nl> ppp b / lib / LLVMIR / IR / LLVMDialect . cpp <nl> static ParseResult parseConstantOp ( OpAsmParser * parser , <nl> return success ( ) ; <nl> } <nl> <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + / / Builder and verifier for LLVM : : LLVMFuncOp . <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + <nl> + void LLVMFuncOp : : build ( Builder * builder , OperationState * result , StringRef name , <nl> + LLVMType type , ArrayRef < NamedAttribute > attrs , <nl> + ArrayRef < NamedAttributeList > argAttrs ) { <nl> + result - > addRegion ( ) ; <nl> + result - > addAttribute ( SymbolTable : : getSymbolAttrName ( ) , <nl> + builder - > getStringAttr ( name ) ) ; <nl> + result - > addAttribute ( " type " , builder - > getTypeAttr ( type ) ) ; <nl> + result - > attributes . append ( attrs . begin ( ) , attrs . end ( ) ) ; <nl> + if ( argAttrs . empty ( ) ) <nl> + return ; <nl> + <nl> + unsigned numInputs = type . getUnderlyingType ( ) - > getFunctionNumParams ( ) ; <nl> + assert ( numInputs = = argAttrs . size ( ) & & <nl> + " expected as many argument attribute lists as arguments " ) ; <nl> + SmallString < 8 > argAttrName ; <nl> + for ( unsigned i = 0 ; i < numInputs ; + + i ) <nl> + if ( auto argDict = argAttrs [ i ] . getDictionary ( ) ) <nl> + result - > addAttribute ( getArgAttrName ( i , argAttrName ) , argDict ) ; <nl> + } <nl> + <nl> + / / Hook for OpTrait : : FunctionLike , called after verifying that the ' type ' <nl> + / / attribute is present . This can check for preconditions of the <nl> + / / getNumArguments hook not failing . <nl> + LogicalResult LLVMFuncOp : : verifyType ( ) { <nl> + auto llvmType = getTypeAttr ( ) . getValue ( ) . dyn_cast_or_null < LLVMType > ( ) ; <nl> + if ( ! llvmType | | ! llvmType . getUnderlyingType ( ) - > isFunctionTy ( ) ) <nl> + return emitOpError ( " requires ' " + getTypeAttrName ( ) + <nl> + " ' attribute of wrapped LLVM function type " ) ; <nl> + <nl> + return success ( ) ; <nl> + } <nl> + <nl> + / / Hook for OpTrait : : FunctionLike , returns the number of function arguments . <nl> + / / Depends on the type attribute being correct as checked by verifyType <nl> + unsigned LLVMFuncOp : : getNumFuncArguments ( ) { <nl> + return getType ( ) . getUnderlyingType ( ) - > getFunctionNumParams ( ) ; <nl> + } <nl> + <nl> + static LogicalResult verify ( LLVMFuncOp op ) { <nl> + if ( op . isExternal ( ) ) <nl> + return success ( ) ; <nl> + <nl> + auto * funcType = cast < llvm : : FunctionType > ( op . getType ( ) . getUnderlyingType ( ) ) ; <nl> + unsigned numArguments = funcType - > getNumParams ( ) ; <nl> + Block & entryBlock = op . front ( ) ; <nl> + for ( unsigned i = 0 ; i < numArguments ; + + i ) { <nl> + Type argType = entryBlock . getArgument ( i ) - > getType ( ) ; <nl> + auto argLLVMType = argType . dyn_cast < LLVMType > ( ) ; <nl> + if ( ! argLLVMType ) <nl> + return op . emitOpError ( " entry block argument # " ) <nl> + < < i < < " is not of LLVM type " ; <nl> + if ( funcType - > getParamType ( i ) ! = argLLVMType . getUnderlyingType ( ) ) <nl> + return op . emitOpError ( " the type of entry block argument # " ) <nl> + < < i < < " does not match the function signature " ; <nl> + } <nl> + <nl> + return success ( ) ; <nl> + } <nl> + <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> / / LLVMDialect initialization , type parsing , and registration . <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> new file mode 100644 <nl> index 0000000000000 . . f056d375f20e9 <nl> mmm / dev / null <nl> ppp b / test / LLVMIR / func . mlir <nl> <nl> + / / RUN : mlir - opt - split - input - file - verify - diagnostics % s | FileCheck % s <nl> + <nl> + module { <nl> + / / CHECK : " llvm . func " <nl> + / / CHECK : sym_name = " foo " <nl> + / / CHECK - SAME : type = ! llvm < " void ( ) " > <nl> + / / CHECK - SAME : ( ) - > ( ) <nl> + " llvm . func " ( ) ( { <nl> + } ) { sym_name = " foo " , type = ! llvm < " void ( ) " > } : ( ) - > ( ) <nl> + <nl> + / / CHECK : " llvm . func " <nl> + / / CHECK : sym_name = " bar " <nl> + / / CHECK - SAME : type = ! llvm < " i64 ( i64 , i64 ) " > <nl> + / / CHECK - SAME : ( ) - > ( ) <nl> + " llvm . func " ( ) ( { <nl> + } ) { sym_name = " bar " , type = ! llvm < " i64 ( i64 , i64 ) " > } : ( ) - > ( ) <nl> + <nl> + / / CHECK : " llvm . func " <nl> + " llvm . func " ( ) ( { <nl> + / / CHECK : ^ bb0 <nl> + ^ bb0 ( % arg0 : ! llvm . i64 ) : <nl> + / / CHECK : llvm . return <nl> + llvm . return % arg0 : ! llvm . i64 <nl> + <nl> + / / CHECK : sym_name = " baz " <nl> + / / CHECK - SAME : type = ! llvm < " i64 ( i64 ) " > <nl> + / / CHECK - SAME : ( ) - > ( ) <nl> + } ) { sym_name = " baz " , type = ! llvm < " i64 ( i64 ) " > } : ( ) - > ( ) <nl> + } <nl> + <nl> + / / mmm - - <nl> + <nl> + module { <nl> + / / expected - error @ + 1 { { expects one region } } <nl> + " llvm . func " ( ) { sym_name = " no_region " , type = ! llvm < " void ( ) " > } : ( ) - > ( ) <nl> + } <nl> + <nl> + / / mmm - - <nl> + <nl> + module { <nl> + / / expected - error @ + 1 { { requires a type attribute ' type ' } } <nl> + " llvm . func " ( ) ( { } ) { sym_name = " missing_type " } : ( ) - > ( ) <nl> + } <nl> + <nl> + / / mmm - - <nl> + <nl> + module { <nl> + / / expected - error @ + 1 { { requires ' type ' attribute of wrapped LLVM function type } } <nl> + " llvm . func " ( ) ( { } ) { sym_name = " non_llvm_type " , type = i64 } : ( ) - > ( ) <nl> + } <nl> + <nl> + / / mmm - - <nl> + <nl> + module { <nl> + / / expected - error @ + 1 { { requires ' type ' attribute of wrapped LLVM function type } } <nl> + " llvm . func " ( ) ( { } ) { sym_name = " non_function_type " , type = ! llvm < " i64 " > } : ( ) - > ( ) <nl> + } <nl> + <nl> + / / mmm - - <nl> + <nl> + module { <nl> + / / expected - error @ + 1 { { entry block must have 0 arguments } } <nl> + " llvm . func " ( ) ( { <nl> + ^ bb0 ( % arg0 : ! llvm . i64 ) : <nl> + llvm . return <nl> + } ) { sym_name = " wrong_arg_number " , type = ! llvm < " void ( ) " > } : ( ) - > ( ) <nl> + } <nl> + <nl> + / / mmm - - <nl> + <nl> + module { <nl> + / / expected - error @ + 1 { { entry block argument # 0 is not of LLVM type } } <nl> + " llvm . func " ( ) ( { <nl> + ^ bb0 ( % arg0 : i64 ) : <nl> + llvm . return <nl> + } ) { sym_name = " wrong_arg_number " , type = ! llvm < " void ( i64 ) " > } : ( ) - > ( ) <nl> + } <nl> + <nl> + / / mmm - - <nl> + <nl> + module { <nl> + / / expected - error @ + 1 { { entry block argument # 0 does not match the function signature } } <nl> + " llvm . func " ( ) ( { <nl> + ^ bb0 ( % arg0 : ! llvm . i32 ) : <nl> + llvm . return <nl> + } ) { sym_name = " wrong_arg_number " , type = ! llvm < " void ( i64 ) " > } : ( ) - > ( ) <nl> + } <nl> | Introduce LLVMFuncOp | tensorflow/tensorflow | 4513930977f153e22d7b416e415b5a46d8b0cc71 | 2019-07-23T16:26:39Z |
mmm a / include / swift / AST / Decl . h <nl> ppp b / include / swift / AST / Decl . h <nl> struct SelfReferenceKind { <nl> other ( other ) { } <nl> } ; <nl> <nl> + / / / The set of known protocols for which derived conformances are supported . <nl> + enum class KnownDerivableProtocolKind : uint8_t { <nl> + RawRepresentable , <nl> + OptionSet , <nl> + CaseIterable , <nl> + Comparable , <nl> + Equatable , <nl> + Hashable , <nl> + BridgedNSError , <nl> + CodingKey , <nl> + Encodable , <nl> + Decodable , <nl> + AdditiveArithmetic , <nl> + Differentiable , <nl> + } ; <nl> + <nl> / / / ProtocolDecl - A declaration of a protocol , for example : <nl> / / / <nl> / / / protocol Drawable { <nl> class ProtocolDecl final : public NominalTypeDecl { <nl> return static_cast < KnownProtocolKind > ( Bits . ProtocolDecl . KnownProtocol - 2 ) ; <nl> } <nl> <nl> + Optional < KnownDerivableProtocolKind > getKnownDerivableProtocolKind ( ) const ; <nl> + <nl> / / / Check whether this protocol is of a specific , known protocol kind . <nl> bool isSpecificProtocol ( KnownProtocolKind kind ) const { <nl> if ( auto knownKind = getKnownProtocolKind ( ) ) <nl> mmm a / include / swift / AST / NameLookup . h <nl> ppp b / include / swift / AST / NameLookup . h <nl> enum class DeclVisibilityKind { <nl> / / / \ endcode <nl> MemberOfCurrentNominal , <nl> <nl> - / / / Declaration that is a requirement of a protocol implemented by the <nl> - / / / immediately enclosing nominal decl , in case the nominal decl does not <nl> - / / / supply a witness for this requirement . <nl> + / / / Declaration is a requirement – in case the nominal decl does not supply <nl> + / / / a corresponding witness – or an extension member of a protocol <nl> + / / / conformed to by the immediately enclosing nominal decl . <nl> / / / <nl> / / / For example , ' foo ' is visible at ( 1 ) because of this . <nl> / / / \ code <nl> enum class DeclVisibilityKind { <nl> / / / } <nl> / / / } <nl> / / / \ endcode <nl> - MemberOfProtocolImplementedByCurrentNominal , <nl> + MemberOfProtocolConformedToByCurrentNominal , <nl> + <nl> + / / / Declaration is a derived requirement of a protocol conformed to by the <nl> + / / / immediately enclosing nominal decl ( a witness for a synthesized <nl> + / / / conformance ) . <nl> + MemberOfProtocolDerivedByCurrentNominal , <nl> <nl> / / / Declaration is a member of the superclass of the immediately enclosing <nl> / / / nominal decl . <nl> void lookupVisibleMemberDecls ( VisibleDeclConsumer & Consumer , <nl> Type BaseTy , <nl> const DeclContext * CurrDC , <nl> bool includeInstanceMembers , <nl> + bool includeDerivedRequirements , <nl> GenericSignatureBuilder * GSB = nullptr ) ; <nl> <nl> namespace namelookup { <nl> mmm a / lib / AST / Decl . cpp <nl> ppp b / lib / AST / Decl . cpp <nl> void ProtocolDecl : : computeKnownProtocolKind ( ) const { <nl> const_cast < ProtocolDecl * > ( this ) - > Bits . ProtocolDecl . KnownProtocol = value ; <nl> } <nl> <nl> + Optional < KnownDerivableProtocolKind > <nl> + ProtocolDecl : : getKnownDerivableProtocolKind ( ) const { <nl> + const auto knownKind = getKnownProtocolKind ( ) ; <nl> + if ( ! knownKind ) <nl> + return None ; <nl> + <nl> + switch ( * knownKind ) { <nl> + case KnownProtocolKind : : RawRepresentable : <nl> + return KnownDerivableProtocolKind : : RawRepresentable ; <nl> + case KnownProtocolKind : : OptionSet : <nl> + return KnownDerivableProtocolKind : : OptionSet ; <nl> + case KnownProtocolKind : : CaseIterable : <nl> + return KnownDerivableProtocolKind : : CaseIterable ; <nl> + case KnownProtocolKind : : Comparable : <nl> + return KnownDerivableProtocolKind : : Comparable ; <nl> + case KnownProtocolKind : : Equatable : <nl> + return KnownDerivableProtocolKind : : Equatable ; <nl> + case KnownProtocolKind : : Hashable : <nl> + return KnownDerivableProtocolKind : : Hashable ; <nl> + case KnownProtocolKind : : BridgedNSError : <nl> + return KnownDerivableProtocolKind : : BridgedNSError ; <nl> + case KnownProtocolKind : : CodingKey : <nl> + return KnownDerivableProtocolKind : : CodingKey ; <nl> + case KnownProtocolKind : : Encodable : <nl> + return KnownDerivableProtocolKind : : Encodable ; <nl> + case KnownProtocolKind : : Decodable : <nl> + return KnownDerivableProtocolKind : : Decodable ; <nl> + case KnownProtocolKind : : AdditiveArithmetic : <nl> + return KnownDerivableProtocolKind : : AdditiveArithmetic ; <nl> + case KnownProtocolKind : : Differentiable : <nl> + return KnownDerivableProtocolKind : : Differentiable ; <nl> + default : return None ; <nl> + } <nl> + } <nl> + <nl> bool ProtocolDecl : : hasCircularInheritedProtocols ( ) const { <nl> auto & ctx = getASTContext ( ) ; <nl> auto * mutableThis = const_cast < ProtocolDecl * > ( this ) ; <nl> mmm a / lib / IDE / CodeCompletion . cpp <nl> ppp b / lib / IDE / CodeCompletion . cpp <nl> class CompletionLookup final : public swift : : VisibleDeclConsumer { <nl> return SemanticContextKind : : ExpressionSpecific ; <nl> return SemanticContextKind : : CurrentNominal ; <nl> <nl> - case DeclVisibilityKind : : MemberOfProtocolImplementedByCurrentNominal : <nl> + case DeclVisibilityKind : : MemberOfProtocolConformedToByCurrentNominal : <nl> case DeclVisibilityKind : : MemberOfSuper : <nl> return SemanticContextKind : : Super ; <nl> <nl> class CompletionLookup final : public swift : : VisibleDeclConsumer { <nl> D , dynamicLookupInfo . getKeyPathDynamicMember ( ) . originalVisibility , <nl> { } ) ; <nl> } <nl> + <nl> + case DeclVisibilityKind : : MemberOfProtocolDerivedByCurrentNominal : <nl> + llvm_unreachable ( " should not see this kind " ) ; <nl> } <nl> llvm_unreachable ( " unhandled kind " ) ; <nl> } <nl> class CompletionLookup final : public swift : : VisibleDeclConsumer { <nl> / / Implement swift : : VisibleDeclConsumer . <nl> void foundDecl ( ValueDecl * D , DeclVisibilityKind Reason , <nl> DynamicLookupInfo dynamicLookupInfo ) override { <nl> + assert ( Reason ! = <nl> + DeclVisibilityKind : : MemberOfProtocolDerivedByCurrentNominal & & <nl> + " Including derived requirement in non - override lookup " ) ; <nl> + <nl> if ( D - > shouldHideFromEditor ( ) ) <nl> return ; <nl> <nl> class CompletionLookup final : public swift : : VisibleDeclConsumer { <nl> if ( isIUO ) { <nl> if ( Type Unwrapped = ExprType - > getOptionalObjectType ( ) ) { <nl> lookupVisibleMemberDecls ( * this , Unwrapped , CurrDeclContext , <nl> - IncludeInstanceMembers ) ; <nl> + IncludeInstanceMembers , <nl> + / * includeDerivedRequirements * / false ) ; <nl> return true ; <nl> } <nl> assert ( IsUnwrappedOptional & & " IUOs should be optional if not bound / forced " ) ; <nl> class CompletionLookup final : public swift : : VisibleDeclConsumer { <nl> CodeCompletionResult : : MaxNumBytesToErase ) { <nl> if ( ! tryTupleExprCompletions ( Unwrapped ) ) { <nl> lookupVisibleMemberDecls ( * this , Unwrapped , CurrDeclContext , <nl> - IncludeInstanceMembers ) ; <nl> + IncludeInstanceMembers , <nl> + / * includeDerivedRequirements * / false ) ; <nl> } <nl> } <nl> return true ; <nl> class CompletionLookup final : public swift : : VisibleDeclConsumer { <nl> tryUnwrappedCompletions ( ExprType , isIUO ) ; <nl> <nl> lookupVisibleMemberDecls ( * this , ExprType , CurrDeclContext , <nl> - IncludeInstanceMembers ) ; <nl> + IncludeInstanceMembers , <nl> + / * includeDerivedRequirements * / false ) ; <nl> } <nl> <nl> void collectOperators ( SmallVectorImpl < OperatorDecl * > & results ) { <nl> class CompletionLookup final : public swift : : VisibleDeclConsumer { <nl> llvm : : SaveAndRestore < Type > SaveType ( ExprType , baseType ) ; <nl> llvm : : SaveAndRestore < bool > SaveUnresolved ( IsUnresolvedMember , true ) ; <nl> lookupVisibleMemberDecls ( consumer , baseType , CurrDeclContext , <nl> - / * includeInstanceMembers = * / false ) ; <nl> + / * includeInstanceMembers = * / false , <nl> + / * includeDerivedRequirements * / false ) ; <nl> } <nl> <nl> void getUnresolvedMemberCompletions ( ArrayRef < Type > Types ) { <nl> class CompletionLookup final : public swift : : VisibleDeclConsumer { <nl> NeedLeadingDot = ! HaveDot ; <nl> lookupVisibleMemberDecls ( * this , MetatypeType : : get ( BaseType ) , <nl> CurrDeclContext , <nl> - IncludeInstanceMembers ) ; <nl> + IncludeInstanceMembers , <nl> + / * includeDerivedRequirements * / false ) ; <nl> if ( BaseType - > isAnyExistentialType ( ) ) { <nl> addKeyword ( " Protocol " , MetatypeType : : get ( BaseType ) ) ; <nl> addKeyword ( " Type " , ExistentialMetatypeType : : get ( BaseType ) ) ; <nl> class CompletionLookup final : public swift : : VisibleDeclConsumer { <nl> this - > BaseType = selfTy ; <nl> NeedLeadingDot = false ; <nl> lookupVisibleMemberDecls ( * this , MetatypeType : : get ( selfTy ) , <nl> - CurrDeclContext , IncludeInstanceMembers ) ; <nl> + CurrDeclContext , IncludeInstanceMembers , <nl> + / * includeDerivedRequirements * / false ) ; <nl> } <nl> <nl> static bool canUseAttributeOnDecl ( DeclAttrKind DAK , bool IsInSil , <nl> class CompletionOverrideLookup : public swift : : VisibleDeclConsumer { <nl> Type getOpaqueResultType ( const ValueDecl * VD , DeclVisibilityKind Reason , <nl> DynamicLookupInfo dynamicLookupInfo ) { <nl> if ( Reason ! = <nl> - DeclVisibilityKind : : MemberOfProtocolImplementedByCurrentNominal ) <nl> + DeclVisibilityKind : : MemberOfProtocolConformedToByCurrentNominal ) <nl> return nullptr ; <nl> <nl> auto currTy = CurrDeclContext - > getDeclaredTypeInContext ( ) ; <nl> class CompletionOverrideLookup : public swift : : VisibleDeclConsumer { <nl> bool needRequired = false ; <nl> auto C = CurrDeclContext - > getSelfClassDecl ( ) ; <nl> if ( C & & ! isKeywordSpecified ( " required " ) ) { <nl> - if ( Reason = = <nl> - DeclVisibilityKind : : MemberOfProtocolImplementedByCurrentNominal & & <nl> - ! C - > isFinal ( ) ) <nl> - needRequired = true ; <nl> - else if ( Reason = = DeclVisibilityKind : : MemberOfSuper & & CD - > isRequired ( ) ) <nl> - needRequired = true ; <nl> + switch ( Reason ) { <nl> + case DeclVisibilityKind : : MemberOfProtocolConformedToByCurrentNominal : <nl> + case DeclVisibilityKind : : MemberOfProtocolDerivedByCurrentNominal : <nl> + if ( ! C - > isFinal ( ) ) <nl> + needRequired = true ; <nl> + break ; <nl> + case DeclVisibilityKind : : MemberOfSuper : <nl> + if ( CD - > isRequired ( ) ) <nl> + needRequired = true ; <nl> + break ; <nl> + default : break ; <nl> + } <nl> } <nl> <nl> llvm : : SmallString < 256 > DeclStr ; <nl> class CompletionOverrideLookup : public swift : : VisibleDeclConsumer { <nl> continue ; <nl> addTypeAlias ( <nl> ATD , <nl> - DeclVisibilityKind : : MemberOfProtocolImplementedByCurrentNominal , <nl> + DeclVisibilityKind : : MemberOfProtocolConformedToByCurrentNominal , <nl> { } ) ; <nl> } <nl> } <nl> class CompletionOverrideLookup : public swift : : VisibleDeclConsumer { <nl> / / Look for overridable static members too . <nl> Type Meta = MetatypeType : : get ( CurrTy ) ; <nl> lookupVisibleMemberDecls ( * this , Meta , CurrDeclContext , <nl> - / * includeInstanceMembers = * / true ) ; <nl> + / * includeInstanceMembers = * / true , <nl> + / * includeDerivedRequirements * / true ) ; <nl> addDesignatedInitializers ( NTD ) ; <nl> addAssociatedTypes ( NTD ) ; <nl> } <nl> mmm a / lib / IDE / ConformingMethodList . cpp <nl> ppp b / lib / IDE / ConformingMethodList . cpp <nl> void ConformingMethodListCallbacks : : getMatchingMethods ( <nl> } LocalConsumer ( CurDeclContext , T , expectedTypes , result ) ; <nl> <nl> lookupVisibleMemberDecls ( LocalConsumer , MetatypeType : : get ( T ) , CurDeclContext , <nl> - / * includeInstanceMembers = * / false ) ; <nl> + / * includeInstanceMembers = * / false , <nl> + / * includeDerivedRequirements * / false ) ; <nl> } <nl> <nl> } / / anonymous namespace . <nl> mmm a / lib / IDE / TypeContextInfo . cpp <nl> ppp b / lib / IDE / TypeContextInfo . cpp <nl> void ContextInfoCallbacks : : getImplicitMembers ( <nl> } LocalConsumer ( CurDeclContext , T , Result ) ; <nl> <nl> lookupVisibleMemberDecls ( LocalConsumer , MetatypeType : : get ( T ) , CurDeclContext , <nl> - / * includeInstanceMembers = * / false ) ; <nl> + / * includeInstanceMembers = * / false , <nl> + / * includeDerivedRequirements * / false ) ; <nl> } <nl> <nl> void PrintingTypeContextInfoConsumer : : handleResults ( <nl> mmm a / lib / Sema / DerivedConformances . cpp <nl> ppp b / lib / Sema / DerivedConformances . cpp <nl> Type DerivedConformance : : getProtocolType ( ) const { <nl> bool DerivedConformance : : derivesProtocolConformance ( DeclContext * DC , <nl> NominalTypeDecl * Nominal , <nl> ProtocolDecl * Protocol ) { <nl> - / / Only known protocols can be derived . <nl> - auto knownProtocol = Protocol - > getKnownProtocolKind ( ) ; <nl> - if ( ! knownProtocol ) <nl> + const auto derivableKind = Protocol - > getKnownDerivableProtocolKind ( ) ; <nl> + if ( ! derivableKind ) <nl> return false ; <nl> <nl> - if ( * knownProtocol = = KnownProtocolKind : : Hashable ) { <nl> + / / When the necessary requirements are met , the conformance to OptionSet <nl> + / / is serendipitously derived via memberwise initializer synthesis . <nl> + if ( * derivableKind = = KnownDerivableProtocolKind : : OptionSet ) { <nl> + return false ; <nl> + } <nl> + <nl> + if ( * derivableKind = = KnownDerivableProtocolKind : : Hashable ) { <nl> / / We can always complete a partial Hashable implementation , and we can <nl> / / synthesize a full Hashable implementation for structs and enums with <nl> / / Hashable components . <nl> return canDeriveHashable ( Nominal ) ; <nl> } <nl> <nl> - if ( * knownProtocol = = KnownProtocolKind : : AdditiveArithmetic ) <nl> + if ( * derivableKind = = KnownDerivableProtocolKind : : AdditiveArithmetic ) <nl> return canDeriveAdditiveArithmetic ( Nominal , DC ) ; <nl> <nl> - if ( * knownProtocol = = KnownProtocolKind : : Differentiable ) <nl> + if ( * derivableKind = = KnownDerivableProtocolKind : : Differentiable ) <nl> return canDeriveDifferentiable ( Nominal , DC ) ; <nl> <nl> if ( auto * enumDecl = dyn_cast < EnumDecl > ( Nominal ) ) { <nl> - switch ( * knownProtocol ) { <nl> + switch ( * derivableKind ) { <nl> / / The presence of a raw type is an explicit declaration that <nl> / / the compiler should derive a RawRepresentable conformance . <nl> - case KnownProtocolKind : : RawRepresentable : <nl> + case KnownDerivableProtocolKind : : RawRepresentable : <nl> return canDeriveRawRepresentable ( DC , Nominal ) ; <nl> <nl> / / Enums without associated values can implicitly derive Equatable <nl> / / conformance . <nl> - case KnownProtocolKind : : Equatable : <nl> + case KnownDerivableProtocolKind : : Equatable : <nl> return canDeriveEquatable ( DC , Nominal ) ; <nl> <nl> - case KnownProtocolKind : : Comparable : <nl> + case KnownDerivableProtocolKind : : Comparable : <nl> return ! enumDecl - > hasPotentiallyUnavailableCaseValue ( ) <nl> & & canDeriveComparable ( DC , enumDecl ) ; <nl> <nl> bool DerivedConformance : : derivesProtocolConformance ( DeclContext * DC , <nl> / / a CaseIterable conformance . <nl> / / <nl> / / FIXME : Lift the availability restriction . <nl> - case KnownProtocolKind : : CaseIterable : <nl> + case KnownDerivableProtocolKind : : CaseIterable : <nl> return ! enumDecl - > hasPotentiallyUnavailableCaseValue ( ) <nl> & & enumDecl - > hasOnlyCasesWithoutAssociatedValues ( ) ; <nl> <nl> / / @ objc enums can explicitly derive their _BridgedNSError conformance . <nl> - case KnownProtocolKind : : BridgedNSError : <nl> + case KnownDerivableProtocolKind : : BridgedNSError : <nl> return enumDecl - > isObjC ( ) & & enumDecl - > hasCases ( ) <nl> & & enumDecl - > hasOnlyCasesWithoutAssociatedValues ( ) ; <nl> <nl> / / Enums without associated values and enums with a raw type of String <nl> / / or Int can explicitly derive CodingKey conformance . <nl> - case KnownProtocolKind : : CodingKey : { <nl> + case KnownDerivableProtocolKind : : CodingKey : { <nl> Type rawType = enumDecl - > getRawType ( ) ; <nl> if ( rawType ) { <nl> auto parentDC = enumDecl - > getDeclContext ( ) ; <nl> bool DerivedConformance : : derivesProtocolConformance ( DeclContext * DC , <nl> / / Structs and classes can explicitly derive Encodable and Decodable <nl> / / conformance ( explicitly meaning we can synthesize an implementation if <nl> / / a type conforms manually ) . <nl> - if ( * knownProtocol = = KnownProtocolKind : : Encodable | | <nl> - * knownProtocol = = KnownProtocolKind : : Decodable ) { <nl> + if ( * derivableKind = = KnownDerivableProtocolKind : : Encodable | | <nl> + * derivableKind = = KnownDerivableProtocolKind : : Decodable ) { <nl> / / FIXME : This is not actually correct . We cannot promise to always <nl> / / provide a witness here for all structs and classes . Unfortunately , <nl> / / figuring out whether this is actually possible requires much more <nl> bool DerivedConformance : : derivesProtocolConformance ( DeclContext * DC , <nl> <nl> / / Structs can explicitly derive Equatable conformance . <nl> if ( isa < StructDecl > ( Nominal ) ) { <nl> - switch ( * knownProtocol ) { <nl> - case KnownProtocolKind : : Equatable : <nl> + switch ( * derivableKind ) { <nl> + case KnownDerivableProtocolKind : : Equatable : <nl> return canDeriveEquatable ( DC , Nominal ) ; <nl> default : <nl> return false ; <nl> mmm a / lib / Sema / LookupVisibleDecls . cpp <nl> ppp b / lib / Sema / LookupVisibleDecls . cpp <nl> struct LookupState { <nl> / / / Should instance members be included even if lookup is performed on a type ? <nl> unsigned IncludeInstanceMembers : 1 ; <nl> <nl> + / / / Should derived protocol requirements be included ? <nl> + / / / This option is only for override completion lookup . <nl> + unsigned IncludeDerivedRequirements : 1 ; <nl> + <nl> LookupState ( ) <nl> : IsQualified ( 0 ) , IsOnMetatype ( 0 ) , IsOnSuperclass ( 0 ) , <nl> - InheritsSuperclassInitializers ( 0 ) , IncludeInstanceMembers ( 0 ) { } <nl> + InheritsSuperclassInitializers ( 0 ) , IncludeInstanceMembers ( 0 ) , <nl> + IncludeDerivedRequirements ( 0 ) { } <nl> <nl> public : <nl> LookupState ( const LookupState & ) = default ; <nl> struct LookupState { <nl> return InheritsSuperclassInitializers ; <nl> } <nl> bool isIncludingInstanceMembers ( ) const { return IncludeInstanceMembers ; } <nl> + bool isIncludingDerivedRequirements ( ) const { <nl> + return IncludeDerivedRequirements ; <nl> + } <nl> <nl> LookupState withOnMetatype ( ) const { <nl> auto Result = * this ; <nl> struct LookupState { <nl> Result . IncludeInstanceMembers = 1 ; <nl> return Result ; <nl> } <nl> + <nl> + LookupState withIncludedDerivedRequirements ( ) const { <nl> + auto Result = * this ; <nl> + Result . IncludeDerivedRequirements = 1 ; <nl> + return Result ; <nl> + } <nl> } ; <nl> } / / end anonymous namespace <nl> <nl> namespace { <nl> static DeclVisibilityKind getReasonForSuper ( DeclVisibilityKind Reason ) { <nl> switch ( Reason ) { <nl> case DeclVisibilityKind : : MemberOfCurrentNominal : <nl> - case DeclVisibilityKind : : MemberOfProtocolImplementedByCurrentNominal : <nl> + case DeclVisibilityKind : : MemberOfProtocolConformedToByCurrentNominal : <nl> case DeclVisibilityKind : : MemberOfSuper : <nl> return DeclVisibilityKind : : MemberOfSuper ; <nl> <nl> static void lookupDeclsFromProtocolsBeingConformedTo ( <nl> ReasonForThisProtocol = getReasonForSuper ( Reason ) ; <nl> else if ( Reason = = DeclVisibilityKind : : MemberOfCurrentNominal ) <nl> ReasonForThisProtocol = <nl> - DeclVisibilityKind : : MemberOfProtocolImplementedByCurrentNominal ; <nl> + DeclVisibilityKind : : MemberOfProtocolConformedToByCurrentNominal ; <nl> else <nl> ReasonForThisProtocol = getReasonForSuper ( Reason ) ; <nl> <nl> if ( auto NormalConformance = dyn_cast < NormalProtocolConformance > ( <nl> Conformance - > getRootConformance ( ) ) ) { <nl> for ( auto Member : Proto - > getMembers ( ) ) { <nl> + / / Skip associated types and value requirements that aren ' t visible <nl> + / / or have a corresponding witness . <nl> if ( auto * ATD = dyn_cast < AssociatedTypeDecl > ( Member ) ) { <nl> - / / Skip type decls if they aren ' t visible , or any type that has a <nl> - / / witness . This cuts down on duplicates . <nl> if ( areTypeDeclsVisibleInLookupMode ( LS ) & & <nl> ! Conformance - > hasTypeWitness ( ATD ) ) { <nl> Consumer . foundDecl ( ATD , ReasonForThisProtocol ) ; <nl> } <nl> - continue ; <nl> - } <nl> - if ( auto * VD = dyn_cast < ValueDecl > ( Member ) ) { <nl> + } else if ( auto * VD = dyn_cast < ValueDecl > ( Member ) ) { <nl> if ( ! isDeclVisibleInLookupMode ( VD , LS , FromContext ) ) <nl> continue ; <nl> <nl> if ( ! VD - > isProtocolRequirement ( ) ) <nl> continue ; <nl> <nl> - / / Skip value requirements that have corresponding witnesses . This <nl> - / / cuts down on duplicates . <nl> - auto witness = NormalConformance - > getWitness ( VD ) ; <nl> - if ( witness & & witness . getDecl ( ) - > getFullName ( ) = = VD - > getFullName ( ) ) <nl> - continue ; <nl> + / / Whether the given witness corresponds to a derived requirement . <nl> + const auto isDerivedRequirement = [ Proto ] ( const ValueDecl * Witness ) { <nl> + return Witness - > isImplicit ( ) & & <nl> + Proto - > getKnownDerivableProtocolKind ( ) ; <nl> + } ; <nl> + DeclVisibilityKind ReasonForThisDecl = ReasonForThisProtocol ; <nl> + if ( const auto Witness = NormalConformance - > getWitness ( VD ) ) { <nl> + if ( Witness . getDecl ( ) - > getFullName ( ) = = VD - > getFullName ( ) ) { <nl> + if ( LS . isIncludingDerivedRequirements ( ) & & <nl> + Reason = = DeclVisibilityKind : : MemberOfCurrentNominal & & <nl> + isDerivedRequirement ( Witness . getDecl ( ) ) ) { <nl> + ReasonForThisDecl = <nl> + DeclVisibilityKind : : MemberOfProtocolDerivedByCurrentNominal ; <nl> + } else { <nl> + continue ; <nl> + } <nl> + } <nl> + } <nl> <nl> - Consumer . foundDecl ( VD , ReasonForThisProtocol ) ; <nl> + Consumer . foundDecl ( VD , ReasonForThisDecl ) ; <nl> } <nl> } <nl> } <nl> static void lookupVisibleMemberDeclsImpl ( <nl> if ( LS . isIncludingInstanceMembers ( ) ) { <nl> subLS = subLS . withIncludedInstanceMembers ( ) ; <nl> } <nl> + if ( LS . isIncludingDerivedRequirements ( ) ) { <nl> + subLS = subLS . withIncludedDerivedRequirements ( ) ; <nl> + } <nl> <nl> / / Just perform normal dot lookup on the type see if we find extensions or <nl> / / anything else . For example , type SomeTy . SomeMember can look up static <nl> template < > struct DenseMapInfo < FoundDeclTy > { <nl> / / If a class ' Base ' conforms to ' Proto ' , and my base type is a subclass <nl> / / ' Derived ' of ' Base ' , use ' Base ' not ' Derived ' as the ' Self ' type in the <nl> / / substitution map . <nl> - static Type getBaseTypeForMember ( ModuleDecl * M , ValueDecl * OtherVD , Type BaseTy ) { <nl> + static Type getBaseTypeForMember ( ModuleDecl * M , const ValueDecl * OtherVD , <nl> + Type BaseTy ) { <nl> if ( auto * Proto = OtherVD - > getDeclContext ( ) - > getSelfProtocolDecl ( ) ) { <nl> if ( BaseTy - > getClassOrBoundGenericClass ( ) ) { <nl> if ( auto Conformance = M - > lookupConformance ( BaseTy , Proto ) ) { <nl> class OverrideFilteringConsumer : public VisibleDeclConsumer { <nl> removeShadowedDecls ( Decls , DC ) ; <nl> <nl> size_t index = 0 ; <nl> - for ( auto DeclAndReason : Results ) { <nl> + for ( const auto DeclAndReason : Results ) { <nl> if ( index > = Decls . size ( ) ) <nl> break ; <nl> if ( DeclAndReason . D ! = Decls [ index ] ) <nl> class OverrideFilteringConsumer : public VisibleDeclConsumer { <nl> <nl> index + + ; <nl> <nl> - auto * VD = DeclAndReason . D ; <nl> - auto Reason = DeclAndReason . Reason ; <nl> - auto dynamicLookupInfo = DeclAndReason . dynamicLookupInfo ; <nl> + auto * const VD = DeclAndReason . D ; <nl> + const auto Reason = DeclAndReason . Reason ; <nl> <nl> / / If this kind of declaration doesn ' t participate in overriding , there ' s <nl> / / no filtering to do here . <nl> if ( ! isa < AbstractFunctionDecl > ( VD ) & & <nl> ! isa < AbstractStorageDecl > ( VD ) & & <nl> ! isa < AssociatedTypeDecl > ( VD ) ) { <nl> - FilteredResults . insert ( FoundDeclTy ( VD , Reason , dynamicLookupInfo ) ) ; <nl> + FilteredResults . insert ( DeclAndReason ) ; <nl> continue ; <nl> } <nl> <nl> class OverrideFilteringConsumer : public VisibleDeclConsumer { <nl> auto & PossiblyConflicting = DeclsByName [ VD - > getBaseName ( ) ] ; <nl> <nl> if ( VD - > isInvalid ( ) ) { <nl> - FilteredResults . insert ( FoundDeclTy ( VD , Reason , dynamicLookupInfo ) ) ; <nl> + FilteredResults . insert ( DeclAndReason ) ; <nl> PossiblyConflicting . push_back ( VD ) ; <nl> continue ; <nl> } <nl> class OverrideFilteringConsumer : public VisibleDeclConsumer { <nl> bool FoundConflicting = false ; <nl> for ( auto I = PossiblyConflicting . begin ( ) , E = PossiblyConflicting . end ( ) ; <nl> I ! = E ; + + I ) { <nl> - auto * OtherVD = * I ; <nl> + auto * const OtherVD = * I ; <nl> if ( OtherVD - > isRecursiveValidation ( ) ) <nl> continue ; <nl> <nl> class OverrideFilteringConsumer : public VisibleDeclConsumer { <nl> / * wouldConflictInSwift5 * / nullptr , <nl> / * skipProtocolExtensionCheck * / true ) ) { <nl> FoundConflicting = true ; <nl> - if ( VD - > getFormalAccess ( ) > OtherVD - > getFormalAccess ( ) | | <nl> + / / Prefer derived requirements over their witnesses . <nl> + if ( Reason = = <nl> + DeclVisibilityKind : : MemberOfProtocolDerivedByCurrentNominal | | <nl> + VD - > getFormalAccess ( ) > OtherVD - > getFormalAccess ( ) | | <nl> / / Prefer available one . <nl> ( ! AvailableAttr : : isUnavailable ( VD ) & & <nl> AvailableAttr : : isUnavailable ( OtherVD ) ) ) { <nl> FilteredResults . remove ( <nl> FoundDeclTy ( OtherVD , DeclVisibilityKind : : LocalVariable , { } ) ) ; <nl> - FilteredResults . insert ( FoundDeclTy ( VD , Reason , dynamicLookupInfo ) ) ; <nl> + FilteredResults . insert ( DeclAndReason ) ; <nl> * I = VD ; <nl> } <nl> } <nl> } <nl> <nl> if ( ! FoundConflicting ) { <nl> - FilteredResults . insert ( FoundDeclTy ( VD , Reason , dynamicLookupInfo ) ) ; <nl> + FilteredResults . insert ( DeclAndReason ) ; <nl> PossiblyConflicting . push_back ( VD ) ; <nl> } <nl> } <nl> void swift : : lookupVisibleDecls ( VisibleDeclConsumer & Consumer , <nl> void swift : : lookupVisibleMemberDecls ( VisibleDeclConsumer & Consumer , Type BaseTy , <nl> const DeclContext * CurrDC , <nl> bool includeInstanceMembers , <nl> + bool includeDerivedRequirements , <nl> GenericSignatureBuilder * GSB ) { <nl> assert ( CurrDC ) ; <nl> LookupState ls = LookupState : : makeQualified ( ) ; <nl> if ( includeInstanceMembers ) { <nl> ls = ls . withIncludedInstanceMembers ( ) ; <nl> } <nl> + if ( includeDerivedRequirements ) { <nl> + ls = ls . withIncludedDerivedRequirements ( ) ; <nl> + } <nl> <nl> : : lookupVisibleMemberDecls ( BaseTy , Consumer , CurrDC , ls , <nl> DeclVisibilityKind : : MemberOfCurrentNominal , <nl> mmm a / lib / Sema / TypeCheckNameLookup . cpp <nl> ppp b / lib / Sema / TypeCheckNameLookup . cpp <nl> void TypeChecker : : performTypoCorrection ( DeclContext * DC , DeclRefKind refKind , <nl> <nl> if ( baseTypeOrNull ) { <nl> lookupVisibleMemberDecls ( consumer , baseTypeOrNull , DC , <nl> - / * include instance members * / true , gsb ) ; <nl> + / * includeInstanceMembers * / true , <nl> + / * includeDerivedRequirements * / false , gsb ) ; <nl> } else { <nl> lookupVisibleDecls ( consumer , DC , / * top level * / true , <nl> corrections . Loc . getBaseNameLoc ( ) ) ; <nl> mmm a / lib / Sema / TypeCheckProtocol . cpp <nl> ppp b / lib / Sema / TypeCheckProtocol . cpp <nl> ValueDecl * TypeChecker : : deriveProtocolRequirement ( DeclContext * DC , <nl> ValueDecl * Requirement ) { <nl> / / Note : whenever you update this function , also update <nl> / / DerivedConformance : : getDerivableRequirement . <nl> - auto * protocol = cast < ProtocolDecl > ( Requirement - > getDeclContext ( ) ) ; <nl> + const auto protocol = cast < ProtocolDecl > ( Requirement - > getDeclContext ( ) ) ; <nl> <nl> - auto knownKind = protocol - > getKnownProtocolKind ( ) ; <nl> - <nl> - if ( ! knownKind ) <nl> + const auto derivableKind = protocol - > getKnownDerivableProtocolKind ( ) ; <nl> + if ( ! derivableKind ) <nl> return nullptr ; <nl> <nl> - auto Decl = DC - > getInnermostDeclarationDeclContext ( ) ; <nl> + const auto Decl = DC - > getInnermostDeclarationDeclContext ( ) ; <nl> if ( Decl - > isInvalid ( ) ) <nl> return nullptr ; <nl> <nl> DerivedConformance derived ( TypeDecl - > getASTContext ( ) , Decl , TypeDecl , <nl> protocol ) ; <nl> <nl> - switch ( * knownKind ) { <nl> - case KnownProtocolKind : : RawRepresentable : <nl> + switch ( * derivableKind ) { <nl> + case KnownDerivableProtocolKind : : RawRepresentable : <nl> return derived . deriveRawRepresentable ( Requirement ) ; <nl> <nl> - case KnownProtocolKind : : CaseIterable : <nl> + case KnownDerivableProtocolKind : : CaseIterable : <nl> return derived . deriveCaseIterable ( Requirement ) ; <nl> <nl> - case KnownProtocolKind : : Comparable : <nl> + case KnownDerivableProtocolKind : : Comparable : <nl> return derived . deriveComparable ( Requirement ) ; <nl> <nl> - case KnownProtocolKind : : Equatable : <nl> + case KnownDerivableProtocolKind : : Equatable : <nl> return derived . deriveEquatable ( Requirement ) ; <nl> <nl> - case KnownProtocolKind : : Hashable : <nl> + case KnownDerivableProtocolKind : : Hashable : <nl> return derived . deriveHashable ( Requirement ) ; <nl> <nl> - case KnownProtocolKind : : BridgedNSError : <nl> + case KnownDerivableProtocolKind : : BridgedNSError : <nl> return derived . deriveBridgedNSError ( Requirement ) ; <nl> <nl> - case KnownProtocolKind : : CodingKey : <nl> + case KnownDerivableProtocolKind : : CodingKey : <nl> return derived . deriveCodingKey ( Requirement ) ; <nl> <nl> - case KnownProtocolKind : : Encodable : <nl> + case KnownDerivableProtocolKind : : Encodable : <nl> return derived . deriveEncodable ( Requirement ) ; <nl> <nl> - case KnownProtocolKind : : Decodable : <nl> + case KnownDerivableProtocolKind : : Decodable : <nl> return derived . deriveDecodable ( Requirement ) ; <nl> <nl> - case KnownProtocolKind : : AdditiveArithmetic : <nl> + case KnownDerivableProtocolKind : : AdditiveArithmetic : <nl> return derived . deriveAdditiveArithmetic ( Requirement ) ; <nl> <nl> - case KnownProtocolKind : : Differentiable : <nl> + case KnownDerivableProtocolKind : : Differentiable : <nl> return derived . deriveDifferentiable ( Requirement ) ; <nl> <nl> - default : <nl> - return nullptr ; <nl> + case KnownDerivableProtocolKind : : OptionSet : <nl> + llvm_unreachable ( <nl> + " When possible , OptionSet is derived via memberwise init synthesis " ) ; <nl> } <nl> } <nl> <nl> mmm a / test / IDE / complete_override . swift <nl> ppp b / test / IDE / complete_override . swift <nl> <nl> <nl> / / RUN : % target - swift - ide - test - enable - objc - interop - code - completion - source - filename % s - code - completion - token = MISSING_ASSOC_1 - code - completion - keywords = false | % FileCheck % s - check - prefix = MISSING_ASSOC_1 <nl> <nl> + / / RUN : % target - swift - ide - test - code - completion - source - filename % s - code - completion - token = OVERRIDE_SYNTHESIZED_1 - code - completion - keywords = false | % FileCheck % s - check - prefix = OVERRIDE_SYNTHESIZED_1 <nl> + / / RUN : % target - swift - ide - test - code - completion - source - filename % s - code - completion - token = OVERRIDE_SYNTHESIZED_2 - code - completion - keywords = false | % FileCheck % s - check - prefix = OVERRIDE_SYNTHESIZED_2 <nl> + / / RUN : % target - swift - ide - test - code - completion - source - filename % s - code - completion - token = OVERRIDE_SYNTHESIZED_3 - code - completion - keywords = false | % FileCheck % s - check - prefix = OVERRIDE_SYNTHESIZED_3 <nl> + / / RUN : % target - swift - ide - test - code - completion - source - filename % s - code - completion - token = OVERRIDE_SYNTHESIZED_4 - code - completion - keywords = false | % FileCheck % s - check - prefix = OVERRIDE_SYNTHESIZED_4 <nl> <nl> @ objc <nl> class TagPA { } <nl> struct MissingAssoc : AssocAndMethod { <nl> / / MISSING_ASSOC_1 - DAG : Decl [ InstanceMethod ] / Super : f2 ( _ : U ) { | } ; <nl> / / MISSING_ASSOC_1 - DAG : Decl [ InstanceMethod ] / Super : f3 ( _ : V ) { | } ; <nl> / / MISSING_ASSOC_1 : End completions <nl> + <nl> + / / Test that we don ' t skip out on synthesized conformance members . <nl> + <nl> + struct SynthesizedConformance1 : Codable { <nl> + let foo : Int <nl> + # ^ OVERRIDE_SYNTHESIZED_1 ^ # <nl> + / / OVERRIDE_SYNTHESIZED_1 : Begin completions , 2 items <nl> + / / OVERRIDE_SYNTHESIZED_1 - DAG : Decl [ Constructor ] / Super : init ( from decoder : Decoder ) throws { | } ; <nl> + / / OVERRIDE_SYNTHESIZED_1 - DAG : Decl [ InstanceMethod ] / Super : func encode ( to encoder : Encoder ) throws { | } ; <nl> + } <nl> + <nl> + open class SynthesizedConformance2 : Codable { <nl> + let foo : Int <nl> + func encode ( to encoder : Encoder ) throws { } <nl> + # ^ OVERRIDE_SYNTHESIZED_2 ^ # <nl> + / / OVERRIDE_SYNTHESIZED_2 : Begin completions , 1 items <nl> + / / OVERRIDE_SYNTHESIZED_2 : Decl [ Constructor ] / Super : public required init ( from decoder : Decoder ) throws { | } ; <nl> + } <nl> + <nl> + struct SynthesizedConformance3 : Hashable { <nl> + let foo : Int <nl> + # ^ OVERRIDE_SYNTHESIZED_3 ^ # <nl> + / / FIXME : Where did Equatable . ( = = ) go ? <nl> + / / OVERRIDE_SYNTHESIZED_3 : Begin completions , 2 items <nl> + / / OVERRIDE_SYNTHESIZED_3 - DAG : Decl [ InstanceVar ] / Super : var hashValue : Int ; name = hashValue : Int <nl> + / / OVERRIDE_SYNTHESIZED_3 - DAG : Decl [ InstanceMethod ] / Super : func hash ( into hasher : inout Hasher ) { | } <nl> + } <nl> + <nl> + enum SynthesizedConformance4 : CaseIterable { <nl> + case a , b , c , d <nl> + # ^ OVERRIDE_SYNTHESIZED_4 ^ # <nl> + / / OVERRIDE_SYNTHESIZED_4 : Begin completions , 4 items <nl> + / / OVERRIDE_SYNTHESIZED_4 - DAG : Decl [ InstanceVar ] / Super : var hashValue : Int <nl> + / / OVERRIDE_SYNTHESIZED_4 - DAG : Decl [ InstanceMethod ] / Super : func hash ( into hasher : inout Hasher ) { | } ; <nl> + / / OVERRIDE_SYNTHESIZED_4 - DAG : Decl [ StaticVar ] / Super : static var allCases : [ SynthesizedConformance4 ] ; <nl> + / / OVERRIDE_SYNTHESIZED_4 - DAG : Decl [ AssociatedType ] / Super : typealias AllCases = { # ( Type ) # } ; <nl> + } <nl> + <nl> + class SynthesizedConformance5 : SynthesizedConformance2 { <nl> + # ^ OVERRIDE_SYNTHESIZED_5 ^ # <nl> + / / OVERRIDE_SYNTHESIZED_5 : Begin completions , 2 items <nl> + / / OVERRIDE_SYNTHESIZED_5 - DAG : Decl [ InstanceMethod ] / Super : override func encode ( to encoder : Encoder ) throws { | } ; <nl> + / / OVERRIDE_SYNTHESIZED_5 - DAG : Decl [ Constructor ] / Super : required init ( from decoder : Decoder ) throws { | } ; <nl> + } <nl> | Merge pull request from AnthonyLatsis / derived - conf - override - compl | apple/swift | 3d26b07883c9b21a1c1228baf1d9f29c7a51c161 | 2020-03-28T23:00:32Z |
mmm a / include / swift / SILOptimizer / Utils / LoadStoreOptUtils . h <nl> ppp b / include / swift / SILOptimizer / Utils / LoadStoreOptUtils . h <nl> static inline llvm : : hash_code hash_value ( const LSValue & V ) { <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> / / Load Store Location <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> - using LSLocationSet = llvm : : DenseSet < LSLocation > ; <nl> using LSLocationList = llvm : : SmallVector < LSLocation , 8 > ; <nl> using LSLocationIndexMap = llvm : : SmallDenseMap < LSLocation , unsigned , 32 > ; <nl> using LSLocationBaseMap = llvm : : DenseMap < SILValue , LSLocation > ; <nl> class LSLocation : public LSBase { <nl> <nl> / / / Given a set of locations derived from the same base , try to merge / reduce <nl> / / / them into smallest number of LSLocations possible . <nl> - static bool reduce ( LSLocation Base , SILModule * Mod , LSLocationSet & Locs ) ; <nl> + static void reduce ( LSLocation Base , SILModule * Mod , LSLocationList & Locs ) ; <nl> <nl> / / / Enumerate the given Mem LSLocation . <nl> static void enumerateLSLocation ( SILModule * M , SILValue Mem , <nl> mmm a / lib / SILOptimizer / Transforms / DeadStoreElimination . cpp <nl> ppp b / lib / SILOptimizer / Transforms / DeadStoreElimination . cpp <nl> class BlockState { <nl> SmallBitVector BBDeallocateLocation ; <nl> <nl> / / / The dead stores in the current basic block . <nl> - llvm : : DenseSet < SILInstruction * > DeadStores ; <nl> + llvm : : SmallVector < SILInstruction * , 2 > DeadStores ; <nl> <nl> / / / Keeps track of what stores to generate after the data flow stabilizes . <nl> / / / these stores come from partial dead stores . <nl> void DSEContext : : processWrite ( SILInstruction * I , SILValue Val , SILValue Mem , <nl> / / instruction is dead . <nl> if ( Dead ) { <nl> LLVM_DEBUG ( llvm : : dbgs ( ) < < " Instruction Dead : " < < * I < < " \ n " ) ; <nl> - S - > DeadStores . insert ( I ) ; <nl> + S - > DeadStores . push_back ( I ) ; <nl> + + NumDeadStores ; <nl> return ; <nl> } <nl> void DSEContext : : processWrite ( SILInstruction * I , SILValue Val , SILValue Mem , <nl> / / Partial dead store - stores to some locations are dead , but not all . This <nl> / / is a partially dead store . Also at this point we know what locations are <nl> / / dead . <nl> - llvm : : DenseSet < LSLocation > Alives ; <nl> + LSLocationList Alives ; <nl> if ( V . any ( ) ) { <nl> / / Take out locations that are dead . <nl> for ( unsigned i = 0 ; i < V . size ( ) ; + + i ) { <nl> if ( V . test ( i ) ) <nl> continue ; <nl> / / This location is alive . <nl> - Alives . insert ( Locs [ i ] ) ; <nl> + Alives . push_back ( Locs [ i ] ) ; <nl> } <nl> <nl> / / Try to create as few aggregated stores as possible out of the locations . <nl> void DSEContext : : processWrite ( SILInstruction * I , SILValue Val , SILValue Mem , <nl> <nl> / / Lastly , mark the old store as dead . <nl> LLVM_DEBUG ( llvm : : dbgs ( ) < < " Instruction Partially Dead : " < < * I < < " \ n " ) ; <nl> - S - > DeadStores . insert ( I ) ; <nl> + S - > DeadStores . push_back ( I ) ; <nl> + + NumPartialDeadStores ; <nl> } <nl> } <nl> mmm a / lib / SILOptimizer / Transforms / RedundantLoadElimination . cpp <nl> ppp b / lib / SILOptimizer / Transforms / RedundantLoadElimination . cpp <nl> class BlockState { <nl> <nl> namespace { <nl> <nl> - using BBValueMap = llvm : : DenseMap < SILBasicBlock * , SILValue > ; <nl> - <nl> / / / This class stores global state that we use when computing redundant load and <nl> / / / their replacement in each basic block . <nl> class RLEContext { <nl> BlockState : : ValueState BlockState : : getValueStateAtEndOfBlock ( RLEContext & Ctx , <nl> <nl> SILValue RLEContext : : computePredecessorLocationValue ( SILBasicBlock * BB , <nl> LSLocation & L ) { <nl> - BBValueMap Values ; <nl> + llvm : : SmallVector < std : : pair < SILBasicBlock * , SILValue > , 8 > Values ; <nl> llvm : : DenseSet < SILBasicBlock * > HandledBBs ; <nl> llvm : : SmallVector < SILBasicBlock * , 8 > WorkList ; <nl> <nl> SILValue RLEContext : : computePredecessorLocationValue ( SILBasicBlock * BB , <nl> / / locations , collect and reduce them into a single value in the current <nl> / / basic block . <nl> if ( Forwarder . isConcreteValues ( * this , L ) ) { <nl> - Values [ CurBB ] = Forwarder . reduceValuesAtEndOfBlock ( * this , L ) ; <nl> + Values . push_back ( { CurBB , Forwarder . reduceValuesAtEndOfBlock ( * this , L ) } ) ; <nl> continue ; <nl> } <nl> <nl> SILValue RLEContext : : computePredecessorLocationValue ( SILBasicBlock * BB , <nl> <nl> / / Reduce the available values into a single SILValue we can use to forward <nl> SILInstruction * IPt = CurBB - > getTerminator ( ) ; <nl> - Values [ CurBB ] = LSValue : : reduce ( L , & BB - > getModule ( ) , LSValues , IPt ) ; <nl> + Values . push_back ( { CurBB , LSValue : : reduce ( L , & BB - > getModule ( ) , LSValues , IPt ) } ) ; <nl> } <nl> <nl> / / Finally , collect all the values for the SILArgument , materialize it using <nl> SILValue RLEContext : : computePredecessorLocationValue ( SILBasicBlock * BB , <nl> bool RLEContext : : collectLocationValues ( SILBasicBlock * BB , LSLocation & L , <nl> LSLocationValueMap & Values , <nl> ValueTableMap & VM ) { <nl> - LSLocationSet CSLocs ; <nl> + LSLocationList CSLocs ; <nl> LSLocationList Locs ; <nl> LSLocation : : expand ( L , & BB - > getModule ( ) , Locs , TE ) ; <nl> <nl> bool RLEContext : : collectLocationValues ( SILBasicBlock * BB , LSLocation & L , <nl> Values [ X ] = getValue ( VM [ getLocationBit ( X ) ] ) ; <nl> if ( ! Values [ X ] . isCoveringValue ( ) ) <nl> continue ; <nl> - CSLocs . insert ( X ) ; <nl> + CSLocs . push_back ( X ) ; <nl> } <nl> <nl> / / For locations which we do not have concrete values for in this basic <nl> bool RLEContext : : run ( ) { <nl> processBasicBlocksForRLE ( Optimistic ) ; <nl> <nl> / / Finally , perform the redundant load replacements . <nl> - llvm : : DenseSet < SILInstruction * > InstsToDelete ; <nl> + llvm : : SmallVector < SILInstruction * , 16 > InstsToDelete ; <nl> bool SILChanged = false ; <nl> for ( auto & B : * Fn ) { <nl> auto & State = BBToLocState [ & B ] ; <nl> bool RLEContext : : run ( ) { <nl> < < " With " < < Iter - > second ) ; <nl> SILChanged = true ; <nl> Iter - > first - > replaceAllUsesWith ( Iter - > second ) ; <nl> - InstsToDelete . insert ( Iter - > first ) ; <nl> + InstsToDelete . push_back ( Iter - > first ) ; <nl> + + NumForwardedLoads ; <nl> } <nl> } <nl> mmm a / lib / SILOptimizer / UtilityPasses / LSLocationPrinter . cpp <nl> ppp b / lib / SILOptimizer / UtilityPasses / LSLocationPrinter . cpp <nl> class LSLocationPrinter : public SILModuleTransform { <nl> void printMemReduction ( SILFunction & Fn ) { <nl> LSLocation L ; <nl> LSLocationList Locs ; <nl> - llvm : : DenseSet < LSLocation > SLocs ; <nl> + LSLocationList SLocs ; <nl> unsigned Counter = 0 ; <nl> for ( auto & BB : Fn ) { <nl> for ( auto & II : BB ) { <nl> class LSLocationPrinter : public SILModuleTransform { <nl> / / Reduction should not care about the order of the memory locations in <nl> / / the set . <nl> for ( auto I = Locs . begin ( ) ; I ! = Locs . end ( ) ; + + I ) { <nl> - SLocs . insert ( * I ) ; <nl> + SLocs . push_back ( * I ) ; <nl> } <nl> <nl> / / This should get the original ( unexpanded ) location back . <nl> mmm a / lib / SILOptimizer / Utils / LoadStoreOptUtils . cpp <nl> ppp b / lib / SILOptimizer / Utils / LoadStoreOptUtils . cpp <nl> LSLocation : : expand ( LSLocation Base , SILModule * M , LSLocationList & Locs , <nl> } <nl> } <nl> <nl> - bool <nl> - LSLocation : : reduce ( LSLocation Base , SILModule * M , LSLocationSet & Locs ) { <nl> + / / / Gets the sub - locations of \ p Base in \ p SubLocations . <nl> + / / / Returns false if this is not possible or too complex . <nl> + static bool <nl> + getSubLocations ( LSLocationList & SubLocations , LSLocation Base , SILModule * M , <nl> + const LSLocationList & Locs ) { <nl> / / If this is a class reference type , we have reached end of the type tree . <nl> if ( Base . getType ( M ) . getClassOrBoundGenericClass ( ) ) <nl> - return Locs . find ( Base ) ! = Locs . end ( ) ; <nl> + return false ; <nl> <nl> - / / This a don ' t expand node . <nl> - if ( ! shouldExpand ( * M , Base . getType ( M ) ) ) { <nl> - return Locs . find ( Base ) ! = Locs . end ( ) ; <nl> + / / Don ' t expand if it would be too complex . As Locs is a list ( and not a set ) <nl> + / / we want to avoid quadratic complexity in replaceInner ( ) . <nl> + / / Usually Locs is small anyway , because we limit expansion to 6 members . <nl> + / / But with deeply nested types we could run in a corner case where Locs is <nl> + / / large . <nl> + if ( ! shouldExpand ( * M , Base . getType ( M ) ) | | Locs . size ( ) > = 8 ) { <nl> + return false ; <nl> } <nl> <nl> / / This is a leaf node . <nl> - LSLocationList NextLevel ; <nl> - Base . getNextLevelLSLocations ( NextLevel , M ) ; <nl> - if ( NextLevel . empty ( ) ) <nl> - return Locs . find ( Base ) ! = Locs . end ( ) ; <nl> + Base . getNextLevelLSLocations ( SubLocations , M ) ; <nl> + return ! SubLocations . empty ( ) ; <nl> + } <nl> <nl> - / / This is not a leaf node , try to find whether all its children are alive . <nl> + / / / Replaces \ p SubLocations with \ p Base in \ p Locs if all sub - locations are <nl> + / / / alive , i . e . present in \ p Locs . <nl> + static bool <nl> + replaceSubLocations ( LSLocation Base , SILModule * M , LSLocationList & Locs , <nl> + const LSLocationList & SubLocations ) { <nl> + / / Find whether all its children of Base are alive . <nl> bool Alive = true ; <nl> - for ( auto & X : NextLevel ) { <nl> - Alive & = LSLocation : : reduce ( X , M , Locs ) ; <nl> + for ( auto & X : SubLocations ) { <nl> + / / Recurse into the next level . <nl> + LSLocationList NextInnerLevel ; <nl> + if ( getSubLocations ( NextInnerLevel , X , M , Locs ) ) { <nl> + Alive & = replaceSubLocations ( X , M , Locs , NextInnerLevel ) ; <nl> + } else { <nl> + Alive & = is_contained ( Locs , X ) ; <nl> + } <nl> } <nl> <nl> / / All next level locations are alive , create the new aggregated location . <nl> - if ( Alive ) { <nl> - for ( auto & X : NextLevel ) <nl> - Locs . erase ( X ) ; <nl> - Locs . insert ( Base ) ; <nl> - } <nl> - return Alive ; <nl> + if ( ! Alive ) <nl> + return false ; <nl> + <nl> + auto newEnd = std : : remove_if ( Locs . begin ( ) , Locs . end ( ) , [ & ] ( const LSLocation & L ) { <nl> + return is_contained ( SubLocations , L ) ; <nl> + } ) ; <nl> + Locs . erase ( newEnd , Locs . end ( ) ) ; <nl> + Locs . push_back ( Base ) ; <nl> + return true ; <nl> + } <nl> + <nl> + void LSLocation : : reduce ( LSLocation Base , SILModule * M , LSLocationList & Locs ) { <nl> + LSLocationList SubLocations ; <nl> + if ( getSubLocations ( SubLocations , Base , M , Locs ) ) <nl> + replaceSubLocations ( Base , M , Locs , SubLocations ) ; <nl> } <nl> <nl> void <nl> | Merge remote - tracking branch ' origin / master ' into master - next | apple/swift | 8ecd2ba03cbe5e612ee46f914db9729c11953129 | 2018-10-01T23:49:19Z |
mmm a / dbms / include / DB / Functions / FunctionsDictionaries . h <nl> ppp b / dbms / include / DB / Functions / FunctionsDictionaries . h <nl> struct CategoryHierarchyImpl <nl> } ; <nl> <nl> <nl> + / * * Вспомогательная вещь , позволяющая достать из словаря конкретный словарь , соответствующий точке зрения <nl> + * ( ключу словаря , передаваемому в аргументе функции ) . <nl> + * Пример : при вызове regionToCountry ( x , ' ua ' ) , может быть использован словарь , в котором Крым относится к Украине . <nl> + * / <nl> + struct RegionsHierarchyGetter <nl> + { <nl> + typedef RegionsHierarchies Src ; <nl> + typedef RegionsHierarchy Dst ; <nl> + <nl> + static const Dst & get ( const Src & src , const std : : string & key ) <nl> + { <nl> + return src . get ( key ) ; <nl> + } <nl> + } ; <nl> + <nl> + / * * Для словарей без поддержки ключей . Ничего не делает . <nl> + * / <nl> + template < typename Dict > <nl> + struct IdentityDictionaryGetter <nl> + { <nl> + typedef Dict Src ; <nl> + typedef Dict Dst ; <nl> + <nl> + static const Dst & get ( const Src & src , const std : : string & key ) <nl> + { <nl> + if ( key . empty ( ) ) <nl> + return src ; <nl> + else <nl> + throw Exception ( " Dictionary doesn ' t support ' point of view ' keys . " , ErrorCodes : : BAD_ARGUMENTS ) ; <nl> + } <nl> + } ; <nl> + <nl> + <nl> / / / Преобразует идентификатор , используя словарь . <nl> - template < typename T , typename Transform , typename Dict , typename Name > <nl> + template < typename T , typename Transform , typename Dict , typename DictGetter , typename Name > <nl> class FunctionTransformWithDictionary : public IFunction <nl> { <nl> private : <nl> class FunctionTransformWithDictionary : public IFunction <nl> / / / Получить тип результата по типам аргументов . Если функция неприменима для данных аргументов - кинуть исключение . <nl> DataTypePtr getReturnType ( const DataTypes & arguments ) const <nl> { <nl> - if ( arguments . size ( ) ! = 1 ) <nl> + if ( arguments . size ( ) ! = 1 & & arguments . size ( ) ! = 2 ) <nl> throw Exception ( " Number of arguments for function " + getName ( ) + " doesn ' t match : passed " <nl> - + toString ( arguments . size ( ) ) + " , should be 1 . " , <nl> + + toString ( arguments . size ( ) ) + " , should be 1 or 2 . " , <nl> ErrorCodes : : NUMBER_OF_ARGUMENTS_DOESNT_MATCH ) ; <nl> <nl> if ( arguments [ 0 ] - > getName ( ) ! = TypeName < T > : : get ( ) ) <nl> class FunctionTransformWithDictionary : public IFunction <nl> + " ( must be " + TypeName < T > : : get ( ) + " ) " , <nl> ErrorCodes : : ILLEGAL_TYPE_OF_ARGUMENT ) ; <nl> <nl> + if ( arguments . size ( ) = = 2 & & arguments [ 1 ] - > getName ( ) ! = TypeName < String > : : get ( ) ) <nl> + throw Exception ( " Illegal type " + arguments [ 1 ] - > getName ( ) + " of the second ( ' point of view ' ) argument of function " + getName ( ) <nl> + + " ( must be " + TypeName < String > : : get ( ) + " ) " , <nl> + ErrorCodes : : ILLEGAL_TYPE_OF_ARGUMENT ) ; <nl> + <nl> return arguments [ 0 ] ; <nl> } <nl> <nl> / / / Выполнить функцию над блоком . <nl> void execute ( Block & block , const ColumnNumbers & arguments , size_t result ) <nl> { <nl> + / / / Ключ словаря , определяющий " точку зрения " . <nl> + std : : string dict_key ; <nl> + <nl> + if ( arguments . size ( ) = = 2 ) <nl> + { <nl> + const ColumnConstString * key_col = dynamic_cast < const ColumnConstString * > ( & * block . getByPosition ( arguments [ 1 ] ) . column ) ; <nl> + <nl> + if ( ! key_col ) <nl> + throw Exception ( " Illegal column " + block . getByPosition ( arguments [ 1 ] ) . column - > getName ( ) <nl> + + " of second ( ' point of view ' ) argument of function " + Name : : get ( ) <nl> + + " . Must be constant string . " , <nl> + ErrorCodes : : ILLEGAL_COLUMN ) ; <nl> + <nl> + dict_key = key_col - > getData ( ) ; <nl> + } <nl> + <nl> + const typename DictGetter : : Dst & dict = DictGetter : : get ( * owned_dict , dict_key ) ; <nl> + <nl> if ( const ColumnVector < T > * col_from = dynamic_cast < const ColumnVector < T > * > ( & * block . getByPosition ( arguments [ 0 ] ) . column ) ) <nl> { <nl> ColumnVector < T > * col_to = new ColumnVector < T > ; <nl> class FunctionTransformWithDictionary : public IFunction <nl> size_t size = vec_from . size ( ) ; <nl> vec_to . resize ( size ) ; <nl> <nl> - const Dict & dict = * owned_dict ; <nl> for ( size_t i = 0 ; i < size ; + + i ) <nl> vec_to [ i ] = Transform : : apply ( vec_from [ i ] , dict ) ; <nl> } <nl> else if ( const ColumnConst < T > * col_from = dynamic_cast < const ColumnConst < T > * > ( & * block . getByPosition ( arguments [ 0 ] ) . column ) ) <nl> { <nl> - block . getByPosition ( result ) . column = new ColumnConst < T > ( col_from - > size ( ) , Transform : : apply ( col_from - > getData ( ) , * owned_dict ) ) ; <nl> + block . getByPosition ( result ) . column = new ColumnConst < T > ( col_from - > size ( ) , Transform : : apply ( col_from - > getData ( ) , dict ) ) ; <nl> } <nl> else <nl> throw Exception ( " Illegal column " + block . getByPosition ( arguments [ 0 ] ) . column - > getName ( ) <nl> class FunctionTransformWithDictionary : public IFunction <nl> <nl> <nl> / / / Проверяет принадлежность , используя словарь . <nl> - template < typename T , typename Transform , typename Dict , typename Name > <nl> + template < typename T , typename Transform , typename Dict , typename DictGetter , typename Name > <nl> class FunctionIsInWithDictionary : public IFunction <nl> { <nl> private : <nl> class FunctionIsInWithDictionary : public IFunction <nl> / / / Получить тип результата по типам аргументов . Если функция неприменима для данных аргументов - кинуть исключение . <nl> DataTypePtr getReturnType ( const DataTypes & arguments ) const <nl> { <nl> - if ( arguments . size ( ) ! = 2 ) <nl> + if ( arguments . size ( ) ! = 2 & & arguments . size ( ) ! = 3 ) <nl> throw Exception ( " Number of arguments for function " + getName ( ) + " doesn ' t match : passed " <nl> - + toString ( arguments . size ( ) ) + " , should be 1 . " , <nl> + + toString ( arguments . size ( ) ) + " , should be 2 or 3 . " , <nl> ErrorCodes : : NUMBER_OF_ARGUMENTS_DOESNT_MATCH ) ; <nl> <nl> if ( arguments [ 0 ] - > getName ( ) ! = TypeName < T > : : get ( ) ) <nl> class FunctionIsInWithDictionary : public IFunction <nl> + " ( must be " + TypeName < T > : : get ( ) + " ) " , <nl> ErrorCodes : : ILLEGAL_TYPE_OF_ARGUMENT ) ; <nl> <nl> + if ( arguments . size ( ) = = 3 & & arguments [ 2 ] - > getName ( ) ! = TypeName < String > : : get ( ) ) <nl> + throw Exception ( " Illegal type " + arguments [ 2 ] - > getName ( ) + " of the third ( ' point of view ' ) argument of function " + getName ( ) <nl> + + " ( must be " + TypeName < String > : : get ( ) + " ) " , <nl> + ErrorCodes : : ILLEGAL_TYPE_OF_ARGUMENT ) ; <nl> + <nl> return new DataTypeUInt8 ; <nl> } <nl> <nl> / / / Выполнить функцию над блоком . <nl> void execute ( Block & block , const ColumnNumbers & arguments , size_t result ) <nl> { <nl> + / / / Ключ словаря , определяющий " точку зрения " . <nl> + std : : string dict_key ; <nl> + <nl> + if ( arguments . size ( ) = = 3 ) <nl> + { <nl> + const ColumnConstString * key_col = dynamic_cast < const ColumnConstString * > ( & * block . getByPosition ( arguments [ 2 ] ) . column ) ; <nl> + <nl> + if ( ! key_col ) <nl> + throw Exception ( " Illegal column " + block . getByPosition ( arguments [ 2 ] ) . column - > getName ( ) <nl> + + " of third ( ' point of view ' ) argument of function " + Name : : get ( ) <nl> + + " . Must be constant string . " , <nl> + ErrorCodes : : ILLEGAL_COLUMN ) ; <nl> + <nl> + dict_key = key_col - > getData ( ) ; <nl> + } <nl> + <nl> + const typename DictGetter : : Dst & dict = DictGetter : : get ( * owned_dict , dict_key ) ; <nl> + <nl> const ColumnVector < T > * col_vec1 = dynamic_cast < const ColumnVector < T > * > ( & * block . getByPosition ( arguments [ 0 ] ) . column ) ; <nl> const ColumnVector < T > * col_vec2 = dynamic_cast < const ColumnVector < T > * > ( & * block . getByPosition ( arguments [ 1 ] ) . column ) ; <nl> const ColumnConst < T > * col_const1 = dynamic_cast < const ColumnConst < T > * > ( & * block . getByPosition ( arguments [ 0 ] ) . column ) ; <nl> class FunctionIsInWithDictionary : public IFunction <nl> size_t size = vec_from1 . size ( ) ; <nl> vec_to . resize ( size ) ; <nl> <nl> - const Dict & dict = * owned_dict ; <nl> for ( size_t i = 0 ; i < size ; + + i ) <nl> vec_to [ i ] = Transform : : apply ( vec_from1 [ i ] , vec_from2 [ i ] , dict ) ; <nl> } <nl> class FunctionIsInWithDictionary : public IFunction <nl> size_t size = vec_from1 . size ( ) ; <nl> vec_to . resize ( size ) ; <nl> <nl> - const Dict & dict = * owned_dict ; <nl> for ( size_t i = 0 ; i < size ; + + i ) <nl> vec_to [ i ] = Transform : : apply ( vec_from1 [ i ] , const_from2 , dict ) ; <nl> } <nl> class FunctionIsInWithDictionary : public IFunction <nl> size_t size = vec_from2 . size ( ) ; <nl> vec_to . resize ( size ) ; <nl> <nl> - const Dict & dict = * owned_dict ; <nl> for ( size_t i = 0 ; i < size ; + + i ) <nl> vec_to [ i ] = Transform : : apply ( const_from1 , vec_from2 [ i ] , dict ) ; <nl> } <nl> else if ( col_const1 & & col_const2 ) <nl> { <nl> block . getByPosition ( result ) . column = new ColumnConst < UInt8 > ( col_const1 - > size ( ) , <nl> - Transform : : apply ( col_const1 - > getData ( ) , col_const2 - > getData ( ) , * owned_dict ) ) ; <nl> + Transform : : apply ( col_const1 - > getData ( ) , col_const2 - > getData ( ) , dict ) ) ; <nl> } <nl> else <nl> throw Exception ( " Illegal columns " + block . getByPosition ( arguments [ 0 ] ) . column - > getName ( ) <nl> class FunctionIsInWithDictionary : public IFunction <nl> <nl> <nl> / / / Получает массив идентификаторов , состоящий из исходного и цепочки родителей . <nl> - template < typename T , typename Transform , typename Dict , typename Name > <nl> + template < typename T , typename Transform , typename Dict , typename DictGetter , typename Name > <nl> class FunctionHierarchyWithDictionary : public IFunction <nl> { <nl> private : <nl> class FunctionHierarchyWithDictionary : public IFunction <nl> / / / Получить тип результата по типам аргументов . Если функция неприменима для данных аргументов - кинуть исключение . <nl> DataTypePtr getReturnType ( const DataTypes & arguments ) const <nl> { <nl> - if ( arguments . size ( ) ! = 1 ) <nl> + if ( arguments . size ( ) ! = 1 & & arguments . size ( ) ! = 2 ) <nl> throw Exception ( " Number of arguments for function " + getName ( ) + " doesn ' t match : passed " <nl> - + toString ( arguments . size ( ) ) + " , should be 1 . " , <nl> - ErrorCodes : : NUMBER_OF_ARGUMENTS_DOESNT_MATCH ) ; <nl> + + toString ( arguments . size ( ) ) + " , should be 1 or 2 . " , <nl> + ErrorCodes : : NUMBER_OF_ARGUMENTS_DOESNT_MATCH ) ; <nl> <nl> if ( arguments [ 0 ] - > getName ( ) ! = TypeName < T > : : get ( ) ) <nl> throw Exception ( " Illegal type " + arguments [ 0 ] - > getName ( ) + " of argument of function " + getName ( ) <nl> + " ( must be " + TypeName < T > : : get ( ) + " ) " , <nl> ErrorCodes : : ILLEGAL_TYPE_OF_ARGUMENT ) ; <nl> + <nl> + if ( arguments . size ( ) = = 2 & & arguments [ 1 ] - > getName ( ) ! = TypeName < String > : : get ( ) ) <nl> + throw Exception ( " Illegal type " + arguments [ 1 ] - > getName ( ) + " of the second ( ' point of view ' ) argument of function " + getName ( ) <nl> + + " ( must be " + TypeName < String > : : get ( ) + " ) " , <nl> + ErrorCodes : : ILLEGAL_TYPE_OF_ARGUMENT ) ; <nl> <nl> return new DataTypeArray ( arguments [ 0 ] ) ; <nl> } <nl> class FunctionHierarchyWithDictionary : public IFunction <nl> / / / Выполнить функцию над блоком . <nl> void execute ( Block & block , const ColumnNumbers & arguments , size_t result ) <nl> { <nl> + / / / Ключ словаря , определяющий " точку зрения " . <nl> + std : : string dict_key ; <nl> + <nl> + if ( arguments . size ( ) = = 2 ) <nl> + { <nl> + const ColumnConstString * key_col = dynamic_cast < const ColumnConstString * > ( & * block . getByPosition ( arguments [ 1 ] ) . column ) ; <nl> + <nl> + if ( ! key_col ) <nl> + throw Exception ( " Illegal column " + block . getByPosition ( arguments [ 1 ] ) . column - > getName ( ) <nl> + + " of second ( ' point of view ' ) argument of function " + Name : : get ( ) <nl> + + " . Must be constant string . " , <nl> + ErrorCodes : : ILLEGAL_COLUMN ) ; <nl> + <nl> + dict_key = key_col - > getData ( ) ; <nl> + } <nl> + <nl> + const typename DictGetter : : Dst & dict = DictGetter : : get ( * owned_dict , dict_key ) ; <nl> + <nl> if ( const ColumnVector < T > * col_from = dynamic_cast < const ColumnVector < T > * > ( & * block . getByPosition ( arguments [ 0 ] ) . column ) ) <nl> { <nl> ColumnVector < T > * col_values = new ColumnVector < T > ; <nl> class FunctionHierarchyWithDictionary : public IFunction <nl> res_offsets . resize ( size ) ; <nl> res_values . reserve ( size * 4 ) ; <nl> <nl> - const Dict & dict = * owned_dict ; <nl> for ( size_t i = 0 ; i < size ; + + i ) <nl> { <nl> T cur = vec_from [ i ] ; <nl> class FunctionHierarchyWithDictionary : public IFunction <nl> { <nl> Array res ; <nl> <nl> - const Dict & dict = * owned_dict ; <nl> T cur = col_from - > getData ( ) ; <nl> while ( cur ) <nl> { <nl> struct NameSEHierarchy { static const char * get ( ) { return " SEHierarchy " ; } } ; <nl> struct NameCategoryHierarchy { static const char * get ( ) { return " categoryHierarchy " ; } } ; <nl> <nl> <nl> - typedef FunctionTransformWithDictionary < UInt32 , RegionToCityImpl , RegionsHierarchy , NameRegionToCity > FunctionRegionToCity ; <nl> - typedef FunctionTransformWithDictionary < UInt32 , RegionToAreaImpl , RegionsHierarchy , NameRegionToArea > FunctionRegionToArea ; <nl> - typedef FunctionTransformWithDictionary < UInt32 , RegionToCountryImpl , RegionsHierarchy , NameRegionToCountry > FunctionRegionToCountry ; <nl> - typedef FunctionTransformWithDictionary < UInt32 , RegionToContinentImpl , RegionsHierarchy , NameRegionToContinent > FunctionRegionToContinent ; <nl> - typedef FunctionTransformWithDictionary < UInt8 , OSToRootImpl , TechDataHierarchy , NameOSToRoot > FunctionOSToRoot ; <nl> - typedef FunctionTransformWithDictionary < UInt8 , SEToRootImpl , TechDataHierarchy , NameSEToRoot > FunctionSEToRoot ; <nl> - typedef FunctionTransformWithDictionary < UInt16 , CategoryToRootImpl , CategoriesHierarchy , NameCategoryToRoot > FunctionCategoryToRoot ; <nl> - typedef FunctionTransformWithDictionary < UInt16 , CategoryToSecondLevelImpl , CategoriesHierarchy , NameCategoryToSecondLevel > FunctionCategoryToSecondLevel ; <nl> + typedef FunctionTransformWithDictionary <nl> + < UInt32 , RegionToCityImpl , RegionsHierarchies , RegionsHierarchyGetter , NameRegionToCity > FunctionRegionToCity ; <nl> + <nl> + typedef FunctionTransformWithDictionary <nl> + < UInt32 , RegionToAreaImpl , RegionsHierarchies , RegionsHierarchyGetter , NameRegionToArea > FunctionRegionToArea ; <nl> + <nl> + typedef FunctionTransformWithDictionary <nl> + < UInt32 , RegionToCountryImpl , RegionsHierarchies , RegionsHierarchyGetter , NameRegionToCountry > FunctionRegionToCountry ; <nl> + <nl> + typedef FunctionTransformWithDictionary <nl> + < UInt32 , RegionToContinentImpl , RegionsHierarchies , RegionsHierarchyGetter , NameRegionToContinent > FunctionRegionToContinent ; <nl> + <nl> + typedef FunctionTransformWithDictionary <nl> + < UInt8 , OSToRootImpl , TechDataHierarchy , IdentityDictionaryGetter < TechDataHierarchy > , NameOSToRoot > FunctionOSToRoot ; <nl> + <nl> + typedef FunctionTransformWithDictionary <nl> + < UInt8 , SEToRootImpl , TechDataHierarchy , IdentityDictionaryGetter < TechDataHierarchy > , NameSEToRoot > FunctionSEToRoot ; <nl> + <nl> + typedef FunctionTransformWithDictionary <nl> + < UInt16 , CategoryToRootImpl , CategoriesHierarchy , IdentityDictionaryGetter < CategoriesHierarchy > , NameCategoryToRoot > FunctionCategoryToRoot ; <nl> + <nl> + typedef FunctionTransformWithDictionary <nl> + < UInt16 , CategoryToSecondLevelImpl , CategoriesHierarchy , IdentityDictionaryGetter < CategoriesHierarchy > , NameCategoryToSecondLevel > <nl> + FunctionCategoryToSecondLevel ; <nl> <nl> - typedef FunctionIsInWithDictionary < UInt32 , RegionInImpl , RegionsHierarchy , NameRegionIn > FunctionRegionIn ; <nl> - typedef FunctionIsInWithDictionary < UInt8 , OSInImpl , TechDataHierarchy , NameOSIn > FunctionOSIn ; <nl> - typedef FunctionIsInWithDictionary < UInt8 , SEInImpl , TechDataHierarchy , NameSEIn > FunctionSEIn ; <nl> - typedef FunctionIsInWithDictionary < UInt16 , CategoryInImpl , CategoriesHierarchy , NameCategoryIn > FunctionCategoryIn ; <nl> + typedef FunctionIsInWithDictionary <nl> + < UInt32 , RegionInImpl , RegionsHierarchies , RegionsHierarchyGetter , NameRegionIn > FunctionRegionIn ; <nl> <nl> - typedef FunctionHierarchyWithDictionary < UInt32 , RegionHierarchyImpl , RegionsHierarchy , NameRegionHierarchy > FunctionRegionHierarchy ; <nl> - typedef FunctionHierarchyWithDictionary < UInt8 , OSHierarchyImpl , TechDataHierarchy , NameOSHierarchy > FunctionOSHierarchy ; <nl> - typedef FunctionHierarchyWithDictionary < UInt8 , SEHierarchyImpl , TechDataHierarchy , NameSEHierarchy > FunctionSEHierarchy ; <nl> - typedef FunctionHierarchyWithDictionary < UInt16 , CategoryHierarchyImpl , CategoriesHierarchy , NameCategoryHierarchy > FunctionCategoryHierarchy ; <nl> + typedef FunctionIsInWithDictionary <nl> + < UInt8 , OSInImpl , TechDataHierarchy , IdentityDictionaryGetter < TechDataHierarchy > , NameOSIn > FunctionOSIn ; <nl> + <nl> + typedef FunctionIsInWithDictionary <nl> + < UInt8 , SEInImpl , TechDataHierarchy , IdentityDictionaryGetter < TechDataHierarchy > , NameSEIn > FunctionSEIn ; <nl> + <nl> + typedef FunctionIsInWithDictionary <nl> + < UInt16 , CategoryInImpl , CategoriesHierarchy , IdentityDictionaryGetter < CategoriesHierarchy > , NameCategoryIn > FunctionCategoryIn ; <nl> + <nl> + typedef FunctionHierarchyWithDictionary <nl> + < UInt32 , RegionHierarchyImpl , RegionsHierarchies , RegionsHierarchyGetter , NameRegionHierarchy > FunctionRegionHierarchy ; <nl> + <nl> + typedef FunctionHierarchyWithDictionary <nl> + < UInt8 , OSHierarchyImpl , TechDataHierarchy , IdentityDictionaryGetter < TechDataHierarchy > , NameOSHierarchy > FunctionOSHierarchy ; <nl> + <nl> + typedef FunctionHierarchyWithDictionary <nl> + < UInt8 , SEHierarchyImpl , TechDataHierarchy , IdentityDictionaryGetter < TechDataHierarchy > , NameSEHierarchy > FunctionSEHierarchy ; <nl> + <nl> + typedef FunctionHierarchyWithDictionary <nl> + < UInt16 , CategoryHierarchyImpl , CategoriesHierarchy , IdentityDictionaryGetter < CategoriesHierarchy > , NameCategoryHierarchy > FunctionCategoryHierarchy ; <nl> <nl> <nl> / / / Преобразует числовой идентификатор региона в имя на заданном языке , используя словарь . <nl> class FunctionRegionToName : public IFunction <nl> + " of the second argument of function " + getName ( ) , <nl> ErrorCodes : : ILLEGAL_COLUMN ) ; <nl> } <nl> - <nl> + <nl> + const RegionsNames & dict = * owned_dict ; <nl> + <nl> if ( const ColumnVector < UInt32 > * col_from = dynamic_cast < const ColumnVector < UInt32 > * > ( & * block . getByPosition ( arguments [ 0 ] ) . column ) ) <nl> { <nl> ColumnString * col_to = new ColumnString ; <nl> class FunctionRegionToName : public IFunction <nl> <nl> const ColumnVector < UInt32 > : : Container_t & region_ids = col_from - > getData ( ) ; <nl> <nl> - const RegionsNames & dict = * owned_dict ; <nl> for ( size_t i = 0 ; i < region_ids . size ( ) ; + + i ) <nl> { <nl> const DB : : StringRef & name_ref = dict . getRegionName ( region_ids [ i ] , language ) ; <nl> class FunctionRegionToName : public IFunction <nl> else if ( const ColumnConst < UInt32 > * col_from = dynamic_cast < const ColumnConst < UInt32 > * > ( & * block . getByPosition ( arguments [ 0 ] ) . column ) ) <nl> { <nl> UInt32 region_id = col_from - > getData ( ) ; <nl> - const DB : : StringRef & name_ref = owned_dict - > getRegionName ( region_id , language ) ; <nl> + const DB : : StringRef & name_ref = dict . getRegionName ( region_id , language ) ; <nl> <nl> block . getByPosition ( result ) . column = new ColumnConstString ( col_from - > size ( ) , name_ref . toString ( ) ) ; <nl> } <nl> mmm a / dbms / include / DB / Interpreters / Dictionaries . h <nl> ppp b / dbms / include / DB / Interpreters / Dictionaries . h <nl> <nl> <nl> # include < Yandex / MultiVersion . h > <nl> # include < Yandex / logger_useful . h > <nl> - # include < statdaemons / RegionsHierarchy . h > <nl> + # include < statdaemons / RegionsHierarchies . h > <nl> # include < statdaemons / TechDataHierarchy . h > <nl> # include < statdaemons / CategoriesHierarchy . h > <nl> # include < statdaemons / RegionsNames . h > <nl> using Poco : : SharedPtr ; <nl> class Dictionaries <nl> { <nl> private : <nl> - MultiVersion < RegionsHierarchy > regions_hierarchy ; <nl> + MultiVersion < RegionsHierarchies > regions_hierarchies ; <nl> MultiVersion < TechDataHierarchy > tech_data_hierarchy ; <nl> MultiVersion < CategoriesHierarchy > categories_hierarchy ; <nl> MultiVersion < RegionsNames > regions_names ; <nl> class Dictionaries <nl> <nl> try <nl> { <nl> - MultiVersion < RegionsHierarchy > : : Version new_regions_hierarchy = new RegionsHierarchy ; <nl> - new_regions_hierarchy - > reload ( ) ; <nl> - regions_hierarchy . set ( new_regions_hierarchy ) ; <nl> + MultiVersion < RegionsHierarchies > : : Version new_regions_hierarchies = new RegionsHierarchies ; <nl> + new_regions_hierarchies - > reload ( ) ; <nl> + regions_hierarchies . set ( new_regions_hierarchies ) ; <nl> <nl> } <nl> catch ( . . . ) <nl> class Dictionaries <nl> reloading_thread . join ( ) ; <nl> } <nl> <nl> - MultiVersion < RegionsHierarchy > : : Version getRegionsHierarchy ( ) const <nl> + MultiVersion < RegionsHierarchies > : : Version getRegionsHierarchies ( ) const <nl> { <nl> - return regions_hierarchy . get ( ) ; <nl> + return regions_hierarchies . get ( ) ; <nl> } <nl> <nl> MultiVersion < TechDataHierarchy > : : Version getTechDataHierarchy ( ) const <nl> mmm a / dbms / src / Functions / FunctionFactory . cpp <nl> ppp b / dbms / src / Functions / FunctionFactory . cpp <nl> FunctionPtr FunctionFactory : : get ( <nl> <nl> else if ( name = = " if " ) return new FunctionIf ; <nl> <nl> - else if ( name = = " regionToCity " ) return new FunctionRegionToCity ( context . getDictionaries ( ) . getRegionsHierarchy ( ) ) ; <nl> - else if ( name = = " regionToArea " ) return new FunctionRegionToArea ( context . getDictionaries ( ) . getRegionsHierarchy ( ) ) ; <nl> - else if ( name = = " regionToCountry " ) return new FunctionRegionToCountry ( context . getDictionaries ( ) . getRegionsHierarchy ( ) ) ; <nl> - else if ( name = = " regionToContinent " ) return new FunctionRegionToContinent ( context . getDictionaries ( ) . getRegionsHierarchy ( ) ) ; <nl> + else if ( name = = " regionToCity " ) return new FunctionRegionToCity ( context . getDictionaries ( ) . getRegionsHierarchies ( ) ) ; <nl> + else if ( name = = " regionToArea " ) return new FunctionRegionToArea ( context . getDictionaries ( ) . getRegionsHierarchies ( ) ) ; <nl> + else if ( name = = " regionToCountry " ) return new FunctionRegionToCountry ( context . getDictionaries ( ) . getRegionsHierarchies ( ) ) ; <nl> + else if ( name = = " regionToContinent " ) return new FunctionRegionToContinent ( context . getDictionaries ( ) . getRegionsHierarchies ( ) ) ; <nl> else if ( name = = " OSToRoot " ) return new FunctionOSToRoot ( context . getDictionaries ( ) . getTechDataHierarchy ( ) ) ; <nl> else if ( name = = " SEToRoot " ) return new FunctionSEToRoot ( context . getDictionaries ( ) . getTechDataHierarchy ( ) ) ; <nl> else if ( name = = " categoryToRoot " ) return new FunctionCategoryToRoot ( context . getDictionaries ( ) . getCategoriesHierarchy ( ) ) ; <nl> else if ( name = = " categoryToSecondLevel " ) return new FunctionCategoryToSecondLevel ( context . getDictionaries ( ) . getCategoriesHierarchy ( ) ) ; <nl> - else if ( name = = " regionIn " ) return new FunctionRegionIn ( context . getDictionaries ( ) . getRegionsHierarchy ( ) ) ; <nl> + else if ( name = = " regionIn " ) return new FunctionRegionIn ( context . getDictionaries ( ) . getRegionsHierarchies ( ) ) ; <nl> else if ( name = = " OSIn " ) return new FunctionOSIn ( context . getDictionaries ( ) . getTechDataHierarchy ( ) ) ; <nl> else if ( name = = " SEIn " ) return new FunctionSEIn ( context . getDictionaries ( ) . getTechDataHierarchy ( ) ) ; <nl> else if ( name = = " categoryIn " ) return new FunctionCategoryIn ( context . getDictionaries ( ) . getCategoriesHierarchy ( ) ) ; <nl> - else if ( name = = " regionHierarchy " ) return new FunctionRegionHierarchy ( context . getDictionaries ( ) . getRegionsHierarchy ( ) ) ; <nl> + else if ( name = = " regionHierarchy " ) return new FunctionRegionHierarchy ( context . getDictionaries ( ) . getRegionsHierarchies ( ) ) ; <nl> else if ( name = = " OSHierarchy " ) return new FunctionOSHierarchy ( context . getDictionaries ( ) . getTechDataHierarchy ( ) ) ; <nl> else if ( name = = " SEHierarchy " ) return new FunctionSEHierarchy ( context . getDictionaries ( ) . getTechDataHierarchy ( ) ) ; <nl> else if ( name = = " categoryHierarchy " ) return new FunctionCategoryHierarchy ( context . getDictionaries ( ) . getCategoriesHierarchy ( ) ) ; <nl> | dbms : added support for ' point of view ' argument of functions working with dictionaries [ # METR - 10713 ] . | ClickHouse/ClickHouse | 4903752cd0184d6712d29a49a02482aa1b6d1006 | 2014-04-04T18:08:01Z |
mmm a / src / core / grabber / include / device_grabber . hpp <nl> ppp b / src / core / grabber / include / device_grabber . hpp <nl> class device_grabber final : public pqrs : : dispatcher : : extra : : dispatcher_client { <nl> <nl> auto to_json = nlohmann : : json : : parse ( pair . second ) ; <nl> <nl> - return std : : make_shared < manipulator : : manipulators : : basic > ( manipulator : : manipulators : : basic : : from_event_definition ( from_json ) , <nl> - manipulator : : to_event_definition ( to_json ) ) ; <nl> + return std : : make_shared < manipulator : : manipulators : : basic : : basic > ( manipulator : : manipulators : : basic : : basic : : from_event_definition ( from_json ) , <nl> + manipulator : : to_event_definition ( to_json ) ) ; <nl> } catch ( std : : exception & ) { <nl> } <nl> } <nl> class device_grabber final : public pqrs : : dispatcher : : extra : : dispatcher_client { <nl> { " modifiers " , nlohmann : : json : : array ( { " fn " } ) } , <nl> } ) ; <nl> <nl> - auto manipulator = std : : make_shared < manipulator : : manipulators : : basic > ( manipulator : : manipulators : : basic : : from_event_definition ( from_json ) , <nl> - manipulator : : to_event_definition ( to_json ) ) ; <nl> + auto manipulator = std : : make_shared < manipulator : : manipulators : : basic : : basic > ( manipulator : : manipulators : : basic : : basic : : from_event_definition ( from_json ) , <nl> + manipulator : : to_event_definition ( to_json ) ) ; <nl> fn_function_keys_manipulator_manager_ - > push_back_manipulator ( std : : shared_ptr < manipulator : : manipulators : : base > ( manipulator ) ) ; <nl> } <nl> } <nl> class device_grabber final : public pqrs : : dispatcher : : extra : : dispatcher_client { <nl> auto to_json = d [ " to " ] ; <nl> to_json [ " modifiers " ] = nlohmann : : json : : array ( { " fn " } ) ; <nl> <nl> - auto manipulator = std : : make_shared < manipulator : : manipulators : : basic > ( manipulator : : manipulators : : basic : : from_event_definition ( from_json ) , <nl> - manipulator : : to_event_definition ( to_json ) ) ; <nl> + auto manipulator = std : : make_shared < manipulator : : manipulators : : basic : : basic > ( manipulator : : manipulators : : basic : : basic : : from_event_definition ( from_json ) , <nl> + manipulator : : to_event_definition ( to_json ) ) ; <nl> fn_function_keys_manipulator_manager_ - > push_back_manipulator ( std : : shared_ptr < manipulator : : manipulators : : base > ( manipulator ) ) ; <nl> } <nl> } <nl> class device_grabber final : public pqrs : : dispatcher : : extra : : dispatcher_client { <nl> } <nl> to_json [ " modifiers " ] = to_modifiers ; <nl> <nl> - return std : : make_shared < manipulator : : manipulators : : basic > ( manipulator : : manipulators : : basic : : from_event_definition ( from_json ) , <nl> - manipulator : : to_event_definition ( to_json ) ) ; <nl> + return std : : make_shared < manipulator : : manipulators : : basic : : basic > ( manipulator : : manipulators : : basic : : basic : : from_event_definition ( from_json ) , <nl> + manipulator : : to_event_definition ( to_json ) ) ; <nl> } catch ( std : : exception & ) { <nl> } <nl> return nullptr ; <nl> mmm a / src / core / grabber / include / manipulator / manipulator_factory . hpp <nl> ppp b / src / core / grabber / include / manipulator / manipulator_factory . hpp <nl> <nl> # include " core_configuration / core_configuration . hpp " <nl> # include " json_utility . hpp " <nl> # include " manipulator / manipulators / base . hpp " <nl> - # include " manipulator / manipulators / basic . hpp " <nl> + # include " manipulator / manipulators / basic / basic . hpp " <nl> # include " manipulator / manipulators / nop . hpp " <nl> # include " manipulator / types . hpp " <nl> # include < memory > <nl> class manipulator_factory final { <nl> { <nl> if ( auto value = json_utility : : find_optional < std : : string > ( json , " type " ) ) { <nl> if ( * value = = " basic " ) { <nl> - return std : : make_shared < manipulators : : basic > ( json , <nl> - parameters ) ; <nl> + return std : : make_shared < manipulators : : basic : : basic > ( json , <nl> + parameters ) ; <nl> } else { <nl> logger : : get_logger ( ) - > error ( " complex_modifications json error : Unknown ` type ` { 0 } in { 1 } " , * value , json . dump ( ) ) ; <nl> return std : : make_shared < manipulators : : nop > ( ) ; <nl> similarity index 99 % <nl> rename from src / core / grabber / include / manipulator / manipulators / basic . hpp <nl> rename to src / core / grabber / include / manipulator / manipulators / basic / basic . hpp <nl> mmm a / src / core / grabber / include / manipulator / manipulators / basic . hpp <nl> ppp b / src / core / grabber / include / manipulator / manipulators / basic / basic . hpp <nl> <nl> # pragma once <nl> <nl> - # include " . . / types . hpp " <nl> - # include " base . hpp " <nl> + # include " . . / . . / types . hpp " <nl> + # include " . . / base . hpp " <nl> # include " core_configuration / core_configuration . hpp " <nl> # include " krbn_notification_center . hpp " <nl> # include < nlohmann / json . hpp > <nl> <nl> namespace krbn { <nl> namespace manipulator { <nl> namespace manipulators { <nl> + namespace basic { <nl> class basic final : public base , public pqrs : : dispatcher : : extra : : dispatcher_client { <nl> public : <nl> - # include " basic / from_event_definition . hpp " <nl> - # include " basic / manipulated_original_event . hpp " <nl> + # include " from_event_definition . hpp " <nl> + # include " manipulated_original_event . hpp " <nl> <nl> - # include " basic / to_delayed_action . hpp " <nl> - # include " basic / to_if_held_down . hpp " <nl> + # include " to_delayed_action . hpp " <nl> + # include " to_if_held_down . hpp " <nl> <nl> basic ( const nlohmann : : json & json , <nl> const core_configuration : : details : : complex_modifications_parameters & parameters ) : base ( ) , <nl> inline void from_json ( const nlohmann : : json & json , basic : : from_event_definition : : <nl> value = basic : : from_event_definition : : simultaneous_options : : key_up_when : : any ; <nl> } <nl> } <nl> + } / / namespace basic <nl> } / / namespace manipulators <nl> } / / namespace manipulator <nl> } / / namespace krbn <nl> mmm a / tests / src / core_configuration / src / test . cpp <nl> ppp b / tests / src / core_configuration / src / test . cpp <nl> <nl> # include < catch2 / catch . hpp > <nl> <nl> # include " core_configuration / core_configuration . hpp " <nl> - # include " manipulator / manipulators / basic . hpp " <nl> + # include " manipulator / manipulators / basic / basic . hpp " <nl> # include " manipulator / types . hpp " <nl> # include < iostream > <nl> <nl> TEST_CASE ( " simple_modifications . to_json " ) { <nl> <nl> krbn : : core_configuration : : details : : simple_modifications simple_modifications ( json ) ; <nl> { <nl> - krbn : : manipulator : : manipulators : : basic : : from_event_definition from_event_definition ( nlohmann : : json : : parse ( simple_modifications . get_pairs ( ) [ 0 ] . first ) ) ; <nl> + krbn : : manipulator : : manipulators : : basic : : basic : : from_event_definition from_event_definition ( nlohmann : : json : : parse ( simple_modifications . get_pairs ( ) [ 0 ] . first ) ) ; <nl> REQUIRE ( from_event_definition . get_event_definitions ( ) . size ( ) = = 1 ) ; <nl> REQUIRE ( from_event_definition . get_event_definitions ( ) . front ( ) . get_consumer_key_code ( ) = = krbn : : consumer_key_code : : mute ) ; <nl> } <nl> TEST_CASE ( " simple_modifications . to_json " ) { <nl> REQUIRE ( to_event_definition . get_event_definition ( ) . get_pointing_button ( ) = = krbn : : pointing_button : : button3 ) ; <nl> } <nl> { <nl> - krbn : : manipulator : : manipulators : : basic : : from_event_definition from_event_definition ( nlohmann : : json : : parse ( simple_modifications . get_pairs ( ) [ 1 ] . first ) ) ; <nl> + krbn : : manipulator : : manipulators : : basic : : basic : : from_event_definition from_event_definition ( nlohmann : : json : : parse ( simple_modifications . get_pairs ( ) [ 1 ] . first ) ) ; <nl> REQUIRE ( from_event_definition . get_event_definitions ( ) . size ( ) = = 1 ) ; <nl> REQUIRE ( from_event_definition . get_event_definitions ( ) . front ( ) . get_key_code ( ) = = krbn : : key_code : : a ) ; <nl> } <nl> mmm a / tests / src / event_definition / test . cpp <nl> ppp b / tests / src / event_definition / test . cpp <nl> <nl> # define CATCH_CONFIG_MAIN <nl> # include < catch2 / catch . hpp > <nl> <nl> - # include " manipulator / manipulators / basic . hpp " <nl> + # include " manipulator / manipulators / basic / basic . hpp " <nl> # include " manipulator / types . hpp " <nl> # include < pqrs / filesystem . hpp > <nl> <nl> mmm a / tests / src / manipulator / manipulator_factory_test . cpp <nl> ppp b / tests / src / manipulator / manipulator_factory_test . cpp <nl> TEST_CASE ( " manipulator . manipulator_factory " ) { <nl> auto manipulator = krbn : : manipulator : : manipulator_factory : : make_manipulator ( json , <nl> parameters ) ; <nl> REQUIRE ( dynamic_cast < krbn : : manipulator : : manipulators : : nop * > ( manipulator . get ( ) ) ! = nullptr ) ; <nl> - REQUIRE ( dynamic_cast < krbn : : manipulator : : manipulators : : basic * > ( manipulator . get ( ) ) = = nullptr ) ; <nl> + REQUIRE ( dynamic_cast < krbn : : manipulator : : manipulators : : basic : : basic * > ( manipulator . get ( ) ) = = nullptr ) ; <nl> REQUIRE ( manipulator - > get_valid ( ) = = true ) ; <nl> REQUIRE ( manipulator - > active ( ) = = false ) ; <nl> } <nl> TEST_CASE ( " manipulator . manipulator_factory " ) { <nl> krbn : : core_configuration : : details : : complex_modifications_parameters parameters ; <nl> auto manipulator = krbn : : manipulator : : manipulator_factory : : make_manipulator ( json , <nl> parameters ) ; <nl> - REQUIRE ( dynamic_cast < krbn : : manipulator : : manipulators : : basic * > ( manipulator . get ( ) ) ! = nullptr ) ; <nl> + REQUIRE ( dynamic_cast < krbn : : manipulator : : manipulators : : basic : : basic * > ( manipulator . get ( ) ) ! = nullptr ) ; <nl> REQUIRE ( dynamic_cast < krbn : : manipulator : : manipulators : : nop * > ( manipulator . get ( ) ) = = nullptr ) ; <nl> REQUIRE ( manipulator - > get_valid ( ) = = true ) ; <nl> REQUIRE ( manipulator - > active ( ) = = false ) ; <nl> <nl> - auto basic = dynamic_cast < krbn : : manipulator : : manipulators : : basic * > ( manipulator . get ( ) ) ; <nl> + auto basic = dynamic_cast < krbn : : manipulator : : manipulators : : basic : : basic * > ( manipulator . get ( ) ) ; <nl> REQUIRE ( basic - > get_from ( ) . get_event_definitions ( ) . size ( ) = = 1 ) ; <nl> REQUIRE ( basic - > get_from ( ) . get_event_definitions ( ) . front ( ) . get_type ( ) = = event_definition : : type : : key_code ) ; <nl> REQUIRE ( basic - > get_from ( ) . get_event_definitions ( ) . front ( ) . get_key_code ( ) = = krbn : : key_code : : escape ) ; <nl> mmm a / tests / src / manipulator_details_basic / test . cpp <nl> ppp b / tests / src / manipulator_details_basic / test . cpp <nl> <nl> # define CATCH_CONFIG_MAIN <nl> # include < catch2 / catch . hpp > <nl> <nl> - # include " manipulator / manipulators / basic . hpp " <nl> + # include " manipulator / manipulators / basic / basic . hpp " <nl> # include " manipulator / types . hpp " <nl> # include < pqrs / filesystem . hpp > <nl> <nl> void set_null_logger ( void ) { <nl> TEST_CASE ( " modifier_definition . test_modifier " ) { <nl> using krbn : : manipulator : : event_definition ; <nl> using krbn : : manipulator : : modifier_definition ; <nl> - using krbn : : manipulator : : manipulators : : basic ; <nl> + using krbn : : manipulator : : manipulators : : basic : : basic ; <nl> <nl> { <nl> krbn : : modifier_flag_manager modifier_flag_manager ; <nl> TEST_CASE ( " modifier_definition . test_modifier " ) { <nl> TEST_CASE ( " from_event_definition . test_modifiers " ) { <nl> using krbn : : manipulator : : event_definition ; <nl> using krbn : : manipulator : : modifier_definition ; <nl> - using krbn : : manipulator : : manipulators : : basic ; <nl> + using krbn : : manipulator : : manipulators : : basic : : basic ; <nl> <nl> / / empty <nl> <nl> TEST_CASE ( " from_event_definition . test_modifiers " ) { <nl> } <nl> <nl> TEST_CASE ( " manipulator . details . basic : : from_event_definition " ) { <nl> - using krbn : : manipulator : : manipulators : : basic ; <nl> + using krbn : : manipulator : : manipulators : : basic : : basic ; <nl> <nl> { <nl> nlohmann : : json json ; <nl> TEST_CASE ( " manipulator . details . basic : : from_event_definition " ) { <nl> } <nl> <nl> TEST_CASE ( " event_definition . error_messages " ) { <nl> - using krbn : : manipulator : : manipulators : : basic ; <nl> + using krbn : : manipulator : : manipulators : : basic : : basic ; <nl> <nl> set_file_logger ( " tmp / error_messages . log " ) ; <nl> <nl> TEST_CASE ( " event_definition . error_messages " ) { <nl> } <nl> <nl> TEST_CASE ( " basic : : from_event_definition . test_event " ) { <nl> - using krbn : : manipulator : : manipulators : : basic ; <nl> + using krbn : : manipulator : : manipulators : : basic : : basic ; <nl> <nl> { <nl> basic : : from_event_definition d ( nlohmann : : json : : object ( { } ) ) ; <nl> TEST_CASE ( " basic : : from_event_definition . test_event " ) { <nl> } <nl> <nl> TEST_CASE ( " simultaneous_options " ) { <nl> - using krbn : : manipulator : : manipulators : : basic ; <nl> + using krbn : : manipulator : : manipulators : : basic : : basic ; <nl> <nl> { <nl> basic : : from_event_definition event_definition ( nlohmann : : json : : object ( { <nl> | manipulator : : manipulators : : basic : : basic - > manipulator : : manipulators : : basic | pqrs-org/Karabiner-Elements | 4dbd9fc355c1f4cb44cbdb5adc29a00d081ac48d | 2019-02-04T09:36:05Z |
mmm a / lib / Sema / ConstraintSystem . cpp <nl> ppp b / lib / Sema / ConstraintSystem . cpp <nl> bool ConstraintSystem : : salvage ( SmallVectorImpl < Solution > & viable , Expr * expr ) { <nl> SolverState state ( expr , * this , FreeTypeVariableBinding : : Disallow ) ; <nl> state . recordFixes = true ; <nl> <nl> - if ( failedConstraint & & simplifyConstraint ( * failedConstraint ) = = SolutionKind : : Solved ) <nl> + / / Retry all inactive and failed constraints <nl> + if ( failedConstraint ) { <nl> + addUnsolvedConstraint ( failedConstraint ) ; <nl> failedConstraint = nullptr ; <nl> + } <nl> + ActiveConstraints . splice ( ActiveConstraints . end ( ) , InactiveConstraints ) ; <nl> + for ( auto & constraint : ActiveConstraints ) <nl> + constraint . setActive ( true ) ; <nl> <nl> / / Solve the system . <nl> solve ( viable ) ; <nl> | More thorough retry of constraints which may succeed now that fixes are allowed . | apple/swift | dec2f455a8ae52d763b8b24bbdc8378d3a8f724d | 2018-10-14T16:34:43Z |
Subsets and Splits