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 / mongo / db / repl / replication_coordinator_external_state . h <nl> ppp b / src / mongo / db / repl / replication_coordinator_external_state . h <nl> class ReplicationCoordinatorExternalState { <nl> * / <nl> virtual bool isReadConcernSnapshotSupportedByStorageEngine ( OperationContext * opCtx ) const = 0 ; <nl> <nl> - / * * <nl> - * Applies the operations described in the oplog entries contained in " ops " using the <nl> - * " applyOperation " function . <nl> - * / <nl> - virtual StatusWith < OpTime > multiApply ( OperationContext * opCtx , <nl> - MultiApplier : : Operations ops , <nl> - OplogApplier : : Observer * observer , <nl> - const HostAndPort & source , <nl> - ThreadPool * writerPool ) = 0 ; <nl> - <nl> - / * * <nl> - * This function creates an oplog buffer of the type specified at server startup . <nl> - * / <nl> - virtual std : : unique_ptr < OplogBuffer > makeInitialSyncOplogBuffer ( <nl> - OperationContext * opCtx ) const = 0 ; <nl> - <nl> / * * <nl> * Returns maximum number of times that the oplog fetcher will consecutively restart the oplog <nl> * tailing query on non - cancellation errors . <nl> mmm a / src / mongo / db / repl / replication_coordinator_external_state_impl . cpp <nl> ppp b / src / mongo / db / repl / replication_coordinator_external_state_impl . cpp <nl> <nl> # include " mongo / db / repl / replication_process . h " <nl> # include " mongo / db / repl / rs_sync . h " <nl> # include " mongo / db / repl / storage_interface . h " <nl> + # include " mongo / db / repl / sync_tail . h " <nl> # include " mongo / db / s / balancer / balancer . h " <nl> # include " mongo / db / s / chunk_splitter . h " <nl> # include " mongo / db / s / config / sharding_catalog_manager . h " <nl> bool ReplicationCoordinatorExternalStateImpl : : isReadConcernSnapshotSupportedBySt <nl> return storageEngine - > supportsReadConcernSnapshot ( ) ; <nl> } <nl> <nl> - StatusWith < OpTime > ReplicationCoordinatorExternalStateImpl : : multiApply ( <nl> - OperationContext * opCtx , <nl> - MultiApplier : : Operations ops , <nl> - OplogApplier : : Observer * observer , <nl> - const HostAndPort & source , <nl> - ThreadPool * writerPool ) { <nl> - SyncTail syncTail ( observer , repl : : multiInitialSyncApply , writerPool ) ; <nl> - syncTail . setHostname ( source . toString ( ) ) ; <nl> - return syncTail . multiApply ( opCtx , std : : move ( ops ) ) ; <nl> - } <nl> - <nl> - std : : unique_ptr < OplogBuffer > ReplicationCoordinatorExternalStateImpl : : makeInitialSyncOplogBuffer ( <nl> - OperationContext * opCtx ) const { <nl> - return { } ; <nl> - } <nl> - <nl> std : : size_t ReplicationCoordinatorExternalStateImpl : : getOplogFetcherMaxFetcherRestarts ( ) const { <nl> return oplogFetcherMaxFetcherRestarts . load ( ) ; <nl> } <nl> mmm a / src / mongo / db / repl / replication_coordinator_external_state_impl . h <nl> ppp b / src / mongo / db / repl / replication_coordinator_external_state_impl . h <nl> <nl> # include " mongo / db / repl / replication_coordinator_external_state . h " <nl> # include " mongo / db / repl / rs_sync . h " <nl> # include " mongo / db / repl / sync_source_feedback . h " <nl> - # include " mongo / db / repl / sync_tail . h " <nl> # include " mongo / db / repl / task_runner . h " <nl> # include " mongo / db / storage / journal_listener . h " <nl> # include " mongo / db / storage / snapshot_manager . h " <nl> class ReplicationCoordinatorExternalStateImpl final : public ReplicationCoordina <nl> virtual double getElectionTimeoutOffsetLimitFraction ( ) const ; <nl> virtual bool isReadCommittedSupportedByStorageEngine ( OperationContext * opCtx ) const ; <nl> virtual bool isReadConcernSnapshotSupportedByStorageEngine ( OperationContext * opCtx ) const ; <nl> - virtual StatusWith < OpTime > multiApply ( OperationContext * opCtx , <nl> - MultiApplier : : Operations ops , <nl> - OplogApplier : : Observer * observer , <nl> - const HostAndPort & source , <nl> - ThreadPool * writerPool ) override ; <nl> - virtual std : : unique_ptr < OplogBuffer > makeInitialSyncOplogBuffer ( <nl> - OperationContext * opCtx ) const override ; <nl> virtual std : : size_t getOplogFetcherMaxFetcherRestarts ( ) const override ; <nl> <nl> / / Methods from JournalListener . <nl> mmm a / src / mongo / db / repl / replication_coordinator_external_state_mock . cpp <nl> ppp b / src / mongo / db / repl / replication_coordinator_external_state_mock . cpp <nl> bool ReplicationCoordinatorExternalStateMock : : isReadConcernSnapshotSupportedBySt <nl> return true ; <nl> } <nl> <nl> - StatusWith < OpTime > ReplicationCoordinatorExternalStateMock : : multiApply ( <nl> - OperationContext * , <nl> - MultiApplier : : Operations , <nl> - OplogApplier : : Observer * observer , <nl> - const HostAndPort & source , <nl> - ThreadPool * writerPool ) { <nl> - return { ErrorCodes : : InternalError , " Method not implemented " } ; <nl> - } <nl> - <nl> - std : : unique_ptr < OplogBuffer > ReplicationCoordinatorExternalStateMock : : makeInitialSyncOplogBuffer ( <nl> - OperationContext * opCtx ) const { <nl> - return stdx : : make_unique < OplogBufferBlockingQueue > ( ) ; <nl> - } <nl> - <nl> std : : size_t ReplicationCoordinatorExternalStateMock : : getOplogFetcherMaxFetcherRestarts ( ) const { <nl> return 0 ; <nl> } <nl> mmm a / src / mongo / db / repl / replication_coordinator_external_state_mock . h <nl> ppp b / src / mongo / db / repl / replication_coordinator_external_state_mock . h <nl> class ReplicationCoordinatorExternalStateMock : public ReplicationCoordinatorExt <nl> virtual double getElectionTimeoutOffsetLimitFraction ( ) const ; <nl> virtual bool isReadCommittedSupportedByStorageEngine ( OperationContext * opCtx ) const ; <nl> virtual bool isReadConcernSnapshotSupportedByStorageEngine ( OperationContext * opCtx ) const ; <nl> - virtual StatusWith < OpTime > multiApply ( OperationContext * opCtx , <nl> - MultiApplier : : Operations ops , <nl> - OplogApplier : : Observer * observer , <nl> - const HostAndPort & source , <nl> - ThreadPool * writerPool ) override ; <nl> - virtual std : : unique_ptr < OplogBuffer > makeInitialSyncOplogBuffer ( <nl> - OperationContext * opCtx ) const override ; <nl> virtual std : : size_t getOplogFetcherMaxFetcherRestarts ( ) const override ; <nl> <nl> / * * <nl>
SERVER - 32335 remove unused initial sync functions from ReplicationCoordinatorExternalState
mongodb/mongo
207bcfacd612dc1ddbe98c524624658cb54e4346
2018-03-23T01:18:43Z
mmm a / hphp / NEWS <nl> ppp b / hphp / NEWS <nl> <nl> + " Snoop Dogg " 11 - Sep - 2014 <nl> + - VASM phase 1 : emit vasm instructions , with existing register allocation <nl> + - More xdebug support <nl> + - [ hack ] Implement async lambdas . <nl> + - add process memory and code segment size to admin memory page <nl> + - Overhauled xdebug remote debugging testing <nl> + - Add a mechanism for building and testing a zend extension as a DSO . <nl> + - Support fast object allocation path when Eval . EnableObjDestruct call is on <nl> + - Static string table memory usage <nl> + - Implement parallel repo preloading . <nl> + - Add mcrypt constants to hhi <nl> + - Move var_dump ( ) to HNI , kill off variable . idl . json <nl> + - JIT : Use std , boost , and folly instead of smart containers . <nl> + - Hack : Support for variance ( + / - ) annotations on type - parameters <nl> + - Implement APCIterator <nl> + - Convert v ? s ? printf ( ) to HNI using Variadics <nl> + - Enable variadics for HNI functions / methods <nl> + - Smooth a wrinkle in HHVM ' s safesort impl <nl> + - Make Set implement KeyedIterable and support bracket syntax for reading <nl> + - Covariance fixes <nl> + <nl> + " RBX " 28 - Aug - 2014 <nl> + - Make MemExceeded flag sticky <nl> + - Check for OOM during json decoding <nl> + - Check surprise flags when unserializing arrays and objects <nl> + - Limit curl timeout to remaining request timeout <nl> + - Add variant of openssl_pkcs7_verify that ignores cert expiration <nl> + - Numerous changes to support xdebug <nl> + - Remove use of non - threadsafe strtok ( ) <nl> + - Numerous changes to normalize INI setting names <nl> + - update to new sqlite <nl> + - < < __Memoize > > support <nl> + - Hack : Print backtrace when worker dies <nl> + - Parser support for " varray ( . . ) " <nl> + - Introduce kVPackedKind for vector - like arrays <nl> + - Move mailparse to HNI <nl> + - VASM start phase 1 ; emit vasm for some instructions <nl> + - Fix in headers defines for cygwin <nl> + - [ hack ] Parser : Fix decl mode ' s confusion of type hints and xhp . <nl> + - Create a unified stack for Xenon <nl> + - Move debugger from IDL to HNI <nl> + - Fix mcrypt_create_iv ( . . . , MCRYPT_RAND ) to auto - seed RNG <nl> + - Fix information leak in hash_equals ( ) implementation <nl> + - don ' t statically link libgcc / libstdc + + by default on OSX <nl> + - Adds ssdeep module to HHVM <nl> + - added new raise_error family functions that skip the top frame of the backtrace . <nl> + - Add initial support for - d outside of - - php mode <nl> + - Fix covariance for Const { Vector , Map , Set } , add tests <nl> + - GMP cleanup / fixes <nl> + - Implement SplDoublyLinkedList : : add <nl> + - Link against LLVM library if present . <nl> + - Disallow multiple ' default : ' blocks in a single switch <nl> + - Introduce async function lambdas <nl> + - Document the PHP profilers <nl> + - Fix sample profiler output ; make it more efficient <nl> + - Properly shut down fastcgi worker threads when connection is closed <nl> + - Delete SimpleProfiler <nl> + - Create HHVM man page <nl> + - Improved PHP compatibility in the reflection API . <nl> + <nl> " Queen Latifah " 14 - Aug - 2014 <nl> - Implement RecursiveCallbackFilterIterator <nl> - cmake installations should no longer put files in hphp and now put them in hhvm <nl> <nl> - Relax restrictions on the typing of class constant shape field names . <nl> - Fix file : / / URL decoding in libxml functions and elsewhere <nl> <nl> - NEXT <nl> + " Public Enemy " 31 - July - 2014 <nl> - Interface requirements ( similar to trait requirements ) enforced <nl> - Initial support for PHP5 . 6 argument unpacking : f ( $ x , $ y , . . . $ args ) <nl> - Hack : hhi files are embedded in the hh_server binary <nl> NEXT <nl> - Cleanup of PHP - level profilers <nl> - Change default for Eval . EnableObjDestructCall to true <nl> <nl> - " Outkast " 17 - July 2014 <nl> + " Outkast " 17 - July - 2014 <nl> - PHP_VERSION is now 5 . 6 <nl> - Introduce Dbl specific relational IR opcodes <nl> - Expose APC info to admin port <nl>
Update NEWS for " Snoop Dogg "
facebook/hhvm
57f679705addf1fd88acbe045c95e5663dcd5743
2014-09-01T20:00:20Z
mmm a / include / swift / AST / ClangModuleLoader . h <nl> ppp b / include / swift / AST / ClangModuleLoader . h <nl> class ClangModuleLoader : public ModuleLoader { <nl> / / / module , it returns it . This is intended for use in reflection / debugging <nl> / / / contexts where access is not a problem . <nl> virtual void <nl> - lookupRelatedEntity ( StringRef clangName , StringRef relatedEntityKind , <nl> + lookupRelatedEntity ( StringRef clangName , ClangTypeKind kind , <nl> + StringRef relatedEntityKind , <nl> llvm : : function_ref < void ( TypeDecl * ) > receiver ) { } <nl> } ; <nl> <nl> mmm a / include / swift / ClangImporter / ClangImporter . h <nl> ppp b / include / swift / ClangImporter / ClangImporter . h <nl> class ClangImporter final : public ClangModuleLoader { <nl> / / / module , it returns it . This is intended for use in reflection / debugging <nl> / / / contexts where access is not a problem . <nl> void <nl> - lookupRelatedEntity ( StringRef clangName , StringRef relatedEntityKind , <nl> + lookupRelatedEntity ( StringRef clangName , ClangTypeKind kind , <nl> + StringRef relatedEntityKind , <nl> llvm : : function_ref < void ( TypeDecl * ) > receiver ) override ; <nl> <nl> / / / Look for textually included declarations from the bridging header . <nl> mmm a / lib / AST / ASTDemangler . cpp <nl> ppp b / lib / AST / ASTDemangler . cpp <nl> GenericTypeDecl * ASTBuilder : : findForeignTypeDecl ( StringRef name , <nl> switch ( foreignKind ) { <nl> case ForeignModuleKind : : SynthesizedByImporter : <nl> if ( ! relatedEntityKind . empty ( ) ) { <nl> - importer - > lookupRelatedEntity ( name , relatedEntityKind , found ) ; <nl> + importer - > lookupRelatedEntity ( name , * lookupKind , relatedEntityKind , <nl> + found ) ; <nl> break ; <nl> } <nl> importer - > lookupValue ( Ctx . getIdentifier ( name ) , consumer ) ; <nl> mmm a / lib / ClangImporter / ClangImporter . cpp <nl> ppp b / lib / ClangImporter / ClangImporter . cpp <nl> void ClangImporter : : lookupTypeDecl ( <nl> } <nl> <nl> void ClangImporter : : lookupRelatedEntity ( <nl> - StringRef rawName , StringRef relatedEntityKind , <nl> + StringRef rawName , ClangTypeKind kind , StringRef relatedEntityKind , <nl> llvm : : function_ref < void ( TypeDecl * ) > receiver ) { <nl> using CISTAttr = ClangImporterSynthesizedTypeAttr ; <nl> if ( relatedEntityKind = = <nl>
Add back the kind parameter of ClangImporter : : lookupRelatedEntity ( ) .
apple/swift
931f60f2795411f4a6db1773820f7cacdbdf2fc8
2019-08-13T20:05:47Z
mmm a / hphp / compiler / analysis / emitter . cpp <nl> ppp b / hphp / compiler / analysis / emitter . cpp <nl> emitHHBCNativeFuncUnit ( const HhbcExtFuncInfo * builtinFuncs , <nl> ! RuntimeOption : : EnableZendCompat ) { <nl> continue ; <nl> } <nl> - if ( Unit : : lookupFunc ( name ) ) { <nl> - / / already provided by systemlib , rename to allow the php <nl> - / / version to delegate if necessary <nl> - name = makeStaticString ( " __builtin_ " + name - > toCPPString ( ) ) ; <nl> + <nl> + / / We already provide array_map by the hhas systemlib . Rename <nl> + / / because that hhas implementation delegates back to the C + + <nl> + / / implementation for some edge cases . This works for any <nl> + / / similarly defined function ( already defined not as a builtin ) , <nl> + / / and requires that the hhas systemlib is already loaded . <nl> + if ( auto const existing = Unit : : lookupFunc ( name ) ) { <nl> + if ( ! existing - > isCPPBuiltin ( ) ) { <nl> + name = makeStaticString ( " __builtin_ " + name - > toCPPString ( ) ) ; <nl> + } <nl> } <nl> + <nl> FuncEmitter * fe = ue - > newFuncEmitter ( name ) ; <nl> Offset base = ue - > bcPos ( ) ; <nl> fe - > setBuiltinFunc ( mi , bif , nif , base ) ; <nl>
Only rename builtins that aren ' t C + + builtins to __builtin_name
facebook/hhvm
2325d6ba092755e0b50f58cb67f001348c975544
2014-02-12T16:39:51Z
mmm a / js / client / modules / @ arangodb / replication . js <nl> ppp b / js / client / modules / @ arangodb / replication . js <nl> var waitForResult = function ( config , id ) { <nl> arangosh . checkRequestResult ( jobResult ) ; <nl> } <nl> catch ( err ) { <nl> - print ( " everythings ruined " , jobResult ) ; <nl> throw err ; <nl> } <nl> <nl> mmm a / js / common / tests / shell / shell - cluster - crud . js <nl> ppp b / js / common / tests / shell / shell - cluster - crud . js <nl> function ClusterCrudDeleteSuite ( ) { <nl> / / remove a non - existing revision <nl> old = c . save ( { " a " : 1 , " b " : " 2 " , " c " : true , " d " : " test " } ) ; <nl> doc = c . update ( old . _key , { " foo " : " bar " } ) ; <nl> - assertTrue ( old . _rev ! = doc . _rev ) ; <nl> + assertTrue ( old . _rev ! = = doc . _rev ) ; <nl> <nl> try { <nl> c . remove ( old ) ; <nl> mmm a / js / common / tests / shell / shell - index - ensure . js <nl> ppp b / js / common / tests / shell / shell - index - ensure . js <nl> function ensureIndexSuite ( ) { <nl> assertFalse ( idx . geoJson ) ; <nl> <nl> var indexes = collection . getIndexes ( ) ; <nl> - res = indexes [ 0 ] . type = = " primary " ? indexes [ 1 ] : indexes [ 0 ] ; <nl> + res = indexes [ 0 ] . type = = = " primary " ? indexes [ 1 ] : indexes [ 0 ] ; <nl> <nl> assertEqual ( " geo1 " , res . type ) ; <nl> assertFalse ( res . unique ) ; <nl> mmm a / js / server / modules / @ arangodb / simple - query . js <nl> ppp b / js / server / modules / @ arangodb / simple - query . js <nl> SimpleQueryNear . prototype . execute = function ( ) { <nl> options ) ; <nl> } ) ; <nl> <nl> - result = cluster . wait ( coord , shards ) ; <nl> + var result = cluster . wait ( coord , shards ) ; <nl> <nl> result . forEach ( function ( part ) { <nl> var body = JSON . parse ( part . body ) ; <nl> SimpleQueryNear . prototype . execute = function ( ) { <nl> } <nl> <nl> if ( this . _distance = = = null ) { <nl> - n = documents . length ; <nl> - for ( i = 0 ; i < n ; + + i ) { <nl> + var n = documents . length ; <nl> + for ( var i = 0 ; i < n ; + + i ) { <nl> delete documents [ i ] [ attribute ] ; <nl> } <nl> } <nl> SimpleQueryWithin . prototype . execute = function ( ) { <nl> options ) ; <nl> } ) ; <nl> <nl> - result = cluster . wait ( coord , shards ) ; <nl> + var result = cluster . wait ( coord , shards ) ; <nl> <nl> result . forEach ( function ( part ) { <nl> var body = JSON . parse ( part . body ) ; <nl> SimpleQueryWithin . prototype . execute = function ( ) { <nl> } <nl> <nl> if ( this . _distance = = = null ) { <nl> - n = documents . length ; <nl> - for ( i = 0 ; i < n ; + + i ) { <nl> + var n = documents . length ; <nl> + for ( var i = 0 ; i < n ; + + i ) { <nl> delete documents [ i ] [ attribute ] ; <nl> } <nl> } <nl> SimpleQueryFulltext . prototype . execute = function ( ) { <nl> options ) ; <nl> } ) ; <nl> <nl> - result = cluster . wait ( coord , shards ) ; <nl> + var result = cluster . wait ( coord , shards ) ; <nl> <nl> result . forEach ( function ( part ) { <nl> var body = JSON . parse ( part . body ) ; <nl>
jslint
arangodb/arangodb
f45b6eeb49358f3c9334bf9c5d11fa903544d395
2016-04-06T07:50:39Z
mmm a / lib / Sema / BuilderTransform . cpp <nl> ppp b / lib / Sema / BuilderTransform . cpp <nl> class BuilderClosureVisitor <nl> if ( isa < IfConfigDecl > ( decl ) ) <nl> continue ; <nl> <nl> + / / Emit # warning / # error but don ' t build anything for it . <nl> + if ( auto poundDiag = dyn_cast < PoundDiagnosticDecl > ( decl ) ) { <nl> + TypeChecker : : typeCheckDecl ( poundDiag ) ; <nl> + continue ; <nl> + } <nl> + <nl> if ( ! unhandledNode ) <nl> unhandledNode = decl ; <nl> <nl> mmm a / test / Constraints / function_builder_diags . swift <nl> ppp b / test / Constraints / function_builder_diags . swift <nl> func extraArg ( ) { <nl> 6 / / expected - error { { extra argument in call } } <nl> } <nl> } <nl> + <nl> + / / rdar : / / problem / 53209000 - use of # warning and # error <nl> + tuplify ( true ) { x in <nl> + 1 <nl> + # error ( " boom " ) / / expected - error { { boom } } <nl> + " hello " <nl> + # warning ( " oops " ) / / expected - warning { { oops } } <nl> + 3 . 14159 <nl> + } <nl>
[ Function builders ] Handle # warning and # error
apple/swift
6022b3838ff46f4a10a8a54abfe87e1e9ce74e3f
2019-12-06T07:24:41Z
mmm a / src / protob / protob . hpp <nl> ppp b / src / protob / protob . hpp <nl> class protob_server_t : public http_app_t { <nl> response_t ( * _on_unparsable_query ) ( request_t * , std : : string ) , <nl> protob_server_callback_mode_t _cb_mode = CORO_ORDERED ) ; <nl> ~ protob_server_t ( ) ; <nl> - static const int32_t magic_number ; <nl> <nl> int get_port ( ) const ; <nl> private : <nl> class protob_server_t : public http_app_t { <nl> unsigned next_thread ; <nl> } ; <nl> <nl> - template < class request_t , class response_t , class context_t > <nl> - const int32_t protob_server_t < request_t , response_t , context_t > : : magic_number <nl> - = 0x3f61ba36 ; <nl> - <nl> / / TODO figure out how to do 0 copy serialization with this . <nl> <nl> # define RDB_MAKE_PROTOB_SERIALIZABLE_HELPER ( pb_t , isinline ) \ <nl> mmm a / src / protob / protob . tcc <nl> ppp b / src / protob / protob . tcc <nl> void protob_server_t < request_t , response_t , context_t > : : handle_conn ( const scoped <nl> try { <nl> int32_t client_magic_number ; <nl> conn - > read ( & client_magic_number , sizeof ( int32_t ) , & ct_keepalive ) ; <nl> - if ( client_magic_number ! = magic_number ) { <nl> + if ( client_magic_number ! = context_t : : magic_number ) { <nl> const char * msg = " ERROR : This is the rdb protocol port ! ( bad magic number ) \ n " ; <nl> conn - > write ( msg , strlen ( msg ) , & ct_keepalive ) ; <nl> conn - > shutdown_write ( ) ; <nl> mmm a / src / rdb_protocol / pb_server . hpp <nl> ppp b / src / rdb_protocol / pb_server . hpp <nl> class query2_server_t { <nl> <nl> struct context_t { <nl> context_t ( ) : interruptor ( 0 ) { } <nl> + static const int32_t magic_number = VersionDummy : : V0_1 ; <nl> ql : : stream_cache2_t stream_cache2 ; <nl> signal_t * interruptor ; <nl> } ; <nl>
CR 199 / D606 etc . ( moved magic number into context )
rethinkdb/rethinkdb
e0a1b4a7f8a9b2cd30969eadae4dbff674d68717
2013-03-26T04:12:55Z
mmm a / third_party / mlir / g3doc / Tutorials / Toy / Ch - 1 . md <nl> ppp b / third_party / mlir / g3doc / Tutorials / Toy / Ch - 1 . md <nl> Module : <nl> var : b @ test / ast . toy : 21 : 30 <nl> var : c @ test / ast . toy : 21 : 33 <nl> ] <nl> - VarDecl e < > @ test / ast . toy : 24 : 3 <nl> + VarDecl f < > @ test / ast . toy : 24 : 3 <nl> Call ' multiply_transpose ' [ @ test / ast . toy : 24 : 11 <nl> Call ' transpose ' [ @ test / ast . toy : 24 : 30 <nl> var : a @ test / ast . toy : 24 : 40 <nl>
Fixed typo in Toy tutorial ( second var e - > var f )
tensorflow/tensorflow
9fae7ec3734ce93a38c90baaea97701e3cdda969
2019-11-27T20:04:06Z
mmm a / tensorflow / contrib / learn / python / learn / estimators / dnn_linear_combined . py <nl> ppp b / tensorflow / contrib / learn / python / learn / estimators / dnn_linear_combined . py <nl> def input_fn_train : # returns x , y ( where y represents label ' s class index ) . <nl> . . . <nl> def input_fn_eval : # returns x , y ( where y represents label ' s class index ) . <nl> . . . <nl> + def input_fn_predict : # returns x , None . <nl> + . . . <nl> + estimator . fit ( input_fn = input_fn_train ) <nl> + estimator . evaluate ( input_fn = input_fn_eval ) <nl> + # predict_classes returns class indices . <nl> + estimator . predict_classes ( input_fn = input_fn_predict ) <nl> + ` ` ` <nl> + <nl> + If the user specifies ` label_keys ` in constructor , labels must be strings from <nl> + the ` label_keys ` vocabulary . Example : <nl> + <nl> + ` ` ` python <nl> + label_keys = [ ' label0 ' , ' label1 ' , ' label2 ' ] <nl> + estimator = DNNLinearCombinedClassifier ( <nl> + n_classes = n_classes , <nl> + linear_feature_columns = [ sparse_feature_a_x_sparse_feature_b ] , <nl> + dnn_feature_columns = [ sparse_feature_a_emb , sparse_feature_b_emb ] , <nl> + dnn_hidden_units = [ 1000 , 500 , 100 ] , <nl> + label_keys = label_keys ) <nl> + <nl> + def input_fn_train : # returns x , y ( where y is one of label_keys ) . <nl> + pass <nl> estimator . fit ( input_fn = input_fn_train ) <nl> + <nl> + def input_fn_eval : # returns x , y ( where y is one of label_keys ) . <nl> + pass <nl> estimator . evaluate ( input_fn = input_fn_eval ) <nl> - estimator . predict ( x = x ) # returns predicted labels ( i . e . label ' s class index ) . <nl> + def input_fn_predict : # returns x , None <nl> + # predict_classes returns one of label_keys . <nl> + estimator . predict_classes ( input_fn = input_fn_predict ) <nl> ` ` ` <nl> <nl> Input of ` fit ` and ` evaluate ` should have following features , <nl> def __init__ ( self , # _joint_linear_weights pylint : disable = invalid - name <nl> feature_engineering_fn = None , <nl> embedding_lr_multipliers = None , <nl> input_layer_min_slice_size = None , <nl> + label_keys = None , <nl> fix_global_step_increment_bug = False ) : <nl> " " " Constructs a DNNLinearCombinedClassifier instance . <nl> <nl> def __init__ ( self , # _joint_linear_weights pylint : disable = invalid - name <nl> learning rate for the embedding variables . <nl> input_layer_min_slice_size : Optional . The min slice size of input layer <nl> partitions . If not provided , will use the default of 64M . <nl> + label_keys : Optional list of strings with size ` [ n_classes ] ` defining the <nl> + label vocabulary . Only supported for ` n_classes ` > 2 . <nl> fix_global_step_increment_bug : If ` False ` , the estimator needs two fit <nl> steps to optimize both linear and dnn parts . If ` True ` , this bug is <nl> fixed . New users must set this to ` True ` , but it the default value is <nl> def __init__ ( self , # _joint_linear_weights pylint : disable = invalid - name <nl> head = head_lib . multi_class_head ( <nl> n_classes = n_classes , <nl> weight_column_name = weight_column_name , <nl> - enable_centered_bias = enable_centered_bias ) <nl> + enable_centered_bias = enable_centered_bias , <nl> + label_keys = label_keys ) <nl> linear_feature_columns = tuple ( linear_feature_columns or [ ] ) <nl> dnn_feature_columns = tuple ( dnn_feature_columns or [ ] ) <nl> self . _feature_columns = linear_feature_columns + dnn_feature_columns <nl> def input_fn_train : # returns x , y <nl> . . . <nl> def input_fn_eval : # returns x , y <nl> . . . <nl> + def input_fn_predict : # returns x , None <nl> + . . . <nl> estimator . train ( input_fn_train ) <nl> estimator . evaluate ( input_fn_eval ) <nl> - estimator . predict ( x ) <nl> + estimator . predict ( input_fn_predict ) <nl> ` ` ` <nl> <nl> Input of ` fit ` , ` train ` , and ` evaluate ` should have following features , <nl> mmm a / tensorflow / contrib / learn / python / learn / estimators / dnn_linear_combined_test . py <nl> ppp b / tensorflow / contrib / learn / python / learn / estimators / dnn_linear_combined_test . py <nl> def testMultiClass ( self ) : <nl> input_fn = test_data . iris_input_multiclass_fn , steps = 100 ) <nl> _assert_metrics_in_range ( ( ' accuracy ' , ) , scores ) <nl> <nl> + def testMultiClassLabelKeys ( self ) : <nl> + " " " Tests n_classes > 2 with label_keys vocabulary for labels . " " " <nl> + # Byte literals needed for python3 test to pass . <nl> + label_keys = [ b ' label0 ' , b ' label1 ' , b ' label2 ' ] <nl> + <nl> + def _input_fn ( num_epochs = None ) : <nl> + features = { <nl> + ' age ' : <nl> + input_lib . limit_epochs ( <nl> + constant_op . constant ( [ [ . 8 ] , [ 0 . 2 ] , [ . 1 ] ] ) , <nl> + num_epochs = num_epochs ) , <nl> + ' language ' : <nl> + sparse_tensor . SparseTensor ( <nl> + values = input_lib . limit_epochs ( <nl> + [ ' en ' , ' fr ' , ' zh ' ] , num_epochs = num_epochs ) , <nl> + indices = [ [ 0 , 0 ] , [ 0 , 1 ] , [ 2 , 0 ] ] , <nl> + dense_shape = [ 3 , 2 ] ) <nl> + } <nl> + labels = constant_op . constant ( <nl> + [ [ label_keys [ 1 ] ] , [ label_keys [ 0 ] ] , [ label_keys [ 0 ] ] ] , <nl> + dtype = dtypes . string ) <nl> + return features , labels <nl> + <nl> + language_column = feature_column . sparse_column_with_hash_bucket ( <nl> + ' language ' , hash_bucket_size = 20 ) <nl> + <nl> + classifier = dnn_linear_combined . DNNLinearCombinedClassifier ( <nl> + n_classes = 3 , <nl> + linear_feature_columns = [ language_column ] , <nl> + dnn_feature_columns = [ <nl> + feature_column . embedding_column ( <nl> + language_column , dimension = 1 ) , <nl> + feature_column . real_valued_column ( ' age ' ) <nl> + ] , <nl> + dnn_hidden_units = [ 3 , 3 ] , <nl> + label_keys = label_keys ) <nl> + <nl> + classifier . fit ( input_fn = _input_fn , steps = 50 ) <nl> + <nl> + scores = classifier . evaluate ( input_fn = _input_fn , steps = 1 ) <nl> + _assert_metrics_in_range ( ( ' accuracy ' , ) , scores ) <nl> + self . assertIn ( ' loss ' , scores ) <nl> + predict_input_fn = functools . partial ( _input_fn , num_epochs = 1 ) <nl> + predicted_classes = list ( <nl> + classifier . predict_classes ( <nl> + input_fn = predict_input_fn , as_iterable = True ) ) <nl> + self . assertEqual ( 3 , len ( predicted_classes ) ) <nl> + for pred in predicted_classes : <nl> + self . assertIn ( pred , label_keys ) <nl> + predictions = list ( <nl> + classifier . predict ( input_fn = predict_input_fn , as_iterable = True ) ) <nl> + self . assertAllEqual ( predicted_classes , predictions ) <nl> + <nl> def testLoss ( self ) : <nl> " " " Tests loss calculation . " " " <nl> <nl> mmm a / tensorflow / contrib / learn / python / learn / estimators / linear . py <nl> ppp b / tensorflow / contrib / learn / python / learn / estimators / linear . py <nl> def input_fn_train : # returns x , y ( where y represents label ' s class index ) . <nl> . . . <nl> def input_fn_eval : # returns x , y ( where y represents label ' s class index ) . <nl> . . . <nl> + def input_fn_predict : # returns x , None . <nl> + . . . <nl> estimator . fit ( input_fn = input_fn_train ) <nl> estimator . evaluate ( input_fn = input_fn_eval ) <nl> - estimator . predict ( x = x ) # returns predicted labels ( i . e . label ' s class index ) . <nl> + # predict_classes returns class indices . <nl> + estimator . predict_classes ( input_fn = input_fn_predict ) <nl> + ` ` ` <nl> + <nl> + If the user specifies ` label_keys ` in constructor , labels must be strings from <nl> + the ` label_keys ` vocabulary . Example : <nl> + <nl> + ` ` ` python <nl> + label_keys = [ ' label0 ' , ' label1 ' , ' label2 ' ] <nl> + estimator = LinearClassifier ( <nl> + n_classes = n_classes , <nl> + feature_columns = [ sparse_column_a , sparse_feature_a_x_sparse_feature_b ] , <nl> + label_keys = label_keys ) <nl> + <nl> + def input_fn_train : # returns x , y ( where y is one of label_keys ) . <nl> + pass <nl> + estimator . fit ( input_fn = input_fn_train ) <nl> + <nl> + def input_fn_eval : # returns x , y ( where y is one of label_keys ) . <nl> + pass <nl> + estimator . evaluate ( input_fn = input_fn_eval ) <nl> + def input_fn_predict : # returns x , None <nl> + # predict_classes returns one of label_keys . <nl> + estimator . predict_classes ( input_fn = input_fn_predict ) <nl> ` ` ` <nl> <nl> Input of ` fit ` and ` evaluate ` should have following features , <nl> def __init__ ( self , # _joint_weight pylint : disable = invalid - name <nl> enable_centered_bias = False , <nl> _joint_weight = False , <nl> config = None , <nl> - feature_engineering_fn = None ) : <nl> + feature_engineering_fn = None , <nl> + label_keys = None ) : <nl> " " " Construct a ` LinearClassifier ` estimator object . <nl> <nl> Args : <nl> def __init__ ( self , # _joint_weight pylint : disable = invalid - name <nl> labels which are the output of ` input_fn ` and <nl> returns features and labels which will be fed <nl> into the model . <nl> + label_keys : Optional list of strings with size ` [ n_classes ] ` defining the <nl> + label vocabulary . Only supported for ` n_classes ` > 2 . <nl> <nl> Returns : <nl> A ` LinearClassifier ` estimator . <nl> def __init__ ( self , # _joint_weight pylint : disable = invalid - name <nl> head = head_lib . multi_class_head ( <nl> n_classes , <nl> weight_column_name = weight_column_name , <nl> - enable_centered_bias = enable_centered_bias ) <nl> + enable_centered_bias = enable_centered_bias , <nl> + label_keys = label_keys ) <nl> params = { <nl> " head " : head , <nl> " feature_columns " : feature_columns , <nl> mmm a / tensorflow / contrib / learn / python / learn / estimators / linear_test . py <nl> ppp b / tensorflow / contrib / learn / python / learn / estimators / linear_test . py <nl> def testMultiClass_NpMatrixData ( self ) : <nl> scores = classifier . evaluate ( x = train_x , y = train_y , steps = 1 ) <nl> self . assertGreater ( scores [ ' accuracy ' ] , 0 . 9 ) <nl> <nl> + def testMultiClassLabelKeys ( self ) : <nl> + " " " Tests n_classes > 2 with label_keys vocabulary for labels . " " " <nl> + # Byte literals needed for python3 test to pass . <nl> + label_keys = [ b ' label0 ' , b ' label1 ' , b ' label2 ' ] <nl> + <nl> + def _input_fn ( num_epochs = None ) : <nl> + features = { <nl> + ' language ' : <nl> + sparse_tensor . SparseTensor ( <nl> + values = input_lib . limit_epochs ( <nl> + [ ' en ' , ' fr ' , ' zh ' ] , num_epochs = num_epochs ) , <nl> + indices = [ [ 0 , 0 ] , [ 0 , 1 ] , [ 2 , 0 ] ] , <nl> + dense_shape = [ 3 , 2 ] ) <nl> + } <nl> + labels = constant_op . constant ( <nl> + [ [ label_keys [ 1 ] ] , [ label_keys [ 0 ] ] , [ label_keys [ 0 ] ] ] , <nl> + dtype = dtypes . string ) <nl> + return features , labels <nl> + <nl> + language_column = feature_column_lib . sparse_column_with_hash_bucket ( <nl> + ' language ' , hash_bucket_size = 20 ) <nl> + <nl> + classifier = linear . LinearClassifier ( <nl> + n_classes = 3 , <nl> + feature_columns = [ language_column ] , <nl> + label_keys = label_keys ) <nl> + <nl> + classifier . fit ( input_fn = _input_fn , steps = 50 ) <nl> + <nl> + scores = classifier . evaluate ( input_fn = _input_fn , steps = 1 ) <nl> + self . assertGreater ( scores [ ' accuracy ' ] , 0 . 9 ) <nl> + self . assertIn ( ' loss ' , scores ) <nl> + predict_input_fn = functools . partial ( _input_fn , num_epochs = 1 ) <nl> + predicted_classes = list ( <nl> + classifier . predict_classes ( <nl> + input_fn = predict_input_fn , as_iterable = True ) ) <nl> + self . assertEqual ( 3 , len ( predicted_classes ) ) <nl> + for pred in predicted_classes : <nl> + self . assertIn ( pred , label_keys ) <nl> + predictions = list ( <nl> + classifier . predict ( input_fn = predict_input_fn , as_iterable = True ) ) <nl> + self . assertAllEqual ( predicted_classes , predictions ) <nl> + <nl> def testLogisticRegression_MatrixData ( self ) : <nl> " " " Tests binary classification using matrix data as input . " " " <nl> <nl>
Support label_keys in DNNLinearCombinedClassifier and in LinearClassifier .
tensorflow/tensorflow
56bca499698cee57cfc7424089f0b0c183cd3bfd
2017-04-28T22:28:23Z
mmm a / arangod / Utils / ExplicitTransaction . h <nl> ppp b / arangod / Utils / ExplicitTransaction . h <nl> class ExplicitTransaction : public Transaction { <nl> ExplicitTransaction ( std : : shared_ptr < V8TransactionContext > transactionContext , <nl> std : : vector < std : : string > const & readCollections , <nl> std : : vector < std : : string > const & writeCollections , <nl> - double lockTimeout , bool waitForSync , bool embed , <nl> + double lockTimeout , bool waitForSync , <nl> bool allowImplicitCollections ) <nl> : Transaction ( transactionContext , 0 ) { <nl> this - > addHint ( TRI_TRANSACTION_HINT_LOCK_ENTIRELY , false ) ; <nl> mmm a / arangod / V8Server / V8Traverser . h <nl> ppp b / arangod / V8Server / V8Traverser . h <nl> <nl> # ifndef ARANGOD_V8_SERVER_V8_TRAVERSER_H <nl> # define ARANGOD_V8_SERVER_V8_TRAVERSER_H 1 <nl> <nl> - # include " Utils / ExplicitTransaction . h " <nl> # include " VocBase / ExampleMatcher . h " <nl> # include " VocBase / Traverser . h " <nl> <nl> mmm a / arangod / V8Server / v8 - vocbase . cpp <nl> ppp b / arangod / V8Server / v8 - vocbase . cpp <nl> <nl> # include " Aql / QueryList . h " <nl> # include " Aql / QueryRegistry . h " <nl> # include " Basics / conversions . h " <nl> - # include " Basics / json - utilities . h " <nl> # include " Basics / MutexLocker . h " <nl> # include " Basics / ScopeGuard . h " <nl> # include " Basics / tri - strings . h " <nl> # include " Basics / Utf8Helper . h " <nl> - # include " Cluster / AgencyComm . h " <nl> # include " Cluster / ClusterComm . h " <nl> # include " Cluster / ClusterInfo . h " <nl> # include " Cluster / ClusterMethods . h " <nl> # include " Cluster / ServerState . h " <nl> - # include " Indexes / Index . h " <nl> # include " HttpServer / ApplicationEndpointServer . h " <nl> # include " RestServer / ConsoleThread . h " <nl> # include " RestServer / VocbaseContext . h " <nl> # include " Rest / Version . h " <nl> + # include " Utils / ExplicitTransaction . h " <nl> + # include " Utils / V8TransactionContext . h " <nl> # include " V8 / JSLoader . h " <nl> # include " V8 / v8 - conv . h " <nl> # include " V8 / v8 - utils . h " <nl> static void JS_Transaction ( v8 : : FunctionCallbackInfo < v8 : : Value > const & args ) { <nl> TRI_V8_THROW_EXCEPTION_PARAMETER ( actionError ) ; <nl> } <nl> <nl> - auto transactionContext = std : : make_shared < V8TransactionContext > ( vocbase , false ) ; <nl> + auto transactionContext = std : : make_shared < V8TransactionContext > ( vocbase , embed ) ; <nl> <nl> / / start actual transaction <nl> ExplicitTransaction trx ( transactionContext , readCollections , writeCollections , <nl> - lockTimeout , waitForSync , embed , <nl> + lockTimeout , waitForSync , <nl> allowImplicitCollections ) ; <nl> <nl> int res = trx . begin ( ) ; <nl> static ExplicitTransaction * BeginTransaction ( <nl> / / IHHF isCoordinator <nl> double lockTimeout = <nl> ( double ) ( TRI_TRANSACTION_DEFAULT_LOCK_TIMEOUT / 1000000ULL ) ; <nl> - bool embed = true ; <nl> bool waitForSync = false ; <nl> <nl> / / Start Transaction to collect all parts of the path <nl> auto trx = std : : make_unique < ExplicitTransaction > ( <nl> transactionContext , readCollections , writeCollections , lockTimeout , waitForSync , <nl> - embed , true ) ; <nl> + true ) ; <nl> <nl> int res = trx - > begin ( ) ; <nl> if ( res ! = TRI_ERROR_NO_ERROR ) { <nl>
bugfixes
arangodb/arangodb
13980ef299cd54d9f0222b12e99de01aa4d04f11
2016-03-24T15:18:18Z
deleted file mode 100755 <nl> index d37c798d428 . . 00000000000 <nl> mmm a / docker / build / installers / install_opuslib . sh <nl> ppp / dev / null <nl> <nl> - # ! / usr / bin / env bash <nl> - <nl> - # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> - # Copyright 2019 The Apollo Authors . All Rights Reserved . <nl> - # <nl> - # Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> - # you may not use this file except in compliance with the License . <nl> - # You may obtain a copy of the License at <nl> - # <nl> - # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> - # <nl> - # Unless required by applicable law or agreed to in writing , software <nl> - # distributed under the License is distributed on an " AS IS " BASIS , <nl> - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> - # See the License for the specific language governing permissions and <nl> - # limitations under the License . <nl> - # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> - <nl> - # Fail on first error . <nl> - set - e <nl> - <nl> - cd " $ ( dirname " $ { BASH_SOURCE [ 0 ] } " ) " <nl> - <nl> - # Prepare <nl> - PACKAGE = " 2 . 0 . 0 . tar . gz " <nl> - OPUSLIB = " opuslib - 2 . 0 . 0 " <nl> - wget https : / / github . com / OnBeep / opuslib / archive / $ { PACKAGE } <nl> - tar zxf $ { PACKAGE } <nl> - <nl> - # Build and install . <nl> - pushd $ { OPUSLIB } <nl> - make <nl> - make install <nl> - popd <nl> - <nl> - # Clean <nl> - rm - fr $ { PACKAGE } $ { OPUSLIB } <nl> - <nl>
Docker : remove unused installers
ApolloAuto/apollo
ac7a7aa5c917efac208335c4791c42b4e524aa2e
2020-07-21T15:43:53Z
mmm a / PowerEditor / src / MISC / RegExt / regExtDlg . cpp <nl> ppp b / PowerEditor / src / MISC / RegExt / regExtDlg . cpp <nl> void RegExtDlg : : doDialog ( bool isRTL ) <nl> { <nl> DLGTEMPLATE * pMyDlgTemplate = NULL ; <nl> HGLOBAL hMyDlgTemplate = makeRTLResource ( IDD_REGEXT_BOX , & pMyDlgTemplate ) ; <nl> - : : DialogBoxIndirectParam ( _hInst , pMyDlgTemplate , _hParent , ( DLGPROC ) dlgProc , ( LPARAM ) this ) ; <nl> + : : DialogBoxIndirectParam ( _hInst , pMyDlgTemplate , _hParent , dlgProc , ( LPARAM ) this ) ; <nl> : : GlobalFree ( hMyDlgTemplate ) ; <nl> } <nl> else <nl> - : : DialogBoxParam ( _hInst , MAKEINTRESOURCE ( IDD_REGEXT_BOX ) , _hParent , ( DLGPROC ) dlgProc , ( LPARAM ) this ) ; <nl> + : : DialogBoxParam ( _hInst , MAKEINTRESOURCE ( IDD_REGEXT_BOX ) , _hParent , dlgProc , ( LPARAM ) this ) ; <nl> } ; <nl> <nl> - BOOL CALLBACK RegExtDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) <nl> + INT_PTR CALLBACK RegExtDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) <nl> { <nl> switch ( Message ) <nl> { <nl> mmm a / PowerEditor / src / MISC / RegExt / regExtDlg . h <nl> ppp b / PowerEditor / src / MISC / RegExt / regExtDlg . h <nl> public : <nl> private : <nl> bool _isCustomize ; <nl> <nl> - BOOL CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> + INT_PTR CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> <nl> void getRegisteredExts ( ) ; <nl> void getDefSupportedExts ( ) ; <nl> mmm a / PowerEditor / src / ScitillaComponent / FindReplaceDlg . cpp <nl> ppp b / PowerEditor / src / ScitillaComponent / FindReplaceDlg . cpp <nl> void Finder : : gotoNextFoundResult ( int direction ) <nl> } <nl> } <nl> <nl> - BOOL CALLBACK FindReplaceDlg : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) <nl> + INT_PTR CALLBACK FindReplaceDlg : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) <nl> { <nl> switch ( message ) <nl> { <nl> void Finder : : setFinderStyle ( ) <nl> _scintView . execute ( SCI_COLOURISE , 0 , - 1 ) ; <nl> } <nl> <nl> - BOOL CALLBACK Finder : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) <nl> + INT_PTR CALLBACK Finder : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) <nl> { <nl> switch ( message ) <nl> { <nl> void FindIncrementDlg : : display ( bool toShow ) const <nl> _pRebar - > setIDVisible ( _rbBand . wID , toShow ) ; <nl> } <nl> <nl> - BOOL CALLBACK FindIncrementDlg : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) <nl> + INT_PTR CALLBACK FindIncrementDlg : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) <nl> { <nl> switch ( message ) <nl> { <nl> mmm a / PowerEditor / src / ScitillaComponent / FindReplaceDlg . h <nl> ppp b / PowerEditor / src / ScitillaComponent / FindReplaceDlg . h <nl> friend class FindReplaceDlg ; <nl> void DeleteResult ( ) ; <nl> <nl> protected : <nl> - virtual BOOL CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> + virtual INT_PTR CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> bool notify ( SCNotification * notification ) ; <nl> <nl> private : <nl> public : <nl> <nl> <nl> protected : <nl> - virtual BOOL CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> + virtual INT_PTR CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> void addText2Combo ( const TCHAR * txt2add , HWND comboID , bool isUTF8 = false ) ; <nl> generic_string getTextFromCombo ( HWND hCombo , bool isUnicode = false ) const ; <nl> static LONG originalFinderProc ; <nl> private : <nl> ReBar * _pRebar ; <nl> REBARBANDINFO _rbBand ; <nl> <nl> - virtual BOOL CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> + virtual INT_PTR CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> void markSelectedTextInc ( bool enable , FindOption * opt = NULL ) ; <nl> } ; <nl> <nl> mmm a / PowerEditor / src / ScitillaComponent / GoToLineDlg . cpp <nl> ppp b / PowerEditor / src / ScitillaComponent / GoToLineDlg . cpp <nl> <nl> # include " GoToLineDlg . h " <nl> <nl> <nl> - BOOL CALLBACK GoToLineDlg : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM ) <nl> + INT_PTR CALLBACK GoToLineDlg : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM ) <nl> { <nl> switch ( message ) <nl> { <nl> mmm a / PowerEditor / src / ScitillaComponent / GoToLineDlg . h <nl> ppp b / PowerEditor / src / ScitillaComponent / GoToLineDlg . h <nl> public : <nl> protected : <nl> enum mode { go2line , go2offsset } ; <nl> mode _mode ; <nl> - virtual BOOL CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> + virtual INT_PTR CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> <nl> private : <nl> <nl> mmm a / PowerEditor / src / ScitillaComponent / UserDefineDialog . cpp <nl> ppp b / PowerEditor / src / ScitillaComponent / UserDefineDialog . cpp <nl> bool SharedParametersDialog : : setPropertyByCheck ( HWND hwnd , WPARAM id , bool & boo <nl> return TRUE ; <nl> } <nl> <nl> - BOOL CALLBACK SharedParametersDialog : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM / * lParam * / ) <nl> + INT_PTR CALLBACK SharedParametersDialog : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM / * lParam * / ) <nl> { <nl> switch ( Message ) <nl> { <nl> BOOL CALLBACK SharedParametersDialog : : run_dlgProc ( UINT Message , WPARAM wParam , L <nl> return FALSE ; <nl> } <nl> <nl> - BOOL CALLBACK FolderStyleDialog : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) <nl> + INT_PTR CALLBACK FolderStyleDialog : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) <nl> { <nl> switch ( Message ) <nl> { <nl> void FolderStyleDialog : : retrieve ( TCHAR * dest , const TCHAR * toRetrieve , TCHAR * pr <nl> dest [ j + + ] = ' \ 0 ' ; <nl> } <nl> <nl> - BOOL CALLBACK KeyWordsStyleDialog : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) <nl> + INT_PTR CALLBACK KeyWordsStyleDialog : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) <nl> { <nl> switch ( Message ) <nl> { <nl> void KeyWordsStyleDialog : : updateDlg ( ) <nl> : : SendDlgItemMessage ( _hSelf , IDC_KEYWORD8_PREFIX_CHECK , BM_SETCHECK , _pUserLang - > _isPrefix [ 7 ] , 0 ) ; <nl> } <nl> <nl> - BOOL CALLBACK CommentStyleDialog : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) <nl> + INT_PTR CALLBACK CommentStyleDialog : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) <nl> { <nl> switch ( Message ) <nl> { <nl> void SymbolsStyleDialog : : updateDlg ( ) <nl> : : SendDlgItemMessage ( _hSelf , IDC_OPERATOR2_EDIT , WM_SETTEXT , 0 , ( LPARAM ) ( _pUserLang - > _keywordLists [ SCE_USER_KWLIST_OPERATORS2 ] ) ) ; <nl> } <nl> <nl> - BOOL CALLBACK SymbolsStyleDialog : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) <nl> + INT_PTR CALLBACK SymbolsStyleDialog : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) <nl> { <nl> switch ( Message ) <nl> { <nl> void UserDefineDialog : : updateDlg ( ) <nl> _symbolsStyleDlg . updateDlg ( ) ; <nl> } <nl> <nl> - BOOL CALLBACK UserDefineDialog : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) <nl> + INT_PTR CALLBACK UserDefineDialog : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) <nl> { <nl> NppParameters * pNppParam = NppParameters : : getInstance ( ) ; <nl> switch ( message ) <nl> BOOL CALLBACK UserDefineDialog : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM <nl> return FALSE ; <nl> } <nl> <nl> - BOOL CALLBACK StringDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> + INT_PTR CALLBACK StringDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> { <nl> switch ( Message ) <nl> { <nl> BOOL CALLBACK StringDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> } <nl> } <nl> <nl> - BOOL CALLBACK StylerDlg : : dlgProc ( HWND hwnd , UINT message , WPARAM wParam , LPARAM lParam ) <nl> + INT_PTR CALLBACK StylerDlg : : dlgProc ( HWND hwnd , UINT message , WPARAM wParam , LPARAM lParam ) <nl> { <nl> StylerDlg * dlg = ( StylerDlg * ) : : GetProp ( hwnd , TEXT ( " Styler dialog prop " ) ) ; <nl> NppParameters * pNppParam = NppParameters : : getInstance ( ) ; <nl> mmm a / PowerEditor / src / ScitillaComponent / UserDefineDialog . h <nl> ppp b / PowerEditor / src / ScitillaComponent / UserDefineDialog . h <nl> protected : <nl> / / Shared data <nl> static UserLangContainer * _pUserLang ; <nl> static ScintillaEditView * _pScintilla ; <nl> - BOOL CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> + INT_PTR CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> bool setPropertyByCheck ( HWND hwnd , WPARAM id , bool & bool2set ) ; <nl> virtual void setKeywords2List ( int ctrlID ) = 0 ; <nl> } ; <nl> class FolderStyleDialog : public SharedParametersDialog <nl> FolderStyleDialog ( ) : SharedParametersDialog ( ) { } ; <nl> void updateDlg ( ) ; <nl> protected : <nl> - BOOL CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> + INT_PTR CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> void setKeywords2List ( int ctrlID ) ; <nl> private : <nl> void convertTo ( TCHAR * dest , const TCHAR * toConvert , TCHAR * prefix ) const ; <nl> class KeyWordsStyleDialog : public SharedParametersDialog <nl> KeyWordsStyleDialog ( ) : SharedParametersDialog ( ) { } ; <nl> void updateDlg ( ) ; <nl> protected : <nl> - BOOL CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> + INT_PTR CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> void setKeywords2List ( int id ) ; <nl> } ; <nl> <nl> public : <nl> CommentStyleDialog ( ) : SharedParametersDialog ( ) { } ; <nl> void updateDlg ( ) ; <nl> protected : <nl> - BOOL CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> + INT_PTR CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> void setKeywords2List ( int id ) ; <nl> private : <nl> void convertTo ( TCHAR * dest , const TCHAR * toConvert , TCHAR * prefix ) const ; <nl> public : <nl> SymbolsStyleDialog ( ) : SharedParametersDialog ( ) { } ; <nl> void updateDlg ( ) ; <nl> protected : <nl> - BOOL CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> + INT_PTR CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> void setKeywords2List ( int id ) ; <nl> private : <nl> void convertTo ( TCHAR * dest , const TCHAR * toConvert , TCHAR * prefix ) const ; <nl> public : <nl> _ctrlTab . renameTab ( index , name2set ) ; <nl> } ; <nl> protected : <nl> - virtual BOOL CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> + virtual INT_PTR CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> private : <nl> ControlsTab _ctrlTab ; <nl> WindowVector _wVector ; <nl> public : <nl> _txtLen = txtLen ; <nl> } ; <nl> long doDialog ( ) { <nl> - return long ( : : DialogBoxParam ( _hInst , MAKEINTRESOURCE ( IDD_STRING_DLG ) , _hParent , ( DLGPROC ) dlgProc , ( LPARAM ) this ) ) ; <nl> + return long ( : : DialogBoxParam ( _hInst , MAKEINTRESOURCE ( IDD_STRING_DLG ) , _hParent , dlgProc , ( LPARAM ) this ) ) ; <nl> } ; <nl> virtual void destroy ( ) { } ; <nl> protected : <nl> - BOOL CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) ; <nl> + INT_PTR CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) ; <nl> private : <nl> generic_string _title ; <nl> generic_string _textValue ; <nl> class StylerDlg <nl> } ; <nl> <nl> long doDialog ( ) { <nl> - return long ( : : DialogBoxParam ( _hInst , MAKEINTRESOURCE ( IDD_STYLER_POPUP_DLG ) , _parent , ( DLGPROC ) dlgProc , ( LPARAM ) this ) ) ; <nl> + return long ( : : DialogBoxParam ( _hInst , MAKEINTRESOURCE ( IDD_STYLER_POPUP_DLG ) , _parent , dlgProc , ( LPARAM ) this ) ) ; <nl> } ; <nl> <nl> - static BOOL CALLBACK dlgProc ( HWND hwnd , UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> + static INT_PTR CALLBACK dlgProc ( HWND hwnd , UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> public : <nl> HINSTANCE _hInst ; <nl> HWND _parent ; <nl> mmm a / PowerEditor / src / ScitillaComponent / columnEditor . cpp <nl> ppp b / PowerEditor / src / ScitillaComponent / columnEditor . cpp <nl> void ColumnEditorDlg : : display ( bool toShow ) const <nl> : : SetFocus ( : : GetDlgItem ( _hSelf , ID_GOLINE_EDIT ) ) ; <nl> } <nl> <nl> - BOOL CALLBACK ColumnEditorDlg : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM ) <nl> + INT_PTR CALLBACK ColumnEditorDlg : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM ) <nl> { <nl> switch ( message ) <nl> { <nl> mmm a / PowerEditor / src / ScitillaComponent / columnEditor . h <nl> ppp b / PowerEditor / src / ScitillaComponent / columnEditor . h <nl> public : <nl> UCHAR getFormat ( ) ; <nl> <nl> protected : <nl> - virtual BOOL CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> + virtual INT_PTR CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> <nl> private : <nl> <nl> mmm a / PowerEditor / src / WinControls / AboutDlg / AboutDlg . h <nl> ppp b / PowerEditor / src / WinControls / AboutDlg / AboutDlg . h <nl> public : <nl> } ; <nl> <nl> protected : <nl> - virtual BOOL CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> + virtual INT_PTR CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> <nl> private : <nl> URLCtrl _emailLink ; <nl> mmm a / PowerEditor / src / WinControls / AnsiCharPanel / ansiCharPanel . cpp <nl> ppp b / PowerEditor / src / WinControls / AnsiCharPanel / ansiCharPanel . cpp <nl> void AnsiCharPanel : : switchEncoding ( ) <nl> _listView . resetValues ( codepage ) ; <nl> } <nl> <nl> - BOOL CALLBACK AnsiCharPanel : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) <nl> + INT_PTR CALLBACK AnsiCharPanel : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) <nl> { <nl> switch ( message ) <nl> { <nl> mmm a / PowerEditor / src / WinControls / AnsiCharPanel / ansiCharPanel . h <nl> ppp b / PowerEditor / src / WinControls / AnsiCharPanel / ansiCharPanel . h <nl> class AnsiCharPanel : public DockingDlgInterface { <nl> } ; <nl> <nl> protected : <nl> - virtual BOOL CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> + virtual INT_PTR CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> <nl> private : <nl> ScintillaEditView * * _ppEditView ; <nl> mmm a / PowerEditor / src / WinControls / ClipboardHistory / clipboardHistoryPanel . cpp <nl> ppp b / PowerEditor / src / WinControls / ClipboardHistory / clipboardHistoryPanel . cpp <nl> void ClipboardHistoryPanel : : drawItem ( LPDRAWITEMSTRUCT lpDrawItemStruct ) <nl> : : DrawText ( lpDrawItemStruct - > hDC , ptStr , lstrlen ( ptStr ) , & ( lpDrawItemStruct - > rcItem ) , DT_SINGLELINE | DT_VCENTER | DT_LEFT ) ; <nl> } <nl> <nl> - BOOL CALLBACK ClipboardHistoryPanel : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) <nl> + INT_PTR CALLBACK ClipboardHistoryPanel : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) <nl> { <nl> switch ( message ) <nl> { <nl> mmm a / PowerEditor / src / WinControls / ClipboardHistory / clipboardHistoryPanel . h <nl> ppp b / PowerEditor / src / WinControls / ClipboardHistory / clipboardHistoryPanel . h <nl> class ClipboardHistoryPanel : public DockingDlgInterface { <nl> void drawItem ( LPDRAWITEMSTRUCT lpDrawItemStruct ) ; <nl> <nl> protected : <nl> - virtual BOOL CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> + virtual INT_PTR CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> <nl> private : <nl> ScintillaEditView * * _ppEditView ; <nl> mmm a / PowerEditor / src / WinControls / ColourPicker / ColourPopup . cpp <nl> ppp b / PowerEditor / src / WinControls / ColourPicker / ColourPopup . cpp <nl> DWORD colourItems [ ] = { <nl> <nl> void ColourPopup : : create ( int dialogID ) <nl> { <nl> - _hSelf = : : CreateDialogParam ( _hInst , MAKEINTRESOURCE ( dialogID ) , _hParent , ( DLGPROC ) dlgProc , ( LPARAM ) this ) ; <nl> + _hSelf = : : CreateDialogParam ( _hInst , MAKEINTRESOURCE ( dialogID ) , _hParent , dlgProc , ( LPARAM ) this ) ; <nl> <nl> if ( ! _hSelf ) <nl> { <nl> void ColourPopup : : create ( int dialogID ) <nl> display ( ) ; <nl> } <nl> <nl> - BOOL CALLBACK ColourPopup : : dlgProc ( HWND hwnd , UINT message , WPARAM wParam , LPARAM lParam ) <nl> + INT_PTR CALLBACK ColourPopup : : dlgProc ( HWND hwnd , UINT message , WPARAM wParam , LPARAM lParam ) <nl> { <nl> switch ( message ) <nl> { <nl> mmm a / PowerEditor / src / WinControls / ColourPicker / ColourPopup . h <nl> ppp b / PowerEditor / src / WinControls / ColourPicker / ColourPopup . h <nl> private : <nl> COLORREF _colour ; <nl> / / bool isColourChooserLaunched ; <nl> <nl> - static BOOL CALLBACK dlgProc ( HWND hwnd , UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> - BOOL CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> + static INT_PTR CALLBACK dlgProc ( HWND hwnd , UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> + INT_PTR CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> } ; <nl> <nl> # endif / / COLOUR_POPUP_H <nl> mmm a / PowerEditor / src / WinControls / ColourPicker / WordStyleDlg . cpp <nl> ppp b / PowerEditor / src / WinControls / ColourPicker / WordStyleDlg . cpp <nl> <nl> <nl> using namespace std ; <nl> <nl> - BOOL CALLBACK ColourStaticTextHooker : : colourStaticProc ( HWND hwnd , UINT Message , WPARAM wParam , LPARAM lParam ) <nl> + LRESULT CALLBACK ColourStaticTextHooker : : colourStaticProc ( HWND hwnd , UINT Message , WPARAM wParam , LPARAM lParam ) <nl> { <nl> switch ( Message ) <nl> { <nl> void WordStyleDlg : : updateGlobalOverrideCtrls ( ) <nl> : : SendDlgItemMessage ( _hSelf , IDC_GLOBAL_UNDERLINE_CHECK , BM_SETCHECK , nppGUI . _globalOverride . enableUnderLine , 0 ) ; <nl> } <nl> <nl> - BOOL CALLBACK WordStyleDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) <nl> + INT_PTR CALLBACK WordStyleDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) <nl> { <nl> switch ( Message ) <nl> { <nl> mmm a / PowerEditor / src / WinControls / ColourPicker / WordStyleDlg . h <nl> ppp b / PowerEditor / src / WinControls / ColourPicker / WordStyleDlg . h <nl> private : <nl> COLORREF _colour ; <nl> WNDPROC _oldProc ; <nl> <nl> - static BOOL CALLBACK staticProc ( HWND hwnd , UINT message , WPARAM wParam , LPARAM lParam ) { <nl> + static LRESULT CALLBACK staticProc ( HWND hwnd , UINT message , WPARAM wParam , LPARAM lParam ) { <nl> ColourStaticTextHooker * pColourStaticTextHooker = reinterpret_cast < ColourStaticTextHooker * > ( : : GetWindowLongPtr ( hwnd , GWL_USERDATA ) ) ; <nl> return pColourStaticTextHooker - > colourStaticProc ( hwnd , message , wParam , lParam ) ; <nl> } ; <nl> - BOOL CALLBACK colourStaticProc ( HWND hwnd , UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> + LRESULT CALLBACK colourStaticProc ( HWND hwnd , UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> } ; <nl> <nl> class WordStyleDlg : public StaticDialog <nl> private : <nl> / / bool _isSync ; <nl> bool _isShownGOCtrls ; <nl> <nl> - BOOL CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> + INT_PTR CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> <nl> <nl> Style & getCurrentStyler ( ) { <nl> mmm a / PowerEditor / src / WinControls / DockingWnd / DockingCont . cpp <nl> ppp b / PowerEditor / src / WinControls / DockingWnd / DockingCont . cpp <nl> void DockingCont : : drawTabItem ( DRAWITEMSTRUCT * pDrawItemStruct ) <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> / / Process function of dialog <nl> / / <nl> - BOOL CALLBACK DockingCont : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) <nl> + INT_PTR CALLBACK DockingCont : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) <nl> { <nl> switch ( Message ) <nl> { <nl> mmm a / PowerEditor / src / WinControls / DockingWnd / DockingCont . h <nl> ppp b / PowerEditor / src / WinControls / DockingWnd / DockingCont . h <nl> protected : <nl> return ( ( ( DockingCont * ) ( : : GetWindowLongPtr ( hwnd , GWL_USERDATA ) ) ) - > runProcTab ( hwnd , Message , wParam , lParam ) ) ; <nl> } ; <nl> <nl> - virtual BOOL CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> + virtual INT_PTR CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> <nl> / / drawing functions <nl> void drawCaptionItem ( DRAWITEMSTRUCT * pDrawItemStruct ) ; <nl> mmm a / PowerEditor / src / WinControls / DockingWnd / DockingDlgInterface . h <nl> ppp b / PowerEditor / src / WinControls / DockingWnd / DockingDlgInterface . h <nl> class DockingDlgInterface : public StaticDialog <nl> } ; <nl> <nl> protected : <nl> - virtual BOOL CALLBACK run_dlgProc ( UINT message , WPARAM , LPARAM lParam ) <nl> + virtual INT_PTR CALLBACK run_dlgProc ( UINT message , WPARAM , LPARAM lParam ) <nl> { <nl> switch ( message ) <nl> { <nl> mmm a / PowerEditor / src / WinControls / DocumentMap / documentMap . cpp <nl> ppp b / PowerEditor / src / WinControls / DocumentMap / documentMap . cpp <nl> void DocumentMap : : redraw ( bool ) const <nl> _pScintillaEditView - > execute ( SCI_COLOURISE , 0 , - 1 ) ; <nl> } <nl> <nl> - BOOL CALLBACK DocumentMap : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) <nl> + INT_PTR CALLBACK DocumentMap : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) <nl> { <nl> switch ( message ) <nl> { <nl> void ViewZoneDlg : : doDialog ( ) <nl> display ( ) ; <nl> } ; <nl> <nl> - BOOL CALLBACK ViewZoneDlg : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) <nl> + INT_PTR CALLBACK ViewZoneDlg : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) <nl> { <nl> switch ( message ) <nl> { <nl> BOOL CALLBACK ViewZoneDlg : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM lPara <nl> return FALSE ; <nl> } <nl> <nl> - BOOL CALLBACK ViewZoneDlg : : canvasStaticProc ( HWND hwnd , UINT message , WPARAM wParam , LPARAM lParam ) <nl> + LRESULT CALLBACK ViewZoneDlg : : canvasStaticProc ( HWND hwnd , UINT message , WPARAM wParam , LPARAM lParam ) <nl> { <nl> ViewZoneDlg * pViewZoneDlg = reinterpret_cast < ViewZoneDlg * > ( : : GetWindowLongPtr ( hwnd , GWL_USERDATA ) ) ; <nl> if ( ! pViewZoneDlg ) <nl> BOOL CALLBACK ViewZoneDlg : : canvasStaticProc ( HWND hwnd , UINT message , WPARAM wPar <nl> return pViewZoneDlg - > canvas_runProc ( hwnd , message , wParam , lParam ) ; <nl> } <nl> <nl> - BOOL CALLBACK ViewZoneDlg : : canvas_runProc ( HWND hwnd , UINT message , WPARAM wParam , LPARAM lParam ) <nl> + LRESULT CALLBACK ViewZoneDlg : : canvas_runProc ( HWND hwnd , UINT message , WPARAM wParam , LPARAM lParam ) <nl> { <nl> switch ( message ) <nl> { <nl> mmm a / PowerEditor / src / WinControls / DocumentMap / documentMap . h <nl> ppp b / PowerEditor / src / WinControls / DocumentMap / documentMap . h <nl> public : <nl> } ; <nl> <nl> protected : <nl> - virtual BOOL CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> + virtual INT_PTR CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> <nl> - static BOOL CALLBACK canvasStaticProc ( HWND hwnd , UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> - BOOL CALLBACK canvas_runProc ( HWND hwnd , UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> + static LRESULT CALLBACK canvasStaticProc ( HWND hwnd , UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> + LRESULT CALLBACK canvas_runProc ( HWND hwnd , UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> <nl> void drawPreviewZone ( DRAWITEMSTRUCT * pdis ) ; <nl> <nl> class DocumentMap : public DockingDlgInterface { <nl> void changeTextDirection ( bool isRTL ) ; <nl> <nl> protected : <nl> - virtual BOOL CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> + virtual INT_PTR CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> bool needToRecomputeWith ( ) ; <nl> int getEditorTextZoneWidth ( ) ; <nl> <nl> mmm a / PowerEditor / src / WinControls / FindCharsInRange / FindCharsInRange . cpp <nl> ppp b / PowerEditor / src / WinControls / FindCharsInRange / FindCharsInRange . cpp <nl> <nl> # include " FindCharsInRange . h " <nl> # include " FindCharsInRange_rc . h " <nl> <nl> - BOOL CALLBACK FindCharsInRangeDlg : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM ) <nl> + INT_PTR CALLBACK FindCharsInRangeDlg : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM ) <nl> { <nl> switch ( message ) <nl> { <nl> mmm a / PowerEditor / src / WinControls / FindCharsInRange / FindCharsInRange . h <nl> ppp b / PowerEditor / src / WinControls / FindCharsInRange / FindCharsInRange . h <nl> public : <nl> } ; <nl> <nl> protected : <nl> - virtual BOOL CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> + virtual INT_PTR CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> <nl> private : <nl> ScintillaEditView * * _ppEditView ; <nl> mmm a / PowerEditor / src / WinControls / FunctionList / functionListPanel . cpp <nl> ppp b / PowerEditor / src / WinControls / FunctionList / functionListPanel . cpp <nl> void FunctionListPanel : : searchFuncAndSwitchView ( ) <nl> } <nl> <nl> static WNDPROC oldFunclstToolbarProc = NULL ; <nl> - static BOOL CALLBACK funclstToolbarProc ( HWND hwnd , UINT message , WPARAM wParam , LPARAM lParam ) <nl> + static LRESULT CALLBACK funclstToolbarProc ( HWND hwnd , UINT message , WPARAM wParam , LPARAM lParam ) <nl> { <nl> switch ( message ) <nl> { <nl> void FunctionListPanel : : setSort ( bool isEnabled ) <nl> : : SendMessage ( _hToolbarMenu , TB_SETBUTTONINFO , IDC_SORTBUTTON_FUNCLIST , ( LPARAM ) & tbbuttonInfo ) ; <nl> } <nl> <nl> - BOOL CALLBACK FunctionListPanel : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) <nl> + INT_PTR CALLBACK FunctionListPanel : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) <nl> { <nl> switch ( message ) <nl> { <nl> mmm a / PowerEditor / src / WinControls / FunctionList / functionListPanel . h <nl> ppp b / PowerEditor / src / WinControls / FunctionList / functionListPanel . h <nl> class FunctionListPanel : public DockingDlgInterface { <nl> void searchFuncAndSwitchView ( ) ; <nl> <nl> protected : <nl> - virtual BOOL CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> + virtual INT_PTR CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> <nl> private : <nl> HWND _hToolbarMenu ; <nl> mmm a / PowerEditor / src / WinControls / Grid / ShortcutMapper . cpp <nl> ppp b / PowerEditor / src / WinControls / Grid / ShortcutMapper . cpp <nl> void ShortcutMapper : : fillOutBabyGrid ( ) <nl> } <nl> } <nl> <nl> - BOOL CALLBACK ShortcutMapper : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) <nl> + INT_PTR CALLBACK ShortcutMapper : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) <nl> { <nl> switch ( message ) <nl> { <nl> mmm a / PowerEditor / src / WinControls / Grid / ShortcutMapper . h <nl> ppp b / PowerEditor / src / WinControls / Grid / ShortcutMapper . h <nl> class ShortcutMapper : public StaticDialog { <nl> { <nl> DLGTEMPLATE * pMyDlgTemplate = NULL ; <nl> HGLOBAL hMyDlgTemplate = makeRTLResource ( IDD_SHORTCUTMAPPER_DLG , & pMyDlgTemplate ) ; <nl> - : : DialogBoxIndirectParam ( _hInst , pMyDlgTemplate , _hParent , ( DLGPROC ) dlgProc , ( LPARAM ) this ) ; <nl> + : : DialogBoxIndirectParam ( _hInst , pMyDlgTemplate , _hParent , dlgProc , ( LPARAM ) this ) ; <nl> : : GlobalFree ( hMyDlgTemplate ) ; <nl> } <nl> else <nl> - : : DialogBoxParam ( _hInst , MAKEINTRESOURCE ( IDD_SHORTCUTMAPPER_DLG ) , _hParent , ( DLGPROC ) dlgProc , ( LPARAM ) this ) ; <nl> + : : DialogBoxParam ( _hInst , MAKEINTRESOURCE ( IDD_SHORTCUTMAPPER_DLG ) , _hParent , dlgProc , ( LPARAM ) this ) ; <nl> } ; <nl> void getClientRect ( RECT & rc ) const ; <nl> void translateTab ( int index , const TCHAR * newname ) ; <nl> <nl> protected : <nl> - BOOL CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> + INT_PTR CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> <nl> private : <nl> static const int maxTabName = 64 ; <nl> mmm a / PowerEditor / src / WinControls / OpenSaveFileDialog / FileDialog . cpp <nl> ppp b / PowerEditor / src / WinControls / OpenSaveFileDialog / FileDialog . cpp <nl> static WNDPROC oldProc = NULL ; <nl> static generic_string currentExt = TEXT ( " " ) ; <nl> <nl> <nl> - static BOOL CALLBACK fileDlgProc ( HWND hwnd , UINT message , WPARAM wParam , LPARAM lParam ) <nl> + static LRESULT CALLBACK fileDlgProc ( HWND hwnd , UINT message , WPARAM wParam , LPARAM lParam ) <nl> { <nl> switch ( message ) <nl> { <nl> mmm a / PowerEditor / src / WinControls / Preference / preferenceDlg . cpp <nl> ppp b / PowerEditor / src / WinControls / Preference / preferenceDlg . cpp <nl> int encodings [ ] = { <nl> 20866 <nl> } ; <nl> <nl> - BOOL CALLBACK PreferenceDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) <nl> + INT_PTR CALLBACK PreferenceDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) <nl> { <nl> switch ( Message ) <nl> { <nl> void PreferenceDlg : : destroy ( ) <nl> _delimiterSettingsDlg . destroy ( ) ; <nl> } <nl> <nl> - BOOL CALLBACK BarsDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> + INT_PTR CALLBACK BarsDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> { <nl> NppParameters * pNppParam = NppParameters : : getInstance ( ) ; <nl> <nl> void MarginsDlg : : initScintParam ( ) <nl> } <nl> <nl> <nl> - BOOL CALLBACK MarginsDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) <nl> + INT_PTR CALLBACK MarginsDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) <nl> { <nl> NppParameters * pNppParam = NppParameters : : getInstance ( ) ; <nl> NppGUI & nppGUI = ( NppGUI & ) pNppParam - > getNppGUI ( ) ; <nl> BOOL CALLBACK MarginsDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam <nl> return FALSE ; <nl> } <nl> <nl> - BOOL CALLBACK SettingsDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> + INT_PTR CALLBACK SettingsDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> { <nl> NppParameters * pNppParam = NppParameters : : getInstance ( ) ; <nl> NppGUI & nppGUI = ( NppGUI & ) pNppParam - > getNppGUI ( ) ; <nl> void RecentFilesHistoryDlg : : setCustomLen ( int val ) <nl> : : ShowWindow ( : : GetDlgItem ( _hSelf , IDC_CUSTOMIZELENGTHVAL_STATIC ) , val > 0 ? SW_SHOW : SW_HIDE ) ; <nl> } <nl> <nl> - BOOL CALLBACK DefaultNewDocDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> + INT_PTR CALLBACK DefaultNewDocDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> { <nl> NppParameters * pNppParam = NppParameters : : getInstance ( ) ; <nl> NppGUI & nppGUI = ( NppGUI & ) pNppParam - > getNppGUI ( ) ; <nl> BOOL CALLBACK DefaultNewDocDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> return FALSE ; <nl> } <nl> <nl> - BOOL CALLBACK DefaultDirectoryDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> + INT_PTR CALLBACK DefaultDirectoryDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> { <nl> NppParameters * pNppParam = NppParameters : : getInstance ( ) ; <nl> NppGUI & nppGUI = ( NppGUI & ) pNppParam - > getNppGUI ( ) ; <nl> BOOL CALLBACK DefaultDirectoryDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPAR <nl> return FALSE ; <nl> } <nl> <nl> - BOOL CALLBACK RecentFilesHistoryDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> + INT_PTR CALLBACK RecentFilesHistoryDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> { <nl> NppParameters * pNppParam = NppParameters : : getInstance ( ) ; <nl> NppGUI & nppGUI = ( NppGUI & ) pNppParam - > getNppGUI ( ) ; <nl> BOOL CALLBACK RecentFilesHistoryDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LP <nl> return FALSE ; <nl> } <nl> <nl> - BOOL CALLBACK LangMenuDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) <nl> + INT_PTR CALLBACK LangMenuDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) <nl> { <nl> NppParameters * pNppParam = NppParameters : : getInstance ( ) ; <nl> NppGUI & nppGUI = ( NppGUI & ) pNppParam - > getNppGUI ( ) ; <nl> BOOL CALLBACK LangMenuDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lPara <nl> return FALSE ; <nl> } <nl> <nl> - BOOL CALLBACK TabSettings : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM / * lParam * / ) <nl> + INT_PTR CALLBACK TabSettings : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM / * lParam * / ) <nl> { <nl> NppParameters * pNppParam = NppParameters : : getInstance ( ) ; <nl> NppGUI & nppGUI = ( NppGUI & ) pNppParam - > getNppGUI ( ) ; <nl> void trim ( generic_string & str ) <nl> else str . erase ( str . begin ( ) , str . end ( ) ) ; <nl> } ; <nl> <nl> - BOOL CALLBACK PrintSettingsDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> + INT_PTR CALLBACK PrintSettingsDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> { <nl> NppParameters * pNppParam = NppParameters : : getInstance ( ) ; <nl> NppGUI & nppGUI = ( NppGUI & ) pNppParam - > getNppGUI ( ) ; <nl> BOOL CALLBACK PrintSettingsDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> } <nl> <nl> <nl> - BOOL CALLBACK BackupDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> + INT_PTR CALLBACK BackupDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> { <nl> NppParameters * pNppParam = NppParameters : : getInstance ( ) ; <nl> NppGUI & nppGUI = ( NppGUI & ) pNppParam - > getNppGUI ( ) ; <nl> void BackupDlg : : updateBackupGUI ( ) <nl> } <nl> <nl> <nl> - BOOL CALLBACK AutoCompletionDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> + INT_PTR CALLBACK AutoCompletionDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> { <nl> NppParameters * pNppParam = NppParameters : : getInstance ( ) ; <nl> NppGUI & nppGUI = ( NppGUI & ) pNppParam - > getNppGUI ( ) ; <nl> BOOL CALLBACK AutoCompletionDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM <nl> } <nl> <nl> <nl> - BOOL CALLBACK MultiInstDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> + INT_PTR CALLBACK MultiInstDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> { <nl> NppGUI & nppGUI = ( NppGUI & ) ( ( NppParameters : : getInstance ( ) ) - > getNppGUI ( ) ) ; <nl> switch ( Message ) <nl> BOOL CALLBACK MultiInstDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> return FALSE ; <nl> } <nl> <nl> - BOOL CALLBACK DelimiterSettingsDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) <nl> + INT_PTR CALLBACK DelimiterSettingsDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) <nl> { <nl> NppGUI & nppGUI = ( NppGUI & ) ( ( NppParameters : : getInstance ( ) ) - > getNppGUI ( ) ) ; <nl> switch ( Message ) <nl> BOOL CALLBACK DelimiterSettingsDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPA <nl> return FALSE ; <nl> } <nl> <nl> - BOOL CALLBACK SettingsOnCloudDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> + INT_PTR CALLBACK SettingsOnCloudDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> { <nl> NppGUI & nppGUI = ( NppGUI & ) ( ( NppParameters : : getInstance ( ) ) - > getNppGUI ( ) ) ; <nl> switch ( Message ) <nl> mmm a / PowerEditor / src / WinControls / Preference / preferenceDlg . h <nl> ppp b / PowerEditor / src / WinControls / Preference / preferenceDlg . h <nl> public : <nl> SettingsDlg ( ) { } ; <nl> <nl> private : <nl> - BOOL CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> + INT_PTR CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> } ; <nl> <nl> class BarsDlg : public StaticDialog <nl> class BarsDlg : public StaticDialog <nl> public : <nl> BarsDlg ( ) { } ; <nl> private : <nl> - BOOL CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> + INT_PTR CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> } ; <nl> <nl> class MarginsDlg : public StaticDialog <nl> public : <nl> <nl> private : <nl> URLCtrl _verticalEdgeLineNbColVal ; <nl> - BOOL CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> + INT_PTR CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> void initScintParam ( ) ; <nl> } ; <nl> <nl> private : <nl> : : SendDlgItemMessage ( _hSelf , IDC_CHECK_OPENANSIASUTF8 , BM_SETCHECK , BST_UNCHECKED , 0 ) ; <nl> : : EnableWindow ( : : GetDlgItem ( _hSelf , IDC_CHECK_OPENANSIASUTF8 ) , doIt ) ; <nl> } ; <nl> - BOOL CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> + INT_PTR CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> } ; <nl> <nl> class DefaultDirectoryDlg : public StaticDialog <nl> public : <nl> DefaultDirectoryDlg ( ) { } ; <nl> <nl> private : <nl> - BOOL CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> + INT_PTR CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> } ; <nl> <nl> class RecentFilesHistoryDlg : public StaticDialog <nl> private : <nl> URLCtrl _customLenVal ; <nl> std : : vector < LangID_Name > _langList ; <nl> void setCustomLen ( int val ) ; <nl> - BOOL CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> + INT_PTR CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> } ; <nl> <nl> class LangMenuDlg : public StaticDialog <nl> public : <nl> <nl> private : <nl> LexerStylerArray _lsArray ; <nl> - BOOL CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> + INT_PTR CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> std : : vector < LangMenuItem > _langList ; <nl> } ; <nl> <nl> public : <nl> <nl> private : <nl> URLCtrl _tabSizeVal ; <nl> - BOOL CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> + INT_PTR CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> } ; <nl> <nl> <nl> class PrintSettingsDlg : public StaticDialog <nl> public : <nl> PrintSettingsDlg ( ) : _focusedEditCtrl ( 0 ) , _selStart ( 0 ) , _selEnd ( 0 ) { } ; <nl> private : <nl> - BOOL CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> + INT_PTR CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> std : : vector < strCouple > varList ; <nl> int _focusedEditCtrl ; <nl> DWORD _selStart ; <nl> public : <nl> BackupDlg ( ) { } ; <nl> private : <nl> void updateBackupGUI ( ) ; <nl> - BOOL CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> + INT_PTR CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> } ; <nl> <nl> <nl> public : <nl> AutoCompletionDlg ( ) { } ; <nl> private : <nl> URLCtrl _nbCharVal ; <nl> - BOOL CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> + INT_PTR CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> } ; <nl> <nl> class MultiInstDlg : public StaticDialog <nl> public : <nl> MultiInstDlg ( ) { } ; <nl> <nl> private : <nl> - BOOL CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> + INT_PTR CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> } ; <nl> <nl> class DelimiterSettingsDlg : public StaticDialog <nl> public : <nl> DelimiterSettingsDlg ( ) { } ; <nl> <nl> private : <nl> - BOOL CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> + INT_PTR CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> POINT _singleLineModePoint , _multiLineModePoint ; <nl> RECT _closerRect , _closerLabelRect ; <nl> } ; <nl> public : <nl> private : <nl> CloudChoice _initialCloudChoice ; <nl> <nl> - BOOL CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> + INT_PTR CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> void setCloudChoice ( const char * choice ) ; <nl> void removeCloudChoice ( ) ; <nl> } ; <nl> public : <nl> virtual void destroy ( ) ; <nl> <nl> private : <nl> - BOOL CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> + INT_PTR CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> void makeCategoryList ( ) ; <nl> void showDialogByIndex ( int index ) ; <nl> / / ControlsTab _ctrlTab ; <nl> mmm a / PowerEditor / src / WinControls / ProjectPanel / ProjectPanel . cpp <nl> ppp b / PowerEditor / src / WinControls / ProjectPanel / ProjectPanel . cpp <nl> <nl> # define GET_X_LPARAM ( lp ) ( ( int ) ( short ) LOWORD ( lp ) ) <nl> # define GET_Y_LPARAM ( lp ) ( ( int ) ( short ) HIWORD ( lp ) ) <nl> <nl> - BOOL CALLBACK ProjectPanel : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) <nl> + INT_PTR CALLBACK ProjectPanel : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) <nl> { <nl> switch ( message ) <nl> { <nl> void ProjectPanel : : addFilesFromDirectory ( HTREEITEM hTreeItem ) <nl> } <nl> } <nl> <nl> - BOOL CALLBACK FileRelocalizerDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> + INT_PTR CALLBACK FileRelocalizerDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> { <nl> switch ( Message ) <nl> { <nl> int FileRelocalizerDlg : : doDialog ( const TCHAR * fn , bool isRTL ) <nl> { <nl> DLGTEMPLATE * pMyDlgTemplate = NULL ; <nl> HGLOBAL hMyDlgTemplate = makeRTLResource ( IDD_FILERELOCALIZER_DIALOG , & pMyDlgTemplate ) ; <nl> - int result = : : DialogBoxIndirectParam ( _hInst , pMyDlgTemplate , _hParent , ( DLGPROC ) dlgProc , ( LPARAM ) this ) ; <nl> + int result = : : DialogBoxIndirectParam ( _hInst , pMyDlgTemplate , _hParent , dlgProc , ( LPARAM ) this ) ; <nl> : : GlobalFree ( hMyDlgTemplate ) ; <nl> return result ; <nl> } <nl> - return : : DialogBoxParam ( _hInst , MAKEINTRESOURCE ( IDD_FILERELOCALIZER_DIALOG ) , _hParent , ( DLGPROC ) dlgProc , ( LPARAM ) this ) ; <nl> + return : : DialogBoxParam ( _hInst , MAKEINTRESOURCE ( IDD_FILERELOCALIZER_DIALOG ) , _hParent , dlgProc , ( LPARAM ) this ) ; <nl> } <nl> <nl> mmm a / PowerEditor / src / WinControls / ProjectPanel / ProjectPanel . h <nl> ppp b / PowerEditor / src / WinControls / ProjectPanel / ProjectPanel . h <nl> class ProjectPanel : public DockingDlgInterface { <nl> void setWorkSpaceDirty ( bool isDirty ) ; <nl> void popupMenuCmd ( int cmdID ) ; <nl> POINT getMenuDisplyPoint ( int iButton ) ; <nl> - virtual BOOL CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> + virtual INT_PTR CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> bool buildTreeFrom ( TiXmlNode * projectRoot , HTREEITEM hParentItem ) ; <nl> void notified ( LPNMHDR notification ) ; <nl> void showContextMenu ( int x , int y ) ; <nl> public : <nl> } ; <nl> <nl> protected : <nl> - virtual BOOL CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> + virtual INT_PTR CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> <nl> private : <nl> generic_string _fullFilePath ; <nl> mmm a / PowerEditor / src / WinControls / StaticDialog / RunDlg / RunDlg . cpp <nl> ppp b / PowerEditor / src / WinControls / StaticDialog / RunDlg / RunDlg . cpp <nl> HINSTANCE Command : : run ( HWND hWnd ) <nl> return res ; <nl> } <nl> <nl> - BOOL CALLBACK RunDlg : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM ) <nl> + INT_PTR CALLBACK RunDlg : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM ) <nl> { <nl> switch ( message ) <nl> { <nl> mmm a / PowerEditor / src / WinControls / StaticDialog / RunDlg / RunDlg . h <nl> ppp b / PowerEditor / src / WinControls / StaticDialog / RunDlg / RunDlg . h <nl> public : <nl> } ; <nl> <nl> protected : <nl> - virtual BOOL CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> + virtual INT_PTR CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> <nl> private : <nl> void addTextToCombo ( const TCHAR * txt2Add ) const ; <nl> mmm a / PowerEditor / src / WinControls / StaticDialog / StaticDialog . cpp <nl> ppp b / PowerEditor / src / WinControls / StaticDialog / StaticDialog . cpp <nl> void StaticDialog : : create ( int dialogID , bool isRTL , bool msgDestParent ) <nl> { <nl> DLGTEMPLATE * pMyDlgTemplate = NULL ; <nl> HGLOBAL hMyDlgTemplate = makeRTLResource ( dialogID , & pMyDlgTemplate ) ; <nl> - _hSelf = : : CreateDialogIndirectParam ( _hInst , pMyDlgTemplate , _hParent , ( DLGPROC ) dlgProc , ( LPARAM ) this ) ; <nl> + _hSelf = : : CreateDialogIndirectParam ( _hInst , pMyDlgTemplate , _hParent , dlgProc , ( LPARAM ) this ) ; <nl> : : GlobalFree ( hMyDlgTemplate ) ; <nl> } <nl> else <nl> - _hSelf = : : CreateDialogParam ( _hInst , MAKEINTRESOURCE ( dialogID ) , _hParent , ( DLGPROC ) dlgProc , ( LPARAM ) this ) ; <nl> + _hSelf = : : CreateDialogParam ( _hInst , MAKEINTRESOURCE ( dialogID ) , _hParent , dlgProc , ( LPARAM ) this ) ; <nl> <nl> if ( ! _hSelf ) <nl> { <nl> void StaticDialog : : create ( int dialogID , bool isRTL , bool msgDestParent ) <nl> : : SendMessage ( msgDestParent ? _hParent : ( : : GetParent ( _hParent ) ) , NPPM_MODELESSDIALOG , MODELESSDIALOGADD , ( WPARAM ) _hSelf ) ; <nl> } <nl> <nl> - BOOL CALLBACK StaticDialog : : dlgProc ( HWND hwnd , UINT message , WPARAM wParam , LPARAM lParam ) <nl> + INT_PTR CALLBACK StaticDialog : : dlgProc ( HWND hwnd , UINT message , WPARAM wParam , LPARAM lParam ) <nl> { <nl> switch ( message ) <nl> { <nl> mmm a / PowerEditor / src / WinControls / StaticDialog / StaticDialog . h <nl> ppp b / PowerEditor / src / WinControls / StaticDialog / StaticDialog . h <nl> public : <nl> <nl> protected : <nl> RECT _rc ; <nl> - static BOOL CALLBACK dlgProc ( HWND hwnd , UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> - virtual BOOL CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) = 0 ; <nl> + static INT_PTR CALLBACK dlgProc ( HWND hwnd , UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> + virtual INT_PTR CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) = 0 ; <nl> <nl> void alignWith ( HWND handle , HWND handle2Align , PosAlign pos , POINT & point ) ; <nl> HGLOBAL makeRTLResource ( int dialogID , DLGTEMPLATE * * ppMyDlgTemplate ) ; <nl> mmm a / PowerEditor / src / WinControls / TaskList / TaskListDlg . cpp <nl> ppp b / PowerEditor / src / WinControls / TaskList / TaskListDlg . cpp <nl> LRESULT CALLBACK hookProc ( UINT nCode , WPARAM wParam , LPARAM lParam ) <nl> { <nl> DLGTEMPLATE * pMyDlgTemplate = NULL ; <nl> HGLOBAL hMyDlgTemplate = makeRTLResource ( IDD_VALUE_DLG , & pMyDlgTemplate ) ; <nl> - int result = : : DialogBoxIndirectParam ( _hInst , pMyDlgTemplate , _hParent , ( DLGPROC ) dlgProc , ( LPARAM ) this ) ; <nl> + int result = : : DialogBoxIndirectParam ( _hInst , pMyDlgTemplate , _hParent , dlgProc , ( LPARAM ) this ) ; <nl> : : GlobalFree ( hMyDlgTemplate ) ; <nl> return result ; <nl> } <nl> - return : : DialogBoxParam ( _hInst , MAKEINTRESOURCE ( IDD_TASKLIST_DLG ) , _hParent , ( DLGPROC ) dlgProc , ( LPARAM ) this ) ; <nl> + return : : DialogBoxParam ( _hInst , MAKEINTRESOURCE ( IDD_TASKLIST_DLG ) , _hParent , dlgProc , ( LPARAM ) this ) ; <nl> } <nl> <nl> - BOOL CALLBACK TaskListDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) <nl> + INT_PTR CALLBACK TaskListDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) <nl> { <nl> switch ( Message ) <nl> { <nl> mmm a / PowerEditor / src / WinControls / TaskList / TaskListDlg . h <nl> ppp b / PowerEditor / src / WinControls / TaskList / TaskListDlg . h <nl> public : <nl> virtual void destroy ( ) { } ; <nl> <nl> protected : <nl> - BOOL CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> + INT_PTR CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> <nl> private : <nl> TaskList _taskList ; <nl> mmm a / PowerEditor / src / WinControls / ToolTip / ToolTip . cpp <nl> ppp b / PowerEditor / src / WinControls / ToolTip / ToolTip . cpp <nl> <nl> <nl> <nl> <nl> - LRESULT CALLBACK dlgProc ( HWND hWnd , UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> + INT_PTR CALLBACK dlgProc ( HWND hWnd , UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> <nl> <nl> void ToolTip : : init ( HINSTANCE hInst , HWND hParent ) <nl> mmm a / PowerEditor / src / WinControls / VerticalFileSwitcher / VerticalFileSwitcher . cpp <nl> ppp b / PowerEditor / src / WinControls / VerticalFileSwitcher / VerticalFileSwitcher . cpp <nl> int CALLBACK ListViewCompareProc ( LPARAM lParam1 , LPARAM lParam2 , LPARAM lParamSo <nl> return ( 0 - result ) ; <nl> } ; <nl> <nl> - BOOL CALLBACK VerticalFileSwitcher : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) <nl> + INT_PTR CALLBACK VerticalFileSwitcher : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) <nl> { <nl> switch ( message ) <nl> { <nl> mmm a / PowerEditor / src / WinControls / VerticalFileSwitcher / VerticalFileSwitcher . h <nl> ppp b / PowerEditor / src / WinControls / VerticalFileSwitcher / VerticalFileSwitcher . h <nl> class VerticalFileSwitcher : public DockingDlgInterface { <nl> } ; <nl> <nl> protected : <nl> - virtual BOOL CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> + virtual INT_PTR CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> <nl> private : <nl> VerticalFileSwitcherListView _fileListView ; <nl> mmm a / PowerEditor / src / WinControls / WindowsDlg / SizeableDlg . cpp <nl> ppp b / PowerEditor / src / WinControls / WindowsDlg / SizeableDlg . cpp <nl> LRESULT SizeableDlg : : onWinMgr ( WPARAM , LPARAM ) <nl> return 0 ; <nl> } <nl> <nl> - BOOL CALLBACK SizeableDlg : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) <nl> + INT_PTR CALLBACK SizeableDlg : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) <nl> { <nl> switch ( message ) <nl> { <nl> mmm a / PowerEditor / src / WinControls / WindowsDlg / SizeableDlg . h <nl> ppp b / PowerEditor / src / WinControls / WindowsDlg / SizeableDlg . h <nl> class SizeableDlg : public StaticDialog { <nl> protected : <nl> CWinMgr _winMgr ; / / window manager <nl> <nl> - virtual BOOL CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> + virtual INT_PTR CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> virtual BOOL onInitDialog ( ) ; <nl> virtual void onSize ( UINT nType , int cx , int cy ) ; <nl> virtual void onGetMinMaxInfo ( MINMAXINFO * lpMMI ) ; <nl> mmm a / PowerEditor / src / WinControls / WindowsDlg / WindowsDlg . cpp <nl> ppp b / PowerEditor / src / WinControls / WindowsDlg / WindowsDlg . cpp <nl> void WindowsDlg : : init ( HINSTANCE hInst , HWND parent ) <nl> _pTab = NULL ; <nl> } <nl> <nl> - BOOL CALLBACK WindowsDlg : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) <nl> + INT_PTR CALLBACK WindowsDlg : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) <nl> { <nl> switch ( message ) <nl> { <nl> void WindowsDlg : : updateButtonState ( ) <nl> int WindowsDlg : : doDialog ( TiXmlNodeA * dlgNode ) <nl> { <nl> _dlgNode = dlgNode ; <nl> - return : : DialogBoxParam ( _hInst , MAKEINTRESOURCE ( IDD_WINDOWS ) , _hParent , ( DLGPROC ) dlgProc , ( LPARAM ) this ) ; <nl> + return : : DialogBoxParam ( _hInst , MAKEINTRESOURCE ( IDD_WINDOWS ) , _hParent , dlgProc , ( LPARAM ) this ) ; <nl> } ; <nl> <nl> bool WindowsDlg : : changeDlgLang ( ) <nl> mmm a / PowerEditor / src / WinControls / WindowsDlg / WindowsDlg . h <nl> ppp b / PowerEditor / src / WinControls / WindowsDlg / WindowsDlg . h <nl> public : <nl> bool changeDlgLang ( ) ; <nl> <nl> protected : <nl> - virtual BOOL CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> + virtual INT_PTR CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> virtual BOOL onInitDialog ( ) ; <nl> virtual void onSize ( UINT nType , int cx , int cy ) ; <nl> virtual void onGetMinMaxInfo ( MINMAXINFO * lpMMI ) ; <nl> mmm a / PowerEditor / src / WinControls / shortcut / RunMacroDlg . cpp <nl> ppp b / PowerEditor / src / WinControls / shortcut / RunMacroDlg . cpp <nl> void RunMacroDlg : : initMacroList ( ) <nl> m_macroIndex = 0 ; <nl> } <nl> <nl> - BOOL CALLBACK RunMacroDlg : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM ) <nl> + INT_PTR CALLBACK RunMacroDlg : : run_dlgProc ( UINT message , WPARAM wParam , LPARAM ) <nl> { <nl> switch ( message ) <nl> { <nl> mmm a / PowerEditor / src / WinControls / shortcut / RunMacroDlg . h <nl> ppp b / PowerEditor / src / WinControls / shortcut / RunMacroDlg . h <nl> public : <nl> int getMacro2Exec ( ) const ; <nl> <nl> private : <nl> - virtual BOOL CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> + virtual INT_PTR CALLBACK run_dlgProc ( UINT message , WPARAM wParam , LPARAM lParam ) ; <nl> void check ( int ) ; <nl> <nl> int m_Mode ; <nl> mmm a / PowerEditor / src / WinControls / shortcut / shortcut . cpp <nl> ppp b / PowerEditor / src / WinControls / shortcut / shortcut . cpp <nl> void getNameStrFromCmd ( DWORD cmd , generic_string & str ) <nl> return ; <nl> } <nl> <nl> - BOOL CALLBACK Shortcut : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> + INT_PTR CALLBACK Shortcut : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> { <nl> switch ( Message ) <nl> { <nl> void ScintillaKeyMap : : updateListItem ( int index ) { <nl> : : SendDlgItemMessage ( _hSelf , IDC_LIST_KEYS , LB_DELETESTRING , index + 1 , 0 ) ; <nl> } <nl> <nl> - BOOL CALLBACK ScintillaKeyMap : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> + INT_PTR CALLBACK ScintillaKeyMap : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> { <nl> <nl> switch ( Message ) <nl> mmm a / PowerEditor / src / WinControls / shortcut / shortcut . h <nl> ppp b / PowerEditor / src / WinControls / shortcut / shortcut . h <nl> class Shortcut : public StaticDialog { <nl> } ; <nl> <nl> virtual int doDialog ( ) { <nl> - return : : DialogBoxParam ( _hInst , MAKEINTRESOURCE ( IDD_SHORTCUT_DLG ) , _hParent , ( DLGPROC ) dlgProc , ( LPARAM ) this ) ; <nl> + return : : DialogBoxParam ( _hInst , MAKEINTRESOURCE ( IDD_SHORTCUT_DLG ) , _hParent , dlgProc , ( LPARAM ) this ) ; <nl> } ; <nl> <nl> virtual bool isValid ( ) const { / / valid should only be used in cases where the shortcut isEnabled ( ) . <nl> class Shortcut : public StaticDialog { <nl> <nl> protected : <nl> KeyCombo _keyCombo ; <nl> - virtual BOOL CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> + virtual INT_PTR CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> bool _canModifyName ; <nl> TCHAR _name [ nameLenMax ] ; / / normal name is plain text ( for display purposes ) <nl> TCHAR _menuName [ nameLenMax ] ; / / menu name has ampersands for quick keys <nl> class ScintillaKeyMap : public Shortcut { <nl> generic_string toString ( int index ) const ; <nl> <nl> int doDialog ( ) { <nl> - return : : DialogBoxParam ( _hInst , MAKEINTRESOURCE ( IDD_SHORTCUTSCINT_DLG ) , _hParent , ( DLGPROC ) dlgProc , ( LPARAM ) this ) ; <nl> + return : : DialogBoxParam ( _hInst , MAKEINTRESOURCE ( IDD_SHORTCUTSCINT_DLG ) , _hParent , dlgProc , ( LPARAM ) this ) ; <nl> } ; <nl> <nl> / / only compares the internal KeyCombos , nothing else <nl> class ScintillaKeyMap : public Shortcut { <nl> void showCurrentSettings ( ) ; <nl> void updateListItem ( int index ) ; <nl> protected : <nl> - BOOL CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> + INT_PTR CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM lParam ) ; <nl> } ; <nl> <nl> <nl> mmm a / PowerEditor / src / lesDlgs . cpp <nl> ppp b / PowerEditor / src / lesDlgs . cpp <nl> int ValueDlg : : doDialog ( POINT p , bool isRTL ) <nl> { <nl> DLGTEMPLATE * pMyDlgTemplate = NULL ; <nl> HGLOBAL hMyDlgTemplate = makeRTLResource ( IDD_VALUE_DLG , & pMyDlgTemplate ) ; <nl> - int result = : : DialogBoxIndirectParam ( _hInst , pMyDlgTemplate , _hParent , ( DLGPROC ) dlgProc , ( LPARAM ) this ) ; <nl> + int result = : : DialogBoxIndirectParam ( _hInst , pMyDlgTemplate , _hParent , dlgProc , ( LPARAM ) this ) ; <nl> : : GlobalFree ( hMyDlgTemplate ) ; <nl> return result ; <nl> } <nl> - return : : DialogBoxParam ( _hInst , MAKEINTRESOURCE ( IDD_VALUE_DLG ) , _hParent , ( DLGPROC ) dlgProc , ( LPARAM ) this ) ; <nl> + return : : DialogBoxParam ( _hInst , MAKEINTRESOURCE ( IDD_VALUE_DLG ) , _hParent , dlgProc , ( LPARAM ) this ) ; <nl> } <nl> <nl> <nl> int ValueDlg : : reSizeValueBox ( ) <nl> return extraSize ; <nl> } <nl> <nl> - BOOL CALLBACK ValueDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> + INT_PTR CALLBACK ValueDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> { <nl> switch ( Message ) <nl> { <nl> BOOL CALLBACK ValueDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> <nl> <nl> <nl> - BOOL CALLBACK ButtonDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> + INT_PTR CALLBACK ButtonDlg : : run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) <nl> { <nl> switch ( Message ) <nl> { <nl> mmm a / PowerEditor / src / lesDlgs . h <nl> ppp b / PowerEditor / src / lesDlgs . h <nl> public : <nl> void destroy ( ) { } ; <nl> <nl> protected : <nl> - BOOL CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) ; <nl> + INT_PTR CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) ; <nl> <nl> private : <nl> int _nbNumber ; <nl> public : <nl> } ; <nl> <nl> protected : <nl> - BOOL CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) ; <nl> + INT_PTR CALLBACK run_dlgProc ( UINT Message , WPARAM wParam , LPARAM ) ; <nl> int _buttonStatus ; <nl> <nl> } ; <nl>
DlgProc returns INT_PTR and not BOOL . Use correct prototype and remove casts .
notepad-plus-plus/notepad-plus-plus
dbb43a729f2577426b1ef6004aed219b864fd93f
2015-06-01T18:30:41Z
mmm a / imgui . cpp <nl> ppp b / imgui . cpp <nl> <nl> - columns : columns header to act as button ( ~ sort op ) and allow resize / reorder <nl> - columns : user specify columns size <nl> - combo : turn child handling code into pop up helper <nl> - - combo : layer conflict with other child windows <nl> - combo : contents should extends to fit label if combo widget is small <nl> - list selection , concept of a selectable " block " ( that can be multiple widgets ) <nl> ! menubar , menus <nl> void ImGuiWindow : : AddToRenderList ( ) <nl> for ( size_t i = 0 ; i < DC . ChildWindows . size ( ) ; i + + ) <nl> { <nl> ImGuiWindow * child = DC . ChildWindows [ i ] ; <nl> - if ( child - > Visible ) / / clipped childs may have been marked not Visible <nl> + if ( child - > Visible ) / / clipped children may have been marked not Visible <nl> child - > AddToRenderList ( ) ; <nl> } <nl> } <nl> void ImGui : : Shutdown ( ) <nl> g . Initialized = false ; <nl> } <nl> <nl> + / / FIXME : Add a more explicit sort order in the window structure . <nl> + static int ChildWindowComparer ( const void * lhs , const void * rhs ) <nl> + { <nl> + const ImGuiWindow * a = * ( const ImGuiWindow * * ) lhs ; <nl> + const ImGuiWindow * b = * ( const ImGuiWindow * * ) rhs ; <nl> + if ( int d = ( a - > Flags & ImGuiWindowFlags_Tooltip ) - ( b - > Flags & ImGuiWindowFlags_Tooltip ) ) <nl> + return d ; <nl> + if ( int d = ( a - > Flags & ImGuiWindowFlags_ComboBox ) - ( b - > Flags & ImGuiWindowFlags_ComboBox ) ) <nl> + return d ; <nl> + return 0 ; <nl> + } <nl> + <nl> static void AddWindowToSortedBuffer ( ImGuiWindow * window , ImVector < ImGuiWindow * > & sorted_windows ) <nl> { <nl> sorted_windows . push_back ( window ) ; <nl> if ( window - > Visible ) <nl> { <nl> - for ( size_t i = 0 ; i < window - > DC . ChildWindows . size ( ) ; i + + ) <nl> + const size_t count = window - > DC . ChildWindows . size ( ) ; <nl> + if ( count > 1 ) <nl> + qsort ( window - > DC . ChildWindows . begin ( ) , count , sizeof ( ImGuiWindow * ) , ChildWindowComparer ) ; <nl> + for ( size_t i = 0 ; i < count ; i + + ) <nl> { <nl> ImGuiWindow * child = window - > DC . ChildWindows [ i ] ; <nl> if ( child - > Visible ) <nl> void ImGui : : Render ( ) <nl> g . CurrentWindow - > Visible = false ; <nl> ImGui : : End ( ) ; <nl> <nl> - / / Select window for move / focus when we ' re done with all our widgets ( we only consider non - childs windows here ) <nl> + / / Select window for move / focus when we ' re done with all our widgets ( we only consider non - child windows here ) <nl> if ( g . ActiveId = = 0 & & g . HoveredId = = 0 & & g . HoveredRootWindow ! = NULL & & g . IO . MouseClicked [ 0 ] ) <nl> SetActiveId ( g . HoveredRootWindow - > GetID ( " # MOVE " ) ) ; <nl> <nl> void ImGui : : Render ( ) <nl> for ( size_t i = 0 ; i ! = g . Windows . size ( ) ; i + + ) <nl> { <nl> ImGuiWindow * window = g . Windows [ i ] ; <nl> - if ( window - > Flags & ImGuiWindowFlags_ChildWindow ) / / if a child is visible its parent will add it <nl> + if ( window - > Flags & ImGuiWindowFlags_ChildWindow ) / / if a child is visible its parent will add it <nl> if ( window - > Visible ) <nl> continue ; <nl> AddWindowToSortedBuffer ( window , g . RenderSortedWindows ) ; <nl> } <nl> - IM_ASSERT ( g . Windows . size ( ) = = g . RenderSortedWindows . size ( ) ) ; / / We done something wrong <nl> + IM_ASSERT ( g . Windows . size ( ) = = g . RenderSortedWindows . size ( ) ) ; / / we done something wrong <nl> g . Windows . swap ( g . RenderSortedWindows ) ; <nl> <nl> / / Clear data for next frame <nl>
Combo box always appear above other child windows of a same parent
ocornut/imgui
f387c3f22fd48e3f86fd1d8f56ab21f88e423f94
2015-02-08T17:21:51Z
mmm a / python / mxnet / metric . py <nl> ppp b / python / mxnet / metric . py <nl> def update ( self , labels , preds ) : <nl> assert len ( labels ) = = len ( preds ) <nl> loss = 0 . <nl> num = 0 <nl> - probs = [ ] <nl> - <nl> for label , pred in zip ( labels , preds ) : <nl> assert label . size = = pred . size / pred . shape [ - 1 ] , \ <nl> " shape mismatch : % s vs . % s " % ( label . shape , pred . shape ) <nl> - label = label . as_in_context ( pred . context ) . astype ( dtype = ' int32 ' ) . reshape ( ( label . size , ) ) <nl> - pred = ndarray . pick ( pred , label , axis = self . axis ) <nl> - probs . append ( pred ) <nl> - <nl> - for label , prob in zip ( labels , probs ) : <nl> - prob = prob . asnumpy ( ) <nl> + label = label . as_in_context ( pred . context ) . reshape ( ( label . size , ) ) <nl> + pred = ndarray . pick ( pred , label . astype ( dtype = ' int32 ' ) , axis = self . axis ) <nl> if self . ignore_label is not None : <nl> - ignore = label . asnumpy ( ) . flatten ( ) = = self . ignore_label <nl> - prob = prob * ( 1 - ignore ) + ignore <nl> - num + = prob . size - ignore . sum ( ) <nl> - else : <nl> - num + = prob . size <nl> - loss + = - numpy . log ( numpy . maximum ( 1e - 10 , prob ) ) . sum ( ) <nl> - <nl> - self . sum_metric + = numpy . exp ( loss / num ) <nl> + ignore = label = = self . ignore_label <nl> + num - = ndarray . sum ( ignore ) . asscalar ( ) <nl> + pred = pred * ( 1 - ignore ) + ignore <nl> + loss - = ndarray . sum ( ndarray . log ( ndarray . maximum ( 1e - 10 , pred ) ) ) . asscalar ( ) <nl> + num + = pred . size <nl> + self . sum_metric + = math . exp ( loss / num ) <nl> self . num_inst + = 1 <nl> <nl> <nl>
Changed from numpy to ndarray for Perplexity ( )
apache/incubator-mxnet
6c059436953233397ca284611817351c9e7f81d4
2017-04-12T03:37:25Z
mmm a / build / fbcode_builder / getdeps . py <nl> ppp b / build / fbcode_builder / getdeps . py <nl> def add_common_arg ( * args , * * kwargs ) : <nl> " - - facebook - internal " , <nl> help = " Setup the build context as an FB internal build " , <nl> action = " store_true " , <nl> - default = False , <nl> + default = None , <nl> + ) <nl> + add_common_arg ( <nl> + " - - no - facebook - internal " , <nl> + help = " Perform a non - FB internal build , even when in an fbsource repository " , <nl> + action = " store_false " , <nl> + dest = " facebook_internal " , <nl> ) <nl> <nl> ap = argparse . ArgumentParser ( <nl> mmm a / build / fbcode_builder / getdeps / buildopts . py <nl> ppp b / build / fbcode_builder / getdeps / buildopts . py <nl> def get_vcvars_path ( self ) : <nl> def is_linux ( self ) : <nl> return self . host_type . is_linux ( ) <nl> <nl> - def get_context_generator ( self , host_tuple = None , facebook_internal = False ) : <nl> + def get_context_generator ( self , host_tuple = None , facebook_internal = None ) : <nl> " " " Create a manifest ContextGenerator for the specified target platform . " " " <nl> if host_tuple is None : <nl> host_type = self . host_type <nl> def get_context_generator ( self , host_tuple = None , facebook_internal = False ) : <nl> else : <nl> host_type = HostType . from_tuple_string ( host_tuple ) <nl> <nl> + # facebook_internal is an Optional [ bool ] <nl> + # If it is None , default to assuming this is a Facebook - internal build if <nl> + # we are running in an fbsource repository . <nl> + if facebook_internal is None : <nl> + facebook_internal = self . fbsource_dir is not None <nl> + <nl> return ContextGenerator ( <nl> { <nl> " os " : host_type . ostype , <nl>
getdeps : automatically detect if a build appears to be Facebook - internal
facebook/folly
c951878fc44b4c61ebd128e4337298d254d2a20d
2019-11-21T00:03:14Z
mmm a / stdlib / public / stubs / CMakeLists . txt <nl> ppp b / stdlib / public / stubs / CMakeLists . txt <nl> set ( LLVM_OPTIONAL_SOURCES <nl> $ { swift_stubs_objc_sources } <nl> $ { swift_stubs_unicode_normalization_sources } ) <nl> <nl> - find_package ( ICU REQUIRED COMPONENTS uc ) <nl> - set ( ICU_UC_LIBRARY " " ) <nl> + if ( NOT CMAKE_SYSTEM_NAME STREQUAL " Darwin " ) <nl> + find_package ( ICU REQUIRED COMPONENTS uc ) <nl> + set ( ICU_UC_LIBRARY " " ) <nl> + endif ( ) <nl> <nl> set ( swift_stubs_c_compile_flags $ { SWIFT_RUNTIME_CORE_CXX_FLAGS } ) <nl> list ( APPEND swift_stubs_c_compile_flags - DswiftCore_EXPORTS ) <nl>
don ' t require ICU on Darwin as per jrose - apple ' s comment
apple/swift
5384630a188e67a9e980b074c0391b87f1787c9a
2016-10-25T18:42:17Z
mmm a / emscripten . py <nl> ppp b / emscripten . py <nl> def make_table ( sig , raw ) : <nl> Counter . j = 0 <nl> def fix_item ( item ) : <nl> Counter . j + = 1 <nl> - newline = Counter . j % 30 = = 1 <nl> + newline = Counter . j % 30 = = 29 <nl> if item = = ' 0 ' : return bad if not newline else ( bad + ' \ n ' ) <nl> return item if not newline else ( item + ' \ n ' ) <nl> body = ' , ' . join ( map ( fix_item , body ) ) <nl>
make function table emitting nicer
emscripten-core/emscripten
352f3f4f10f11ed00b8b0df714ef93b92a271758
2013-10-02T04:24:11Z
mmm a / Marlin / pins . h <nl> ppp b / Marlin / pins . h <nl> <nl> <nl> # endif <nl> <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * * * * * * * * * <nl> + * Gen7 Alfons3 pin assignment <nl> + * <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * * * * * * * * / <nl> + / * These Pins are assigned for the modified GEN7 Board from Alfons3 Please review the pins and adjust it for your needs * / <nl> + <nl> + # if MOTHERBOARD = = 77 <nl> + # define KNOWN_BOARD <nl> + <nl> + # if ! defined ( __AVR_ATmega644P__ ) & & ! defined ( __AVR_ATmega644__ ) & & ! defined ( __AVR_ATmega1284P__ ) <nl> + # error Oops ! Make sure you have ' Gen7 ' selected from the ' Tools - > Boards ' menu . <nl> + <nl> + # endif <nl> + <nl> + / / x axis pins <nl> + # define X_STEP_PIN 21 / / different from stanard GEN7 <nl> + # define X_DIR_PIN 20 / / different from stanard GEN7 <nl> + # define X_ENABLE_PIN 24 <nl> + # define X_MIN_PIN 0 <nl> + # define X_MAX_PIN - 1 <nl> + <nl> + / / y axis pins <nl> + # define Y_STEP_PIN 23 <nl> + # define Y_DIR_PIN 22 <nl> + # define Y_ENABLE_PIN 24 <nl> + # define Y_MIN_PIN 1 <nl> + # define Y_MAX_PIN - 1 <nl> + <nl> + / / z axis pins <nl> + # define Z_STEP_PIN 26 <nl> + # define Z_DIR_PIN 25 <nl> + # define Z_ENABLE_PIN 24 <nl> + # define Z_MIN_PIN 2 <nl> + # define Z_MAX_PIN - 1 <nl> + <nl> + / / extruder pins <nl> + # define E0_STEP_PIN 28 <nl> + # define E0_DIR_PIN 27 <nl> + # define E0_ENABLE_PIN 24 <nl> + <nl> + # define TEMP_0_PIN 2 <nl> + # define TEMP_1_PIN - 1 <nl> + # define TEMP_2_PIN - 1 <nl> + # define TEMP_BED_PIN 1 / / MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING ! ! ! ! ! ! ! ! ! ( pin 34 bed ) <nl> + <nl> + # define HEATER_0_PIN 4 <nl> + # define HEATER_1_PIN - 1 <nl> + # define HEATER_2_PIN - 1 <nl> + # define HEATER_BED_PIN 3 / / ( bed ) <nl> + <nl> + <nl> + <nl> + <nl> + # define SDPOWER - 1 <nl> + # define SDSS 31 / / SCL pin of I2C header | | CS Pin for SD Card support <nl> + # define LED_PIN - 1 <nl> + <nl> + # define FAN_PIN - 1 <nl> + # define PS_ON_PIN 19 <nl> + / / our pin for debugging . <nl> + <nl> + # define DEBUG_PIN - 1 <nl> + <nl> + / / our RS485 pins <nl> + / / # define TX_ENABLE_PIN 12 <nl> + / / # define RX_ENABLE_PIN 13 <nl> + <nl> + # define BEEPER - 1 <nl> + # define SDCARDDETECT - 1 <nl> + # define SUICIDE_PIN - 1 / / has to be defined ; otherwise Power_off doesn ' t work <nl> + <nl> + / / Pins for 4bit LCD Support <nl> + # define LCD_PINS_RS 18 <nl> + # define LCD_PINS_ENABLE 17 <nl> + # define LCD_PINS_D4 16 <nl> + # define LCD_PINS_D5 15 <nl> + # define LCD_PINS_D6 13 <nl> + # define LCD_PINS_D7 14 <nl> + <nl> + / / buttons are directly attached <nl> + # define BTN_EN1 11 <nl> + # define BTN_EN2 10 <nl> + # define BTN_ENC 12 / / the click <nl> + <nl> + # define BLEN_C 2 <nl> + # define BLEN_B 1 <nl> + # define BLEN_A 0 <nl> + <nl> + <nl> + # define encrot0 0 <nl> + # define encrot1 2 <nl> + # define encrot2 3 <nl> + # define encrot3 1 <nl> + <nl> + <nl> + # endif <nl> <nl> # if MOTHERBOARD = = 7 <nl> # define KNOWN_BOARD <nl>
- Pins for modified GEN7 assigned
MarlinFirmware/Marlin
a11f3b2d2f33487b09ae50c4f878a2ccdec3d974
2012-02-06T10:49:23Z
new file mode 100644 <nl> index 0000000000 . . 12a863deed <nl> mmm / dev / null <nl> ppp b / code / sorting / merge_sort / mergesort_linkedlist . c <nl> <nl> + / / Program to mergesort linked list <nl> + <nl> + # include < stdio . h > <nl> + # include < stdlib . h > <nl> + <nl> + <nl> + typedef struct node { <nl> + int data ; <nl> + struct node * next ; <nl> + } node ; <nl> + <nl> + <nl> + node * insert ( node * root , int data ) <nl> + { <nl> + <nl> + node * tail = malloc ( sizeof ( node ) ) ; <nl> + tail - > data = data ; <nl> + tail - > next = NULL ; <nl> + <nl> + if ( ! root ) <nl> + { <nl> + root = tail ; <nl> + return root ; <nl> + } <nl> + node * temp = root ; <nl> + while ( temp - > next ) <nl> + { <nl> + temp = temp - > next ; <nl> + } <nl> + <nl> + temp - > next = tail ; <nl> + return root ; <nl> + } <nl> + <nl> + void print ( node * root ) <nl> + { <nl> + node * temp = root ; <nl> + while ( temp ) <nl> + { <nl> + printf ( " % d " , temp - > data ) ; <nl> + temp = temp - > next ; <nl> + } <nl> + } <nl> + <nl> + node * merge ( node * lroot , node * rroot ) <nl> + { <nl> + node * root , * temp ; <nl> + <nl> + if ( lroot - > data < = rroot - > data ) <nl> + { <nl> + root = temp = lroot ; <nl> + lroot = lroot - > next ; <nl> + } <nl> + else <nl> + { <nl> + root = temp = rroot ; <nl> + rroot = rroot - > next ; <nl> + } <nl> + <nl> + while ( lroot & & rroot ) <nl> + { <nl> + if ( lroot - > data < = rroot - > data ) <nl> + { <nl> + temp - > next = lroot ; <nl> + temp = temp - > next ; <nl> + lroot = lroot - > next ; <nl> + } <nl> + else <nl> + { <nl> + temp - > next = rroot ; <nl> + temp = temp - > next ; <nl> + rroot = rroot - > next ; <nl> + } <nl> + } <nl> + <nl> + while ( lroot ) <nl> + { <nl> + temp - > next = lroot ; <nl> + temp = temp - > next ; <nl> + lroot = lroot - > next ; <nl> + } <nl> + <nl> + while ( rroot ) <nl> + { <nl> + temp - > next = rroot ; <nl> + temp = temp - > next ; <nl> + rroot = rroot - > next ; <nl> + } <nl> + <nl> + return root ; <nl> + } <nl> + <nl> + node * merge_sort ( node * root , int len ) <nl> + { <nl> + node * temp = root , * prev ; <nl> + int llen = 0 ; <nl> + <nl> + if ( len = = 1 ) <nl> + { <nl> + return root ; <nl> + } <nl> + <nl> + while ( llen < len / 2 ) <nl> + { <nl> + prev = temp ; <nl> + temp = temp - > next ; <nl> + llen + + ; <nl> + } <nl> + prev - > next = NULL ; <nl> + <nl> + node * lroot = merge_sort ( root , llen ) ; <nl> + node * rroot = merge_sort ( temp , len - llen ) ; <nl> + <nl> + temp = merge ( lroot , rroot ) ; <nl> + <nl> + return temp ; <nl> + } <nl> + <nl> + <nl> + int main ( ) <nl> + { <nl> + node * root = NULL , * temp ; <nl> + int len = 0 ; <nl> + <nl> + root = insert ( root , 2 ) ; <nl> + root = insert ( root , 1 ) ; <nl> + root = insert ( root , 13 ) ; <nl> + root = insert ( root , 42 ) ; <nl> + root = insert ( root , - 2 ) ; <nl> + root = insert ( root , 67 ) ; <nl> + root = insert ( root , 22 ) ; <nl> + root = insert ( root , 3 ) ; <nl> + root = insert ( root , 2 ) ; <nl> + root = insert ( root , 12 ) ; <nl> + print ( root ) ; <nl> + <nl> + temp = root ; <nl> + while ( temp ) <nl> + { <nl> + temp = temp - > next ; <nl> + len + + ; <nl> + } <nl> + printf ( " \ n " ) ; <nl> + root = merge_sort ( root , len ) ; <nl> + print ( root ) ; <nl> + return 0 ; <nl> + } <nl>
Merge pull request from huzaifafaruqui / master
OpenGenus/cosmos
ebc27df6db88cf94d30e24defe20738d54e36697
2017-10-17T15:35:28Z
mmm a / src / phantomjs . pro <nl> ppp b / src / phantomjs . pro <nl> DESTDIR = . . / bin <nl> RESOURCES = phantomjs . qrc \ <nl> ghostdriver / ghostdriver . qrc <nl> <nl> + win32 { <nl> + RESOURCES + = \ <nl> + qt / qtwebkit / Source / WebCore / inspector / front - end / WebKit . qrc \ <nl> + qt / qtwebkit / Source / WebCore / generated / InspectorBackendCommands . qrc <nl> + } <nl> + <nl> ! winrt : ! win32 : { <nl> QTPLUGIN + = qphantom <nl> } <nl>
Include Web Inspector resources in Windows build
ariya/phantomjs
44e50f41d14dfa1abadc76ab8479de778a7179b7
2015-08-06T19:05:06Z
mmm a / lib / SILPasses / Scalar / DeadObjectElimination . cpp <nl> ppp b / lib / SILPasses / Scalar / DeadObjectElimination . cpp <nl> bool DeadObjectElimination : : processAllocApply ( ApplyInst * AI ) { <nl> / / This is a version of the initializer which receives a pre - allocated <nl> / / buffer as first argument . If we want to delete the initializer we also <nl> / / have to delete the allocation . <nl> - / / But we have to check tbhe argument is really a buffer allocation call . <nl> AllocBufferAI = dyn_cast < ApplyInst > ( Arg0 ) ; <nl> if ( ! AllocBufferAI ) <nl> return false ; <nl> - <nl> - auto * FRI = dyn_cast < FunctionRefInst > ( AllocBufferAI - > getCallee ( ) ) ; <nl> - if ( ! FRI ) <nl> - return false ; <nl> - <nl> - StringRef AllocFuncName = FRI - > getReferencedFunction ( ) - > getName ( ) ; <nl> - if ( AllocFuncName ! = " swift_bufferAllocate " & & <nl> - AllocFuncName ! = " swift_bufferAllocateOnStack " ) <nl> - return false ; <nl> - <nl> - if ( ! hasOneNonDebugUse ( * AllocBufferAI ) ) <nl> - return false ; <nl> } <nl> <nl> if ( ! removeAndReleaseArray ( AI ) ) <nl>
DeadObjectElimination : The ArraySemanticsCall API now does the check for us .
apple/swift
1623516911eacbb09c03ffea290ad34583d53b5b
2015-11-12T20:54:49Z
mmm a / base / common / StringRef . h <nl> ppp b / base / common / StringRef . h <nl> struct StringRef <nl> <nl> / / / Non - constexpr due to reinterpret_cast . <nl> template < typename CharT , typename = std : : enable_if_t < sizeof ( CharT ) = = 1 > > <nl> - StringRef ( const CharT * data_ , size_t size_ ) : data ( reinterpret_cast < const char * > ( data_ ) ) , size ( size_ ) { } <nl> + StringRef ( const CharT * data_ , size_t size_ ) : data ( reinterpret_cast < const char * > ( data_ ) ) , size ( size_ ) <nl> + { <nl> + / / / Sanity check for overflowed values . <nl> + assert ( size < 0x8000000000000000ULL ) ; <nl> + } <nl> <nl> constexpr StringRef ( const char * data_ , size_t size_ ) : data ( data_ ) , size ( size_ ) { } <nl> <nl> mmm a / tests / performance / array_index_low_cardinality . xml <nl> ppp b / tests / performance / array_index_low_cardinality . xml <nl> <nl> < create_query > <nl> INSERT INTO perf_lc ( str ) <nl> SELECT concat ( ' asdf ' , toString ( number % 10000 ) ) <nl> - FROM numbers ( 500000000 ) <nl> + FROM numbers ( 250000000 ) <nl> < / create_query > <nl> <nl> < query > SELECT count ( ) FROM perf_lc WHERE str = ' asdf337 ' < / query > <nl>
fixed perftest long test and StringRef assert
ClickHouse/ClickHouse
82206e89dd8599292041aca99f70ad62c3c3819b
2020-08-12T14:07:56Z
mmm a / web <nl> ppp b / web <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit f26bb7a49e7ed37e43496c7edd0937a3c34a47d0 <nl> + Subproject commit f33b9d95a5ecb4f7210f2c99e23f5fbba46fd119 <nl>
Update web index
cocos2d/cocos2d-x
62fe8f0248b3c1dc8dbf062c5bc1bd0d2bbae919
2015-08-12T10:28:10Z
mmm a / format . h <nl> ppp b / format . h <nl> void format ( BasicFormatter < Char > & f , const Char * & format_str , const T & value ) { <nl> internal : : Value & arg_value = arg ; <nl> std : : basic_string < Char > str = os . str ( ) ; <nl> arg_value = internal : : MakeValue < Char > ( str ) ; <nl> - arg . type = static_cast < internal : : Arg : : Type > ( internal : : MakeValue < Char > : : type ( str ) ) ; <nl> + arg . type = static_cast < internal : : Arg : : Type > ( <nl> + internal : : MakeValue < Char > : : type ( str ) ) ; <nl> format_str = f . format ( format_str , arg ) ; <nl> } <nl> <nl> class WindowsError : public SystemError { <nl> . . parsed - literal : : <nl> * < message > * : * < system - message > * <nl> <nl> - where * < message > * is the formatted message and * < system - message > * is the system <nl> - message corresponding to the error code . <nl> + where * < message > * is the formatted message and * < system - message > * is the <nl> + system message corresponding to the error code . <nl> * error_code * is a Windows error code as given by ` ` GetLastError ` ` . <nl> If * error_code * is not a valid error code such as - 1 , the system message <nl> will look like " error - 1 " . <nl> class WindowsError : public SystemError { <nl> const char * filename = " madeup " ; <nl> LPOFSTRUCT of = LPOFSTRUCT ( ) ; <nl> HFILE file = OpenFile ( filename , & of , OF_READ ) ; <nl> - if ( file = = HFILE_ERROR ) <nl> - throw fmt : : WindowsError ( GetLastError ( ) , " cannot open file ' { } ' " , filename ) ; <nl> + if ( file = = HFILE_ERROR ) { <nl> + throw fmt : : WindowsError ( GetLastError ( ) , <nl> + " cannot open file ' { } ' " , filename ) ; <nl> + } <nl> \ endrst <nl> * / <nl> WindowsError ( int error_code , StringRef message ) { <nl>
Break long lines
fmtlib/fmt
7215c3446b0825bb45def8d1aab536540087c37a
2015-02-25T00:44:01Z
mmm a / src / handles . cc <nl> ppp b / src / handles . cc <nl> Handle < FixedArray > GetKeysInFixedArrayFor ( Handle < JSObject > object , <nl> <nl> / / Check access rights if required . <nl> if ( current - > IsAccessCheckNeeded ( ) & & <nl> - ! Top : : MayNamedAccess ( * current , Heap : : undefined_value ( ) , <nl> - v8 : : ACCESS_KEYS ) ) { <nl> + ! Top : : MayNamedAccess ( * current , Heap : : undefined_value ( ) , <nl> + v8 : : ACCESS_KEYS ) ) { <nl> Top : : ReportFailedAccessCheck ( * current , v8 : : ACCESS_KEYS ) ; <nl> break ; <nl> } <nl> mmm a / src / objects . cc <nl> ppp b / src / objects . cc <nl> Object * JSObject : : SetPropertyWithFailedAccessCheck ( LookupResult * result , <nl> } <nl> } <nl> <nl> + HandleScope scope ; <nl> + Handle < Object > value_handle ( value ) ; <nl> Top : : ReportFailedAccessCheck ( this , v8 : : ACCESS_SET ) ; <nl> - return value ; <nl> + return * value_handle ; <nl> } <nl> <nl> <nl> Object * JSObject : : SetElement ( uint32_t index , Object * value ) { <nl> / / Check access rights if needed . <nl> if ( IsAccessCheckNeeded ( ) & & <nl> ! Top : : MayIndexedAccess ( this , index , v8 : : ACCESS_SET ) ) { <nl> + HandleScope scope ; <nl> + Handle < Object > value_handle ( value ) ; <nl> Top : : ReportFailedAccessCheck ( this , v8 : : ACCESS_SET ) ; <nl> - return value ; <nl> + return * value_handle ; <nl> } <nl> <nl> if ( IsJSGlobalProxy ( ) ) { <nl> mmm a / src / top . cc <nl> ppp b / src / top . cc <nl> void Top : : PrintStack ( StringStream * accumulator ) { <nl> <nl> <nl> void Top : : SetFailedAccessCheckCallback ( v8 : : FailedAccessCheckCallback callback ) { <nl> - ASSERT ( thread_local_ . failed_access_check_callback_ = = NULL ) ; <nl> thread_local_ . failed_access_check_callback_ = callback ; <nl> } <nl> <nl> void Top : : ReportFailedAccessCheck ( JSObject * receiver , v8 : : AccessType type ) { <nl> <nl> ASSERT ( receiver - > IsAccessCheckNeeded ( ) ) ; <nl> ASSERT ( Top : : context ( ) ) ; <nl> - / / The callers of this method are not expecting a GC . <nl> - AssertNoAllocation no_gc ; <nl> <nl> / / Get the data object from access check info . <nl> JSFunction * constructor = JSFunction : : cast ( receiver - > map ( ) - > constructor ( ) ) ; <nl> mmm a / test / cctest / test - api . cc <nl> ppp b / test / cctest / test - api . cc <nl> static void ExpectTrue ( const char * code ) { <nl> } <nl> <nl> <nl> + static void ExpectFalse ( const char * code ) { <nl> + ExpectBoolean ( code , false ) ; <nl> + } <nl> + <nl> + <nl> static void ExpectObject ( const char * code , Local < Value > expected ) { <nl> Local < Value > result = CompileRun ( code ) ; <nl> CHECK ( result - > Equals ( expected ) ) ; <nl> } <nl> <nl> <nl> + static void ExpectUndefined ( const char * code ) { <nl> + Local < Value > result = CompileRun ( code ) ; <nl> + CHECK ( result - > IsUndefined ( ) ) ; <nl> + } <nl> + <nl> + <nl> static int signature_callback_count ; <nl> static v8 : : Handle < Value > IncrementingSignatureCallback ( <nl> const v8 : : Arguments & args ) { <nl> THREADED_TEST ( TwoByteStringInAsciiCons ) { <nl> reresult = CompileRun ( " str2 . charCodeAt ( 2 ) ; " ) ; <nl> CHECK_EQ ( static_cast < int32_t > ( ' e ' ) , reresult - > Int32Value ( ) ) ; <nl> } <nl> + <nl> + <nl> + / / Failed access check callback that performs a GC on each invocation . <nl> + void FailedAccessCheckCallbackGC ( Local < v8 : : Object > target , <nl> + v8 : : AccessType type , <nl> + Local < v8 : : Value > data ) { <nl> + i : : Heap : : CollectAllGarbage ( true ) ; <nl> + } <nl> + <nl> + <nl> + TEST ( GCInFailedAccessCheckCallback ) { <nl> + / / Install a failed access check callback that performs a GC on each <nl> + / / invocation . Then force the callback to be called from va <nl> + <nl> + v8 : : V8 : : Initialize ( ) ; <nl> + v8 : : V8 : : SetFailedAccessCheckCallbackFunction ( & FailedAccessCheckCallbackGC ) ; <nl> + <nl> + v8 : : HandleScope scope ; <nl> + <nl> + / / Create an ObjectTemplate for global objects and install access <nl> + / / check callbacks that will block access . <nl> + v8 : : Handle < v8 : : ObjectTemplate > global_template = v8 : : ObjectTemplate : : New ( ) ; <nl> + global_template - > SetAccessCheckCallbacks ( NamedGetAccessBlocker , <nl> + IndexedGetAccessBlocker , <nl> + v8 : : Handle < v8 : : Value > ( ) , <nl> + false ) ; <nl> + <nl> + / / Create a context and set an x property on it ' s global object . <nl> + LocalContext context0 ( NULL , global_template ) ; <nl> + context0 - > Global ( ) - > Set ( v8_str ( " x " ) , v8_num ( 42 ) ) ; <nl> + v8 : : Handle < v8 : : Object > global0 = context0 - > Global ( ) ; <nl> + <nl> + / / Create a context with a different security token so that the <nl> + / / failed access check callback will be called on each access . <nl> + LocalContext context1 ( NULL , global_template ) ; <nl> + context1 - > Global ( ) - > Set ( v8_str ( " other " ) , global0 ) ; <nl> + <nl> + / / Get property with failed access check . <nl> + ExpectUndefined ( " other . x " ) ; <nl> + <nl> + / / Get element with failed access check . <nl> + ExpectUndefined ( " other [ 0 ] " ) ; <nl> + <nl> + / / Set property with failed access check . <nl> + v8 : : Handle < v8 : : Value > result = CompileRun ( " other . x = new Object ( ) " ) ; <nl> + CHECK ( result - > IsObject ( ) ) ; <nl> + <nl> + / / Set element with failed access check . <nl> + result = CompileRun ( " other [ 0 ] = new Object ( ) " ) ; <nl> + CHECK ( result - > IsObject ( ) ) ; <nl> + <nl> + / / Get property attribute with failed access check . <nl> + ExpectFalse ( " \ ' x \ ' in other " ) ; <nl> + <nl> + / / Get property attribute for element with failed access check . <nl> + ExpectFalse ( " 0 in other " ) ; <nl> + <nl> + / / Delete property . <nl> + ExpectFalse ( " delete other . x " ) ; <nl> + <nl> + / / Delete element . <nl> + CHECK_EQ ( false , global0 - > Delete ( 0 ) ) ; <nl> + <nl> + / / DefineAccessor . <nl> + CHECK_EQ ( false , <nl> + global0 - > SetAccessor ( v8_str ( " x " ) , GetXValue , NULL , v8_str ( " x " ) ) ) ; <nl> + <nl> + / / Define JavaScript accessor . <nl> + ExpectUndefined ( " Object . prototype . __defineGetter__ . call ( " <nl> + " other , \ ' x \ ' , function ( ) { return 42 ; } ) " ) ; <nl> + <nl> + / / LookupAccessor . <nl> + ExpectUndefined ( " Object . prototype . __lookupGetter__ . call ( " <nl> + " other , \ ' x \ ' ) " ) ; <nl> + <nl> + / / HasLocalElement . <nl> + ExpectFalse ( " Object . prototype . hasOwnProperty . call ( other , \ ' 0 \ ' ) " ) ; <nl> + <nl> + CHECK_EQ ( false , global0 - > HasRealIndexedProperty ( 0 ) ) ; <nl> + CHECK_EQ ( false , global0 - > HasRealNamedProperty ( v8_str ( " x " ) ) ) ; <nl> + CHECK_EQ ( false , global0 - > HasRealNamedCallbackProperty ( v8_str ( " x " ) ) ) ; <nl> + <nl> + / / Reset the failed access check callback so it does not influence <nl> + / / the other tests . <nl> + v8 : : V8 : : SetFailedAccessCheckCallbackFunction ( NULL ) ; <nl> + } <nl>
Allow allocation in FailedAccessCheckCallback to allow embedders to
v8/v8
d40abe33131b78ccec9811753827ea1040842f68
2010-08-13T06:55:44Z
mmm a / tests / test_core . py <nl> ppp b / tests / test_core . py <nl> def test_inlinejs ( self ) : <nl> int main ( ) { <nl> asm ( " Module . print ( ' Inline JS is very cool ' ) " ) ; <nl> printf ( " % . 2f \ n " , get ( ) ) ; <nl> + <nl> + / / Test that passing multiple input and output variables works . <nl> + int src1 = 1 , src2 = 2 , src3 = 3 ; <nl> + int dst1 = 0 , dst2 = 0 , dst3 = 0 ; <nl> + asm ( " Module . print ( % 3 ) ; Module . print ( % 4 ) ; Module . print ( % 5 ) ; % 0 = % 3 ; % 1 = % 4 ; % 2 = % 5 ; " : " = r " ( dst1 ) , " = r " ( dst2 ) , " = r " ( dst3 ) : " r " ( src1 ) , " r " ( src2 ) , " r " ( src3 ) ) ; <nl> + printf ( " % d \ n % d \ n % d \ n " , dst1 , dst2 , dst3 ) ; <nl> + <nl> return 0 ; <nl> } <nl> ' ' ' <nl> <nl> - self . do_run ( src , ' Inline JS is very cool \ n3 . 64 \ n ' ) <nl> + self . do_run ( src , ' Inline JS is very cool \ n3 . 64 \ n1 \ n2 \ n3 \ n1 \ n2 \ n3 \ n ' ) <nl> <nl> def test_inlinejs2 ( self ) : <nl> if Settings . ASM_JS : Settings . ASM_JS = 2 # skip validation , asm does not support random code <nl>
Add new unit test for inline asm syntax passing through input variables to output variables .
emscripten-core/emscripten
a1b9fd28f9392143ad571cb5567192c0ec3b5e73
2013-09-11T15:36:27Z
mmm a / tensorflow / lite / c / c_api_experimental . h <nl> ppp b / tensorflow / lite / c / c_api_experimental . h <nl> extern " C " { <nl> # endif / / __cplusplus <nl> <nl> / / / Resets all variable tensors to zero . <nl> + / / / <nl> + / / / WARNING : This is an experimental API and subject to change . <nl> TFL_CAPI_EXPORT extern TfLiteStatus TfLiteInterpreterResetVariableTensors ( <nl> TfLiteInterpreter * interpreter ) ; <nl> <nl> TFL_CAPI_EXPORT extern TfLiteStatus TfLiteInterpreterResetVariableTensors ( <nl> / / / <nl> / / / Code that uses this function should NOT call <nl> / / / ` TfLiteInterpreterOptionsSetOpResolver ' on the same options object . <nl> + / / / <nl> + / / / WARNING : This is an experimental API and subject to change . <nl> TFL_CAPI_EXPORT void TfLiteInterpreterOptionsAddBuiltinOp ( <nl> TfLiteInterpreterOptions * options , TfLiteBuiltinOperator op , <nl> const TfLiteRegistration * registration , int32_t min_version , <nl> TFL_CAPI_EXPORT void TfLiteInterpreterOptionsAddBuiltinOp ( <nl> / / / <nl> / / / Code that uses this function should NOT call <nl> / / / ` TfLiteInterpreterOptionsSetOpResolver ' on the same options object . <nl> + / / / <nl> + / / / WARNING : This is an experimental API and subject to change . <nl> TFL_CAPI_EXPORT void TfLiteInterpreterOptionsAddCustomOp ( <nl> TfLiteInterpreterOptions * options , const char * name , <nl> const TfLiteRegistration * registration , int32_t min_version , <nl> TFL_CAPI_EXPORT void TfLiteInterpreterOptionsAddCustomOp ( <nl> / / / Code that uses this function should NOT call <nl> / / / ` TfLiteInterpreterOptionsAddBuiltin ' or <nl> / / / ` TfLiteInterpreterOptionsAddCustomOp ' on the same options object . <nl> + / / / <nl> + / / / WARNING : This is an experimental API and subject to change . <nl> void TfLiteInterpreterOptionsSetOpResolver ( <nl> TfLiteInterpreterOptions * options , <nl> const TfLiteRegistration * ( * find_builtin_op ) ( void * user_data , <nl> void TfLiteInterpreterOptionsSetOpResolver ( <nl> / / / <nl> / / / NOTE : The client * must * explicitly allocate tensors before attempting to <nl> / / / access input tensor data or invoke the interpreter . <nl> + / / / <nl> + / / / WARNING : This is an experimental API and subject to change . <nl> TFL_CAPI_EXPORT extern TfLiteInterpreter * <nl> TfLiteInterpreterCreateWithSelectedOps ( const TfLiteModel * model , <nl> const TfLiteInterpreterOptions * options ) ; <nl> <nl> / / / Enable or disable the NN API for the interpreter ( true to enable ) . <nl> + / / / <nl> + / / / WARNING : This is an experimental API and subject to change . <nl> TFL_CAPI_EXPORT extern void TfLiteInterpreterOptionsSetUseNNAPI ( <nl> TfLiteInterpreterOptions * options , bool enable ) ; <nl> <nl>
Add explicit documentation for each of the API functions in
tensorflow/tensorflow
2e2765f0237ec05361bb93bb44d37126435f7782
2020-09-29T17:31:48Z
new file mode 100644 <nl> index 00000000000 . . 92a7573e4ba <nl> mmm / dev / null <nl> ppp b / scripts / addPoshVcpkgToPowershellProfile . ps1 <nl> <nl> + [ CmdletBinding ( ) ] <nl> + param ( ) <nl> + <nl> + function findExistingImportModuleDirectives ( [ Parameter ( Mandatory = $ true ) ] [ string ] $ path ) <nl> + { <nl> + if ( ! ( Test - Path $ path ) ) <nl> + { <nl> + return $ false <nl> + } <nl> + <nl> + $ fileContents = Get - Content $ path <nl> + return $ fileContents - match ' Import - Module . + ? ( ? = posh - vcpkg ) ' <nl> + } <nl> + <nl> + $ scriptsDir = split - path - parent $ MyInvocation . MyCommand . Definition <nl> + . " $ scriptsDir \ VcpkgPowershellUtils . ps1 " <nl> + <nl> + $ profileEntry = " Import - Module ' $ scriptsDir \ posh - vcpkg ' " <nl> + $ profilePath = $ PROFILE # Implicit powershell variable <nl> + if ( ! ( Test - Path $ profilePath ) ) <nl> + { <nl> + $ profileDir = Split - Path $ profilePath - Parent <nl> + vcpkgCreateDirectoryIfNotExists $ profileDir <nl> + } <nl> + <nl> + Write - Host " ` nAdding the following line to $ { profilePath } : " <nl> + Write - Host " $ profileEntry " <nl> + <nl> + # @ ( ) Needed to force Array in PowerShell 2 . 0 <nl> + [ Array ] $ existingImports = @ ( findExistingImportModuleDirectives $ profilePath ) <nl> + if ( $ existingImports . Count - gt 0 ) <nl> + { <nl> + $ existingImportsOut = $ existingImports - join " ` n " <nl> + Write - Host " ` nposh - vcpkg is already imported to your PowerShell profile . The following entries were found : " <nl> + Write - Host " $ existingImportsOut " <nl> + Write - Host " ` nPlease make sure you have started a new Powershell window for the changes to take effect . " <nl> + return <nl> + } <nl> + <nl> + # Posh - git does the following check , so we should too . <nl> + # https : / / github . com / dahlbyk / posh - git / blob / master / src / Utils . ps1 <nl> + # If the profile script exists and is signed , then we should not modify it <nl> + if ( Test - Path $ profilePath ) <nl> + { <nl> + $ sig = Get - AuthenticodeSignature $ profilePath <nl> + if ( $ null - ne $ sig . SignerCertificate ) <nl> + { <nl> + Write - Warning " Skipping add of posh - vcpkg import to profile ; ' $ profilePath ' appears to be signed . " <nl> + Write - Warning " Please manually add the line ' $ profileEntry ' to your profile and resign it . " <nl> + return <nl> + } <nl> + } <nl> + <nl> + Add - Content $ profilePath - Value " ` n $ profileEntry " - Encoding UTF8 <nl> + Write - Host " ` nSuccessfully added posh - vcpkg to your PowerShell profile . Please start a new Powershell window for the changes to take effect . " <nl> mmm a / toolsrc / src / vcpkg / commands . integrate . cpp <nl> ppp b / toolsrc / src / vcpkg / commands . integrate . cpp <nl> With a project open , go to Tools - > NuGet Package Manager - > Package Manager Console <nl> " vcpkg integrate install Make installed packages available user - wide . Requires admin privileges on " <nl> " first use \ n " <nl> " vcpkg integrate remove Remove user - wide integration \ n " <nl> - " vcpkg integrate project Generate a referencing nuget package for individual VS project use \ n " ; <nl> + " vcpkg integrate project Generate a referencing nuget package for individual VS project use \ n " <nl> + " vcpkg integrate powershell Enable PowerShell Tab - Completion \ n " ; <nl> <nl> namespace Subcommand <nl> { <nl> static const std : : string INSTALL = " install " ; <nl> static const std : : string REMOVE = " remove " ; <nl> static const std : : string PROJECT = " project " ; <nl> + static const std : : string POWERSHELL = " powershell " ; <nl> } <nl> <nl> static std : : vector < std : : string > valid_arguments ( const VcpkgPaths & ) <nl> { <nl> - return { Subcommand : : INSTALL , Subcommand : : REMOVE , Subcommand : : PROJECT } ; <nl> + return { Subcommand : : INSTALL , Subcommand : : REMOVE , Subcommand : : PROJECT , Subcommand : : POWERSHELL } ; <nl> } <nl> <nl> const CommandStructure COMMAND_STRUCTURE = { <nl> With a project open , go to Tools - > NuGet Package Manager - > Package Manager Console <nl> { <nl> return integrate_project ( paths ) ; <nl> } <nl> + if ( args . command_arguments [ 0 ] = = Subcommand : : POWERSHELL ) <nl> + { <nl> + System : : powershell_execute ( " PowerShell Tab - Completion " , <nl> + paths . scripts / " addPoshVcpkgToPowershellProfile . ps1 " ) ; <nl> + Checks : : exit_success ( VCPKG_LINE_INFO ) ; <nl> + } <nl> # endif <nl> <nl> Checks : : exit_with_message ( VCPKG_LINE_INFO , " Unknown parameter % s for integrate " , args . command_arguments [ 0 ] ) ; <nl>
Add ` vcpkg integrate powershell ` for tab completion
microsoft/vcpkg
d26a6b067c24e324b111849c320bdc4cf681e713
2017-12-04T23:37:06Z
mmm a / hphp / runtime / ext / server / ext_server . cpp <nl> ppp b / hphp / runtime / ext / server / ext_server . cpp <nl> bool HHVM_FUNCTION ( server_is_stopping ) { <nl> } <nl> <nl> int64_t HHVM_FUNCTION ( server_health_level ) { <nl> - constexpr int32_t kMaxHealth = 100 ; <nl> if ( HttpServer : : Server ) { <nl> if ( auto const server = HttpServer : : Server - > getPageServer ( ) ) { <nl> - / / Smaller HealthLevel indicates better health condition , under <nl> - / / which this function returns a bigger number . <nl> - static_assert ( static_cast < int > ( HealthLevel : : Bold ) = = 0 , " " ) ; <nl> - constexpr int32_t kMaxLevel = <nl> - static_cast < int32_t > ( HealthLevel : : NumLevels ) - 1 ; <nl> - auto const level = server - > getHealthLevel ( ) ; <nl> - if ( LIKELY ( level = = HealthLevel : : Bold ) ) return kMaxHealth ; <nl> - auto const result = kMaxHealth * <nl> - ( kMaxLevel - static_cast < int32_t > ( level ) ) / kMaxLevel ; <nl> - return result ; <nl> + return healthLeveltToInt ( server - > getHealthLevel ( ) ) ; <nl> } <nl> } <nl> / / If server is not yet started , e . g . , when not running in server <nl> / / mode , or before server starts , we assume everything is OK . <nl> - return kMaxHealth ; <nl> + return healthLeveltToInt ( HealthLevel : : Bold ) ; <nl> } <nl> <nl> int64_t HHVM_FUNCTION ( server_uptime ) { <nl> mmm a / hphp / util / health - monitor - types . h <nl> ppp b / hphp / util / health - monitor - types . h <nl> <nl> <nl> # include < string > <nl> <nl> + # include < folly / Likely . h > <nl> + <nl> namespace HPHP { <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> struct IHostHealthObserver { <nl> virtual HealthLevel getHealthLevel ( ) = 0 ; <nl> } ; <nl> <nl> + / * <nl> + * Helper function to convert HealthLevel enum value to integer number that is <nl> + * bigger for better health condition . <nl> + * / <nl> + inline int64_t healthLeveltToInt ( HealthLevel level ) { <nl> + constexpr int32_t kMaxHealth = 100 ; <nl> + / / Smaller HealthLevel indicates better health condition , under <nl> + / / which this function returns a bigger number . <nl> + static_assert ( static_cast < int > ( HealthLevel : : Bold ) = = 0 , " " ) ; <nl> + constexpr int32_t kMaxLevel = <nl> + static_cast < int32_t > ( HealthLevel : : NumLevels ) - 1 ; <nl> + if ( LIKELY ( level = = HealthLevel : : Bold ) ) { <nl> + return kMaxHealth ; <nl> + } <nl> + auto const result = kMaxHealth * <nl> + ( kMaxLevel - static_cast < int32_t > ( level ) ) / kMaxLevel ; <nl> + return result ; <nl> + } <nl> + <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> } <nl> <nl>
Add function to convert HealthLevel to " health int " .
facebook/hhvm
2d7ea62309ab8969b35bc0d6f1488f8ca4acc778
2016-05-26T22:07:02Z
mmm a / folly / test / AtomicHashArrayTest . cpp <nl> ppp b / folly / test / AtomicHashArrayTest . cpp <nl> static bool legalKey ( char * a ) { <nl> TEST ( Aha , LookupAny ) { <nl> auto arr = AHACstrInt : : create ( 12 ) ; <nl> <nl> - arr - > insert ( std : : make_pair ( strdup ( " f " ) , 42 ) ) ; <nl> + char * f_char = strdup ( " f " ) ; <nl> + SCOPE_EXIT { free ( f_char ) ; } ; <nl> + arr - > insert ( std : : make_pair ( f_char , 42 ) ) ; <nl> + <nl> EXPECT_EQ ( 42 , arr - > find ( " f " ) - > second ) ; <nl> { <nl> / / Look up a single char , successfully . <nl> TEST ( Aha , LookupAny ) { <nl> EXPECT_TRUE ( res . first ! = arr - > end ( ) ) ; <nl> } <nl> <nl> - for ( auto it : * arr ) free ( it . first ) ; <nl> + for ( auto it : * arr ) { <nl> + free ( it . first ) ; <nl> + } <nl> } <nl>
Fixing AtomicHashArrayTest ASan Test Failure
facebook/folly
2203c92785b64b2df20f0b25e0be6f32a73c18b3
2016-02-25T03:20:27Z
mmm a / dbms / src / Common / BackgroundSchedulePool . cpp <nl> ppp b / dbms / src / Common / BackgroundSchedulePool . cpp <nl> <nl> # include < Common / CurrentMetrics . h > <nl> # include < Common / Exception . h > <nl> # include < Common / setThreadName . h > <nl> + # include < Common / Stopwatch . h > <nl> # include < common / logger_useful . h > <nl> # include < chrono > <nl> <nl> bool BackgroundSchedulePool : : TaskInfo : : schedule ( ) <nl> <nl> scheduled = true ; <nl> <nl> - if ( iterator ! = pool . delayed_tasks . end ( ) ) <nl> + if ( isScheduledWithDelay ( ) ) <nl> pool . cancelDelayedTask ( shared_from_this ( ) ) ; <nl> <nl> pool . queue . enqueueNotification ( new TaskNotification ( shared_from_this ( ) ) ) ; <nl> bool BackgroundSchedulePool : : TaskInfo : : scheduleAfter ( size_t ms ) <nl> <nl> void BackgroundSchedulePool : : TaskInfo : : pause ( ) <nl> { <nl> - Guard g ( lock ) ; <nl> - <nl> - if ( removed ) <nl> - return ; <nl> invalidate ( ) ; <nl> } <nl> <nl> void BackgroundSchedulePool : : TaskInfo : : invalidate ( ) <nl> removed = true ; <nl> scheduled = false ; <nl> <nl> - if ( iterator ! = pool . delayed_tasks . end ( ) ) <nl> + if ( isScheduledWithDelay ( ) ) <nl> pool . cancelDelayedTask ( shared_from_this ( ) ) ; <nl> } <nl> <nl> void BackgroundSchedulePool : : TaskInfo : : execute ( ) <nl> scheduled = false ; <nl> CurrentMetrics : : Increment metric_increment { CurrentMetrics : : BackgroundSchedulePoolTask } ; <nl> <nl> - auto start = std : : chrono : : steady_clock : : now ( ) ; <nl> - <nl> + Stopwatch watch ; <nl> function ( ) ; <nl> - <nl> - auto diff_ms = std : : chrono : : duration_cast < std : : chrono : : milliseconds > ( std : : chrono : : steady_clock : : now ( ) - start ) . count ( ) ; <nl> + UInt64 milliseconds = watch . elapsedMilliseconds ( ) ; <nl> <nl> / / / If the task is executed longer than specified time , it will be logged . <nl> static const int32_t slow_execution_threshold_ms = 50 ; <nl> <nl> - if ( diff_ms > = slow_execution_threshold_ms ) <nl> - LOG_INFO ( & Logger : : get ( " BackgroundSchedulePool " ) , " Executing " < < name < < " took : " < < diff_ms < < " ms " ) ; <nl> + if ( milliseconds > = slow_execution_threshold_ms ) <nl> + LOG_INFO ( & Logger : : get ( " BackgroundSchedulePool " ) , " Executing " < < name < < " took " < < milliseconds < < " ms . " ) ; <nl> } <nl> <nl> <nl> / / BackgroundSchedulePool <nl> <nl> - BackgroundSchedulePool : : BackgroundSchedulePool ( size_t size ) : <nl> - size ( size ) <nl> + BackgroundSchedulePool : : BackgroundSchedulePool ( size_t size ) <nl> + : size ( size ) <nl> { <nl> LOG_INFO ( & Logger : : get ( " BackgroundSchedulePool " ) , " Create BackgroundSchedulePool with " < < size < < " threads " ) ; <nl> <nl> BackgroundSchedulePool : : ~ BackgroundSchedulePool ( ) <nl> try <nl> { <nl> shutdown = true ; <nl> - wake_event . notify_all ( ) ; <nl> + wakeup_event . notify_all ( ) ; <nl> queue . wakeUpAll ( ) ; <nl> <nl> delayed_thread . join ( ) ; <nl> void BackgroundSchedulePool : : scheduleDelayedTask ( const TaskHandle & task , size_t <nl> task - > iterator = delayed_tasks . emplace ( current_time + ( ms * 1000 ) , task ) ; <nl> } <nl> <nl> - wake_event . notify_all ( ) ; <nl> + wakeup_event . notify_all ( ) ; <nl> } <nl> <nl> <nl> void BackgroundSchedulePool : : cancelDelayedTask ( const TaskHandle & task ) <nl> task - > iterator = delayed_tasks . end ( ) ; <nl> } <nl> <nl> - wake_event . notify_all ( ) ; <nl> + wakeup_event . notify_all ( ) ; <nl> } <nl> <nl> <nl> void BackgroundSchedulePool : : threadFunction ( ) <nl> <nl> while ( ! shutdown ) <nl> { <nl> - Poco : : AutoPtr < Poco : : Notification > notification ( queue . waitDequeueNotification ( ) ) ; <nl> - <nl> - if ( notification ) <nl> + if ( Poco : : AutoPtr < Poco : : Notification > notification = queue . waitDequeueNotification ( ) ) <nl> { <nl> TaskNotification & task_notification = static_cast < TaskNotification & > ( * notification ) ; <nl> task_notification . execute ( ) ; <nl> void BackgroundSchedulePool : : delayExecutionThreadFunction ( ) <nl> if ( ! task ) <nl> { <nl> std : : unique_lock < std : : mutex > lock ( delayed_tasks_lock ) ; <nl> - wake_event . wait ( lock ) ; <nl> + wakeup_event . wait ( lock ) ; <nl> continue ; <nl> } <nl> <nl> void BackgroundSchedulePool : : delayExecutionThreadFunction ( ) <nl> if ( min_time > current_time ) <nl> { <nl> std : : unique_lock < std : : mutex > lock ( delayed_tasks_lock ) ; <nl> - wake_event . wait_for ( lock , std : : chrono : : microseconds ( min_time - current_time ) ) ; <nl> + wakeup_event . wait_for ( lock , std : : chrono : : microseconds ( min_time - current_time ) ) ; <nl> } <nl> else <nl> { <nl> mmm a / dbms / src / Common / BackgroundSchedulePool . h <nl> ppp b / dbms / src / Common / BackgroundSchedulePool . h <nl> class BackgroundSchedulePool <nl> TaskInfo ( BackgroundSchedulePool & pool , const std : : string & name , const Task & function ) ; <nl> <nl> / / / Schedule for execution as soon as possible ( if not already scheduled ) . <nl> + / / / If the task was already scheduled with delay , the delay will be ignored . <nl> bool schedule ( ) ; <nl> <nl> / / / Schedule for execution after specified delay . <nl> class BackgroundSchedulePool <nl> bool scheduled = false ; <nl> BackgroundSchedulePool & pool ; <nl> Task function ; <nl> + <nl> + / / / If the task is scheduled with delay , points to element of delayed_tasks . Otherwise , set to delayed_tasks . end ( ) . <nl> Tasks : : iterator iterator ; <nl> + <nl> + bool isScheduledWithDelay ( ) const { return iterator = = pool . delayed_tasks . end ( ) ; } <nl> } ; <nl> <nl> BackgroundSchedulePool ( size_t size ) ; <nl> class BackgroundSchedulePool <nl> <nl> void threadFunction ( ) ; <nl> void delayExecutionThreadFunction ( ) ; <nl> + <nl> + / / / Schedule task for execution after specified delay from now . <nl> void scheduleDelayedTask ( const TaskHandle & task , size_t ms ) ; <nl> + <nl> + / / / Remove task , that was scheduled with delay , from schedule . <nl> void cancelDelayedTask ( const TaskHandle & task ) ; <nl> <nl> + / / / Number for worker threads . <nl> const size_t size ; <nl> std : : atomic < bool > shutdown { false } ; <nl> Threads threads ; <nl> Poco : : NotificationQueue queue ; <nl> <nl> - / / delayed notifications <nl> + / / / Delayed notifications . <nl> <nl> - std : : condition_variable wake_event ; <nl> + std : : condition_variable wakeup_event ; <nl> std : : mutex delayed_tasks_lock ; <nl> + / / / Thread waiting for next delayed task . <nl> std : : thread delayed_thread ; <nl> + / / / Tasks ordered by scheduled time . <nl> Tasks delayed_tasks ; <nl> } ; <nl> <nl>
BackgroundSchedulePool : miscellaneous [ # CLICKHOUSE - 2 ] .
ClickHouse/ClickHouse
dfb4a92f5a321109c89e02cde1896275f19486de
2017-11-18T23:47:39Z
mmm a / cmake / OpenCVConfig . cmake <nl> ppp b / cmake / OpenCVConfig . cmake <nl> if ( MSVC ) <nl> set ( OpenCV_RUNTIME vc11 ) <nl> elseif ( MSVC_VERSION EQUAL 1800 ) <nl> set ( OpenCV_RUNTIME vc12 ) <nl> + elseif ( MSVC_VERSION EQUAL 1900 ) <nl> + set ( OpenCV_RUNTIME vc14 ) <nl> endif ( ) <nl> elseif ( MINGW ) <nl> set ( OpenCV_RUNTIME mingw ) <nl> mmm a / cmake / OpenCVDetectCXXCompiler . cmake <nl> ppp b / cmake / OpenCVDetectCXXCompiler . cmake <nl> if ( MSVC ) <nl> set ( OpenCV_RUNTIME vc11 ) <nl> elseif ( MSVC_VERSION EQUAL 1800 ) <nl> set ( OpenCV_RUNTIME vc12 ) <nl> + elseif ( MSVC_VERSION EQUAL 1900 ) <nl> + set ( OpenCV_RUNTIME vc14 ) <nl> endif ( ) <nl> elseif ( MINGW ) <nl> set ( OpenCV_RUNTIME mingw ) <nl>
Merge pull request from patrikhuber : vs2015 - support - master
opencv/opencv
35884a7e3f48942309fed0890282835272fe3a49
2015-05-15T12:32:27Z
mmm a / tests / cpp - tests / Classes / Sprite3DTest / Sprite3DTest . cpp <nl> ppp b / tests / cpp - tests / Classes / Sprite3DTest / Sprite3DTest . cpp <nl> void Sprite3DWithSkinTest : : addNewSpriteWithCoords ( Vec2 p ) <nl> std : : string fileName = " Sprite3DTest / girl . c3b " ; <nl> auto sprite = Sprite3D : : create ( fileName ) ; <nl> addChild ( sprite ) ; <nl> - sprite - > setRotation3D ( Vec3 ( - 90 . f , 0 . f , 0 . f ) ) ; <nl> sprite - > setPosition ( Vec2 ( p . x , p . y ) ) ; <nl> <nl> auto animation = Animation3D : : getOrCreate ( fileName ) ; <nl>
don ' t rotate girl model
cocos2d/cocos2d-x
7331ef49b61c3aebd14bb1d80aac16ba249b15ff
2014-06-25T05:29:45Z
mmm a / src / core / hle / service / vi / vi . cpp <nl> ppp b / src / core / hle / service / vi / vi . cpp <nl> class IGBPConnectResponseParcel : public Parcel { <nl> Data data { } ; <nl> } ; <nl> <nl> + / / / Represents a parcel containing one int ' 0 ' as its data <nl> + / / / Used by DetachBuffer and Disconnect <nl> + class IGBPEmptyResponseParcel : public Parcel { <nl> + protected : <nl> + void SerializeData ( ) override { <nl> + Write ( data ) ; <nl> + } <nl> + <nl> + private : <nl> + struct Data { <nl> + u32_le unk_0 ; <nl> + } ; <nl> + <nl> + Data data { } ; <nl> + } ; <nl> + <nl> class IGBPSetPreallocatedBufferRequestParcel : public Parcel { <nl> public : <nl> explicit IGBPSetPreallocatedBufferRequestParcel ( std : : vector < u8 > buffer ) <nl> class IHOSBinderDriver final : public ServiceFramework < IHOSBinderDriver > { <nl> ctx . WriteBuffer ( response . Serialize ( ) ) ; <nl> } else if ( transaction = = TransactionId : : CancelBuffer ) { <nl> LOG_CRITICAL ( Service_VI , " ( STUBBED ) called , transaction = CancelBuffer " ) ; <nl> + } else if ( transaction = = TransactionId : : Disconnect | | <nl> + transaction = = TransactionId : : DetachBuffer ) { <nl> + const auto buffer = ctx . ReadBuffer ( ) ; <nl> + <nl> + IGBPEmptyResponseParcel response { } ; <nl> + ctx . WriteBuffer ( response . Serialize ( ) ) ; <nl> } else { <nl> ASSERT_MSG ( false , " Unimplemented " ) ; <nl> } <nl>
Merge pull request from DarkLordZach / vi - disconnect
yuzu-emu/yuzu
611141e09f090e067e98cd99cd5ad56c96c302bb
2018-11-19T03:18:46Z
mmm a / system / include / emscripten / html5 . h <nl> ppp b / system / include / emscripten / html5 . h <nl> extern " C " { <nl> # define EMSCRIPTEN_RESULT_NO_DATA - 7 <nl> <nl> # define EM_BOOL int <nl> + # define EM_TRUE 1 <nl> + # define EM_FALSE 0 <nl> # define EM_UTF8 char <nl> <nl> # define DOM_KEY_LOCATION int <nl>
Adds EM_TRUE and EM_FALSE as convenience macros to html5 . h
emscripten-core/emscripten
cfb789bbf3f21e304ab9fc0c3365a66c9e5fc5a5
2016-04-13T14:09:41Z
mmm a / R - package / src / base . h <nl> ppp b / R - package / src / base . h <nl> <nl> # include < sstream > <nl> # include < set > <nl> # include < vector > <nl> + # include < algorithm > <nl> <nl> / * ! \ brief namespace of mxnet * / <nl> namespace mxnet { <nl> inline bool isSimple ( const Rcpp : : RObject & val ) { <nl> inline std : : string toPyString ( const std : : string & key , const Rcpp : : RObject & val ) { <nl> std : : ostringstream os ; <nl> int len = Rf_length ( val ) ; <nl> - if ( len ! = 1 ) { <nl> + if ( len ! = 1 | | <nl> + key . substr ( std : : max ( 5 , static_cast < int > ( key . size ( ) ) ) - 5 ) = = std : : string ( " shape " ) ) { <nl> RCHECK ( TYPEOF ( val ) = = INTSXP | | TYPEOF ( val ) = = REALSXP ) <nl> < < " Only accept integer vectors or simple types " ; <nl> / / Do shape convesion back to reversed shape . <nl>
Merge pull request from thirdwing / master
apache/incubator-mxnet
53a85bd867978cafd3ca2144425fd629cebf2af0
2015-12-25T01:22:42Z
mmm a / project / BuildDependencies / scripts / 0_package . target - x64 . list <nl> ppp b / project / BuildDependencies / scripts / 0_package . target - x64 . list <nl> shairplay - ce80e00 - x64 - vc140 . 7z <nl> sqlite - 3 . 17 . 0 - x64 - vc140 . 7z <nl> taglib - 1 . 11 . 1 - x64 - vc140 . 7z <nl> tinyxmlstl - 2 . 6 . 2 - x64 - vc140 . 7z <nl> - zlib - 1 . 2 . 11 - x64 - vc140 . 7z <nl> + zlib - 1 . 2 . 11 - x64 - v141 . 7z <nl>
[ windows ] use recompiled zlib for x64
xbmc/xbmc
7f50119932216ba56dce0ea216b4b4fda2777989
2018-06-25T07:00:00Z
mmm a / toolsrc / include / tests . utils . h <nl> ppp b / toolsrc / include / tests . utils . h <nl> std : : unique_ptr < vcpkg : : StatusParagraph > make_status_pgh ( const char * name , <nl> std : : unique_ptr < vcpkg : : StatusParagraph > make_status_feature_pgh ( const char * name , <nl> const char * feature , <nl> const char * depends = " " , <nl> - const char * triplet = " x86 - windows " ) ; <nl> - <nl> - template < class T , class S > <nl> - T & & unwrap ( vcpkg : : ExpectedT < T , S > & & p ) <nl> - { <nl> - Assert : : IsTrue ( p . has_value ( ) ) ; <nl> - return std : : move ( * p . get ( ) ) ; <nl> - } <nl> - <nl> - template < class T > <nl> - T & & unwrap ( vcpkg : : Optional < T > & & opt ) <nl> - { <nl> - Assert : : IsTrue ( opt . has_value ( ) ) ; <nl> - return std : : move ( * opt . get ( ) ) ; <nl> - } <nl> + const char * triplet = " x86 - windows " ) ; <nl> \ No newline at end of file <nl> mmm a / toolsrc / include / vcpkg / commands . h <nl> ppp b / toolsrc / include / vcpkg / commands . h <nl> namespace vcpkg : : Commands <nl> void perform_and_exit ( const VcpkgCmdArguments & args , const VcpkgPaths & paths ) ; <nl> } <nl> <nl> - namespace Upgrade <nl> - { <nl> - extern const CommandStructure COMMAND_STRUCTURE ; <nl> - void perform_and_exit ( const VcpkgCmdArguments & args , const VcpkgPaths & paths , const Triplet & default_triplet ) ; <nl> - } <nl> - <nl> namespace Edit <nl> { <nl> extern const CommandStructure COMMAND_STRUCTURE ; <nl> mmm a / toolsrc / include / vcpkg / dependencies . h <nl> ppp b / toolsrc / include / vcpkg / dependencies . h <nl> namespace vcpkg : : Dependencies <nl> <nl> struct AnyAction <nl> { <nl> - AnyAction ( InstallPlanAction & & iplan ) : install_action ( std : : move ( iplan ) ) { } <nl> - AnyAction ( RemovePlanAction & & rplan ) : remove_action ( std : : move ( rplan ) ) { } <nl> + AnyAction ( InstallPlanAction & & iplan ) : install_plan ( std : : move ( iplan ) ) { } <nl> + AnyAction ( RemovePlanAction & & rplan ) : remove_plan ( std : : move ( rplan ) ) { } <nl> <nl> - Optional < InstallPlanAction > install_action ; <nl> - Optional < RemovePlanAction > remove_action ; <nl> + Optional < InstallPlanAction > install_plan ; <nl> + Optional < RemovePlanAction > remove_plan ; <nl> <nl> const PackageSpec & spec ( ) const ; <nl> } ; <nl> namespace vcpkg : : Dependencies <nl> <nl> struct PortFileProvider <nl> { <nl> - virtual Optional < const SourceControlFile & > get_control_file ( const std : : string & src_name ) const = 0 ; <nl> + virtual const SourceControlFile & get_control_file ( const std : : string & spec ) const = 0 ; <nl> } ; <nl> <nl> - struct MapPortFileProvider : Util : : ResourceBase , PortFileProvider <nl> + struct MapPortFile : Util : : ResourceBase , PortFileProvider <nl> { <nl> - explicit MapPortFileProvider ( const std : : unordered_map < std : : string , SourceControlFile > & map ) ; <nl> - Optional < const SourceControlFile & > get_control_file ( const std : : string & src_name ) const override ; <nl> - <nl> - private : <nl> const std : : unordered_map < std : : string , SourceControlFile > & ports ; <nl> + explicit MapPortFile ( const std : : unordered_map < std : : string , SourceControlFile > & map ) ; <nl> + const SourceControlFile & get_control_file ( const std : : string & spec ) const override ; <nl> } ; <nl> <nl> - struct PathsPortFileProvider : Util : : ResourceBase , PortFileProvider <nl> + struct PathsPortFile : Util : : ResourceBase , PortFileProvider <nl> { <nl> - explicit PathsPortFileProvider ( const VcpkgPaths & paths ) ; <nl> - Optional < const SourceControlFile & > get_control_file ( const std : : string & src_name ) const override ; <nl> - <nl> - private : <nl> const VcpkgPaths & ports ; <nl> mutable std : : unordered_map < std : : string , SourceControlFile > cache ; <nl> - } ; <nl> - <nl> - struct ClusterGraph ; <nl> - struct GraphPlan ; <nl> - <nl> - struct PackageGraph <nl> - { <nl> - PackageGraph ( const PortFileProvider & provider , const StatusParagraphs & status_db ) ; <nl> - ~ PackageGraph ( ) ; <nl> - <nl> - void install ( const FeatureSpec & spec ) ; <nl> - void upgrade ( const PackageSpec & spec ) ; <nl> - <nl> - std : : vector < AnyAction > serialize ( ) const ; <nl> - <nl> - private : <nl> - std : : unique_ptr < GraphPlan > m_graph_plan ; <nl> - std : : unique_ptr < ClusterGraph > m_graph ; <nl> + explicit PathsPortFile ( const VcpkgPaths & paths ) ; <nl> + const SourceControlFile & get_control_file ( const std : : string & spec ) const override ; <nl> } ; <nl> <nl> std : : vector < InstallPlanAction > create_install_plan ( const PortFileProvider & port_file_provider , <nl> namespace vcpkg : : Dependencies <nl> std : : vector < AnyAction > create_feature_install_plan ( const std : : unordered_map < std : : string , SourceControlFile > & map , <nl> const std : : vector < FeatureSpec > & specs , <nl> const StatusParagraphs & status_db ) ; <nl> - <nl> - std : : vector < AnyAction > create_feature_install_plan ( const PortFileProvider & port_file_provider , <nl> - const std : : vector < FeatureSpec > & specs , <nl> - const StatusParagraphs & status_db ) ; <nl> - <nl> - void print_plan ( const std : : vector < AnyAction > & action_plan , const bool is_recursive = true ) ; <nl> } <nl> mmm a / toolsrc / include / vcpkg / paragraphs . h <nl> ppp b / toolsrc / include / vcpkg / paragraphs . h <nl> namespace vcpkg : : Paragraphs <nl> <nl> std : : vector < std : : unique_ptr < SourceControlFile > > load_all_ports ( const Files : : Filesystem & fs , <nl> const fs : : path & ports_dir ) ; <nl> + <nl> + std : : map < std : : string , VersionT > load_all_port_names_and_versions ( const Files : : Filesystem & fs , <nl> + const fs : : path & ports_dir ) ; <nl> } <nl> mmm a / toolsrc / include / vcpkg / update . h <nl> ppp b / toolsrc / include / vcpkg / update . h <nl> <nl> # pragma once <nl> <nl> - # include < vcpkg / dependencies . h > <nl> # include < vcpkg / packagespec . h > <nl> # include < vcpkg / statusparagraphs . h > <nl> # include < vcpkg / vcpkgcmdarguments . h > <nl> namespace vcpkg : : Update <nl> VersionDiff version_diff ; <nl> } ; <nl> <nl> - std : : vector < OutdatedPackage > find_outdated_packages ( const Dependencies : : PortFileProvider & provider , <nl> + std : : vector < OutdatedPackage > find_outdated_packages ( const std : : map < std : : string , VersionT > & src_names_to_versions , <nl> const StatusParagraphs & status_db ) ; <nl> - <nl> void perform_and_exit ( const VcpkgCmdArguments & args , const VcpkgPaths & paths ) ; <nl> - } <nl> + } <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 7a32100424f . . 00000000000 <nl> mmm a / toolsrc / src / commands . upgrade . cpp <nl> ppp / dev / null <nl> <nl> - # include " pch . h " <nl> - <nl> - # include < vcpkg / commands . h > <nl> - # include < vcpkg / dependencies . h > <nl> - # include < vcpkg / help . h > <nl> - # include < vcpkg / install . h > <nl> - # include < vcpkg / statusparagraphs . h > <nl> - # include < vcpkg / update . h > <nl> - # include < vcpkg / vcpkglib . h > <nl> - <nl> - namespace vcpkg : : Commands : : Upgrade <nl> - { <nl> - using Install : : KeepGoing ; <nl> - using Install : : to_keep_going ; <nl> - <nl> - static const std : : string OPTION_NO_DRY_RUN = " - - no - dry - run " ; <nl> - static const std : : string OPTION_KEEP_GOING = " - - keep - going " ; <nl> - <nl> - static const std : : array < CommandSwitch , 2 > INSTALL_SWITCHES = { { <nl> - { OPTION_NO_DRY_RUN , " Actually upgrade " } , <nl> - { OPTION_KEEP_GOING , " Continue installing packages on failure " } , <nl> - } } ; <nl> - <nl> - const CommandStructure COMMAND_STRUCTURE = { <nl> - Help : : create_example_string ( " upgrade - - no - dry - run " ) , <nl> - 0 , <nl> - 0 , <nl> - { INSTALL_SWITCHES , { } } , <nl> - nullptr , <nl> - } ; <nl> - <nl> - void perform_and_exit ( const VcpkgCmdArguments & args , const VcpkgPaths & paths , const Triplet & ) <nl> - { <nl> - / / input sanitization <nl> - const ParsedArguments options = args . parse_arguments ( COMMAND_STRUCTURE ) ; <nl> - <nl> - const bool no_dry_run = Util : : Sets : : contains ( options . switches , OPTION_NO_DRY_RUN ) ; <nl> - const KeepGoing keep_going = to_keep_going ( Util : : Sets : : contains ( options . switches , OPTION_KEEP_GOING ) ) ; <nl> - <nl> - / / create the plan <nl> - StatusParagraphs status_db = database_load_check ( paths ) ; <nl> - <nl> - Dependencies : : PathsPortFileProvider provider ( paths ) ; <nl> - Dependencies : : PackageGraph graph ( provider , status_db ) ; <nl> - <nl> - auto outdated_packages = Update : : find_outdated_packages ( provider , status_db ) ; <nl> - for ( auto & & outdated_package : outdated_packages ) <nl> - graph . upgrade ( outdated_package . spec ) ; <nl> - <nl> - auto plan = graph . serialize ( ) ; <nl> - <nl> - if ( plan . empty ( ) ) <nl> - { <nl> - System : : println ( " All packages are up - to - date . " ) ; <nl> - Checks : : exit_success ( VCPKG_LINE_INFO ) ; <nl> - } <nl> - <nl> - Dependencies : : print_plan ( plan , true ) ; <nl> - <nl> - if ( ! no_dry_run ) <nl> - { <nl> - System : : println ( System : : Color : : warning , <nl> - " If you are sure you want to rebuild the above packages , run this command with the " <nl> - " - - no - dry - run option . " ) ; <nl> - Checks : : exit_fail ( VCPKG_LINE_INFO ) ; <nl> - } <nl> - <nl> - const Install : : InstallSummary summary = Install : : perform ( plan , keep_going , paths , status_db ) ; <nl> - <nl> - System : : println ( " \ nTotal elapsed time : % s \ n " , summary . total_elapsed_time ) ; <nl> - <nl> - if ( keep_going = = KeepGoing : : YES ) <nl> - { <nl> - summary . print ( ) ; <nl> - } <nl> - <nl> - Checks : : exit_success ( VCPKG_LINE_INFO ) ; <nl> - } <nl> - } <nl> mmm a / toolsrc / src / tests . plan . cpp <nl> ppp b / toolsrc / src / tests . plan . cpp <nl> namespace UnitTest1 <nl> std : : vector < std : : string > vec , <nl> const Triplet & triplet = Triplet : : X86_WINDOWS ) <nl> { <nl> - const auto & plan = install_action - > install_action . value_or_exit ( VCPKG_LINE_INFO ) ; <nl> + const auto & plan = install_action - > install_plan . value_or_exit ( VCPKG_LINE_INFO ) ; <nl> const auto & feature_list = plan . feature_list ; <nl> <nl> Assert : : AreEqual ( plan . spec . triplet ( ) . to_string ( ) . c_str ( ) , triplet . to_string ( ) . c_str ( ) ) ; <nl> namespace UnitTest1 <nl> std : : string pkg_name , <nl> const Triplet & triplet = Triplet : : X86_WINDOWS ) <nl> { <nl> - const auto & plan = remove_action - > remove_action . value_or_exit ( VCPKG_LINE_INFO ) ; <nl> + const auto & plan = remove_action - > remove_plan . value_or_exit ( VCPKG_LINE_INFO ) ; <nl> Assert : : AreEqual ( plan . spec . triplet ( ) . to_string ( ) . c_str ( ) , triplet . to_string ( ) . c_str ( ) ) ; <nl> Assert : : AreEqual ( pkg_name . c_str ( ) , plan . spec . name ( ) . c_str ( ) ) ; <nl> } <nl> namespace UnitTest1 <nl> auto spec_b = spec_map . emplace ( " b " , " c " ) ; <nl> auto spec_c = spec_map . emplace ( " c " ) ; <nl> <nl> - Dependencies : : MapPortFileProvider map_port ( spec_map . map ) ; <nl> + Dependencies : : MapPortFile map_port ( spec_map . map ) ; <nl> auto install_plan = <nl> Dependencies : : create_install_plan ( map_port , { spec_a } , StatusParagraphs ( std : : move ( status_paragraphs ) ) ) ; <nl> <nl> namespace UnitTest1 <nl> auto spec_g = spec_map . emplace ( " g " ) ; <nl> auto spec_h = spec_map . emplace ( " h " ) ; <nl> <nl> - Dependencies : : MapPortFileProvider map_port ( spec_map . map ) ; <nl> + Dependencies : : MapPortFile map_port ( spec_map . map ) ; <nl> auto install_plan = Dependencies : : create_install_plan ( <nl> map_port , { spec_a , spec_b , spec_c } , StatusParagraphs ( std : : move ( status_paragraphs ) ) ) ; <nl> <nl> namespace UnitTest1 <nl> StatusParagraphs ( std : : move ( status_paragraphs ) ) ) ; <nl> <nl> Assert : : AreEqual ( size_t ( 1 ) , install_plan . size ( ) ) ; <nl> - auto p = install_plan [ 0 ] . install_action . get ( ) ; <nl> + auto p = install_plan [ 0 ] . install_plan . get ( ) ; <nl> Assert : : IsNotNull ( p ) ; <nl> Assert : : AreEqual ( " a " , p - > spec . name ( ) . c_str ( ) ) ; <nl> Assert : : AreEqual ( Dependencies : : InstallPlanType : : ALREADY_INSTALLED , p - > plan_type ) ; <nl> namespace UnitTest1 <nl> StatusParagraphs ( std : : move ( status_paragraphs ) ) ) ; <nl> <nl> Assert : : AreEqual ( size_t ( 2 ) , install_plan . size ( ) ) ; <nl> - auto p = install_plan [ 0 ] . install_action . get ( ) ; <nl> + auto p = install_plan [ 0 ] . install_plan . get ( ) ; <nl> Assert : : IsNotNull ( p ) ; <nl> Assert : : AreEqual ( " b " , p - > spec . name ( ) . c_str ( ) ) ; <nl> Assert : : AreEqual ( Dependencies : : InstallPlanType : : BUILD_AND_INSTALL , p - > plan_type ) ; <nl> Assert : : AreEqual ( Dependencies : : RequestType : : AUTO_SELECTED , p - > request_type ) ; <nl> <nl> - auto p2 = install_plan [ 1 ] . install_action . get ( ) ; <nl> + auto p2 = install_plan [ 1 ] . install_plan . get ( ) ; <nl> Assert : : IsNotNull ( p2 ) ; <nl> Assert : : AreEqual ( " a " , p2 - > spec . name ( ) . c_str ( ) ) ; <nl> Assert : : AreEqual ( Dependencies : : InstallPlanType : : BUILD_AND_INSTALL , p2 - > plan_type ) ; <nl> namespace UnitTest1 <nl> auto spec_j = spec_map . emplace ( " j " , " k " ) ; <nl> auto spec_k = spec_map . emplace ( " k " ) ; <nl> <nl> - Dependencies : : MapPortFileProvider map_port ( spec_map . map ) ; <nl> + Dependencies : : MapPortFile map_port ( spec_map . map ) ; <nl> auto install_plan = <nl> Dependencies : : create_install_plan ( map_port , { spec_a } , StatusParagraphs ( std : : move ( status_paragraphs ) ) ) ; <nl> <nl> namespace UnitTest1 <nl> Assert : : AreEqual ( " expat " , remove_plan [ 2 ] . spec . name ( ) . c_str ( ) ) ; <nl> } <nl> } ; <nl> - <nl> - class UpgradePlanTests : public TestClass < UpgradePlanTests > <nl> - { <nl> - TEST_METHOD ( basic_upgrade_scheme ) <nl> - { <nl> - std : : vector < std : : unique_ptr < StatusParagraph > > pghs ; <nl> - pghs . push_back ( make_status_pgh ( " a " ) ) ; <nl> - StatusParagraphs status_db ( std : : move ( pghs ) ) ; <nl> - <nl> - PackageSpecMap spec_map ( Triplet : : X86_WINDOWS ) ; <nl> - auto spec_a = spec_map . emplace ( " a " ) ; <nl> - <nl> - Dependencies : : MapPortFileProvider provider ( spec_map . map ) ; <nl> - Dependencies : : PackageGraph graph ( provider , status_db ) ; <nl> - <nl> - graph . upgrade ( spec_a ) ; <nl> - <nl> - auto plan = graph . serialize ( ) ; <nl> - <nl> - Assert : : AreEqual ( size_t ( 2 ) , plan . size ( ) ) ; <nl> - Assert : : AreEqual ( " a " , plan [ 0 ] . spec ( ) . name ( ) . c_str ( ) ) ; <nl> - Assert : : IsTrue ( plan [ 0 ] . remove_action . has_value ( ) ) ; <nl> - Assert : : AreEqual ( " a " , plan [ 1 ] . spec ( ) . name ( ) . c_str ( ) ) ; <nl> - Assert : : IsTrue ( plan [ 1 ] . install_action . has_value ( ) ) ; <nl> - } <nl> - <nl> - TEST_METHOD ( basic_upgrade_scheme_with_recurse ) <nl> - { <nl> - std : : vector < std : : unique_ptr < StatusParagraph > > pghs ; <nl> - pghs . push_back ( make_status_pgh ( " a " ) ) ; <nl> - pghs . push_back ( make_status_pgh ( " b " , " a " ) ) ; <nl> - StatusParagraphs status_db ( std : : move ( pghs ) ) ; <nl> - <nl> - PackageSpecMap spec_map ( Triplet : : X86_WINDOWS ) ; <nl> - auto spec_a = spec_map . emplace ( " a " ) ; <nl> - spec_map . emplace ( " b " , " a " ) ; <nl> - <nl> - Dependencies : : MapPortFileProvider provider ( spec_map . map ) ; <nl> - Dependencies : : PackageGraph graph ( provider , status_db ) ; <nl> - <nl> - graph . upgrade ( spec_a ) ; <nl> - <nl> - auto plan = graph . serialize ( ) ; <nl> - <nl> - Assert : : AreEqual ( size_t ( 4 ) , plan . size ( ) ) ; <nl> - Assert : : AreEqual ( " b " , plan [ 0 ] . spec ( ) . name ( ) . c_str ( ) ) ; <nl> - Assert : : IsTrue ( plan [ 0 ] . remove_action . has_value ( ) ) ; <nl> - <nl> - Assert : : AreEqual ( " a " , plan [ 1 ] . spec ( ) . name ( ) . c_str ( ) ) ; <nl> - Assert : : IsTrue ( plan [ 1 ] . remove_action . has_value ( ) ) ; <nl> - <nl> - Assert : : AreEqual ( " a " , plan [ 2 ] . spec ( ) . name ( ) . c_str ( ) ) ; <nl> - Assert : : IsTrue ( plan [ 2 ] . install_action . has_value ( ) ) ; <nl> - <nl> - Assert : : AreEqual ( " b " , plan [ 3 ] . spec ( ) . name ( ) . c_str ( ) ) ; <nl> - Assert : : IsTrue ( plan [ 3 ] . install_action . has_value ( ) ) ; <nl> - } <nl> - <nl> - TEST_METHOD ( basic_upgrade_scheme_with_bystander ) <nl> - { <nl> - std : : vector < std : : unique_ptr < StatusParagraph > > pghs ; <nl> - pghs . push_back ( make_status_pgh ( " a " ) ) ; <nl> - pghs . push_back ( make_status_pgh ( " b " ) ) ; <nl> - StatusParagraphs status_db ( std : : move ( pghs ) ) ; <nl> - <nl> - PackageSpecMap spec_map ( Triplet : : X86_WINDOWS ) ; <nl> - auto spec_a = spec_map . emplace ( " a " ) ; <nl> - spec_map . emplace ( " b " , " a " ) ; <nl> - <nl> - Dependencies : : MapPortFileProvider provider ( spec_map . map ) ; <nl> - Dependencies : : PackageGraph graph ( provider , status_db ) ; <nl> - <nl> - graph . upgrade ( spec_a ) ; <nl> - <nl> - auto plan = graph . serialize ( ) ; <nl> - <nl> - Assert : : AreEqual ( size_t ( 2 ) , plan . size ( ) ) ; <nl> - Assert : : AreEqual ( " a " , plan [ 0 ] . spec ( ) . name ( ) . c_str ( ) ) ; <nl> - Assert : : IsTrue ( plan [ 0 ] . remove_action . has_value ( ) ) ; <nl> - Assert : : AreEqual ( " a " , plan [ 1 ] . spec ( ) . name ( ) . c_str ( ) ) ; <nl> - Assert : : IsTrue ( plan [ 1 ] . install_action . has_value ( ) ) ; <nl> - } <nl> - <nl> - TEST_METHOD ( basic_upgrade_scheme_with_new_dep ) <nl> - { <nl> - std : : vector < std : : unique_ptr < StatusParagraph > > pghs ; <nl> - pghs . push_back ( make_status_pgh ( " a " ) ) ; <nl> - StatusParagraphs status_db ( std : : move ( pghs ) ) ; <nl> - <nl> - PackageSpecMap spec_map ( Triplet : : X86_WINDOWS ) ; <nl> - auto spec_a = spec_map . emplace ( " a " , " b " ) ; <nl> - spec_map . emplace ( " b " ) ; <nl> - <nl> - Dependencies : : MapPortFileProvider provider ( spec_map . map ) ; <nl> - Dependencies : : PackageGraph graph ( provider , status_db ) ; <nl> - <nl> - graph . upgrade ( spec_a ) ; <nl> - <nl> - auto plan = graph . serialize ( ) ; <nl> - <nl> - Assert : : AreEqual ( size_t ( 3 ) , plan . size ( ) ) ; <nl> - Assert : : AreEqual ( " a " , plan [ 0 ] . spec ( ) . name ( ) . c_str ( ) ) ; <nl> - Assert : : IsTrue ( plan [ 0 ] . remove_action . has_value ( ) ) ; <nl> - Assert : : AreEqual ( " b " , plan [ 1 ] . spec ( ) . name ( ) . c_str ( ) ) ; <nl> - Assert : : IsTrue ( plan [ 1 ] . install_action . has_value ( ) ) ; <nl> - Assert : : AreEqual ( " a " , plan [ 2 ] . spec ( ) . name ( ) . c_str ( ) ) ; <nl> - Assert : : IsTrue ( plan [ 2 ] . install_action . has_value ( ) ) ; <nl> - } <nl> - <nl> - TEST_METHOD ( basic_upgrade_scheme_with_features ) <nl> - { <nl> - std : : vector < std : : unique_ptr < StatusParagraph > > pghs ; <nl> - pghs . push_back ( make_status_pgh ( " a " ) ) ; <nl> - pghs . push_back ( make_status_feature_pgh ( " a " , " a1 " ) ) ; <nl> - StatusParagraphs status_db ( std : : move ( pghs ) ) ; <nl> - <nl> - PackageSpecMap spec_map ( Triplet : : X86_WINDOWS ) ; <nl> - auto spec_a = spec_map . emplace ( " a " , " " , { { " a1 " , " " } } ) ; <nl> - <nl> - Dependencies : : MapPortFileProvider provider ( spec_map . map ) ; <nl> - Dependencies : : PackageGraph graph ( provider , status_db ) ; <nl> - <nl> - graph . upgrade ( spec_a ) ; <nl> - <nl> - auto plan = graph . serialize ( ) ; <nl> - <nl> - Assert : : AreEqual ( size_t ( 2 ) , plan . size ( ) ) ; <nl> - <nl> - Assert : : AreEqual ( " a " , plan [ 0 ] . spec ( ) . name ( ) . c_str ( ) ) ; <nl> - Assert : : IsTrue ( plan [ 0 ] . remove_action . has_value ( ) ) ; <nl> - <nl> - features_check ( & plan [ 1 ] , " a " , { " core " , " a1 " } ) ; <nl> - } <nl> - } ; <nl> } <nl> mmm a / toolsrc / src / tests . update . cpp <nl> ppp b / toolsrc / src / tests . update . cpp <nl> using namespace vcpkg : : Update ; <nl> <nl> namespace UnitTest1 <nl> { <nl> - using Pgh = std : : vector < std : : unordered_map < std : : string , std : : string > > ; <nl> - <nl> class UpdateTests : public TestClass < UpdateTests > <nl> { <nl> TEST_METHOD ( find_outdated_packages_basic ) <nl> namespace UnitTest1 <nl> <nl> StatusParagraphs status_db ( std : : move ( status_paragraphs ) ) ; <nl> <nl> - std : : unordered_map < std : : string , SourceControlFile > map ; <nl> - auto scf = unwrap ( SourceControlFile : : parse_control_file ( Pgh { { { " Source " , " a " } , { " Version " , " 0 " } } } ) ) ; <nl> - map . emplace ( " a " , std : : move ( * scf ) ) ; <nl> - Dependencies : : MapPortFileProvider provider ( map ) ; <nl> + std : : map < std : : string , VersionT > port_versions ; <nl> + port_versions [ " a " ] = VersionT ( " 0 " ) ; <nl> <nl> - auto pkgs = SortedVector < OutdatedPackage > ( Update : : find_outdated_packages ( provider , status_db ) , <nl> + auto pkgs = SortedVector < OutdatedPackage > ( Update : : find_outdated_packages ( port_versions , status_db ) , <nl> & OutdatedPackage : : compare_by_name ) ; <nl> <nl> Assert : : AreEqual ( size_t ( 1 ) , pkgs . size ( ) ) ; <nl> namespace UnitTest1 <nl> <nl> StatusParagraphs status_db ( std : : move ( status_paragraphs ) ) ; <nl> <nl> - std : : unordered_map < std : : string , SourceControlFile > map ; <nl> - auto scf = unwrap ( SourceControlFile : : parse_control_file ( Pgh { { { " Source " , " a " } , { " Version " , " 0 " } } } ) ) ; <nl> - map . emplace ( " a " , std : : move ( * scf ) ) ; <nl> - Dependencies : : MapPortFileProvider provider ( map ) ; <nl> + std : : map < std : : string , VersionT > port_versions ; <nl> + port_versions [ " a " ] = VersionT ( " 0 " ) ; <nl> <nl> - auto pkgs = SortedVector < OutdatedPackage > ( Update : : find_outdated_packages ( provider , status_db ) , <nl> + auto pkgs = SortedVector < OutdatedPackage > ( Update : : find_outdated_packages ( port_versions , status_db ) , <nl> & OutdatedPackage : : compare_by_name ) ; <nl> <nl> Assert : : AreEqual ( size_t ( 1 ) , pkgs . size ( ) ) ; <nl> namespace UnitTest1 <nl> <nl> StatusParagraphs status_db ( std : : move ( status_paragraphs ) ) ; <nl> <nl> - std : : unordered_map < std : : string , SourceControlFile > map ; <nl> - auto scf = unwrap ( SourceControlFile : : parse_control_file ( Pgh { { { " Source " , " a " } , { " Version " , " 0 " } } } ) ) ; <nl> - map . emplace ( " a " , std : : move ( * scf ) ) ; <nl> - Dependencies : : MapPortFileProvider provider ( map ) ; <nl> + std : : map < std : : string , VersionT > port_versions ; <nl> + port_versions [ " a " ] = VersionT ( " 0 " ) ; <nl> <nl> - auto pkgs = SortedVector < OutdatedPackage > ( Update : : find_outdated_packages ( provider , status_db ) , <nl> + auto pkgs = SortedVector < OutdatedPackage > ( Update : : find_outdated_packages ( port_versions , status_db ) , <nl> & OutdatedPackage : : compare_by_name ) ; <nl> <nl> Assert : : AreEqual ( size_t ( 1 ) , pkgs . size ( ) ) ; <nl> namespace UnitTest1 <nl> <nl> StatusParagraphs status_db ( std : : move ( status_paragraphs ) ) ; <nl> <nl> - std : : unordered_map < std : : string , SourceControlFile > map ; <nl> - auto scf = unwrap ( SourceControlFile : : parse_control_file ( Pgh { { { " Source " , " a " } , { " Version " , " 2 " } } } ) ) ; <nl> - map . emplace ( " a " , std : : move ( * scf ) ) ; <nl> - Dependencies : : MapPortFileProvider provider ( map ) ; <nl> + std : : map < std : : string , VersionT > port_versions ; <nl> + port_versions [ " a " ] = VersionT ( " 2 " ) ; <nl> <nl> - auto pkgs = SortedVector < OutdatedPackage > ( Update : : find_outdated_packages ( provider , status_db ) , <nl> + auto pkgs = SortedVector < OutdatedPackage > ( Update : : find_outdated_packages ( port_versions , status_db ) , <nl> & OutdatedPackage : : compare_by_name ) ; <nl> <nl> Assert : : AreEqual ( size_t ( 0 ) , pkgs . size ( ) ) ; <nl> mmm a / toolsrc / src / vcpkg / commands . ci . cpp <nl> ppp b / toolsrc / src / vcpkg / commands . ci . cpp <nl> namespace vcpkg : : Commands : : CI <nl> const std : : vector < PackageSpec > specs = PackageSpec : : to_package_specs ( ports , triplet ) ; <nl> <nl> StatusParagraphs status_db = database_load_check ( paths ) ; <nl> - const auto & paths_port_file = Dependencies : : PathsPortFileProvider ( paths ) ; <nl> + const auto & paths_port_file = Dependencies : : PathsPortFile ( paths ) ; <nl> std : : vector < InstallPlanAction > install_plan = <nl> Dependencies : : create_install_plan ( paths_port_file , specs , status_db ) ; <nl> <nl> mmm a / toolsrc / src / vcpkg / commands . cpp <nl> ppp b / toolsrc / src / vcpkg / commands . cpp <nl> namespace vcpkg : : Commands <nl> Span < const PackageNameAndFunction < CommandTypeA > > get_available_commands_type_a ( ) <nl> { <nl> static std : : vector < PackageNameAndFunction < CommandTypeA > > t = { <nl> - { " install " , & Install : : perform_and_exit } , <nl> + PackageNameAndFunction < CommandTypeA > { " install " , & Install : : perform_and_exit } , <nl> { " ci " , & CI : : perform_and_exit } , <nl> { " remove " , & Remove : : perform_and_exit } , <nl> - { " upgrade " , & Upgrade : : perform_and_exit } , <nl> { " build " , & Build : : Command : : perform_and_exit } , <nl> { " env " , & Env : : perform_and_exit } , <nl> { " build - external " , & BuildExternal : : perform_and_exit } , <nl> mmm a / toolsrc / src / vcpkg / commands . portsdiff . cpp <nl> ppp b / toolsrc / src / vcpkg / commands . portsdiff . cpp <nl> namespace vcpkg : : Commands : : PortsDiff <nl> " . vcpkg - root " , <nl> git_exe . u8string ( ) ) ; <nl> System : : cmd_execute_clean ( cmd ) ; <nl> - const auto all_ports = <nl> - Paragraphs : : load_all_ports ( paths . get_filesystem ( ) , temp_checkout_path / ports_dir_name_as_string ) ; <nl> - std : : map < std : : string , VersionT > names_and_versions ; <nl> - for ( auto & & port : all_ports ) <nl> - names_and_versions . emplace ( port - > core_paragraph - > name , port - > core_paragraph - > version ) ; <nl> + const std : : map < std : : string , VersionT > names_and_versions = Paragraphs : : load_all_port_names_and_versions ( <nl> + paths . get_filesystem ( ) , temp_checkout_path / ports_dir_name_as_string ) ; <nl> fs . remove_all ( temp_checkout_path , ec ) ; <nl> return names_and_versions ; <nl> } <nl> mmm a / toolsrc / src / vcpkg / dependencies . cpp <nl> ppp b / toolsrc / src / vcpkg / dependencies . cpp <nl> namespace vcpkg : : Dependencies <nl> <nl> struct ClusterGraph : Util : : MoveOnlyBase <nl> { <nl> - explicit ClusterGraph ( const PortFileProvider & provider ) : m_provider ( provider ) { } <nl> + explicit ClusterGraph ( std : : unordered_map < std : : string , const SourceControlFile * > & & ports ) <nl> + : m_ports ( std : : move ( ports ) ) <nl> + { <nl> + } <nl> <nl> Cluster & get ( const PackageSpec & spec ) <nl> { <nl> auto it = m_graph . find ( spec ) ; <nl> if ( it = = m_graph . end ( ) ) <nl> { <nl> - / / Load on - demand from m_provider <nl> - auto maybe_scf = m_provider . get_control_file ( spec . name ( ) ) ; <nl> - auto & clust = m_graph [ spec ] ; <nl> - clust . spec = spec ; <nl> - if ( auto p_scf = maybe_scf . get ( ) ) cluster_from_scf ( * p_scf , clust ) ; <nl> - return clust ; <nl> + / / Load on - demand from m_ports <nl> + auto it_ports = m_ports . find ( spec . name ( ) ) ; <nl> + if ( it_ports ! = m_ports . end ( ) ) <nl> + { <nl> + auto & clust = m_graph [ spec ] ; <nl> + clust . spec = spec ; <nl> + cluster_from_scf ( * it_ports - > second , clust ) ; <nl> + return clust ; <nl> + } <nl> + return m_graph [ spec ] ; <nl> } <nl> return it - > second ; <nl> } <nl> namespace vcpkg : : Dependencies <nl> } <nl> <nl> std : : unordered_map < PackageSpec , Cluster > m_graph ; <nl> - const PortFileProvider & m_provider ; <nl> + std : : unordered_map < std : : string , const SourceControlFile * > m_ports ; <nl> } ; <nl> <nl> std : : vector < PackageSpec > AnyParagraph : : dependencies ( const Triplet & triplet ) const <nl> namespace vcpkg : : Dependencies <nl> <nl> const PackageSpec & AnyAction : : spec ( ) const <nl> { <nl> - if ( const auto p = install_action . get ( ) ) <nl> + if ( const auto p = install_plan . get ( ) ) <nl> { <nl> return p - > spec ; <nl> } <nl> <nl> - if ( const auto p = remove_action . get ( ) ) <nl> + if ( const auto p = remove_plan . get ( ) ) <nl> { <nl> return p - > spec ; <nl> } <nl> namespace vcpkg : : Dependencies <nl> return left - > spec . name ( ) < right - > spec . name ( ) ; <nl> } <nl> <nl> - MapPortFileProvider : : MapPortFileProvider ( const std : : unordered_map < std : : string , SourceControlFile > & map ) : ports ( map ) <nl> - { <nl> - } <nl> + MapPortFile : : MapPortFile ( const std : : unordered_map < std : : string , SourceControlFile > & map ) : ports ( map ) { } <nl> <nl> - Optional < const SourceControlFile & > MapPortFileProvider : : get_control_file ( const std : : string & spec ) const <nl> + const SourceControlFile & MapPortFile : : get_control_file ( const std : : string & spec ) const <nl> { <nl> auto scf = ports . find ( spec ) ; <nl> - if ( scf = = ports . end ( ) ) return nullopt ; <nl> + if ( scf = = ports . end ( ) ) <nl> + { <nl> + Checks : : exit_fail ( VCPKG_LINE_INFO ) ; <nl> + } <nl> return scf - > second ; <nl> } <nl> <nl> - PathsPortFileProvider : : PathsPortFileProvider ( const VcpkgPaths & paths ) : ports ( paths ) { } <nl> + PathsPortFile : : PathsPortFile ( const VcpkgPaths & paths ) : ports ( paths ) { } <nl> <nl> - Optional < const SourceControlFile & > PathsPortFileProvider : : get_control_file ( const std : : string & spec ) const <nl> + const SourceControlFile & PathsPortFile : : get_control_file ( const std : : string & spec ) const <nl> { <nl> auto cache_it = cache . find ( spec ) ; <nl> if ( cache_it ! = cache . end ( ) ) <nl> namespace vcpkg : : Dependencies <nl> auto it = cache . emplace ( spec , std : : move ( * scf - > get ( ) ) ) ; <nl> return it . first - > second ; <nl> } <nl> - return nullopt ; <nl> + print_error_message ( source_control_file . error ( ) ) ; <nl> + Checks : : exit_fail ( VCPKG_LINE_INFO ) ; <nl> } <nl> <nl> std : : vector < InstallPlanAction > create_install_plan ( const PortFileProvider & port_file_provider , <nl> const std : : vector < PackageSpec > & specs , <nl> const StatusParagraphs & status_db ) <nl> { <nl> - auto fspecs = Util : : fmap ( specs , [ ] ( const PackageSpec & spec ) { return FeatureSpec ( spec , " " ) ; } ) ; <nl> - auto plan = create_feature_install_plan ( port_file_provider , fspecs , status_db ) ; <nl> + struct InstallAdjacencyProvider final : Graphs : : AdjacencyProvider < PackageSpec , InstallPlanAction > <nl> + { <nl> + const PortFileProvider & port_file_provider ; <nl> + const StatusParagraphs & status_db ; <nl> + const std : : unordered_set < PackageSpec > & specs_as_set ; <nl> <nl> - std : : vector < InstallPlanAction > ret ; <nl> - ret . reserve ( plan . size ( ) ) ; <nl> + InstallAdjacencyProvider ( const PortFileProvider & port_file_provider , <nl> + const StatusParagraphs & s , <nl> + const std : : unordered_set < PackageSpec > & specs_as_set ) <nl> + : port_file_provider ( port_file_provider ) , status_db ( s ) , specs_as_set ( specs_as_set ) <nl> + { <nl> + } <nl> <nl> - for ( auto & & action : plan ) <nl> - { <nl> - if ( auto p_install = action . install_action . get ( ) ) <nl> + std : : vector < PackageSpec > adjacency_list ( const InstallPlanAction & plan ) const override <nl> { <nl> - ret . push_back ( std : : move ( * p_install ) ) ; <nl> + if ( plan . any_paragraph . status_paragraph . get ( ) ) return std : : vector < PackageSpec > { } ; <nl> + return plan . any_paragraph . dependencies ( plan . spec . triplet ( ) ) ; <nl> } <nl> - else <nl> + <nl> + InstallPlanAction load_vertex_data ( const PackageSpec & spec ) const override <nl> { <nl> - Checks : : exit_with_message ( VCPKG_LINE_INFO , <nl> - " The installation plan requires feature packages support . Please re - run the " <nl> - " command with - - featurepackages . " ) ; <nl> + const RequestType request_type = specs_as_set . find ( spec ) ! = specs_as_set . end ( ) <nl> + ? RequestType : : USER_REQUESTED <nl> + : RequestType : : AUTO_SELECTED ; <nl> + auto it = status_db . find_installed ( spec ) ; <nl> + if ( it ! = status_db . end ( ) ) return InstallPlanAction { spec , { * it - > get ( ) , nullopt , nullopt } , request_type } ; <nl> + return InstallPlanAction { <nl> + spec , <nl> + { nullopt , nullopt , * port_file_provider . get_control_file ( spec . name ( ) ) . core_paragraph } , <nl> + request_type } ; <nl> } <nl> - } <nl> + } ; <nl> <nl> - return ret ; <nl> + const std : : unordered_set < PackageSpec > specs_as_set ( specs . cbegin ( ) , specs . cend ( ) ) ; <nl> + std : : vector < InstallPlanAction > toposort = <nl> + Graphs : : topological_sort ( specs , InstallAdjacencyProvider { port_file_provider , status_db , specs_as_set } ) ; <nl> + Util : : erase_remove_if ( toposort , [ ] ( const InstallPlanAction & plan ) { <nl> + return plan . request_type = = RequestType : : AUTO_SELECTED & & <nl> + plan . plan_type = = InstallPlanType : : ALREADY_INSTALLED ; <nl> + } ) ; <nl> + <nl> + return toposort ; <nl> } <nl> <nl> std : : vector < RemovePlanAction > create_remove_plan ( const std : : vector < PackageSpec > & specs , <nl> namespace vcpkg : : Dependencies <nl> SUCCESS , <nl> } ; <nl> <nl> - static MarkPlusResult mark_plus ( const std : : string & feature , <nl> - Cluster & cluster , <nl> - ClusterGraph & pkg_to_cluster , <nl> - GraphPlan & graph_plan ) ; <nl> - <nl> - static void mark_minus ( Cluster & cluster , ClusterGraph & pkg_to_cluster , GraphPlan & graph_plan ) ; <nl> + MarkPlusResult mark_plus ( const std : : string & feature , <nl> + Cluster & cluster , <nl> + ClusterGraph & pkg_to_cluster , <nl> + GraphPlan & graph_plan ) ; <nl> + void mark_minus ( Cluster & cluster , ClusterGraph & pkg_to_cluster , GraphPlan & graph_plan ) ; <nl> <nl> MarkPlusResult mark_plus ( const std : : string & feature , Cluster & cluster , ClusterGraph & graph , GraphPlan & graph_plan ) <nl> { <nl> namespace vcpkg : : Dependencies <nl> } <nl> } <nl> <nl> - std : : vector < AnyAction > create_feature_install_plan ( const PortFileProvider & provider , <nl> - const std : : vector < FeatureSpec > & specs , <nl> - const StatusParagraphs & status_db ) <nl> + static ClusterGraph create_feature_install_graph ( const std : : unordered_map < std : : string , SourceControlFile > & map , <nl> + const StatusParagraphs & status_db ) <nl> { <nl> - PackageGraph pgraph ( provider , status_db ) ; <nl> - for ( auto & & spec : specs ) <nl> - pgraph . install ( spec ) ; <nl> + std : : unordered_map < std : : string , const SourceControlFile * > ptr_map ; <nl> + for ( auto & & p : map ) <nl> + ptr_map . emplace ( p . first , & p . second ) ; <nl> + ClusterGraph graph ( std : : move ( ptr_map ) ) ; <nl> + <nl> + auto installed_ports = get_installed_ports ( status_db ) ; <nl> <nl> - return pgraph . serialize ( ) ; <nl> + for ( auto & & status_paragraph : installed_ports ) <nl> + { <nl> + Cluster & cluster = graph . get ( status_paragraph - > package . spec ) ; <nl> + <nl> + cluster . transient_uninstalled = false ; <nl> + <nl> + cluster . status_paragraphs . emplace_back ( status_paragraph ) ; <nl> + <nl> + auto & status_paragraph_feature = status_paragraph - > package . feature ; <nl> + / / In this case , empty string indicates the " core " paragraph for a package . <nl> + if ( status_paragraph_feature . empty ( ) ) <nl> + { <nl> + cluster . original_features . insert ( " core " ) ; <nl> + } <nl> + else <nl> + { <nl> + cluster . original_features . insert ( status_paragraph_feature ) ; <nl> + } <nl> + } <nl> + <nl> + for ( auto & & status_paragraph : installed_ports ) <nl> + { <nl> + auto & spec = status_paragraph - > package . spec ; <nl> + auto & status_paragraph_feature = status_paragraph - > package . feature ; <nl> + auto reverse_edges = FeatureSpec : : from_strings_and_triplet ( status_paragraph - > package . depends , <nl> + status_paragraph - > package . spec . triplet ( ) ) ; <nl> + <nl> + for ( auto & & dependency : reverse_edges ) <nl> + { <nl> + auto & dep_cluster = graph . get ( dependency . spec ( ) ) ; <nl> + <nl> + auto depends_name = dependency . feature ( ) ; <nl> + if ( depends_name . empty ( ) ) depends_name = " core " ; <nl> + <nl> + auto & target_node = dep_cluster . edges [ depends_name ] ; <nl> + target_node . remove_edges . emplace_back ( FeatureSpec { spec , status_paragraph_feature } ) ; <nl> + } <nl> + } <nl> + return graph ; <nl> } <nl> <nl> std : : vector < AnyAction > create_feature_install_plan ( const std : : unordered_map < std : : string , SourceControlFile > & map , <nl> const std : : vector < FeatureSpec > & specs , <nl> const StatusParagraphs & status_db ) <nl> { <nl> - MapPortFileProvider provider ( map ) ; <nl> - return create_feature_install_plan ( provider , specs , status_db ) ; <nl> - } <nl> + ClusterGraph graph = create_feature_install_graph ( map , status_db ) ; <nl> <nl> - void PackageGraph : : install ( const FeatureSpec & spec ) <nl> - { <nl> - Cluster & spec_cluster = m_graph - > get ( spec . spec ( ) ) ; <nl> - spec_cluster . request_type = RequestType : : USER_REQUESTED ; <nl> - if ( spec . feature ( ) = = " * " ) <nl> + GraphPlan graph_plan ; <nl> + for ( auto & & spec : specs ) <nl> { <nl> - if ( auto p_scf = spec_cluster . source_control_file . value_or ( nullptr ) ) <nl> + Cluster & spec_cluster = graph . get ( spec . spec ( ) ) ; <nl> + spec_cluster . request_type = RequestType : : USER_REQUESTED ; <nl> + if ( spec . feature ( ) = = " * " ) <nl> { <nl> - for ( auto & & feature : p_scf - > feature_paragraphs ) <nl> + if ( auto p_scf = spec_cluster . source_control_file . value_or ( nullptr ) ) <nl> { <nl> - auto res = mark_plus ( feature - > name , spec_cluster , * m_graph , * m_graph_plan ) ; <nl> + for ( auto & & feature : p_scf - > feature_paragraphs ) <nl> + { <nl> + auto res = mark_plus ( feature - > name , spec_cluster , graph , graph_plan ) ; <nl> + <nl> + Checks : : check_exit ( VCPKG_LINE_INFO , <nl> + res = = MarkPlusResult : : SUCCESS , <nl> + " Error : Unable to locate feature % s " , <nl> + spec ) ; <nl> + } <nl> + <nl> + auto res = mark_plus ( " core " , spec_cluster , graph , graph_plan ) ; <nl> <nl> Checks : : check_exit ( <nl> VCPKG_LINE_INFO , res = = MarkPlusResult : : SUCCESS , " Error : Unable to locate feature % s " , spec ) ; <nl> } <nl> - <nl> - auto res = mark_plus ( " core " , spec_cluster , * m_graph , * m_graph_plan ) ; <nl> - <nl> - Checks : : check_exit ( <nl> - VCPKG_LINE_INFO , res = = MarkPlusResult : : SUCCESS , " Error : Unable to locate feature % s " , spec ) ; <nl> + else <nl> + { <nl> + Checks : : exit_with_message ( <nl> + VCPKG_LINE_INFO , " Error : Unable to handle ' * ' because can ' t find CONTROL for % s " , spec . spec ( ) ) ; <nl> + } <nl> } <nl> else <nl> { <nl> - Checks : : exit_with_message ( <nl> - VCPKG_LINE_INFO , " Error : Unable to handle ' * ' because can ' t find CONTROL for % s " , spec . spec ( ) ) ; <nl> + auto res = mark_plus ( spec . feature ( ) , spec_cluster , graph , graph_plan ) ; <nl> + <nl> + Checks : : check_exit ( <nl> + VCPKG_LINE_INFO , res = = MarkPlusResult : : SUCCESS , " Error : Unable to locate feature % s " , spec ) ; <nl> } <nl> - } <nl> - else <nl> - { <nl> - auto res = mark_plus ( spec . feature ( ) , spec_cluster , * m_graph , * m_graph_plan ) ; <nl> <nl> - Checks : : check_exit ( <nl> - VCPKG_LINE_INFO , res = = MarkPlusResult : : SUCCESS , " Error : Unable to locate feature % s " , spec ) ; <nl> + graph_plan . install_graph . add_vertex ( ClusterPtr { & spec_cluster } ) ; <nl> } <nl> <nl> - m_graph_plan - > install_graph . add_vertex ( ClusterPtr { & spec_cluster } ) ; <nl> - } <nl> - <nl> - void PackageGraph : : upgrade ( const PackageSpec & spec ) <nl> - { <nl> - Cluster & spec_cluster = m_graph - > get ( spec ) ; <nl> - spec_cluster . request_type = RequestType : : USER_REQUESTED ; <nl> - <nl> - mark_minus ( spec_cluster , * m_graph , * m_graph_plan ) ; <nl> - } <nl> - <nl> - std : : vector < AnyAction > PackageGraph : : serialize ( ) const <nl> - { <nl> - Graphs : : GraphAdjacencyProvider < ClusterPtr > adjacency_remove_graph ( m_graph_plan - > remove_graph . adjacency_list ( ) ) ; <nl> - auto remove_vertex_list = m_graph_plan - > remove_graph . vertex_list ( ) ; <nl> + Graphs : : GraphAdjacencyProvider < ClusterPtr > adjacency_remove_graph ( graph_plan . remove_graph . adjacency_list ( ) ) ; <nl> + auto remove_vertex_list = graph_plan . remove_graph . vertex_list ( ) ; <nl> auto remove_toposort = Graphs : : topological_sort ( remove_vertex_list , adjacency_remove_graph ) ; <nl> <nl> - Graphs : : GraphAdjacencyProvider < ClusterPtr > adjacency_install_graph ( <nl> - m_graph_plan - > install_graph . adjacency_list ( ) ) ; <nl> - auto insert_vertex_list = m_graph_plan - > install_graph . vertex_list ( ) ; <nl> + Graphs : : GraphAdjacencyProvider < ClusterPtr > adjacency_install_graph ( graph_plan . install_graph . adjacency_list ( ) ) ; <nl> + auto insert_vertex_list = graph_plan . install_graph . vertex_list ( ) ; <nl> auto insert_toposort = Graphs : : topological_sort ( insert_vertex_list , adjacency_install_graph ) ; <nl> <nl> std : : vector < AnyAction > plan ; <nl> namespace vcpkg : : Dependencies <nl> <nl> return plan ; <nl> } <nl> - <nl> - static std : : unique_ptr < ClusterGraph > create_feature_install_graph ( const PortFileProvider & map , <nl> - const StatusParagraphs & status_db ) <nl> - { <nl> - std : : unique_ptr < ClusterGraph > graph = std : : make_unique < ClusterGraph > ( map ) ; <nl> - <nl> - auto installed_ports = get_installed_ports ( status_db ) ; <nl> - <nl> - for ( auto & & status_paragraph : installed_ports ) <nl> - { <nl> - Cluster & cluster = graph - > get ( status_paragraph - > package . spec ) ; <nl> - <nl> - cluster . transient_uninstalled = false ; <nl> - <nl> - cluster . status_paragraphs . emplace_back ( status_paragraph ) ; <nl> - <nl> - auto & status_paragraph_feature = status_paragraph - > package . feature ; <nl> - / / In this case , empty string indicates the " core " paragraph for a package . <nl> - if ( status_paragraph_feature . empty ( ) ) <nl> - { <nl> - cluster . original_features . insert ( " core " ) ; <nl> - } <nl> - else <nl> - { <nl> - cluster . original_features . insert ( status_paragraph_feature ) ; <nl> - } <nl> - } <nl> - <nl> - / / Populate the graph with " remove edges " , which are the reverse of the Build - Depends edges . <nl> - for ( auto & & status_paragraph : installed_ports ) <nl> - { <nl> - auto & spec = status_paragraph - > package . spec ; <nl> - auto & status_paragraph_feature = status_paragraph - > package . feature ; <nl> - auto reverse_edges = FeatureSpec : : from_strings_and_triplet ( status_paragraph - > package . depends , <nl> - status_paragraph - > package . spec . triplet ( ) ) ; <nl> - <nl> - for ( auto & & dependency : reverse_edges ) <nl> - { <nl> - auto & dep_cluster = graph - > get ( dependency . spec ( ) ) ; <nl> - <nl> - auto depends_name = dependency . feature ( ) ; <nl> - if ( depends_name . empty ( ) ) depends_name = " core " ; <nl> - <nl> - auto & target_node = dep_cluster . edges [ depends_name ] ; <nl> - target_node . remove_edges . emplace_back ( FeatureSpec { spec , status_paragraph_feature } ) ; <nl> - } <nl> - } <nl> - return graph ; <nl> - } <nl> - <nl> - PackageGraph : : PackageGraph ( const PortFileProvider & provider , const StatusParagraphs & status_db ) <nl> - : m_graph ( create_feature_install_graph ( provider , status_db ) ) , m_graph_plan ( std : : make_unique < GraphPlan > ( ) ) <nl> - { <nl> - } <nl> - <nl> - PackageGraph : : ~ PackageGraph ( ) { } <nl> - <nl> - void print_plan ( const std : : vector < AnyAction > & action_plan , const bool is_recursive ) <nl> - { <nl> - std : : vector < const RemovePlanAction * > remove_plans ; <nl> - std : : vector < const InstallPlanAction * > rebuilt_plans ; <nl> - std : : vector < const InstallPlanAction * > only_install_plans ; <nl> - std : : vector < const InstallPlanAction * > new_plans ; <nl> - std : : vector < const InstallPlanAction * > already_installed_plans ; <nl> - std : : vector < const InstallPlanAction * > excluded ; <nl> - <nl> - const bool has_non_user_requested_packages = Util : : find_if ( action_plan , [ ] ( const AnyAction & package ) - > bool { <nl> - if ( auto iplan = package . install_action . get ( ) ) <nl> - return iplan - > request_type ! = RequestType : : USER_REQUESTED ; <nl> - else <nl> - return false ; <nl> - } ) ! = action_plan . cend ( ) ; <nl> - <nl> - for ( auto & & action : action_plan ) <nl> - { <nl> - if ( auto install_action = action . install_action . get ( ) ) <nl> - { <nl> - / / remove plans are guaranteed to come before install plans , so we know the plan will be contained if at <nl> - / / all . <nl> - auto it = Util : : find_if ( <nl> - remove_plans , [ & ] ( const RemovePlanAction * plan ) { return plan - > spec = = install_action - > spec ; } ) ; <nl> - if ( it ! = remove_plans . end ( ) ) <nl> - { <nl> - rebuilt_plans . emplace_back ( install_action ) ; <nl> - } <nl> - else <nl> - { <nl> - switch ( install_action - > plan_type ) <nl> - { <nl> - case InstallPlanType : : INSTALL : only_install_plans . emplace_back ( install_action ) ; break ; <nl> - case InstallPlanType : : ALREADY_INSTALLED : <nl> - if ( install_action - > request_type = = RequestType : : USER_REQUESTED ) <nl> - already_installed_plans . emplace_back ( install_action ) ; <nl> - break ; <nl> - case InstallPlanType : : BUILD_AND_INSTALL : new_plans . emplace_back ( install_action ) ; break ; <nl> - case InstallPlanType : : EXCLUDED : excluded . emplace_back ( install_action ) ; break ; <nl> - default : Checks : : unreachable ( VCPKG_LINE_INFO ) ; <nl> - } <nl> - } <nl> - } <nl> - else if ( auto remove_action = action . remove_action . get ( ) ) <nl> - { <nl> - remove_plans . emplace_back ( remove_action ) ; <nl> - } <nl> - } <nl> - <nl> - std : : sort ( remove_plans . begin ( ) , remove_plans . end ( ) , & RemovePlanAction : : compare_by_name ) ; <nl> - std : : sort ( rebuilt_plans . begin ( ) , rebuilt_plans . end ( ) , & InstallPlanAction : : compare_by_name ) ; <nl> - std : : sort ( only_install_plans . begin ( ) , only_install_plans . end ( ) , & InstallPlanAction : : compare_by_name ) ; <nl> - std : : sort ( new_plans . begin ( ) , new_plans . end ( ) , & InstallPlanAction : : compare_by_name ) ; <nl> - std : : sort ( already_installed_plans . begin ( ) , already_installed_plans . end ( ) , & InstallPlanAction : : compare_by_name ) ; <nl> - std : : sort ( excluded . begin ( ) , excluded . end ( ) , & InstallPlanAction : : compare_by_name ) ; <nl> - <nl> - static auto actions_to_output_string = [ ] ( const std : : vector < const InstallPlanAction * > & v ) { <nl> - return Strings : : join ( " \ n " , v , [ ] ( const InstallPlanAction * p ) { <nl> - return to_output_string ( p - > request_type , p - > displayname ( ) , p - > build_options ) ; <nl> - } ) ; <nl> - } ; <nl> - <nl> - if ( excluded . size ( ) > 0 ) <nl> - { <nl> - System : : println ( " The following packages are excluded : \ n % s " , actions_to_output_string ( excluded ) ) ; <nl> - } <nl> - <nl> - if ( already_installed_plans . size ( ) > 0 ) <nl> - { <nl> - System : : println ( " The following packages are already installed : \ n % s " , <nl> - actions_to_output_string ( already_installed_plans ) ) ; <nl> - } <nl> - <nl> - if ( rebuilt_plans . size ( ) > 0 ) <nl> - { <nl> - System : : println ( " The following packages will be rebuilt : \ n % s " , actions_to_output_string ( rebuilt_plans ) ) ; <nl> - } <nl> - <nl> - if ( new_plans . size ( ) > 0 ) <nl> - { <nl> - System : : println ( " The following packages will be built and installed : \ n % s " , <nl> - actions_to_output_string ( new_plans ) ) ; <nl> - } <nl> - <nl> - if ( only_install_plans . size ( ) > 0 ) <nl> - { <nl> - System : : println ( " The following packages will be directly installed : \ n % s " , <nl> - actions_to_output_string ( only_install_plans ) ) ; <nl> - } <nl> - <nl> - if ( has_non_user_requested_packages ) <nl> - System : : println ( " Additional packages ( * ) will be modified to complete this operation . " ) ; <nl> - <nl> - if ( remove_plans . size ( ) > 0 & & ! is_recursive ) <nl> - { <nl> - System : : println ( System : : Color : : warning , <nl> - " If you are sure you want to rebuild the above packages , run the command with the " <nl> - " - - recurse option " ) ; <nl> - Checks : : exit_fail ( VCPKG_LINE_INFO ) ; <nl> - } <nl> - } <nl> } <nl> mmm a / toolsrc / src / vcpkg / help . cpp <nl> ppp b / toolsrc / src / vcpkg / help . cpp <nl> namespace vcpkg : : Help <nl> " vcpkg remove - - outdated Uninstall all out - of - date packages \ n " <nl> " vcpkg list List installed packages \ n " <nl> " vcpkg update Display list of packages for updating \ n " <nl> - " vcpkg upgrade Rebuild all outdated packages \ n " <nl> " vcpkg hash < file > [ alg ] Hash a file by specific algorithm , default SHA512 \ n " <nl> " vcpkg help topics Display the list of help topics \ n " <nl> " vcpkg help < topic > Display help for a specific topic \ n " <nl> mmm a / toolsrc / src / vcpkg / install . cpp <nl> ppp b / toolsrc / src / vcpkg / install . cpp <nl> namespace vcpkg : : Install <nl> Checks : : unreachable ( VCPKG_LINE_INFO ) ; <nl> } <nl> <nl> + static void print_plan ( const std : : vector < AnyAction > & action_plan , const bool is_recursive ) <nl> + { <nl> + std : : vector < const RemovePlanAction * > remove_plans ; <nl> + std : : vector < const InstallPlanAction * > rebuilt_plans ; <nl> + std : : vector < const InstallPlanAction * > only_install_plans ; <nl> + std : : vector < const InstallPlanAction * > new_plans ; <nl> + std : : vector < const InstallPlanAction * > already_installed_plans ; <nl> + std : : vector < const InstallPlanAction * > excluded ; <nl> + <nl> + const bool has_non_user_requested_packages = Util : : find_if ( action_plan , [ ] ( const AnyAction & package ) - > bool { <nl> + if ( auto iplan = package . install_plan . get ( ) ) <nl> + return iplan - > request_type ! = RequestType : : USER_REQUESTED ; <nl> + else <nl> + return false ; <nl> + } ) ! = action_plan . cend ( ) ; <nl> + <nl> + for ( auto & & action : action_plan ) <nl> + { <nl> + if ( auto install_action = action . install_plan . get ( ) ) <nl> + { <nl> + / / remove plans are guaranteed to come before install plans , so we know the plan will be contained if at <nl> + / / all . <nl> + auto it = Util : : find_if ( <nl> + remove_plans , [ & ] ( const RemovePlanAction * plan ) { return plan - > spec = = install_action - > spec ; } ) ; <nl> + if ( it ! = remove_plans . end ( ) ) <nl> + { <nl> + rebuilt_plans . emplace_back ( install_action ) ; <nl> + } <nl> + else <nl> + { <nl> + switch ( install_action - > plan_type ) <nl> + { <nl> + case InstallPlanType : : INSTALL : only_install_plans . emplace_back ( install_action ) ; break ; <nl> + case InstallPlanType : : ALREADY_INSTALLED : <nl> + if ( install_action - > request_type = = RequestType : : USER_REQUESTED ) <nl> + already_installed_plans . emplace_back ( install_action ) ; <nl> + break ; <nl> + case InstallPlanType : : BUILD_AND_INSTALL : new_plans . emplace_back ( install_action ) ; break ; <nl> + case InstallPlanType : : EXCLUDED : excluded . emplace_back ( install_action ) ; break ; <nl> + default : Checks : : unreachable ( VCPKG_LINE_INFO ) ; <nl> + } <nl> + } <nl> + } <nl> + else if ( auto remove_action = action . remove_plan . get ( ) ) <nl> + { <nl> + remove_plans . emplace_back ( remove_action ) ; <nl> + } <nl> + } <nl> + <nl> + std : : sort ( remove_plans . begin ( ) , remove_plans . end ( ) , & RemovePlanAction : : compare_by_name ) ; <nl> + std : : sort ( rebuilt_plans . begin ( ) , rebuilt_plans . end ( ) , & InstallPlanAction : : compare_by_name ) ; <nl> + std : : sort ( only_install_plans . begin ( ) , only_install_plans . end ( ) , & InstallPlanAction : : compare_by_name ) ; <nl> + std : : sort ( new_plans . begin ( ) , new_plans . end ( ) , & InstallPlanAction : : compare_by_name ) ; <nl> + std : : sort ( already_installed_plans . begin ( ) , already_installed_plans . end ( ) , & InstallPlanAction : : compare_by_name ) ; <nl> + std : : sort ( excluded . begin ( ) , excluded . end ( ) , & InstallPlanAction : : compare_by_name ) ; <nl> + <nl> + static auto actions_to_output_string = [ ] ( const std : : vector < const InstallPlanAction * > & v ) { <nl> + return Strings : : join ( " \ n " , v , [ ] ( const InstallPlanAction * p ) { <nl> + return to_output_string ( p - > request_type , p - > displayname ( ) , p - > build_options ) ; <nl> + } ) ; <nl> + } ; <nl> + <nl> + if ( excluded . size ( ) > 0 ) <nl> + { <nl> + System : : println ( " The following packages are excluded : \ n % s " , actions_to_output_string ( excluded ) ) ; <nl> + } <nl> + <nl> + if ( already_installed_plans . size ( ) > 0 ) <nl> + { <nl> + System : : println ( " The following packages are already installed : \ n % s " , <nl> + actions_to_output_string ( already_installed_plans ) ) ; <nl> + } <nl> + <nl> + if ( rebuilt_plans . size ( ) > 0 ) <nl> + { <nl> + System : : println ( " The following packages will be rebuilt : \ n % s " , actions_to_output_string ( rebuilt_plans ) ) ; <nl> + } <nl> + <nl> + if ( new_plans . size ( ) > 0 ) <nl> + { <nl> + System : : println ( " The following packages will be built and installed : \ n % s " , <nl> + actions_to_output_string ( new_plans ) ) ; <nl> + } <nl> + <nl> + if ( only_install_plans . size ( ) > 0 ) <nl> + { <nl> + System : : println ( " The following packages will be directly installed : \ n % s " , <nl> + actions_to_output_string ( only_install_plans ) ) ; <nl> + } <nl> + <nl> + if ( has_non_user_requested_packages ) <nl> + System : : println ( " Additional packages ( * ) will be installed to complete this operation . " ) ; <nl> + <nl> + if ( remove_plans . size ( ) > 0 & & ! is_recursive ) <nl> + { <nl> + System : : println ( System : : Color : : warning , <nl> + " If you are sure you want to rebuild the above packages , run the command with the " <nl> + " - - recurse option " ) ; <nl> + Checks : : exit_fail ( VCPKG_LINE_INFO ) ; <nl> + } <nl> + } <nl> + <nl> void InstallSummary : : print ( ) const <nl> { <nl> System : : println ( " RESULTS " ) ; <nl> namespace vcpkg : : Install <nl> <nl> results . emplace_back ( spec , & action ) ; <nl> <nl> - if ( const auto install_action = action . install_action . get ( ) ) <nl> + if ( const auto install_action = action . install_plan . get ( ) ) <nl> { <nl> auto result = perform_install_plan_action ( paths , * install_action , status_db ) ; <nl> <nl> namespace vcpkg : : Install <nl> <nl> results . back ( ) . build_result = std : : move ( result ) ; <nl> } <nl> - else if ( const auto remove_action = action . remove_action . get ( ) ) <nl> + else if ( const auto remove_action = action . remove_plan . get ( ) ) <nl> { <nl> Checks : : check_exit ( VCPKG_LINE_INFO , GlobalState : : feature_packages ) ; <nl> Remove : : perform_remove_plan_action ( paths , * remove_action , Remove : : Purge : : YES , status_db ) ; <nl> namespace vcpkg : : Install <nl> } <nl> else <nl> { <nl> - Dependencies : : PathsPortFileProvider paths_port_file ( paths ) ; <nl> + Dependencies : : PathsPortFile paths_port_file ( paths ) ; <nl> auto install_plan = Dependencies : : create_install_plan ( <nl> paths_port_file , Util : : fmap ( specs , [ ] ( auto & & spec ) { return spec . package_spec ; } ) , status_db ) ; <nl> <nl> namespace vcpkg : : Install <nl> <nl> for ( auto & & action : action_plan ) <nl> { <nl> - if ( auto p_install = action . install_action . get ( ) ) <nl> + if ( auto p_install = action . install_plan . get ( ) ) <nl> { <nl> p_install - > build_options = install_plan_options ; <nl> if ( p_install - > request_type ! = RequestType : : USER_REQUESTED ) <nl> namespace vcpkg : : Install <nl> <nl> / / log the plan <nl> const std : : string specs_string = Strings : : join ( " , " , action_plan , [ ] ( const AnyAction & action ) { <nl> - if ( auto iaction = action . install_action . get ( ) ) <nl> + if ( auto iaction = action . install_plan . get ( ) ) <nl> return iaction - > spec . to_string ( ) ; <nl> - else if ( auto raction = action . remove_action . get ( ) ) <nl> + else if ( auto raction = action . remove_plan . get ( ) ) <nl> return " R $ " + raction - > spec . to_string ( ) ; <nl> Checks : : unreachable ( VCPKG_LINE_INFO ) ; <nl> } ) ; <nl> <nl> Metrics : : g_metrics . lock ( ) - > track_property ( " installplan " , specs_string ) ; <nl> <nl> - Dependencies : : print_plan ( action_plan , is_recursive ) ; <nl> + print_plan ( action_plan , is_recursive ) ; <nl> <nl> if ( dry_run ) <nl> { <nl> namespace vcpkg : : Install <nl> for ( auto & & result : summary . results ) <nl> { <nl> if ( ! result . action ) continue ; <nl> - if ( auto p_install_action = result . action - > install_action . get ( ) ) <nl> + if ( auto p_install_action = result . action - > install_plan . get ( ) ) <nl> { <nl> if ( p_install_action - > request_type ! = RequestType : : USER_REQUESTED ) continue ; <nl> auto bpgh = result . get_binary_paragraph ( ) ; <nl> namespace vcpkg : : Install <nl> { <nl> if ( build_result . binary_control_file ) return & build_result . binary_control_file - > core_paragraph ; <nl> if ( action ) <nl> - if ( auto p_install_plan = action - > install_action . get ( ) ) <nl> + if ( auto p_install_plan = action - > install_plan . get ( ) ) <nl> { <nl> if ( auto p_bcf = p_install_plan - > any_paragraph . binary_control_file . get ( ) ) <nl> return & p_bcf - > core_paragraph ; <nl> mmm a / toolsrc / src / vcpkg / paragraphs . cpp <nl> ppp b / toolsrc / src / vcpkg / paragraphs . cpp <nl> namespace vcpkg : : Paragraphs <nl> } <nl> return std : : move ( results . paragraphs ) ; <nl> } <nl> + <nl> + std : : map < std : : string , VersionT > load_all_port_names_and_versions ( const Files : : Filesystem & fs , <nl> + const fs : : path & ports_dir ) <nl> + { <nl> + auto all_ports = load_all_ports ( fs , ports_dir ) ; <nl> + <nl> + std : : map < std : : string , VersionT > names_and_versions ; <nl> + for ( auto & & port : all_ports ) <nl> + names_and_versions . emplace ( port - > core_paragraph - > name , port - > core_paragraph - > version ) ; <nl> + <nl> + return names_and_versions ; <nl> + } <nl> } <nl> mmm a / toolsrc / src / vcpkg / remove . cpp <nl> ppp b / toolsrc / src / vcpkg / remove . cpp <nl> namespace vcpkg : : Remove <nl> System : : println ( System : : Color : : error , " Error : ' remove ' accepts either libraries or ' - - outdated ' " ) ; <nl> Checks : : exit_fail ( VCPKG_LINE_INFO ) ; <nl> } <nl> - <nl> - Dependencies : : PathsPortFileProvider provider ( paths ) ; <nl> - <nl> - specs = Util : : fmap ( Update : : find_outdated_packages ( provider , status_db ) , <nl> - [ ] ( auto & & outdated ) { return outdated . spec ; } ) ; <nl> + specs = Util : : fmap ( <nl> + Update : : find_outdated_packages ( <nl> + Paragraphs : : load_all_port_names_and_versions ( paths . get_filesystem ( ) , paths . ports ) , status_db ) , <nl> + [ ] ( auto & & outdated ) { return outdated . spec ; } ) ; <nl> <nl> if ( specs . empty ( ) ) <nl> { <nl> mmm a / toolsrc / src / vcpkg / update . cpp <nl> ppp b / toolsrc / src / vcpkg / update . cpp <nl> namespace vcpkg : : Update <nl> return left . spec . name ( ) < right . spec . name ( ) ; <nl> } <nl> <nl> - std : : vector < OutdatedPackage > find_outdated_packages ( const Dependencies : : PortFileProvider & provider , <nl> + std : : vector < OutdatedPackage > find_outdated_packages ( const std : : map < std : : string , VersionT > & src_names_to_versions , <nl> const StatusParagraphs & status_db ) <nl> { <nl> const std : : vector < StatusParagraph * > installed_packages = get_installed_ports ( status_db ) ; <nl> namespace vcpkg : : Update <nl> { <nl> if ( ! pgh - > package . feature . empty ( ) ) <nl> { <nl> - / / Skip feature paragraphs ; only consider master paragraphs for needing updates . <nl> + / / Skip feature packages ; only consider master packages for needing updates . <nl> continue ; <nl> } <nl> <nl> - auto maybe_scf = provider . get_control_file ( pgh - > package . spec . name ( ) ) ; <nl> - if ( auto p_scf = maybe_scf . get ( ) ) <nl> + const auto it = src_names_to_versions . find ( pgh - > package . spec . name ( ) ) ; <nl> + if ( it = = src_names_to_versions . end ( ) ) <nl> { <nl> - auto & & port_version = p_scf - > core_paragraph - > version ; <nl> - auto & & installed_version = pgh - > package . version ; <nl> - if ( installed_version ! = port_version ) <nl> - { <nl> - output . push_back ( { pgh - > package . spec , VersionDiff ( installed_version , port_version ) } ) ; <nl> - } <nl> + / / Package was not installed from portfile <nl> + continue ; <nl> } <nl> - else <nl> + if ( it - > second ! = pgh - > package . version ) <nl> { <nl> - / / No portfile available <nl> + output . push_back ( { pgh - > package . spec , VersionDiff ( pgh - > package . version , it - > second ) } ) ; <nl> } <nl> } <nl> <nl> namespace vcpkg : : Update <nl> <nl> const StatusParagraphs status_db = database_load_check ( paths ) ; <nl> <nl> - Dependencies : : PathsPortFileProvider provider ( paths ) ; <nl> - <nl> - const auto outdated_packages = SortedVector < OutdatedPackage > ( find_outdated_packages ( provider , status_db ) , <nl> - & OutdatedPackage : : compare_by_name ) ; <nl> + const auto outdated_packages = SortedVector < OutdatedPackage > ( <nl> + find_outdated_packages ( Paragraphs : : load_all_port_names_and_versions ( paths . get_filesystem ( ) , paths . ports ) , <nl> + status_db ) , <nl> + & OutdatedPackage : : compare_by_name ) ; <nl> <nl> if ( outdated_packages . empty ( ) ) <nl> { <nl> namespace vcpkg : : Update <nl> } <nl> else <nl> { <nl> + std : : string install_line ; <nl> System : : println ( " The following packages differ from their port versions : " ) ; <nl> for ( auto & & package : outdated_packages ) <nl> { <nl> + install_line + = package . spec . to_string ( ) ; <nl> + install_line + = " " ; <nl> System : : println ( " % - 32s % s " , package . spec , package . version_diff . to_string ( ) ) ; <nl> } <nl> System : : println ( " \ n " <nl> - " To update these packages and all dependencies , run \ n " <nl> - " . \ \ vcpkg upgrade \ n " <nl> - " \ n " <nl> - " To only remove outdated packages , run \ n " <nl> - " . \ \ vcpkg remove - - outdated \ n " ) ; <nl> + " To update these packages , run \ n " <nl> + " . \ \ vcpkg remove - - outdated \ n " <nl> + " . \ \ vcpkg install " + <nl> + install_line ) ; <nl> } <nl> <nl> Checks : : exit_success ( VCPKG_LINE_INFO ) ; <nl> mmm a / toolsrc / vcpkglib / vcpkglib . vcxproj <nl> ppp b / toolsrc / vcpkglib / vcpkglib . vcxproj <nl> <nl> < ClInclude Include = " . . \ include \ vcpkg \ versiont . h " / > <nl> < / ItemGroup > <nl> < ItemGroup > <nl> - < ClCompile Include = " . . \ src \ commands . upgrade . cpp " / > <nl> < ClCompile Include = " . . \ src \ pch . cpp " > <nl> < PrecompiledHeader Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | Win32 ' " > Create < / PrecompiledHeader > <nl> < PrecompiledHeader Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Release | Win32 ' " > Create < / PrecompiledHeader > <nl> mmm a / toolsrc / vcpkglib / vcpkglib . vcxproj . filters <nl> ppp b / toolsrc / vcpkglib / vcpkglib . vcxproj . filters <nl> <nl> < ClCompile Include = " . . \ src \ vcpkg \ userconfig . cpp " > <nl> < Filter > Source Files \ vcpkg < / Filter > <nl> < / ClCompile > <nl> - < ClCompile Include = " . . \ src \ commands . upgrade . cpp " > <nl> - < Filter > Source Files \ vcpkg < / Filter > <nl> - < / ClCompile > <nl> < / ItemGroup > <nl> < ItemGroup > <nl> < ClInclude Include = " . . \ include \ pch . h " > <nl>
Revert " [ vcpkg - upgrade ] Initial commit of upgrade command . "
microsoft/vcpkg
7a6ffdc75c6634e0df3c158e871426190511a096
2017-12-13T12:48:13Z
mmm a / tests / queries / 0_stateless / 01600_quota_by_forwarded_ip . sh <nl> ppp b / tests / queries / 0_stateless / 01600_quota_by_forwarded_ip . sh <nl> $ { CLICKHOUSE_CURL } - H ' X - Forwarded - For : 1 . 2 . 3 . 4 ' - sS " $ { CLICKHOUSE_URL } & user = quo <nl> $ { CLICKHOUSE_CURL } - H ' X - Forwarded - For : 5 . 6 . 7 . 8 , 1 . 2 . 3 . 4 ' - sS " $ { CLICKHOUSE_URL } & user = quoted_by_forwarded_ip " - d " SELECT count ( ) FROM numbers ( 10 ) " | grep - oF ' exceeded ' <nl> <nl> $ { CLICKHOUSE_CURL } - H ' X - Forwarded - For : 1 . 2 . 3 . 4 , 5 . 6 . 7 . 8 ' - sS " $ { CLICKHOUSE_URL } & user = quoted_by_forwarded_ip " - d " SELECT count ( ) FROM numbers ( 10 ) " <nl> + <nl> + $ CLICKHOUSE_CLIENT - n - - query " <nl> + DROP QUOTA IF EXISTS quota_by_ip ; <nl> + DROP QUOTA IF EXISTS quota_by_forwarded_ip ; <nl> + <nl> + DROP USER IF EXISTS quoted_by_ip ; <nl> + DROP USER IF EXISTS quoted_by_forwarded_ip ; <nl> + " <nl>
Better test
ClickHouse/ClickHouse
d92606d362560b4e1aa2c0194c73907d4ba8c2da
2020-12-03T20:23:09Z
mmm a / src / app / widget_loader . cpp <nl> ppp b / src / app / widget_loader . cpp <nl> void WidgetLoader : : fillWidgetWithXmlElementAttributes ( const TiXmlElement * elem , <nl> else if ( strcmp ( tooltip_dir , " right " ) = = 0 ) dir = RIGHT ; <nl> } <nl> <nl> - m_tooltipManager - > addTooltipFor ( widget , m_xmlTranslator ( elem , " tooltip " ) , dir ) ; <nl> + Widget * widgetWithTooltip ; <nl> + if ( widget - > type ( ) = = ui : : kComboBoxWidget ) <nl> + widgetWithTooltip = static_cast < ComboBox * > ( widget ) - > getEntryWidget ( ) ; <nl> + else <nl> + widgetWithTooltip = widget ; <nl> + m_tooltipManager - > addTooltipFor ( widgetWithTooltip , m_xmlTranslator ( elem , " tooltip " ) , dir ) ; <nl> } <nl> <nl> if ( selected ) <nl>
Fix loading tooltips for comboboxes
aseprite/aseprite
f375ced8834d41002cbc13c9f1c5161d3afd8c98
2019-10-22T23:31:06Z
mmm a / cocos2dx / platform / mac / CCCommon . mm <nl> ppp b / cocos2dx / platform / mac / CCCommon . mm <nl> void CCLog ( const char * pszFormat , . . . ) <nl> <nl> void CCLuaLog ( const char * pszFormat ) <nl> { <nl> - CCLog ( pszFormat ) ; <nl> + CCLog ( " % s " , pszFormat ) ; <nl> } <nl> <nl> / / ios no MessageBox , use CCLog instead <nl> mmm a / cocos2dx / platform / mac / CCDirectorCaller . mm <nl> ppp b / cocos2dx / platform / mac / CCDirectorCaller . mm <nl> - ( void ) alloc <nl> - ( void ) dealloc <nl> { <nl> s_sharedDirectorCaller = nil ; <nl> - NSLog ( @ " cocos2d : deallocing CCDirectorCaller % @ " , self ) ; <nl> + CCLOG ( " cocos2d : deallocing CCDirectorCaller % x " , ( unsigned int ) self ) ; <nl> if ( displayLink ) { <nl> CVDisplayLinkRelease ( displayLink ) ; <nl> } <nl> + <nl> + CCLOG ( " mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - " ) ; <nl> + CCLOG ( " " ) ; <nl> + CCLOG ( " " ) ; <nl> + CCLOG ( " " ) ; <nl> [ super dealloc ] ; <nl> } <nl> <nl>
[ Mac ] fix CCLuaLog crash
cocos2d/cocos2d-x
4aa74d8f5e2688a3e71cb58acc1a44fee85b013d
2012-09-13T02:26:47Z
mmm a / modules / gapi / src / api / gbackend . cpp <nl> ppp b / modules / gapi / src / api / gbackend . cpp <nl> void bindInArg ( Mag & mag , const RcDesc & rc , const GRunArg & arg , bool is_umat ) <nl> case GRunArg : : index_of < cv : : gapi : : own : : Mat > ( ) : <nl> if ( is_umat ) <nl> { <nl> + # if ! defined ( GAPI_STANDALONE ) <nl> auto & mag_umat = mag . template slot < cv : : UMat > ( ) [ rc . id ] ; <nl> mag_umat = to_ocv ( util : : get < cv : : gapi : : own : : Mat > ( arg ) ) . getUMat ( ACCESS_READ ) ; <nl> + # else <nl> + util : : throw_error ( std : : logic_error ( " UMat is not supported in stadnalone build " ) ) ; <nl> + # endif / / ! defined ( GAPI_STANDALONE ) <nl> } <nl> else <nl> { <nl> void bindOutArg ( Mag & mag , const RcDesc & rc , const GRunArgP & arg , bool is_umat ) <nl> case GRunArgP : : index_of < cv : : gapi : : own : : Mat * > ( ) : <nl> if ( is_umat ) <nl> { <nl> + # if ! defined ( GAPI_STANDALONE ) <nl> auto & mag_umat = mag . template slot < cv : : UMat > ( ) [ rc . id ] ; <nl> mag_umat = to_ocv ( * ( util : : get < cv : : gapi : : own : : Mat * > ( arg ) ) ) . getUMat ( ACCESS_RW ) ; <nl> + # else <nl> + util : : throw_error ( std : : logic_error ( " UMat is not supported in standalone build " ) ) ; <nl> + # endif / / ! defined ( GAPI_STANDALONE ) <nl> } <nl> else <nl> { <nl> cv : : GRunArgP getObjPtr ( Mag & mag , const RcDesc & rc , bool is_umat ) <nl> { <nl> case GShape : : GMAT : <nl> if ( is_umat ) <nl> + { <nl> + # if ! defined ( GAPI_STANDALONE ) <nl> return GRunArgP ( & mag . template slot < cv : : UMat > ( ) [ rc . id ] ) ; <nl> + # else <nl> + util : : throw_error ( std : : logic_error ( " UMat is not supported in standalone build " ) ) ; <nl> + # endif / / ! defined ( GAPI_STANDALONE ) <nl> + } <nl> else <nl> return GRunArgP ( & mag . template slot < cv : : gapi : : own : : Mat > ( ) [ rc . id ] ) ; <nl> case GShape : : GSCALAR : return GRunArgP ( & mag . template slot < cv : : gapi : : own : : Scalar > ( ) [ rc . id ] ) ; <nl> void writeBack ( const Mag & mag , const RcDesc & rc , GRunArgP & g_arg , bool is_umat ) <nl> } <nl> if ( is_umat ) <nl> { <nl> + # if ! defined ( GAPI_STANDALONE ) <nl> auto & in_mag = mag . template slot < cv : : UMat > ( ) . at ( rc . id ) ; <nl> GAPI_Assert ( ( out_arg_data = = ( in_mag . getMat ( ACCESS_RW ) . data ) ) & & " data for output parameters was reallocated ? " ) ; <nl> + # else <nl> + util : : throw_error ( std : : logic_error ( " UMat is not supported in standalone build " ) ) ; <nl> + # endif / / ! defined ( GAPI_STANDALONE ) <nl> } <nl> else <nl> { <nl>
G - API : Recent inclusion has broken STANDALONE build
opencv/opencv
1b13df53685dca7451a82abeac775f7747b317c1
2018-11-20T11:00:08Z
mmm a / hphp / util / tiny - vector . h <nl> ppp b / hphp / util / tiny - vector . h <nl> namespace HPHP { <nl> * in that case . ( Unless you want the first element to remain <nl> * accessible inline instead of moved to the heap . ) <nl> * / <nl> - template < class T , size_t InternalSize = 1 , size_t MinHeapCapacity = 0 > <nl> + <nl> + / / Allocator interface to control how TinyVector allocates memory . It would be <nl> + / / nice if it could use the standard allocator interface . However , it expects to <nl> + / / allocate raw memory of N bytes , while the standard allocator interface <nl> + / / allocates N instances of type T . <nl> + template < typename T > struct TinyVectorMallocAllocator { <nl> + template < typename U > struct rebind { <nl> + using type = TinyVectorMallocAllocator < U > ; <nl> + } ; <nl> + <nl> + void * allocate ( std : : size_t size ) const { return malloc ( size ) ; } <nl> + void deallocate ( void * ptr ) const { free ( ptr ) ; } <nl> + std : : size_t usable_size ( void * ptr , std : : size_t size ) const { <nl> + return malloc_usable_size ( ptr ) ; <nl> + } <nl> + } ; <nl> + <nl> + template < class T , <nl> + size_t InternalSize = 1 , <nl> + size_t MinHeapCapacity = 0 , <nl> + typename OrigAllocator = TinyVectorMallocAllocator < T > > <nl> struct TinyVector { <nl> struct const_iterator ; <nl> <nl> struct TinyVector { <nl> TinyVector ( const TinyVector & ) = delete ; <nl> TinyVector & operator = ( const TinyVector & ) = delete ; <nl> <nl> - size_t size ( ) const { return m_data . size ( ) ; } <nl> + size_t size ( ) const { return m_impl . m_data . size ( ) ; } <nl> bool empty ( ) const { return ! size ( ) ; } <nl> <nl> const_iterator begin ( ) const { return const_iterator ( this , 0 ) ; } <nl> struct TinyVector { <nl> } <nl> <nl> void clear ( ) { <nl> - if ( HeapData * p = m_data . ptr ( ) ) { <nl> - free ( p ) ; <nl> + if ( HeapData * p = m_impl . m_data . ptr ( ) ) { <nl> + m_impl . deallocate ( p ) ; <nl> } <nl> - m_data . set ( 0 , 0 ) ; <nl> + m_impl . m_data . set ( 0 , 0 ) ; <nl> } <nl> <nl> void push_back ( const T & t ) { <nl> struct TinyVector { <nl> T & alloc_back ( ) { <nl> size_t current = size ( ) ; <nl> reserve ( current + 1 ) ; <nl> - m_data . set ( current + 1 , m_data . ptr ( ) ) ; <nl> + m_impl . m_data . set ( current + 1 , m_impl . m_data . ptr ( ) ) ; <nl> return back ( ) ; <nl> } <nl> <nl> void pop_back ( ) { <nl> assert ( ! empty ( ) ) ; <nl> - m_data . set ( size ( ) - 1 , m_data . ptr ( ) ) ; <nl> + m_impl . m_data . set ( size ( ) - 1 , m_impl . m_data . ptr ( ) ) ; <nl> } <nl> <nl> T & back ( ) { <nl> struct TinyVector { <nl> <nl> T & front ( ) { <nl> assert ( ! empty ( ) ) ; <nl> - return m_vals [ 0 ] ; <nl> + return m_impl . m_vals [ 0 ] ; <nl> } <nl> <nl> const T & front ( ) const { <nl> assert ( ! empty ( ) ) ; <nl> - return m_vals [ 0 ] ; <nl> + return m_impl . m_vals [ 0 ] ; <nl> } <nl> <nl> void reserve ( size_t sz ) { <nl> if ( sz < InternalSize ) return ; <nl> <nl> - const size_t currentHeap = m_data . ptr ( ) ? m_data . ptr ( ) - > capacity : 0 ; <nl> + const size_t currentHeap = <nl> + m_impl . m_data . ptr ( ) ? m_impl . m_data . ptr ( ) - > capacity : 0 ; <nl> const size_t neededHeap = sz - InternalSize ; <nl> if ( neededHeap < = currentHeap ) { <nl> return ; <nl> struct TinyVector { <nl> currentHeap ? currentHeap * 4 / 3 <nl> : std : : max ( neededHeap , MinHeapCapacity ) , <nl> neededHeap ) ; <nl> - HeapData * newHeap = static_cast < HeapData * > ( <nl> - malloc ( sizeof ( HeapData ) + sizeof ( T ) * newCapacity ) ) ; <nl> - newHeap - > capacity = ( malloc_usable_size ( newHeap ) - <nl> + const size_t requested = sizeof ( HeapData ) + sizeof ( T ) * newCapacity ; <nl> + HeapData * newHeap = static_cast < HeapData * > ( m_impl . allocate ( requested ) ) ; <nl> + newHeap - > capacity = ( m_impl . usable_size ( newHeap , requested ) - <nl> offsetof ( HeapData , vals ) ) / sizeof ( T ) ; <nl> <nl> - std : : copy ( & m_data . ptr ( ) - > vals [ 0 ] , <nl> - & m_data . ptr ( ) - > vals [ size ( ) - InternalSize ] , <nl> + std : : copy ( & m_impl . m_data . ptr ( ) - > vals [ 0 ] , <nl> + & m_impl . m_data . ptr ( ) - > vals [ size ( ) - InternalSize ] , <nl> & newHeap - > vals [ 0 ] ) ; <nl> - free ( m_data . ptr ( ) ) ; <nl> - m_data . set ( size ( ) , newHeap ) ; <nl> + m_impl . deallocate ( m_impl . m_data . ptr ( ) ) ; <nl> + m_impl . m_data . set ( size ( ) , newHeap ) ; <nl> } <nl> <nl> private : <nl> struct TinyVector { <nl> } ; <nl> <nl> T * location ( size_t index ) { <nl> - return index < InternalSize ? & m_vals [ index ] <nl> - : & m_data . ptr ( ) - > vals [ index - InternalSize ] ; <nl> + return index < InternalSize ? <nl> + & m_impl . m_vals [ index ] <nl> + : & m_impl . m_data . ptr ( ) - > vals [ index - InternalSize ] ; <nl> } <nl> <nl> private : <nl> - CompactSizedPtr < HeapData > m_data ; <nl> - T m_vals [ InternalSize ] ; <nl> + using Allocator = typename OrigAllocator : : template rebind < HeapData > : : type ; <nl> + struct Impl : Allocator { <nl> + CompactSizedPtr < HeapData > m_data ; <nl> + T m_vals [ InternalSize ] ; <nl> + } ; <nl> + Impl m_impl ; <nl> } ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - template < class T , size_t InternalSize , size_t MinHeapCapacity > <nl> - struct TinyVector < T , InternalSize , MinHeapCapacity > : : const_iterator <nl> + template < class T , <nl> + size_t InternalSize , <nl> + size_t MinHeapCapacity , <nl> + typename Allocator > <nl> + struct TinyVector < T , InternalSize , MinHeapCapacity , Allocator > : : const_iterator <nl> : boost : : iterator_facade < const_iterator , <nl> const T , <nl> boost : : forward_traversal_tag > <nl>
Make TinyVector memory allocation a template parameter
facebook/hhvm
1d95265901ab8895af27c78da06aaa7faf9bb299
2016-02-25T22:00:49Z
mmm a / Code / CryEngine / RenderDll / Common / Renderer . cpp <nl> ppp b / Code / CryEngine / RenderDll / Common / Renderer . cpp <nl> IDynTextureSource * CRenderer : : EF_LoadDynTexture ( const char * dynsourceName , bool <nl> <nl> bool SShaderItem : : Update ( ) <nl> { <nl> - if ( ! ( m_pShader - > GetFlags ( ) & EF_LOADED ) ) <nl> + if ( ! m_pShader | | ! ( m_pShader - > GetFlags ( ) & EF_LOADED ) ) <nl> return false ; <nl> if ( ( uint32 ) m_nTechnique > 1000 & & m_nTechnique ! = - 1 ) / / HACK HACK HACK <nl> { <nl> mmm a / Code / Sandbox / Plugins / MeshImporter / MainDialog . cpp <nl> ppp b / Code / Sandbox / Plugins / MeshImporter / MainDialog . cpp <nl> static bool FinalizeMesh ( CMesh * pMesh , const char * & szError ) <nl> return pMesh - > Validate ( & szError ) ; <nl> } <nl> <nl> - static SShaderItem SetBumpMap ( const SShaderItem & shaderItem ) <nl> - { <nl> - SInputShaderResources * inputShaderResources = gEnv - > pRenderer - > EF_CreateInputShaderResource ( shaderItem . m_pShaderResources ) ; <nl> - <nl> - const EEfResTextures texId = MaterialHelpers : : FindTexSlot ( " Bumpmap " ) ; <nl> - inputShaderResources - > m_Textures [ texId ] . m_Name = " Objects / pbs_reference / gloss0_ddna . tif " ; <nl> - <nl> - const char * const szShaderName = shaderItem . m_pShader - > GetName ( ) ; <nl> - const uint64 shaderGenMask = shaderItem . m_pShader - > GetGenerationMask ( ) ; <nl> - <nl> - SShaderItem newShaderItem = gEnv - > pRenderer - > EF_LoadShaderItem ( <nl> - szShaderName , false , 0 , inputShaderResources , shaderGenMask ) ; <nl> - <nl> - gEnv - > pRenderer - > UpdateShaderItem ( & newShaderItem , NULL ) ; <nl> - <nl> - return newShaderItem ; <nl> - } <nl> - <nl> void CMainDialog : : AssignScene ( const MeshImporter : : SImportScenePayload * pPayload ) <nl> { <nl> m_bMaterialNameWasRelative = false ; <nl> void CMainDialog : : AssignScene ( const MeshImporter : : SImportScenePayload * pPayload ) <nl> for ( int i = 0 ; i < materialCount ; + + i ) <nl> { <nl> m_materials [ i ] = pMaterialManager - > CloneMaterial ( pReferenceMaterial ) ; <nl> - <nl> - const EEfResTextures texId = MaterialHelpers : : FindTexSlot ( " Bumpmap " ) ; <nl> - <nl> - SShaderItem shaderItem = SetBumpMap ( m_materials [ i ] - > GetShaderItem ( ) ) ; <nl> - m_materials [ i ] - > AssignShaderItem ( shaderItem ) ; <nl> } <nl> <nl> / / Create uber - materials . <nl>
! XB ( Sandbox ) ( CE - 15172 ) FBX : Using FBX Import mesh freezes editor
CRYTEK/CRYENGINE
34409d394f9c6367964f05023b9f166c075abf50
2018-01-26T14:30:44Z
mmm a / lib / SILOptimizer / SILCombiner / SILCombinerApplyVisitors . cpp <nl> ppp b / lib / SILOptimizer / SILCombiner / SILCombinerApplyVisitors . cpp <nl> SILCombiner : : buildConcreteOpenedExistentialInfoFromSoleConformingType ( <nl> ( archetypeTy - > getConformsTo ( ) . size ( ) = = 1 ) ) { <nl> PD = archetypeTy - > getConformsTo ( ) [ 0 ] ; <nl> } else if ( ArgType . isExistentialType ( ) & & ! ArgType . isAnyObject ( ) & & <nl> - ! SwiftArgType - > isAny ( ) & & SwiftArgType - > getAnyNominal ( ) ) { <nl> - PD = dyn_cast < ProtocolDecl > ( SwiftArgType - > getAnyNominal ( ) ) ; <nl> + ! SwiftArgType - > isAny ( ) ) { <nl> + PD = dyn_cast_or_null < ProtocolDecl > ( SwiftArgType - > getAnyNominal ( ) ) ; <nl> } <nl> } <nl> <nl> mmm a / validation - test / compiler_crashers_2_fixed / sr11624 . swift <nl> ppp b / validation - test / compiler_crashers_2_fixed / sr11624 . swift <nl> <nl> / / See https : / / swift . org / LICENSE . txt for license information <nl> / / See https : / / swift . org / CONTRIBUTORS . txt for the list of Swift project authors <nl> <nl> - / / RUN : not % target - swift - frontend % s - O - whole - module - optimization <nl> + / / RUN : % target - swift - frontend % s - O - whole - module - optimization - emit - sil <nl> <nl> class ClassA < T > { } <nl> protocol ProtocolA { } <nl>
SILCombine cleanup ; replace null check with dyn_cast_or_null .
apple/swift
fd6497bbc7c38b211c3d52c0f690ba4195d77641
2019-11-02T04:36:35Z
mmm a / tensorflow / compiler / xla / service / buffer_assignment . cc <nl> ppp b / tensorflow / compiler / xla / service / buffer_assignment . cc <nl> using : : tensorflow : : strings : : HumanReadableNumBytes ; <nl> using : : tensorflow : : strings : : Printf ; <nl> using : : tensorflow : : strings : : StrAppend ; <nl> <nl> + namespace { <nl> + <nl> + template < typename T > <nl> + string ColocatedBufferSetsToString ( const T & container , const char * title ) { <nl> + string result ; <nl> + StrAppend ( & result , title , " \ n " ) ; <nl> + for ( const auto & it : container ) { <nl> + StrAppend ( & result , " \ t " , it - > ToString ( ) , " \ n " ) ; <nl> + } <nl> + return result ; <nl> + } <nl> + <nl> + / / Walk the call graph of the HLO module and place each computation into either <nl> + / / thread_local_computations or global_computations depending upon whether the <nl> + / / computation requires thread - local allocations or global allocations . The <nl> + / / elements in thread_local_computations and global_computations are in post <nl> + / / order ( if computation A has an instruction which calls computation B , then A <nl> + / / will appear after B in the vector ) . <nl> + Status GatherComputationsByAllocationType ( <nl> + const HloModule * module , <nl> + std : : vector < const HloComputation * > * thread_local_computations , <nl> + std : : vector < const HloComputation * > * global_computations ) { <nl> + / / Create a worklist of computations paired with whether the allocation must <nl> + / / be thread - local . <nl> + std : : deque < std : : pair < const HloComputation * , bool > > worklist ; <nl> + worklist . push_back ( std : : make_pair ( module - > entry_computation ( ) , <nl> + / * is_thread_local * / false ) ) ; <nl> + <nl> + / / Sets for quickly checking membership . Computations are returned in vectors <nl> + / / for stable iteration . <nl> + FlatSet < const HloComputation * > thread_local_set ; <nl> + FlatSet < const HloComputation * > global_set ; <nl> + <nl> + while ( ! worklist . empty ( ) ) { <nl> + auto worklist_front = worklist . front ( ) ; <nl> + worklist . pop_front ( ) ; <nl> + const HloComputation * computation = worklist_front . first ; <nl> + bool is_thread_local = worklist_front . second ; <nl> + bool in_thread_local_set = thread_local_set . count ( computation ) > 0 ; <nl> + bool in_global_set = global_set . count ( computation ) > 0 ; <nl> + <nl> + / / If the computation has already been added to the respective set , then <nl> + / / nothing to do . <nl> + if ( ( is_thread_local & & in_thread_local_set ) | | <nl> + ( ! is_thread_local & & in_global_set ) ) { <nl> + continue ; <nl> + } <nl> + <nl> + / / If the computation has already been added to the other set this is an <nl> + / / error condition because the global call to the computation ( eg , <nl> + / / while / call ) may return a reference to one of the thread - local buffers to <nl> + / / the calling computation which will become a dangling reference when the <nl> + / / thread - local is deallocated with the call return . <nl> + if ( ( is_thread_local & & in_global_set ) | | <nl> + ( ! is_thread_local & & in_thread_local_set ) ) { <nl> + return InvalidArgument ( <nl> + " computation % s has conflicting allocation requirements ( global " <nl> + " and thread - local ) " , <nl> + computation - > name ( ) . c_str ( ) ) ; <nl> + } <nl> + <nl> + if ( is_thread_local ) { <nl> + thread_local_set . insert ( computation ) ; <nl> + } else { <nl> + global_set . insert ( computation ) ; <nl> + } <nl> + <nl> + for ( auto * instruction : computation - > instructions ( ) ) { <nl> + for ( HloComputation * subcomputation : <nl> + instruction - > called_computations ( ) ) { <nl> + switch ( instruction - > opcode ( ) ) { <nl> + case HloOpcode : : kCall : <nl> + case HloOpcode : : kConditional : <nl> + case HloOpcode : : kWhile : <nl> + / / Call and while must be called from a computation with global <nl> + / / allocations as they may return references to buffers inside the <nl> + / / called computation which cannot be thread - local . <nl> + if ( is_thread_local ) { <nl> + return InvalidArgument ( <nl> + " computation % s cannot contain call / while op because it " <nl> + " requires thread - local buffer allocations " , <nl> + computation - > name ( ) . c_str ( ) ) ; <nl> + } <nl> + worklist . push_back ( std : : make_pair ( subcomputation , <nl> + false ) ) ; / / Not thread local . <nl> + break ; <nl> + case HloOpcode : : kMap : <nl> + case HloOpcode : : kReduce : <nl> + case HloOpcode : : kReduceWindow : <nl> + case HloOpcode : : kSelectAndScatter : <nl> + case HloOpcode : : kFusion : <nl> + / / Map / reduce etc computations are always thread - local . <nl> + worklist . push_back ( std : : make_pair ( subcomputation , <nl> + true ) ) ; / / Thread local . <nl> + break ; <nl> + default : <nl> + return InternalError ( <nl> + " Unexpected calling opcode : % s " , <nl> + HloOpcodeString ( instruction - > opcode ( ) ) . c_str ( ) ) ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + <nl> + / / Add the computations to the vectors in post order . <nl> + for ( auto * computation : module - > MakeComputationPostOrder ( ) ) { <nl> + if ( thread_local_set . count ( computation ) > 0 ) { <nl> + thread_local_computations - > push_back ( computation ) ; <nl> + } else if ( global_set . count ( computation ) > 0 ) { <nl> + global_computations - > push_back ( computation ) ; <nl> + } <nl> + / / If the computation is not reachable from the entry computation , then it <nl> + / / will not appear in either thread_local_set or global_set . We don ' t bother <nl> + / / assigning buffers for these . <nl> + } <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + / / Checks that points - to set of ' instruction ' is unambiguous and distinct <nl> + / / ( ensured by CopyInsertion ) , then adds the buffer from the points - to set at <nl> + / / ' index ' to ' colocated_set ' . <nl> + const LogicalBuffer * AddBufferToColocatedSet ( <nl> + const HloInstruction * instruction , const ShapeIndex & index , <nl> + const TuplePointsToAnalysis & points_to_analysis , <nl> + std : : vector < const LogicalBuffer * > * colocated_set ) { <nl> + / / CopyInsertion ensures root points - to set is unambiguous and distinct . <nl> + const auto & points_to = points_to_analysis . GetPointsToSet ( instruction ) ; <nl> + DCHECK ( ! points_to . IsAmbiguous ( ) ) ; <nl> + colocated_set - > push_back ( points_to . element ( index ) [ 0 ] ) ; <nl> + return colocated_set - > back ( ) ; <nl> + } <nl> + <nl> + / / Given the interference map of a graph ( the list of interfering node indices <nl> + / / for each node ) , perform graph coloring such that interfering nodes are <nl> + / / assigned to different colors . Returns the assigned color of the nodes , where <nl> + / / the colors are represented as integer values [ 0 , color_count ) . <nl> + std : : vector < int64 > ColorInterferenceGraph ( <nl> + const std : : vector < std : : vector < int64 > > & interference_map ) { <nl> + const int64 node_count = interference_map . size ( ) ; <nl> + <nl> + / / Sort the nodes such that we assign nodes with more interference first . This <nl> + / / relies on the common heuristic of assigning the most constrained node <nl> + / / first , but it would be good to investigate other ordering heuristics too . <nl> + std : : vector < int64 > nodes ( node_count ) ; <nl> + std : : iota ( nodes . begin ( ) , nodes . end ( ) , 0 ) ; <nl> + std : : sort ( nodes . begin ( ) , nodes . end ( ) , <nl> + [ & interference_map ] ( const int64 i , const int64 j ) { <nl> + return interference_map [ i ] . size ( ) > interference_map [ j ] . size ( ) ; <nl> + } ) ; <nl> + <nl> + const int64 kColorUnassigned = - 1 ; <nl> + std : : vector < int64 > assigned_colors ( node_count , kColorUnassigned ) ; <nl> + for ( int64 node : nodes ) { <nl> + / / Mark the colors that are already assigned to the neighbors . <nl> + std : : vector < bool > available_colors ( node_count , true ) ; <nl> + for ( int64 neighbor : interference_map [ node ] ) { <nl> + int64 color = assigned_colors [ neighbor ] ; <nl> + if ( color ! = kColorUnassigned ) { <nl> + available_colors [ color ] = false ; <nl> + } <nl> + } <nl> + <nl> + / / Find the color that is not yet assigned to the neighbors . <nl> + int64 color = kColorUnassigned ; <nl> + for ( color = 0 ; color < available_colors . size ( ) ; + + color ) { <nl> + if ( available_colors [ color ] ) { <nl> + break ; <nl> + } <nl> + } <nl> + CHECK_NE ( color , kColorUnassigned ) ; <nl> + assigned_colors [ node ] = color ; <nl> + } <nl> + return assigned_colors ; <nl> + } <nl> + <nl> + } / / namespace <nl> + <nl> size_t BufferAllocation : : Slice : : Hasher : : operator ( ) ( Slice s ) const { <nl> uint64 h = std : : hash < int64 > ( ) ( s . index ( ) ) ; <nl> h = tensorflow : : Hash64Combine ( h , std : : hash < int64 > ( ) ( s . offset ( ) ) ) ; <nl> BufferAssignmentProto BufferAssignment : : ToProto ( ) const { <nl> return proto ; <nl> } <nl> <nl> - namespace { <nl> - <nl> - / / Walk the call graph of the HLO module and place each computation into either <nl> - / / thread_local_computations or global_computations depending upon whether the <nl> - / / computation requires thread - local allocations or global allocations . The <nl> - / / elements in thread_local_computations and global_computations are in post <nl> - / / order ( if computation A has an instruction which calls computation B , then A <nl> - / / will appear after B in the vector ) . <nl> - Status GatherComputationsByAllocationType ( <nl> - const HloModule * module , <nl> - std : : vector < const HloComputation * > * thread_local_computations , <nl> - std : : vector < const HloComputation * > * global_computations ) { <nl> - / / Create a worklist of computations paired with whether the allocation must <nl> - / / be thread - local . <nl> - std : : deque < std : : pair < const HloComputation * , bool > > worklist ; <nl> - worklist . push_back ( std : : make_pair ( module - > entry_computation ( ) , <nl> - / * is_thread_local * / false ) ) ; <nl> - <nl> - / / Sets for quickly checking membership . Computations are returned in vectors <nl> - / / for stable iteration . <nl> - FlatSet < const HloComputation * > thread_local_set ; <nl> - FlatSet < const HloComputation * > global_set ; <nl> - <nl> - while ( ! worklist . empty ( ) ) { <nl> - auto worklist_front = worklist . front ( ) ; <nl> - worklist . pop_front ( ) ; <nl> - const HloComputation * computation = worklist_front . first ; <nl> - bool is_thread_local = worklist_front . second ; <nl> - bool in_thread_local_set = thread_local_set . count ( computation ) > 0 ; <nl> - bool in_global_set = global_set . count ( computation ) > 0 ; <nl> - <nl> - / / If the computation has already been added to the respective set , then <nl> - / / nothing to do . <nl> - if ( ( is_thread_local & & in_thread_local_set ) | | <nl> - ( ! is_thread_local & & in_global_set ) ) { <nl> - continue ; <nl> - } <nl> - <nl> - / / If the computation has already been added to the other set this is an <nl> - / / error condition because the global call to the computation ( eg , <nl> - / / while / call ) may return a reference to one of the thread - local buffers to <nl> - / / the calling computation which will become a dangling reference when the <nl> - / / thread - local is deallocated with the call return . <nl> - if ( ( is_thread_local & & in_global_set ) | | <nl> - ( ! is_thread_local & & in_thread_local_set ) ) { <nl> - return InvalidArgument ( <nl> - " computation % s has conflicting allocation requirements ( global " <nl> - " and thread - local ) " , <nl> - computation - > name ( ) . c_str ( ) ) ; <nl> - } <nl> - <nl> - if ( is_thread_local ) { <nl> - thread_local_set . insert ( computation ) ; <nl> - } else { <nl> - global_set . insert ( computation ) ; <nl> - } <nl> - <nl> - for ( auto * instruction : computation - > instructions ( ) ) { <nl> - for ( HloComputation * subcomputation : <nl> - instruction - > called_computations ( ) ) { <nl> - switch ( instruction - > opcode ( ) ) { <nl> - case HloOpcode : : kCall : <nl> - case HloOpcode : : kConditional : <nl> - case HloOpcode : : kWhile : <nl> - / / Call and while must be called from a computation with global <nl> - / / allocations as they may return references to buffers inside the <nl> - / / called computation which cannot be thread - local . <nl> - if ( is_thread_local ) { <nl> - return InvalidArgument ( <nl> - " computation % s cannot contain call / while op because it " <nl> - " requires thread - local buffer allocations " , <nl> - computation - > name ( ) . c_str ( ) ) ; <nl> - } <nl> - worklist . push_back ( std : : make_pair ( subcomputation , <nl> - false ) ) ; / / Not thread local . <nl> - break ; <nl> - case HloOpcode : : kMap : <nl> - case HloOpcode : : kReduce : <nl> - case HloOpcode : : kReduceWindow : <nl> - case HloOpcode : : kSelectAndScatter : <nl> - case HloOpcode : : kFusion : <nl> - / / Map / reduce etc computations are always thread - local . <nl> - worklist . push_back ( std : : make_pair ( subcomputation , <nl> - true ) ) ; / / Thread local . <nl> - break ; <nl> - default : <nl> - return InternalError ( <nl> - " Unexpected calling opcode : % s " , <nl> - HloOpcodeString ( instruction - > opcode ( ) ) . c_str ( ) ) ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - <nl> - / / Add the computations to the vectors in post order . <nl> - for ( auto * computation : module - > MakeComputationPostOrder ( ) ) { <nl> - if ( thread_local_set . count ( computation ) > 0 ) { <nl> - thread_local_computations - > push_back ( computation ) ; <nl> - } else if ( global_set . count ( computation ) > 0 ) { <nl> - global_computations - > push_back ( computation ) ; <nl> - } <nl> - / / If the computation is not reachable from the entry computation , then it <nl> - / / will not appear in either thread_local_set or global_set . We don ' t bother <nl> - / / assigning buffers for these . <nl> - } <nl> - return Status : : OK ( ) ; <nl> - } <nl> - <nl> - } / / namespace <nl> - <nl> / * static * / <nl> StatusOr < std : : unique_ptr < BufferAssignment > > BufferAssigner : : Run ( <nl> const HloModule * module , std : : unique_ptr < HloOrdering > hlo_ordering , <nl> void BufferAssigner : : AddSetToColocatedBufferSets ( <nl> if ( colocated_set . empty ( ) ) { <nl> return ; <nl> } <nl> - <nl> + VLOG ( 5 ) < < ColocatedBufferSetsToString ( colocated_set , <nl> + " Adding colocated buffer set " ) ; <nl> / / Find existing sets that overlap with at least one buffer from the <nl> / / colocated_set . The resulting ' overlap_set_indices ' will have at most <nl> / / colocated_buffer_sets - > size ( ) entries , and will be in increasing order . <nl> void BufferAssigner : : AddSetToColocatedBufferSets ( <nl> for ( size_t index = 0 ; index < colocated_buffer_sets - > size ( ) ; + + index ) { <nl> for ( const LogicalBuffer * buffer : colocated_set ) { <nl> if ( ( * colocated_buffer_sets ) [ index ] . count ( buffer ) > 0 ) { <nl> + VLOG ( 5 ) < < " Found overlap with existing set on buffer " <nl> + < < buffer - > ToString ( ) < < " \ n " <nl> + < < ColocatedBufferSetsToString ( ( * colocated_buffer_sets ) [ index ] , <nl> + " Overlapping set " ) ; <nl> overlap_set_indices . push_back ( index ) ; <nl> break ; <nl> } <nl> void BufferAssigner : : AddSetToColocatedBufferSets ( <nl> colocated_buffer_sets - > emplace_back ( ) ; <nl> colocated_buffer_sets - > back ( ) . insert ( colocated_set . begin ( ) , <nl> colocated_set . end ( ) ) ; <nl> + VLOG ( 5 ) < < " No overlap found , new group created " ; <nl> return ; <nl> } <nl> <nl> void BufferAssigner : : AddSetToColocatedBufferSets ( <nl> first - > insert ( overlap_set . begin ( ) , overlap_set . end ( ) ) ; <nl> } <nl> first - > insert ( colocated_set . begin ( ) , colocated_set . end ( ) ) ; <nl> + VLOG ( 5 ) < < ColocatedBufferSetsToString ( <nl> + * first , " Result of the colocated buffer set merging " ) ; <nl> <nl> / / Remove overlap sets that we just merged . The offset accounts for the fact <nl> / / that as elements are erased , the indices need to be adjusted . Keep in mind <nl> void BufferAssigner : : AddSetToColocatedBufferSets ( <nl> } <nl> } <nl> <nl> - namespace { <nl> - <nl> - / / Checks that points - to set of ' instruction ' is unambiguous and distinct <nl> - / / ( ensured by CopyInsertion ) , then adds the buffer from the points - to set at <nl> - / / ' index ' to ' colocated_set ' . <nl> - const LogicalBuffer * AddBufferToColocatedSet ( <nl> - const HloInstruction * instruction , const ShapeIndex & index , <nl> - const TuplePointsToAnalysis & points_to_analysis , <nl> - std : : vector < const LogicalBuffer * > * colocated_set ) { <nl> - / / CopyInsertion ensures root points - to set is unambiguous and distinct . <nl> - const auto & points_to = points_to_analysis . GetPointsToSet ( instruction ) ; <nl> - DCHECK ( ! points_to . IsAmbiguous ( ) ) ; <nl> - colocated_set - > push_back ( points_to . element ( index ) [ 0 ] ) ; <nl> - return colocated_set - > back ( ) ; <nl> - } <nl> - <nl> - / / Given the interference map of a graph ( the list of interfering node indices <nl> - / / for each node ) , perform graph coloring such that interfering nodes are <nl> - / / assigned to different colors . Returns the assigned color of the nodes , where <nl> - / / the colors are represented as integer values [ 0 , color_count ) . <nl> - std : : vector < int64 > ColorInterferenceGraph ( <nl> - const std : : vector < std : : vector < int64 > > & interference_map ) { <nl> - const int64 node_count = interference_map . size ( ) ; <nl> - <nl> - / / Sort the nodes such that we assign nodes with more interference first . This <nl> - / / relies on the common heuristic of assigning the most constrained node <nl> - / / first , but it would be good to investigate other ordering heuristics too . <nl> - std : : vector < int64 > nodes ( node_count ) ; <nl> - std : : iota ( nodes . begin ( ) , nodes . end ( ) , 0 ) ; <nl> - std : : sort ( nodes . begin ( ) , nodes . end ( ) , <nl> - [ & interference_map ] ( const int64 i , const int64 j ) { <nl> - return interference_map [ i ] . size ( ) > interference_map [ j ] . size ( ) ; <nl> - } ) ; <nl> - <nl> - const int64 kColorUnassigned = - 1 ; <nl> - std : : vector < int64 > assigned_colors ( node_count , kColorUnassigned ) ; <nl> - for ( int64 node : nodes ) { <nl> - / / Mark the colors that are already assigned to the neighbors . <nl> - std : : vector < bool > available_colors ( node_count , true ) ; <nl> - for ( int64 neighbor : interference_map [ node ] ) { <nl> - int64 color = assigned_colors [ neighbor ] ; <nl> - if ( color ! = kColorUnassigned ) { <nl> - available_colors [ color ] = false ; <nl> - } <nl> - } <nl> - <nl> - / / Find the color that is not yet assigned to the neighbors . <nl> - int64 color = kColorUnassigned ; <nl> - for ( color = 0 ; color < available_colors . size ( ) ; + + color ) { <nl> - if ( available_colors [ color ] ) { <nl> - break ; <nl> - } <nl> - } <nl> - CHECK_NE ( color , kColorUnassigned ) ; <nl> - assigned_colors [ node ] = color ; <nl> - } <nl> - return assigned_colors ; <nl> - } <nl> - <nl> - } / / namespace <nl> - <nl> std : : vector < BufferAssigner : : ColocatedBufferSet > <nl> BufferAssigner : : MergeColocatedBufferSets ( <nl> const std : : vector < ColocatedBufferSet > & colocated_buffer_sets , <nl> mmm a / tensorflow / compiler / xla / service / copy_insertion . cc <nl> ppp b / tensorflow / compiler / xla / service / copy_insertion . cc <nl> bool ValueIsReadOnly ( const HloValue & value ) { <nl> return IsConstantValue ( value ) | | IsEntryParameterValue ( value ) ; <nl> } <nl> <nl> + / / Data structure describing the action which should be taken on parts of a <nl> + / / computation buffers , with respect to the adding of special case copies . <nl> + struct SpecialCaseCopyPolicy { <nl> + / / Insert a copy if the same buffer is found at multiple indices within the <nl> + / / output tuple . <nl> + bool copy_root_replicated_buffers = false ; <nl> + / / If true , insert a copy if a buffer coming from a constant or a parameter <nl> + / / is found wihtin the output tuple . <nl> + bool copy_parameters_and_constants = false ; <nl> + } ; <nl> + <nl> + SpecialCaseCopyPolicy GetSpecialCaseCopyPolicy ( const CallGraphNode & node , <nl> + HloModule * module , <nl> + HloComputation * computation ) { <nl> + SpecialCaseCopyPolicy policy ; <nl> + if ( computation = = module - > entry_computation ( ) ) { <nl> + policy . copy_parameters_and_constants = true ; <nl> + policy . copy_root_replicated_buffers = true ; <nl> + } <nl> + for ( const CallSite & site : node . caller_callsites ( ) ) { <nl> + / / The kWhile instruction does not have an handling here , as the <nl> + / / AddCopiesForWhile ( ) API takes care of adding its own copies . <nl> + if ( site . instruction ( ) - > opcode ( ) = = HloOpcode : : kConditional ) { <nl> + policy . copy_parameters_and_constants = true ; <nl> + policy . copy_root_replicated_buffers = true ; <nl> + } <nl> + } <nl> + return policy ; <nl> + } <nl> + <nl> + bool ShouldCopyRootValue ( const HloValue & value , <nl> + const SpecialCaseCopyPolicy & policy ) { <nl> + if ( policy . copy_parameters_and_constants ) { <nl> + return IsConstantValue ( value ) | | <nl> + value . defining_instruction ( ) - > opcode ( ) = = HloOpcode : : kParameter ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> / / Deep copy the given instructions ' from ' and ' to ' at the ShapeIndexes given in <nl> / / ' indices_to_copy ' . Add control edges from the respective kCopy instructions <nl> / / in deep copy of ' from ' to the respective kCopy instruction in the deep copy <nl> Status AddSpecialCaseCopies ( const CallGraph & call_graph , HloModule * module ) { <nl> } <nl> TF_RET_CHECK ( node . context ( ) = = CallContext : : kSequential ) ; <nl> <nl> - const bool is_entry = computation = = module - > entry_computation ( ) ; <nl> + SpecialCaseCopyPolicy policy = <nl> + GetSpecialCaseCopyPolicy ( node , module , computation ) ; <nl> HloInstruction * root = computation - > root_instruction ( ) ; <nl> <nl> / / Mark nondistinct / ambiguous indices . <nl> Status AddSpecialCaseCopies ( const CallGraph & call_graph , HloModule * module ) { <nl> for ( const HloBuffer * buffer : buffers_at_index ) { <nl> buffer_seen_before | = ! seen . insert ( buffer ) . second ; <nl> } <nl> - if ( buffers_at_index . size ( ) > 1 | | ( buffer_seen_before & & is_entry ) ) { <nl> - VLOG ( 2 ) < < " Index " < < index < < " of root of computation " <nl> + if ( buffers_at_index . size ( ) > 1 | | <nl> + ( buffer_seen_before & & policy . copy_root_replicated_buffers ) ) { <nl> + VLOG ( 2 ) < < " Index " < < index < < " of computation " <nl> < < computation - > name ( ) < < " ( " < < root - > name ( ) <nl> < < " ) has ambiguous or non - distinct buffer . Copying . " ; <nl> add_index_to_copy ( root , index ) ; <nl> } <nl> } ) ; <nl> <nl> - / / For entry instructions , mark any parameter or constant values . <nl> - if ( is_entry ) { <nl> - for ( const auto & pair : <nl> - alias_analysis - > dataflow_analysis ( ) . GetInstructionValueSet ( root ) ) { <nl> - const ShapeIndex & index = pair . first ; <nl> - const HloValueSet & value_set = pair . second ; <nl> - for ( const HloValue * value : value_set . values ( ) ) { <nl> - if ( ValueIsReadOnly ( * value ) ) { <nl> - VLOG ( 2 ) < < " Root of entry computation ( " < < root - > name ( ) <nl> - < < " ) has constant or entry parameter value at index " <nl> - < < index < < " . Copying . " ; <nl> - add_index_to_copy ( root , index ) ; <nl> - } <nl> + for ( const auto & pair : <nl> + alias_analysis - > dataflow_analysis ( ) . GetInstructionValueSet ( root ) ) { <nl> + const ShapeIndex & index = pair . first ; <nl> + const HloValueSet & value_set = pair . second ; <nl> + for ( const HloValue * value : value_set . values ( ) ) { <nl> + if ( ShouldCopyRootValue ( * value , policy ) ) { <nl> + VLOG ( 2 ) < < " Root of ( " < < root - > name ( ) < < " ) of computation ( " <nl> + < < computation - > name ( ) <nl> + < < " ) has constant or parameter value at index " < < index <nl> + < < " . Copying . " ; <nl> + add_index_to_copy ( root , index ) ; <nl> } <nl> } <nl> } <nl> Status AddSpecialCaseCopies ( const CallGraph & call_graph , HloModule * module ) { <nl> instruction - > parent ( ) - > set_root_instruction ( deep_copy ) ; <nl> } <nl> } <nl> - <nl> return Status : : OK ( ) ; <nl> } <nl> <nl>
Fix buffer assignment for conditional instruction .
tensorflow/tensorflow
cb0984df5549c077621049416f69b914635208ce
2018-02-27T22:33:33Z
mmm a / filament / src / driver / CommandBufferQueue . cpp <nl> ppp b / filament / src / driver / CommandBufferQueue . cpp <nl> void CommandBufferQueue : : flush ( ) noexcept { <nl> } <nl> <nl> std : : vector < CommandBufferQueue : : Slice > CommandBufferQueue : : waitForCommands ( ) const { <nl> - if ( UTILS_HAS_THREADING ) { <nl> - std : : unique_lock < utils : : Mutex > lock ( mLock ) ; <nl> - while ( mCommandBuffersToExecute . empty ( ) & & ! mExitRequested ) { <nl> - mCondition . wait ( lock ) ; <nl> - } <nl> + if ( ! UTILS_HAS_THREADING ) { <nl> + return std : : move ( mCommandBuffersToExecute ) ; <nl> + } <nl> + std : : unique_lock < utils : : Mutex > lock ( mLock ) ; <nl> + while ( mCommandBuffersToExecute . empty ( ) & & ! mExitRequested ) { <nl> + mCondition . wait ( lock ) ; <nl> } <nl> return std : : move ( mCommandBuffersToExecute ) ; <nl> } <nl>
Fix mutex lifetime in waitForCommands .
google/filament
155aa443884f9506987c28af6156c7e9a998e6fe
2018-08-27T15:51:46Z
mmm a / buildscripts / cpplint . py <nl> ppp b / buildscripts / cpplint . py <nl> def ProcessFile ( filename , vlevel , extra_check_functions = [ ] ) : <nl> ' One or more unexpected \ \ r ( ^ M ) found ; ' <nl> ' better to use only a \ \ n ' ) <nl> <nl> - sys . stderr . write ( ' Done processing % s \ n ' % filename ) <nl> + # sys . stderr . write ( ' Done processing % s \ n ' % filename ) <nl> <nl> <nl> def PrintUsage ( message ) : <nl>
try turning off " Done " for each file so we can see failures more easily
mongodb/mongo
317272e1fee6d932c084df930f46fb2c669c1988
2012-10-16T14:35:38Z
mmm a / modules / gpu / include / opencv2 / gpu / gpu . hpp <nl> ppp b / modules / gpu / include / opencv2 / gpu / gpu . hpp <nl> namespace cv <nl> <nl> HOGDescriptor ( Size win_size = Size ( 64 , 128 ) , Size block_size = Size ( 16 , 16 ) , <nl> Size block_stride = Size ( 8 , 8 ) , Size cell_size = Size ( 8 , 8 ) , <nl> - bool gamma_correction = true , int nbins = 9 , double win_sigma = DEFAULT_WIN_SIGMA , <nl> - double threshold_L2hys = 0 . 2 , int nlevels = DEFAULT_NLEVELS ) ; <nl> + int nbins = 9 , double win_sigma = DEFAULT_WIN_SIGMA , <nl> + double threshold_L2hys = 0 . 2 , bool gamma_correction = true , <nl> + int nlevels = DEFAULT_NLEVELS ) ; <nl> <nl> size_t getDescriptorSize ( ) const ; <nl> size_t getBlockHistogramSize ( ) const ; <nl> double getWinSigma ( ) const ; <nl> <nl> static vector < float > getDefaultPeopleDetector ( ) ; <nl> - static vector < float > getDefaultPeopleDetector_64x128 ( ) ; <nl> + static vector < float > getPeopleDetector_48x96 ( ) ; <nl> + static vector < float > getPeopleDetector_64x128 ( ) ; <nl> void setSVMDetector ( const vector < float > & detector ) ; <nl> bool checkDetectorSize ( ) const ; <nl> <nl> namespace cv <nl> Size block_size ; <nl> Size block_stride ; <nl> Size cell_size ; <nl> - bool gamma_correction ; <nl> int nbins ; <nl> double win_sigma ; <nl> double threshold_L2hys ; <nl> + bool gamma_correction ; <nl> int nlevels ; <nl> <nl> / / Coefficients of the separating plane <nl> mmm a / modules / gpu / src / hog . cpp <nl> ppp b / modules / gpu / src / hog . cpp <nl> <nl> <nl> # if ! defined ( HAVE_CUDA ) <nl> <nl> - cv : : gpu : : HOGDescriptor : : HOGDescriptor ( Size , Size , Size , Size , bool , int , double , double , int ) { throw_nogpu ( ) ; } <nl> + cv : : gpu : : HOGDescriptor : : HOGDescriptor ( Size , Size , Size , Size , int , double , double , bool , int ) { throw_nogpu ( ) ; } <nl> size_t cv : : gpu : : HOGDescriptor : : getDescriptorSize ( ) const { throw_nogpu ( ) ; return 0 ; } <nl> size_t cv : : gpu : : HOGDescriptor : : getBlockHistogramSize ( ) const { throw_nogpu ( ) ; return 0 ; } <nl> double cv : : gpu : : HOGDescriptor : : getWinSigma ( ) const { throw_nogpu ( ) ; return 0 ; } <nl> void cv : : gpu : : HOGDescriptor : : detectMultiScale ( const GpuMat & , vector < Rect > & , doub <nl> int cv : : gpu : : HOGDescriptor : : numPartsWithin ( int , int , int ) { throw_nogpu ( ) ; return 0 ; } <nl> cv : : Size cv : : gpu : : HOGDescriptor : : numPartsWithin ( cv : : Size , cv : : Size , cv : : Size ) { throw_nogpu ( ) ; return cv : : Size ( ) ; } <nl> std : : vector < float > cv : : gpu : : HOGDescriptor : : getDefaultPeopleDetector ( ) { throw_nogpu ( ) ; return std : : vector < float > ( ) ; } <nl> - std : : vector < float > cv : : gpu : : HOGDescriptor : : getDefaultPeopleDetector_64x128 ( ) { throw_nogpu ( ) ; return std : : vector < float > ( ) ; } <nl> + std : : vector < float > cv : : gpu : : HOGDescriptor : : getPeopleDetector_48x96 ( ) { throw_nogpu ( ) ; return std : : vector < float > ( ) ; } <nl> + std : : vector < float > cv : : gpu : : HOGDescriptor : : getPeopleDetector_64x128 ( ) { throw_nogpu ( ) ; return std : : vector < float > ( ) ; } <nl> <nl> # else <nl> <nl> void resize_8UC4 ( const cv : : gpu : : DevMem2D & src , cv : : gpu : : DevMem2D dst ) ; <nl> <nl> <nl> cv : : gpu : : HOGDescriptor : : HOGDescriptor ( Size win_size , Size block_size , Size block_stride , <nl> - Size cell_size , bool gamma_correction , int nbins , <nl> - double win_sigma , double threshold_L2hys , int nlevels ) <nl> + Size cell_size , int nbins , double win_sigma , double threshold_L2hys , <nl> + bool gamma_correction , int nlevels ) <nl> : win_size ( win_size ) , <nl> block_size ( block_size ) , <nl> block_stride ( block_stride ) , <nl> cell_size ( cell_size ) , <nl> - gamma_correction ( gamma_correction ) , <nl> nbins ( nbins ) , <nl> win_sigma ( win_sigma ) , <nl> threshold_L2hys ( threshold_L2hys ) , <nl> + gamma_correction ( gamma_correction ) , <nl> nlevels ( nlevels ) <nl> { <nl> CV_Assert ( ( win_size . width - block_size . width ) % block_stride . width = = 0 & & <nl> cv : : Size cv : : gpu : : HOGDescriptor : : numPartsWithin ( cv : : Size size , cv : : Size part_siz <nl> <nl> std : : vector < float > cv : : gpu : : HOGDescriptor : : getDefaultPeopleDetector ( ) <nl> { <nl> - return getDefaultPeopleDetector_64x128 ( ) ; <nl> + return getPeopleDetector_64x128 ( ) ; <nl> } <nl> <nl> - std : : vector < float > cv : : gpu : : HOGDescriptor : : getDefaultPeopleDetector_64x128 ( ) <nl> + <nl> + std : : vector < float > cv : : gpu : : HOGDescriptor : : getPeopleDetector_48x96 ( ) <nl> + { <nl> + static const float detector [ ] = { <nl> + 0 . 294350f , - 0 . 098796f , - 0 . 129522f , 0 . 078753f , 0 . 387527f , 0 . 261529f , <nl> + 0 . 145939f , 0 . 061520f , 0 . 328699f , 0 . 227148f , - 0 . 066467f , - 0 . 086723f , <nl> + 0 . 047559f , 0 . 106714f , 0 . 037897f , 0 . 111461f , - 0 . 024406f , 0 . 304769f , <nl> + 0 . 254676f , - 0 . 069235f , 0 . 082566f , 0 . 147260f , 0 . 326969f , 0 . 148888f , <nl> + 0 . 055270f , - 0 . 087985f , 0 . 261720f , 0 . 143442f , 0 . 026812f , 0 . 238212f , <nl> + 0 . 194020f , 0 . 056341f , - 0 . 025854f , - 0 . 034444f , - 0 . 156631f , 0 . 205174f , <nl> + 0 . 089008f , - 0 . 139811f , - 0 . 100147f , - 0 . 037830f , - 0 . 029230f , - 0 . 055641f , <nl> + 0 . 033248f , - 0 . 016512f , 0 . 155244f , 0 . 247315f , - 0 . 124694f , - 0 . 048414f , <nl> + - 0 . 062219f , 0 . 193683f , 0 . 004574f , 0 . 055089f , 0 . 093565f , 0 . 167712f , <nl> + 0 . 167581f , 0 . 018895f , 0 . 215258f , 0 . 122609f , 0 . 090520f , - 0 . 067219f , <nl> + - 0 . 049029f , - 0 . 099615f , 0 . 241804f , - 0 . 094893f , - 0 . 176248f , 0 . 001727f , <nl> + - 0 . 134473f , 0 . 104442f , 0 . 050942f , 0 . 081165f , 0 . 072156f , 0 . 121646f , <nl> + 0 . 002656f , - 0 . 297974f , - 0 . 133587f , - 0 . 060121f , - 0 . 092515f , - 0 . 048974f , <nl> + - 0 . 084754f , - 0 . 180111f , - 0 . 038590f , 0 . 086283f , - 0 . 134636f , - 0 . 107249f , <nl> + 0 . 132890f , 0 . 141556f , 0 . 249425f , 0 . 130273f , - 0 . 030031f , 0 . 073212f , <nl> + - 0 . 008155f , 0 . 019931f , 0 . 071688f , 0 . 000300f , - 0 . 019525f , - 0 . 021725f , <nl> + - 0 . 040993f , - 0 . 086841f , 0 . 070124f , 0 . 240033f , 0 . 265350f , 0 . 043208f , <nl> + 0 . 166754f , 0 . 091453f , 0 . 060916f , - 0 . 036972f , - 0 . 091043f , 0 . 079873f , <nl> + 0 . 219781f , 0 . 158102f , - 0 . 140618f , - 0 . 043016f , 0 . 124802f , 0 . 093668f , <nl> + 0 . 103208f , 0 . 094872f , 0 . 080541f , 0 . 137711f , 0 . 160566f , - 0 . 169231f , <nl> + 0 . 013983f , 0 . 309508f , - 0 . 004217f , - 0 . 057200f , - 0 . 064489f , 0 . 014066f , <nl> + 0 . 361009f , 0 . 251328f , - 0 . 080983f , - 0 . 044183f , 0 . 061436f , - 0 . 037381f , <nl> + - 0 . 078786f , 0 . 030993f , 0 . 066314f , 0 . 037683f , 0 . 152325f , - 0 . 091683f , <nl> + 0 . 070203f , 0 . 217856f , 0 . 036435f , - 0 . 076462f , 0 . 006254f , - 0 . 094431f , <nl> + 0 . 154829f , - 0 . 023038f , - 0 . 196961f , - 0 . 024594f , 0 . 178465f , - 0 . 050139f , <nl> + - 0 . 045932f , - 0 . 000965f , 0 . 109112f , 0 . 046165f , - 0 . 159373f , - 0 . 008713f , <nl> + 0 . 041307f , 0 . 097129f , - 0 . 057211f , - 0 . 064599f , 0 . 077165f , 0 . 176167f , <nl> + 0 . 138322f , 0 . 065753f , - 0 . 104950f , 0 . 017933f , 0 . 136255f , - 0 . 011598f , <nl> + 0 . 047007f , 0 . 080550f , 0 . 068619f , 0 . 084661f , - 0 . 035493f , - 0 . 091314f , <nl> + - 0 . 041411f , 0 . 060971f , - 0 . 101912f , - 0 . 079870f , - 0 . 085977f , - 0 . 022686f , <nl> + 0 . 079788f , - 0 . 098064f , - 0 . 054603f , 0 . 040383f , 0 . 300794f , 0 . 128603f , <nl> + 0 . 094844f , 0 . 047407f , 0 . 101825f , 0 . 061832f , - 0 . 162160f , - 0 . 204553f , <nl> + - 0 . 035165f , 0 . 101450f , - 0 . 016641f , - 0 . 027140f , - 0 . 134392f , - 0 . 008743f , <nl> + 0 . 102331f , 0 . 114853f , 0 . 009644f , 0 . 062823f , 0 . 237339f , 0 . 167843f , <nl> + 0 . 053066f , - 0 . 012592f , 0 . 043158f , 0 . 002305f , 0 . 065001f , - 0 . 038929f , <nl> + - 0 . 020356f , 0 . 152343f , 0 . 043469f , - 0 . 029967f , - 0 . 042948f , 0 . 032481f , <nl> + 0 . 068488f , - 0 . 110840f , - 0 . 111083f , 0 . 111980f , - 0 . 002072f , - 0 . 005562f , <nl> + 0 . 082926f , 0 . 006635f , - 0 . 108153f , 0 . 024242f , - 0 . 086464f , - 0 . 189884f , <nl> + - 0 . 017492f , 0 . 191456f , - 0 . 007683f , - 0 . 128769f , - 0 . 038017f , - 0 . 132380f , <nl> + 0 . 091926f , 0 . 079696f , - 0 . 106728f , - 0 . 007656f , 0 . 172744f , 0 . 011576f , <nl> + 0 . 009883f , 0 . 083258f , - 0 . 026516f , 0 . 145534f , 0 . 153924f , - 0 . 130290f , <nl> + - 0 . 108945f , 0 . 124490f , - 0 . 003186f , - 0 . 100485f , 0 . 015024f , - 0 . 060512f , <nl> + 0 . 026288f , - 0 . 086713f , - 0 . 169012f , 0 . 076517f , 0 . 215778f , 0 . 043701f , <nl> + - 0 . 131642f , - 0 . 012585f , - 0 . 045181f , - 0 . 118183f , - 0 . 241544f , - 0 . 167293f , <nl> + - 0 . 020107f , - 0 . 019917f , - 0 . 101827f , - 0 . 107096f , - 0 . 010503f , 0 . 044938f , <nl> + 0 . 189680f , 0 . 217119f , - 0 . 046086f , 0 . 044508f , 0 . 199716f , - 0 . 036004f , <nl> + - 0 . 148927f , 0 . 013355f , - 0 . 078279f , 0 . 030451f , 0 . 056301f , - 0 . 024609f , <nl> + 0 . 083224f , 0 . 099533f , - 0 . 039432f , - 0 . 138880f , 0 . 005482f , - 0 . 024120f , <nl> + - 0 . 140468f , - 0 . 066381f , - 0 . 017057f , 0 . 009260f , - 0 . 058004f , - 0 . 028486f , <nl> + - 0 . 061610f , 0 . 007483f , - 0 . 158309f , - 0 . 150687f , - 0 . 044595f , - 0 . 105121f , <nl> + - 0 . 045763f , - 0 . 006618f , - 0 . 024419f , - 0 . 117713f , - 0 . 119366f , - 0 . 175941f , <nl> + - 0 . 071542f , 0 . 119027f , 0 . 111362f , 0 . 043080f , 0 . 034889f , 0 . 093003f , <nl> + 0 . 007842f , 0 . 057368f , - 0 . 108834f , - 0 . 079968f , 0 . 230959f , 0 . 020205f , <nl> + 0 . 011470f , 0 . 098877f , 0 . 101310f , - 0 . 030215f , - 0 . 018018f , - 0 . 059552f , <nl> + - 0 . 106157f , 0 . 021866f , - 0 . 036471f , 0 . 080051f , 0 . 041165f , - 0 . 082101f , <nl> + 0 . 117726f , 0 . 030961f , - 0 . 054763f , - 0 . 084102f , - 0 . 185778f , - 0 . 061305f , <nl> + - 0 . 038089f , - 0 . 110728f , - 0 . 264010f , 0 . 076675f , - 0 . 077111f , - 0 . 137644f , <nl> + 0 . 036232f , 0 . 277995f , 0 . 019116f , 0 . 107738f , 0 . 144003f , 0 . 080304f , <nl> + 0 . 215036f , 0 . 228897f , 0 . 072713f , 0 . 077773f , 0 . 120168f , 0 . 075324f , <nl> + 0 . 062730f , 0 . 122478f , - 0 . 049008f , 0 . 164912f , 0 . 162450f , 0 . 041246f , <nl> + 0 . 009891f , - 0 . 097827f , - 0 . 038700f , - 0 . 023027f , - 0 . 120020f , 0 . 203364f , <nl> + 0 . 248474f , 0 . 149810f , - 0 . 036276f , - 0 . 082814f , - 0 . 090343f , - 0 . 027143f , <nl> + - 0 . 075689f , - 0 . 320310f , - 0 . 000500f , - 0 . 143334f , - 0 . 065077f , - 0 . 186936f , <nl> + 0 . 129372f , 0 . 116431f , 0 . 181699f , 0 . 170436f , 0 . 418854f , 0 . 460045f , <nl> + 0 . 333719f , 0 . 230515f , 0 . 047822f , - 0 . 044954f , - 0 . 068086f , 0 . 140179f , <nl> + - 0 . 044821f , 0 . 085550f , 0 . 092483f , - 0 . 107296f , - 0 . 130670f , - 0 . 206629f , <nl> + 0 . 114601f , - 0 . 317869f , - 0 . 076663f , 0 . 038680f , 0 . 212753f , - 0 . 016059f , <nl> + - 0 . 126526f , - 0 . 163602f , 0 . 210154f , 0 . 099887f , - 0 . 126366f , 0 . 118453f , <nl> + 0 . 019309f , - 0 . 021611f , - 0 . 096499f , - 0 . 111809f , - 0 . 200489f , 0 . 142854f , <nl> + 0 . 228840f , - 0 . 353346f , - 0 . 179151f , 0 . 116834f , 0 . 252389f , - 0 . 031728f , <nl> + - 0 . 188135f , - 0 . 158998f , 0 . 386523f , 0 . 122315f , 0 . 209944f , 0 . 394023f , <nl> + 0 . 359030f , 0 . 260717f , 0 . 170335f , 0 . 013683f , - 0 . 142596f , - 0 . 026138f , <nl> + - 0 . 011878f , - 0 . 150519f , 0 . 047159f , - 0 . 107062f , - 0 . 147347f , - 0 . 187689f , <nl> + - 0 . 186027f , - 0 . 208048f , 0 . 058468f , - 0 . 073026f , - 0 . 236556f , - 0 . 079788f , <nl> + - 0 . 146216f , - 0 . 058563f , - 0 . 101361f , - 0 . 071294f , - 0 . 071093f , 0 . 116919f , <nl> + 0 . 234304f , 0 . 306781f , 0 . 321866f , 0 . 240000f , 0 . 073261f , - 0 . 012173f , <nl> + 0 . 026479f , 0 . 050173f , 0 . 166127f , 0 . 228955f , 0 . 061905f , 0 . 156460f , <nl> + 0 . 205990f , 0 . 120672f , 0 . 037350f , 0 . 167884f , 0 . 290099f , 0 . 420900f , <nl> + - 0 . 012601f , 0 . 189839f , 0 . 306378f , 0 . 118383f , - 0 . 095598f , - 0 . 072360f , <nl> + - 0 . 132496f , - 0 . 224259f , - 0 . 126021f , 0 . 022714f , 0 . 284039f , 0 . 051369f , <nl> + - 0 . 000927f , - 0 . 058735f , - 0 . 083354f , - 0 . 141254f , - 0 . 187578f , - 0 . 202669f , <nl> + 0 . 048902f , 0 . 246597f , 0 . 441863f , 0 . 342519f , 0 . 066979f , 0 . 215286f , <nl> + 0 . 188191f , - 0 . 072240f , - 0 . 208142f , - 0 . 030196f , 0 . 178141f , 0 . 136985f , <nl> + - 0 . 043374f , - 0 . 181098f , 0 . 091815f , 0 . 116177f , - 0 . 126690f , - 0 . 386625f , <nl> + 0 . 368165f , 0 . 269149f , - 0 . 088042f , - 0 . 028823f , 0 . 092961f , 0 . 024099f , <nl> + 0 . 046112f , 0 . 176756f , 0 . 135849f , 0 . 124955f , 0 . 195467f , - 0 . 037218f , <nl> + 0 . 167217f , 0 . 188938f , 0 . 053528f , - 0 . 066561f , 0 . 133721f , - 0 . 070565f , <nl> + 0 . 115898f , 0 . 152435f , - 0 . 116993f , - 0 . 110592f , - 0 . 179005f , 0 . 026668f , <nl> + 0 . 080530f , 0 . 075084f , - 0 . 070401f , 0 . 012497f , 0 . 021849f , - 0 . 139764f , <nl> + - 0 . 022020f , - 0 . 096301f , - 0 . 064954f , - 0 . 127446f , - 0 . 013806f , - 0 . 108315f , <nl> + 0 . 156285f , 0 . 149867f , - 0 . 011382f , 0 . 064532f , 0 . 029168f , 0 . 027393f , <nl> + 0 . 069716f , 0 . 153735f , 0 . 038459f , 0 . 230714f , 0 . 253840f , 0 . 059522f , <nl> + - 0 . 045053f , 0 . 014083f , 0 . 071103f , 0 . 068747f , 0 . 095887f , 0 . 005832f , <nl> + 0 . 144887f , 0 . 026357f , - 0 . 067359f , - 0 . 044151f , - 0 . 123283f , - 0 . 019911f , <nl> + 0 . 005318f , 0 . 109208f , - 0 . 003201f , - 0 . 021734f , 0 . 142025f , - 0 . 066907f , <nl> + - 0 . 120070f , - 0 . 188639f , 0 . 012472f , - 0 . 048704f , - 0 . 012366f , - 0 . 184828f , <nl> + 0 . 168591f , 0 . 267166f , 0 . 058208f , - 0 . 044101f , 0 . 033500f , 0 . 178558f , <nl> + 0 . 104550f , 0 . 122418f , 0 . 080177f , 0 . 173246f , 0 . 298537f , 0 . 064173f , <nl> + 0 . 053397f , 0 . 174341f , 0 . 230984f , 0 . 117025f , 0 . 166242f , 0 . 227781f , <nl> + 0 . 120623f , 0 . 176952f , - 0 . 011393f , - 0 . 086483f , - 0 . 008270f , 0 . 051700f , <nl> + - 0 . 153369f , - 0 . 058837f , - 0 . 057639f , - 0 . 060115f , 0 . 026349f , - 0 . 160745f , <nl> + - 0 . 037894f , - 0 . 048575f , 0 . 041052f , - 0 . 022112f , 0 . 060365f , 0 . 051906f , <nl> + 0 . 162657f , 0 . 138519f , - 0 . 050185f , - 0 . 005938f , 0 . 071301f , 0 . 127686f , <nl> + 0 . 062342f , 0 . 144400f , 0 . 072600f , 0 . 198436f , 0 . 246219f , - 0 . 078185f , <nl> + - 0 . 036169f , 0 . 075934f , 0 . 047328f , - 0 . 013601f , 0 . 087205f , 0 . 019900f , <nl> + 0 . 022606f , - 0 . 015365f , - 0 . 092506f , 0 . 075275f , - 0 . 116375f , 0 . 050500f , <nl> + 0 . 045118f , 0 . 166567f , 0 . 072073f , 0 . 060371f , 0 . 131747f , - 0 . 169863f , <nl> + - 0 . 039352f , - 0 . 047486f , - 0 . 039797f , - 0 . 204312f , 0 . 021710f , 0 . 129443f , <nl> + - 0 . 021173f , 0 . 173416f , - 0 . 070794f , - 0 . 063986f , 0 . 069689f , - 0 . 064099f , <nl> + - 0 . 123201f , - 0 . 017372f , - 0 . 206870f , 0 . 065863f , 0 . 113226f , 0 . 024707f , <nl> + - 0 . 071341f , - 0 . 066964f , - 0 . 098278f , - 0 . 062927f , 0 . 075840f , 0 . 014716f , <nl> + 0 . 019378f , 0 . 132699f , - 0 . 074191f , - 0 . 089557f , - 0 . 078446f , - 0 . 197488f , <nl> + - 0 . 173665f , 0 . 052583f , 0 . 044361f , 0 . 113549f , 0 . 098492f , 0 . 077379f , <nl> + - 0 . 011146f , - 0 . 192593f , - 0 . 164435f , 0 . 045568f , 0 . 205699f , 0 . 049187f , <nl> + - 0 . 082281f , 0 . 134874f , 0 . 185499f , 0 . 034968f , - 0 . 119561f , - 0 . 112372f , <nl> + - 0 . 115091f , - 0 . 054042f , - 0 . 183816f , - 0 . 078100f , 0 . 190695f , 0 . 091617f , <nl> + 0 . 004257f , - 0 . 041135f , - 0 . 061453f , - 0 . 141592f , - 0 . 194809f , - 0 . 120638f , <nl> + 0 . 020168f , 0 . 109672f , 0 . 067398f , - 0 . 015238f , - 0 . 239145f , - 0 . 264671f , <nl> + - 0 . 185176f , 0 . 050472f , 0 . 020793f , 0 . 035678f , 0 . 022839f , - 0 . 052055f , <nl> + - 0 . 127968f , - 0 . 113049f , - 0 . 228416f , - 0 . 258281f , - 0 . 053437f , 0 . 076424f , <nl> + 0 . 061450f , 0 . 237478f , 0 . 003618f , - 0 . 055865f , - 0 . 108087f , - 0 . 028937f , <nl> + 0 . 045585f , 0 . 052829f , - 0 . 001471f , 0 . 022826f , 0 . 059565f , - 0 . 104430f , <nl> + - 0 . 077266f , - 0 . 211882f , - 0 . 212078f , 0 . 028074f , 0 . 075846f , 0 . 016265f , <nl> + 0 . 161879f , 0 . 134477f , 0 . 008935f , - 0 . 048041f , 0 . 074692f , 0 . 004928f , <nl> + - 0 . 025156f , 0 . 192874f , 0 . 074410f , 0 . 308732f , 0 . 267400f , 0 . 094208f , <nl> + - 0 . 005251f , 0 . 042041f , - 0 . 032148f , 0 . 015588f , 0 . 252869f , 0 . 175302f , <nl> + 0 . 022892f , 0 . 081673f , 0 . 063208f , 0 . 162626f , 0 . 194426f , 0 . 233890f , <nl> + 0 . 262292f , 0 . 186930f , 0 . 084079f , - 0 . 286388f , - 0 . 213034f , - 0 . 048867f , <nl> + - 0 . 207669f , - 0 . 170050f , 0 . 011673f , - 0 . 092958f , - 0 . 192786f , - 0 . 273536f , <nl> + 0 . 230904f , 0 . 266732f , 0 . 320519f , 0 . 297155f , 0 . 548169f , 0 . 304922f , <nl> + 0 . 132687f , 0 . 247333f , 0 . 212488f , - 0 . 271472f , - 0 . 142105f , - 0 . 002627f , <nl> + - 0 . 119215f , 0 . 128383f , 0 . 100079f , - 0 . 057490f , - 0 . 121902f , - 0 . 228892f , <nl> + 0 . 202292f , - 0 . 399795f , - 0 . 371326f , - 0 . 095836f , - 0 . 063626f , - 0 . 161375f , <nl> + - 0 . 311180f , - 0 . 294797f , 0 . 242122f , 0 . 011788f , 0 . 095573f , 0 . 322523f , <nl> + 0 . 511840f , 0 . 322880f , 0 . 313259f , 0 . 173331f , 0 . 002542f , - 0 . 029802f , <nl> + 0 . 324766f , - 0 . 326170f , - 0 . 340547f , - 0 . 138288f , - 0 . 002963f , - 0 . 114060f , <nl> + - 0 . 377312f , - 0 . 442570f , 0 . 212446f , - 0 . 007759f , - 0 . 011576f , 0 . 169711f , <nl> + 0 . 308689f , 0 . 317348f , 0 . 539390f , 0 . 332845f , 0 . 057331f , - 0 . 068180f , <nl> + 0 . 101994f , 0 . 266995f , 0 . 209570f , 0 . 355730f , 0 . 091635f , 0 . 170238f , <nl> + 0 . 125215f , 0 . 274154f , 0 . 070223f , 0 . 025515f , 0 . 049946f , - 0 . 000550f , <nl> + 0 . 043715f , - 0 . 141843f , 0 . 020844f , 0 . 129871f , 0 . 256588f , 0 . 105015f , <nl> + 0 . 148339f , 0 . 170682f , 0 . 028792f , 0 . 074037f , 0 . 160042f , 0 . 405137f , <nl> + 0 . 246187f , 0 . 352160f , 0 . 168951f , 0 . 222263f , 0 . 264439f , 0 . 065945f , <nl> + 0 . 021963f , - 0 . 075084f , 0 . 093105f , 0 . 027318f , 0 . 098864f , 0 . 057566f , <nl> + - 0 . 080282f , 0 . 185032f , 0 . 314419f , 0 . 333727f , 0 . 125798f , 0 . 294919f , <nl> + 0 . 386002f , 0 . 217619f , - 0 . 183517f , - 0 . 278622f , - 0 . 002342f , - 0 . 027821f , <nl> + - 0 . 134266f , - 0 . 331843f , - 0 . 008296f , 0 . 124564f , 0 . 053712f , - 0 . 369016f , <nl> + - 0 . 095036f , 0 . 209381f , 0 . 423760f , 0 . 371760f , 0 . 106397f , 0 . 369408f , <nl> + 0 . 485608f , 0 . 231201f , - 0 . 138685f , - 0 . 349208f , - 0 . 070083f , 0 . 028991f , <nl> + - 0 . 081630f , - 0 . 395992f , - 0 . 146791f , - 0 . 027354f , 0 . 063396f , - 0 . 272484f , <nl> + 0 . 058299f , 0 . 338207f , 0 . 110767f , - 0 . 052642f , - 0 . 233848f , - 0 . 027448f , <nl> + 0 . 030328f , 0 . 155572f , - 0 . 093826f , 0 . 019331f , 0 . 120638f , 0 . 006292f , <nl> + - 0 . 106083f , - 0 . 236290f , - 0 . 140933f , - 0 . 088067f , - 0 . 025138f , - 0 . 208395f , <nl> + - 0 . 025502f , 0 . 144192f , - 0 . 048353f , - 0 . 106144f , - 0 . 305121f , - 0 . 114147f , <nl> + 0 . 090963f , 0 . 327727f , 0 . 035606f , - 0 . 093779f , 0 . 002651f , - 0 . 171081f , <nl> + - 0 . 188131f , - 0 . 216571f , - 0 . 209101f , - 0 . 054402f , 0 . 157147f , - 0 . 057127f , <nl> + 0 . 066584f , 0 . 008988f , 0 . 041191f , 0 . 034456f , - 0 . 078255f , 0 . 052099f , <nl> + - 0 . 022239f , 0 . 066981f , - 0 . 117520f , - 0 . 072637f , 0 . 062512f , 0 . 037570f , <nl> + - 0 . 057544f , - 0 . 312359f , 0 . 034357f , - 0 . 031549f , 0 . 002566f , - 0 . 207375f , <nl> + - 0 . 070654f , - 0 . 018786f , - 0 . 044815f , - 0 . 012814f , - 0 . 076320f , 0 . 078183f , <nl> + 0 . 023877f , 0 . 117078f , 0 . 022292f , - 0 . 205424f , - 0 . 060430f , - 0 . 017296f , <nl> + - 0 . 004827f , - 0 . 321036f , - 0 . 092155f , 0 . 038837f , 0 . 073190f , - 0 . 067513f , <nl> + 0 . 026521f , 0 . 171945f , 0 . 087318f , 0 . 034495f , - 0 . 034089f , 0 . 154410f , <nl> + - 0 . 061431f , 0 . 007435f , - 0 . 111094f , - 0 . 095976f , 0 . 014741f , - 0 . 132324f , <nl> + - 0 . 029517f , - 0 . 192160f , 0 . 098667f , 0 . 020762f , 0 . 177050f , - 0 . 064510f , <nl> + - 0 . 054437f , - 0 . 058678f , - 0 . 001858f , 0 . 167602f , 0 . 015735f , 0 . 054338f , <nl> + 0 . 016477f , 0 . 186381f , - 0 . 010667f , 0 . 054692f , 0 . 126742f , 0 . 013140f , <nl> + 0 . 090353f , - 0 . 133608f , - 0 . 018017f , - 0 . 152619f , 0 . 027600f , - 0 . 138700f , <nl> + - 0 . 050274f , 0 . 045141f , - 0 . 118731f , 0 . 094797f , - 0 . 167605f , 0 . 097461f , <nl> + - 0 . 009131f , 0 . 199920f , - 0 . 052976f , 0 . 158194f , 0 . 178568f , - 0 . 107600f , <nl> + 0 . 009671f , - 0 . 084072f , - 0 . 040258f , - 0 . 205673f , 0 . 102891f , 0 . 223511f , <nl> + 0 . 042699f , 0 . 118548f , - 0 . 021274f , 0 . 110997f , - 0 . 155121f , 0 . 027696f , <nl> + - 0 . 149968f , 0 . 051552f , - 0 . 129219f , 0 . 173524f , 0 . 073972f , - 0 . 189045f , <nl> + - 0 . 034523f , - 0 . 106655f , - 0 . 011843f , - 0 . 197381f , 0 . 219413f , 0 . 183197f , <nl> + - 0 . 054920f , 0 . 144955f , 0 . 036517f , - 0 . 085412f , - 0 . 229070f , - 0 . 143710f , <nl> + - 0 . 049486f , 0 . 156634f , - 0 . 008673f , - 0 . 064778f , 0 . 082344f , 0 . 145673f , <nl> + 0 . 002912f , - 0 . 210121f , - 0 . 116564f , 0 . 078425f , 0 . 220908f , - 0 . 067594f , <nl> + 0 . 048610f , 0 . 084912f , - 0 . 066202f , - 0 . 112515f , - 0 . 217767f , - 0 . 082640f , <nl> + - 0 . 017414f , 0 . 230265f , - 0 . 070735f , 0 . 066073f , 0 . 215256f , 0 . 071157f , <nl> + - 0 . 087220f , - 0 . 202235f , - 0 . 011918f , 0 . 099562f , 0 . 174716f , - 0 . 063845f , <nl> + - 0 . 121055f , 0 . 014367f , 0 . 132709f , - 0 . 005060f , - 0 . 244606f , - 0 . 179693f , <nl> + - 0 . 134690f , 0 . 023239f , - 0 . 193116f , - 0 . 076975f , - 0 . 021164f , - 0 . 001938f , <nl> + - 0 . 163799f , - 0 . 111437f , - 0 . 210362f , - 0 . 166376f , 0 . 034754f , 0 . 010036f , <nl> + - 0 . 021917f , 0 . 068014f , - 0 . 086893f , - 0 . 251746f , - 0 . 267171f , 0 . 037383f , <nl> + 0 . 003966f , 0 . 033571f , - 0 . 151506f , 0 . 025437f , - 0 . 020626f , - 0 . 308454f , <nl> + - 0 . 343143f , - 0 . 092263f , - 0 . 026261f , - 0 . 028345f , 0 . 036036f , 0 . 035169f , <nl> + 0 . 129470f , 0 . 122205f , 0 . 015661f , - 0 . 070612f , - 0 . 094333f , - 0 . 066055f , <nl> + - 0 . 041083f , 0 . 159146f , 0 . 073184f , 0 . 110044f , 0 . 174471f , 0 . 078069f , <nl> + - 0 . 014881f , 0 . 008116f , 0 . 013209f , 0 . 075857f , 0 . 195605f , 0 . 062714f , <nl> + 0 . 067955f , 0 . 056544f , - 0 . 153908f , - 0 . 141749f , - 0 . 072550f , 0 . 033523f , <nl> + - 0 . 024665f , 0 . 134487f , 0 . 079076f , 0 . 133562f , 0 . 227130f , 0 . 018054f , <nl> + 0 . 004928f , 0 . 169162f , 0 . 065152f , 0 . 072160f , 0 . 131631f , 0 . 096303f , <nl> + 0 . 054288f , 0 . 106256f , 0 . 114632f , 0 . 119038f , 0 . 515200f , 0 . 247429f , <nl> + 0 . 199134f , 0 . 211957f , 0 . 127558f , - 0 . 294684f , - 0 . 194890f , - 0 . 049988f , <nl> + - 0 . 112247f , - 0 . 008122f , - 0 . 006176f , 0 . 037035f , - 0 . 110881f , - 0 . 249989f , <nl> + 0 . 152434f , 0 . 234621f , 0 . 153340f , 0 . 349283f , 0 . 683049f , 0 . 157174f , <nl> + 0 . 124844f , 0 . 099136f , 0 . 064407f , - 0 . 248400f , - 0 . 155323f , - 0 . 026498f , <nl> + - 0 . 023450f , 0 . 049051f , - 0 . 114187f , 0 . 007195f , - 0 . 176825f , - 0 . 376926f , <nl> + 0 . 366159f , - 0 . 179938f , - 0 . 148508f , 0 . 006043f , 0 . 170048f , 0 . 097866f , <nl> + - 0 . 102658f , - 0 . 260430f , 0 . 248868f , 0 . 037019f , - 0 . 118111f , 0 . 078176f , <nl> + 0 . 194171f , 0 . 211328f , 0 . 368612f , 0 . 361213f , 0 . 130013f , 0 . 094650f , <nl> + 0 . 227396f , - 0 . 178058f , - 0 . 114782f , - 0 . 008093f , 0 . 231080f , - 0 . 011843f , <nl> + - 0 . 097917f , - 0 . 325788f , 0 . 141879f , 0 . 119738f , - 0 . 230427f , - 0 . 117419f , <nl> + - 0 . 114153f , 0 . 037903f , 0 . 116383f , 0 . 218773f , - 0 . 101884f , 0 . 059466f , <nl> + 0 . 119255f , 0 . 010874f , - 0 . 031449f , 0 . 045996f , 0 . 119931f , 0 . 273760f , <nl> + 0 . 311700f , 0 . 261794f , 0 . 194809f , 0 . 339829f , 0 . 239449f , 0 . 064140f , <nl> + 0 . 077597f , 0 . 098996f , 0 . 143534f , 0 . 184602f , 0 . 037507f , 0 . 225494f , <nl> + 0 . 096142f , - 0 . 147370f , - 0 . 207833f , - 0 . 174742f , - 0 . 086391f , - 0 . 038942f , <nl> + 0 . 159577f , - 0 . 088492f , - 0 . 000989f , 0 . 108154f , - 0 . 025890f , - 0 . 072713f , <nl> + 0 . 025997f , - 0 . 006803f , - 0 . 086879f , - 0 . 011290f , - 0 . 269200f , - 0 . 103450f , <nl> + - 0 . 124910f , - 0 . 116340f , 0 . 141459f , 0 . 208800f , 0 . 042268f , 0 . 265034f , <nl> + 0 . 516474f , 0 . 217591f , - 0 . 018843f , - 0 . 313328f , - 0 . 168363f , 0 . 047129f , <nl> + 0 . 090480f , - 0 . 109852f , - 0 . 018761f , 0 . 210669f , 0 . 281269f , - 0 . 043591f , <nl> + - 0 . 034147f , - 0 . 237772f , - 0 . 134843f , - 0 . 072481f , - 0 . 103831f , 0 . 038355f , <nl> + 0 . 308619f , 0 . 148023f , - 0 . 045867f , - 0 . 123950f , - 0 . 210860f , - 0 . 064973f , <nl> + - 0 . 036308f , - 0 . 046731f , - 0 . 022099f , 0 . 095776f , 0 . 409423f , 0 . 060635f , <nl> + - 0 . 065196f , 0 . 051828f , 0 . 027981f , - 0 . 009609f , - 0 . 137681f , - 0 . 095011f , <nl> + - 0 . 019045f , 0 . 177278f , 0 . 009759f , - 0 . 092119f , - 0 . 016958f , - 0 . 133860f , <nl> + - 0 . 118421f , - 0 . 032039f , - 0 . 006214f , - 0 . 084541f , 0 . 063971f , - 0 . 073642f , <nl> + 0 . 165676f , 0 . 110443f , 0 . 044131f , 0 . 046568f , 0 . 053292f , - 0 . 055466f , <nl> + 0 . 015512f , 0 . 371947f , 0 . 232102f , - 0 . 016923f , 0 . 103979f , - 0 . 091758f , <nl> + 0 . 005907f , 0 . 209100f , 0 . 157433f , 0 . 030518f , 0 . 250366f , 0 . 062322f , <nl> + 0 . 036720f , 0 . 094676f , 0 . 017306f , - 0 . 010328f , - 0 . 079012f , 0 . 016781f , <nl> + - 0 . 112435f , 0 . 061795f , 0 . 042543f , - 0 . 126799f , - 0 . 009975f , - 0 . 056760f , <nl> + 0 . 046424f , - 0 . 194712f , - 0 . 139399f , - 0 . 037731f , 0 . 157989f , - 0 . 016261f , <nl> + 0 . 123345f , 0 . 230563f , 0 . 083300f , - 0 . 016392f , 0 . 059567f , - 0 . 016035f , <nl> + - 0 . 064767f , 0 . 231945f , 0 . 156629f , 0 . 034602f , 0 . 145628f , 0 . 041315f , <nl> + 0 . 034535f , 0 . 019967f , - 0 . 089188f , - 0 . 012091f , 0 . 307857f , 0 . 211405f , <nl> + - 0 . 025091f , - 0 . 148249f , - 0 . 129384f , 0 . 063536f , - 0 . 068603f , - 0 . 067941f , <nl> + - 0 . 035104f , 0 . 210832f , 0 . 063810f , 0 . 062764f , - 0 . 089889f , - 0 . 030554f , <nl> + 0 . 014791f , - 0 . 053362f , - 0 . 037818f , - 0 . 196640f , 0 . 008388f , - 0 . 082654f , <nl> + 0 . 143056f , 0 . 064221f , 0 . 069795f , 0 . 191040f , 0 . 097321f , - 0 . 028679f , <nl> + 0 . 075794f , 0 . 313154f , 0 . 086240f , 0 . 207643f , 0 . 017809f , 0 . 122867f , <nl> + 0 . 224586f , 0 . 167403f , - 0 . 023884f , 0 . 047434f , 0 . 344091f , 0 . 187745f , <nl> + 0 . 136177f , 0 . 141738f , 0 . 063799f , 0 . 045233f , - 0 . 077342f , - 0 . 003525f , <nl> + - 0 . 165041f , - 0 . 025616f , - 0 . 073745f , 0 . 164439f , 0 . 011200f , - 0 . 145896f , <nl> + - 0 . 027954f , - 0 . 061987f , - 0 . 039874f , - 0 . 142775f , 0 . 151042f , - 0 . 038238f , <nl> + 0 . 053152f , 0 . 078615f , 0 . 086061f , 0 . 100593f , 0 . 128046f , - 0 . 071006f , <nl> + - 0 . 116558f , 0 . 208445f , 0 . 051086f , 0 . 076843f , 0 . 023191f , - 0 . 084781f , <nl> + - 0 . 011790f , 0 . 147807f , - 0 . 048554f , - 0 . 113932f , 0 . 283322f , 0 . 190934f , <nl> + 0 . 092789f , 0 . 033018f , - 0 . 142428f , - 0 . 142480f , - 0 . 099023f , - 0 . 041020f , <nl> + - 0 . 042760f , 0 . 203295f , - 0 . 053475f , 0 . 042424f , 0 . 222839f , - 0 . 019167f , <nl> + - 0 . 133176f , - 0 . 276216f , - 0 . 031998f , 0 . 117290f , 0 . 177827f , - 0 . 059973f , <nl> + - 0 . 064744f , - 0 . 117040f , - 0 . 155482f , - 0 . 099531f , 0 . 164121f , - 0 . 026682f , <nl> + - 0 . 093810f , 0 . 238993f , - 0 . 006506f , 0 . 007830f , 0 . 065819f , - 0 . 203643f , <nl> + - 0 . 100925f , - 0 . 053652f , - 0 . 130770f , 0 . 026277f , 0 . 131796f , 0 . 032742f , <nl> + 0 . 127186f , 0 . 116694f , - 0 . 161122f , - 0 . 279773f , - 0 . 252515f , - 0 . 002638f , <nl> + 0 . 042812f , 0 . 096776f , - 0 . 123280f , 0 . 064858f , - 0 . 010455f , - 0 . 219760f , <nl> + - 0 . 239331f , - 0 . 104363f , - 0 . 058022f , - 0 . 053584f , 0 . 025611f , 0 . 005129f , <nl> + - 0 . 100418f , - 0 . 045712f , - 0 . 194418f , - 0 . 126366f , - 0 . 030530f , 0 . 051168f , <nl> + 0 . 215959f , 0 . 172402f , - 0 . 054700f , - 0 . 185995f , - 0 . 278360f , - 0 . 193693f , <nl> + - 0 . 040309f , 0 . 003735f , - 0 . 007770f , 0 . 123556f , 0 . 190179f , - 0 . 077315f , <nl> + 0 . 117403f , 0 . 212942f , 0 . 012160f , 0 . 000113f , 0 . 027331f , 0 . 040202f , <nl> + 0 . 033293f , 0 . 219438f , 0 . 184174f , 0 . 259349f , 0 . 311206f , 0 . 082547f , <nl> + - 0 . 047875f , - 0 . 078417f , 0 . 010746f , 0 . 082620f , 0 . 311931f , 0 . 307605f , <nl> + 0 . 003863f , 0 . 021405f , - 0 . 026388f , - 0 . 019572f , 0 . 020582f , - 0 . 059353f , <nl> + 0 . 025199f , 0 . 261319f , 0 . 086316f , 0 . 143614f , 0 . 107780f , 0 . 003900f , <nl> + - 0 . 188397f , - 0 . 038563f , - 0 . 106045f , - 0 . 125154f , - 0 . 010509f , 0 . 054021f , <nl> + 0 . 242130f , 0 . 279152f , 0 . 215546f , 0 . 346995f , 0 . 440856f , 0 . 237452f , <nl> + 0 . 234154f , 0 . 301646f , 0 . 168929f , - 0 . 208358f , - 0 . 126848f , 0 . 010260f , <nl> + 0 . 121018f , - 0 . 062975f , - 0 . 052848f , 0 . 050341f , - 0 . 061103f , - 0 . 266482f , <nl> + 0 . 107186f , 0 . 140221f , 0 . 280065f , 0 . 287889f , 0 . 373198f , 0 . 151596f , <nl> + 0 . 013593f , 0 . 115616f , 0 . 014616f , - 0 . 281710f , - 0 . 237597f , - 0 . 117305f , <nl> + - 0 . 000034f , - 0 . 136739f , - 0 . 196275f , - 0 . 095225f , - 0 . 125310f , - 0 . 250514f , <nl> + 0 . 236804f , - 0 . 071805f , - 0 . 037421f , 0 . 048230f , 0 . 321596f , 0 . 063632f , <nl> + 0 . 024039f , - 0 . 029133f , 0 . 230983f , 0 . 160593f , - 0 . 154355f , - 0 . 013086f , <nl> + - 0 . 079929f , 0 . 094692f , 0 . 160391f , 0 . 180239f , 0 . 053895f , 0 . 100759f , <nl> + 0 . 288631f , 0 . 038191f , 0 . 181692f , 0 . 229682f , 0 . 440166f , 0 . 063401f , <nl> + 0 . 006273f , 0 . 020865f , 0 . 338695f , 0 . 256244f , - 0 . 043927f , 0 . 115617f , <nl> + 0 . 003296f , 0 . 173965f , 0 . 021318f , - 0 . 040936f , - 0 . 118932f , 0 . 182380f , <nl> + 0 . 235922f , - 0 . 053233f , - 0 . 015053f , - 0 . 101057f , 0 . 095341f , 0 . 051111f , <nl> + 0 . 161831f , 0 . 032614f , 0 . 159496f , 0 . 072375f , 0 . 025089f , 0 . 023748f , <nl> + 0 . 029151f , 0 . 161284f , - 0 . 117717f , - 0 . 036191f , - 0 . 176822f , - 0 . 162006f , <nl> + 0 . 226542f , - 0 . 078329f , 0 . 043079f , - 0 . 119172f , 0 . 054614f , - 0 . 101365f , <nl> + - 0 . 064541f , - 0 . 115304f , 0 . 135170f , 0 . 298872f , 0 . 098060f , 0 . 089428f , <nl> + - 0 . 007497f , 0 . 110391f , - 0 . 028824f , 0 . 020835f , - 0 . 036804f , 0 . 125411f , <nl> + 0 . 192105f , - 0 . 048931f , 0 . 003086f , - 0 . 010681f , 0 . 074698f , - 0 . 016263f , <nl> + 0 . 096063f , 0 . 060267f , - 0 . 007277f , 0 . 139139f , - 0 . 080635f , 0 . 036628f , <nl> + 0 . 086058f , 0 . 131979f , 0 . 085707f , 0 . 025301f , 0 . 226094f , 0 . 194759f , <nl> + 0 . 042193f , - 0 . 157846f , - 0 . 068402f , - 0 . 141450f , - 0 . 112659f , - 0 . 076305f , <nl> + - 0 . 069085f , - 0 . 114332f , - 0 . 102005f , 0 . 132193f , - 0 . 067042f , 0 . 106643f , <nl> + 0 . 198964f , 0 . 171616f , 0 . 167237f , - 0 . 033730f , - 0 . 026755f , 0 . 083621f , <nl> + 0 . 149459f , - 0 . 002799f , - 0 . 000318f , 0 . 011753f , 0 . 065889f , - 0 . 089375f , <nl> + - 0 . 049610f , 0 . 224579f , 0 . 216548f , - 0 . 034908f , - 0 . 017851f , - 0 . 088144f , <nl> + 0 . 007530f , 0 . 240268f , 0 . 073270f , 0 . 013263f , 0 . 175323f , 0 . 012082f , <nl> + 0 . 093993f , 0 . 015282f , 0 . 105854f , 0 . 107990f , 0 . 077798f , - 0 . 096166f , <nl> + - 0 . 079607f , 0 . 177820f , 0 . 142392f , 0 . 033337f , - 0 . 078100f , - 0 . 081616f , <nl> + - 0 . 046993f , 0 . 139459f , 0 . 020272f , - 0 . 123161f , 0 . 175269f , 0 . 105217f , <nl> + 0 . 057328f , 0 . 080909f , - 0 . 012612f , - 0 . 097081f , 0 . 082060f , - 0 . 096716f , <nl> + - 0 . 063921f , 0 . 201884f , 0 . 128166f , - 0 . 035051f , - 0 . 032227f , - 0 . 068139f , <nl> + - 0 . 115915f , 0 . 095080f , - 0 . 086007f , - 0 . 067543f , 0 . 030776f , 0 . 032712f , <nl> + 0 . 088937f , 0 . 054336f , - 0 . 039329f , - 0 . 114022f , 0 . 171672f , - 0 . 112321f , <nl> + - 0 . 217646f , 0 . 065186f , 0 . 060223f , 0 . 192174f , 0 . 055580f , - 0 . 131107f , <nl> + - 0 . 144338f , 0 . 056730f , - 0 . 034707f , - 0 . 081616f , - 0 . 135298f , - 0 . 000614f , <nl> + 0 . 087189f , 0 . 014614f , 0 . 067709f , 0 . 107689f , 0 . 225780f , 0 . 084361f , <nl> + - 0 . 008544f , 0 . 051649f , - 0 . 048369f , - 0 . 037739f , - 0 . 060710f , 0 . 002654f , <nl> + 0 . 016935f , 0 . 085563f , - 0 . 015961f , - 0 . 019265f , 0 . 111788f , 0 . 062376f , <nl> + 0 . 202019f , 0 . 047713f , 0 . 042261f , 0 . 069716f , 0 . 242913f , 0 . 021052f , <nl> + - 0 . 072812f , - 0 . 155920f , - 0 . 026436f , 0 . 035621f , - 0 . 079300f , - 0 . 028787f , <nl> + - 0 . 048329f , 0 . 084718f , - 0 . 060565f , - 0 . 083750f , - 0 . 164075f , - 0 . 040742f , <nl> + - 0 . 086219f , 0 . 015271f , - 0 . 005204f , - 0 . 016038f , 0 . 045816f , - 0 . 050433f , <nl> + - 0 . 077652f , 0 . 117109f , 0 . 009611f , - 0 . 009045f , - 0 . 008634f , - 0 . 055373f , <nl> + - 0 . 085968f , 0 . 028527f , - 0 . 054736f , - 0 . 168089f , 0 . 175839f , 0 . 071205f , <nl> + - 0 . 023603f , 0 . 037907f , - 0 . 004561f , - 0 . 022634f , 0 . 123831f , 0 . 094469f , <nl> + - 0 . 072920f , - 0 . 133642f , - 0 . 014032f , - 0 . 142754f , - 0 . 026999f , - 0 . 199409f , <nl> + 0 . 013268f , 0 . 226989f , 0 . 048650f , - 0 . 170988f , - 0 . 050141f , 0 . 007880f , <nl> + 0 . 061880f , 0 . 019078f , - 0 . 043578f , - 0 . 038139f , 0 . 134814f , 0 . 054097f , <nl> + - 0 . 081670f , 0 . 176838f , 0 . 047920f , - 0 . 038176f , 0 . 050406f , - 0 . 107181f , <nl> + - 0 . 036279f , 0 . 027060f , 0 . 081594f , - 0 . 002820f , 0 . 090507f , - 0 . 033338f , <nl> + - 0 . 059571f , 0 . 013404f , - 0 . 099860f , 0 . 073371f , 0 . 342805f , 0 . 098305f , <nl> + - 0 . 150910f , - 0 . 020822f , - 0 . 056960f , 0 . 046262f , - 0 . 043413f , - 0 . 149405f , <nl> + - 0 . 129105f , - 0 . 010899f , - 0 . 014229f , - 0 . 179949f , - 0 . 113044f , - 0 . 049468f , <nl> + - 0 . 065513f , 0 . 090269f , - 0 . 011919f , 0 . 087846f , 0 . 095796f , 0 . 146127f , <nl> + 0 . 101599f , 0 . 078066f , - 0 . 084348f , - 0 . 100002f , - 0 . 020134f , - 0 . 050169f , <nl> + 0 . 062122f , 0 . 014640f , 0 . 019143f , 0 . 036543f , 0 . 180924f , - 0 . 013976f , <nl> + - 0 . 066768f , - 0 . 001090f , - 0 . 070419f , - 0 . 004839f , - 0 . 001504f , 0 . 034483f , <nl> + - 0 . 044954f , - 0 . 050336f , - 0 . 088638f , - 0 . 174782f , - 0 . 116082f , - 0 . 205507f , <nl> + 0 . 015587f , - 0 . 042839f , - 0 . 096879f , - 0 . 144097f , - 0 . 050268f , - 0 . 196796f , <nl> + 0 . 109639f , 0 . 271411f , 0 . 173732f , 0 . 108070f , 0 . 156437f , 0 . 124255f , <nl> + 0 . 097242f , 0 . 238693f , 0 . 083941f , 0 . 109105f , 0 . 223940f , 0 . 267188f , <nl> + 0 . 027385f , 0 . 025819f , 0 . 125070f , 0 . 093738f , 0 . 040353f , 0 . 038645f , <nl> + - 0 . 012730f , 0 . 144063f , 0 . 052931f , - 0 . 009138f , 0 . 084193f , 0 . 160272f , <nl> + - 0 . 041366f , 0 . 011951f , - 0 . 121446f , - 0 . 106713f , - 0 . 047566f , 0 . 047984f , <nl> + - 0 . 255224f , - 0 . 076116f , 0 . 098685f , - 0 . 150845f , - 0 . 171513f , - 0 . 156590f , <nl> + 0 . 058331f , 0 . 187493f , 0 . 413018f , 0 . 554265f , 0 . 372242f , 0 . 237943f , <nl> + 0 . 124571f , 0 . 110829f , 0 . 010322f , - 0 . 174477f , - 0 . 067627f , - 0 . 001979f , <nl> + 0 . 142913f , 0 . 040597f , 0 . 019907f , 0 . 025963f , - 0 . 043585f , - 0 . 120732f , <nl> + 0 . 099937f , 0 . 091059f , 0 . 247307f , 0 . 204226f , - 0 . 042753f , - 0 . 068580f , <nl> + - 0 . 119002f , 0 . 026722f , 0 . 034853f , - 0 . 060934f , - 0 . 025054f , - 0 . 093026f , <nl> + - 0 . 035372f , - 0 . 233209f , - 0 . 049869f , - 0 . 039151f , - 0 . 022279f , - 0 . 065380f , <nl> + - 9 . 063785f } ; <nl> + return vector < float > ( detector , detector + sizeof ( detector ) / sizeof ( detector [ 0 ] ) ) ; <nl> + } <nl> + <nl> + <nl> + <nl> + <nl> + std : : vector < float > cv : : gpu : : HOGDescriptor : : getPeopleDetector_64x128 ( ) <nl> { <nl> static const float detector [ ] = { <nl> 0 . 05359386f , - 0 . 14721455f , - 0 . 05532170f , 0 . 05077307f , <nl>
added getPeopleDetector_48x96 into gpu HOG
opencv/opencv
4568d702ff38e4a6f545563cb42c9c283b35e772
2010-11-17T08:31:24Z
mmm a / cmake / find_llvm . cmake <nl> ppp b / cmake / find_llvm . cmake <nl> if ( ENABLE_EMBEDDED_COMPILER ) <nl> <nl> option ( LLVM_HAS_RTTI " Enable if LLVM was build with RTTI enabled " ON ) <nl> set ( USE_EMBEDDED_COMPILER 1 ) <nl> + else ( ) <nl> + set ( USE_EMBEDDED_COMPILER 0 ) <nl> endif ( ) <nl> else ( ) <nl> set ( LLVM_FOUND 1 ) <nl>
Fixed build [ # CLICKHOUSE - 2 ]
ClickHouse/ClickHouse
b68c68a414ccd2c940d7df21de3d35b7005d5bce
2018-06-14T23:29:29Z
mmm a / x64_dbg_dbg / debugger . cpp <nl> ppp b / x64_dbg_dbg / debugger . cpp <nl> <nl> # include " disasm_helper . h " <nl> # include " symbolinfo . h " <nl> # include " thread . h " <nl> + # include " disasm_fast . h " <nl> <nl> # include " BeaEngine \ BeaEngine . h " <nl> <nl> CMDRESULT cbBenchmark ( int argc , char * argv [ ] ) <nl> } <nl> dprintf ( " memread : % " fext " X : % ums \ n " , size , GetTickCount ( ) - ticks ) ; <nl> ticks = GetTickCount ( ) ; <nl> + DISASM disasm ; <nl> + memset ( & disasm , 0 , sizeof ( disasm ) ) ; <nl> + # ifdef _WIN64 <nl> + disasm . Archi = 64 ; <nl> + # endif / / _WIN64 <nl> + disasm . EIP = ( UIntPtr ) data ; <nl> + disasm . VirtualAddr = ( UInt64 ) data ; <nl> uint i = 0 ; <nl> + BASIC_INSTRUCTION_INFO basicinfo ; <nl> while ( i < size ) <nl> { <nl> - DISASM_INSTR instr ; <nl> - memset ( & instr , 0 , sizeof ( instr ) ) ; <nl> - disasmget ( ( unsigned char * ) ( data + i ) , base + i , & instr ) ; <nl> - i + = instr . instr_size ; <nl> - count + + ; <nl> + int len = Disasm ( & disasm ) ; <nl> + if ( len ! = UNKNOWN_OPCODE ) <nl> + { <nl> + / / fillbasicinfo ( & disasm , & basicinfo ) ; <nl> + count + + ; <nl> + } <nl> + else <nl> + len = 1 ; <nl> + disasm . EIP + = len ; <nl> + disasm . VirtualAddr + = len ; <nl> + i + = len ; <nl> } <nl> efree ( data ) ; <nl> - dprintf ( " disasmget : % d : % ums \ n " , count , GetTickCount ( ) - ticks ) ; <nl> + dprintf ( " disasmget : % u : % ums \ n " , count , GetTickCount ( ) - ticks ) ; <nl> return STATUS_CONTINUE ; <nl> } <nl> <nl> new file mode 100644 <nl> index 000000000 . . 4f161dfb0 <nl> mmm / dev / null <nl> ppp b / x64_dbg_dbg / disasm_fast . cpp <nl> <nl> + # include " disasm_fast . h " <nl> + <nl> + static MEMORY_SIZE argsize2memsize ( int argsize ) <nl> + { <nl> + switch ( argsize ) <nl> + { <nl> + case 8 : <nl> + return size_byte ; <nl> + case 16 : <nl> + return size_word ; <nl> + case 32 : <nl> + return size_dword ; <nl> + case 64 : <nl> + return size_qword ; <nl> + } <nl> + return size_byte ; <nl> + } <nl> + <nl> + void fillbasicinfo ( DISASM * disasm , BASIC_INSTRUCTION_INFO * basicinfo ) <nl> + { <nl> + / / set type to zero <nl> + basicinfo - > type = 0 ; <nl> + / / find immidiat <nl> + if ( disasm - > Instruction . BranchType = = 0 ) / / no branch <nl> + { <nl> + if ( ( disasm - > Argument1 . ArgType & CONSTANT_TYPE ) = = CONSTANT_TYPE ) <nl> + { <nl> + basicinfo - > type | = TYPE_VALUE ; <nl> + basicinfo - > value . value = ( ULONG_PTR ) disasm - > Instruction . Immediat ; <nl> + basicinfo - > value . size = argsize2memsize ( disasm - > Argument1 . ArgSize ) ; <nl> + } <nl> + else if ( ( disasm - > Argument2 . ArgType & CONSTANT_TYPE ) = = CONSTANT_TYPE ) <nl> + { <nl> + basicinfo - > type | = TYPE_VALUE ; <nl> + basicinfo - > value . value = ( ULONG_PTR ) disasm - > Instruction . Immediat ; <nl> + basicinfo - > value . size = argsize2memsize ( disasm - > Argument2 . ArgSize ) ; <nl> + } <nl> + } <nl> + else / / branch <nl> + basicinfo - > branch = true ; <nl> + / / find memory displacement <nl> + if ( ( disasm - > Argument1 . ArgType & MEMORY_TYPE ) = = MEMORY_TYPE | | ( disasm - > Argument2 . ArgType & MEMORY_TYPE ) = = MEMORY_TYPE ) <nl> + { <nl> + if ( disasm - > Argument1 . Memory . Displacement ) <nl> + { <nl> + basicinfo - > type | = TYPE_MEMORY ; <nl> + basicinfo - > memory . value = ( ULONG_PTR ) disasm - > Argument1 . Memory . Displacement ; <nl> + strcpy ( basicinfo - > memory . mnemonic , disasm - > Argument1 . ArgMnemonic ) ; <nl> + basicinfo - > memory . size = argsize2memsize ( disasm - > Argument1 . ArgSize ) ; <nl> + } <nl> + else if ( disasm - > Argument2 . Memory . Displacement ) <nl> + { <nl> + basicinfo - > type | = TYPE_MEMORY ; <nl> + basicinfo - > memory . value = ( ULONG_PTR ) disasm - > Argument2 . Memory . Displacement ; <nl> + strcpy ( basicinfo - > memory . mnemonic , disasm - > Argument2 . ArgMnemonic ) ; <nl> + basicinfo - > memory . size = argsize2memsize ( disasm - > Argument2 . ArgSize ) ; <nl> + } <nl> + } <nl> + / / find address value <nl> + if ( disasm - > Instruction . BranchType & & disasm - > Instruction . AddrValue ) <nl> + { <nl> + basicinfo - > type | = TYPE_ADDR ; <nl> + basicinfo - > addr = ( ULONG_PTR ) disasm - > Instruction . AddrValue ; <nl> + } <nl> + / / rip - relative ( non - branch ) <nl> + if ( disasm - > Instruction . BranchType = = 0 ) <nl> + { <nl> + if ( ( disasm - > Argument1 . ArgType & RELATIVE_ ) = = RELATIVE_ ) <nl> + { <nl> + basicinfo - > type | = TYPE_MEMORY ; <nl> + basicinfo - > memory . value = ( ULONG_PTR ) disasm - > Instruction . AddrValue ; <nl> + strcpy ( basicinfo - > memory . mnemonic , disasm - > Argument1 . ArgMnemonic ) ; <nl> + basicinfo - > memory . size = argsize2memsize ( disasm - > Argument1 . ArgSize ) ; <nl> + } <nl> + else if ( ( disasm - > Argument2 . ArgType & RELATIVE_ ) = = RELATIVE_ ) <nl> + { <nl> + basicinfo - > type | = TYPE_MEMORY ; <nl> + basicinfo - > memory . value = ( ULONG_PTR ) disasm - > Instruction . AddrValue ; <nl> + strcpy ( basicinfo - > memory . mnemonic , disasm - > Argument2 . ArgMnemonic ) ; <nl> + basicinfo - > memory . size = argsize2memsize ( disasm - > Argument2 . ArgSize ) ; <nl> + } <nl> + } <nl> + } <nl> \ No newline at end of file <nl> new file mode 100644 <nl> index 000000000 . . 1e2ba962a <nl> mmm / dev / null <nl> ppp b / x64_dbg_dbg / disasm_fast . h <nl> <nl> + # ifndef _DISASM_FAST_H <nl> + <nl> + # include " _global . h " <nl> + # include " BeaEngine \ BeaEngine . h " <nl> + <nl> + # define TYPE_VALUE 1 <nl> + # define TYPE_MEMORY 2 <nl> + # define TYPE_ADDR 4 <nl> + <nl> + # define MAX_MNEMONIC_SIZE 64 <nl> + <nl> + enum MEMORY_SIZE <nl> + { <nl> + size_byte , <nl> + size_word , <nl> + size_dword , <nl> + size_qword <nl> + } ; <nl> + <nl> + typedef MEMORY_SIZE VALUE_SIZE ; <nl> + <nl> + struct MEMORY_INFO <nl> + { <nl> + ULONG_PTR value ; / / displacement / addrvalue ( rip - relative ) <nl> + MEMORY_SIZE size ; / / byte / word / dword / qword <nl> + char mnemonic [ MAX_MNEMONIC_SIZE ] ; <nl> + } ; <nl> + <nl> + struct VALUE_INFO <nl> + { <nl> + ULONG_PTR value ; <nl> + VALUE_SIZE size ; <nl> + } ; <nl> + <nl> + struct BASIC_INSTRUCTION_INFO <nl> + { <nl> + DWORD type ; / / value | memory | addr <nl> + VALUE_INFO value ; / / immediat <nl> + MEMORY_INFO memory ; <nl> + ULONG_PTR addr ; / / addrvalue ( jumps + calls ) <nl> + bool branch ; / / jumps / calls <nl> + } ; <nl> + <nl> + void fillbasicinfo ( DISASM * disasm , BASIC_INSTRUCTION_INFO * basicinfo ) ; <nl> + <nl> + # endif / / _DISASM_FAST_H <nl> \ No newline at end of file <nl> mmm a / x64_dbg_dbg / x64_dbg_dbg . cbp <nl> ppp b / x64_dbg_dbg / x64_dbg_dbg . cbp <nl> <nl> < Unit filename = " dbghelp / dbghelp . h " / > <nl> < Unit filename = " debugger . cpp " / > <nl> < Unit filename = " debugger . h " / > <nl> + < Unit filename = " disasm_fast . cpp " / > <nl> + < Unit filename = " disasm_fast . h " / > <nl> < Unit filename = " disasm_helper . cpp " / > <nl> < Unit filename = " disasm_helper . h " / > <nl> < Unit filename = " instruction . cpp " / > <nl> <nl> < Unit filename = " thread . h " / > <nl> < Unit filename = " threading . cpp " / > <nl> < Unit filename = " threading . h " / > <nl> + < Unit filename = " undocumented . h " / > <nl> < Unit filename = " value . cpp " / > <nl> < Unit filename = " value . h " / > <nl> < Unit filename = " variable . cpp " / > <nl> mmm a / x64_dbg_dbg / x64_dbg_dbg . vcxproj <nl> ppp b / x64_dbg_dbg / x64_dbg_dbg . vcxproj <nl> <nl> < ClCompile Include = " command . cpp " / > <nl> < ClCompile Include = " console . cpp " / > <nl> < ClCompile Include = " debugger . cpp " / > <nl> + < ClCompile Include = " disasm_fast . cpp " / > <nl> < ClCompile Include = " disasm_helper . cpp " / > <nl> < ClCompile Include = " instruction . cpp " / > <nl> < ClCompile Include = " main . cpp " / > <nl> <nl> < ClInclude Include = " data . h " / > <nl> < ClInclude Include = " dbg . h " / > <nl> < ClInclude Include = " debugger . h " / > <nl> + < ClInclude Include = " disasm_fast . h " / > <nl> < ClInclude Include = " disasm_helper . h " / > <nl> < ClInclude Include = " instruction . h " / > <nl> < ClInclude Include = " math . h " / > <nl> mmm a / x64_dbg_dbg / x64_dbg_dbg . vcxproj . filters <nl> ppp b / x64_dbg_dbg / x64_dbg_dbg . vcxproj . filters <nl> <nl> < ClCompile Include = " thread . cpp " > <nl> < Filter > Source Files < / Filter > <nl> < / ClCompile > <nl> + < ClCompile Include = " disasm_fast . cpp " > <nl> + < Filter > Source Files < / Filter > <nl> + < / ClCompile > <nl> < / ItemGroup > <nl> < ItemGroup > <nl> < ClInclude Include = " _exports . h " > <nl> <nl> < ClInclude Include = " undocumented . h " > <nl> < Filter > Header Files < / Filter > <nl> < / ClInclude > <nl> + < ClInclude Include = " disasm_fast . h " > <nl> + < Filter > Header Files < / Filter > <nl> + < / ClInclude > <nl> < / ItemGroup > <nl> < / Project > <nl> \ No newline at end of file <nl>
DBG : added fast disassembly ( 1million instructions per second with analysis )
x64dbg/x64dbg
d2a37413e88acfb20e46c2dc1141878c8a747d40
2014-04-02T20:47:10Z
mmm a / Changelog <nl> ppp b / Changelog <nl> <nl> - WEB UI : Remodeled Web UI to match new qBittorrent UI ( Properties and preferences available ) <nl> - WEB UI : Added internationalization support <nl> - WEB UI : Reduced computation in Javascript ( do this one server side instead ) <nl> + - WEB UI : Fixed Transfer list flickering <nl> - COSMETIC : Merged download / upload lists <nl> - COSMETIC : Torrents can be filtered based on their status <nl> - COSMETIC : Torrent properties are now displayed in main window <nl> mmm a / src / webui / scripts / client . js <nl> ppp b / src / webui / scripts / client . js <nl> window . addEvent ( ' domready ' , function ( ) { <nl> initializeWindows ( ) ; <nl> var r = 0 ; <nl> var waiting = false ; <nl> + <nl> var stateToImg = function ( state ) { <nl> - switch ( state ) <nl> - { <nl> - case ' pausedUP ' : <nl> - return ' < img src = " images / skin / pausedUP . png " / > ' ; <nl> - case ' pausedDL ' : <nl> - return ' < img src = " images / skin / pausedDL . png " / > ' ; <nl> - case ' seeding ' : <nl> - return ' < img src = " images / skin / uploading . png " / > ' ; <nl> - case ' stalledUP ' : <nl> - return ' < img src = " images / skin / stalledUP . png " / > ' ; <nl> - case ' checkingUP ' : <nl> - return ' < img src = " images / skin / checkingUP . png " / > ' ; <nl> - case ' checkingDL ' : <nl> - return ' < img src = " images / skin / checkingDL . png " / > ' ; <nl> - case ' downloading ' : <nl> - return ' < img src = " images / skin / downloading . png " / > ' ; <nl> - case ' stalledDL ' : <nl> - return ' < img src = " images / skin / stalledDL . png " / > ' ; <nl> - case ' queuedUP ' : <nl> - return ' < img src = " images / skin / queuedUP . png " / > ' ; <nl> - case ' queuedDL ' : <nl> - return ' < img src = " images / skin / queuedDL . png " / > ' ; <nl> - default : <nl> - return ' ' ; <nl> - } <nl> - return ' ' ; <nl> + return ' images / skin / ' + state + ' . png ' ; <nl> } ; <nl> var ajaxfn = function ( ) { <nl> var queueing_enabled = false ; <nl> mmm a / src / webui / scripts / dynamicTable . js <nl> ppp b / src / webui / scripts / dynamicTable . js <nl> var dynamicTable = new Class ( { <nl> if ( i = = this . progressIndex ) { <nl> td . adopt ( new ProgressBar ( row [ i ] . toFloat ( ) , { width : 80 } ) ) ; <nl> } else { <nl> - td . set ( ' html ' , row [ i ] ) ; <nl> + if ( i = = 0 ) { <nl> + td . adopt ( new Element ( ' img ' , { ' src ' : row [ i ] } ) ) ; <nl> + } else { <nl> + td . set ( ' html ' , row [ i ] ) ; <nl> + } <nl> } <nl> td . injectInside ( tr ) ; <nl> } ; <nl> var dynamicTable = new Class ( { <nl> var tds = tr . getElements ( ' td ' ) ; <nl> for ( var i = 0 ; i < row . length ; i + + ) { <nl> if ( i = = this . progressIndex ) { <nl> - tds [ i ] . set ( ' html ' , ' ' ) ; <nl> - tds [ i ] . adopt ( new ProgressBar ( row [ i ] . toFloat ( ) , { width : 80 } ) ) ; <nl> + new ProgressBar ( row [ i ] . toFloat ( ) , { width : 80 } ) . replaces ( tds [ i ] . getChildren ( ) [ 0 ] ) ; <nl> + / * tds [ i ] . set ( ' html ' , ' ' ) ; <nl> + tds [ i ] . adopt ( new ProgressBar ( row [ i ] . toFloat ( ) , { width : 80 } ) ) ; * / <nl> } else { <nl> - tds [ i ] . set ( ' html ' , row [ i ] ) ; <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> } ; <nl> return true ; <nl>
- Fix transfer list flickering
qbittorrent/qBittorrent
c212d8beff6afc8f57133cca08be69e392451bd7
2009-11-25T12:09:10Z
mmm a / src / buffer_cache / buf_patch . cc <nl> ppp b / src / buffer_cache / buf_patch . cc <nl> void buf_patch_t : : serialize ( char * destination ) const { <nl> buf_patch_t : : buf_patch_t ( const block_id_t _block_id , const patch_operation_code_t _operation_code ) : <nl> block_id ( _block_id ) , <nl> operation_code ( _operation_code ) { } <nl> - <nl> - <nl> - memcpy_patch_t : : memcpy_patch_t ( const block_id_t block_id , const uint16_t _dest_offset , const char * src , const uint16_t n ) : <nl> - buf_patch_t ( block_id , buf_patch_t : : OPER_MEMCPY ) , <nl> - dest_offset ( _dest_offset ) { <nl> - src_buf . init ( n ) ; <nl> - memcpy ( src_buf . data ( ) , src , n ) ; <nl> - } <nl> - memcpy_patch_t : : memcpy_patch_t ( const block_id_t block_id , const char * data , const uint16_t data_length ) : <nl> - buf_patch_t ( block_id , buf_patch_t : : OPER_MEMCPY ) { <nl> - uint16_t n ; <nl> - guarantee_patch_format ( data_length > = sizeof ( dest_offset ) + sizeof ( n ) ) ; <nl> - dest_offset = * reinterpret_cast < const uint16_t * > ( data ) ; <nl> - data + = sizeof ( dest_offset ) ; <nl> - n = * reinterpret_cast < const uint16_t * > ( data ) ; <nl> - data + = sizeof ( n ) ; <nl> - guarantee_patch_format ( data_length = = sizeof ( dest_offset ) + sizeof ( n ) + n ) ; <nl> - src_buf . init ( n ) ; <nl> - memcpy ( src_buf . data ( ) , data , n ) ; <nl> - <nl> - / / Uncomment if you have more to read . <nl> - / / data + = n ; <nl> - } <nl> - <nl> - void memcpy_patch_t : : serialize_data ( char * destination ) const { <nl> - memcpy ( destination , & dest_offset , sizeof ( dest_offset ) ) ; <nl> - destination + = sizeof ( dest_offset ) ; <nl> - uint64_t n = src_buf . size ( ) ; <nl> - memcpy ( destination , & n , sizeof ( n ) ) ; <nl> - destination + = sizeof ( n ) ; <nl> - memcpy ( destination , src_buf . data ( ) , n ) ; <nl> - <nl> - / / Uncomment if you have more to write . <nl> - / / destination + = n ; <nl> - } <nl> - uint16_t memcpy_patch_t : : get_data_size ( ) const { <nl> - return sizeof ( dest_offset ) + sizeof ( uint16_t ) + src_buf . size ( ) ; <nl> - } <nl> - <nl> - memcpy_patch_t : : ~ memcpy_patch_t ( ) { } <nl> - <nl> - void memcpy_patch_t : : apply_to_buf ( char * buf_data , UNUSED block_size_t bs ) { <nl> - memcpy ( buf_data + dest_offset , src_buf . data ( ) , src_buf . size ( ) ) ; <nl> - } <nl> - <nl> - memmove_patch_t : : memmove_patch_t ( const block_id_t block_id , const uint16_t _dest_offset , const uint16_t _src_offset , const uint16_t _n ) : <nl> - buf_patch_t ( block_id , buf_patch_t : : OPER_MEMMOVE ) , <nl> - dest_offset ( _dest_offset ) , <nl> - src_offset ( _src_offset ) , <nl> - n ( _n ) { } <nl> - <nl> - memmove_patch_t : : memmove_patch_t ( const block_id_t block_id , const char * data , const uint16_t data_length ) : <nl> - buf_patch_t ( block_id , buf_patch_t : : OPER_MEMMOVE ) { <nl> - guarantee_patch_format ( data_length = = get_data_size ( ) ) ; <nl> - dest_offset = * reinterpret_cast < const uint16_t * > ( data ) ; <nl> - data + = sizeof ( dest_offset ) ; <nl> - src_offset = * reinterpret_cast < const uint16_t * > ( data ) ; <nl> - data + = sizeof ( src_offset ) ; <nl> - n = * reinterpret_cast < const uint16_t * > ( data ) ; <nl> - <nl> - / / Uncomment if you have more to read . <nl> - / / data + = sizeof ( n ) ; <nl> - } <nl> - <nl> - void memmove_patch_t : : serialize_data ( char * destination ) const { <nl> - memcpy ( destination , & dest_offset , sizeof ( dest_offset ) ) ; <nl> - destination + = sizeof ( dest_offset ) ; <nl> - memcpy ( destination , & src_offset , sizeof ( src_offset ) ) ; <nl> - destination + = sizeof ( src_offset ) ; <nl> - memcpy ( destination , & n , sizeof ( n ) ) ; <nl> - <nl> - / / Uncomment if you have more to write . <nl> - / / destination + = sizeof ( n ) ; <nl> - } <nl> - uint16_t memmove_patch_t : : get_data_size ( ) const { <nl> - return sizeof ( dest_offset ) + sizeof ( src_offset ) + sizeof ( n ) ; <nl> - } <nl> - <nl> - void memmove_patch_t : : apply_to_buf ( char * buf_data , UNUSED block_size_t bs ) { <nl> - memmove ( buf_data + dest_offset , buf_data + src_offset , n ) ; <nl> - } <nl> - <nl> mmm a / src / buffer_cache / buf_patch . hpp <nl> ppp b / src / buffer_cache / buf_patch . hpp <nl> class buf_patch_t { <nl> DISABLE_COPYING ( buf_patch_t ) ; <nl> } ; <nl> <nl> - / * Binary patches * / <nl> - <nl> - / * memcpy_patch_t copies n bytes from src to the offset dest_offset of a buffer * / <nl> - class memcpy_patch_t : public buf_patch_t { <nl> - public : <nl> - memcpy_patch_t ( block_id_t block_id , uint16_t dest_offset , const char * src , uint16_t n ) ; <nl> - memcpy_patch_t ( block_id_t block_id , const char * data , uint16_t data_length ) ; <nl> - <nl> - virtual ~ memcpy_patch_t ( ) ; <nl> - <nl> - virtual void apply_to_buf ( char * buf_data , block_size_t bs ) ; <nl> - <nl> - protected : <nl> - virtual void serialize_data ( char * destination ) const ; <nl> - virtual uint16_t get_data_size ( ) const ; <nl> - <nl> - private : <nl> - uint16_t dest_offset ; <nl> - scoped_array_t < char > src_buf ; <nl> - } ; <nl> - <nl> - / * memove_patch_t moves data from src_offset to dest_offset within a single buffer ( with semantics equivalent to memmove ( ) ) * / <nl> - class memmove_patch_t : public buf_patch_t { <nl> - public : <nl> - memmove_patch_t ( block_id_t block_id , uint16_t dest_offset , uint16_t src_offset , uint16_t n ) ; <nl> - memmove_patch_t ( block_id_t block_id , const char * data , uint16_t data_length ) ; <nl> - <nl> - virtual void apply_to_buf ( char * buf_data , block_size_t bs ) ; <nl> - <nl> - virtual uint16_t get_data_size ( ) const ; <nl> - <nl> - protected : <nl> - virtual void serialize_data ( char * destination ) const ; <nl> - <nl> - private : <nl> - uint16_t dest_offset ; <nl> - uint16_t src_offset ; <nl> - uint16_t n ; <nl> - } ; <nl> - <nl> # endif / * BUFFER_CACHE_BUF_PATCH_HPP_ * / <nl> <nl> mmm a / src / buffer_cache / mirrored / mirrored . cc <nl> ppp b / src / buffer_cache / mirrored / mirrored . cc <nl> void mc_buf_lock_t : : mark_deleted ( ) { <nl> ensure_flush ( ) ; / / Disable patch log system for the buffer <nl> } <nl> <nl> - bool ptr_in_byte_range ( const void * p , const void * range_start , size_t size_in_bytes ) { <nl> - const uint8_t * p8 = reinterpret_cast < const uint8_t * > ( p ) ; <nl> - const uint8_t * range8 = reinterpret_cast < const uint8_t * > ( range_start ) ; <nl> - return range8 < = p8 & & p8 < range8 + size_in_bytes ; <nl> - } <nl> - <nl> - bool range_inside_of_byte_range ( const void * p , size_t n_bytes , const void * range_start , size_t size_in_bytes ) { <nl> - const uint8_t * p8 = reinterpret_cast < const uint8_t * > ( p ) ; <nl> - return ptr_in_byte_range ( p , range_start , size_in_bytes ) & & <nl> - ( n_bytes = = 0 | | ptr_in_byte_range ( p8 + n_bytes - 1 , range_start , size_in_bytes ) ) ; <nl> - } <nl> - <nl> / / Personally I ' d be happier if these functions took offsets . That ' s <nl> / / a sort of long - term TODO , though . <nl> / / <nl> mmm a / src / buffer_cache / mock . cc <nl> ppp b / src / buffer_cache / mock . cc <nl> void mock_buf_lock_t : : apply_patch ( buf_patch_t * patch ) { <nl> } <nl> <nl> void mock_buf_lock_t : : set_data ( void * dest , const void * src , const size_t n ) { <nl> - size_t offset = reinterpret_cast < const char * > ( dest ) - reinterpret_cast < const char * > ( internal_buf - > data ) ; <nl> - apply_patch ( new memcpy_patch_t ( internal_buf - > block_id , offset , reinterpret_cast < const char * > ( src ) , n ) ) ; <nl> + void * const data = get_data_major_write ( ) ; <nl> + <nl> + rassert ( range_inside_of_byte_range ( dest , n , data , internal_buf - > cache - > block_size . value ( ) ) ) ; <nl> + <nl> + memcpy ( dest , src , n ) ; <nl> } <nl> <nl> void mock_buf_lock_t : : move_data ( void * dest , const void * src , const size_t n ) { <nl> - size_t dest_offset = reinterpret_cast < const char * > ( dest ) - reinterpret_cast < const char * > ( internal_buf - > data ) ; <nl> - size_t src_offset = reinterpret_cast < const char * > ( src ) - reinterpret_cast < const char * > ( internal_buf - > data ) ; <nl> - apply_patch ( new memmove_patch_t ( internal_buf - > block_id , dest_offset , src_offset , n ) ) ; <nl> + void * const data = get_data_major_write ( ) ; <nl> + const size_t block_size = internal_buf - > cache - > block_size . value ( ) ; <nl> + <nl> + rassert ( range_inside_of_byte_range ( src , n , data , block_size ) ) ; <nl> + rassert ( range_inside_of_byte_range ( dest , n , data , block_size ) ) ; <nl> + <nl> + memmove ( dest , src , n ) ; <nl> } <nl> <nl> void mock_buf_lock_t : : mark_deleted ( ) { <nl> mmm a / src / utils . cc <nl> ppp b / src / utils . cc <nl> int get_num_db_threads ( ) { <nl> } <nl> <nl> <nl> + bool ptr_in_byte_range ( const void * p , const void * range_start , size_t size_in_bytes ) { <nl> + const uint8_t * p8 = reinterpret_cast < const uint8_t * > ( p ) ; <nl> + const uint8_t * range8 = reinterpret_cast < const uint8_t * > ( range_start ) ; <nl> + return range8 < = p8 & & p8 < range8 + size_in_bytes ; <nl> + } <nl> + <nl> + bool range_inside_of_byte_range ( const void * p , size_t n_bytes , const void * range_start , size_t size_in_bytes ) { <nl> + const uint8_t * p8 = reinterpret_cast < const uint8_t * > ( p ) ; <nl> + return ptr_in_byte_range ( p , range_start , size_in_bytes ) & & <nl> + ( n_bytes = = 0 | | ptr_in_byte_range ( p8 + n_bytes - 1 , range_start , size_in_bytes ) ) ; <nl> + } <nl> + <nl> + <nl> + <nl> + <nl> / / GCC and CLANG are smart enough to optimize out strlen ( " " ) , so this works . <nl> / / This is the simplist thing I could find that gave warning in all of these <nl> / / cases : <nl> mmm a / src / utils . hpp <nl> ppp b / src / utils . hpp <nl> class serializer_filepath_t { <nl> <nl> <nl> <nl> + bool ptr_in_byte_range ( const void * p , const void * range_start , size_t size_in_bytes ) ; <nl> + bool range_inside_of_byte_range ( const void * p , size_t n_bytes , const void * range_start , size_t size_in_bytes ) ; <nl> + <nl> + <nl> + <nl> # define STR ( x ) # x <nl> # define MSTR ( x ) STR ( x ) / / Stringify a macro <nl> # if defined __clang__ <nl>
Removed memcpy_patch_t and memmove_patch_t .
rethinkdb/rethinkdb
ab468bbba29042e46d922038640aac9029b271c0
2013-02-18T13:23:22Z
mmm a / editor / editor_profiler . cpp <nl> ppp b / editor / editor_profiler . cpp <nl> void EditorProfiler : : _update_frame ( ) { <nl> category - > set_custom_color ( 0 , _get_color_from_signature ( m . categories [ i ] . signature ) ) ; <nl> } <nl> <nl> - for ( int j = 0 ; j < m . categories [ i ] . items . size ( ) ; j + + ) { <nl> + for ( int j = m . categories [ i ] . items . size ( ) - 1 ; j > = 0 ; j - - ) { <nl> const Metric : : Category : : Item & it = m . categories [ i ] . items [ j ] ; <nl> <nl> TreeItem * item = variables - > create_item ( category ) ; <nl>
Merge pull request from Ranoller / patch - 5
godotengine/godot
d9268265dcc19ac7e61629f51783d30750eb80e8
2019-01-26T19:44:10Z
mmm a / tools / extra / parselog . sh <nl> ppp b / tools / extra / parselog . sh <nl> <nl> # It creates two files one caffe . log . test that contains the loss and test accuracy of the test and <nl> # another one caffe . log . loss that contains the loss computed during the training <nl> <nl> + # get the dirname of the script <nl> + DIR = " $ ( cd " $ ( dirname " $ { BASH_SOURCE [ 0 ] } " ) " & & pwd ) " <nl> + <nl> if [ " $ # " - lt 1 ] <nl> then <nl> echo " Usage parselog . sh / path / to / your . log " <nl> grep ' Test score # 1 ' aux . txt | awk ' { print $ 8 } ' > aux2 . txt <nl> # For extraction of time since this line constains the start time <nl> grep ' ] Solving ' $ 1 > aux3 . txt <nl> grep ' Testing net ' $ 1 > > aux3 . txt <nl> - . / extract_seconds . py aux3 . txt aux4 . txt <nl> + $ DIR / extract_seconds . py aux3 . txt aux4 . txt <nl> <nl> # Generating <nl> echo ' # Iters Seconds TestAccuracy TestLoss ' > $ LOG . test <nl> grep ' , loss = ' $ 1 | awk ' { print $ 9 } ' > aux1 . txt <nl> grep ' , lr = ' $ 1 | awk ' { print $ 9 } ' > aux2 . txt <nl> <nl> # Extracting elpased seconds <nl> - . / extract_seconds . py aux . txt aux3 . txt <nl> + $ DIR / extract_seconds . py aux . txt aux3 . txt <nl> <nl> # Generating <nl> echo ' # Iters Seconds TrainingLoss LearningRate ' > $ LOG . train <nl> mmm a / tools / extra / plot_training_log . py . example <nl> ppp b / tools / extra / plot_training_log . py . example <nl> <nl> # ! / usr / bin / env python <nl> + import inspect <nl> import os <nl> import random <nl> import sys <nl> import matplotlib . legend as lgd <nl> import matplotlib . markers as mks <nl> <nl> def get_log_parsing_script ( ) : <nl> - return ' . / parselog . sh ' <nl> + dirname = os . path . dirname ( os . path . abspath ( inspect . getfile ( inspect . currentframe ( ) ) ) ) <nl> + return dirname + ' / parselog . sh ' <nl> <nl> def get_log_file_suffix ( ) : <nl> return ' . log ' <nl> def is_x_axis_field ( field ) : <nl> return field in x_axis_fields <nl> <nl> def create_field_index ( ) : <nl> - train_key = ' Training ' <nl> + train_key = ' Train ' <nl> test_key = ' Test ' <nl> field_index = { train_key : { ' Iters ' : 0 , ' Seconds ' : 1 , train_key + ' loss ' : 2 , <nl> train_key + ' learning rate ' : 3 } , <nl> def get_data_file_type ( chart_type ) : <nl> return data_file_type <nl> <nl> def get_data_file ( chart_type , path_to_log ) : <nl> - return path_to_log + ' . ' + get_data_file_type ( chart_type ) . lower ( ) <nl> + return os . path . basename ( path_to_log ) + ' . ' + get_data_file_type ( chart_type ) . lower ( ) <nl> <nl> def get_field_descriptions ( chart_type ) : <nl> description = get_chart_type_description ( chart_type ) . split ( <nl>
Merge pull request from chyojn / absolute_path_of_script
BVLC/caffe
b84e0f36e940e479a32a62109067b3e82cd034a6
2014-02-28T18:42:02Z
mmm a / tensorflow / python / ops / structured / BUILD <nl> ppp b / tensorflow / python / ops / structured / BUILD <nl> py_test ( <nl> " @ absl_py / / absl / testing : parameterized " , <nl> ] , <nl> ) <nl> + <nl> + py_test ( <nl> + name = " structured_tensor_slice_test " , <nl> + srcs = [ " structured_tensor_slice_test . py " ] , <nl> + deps = [ <nl> + " : structured_tensor " , <nl> + " / / tensorflow / python : framework_ops " , <nl> + " / / tensorflow / python : framework_test_lib " , <nl> + " / / tensorflow / python : sparse_tensor " , <nl> + " / / tensorflow / python : tensor_shape " , <nl> + " / / tensorflow / python / ops / ragged : ragged_factory_ops " , <nl> + " / / tensorflow / python / ops / ragged : ragged_tensor " , <nl> + " @ absl_py / / absl / testing : parameterized " , <nl> + ] , <nl> + ) <nl> mmm a / tensorflow / python / ops / structured / structured_tensor . py <nl> ppp b / tensorflow / python / ops / structured / structured_tensor . py <nl> <nl> from tensorflow . python . ops . ragged import ragged_factory_ops <nl> from tensorflow . python . ops . ragged import ragged_tensor <nl> from tensorflow . python . ops . ragged import ragged_util <nl> + from tensorflow . python . util import compat <nl> from tensorflow . python . util import nest <nl> <nl> <nl> def field_value ( self , field_name ) : <nl> return value <nl> return self . _fields [ field_name ] <nl> <nl> + # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + # Operators <nl> + # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + <nl> + # TODO ( edloper ) : Add support for ellipsis and / or newaxis ? <nl> + def __getitem__ ( self , key ) : <nl> + " " " Returns the specified piece of this StructuredTensor . <nl> + <nl> + * If ` struct_tensor ` is scalar ( i . e . , a single structure ) , then <nl> + ` struct_tensor [ f ] ` returns the value of field ` f ` ( where ` f ` must be a <nl> + string ) . <nl> + <nl> + * If ` struct_tensor ` is non - scalar ( i . e . , a vector or higher - dimensional <nl> + tensor of structures ) , ` struct_tensor [ i ] ` selects an element or slice of <nl> + the tensor using standard Python semantics ( e . g . , negative values index <nl> + from the end ) . ` i ` may have any of the following types : <nl> + <nl> + * ` int ` constant <nl> + * ` string ` constant <nl> + * scalar integer ` Tensor ` <nl> + * ` slice ` containing integer constants and / or scalar integer <nl> + ` Tensor ` s <nl> + <nl> + # # # # Multidimensional indexing <nl> + <nl> + ` StructuredTensor ` supports multidimensional indexing . I . e . , ` key ` may be a <nl> + ` tuple ` of values , indexing or slicing multiple dimensions at once . For <nl> + example , if ` people ` is a vector of structures , each of which has a vector - <nl> + valued ` names ` field , then ` people [ 3 , ' names ' , 0 ] ` is equivalent to <nl> + ` people [ 3 ] [ ' names ' ] [ 0 ] ` ; and ` people [ : , ' names ' , : ] ` will return a ( possibly <nl> + ragged ) matrix of names , with shape ` [ num_people , num_names_per_person ] ` . <nl> + <nl> + Args : <nl> + key : Indicates which piece of the StructuredTensor to return . <nl> + Returns : <nl> + A ` Tensor ` , ` StructuredTensor ` , or ` RaggedTensor ` . <nl> + " " " <nl> + if isinstance ( key , list ) : <nl> + key = tuple ( key ) <nl> + elif not isinstance ( key , tuple ) : <nl> + key = ( key , ) <nl> + if not key : <nl> + return self <nl> + <nl> + if self . _static_shape . ndims = = 0 : <nl> + return self . _scalar_getitem ( key ) <nl> + else : <nl> + return self . _tensor_getitem ( key ) <nl> + <nl> + def _scalar_getitem ( self , key ) : <nl> + if ( isinstance ( key [ 0 ] , slice ) and slice . start is None and <nl> + slice . stop is None and slice . step is None ) : <nl> + fields = dict ( ( field_name , field_value . __getitem__ ( key [ 1 : ] ) ) <nl> + for ( field_name , field_value ) in self . _fields . items ( ) ) <nl> + return StructuredTensor ( self . _static_shape [ 1 : ] , fields ) <nl> + <nl> + elif not isinstance ( key [ 0 ] , compat . bytes_or_text_types ) : <nl> + raise ValueError ( ' Key for indexing a StructuredTensor must be a ' <nl> + " string or a full slice ( ' : ' ) " ) <nl> + <nl> + return self . _fields [ key [ 0 ] ] . __getitem__ ( key [ 1 : ] ) <nl> + <nl> + def _tensor_getitem ( self , key ) : <nl> + rank = self . _static_shape . ndims <nl> + if len ( key ) < = rank : <nl> + new_fields = dict ( ( field_name , field_value . __getitem__ ( key ) ) <nl> + for ( field_name , field_value ) in self . _fields . items ( ) ) <nl> + result_shape = self . shape . as_list ( ) <nl> + for d , k in enumerate ( key ) : <nl> + if isinstance ( k , slice ) : <nl> + if not ( k . start is None and k . stop is None and k . step is None ) : <nl> + # TODO ( edloper ) : Better static shape analysis here . <nl> + result_shape [ d ] = None <nl> + elif isinstance ( k , ( int , ops . Tensor ) ) : <nl> + result_shape [ d ] = - 1 # mark for deletion <nl> + else : <nl> + # Ellipsis , tf . newaxis : <nl> + raise ValueError ( ' Slicing not supported for % r ' % k ) <nl> + result_shape = [ d for d in result_shape if d ! = - 1 ] <nl> + return StructuredTensor ( result_shape , new_fields ) <nl> + <nl> + else : <nl> + if not isinstance ( key [ rank ] , compat . bytes_or_text_types ) : <nl> + raise ValueError ( ' Key for indexing a StructuredTensor must be a string ' ) <nl> + return self . _fields [ key [ rank ] ] . __getitem__ ( key [ : rank ] + key [ rank + 1 : ] ) <nl> + <nl> def __repr__ ( self ) : <nl> if self . _is_eager ( ) and False : <nl> return ' < StructuredTensor % s > ' % self . to_pyval ( ) <nl> new file mode 100644 <nl> index 0000000000000 . . e4011f20e30bf <nl> mmm / dev / null <nl> ppp b / tensorflow / python / ops / structured / structured_tensor_slice_test . py <nl> <nl> + # Copyright 2019 The TensorFlow Authors . All Rights Reserved . <nl> + # <nl> + # Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + # you may not use this file except in compliance with the License . <nl> + # You may obtain a copy of the License at <nl> + # <nl> + # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + # <nl> + # Unless required by applicable law or agreed to in writing , software <nl> + # distributed under the License is distributed on an " AS IS " BASIS , <nl> + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + # See the License for the specific language governing permissions and <nl> + # limitations under the License . <nl> + # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + " " " Tests for StructuredTensor . " " " <nl> + <nl> + from __future__ import absolute_import <nl> + from __future__ import division <nl> + from __future__ import print_function <nl> + <nl> + from absl . testing import parameterized <nl> + <nl> + from tensorflow . python . framework import constant_op <nl> + from tensorflow . python . framework import dtypes <nl> + from tensorflow . python . framework import tensor_shape <nl> + from tensorflow . python . framework import tensor_spec <nl> + from tensorflow . python . framework import test_util <nl> + from tensorflow . python . ops import array_ops <nl> + from tensorflow . python . ops . structured import structured_tensor <nl> + from tensorflow . python . platform import googletest <nl> + <nl> + <nl> + # TODO ( edloper ) : Move this to a common util package ( forked from ragged ) . <nl> + class _SliceBuilder ( object ) : <nl> + " " " Helper to construct arguments for __getitem__ . <nl> + <nl> + Usage : _SliceBuilder ( ) [ < expr > ] slice_spec Python generates for < expr > . <nl> + " " " <nl> + <nl> + def __getitem__ ( self , slice_spec ) : <nl> + return slice_spec <nl> + <nl> + <nl> + # TODO ( edloper ) : Move this to a common util package ( forked from ragged ) . <nl> + SLICE_BUILDER = _SliceBuilder ( ) <nl> + <nl> + <nl> + # TODO ( edloper ) : Move this to a common util package ( forked from ragged ) . <nl> + def _make_tensor_slice_spec ( slice_spec , use_constant = True ) : <nl> + " " " Wraps all integers in an extended slice spec w / a tensor . <nl> + <nl> + This function is used to help test slicing when the slice spec contains <nl> + tensors , rather than integers . <nl> + <nl> + Args : <nl> + slice_spec : The extended slice spec . <nl> + use_constant : If true , then wrap each integer with a tf . constant . If false , <nl> + then wrap each integer with a tf . placeholder . <nl> + <nl> + Returns : <nl> + A copy of slice_spec , but with each integer i replaced with tf . constant ( i ) . <nl> + " " " <nl> + <nl> + def make_piece_scalar ( piece ) : <nl> + if isinstance ( piece , int ) : <nl> + scalar = constant_op . constant ( piece ) <nl> + if use_constant : <nl> + return scalar <nl> + else : <nl> + return array_ops . placeholder_with_default ( scalar , [ ] ) <nl> + elif isinstance ( piece , slice ) : <nl> + return slice ( <nl> + make_piece_scalar ( piece . start ) , make_piece_scalar ( piece . stop ) , <nl> + make_piece_scalar ( piece . step ) ) <nl> + else : <nl> + return piece <nl> + <nl> + if isinstance ( slice_spec , tuple ) : <nl> + return tuple ( make_piece_scalar ( piece ) for piece in slice_spec ) <nl> + else : <nl> + return make_piece_scalar ( slice_spec ) <nl> + <nl> + <nl> + EXAMPLE_STRUCT = { <nl> + # f1 : scalar value field <nl> + " f1 " : 1 , <nl> + # f2 : matrix field <nl> + " f2 " : [ [ 1 , 2 ] , [ 3 , 4 ] ] , <nl> + # f3 : scalar structure field <nl> + " f3 " : { " f3_1 " : 1 } , <nl> + # f4 : vector structure field <nl> + " f4 " : [ { " f4_1 " : 1 , " f4_2 " : b " a " } , { " f4_1 " : 2 , " f4_2 " : b " b " } ] , <nl> + # f5 : matrix structure field <nl> + " f5 " : [ [ { " f5_1 " : 1 } , { " f5_1 " : 2 } ] , [ { " f5_1 " : 3 } , { " f5_1 " : 4 } ] ] , <nl> + } <nl> + <nl> + EXAMPLE_STRUCT_2 = { <nl> + # f1 : scalar value field <nl> + " f1 " : 5 , <nl> + # f2 : matrix field <nl> + " f2 " : [ [ 6 , 7 ] , [ 8 , 9 ] ] , <nl> + # f3 : scalar structure field <nl> + " f3 " : { " f3_1 " : 9 } , <nl> + # f4 : vector structure field <nl> + " f4 " : [ { " f4_1 " : 5 , " f4_2 " : b " A " } , { " f4_1 " : 6 , " f4_2 " : b " B " } ] , <nl> + # f5 : matrix structure field <nl> + " f5 " : [ [ { " f5_1 " : 6 } , { " f5_1 " : 7 } ] , [ { " f5_1 " : 8 } , { " f5_1 " : 9 } ] ] , <nl> + } <nl> + <nl> + EXAMPLE_STRUCT_VECTOR = [ EXAMPLE_STRUCT ] * 5 + [ EXAMPLE_STRUCT_2 ] <nl> + <nl> + EXAMPLE_STRUCT_SPEC1 = structured_tensor . StructuredTensorSpec ( [ ] , { <nl> + " f1 " : tensor_spec . TensorSpec ( [ ] , dtypes . int32 ) , <nl> + " f2 " : tensor_spec . TensorSpec ( [ 2 , 2 ] , dtypes . int32 ) , <nl> + " f3 " : structured_tensor . StructuredTensorSpec ( <nl> + [ ] , { " f3_1 " : tensor_spec . TensorSpec ( [ ] , dtypes . int32 ) } ) , <nl> + " f4 " : structured_tensor . StructuredTensorSpec ( <nl> + [ 2 ] , { " f4_1 " : tensor_spec . TensorSpec ( [ 2 ] , dtypes . int32 ) , <nl> + " f4_2 " : tensor_spec . TensorSpec ( [ 2 ] , dtypes . string ) } ) , <nl> + " f5 " : structured_tensor . StructuredTensorSpec ( <nl> + [ 2 , 2 ] , { " f5_1 " : tensor_spec . TensorSpec ( [ 2 , 2 ] , dtypes . int32 ) } ) , <nl> + } ) <nl> + <nl> + <nl> + @ test_util . run_all_in_graph_and_eager_modes <nl> + class StructuredTensorSliceTest ( test_util . TensorFlowTestCase , <nl> + parameterized . TestCase ) : <nl> + <nl> + def assertAllEqual ( self , a , b , msg = None ) : <nl> + if not ( isinstance ( a , structured_tensor . StructuredTensor ) or <nl> + isinstance ( b , structured_tensor . StructuredTensor ) ) : <nl> + super ( StructuredTensorSliceTest , self ) . assertAllEqual ( a , b , msg ) <nl> + elif ( isinstance ( a , structured_tensor . StructuredTensor ) and <nl> + isinstance ( b , structured_tensor . StructuredTensor ) ) : <nl> + a_shape = tensor_shape . as_shape ( a . shape ) <nl> + b_shape = tensor_shape . as_shape ( b . shape ) <nl> + a_shape . assert_is_compatible_with ( b_shape ) <nl> + self . assertEqual ( set ( a . field_names ( ) ) , set ( b . field_names ( ) ) ) <nl> + for field in a . field_names ( ) : <nl> + self . assertAllEqual ( a . field_value ( field ) , b . field_value ( field ) ) <nl> + elif isinstance ( b , structured_tensor . StructuredTensor ) : <nl> + self . assertAllEqual ( b , a , msg ) <nl> + else : <nl> + if a . rank = = 0 : <nl> + self . assertIsInstance ( b , dict ) <nl> + self . assertEqual ( set ( a . field_names ( ) ) , set ( b ) ) <nl> + for ( key , b_val ) in b . items ( ) : <nl> + a_val = a . field_value ( key ) <nl> + self . assertAllEqual ( a_val , b_val ) <nl> + else : <nl> + self . assertIsInstance ( b , ( list , tuple ) ) <nl> + a . shape [ : 1 ] . assert_is_compatible_with ( [ len ( b ) ] ) <nl> + for i in range ( len ( b ) ) : <nl> + self . assertAllEqual ( a [ i ] , b [ i ] ) <nl> + <nl> + def _TestGetItem ( self , struct , slice_spec , expected ) : <nl> + " " " Helper function for testing StructuredTensor . __getitem__ . <nl> + <nl> + Checks that calling ` struct . __getitem__ ( slice_spec ) returns the expected <nl> + value . Checks three different configurations for each slice spec : <nl> + <nl> + * Call __getitem__ with the slice spec as - is ( with int values ) <nl> + * Call __getitem__ with int values in the slice spec wrapped in <nl> + ` tf . constant ( ) ` . <nl> + * Call __getitem__ with int values in the slice spec wrapped in <nl> + ` tf . compat . v1 . placeholder ( ) ` ( so value is not known at graph <nl> + construction time ) . <nl> + <nl> + Args : <nl> + struct : The StructuredTensor to test . <nl> + slice_spec : The slice spec . <nl> + expected : The expected value of struct . __getitem__ ( slice_spec ) , as a <nl> + python list . <nl> + " " " <nl> + tensor_slice_spec1 = _make_tensor_slice_spec ( slice_spec , True ) <nl> + tensor_slice_spec2 = _make_tensor_slice_spec ( slice_spec , False ) <nl> + value1 = struct . __getitem__ ( slice_spec ) <nl> + value2 = struct . __getitem__ ( tensor_slice_spec1 ) <nl> + value3 = struct . __getitem__ ( tensor_slice_spec2 ) <nl> + self . assertAllEqual ( value1 , expected , " slice_spec = % s " % ( slice_spec , ) ) <nl> + self . assertAllEqual ( value2 , expected , " slice_spec = % s " % ( slice_spec , ) ) <nl> + self . assertAllEqual ( value3 , expected , " slice_spec = % s " % ( slice_spec , ) ) <nl> + <nl> + @ parameterized . parameters ( [ <nl> + # Simple indexing <nl> + ( SLICE_BUILDER [ " f1 " ] , EXAMPLE_STRUCT [ " f1 " ] ) , <nl> + ( SLICE_BUILDER [ " f2 " ] , EXAMPLE_STRUCT [ " f2 " ] ) , <nl> + ( SLICE_BUILDER [ " f3 " ] , EXAMPLE_STRUCT [ " f3 " ] ) , <nl> + ( SLICE_BUILDER [ " f4 " ] , EXAMPLE_STRUCT [ " f4 " ] ) , <nl> + ( SLICE_BUILDER [ " f5 " ] , EXAMPLE_STRUCT [ " f5 " ] ) , <nl> + # Multidimensional indexing <nl> + ( SLICE_BUILDER [ " f2 " , 1 ] , EXAMPLE_STRUCT [ " f2 " ] [ 1 ] ) , <nl> + ( SLICE_BUILDER [ " f3 " , " f3_1 " ] , EXAMPLE_STRUCT [ " f3 " ] [ " f3_1 " ] ) , <nl> + ( SLICE_BUILDER [ " f4 " , 1 ] , EXAMPLE_STRUCT [ " f4 " ] [ 1 ] ) , <nl> + ( SLICE_BUILDER [ " f4 " , 1 , " f4_2 " ] , EXAMPLE_STRUCT [ " f4 " ] [ 1 ] [ " f4_2 " ] ) , <nl> + ( SLICE_BUILDER [ " f5 " , 0 , 1 ] , EXAMPLE_STRUCT [ " f5 " ] [ 0 ] [ 1 ] ) , <nl> + ( SLICE_BUILDER [ " f5 " , 0 , 1 , " f5_1 " ] , EXAMPLE_STRUCT [ " f5 " ] [ 0 ] [ 1 ] [ " f5_1 " ] ) , <nl> + # Multidimensional slicing <nl> + ( SLICE_BUILDER [ " f2 " , 1 : ] , EXAMPLE_STRUCT [ " f2 " ] [ 1 : ] ) , <nl> + ( SLICE_BUILDER [ " f4 " , : 1 ] , EXAMPLE_STRUCT [ " f4 " ] [ : 1 ] ) , <nl> + ( SLICE_BUILDER [ " f4 " , 1 : , " f4_2 " ] , [ b " b " ] ) , <nl> + ( SLICE_BUILDER [ " f4 " , : , " f4_2 " ] , [ b " a " , b " b " ] ) , <nl> + ( SLICE_BUILDER [ " f5 " , : , : , " f5_1 " ] , [ [ 1 , 2 ] , [ 3 , 4 ] ] ) , <nl> + ] ) <nl> + def testGetitemFromScalarStruct ( self , slice_spec , expected ) : <nl> + # By default , lists are converted to RaggedTensors . <nl> + struct = structured_tensor . StructuredTensor . from_pyval ( EXAMPLE_STRUCT ) <nl> + self . _TestGetItem ( struct , slice_spec , expected ) <nl> + <nl> + # Using an explicit TypeSpec , we can convert them to Tensors instead . <nl> + struct2 = structured_tensor . StructuredTensor . from_pyval ( <nl> + EXAMPLE_STRUCT , EXAMPLE_STRUCT_SPEC1 ) <nl> + self . _TestGetItem ( struct2 , slice_spec , expected ) <nl> + <nl> + @ parameterized . parameters ( [ <nl> + ( SLICE_BUILDER [ 2 ] , EXAMPLE_STRUCT_VECTOR [ 2 ] ) , <nl> + ( SLICE_BUILDER [ 5 ] , EXAMPLE_STRUCT_VECTOR [ 5 ] ) , <nl> + ( SLICE_BUILDER [ - 2 ] , EXAMPLE_STRUCT_VECTOR [ - 2 ] ) , <nl> + ( SLICE_BUILDER [ - 1 ] , EXAMPLE_STRUCT_VECTOR [ - 1 ] ) , <nl> + ( SLICE_BUILDER [ 2 , " f1 " ] , EXAMPLE_STRUCT_VECTOR [ 2 ] [ " f1 " ] ) , <nl> + ( SLICE_BUILDER [ - 1 , " f1 " ] , EXAMPLE_STRUCT_VECTOR [ - 1 ] [ " f1 " ] ) , <nl> + ( SLICE_BUILDER [ 5 : ] , EXAMPLE_STRUCT_VECTOR [ 5 : ] ) , <nl> + ( SLICE_BUILDER [ 3 : , " f1 " ] , [ 1 , 1 , 5 ] ) , <nl> + ( SLICE_BUILDER [ : : 2 , " f1 " ] , [ 1 , 1 , 1 ] ) , <nl> + ( SLICE_BUILDER [ 1 : : 2 , " f1 " ] , [ 1 , 1 , 5 ] ) , <nl> + ( SLICE_BUILDER [ 4 : , " f5 " , 0 , 1 , " f5_1 " ] , [ 2 , 7 ] , True ) , <nl> + ( SLICE_BUILDER [ 4 : , " f5 " , : , : , " f5_1 " ] , <nl> + [ [ [ 1 , 2 ] , [ 3 , 4 ] ] , [ [ 6 , 7 ] , [ 8 , 9 ] ] ] ) , <nl> + ] ) # pyformat : disable <nl> + def testGetitemFromVectorStruct ( self , slice_spec , expected , <nl> + test_requires_typespec = False ) : <nl> + # By default , lists are converted to RaggedTensors . <nl> + if not test_requires_typespec : <nl> + struct_vector = structured_tensor . StructuredTensor . from_pyval ( <nl> + EXAMPLE_STRUCT_VECTOR ) <nl> + self . _TestGetItem ( struct_vector , slice_spec , expected ) <nl> + <nl> + # Using an explicit TypeSpec , we can convert them to Tensors instead . <nl> + struct_vector2 = structured_tensor . StructuredTensor . from_pyval ( <nl> + EXAMPLE_STRUCT_VECTOR , EXAMPLE_STRUCT_SPEC1 . _batch ( 6 ) ) <nl> + self . _TestGetItem ( struct_vector2 , slice_spec , expected ) <nl> + <nl> + # TODO ( edloper ) : Add tests for slicing from matrix StructuredTensors . <nl> + <nl> + <nl> + if __name__ = = " __main__ " : <nl> + googletest . main ( ) <nl>
StructuredTensor : Add slicing ( __getitem__ )
tensorflow/tensorflow
7cdc3da706d7717850c1f2e69798969919015a09
2019-10-12T04:52:32Z
mmm a / test / fuzz / fuzz_runner . cc <nl> ppp b / test / fuzz / fuzz_runner . cc <nl> <nl> namespace Envoy { <nl> namespace Fuzz { <nl> <nl> - void Runner : : setupEnvironment ( int argc , char * * argv ) { <nl> + spdlog : : level : : level_enum Runner : : log_level_ ; <nl> + <nl> + void Runner : : setupEnvironment ( int argc , char * * argv , spdlog : : level : : level_enum default_log_level ) { <nl> Event : : Libevent : : Global : : initialize ( ) ; <nl> <nl> TestEnvironment : : initializeOptions ( argc , argv ) ; <nl> <nl> static auto * lock = new Thread : : MutexBasicLockable ( ) ; <nl> const auto environment_log_level = TestEnvironment : : getOptions ( ) . logLevel ( ) ; <nl> - Logger : : Registry : : initialize ( std : : min ( environment_log_level , spdlog : : level : : info ) , <nl> - TestEnvironment : : getOptions ( ) . logFormat ( ) , * lock ) ; <nl> + / / We only override the default log level if it looks like we ' re debugging ; <nl> + / / otherwise the default environment log level might override the default and <nl> + / / spew too much when running under a fuzz engine . <nl> + log_level_ = <nl> + environment_log_level < = spdlog : : level : : debug ? environment_log_level : default_log_level ; <nl> + Logger : : Registry : : initialize ( log_level_ , TestEnvironment : : getOptions ( ) . logFormat ( ) , * lock ) ; <nl> } <nl> <nl> } / / namespace Fuzz <nl> } / / namespace Envoy <nl> <nl> extern " C " int LLVMFuzzerInitialize ( int * / * argc * / , char * * * argv ) { <nl> - Envoy : : Fuzz : : Runner : : setupEnvironment ( 1 , * argv ) ; <nl> + Envoy : : Fuzz : : Runner : : setupEnvironment ( 1 , * argv , spdlog : : level : : off ) ; <nl> return 0 ; <nl> } <nl> mmm a / test / fuzz / fuzz_runner . h <nl> ppp b / test / fuzz / fuzz_runner . h <nl> <nl> / / Bring in DEFINE_PROTO_FUZZER definition as per <nl> / / https : / / github . com / google / libprotobuf - mutator # integrating - with - libfuzzer . <nl> # include " libprotobuf_mutator / src / libfuzzer / libfuzzer_macro . h " <nl> + # include " spdlog / spdlog . h " <nl> <nl> namespace Envoy { <nl> namespace Fuzz { <nl> class Runner { <nl> * invoked in this environment . <nl> * @ param argc number of command - line args . <nl> * @ param argv array of command - line args . <nl> + * @ param default_loglevel default log level ( overridable with - l ) . <nl> * / <nl> - static void setupEnvironment ( int argc , char * * argv ) ; <nl> + static void setupEnvironment ( int argc , char * * argv , spdlog : : level : : level_enum default_log_level ) ; <nl> + <nl> + / * * <nl> + * @ return spdlog : : level : : level_enum the log level for the fuzzer . <nl> + * / <nl> + static spdlog : : level : : level_enum logLevel ( ) { return log_level_ ; } <nl> + <nl> + private : <nl> + static spdlog : : level : : level_enum log_level_ ; <nl> } ; <nl> <nl> } / / namespace Fuzz <nl> mmm a / test / fuzz / main . cc <nl> ppp b / test / fuzz / main . cc <nl> int main ( int argc , char * * argv ) { <nl> RELEASE_ASSERT ( Envoy : : Filesystem : : directoryExists ( corpus_path ) , " " ) ; <nl> Envoy : : test_corpus_ = Envoy : : TestUtility : : listFiles ( corpus_path , true ) ; <nl> testing : : InitGoogleTest ( & argc , argv ) ; <nl> - Envoy : : Fuzz : : Runner : : setupEnvironment ( argc , argv ) ; <nl> + Envoy : : Fuzz : : Runner : : setupEnvironment ( argc , argv , spdlog : : level : : info ) ; <nl> return RUN_ALL_TESTS ( ) ; <nl> } <nl> mmm a / test / mocks / server / mocks . cc <nl> ppp b / test / mocks / server / mocks . cc <nl> MockOptions : : MockOptions ( const std : : string & config_path ) : config_path_ ( config_p <nl> ON_CALL ( * this , serviceClusterName ( ) ) . WillByDefault ( ReturnRef ( service_cluster_name_ ) ) ; <nl> ON_CALL ( * this , serviceNodeName ( ) ) . WillByDefault ( ReturnRef ( service_node_name_ ) ) ; <nl> ON_CALL ( * this , serviceZone ( ) ) . WillByDefault ( ReturnRef ( service_zone_name_ ) ) ; <nl> + ON_CALL ( * this , logLevel ( ) ) . WillByDefault ( Return ( log_level_ ) ) ; <nl> ON_CALL ( * this , logPath ( ) ) . WillByDefault ( ReturnRef ( log_path_ ) ) ; <nl> ON_CALL ( * this , maxStats ( ) ) . WillByDefault ( Return ( 1000 ) ) ; <nl> ON_CALL ( * this , statsOptions ( ) ) . WillByDefault ( ReturnRef ( stats_options_ ) ) ; <nl> mmm a / test / mocks / server / mocks . h <nl> ppp b / test / mocks / server / mocks . h <nl> class MockOptions : public Options { <nl> std : : string service_cluster_name_ ; <nl> std : : string service_node_name_ ; <nl> std : : string service_zone_name_ ; <nl> + spdlog : : level : : level_enum log_level_ { spdlog : : level : : trace } ; <nl> std : : string log_path_ ; <nl> Stats : : StatsOptionsImpl stats_options_ ; <nl> bool hot_restart_disabled_ { } ; <nl> mmm a / test / server / config_validation / config_fuzz_test . cc <nl> ppp b / test / server / config_validation / config_fuzz_test . cc <nl> DEFINE_PROTO_FUZZER ( const envoy : : config : : bootstrap : : v2 : : Bootstrap & input ) { <nl> bootstrap_file < < input . DebugString ( ) ; <nl> options . config_path_ = bootstrap_path ; <nl> options . v2_config_only_ = true ; <nl> + options . log_level_ = Fuzz : : Runner : : logLevel ( ) ; <nl> <nl> try { <nl> validateConfig ( options , Network : : Address : : InstanceConstSharedPtr ( ) , component_factory ) ; <nl> mmm a / test / server / server_fuzz_test . cc <nl> ppp b / test / server / server_fuzz_test . cc <nl> DEFINE_PROTO_FUZZER ( const envoy : : config : : bootstrap : : v2 : : Bootstrap & input ) { <nl> bootstrap_file < < input . DebugString ( ) ; <nl> options . config_path_ = bootstrap_path ; <nl> options . v2_config_only_ = true ; <nl> + options . log_level_ = Fuzz : : Runner : : logLevel ( ) ; <nl> } <nl> <nl> try { <nl>
fuzz : reduce log level when running under fuzz engine . ( )
envoyproxy/envoy
132302caffbf81bdc116ac44a880c3238b6ebe85
2018-08-16T15:43:31Z
mmm a / tensorflow / contrib / bigtable / README . md <nl> ppp b / tensorflow / contrib / bigtable / README . md <nl> If you encounter a log line that includes the following : <nl> " filename " : " / usr / share / grpc / roots . pem " <nl> ` ` ` <nl> <nl> - you likely need to copy the [ gRPC ` roots . pem ` file ] [ grpcPem ] to <nl> - ` / usr / share / grpc / roots . pem ` on your local machine . <nl> + you can solve it via either of the following approaches : <nl> + <nl> + * copy the [ gRPC ` roots . pem ` file ] [ grpcPem ] to <nl> + ` / usr / share / grpc / roots . pem ` on your local machine , which is the default <nl> + location where gRPC will look for this file <nl> + * export the environment variable ` GRPC_DEFAULT_SSL_ROOTS_FILE_PATH ` to point to <nl> + the full path of the gRPC ` roots . pem ` file on your file system if it ' s in a <nl> + different location <nl> <nl> [ grpcPem ] : https : / / github . com / grpc / grpc / blob / master / etc / roots . pem <nl> <nl>
Provide an alternative method to find gRPC ` roots . pem ` file , using an environment
tensorflow/tensorflow
8987d1cfd3c17eab4e28da376fdc718f53d82e19
2018-08-28T16:15:50Z
mmm a / . circleci / cimodel / data / windows_build_definitions . py <nl> ppp b / . circleci / cimodel / data / windows_build_definitions . py <nl> def TruePred ( _ ) : <nl> <nl> WORKFLOW_DATA = [ <nl> # VS2017 CUDA - 10 . 1 <nl> - WindowsJob ( None , VcSpec ( 2017 , [ " 14 " , " 11 " ] ) , CudaVersion ( 10 , 1 ) , master_only_pred = FalsePred ) , <nl> - WindowsJob ( 1 , VcSpec ( 2017 , [ " 14 " , " 11 " ] ) , CudaVersion ( 10 , 1 ) ) , <nl> + WindowsJob ( None , VcSpec ( 2017 , [ " 14 " , " 13 " ] ) , CudaVersion ( 10 , 1 ) , master_only_pred = FalsePred ) , <nl> + WindowsJob ( 1 , VcSpec ( 2017 , [ " 14 " , " 13 " ] ) , CudaVersion ( 10 , 1 ) ) , <nl> # VS2017 no - CUDA ( builds only ) <nl> WindowsJob ( None , VcSpec ( 2017 , [ " 14 " , " 16 " ] ) , CudaVersion ( 10 , 1 ) ) , <nl> WindowsJob ( None , VcSpec ( 2017 , [ " 14 " , " 16 " ] ) , None ) , <nl> mmm a / . circleci / config . yml <nl> ppp b / . circleci / config . yml <nl> pytorch_windows_params : & pytorch_windows_params <nl> default : " 3 . 6 " <nl> vc_version : <nl> type : string <nl> - default : " 14 . 11 " <nl> + default : " 14 . 13 " <nl> vc_year : <nl> type : string <nl> default : " 2017 " <nl> jobs : <nl> default : " 3 . 6 " <nl> vc_version : <nl> type : string <nl> - default : " 14 . 11 " <nl> + default : " 14 . 13 " <nl> vc_year : <nl> type : string <nl> default : " 2017 " <nl> jobs : <nl> default : " 3 . 6 " <nl> vc_version : <nl> type : string <nl> - default : " 14 . 11 " <nl> + default : " 14 . 13 " <nl> vc_year : <nl> type : string <nl> default : " 2017 " <nl> workflows : <nl> requires : <nl> - nightly_pytorch_linux_xenial_py3_clang5_android_ndk_r19c_android_gradle_build <nl> - pytorch_windows_build : <nl> - build_environment : pytorch - win - vs2017 - 14 - 11 - cuda10 - cudnn7 - py3 <nl> + build_environment : pytorch - win - vs2017 - 14 - 13 - cuda10 - cudnn7 - py3 <nl> cuda_version : " 10 " <nl> - name : pytorch_windows_vs2017_14 . 11_py36_cuda10 . 1_build <nl> + name : pytorch_windows_vs2017_14 . 13_py36_cuda10 . 1_build <nl> python_version : " 3 . 6 " <nl> use_cuda : " 1 " <nl> vc_product : BuildTools <nl> - vc_version : " 14 . 11 " <nl> + vc_version : " 14 . 13 " <nl> vc_year : " 2017 " <nl> - pytorch_windows_test : <nl> - build_environment : pytorch - win - vs2017 - 14 - 11 - cuda10 - cudnn7 - py3 <nl> + build_environment : pytorch - win - vs2017 - 14 - 13 - cuda10 - cudnn7 - py3 <nl> cuda_version : " 10 " <nl> executor : windows - with - nvidia - gpu <nl> filters : <nl> workflows : <nl> - master <nl> - / ci - all \ / . * / <nl> - / release \ / . * / <nl> - name : pytorch_windows_vs2017_14 . 11_py36_cuda10 . 1_test1 <nl> + name : pytorch_windows_vs2017_14 . 13_py36_cuda10 . 1_test1 <nl> python_version : " 3 . 6 " <nl> requires : <nl> - - pytorch_windows_vs2017_14 . 11_py36_cuda10 . 1_build <nl> + - pytorch_windows_vs2017_14 . 13_py36_cuda10 . 1_build <nl> test_name : pytorch - windows - test1 <nl> use_cuda : " 1 " <nl> vc_product : BuildTools <nl> - vc_version : " 14 . 11 " <nl> + vc_version : " 14 . 13 " <nl> vc_year : " 2017 " <nl> - pytorch_windows_build : <nl> build_environment : pytorch - win - vs2017 - 14 - 16 - cuda10 - cudnn7 - py3 <nl> mmm a / . circleci / scripts / vs_install . ps1 <nl> ppp b / . circleci / scripts / vs_install . ps1 <nl> <nl> $ VS_DOWNLOAD_LINK = " https : / / aka . ms / vs / 15 / release / vs_buildtools . exe " <nl> $ COLLECT_DOWNLOAD_LINK = " https : / / aka . ms / vscollect . exe " <nl> $ VS_INSTALL_ARGS = @ ( " - - nocache " , " - - quiet " , " - - wait " , " - - add Microsoft . VisualStudio . Workload . VCTools " , <nl> - " - - add Microsoft . VisualStudio . Component . VC . Tools . 14 . 11 " , <nl> + " - - add Microsoft . VisualStudio . Component . VC . Tools . 14 . 13 " , <nl> " - - add Microsoft . Component . MSBuild " , <nl> " - - add Microsoft . VisualStudio . Component . Roslyn . Compiler " , <nl> " - - add Microsoft . VisualStudio . Component . TextTemplating " , <nl> mmm a / . circleci / verbatim - sources / build - parameters / pytorch - build - params . yml <nl> ppp b / . circleci / verbatim - sources / build - parameters / pytorch - build - params . yml <nl> pytorch_windows_params : & pytorch_windows_params <nl> default : " 3 . 6 " <nl> vc_version : <nl> type : string <nl> - default : " 14 . 11 " <nl> + default : " 14 . 13 " <nl> vc_year : <nl> type : string <nl> default : " 2017 " <nl> mmm a / . circleci / verbatim - sources / job - specs / pytorch - job - specs . yml <nl> ppp b / . circleci / verbatim - sources / job - specs / pytorch - job - specs . yml <nl> jobs : <nl> default : " 3 . 6 " <nl> vc_version : <nl> type : string <nl> - default : " 14 . 11 " <nl> + default : " 14 . 13 " <nl> vc_year : <nl> type : string <nl> default : " 2017 " <nl> jobs : <nl> default : " 3 . 6 " <nl> vc_version : <nl> type : string <nl> - default : " 14 . 11 " <nl> + default : " 14 . 13 " <nl> vc_year : <nl> type : string <nl> default : " 2017 " <nl> mmm a / README . md <nl> ppp b / README . md <nl> Each CUDA version only supports one particular XCode version . The following comb <nl> <nl> On Windows <nl> <nl> - At least Visual Studio 2017 Update 3 ( version 15 . 3 . 3 with the toolset 14 . 11 ) and [ NVTX ] ( https : / / docs . nvidia . com / gameworks / content / gameworkslibrary / nvtx / nvidia_tools_extension_library_nvtx . htm ) are needed . <nl> + At least Visual Studio 2017 version 15 . 6 with the toolset 14 . 13 and [ NVTX ] ( https : / / docs . nvidia . com / gameworks / content / gameworkslibrary / nvtx / nvidia_tools_extension_library_nvtx . htm ) are needed . <nl> <nl> - If the version of Visual Studio 2017 is higher than 15 . 4 . 5 , installing of " VC + + 2017 version 15 . 4 v14 . 11 toolset " is strongly recommended . <nl> - < br / > If the version of Visual Studio 2017 is lesser than 15 . 3 . 3 , please update Visual Studio 2017 to the latest version along with installing " VC + + 2017 version 15 . 4 v14 . 11 toolset " . <nl> - < br / > There is no guarantee of the correct building with VC + + 2017 toolsets , others than version 15 . 4 v14 . 11 . <nl> - < br / > " VC + + 2017 version 15 . 4 v14 . 11 toolset " might be installed onto already installed Visual Studio 2017 by running its installation once again and checking the corresponding checkbox under " Individual components " / " Compilers , build tools , and runtimes " . <nl> + If the version of Visual Studio 2017 is higher than 15 . 6 , installing of " VC + + 2017 version 15 . 6 v14 . 13 toolset " is strongly recommended . <nl> + < br / > If the version of Visual Studio 2017 is lesser than 15 . 6 , please update Visual Studio 2017 to the latest version along with installing " VC + + 2017 version 15 . 6 v14 . 13 toolset " . <nl> + < br / > There is no guarantee of the correct building with VC + + 2017 toolsets , others than version 15 . 6 v14 . 13 . <nl> + < br / > " VC + + 2017 version 15 . 6 v14 . 13 toolset " might be installed onto already installed Visual Studio 2017 by running its installation once again and checking the corresponding checkbox under " Individual components " / " Compilers , build tools , and runtimes " . <nl> <nl> NVTX is a part of CUDA distributive , where it is called " Nsight Compute " . To install it onto already installed CUDA run CUDA installation once again and check the corresponding checkbox . <nl> Be sure that CUDA with Nsight Compute is installed after Visual Studio 2017 . <nl> mmm a / aten / src / ATen / core / stack . h <nl> ppp b / aten / src / ATen / core / stack . h <nl> template < typename . . . Types > <nl> static inline void pop ( Stack & stack , Types & . . . args ) { <nl> size_t i = 0 ; <nl> constexpr size_t N = sizeof . . . ( args ) ; <nl> - int result [ N ] = { <nl> + ( void ) std : : initializer_list < int > { <nl> ( args = std : : move ( peek ( stack , i + + , N ) ) . template to < Types > ( ) , 0 ) . . . } ; <nl> - ( void ) result ; <nl> drop ( stack , N ) ; <nl> } <nl> template < typename Type > <nl>
Back out " Revert D22072830 : [ wip ] Upgrade msvc to 14 . 13 " ( )
pytorch/pytorch
c7904763847277a5e47f5fc85a8ca2fabdb7a3e2
2020-06-26T00:19:33Z
deleted file mode 100644 <nl> index 7d99a13a475 . . 00000000000 <nl> mmm a / ports / ebml / CMakeLists . txt <nl> ppp / dev / null <nl> <nl> - cmake_minimum_required ( VERSION 3 . 1 . 2 ) <nl> - <nl> - project ( ebml VERSION 1 . 3 . 5 ) <nl> - <nl> - option ( DISABLE_PKGCONFIG " Disable PkgConfig module generation " OFF ) <nl> - option ( DISABLE_CMAKE_CONFIG " Disable CMake package config module generation " OFF ) <nl> - <nl> - include ( GNUInstallDirs ) <nl> - <nl> - set ( libebml_SOURCES <nl> - src / Debug . cpp <nl> - src / EbmlBinary . cpp <nl> - src / EbmlContexts . cpp <nl> - src / EbmlCrc32 . cpp <nl> - src / EbmlDate . cpp <nl> - src / EbmlDummy . cpp <nl> - src / EbmlElement . cpp <nl> - src / EbmlFloat . cpp <nl> - src / EbmlHead . cpp <nl> - src / EbmlMaster . cpp <nl> - src / EbmlSInteger . cpp <nl> - src / EbmlStream . cpp <nl> - src / EbmlString . cpp <nl> - src / EbmlSubHead . cpp <nl> - src / EbmlUInteger . cpp <nl> - src / EbmlUnicodeString . cpp <nl> - src / EbmlVersion . cpp <nl> - src / EbmlVoid . cpp <nl> - src / IOCallback . cpp <nl> - src / MemIOCallback . cpp <nl> - src / MemReadIOCallback . cpp <nl> - src / SafeReadIOCallback . cpp <nl> - src / StdIOCallback . cpp ) <nl> - <nl> - set ( libebml_PUBLIC_HEADERS <nl> - ebml / Debug . h <nl> - ebml / EbmlBinary . h <nl> - ebml / EbmlConfig . h <nl> - ebml / EbmlContexts . h <nl> - ebml / EbmlCrc32 . h <nl> - ebml / EbmlDate . h <nl> - ebml / EbmlDummy . h <nl> - ebml / EbmlElement . h <nl> - ebml / EbmlEndian . h <nl> - ebml / EbmlFloat . h <nl> - ebml / EbmlHead . h <nl> - ebml / EbmlId . h <nl> - ebml / EbmlMaster . h <nl> - ebml / EbmlSInteger . h <nl> - ebml / EbmlStream . h <nl> - ebml / EbmlString . h <nl> - ebml / EbmlSubHead . h <nl> - ebml / EbmlTypes . h <nl> - ebml / EbmlUInteger . h <nl> - ebml / EbmlUnicodeString . h <nl> - ebml / EbmlVersion . h <nl> - ebml / EbmlVoid . h <nl> - ebml / IOCallback . h <nl> - ebml / MemIOCallback . h <nl> - ebml / MemReadIOCallback . h <nl> - ebml / SafeReadIOCallback . h <nl> - ebml / StdIOCallback . h ) <nl> - if ( WIN32 ) <nl> - list ( APPEND libebml_SOURCES <nl> - src / platform / win32 / WinIOCallback . cpp ) <nl> - list ( APPEND libebml_PUBLIC_HEADERS <nl> - src / platform / win32 / WinIOCallback . h ) <nl> - endif ( ) <nl> - <nl> - set ( libebml_C_PUBLIC_HEADERS ebml / c / libebml_t . h ) <nl> - <nl> - add_library ( ebml $ { libebml_SOURCES } $ { libebml_PUBLIC_HEADERS } $ { libebml_C_PUBLIC_HEADERS } ) <nl> - if ( WIN32 ) <nl> - include ( CheckIncludeFile ) <nl> - check_include_file ( winapifamily . h HAVE_WINAPIFAMILY_H ) <nl> - if ( HAVE_WINAPIFAMILY_H ) <nl> - target_compile_definitions ( ebml PUBLIC HAVE_WINAPIFAMILY_H ) <nl> - endif ( ) <nl> - endif ( ) <nl> - set_target_properties ( ebml PROPERTIES <nl> - VERSION 4 . 0 . 0 <nl> - SOVERSION 4 ) <nl> - target_include_directories ( ebml PUBLIC <nl> - $ < BUILD_INTERFACE : $ { CMAKE_CURRENT_SOURCE_DIR } > <nl> - $ < INSTALL_INTERFACE : $ { CMAKE_INSTALL_INCLUDEDIR } > ) <nl> - if ( MSVC ) <nl> - target_compile_definitions ( ebml PRIVATE _CRT_SECURE_NO_WARNINGS ) <nl> - endif ( ) <nl> - if ( BUILD_SHARED_LIBS ) <nl> - set_target_properties ( ebml <nl> - PROPERTIES <nl> - DEFINE_SYMBOL " EBML_DLL_EXPORT " <nl> - C_VISIBILITY_PRESET hidden <nl> - VISIBILITY_INLINES_HIDDEN 1 ) <nl> - target_compile_definitions ( ebml <nl> - PUBLIC EBML_DLL <nl> - PRIVATE EBML_DLL_EXPORT ) <nl> - endif ( ) <nl> - <nl> - install ( TARGETS ebml <nl> - EXPORT EbmlTargets <nl> - RUNTIME DESTINATION $ { CMAKE_INSTALL_BINDIR } <nl> - ARCHIVE DESTINATION $ { CMAKE_INSTALL_LIBDIR } <nl> - LIBRARY DESTINATION $ { CMAKE_INSTALL_LIBDIR } ) <nl> - <nl> - install ( FILES $ { libebml_PUBLIC_HEADERS } DESTINATION $ { CMAKE_INSTALL_INCLUDEDIR } / ebml ) <nl> - install ( FILES $ { libebml_C_PUBLIC_HEADERS } DESTINATION $ { CMAKE_INSTALL_INCLUDEDIR } / ebml / c ) <nl> - <nl> - if ( NOT DISABLE_PKGCONFIG ) <nl> - set ( prefix $ { CMAKE_INSTALL_PREFIX } ) <nl> - set ( exec_prefix " \ $ \ { prefix \ } " ) <nl> - set ( libdir " \ $ \ { prefix \ } / $ { CMAKE_INSTALL_LIBDIR } " ) <nl> - set ( includedir " \ $ \ { prefix \ } / $ { CMAKE_INSTALL_INCLUDEDIR } " ) <nl> - set ( PACKAGE_VERSION $ { PROJECT_VERSION } ) <nl> - configure_file ( libebml . pc . in libebml . pc @ ONLY ) <nl> - install ( FILES $ { CMAKE_CURRENT_BINARY_DIR } / libebml . pc DESTINATION $ { CMAKE_INSTALL_LIBDIR } / pkgconfig ) <nl> - endif ( ) <nl> - <nl> - if ( NOT DISABLE_CMAKE_CONFIG ) <nl> - if ( WIN32 ) <nl> - set ( CMAKE_INSTALL_PACKAGEDIR cmake ) <nl> - else ( ) <nl> - set ( CMAKE_INSTALL_PACKAGEDIR $ { CMAKE_INSTALL_LIBDIR } / cmake / $ { PROJECT_NAME } ) <nl> - endif ( ) <nl> - include ( CMakePackageConfigHelpers ) <nl> - write_basic_package_version_file ( EbmlConfigVersion . cmake COMPATIBILITY SameMajorVersion ) <nl> - install ( EXPORT EbmlTargets DESTINATION $ { CMAKE_INSTALL_PACKAGEDIR } ) <nl> - install ( FILES <nl> - $ { CMAKE_CURRENT_SOURCE_DIR } / EbmlConfig . cmake <nl> - $ { CMAKE_CURRENT_BINARY_DIR } / EbmlConfigVersion . cmake <nl> - DESTINATION $ { CMAKE_INSTALL_PACKAGEDIR } ) <nl> - endif ( ) <nl> mmm a / ports / ebml / CONTROL <nl> ppp b / ports / ebml / CONTROL <nl> <nl> - Source : ebml <nl> - Version : 1 . 3 . 5 - 1 <nl> - Description : a C + + libary to parse EBML files <nl> + Source : ebml <nl> + Version : 1 . 3 . 6 - 1 <nl> + Description : a C + + libary to parse EBML files <nl> deleted file mode 100644 <nl> index 5752fa63298 . . 00000000000 <nl> mmm a / ports / ebml / EbmlConfig . cmake <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - include ( $ { CMAKE_CURRENT_LIST_DIR } / EbmlTargets . cmake ) <nl> mmm a / ports / ebml / portfile . cmake <nl> ppp b / ports / ebml / portfile . cmake <nl> <nl> - # Common Ambient Variables : <nl> - # CURRENT_BUILDTREES_DIR = $ { VCPKG_ROOT_DIR } \ buildtrees \ $ { PORT } <nl> - # CURRENT_PACKAGES_DIR = $ { VCPKG_ROOT_DIR } \ packages \ $ { PORT } _ $ { TARGET_TRIPLET } <nl> - # CURRENT_PORT_DIR = $ { VCPKG_ROOT_DIR } \ ports \ $ { PORT } <nl> - # PORT = current port name ( zlib , etc ) <nl> - # TARGET_TRIPLET = current triplet ( x86 - windows , x64 - windows - static , etc ) <nl> - # VCPKG_CRT_LINKAGE = C runtime linkage type ( static , dynamic ) <nl> - # VCPKG_LIBRARY_LINKAGE = target library linkage type ( static , dynamic ) <nl> - # VCPKG_ROOT_DIR = < C : \ path \ to \ current \ vcpkg > <nl> - # VCPKG_TARGET_ARCHITECTURE = target architecture ( x64 , x86 , arm ) <nl> - # <nl> - <nl> - include ( vcpkg_common_functions ) <nl> - <nl> - if ( VCPKG_CMAKE_SYSTEM_NAME STREQUAL " WindowsStore " ) <nl> - message ( FATAL_ERROR " $ { PORT } does not currently support UWP " ) <nl> - endif ( ) <nl> - <nl> - <nl> - vcpkg_from_github ( <nl> - OUT_SOURCE_PATH SOURCE_PATH <nl> - REPO Matroska - Org / libebml <nl> - REF release - 1 . 3 . 5 <nl> - SHA512 ccfa58aebb8685b2dbbab7038ab7f7e0788dba2fc391abafad5a0e05c71c8f02c7e1e3521e1c59076057f9643737c2d96a4fffdeb7991214234f2db80c78254b <nl> - HEAD_REF master <nl> - ) <nl> - <nl> - file ( COPY $ { CMAKE_CURRENT_LIST_DIR } / CMakeLists . txt DESTINATION $ { SOURCE_PATH } ) <nl> - file ( COPY $ { CMAKE_CURRENT_LIST_DIR } / EbmlConfig . cmake DESTINATION $ { SOURCE_PATH } ) <nl> - <nl> - vcpkg_apply_patches ( <nl> - SOURCE_PATH $ { SOURCE_PATH } <nl> - PATCHES <nl> - $ { CMAKE_CURRENT_LIST_DIR } / export - endofstreamx . patch <nl> - ) <nl> - <nl> - vcpkg_configure_cmake ( <nl> - SOURCE_PATH $ { SOURCE_PATH } <nl> - PREFER_NINJA # Disable this option if project cannot be built with Ninja <nl> - OPTIONS - DDISABLE_PKGCONFIG = 1 <nl> - # OPTIONS_RELEASE - DOPTIMIZE = 1 <nl> - # OPTIONS_DEBUG - DDEBUGGABLE = 1 <nl> - ) <nl> - <nl> - vcpkg_install_cmake ( ) <nl> - <nl> - vcpkg_fixup_cmake_targets ( CONFIG_PATH cmake ) <nl> - <nl> - file ( REMOVE_RECURSE $ { CURRENT_PACKAGES_DIR } / debug / include ) <nl> - <nl> - # Handle copyright <nl> - file ( INSTALL $ { SOURCE_PATH } / LICENSE . LGPL DESTINATION $ { CURRENT_PACKAGES_DIR } / share / ebml RENAME copyright ) <nl> + include ( vcpkg_common_functions ) <nl> + <nl> + if ( VCPKG_CMAKE_SYSTEM_NAME STREQUAL " WindowsStore " ) <nl> + message ( FATAL_ERROR " $ { PORT } does not currently support UWP " ) <nl> + endif ( ) <nl> + <nl> + <nl> + vcpkg_from_github ( <nl> + OUT_SOURCE_PATH SOURCE_PATH <nl> + REPO Matroska - Org / libebml <nl> + REF release - 1 . 3 . 6 <nl> + SHA512 249ff2e9b381d827311eaec910962685243a3b65335c7bd404a35e11cd204c63bc7ea69787f0e27ea9c9144024e45867fd4ae7d30688a3695cd45fee1ce89ec9 <nl> + HEAD_REF master <nl> + PATCHES export - endofstreamx . patch <nl> + ) <nl> + <nl> + vcpkg_configure_cmake ( <nl> + SOURCE_PATH $ { SOURCE_PATH } <nl> + PREFER_NINJA <nl> + OPTIONS - DDISABLE_PKGCONFIG = 1 <nl> + ) <nl> + <nl> + vcpkg_install_cmake ( ) <nl> + <nl> + vcpkg_fixup_cmake_targets ( CONFIG_PATH cmake ) <nl> + <nl> + file ( REMOVE_RECURSE $ { CURRENT_PACKAGES_DIR } / debug / include ) <nl> + <nl> + # Handle copyright <nl> + file ( INSTALL $ { SOURCE_PATH } / LICENSE . LGPL DESTINATION $ { CURRENT_PACKAGES_DIR } / share / ebml RENAME copyright ) <nl>
[ ebml ] Update to v1 . 3 . 6 ( )
microsoft/vcpkg
0af8b7825aacb3144cec6e557db3356fa5a3e843
2019-01-09T20:38:46Z
mmm a / scene / gui / popup_menu . cpp <nl> ppp b / scene / gui / popup_menu . cpp <nl> void PopupMenu : : _activate_submenu ( int over ) { <nl> Point2 p = get_global_pos ( ) ; <nl> Rect2 pr ( p , get_size ( ) ) ; <nl> Ref < StyleBox > style = get_stylebox ( " panel " ) ; <nl> - pm - > set_pos ( p + Point2 ( get_size ( ) . width , items [ over ] . _ofs_cache - style - > get_offset ( ) . y ) ) ; <nl> + <nl> + Point2 pos = p + Point2 ( get_size ( ) . width , items [ over ] . _ofs_cache - style - > get_offset ( ) . y ) ; <nl> + Size2 size = pm - > get_size ( ) ; <nl> + / / fix pos <nl> + if ( pos . x + size . width > get_viewport_rect ( ) . size . width ) <nl> + pos . x = p . x - size . width ; <nl> + <nl> + pm - > set_pos ( pos ) ; <nl> pm - > popup ( ) ; <nl> <nl> PopupMenu * pum = pm - > cast_to < PopupMenu > ( ) ; <nl>
Popup submenu position enhancement
godotengine/godot
9797b6374bff3845130e31029eeaa544ca546653
2015-11-22T14:53:22Z
mmm a / src / compiler / ruby_generator . cc <nl> ppp b / src / compiler / ruby_generator . cc <nl> void PrintService ( const ServiceDescriptor * service , const grpc : : string & package , <nl> out - > Print ( " self . marshal_class_method = : encode \ n " ) ; <nl> out - > Print ( " self . unmarshal_class_method = : decode \ n " ) ; <nl> std : : map < grpc : : string , grpc : : string > pkg_vars = <nl> - ListToDict ( { " service . name " , service - > name ( ) , " pkg . name " , package , } ) ; <nl> + ListToDict ( { " service_full_namename " , service - > full_name ( ) } ) ; <nl> out - > Print ( pkg_vars , " self . service_name = ' $ pkg . name $ . $ service . name $ ' \ n " ) ; <nl> out - > Print ( " \ n " ) ; <nl> for ( int i = 0 ; i < service - > method_count ( ) ; + + i ) { <nl>
Made ruby plugin support empty package names
grpc/grpc
6a45e9340701f3107f5d39cc5f5c0366204faa23
2016-05-02T21:25:49Z
mmm a / tensorflow / lite / tools / pip_package / Makefile <nl> ppp b / tensorflow / lite / tools / pip_package / Makefile <nl> docker - build : docker - image <nl> - - volume $ ( OUT_DIR ) : / out \ <nl> $ ( TAG_IMAGE ) \ <nl> / bin / bash - c " tensorflow / tensorflow / lite / tools / pip_package / build_pip_package . sh & & \ <nl> - ( cp / tmp / tflite_pip / * . deb / tmp / tflite_pip / $ ( PYTHON ) / dist / { * . whl , * . tar . gz } / out 2 > / dev / null | | true ) " <nl> + ( cp $ { MAKEFILE_DIR } / gen / tflite_pip / * . deb $ { MAKEFILE_DIR } / gen / tflite_pip / python3 / dist / { * . whl , * . tar . gz } / out 2 > / dev / null | | true ) " <nl> <nl> clean : <nl> rm - rf $ ( CURDIR ) / out <nl> mmm a / tensorflow / lite / tools / pip_package / build_pip_package . sh <nl> ppp b / tensorflow / lite / tools / pip_package / build_pip_package . sh <nl> export TENSORFLOW_DIR = " $ { SCRIPT_DIR } / . . / . . / . . / . . " <nl> TENSORFLOW_LITE_DIR = " $ { TENSORFLOW_DIR } / tensorflow / lite " <nl> TENSORFLOW_VERSION = $ ( grep " _VERSION = " " $ { TENSORFLOW_DIR } / tensorflow / tools / pip_package / setup . py " | cut - d = - f2 | sed " s / [ ' - ] / / g " ) <nl> export PACKAGE_VERSION = " $ { TENSORFLOW_VERSION } $ { VERSION_SUFFIX } " <nl> - BUILD_DIR = " / tmp / tflite_pip / $ { PYTHON } " <nl> + BUILD_DIR = " $ { SCRIPT_DIR } / gen / tflite_pip / python3 " <nl> <nl> # Build source tree . <nl> rm - rf " $ { BUILD_DIR } " & & mkdir - p " $ { BUILD_DIR } / tflite_runtime " <nl> case " $ { TENSORFLOW_TARGET } " in <nl> bdist_wheel - - plat - name = linux - aarch64 <nl> ; ; <nl> * ) <nl> - $ { PYTHON } setup . py bdist bdist_wheel <nl> + if [ [ - n " $ { TENSORFLOW_TARGET } " ] ] & & [ [ - n " $ { TENSORFLOW_TARGET_ARCH } " ] ] ; then <nl> + $ { PYTHON } setup . py bdist - - plat - name = $ { TENSORFLOW_TARGET } - $ { TENSORFLOW_TARGET_ARCH } \ <nl> + bdist_wheel - - plat - name = $ { TENSORFLOW_TARGET } - $ { TENSORFLOW_TARGET_ARCH } <nl> + else <nl> + $ { PYTHON } setup . py bdist bdist_wheel <nl> + fi <nl> ; ; <nl> esac <nl> <nl> mmm a / tensorflow / lite / tools / pip_package / setup . py <nl> ppp b / tensorflow / lite / tools / pip_package / setup . py <nl> <nl> os . environ [ ' CC ' ] = ' aarch64 - linux - gnu - gcc ' <nl> MAKE_CROSS_OPTIONS = [ ' TARGET = % s ' % TARGET ] if TARGET else [ ] <nl> <nl> + TARGET_ARCH = ( <nl> + os . environ [ ' TENSORFLOW_TARGET_ARCH ' ] \ <nl> + if ' TENSORFLOW_TARGET_ARCH ' in os . environ <nl> + else None ) <nl> + MAKE_CROSS_OPTIONS + = [ ' TARGET_ARCH = % s ' % TARGET_ARCH ] \ <nl> + if TARGET_ARCH else [ ] <nl> + <nl> + CC_PREFIX = ( <nl> + os . environ [ ' TENSORFLOW_CC_PREFIX ' ] \ <nl> + if ' TENSORFLOW_CC_PREFIX ' in os . environ <nl> + else None ) <nl> + MAKE_CROSS_OPTIONS + = [ ' CC_PREFIX = % s ' % CC_PREFIX ] \ <nl> + if CC_PREFIX else [ ] <nl> + <nl> + EXTRA_CXXFLAGS = ( <nl> + os . environ [ ' TENSORFLOW_EXTRA_CXXFLAGS ' ] \ <nl> + if ' TENSORFLOW_EXTRA_CXXFLAGS ' in os . environ <nl> + else None ) <nl> + MAKE_CROSS_OPTIONS + = [ ' EXTRA_CXXFLAGS = % s ' % EXTRA_CXXFLAGS ] \ <nl> + if EXTRA_CXXFLAGS else [ ] <nl> + <nl> RELATIVE_MAKE_DIR = os . path . join ( ' tensorflow ' , ' lite ' , ' tools ' , ' make ' ) <nl> MAKE_DIR = os . path . join ( TENSORFLOW_DIR , RELATIVE_MAKE_DIR ) <nl> DOWNLOADS_DIR = os . path . join ( MAKE_DIR , ' downloads ' ) <nl>
Merge pull request from vinceab : master_TFLite - cross - compiling
tensorflow/tensorflow
12651b662c676793442bc580ceb4077dda310e4b
2020-02-19T04:21:18Z
similarity index 100 % <nl> rename from hphp / test / quick / all_type_comparison_test . php <nl> rename to hphp / test / slow / comparisons / all_type_comparison_test . php <nl> similarity index 100 % <nl> rename from hphp / test / quick / all_type_comparison_test . php . expect <nl> rename to hphp / test / slow / comparisons / all_type_comparison_test . php . expect <nl> similarity index 100 % <nl> rename from hphp / test / quick / all_type_comparison_test . php . opts <nl> rename to hphp / test / slow / comparisons / all_type_comparison_test . php . opts <nl>
Move all_type_comparison_test to slow tests
facebook/hhvm
4e5edb5ec8ebcfc8a932994343566c6561dcf011
2018-01-21T23:40:09Z
mmm a / demo / multiclass_classification / README . md <nl> ppp b / demo / multiclass_classification / README . md <nl> Make sure you make make xgboost python module in . . / . . / python <nl> . / runexp . sh <nl> ` ` ` <nl> <nl> - <nl> + * * R version * * please see the ` train . R ` . <nl> new file mode 100644 <nl> index 0000000000 . . 4a07f278d7 <nl> mmm / dev / null <nl> ppp b / demo / multiclass_classification / train . R <nl> <nl> + library ( data . table ) <nl> + library ( xgboost ) <nl> + <nl> + if ( ! file . exists ( " . / dermatology . data " ) ) { <nl> + download . file ( <nl> + " https : / / archive . ics . uci . edu / ml / machine - learning - databases / dermatology / dermatology . data " , <nl> + " dermatology . data " , <nl> + method = " curl " <nl> + ) <nl> + } <nl> + <nl> + df < - fread ( " dermatology . data " , sep = " , " , header = FALSE ) <nl> + <nl> + df [ , ` : = ` ( V34 = as . integer ( ifelse ( V34 = = " ? " , 0L , V34 ) ) , <nl> + V35 = V35 - 1L ) ] <nl> + <nl> + idx < - sample ( nrow ( df ) , size = round ( 0 . 7 * nrow ( df ) ) , replace = FALSE ) <nl> + <nl> + train < - df [ idx , ] <nl> + test < - df [ - idx , ] <nl> + <nl> + train_x < - train [ , 1 : 34 ] <nl> + train_y < - train [ , V35 ] <nl> + <nl> + test_x < - test [ , 1 : 34 ] <nl> + test_y < - test [ , V35 ] <nl> + <nl> + xg_train < - xgb . DMatrix ( data = as . matrix ( train_x ) , label = train_y ) <nl> + xg_test = xgb . DMatrix ( as . matrix ( test_x ) , label = test_y ) <nl> + <nl> + params < - list ( <nl> + objective = ' multi : softmax ' , <nl> + num_class = 6 , <nl> + max_depth = 6 , <nl> + nthread = 4 , <nl> + eta = 0 . 1 <nl> + ) <nl> + <nl> + watchlist = list ( train = xg_train , test = xg_test ) <nl> + <nl> + bst < - xgb . train ( <nl> + params = params , <nl> + data = xg_train , <nl> + watchlist = watchlist , <nl> + nrounds = 5 <nl> + ) <nl> + <nl> + pred < - predict ( bst , xg_test ) <nl> + error_rate < - sum ( pred ! = test_y ) / length ( test_y ) <nl> + print ( paste ( " Test error using softmax = " , error_rate ) ) <nl> + <nl> + # do the same thing again , but output probabilities <nl> + params $ objective < - ' multi : softprob ' <nl> + bst < - xgb . train ( params , xg_train , nrounds = 5 , watchlist ) <nl> + <nl> + pred_prob < - predict ( bst , xg_test ) <nl> + <nl> + pred_mat < - matrix ( pred_prob , ncol = 6 , byrow = TRUE ) <nl> + # validation <nl> + # rowSums ( pred_mat ) <nl> + <nl> + pred_label < - apply ( pred_mat , 1 , which . max ) - 1L <nl> + error_rate = sum ( pred_label ! = test_y ) / length ( test_y ) <nl> + print ( paste ( " Test error using softprob = " , error_rate ) ) <nl>
[ R ] add a demo of multi - class classification R version ( )
dmlc/xgboost
3b5a1f389a9aab92b32ce59a13012840a8ba181c
2018-09-22T06:06:40Z
mmm a / dbms / src / Server / ClusterCopier . cpp <nl> ppp b / dbms / src / Server / ClusterCopier . cpp <nl> struct TaskTable <nl> <nl> struct TaskCluster <nl> { <nl> - TaskCluster ( const String & task_zookeeper_path_ , const Poco : : Util : : AbstractConfiguration & config , const String & base_key , const String & default_local_database_ ) ; <nl> + TaskCluster ( const String & task_zookeeper_path_ , const String & default_local_database_ ) <nl> + : task_zookeeper_path ( task_zookeeper_path_ ) , default_local_database ( default_local_database_ ) { } <nl> + <nl> + void loadTasks ( const Poco : : Util : : AbstractConfiguration & config , const String & base_key = " " ) ; <nl> + <nl> + void reloadSettings ( const Poco : : Util : : AbstractConfiguration & config , const String & base_key = " " ) ; <nl> <nl> / / / Base node for all tasks . Its structure : <nl> / / / workers / - directory with active workers ( amount of them is less or equal max_workers ) <nl> struct TaskCluster <nl> / / / table_table1 / - directories with per - partition copying status <nl> String task_zookeeper_path ; <nl> <nl> + / / / Database used to create temporary Distributed tables <nl> + String default_local_database ; <nl> + <nl> / / / Limits number of simultaneous workers <nl> size_t max_workers = 0 ; <nl> <nl> struct TaskCluster <nl> / / / Settings used to insert data <nl> Settings settings_push ; <nl> <nl> + String clusters_prefix ; <nl> + <nl> / / / Subtasks <nl> TasksTable table_tasks ; <nl> <nl> - / / / Database used to create temporary Distributed tables <nl> - String default_local_database ; <nl> - <nl> - / / / Path to remote_servers in task config <nl> - String clusters_prefix ; <nl> - <nl> std : : random_device random_device ; <nl> pcg64 random_engine ; <nl> } ; <nl> void TaskTable : : initShards ( RandomEngine & & random_engine ) <nl> local_shards . assign ( all_shards . begin ( ) , it_first_remote ) ; <nl> } <nl> <nl> - TaskCluster : : TaskCluster ( const String & task_zookeeper_path_ , const Poco : : Util : : AbstractConfiguration & config , const String & base_key , <nl> - const String & default_local_database_ ) <nl> + <nl> + void DB : : TaskCluster : : loadTasks ( const Poco : : Util : : AbstractConfiguration & config , const String & base_key ) <nl> { <nl> String prefix = base_key . empty ( ) ? " " : base_key + " . " ; <nl> <nl> - task_zookeeper_path = task_zookeeper_path_ ; <nl> + clusters_prefix = prefix + " remote_servers " ; <nl> + if ( ! config . has ( clusters_prefix ) ) <nl> + throw Exception ( " You should specify list of clusters in " + clusters_prefix , ErrorCodes : : BAD_ARGUMENTS ) ; <nl> + <nl> + Poco : : Util : : AbstractConfiguration : : Keys tables_keys ; <nl> + config . keys ( prefix + " tables " , tables_keys ) ; <nl> + <nl> + for ( const auto & table_key : tables_keys ) <nl> + { <nl> + table_tasks . emplace_back ( * this , config , prefix + " tables " , table_key ) ; <nl> + } <nl> + } <nl> <nl> - default_local_database = default_local_database_ ; <nl> + void DB : : TaskCluster : : reloadSettings ( const Poco : : Util : : AbstractConfiguration & config , const String & base_key ) <nl> + { <nl> + String prefix = base_key . empty ( ) ? " " : base_key + " . " ; <nl> <nl> max_workers = config . getUInt64 ( prefix + " max_workers " ) ; <nl> <nl> + settings_common = Settings ( ) ; <nl> if ( config . has ( prefix + " settings " ) ) <nl> - { <nl> settings_common . loadSettingsFromConfig ( prefix + " settings " , config ) ; <nl> - settings_pull = settings_common ; <nl> - settings_push = settings_common ; <nl> - } <nl> <nl> + settings_pull = settings_common ; <nl> if ( config . has ( prefix + " settings_pull " ) ) <nl> settings_pull . loadSettingsFromConfig ( prefix + " settings_pull " , config ) ; <nl> <nl> + settings_push = settings_common ; <nl> if ( config . has ( prefix + " settings_push " ) ) <nl> settings_push . loadSettingsFromConfig ( prefix + " settings_push " , config ) ; <nl> <nl> - clusters_prefix = prefix + " remote_servers " ; <nl> + / / / Override important settings <nl> + settings_pull . load_balancing = LoadBalancing : : NEAREST_HOSTNAME ; <nl> + settings_pull . limits . readonly = 1 ; <nl> + settings_pull . max_threads = 1 ; <nl> + settings_pull . max_block_size = std : : min ( 8192UL , settings_pull . max_block_size . value ) ; <nl> + settings_pull . preferred_block_size_bytes = 0 ; <nl> <nl> - if ( ! config . has ( clusters_prefix ) ) <nl> - throw Exception ( " You should specify list of clusters in " + clusters_prefix , ErrorCodes : : BAD_ARGUMENTS ) ; <nl> - <nl> - Poco : : Util : : AbstractConfiguration : : Keys tables_keys ; <nl> - config . keys ( prefix + " tables " , tables_keys ) ; <nl> - <nl> - for ( const auto & table_key : tables_keys ) <nl> - { <nl> - table_tasks . emplace_back ( * this , config , prefix + " tables " , table_key ) ; <nl> - } <nl> + settings_push . insert_distributed_timeout = 0 ; <nl> + settings_push . insert_distributed_sync = 1 ; <nl> } <nl> <nl> + <nl> } / / end of an anonymous namespace <nl> <nl> <nl> class ClusterCopier <nl> <nl> void init ( ) <nl> { <nl> - String description_path = task_zookeeper_path + " / description " ; <nl> - String task_config_str = getZooKeeper ( ) - > get ( description_path ) ; <nl> + auto zookeeper = getZooKeeper ( ) ; <nl> <nl> - task_cluster_config = getConfigurationFromXMLString ( task_config_str ) ; <nl> - task_cluster = std : : make_unique < TaskCluster > ( task_zookeeper_path , * task_cluster_config , " " , working_database_name ) ; <nl> + task_description_watch_callback = [ this ] ( zkutil : : ZooKeeper & , int , int , const char * ) <nl> + { <nl> + UInt64 version = + + task_descprtion_version ; <nl> + LOG_DEBUG ( log , " Task description should be updated , local version " < < version ) ; <nl> + } ; <nl> <nl> - / / / Override important settings <nl> - Settings & settings_pull = task_cluster - > settings_pull ; <nl> - settings_pull . load_balancing = LoadBalancing : : NEAREST_HOSTNAME ; <nl> - settings_pull . limits . readonly = 1 ; <nl> - settings_pull . max_threads = 1 ; <nl> - settings_pull . max_block_size = std : : min ( 8192UL , settings_pull . max_block_size . value ) ; <nl> - settings_pull . preferred_block_size_bytes = 0 ; <nl> + task_description_path = task_zookeeper_path + " / description " ; <nl> + task_cluster = std : : make_unique < TaskCluster > ( task_zookeeper_path , working_database_name ) ; <nl> <nl> - Settings & settings_push = task_cluster - > settings_push ; <nl> - settings_push . insert_distributed_timeout = 0 ; <nl> - settings_push . insert_distributed_sync = 1 ; <nl> + reloadTaskDescription ( ) ; <nl> + task_cluster_initial_config = task_cluster_current_config ; <nl> <nl> - / / / Set up clusters <nl> - context . getSettingsRef ( ) = task_cluster - > settings_common ; <nl> - context . setClustersConfig ( task_cluster_config , task_cluster - > clusters_prefix ) ; <nl> + task_cluster - > loadTasks ( * task_cluster_initial_config ) ; <nl> + context . setClustersConfig ( task_cluster_initial_config , task_cluster - > clusters_prefix ) ; <nl> <nl> / / / Set up shards and their priority <nl> task_cluster - > random_engine . seed ( task_cluster - > random_device ( ) ) ; <nl> class ClusterCopier <nl> } <nl> } <nl> <nl> - auto zookeeper = getZooKeeper ( ) ; <nl> - zookeeper - > createAncestors ( getWorkersPath ( ) + " / " ) ; <nl> + getZooKeeper ( ) - > createAncestors ( getWorkersPath ( ) + " / " ) ; <nl> } <nl> <nl> + void reloadTaskDescription ( ) <nl> + { <nl> + String task_config_str ; <nl> + zkutil : : Stat stat ; <nl> + int code ; <nl> + <nl> + getZooKeeper ( ) - > tryGetWatch ( task_description_path , task_config_str , & stat , task_description_watch_callback , & code ) ; <nl> + if ( code ! = ZOK ) <nl> + throw Exception ( " Can ' t get description node " + task_description_path , ErrorCodes : : BAD_ARGUMENTS ) ; <nl> + <nl> + LOG_DEBUG ( log , " Loading description , zxid = " < < task_descprtion_current_stat . czxid ) ; <nl> + auto config = getConfigurationFromXMLString ( task_config_str ) ; <nl> + <nl> + / / / Setup settings <nl> + task_cluster - > reloadSettings ( * config ) ; <nl> + context . getSettingsRef ( ) = task_cluster - > settings_common ; <nl> + <nl> + task_cluster_current_config = config ; <nl> + task_descprtion_current_stat = stat ; <nl> + } <nl> + <nl> + void updateConfigIfNeeded ( ) <nl> + { <nl> + UInt64 version_to_update = task_descprtion_version ; <nl> + if ( task_descprtion_current_version = = version_to_update ) <nl> + return ; <nl> + <nl> + task_descprtion_current_version = version_to_update ; <nl> + } <nl> <nl> static constexpr size_t max_table_tries = 1000 ; <nl> - static constexpr size_t max_partition_tries = 3 ; <nl> + static constexpr size_t max_partition_tries = 1 ; <nl> <nl> bool tryProcessTable ( TaskTable & task_table ) <nl> { <nl> class ClusterCopier <nl> return getWorkersPath ( ) + " / " + host_id ; <nl> } <nl> <nl> - zkutil : : EphemeralNodeHolder : : Ptr createWorkerNodeAndWaitIfNeed ( const zkutil : : ZooKeeperPtr & zookeeper , const String & task_description ) <nl> + zkutil : : EphemeralNodeHolder : : Ptr createTaskWorkerNodeAndWaitIfNeed ( const zkutil : : ZooKeeperPtr & zookeeper , <nl> + const String & description ) <nl> { <nl> while ( true ) <nl> { <nl> class ClusterCopier <nl> if ( static_cast < size_t > ( stat . numChildren ) > = task_cluster - > max_workers ) <nl> { <nl> LOG_DEBUG ( log , " Too many workers ( " < < stat . numChildren < < " , maximum " < < task_cluster - > max_workers < < " ) " <nl> - < < " . Postpone processing " < < task_description ) ; <nl> + < < " . Postpone processing " < < description ) ; <nl> std : : this_thread : : sleep_for ( default_sleep_time ) ; <nl> } <nl> else <nl> { <nl> - return std : : make_shared < zkutil : : EphemeralNodeHolder > ( getCurrentWorkerNodePath ( ) , * zookeeper , true , false , task_description ) ; <nl> + return std : : make_shared < zkutil : : EphemeralNodeHolder > ( getCurrentWorkerNodePath ( ) , * zookeeper , true , false , description ) ; <nl> } <nl> } <nl> } <nl> class ClusterCopier <nl> return true ; <nl> } <nl> <nl> + <nl> bool processPartitionTask ( TaskPartition & task_partition ) <nl> { <nl> + bool res ; <nl> + <nl> try <nl> { <nl> - return processPartitionTaskImpl ( task_partition ) ; <nl> + res = processPartitionTaskImpl ( task_partition ) ; <nl> } <nl> catch ( . . . ) <nl> { <nl> tryLogCurrentException ( log , " An error occurred while processing partition " + task_partition . name ) ; <nl> return false ; <nl> } <nl> + <nl> + / / / At the end of each task check if the config is updated <nl> + try <nl> + { <nl> + updateConfigIfNeeded ( ) ; <nl> + } <nl> + catch ( . . . ) <nl> + { <nl> + tryLogCurrentException ( log , " An error occurred while updating the config " ) ; <nl> + } <nl> + <nl> + return res ; <nl> } <nl> <nl> bool processPartitionTaskImpl ( TaskPartition & task_partition ) <nl> class ClusterCopier <nl> <nl> <nl> / / / Load balancing <nl> - auto worker_node_holder = createWorkerNodeAndWaitIfNeed ( zookeeper , current_task_status_path ) ; <nl> + auto worker_node_holder = createTaskWorkerNodeAndWaitIfNeed ( zookeeper , current_task_status_path ) ; <nl> <nl> LOG_DEBUG ( log , " Processing " < < current_task_status_path ) ; <nl> <nl> class ClusterCopier <nl> zookeeper - > createAncestors ( current_task_status_path ) ; <nl> <nl> / / / We need to update table definitions for each part , it could be changed after ALTER <nl> - ASTPtr create_query_pull_ast ; <nl> + ASTPtr query_create_pull_table ; <nl> { <nl> / / / Fetch and parse ( possibly ) new definition <nl> auto connection_entry = task_shard . info . pool - > get ( & task_cluster - > settings_pull ) ; <nl> String create_query_pull_str = getRemoteCreateTable ( task_table . table_pull , * connection_entry , & task_cluster - > settings_pull ) ; <nl> <nl> ParserCreateQuery parser_create_query ; <nl> - create_query_pull_ast = parseQuery ( parser_create_query , create_query_pull_str ) ; <nl> + query_create_pull_table = parseQuery ( parser_create_query , create_query_pull_str ) ; <nl> } <nl> <nl> / / / Create local Distributed tables : <nl> class ClusterCopier <nl> auto storage_shard_ast = createASTStorageDistributed ( shard_read_cluster_name , task_table . table_pull . first , task_table . table_pull . second ) ; <nl> const auto & storage_split_ast = task_table . engine_split_ast ; <nl> <nl> - auto create_query_ast = removeAliasColumnsFromCreateQuery ( create_query_pull_ast ) ; <nl> + auto create_query_ast = removeAliasColumnsFromCreateQuery ( query_create_pull_table ) ; <nl> auto create_table_pull_ast = rewriteCreateQueryStorage ( create_query_ast , table_shard , storage_shard_ast ) ; <nl> auto create_table_split_ast = rewriteCreateQueryStorage ( create_query_ast , table_split , storage_split_ast ) ; <nl> <nl> class ClusterCopier <nl> <nl> / / / Try create table ( if not exists ) on each shard <nl> { <nl> - auto create_query_push_ast = rewriteCreateQueryStorage ( create_query_pull_ast , task_table . table_push , task_table . engine_push_ast ) ; <nl> + auto create_query_push_ast = rewriteCreateQueryStorage ( query_create_pull_table , task_table . table_push , task_table . engine_push_ast ) ; <nl> typeid_cast < ASTCreateQuery & > ( * create_query_push_ast ) . if_not_exists = true ; <nl> String query = queryToString ( create_query_push_ast ) ; <nl> <nl> LOG_DEBUG ( log , " Create remote push tables . Query : " < < query ) ; <nl> - executeQueryOnCluster ( task_table . cluster_push , query , create_query_push_ast , & task_cluster - > settings_push , PoolMode : : GET_MANY ) ; <nl> + size_t shards = executeQueryOnCluster ( task_table . cluster_push , query , create_query_push_ast , & task_cluster - > settings_push , <nl> + PoolMode : : GET_MANY ) ; <nl> + LOG_DEBUG ( log , " Remote push tables have been created on " < < shards < < " shards of " <nl> + < < task_table . cluster_push - > getShardCount ( ) ) ; <nl> } <nl> <nl> / / / Do the copying <nl> class ClusterCopier <nl> / / / Will try to make as many as possible queries <nl> if ( shard . hasRemoteConnections ( ) ) <nl> { <nl> - Settings current_settings = * settings ; <nl> + Settings current_settings = settings ? * settings : task_cluster - > settings_common ; <nl> current_settings . max_parallel_replicas = num_remote_replicas ? num_remote_replicas : 1 ; <nl> <nl> std : : vector < IConnectionPool : : Entry > connections = shard . pool - > getMany ( & current_settings , pool_mode ) ; <nl> <nl> for ( auto & connection : connections ) <nl> { <nl> - if ( ! connection . isNull ( ) ) <nl> + if ( connection . isNull ( ) ) <nl> + continue ; <nl> + <nl> + try <nl> { <nl> - try <nl> - { <nl> - RemoteBlockInputStream stream ( * connection , query , { } , context , & current_settings ) ; <nl> - NullBlockOutputStream output ; <nl> - copyData ( stream , output ) ; <nl> + RemoteBlockInputStream stream ( * connection , query , context , & current_settings ) ; <nl> + NullBlockOutputStream output ; <nl> + copyData ( stream , output ) ; <nl> <nl> - if ( increment_and_check_exit ( ) ) <nl> - return ; <nl> - } <nl> - catch ( const Exception & e ) <nl> - { <nl> - LOG_INFO ( log , getCurrentExceptionMessage ( false , true ) ) ; <nl> - } <nl> + if ( increment_and_check_exit ( ) ) <nl> + return ; <nl> + } <nl> + catch ( const Exception & e ) <nl> + { <nl> + LOG_INFO ( log , getCurrentExceptionMessage ( false , true ) ) ; <nl> } <nl> } <nl> } <nl> class ClusterCopier <nl> private : <nl> ConfigurationPtr zookeeper_config ; <nl> String task_zookeeper_path ; <nl> + String task_description_path ; <nl> String host_id ; <nl> String working_database_name ; <nl> <nl> - bool is_safe_mode = false ; <nl> - double copy_fault_probability = 0 . 0 ; <nl> + UInt64 task_descprtion_current_version = 1 ; <nl> + std : : atomic < UInt64 > task_descprtion_version { 1 } ; <nl> + zkutil : : WatchCallback task_description_watch_callback ; <nl> + <nl> + ConfigurationPtr task_cluster_initial_config ; <nl> + ConfigurationPtr task_cluster_current_config ; <nl> + zkutil : : Stat task_descprtion_current_stat ; <nl> <nl> - ConfigurationPtr task_cluster_config ; <nl> std : : unique_ptr < TaskCluster > task_cluster ; <nl> <nl> zkutil : : ZooKeeperPtr current_zookeeper ; <nl> <nl> + bool is_safe_mode = false ; <nl> + double copy_fault_probability = 0 . 0 ; <nl> + <nl> Context & context ; <nl> Poco : : Logger * log ; <nl> <nl>
Autoupdate of ClusterCopier settings . [ # CLICKHOUSE - 3346 ]
ClickHouse/ClickHouse
f6a63c4d0cf0c11ddeca4e0fdd6912538f0de7ae
2018-02-19T17:26:47Z
mmm a / hphp / doc / ir . specification <nl> ppp b / hphp / doc / ir . specification <nl> To darray conversion : <nl> <nl> To bool conversions : <nl> <nl> - | ConvArrToBool , D ( Bool ) , S ( Arr ) , NF <nl> - <nl> | ConvDblToBool , D ( Bool ) , S ( Dbl ) , NF <nl> <nl> | ConvIntToBool , D ( Bool ) , S ( Int ) , NF <nl> To string conversions : <nl> <nl> | CountArray , D ( Int ) , S ( Arr ) , NF <nl> <nl> - | CountArrayFast , D ( Int ) , S ( Arr ) , NF <nl> - <nl> | CountVec , D ( Int ) , S ( Vec ) , NF <nl> <nl> | CountDict , D ( Int ) , S ( Dict ) , NF <nl> To string conversions : <nl> <nl> | CountCollection , D ( Int ) , S ( Obj ) , NF <nl> <nl> - Computes the number of elements in S0 using the same definition as Count , but <nl> - with a restriction on the input type . <nl> - <nl> - CountArray expects any array . CountArrayFast expects an array whose kind is <nl> - not kGlobalsKind . CountCollection expects a collection object . <nl> + Computes the number of elements in S0 using the same definition as Count , <nl> + but with a restriction on the input type that allows for optimizations . <nl> <nl> | Nop , ND , NA , NF <nl> <nl> mmm a / hphp / runtime / test / simplifier . cpp <nl> ppp b / hphp / runtime / test / simplifier . cpp <nl> TEST ( Simplifier , Count ) { <nl> EXPECT_EQ ( 1 , result . dst - > intVal ( ) ) ; <nl> } <nl> <nl> - / / Count ( $ vanilla_array ) - - > CountArrayFast ( $ vanilla_array ) <nl> + / / Count ( $ vanilla_array ) - - > CountArray ( $ vanilla_array ) <nl> { <nl> auto const arr = unit . gen ( Conjure , dummy , TVanillaArr ) ; <nl> auto const count = unit . gen ( Count , dummy , arr - > dst ( ) ) ; <nl> TEST ( Simplifier , Count ) { <nl> <nl> EXPECT_NE ( nullptr , result . dst ) ; <nl> EXPECT_EQ ( 1 , result . instrs . size ( ) ) ; <nl> - EXPECT_MATCH ( result . instrs [ 0 ] , CountArrayFast , arr - > dst ( ) ) ; <nl> + EXPECT_MATCH ( result . instrs [ 0 ] , CountArray , arr - > dst ( ) ) ; <nl> } <nl> <nl> - / / Count ( $ array_packed ) - - > CountArrayFast ( $ array_packed ) <nl> + / / Count ( $ array_packed ) - - > CountArray ( $ array_packed ) <nl> { <nl> auto const arr = unit . gen ( Conjure , dummy , TPackedArr ) ; <nl> auto const count = unit . gen ( Count , dummy , arr - > dst ( ) ) ; <nl> TEST ( Simplifier , Count ) { <nl> <nl> EXPECT_NE ( nullptr , result . dst ) ; <nl> EXPECT_EQ ( 1 , result . instrs . size ( ) ) ; <nl> - EXPECT_MATCH ( result . instrs [ 0 ] , CountArrayFast , arr - > dst ( ) ) ; <nl> + EXPECT_MATCH ( result . instrs [ 0 ] , CountArray , arr - > dst ( ) ) ; <nl> } <nl> <nl> / / Count ( $ some_obj ) - - > Count ( $ some_obj ) <nl> mmm a / hphp / runtime / vm / jit / dce . cpp <nl> ppp b / hphp / runtime / vm / jit / dce . cpp <nl> bool canDCE ( IRInstruction * inst ) { <nl> case ConvDblToArr : <nl> case ConvIntToArr : <nl> case ConvFuncToArr : <nl> - case ConvArrToBool : <nl> case ConvDblToBool : <nl> case ConvIntToBool : <nl> case ConvStrToBool : <nl> bool canDCE ( IRInstruction * inst ) { <nl> case LdRetVal : <nl> case Mov : <nl> case CountArray : <nl> - case CountArrayFast : <nl> case CountVec : <nl> case CountDict : <nl> case CountKeyset : <nl> mmm a / hphp / runtime / vm / jit / gvn . cpp <nl> ppp b / hphp / runtime / vm / jit / gvn . cpp <nl> bool supportsGVN ( const IRInstruction * inst ) { <nl> case OrdStr : <nl> case ChrInt : <nl> case CheckRange : <nl> - case CountArrayFast : <nl> + case CountArray : <nl> case CountVec : <nl> case CountDict : <nl> case CountKeyset : <nl> mmm a / hphp / runtime / vm / jit / ir - opcode . cpp <nl> ppp b / hphp / runtime / vm / jit / ir - opcode . cpp <nl> bool opcodeMayRaise ( Opcode opc ) { <nl> case ContStarted : <nl> case ContStartedCheck : <nl> case ContValid : <nl> - case ConvArrToBool : <nl> case ConvArrToDArr : <nl> case ConvArrToDbl : <nl> case ConvArrToNonDVArr : <nl> bool opcodeMayRaise ( Opcode opc ) { <nl> case ConvVecToVArr : <nl> case ConvPtrToLval : <nl> case CountArray : <nl> - case CountArrayFast : <nl> case CountCollection : <nl> case CountDict : <nl> case CountKeyset : <nl> mmm a / hphp / runtime / vm / jit / irgen - arith . cpp <nl> ppp b / hphp / runtime / vm / jit / irgen - arith . cpp <nl> void implArrCmp ( IRGS & env , Op op , SSATmp * left , SSATmp * right ) { <nl> push ( env , <nl> gen ( env , <nl> toBoolCmpOpcode ( op ) , <nl> - gen ( env , ConvArrToBool , left ) , <nl> + gen ( env , ConvTVToBool , left ) , <nl> gen ( env , ConvTVToBool , right ) ) ) ; <nl> } else if ( rightTy < = TObj ) { <nl> / / Objects are always greater than arrays . Emit a collection check first . <nl> mmm a / hphp / runtime / vm / jit / irgen - iter - spec . cpp <nl> ppp b / hphp / runtime / vm / jit / irgen - iter - spec . cpp <nl> struct PackedAccessor : public Accessor { <nl> } <nl> <nl> SSATmp * getSize ( IRGS & env , SSATmp * arr ) const override { <nl> - auto const op = is_hack_arr ? CountVec : CountArrayFast ; <nl> + auto const op = is_hack_arr ? CountVec : CountArray ; <nl> return gen ( env , op , arr ) ; <nl> } <nl> <nl> struct MixedAccessor : public Accessor { <nl> } <nl> <nl> SSATmp * getSize ( IRGS & env , SSATmp * arr ) const override { <nl> - auto const op = is_hack_arr ? CountDict : CountArrayFast ; <nl> + auto const op = is_hack_arr ? CountDict : CountArray ; <nl> return gen ( env , op , arr ) ; <nl> } <nl> <nl> mmm a / hphp / runtime / vm / jit / irgen - minstr . h <nl> ppp b / hphp / runtime / vm / jit / irgen - minstr . h <nl> SSATmp * profiledArrayAccess ( IRGS & env , SSATmp * arr , SSATmp * key , MOpMode mode , <nl> auto const count = [ & ] { <nl> if ( is_dict ) return gen ( env , CountDict , arr ) ; <nl> if ( is_keyset ) return gen ( env , CountKeyset , arr ) ; <nl> - return gen ( env , CountArrayFast , arr ) ; <nl> + return gen ( env , CountArray , arr ) ; <nl> } ( ) ; <nl> gen ( env , JmpNZero , taken , count ) ; <nl> } ) ; <nl> mmm a / hphp / runtime / vm / jit / irlower - array . cpp <nl> ppp b / hphp / runtime / vm / jit / irlower - array . cpp <nl> void implCountArrayLike ( IRLS & env , const IRInstruction * inst ) { <nl> IMPL_OPCODE_CALL ( Count ) <nl> <nl> void cgCountArray ( IRLS & env , const IRInstruction * inst ) { <nl> - auto const & arr_type = inst - > src ( 0 ) - > type ( ) ; <nl> - auto const src = srcLoc ( env , inst , 0 ) . reg ( ) ; <nl> - auto const dst = dstLoc ( env , inst , 0 ) . reg ( ) ; <nl> - auto & v = vmain ( env ) ; <nl> - <nl> - auto const d = v . makeReg ( ) ; <nl> - auto const sf = v . makeReg ( ) ; <nl> - v < < loadl { src [ ArrayData : : offsetofSize ( ) ] , d } ; <nl> - v < < testl { d , d , sf } ; <nl> - <nl> - unlikelyCond ( <nl> - v , vcold ( env ) , CC_S , sf , dst , <nl> - [ & ] ( Vout & v ) { <nl> - auto const d = v . makeReg ( ) ; <nl> - auto const call = CallSpec : : array ( <nl> - arr_type , & g_array_funcs . vsize , & ArrayData : : size ) ; <nl> - cgCallHelper ( v , env , call , callDest ( d ) , SyncOptions : : None , <nl> - argGroup ( env , inst ) . ssa ( 0 ) ) ; <nl> - return d ; <nl> - } , <nl> - [ & ] ( Vout & / * v * / ) { return d ; } ) ; <nl> - } <nl> - <nl> - void cgCountArrayFast ( IRLS & env , const IRInstruction * inst ) { <nl> implCountArrayLike ( env , inst ) ; <nl> } <nl> <nl> mmm a / hphp / runtime / vm / jit / irlower - conv . cpp <nl> ppp b / hphp / runtime / vm / jit / irlower - conv . cpp <nl> void cgConvStrToBool ( IRLS & env , const IRInstruction * inst ) { <nl> ) ; <nl> } <nl> <nl> - void cgConvArrToBool ( IRLS & env , const IRInstruction * inst ) { <nl> - auto const dst = dstLoc ( env , inst , 0 ) . reg ( ) ; <nl> - auto const src = srcLoc ( env , inst , 0 ) . reg ( ) ; <nl> - auto & v = vmain ( env ) ; <nl> - <nl> - auto const sf = v . makeReg ( ) ; <nl> - v < < cmplim { 0 , src [ ArrayData : : offsetofSize ( ) ] , sf } ; <nl> - <nl> - unlikelyCond ( v , vcold ( env ) , CC_S , sf , dst , <nl> - [ & ] ( Vout & v ) { <nl> - auto const vsize = v . makeReg ( ) ; <nl> - cgCallHelper ( v , env , CallSpec : : method ( & ArrayData : : vsize ) , <nl> - callDest ( vsize ) , SyncOptions : : None , <nl> - argGroup ( env , inst ) . ssa ( 0 ) ) ; <nl> - <nl> - auto const sf = v . makeReg ( ) ; <nl> - auto const d = v . makeReg ( ) ; <nl> - v < < testl { vsize , vsize , sf } ; <nl> - v < < setcc { CC_NZ , sf , d } ; <nl> - return d ; <nl> - } , <nl> - [ & ] ( Vout & v ) { <nl> - auto const d = v . makeReg ( ) ; <nl> - v < < setcc { CC_NZ , sf , d } ; <nl> - return d ; <nl> - } <nl> - ) ; <nl> - } <nl> - <nl> void cgConvObjToBool ( IRLS & env , const IRInstruction * inst ) { <nl> auto const dst = dstLoc ( env , inst , 0 ) . reg ( ) ; <nl> auto const src = srcLoc ( env , inst , 0 ) . reg ( ) ; <nl> mmm a / hphp / runtime / vm / jit / memory - effects . cpp <nl> ppp b / hphp / runtime / vm / jit / memory - effects . cpp <nl> MemEffects memory_effects_impl ( const IRInstruction & inst ) { <nl> case IncStat : <nl> case ContPreNext : <nl> case ContStartedCheck : <nl> - case ConvArrToBool : <nl> case ConvArrToDbl : <nl> case CountArray : <nl> - case CountArrayFast : <nl> case CountVec : <nl> case CountDict : <nl> case CountKeyset : <nl> mmm a / hphp / runtime / vm / jit / simplify . cpp <nl> ppp b / hphp / runtime / vm / jit / simplify . cpp <nl> SSATmp * simplifyConvClsMethToKeyset ( State & env , const IRInstruction * inst ) { <nl> return nullptr ; <nl> } <nl> <nl> - SSATmp * simplifyConvArrToBool ( State & env , const IRInstruction * inst ) { <nl> - auto const src = inst - > src ( 0 ) ; <nl> - return gen ( env , ConvIntToBool , gen ( env , CountArrayFast , src ) ) ; <nl> - } <nl> - <nl> SSATmp * simplifyConvDblToBool ( State & env , const IRInstruction * inst ) { <nl> auto const src = inst - > src ( 0 ) ; <nl> if ( src - > hasConstVal ( ) ) { <nl> SSATmp * simplifyConvTVToBool ( State & env , const IRInstruction * inst ) { <nl> <nl> if ( srcType < = TBool ) return src ; <nl> if ( srcType < = TNull ) return cns ( env , false ) ; <nl> - if ( srcType < = TArr ) return gen ( env , ConvArrToBool , src ) ; <nl> + if ( srcType < = TArr ) { <nl> + auto const length = gen ( env , CountArray , src ) ; <nl> + return gen ( env , NeqInt , length , cns ( env , 0 ) ) ; <nl> + } <nl> if ( srcType < = TVec ) { <nl> auto const length = gen ( env , CountVec , src ) ; <nl> return gen ( env , NeqInt , length , cns ( env , 0 ) ) ; <nl> SSATmp * simplifyCount ( State & env , const IRInstruction * inst ) { <nl> return nullptr ; <nl> } <nl> <nl> - <nl> - SSATmp * simplifyCountArray ( State & env , const IRInstruction * inst ) { <nl> - auto const src = inst - > src ( 0 ) ; <nl> - if ( src - > hasConstVal ( ) ) return cns ( env , src - > arrVal ( ) - > size ( ) ) ; <nl> - return gen ( env , CountArrayFast , src ) ; <nl> - } <nl> - <nl> namespace { <nl> SSATmp * simplifyCountHelper ( <nl> State & env , <nl> SSATmp * simplifyCountHelper ( <nl> } <nl> } <nl> <nl> - SSATmp * simplifyCountArrayFast ( State & env , const IRInstruction * inst ) { <nl> + SSATmp * simplifyCountArray ( State & env , const IRInstruction * inst ) { <nl> return simplifyCountHelper ( env , inst , TArr ) ; <nl> } <nl> <nl> SSATmp * simplifyWork ( State & env , const IRInstruction * inst ) { <nl> X ( ConcatStr4 ) <nl> X ( ConcatIntStr ) <nl> X ( ConcatStrInt ) <nl> - X ( ConvArrToBool ) <nl> X ( ConvArrToDbl ) <nl> X ( ConvBoolToArr ) <nl> X ( ConvBoolToDbl ) <nl> SSATmp * simplifyWork ( State & env , const IRInstruction * inst ) { <nl> X ( DblAsBits ) <nl> X ( Count ) <nl> X ( CountArray ) <nl> - X ( CountArrayFast ) <nl> X ( CountVec ) <nl> X ( CountDict ) <nl> X ( CountKeyset ) <nl>
Eliminate CountArrayFast and ConvArrToBool
facebook/hhvm
4fa638d645dc9b0a081e08b7177d06d1755ac8e1
2020-07-01T01:11:21Z
mmm a / README . md <nl> ppp b / README . md <nl> score = metrics . accuracy_score ( classifier . predict ( iris . data ) , iris . target ) <nl> print ( " Accuracy : % f " % score ) <nl> ` ` ` <nl> <nl> + # # # Custom model with multiple GPUs <nl> + <nl> + To use multiple GPUs to build a custom model , everything else is the same as the example above <nl> + except that in the definition of custom model you ' ll need to specify the device : <nl> + <nl> + ` ` ` Python <nl> + import tensorflow as tf <nl> + <nl> + def my_model ( X , y ) : <nl> + " " " <nl> + This is DNN with 10 , 20 , 10 hidden layers , and dropout of 0 . 5 probability . <nl> + <nl> + Note : If you want to run this example with multiple GPUs , Cuda Toolkit 7 . 0 and <nl> + CUDNN 6 . 5 V2 from NVIDIA need to be installed beforehand . <nl> + " " " <nl> + with tf . device ( ' / gpu : 1 ' ) : <nl> + layers = skflow . ops . dnn ( X , [ 10 , 20 , 10 ] , keep_prob = 0 . 5 ) <nl> + with tf . device ( ' / gpu : 2 ' ) : <nl> + return skflow . models . logistic_regression ( layers , y ) <nl> + ` ` ` <nl> + <nl> # # Coming soon <nl> <nl> * Easy way to handle categorical variables <nl>
Added multiple GPUs example to README ( + 1 squashed commit )
tensorflow/tensorflow
ad11530879c9aaf3308aee85f75c32bb8e1fe706
2015-12-06T05:13:33Z
mmm a / ports / hpx / CONTROL <nl> ppp b / ports / hpx / CONTROL <nl> <nl> Source : hpx <nl> Version : 1 . 5 . 1 <nl> + Port - Version : 1 <nl> Build - Depends : hwloc , boost - accumulators , boost - algorithm , boost - asio , boost - bimap , boost - config , boost - context , boost - dynamic - bitset , boost - exception , boost - filesystem , boost - iostreams , boost - lockfree , boost - program - options , boost - range , boost - spirit , boost - system , boost - throw - exception , boost - variant , boost - winapi <nl> Homepage : https : / / github . com / STEllAR - GROUP / hpx <nl> Description : The C + + Standards Library for Concurrency and Parallelism <nl> mmm a / ports / hpx / portfile . cmake <nl> ppp b / ports / hpx / portfile . cmake <nl> foreach ( CMAKE_FILE IN LISTS CMAKE_FILES ) <nl> file ( WRITE $ { CMAKE_FILE } " $ { _contents } " ) <nl> endforeach ( ) <nl> <nl> + vcpkg_replace_string ( <nl> + " $ { CURRENT_PACKAGES_DIR } / share / $ { PORT } / HPXConfig . cmake " <nl> + " set ( HPX_BUILD_TYPE \ " Release \ " ) " <nl> + " set ( HPX_BUILD_TYPE \ " \ $ { CMAKE_BUILD_TYPE } \ " ) " ) <nl> + <nl> vcpkg_replace_string ( <nl> " $ { CURRENT_PACKAGES_DIR } / share / $ { PORT } / HPXMacros . cmake " <nl> " set ( CMAKE_MODULE_PATH \ $ { CMAKE_MODULE_PATH } \ " \ $ { CMAKE_CURRENT_LIST_DIR } \ " ) " <nl>
[ hpx ] Fix cmake config issue ( )
microsoft/vcpkg
973ad930924c6b9c59ca7bcad9666ada2d3b45f8
2020-10-20T21:43:10Z
mmm a / cmake / find_hdfs3 . cmake <nl> ppp b / cmake / find_hdfs3 . cmake <nl> <nl> - if ( NOT ARCH_ARM ) <nl> + if ( NOT ARCH_ARM AND NOT OS_FREEBSD AND NOT APPLE ) <nl> option ( ENABLE_HDFS " Enable HDFS " $ { NOT_UNBUNDLED } ) <nl> endif ( ) <nl> <nl> mmm a / cmake / find_libgsasl . cmake <nl> ppp b / cmake / find_libgsasl . cmake <nl> <nl> - option ( USE_INTERNAL_LIBGSASL_LIBRARY " Set to FALSE to use system libgsasl library instead of bundled " $ { NOT_UNBUNDLED } ) <nl> + if ( NOT APPLE ) <nl> + option ( USE_INTERNAL_LIBGSASL_LIBRARY " Set to FALSE to use system libgsasl library instead of bundled " $ { NOT_UNBUNDLED } ) <nl> + endif ( ) <nl> <nl> if ( USE_INTERNAL_LIBGSASL_LIBRARY AND NOT EXISTS " $ { ClickHouse_SOURCE_DIR } / contrib / libgsasl / src / gsasl . h " ) <nl> message ( WARNING " submodule contrib / libgsasl is missing . to fix try run : \ n git submodule update - - init - - recursive " ) <nl> mmm a / contrib / CMakeLists . txt <nl> ppp b / contrib / CMakeLists . txt <nl> if ( USE_INTERNAL_LIBXML2_LIBRARY ) <nl> endif ( ) <nl> <nl> if ( USE_INTERNAL_HDFS3_LIBRARY ) <nl> - include ( $ { CMAKE_SOURCE_DIR } / cmake / find_protobuf . cmake ) <nl> + include ( $ { ClickHouse_SOURCE_DIR } / cmake / find_protobuf . cmake ) <nl> if ( USE_INTERNAL_PROTOBUF_LIBRARY ) <nl> set ( protobuf_BUILD_TESTS OFF CACHE INTERNAL " " FORCE ) <nl> set ( protobuf_BUILD_SHARED_LIBS OFF CACHE INTERNAL " " FORCE ) <nl> mmm a / release <nl> ppp b / release <nl> do <nl> shift <nl> elif [ [ $ 1 = = ' - - fast ' ] ] ; then <nl> # Wrong but fast pbuilder mode : create base package with all depends <nl> - EXTRAPACKAGES = " $ EXTRAPACKAGES debhelper cmake ninja - build gcc - 7 g + + - 7 libc6 - dev libicu - dev libreadline - dev psmisc bash expect python python - lxml python - termcolor python - requests curl perl sudo openssl netcat - openbsd uuid xml2 krb5 gsasl " <nl> + EXTRAPACKAGES = " $ EXTRAPACKAGES debhelper cmake ninja - build gcc - 7 g + + - 7 libc6 - dev libicu - dev libreadline - dev psmisc bash expect python python - lxml python - termcolor python - requests curl perl sudo openssl netcat - openbsd " <nl> shift <nl> else <nl> echo " Unknown option $ 1 " <nl>
Build fixes
ClickHouse/ClickHouse
7ce0d5964869cf83f76822e713a805866cc13382
2018-12-07T20:12:06Z
mmm a / src / compiler / code - generator . cc <nl> ppp b / src / compiler / code - generator . cc <nl> Handle < Code > CodeGenerator : : GenerateCode ( ) { <nl> <nl> safepoints ( ) - > Emit ( masm ( ) , frame ( ) - > GetSpillSlotCount ( ) ) ; <nl> <nl> - / / TODO ( titzer ) : what are the right code flags here ? <nl> - Code : : Kind kind = Code : : STUB ; <nl> - if ( linkage ( ) - > GetIncomingDescriptor ( ) - > IsJSFunctionCall ( ) ) { <nl> - kind = Code : : OPTIMIZED_FUNCTION ; <nl> - } <nl> Handle < Code > result = v8 : : internal : : CodeGenerator : : MakeCodeEpilogue ( <nl> - masm ( ) , Code : : ComputeFlags ( kind ) , info ) ; <nl> + masm ( ) , info - > flags ( ) , info ) ; <nl> result - > set_is_turbofanned ( true ) ; <nl> result - > set_stack_slots ( frame ( ) - > GetSpillSlotCount ( ) ) ; <nl> result - > set_safepoint_table_offset ( safepoints ( ) - > GetCodeOffset ( ) ) ; <nl> mmm a / src / objects - inl . h <nl> ppp b / src / objects - inl . h <nl> inline void Code : : set_is_crankshafted ( bool value ) { <nl> <nl> <nl> inline bool Code : : is_turbofanned ( ) { <nl> - DCHECK ( kind ( ) = = OPTIMIZED_FUNCTION | | kind ( ) = = STUB ) ; <nl> return IsTurbofannedField : : decode ( <nl> READ_UINT32_FIELD ( this , kKindSpecificFlags1Offset ) ) ; <nl> } <nl> <nl> <nl> inline void Code : : set_is_turbofanned ( bool value ) { <nl> - DCHECK ( kind ( ) = = OPTIMIZED_FUNCTION | | kind ( ) = = STUB ) ; <nl> int previous = READ_UINT32_FIELD ( this , kKindSpecificFlags1Offset ) ; <nl> int updated = IsTurbofannedField : : update ( previous , value ) ; <nl> WRITE_UINT32_FIELD ( this , kKindSpecificFlags1Offset , updated ) ; <nl>
Get code flags from compilation info .
v8/v8
56f9cca8f1cc6ccb522ee8dafd3874d3b6082a66
2015-02-16T11:04:30Z
mmm a / tests / test - lua / Resources / luaScript / PerformanceTest / PerformanceTest . lua <nl> ppp b / tests / test - lua / Resources / luaScript / PerformanceTest / PerformanceTest . lua <nl> <nl> require " luaScript / PerformanceTest / PerformanceSpriteTest " <nl> <nl> - local MAX_COUNT = 5 <nl> + local MAX_COUNT = 6 <nl> local LINE_SPACE = 40 <nl> local kItemTagBasic = 1000 <nl> <nl> local testsName = <nl> " PerformanceParticleTest " , <nl> " PerformanceSpriteTest " , <nl> " PerformanceTextureTest " , <nl> - " PerformanceTouchesTest " <nl> + " PerformanceTouchesTest " , <nl> + " PerformanceFuncRelateWithTable " , <nl> } <nl> <nl> local s = cc . Director : getInstance ( ) : getWinSize ( ) <nl> <nl> - - Create toMainLayr MenuItem <nl> function CreatePerfomBasicLayerMenu ( pMenu ) <nl> - if nil = = pMenu then <nl> - return <nl> - end <nl> - local function toMainLayer ( ) <nl> + if nil = = pMenu then <nl> + return <nl> + end <nl> + local function toMainLayer ( ) <nl> local pScene = PerformanceTestMain ( ) <nl> if pScene ~ = nil then <nl> cc . Director : getInstance ( ) : replaceScene ( pScene ) <nl> end <nl> - end <nl> + end <nl> - - Create BackMneu <nl> cc . MenuItemFont : setFontName ( " Arial " ) <nl> cc . MenuItemFont : setFontSize ( 24 ) <nl> - local pMenuItemFont = cc . MenuItemFont : create ( " Back " ) <nl> + local pMenuItemFont = cc . MenuItemFont : create ( " Back " ) <nl> pMenuItemFont : setPosition ( cc . p ( VisibleRect : rightBottom ( ) . x - 50 , VisibleRect : rightBottom ( ) . y + 25 ) ) <nl> pMenuItemFont : registerScriptTapHandler ( toMainLayer ) <nl> pMenu : addChild ( pMenuItemFont ) <nl> end <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> local NodeChildrenTestParam = <nl> { <nl> - kTagInfoLayer = 1 , <nl> - kTagMainLayer = 2 , <nl> - kTagLabelAtlas = 3 , <nl> - kTagBase = 20000 , <nl> - TEST_COUNT = 4 , <nl> - kMaxNodes = 15000 , <nl> - kNodesIncrease = 500 , <nl> + kTagInfoLayer = 1 , <nl> + kTagMainLayer = 2 , <nl> + kTagLabelAtlas = 3 , <nl> + kTagBase = 20000 , <nl> + TEST_COUNT = 4 , <nl> + kMaxNodes = 15000 , <nl> + kNodesIncrease = 500 , <nl> } <nl> <nl> local function runNodeChildrenTest ( ) <nl> - - - NodeChildrenMainScene <nl> - local nLastRenderedCount = 0 <nl> + - - NodeChildrenMainScene <nl> + local nLastRenderedCount = 0 <nl> local nQuantityOfNodes = 0 <nl> local nCurrentQuantityOfNodes = 0 <nl> - - IterateSpriteSheet <nl> local function runNodeChildrenTest ( ) <nl> local pNewscene = cc . Scene : create ( ) <nl> <nl> local function GetTitle ( ) <nl> - if 0 = = nCurCase then <nl> - return " B - Iterate SpriteSheet " <nl> - elseif 1 = = nCurCase then <nl> - return " C - Add to spritesheet " <nl> - elseif 2 = = nCurCase then <nl> - return " D - Del from spritesheet " <nl> - elseif 3 = = nCurCase then <nl> - return " E - Reorder from spritesheet " <nl> - end <nl> + if 0 = = nCurCase then <nl> + return " B - Iterate SpriteSheet " <nl> + elseif 1 = = nCurCase then <nl> + return " C - Add to spritesheet " <nl> + elseif 2 = = nCurCase then <nl> + return " D - Del from spritesheet " <nl> + elseif 3 = = nCurCase then <nl> + return " E - Reorder from spritesheet " <nl> + end <nl> end <nl> <nl> local function GetSubTitle ( ) <nl> - if 0 = = nCurCase then <nl> - return " Iterate children using C Array API . See console " <nl> - elseif 1 = = nCurCase then <nl> - return " Adds % 10 of total sprites with random z . See console " <nl> - elseif 2 = = nCurCase then <nl> - return " Remove % 10 of total sprites placed randomly . See console " <nl> - elseif 3 = = nCurCase then <nl> - return " Reorder % 10 of total sprites placed randomly . See console " <nl> - end <nl> + if 0 = = nCurCase then <nl> + return " Iterate children using C Array API . See console " <nl> + elseif 1 = = nCurCase then <nl> + return " Adds % 10 of total sprites with random z . See console " <nl> + elseif 2 = = nCurCase then <nl> + return " Remove % 10 of total sprites placed randomly . See console " <nl> + elseif 3 = = nCurCase then <nl> + return " Reorder % 10 of total sprites placed randomly . See console " <nl> + end <nl> end <nl> <nl> local function GetProfilerName ( ) <nl> - if 0 = = nCurCase then <nl> - return " iter c - array " <nl> - elseif 1 = = nCurCase then <nl> - return " add sprites " <nl> - elseif 2 = = nCurCase then <nl> - return " remove sprites " <nl> - elseif 3 = = nCurCase then <nl> - return " reorder sprites " <nl> - end <nl> + if 0 = = nCurCase then <nl> + return " iter c - array " <nl> + elseif 1 = = nCurCase then <nl> + return " add sprites " <nl> + elseif 2 = = nCurCase then <nl> + return " remove sprites " <nl> + elseif 3 = = nCurCase then <nl> + return " reorder sprites " <nl> + end <nl> end <nl> <nl> local function CreateBasicLayerMenuItem ( pMenu , bMenuVisible , nMaxCasesNum , nCurCaseIndex ) <nl> - if nil ~ = pMenu then <nl> - bControlMenuVisible = bMenuVisible <nl> - nMaxCases = nMaxCasesNum <nl> - nCurCase = nCurCaseIndex <nl> - if true = = bControlMenuVisible then <nl> - local function backCallback ( ) <nl> - nCurCase = nCurCase - 1 <nl> - if nCurCase < 0 then <nl> - nCurCase = nCurCase + nMaxCases <nl> - end <nl> - ShowCurrentTest ( ) <nl> - end <nl> - <nl> - local function restartCallback ( ) <nl> - ShowCurrentTest ( ) <nl> - end <nl> - <nl> - local function nextCallback ( ) <nl> - nCurCase = nCurCase + 1 <nl> - - - No check nMaxCases <nl> - nCurCase = nCurCase % nMaxCases <nl> - ShowCurrentTest ( ) <nl> - end <nl> - <nl> - local size = cc . Director : getInstance ( ) : getWinSize ( ) <nl> - local item1 = cc . MenuItemImage : create ( s_pPathB1 , s_pPathB2 ) <nl> - item1 : registerScriptTapHandler ( backCallback ) <nl> - pMenu : addChild ( item1 , kItemTagBasic ) <nl> - local item2 = cc . MenuItemImage : create ( s_pPathR1 , s_pPathR2 ) <nl> - item2 : registerScriptTapHandler ( restartCallback ) <nl> - pMenu : addChild ( item2 , kItemTagBasic ) <nl> - local item3 = cc . MenuItemImage : create ( s_pPathF1 , s_pPathF2 ) <nl> - pMenu : addChild ( item3 , kItemTagBasic ) <nl> - item3 : registerScriptTapHandler ( nextCallback ) <nl> - <nl> - local size = cc . Director : getInstance ( ) : getWinSize ( ) <nl> - item1 : setPosition ( cc . p ( size . width / 2 - item2 : getContentSize ( ) . width * 2 , item2 : getContentSize ( ) . height / 2 ) ) <nl> - item2 : setPosition ( cc . p ( size . width / 2 , item2 : getContentSize ( ) . height / 2 ) ) <nl> - item3 : setPosition ( cc . p ( size . width / 2 + item2 : getContentSize ( ) . width * 2 , item2 : getContentSize ( ) . height / 2 ) ) <nl> - end <nl> - end <nl> + if nil ~ = pMenu then <nl> + bControlMenuVisible = bMenuVisible <nl> + nMaxCases = nMaxCasesNum <nl> + nCurCase = nCurCaseIndex <nl> + if true = = bControlMenuVisible then <nl> + local function backCallback ( ) <nl> + nCurCase = nCurCase - 1 <nl> + if nCurCase < 0 then <nl> + nCurCase = nCurCase + nMaxCases <nl> + end <nl> + ShowCurrentTest ( ) <nl> + end <nl> + <nl> + local function restartCallback ( ) <nl> + ShowCurrentTest ( ) <nl> + end <nl> + <nl> + local function nextCallback ( ) <nl> + nCurCase = nCurCase + 1 <nl> + - - No check nMaxCases <nl> + nCurCase = nCurCase % nMaxCases <nl> + ShowCurrentTest ( ) <nl> + end <nl> + <nl> + local size = cc . Director : getInstance ( ) : getWinSize ( ) <nl> + local item1 = cc . MenuItemImage : create ( s_pPathB1 , s_pPathB2 ) <nl> + item1 : registerScriptTapHandler ( backCallback ) <nl> + pMenu : addChild ( item1 , kItemTagBasic ) <nl> + local item2 = cc . MenuItemImage : create ( s_pPathR1 , s_pPathR2 ) <nl> + item2 : registerScriptTapHandler ( restartCallback ) <nl> + pMenu : addChild ( item2 , kItemTagBasic ) <nl> + local item3 = cc . MenuItemImage : create ( s_pPathF1 , s_pPathF2 ) <nl> + pMenu : addChild ( item3 , kItemTagBasic ) <nl> + item3 : registerScriptTapHandler ( nextCallback ) <nl> + <nl> + local size = cc . Director : getInstance ( ) : getWinSize ( ) <nl> + item1 : setPosition ( cc . p ( size . width / 2 - item2 : getContentSize ( ) . width * 2 , item2 : getContentSize ( ) . height / 2 ) ) <nl> + item2 : setPosition ( cc . p ( size . width / 2 , item2 : getContentSize ( ) . height / 2 ) ) <nl> + item3 : setPosition ( cc . p ( size . width / 2 + item2 : getContentSize ( ) . width * 2 , item2 : getContentSize ( ) . height / 2 ) ) <nl> + end <nl> + end <nl> end <nl> <nl> local function updateQuantityLabel ( ) <nl> - if nQuantityOfNodes ~ = nLastRenderedCount then <nl> - - - local pInfoLabel = pNewscene : getChildByTag ( NodeChildrenTestParam . kTagInfoLayer ) <nl> - local pInfoLabel = tolua . cast ( pNewscene : getChildByTag ( NodeChildrenTestParam . kTagInfoLayer ) , " cc . LabelTTF " ) <nl> - local strNode = nQuantityOfNodes . . " nodes " <nl> - pInfoLabel : setString ( strNode ) <nl> - nLastRenderedCount = nQuantityOfNodes <nl> - end <nl> + if nQuantityOfNodes ~ = nLastRenderedCount then <nl> + - - local pInfoLabel = pNewscene : getChildByTag ( NodeChildrenTestParam . kTagInfoLayer ) <nl> + local pInfoLabel = tolua . cast ( pNewscene : getChildByTag ( NodeChildrenTestParam . kTagInfoLayer ) , " cc . LabelTTF " ) <nl> + local strNode = nQuantityOfNodes . . " nodes " <nl> + pInfoLabel : setString ( strNode ) <nl> + nLastRenderedCount = nQuantityOfNodes <nl> + end <nl> end <nl> <nl> local function IterateSpriteSheetCArrayUpdate ( t ) <nl> - if nil = = pBatchNode then <nl> - return <nl> - end <nl> - local pChildren = pBatchNode : getChildren ( ) <nl> - local pObject = nil <nl> - if nil = = pChildren then <nl> - return <nl> - end <nl> - local i = 0 <nl> - local len = table . getn ( pChildren ) <nl> - for i = 0 , len - 1 , 1 do <nl> - local child = tolua . cast ( pChildren [ i + 1 ] , " cc . Sprite " ) <nl> - child : setVisible ( false ) <nl> - end <nl> + if nil = = pBatchNode then <nl> + return <nl> + end <nl> + local pChildren = pBatchNode : getChildren ( ) <nl> + local pObject = nil <nl> + if nil = = pChildren then <nl> + return <nl> + end <nl> + local i = 0 <nl> + local len = table . getn ( pChildren ) <nl> + for i = 0 , len - 1 , 1 do <nl> + local child = tolua . cast ( pChildren [ i + 1 ] , " cc . Sprite " ) <nl> + child : setVisible ( false ) <nl> + end <nl> end <nl> <nl> local function AddSpriteSheetUpdate ( t ) <nl> - if nil = = pBatchNode then <nl> - return <nl> - end <nl> - <nl> - - - 15 percent <nl> - local nTotalToAdd = nCurrentQuantityOfNodes * 0 . 15 <nl> - local zs = { } <nl> - if nTotalToAdd > 0 then <nl> + if nil = = pBatchNode then <nl> + return <nl> + end <nl> + <nl> + - - 15 percent <nl> + local nTotalToAdd = nCurrentQuantityOfNodes * 0 . 15 <nl> + local zs = { } <nl> + if nTotalToAdd > 0 then <nl> local pSprites = { } <nl> - local i = 0 <nl> - for i = 0 , nTotalToAdd - 1 do <nl> - local pSprite = cc . Sprite : createWithTexture ( pBatchNode : getTexture ( ) , cc . rect ( 0 , 0 , 32 , 32 ) ) <nl> + local i = 0 <nl> + for i = 0 , nTotalToAdd - 1 do <nl> + local pSprite = cc . Sprite : createWithTexture ( pBatchNode : getTexture ( ) , cc . rect ( 0 , 0 , 32 , 32 ) ) <nl> pSprites [ i + 1 ] = pSprite <nl> - zs [ i ] = math . random ( - 1 , 1 ) * 50 <nl> - end <nl> - <nl> - for i = 0 , nTotalToAdd - 1 do <nl> - local pChild = tolua . cast ( pSprites [ i + 1 ] , " cc . Node " ) <nl> - pBatchNode : addChild ( pChild , zs [ i ] , NodeChildrenTestParam . kTagBase + i ) <nl> - end <nl> - <nl> - pBatchNode : sortAllChildren ( ) <nl> - <nl> - for i = 0 , nTotalToAdd - 1 do <nl> - pBatchNode : removeChildByTag ( NodeChildrenTestParam . kTagBase + i , true ) <nl> - end <nl> - end <nl> + zs [ i ] = math . random ( - 1 , 1 ) * 50 <nl> + end <nl> + <nl> + for i = 0 , nTotalToAdd - 1 do <nl> + local pChild = tolua . cast ( pSprites [ i + 1 ] , " cc . Node " ) <nl> + pBatchNode : addChild ( pChild , zs [ i ] , NodeChildrenTestParam . kTagBase + i ) <nl> + end <nl> + <nl> + pBatchNode : sortAllChildren ( ) <nl> + <nl> + for i = 0 , nTotalToAdd - 1 do <nl> + pBatchNode : removeChildByTag ( NodeChildrenTestParam . kTagBase + i , true ) <nl> + end <nl> + end <nl> end <nl> <nl> local function RemoveSpriteSheetUpdate ( t ) <nl> - if nil = = pBatchNode then <nl> - return <nl> - end <nl> - local nTotalToAdd = nCurrentQuantityOfNodes * 0 . 15 <nl> - if nTotalToAdd > 0 then <nl> + if nil = = pBatchNode then <nl> + return <nl> + end <nl> + local nTotalToAdd = nCurrentQuantityOfNodes * 0 . 15 <nl> + if nTotalToAdd > 0 then <nl> local pSprites = { } <nl> - - - Don ' t include the sprite creation time as part of the profiling <nl> - local i = 0 <nl> - for i = 0 , nTotalToAdd - 1 do <nl> - local pSprite = cc . Sprite : createWithTexture ( pBatchNode : getTexture ( ) , cc . rect ( 0 , 0 , 32 , 32 ) ) <nl> + - - Don ' t include the sprite creation time as part of the profiling <nl> + local i = 0 <nl> + for i = 0 , nTotalToAdd - 1 do <nl> + local pSprite = cc . Sprite : createWithTexture ( pBatchNode : getTexture ( ) , cc . rect ( 0 , 0 , 32 , 32 ) ) <nl> pSprites [ i + 1 ] = pSprite <nl> - end <nl> - - - add them with random Z ( very important ! ) <nl> - for i = 0 , nTotalToAdd - 1 do <nl> - local pChild = tolua . cast ( pSprites [ i + 1 ] , " cc . Node " ) <nl> - pBatchNode : addChild ( pChild , math . random ( - 1 , 1 ) * 50 , NodeChildrenTestParam . kTagBase + i ) <nl> + end <nl> + - - add them with random Z ( very important ! ) <nl> + for i = 0 , nTotalToAdd - 1 do <nl> + local pChild = tolua . cast ( pSprites [ i + 1 ] , " cc . Node " ) <nl> + pBatchNode : addChild ( pChild , math . random ( - 1 , 1 ) * 50 , NodeChildrenTestParam . kTagBase + i ) <nl> end <nl> <nl> - for i = 0 , nTotalToAdd - 1 do <nl> - pBatchNode : removeChildByTag ( NodeChildrenTestParam . kTagBase + i , true ) <nl> - end <nl> + for i = 0 , nTotalToAdd - 1 do <nl> + pBatchNode : removeChildByTag ( NodeChildrenTestParam . kTagBase + i , true ) <nl> + end <nl> end <nl> end <nl> <nl> local function ReorderSpriteSheetUpdate ( t ) <nl> - if nil = = pBatchNode then <nl> - return <nl> - end <nl> + if nil = = pBatchNode then <nl> + return <nl> + end <nl> - - 15 percent <nl> - local nTotalToAdd = nCurrentQuantityOfNodes * 0 . 15 <nl> + local nTotalToAdd = nCurrentQuantityOfNodes * 0 . 15 <nl> <nl> - if nTotalToAdd > 0 then <nl> + if nTotalToAdd > 0 then <nl> local pSprites = { } <nl> - - - Don ' t include the sprite creation time as part of the profiling <nl> - local i = 0 <nl> - for i = 0 , nTotalToAdd - 1 do <nl> - local pSprite = cc . Sprite : createWithTexture ( pBatchNode : getTexture ( ) , cc . rect ( 0 , 0 , 32 , 32 ) ) <nl> - pSprites [ i + 1 ] = pSprite <nl> - end <nl> - <nl> - - - dd them with random Z ( very important ! ) <nl> - for i = 0 , nTotalToAdd - 1 do <nl> - local pChild = tolua . cast ( pSprites [ i + 1 ] , " cc . Node " ) <nl> - pBatchNode : addChild ( pChild , math . random ( - 1 , 1 ) * 50 , NodeChildrenTestParam . kTagBase + i ) <nl> - end <nl> - <nl> - pBatchNode : sortAllChildren ( ) <nl> - <nl> - - - reorder them <nl> - for i = 0 , nTotalToAdd - 1 do <nl> - local pNode = tolua . cast ( pSprites [ i + 1 ] , " cc . Node " ) <nl> - pBatchNode : reorderChild ( pNode , math . random ( - 1 , 1 ) * 50 ) <nl> - end <nl> - pBatchNode : sortAllChildren ( ) <nl> - - - remove them <nl> - for i = 0 , nTotalToAdd - 1 do <nl> - pBatchNode : removeChildByTag ( NodeChildrenTestParam . kTagBase + i , true ) <nl> - end <nl> + - - Don ' t include the sprite creation time as part of the profiling <nl> + local i = 0 <nl> + for i = 0 , nTotalToAdd - 1 do <nl> + local pSprite = cc . Sprite : createWithTexture ( pBatchNode : getTexture ( ) , cc . rect ( 0 , 0 , 32 , 32 ) ) <nl> + pSprites [ i + 1 ] = pSprite <nl> + end <nl> + <nl> + - - dd them with random Z ( very important ! ) <nl> + for i = 0 , nTotalToAdd - 1 do <nl> + local pChild = tolua . cast ( pSprites [ i + 1 ] , " cc . Node " ) <nl> + pBatchNode : addChild ( pChild , math . random ( - 1 , 1 ) * 50 , NodeChildrenTestParam . kTagBase + i ) <nl> + end <nl> + <nl> + pBatchNode : sortAllChildren ( ) <nl> + <nl> + - - reorder them <nl> + for i = 0 , nTotalToAdd - 1 do <nl> + local pNode = tolua . cast ( pSprites [ i + 1 ] , " cc . Node " ) <nl> + pBatchNode : reorderChild ( pNode , math . random ( - 1 , 1 ) * 50 ) <nl> + end <nl> + pBatchNode : sortAllChildren ( ) <nl> + - - remove them <nl> + for i = 0 , nTotalToAdd - 1 do <nl> + pBatchNode : removeChildByTag ( NodeChildrenTestParam . kTagBase + i , true ) <nl> + end <nl> end <nl> end <nl> <nl> local function NodeChildrenScheduleUpdate ( ) <nl> - if 0 = = nCurCase then <nl> - pNewscene : scheduleUpdateWithPriorityLua ( IterateSpriteSheetCArrayUpdate , 0 ) <nl> - elseif 1 = = nCurCase then <nl> - pNewscene : scheduleUpdateWithPriorityLua ( AddSpriteSheetUpdate , 0 ) <nl> - elseif 2 = = nCurCase then <nl> - pNewscene : scheduleUpdateWithPriorityLua ( RemoveSpriteSheetUpdate , 0 ) <nl> - elseif 3 = = nCurCase then <nl> - pNewscene : scheduleUpdateWithPriorityLua ( ReorderSpriteSheetUpdate , 0 ) <nl> - end <nl> + if 0 = = nCurCase then <nl> + pNewscene : scheduleUpdateWithPriorityLua ( IterateSpriteSheetCArrayUpdate , 0 ) <nl> + elseif 1 = = nCurCase then <nl> + pNewscene : scheduleUpdateWithPriorityLua ( AddSpriteSheetUpdate , 0 ) <nl> + elseif 2 = = nCurCase then <nl> + pNewscene : scheduleUpdateWithPriorityLua ( RemoveSpriteSheetUpdate , 0 ) <nl> + elseif 3 = = nCurCase then <nl> + pNewscene : scheduleUpdateWithPriorityLua ( ReorderSpriteSheetUpdate , 0 ) <nl> + end <nl> end <nl> <nl> local function updateQuantityOfNodes ( ) <nl> - local s = cc . Director : getInstance ( ) : getWinSize ( ) <nl> - - - increase nodes <nl> - if ( nCurrentQuantityOfNodes < nQuantityOfNodes ) then <nl> - local i = 0 <nl> - for i = 0 , nQuantityOfNodes - nCurrentQuantityOfNodes - 1 do <nl> - local sprite = cc . Sprite : createWithTexture ( pBatchNode : getTexture ( ) , cc . rect ( 0 , 0 , 32 , 32 ) ) <nl> - pBatchNode : addChild ( sprite ) <nl> - sprite : setPosition ( cc . p ( math . random ( ) * s . width , math . random ( ) * s . height ) ) <nl> - if 0 ~ = nCurCase then <nl> - sprite : setVisible ( false ) <nl> - end <nl> - end <nl> - elseif ( nCurrentQuantityOfNodes > nQuantityOfNodes ) then <nl> - i = 0 <nl> - for i = 0 , nCurrentQuantityOfNodes - nQuantityOfNodes - 1 do <nl> - local index = nCurrentQuantityOfNodes - i - 1 <nl> - pBatchNode : removeChildAtIndex ( index , true ) <nl> - end <nl> - end <nl> - <nl> - <nl> - nCurrentQuantityOfNodes = nQuantityOfNodes <nl> + local s = cc . Director : getInstance ( ) : getWinSize ( ) <nl> + - - increase nodes <nl> + if ( nCurrentQuantityOfNodes < nQuantityOfNodes ) then <nl> + local i = 0 <nl> + for i = 0 , nQuantityOfNodes - nCurrentQuantityOfNodes - 1 do <nl> + local sprite = cc . Sprite : createWithTexture ( pBatchNode : getTexture ( ) , cc . rect ( 0 , 0 , 32 , 32 ) ) <nl> + pBatchNode : addChild ( sprite ) <nl> + sprite : setPosition ( cc . p ( math . random ( ) * s . width , math . random ( ) * s . height ) ) <nl> + if 0 ~ = nCurCase then <nl> + sprite : setVisible ( false ) <nl> + end <nl> + end <nl> + elseif ( nCurrentQuantityOfNodes > nQuantityOfNodes ) then <nl> + i = 0 <nl> + for i = 0 , nCurrentQuantityOfNodes - nQuantityOfNodes - 1 do <nl> + local index = nCurrentQuantityOfNodes - i - 1 <nl> + pBatchNode : removeChildAtIndex ( index , true ) <nl> + end <nl> + end <nl> + <nl> + <nl> + nCurrentQuantityOfNodes = nQuantityOfNodes <nl> end <nl> <nl> local function onDecrease ( ) <nl> - nQuantityOfNodes = nQuantityOfNodes - NodeChildrenTestParam . kNodesIncrease <nl> - if nQuantityOfNodes < 0 then <nl> - nQuantityOfNodes = 0 <nl> - end <nl> - <nl> - updateQuantityLabel ( ) <nl> - updateQuantityOfNodes ( ) <nl> + nQuantityOfNodes = nQuantityOfNodes - NodeChildrenTestParam . kNodesIncrease <nl> + if nQuantityOfNodes < 0 then <nl> + nQuantityOfNodes = 0 <nl> + end <nl> + <nl> + updateQuantityLabel ( ) <nl> + updateQuantityOfNodes ( ) <nl> end <nl> <nl> local function onIncrease ( ) <nl> - nQuantityOfNodes = nQuantityOfNodes + NodeChildrenTestParam . kNodesIncrease <nl> - if nQuantityOfNodes > NodeChildrenTestParam . kMaxNodes then <nl> - nQuantityOfNodes = NodeChildrenTestParam . kMaxNodes <nl> - end <nl> - <nl> - updateQuantityLabel ( ) <nl> - updateQuantityOfNodes ( ) <nl> + nQuantityOfNodes = nQuantityOfNodes + NodeChildrenTestParam . kNodesIncrease <nl> + if nQuantityOfNodes > NodeChildrenTestParam . kMaxNodes then <nl> + nQuantityOfNodes = NodeChildrenTestParam . kMaxNodes <nl> + end <nl> + <nl> + updateQuantityLabel ( ) <nl> + updateQuantityOfNodes ( ) <nl> end <nl> <nl> <nl> local function SpecialInitWithQuantityOfNodes ( ) <nl> - - - if 0 = = nCurCase then <nl> - pBatchNode = cc . SpriteBatchNode : create ( " Images / spritesheet1 . png " ) <nl> - pNewscene : addChild ( pBatchNode ) <nl> - - - [ [ <nl> - else <nl> - pBatchNode = cc . SpriteBatchNode : create ( " Images / spritesheet1 . png " ) <nl> - pNewscene : addChild ( pBatchNode ) <nl> - end <nl> - ] ] - - <nl> + - - if 0 = = nCurCase then <nl> + pBatchNode = cc . SpriteBatchNode : create ( " Images / spritesheet1 . png " ) <nl> + pNewscene : addChild ( pBatchNode ) <nl> + - - [ [ <nl> + else <nl> + pBatchNode = cc . SpriteBatchNode : create ( " Images / spritesheet1 . png " ) <nl> + pNewscene : addChild ( pBatchNode ) <nl> + end <nl> + ] ] - - <nl> end <nl> <nl> local function MainSceneInitWithQuantityOfNodes ( nNodes ) <nl> - local s = cc . Director : getInstance ( ) : getWinSize ( ) <nl> - <nl> + local s = cc . Director : getInstance ( ) : getWinSize ( ) <nl> + <nl> - - Title <nl> - local pLabel = cc . LabelTTF : create ( GetTitle ( ) , " Arial " , 40 ) <nl> - pNewscene : addChild ( pLabel , 1 ) <nl> - pLabel : setPosition ( cc . p ( s . width / 2 , s . height - 32 ) ) <nl> - pLabel : setColor ( cc . c3b ( 255 , 255 , 40 ) ) <nl> - <nl> - if ( nil ~ = GetSubTitle ( ) ) and ( " " ~ = GetSubTitle ( ) ) then <nl> - local pSubLabel = cc . LabelTTF : create ( GetSubTitle ( ) , " Thonburi " , 16 ) <nl> - pNewscene : addChild ( pSubLabel , 1 ) <nl> - pSubLabel : setPosition ( cc . p ( s . width / 2 , s . height - 80 ) ) <nl> + local pLabel = cc . LabelTTF : create ( GetTitle ( ) , " Arial " , 40 ) <nl> + pNewscene : addChild ( pLabel , 1 ) <nl> + pLabel : setPosition ( cc . p ( s . width / 2 , s . height - 32 ) ) <nl> + pLabel : setColor ( cc . c3b ( 255 , 255 , 40 ) ) <nl> + <nl> + if ( nil ~ = GetSubTitle ( ) ) and ( " " ~ = GetSubTitle ( ) ) then <nl> + local pSubLabel = cc . LabelTTF : create ( GetSubTitle ( ) , " Thonburi " , 16 ) <nl> + pNewscene : addChild ( pSubLabel , 1 ) <nl> + pSubLabel : setPosition ( cc . p ( s . width / 2 , s . height - 80 ) ) <nl> end <nl> <nl> - nLastRenderedCount = 0 <nl> - nCurrentQuantityOfNodes = 0 <nl> - nQuantityOfNodes = nNodes <nl> - <nl> - - - " + " , " - " Menu <nl> - cc . MenuItemFont : setFontSize ( 65 ) <nl> - local pDecrease = cc . MenuItemFont : create ( " - " ) <nl> - pDecrease : registerScriptTapHandler ( onDecrease ) <nl> - pDecrease : setColor ( cc . c3b ( 0 , 200 , 20 ) ) <nl> - local pIncrease = cc . MenuItemFont : create ( " + " ) <nl> - pIncrease : registerScriptTapHandler ( onIncrease ) <nl> - pIncrease : setColor ( cc . c3b ( 0 , 200 , 20 ) ) <nl> - <nl> - local pMenuAddOrSub = cc . Menu : create ( ) <nl> - pMenuAddOrSub : addChild ( pDecrease ) <nl> - pMenuAddOrSub : addChild ( pIncrease ) <nl> - pMenuAddOrSub : alignItemsHorizontally ( ) <nl> - pMenuAddOrSub : setPosition ( cc . p ( s . width / 2 , s . height / 2 + 15 ) ) <nl> - pNewscene : addChild ( pMenuAddOrSub , 1 ) <nl> - <nl> - - - InfoLayer <nl> - local pInfoLabel = cc . LabelTTF : create ( " 0 nodes " , " Marker Felt " , 30 ) <nl> - pInfoLabel : setColor ( cc . c3b ( 0 , 200 , 20 ) ) <nl> - pInfoLabel : setPosition ( cc . p ( s . width / 2 , s . height / 2 - 15 ) ) <nl> - pNewscene : addChild ( pInfoLabel , 1 , NodeChildrenTestParam . kTagInfoLayer ) <nl> - <nl> - - - NodeChildrenMenuLayer <nl> - local pNodeChildrenMenuLayer = cc . Layer : create ( ) <nl> - local pNodeChildrenMenuMenu = cc . Menu : create ( ) <nl> - CreatePerfomBasicLayerMenu ( pNodeChildrenMenuMenu ) <nl> - CreateBasicLayerMenuItem ( pNodeChildrenMenuMenu , true , NodeChildrenTestParam . TEST_COUNT , nCurCase ) <nl> - pNodeChildrenMenuMenu : setPosition ( cc . p ( 0 , 0 ) ) <nl> - pNodeChildrenMenuLayer : addChild ( pNodeChildrenMenuMenu ) <nl> - pNewscene : addChild ( pNodeChildrenMenuLayer ) <nl> - <nl> - updateQuantityLabel ( ) <nl> - updateQuantityOfNodes ( ) <nl> - <nl> - end <nl> - <nl> - function ShowCurrentTest ( ) <nl> - if nil ~ = pNewscene then <nl> - pNewscene : unscheduleUpdate ( ) <nl> - end <nl> - <nl> - pNewscene = cc . Scene : create ( ) <nl> - if nil ~ = pNewscene then <nl> - SpecialInitWithQuantityOfNodes ( ) <nl> - MainSceneInitWithQuantityOfNodes ( nQuantityOfNodes ) <nl> mmm pNewscene : registerScriptHandler ( onNodeEvent ) <nl> - NodeChildrenScheduleUpdate ( ) <nl> - cc . Director : getInstance ( ) : replaceScene ( pNewscene ) <nl> - end <nl> - end <nl> - <nl> - SpecialInitWithQuantityOfNodes ( ) <nl> - MainSceneInitWithQuantityOfNodes ( NodeChildrenTestParam . kNodesIncrease ) <nl> mmm pNewscene : registerScriptHandler ( onNodeEvent ) <nl> - NodeChildrenScheduleUpdate ( ) <nl> - <nl> - return pNewscene <nl> + nLastRenderedCount = 0 <nl> + nCurrentQuantityOfNodes = 0 <nl> + nQuantityOfNodes = nNodes <nl> + <nl> + - - " + " , " - " Menu <nl> + cc . MenuItemFont : setFontSize ( 65 ) <nl> + local pDecrease = cc . MenuItemFont : create ( " - " ) <nl> + pDecrease : registerScriptTapHandler ( onDecrease ) <nl> + pDecrease : setColor ( cc . c3b ( 0 , 200 , 20 ) ) <nl> + local pIncrease = cc . MenuItemFont : create ( " + " ) <nl> + pIncrease : registerScriptTapHandler ( onIncrease ) <nl> + pIncrease : setColor ( cc . c3b ( 0 , 200 , 20 ) ) <nl> + <nl> + local pMenuAddOrSub = cc . Menu : create ( ) <nl> + pMenuAddOrSub : addChild ( pDecrease ) <nl> + pMenuAddOrSub : addChild ( pIncrease ) <nl> + pMenuAddOrSub : alignItemsHorizontally ( ) <nl> + pMenuAddOrSub : setPosition ( cc . p ( s . width / 2 , s . height / 2 + 15 ) ) <nl> + pNewscene : addChild ( pMenuAddOrSub , 1 ) <nl> + <nl> + - - InfoLayer <nl> + local pInfoLabel = cc . LabelTTF : create ( " 0 nodes " , " Marker Felt " , 30 ) <nl> + pInfoLabel : setColor ( cc . c3b ( 0 , 200 , 20 ) ) <nl> + pInfoLabel : setPosition ( cc . p ( s . width / 2 , s . height / 2 - 15 ) ) <nl> + pNewscene : addChild ( pInfoLabel , 1 , NodeChildrenTestParam . kTagInfoLayer ) <nl> + <nl> + - - NodeChildrenMenuLayer <nl> + local pNodeChildrenMenuLayer = cc . Layer : create ( ) <nl> + local pNodeChildrenMenuMenu = cc . Menu : create ( ) <nl> + CreatePerfomBasicLayerMenu ( pNodeChildrenMenuMenu ) <nl> + CreateBasicLayerMenuItem ( pNodeChildrenMenuMenu , true , NodeChildrenTestParam . TEST_COUNT , nCurCase ) <nl> + pNodeChildrenMenuMenu : setPosition ( cc . p ( 0 , 0 ) ) <nl> + pNodeChildrenMenuLayer : addChild ( pNodeChildrenMenuMenu ) <nl> + pNewscene : addChild ( pNodeChildrenMenuLayer ) <nl> + <nl> + updateQuantityLabel ( ) <nl> + updateQuantityOfNodes ( ) <nl> + <nl> + end <nl> + <nl> + function ShowCurrentTest ( ) <nl> + if nil ~ = pNewscene then <nl> + pNewscene : unscheduleUpdate ( ) <nl> + end <nl> + <nl> + pNewscene = cc . Scene : create ( ) <nl> + if nil ~ = pNewscene then <nl> + SpecialInitWithQuantityOfNodes ( ) <nl> + MainSceneInitWithQuantityOfNodes ( nQuantityOfNodes ) <nl> + - - pNewscene : registerScriptHandler ( onNodeEvent ) <nl> + NodeChildrenScheduleUpdate ( ) <nl> + cc . Director : getInstance ( ) : replaceScene ( pNewscene ) <nl> + end <nl> + end <nl> + <nl> + SpecialInitWithQuantityOfNodes ( ) <nl> + MainSceneInitWithQuantityOfNodes ( NodeChildrenTestParam . kNodesIncrease ) <nl> + - - pNewscene : registerScriptHandler ( onNodeEvent ) <nl> + NodeChildrenScheduleUpdate ( ) <nl> + <nl> + return pNewscene <nl> end <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> - - PerformanceParticleTest <nl> local ParticleTestParam = <nl> } <nl> <nl> local function runParticleTest ( ) <nl> - - - PerformanceParticle param <nl> + - - PerformanceParticle param <nl> local nLastRenderedCount = 0 <nl> local nQuantityParticles = 0 <nl> local nSubtestNumber = 0 <nl> local function runParticleTest ( ) <nl> local pNewScene = cc . Scene : create ( ) <nl> <nl> local function GetTitle ( ) <nl> - local strTitle = nil <nl> - if 0 = = nCurCase then <nl> - strTitle = string . format ( " A ( % d ) size = 4 " , nSubtestNumber ) <nl> - elseif 1 = = nCurCase then <nl> - strTitle = string . format ( " B ( % d ) size = 8 " , nSubtestNumber ) <nl> - elseif 2 = = nCurCase then <nl> - strTitle = string . format ( " C ( % d ) size = 32 " , nSubtestNumber ) <nl> - elseif 3 = = nCurCase then <nl> - strTitle = string . format ( " D ( % d ) size = 64 " , nSubtestNumber ) <nl> - end <nl> - return strTitle <nl> + local strTitle = nil <nl> + if 0 = = nCurCase then <nl> + strTitle = string . format ( " A ( % d ) size = 4 " , nSubtestNumber ) <nl> + elseif 1 = = nCurCase then <nl> + strTitle = string . format ( " B ( % d ) size = 8 " , nSubtestNumber ) <nl> + elseif 2 = = nCurCase then <nl> + strTitle = string . format ( " C ( % d ) size = 32 " , nSubtestNumber ) <nl> + elseif 3 = = nCurCase then <nl> + strTitle = string . format ( " D ( % d ) size = 64 " , nSubtestNumber ) <nl> + end <nl> + return strTitle <nl> end <nl> <nl> local function CreateBasicLayerMenuItem ( pMenu , bMenuVisible , nMaxCasesNum , nCurCaseIndex ) <nl> - if nil ~ = pMenu then <nl> - bControlMenuVisible = bMenuVisible <nl> - nMaxCases = nMaxCasesNum <nl> - nCurCase = nCurCaseIndex <nl> - if true = = bControlMenuVisible then <nl> - local function backCallback ( ) <nl> - nCurCase = nCurCase - 1 <nl> - if nCurCase < 0 then <nl> - nCurCase = nCurCase + nMaxCases <nl> - end <nl> - ShowCurrentTest ( ) <nl> - end <nl> - <nl> - local function restartCallback ( ) <nl> - ShowCurrentTest ( ) <nl> - end <nl> - <nl> - local function nextCallback ( ) <nl> - nCurCase = nCurCase + 1 <nl> - - - No check nMaxCases <nl> - nCurCase = nCurCase % nMaxCases <nl> - ShowCurrentTest ( ) <nl> - end <nl> - <nl> - local size = cc . Director : getInstance ( ) : getWinSize ( ) <nl> - local item1 = cc . MenuItemImage : create ( s_pPathB1 , s_pPathB2 ) <nl> - item1 : registerScriptTapHandler ( backCallback ) <nl> - pMenu : addChild ( item1 , kItemTagBasic ) <nl> - local item2 = cc . MenuItemImage : create ( s_pPathR1 , s_pPathR2 ) <nl> - item2 : registerScriptTapHandler ( restartCallback ) <nl> - pMenu : addChild ( item2 , kItemTagBasic ) <nl> - local item3 = cc . MenuItemImage : create ( s_pPathF1 , s_pPathF2 ) <nl> - pMenu : addChild ( item3 , kItemTagBasic ) <nl> - item3 : registerScriptTapHandler ( nextCallback ) <nl> - <nl> - local size = cc . Director : getInstance ( ) : getWinSize ( ) <nl> - item1 : setPosition ( cc . p ( size . width / 2 - item2 : getContentSize ( ) . width * 2 , item2 : getContentSize ( ) . height / 2 ) ) <nl> - item2 : setPosition ( cc . p ( size . width / 2 , item2 : getContentSize ( ) . height / 2 ) ) <nl> - item3 : setPosition ( cc . p ( size . width / 2 + item2 : getContentSize ( ) . width * 2 , item2 : getContentSize ( ) . height / 2 ) ) <nl> - end <nl> - end <nl> + if nil ~ = pMenu then <nl> + bControlMenuVisible = bMenuVisible <nl> + nMaxCases = nMaxCasesNum <nl> + nCurCase = nCurCaseIndex <nl> + if true = = bControlMenuVisible then <nl> + local function backCallback ( ) <nl> + nCurCase = nCurCase - 1 <nl> + if nCurCase < 0 then <nl> + nCurCase = nCurCase + nMaxCases <nl> + end <nl> + ShowCurrentTest ( ) <nl> + end <nl> + <nl> + local function restartCallback ( ) <nl> + ShowCurrentTest ( ) <nl> + end <nl> + <nl> + local function nextCallback ( ) <nl> + nCurCase = nCurCase + 1 <nl> + - - No check nMaxCases <nl> + nCurCase = nCurCase % nMaxCases <nl> + ShowCurrentTest ( ) <nl> + end <nl> + <nl> + local size = cc . Director : getInstance ( ) : getWinSize ( ) <nl> + local item1 = cc . MenuItemImage : create ( s_pPathB1 , s_pPathB2 ) <nl> + item1 : registerScriptTapHandler ( backCallback ) <nl> + pMenu : addChild ( item1 , kItemTagBasic ) <nl> + local item2 = cc . MenuItemImage : create ( s_pPathR1 , s_pPathR2 ) <nl> + item2 : registerScriptTapHandler ( restartCallback ) <nl> + pMenu : addChild ( item2 , kItemTagBasic ) <nl> + local item3 = cc . MenuItemImage : create ( s_pPathF1 , s_pPathF2 ) <nl> + pMenu : addChild ( item3 , kItemTagBasic ) <nl> + item3 : registerScriptTapHandler ( nextCallback ) <nl> + <nl> + local size = cc . Director : getInstance ( ) : getWinSize ( ) <nl> + item1 : setPosition ( cc . p ( size . width / 2 - item2 : getContentSize ( ) . width * 2 , item2 : getContentSize ( ) . height / 2 ) ) <nl> + item2 : setPosition ( cc . p ( size . width / 2 , item2 : getContentSize ( ) . height / 2 ) ) <nl> + item3 : setPosition ( cc . p ( size . width / 2 + item2 : getContentSize ( ) . width * 2 , item2 : getContentSize ( ) . height / 2 ) ) <nl> + end <nl> + end <nl> end <nl> <nl> local function TestNCallback ( tag , pMenuItem ) <nl> - local nIndex = pMenuItem : getLocalZOrder ( ) - ParticleTestParam . kSubMenuBasicZOrder <nl> - nSubtestNumber = nIndex <nl> - ShowCurrentTest ( ) <nl> + local nIndex = pMenuItem : getLocalZOrder ( ) - ParticleTestParam . kSubMenuBasicZOrder <nl> + nSubtestNumber = nIndex <nl> + ShowCurrentTest ( ) <nl> end <nl> <nl> local function UpdateQuantityLabel ( ) <nl> - if nQuantityParticles ~ = nLastRenderedCount then <nl> - local pInfoLabel = tolua . cast ( pNewScene : getChildByTag ( ParticleTestParam . kTagInfoLayer ) , " cc . LabelTTF " ) <nl> - local strInfo = string . format ( " % u particles " , nQuantityParticles ) <nl> - pInfoLabel : setString ( strInfo ) <nl> - <nl> - nLastRenderedCount = nQuantityParticles <nl> - end <nl> + if nQuantityParticles ~ = nLastRenderedCount then <nl> + local pInfoLabel = tolua . cast ( pNewScene : getChildByTag ( ParticleTestParam . kTagInfoLayer ) , " cc . LabelTTF " ) <nl> + local strInfo = string . format ( " % u particles " , nQuantityParticles ) <nl> + pInfoLabel : setString ( strInfo ) <nl> + <nl> + nLastRenderedCount = nQuantityParticles <nl> + end <nl> end <nl> <nl> local function doTest ( ) <nl> - local s = cc . Director : getInstance ( ) : getWinSize ( ) <nl> - local pParticleSystem = tolua . cast ( pNewScene : getChildByTag ( ParticleTestParam . kTagParticleSystem ) , " cc . ParticleSystem " ) <nl> - if nil = = pParticleSystem then <nl> - return <nl> - end <nl> - if 0 = = nCurCase then <nl> - - - duration <nl> - pParticleSystem : setDuration ( - 1 ) <nl> - <nl> - - - gravity <nl> - pParticleSystem : setGravity ( cc . p ( 0 , - 90 ) ) <nl> - <nl> - - - angle <nl> - pParticleSystem : setAngle ( 90 ) <nl> - pParticleSystem : setAngleVar ( 0 ) <nl> - <nl> - - - radial <nl> - pParticleSystem : setRadialAccel ( 0 ) <nl> - pParticleSystem : setRadialAccelVar ( 0 ) <nl> - <nl> - - - speed of particles <nl> + local s = cc . Director : getInstance ( ) : getWinSize ( ) <nl> + local pParticleSystem = tolua . cast ( pNewScene : getChildByTag ( ParticleTestParam . kTagParticleSystem ) , " cc . ParticleSystem " ) <nl> + if nil = = pParticleSystem then <nl> + return <nl> + end <nl> + if 0 = = nCurCase then <nl> + - - duration <nl> + pParticleSystem : setDuration ( - 1 ) <nl> + <nl> + - - gravity <nl> + pParticleSystem : setGravity ( cc . p ( 0 , - 90 ) ) <nl> + <nl> + - - angle <nl> + pParticleSystem : setAngle ( 90 ) <nl> + pParticleSystem : setAngleVar ( 0 ) <nl> + <nl> + - - radial <nl> + pParticleSystem : setRadialAccel ( 0 ) <nl> + pParticleSystem : setRadialAccelVar ( 0 ) <nl> + <nl> + - - speed of particles <nl> pParticleSystem : setSpeed ( 180 ) <nl> - pParticleSystem : setSpeedVar ( 50 ) <nl> - <nl> - - - emitter position <nl> - pParticleSystem : setPosition ( cc . p ( s . width / 2 , 100 ) ) <nl> - pParticleSystem : setPosVar ( cc . p ( s . width / 2 , 0 ) ) <nl> + pParticleSystem : setSpeedVar ( 50 ) <nl> + <nl> + - - emitter position <nl> + pParticleSystem : setPosition ( cc . p ( s . width / 2 , 100 ) ) <nl> + pParticleSystem : setPosVar ( cc . p ( s . width / 2 , 0 ) ) <nl> <nl> - - - life of particles <nl> - pParticleSystem : setLife ( 2 . 0 ) <nl> - pParticleSystem : setLifeVar ( 1 ) <nl> + - - life of particles <nl> + pParticleSystem : setLife ( 2 . 0 ) <nl> + pParticleSystem : setLifeVar ( 1 ) <nl> <nl> - - - emits per frame <nl> - pParticleSystem : setEmissionRate ( pParticleSystem : getTotalParticles ( ) / pParticleSystem : getLife ( ) ) <nl> - <nl> - - - color of particles <nl> - pParticleSystem : setStartColor ( cc . c4f ( 0 . 5 , 0 . 5 , 0 . 5 , 1 . 0 ) ) <nl> + - - emits per frame <nl> + pParticleSystem : setEmissionRate ( pParticleSystem : getTotalParticles ( ) / pParticleSystem : getLife ( ) ) <nl> + <nl> + - - color of particles <nl> + pParticleSystem : setStartColor ( cc . c4f ( 0 . 5 , 0 . 5 , 0 . 5 , 1 . 0 ) ) <nl> <nl> - pParticleSystem : setStartColorVar ( cc . c4f ( 0 . 5 , 0 . 5 , 0 . 5 , 1 . 0 ) ) <nl> + pParticleSystem : setStartColorVar ( cc . c4f ( 0 . 5 , 0 . 5 , 0 . 5 , 1 . 0 ) ) <nl> <nl> - pParticleSystem : setEndColor ( cc . c4f ( 0 . 1 , 0 . 1 , 0 . 1 , 0 . 2 ) ) <nl> + pParticleSystem : setEndColor ( cc . c4f ( 0 . 1 , 0 . 1 , 0 . 1 , 0 . 2 ) ) <nl> <nl> - pParticleSystem : setEndColorVar ( cc . c4f ( 0 . 1 , 0 . 1 , 0 . 1 , 0 . 2 ) ) <nl> - <nl> - - - size , in pixels <nl> - pParticleSystem : setEndSize ( 4 . 0 ) <nl> - pParticleSystem : setStartSize ( 4 . 0 ) <nl> - pParticleSystem : setEndSizeVar ( 0 ) <nl> - pParticleSystem : setStartSizeVar ( 0 ) <nl> - <nl> - - - additive <nl> - pParticleSystem : setBlendAdditive ( false ) <nl> - <nl> - elseif 1 = = nCurCase then <nl> - - - duration <nl> - pParticleSystem : setDuration ( - 1 ) <nl> - <nl> - - - gravity <nl> - pParticleSystem : setGravity ( cc . p ( 0 , - 90 ) ) <nl> - <nl> - - - angle <nl> - pParticleSystem : setAngle ( 90 ) <nl> - pParticleSystem : setAngleVar ( 0 ) <nl> - <nl> - - - radial <nl> - pParticleSystem : setRadialAccel ( 0 ) <nl> - pParticleSystem : setRadialAccelVar ( 0 ) <nl> - <nl> - - - speed of particles <nl> + pParticleSystem : setEndColorVar ( cc . c4f ( 0 . 1 , 0 . 1 , 0 . 1 , 0 . 2 ) ) <nl> + <nl> + - - size , in pixels <nl> + pParticleSystem : setEndSize ( 4 . 0 ) <nl> + pParticleSystem : setStartSize ( 4 . 0 ) <nl> + pParticleSystem : setEndSizeVar ( 0 ) <nl> + pParticleSystem : setStartSizeVar ( 0 ) <nl> + <nl> + - - additive <nl> + pParticleSystem : setBlendAdditive ( false ) <nl> + <nl> + elseif 1 = = nCurCase then <nl> + - - duration <nl> + pParticleSystem : setDuration ( - 1 ) <nl> + <nl> + - - gravity <nl> + pParticleSystem : setGravity ( cc . p ( 0 , - 90 ) ) <nl> + <nl> + - - angle <nl> + pParticleSystem : setAngle ( 90 ) <nl> + pParticleSystem : setAngleVar ( 0 ) <nl> + <nl> + - - radial <nl> + pParticleSystem : setRadialAccel ( 0 ) <nl> + pParticleSystem : setRadialAccelVar ( 0 ) <nl> + <nl> + - - speed of particles <nl> pParticleSystem : setSpeed ( 180 ) <nl> - pParticleSystem : setSpeedVar ( 50 ) <nl> - <nl> - - - emitter position <nl> - pParticleSystem : setPosition ( cc . p ( s . width / 2 , 100 ) ) <nl> - pParticleSystem : setPosVar ( cc . p ( s . width / 2 , 0 ) ) <nl> + pParticleSystem : setSpeedVar ( 50 ) <nl> + <nl> + - - emitter position <nl> + pParticleSystem : setPosition ( cc . p ( s . width / 2 , 100 ) ) <nl> + pParticleSystem : setPosVar ( cc . p ( s . width / 2 , 0 ) ) <nl> <nl> - - - life of particles <nl> - pParticleSystem : setLife ( 2 . 0 ) <nl> - pParticleSystem : setLifeVar ( 1 ) <nl> + - - life of particles <nl> + pParticleSystem : setLife ( 2 . 0 ) <nl> + pParticleSystem : setLifeVar ( 1 ) <nl> <nl> - - - emits per frame <nl> - pParticleSystem : setEmissionRate ( pParticleSystem : getTotalParticles ( ) / pParticleSystem : getLife ( ) ) <nl> - <nl> - - - color of particles <nl> - pParticleSystem : setStartColor ( cc . c4f ( 0 . 5 , 0 . 5 , 0 . 5 , 1 . 0 ) ) <nl> + - - emits per frame <nl> + pParticleSystem : setEmissionRate ( pParticleSystem : getTotalParticles ( ) / pParticleSystem : getLife ( ) ) <nl> + <nl> + - - color of particles <nl> + pParticleSystem : setStartColor ( cc . c4f ( 0 . 5 , 0 . 5 , 0 . 5 , 1 . 0 ) ) <nl> <nl> - pParticleSystem : setStartColorVar ( cc . c4f ( 0 . 5 , 0 . 5 , 0 . 5 , 1 . 0 ) ) <nl> + pParticleSystem : setStartColorVar ( cc . c4f ( 0 . 5 , 0 . 5 , 0 . 5 , 1 . 0 ) ) <nl> <nl> - pParticleSystem : setEndColor ( cc . c4f ( 0 . 1 , 0 . 1 , 0 . 1 , 0 . 2 ) ) <nl> + pParticleSystem : setEndColor ( cc . c4f ( 0 . 1 , 0 . 1 , 0 . 1 , 0 . 2 ) ) <nl> <nl> - pParticleSystem : setEndColorVar ( cc . c4f ( 0 . 1 , 0 . 1 , 0 . 1 , 0 . 2 ) ) <nl> - <nl> - - - size , in pixels <nl> - pParticleSystem : setEndSize ( 8 . 0 ) <nl> - pParticleSystem : setStartSize ( 8 . 0 ) <nl> - pParticleSystem : setEndSizeVar ( 0 ) <nl> - pParticleSystem : setStartSizeVar ( 0 ) <nl> - <nl> - - - additive <nl> - pParticleSystem : setBlendAdditive ( false ) <nl> - elseif 2 = = nCurCase then <nl> - - - duration <nl> - pParticleSystem : setDuration ( - 1 ) <nl> - <nl> - - - gravity <nl> - pParticleSystem : setGravity ( cc . p ( 0 , - 90 ) ) <nl> - <nl> - - - angle <nl> - pParticleSystem : setAngle ( 90 ) <nl> - pParticleSystem : setAngleVar ( 0 ) <nl> - <nl> - - - radial <nl> - pParticleSystem : setRadialAccel ( 0 ) <nl> - pParticleSystem : setRadialAccelVar ( 0 ) <nl> - <nl> - - - speed of particles <nl> + pParticleSystem : setEndColorVar ( cc . c4f ( 0 . 1 , 0 . 1 , 0 . 1 , 0 . 2 ) ) <nl> + <nl> + - - size , in pixels <nl> + pParticleSystem : setEndSize ( 8 . 0 ) <nl> + pParticleSystem : setStartSize ( 8 . 0 ) <nl> + pParticleSystem : setEndSizeVar ( 0 ) <nl> + pParticleSystem : setStartSizeVar ( 0 ) <nl> + <nl> + - - additive <nl> + pParticleSystem : setBlendAdditive ( false ) <nl> + elseif 2 = = nCurCase then <nl> + - - duration <nl> + pParticleSystem : setDuration ( - 1 ) <nl> + <nl> + - - gravity <nl> + pParticleSystem : setGravity ( cc . p ( 0 , - 90 ) ) <nl> + <nl> + - - angle <nl> + pParticleSystem : setAngle ( 90 ) <nl> + pParticleSystem : setAngleVar ( 0 ) <nl> + <nl> + - - radial <nl> + pParticleSystem : setRadialAccel ( 0 ) <nl> + pParticleSystem : setRadialAccelVar ( 0 ) <nl> + <nl> + - - speed of particles <nl> pParticleSystem : setSpeed ( 180 ) <nl> - pParticleSystem : setSpeedVar ( 50 ) <nl> - <nl> - - - emitter position <nl> - pParticleSystem : setPosition ( cc . p ( s . width / 2 , 100 ) ) <nl> - pParticleSystem : setPosVar ( cc . p ( s . width / 2 , 0 ) ) <nl> + pParticleSystem : setSpeedVar ( 50 ) <nl> + <nl> + - - emitter position <nl> + pParticleSystem : setPosition ( cc . p ( s . width / 2 , 100 ) ) <nl> + pParticleSystem : setPosVar ( cc . p ( s . width / 2 , 0 ) ) <nl> <nl> - - - life of particles <nl> - pParticleSystem : setLife ( 2 . 0 ) <nl> - pParticleSystem : setLifeVar ( 1 ) <nl> + - - life of particles <nl> + pParticleSystem : setLife ( 2 . 0 ) <nl> + pParticleSystem : setLifeVar ( 1 ) <nl> <nl> - - - emits per frame <nl> - pParticleSystem : setEmissionRate ( pParticleSystem : getTotalParticles ( ) / pParticleSystem : getLife ( ) ) <nl> - <nl> - - - color of particles <nl> - pParticleSystem : setStartColor ( cc . c4f ( 0 . 5 , 0 . 5 , 0 . 5 , 1 . 0 ) ) <nl> + - - emits per frame <nl> + pParticleSystem : setEmissionRate ( pParticleSystem : getTotalParticles ( ) / pParticleSystem : getLife ( ) ) <nl> + <nl> + - - color of particles <nl> + pParticleSystem : setStartColor ( cc . c4f ( 0 . 5 , 0 . 5 , 0 . 5 , 1 . 0 ) ) <nl> <nl> - pParticleSystem : setStartColorVar ( cc . c4f ( 0 . 5 , 0 . 5 , 0 . 5 , 1 . 0 ) ) <nl> + pParticleSystem : setStartColorVar ( cc . c4f ( 0 . 5 , 0 . 5 , 0 . 5 , 1 . 0 ) ) <nl> <nl> - pParticleSystem : setEndColor ( cc . c4f ( 0 . 1 , 0 . 1 , 0 . 1 , 0 . 2 ) ) <nl> + pParticleSystem : setEndColor ( cc . c4f ( 0 . 1 , 0 . 1 , 0 . 1 , 0 . 2 ) ) <nl> <nl> - pParticleSystem : setEndColorVar ( cc . c4f ( 0 . 1 , 0 . 1 , 0 . 1 , 0 . 2 ) ) <nl> - <nl> - - - size , in pixels <nl> - pParticleSystem : setEndSize ( 32 . 0 ) <nl> - pParticleSystem : setStartSize ( 32 . 0 ) <nl> - pParticleSystem : setEndSizeVar ( 0 ) <nl> - pParticleSystem : setStartSizeVar ( 0 ) <nl> - <nl> - - - additive <nl> - pParticleSystem : setBlendAdditive ( false ) <nl> - elseif 3 = = nCurCase then <nl> - - - duration <nl> - pParticleSystem : setDuration ( - 1 ) <nl> - <nl> - - - gravity <nl> - pParticleSystem : setGravity ( cc . p ( 0 , - 90 ) ) <nl> - <nl> - - - angle <nl> - pParticleSystem : setAngle ( 90 ) <nl> - pParticleSystem : setAngleVar ( 0 ) <nl> - <nl> - - - radial <nl> - pParticleSystem : setRadialAccel ( 0 ) <nl> - pParticleSystem : setRadialAccelVar ( 0 ) <nl> - <nl> - - - speed of particles <nl> + pParticleSystem : setEndColorVar ( cc . c4f ( 0 . 1 , 0 . 1 , 0 . 1 , 0 . 2 ) ) <nl> + <nl> + - - size , in pixels <nl> + pParticleSystem : setEndSize ( 32 . 0 ) <nl> + pParticleSystem : setStartSize ( 32 . 0 ) <nl> + pParticleSystem : setEndSizeVar ( 0 ) <nl> + pParticleSystem : setStartSizeVar ( 0 ) <nl> + <nl> + - - additive <nl> + pParticleSystem : setBlendAdditive ( false ) <nl> + elseif 3 = = nCurCase then <nl> + - - duration <nl> + pParticleSystem : setDuration ( - 1 ) <nl> + <nl> + - - gravity <nl> + pParticleSystem : setGravity ( cc . p ( 0 , - 90 ) ) <nl> + <nl> + - - angle <nl> + pParticleSystem : setAngle ( 90 ) <nl> + pParticleSystem : setAngleVar ( 0 ) <nl> + <nl> + - - radial <nl> + pParticleSystem : setRadialAccel ( 0 ) <nl> + pParticleSystem : setRadialAccelVar ( 0 ) <nl> + <nl> + - - speed of particles <nl> pParticleSystem : setSpeed ( 180 ) <nl> - pParticleSystem : setSpeedVar ( 50 ) <nl> - <nl> - - - emitter position <nl> - pParticleSystem : setPosition ( cc . p ( s . width / 2 , 100 ) ) <nl> - pParticleSystem : setPosVar ( cc . p ( s . width / 2 , 0 ) ) <nl> + pParticleSystem : setSpeedVar ( 50 ) <nl> + <nl> + - - emitter position <nl> + pParticleSystem : setPosition ( cc . p ( s . width / 2 , 100 ) ) <nl> + pParticleSystem : setPosVar ( cc . p ( s . width / 2 , 0 ) ) <nl> <nl> - - - life of particles <nl> - pParticleSystem : setLife ( 2 . 0 ) <nl> - pParticleSystem : setLifeVar ( 1 ) <nl> + - - life of particles <nl> + pParticleSystem : setLife ( 2 . 0 ) <nl> + pParticleSystem : setLifeVar ( 1 ) <nl> <nl> - - - emits per frame <nl> - pParticleSystem : setEmissionRate ( pParticleSystem : getTotalParticles ( ) / pParticleSystem : getLife ( ) ) <nl> - <nl> - - - color of particles <nl> - pParticleSystem : setStartColor ( cc . c4f ( 0 . 5 , 0 . 5 , 0 . 5 , 1 . 0 ) ) <nl> + - - emits per frame <nl> + pParticleSystem : setEmissionRate ( pParticleSystem : getTotalParticles ( ) / pParticleSystem : getLife ( ) ) <nl> + <nl> + - - color of particles <nl> + pParticleSystem : setStartColor ( cc . c4f ( 0 . 5 , 0 . 5 , 0 . 5 , 1 . 0 ) ) <nl> <nl> - pParticleSystem : setStartColorVar ( cc . c4f ( 0 . 5 , 0 . 5 , 0 . 5 , 1 . 0 ) ) <nl> + pParticleSystem : setStartColorVar ( cc . c4f ( 0 . 5 , 0 . 5 , 0 . 5 , 1 . 0 ) ) <nl> <nl> - pParticleSystem : setEndColor ( cc . c4f ( 0 . 1 , 0 . 1 , 0 . 1 , 0 . 2 ) ) <nl> + pParticleSystem : setEndColor ( cc . c4f ( 0 . 1 , 0 . 1 , 0 . 1 , 0 . 2 ) ) <nl> <nl> - pParticleSystem : setEndColorVar ( cc . c4f ( 0 . 1 , 0 . 1 , 0 . 1 , 0 . 2 ) ) <nl> + pParticleSystem : setEndColorVar ( cc . c4f ( 0 . 1 , 0 . 1 , 0 . 1 , 0 . 2 ) ) <nl> <nl> - - - size , in pixels <nl> - pParticleSystem : setEndSize ( 64 . 0 ) <nl> - pParticleSystem : setStartSize ( 64 . 0 ) <nl> - pParticleSystem : setEndSizeVar ( 0 ) <nl> - pParticleSystem : setStartSizeVar ( 0 ) <nl> - <nl> - - - additive <nl> - pParticleSystem : setBlendAdditive ( false ) <nl> - end <nl> + - - size , in pixels <nl> + pParticleSystem : setEndSize ( 64 . 0 ) <nl> + pParticleSystem : setStartSize ( 64 . 0 ) <nl> + pParticleSystem : setEndSizeVar ( 0 ) <nl> + pParticleSystem : setStartSizeVar ( 0 ) <nl> + <nl> + - - additive <nl> + pParticleSystem : setBlendAdditive ( false ) <nl> + end <nl> end <nl> <nl> local function CreateParticleSystem ( ) <nl> - local pParticleSystem = nil <nl> - - - [ [ <nl> - * Tests : <nl> - * 1 : Point Particle System using 32 - bit textures ( PNG ) <nl> - * 2 : Point Particle System using 16 - bit textures ( PNG ) <nl> - * 3 : Point Particle System using 8 - bit textures ( PNG ) <nl> - * 4 : Point Particle System using 4 - bit textures ( PVRTC ) <nl> - <nl> - * 5 : Quad Particle System using 32 - bit textures ( PNG ) <nl> - * 6 : Quad Particle System using 16 - bit textures ( PNG ) <nl> - * 7 : Quad Particle System using 8 - bit textures ( PNG ) <nl> - * 8 : Quad Particle System using 4 - bit textures ( PVRTC ) <nl> - ] ] - - <nl> - pNewScene : removeChildByTag ( ParticleTestParam . kTagParticleSystem , true ) <nl> - <nl> - - - remove the " fire . png " from the TextureCache cache . <nl> - local pTexture = cc . Director : getInstance ( ) : getTextureCache ( ) : addImage ( " Images / fire . png " ) <nl> - cc . Director : getInstance ( ) : getTextureCache ( ) : removeTexture ( pTexture ) <nl> - local pParticleSystem = cc . ParticleSystemQuad : createWithTotalParticles ( nQuantityParticles ) <nl> - if 1 = = nSubtestNumber then <nl> - cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE2_D_PIXEL_FORMAT_RGB_A8888 ) <nl> - elseif 2 = = nSubtestNumber then <nl> - cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE2_D_PIXEL_FORMAT_RGB_A4444 ) <nl> - elseif 3 = = nSubtestNumber then <nl> - cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE2_D_PIXEL_FORMAT_A8 ) <nl> - elseif 4 = = nSubtestNumber then <nl> - cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE2_D_PIXEL_FORMAT_RGB_A8888 ) <nl> - elseif 5 = = nSubtestNumber then <nl> - cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE2_D_PIXEL_FORMAT_RGB_A4444 ) <nl> - elseif 6 = = nSubtestNumber then <nl> - cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE2_D_PIXEL_FORMAT_A8 ) <nl> - else <nl> - pParticleSystem = nil <nl> - print ( " Shall not happen ! " ) <nl> - end <nl> - <nl> - if nil ~ = pParticleSystem then <nl> - pParticleSystem : setTexture ( cc . Director : getInstance ( ) : getTextureCache ( ) : addImage ( " Images / fire . png " ) ) <nl> - end <nl> - <nl> - pNewScene : addChild ( pParticleSystem , 0 , ParticleTestParam . kTagParticleSystem ) <nl> - <nl> - doTest ( ) <nl> - - - restore the default pixel format <nl> - cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE2_D_PIXEL_FORMAT_RGB_A8888 ) <nl> - end <nl> - <nl> - local function step ( t ) <nl> - local pAtlas = tolua . cast ( pNewScene : getChildByTag ( ParticleTestParam . kTagLabelAtlas ) , " cc . LabelAtlas " ) <nl> - local pEmitter = tolua . cast ( pNewScene : getChildByTag ( ParticleTestParam . kTagParticleSystem ) , " cc . ParticleSystem " ) <nl> - local strInfo = string . format ( " % 4d " , pEmitter : getParticleCount ( ) ) <nl> - pAtlas : setString ( strInfo ) <nl> - end <nl> - <nl> - local function ScheduleFuncion ( ) <nl> - local function OnEnterOrExit ( tag ) <nl> - local scheduler = cc . Director : getInstance ( ) : getScheduler ( ) <nl> - if tag = = " enter " then <nl> - ScheduleSelector = scheduler : scheduleScriptFunc ( step , 0 , false ) <nl> - elseif tag = = " exit " then <nl> - scheduler : unscheduleScriptEntry ( ScheduleSelector ) <nl> - end <nl> - end <nl> - pNewScene : registerScriptHandler ( OnEnterOrExit ) <nl> - end <nl> + local pParticleSystem = nil <nl> + - - [ [ <nl> + * Tests : <nl> + * 1 : Point Particle System using 32 - bit textures ( PNG ) <nl> + * 2 : Point Particle System using 16 - bit textures ( PNG ) <nl> + * 3 : Point Particle System using 8 - bit textures ( PNG ) <nl> + * 4 : Point Particle System using 4 - bit textures ( PVRTC ) <nl> + <nl> + * 5 : Quad Particle System using 32 - bit textures ( PNG ) <nl> + * 6 : Quad Particle System using 16 - bit textures ( PNG ) <nl> + * 7 : Quad Particle System using 8 - bit textures ( PNG ) <nl> + * 8 : Quad Particle System using 4 - bit textures ( PVRTC ) <nl> + ] ] - - <nl> + pNewScene : removeChildByTag ( ParticleTestParam . kTagParticleSystem , true ) <nl> + <nl> + - - remove the " fire . png " from the TextureCache cache . <nl> + local pTexture = cc . Director : getInstance ( ) : getTextureCache ( ) : addImage ( " Images / fire . png " ) <nl> + cc . Director : getInstance ( ) : getTextureCache ( ) : removeTexture ( pTexture ) <nl> + local pParticleSystem = cc . ParticleSystemQuad : createWithTotalParticles ( nQuantityParticles ) <nl> + if 1 = = nSubtestNumber then <nl> + cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE2_D_PIXEL_FORMAT_RGB_A8888 ) <nl> + elseif 2 = = nSubtestNumber then <nl> + cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE2_D_PIXEL_FORMAT_RGB_A4444 ) <nl> + elseif 3 = = nSubtestNumber then <nl> + cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE2_D_PIXEL_FORMAT_A8 ) <nl> + elseif 4 = = nSubtestNumber then <nl> + cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE2_D_PIXEL_FORMAT_RGB_A8888 ) <nl> + elseif 5 = = nSubtestNumber then <nl> + cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE2_D_PIXEL_FORMAT_RGB_A4444 ) <nl> + elseif 6 = = nSubtestNumber then <nl> + cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE2_D_PIXEL_FORMAT_A8 ) <nl> + else <nl> + pParticleSystem = nil <nl> + print ( " Shall not happen ! " ) <nl> + end <nl> + <nl> + if nil ~ = pParticleSystem then <nl> + pParticleSystem : setTexture ( cc . Director : getInstance ( ) : getTextureCache ( ) : addImage ( " Images / fire . png " ) ) <nl> + end <nl> + <nl> + pNewScene : addChild ( pParticleSystem , 0 , ParticleTestParam . kTagParticleSystem ) <nl> + <nl> + doTest ( ) <nl> + - - restore the default pixel format <nl> + cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE2_D_PIXEL_FORMAT_RGB_A8888 ) <nl> + end <nl> + <nl> + local function step ( t ) <nl> + local pAtlas = tolua . cast ( pNewScene : getChildByTag ( ParticleTestParam . kTagLabelAtlas ) , " cc . LabelAtlas " ) <nl> + local pEmitter = tolua . cast ( pNewScene : getChildByTag ( ParticleTestParam . kTagParticleSystem ) , " cc . ParticleSystem " ) <nl> + local strInfo = string . format ( " % 4d " , pEmitter : getParticleCount ( ) ) <nl> + pAtlas : setString ( strInfo ) <nl> + end <nl> + <nl> + local function ScheduleFuncion ( ) <nl> + local function OnEnterOrExit ( tag ) <nl> + local scheduler = cc . Director : getInstance ( ) : getScheduler ( ) <nl> + if tag = = " enter " then <nl> + ScheduleSelector = scheduler : scheduleScriptFunc ( step , 0 , false ) <nl> + elseif tag = = " exit " then <nl> + scheduler : unscheduleScriptEntry ( ScheduleSelector ) <nl> + end <nl> + end <nl> + pNewScene : registerScriptHandler ( OnEnterOrExit ) <nl> + end <nl> <nl> local function onDecrease ( ) <nl> - nQuantityParticles = nQuantityParticles - ParticleTestParam . kNodesIncrease <nl> - if nQuantityParticles < 0 then <nl> - nQuantityParticles = 0 <nl> + nQuantityParticles = nQuantityParticles - ParticleTestParam . kNodesIncrease <nl> + if nQuantityParticles < 0 then <nl> + nQuantityParticles = 0 <nl> end <nl> <nl> - UpdateQuantityLabel ( ) <nl> - CreateParticleSystem ( ) <nl> + UpdateQuantityLabel ( ) <nl> + CreateParticleSystem ( ) <nl> end <nl> <nl> local function onIncrease ( ) <nl> - nQuantityParticles = nQuantityParticles + ParticleTestParam . kNodesIncrease <nl> - if nQuantityParticles > ParticleTestParam . kMaxParticles then <nl> - nQuantityParticles = ParticleTestParam . kMaxParticles <nl> + nQuantityParticles = nQuantityParticles + ParticleTestParam . kNodesIncrease <nl> + if nQuantityParticles > ParticleTestParam . kMaxParticles then <nl> + nQuantityParticles = ParticleTestParam . kMaxParticles <nl> end <nl> <nl> - UpdateQuantityLabel ( ) <nl> - CreateParticleSystem ( ) <nl> + UpdateQuantityLabel ( ) <nl> + CreateParticleSystem ( ) <nl> end <nl> <nl> local function InitWithSubTest ( nSubtest , nParticles ) <nl> - nSubtestNumber = nSubtest <nl> - local s = cc . Director : getInstance ( ) : getWinSize ( ) <nl> - <nl> - nLastRenderedCount = 0 <nl> - nQuantityParticles = nParticles <nl> - <nl> - - - " + " , " - " Menu <nl> - cc . MenuItemFont : setFontSize ( 65 ) <nl> - local pDecrease = cc . MenuItemFont : create ( " - " ) <nl> - pDecrease : registerScriptTapHandler ( onDecrease ) <nl> - pDecrease : setColor ( cc . c3b ( 0 , 200 , 20 ) ) <nl> - local pIncrease = cc . MenuItemFont : create ( " + " ) <nl> - pIncrease : registerScriptTapHandler ( onIncrease ) <nl> - pIncrease : setColor ( cc . c3b ( 0 , 200 , 20 ) ) <nl> - <nl> - local pMenuAddOrSub = cc . Menu : create ( ) <nl> - pMenuAddOrSub : addChild ( pDecrease ) <nl> - pMenuAddOrSub : addChild ( pIncrease ) <nl> - pMenuAddOrSub : alignItemsHorizontally ( ) <nl> - pMenuAddOrSub : setPosition ( cc . p ( s . width / 2 , s . height / 2 + 15 ) ) <nl> - pNewScene : addChild ( pMenuAddOrSub , 1 ) <nl> - <nl> - local pInfoLabel = cc . LabelTTF : create ( " 0 nodes " , " Marker Felt " , 30 ) <nl> + nSubtestNumber = nSubtest <nl> + local s = cc . Director : getInstance ( ) : getWinSize ( ) <nl> + <nl> + nLastRenderedCount = 0 <nl> + nQuantityParticles = nParticles <nl> + <nl> + - - " + " , " - " Menu <nl> + cc . MenuItemFont : setFontSize ( 65 ) <nl> + local pDecrease = cc . MenuItemFont : create ( " - " ) <nl> + pDecrease : registerScriptTapHandler ( onDecrease ) <nl> + pDecrease : setColor ( cc . c3b ( 0 , 200 , 20 ) ) <nl> + local pIncrease = cc . MenuItemFont : create ( " + " ) <nl> + pIncrease : registerScriptTapHandler ( onIncrease ) <nl> + pIncrease : setColor ( cc . c3b ( 0 , 200 , 20 ) ) <nl> + <nl> + local pMenuAddOrSub = cc . Menu : create ( ) <nl> + pMenuAddOrSub : addChild ( pDecrease ) <nl> + pMenuAddOrSub : addChild ( pIncrease ) <nl> + pMenuAddOrSub : alignItemsHorizontally ( ) <nl> + pMenuAddOrSub : setPosition ( cc . p ( s . width / 2 , s . height / 2 + 15 ) ) <nl> + pNewScene : addChild ( pMenuAddOrSub , 1 ) <nl> + <nl> + local pInfoLabel = cc . LabelTTF : create ( " 0 nodes " , " Marker Felt " , 30 ) <nl> pInfoLabel : setColor ( cc . c3b ( 0 , 200 , 20 ) ) <nl> - pInfoLabel : setPosition ( cc . p ( s . width / 2 , s . height - 90 ) ) <nl> - pNewScene : addChild ( pInfoLabel , 1 , ParticleTestParam . kTagInfoLayer ) <nl> - <nl> - - - particles on stage <nl> - local pLabelAtlas = cc . LabelAtlas : _create ( " 0000 " , " fps_images . png " , 12 , 32 , string . byte ( ' . ' ) ) <nl> - pNewScene : addChild ( pLabelAtlas , 0 , ParticleTestParam . kTagLabelAtlas ) <nl> - pLabelAtlas : setPosition ( cc . p ( s . width - 66 , 50 ) ) <nl> - <nl> - - - ParticleTestMenuLayer <nl> - local pParticleMenuLayer = cc . Layer : create ( ) <nl> - local pParticleMenu = cc . Menu : create ( ) <nl> - CreatePerfomBasicLayerMenu ( pParticleMenu ) <nl> - CreateBasicLayerMenuItem ( pParticleMenu , true , ParticleTestParam . TEST_COUNT , nCurCase ) <nl> - pParticleMenu : setPosition ( cc . p ( 0 , 0 ) ) <nl> - pParticleMenuLayer : addChild ( pParticleMenu ) <nl> - pNewScene : addChild ( pParticleMenuLayer ) <nl> - <nl> - - - Sub Tests <nl> - cc . MenuItemFont : setFontSize ( 40 ) <nl> - local pSubMenu = cc . Menu : create ( ) <nl> - local i = 1 <nl> - for i = 1 , 6 do <nl> - local strNum = string . format ( " % d " , i ) <nl> - local pItemFont = cc . MenuItemFont : create ( strNum ) <nl> - pItemFont : registerScriptTapHandler ( TestNCallback ) <nl> - pSubMenu : addChild ( pItemFont , i + ParticleTestParam . kSubMenuBasicZOrder ) <nl> - if i < = 3 then <nl> - pItemFont : setColor ( cc . c3b ( 200 , 20 , 20 ) ) <nl> - else <nl> - pItemFont : setColor ( cc . c3b ( 0 , 200 , 20 ) ) <nl> - end <nl> - end <nl> - pSubMenu : alignItemsHorizontally ( ) <nl> - pSubMenu : setPosition ( cc . p ( s . width / 2 , 80 ) ) <nl> - pNewScene : addChild ( pSubMenu , 2 ) <nl> - <nl> - local pLabel = cc . LabelTTF : create ( GetTitle ( ) , " Arial " , 40 ) <nl> - pNewScene : addChild ( pLabel , 1 ) <nl> - pLabel : setPosition ( cc . p ( s . width / 2 , s . height - 32 ) ) <nl> - pLabel : setColor ( cc . c3b ( 255 , 255 , 40 ) ) <nl> - <nl> - UpdateQuantityLabel ( ) <nl> - CreateParticleSystem ( ) <nl> - ScheduleFuncion ( ) <nl> + pInfoLabel : setPosition ( cc . p ( s . width / 2 , s . height - 90 ) ) <nl> + pNewScene : addChild ( pInfoLabel , 1 , ParticleTestParam . kTagInfoLayer ) <nl> + <nl> + - - particles on stage <nl> + local pLabelAtlas = cc . LabelAtlas : _create ( " 0000 " , " fps_images . png " , 12 , 32 , string . byte ( ' . ' ) ) <nl> + pNewScene : addChild ( pLabelAtlas , 0 , ParticleTestParam . kTagLabelAtlas ) <nl> + pLabelAtlas : setPosition ( cc . p ( s . width - 66 , 50 ) ) <nl> + <nl> + - - ParticleTestMenuLayer <nl> + local pParticleMenuLayer = cc . Layer : create ( ) <nl> + local pParticleMenu = cc . Menu : create ( ) <nl> + CreatePerfomBasicLayerMenu ( pParticleMenu ) <nl> + CreateBasicLayerMenuItem ( pParticleMenu , true , ParticleTestParam . TEST_COUNT , nCurCase ) <nl> + pParticleMenu : setPosition ( cc . p ( 0 , 0 ) ) <nl> + pParticleMenuLayer : addChild ( pParticleMenu ) <nl> + pNewScene : addChild ( pParticleMenuLayer ) <nl> + <nl> + - - Sub Tests <nl> + cc . MenuItemFont : setFontSize ( 40 ) <nl> + local pSubMenu = cc . Menu : create ( ) <nl> + local i = 1 <nl> + for i = 1 , 6 do <nl> + local strNum = string . format ( " % d " , i ) <nl> + local pItemFont = cc . MenuItemFont : create ( strNum ) <nl> + pItemFont : registerScriptTapHandler ( TestNCallback ) <nl> + pSubMenu : addChild ( pItemFont , i + ParticleTestParam . kSubMenuBasicZOrder ) <nl> + if i < = 3 then <nl> + pItemFont : setColor ( cc . c3b ( 200 , 20 , 20 ) ) <nl> + else <nl> + pItemFont : setColor ( cc . c3b ( 0 , 200 , 20 ) ) <nl> + end <nl> + end <nl> + pSubMenu : alignItemsHorizontally ( ) <nl> + pSubMenu : setPosition ( cc . p ( s . width / 2 , 80 ) ) <nl> + pNewScene : addChild ( pSubMenu , 2 ) <nl> + <nl> + local pLabel = cc . LabelTTF : create ( GetTitle ( ) , " Arial " , 40 ) <nl> + pNewScene : addChild ( pLabel , 1 ) <nl> + pLabel : setPosition ( cc . p ( s . width / 2 , s . height - 32 ) ) <nl> + pLabel : setColor ( cc . c3b ( 255 , 255 , 40 ) ) <nl> + <nl> + UpdateQuantityLabel ( ) <nl> + CreateParticleSystem ( ) <nl> + ScheduleFuncion ( ) <nl> end <nl> <nl> function ShowCurrentTest ( ) <nl> - if nil ~ = pNewScene then <nl> - cc . Director : getInstance ( ) : getScheduler ( ) : unscheduleScriptEntry ( ScheduleSelector ) <nl> - end <nl> - pNewScene = cc . Scene : create ( ) <nl> - InitWithSubTest ( nSubtestNumber , nQuantityParticles ) <nl> - cc . Director : getInstance ( ) : replaceScene ( pNewScene ) <nl> + if nil ~ = pNewScene then <nl> + cc . Director : getInstance ( ) : getScheduler ( ) : unscheduleScriptEntry ( ScheduleSelector ) <nl> + end <nl> + pNewScene = cc . Scene : create ( ) <nl> + InitWithSubTest ( nSubtestNumber , nQuantityParticles ) <nl> + cc . Director : getInstance ( ) : replaceScene ( pNewScene ) <nl> end <nl> <nl> - <nl> - InitWithSubTest ( 1 , ParticleTestParam . kNodesIncrease ) <nl> - return pNewScene <nl> + <nl> + InitWithSubTest ( 1 , ParticleTestParam . kNodesIncrease ) <nl> + return pNewScene <nl> end <nl> <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> end <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> local SpriteTestParam = <nl> { <nl> - kMaxNodes = 50000 , <nl> + kMaxNodes = 50000 , <nl> kNodesIncrease = 250 , <nl> TEST_COUNT = 7 , <nl> <nl> local SpriteTestParam = <nl> } <nl> <nl> local function runSpriteTest ( ) <nl> - - - PerformanceParticle param <nl> + - - PerformanceParticle param <nl> local nLastRenderedCount = 0 <nl> local nQuantityNodes = 0 <nl> local nSubtestNumber = 0 <nl> local function runSpriteTest ( ) <nl> local pBatchNode = nil <nl> <nl> local function GetTitle ( ) <nl> - local strTitle = nil <nl> - if 0 = = nCurCase then <nl> - strTitle = string . format ( " A ( % d ) position " , nSubtestNumber ) <nl> - elseif 1 = = nCurCase then <nl> - strTitle = string . format ( " B ( % d ) scale " , nSubtestNumber ) <nl> - elseif 2 = = nCurCase then <nl> - strTitle = string . format ( " C ( % d ) scale + rot " , nSubtestNumber ) <nl> - elseif 3 = = nCurCase then <nl> - strTitle = string . format ( " D ( % d ) 100 % % out " , nSubtestNumber ) <nl> - elseif 4 = = nCurCase then <nl> - strTitle = string . format ( " E ( % d ) 80 % % out " , nSubtestNumber ) <nl> - elseif 5 = = nCurCase then <nl> - strTitle = string . format ( " F ( % d ) actions " , nSubtestNumber ) <nl> - elseif 6 = = nCurCase then <nl> - strTitle = string . format ( " G ( % d ) actions 80 % % out " , nSubtestNumber ) <nl> - end <nl> - <nl> - return strTitle <nl> + local strTitle = nil <nl> + if 0 = = nCurCase then <nl> + strTitle = string . format ( " A ( % d ) position " , nSubtestNumber ) <nl> + elseif 1 = = nCurCase then <nl> + strTitle = string . format ( " B ( % d ) scale " , nSubtestNumber ) <nl> + elseif 2 = = nCurCase then <nl> + strTitle = string . format ( " C ( % d ) scale + rot " , nSubtestNumber ) <nl> + elseif 3 = = nCurCase then <nl> + strTitle = string . format ( " D ( % d ) 100 % % out " , nSubtestNumber ) <nl> + elseif 4 = = nCurCase then <nl> + strTitle = string . format ( " E ( % d ) 80 % % out " , nSubtestNumber ) <nl> + elseif 5 = = nCurCase then <nl> + strTitle = string . format ( " F ( % d ) actions " , nSubtestNumber ) <nl> + elseif 6 = = nCurCase then <nl> + strTitle = string . format ( " G ( % d ) actions 80 % % out " , nSubtestNumber ) <nl> + end <nl> + <nl> + return strTitle <nl> end <nl> <nl> local pNewScene = cc . Scene : create ( ) <nl> <nl> local function CreateBasicLayerMenuItem ( pMenu , bMenuVisible , nMaxCasesNum , nCurCaseIndex ) <nl> - if nil ~ = pMenu then <nl> - bControlMenuVisible = bMenuVisible <nl> - nMaxCases = nMaxCasesNum <nl> - nCurCase = nCurCaseIndex <nl> - if true = = bControlMenuVisible then <nl> - local function backCallback ( ) <nl> - nCurCase = nCurCase - 1 <nl> - if nCurCase < 0 then <nl> - nCurCase = nCurCase + nMaxCases <nl> - end <nl> - ShowCurrentTest ( ) <nl> - end <nl> - <nl> - local function restartCallback ( ) <nl> - ShowCurrentTest ( ) <nl> - end <nl> - <nl> - local function nextCallback ( ) <nl> - nCurCase = nCurCase + 1 <nl> - - - No check nMaxCases <nl> - nCurCase = nCurCase % nMaxCases <nl> - ShowCurrentTest ( ) <nl> - end <nl> - <nl> - local size = cc . Director : getInstance ( ) : getWinSize ( ) <nl> - local item1 = cc . MenuItemImage : create ( s_pPathB1 , s_pPathB2 ) <nl> - item1 : registerScriptTapHandler ( backCallback ) <nl> - pMenu : addChild ( item1 , kItemTagBasic ) <nl> - local item2 = cc . MenuItemImage : create ( s_pPathR1 , s_pPathR2 ) <nl> - item2 : registerScriptTapHandler ( restartCallback ) <nl> - pMenu : addChild ( item2 , kItemTagBasic ) <nl> - local item3 = cc . MenuItemImage : create ( s_pPathF1 , s_pPathF2 ) <nl> - pMenu : addChild ( item3 , kItemTagBasic ) <nl> - item3 : registerScriptTapHandler ( nextCallback ) <nl> - <nl> - local size = cc . Director : getInstance ( ) : getWinSize ( ) <nl> - item1 : setPosition ( cc . p ( size . width / 2 - item2 : getContentSize ( ) . width * 2 , item2 : getContentSize ( ) . height / 2 ) ) <nl> - item2 : setPosition ( cc . p ( size . width / 2 , item2 : getContentSize ( ) . height / 2 ) ) <nl> - item3 : setPosition ( cc . p ( size . width / 2 + item2 : getContentSize ( ) . width * 2 , item2 : getContentSize ( ) . height / 2 ) ) <nl> - end <nl> - end <nl> + if nil ~ = pMenu then <nl> + bControlMenuVisible = bMenuVisible <nl> + nMaxCases = nMaxCasesNum <nl> + nCurCase = nCurCaseIndex <nl> + if true = = bControlMenuVisible then <nl> + local function backCallback ( ) <nl> + nCurCase = nCurCase - 1 <nl> + if nCurCase < 0 then <nl> + nCurCase = nCurCase + nMaxCases <nl> + end <nl> + ShowCurrentTest ( ) <nl> + end <nl> + <nl> + local function restartCallback ( ) <nl> + ShowCurrentTest ( ) <nl> + end <nl> + <nl> + local function nextCallback ( ) <nl> + nCurCase = nCurCase + 1 <nl> + - - No check nMaxCases <nl> + nCurCase = nCurCase % nMaxCases <nl> + ShowCurrentTest ( ) <nl> + end <nl> + <nl> + local size = cc . Director : getInstance ( ) : getWinSize ( ) <nl> + local item1 = cc . MenuItemImage : create ( s_pPathB1 , s_pPathB2 ) <nl> + item1 : registerScriptTapHandler ( backCallback ) <nl> + pMenu : addChild ( item1 , kItemTagBasic ) <nl> + local item2 = cc . MenuItemImage : create ( s_pPathR1 , s_pPathR2 ) <nl> + item2 : registerScriptTapHandler ( restartCallback ) <nl> + pMenu : addChild ( item2 , kItemTagBasic ) <nl> + local item3 = cc . MenuItemImage : create ( s_pPathF1 , s_pPathF2 ) <nl> + pMenu : addChild ( item3 , kItemTagBasic ) <nl> + item3 : registerScriptTapHandler ( nextCallback ) <nl> + <nl> + local size = cc . Director : getInstance ( ) : getWinSize ( ) <nl> + item1 : setPosition ( cc . p ( size . width / 2 - item2 : getContentSize ( ) . width * 2 , item2 : getContentSize ( ) . height / 2 ) ) <nl> + item2 : setPosition ( cc . p ( size . width / 2 , item2 : getContentSize ( ) . height / 2 ) ) <nl> + item3 : setPosition ( cc . p ( size . width / 2 + item2 : getContentSize ( ) . width * 2 , item2 : getContentSize ( ) . height / 2 ) ) <nl> + end <nl> + end <nl> end <nl> <nl> local function UpdateNodes ( ) <nl> - if nQuantityNodes ~ = nLastRenderedCount then <nl> - local pInfoLabel = tolua . cast ( pNewScene : getChildByTag ( SpriteTestParam . kTagInfoLayer ) , " cc . LabelTTF " ) <nl> - local strInfo = string . format ( " % u nodes " , nQuantityNodes ) <nl> - pInfoLabel : setString ( strInfo ) <nl> - nLastRenderedCount = nQuantityNodes <nl> - end <nl> + if nQuantityNodes ~ = nLastRenderedCount then <nl> + local pInfoLabel = tolua . cast ( pNewScene : getChildByTag ( SpriteTestParam . kTagInfoLayer ) , " cc . LabelTTF " ) <nl> + local strInfo = string . format ( " % u nodes " , nQuantityNodes ) <nl> + pInfoLabel : setString ( strInfo ) <nl> + nLastRenderedCount = nQuantityNodes <nl> + end <nl> end <nl> <nl> local function PerformancePosition ( pSprite ) <nl> - local size = cc . Director : getInstance ( ) : getWinSize ( ) <nl> - pSprite : setPosition ( cc . p ( ( math . random ( 0 , SpriteTestParam . kRandMax ) % ( size . width ) ) , ( math . random ( 0 , SpriteTestParam . kRandMax ) % ( size . height ) ) ) ) <nl> + local size = cc . Director : getInstance ( ) : getWinSize ( ) <nl> + pSprite : setPosition ( cc . p ( ( math . random ( 0 , SpriteTestParam . kRandMax ) % ( size . width ) ) , ( math . random ( 0 , SpriteTestParam . kRandMax ) % ( size . height ) ) ) ) <nl> end <nl> <nl> local function PerformanceScale ( pSprite ) <nl> - local size = cc . Director : getInstance ( ) : getWinSize ( ) <nl> - pSprite : setPosition ( cc . p ( ( math . random ( 0 , SpriteTestParam . kRandMax ) % ( size . width ) ) , ( math . random ( 0 , SpriteTestParam . kRandMax ) % ( size . height ) ) ) ) <nl> - pSprite : setScale ( math . random ( ) * 100 / 50 ) <nl> - end <nl> - <nl> - local function PerformanceRotationScale ( pSprite ) <nl> - local size = cc . Director : getInstance ( ) : getWinSize ( ) <nl> - pSprite : setPosition ( cc . p ( ( math . random ( 0 , SpriteTestParam . kRandMax ) % ( size . width ) ) , ( math . random ( 0 , SpriteTestParam . kRandMax ) % ( size . height ) ) ) ) <nl> - pSprite : setRotation ( math . random ( ) * 360 ) <nl> - pSprite : setScale ( math . random ( ) * 2 ) <nl> - end <nl> - <nl> - local function PerformanceOut100 ( pSprite ) <nl> - pSprite : setPosition ( cc . p ( - 1000 , - 1000 ) ) <nl> - end <nl> - <nl> - local function Performanceout20 ( pSprite ) <nl> - local size = cc . Director : getInstance ( ) : getWinSize ( ) <nl> - <nl> - if math . random ( ) < 0 . 2 then <nl> - pSprite : setPosition ( cc . p ( ( math . random ( 0 , SpriteTestParam . kRandMax ) % ( size . width ) ) , ( math . random ( 0 , SpriteTestParam . kRandMax ) % ( size . height ) ) ) ) <nl> - else <nl> - pSprite : setPosition ( cc . p ( - 1000 , - 1000 ) ) <nl> - end <nl> - end <nl> - <nl> - local function PerformanceActions ( pSprite ) <nl> - local size = cc . Director : getInstance ( ) : getWinSize ( ) <nl> - pSprite : setPosition ( cc . p ( ( math . random ( 0 , SpriteTestParam . kRandMax ) % ( size . width ) ) , ( math . random ( 0 , SpriteTestParam . kRandMax ) % ( size . height ) ) ) ) <nl> - <nl> - local fPeriod = 0 . 5 + ( math . random ( 0 , SpriteTestParam . kRandMax ) % 1000 ) / 500 . 0 <nl> - local pRot = cc . RotateBy : create ( fPeriod , 360 . 0 * math . random ( ) ) <nl> - local pRot_back = pRot : reverse ( ) <nl> - local pPermanentRotation = cc . RepeatForever : create ( cc . Sequence : create ( pRot , pRot_back ) ) <nl> - pSprite : runAction ( pPermanentRotation ) <nl> - <nl> - local fGrowDuration = 0 . 5 + ( math . random ( 0 , SpriteTestParam . kRandMax ) % 1000 ) / 500 . 0 <nl> - local pGrow = cc . ScaleBy : create ( fGrowDuration , 0 . 5 , 0 . 5 ) <nl> - local pPermanentScaleLoop = cc . RepeatForever : create ( cc . Sequence : create ( pGrow , pGrow : reverse ( ) ) ) <nl> - pSprite : runAction ( pPermanentScaleLoop ) <nl> - end <nl> - <nl> - local function PerformanceActions20 ( pSprite ) <nl> - local size = cc . Director : getInstance ( ) : getWinSize ( ) <nl> - <nl> - if math . random ( ) < 0 . 2 then <nl> - pSprite : setPosition ( cc . p ( ( math . random ( 0 , SpriteTestParam . kRandMax ) % ( size . width ) ) , ( math . random ( 0 , SpriteTestParam . kRandMax ) % ( size . height ) ) ) ) <nl> - else <nl> - pSprite : setPosition ( cc . p ( - 1000 , - 1000 ) ) <nl> + local size = cc . Director : getInstance ( ) : getWinSize ( ) <nl> + pSprite : setPosition ( cc . p ( ( math . random ( 0 , SpriteTestParam . kRandMax ) % ( size . width ) ) , ( math . random ( 0 , SpriteTestParam . kRandMax ) % ( size . height ) ) ) ) <nl> + pSprite : setScale ( math . random ( ) * 100 / 50 ) <nl> + end <nl> + <nl> + local function PerformanceRotationScale ( pSprite ) <nl> + local size = cc . Director : getInstance ( ) : getWinSize ( ) <nl> + pSprite : setPosition ( cc . p ( ( math . random ( 0 , SpriteTestParam . kRandMax ) % ( size . width ) ) , ( math . random ( 0 , SpriteTestParam . kRandMax ) % ( size . height ) ) ) ) <nl> + pSprite : setRotation ( math . random ( ) * 360 ) <nl> + pSprite : setScale ( math . random ( ) * 2 ) <nl> + end <nl> + <nl> + local function PerformanceOut100 ( pSprite ) <nl> + pSprite : setPosition ( cc . p ( - 1000 , - 1000 ) ) <nl> + end <nl> + <nl> + local function Performanceout20 ( pSprite ) <nl> + local size = cc . Director : getInstance ( ) : getWinSize ( ) <nl> + print ( " come in " ) <nl> + if math . random ( ) < 0 . 2 then <nl> + pSprite : setPosition ( cc . p ( ( math . random ( 0 , SpriteTestParam . kRandMax ) % ( size . width ) ) , ( math . random ( 0 , SpriteTestParam . kRandMax ) % ( size . height ) ) ) ) <nl> + else <nl> + pSprite : setPosition ( cc . p ( - 1000 , - 1000 ) ) <nl> + end <nl> + end <nl> + <nl> + local function PerformanceActions ( pSprite ) <nl> + local size = cc . Director : getInstance ( ) : getWinSize ( ) <nl> + pSprite : setPosition ( cc . p ( ( math . random ( 0 , SpriteTestParam . kRandMax ) % ( size . width ) ) , ( math . random ( 0 , SpriteTestParam . kRandMax ) % ( size . height ) ) ) ) <nl> + <nl> + local fPeriod = 0 . 5 + ( math . random ( 0 , SpriteTestParam . kRandMax ) % 1000 ) / 500 . 0 <nl> + local pRot = cc . RotateBy : create ( fPeriod , 360 . 0 * math . random ( ) ) <nl> + local pRot_back = pRot : reverse ( ) <nl> + local pPermanentRotation = cc . RepeatForever : create ( cc . Sequence : create ( pRot , pRot_back ) ) <nl> + pSprite : runAction ( pPermanentRotation ) <nl> + <nl> + local fGrowDuration = 0 . 5 + ( math . random ( 0 , SpriteTestParam . kRandMax ) % 1000 ) / 500 . 0 <nl> + local pGrow = cc . ScaleBy : create ( fGrowDuration , 0 . 5 , 0 . 5 ) <nl> + local pPermanentScaleLoop = cc . RepeatForever : create ( cc . Sequence : create ( pGrow , pGrow : reverse ( ) ) ) <nl> + pSprite : runAction ( pPermanentScaleLoop ) <nl> + end <nl> + <nl> + local function PerformanceActions20 ( pSprite ) <nl> + local size = cc . Director : getInstance ( ) : getWinSize ( ) <nl> + <nl> + if math . random ( ) < 0 . 2 then <nl> + pSprite : setPosition ( cc . p ( ( math . random ( 0 , SpriteTestParam . kRandMax ) % ( size . width ) ) , ( math . random ( 0 , SpriteTestParam . kRandMax ) % ( size . height ) ) ) ) <nl> + else <nl> + pSprite : setPosition ( cc . p ( - 1000 , - 1000 ) ) <nl> end <nl> <nl> - local pPeriod = 0 . 5 + ( math . random ( 0 , SpriteTestParam . kRandMax ) % 1000 ) / 500 . 0 <nl> - local pRot = cc . RotateBy : create ( pPeriod , 360 . 0 * math . random ( ) ) <nl> - local pRot_back = pRot : reverse ( ) <nl> - local pPermanentRotation = cc . RepeatForever : create ( cc . Sequence : create ( pRot , pRot_back ) ) <nl> - pSprite : runAction ( pPermanentRotation ) <nl> + local pPeriod = 0 . 5 + ( math . random ( 0 , SpriteTestParam . kRandMax ) % 1000 ) / 500 . 0 <nl> + local pRot = cc . RotateBy : create ( pPeriod , 360 . 0 * math . random ( ) ) <nl> + local pRot_back = pRot : reverse ( ) <nl> + local pPermanentRotation = cc . RepeatForever : create ( cc . Sequence : create ( pRot , pRot_back ) ) <nl> + pSprite : runAction ( pPermanentRotation ) <nl> <nl> <nl> - local fGrowDuration = 0 . 5 + ( math . random ( 0 , SpriteTestParam . kRandMax ) % 1000 ) / 500 . 0 <nl> - local pGrow = cc . ScaleBy : create ( fGrowDuration , 0 . 5 , 0 . 5 ) <nl> + local fGrowDuration = 0 . 5 + ( math . random ( 0 , SpriteTestParam . kRandMax ) % 1000 ) / 500 . 0 <nl> + local pGrow = cc . ScaleBy : create ( fGrowDuration , 0 . 5 , 0 . 5 ) <nl> local pPermanentScaleLoop = cc . RepeatForever : create ( cc . Sequence : create ( pGrow , pGrow : reverse ( ) ) ) <nl> - pSprite : runAction ( pPermanentScaleLoop ) <nl> - <nl> - end <nl> - <nl> - local function CreateSpriteWithTag ( nTag ) <nl> + pSprite : runAction ( pPermanentScaleLoop ) <nl> + <nl> + end <nl> + <nl> + local function CreateSpriteWithTag ( nTag ) <nl> - - create <nl> - cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE2_D_PIXEL_FORMAT_RGB_A8888 ) <nl> - local pSprite = nil <nl> - if 1 = = nSubtestNumber then <nl> - pSprite = cc . Sprite : create ( " Images / grossinis_sister1 . png " ) <nl> + cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE2_D_PIXEL_FORMAT_RGB_A8888 ) <nl> + local pSprite = nil <nl> + if 1 = = nSubtestNumber then <nl> + pSprite = cc . Sprite : create ( " Images / grossinis_sister1 . png " ) <nl> pNewScene : addChild ( pSprite , 0 , nTag + 100 ) <nl> - elseif 2 = = nSubtestNumber or 3 = = nSubtestNumber then <nl> - pSprite = cc . Sprite : createWithTexture ( pBatchNode : getTexture ( ) , cc . rect ( 0 , 0 , 52 , 139 ) ) <nl> + elseif 2 = = nSubtestNumber or 3 = = nSubtestNumber then <nl> + pSprite = cc . Sprite : createWithTexture ( pBatchNode : getTexture ( ) , cc . rect ( 0 , 0 , 52 , 139 ) ) <nl> pBatchNode : addChild ( pSprite , 0 , nTag + 100 ) <nl> - elseif 4 = = nSubtestNumber then <nl> - local nIndex = math . floor ( ( math . random ( ) * 1400 / 100 ) ) + 1 <nl> + elseif 4 = = nSubtestNumber then <nl> + local nIndex = math . floor ( ( math . random ( ) * 1400 / 100 ) ) + 1 <nl> local strPath = string . format ( " Images / grossini_dance_ % 02d . png " , nIndex ) <nl> pSprite = cc . Sprite : create ( strPath ) <nl> pNewScene : addChild ( pSprite , 0 , nTag + 100 ) <nl> - elseif 5 = = nSubtestNumber or 6 = = nSubtestNumber then <nl> - local nY = 0 <nl> - local nX = 0 <nl> + elseif 5 = = nSubtestNumber or 6 = = nSubtestNumber then <nl> + local nY = 0 <nl> + local nX = 0 <nl> local nR = math . floor ( math . random ( ) * 1400 / 100 ) <nl> <nl> nX = nR % 5 <nl> local function runSpriteTest ( ) <nl> nY = nY * 121 <nl> pSprite = cc . Sprite : createWithTexture ( pBatchNode : getTexture ( ) , cc . rect ( nX , nY , 85 , 121 ) ) <nl> pBatchNode : addChild ( pSprite , 0 , nTag + 100 ) <nl> - elseif 7 = = nSubtestNumber then <nl> - local nX = 0 <nl> - local nY = 0 <nl> + elseif 7 = = nSubtestNumber then <nl> + local nX = 0 <nl> + local nY = 0 <nl> local nR = math . floor ( math . random ( ) * 6400 / 100 ) <nl> <nl> - nX = nR % 8 <nl> + nX = nR % 8 <nl> nY = math . floor ( nR / 8 ) <nl> <nl> local strPath = string . format ( " Images / sprites_test / sprite - % d - % d . png " , nX , nY ) <nl> pSprite = cc . Sprite : create ( strPath ) <nl> pNewScene : addChild ( pSprite , 0 , nTag + 100 ) <nl> - elseif 8 = = nSubtestNumber or 9 = = nSubtestNumber then <nl> - local nX = 0 <nl> - local nY = 0 <nl> + elseif 8 = = nSubtestNumber or 9 = = nSubtestNumber then <nl> + local nX = 0 <nl> + local nY = 0 <nl> local nR = math . floor ( math . random ( ) * 6400 / 100 ) <nl> <nl> - nX = nR % 8 <nl> + nX = nR % 8 <nl> nY = math . floor ( nR / 8 ) <nl> <nl> nX = nX * 32 <nl> nY = nY * 32 <nl> pSprite = cc . Sprite : createWithTexture ( pBatchNode : getTexture ( ) , cc . rect ( nX , nY , 32 , 32 ) ) <nl> pBatchNode : addChild ( pSprite , 0 , nTag + 100 ) <nl> - end <nl> - cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE_PIXELFORMAT_DEFAULT ) <nl> - <nl> - return pSprite <nl> + end <nl> + cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE_PIXELFORMAT_DEFAULT ) <nl> + <nl> + return pSprite <nl> end <nl> <nl> local function RemoveByTag ( nTag ) <nl> - if 1 = = nSubtestNumber or 4 = = nSubtestNumber or 7 = = nSubtestNumber then <nl> - pNewScene : removeChildByTag ( nTag + 100 , true ) <nl> - elseif 2 = = nSubtestNumber or 3 = = nSubtestNumber or 5 = = nSubtestNumber or 6 = = nSubtestNumber or 8 = = nSubtestNumber or 9 = = nSubtestNumber then <nl> - pBatchNode : removeChildAtIndex ( nTag , true ) <nl> - end <nl> - <nl> + if 1 = = nSubtestNumber or 4 = = nSubtestNumber or 7 = = nSubtestNumber then <nl> + pNewScene : removeChildByTag ( nTag + 100 , true ) <nl> + elseif 2 = = nSubtestNumber or 3 = = nSubtestNumber or 5 = = nSubtestNumber or 6 = = nSubtestNumber or 8 = = nSubtestNumber or 9 = = nSubtestNumber then <nl> + pBatchNode : removeChildAtIndex ( nTag , true ) <nl> + end <nl> + <nl> end <nl> <nl> local function DoTest ( pSprite ) <nl> - if 0 = = nCurCase then <nl> - PerformancePosition ( pSprite ) <nl> - elseif 1 = = nCurCase then <nl> - PerformanceScale ( pSprite ) <nl> - elseif 2 = = nCurCase then <nl> - PerformanceRotationScale ( pSprite ) <nl> - elseif 3 = = nCurCase then <nl> - PerformanceOut100 ( pSprite ) <nl> - elseif 4 = = nCurCase then <nl> - Performanceout20 ( pSprite ) <nl> - elseif 5 = = nCurCase then <nl> - PerformanceActions ( pSprite ) <nl> - elseif 6 = = nCurCase then <nl> - PerformanceActions20 ( pSprite ) <nl> - end <nl> + if 0 = = nCurCase then <nl> + PerformancePosition ( pSprite ) <nl> + elseif 1 = = nCurCase then <nl> + PerformanceScale ( pSprite ) <nl> + elseif 2 = = nCurCase then <nl> + PerformanceRotationScale ( pSprite ) <nl> + elseif 3 = = nCurCase then <nl> + PerformanceOut100 ( pSprite ) <nl> + elseif 4 = = nCurCase then <nl> + Performanceout20 ( pSprite ) <nl> + elseif 5 = = nCurCase then <nl> + PerformanceActions ( pSprite ) <nl> + elseif 6 = = nCurCase then <nl> + PerformanceActions20 ( pSprite ) <nl> + end <nl> end <nl> <nl> local function onDecrease ( ) <nl> - if nQuantityNodes < = 0 then <nl> - return <nl> - end <nl> - <nl> - local i = 0 <nl> - for i = 0 , SpriteTestParam . kNodesIncrease - 1 do <nl> - nQuantityNodes = nQuantityNodes - 1 <nl> - RemoveByTag ( nQuantityNodes ) <nl> - end <nl> - UpdateNodes ( ) <nl> + if nQuantityNodes < = 0 then <nl> + return <nl> + end <nl> + <nl> + local i = 0 <nl> + for i = 0 , SpriteTestParam . kNodesIncrease - 1 do <nl> + nQuantityNodes = nQuantityNodes - 1 <nl> + RemoveByTag ( nQuantityNodes ) <nl> + end <nl> + UpdateNodes ( ) <nl> end <nl> <nl> local function onIncrease ( ) <nl> - if nQuantityNodes > = SpriteTestParam . kMaxNodes then <nl> - return <nl> - end <nl> - <nl> - local i = 0 <nl> - for i = 0 , SpriteTestParam . kNodesIncrease - 1 do <nl> - local pSprite = CreateSpriteWithTag ( nQuantityNodes ) <nl> + if nQuantityNodes > = SpriteTestParam . kMaxNodes then <nl> + return <nl> + end <nl> + <nl> + local i = 0 <nl> + for i = 0 , SpriteTestParam . kNodesIncrease - 1 do <nl> + local pSprite = CreateSpriteWithTag ( nQuantityNodes ) <nl> DoTest ( pSprite ) <nl> - nQuantityNodes = nQuantityNodes + 1 <nl> - end <nl> - UpdateNodes ( ) <nl> + nQuantityNodes = nQuantityNodes + 1 <nl> + end <nl> + UpdateNodes ( ) <nl> end <nl> <nl> local function TestNCallback ( tag , pMenuItem ) <nl> - local nIndex = pMenuItem : getLocalZOrder ( ) - SpriteTestParam . kSubMenuBasicZOrder <nl> - nSubtestNumber = nIndex <nl> - ShowCurrentTest ( ) <nl> + local nIndex = pMenuItem : getLocalZOrder ( ) - SpriteTestParam . kSubMenuBasicZOrder <nl> + nSubtestNumber = nIndex <nl> + ShowCurrentTest ( ) <nl> end <nl> <nl> local function InitWithSubTest ( nSubTest ) <nl> - pBatchNode = nil <nl> - - - [ [ <nl> - * Tests : <nl> - * 1 : 1 ( 32 - bit ) PNG sprite of 52 x 139 <nl> - * 2 : 1 ( 32 - bit ) PNG Batch Node using 1 sprite of 52 x 139 <nl> - * 3 : 1 ( 16 - bit ) PNG Batch Node using 1 sprite of 52 x 139 <nl> - * 4 : 1 ( 4 - bit ) PVRTC Batch Node using 1 sprite of 52 x 139 <nl> - <nl> - * 5 : 14 ( 32 - bit ) PNG sprites of 85 x 121 each <nl> - * 6 : 14 ( 32 - bit ) PNG Batch Node of 85 x 121 each <nl> - * 7 : 14 ( 16 - bit ) PNG Batch Node of 85 x 121 each <nl> - * 8 : 14 ( 4 - bit ) PVRTC Batch Node of 85 x 121 each <nl> - <nl> - * 9 : 64 ( 32 - bit ) sprites of 32 x 32 each <nl> - * 10 : 64 ( 32 - bit ) PNG Batch Node of 32 x 32 each <nl> - * 11 : 64 ( 16 - bit ) PNG Batch Node of 32 x 32 each <nl> - * 12 : 64 ( 4 - bit ) PVRTC Batch Node of 32 x 32 each <nl> - ] ] - - <nl> - - - purge textures <nl> - local pMgr = cc . Director : getInstance ( ) : getTextureCache ( ) <nl> - - - [ mgr removeAllTextures ] <nl> - pMgr : removeTexture ( pMgr : addImage ( " Images / grossinis_sister1 . png " ) ) <nl> - pMgr : removeTexture ( pMgr : addImage ( " Images / grossini_dance_atlas . png " ) ) <nl> - pMgr : removeTexture ( pMgr : addImage ( " Images / spritesheet1 . png " ) ) <nl> - <nl> - if 1 = = nSubTest or 4 = = nSubTest or 7 = = nSubTest then <nl> - elseif 2 = = nSubTest then <nl> - cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE2_D_PIXEL_FORMAT_RGB_A8888 ) <nl> + pBatchNode = nil <nl> + - - [ [ <nl> + * Tests : <nl> + * 1 : 1 ( 32 - bit ) PNG sprite of 52 x 139 <nl> + * 2 : 1 ( 32 - bit ) PNG Batch Node using 1 sprite of 52 x 139 <nl> + * 3 : 1 ( 16 - bit ) PNG Batch Node using 1 sprite of 52 x 139 <nl> + * 4 : 1 ( 4 - bit ) PVRTC Batch Node using 1 sprite of 52 x 139 <nl> + <nl> + * 5 : 14 ( 32 - bit ) PNG sprites of 85 x 121 each <nl> + * 6 : 14 ( 32 - bit ) PNG Batch Node of 85 x 121 each <nl> + * 7 : 14 ( 16 - bit ) PNG Batch Node of 85 x 121 each <nl> + * 8 : 14 ( 4 - bit ) PVRTC Batch Node of 85 x 121 each <nl> + <nl> + * 9 : 64 ( 32 - bit ) sprites of 32 x 32 each <nl> + * 10 : 64 ( 32 - bit ) PNG Batch Node of 32 x 32 each <nl> + * 11 : 64 ( 16 - bit ) PNG Batch Node of 32 x 32 each <nl> + * 12 : 64 ( 4 - bit ) PVRTC Batch Node of 32 x 32 each <nl> + ] ] - - <nl> + - - purge textures <nl> + local pMgr = cc . Director : getInstance ( ) : getTextureCache ( ) <nl> + - - [ mgr removeAllTextures ] <nl> + pMgr : removeTexture ( pMgr : addImage ( " Images / grossinis_sister1 . png " ) ) <nl> + pMgr : removeTexture ( pMgr : addImage ( " Images / grossini_dance_atlas . png " ) ) <nl> + pMgr : removeTexture ( pMgr : addImage ( " Images / spritesheet1 . png " ) ) <nl> + <nl> + if 1 = = nSubTest or 4 = = nSubTest or 7 = = nSubTest then <nl> + elseif 2 = = nSubTest then <nl> + cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE2_D_PIXEL_FORMAT_RGB_A8888 ) <nl> pBatchNode = cc . SpriteBatchNode : create ( " Images / grossinis_sister1 . png " , 100 ) <nl> pNewScene : addChild ( pBatchNode , 0 ) <nl> - elseif 3 = = nSubTest then <nl> - cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE2_D_PIXEL_FORMAT_RGB_A4444 ) <nl> + elseif 3 = = nSubTest then <nl> + cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE2_D_PIXEL_FORMAT_RGB_A4444 ) <nl> pBatchNode = cc . SpriteBatchNode : create ( " Images / grossinis_sister1 . png " , 100 ) <nl> pNewScene : addChild ( pBatchNode , 0 ) <nl> - elseif 5 = = nSubTest then <nl> - cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE2_D_PIXEL_FORMAT_RGB_A8888 ) <nl> + elseif 5 = = nSubTest then <nl> + cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE2_D_PIXEL_FORMAT_RGB_A8888 ) <nl> pBatchNode = cc . SpriteBatchNode : create ( " Images / grossini_dance_atlas . png " , 100 ) <nl> pNewScene : addChild ( pBatchNode , 0 ) <nl> - elseif 6 = = nSubTest then <nl> - cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE2_D_PIXEL_FORMAT_RGB_A4444 ) <nl> + elseif 6 = = nSubTest then <nl> + cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE2_D_PIXEL_FORMAT_RGB_A4444 ) <nl> pBatchNode = cc . SpriteBatchNode : create ( " Images / grossini_dance_atlas . png " , 100 ) <nl> pNewScene : addChild ( pBatchNode , 0 ) <nl> - elseif 8 = = nSubTest then <nl> - cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE2_D_PIXEL_FORMAT_RGB_A8888 ) <nl> + elseif 8 = = nSubTest then <nl> + cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE2_D_PIXEL_FORMAT_RGB_A8888 ) <nl> pBatchNode = cc . SpriteBatchNode : create ( " Images / spritesheet1 . png " , 100 ) <nl> pNewScene : addChild ( pBatchNode , 0 ) <nl> - elseif 9 = = nSubTest then <nl> - cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE2_D_PIXEL_FORMAT_RGB_A4444 ) <nl> + elseif 9 = = nSubTest then <nl> + cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE2_D_PIXEL_FORMAT_RGB_A4444 ) <nl> pBatchNode = cc . SpriteBatchNode : create ( " Images / spritesheet1 . png " , 100 ) <nl> pNewScene : addChild ( pBatchNode , 0 ) <nl> - end <nl> - <nl> - if nil ~ = pBatchNode then <nl> - pBatchNode : retain ( ) <nl> - end <nl> + end <nl> + <nl> + if nil ~ = pBatchNode then <nl> + pBatchNode : retain ( ) <nl> + end <nl> <nl> - cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE_PIXELFORMAT_DEFAULT ) <nl> + cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE_PIXELFORMAT_DEFAULT ) <nl> end <nl> <nl> local function InitWithSpriteTest ( nSubtest , nNodes ) <nl> - nSubtestNumber = nSubtest <nl> - - - about create subset <nl> - InitWithSubTest ( nSubtest ) <nl> - local s = cc . Director : getInstance ( ) : getWinSize ( ) <nl> - <nl> - nLastRenderedCount = 0 <nl> - nQuantityNodes = 0 <nl> - <nl> - - - " + " , " - " Menu <nl> - cc . MenuItemFont : setFontSize ( 65 ) <nl> - local pDecrease = cc . MenuItemFont : create ( " - " ) <nl> - pDecrease : registerScriptTapHandler ( onDecrease ) <nl> - pDecrease : setColor ( cc . c3b ( 0 , 200 , 20 ) ) <nl> - local pIncrease = cc . MenuItemFont : create ( " + " ) <nl> - pIncrease : registerScriptTapHandler ( onIncrease ) <nl> - pIncrease : setColor ( cc . c3b ( 0 , 200 , 20 ) ) <nl> - <nl> - local pMenuAddOrSub = cc . Menu : create ( ) <nl> - pMenuAddOrSub : addChild ( pDecrease ) <nl> - pMenuAddOrSub : addChild ( pIncrease ) <nl> - pMenuAddOrSub : alignItemsHorizontally ( ) <nl> - pMenuAddOrSub : setPosition ( cc . p ( s . width / 2 , s . height / 2 + 15 ) ) <nl> - pNewScene : addChild ( pMenuAddOrSub , 1 ) <nl> - <nl> - local pInfoLabel = cc . LabelTTF : create ( " 0 nodes " , " Marker Felt " , 30 ) <nl> + nSubtestNumber = nSubtest <nl> + - - about create subset <nl> + InitWithSubTest ( nSubtest ) <nl> + local s = cc . Director : getInstance ( ) : getWinSize ( ) <nl> + <nl> + nLastRenderedCount = 0 <nl> + nQuantityNodes = 0 <nl> + <nl> + - - " + " , " - " Menu <nl> + cc . MenuItemFont : setFontSize ( 65 ) <nl> + local pDecrease = cc . MenuItemFont : create ( " - " ) <nl> + pDecrease : registerScriptTapHandler ( onDecrease ) <nl> + pDecrease : setColor ( cc . c3b ( 0 , 200 , 20 ) ) <nl> + local pIncrease = cc . MenuItemFont : create ( " + " ) <nl> + pIncrease : registerScriptTapHandler ( onIncrease ) <nl> + pIncrease : setColor ( cc . c3b ( 0 , 200 , 20 ) ) <nl> + <nl> + local pMenuAddOrSub = cc . Menu : create ( ) <nl> + pMenuAddOrSub : addChild ( pDecrease ) <nl> + pMenuAddOrSub : addChild ( pIncrease ) <nl> + pMenuAddOrSub : alignItemsHorizontally ( ) <nl> + pMenuAddOrSub : setPosition ( cc . p ( s . width / 2 , s . height / 2 + 15 ) ) <nl> + pNewScene : addChild ( pMenuAddOrSub , 1 ) <nl> + <nl> + local pInfoLabel = cc . LabelTTF : create ( " 0 nodes " , " Marker Felt " , 30 ) <nl> pInfoLabel : setColor ( cc . c3b ( 0 , 200 , 20 ) ) <nl> - pInfoLabel : setPosition ( cc . p ( s . width / 2 , s . height - 90 ) ) <nl> - pNewScene : addChild ( pInfoLabel , 1 , SpriteTestParam . kTagInfoLayer ) <nl> - <nl> - - - SpriteTestMenuLayer <nl> - local pSpriteMenuLayer = cc . Layer : create ( ) <nl> - local pSpriteMenu = cc . Menu : create ( ) <nl> - CreatePerfomBasicLayerMenu ( pSpriteMenu ) <nl> - CreateBasicLayerMenuItem ( pSpriteMenu , true , SpriteTestParam . TEST_COUNT , nCurCase ) <nl> - pSpriteMenu : setPosition ( cc . p ( 0 , 0 ) ) <nl> - pSpriteMenuLayer : addChild ( pSpriteMenu ) <nl> - pNewScene : addChild ( pSpriteMenuLayer , 1 , SpriteTestParam . kTagMenuLayer ) <nl> - <nl> - <nl> - - - Sub Tests <nl> - cc . MenuItemFont : setFontSize ( 40 ) <nl> - local pSubMenu = cc . Menu : create ( ) <nl> - local i = 1 <nl> - for i = 1 , 9 do <nl> - local strNum = string . format ( " % d " , i ) <nl> - local pItemFont = cc . MenuItemFont : create ( strNum ) <nl> - pItemFont : registerScriptTapHandler ( TestNCallback ) <nl> - pSubMenu : addChild ( pItemFont , i + SpriteTestParam . kSubMenuBasicZOrder ) <nl> - if i < = 3 then <nl> - pItemFont : setColor ( cc . c3b ( 200 , 20 , 20 ) ) <nl> - elseif i < = 6 then <nl> - pItemFont : setColor ( cc . c3b ( 0 , 200 , 20 ) ) <nl> - else <nl> - pItemFont : setColor ( cc . c3b ( 0 , 20 , 200 ) ) <nl> - end <nl> - end <nl> - <nl> - <nl> - pSubMenu : alignItemsHorizontally ( ) <nl> - pSubMenu : setPosition ( cc . p ( s . width / 2 , 80 ) ) <nl> - pNewScene : addChild ( pSubMenu , 2 ) <nl> - <nl> - local pLabel = cc . LabelTTF : create ( GetTitle ( ) , " Arial " , 40 ) <nl> - pNewScene : addChild ( pLabel , 1 ) <nl> - pLabel : setPosition ( cc . p ( s . width / 2 , s . height - 32 ) ) <nl> - pLabel : setColor ( cc . c3b ( 255 , 255 , 40 ) ) <nl> - while nQuantityNodes < nNodes do <nl> - onIncrease ( ) <nl> - end <nl> - end <nl> - <nl> - function ShowCurrentTest ( ) <nl> - pNewScene = cc . Scene : create ( ) <nl> - InitWithSpriteTest ( nSubtestNumber , nQuantityNodes ) <nl> - cc . Director : getInstance ( ) : replaceScene ( pNewScene ) <nl> + pInfoLabel : setPosition ( cc . p ( s . width / 2 , s . height - 90 ) ) <nl> + pNewScene : addChild ( pInfoLabel , 1 , SpriteTestParam . kTagInfoLayer ) <nl> + <nl> + - - SpriteTestMenuLayer <nl> + local pSpriteMenuLayer = cc . Layer : create ( ) <nl> + local pSpriteMenu = cc . Menu : create ( ) <nl> + CreatePerfomBasicLayerMenu ( pSpriteMenu ) <nl> + CreateBasicLayerMenuItem ( pSpriteMenu , true , SpriteTestParam . TEST_COUNT , nCurCase ) <nl> + pSpriteMenu : setPosition ( cc . p ( 0 , 0 ) ) <nl> + pSpriteMenuLayer : addChild ( pSpriteMenu ) <nl> + pNewScene : addChild ( pSpriteMenuLayer , 1 , SpriteTestParam . kTagMenuLayer ) <nl> + <nl> + <nl> + - - Sub Tests <nl> + cc . MenuItemFont : setFontSize ( 40 ) <nl> + local pSubMenu = cc . Menu : create ( ) <nl> + local i = 1 <nl> + for i = 1 , 9 do <nl> + local strNum = string . format ( " % d " , i ) <nl> + local pItemFont = cc . MenuItemFont : create ( strNum ) <nl> + pItemFont : registerScriptTapHandler ( TestNCallback ) <nl> + pSubMenu : addChild ( pItemFont , i + SpriteTestParam . kSubMenuBasicZOrder ) <nl> + if i < = 3 then <nl> + pItemFont : setColor ( cc . c3b ( 200 , 20 , 20 ) ) <nl> + elseif i < = 6 then <nl> + pItemFont : setColor ( cc . c3b ( 0 , 200 , 20 ) ) <nl> + else <nl> + pItemFont : setColor ( cc . c3b ( 0 , 20 , 200 ) ) <nl> + end <nl> + end <nl> + <nl> + <nl> + pSubMenu : alignItemsHorizontally ( ) <nl> + pSubMenu : setPosition ( cc . p ( s . width / 2 , 80 ) ) <nl> + pNewScene : addChild ( pSubMenu , 2 ) <nl> + <nl> + local pLabel = cc . LabelTTF : create ( GetTitle ( ) , " Arial " , 40 ) <nl> + pNewScene : addChild ( pLabel , 1 ) <nl> + pLabel : setPosition ( cc . p ( s . width / 2 , s . height - 32 ) ) <nl> + pLabel : setColor ( cc . c3b ( 255 , 255 , 40 ) ) <nl> + while nQuantityNodes < nNodes do <nl> + onIncrease ( ) <nl> + end <nl> + end <nl> + <nl> + function ShowCurrentTest ( ) <nl> + pNewScene = cc . Scene : create ( ) <nl> + InitWithSpriteTest ( nSubtestNumber , nQuantityNodes ) <nl> + cc . Director : getInstance ( ) : replaceScene ( pNewScene ) <nl> end <nl> <nl> InitWithSpriteTest ( 1 , SpriteTestParam . kInitNodes ) <nl> end <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> local TextureTestParam = <nl> { <nl> - TEST_COUNT = 1 , <nl> + TEST_COUNT = 1 , <nl> } <nl> <nl> local function runTextureTest ( ) <nl> - <nl> - local function GetTitle ( ) <nl> - return " Texture Performance Test " <nl> - end <nl> - <nl> - local function GetSubtitle ( ) <nl> - return " See console for results " <nl> - end <nl> - <nl> - local nTexCurCase = 0 <nl> - local pNewscene = cc . Scene : create ( ) <nl> - local pLayer = cc . Layer : create ( ) <nl> - local s = cc . Director : getInstance ( ) : getWinSize ( ) <nl> - <nl> - local function PerformTestsPNG ( strFileName ) <nl> - local time <nl> - local pTexture = nil <nl> - local pCache = cc . Director : getInstance ( ) : getTextureCache ( ) <nl> + <nl> + local function GetTitle ( ) <nl> + return " Texture Performance Test " <nl> + end <nl> + <nl> + local function GetSubtitle ( ) <nl> + return " See console for results " <nl> + end <nl> + <nl> + local nTexCurCase = 0 <nl> + local pNewscene = cc . Scene : create ( ) <nl> + local pLayer = cc . Layer : create ( ) <nl> + local s = cc . Director : getInstance ( ) : getWinSize ( ) <nl> + <nl> + local function PerformTestsPNG ( strFileName ) <nl> + local time <nl> + local pTexture = nil <nl> + local pCache = cc . Director : getInstance ( ) : getTextureCache ( ) <nl> <nl> local pDefaultFormat = cc . Texture2D : getDefaultAlphaPixelFormat ( ) ; <nl> <nl> - print ( " RGBA 8888 " ) <nl> - cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE2_D_PIXEL_FORMAT_RGB_A8888 ) <nl> - pTexture = pCache : addImage ( strFileName ) <nl> - if nil ~ = pTexture then <nl> - - - os . time ( ) - - get secs , not micr sec <nl> - print ( " add sucess " ) <nl> - else <nl> - print ( " ERROR " ) <nl> + print ( " RGBA 8888 " ) <nl> + cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE2_D_PIXEL_FORMAT_RGB_A8888 ) <nl> + pTexture = pCache : addImage ( strFileName ) <nl> + if nil ~ = pTexture then <nl> + - - os . time ( ) - - get secs , not micr sec <nl> + print ( " add sucess " ) <nl> + else <nl> + print ( " ERROR " ) <nl> end <nl> - pCache : removeTexture ( pTexture ) <nl> - <nl> - print ( " RGBA 4444 " ) <nl> - cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE2_D_PIXEL_FORMAT_RGB_A4444 ) <nl> - - - gettimeofday ( & now , NULL ) <nl> - pTexture = pCache : addImage ( strFileName ) <nl> - if nil ~ = pTexture then <nl> + pCache : removeTexture ( pTexture ) <nl> + <nl> + print ( " RGBA 4444 " ) <nl> + cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE2_D_PIXEL_FORMAT_RGB_A4444 ) <nl> + - - gettimeofday ( & now , NULL ) <nl> + pTexture = pCache : addImage ( strFileName ) <nl> + if nil ~ = pTexture then <nl> print ( " add sucess " ) <nl> - else <nl> - print ( " ERROR " ) <nl> + else <nl> + print ( " ERROR " ) <nl> end <nl> - pCache : removeTexture ( pTexture ) <nl> - <nl> - print ( " RGBA 5551 " ) <nl> - cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE2_D_PIXEL_FORMAT_RGB5_A1 ) <nl> - - - gettimeofday ( & now , NULL ) <nl> - pTexture = pCache : addImage ( strFileName ) <nl> - if nil ~ = pTexture then <nl> - print ( " add sucess " ) <nl> - else <nl> - print ( " ERROR " ) <nl> + pCache : removeTexture ( pTexture ) <nl> + <nl> + print ( " RGBA 5551 " ) <nl> + cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE2_D_PIXEL_FORMAT_RGB5_A1 ) <nl> + - - gettimeofday ( & now , NULL ) <nl> + pTexture = pCache : addImage ( strFileName ) <nl> + if nil ~ = pTexture then <nl> + print ( " add sucess " ) <nl> + else <nl> + print ( " ERROR " ) <nl> end <nl> - pCache : removeTexture ( pTexture ) <nl> - <nl> - print ( " RGB 565 " ) <nl> - cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE2_D_PIXEL_FORMAT_RG_B565 ) <nl> - - - gettimeofday ( & now , NULL ) <nl> - pTexture = pCache : addImage ( strFileName ) <nl> - if nil ~ = pTexture then <nl> - - - log ( " ms : % f " , calculateDeltaTime ( & now ) ) <nl> - print ( " add sucess " ) <nl> - else <nl> - print ( " ERROR " ) <nl> - end <nl> - pCache : removeTexture ( pTexture ) <nl> + pCache : removeTexture ( pTexture ) <nl> + <nl> + print ( " RGB 565 " ) <nl> + cc . Texture2D : setDefaultAlphaPixelFormat ( cc . TEXTURE2_D_PIXEL_FORMAT_RG_B565 ) <nl> + - - gettimeofday ( & now , NULL ) <nl> + pTexture = pCache : addImage ( strFileName ) <nl> + if nil ~ = pTexture then <nl> + - - log ( " ms : % f " , calculateDeltaTime ( & now ) ) <nl> + print ( " add sucess " ) <nl> + else <nl> + print ( " ERROR " ) <nl> + end <nl> + pCache : removeTexture ( pTexture ) <nl> <nl> cc . Texture2D : setDefaultAlphaPixelFormat ( pDefaultFormat ) <nl> - end <nl> - local function PerformTests ( ) <nl> - print ( " mmmmmm - - " ) <nl> - print ( " mmm PNG 128x128 mmm " ) <nl> - PerformTestsPNG ( " Images / test_image . png " ) <nl> - <nl> - print ( " mmm PNG 512x512 mmm " ) <nl> - PerformTestsPNG ( " Images / texture512x512 . png " ) <nl> - <nl> - print ( " EMPTY IMAGE " ) <nl> - print ( " mmm PNG 1024x1024 mmm " ) <nl> - PerformTestsPNG ( " Images / texture1024x1024 . png " ) <nl> - <nl> - print ( " SPRITESHEET IMAGE " ) <nl> - print ( " mmm PNG 1024x1024 mmm " ) <nl> - PerformTestsPNG ( " Images / PlanetCute - 1024x1024 . png " ) <nl> - <nl> - print ( " LANDSCAPE IMAGE " ) <nl> - print ( " mmm PNG 1024x1024 mmm " ) <nl> - PerformTestsPNG ( " Images / landscape - 1024x1024 . png " ) <nl> - end <nl> - <nl> - local function InitTextureMenuLayer ( ) <nl> - if nil = = pLayer then <nl> - return <nl> - end <nl> - <nl> - - - Title <nl> - local pLabel = cc . LabelTTF : create ( GetTitle ( ) , " Arial " , 40 ) <nl> - pLayer : addChild ( pLabel , 1 ) <nl> - pLabel : setPosition ( cc . p ( s . width / 2 , s . height - 32 ) ) <nl> - pLabel : setColor ( cc . c3b ( 255 , 255 , 40 ) ) <nl> - <nl> - - - Subtitle <nl> + end <nl> + local function PerformTests ( ) <nl> + print ( " mmmmmm - - " ) <nl> + print ( " mmm PNG 128x128 mmm " ) <nl> + PerformTestsPNG ( " Images / test_image . png " ) <nl> + <nl> + print ( " mmm PNG 512x512 mmm " ) <nl> + PerformTestsPNG ( " Images / texture512x512 . png " ) <nl> + <nl> + print ( " EMPTY IMAGE " ) <nl> + print ( " mmm PNG 1024x1024 mmm " ) <nl> + PerformTestsPNG ( " Images / texture1024x1024 . png " ) <nl> + <nl> + print ( " SPRITESHEET IMAGE " ) <nl> + print ( " mmm PNG 1024x1024 mmm " ) <nl> + PerformTestsPNG ( " Images / PlanetCute - 1024x1024 . png " ) <nl> + <nl> + print ( " LANDSCAPE IMAGE " ) <nl> + print ( " mmm PNG 1024x1024 mmm " ) <nl> + PerformTestsPNG ( " Images / landscape - 1024x1024 . png " ) <nl> + end <nl> + <nl> + local function InitTextureMenuLayer ( ) <nl> + if nil = = pLayer then <nl> + return <nl> + end <nl> + <nl> + - - Title <nl> + local pLabel = cc . LabelTTF : create ( GetTitle ( ) , " Arial " , 40 ) <nl> + pLayer : addChild ( pLabel , 1 ) <nl> + pLabel : setPosition ( cc . p ( s . width / 2 , s . height - 32 ) ) <nl> + pLabel : setColor ( cc . c3b ( 255 , 255 , 40 ) ) <nl> + <nl> + - - Subtitle <nl> local pSubLabel = cc . LabelTTF : create ( GetSubtitle ( ) , " Thonburi " , 16 ) <nl> pLayer : addChild ( pSubLabel , 1 ) <nl> pSubLabel : setPosition ( cc . p ( s . width / 2 , s . height - 80 ) ) <nl> local function runTextureTest ( ) <nl> pLayer : addChild ( pMenu ) <nl> <nl> PerformTests ( ) <nl> - end <nl> - <nl> - InitTextureMenuLayer ( ) <nl> - pNewscene : addChild ( pLayer ) <nl> - return pNewscene <nl> + end <nl> + <nl> + InitTextureMenuLayer ( ) <nl> + pNewscene : addChild ( pLayer ) <nl> + return pNewscene <nl> end <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> - - PerformanceTouchesTest <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> local TouchesTestParam = <nl> { <nl> - TEST_COUNT = 2 , <nl> + TEST_COUNT = 2 , <nl> } <nl> local function runTouchesTest ( ) <nl> - local nTouchCurCase = 0 <nl> - - - PerformBasicLayer param <nl> - local bControlMenuVisible = false <nl> + local nTouchCurCase = 0 <nl> + - - PerformBasicLayer param <nl> + local bControlMenuVisible = false <nl> local nMaxCases = 0 <nl> local nCurCase = 0 <nl> - - TouchesMainScene param <nl> local function runTouchesTest ( ) <nl> local fElapsedTime = 0 . 0 <nl> <nl> local s = cc . Director : getInstance ( ) : getWinSize ( ) <nl> - local pNewscene = cc . Scene : create ( ) <nl> - local pLayer = cc . Layer : create ( ) <nl> - <nl> + local pNewscene = cc . Scene : create ( ) <nl> + local pLayer = cc . Layer : create ( ) <nl> + <nl> local function GetTitle ( ) <nl> - if 0 = = nCurCase then <nl> - return " Targeted touches " <nl> - elseif 1 = = nCurCase then <nl> - return " Standard touches " <nl> - end <nl> + if 0 = = nCurCase then <nl> + return " Targeted touches " <nl> + elseif 1 = = nCurCase then <nl> + return " Standard touches " <nl> + end <nl> end <nl> - <nl> + <nl> local function CreateBasicLayerMenuItem ( pMenu , bMenuVisible , nMaxCasesNum , nCurCaseIndex ) <nl> - if nil ~ = pMenu then <nl> - bControlMenuVisible = bMenuVisible <nl> - nMaxCases = nMaxCasesNum <nl> - nCurCase = nCurCaseIndex <nl> - if true = = bControlMenuVisible then <nl> - local function backCallback ( ) <nl> - nCurCase = nCurCase - 1 <nl> - if nCurCase < 0 then <nl> - nCurCase = nCurCase + nMaxCases <nl> - end <nl> - ShowCurrentTest ( ) <nl> - end <nl> - <nl> - local function restartCallback ( ) <nl> - ShowCurrentTest ( ) <nl> - end <nl> - <nl> - local function nextCallback ( ) <nl> - nCurCase = nCurCase + 1 <nl> - - - No check nMaxCases <nl> - nCurCase = nCurCase % nMaxCases <nl> - ShowCurrentTest ( ) <nl> - end <nl> - <nl> - local size = cc . Director : getInstance ( ) : getWinSize ( ) <nl> - local item1 = cc . MenuItemImage : create ( s_pPathB1 , s_pPathB2 ) <nl> - item1 : registerScriptTapHandler ( backCallback ) <nl> - pMenu : addChild ( item1 , kItemTagBasic ) <nl> - local item2 = cc . MenuItemImage : create ( s_pPathR1 , s_pPathR2 ) <nl> - item2 : registerScriptTapHandler ( restartCallback ) <nl> - pMenu : addChild ( item2 , kItemTagBasic ) <nl> - local item3 = cc . MenuItemImage : create ( s_pPathF1 , s_pPathF2 ) <nl> - pMenu : addChild ( item3 , kItemTagBasic ) <nl> - item3 : registerScriptTapHandler ( nextCallback ) <nl> - <nl> - local size = cc . Director : getInstance ( ) : getWinSize ( ) <nl> - item1 : setPosition ( cc . p ( size . width / 2 - item2 : getContentSize ( ) . width * 2 , item2 : getContentSize ( ) . height / 2 ) ) <nl> - item2 : setPosition ( cc . p ( size . width / 2 , item2 : getContentSize ( ) . height / 2 ) ) <nl> - item3 : setPosition ( cc . p ( size . width / 2 + item2 : getContentSize ( ) . width * 2 , item2 : getContentSize ( ) . height / 2 ) ) <nl> - end <nl> - end <nl> + if nil ~ = pMenu then <nl> + bControlMenuVisible = bMenuVisible <nl> + nMaxCases = nMaxCasesNum <nl> + nCurCase = nCurCaseIndex <nl> + if true = = bControlMenuVisible then <nl> + local function backCallback ( ) <nl> + nCurCase = nCurCase - 1 <nl> + if nCurCase < 0 then <nl> + nCurCase = nCurCase + nMaxCases <nl> + end <nl> + ShowCurrentTest ( ) <nl> + end <nl> + <nl> + local function restartCallback ( ) <nl> + ShowCurrentTest ( ) <nl> + end <nl> + <nl> + local function nextCallback ( ) <nl> + nCurCase = nCurCase + 1 <nl> + - - No check nMaxCases <nl> + nCurCase = nCurCase % nMaxCases <nl> + ShowCurrentTest ( ) <nl> + end <nl> + <nl> + local size = cc . Director : getInstance ( ) : getWinSize ( ) <nl> + local item1 = cc . MenuItemImage : create ( s_pPathB1 , s_pPathB2 ) <nl> + item1 : registerScriptTapHandler ( backCallback ) <nl> + pMenu : addChild ( item1 , kItemTagBasic ) <nl> + local item2 = cc . MenuItemImage : create ( s_pPathR1 , s_pPathR2 ) <nl> + item2 : registerScriptTapHandler ( restartCallback ) <nl> + pMenu : addChild ( item2 , kItemTagBasic ) <nl> + local item3 = cc . MenuItemImage : create ( s_pPathF1 , s_pPathF2 ) <nl> + pMenu : addChild ( item3 , kItemTagBasic ) <nl> + item3 : registerScriptTapHandler ( nextCallback ) <nl> + <nl> + local size = cc . Director : getInstance ( ) : getWinSize ( ) <nl> + item1 : setPosition ( cc . p ( size . width / 2 - item2 : getContentSize ( ) . width * 2 , item2 : getContentSize ( ) . height / 2 ) ) <nl> + item2 : setPosition ( cc . p ( size . width / 2 , item2 : getContentSize ( ) . height / 2 ) ) <nl> + item3 : setPosition ( cc . p ( size . width / 2 + item2 : getContentSize ( ) . width * 2 , item2 : getContentSize ( ) . height / 2 ) ) <nl> + end <nl> + end <nl> end <nl> <nl> local function update ( fTime ) <nl> - fElapsedTime = fElapsedTime + fTime <nl> - <nl> - if fElapsedTime > 1 . 0 then <nl> - local fFrameRateB = nNumberOfTouchesB / fElapsedTime <nl> - local fFrameRateM = nNumberOfTouchesM / fElapsedTime <nl> - local fFrameRateE = nNumberOfTouchesE / fElapsedTime <nl> - local fFrameRateC = nNumberOfTouchesC / fElapsedTime <nl> - fElapsedTime = 0 <nl> - nNumberOfTouchesB = 0 <nl> - nNumberOfTouchesM = 0 <nl> - nNumberOfTouchesE = 0 <nl> - nNumberOfTouchesC = 0 <nl> - <nl> - local strInfo = string . format ( " % . 1f % . 1f % . 1f % . 1f " , fFrameRateB , fFrameRateM , fFrameRateE , fFrameRateC ) <nl> - if nil ~ = pClassLabel then <nl> - pClassLabel : setString ( strInfo ) <nl> - end <nl> - end <nl> + fElapsedTime = fElapsedTime + fTime <nl> + <nl> + if fElapsedTime > 1 . 0 then <nl> + local fFrameRateB = nNumberOfTouchesB / fElapsedTime <nl> + local fFrameRateM = nNumberOfTouchesM / fElapsedTime <nl> + local fFrameRateE = nNumberOfTouchesE / fElapsedTime <nl> + local fFrameRateC = nNumberOfTouchesC / fElapsedTime <nl> + fElapsedTime = 0 <nl> + nNumberOfTouchesB = 0 <nl> + nNumberOfTouchesM = 0 <nl> + nNumberOfTouchesE = 0 <nl> + nNumberOfTouchesC = 0 <nl> + <nl> + local strInfo = string . format ( " % . 1f % . 1f % . 1f % . 1f " , fFrameRateB , fFrameRateM , fFrameRateE , fFrameRateC ) <nl> + if nil ~ = pClassLabel then <nl> + pClassLabel : setString ( strInfo ) <nl> + end <nl> + end <nl> <nl> end <nl> <nl> local function runTouchesTest ( ) <nl> end <nl> <nl> local function InitLayer ( ) <nl> - - - menu <nl> - local pTouchesTestMenu = cc . Menu : create ( ) <nl> - CreatePerfomBasicLayerMenu ( pTouchesTestMenu ) <nl> - CreateBasicLayerMenuItem ( pTouchesTestMenu , true , TouchesTestParam . TEST_COUNT , nCurCase ) <nl> - pTouchesTestMenu : setPosition ( cc . p ( 0 , 0 ) ) <nl> - pLayer : addChild ( pTouchesTestMenu ) <nl> - <nl> - - - Title <nl> - local pLabel = cc . LabelTTF : create ( GetTitle ( ) , " Arial " , 40 ) <nl> - pLayer : addChild ( pLabel , 1 ) <nl> - pLabel : setPosition ( cc . p ( s . width / 2 , s . height - 32 ) ) <nl> - pLabel : setColor ( cc . c3b ( 255 , 255 , 40 ) ) <nl> - <nl> - pLayer : scheduleUpdateWithPriorityLua ( update , 0 ) <nl> - <nl> - pClassLabel = cc . LabelBMFont : create ( " 00 . 0 " , " fonts / arial16 . fnt " ) <nl> - pClassLabel : setPosition ( cc . p ( s . width / 2 , s . height / 2 ) ) <nl> - pLayer : addChild ( pClassLabel ) <nl> - <nl> - fElapsedTime = 0 . 0 <nl> - nNumberOfTouchesB = 0 <nl> - nNumberOfTouchesM = 0 <nl> - nNumberOfTouchesE = 0 <nl> - nNumberOfTouchesC = 0 <nl> + - - menu <nl> + local pTouchesTestMenu = cc . Menu : create ( ) <nl> + CreatePerfomBasicLayerMenu ( pTouchesTestMenu ) <nl> + CreateBasicLayerMenuItem ( pTouchesTestMenu , true , TouchesTestParam . TEST_COUNT , nCurCase ) <nl> + pTouchesTestMenu : setPosition ( cc . p ( 0 , 0 ) ) <nl> + pLayer : addChild ( pTouchesTestMenu ) <nl> + <nl> + - - Title <nl> + local pLabel = cc . LabelTTF : create ( GetTitle ( ) , " Arial " , 40 ) <nl> + pLayer : addChild ( pLabel , 1 ) <nl> + pLabel : setPosition ( cc . p ( s . width / 2 , s . height - 32 ) ) <nl> + pLabel : setColor ( cc . c3b ( 255 , 255 , 40 ) ) <nl> + <nl> + pLayer : scheduleUpdateWithPriorityLua ( update , 0 ) <nl> + <nl> + pClassLabel = cc . LabelBMFont : create ( " 00 . 0 " , " fonts / arial16 . fnt " ) <nl> + pClassLabel : setPosition ( cc . p ( s . width / 2 , s . height / 2 ) ) <nl> + pLayer : addChild ( pClassLabel ) <nl> + <nl> + fElapsedTime = 0 . 0 <nl> + nNumberOfTouchesB = 0 <nl> + nNumberOfTouchesM = 0 <nl> + nNumberOfTouchesE = 0 <nl> + nNumberOfTouchesC = 0 <nl> <nl> if 0 = = nCurCase then <nl> local listener = cc . EventListenerTouchOneByOne : create ( ) <nl> local function runTouchesTest ( ) <nl> end <nl> <nl> function ShowCurrentTest ( ) <nl> - if nil ~ = pLayer then <nl> - pLayer : unscheduleUpdate ( ) <nl> - end <nl> - <nl> - pNewscene = cc . Scene : create ( ) <nl> - <nl> - if nil ~ = pNewscene then <nl> - pLayer = cc . Layer : create ( ) <nl> - InitLayer ( ) <nl> - pNewscene : addChild ( pLayer ) <nl> - cc . Director : getInstance ( ) : replaceScene ( pNewscene ) <nl> - end <nl> - end <nl> - <nl> - InitLayer ( ) <nl> - pNewscene : addChild ( pLayer ) <nl> - return pNewscene <nl> + if nil ~ = pLayer then <nl> + pLayer : unscheduleUpdate ( ) <nl> + end <nl> + <nl> + pNewscene = cc . Scene : create ( ) <nl> + <nl> + if nil ~ = pNewscene then <nl> + pLayer = cc . Layer : create ( ) <nl> + InitLayer ( ) <nl> + pNewscene : addChild ( pLayer ) <nl> + cc . Director : getInstance ( ) : replaceScene ( pNewscene ) <nl> + end <nl> + end <nl> + <nl> + InitLayer ( ) <nl> + pNewscene : addChild ( pLayer ) <nl> + return pNewscene <nl> + end <nl> + <nl> + local function runFuncRelateWithTable ( ) <nl> + - - body <nl> + local newscene = cc . Scene : create ( ) <nl> + local layer = cc . Layer : create ( ) <nl> + local s = cc . Director : getInstance ( ) : getWinSize ( ) <nl> + local scheduler = cc . Director : getInstance ( ) : getScheduler ( ) <nl> + local scheduleEntryID = 0 <nl> + local quantityOfNodes = 10000 <nl> + local socket = require ( " socket " ) <nl> + local maxTime = 0 . 0 <nl> + local minTime = 99999 <nl> + local averageTime1 = 0 . 0 <nl> + local averageTime2 = 0 . 0 <nl> + local totalTime = 0 . 0 <nl> + local numberOfCalls = 0 <nl> + <nl> + local function GetTitle ( ) <nl> + return " Func Releated Table Performance Test " <nl> + end <nl> + <nl> + local function GetSubtitle ( ) <nl> + return " See console for results " <nl> + end <nl> + <nl> + local function initVar ( ) <nl> + maxTime = 0 . 0 <nl> + minTime = 99999 <nl> + averageTime1 = 0 . 0 <nl> + averageTime2 = 0 . 0 <nl> + totalTime = 0 . 0 <nl> + numberOfCalls = 0 <nl> + end <nl> + <nl> + - - Title <nl> + local title = cc . LabelTTF : create ( GetTitle ( ) , " Arial " , 28 ) <nl> + layer : addChild ( title , 1 ) <nl> + title : setPosition ( cc . p ( s . width / 2 , s . height - 32 ) ) <nl> + title : setColor ( cc . c3b ( 255 , 255 , 40 ) ) <nl> + - - Subtitle <nl> + local subTitle = cc . LabelTTF : create ( GetSubtitle ( ) , " Thonburi " , 16 ) <nl> + layer : addChild ( subTitle , 1 ) <nl> + subTitle : setPosition ( cc . p ( s . width / 2 , s . height - 80 ) ) <nl> + <nl> + - - " + " , " - " Menu <nl> + local function onDecrease ( ) <nl> + quantityOfNodes = quantityOfNodes - 100 <nl> + if quantityOfNodes = = 0 then <nl> + quantityOfNodes = 100 <nl> + end <nl> + local numLabel = tolua . cast ( layer : getChildByTag ( NodeChildrenTestParam . kTagInfoLayer ) , " cc . LabelTTF " ) <nl> + local strNum = string . format ( " % d " , quantityOfNodes ) <nl> + numLabel : setString ( strNum ) <nl> + end <nl> + <nl> + local function onIncrease ( ) <nl> + quantityOfNodes = quantityOfNodes + 100 <nl> + local numLabel = tolua . cast ( layer : getChildByTag ( NodeChildrenTestParam . kTagInfoLayer ) , " cc . LabelTTF " ) <nl> + local strNum = string . format ( " % d " , quantityOfNodes ) <nl> + numLabel : setString ( strNum ) <nl> + end <nl> + <nl> + cc . MenuItemFont : setFontSize ( 65 ) <nl> + local decrease = cc . MenuItemFont : create ( " - " ) <nl> + decrease : registerScriptTapHandler ( onDecrease ) <nl> + decrease : setColor ( cc . c3b ( 0 , 200 , 20 ) ) <nl> + local increase = cc . MenuItemFont : create ( " + " ) <nl> + increase : registerScriptTapHandler ( onIncrease ) <nl> + increase : setColor ( cc . c3b ( 0 , 200 , 20 ) ) <nl> + <nl> + local menuAddOrSub = cc . Menu : create ( ) <nl> + menuAddOrSub : addChild ( decrease ) <nl> + menuAddOrSub : addChild ( increase ) <nl> + menuAddOrSub : alignItemsHorizontally ( ) <nl> + menuAddOrSub : setPosition ( cc . p ( s . width / 2 , s . height / 2 + 15 ) ) <nl> + layer : addChild ( menuAddOrSub , 1 ) <nl> + <nl> + - - num <nl> + local numLabel = cc . LabelTTF : create ( " 10000 " , " Marker Felt " , 30 ) <nl> + numLabel : setColor ( cc . c3b ( 0 , 200 , 20 ) ) <nl> + numLabel : setPosition ( cc . p ( s . width / 2 , s . height / 2 - 15 ) ) <nl> + layer : addChild ( numLabel , 1 , NodeChildrenTestParam . kTagInfoLayer ) <nl> + <nl> + - - setPosition , getPosition , Point <nl> + cc . MenuItemFont : setFontSize ( 18 ) <nl> + local setPositionItem = cc . MenuItemFont : create ( " setPosition " ) <nl> + local getPositionItem = cc . MenuItemFont : create ( " getPosition " ) <nl> + local getAnchorPointItem = cc . MenuItemFont : create ( " getAnchorPoint " ) <nl> + local pointItem = cc . MenuItemFont : create ( " object " ) <nl> + local funcToggleItem = cc . MenuItemToggle : create ( setPositionItem ) <nl> + funcToggleItem : addSubItem ( getPositionItem ) <nl> + funcToggleItem : addSubItem ( getAnchorPointItem ) <nl> + funcToggleItem : addSubItem ( pointItem ) <nl> + funcToggleItem : setAnchorPoint ( cc . p ( 0 . 0 , 0 . 5 ) ) <nl> + funcToggleItem : setPosition ( cc . p ( VisibleRect : left ( ) ) ) <nl> + local funcMenu = cc . Menu : create ( funcToggleItem ) <nl> + funcMenu : setPosition ( cc . p ( 0 , 0 ) ) <nl> + layer : addChild ( funcMenu ) <nl> + <nl> + local testNode = cc . Node : create ( ) <nl> + layer : addChild ( testNode ) <nl> + <nl> + local function step ( dt ) <nl> + print ( string . format ( " push num : % d , avg1 : % f , avg2 : % f , min : % f , max : % f , total : % f , calls : % d " , quantityOfNodes , averageTime1 , averageTime2 , minTime , maxTime , totalTime , numberOfCalls ) ) <nl> + end <nl> + <nl> + local function profileEnd ( startTime ) <nl> + local duration = socket . gettime ( ) - startTime <nl> + totalTime = totalTime + duration <nl> + averageTime1 = ( averageTime1 + duration ) / 2 <nl> + averageTime2 = totalTime / numberOfCalls <nl> + <nl> + if maxTime < duration then <nl> + maxTime = duration <nl> + end <nl> + <nl> + if minTime > duration then <nl> + minTime = duration <nl> + end <nl> + end <nl> + <nl> + local function callSetPosition ( ) <nl> + numberOfCalls = numberOfCalls + 1 <nl> + local startTime = socket . gettime ( ) <nl> + for i = 1 , quantityOfNodes do <nl> + testNode : setPosition ( cc . p ( 1 , 2 ) ) <nl> + end <nl> + profileEnd ( startTime ) <nl> + end <nl> + <nl> + local function callGetPosition ( ) <nl> + numberOfCalls = numberOfCalls + 1 <nl> + local startTime = socket . gettime ( ) <nl> + for i = 1 , quantityOfNodes do <nl> + local x , y = testNode : getPosition ( ) <nl> + end <nl> + profileEnd ( startTime ) <nl> + end <nl> + <nl> + local function callGetAnchorPoint ( ) <nl> + numberOfCalls = numberOfCalls + 1 <nl> + local startTime = socket . gettime ( ) <nl> + for i = 1 , quantityOfNodes do <nl> + local anchorPoint = testNode : getAnchorPoint ( ) <nl> + end <nl> + profileEnd ( startTime ) <nl> + end <nl> + <nl> + local function callTableObject ( ) <nl> + numberOfCalls = numberOfCalls + 1 <nl> + local startTime = socket . gettime ( ) <nl> + for i = 1 , quantityOfNodes do <nl> + local pt = cc . p ( 1 , 2 ) <nl> + end <nl> + profileEnd ( startTime ) <nl> + end <nl> + <nl> + local function update ( dt ) <nl> + <nl> + local funcSelected = funcToggleItem : getSelectedIndex ( ) <nl> + if 0 = = funcSelected then <nl> + callSetPosition ( ) <nl> + elseif 1 = = funcSelected then <nl> + callGetPosition ( ) <nl> + elseif 2 = = funcSelected then <nl> + callGetAnchorPoint ( ) <nl> + elseif 3 = = funcSelected then <nl> + callTableObject ( ) <nl> + end <nl> + end <nl> + <nl> + local function onNodeEvent ( tag ) <nl> + if tag = = " exit " then <nl> + layer : unscheduleUpdate ( ) <nl> + scheduler : unscheduleScriptEntry ( scheduleEntryID ) <nl> + end <nl> + end <nl> + <nl> + layer : registerScriptHandler ( onNodeEvent ) <nl> + <nl> + <nl> + local function startCallback ( ) <nl> + initVar ( ) <nl> + decrease : setEnabled ( false ) <nl> + increase : setEnabled ( false ) <nl> + funcToggleItem : setEnabled ( false ) <nl> + layer : unscheduleUpdate ( ) <nl> + layer : scheduleUpdateWithPriorityLua ( update , 0 ) <nl> + scheduler : unscheduleScriptEntry ( scheduleEntryID ) <nl> + scheduleEntryID = scheduler : scheduleScriptFunc ( step , 2 , false ) <nl> + end <nl> + <nl> + local function stopCallback ( ) <nl> + decrease : setEnabled ( true ) <nl> + increase : setEnabled ( true ) <nl> + funcToggleItem : setEnabled ( true ) <nl> + layer : unscheduleUpdate ( ) <nl> + scheduler : unscheduleScriptEntry ( scheduleEntryID ) <nl> + end <nl> + local startItem = cc . MenuItemFont : create ( " start " ) <nl> + startItem : registerScriptTapHandler ( startCallback ) <nl> + local stopItem = cc . MenuItemFont : create ( " stop " ) <nl> + stopItem : registerScriptTapHandler ( stopCallback ) <nl> + local startAndStop = cc . Menu : create ( startItem , stopItem ) <nl> + startAndStop : alignItemsVertically ( ) <nl> + startAndStop : setPosition ( VisibleRect : right ( ) . x - 50 , VisibleRect : right ( ) . y ) <nl> + layer : addChild ( startAndStop ) <nl> + <nl> + - - back menu <nl> + local menu = cc . Menu : create ( ) <nl> + CreatePerfomBasicLayerMenu ( menu ) <nl> + menu : setPosition ( cc . p ( 0 , 0 ) ) <nl> + layer : addChild ( menu ) <nl> + <nl> + newscene : addChild ( layer ) <nl> + return newscene <nl> end <nl> <nl> <nl> end <nl> mmmmmmmmmmmmmmmmmmmmmmmm <nl> local CreatePerformancesTestTable = <nl> { <nl> - runNodeChildrenTest , <nl> - runParticleTest , <nl> - runSpriteTest , <nl> - runTextureTest , <nl> - runTouchesTest <nl> + runNodeChildrenTest , <nl> + runParticleTest , <nl> + runSpriteTest , <nl> + runTextureTest , <nl> + runTouchesTest , <nl> + runFuncRelateWithTable , <nl> } <nl> <nl> local function CreatePerformancesTestScene ( nPerformanceNo ) <nl> local function CreatePerformancesTestScene ( nPerformanceNo ) <nl> return pNewscene <nl> end <nl> local function menuCallback ( tag , pMenuItem ) <nl> - local scene = nil <nl> + local scene = nil <nl> local nIdx = pMenuItem : getLocalZOrder ( ) - kItemTagBasic <nl> - local PerformanceTestScene = CreatePerformancesTestScene ( nIdx ) <nl> + local PerformanceTestScene = CreatePerformancesTestScene ( nIdx ) <nl> if nil ~ = PerformanceTestScene then <nl> cc . Director : getInstance ( ) : replaceScene ( PerformanceTestScene ) <nl> end <nl> end <nl> <nl> local function PerformanceMainLayer ( ) <nl> - local layer = cc . Layer : create ( ) <nl> + local layer = cc . Layer : create ( ) <nl> <nl> - local menu = cc . Menu : create ( ) <nl> + local menu = cc . Menu : create ( ) <nl> menu : setPosition ( cc . p ( 0 , 0 ) ) <nl> cc . MenuItemFont : setFontName ( " Arial " ) <nl> cc . MenuItemFont : setFontSize ( 24 ) <nl> for i = 1 , MAX_COUNT do <nl> - local item = cc . MenuItemFont : create ( testsName [ i ] ) <nl> + local item = cc . MenuItemFont : create ( testsName [ i ] ) <nl> item : registerScriptTapHandler ( menuCallback ) <nl> - item : setPosition ( s . width / 2 , s . height - ( i + 1 ) * LINE_SPACE ) <nl> + item : setPosition ( s . width / 2 , s . height - i * LINE_SPACE ) <nl> menu : addChild ( item , kItemTagBasic + i ) <nl> - end <nl> + end <nl> <nl> layer : addChild ( menu ) <nl> <nl> - return layer <nl> + return layer <nl> end <nl> <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> - - Performance Test <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> function PerformanceTestMain ( ) <nl> - local scene = cc . Scene : create ( ) <nl> + local scene = cc . Scene : create ( ) <nl> <nl> - scene : addChild ( PerformanceMainLayer ( ) ) <nl> - scene : addChild ( CreateBackMenuItem ( ) ) <nl> + scene : addChild ( PerformanceMainLayer ( ) ) <nl> + scene : addChild ( CreateBackMenuItem ( ) ) <nl> <nl> - return scene <nl> + return scene <nl> end <nl>
Merge pull request from samuele3hu / developPerformance
cocos2d/cocos2d-x
e550ff7741baaf0f89794f14850d0e1346b4d3ad
2014-02-17T07:16:31Z
mmm a / CMakeLists . txt <nl> ppp b / CMakeLists . txt <nl> endif ( ) <nl> OCV_OPTION ( WITH_1394 " Include IEEE1394 support " ON IF ( NOT ANDROID AND NOT IOS ) ) <nl> OCV_OPTION ( WITH_AVFOUNDATION " Use AVFoundation for Video I / O " ON IF IOS ) <nl> OCV_OPTION ( WITH_CARBON " Use Carbon for UI instead of Cocoa " OFF IF APPLE ) <nl> + OCV_OPTION ( WITH_VTK " Include VTK library support ( and build opencv_viz module eiher ) " OFF IF ( NOT ANDROID AND NOT IOS ) ) <nl> OCV_OPTION ( WITH_CUDA " Include NVidia Cuda Runtime support " ON IF ( NOT IOS ) ) <nl> OCV_OPTION ( WITH_CUFFT " Include NVidia Cuda Fast Fourier Transform ( FFT ) library support " ON IF ( NOT IOS ) ) <nl> OCV_OPTION ( WITH_CUBLAS " Include NVidia Cuda Basic Linear Algebra Subprograms ( BLAS ) library support " OFF IF ( NOT IOS ) ) <nl> endif ( ) <nl> # mmm Matlab / Octave mmm <nl> include ( cmake / OpenCVFindMatlab . cmake ) <nl> <nl> + include ( cmake / OpenCVDetectVTK . cmake ) <nl> + <nl> # mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> # Add CUDA libraries ( needed for apps / tools , samples ) <nl> # mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> else ( ) <nl> endif ( ) <nl> <nl> status ( " OpenGL support : " HAVE_OPENGL THEN " YES ( $ { OPENGL_LIBRARIES } ) " ELSE NO ) <nl> + status ( " VTK support : " HAVE_VTK THEN " YES ( ver $ { VTK_VERSION } ) " ELSE NO ) <nl> <nl> # = = = = = = = = = = = = = = = = = = = = = = = = = = MEDIA IO = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> status ( " " ) <nl> new file mode 100644 <nl> index 00000000000 . . f0d28d552af <nl> mmm / dev / null <nl> ppp b / cmake / OpenCVDetectVTK . cmake <nl> <nl> + if ( NOT WITH_VTK OR ANDROID OR IOS ) <nl> + return ( ) <nl> + endif ( ) <nl> + <nl> + find_package ( VTK 6 . 0 QUIET COMPONENTS vtkRenderingCore vtkInteractionWidgets vtkInteractionStyle vtkIOLegacy vtkIOPLY vtkRenderingFreeType vtkRenderingLOD vtkFiltersTexture NO_MODULE ) <nl> + <nl> + if ( NOT DEFINED VTK_FOUND OR NOT VTK_FOUND ) <nl> + find_package ( VTK 5 . 10 QUIET COMPONENTS vtkCommon vtkFiltering vtkRendering vtkWidgets vtkImaging NO_MODULE ) <nl> + endif ( ) <nl> + <nl> + if ( NOT DEFINED VTK_FOUND OR NOT VTK_FOUND ) <nl> + find_package ( VTK 5 . 8 QUIET COMPONENTS vtkCommon vtkFiltering vtkRendering vtkWidgets vtkImaging NO_MODULE ) <nl> + endif ( ) <nl> + <nl> + if ( VTK_FOUND ) <nl> + set ( HAVE_VTK ON ) <nl> + message ( STATUS " Found VTK ver . $ { VTK_VERSION } ( usefile : $ { VTK_USE_FILE } ) " ) <nl> + else ( ) <nl> + set ( HAVE_VTK OFF ) <nl> + message ( STATUS " VTK is not found . Please set - DVTK_DIR in CMake to VTK build directory , or set $ VTK_DIR enviroment variable to VTK install subdirectory with VTKConfig . cmake file ( for windows ) " ) <nl> + endif ( ) <nl> \ No newline at end of file <nl> mmm a / modules / calib3d / test / test_affine3 . cpp <nl> ppp b / modules / calib3d / test / test_affine3 . cpp <nl> TEST ( Calib3d_Affine3f , accuracy ) <nl> <nl> ASSERT_LT ( cv : : norm ( diff , cv : : NORM_INF ) , 1e - 15 ) ; <nl> } <nl> + <nl> + TEST ( Calib3d_Affine3f , accuracy_rvec ) <nl> + { <nl> + cv : : RNG rng ; <nl> + typedef float T ; <nl> + <nl> + cv : : Affine3 < T > : : Vec3 w ; <nl> + cv : : Affine3 < T > : : Mat3 u , vt , R ; <nl> + <nl> + for ( int i = 0 ; i < 100 ; + + i ) <nl> + { <nl> + rng . fill ( R , cv : : RNG : : UNIFORM , - 10 , 10 , true ) ; <nl> + cv : : SVD : : compute ( R , w , u , vt , cv : : SVD : : FULL_UV + cv : : SVD : : MODIFY_A ) ; <nl> + R = u * vt ; <nl> + <nl> + / / double s = ( double ) cv : : getTickCount ( ) ; <nl> + cv : : Affine3 < T > : : Vec3 va = cv : : Affine3 < T > ( R ) . rvec ( ) ; <nl> + / / std : : cout < < " M : " < < ( cv : : getTickCount ( ) - s ) * 1000 / cv : : getTickFrequency ( ) < < std : : endl ; <nl> + <nl> + cv : : Affine3 < T > : : Vec3 vo ; <nl> + / / s = ( double ) cv : : getTickCount ( ) ; <nl> + cv : : Rodrigues ( R , vo ) ; <nl> + / / std : : cout < < " O : " < < ( cv : : getTickCount ( ) - s ) * 1000 / cv : : getTickFrequency ( ) < < std : : endl ; <nl> + <nl> + ASSERT_LT ( cv : : norm ( va - vo ) , 1e - 9 ) ; <nl> + } <nl> + } <nl> mmm a / modules / core / include / opencv2 / core / affine . hpp <nl> ppp b / modules / core / include / opencv2 / core / affine . hpp <nl> <nl> namespace cv <nl> { <nl> template < typename T > <nl> - class CV_EXPORTS Affine3 <nl> + class Affine3 <nl> { <nl> public : <nl> typedef T float_type ; <nl> namespace cv <nl> Mat3 linear ( ) const ; <nl> Vec3 translation ( ) const ; <nl> <nl> + / / Rodrigues vector <nl> + Vec3 rvec ( ) const ; <nl> + <nl> Affine3 inv ( int method = cv : : DECOMP_SVD ) const ; <nl> <nl> / / a . rotate ( R ) is equivalent to Affine ( R , 0 ) * a ; <nl> cv : : Affine3 < T > : : Affine3 ( const Mat3 & R , const Vec3 & t ) <nl> } <nl> <nl> template < typename T > inline <nl> - cv : : Affine3 < T > : : Affine3 ( const Vec3 & rvec , const Vec3 & t ) <nl> + cv : : Affine3 < T > : : Affine3 ( const Vec3 & _rvec , const Vec3 & t ) <nl> { <nl> - rotation ( rvec ) ; <nl> + rotation ( _rvec ) ; <nl> translation ( t ) ; <nl> matrix . val [ 12 ] = matrix . val [ 13 ] = matrix . val [ 14 ] = 0 ; <nl> matrix . val [ 15 ] = 1 ; <nl> void cv : : Affine3 < T > : : rotation ( const Mat3 & R ) <nl> } <nl> <nl> template < typename T > inline <nl> - void cv : : Affine3 < T > : : rotation ( const Vec3 & rvec ) <nl> + void cv : : Affine3 < T > : : rotation ( const Vec3 & _rvec ) <nl> { <nl> - double rx = rvec [ 0 ] , ry = rvec [ 1 ] , rz = rvec [ 2 ] ; <nl> + double rx = _rvec [ 0 ] , ry = _rvec [ 1 ] , rz = _rvec [ 2 ] ; <nl> double theta = std : : sqrt ( rx * rx + ry * ry + rz * rz ) ; <nl> <nl> if ( theta < DBL_EPSILON ) <nl> void cv : : Affine3 < T > : : rotation ( const cv : : Mat & data ) <nl> } <nl> else if ( ( data . cols = = 3 & & data . rows = = 1 ) | | ( data . cols = = 1 & & data . rows = = 3 ) ) <nl> { <nl> - Vec3 rvec ; <nl> - data . reshape ( 1 , 3 ) . copyTo ( rvec ) ; <nl> - rotation ( rvec ) ; <nl> + Vec3 _rvec ; <nl> + data . reshape ( 1 , 3 ) . copyTo ( _rvec ) ; <nl> + rotation ( _rvec ) ; <nl> } <nl> else <nl> CV_Assert ( ! " Input marix can be 3x3 , 1x3 or 3x1 " ) ; <nl> typename cv : : Affine3 < T > : : Vec3 cv : : Affine3 < T > : : translation ( ) const <nl> return Vec3 ( matrix . val [ 3 ] , matrix . val [ 7 ] , matrix . val [ 11 ] ) ; <nl> } <nl> <nl> + template < typename T > inline <nl> + typename cv : : Affine3 < T > : : Vec3 cv : : Affine3 < T > : : rvec ( ) const <nl> + { <nl> + cv : : Vec3d w ; <nl> + cv : : Matx33d u , vt , R = rotation ( ) ; <nl> + cv : : SVD : : compute ( R , w , u , vt , cv : : SVD : : FULL_UV + cv : : SVD : : MODIFY_A ) ; <nl> + R = u * vt ; <nl> + <nl> + double rx = R . val [ 7 ] - R . val [ 5 ] ; <nl> + double ry = R . val [ 2 ] - R . val [ 6 ] ; <nl> + double rz = R . val [ 3 ] - R . val [ 1 ] ; <nl> + <nl> + double s = std : : sqrt ( ( rx * rx + ry * ry + rz * rz ) * 0 . 25 ) ; <nl> + double c = ( R . val [ 0 ] + R . val [ 4 ] + R . val [ 8 ] - 1 ) * 0 . 5 ; <nl> + c = c > 1 . 0 ? 1 . 0 : c < - 1 . 0 ? - 1 . 0 : c ; <nl> + double theta = acos ( c ) ; <nl> + <nl> + if ( s < 1e - 5 ) <nl> + { <nl> + if ( c > 0 ) <nl> + rx = ry = rz = 0 ; <nl> + else <nl> + { <nl> + double t ; <nl> + t = ( R . val [ 0 ] + 1 ) * 0 . 5 ; <nl> + rx = std : : sqrt ( std : : max ( t , 0 . 0 ) ) ; <nl> + t = ( R . val [ 4 ] + 1 ) * 0 . 5 ; <nl> + ry = std : : sqrt ( std : : max ( t , 0 . 0 ) ) * ( R . val [ 1 ] < 0 ? - 1 . 0 : 1 . 0 ) ; <nl> + t = ( R . val [ 8 ] + 1 ) * 0 . 5 ; <nl> + rz = std : : sqrt ( std : : max ( t , 0 . 0 ) ) * ( R . val [ 2 ] < 0 ? - 1 . 0 : 1 . 0 ) ; <nl> + <nl> + if ( fabs ( rx ) < fabs ( ry ) & & fabs ( rx ) < fabs ( rz ) & & ( R . val [ 5 ] > 0 ) ! = ( ry * rz > 0 ) ) <nl> + rz = - rz ; <nl> + theta / = std : : sqrt ( rx * rx + ry * ry + rz * rz ) ; <nl> + rx * = theta ; <nl> + ry * = theta ; <nl> + rz * = theta ; <nl> + } <nl> + } <nl> + else <nl> + { <nl> + double vth = 1 / ( 2 * s ) ; <nl> + vth * = theta ; <nl> + rx * = vth ; ry * = vth ; rz * = vth ; <nl> + } <nl> + <nl> + return cv : : Vec3d ( rx , ry , rz ) ; <nl> + } <nl> + <nl> template < typename T > inline <nl> cv : : Affine3 < T > cv : : Affine3 < T > : : inv ( int method ) const <nl> { <nl> mmm a / modules / core / include / opencv2 / core / operations . hpp <nl> ppp b / modules / core / include / opencv2 / core / operations . hpp <nl> int print ( const std : : vector < Point3_ < _Tp > > & vec , FILE * stream = stdout ) <nl> template < typename _Tp , int m , int n > static inline <nl> int print ( const Matx < _Tp , m , n > & matx , FILE * stream = stdout ) <nl> { <nl> - return print ( Formatter : : get ( ) - > format ( matx ) , stream ) ; <nl> + return print ( Formatter : : get ( ) - > format ( cv : : Mat ( matx ) ) , stream ) ; <nl> } <nl> <nl> <nl> mmm a / modules / highgui / src / cap_openni . cpp <nl> ppp b / modules / highgui / src / cap_openni . cpp <nl> class ApproximateSyncGrabber <nl> task = new ( tbb : : task : : allocate_root ( ) ) TBBApproximateSynchronizerTask ( * this ) ; <nl> tbb : : task : : enqueue ( * task ) ; <nl> # else <nl> - task - > reset ( new ApproximateSynchronizer ( * this ) ) ; <nl> + task . reset ( new ApproximateSynchronizer ( * this ) ) ; <nl> # endif <nl> } <nl> <nl> mmm a / modules / viz / CMakeLists . txt <nl> ppp b / modules / viz / CMakeLists . txt <nl> <nl> - macro ( find_qvtk ) <nl> - find_library ( QVTK_LIBRARY QVTK HINTS $ { VTK_DIR } $ { VTK_DIR } / bin ) <nl> - find_path ( QVTK_INCLUDE_DIR QVTKWidget . h HINT $ { VTK_INCLUDE_DIRS } ) <nl> - find_package_handle_standard_args ( QVTK DEFAULT_MSG QVTK_LIBRARY QVTK_INCLUDE_DIR ) <nl> - <nl> - if ( QVTK_FOUND ) <nl> - get_filename_component ( QVTK_LIBRARY_DIR $ { QVTK_LIBRARY } PATH ) <nl> - list ( APPEND VTK_LIBRARY_DIRS $ { QVTK_LIBRARY_DIR } ) <nl> - list ( APPEND VTK_INCLUDE_DIRS $ { QVTK_INCLUDE_DIR } ) <nl> - set ( VTK_USE_QVTK ON ) <nl> - endif ( ) <nl> - endmacro ( ) <nl> - <nl> - macro ( find_vtk ) <nl> - find_package ( VTK ) <nl> - if ( $ { VTK_MAJOR_VERSION } LESS 5 ) <nl> - MESSAGE ( FATAL_ERROR " VTK 5 or more required ! " ) <nl> - endif ( ) <nl> - if ( VTK_FOUND ) <nl> - if ( BUILD_SHARED_LIBS OR ( NOT BUILD_SHARED_LIBS AND NOT VTK_BUILD_SHARED_LIBS ) ) <nl> - find_qvtk ( ) <nl> - message ( STATUS " VTK found ( include : $ { VTK_INCLUDE_DIRS } , lib : $ { VTK_LIBRARY_DIRS } ) " ) <nl> - link_directories ( $ { VTK_LIBRARY_DIRS } ) <nl> - include_directories ( SYSTEM $ { VTK_INCLUDE_DIRS } ) <nl> - set ( HAVE_VTK ON ) <nl> - else ( ) <nl> - set ( HAVE_VTK OFF ) <nl> - message ( FATAL_ERROR " VTK disabled . You are to build OpenCV in STATIC but VTK is SHARED ! " ) <nl> - endif ( ) <nl> - endif ( ) <nl> - endmacro ( ) <nl> - <nl> - if ( NOT OPENCV_INITIAL_PASS AND DEFINED BUILD_opencv_viz AND BUILD_opencv_viz ) <nl> - find_vtk ( ) <nl> - endif ( ) <nl> - <nl> - if ( DEFINED HAVE_VTK AND HAVE_VTK ) <nl> - set ( VTK_USE_FILE $ { VTK_USE_FILE } CACHE INTERNAL " VTK_USE_FILE " ) <nl> - include ( $ { VTK_USE_FILE } ) <nl> - add_definitions ( - DHAVE_VTK ) <nl> + if ( NOT WITH_VTK OR NOT DEFINED HAVE_VTK OR NOT HAVE_VTK ) <nl> + ocv_module_disable ( viz ) <nl> endif ( ) <nl> <nl> + include ( $ { VTK_USE_FILE } ) <nl> set ( the_description " Viz " ) <nl> - set ( BUILD_opencv_viz_INIT OFF ) <nl> - include_directories ( src ) <nl> - ocv_define_module ( viz opencv_core ) <nl> + ocv_define_module ( viz opencv_core $ { VTK_LIBRARIES } ) <nl> <nl> - if ( DEFINED BUILD_opencv_viz AND BUILD_opencv_viz AND DEFINED HAVE_VTK AND HAVE_VTK ) <nl> - if ( $ { VTK_VERSION_MAJOR } EQUAL 5 ) <nl> - target_link_libraries ( opencv_viz vtkCommon vtkWidgets vtkFiltering vtkRendering ) <nl> - else ( ) <nl> - target_link_libraries ( opencv_viz vtkViewsCore vtkRenderingLOD vtkIOPLY vtkRenderingFreeTypeOpenGL vtkRenderingVolumeOpenGL vtkFiltersTexture ) <nl> - endif ( ) <nl> - if ( APPLE ) <nl> - target_link_libraries ( opencv_viz " - framework Cocoa " ) <nl> - endif ( ) <nl> + if ( APPLE AND BUILD_opencv_viz ) <nl> + target_link_libraries ( opencv_viz " - framework Cocoa " ) <nl> endif ( ) <nl> mmm a / modules / viz / doc / viz3d . rst <nl> ppp b / modules / viz / doc / viz3d . rst <nl> Checks * * point * * for nan <nl> <nl> : param p : return true if * * any * * of the elements of the point is * nan * . <nl> <nl> - viz : : VizAccessor <nl> mmmmmmmmmmmmmmm - - <nl> - . . ocv : class : : VizAccessor <nl> - <nl> - A singleton class that provides access by name infrastructure for 3D visualization windows . : : <nl> - <nl> - class CV_EXPORTS VizAccessor <nl> - { <nl> - public : <nl> - static VizAccessor & getInstance ( ) ; <nl> - static void release ( ) ; <nl> - <nl> - Viz3d get ( const String & window_name ) ; <nl> - <nl> - / / ! window names automatically have Viz - prefix even though not provided by the users <nl> - static void generateWindowName ( const String & window_name , String & output ) ; <nl> - <nl> - private : <nl> - / * hidden * / <nl> - } ; <nl> - <nl> - viz : : VizAccessor : : getInstance <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> - Returns the single instance of VizAccessor . <nl> - <nl> - . . ocv : function : : static VizAccessor & getInstance ( ) <nl> - <nl> - viz : : VizAccessor : : release <nl> mmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - Deletes the single instance of VizAccessor . <nl> - <nl> - . . ocv : function : : static void release ( ) <nl> - <nl> - viz : : VizAccessor : : get <nl> mmmmmmmmmmmmmmmmmmmmm - <nl> - Retrieves a window by its name . <nl> - <nl> - . . ocv : function : : Viz3d get ( const String & window_name ) <nl> - <nl> - : param window_name : Name of the window that is to be retrieved . <nl> - <nl> - This function returns a : ocv : class : ` Viz3d ` object with the given name . <nl> - <nl> - . . note : : If the window with that name already exists , that window is returned . Otherwise , new window is created with the given name , and it is returned . <nl> - <nl> - . . note : : Window names are automatically prefixed by " Viz - " if it is not done by the user . <nl> - <nl> - . . code - block : : cpp <nl> - <nl> - / / / window and window_2 are the same windows . <nl> - viz : : Viz3d window = viz : : get ( " myWindow " ) ; <nl> - viz : : Viz3d window_2 = viz : : get ( " Viz - myWindow " ) ; <nl> - <nl> - viz : : VizAccessor : : generateWindowName <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> - Generates a window name by prefixing " Viz - " if it has not already been prefixed . <nl> - <nl> - . . ocv : function : : static void generateWindowName ( const String & window_name , String & output ) <nl> - <nl> - : param window_name : Window name <nl> - : param output : Prefixed window name <nl> - <nl> viz : : Viz3d <nl> mmmmmmmmm - <nl> . . ocv : class : : Viz3d <nl> mmm a / modules / viz / doc / widget . rst <nl> ppp b / modules / viz / doc / widget . rst <nl> This 3D Widget defines a finite plane . : : <nl> class CV_EXPORTS WPlane : public Widget3D <nl> { <nl> public : <nl> - WPlane ( const Vec4f & coefs , double size = 1 . 0 , const Color & color = Color : : white ( ) ) ; <nl> - WPlane ( const Vec4f & coefs , const Point3f & pt , double size = 1 . 0 , const Color & color = Color : : white ( ) ) ; <nl> + WPlane ( const Vec4f & coefs , float size = 1 . 0 , const Color & color = Color : : white ( ) ) ; <nl> + WPlane ( const Vec4f & coefs , const Point3f & pt , float size = 1 . 0 , const Color & color = Color : : white ( ) ) ; <nl> private : <nl> / * hidden * / <nl> } ; <nl> viz : : WPlane : : WPlane <nl> mmmmmmmmmmmmmmmmmm - <nl> Constructs a WPlane . <nl> <nl> - . . ocv : function : : WPlane ( const Vec4f & coefs , double size = 1 . 0 , const Color & color = Color : : white ( ) ) <nl> + . . ocv : function : : WPlane ( const Vec4f & coefs , float size = 1 . 0 , const Color & color = Color : : white ( ) ) <nl> <nl> : param coefs : Plane coefficients as in ( A , B , C , D ) where Ax + By + Cz + D = 0 . <nl> : param size : Size of the plane . <nl> : param color : : ocv : class : ` Color ` of the plane . <nl> <nl> - . . ocv : function : : WPlane ( const Vec4f & coefs , const Point3f & pt , double size = 1 . 0 , const Color & color = Color : : white ( ) ) <nl> + . . ocv : function : : WPlane ( const Vec4f & coefs , const Point3f & pt , float size = 1 . 0 , const Color & color = Color : : white ( ) ) <nl> <nl> : param coefs : Plane coefficients as in ( A , B , C , D ) where Ax + By + Cz + D = 0 . <nl> : param pt : Position of the plane . <nl> This 3D Widget defines an arrow . : : <nl> class CV_EXPORTS WArrow : public Widget3D <nl> { <nl> public : <nl> - WArrow ( const Point3f & pt1 , const Point3f & pt2 , double thickness = 0 . 03 , const Color & color = Color : : white ( ) ) ; <nl> + WArrow ( const Point3f & pt1 , const Point3f & pt2 , float thickness = 0 . 03 , const Color & color = Color : : white ( ) ) ; <nl> } ; <nl> <nl> viz : : WArrow : : WArrow <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> Constructs an WArrow . <nl> <nl> - . . ocv : function : : WArrow ( const Point3f & pt1 , const Point3f & pt2 , double thickness = 0 . 03 , const Color & color = Color : : white ( ) ) <nl> + . . ocv : function : : WArrow ( const Point3f & pt1 , const Point3f & pt2 , float thickness = 0 . 03 , const Color & color = Color : : white ( ) ) <nl> <nl> : param pt1 : Start point of the arrow . <nl> : param pt2 : End point of the arrow . <nl> This 3D Widget defines a circle . : : <nl> class CV_EXPORTS WCircle : public Widget3D <nl> { <nl> public : <nl> - WCircle ( const Point3f & pt , double radius , double thickness = 0 . 01 , const Color & color = Color : : white ( ) ) ; <nl> + WCircle ( const Point3f & pt , float radius , float thickness = 0 . 01 , const Color & color = Color : : white ( ) ) ; <nl> } ; <nl> <nl> viz : : WCircle : : WCircle <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> Constructs a WCircle . <nl> <nl> - . . ocv : function : : WCircle ( const Point3f & pt , double radius , double thickness = 0 . 01 , const Color & color = Color : : white ( ) ) <nl> + . . ocv : function : : WCircle ( const Point3f & pt , float radius , float thickness = 0 . 01 , const Color & color = Color : : white ( ) ) <nl> <nl> : param pt : Center of the circle . <nl> : param radius : Radius of the circle . <nl> This 3D Widget defines a cylinder . : : <nl> class CV_EXPORTS WCylinder : public Widget3D <nl> { <nl> public : <nl> - WCylinder ( const Point3f & pt_on_axis , const Point3f & axis_direction , double radius , int numsides = 30 , const Color & color = Color : : white ( ) ) ; <nl> + WCylinder ( const Point3f & pt_on_axis , const Point3f & axis_direction , float radius , int numsides = 30 , const Color & color = Color : : white ( ) ) ; <nl> } ; <nl> <nl> viz : : WCylinder : : WCylinder <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> Constructs a WCylinder . <nl> <nl> - . . ocv : function : : WCylinder ( const Point3f & pt_on_axis , const Point3f & axis_direction , double radius , int numsides = 30 , const Color & color = Color : : white ( ) ) <nl> + . . ocv : function : : WCylinder ( const Point3f & pt_on_axis , const Point3f & axis_direction , float radius , int numsides = 30 , const Color & color = Color : : white ( ) ) <nl> <nl> : param pt_on_axis : A point on the axis of the cylinder . <nl> : param axis_direction : Direction of the axis of the cylinder . <nl> This 3D Widget represents a coordinate system . : : <nl> class CV_EXPORTS WCoordinateSystem : public Widget3D <nl> { <nl> public : <nl> - WCoordinateSystem ( double scale = 1 . 0 ) ; <nl> + WCoordinateSystem ( float scale = 1 . 0 ) ; <nl> } ; <nl> <nl> viz : : WCoordinateSystem : : WCoordinateSystem <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> Constructs a WCoordinateSystem . <nl> <nl> - . . ocv : function : : WCoordinateSystem ( double scale = 1 . 0 ) <nl> + . . ocv : function : : WCoordinateSystem ( float scale = 1 . 0 ) <nl> <nl> : param scale : Determines the size of the axes . <nl> <nl> This 3D Widget represents 3D text . The text always faces the camera . : : <nl> class CV_EXPORTS WText3D : public Widget3D <nl> { <nl> public : <nl> - WText3D ( const String & text , const Point3f & position , double text_scale = 1 . 0 , double face_camera = true , const Color & color = Color : : white ( ) ) ; <nl> + WText3D ( const String & text , const Point3f & position , float text_scale = 1 . 0 , bool face_camera = true , const Color & color = Color : : white ( ) ) ; <nl> <nl> void setText ( const String & text ) ; <nl> String getText ( ) const ; <nl> viz : : WText3D : : WText3D <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> Constructs a WText3D . <nl> <nl> - . . ocv : function : : WText3D ( const String & text , const Point3f & position , double text_scale = 1 . 0 , double face_camera = true , const Color & color = Color : : white ( ) ) <nl> + . . ocv : function : : WText3D ( const String & text , const Point3f & position , float text_scale = 1 . 0 , bool face_camera = true , const Color & color = Color : : white ( ) ) <nl> <nl> : param text : Text content of the widget . <nl> : param position : Position of the text . <nl> This 3D Widget represents camera position in a scene by its axes or viewing frus <nl> { <nl> public : <nl> / / ! Creates camera coordinate frame ( axes ) at the origin <nl> - WCameraPosition ( double scale = 1 . 0 ) ; <nl> + WCameraPosition ( float scale = 1 . 0 ) ; <nl> / / ! Creates frustum based on the intrinsic marix K at the origin <nl> - WCameraPosition ( const Matx33f & K , double scale = 1 . 0 , const Color & color = Color : : white ( ) ) ; <nl> + WCameraPosition ( const Matx33f & K , float scale = 1 . 0 , const Color & color = Color : : white ( ) ) ; <nl> / / ! Creates frustum based on the field of view at the origin <nl> - WCameraPosition ( const Vec2f & fov , double scale = 1 . 0 , const Color & color = Color : : white ( ) ) ; <nl> + WCameraPosition ( const Vec2f & fov , float scale = 1 . 0 , const Color & color = Color : : white ( ) ) ; <nl> / / ! Creates frustum and display given image at the far plane <nl> - WCameraPosition ( const Matx33f & K , const Mat & img , double scale = 1 . 0 , const Color & color = Color : : white ( ) ) ; <nl> + WCameraPosition ( const Matx33f & K , const Mat & img , float scale = 1 . 0 , const Color & color = Color : : white ( ) ) ; <nl> / / ! Creates frustum and display given image at the far plane <nl> - WCameraPosition ( const Vec2f & fov , const Mat & img , double scale = 1 . 0 , const Color & color = Color : : white ( ) ) ; <nl> + WCameraPosition ( const Vec2f & fov , const Mat & img , float scale = 1 . 0 , const Color & color = Color : : white ( ) ) ; <nl> } ; <nl> <nl> viz : : WCameraPosition : : WCameraPosition <nl> Constructs a WCameraPosition . <nl> <nl> - * * Display camera coordinate frame . * * <nl> <nl> - . . ocv : function : : WCameraPosition ( double scale = 1 . 0 ) <nl> + . . ocv : function : : WCameraPosition ( float scale = 1 . 0 ) <nl> <nl> Creates camera coordinate frame at the origin . <nl> <nl> Constructs a WCameraPosition . <nl> <nl> - * * Display the viewing frustum . * * <nl> <nl> - . . ocv : function : : WCameraPosition ( const Matx33f & K , double scale = 1 . 0 , const Color & color = Color : : white ( ) ) <nl> + . . ocv : function : : WCameraPosition ( const Matx33f & K , float scale = 1 . 0 , const Color & color = Color : : white ( ) ) <nl> <nl> : param K : Intrinsic matrix of the camera . <nl> : param scale : Scale of the frustum . <nl> Constructs a WCameraPosition . <nl> <nl> Creates viewing frustum of the camera based on its intrinsic matrix K . <nl> <nl> - . . ocv : function : : WCameraPosition ( const Vec2f & fov , double scale = 1 . 0 , const Color & color = Color : : white ( ) ) <nl> + . . ocv : function : : WCameraPosition ( const Vec2f & fov , float scale = 1 . 0 , const Color & color = Color : : white ( ) ) <nl> <nl> : param fov : Field of view of the camera ( horizontal , vertical ) . <nl> : param scale : Scale of the frustum . <nl> Constructs a WCameraPosition . <nl> <nl> - * * Display image on the far plane of the viewing frustum . * * <nl> <nl> - . . ocv : function : : WCameraPosition ( const Matx33f & K , const Mat & img , double scale = 1 . 0 , const Color & color = Color : : white ( ) ) <nl> + . . ocv : function : : WCameraPosition ( const Matx33f & K , const Mat & img , float scale = 1 . 0 , const Color & color = Color : : white ( ) ) <nl> <nl> : param K : Intrinsic matrix of the camera . <nl> : param img : BGR or Gray - Scale image that is going to be displayed on the far plane of the frustum . <nl> Constructs a WCameraPosition . <nl> <nl> Creates viewing frustum of the camera based on its intrinsic matrix K , and displays image on the far end plane . <nl> <nl> - . . ocv : function : : WCameraPosition ( const Vec2f & fov , const Mat & img , double scale = 1 . 0 , const Color & color = Color : : white ( ) ) <nl> + . . ocv : function : : WCameraPosition ( const Vec2f & fov , const Mat & img , float scale = 1 . 0 , const Color & color = Color : : white ( ) ) <nl> <nl> : param fov : Field of view of the camera ( horizontal , vertical ) . <nl> : param img : BGR or Gray - Scale image that is going to be displayed on the far plane of the frustum . <nl> This 3D Widget represents a trajectory . : : <nl> enum { DISPLAY_FRAMES = 1 , DISPLAY_PATH = 2 } ; <nl> <nl> / / ! Displays trajectory of the given path either by coordinate frames or polyline <nl> - WTrajectory ( const std : : vector < Affine3f > & path , int display_mode = WTrajectory : : DISPLAY_PATH , const Color & color = Color : : white ( ) , double scale = 1 . 0 ) ; <nl> + WTrajectory ( const std : : vector < Affine3f > & path , int display_mode = WTrajectory : : DISPLAY_PATH , const Color & color = Color : : white ( ) , float scale = 1 . 0 ) ; <nl> / / ! Displays trajectory of the given path by frustums <nl> - WTrajectory ( const std : : vector < Affine3f > & path , const Matx33f & K , double scale = 1 . 0 , const Color & color = Color : : white ( ) ) ; <nl> + WTrajectory ( const std : : vector < Affine3f > & path , const Matx33f & K , float scale = 1 . 0 , const Color & color = Color : : white ( ) ) ; <nl> / / ! Displays trajectory of the given path by frustums <nl> - WTrajectory ( const std : : vector < Affine3f > & path , const Vec2f & fov , double scale = 1 . 0 , const Color & color = Color : : white ( ) ) ; <nl> + WTrajectory ( const std : : vector < Affine3f > & path , const Vec2f & fov , float scale = 1 . 0 , const Color & color = Color : : white ( ) ) ; <nl> <nl> private : <nl> / * hidden * / <nl> viz : : WTrajectory : : WTrajectory <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> Constructs a WTrajectory . <nl> <nl> - . . ocv : function : : WTrajectory ( const std : : vector < Affine3f > & path , int display_mode = WTrajectory : : DISPLAY_PATH , const Color & color = Color : : white ( ) , double scale = 1 . 0 ) <nl> + . . ocv : function : : WTrajectory ( const std : : vector < Affine3f > & path , int display_mode = WTrajectory : : DISPLAY_PATH , const Color & color = Color : : white ( ) , float scale = 1 . 0 ) <nl> <nl> : param path : List of poses on a trajectory . <nl> : param display_mode : Display mode . This can be DISPLAY_PATH , DISPLAY_FRAMES , DISPLAY_PATH & DISPLAY_FRAMES . <nl> Constructs a WTrajectory . <nl> * DISPLAY_FRAMES : Displays coordinate frames at each pose . <nl> * DISPLAY_PATH & DISPLAY_FRAMES : Displays both poly line and coordinate frames . <nl> <nl> - . . ocv : function : : WTrajectory ( const std : : vector < Affine3f > & path , const Matx33f & K , double scale = 1 . 0 , const Color & color = Color : : white ( ) ) <nl> + . . ocv : function : : WTrajectory ( const std : : vector < Affine3f > & path , const Matx33f & K , float scale = 1 . 0 , const Color & color = Color : : white ( ) ) <nl> <nl> : param path : List of poses on a trajectory . <nl> : param K : Intrinsic matrix of the camera . <nl> Constructs a WTrajectory . <nl> <nl> Displays frustums at each pose of the trajectory . <nl> <nl> - . . ocv : function : : WTrajectory ( const std : : vector < Affine3f > & path , const Vec2f & fov , double scale = 1 . 0 , const Color & color = Color : : white ( ) ) <nl> + . . ocv : function : : WTrajectory ( const std : : vector < Affine3f > & path , const Vec2f & fov , float scale = 1 . 0 , const Color & color = Color : : white ( ) ) <nl> <nl> : param path : List of poses on a trajectory . <nl> : param fov : Field of view of the camera ( horizontal , vertical ) . <nl> represent the direction from previous position to the current . : : <nl> { <nl> public : <nl> WSpheresTrajectory ( const std : : vector < Affine3f > & path , float line_length = 0 . 05f , <nl> - double init_sphere_radius = 0 . 021 , sphere_radius = 0 . 007 , <nl> + float init_sphere_radius = 0 . 021 , sphere_radius = 0 . 007 , <nl> Color & line_color = Color : : white ( ) , const Color & sphere_color = Color : : white ( ) ) ; <nl> } ; <nl> <nl> viz : : WSpheresTrajectory : : WSpheresTrajectory <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> Constructs a WSpheresTrajectory . <nl> <nl> - . . ocv : function : : WSpheresTrajectory ( const std : : vector < Affine3f > & path , float line_length = 0 . 05f , double init_sphere_radius = 0 . 021 , double sphere_radius = 0 . 007 , const Color & line_color = Color : : white ( ) , const Color & sphere_color = Color : : white ( ) ) <nl> + . . ocv : function : : WSpheresTrajectory ( const std : : vector < Affine3f > & path , float line_length = 0 . 05f , float init_sphere_radius = 0 . 021 , float sphere_radius = 0 . 007 , const Color & line_color = Color : : white ( ) , const Color & sphere_color = Color : : white ( ) ) <nl> <nl> : param path : List of poses on a trajectory . <nl> : param line_length : Length of the lines . <nl> mmm a / modules / viz / include / opencv2 / viz . hpp <nl> ppp b / modules / viz / include / opencv2 / viz . hpp <nl> namespace cv <nl> / / ! constructs camera pose from position , focal_point and up_vector ( see gluLookAt ( ) for more infromation ) <nl> CV_EXPORTS Affine3f makeCameraPose ( const Vec3f & position , const Vec3f & focal_point , const Vec3f & y_dir ) ; <nl> <nl> - / / ! retrieves a window by its name <nl> + / / ! retrieves a window by its name . If no window with such name , then it creates new . <nl> CV_EXPORTS Viz3d get ( const String & window_name ) ; <nl> <nl> + / / ! Unregisters all Viz windows from internal database . After it ' get ( ) ' will create new windows instead getting existing from the database . <nl> + CV_EXPORTS void unregisterAllWindows ( ) ; <nl> + <nl> / / ! checks float value for Nan <nl> inline bool isNan ( float x ) <nl> { <nl> namespace cv <nl> template < typename _Tp > inline bool isNan ( const Point3_ < _Tp > & p ) <nl> { return isNan ( p . x ) | | isNan ( p . y ) | | isNan ( p . z ) ; } <nl> <nl> - / / ! helper class that provides access by name infrastructure <nl> - class CV_EXPORTS VizAccessor <nl> - { <nl> - public : <nl> - static VizAccessor & getInstance ( ) ; <nl> - static void release ( ) ; <nl> - <nl> - Viz3d get ( const String & window_name ) ; <nl> - <nl> - / / ! window names automatically have Viz - prefix even though not provided by the users <nl> - static void generateWindowName ( const String & window_name , String & output ) ; <nl> - <nl> - private : <nl> - VizAccessor ( ) ; / / Singleton <nl> - ~ VizAccessor ( ) ; <nl> - <nl> - void add ( Viz3d window ) ; <nl> - void remove ( const String & window_name ) ; <nl> - <nl> - static VizAccessor * instance_ ; <nl> - <nl> - struct VizAccessorImpl ; <nl> - VizAccessorImpl * impl_ ; <nl> - <nl> - friend class Viz3d ; <nl> - } ; <nl> } / * namespace viz * / <nl> } / * namespace cv * / <nl> <nl> mmm a / modules / viz / include / opencv2 / viz / types . hpp <nl> ppp b / modules / viz / include / opencv2 / viz / types . hpp <nl> namespace cv <nl> / / / cv : : viz : : Color <nl> <nl> inline cv : : viz : : Color : : Color ( ) : Scalar ( 0 , 0 , 0 ) { } <nl> - inline cv : : viz : : Color : : Color ( double gray ) : Scalar ( gray , gray , gray ) { } <nl> - inline cv : : viz : : Color : : Color ( double blue , double green , double red ) : Scalar ( blue , green , red ) { } <nl> + inline cv : : viz : : Color : : Color ( double _gray ) : Scalar ( _gray , _gray , _gray ) { } <nl> + inline cv : : viz : : Color : : Color ( double _blue , double _green , double _red ) : Scalar ( _blue , _green , _red ) { } <nl> inline cv : : viz : : Color : : Color ( const Scalar & color ) : Scalar ( color ) { } <nl> <nl> inline cv : : viz : : Color cv : : viz : : Color : : black ( ) { return Color ( 0 , 0 , 0 ) ; } <nl> mmm a / modules / viz / include / opencv2 / viz / viz3d . hpp <nl> ppp b / modules / viz / include / opencv2 / viz / viz3d . hpp <nl> <nl> # ifndef __OPENCV_VIZ_VIZ3D_HPP__ <nl> # define __OPENCV_VIZ_VIZ3D_HPP__ <nl> <nl> - # if ! defined YES_I_AGREE_THAT_VIZ_API_IS_NOT_STABLE_NOW_AND_BINARY_COMPARTIBILITY_WONT_BE_SUPPORTED <nl> + # if ! defined YES_I_AGREE_THAT_VIZ_API_IS_NOT_STABLE_NOW_AND_BINARY_COMPARTIBILITY_WONT_BE_SUPPORTED & & ! defined CVAPI_EXPORTS <nl> / / # error " Viz is in beta state now . Please define macro above to use it " <nl> # endif <nl> <nl> namespace cv <nl> class CV_EXPORTS Viz3d <nl> { <nl> public : <nl> - typedef cv : : Ptr < Viz3d > Ptr ; <nl> typedef void ( * KeyboardCallback ) ( const KeyboardEvent & , void * ) ; <nl> typedef void ( * MouseCallback ) ( const MouseEvent & , void * ) ; <nl> <nl> namespace cv <nl> <nl> void create ( const String & window_name ) ; <nl> void release ( ) ; <nl> + <nl> + friend class VizStorage ; <nl> } ; <nl> <nl> } / * namespace viz * / <nl> mmm a / modules / viz / include / opencv2 / viz / widgets . hpp <nl> ppp b / modules / viz / include / opencv2 / viz / widgets . hpp <nl> namespace cv <nl> class CV_EXPORTS WPlane : public Widget3D <nl> { <nl> public : <nl> - WPlane ( const Vec4f & coefs , double size = 1 . 0 , const Color & color = Color : : white ( ) ) ; <nl> - WPlane ( const Vec4f & coefs , const Point3f & pt , double size = 1 . 0 , const Color & color = Color : : white ( ) ) ; <nl> + WPlane ( const Vec4f & coefs , float size = 1 . f , const Color & color = Color : : white ( ) ) ; <nl> + WPlane ( const Vec4f & coefs , const Point3f & pt , float size = 1 . f , const Color & color = Color : : white ( ) ) ; <nl> private : <nl> struct SetSizeImpl ; <nl> } ; <nl> namespace cv <nl> class CV_EXPORTS WArrow : public Widget3D <nl> { <nl> public : <nl> - WArrow ( const Point3f & pt1 , const Point3f & pt2 , double thickness = 0 . 03 , const Color & color = Color : : white ( ) ) ; <nl> + WArrow ( const Point3f & pt1 , const Point3f & pt2 , float thickness = 0 . 03f , const Color & color = Color : : white ( ) ) ; <nl> } ; <nl> <nl> class CV_EXPORTS WCircle : public Widget3D <nl> { <nl> public : <nl> - WCircle ( const Point3f & pt , double radius , double thickness = 0 . 01 , const Color & color = Color : : white ( ) ) ; <nl> + WCircle ( const Point3f & pt , float radius , float thickness = 0 . 01f , const Color & color = Color : : white ( ) ) ; <nl> } ; <nl> <nl> class CV_EXPORTS WCylinder : public Widget3D <nl> { <nl> public : <nl> - WCylinder ( const Point3f & pt_on_axis , const Point3f & axis_direction , double radius , int numsides = 30 , const Color & color = Color : : white ( ) ) ; <nl> + WCylinder ( const Point3f & pt_on_axis , const Point3f & axis_direction , float radius , int numsides = 30 , const Color & color = Color : : white ( ) ) ; <nl> } ; <nl> <nl> class CV_EXPORTS WCube : public Widget3D <nl> namespace cv <nl> class CV_EXPORTS WCoordinateSystem : public Widget3D <nl> { <nl> public : <nl> - WCoordinateSystem ( double scale = 1 . 0 ) ; <nl> + WCoordinateSystem ( float scale = 1 . f ) ; <nl> } ; <nl> <nl> class CV_EXPORTS WPolyLine : public Widget3D <nl> namespace cv <nl> class CV_EXPORTS WText3D : public Widget3D <nl> { <nl> public : <nl> - WText3D ( const String & text , const Point3f & position , double text_scale = 1 . 0 , bool face_camera = true , const Color & color = Color : : white ( ) ) ; <nl> + WText3D ( const String & text , const Point3f & position , float text_scale = 1 . f , bool face_camera = true , const Color & color = Color : : white ( ) ) ; <nl> <nl> void setText ( const String & text ) ; <nl> String getText ( ) const ; <nl> namespace cv <nl> { <nl> public : <nl> / / ! Creates camera coordinate frame ( axes ) at the origin <nl> - WCameraPosition ( double scale = 1 . 0 ) ; <nl> + WCameraPosition ( float scale = 1 . f ) ; <nl> / / ! Creates frustum based on the intrinsic marix K at the origin <nl> - WCameraPosition ( const Matx33f & K , double scale = 1 . 0 , const Color & color = Color : : white ( ) ) ; <nl> + WCameraPosition ( const Matx33f & K , float scale = 1 . f , const Color & color = Color : : white ( ) ) ; <nl> / / ! Creates frustum based on the field of view at the origin <nl> - WCameraPosition ( const Vec2f & fov , double scale = 1 . 0 , const Color & color = Color : : white ( ) ) ; <nl> + WCameraPosition ( const Vec2f & fov , float scale = 1 . f , const Color & color = Color : : white ( ) ) ; <nl> / / ! Creates frustum and display given image at the far plane <nl> - WCameraPosition ( const Matx33f & K , const Mat & img , double scale = 1 . 0 , const Color & color = Color : : white ( ) ) ; <nl> + WCameraPosition ( const Matx33f & K , const Mat & img , float scale = 1 . f , const Color & color = Color : : white ( ) ) ; <nl> / / ! Creates frustum and display given image at the far plane <nl> - WCameraPosition ( const Vec2f & fov , const Mat & img , double scale = 1 . 0 , const Color & color = Color : : white ( ) ) ; <nl> + WCameraPosition ( const Vec2f & fov , const Mat & img , float scale = 1 . f , const Color & color = Color : : white ( ) ) ; <nl> <nl> private : <nl> struct ProjectImage ; <nl> namespace cv <nl> enum { DISPLAY_FRAMES = 1 , DISPLAY_PATH = 2 } ; <nl> <nl> / / ! Displays trajectory of the given path either by coordinate frames or polyline <nl> - WTrajectory ( const std : : vector < Affine3f > & path , int display_mode = WTrajectory : : DISPLAY_PATH , const Color & color = Color : : white ( ) , double scale = 1 . 0 ) ; <nl> + WTrajectory ( const std : : vector < Affine3f > & path , int display_mode = WTrajectory : : DISPLAY_PATH , const Color & color = Color : : white ( ) , float scale = 1 . f ) ; <nl> / / ! Displays trajectory of the given path by frustums <nl> - WTrajectory ( const std : : vector < Affine3f > & path , const Matx33f & K , double scale = 1 . 0 , const Color & color = Color : : white ( ) ) ; <nl> + WTrajectory ( const std : : vector < Affine3f > & path , const Matx33f & K , float scale = 1 . f , const Color & color = Color : : white ( ) ) ; <nl> / / ! Displays trajectory of the given path by frustums <nl> - WTrajectory ( const std : : vector < Affine3f > & path , const Vec2f & fov , double scale = 1 . 0 , const Color & color = Color : : white ( ) ) ; <nl> + WTrajectory ( const std : : vector < Affine3f > & path , const Vec2f & fov , float scale = 1 . f , const Color & color = Color : : white ( ) ) ; <nl> <nl> private : <nl> struct ApplyPath ; <nl> namespace cv <nl> class CV_EXPORTS WSpheresTrajectory : public Widget3D <nl> { <nl> public : <nl> - WSpheresTrajectory ( const std : : vector < Affine3f > & path , float line_length = 0 . 05f , double init_sphere_radius = 0 . 021 , <nl> - double sphere_radius = 0 . 007 , const Color & line_color = Color : : white ( ) , const Color & sphere_color = Color : : white ( ) ) ; <nl> + WSpheresTrajectory ( const std : : vector < Affine3f > & path , float line_length = 0 . 05f , float init_sphere_radius = 0 . 021f , <nl> + float sphere_radius = 0 . 007f , const Color & line_color = Color : : white ( ) , const Color & sphere_color = Color : : white ( ) ) ; <nl> } ; <nl> <nl> class CV_EXPORTS WCloud : public Widget3D <nl> similarity index 100 % <nl> rename from modules / viz / src / interactor_style . h <nl> rename to modules / viz / src / interactor_style . hpp <nl> mmm a / modules / viz / src / precomp . hpp <nl> ppp b / modules / viz / src / precomp . hpp <nl> <nl> # include < list > <nl> # include < vector > <nl> <nl> - # if defined __GNUC__ <nl> - # pragma GCC system_header <nl> - # ifdef __DEPRECATED <nl> - # undef __DEPRECATED <nl> - # define __DEPRECATED_DISABLED__ <nl> - # endif <nl> - # endif <nl> - <nl> # include < vtkAppendPolyData . h > <nl> # include < vtkAssemblyPath . h > <nl> # include < vtkCellData . h > <nl> <nl> # include < vtkSmartPointer . h > <nl> # include < vtkDataSet . h > <nl> # include < vtkPolygon . h > <nl> - # include < vtkPointPicker . h > <nl> # include < vtkUnstructuredGrid . h > <nl> # include < vtkDiskSource . h > <nl> # include < vtkPlaneSource . h > <nl> <nl> # include < vtkCamera . h > <nl> # include < vtkObjectFactory . h > <nl> # include < vtkPlanes . h > <nl> - # include < vtkImageViewer . h > <nl> # include < vtkImageFlip . h > <nl> # include < vtkRenderWindow . h > <nl> # include < vtkTextProperty . h > <nl> <nl> # include < vtkTextureMapToPlane . h > <nl> # include < vtkPolyDataNormals . h > <nl> # include < vtkAlgorithmOutput . h > <nl> - <nl> - # if defined __GNUC__ & & defined __DEPRECATED_DISABLED__ <nl> - # define __DEPRECATED <nl> - # undef __DEPRECATED_DISABLED__ <nl> - # endif <nl> + # include < vtkImageMapper . h > <nl> <nl> # include < opencv2 / core . hpp > <nl> # include < opencv2 / viz . hpp > <nl> namespace cv <nl> namespace viz <nl> { <nl> typedef std : : map < String , vtkSmartPointer < vtkProp > > WidgetActorMap ; <nl> - } <nl> - } <nl> + typedef std : : map < String , Viz3d > VizMap ; <nl> <nl> - # include " interactor_style . h " <nl> - # include " viz3d_impl . hpp " <nl> + class VizStorage <nl> + { <nl> + public : <nl> + static void unregisterAll ( ) ; <nl> <nl> - namespace cv <nl> - { <nl> - namespace viz <nl> - { <nl> - typedef std : : map < String , Viz3d > VizMap ; <nl> - typedef std : : pair < String , Viz3d > VizPair ; <nl> + / / ! window names automatically have Viz - prefix even though not provided by the users <nl> + static String generateWindowName ( const String & window_name ) ; <nl> + <nl> + private : <nl> + VizStorage ( ) ; / / Static <nl> + ~ VizStorage ( ) ; <nl> + <nl> + static void add ( const Viz3d & window ) ; <nl> + static Viz3d & get ( const String & window_name ) ; <nl> + static void remove ( const String & window_name ) ; <nl> + static bool windowExists ( const String & window_name ) ; <nl> + static void removeUnreferenced ( ) ; <nl> + <nl> + static VizMap storage ; <nl> + friend class Viz3d ; <nl> + } ; <nl> } <nl> } <nl> <nl> + # include " interactor_style . hpp " <nl> + # include " viz3d_impl . hpp " <nl> + <nl> <nl> # endif <nl> mmm a / modules / viz / src / shape_widgets . cpp <nl> ppp b / modules / viz / src / shape_widgets . cpp <nl> struct cv : : viz : : WPlane : : SetSizeImpl <nl> } <nl> } ; <nl> <nl> - cv : : viz : : WPlane : : WPlane ( const Vec4f & coefs , double size , const Color & color ) <nl> + cv : : viz : : WPlane : : WPlane ( const Vec4f & coefs , float size , const Color & color ) <nl> { <nl> vtkSmartPointer < vtkPlaneSource > plane = vtkSmartPointer < vtkPlaneSource > : : New ( ) ; <nl> plane - > SetNormal ( coefs [ 0 ] , coefs [ 1 ] , coefs [ 2 ] ) ; <nl> cv : : viz : : WPlane : : WPlane ( const Vec4f & coefs , double size , const Color & color ) <nl> setColor ( color ) ; <nl> } <nl> <nl> - cv : : viz : : WPlane : : WPlane ( const Vec4f & coefs , const Point3f & pt , double size , const Color & color ) <nl> + cv : : viz : : WPlane : : WPlane ( const Vec4f & coefs , const Point3f & pt , float size , const Color & color ) <nl> { <nl> vtkSmartPointer < vtkPlaneSource > plane = vtkSmartPointer < vtkPlaneSource > : : New ( ) ; <nl> Point3f coefs3 ( coefs [ 0 ] , coefs [ 1 ] , coefs [ 2 ] ) ; <nl> template < > cv : : viz : : WSphere cv : : viz : : Widget : : cast < cv : : viz : : WSphere > ( ) <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / arrow widget implementation <nl> <nl> - cv : : viz : : WArrow : : WArrow ( const Point3f & pt1 , const Point3f & pt2 , double thickness , const Color & color ) <nl> + cv : : viz : : WArrow : : WArrow ( const Point3f & pt1 , const Point3f & pt2 , float thickness , const Color & color ) <nl> { <nl> vtkSmartPointer < vtkArrowSource > arrowSource = vtkSmartPointer < vtkArrowSource > : : New ( ) ; <nl> arrowSource - > SetShaftRadius ( thickness ) ; <nl> template < > cv : : viz : : WArrow cv : : viz : : Widget : : cast < cv : : viz : : WArrow > ( ) <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / circle widget implementation <nl> <nl> - cv : : viz : : WCircle : : WCircle ( const Point3f & pt , double radius , double thickness , const Color & color ) <nl> + cv : : viz : : WCircle : : WCircle ( const Point3f & pt , float radius , float thickness , const Color & color ) <nl> { <nl> vtkSmartPointer < vtkDiskSource > disk = vtkSmartPointer < vtkDiskSource > : : New ( ) ; <nl> / / Maybe the resolution should be lower e . g . 50 or 25 <nl> template < > cv : : viz : : WCircle cv : : viz : : Widget : : cast < cv : : viz : : WCircle > ( ) <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / cylinder widget implementation <nl> <nl> - cv : : viz : : WCylinder : : WCylinder ( const Point3f & pt_on_axis , const Point3f & axis_direction , double radius , int numsides , const Color & color ) <nl> + cv : : viz : : WCylinder : : WCylinder ( const Point3f & pt_on_axis , const Point3f & axis_direction , float radius , int numsides , const Color & color ) <nl> { <nl> const Point3f pt2 = pt_on_axis + axis_direction ; <nl> vtkSmartPointer < vtkLineSource > line = vtkSmartPointer < vtkLineSource > : : New ( ) ; <nl> template < > cv : : viz : : WCube cv : : viz : : Widget : : cast < cv : : viz : : WCube > ( ) <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / coordinate system widget implementation <nl> <nl> - cv : : viz : : WCoordinateSystem : : WCoordinateSystem ( double scale ) <nl> + cv : : viz : : WCoordinateSystem : : WCoordinateSystem ( float scale ) <nl> { <nl> vtkSmartPointer < vtkAxes > axes = vtkSmartPointer < vtkAxes > : : New ( ) ; <nl> axes - > SetOrigin ( 0 , 0 , 0 ) ; <nl> template < > cv : : viz : : WGrid cv : : viz : : Widget : : cast < cv : : viz : : WGrid > ( ) <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / text3D widget implementation <nl> <nl> - cv : : viz : : WText3D : : WText3D ( const String & text , const Point3f & position , double text_scale , bool face_camera , const Color & color ) <nl> + cv : : viz : : WText3D : : WText3D ( const String & text , const Point3f & position , float text_scale , bool face_camera , const Color & color ) <nl> { <nl> vtkSmartPointer < vtkVectorText > textSource = vtkSmartPointer < vtkVectorText > : : New ( ) ; <nl> textSource - > SetText ( text . c_str ( ) ) ; <nl> struct cv : : viz : : WCameraPosition : : ProjectImage <nl> } <nl> } ; <nl> <nl> - cv : : viz : : WCameraPosition : : WCameraPosition ( double scale ) <nl> + cv : : viz : : WCameraPosition : : WCameraPosition ( float scale ) <nl> { <nl> vtkSmartPointer < vtkAxes > axes = vtkSmartPointer < vtkAxes > : : New ( ) ; <nl> axes - > SetOrigin ( 0 , 0 , 0 ) ; <nl> cv : : viz : : WCameraPosition : : WCameraPosition ( double scale ) <nl> WidgetAccessor : : setProp ( * this , actor ) ; <nl> } <nl> <nl> - cv : : viz : : WCameraPosition : : WCameraPosition ( const Matx33f & K , double scale , const Color & color ) <nl> + cv : : viz : : WCameraPosition : : WCameraPosition ( const Matx33f & K , float scale , const Color & color ) <nl> { <nl> vtkSmartPointer < vtkCamera > camera = vtkSmartPointer < vtkCamera > : : New ( ) ; <nl> float f_x = K ( 0 , 0 ) ; <nl> cv : : viz : : WCameraPosition : : WCameraPosition ( const Matx33f & K , double scale , const <nl> } <nl> <nl> <nl> - cv : : viz : : WCameraPosition : : WCameraPosition ( const Vec2f & fov , double scale , const Color & color ) <nl> + cv : : viz : : WCameraPosition : : WCameraPosition ( const Vec2f & fov , float scale , const Color & color ) <nl> { <nl> vtkSmartPointer < vtkCamera > camera = vtkSmartPointer < vtkCamera > : : New ( ) ; <nl> <nl> cv : : viz : : WCameraPosition : : WCameraPosition ( const Vec2f & fov , double scale , const <nl> setColor ( color ) ; <nl> } <nl> <nl> - cv : : viz : : WCameraPosition : : WCameraPosition ( const Matx33f & K , const Mat & image , double scale , const Color & color ) <nl> + cv : : viz : : WCameraPosition : : WCameraPosition ( const Matx33f & K , const Mat & image , float scale , const Color & color ) <nl> { <nl> CV_Assert ( ! image . empty ( ) & & image . depth ( ) = = CV_8U ) ; <nl> float f_y = K ( 1 , 1 ) ; <nl> cv : : viz : : WCameraPosition : : WCameraPosition ( const Matx33f & K , const Mat & image , do <nl> WidgetAccessor : : setProp ( * this , actor ) ; <nl> } <nl> <nl> - cv : : viz : : WCameraPosition : : WCameraPosition ( const Vec2f & fov , const Mat & image , double scale , const Color & color ) <nl> + cv : : viz : : WCameraPosition : : WCameraPosition ( const Vec2f & fov , const Mat & image , float scale , const Color & color ) <nl> { <nl> CV_Assert ( ! image . empty ( ) & & image . depth ( ) = = CV_8U ) ; <nl> float fovy = fov [ 1 ] * 180 . 0f / CV_PI ; <nl> struct cv : : viz : : WTrajectory : : ApplyPath <nl> } <nl> } ; <nl> <nl> - cv : : viz : : WTrajectory : : WTrajectory ( const std : : vector < Affine3f > & path , int display_mode , const Color & color , double scale ) <nl> + cv : : viz : : WTrajectory : : WTrajectory ( const std : : vector < Affine3f > & path , int display_mode , const Color & color , float scale ) <nl> { <nl> vtkSmartPointer < vtkAppendPolyData > appendFilter = vtkSmartPointer < vtkAppendPolyData > : : New ( ) ; <nl> <nl> cv : : viz : : WTrajectory : : WTrajectory ( const std : : vector < Affine3f > & path , int display <nl> WidgetAccessor : : setProp ( * this , actor ) ; <nl> } <nl> <nl> - cv : : viz : : WTrajectory : : WTrajectory ( const std : : vector < Affine3f > & path , const Matx33f & K , double scale , const Color & color ) <nl> + cv : : viz : : WTrajectory : : WTrajectory ( const std : : vector < Affine3f > & path , const Matx33f & K , float scale , const Color & color ) <nl> { <nl> vtkSmartPointer < vtkCamera > camera = vtkSmartPointer < vtkCamera > : : New ( ) ; <nl> float f_x = K ( 0 , 0 ) ; <nl> cv : : viz : : WTrajectory : : WTrajectory ( const std : : vector < Affine3f > & path , const Matx3 <nl> setColor ( color ) ; <nl> } <nl> <nl> - cv : : viz : : WTrajectory : : WTrajectory ( const std : : vector < Affine3f > & path , const Vec2f & fov , double scale , const Color & color ) <nl> + cv : : viz : : WTrajectory : : WTrajectory ( const std : : vector < Affine3f > & path , const Vec2f & fov , float scale , const Color & color ) <nl> { <nl> vtkSmartPointer < vtkCamera > camera = vtkSmartPointer < vtkCamera > : : New ( ) ; <nl> <nl> template < > cv : : viz : : WTrajectory cv : : viz : : Widget : : cast < cv : : viz : : WTrajectory > ( ) <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / spheres trajectory widget implementation <nl> <nl> - cv : : viz : : WSpheresTrajectory : : WSpheresTrajectory ( const std : : vector < Affine3f > & path , float line_length , double init_sphere_radius , double sphere_radius , <nl> + cv : : viz : : WSpheresTrajectory : : WSpheresTrajectory ( const std : : vector < Affine3f > & path , float line_length , float init_sphere_radius , float sphere_radius , <nl> const Color & line_color , const Color & sphere_color ) <nl> { <nl> vtkSmartPointer < vtkAppendPolyData > appendFilter = vtkSmartPointer < vtkAppendPolyData > : : New ( ) ; <nl> mmm a / modules / viz / src / viz . cpp <nl> ppp b / modules / viz / src / viz . cpp <nl> namespace cv { namespace viz <nl> } } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / Viz accessor implementation <nl> + / / / VizStorage implementation <nl> <nl> - cv : : viz : : VizAccessor * cv : : viz : : VizAccessor : : instance_ = 0 ; <nl> + cv : : viz : : VizMap cv : : viz : : VizStorage : : storage ; <nl> + void cv : : viz : : VizStorage : : unregisterAll ( ) { storage . clear ( ) ; } <nl> <nl> - struct cv : : viz : : VizAccessor : : VizAccessorImpl <nl> + cv : : viz : : Viz3d & cv : : viz : : VizStorage : : get ( const String & window_name ) <nl> { <nl> - cv : : viz : : VizMap viz_map ; <nl> - } ; <nl> - <nl> - cv : : viz : : VizAccessor : : VizAccessor ( ) { impl_ = new cv : : viz : : VizAccessor : : VizAccessorImpl ; } <nl> - cv : : viz : : VizAccessor : : ~ VizAccessor ( ) { delete impl_ ; } <nl> - <nl> - cv : : viz : : VizAccessor & cv : : viz : : VizAccessor : : getInstance ( ) <nl> - { <nl> - if ( ! instance_ ) <nl> - instance_ = new VizAccessor ( ) ; <nl> - <nl> - return * instance_ ; <nl> - } <nl> - <nl> - void cv : : viz : : VizAccessor : : release ( ) <nl> - { <nl> - if ( instance_ ) <nl> - { <nl> - delete instance_ ; <nl> - instance_ = 0 ; <nl> - } <nl> + String name = generateWindowName ( window_name ) ; <nl> + VizMap : : iterator vm_itr = storage . find ( name ) ; <nl> + CV_Assert ( vm_itr ! = storage . end ( ) ) ; <nl> + return vm_itr - > second ; <nl> } <nl> <nl> - cv : : viz : : Viz3d cv : : viz : : VizAccessor : : get ( const String & window_name ) <nl> + void cv : : viz : : VizStorage : : add ( const Viz3d & window ) <nl> { <nl> - / / Add the prefix Viz <nl> - String name ; <nl> - generateWindowName ( window_name , name ) ; <nl> - <nl> - VizMap : : iterator vm_itr = impl_ - > viz_map . find ( name ) ; <nl> - return vm_itr ! = impl_ - > viz_map . end ( ) ? vm_itr - > second : Viz3d ( window_name ) ; <nl> + String window_name = window . getWindowName ( ) ; <nl> + VizMap : : iterator vm_itr = storage . find ( window_name ) ; <nl> + CV_Assert ( vm_itr = = storage . end ( ) ) ; <nl> + storage . insert ( std : : make_pair ( window_name , window ) ) ; <nl> } <nl> <nl> - void cv : : viz : : VizAccessor : : add ( Viz3d window ) <nl> + bool cv : : viz : : VizStorage : : windowExists ( const String & window_name ) <nl> { <nl> - String window_name = window . getWindowName ( ) ; <nl> - VizMap : : iterator vm_itr = impl_ - > viz_map . find ( window_name ) ; <nl> - if ( vm_itr = = impl_ - > viz_map . end ( ) ) <nl> - impl_ - > viz_map . insert ( VizPair ( window_name , window ) ) ; <nl> + String name = generateWindowName ( window_name ) ; <nl> + return storage . find ( name ) ! = storage . end ( ) ; <nl> } <nl> <nl> - void cv : : viz : : VizAccessor : : remove ( const String & window_name ) <nl> + void cv : : viz : : VizStorage : : removeUnreferenced ( ) <nl> { <nl> - / / Add the prefix Viz <nl> - String name ; <nl> - generateWindowName ( window_name , name ) ; <nl> - <nl> - VizMap : : iterator vm_itr = impl_ - > viz_map . find ( name ) ; <nl> - if ( vm_itr ! = impl_ - > viz_map . end ( ) ) <nl> - impl_ - > viz_map . erase ( vm_itr ) ; <nl> + for ( VizMap : : iterator pos = storage . begin ( ) ; pos ! = storage . end ( ) ; ) <nl> + if ( pos - > second . impl_ - > ref_counter = = 1 ) <nl> + storage . erase ( pos + + ) ; <nl> + else <nl> + + + pos ; <nl> } <nl> <nl> - void cv : : viz : : VizAccessor : : generateWindowName ( const String & window_name , String & output ) <nl> + cv : : String cv : : viz : : VizStorage : : generateWindowName ( const String & window_name ) <nl> { <nl> - output = " Viz " ; <nl> + String output = " Viz " ; <nl> / / Already is Viz <nl> if ( window_name = = output ) <nl> - return ; <nl> + return output ; <nl> <nl> String prefixed = output + " - " ; <nl> if ( window_name . substr ( 0 , prefixed . length ( ) ) = = prefixed ) <nl> void cv : : viz : : VizAccessor : : generateWindowName ( const String & window_name , String <nl> output = prefixed + window_name ; / / Doesn ' t have prefix <nl> else <nl> output = ( window_name = = " " ? output : prefixed + window_name ) ; <nl> - } <nl> <nl> - cv : : viz : : Viz3d cv : : viz : : get ( const String & window_name ) <nl> - { <nl> - return cv : : viz : : VizAccessor : : getInstance ( ) . get ( window_name ) ; <nl> + return output ; <nl> } <nl> + <nl> + cv : : viz : : Viz3d cv : : viz : : get ( const String & window_name ) { return Viz3d ( window_name ) ; } <nl> + void cv : : viz : : unregisterAllWindows ( ) { VizStorage : : unregisterAll ( ) ; } <nl> mmm a / modules / viz / src / viz3d . cpp <nl> ppp b / modules / viz / src / viz3d . cpp <nl> cv : : viz : : Viz3d : : Viz3d ( const String & window_name ) : impl_ ( 0 ) { create ( window_name <nl> <nl> cv : : viz : : Viz3d : : Viz3d ( const Viz3d & other ) : impl_ ( other . impl_ ) <nl> { <nl> - if ( impl_ ) CV_XADD ( & impl_ - > ref_counter , 1 ) ; <nl> + if ( impl_ ) <nl> + CV_XADD ( & impl_ - > ref_counter , 1 ) ; <nl> } <nl> <nl> cv : : viz : : Viz3d & cv : : viz : : Viz3d : : operator = ( const Viz3d & other ) <nl> cv : : viz : : Viz3d & cv : : viz : : Viz3d : : operator = ( const Viz3d & other ) <nl> { <nl> release ( ) ; <nl> impl_ = other . impl_ ; <nl> - if ( impl_ ) CV_XADD ( & impl_ - > ref_counter , 1 ) ; <nl> + if ( impl_ ) <nl> + CV_XADD ( & impl_ - > ref_counter , 1 ) ; <nl> } <nl> return * this ; <nl> } <nl> cv : : viz : : Viz3d : : ~ Viz3d ( ) { release ( ) ; } <nl> <nl> void cv : : viz : : Viz3d : : create ( const String & window_name ) <nl> { <nl> - if ( impl_ ) release ( ) ; <nl> - impl_ = new VizImpl ( window_name ) ; <nl> - impl_ - > ref_counter = 1 ; <nl> - / / Register the window <nl> - cv : : viz : : VizAccessor : : getInstance ( ) . add ( * this ) ; <nl> + if ( impl_ ) <nl> + release ( ) ; <nl> + <nl> + if ( VizStorage : : windowExists ( window_name ) ) <nl> + * this = VizStorage : : get ( window_name ) ; <nl> + else <nl> + { <nl> + impl_ = new VizImpl ( window_name ) ; <nl> + impl_ - > ref_counter = 1 ; <nl> + <nl> + / / Register the window <nl> + VizStorage : : add ( * this ) ; <nl> + } <nl> } <nl> <nl> void cv : : viz : : Viz3d : : release ( ) <nl> { <nl> - / / If the current referene count is equal to 2 , we can delete it <nl> - / / - 2 : because minimum there will be two instances , one of which is in the map <nl> - if ( impl_ & & CV_XADD ( & impl_ - > ref_counter , - 1 ) = = 2 ) <nl> + if ( impl_ & & CV_XADD ( & impl_ - > ref_counter , - 1 ) = = 1 ) <nl> { <nl> - / / Erase the window <nl> - cv : : viz : : VizAccessor : : getInstance ( ) . remove ( getWindowName ( ) ) ; <nl> delete impl_ ; <nl> impl_ = 0 ; <nl> } <nl> + <nl> + if ( impl_ & & impl_ - > ref_counter = = 1 ) <nl> + VizStorage : : removeUnreferenced ( ) ; <nl> + <nl> + impl_ = 0 ; <nl> } <nl> <nl> void cv : : viz : : Viz3d : : spin ( ) { impl_ - > spin ( ) ; } <nl> mmm a / modules / viz / src / viz3d_impl . cpp <nl> ppp b / modules / viz / src / viz3d_impl . cpp <nl> <nl> <nl> # include " precomp . hpp " <nl> <nl> + vtkRenderWindowInteractor * vtkRenderWindowInteractorFixNew ( ) ; <nl> + <nl> # if 1 | | ! defined __APPLE__ <nl> vtkRenderWindowInteractor * vtkRenderWindowInteractorFixNew ( ) <nl> { <nl> vtkRenderWindowInteractor * vtkRenderWindowInteractorFixNew ( ) <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> cv : : viz : : Viz3d : : VizImpl : : VizImpl ( const String & name ) <nl> - : style_ ( vtkSmartPointer < cv : : viz : : InteractorStyle > : : New ( ) ) , widget_actor_map_ ( new WidgetActorMap ) , s_lastDone_ ( 0 . 0 ) <nl> + : s_lastDone_ ( 0 . 0 ) , style_ ( vtkSmartPointer < cv : : viz : : InteractorStyle > : : New ( ) ) , widget_actor_map_ ( new WidgetActorMap ) <nl> { <nl> renderer_ = vtkSmartPointer < vtkRenderer > : : New ( ) ; <nl> <nl> cv : : viz : : Viz3d : : VizImpl : : VizImpl ( const String & name ) <nl> style_ - > UseTimersOn ( ) ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - interactor_ = vtkSmartPointer < vtkRenderWindowInteractor > : : Take ( vtkRenderWindowInteractorFixNew ( ) ) ; <nl> + interactor_ = vtkSmartPointer < vtkRenderWindowInteractor > : : Take ( vtkRenderWindowInteractorFixNew ( ) ) ; <nl> <nl> window_ - > AlphaBitPlanesOff ( ) ; <nl> window_ - > PointSmoothingOff ( ) ; <nl> cv : : viz : : Viz3d : : VizImpl : : VizImpl ( const String & name ) <nl> timer_id_ = interactor_ - > CreateRepeatingTimer ( 5000L ) ; <nl> <nl> / / Set a simple PointPicker <nl> - vtkSmartPointer < vtkPointPicker > pp = vtkSmartPointer < vtkPointPicker > : : New ( ) ; <nl> - pp - > SetTolerance ( pp - > GetTolerance ( ) * 2 ) ; <nl> - interactor_ - > SetPicker ( pp ) ; <nl> + / / vtkSmartPointer < vtkPointPicker > pp = vtkSmartPointer < vtkPointPicker > : : New ( ) ; <nl> + / / pp - > SetTolerance ( pp - > GetTolerance ( ) * 2 ) ; <nl> + / / interactor_ - > SetPicker ( pp ) ; <nl> <nl> exit_main_loop_timer_callback_ = vtkSmartPointer < ExitMainLoopTimerCallback > : : New ( ) ; <nl> exit_main_loop_timer_callback_ - > viz_ = this ; <nl> cv : : viz : : Viz3d : : VizImpl : : VizImpl ( const String & name ) <nl> <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - String window_name ; <nl> - VizAccessor : : generateWindowName ( name , window_name ) ; <nl> + String window_name = VizStorage : : generateWindowName ( name ) ; <nl> window_ - > SetWindowName ( window_name . c_str ( ) ) ; <nl> } <nl> <nl> bool cv : : viz : : Viz3d : : VizImpl : : removeActorFromRenderer ( const vtkSmartPointer < vtkP <nl> return false ; <nl> } <nl> <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - void cv : : viz : : Viz3d : : VizImpl : : createActorFromVTKDataSet ( const vtkSmartPointer < vtkDataSet > & data , vtkSmartPointer < vtkLODActor > & actor , bool use_scalars ) <nl> - { <nl> - if ( ! actor ) <nl> - actor = vtkSmartPointer < vtkLODActor > : : New ( ) ; <nl> - <nl> - vtkSmartPointer < vtkDataSetMapper > mapper = vtkSmartPointer < vtkDataSetMapper > : : New ( ) ; <nl> - # if VTK_MAJOR_VERSION < = 5 <nl> - mapper - > SetInput ( data ) ; <nl> - # else <nl> - mapper - > SetInputData ( data ) ; <nl> - # endif <nl> - <nl> - if ( use_scalars ) <nl> - { <nl> - vtkSmartPointer < vtkDataArray > scalars = data - > GetPointData ( ) - > GetScalars ( ) ; <nl> - if ( scalars ) <nl> - { <nl> - cv : : Vec3d minmax ( scalars - > GetRange ( ) ) ; <nl> - mapper - > SetScalarRange ( minmax . val ) ; <nl> - mapper - > SetScalarModeToUsePointData ( ) ; <nl> - <nl> - / / interpolation OFF , if data is a vtkPolyData that contains only vertices , ON for anything else . <nl> - vtkPolyData * polyData = vtkPolyData : : SafeDownCast ( data ) ; <nl> - bool interpolation = ( polyData & & polyData - > GetNumberOfCells ( ) ! = polyData - > GetNumberOfVerts ( ) ) ; <nl> - <nl> - mapper - > SetInterpolateScalarsBeforeMapping ( interpolation ) ; <nl> - mapper - > ScalarVisibilityOn ( ) ; <nl> - } <nl> - } <nl> - mapper - > ImmediateModeRenderingOff ( ) ; <nl> - <nl> - actor - > SetNumberOfCloudPoints ( int ( std : : max < vtkIdType > ( 1 , data - > GetNumberOfPoints ( ) / 10 ) ) ) ; <nl> - actor - > GetProperty ( ) - > SetInterpolationToFlat ( ) ; <nl> - actor - > GetProperty ( ) - > BackfaceCullingOn ( ) ; <nl> - <nl> - actor - > SetMapper ( mapper ) ; <nl> - } <nl> - <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> void cv : : viz : : Viz3d : : VizImpl : : setBackgroundColor ( const Color & color ) <nl> { <nl> void cv : : viz : : Viz3d : : VizImpl : : setRepresentation ( int representation ) <nl> } <nl> } <nl> <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - void cv : : viz : : Viz3d : : VizImpl : : updateCells ( vtkSmartPointer < vtkIdTypeArray > & cells , vtkSmartPointer < vtkIdTypeArray > & initcells , vtkIdType nr_points ) <nl> - { <nl> - / / If no init cells and cells has not been initialized . . . <nl> - if ( ! cells ) <nl> - cells = vtkSmartPointer < vtkIdTypeArray > : : New ( ) ; <nl> - <nl> - / / If we have less values then we need to recreate the array <nl> - if ( cells - > GetNumberOfTuples ( ) < nr_points ) <nl> - { <nl> - cells = vtkSmartPointer < vtkIdTypeArray > : : New ( ) ; <nl> - <nl> - / / If init cells is given , and there ' s enough data in it , use it <nl> - if ( initcells & & initcells - > GetNumberOfTuples ( ) > = nr_points ) <nl> - { <nl> - cells - > DeepCopy ( initcells ) ; <nl> - cells - > SetNumberOfComponents ( 2 ) ; <nl> - cells - > SetNumberOfTuples ( nr_points ) ; <nl> - } <nl> - else <nl> - { <nl> - / / If the number of tuples is still too small , we need to recreate the array <nl> - cells - > SetNumberOfComponents ( 2 ) ; <nl> - cells - > SetNumberOfTuples ( nr_points ) ; <nl> - vtkIdType * cell = cells - > GetPointer ( 0 ) ; <nl> - / / Fill it with 1s <nl> - std : : fill_n ( cell , nr_points * 2 , 1 ) ; <nl> - cell + + ; <nl> - for ( vtkIdType i = 0 ; i < nr_points ; + + i , cell + = 2 ) <nl> - * cell = i ; <nl> - / / Save the results in initcells <nl> - initcells = vtkSmartPointer < vtkIdTypeArray > : : New ( ) ; <nl> - initcells - > DeepCopy ( cells ) ; <nl> - } <nl> - } <nl> - else <nl> - { <nl> - / / The assumption here is that the current set of cells has more data than needed <nl> - cells - > SetNumberOfComponents ( 2 ) ; <nl> - cells - > SetNumberOfTuples ( nr_points ) ; <nl> - } <nl> - } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> void cv : : viz : : Viz3d : : VizImpl : : setFullScreen ( bool mode ) <nl> mmm a / modules / viz / src / viz3d_impl . hpp <nl> ppp b / modules / viz / src / viz3d_impl . hpp <nl> <nl> struct cv : : viz : : Viz3d : : VizImpl <nl> { <nl> public : <nl> - typedef cv : : Ptr < VizImpl > Ptr ; <nl> typedef Viz3d : : KeyboardCallback KeyboardCallback ; <nl> typedef Viz3d : : MouseCallback MouseCallback ; <nl> <nl> struct cv : : viz : : Viz3d : : VizImpl <nl> bool camera_set_ ; <nl> <nl> bool removeActorFromRenderer ( const vtkSmartPointer < vtkProp > & actor ) ; <nl> - <nl> - void createActorFromVTKDataSet ( const vtkSmartPointer < vtkDataSet > & data , vtkSmartPointer < vtkLODActor > & actor , bool use_scalars = true ) ; <nl> - void updateCells ( vtkSmartPointer < vtkIdTypeArray > & cells , vtkSmartPointer < vtkIdTypeArray > & initcells , vtkIdType nr_points ) ; <nl> } ; <nl> <nl> <nl> new file mode 100644 <nl> index 00000000000 . . 6e9189b8f25 <nl> mmm / dev / null <nl> ppp b / modules / viz / test / test_tutorial2 . cpp <nl> <nl> + # include " test_precomp . hpp " <nl> + <nl> + using namespace cv ; <nl> + using namespace std ; <nl> + <nl> + void tutorial2 ( ) <nl> + { <nl> + / / / Create a window <nl> + viz : : Viz3d myWindow ( " Coordinate Frame " ) ; <nl> + <nl> + / / / Add coordinate axes <nl> + myWindow . showWidget ( " Coordinate Widget " , viz : : WCoordinateSystem ( ) ) ; <nl> + <nl> + / / / Add line to represent ( 1 , 1 , 1 ) axis <nl> + viz : : WLine axis ( Point3f ( - 1 . 0f , - 1 . 0f , - 1 . 0f ) , Point3f ( 1 . 0f , 1 . 0f , 1 . 0f ) ) ; <nl> + axis . setRenderingProperty ( viz : : LINE_WIDTH , 4 . 0 ) ; <nl> + myWindow . showWidget ( " Line Widget " , axis ) ; <nl> + <nl> + / / / Construct a cube widget <nl> + viz : : WCube cube_widget ( Point3f ( 0 . 5 , 0 . 5 , 0 . 0 ) , Point3f ( 0 . 0 , 0 . 0 , - 0 . 5 ) , true , viz : : Color : : blue ( ) ) ; <nl> + cube_widget . setRenderingProperty ( viz : : LINE_WIDTH , 4 . 0 ) ; <nl> + <nl> + / / / Display widget ( update if already displayed ) <nl> + myWindow . showWidget ( " Cube Widget " , cube_widget ) ; <nl> + <nl> + / / / Rodrigues vector <nl> + Mat rot_vec = Mat : : zeros ( 1 , 3 , CV_32F ) ; <nl> + float translation_phase = 0 . 0 , translation = 0 . 0 ; <nl> + while ( ! myWindow . wasStopped ( ) ) <nl> + { <nl> + / * Rotation using rodrigues * / <nl> + / / / Rotate around ( 1 , 1 , 1 ) <nl> + rot_vec . at < float > ( 0 , 0 ) + = CV_PI * 0 . 01f ; <nl> + rot_vec . at < float > ( 0 , 1 ) + = CV_PI * 0 . 01f ; <nl> + rot_vec . at < float > ( 0 , 2 ) + = CV_PI * 0 . 01f ; <nl> + <nl> + / / / Shift on ( 1 , 1 , 1 ) <nl> + translation_phase + = CV_PI * 0 . 01f ; <nl> + translation = sin ( translation_phase ) ; <nl> + <nl> + / / / Construct pose <nl> + Affine3f pose ( rot_vec , Vec3f ( translation , translation , translation ) ) ; <nl> + <nl> + myWindow . setWidgetPose ( " Cube Widget " , pose ) ; <nl> + <nl> + myWindow . spinOnce ( 1 , true ) ; <nl> + } <nl> + } <nl> + <nl> + <nl> + TEST ( Viz_viz3d , DISABLED_tutorial2_pose_of_widget ) <nl> + { <nl> + tutorial2 ( ) ; <nl> + } <nl>
Merge pull request from Nerei : master
opencv/opencv
24465bbd05f3ddb05aaf93d641d4a080d0e26417
2013-12-09T10:13:40Z
mmm a / src / CMakeLists . txt <nl> ppp b / src / CMakeLists . txt <nl> set ( INTERNAL_HEADERS <nl> $ { SOURCES_DIR } / catch_leak_detector . h <nl> $ { SOURCES_DIR } / catch_list . h <nl> $ { SOURCES_DIR } / matchers / catch_matchers . hpp <nl> + $ { SOURCES_DIR } / matchers / catch_matchers_contains . hpp <nl> $ { SOURCES_DIR } / matchers / catch_matchers_exception . hpp <nl> $ { SOURCES_DIR } / matchers / catch_matchers_floating . hpp <nl> $ { SOURCES_DIR } / matchers / catch_matchers_generic . hpp <nl> new file mode 100644 <nl> index 000000000 . . 0fcd80a63 <nl> mmm / dev / null <nl> ppp b / src / catch2 / matchers / catch_matchers_contains . hpp <nl> <nl> + / * <nl> + * Distributed under the Boost Software License , Version 1 . 0 . ( See accompanying <nl> + * file LICENSE_1_0 . txt or copy at http : / / www . boost . org / LICENSE_1_0 . txt ) <nl> + * / <nl> + # ifndef TWOBLUECUBES_CATCH_MATCHERS_CONTAINS_HPP_INCLUDED <nl> + # define TWOBLUECUBES_CATCH_MATCHERS_CONTAINS_HPP_INCLUDED <nl> + <nl> + # include < catch2 / matchers / catch_matchers_templates . hpp > <nl> + <nl> + # include < algorithm > <nl> + # include < functional > <nl> + # include < utility > <nl> + <nl> + namespace Catch { <nl> + namespace Matchers { <nl> + / / ! Matcher for checking that an element in range is equal to specific element <nl> + template < typename T , typename Equality > <nl> + class ContainsElementMatcher final : public MatcherGenericBase { <nl> + T m_desired ; <nl> + Equality m_eq ; <nl> + public : <nl> + template < typename T2 , typename Equality2 > <nl> + ContainsElementMatcher ( T2 & & target , Equality2 & & predicate ) : <nl> + m_desired ( std : : forward < T2 > ( target ) ) , <nl> + m_eq ( std : : forward < Equality2 > ( predicate ) ) <nl> + { } <nl> + <nl> + std : : string describe ( ) const override { <nl> + return " contains element " + Catch : : Detail : : stringify ( m_desired ) ; <nl> + } <nl> + <nl> + template < typename RangeLike > <nl> + bool match ( RangeLike & & rng ) const { <nl> + using std : : begin ; using std : : end ; <nl> + <nl> + return end ( rng ) ! = std : : find_if ( begin ( rng ) , end ( rng ) , <nl> + [ & ] ( auto const & elem ) { <nl> + return m_eq ( elem , m_desired ) ; <nl> + } ) ; <nl> + } <nl> + } ; <nl> + <nl> + / / ! Meta - matcher for checking that an element in a range matches a specific matcher <nl> + template < typename Matcher > <nl> + class ContainsMatcherMatcher final : public MatcherGenericBase { <nl> + Matcher m_matcher ; <nl> + public : <nl> + / / Note that we do a copy + move to avoid having to SFINAE this <nl> + / / constructor ( and also avoid some perfect forwarding failure <nl> + / / cases ) <nl> + ContainsMatcherMatcher ( Matcher matcher ) : <nl> + m_matcher ( std : : move ( matcher ) ) <nl> + { } <nl> + <nl> + template < typename RangeLike > <nl> + bool match ( RangeLike & & rng ) const { <nl> + using std : : begin ; using std : : endl ; <nl> + for ( auto & & elem : rng ) { <nl> + if ( m_matcher . match ( elem ) ) { <nl> + return true ; <nl> + } <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + std : : string describe ( ) const override { <nl> + return " contains element matching " + m_matcher . describe ( ) ; <nl> + } <nl> + } ; <nl> + <nl> + / * * <nl> + * Creates a matcher that checks whether a range contains a specific element . <nl> + * <nl> + * Uses ` std : : equal_to ` to do the comparison <nl> + * / <nl> + template < typename T > <nl> + std : : enable_if_t < ! Detail : : is_matcher < T > : : value , <nl> + ContainsElementMatcher < T , std : : equal_to < > > > Contains ( T & & elem ) { <nl> + return { std : : forward < T > ( elem ) , std : : equal_to < > { } } ; <nl> + } <nl> + <nl> + / / ! Creates a matcher that checks whether a range contains element matching a matcher <nl> + template < typename Matcher > <nl> + std : : enable_if_t < Detail : : is_matcher < Matcher > : : value , <nl> + ContainsMatcherMatcher < Matcher > > Contains ( Matcher & & matcher ) { <nl> + return { std : : forward < Matcher > ( matcher ) } ; <nl> + } <nl> + <nl> + / * * <nl> + * Creates a matcher that checks whether a range contains a specific element . <nl> + * <nl> + * Uses ` eq ` to do the comparisons <nl> + * / <nl> + template < typename T , typename Equality > <nl> + ContainsElementMatcher < T , Equality > Contains ( T & & elem , Equality & & eq ) { <nl> + return { std : : forward < T > ( elem ) , std : : forward < Equality > ( eq ) } ; <nl> + } <nl> + <nl> + } <nl> + } <nl> + <nl> + # endif / / TWOBLUECUBES_CATCH_MATCHERS_CONTAINS_HPP_INCLUDED <nl> mmm a / tests / CMakeLists . txt <nl> ppp b / tests / CMakeLists . txt <nl> set ( TEST_SOURCES <nl> $ { SELF_TEST_DIR } / UsageTests / ToStringWhich . tests . cpp <nl> $ { SELF_TEST_DIR } / UsageTests / Tricky . tests . cpp <nl> $ { SELF_TEST_DIR } / UsageTests / VariadicMacros . tests . cpp <nl> + $ { SELF_TEST_DIR } / UsageTests / MatchersRanges . tests . cpp <nl> $ { SELF_TEST_DIR } / UsageTests / Matchers . tests . cpp <nl> ) <nl> CheckFileList ( TEST_SOURCES $ { SELF_TEST_DIR } ) <nl> mmm a / tests / SelfTest / Baselines / automake . sw . approved . txt <nl> ppp b / tests / SelfTest / Baselines / automake . sw . approved . txt <nl> Nor would this <nl> : test - result : PASS Approximate comparisons with mixed numeric types <nl> : test - result : PASS Arbitrary predicate matcher <nl> : test - result : PASS Assertions then sections <nl> + : test - result : PASS Basic use of the Contains range matcher <nl> : test - result : PASS CAPTURE can deal with complex expressions <nl> : test - result : PASS CAPTURE can deal with complex expressions involving commas <nl> : test - result : PASS CAPTURE parses string and character constants <nl> mmm a / tests / SelfTest / Baselines / compact . sw . approved . txt <nl> ppp b / tests / SelfTest / Baselines / compact . sw . approved . txt <nl> Tricky . tests . cpp : < line number > : passed : true <nl> Tricky . tests . cpp : < line number > : passed : true <nl> Tricky . tests . cpp : < line number > : passed : true <nl> Tricky . tests . cpp : < line number > : passed : true <nl> + MatchersRanges . tests . cpp : < line number > : passed : a , Contains ( 1 ) for : { 1 , 2 , 3 } contains element 1 <nl> + MatchersRanges . tests . cpp : < line number > : passed : b , Contains ( 1 ) for : { 0 , 1 , 2 } contains element 1 <nl> + MatchersRanges . tests . cpp : < line number > : passed : c , ! Contains ( 1 ) for : { 4 , 5 , 6 } not contains element 1 <nl> + MatchersRanges . tests . cpp : < line number > : passed : a , Contains ( 0 , close_enough ) for : { 1 , 2 , 3 } contains element 0 <nl> + MatchersRanges . tests . cpp : < line number > : passed : b , Contains ( 0 , close_enough ) for : { 0 , 1 , 2 } contains element 0 <nl> + MatchersRanges . tests . cpp : < line number > : passed : c , ! Contains ( 0 , close_enough ) for : { 4 , 5 , 6 } not contains element 0 <nl> + MatchersRanges . tests . cpp : < line number > : passed : a , Contains ( 4 , [ ] ( auto & & lhs , size_t sz ) { return lhs . size ( ) = = sz ; } ) for : { " abc " , " abcd " , " abcde " } contains element 4 <nl> + MatchersRanges . tests . cpp : < line number > : passed : in , Contains ( 1 ) for : { 1 , 2 , 3 , 4 , 5 } contains element 1 <nl> + MatchersRanges . tests . cpp : < line number > : passed : in , ! Contains ( 8 ) for : { 1 , 2 , 3 , 4 , 5 } not contains element 8 <nl> + MatchersRanges . tests . cpp : < line number > : passed : in , Contains ( MoveOnlyTestElement { 2 } ) for : { 1 , 2 , 3 } contains element 2 <nl> + MatchersRanges . tests . cpp : < line number > : passed : in , ! Contains ( MoveOnlyTestElement { 9 } ) for : { 1 , 2 , 3 } not contains element 9 <nl> + MatchersRanges . tests . cpp : < line number > : passed : in , Contains ( Catch : : Matchers : : WithinAbs ( 0 . 5 , 0 . 5 ) ) for : { 1 . 0 , 2 . 0 , 3 . 0 , 0 . 0 } contains element matching is within 0 . 5 of 0 . 5 <nl> Message . tests . cpp : < line number > : passed : with 7 messages : ' a : = 1 ' and ' b : = 2 ' and ' c : = 3 ' and ' a + b : = 3 ' and ' a + b : = 3 ' and ' c > b : = true ' and ' a = = 1 : = true ' <nl> Message . tests . cpp : < line number > : passed : with 7 messages : ' std : : vector < int > { 1 , 2 , 3 } [ 0 , 1 , 2 ] : = 3 ' and ' std : : vector < int > { 1 , 2 , 3 } [ ( 0 , 1 ) ] : = 2 ' and ' std : : vector < int > { 1 , 2 , 3 } [ 0 ] : = 1 ' and ' ( helper_1436 < int , int > { 12 , - 12 } ) : = { 12 , - 12 } ' and ' ( helper_1436 < int , int > ( - 12 , 12 ) ) : = { - 12 , 12 } ' and ' ( 1 , 2 ) : = 2 ' and ' ( 2 , 3 ) : = 3 ' <nl> Message . tests . cpp : < line number > : passed : with 11 messages : ' ( " comma , in string " , " escaped , \ " , " ) : = " escaped , " , " ' and ' " single quote in string , ' , " : = " single quote in string , ' , " ' and ' " some escapes , \ \ , \ \ \ \ " : = " some escapes , \ , \ \ " ' and ' " some , ) , unmatched , } prenheses { [ < " : = " some , ) , unmatched , } prenheses { [ < " ' and ' ' " ' : = ' " ' ' and ' ' \ ' ' : = ' ' ' ' and ' ' , ' : = ' , ' ' and ' ' } ' : = ' } ' ' and ' ' ) ' : = ' ) ' ' and ' ' ( ' : = ' ( ' ' and ' ' { ' : = ' { ' ' <nl> mmm a / tests / SelfTest / Baselines / console . std . approved . txt <nl> ppp b / tests / SelfTest / Baselines / console . std . approved . txt <nl> due to unexpected exception with message : <nl> Why would you throw a std : : string ? <nl> <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - test cases : 328 | 254 passed | 70 failed | 4 failed as expected <nl> - assertions : 1839 | 1687 passed | 131 failed | 21 failed as expected <nl> + test cases : 329 | 255 passed | 70 failed | 4 failed as expected <nl> + assertions : 1851 | 1699 passed | 131 failed | 21 failed as expected <nl> <nl> mmm a / tests / SelfTest / Baselines / console . sw . approved . txt <nl> ppp b / tests / SelfTest / Baselines / console . sw . approved . txt <nl> Tricky . tests . cpp : < line number > <nl> Tricky . tests . cpp : < line number > : PASSED : <nl> REQUIRE ( true ) <nl> <nl> + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + Basic use of the Contains range matcher <nl> + Different argument ranges , same element type , default comparison <nl> + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + MatchersRanges . tests . cpp : < line number > <nl> + . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <nl> + <nl> + MatchersRanges . tests . cpp : < line number > : PASSED : <nl> + REQUIRE_THAT ( a , Contains ( 1 ) ) <nl> + with expansion : <nl> + { 1 , 2 , 3 } contains element 1 <nl> + <nl> + MatchersRanges . tests . cpp : < line number > : PASSED : <nl> + REQUIRE_THAT ( b , Contains ( 1 ) ) <nl> + with expansion : <nl> + { 0 , 1 , 2 } contains element 1 <nl> + <nl> + MatchersRanges . tests . cpp : < line number > : PASSED : <nl> + REQUIRE_THAT ( c , ! Contains ( 1 ) ) <nl> + with expansion : <nl> + { 4 , 5 , 6 } not contains element 1 <nl> + <nl> + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + Basic use of the Contains range matcher <nl> + Different argument ranges , same element type , custom comparison <nl> + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + MatchersRanges . tests . cpp : < line number > <nl> + . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <nl> + <nl> + MatchersRanges . tests . cpp : < line number > : PASSED : <nl> + REQUIRE_THAT ( a , Contains ( 0 , close_enough ) ) <nl> + with expansion : <nl> + { 1 , 2 , 3 } contains element 0 <nl> + <nl> + MatchersRanges . tests . cpp : < line number > : PASSED : <nl> + REQUIRE_THAT ( b , Contains ( 0 , close_enough ) ) <nl> + with expansion : <nl> + { 0 , 1 , 2 } contains element 0 <nl> + <nl> + MatchersRanges . tests . cpp : < line number > : PASSED : <nl> + REQUIRE_THAT ( c , ! Contains ( 0 , close_enough ) ) <nl> + with expansion : <nl> + { 4 , 5 , 6 } not contains element 0 <nl> + <nl> + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + Basic use of the Contains range matcher <nl> + Different element type , custom comparisons <nl> + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + MatchersRanges . tests . cpp : < line number > <nl> + . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <nl> + <nl> + MatchersRanges . tests . cpp : < line number > : PASSED : <nl> + REQUIRE_THAT ( a , Contains ( 4 , [ ] ( auto & & lhs , size_t sz ) { return lhs . size ( ) = = sz ; } ) ) <nl> + with expansion : <nl> + { " abc " , " abcd " , " abcde " } contains element 4 <nl> + <nl> + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + Basic use of the Contains range matcher <nl> + Can handle type that requires ADL - found free function begin and end <nl> + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + MatchersRanges . tests . cpp : < line number > <nl> + . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <nl> + <nl> + MatchersRanges . tests . cpp : < line number > : PASSED : <nl> + REQUIRE_THAT ( in , Contains ( 1 ) ) <nl> + with expansion : <nl> + { 1 , 2 , 3 , 4 , 5 } contains element 1 <nl> + <nl> + MatchersRanges . tests . cpp : < line number > : PASSED : <nl> + REQUIRE_THAT ( in , ! Contains ( 8 ) ) <nl> + with expansion : <nl> + { 1 , 2 , 3 , 4 , 5 } not contains element 8 <nl> + <nl> + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + Basic use of the Contains range matcher <nl> + Initialization with move only types <nl> + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + MatchersRanges . tests . cpp : < line number > <nl> + . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <nl> + <nl> + MatchersRanges . tests . cpp : < line number > : PASSED : <nl> + REQUIRE_THAT ( in , Contains ( MoveOnlyTestElement { 2 } ) ) <nl> + with expansion : <nl> + { 1 , 2 , 3 } contains element 2 <nl> + <nl> + MatchersRanges . tests . cpp : < line number > : PASSED : <nl> + REQUIRE_THAT ( in , ! Contains ( MoveOnlyTestElement { 9 } ) ) <nl> + with expansion : <nl> + { 1 , 2 , 3 } not contains element 9 <nl> + <nl> + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + Basic use of the Contains range matcher <nl> + Matching using matcher <nl> + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + MatchersRanges . tests . cpp : < line number > <nl> + . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <nl> + <nl> + MatchersRanges . tests . cpp : < line number > : PASSED : <nl> + REQUIRE_THAT ( in , Contains ( Catch : : Matchers : : WithinAbs ( 0 . 5 , 0 . 5 ) ) ) <nl> + with expansion : <nl> + { 1 . 0 , 2 . 0 , 3 . 0 , 0 . 0 } contains element matching is within 0 . 5 of 0 . 5 <nl> + <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> CAPTURE can deal with complex expressions <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> Misc . tests . cpp : < line number > <nl> Misc . tests . cpp : < line number > : PASSED : <nl> <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - test cases : 328 | 238 passed | 86 failed | 4 failed as expected <nl> - assertions : 1856 | 1687 passed | 148 failed | 21 failed as expected <nl> + test cases : 329 | 239 passed | 86 failed | 4 failed as expected <nl> + assertions : 1868 | 1699 passed | 148 failed | 21 failed as expected <nl> <nl> mmm a / tests / SelfTest / Baselines / junit . sw . approved . txt <nl> ppp b / tests / SelfTest / Baselines / junit . sw . approved . txt <nl> <nl> < ? xml version = " 1 . 0 " encoding = " UTF - 8 " ? > <nl> < testsuitesloose text artifact <nl> > <nl> - < testsuite name = " < exe - name > " errors = " 17 " failures = " 132 " tests = " 1857 " hostname = " tbd " time = " { duration } " timestamp = " { iso8601 - timestamp } " > <nl> + < testsuite name = " < exe - name > " errors = " 17 " failures = " 132 " tests = " 1869 " hostname = " tbd " time = " { duration } " timestamp = " { iso8601 - timestamp } " > <nl> < properties > <nl> < property name = " filters " value = " ~ [ ! nonportable ] ~ [ ! benchmark ] ~ [ approvals ] * " / > <nl> < property name = " random - seed " value = " 1 " / > <nl> Exception . tests . cpp : < line number > <nl> < testcase classname = " < exe - name > . global " name = " Assertions then sections / A section " time = " { duration } " / > <nl> < testcase classname = " < exe - name > . global " name = " Assertions then sections / A section / Another section " time = " { duration } " / > <nl> < testcase classname = " < exe - name > . global " name = " Assertions then sections / A section / Another other section " time = " { duration } " / > <nl> + < testcase classname = " < exe - name > . global " name = " Basic use of the Contains range matcher / Different argument ranges , same element type , default comparison " time = " { duration } " / > <nl> + < testcase classname = " < exe - name > . global " name = " Basic use of the Contains range matcher / Different argument ranges , same element type , custom comparison " time = " { duration } " / > <nl> + < testcase classname = " < exe - name > . global " name = " Basic use of the Contains range matcher / Different element type , custom comparisons " time = " { duration } " / > <nl> + < testcase classname = " < exe - name > . global " name = " Basic use of the Contains range matcher / Can handle type that requires ADL - found free function begin and end " time = " { duration } " / > <nl> + < testcase classname = " < exe - name > . global " name = " Basic use of the Contains range matcher / Initialization with move only types " time = " { duration } " / > <nl> + < testcase classname = " < exe - name > . global " name = " Basic use of the Contains range matcher / Matching using matcher " time = " { duration } " / > <nl> < testcase classname = " < exe - name > . global " name = " CAPTURE can deal with complex expressions " time = " { duration } " / > <nl> < testcase classname = " < exe - name > . global " name = " CAPTURE can deal with complex expressions involving commas " time = " { duration } " / > <nl> < testcase classname = " < exe - name > . global " name = " CAPTURE parses string and character constants " time = " { duration } " / > <nl> mmm a / tests / SelfTest / Baselines / sonarqube . sw . approved . txt <nl> ppp b / tests / SelfTest / Baselines / sonarqube . sw . approved . txt <nl> Matchers . tests . cpp : < line number > <nl> < / failure > <nl> < / testCase > <nl> < / file > <nl> + < file path = " tests / < exe - name > / UsageTests / MatchersRanges . tests . cpp " > <nl> + < testCase name = " Basic use of the Contains range matcher / Different argument ranges , same element type , default comparison " duration = " { duration } " / > <nl> + < testCase name = " Basic use of the Contains range matcher / Different argument ranges , same element type , custom comparison " duration = " { duration } " / > <nl> + < testCase name = " Basic use of the Contains range matcher / Different element type , custom comparisons " duration = " { duration } " / > <nl> + < testCase name = " Basic use of the Contains range matcher / Can handle type that requires ADL - found free function begin and end " duration = " { duration } " / > <nl> + < testCase name = " Basic use of the Contains range matcher / Initialization with move only types " duration = " { duration } " / > <nl> + < testCase name = " Basic use of the Contains range matcher / Matching using matcher " duration = " { duration } " / > <nl> + < / file > <nl> < file path = " tests / < exe - name > / UsageTests / Message . tests . cpp " > <nl> < testCase name = " # 1455 - INFO and WARN can start with a linebreak " duration = " { duration } " / > <nl> < testCase name = " CAPTURE can deal with complex expressions " duration = " { duration } " / > <nl> mmm a / tests / SelfTest / Baselines / tap . sw . approved . txt <nl> ppp b / tests / SelfTest / Baselines / tap . sw . approved . txt <nl> ok { test - number } - true <nl> ok { test - number } - true <nl> # Assertions then sections <nl> ok { test - number } - true <nl> + # Basic use of the Contains range matcher <nl> + ok { test - number } - a , Contains ( 1 ) for : { 1 , 2 , 3 } contains element 1 <nl> + # Basic use of the Contains range matcher <nl> + ok { test - number } - b , Contains ( 1 ) for : { 0 , 1 , 2 } contains element 1 <nl> + # Basic use of the Contains range matcher <nl> + ok { test - number } - c , ! Contains ( 1 ) for : { 4 , 5 , 6 } not contains element 1 <nl> + # Basic use of the Contains range matcher <nl> + ok { test - number } - a , Contains ( 0 , close_enough ) for : { 1 , 2 , 3 } contains element 0 <nl> + # Basic use of the Contains range matcher <nl> + ok { test - number } - b , Contains ( 0 , close_enough ) for : { 0 , 1 , 2 } contains element 0 <nl> + # Basic use of the Contains range matcher <nl> + ok { test - number } - c , ! Contains ( 0 , close_enough ) for : { 4 , 5 , 6 } not contains element 0 <nl> + # Basic use of the Contains range matcher <nl> + ok { test - number } - a , Contains ( 4 , [ ] ( auto & & lhs , size_t sz ) { return lhs . size ( ) = = sz ; } ) for : { " abc " , " abcd " , " abcde " } contains element 4 <nl> + # Basic use of the Contains range matcher <nl> + ok { test - number } - in , Contains ( 1 ) for : { 1 , 2 , 3 , 4 , 5 } contains element 1 <nl> + # Basic use of the Contains range matcher <nl> + ok { test - number } - in , ! Contains ( 8 ) for : { 1 , 2 , 3 , 4 , 5 } not contains element 8 <nl> + # Basic use of the Contains range matcher <nl> + ok { test - number } - in , Contains ( MoveOnlyTestElement { 2 } ) for : { 1 , 2 , 3 } contains element 2 <nl> + # Basic use of the Contains range matcher <nl> + ok { test - number } - in , ! Contains ( MoveOnlyTestElement { 9 } ) for : { 1 , 2 , 3 } not contains element 9 <nl> + # Basic use of the Contains range matcher <nl> + ok { test - number } - in , Contains ( Catch : : Matchers : : WithinAbs ( 0 . 5 , 0 . 5 ) ) for : { 1 . 0 , 2 . 0 , 3 . 0 , 0 . 0 } contains element matching is within 0 . 5 of 0 . 5 <nl> # CAPTURE can deal with complex expressions <nl> ok { test - number } - with 7 messages : ' a : = 1 ' and ' b : = 2 ' and ' c : = 3 ' and ' a + b : = 3 ' and ' a + b : = 3 ' and ' c > b : = true ' and ' a = = 1 : = true ' <nl> # CAPTURE can deal with complex expressions involving commas <nl> ok { test - number } - q3 = = 23 . for : 23 . 0 = = 23 . 0 <nl> ok { test - number } - <nl> # xmlentitycheck <nl> ok { test - number } - <nl> - 1 . . 1848 <nl> + 1 . . 1860 <nl> <nl> mmm a / tests / SelfTest / Baselines / teamcity . sw . approved . txt <nl> ppp b / tests / SelfTest / Baselines / teamcity . sw . approved . txt <nl> Exception . tests . cpp : < line number > | nunexpected exception with message : | n " unexpe <nl> # # teamcity [ testFinished name = ' Arbitrary predicate matcher ' duration = " { duration } " ] <nl> # # teamcity [ testStarted name = ' Assertions then sections ' ] <nl> # # teamcity [ testFinished name = ' Assertions then sections ' duration = " { duration } " ] <nl> + # # teamcity [ testStarted name = ' Basic use of the Contains range matcher ' ] <nl> + # # teamcity [ testFinished name = ' Basic use of the Contains range matcher ' duration = " { duration } " ] <nl> # # teamcity [ testStarted name = ' CAPTURE can deal with complex expressions ' ] <nl> # # teamcity [ testFinished name = ' CAPTURE can deal with complex expressions ' duration = " { duration } " ] <nl> # # teamcity [ testStarted name = ' CAPTURE can deal with complex expressions involving commas ' ] <nl> mmm a / tests / SelfTest / Baselines / xml . sw . approved . txt <nl> ppp b / tests / SelfTest / Baselines / xml . sw . approved . txt <nl> Nor would this <nl> < / Section > <nl> < OverallResult success = " true " / > <nl> < / TestCase > <nl> + < TestCase name = " Basic use of the Contains range matcher " tags = " [ contains ] [ matchers ] [ templated ] " filename = " tests / < exe - name > / UsageTests / MatchersRanges . tests . cpp " > <nl> + < Section name = " Different argument ranges , same element type , default comparison " filename = " tests / < exe - name > / UsageTests / MatchersRanges . tests . cpp " > <nl> + < Expression success = " true " type = " REQUIRE_THAT " filename = " tests / < exe - name > / UsageTests / MatchersRanges . tests . cpp " > <nl> + < Original > <nl> + a , Contains ( 1 ) <nl> + < / Original > <nl> + < Expanded > <nl> + { 1 , 2 , 3 } contains element 1 <nl> + < / Expanded > <nl> + < / Expression > <nl> + < Expression success = " true " type = " REQUIRE_THAT " filename = " tests / < exe - name > / UsageTests / MatchersRanges . tests . cpp " > <nl> + < Original > <nl> + b , Contains ( 1 ) <nl> + < / Original > <nl> + < Expanded > <nl> + { 0 , 1 , 2 } contains element 1 <nl> + < / Expanded > <nl> + < / Expression > <nl> + < Expression success = " true " type = " REQUIRE_THAT " filename = " tests / < exe - name > / UsageTests / MatchersRanges . tests . cpp " > <nl> + < Original > <nl> + c , ! Contains ( 1 ) <nl> + < / Original > <nl> + < Expanded > <nl> + { 4 , 5 , 6 } not contains element 1 <nl> + < / Expanded > <nl> + < / Expression > <nl> + < OverallResults successes = " 3 " failures = " 0 " expectedFailures = " 0 " / > <nl> + < / Section > <nl> + < Section name = " Different argument ranges , same element type , custom comparison " filename = " tests / < exe - name > / UsageTests / MatchersRanges . tests . cpp " > <nl> + < Expression success = " true " type = " REQUIRE_THAT " filename = " tests / < exe - name > / UsageTests / MatchersRanges . tests . cpp " > <nl> + < Original > <nl> + a , Contains ( 0 , close_enough ) <nl> + < / Original > <nl> + < Expanded > <nl> + { 1 , 2 , 3 } contains element 0 <nl> + < / Expanded > <nl> + < / Expression > <nl> + < Expression success = " true " type = " REQUIRE_THAT " filename = " tests / < exe - name > / UsageTests / MatchersRanges . tests . cpp " > <nl> + < Original > <nl> + b , Contains ( 0 , close_enough ) <nl> + < / Original > <nl> + < Expanded > <nl> + { 0 , 1 , 2 } contains element 0 <nl> + < / Expanded > <nl> + < / Expression > <nl> + < Expression success = " true " type = " REQUIRE_THAT " filename = " tests / < exe - name > / UsageTests / MatchersRanges . tests . cpp " > <nl> + < Original > <nl> + c , ! Contains ( 0 , close_enough ) <nl> + < / Original > <nl> + < Expanded > <nl> + { 4 , 5 , 6 } not contains element 0 <nl> + < / Expanded > <nl> + < / Expression > <nl> + < OverallResults successes = " 3 " failures = " 0 " expectedFailures = " 0 " / > <nl> + < / Section > <nl> + < Section name = " Different element type , custom comparisons " filename = " tests / < exe - name > / UsageTests / MatchersRanges . tests . cpp " > <nl> + < Expression success = " true " type = " REQUIRE_THAT " filename = " tests / < exe - name > / UsageTests / MatchersRanges . tests . cpp " > <nl> + < Original > <nl> + a , Contains ( 4 , [ ] ( auto & amp ; & amp ; lhs , size_t sz ) { return lhs . size ( ) = = sz ; } ) <nl> + < / Original > <nl> + < Expanded > <nl> + { " abc " , " abcd " , " abcde " } contains element 4 <nl> + < / Expanded > <nl> + < / Expression > <nl> + < OverallResults successes = " 1 " failures = " 0 " expectedFailures = " 0 " / > <nl> + < / Section > <nl> + < Section name = " Can handle type that requires ADL - found free function begin and end " filename = " tests / < exe - name > / UsageTests / MatchersRanges . tests . cpp " > <nl> + < Expression success = " true " type = " REQUIRE_THAT " filename = " tests / < exe - name > / UsageTests / MatchersRanges . tests . cpp " > <nl> + < Original > <nl> + in , Contains ( 1 ) <nl> + < / Original > <nl> + < Expanded > <nl> + { 1 , 2 , 3 , 4 , 5 } contains element 1 <nl> + < / Expanded > <nl> + < / Expression > <nl> + < Expression success = " true " type = " REQUIRE_THAT " filename = " tests / < exe - name > / UsageTests / MatchersRanges . tests . cpp " > <nl> + < Original > <nl> + in , ! Contains ( 8 ) <nl> + < / Original > <nl> + < Expanded > <nl> + { 1 , 2 , 3 , 4 , 5 } not contains element 8 <nl> + < / Expanded > <nl> + < / Expression > <nl> + < OverallResults successes = " 2 " failures = " 0 " expectedFailures = " 0 " / > <nl> + < / Section > <nl> + < Section name = " Initialization with move only types " filename = " tests / < exe - name > / UsageTests / MatchersRanges . tests . cpp " > <nl> + < Expression success = " true " type = " REQUIRE_THAT " filename = " tests / < exe - name > / UsageTests / MatchersRanges . tests . cpp " > <nl> + < Original > <nl> + in , Contains ( MoveOnlyTestElement { 2 } ) <nl> + < / Original > <nl> + < Expanded > <nl> + { 1 , 2 , 3 } contains element 2 <nl> + < / Expanded > <nl> + < / Expression > <nl> + < Expression success = " true " type = " REQUIRE_THAT " filename = " tests / < exe - name > / UsageTests / MatchersRanges . tests . cpp " > <nl> + < Original > <nl> + in , ! Contains ( MoveOnlyTestElement { 9 } ) <nl> + < / Original > <nl> + < Expanded > <nl> + { 1 , 2 , 3 } not contains element 9 <nl> + < / Expanded > <nl> + < / Expression > <nl> + < OverallResults successes = " 2 " failures = " 0 " expectedFailures = " 0 " / > <nl> + < / Section > <nl> + < Section name = " Matching using matcher " filename = " tests / < exe - name > / UsageTests / MatchersRanges . tests . cpp " > <nl> + < Expression success = " true " type = " REQUIRE_THAT " filename = " tests / < exe - name > / UsageTests / MatchersRanges . tests . cpp " > <nl> + < Original > <nl> + in , Contains ( Catch : : Matchers : : WithinAbs ( 0 . 5 , 0 . 5 ) ) <nl> + < / Original > <nl> + < Expanded > <nl> + { 1 . 0 , 2 . 0 , 3 . 0 , 0 . 0 } contains element matching is within 0 . 5 of 0 . 5 <nl> + < / Expanded > <nl> + < / Expression > <nl> + < OverallResults successes = " 1 " failures = " 0 " expectedFailures = " 0 " / > <nl> + < / Section > <nl> + < OverallResult success = " true " / > <nl> + < / TestCase > <nl> < TestCase name = " CAPTURE can deal with complex expressions " tags = " [ capture ] [ messages ] " filename = " tests / < exe - name > / UsageTests / Message . tests . cpp " > <nl> < Info > <nl> a : = 1 <nl> loose text artifact <nl> < / Section > <nl> < OverallResult success = " true " / > <nl> < / TestCase > <nl> - < OverallResults successes = " 1687 " failures = " 149 " expectedFailures = " 21 " / > <nl> + < OverallResults successes = " 1699 " failures = " 149 " expectedFailures = " 21 " / > <nl> < / Group > <nl> - < OverallResults successes = " 1687 " failures = " 148 " expectedFailures = " 21 " / > <nl> + < OverallResults successes = " 1699 " failures = " 148 " expectedFailures = " 21 " / > <nl> < / Catch > <nl> new file mode 100644 <nl> index 000000000 . . 7cf5590b2 <nl> mmm / dev / null <nl> ppp b / tests / SelfTest / UsageTests / MatchersRanges . tests . cpp <nl> <nl> + / / Distributed under the Boost Software License , Version 1 . 0 . ( See accompanying <nl> + / / file LICENSE_1_0 . txt or copy at http : / / www . boost . org / LICENSE_1_0 . txt ) <nl> + <nl> + # include < catch2 / catch_test_macros . hpp > <nl> + # include < catch2 / matchers / catch_matchers_contains . hpp > <nl> + # include < catch2 / matchers / catch_matchers_floating . hpp > <nl> + <nl> + # include < array > <nl> + # include < cmath > <nl> + # include < list > <nl> + # include < vector > <nl> + <nl> + namespace unrelated { <nl> + class needs_ADL_begin { <nl> + std : : array < int , 5 > elements { { 1 , 2 , 3 , 4 , 5 } } ; <nl> + public : <nl> + using iterator = std : : array < int , 5 > : : iterator ; <nl> + using const_iterator = std : : array < int , 5 > : : const_iterator ; <nl> + <nl> + const_iterator Begin ( ) const { return elements . begin ( ) ; } <nl> + const_iterator End ( ) const { return elements . end ( ) ; } <nl> + <nl> + friend const_iterator begin ( needs_ADL_begin const & lhs ) { <nl> + return lhs . Begin ( ) ; <nl> + } <nl> + friend const_iterator end ( needs_ADL_begin const & rhs ) { <nl> + return rhs . End ( ) ; <nl> + } <nl> + } ; <nl> + } / / end anon namespace <nl> + <nl> + struct MoveOnlyTestElement { <nl> + int num = 0 ; <nl> + MoveOnlyTestElement ( int n ) : num ( n ) { } <nl> + <nl> + MoveOnlyTestElement ( MoveOnlyTestElement & & rhs ) = default ; <nl> + MoveOnlyTestElement & operator = ( MoveOnlyTestElement & & rhs ) = default ; <nl> + <nl> + friend bool operator = = ( MoveOnlyTestElement const & lhs , MoveOnlyTestElement const & rhs ) { <nl> + return lhs . num = = rhs . num ; <nl> + } <nl> + <nl> + friend std : : ostream & operator < < ( std : : ostream & out , MoveOnlyTestElement const & elem ) { <nl> + out < < elem . num ; <nl> + return out ; <nl> + } <nl> + } ; <nl> + <nl> + TEST_CASE ( " Basic use of the Contains range matcher " , " [ matchers ] [ templated ] [ contains ] " ) { <nl> + using Catch : : Matchers : : Contains ; <nl> + <nl> + SECTION ( " Different argument ranges , same element type , default comparison " ) { <nl> + std : : array < int , 3 > a { { 1 , 2 , 3 } } ; <nl> + std : : vector < int > b { 0 , 1 , 2 } ; <nl> + std : : list < int > c { 4 , 5 , 6 } ; <nl> + <nl> + / / A contains 1 <nl> + REQUIRE_THAT ( a , Contains ( 1 ) ) ; <nl> + / / B contains 1 <nl> + REQUIRE_THAT ( b , Contains ( 1 ) ) ; <nl> + / / C does not contain 1 <nl> + REQUIRE_THAT ( c , ! Contains ( 1 ) ) ; <nl> + } <nl> + <nl> + SECTION ( " Different argument ranges , same element type , custom comparison " ) { <nl> + std : : array < int , 3 > a { { 1 , 2 , 3 } } ; <nl> + std : : vector < int > b { 0 , 1 , 2 } ; <nl> + std : : list < int > c { 4 , 5 , 6 } ; <nl> + <nl> + auto close_enough = [ ] ( int lhs , int rhs ) { return std : : abs ( lhs - rhs ) < = 1 ; } ; <nl> + <nl> + / / A contains 1 , which is " close enough " to 0 <nl> + REQUIRE_THAT ( a , Contains ( 0 , close_enough ) ) ; <nl> + / / B contains 0 directly <nl> + REQUIRE_THAT ( b , Contains ( 0 , close_enough ) ) ; <nl> + / / C does not contain anything " close enough " to 0 <nl> + REQUIRE_THAT ( c , ! Contains ( 0 , close_enough ) ) ; <nl> + } <nl> + <nl> + SECTION ( " Different element type , custom comparisons " ) { <nl> + std : : array < std : : string , 3 > a { { " abc " , " abcd " , " abcde " } } ; <nl> + <nl> + REQUIRE_THAT ( a , Contains ( 4 , [ ] ( auto & & lhs , size_t sz ) { <nl> + return lhs . size ( ) = = sz ; <nl> + } ) ) ; <nl> + } <nl> + <nl> + SECTION ( " Can handle type that requires ADL - found free function begin and end " ) { <nl> + unrelated : : needs_ADL_begin in ; <nl> + <nl> + REQUIRE_THAT ( in , Contains ( 1 ) ) ; <nl> + REQUIRE_THAT ( in , ! Contains ( 8 ) ) ; <nl> + } <nl> + <nl> + SECTION ( " Initialization with move only types " ) { <nl> + std : : array < MoveOnlyTestElement , 3 > in { { MoveOnlyTestElement { 1 } , MoveOnlyTestElement { 2 } , MoveOnlyTestElement { 3 } } } ; <nl> + <nl> + REQUIRE_THAT ( in , Contains ( MoveOnlyTestElement { 2 } ) ) ; <nl> + REQUIRE_THAT ( in , ! Contains ( MoveOnlyTestElement { 9 } ) ) ; <nl> + } <nl> + <nl> + SECTION ( " Matching using matcher " ) { <nl> + std : : array < double , 4 > in { { 1 , 2 , 3 } } ; <nl> + <nl> + REQUIRE_THAT ( in , Contains ( Catch : : Matchers : : WithinAbs ( 0 . 5 , 0 . 5 ) ) ) ; <nl> + } <nl> + } <nl>
Add generic Contains matcher
catchorg/Catch2
007efc173a6cf64f625f4b75f40d7f4ebd3c0b34
2020-03-27T09:22:25Z
mmm a / tensorflow / contrib / data / python / ops / dataset_ops . py <nl> ppp b / tensorflow / contrib / data / python / ops / dataset_ops . py <nl> <nl> from tensorflow . python . framework import tensor_shape <nl> from tensorflow . python . ops import gen_io_ops <nl> from tensorflow . python . ops import script_ops <nl> + from tensorflow . python . util import deprecation <nl> <nl> <nl> class Dataset ( dataset_ops . Dataset ) : <nl> def __init__ ( self , dataset ) : <nl> super ( Dataset , self ) . __init__ ( ) <nl> self . _dataset = dataset <nl> <nl> + @ deprecation . deprecated ( None , " Use ` ds . _as_variant_tensor ( ) ` . " ) <nl> def make_dataset_resource ( self ) : <nl> return self . _as_variant_tensor ( ) <nl> <nl> def output_types ( self ) : <nl> return self . _dataset . output_types <nl> <nl> @ staticmethod <nl> + @ deprecation . deprecated ( None , " Use ` tf . data . Dataset . from_tensors ( ) ` . " ) <nl> def from_tensors ( tensors ) : <nl> " " " Creates a ` Dataset ` with a single element , comprising the given tensors . <nl> <nl> def from_tensors ( tensors ) : <nl> return Dataset ( dataset_ops . TensorDataset ( tensors ) ) <nl> <nl> @ staticmethod <nl> + @ deprecation . deprecated ( None , " Use ` tf . data . Dataset . from_tensor_slices ( ) ` . " ) <nl> def from_tensor_slices ( tensors ) : <nl> " " " Creates a ` Dataset ` whose elements are slices of the given tensors . <nl> <nl> def from_tensor_slices ( tensors ) : <nl> return Dataset ( dataset_ops . TensorSliceDataset ( tensors ) ) <nl> <nl> @ staticmethod <nl> + @ deprecation . deprecated ( None , <nl> + " Use ` tf . data . Dataset . from_sparse_tensor_slices ( ) ` . " ) <nl> def from_sparse_tensor_slices ( sparse_tensor ) : <nl> " " " Splits each rank - N ` tf . SparseTensor ` in this dataset row - wise . <nl> <nl> def from_sparse_tensor_slices ( sparse_tensor ) : <nl> return Dataset ( dataset_ops . SparseTensorSliceDataset ( sparse_tensor ) ) <nl> <nl> @ staticmethod <nl> + @ deprecation . deprecated ( None , " Use ` tf . data . Dataset . from_generator ( ) ` . " ) <nl> def from_generator ( generator , output_types , output_shapes = None ) : <nl> " " " Creates a ` Dataset ` whose elements are generated by ` generator ` . <nl> <nl> def flat_map_fn ( iterator_id_t ) : <nl> return id_dataset . flat_map ( flat_map_fn ) <nl> <nl> @ staticmethod <nl> + @ deprecation . deprecated ( None , " Use ` tf . data . Dataset . range ( ) ` . " ) <nl> def range ( * args ) : <nl> " " " Creates a ` Dataset ` of a step - separated range of values . <nl> <nl> def range ( * args ) : <nl> return Dataset ( dataset_ops . RangeDataset ( * args ) ) <nl> <nl> @ staticmethod <nl> + @ deprecation . deprecated ( None , " Use ` tf . data . Dataset . zip ( ) ` . " ) <nl> def zip ( datasets ) : <nl> " " " Creates a ` Dataset ` by zipping together the given datasets . <nl> <nl> def prefetch ( self , buffer_size ) : <nl> return Dataset ( dataset_ops . PrefetchDataset ( self . _dataset , buffer_size ) ) <nl> <nl> @ staticmethod <nl> + @ deprecation . deprecated ( None , " Use ` tf . data . Dataset . list_files ( ) ` . " ) <nl> def list_files ( file_pattern ) : <nl> " " " A dataset of all files matching a pattern . <nl> <nl> def repeat ( self , count = None ) : <nl> " " " <nl> return Dataset ( dataset_ops . RepeatDataset ( self . _dataset , count ) ) <nl> <nl> + @ deprecation . deprecated ( <nl> + None , " Use ` ds . apply ( tf . contrib . data . enumerate_dataset ( ) ) ` . " ) <nl> def enumerate ( self , start = 0 ) : <nl> " " " Deprecated : Use ` Dataset . apply ( tf . contrib . data . enumerate_dataset ( . . ) ` . " " " <nl> <nl> def shard ( self , num_shards , index ) : <nl> " " " <nl> return Dataset ( self . _dataset . shard ( num_shards , index ) ) <nl> <nl> + @ deprecation . deprecated ( <nl> + None , " Use ` ds . apply ( tf . contrib . data . ignore_errors ( ) ) ` . " ) <nl> def ignore_errors ( self ) : <nl> - " " " Deprecated : Use ` Dataset . apply ( tf . contrib . data . ignore_errors ( ) ` . " " " <nl> + " " " Deprecated : Use ` Dataset . apply ( tf . contrib . data . ignore_errors ( ) ) ` . " " " <nl> <nl> return self . apply ( error_ops . ignore_errors ( ) ) <nl> <nl> def padded_batch ( self , batch_size , padded_shapes , padding_values = None ) : <nl> dataset_ops . PaddedBatchDataset ( self . _dataset , batch_size , padded_shapes , <nl> padding_values ) ) <nl> <nl> + @ deprecation . deprecated ( <nl> + None , " Use ` ds . apply ( tf . contrib . data . dense_to_sparse_batch ( ) ) ` . " ) <nl> def dense_to_sparse_batch ( self , batch_size , row_shape ) : <nl> " " " Use : ` Dataset . apply ( tf . contrib . data . dense_to_sparse_batch ( . . . ) ) ` . " " " <nl> <nl> return self . apply ( batching . dense_to_sparse_batch ( batch_size , row_shape ) ) <nl> <nl> + @ deprecation . deprecated ( <nl> + None , " Use ` ds . apply ( tf . contrib . data . group_by_window ( ) ) ` . " ) <nl> def group_by_window ( self , key_func , reduce_func , window_size ) : <nl> " " " Deprecated : Use ` Dataset . apply ( tf . contrib . data . group_by_window ( . . . ) ) ` . " " " <nl> <nl> return self . apply ( <nl> grouping . group_by_window ( key_func , reduce_func , window_size ) ) <nl> <nl> + @ deprecation . deprecated_args ( <nl> + None , <nl> + " Replace ` num_threads = T ` with ` num_parallel_calls = T ` . Replace " <nl> + " ` output_buffer_size = N ` with ` ds . prefetch ( N ) ` on the returned dataset . " , <nl> + " num_threads " , " output_buffer_size " ) <nl> def map ( self , <nl> map_func , <nl> num_threads = None , <nl> def interleave ( self , map_func , cycle_length , block_length = 1 ) : <nl> dataset_ops . InterleaveDataset ( self . _dataset , map_func , cycle_length , <nl> block_length ) ) <nl> <nl> + @ deprecation . deprecated ( None , " Use ` ds . apply ( tf . contrib . data . unbatch ( ) ) ` . " ) <nl> def unbatch ( self ) : <nl> " " " Deprecated : Use ` Dataset . apply ( tf . contrib . data . unbatch ( ) ` . " " " <nl> <nl> mmm a / tensorflow / contrib / data / python / ops / readers . py <nl> ppp b / tensorflow / contrib / data / python / ops / readers . py <nl> <nl> from tensorflow . python . ops import gen_dataset_ops <nl> from tensorflow . python . ops import parsing_ops <nl> from tensorflow . python . platform import gfile <nl> + from tensorflow . python . util import deprecation <nl> <nl> <nl> class TextLineDataset ( contrib_dataset_ops . Dataset ) : <nl> " " " A ` Dataset ` comprising lines from one or more text files . " " " <nl> <nl> + @ deprecation . deprecated ( None , " Use ` tf . data . TextLineDataset ` . " ) <nl> def __init__ ( self , filenames , compression_type = None , buffer_size = None ) : <nl> " " " Creates a ` TextLineDataset ` . <nl> <nl> def __init__ ( self , filenames , compression_type = None , buffer_size = None ) : <nl> class TFRecordDataset ( contrib_dataset_ops . Dataset ) : <nl> " " " A ` Dataset ` comprising records from one or more TFRecord files . " " " <nl> <nl> + @ deprecation . deprecated ( None , " Use ` tf . data . TFRecordDataset ` . " ) <nl> def __init__ ( self , filenames , compression_type = None , buffer_size = None ) : <nl> " " " Creates a ` TFRecordDataset ` . <nl> <nl> def __init__ ( self , filenames , compression_type = None , buffer_size = None ) : <nl> class FixedLengthRecordDataset ( contrib_dataset_ops . Dataset ) : <nl> " " " A ` Dataset ` of fixed - length records from one or more binary files . " " " <nl> <nl> + @ deprecation . deprecated ( None , " Use ` tf . data . FixedLengthRecordDataset ` . " ) <nl> def __init__ ( self , <nl> filenames , <nl> record_bytes , <nl>
[ tf . contrib . data ] Add deprecation decorators to deprecated methods .
tensorflow/tensorflow
b229b0634c1268a8cd1953d02c23150284f1da4c
2017-10-03T02:24:54Z
mmm a / src / mips / assembler - mips . cc <nl> ppp b / src / mips / assembler - mips . cc <nl> void Assembler : : lsa ( Register rd , Register rt , Register rs , uint8_t sa ) { <nl> / / Helper for base - reg + offset , when offset is larger than int16 . <nl> void Assembler : : LoadRegPlusOffsetToAt ( const MemOperand & src ) { <nl> DCHECK ( ! src . rm ( ) . is ( at ) ) ; <nl> - lui ( at , ( src . offset_ > > kLuiShift ) & kImm16Mask ) ; <nl> - ori ( at , at , src . offset_ & kImm16Mask ) ; / / Load 32 - bit offset . <nl> - addu ( at , at , src . rm ( ) ) ; / / Add base register . <nl> + if ( IsMipsArchVariant ( kMips32r6 ) ) { <nl> + int32_t hi = ( src . offset_ > > kLuiShift ) & kImm16Mask ; <nl> + if ( src . offset_ & kNegOffset ) { <nl> + hi + = 1 ; <nl> + } <nl> + aui ( at , src . rm ( ) , hi ) ; <nl> + addiu ( at , at , src . offset_ & kImm16Mask ) ; <nl> + } else { <nl> + lui ( at , ( src . offset_ > > kLuiShift ) & kImm16Mask ) ; <nl> + ori ( at , at , src . offset_ & kImm16Mask ) ; / / Load 32 - bit offset . <nl> + addu ( at , at , src . rm ( ) ) ; / / Add base register . <nl> + } <nl> } <nl> <nl> / / Helper for base - reg + upper part of offset , when offset is larger than int16 . <nl> int32_t Assembler : : LoadRegPlusUpperOffsetPartToAt ( const MemOperand & src ) { <nl> if ( src . offset_ & kNegOffset ) { <nl> hi + = 1 ; <nl> } <nl> - lui ( at , hi ) ; <nl> - addu ( at , at , src . rm ( ) ) ; <nl> + <nl> + if ( IsMipsArchVariant ( kMips32r6 ) ) { <nl> + aui ( at , src . rm ( ) , hi ) ; <nl> + } else { <nl> + lui ( at , hi ) ; <nl> + addu ( at , at , src . rm ( ) ) ; <nl> + } <nl> return ( src . offset_ & kImm16Mask ) ; <nl> } <nl> <nl> mmm a / src / mips64 / assembler - mips64 . cc <nl> ppp b / src / mips64 / assembler - mips64 . cc <nl> void Assembler : : dlsa ( Register rd , Register rt , Register rs , uint8_t sa ) { <nl> void Assembler : : LoadRegPlusOffsetToAt ( const MemOperand & src ) { <nl> DCHECK ( ! src . rm ( ) . is ( at ) ) ; <nl> DCHECK ( is_int32 ( src . offset_ ) ) ; <nl> - lui ( at , ( src . offset_ > > kLuiShift ) & kImm16Mask ) ; <nl> - ori ( at , at , src . offset_ & kImm16Mask ) ; / / Load 32 - bit offset . <nl> - daddu ( at , at , src . rm ( ) ) ; / / Add base register . <nl> + <nl> + if ( kArchVariant = = kMips64r6 ) { <nl> + int32_t hi = ( src . offset_ > > kLuiShift ) & kImm16Mask ; <nl> + if ( src . offset_ & kNegOffset ) { <nl> + if ( ( hi & kNegOffset ) ! = ( ( hi + 1 ) & kNegOffset ) ) { <nl> + lui ( at , ( src . offset_ > > kLuiShift ) & kImm16Mask ) ; <nl> + ori ( at , at , src . offset_ & kImm16Mask ) ; / / Load 32 - bit offset . <nl> + daddu ( at , at , src . rm ( ) ) ; / / Add base register . <nl> + return ; <nl> + } <nl> + <nl> + hi + = 1 ; <nl> + } <nl> + <nl> + daui ( at , src . rm ( ) , hi ) ; <nl> + daddiu ( at , at , src . offset_ & kImm16Mask ) ; <nl> + } else { <nl> + lui ( at , ( src . offset_ > > kLuiShift ) & kImm16Mask ) ; <nl> + ori ( at , at , src . offset_ & kImm16Mask ) ; / / Load 32 - bit offset . <nl> + daddu ( at , at , src . rm ( ) ) ; / / Add base register . <nl> + } <nl> } <nl> <nl> / / Helper for base - reg + upper part of offset , when offset is larger than int16 . <nl> int32_t Assembler : : LoadRegPlusUpperOffsetPartToAt ( const MemOperand & src ) { <nl> hi + = 1 ; <nl> } <nl> <nl> - lui ( at , hi ) ; <nl> - daddu ( at , at , src . rm ( ) ) ; <nl> + if ( kArchVariant = = kMips64r6 ) { <nl> + daui ( at , src . rm ( ) , hi ) ; <nl> + } else { <nl> + lui ( at , hi ) ; <nl> + daddu ( at , at , src . rm ( ) ) ; <nl> + } <nl> return ( src . offset_ & kImm16Mask ) ; <nl> } <nl> <nl>
MIPS : Optimize load / store with large offset on MIPSr6
v8/v8
51159360d48b7871dd1e049581eee92a4844842a
2016-12-01T13:10:43Z
mmm a / dbms / src / IO / WriteHelpers . h <nl> ppp b / dbms / src / IO / WriteHelpers . h <nl> inline void writeBoolText ( bool x , WriteBuffer & buf ) <nl> template < typename T > <nl> inline size_t writeFloatTextFastPath ( T x , char * buffer ) <nl> { <nl> + if ( x = = 0 ) <nl> + { <nl> + buffer [ 0 ] = ' 0 ' ; <nl> + return 1 ; <nl> + } <nl> + <nl> int result = 0 ; <nl> if constexpr ( std : : is_same_v < T , double > ) <nl> - result = d2s_buffered_n ( x , buffer ) ; <nl> + { <nl> + / / / Ryu library cannot automatically decide between plain and exponential representation . <nl> + / / / We have to do it by ourself . <nl> + <nl> + uint16_t exponent = ( unalignedLoad < uint16_t > ( & x ) & 0b0111111111110000 ) > > 4 ; <nl> + if ( exponent > = 0x3F - 10 & & exponent < = 0x3F + 64 ) <nl> + { <nl> + result = d2fixed_buffered_n ( x , 16 , buffer ) ; <nl> + } <nl> + else if ( unlikely ( exponent = = 0xFFF ) ) <nl> + { <nl> + / / / Ryu library prints inf / nans in slightly different way ( as Infinity and NaN ) . <nl> + / / / This is technically Ok and we can parse these representation back , <nl> + / / / but to maintain compatibility and save space , better to write as inf and nan . <nl> + <nl> + uint64_t mantissa = unalignedLoad < uint64_t > ( & x ) & 0b0000000000001111111111111111111111111111111111111111111111111111ul ; <nl> + if ( mantissa = = 0 ) <nl> + { <nl> + if ( x > 0 ) <nl> + { <nl> + memcpy ( buffer , " inf " , 3 ) ; <nl> + return 3 ; <nl> + } <nl> + else <nl> + { <nl> + memcpy ( buffer , " - inf " , 4 ) ; <nl> + return 4 ; <nl> + } <nl> + } <nl> + else <nl> + { <nl> + memcpy ( buffer , " nan " , 3 ) ; <nl> + return 3 ; <nl> + } <nl> + } <nl> + else <nl> + { <nl> + result = d2s_buffered_n ( x , buffer ) ; <nl> + } <nl> + } <nl> else <nl> - result = f2s_buffered_n ( x , buffer ) ; <nl> + { <nl> + uint16_t exponent = ( unalignedLoad < uint16_t > ( x ) & 0b0111111110000000 ) > > 7 ; <nl> + if ( exponent > = 0x3F - 10 & & exponent < = 0x3F + 64 ) <nl> + { <nl> + result = f2fixed_buffered_n ( x , 8 , buffer ) ; <nl> + } <nl> + else if ( unlikely ( exponent = = 0xFF ) ) <nl> + { <nl> + uint64_t mantissa = unalignedLoad < uint32_t > ( x ) & 0b00000000011111111111111111111111u ; <nl> + if ( mantissa = = 0 ) <nl> + { <nl> + if ( x > 0 ) <nl> + { <nl> + memcpy ( buffer , " inf " , 3 ) ; <nl> + return 3 ; <nl> + } <nl> + else <nl> + { <nl> + memcpy ( buffer , " - inf " , 4 ) ; <nl> + return 4 ; <nl> + } <nl> + } <nl> + else <nl> + { <nl> + memcpy ( buffer , " nan " , 3 ) ; <nl> + return 3 ; <nl> + } <nl> + } <nl> + else <nl> + result = f2s_buffered_n ( x , buffer ) ; <nl> + } <nl> <nl> if ( result < = 0 ) <nl> throw Exception ( " Cannot print floating point number " , ErrorCodes : : CANNOT_PRINT_FLOAT_OR_DOUBLE_NUMBER ) ; <nl>
Attempt to make usage of Ryu library compatible
ClickHouse/ClickHouse
bc138d272b6a1a2cc40ec7bdc39c3e0237ba2584
2020-01-06T06:17:50Z
mmm a / tensorflow / core / common_runtime / eager / execute_node . cc <nl> ppp b / tensorflow / core / common_runtime / eager / execute_node . cc <nl> Status ExecuteNodeArgs : : Init ( <nl> / / overwritten during kernel execution . The reference count is incremented <nl> / / below when we insert a copy of the Tensor into protected_tensors , and will <nl> / / be decremented once execution is complete . <nl> - int first_index_that_needs_protecting = - 1 ; <nl> - for ( int i = 0 ; i < op_inputs . size ( ) ; + + i ) { <nl> - TensorHandle * in = op_inputs [ i ] ; <nl> - if ( ! in - > IsRemote ( ) ) { <nl> - TF_RETURN_IF_ERROR ( in - > TensorValue ( & tensor_args_ [ i ] ) ) ; <nl> - if ( first_index_that_needs_protecting < 0 & & ! in - > RefCountIsOne ( ) ) { <nl> - first_index_that_needs_protecting = i ; <nl> - } <nl> - } else { <nl> - if ( ! has_remote_inputs_ ) { <nl> - has_remote_inputs_ = true ; <nl> + const int n_inputs = op_inputs . size ( ) ; <nl> + gtl : : InlinedVector < TensorValue , 4 > input_vector ( n_inputs ) ; <nl> + int first_index_that_needs_protecting = - 1 ; / / Used to avoid second loop <nl> + if ( n_inputs > 0 ) { <nl> + TensorHandle * const * op_inputs_array = & op_inputs [ 0 ] ; <nl> + TensorValue * tensor_args_array = & tensor_args_ [ 0 ] ; <nl> + for ( int i = 0 ; i < n_inputs ; + + i ) { <nl> + TensorHandle * in = op_inputs_array [ i ] ; <nl> + if ( ! in - > IsRemote ( ) ) { <nl> + TF_RETURN_IF_ERROR ( in - > TensorValue ( & tensor_args_array [ i ] ) ) ; <nl> + if ( first_index_that_needs_protecting < 0 & & ! in - > RefCountIsOne ( ) ) { <nl> + first_index_that_needs_protecting = i ; <nl> + } <nl> + } else { <nl> + if ( ! has_remote_inputs_ ) { <nl> + has_remote_inputs_ = true ; <nl> + } <nl> } <nl> } <nl> - } <nl> <nl> - if ( first_index_that_needs_protecting > = 0 ) { <nl> - for ( int i = first_index_that_needs_protecting ; i < op_inputs . size ( ) ; + + i ) { <nl> - TensorHandle * in = op_inputs [ i ] ; <nl> - if ( ! in - > IsRemote ( ) & & ! in - > RefCountIsOne ( ) ) { <nl> - const Tensor * input_tensor = nullptr ; <nl> - TF_RETURN_IF_ERROR ( op_inputs [ i ] - > Tensor ( & input_tensor ) ) ; <nl> - protected_tensors_ . emplace_back ( TensorReference ( * input_tensor ) ) ; <nl> + if ( first_index_that_needs_protecting > = 0 ) { <nl> + for ( int i = first_index_that_needs_protecting ; i < n_inputs ; + + i ) { <nl> + TensorHandle * in = op_inputs_array [ i ] ; <nl> + if ( ! in - > IsRemote ( ) & & ! in - > RefCountIsOne ( ) ) { <nl> + const Tensor * input_tensor = nullptr ; <nl> + TF_RETURN_IF_ERROR ( op_inputs_array [ i ] - > Tensor ( & input_tensor ) ) ; <nl> + protected_tensors_ . emplace_back ( TensorReference ( * input_tensor ) ) ; <nl> + } <nl> } <nl> } <nl> } <nl>
Use C array ops instead of operator [ ]
tensorflow/tensorflow
68969accd845aab50bcd4b629903e604b1b60559
2019-11-15T01:14:18Z
mmm a / js / client / tests / shell - fm . js <nl> ppp b / js / client / tests / shell - fm . js <nl> function FoxxManagerSuite ( ) { <nl> <nl> for ( version in entry . versions ) { <nl> if ( entry . versions . hasOwnProperty ( version ) ) { <nl> - assertMatch ( / ^ \ d + ( \ . \ d + ) * $ / , version ) ; <nl> + assertMatch ( / ^ \ d + ( \ . \ d + ) * ( - . * ) ? $ / , version ) ; <nl> assertTrue ( entry . versions [ version ] . hasOwnProperty ( " type " ) ) ; <nl> assertTrue ( entry . versions [ version ] . hasOwnProperty ( " location " ) ) ; <nl> } <nl> function FoxxManagerSuite ( ) { <nl> } , <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief test search existings <nl> + / / / @ brief test search existing app <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> testSearchAztec : function ( ) { <nl> function FoxxManagerSuite ( ) { <nl> / / validate the results structure , simply take the first match <nl> var entry = result . pop ( ) ; <nl> <nl> - assertEqual ( " jsteemann " , entry . author ) ; <nl> + assertEqual ( " Jan Steemann " , entry . author ) ; <nl> assertEqual ( " itzpapalotl " , entry . name ) ; <nl> } , <nl> <nl>
fixed test
arangodb/arangodb
de896edb5bdc91089fe92fa93017e2aa22ce276d
2015-09-14T22:16:26Z
mmm a / lib / AST / Module . cpp <nl> ppp b / lib / AST / Module . cpp <nl> SourceFile : : collectLinkLibraries ( ModuleDecl : : LinkLibraryCallback callback ) const <nl> llvm : : SmallDenseSet < ModuleDecl * , 32 > visited ; <nl> SmallVector < ModuleDecl : : ImportedModule , 32 > stack ; <nl> <nl> - ModuleDecl : : ImportFilter filter = ModuleDecl : : ImportFilterKind : : Public ; <nl> - filter | = ModuleDecl : : ImportFilterKind : : Private ; <nl> - filter | = ModuleDecl : : ImportFilterKind : : SPIAccessControl ; <nl> + ModuleDecl : : ImportFilter filter = { <nl> + ModuleDecl : : ImportFilterKind : : Public , <nl> + ModuleDecl : : ImportFilterKind : : Private , <nl> + ModuleDecl : : ImportFilterKind : : SPIAccessControl } ; <nl> <nl> auto * topLevel = getParentModule ( ) ; <nl> <nl> mmm a / lib / Frontend / ModuleInterfaceSupport . cpp <nl> ppp b / lib / Frontend / ModuleInterfaceSupport . cpp <nl> static void printImports ( raw_ostream & out , <nl> ModuleDecl * M ) { <nl> / / FIXME : This is very similar to what ' s in Serializer : : writeInputBlock , but <nl> / / it ' s not obvious what higher - level optimization would be factored out here . <nl> - ModuleDecl : : ImportFilter allImportFilter ; <nl> - allImportFilter | = ModuleDecl : : ImportFilterKind : : Public ; <nl> - allImportFilter | = ModuleDecl : : ImportFilterKind : : Private ; <nl> - allImportFilter | = ModuleDecl : : ImportFilterKind : : SPIAccessControl ; <nl> + ModuleDecl : : ImportFilter allImportFilter = { <nl> + ModuleDecl : : ImportFilterKind : : Public , <nl> + ModuleDecl : : ImportFilterKind : : Private , <nl> + ModuleDecl : : ImportFilterKind : : SPIAccessControl } ; <nl> <nl> / / With - experimental - spi - imports : <nl> / / When printing the private swiftinterface file , print implementation - only <nl>
Refactor construction of ` ModuleDecl : : ImportFilter ` s to use new initializer list constructor ( )
apple/swift
96587bc2d4d0bcafee60ba60cb23e4466ff43fb9
2020-08-01T21:24:44Z
mmm a / emcc <nl> ppp b / emcc <nl> Options that are modified or new in % s include : <nl> will by default generate an output name ' dir / a . o ' , <nl> but this cmdline param can be passed to generate a <nl> file with a custom suffix ' dir / a . ext ' . <nl> + - - valid_abspath path Whitelist an absolute path to prevent warnings about <nl> + absolute include paths . <nl> <nl> The target file , if specified ( - o < target > ) , defines what will <nl> be generated : <nl> else : <nl> def in_temp ( name ) : <nl> return os . path . join ( temp_dir , os . path . basename ( name ) ) <nl> <nl> + def in_directory ( root , child ) : <nl> + # make both path absolute <nl> + root = os . path . realpath ( root ) <nl> + child = os . path . realpath ( child ) <nl> + <nl> + # return true , if the common prefix of both is equal to directory <nl> + # e . g . / a / b / c / d . rst and directory is / a / b , the common prefix is / a / b <nl> + return os . path . commonprefix ( [ root , child ] ) = = root <nl> + <nl> # Parses the essential suffix of a filename , discarding Unix - style version numbers in the name . For example for ' libz . so . 1 . 2 . 8 ' returns ' . so ' <nl> def filename_type_suffix ( filename ) : <nl> for i in reversed ( filename . split ( ' . ' ) [ 1 : ] ) : <nl> try : <nl> no_heap_copy = False <nl> proxy_to_worker = False <nl> default_object_extension = ' . o ' <nl> + valid_abspaths = [ ] <nl> + <nl> + def is_valid_abspath ( path_name ) : <nl> + for valid_abspath in valid_abspaths : <nl> + if in_directory ( valid_abspath , path_name ) : <nl> + return True <nl> + return False <nl> + <nl> <nl> if use_cxx : <nl> default_cxx_std = ' - std = c + + 03 ' # Enforce a consistent C + + standard when compiling . cpp files , if user does not specify one on the cmdline . <nl> try : <nl> elif newargs [ i ] = = ' - - proxy - to - worker ' : <nl> proxy_to_worker = True <nl> newargs [ i ] = ' ' <nl> + elif newargs [ i ] = = ' - - valid - abspath ' : <nl> + valid_abspaths . append ( newargs [ i + 1 ] ) <nl> + newargs [ i ] = ' ' <nl> + newargs [ i + 1 ] = ' ' <nl> elif newargs [ i ] . startswith ( ( ' - I ' , ' - L ' ) ) : <nl> path_name = newargs [ i ] [ 2 : ] <nl> - if not absolute_warning_shown and os . path . isabs ( path_name ) : <nl> + if not absolute_warning_shown and os . path . isabs ( path_name ) and not is_valid_abspath ( path_name ) : <nl> logging . warning ( ' - I or - L of an absolute path " ' + newargs [ i ] + ' " encountered . If this is to a local system header / library , it may cause problems ( local system files make sense for compiling natively on your system , but not necessarily to JavaScript ) . Pass \ ' - Wno - warn - absolute - paths \ ' to emcc to hide this warning . ' ) # Of course an absolute path to a non - system - specific library or header is fine , and you can ignore this warning . The danger are system headers that are e . g . x86 specific and nonportable . The emscripten bundled headers are modified to be portable , local system ones are generally not <nl> absolute_warning_shown = True <nl> elif newargs [ i ] = = ' - - emrun ' : <nl> mmm a / tests / test_other . py <nl> ppp b / tests / test_other . py <nl> def test_bad_triple ( self ) : <nl> out , err = Popen ( [ PYTHON , EMCC , ' a . bc ' ] , stdout = PIPE , stderr = PIPE ) . communicate ( ) <nl> assert ' warning ' in err , err <nl> assert ' incorrect target triple ' in err , err <nl> + <nl> + def test_valid_abspath ( self ) : <nl> + # Test whether abspath warning appears <nl> + abs_include_path = path_from_root ( ' tests ' ) <nl> + process = Popen ( [ PYTHON , EMCC , ' - I % s ' % abs_include_path , path_from_root ( ' tests ' , ' hello_world . c ' ) ] , stdout = PIPE , stderr = PIPE ) <nl> + out , err = process . communicate ( ) <nl> + warning = ' - I or - L of an absolute path " - I % s " encountered . If this is to a local system header / library , it may cause problems ( local system files make sense for compiling natively on your system , but not necessarily to JavaScript ) . Pass \ ' - Wno - warn - absolute - paths \ ' to emcc to hide this warning . ' % abs_include_path <nl> + assert ( warning in err ) <nl> + <nl> + # Hide warning for this include path <nl> + process = Popen ( [ PYTHON , EMCC , ' - - valid - abspath ' , abs_include_path , ' - I % s ' % abs_include_path , path_from_root ( ' tests ' , ' hello_world . c ' ) ] , stdout = PIPE , stderr = PIPE ) <nl> + out , err = process . communicate ( ) <nl> + assert ( warning not in err ) <nl> <nl> def test_simplify_ifs ( self ) : <nl> def test ( src , nums ) : <nl> mmm a / tools / shared . py <nl> ppp b / tools / shared . py <nl> def get_llvm_target ( ) : <nl> if USE_EMSDK : <nl> # Disable system C and C + + include directories , and add our own ( using - idirafter so they are last , like system dirs , which <nl> # allows projects to override them ) <nl> - EMSDK_OPTS = [ ' - nostdinc ' , ' - Xclang ' , ' - nobuiltininc ' , ' - Xclang ' , ' - nostdsysteminc ' , <nl> - ' - Xclang ' , ' - isystem ' + path_from_root ( ' system ' , ' local ' , ' include ' ) , <nl> - ' - Xclang ' , ' - isystem ' + path_from_root ( ' system ' , ' include ' , ' compat ' ) , <nl> - ' - Xclang ' , ' - isystem ' + path_from_root ( ' system ' , ' include ' , ' libcxx ' ) , <nl> - ' - Xclang ' , ' - isystem ' + path_from_root ( ' system ' , ' include ' ) , <nl> - ' - Xclang ' , ' - isystem ' + path_from_root ( ' system ' , ' include ' , ' emscripten ' ) , <nl> - ' - Xclang ' , ' - isystem ' + path_from_root ( ' system ' , ' include ' , ' bsd ' ) , # posix stuff <nl> - ' - Xclang ' , ' - isystem ' + path_from_root ( ' system ' , ' include ' , ' libc ' ) , <nl> - ' - Xclang ' , ' - isystem ' + path_from_root ( ' system ' , ' include ' , ' gfx ' ) , <nl> - ' - Xclang ' , ' - isystem ' + path_from_root ( ' system ' , ' include ' , ' net ' ) , <nl> - ' - Xclang ' , ' - isystem ' + path_from_root ( ' system ' , ' include ' , ' SDL ' ) , <nl> + C_INCLUDE_PATHS = [ path_from_root ( ' system ' , ' local ' , ' include ' ) , <nl> + path_from_root ( ' system ' , ' include ' , ' compat ' ) , <nl> + path_from_root ( ' system ' , ' include ' ) , <nl> + path_from_root ( ' system ' , ' include ' , ' emscripten ' ) , <nl> + path_from_root ( ' system ' , ' include ' , ' bsd ' ) , # posix stuff <nl> + path_from_root ( ' system ' , ' include ' , ' libc ' ) , <nl> + path_from_root ( ' system ' , ' include ' , ' gfx ' ) , <nl> + path_from_root ( ' system ' , ' include ' , ' net ' ) , <nl> + path_from_root ( ' system ' , ' include ' , ' SDL ' ) , <nl> ] <nl> + <nl> + CXX_INCLUDE_PATHS = [ path_from_root ( ' system ' , ' include ' , ' libcxx ' ) <nl> + ] <nl> + <nl> + C_OPTS = [ ' - nostdinc ' , ' - Xclang ' , ' - nobuiltininc ' , ' - Xclang ' , ' - nostdsysteminc ' , <nl> + ] <nl> + <nl> + def include_directive ( paths ) : <nl> + result = [ ] <nl> + for path in paths : <nl> + result + = [ ' - Xclang ' , ' - isystem ' + path ] <nl> + return result <nl> + <nl> + EMSDK_OPTS = C_OPTS + include_directive ( C_INCLUDE_PATHS ) + include_directive ( CXX_INCLUDE_PATHS ) <nl> + <nl> EMSDK_OPTS + = COMPILER_STANDARDIZATION_OPTS <nl> # For temporary compatibility , treat ' le32 - unknown - nacl ' as ' asmjs - unknown - emscripten ' . <nl> if LLVM_TARGET ! = ' asmjs - unknown - emscripten ' and \ <nl>
Merge pull request from abergmeier / empkg_prerequisites
emscripten-core/emscripten
3d4319101722c40d37d5b104777de3eb4d1a03e3
2014-04-03T20:09:48Z
mmm a / src / base / macros . h <nl> ppp b / src / base / macros . h <nl> <nl> ( reinterpret_cast < intptr_t > ( & ( reinterpret_cast < type * > ( 4 ) - > field ) ) - 4 ) <nl> <nl> <nl> - / / The arraysize ( arr ) macro returns the # of elements in an array arr . <nl> - / / The expression is a compile - time constant , and therefore can be <nl> - / / used in defining new arrays , for example . If you use arraysize on <nl> - / / a pointer by mistake , you will get a compile - time error . <nl> - / / <nl> - / / One caveat is that arraysize ( ) doesn ' t accept any array of an <nl> - / / anonymous type or a type defined inside a function . In these rare <nl> - / / cases , you have to use the unsafe ARRAYSIZE_UNSAFE ( ) macro below . This is <nl> - / / due to a limitation in C + + ' s template system . The limitation might <nl> - / / eventually be removed , but it hasn ' t happened yet . <nl> - # define arraysize ( array ) ( sizeof ( ArraySizeHelper ( array ) ) ) <nl> - <nl> - <nl> - / / This template function declaration is used in defining arraysize . <nl> - / / Note that the function doesn ' t need an implementation , as we only <nl> - / / use its type . <nl> - template < typename T , size_t N > <nl> - char ( & ArraySizeHelper ( T ( & array ) [ N ] ) ) [ N ] ; <nl> - <nl> - <nl> - # if V8_CC_GNU <nl> - / / That gcc wants both of these prototypes seems mysterious . VC , for <nl> - / / its part , can ' t decide which to use ( another mystery ) . Matching of <nl> - / / template overloads : the final frontier . <nl> - template < typename T , size_t N > <nl> - char ( & ArraySizeHelper ( const T ( & array ) [ N ] ) ) [ N ] ; <nl> - # endif <nl> - <nl> - <nl> / / ARRAYSIZE_UNSAFE performs essentially the same calculation as arraysize , <nl> / / but can be used on anonymous types or types defined inside <nl> / / functions . It ' s less safe than arraysize as it accepts some <nl> char ( & ArraySizeHelper ( const T ( & array ) [ N ] ) ) [ N ] ; <nl> static_cast < size_t > ( ! ( sizeof ( a ) % sizeof ( * ( a ) ) ) ) ) / / NOLINT <nl> <nl> <nl> + # if V8_OS_NACL <nl> + <nl> + / / TODO ( bmeurer ) : For some reason , the NaCl toolchain cannot handle the correct <nl> + / / definition of arraysize ( ) below , so we have to use the unsafe version for <nl> + / / now . <nl> + # define arraysize ARRAYSIZE_UNSAFE <nl> + <nl> + # else / / V8_OS_NACL <nl> + <nl> + / / The arraysize ( arr ) macro returns the # of elements in an array arr . <nl> + / / The expression is a compile - time constant , and therefore can be <nl> + / / used in defining new arrays , for example . If you use arraysize on <nl> + / / a pointer by mistake , you will get a compile - time error . <nl> + / / <nl> + / / One caveat is that arraysize ( ) doesn ' t accept any array of an <nl> + / / anonymous type or a type defined inside a function . In these rare <nl> + / / cases , you have to use the unsafe ARRAYSIZE_UNSAFE ( ) macro below . This is <nl> + / / due to a limitation in C + + ' s template system . The limitation might <nl> + / / eventually be removed , but it hasn ' t happened yet . <nl> + # define arraysize ( array ) ( sizeof ( ArraySizeHelper ( array ) ) ) <nl> + <nl> + <nl> + / / This template function declaration is used in defining arraysize . <nl> + / / Note that the function doesn ' t need an implementation , as we only <nl> + / / use its type . <nl> + template < typename T , size_t N > <nl> + char ( & ArraySizeHelper ( T ( & array ) [ N ] ) ) [ N ] ; <nl> + <nl> + <nl> + # if ! V8_CC_MSVC <nl> + / / That gcc wants both of these prototypes seems mysterious . VC , for <nl> + / / its part , can ' t decide which to use ( another mystery ) . Matching of <nl> + / / template overloads : the final frontier . <nl> + template < typename T , size_t N > <nl> + char ( & ArraySizeHelper ( const T ( & array ) [ N ] ) ) [ N ] ; <nl> + # endif <nl> + <nl> + # endif / / V8_OS_NACL <nl> + <nl> + <nl> / / A macro to disallow the evil copy constructor and operator = functions <nl> / / This should be used in the private : declarations for a class <nl> # define DISALLOW_COPY_AND_ASSIGN ( TypeName ) \ <nl> mmm a / src / serialize . cc <nl> ppp b / src / serialize . cc <nl> void ExternalReferenceTable : : PopulateTable ( Isolate * isolate ) { <nl> # undef IC_ENTRY <nl> } ; / / end of ref_table [ ] . <nl> <nl> - for ( size_t i = 0 ; i < ARRAYSIZE_UNSAFE ( ref_table ) ; + + i ) { <nl> + for ( size_t i = 0 ; i < arraysize ( ref_table ) ; + + i ) { <nl> AddFromId ( ref_table [ i ] . type , <nl> ref_table [ i ] . id , <nl> ref_table [ i ] . name , <nl> void ExternalReferenceTable : : PopulateTable ( Isolate * isolate ) { <nl> } ; / / end of stats_ref_table [ ] . <nl> <nl> Counters * counters = isolate - > counters ( ) ; <nl> - for ( size_t i = 0 ; i < ARRAYSIZE_UNSAFE ( stats_ref_table ) ; + + i ) { <nl> + for ( size_t i = 0 ; i < arraysize ( stats_ref_table ) ; + + i ) { <nl> Add ( reinterpret_cast < Address > ( GetInternalPointer ( <nl> ( counters - > * ( stats_ref_table [ i ] . counter ) ) ( ) ) ) , <nl> STATS_COUNTER , <nl>
Next attempt to fix NaCl build .
v8/v8
630a8a703828ea6d05abfca774a4e2b8a3d6646b
2014-08-26T10:29:51Z
mmm a / Code / Sandbox / Plugins / DependencyGraph / GraphView . cpp <nl> ppp b / Code / Sandbox / Plugins / DependencyGraph / GraphView . cpp <nl> void CGraphView : : OnContextMenuEntryClicked ( CAbstractDictionaryEntry & entry ) <nl> } <nl> } <nl> <nl> + void CGraphView : : closeEvent ( QCloseEvent * pEvent ) <nl> + { <nl> + pEvent - > accept ( ) ; <nl> + SetModel ( nullptr ) ; <nl> + } <nl> + <nl> CAssetWidget : : CAssetWidget ( CAssetNodeBase & item , CryGraphEditor : : CNodeGraphView & view ) <nl> : CryGraphEditor : : CNodeWidget ( item , view ) <nl> { <nl> mmm a / Code / Sandbox / Plugins / DependencyGraph / GraphView . h <nl> ppp b / Code / Sandbox / Plugins / DependencyGraph / GraphView . h <nl> class CGraphView : public CryGraphEditor : : CNodeGraphView <nl> virtual bool PopulateNodeContextMenu ( CryGraphEditor : : CAbstractNodeItem & node , QMenu & menu ) override ; <nl> virtual void ShowGraphContextMenu ( QPointF screenPos ) override ; <nl> void OnContextMenuEntryClicked ( CAbstractDictionaryEntry & entry ) ; <nl> + virtual void closeEvent ( QCloseEvent * pEvent ) override ; <nl> private : <nl> std : : unique_ptr < QPopupWidget > m_pSearchPopup ; <nl> CDictionaryWidget * m_pSearchPopupContent ; <nl>
! XB ( Sandbox ) ( CE - 21231 ) Using ' Edit Asset ' on a material in Dependency Graph to open the the Material Editor , then exiting the editor crashes
CRYTEK/CRYENGINE
d6b307c768549f6e5723f0b46de10374f77666ed
2019-07-15T07:52:28Z
mmm a / BUILD <nl> ppp b / BUILD <nl> cc_library ( <nl> " src / core / ext / client_config / subchannel_call_holder . h " , <nl> " src / core / ext / client_config / subchannel_index . h " , <nl> " src / core / ext / client_config / uri_parser . h " , <nl> + " src / core / ext / lb_policy / grpclb / grpclb . h " , <nl> " src / core / ext / lb_policy / grpclb / load_balancer_api . h " , <nl> " src / core / ext / lb_policy / grpclb / proto / grpc / lb / v1 / load_balancer . pb . h " , <nl> " src / core / ext / load_reporting / load_reporting . h " , <nl> cc_library ( <nl> " src / core / ext / client_config / uri_parser . h " , <nl> " src / core / ext / load_reporting / load_reporting . h " , <nl> " src / core / ext / load_reporting / load_reporting_filter . h " , <nl> + " src / core / ext / lb_policy / grpclb / grpclb . h " , <nl> " src / core / ext / lb_policy / grpclb / load_balancer_api . h " , <nl> " src / core / ext / lb_policy / grpclb / proto / grpc / lb / v1 / load_balancer . pb . h " , <nl> " src / core / ext / census / aggregation . h " , <nl> objc_library ( <nl> " src / core / ext / client_config / subchannel_call_holder . h " , <nl> " src / core / ext / client_config / subchannel_index . h " , <nl> " src / core / ext / client_config / uri_parser . h " , <nl> + " src / core / ext / lb_policy / grpclb / grpclb . h " , <nl> " src / core / ext / lb_policy / grpclb / load_balancer_api . h " , <nl> " src / core / ext / lb_policy / grpclb / proto / grpc / lb / v1 / load_balancer . pb . h " , <nl> " src / core / ext / load_reporting / load_reporting . h " , <nl> mmm a / build . yaml <nl> ppp b / build . yaml <nl> filegroups : <nl> - gpr_codegen <nl> - name : grpc_lb_policy_grpclb <nl> headers : <nl> + - src / core / ext / lb_policy / grpclb / grpclb . h <nl> - src / core / ext / lb_policy / grpclb / load_balancer_api . h <nl> - src / core / ext / lb_policy / grpclb / proto / grpc / lb / v1 / load_balancer . pb . h <nl> src : <nl> mmm a / gRPC . podspec <nl> ppp b / gRPC . podspec <nl> Pod : : Spec . new do | s | <nl> ' src / core / ext / client_config / subchannel_call_holder . h ' , <nl> ' src / core / ext / client_config / subchannel_index . h ' , <nl> ' src / core / ext / client_config / uri_parser . h ' , <nl> + ' src / core / ext / lb_policy / grpclb / grpclb . h ' , <nl> ' src / core / ext / lb_policy / grpclb / load_balancer_api . h ' , <nl> ' src / core / ext / lb_policy / grpclb / proto / grpc / lb / v1 / load_balancer . pb . h ' , <nl> ' third_party / nanopb / pb . h ' , <nl> Pod : : Spec . new do | s | <nl> ' src / core / ext / client_config / subchannel_call_holder . h ' , <nl> ' src / core / ext / client_config / subchannel_index . h ' , <nl> ' src / core / ext / client_config / uri_parser . h ' , <nl> + ' src / core / ext / lb_policy / grpclb / grpclb . h ' , <nl> ' src / core / ext / lb_policy / grpclb / load_balancer_api . h ' , <nl> ' src / core / ext / lb_policy / grpclb / proto / grpc / lb / v1 / load_balancer . pb . h ' , <nl> ' third_party / nanopb / pb . h ' , <nl> mmm a / grpc . gemspec <nl> ppp b / grpc . gemspec <nl> Gem : : Specification . new do | s | <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> s . files + = % w ( src / core / ext / client_config / uri_parser . h ) <nl> + s . files + = % w ( src / core / ext / lb_policy / grpclb / grpclb . h ) <nl> s . files + = % w ( src / core / ext / lb_policy / grpclb / load_balancer_api . h ) <nl> s . files + = % w ( src / core / ext / lb_policy / grpclb / proto / grpc / lb / v1 / load_balancer . pb . h ) <nl> s . files + = % w ( third_party / nanopb / pb . h ) <nl> mmm a / package . xml <nl> ppp b / package . xml <nl> <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> < file baseinstalldir = " / " name = " src / core / ext / client_config / uri_parser . h " role = " src " / > <nl> + < file baseinstalldir = " / " name = " src / core / ext / lb_policy / grpclb / grpclb . h " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / ext / lb_policy / grpclb / load_balancer_api . h " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / ext / lb_policy / grpclb / proto / grpc / lb / v1 / load_balancer . pb . h " role = " src " / > <nl> < file baseinstalldir = " / " name = " third_party / nanopb / pb . h " role = " src " / > <nl> mmm a / tools / doxygen / Doxyfile . core . internal <nl> ppp b / tools / doxygen / Doxyfile . core . internal <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 / client_config / uri_parser . h \ <nl> + src / core / ext / lb_policy / grpclb / grpclb . h \ <nl> src / core / ext / lb_policy / grpclb / load_balancer_api . h \ <nl> src / core / ext / lb_policy / grpclb / proto / grpc / lb / v1 / load_balancer . pb . h \ <nl> third_party / nanopb / pb . h \ <nl> mmm a / tools / run_tests / sources_and_headers . json <nl> ppp b / tools / run_tests / sources_and_headers . json <nl> <nl> " nanopb " <nl> ] , <nl> " headers " : [ <nl> + " src / core / ext / lb_policy / grpclb / grpclb . h " , <nl> " src / core / ext / lb_policy / grpclb / load_balancer_api . h " , <nl> " src / core / ext / lb_policy / grpclb / proto / grpc / lb / v1 / load_balancer . pb . h " <nl> ] , <nl> <nl> " name " : " grpc_lb_policy_grpclb " , <nl> " src " : [ <nl> " src / core / ext / lb_policy / grpclb / grpclb . c " , <nl> + " src / core / ext / lb_policy / grpclb / grpclb . h " , <nl> " src / core / ext / lb_policy / grpclb / load_balancer_api . c " , <nl> " src / core / ext / lb_policy / grpclb / load_balancer_api . h " , <nl> " src / core / ext / lb_policy / grpclb / proto / grpc / lb / v1 / load_balancer . pb . c " , <nl> mmm a / vsprojects / vcxproj / grpc / grpc . vcxproj <nl> ppp b / vsprojects / vcxproj / grpc / grpc . vcxproj <nl> <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> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ uri_parser . h " / > <nl> + < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ lb_policy \ grpclb \ grpclb . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ lb_policy \ grpclb \ load_balancer_api . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ lb_policy \ grpclb \ proto \ grpc \ lb \ v1 \ load_balancer . pb . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ third_party \ nanopb \ pb . h " / > <nl> mmm a / vsprojects / vcxproj / grpc / grpc . vcxproj . filters <nl> ppp b / vsprojects / vcxproj / grpc / grpc . vcxproj . filters <nl> <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ client_config \ uri_parser . h " > <nl> < Filter > src \ core \ ext \ client_config < / Filter > <nl> < / ClInclude > <nl> + < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ lb_policy \ grpclb \ grpclb . h " > <nl> + < Filter > src \ core \ ext \ lb_policy \ grpclb < / Filter > <nl> + < / ClInclude > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ lb_policy \ grpclb \ load_balancer_api . h " > <nl> < Filter > src \ core \ ext \ lb_policy \ grpclb < / 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 \ client_config \ uri_parser . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ load_reporting \ load_reporting . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ load_reporting \ load_reporting_filter . h " / > <nl> + < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ lb_policy \ grpclb \ grpclb . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ lb_policy \ grpclb \ load_balancer_api . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ lb_policy \ grpclb \ proto \ grpc \ lb \ v1 \ load_balancer . pb . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ third_party \ nanopb \ pb . h " / > <nl> mmm a / vsprojects / vcxproj / grpc_unsecure / grpc_unsecure . vcxproj . filters <nl> ppp b / vsprojects / vcxproj / grpc_unsecure / grpc_unsecure . vcxproj . filters <nl> <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ load_reporting \ load_reporting_filter . h " > <nl> < Filter > src \ core \ ext \ load_reporting < / Filter > <nl> < / ClInclude > <nl> + < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ lb_policy \ grpclb \ grpclb . h " > <nl> + < Filter > src \ core \ ext \ lb_policy \ grpclb < / Filter > <nl> + < / ClInclude > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ ext \ lb_policy \ grpclb \ load_balancer_api . h " > <nl> < Filter > src \ core \ ext \ lb_policy \ grpclb < / Filter > <nl> < / ClInclude > <nl>
added missing grpclb . h dep in build . yaml
grpc/grpc
b2e986b3fa333135533b3e050229c259aac7376c
2016-06-16T06:55:50Z
mmm a / docs / api / app . md <nl> ppp b / docs / api / app . md <nl> Clears the recent documents list . <nl> <nl> This method sets the current executable as the default handler for a protocol <nl> ( aka URI scheme ) . It allows you to integrate your app deeper into the operating <nl> - system . Once registered , all links with ` your - protocol : / / ` will be openend with <nl> + system . Once registered , all links with ` your - protocol : / / ` will be opened with <nl> the current executable . The whole link , including protocol , will be passed to <nl> your application as a parameter . <nl> <nl> mmm a / docs / api / web - contents . md <nl> ppp b / docs / api / web - contents . md <nl> Returns : <nl> <nl> * ` event ` Event <nl> * ` params ` Object <nl> - * ` x ` Integer - x coodinate <nl> - * ` y ` Integer - y coodinate <nl> + * ` x ` Integer - x coordinate <nl> + * ` y ` Integer - y coordinate <nl> * ` linkURL ` String - URL of the link that encloses the node the context menu <nl> was invoked on . <nl> * ` linkText ` String - Text associated with the link . May be an empty <nl> mmm a / docs / api / web - frame . md <nl> ppp b / docs / api / web - frame . md <nl> previous navigation ) . <nl> <nl> Note that blindly calling this method probably makes Electron slower since it <nl> will have to refill these emptied caches , you should only call it if an event <nl> - in your app has occured that makes you think your page is actually using less <nl> + in your app has occurred that makes you think your page is actually using less <nl> memory ( i . e . you have navigated from a super heavy page to a mostly empty one , <nl> and intend to stay there ) . <nl> <nl> mmm a / docs / tutorial / security . md <nl> ppp b / docs / tutorial / security . md <nl> This is not bulletproof , but at the least , you should attempt the following : <nl> ( using ` webPreferences ` ) <nl> * Do not disable ` webSecurity ` . Disabling it will disable the same - origin policy . <nl> * Define a [ ` Content - Security - Policy ` ] ( http : / / www . html5rocks . com / en / tutorials / security / content - security - policy / ) <nl> - , and use restrictive rules ( ie : ` script - src ' self ' ` ) <nl> + , and use restrictive rules ( i . e . ` script - src ' self ' ` ) <nl> * [ Override and disable ` eval ` ] ( https : / / github . com / nylas / N1 / blob / 0abc5d5defcdb057120d726b271933425b75b415 / static / index . js # L6 ) <nl> , which allows strings to be executed as code . <nl> * Do not set ` allowDisplayingInsecureContent ` to true . <nl> mmm a / docs / tutorial / testing - on - headless - ci . md <nl> ppp b / docs / tutorial / testing - on - headless - ci . md <nl> xvfb - maybe electron - mocha . / test / * . js <nl> <nl> On Travis , your ` . travis . yml ` should look roughly like this : <nl> <nl> - ` ` ` <nl> + ` ` ` yml <nl> addons : <nl> apt : <nl> packages : <nl> mmm a / docs / tutorial / windows - store - guide . md <nl> ppp b / docs / tutorial / windows - store - guide . md <nl> folder . <nl> Once the expanded AppX files are created , the tool uses the Windows App Packager <nl> ( ` MakeAppx . exe ` ) to create a single - file AppX package from those files on disk . <nl> Finally , the tool can be used to create a trusted certificate on your computer <nl> - to sign the new AppX pacakge . With the signed AppX package , the CLI can also <nl> + to sign the new AppX package . With the signed AppX package , the CLI can also <nl> automatically install the package on your machine . <nl> <nl> # # Step 3 : Using the AppX Package <nl> Once installation succeeded , you can move on to compiling your Electron app . <nl> [ add - appxpackage ] : https : / / technet . microsoft . com / en - us / library / hh856048 . aspx <nl> [ electron - packager ] : https : / / github . com / electron - userland / electron - packager <nl> [ electron - windows - store ] : https : / / github . com / catalystcode / electron - windows - store <nl> - [ background - task ] : https : / / github . com / felixrieseberg / electron - uwp - background <nl> \ No newline at end of file <nl> + [ background - task ] : https : / / github . com / felixrieseberg / electron - uwp - background <nl>
Merge pull request from electron / doc - typos
electron/electron
a6e3eeee2ded24c53d55d8a905399b6072a5c3e1
2016-06-16T22:27:59Z
mmm a / Marlin / src / HAL / HAL_STM32F1 / HAL_Stm32f1 . cpp <nl> ppp b / Marlin / src / HAL / HAL_STM32F1 / HAL_Stm32f1 . cpp <nl> uint8 adc_pins [ ] = { <nl> } ; <nl> <nl> enum TEMP_PINS { <nl> - TEMP_0 , <nl> - TEMP_1 , <nl> - TEMP_2 , <nl> - TEMP_3 , <nl> - TEMP_4 , <nl> - TEMP_BED , <nl> - FILWIDTH <nl> + # if HAS_TEMP_0 <nl> + TEMP_0 , <nl> + # endif <nl> + # if HAS_TEMP_1 <nl> + TEMP_1 , <nl> + # endif <nl> + # if HAS_TEMP_2 <nl> + TEMP_2 , <nl> + # endif <nl> + # if HAS_TEMP_3 <nl> + TEMP_3 , <nl> + # endif <nl> + # if HAS_TEMP_4 <nl> + TEMP_4 , <nl> + # endif <nl> + # if HAS_TEMP_BED <nl> + TEMP_BED , <nl> + # endif <nl> + # if ENABLED ( FILAMENT_WIDTH_SENSOR ) <nl> + FILWIDTH , <nl> + # endif <nl> + ADC_PIN_COUNT <nl> } ; <nl> <nl> - # define ADC_PIN_COUNT ( sizeof ( adc_pins ) / sizeof ( adc_pins [ 0 ] ) ) <nl> uint16_t HAL_adc_results [ ADC_PIN_COUNT ] ; <nl> <nl> <nl> void HAL_adc_init ( void ) { <nl> void HAL_adc_start_conversion ( const uint8_t adc_pin ) { <nl> TEMP_PINS pin_index ; <nl> switch ( adc_pin ) { <nl> - default : <nl> - case TEMP_0_PIN : pin_index = TEMP_0 ; break ; <nl> - case TEMP_1_PIN : pin_index = TEMP_1 ; break ; <nl> - case TEMP_2_PIN : pin_index = TEMP_2 ; break ; <nl> - case TEMP_3_PIN : pin_index = TEMP_3 ; break ; <nl> - case TEMP_4_PIN : pin_index = TEMP_4 ; break ; <nl> - case TEMP_BED_PIN : pin_index = TEMP_BED ; break ; <nl> + # if HAS_TEMP_0 <nl> + case TEMP_0_PIN : pin_index = TEMP_0 ; break ; <nl> + # endif <nl> + # if HAS_TEMP_1 <nl> + case TEMP_1_PIN : pin_index = TEMP_1 ; break ; <nl> + # endif <nl> + # if HAS_TEMP_2 <nl> + case TEMP_2_PIN : pin_index = TEMP_2 ; break ; <nl> + # endif <nl> + # if HAS_TEMP_3 <nl> + case TEMP_3_PIN : pin_index = TEMP_3 ; break ; <nl> + # endif <nl> + # if HAS_TEMP_4 <nl> + case TEMP_4_PIN : pin_index = TEMP_4 ; break ; <nl> + # endif <nl> + # if HAS_TEMP_BED <nl> + case TEMP_BED_PIN : pin_index = TEMP_BED ; break ; <nl> + # endif <nl> # if ENABLED ( FILAMENT_WIDTH_SENSOR ) <nl> case FILWIDTH_PIN : pin_index = FILWIDTH ; break ; <nl> # endif <nl> mmm a / Marlin / src / HAL / HAL_STM32F1 / HAL_spi_Stm32f1 . cpp <nl> ppp b / Marlin / src / HAL / HAL_STM32F1 / HAL_spi_Stm32f1 . cpp <nl> void spiBegin ( ) { <nl> # if ! PIN_EXISTS ( SS ) <nl> # error " SS_PIN not defined ! " <nl> # endif <nl> - SET_OUTPUT ( SS_PIN ) ; <nl> WRITE ( SS_PIN , HIGH ) ; <nl> + SET_OUTPUT ( SS_PIN ) ; <nl> } <nl> <nl> / * * <nl> void spiBegin ( ) { <nl> void spiInit ( uint8_t spiRate ) { <nl> uint8_t clock ; <nl> switch ( spiRate ) { <nl> - case SPI_FULL_SPEED : clock = SPI_CLOCK_DIV2 ; break ; <nl> - case SPI_HALF_SPEED : clock = SPI_CLOCK_DIV4 ; break ; <nl> - case SPI_QUARTER_SPEED : clock = SPI_CLOCK_DIV8 ; break ; <nl> - case SPI_EIGHTH_SPEED : clock = SPI_CLOCK_DIV16 ; break ; <nl> - case SPI_SPEED_5 : clock = SPI_CLOCK_DIV32 ; break ; <nl> - case SPI_SPEED_6 : clock = SPI_CLOCK_DIV64 ; break ; <nl> + case SPI_FULL_SPEED : clock = SPI_CLOCK_DIV2 ; break ; <nl> + case SPI_HALF_SPEED : clock = SPI_CLOCK_DIV4 ; break ; <nl> + case SPI_QUARTER_SPEED : clock = SPI_CLOCK_DIV8 ; break ; <nl> + case SPI_EIGHTH_SPEED : clock = SPI_CLOCK_DIV16 ; break ; <nl> + case SPI_SPEED_5 : clock = SPI_CLOCK_DIV32 ; break ; <nl> + case SPI_SPEED_6 : clock = SPI_CLOCK_DIV64 ; break ; <nl> default : <nl> clock = SPI_CLOCK_DIV2 ; / / Default from the SPI library <nl> } <nl> mmm a / Marlin / src / HAL / HAL_STM32F1 / HAL_timers_Stm32f1 . cpp <nl> ppp b / Marlin / src / HAL / HAL_STM32F1 / HAL_timers_Stm32f1 . cpp <nl> const tTimerConfig TimerConfig [ NUM_HARDWARE_TIMERS ] = { <nl> / / Public functions <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> - / * <nl> - Timer_clock1 : Prescaler 2 - > 42MHz <nl> - Timer_clock2 : Prescaler 8 - > 10 . 5MHz <nl> - Timer_clock3 : Prescaler 32 - > 2 . 625MHz <nl> - Timer_clock4 : Prescaler 128 - > 656 . 25kHz <nl> - * / <nl> + / * * <nl> + * Timer_clock1 : Prescaler 2 - > 36 MHz <nl> + * Timer_clock2 : Prescaler 8 - > 9 MHz <nl> + * Timer_clock3 : Prescaler 32 - > 2 . 25 MHz <nl> + * Timer_clock4 : Prescaler 128 - > 562 . 5 kHz <nl> + * / <nl> <nl> / * * <nl> * TODO : Calculate Timer prescale value , so we get the 32bit to adjust <nl> * / <nl> <nl> void HAL_timer_start ( uint8_t timer_num , uint32_t frequency ) { <nl> + nvic_irq_num irq_num ; <nl> + switch ( timer_num ) { <nl> + case 1 : irq_num = NVIC_TIMER1_CC ; break ; <nl> + case 2 : irq_num = NVIC_TIMER2 ; break ; <nl> + case 3 : irq_num = NVIC_TIMER3 ; break ; <nl> + case 4 : irq_num = NVIC_TIMER4 ; break ; <nl> + case 5 : irq_num = NVIC_TIMER5 ; break ; <nl> + default : <nl> + / * * <nl> + * We should not get here , add Sanitycheck for timer number . Should be a general timer <nl> + * since basic timers do not have CC channels . <nl> + * Advanced timers should be skipped if possible too , and are not listed above . <nl> + * / <nl> + break ; <nl> + } <nl> + nvic_irq_set_priority ( irq_num , 0xF ) ; / / this is the lowest settable priority , but should still be over USB <nl> + <nl> switch ( timer_num ) { <nl> case STEP_TIMER_NUM : <nl> timer_pause ( STEP_TIMER_DEV ) ; <nl> mmm a / Marlin / src / HAL / HAL_STM32F1 / HAL_timers_Stm32f1 . h <nl> ppp b / Marlin / src / HAL / HAL_STM32F1 / HAL_timers_Stm32f1 . h <nl> <nl> typedef uint16_t hal_timer_t ; <nl> # define HAL_TIMER_TYPE_MAX 0xFFFF <nl> <nl> - # ifdef MCU_STM32F103CB | | defined ( MCU_STM32F103C8 ) <nl> + # if defined MCU_STM32F103CB | | defined ( MCU_STM32F103C8 ) <nl> # define STEP_TIMER_NUM 4 / / For C8 / CB boards , use timer 4 <nl> # else <nl> # define STEP_TIMER_NUM 5 / / for other boards , five is fine . <nl> typedef uint16_t hal_timer_t ; <nl> # define TEMP_TIMER_NUM 2 / / index of timer to use for temperature <nl> # define TEMP_TIMER_CHAN 1 / / Channel of the timer to use for compare and interrupts <nl> <nl> + # define CAT ( a , . . . ) a # # __VA_ARGS__ <nl> + # define TIMER_DEV ( num ) CAT ( & timer , num ) <nl> + <nl> + # define STEP_TIMER_DEV TIMER_DEV ( STEP_TIMER_NUM ) <nl> + # define TEMP_TIMER_DEV TIMER_DEV ( TEMP_TIMER_NUM ) <nl> + <nl> + <nl> + <nl> + / / STM32_HAVE_TIMER ( n ) ; <nl> + <nl> # define HAL_TIMER_RATE ( F_CPU ) / / frequency of timers peripherals <nl> - # define STEPPER_TIMER_PRESCALE 36 / / prescaler for setting stepper timer , 2Mhz <nl> + # define STEPPER_TIMER_PRESCALE 18 / / prescaler for setting stepper timer , 4Mhz <nl> # define HAL_STEPPER_TIMER_RATE ( HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE ) / / frequency of stepper timer ( HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE ) <nl> # define HAL_TICKS_PER_US ( ( HAL_STEPPER_TIMER_RATE ) / 1000000 ) / / stepper timer ticks per us <nl> <nl> typedef uint16_t hal_timer_t ; <nl> # define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE <nl> <nl> # define TEMP_TIMER_PRESCALE 1000 / / prescaler for setting Temp timer , 72Khz <nl> - # define TEMP_TIMER_FREQUENCY 1000 / / temperature interrupt frequency <nl> + # define TEMP_TIMER_FREQUENCY 100 / / temperature interrupt frequency <nl> <nl> - # define ENABLE_STEPPER_DRIVER_INTERRUPT ( ) HAL_timer_enable_interrupt ( STEP_TIMER_NUM ) <nl> - # define DISABLE_STEPPER_DRIVER_INTERRUPT ( ) HAL_timer_disable_interrupt ( STEP_TIMER_NUM ) <nl> + # define ENABLE_STEPPER_DRIVER_INTERRUPT ( ) timer_enable_irq ( STEP_TIMER_DEV , STEP_TIMER_CHAN ) <nl> + # define DISABLE_STEPPER_DRIVER_INTERRUPT ( ) timer_disable_irq ( STEP_TIMER_DEV , STEP_TIMER_CHAN ) <nl> + <nl> + # define ENABLE_TEMPERATURE_INTERRUPT ( ) timer_enable_irq ( TEMP_TIMER_DEV , TEMP_TIMER_CHAN ) <nl> + # define DISABLE_TEMPERATURE_INTERRUPT ( ) timer_disable_irq ( TEMP_TIMER_DEV , TEMP_TIMER_CHAN ) <nl> + <nl> + # define HAL_timer_get_current_count ( timer_num ) timer_get_count ( TIMER_DEV ( timer_num ) ) <nl> + # define HAL_timer_set_current_count ( timer_num , count ) timer_set_count ( TIMER_DEV ( timer_num , ( uint16 ) count ) ) <nl> <nl> - # define ENABLE_TEMPERATURE_INTERRUPT ( ) HAL_timer_enable_interrupt ( TEMP_TIMER_NUM ) <nl> - # define DISABLE_TEMPERATURE_INTERRUPT ( ) HAL_timer_disable_interrupt ( TEMP_TIMER_NUM ) <nl> <nl> # define HAL_ENABLE_ISRs ( ) do { if ( thermalManager . in_temp_isr ) DISABLE_TEMPERATURE_INTERRUPT ( ) ; else ENABLE_TEMPERATURE_INTERRUPT ( ) ; ENABLE_STEPPER_DRIVER_INTERRUPT ( ) ; } while ( 0 ) <nl> / / TODO change this <nl> void HAL_timer_disable_interrupt ( uint8_t timer_num ) ; <nl> * / <nl> <nl> FORCE_INLINE static void HAL_timer_set_count ( const uint8_t timer_num , const hal_timer_t count ) { <nl> + / / count = min ( count , HAL_TIMER_TYPE_MAX ) ; <nl> switch ( timer_num ) { <nl> case STEP_TIMER_NUM : <nl> - StepperTimer . pause ( ) ; <nl> - StepperTimer . setCompare ( STEP_TIMER_CHAN , count ) ; <nl> - StepperTimer . refresh ( ) ; <nl> - StepperTimer . resume ( ) ; <nl> - break ; <nl> + timer_set_compare ( STEP_TIMER_DEV , STEP_TIMER_CHAN , count ) ; <nl> + return ; <nl> case TEMP_TIMER_NUM : <nl> - TempTimer . pause ( ) ; <nl> - TempTimer . setCompare ( TEMP_TIMER_CHAN , count ) ; <nl> - TempTimer . refresh ( ) ; <nl> - TempTimer . resume ( ) ; <nl> - break ; <nl> + timer_set_compare ( TEMP_TIMER_DEV , TEMP_TIMER_CHAN , count ) ; <nl> + return ; <nl> default : <nl> - break ; <nl> + return ; <nl> } <nl> } <nl> <nl> FORCE_INLINE static hal_timer_t HAL_timer_get_count ( const uint8_t timer_num ) { <nl> - hal_timer_t temp ; <nl> switch ( timer_num ) { <nl> case STEP_TIMER_NUM : <nl> - temp = StepperTimer . getCompare ( STEP_TIMER_CHAN ) ; <nl> - break ; <nl> + return timer_get_compare ( STEP_TIMER_DEV , STEP_TIMER_CHAN ) ; <nl> case TEMP_TIMER_NUM : <nl> - temp = TempTimer . getCompare ( TEMP_TIMER_CHAN ) ; <nl> - break ; <nl> + return timer_get_compare ( TEMP_TIMER_DEV , TEMP_TIMER_CHAN ) ; <nl> default : <nl> - temp = 0 ; <nl> - break ; <nl> + return 0 ; <nl> } <nl> - return temp ; <nl> } <nl> <nl> - FORCE_INLINE static void HAL_timer_set_current_count ( const uint8_t timer_num , const hal_timer_t count ) { <nl> - switch ( timer_num ) { <nl> - case STEP_TIMER_NUM : StepperTimer . setCount ( count ) ; break ; <nl> - case TEMP_TIMER_NUM : TempTimer . setCount ( count ) ; break ; <nl> - } <nl> - } <nl> - <nl> - FORCE_INLINE static hal_timer_t HAL_timer_get_current_count ( const uint8_t timer_num ) { <nl> - hal_timer_t temp ; <nl> - switch ( timer_num ) { <nl> - case STEP_TIMER_NUM : <nl> - temp = StepperTimer . getCount ( ) ; <nl> - break ; <nl> - case TEMP_TIMER_NUM : <nl> - temp = TempTimer . getCount ( ) ; <nl> - break ; <nl> - default : <nl> - temp = 0 ; <nl> - break ; <nl> - } <nl> - return temp ; <nl> - } <nl> - <nl> - / / void HAL_timer_isr_prologue ( const uint8_t timer_num ) ; <nl> - <nl> FORCE_INLINE static void HAL_timer_isr_prologue ( const uint8_t timer_num ) { <nl> switch ( timer_num ) { <nl> case STEP_TIMER_NUM : <nl> - StepperTimer . pause ( ) ; <nl> - StepperTimer . setCount ( 0 ) ; <nl> - StepperTimer . refresh ( ) ; <nl> - StepperTimer . resume ( ) ; <nl> - break ; <nl> + timer_set_count ( STEP_TIMER_DEV , 0 ) ; <nl> + timer_generate_update ( STEP_TIMER_DEV ) ; <nl> + return ; <nl> case TEMP_TIMER_NUM : <nl> - TempTimer . pause ( ) ; <nl> - TempTimer . setCount ( 0 ) ; <nl> - TempTimer . refresh ( ) ; <nl> - TempTimer . resume ( ) ; <nl> - break ; <nl> + timer_set_count ( TEMP_TIMER_DEV , 0 ) ; <nl> + timer_generate_update ( TEMP_TIMER_DEV ) ; <nl> + return ; <nl> default : <nl> - break ; <nl> + return ; <nl> } <nl> } <nl> <nl> mmm a / Marlin / src / HAL / HAL_STM32F1 / SanityCheck_Stm32f1 . h <nl> ppp b / Marlin / src / HAL / HAL_STM32F1 / SanityCheck_Stm32f1 . h <nl> <nl> # elif ENABLED ( SPINDLE_LASER_PWM ) & & PIN_EXISTS ( SPINDLE_LASER_PWM ) <nl> # if ! PWM_PIN ( SPINDLE_LASER_PWM_PIN ) <nl> # error " SPINDLE_LASER_PWM_PIN not assigned to a PWM pin . " <nl> - # elif ! ( SPINDLE_LASER_PWM_PIN = = 4 | | SPINDLE_LASER_PWM_PIN = = 6 | | SPINDLE_LASER_PWM_PIN = = 11 ) <nl> - # error " SPINDLE_LASER_PWM_PIN must use SERVO0 , SERVO1 or SERVO3 connector " <nl> - # elif SPINDLE_LASER_POWERUP_DELAY < 1 <nl> - # error " SPINDLE_LASER_POWERUP_DELAY must be greater than 0 . " <nl> - # elif SPINDLE_LASER_POWERDOWN_DELAY < 1 <nl> - # error " SPINDLE_LASER_POWERDOWN_DELAY must be greater than 0 . " <nl> + # elif SPINDLE_LASER_POWERUP_DELAY < 0 <nl> + # error " SPINDLE_LASER_POWERUP_DELAY must be positive " <nl> + # elif SPINDLE_LASER_POWERDOWN_DELAY < 0 <nl> + # error " SPINDLE_LASER_POWERDOWN_DELAY must be positive " <nl> # elif ! defined ( SPINDLE_LASER_PWM_INVERT ) <nl> # error " SPINDLE_LASER_PWM_INVERT missing . " <nl> # elif ! defined ( SPEED_POWER_SLOPE ) | | ! defined ( SPEED_POWER_INTERCEPT ) | | ! defined ( SPEED_POWER_MIN ) | | ! defined ( SPEED_POWER_MAX ) <nl> mmm a / Marlin / src / HAL / HAL_STM32F1 / fastio_Stm32f1 . h <nl> ppp b / Marlin / src / HAL / HAL_STM32F1 / fastio_Stm32f1 . h <nl> <nl> # define GET_OUTPUT ( IO ) ( _GET_MODE ( IO ) = = GPIO_OUTPUT_PP ) <nl> # define GET_TIMER ( IO ) ( PIN_MAP [ IO ] . timer_device ! = NULL ) <nl> <nl> - # define OUT_WRITE ( IO , v ) { _SET_OUTPUT ( IO ) ; WRITE ( IO , v ) ; } <nl> + # define OUT_WRITE ( IO , v ) { _SET_OUTPUT ( IO ) ; WRITE ( IO , v ) ; } <nl> + / * <nl> + * TODO : Write a macro to test if PIN is PWM or not . <nl> + * / <nl> + # define PWM_PIN ( p ) true <nl> <nl> # endif / * _FASTIO_STM32F1_H * / <nl> mmm a / Marlin / src / HAL / HAL_STM32F1 / spi_pins . h <nl> ppp b / Marlin / src / HAL / HAL_STM32F1 / spi_pins . h <nl> <nl> / * * <nl> * Define SPI Pins : SCK , MISO , MOSI , SS <nl> * <nl> - * Available chip select pins for HW SPI are 4 10 52 77 <nl> + * Any PIN can be used for Chip Select ( SS ) <nl> * / <nl> # define SCK_PIN PA5 <nl> # define MISO_PIN PA6 <nl> mmm a / Marlin / src / HAL / HAL_STM32F1 / watchdog_Stm32f1 . h <nl> ppp b / Marlin / src / HAL / HAL_STM32F1 / watchdog_Stm32f1 . h <nl> <nl> # include < libmaple / iwdg . h > <nl> <nl> # include " . . / . . / . . / src / inc / MarlinConfig . h " <nl> + <nl> + / * * <nl> + * The watchdog clock is 40Khz . We need a 4 seconds interval , so use a / 256 preescaler and <nl> + * 625 reload value ( counts down to 0 ) <nl> + * use 1250 for 8 seconds <nl> + * / <nl> # define STM32F1_WD_RELOAD 625 <nl> <nl> / / Arduino STM32F1 core now has watchdog support <nl> void watchdog_init ( ) ; <nl> <nl> / / Reset watchdog . MUST be called at least every 4 seconds after the <nl> / / first watchdog_init or STM32F1 will reset . <nl> - inline void watchdog_reset ( ) { iwdg_feed ( ) ; } <nl> + inline void watchdog_reset ( ) { <nl> + # if PIN_EXISTS ( LED ) <nl> + TOGGLE ( LED_PIN ) ; / / heart beat indicator <nl> + # endif <nl> + iwdg_feed ( ) ; <nl> + } <nl> <nl> # endif / / WATCHDOG_STM32F1_H <nl>
Changes to STM32F1 HAL ( )
MarlinFirmware/Marlin
2ec4113cb26f1a3b70a9f513f7344e57c7ef1e45
2017-12-20T22:16:36Z
new file mode 100644 <nl> index 000000000000 . . 1496779a0b25 <nl> mmm / dev / null <nl> ppp b / caffe2 / core / net_async_task . cc <nl> <nl> + # include " caffe2 / core / net_async_task . h " <nl> + <nl> + # include " caffe2 / core / net_async_task_graph . h " <nl> + <nl> + namespace caffe2 { <nl> + <nl> + AsyncTask : : AsyncTask ( const std : : vector < OperatorBase * > & ops ) : ops_ ( ops ) { <nl> + CAFFE_ENFORCE ( ! ops_ . empty ( ) ) ; <nl> + device_option_ = ops_ . front ( ) - > device_option ( ) ; <nl> + for ( auto & op : ops_ ) { <nl> + CAFFE_ENFORCE ( IsSameDevice ( device_option_ , op - > device_option ( ) ) ) ; <nl> + } <nl> + Reset ( ) ; <nl> + } <nl> + <nl> + void AsyncTask : : handleChainError ( <nl> + OperatorBase * op , <nl> + const char * err_str , <nl> + bool save_exception ) { <nl> + std : : string err_msg = err_str ; <nl> + if ( op ) { <nl> + err_msg + = " , op " + ( op - > has_debug_def ( ) ? op - > type ( ) : " unknown " ) ; <nl> + } <nl> + LOG ( ERROR ) < < err_msg ; <nl> + <nl> + / / save error message and exception in chain ' s Event <nl> + auto last_op = ops_ . back ( ) ; <nl> + if ( save_exception ) { <nl> + last_op - > event ( ) . SetFinishedWithException ( err_msg . c_str ( ) ) ; <nl> + } else { <nl> + last_op - > event ( ) . SetFinished ( err_msg . c_str ( ) ) ; <nl> + } <nl> + <nl> + / / set future as completed with an error <nl> + / / TODO : exceptions in future <nl> + future_ . SetCompleted ( err_msg . c_str ( ) ) ; <nl> + } <nl> + <nl> + bool AsyncTask : : Run ( const ExecutionOptions & options ) { <nl> + / / TODO : insert CUDA ' s async stream waits ; tracing and counters <nl> + OperatorBase * op = nullptr ; <nl> + try { <nl> + for ( auto op_idx = 0 ; op_idx < ops_ . size ( ) ; + + op_idx ) { <nl> + op = ops_ [ op_idx ] ; <nl> + int stream_id = 0 ; / / TODO : thread local stream id <nl> + if ( ! op - > RunAsync ( stream_id ) ) { <nl> + handleChainError ( op , " Failed to execute an op " ) ; <nl> + return false ; <nl> + } <nl> + } <nl> + <nl> + if ( options . finish_chain_ ) { <nl> + op = ops_ . back ( ) ; <nl> + op - > Finish ( ) ; <nl> + } <nl> + <nl> + / / set the future as successfully completed or , in case of async CPU , <nl> + / / use op ' s callback <nl> + if ( IsCPUDeviceType ( device_option_ . device_type ( ) ) & & <nl> + ops_ . back ( ) - > HasAsyncPart ( ) ) { <nl> + auto & event = ops_ . back ( ) - > event ( ) ; <nl> + event . SetCallback ( [ this , & event ] ( ) { <nl> + CAFFE_ENFORCE ( event . IsFinished ( ) ) ; <nl> + if ( event . Query ( ) = = EventStatus : : EVENT_SUCCESS ) { <nl> + future_ . SetCompleted ( ) ; <nl> + } else { <nl> + / / TODO : support for exceptions <nl> + future_ . SetCompleted ( event . ErrorMessage ( ) . c_str ( ) ) ; <nl> + } <nl> + } ) ; <nl> + } else { <nl> + future_ . SetCompleted ( ) ; <nl> + } <nl> + } catch ( const std : : exception & e ) { <nl> + handleChainError ( op , e . what ( ) , / * save_exception * / true ) ; <nl> + return false ; <nl> + } catch ( . . . ) { <nl> + handleChainError ( <nl> + op , <nl> + " Failed to execute task : unknown error " , <nl> + / * save_exception * / true ) ; <nl> + return false ; <nl> + } <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + void AsyncTask : : Reset ( ) { <nl> + for ( auto & op : ops_ ) { <nl> + op - > ResetEvent ( ) ; <nl> + } <nl> + future_ . ResetState ( ) ; <nl> + } <nl> + <nl> + DeviceOption AsyncTask : : GetDeviceOption ( ) const { <nl> + return device_option_ ; <nl> + } <nl> + <nl> + AsyncTaskFuture & AsyncTask : : GetFuture ( ) { <nl> + return future_ ; <nl> + } <nl> + <nl> + const AsyncTaskFuture & AsyncTask : : GetFuture ( ) const { <nl> + return future_ ; <nl> + } <nl> + <nl> + } ; / / namespace caffe2 <nl> new file mode 100644 <nl> index 000000000000 . . e9aa699854ed <nl> mmm / dev / null <nl> ppp b / caffe2 / core / net_async_task . h <nl> <nl> + # ifndef CAFFE2_NET_ASYNC_TASK_H <nl> + # define CAFFE2_NET_ASYNC_TASK_H <nl> + <nl> + # include " caffe2 / core / net_async_base . h " <nl> + # include " caffe2 / core / net_async_task_future . h " <nl> + # include " caffe2 / core / operator . h " <nl> + <nl> + # include < vector > <nl> + <nl> + namespace caffe2 { <nl> + <nl> + / / AsyncTask represents an asynchronous execution of a chain of ops . <nl> + class AsyncTask { <nl> + public : <nl> + AsyncTask ( const std : : vector < OperatorBase * > & ops ) ; <nl> + <nl> + bool Run ( const ExecutionOptions & options ) ; <nl> + <nl> + void Reset ( ) ; <nl> + <nl> + DeviceOption GetDeviceOption ( ) const ; <nl> + <nl> + AsyncTaskFuture & GetFuture ( ) ; <nl> + const AsyncTaskFuture & GetFuture ( ) const ; <nl> + <nl> + private : <nl> + void handleChainError ( <nl> + OperatorBase * op , <nl> + const char * err_msg , <nl> + bool save_exception = false ) ; <nl> + <nl> + std : : vector < OperatorBase * > ops_ ; <nl> + DeviceOption device_option_ ; <nl> + AsyncTaskFuture future_ ; <nl> + } ; <nl> + <nl> + } / / namespace caffe2 <nl> + <nl> + # endif / / CAFFE2_NET_ASYNC_TASK_H <nl> new file mode 100644 <nl> index 000000000000 . . da33d21fb1eb <nl> mmm / dev / null <nl> ppp b / caffe2 / core / net_async_task_future . cc <nl> <nl> + # include " caffe2 / core / net_async_task_future . h " <nl> + <nl> + # include " c10 / util / Logging . h " <nl> + # include " caffe2 / core / common . h " <nl> + <nl> + namespace caffe2 { <nl> + <nl> + AsyncTaskFuture : : AsyncTaskFuture ( ) : completed_ ( false ) , failed_ ( false ) { } <nl> + <nl> + AsyncTaskFuture : : AsyncTaskFuture ( const std : : vector < AsyncTaskFuture * > & futures ) <nl> + : completed_ ( false ) , failed_ ( false ) { <nl> + if ( futures . size ( ) > 1 ) { <nl> + parent_counter_ = caffe2 : : make_unique < ParentCounter > ( futures . size ( ) ) ; <nl> + for ( auto future : futures ) { <nl> + future - > SetCallback ( [ this ] ( const AsyncTaskFuture * f ) { <nl> + if ( f - > IsFailed ( ) ) { <nl> + std : : unique_lock < std : : mutex > lock ( parent_counter_ - > err_mutex ) ; <nl> + if ( parent_counter_ - > parent_failed ) { <nl> + parent_counter_ - > err_msg + = " , " + f - > ErrorMessage ( ) ; <nl> + } else { <nl> + parent_counter_ - > parent_failed = true ; <nl> + parent_counter_ - > err_msg = f - > ErrorMessage ( ) ; <nl> + } <nl> + } <nl> + int count = - - parent_counter_ - > parent_count ; <nl> + if ( count = = 0 ) { <nl> + / / thread safe to use parent_counter here <nl> + if ( ! parent_counter_ - > parent_failed ) { <nl> + SetCompleted ( ) ; <nl> + } else { <nl> + SetCompleted ( parent_counter_ - > err_msg . c_str ( ) ) ; <nl> + } <nl> + } <nl> + } ) ; <nl> + } <nl> + } else { <nl> + CAFFE_ENFORCE_EQ ( futures . size ( ) , 1 ) ; <nl> + auto future = futures . back ( ) ; <nl> + future - > SetCallback ( [ this ] ( const AsyncTaskFuture * f ) { <nl> + if ( ! f - > IsFailed ( ) ) { <nl> + SetCompleted ( ) ; <nl> + } else { <nl> + SetCompleted ( f - > ErrorMessage ( ) . c_str ( ) ) ; <nl> + } <nl> + } ) ; <nl> + } <nl> + } <nl> + <nl> + bool AsyncTaskFuture : : IsCompleted ( ) const { <nl> + return completed_ ; <nl> + } <nl> + <nl> + bool AsyncTaskFuture : : IsFailed ( ) const { <nl> + return failed_ ; <nl> + } <nl> + <nl> + std : : string AsyncTaskFuture : : ErrorMessage ( ) const { <nl> + return err_msg_ ; <nl> + } <nl> + <nl> + void AsyncTaskFuture : : Wait ( ) const { <nl> + std : : unique_lock < std : : mutex > lock ( mutex_ ) ; <nl> + while ( ! completed_ ) { <nl> + cv_completed_ . wait ( lock ) ; <nl> + } <nl> + } <nl> + <nl> + void AsyncTaskFuture : : SetCallback ( <nl> + std : : function < void ( const AsyncTaskFuture * ) > callback ) { <nl> + std : : unique_lock < std : : mutex > lock ( mutex_ ) ; <nl> + <nl> + callbacks_ . push_back ( callback ) ; <nl> + if ( completed_ ) { <nl> + callback ( this ) ; <nl> + } <nl> + } <nl> + <nl> + void AsyncTaskFuture : : SetCompleted ( const char * err_msg ) { <nl> + std : : unique_lock < std : : mutex > lock ( mutex_ ) ; <nl> + <nl> + CAFFE_ENFORCE ( ! completed_ , " Calling SetCompleted on a completed future " ) ; <nl> + completed_ = true ; <nl> + <nl> + if ( err_msg ) { <nl> + failed_ = true ; <nl> + err_msg_ = err_msg ; <nl> + } <nl> + <nl> + for ( auto & callback : callbacks_ ) { <nl> + callback ( this ) ; <nl> + } <nl> + <nl> + cv_completed_ . notify_all ( ) ; <nl> + } <nl> + <nl> + / / ResetState is called on a completed future , <nl> + / / does not reset callbacks to keep task graph structure <nl> + void AsyncTaskFuture : : ResetState ( ) { <nl> + std : : unique_lock < std : : mutex > lock ( mutex_ ) ; <nl> + if ( parent_counter_ ) { <nl> + parent_counter_ - > Reset ( ) ; <nl> + } <nl> + completed_ = false ; <nl> + failed_ = false ; <nl> + err_msg_ = " " ; <nl> + } <nl> + <nl> + AsyncTaskFuture : : ~ AsyncTaskFuture ( ) { } <nl> + <nl> + } / / namespace caffe2 <nl> new file mode 100644 <nl> index 000000000000 . . 167b4b29c525 <nl> mmm / dev / null <nl> ppp b / caffe2 / core / net_async_task_future . h <nl> <nl> + # ifndef CAFFE2_NET_ASYNC_TASK_FUTURE_H <nl> + # define CAFFE2_NET_ASYNC_TASK_FUTURE_H <nl> + <nl> + # include < atomic > <nl> + # include < condition_variable > <nl> + # include < functional > <nl> + # include < memory > <nl> + # include < mutex > <nl> + # include < string > <nl> + # include < vector > <nl> + <nl> + namespace caffe2 { <nl> + <nl> + / / Represents the state of AsyncTask execution , that can be queried with <nl> + / / IsCompleted / IsFailed . Callbacks are supported through SetCallback and <nl> + / / are called upon future ' s completion . <nl> + <nl> + class AsyncTaskFuture { <nl> + public : <nl> + AsyncTaskFuture ( ) ; <nl> + / / Creates a future completed when all given futures are completed <nl> + explicit AsyncTaskFuture ( const std : : vector < AsyncTaskFuture * > & futures ) ; <nl> + ~ AsyncTaskFuture ( ) ; <nl> + <nl> + AsyncTaskFuture ( const AsyncTaskFuture & ) = delete ; <nl> + <nl> + AsyncTaskFuture & operator = ( const AsyncTaskFuture & ) = delete ; <nl> + <nl> + bool IsCompleted ( ) const ; <nl> + <nl> + bool IsFailed ( ) const ; <nl> + <nl> + std : : string ErrorMessage ( ) const ; <nl> + <nl> + void Wait ( ) const ; <nl> + <nl> + void SetCallback ( std : : function < void ( const AsyncTaskFuture * ) > callback ) ; <nl> + <nl> + void SetCompleted ( const char * err_msg = nullptr ) ; <nl> + <nl> + void ResetState ( ) ; <nl> + <nl> + private : <nl> + mutable std : : mutex mutex_ ; <nl> + mutable std : : condition_variable cv_completed_ ; <nl> + std : : atomic < bool > completed_ ; <nl> + std : : atomic < bool > failed_ ; <nl> + std : : string err_msg_ ; <nl> + std : : vector < std : : function < void ( const AsyncTaskFuture * ) > > callbacks_ ; <nl> + <nl> + struct ParentCounter { <nl> + explicit ParentCounter ( int init_parent_count ) <nl> + : init_parent_count_ ( init_parent_count ) , <nl> + parent_count ( init_parent_count ) , <nl> + parent_failed ( false ) { } <nl> + <nl> + void Reset ( ) { <nl> + std : : unique_lock < std : : mutex > lock ( err_mutex ) ; <nl> + parent_count = init_parent_count_ ; <nl> + parent_failed = false ; <nl> + err_msg = " " ; <nl> + } <nl> + <nl> + const int init_parent_count_ ; <nl> + std : : atomic < int > parent_count ; <nl> + std : : mutex err_mutex ; <nl> + std : : atomic < bool > parent_failed ; <nl> + std : : string err_msg ; <nl> + } ; <nl> + <nl> + std : : unique_ptr < ParentCounter > parent_counter_ ; <nl> + } ; <nl> + <nl> + } / / namespace caffe2 <nl> + <nl> + # endif / / CAFFE2_NET_ASYNC_TASK_FUTURE_H <nl> new file mode 100644 <nl> index 000000000000 . . c2732ee97c01 <nl> mmm / dev / null <nl> ppp b / caffe2 / core / net_async_task_graph . cc <nl> <nl> + # include " caffe2 / core / net_async_task_graph . h " <nl> + <nl> + # include " caffe2 / core / net_parallel . h " <nl> + <nl> + namespace caffe2 { <nl> + <nl> + AsyncTaskGraph : : AsyncTaskGraph ( <nl> + ExecutorHelper * helper , <nl> + const ExecutionOptions & options ) <nl> + : helper_ ( helper ) , options_ ( options ) , frozen_ ( false ) { } <nl> + <nl> + bool AsyncTaskGraph : : CreateNode ( <nl> + int node_id , <nl> + const std : : vector < OperatorBase * > & ops ) { <nl> + CAFFE_ENFORCE ( ! frozen_ ) ; <nl> + if ( ! nodes_ . count ( node_id ) ) { <nl> + nodes_ [ node_id ] = caffe2 : : make_unique < AsyncTask > ( ops ) ; <nl> + return true ; <nl> + } else { <nl> + return false ; <nl> + } <nl> + } <nl> + <nl> + bool AsyncTaskGraph : : AddDependency ( <nl> + int child_node_id , <nl> + const std : : vector < int > & parent_node_ids ) { <nl> + CAFFE_ENFORCE ( ! frozen_ ) ; <nl> + CAFFE_ENFORCE ( ! parent_node_ids . empty ( ) ) ; <nl> + CAFFE_ENFORCE ( nodes_ . count ( child_node_id ) ) ; <nl> + for ( auto node_id : parent_node_ids ) { <nl> + CAFFE_ENFORCE ( nodes_ . count ( node_id ) ) ; <nl> + } <nl> + CAFFE_ENFORCE ( ! parents_ . count ( child_node_id ) ) ; <nl> + <nl> + auto * child_task = nodes_ [ child_node_id ] . get ( ) ; <nl> + auto child_device = child_task - > GetDeviceOption ( ) ; <nl> + <nl> + std : : vector < AsyncTaskFuture * > parent_futures ; <nl> + for ( auto node_id : parent_node_ids ) { <nl> + parents_ [ child_node_id ] . insert ( node_id ) ; <nl> + children_ [ node_id ] . insert ( child_node_id ) ; <nl> + parent_futures . push_back ( & nodes_ [ node_id ] - > GetFuture ( ) ) ; <nl> + } <nl> + <nl> + AsyncTaskFuture * parents_future = nullptr ; <nl> + if ( parent_futures . size ( ) > 1 ) { <nl> + edge_futures_ . push_back ( <nl> + caffe2 : : make_unique < AsyncTaskFuture > ( parent_futures ) ) ; <nl> + parents_future = edge_futures_ . back ( ) . get ( ) ; <nl> + } else { <nl> + CAFFE_ENFORCE_EQ ( parent_futures . size ( ) , 1 ) ; <nl> + parents_future = parent_futures . back ( ) ; <nl> + } <nl> + <nl> + / / TODO : CUDA polling <nl> + parents_future - > SetCallback ( <nl> + [ this , child_task , child_device ] ( const AsyncTaskFuture * f ) { <nl> + CAFFE_ENFORCE ( f - > IsCompleted ( ) ) ; <nl> + if ( ! f - > IsFailed ( ) ) { <nl> + / / if we ' re in the correct thread pool and DFS scheduling is enabled , <nl> + / / immediately call task inline , otherwise send task into thread pool <nl> + auto * pool = helper_ - > GetPool ( child_device ) ; <nl> + if ( pool - > inThreadPool ( ) & & options_ . use_dfs_scheduling_ ) { <nl> + child_task - > Run ( options_ ) ; <nl> + } else { <nl> + pool - > run ( [ this , child_task ] ( ) { child_task - > Run ( options_ ) ; } ) ; <nl> + } <nl> + } else { <nl> + / / skip task execution and propagate error further <nl> + child_task - > GetFuture ( ) . SetCompleted ( f - > ErrorMessage ( ) . c_str ( ) ) ; <nl> + } <nl> + } ) ; <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + void AsyncTaskGraph : : FreezeGraph ( ) { <nl> + if ( frozen_ ) { <nl> + return ; <nl> + } <nl> + <nl> + CAFFE_ENFORCE ( ! run_future_ ) ; <nl> + CAFFE_ENFORCE ( root_tasks_ . empty ( ) ) ; <nl> + <nl> + std : : vector < AsyncTaskFuture * > final_futures ; <nl> + for ( auto & kv : nodes_ ) { <nl> + auto task_id = kv . first ; <nl> + auto * task = kv . second . get ( ) ; <nl> + <nl> + if ( parents_ [ task_id ] . empty ( ) ) { <nl> + root_tasks_ . push_back ( task ) ; <nl> + } <nl> + <nl> + if ( children_ [ task_id ] . empty ( ) ) { <nl> + auto & future = task - > GetFuture ( ) ; <nl> + final_futures . push_back ( & future ) ; <nl> + } <nl> + } <nl> + <nl> + CAFFE_ENFORCE ( ! root_tasks_ . empty ( ) ) ; <nl> + CAFFE_ENFORCE ( ! final_futures . empty ( ) ) ; <nl> + <nl> + run_future_ = caffe2 : : make_unique < AsyncTaskFuture > ( final_futures ) ; <nl> + <nl> + frozen_ = true ; <nl> + } <nl> + <nl> + AsyncTaskFuture * AsyncTaskGraph : : ExecuteGraph ( ) { <nl> + CAFFE_ENFORCE ( frozen_ ) ; <nl> + CAFFE_ENFORCE ( run_future_ & & ! run_future_ - > IsCompleted ( ) ) ; <nl> + <nl> + / / TODO : run root tasks inline in inference mode <nl> + for ( auto * task : root_tasks_ ) { <nl> + auto task_device = task - > GetDeviceOption ( ) ; <nl> + helper_ - > GetPool ( task_device ) - > run ( [ this , task ] ( ) { task - > Run ( options_ ) ; } ) ; <nl> + } <nl> + <nl> + return run_future_ . get ( ) ; <nl> + } <nl> + <nl> + AsyncTaskFuture * AsyncTaskGraph : : GetFuture ( ) { <nl> + CAFFE_ENFORCE ( frozen_ ) ; <nl> + return run_future_ . get ( ) ; <nl> + } <nl> + <nl> + void AsyncTaskGraph : : Reset ( ) { <nl> + CAFFE_ENFORCE ( frozen_ ) ; <nl> + for ( auto & kv : nodes_ ) { <nl> + kv . second - > Reset ( ) ; <nl> + } <nl> + for ( auto & future : edge_futures_ ) { <nl> + future - > ResetState ( ) ; <nl> + } <nl> + if ( run_future_ ) { <nl> + run_future_ - > ResetState ( ) ; <nl> + } <nl> + } <nl> + <nl> + } ; / / namespace caffe2 <nl> new file mode 100644 <nl> index 000000000000 . . 8ccec923ea61 <nl> mmm / dev / null <nl> ppp b / caffe2 / core / net_async_task_graph . h <nl> <nl> + # ifndef CAFFE2_NET_ASYNC_TASK_GRAPH_H <nl> + # define CAFFE2_NET_ASYNC_TASK_GRAPH_H <nl> + <nl> + # include " caffe2 / core / net_async_base . h " <nl> + # include " caffe2 / core / net_async_task . h " <nl> + # include " caffe2 / core / net_async_task_future . h " <nl> + # include " caffe2 / core / operator . h " <nl> + <nl> + namespace caffe2 { <nl> + <nl> + / / AsyncTaskGraph represents an execution of a net , it owns the tasks and <nl> + / / associated futures , sets up future callbacks and propagates errors . <nl> + / / Usage steps : <nl> + / / - Adding graph nodes and edges through CreateNode / AddDependency ; <nl> + / / - Freezing the graph ( FreezeGraph ) , after the freezing a future <nl> + / / can be obtained using GetFuture ; <nl> + / / - Execution of the graph is scheduled through ExecuteGraph , after each <nl> + / / execution Reset must be called to prepare the graph for the next run <nl> + <nl> + class AsyncTaskGraphBase { <nl> + public : <nl> + virtual bool CreateNode ( <nl> + int node_id , <nl> + const std : : vector < OperatorBase * > & ops ) = 0 ; <nl> + <nl> + virtual bool AddDependency ( <nl> + int child_node_id , <nl> + const std : : vector < int > & parent_node_ids ) = 0 ; <nl> + <nl> + virtual void FreezeGraph ( ) = 0 ; <nl> + <nl> + virtual AsyncTaskFuture * ExecuteGraph ( ) = 0 ; <nl> + <nl> + virtual AsyncTaskFuture * GetFuture ( ) = 0 ; <nl> + <nl> + virtual void Reset ( ) = 0 ; <nl> + <nl> + virtual ~ AsyncTaskGraphBase ( ) noexcept { } <nl> + } ; <nl> + <nl> + class AsyncTaskGraph : public AsyncTaskGraphBase { <nl> + public : <nl> + AsyncTaskGraph ( ExecutorHelper * helper , const ExecutionOptions & options ) ; <nl> + <nl> + bool CreateNode ( int node_id , const std : : vector < OperatorBase * > & ops ) override ; <nl> + <nl> + bool AddDependency ( int child_node_id , const std : : vector < int > & parent_node_ids ) <nl> + override ; <nl> + <nl> + void FreezeGraph ( ) override ; <nl> + <nl> + AsyncTaskFuture * ExecuteGraph ( ) override ; <nl> + <nl> + AsyncTaskFuture * GetFuture ( ) override ; <nl> + <nl> + void Reset ( ) override ; <nl> + <nl> + private : <nl> + / / used to , e . g . , get access to executor ' s thread pools <nl> + / / TODO : pass tracer and counters through ExecutorHelper <nl> + ExecutorHelper * helper_ ; <nl> + ExecutionOptions options_ ; <nl> + <nl> + bool frozen_ ; <nl> + <nl> + std : : unordered_map < int , std : : unique_ptr < AsyncTask > > nodes_ ; <nl> + std : : unordered_map < int , std : : unordered_set < int > > parents_ ; <nl> + std : : unordered_map < int , std : : unordered_set < int > > children_ ; <nl> + std : : vector < std : : unique_ptr < AsyncTaskFuture > > edge_futures_ ; <nl> + <nl> + std : : vector < AsyncTask * > root_tasks_ ; <nl> + <nl> + std : : unique_ptr < AsyncTaskFuture > run_future_ ; <nl> + } ; <nl> + <nl> + } / / namespace caffe2 <nl> + <nl> + # endif / / CAFFE2_NET_ASYNC_TASK_GRAPH_H <nl> new file mode 100644 <nl> index 000000000000 . . b9a9f0869f72 <nl> mmm / dev / null <nl> ppp b / caffe2 / core / net_parallel . cc <nl> <nl> + # include " caffe2 / core / net_parallel . h " <nl> + <nl> + # include " caffe2 / core / operator . h " <nl> + <nl> + # include < sstream > <nl> + <nl> + C10_DEFINE_string ( <nl> + caffe2_task_graph_engine , <nl> + " futures " , <nl> + " Task graph engine type used by net executor " ) ; <nl> + <nl> + namespace caffe2 { <nl> + <nl> + ParallelNet : : ParallelNet ( <nl> + const std : : shared_ptr < const NetDef > & net_def , <nl> + Workspace * ws ) <nl> + : NetBase ( net_def , ws ) , options_ ( net_def ) , run_future_ ( nullptr ) { <nl> + num_workers_ = net_def - > num_workers ( ) ; <nl> + CAFFE_ENFORCE_GT ( <nl> + num_workers_ , 0 , " Expected positive number of worker threads " ) ; <nl> + <nl> + helper_ = caffe2 : : make_unique < ParallelNetExecutorHelper > ( this ) ; <nl> + task_graph_ = TaskGraphRegistry ( ) - > Create ( <nl> + FLAGS_caffe2_task_graph_engine , helper_ . get ( ) , options_ ) ; <nl> + <nl> + / / initialize operators <nl> + operator_nodes_ = dag_utils : : prepareOperatorNodes ( net_def , ws ) ; <nl> + operators_ . reserve ( operator_nodes_ . size ( ) ) ; <nl> + for ( const auto & node : operator_nodes_ ) { <nl> + auto op = node . operator_ . get ( ) ; <nl> + op - > SetExecutorHelper ( helper_ . get ( ) ) ; <nl> + operators_ . push_back ( op ) ; <nl> + } <nl> + <nl> + / / compute chains <nl> + / / TODO : inference mode for chaining <nl> + auto execution_chains = dag_utils : : computeChains ( operator_nodes_ ) ; <nl> + std : : vector < std : : vector < int > > chains ; <nl> + chains . reserve ( execution_chains . size ( ) ) ; <nl> + for ( const auto & kv : execution_chains ) { <nl> + chains . push_back ( kv . second ) ; <nl> + } <nl> + auto chain_nodes = dag_utils : : prepareChainGraphNodes ( operator_nodes_ , chains ) ; <nl> + CAFFE_ENFORCE_EQ ( chains . size ( ) , chain_nodes . size ( ) ) ; <nl> + <nl> + / / disable unused events <nl> + for ( const auto & chain : chains ) { <nl> + for ( const auto & op_id : chain ) { <nl> + if ( op_id = = chain . back ( ) | | op_id = = chain . front ( ) ) { <nl> + continue ; <nl> + } <nl> + auto op = operators_ [ op_id ] ; <nl> + if ( IsCPUDeviceType ( op - > device_option ( ) . device_type ( ) ) & & <nl> + op - > HasAsyncPart ( ) ) { <nl> + continue ; <nl> + } <nl> + op - > DisableEvent ( ) ; <nl> + } <nl> + } <nl> + <nl> + / / initialize task graph <nl> + for ( auto chain_id = 0 ; chain_id < chains . size ( ) ; + + chain_id ) { <nl> + std : : vector < OperatorBase * > ops ; <nl> + ops . reserve ( chains [ chain_id ] . size ( ) ) ; <nl> + for ( auto op_id : chains [ chain_id ] ) { <nl> + ops . push_back ( operators_ [ op_id ] ) ; <nl> + } <nl> + CAFFE_ENFORCE ( task_graph_ - > CreateNode ( chain_id , ops ) ) ; <nl> + } <nl> + for ( auto chain_id = 0 ; chain_id < chain_nodes . size ( ) ; + + chain_id ) { <nl> + if ( ! chain_nodes [ chain_id ] . parents_ . empty ( ) ) { <nl> + CAFFE_ENFORCE ( <nl> + task_graph_ - > AddDependency ( chain_id , chain_nodes [ chain_id ] . parents_ ) ) ; <nl> + } <nl> + } <nl> + <nl> + / / Freeze graph and initialize graph execution future <nl> + task_graph_ - > FreezeGraph ( ) ; <nl> + run_future_ = task_graph_ - > GetFuture ( ) ; <nl> + run_future_ - > SetCallback ( [ this ] ( const AsyncTaskFuture * / * unused * / ) { <nl> + StopAllObservers ( ) ; <nl> + finishRun ( ) ; <nl> + } ) ; <nl> + <nl> + LOG ( INFO ) < < " Initialized parallel net : ' " < < Name ( ) <nl> + < < " ' , # ops : " < < net_def - > op_size ( ) <nl> + < < " , # chains : " < < chains . size ( ) < < " , # workers : " < < num_workers_ <nl> + < < " , dfs scheduling : " < < options_ . use_dfs_scheduling_ <nl> + < < " , task graph engine : " < < FLAGS_caffe2_task_graph_engine ; <nl> + } <nl> + <nl> + bool ParallelNet : : RunAsync ( ) { <nl> + reset ( ) ; <nl> + StartAllObservers ( ) ; <nl> + <nl> + try { <nl> + task_graph_ - > ExecuteGraph ( ) ; <nl> + } catch ( const std : : exception & ) { <nl> + StopAllObservers ( ) ; <nl> + return false ; <nl> + } <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + void ParallelNet : : Wait ( ) { <nl> + CAFFE_ENFORCE ( run_future_ ) ; <nl> + run_future_ - > Wait ( ) ; <nl> + } <nl> + <nl> + void ParallelNet : : reset ( ) { <nl> + task_graph_ - > Reset ( ) ; <nl> + } <nl> + <nl> + bool ParallelNet : : handleRunError ( ) { <nl> + CAFFE_ENFORCE ( run_future_ & & run_future_ - > IsCompleted ( ) ) ; <nl> + / / TODO : throw saved exceptions <nl> + if ( run_future_ - > IsFailed ( ) ) { <nl> + LOG ( ERROR ) < < " Failed parallel run ( " < < Name ( ) <nl> + < < " ) : " < < run_future_ - > ErrorMessage ( ) ; <nl> + } <nl> + return ! run_future_ - > IsFailed ( ) ; <nl> + } <nl> + <nl> + TaskThreadPoolBase * ParallelNet : : poolGetter ( <nl> + PoolsMap & pools , <nl> + int device_type , <nl> + int device_id , <nl> + int pool_size ) { <nl> + std : : unique_lock < std : : mutex > pools_lock ( pools_mutex_ ) ; <nl> + auto pool = pools [ device_id ] [ pool_size ] ; <nl> + if ( ! pool ) { <nl> + pool = ThreadPoolRegistry ( ) - > Create ( <nl> + DeviceTypeName ( device_type ) , <nl> + device_id , <nl> + pool_size , <nl> + options_ . use_per_net_pools_ ) ; <nl> + pools [ device_id ] [ pool_size ] = pool ; <nl> + } <nl> + return pool . get ( ) ; <nl> + } <nl> + <nl> + TaskThreadPoolBase * ParallelNet : : Pool ( const DeviceOption & device_option ) { <nl> + if ( options_ . use_single_pool_ ) { <nl> + return poolGetter ( cpu_pools_ , PROTO_CPU , - 1 , num_workers_ ) ; <nl> + } <nl> + const auto device_type = device_option . device_type ( ) ; <nl> + if ( IsCPUDeviceType ( device_type ) ) { <nl> + auto numa_node_id = - 1 ; <nl> + if ( device_option . has_numa_node_id ( ) ) { <nl> + numa_node_id = device_option . numa_node_id ( ) ; <nl> + CAFFE_ENFORCE_GE ( numa_node_id , 0 , " Invalid NUMA node id : " , numa_node_id ) ; <nl> + } <nl> + CAFFE_ENFORCE_LT ( <nl> + numa_node_id , <nl> + FLAGS_caffe2_net_async_max_numa_nodes , <nl> + " Invalid NUMA node id : " , <nl> + numa_node_id ) ; <nl> + return poolGetter ( cpu_pools_ , device_type , numa_node_id , num_workers_ ) ; <nl> + } else if ( IsGPUDeviceType ( device_type ) ) { <nl> + auto gpu_id = device_option . device_id ( ) ; <nl> + CAFFE_ENFORCE ( <nl> + gpu_id > = 0 & & gpu_id < FLAGS_caffe2_net_async_max_gpus , <nl> + " Invalid GPU id : " + caffe2 : : to_string ( gpu_id ) ) ; <nl> + return poolGetter ( gpu_pools_ , device_type , gpu_id , num_workers_ ) ; <nl> + } else { <nl> + CAFFE_THROW ( " Unsupported device type " + caffe2 : : to_string ( device_type ) ) ; <nl> + } <nl> + } <nl> + <nl> + bool ParallelNet : : SupportsAsync ( ) { <nl> + return true ; <nl> + } <nl> + <nl> + void ParallelNet : : finishRun ( ) { } <nl> + <nl> + std : : vector < OperatorBase * > ParallelNet : : GetOperators ( ) const { <nl> + return operators_ ; <nl> + } <nl> + <nl> + std : : shared_ptr < AsyncTaskGraphBase > GetAsyncTaskGraph ( <nl> + ExecutorHelper * helper , <nl> + const ExecutionOptions & options ) { <nl> + return std : : make_shared < AsyncTaskGraph > ( helper , options ) ; <nl> + } <nl> + <nl> + C10_DEFINE_SHARED_REGISTRY ( <nl> + TaskGraphRegistry , <nl> + AsyncTaskGraphBase , <nl> + ExecutorHelper * , <nl> + const ExecutionOptions & ) ; <nl> + <nl> + C10_REGISTER_CREATOR ( TaskGraphRegistry , futures , GetAsyncTaskGraph ) ; <nl> + <nl> + REGISTER_NET ( parallel , ParallelNet ) ; <nl> + <nl> + } / / namespace caffe2 <nl> new file mode 100644 <nl> index 000000000000 . . df5b6d8a4efb <nl> mmm / dev / null <nl> ppp b / caffe2 / core / net_parallel . h <nl> <nl> + # ifndef CAFFE2_CORE_NET_PARALLEL_H <nl> + # define CAFFE2_CORE_NET_PARALLEL_H <nl> + <nl> + # include " caffe2 / core / net_async_base . h " <nl> + # include " caffe2 / core / net_async_task_graph . h " <nl> + <nl> + C10_DECLARE_string ( caffe2_task_graph_engine ) ; <nl> + <nl> + namespace caffe2 { <nl> + <nl> + class ParallelNetExecutorHelper ; <nl> + <nl> + class CAFFE2_API ParallelNet : public NetBase { <nl> + public : <nl> + ParallelNet ( const std : : shared_ptr < const NetDef > & net_def , Workspace * ws ) ; <nl> + <nl> + bool RunAsync ( ) override ; <nl> + void Wait ( ) override ; <nl> + <nl> + bool SupportsAsync ( ) override ; <nl> + std : : vector < OperatorBase * > GetOperators ( ) const override ; <nl> + <nl> + TaskThreadPoolBase * Pool ( const DeviceOption & device_option ) ; <nl> + <nl> + protected : <nl> + bool handleRunError ( ) override ; <nl> + virtual void finishRun ( ) ; <nl> + virtual void reset ( ) ; <nl> + <nl> + ExecutionOptions options_ ; <nl> + int num_workers_ ; <nl> + <nl> + std : : unique_ptr < ParallelNetExecutorHelper > helper_ ; <nl> + std : : shared_ptr < AsyncTaskGraphBase > task_graph_ ; <nl> + AsyncTaskFuture * run_future_ ; <nl> + <nl> + std : : vector < dag_utils : : OperatorNode > operator_nodes_ ; <nl> + std : : vector < OperatorBase * > operators_ ; <nl> + <nl> + std : : mutex pools_mutex_ ; <nl> + typedef std : : unordered_map < <nl> + int , <nl> + std : : unordered_map < int , std : : shared_ptr < TaskThreadPoolBase > > > <nl> + PoolsMap ; <nl> + PoolsMap cpu_pools_ ; <nl> + PoolsMap gpu_pools_ ; <nl> + TaskThreadPoolBase * <nl> + poolGetter ( PoolsMap & pools , int device_type , int device_id , int pool_size ) ; <nl> + <nl> + friend class ParallelNetExecutorHelper ; <nl> + C10_DISABLE_COPY_AND_ASSIGN ( ParallelNet ) ; <nl> + } ; <nl> + <nl> + C10_DECLARE_SHARED_REGISTRY ( <nl> + TaskGraphRegistry , <nl> + AsyncTaskGraphBase , <nl> + ExecutorHelper * , <nl> + const ExecutionOptions & ) ; <nl> + <nl> + std : : shared_ptr < AsyncTaskGraphBase > GetAsyncTaskGraph ( <nl> + ExecutorHelper * helper , <nl> + const ExecutionOptions & options ) ; <nl> + <nl> + class ParallelNetExecutorHelper : public ExecutorHelper { <nl> + public : <nl> + explicit ParallelNetExecutorHelper ( ParallelNet * net ) : net_ ( net ) { } <nl> + TaskThreadPoolBase * GetPool ( const DeviceOption & option ) const override { <nl> + return net_ - > Pool ( option ) ; <nl> + } <nl> + <nl> + private : <nl> + ParallelNet * net_ ; <nl> + } ; <nl> + <nl> + } / / namespace caffe2 <nl> + <nl> + # endif / / CAFFE2_CORE_NET_PARALLEL_H <nl> mmm a / caffe2 / python / test / executor_test . py <nl> ppp b / caffe2 / python / test / executor_test . py <nl> <nl> import unittest <nl> <nl> <nl> - EXECUTORS = [ " async_scheduling " , " dag " , " async_dag " ] <nl> + EXECUTORS = [ " parallel " , " async_scheduling " ] <nl> ITERATIONS = 1 <nl> <nl> <nl>
Back out " Revert D13043261 : [ caffe2 ] Task graph and task future abstractions in executor "
pytorch/pytorch
e9cd7816819ea7af3f2236d9a1672d165c19f1f3
2018-12-11T03:30:58Z
deleted file mode 100644 <nl> index e4068f0440a . . 00000000000 <nl> mmm a / hphp / test / slow / ext_gd / imageaffine . php . expect <nl> ppp / dev / null <nl> <nl> - string ( 32 ) " 4630bed0dfc139cb0850823ff24d38ed " <nl> - string ( 32 ) " df7fe2c5e24920c5869b48136f284d0e " <nl> - string ( 32 ) " 3fd23a5c6251eadb9432df7252b58d5a " <nl> - string ( 32 ) " 3fd23a5c6251eadb9432df7252b58d5a " <nl> - string ( 32 ) " dadadb09d09b9618eb7a17bf0541304a " <nl> - string ( 32 ) " 25e0e0cd2bffe4f7195055d753c3eaac " <nl> - string ( 32 ) " 97e4dbcf9221a142ebf07446ee3d03af " <nl> - string ( 32 ) " 3609b761e7ebcb7276cb59bf39e539ad " <nl> - string ( 32 ) " ae897deaf85f71ac90952cb9b93d25fc " <nl> - string ( 32 ) " 4053e0ab992b46a9f3c5f532d2b08808 " <nl> new file mode 100644 <nl> index 00000000000 . . f696515f7e5 <nl> mmm / dev / null <nl> ppp b / hphp / test / slow / ext_gd / imageaffine . php . expectregex <nl> <nl> + string \ ( 32 \ ) \ " 4630bed0dfc139cb0850823ff24d38ed \ " <nl> + string \ ( 32 \ ) \ " df7fe2c5e24920c5869b48136f284d0e \ " <nl> + string \ ( 32 \ ) \ " 3fd23a5c6251eadb9432df7252b58d5a \ " <nl> + string \ ( 32 \ ) \ " 3fd23a5c6251eadb9432df7252b58d5a \ " <nl> + string \ ( 32 \ ) \ " ( dadadb09d09b9618eb7a17bf0541304a | 36e5b9b565ae32650ca9e420503772ed ) \ " <nl> + string \ ( 32 \ ) \ " ( 25e0e0cd2bffe4f7195055d753c3eaac | b187d992f10ba562b9e716525dd84c4a ) \ " <nl> + string \ ( 32 \ ) \ " 97e4dbcf9221a142ebf07446ee3d03af \ " <nl> + string \ ( 32 \ ) \ " 3609b761e7ebcb7276cb59bf39e539ad \ " <nl> + string \ ( 32 \ ) \ " ( ae897deaf85f71ac90952cb9b93d25fc | b6b2d5f1c64bd5592e6a6672282f827f ) \ " <nl> + string \ ( 32 \ ) \ " ( 4053e0ab992b46a9f3c5f532d2b08808 | b57191ca3a050102af7a02c57148c19d ) \ " <nl>
test : FMA instructions create alternative result in imageaffine . php
facebook/hhvm
9f8011e2cc3e45b643837c3a30ac30f138f74cd6
2017-01-19T17:02:48Z
mmm a / include / grpcpp / impl / codegen / proto_utils . h <nl> ppp b / include / grpcpp / impl / codegen / proto_utils . h <nl> Status GenericDeserialize ( ByteBuffer * buffer , <nl> if ( ! reader . status ( ) . ok ( ) ) { <nl> return reader . status ( ) ; <nl> } <nl> - : : grpc : : protobuf : : io : : CodedInputStream decoder ( & reader ) ; <nl> - decoder . SetTotalBytesLimit ( INT_MAX , INT_MAX ) ; <nl> - if ( ! msg - > ParseFromCodedStream ( & decoder ) ) { <nl> + if ( ! msg - > ParseFromZeroCopyStream ( & reader ) ) { <nl> result = Status ( StatusCode : : INTERNAL , msg - > InitializationErrorString ( ) ) ; <nl> } <nl> - if ( ! decoder . ConsumedEntireMessage ( ) ) { <nl> - result = Status ( StatusCode : : INTERNAL , " Did not read entire message " ) ; <nl> - } <nl> } <nl> buffer - > Clear ( ) ; <nl> return result ; <nl>
Directly use the ZeroCopyInputStream for grpc : : GenericDeserialize .
grpc/grpc
eadd5ea11093a3c3811b47dd15005df031719f79
2019-08-13T02:44:56Z
mmm a / include / swift / AST / Attr . def <nl> ppp b / include / swift / AST / Attr . def <nl> TYPE_ATTR ( cc ) <nl> TYPE_ATTR ( thin ) <nl> TYPE_ATTR ( objc_block ) <nl> TYPE_ATTR ( auto_closure ) <nl> + TYPE_ATTR ( inout ) <nl> + <nl> + / / SIL - specific attributes <nl> + TYPE_ATTR ( sil_self ) <nl> + TYPE_ATTR ( local_storage ) <nl> <nl> <nl> ATTR ( assignment ) <nl> ATTR ( infix ) <nl> ATTR ( resilient ) <nl> ATTR ( fragile ) <nl> ATTR ( born_fragile ) <nl> - BOTH_ATTR ( inout ) <nl> BOTH_ATTR ( noreturn ) <nl> ATTR ( asmname ) <nl> ATTR ( prefix ) <nl> ATTR ( postfix ) <nl> ATTR ( objc ) <nl> ATTR ( iboutlet ) <nl> ATTR ( ibaction ) <nl> - BOTH_ATTR ( local_storage ) <nl> ATTR ( transparent ) <nl> BOTH_ATTR ( weak ) <nl> BOTH_ATTR ( unowned ) <nl> <nl> - / / SIL - specific attributes <nl> - BOTH_ATTR ( sil_self ) <nl> <nl> / / Axle - specific attributes <nl> ATTR ( kernel ) <nl> mmm a / include / swift / AST / Attr . h <nl> ppp b / include / swift / AST / Attr . h <nl> class DeclAttributes { <nl> return true ; <nl> } <nl> <nl> - bool isInOut ( ) const { return has ( AK_inout ) ; } <nl> bool isNoReturn ( ) const { return has ( AK_noreturn ) ; } <nl> bool isAssignment ( ) const { return has ( AK_assignment ) ; } <nl> bool isConversion ( ) const { return has ( AK_conversion ) ; } <nl> class DeclAttributes { <nl> bool isIBOutlet ( ) const { return has ( AK_iboutlet ) ; } <nl> bool isIBAction ( ) const { return has ( AK_ibaction ) ; } <nl> bool isClassProtocol ( ) const { return has ( AK_class_protocol ) ; } <nl> - bool isLocalStorage ( ) const { return has ( AK_local_storage ) ; } <nl> bool isWeak ( ) const { return has ( AK_weak ) ; } <nl> bool isUnowned ( ) const { return has ( AK_unowned ) ; } <nl> bool isExported ( ) const { return has ( AK_exported ) ; } <nl> - bool isSILSelf ( ) const { return has ( AK_sil_self ) ; } <nl> bool isKernel ( ) const { return has ( AK_kernel ) ; } <nl> bool isVertex ( ) const { return has ( AK_vertex ) ; } <nl> bool isFragment ( ) const { return has ( AK_fragment ) ; } <nl> mmm a / lib / AST / ASTPrinter . cpp <nl> ppp b / lib / AST / ASTPrinter . cpp <nl> void PrintAST : : printAttributes ( const DeclAttributes & Attrs ) { <nl> case Resilience : : InherentlyFragile : AP . next ( ) < < " born_fragile " ; break ; <nl> case Resilience : : Resilient : AP . next ( ) < < " resilient " ; break ; <nl> } <nl> - if ( Attrs . isInOut ( ) ) <nl> - AP . next ( ) < < " inout " ; <nl> if ( Attrs . isNoReturn ( ) ) <nl> AP . next ( ) < < " noreturn " ; <nl> if ( ! Attrs . AsmName . empty ( ) ) <nl> mmm a / lib / Parse / ParseDecl . cpp <nl> ppp b / lib / Parse / ParseDecl . cpp <nl> bool Parser : : parseAttribute ( DeclAttributes & Attributes , bool OldStyle ) { <nl> / / Handle any attribute - specific processing logic . <nl> switch ( attr ) { <nl> default : break ; <nl> - case AK_local_storage : <nl> - case AK_sil_self : <nl> - if ( ! isInSILMode ( ) ) / / SIL ' s ' local_storage ' type attribute . <nl> - diagnose ( Loc , diag : : only_allowed_in_sil , " local_storage " ) ; <nl> - break ; <nl> - <nl> / / Ownership attributes . <nl> case AK_weak : <nl> case AK_unowned : <nl> mmm a / lib / Sema / TypeCheckDecl . cpp <nl> ppp b / lib / Sema / TypeCheckDecl . cpp <nl> static void validateAttributes ( TypeChecker & TC , Decl * D ) { <nl> } <nl> <nl> static const AttrKind InvalidAttrs [ ] = { <nl> - AK_inout , AK_exported , AK_noreturn , AK_local_storage <nl> + AK_exported , AK_noreturn <nl> } ; <nl> <nl> for ( AttrKind K : InvalidAttrs ) { <nl>
inout , localstorage and silself are type attributes , not decl attributes .
apple/swift
e341dd94e9e1362438a72ceceb2a5e55475ffb96
2013-10-13T04:14:03Z
mmm a / lib / renderer / override . js <nl> ppp b / lib / renderer / override . js <nl> var BrowserWindowProxy = ( function ( ) { <nl> } <nl> <nl> function BrowserWindowProxy ( guestId1 ) { <nl> - this . guestId = guestId1 <nl> + Object . defineProperty ( this , ' guestId ' , { <nl> + configurable : false , <nl> + enumerable : true , <nl> + writeable : false , <nl> + value : guestId1 <nl> + } ) <nl> + <nl> this . closed = false <nl> ipcRenderer . once ( ' ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_CLOSED_ ' + this . guestId , ( ) = > { <nl> BrowserWindowProxy . remove ( this . guestId ) <nl>
Make BrowserWindowProxy guestId non - writeable
electron/electron
2f93735909af3f451c42d35fe7dde09bc1d30ccb
2016-06-09T20:41:42Z
mmm a / stdlib / public / core / String . swift <nl> ppp b / stdlib / public / core / String . swift <nl> extension String { <nl> @ inline ( __always ) / / Eliminate dynamic type check when possible <nl> internal mutating func append < S : StringProtocol > ( _ other : S ) { <nl> if let contigBytes = other as ? _HasContiguousBytes { <nl> - contigBytes . withUnsafeBytes { self . _guts . append ( $ 0 . _asUInt8 ) } <nl> + contigBytes . withUnsafeBytes { <nl> + / / TODO ( UTF8 perf ) : track ASCIIness <nl> + let immortalBytes = _StringGuts ( $ 0 . _asUInt8 , isKnownASCII : false ) <nl> + self . _guts . append ( immortalBytes ) <nl> + } <nl> return <nl> } <nl> <nl> extension Sequence where Element : StringProtocol { <nl> / / / - Returns : A single , concatenated string . <nl> @ _specialize ( where Self = = Array < Substring > ) <nl> @ _specialize ( where Self = = Array < String > ) <nl> - / / TODO ( UTF8 merge ) : replace String ( ) with " " <nl> - public func joined ( separator : String = String ( ) ) - > String { <nl> + public func joined ( separator : String = " " ) - > String { <nl> return _joined ( separator : separator ) <nl> } <nl> <nl> extension BidirectionalCollection where Iterator . Element = = String { <nl> / / / in this sequence . The default separator is an empty string . <nl> / / / - Returns : A single , concatenated string . <nl> @ _specialize ( where Self = = Array < String > ) <nl> - / / TODO ( UTF8 merge ) : replace String ( ) with " " <nl> - public func joined ( separator : String = String ( ) ) - > String { <nl> + public func joined ( separator : String = " " ) - > String { <nl> return _joined ( separator : separator ) <nl> } <nl> } <nl> mmm a / stdlib / public / core / StringGuts . swift <nl> ppp b / stdlib / public / core / StringGuts . swift <nl> extension _StringGuts { <nl> @ inline ( __always ) get { return _object . isASCII } <nl> } <nl> <nl> - @ inlinable <nl> - internal var capacity : Int ? { <nl> - / / TODO : Should small strings return their capacity too ? <nl> - guard _object . hasNativeStorage else { return nil } <nl> - return _object . nativeStorage . capacity <nl> + internal var nativeCapacity : Int ? { <nl> + guard hasNativeStorage else { return nil } <nl> + return _object . nativeStorage . capacity <nl> + } <nl> + <nl> + internal var nativeUnusedCapacity : Int ? { <nl> + guard hasNativeStorage else { return nil } <nl> + return _object . nativeStorage . unusedCapacity <nl> + } <nl> + <nl> + / / If natively stored and uniquely referenced , return the storage ' s total <nl> + / / capacity . Otherwise , nil . <nl> + internal var uniqueNativeCapacity : Int ? { <nl> + @ inline ( __always ) mutating get { <nl> + guard isUniqueNative else { return nil } <nl> + return _object . nativeStorage . capacity <nl> + } <nl> } <nl> + <nl> + / / If natively stored and uniquely referenced , return the storage ' s spare <nl> + / / capacity . Otherwise , nil . <nl> + internal var uniqueNativeUnusedCapacity : Int ? { <nl> + @ inline ( __always ) mutating get { <nl> + guard isUniqueNative else { return nil } <nl> + return _object . nativeStorage . unusedCapacity <nl> + } <nl> + } <nl> + <nl> + @ inlinable <nl> + internal var hasNativeStorage : Bool { return _object . hasNativeStorage } <nl> } <nl> <nl> / / <nl> extension _StringGuts { <nl> <nl> / / Append <nl> extension _StringGuts { <nl> + @ usableFromInline / / @ testable <nl> + internal var isUniqueNative : Bool { <nl> + @ inline ( __always ) mutating get { <nl> + / / Note : mutating so that self is ` inout ` . <nl> + guard hasNativeStorage else { return false } <nl> + defer { _fixLifetime ( self ) } <nl> + var bits : UInt = _object . largeAddressBits <nl> + return _isUnique_native ( & bits ) <nl> + } <nl> + } <nl> + <nl> internal mutating func reserveCapacity ( _ n : Int ) { <nl> / / Check if there ' s nothing to do <nl> if n < = _SmallString . capacity { return } <nl> - if let currentCap = self . capacity , currentCap > = n { return } <nl> + if let currentCap = self . uniqueNativeCapacity , currentCap > = n { return } <nl> <nl> / / Grow <nl> - if isFastUTF8 { <nl> + self . grow ( n ) <nl> + } <nl> + <nl> + / / Grow to accomodate at least ` n ` code units <nl> + internal mutating func grow ( _ n : Int ) { <nl> + defer { self . _invariantCheck ( ) } <nl> + <nl> + _sanityCheck ( <nl> + self . uniqueNativeCapacity = = nil | | self . uniqueNativeCapacity ! < n ) <nl> + <nl> + if _fastPath ( isFastUTF8 ) { <nl> let storage = self . withFastUTF8 { <nl> _StringStorage . create ( initializingFrom : $ 0 , capacity : n ) <nl> } <nl> extension _StringGuts { <nl> return <nl> } <nl> <nl> - unimplemented_utf8 ( ) <nl> + _foreignGrow ( n ) <nl> + } <nl> + <nl> + @ inline ( never ) / / slow - path <nl> + internal mutating func _foreignGrow ( _ n : Int ) { <nl> + / / TODO ( UTF8 perf ) : skip the intermediary arrays <nl> + let selfUTF8 = Array ( String ( self ) . utf8 ) <nl> + selfUTF8 . withUnsafeBufferPointer { <nl> + self = _StringGuts ( _StringStorage . create ( <nl> + initializingFrom : $ 0 , capacity : n ) ) <nl> + } <nl> } <nl> <nl> internal mutating func append ( _ other : _StringGuts ) { <nl> + defer { self . _invariantCheck ( ) } <nl> + <nl> / / Try to form a small string if possible <nl> - if let smol = _SmallString ( base : self , appending : other ) { <nl> - self = _StringGuts ( smol ) <nl> - return <nl> + if ! hasNativeStorage { <nl> + if let smol = _SmallString ( base : self , appending : other ) { <nl> + self = _StringGuts ( smol ) <nl> + return <nl> + } <nl> } <nl> <nl> - if other . isFastUTF8 { <nl> - other . withFastUTF8 { self . append ( $ 0 ) } <nl> - return <nl> + / / See if we can accomodate without growing or copying . If we have <nl> + / / sufficient capacity , we do not need to grow , and we can skip the copy if <nl> + / / unique . Otherwise , growth is required . <nl> + let otherUTF8Count = other . utf8Count <nl> + let sufficientCapacity : Bool <nl> + if let unused = self . nativeUnusedCapacity , unused > = otherUTF8Count { <nl> + sufficientCapacity = true <nl> + } else { <nl> + sufficientCapacity = false <nl> } <nl> - _foreignAppend ( other ) <nl> - } <nl> - <nl> - internal mutating func append ( _ bufPtr : UnsafeBufferPointer < UInt8 > ) { <nl> - if _object . hasNativeStorage { <nl> - if _object . nativeStorage . unusedCapacity > = bufPtr . count { <nl> - / / TODO ( UTF8 perf ) : Uniqueness check and skip the reallocation <nl> + if ! self . isUniqueNative | | ! sufficientCapacity { <nl> + let totalCount = self . utf8Count + otherUTF8Count <nl> + <nl> + / / Non - unique storage : just make a copy of the appropriate size , otherwise <nl> + / / grow like an array . <nl> + let growthTarget : Int <nl> + if sufficientCapacity { <nl> + growthTarget = totalCount <nl> + } else { <nl> + growthTarget = Swift . max ( <nl> + totalCount , _growArrayCapacity ( nativeCapacity ? ? 0 ) ) <nl> } <nl> + self . grow ( growthTarget ) <nl> } <nl> <nl> - if _slowPath ( _object . isForeign ) { <nl> - _foreignAppend ( bufPtr ) <nl> - return <nl> - } <nl> + _sanityCheck ( self . uniqueNativeUnusedCapacity ! = nil , <nl> + " growth should produce uniqueness " ) <nl> <nl> - / / Grow into an appropriately sized storage <nl> - / / <nl> - / / TODO ( UTF8 ) : How do we want to grow ? Take current capacity into account ? <nl> - let storage = self . withFastUTF8 { <nl> - _StringStorage . create ( initializingFrom : $ 0 , andAppending : bufPtr ) <nl> + if other . isFastUTF8 { <nl> + other . withFastUTF8 { self . appendInPlace ( $ 0 ) } <nl> + return <nl> } <nl> - <nl> - / / TODO ( UTF8 ) : Track known ascii <nl> - self = _StringGuts ( storage ) <nl> - return <nl> + _foreignAppendInPlace ( other ) <nl> } <nl> <nl> - @ inline ( never ) / / slow - path <nl> - internal mutating func _foreignAppend ( _ bufPtr : UnsafeBufferPointer < UInt8 > ) { <nl> - _sanityCheck ( ! isFastUTF8 ) <nl> + internal mutating func appendInPlace ( _ other : UnsafeBufferPointer < UInt8 > ) { <nl> + self . _object . nativeStorage . appendInPlace ( other ) <nl> <nl> - / / TODO ( UTF8 perf ) : skip the intermediary arrays <nl> - let selfUTF8 = Array ( String ( self ) . utf8 ) <nl> - selfUTF8 . withUnsafeBufferPointer { <nl> - self = _StringGuts ( _StringStorage . create ( <nl> - initializingFrom : $ 0 , andAppending : bufPtr ) ) <nl> - } <nl> + / / We re - initialize from the modified storage to pick up new count , flags , <nl> + / / etc . <nl> + self = _StringGuts ( self . _object . nativeStorage ) <nl> } <nl> <nl> @ inline ( never ) / / slow - path <nl> - internal mutating func _foreignAppend ( _ other : _StringGuts ) { <nl> + internal mutating func _foreignAppendInPlace ( _ other : _StringGuts ) { <nl> _sanityCheck ( ! other . isFastUTF8 ) <nl> + _sanityCheck ( self . uniqueNativeUnusedCapacity ! = nil ) <nl> <nl> - / / TODO ( UTF8 perf ) : skip the intermediary arrays <nl> - let otherUTF8 = Array ( String ( other ) . utf8 ) <nl> - otherUTF8 . withUnsafeBufferPointer { <nl> - self . append ( $ 0 ) <nl> - } <nl> + var iter = String ( other ) . utf8 . makeIterator ( ) <nl> + self . _object . nativeStorage . appendInPlace ( & iter ) <nl> + <nl> + / / We re - initialize from the modified storage to pick up new count , flags , <nl> + / / etc . <nl> + self = _StringGuts ( self . _object . nativeStorage ) <nl> } <nl> } <nl> <nl> mmm a / stdlib / public / core / StringLegacy . swift <nl> ppp b / stdlib / public / core / StringLegacy . swift <nl> extension String { <nl> public init ( repeating repeatedValue : String , count : Int ) { <nl> precondition ( count > = 0 , " Negative count not allowed " ) <nl> guard count > 1 else { <nl> - / / TODO ( UTF8 merge ) : use string literal <nl> - self = count = = 0 ? String ( ) : repeatedValue <nl> + self = count = = 0 ? " " : repeatedValue <nl> return <nl> } <nl> <nl> mmm a / stdlib / public / core / StringRangeReplaceableCollection . swift <nl> ppp b / stdlib / public / core / StringRangeReplaceableCollection . swift <nl> extension String : RangeReplaceableCollection { <nl> public mutating func remove ( at i : Index ) - > Character { <nl> / / TODO ( UTF8 perf ) : Operate on storage directly , sliding down elements <nl> let c = self [ i ] <nl> - self . replaceSubrange ( i . . < i , with : String ( ) ) / / TODO ( UTF8 ) : empty literal <nl> + self . removeSubrange ( i . . < self . index ( after : i ) ) <nl> return c <nl> } <nl> <nl> extension String : RangeReplaceableCollection { <nl> / / / lower bounds of ` bounds ` must be valid indices of the string . <nl> public mutating func removeSubrange ( _ bounds : Range < Index > ) { <nl> / / TODO ( UTF8 perf ) : Operate on storage directly , sliding down elements <nl> + / / TODO ( UTF8 merge ) : replace with literal <nl> self . replaceSubrange ( bounds , with : String ( ) ) <nl> } <nl> <nl> extension String : RangeReplaceableCollection { <nl> / / / optimization when you ' re planning to grow the string again . The <nl> / / / default value is ` false ` . <nl> public mutating func removeAll ( keepingCapacity keepCapacity : Bool = false ) { <nl> - guard keepCapacity | | _guts . capacity ! = nil else { <nl> + guard keepCapacity | | _guts . uniqueNativeCapacity ! = nil else { <nl> self = String ( ) <nl> return <nl> } <nl> mmm a / stdlib / public / core / StringStorage . swift <nl> ppp b / stdlib / public / core / StringStorage . swift <nl> extension _AbstractStringStorage { <nl> @ objc ( _fastCStringContents ) <nl> final func _fastCStringContents ( ) - > UnsafePointer < CChar > ? { <nl> if let native = self as ? _StringStorage { <nl> + / / FIXME ( UTF8 ) : Need to check for interior nul <nl> return native . start . _asCChar <nl> } <nl> <nl> extension _AbstractStringStorage { <nl> @ _fixed_layout <nl> @ usableFromInline <nl> final internal class _StringStorage : _AbstractStringStorage { <nl> + / / The capacity of our allocation . Note that this includes the nul - terminator , <nl> + / / which is not available for overridding . <nl> @ nonobjc <nl> @ usableFromInline <nl> - internal var capacity : Int <nl> + internal var _realCapacity : Int <nl> <nl> @ nonobjc <nl> @ usableFromInline <nl> extension _StringStorage { <nl> _sanityCheck ( capacity > = count ) <nl> <nl> / / Reserve enough capacity for a trailing nul character <nl> - let capacity = 1 + Swift . max ( capacity , _SmallUTF8String . capacity ) <nl> - _sanityCheck ( capacity > count ) <nl> + let desiredCapacity = 1 + Swift . max ( capacity , _SmallUTF8String . capacity ) <nl> + _sanityCheck ( desiredCapacity > count ) <nl> <nl> let storage = Builtin . allocWithTailElems_1 ( <nl> _StringStorage . self , <nl> - capacity . _builtinWordValue , UInt8 . self ) <nl> + desiredCapacity . _builtinWordValue , UInt8 . self ) <nl> <nl> let storageAddr = UnsafeRawPointer ( <nl> Builtin . bridgeToRawPointer ( storage ) ) <nl> extension _StringStorage { <nl> storageAddr + _stdlib_malloc_size ( storageAddr ) <nl> ) . assumingMemoryBound ( to : UInt8 . self ) <nl> <nl> - storage . capacity = endAddr - storage . start <nl> + storage . _realCapacity = endAddr - storage . start <nl> storage . _count = count <nl> _sanityCheck ( storage . capacity > = capacity ) <nl> - storage . unusedStorage [ 0 ] = 0 / / nul - terminated <nl> + storage . terminator . pointee = 0 / / nul - terminated <nl> storage . _invariantCheck ( ) <nl> <nl> return storage <nl> extension _StringStorage { <nl> capacity : capacity , count : bufPtr . count ) <nl> let addr = bufPtr . baseAddress . _unsafelyUnwrappedUnchecked <nl> storage . mutableStart . initialize ( from : addr , count : bufPtr . count ) <nl> + storage . _invariantCheck ( ) <nl> return storage <nl> } <nl> <nl> extension _StringStorage { <nl> return _StringStorage . create ( <nl> initializingFrom : bufPtr , capacity : bufPtr . count ) <nl> } <nl> - <nl> - @ nonobjc <nl> - internal static func create ( <nl> - initializingFrom bufPtr : UnsafeBufferPointer < UInt8 > , <nl> - andAppending secondBufPtr : UnsafeBufferPointer < UInt8 > <nl> - ) - > _StringStorage { <nl> - let size = bufPtr . count + secondBufPtr . count <nl> - let storage = _StringStorage . create ( <nl> - capacity : size , count : size ) <nl> - <nl> - let addr = bufPtr . baseAddress . _unsafelyUnwrappedUnchecked <nl> - storage . mutableStart . initialize ( from : addr , count : bufPtr . count ) <nl> - <nl> - let secondAddr = secondBufPtr . baseAddress . _unsafelyUnwrappedUnchecked <nl> - ( storage . mutableStart + bufPtr . count ) . initialize ( <nl> - from : secondAddr , count : secondBufPtr . count ) <nl> - return storage <nl> - } <nl> } <nl> <nl> / / TODO ( UTF8 perf ) : Append helpers , which can keep nul - termination <nl> extension _StringStorage { <nl> @ inline ( __always ) get { return UnsafePointer ( mutableEnd ) } <nl> } <nl> <nl> + / / Point to the nul - terminator <nl> + @ nonobjc <nl> + @ inlinable <nl> + internal final var terminator : UnsafeMutablePointer < UInt8 > { <nl> + @ inline ( __always ) get { return mutableEnd } <nl> + } <nl> + <nl> @ nonobjc <nl> @ inlinable <nl> internal var codeUnits : UnsafeBufferPointer < UInt8 > { <nl> extension _StringStorage { <nl> } <nl> } <nl> <nl> - @ inlinable <nl> + / / The total capacity available for code units . Note that this excludes the <nl> + / / required nul - terminator <nl> + @ nonobjc <nl> + internal var capacity : Int { return _realCapacity & - 1 } <nl> + <nl> + / / The unused capacity available for appending . Note that this excludes the <nl> + / / required nul - terminator <nl> @ nonobjc <nl> internal var unusedStorage : UnsafeMutableBufferPointer < UInt8 > { <nl> @ inline ( __always ) get { <nl> return UnsafeMutableBufferPointer ( <nl> - start : mutableEnd , count : unusedCapacity ) <nl> + start : mutableEnd , count : capacity ) <nl> } <nl> } <nl> <nl> + / / The capacity available for appending . Note that this excludes the required <nl> + / / nul - terminator <nl> @ nonobjc <nl> @ inlinable <nl> internal var unusedCapacity : Int { <nl> - @ inline ( __always ) get { return capacity & - count } <nl> + @ inline ( __always ) get { return _realCapacity & - _count & - 1 } <nl> } <nl> <nl> @ nonobjc <nl> extension _StringStorage { <nl> # if INTERNAL_CHECKS_ENABLED <nl> let rawSelf = UnsafeRawPointer ( Builtin . bridgeToRawPointer ( self ) ) <nl> let rawStart = UnsafeRawPointer ( start ) <nl> + _sanityCheck ( unusedCapacity > = 0 ) <nl> _sanityCheck ( rawSelf + Int ( _StringObject . nativeBias ) = = rawStart ) <nl> - _sanityCheck ( self . capacity > self . count , " no room for nul - terminator " ) <nl> - _sanityCheck ( self . unusedStorage [ 0 ] = = 0 , " not nul terminated " ) <nl> + _sanityCheck ( self . _realCapacity > self . _count , " no room for nul - terminator " ) <nl> + _sanityCheck ( self . terminator . pointee = = 0 , " not nul terminated " ) <nl> # endif <nl> } <nl> } <nl> <nl> + / / Appending <nl> + extension _StringStorage { <nl> + @ nonobjc <nl> + internal func appendInPlace ( _ other : UnsafeBufferPointer < UInt8 > ) { <nl> + _sanityCheck ( self . capacity > = other . count ) <nl> + let oldTerminator = self . terminator <nl> + <nl> + let srcAddr = other . baseAddress . _unsafelyUnwrappedUnchecked <nl> + let srcCount = other . count <nl> + self . mutableEnd . initialize ( from : srcAddr , count : srcCount ) <nl> + self . _count + = srcCount <nl> + <nl> + _sanityCheck ( oldTerminator + other . count = = self . terminator ) <nl> + self . terminator . pointee = 0 <nl> + <nl> + _invariantCheck ( ) <nl> + } <nl> + <nl> + @ nonobjc <nl> + internal func appendInPlace < Iter : IteratorProtocol > ( <nl> + _ other : inout Iter <nl> + ) where Iter . Element = = UInt8 { <nl> + let oldTerminator = self . terminator <nl> + var srcCount = 0 <nl> + while let cu = other . next ( ) { <nl> + _sanityCheck ( self . unusedCapacity > = 1 ) <nl> + unusedStorage [ srcCount ] = cu <nl> + srcCount + = 1 <nl> + } <nl> + self . _count + = srcCount <nl> + <nl> + _sanityCheck ( oldTerminator + srcCount = = self . terminator ) <nl> + self . terminator . pointee = 0 <nl> + <nl> + _invariantCheck ( ) <nl> + } <nl> + } <nl> + <nl> / / For bridging literals <nl> / / <nl> / / TODO ( UTF8 ) : Unify impls with _StringStorage <nl> mmm a / stdlib / public / core / StringTesting . swift <nl> ppp b / stdlib / public / core / StringTesting . swift <nl> extension _StringGuts { <nl> var result = _StringRepresentation ( <nl> _isASCII : self . isKnownASCII , <nl> _count : self . count , <nl> - _capacity : self . capacity ? ? 0 , <nl> + _capacity : nativeCapacity ? ? 0 , <nl> _form : . _small <nl> ) <nl> if _object . isSmall { <nl>
[ String ] In - place append and other RRC improvements
apple/swift
7c005527298188d1ef752d4465b6b7983e10a033
2018-11-04T18:42:40Z
mmm a / lib / Sema / CSDiagnostics . cpp <nl> ppp b / lib / Sema / CSDiagnostics . cpp <nl> static bool diagnoseUnwrap ( ConstraintSystem & CS , Expr * expr , Type baseType , <nl> assert ( ! unwrappedType - > hasTypeVariable ( ) & & <nl> " Unwrapped type must not be a type variable " ) ; <nl> <nl> - if ( baseType & & ! baseType - > getOptionalObjectType ( ) ) <nl> + if ( ! baseType - > getOptionalObjectType ( ) ) <nl> return false ; <nl> <nl> CS . TC . diagnose ( expr - > getLoc ( ) , diag : : optional_not_unwrapped , baseType , <nl> bool MissingOptionalUnwrapFailure : : diagnoseAsError ( ) { <nl> anchor = assignExpr - > getSrc ( ) ; <nl> <nl> auto * unwrapped = anchor - > getValueProvidingExpr ( ) ; <nl> - Type type = getType ( anchor ) - > getRValueType ( ) ; <nl> + auto type = getType ( anchor ) - > getRValueType ( ) ; <nl> <nl> auto * tryExpr = dyn_cast < OptionalTryExpr > ( unwrapped ) ; <nl> if ( ! tryExpr ) { <nl> - auto resolvedBaseTy = <nl> - resolveType ( BaseType ) - > reconstituteSugar ( / * recursive = * / true ) ; <nl> - auto resolvedUnwrappedTy = <nl> - resolveType ( UnwrappedType ) - > reconstituteSugar ( / * recursive = * / true ) ; <nl> - return diagnoseUnwrap ( getConstraintSystem ( ) , unwrapped , resolvedBaseTy , <nl> - resolvedUnwrappedTy ) ; <nl> + return diagnoseUnwrap ( getConstraintSystem ( ) , unwrapped , getBaseType ( ) , <nl> + getUnwrappedType ( ) ) ; <nl> } <nl> <nl> bool isSwift5OrGreater = getTypeChecker ( ) . getLangOpts ( ) . isSwiftVersionAtLeast ( 5 ) ; <nl> bool MissingOptionalUnwrapFailure : : diagnoseAsError ( ) { <nl> / / under Swift 5 + , so just report that a missing unwrap can ' t be handled here . <nl> return false ; <nl> } <nl> - else { <nl> - emitDiagnostic ( tryExpr - > getTryLoc ( ) , diag : : missing_unwrap_optional_try , type ) <nl> - . fixItReplace ( { tryExpr - > getTryLoc ( ) , tryExpr - > getQuestionLoc ( ) } , " try ! " ) ; <nl> - return true ; <nl> - } <nl> + <nl> + emitDiagnostic ( tryExpr - > getTryLoc ( ) , diag : : missing_unwrap_optional_try , type ) <nl> + . fixItReplace ( { tryExpr - > getTryLoc ( ) , tryExpr - > getQuestionLoc ( ) } , " try ! " ) ; <nl> + return true ; <nl> } <nl> <nl> bool RValueTreatedAsLValueFailure : : diagnoseAsError ( ) { <nl> mmm a / lib / Sema / CSDiagnostics . h <nl> ppp b / lib / Sema / CSDiagnostics . h <nl> class FailureDiagnostic { <nl> Type getType ( Expr * expr ) const ; <nl> <nl> / / / Resolve type variables present in the raw type , if any . <nl> - Type resolveType ( Type rawType ) const { <nl> - return CS . simplifyType ( rawType ) ; <nl> + Type resolveType ( Type rawType , bool reconstituteSugar = false ) const { <nl> + auto resolvedType = CS . simplifyType ( rawType ) ; <nl> + return reconstituteSugar <nl> + ? resolvedType - > reconstituteSugar ( / * recursive * / true ) <nl> + : resolvedType ; <nl> } <nl> <nl> template < typename . . . ArgTypes > <nl> class MissingOptionalUnwrapFailure final : public FailureDiagnostic { <nl> UnwrappedType ( unwrappedType ) { } <nl> <nl> bool diagnoseAsError ( ) override ; <nl> + <nl> + private : <nl> + Type getBaseType ( ) const { <nl> + return resolveType ( BaseType , / * reconstituteSugar = * / true ) ; <nl> + } <nl> + <nl> + Type getUnwrappedType ( ) const { <nl> + return resolveType ( UnwrappedType , / * reconstituteSugar = * / true ) ; <nl> + } <nl> } ; <nl> <nl> / / / Diagnose errors associated with rvalues in positions <nl> mmm a / lib / Sema / CSFix . h <nl> ppp b / lib / Sema / CSFix . h <nl> class ForceOptional final : public ConstraintFix { <nl> ForceOptional ( ConstraintSystem & cs , Type baseType , Type unwrappedType , <nl> ConstraintLocator * locator ) <nl> : ConstraintFix ( cs , FixKind : : ForceOptional , locator ) , BaseType ( baseType ) , <nl> - UnwrappedType ( unwrappedType ) { } <nl> + UnwrappedType ( unwrappedType ) { <nl> + assert ( baseType & & " Base type must not be null " ) ; <nl> + assert ( unwrappedType & & " Unwrapped type must not be null " ) ; <nl> + } <nl> <nl> public : <nl> std : : string getName ( ) const override { return " force optional " ; } <nl> mmm a / lib / Sema / CSSimplify . cpp <nl> ppp b / lib / Sema / CSSimplify . cpp <nl> ConstraintSystem : : simplifyApplicableFnConstraint ( <nl> ConstraintLocator : : FunctionResult ) ) . isFailure ( ) ) <nl> return SolutionKind : : Error ; <nl> <nl> + if ( unwrapCount = = 0 ) <nl> + return SolutionKind : : Solved ; <nl> + <nl> / / Record any fixes we attempted to get to the correct solution . <nl> auto * fix = ForceOptional : : create ( * this , origType2 , <nl> origType2 - > getOptionalObjectType ( ) , <nl> ConstraintSystem : : simplifyApplicableFnConstraint ( <nl> <nl> / / Record any fixes we attempted to get to the correct solution . <nl> if ( simplified = = SolutionKind : : Solved ) { <nl> + if ( unwrapCount = = 0 ) <nl> + return SolutionKind : : Solved ; <nl> + <nl> auto * fix = ForceOptional : : create ( * this , origType2 , <nl> origType2 - > getOptionalObjectType ( ) , <nl> getConstraintLocator ( locator ) ) ; <nl> mmm a / test / Constraints / fixes . swift <nl> ppp b / test / Constraints / fixes . swift <nl> let _ : Int = thing ? . e ? . a ( ) / / expected - error { { value of optional type ' Int ? ' mus <nl> / / expected - note @ - 2 { { force - unwrap } } <nl> let _ : Int ? = thing ? . e ? . b / / expected - error { { value of optional type ' Int ? ? ' must be unwrapped to a value of type ' Int ? ' } } <nl> / / expected - note @ - 1 { { coalesce } } <nl> - / / expected - note @ - 2 { { force - unwrap } } <nl> \ No newline at end of file <nl> + / / expected - note @ - 2 { { force - unwrap } } <nl> mmm a / test / Constraints / patterns . swift <nl> ppp b / test / Constraints / patterns . swift <nl> switch staticMembers { <nl> case . init ( 0 ) : break <nl> case . init ( _ ) : break / / expected - error { { ' _ ' can only appear in a pattern } } <nl> case . init ( let x ) : break / / expected - error { { cannot appear in an expression } } <nl> - case . init ( opt : 0 ) : break / / expected - error { { value of optional type ' StaticMembers ? ' must be unwrapped to a value of type ' StaticMembers ' } } <nl> - / / expected - note @ - 1 { { coalesce } } <nl> - / / expected - note @ - 2 { { force - unwrap } } <nl> + case . init ( opt : 0 ) : break <nl> + / / expected - error @ - 1 { { value of optional type ' StaticMembers ? ' must be unwrapped to a value of type ' StaticMembers ' } } <nl> + / / expected - note @ - 2 { { coalesce } } <nl> + / / expected - note @ - 3 { { force - unwrap } } <nl> <nl> case . prop : break <nl> / / TODO : repeated error message <nl> switch staticMembers { <nl> case . method ( withLabel : let x ) : break / / expected - error { { cannot appear in an expression } } <nl> <nl> case . optMethod : break / / expected - error { { cannot match } } <nl> - case . optMethod ( 0 ) : break / / expected - error { { value of optional type ' StaticMembers ? ' must be unwrapped to a value of type ' StaticMembers ' } } <nl> - / / expected - note @ - 1 { { coalesce } } <nl> - / / expected - note @ - 2 { { force - unwrap } } <nl> + case . optMethod ( 0 ) : break <nl> + / / expected - error @ - 1 { { value of optional type ' StaticMembers ? ' must be unwrapped to a value of type ' StaticMembers ' } } <nl> + / / expected - note @ - 2 { { coalesce } } <nl> + / / expected - note @ - 3 { { force - unwrap } } <nl> } <nl> <nl> _ = 0 <nl> mmm a / test / expr / delayed - ident / static_var . swift <nl> ppp b / test / expr / delayed - ident / static_var . swift <nl> struct HasClosure { <nl> var _ : HasClosure = . factoryNormal ( 0 ) <nl> var _ : HasClosure = . factoryReturnOpt ( 1 ) ! <nl> var _ : HasClosure = . factoryIUO ( 2 ) <nl> - var _ : HasClosure = . factoryOpt ( 3 ) / / expected - error { { value of optional type ' ( ( Int ) - > HasClosure ) ? ' must be unwrapped to a value of type ' ( Int ) - > HasClosure ' } } <nl> - / / expected - note @ - 1 { { coalesce } } <nl> - / / expected - note @ - 2 { { force - unwrap } } <nl> + var _ : HasClosure = . factoryOpt ( 3 ) <nl> + / / expected - error @ - 1 { { value of optional type ' ( ( Int ) - > HasClosure ) ? ' must be unwrapped to a value of type ' ( Int ) - > HasClosure ' } } <nl> + / / expected - note @ - 2 { { coalesce } } <nl> + / / expected - note @ - 3 { { force - unwrap } } <nl> var _ : HasClosure = . factoryOpt ! ( 4 ) / / expected - error { { type of expression is ambiguous without more context } } <nl> mmm a / test / expr / postfix / dot / optional_context_member . swift <nl> ppp b / test / expr / postfix / dot / optional_context_member . swift <nl> func nonOptContext ( ) - > Foo { <nl> case ( ) : <nl> return . someVar <nl> case ( ) : / / expected - warning { { case is already handled by previous patterns ; consider removing it } } <nl> - return . someOptVar / / expected - error { { value of optional type ' Foo ? ' must be unwrapped to a value of type ' Foo ' } } <nl> - / / expected - note @ - 1 { { coalesce } } <nl> - / / expected - note @ - 2 { { force - unwrap } } <nl> + return . someOptVar <nl> + / / expected - error @ - 1 { { value of optional type ' Foo ? ' must be unwrapped to a value of type ' Foo ' } } <nl> + / / expected - note @ - 2 { { coalesce } } <nl> + / / expected - note @ - 3 { { force - unwrap } } <nl> / / TODO <nl> / / case ( ) : <nl> / / return . someOptVar ! <nl> case ( ) : / / expected - warning { { case is already handled by previous patterns ; consider removing it } } <nl> return . someFunc ( ) <nl> case ( ) : / / expected - warning { { case is already handled by previous patterns ; consider removing it } } <nl> - return . someOptFunc ( ) / / expected - error { { value of optional type ' Foo ? ' must be unwrapped to a value of type ' Foo ' } } <nl> - / / expected - note @ - 1 { { coalesce } } <nl> - / / expected - note @ - 2 { { force - unwrap } } <nl> + return . someOptFunc ( ) <nl> + / / expected - error @ - 1 { { value of optional type ' Foo ? ' must be unwrapped to a value of type ' Foo ' } } <nl> + / / expected - note @ - 2 { { coalesce } } <nl> + / / expected - note @ - 3 { { force - unwrap } } <nl> / / TODO <nl> / / case ( ) : <nl> / / return . someOptFunc ( ) ! <nl>
[ CSFix ] Couple of small cleanups related to ForceOptional
apple/swift
1c79380a12e5c7df386f4c1cdd22645baa715f30
2019-01-26T08:48:01Z
mmm a / cocos / ui / UILayoutComponent . cpp <nl> ppp b / cocos / ui / UILayoutComponent . cpp <nl> namespace ui { <nl> <nl> } <nl> <nl> + LayoutComponent * LayoutComponent : : boundingLayoutForNode ( Node * node ) <nl> + { <nl> + LayoutComponent * layout = ( LayoutComponent * ) node - > getComponent ( __LAYOUT_COMPONENT_NAME ) ; <nl> + if ( layout ! = nullptr ) <nl> + return layout ; <nl> + <nl> + layout = new ( std : : nothrow ) LayoutComponent ( ) ; <nl> + if ( layout & & layout - > init ( ) ) <nl> + { <nl> + layout - > autorelease ( ) ; <nl> + node - > addComponent ( layout ) ; <nl> + return layout ; <nl> + } <nl> + CC_SAFE_DELETE ( layout ) ; <nl> + return nullptr ; <nl> + } <nl> + <nl> bool LayoutComponent : : init ( ) <nl> { <nl> bool ret = true ; <nl> namespace ui { <nl> ownerSize . height = parentSize . height * _percentHeight ; <nl> } <nl> break ; <nl> - case VerticalEage : : Buttom : <nl> + case VerticalEage : : Bottom : <nl> if ( _usingPercentHeight | | _usingStretchHeight ) <nl> ownerSize . height = parentSize . height * _percentHeight ; <nl> ownerPosition . y = _buttomMargin + ownerAnchor . y * ownerSize . height ; <nl> mmm a / cocos / ui / UILayoutComponent . h <nl> ppp b / cocos / ui / UILayoutComponent . h <nl> namespace ui { <nl> virtual bool init ( ) override ; <nl> CREATE_FUNC ( LayoutComponent ) ; <nl> <nl> + static LayoutComponent * boundingLayoutForNode ( Node * node ) ; <nl> + <nl> enum class HorizontalEage <nl> { <nl> None , <nl> namespace ui { <nl> enum class VerticalEage <nl> { <nl> None , <nl> - Buttom , <nl> + Bottom , <nl> Top , <nl> Center <nl> } ; <nl> mmm a / tests / cpp - tests / Classes / UITest / CocoStudioGUITest / CocosGUIScene . cpp <nl> ppp b / tests / cpp - tests / Classes / UITest / CocoStudioGUITest / CocosGUIScene . cpp <nl> g_guisTests [ ] = <nl> UISceneManager * sceneManager = UISceneManager : : sharedUISceneManager ( ) ; <nl> sceneManager - > setCurrentUISceneId ( kUILayoutTest ) ; <nl> sceneManager - > setMinUISceneId ( kUILayoutTest ) ; <nl> - sceneManager - > setMaxUISceneId ( kUILayoutTest_Layout_Relative_Location ) ; <nl> + sceneManager - > setMaxUISceneId ( kUILayoutComponent_Berth_Stretch_Test ) ; <nl> Scene * scene = sceneManager - > currentUIScene ( ) ; <nl> Director : : getInstance ( ) - > replaceScene ( scene ) ; <nl> } <nl> mmm a / tests / cpp - tests / Classes / UITest / CocoStudioGUITest / UILayoutTest / UILayoutTest . cpp <nl> ppp b / tests / cpp - tests / Classes / UITest / CocoStudioGUITest / UILayoutTest / UILayoutTest . cpp <nl> bool UILayoutTest : : init ( ) <nl> if ( UIScene : : init ( ) ) <nl> { <nl> Size widgetSize = _widget - > getContentSize ( ) ; <nl> - <nl> + <nl> / / Add the alert <nl> - Text * alert = Text : : create ( " Layout " , " fonts / Marker Felt . ttf " , 30 ) ; <nl> + Text * alert = Text : : create ( " Layout " , " fonts / Marker Felt . ttf " , 30 ) ; <nl> alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> alert - > setPosition ( Vec2 ( widgetSize . width / 2 . 0f , <nl> - widgetSize . height / 2 . 0f - alert - > getContentSize ( ) . height * 3 . 075f ) ) ; <nl> - <nl> + widgetSize . height / 2 . 0f - alert - > getContentSize ( ) . height * 3 . 075f ) ) ; <nl> + <nl> _uiLayer - > addChild ( alert ) ; <nl> - <nl> - Layout * root = static_cast < Layout * > ( _uiLayer - > getChildByTag ( 81 ) ) ; <nl> - <nl> + <nl> + Layout * root = static_cast < Layout * > ( _uiLayer - > getChildByTag ( 81 ) ) ; <nl> + <nl> Layout * background = static_cast < Layout * > ( root - > getChildByName ( " background_Panel " ) ) ; <nl> - <nl> + <nl> / / Create the layout <nl> Layout * layout = Layout : : create ( ) ; <nl> layout - > setContentSize ( Size ( 280 , 150 ) ) ; <nl> Size backgroundSize = background - > getContentSize ( ) ; <nl> layout - > setPosition ( Vec2 ( ( widgetSize . width - backgroundSize . width ) / 2 . 0f + <nl> - ( backgroundSize . width - layout - > getContentSize ( ) . width ) / 2 . 0f , <nl> - ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> - ( backgroundSize . height - layout - > getContentSize ( ) . height ) / 2 . 0f ) ) ; <nl> + ( backgroundSize . width - layout - > getContentSize ( ) . width ) / 2 . 0f , <nl> + ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> + ( backgroundSize . height - layout - > getContentSize ( ) . height ) / 2 . 0f ) ) ; <nl> _uiLayer - > addChild ( layout ) ; <nl> - <nl> + <nl> Button * button = Button : : create ( " cocosui / animationbuttonnormal . png " , " cocosui / animationbuttonpressed . png " ) ; <nl> button - > setPosition ( Vec2 ( button - > getContentSize ( ) . width / 2 . 0f , <nl> - layout - > getContentSize ( ) . height - button - > getContentSize ( ) . height / 2 . 0f ) ) ; <nl> + layout - > getContentSize ( ) . height - button - > getContentSize ( ) . height / 2 . 0f ) ) ; <nl> layout - > addChild ( button ) ; <nl> - <nl> + <nl> Button * titleButton = Button : : create ( " cocosui / backtotopnormal . png " , " cocosui / backtotoppressed . png " ) ; <nl> titleButton - > setTitleText ( " Title Button " ) ; <nl> titleButton - > setPosition ( Vec2 ( layout - > getContentSize ( ) . width / 2 . 0f , layout - > getContentSize ( ) . height / 2 . 0f ) ) ; <nl> layout - > addChild ( titleButton ) ; <nl> - <nl> + <nl> Button * button_scale9 = Button : : create ( " cocosui / button . png " , " cocosui / buttonHighlighted . png " ) ; <nl> button_scale9 - > setScale9Enabled ( true ) ; <nl> button_scale9 - > setContentSize ( Size ( 100 . 0f , button_scale9 - > getVirtualRendererSize ( ) . height ) ) ; <nl> button_scale9 - > setPosition ( Vec2 ( layout - > getContentSize ( ) . width - button_scale9 - > getContentSize ( ) . width / 2 . 0f , <nl> - button_scale9 - > getContentSize ( ) . height / 2 . 0f ) ) ; <nl> - <nl> + button_scale9 - > getContentSize ( ) . height / 2 . 0f ) ) ; <nl> + <nl> layout - > addChild ( button_scale9 ) ; <nl> - <nl> + <nl> return true ; <nl> } <nl> - <nl> + <nl> return false ; <nl> } <nl> <nl> bool UILayoutTest_Color : : init ( ) <nl> if ( UIScene : : init ( ) ) <nl> { <nl> Size widgetSize = _widget - > getContentSize ( ) ; <nl> - <nl> + <nl> / / Add the alert <nl> Text * alert = Text : : create ( " Layout color render " , " fonts / Marker Felt . ttf " , 30 ) ; <nl> alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> alert - > setPosition ( Vec2 ( widgetSize . width / 2 . 0f , <nl> - widgetSize . height / 2 . 0f - alert - > getContentSize ( ) . height * 3 . 075f ) ) ; <nl> - <nl> + widgetSize . height / 2 . 0f - alert - > getContentSize ( ) . height * 3 . 075f ) ) ; <nl> + <nl> _uiLayer - > addChild ( alert ) ; <nl> - <nl> + <nl> Layout * root = static_cast < Layout * > ( _uiLayer - > getChildByTag ( 81 ) ) ; <nl> - <nl> + <nl> Layout * background = static_cast < Layout * > ( root - > getChildByName ( " background_Panel " ) ) ; <nl> - <nl> + <nl> / / Create the layout with color render <nl> Layout * layout = Layout : : create ( ) ; <nl> layout - > setBackGroundColorType ( Layout : : BackGroundColorType : : SOLID ) ; <nl> bool UILayoutTest_Color : : init ( ) <nl> layout - > setContentSize ( Size ( 280 , 150 ) ) ; <nl> Size backgroundSize = background - > getContentSize ( ) ; <nl> layout - > setPosition ( Vec2 ( ( widgetSize . width - backgroundSize . width ) / 2 . 0f + <nl> - ( backgroundSize . width - layout - > getContentSize ( ) . width ) / 2 . 0f , <nl> - ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> - ( backgroundSize . height - layout - > getContentSize ( ) . height ) / 2 . 0f ) ) ; <nl> + ( backgroundSize . width - layout - > getContentSize ( ) . width ) / 2 . 0f , <nl> + ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> + ( backgroundSize . height - layout - > getContentSize ( ) . height ) / 2 . 0f ) ) ; <nl> _uiLayer - > addChild ( layout ) ; <nl> - <nl> + <nl> Button * button = Button : : create ( " cocosui / animationbuttonnormal . png " , " cocosui / animationbuttonpressed . png " ) ; <nl> button - > setPosition ( Vec2 ( button - > getContentSize ( ) . width / 2 . 0f , <nl> - layout - > getContentSize ( ) . height - button - > getContentSize ( ) . height / 2 . 0f ) ) ; <nl> - <nl> + layout - > getContentSize ( ) . height - button - > getContentSize ( ) . height / 2 . 0f ) ) ; <nl> + <nl> layout - > addChild ( button ) ; <nl> - <nl> + <nl> Button * titleButton = Button : : create ( " cocosui / backtotopnormal . png " , " cocosui / backtotoppressed . png " ) ; <nl> titleButton - > setTitleText ( " Title Button " ) ; <nl> titleButton - > setPosition ( Vec2 ( layout - > getContentSize ( ) . width / 2 . 0f , layout - > getContentSize ( ) . height / 2 . 0f ) ) ; <nl> layout - > addChild ( titleButton ) ; <nl> - <nl> + <nl> Button * button_scale9 = Button : : create ( " cocosui / button . png " , " cocosui / buttonHighlighted . png " ) ; <nl> button_scale9 - > setScale9Enabled ( true ) ; <nl> button_scale9 - > setContentSize ( Size ( 100 . 0f , button_scale9 - > getVirtualRendererSize ( ) . height ) ) ; <nl> button_scale9 - > setPosition ( Vec2 ( layout - > getContentSize ( ) . width - button_scale9 - > getContentSize ( ) . width / 2 . 0f , <nl> - button_scale9 - > getContentSize ( ) . height / 2 . 0f ) ) ; <nl> - <nl> - layout - > addChild ( button_scale9 ) ; <nl> - <nl> + button_scale9 - > getContentSize ( ) . height / 2 . 0f ) ) ; <nl> + <nl> + layout - > addChild ( button_scale9 ) ; <nl> + <nl> return true ; <nl> } <nl> return false ; <nl> bool UILayoutTest_Color : : init ( ) <nl> / / UILayoutTest_Gradient <nl> <nl> UILayoutTest_Gradient : : UILayoutTest_Gradient ( ) <nl> - { <nl> + { <nl> } <nl> <nl> UILayoutTest_Gradient : : ~ UILayoutTest_Gradient ( ) <nl> bool UILayoutTest_Gradient : : init ( ) <nl> if ( UIScene : : init ( ) ) <nl> { <nl> Size widgetSize = _widget - > getContentSize ( ) ; <nl> - <nl> + <nl> / / Add the alert <nl> Text * alert = Text : : create ( " Layout gradient render " , " fonts / Marker Felt . ttf " , 30 ) ; <nl> alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> alert - > setPosition ( Vec2 ( widgetSize . width / 2 . 0f , <nl> - widgetSize . height / 2 . 0f - alert - > getContentSize ( ) . height * 3 . 075f ) ) ; <nl> - <nl> + widgetSize . height / 2 . 0f - alert - > getContentSize ( ) . height * 3 . 075f ) ) ; <nl> + <nl> _uiLayer - > addChild ( alert ) ; <nl> - <nl> + <nl> Layout * root = static_cast < Layout * > ( _uiLayer - > getChildByTag ( 81 ) ) ; <nl> - <nl> + <nl> Layout * background = static_cast < Layout * > ( root - > getChildByName ( " background_Panel " ) ) ; <nl> - <nl> + <nl> / / Create the layout with gradient render <nl> Layout * layout = Layout : : create ( ) ; <nl> layout - > setBackGroundColorType ( Layout : : BackGroundColorType : : GRADIENT ) ; <nl> bool UILayoutTest_Gradient : : init ( ) <nl> layout - > setContentSize ( Size ( 280 , 150 ) ) ; <nl> Size backgroundSize = background - > getContentSize ( ) ; <nl> layout - > setPosition ( Vec2 ( ( widgetSize . width - backgroundSize . width ) / 2 . 0f + <nl> - ( backgroundSize . width - layout - > getContentSize ( ) . width ) / 2 . 0f , <nl> - ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> - ( backgroundSize . height - layout - > getContentSize ( ) . height ) / 2 . 0f ) ) ; <nl> + ( backgroundSize . width - layout - > getContentSize ( ) . width ) / 2 . 0f , <nl> + ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> + ( backgroundSize . height - layout - > getContentSize ( ) . height ) / 2 . 0f ) ) ; <nl> _uiLayer - > addChild ( layout ) ; <nl> - <nl> + <nl> Button * button = Button : : create ( " cocosui / animationbuttonnormal . png " , " cocosui / animationbuttonpressed . png " ) ; <nl> button - > setPosition ( Vec2 ( button - > getContentSize ( ) . width / 2 . 0f , <nl> - layout - > getContentSize ( ) . height - button - > getContentSize ( ) . height / 2 . 0f ) ) ; <nl> - <nl> + layout - > getContentSize ( ) . height - button - > getContentSize ( ) . height / 2 . 0f ) ) ; <nl> + <nl> layout - > addChild ( button ) ; <nl> - <nl> + <nl> Button * titleButton = Button : : create ( " cocosui / backtotopnormal . png " , " cocosui / backtotoppressed . png " ) ; <nl> titleButton - > setTitleText ( " Title Button " ) ; <nl> titleButton - > setPosition ( Vec2 ( layout - > getContentSize ( ) . width / 2 . 0f , layout - > getContentSize ( ) . height / 2 . 0f ) ) ; <nl> layout - > addChild ( titleButton ) ; <nl> - <nl> + <nl> Button * button_scale9 = Button : : create ( " cocosui / button . png " , " cocosui / buttonHighlighted . png " ) ; <nl> button_scale9 - > setScale9Enabled ( true ) ; <nl> button_scale9 - > setContentSize ( Size ( 100 . 0f , button_scale9 - > getVirtualRendererSize ( ) . height ) ) ; <nl> button_scale9 - > setPosition ( Vec2 ( layout - > getContentSize ( ) . width - button_scale9 - > getContentSize ( ) . width / 2 . 0f , <nl> - button_scale9 - > getContentSize ( ) . height / 2 . 0f ) ) ; <nl> - <nl> - layout - > addChild ( button_scale9 ) ; <nl> - <nl> + button_scale9 - > getContentSize ( ) . height / 2 . 0f ) ) ; <nl> + <nl> + layout - > addChild ( button_scale9 ) ; <nl> + <nl> return true ; <nl> } <nl> return false ; <nl> bool UILayoutTest_BackGroundImage : : init ( ) <nl> if ( UIScene : : init ( ) ) <nl> { <nl> Size widgetSize = _widget - > getContentSize ( ) ; <nl> - <nl> + <nl> / / Add the alert <nl> Text * alert = Text : : create ( " Layout background image " , " fonts / Marker Felt . ttf " , 20 ) ; <nl> alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> alert - > setPosition ( Vec2 ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getContentSize ( ) . height * 4 . 5f ) ) ; <nl> _uiLayer - > addChild ( alert ) ; <nl> - <nl> + <nl> Layout * root = static_cast < Layout * > ( _uiLayer - > getChildByTag ( 81 ) ) ; <nl> - <nl> + <nl> Layout * background = dynamic_cast < Layout * > ( root - > getChildByName ( " background_Panel " ) ) ; <nl> - <nl> + <nl> / / Create the layout with background image <nl> Layout * layout = Layout : : create ( ) ; <nl> layout - > setClippingEnabled ( true ) ; <nl> bool UILayoutTest_BackGroundImage : : init ( ) <nl> layout - > setContentSize ( Size ( 280 , 150 ) ) ; <nl> Size backgroundSize = background - > getContentSize ( ) ; <nl> layout - > setPosition ( Vec2 ( ( widgetSize . width - backgroundSize . width ) / 2 . 0f + <nl> - ( backgroundSize . width - layout - > getContentSize ( ) . width ) / 2 . 0f , <nl> - ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> - ( backgroundSize . height - layout - > getContentSize ( ) . height ) / 2 . 0f ) ) ; <nl> + ( backgroundSize . width - layout - > getContentSize ( ) . width ) / 2 . 0f , <nl> + ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> + ( backgroundSize . height - layout - > getContentSize ( ) . height ) / 2 . 0f ) ) ; <nl> _uiLayer - > addChild ( layout ) ; <nl> - <nl> + <nl> Button * button = Button : : create ( " cocosui / animationbuttonnormal . png " , " cocosui / animationbuttonpressed . png " ) ; <nl> button - > setPosition ( Vec2 ( button - > getContentSize ( ) . width / 2 . 0f , <nl> - layout - > getContentSize ( ) . height - button - > getContentSize ( ) . height / 2 . 0f ) ) ; <nl> + layout - > getContentSize ( ) . height - button - > getContentSize ( ) . height / 2 . 0f ) ) ; <nl> layout - > addChild ( button ) ; <nl> - <nl> + <nl> Button * titleButton = Button : : create ( " cocosui / backtotopnormal . png " , " cocosui / backtotoppressed . png " ) ; <nl> titleButton - > setTitleText ( " Title Button " ) ; <nl> titleButton - > setPosition ( Vec2 ( layout - > getContentSize ( ) . width / 2 . 0f , layout - > getContentSize ( ) . height / 2 . 0f ) ) ; <nl> layout - > addChild ( titleButton ) ; <nl> - <nl> + <nl> Button * button_scale9 = Button : : create ( " cocosui / button . png " , " cocosui / buttonHighlighted . png " ) ; <nl> button_scale9 - > setScale9Enabled ( true ) ; <nl> button_scale9 - > setContentSize ( Size ( 100 . 0f , button_scale9 - > getVirtualRendererSize ( ) . height ) ) ; <nl> button_scale9 - > setPosition ( Vec2 ( layout - > getContentSize ( ) . width - button_scale9 - > getContentSize ( ) . width / 2 . 0f , <nl> - button_scale9 - > getContentSize ( ) . height / 2 . 0f ) ) ; <nl> - <nl> - layout - > addChild ( button_scale9 ) ; <nl> - <nl> + button_scale9 - > getContentSize ( ) . height / 2 . 0f ) ) ; <nl> + <nl> + layout - > addChild ( button_scale9 ) ; <nl> + <nl> return true ; <nl> } <nl> return false ; <nl> bool UILayoutTest_BackGroundImage_Scale9 : : init ( ) <nl> if ( UIScene : : init ( ) ) <nl> { <nl> Size widgetSize = _widget - > getContentSize ( ) ; <nl> - <nl> + <nl> / / Add the alert <nl> Text * alert = Text : : create ( " Layout background image scale9 " , " fonts / Marker Felt . ttf " , 20 ) ; <nl> alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> alert - > setPosition ( Vec2 ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getContentSize ( ) . height * 4 . 5f ) ) ; <nl> _uiLayer - > addChild ( alert ) ; <nl> - <nl> + <nl> Layout * root = static_cast < Layout * > ( _uiLayer - > getChildByTag ( 81 ) ) ; <nl> - <nl> + <nl> Layout * background = dynamic_cast < Layout * > ( root - > getChildByName ( " background_Panel " ) ) ; <nl> - <nl> + <nl> / / Create the layout with background image <nl> Layout * layout = Layout : : create ( ) ; <nl> layout - > setBackGroundImageScale9Enabled ( true ) ; <nl> bool UILayoutTest_BackGroundImage_Scale9 : : init ( ) <nl> layout - > setContentSize ( Size ( 280 , 150 ) ) ; <nl> Size backgroundSize = background - > getContentSize ( ) ; <nl> layout - > setPosition ( Vec2 ( ( widgetSize . width - backgroundSize . width ) / 2 . 0f + <nl> - ( backgroundSize . width - layout - > getContentSize ( ) . width ) / 2 . 0f , <nl> - ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> - ( backgroundSize . height - layout - > getContentSize ( ) . height ) / 2 . 0f ) ) ; <nl> + ( backgroundSize . width - layout - > getContentSize ( ) . width ) / 2 . 0f , <nl> + ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> + ( backgroundSize . height - layout - > getContentSize ( ) . height ) / 2 . 0f ) ) ; <nl> _uiLayer - > addChild ( layout ) ; <nl> - <nl> + <nl> Button * button = Button : : create ( " cocosui / animationbuttonnormal . png " , " cocosui / animationbuttonpressed . png " ) ; <nl> button - > setPosition ( Vec2 ( button - > getContentSize ( ) . width / 2 . 0f , <nl> - layout - > getContentSize ( ) . height - button - > getContentSize ( ) . height / 2 . 0f ) ) ; <nl> - <nl> + layout - > getContentSize ( ) . height - button - > getContentSize ( ) . height / 2 . 0f ) ) ; <nl> + <nl> layout - > addChild ( button ) ; <nl> - <nl> + <nl> Button * titleButton = Button : : create ( " cocosui / backtotopnormal . png " , " cocosui / backtotoppressed . png " ) ; <nl> titleButton - > setTitleText ( " Title Button " ) ; <nl> titleButton - > setPosition ( Vec2 ( layout - > getContentSize ( ) . width / 2 . 0f , layout - > getContentSize ( ) . height / 2 . 0f ) ) ; <nl> layout - > addChild ( titleButton ) ; <nl> - <nl> + <nl> Button * button_scale9 = Button : : create ( " cocosui / button . png " , " cocosui / buttonHighlighted . png " ) ; <nl> button_scale9 - > setScale9Enabled ( true ) ; <nl> button_scale9 - > setContentSize ( Size ( 100 . 0f , button_scale9 - > getVirtualRendererSize ( ) . height ) ) ; <nl> button_scale9 - > setPosition ( Vec2 ( layout - > getContentSize ( ) . width - button_scale9 - > getContentSize ( ) . width / 2 . 0f , <nl> - button_scale9 - > getContentSize ( ) . height / 2 . 0f ) ) ; <nl> + button_scale9 - > getContentSize ( ) . height / 2 . 0f ) ) ; <nl> layout - > addChild ( button_scale9 ) ; <nl> - <nl> + <nl> return true ; <nl> } <nl> return false ; <nl> bool UILayoutTest_Layout_Linear_Vertical : : init ( ) <nl> if ( UIScene : : init ( ) ) <nl> { <nl> Size widgetSize = _widget - > getContentSize ( ) ; <nl> - <nl> + <nl> / / Add the alert <nl> Text * alert = Text : : create ( " Layout Linear Vertical " , " fonts / Marker Felt . ttf " , 20 ) ; <nl> alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> alert - > setPosition ( Vec2 ( widgetSize . width / 2 . 0f , <nl> - widgetSize . height / 2 . 0f - alert - > getContentSize ( ) . height * 4 . 5f ) ) ; <nl> - <nl> + widgetSize . height / 2 . 0f - alert - > getContentSize ( ) . height * 4 . 5f ) ) ; <nl> + <nl> _uiLayer - > addChild ( alert ) ; <nl> - <nl> + <nl> Layout * root = static_cast < Layout * > ( _uiLayer - > getChildByTag ( 81 ) ) ; <nl> - <nl> + <nl> Layout * background = static_cast < Layout * > ( root - > getChildByName ( " background_Panel " ) ) ; <nl> - <nl> + <nl> / / Create the layout <nl> Layout * layout = Layout : : create ( ) ; <nl> layout - > setLayoutType ( LayoutType : : VERTICAL ) ; <nl> layout - > setContentSize ( Size ( 280 , 150 ) ) ; <nl> Size backgroundSize = background - > getContentSize ( ) ; <nl> layout - > setPosition ( Vec2 ( ( widgetSize . width - backgroundSize . width ) / 2 . 0f + <nl> - ( backgroundSize . width - layout - > getContentSize ( ) . width ) / 2 . 0f , <nl> - ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> - ( backgroundSize . height - layout - > getContentSize ( ) . height ) / 2 . 0f ) ) ; <nl> + ( backgroundSize . width - layout - > getContentSize ( ) . width ) / 2 . 0f , <nl> + ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> + ( backgroundSize . height - layout - > getContentSize ( ) . height ) / 2 . 0f ) ) ; <nl> _uiLayer - > addChild ( layout ) ; <nl> - <nl> - <nl> + <nl> + <nl> Button * button = Button : : create ( " cocosui / animationbuttonnormal . png " , " cocosui / animationbuttonpressed . png " ) ; <nl> layout - > addChild ( button ) ; <nl> - <nl> + <nl> LinearLayoutParameter * lp1 = LinearLayoutParameter : : create ( ) ; <nl> button - > setLayoutParameter ( lp1 ) ; <nl> lp1 - > setGravity ( LinearLayoutParameter : : LinearGravity : : CENTER_HORIZONTAL ) ; <nl> lp1 - > setMargin ( Margin ( 0 . 0f , 5 . 0f , 0 . 0f , 10 . 0f ) ) ; <nl> - <nl> - <nl> + <nl> + <nl> Button * titleButton = Button : : create ( " cocosui / backtotopnormal . png " , " cocosui / backtotoppressed . png " ) ; <nl> titleButton - > setTitleText ( " Title Button " ) ; <nl> layout - > addChild ( titleButton ) ; <nl> - <nl> + <nl> LinearLayoutParameter * lp2 = LinearLayoutParameter : : create ( ) ; <nl> titleButton - > setLayoutParameter ( lp2 ) ; <nl> lp2 - > setGravity ( LinearLayoutParameter : : LinearGravity : : CENTER_HORIZONTAL ) ; <nl> lp2 - > setMargin ( Margin ( 0 . 0f , 10 . 0f , 0 . 0f , 10 . 0f ) ) ; <nl> - <nl> - <nl> + <nl> + <nl> Button * button_scale9 = Button : : create ( " cocosui / button . png " , " cocosui / buttonHighlighted . png " ) ; <nl> button_scale9 - > setScale9Enabled ( true ) ; <nl> button_scale9 - > setContentSize ( Size ( 100 . 0f , button_scale9 - > getVirtualRendererSize ( ) . height ) ) ; <nl> layout - > addChild ( button_scale9 ) ; <nl> - <nl> + <nl> LinearLayoutParameter * lp3 = LinearLayoutParameter : : create ( ) ; <nl> button_scale9 - > setLayoutParameter ( lp3 ) ; <nl> lp3 - > setGravity ( LinearLayoutParameter : : LinearGravity : : CENTER_HORIZONTAL ) ; <nl> lp3 - > setMargin ( Margin ( 0 . 0f , 10 . 0f , 0 . 0f , 10 . 0f ) ) ; <nl> - <nl> - <nl> + <nl> + <nl> return true ; <nl> } <nl> - <nl> + <nl> return false ; <nl> } <nl> <nl> bool UILayoutTest_Layout_Linear_Horizontal : : init ( ) <nl> if ( UIScene : : init ( ) ) <nl> { <nl> Size widgetSize = _widget - > getContentSize ( ) ; <nl> - <nl> + <nl> / / Add the alert <nl> Text * alert = Text : : create ( " Layout Linear Horizontal " , " fonts / Marker Felt . ttf " , 20 ) ; <nl> alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> alert - > setPosition ( Vec2 ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getContentSize ( ) . height * 4 . 5f ) ) ; <nl> _uiLayer - > addChild ( alert ) ; <nl> - <nl> + <nl> Layout * root = static_cast < Layout * > ( _uiLayer - > getChildByTag ( 81 ) ) ; <nl> - <nl> + <nl> Layout * background = dynamic_cast < Layout * > ( root - > getChildByName ( " background_Panel " ) ) ; <nl> - <nl> + <nl> / / Create the layout <nl> Layout * layout = Layout : : create ( ) ; <nl> layout - > setLayoutType ( LayoutType : : HORIZONTAL ) ; <nl> bool UILayoutTest_Layout_Linear_Horizontal : : init ( ) <nl> layout - > setContentSize ( Size ( 280 , 150 ) ) ; <nl> Size backgroundSize = background - > getContentSize ( ) ; <nl> layout - > setPosition ( Vec2 ( ( widgetSize . width - backgroundSize . width ) / 2 . 0f + <nl> - ( backgroundSize . width - layout - > getContentSize ( ) . width ) / 2 . 0f , <nl> - ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> - ( backgroundSize . height - layout - > getContentSize ( ) . height ) / 2 . 0f ) ) ; <nl> + ( backgroundSize . width - layout - > getContentSize ( ) . width ) / 2 . 0f , <nl> + ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> + ( backgroundSize . height - layout - > getContentSize ( ) . height ) / 2 . 0f ) ) ; <nl> _uiLayer - > addChild ( layout ) ; <nl> - <nl> + <nl> Button * button = Button : : create ( " cocosui / animationbuttonnormal . png " , " cocosui / animationbuttonpressed . png " ) ; <nl> layout - > addChild ( button ) ; <nl> - <nl> + <nl> LinearLayoutParameter * lp1 = LinearLayoutParameter : : create ( ) ; <nl> button - > setLayoutParameter ( lp1 ) ; <nl> lp1 - > setGravity ( LinearLayoutParameter : : LinearGravity : : CENTER_VERTICAL ) ; <nl> lp1 - > setMargin ( Margin ( 0 . 0f , 10 . 0f , 0 . 0f , 10 . 0f ) ) ; <nl> - <nl> - <nl> + <nl> + <nl> Button * titleButton = Button : : create ( " cocosui / backtotopnormal . png " , " cocosui / backtotoppressed . png " ) ; <nl> titleButton - > setTitleText ( " Title Button " ) ; <nl> layout - > addChild ( titleButton ) ; <nl> - <nl> + <nl> LinearLayoutParameter * lp2 = LinearLayoutParameter : : create ( ) ; <nl> titleButton - > setLayoutParameter ( lp2 ) ; <nl> lp2 - > setGravity ( LinearLayoutParameter : : LinearGravity : : CENTER_VERTICAL ) ; <nl> lp2 - > setMargin ( Margin ( 0 . 0f , 10 . 0f , 0 . 0f , 10 . 0f ) ) ; <nl> - <nl> - <nl> + <nl> + <nl> Button * button_scale9 = Button : : create ( " cocosui / button . png " , " cocosui / buttonHighlighted . png " ) ; <nl> button_scale9 - > setScale9Enabled ( true ) ; <nl> button_scale9 - > setContentSize ( Size ( 100 . 0f , button_scale9 - > getVirtualRendererSize ( ) . height ) ) ; <nl> layout - > addChild ( button_scale9 ) ; <nl> - <nl> + <nl> LinearLayoutParameter * lp3 = LinearLayoutParameter : : create ( ) ; <nl> button_scale9 - > setLayoutParameter ( lp3 ) ; <nl> lp3 - > setGravity ( LinearLayoutParameter : : LinearGravity : : CENTER_VERTICAL ) ; <nl> lp3 - > setMargin ( Margin ( 0 . 0f , 10 . 0f , 0 . 0f , 10 . 0f ) ) ; <nl> - <nl> - <nl> + <nl> + <nl> return true ; <nl> } <nl> - <nl> + <nl> return false ; <nl> } <nl> <nl> bool UILayoutTest_Layout_Relative_Align_Parent : : init ( ) <nl> if ( UIScene : : init ( ) ) <nl> { <nl> Size widgetSize = _widget - > getContentSize ( ) ; <nl> - <nl> + <nl> / / Add the alert <nl> Text * alert = Text : : create ( " Layout Relative Align Parent " , " fonts / Marker Felt . ttf " , 20 ) ; <nl> alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> alert - > setPosition ( Vec2 ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getContentSize ( ) . height * 4 . 5f ) ) ; <nl> _uiLayer - > addChild ( alert ) ; <nl> - <nl> + <nl> Layout * root = static_cast < Layout * > ( _uiLayer - > getChildByTag ( 81 ) ) ; <nl> - <nl> + <nl> Layout * background = dynamic_cast < Layout * > ( root - > getChildByName ( " background_Panel " ) ) ; <nl> - <nl> + <nl> / / Create the layout <nl> Layout * layout = Layout : : create ( ) ; <nl> layout - > setLayoutType ( LayoutType : : RELATIVE ) ; <nl> bool UILayoutTest_Layout_Relative_Align_Parent : : init ( ) <nl> layout - > setBackGroundColor ( Color3B : : GREEN ) ; <nl> Size backgroundSize = background - > getContentSize ( ) ; <nl> layout - > setPosition ( Vec2 ( ( widgetSize . width - backgroundSize . width ) / 2 . 0f + <nl> - ( backgroundSize . width - layout - > getContentSize ( ) . width ) / 2 . 0f , <nl> - ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> - ( backgroundSize . height - layout - > getContentSize ( ) . height ) / 2 . 0f ) ) ; <nl> + ( backgroundSize . width - layout - > getContentSize ( ) . width ) / 2 . 0f , <nl> + ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> + ( backgroundSize . height - layout - > getContentSize ( ) . height ) / 2 . 0f ) ) ; <nl> _uiLayer - > addChild ( layout ) ; <nl> - <nl> + <nl> / / top left <nl> Button * button_TopLeft = Button : : create ( " cocosui / animationbuttonnormal . png " , <nl> - " cocosui / animationbuttonpressed . png " ) ; <nl> + " cocosui / animationbuttonpressed . png " ) ; <nl> layout - > addChild ( button_TopLeft ) ; <nl> - <nl> + <nl> RelativeLayoutParameter * rp_TopLeft = RelativeLayoutParameter : : create ( ) ; <nl> rp_TopLeft - > setAlign ( RelativeLayoutParameter : : RelativeAlign : : PARENT_TOP_LEFT ) ; <nl> button_TopLeft - > setLayoutParameter ( rp_TopLeft ) ; <nl> - <nl> - <nl> + <nl> + <nl> / / top center horizontal <nl> Button * button_TopCenter = Button : : create ( " cocosui / animationbuttonnormal . png " , <nl> - " cocosui / animationbuttonpressed . png " ) ; <nl> + " cocosui / animationbuttonpressed . png " ) ; <nl> layout - > addChild ( button_TopCenter ) ; <nl> - <nl> + <nl> RelativeLayoutParameter * rp_TopCenter = RelativeLayoutParameter : : create ( ) ; <nl> rp_TopCenter - > setAlign ( RelativeLayoutParameter : : RelativeAlign : : PARENT_TOP_CENTER_HORIZONTAL ) ; <nl> button_TopCenter - > setLayoutParameter ( rp_TopCenter ) ; <nl> - <nl> - <nl> + <nl> + <nl> / / top right <nl> Button * button_TopRight = Button : : create ( " cocosui / animationbuttonnormal . png " , <nl> - " cocosui / animationbuttonpressed . png " ) ; <nl> + " cocosui / animationbuttonpressed . png " ) ; <nl> layout - > addChild ( button_TopRight ) ; <nl> - <nl> + <nl> RelativeLayoutParameter * rp_TopRight = RelativeLayoutParameter : : create ( ) ; <nl> rp_TopRight - > setAlign ( RelativeLayoutParameter : : RelativeAlign : : PARENT_TOP_RIGHT ) ; <nl> button_TopRight - > setLayoutParameter ( rp_TopRight ) ; <nl> - <nl> - <nl> + <nl> + <nl> / / left center <nl> Button * button_LeftCenter = Button : : create ( " cocosui / animationbuttonnormal . png " , <nl> - " cocosui / animationbuttonpressed . png " ) ; <nl> + " cocosui / animationbuttonpressed . png " ) ; <nl> layout - > addChild ( button_LeftCenter ) ; <nl> - <nl> + <nl> RelativeLayoutParameter * rp_LeftCenter = RelativeLayoutParameter : : create ( ) ; <nl> rp_LeftCenter - > setAlign ( RelativeLayoutParameter : : RelativeAlign : : PARENT_LEFT_CENTER_VERTICAL ) ; <nl> button_LeftCenter - > setLayoutParameter ( rp_LeftCenter ) ; <nl> - <nl> - <nl> + <nl> + <nl> / / center <nl> Button * buttonCenter = Button : : create ( " cocosui / animationbuttonnormal . png " , <nl> - " cocosui / animationbuttonpressed . png " ) ; <nl> + " cocosui / animationbuttonpressed . png " ) ; <nl> layout - > addChild ( buttonCenter ) ; <nl> - <nl> + <nl> RelativeLayoutParameter * rpCenter = RelativeLayoutParameter : : create ( ) ; <nl> rpCenter - > setAlign ( RelativeLayoutParameter : : RelativeAlign : : CENTER_IN_PARENT ) ; <nl> buttonCenter - > setLayoutParameter ( rpCenter ) ; <nl> - <nl> - <nl> + <nl> + <nl> / / right center <nl> Button * button_RightCenter = Button : : create ( " cocosui / animationbuttonnormal . png " , <nl> - " cocosui / animationbuttonpressed . png " ) ; <nl> + " cocosui / animationbuttonpressed . png " ) ; <nl> layout - > addChild ( button_RightCenter ) ; <nl> - <nl> + <nl> RelativeLayoutParameter * rp_RightCenter = RelativeLayoutParameter : : create ( ) ; <nl> rp_RightCenter - > setAlign ( RelativeLayoutParameter : : RelativeAlign : : PARENT_RIGHT_CENTER_VERTICAL ) ; <nl> button_RightCenter - > setLayoutParameter ( rp_RightCenter ) ; <nl> - <nl> - <nl> + <nl> + <nl> / / left bottom <nl> Button * button_LeftBottom = Button : : create ( " cocosui / animationbuttonnormal . png " , <nl> - " cocosui / animationbuttonpressed . png " ) ; <nl> + " cocosui / animationbuttonpressed . png " ) ; <nl> layout - > addChild ( button_LeftBottom ) ; <nl> - <nl> + <nl> RelativeLayoutParameter * rp_LeftBottom = RelativeLayoutParameter : : create ( ) ; <nl> rp_LeftBottom - > setAlign ( RelativeLayoutParameter : : RelativeAlign : : PARENT_LEFT_BOTTOM ) ; <nl> button_LeftBottom - > setLayoutParameter ( rp_LeftBottom ) ; <nl> - <nl> - <nl> + <nl> + <nl> / / bottom center <nl> Button * button_BottomCenter = Button : : create ( " cocosui / animationbuttonnormal . png " , <nl> - " cocosui / animationbuttonpressed . png " ) ; <nl> + " cocosui / animationbuttonpressed . png " ) ; <nl> layout - > addChild ( button_BottomCenter ) ; <nl> - <nl> + <nl> RelativeLayoutParameter * rp_BottomCenter = RelativeLayoutParameter : : create ( ) ; <nl> rp_BottomCenter - > setAlign ( RelativeLayoutParameter : : RelativeAlign : : PARENT_BOTTOM_CENTER_HORIZONTAL ) ; <nl> button_BottomCenter - > setLayoutParameter ( rp_BottomCenter ) ; <nl> - <nl> - <nl> + <nl> + <nl> / / right bottom <nl> Button * button_RightBottom = Button : : create ( " cocosui / animationbuttonnormal . png " , <nl> - " cocosui / animationbuttonpressed . png " ) ; <nl> + " cocosui / animationbuttonpressed . png " ) ; <nl> layout - > addChild ( button_RightBottom ) ; <nl> - <nl> + <nl> RelativeLayoutParameter * rp_RightBottom = RelativeLayoutParameter : : create ( ) ; <nl> rp_RightBottom - > setAlign ( RelativeLayoutParameter : : RelativeAlign : : PARENT_RIGHT_BOTTOM ) ; <nl> button_RightBottom - > setLayoutParameter ( rp_RightBottom ) ; <nl> - <nl> - <nl> + <nl> + <nl> return true ; <nl> } <nl> - <nl> + <nl> return false ; <nl> } <nl> <nl> bool UILayoutTest_Layout_Relative_Location : : init ( ) <nl> if ( UIScene : : init ( ) ) <nl> { <nl> Size widgetSize = _widget - > getContentSize ( ) ; <nl> - <nl> + <nl> / / Add the alert <nl> Text * alert = Text : : create ( " Layout Relative Location " , " fonts / Marker Felt . ttf " , 20 ) ; <nl> alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> alert - > setPosition ( Vec2 ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getContentSize ( ) . height * 4 . 5f ) ) ; <nl> _uiLayer - > addChild ( alert ) ; <nl> - <nl> + <nl> Layout * root = static_cast < Layout * > ( _uiLayer - > getChildByTag ( 81 ) ) ; <nl> - <nl> + <nl> Layout * background = dynamic_cast < Layout * > ( root - > getChildByName ( " background_Panel " ) ) ; <nl> - <nl> + <nl> / / Create the layout <nl> Layout * layout = Layout : : create ( ) ; <nl> layout - > setLayoutType ( LayoutType : : RELATIVE ) ; <nl> layout - > setContentSize ( Size ( 280 , 150 ) ) ; <nl> Size backgroundSize = background - > getContentSize ( ) ; <nl> layout - > setPosition ( Vec2 ( ( widgetSize . width - backgroundSize . width ) / 2 . 0f + <nl> - ( backgroundSize . width - layout - > getContentSize ( ) . width ) / 2 . 0f , <nl> - ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> - ( backgroundSize . height - layout - > getContentSize ( ) . height ) / 2 . 0f ) ) ; <nl> + ( backgroundSize . width - layout - > getContentSize ( ) . width ) / 2 . 0f , <nl> + ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> + ( backgroundSize . height - layout - > getContentSize ( ) . height ) / 2 . 0f ) ) ; <nl> _uiLayer - > addChild ( layout ) ; <nl> - <nl> + <nl> / / center <nl> ImageView * imageView_Center = ImageView : : create ( " cocosui / scrollviewbg . png " ) ; <nl> layout - > addChild ( imageView_Center ) ; <nl> - <nl> + <nl> RelativeLayoutParameter * rp_Center = RelativeLayoutParameter : : create ( ) ; <nl> rp_Center - > setRelativeName ( " rp_Center " ) ; <nl> rp_Center - > setAlign ( RelativeLayoutParameter : : RelativeAlign : : CENTER_IN_PARENT ) ; <nl> imageView_Center - > setLayoutParameter ( rp_Center ) ; <nl> - <nl> - <nl> + <nl> + <nl> / / above center <nl> ImageView * imageView_AboveCenter = ImageView : : create ( " cocosui / switch - mask . png " ) ; <nl> layout - > addChild ( imageView_AboveCenter ) ; <nl> - <nl> + <nl> RelativeLayoutParameter * rp_AboveCenter = RelativeLayoutParameter : : create ( ) ; <nl> rp_AboveCenter - > setRelativeToWidgetName ( " rp_Center " ) ; <nl> rp_AboveCenter - > setAlign ( RelativeLayoutParameter : : RelativeAlign : : LOCATION_ABOVE_CENTER ) ; <nl> imageView_AboveCenter - > setLayoutParameter ( rp_AboveCenter ) ; <nl> - <nl> - <nl> + <nl> + <nl> / / below center <nl> ImageView * imageView_BelowCenter = ImageView : : create ( " cocosui / switch - mask . png " ) ; <nl> layout - > addChild ( imageView_BelowCenter ) ; <nl> - <nl> + <nl> RelativeLayoutParameter * rp_BelowCenter = RelativeLayoutParameter : : create ( ) ; <nl> rp_BelowCenter - > setRelativeToWidgetName ( " rp_Center " ) ; <nl> rp_BelowCenter - > setAlign ( RelativeLayoutParameter : : RelativeAlign : : LOCATION_BELOW_CENTER ) ; <nl> imageView_BelowCenter - > setLayoutParameter ( rp_BelowCenter ) ; <nl> - <nl> - <nl> + <nl> + <nl> / / left center <nl> ImageView * imageView_LeftCenter = ImageView : : create ( " cocosui / switch - mask . png " ) ; <nl> layout - > addChild ( imageView_LeftCenter ) ; <nl> - <nl> + <nl> RelativeLayoutParameter * rp_LeftCenter = RelativeLayoutParameter : : create ( ) ; <nl> rp_LeftCenter - > setRelativeToWidgetName ( " rp_Center " ) ; <nl> rp_LeftCenter - > setAlign ( RelativeLayoutParameter : : RelativeAlign : : LOCATION_LEFT_OF_CENTER ) ; <nl> imageView_LeftCenter - > setLayoutParameter ( rp_LeftCenter ) ; <nl> - <nl> - <nl> - <nl> + <nl> + <nl> + <nl> / / right center <nl> ImageView * imageView_RightCenter = ImageView : : create ( " cocosui / switch - mask . png " ) ; <nl> layout - > addChild ( imageView_RightCenter ) ; <nl> - <nl> + <nl> RelativeLayoutParameter * rp_RightCenter = RelativeLayoutParameter : : create ( ) ; <nl> rp_RightCenter - > setRelativeToWidgetName ( " rp_Center " ) ; <nl> rp_RightCenter - > setAlign ( RelativeLayoutParameter : : RelativeAlign : : LOCATION_RIGHT_OF_CENTER ) ; <nl> imageView_RightCenter - > setLayoutParameter ( rp_RightCenter ) ; <nl> - <nl> - <nl> + <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + return false ; <nl> + } <nl> + <nl> + bool UILayoutComponentTest : : init ( ) <nl> + { <nl> + if ( UIScene : : init ( ) ) <nl> + { <nl> + Size widgetSize = _widget - > getContentSize ( ) ; <nl> + <nl> + _baseLayer = LayerColor : : create ( ) ; <nl> + _baseLayer - > setColor ( Color3B ( 50 , 100 , 0 ) ) ; <nl> + _baseLayer - > setOpacity ( 100 ) ; <nl> + _baseLayer - > setContentSize ( Size ( 200 , 200 ) ) ; <nl> + _uiLayer - > addChild ( _baseLayer ) ; <nl> + <nl> + Button * button = Button : : create ( " cocosui / animationbuttonnormal . png " ) ; <nl> + CCLOG ( " content size should be greater than 0 : width = % f , height = % f " , button - > getContentSize ( ) . width , <nl> + button - > getContentSize ( ) . height ) ; <nl> + button - > setPosition ( Vec2 ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f ) ) ; <nl> + button - > addTouchEventListener ( CC_CALLBACK_2 ( UILayoutComponentTest : : touchEvent , this ) ) ; <nl> + button - > setZoomScale ( 0 . 4f ) ; <nl> + button - > setPressedActionEnabled ( true ) ; <nl> + _uiLayer - > addChild ( button ) ; <nl> + <nl> + return true ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + void UILayoutComponentTest : : touchEvent ( Ref * pSender , Widget : : TouchEventType type ) <nl> + { <nl> + switch ( type ) <nl> + { <nl> + case Widget : : TouchEventType : : BEGAN : <nl> + break ; <nl> + <nl> + case Widget : : TouchEventType : : MOVED : <nl> + break ; <nl> + <nl> + case Widget : : TouchEventType : : ENDED : <nl> + { <nl> + Size widgetSize = _widget - > getContentSize ( ) ; <nl> + Size layerSize = _baseLayer - > getContentSize ( ) ; <nl> + if ( layerSize . width = = widgetSize . width & & layerSize . height = = widgetSize . height ) <nl> + _baseLayer - > setContentSize ( Size ( 200 , 200 ) ) ; <nl> + else <nl> + _baseLayer - > setContentSize ( widgetSize ) ; <nl> + ui : Helper : : doLayout ( _baseLayer ) ; <nl> + } <nl> + break ; <nl> + <nl> + case Widget : : TouchEventType : : CANCELED : <nl> + break ; <nl> + <nl> + default : <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + bool UILayoutComponent_Berth_Test : : init ( ) <nl> + { <nl> + if ( UILayoutComponentTest : : init ( ) ) <nl> + { <nl> + Sprite * leftTopSprite = Sprite : : create ( " cocosui / CloseSelected . png " ) ; <nl> + LayoutComponent * leftTop = LayoutComponent : : boundingLayoutForNode ( leftTopSprite ) ; <nl> + leftTop - > setHorizontalEage ( LayoutComponent : : HorizontalEage : : Left ) ; <nl> + leftTop - > setVerticalEage ( LayoutComponent : : VerticalEage : : Top ) ; <nl> + _baseLayer - > addChild ( leftTopSprite ) ; <nl> + <nl> + Sprite * leftBottomSprite = Sprite : : create ( " cocosui / CloseSelected . png " ) ; <nl> + LayoutComponent * leftBottom = LayoutComponent : : boundingLayoutForNode ( leftBottomSprite ) ; <nl> + leftBottom - > setHorizontalEage ( LayoutComponent : : HorizontalEage : : Left ) ; <nl> + leftBottom - > setVerticalEage ( LayoutComponent : : VerticalEage : : Bottom ) ; <nl> + _baseLayer - > addChild ( leftBottomSprite ) ; <nl> + <nl> + Sprite * rightTopSprite = Sprite : : create ( " cocosui / CloseSelected . png " ) ; <nl> + LayoutComponent * rightTop = LayoutComponent : : boundingLayoutForNode ( rightTopSprite ) ; <nl> + rightTop - > setHorizontalEage ( LayoutComponent : : HorizontalEage : : Right ) ; <nl> + rightTop - > setVerticalEage ( LayoutComponent : : VerticalEage : : Top ) ; <nl> + _baseLayer - > addChild ( rightTopSprite ) ; <nl> + <nl> + Sprite * rightBottomSprite = Sprite : : create ( " cocosui / CloseSelected . png " ) ; <nl> + LayoutComponent * rightBottom = LayoutComponent : : boundingLayoutForNode ( rightBottomSprite ) ; <nl> + rightBottom - > setHorizontalEage ( LayoutComponent : : HorizontalEage : : Right ) ; <nl> + rightBottom - > setVerticalEage ( LayoutComponent : : VerticalEage : : Bottom ) ; <nl> + _baseLayer - > addChild ( rightBottomSprite ) ; <nl> + <nl> + ui : : Helper : : doLayout ( _baseLayer ) ; <nl> + <nl> + return true ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + bool UILayoutComponent_Berth_Stretch_Test : : init ( ) <nl> + { <nl> + if ( UILayoutComponentTest : : init ( ) ) <nl> + { <nl> + ImageView * leftTopSprite = ImageView : : create ( " cocosui / CloseSelected . png " ) ; <nl> + leftTopSprite - > ignoreContentAdaptWithSize ( false ) ; <nl> + LayoutComponent * leftTop = LayoutComponent : : boundingLayoutForNode ( leftTopSprite ) ; <nl> + leftTop - > setHorizontalEage ( LayoutComponent : : HorizontalEage : : Left ) ; <nl> + leftTop - > setVerticalEage ( LayoutComponent : : VerticalEage : : Top ) ; <nl> + leftTop - > setStretchWidthEnabled ( true ) ; <nl> + leftTop - > setStretchHeightEnabled ( true ) ; <nl> + _baseLayer - > addChild ( leftTopSprite ) ; <nl> + leftTop - > setSize ( leftTopSprite - > getContentSize ( ) ) ; <nl> + leftTop - > setLeftMargin ( 0 ) ; <nl> + leftTop - > setTopMargin ( 0 ) ; <nl> + <nl> + ImageView * leftBottomSprite = ImageView : : create ( " cocosui / CloseSelected . png " ) ; <nl> + leftBottomSprite - > ignoreContentAdaptWithSize ( false ) ; <nl> + LayoutComponent * leftBottom = LayoutComponent : : boundingLayoutForNode ( leftBottomSprite ) ; <nl> + leftBottom - > setHorizontalEage ( LayoutComponent : : HorizontalEage : : Left ) ; <nl> + leftBottom - > setVerticalEage ( LayoutComponent : : VerticalEage : : Bottom ) ; <nl> + leftBottom - > setStretchWidthEnabled ( true ) ; <nl> + leftBottom - > setStretchHeightEnabled ( true ) ; <nl> + _baseLayer - > addChild ( leftBottomSprite ) ; <nl> + leftBottom - > setSize ( leftBottomSprite - > getContentSize ( ) ) ; <nl> + leftBottom - > setLeftMargin ( 0 ) ; <nl> + leftBottom - > setButtomMargin ( 0 ) ; <nl> + <nl> + ImageView * rightTopSprite = ImageView : : create ( " cocosui / CloseSelected . png " ) ; <nl> + rightTopSprite - > ignoreContentAdaptWithSize ( false ) ; <nl> + LayoutComponent * rightTop = LayoutComponent : : boundingLayoutForNode ( rightTopSprite ) ; <nl> + rightTop - > setHorizontalEage ( LayoutComponent : : HorizontalEage : : Right ) ; <nl> + rightTop - > setVerticalEage ( LayoutComponent : : VerticalEage : : Top ) ; <nl> + rightTop - > setStretchWidthEnabled ( true ) ; <nl> + rightTop - > setStretchHeightEnabled ( true ) ; <nl> + _baseLayer - > addChild ( rightTopSprite ) ; <nl> + rightTop - > setSize ( rightTopSprite - > getContentSize ( ) ) ; <nl> + rightTop - > setTopMargin ( 0 ) ; <nl> + rightTop - > setRightMargin ( 0 ) ; <nl> + <nl> + ImageView * rightBottomSprite = ImageView : : create ( " cocosui / CloseSelected . png " ) ; <nl> + rightBottomSprite - > ignoreContentAdaptWithSize ( false ) ; <nl> + LayoutComponent * rightBottom = LayoutComponent : : boundingLayoutForNode ( rightBottomSprite ) ; <nl> + rightBottom - > setHorizontalEage ( LayoutComponent : : HorizontalEage : : Right ) ; <nl> + rightBottom - > setVerticalEage ( LayoutComponent : : VerticalEage : : Bottom ) ; <nl> + rightBottom - > setStretchWidthEnabled ( true ) ; <nl> + rightBottom - > setStretchHeightEnabled ( true ) ; <nl> + _baseLayer - > addChild ( rightBottomSprite ) ; <nl> + rightBottom - > setSize ( rightBottomSprite - > getContentSize ( ) ) ; <nl> + rightBottom - > setButtomMargin ( 0 ) ; <nl> + rightBottom - > setRightMargin ( 0 ) ; <nl> + <nl> + ui : : Helper : : doLayout ( _baseLayer ) ; <nl> + <nl> return true ; <nl> } <nl> - <nl> return false ; <nl> } <nl> <nl> mmm a / tests / cpp - tests / Classes / UITest / CocoStudioGUITest / UILayoutTest / UILayoutTest . h <nl> ppp b / tests / cpp - tests / Classes / UITest / CocoStudioGUITest / UILayoutTest / UILayoutTest . h <nl> class UILayoutTest_Layout_Relative_Location : public UIScene <nl> UI_SCENE_CREATE_FUNC ( UILayoutTest_Layout_Relative_Location ) <nl> } ; <nl> <nl> + class UILayoutComponentTest : public UIScene <nl> + { <nl> + public : <nl> + virtual bool init ( ) ; <nl> + void touchEvent ( Ref * pSender , Widget : : TouchEventType type ) ; <nl> + protected : <nl> + LayerColor * _baseLayer ; <nl> + UI_SCENE_CREATE_FUNC ( UILayoutComponentTest ) <nl> + } ; <nl> + <nl> + class UILayoutComponent_Berth_Test : public UILayoutComponentTest <nl> + { <nl> + public : <nl> + virtual bool init ( ) override ; <nl> + protected : <nl> + UI_SCENE_CREATE_FUNC ( UILayoutComponent_Berth_Test ) <nl> + } ; <nl> + <nl> + class UILayoutComponent_Berth_Stretch_Test : public UILayoutComponentTest <nl> + { <nl> + public : <nl> + virtual bool init ( ) override ; <nl> + protected : <nl> + UI_SCENE_CREATE_FUNC ( UILayoutComponent_Berth_Stretch_Test ) <nl> + } ; <nl> + <nl> / * <nl> class UILayoutTest_Layout_Grid : public UIScene <nl> { <nl> mmm a / tests / cpp - tests / Classes / UITest / CocoStudioGUITest / UISceneManager . cpp <nl> ppp b / tests / cpp - tests / Classes / UITest / CocoStudioGUITest / UISceneManager . cpp <nl> static const char * s_testArray [ ] = <nl> " UILayoutTest_Layout_Linear_Horizontal " , <nl> " UILayoutTest_Layout_Relative_Align_Parent " , <nl> " UILayoutTest_Layout_Relative_Location " , <nl> + " UILayoutComponent_Berth_Test " , <nl> + " UILayoutComponent_Berth_Stretch_Test " , <nl> <nl> " UIScrollViewTest_Vertical " , <nl> " UIScrollViewTest_Horizontal " , <nl> Scene * UISceneManager : : currentUIScene ( ) <nl> case kUILayoutTest_Layout_Relative_Location : <nl> return UILayoutTest_Layout_Relative_Location : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> <nl> + case kUILayoutComponent_Berth_Test : <nl> + return UILayoutComponent_Berth_Test : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> + <nl> + case kUILayoutComponent_Berth_Stretch_Test : <nl> + return UILayoutComponent_Berth_Stretch_Test : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> + <nl> case kUIScrollViewTest_Vertical : <nl> return UIScrollViewTest_Vertical : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> <nl> mmm a / tests / cpp - tests / Classes / UITest / CocoStudioGUITest / UISceneManager . h <nl> ppp b / tests / cpp - tests / Classes / UITest / CocoStudioGUITest / UISceneManager . h <nl> enum <nl> kUILayoutTest_Layout_Linear_Horizontal , <nl> kUILayoutTest_Layout_Relative_Align_Parent , <nl> kUILayoutTest_Layout_Relative_Location , <nl> + kUILayoutComponent_Berth_Test , <nl> + kUILayoutComponent_Berth_Stretch_Test , <nl> kUIScrollViewTest_Vertical , <nl> kUIScrollViewTest_Horizontal , <nl> kUIScrollViewTest_Both , <nl>
update for lay out samples
cocos2d/cocos2d-x
7c4d31feabde174be7980b97950b2f18165f987c
2014-12-22T06:51:50Z
mmm a / src / doc / test_context . h <nl> ppp b / src / doc / test_context . h <nl> namespace doc { <nl> } <nl> <nl> void onAddDocument ( Document * doc ) override { <nl> - notifyActiveDocumentChanged ( m_activeDoc = doc ) ; <nl> + this - > notifyActiveDocumentChanged ( m_activeDoc = doc ) ; <nl> } <nl> <nl> void onRemoveDocument ( Document * doc ) override { <nl> if ( m_activeDoc = = doc ) <nl> - notifyActiveDocumentChanged ( m_activeDoc = nullptr ) ; <nl> + this - > notifyActiveDocumentChanged ( m_activeDoc = nullptr ) ; <nl> } <nl> <nl> private : <nl>
Fix build of document_api_test . cpp
aseprite/aseprite
ad1290b1c8e236c92436d32e3c7442d8fbb88048
2015-04-27T16:08:21Z
mmm a / Marlin / Marlin . h <nl> ppp b / Marlin / Marlin . h <nl> float code_value_temp_diff ( ) ; <nl> extern float delta_diagonal_rod_trim_tower_3 ; <nl> void calculate_delta ( float cartesian [ 3 ] ) ; <nl> void recalc_delta_settings ( float radius , float diagonal_rod ) ; <nl> - float delta_safe_distance_from_top ( ) ; <nl> - void set_cartesian_from_steppers ( ) ; <nl> - void forwardKinematics ( float point [ 3 ] ) ; <nl> - void forwardKinematics ( float z1 , float z2 , float z3 ) ; <nl> # if ENABLED ( AUTO_BED_LEVELING_FEATURE ) <nl> extern int delta_grid_spacing [ 2 ] ; <nl> void adjust_delta ( float cartesian [ 3 ] ) ; <nl> mmm a / Marlin / Marlin_main . cpp <nl> ppp b / Marlin / Marlin_main . cpp <nl> static uint8_t target_extruder ; <nl> int delta_grid_spacing [ 2 ] = { 0 , 0 } ; <nl> float bed_level [ AUTO_BED_LEVELING_GRID_POINTS ] [ AUTO_BED_LEVELING_GRID_POINTS ] ; <nl> # endif <nl> + float delta_safe_distance_from_top ( ) ; <nl> # else <nl> static bool home_all_axis = true ; <nl> # endif <nl>
Move kinematic functions to " private " scope
MarlinFirmware/Marlin
4b1725628be3353fa09fbd283a8cf3a0144404c9
2016-07-22T23:36:33Z
mmm a / folly / Portability . h <nl> ppp b / folly / Portability . h <nl> constexpr auto kIsBigEndian = ! kIsLittleEndian ; <nl> ( FOLLY_SSE > major | | FOLLY_SSE = = major & & FOLLY_SSE_MINOR > = minor ) <nl> <nl> # ifndef FOLLY_NEON <nl> - # if defined ( __ARM_NEON ) <nl> + # if defined ( __ARM_NEON ) | | defined ( __ARM_NEON__ ) <nl> # define FOLLY_NEON 1 <nl> # endif <nl> # endif <nl>
include legacy __ARM_NEON__ check for FOLLY_NEON
facebook/folly
300298489cc162cbbf2f49ceae469135535081dd
2018-08-04T00:51:26Z
mmm a / atom / browser / browser . cc <nl> ppp b / atom / browser / browser . cc <nl> void Browser : : Shutdown ( ) { <nl> <nl> if ( base : : ThreadTaskRunnerHandle : : IsSet ( ) ) { <nl> base : : ThreadTaskRunnerHandle : : Get ( ) - > PostTask ( <nl> - FROM_HERE , base : : MessageLoop : : QuitWhenIdleClosure ( ) ) ; <nl> + FROM_HERE , base : : RunLoop : : QuitCurrentWhenIdleClosureDeprecated ( ) ) ; <nl> } else { <nl> / / There is no message loop available so we are in early stage . <nl> exit ( 0 ) ; <nl> mmm a / brightray / browser / browser_main_parts . cc <nl> ppp b / brightray / browser / browser_main_parts . cc <nl> int BrowserX11IOErrorHandler ( Display * d ) { <nl> g_in_x11_io_error_handler = true ; <nl> LOG ( ERROR ) < < " X IO error received ( X server probably went away ) " ; <nl> base : : ThreadTaskRunnerHandle : : Get ( ) - > PostTask ( <nl> - FROM_HERE , base : : MessageLoop : : QuitWhenIdleClosure ( ) ) ; <nl> + FROM_HERE , base : : RunLoop : : QuitCurrentWhenIdleClosureDeprecated ( ) ) ; <nl> <nl> return 0 ; <nl> } <nl>
MessageLoop : : QuitWhenIdleClosure - > RunLoop : : QuitCurrentWhenIdleClosureDeprecated
electron/electron
f0da5bce80eea148c8032653a8b7fbc7e2a1a4c2
2018-10-03T22:12:55Z
mmm a / stdlib / public / core / StringLegacy . swift <nl> ppp b / stdlib / public / core / StringLegacy . swift <nl> extension String { <nl> <nl> / / / Returns ` true ` iff ` self ` ends with ` suffix ` . <nl> public func hasSuffix ( _ suffix : String ) - > Bool { <nl> - if self . _core . hasContiguousStorage & & suffix . _core . hasContiguousStorage { <nl> - let lhsStr = _NSContiguousString ( self . _core ) <nl> - let rhsStr = _NSContiguousString ( suffix . _core ) <nl> + let selfCore = self . _core <nl> + let suffixCore = suffix . _core <nl> + if selfCore . hasContiguousStorage & & suffixCore . hasContiguousStorage { <nl> + if selfCore . isASCII & & suffixCore . isASCII { <nl> + / / Prefix longer than self . <nl> + let suffixCount = suffixCore . count <nl> + let selfCount = selfCore . count <nl> + if suffixCount > selfCount | | suffixCount = = 0 { <nl> + return false <nl> + } <nl> + return Int ( _swift_stdlib_memcmp ( <nl> + selfCore . startASCII + ( selfCount - suffixCount ) , <nl> + suffixCore . startASCII , suffixCount ) ) = = 0 <nl> + } <nl> + let lhsStr = _NSContiguousString ( selfCore ) <nl> + let rhsStr = _NSContiguousString ( suffixCore ) <nl> return lhsStr . _unsafeWithNotEscapedSelfPointerPair ( rhsStr ) { <nl> return _stdlib_NSStringHasSuffixNFDPointer ( $ 0 , $ 1 ) <nl> } <nl>
ASCII fast path for String ' s hasSuffix
apple/swift
eea243d9914a7f4a1bcde9f7277a2b3d6b8f26de
2016-04-19T18:08:28Z
new file mode 100644 <nl> index 000000000000 . . 1d4802e025af <nl> mmm / dev / null <nl> ppp b / include / swift / Syntax / AtomicCache . h <nl> <nl> + / / = = = mmmmmmmmmmmm - AtomicCache . h - Lazy Atomic Cache mmmmmmmmmmmm * - C + + - * - = = = / / <nl> + / / <nl> + / / This source file is part of the Swift . org open source project <nl> + / / <nl> + / / Copyright ( c ) 2014 - 2017 Apple Inc . and the Swift project authors <nl> + / / Licensed under Apache License v2 . 0 with Runtime Library Exception <nl> + / / <nl> + / / See https : / / swift . org / LICENSE . txt for license information <nl> + / / See https : / / swift . org / CONTRIBUTORS . txt for the list of Swift project authors <nl> + / / <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + <nl> + # ifndef SWIFT_SYNTAX_ATOMICCACHE_H <nl> + # define SWIFT_SYNTAX_ATOMICCACHE_H <nl> + <nl> + # include < functional > <nl> + # include " swift / Syntax / References . h " <nl> + <nl> + namespace swift { <nl> + <nl> + / / / AtomicCache is an atomic cache for a reference - counted value . It maintains <nl> + / / / a reference - counted pointer with a facility for atomically getting or <nl> + / / / creating it with a lambda . <nl> + template < typename T > <nl> + class AtomicCache { <nl> + / / Whatever type is created through this cache must be pointer - sized , <nl> + / / othwerise , we can ' t pretend it ' s a uintptr_t and use its <nl> + / / compare_exchange_strong . <nl> + static_assert ( sizeof ( uintptr_t ) = = sizeof ( RC < T > ) , <nl> + " RC < T > must be pointer sized ! " ) ; <nl> + private : <nl> + / / / This must only be mutated in one place : AtomicCache : : getOrCreate . <nl> + mutable RC < T > Storage = nullptr ; <nl> + <nl> + public : <nl> + / / / The empty constructor initializes the storage to nullptr . <nl> + AtomicCache ( ) { } <nl> + <nl> + / / / Gets the value inside the cache , or creates it atomically using the <nl> + / / / provided lambda if it doesn ' t already exist . <nl> + RC < T > getOrCreate ( std : : function < RC < T > ( ) > Create ) const { <nl> + auto & Ptr = * reinterpret_cast < std : : atomic < uintptr_t > * > ( & Storage ) ; <nl> + <nl> + / / If an atomic load gets an initialized value , then return Storage . <nl> + if ( Ptr ) { <nl> + return Storage ; <nl> + } <nl> + <nl> + / / We expect the uncached value to wrap a nullptr . If another thread <nl> + / / beats us to caching the child , it ' ll be non - null , so we would <nl> + / / leave it alone . <nl> + uintptr_t Expected = 0 ; <nl> + <nl> + / / Make a RC < T > at RefCount = = 1 , which we ' ll try to <nl> + / / atomically swap in . <nl> + auto Data = Create ( ) ; <nl> + <nl> + / / Try to swap in raw pointer value . <nl> + / / If we won , then leave the RefCount = = 1 . <nl> + if ( Ptr . compare_exchange_strong ( Expected , <nl> + reinterpret_cast < uintptr_t > ( Data . get ( ) ) ) ) { <nl> + Data . resetWithoutRelease ( ) ; <nl> + } <nl> + <nl> + / / Otherwise , the Data we just made is unfortunately useless . <nl> + / / Let it die on this scope exit after its terminal release . <nl> + <nl> + return Storage ; <nl> + } <nl> + } ; <nl> + <nl> + } / / end namespace swift <nl> + <nl> + # endif / * SWIFT_SYNTAX_ATOMICCACHE_H * / <nl> mmm a / include / swift / Syntax / DeclSyntax . h <nl> ppp b / include / swift / Syntax / DeclSyntax . h <nl> namespace swift { <nl> namespace syntax { <nl> <nl> class ExprSyntax ; <nl> - class ExprSyntaxData ; <nl> class CodeBlockStmtSyntax ; <nl> - class CodeBlockStmtSyntaxData ; <nl> - class TypeAttributesSyntax ; <nl> - class TypeAttributesSyntaxData ; <nl> - class DeclModifierListSyntax ; <nl> class GenericWhereClauseSyntax ; <nl> - class GenericWhereClauseSyntaxData ; <nl> - class GenericParameterListSyntax ; <nl> - class GenericParameterListSyntaxData ; <nl> - <nl> - # pragma mark declaration - modifier Data <nl> - <nl> - class DeclModifierSyntaxData final : public SyntaxData { <nl> - friend struct SyntaxFactory ; <nl> - friend class SyntaxData ; <nl> - friend class Syntax ; <nl> - friend class DeclModifierSyntax ; <nl> - <nl> - DeclModifierSyntaxData ( const RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - const CursorIndex IndexInParent = 0 ) ; <nl> - <nl> - static RC < DeclModifierSyntaxData > make ( const RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - const CursorIndex IndexInParent = 0 ) ; <nl> - <nl> - static RC < DeclModifierSyntaxData > makeBlank ( ) ; <nl> - <nl> - public : <nl> - static bool classof ( const SyntaxData * SD ) { <nl> - return SD - > getKind ( ) = = SyntaxKind : : DeclModifier ; <nl> - } <nl> - } ; <nl> <nl> # pragma mark declaration - modifier API <nl> <nl> class DeclModifierSyntax final : public Syntax { <nl> friend struct SyntaxFactory ; <nl> friend class Syntax ; <nl> friend class SyntaxData ; <nl> - friend class DeclModifierSyntaxData ; <nl> <nl> enum class Cursor : CursorIndex { <nl> Name , <nl> class DeclModifierSyntax final : public Syntax { <nl> RightParen <nl> } ; <nl> <nl> - DeclModifierSyntax ( const RC < SyntaxData > Root , const DataType * Data ) <nl> - : Syntax ( Root , Data ) { } <nl> + virtual void validate ( ) const override ; <nl> <nl> public : <nl> - using DataType = DeclModifierSyntaxData ; <nl> + static DeclModifierSyntax makeBlank ( ) ; <nl> + DeclModifierSyntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> + : Syntax ( Root , Data ) { } <nl> <nl> / / / Return the name of the modifier . <nl> RC < TokenSyntax > getName ( ) const ; <nl> class DeclModifierSyntax final : public Syntax { <nl> } <nl> } ; <nl> <nl> - # pragma mark declaration - modifiers Data <nl> - <nl> - using DeclModifierListSyntaxData = <nl> - SyntaxCollectionData < SyntaxKind : : DeclModifierList , DeclModifierSyntax > ; <nl> - <nl> - # pragma mark declaration - modifiers API <nl> - <nl> - class DeclModifierListSyntax final : <nl> - public SyntaxCollection < SyntaxKind : : DeclModifierList , DeclModifierSyntax > { <nl> - <nl> - friend struct SyntaxFactory ; <nl> - friend class Syntax ; <nl> - friend class SyntaxData ; <nl> - friend class FunctionDeclSyntax ; <nl> - <nl> - using DataType = DeclModifierListSyntaxData ; <nl> - <nl> - DeclModifierListSyntax ( const RC < SyntaxData > Root , const DataType * Data ) <nl> - : SyntaxCollection ( Root , Data ) { } <nl> - <nl> - public : <nl> - static bool classof ( const Syntax * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : DeclModifierList ; <nl> - } <nl> - } ; <nl> - <nl> - # pragma mark declaration Data <nl> - <nl> - class DeclSyntaxData : public SyntaxData { <nl> - protected : <nl> - DeclSyntaxData ( RC < RawSyntax > Raw , const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - <nl> - public : <nl> - static bool classof ( const SyntaxData * S ) { return S - > isDecl ( ) ; } <nl> - } ; <nl> - <nl> # pragma mark declaration API <nl> <nl> class DeclSyntax : public Syntax { <nl> friend class Syntax ; <nl> - using DataType = DeclSyntaxData ; <nl> protected : <nl> - DeclSyntax ( const RC < SyntaxData > Root , const DeclSyntaxData * Data ) ; <nl> + virtual void validate ( ) const override { } <nl> <nl> public : <nl> - static bool classof ( const SyntaxData * S ) { return S - > isDecl ( ) ; } <nl> - } ; <nl> - <nl> - # pragma mark - unknown - declaration Data <nl> - <nl> - class UnknownDeclSyntaxData : public UnknownSyntaxData { <nl> - UnknownDeclSyntaxData ( RC < RawSyntax > Raw , const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - public : <nl> - static RC < UnknownDeclSyntaxData > make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> + static DeclSyntax makeBlank ( ) ; <nl> + DeclSyntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> + : Syntax ( Root , Data ) { } <nl> <nl> - static bool classof ( const SyntaxData * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : UnknownDecl ; <nl> - } <nl> + static bool classof ( const SyntaxData * S ) { return S - > isDecl ( ) ; } <nl> } ; <nl> <nl> # pragma mark - unknown - declaration API <nl> <nl> class UnknownDeclSyntax : public UnknownSyntax { <nl> friend class SyntaxData ; <nl> - friend class UnknownStmtSyntaxData ; <nl> friend class LegacyASTTransformer ; <nl> <nl> - using DataType = UnknownDeclSyntaxData ; <nl> - <nl> - UnknownDeclSyntax ( const RC < SyntaxData > Root , <nl> - const UnknownDeclSyntaxData * Data ) ; <nl> + virtual void validate ( ) const override ; <nl> <nl> public : <nl> + static UnknownDeclSyntax makeBlank ( ) ; <nl> + UnknownDeclSyntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> + : UnknownSyntax ( Root , Data ) { } <nl> + <nl> static bool classof ( const Syntax * S ) { <nl> return S - > getKind ( ) = = SyntaxKind : : UnknownDecl ; <nl> } <nl> } ; <nl> <nl> - # pragma mark declaration - members Data <nl> - <nl> - class DeclMembersSyntaxData final : public SyntaxData { <nl> - friend class SyntaxData ; <nl> - friend class DeclMembersSyntaxBuilder ; <nl> - friend struct SyntaxFactory ; <nl> - <nl> - DeclMembersSyntaxData ( RC < RawSyntax > Raw , const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - <nl> - public : <nl> - static RC < DeclMembersSyntaxData > make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < DeclMembersSyntaxData > makeBlank ( ) ; <nl> - <nl> - static bool classof ( const SyntaxData * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : DeclMembers ; <nl> - } <nl> - } ; <nl> - <nl> # pragma mark - <nl> # pragma mark declaration - members API <nl> <nl> class DeclMembersSyntax final : public Syntax { <nl> - using DataType = DeclMembersSyntaxData ; <nl> friend struct SyntaxFactory ; <nl> friend class SyntaxData ; <nl> friend class Syntax ; <nl> friend class DeclMembersSyntaxBuilder ; <nl> friend class StructDeclSyntax ; <nl> <nl> - DeclMembersSyntax ( RC < SyntaxData > Root , <nl> - const DeclMembersSyntaxData * Data ) ; <nl> + virtual void validate ( ) const override { } <nl> + <nl> public : <nl> + static DeclMembersSyntax makeBlank ( ) ; <nl> + DeclMembersSyntax ( RC < SyntaxData > Root , const SyntaxData * Data ) <nl> + : Syntax ( Root , Data ) { } <nl> static bool classof ( const Syntax * S ) { <nl> return S - > getKind ( ) = = SyntaxKind : : DeclMembers ; <nl> } <nl> class DeclMembersSyntaxBuilder final { <nl> } ; <nl> <nl> # pragma mark - <nl> - # pragma mark struct - declaration Data <nl> - <nl> - class StructDeclSyntaxData final : public DeclSyntaxData { <nl> - friend class SyntaxData ; <nl> - friend class StructDeclSyntax ; <nl> - friend class StructDeclSyntaxBuilder ; <nl> - friend struct SyntaxFactory ; <nl> - <nl> - RC < GenericWhereClauseSyntaxData > CachedWhereClause ; <nl> - RC < GenericParameterClauseSyntaxData > CachedGenericParams ; <nl> - RC < DeclMembersSyntaxData > CachedMembers ; <nl> - <nl> - StructDeclSyntaxData ( RC < RawSyntax > Raw , const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - <nl> - static RC < StructDeclSyntaxData > make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < StructDeclSyntaxData > makeBlank ( ) ; <nl> - <nl> - public : <nl> - static bool classof ( const SyntaxData * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : StructDecl ; <nl> - } <nl> - } ; <nl> <nl> # pragma mark - struct - declaration API <nl> <nl> class StructDeclSyntaxData final : public DeclSyntaxData { <nl> / / / struct - members - > struct - member struct - members ? <nl> / / / struct - member - > declaration | compiler - control - statement <nl> class StructDeclSyntax final : public DeclSyntax { <nl> - using DataType = StructDeclSyntaxData ; <nl> friend struct SyntaxFactory ; <nl> friend class Syntax ; <nl> friend class SyntaxData ; <nl> - friend class StructDeclSyntaxData ; <nl> friend class StructDeclSyntaxBuilder ; <nl> <nl> enum class Cursor : CursorIndex { <nl> class StructDeclSyntax final : public DeclSyntax { <nl> Last = RightBrace , <nl> } ; <nl> <nl> - StructDeclSyntax ( const RC < SyntaxData > Root , const StructDeclSyntaxData * Data ) ; <nl> - <nl> - const StructDeclSyntaxData * getData ( ) const { <nl> - return cast < StructDeclSyntaxData > ( Data ) ; <nl> - } <nl> + virtual void validate ( ) const override ; <nl> <nl> public : <nl> + static StructDeclSyntax makeBlank ( ) ; <nl> + StructDeclSyntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> + : DeclSyntax ( Root , Data ) { } <nl> + <nl> / / / Return the ' struct ' keyword attached to the declaration . <nl> RC < TokenSyntax > getStructKeyword ( ) const ; <nl> <nl> class StructDeclSyntaxBuilder final { <nl> } ; <nl> <nl> # pragma mark - <nl> - # pragma mark - type - alias Data <nl> - <nl> - class TypeAliasDeclSyntaxData final : public DeclSyntaxData { <nl> - friend class SyntaxData ; <nl> - friend struct SyntaxFactory ; <nl> - friend class TypeAliasDeclSyntaxBuilder ; <nl> - <nl> - TypeAliasDeclSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < TypeAliasDeclSyntaxData > make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < TypeAliasDeclSyntaxData > makeBlank ( ) ; <nl> - <nl> - public : <nl> - static bool classof ( const SyntaxData * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : TypeAliasDecl ; <nl> - } <nl> - } ; <nl> <nl> # pragma mark - <nl> # pragma mark - type - alias API <nl> class TypeAliasDeclSyntaxData final : public DeclSyntaxData { <nl> class TypeAliasDeclSyntax final : public DeclSyntax { <nl> friend struct SyntaxFactory ; <nl> friend class SyntaxData ; <nl> - friend class TypeAliasDeclSyntaxData ; <nl> friend class TypeAliasDeclSyntaxBuilder ; <nl> <nl> - using DataType = TypeAliasDeclSyntaxData ; <nl> - <nl> enum Cursor : CursorIndex { <nl> TypeAliasKeyword , <nl> Identifier , <nl> class TypeAliasDeclSyntax final : public DeclSyntax { <nl> Type <nl> } ; <nl> <nl> - TypeAliasDeclSyntax ( RC < SyntaxData > Root , const TypeAliasDeclSyntaxData * Data ) ; <nl> + virtual void validate ( ) const override { } <nl> <nl> public : <nl> + static TypeAliasDeclSyntax makeBlank ( ) ; <nl> + TypeAliasDeclSyntax ( RC < SyntaxData > Root , const SyntaxData * Data ) <nl> + : DeclSyntax ( Root , Data ) { } <nl> + <nl> / / / Return the ' typealias ' keyword for the declaration . <nl> RC < TokenSyntax > getTypealiasKeyword ( ) const { <nl> return cast < TokenSyntax > ( getRaw ( ) - > getChild ( Cursor : : TypeAliasKeyword ) ) ; <nl> class TypeAliasDeclSyntaxBuilder final { <nl> TypeAliasDeclSyntax build ( ) const ; <nl> } ; <nl> <nl> - # pragma mark - function - parameter Data <nl> - <nl> - class FunctionParameterSyntaxData final : public SyntaxData { <nl> - <nl> - friend struct SyntaxFactory ; <nl> - friend class Syntax ; <nl> - friend class SyntaxData ; <nl> - friend class FunctionParameterSyntax ; <nl> - <nl> - RC < TypeSyntaxData > CachedTypeSyntax ; <nl> - RC < ExprSyntaxData > CachedDefaultValue ; <nl> - <nl> - FunctionParameterSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < FunctionParameterSyntaxData > <nl> - make ( RC < RawSyntax > Raw , const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < FunctionParameterSyntaxData > makeBlank ( ) ; <nl> - <nl> - public : <nl> - static bool classof ( const SyntaxData * SD ) { <nl> - return SD - > getKind ( ) = = SyntaxKind : : FunctionParameter ; <nl> - } <nl> - } ; <nl> - <nl> # pragma mark - function - parameter API <nl> <nl> / / / parameter - > <nl> class FunctionParameterSyntax final : public Syntax { <nl> friend struct SyntaxFactory ; <nl> friend class Syntax ; <nl> friend class SyntaxData ; <nl> - friend class FunctionParameterSyntaxData ; <nl> <nl> enum class Cursor : CursorIndex { <nl> ExternalName , <nl> class FunctionParameterSyntax final : public Syntax { <nl> TrailingComma , <nl> } ; <nl> <nl> + virtual void validate ( ) const override ; <nl> + <nl> public : <nl> - using DataType = FunctionParameterSyntaxData ; <nl> + static FunctionParameterSyntax makeBlank ( ) ; <nl> <nl> - FunctionParameterSyntax ( const RC < SyntaxData > Root , const DataType * Data ) <nl> + FunctionParameterSyntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> : Syntax ( Root , Data ) { } <nl> <nl> / / / Get the external name of the parameter , if there is one . <nl> class FunctionParameterSyntax final : public Syntax { <nl> # pragma mark - function - parameter - list API <nl> <nl> / / / parameter - list - > parameter | parameter ' , ' parameter - list <nl> - class FunctionParameterListSyntax final : public <nl> - SyntaxCollection < SyntaxKind : : FunctionParameterList , FunctionParameterSyntax > { <nl> - friend struct SyntaxFactory ; <nl> - friend class Syntax ; <nl> - friend class SyntaxData ; <nl> - friend class FunctionSignatureSyntax ; <nl> - <nl> - using DataType = FunctionParameterListSyntaxData ; <nl> - <nl> - FunctionParameterListSyntax ( const RC < SyntaxData > Root , <nl> - const DataType * Data ) <nl> - : SyntaxCollection ( Root , Data ) { } <nl> - <nl> - public : <nl> - static bool classof ( const Syntax * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : FunctionParameterList ; <nl> - } <nl> - } ; <nl> - <nl> - # pragma mark - function - signature Data <nl> - <nl> - class FunctionSignatureSyntaxData final : public SyntaxData { <nl> - friend struct SyntaxFactory ; <nl> - friend class SyntaxData ; <nl> - friend class FunctionSignatureSyntax ; <nl> - <nl> - RC < FunctionParameterListSyntaxData > CachedParameterList ; <nl> - RC < TypeAttributesSyntaxData > CachedReturnTypeAttributes ; <nl> - RC < TypeSyntaxData > CachedReturnTypeSyntax ; <nl> - <nl> - FunctionSignatureSyntaxData ( const RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - const CursorIndex IndexInParent = 0 ) ; <nl> - <nl> - static RC < FunctionSignatureSyntaxData > <nl> - make ( RC < RawSyntax > Raw , const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < FunctionSignatureSyntaxData > makeBlank ( ) ; <nl> - <nl> - public : <nl> - static bool classof ( const SyntaxData * SD ) { <nl> - return SD - > getKind ( ) = = SyntaxKind : : FunctionSignature ; <nl> - } <nl> - } ; <nl> + using FunctionParameterListSyntax = <nl> + SyntaxCollection < SyntaxKind : : FunctionParameterList , FunctionParameterSyntax > ; <nl> <nl> # pragma mark - function - signature API <nl> <nl> class FunctionSignatureSyntax final : public Syntax { <nl> friend struct SyntaxBuilder ; <nl> friend class Syntax ; <nl> friend class SyntaxData ; <nl> - friend class FunctionSignatureSyntaxData ; <nl> <nl> enum class Cursor : CursorIndex { <nl> LeftParen , <nl> class FunctionSignatureSyntax final : public Syntax { <nl> ReturnType , <nl> } ; <nl> <nl> + virtual void validate ( ) const override ; <nl> + <nl> public : <nl> - using DataType = FunctionSignatureSyntaxData ; <nl> + static FunctionSignatureSyntax makeBlank ( ) ; <nl> <nl> - FunctionSignatureSyntax ( const RC < SyntaxData > Root , const DataType * Data ) <nl> + FunctionSignatureSyntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> : Syntax ( Root , Data ) { } <nl> <nl> / / / Return the left parenthesis ' ( ' token enclosing the parameter list . <nl> class FunctionSignatureSyntax final : public Syntax { <nl> } <nl> } ; <nl> <nl> - # pragma mark - function - declaration Data <nl> - <nl> - class FunctionDeclSyntaxData final : public SyntaxData { <nl> - friend struct SyntaxFactory ; <nl> - friend class SyntaxData ; <nl> - friend class FunctionDeclSyntax ; <nl> - <nl> - RC < TypeAttributesSyntaxData > CachedAttributes ; <nl> - RC < DeclModifierListSyntaxData > CachedModifiers ; <nl> - RC < GenericParameterClauseSyntaxData > CachedGenericParams ; <nl> - RC < FunctionSignatureSyntaxData > CachedSignature ; <nl> - RC < GenericWhereClauseSyntaxData > CachedGenericWhereClause ; <nl> - RC < CodeBlockStmtSyntaxData > CachedBody ; <nl> - <nl> - FunctionDeclSyntaxData ( const RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - const CursorIndex IndexInParent = 0 ) ; <nl> - <nl> - static RC < FunctionDeclSyntaxData > make ( const RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - const CursorIndex IndexInParent = 0 ) ; <nl> - static RC < FunctionDeclSyntaxData > makeBlank ( ) ; <nl> - <nl> - public : <nl> - static bool classof ( const SyntaxData * SD ) { <nl> - return SD - > getKind ( ) = = SyntaxKind : : FunctionDecl ; <nl> - } <nl> - } ; <nl> - <nl> # pragma mark - function - declaration API <nl> <nl> - class FunctionDeclSyntax final : public Syntax { <nl> + class FunctionDeclSyntax final : public DeclSyntax { <nl> friend struct SyntaxFactory ; <nl> friend class Syntax ; <nl> friend class SyntaxData ; <nl> - friend class FunctionDeclSyntaxData ; <nl> <nl> enum class Cursor : CursorIndex { <nl> Attributes , <nl> class FunctionDeclSyntax final : public Syntax { <nl> Body <nl> } ; <nl> <nl> - using DataType = FunctionDeclSyntaxData ; <nl> - <nl> - FunctionDeclSyntax ( const RC < SyntaxData > Root , const DataType * Data ) <nl> - : Syntax ( Root , Data ) { } <nl> + virtual void validate ( ) const override ; <nl> <nl> public : <nl> + static FunctionDeclSyntax makeBlank ( ) ; <nl> + FunctionDeclSyntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> + : DeclSyntax ( Root , Data ) { } <nl> + <nl> / / / Get the attributes of this function declaration . <nl> TypeAttributesSyntax getAttributes ( ) const ; <nl> <nl> mmm a / include / swift / Syntax / ExprSyntax . h <nl> ppp b / include / swift / Syntax / ExprSyntax . h <nl> <nl> # include " swift / Syntax / Syntax . h " <nl> # include " swift / Syntax / SyntaxData . h " <nl> # include " swift / Syntax / SyntaxCollection . h " <nl> - # include " swift / Syntax / SyntaxCollectionData . h " <nl> # include " swift / Syntax / TokenSyntax . h " <nl> # include " swift / Syntax / UnknownSyntax . h " <nl> <nl> using llvm : : Optional ; <nl> namespace swift { <nl> namespace syntax { <nl> <nl> - class GenericArgumentClauseSyntax ; <nl> - class GenericArgumentClauseSyntaxData ; <nl> <nl> - class ExprSyntaxData : public SyntaxData { <nl> - protected : <nl> - ExprSyntaxData ( RC < RawSyntax > Raw , const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) <nl> - : SyntaxData ( Raw , Parent , IndexInParent ) { <nl> - assert ( Raw - > isExpr ( ) ) ; <nl> - } <nl> - public : <nl> - static RC < ExprSyntaxData > make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < ExprSyntaxData > makeBlank ( ) ; <nl> - static bool classof ( const SyntaxData * S ) { <nl> - return S - > isExpr ( ) ; <nl> - } <nl> - } ; <nl> + # pragma mark - function - call - argument - list API <nl> + <nl> + class FunctionCallArgumentSyntax ; <nl> + <nl> + class GenericArgumentClauseSyntax ; <nl> <nl> class ExprSyntax : public Syntax { <nl> friend class FunctionParameterSyntax ; <nl> - public : <nl> - using DataType = ExprSyntaxData ; <nl> <nl> - ExprSyntax ( const RC < SyntaxData > Root , const ExprSyntaxData * Data ) ; <nl> - static bool classof ( const Syntax * S ) { <nl> - return S - > isExpr ( ) ; <nl> - } <nl> - } ; <nl> - <nl> - # pragma mark - unknown - expression Data <nl> + protected : <nl> + virtual void validate ( ) const override { } <nl> <nl> - class UnknownExprSyntaxData : public UnknownSyntaxData { <nl> - UnknownExprSyntaxData ( RC < RawSyntax > Raw , const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> public : <nl> - static RC < UnknownExprSyntaxData > make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - <nl> - static bool classof ( const SyntaxData * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : UnknownExpr ; <nl> + static ExprSyntax makeBlank ( ) ; <nl> + ExprSyntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> + : Syntax ( Root , Data ) { } <nl> + static bool classof ( const Syntax * S ) { <nl> + return S - > isExpr ( ) ; <nl> } <nl> } ; <nl> <nl> # pragma mark - unknown - expression API <nl> <nl> class UnknownExprSyntax : public UnknownSyntax { <nl> - friend class SyntaxData ; <nl> - friend class UnknownExprSyntaxData ; <nl> friend class LegacyASTTransformer ; <nl> <nl> - using DataType = UnknownExprSyntaxData ; <nl> - <nl> + virtual void validate ( ) const override ; <nl> public : <nl> - UnknownExprSyntax ( const RC < SyntaxData > Root , <nl> - const UnknownExprSyntaxData * Data ) ; <nl> - <nl> + static UnknownExprSyntax makeBlank ( ) ; <nl> + UnknownExprSyntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> + : UnknownSyntax ( Root , Data ) { } <nl> static bool classof ( const Syntax * S ) { <nl> return S - > getKind ( ) = = SyntaxKind : : UnknownExpr ; <nl> } <nl> } ; <nl> <nl> - # pragma mark - integer - literal - expression Data <nl> - <nl> - class IntegerLiteralExprSyntaxData : public ExprSyntaxData { <nl> - friend struct SyntaxFactory ; <nl> - friend class SyntaxData ; <nl> - <nl> - IntegerLiteralExprSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < IntegerLiteralExprSyntaxData > make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < IntegerLiteralExprSyntaxData > makeBlank ( ) ; <nl> - public : <nl> - static bool classof ( const SyntaxData * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : IntegerLiteralExpr ; <nl> - } <nl> - } ; <nl> - <nl> # pragma mark - integer - literal - expression API <nl> <nl> class IntegerLiteralExprSyntax : public ExprSyntax { <nl> - using DataType = IntegerLiteralExprSyntaxData ; <nl> - friend struct SyntaxFactory ; <nl> - friend class SyntaxData ; <nl> - friend class IntegerLiteralExprSyntaxData ; <nl> - <nl> - IntegerLiteralExprSyntax ( const RC < SyntaxData > Root , <nl> - const IntegerLiteralExprSyntaxData * Data ) ; <nl> + friend struct SyntaxFactory ; <nl> + <nl> + virtual void validate ( ) const override ; <nl> <nl> enum class Cursor : CursorIndex { <nl> Sign , <nl> class IntegerLiteralExprSyntax : public ExprSyntax { <nl> <nl> public : <nl> <nl> + static IntegerLiteralExprSyntax makeBlank ( ) ; <nl> + IntegerLiteralExprSyntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> + : ExprSyntax ( Root , Data ) { } <nl> + <nl> / / / Get the ' + ' or ' - ' associated with this integer literal expression . <nl> RC < TokenSyntax > getSign ( ) const ; <nl> <nl> class IntegerLiteralExprSyntax : public ExprSyntax { <nl> static bool classof ( const Syntax * S ) { <nl> return S - > getKind ( ) = = SyntaxKind : : IntegerLiteralExpr ; <nl> } <nl> - } ; <nl> - <nl> - # pragma mark - symbolic - reference Data <nl> - <nl> - class SymbolicReferenceExprSyntaxData : public ExprSyntaxData { <nl> - friend class SymbolicReferenceExprSyntax ; <nl> - friend class SyntaxData ; <nl> - friend struct SyntaxFactory ; <nl> - <nl> - RC < GenericArgumentClauseSyntaxData > CachedGenericArgClause ; <nl> - <nl> - SymbolicReferenceExprSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> <nl> - static RC < SymbolicReferenceExprSyntaxData > <nl> - make ( RC < RawSyntax > Raw , const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - <nl> - static RC < SymbolicReferenceExprSyntaxData > makeBlank ( ) ; <nl> - <nl> - public : <nl> - static bool classof ( const SyntaxData * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : SymbolicReferenceExpr ; <nl> - } <nl> + virtual ~ IntegerLiteralExprSyntax ( ) { } <nl> } ; <nl> <nl> # pragma mark - symbolic - reference API <nl> class SymbolicReferenceExprSyntaxData : public ExprSyntaxData { <nl> / / / in the grammar . It can be just an identifier referring to some <nl> / / / declaration , or it could perhaps be a constructor call to ` Array < Int > ` . <nl> class SymbolicReferenceExprSyntax : public ExprSyntax { <nl> - <nl> - using DataType = SymbolicReferenceExprSyntaxData ; <nl> - <nl> friend struct SyntaxFactory ; <nl> - friend class SyntaxData ; <nl> friend class Syntax ; <nl> - friend class SymbolicReferenceExprSyntaxData ; <nl> <nl> enum class Cursor : CursorIndex { <nl> Identifier , <nl> GenericArgumentClause <nl> } ; <nl> <nl> - SymbolicReferenceExprSyntax ( const RC < SyntaxData > Root , <nl> - const DataType * Data ) ; <nl> + virtual void validate ( ) const override ; <nl> <nl> public : <nl> + static SymbolicReferenceExprSyntax makeBlank ( ) ; <nl> + SymbolicReferenceExprSyntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> + : ExprSyntax ( Root , Data ) { } <nl> + <nl> <nl> / / / Get the identifier for the symbol to which this expression refers . <nl> RC < TokenSyntax > getIdentifier ( ) const ; <nl> class SymbolicReferenceExprSyntax : public ExprSyntax { <nl> } <nl> } ; <nl> <nl> - # pragma mark - function - call - argument Data <nl> - <nl> - class FunctionCallArgumentSyntaxData : public SyntaxData { <nl> - friend struct SyntaxFactory ; <nl> - friend class FunctionCallArgumentSyntax ; <nl> - friend class SyntaxData ; <nl> - <nl> - RC < ExprSyntaxData > CachedExpression ; <nl> - <nl> - FunctionCallArgumentSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - <nl> - static RC < FunctionCallArgumentSyntaxData > <nl> - make ( RC < RawSyntax > Raw , const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - <nl> - static RC < FunctionCallArgumentSyntaxData > makeBlank ( ) ; <nl> - <nl> - public : <nl> - static bool classof ( const SyntaxData * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : FunctionCallArgument ; <nl> - } <nl> - } ; <nl> - <nl> # pragma mark - function - call - argument API <nl> <nl> / / / function - call - argument - > label ? ' : ' ? ( expression | operator ) ' , ' ? <nl> class FunctionCallArgumentSyntax : public Syntax { <nl> - using DataType = FunctionCallArgumentSyntaxData ; <nl> <nl> friend struct SyntaxFactory ; <nl> - friend class SyntaxData ; <nl> friend class Syntax ; <nl> - friend class FunctionCallArgumentSyntaxData ; <nl> - friend class FunctionCallArgumentListSyntax ; <nl> - friend class SyntaxCollectionData < SyntaxKind : : FunctionCallArgumentList , <nl> - FunctionCallArgumentSyntax > ; <nl> friend class SyntaxCollection < SyntaxKind : : FunctionCallArgumentList , <nl> FunctionCallArgumentSyntax > ; <nl> <nl> class FunctionCallArgumentSyntax : public Syntax { <nl> Comma , <nl> } ; <nl> <nl> - FunctionCallArgumentSyntax ( const RC < SyntaxData > Root , <nl> - const DataType * Data ) ; <nl> + virtual void validate ( ) const override ; <nl> <nl> public : <nl> <nl> + static FunctionCallArgumentSyntax makeBlank ( ) ; <nl> + FunctionCallArgumentSyntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> + : Syntax ( Root , Data ) { } <nl> + <nl> / / / Return the label identifier for this argument , if it has one . <nl> RC < TokenSyntax > getLabel ( ) const ; <nl> <nl> class FunctionCallArgumentSyntax : public Syntax { <nl> } <nl> } ; <nl> <nl> - # pragma mark - function - call - argument - list Data <nl> - <nl> - using FunctionCallArgumentListSyntaxData = <nl> - SyntaxCollectionData < SyntaxKind : : FunctionCallArgumentList , <nl> - FunctionCallArgumentSyntax > ; <nl> - <nl> - # pragma mark - function - call - argument - list API <nl> - <nl> - / / / function - call - argument - list - > function - call - argument <nl> - / / / function - call - argument - list ? <nl> - class FunctionCallArgumentListSyntax <nl> - : public SyntaxCollection < SyntaxKind : : FunctionCallArgumentList , <nl> - FunctionCallArgumentSyntax > { <nl> - friend struct SyntaxFactory ; <nl> - friend class FunctionCallExprSyntax ; <nl> - friend class Syntax ; <nl> - friend class SyntaxData ; <nl> - <nl> - using DataType = FunctionCallArgumentListSyntaxData ; <nl> - <nl> - FunctionCallArgumentListSyntax ( const RC < SyntaxData > Root , <nl> - const DataType * Data ) ; <nl> - <nl> - public : <nl> - static bool classof ( const Syntax * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : FunctionCallArgumentList ; <nl> - } <nl> - } ; <nl> - <nl> - # pragma mark - function - call - expression Data <nl> - <nl> - class FunctionCallExprSyntaxData : public ExprSyntaxData { <nl> - friend struct SyntaxFactory ; <nl> - friend class FunctionCallExprSyntax ; <nl> - friend class FunctionCallExprSyntaxBuilder ; <nl> - friend class SyntaxData ; <nl> - <nl> - RC < ExprSyntaxData > CachedCalledExpression ; <nl> - RC < FunctionCallArgumentListSyntaxData > CachedArgumentList ; <nl> - <nl> - FunctionCallExprSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - <nl> - static RC < FunctionCallExprSyntaxData > <nl> - make ( RC < RawSyntax > Raw , const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - <nl> - static RC < FunctionCallExprSyntaxData > makeBlank ( ) ; <nl> - <nl> - public : <nl> - static bool classof ( const SyntaxData * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : FunctionCallExpr ; <nl> - } <nl> - } ; <nl> - <nl> # pragma mark - function - call - expression API <nl> <nl> class FunctionCallExprSyntax : public ExprSyntax { <nl> - using DataType = FunctionCallExprSyntaxData ; <nl> friend struct SyntaxFactory ; <nl> - friend class FunctionCallExprSyntaxData ; <nl> friend class FunctionCallExprSyntaxBuilder ; <nl> friend class Syntax ; <nl> - friend class SyntaxData ; <nl> - <nl> + <nl> enum class Cursor : CursorIndex { <nl> CalledExpression , <nl> LeftParen , <nl> class FunctionCallExprSyntax : public ExprSyntax { <nl> RightParen , <nl> } ; <nl> <nl> - FunctionCallExprSyntax ( const RC < SyntaxData > Root , const DataType * Data ) ; <nl> + virtual void validate ( ) const override ; <nl> <nl> public : <nl> + static FunctionCallExprSyntax makeBlank ( ) ; <nl> + FunctionCallExprSyntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> + : ExprSyntax ( Root , Data ) { } <nl> <nl> / / / Get the base expression getting called . <nl> ExprSyntax getCalledExpression ( ) const ; <nl> mmm a / include / swift / Syntax / GenericSyntax . h <nl> ppp b / include / swift / Syntax / GenericSyntax . h <nl> namespace swift { <nl> namespace syntax { <nl> <nl> class TypeSyntax ; <nl> - class TypeSyntaxData ; <nl> class TypeIdentifierSyntax ; <nl> - class TypeIdentifierSyntaxData ; <nl> - <nl> - # pragma mark - generic - requirement Data <nl> - <nl> - class GenericRequirementSyntaxData : public SyntaxData { <nl> - friend class GenericRequirementSyntax ; <nl> - friend class SyntaxData ; <nl> - <nl> - protected : <nl> - GenericRequirementSyntaxData ( const RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - const CursorIndex IndexInParent = 0 ) <nl> - : SyntaxData ( Raw , Parent , IndexInParent ) { } <nl> - <nl> - public : <nl> - static bool classof ( const SyntaxData * SD ) { <nl> - return SD - > getKind ( ) = = SyntaxKind : : ConformanceRequirement | | <nl> - SD - > getKind ( ) = = SyntaxKind : : SameTypeRequirement ; <nl> - } <nl> - } ; <nl> <nl> # pragma mark - generic - requirement API <nl> <nl> class GenericRequirementSyntax : public Syntax { <nl> friend class Syntax ; <nl> - friend class SyntaxData ; <nl> - friend class GenericRequirementSyntaxData ; <nl> - <nl> + <nl> + protected : <nl> + virtual void validate ( ) const override { } <nl> public : <nl> - using DataType = GenericRequirementSyntaxData ; <nl> - <nl> - GenericRequirementSyntax ( const RC < SyntaxData > Root , const DataType * Data ) <nl> + static GenericRequirementSyntax makeBlank ( ) ; <nl> + GenericRequirementSyntax ( const RC < SyntaxData > Root , <nl> + const SyntaxData * Data ) <nl> : Syntax ( Root , Data ) { } <nl> - <nl> static bool classof ( const Syntax * S ) { <nl> return S - > getKind ( ) = = SyntaxKind : : ConformanceRequirement | | <nl> - S - > getKind ( ) = = SyntaxKind : : SameTypeRequirement ; <nl> - } <nl> - } ; <nl> - <nl> - # pragma mark - conformance - requirement Data <nl> - <nl> - class ConformanceRequirementSyntaxData final <nl> - : public GenericRequirementSyntaxData { <nl> - friend class SyntaxData ; <nl> - <nl> - RC < TypeIdentifierSyntaxData > CachedConformingTypeIdentifier ; <nl> - RC < TypeSyntaxData > InheritedType ; <nl> - <nl> - ConformanceRequirementSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < ConformanceRequirementSyntaxData > <nl> - make ( RC < RawSyntax > Raw , const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < ConformanceRequirementSyntaxData > makeBlank ( ) ; <nl> - <nl> - public : <nl> - static bool classof ( const SyntaxData * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : ConformanceRequirement ; <nl> - } <nl> - static bool classof ( const GenericRequirementSyntaxData * SD ) { <nl> - return SD - > getKind ( ) = = SyntaxKind : : ConformanceRequirement ; <nl> + S - > getKind ( ) = = SyntaxKind : : SameTypeRequirement ; <nl> } <nl> } ; <nl> <nl> class ConformanceRequirementSyntaxData final <nl> / / / conformance - requirement - > type - identifier : type - identifier <nl> class ConformanceRequirementSyntax final : public GenericRequirementSyntax { <nl> <nl> - friend class ConformanceRequirementSyntaxData ; <nl> - friend class SyntaxData ; <nl> friend class Syntax ; <nl> <nl> enum Cursor : CursorIndex { <nl> class ConformanceRequirementSyntax final : public GenericRequirementSyntax { <nl> RightTypeIdentifier , <nl> } ; <nl> <nl> - ConformanceRequirementSyntax ( RC < SyntaxData > Root , <nl> - ConformanceRequirementSyntaxData * Data ) ; <nl> - <nl> - static ConformanceRequirementSyntax make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - <nl> - static ConformanceRequirementSyntax makeBlank ( ) ; <nl> - <nl> + protected : <nl> + virtual void validate ( ) const override ; <nl> public : <nl> - using DataType = ConformanceRequirementSyntaxData ; <nl> + static ConformanceRequirementSyntax makeBlank ( ) ; <nl> + ConformanceRequirementSyntax ( const RC < SyntaxData > Root , <nl> + const SyntaxData * Data ) <nl> + : GenericRequirementSyntax ( Root , Data ) { } <nl> <nl> - / / / Return the conforming " left - hand " type identifier in the <nl> + / / / Return the conforming " left - hand " type identifier in the <nl> / / / conformance requirement . <nl> TypeIdentifierSyntax getConformingTypeIdentifier ( ) const ; <nl> <nl> class ConformanceRequirementSyntax final : public GenericRequirementSyntax { <nl> } <nl> } ; <nl> <nl> - # pragma mark - same - type - requirement Data <nl> - <nl> - class SameTypeRequirementSyntaxData final <nl> - : public GenericRequirementSyntaxData { <nl> - friend struct SyntaxFactory ; <nl> - friend class SyntaxData ; <nl> - <nl> - RC < TypeIdentifierSyntaxData > CachedLeftTypeIdentifier ; <nl> - RC < TypeSyntaxData > CachedRightType ; <nl> - <nl> - SameTypeRequirementSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < SameTypeRequirementSyntaxData > <nl> - make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < SameTypeRequirementSyntaxData > makeBlank ( ) ; <nl> - <nl> - public : <nl> - static bool classof ( const SyntaxData * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : SameTypeRequirement ; <nl> - } <nl> - } ; <nl> - <nl> # pragma mark - same - type - requirement API <nl> <nl> / / / same - type - requirement - > type - identifier = = type <nl> class SameTypeRequirementSyntax final : public Syntax { <nl> friend struct SyntaxFactory ; <nl> friend class Syntax ; <nl> - friend class SyntaxData ; <nl> - friend class SameTypeRequirementSyntaxData ; <nl> enum Cursor : CursorIndex { <nl> LeftTypeIdentifier , <nl> EqualityToken , <nl> RightType , <nl> } ; <nl> <nl> - SameTypeRequirementSyntax ( RC < SyntaxData > Root , <nl> - const SameTypeRequirementSyntaxData * Data ) ; <nl> + virtual void validate ( ) const override ; <nl> <nl> public : <nl> - using DataType = SameTypeRequirementSyntaxData ; <nl> + static SameTypeRequirementSyntax makeBlank ( ) ; <nl> + SameTypeRequirementSyntax ( const RC < SyntaxData > Root , <nl> + const SyntaxData * Data ) <nl> + : Syntax ( Root , Data ) { } <nl> <nl> - / / / Return the type identifier on the left side of the same - type requirement . <nl> + / / / Return the type identifier on the left side of the same - type requirement . <nl> TypeIdentifierSyntax getLeftTypeIdentifier ( ) const ; <nl> <nl> / / / Return a SameTypeRequirementSyntax with the given type identifier on <nl> class SameTypeRequirementSyntax final : public Syntax { <nl> } <nl> } ; <nl> <nl> - # pragma mark generic - parameter Data <nl> - <nl> - class GenericParameterSyntaxData final : public SyntaxData { <nl> - friend class SyntaxData ; <nl> - friend struct SyntaxFactory ; <nl> - RC < TypeSyntaxData > CachedInheritedType ; <nl> - <nl> - GenericParameterSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - <nl> - static RC < GenericParameterSyntaxData > <nl> - make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < GenericParameterSyntaxData > makeBlank ( ) ; <nl> - <nl> - static bool classof ( const SyntaxData * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : GenericParameterClause ; <nl> - } <nl> - } ; <nl> - <nl> # pragma mark - generic - parameter API <nl> <nl> / / / generic - parameter - > type - name <nl> class GenericParameterSyntax final : public Syntax { <nl> InheritedType , <nl> } ; <nl> <nl> - GenericParameterSyntax ( RC < SyntaxData > Root , <nl> - const GenericParameterSyntaxData * Data ) ; <nl> + protected : <nl> + virtual void validate ( ) const override ; <nl> <nl> public : <nl> + static GenericParameterSyntax makeBlank ( ) ; <nl> + GenericParameterSyntax ( const RC < SyntaxData > Root , <nl> + const SyntaxData * Data ) <nl> + : Syntax ( Root , Data ) { } <nl> <nl> / / / Return the name of the generic parameter . <nl> RC < TokenSyntax > getIdentifier ( ) const ; <nl> class GenericParameterSyntax final : public Syntax { <nl> } <nl> } ; <nl> <nl> - <nl> - # pragma mark - generic - parameter - list Data <nl> - <nl> - class GenericParameterListSyntaxData final : public SyntaxData { <nl> - friend class SyntaxData ; <nl> - <nl> - GenericParameterListSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < GenericParameterListSyntaxData > <nl> - make ( RC < RawSyntax > Raw , const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < GenericParameterListSyntaxData > makeBlank ( ) ; <nl> - <nl> - public : <nl> - static bool classof ( const SyntaxData * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : GenericParameterList ; <nl> - } <nl> - } ; <nl> - <nl> - # pragma mark - generic - parameter - list API <nl> - <nl> - / / / generic - parameter - list - > generic - parameter <nl> - / / / | generic - parameter ' , ' generic - parameter - list <nl> - class GenericParameterListSyntax final : public Syntax { <nl> - friend struct SyntaxFactory ; <nl> - } ; <nl> - <nl> - # pragma mark generic - parameter - clause Data <nl> - <nl> - class GenericParameterClauseSyntaxData final : public SyntaxData { <nl> - friend class SyntaxData ; <nl> - friend struct SyntaxFactory ; <nl> - friend class GenericParameterClauseBuilder ; <nl> - <nl> - RC < GenericParameterListSyntaxData > CachedGenericParameterList ; <nl> - <nl> - GenericParameterClauseSyntaxData ( const RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - const CursorIndex IndexInParent = 0 ) ; <nl> - static RC < GenericParameterClauseSyntaxData > <nl> - make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < GenericParameterClauseSyntaxData > makeBlank ( ) ; <nl> - <nl> - public : <nl> - static bool classof ( const SyntaxData * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : GenericParameterClause ; <nl> - } <nl> - } ; <nl> - <nl> # pragma mark - generic - parameter - clause API <nl> <nl> / / / generic - parameter - clause - > ' < ' generic - argument - list ' > ' <nl> class GenericParameterClauseSyntax final : public Syntax { <nl> friend struct SyntaxFactory ; <nl> - friend class GenericParameterClauseSyntaxData ; <nl> friend class GenericParameterClauseBuilder ; <nl> friend class FunctionDeclSyntax ; <nl> <nl> class GenericParameterClauseSyntax final : public Syntax { <nl> RightAngleBracketToken , <nl> } ; <nl> <nl> - GenericParameterClauseSyntax ( RC < SyntaxData > Root , <nl> - const GenericParameterClauseSyntaxData * Data ) ; <nl> + protected : <nl> + virtual void validate ( ) const override ; <nl> <nl> public : <nl> + static GenericParameterClauseSyntax makeBlank ( ) ; <nl> + GenericParameterClauseSyntax ( const RC < SyntaxData > Root , <nl> + const SyntaxData * Data ) <nl> + : Syntax ( Root , Data ) { } <nl> / / / Return the left angle bracket ' < ' token on the generic parameter clause . <nl> RC < TokenSyntax > getLeftAngleBracket ( ) const ; <nl> <nl> class GenericParameterClauseBuilder { <nl> GenericParameterClauseSyntax build ( ) const ; <nl> } ; <nl> <nl> - # pragma mark - generic - argument - list Data <nl> - <nl> - class GenericArgumentListSyntaxData final : public SyntaxData { <nl> - friend class SyntaxData ; <nl> - GenericArgumentListSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < GenericArgumentListSyntaxData > <nl> - make ( RC < RawSyntax > Raw , const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < GenericArgumentListSyntaxData > makeBlank ( ) ; <nl> - public : <nl> - static bool classof ( const SyntaxData * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : GenericArgumentList ; <nl> - } <nl> - } ; <nl> - <nl> - # pragma mark - generic - argument - list API <nl> - <nl> - / / / generic - argument - list - > generic - argument <nl> - / / / | generic - argument ' , ' generic - argument - list <nl> - class GenericArgumentListSyntax final : public Syntax { <nl> - friend struct SyntaxFactory ; <nl> - <nl> - GenericArgumentListSyntax ( RC < SyntaxData > Root , <nl> - GenericArgumentListSyntaxData * Data ) ; <nl> - <nl> - static GenericArgumentListSyntax make ( RC < RawSyntax > Raw ) ; <nl> - <nl> - static GenericArgumentListSyntax makeBlank ( ) ; <nl> - <nl> - public : <nl> - / / / Get the n - th generic argument from this list . <nl> - TypeSyntax getArgument ( unsigned n ) const ; <nl> - <nl> - / / / Return a GenericArgumentListSyntax with the given generic argument added . <nl> - GenericArgumentListSyntax <nl> - addGenericArgument ( llvm : : Optional < RC < TokenSyntax > > Comma , <nl> - TypeSyntax NewArgument ) const ; <nl> - <nl> - static bool classof ( const Syntax * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : GenericArgumentList ; <nl> - } <nl> - } ; <nl> - <nl> - # pragma mark - generic - argument - clause Data <nl> - <nl> - class GenericArgumentClauseSyntaxData final : public SyntaxData { <nl> - friend class SyntaxData ; <nl> - friend struct SyntaxFactory ; <nl> - friend class GenericArgumentClauseBuilder ; <nl> - RC < GenericArgumentListSyntaxData > CachedGenericArgumentList ; <nl> - <nl> - GenericArgumentClauseSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < GenericArgumentClauseSyntaxData > <nl> - make ( RC < RawSyntax > Raw , const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < GenericArgumentClauseSyntaxData > makeBlank ( ) ; <nl> - <nl> - public : <nl> - static bool classof ( const SyntaxData * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : GenericArgumentClause ; <nl> - } <nl> - } ; <nl> - <nl> # pragma mark - generic - argument - clause API <nl> <nl> / / / generic - argument - clause - > ' < ' generic - argument - list ' > ' <nl> class GenericArgumentClauseSyntax : public Syntax { <nl> friend struct SyntaxFactory ; <nl> friend class GenericArgumentClauseBuilder ; <nl> friend class SymbolicReferenceExprSyntax ; <nl> - friend class SyntaxData ; <nl> friend class Syntax ; <nl> <nl> - using DataType = GenericArgumentClauseSyntaxData ; <nl> - <nl> - enum class Cursor : CursorIndex { <nl> + enum class Cursor : CursorIndex { <nl> LeftAngleBracketToken , <nl> GenericArgumentList , <nl> RightAngleBracketToken , <nl> } ; <nl> <nl> - GenericArgumentClauseSyntax ( RC < SyntaxData > Root , <nl> - const GenericArgumentClauseSyntaxData * Data ) ; <nl> + protected : <nl> + virtual void validate ( ) const override { } <nl> <nl> public : <nl> + static GenericArgumentClauseSyntax makeBlank ( ) ; <nl> + GenericArgumentClauseSyntax ( const RC < SyntaxData > Root , <nl> + const SyntaxData * Data ) <nl> + : Syntax ( Root , Data ) { } <nl> + <nl> / / / Return the left angle bracket ' < ' token on the generic argument clause . <nl> RC < TokenSyntax > getLeftAngleBracket ( ) const ; <nl> <nl> class GenericArgumentClauseSyntax : public Syntax { <nl> } <nl> } ; <nl> <nl> - # pragma mark - generic - requirement - list Data <nl> - <nl> - using GenericRequirementListSyntaxData = <nl> - SyntaxCollectionData < SyntaxKind : : GenericRequirementList , <nl> - GenericRequirementSyntax > ; <nl> - <nl> - # pragma mark - generic - requirement - list API <nl> - <nl> - / / / requirement - list - > requirement | requirement ' , ' requirement - list <nl> - / / / <nl> - / / / requirement - > conformance - requirement | same - type - requirement <nl> - class GenericRequirementListSyntax final <nl> - : public SyntaxCollection < SyntaxKind : : GenericRequirementList , <nl> - GenericRequirementSyntax > { <nl> - friend struct SyntaxFactory ; <nl> - friend class Syntax ; <nl> - friend class SyntaxData ; <nl> - <nl> - using DataType = GenericRequirementListSyntaxData ; <nl> - <nl> - GenericRequirementListSyntax ( const RC < SyntaxData > Root , <nl> - const DataType * Data ) <nl> - : SyntaxCollection ( Root , Data ) { } <nl> - public : <nl> - static bool classof ( const Syntax * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : GenericRequirementList ; <nl> - } <nl> - } ; <nl> - <nl> # pragma mark - generic - argument - clause Builder <nl> <nl> class GenericArgumentClauseBuilder { <nl> class GenericArgumentClauseBuilder { <nl> GenericArgumentClauseSyntax build ( ) const ; <nl> } ; <nl> <nl> - # pragma mark - generic - where - clause Data <nl> - <nl> - class GenericWhereClauseSyntaxData final : public SyntaxData { <nl> - friend class SyntaxData ; <nl> - friend struct SyntaxFactory ; <nl> - <nl> - RC < GenericRequirementListSyntaxData > CachedRequirementList ; <nl> - <nl> - GenericWhereClauseSyntaxData ( const RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - const CursorIndex IndexInParent = 0 ) ; <nl> - static RC < GenericWhereClauseSyntaxData > <nl> - make ( const RC < RawSyntax > Raw , const SyntaxData * Parent = nullptr , <nl> - const CursorIndex IndexInParent = 0 ) ; <nl> - static RC < GenericWhereClauseSyntaxData > makeBlank ( ) ; <nl> - <nl> - public : <nl> - static bool classof ( const SyntaxData * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : GenericWhereClause ; <nl> - } <nl> - } ; <nl> - <nl> # pragma mark - generic - where - clause API <nl> <nl> / / / generic - where - clause - > ' where ' requirement - list <nl> class GenericWhereClauseSyntax final : public Syntax { <nl> friend struct SyntaxFactory ; <nl> friend class Syntax ; <nl> - friend class SyntaxData ; <nl> - friend class GenericWhereClauseSyntaxData ; <nl> enum class Cursor : CursorIndex { <nl> WhereKeyword , <nl> RequirementList , <nl> } ; <nl> <nl> - using DataType = GenericWhereClauseSyntaxData ; <nl> - <nl> - GenericWhereClauseSyntax ( RC < SyntaxData > Root , <nl> - const GenericWhereClauseSyntaxData * Data ) ; <nl> + protected : <nl> + virtual void validate ( ) const override ; <nl> <nl> public : <nl> + static GenericWhereClauseSyntax makeBlank ( ) ; <nl> + GenericWhereClauseSyntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> + : Syntax ( Root , Data ) { } <nl> + <nl> / / / Return the ' where ' keyword in the generic where clause . <nl> RC < TokenSyntax > getWhereKeyword ( ) const ; <nl> <nl> mmm a / include / swift / Syntax / StmtSyntax . h <nl> ppp b / include / swift / Syntax / StmtSyntax . h <nl> namespace swift { <nl> namespace syntax { <nl> <nl> class ExprSyntax ; <nl> - class ExprSyntaxData ; <nl> - <nl> - # pragma mark - statement Data <nl> - <nl> - class StmtSyntaxData : public SyntaxData { <nl> - protected : <nl> - StmtSyntaxData ( RC < RawSyntax > Raw , const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) <nl> - : SyntaxData ( Raw , Parent , IndexInParent ) { } <nl> - public : <nl> - static bool classof ( const SyntaxData * S ) { <nl> - return S - > isStmt ( ) ; <nl> - } <nl> - } ; <nl> <nl> # pragma mark - statement API <nl> <nl> class StmtSyntaxData : public SyntaxData { <nl> class StmtSyntax : public Syntax { <nl> friend class Syntax ; <nl> protected : <nl> - StmtSyntax ( const RC < SyntaxData > Root , const StmtSyntaxData * Data ) ; <nl> + virtual void validate ( ) const override { } <nl> public : <nl> - using DataType = StmtSyntaxData ; <nl> - static bool classof ( const Syntax * S ) { <nl> + static StmtSyntax makeBlank ( ) ; <nl> + StmtSyntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> + : Syntax ( Root , Data ) { } <nl> + static bool classof ( const Syntax * S ) { <nl> return S - > isStmt ( ) ; <nl> } <nl> } ; <nl> <nl> - # pragma mark - unknown - statement Data <nl> - <nl> - class UnknownStmtSyntaxData : public UnknownSyntaxData { <nl> - UnknownStmtSyntaxData ( RC < RawSyntax > Raw , const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - public : <nl> - static RC < UnknownStmtSyntaxData > make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - <nl> - static bool classof ( const SyntaxData * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : UnknownStmt ; <nl> - } <nl> - } ; <nl> - <nl> # pragma mark - unknown - statement API <nl> <nl> class UnknownStmtSyntax : public UnknownSyntax { <nl> - friend class SyntaxData ; <nl> - friend class UnknownStmtSyntaxData ; <nl> friend class LegacyASTTransformer ; <nl> <nl> - using DataType = UnknownStmtSyntaxData ; <nl> - <nl> - UnknownStmtSyntax ( const RC < SyntaxData > Root , <nl> - const UnknownStmtSyntaxData * Data ) ; <nl> - <nl> + virtual void validate ( ) const override ; <nl> public : <nl> + static UnknownStmtSyntax makeBlank ( ) ; <nl> + UnknownStmtSyntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> + : UnknownSyntax ( Root , Data ) { } <nl> static bool classof ( const Syntax * S ) { <nl> return S - > getKind ( ) = = SyntaxKind : : UnknownStmt ; <nl> } <nl> } ; <nl> <nl> - # pragma mark - <nl> - # pragma mark code - block Data <nl> - <nl> - class CodeBlockStmtSyntaxData final : public StmtSyntaxData { <nl> - friend class SyntaxData ; <nl> - friend class CodeBlockStmtSyntax ; <nl> - friend struct SyntaxFactory ; <nl> - <nl> - CodeBlockStmtSyntaxData ( RC < RawSyntax > Raw , const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < CodeBlockStmtSyntaxData > make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < CodeBlockStmtSyntaxData > makeBlank ( ) ; <nl> - public : <nl> - static bool classof ( const SyntaxData * SD ) { <nl> - return SD - > getKind ( ) = = SyntaxKind : : CodeBlockStmt ; <nl> - } <nl> - } ; <nl> - <nl> # pragma mark - <nl> # pragma mark code - block API <nl> <nl> class CodeBlockStmtSyntax : public StmtSyntax { <nl> RightBrace , <nl> } ; <nl> friend struct SyntaxFactory ; <nl> - friend class CodeBlockStmtSyntaxData ; <nl> friend class FunctionDeclSyntax ; <nl> <nl> - CodeBlockStmtSyntax ( const RC < SyntaxData > Root , CodeBlockStmtSyntaxData * Data ) ; <nl> - <nl> public : <nl> + <nl> + virtual void validate ( ) const override ; <nl> + static CodeBlockStmtSyntax makeBlank ( ) ; <nl> + CodeBlockStmtSyntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> + : StmtSyntax ( Root , Data ) { } <nl> + <nl> / / / Returns the left brace of the code block . <nl> RC < TokenSyntax > getLeftBraceToken ( ) const ; <nl> <nl> class CodeBlockStmtSyntax : public StmtSyntax { <nl> } <nl> } ; <nl> <nl> - # pragma mark - <nl> - # pragma mark statements Data <nl> - <nl> - using StmtListSyntaxData = <nl> - SyntaxCollectionData < SyntaxKind : : StmtList , StmtSyntax > ; <nl> - <nl> - # pragma mark - <nl> - # pragma mark statements API <nl> - <nl> - / / / statements - > statement <nl> - / / / | statement statements <nl> - class StmtListSyntax final <nl> - : public SyntaxCollection < SyntaxKind : : StmtList , StmtSyntax > { <nl> - friend struct SyntaxFactory ; <nl> - friend class Syntax ; <nl> - friend class SyntaxData ; <nl> - friend class FunctionDeclSyntax ; <nl> - <nl> - using DataType = StmtListSyntaxData ; <nl> - <nl> - StmtListSyntax ( const RC < SyntaxData > Root , const DataType * Data ) <nl> - : SyntaxCollection ( Root , Data ) { } <nl> - <nl> - public : <nl> - static bool classof ( const Syntax * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : StmtList ; <nl> - } <nl> - } ; <nl> - <nl> - # pragma mark - <nl> - # pragma mark fallthrough - statement Data <nl> - <nl> - class FallthroughStmtSyntaxData final : public StmtSyntaxData { <nl> - friend class SyntaxData ; <nl> - friend class FallthroughStmtSyntax ; <nl> - friend struct SyntaxFactory ; <nl> - <nl> - FallthroughStmtSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < FallthroughStmtSyntaxData > make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < FallthroughStmtSyntaxData > makeBlank ( ) ; <nl> - <nl> - public : <nl> - static bool classof ( const SyntaxData * SD ) { <nl> - return SD - > getKind ( ) = = SyntaxKind : : FallthroughStmt ; <nl> - } <nl> - } ; <nl> - <nl> # pragma mark - <nl> # pragma mark fallthrough - statement API <nl> <nl> / / / fallthrough - statement - > ' fallthrough ' <nl> class FallthroughStmtSyntax : public StmtSyntax { <nl> friend struct SyntaxFactory ; <nl> - friend class SyntaxData ; <nl> - friend class FallthroughStmtSyntaxData ; <nl> - <nl> - using DataType = FallthroughStmtSyntaxData ; <nl> - <nl> + <nl> enum class Cursor : CursorIndex { <nl> FallthroughKeyword , <nl> } ; <nl> <nl> - FallthroughStmtSyntax ( const RC < SyntaxData > Root , <nl> - const FallthroughStmtSyntaxData * Data ) ; <nl> - <nl> - static FallthroughStmtSyntax make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static FallthroughStmtSyntax makeBlank ( ) ; <nl> + virtual void validate ( ) const override ; <nl> <nl> public : <nl> + static FallthroughStmtSyntax makeBlank ( ) ; <nl> + FallthroughStmtSyntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> + : StmtSyntax ( Root , Data ) { } <nl> <nl> / / / Get the ' fallthrough ' keyword associated comprising this <nl> / / / fallthrough statement . <nl> class FallthroughStmtSyntax : public StmtSyntax { <nl> } <nl> } ; <nl> <nl> - # pragma mark - break - statement Data <nl> - <nl> - class BreakStmtSyntaxData : public StmtSyntaxData { <nl> - friend class SyntaxData ; <nl> - friend class BreakStmtSyntax ; <nl> - friend struct SyntaxFactory ; <nl> - BreakStmtSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < BreakStmtSyntaxData > make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < BreakStmtSyntaxData > makeBlank ( ) ; <nl> - <nl> - public : <nl> - static bool classof ( const SyntaxData * SD ) { <nl> - return SD - > getKind ( ) = = SyntaxKind : : BreakStmt ; <nl> - } <nl> - <nl> - } ; <nl> - <nl> # pragma mark - break - statement API <nl> <nl> / / / break - statement - > ' break ' label - name ? <nl> / / / label - name - > identifier <nl> class BreakStmtSyntax : public StmtSyntax { <nl> friend struct SyntaxFactory ; <nl> - friend class BreakStmtSyntaxData ; <nl> - friend class SyntaxData ; <nl> - <nl> - using DataType = BreakStmtSyntaxData ; <nl> <nl> enum class Cursor : CursorIndex { <nl> BreakKeyword , <nl> Label <nl> } ; <nl> <nl> - BreakStmtSyntax ( const RC < SyntaxData > Root , <nl> - BreakStmtSyntaxData * Data ) ; <nl> + virtual void validate ( ) const override ; <nl> <nl> - static BreakStmtSyntax make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static BreakStmtSyntax makeBlank ( ) ; <nl> public : <nl> + static BreakStmtSyntax makeBlank ( ) ; <nl> + BreakStmtSyntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> + : StmtSyntax ( Root , Data ) { } <nl> <nl> / / / Return the ' break ' keyword associated with this break statement . <nl> RC < TokenSyntax > getBreakKeyword ( ) const ; <nl> class BreakStmtSyntax : public StmtSyntax { <nl> } <nl> } ; <nl> <nl> - # pragma mark - continue - statement Data <nl> - <nl> - class ContinueStmtSyntaxData : public StmtSyntaxData { <nl> - friend class SyntaxData ; <nl> - friend class ContinueStmtSyntax ; <nl> - friend struct SyntaxFactory ; <nl> - ContinueStmtSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < ContinueStmtSyntaxData > make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < ContinueStmtSyntaxData > makeBlank ( ) ; <nl> - <nl> - public : <nl> - static bool classof ( const SyntaxData * SD ) { <nl> - return SD - > getKind ( ) = = SyntaxKind : : ContinueStmt ; <nl> - } <nl> - <nl> - } ; <nl> - <nl> # pragma mark - continue - statement API <nl> <nl> / / / continue - statement - > ' continue ' label - name ? <nl> / / / label - name - > identifier <nl> class ContinueStmtSyntax : public StmtSyntax { <nl> friend struct SyntaxFactory ; <nl> - friend class ContinueStmtSyntaxData ; <nl> - friend class SyntaxData ; <nl> - <nl> - using DataType = ContinueStmtSyntaxData ; <nl> <nl> enum class Cursor : CursorIndex { <nl> ContinueKeyword , <nl> Label <nl> } ; <nl> <nl> - ContinueStmtSyntax ( const RC < SyntaxData > Root , <nl> - ContinueStmtSyntaxData * Data ) ; <nl> + virtual void validate ( ) const override ; <nl> <nl> - static ContinueStmtSyntax make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static ContinueStmtSyntax makeBlank ( ) ; <nl> public : <nl> + static ContinueStmtSyntax makeBlank ( ) ; <nl> + ContinueStmtSyntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> + : StmtSyntax ( Root , Data ) { } <nl> <nl> / / / Return the ' continue ' keyword associated with this continue statement . <nl> RC < TokenSyntax > getContinueKeyword ( ) const ; <nl> class ContinueStmtSyntax : public StmtSyntax { <nl> } <nl> } ; <nl> <nl> - # pragma mark - return - statement Data <nl> - <nl> - class ReturnStmtSyntaxData : public StmtSyntaxData { <nl> - friend class SyntaxData ; <nl> - friend class ReturnStmtSyntax ; <nl> - friend struct SyntaxFactory ; <nl> - <nl> - RC < ExprSyntaxData > CachedExpression ; <nl> - <nl> - ReturnStmtSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < ReturnStmtSyntaxData > make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < ReturnStmtSyntaxData > makeBlank ( ) ; <nl> - <nl> - public : <nl> - static bool classof ( const SyntaxData * SD ) { <nl> - return SD - > getKind ( ) = = SyntaxKind : : ReturnStmt ; <nl> - } <nl> - <nl> - } ; <nl> - <nl> # pragma mark - return - statement API <nl> <nl> / / / return - statement - > ' return ' expression ? ' ; ' ? <nl> class ReturnStmtSyntax : public StmtSyntax { <nl> friend struct SyntaxFactory ; <nl> - friend class ReturnStmtSyntaxData ; <nl> - friend class SyntaxData ; <nl> friend class Syntax ; <nl> <nl> - using DataType = ReturnStmtSyntaxData ; <nl> - <nl> enum class Cursor : CursorIndex { <nl> ReturnKeyword , <nl> Expression <nl> } ; <nl> <nl> - ReturnStmtSyntax ( const RC < SyntaxData > Root , <nl> - const ReturnStmtSyntaxData * Data ) ; <nl> + virtual void validate ( ) const override ; <nl> <nl> - static ReturnStmtSyntax make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static ReturnStmtSyntax makeBlank ( ) ; <nl> public : <nl> + static ReturnStmtSyntax makeBlank ( ) ; <nl> + ReturnStmtSyntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> + : StmtSyntax ( Root , Data ) { } <nl> <nl> / / / Return the ' return ' keyword associated with this return statement . <nl> RC < TokenSyntax > getReturnKeyword ( ) const ; <nl> mmm a / include / swift / Syntax / Syntax . h <nl> ppp b / include / swift / Syntax / Syntax . h <nl> <nl> # ifndef SWIFT_SYNTAX_SYNTAX_H <nl> # define SWIFT_SYNTAX_SYNTAX_H <nl> <nl> + # include " swift / Syntax / SyntaxData . h " <nl> # include " swift / Syntax / References . h " <nl> # include " swift / Syntax / RawSyntax . h " <nl> # include " swift / Syntax / Trivia . h " <nl> namespace sema { <nl> } <nl> namespace syntax { <nl> <nl> - const auto NoParent = llvm : : None ; <nl> + template < typename SyntaxNode > <nl> + SyntaxNode make ( RC < RawSyntax > Raw ) { <nl> + auto Data = SyntaxData : : make ( Raw ) ; <nl> + return { Data , Data . get ( ) } ; <nl> + } <nl> <nl> - class SyntaxData ; <nl> + const auto NoParent = llvm : : None ; <nl> <nl> / / / The main handle for syntax nodes - subclasses contain all public <nl> / / / structured editing APIs . <nl> class SyntaxData ; <nl> / / / their children . <nl> class Syntax { <nl> friend struct SyntaxFactory ; <nl> - friend class SyntaxData ; <nl> friend class LegacyASTTransformer ; <nl> friend class sema : : Semantics ; <nl> <nl> class Syntax { <nl> / / / lazily created . <nl> mutable const SyntaxData * Data ; <nl> <nl> - template < typename SyntaxNode > <nl> - typename SyntaxNode : : DataType * getUnsafeData ( ) const { <nl> - auto Casted = cast < typename SyntaxNode : : DataType > ( Data ) ; <nl> - return const_cast < typename SyntaxNode : : DataType * > ( Casted ) ; <nl> - } <nl> + / / / Subclasses override this to ensure their structure matches expectations . <nl> + virtual void validate ( ) const { } ; <nl> <nl> public : <nl> - using DataType = SyntaxData ; <nl> + Syntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> + : Root ( Root ) , Data ( Data ) { <nl> + this - > validate ( ) ; <nl> + } <nl> <nl> - Syntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) ; <nl> + virtual ~ Syntax ( ) { } <nl> <nl> / / / Get the kind of syntax . <nl> SyntaxKind getKind ( ) const ; <nl> class Syntax { <nl> } <nl> <nl> / / / Get the Data for this Syntax node . <nl> - template < typename T > <nl> - typename T : : DataType & getData ( ) const { <nl> - assert ( is < T > ( ) & & " getData < T > ( ) node of incompatible type ! " ) ; <nl> - return * reinterpret_cast < typename T : : DataType * > ( Data ) ; <nl> + const SyntaxData & getData ( ) const { <nl> + return * Data ; <nl> } <nl> <nl> const SyntaxData * getDataPointer ( ) const { <nl> class Syntax { <nl> template < typename T > <nl> T castTo ( ) const { <nl> assert ( is < T > ( ) & & " castTo < T > ( ) node of incompatible type ! " ) ; <nl> - return T { Root , reinterpret_cast < const typename T : : DataType * > ( Data ) } ; <nl> + return T { Root , Data } ; <nl> } <nl> <nl> / / / If this Syntax node is of the right kind , cast and return it , <nl> mmm a / include / swift / Syntax / SyntaxCollection . h <nl> ppp b / include / swift / Syntax / SyntaxCollection . h <nl> <nl> # define SWIFT_SYNTAX_SYNTAXCOLLECTION_H <nl> <nl> # include " swift / Syntax / Syntax . h " <nl> - # include " swift / Syntax / SyntaxCollectionData . h " <nl> <nl> namespace swift { <nl> namespace syntax { <nl> <nl> + template < SyntaxKind CollectionKind , typename Element > <nl> + class SyntaxCollection ; <nl> + <nl> template < SyntaxKind CollectionKind , typename Element > <nl> struct SyntaxCollectionIterator { <nl> const SyntaxCollection < CollectionKind , Element > & Collection ; <nl> struct SyntaxCollectionIterator { <nl> template < SyntaxKind CollectionKind , typename Element > <nl> class SyntaxCollection : public Syntax { <nl> friend struct SyntaxFactory ; <nl> - friend class SyntaxData ; <nl> friend class Syntax ; <nl> - using DataType = SyntaxCollectionData < CollectionKind , Element > ; <nl> <nl> private : <nl> - static RC < DataType > <nl> + static RC < SyntaxData > <nl> makeData ( std : : vector < Element > & Elements ) { <nl> RawSyntax : : LayoutList List ; <nl> for ( auto & Elt : Elements ) { <nl> class SyntaxCollection : public Syntax { <nl> } <nl> auto Raw = RawSyntax : : make ( CollectionKind , List , <nl> SourcePresence : : Present ) ; <nl> - return DataType : : make ( Raw ) ; <nl> + return SyntaxData : : make ( Raw ) ; <nl> } <nl> <nl> - protected : <nl> - SyntaxCollection ( const RC < SyntaxData > Root , const DataType * Data ) <nl> - : Syntax ( Root , Data ) { } <nl> - <nl> public : <nl> <nl> + static SyntaxCollection < CollectionKind , Element > makeBlank ( ) { <nl> + auto Raw = RawSyntax : : make ( CollectionKind , { } , SourcePresence : : Present ) ; <nl> + return make < SyntaxCollection < CollectionKind , Element > > ( Raw ) ; <nl> + } <nl> + <nl> + SyntaxCollection ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> + : Syntax ( Root , Data ) { } <nl> + <nl> / / / Returns true if the collection is empty . <nl> bool empty ( ) const { <nl> return size ( ) = = 0 ; <nl> class SyntaxCollection : public Syntax { <nl> assert ( Index < size ( ) ) ; <nl> assert ( ! empty ( ) ) ; <nl> <nl> - auto RawElement = getRaw ( ) - > Layout [ Index ] ; <nl> - auto * MyData = getUnsafeData < SyntaxCollection < CollectionKind , Element > > ( ) ; <nl> - <nl> - if ( auto Data = MyData - > CachedElements [ Index ] . get ( ) ) { <nl> - return Element { Root , Data } ; <nl> - } <nl> - <nl> - auto & ChildPtr = * reinterpret_cast < std : : atomic < uintptr_t > * > ( <nl> - MyData - > CachedElements . data ( ) + Index ) ; <nl> - <nl> - SyntaxData : : realizeSyntaxNode < Element > ( ChildPtr , RawElement , MyData , Index ) ; <nl> - <nl> - return Element { <nl> - Root , <nl> - MyData - > CachedElements [ Index ] . get ( ) <nl> - } ; <nl> + auto ChildData = Data - > getChild ( Index ) ; <nl> + return Element { Root , ChildData . get ( ) } ; <nl> } <nl> <nl> / / / Return a new collection with the given element added to the end . <nl> class SyntaxCollection : public Syntax { <nl> } <nl> } ; <nl> <nl> + # define SYNTAX ( Id , Super ) <nl> + # define SYNTAX_COLLECTION ( Id , Element ) \ <nl> + class Element ; \ <nl> + using Id # # Syntax = SyntaxCollection < SyntaxKind : : Id , Element > ; <nl> + # include " swift / Syntax / SyntaxKinds . def " <nl> + <nl> } / / end namespace syntax <nl> } / / end namespace swift <nl> <nl> deleted file mode 100644 <nl> index 457e36cb8b6e . . 000000000000 <nl> mmm a / include / swift / Syntax / SyntaxCollectionData . h <nl> ppp / dev / null <nl> <nl> - / / = = = mmm SyntaxCollectionData . h mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * - C + + - * - = = = / / <nl> - / / <nl> - / / This source file is part of the Swift . org open source project <nl> - / / <nl> - / / Copyright ( c ) 2014 - 2017 Apple Inc . and the Swift project authors <nl> - / / Licensed under Apache License v2 . 0 with Runtime Library Exception <nl> - / / <nl> - / / See https : / / swift . org / LICENSE . txt for license information <nl> - / / See https : / / swift . org / CONTRIBUTORS . txt for the list of Swift project authors <nl> - / / <nl> - / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> - <nl> - # ifndef SWIFT_SYNTAX_SYNTAXCOLLECTIONDATA_H <nl> - # define SWIFT_SYNTAX_SYNTAXCOLLECTIONDATA_H <nl> - <nl> - # include " swift / Syntax / SyntaxData . h " <nl> - <nl> - namespace swift { <nl> - namespace syntax { <nl> - <nl> - template < SyntaxKind CollectionKind , typename ElementType > <nl> - class SyntaxCollection ; <nl> - <nl> - template < SyntaxKind CollectionKind , typename ElementType > <nl> - class SyntaxCollectionData : public SyntaxData { <nl> - friend class SyntaxCollection < CollectionKind , ElementType > ; <nl> - std : : vector < RC < typename ElementType : : DataType > > CachedElements ; <nl> - <nl> - friend struct SyntaxFactory ; <nl> - friend class SyntaxData ; <nl> - friend class FunctionCallExprSyntaxBuilder ; <nl> - <nl> - <nl> - static RC < SyntaxCollectionData < CollectionKind , ElementType > > <nl> - make ( RC < RawSyntax > Raw , const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) { <nl> - <nl> - return RC < SyntaxCollectionData < CollectionKind , ElementType > > { <nl> - new SyntaxCollectionData < CollectionKind , ElementType > { <nl> - Raw , Parent , IndexInParent <nl> - } <nl> - } ; <nl> - } <nl> - <nl> - static RC < SyntaxCollectionData < CollectionKind , ElementType > > makeBlank ( ) { <nl> - auto Raw = RawSyntax : : make ( CollectionKind , { } , SourcePresence : : Present ) ; <nl> - return make ( Raw ) ; <nl> - } <nl> - <nl> - protected : <nl> - SyntaxCollectionData ( RC < RawSyntax > Raw , const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) <nl> - : SyntaxData ( Raw , Parent , IndexInParent ) , <nl> - CachedElements ( Raw - > Layout . size ( ) , nullptr ) { <nl> - assert ( Raw - > Kind = = CollectionKind ) ; <nl> - } <nl> - <nl> - public : <nl> - static bool classof ( const SyntaxData * SD ) { <nl> - return SD - > getKind ( ) = = CollectionKind ; <nl> - } <nl> - } ; <nl> - <nl> - # define SYNTAX ( Id , Parent ) <nl> - # define SYNTAX_COLLECTION ( Id , Element ) \ <nl> - class Element ; \ <nl> - using Id # # SyntaxData = SyntaxCollectionData < SyntaxKind : : Id , Element > ; <nl> - # include " swift / Syntax / SyntaxKinds . def " <nl> - <nl> - } / / end namespace syntax <nl> - } / / end namespace swift <nl> - <nl> - # endif <nl> mmm a / include / swift / Syntax / SyntaxData . h <nl> ppp b / include / swift / Syntax / SyntaxData . h <nl> <nl> / / <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> / / <nl> - / / This file defines the SyntaxData interface , the base type for the instance <nl> + / / This file defines the SyntaxData interface , the type for the instance <nl> / / data for Syntax nodes . <nl> / / <nl> / / Effectively , these provide two main things to a Syntax node - parental <nl> <nl> # ifndef SWIFT_SYNTAX_SYNTAXDATA_H <nl> # define SWIFT_SYNTAX_SYNTAXDATA_H <nl> <nl> + # include " swift / Syntax / AtomicCache . h " <nl> # include " swift / Syntax / RawSyntax . h " <nl> # include " swift / Syntax / References . h " <nl> - # include " swift / Syntax / Syntax . h " <nl> # include " llvm / ADT / DenseMap . h " <nl> <nl> # include < atomic > <nl> namespace syntax { <nl> <nl> class Syntax ; <nl> <nl> - / / / The base class for holding parented syntax . <nl> + / / / The class for holding parented syntax . <nl> / / / <nl> - / / / This structure and subclasses thereof should not contain significant public <nl> + / / / This structure should not contain significant public <nl> / / / API or internal modification API . <nl> / / / <nl> / / / This is only for holding a strong reference to the RawSyntax , a weak <nl> / / / reference to the parent , and , in subclasses , lazily created strong <nl> / / / references to non - terminal child nodes . <nl> - class SyntaxData : public llvm : : ThreadSafeRefCountedBase < SyntaxData > { <nl> + class SyntaxData final : public llvm : : ThreadSafeRefCountedBase < SyntaxData > { <nl> friend struct SyntaxFactory ; <nl> # define SYNTAX ( Id , Parent ) friend class Id # # Syntax ; <nl> # include " swift / Syntax / SyntaxKinds . def " <nl> + <nl> + using RootDataPair = std : : pair < RC < SyntaxData > , RC < SyntaxData > > ; <nl> + <nl> + llvm : : SmallVector < AtomicCache < SyntaxData > , 10 > Children ; <nl> + <nl> public : <nl> / / / The shared raw syntax representing this syntax data node . <nl> const RC < RawSyntax > Raw ; <nl> class SyntaxData : public llvm : : ThreadSafeRefCountedBase < SyntaxData > { <nl> <nl> SyntaxData ( RC < RawSyntax > Raw , const SyntaxData * Parent = nullptr , <nl> CursorIndex IndexInParent = 0 ) <nl> - : Raw ( Raw ) , Parent ( Parent ) , IndexInParent ( IndexInParent ) { } <nl> + : Raw ( Raw ) , Parent ( Parent ) , IndexInParent ( IndexInParent ) { <nl> + if ( Raw ) { <nl> + for ( size_t I = 0 ; I < Raw - > Layout . size ( ) ; + + I ) { <nl> + Children . push_back ( AtomicCache < SyntaxData > ( ) ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + / / / Constructs a SyntaxNode by replacing ` self ` and recursively building <nl> + / / / the parent chain up to the root . <nl> + template < typename SyntaxNode > <nl> + SyntaxNode replaceSelf ( const RC < RawSyntax > NewRaw ) const { <nl> + auto NewRootAndData = replaceSelf ( NewRaw ) ; <nl> + return { NewRootAndData . first , NewRootAndData . second . get ( ) } ; <nl> + } <nl> <nl> / / / With a new RawSyntax node , create a new node from this one and <nl> / / / recursively rebuild the parental chain up to the root . <nl> / / / <nl> / / / DO NOT expose this as public API . <nl> - template < typename SyntaxNode > <nl> - SyntaxNode replaceSelf ( RC < RawSyntax > NewRaw ) const { <nl> - auto NewMe = SyntaxNode : : DataType : : make ( NewRaw , nullptr , IndexInParent ) ; <nl> + RootDataPair replaceSelf ( const RC < RawSyntax > NewRaw ) const { <nl> if ( hasParent ( ) ) { <nl> - auto NewRootAndParent = getParent ( ) . getValue ( ) <nl> - - > replaceChild < Syntax > ( NewRaw , IndexInParent ) ; <nl> - NewMe - > Parent = NewRootAndParent . Data ; <nl> - return SyntaxNode { <nl> - NewRootAndParent . Root , <nl> - cast < typename SyntaxNode : : DataType > ( NewMe . get ( ) ) <nl> - } ; <nl> + auto NewRootAndParent = <nl> + getParent ( ) . getValue ( ) - > replaceChild ( NewRaw , IndexInParent ) ; <nl> + auto NewMe = NewRootAndParent . second - > getChild ( IndexInParent ) ; <nl> + return { NewRootAndParent . first , NewMe . get ( ) } ; <nl> } else { <nl> - return SyntaxNode { <nl> - NewMe , <nl> - cast < typename SyntaxNode : : DataType > ( NewMe . get ( ) ) <nl> - } ; <nl> + auto NewMe = make ( NewRaw , nullptr , IndexInParent ) ; <nl> + return { NewMe , NewMe . get ( ) } ; <nl> } <nl> } <nl> <nl> - / / / Unsafely instantiate a child within another node . <nl> - / / / <nl> - / / / DANGER ! <nl> - / / / <nl> - / / / Scary thread - safe code here . This should only be used for internally <nl> - / / / mutating cached children ! <nl> - / / / <nl> - / / / Why do we need this ? <nl> - / / / - ___SyntaxData nodes should have pointer identity . <nl> - / / / - We only want to construct parented , realized child nodes as <nl> - / / / ___SyntaxData when asked . <nl> - / / / <nl> - / / / For example , if we have a ReturnStmtSyntax , and ask for its returned <nl> - / / / expression for the first time with getExpression ( ) , two nodes can race <nl> - / / / to create and set the cached expression . <nl> - / / / <nl> - / / / <nl> - / / / Looking at an example - say we have a ReturnStmtSyntaxData . <nl> - / / / <nl> - / / / ReturnStmtSyntaxData = { <nl> - / / / RC < RawSyntax > Raw = { <nl> - / / / RC < TokenSyntax { SyntaxKind : : Token , tok : : return_kw , " return " } , <nl> - / / / RC < RawSyntax > { SyntaxKind : : SomeExpression , . . . } <nl> - / / / } <nl> - / / / RC < ExprSyntaxData > CachedExpression = { 0 } ; <nl> - / / / } <nl> - / / / <nl> - / / / We pretend that ` CachedExpression ` is a std : : atomic < uintptr_t > & , so that <nl> - / / / we can safely instantiate that field using the RawSyntax for the <nl> - / / / expression , i . e . getRaw ( ) - > getChild ( ReturnStmtSyntax : : Cursor : : Expression ) ) <nl> - template < typename SyntaxNode > <nl> - static <nl> - void realizeSyntaxNode ( std : : atomic < uintptr_t > & Child , <nl> - RC < RawSyntax > RawChild , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - / / We rely on the fact that an RC < ___SyntaxData > is pointer - sized , which <nl> - / / means we can atomically compare - exchange the child field . <nl> - / / If we can ' t do that , we can ' t pretend it ' s a uintptr_t and use its <nl> - / / compare_exchange_strong . <nl> - static_assert ( <nl> - sizeof ( uintptr_t ) = = sizeof ( RC < typename SyntaxNode : : DataType > ) , <nl> - " Can ' t safely atomically replace a child SyntaxData node " <nl> - " for caching ! This is the end of the world ! " ) ; <nl> - <nl> - if ( Child = = 0 ) { <nl> - / / We expect the uncached value to wrap a nullptr . If another thread <nl> - / / beats us to caching the child , it ' ll be non - null , so we would <nl> - / / leave it alone . <nl> - uintptr_t Expected = 0 ; <nl> - <nl> - / / Make a RC < SyntaxNode : : DataType > at RefCount = = 1 , which we ' ll try to <nl> - / / atomically swap in . <nl> - RC < typename SyntaxNode : : DataType > Data = <nl> - cast < typename SyntaxNode : : DataType > ( <nl> - SyntaxData : : makeDataFromRaw ( RawChild , Parent , IndexInParent ) ) ; <nl> - <nl> - / / Try to swap in raw pointer value . <nl> - auto SuccessfullySwapped = <nl> - Child . compare_exchange_strong ( Expected , <nl> - reinterpret_cast < uintptr_t > ( Data . get ( ) ) ) ; <nl> - <nl> - / / If we won , then leave the RefCount = = 1 . <nl> - if ( SuccessfullySwapped ) { <nl> - Data . resetWithoutRelease ( ) ; <nl> - } <nl> - <nl> - / / Otherwise , the Data we just made is unfortunately useless . <nl> - / / Let it die on this scope exit after its terminal release . <nl> - } <nl> + / / / Create the data for a child node with the raw syntax in our layout <nl> + / / / at the provided index . <nl> + / / / DO NOT expose this as public API . <nl> + RC < SyntaxData > realizeSyntaxNode ( CursorIndex Index ) const { <nl> + auto RawChild = Raw - > Layout . at ( Index ) ; <nl> + return SyntaxData : : make ( RawChild , this , Index ) ; <nl> } <nl> <nl> / / / Replace a child in the raw syntax and recursively rebuild the <nl> / / / parental chain up to the root . <nl> / / / <nl> - / / / This is the effective private implementation of all setters in <nl> - / / / subclasses of ` SyntaxData ` . <nl> - / / / <nl> / / / DO NOT expose this as public API . <nl> template < typename SyntaxNode , typename CursorType > <nl> - SyntaxNode replaceChild ( RC < RawSyntax > RawChild , <nl> + SyntaxNode replaceChild ( const RC < RawSyntax > RawChild , <nl> CursorType ChildCursor ) const { <nl> + auto NewRootAndParent = replaceChild ( RawChild , ChildCursor ) ; <nl> + return SyntaxNode { <nl> + NewRootAndParent . first , <nl> + NewRootAndParent . second . get ( ) <nl> + } ; <nl> + } <nl> + <nl> + / / / Replace a child in the raw syntax and recursively rebuild the <nl> + / / / parental chain up to the root . <nl> + / / / <nl> + / / / DO NOT expose this as public API . <nl> + template < typename CursorType > <nl> + RootDataPair replaceChild ( const RC < RawSyntax > RawChild , <nl> + CursorType ChildCursor ) const { <nl> auto NewRaw = Raw - > replaceChild ( ChildCursor , RawChild ) ; <nl> - return replaceSelf < SyntaxNode > ( NewRaw ) ; <nl> + return replaceSelf ( NewRaw ) ; <nl> } <nl> <nl> public : <nl> <nl> - static RC < SyntaxData > makeDataFromRaw ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) ; <nl> - <nl> static RC < SyntaxData > make ( RC < RawSyntax > Raw , <nl> const SyntaxData * Parent = nullptr , <nl> CursorIndex IndexInParent = 0 ) ; <nl> class SyntaxData : public llvm : : ThreadSafeRefCountedBase < SyntaxData > { <nl> if ( Parent ! = nullptr ) { <nl> return Parent ; <nl> } <nl> - return NoParent ; <nl> + return llvm : : None ; <nl> } <nl> <nl> / / / Returns true if this syntax node has a parent . <nl> class SyntaxData : public llvm : : ThreadSafeRefCountedBase < SyntaxData > { <nl> return IndexInParent ; <nl> } <nl> <nl> + / / / Returns the number of children this SyntaxData represents . <nl> + size_t getNumChildren ( ) const { <nl> + return Raw - > Layout . size ( ) ; <nl> + } <nl> + <nl> + / / / Gets the child at the index specified by the provided cursor , <nl> + / / / lazily creating it if necessary . <nl> + template < typename CursorType > <nl> + RC < SyntaxData > getChild ( CursorType Cursor ) const { <nl> + return getChild ( ( size_t ) cursorIndex ( Cursor ) ) ; <nl> + } <nl> + <nl> + / / / Gets the child at the specified index in this data ' s children array . <nl> + / / / Why do we need this ? <nl> + / / / - SyntaxData nodes should have pointer identity . <nl> + / / / - We only want to construct parented , realized child nodes as <nl> + / / / SyntaxData when asked . <nl> + / / / <nl> + / / / For example , if we have a ReturnStmtSyntax , and ask for its returned <nl> + / / / expression for the first time with getExpression ( ) , two nodes can race <nl> + / / / to create and set the cached expression . <nl> + / / / <nl> + / / / Looking at an example - say we have a SyntaxData . <nl> + / / / <nl> + / / / SyntaxData = { <nl> + / / / RC < RawSyntax > Raw = { <nl> + / / / RC < RawTokenSyntax { SyntaxKind : : Token , tok : : return_kw , " return " } , <nl> + / / / RC < RawSyntax > { SyntaxKind : : SomeExpression , . . . } <nl> + / / / } <nl> + / / / llvm : : SmallVector < AtomicCache < SyntaxData > , 10 > Children { <nl> + / / / AtomicCache < SyntaxData > { RC < SyntaxData > = nullptr ; } , <nl> + / / / AtomicCache < SyntaxData > { RC < SyntaxData > = nullptr ; } , <nl> + / / / } <nl> + / / / } <nl> + / / / <nl> + / / / If we wanted to safely create the 0th child , an instance of TokenSyntax , <nl> + / / / then we ask the AtomicCache in that position to realize its value and <nl> + / / / cache it . This is safe because AtomicCache only ever mutates its cache <nl> + / / / one time - - the first initialization that wins a compare_exchange_strong . <nl> + RC < SyntaxData > getChild ( size_t Index ) const { <nl> + return Children [ Index ] . getOrCreate ( [ & ] ( ) { <nl> + return realizeSyntaxNode ( Index ) ; <nl> + } ) ; <nl> + } <nl> + <nl> / / / Returns true if the data node represents type syntax . <nl> bool isType ( ) const ; <nl> <nl> class SyntaxData : public llvm : : ThreadSafeRefCountedBase < SyntaxData > { <nl> / / / Returns true if the data node represents expression syntax . <nl> bool isExpr ( ) const ; <nl> <nl> + / / / Returns true if the data node represents pattern syntax . <nl> + bool isPattern ( ) const ; <nl> + <nl> / / / Returns true if this syntax is of some " unknown " kind . <nl> bool isUnknown ( ) const ; <nl> <nl> mmm a / include / swift / Syntax / SyntaxKinds . def <nl> ppp b / include / swift / Syntax / SyntaxKinds . def <nl> SYNTAX_RANGE ( Decl , MissingDecl , FunctionDecl ) <nl> SYNTAX ( DeclMembers , Syntax ) <nl> SYNTAX ( GenericParameter , Syntax ) <nl> SYNTAX ( GenericParameterClause , Syntax ) <nl> - SYNTAX ( GenericParameterList , Syntax ) <nl> <nl> SYNTAX ( GenericWhereClause , Syntax ) <nl> - SYNTAX ( GenericRequirementList , Syntax ) <nl> SYNTAX ( GenericArgumentClause , Syntax ) <nl> - SYNTAX ( GenericArgumentList , Syntax ) <nl> ABSTRACT_SYNTAX ( GenericRequirementSyntax , Syntax ) <nl> SYNTAX ( ConformanceRequirement , GenericRequirementSyntax ) <nl> SYNTAX ( SameTypeRequirement , GenericRequirementSyntax ) <nl> ABSTRACT_SYNTAX ( TypeSyntax , Syntax ) <nl> SYNTAX_RANGE ( Type , MissingType , FunctionType ) <nl> <nl> / / Statements <nl> - SYNTAX ( StmtList , Syntax ) <nl> <nl> ABSTRACT_SYNTAX ( StmtSyntax , Syntax ) <nl> SYNTAX ( UnknownStmt , StmtSyntax ) <nl> SYNTAX_RANGE ( Expr , MissingExpr , SymbolicReferenceExpr ) <nl> / / Other stuff <nl> SYNTAX ( BalancedTokens , Syntax ) <nl> SYNTAX ( TypeAttribute , Syntax ) <nl> - SYNTAX ( TypeAttributes , Syntax ) <nl> SYNTAX ( TupleTypeElement , Syntax ) <nl> SYNTAX ( FunctionTypeArgument , Syntax ) <nl> - SYNTAX ( FunctionCallArgumentList , Syntax ) <nl> SYNTAX ( FunctionCallArgument , Syntax ) <nl> SYNTAX ( FunctionSignature , Syntax ) <nl> SYNTAX ( FunctionParameter , Syntax ) <nl> SYNTAX ( DeclModifier , Syntax ) <nl> - SYNTAX ( DeclModifierList , Syntax ) <nl> <nl> + SYNTAX_COLLECTION ( StmtList , StmtSyntax ) <nl> + SYNTAX_COLLECTION ( FunctionCallArgumentList , FunctionCallArgumentSyntax ) <nl> + SYNTAX_COLLECTION ( DeclModifierList , DeclModifierSyntax ) <nl> SYNTAX_COLLECTION ( FunctionParameterList , FunctionParameterSyntax ) <nl> SYNTAX_COLLECTION ( TupleTypeElementList , TupleTypeElementSyntax ) <nl> + SYNTAX_COLLECTION ( GenericParameterList , GenericParameterSyntax ) <nl> + SYNTAX_COLLECTION ( GenericRequirementList , GenericRequirementSyntax ) <nl> + SYNTAX_COLLECTION ( GenericArgumentList , GenericArgumentSyntax ) <nl> + SYNTAX_COLLECTION ( TypeAttributes , TypeAttributeSyntax ) <nl> <nl> # undef SYNTAX_COLLECTION <nl> # undef ABSTRACT_SYNTAX <nl> mmm a / include / swift / Syntax / TypeSyntax . h <nl> ppp b / include / swift / Syntax / TypeSyntax . h <nl> namespace swift { <nl> namespace syntax { <nl> <nl> class GenericArgumentClauseSyntax ; <nl> - class GenericArgumentClauseSyntaxData ; <nl> class GenericParameterClauseSyntax ; <nl> - class GenericParameterClauseSyntaxData ; <nl> - <nl> - # pragma mark - balanced - tokens Data <nl> - <nl> - class BalancedTokensSyntaxData final : public SyntaxData { <nl> - friend class SyntaxData ; <nl> - friend struct SyntaxFactory ; <nl> - <nl> - BalancedTokensSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < BalancedTokensSyntaxData > make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < BalancedTokensSyntaxData > makeBlank ( ) ; <nl> - public : <nl> - static bool classof ( const SyntaxData * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : BalancedTokens ; <nl> - } <nl> - } ; <nl> <nl> # pragma mark - balanced - tokens API <nl> <nl> class BalancedTokensSyntaxData final : public SyntaxData { <nl> / / / | Any punctuation except ( , ) , [ , ] , { , or } <nl> class BalancedTokensSyntax final : public Syntax { <nl> friend struct SyntaxFactory ; <nl> - friend class SyntaxData ; <nl> - <nl> - using DataType = BalancedTokensSyntaxData ; <nl> - <nl> - BalancedTokensSyntax ( RC < SyntaxData > Root , <nl> - const BalancedTokensSyntaxData * Data ) ; <nl> + <nl> + virtual void validate ( ) const override ; <nl> <nl> public : <nl> + static BalancedTokensSyntax makeBlank ( ) ; <nl> + BalancedTokensSyntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> + : Syntax ( Root , Data ) { } <nl> + <nl> / / TODO : TODO : BalancedTokensSyntax : : getBalancedToken <nl> <nl> BalancedTokensSyntax <nl> class BalancedTokensSyntax final : public Syntax { <nl> } <nl> } ; <nl> <nl> - # pragma mark - type - attribute Data <nl> - <nl> - class TypeAttributeSyntaxData final : public SyntaxData { <nl> - friend class SyntaxData ; <nl> - RC < BalancedTokensSyntaxData > CachedBalancedTokens ; <nl> - friend struct SyntaxFactory ; <nl> - <nl> - TypeAttributeSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < TypeAttributeSyntaxData > make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < TypeAttributeSyntaxData > makeBlank ( ) ; <nl> - <nl> - public : <nl> - static bool classof ( const SyntaxData * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : TypeAttribute ; <nl> - } <nl> - } ; <nl> - <nl> # pragma mark - type - attribute API <nl> <nl> / / / type - attribute - > ' @ ' identifier attribute - argument - clause ? <nl> / / / attribute - argument - clause - > ' ( ' balanced - tokens ' ) ' <nl> class TypeAttributeSyntax final : public Syntax { <nl> friend struct SyntaxFactory ; <nl> - friend class TypeAttributeSyntaxData ; <nl> - friend class SyntaxData ; <nl> - <nl> - using DataType = TypeAttributeSyntaxData ; <nl> - <nl> + <nl> enum class Cursor : CursorIndex { <nl> AtSignToken , <nl> Identifier , <nl> class TypeAttributeSyntax final : public Syntax { <nl> RightParenToken , <nl> } ; <nl> <nl> - TypeAttributeSyntax ( RC < SyntaxData > Root , const TypeAttributeSyntaxData * Data ) ; <nl> + virtual void validate ( ) const override ; <nl> <nl> public : <nl> + static TypeAttributeSyntax makeBlank ( ) ; <nl> + TypeAttributeSyntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> + : Syntax ( Root , Data ) { } <nl> <nl> / / / Return the ' @ ' token associated with the type attribute . <nl> RC < TokenSyntax > getAtSignToken ( ) const ; <nl> class TypeAttributeSyntax final : public Syntax { <nl> } <nl> } ; <nl> <nl> - # pragma mark - type - attributes Data <nl> - <nl> - class TypeAttributesSyntaxData final : public SyntaxData { <nl> - friend class SyntaxData ; <nl> - friend class TypeAttributesSyntax ; <nl> - friend struct SyntaxFactory ; <nl> - <nl> - TypeAttributesSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < TypeAttributesSyntaxData > make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < TypeAttributesSyntaxData > makeBlank ( ) ; <nl> - public : <nl> - static bool classof ( const SyntaxData * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : TypeAttributes ; <nl> - } <nl> - } ; <nl> - <nl> - # pragma mark - type - attributes API <nl> - <nl> - / / / type - attributes - > type - attribute <nl> - / / / | type - attribute type - attributes <nl> - class TypeAttributesSyntax final : public Syntax { <nl> - friend struct SyntaxFactory ; <nl> - friend class TypeAttributesSyntaxData ; <nl> - friend class SyntaxData ; <nl> - friend class FunctionSignatureSyntax ; <nl> - friend class FunctionDeclSyntax ; <nl> - <nl> - using DataType = TypeAttributesSyntaxData ; <nl> - <nl> - TypeAttributesSyntax ( RC < SyntaxData > Root , <nl> - const TypeAttributesSyntaxData * Data ) ; <nl> - public : <nl> - / / TODO : Convert to SyntaxCollection <nl> - / / <nl> - <nl> - TypeAttributesSyntax <nl> - addTypeAttribute ( TypeAttributeSyntax NewTypeAttribute ) const ; <nl> - <nl> - static bool classof ( const Syntax * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : TypeAttributes ; <nl> - } <nl> - } ; <nl> - <nl> - # pragma mark - type - syntax Data <nl> - <nl> - class TypeSyntaxData : public SyntaxData { <nl> - friend class SyntaxData ; <nl> - friend class TypeSyntax ; <nl> - <nl> - protected : <nl> - TypeSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - <nl> - public : <nl> - static bool classof ( const SyntaxData * S ) { <nl> - return S - > isType ( ) ; <nl> - } <nl> - } ; <nl> - <nl> # pragma mark - type - syntax API <nl> <nl> / / / type - > array - type <nl> class TypeSyntaxData : public SyntaxData { <nl> / / / | ' Any ' <nl> / / / | ' Self ' <nl> class TypeSyntax : public Syntax { <nl> - using DataType = TypeSyntaxData ; <nl> - friend class SyntaxData ; <nl> friend class FunctionParameterSyntax ; <nl> friend class FunctionSignatureSyntax ; <nl> protected : <nl> - TypeSyntax ( const RC < SyntaxData > Root , const TypeSyntaxData * Data ) ; <nl> + virtual void validate ( ) const override { } <nl> + <nl> public : <nl> + static TypeSyntax makeBlank ( ) ; <nl> + TypeSyntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> + : Syntax ( Root , Data ) { } <nl> static bool classof ( const Syntax * S ) { <nl> return S - > isType ( ) ; <nl> } <nl> } ; <nl> <nl> - # pragma mark - type - identifier Data <nl> - <nl> - class TypeIdentifierSyntaxData final : public TypeSyntaxData { <nl> - friend struct SyntaxFactory ; <nl> - friend class TypeIdentifierSyntax ; <nl> - friend class SyntaxData ; <nl> - <nl> - RC < GenericArgumentClauseSyntaxData > CachedGenericArgumentClause ; <nl> - RC < TypeIdentifierSyntaxData > CachedChildTypeIdentifier ; <nl> - <nl> - TypeIdentifierSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - <nl> - static RC < TypeIdentifierSyntaxData > make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < TypeIdentifierSyntaxData > makeBlank ( ) ; <nl> - public : <nl> - static bool classof ( const SyntaxData * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : TypeIdentifier ; <nl> - } <nl> - } ; <nl> - <nl> # pragma mark - type - identifier API <nl> <nl> / / / type - identifier - > type - name generic - argument - clause ? <nl> / / / | type - name generic - argument - clause ' . ' type - identifier <nl> class TypeIdentifierSyntax final : public TypeSyntax { <nl> friend struct SyntaxFactory ; <nl> - friend class TypeIdentifierSyntaxData ; <nl> - friend class SyntaxData ; <nl> - <nl> - using DataType = TypeIdentifierSyntaxData ; <nl> - <nl> + <nl> private : <nl> enum class Cursor { <nl> Identifier , <nl> class TypeIdentifierSyntax final : public TypeSyntax { <nl> ChildTypeIdentifier , <nl> } ; <nl> <nl> - TypeIdentifierSyntax ( RC < SyntaxData > Root , <nl> - const TypeIdentifierSyntaxData * Data ) ; <nl> + virtual void validate ( ) const override ; <nl> <nl> public : <nl> + static TypeIdentifierSyntax makeBlank ( ) ; <nl> + TypeIdentifierSyntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> + : TypeSyntax ( Root , Data ) { } <nl> + <nl> RC < TokenSyntax > getIdentifier ( ) const ; <nl> <nl> TypeIdentifierSyntax <nl> class TypeIdentifierSyntax final : public TypeSyntax { <nl> } <nl> } ; <nl> <nl> - # pragma mark - tuple - type - element Data <nl> - <nl> - class TupleTypeElementSyntaxData final : public SyntaxData { <nl> - friend class SyntaxData ; <nl> - friend struct SyntaxFactory ; <nl> - <nl> - TupleTypeElementSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < TupleTypeElementSyntaxData > make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < TupleTypeElementSyntaxData > makeBlank ( ) ; <nl> - public : <nl> - static bool classof ( const SyntaxData * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : TupleTypeElement ; <nl> - } <nl> - } ; <nl> - <nl> # pragma mark - tuple - type - element API <nl> <nl> / / / tuple - type - element - > ( identifier ' : ' ) ? type - attributes ? ' inout ' ? type <nl> class TupleTypeElementSyntaxData final : public SyntaxData { <nl> / / / a type without a label . <nl> class TupleTypeElementSyntax final : public Syntax { <nl> friend struct SyntaxFactory ; <nl> - friend class TupleTypeElementSyntaxData ; <nl> - friend class SyntaxData ; <nl> - <nl> + <nl> enum class Cursor : CursorIndex { <nl> Label , <nl> ColonToken , <nl> class TupleTypeElementSyntax final : public Syntax { <nl> CommaToken , <nl> } ; <nl> <nl> - TupleTypeElementSyntax ( RC < SyntaxData > Root , <nl> - const TupleTypeElementSyntaxData * Data ) ; <nl> + virtual void validate ( ) const override ; <nl> + <nl> public : <nl> - using DataType = TupleTypeElementSyntaxData ; <nl> + static TupleTypeElementSyntax makeBlank ( ) ; <nl> + TupleTypeElementSyntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> + : Syntax ( Root , Data ) { } <nl> <nl> / / / Return the label of the tuple type element . <nl> RC < TokenSyntax > getLabel ( ) const ; <nl> class TupleTypeElementSyntax final : public Syntax { <nl> } <nl> } ; <nl> <nl> - # pragma mark - tuple - type - element - list API <nl> - <nl> - using TupleTypeElementListSyntax = <nl> - SyntaxCollection < SyntaxKind : : TupleTypeElementList , TupleTypeElementSyntax > ; <nl> - <nl> - # pragma mark - tuple - type Data <nl> - <nl> - class TupleTypeSyntaxData final : public TypeSyntaxData { <nl> - friend class SyntaxData ; <nl> - friend struct SyntaxFactory ; <nl> - friend class TupleTypeSyntaxBuilder ; <nl> - TupleTypeSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - <nl> - static RC < TupleTypeSyntaxData > make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < TupleTypeSyntaxData > makeBlank ( ) ; <nl> - <nl> - public : <nl> - static bool classof ( const SyntaxData * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : TupleType ; <nl> - } <nl> - } ; <nl> - <nl> # pragma mark - tuple - type API <nl> <nl> / / / tuple - type - > ' ( ' tuple - type - element - list ' ) ' <nl> class TupleTypeSyntax final : public TypeSyntax { <nl> friend struct SyntaxFactory ; <nl> - friend class TupleTypeSyntaxData ; <nl> - friend class SyntaxData ; <nl> friend class TupleTypeSyntaxBuilder ; <nl> <nl> - using DataType = TupleTypeSyntaxData ; <nl> - <nl> enum class Cursor : CursorIndex { <nl> LeftParenToken , <nl> TypeElementList , <nl> RightParenToken , <nl> } ; <nl> <nl> - TupleTypeSyntax ( RC < SyntaxData > Root , const TupleTypeSyntaxData * Data ) ; <nl> + virtual void validate ( ) const override ; <nl> <nl> public : <nl> + static TupleTypeSyntax makeBlank ( ) ; <nl> + TupleTypeSyntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> + : TypeSyntax ( Root , Data ) { } <nl> + <nl> / / / Return the left paren ' ( ' token surrounding the tuple type syntax . <nl> RC < TokenSyntax > getLeftParen ( ) const ; <nl> TupleTypeSyntax withLeftParen ( RC < TokenSyntax > NewLeftParen ) const ; <nl> class TupleTypeSyntaxBuilder final { <nl> TupleTypeSyntax build ( ) const ; <nl> } ; <nl> <nl> - # pragma mark - metatype - type Data <nl> - <nl> - class MetatypeTypeSyntaxData final : public TypeSyntaxData { <nl> - friend struct SyntaxFactory ; <nl> - friend class SyntaxData ; <nl> - MetatypeTypeSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < MetatypeTypeSyntaxData > make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < MetatypeTypeSyntaxData > makeBlank ( ) ; <nl> - public : <nl> - static bool classof ( const SyntaxData * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : MetatypeType ; <nl> - } <nl> - } ; <nl> - <nl> # pragma mark - metatype - type API <nl> <nl> / / / metatype - type - > type ' . ' ' Type ' <nl> / / / | type ' . ' ' Protocol ' <nl> class MetatypeTypeSyntax final : public TypeSyntax { <nl> friend struct SyntaxFactory ; <nl> - friend class MetatypeTypeSyntaxData ; <nl> - friend class SyntaxData ; <nl> - <nl> - using DataType = MetatypeTypeSyntaxData ; <nl> - <nl> + <nl> enum class Cursor : CursorIndex { <nl> BaseType , <nl> DotToken , <nl> TypeToken , <nl> } ; <nl> <nl> - MetatypeTypeSyntax ( RC < SyntaxData > Root , const MetatypeTypeSyntaxData * Data ) ; <nl> + virtual void validate ( ) const override ; <nl> <nl> public : <nl> + static MetatypeTypeSyntax makeBlank ( ) ; <nl> + MetatypeTypeSyntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> + : TypeSyntax ( Root , Data ) { } <nl> + <nl> TypeSyntax getBaseTypeSyntax ( ) const ; <nl> / / / Return a new metatype type with the given base type - the ` A ` in ` A . Type ` . <nl> MetatypeTypeSyntax withBaseTypeSyntax ( TypeSyntax NewBaseType ) const ; <nl> class MetatypeTypeSyntax final : public TypeSyntax { <nl> } <nl> } ; <nl> <nl> - # pragma mark - optional - type Data <nl> - <nl> - class OptionalTypeSyntaxData final : public TypeSyntaxData { <nl> - friend class SyntaxData ; <nl> - friend struct SyntaxFactory ; <nl> - OptionalTypeSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < OptionalTypeSyntaxData > make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < OptionalTypeSyntaxData > makeBlank ( ) ; <nl> - public : <nl> - static bool classof ( const SyntaxData * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : OptionalType ; <nl> - } <nl> - } ; <nl> - <nl> # pragma mark - optional - type API <nl> <nl> / / / optional - type - > type ' ? ' <nl> class OptionalTypeSyntax final : public TypeSyntax { <nl> friend struct SyntaxFactory ; <nl> - friend class OptionalTypeSyntaxData ; <nl> - friend class SyntaxData ; <nl> - <nl> - using DataType = OptionalTypeSyntaxData ; <nl> - <nl> + <nl> enum class Cursor : CursorIndex { <nl> BaseType , <nl> QuestionToken <nl> } ; <nl> <nl> - OptionalTypeSyntax ( RC < SyntaxData > Root , const OptionalTypeSyntaxData * Data ) ; <nl> - <nl> + virtual void validate ( ) const override ; <nl> public : <nl> + static OptionalTypeSyntax makeBlank ( ) ; <nl> + OptionalTypeSyntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> + : TypeSyntax ( Root , Data ) { } <nl> + <nl> / / / Return the syntax of the type to which this optional type refers . <nl> TypeSyntax getBaseTypeSyntax ( ) const ; <nl> <nl> class OptionalTypeSyntax final : public TypeSyntax { <nl> } <nl> } ; <nl> <nl> - # pragma mark - implicitly - unwrapped - optional - type Data <nl> - <nl> - class ImplicitlyUnwrappedOptionalTypeSyntaxData final : public TypeSyntaxData { <nl> - friend struct SyntaxFactory ; <nl> - friend class SyntaxData ; <nl> - ImplicitlyUnwrappedOptionalTypeSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - <nl> - static RC < ImplicitlyUnwrappedOptionalTypeSyntaxData > <nl> - make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < ImplicitlyUnwrappedOptionalTypeSyntaxData > makeBlank ( ) ; <nl> - public : <nl> - static bool classof ( const SyntaxData * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : ImplicitlyUnwrappedOptionalType ; <nl> - } <nl> - } ; <nl> - <nl> # pragma mark - implicitly - unwrapped - optional - type API <nl> <nl> / / / implicitly - unwrapped - optional - type - > type ' ! ' <nl> class ImplicitlyUnwrappedOptionalTypeSyntax final : public TypeSyntax { <nl> friend struct SyntaxFactory ; <nl> - friend class ImplicitlyUnwrappedOptionalTypeSyntaxData ; <nl> - friend class SyntaxData ; <nl> - <nl> - using DataType = ImplicitlyUnwrappedOptionalTypeSyntaxData ; <nl> - <nl> + <nl> enum class Cursor : CursorIndex { Type , ExclaimToken } ; <nl> <nl> - ImplicitlyUnwrappedOptionalTypeSyntax ( RC < SyntaxData > Root , <nl> - const ImplicitlyUnwrappedOptionalTypeSyntaxData * Data ) ; <nl> + virtual void validate ( ) const override ; <nl> <nl> public : <nl> + static ImplicitlyUnwrappedOptionalTypeSyntax makeBlank ( ) ; <nl> + ImplicitlyUnwrappedOptionalTypeSyntax ( const RC < SyntaxData > Root , <nl> + const SyntaxData * Data ) <nl> + : TypeSyntax ( Root , Data ) { } <nl> + <nl> / / / Return the syntax for the base type to which this implicitly unwrapped <nl> / / / optional type refers . <nl> TypeSyntax getBaseTypeSyntax ( ) const ; <nl> class ImplicitlyUnwrappedOptionalTypeSyntax final : public TypeSyntax { <nl> } <nl> } ; <nl> <nl> - # pragma mark - array - type Data <nl> - <nl> - class ArrayTypeSyntaxData final : public TypeSyntaxData { <nl> - friend class SyntaxData ; <nl> - friend struct SyntaxFactory ; <nl> - <nl> - ArrayTypeSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - <nl> - static RC < ArrayTypeSyntaxData > make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < ArrayTypeSyntaxData > makeBlank ( ) ; <nl> - <nl> - public : <nl> - static bool classof ( const SyntaxData * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : OptionalType ; <nl> - } <nl> - } ; <nl> - <nl> # pragma mark - array - type API <nl> <nl> / / array - type - > ' [ ' type ' ] ' <nl> class ArrayTypeSyntax final : public TypeSyntax { <nl> friend struct SyntaxFactory ; <nl> - friend class ArrayTypeSyntaxData ; <nl> - friend class SyntaxData ; <nl> - <nl> - using DataType = ArrayTypeSyntaxData ; <nl> - <nl> + <nl> enum class Cursor : CursorIndex { <nl> LeftSquareBracketToken , <nl> Type , <nl> RightSquareBracketToken , <nl> } ; <nl> <nl> - ArrayTypeSyntax ( RC < SyntaxData > Root , const ArrayTypeSyntaxData * Data ) ; <nl> - <nl> + virtual void validate ( ) const override ; <nl> public : <nl> + static ArrayTypeSyntax makeBlank ( ) ; <nl> + <nl> + ArrayTypeSyntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> + : TypeSyntax ( Root , Data ) { } <nl> + <nl> / / / Return the left square bracket ' [ ' token surrounding the array <nl> / / / type syntax . <nl> RC < TokenSyntax > getLeftSquareBracketToken ( ) const ; <nl> class ArrayTypeSyntax final : public TypeSyntax { <nl> } <nl> } ; <nl> <nl> - # pragma mark - dictionary - type Data <nl> - <nl> - class DictionaryTypeSyntaxData final : public TypeSyntaxData { <nl> - friend class SyntaxData ; <nl> - friend class DictionaryTypeSyntax ; <nl> - friend struct SyntaxFactory ; <nl> - <nl> - RC < TypeSyntaxData > CachedKeyTypeSyntax ; <nl> - RC < TypeSyntaxData > CachedValueTypeSyntax ; <nl> - <nl> - DictionaryTypeSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - <nl> - static RC < DictionaryTypeSyntaxData > make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < DictionaryTypeSyntaxData > makeBlank ( ) ; <nl> - public : <nl> - static bool classof ( const SyntaxData * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : ArrayType ; <nl> - } <nl> - } ; <nl> - <nl> # pragma mark - dictionary - type API <nl> <nl> / / dictionary - type - > ' [ ' type ' : ' type ' ] ' <nl> class DictionaryTypeSyntax final : public TypeSyntax { <nl> friend struct SyntaxFactory ; <nl> - friend class DictionaryTypeSyntaxData ; <nl> - friend class SyntaxData ; <nl> - <nl> - using DataType = DictionaryTypeSyntaxData ; <nl> - <nl> + <nl> enum class Cursor : CursorIndex { <nl> LeftSquareBracketToken , <nl> KeyType , <nl> class DictionaryTypeSyntax final : public TypeSyntax { <nl> RightSquareBracketToken , <nl> } ; <nl> <nl> - DictionaryTypeSyntax ( RC < SyntaxData > Root , <nl> - const DictionaryTypeSyntaxData * Data ) ; <nl> + virtual void validate ( ) const override ; <nl> <nl> public : <nl> + static DictionaryTypeSyntax makeBlank ( ) ; <nl> + <nl> + DictionaryTypeSyntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> + : TypeSyntax ( Root , Data ) { } <nl> + <nl> / / / Return the left square bracket ' [ ' token surrounding the dictionary <nl> / / / type syntax . <nl> RC < TokenSyntax > getLeftSquareBracketToken ( ) const ; <nl> class DictionaryTypeSyntax final : public TypeSyntax { <nl> } <nl> } ; <nl> <nl> - # pragma mark - function - type - argument Data <nl> - <nl> - class FunctionTypeArgumentSyntaxData final : public SyntaxData { <nl> - friend class SyntaxData ; <nl> - friend struct SyntaxFactory ; <nl> - <nl> - FunctionTypeArgumentSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - <nl> - static RC < FunctionTypeArgumentSyntaxData > <nl> - make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < FunctionTypeArgumentSyntaxData > makeBlank ( ) ; <nl> - public : <nl> - static bool classof ( const SyntaxData * SD ) { <nl> - return SD - > getKind ( ) = = SyntaxKind : : FunctionTypeArgument ; <nl> - } <nl> - } ; <nl> - <nl> # pragma mark - function - type - argument API <nl> <nl> class FunctionTypeArgumentSyntax final : public Syntax { <nl> friend struct SyntaxFactory ; <nl> - friend class SyntaxData ; <nl> - <nl> - using DataType = FunctionTypeArgumentSyntaxData ; <nl> - <nl> + <nl> enum class Cursor : CursorIndex { <nl> ExternalParameterName , <nl> LocalParameterName , <nl> class FunctionTypeArgumentSyntax final : public Syntax { <nl> Type , <nl> } ; <nl> <nl> - FunctionTypeArgumentSyntax ( RC < SyntaxData > Root , <nl> - const FunctionTypeArgumentSyntaxData * Data ) ; <nl> + virtual void validate ( ) const override ; <nl> <nl> public : <nl> + static FunctionTypeArgumentSyntax makeBlank ( ) ; <nl> + FunctionTypeArgumentSyntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> + : Syntax ( Root , Data ) { } <nl> + <nl> static bool classof ( const Syntax * S ) { <nl> return S - > getKind ( ) = = SyntaxKind : : FunctionTypeArgument ; <nl> } <nl> } ; <nl> <nl> - <nl> - # pragma mark - function - type Data <nl> - <nl> - class FunctionTypeSyntaxData final : public TypeSyntaxData { <nl> - friend class SyntaxData ; <nl> - friend class FunctionTypeSyntax ; <nl> - friend class FunctionTypeSyntaxBuilder ; <nl> - friend struct SyntaxFactory ; <nl> - <nl> - FunctionTypeSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < FunctionTypeSyntaxData > make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - static RC < FunctionTypeSyntaxData > makeBlank ( ) ; <nl> - public : <nl> - static bool classof ( const SyntaxData * S ) { <nl> - return S - > getKind ( ) = = SyntaxKind : : DictionaryType ; <nl> - } <nl> - } ; <nl> - <nl> # pragma mark - function - type API <nl> <nl> / / / function - type - > <nl> class FunctionTypeSyntaxData final : public TypeSyntaxData { <nl> class FunctionTypeSyntax final : public TypeSyntax { <nl> friend struct SyntaxFactory ; <nl> friend class FunctionTypeSyntaxBuilder ; <nl> - friend class FunctionTypeSyntaxData ; <nl> - friend class SyntaxData ; <nl> - <nl> - using DataType = FunctionTypeSyntaxData ; <nl> - <nl> + <nl> enum class Cursor : CursorIndex { <nl> TypeAttributes , <nl> LeftParen , <nl> class FunctionTypeSyntax final : public TypeSyntax { <nl> ReturnType <nl> } ; <nl> <nl> - FunctionTypeSyntax ( RC < SyntaxData > Root , <nl> - const FunctionTypeSyntaxData * Data ) ; <nl> - <nl> + virtual void validate ( ) const override ; <nl> public : <nl> + static FunctionTypeSyntax makeBlank ( ) ; <nl> + FunctionTypeSyntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> + : TypeSyntax ( Root , Data ) { } <nl> <nl> / / / Return the type attributes for the function type . <nl> TypeAttributesSyntax getAttributes ( ) const ; <nl> mmm a / include / swift / Syntax / UnknownSyntax . h <nl> ppp b / include / swift / Syntax / UnknownSyntax . h <nl> <nl> namespace swift { <nl> namespace syntax { <nl> <nl> - # pragma mark unknown - syntax Data <nl> - <nl> - class UnknownSyntaxData : public SyntaxData { <nl> - friend class SyntaxData ; <nl> - friend class UnknownSyntax ; <nl> - friend struct SyntaxFactory ; <nl> - friend class LegacyASTTransformer ; <nl> - <nl> - protected : <nl> - std : : vector < RC < SyntaxData > > CachedChildren ; <nl> - <nl> - UnknownSyntaxData ( const RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - const CursorIndex IndexInParent = 0 ) ; <nl> - public : <nl> - <nl> - static RC < UnknownSyntaxData > make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent = nullptr , <nl> - CursorIndex IndexInParent = 0 ) ; <nl> - <nl> - size_t getNumChildren ( ) const { <nl> - return CachedChildren . size ( ) ; <nl> - } <nl> - <nl> - / / / Get the child at the given Index . <nl> - / / / <nl> - / / / Precondition : Index < = getNumChildren ( ) ; <nl> - Syntax getChild ( size_t Index ) const ; <nl> - <nl> - static bool classof ( const SyntaxData * SD ) { <nl> - return SD - > isUnknown ( ) ; <nl> - } <nl> - } ; <nl> - <nl> # pragma mark unknown - syntax API <nl> <nl> / / / A chunk of " unknown " syntax . <nl> class UnknownSyntax : public Syntax { <nl> friend struct SyntaxFactory ; <nl> friend class Syntax ; <nl> <nl> - using DataType = UnknownSyntaxData ; <nl> - <nl> + virtual void validate ( ) const override ; <nl> public : <nl> - UnknownSyntax ( const RC < SyntaxData > Root , const UnknownSyntaxData * Data ) ; <nl> + UnknownSyntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> + : Syntax ( Root , Data ) { } <nl> <nl> / / / Get the number of child nodes in this piece of syntax , not including <nl> / / / tokens . <nl> mmm a / lib / Sema / Semantics . cpp <nl> ppp b / lib / Sema / Semantics . cpp <nl> <nl> # include " swift / AST / Expr . h " <nl> # include " swift / AST / Decl . h " <nl> # include " swift / AST / Stmt . h " <nl> + # include " swift / Syntax / Syntax . h " <nl> <nl> using namespace swift ; <nl> using namespace swift : : sema ; <nl> mmm a / lib / Syntax / DeclSyntax . cpp <nl> ppp b / lib / Syntax / DeclSyntax . cpp <nl> <nl> using namespace swift ; <nl> using namespace swift : : syntax ; <nl> <nl> - # pragma mark - declaration Data <nl> - <nl> - DeclSyntaxData : : DeclSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : SyntaxData ( Raw , Parent , IndexInParent ) { <nl> - assert ( Raw - > isDecl ( ) ) ; <nl> - } <nl> - <nl> # pragma mark - declaration API <nl> <nl> - DeclSyntax : : DeclSyntax ( const RC < SyntaxData > Root , const DeclSyntaxData * Data ) <nl> - : Syntax ( Root , Data ) { } <nl> - <nl> - # pragma mark - declaration - modifier Data <nl> - <nl> - DeclModifierSyntaxData : : <nl> - DeclModifierSyntaxData ( const RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - const CursorIndex IndexInParent ) <nl> - : SyntaxData ( Raw , Parent , IndexInParent ) { <nl> - assert ( Raw - > Kind = = SyntaxKind : : DeclModifier ) ; <nl> - assert ( Raw - > Layout . size ( ) = = 4 ) ; <nl> - # ifndef NDEBUG <nl> - auto Name = <nl> - cast < TokenSyntax > ( Raw - > getChild ( DeclModifierSyntax : : Cursor : : Name ) ) ; <nl> - auto Kind = Name - > getTokenKind ( ) ; <nl> - assert ( Kind = = tok : : kw_class | | <nl> - Kind = = tok : : kw_static | | <nl> - Kind = = tok : : identifier | | <nl> - Kind = = tok : : kw_public | | <nl> - Kind = = tok : : kw_private | | <nl> - Kind = = tok : : kw_fileprivate | | <nl> - Kind = = tok : : kw_internal ) ; <nl> - # endif <nl> - syntax_assert_child_token_text ( Raw , DeclModifierSyntax : : Cursor : : LeftParen , <nl> - tok : : l_paren , " ( " ) ; <nl> - syntax_assert_child_token ( Raw , DeclModifierSyntax : : Cursor : : Argument , <nl> - tok : : identifier ) ; <nl> - syntax_assert_child_token_text ( Raw , DeclModifierSyntax : : Cursor : : RightParen , <nl> - tok : : r_paren , " ) " ) ; <nl> - } <nl> - <nl> - RC < DeclModifierSyntaxData > <nl> - DeclModifierSyntaxData : : make ( const RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - const CursorIndex IndexInParent ) { <nl> - return RC < DeclModifierSyntaxData > { <nl> - new DeclModifierSyntaxData { <nl> - Raw , Parent , IndexInParent <nl> - } <nl> - } ; <nl> + void DeclModifierSyntax : : validate ( ) const { <nl> + assert ( Data - > Raw - > isDecl ( ) ) ; <nl> } <nl> <nl> - RC < DeclModifierSyntaxData > DeclModifierSyntaxData : : makeBlank ( ) { <nl> - auto Raw = RawSyntax : : make ( SyntaxKind : : DeclModifier , <nl> - { <nl> - TokenSyntax : : missingToken ( tok : : identifier , " " ) , <nl> - TokenSyntax : : missingToken ( tok : : l_paren , " ( " ) , <nl> - TokenSyntax : : missingToken ( tok : : identifier , " " ) , <nl> - TokenSyntax : : missingToken ( tok : : r_paren , " ) " ) , <nl> - } , <nl> - SourcePresence : : Present ) ; <nl> - return make ( Raw ) ; <nl> + DeclModifierSyntax DeclModifierSyntax : : makeBlank ( ) { <nl> + return make < DeclModifierSyntax > ( <nl> + RawSyntax : : make ( SyntaxKind : : DeclModifier , <nl> + { <nl> + TokenSyntax : : missingToken ( tok : : identifier , " " ) , <nl> + TokenSyntax : : missingToken ( tok : : l_paren , " ( " ) , <nl> + TokenSyntax : : missingToken ( tok : : identifier , " " ) , <nl> + TokenSyntax : : missingToken ( tok : : r_paren , " ) " ) , <nl> + } , <nl> + SourcePresence : : Present ) ) ; <nl> } <nl> <nl> # pragma mark - declaration - modifier API <nl> DeclModifierSyntax : : withRightParenToken ( RC < TokenSyntax > NewRightParen ) const { <nl> Cursor : : RightParen ) ; <nl> } <nl> <nl> - # pragma mark - unknown - statement Data <nl> - <nl> - UnknownDeclSyntaxData : : UnknownDeclSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : UnknownSyntaxData ( Raw , Parent , IndexInParent ) { <nl> - assert ( Raw - > Kind = = SyntaxKind : : UnknownDecl ) ; <nl> - } <nl> - <nl> - RC < UnknownDeclSyntaxData > <nl> - UnknownDeclSyntaxData : : make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - auto UnknownRaw = RawSyntax : : make ( SyntaxKind : : UnknownDecl , Raw - > Layout , <nl> - Raw - > Presence ) ; <nl> - return RC < UnknownDeclSyntaxData > { <nl> - new UnknownDeclSyntaxData { <nl> - Raw , Parent , IndexInParent <nl> - } <nl> - } ; <nl> - } <nl> - <nl> # pragma mark - unknown - statement API <nl> <nl> - UnknownDeclSyntax : : UnknownDeclSyntax ( const RC < SyntaxData > Root , <nl> - const UnknownDeclSyntaxData * Data ) <nl> - : UnknownSyntax ( Root , Data ) { } <nl> - <nl> - # pragma mark - declaration - members Data <nl> - <nl> - DeclMembersSyntaxData : : DeclMembersSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : SyntaxData ( Raw , Parent , IndexInParent ) { <nl> - assert ( Raw - > Kind = = SyntaxKind : : DeclMembers ) ; <nl> - } <nl> - <nl> - RC < DeclMembersSyntaxData > <nl> - DeclMembersSyntaxData : : make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - return RC < DeclMembersSyntaxData > { <nl> - new DeclMembersSyntaxData { <nl> - Raw , Parent , IndexInParent <nl> - } <nl> - } ; <nl> - } <nl> - <nl> - RC < DeclMembersSyntaxData > DeclMembersSyntaxData : : makeBlank ( ) { <nl> - return make ( RawSyntax : : make ( SyntaxKind : : DeclMembers , { } , <nl> - SourcePresence : : Present ) ) ; <nl> + void UnknownDeclSyntax : : validate ( ) const { <nl> + assert ( Data - > Raw - > Kind = = SyntaxKind : : UnknownDecl ) ; <nl> } <nl> <nl> # pragma mark - declaration - members API <nl> <nl> - DeclMembersSyntax : : DeclMembersSyntax ( const RC < SyntaxData > Root , <nl> - const DeclMembersSyntaxData * Data ) <nl> - : Syntax ( Root , Data ) { } <nl> + DeclMembersSyntax DeclMembersSyntax : : makeBlank ( ) { <nl> + return make < DeclMembersSyntax > ( RawSyntax : : make ( SyntaxKind : : DeclMembers , { } , <nl> + SourcePresence : : Present ) ) ; <nl> + } <nl> <nl> # pragma mark - declaration - members Builder <nl> <nl> DeclMembersSyntaxBuilder : : addMember ( DeclSyntax Member ) { <nl> DeclMembersSyntax DeclMembersSyntaxBuilder : : build ( ) const { <nl> auto Raw = RawSyntax : : make ( SyntaxKind : : DeclMembers , MembersLayout , <nl> SourcePresence : : Present ) ; <nl> - auto Data = DeclMembersSyntaxData : : make ( Raw ) ; <nl> + auto Data = SyntaxData : : make ( Raw ) ; <nl> return DeclMembersSyntax { Data , Data . get ( ) } ; <nl> } <nl> <nl> # pragma mark - struct - declaration Data <nl> <nl> - StructDeclSyntaxData : : StructDeclSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : DeclSyntaxData ( Raw , Parent , IndexInParent ) { <nl> - assert ( Raw - > Kind = = SyntaxKind : : StructDecl ) ; <nl> - syntax_assert_child_token_text ( Raw , StructDeclSyntax : : Cursor : : StructKeyword , <nl> + void StructDeclSyntax : : validate ( ) const { <nl> + assert ( Data - > Raw - > Kind = = SyntaxKind : : StructDecl ) ; <nl> + syntax_assert_child_token_text ( Data - > Raw , <nl> + StructDeclSyntax : : Cursor : : StructKeyword , <nl> tok : : kw_struct , " struct " ) ; <nl> - syntax_assert_child_token ( Raw , StructDeclSyntax : : Cursor : : Identifier , <nl> + syntax_assert_child_token ( Data - > Raw , StructDeclSyntax : : Cursor : : Identifier , <nl> tok : : identifier ) ; <nl> - syntax_assert_child_kind ( Raw , <nl> + syntax_assert_child_kind ( Data - > Raw , <nl> StructDeclSyntax : : Cursor : : GenericParameterClause , <nl> SyntaxKind : : GenericParameterClause ) ; <nl> - syntax_assert_child_kind ( Raw , StructDeclSyntax : : Cursor : : GenericWhereClause , <nl> + syntax_assert_child_kind ( Data - > Raw , <nl> + StructDeclSyntax : : Cursor : : GenericWhereClause , <nl> SyntaxKind : : GenericWhereClause ) ; <nl> - syntax_assert_child_token_text ( Raw , StructDeclSyntax : : Cursor : : LeftBrace , <nl> + syntax_assert_child_token_text ( Data - > Raw , StructDeclSyntax : : Cursor : : LeftBrace , <nl> tok : : l_brace , " { " ) ; <nl> - syntax_assert_child_kind ( Raw , StructDeclSyntax : : Cursor : : Members , <nl> + syntax_assert_child_kind ( Data - > Raw , StructDeclSyntax : : Cursor : : Members , <nl> SyntaxKind : : DeclMembers ) ; <nl> - syntax_assert_child_token_text ( Raw , StructDeclSyntax : : Cursor : : RightBrace , <nl> + syntax_assert_child_token_text ( Data - > Raw , <nl> + StructDeclSyntax : : Cursor : : RightBrace , <nl> tok : : r_brace , " } " ) ; <nl> } <nl> <nl> - RC < StructDeclSyntaxData > StructDeclSyntaxData : : make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - return RC < StructDeclSyntaxData > { <nl> - new StructDeclSyntaxData { Raw , Parent , IndexInParent } <nl> - } ; <nl> - } <nl> - <nl> - RC < StructDeclSyntaxData > StructDeclSyntaxData : : makeBlank ( ) { <nl> - return make ( RawSyntax : : make ( SyntaxKind : : StructDecl , <nl> + StructDeclSyntax StructDeclSyntax : : makeBlank ( ) { <nl> + return make < StructDeclSyntax > ( RawSyntax : : make ( SyntaxKind : : StructDecl , <nl> { <nl> TokenSyntax : : missingToken ( tok : : kw_struct , " struct " ) , <nl> TokenSyntax : : missingToken ( tok : : identifier , " " ) , <nl> RC < StructDeclSyntaxData > StructDeclSyntaxData : : makeBlank ( ) { <nl> <nl> # pragma mark - struct - declaration API <nl> <nl> - StructDeclSyntax : : StructDeclSyntax ( const RC < SyntaxData > Root , <nl> - const StructDeclSyntaxData * Data ) <nl> - : DeclSyntax ( Root , Data ) { } <nl> - <nl> RC < TokenSyntax > StructDeclSyntax : : getStructKeyword ( ) const { <nl> return cast < TokenSyntax > ( getRaw ( ) - > getChild ( Cursor : : StructKeyword ) ) ; <nl> } <nl> StructDeclSyntax : : withMembers ( DeclMembersSyntax NewMembers ) const { <nl> } <nl> <nl> DeclMembersSyntax StructDeclSyntax : : getMembers ( ) const { <nl> - auto Raw = getRaw ( ) - > getChild ( Cursor : : Members ) ; <nl> - auto MembersData = DeclMembersSyntaxData : : make ( Raw , <nl> - Data , <nl> - cursorIndex ( Cursor : : Members ) ) ; <nl> - const_cast < StructDeclSyntaxData * > ( getData ( ) ) - > CachedMembers = MembersData ; <nl> - return DeclMembersSyntax { Root , MembersData . get ( ) } ; <nl> + return DeclMembersSyntax { Root , Data - > getChild ( Cursor : : Members ) . get ( ) } ; <nl> } <nl> <nl> # pragma mark - struct - declaration Builder <nl> StructDeclSyntaxBuilder : : useRightBrace ( RC < TokenSyntax > RightBrace ) { <nl> StructDeclSyntax StructDeclSyntaxBuilder : : build ( ) const { <nl> auto Raw = RawSyntax : : make ( SyntaxKind : : StructDecl , StructLayout , <nl> SourcePresence : : Present ) ; <nl> - auto Data = StructDeclSyntaxData : : make ( Raw ) ; <nl> + auto Data = SyntaxData : : make ( Raw ) ; <nl> return StructDeclSyntax { Data , Data . get ( ) } ; <nl> } <nl> <nl> - # pragma mark - type - alias Data <nl> - <nl> - TypeAliasDeclSyntaxData : : TypeAliasDeclSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : DeclSyntaxData ( Raw , Parent , IndexInParent ) { } <nl> - <nl> - RC < TypeAliasDeclSyntaxData > <nl> - TypeAliasDeclSyntaxData : : make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - return RC < TypeAliasDeclSyntaxData > { <nl> - new TypeAliasDeclSyntaxData { Raw , Parent , IndexInParent } <nl> - } ; <nl> - } <nl> - <nl> - RC < TypeAliasDeclSyntaxData > <nl> - TypeAliasDeclSyntaxData : : makeBlank ( ) { <nl> - return make ( RawSyntax : : make ( SyntaxKind : : TypeAliasDecl , <nl> + TypeAliasDeclSyntax <nl> + TypeAliasDeclSyntax : : makeBlank ( ) { <nl> + return make < TypeAliasDeclSyntax > ( RawSyntax : : make ( SyntaxKind : : TypeAliasDecl , <nl> { <nl> TokenSyntax : : missingToken ( tok : : kw_typealias , " typealias " ) , <nl> TokenSyntax : : missingToken ( tok : : identifier , " " ) , <nl> TypeAliasDeclSyntaxData : : makeBlank ( ) { <nl> <nl> # pragma mark - type - alias API <nl> <nl> - TypeAliasDeclSyntax : : TypeAliasDeclSyntax ( RC < SyntaxData > Root , <nl> - const TypeAliasDeclSyntaxData * Data ) <nl> - : DeclSyntax ( Root , Data ) { } <nl> - <nl> TypeAliasDeclSyntax TypeAliasDeclSyntax : : <nl> withTypeAliasKeyword ( RC < TokenSyntax > NewTypeAliasKeyword ) const { <nl> syntax_assert_token_is ( NewTypeAliasKeyword , tok : : kw_typealias , " typealias " ) ; <nl> TypeAliasDeclSyntaxBuilder : : useType ( TypeSyntax ReferentType ) { <nl> TypeAliasDeclSyntax TypeAliasDeclSyntaxBuilder : : build ( ) const { <nl> auto Raw = RawSyntax : : make ( SyntaxKind : : TypeAliasDecl , TypeAliasLayout , <nl> SourcePresence : : Present ) ; <nl> - auto Data = TypeAliasDeclSyntaxData : : make ( Raw ) ; <nl> + auto Data = SyntaxData : : make ( Raw ) ; <nl> return { Data , Data . get ( ) } ; <nl> } <nl> <nl> # pragma mark - function - parameter Data <nl> <nl> - FunctionParameterSyntaxData : : FunctionParameterSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : SyntaxData ( Raw , Parent , IndexInParent ) { <nl> + void FunctionParameterSyntax : : validate ( ) const { <nl> + auto Raw = Data - > Raw ; <nl> assert ( Raw - > Layout . size ( ) = = 8 ) ; <nl> - syntax_assert_child_token ( Raw , FunctionParameterSyntax : : Cursor : : ExternalName , <nl> + syntax_assert_child_token ( Raw , Cursor : : ExternalName , <nl> tok : : identifier ) ; <nl> - syntax_assert_child_token ( Raw , FunctionParameterSyntax : : Cursor : : LocalName , <nl> + syntax_assert_child_token ( Raw , Cursor : : LocalName , <nl> tok : : identifier ) ; <nl> - syntax_assert_child_token_text ( Raw , FunctionParameterSyntax : : Cursor : : Colon , <nl> - tok : : colon , " : " ) ; <nl> - assert ( Raw - > getChild ( FunctionParameterSyntax : : Cursor : : Type ) - > isType ( ) ) ; <nl> - syntax_assert_child_token_text ( Raw , FunctionParameterSyntax : : Cursor : : Ellipsis , <nl> - tok : : identifier , " . . . " ) ; <nl> - syntax_assert_child_token_text ( Raw , <nl> - FunctionParameterSyntax : : Cursor : : DefaultEqual , <nl> - tok : : equal , " = " ) ; <nl> - assert ( Raw - > getChild ( <nl> - FunctionParameterSyntax : : Cursor : : DefaultExpression ) - > isExpr ( ) ) ; <nl> - syntax_assert_child_token_text ( Raw , <nl> - FunctionParameterSyntax : : Cursor : : TrailingComma , <nl> - tok : : comma , " , " ) ; <nl> + syntax_assert_child_token_text ( Raw , Cursor : : Colon , tok : : colon , " : " ) ; <nl> + assert ( Raw - > getChild ( Cursor : : Type ) - > isType ( ) ) ; <nl> + syntax_assert_child_token_text ( Raw , Cursor : : Ellipsis , tok : : identifier , " . . . " ) ; <nl> + syntax_assert_child_token_text ( Raw , Cursor : : DefaultEqual , tok : : equal , " = " ) ; <nl> + assert ( Raw - > getChild ( Cursor : : DefaultExpression ) - > isExpr ( ) ) ; <nl> + syntax_assert_child_token_text ( Raw , Cursor : : TrailingComma , tok : : comma , " , " ) ; <nl> } <nl> <nl> - RC < FunctionParameterSyntaxData > <nl> - FunctionParameterSyntaxData : : make ( RC < RawSyntax > Raw , const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - return RC < FunctionParameterSyntaxData > { <nl> - new FunctionParameterSyntaxData { <nl> - Raw , Parent , IndexInParent <nl> - } <nl> - } ; <nl> - } <nl> - <nl> - RC < FunctionParameterSyntaxData > FunctionParameterSyntaxData : : makeBlank ( ) { <nl> + FunctionParameterSyntax FunctionParameterSyntax : : makeBlank ( ) { <nl> auto Raw = RawSyntax : : make ( SyntaxKind : : FunctionParameter , <nl> { <nl> TokenSyntax : : missingToken ( tok : : identifier , " " ) , <nl> RC < FunctionParameterSyntaxData > FunctionParameterSyntaxData : : makeBlank ( ) { <nl> TokenSyntax : : missingToken ( tok : : comma , " , " ) , <nl> } , <nl> SourcePresence : : Present ) ; <nl> - return make ( Raw ) ; <nl> + return make < FunctionParameterSyntax > ( Raw ) ; <nl> } <nl> <nl> <nl> llvm : : Optional < TypeSyntax > FunctionParameterSyntax : : getTypeSyntax ( ) const { <nl> return llvm : : None ; <nl> } <nl> <nl> - auto * MyData = getUnsafeData < FunctionParameterSyntax > ( ) ; <nl> - <nl> - if ( MyData - > CachedTypeSyntax ) { <nl> - return TypeSyntax { Root , MyData - > CachedTypeSyntax . get ( ) } ; <nl> - } <nl> - <nl> - auto & ChildPtr = * reinterpret_cast < std : : atomic < uintptr_t > * > ( <nl> - & MyData - > CachedTypeSyntax ) ; <nl> - <nl> - SyntaxData : : realizeSyntaxNode < TypeSyntax > ( ChildPtr , RawType , MyData , <nl> - cursorIndex ( Cursor : : Type ) ) ; <nl> - <nl> - return TypeSyntax { Root , MyData - > CachedTypeSyntax . get ( ) } ; <nl> + return TypeSyntax { Root , Data - > getChild ( Cursor : : Type ) . get ( ) } ; <nl> } <nl> <nl> FunctionParameterSyntax FunctionParameterSyntax : : <nl> withEqualToken ( RC < TokenSyntax > NewEqualToken ) const { <nl> } <nl> <nl> llvm : : Optional < ExprSyntax > FunctionParameterSyntax : : getDefaultValue ( ) const { <nl> - auto RawExpr = getRaw ( ) - > getChild ( Cursor : : DefaultExpression ) ; <nl> - if ( RawExpr - > isMissing ( ) ) { <nl> - return llvm : : None ; <nl> - } <nl> - <nl> - auto * MyData = getUnsafeData < FunctionParameterSyntax > ( ) ; <nl> - <nl> - if ( MyData - > CachedTypeSyntax ) { <nl> - return ExprSyntax { Root , MyData - > CachedDefaultValue . get ( ) } ; <nl> - } <nl> - <nl> - auto & ChildPtr = * reinterpret_cast < std : : atomic < uintptr_t > * > ( <nl> - & MyData - > CachedDefaultValue ) ; <nl> + auto RawExpr = getRaw ( ) - > getChild ( Cursor : : DefaultExpression ) ; <nl> + if ( RawExpr - > isMissing ( ) ) { <nl> + return llvm : : None ; <nl> + } <nl> <nl> - SyntaxData : : realizeSyntaxNode < TypeSyntax > ( ChildPtr , RawExpr , MyData , <nl> - cursorIndex ( Cursor : : DefaultExpression ) ) ; <nl> - <nl> - return ExprSyntax { Root , MyData - > CachedDefaultValue . get ( ) } ; <nl> + return ExprSyntax { Root , Data - > getChild ( Cursor : : DefaultExpression ) . get ( ) } ; <nl> } <nl> <nl> FunctionParameterSyntax FunctionParameterSyntax : : <nl> withTrailingComma ( RC < TokenSyntax > NewTrailingComma ) const { <nl> <nl> # pragma mark - function - signature Data <nl> <nl> - FunctionSignatureSyntaxData : : <nl> - FunctionSignatureSyntaxData ( const RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - const CursorIndex IndexInParent ) <nl> - : SyntaxData ( Raw , Parent , IndexInParent ) { <nl> + void FunctionSignatureSyntax : : validate ( ) const { <nl> + auto Raw = Data - > Raw ; <nl> assert ( Raw - > Layout . size ( ) = = 7 ) ; <nl> syntax_assert_child_token_text ( Raw , <nl> - FunctionSignatureSyntax : : Cursor : : LeftParen , <nl> + Cursor : : LeftParen , <nl> tok : : l_paren , " ( " ) ; <nl> <nl> - assert ( Raw - > getChild ( FunctionSignatureSyntax : : Cursor : : ParameterList ) - > Kind = = <nl> + assert ( Raw - > getChild ( Cursor : : ParameterList ) - > Kind = = <nl> SyntaxKind : : FunctionParameterList ) ; <nl> <nl> syntax_assert_child_token_text ( Raw , <nl> - FunctionSignatureSyntax : : Cursor : : RightParen , <nl> + Cursor : : RightParen , <nl> tok : : r_paren , " ) " ) ; <nl> # ifndef NDEBUG <nl> auto ThrowsRethrows = cast < TokenSyntax > ( <nl> - Raw - > getChild ( FunctionSignatureSyntax : : Cursor : : ThrowsOrRethrows ) ) ; <nl> + Raw - > getChild ( Cursor : : ThrowsOrRethrows ) ) ; <nl> assert ( cast < TokenSyntax > ( ThrowsRethrows ) - > getTokenKind ( ) = = tok : : kw_throws | | <nl> cast < TokenSyntax > ( ThrowsRethrows ) - > getTokenKind ( ) = = tok : : kw_rethrows ) ; <nl> # endif <nl> - syntax_assert_child_token_text ( Raw , FunctionSignatureSyntax : : Cursor : : Arrow , <nl> + syntax_assert_child_token_text ( Raw , Cursor : : Arrow , <nl> tok : : arrow , " - > " ) ; <nl> syntax_assert_child_kind ( Raw , <nl> - FunctionSignatureSyntax : : Cursor : : ReturnTypeAttributes , <nl> - SyntaxKind : : TypeAttributes ) ; <nl> - assert ( Raw - > getChild ( FunctionSignatureSyntax : : Cursor : : ReturnType ) - > isType ( ) ) ; <nl> - } <nl> - <nl> - RC < FunctionSignatureSyntaxData > <nl> - FunctionSignatureSyntaxData : : make ( RC < RawSyntax > Raw , const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - return RC < FunctionSignatureSyntaxData > { <nl> - new FunctionSignatureSyntaxData { <nl> - Raw , Parent , IndexInParent <nl> - } <nl> - } ; <nl> + Cursor : : ReturnTypeAttributes , <nl> + SyntaxKind : : TypeAttributes ) ; <nl> + assert ( Raw - > getChild ( Cursor : : ReturnType ) - > isType ( ) ) ; <nl> } <nl> <nl> - RC < FunctionSignatureSyntaxData > FunctionSignatureSyntaxData : : makeBlank ( ) { <nl> + FunctionSignatureSyntax FunctionSignatureSyntax : : makeBlank ( ) { <nl> auto Raw = RawSyntax : : make ( SyntaxKind : : FunctionSignature , <nl> { <nl> TokenSyntax : : missingToken ( tok : : l_paren , " ( " ) , <nl> RC < FunctionSignatureSyntaxData > FunctionSignatureSyntaxData : : makeBlank ( ) { <nl> RawSyntax : : missing ( SyntaxKind : : MissingType ) , <nl> } , <nl> SourcePresence : : Present ) ; <nl> - return make ( Raw ) ; <nl> + return make < FunctionSignatureSyntax > ( Raw ) ; <nl> } <nl> <nl> # pragma mark - function - signature API <nl> withLeftParenToken ( RC < TokenSyntax > NewLeftParen ) const { <nl> } <nl> <nl> FunctionParameterListSyntax FunctionSignatureSyntax : : getParameterList ( ) const { <nl> - auto RawList = getRaw ( ) - > getChild ( Cursor : : ParameterList ) ; <nl> - <nl> - auto * MyData = getUnsafeData < FunctionSignatureSyntax > ( ) ; <nl> - <nl> - auto & ChildPtr = * reinterpret_cast < std : : atomic < uintptr_t > * > ( <nl> - & MyData - > CachedParameterList ) ; <nl> - <nl> - SyntaxData : : realizeSyntaxNode < FunctionParameterListSyntax > ( ChildPtr , RawList , <nl> - MyData , cursorIndex ( Cursor : : ParameterList ) ) ; <nl> - <nl> return FunctionParameterListSyntax { <nl> Root , <nl> - MyData - > CachedParameterList . get ( ) <nl> + Data - > getChild ( Cursor : : ParameterList ) . get ( ) <nl> } ; <nl> } <nl> <nl> withArrowToken ( RC < TokenSyntax > NewArrowToken ) const { <nl> } <nl> <nl> TypeAttributesSyntax FunctionSignatureSyntax : : getReturnTypeAttributes ( ) const { <nl> - auto RawAttrs = getRaw ( ) - > getChild ( Cursor : : ReturnTypeAttributes ) ; <nl> - <nl> - auto * MyData = getUnsafeData < FunctionSignatureSyntax > ( ) ; <nl> - <nl> - auto & ChildPtr = * reinterpret_cast < std : : atomic < uintptr_t > * > ( <nl> - & MyData - > CachedReturnTypeAttributes ) ; <nl> - <nl> - SyntaxData : : realizeSyntaxNode < TypeAttributesSyntax > ( ChildPtr , RawAttrs , <nl> - MyData , cursorIndex ( Cursor : : ReturnTypeAttributes ) ) ; <nl> - <nl> return TypeAttributesSyntax { <nl> Root , <nl> - MyData - > CachedReturnTypeAttributes . get ( ) <nl> + Data - > getChild ( Cursor : : ReturnTypeAttributes ) . get ( ) <nl> } ; <nl> } <nl> <nl> withReturnTypeAttributes ( TypeAttributesSyntax NewAttributes ) const { <nl> } <nl> <nl> TypeSyntax FunctionSignatureSyntax : : getReturnTypeSyntax ( ) const { <nl> - auto RawType = getRaw ( ) - > getChild ( Cursor : : ReturnType ) ; <nl> - <nl> - auto * MyData = getUnsafeData < FunctionSignatureSyntax > ( ) ; <nl> - <nl> - auto & ChildPtr = * reinterpret_cast < std : : atomic < uintptr_t > * > ( <nl> - & MyData - > CachedReturnTypeSyntax ) ; <nl> - <nl> - SyntaxData : : realizeSyntaxNode < TypeSyntax > ( ChildPtr , RawType , <nl> - MyData , cursorIndex ( Cursor : : ReturnType ) ) ; <nl> - <nl> return TypeSyntax { <nl> Root , <nl> - MyData - > CachedReturnTypeSyntax . get ( ) <nl> + Data - > getChild ( Cursor : : ReturnType ) . get ( ) <nl> } ; <nl> } <nl> <nl> withReturnTypeSyntax ( TypeSyntax NewReturnTypeSyntax ) const { <nl> <nl> # pragma mark - function - declaration - data <nl> <nl> - FunctionDeclSyntaxData : : <nl> - FunctionDeclSyntaxData ( const RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - const CursorIndex IndexInParent ) <nl> - : SyntaxData ( Raw , Parent , IndexInParent ) { <nl> + void FunctionDeclSyntax : : validate ( ) const { <nl> + auto Raw = Data - > Raw ; <nl> assert ( Raw - > Kind = = SyntaxKind : : FunctionDecl ) ; <nl> assert ( Raw - > Layout . size ( ) = = 8 ) ; <nl> syntax_assert_child_kind ( Raw , FunctionDeclSyntax : : Cursor : : Attributes , <nl> FunctionDeclSyntaxData ( const RC < RawSyntax > Raw , <nl> SyntaxKind : : CodeBlockStmt ) ; <nl> } <nl> <nl> - RC < FunctionDeclSyntaxData > FunctionDeclSyntaxData : : make ( const RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - const CursorIndex IndexInParent ) { <nl> - return RC < FunctionDeclSyntaxData > { <nl> - new FunctionDeclSyntaxData { <nl> - Raw , Parent , IndexInParent <nl> - } <nl> - } ; <nl> - } <nl> - <nl> - RC < FunctionDeclSyntaxData > FunctionDeclSyntaxData : : makeBlank ( ) { <nl> + FunctionDeclSyntax FunctionDeclSyntax : : makeBlank ( ) { <nl> auto Raw = RawSyntax : : make ( SyntaxKind : : FunctionDecl , <nl> { <nl> RawSyntax : : missing ( SyntaxKind : : TypeAttributes ) , <nl> RC < FunctionDeclSyntaxData > FunctionDeclSyntaxData : : makeBlank ( ) { <nl> RawSyntax : : missing ( SyntaxKind : : CodeBlockStmt ) , <nl> } , <nl> SourcePresence : : Present ) ; <nl> - return make ( Raw ) ; <nl> + return make < FunctionDeclSyntax > ( Raw ) ; <nl> } <nl> <nl> # pragma mark - function - declaration - API <nl> <nl> TypeAttributesSyntax FunctionDeclSyntax : : getAttributes ( ) const { <nl> - auto RawAttrs = getRaw ( ) - > getChild ( Cursor : : Attributes ) ; <nl> - <nl> - auto * MyData = getUnsafeData < FunctionDeclSyntax > ( ) ; <nl> - <nl> - auto & ChildPtr = * reinterpret_cast < std : : atomic < uintptr_t > * > ( <nl> - & MyData - > CachedAttributes ) ; <nl> - <nl> - SyntaxData : : realizeSyntaxNode < ExprSyntax > ( ChildPtr , RawAttrs , MyData , <nl> - cursorIndex ( Cursor : : Attributes ) ) ; <nl> - <nl> - return { Root , MyData - > CachedAttributes . get ( ) } ; <nl> + return { Root , Data - > getChild ( Cursor : : Attributes ) . get ( ) } ; <nl> } <nl> <nl> FunctionDeclSyntax <nl> FunctionDeclSyntax : : withAttributes ( TypeAttributesSyntax NewAttributes ) const { <nl> } <nl> <nl> DeclModifierListSyntax FunctionDeclSyntax : : getModifiers ( ) const { <nl> - auto RawModifiers = getRaw ( ) - > getChild ( Cursor : : Attributes ) ; <nl> - <nl> - auto * MyData = getUnsafeData < FunctionDeclSyntax > ( ) ; <nl> - <nl> - auto & ChildPtr = * reinterpret_cast < std : : atomic < uintptr_t > * > ( <nl> - & MyData - > CachedModifiers ) ; <nl> - <nl> - SyntaxData : : realizeSyntaxNode < DeclModifierListSyntax > ( ChildPtr , RawModifiers , <nl> - MyData , cursorIndex ( Cursor : : Modifiers ) ) ; <nl> - <nl> - return { Root , MyData - > CachedModifiers . get ( ) } ; <nl> + return { Root , Data - > getChild ( Cursor : : Modifiers ) . get ( ) } ; <nl> } <nl> <nl> FunctionDeclSyntax <nl> FunctionDeclSyntax : : withIdentifier ( RC < TokenSyntax > NewIdentifier ) const { <nl> <nl> llvm : : Optional < GenericParameterClauseSyntax > <nl> FunctionDeclSyntax : : getGenericParameterClause ( ) const { <nl> - auto RawGenericParams = getRaw ( ) - > getChild ( Cursor : : Attributes ) ; <nl> + auto RawGenericParams = getRaw ( ) - > getChild ( Cursor : : GenericParameterClause ) ; <nl> if ( RawGenericParams - > isMissing ( ) ) { <nl> return llvm : : None ; <nl> } <nl> - <nl> - auto * MyData = getUnsafeData < FunctionDeclSyntax > ( ) ; <nl> - <nl> - auto & ChildPtr = * reinterpret_cast < std : : atomic < uintptr_t > * > ( <nl> - & MyData - > CachedGenericParams ) ; <nl> - <nl> - SyntaxData : : realizeSyntaxNode < DeclModifierListSyntax > ( ChildPtr , <nl> - RawGenericParams , MyData , cursorIndex ( Cursor : : GenericParameterClause ) ) ; <nl> - <nl> - GenericParameterClauseSyntax Params { <nl> - Root , <nl> - MyData - > CachedGenericParams . get ( ) <nl> + return llvm : : Optional < GenericParameterClauseSyntax > { <nl> + GenericParameterClauseSyntax { <nl> + Root , <nl> + Data - > getChild ( Cursor : : GenericParameterClause ) . get ( ) <nl> + } <nl> } ; <nl> - <nl> - return Params ; <nl> } <nl> <nl> FunctionDeclSyntax FunctionDeclSyntax : : withGenericParameterClause ( <nl> FunctionDeclSyntax FunctionDeclSyntax : : withGenericParameterClause ( <nl> } <nl> <nl> FunctionSignatureSyntax FunctionDeclSyntax : : getSignature ( ) const { <nl> - auto RawSig = getRaw ( ) - > getChild ( Cursor : : Attributes ) ; <nl> - <nl> - auto * MyData = getUnsafeData < FunctionDeclSyntax > ( ) ; <nl> - <nl> - auto & ChildPtr = * reinterpret_cast < std : : atomic < uintptr_t > * > ( <nl> - & MyData - > CachedSignature ) ; <nl> - <nl> - SyntaxData : : realizeSyntaxNode < FunctionSignatureSyntax > ( ChildPtr , RawSig , <nl> - MyData , cursorIndex ( Cursor : : Signature ) ) ; <nl> - <nl> - return { Root , MyData - > CachedSignature . get ( ) } ; <nl> + return { Root , Data - > getChild ( Cursor : : Signature ) . get ( ) } ; <nl> } <nl> <nl> FunctionDeclSyntax <nl> llvm : : Optional < CodeBlockStmtSyntax > FunctionDeclSyntax : : getBody ( ) const { <nl> if ( RawBody - > isMissing ( ) ) { <nl> return llvm : : None ; <nl> } <nl> - <nl> - auto * MyData = getUnsafeData < FunctionDeclSyntax > ( ) ; <nl> - <nl> - auto & ChildPtr = * reinterpret_cast < std : : atomic < uintptr_t > * > ( <nl> - & MyData - > CachedBody ) ; <nl> - <nl> - SyntaxData : : realizeSyntaxNode < CodeBlockStmtSyntax > ( ChildPtr , <nl> - RawBody , MyData , cursorIndex ( Cursor : : Body ) ) ; <nl> <nl> - CodeBlockStmtSyntax Body { <nl> - Root , <nl> - MyData - > CachedBody . get ( ) <nl> + return llvm : : Optional < CodeBlockStmtSyntax > { <nl> + CodeBlockStmtSyntax { Root , Data - > getChild ( Cursor : : Body ) . get ( ) } <nl> } ; <nl> - <nl> - return Body ; <nl> } <nl> <nl> FunctionDeclSyntax FunctionDeclSyntax : : <nl> mmm a / lib / Syntax / ExprSyntax . cpp <nl> ppp b / lib / Syntax / ExprSyntax . cpp <nl> <nl> using namespace swift ; <nl> using namespace swift : : syntax ; <nl> <nl> - # pragma mark - expression Data <nl> - <nl> - RC < ExprSyntaxData > ExprSyntaxData : : make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - return RC < ExprSyntaxData > { <nl> - new ExprSyntaxData { <nl> - Raw , Parent , IndexInParent <nl> - } <nl> - } ; <nl> - } <nl> - <nl> - RC < ExprSyntaxData > ExprSyntaxData : : makeBlank ( ) { <nl> - return make ( RawSyntax : : missing ( SyntaxKind : : MissingExpr ) ) ; <nl> - } <nl> - <nl> # pragma mark - expression API <nl> <nl> - ExprSyntax : : ExprSyntax ( const RC < SyntaxData > Root , const ExprSyntaxData * Data ) <nl> - : Syntax ( Root , Data ) { } <nl> - <nl> - # pragma mark - unknown - expression Data <nl> - <nl> - UnknownExprSyntaxData : : UnknownExprSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : UnknownSyntaxData ( Raw , Parent , IndexInParent ) { <nl> - assert ( Raw - > Kind = = SyntaxKind : : UnknownExpr ) ; <nl> - } <nl> - <nl> - RC < UnknownExprSyntaxData > <nl> - UnknownExprSyntaxData : : make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - auto UnknownRaw = RawSyntax : : make ( SyntaxKind : : UnknownExpr , Raw - > Layout , <nl> - Raw - > Presence ) ; <nl> - return RC < UnknownExprSyntaxData > { <nl> - new UnknownExprSyntaxData { <nl> - UnknownRaw , Parent , IndexInParent <nl> - } <nl> - } ; <nl> + ExprSyntax ExprSyntax : : makeBlank ( ) { <nl> + return make < ExprSyntax > ( RawSyntax : : missing ( SyntaxKind : : MissingExpr ) ) ; <nl> } <nl> <nl> # pragma mark - unknown - expression API <nl> <nl> - UnknownExprSyntax : : UnknownExprSyntax ( const RC < SyntaxData > Root , <nl> - const UnknownExprSyntaxData * Data ) <nl> - : UnknownSyntax ( Root , Data ) { } <nl> + void UnknownExprSyntax : : validate ( ) const { <nl> + assert ( Data - > Raw - > Kind = = SyntaxKind : : UnknownExpr ) ; <nl> + } <nl> <nl> - # pragma mark - integer - literal - expression Data <nl> + # pragma mark - integer - literal - expression API <nl> <nl> - IntegerLiteralExprSyntaxData : : <nl> - IntegerLiteralExprSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : ExprSyntaxData ( Raw , Parent , IndexInParent ) { <nl> - assert ( Raw - > Kind = = SyntaxKind : : IntegerLiteralExpr ) ; <nl> - assert ( Raw - > Layout . size ( ) = = 2 ) ; <nl> - syntax_assert_child_token ( Raw , IntegerLiteralExprSyntax : : Cursor : : Sign , <nl> + void IntegerLiteralExprSyntax : : validate ( ) const { <nl> + assert ( Data - > Raw - > Kind = = SyntaxKind : : IntegerLiteralExpr ) ; <nl> + assert ( Data - > Raw - > Layout . size ( ) = = 2 ) ; <nl> + syntax_assert_child_token ( Data - > Raw , Cursor : : Sign , <nl> tok : : oper_prefix ) ; <nl> - syntax_assert_child_token ( Raw , IntegerLiteralExprSyntax : : Cursor : : Digits , <nl> + syntax_assert_child_token ( Data - > Raw , Cursor : : Digits , <nl> tok : : integer_literal ) ; <nl> } <nl> <nl> - RC < IntegerLiteralExprSyntaxData > <nl> - IntegerLiteralExprSyntaxData : : make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - return RC < IntegerLiteralExprSyntaxData > { <nl> - new IntegerLiteralExprSyntaxData { <nl> - Raw , Parent , IndexInParent <nl> - } <nl> - } ; <nl> - } <nl> - RC < IntegerLiteralExprSyntaxData > IntegerLiteralExprSyntaxData : : makeBlank ( ) { <nl> + IntegerLiteralExprSyntax IntegerLiteralExprSyntax : : makeBlank ( ) { <nl> auto Raw = RawSyntax : : make ( SyntaxKind : : IntegerLiteralExpr , <nl> { <nl> TokenSyntax : : missingToken ( tok : : oper_prefix , " " ) , <nl> TokenSyntax : : missingToken ( tok : : integer_literal , " " ) <nl> } , <nl> SourcePresence : : Present ) ; <nl> - return make ( Raw ) ; <nl> + return make < IntegerLiteralExprSyntax > ( Raw ) ; <nl> } <nl> <nl> - # pragma mark - integer - literal - expression API <nl> - <nl> - IntegerLiteralExprSyntax : : <nl> - IntegerLiteralExprSyntax ( const RC < SyntaxData > Root , <nl> - const IntegerLiteralExprSyntaxData * Data ) <nl> - : ExprSyntax ( Root , Data ) { } <nl> - <nl> IntegerLiteralExprSyntax <nl> IntegerLiteralExprSyntax : : withDigits ( RC < TokenSyntax > NewDigits ) const { <nl> assert ( NewDigits - > getTokenKind ( ) = = tok : : integer_literal ) ; <nl> IntegerLiteralExprSyntax : : withSign ( RC < swift : : syntax : : TokenSyntax > NewSign ) <nl> return Data - > replaceChild < IntegerLiteralExprSyntax > ( NewSign , Cursor : : Sign ) ; <nl> } <nl> <nl> - # pragma mark - symbolic - reference Data <nl> - <nl> - SymbolicReferenceExprSyntaxData : : <nl> - SymbolicReferenceExprSyntaxData ( RC < RawSyntax > Raw , const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : ExprSyntaxData ( Raw , Parent , IndexInParent ) { <nl> - assert ( Raw - > Layout . size ( ) = = 2 ) ; <nl> - syntax_assert_child_token ( Raw , <nl> - SymbolicReferenceExprSyntax : : Cursor : : Identifier , tok : : identifier ) ; <nl> - syntax_assert_child_kind ( Raw , <nl> - SymbolicReferenceExprSyntax : : Cursor : : GenericArgumentClause , <nl> - SyntaxKind : : GenericArgumentClause ) ; <nl> - } <nl> + # pragma mark - symbolic - reference API <nl> <nl> - RC < SymbolicReferenceExprSyntaxData > <nl> - SymbolicReferenceExprSyntaxData : : make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - return RC < SymbolicReferenceExprSyntaxData > { <nl> - new SymbolicReferenceExprSyntaxData { <nl> - Raw , Parent , IndexInParent <nl> - } <nl> - } ; <nl> + void SymbolicReferenceExprSyntax : : validate ( ) const { <nl> + assert ( Data - > Raw - > Layout . size ( ) = = 2 ) ; <nl> + syntax_assert_child_token ( Data - > Raw , Cursor : : Identifier , tok : : identifier ) ; <nl> + syntax_assert_child_kind ( Data - > Raw , Cursor : : GenericArgumentClause , <nl> + SyntaxKind : : GenericArgumentClause ) ; <nl> } <nl> <nl> - RC < SymbolicReferenceExprSyntaxData > <nl> - SymbolicReferenceExprSyntaxData : : makeBlank ( ) { <nl> + SymbolicReferenceExprSyntax SymbolicReferenceExprSyntax : : makeBlank ( ) { <nl> auto Raw = RawSyntax : : make ( SyntaxKind : : SymbolicReferenceExpr , <nl> { <nl> TokenSyntax : : missingToken ( tok : : identifier , " " ) , <nl> RawSyntax : : missing ( SyntaxKind : : GenericArgumentClause ) , <nl> } , <nl> SourcePresence : : Present ) ; <nl> - return make ( Raw ) ; <nl> + return make < SymbolicReferenceExprSyntax > ( Raw ) ; <nl> } <nl> <nl> - # pragma mark - symbolic - reference API <nl> - <nl> - SymbolicReferenceExprSyntax : : <nl> - SymbolicReferenceExprSyntax ( const RC < SyntaxData > Root , const DataType * Data ) <nl> - : ExprSyntax ( Root , Data ) { } <nl> - <nl> RC < TokenSyntax > SymbolicReferenceExprSyntax : : getIdentifier ( ) const { <nl> return cast < TokenSyntax > ( getRaw ( ) - > getChild ( Cursor : : Identifier ) ) ; <nl> } <nl> SymbolicReferenceExprSyntax : : getGenericArgumentClause ( ) const { <nl> return llvm : : None ; <nl> } <nl> <nl> - auto * MyData = getUnsafeData < SymbolicReferenceExprSyntax > ( ) ; <nl> - auto & ChildPtr = * reinterpret_cast < std : : atomic < uintptr_t > * > ( <nl> - & MyData - > CachedGenericArgClause ) ; <nl> - SyntaxData : : realizeSyntaxNode < GenericArgumentClauseSyntax > ( ChildPtr , <nl> - RawClause , MyData , <nl> - cursorIndex ( Cursor : : GenericArgumentClause ) ) ; <nl> - <nl> return llvm : : Optional < GenericArgumentClauseSyntax > { <nl> GenericArgumentClauseSyntax { <nl> Root , <nl> - MyData - > CachedGenericArgClause . get ( ) <nl> + Data - > getChild ( Cursor : : GenericArgumentClause ) . get ( ) <nl> } <nl> } ; <nl> } <nl> withGenericArgumentClause ( GenericArgumentClauseSyntax NewGenericArgs ) const { <nl> <nl> # pragma mark - function - call - argument Data <nl> <nl> - FunctionCallArgumentSyntaxData : : <nl> - FunctionCallArgumentSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : SyntaxData ( Raw , Parent , IndexInParent ) { <nl> - syntax_assert_child_token ( Raw , FunctionCallArgumentSyntax : : Cursor : : Label , <nl> - tok : : identifier ) ; <nl> - syntax_assert_child_token_text ( Raw , <nl> - FunctionCallArgumentSyntax : : Cursor : : Colon , <nl> - tok : : colon , " : " ) ; <nl> - assert ( <nl> - Raw - > getChild ( FunctionCallArgumentSyntax : : Cursor : : Expression ) - > isExpr ( ) ) ; <nl> - <nl> - syntax_assert_child_token_text ( Raw , <nl> - FunctionCallArgumentSyntax : : Cursor : : Comma , <nl> - tok : : comma , " , " ) ; <nl> - } <nl> - <nl> - RC < FunctionCallArgumentSyntaxData > <nl> - FunctionCallArgumentSyntaxData : : make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - return RC < FunctionCallArgumentSyntaxData > { <nl> - new FunctionCallArgumentSyntaxData { <nl> - Raw , Parent , IndexInParent <nl> - } <nl> - } ; <nl> + void FunctionCallArgumentSyntax : : validate ( ) const { <nl> + syntax_assert_child_token ( Data - > Raw , Cursor : : Label , <nl> + tok : : identifier ) ; <nl> + syntax_assert_child_token_text ( Data - > Raw , Cursor : : Colon , <nl> + tok : : colon , " : " ) ; <nl> + assert ( Data - > Raw - > getChild ( Cursor : : Expression ) - > isExpr ( ) ) ; <nl> + <nl> + syntax_assert_child_token_text ( Data - > Raw , <nl> + Cursor : : Comma , <nl> + tok : : comma , " , " ) ; <nl> } <nl> <nl> - RC < FunctionCallArgumentSyntaxData > FunctionCallArgumentSyntaxData : : makeBlank ( ) { <nl> + FunctionCallArgumentSyntax FunctionCallArgumentSyntax : : makeBlank ( ) { <nl> auto Raw = RawSyntax : : make ( SyntaxKind : : FunctionCallArgument , <nl> { <nl> TokenSyntax : : missingToken ( tok : : identifier , " " ) , <nl> RC < FunctionCallArgumentSyntaxData > FunctionCallArgumentSyntaxData : : makeBlank ( ) { <nl> TokenSyntax : : missingToken ( tok : : comma , " , " ) <nl> } , <nl> SourcePresence : : Present ) ; <nl> - return make ( Raw ) ; <nl> + return make < FunctionCallArgumentSyntax > ( Raw ) ; <nl> } <nl> <nl> # pragma mark - function - call - argument API <nl> <nl> - FunctionCallArgumentSyntax : : <nl> - FunctionCallArgumentSyntax ( const RC < SyntaxData > Root , const DataType * Data ) <nl> - : Syntax ( Root , Data ) { } <nl> - <nl> RC < TokenSyntax > FunctionCallArgumentSyntax : : getLabel ( ) const { <nl> return cast < TokenSyntax > ( getRaw ( ) - > getChild ( Cursor : : Label ) ) ; <nl> } <nl> llvm : : Optional < ExprSyntax > FunctionCallArgumentSyntax : : getExpression ( ) const { <nl> if ( RawExpression - > isMissing ( ) ) { <nl> return llvm : : None ; <nl> } <nl> - <nl> - auto * MyData = getUnsafeData < FunctionCallArgumentSyntax > ( ) ; <nl> - <nl> - auto & ChildPtr = * reinterpret_cast < std : : atomic < uintptr_t > * > ( <nl> - & MyData - > CachedExpression ) ; <nl> - <nl> - SyntaxData : : realizeSyntaxNode < ExprSyntax > ( ChildPtr , RawExpression , MyData , <nl> - cursorIndex ( Cursor : : Expression ) ) ; <nl> <nl> - return ExprSyntax { Root , MyData - > CachedExpression . get ( ) } ; <nl> + return llvm : : Optional < ExprSyntax > { <nl> + ExprSyntax { Root , Data - > getChild ( Cursor : : Expression ) . get ( ) } <nl> + } ; <nl> } <nl> <nl> FunctionCallArgumentSyntax <nl> withTrailingComma ( RC < TokenSyntax > NewTrailingComma ) const { <nl> FunctionCallArgumentSyntax : : Cursor : : Comma ) ; <nl> } <nl> <nl> - # pragma mark - function - call - argument - list API <nl> - <nl> - FunctionCallArgumentListSyntax : : <nl> - FunctionCallArgumentListSyntax ( const RC < SyntaxData > Root , <nl> - const DataType * Data ) <nl> - : SyntaxCollection ( Root , Data ) { } <nl> - <nl> # pragma mark - function - call - expression Data <nl> <nl> - RC < FunctionCallArgumentListSyntaxData > CachedArgumentList ; <nl> - <nl> - FunctionCallExprSyntaxData : : FunctionCallExprSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : ExprSyntaxData ( Raw , Parent , IndexInParent ) { <nl> - assert ( Raw - > Layout . size ( ) = = 4 ) ; <nl> - assert ( Raw - > getChild ( FunctionCallExprSyntax : : Cursor : : CalledExpression ) <nl> + void FunctionCallExprSyntax : : validate ( ) const { <nl> + auto Raw = Data - > Raw ; <nl> + assert ( Raw - > getChild ( Cursor : : CalledExpression ) <nl> - > isExpr ( ) ) ; <nl> - syntax_assert_child_token_text ( Raw , FunctionCallExprSyntax : : Cursor : : LeftParen , <nl> + syntax_assert_child_token_text ( Raw , Cursor : : LeftParen , <nl> tok : : l_paren , " ( " ) ; <nl> - syntax_assert_child_kind ( Raw , FunctionCallExprSyntax : : Cursor : : ArgumentList , <nl> + syntax_assert_child_kind ( Raw , Cursor : : ArgumentList , <nl> SyntaxKind : : FunctionCallArgumentList ) ; <nl> syntax_assert_child_token_text ( Raw , <nl> - FunctionCallExprSyntax : : Cursor : : RightParen , <nl> + Cursor : : RightParen , <nl> tok : : r_paren , " ) " ) ; <nl> } <nl> <nl> - RC < FunctionCallExprSyntaxData > <nl> - FunctionCallExprSyntaxData : : make ( RC < RawSyntax > Raw , const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - return RC < FunctionCallExprSyntaxData > { <nl> - new FunctionCallExprSyntaxData { <nl> - Raw , Parent , IndexInParent <nl> - } <nl> - } ; <nl> - } <nl> - <nl> - RC < FunctionCallExprSyntaxData > FunctionCallExprSyntaxData : : makeBlank ( ) { <nl> + FunctionCallExprSyntax FunctionCallExprSyntax : : makeBlank ( ) { <nl> auto Raw = RawSyntax : : make ( SyntaxKind : : FunctionCallExpr , <nl> { <nl> RawSyntax : : missing ( SyntaxKind : : MissingExpr ) , <nl> RC < FunctionCallExprSyntaxData > FunctionCallExprSyntaxData : : makeBlank ( ) { <nl> TokenSyntax : : missingToken ( tok : : r_paren , " ) " ) , <nl> } , <nl> SourcePresence : : Present ) ; <nl> - return make ( Raw ) ; <nl> + return make < FunctionCallExprSyntax > ( Raw ) ; <nl> } <nl> <nl> - <nl> # pragma mark - function - call - expression API <nl> <nl> - FunctionCallExprSyntax : : FunctionCallExprSyntax ( const RC < SyntaxData > Root , <nl> - const DataType * Data ) <nl> - : ExprSyntax ( Root , Data ) { } <nl> - <nl> ExprSyntax FunctionCallExprSyntax : : getCalledExpression ( ) const { <nl> - auto RawArg = getRaw ( ) - > getChild ( Cursor : : CalledExpression ) ; <nl> - <nl> - auto * MyData = getUnsafeData < FunctionCallExprSyntax > ( ) ; <nl> - <nl> - auto & ChildPtr = * reinterpret_cast < std : : atomic < uintptr_t > * > ( <nl> - & MyData - > CachedCalledExpression ) ; <nl> - <nl> - SyntaxData : : realizeSyntaxNode < ExprSyntax > ( <nl> - ChildPtr , RawArg , MyData , cursorIndex ( Cursor : : CalledExpression ) ) ; <nl> - <nl> - return ExprSyntax { <nl> + return { <nl> Root , <nl> - MyData - > CachedCalledExpression . get ( ) , <nl> + Data - > getChild ( Cursor : : CalledExpression ) . get ( ) , <nl> } ; <nl> } <nl> <nl> FunctionCallExprSyntax : : withLeftParen ( RC < TokenSyntax > NewLeftParen ) const { <nl> } <nl> <nl> FunctionCallArgumentListSyntax FunctionCallExprSyntax : : getArgumentList ( ) const { <nl> - auto RawArg = getRaw ( ) - > getChild ( Cursor : : ArgumentList ) ; <nl> - <nl> - auto * MyData = getUnsafeData < FunctionCallExprSyntax > ( ) ; <nl> - <nl> - auto & ChildPtr = * reinterpret_cast < std : : atomic < uintptr_t > * > ( <nl> - & MyData - > CachedArgumentList ) ; <nl> - <nl> - SyntaxData : : realizeSyntaxNode < FunctionCallArgumentListSyntax > ( <nl> - ChildPtr , RawArg , MyData , cursorIndex ( Cursor : : ArgumentList ) ) ; <nl> - <nl> return FunctionCallArgumentListSyntax { <nl> Root , <nl> - MyData - > CachedArgumentList . get ( ) , <nl> + Data - > getChild ( Cursor : : ArgumentList ) . get ( ) , <nl> } ; <nl> } <nl> <nl> FunctionCallExprSyntax : : withRightParen ( RC < TokenSyntax > NewRightParen ) const { <nl> # pragma mark - function - call - expression Builder <nl> <nl> FunctionCallExprSyntaxBuilder : : FunctionCallExprSyntaxBuilder ( ) <nl> - : CallLayout ( FunctionCallExprSyntaxData : : makeBlank ( ) - > getRaw ( ) - > Layout ) , <nl> - ListLayout ( <nl> - FunctionCallArgumentListSyntaxData : : makeBlank ( ) - > getRaw ( ) - > Layout ) { } <nl> + : CallLayout ( FunctionCallExprSyntax : : makeBlank ( ) . getRaw ( ) - > Layout ) , <nl> + ListLayout ( FunctionCallArgumentListSyntax : : makeBlank ( ) . getRaw ( ) - > Layout ) { } <nl> <nl> FunctionCallExprSyntaxBuilder & <nl> FunctionCallExprSyntaxBuilder : : useLeftParen ( RC < TokenSyntax > LeftParen ) { <nl> FunctionCallExprSyntax FunctionCallExprSyntaxBuilder : : build ( ) const { <nl> auto RawCall = RawSyntax : : make ( SyntaxKind : : FunctionCallExpr , CallLayout , <nl> SourcePresence : : Present ) <nl> - > replaceChild ( FunctionCallExprSyntax : : Cursor : : ArgumentList , RawArgs ) ; <nl> - auto Data = FunctionCallExprSyntaxData : : make ( RawCall ) ; <nl> + auto Data = SyntaxData : : make ( RawCall ) ; <nl> return { Data , Data . get ( ) } ; <nl> } <nl> mmm a / lib / Syntax / GenericSyntax . cpp <nl> ppp b / lib / Syntax / GenericSyntax . cpp <nl> using namespace swift : : syntax ; <nl> <nl> # pragma mark - conformance - requirement Data <nl> <nl> - ConformanceRequirementSyntaxData : : <nl> - ConformanceRequirementSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : GenericRequirementSyntaxData ( Raw , Parent , IndexInParent ) { <nl> + void ConformanceRequirementSyntax : : validate ( ) const { <nl> + auto Raw = Data - > Raw ; <nl> assert ( Raw - > Kind = = SyntaxKind : : ConformanceRequirement ) ; <nl> - syntax_assert_child_kind ( Raw , <nl> - ConformanceRequirementSyntax : : Cursor : : LeftTypeIdentifier , <nl> + syntax_assert_child_kind ( Raw , Cursor : : LeftTypeIdentifier , <nl> SyntaxKind : : TypeIdentifier ) ; <nl> - syntax_assert_child_token_text ( Raw , <nl> - ConformanceRequirementSyntax : : Cursor : : Colon , <nl> + syntax_assert_child_token_text ( Raw , Cursor : : Colon , <nl> tok : : colon , " : " ) ; <nl> - syntax_assert_child_kind ( Raw , <nl> - ConformanceRequirementSyntax : : Cursor : : RightTypeIdentifier , <nl> + syntax_assert_child_kind ( Raw , Cursor : : RightTypeIdentifier , <nl> SyntaxKind : : TypeIdentifier ) ; <nl> } <nl> <nl> - RC < ConformanceRequirementSyntaxData > <nl> - ConformanceRequirementSyntaxData : : make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - return RC < ConformanceRequirementSyntaxData > { <nl> - new ConformanceRequirementSyntaxData { <nl> - Raw , Parent , IndexInParent <nl> - } <nl> - } ; <nl> - } <nl> - <nl> - RC < ConformanceRequirementSyntaxData > <nl> - ConformanceRequirementSyntaxData : : makeBlank ( ) { <nl> + ConformanceRequirementSyntax <nl> + ConformanceRequirementSyntax : : makeBlank ( ) { <nl> auto Raw = RawSyntax : : make ( SyntaxKind : : ConformanceRequirement , <nl> { <nl> RawSyntax : : missing ( SyntaxKind : : TypeIdentifier ) , <nl> ConformanceRequirementSyntaxData : : makeBlank ( ) { <nl> RawSyntax : : missing ( SyntaxKind : : TypeIdentifier ) , <nl> } , <nl> SourcePresence : : Present ) ; <nl> - return make ( Raw ) ; <nl> - } <nl> - <nl> - <nl> - # pragma mark - generic - parameter Data <nl> - <nl> - GenericParameterSyntaxData : : <nl> - GenericParameterSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : SyntaxData ( Raw , Parent , IndexInParent ) { <nl> - assert ( Raw - > Kind = = SyntaxKind : : GenericParameter ) ; <nl> - } <nl> - <nl> - RC < GenericParameterSyntaxData > <nl> - GenericParameterSyntaxData : : make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - return RC < GenericParameterSyntaxData > { <nl> - new GenericParameterSyntaxData { Raw , Parent , IndexInParent } <nl> - } ; <nl> - } <nl> - <nl> - RC < GenericParameterSyntaxData > GenericParameterSyntaxData : : makeBlank ( ) { <nl> - return make ( RawSyntax : : make ( SyntaxKind : : GenericParameter , <nl> - { <nl> - TokenSyntax : : missingToken ( tok : : identifier , " " ) , <nl> - TokenSyntax : : missingToken ( tok : : colon , " : " ) , <nl> - RawSyntax : : missing ( SyntaxKind : : MissingType ) , <nl> - } , <nl> - SourcePresence : : Present ) ) ; <nl> + return make < ConformanceRequirementSyntax > ( Raw ) ; <nl> } <nl> <nl> # pragma mark - generic - parameter API <nl> <nl> - GenericParameterSyntax : : <nl> - GenericParameterSyntax ( RC < SyntaxData > Root , <nl> - const GenericParameterSyntaxData * Data ) <nl> - : Syntax ( Root , Data ) { } <nl> - <nl> - # pragma mark - generic - parameter - list Data <nl> - <nl> - GenericParameterListSyntaxData : : <nl> - GenericParameterListSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : SyntaxData ( Raw , Parent , IndexInParent ) { <nl> - assert ( Raw - > Kind = = SyntaxKind : : GenericParameterList ) ; <nl> + void GenericParameterSyntax : : validate ( ) const { <nl> + assert ( Data - > Raw - > Kind = = SyntaxKind : : GenericParameter ) ; <nl> } <nl> <nl> - RC < GenericParameterListSyntaxData > <nl> - GenericParameterListSyntaxData : : make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - return RC < GenericParameterListSyntaxData > { <nl> - new GenericParameterListSyntaxData { <nl> - Raw , Parent , IndexInParent <nl> - } <nl> - } ; <nl> - } <nl> - <nl> - RC < GenericParameterListSyntaxData > GenericParameterListSyntaxData : : makeBlank ( ) { <nl> - auto Raw = RawSyntax : : make ( SyntaxKind : : GenericParameterList , <nl> - { } , SourcePresence : : Present ) ; <nl> - return make ( Raw ) ; <nl> + GenericParameterSyntax GenericParameterSyntax : : makeBlank ( ) { <nl> + auto Raw = RawSyntax : : make ( SyntaxKind : : GenericParameter , <nl> + { <nl> + TokenSyntax : : missingToken ( tok : : identifier , " " ) , <nl> + TokenSyntax : : missingToken ( tok : : colon , " : " ) , <nl> + RawSyntax : : missing ( SyntaxKind : : MissingType ) , <nl> + } , <nl> + SourcePresence : : Present ) ; <nl> + return make < GenericParameterSyntax > ( Raw ) ; <nl> } <nl> <nl> # pragma mark - <nl> - # pragma mark generic - parameter - clause Data <nl> + # pragma mark - generic - parameter - clause API <nl> <nl> - GenericParameterClauseSyntaxData : : <nl> - GenericParameterClauseSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : SyntaxData ( Raw , Parent , IndexInParent ) { <nl> - syntax_assert_child_token_text ( Raw , <nl> - GenericParameterClauseSyntax : : Cursor : : LeftAngleBracketToken , <nl> + void GenericParameterClauseSyntax : : validate ( ) const { <nl> + auto Raw = Data - > Raw ; <nl> + syntax_assert_child_token_text ( Raw , Cursor : : LeftAngleBracketToken , <nl> tok : : l_angle , " < " ) ; <nl> <nl> - syntax_assert_child_kind ( Raw , <nl> - GenericParameterClauseSyntax : : Cursor : : GenericParameterList , <nl> + syntax_assert_child_kind ( Raw , Cursor : : GenericParameterList , <nl> SyntaxKind : : GenericParameterList ) ; <nl> <nl> - syntax_assert_child_token_text ( Raw , <nl> - GenericParameterClauseSyntax : : Cursor : : RightAngleBracketToken , <nl> + syntax_assert_child_token_text ( Raw , Cursor : : RightAngleBracketToken , <nl> tok : : r_angle , " > " ) ; <nl> } <nl> <nl> - RC < GenericParameterClauseSyntaxData > <nl> - GenericParameterClauseSyntaxData : : make ( const RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - const CursorIndex IndexInParent ) { <nl> - return RC < GenericParameterClauseSyntaxData > { <nl> - new GenericParameterClauseSyntaxData { <nl> - Raw , Parent , IndexInParent , <nl> - } <nl> - } ; <nl> - } <nl> - <nl> - RC < GenericParameterClauseSyntaxData > <nl> - GenericParameterClauseSyntaxData : : makeBlank ( ) { <nl> - return make ( RawSyntax : : make ( SyntaxKind : : GenericParameterClause , <nl> - { <nl> - TokenSyntax : : missingToken ( tok : : l_angle , " < " ) , <nl> - RawSyntax : : missing ( SyntaxKind : : GenericParameterList ) , <nl> - TokenSyntax : : missingToken ( tok : : r_angle , " > " ) , <nl> - } , <nl> - SourcePresence : : Present ) ) ; <nl> + GenericParameterClauseSyntax <nl> + GenericParameterClauseSyntax : : makeBlank ( ) { <nl> + auto Raw = RawSyntax : : make ( <nl> + SyntaxKind : : GenericParameterClause , <nl> + { <nl> + TokenSyntax : : missingToken ( tok : : l_angle , " < " ) , <nl> + RawSyntax : : missing ( SyntaxKind : : GenericParameterList ) , <nl> + TokenSyntax : : missingToken ( tok : : r_angle , " > " ) , <nl> + } , <nl> + SourcePresence : : Present ) ; <nl> + return make < GenericParameterClauseSyntax > ( Raw ) ; <nl> } <nl> <nl> - # pragma mark - generic - parameter - clause API <nl> - <nl> - GenericParameterClauseSyntax : : <nl> - GenericParameterClauseSyntax ( const RC < SyntaxData > Root , <nl> - const GenericParameterClauseSyntaxData * Data ) <nl> - : Syntax ( Root , Data ) { } <nl> - <nl> # pragma mark - generic - parameter - clause Builder <nl> <nl> GenericParameterClauseBuilder : : GenericParameterClauseBuilder ( ) <nl> GenericParameterClauseSyntax GenericParameterClauseBuilder : : build ( ) const { <nl> RightAngleToken , <nl> } , <nl> SourcePresence : : Present ) ; <nl> - auto Data = GenericParameterClauseSyntaxData : : make ( Raw ) ; <nl> + auto Data = SyntaxData : : make ( Raw ) ; <nl> return { Data , Data . get ( ) } ; <nl> } <nl> <nl> - # pragma mark - generic - where - clause Data <nl> + # pragma mark - generic - where - clause API <nl> <nl> - GenericWhereClauseSyntaxData : : <nl> - GenericWhereClauseSyntaxData ( const RC < RawSyntax > Raw , const SyntaxData * Parent , <nl> - const CursorIndex IndexInParent ) <nl> - : SyntaxData ( Raw , Parent , IndexInParent ) { <nl> + void GenericWhereClauseSyntax : : validate ( ) const { <nl> + auto Raw = Data - > Raw ; <nl> assert ( Raw - > Kind = = SyntaxKind : : GenericWhereClause ) ; <nl> syntax_assert_child_token_text ( Raw , <nl> GenericWhereClauseSyntax : : Cursor : : WhereKeyword , tok : : kw_where , " where " ) ; <nl> GenericWhereClauseSyntaxData ( const RC < RawSyntax > Raw , const SyntaxData * Parent , <nl> SyntaxKind : : GenericRequirementList ) ; <nl> } <nl> <nl> - RC < GenericWhereClauseSyntaxData > <nl> - GenericWhereClauseSyntaxData : : make ( const RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - const CursorIndex IndexInParent ) { <nl> - return RC < GenericWhereClauseSyntaxData > { <nl> - new GenericWhereClauseSyntaxData { Raw , Parent , IndexInParent } <nl> - } ; <nl> - } <nl> - <nl> - RC < GenericWhereClauseSyntaxData > GenericWhereClauseSyntaxData : : makeBlank ( ) { <nl> - return make ( RawSyntax : : make ( SyntaxKind : : GenericWhereClause , <nl> - { <nl> - TokenSyntax : : missingToken ( tok : : kw_where , " where " ) , <nl> - RawSyntax : : missing ( SyntaxKind : : GenericRequirementList ) , <nl> - } , <nl> - SourcePresence : : Present ) ) ; <nl> + GenericWhereClauseSyntax GenericWhereClauseSyntax : : makeBlank ( ) { <nl> + auto Raw = RawSyntax : : make ( <nl> + SyntaxKind : : GenericWhereClause , <nl> + { <nl> + TokenSyntax : : missingToken ( tok : : kw_where , " where " ) , <nl> + RawSyntax : : missing ( SyntaxKind : : GenericRequirementList ) , <nl> + } , <nl> + SourcePresence : : Present ) ; <nl> + return make < GenericWhereClauseSyntax > ( Raw ) ; <nl> } <nl> <nl> - # pragma mark - generic - where - clause API <nl> - <nl> - GenericWhereClauseSyntax : : <nl> - GenericWhereClauseSyntax ( RC < SyntaxData > Root , <nl> - const GenericWhereClauseSyntaxData * Data ) <nl> - : Syntax ( Root , Data ) { } <nl> - <nl> GenericWhereClauseSyntax GenericWhereClauseSyntax : : <nl> withWhereKeyword ( RC < TokenSyntax > NewWhereKeyword ) const { <nl> syntax_assert_token_is ( NewWhereKeyword , tok : : kw_where , " where " ) ; <nl> withRequirementList ( GenericRequirementListSyntax NewRequirements ) const { <nl> Cursor : : RequirementList ) ; <nl> } <nl> <nl> - # pragma mark - same - type - requirement Data <nl> + # pragma mark - same - type - requirement API <nl> <nl> - SameTypeRequirementSyntaxData : : <nl> - SameTypeRequirementSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : GenericRequirementSyntaxData ( Raw , Parent , IndexInParent ) { <nl> + void SameTypeRequirementSyntax : : validate ( ) const { <nl> + auto Raw = Data - > Raw ; <nl> assert ( Raw - > Kind = = SyntaxKind : : SameTypeRequirement ) ; <nl> assert ( Raw - > Layout . size ( ) = = 3 ) ; <nl> - syntax_assert_child_kind ( Raw , <nl> - SameTypeRequirementSyntax : : Cursor : : LeftTypeIdentifier , <nl> + syntax_assert_child_kind ( Raw , Cursor : : LeftTypeIdentifier , <nl> SyntaxKind : : TypeIdentifier ) ; <nl> - syntax_assert_child_token_text ( Raw , <nl> - SameTypeRequirementSyntax : : Cursor : : EqualityToken , <nl> + syntax_assert_child_token_text ( Raw , Cursor : : EqualityToken , <nl> tok : : oper_binary_spaced , " = = " ) ; <nl> - assert ( Raw - > getChild ( SameTypeRequirementSyntax : : Cursor : : RightType ) - > isType ( ) ) ; <nl> - } <nl> - <nl> - RC < SameTypeRequirementSyntaxData > <nl> - SameTypeRequirementSyntaxData : : make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - return RC < SameTypeRequirementSyntaxData > { <nl> - new SameTypeRequirementSyntaxData { <nl> - Raw , Parent , IndexInParent <nl> - } <nl> - } ; <nl> - } <nl> - <nl> - RC < SameTypeRequirementSyntaxData > SameTypeRequirementSyntaxData : : makeBlank ( ) { <nl> - return make ( RawSyntax : : make ( SyntaxKind : : SameTypeRequirement , <nl> - { <nl> - RawSyntax : : missing ( SyntaxKind : : TypeIdentifier ) , <nl> - TokenSyntax : : missingToken ( tok : : equal , " = " ) , <nl> - RawSyntax : : missing ( SyntaxKind : : MissingType ) , <nl> - } , <nl> - SourcePresence : : Present ) ) ; <nl> - } <nl> - <nl> - # pragma mark - same - type - requirement API <nl> - <nl> - SameTypeRequirementSyntax : : <nl> - SameTypeRequirementSyntax ( RC < SyntaxData > Root , <nl> - const SameTypeRequirementSyntaxData * Data ) <nl> - : Syntax ( Root , Data ) { } <nl> - <nl> - # pragma mark - generic - argument - list Data <nl> - <nl> - GenericArgumentListSyntaxData : : <nl> - GenericArgumentListSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : SyntaxData ( Raw , Parent , IndexInParent ) { <nl> - assert ( Raw - > Kind = = SyntaxKind : : GenericArgumentList ) ; <nl> + assert ( Raw - > getChild ( Cursor : : RightType ) - > isType ( ) ) ; <nl> } <nl> <nl> - RC < GenericArgumentListSyntaxData > <nl> - GenericArgumentListSyntaxData : : make ( RC < RawSyntax > Raw , const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - return RC < GenericArgumentListSyntaxData > { <nl> - new GenericArgumentListSyntaxData { <nl> - Raw , Parent , IndexInParent <nl> - } <nl> - } ; <nl> - } <nl> - <nl> - RC < GenericArgumentListSyntaxData > GenericArgumentListSyntaxData : : makeBlank ( ) { <nl> - auto Raw = RawSyntax : : make ( SyntaxKind : : GenericArgumentList , { } , <nl> + SameTypeRequirementSyntax SameTypeRequirementSyntax : : makeBlank ( ) { <nl> + auto Raw = RawSyntax : : make ( SyntaxKind : : SameTypeRequirement , <nl> + { <nl> + RawSyntax : : missing ( SyntaxKind : : TypeIdentifier ) , <nl> + TokenSyntax : : missingToken ( tok : : equal , " = " ) , <nl> + RawSyntax : : missing ( SyntaxKind : : MissingType ) , <nl> + } , <nl> SourcePresence : : Present ) ; <nl> - return make ( Raw ) ; <nl> + return make < SameTypeRequirementSyntax > ( Raw ) ; <nl> } <nl> <nl> + # pragma mark - generic - argument - clause API ( TODO ) <nl> <nl> - # pragma mark - generic - argument - list API ( TODO ) <nl> - <nl> - # pragma mark - generic - argument - clause Data <nl> - <nl> - GenericArgumentClauseSyntaxData : : <nl> - GenericArgumentClauseSyntaxData ( RC < RawSyntax > Raw , const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : SyntaxData ( Raw , Parent , IndexInParent ) { } <nl> - <nl> - RC < GenericArgumentClauseSyntaxData > <nl> - GenericArgumentClauseSyntaxData : : make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - return RC < GenericArgumentClauseSyntaxData > { <nl> - new GenericArgumentClauseSyntaxData { Raw , Parent , IndexInParent } <nl> - } ; <nl> - } <nl> - <nl> - RC < GenericArgumentClauseSyntaxData > <nl> - GenericArgumentClauseSyntaxData : : makeBlank ( ) { <nl> + GenericArgumentClauseSyntax <nl> + GenericArgumentClauseSyntax : : makeBlank ( ) { <nl> auto Raw = RawSyntax : : make ( SyntaxKind : : GenericArgumentClause , <nl> { <nl> TokenSyntax : : missingToken ( tok : : l_angle , " < " ) , <nl> GenericArgumentClauseSyntaxData : : makeBlank ( ) { <nl> TokenSyntax : : missingToken ( tok : : r_angle , " > " ) , <nl> } , <nl> SourcePresence : : Present ) ; <nl> - return make ( Raw ) ; <nl> + return make < GenericArgumentClauseSyntax > ( Raw ) ; <nl> } <nl> <nl> - # pragma mark - generic - argument - clause API <nl> - <nl> - GenericArgumentClauseSyntax : : <nl> - GenericArgumentClauseSyntax ( RC < SyntaxData > Root , <nl> - const GenericArgumentClauseSyntaxData * Data ) <nl> - : Syntax ( Root , Data ) { } <nl> <nl> GenericArgumentClauseSyntax GenericArgumentClauseSyntax : : <nl> withLeftAngleBracket ( RC < TokenSyntax > NewLeftAngleBracket ) const { <nl> GenericArgumentClauseSyntax GenericArgumentClauseBuilder : : build ( ) const { <nl> RightAngleToken <nl> } , <nl> SourcePresence : : Present ) ; <nl> - auto Data = GenericArgumentClauseSyntaxData : : make ( Raw ) ; <nl> + auto Data = SyntaxData : : make ( Raw ) ; <nl> return { Data , Data . get ( ) } ; <nl> } <nl> mmm a / lib / Syntax / LegacyASTTransformer . cpp <nl> ppp b / lib / Syntax / LegacyASTTransformer . cpp <nl> RC < SyntaxData > LegacyASTTransformer : : getUnknownSyntax ( SourceRange SR ) { <nl> auto Raw = RawSyntax : : make ( SyntaxKind : : Unknown , <nl> Layout , <nl> SourcePresence : : Present ) ; <nl> - return UnknownSyntaxData : : make ( Raw ) ; <nl> + return SyntaxData : : make ( Raw ) ; <nl> } <nl> <nl> RC < SyntaxData > LegacyASTTransformer : : getUnknownDecl ( Decl * D ) { <nl> RC < SyntaxData > LegacyASTTransformer : : getUnknownDecl ( Decl * D ) { <nl> auto Raw = RawSyntax : : make ( SyntaxKind : : UnknownDecl , <nl> Layout , <nl> SourcePresence : : Present ) ; <nl> - return UnknownDeclSyntaxData : : make ( Raw ) ; <nl> + return SyntaxData : : make ( Raw ) ; <nl> } <nl> <nl> RC < SyntaxData > LegacyASTTransformer : : getUnknownStmt ( Stmt * S ) { <nl> RC < SyntaxData > LegacyASTTransformer : : getUnknownStmt ( Stmt * S ) { <nl> auto Raw = RawSyntax : : make ( SyntaxKind : : UnknownStmt , <nl> Layout , <nl> SourcePresence : : Present ) ; <nl> - return UnknownStmtSyntaxData : : make ( Raw ) ; <nl> + return SyntaxData : : make ( Raw ) ; <nl> } <nl> <nl> RC < SyntaxData > LegacyASTTransformer : : getUnknownExpr ( Expr * E ) { <nl> RC < SyntaxData > LegacyASTTransformer : : getUnknownExpr ( Expr * E ) { <nl> auto Raw = RawSyntax : : make ( SyntaxKind : : UnknownExpr , <nl> Layout , <nl> SourcePresence : : Present ) ; <nl> - return UnknownExprSyntaxData : : make ( Raw ) ; <nl> + return SyntaxData : : make ( Raw ) ; <nl> } <nl> <nl> # pragma mark - Declarations <nl> mmm a / lib / Syntax / README . md <nl> ppp b / lib / Syntax / README . md <nl> A couple of remarks about the ` EOF ` token : <nl> additional information : a pointer to a parent , the position in which the node <nl> occurs in its parent , and cached children . <nl> <nl> - For example , if we have a ` StructDeclSyntaxData ` , wrapping a ` RawSyntax ` for a <nl> + For example , if we have a ` SyntaxData ` , wrapping a ` RawSyntax ` for a <nl> struct declaration , we might ask for the generic parameter clause . At first , <nl> this is only represented in the raw syntax . On first ask , we thaw those out by <nl> - creating a new ` GenericParameterClauseSyntaxData ` , cache it as our child , set <nl> + creating a new ` SyntaxData ` , cache it as our child , set <nl> its parent to ` this ` , and send it back to the caller . These cached children <nl> are strong references , keeping the syntax tree alive in memory . <nl> <nl> Here ' s a handy checklist when implementing a production in the grammar . <nl> are affected . <nl> - * * Add the ` Syntax ` bug label ! * * <nl> - Add a * kind * to include / swift / Syntax / SyntaxKinds . def <nl> - - Create the ` $ { KIND } SyntaxData ` class . <nl> - - Cached children members as ` RC < $ { CHILDKIND } SyntaxData > ` <nl> - Create the ` $ { KIND } Syntax ` class . <nl> Be sure to implement the following : <nl> - Define the ` Cursor ` enum for the syntax node . This specifies all of the <nl> Here ' s a handy checklist when implementing a production in the grammar . <nl> ` same - type - requirement - > type - identifier ' = = ' type ` <nl> <nl> That ' s three terms in the production , and you can see this reflected in the <nl> - ` StructDeclSyntaxData ` class : <nl> + ` SameTypeRequirementSyntax ` class : <nl> <nl> ` ` ` c + + <nl> enum Cursor : CursorIndex { <nl> Here ' s a handy checklist when implementing a production in the grammar . <nl> what you changed . ` print ` the new node and check the text . <nl> - Check that the new node has a different parent . <nl> - Getters for all layout elements ( e . g . ` getLeftTypeIdentifier ( ) ` ) <nl> - - Caching mechanics in corresponding ` $ { KIND } SyntaxData ` class . <nl> - Add a C + + unit test . <nl> - After ` get ` ing the child , verify : <nl> - The child ' s parent and root are correct <nl> mmm a / lib / Syntax / StmtSyntax . cpp <nl> ppp b / lib / Syntax / StmtSyntax . cpp <nl> <nl> using namespace swift ; <nl> using namespace swift : : syntax ; <nl> <nl> - # pragma mark - statement API <nl> - <nl> - StmtSyntax : : StmtSyntax ( const RC < SyntaxData > Root , const StmtSyntaxData * Data ) <nl> - : Syntax ( Root , Data ) { } <nl> - <nl> - # pragma mark - unknown - statement Data <nl> - <nl> - UnknownStmtSyntaxData : : UnknownStmtSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : UnknownSyntaxData ( Raw , Parent , IndexInParent ) { <nl> - assert ( Raw - > Kind = = SyntaxKind : : UnknownStmt ) ; <nl> - } <nl> - <nl> - RC < UnknownStmtSyntaxData > <nl> - UnknownStmtSyntaxData : : make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - auto UnknownRaw = RawSyntax : : make ( SyntaxKind : : UnknownStmt , Raw - > Layout , <nl> - Raw - > Presence ) ; <nl> - return RC < UnknownStmtSyntaxData > { <nl> - new UnknownStmtSyntaxData { <nl> - UnknownRaw , Parent , IndexInParent <nl> - } <nl> - } ; <nl> - } <nl> - <nl> # pragma mark - unknown - statement API <nl> <nl> - UnknownStmtSyntax : : UnknownStmtSyntax ( const RC < SyntaxData > Root , <nl> - const UnknownStmtSyntaxData * Data ) <nl> - : UnknownSyntax ( Root , Data ) { } <nl> - <nl> - # pragma mark fallthrough - statement Data <nl> - <nl> - FallthroughStmtSyntaxData : : FallthroughStmtSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : StmtSyntaxData ( Raw , Parent , IndexInParent ) { <nl> - assert ( Raw - > Kind = = SyntaxKind : : FallthroughStmt ) ; <nl> - assert ( Raw - > Layout . size ( ) = = 1 ) ; <nl> - syntax_assert_child_token_text ( Raw , <nl> - FallthroughStmtSyntax : : Cursor : : FallthroughKeyword , <nl> - tok : : kw_fallthrough , " fallthrough " ) ; <nl> + void UnknownStmtSyntax : : validate ( ) const { <nl> + assert ( Data - > Raw - > Kind = = SyntaxKind : : UnknownStmt ) ; <nl> } <nl> <nl> - RC < FallthroughStmtSyntaxData > <nl> - FallthroughStmtSyntaxData : : make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - return RC < FallthroughStmtSyntaxData > { <nl> - new FallthroughStmtSyntaxData { Raw , Parent , IndexInParent } <nl> - } ; <nl> - } <nl> + # pragma mark fallthrough - statement API <nl> <nl> - RC < FallthroughStmtSyntaxData > FallthroughStmtSyntaxData : : makeBlank ( ) { <nl> - return make ( RawSyntax : : make ( SyntaxKind : : FallthroughStmt , <nl> + FallthroughStmtSyntax FallthroughStmtSyntax : : makeBlank ( ) { <nl> + return make < FallthroughStmtSyntax > ( <nl> + RawSyntax : : make ( SyntaxKind : : FallthroughStmt , <nl> { <nl> TokenSyntax : : missingToken ( tok : : kw_fallthrough , " fallthrough " ) , <nl> } , <nl> SourcePresence : : Present ) ) ; <nl> } <nl> <nl> - # pragma mark fallthrough - statement API <nl> - <nl> - FallthroughStmtSyntax : : <nl> - FallthroughStmtSyntax ( const RC < SyntaxData > Root , <nl> - const FallthroughStmtSyntaxData * Data ) <nl> - : StmtSyntax ( Root , Data ) { } <nl> - <nl> - FallthroughStmtSyntax <nl> - FallthroughStmtSyntax : : make ( RC < RawSyntax > Raw , const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - assert ( Raw - > Layout . size ( ) = = 1 ) ; <nl> - syntax_assert_child_token_text ( Raw , <nl> - Cursor : : FallthroughKeyword , <nl> + void FallthroughStmtSyntax : : validate ( ) const { <nl> + assert ( Data - > Raw - > Kind = = SyntaxKind : : FallthroughStmt ) ; <nl> + assert ( Data - > Raw - > Layout . size ( ) = = 1 ) ; <nl> + syntax_assert_child_token_text ( Data - > Raw , Cursor : : FallthroughKeyword , <nl> tok : : kw_fallthrough , " fallthrough " ) ; <nl> - auto Data = FallthroughStmtSyntaxData : : make ( Raw , Parent , IndexInParent ) ; <nl> - return FallthroughStmtSyntax { <nl> - Data , Data . get ( ) , <nl> - } ; <nl> } <nl> <nl> RC < TokenSyntax > FallthroughStmtSyntax : : getFallthroughKeyword ( ) const { <nl> withFallthroughKeyword ( RC < TokenSyntax > NewFallthroughKeyword ) const { <nl> Cursor : : FallthroughKeyword ) ; <nl> } <nl> <nl> + # pragma mark code - block API <nl> <nl> - CodeBlockStmtSyntaxData : : CodeBlockStmtSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : StmtSyntaxData ( Raw , Parent , IndexInParent ) { <nl> - assert ( Raw - > Kind = = SyntaxKind : : CodeBlockStmt ) ; <nl> - syntax_assert_child_token_text ( Raw , CodeBlockStmtSyntax : : Cursor : : LeftBrace , <nl> - tok : : l_brace , " { " ) ; <nl> - syntax_assert_child_kind ( Raw , CodeBlockStmtSyntax : : Cursor : : Elements , <nl> - SyntaxKind : : StmtList ) ; <nl> - syntax_assert_child_token_text ( Raw , CodeBlockStmtSyntax : : Cursor : : RightBrace , <nl> - tok : : r_brace , " } " ) ; <nl> - } <nl> - <nl> - RC < CodeBlockStmtSyntaxData > <nl> - CodeBlockStmtSyntaxData : : make ( RC < RawSyntax > Raw , const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - return RC < CodeBlockStmtSyntaxData > { <nl> - new CodeBlockStmtSyntaxData { Raw , Parent , IndexInParent } <nl> - } ; <nl> - } <nl> - <nl> - RC < CodeBlockStmtSyntaxData > <nl> - CodeBlockStmtSyntaxData : : makeBlank ( ) { <nl> - return make ( RawSyntax : : make ( SyntaxKind : : CodeBlockStmt , <nl> + CodeBlockStmtSyntax <nl> + CodeBlockStmtSyntax : : makeBlank ( ) { <nl> + return make < CodeBlockStmtSyntax > ( RawSyntax : : make ( SyntaxKind : : CodeBlockStmt , <nl> { <nl> TokenSyntax : : missingToken ( tok : : l_brace , " { " ) , <nl> RawSyntax : : missing ( SyntaxKind : : StmtList ) , <nl> CodeBlockStmtSyntaxData : : makeBlank ( ) { <nl> SourcePresence : : Present ) ) ; <nl> } <nl> <nl> - # pragma mark - break - statement Data <nl> - <nl> - BreakStmtSyntaxData : : BreakStmtSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : StmtSyntaxData ( Raw , Parent , IndexInParent ) { <nl> - assert ( Raw - > Layout . size ( ) = = 2 ) ; <nl> - syntax_assert_child_token_text ( Raw , BreakStmtSyntax : : Cursor : : BreakKeyword , <nl> - tok : : kw_break , " break " ) ; <nl> - syntax_assert_child_token ( Raw , BreakStmtSyntax : : Cursor : : Label , <nl> - tok : : identifier ) ; <nl> - } <nl> - <nl> - RC < BreakStmtSyntaxData > <nl> - BreakStmtSyntaxData : : make ( RC < RawSyntax > Raw , const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - return RC < BreakStmtSyntaxData > { <nl> - new BreakStmtSyntaxData { <nl> - Raw , Parent , IndexInParent <nl> - } <nl> - } ; <nl> - } <nl> - <nl> - RC < BreakStmtSyntaxData > BreakStmtSyntaxData : : makeBlank ( ) { <nl> - return make ( RawSyntax : : make ( SyntaxKind : : BreakStmt , <nl> - { <nl> - TokenSyntax : : missingToken ( tok : : kw_break , <nl> - " break " ) , <nl> - TokenSyntax : : missingToken ( tok : : identifier , " " ) , <nl> - } , <nl> - SourcePresence : : Present ) ) ; <nl> + void CodeBlockStmtSyntax : : validate ( ) const { <nl> + assert ( Data - > Raw - > Kind = = SyntaxKind : : CodeBlockStmt ) ; <nl> + syntax_assert_child_token_text ( Data - > Raw , Cursor : : LeftBrace , <nl> + tok : : l_brace , " { " ) ; <nl> + syntax_assert_child_kind ( Data - > Raw , Cursor : : Elements , <nl> + SyntaxKind : : StmtList ) ; <nl> + syntax_assert_child_token_text ( Data - > Raw , Cursor : : RightBrace , <nl> + tok : : r_brace , " } " ) ; <nl> } <nl> <nl> # pragma mark - break - statement API <nl> <nl> - BreakStmtSyntax : : BreakStmtSyntax ( const RC < SyntaxData > Root , <nl> - BreakStmtSyntaxData * Data ) <nl> - : StmtSyntax ( Root , Data ) { } <nl> - <nl> - BreakStmtSyntax BreakStmtSyntax : : make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - auto Data = BreakStmtSyntaxData : : make ( Raw , Parent , IndexInParent ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + void BreakStmtSyntax : : validate ( ) const { <nl> + assert ( Data - > Raw - > Layout . size ( ) = = 2 ) ; <nl> + syntax_assert_child_token_text ( Data - > Raw , Cursor : : BreakKeyword , <nl> + tok : : kw_break , " break " ) ; <nl> + syntax_assert_child_token ( Data - > Raw , BreakStmtSyntax : : Cursor : : Label , <nl> + tok : : identifier ) ; <nl> } <nl> <nl> BreakStmtSyntax BreakStmtSyntax : : makeBlank ( ) { <nl> - auto Data = BreakStmtSyntaxData : : makeBlank ( ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return make < BreakStmtSyntax > ( RawSyntax : : make ( SyntaxKind : : BreakStmt , <nl> + { <nl> + TokenSyntax : : missingToken ( tok : : kw_break , <nl> + " break " ) , <nl> + TokenSyntax : : missingToken ( tok : : identifier , " " ) , <nl> + } , <nl> + SourcePresence : : Present ) ) ; <nl> } <nl> <nl> RC < TokenSyntax > BreakStmtSyntax : : getBreakKeyword ( ) const { <nl> BreakStmtSyntax BreakStmtSyntax : : withLabel ( RC < TokenSyntax > NewLabel ) const { <nl> return Data - > replaceChild < BreakStmtSyntax > ( NewLabel , Cursor : : Label ) ; <nl> } <nl> <nl> - # pragma mark - continue - statement Data <nl> - <nl> - ContinueStmtSyntaxData : : ContinueStmtSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : StmtSyntaxData ( Raw , Parent , IndexInParent ) { <nl> - assert ( Raw - > Layout . size ( ) = = 2 ) ; <nl> - syntax_assert_child_token_text ( Raw , <nl> - ContinueStmtSyntax : : Cursor : : ContinueKeyword , <nl> - tok : : kw_continue , " continue " ) ; <nl> - syntax_assert_child_token ( Raw , ContinueStmtSyntax : : Cursor : : Label , <nl> - tok : : identifier ) ; <nl> - } <nl> - <nl> - RC < ContinueStmtSyntaxData > <nl> - ContinueStmtSyntaxData : : make ( RC < RawSyntax > Raw , const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - return RC < ContinueStmtSyntaxData > { <nl> - new ContinueStmtSyntaxData { <nl> - Raw , Parent , IndexInParent <nl> - } <nl> - } ; <nl> - } <nl> - <nl> - RC < ContinueStmtSyntaxData > ContinueStmtSyntaxData : : makeBlank ( ) { <nl> - return make ( RawSyntax : : make ( SyntaxKind : : ContinueStmt , <nl> - { <nl> - TokenSyntax : : missingToken ( tok : : kw_continue , <nl> - " continue " ) , <nl> - TokenSyntax : : missingToken ( tok : : identifier , " " ) , <nl> - } , <nl> - SourcePresence : : Present ) ) ; <nl> + ContinueStmtSyntax ContinueStmtSyntax : : makeBlank ( ) { <nl> + return make < ContinueStmtSyntax > ( <nl> + RawSyntax : : make ( SyntaxKind : : ContinueStmt , <nl> + { <nl> + TokenSyntax : : missingToken ( tok : : kw_continue , " continue " ) , <nl> + TokenSyntax : : missingToken ( tok : : identifier , " " ) , <nl> + } , <nl> + SourcePresence : : Present ) ) ; <nl> } <nl> <nl> # pragma mark - continue - statement API <nl> <nl> - ContinueStmtSyntax : : ContinueStmtSyntax ( const RC < SyntaxData > Root , <nl> - ContinueStmtSyntaxData * Data ) <nl> - : StmtSyntax ( Root , Data ) { } <nl> - <nl> - ContinueStmtSyntax ContinueStmtSyntax : : make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - auto Data = ContinueStmtSyntaxData : : make ( Raw , Parent , IndexInParent ) ; <nl> - return { Data , Data . get ( ) } ; <nl> - } <nl> - <nl> - ContinueStmtSyntax ContinueStmtSyntax : : makeBlank ( ) { <nl> - auto Data = ContinueStmtSyntaxData : : makeBlank ( ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + void ContinueStmtSyntax : : validate ( ) const { <nl> + assert ( Data - > Raw - > Layout . size ( ) = = 2 ) ; <nl> + syntax_assert_child_token_text ( Data - > Raw , <nl> + Cursor : : ContinueKeyword , <nl> + tok : : kw_continue , " continue " ) ; <nl> + syntax_assert_child_token ( Data - > Raw , Cursor : : Label , <nl> + tok : : identifier ) ; <nl> } <nl> <nl> RC < TokenSyntax > ContinueStmtSyntax : : getContinueKeyword ( ) const { <nl> ContinueStmtSyntax : : withLabel ( RC < TokenSyntax > NewLabel ) const { <nl> return Data - > replaceChild < ContinueStmtSyntax > ( NewLabel , Cursor : : Label ) ; <nl> } <nl> <nl> - # pragma mark - return - statement Data <nl> - <nl> - ReturnStmtSyntaxData : : ReturnStmtSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : StmtSyntaxData ( Raw , Parent , IndexInParent ) { <nl> - assert ( Raw - > Layout . size ( ) = = 2 ) ; <nl> - syntax_assert_child_token_text ( Raw , <nl> - ReturnStmtSyntax : : Cursor : : ReturnKeyword , <nl> - tok : : kw_return , " return " ) ; <nl> - assert ( Raw - > getChild ( ReturnStmtSyntax : : Cursor : : Expression ) - > isExpr ( ) ) ; <nl> - } <nl> - <nl> - RC < ReturnStmtSyntaxData > <nl> - ReturnStmtSyntaxData : : make ( RC < RawSyntax > Raw , const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - return RC < ReturnStmtSyntaxData > { <nl> - new ReturnStmtSyntaxData { <nl> - Raw , Parent , IndexInParent <nl> - } <nl> - } ; <nl> - } <nl> - <nl> - RC < ReturnStmtSyntaxData > ReturnStmtSyntaxData : : makeBlank ( ) { <nl> - return make ( RawSyntax : : make ( SyntaxKind : : ReturnStmt , <nl> - { <nl> - TokenSyntax : : missingToken ( tok : : kw_return , <nl> - " return " ) , <nl> - RawSyntax : : missing ( SyntaxKind : : MissingExpr ) , <nl> - } , <nl> - SourcePresence : : Present ) ) ; <nl> - } <nl> - <nl> # pragma mark - return - statement API <nl> <nl> - ReturnStmtSyntax : : ReturnStmtSyntax ( const RC < SyntaxData > Root , <nl> - const ReturnStmtSyntaxData * Data ) <nl> - : StmtSyntax ( Root , Data ) { } <nl> - <nl> - ReturnStmtSyntax ReturnStmtSyntax : : make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - auto Data = ReturnStmtSyntaxData : : make ( Raw , Parent , IndexInParent ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + void ReturnStmtSyntax : : validate ( ) const { <nl> + assert ( Data - > Raw - > Layout . size ( ) = = 2 ) ; <nl> + syntax_assert_child_token_text ( Data - > Raw , <nl> + Cursor : : ReturnKeyword , <nl> + tok : : kw_return , " return " ) ; <nl> + assert ( Data - > Raw - > getChild ( Cursor : : Expression ) - > isExpr ( ) ) ; <nl> } <nl> <nl> ReturnStmtSyntax ReturnStmtSyntax : : makeBlank ( ) { <nl> - auto Data = ReturnStmtSyntaxData : : makeBlank ( ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + auto Raw = RawSyntax : : make ( SyntaxKind : : ReturnStmt , <nl> + { <nl> + TokenSyntax : : missingToken ( tok : : kw_return , <nl> + " return " ) , <nl> + RawSyntax : : missing ( SyntaxKind : : MissingExpr ) , <nl> + } , <nl> + SourcePresence : : Present ) ; <nl> + return make < ReturnStmtSyntax > ( Raw ) ; <nl> } <nl> <nl> RC < TokenSyntax > ReturnStmtSyntax : : getReturnKeyword ( ) const { <nl> withReturnKeyword ( RC < TokenSyntax > NewReturnKeyword ) const { <nl> } <nl> <nl> Optional < ExprSyntax > ReturnStmtSyntax : : getExpression ( ) const { <nl> - auto RawExpression = getRaw ( ) - > getChild ( Cursor : : Expression ) ; <nl> - if ( RawExpression - > isMissing ( ) ) { <nl> - return llvm : : None ; <nl> - } <nl> - <nl> - auto * MyData = getUnsafeData < ReturnStmtSyntax > ( ) ; <nl> - <nl> - auto & ChildPtr = * reinterpret_cast < std : : atomic < uintptr_t > * > ( <nl> - & MyData - > CachedExpression ) ; <nl> - <nl> - SyntaxData : : realizeSyntaxNode < ExprSyntax > ( ChildPtr , RawExpression , MyData , <nl> - cursorIndex ( Cursor : : Expression ) ) ; <nl> - <nl> - return ExprSyntax { Root , MyData - > CachedExpression . get ( ) } ; <nl> + return ExprSyntax { Root , Data - > getChild ( Cursor : : Expression ) . get ( ) } ; <nl> } <nl> <nl> ReturnStmtSyntax <nl> ReturnStmtSyntax : : withExpression ( ExprSyntax NewExpression ) const { <nl> return Data - > replaceChild < ReturnStmtSyntax > ( NewExpression . getRaw ( ) , <nl> Cursor : : Expression ) ; <nl> } <nl> - <nl> - <nl> - # pragma mark code - block API <nl> - <nl> - CodeBlockStmtSyntax : : CodeBlockStmtSyntax ( const RC < SyntaxData > Root , <nl> - CodeBlockStmtSyntaxData * Data ) <nl> - : StmtSyntax ( Root , Data ) { } <nl> mmm a / lib / Syntax / Syntax . cpp <nl> ppp b / lib / Syntax / Syntax . cpp <nl> <nl> using namespace swift ; <nl> using namespace swift : : syntax ; <nl> <nl> - Syntax : : Syntax ( const RC < SyntaxData > Root , const SyntaxData * Data ) <nl> - : Root ( Root ) , Data ( Data ) { } <nl> - <nl> RC < RawSyntax > Syntax : : getRaw ( ) const { <nl> return Data - > getRaw ( ) ; <nl> } <nl> mmm a / lib / Syntax / SyntaxData . cpp <nl> ppp b / lib / Syntax / SyntaxData . cpp <nl> <nl> / / <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> <nl> - # include " swift / Syntax / DeclSyntax . h " <nl> - # include " swift / Syntax / ExprSyntax . h " <nl> - # include " swift / Syntax / GenericSyntax . h " <nl> - # include " swift / Syntax / TypeSyntax . h " <nl> - # include " swift / Syntax / StmtSyntax . h " <nl> # include " swift / Syntax / UnknownSyntax . h " <nl> # include " llvm / Support / ErrorHandling . h " <nl> <nl> RC < SyntaxData > SyntaxData : : make ( RC < RawSyntax > Raw , <nl> } ; <nl> } <nl> <nl> - RC < SyntaxData > SyntaxData : : makeDataFromRaw ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - switch ( Raw - > Kind ) { <nl> - # define SYNTAX ( Id , ParentType ) \ <nl> - case SyntaxKind : : Id : \ <nl> - return Id # # SyntaxData : : make ( Raw , Parent , IndexInParent ) ; <nl> - <nl> - # define MISSING_SYNTAX ( Id , ParentType ) \ <nl> - case SyntaxKind : : Id : \ <nl> - return ParentType # # Data : : make ( Raw , Parent , IndexInParent ) ; <nl> - <nl> - # define SYNTAX_COLLECTION ( Id , Element ) SYNTAX ( Id , { } ) <nl> - <nl> - # include " swift / Syntax / SyntaxKinds . def " <nl> - case SyntaxKind : : Token : <nl> - llvm_unreachable ( " Can ' t make a SyntaxData from a Token ! " ) ; <nl> - } <nl> - <nl> - llvm_unreachable ( " Unhandled SyntaxKind in switch . " ) ; <nl> - } <nl> - <nl> bool SyntaxData : : isType ( ) const { <nl> return Raw - > isType ( ) ; <nl> } <nl> bool SyntaxData : : isExpr ( ) const { <nl> return Raw - > isExpr ( ) ; <nl> } <nl> <nl> + bool SyntaxData : : isPattern ( ) const { <nl> + return false ; / / FIXME : Raw - > isPattern ( ) ; <nl> + } <nl> + <nl> bool SyntaxData : : isUnknown ( ) const { <nl> return Raw - > isUnknown ( ) ; <nl> } <nl> mmm a / lib / Syntax / SyntaxFactory . cpp <nl> ppp b / lib / Syntax / SyntaxFactory . cpp <nl> SyntaxFactory : : makeUnknownSyntax ( llvm : : ArrayRef < RC < TokenSyntax > > Tokens ) { <nl> std : : copy ( Tokens . begin ( ) , Tokens . end ( ) , std : : back_inserter ( Layout ) ) ; <nl> auto Raw = RawSyntax : : make ( SyntaxKind : : Unknown , Layout , <nl> SourcePresence : : Present ) ; <nl> - auto Data = UnknownSyntaxData : : make ( Raw ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return make < UnknownSyntax > ( Raw ) ; <nl> } <nl> <nl> # pragma mark - Declarations <nl> DeclModifierSyntax SyntaxFactory : : makeDeclModifier ( RC < TokenSyntax > Name , <nl> RightParen , <nl> } , <nl> SourcePresence : : Present ) ; <nl> - auto Data = DeclModifierSyntaxData : : make ( Raw ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return make < DeclModifierSyntax > ( Raw ) ; <nl> } <nl> <nl> DeclModifierSyntax SyntaxFactory : : makeBlankDeclModifier ( ) { <nl> - auto Data = DeclModifierSyntaxData : : makeBlank ( ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return DeclModifierSyntax : : makeBlank ( ) ; <nl> } <nl> <nl> # pragma mark - declaration - modifier - list <nl> makeDeclModifierList ( const std : : vector < DeclModifierSyntax > & Modifiers ) { <nl> <nl> auto Raw = RawSyntax : : make ( SyntaxKind : : DeclModifierList , Layout , <nl> SourcePresence : : Present ) ; <nl> - auto Data = DeclModifierListSyntaxData : : make ( Raw ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return make < DeclModifierListSyntax > ( Raw ) ; <nl> } <nl> <nl> DeclModifierListSyntax SyntaxFactory : : makeBlankDeclModifierList ( ) { <nl> - auto Data = DeclModifierListSyntaxData : : makeBlank ( ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return DeclModifierListSyntax : : makeBlank ( ) ; <nl> } <nl> <nl> # pragma mark - struct - declaration <nl> SyntaxFactory : : makeStructDecl ( RC < TokenSyntax > StructToken , <nl> RightBrace <nl> } , <nl> SourcePresence : : Present ) ; <nl> - auto Data = StructDeclSyntaxData : : make ( Raw ) ; <nl> - return StructDeclSyntax { <nl> - Data , <nl> - Data . get ( ) <nl> - } ; <nl> + return make < StructDeclSyntax > ( Raw ) ; <nl> } <nl> <nl> StructDeclSyntax SyntaxFactory : : makeBlankStructDecl ( ) { <nl> - auto Data = StructDeclSyntaxData : : makeBlank ( ) ; <nl> - return StructDeclSyntax { <nl> - Data , Data . get ( ) <nl> - } ; <nl> + return StructDeclSyntax : : makeBlank ( ) ; <nl> } <nl> <nl> # pragma mark - type - alias - declaration <nl> TypeAliasDeclSyntax SyntaxFactory : : makeTypealiasDecl ( <nl> { TypealiasToken , Identifier , GenericParams . getRaw ( ) , <nl> AssignmentToken , Type . getRaw ( ) } , <nl> SourcePresence : : Present ) ; <nl> - auto Data = TypeAliasDeclSyntaxData : : make ( Raw ) ; <nl> - return TypeAliasDeclSyntax { Data , Data . get ( ) } ; <nl> + return make < TypeAliasDeclSyntax > ( Raw ) ; <nl> } <nl> <nl> TypeAliasDeclSyntax SyntaxFactory : : makeBlankTypealiasDecl ( ) { <nl> - auto Data = TypeAliasDeclSyntaxData : : makeBlank ( ) ; <nl> - return TypeAliasDeclSyntax { Data , Data . get ( ) } ; <nl> + return TypeAliasDeclSyntax : : makeBlank ( ) ; <nl> } <nl> <nl> DeclMembersSyntax SyntaxFactory : : makeBlankDeclMembers ( ) { <nl> - auto Data = DeclMembersSyntaxData : : makeBlank ( ) ; <nl> - return DeclMembersSyntax { Data , Data . get ( ) } ; <nl> + return DeclMembersSyntax : : makeBlank ( ) ; <nl> } <nl> <nl> # pragma mark - function - parameter <nl> makeFunctionParameter ( RC < TokenSyntax > ExternalName , <nl> TrailingComma , <nl> } , <nl> SourcePresence : : Present ) ; <nl> - auto Data = FunctionParameterSyntaxData : : make ( Raw ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return make < FunctionParameterSyntax > ( Raw ) ; <nl> } <nl> <nl> FunctionParameterSyntax SyntaxFactory : : makeBlankFunctionParameter ( ) { <nl> - auto Data = FunctionParameterSyntaxData : : makeBlank ( ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return FunctionParameterSyntax : : makeBlank ( ) ; <nl> } <nl> <nl> # pragma mark - function - parameter - list <nl> FunctionParameterListSyntax SyntaxFactory : : makeFunctionParameterList ( <nl> } <nl> <nl> FunctionParameterListSyntax SyntaxFactory : : makeBlankFunctionParameterList ( ) { <nl> - auto Data = FunctionParameterListSyntaxData : : makeBlank ( ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return FunctionParameterListSyntax : : makeBlank ( ) ; <nl> } <nl> <nl> # pragma mark - function - signature <nl> SyntaxFactory : : makeFunctionSignature ( RC < TokenSyntax > LeftParen , <nl> ReturnTypeSyntax . getRaw ( ) <nl> } , <nl> SourcePresence : : Present ) ; <nl> - auto Data = FunctionSignatureSyntaxData : : make ( Raw ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return make < FunctionSignatureSyntax > ( Raw ) ; <nl> } <nl> <nl> FunctionSignatureSyntax SyntaxFactory : : makeBlankFunctionSignature ( ) { <nl> - auto Data = FunctionSignatureSyntaxData : : makeBlank ( ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return FunctionSignatureSyntax : : makeBlank ( ) ; <nl> } <nl> <nl> # pragma mark - function - declaration <nl> makeFunctionDecl ( TypeAttributesSyntax Attributes , <nl> : SyntaxFactory : : makeBlankCodeBlock ( ) . getRaw ( ) <nl> } , <nl> SourcePresence : : Present ) ; <nl> - auto Data = FunctionDeclSyntaxData : : make ( Raw ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return make < FunctionDeclSyntax > ( Raw ) ; <nl> } <nl> <nl> FunctionDeclSyntax SyntaxFactory : : makeBlankFunctionDecl ( ) { <nl> - auto Data = FunctionDeclSyntaxData : : makeBlank ( ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return FunctionDeclSyntax : : makeBlank ( ) ; <nl> } <nl> <nl> # pragma mark - Statements <nl> SyntaxFactory : : makeCodeBlock ( RC < TokenSyntax > LeftBraceToken , <nl> Elements . getRaw ( ) , <nl> RightBraceToken <nl> } , SourcePresence : : Present ) ; <nl> - auto Data = CodeBlockStmtSyntaxData : : make ( Raw ) ; <nl> - return CodeBlockStmtSyntax { Data , Data . get ( ) } ; <nl> + return make < CodeBlockStmtSyntax > ( Raw ) ; <nl> } <nl> <nl> CodeBlockStmtSyntax SyntaxFactory : : makeBlankCodeBlock ( ) { <nl> - auto Data = CodeBlockStmtSyntaxData : : makeBlank ( ) ; <nl> - return CodeBlockStmtSyntax { Data , Data . get ( ) } ; <nl> + return CodeBlockStmtSyntax : : makeBlank ( ) ; <nl> } <nl> <nl> FallthroughStmtSyntax <nl> SyntaxFactory : : makeFallthroughStmt ( RC < TokenSyntax > FallthroughKeyword ) { <nl> auto Raw = RawSyntax : : make ( SyntaxKind : : FallthroughStmt , { <nl> FallthroughKeyword <nl> } , SourcePresence : : Present ) ; <nl> - auto Data = FallthroughStmtSyntaxData : : make ( Raw ) ; <nl> - return FallthroughStmtSyntax { Data , Data . get ( ) } ; <nl> + return make < FallthroughStmtSyntax > ( Raw ) ; <nl> } <nl> <nl> FallthroughStmtSyntax SyntaxFactory : : makeBlankFallthroughStmt ( ) { <nl> - auto Data = FallthroughStmtSyntaxData : : makeBlank ( ) ; <nl> - return FallthroughStmtSyntax { Data , Data . get ( ) } ; <nl> + return FallthroughStmtSyntax : : makeBlank ( ) ; <nl> } <nl> <nl> # pragma mark - break - statement <nl> SyntaxFactory : : makeBreakStmt ( RC < TokenSyntax > BreakKeyword , <nl> Label , <nl> } , <nl> SourcePresence : : Present ) ; <nl> - auto Data = BreakStmtSyntaxData : : make ( Raw ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return make < BreakStmtSyntax > ( Raw ) ; <nl> } <nl> <nl> / / / Make a break statement with the ` break ` keyword <nl> / / / and destination label marked as missing . <nl> BreakStmtSyntax SyntaxFactory : : makeBlankBreakStmtSyntax ( ) { <nl> - auto Data = BreakStmtSyntaxData : : makeBlank ( ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return BreakStmtSyntax : : makeBlank ( ) ; <nl> } <nl> <nl> # pragma mark - continue - statement <nl> SyntaxFactory : : makeContinueStmt ( RC < TokenSyntax > ContinueKeyword , <nl> Label , <nl> } , <nl> SourcePresence : : Present ) ; <nl> - auto Data = ContinueStmtSyntaxData : : make ( Raw ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return make < ContinueStmtSyntax > ( Raw ) ; <nl> } <nl> <nl> / / / Make a break statement with the ` break ` keyword <nl> / / / and destination label marked as missing . <nl> ContinueStmtSyntax SyntaxFactory : : makeBlankContinueStmtSyntax ( ) { <nl> - auto Data = ContinueStmtSyntaxData : : makeBlank ( ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return ContinueStmtSyntax : : makeBlank ( ) ; <nl> } <nl> <nl> # pragma mark - return - statement <nl> SyntaxFactory : : makeReturnStmt ( RC < TokenSyntax > ReturnKeyword , <nl> ReturnedExpression . getRaw ( ) , <nl> } , <nl> SourcePresence : : Present ) ; <nl> - auto Data = ReturnStmtSyntaxData : : make ( Raw ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return make < ReturnStmtSyntax > ( Raw ) ; <nl> } <nl> <nl> ReturnStmtSyntax SyntaxFactory : : makeBlankReturnStmt ( ) { <nl> ReturnStmtSyntax SyntaxFactory : : makeBlankReturnStmt ( ) { <nl> RawSyntax : : missing ( SyntaxKind : : MissingExpr ) , <nl> } , <nl> SourcePresence : : Present ) ; <nl> - auto Data = ReturnStmtSyntaxData : : make ( Raw ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return make < ReturnStmtSyntax > ( Raw ) ; <nl> } <nl> <nl> / / / Make a statement list from a loosely connected list of statements . <nl> SyntaxFactory : : makeStmtList ( const std : : vector < StmtSyntax > & Statements ) { <nl> <nl> auto Raw = RawSyntax : : make ( SyntaxKind : : StmtList , Layout , <nl> SourcePresence : : Present ) ; <nl> - auto Data = StmtListSyntaxData : : make ( Raw ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return make < StmtListSyntax > ( Raw ) ; <nl> } <nl> <nl> / / / Make an empty statement list . <nl> StmtListSyntax SyntaxFactory : : makeBlankStmtList ( ) { <nl> auto Raw = RawSyntax : : make ( SyntaxKind : : StmtList , { } , SourcePresence : : Present ) ; <nl> - auto Data = StmtListSyntaxData : : make ( Raw ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return make < StmtListSyntax > ( Raw ) ; <nl> } <nl> <nl> # pragma mark - Expressions <nl> SyntaxFactory : : makeIntegerLiteralExpr ( RC < TokenSyntax > Sign , <nl> Digits , <nl> } , <nl> SourcePresence : : Present ) ; <nl> - auto Data = IntegerLiteralExprSyntaxData : : make ( Raw ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return make < IntegerLiteralExprSyntax > ( Raw ) ; <nl> } <nl> <nl> IntegerLiteralExprSyntax SyntaxFactory : : makeBlankIntegerLiteralExpr ( ) { <nl> IntegerLiteralExprSyntax SyntaxFactory : : makeBlankIntegerLiteralExpr ( ) { <nl> TokenSyntax : : missingToken ( tok : : integer_literal , " " ) , <nl> } , <nl> SourcePresence : : Present ) ; <nl> - auto Data = IntegerLiteralExprSyntaxData : : make ( Raw ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return make < IntegerLiteralExprSyntax > ( Raw ) ; <nl> } <nl> <nl> # pragma mark - symbolic - reference <nl> SyntaxFactory : : makeSymbolicReferenceExpr ( RC < TokenSyntax > Identifier , <nl> : RawSyntax : : missing ( SyntaxKind : : GenericArgumentClause ) <nl> } , <nl> SourcePresence : : Present ) ; <nl> - auto Data = SymbolicReferenceExprSyntaxData : : make ( Raw ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return make < SymbolicReferenceExprSyntax > ( Raw ) ; <nl> } <nl> <nl> SymbolicReferenceExprSyntax SyntaxFactory : : makeBlankSymbolicReferenceExpr ( ) { <nl> - auto Data = SymbolicReferenceExprSyntaxData : : makeBlank ( ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return SymbolicReferenceExprSyntax : : makeBlank ( ) ; <nl> } <nl> <nl> # pragma mark - function - call - argument <nl> <nl> FunctionCallArgumentSyntax SyntaxFactory : : makeBlankFunctionCallArgument ( ) { <nl> - auto Data = FunctionCallArgumentSyntaxData : : makeBlank ( ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return FunctionCallArgumentSyntax : : makeBlank ( ) ; <nl> } <nl> <nl> FunctionCallArgumentSyntax <nl> SyntaxFactory : : makeFunctionCallArgument ( RC < TokenSyntax > Label , <nl> TrailingComma <nl> } , <nl> SourcePresence : : Present ) ; <nl> - auto Data = FunctionCallArgumentSyntaxData : : make ( Raw ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return make < FunctionCallArgumentSyntax > ( Raw ) ; <nl> } <nl> <nl> # pragma mark - function - call - argument - list <nl> SyntaxFactory : : makeFunctionCallArgumentList ( <nl> <nl> auto Raw = RawSyntax : : make ( SyntaxKind : : FunctionCallArgumentList , Layout , <nl> SourcePresence : : Present ) ; <nl> - auto Data = FunctionCallArgumentListSyntaxData : : make ( Raw ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return make < FunctionCallArgumentListSyntax > ( Raw ) ; <nl> } <nl> <nl> <nl> FunctionCallArgumentListSyntax <nl> SyntaxFactory : : makeBlankFunctionCallArgumentList ( ) { <nl> - auto Data = FunctionCallArgumentListSyntaxData : : makeBlank ( ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return FunctionCallArgumentListSyntax : : makeBlank ( ) ; <nl> } <nl> <nl> # pragma mark - function - call - expression <nl> SyntaxFactory : : makeFunctionCallExpr ( ExprSyntax CalledExpr , <nl> RightParen <nl> } , <nl> SourcePresence : : Present ) ; <nl> - auto Data = FunctionCallExprSyntaxData : : make ( Raw ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return make < FunctionCallExprSyntax > ( Raw ) ; <nl> } <nl> <nl> <nl> FunctionCallExprSyntax SyntaxFactory : : makeBlankFunctionCallExpr ( ) { <nl> - auto Data = FunctionCallExprSyntaxData : : makeBlank ( ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return FunctionCallExprSyntax : : makeBlank ( ) ; <nl> } <nl> <nl> # pragma mark - Tokens <nl> SyntaxFactory : : makeIntegerLiteralToken ( OwnedString Digits , <nl> <nl> GenericParameterClauseSyntax <nl> SyntaxFactory : : makeBlankGenericParameterClause ( ) { <nl> - auto Data = GenericParameterClauseSyntaxData : : makeBlank ( ) ; <nl> - return GenericParameterClauseSyntax { Data , Data . get ( ) } ; <nl> + return GenericParameterClauseSyntax : : makeBlank ( ) ; <nl> } <nl> <nl> GenericArgumentClauseSyntax SyntaxFactory : : makeBlankGenericArgumentClause ( ) { <nl> - auto Data = GenericArgumentClauseSyntaxData : : makeBlank ( ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return GenericArgumentClauseSyntax : : makeBlank ( ) ; <nl> } <nl> <nl> GenericWhereClauseSyntax <nl> SyntaxFactory : : makeBlankGenericWhereClause ( ) { <nl> - auto Data = GenericWhereClauseSyntaxData : : makeBlank ( ) ; <nl> - return GenericWhereClauseSyntax { Data , Data . get ( ) } ; <nl> + return GenericWhereClauseSyntax : : makeBlank ( ) ; <nl> } <nl> <nl> GenericParameterSyntax <nl> SyntaxFactory : : makeGenericParameter ( OwnedString TypeName , <nl> RawSyntax : : missing ( SyntaxKind : : TypeIdentifier ) , <nl> } , <nl> SourcePresence : : Present ) ; <nl> - auto Data = GenericParameterSyntaxData : : make ( Raw ) ; <nl> - return GenericParameterSyntax { Data , Data . get ( ) } ; <nl> + return make < GenericParameterSyntax > ( Raw ) ; <nl> } <nl> <nl> SameTypeRequirementSyntax SyntaxFactory : : <nl> makeSameTypeRequirement ( TypeIdentifierSyntax LeftTypeIdentifier , <nl> RightType . getRaw ( ) <nl> } , <nl> SourcePresence : : Present ) ; <nl> - auto Data = SameTypeRequirementSyntaxData : : make ( Raw ) ; <nl> - return SameTypeRequirementSyntax { Data , Data . get ( ) } ; <nl> + return make < SameTypeRequirementSyntax > ( Raw ) ; <nl> } <nl> <nl> SameTypeRequirementSyntax SyntaxFactory : : makeBlankSameTypeRequirement ( ) { <nl> - auto Data = SameTypeRequirementSyntaxData : : makeBlank ( ) ; <nl> - return SameTypeRequirementSyntax { Data , Data . get ( ) } ; <nl> + return SameTypeRequirementSyntax : : makeBlank ( ) ; <nl> } <nl> <nl> GenericRequirementListSyntax SyntaxFactory : : <nl> makeGenericRequirementList ( std : : vector < GenericRequirementSyntax > & Requirements ) { <nl> } <nl> auto Raw = RawSyntax : : make ( SyntaxKind : : GenericRequirementList , Layout , <nl> SourcePresence : : Present ) ; <nl> - auto Data = GenericRequirementListSyntaxData : : make ( Raw ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return make < GenericRequirementListSyntax > ( Raw ) ; <nl> } <nl> <nl> GenericRequirementListSyntax SyntaxFactory : : makeBlankGenericRequirementList ( ) { <nl> - auto Data = GenericRequirementListSyntaxData : : makeBlank ( ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return GenericRequirementListSyntax : : makeBlank ( ) ; <nl> } <nl> <nl> # pragma mark - Operators <nl> SyntaxFactory : : makeTypeAttribute ( RC < TokenSyntax > AtSignToken , <nl> RightParen , <nl> } , <nl> SourcePresence : : Present ) ; <nl> - auto Data = TypeAttributeSyntaxData : : make ( Raw ) ; <nl> - return TypeAttributeSyntax { Data , Data . get ( ) } ; <nl> + return make < TypeAttributeSyntax > ( Raw ) ; <nl> } <nl> <nl> TypeAttributeSyntax SyntaxFactory : : makeBlankTypeAttribute ( ) { <nl> - auto Data = TypeAttributeSyntaxData : : makeBlank ( ) ; <nl> - return TypeAttributeSyntax { Data , Data . get ( ) } ; <nl> + return TypeAttributeSyntax : : makeBlank ( ) ; <nl> } <nl> <nl> # pragma mark - type - attributes <nl> SyntaxFactory : : makeBalancedTokens ( RawSyntax : : LayoutList Tokens ) { <nl> auto Raw = RawSyntax : : make ( SyntaxKind : : BalancedTokens , <nl> Tokens , <nl> SourcePresence : : Present ) ; <nl> - auto Data = BalancedTokensSyntaxData : : make ( Raw ) ; <nl> - return BalancedTokensSyntax { Data , Data . get ( ) } ; <nl> + return make < BalancedTokensSyntax > ( Raw ) ; <nl> } <nl> <nl> BalancedTokensSyntax SyntaxFactory : : makeBlankBalancedTokens ( ) { <nl> - auto Data = BalancedTokensSyntaxData : : makeBlank ( ) ; <nl> - return BalancedTokensSyntax { Data , Data . get ( ) } ; <nl> + return BalancedTokensSyntax : : makeBlank ( ) ; <nl> } <nl> <nl> # pragma mark - type - identifier <nl> SyntaxFactory : : makeTypeIdentifier ( OwnedString Name , <nl> RawSyntax : : missing ( SyntaxKind : : TypeIdentifier ) , <nl> } , <nl> SourcePresence : : Present ) ; <nl> - auto Data = TypeIdentifierSyntaxData : : make ( Raw ) ; <nl> - return TypeIdentifierSyntax { Data , Data . get ( ) } ; <nl> + return make < TypeIdentifierSyntax > ( Raw ) ; <nl> } <nl> <nl> TypeIdentifierSyntax SyntaxFactory : : makeAnyTypeIdentifier ( ) { <nl> - auto Data = TypeIdentifierSyntaxData : : makeBlank ( ) ; <nl> - return TypeIdentifierSyntax { Data , Data . get ( ) } <nl> - . withIdentifier ( makeIdentifier ( " Any " , { } , { } ) ) ; <nl> + return TypeIdentifierSyntax : : makeBlank ( ) <nl> + . withIdentifier ( makeIdentifier ( " Any " , { } , { } ) ) ; <nl> } <nl> <nl> TypeIdentifierSyntax SyntaxFactory : : makeSelfTypeIdentifier ( ) { <nl> - auto Data = TypeIdentifierSyntaxData : : makeBlank ( ) ; <nl> - return TypeIdentifierSyntax { Data , Data . get ( ) } <nl> - . withIdentifier ( makeIdentifier ( " Self " , { } , { } ) ) ; <nl> + return TypeIdentifierSyntax : : makeBlank ( ) <nl> + . withIdentifier ( makeIdentifier ( " Self " , { } , { } ) ) ; <nl> } <nl> <nl> TypeIdentifierSyntax <nl> SyntaxFactory : : makeTypeIdentifier ( RC < TokenSyntax > Identifier , <nl> RawSyntax : : missing ( SyntaxKind : : TypeIdentifier ) , <nl> } , <nl> SourcePresence : : Present ) ; <nl> - auto Data = TypeIdentifierSyntaxData : : make ( Raw ) ; <nl> - return TypeIdentifierSyntax { Data , Data . get ( ) } ; <nl> + return make < TypeIdentifierSyntax > ( Raw ) ; <nl> } <nl> <nl> # pragma mark - tuple - type <nl> TupleTypeSyntax SyntaxFactory : : makeVoidTupleType ( ) { <nl> SyntaxFactory : : makeRightParenToken ( { } , { } ) , <nl> } , <nl> SourcePresence : : Present ) ; <nl> - auto Data = TupleTypeSyntaxData : : make ( std : : move ( Raw ) ) ; <nl> - return TupleTypeSyntax { <nl> - Data , Data . get ( ) <nl> - } ; <nl> + return make < TupleTypeSyntax > ( Raw ) ; <nl> } <nl> <nl> TupleTypeSyntax <nl> SyntaxFactory : : makeTupleType ( RC < TokenSyntax > LParen , <nl> auto Raw = RawSyntax : : make ( SyntaxKind : : TupleType , <nl> { LParen , Elements . getRaw ( ) , RParen } , <nl> SourcePresence : : Present ) ; <nl> - auto Data = TupleTypeSyntaxData : : make ( std : : move ( Raw ) ) ; <nl> - return TupleTypeSyntax { <nl> - Data , Data . get ( ) <nl> - } ; <nl> + return make < TupleTypeSyntax > ( Raw ) ; <nl> } <nl> <nl> TupleTypeElementSyntax <nl> SyntaxFactory : : makeTupleTypeElement ( RC < TokenSyntax > Name , <nl> RC < TokenSyntax > Colon , <nl> TypeSyntax ElementTypeSyntax , <nl> Optional < RC < TokenSyntax > > MaybeComma ) { <nl> - auto Data = TupleTypeElementSyntaxData : : makeBlank ( ) ; <nl> RC < TokenSyntax > Comma ; <nl> if ( MaybeComma . hasValue ( ) ) { <nl> Comma = MaybeComma . getValue ( ) ; <nl> } else { <nl> Comma = TokenSyntax : : missingToken ( tok : : comma , " , " ) ; <nl> } <nl> - return TupleTypeElementSyntax { Data , Data . get ( ) } <nl> + return TupleTypeElementSyntax : : makeBlank ( ) <nl> . withLabel ( Name ) <nl> . withColonToken ( Colon ) <nl> . withTypeSyntax ( ElementTypeSyntax ) <nl> SyntaxFactory : : makeTupleTypeElement ( RC < TokenSyntax > Name , <nl> TupleTypeElementSyntax <nl> SyntaxFactory : : makeTupleTypeElement ( TypeSyntax ElementType , <nl> Optional < RC < TokenSyntax > > MaybeComma ) { <nl> - auto Data = TupleTypeElementSyntaxData : : makeBlank ( ) ; <nl> RC < TokenSyntax > Comma ; <nl> if ( MaybeComma . hasValue ( ) ) { <nl> Comma = MaybeComma . getValue ( ) ; <nl> } else { <nl> Comma = TokenSyntax : : missingToken ( tok : : comma , " , " ) ; <nl> } <nl> - return TupleTypeElementSyntax { Data , Data . get ( ) } <nl> + return TupleTypeElementSyntax : : makeBlank ( ) <nl> . withTypeSyntax ( ElementType ) <nl> . withCommaToken ( Comma ) ; <nl> } <nl> SyntaxFactory : : makeOptionalType ( TypeSyntax BaseType , <nl> } , <nl> SourcePresence : : Present ) ; <nl> <nl> - auto Data = OptionalTypeSyntaxData : : make ( Raw ) ; <nl> - return OptionalTypeSyntax { Data , Data . get ( ) } ; <nl> + return make < OptionalTypeSyntax > ( Raw ) ; <nl> } <nl> <nl> OptionalTypeSyntax SyntaxFactory : : makeBlankOptionalType ( ) { <nl> - auto Data = OptionalTypeSyntaxData : : makeBlank ( ) ; <nl> - return OptionalTypeSyntax { Data , Data . get ( ) } ; <nl> + return OptionalTypeSyntax : : makeBlank ( ) ; <nl> } <nl> <nl> # pragma mark - implicitly - unwrapped - optional - type <nl> makeImplicitlyUnwrappedOptionalType ( TypeSyntax BaseType , <nl> SyntaxFactory : : makeExclaimPostfixToken ( TrailingTrivia ) , <nl> } , <nl> SourcePresence : : Present ) ; <nl> - auto Data = ImplicitlyUnwrappedOptionalTypeSyntaxData : : make ( Raw ) ; <nl> - return ImplicitlyUnwrappedOptionalTypeSyntax { Data , Data . get ( ) } ; <nl> + return make < ImplicitlyUnwrappedOptionalTypeSyntax > ( Raw ) ; <nl> } <nl> <nl> ImplicitlyUnwrappedOptionalTypeSyntax <nl> SyntaxFactory : : makeBlankImplicitlyUnwrappedOptionalType ( ) { <nl> - auto Data = ImplicitlyUnwrappedOptionalTypeSyntaxData : : makeBlank ( ) ; <nl> - return ImplicitlyUnwrappedOptionalTypeSyntax { Data , Data . get ( ) } ; <nl> + return ImplicitlyUnwrappedOptionalTypeSyntax : : makeBlank ( ) ; <nl> } <nl> <nl> # pragma mark - metatype - type <nl> MetatypeTypeSyntax SyntaxFactory : : makeMetatypeType ( TypeSyntax BaseType , <nl> TypeToken <nl> } , <nl> SourcePresence : : Present ) ; <nl> - auto Data = MetatypeTypeSyntaxData : : make ( Raw ) ; <nl> - return MetatypeTypeSyntax { Data , Data . get ( ) } ; <nl> + return make < MetatypeTypeSyntax > ( Raw ) ; <nl> } <nl> <nl> MetatypeTypeSyntax SyntaxFactory : : makeBlankMetatypeType ( ) { <nl> - auto Data = MetatypeTypeSyntaxData : : makeBlank ( ) ; <nl> - return MetatypeTypeSyntax { Data , Data . get ( ) } ; <nl> + return MetatypeTypeSyntax : : makeBlank ( ) ; <nl> } <nl> <nl> # pragma mark - function - type <nl> FunctionTypeSyntax SyntaxFactory : : makeFunctionType ( <nl> ReturnType . getRaw ( ) <nl> } , <nl> SourcePresence : : Present ) ; <nl> - auto Data = FunctionTypeSyntaxData : : make ( Raw ) ; <nl> - return FunctionTypeSyntax { Data , Data . get ( ) } ; <nl> + return make < FunctionTypeSyntax > ( Raw ) ; <nl> } <nl> <nl> FunctionTypeSyntax SyntaxFactory : : makeBlankFunctionType ( ) { <nl> - auto Data = FunctionTypeSyntaxData : : makeBlank ( ) ; <nl> - return FunctionTypeSyntax { Data , Data . get ( ) } ; <nl> + return FunctionTypeSyntax : : makeBlank ( ) ; <nl> } <nl> <nl> # pragma mark - function - type - argument <nl> makeFunctionTypeArgument ( RC < TokenSyntax > ExternalParameterName , <nl> ColonToken , <nl> ParameterTypeSyntax . getRaw ( ) <nl> } , SourcePresence : : Present ) ; <nl> - auto Data = FunctionTypeArgumentSyntaxData : : make ( Raw ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return make < FunctionTypeArgumentSyntax > ( Raw ) ; <nl> } <nl> <nl> FunctionTypeArgumentSyntax SyntaxFactory : : <nl> makeFunctionTypeArgument ( RC < TokenSyntax > LocalParameterName , <nl> ColonToken , <nl> TypeArgument . getRaw ( ) <nl> } , SourcePresence : : Present ) ; <nl> - auto Data = FunctionTypeArgumentSyntaxData : : make ( Raw ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return make < FunctionTypeArgumentSyntax > ( Raw ) ; <nl> } <nl> <nl> FunctionTypeArgumentSyntax <nl> SyntaxFactory : : makeFunctionTypeArgument ( TypeSyntax TypeArgument ) { <nl> TokenSyntax : : missingToken ( tok : : colon , " : " ) , <nl> TypeArgument . getRaw ( ) <nl> } , SourcePresence : : Present ) ; <nl> - auto Data = FunctionTypeArgumentSyntaxData : : make ( Raw ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return make < FunctionTypeArgumentSyntax > ( Raw ) ; <nl> } <nl> <nl> # pragma mark - <nl> # pragma mark type - attributes <nl> <nl> TypeAttributesSyntax SyntaxFactory : : makeBlankTypeAttributes ( ) { <nl> - auto Data = TypeAttributesSyntaxData : : makeBlank ( ) ; <nl> - return TypeAttributesSyntax { Data , Data . get ( ) } ; <nl> + return TypeAttributesSyntax : : makeBlank ( ) ; <nl> } <nl> <nl> TupleTypeElementListSyntax SyntaxFactory : : makeBlankTupleTypeElementList ( ) { <nl> - auto Data = TupleTypeElementListSyntaxData : : makeBlank ( ) ; <nl> - return TupleTypeElementListSyntax { Data , Data . get ( ) } ; <nl> + return TupleTypeElementListSyntax : : makeBlank ( ) ; <nl> } <nl> <nl> # pragma mark - array - type <nl> SyntaxFactory : : makeArrayType ( RC < TokenSyntax > LeftSquareBracket , <nl> RightSquareBracket <nl> } , <nl> SourcePresence : : Present ) ; <nl> - auto Data = ArrayTypeSyntaxData : : make ( Raw ) ; <nl> - return ArrayTypeSyntax { Data , Data . get ( ) } ; <nl> + return make < ArrayTypeSyntax > ( Raw ) ; <nl> } <nl> <nl> ArrayTypeSyntax SyntaxFactory : : makeBlankArrayType ( ) { <nl> - auto Data = ArrayTypeSyntaxData : : makeBlank ( ) ; <nl> - return ArrayTypeSyntax { Data , Data . get ( ) } ; <nl> + return ArrayTypeSyntax : : makeBlank ( ) ; <nl> } <nl> <nl> # pragma mark - dictionary - type <nl> SyntaxFactory : : makeDictionaryType ( RC < TokenSyntax > LeftSquareBracket , <nl> RightSquareBracket <nl> } , <nl> SourcePresence : : Present ) ; <nl> - auto Data = DictionaryTypeSyntaxData : : make ( Raw ) ; <nl> - return DictionaryTypeSyntax { Data , Data . get ( ) } ; <nl> + return make < DictionaryTypeSyntax > ( Raw ) ; <nl> } <nl> <nl> DictionaryTypeSyntax SyntaxFactory : : makeBlankDictionaryType ( ) { <nl> - auto Data = DictionaryTypeSyntaxData : : makeBlank ( ) ; <nl> - return DictionaryTypeSyntax { Data , Data . get ( ) } ; <nl> + return DictionaryTypeSyntax : : makeBlank ( ) ; <nl> } <nl> - <nl> - <nl> mmm a / lib / Syntax / TypeSyntax . cpp <nl> ppp b / lib / Syntax / TypeSyntax . cpp <nl> using namespace swift : : syntax ; <nl> using llvm : : None ; <nl> using llvm : : Optional ; <nl> <nl> - TypeSyntaxData : : TypeSyntaxData ( RC < RawSyntax > Raw , const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : SyntaxData ( Raw , Parent , IndexInParent ) { } <nl> - <nl> - TypeSyntax : : TypeSyntax ( RC < SyntaxData > Root , const TypeSyntaxData * Data ) <nl> - : Syntax ( Root , Data ) { } <nl> - <nl> # pragma mark - balanced - tokens Data <nl> <nl> - BalancedTokensSyntaxData : : BalancedTokensSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : SyntaxData ( Raw , Parent , IndexInParent ) { <nl> - assert ( Raw - > Kind = = SyntaxKind : : BalancedTokens ) ; <nl> + void BalancedTokensSyntax : : validate ( ) const { <nl> + assert ( Data - > Raw - > Kind = = SyntaxKind : : BalancedTokens ) ; <nl> / / TODO : Add some checks here that each element of raw syntax <nl> / / matches the grammar rules in the doc comment of <nl> / / this class . <nl> } <nl> <nl> - RC < BalancedTokensSyntaxData > <nl> - BalancedTokensSyntaxData : : make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - return RC < BalancedTokensSyntaxData > { <nl> - new BalancedTokensSyntaxData { Raw , Parent , IndexInParent } <nl> - } ; <nl> - } <nl> - <nl> - RC < BalancedTokensSyntaxData > BalancedTokensSyntaxData : : makeBlank ( ) { <nl> - return make ( RawSyntax : : make ( SyntaxKind : : BalancedTokens , { } , <nl> - SourcePresence : : Present ) ) ; <nl> + BalancedTokensSyntax BalancedTokensSyntax : : makeBlank ( ) { <nl> + auto Raw = RawSyntax : : make ( SyntaxKind : : BalancedTokens , { } , <nl> + SourcePresence : : Present ) ; <nl> + return make < BalancedTokensSyntax > ( Raw ) ; <nl> } <nl> <nl> # pragma mark - balanced - tokens API <nl> <nl> - BalancedTokensSyntax : : BalancedTokensSyntax ( RC < SyntaxData > Root , <nl> - const BalancedTokensSyntaxData * Data ) <nl> - : Syntax ( Root , Data ) { } <nl> - <nl> BalancedTokensSyntax <nl> BalancedTokensSyntax : : addBalancedToken ( RC < TokenSyntax > NewBalancedToken ) const { <nl> # ifndef NDEBUG <nl> BalancedTokensSyntax : : addBalancedToken ( RC < TokenSyntax > NewBalancedToken ) const { <nl> <nl> # pragma mark - type - attribute Data <nl> <nl> - TypeAttributeSyntaxData : : TypeAttributeSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : SyntaxData ( Raw , Parent , IndexInParent ) { <nl> + void TypeAttributeSyntax : : validate ( ) const { <nl> + auto Raw = Data - > Raw ; <nl> assert ( Raw - > Kind = = SyntaxKind : : TypeAttribute ) ; <nl> assert ( Raw - > Layout . size ( ) = = 5 ) ; <nl> syntax_assert_child_token_text ( Raw , <nl> TypeAttributeSyntaxData : : TypeAttributeSyntaxData ( RC < RawSyntax > Raw , <nl> " ) " ) ; <nl> } <nl> <nl> - RC < TypeAttributeSyntaxData > <nl> - TypeAttributeSyntaxData : : make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - return RC < TypeAttributeSyntaxData > { <nl> - new TypeAttributeSyntaxData { Raw , Parent , IndexInParent } <nl> - } ; <nl> - } <nl> + # pragma mark - type - attribute API <nl> <nl> - RC < TypeAttributeSyntaxData > TypeAttributeSyntaxData : : makeBlank ( ) { <nl> + TypeAttributeSyntax TypeAttributeSyntax : : makeBlank ( ) { <nl> auto Raw = RawSyntax : : make ( SyntaxKind : : TypeAttribute , <nl> { <nl> TokenSyntax : : missingToken ( tok : : at_sign , " @ " ) , <nl> RC < TypeAttributeSyntaxData > TypeAttributeSyntaxData : : makeBlank ( ) { <nl> TokenSyntax : : missingToken ( tok : : r_paren , " ) " ) , <nl> } , <nl> SourcePresence : : Present ) ; <nl> - return make ( Raw ) ; <nl> + return make < TypeAttributeSyntax > ( Raw ) ; <nl> } <nl> <nl> - # pragma mark - type - attribute API <nl> - <nl> - TypeAttributeSyntax : : TypeAttributeSyntax ( RC < SyntaxData > Root , <nl> - const TypeAttributeSyntaxData * Data ) <nl> - : Syntax ( Root , Data ) { } <nl> - <nl> TypeAttributeSyntax <nl> TypeAttributeSyntax : : withAtSignToken ( RC < TokenSyntax > NewAtSignToken ) const { <nl> syntax_assert_token_is ( NewAtSignToken , tok : : at_sign , " @ " ) ; <nl> withRightParenToken ( RC < TokenSyntax > NewRightParenToken ) const { <nl> Cursor : : RightParenToken ) ; <nl> } ; <nl> <nl> - # pragma mark - type - attributes Data <nl> - <nl> - TypeAttributesSyntaxData : : TypeAttributesSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : SyntaxData ( Raw , Parent , IndexInParent ) { <nl> - / / TODO : kind assertions <nl> - } <nl> - <nl> - RC < TypeAttributesSyntaxData > <nl> - TypeAttributesSyntaxData : : make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - return RC < TypeAttributesSyntaxData > { <nl> - new TypeAttributesSyntaxData { Raw , Parent , IndexInParent } <nl> - } ; <nl> - } <nl> - <nl> - RC < TypeAttributesSyntaxData > TypeAttributesSyntaxData : : makeBlank ( ) { <nl> - return make ( RawSyntax : : make ( SyntaxKind : : TypeAttributes , { } , <nl> - SourcePresence : : Present ) ) ; <nl> - } <nl> - <nl> - # pragma mark - type - attributes API <nl> - <nl> - TypeAttributesSyntax : : <nl> - TypeAttributesSyntax ( RC < SyntaxData > Root , const TypeAttributesSyntaxData * Data ) <nl> - : Syntax ( Root , Data ) { } <nl> - <nl> - TypeAttributesSyntax TypeAttributesSyntax : : <nl> - addTypeAttribute ( TypeAttributeSyntax NewTypeAttribute ) const { <nl> - auto Layout = getRaw ( ) - > Layout ; <nl> - Layout . push_back ( NewTypeAttribute . getRaw ( ) ) ; <nl> - auto NewRaw = RawSyntax : : make ( SyntaxKind : : TypeAttributes , Layout , <nl> - SourcePresence : : Present ) ; <nl> - return Data - > replaceSelf < TypeAttributesSyntax > ( NewRaw ) ; <nl> - } <nl> - <nl> - # pragma mark - type - identifier Data <nl> + # pragma mark - type - identifier API <nl> <nl> - TypeIdentifierSyntaxData : : TypeIdentifierSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : TypeSyntaxData ( Raw , Parent , IndexInParent ) { <nl> + void TypeIdentifierSyntax : : validate ( ) const { <nl> + auto Raw = Data - > Raw ; <nl> assert ( Raw - > Kind = = SyntaxKind : : TypeIdentifier ) ; <nl> assert ( Raw - > Layout . size ( ) = = 4 ) ; <nl> syntax_assert_child_token ( Raw , TypeIdentifierSyntax : : Cursor : : Identifier , <nl> TypeIdentifierSyntaxData : : TypeIdentifierSyntaxData ( RC < RawSyntax > Raw , <nl> SyntaxKind : : TypeIdentifier ) ; <nl> } <nl> <nl> - RC < TypeIdentifierSyntaxData > <nl> - TypeIdentifierSyntaxData : : make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - return RC < TypeIdentifierSyntaxData > { <nl> - new TypeIdentifierSyntaxData { Raw , Parent , IndexInParent } <nl> - } ; <nl> - } <nl> - <nl> - RC < TypeIdentifierSyntaxData > <nl> - TypeIdentifierSyntaxData : : makeBlank ( ) { <nl> - return make ( RawSyntax : : make ( <nl> + TypeIdentifierSyntax TypeIdentifierSyntax : : makeBlank ( ) { <nl> + return make < TypeIdentifierSyntax > ( RawSyntax : : make ( <nl> SyntaxKind : : TypeIdentifier , <nl> { <nl> TokenSyntax : : missingToken ( tok : : identifier , " " ) , <nl> TypeIdentifierSyntaxData : : makeBlank ( ) { <nl> SourcePresence : : Present ) ) ; <nl> } <nl> <nl> - # pragma mark - type - identifier API <nl> - <nl> - TypeIdentifierSyntax : : TypeIdentifierSyntax ( RC < SyntaxData > Root , <nl> - const TypeIdentifierSyntaxData * Data ) <nl> - : TypeSyntax ( Root , Data ) { } <nl> - <nl> TypeIdentifierSyntax <nl> TypeIdentifierSyntax : : addChildType ( TypeIdentifierSyntax ChildType ) const { <nl> auto MaybeChild = getRaw ( ) - > getChild ( Cursor : : ChildTypeIdentifier ) ; <nl> TypeIdentifierSyntax : : withDotToken ( RC < TokenSyntax > NewDotToken ) const { <nl> return Data - > replaceSelf < TypeIdentifierSyntax > ( NewRaw ) ; <nl> } <nl> <nl> - # pragma mark - tuple - type Data <nl> + # pragma mark - tuple - type API <nl> <nl> - TupleTypeSyntaxData : : TupleTypeSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : TypeSyntaxData ( Raw , Parent , IndexInParent ) { <nl> + void TupleTypeSyntax : : validate ( ) const { <nl> + auto Raw = Data - > Raw ; <nl> assert ( Raw - > Kind = = SyntaxKind : : TupleType ) ; <nl> assert ( Raw - > Layout . size ( ) = = 3 ) ; <nl> syntax_assert_child_token_text ( Raw , TupleTypeSyntax : : Cursor : : LeftParenToken , <nl> TupleTypeSyntaxData : : TupleTypeSyntaxData ( RC < RawSyntax > Raw , <nl> " ) " ) ; <nl> } <nl> <nl> - RC < TupleTypeSyntaxData > <nl> - TupleTypeSyntaxData : : make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - return RC < TupleTypeSyntaxData > { <nl> - new TupleTypeSyntaxData { Raw , Parent , IndexInParent } <nl> - } ; <nl> - } <nl> - <nl> - RC < TupleTypeSyntaxData > <nl> - TupleTypeSyntaxData : : makeBlank ( ) { <nl> - return make ( <nl> + TupleTypeSyntax <nl> + TupleTypeSyntax : : makeBlank ( ) { <nl> + return make < TupleTypeSyntax > ( <nl> RawSyntax : : make ( SyntaxKind : : TupleType , <nl> { <nl> TokenSyntax : : missingToken ( tok : : l_paren , " ( " ) , <nl> TupleTypeSyntaxData : : makeBlank ( ) { <nl> SourcePresence : : Present ) ) ; <nl> } <nl> <nl> - # pragma mark - tuple - type API <nl> - <nl> - TupleTypeSyntax : : TupleTypeSyntax ( RC < SyntaxData > Root , <nl> - const TupleTypeSyntaxData * Data ) <nl> - : TypeSyntax ( Root , Data ) { } <nl> - <nl> TupleTypeSyntax <nl> TupleTypeSyntax : : withLeftParen ( RC < TokenSyntax > NewLeftParen ) const { <nl> syntax_assert_token_is ( NewLeftParen , tok : : l_paren , " ( " ) ; <nl> TupleTypeSyntax TupleTypeSyntaxBuilder : : build ( ) const { <nl> RightParenToken , <nl> } , <nl> SourcePresence : : Present ) ; <nl> - auto Data = TupleTypeSyntaxData : : make ( Raw ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return make < TupleTypeSyntax > ( Raw ) ; <nl> } <nl> <nl> - # pragma mark - tuple - type - element Data <nl> + # pragma mark - tuple - type - element API <nl> <nl> - TupleTypeElementSyntaxData : : <nl> - TupleTypeElementSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : SyntaxData ( Raw , Parent , IndexInParent ) { <nl> + void TupleTypeElementSyntax : : validate ( ) const { <nl> + auto Raw = Data - > Raw ; <nl> assert ( Raw - > Kind = = SyntaxKind : : TupleTypeElement ) ; <nl> assert ( Raw - > Layout . size ( ) = = 6 ) ; <nl> syntax_assert_child_token ( Raw , TupleTypeElementSyntax : : Cursor : : Label , <nl> TupleTypeElementSyntaxData ( RC < RawSyntax > Raw , <nl> assert ( Raw - > getChild ( TupleTypeElementSyntax : : Cursor : : Type ) - > isType ( ) ) ; <nl> } <nl> <nl> - RC < TupleTypeElementSyntaxData > <nl> - TupleTypeElementSyntaxData : : make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - return RC < TupleTypeElementSyntaxData > { <nl> - new TupleTypeElementSyntaxData { Raw , Parent , IndexInParent } <nl> - } ; <nl> - } <nl> - <nl> - RC < TupleTypeElementSyntaxData > <nl> - TupleTypeElementSyntaxData : : makeBlank ( ) { <nl> - return make ( <nl> + TupleTypeElementSyntax TupleTypeElementSyntax : : makeBlank ( ) { <nl> + return make < TupleTypeElementSyntax > ( <nl> RawSyntax : : make ( SyntaxKind : : TupleTypeElement , <nl> { <nl> TokenSyntax : : missingToken ( tok : : identifier , " " ) , <nl> TupleTypeElementSyntaxData : : makeBlank ( ) { <nl> SourcePresence : : Present ) ) ; <nl> } <nl> <nl> - # pragma mark - tuple - type - element API <nl> - <nl> - TupleTypeElementSyntax : : <nl> - TupleTypeElementSyntax ( RC < SyntaxData > Root , <nl> - const TupleTypeElementSyntaxData * Data ) <nl> - : Syntax ( Root , Data ) { } <nl> <nl> RC < TokenSyntax > <nl> TupleTypeElementSyntax : : getLabel ( ) const { <nl> TupleTypeElementSyntax : : withTypeSyntax ( TypeSyntax NewTypeSyntax ) const { <nl> return Data - > replaceSelf < TupleTypeElementSyntax > ( NewRaw ) ; <nl> } <nl> <nl> - # pragma mark - metatype - type Data <nl> + # pragma mark - metatype - type API <nl> <nl> - MetatypeTypeSyntaxData : : MetatypeTypeSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : TypeSyntaxData ( Raw , Parent , IndexInParent ) { <nl> + void MetatypeTypeSyntax : : validate ( ) const { <nl> + auto Raw = Data - > Raw ; <nl> assert ( Raw - > Kind = = SyntaxKind : : MetatypeType ) ; <nl> assert ( Raw - > Layout . size ( ) = = 3 ) ; <nl> assert ( Raw - > getChild ( MetatypeTypeSyntax : : Cursor : : BaseType ) - > isType ( ) ) ; <nl> MetatypeTypeSyntaxData : : MetatypeTypeSyntaxData ( RC < RawSyntax > Raw , <nl> tok : : identifier ) ; <nl> } <nl> <nl> - RC < MetatypeTypeSyntaxData > <nl> - MetatypeTypeSyntaxData : : make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - return RC < MetatypeTypeSyntaxData > { <nl> - new MetatypeTypeSyntaxData { Raw , Parent , IndexInParent } <nl> - } ; <nl> - } <nl> - <nl> - RC < MetatypeTypeSyntaxData > MetatypeTypeSyntaxData : : makeBlank ( ) { <nl> - return make ( RawSyntax : : make ( SyntaxKind : : MetatypeType , <nl> - { <nl> - RawSyntax : : missing ( SyntaxKind : : MissingType ) , <nl> - TokenSyntax : : missingToken ( tok : : period , " . " ) , <nl> - TokenSyntax : : missingToken ( tok : : identifier , " " ) , <nl> - } , <nl> - SourcePresence : : Present ) ) ; <nl> + MetatypeTypeSyntax MetatypeTypeSyntax : : makeBlank ( ) { <nl> + auto Raw = RawSyntax : : make ( SyntaxKind : : MetatypeType , <nl> + { <nl> + RawSyntax : : missing ( SyntaxKind : : MissingType ) , <nl> + TokenSyntax : : missingToken ( tok : : period , " . " ) , <nl> + TokenSyntax : : missingToken ( tok : : identifier , " " ) , <nl> + } , <nl> + SourcePresence : : Present ) ; <nl> + return make < MetatypeTypeSyntax > ( Raw ) ; <nl> } <nl> <nl> - # pragma mark - metatype - type API <nl> - <nl> - MetatypeTypeSyntax : : MetatypeTypeSyntax ( RC < SyntaxData > Root , <nl> - const MetatypeTypeSyntaxData * Data ) <nl> - : TypeSyntax ( Root , Data ) { } <nl> - <nl> MetatypeTypeSyntax <nl> MetatypeTypeSyntax : : withBaseTypeSyntax ( TypeSyntax NewBaseTypeSyntax ) const { <nl> auto NewRaw = getRaw ( ) - > replaceChild ( Cursor : : BaseType , <nl> MetatypeTypeSyntax : : withTypeToken ( RC < TokenSyntax > NewTypeToken ) const { <nl> return Data - > replaceSelf < MetatypeTypeSyntax > ( NewRaw ) ; <nl> } <nl> <nl> - # pragma mark - optional - type Data <nl> + # pragma mark - optional - type API <nl> <nl> - OptionalTypeSyntaxData : : OptionalTypeSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : TypeSyntaxData ( Raw , Parent , IndexInParent ) { <nl> + void OptionalTypeSyntax : : validate ( ) const { <nl> + auto Raw = Data - > Raw ; <nl> assert ( Raw - > Kind = = SyntaxKind : : OptionalType ) ; <nl> assert ( Raw - > Layout . size ( ) = = 2 ) ; <nl> assert ( Raw - > getChild ( OptionalTypeSyntax : : Cursor : : BaseType ) - > isType ( ) ) ; <nl> OptionalTypeSyntaxData : : OptionalTypeSyntaxData ( RC < RawSyntax > Raw , <nl> tok : : question_postfix , " ? " ) ; <nl> } <nl> <nl> - RC < OptionalTypeSyntaxData > <nl> - OptionalTypeSyntaxData : : make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - return RC < OptionalTypeSyntaxData > { <nl> - new OptionalTypeSyntaxData { Raw , Parent , IndexInParent } <nl> - } ; <nl> - } <nl> - <nl> - RC < OptionalTypeSyntaxData > OptionalTypeSyntaxData : : makeBlank ( ) { <nl> - return make ( RawSyntax : : make ( SyntaxKind : : OptionalType , <nl> + OptionalTypeSyntax OptionalTypeSyntax : : makeBlank ( ) { <nl> + return make < OptionalTypeSyntax > ( RawSyntax : : make ( SyntaxKind : : OptionalType , <nl> { <nl> RawSyntax : : missing ( SyntaxKind : : MissingType ) , <nl> TokenSyntax : : missingToken ( tok : : question_postfix , " ? " ) , <nl> RC < OptionalTypeSyntaxData > OptionalTypeSyntaxData : : makeBlank ( ) { <nl> SourcePresence : : Present ) ) ; <nl> } <nl> <nl> - # pragma mark - optional - type API <nl> - <nl> - OptionalTypeSyntax : : OptionalTypeSyntax ( RC < SyntaxData > Root , <nl> - const OptionalTypeSyntaxData * Data ) <nl> - : TypeSyntax ( Root , Data ) { } <nl> - <nl> OptionalTypeSyntax <nl> OptionalTypeSyntax : : withBaseTypeSyntax ( TypeSyntax NewTypeSyntax ) const { <nl> auto NewRaw = getRaw ( ) - > replaceChild ( Cursor : : BaseType , NewTypeSyntax . getRaw ( ) ) ; <nl> OptionalTypeSyntax : : withQuestionToken ( RC < TokenSyntax > NewQuestionToken ) const { <nl> return Data - > replaceSelf < OptionalTypeSyntax > ( NewRaw ) ; <nl> } <nl> <nl> - # pragma mark - implicitly - unwrapped - optional - type Data <nl> + # pragma mark - implicitly - unwrapped - optional - type API <nl> <nl> - ImplicitlyUnwrappedOptionalTypeSyntaxData : : <nl> - ImplicitlyUnwrappedOptionalTypeSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : TypeSyntaxData ( Raw , Parent , IndexInParent ) { <nl> + void ImplicitlyUnwrappedOptionalTypeSyntax : : validate ( ) const { <nl> + auto Raw = Data - > Raw ; <nl> assert ( Raw - > Kind = = SyntaxKind : : ImplicitlyUnwrappedOptionalType ) ; <nl> assert ( Raw - > Layout . size ( ) = = 2 ) ; <nl> assert ( Raw - > getChild ( ImplicitlyUnwrappedOptionalTypeSyntax : : Cursor : : Type ) <nl> ImplicitlyUnwrappedOptionalTypeSyntaxData ( RC < RawSyntax > Raw , <nl> tok : : exclaim_postfix , " ! " ) ; <nl> } <nl> <nl> - RC < ImplicitlyUnwrappedOptionalTypeSyntaxData > <nl> - ImplicitlyUnwrappedOptionalTypeSyntaxData : : make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - return RC < ImplicitlyUnwrappedOptionalTypeSyntaxData > { <nl> - new ImplicitlyUnwrappedOptionalTypeSyntaxData { Raw , Parent , IndexInParent } <nl> - } ; <nl> + ImplicitlyUnwrappedOptionalTypeSyntax <nl> + ImplicitlyUnwrappedOptionalTypeSyntax : : makeBlank ( ) { <nl> + auto Raw = RawSyntax : : make ( <nl> + SyntaxKind : : ImplicitlyUnwrappedOptionalType , <nl> + { <nl> + RawSyntax : : missing ( SyntaxKind : : MissingType ) , <nl> + TokenSyntax : : missingToken ( tok : : exclaim_postfix , " ! " ) , <nl> + } , <nl> + SourcePresence : : Present ) ; <nl> + return make < ImplicitlyUnwrappedOptionalTypeSyntax > ( Raw ) ; <nl> } <nl> <nl> - RC < ImplicitlyUnwrappedOptionalTypeSyntaxData > <nl> - ImplicitlyUnwrappedOptionalTypeSyntaxData : : makeBlank ( ) { <nl> - return make ( RawSyntax : : make ( SyntaxKind : : ImplicitlyUnwrappedOptionalType , <nl> - { <nl> - RawSyntax : : missing ( SyntaxKind : : MissingType ) , <nl> - TokenSyntax : : missingToken ( tok : : exclaim_postfix , " ! " ) , <nl> - } , <nl> - SourcePresence : : Present ) ) ; <nl> - } <nl> - <nl> - # pragma mark - implicitly - unwrapped - optional - type API <nl> - <nl> - ImplicitlyUnwrappedOptionalTypeSyntax : : <nl> - ImplicitlyUnwrappedOptionalTypeSyntax ( RC < SyntaxData > Root , <nl> - const ImplicitlyUnwrappedOptionalTypeSyntaxData * Data ) <nl> - : TypeSyntax ( Root , Data ) { } <nl> - <nl> ImplicitlyUnwrappedOptionalTypeSyntax ImplicitlyUnwrappedOptionalTypeSyntax : : <nl> withBaseTypeSyntax ( TypeSyntax NewTypeSyntax ) const { <nl> auto NewRaw = getRaw ( ) - > replaceChild ( Cursor : : Type , NewTypeSyntax . getRaw ( ) ) ; <nl> withExclaimToken ( RC < TokenSyntax > NewExclaimToken ) const { <nl> return Data - > replaceSelf < ImplicitlyUnwrappedOptionalTypeSyntax > ( NewRaw ) ; <nl> } <nl> <nl> - # pragma mark - array - type Data <nl> + # pragma mark - array - type API <nl> <nl> - ArrayTypeSyntaxData : : ArrayTypeSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : TypeSyntaxData ( Raw , Parent , IndexInParent ) { <nl> + void ArrayTypeSyntax : : validate ( ) const { <nl> + auto Raw = Data - > Raw ; <nl> assert ( Raw - > Kind = = SyntaxKind : : ArrayType ) ; <nl> assert ( Raw - > Layout . size ( ) = = 3 ) ; <nl> syntax_assert_child_token_text ( Raw , <nl> ArrayTypeSyntaxData : : ArrayTypeSyntaxData ( RC < RawSyntax > Raw , <nl> tok : : r_square , " ] " ) ; <nl> } <nl> <nl> - RC < ArrayTypeSyntaxData > ArrayTypeSyntaxData : : make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - return RC < ArrayTypeSyntaxData > { <nl> - new ArrayTypeSyntaxData { Raw , Parent , IndexInParent } <nl> - } ; <nl> - } <nl> - <nl> - RC < ArrayTypeSyntaxData > ArrayTypeSyntaxData : : makeBlank ( ) { <nl> - return make ( RawSyntax : : make ( SyntaxKind : : ArrayType , <nl> - { <nl> - TokenSyntax : : missingToken ( tok : : l_square , " [ " ) , <nl> - RawSyntax : : missing ( SyntaxKind : : MissingType ) , <nl> - TokenSyntax : : missingToken ( tok : : r_square , " ] " ) , <nl> - } , <nl> - SourcePresence : : Present ) ) ; <nl> + ArrayTypeSyntax ArrayTypeSyntax : : makeBlank ( ) { <nl> + auto Raw = RawSyntax : : make ( SyntaxKind : : ArrayType , <nl> + { <nl> + TokenSyntax : : missingToken ( tok : : l_square , " [ " ) , <nl> + RawSyntax : : missing ( SyntaxKind : : MissingType ) , <nl> + TokenSyntax : : missingToken ( tok : : r_square , " ] " ) , <nl> + } , <nl> + SourcePresence : : Present ) ; <nl> + return make < ArrayTypeSyntax > ( Raw ) ; <nl> } <nl> <nl> - # pragma mark - array - type API <nl> - <nl> - ArrayTypeSyntax : : ArrayTypeSyntax ( RC < SyntaxData > Root , <nl> - const ArrayTypeSyntaxData * Data ) <nl> - : TypeSyntax ( Root , Data ) { } <nl> - <nl> ArrayTypeSyntax ArrayTypeSyntax : : <nl> withLeftSquareBracketToken ( RC < TokenSyntax > NewLeftSquareBracketToken ) const { <nl> syntax_assert_token_is ( NewLeftSquareBracketToken , tok : : l_square , " [ " ) ; <nl> withRightSquareBracketToken ( RC < TokenSyntax > NewRightSquareBracketToken ) const { <nl> return Data - > replaceSelf < ArrayTypeSyntax > ( NewRaw ) ; <nl> } <nl> <nl> - # pragma mark - dictionary - type Data <nl> + # pragma mark - dictionary - type API <nl> <nl> - DictionaryTypeSyntaxData : : DictionaryTypeSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : TypeSyntaxData ( Raw , Parent , IndexInParent ) { <nl> + void DictionaryTypeSyntax : : validate ( ) const { <nl> + auto Raw = Data - > Raw ; <nl> assert ( Raw - > Kind = = SyntaxKind : : DictionaryType ) ; <nl> assert ( Raw - > Layout . size ( ) = = 5 ) ; <nl> <nl> DictionaryTypeSyntaxData : : DictionaryTypeSyntaxData ( RC < RawSyntax > Raw , <nl> tok : : r_square , " ] " ) ; <nl> } <nl> <nl> - RC < DictionaryTypeSyntaxData > <nl> - DictionaryTypeSyntaxData : : make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - return RC < DictionaryTypeSyntaxData > { <nl> - new DictionaryTypeSyntaxData { Raw , Parent , IndexInParent } <nl> - } ; <nl> - } <nl> - <nl> - RC < DictionaryTypeSyntaxData > <nl> - DictionaryTypeSyntaxData : : makeBlank ( ) { <nl> - return make ( RawSyntax : : make ( SyntaxKind : : DictionaryType , <nl> - { <nl> - TokenSyntax : : missingToken ( tok : : l_square , " [ " ) , <nl> - RawSyntax : : missing ( SyntaxKind : : MissingType ) , <nl> - TokenSyntax : : missingToken ( tok : : colon , " : " ) , <nl> - RawSyntax : : missing ( SyntaxKind : : MissingType ) , <nl> - TokenSyntax : : missingToken ( tok : : r_square , " ] " ) , <nl> - } , <nl> - SourcePresence : : Present ) ) ; <nl> + DictionaryTypeSyntax DictionaryTypeSyntax : : makeBlank ( ) { <nl> + auto Raw = RawSyntax : : make ( SyntaxKind : : DictionaryType , <nl> + { <nl> + TokenSyntax : : missingToken ( tok : : l_square , " [ " ) , <nl> + RawSyntax : : missing ( SyntaxKind : : MissingType ) , <nl> + TokenSyntax : : missingToken ( tok : : colon , " : " ) , <nl> + RawSyntax : : missing ( SyntaxKind : : MissingType ) , <nl> + TokenSyntax : : missingToken ( tok : : r_square , " ] " ) , <nl> + } , <nl> + SourcePresence : : Present ) ; <nl> + return make < DictionaryTypeSyntax > ( Raw ) ; <nl> } <nl> <nl> - # pragma mark - dictionary - type API <nl> - <nl> - DictionaryTypeSyntax : : DictionaryTypeSyntax ( RC < SyntaxData > Root , <nl> - const DictionaryTypeSyntaxData * Data ) <nl> - : TypeSyntax ( Root , Data ) { } <nl> - <nl> DictionaryTypeSyntax DictionaryTypeSyntax : : <nl> withLeftSquareBracketToken ( RC < TokenSyntax > NewLeftSquareBracketToken ) const { <nl> syntax_assert_token_is ( NewLeftSquareBracketToken , tok : : l_square , " [ " ) ; <nl> withRightSquareBracketToken ( RC < TokenSyntax > NewRightSquareBracketToken ) const { <nl> return Data - > replaceSelf < DictionaryTypeSyntax > ( NewRaw ) ; <nl> } <nl> <nl> - # pragma mark - function - type - argument Data <nl> - <nl> - FunctionTypeArgumentSyntaxData : : <nl> - FunctionTypeArgumentSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : SyntaxData ( Raw , Parent , IndexInParent ) { } <nl> + # pragma mark - function - type - argument API <nl> <nl> - RC < FunctionTypeArgumentSyntaxData > <nl> - FunctionTypeArgumentSyntaxData : : make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - return RC < FunctionTypeArgumentSyntaxData > { <nl> - new FunctionTypeArgumentSyntaxData { Raw , Parent , IndexInParent } <nl> - } ; <nl> - } <nl> + void FunctionTypeArgumentSyntax : : validate ( ) const { } <nl> <nl> - RC < FunctionTypeArgumentSyntaxData > <nl> - FunctionTypeArgumentSyntaxData : : makeBlank ( ) { <nl> + FunctionTypeArgumentSyntax FunctionTypeArgumentSyntax : : makeBlank ( ) { <nl> auto Raw = RawSyntax : : make ( SyntaxKind : : FunctionTypeArgument , <nl> { <nl> TokenSyntax : : missingToken ( tok : : identifier , " " ) , <nl> FunctionTypeArgumentSyntaxData : : makeBlank ( ) { <nl> TokenSyntax : : missingToken ( tok : : colon , " , " ) , <nl> } , <nl> SourcePresence : : Present ) ; <nl> - return make ( Raw ) ; <nl> + return make < FunctionTypeArgumentSyntax > ( Raw ) ; <nl> } <nl> <nl> - # pragma mark - function - type - argument API <nl> - <nl> - FunctionTypeArgumentSyntax : : <nl> - FunctionTypeArgumentSyntax ( RC < SyntaxData > Root , <nl> - const FunctionTypeArgumentSyntaxData * Data ) <nl> - : Syntax ( Root , Data ) { } <nl> - <nl> - # pragma mark - function - type Data <nl> + # pragma mark - function - type API <nl> <nl> - FunctionTypeSyntaxData : : FunctionTypeSyntaxData ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) <nl> - : TypeSyntaxData ( Raw , Parent , IndexInParent ) { <nl> + void FunctionTypeSyntax : : validate ( ) const { <nl> + auto Raw = Data - > Raw ; <nl> assert ( Raw - > Kind = = SyntaxKind : : FunctionType ) ; <nl> syntax_assert_child_kind ( Raw , FunctionTypeSyntax : : Cursor : : TypeAttributes , <nl> SyntaxKind : : TypeAttributes ) ; <nl> FunctionTypeSyntaxData : : FunctionTypeSyntaxData ( RC < RawSyntax > Raw , <nl> assert ( Raw - > getChild ( FunctionTypeSyntax : : Cursor : : ReturnType ) - > isType ( ) ) ; <nl> } <nl> <nl> - RC < FunctionTypeSyntaxData > <nl> - FunctionTypeSyntaxData : : make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - return RC < FunctionTypeSyntaxData > { <nl> - new FunctionTypeSyntaxData { Raw , Parent , IndexInParent } <nl> - } ; <nl> - } <nl> - <nl> - RC < FunctionTypeSyntaxData > FunctionTypeSyntaxData : : makeBlank ( ) { <nl> - return make ( RawSyntax : : make ( SyntaxKind : : FunctionType , <nl> + FunctionTypeSyntax FunctionTypeSyntax : : makeBlank ( ) { <nl> + return make < FunctionTypeSyntax > ( RawSyntax : : make ( SyntaxKind : : FunctionType , <nl> { <nl> RawSyntax : : missing ( SyntaxKind : : TypeAttributes ) , <nl> TokenSyntax : : missingToken ( tok : : l_paren , " ( " ) , <nl> RC < FunctionTypeSyntaxData > FunctionTypeSyntaxData : : makeBlank ( ) { <nl> SourcePresence : : Present ) ) ; <nl> } <nl> <nl> - # pragma mark - function - type API <nl> - <nl> - FunctionTypeSyntax : : FunctionTypeSyntax ( RC < SyntaxData > Root , <nl> - const FunctionTypeSyntaxData * Data ) <nl> - : TypeSyntax ( Root , Data ) { } <nl> - <nl> FunctionTypeSyntax FunctionTypeSyntax : : <nl> withTypeAttributes ( TypeAttributesSyntax NewAttributes ) const { <nl> auto NewRaw = getRaw ( ) - > replaceChild ( Cursor : : TypeAttributes , <nl> FunctionTypeSyntaxBuilder : : useReturnTypeSyntax ( TypeSyntax NewReturnType ) { <nl> FunctionTypeSyntax FunctionTypeSyntaxBuilder : : build ( ) const { <nl> auto Raw = RawSyntax : : make ( SyntaxKind : : FunctionType , FunctionTypeLayout , <nl> SourcePresence : : Present ) ; <nl> - auto Data = FunctionTypeSyntaxData : : make ( Raw ) ; <nl> - return { Data , Data . get ( ) } ; <nl> + return make < FunctionTypeSyntax > ( Raw ) ; <nl> } <nl> mmm a / lib / Syntax / UnknownSyntax . cpp <nl> ppp b / lib / Syntax / UnknownSyntax . cpp <nl> <nl> using namespace swift ; <nl> using namespace swift : : syntax ; <nl> <nl> - # pragma mark - unknown - syntax Data <nl> - <nl> - UnknownSyntaxData : : UnknownSyntaxData ( const RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - const CursorIndex IndexInParent ) <nl> - : SyntaxData ( Raw , Parent , IndexInParent ) { <nl> - assert ( Raw - > isUnknown ( ) ) ; <nl> - for ( auto RawChild : Raw - > Layout ) { <nl> - if ( ! RawChild - > isToken ( ) ) { <nl> - CachedChildren . emplace_back ( nullptr ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - RC < UnknownSyntaxData > UnknownSyntaxData : : make ( RC < RawSyntax > Raw , <nl> - const SyntaxData * Parent , <nl> - CursorIndex IndexInParent ) { <nl> - <nl> - auto UnknownRaw = RawSyntax : : make ( SyntaxKind : : Unknown , Raw - > Layout , <nl> - Raw - > Presence ) ; <nl> - <nl> - return RC < UnknownSyntaxData > { <nl> - new UnknownSyntaxData { UnknownRaw , Parent , IndexInParent } <nl> - } ; <nl> + void UnknownSyntax : : validate ( ) const { <nl> + assert ( Data - > Raw - > isUnknown ( ) ) ; <nl> } <nl> <nl> # pragma mark - unknown - syntax API <nl> <nl> - UnknownSyntax : : UnknownSyntax ( const RC < SyntaxData > Root , <nl> - const UnknownSyntaxData * Data ) <nl> - : Syntax ( Root , Data ) { } <nl> - <nl> size_t UnknownSyntax : : getNumChildren ( ) const { <nl> - size_t Count = 0 ; <nl> + size_t NonTokenChildren = 0 ; <nl> for ( auto Child : getRaw ( ) - > Layout ) { <nl> - if ( Child - > isToken ( ) ) { <nl> - continue ; <nl> + if ( ! Child - > isToken ( ) ) { <nl> + + + NonTokenChildren ; <nl> } <nl> - + + Count ; <nl> } <nl> - return Count ; <nl> + return NonTokenChildren ; <nl> } <nl> <nl> Syntax UnknownSyntax : : getChild ( const size_t N ) const { <nl> - auto * MyData = getUnsafeData < UnknownSyntax > ( ) ; <nl> - <nl> - if ( auto RealizedChild = MyData - > CachedChildren [ N ] ) { <nl> - return Syntax { Root , RealizedChild . get ( ) } ; <nl> - } <nl> - <nl> - assert ( N < getNumChildren ( ) ) ; <nl> - assert ( N < getRaw ( ) - > Layout . size ( ) ) ; <nl> - <nl> - CursorIndex ChildLayoutIndex = 0 ; <nl> - <nl> - for ( size_t LayoutIndex = 0 , Left = N ; <nl> - LayoutIndex < getRaw ( ) - > Layout . size ( ) ; <nl> - + + LayoutIndex ) { <nl> - auto Child = getRaw ( ) - > Layout [ LayoutIndex ] ; <nl> - if ( Child - > isToken ( ) ) { <nl> - continue ; <nl> - } <nl> - ChildLayoutIndex = LayoutIndex ; <nl> - if ( Left = = 0 ) { <nl> - break ; <nl> + / / The actual index of the Nth non - token child . <nl> + size_t ActualIndex = 0 ; <nl> + / / The number of non - token children we ' ve seen . <nl> + size_t NumNonTokenSeen = 0 ; <nl> + for ( auto Child : getRaw ( ) - > Layout ) { <nl> + / / If we see a child that ' s not a token , count it . <nl> + if ( ! Child - > isToken ( ) ) { <nl> + + + NumNonTokenSeen ; <nl> } <nl> - - - Left ; <nl> - } <nl> - <nl> - auto RawChild = getRaw ( ) - > Layout [ ChildLayoutIndex ] ; <nl> - assert ( RawChild - > Kind ! = SyntaxKind : : Token ) ; <nl> - <nl> - auto & ChildPtr = * reinterpret_cast < std : : atomic < uintptr_t > * > ( <nl> - MyData - > CachedChildren . data ( ) + N ) ; <nl> + / / If the number of children we ' ve seen indexes the same ( count - 1 ) as <nl> + / / the number we ' re looking for , then we ' re done . <nl> + if ( NumNonTokenSeen = = N + 1 ) { break ; } <nl> <nl> - SyntaxData : : realizeSyntaxNode < Syntax > ( ChildPtr , RawChild , MyData , <nl> - ChildLayoutIndex ) ; <nl> - <nl> - return Syntax { Root , MyData - > CachedChildren [ N ] . get ( ) } ; <nl> + / / Otherwise increment the actual index and keep searching . <nl> + + + ActualIndex ; <nl> + } <nl> + return Syntax { Root , Data - > getChild ( ActualIndex ) . get ( ) } ; <nl> } <nl> <nl> mmm a / unittests / Syntax / UnknownSyntaxTests . cpp <nl> ppp b / unittests / Syntax / UnknownSyntaxTests . cpp <nl> TEST ( UnknownSyntaxTests , UnknownSyntaxMakeAPIs ) { <nl> <nl> / / Wrap that symbolic reference as an UnknownSyntax . This has the same <nl> / / RawSyntax layout but with the Unknown Kind . <nl> - auto UnknownSymbolicRefData = UnknownSyntaxData : : make ( SymbolicRef . getRaw ( ) ) ; <nl> - <nl> - auto Unknown = UnknownSyntax { <nl> - UnknownSymbolicRefData , <nl> - UnknownSymbolicRefData . get ( ) <nl> - } ; <nl> + auto Unknown = make < UnknownSyntax > ( SymbolicRef . getRaw ( ) ) ; <nl> <nl> / / Print the unknown syntax . It should also print as " Array < Int > " . <nl> SmallString < 48 > UnknownScratch ; <nl> TEST ( UnknownSyntaxTests , UnknownSyntaxGetAPIs ) { <nl> GottenExpr . print ( KnownOS ) ; <nl> <nl> / / Wrap that call as an UnknownExprSyntax . This has the same <nl> - / / RawSyntax layout but with the UnknownExpr Kind . <nl> - auto UnknownCallData = UnknownExprSyntaxData : : make ( Call . getRaw ( ) ) ; <nl> - <nl> - auto Unknown = UnknownExprSyntax { <nl> - UnknownCallData , <nl> - UnknownCallData . get ( ) <nl> - } ; <nl> + / / RawSyntax layout but with the UnknownExpr Kind . ; <nl> + auto Unknown = make < UnknownExprSyntax > ( Call . getRaw ( ) ) ; <nl> <nl> ASSERT_EQ ( Unknown . getNumChildren ( ) , size_t ( 2 ) ) ; <nl> <nl> TEST ( UnknownSyntaxTests , UnknownSyntaxGetAPIs ) { <nl> <nl> / / Wrap that symbolic reference as an UnknownSyntax . This has the same <nl> / / RawSyntax layout but with the Unknown Kind . <nl> - auto UnknownCallData = UnknownSyntaxData : : make ( Call . getRaw ( ) ) ; <nl> - <nl> - auto Unknown = UnknownSyntax { <nl> - UnknownCallData , <nl> - UnknownCallData . get ( ) <nl> - } ; <nl> + auto Unknown = make < UnknownSyntax > ( Call . getRaw ( ) ) ; <nl> <nl> ASSERT_EQ ( Unknown . getNumChildren ( ) , size_t ( 2 ) ) ; <nl> <nl> TEST ( UnknownSyntaxTests , EmbedUnknownExpr ) { <nl> / / Let ' s make a function call expression where the called expression is <nl> / / actually unknown . It should print the same and have the same structure <nl> / / as one with a known called expression . <nl> - auto UnknownSymbolicRefData = <nl> - UnknownExprSyntaxData : : make ( SymbolicRef . getRaw ( ) ) ; <nl> - <nl> - auto UnknownSymbolicRef = UnknownExprSyntax { <nl> - UnknownSymbolicRefData , <nl> - UnknownSymbolicRefData . get ( ) <nl> - } . castTo < ExprSyntax > ( ) ; <nl> + auto UnknownSymbolicRef = make < UnknownExprSyntax > ( SymbolicRef . getRaw ( ) ) <nl> + . castTo < ExprSyntax > ( ) ; <nl> <nl> SmallString < 48 > UnknownScratch ; <nl> llvm : : raw_svector_ostream UnknownOS ( UnknownScratch ) ; <nl>
Merge pull request from harlanhaskins / 🔥 🌲 🔥
apple/swift
06da599affd13b390913f1c9a12b6c3345200264
2017-06-23T22:34:10Z