diff
stringlengths
41
2.03M
msg
stringlengths
1
1.5k
repo
stringlengths
5
40
sha
stringlengths
40
40
time
stringlengths
20
20
mmm a / include / v8 . h <nl> ppp b / include / v8 . h <nl> class V8_EXPORT ArrayBuffer : public Object { <nl> * / <nl> virtual void * AllocateUninitialized ( size_t length ) = 0 ; <nl> <nl> + / * * <nl> + * Reserved | length | bytes , but do not commit the memory . Must call <nl> + * | SetProtection | to make memory accessible . <nl> + * / <nl> + / / TODO ( eholk ) : make this pure virtual once blink implements this . <nl> + virtual void * Reserve ( size_t length ) ; <nl> + <nl> / * * <nl> * Free the memory block of size | length | , pointed to by | data | . <nl> * That memory is guaranteed to be previously allocated by | Allocate | . <nl> * / <nl> virtual void Free ( void * data , size_t length ) = 0 ; <nl> <nl> + enum class AllocationMode { kNormal , kReservation } ; <nl> + <nl> + / * * <nl> + * Free the memory block of size | length | , pointed to by | data | . <nl> + * That memory is guaranteed to be previously allocated by | Allocate | or <nl> + * | Reserve | , depending on | mode | . <nl> + * / <nl> + / / TODO ( eholk ) : make this pure virtual once blink implements this . <nl> + virtual void Free ( void * data , size_t length , AllocationMode mode ) ; <nl> + <nl> + enum class Protection { kNoAccess , kReadWrite } ; <nl> + <nl> + / * * <nl> + * Change the protection on a region of memory . <nl> + * <nl> + * On platforms that make a distinction between reserving and committing <nl> + * memory , changing the protection to kReadWrite must also ensure the memory <nl> + * is committed . <nl> + * / <nl> + / / TODO ( eholk ) : make this pure virtual once blink implements this . <nl> + virtual void SetProtection ( void * data , size_t length , <nl> + Protection protection ) ; <nl> + <nl> / * * <nl> * malloc / free based convenience allocator . <nl> * <nl> mmm a / src / api . cc <nl> ppp b / src / api . cc <nl> void V8 : : SetSnapshotDataBlob ( StartupData * snapshot_blob ) { <nl> i : : V8 : : SetSnapshotBlob ( snapshot_blob ) ; <nl> } <nl> <nl> + void * v8 : : ArrayBuffer : : Allocator : : Reserve ( size_t length ) { UNIMPLEMENTED ( ) ; } <nl> + <nl> + void v8 : : ArrayBuffer : : Allocator : : Free ( void * data , size_t length , <nl> + AllocationMode mode ) { <nl> + UNIMPLEMENTED ( ) ; <nl> + } <nl> + <nl> + void v8 : : ArrayBuffer : : Allocator : : SetProtection ( <nl> + void * data , size_t length , <nl> + v8 : : ArrayBuffer : : Allocator : : Protection protection ) { <nl> + UNIMPLEMENTED ( ) ; <nl> + } <nl> + <nl> namespace { <nl> <nl> class ArrayBufferAllocator : public v8 : : ArrayBuffer : : Allocator { <nl> class ArrayBufferAllocator : public v8 : : ArrayBuffer : : Allocator { <nl> } <nl> virtual void * AllocateUninitialized ( size_t length ) { return malloc ( length ) ; } <nl> virtual void Free ( void * data , size_t ) { free ( data ) ; } <nl> + <nl> + virtual void * Reserve ( size_t length ) { <nl> + return base : : VirtualMemory : : ReserveRegion ( length ) ; <nl> + } <nl> + <nl> + virtual void Free ( void * data , size_t length , <nl> + v8 : : ArrayBuffer : : Allocator : : AllocationMode mode ) { <nl> + switch ( mode ) { <nl> + case v8 : : ArrayBuffer : : Allocator : : AllocationMode : : kNormal : { <nl> + return Free ( data , length ) ; <nl> + } <nl> + case v8 : : ArrayBuffer : : Allocator : : AllocationMode : : kReservation : { <nl> + base : : VirtualMemory : : ReleaseRegion ( data , length ) ; <nl> + return ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + virtual void SetProtection ( <nl> + void * data , size_t length , <nl> + v8 : : ArrayBuffer : : Allocator : : Protection protection ) { <nl> + switch ( protection ) { <nl> + case v8 : : ArrayBuffer : : Allocator : : Protection : : kNoAccess : { <nl> + base : : VirtualMemory : : UncommitRegion ( data , length ) ; <nl> + return ; <nl> + } <nl> + case v8 : : ArrayBuffer : : Allocator : : Protection : : kReadWrite : { <nl> + const bool is_executable = false ; <nl> + base : : VirtualMemory : : CommitRegion ( data , length , is_executable ) ; <nl> + return ; <nl> + } <nl> + } <nl> + } <nl> } ; <nl> <nl> bool RunExtraCode ( Isolate * isolate , Local < Context > context , <nl> mmm a / src / d8 . cc <nl> ppp b / src / d8 . cc <nl> const int kMaxSerializerMemoryUsage = 1 * MB ; / / Arbitrary maximum for testing . <nl> / / array buffers storing the lengths as a SMI internally . <nl> # define TWO_GB ( 2u * 1024u * 1024u * 1024u ) <nl> <nl> - class ShellArrayBufferAllocator : public v8 : : ArrayBuffer : : Allocator { <nl> + / / Forwards memory reservation and protection functions to the V8 default <nl> + / / allocator . Used by ShellArrayBufferAllocator and MockArrayBufferAllocator . <nl> + class ArrayBufferAllocatorBase : public v8 : : ArrayBuffer : : Allocator { <nl> + std : : unique_ptr < Allocator > allocator_ = <nl> + std : : unique_ptr < Allocator > ( NewDefaultAllocator ( ) ) ; <nl> + <nl> public : <nl> - virtual void * Allocate ( size_t length ) { <nl> + void * Reserve ( size_t length ) override { return allocator_ - > Reserve ( length ) ; } <nl> + <nl> + void Free ( void * , size_t ) override = 0 ; <nl> + <nl> + void Free ( void * data , size_t length , AllocationMode mode ) override { <nl> + switch ( mode ) { <nl> + case AllocationMode : : kNormal : { <nl> + return Free ( data , length ) ; <nl> + } <nl> + case AllocationMode : : kReservation : { <nl> + return allocator_ - > Free ( data , length , mode ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + void SetProtection ( void * data , size_t length , <nl> + Protection protection ) override { <nl> + allocator_ - > SetProtection ( data , length , protection ) ; <nl> + } <nl> + } ; <nl> + <nl> + class ShellArrayBufferAllocator : public ArrayBufferAllocatorBase { <nl> + public : <nl> + void * Allocate ( size_t length ) override { <nl> # if USE_VM <nl> if ( RoundToPageSize ( & length ) ) { <nl> void * data = VirtualMemoryAllocate ( length ) ; <nl> class ShellArrayBufferAllocator : public v8 : : ArrayBuffer : : Allocator { <nl> void * data = AllocateUninitialized ( length ) ; <nl> return data = = NULL ? data : memset ( data , 0 , length ) ; <nl> } <nl> - virtual void * AllocateUninitialized ( size_t length ) { <nl> + void * AllocateUninitialized ( size_t length ) override { <nl> # if USE_VM <nl> if ( RoundToPageSize ( & length ) ) return VirtualMemoryAllocate ( length ) ; <nl> # endif <nl> class ShellArrayBufferAllocator : public v8 : : ArrayBuffer : : Allocator { <nl> return malloc ( length ) ; <nl> # endif <nl> } <nl> - virtual void Free ( void * data , size_t length ) { <nl> + void Free ( void * data , size_t length ) override { <nl> # if USE_VM <nl> if ( RoundToPageSize ( & length ) ) { <nl> base : : VirtualMemory : : ReleaseRegion ( data , length ) ; <nl> class ShellArrayBufferAllocator : public v8 : : ArrayBuffer : : Allocator { <nl> # endif <nl> } ; <nl> <nl> + class MockArrayBufferAllocator : public ArrayBufferAllocatorBase { <nl> + const size_t kAllocationLimit = 10 * MB ; <nl> + size_t get_actual_length ( size_t length ) const { <nl> + return length > kAllocationLimit ? base : : OS : : CommitPageSize ( ) : length ; <nl> + } <nl> <nl> - class MockArrayBufferAllocator : public v8 : : ArrayBuffer : : Allocator { <nl> public : <nl> void * Allocate ( size_t length ) override { <nl> - size_t actual_length = length > 10 * MB ? 1 : length ; <nl> + const size_t actual_length = get_actual_length ( length ) ; <nl> void * data = AllocateUninitialized ( actual_length ) ; <nl> return data = = NULL ? data : memset ( data , 0 , actual_length ) ; <nl> } <nl> void * AllocateUninitialized ( size_t length ) override { <nl> - return length > 10 * MB ? malloc ( 1 ) : malloc ( length ) ; <nl> + return malloc ( get_actual_length ( length ) ) ; <nl> } <nl> void Free ( void * p , size_t ) override { free ( p ) ; } <nl> + void Free ( void * data , size_t length , AllocationMode mode ) override { <nl> + ArrayBufferAllocatorBase : : Free ( data , get_actual_length ( length ) , mode ) ; <nl> + } <nl> + void * Reserve ( size_t length ) override { <nl> + return ArrayBufferAllocatorBase : : Reserve ( get_actual_length ( length ) ) ; <nl> + } <nl> } ; <nl> <nl> <nl> mmm a / src / heap / array - buffer - tracker . cc <nl> ppp b / src / heap / array - buffer - tracker . cc <nl> void LocalArrayBufferTracker : : Free ( Callback should_free ) { <nl> JSArrayBuffer * buffer = reinterpret_cast < JSArrayBuffer * > ( it - > first ) ; <nl> if ( should_free ( buffer ) ) { <nl> const size_t len = it - > second ; <nl> - heap_ - > isolate ( ) - > array_buffer_allocator ( ) - > Free ( buffer - > backing_store ( ) , <nl> - len ) ; <nl> + buffer - > FreeBackingStore ( ) ; <nl> + <nl> freed_memory + = len ; <nl> it = array_buffers_ . erase ( it ) ; <nl> } else { <nl> void LocalArrayBufferTracker : : Process ( Callback callback ) { <nl> it = array_buffers_ . erase ( it ) ; <nl> } else if ( result = = kRemoveEntry ) { <nl> const size_t len = it - > second ; <nl> - heap_ - > isolate ( ) - > array_buffer_allocator ( ) - > Free ( <nl> - it - > first - > backing_store ( ) , len ) ; <nl> + it - > first - > FreeBackingStore ( ) ; <nl> freed_memory + = len ; <nl> it = array_buffers_ . erase ( it ) ; <nl> } else { <nl> mmm a / src / objects - body - descriptors - inl . h <nl> ppp b / src / objects - body - descriptors - inl . h <nl> class JSFunction : : BodyDescriptorImpl final : public BodyDescriptorBase { <nl> class JSArrayBuffer : : BodyDescriptor final : public BodyDescriptorBase { <nl> public : <nl> STATIC_ASSERT ( kByteLengthOffset + kPointerSize = = kBackingStoreOffset ) ; <nl> - STATIC_ASSERT ( kBackingStoreOffset + kPointerSize = = kBitFieldSlot ) ; <nl> + STATIC_ASSERT ( kAllocationLengthOffset + kPointerSize = = kBitFieldSlot ) ; <nl> STATIC_ASSERT ( kBitFieldSlot + kPointerSize = = kSize ) ; <nl> <nl> static bool IsValidSlot ( HeapObject * obj , int offset ) { <nl> - if ( offset < kBackingStoreOffset ) return true ; <nl> + if ( offset < kAllocationLengthOffset ) return true ; <nl> if ( offset < kSize ) return false ; <nl> return IsValidSlotImpl ( obj , offset ) ; <nl> } <nl> class JSArrayBuffer : : BodyDescriptor final : public BodyDescriptorBase { <nl> template < typename ObjectVisitor > <nl> static inline void IterateBody ( HeapObject * obj , int object_size , <nl> ObjectVisitor * v ) { <nl> + / / Array buffers contain raw pointers that the GC does not know about . These <nl> + / / are stored at kBackStoreOffset and later , so we do not iterate over <nl> + / / those . <nl> IteratePointers ( obj , kPropertiesOffset , kBackingStoreOffset , v ) ; <nl> IterateBodyImpl ( obj , kSize , object_size , v ) ; <nl> } <nl> class JSArrayBuffer : : BodyDescriptor final : public BodyDescriptorBase { <nl> template < typename StaticVisitor > <nl> static inline void IterateBody ( HeapObject * obj , int object_size ) { <nl> Heap * heap = obj - > GetHeap ( ) ; <nl> + / / Array buffers contain raw pointers that the GC does not know about . These <nl> + / / are stored at kBackStoreOffset and later , so we do not iterate over <nl> + / / those . <nl> IteratePointers < StaticVisitor > ( heap , obj , kPropertiesOffset , <nl> kBackingStoreOffset ) ; <nl> IterateBodyImpl < StaticVisitor > ( heap , obj , kSize , object_size ) ; <nl> mmm a / src / objects - inl . h <nl> ppp b / src / objects - inl . h <nl> void JSArrayBuffer : : set_backing_store ( void * value , WriteBarrierMode mode ) { <nl> <nl> ACCESSORS ( JSArrayBuffer , byte_length , Object , kByteLengthOffset ) <nl> <nl> + void * JSArrayBuffer : : allocation_base ( ) const { <nl> + intptr_t ptr = READ_INTPTR_FIELD ( this , kAllocationBaseOffset ) ; <nl> + return reinterpret_cast < void * > ( ptr ) ; <nl> + } <nl> + <nl> + void JSArrayBuffer : : set_allocation_base ( void * value , WriteBarrierMode mode ) { <nl> + intptr_t ptr = reinterpret_cast < intptr_t > ( value ) ; <nl> + WRITE_INTPTR_FIELD ( this , kAllocationBaseOffset , ptr ) ; <nl> + } <nl> + <nl> + size_t JSArrayBuffer : : allocation_length ( ) const { <nl> + return * reinterpret_cast < const size_t * > ( <nl> + FIELD_ADDR_CONST ( this , kAllocationLengthOffset ) ) ; <nl> + } <nl> + <nl> + void JSArrayBuffer : : set_allocation_length ( size_t value ) { <nl> + ( * reinterpret_cast < size_t * > ( FIELD_ADDR ( this , kAllocationLengthOffset ) ) ) = <nl> + value ; <nl> + } <nl> <nl> void JSArrayBuffer : : set_bit_field ( uint32_t bits ) { <nl> if ( kInt32Size ! = kPointerSize ) { <nl> mmm a / src / objects . cc <nl> ppp b / src / objects . cc <nl> Handle < String > JSMessageObject : : GetSourceLine ( ) const { <nl> void JSArrayBuffer : : Neuter ( ) { <nl> CHECK ( is_neuterable ( ) ) ; <nl> CHECK ( is_external ( ) ) ; <nl> - set_backing_store ( NULL ) ; <nl> + set_backing_store ( nullptr ) ; <nl> set_byte_length ( Smi : : kZero ) ; <nl> + set_allocation_base ( nullptr ) ; <nl> + set_allocation_length ( 0 ) ; <nl> set_was_neutered ( true ) ; <nl> / / Invalidate the neutering protector . <nl> Isolate * const isolate = GetIsolate ( ) ; <nl> void JSArrayBuffer : : Neuter ( ) { <nl> } <nl> } <nl> <nl> + void JSArrayBuffer : : FreeBackingStore ( ) { <nl> + using AllocationMode = ArrayBuffer : : Allocator : : AllocationMode ; <nl> + const size_t length = allocation_length ( ) ; <nl> + const AllocationMode mode = has_guard_region ( ) ? AllocationMode : : kReservation <nl> + : AllocationMode : : kNormal ; <nl> + GetIsolate ( ) - > array_buffer_allocator ( ) - > Free ( allocation_base ( ) , length , mode ) ; <nl> + } <nl> <nl> void JSArrayBuffer : : Setup ( Handle < JSArrayBuffer > array_buffer , Isolate * isolate , <nl> bool is_external , void * data , size_t allocated_length , <nl> SharedFlag shared ) { <nl> + return Setup ( array_buffer , isolate , is_external , data , allocated_length , data , <nl> + allocated_length , shared ) ; <nl> + } <nl> + <nl> + void JSArrayBuffer : : Setup ( Handle < JSArrayBuffer > array_buffer , Isolate * isolate , <nl> + bool is_external , void * allocation_base , <nl> + size_t allocation_length , void * data , <nl> + size_t byte_length , SharedFlag shared ) { <nl> DCHECK ( array_buffer - > GetEmbedderFieldCount ( ) = = <nl> v8 : : ArrayBuffer : : kEmbedderFieldCount ) ; <nl> for ( int i = 0 ; i < v8 : : ArrayBuffer : : kEmbedderFieldCount ; i + + ) { <nl> void JSArrayBuffer : : Setup ( Handle < JSArrayBuffer > array_buffer , Isolate * isolate , <nl> array_buffer - > set_is_neuterable ( shared = = SharedFlag : : kNotShared ) ; <nl> array_buffer - > set_is_shared ( shared = = SharedFlag : : kShared ) ; <nl> <nl> - Handle < Object > byte_length = <nl> - isolate - > factory ( ) - > NewNumberFromSize ( allocated_length ) ; <nl> - CHECK ( byte_length - > IsSmi ( ) | | byte_length - > IsHeapNumber ( ) ) ; <nl> - array_buffer - > set_byte_length ( * byte_length ) ; <nl> + Handle < Object > heap_byte_length = <nl> + isolate - > factory ( ) - > NewNumberFromSize ( byte_length ) ; <nl> + CHECK ( heap_byte_length - > IsSmi ( ) | | heap_byte_length - > IsHeapNumber ( ) ) ; <nl> + array_buffer - > set_byte_length ( * heap_byte_length ) ; <nl> / / Initialize backing store at last to avoid handling of | JSArrayBuffers | that <nl> / / are currently being constructed in the | ArrayBufferTracker | . The <nl> / / registration method below handles the case of registering a buffer that has <nl> / / already been promoted . <nl> array_buffer - > set_backing_store ( data ) ; <nl> <nl> + array_buffer - > set_allocation_base ( data ) ; <nl> + array_buffer - > set_allocation_length ( allocation_length ) ; <nl> + <nl> if ( data & & ! is_external ) { <nl> isolate - > heap ( ) - > RegisterNewArrayBuffer ( * array_buffer ) ; <nl> } <nl> bool JSArrayBuffer : : SetupAllocatingData ( Handle < JSArrayBuffer > array_buffer , <nl> data = NULL ; <nl> } <nl> <nl> - JSArrayBuffer : : Setup ( array_buffer , isolate , false , data , allocated_length , <nl> - shared ) ; <nl> + const bool is_external = false ; <nl> + JSArrayBuffer : : Setup ( array_buffer , isolate , is_external , data , <nl> + allocated_length , shared ) ; <nl> return true ; <nl> } <nl> <nl> Handle < JSArrayBuffer > JSTypedArray : : MaterializeArrayBuffer ( <nl> / / already been promoted . <nl> buffer - > set_backing_store ( backing_store ) ; <nl> isolate - > heap ( ) - > RegisterNewArrayBuffer ( * buffer ) ; <nl> + buffer - > set_allocation_base ( backing_store ) ; <nl> + buffer - > set_allocation_length ( NumberToSize ( buffer - > byte_length ( ) ) ) ; <nl> memcpy ( buffer - > backing_store ( ) , <nl> fixed_typed_array - > DataPtr ( ) , <nl> fixed_typed_array - > DataSize ( ) ) ; <nl> mmm a / src / objects . h <nl> ppp b / src / objects . h <nl> class JSArrayBuffer : public JSObject { <nl> / / [ byte_length ] : length in bytes <nl> DECL_ACCESSORS ( byte_length , Object ) <nl> <nl> + / / [ allocation_base ] : the start of the memory allocation for this array , <nl> + / / normally equal to backing_store <nl> + DECL_ACCESSORS ( allocation_base , void ) <nl> + <nl> + / / [ allocation_length ] : the size of the memory allocation for this array , <nl> + / / normally equal to byte_length <nl> + inline size_t allocation_length ( ) const ; <nl> + inline void set_allocation_length ( size_t value ) ; <nl> + <nl> inline uint32_t bit_field ( ) const ; <nl> inline void set_bit_field ( uint32_t bits ) ; <nl> <nl> class JSArrayBuffer : public JSObject { <nl> <nl> void Neuter ( ) ; <nl> <nl> + void FreeBackingStore ( ) ; <nl> + <nl> V8_EXPORT_PRIVATE static void Setup ( <nl> Handle < JSArrayBuffer > array_buffer , Isolate * isolate , bool is_external , <nl> void * data , size_t allocated_length , <nl> SharedFlag shared = SharedFlag : : kNotShared ) ; <nl> <nl> + V8_EXPORT_PRIVATE static void Setup ( <nl> + Handle < JSArrayBuffer > array_buffer , Isolate * isolate , bool is_external , <nl> + void * allocation_base , size_t allocation_length , void * data , <nl> + size_t byte_length , SharedFlag shared = SharedFlag : : kNotShared ) ; <nl> + <nl> / / Returns false if array buffer contents could not be allocated . <nl> / / In this case , | array_buffer | will not be set up . <nl> static bool SetupAllocatingData ( <nl> class JSArrayBuffer : public JSObject { <nl> DECLARE_VERIFIER ( JSArrayBuffer ) <nl> <nl> static const int kByteLengthOffset = JSObject : : kHeaderSize ; <nl> + / / The rest of the fields are not JSObjects , so they are not iterated over in <nl> + / / objects - body - descriptors - inl . h . <nl> static const int kBackingStoreOffset = kByteLengthOffset + kPointerSize ; <nl> - static const int kBitFieldSlot = kBackingStoreOffset + kPointerSize ; <nl> + static const int kAllocationBaseOffset = kBackingStoreOffset + kPointerSize ; <nl> + static const int kAllocationLengthOffset = <nl> + kAllocationBaseOffset + kPointerSize ; <nl> + static const int kBitFieldSlot = kAllocationLengthOffset + kSizetSize ; <nl> # if V8_TARGET_LITTLE_ENDIAN | | ! V8_HOST_ARCH_64_BIT <nl> static const int kBitFieldOffset = kBitFieldSlot ; <nl> # else <nl>
Add memory protection API to ArrayBuffer : : Allocator
v8/v8
18a26cfe17419633856e614577a84cc1e8385e14
2017-05-18T20:35:09Z
mmm a / src / mongo / client / dbclient_base . cpp <nl> ppp b / src / mongo / client / dbclient_base . cpp <nl> <nl> # include " mongo / client / constants . h " <nl> # include " mongo / client / dbclient_cursor . h " <nl> # include " mongo / config . h " <nl> - # include " mongo / db / auth / authorization_manager . h " <nl> # include " mongo / db / commands . h " <nl> # include " mongo / db / json . h " <nl> # include " mongo / db / namespace_string . h " <nl> mmm a / src / mongo / db / auth / authorization_manager_impl . cpp <nl> ppp b / src / mongo / db / auth / authorization_manager_impl . cpp <nl> AuthorizationManagerImpl : : AuthSchemaVersionCache : : AuthSchemaVersionCache ( <nl> ServiceContext * service , <nl> ThreadPoolInterface & threadPool , <nl> AuthzManagerExternalState * externalState ) <nl> - : ReadThroughCache ( _mutex , service , threadPool , 1 / * cacheSize * / ) , <nl> + : ReadThroughCache ( <nl> + _mutex , <nl> + service , <nl> + threadPool , <nl> + [ this ] ( OperationContext * opCtx , int unusedKey ) { return _lookup ( opCtx , unusedKey ) ; } , <nl> + 1 / * cacheSize * / ) , <nl> _externalState ( externalState ) { } <nl> <nl> - boost : : optional < int > AuthorizationManagerImpl : : AuthSchemaVersionCache : : lookup ( <nl> - OperationContext * opCtx , const int & unusedKey ) { <nl> + boost : : optional < int > AuthorizationManagerImpl : : AuthSchemaVersionCache : : _lookup ( <nl> + OperationContext * opCtx , int unusedKey ) { <nl> invariant ( unusedKey = = 0 ) ; <nl> <nl> int authzVersion ; <nl> AuthorizationManagerImpl : : UserCacheImpl : : UserCacheImpl ( <nl> int cacheSize , <nl> AuthSchemaVersionCache * authSchemaVersionCache , <nl> AuthzManagerExternalState * externalState ) <nl> - : UserCache ( _mutex , service , threadPool , cacheSize ) , <nl> + : UserCache ( _mutex , <nl> + service , <nl> + threadPool , <nl> + [ this ] ( OperationContext * opCtx , const UserRequest & userReq ) { <nl> + return _lookup ( opCtx , userReq ) ; <nl> + } , <nl> + cacheSize ) , <nl> _authSchemaVersionCache ( authSchemaVersionCache ) , <nl> _externalState ( externalState ) { } <nl> <nl> - boost : : optional < User > AuthorizationManagerImpl : : UserCacheImpl : : lookup ( OperationContext * opCtx , <nl> - const UserRequest & userReq ) { <nl> + boost : : optional < User > AuthorizationManagerImpl : : UserCacheImpl : : _lookup ( OperationContext * opCtx , <nl> + const UserRequest & userReq ) { <nl> LOGV2_DEBUG ( 20238 , 1 , " Getting user record " , " user " _attr = userReq . name ) ; <nl> <nl> / / Number of times to retry a user document that fetches due to transient AuthSchemaIncompatible <nl> mmm a / src / mongo / db / auth / authorization_manager_impl . h <nl> ppp b / src / mongo / db / auth / authorization_manager_impl . h <nl> class AuthorizationManagerImpl : public AuthorizationManager { <nl> ThreadPoolInterface & threadPool , <nl> AuthzManagerExternalState * externalState ) ; <nl> <nl> + private : <nl> / / Even though the dist cache permits for lookup to return boost : : none for non - existent <nl> / / values , the contract of the authorization manager is that it should throw an exception if <nl> / / the value can not be loaded , so if it returns , the value will always be set . <nl> - boost : : optional < int > lookup ( OperationContext * opCtx , const int & unusedKey ) override ; <nl> + boost : : optional < int > _lookup ( OperationContext * opCtx , int unusedKey ) ; <nl> <nl> - private : <nl> Mutex _mutex = <nl> MONGO_MAKE_LATCH ( " AuthorizationManagerImpl : : AuthSchemaVersionDistCache : : _mutex " ) ; <nl> <nl> class AuthorizationManagerImpl : public AuthorizationManager { <nl> AuthSchemaVersionCache * authSchemaVersionCache , <nl> AuthzManagerExternalState * externalState ) ; <nl> <nl> + private : <nl> / / Even though the dist cache permits for lookup to return boost : : none for non - existent <nl> / / values , the contract of the authorization manager is that it should throw an exception if <nl> / / the value can not be loaded , so if it returns , the value will always be set . <nl> - boost : : optional < User > lookup ( OperationContext * opCtx , const UserRequest & user ) override ; <nl> + boost : : optional < User > _lookup ( OperationContext * opCtx , const UserRequest & user ) ; <nl> <nl> - private : <nl> Mutex _mutex = MONGO_MAKE_LATCH ( " AuthorizationManagerImpl : : UserDistCacheImpl : : _mutex " ) ; <nl> <nl> AuthSchemaVersionCache * const _authSchemaVersionCache ; <nl> mmm a / src / mongo / db / read_write_concern_defaults . cpp <nl> ppp b / src / mongo / db / read_write_concern_defaults . cpp <nl> void ReadWriteConcernDefaults : : setDefault ( OperationContext * opCtx , RWConcernDefa <nl> } <nl> <nl> void ReadWriteConcernDefaults : : refreshIfNecessary ( OperationContext * opCtx ) { <nl> - auto possibleNewDefaults = _defaults . lookup ( opCtx , Type : : kReadWriteConcernEntry ) ; <nl> + auto possibleNewDefaults = _defaults . lookup ( opCtx ) ; <nl> if ( ! possibleNewDefaults ) { <nl> return ; <nl> } <nl> ReadWriteConcernDefaults & ReadWriteConcernDefaults : : get ( OperationContext * opCtx ) <nl> } <nl> <nl> void ReadWriteConcernDefaults : : create ( ServiceContext * service , FetchDefaultsFn fetchDefaultsFn ) { <nl> - getReadWriteConcernDefaults ( service ) . emplace ( service , fetchDefaultsFn ) ; <nl> + getReadWriteConcernDefaults ( service ) . emplace ( service , std : : move ( fetchDefaultsFn ) ) ; <nl> } <nl> <nl> ReadWriteConcernDefaults : : ReadWriteConcernDefaults ( ServiceContext * service , <nl> FetchDefaultsFn fetchDefaultsFn ) <nl> - : _defaults ( service , <nl> - _threadPool , <nl> - [ fetchDefaultsFn = std : : move ( fetchDefaultsFn ) ] ( <nl> - OperationContext * opCtx , const Type & ) { return fetchDefaultsFn ( opCtx ) ; } ) , <nl> - _threadPool ( [ ] { <nl> + : _defaults ( service , _threadPool , std : : move ( fetchDefaultsFn ) ) , _threadPool ( [ ] { <nl> ThreadPool : : Options options ; <nl> options . poolName = " ReadWriteConcernDefaults " ; <nl> options . minThreads = 0 ; <nl> ReadWriteConcernDefaults : : ~ ReadWriteConcernDefaults ( ) = default ; <nl> <nl> ReadWriteConcernDefaults : : Cache : : Cache ( ServiceContext * service , <nl> ThreadPoolInterface & threadPool , <nl> - LookupFn lookupFn ) <nl> - : ReadThroughCache ( _mutex , service , threadPool , 1 / * cacheSize * / ) , <nl> - _lookupFn ( std : : move ( lookupFn ) ) { } <nl> - <nl> - boost : : optional < RWConcernDefault > ReadWriteConcernDefaults : : Cache : : lookup ( <nl> - OperationContext * opCtx , const ReadWriteConcernDefaults : : Type & key ) { <nl> - invariant ( key = = Type : : kReadWriteConcernEntry ) ; <nl> - return _lookupFn ( opCtx , key ) ; <nl> + FetchDefaultsFn fetchDefaultsFn ) <nl> + : ReadThroughCache ( _mutex , <nl> + service , <nl> + threadPool , <nl> + [ this ] ( OperationContext * opCtx , Type ) { return lookup ( opCtx ) ; } , <nl> + 1 / * cacheSize * / ) , <nl> + _fetchDefaultsFn ( std : : move ( fetchDefaultsFn ) ) { } <nl> + <nl> + boost : : optional < RWConcernDefault > ReadWriteConcernDefaults : : Cache : : lookup ( OperationContext * opCtx ) { <nl> + return _fetchDefaultsFn ( opCtx ) ; <nl> } <nl> <nl> } / / namespace mongo <nl> mmm a / src / mongo / db / read_write_concern_defaults . h <nl> ppp b / src / mongo / db / read_write_concern_defaults . h <nl> class ReadWriteConcernDefaults { <nl> using ReadConcern = repl : : ReadConcernArgs ; <nl> using WriteConcern = WriteConcernOptions ; <nl> <nl> - using FetchDefaultsFn = std : : function < boost : : optional < RWConcernDefault > ( OperationContext * ) > ; <nl> + using FetchDefaultsFn = unique_function < boost : : optional < RWConcernDefault > ( OperationContext * ) > ; <nl> <nl> static constexpr StringData readConcernFieldName = ReadConcern : : kReadConcernFieldName ; <nl> static constexpr StringData writeConcernFieldName = WriteConcern : : kWriteConcernField ; <nl> class ReadWriteConcernDefaults { <nl> Cache & operator = ( const Cache & ) = delete ; <nl> <nl> public : <nl> - Cache ( ServiceContext * service , ThreadPoolInterface & threadPool , LookupFn lookupFn ) ; <nl> + Cache ( ServiceContext * service , <nl> + ThreadPoolInterface & threadPool , <nl> + FetchDefaultsFn fetchDefaultsFn ) ; <nl> virtual ~ Cache ( ) = default ; <nl> <nl> - boost : : optional < RWConcernDefault > lookup ( OperationContext * opCtx , const Type & key ) override ; <nl> + boost : : optional < RWConcernDefault > lookup ( OperationContext * opCtx ) ; <nl> <nl> private : <nl> Mutex _mutex = MONGO_MAKE_LATCH ( " ReadWriteConcernDefaults : : Cache " ) ; <nl> <nl> - LookupFn _lookupFn ; <nl> + FetchDefaultsFn _fetchDefaultsFn ; <nl> } ; <nl> <nl> Cache _defaults ; <nl> mmm a / src / mongo / util / invalidating_lru_cache . h <nl> ppp b / src / mongo / util / invalidating_lru_cache . h <nl> class InvalidatingLRUCache { <nl> * The ' owningCache ' and ' key ' values can be nullptr / boost : : none in order to support the <nl> * detached mode of ValueHandle below . <nl> * / <nl> - StoredValue ( InvalidatingLRUCache * in_owningCache , <nl> - boost : : optional < Key > in_key , <nl> - Value & & in_value ) <nl> - : owningCache ( in_owningCache ) , key ( in_key ) , value ( std : : move ( in_value ) ) { } <nl> + StoredValue ( InvalidatingLRUCache * owningCache , <nl> + uint64_t epoch , <nl> + boost : : optional < Key > & & key , <nl> + Value & & value ) <nl> + : owningCache ( owningCache ) , <nl> + epoch ( epoch ) , <nl> + key ( std : : move ( key ) ) , <nl> + value ( std : : move ( value ) ) { } <nl> <nl> ~ StoredValue ( ) { <nl> - if ( owningCache ) { <nl> - stdx : : lock_guard < Latch > lg ( owningCache - > _mutex ) ; <nl> - owningCache - > _evictedCheckedOutValues . erase ( * key ) ; <nl> + if ( ! owningCache ) <nl> + return ; <nl> + <nl> + stdx : : unique_lock < Latch > ul ( owningCache - > _mutex ) ; <nl> + auto & evictedCheckedOutValues = owningCache - > _evictedCheckedOutValues ; <nl> + auto it = evictedCheckedOutValues . find ( * key ) ; <nl> + <nl> + / / The lookup above can encounter the following cases : <nl> + / / <nl> + / / 1 ) The ' key ' is not on the evictedCheckedOutValues map , because a second value for it <nl> + / / was inserted , which was also evicted and all its handles expired ( so it got removed ) <nl> + if ( it = = evictedCheckedOutValues . end ( ) ) <nl> + return ; <nl> + auto storedValue = it - > second . lock ( ) ; <nl> + / / 2 ) There are no more references to ' key ' , but it is stil on the map , which means <nl> + / / either we are running its destrutor , or some other thread is running the destructor <nl> + / / of a different epoch . In either case it is fine to remove the ' it ' because we are <nl> + / / under a mutex . <nl> + if ( ! storedValue ) { <nl> + evictedCheckedOutValues . erase ( it ) ; <nl> + return ; <nl> } <nl> + ul . unlock ( ) ; <nl> + / / 3 ) The value for ' key ' is for a different epoch , in which case we must dereference <nl> + / / the ' . lock ( ) ' ed storedValue outside of the mutex in order to avoid reentrancy while <nl> + / / holding a mutex . <nl> + invariant ( storedValue - > epoch ! = epoch ) ; <nl> } <nl> <nl> + / / Copy and move constructors need to be deleted in order to avoid having to make the <nl> + / / destructor to account for the object having been moved <nl> + StoredValue ( StoredValue & ) = delete ; <nl> + StoredValue & operator = ( StoredValue & ) = delete ; <nl> + StoredValue ( StoredValue & & ) = delete ; <nl> + StoredValue & operator = ( StoredValue & & ) = delete ; <nl> + <nl> / / The cache which stores this key / value pair <nl> - InvalidatingLRUCache * owningCache ; <nl> + InvalidatingLRUCache * const owningCache ; <nl> + <nl> + / / Identity associated with this value . See the destructor for its usage . <nl> + const uint64_t epoch ; <nl> <nl> / / The key / value pair . See the comments on the constructor about why the key is optional . <nl> - boost : : optional < Key > key ; <nl> + const boost : : optional < Key > key ; <nl> Value value ; <nl> <nl> / / Initially set to true to indicate that the entry is valid and can be read without <nl> class InvalidatingLRUCache { <nl> / / support pinning items . Their only usage must be in the authorization mananager for the <nl> / / internal authentication user . <nl> explicit ValueHandle ( Value & & value ) <nl> - : _value ( std : : make_shared < StoredValue > ( nullptr , boost : : none , std : : move ( value ) ) ) { } <nl> + : _value ( std : : make_shared < StoredValue > ( nullptr , 0 , boost : : none , std : : move ( value ) ) ) { } <nl> <nl> ValueHandle ( ) = default ; <nl> <nl> class InvalidatingLRUCache { <nl> LockGuardWithPostUnlockDestructor guard ( _mutex ) ; <nl> _invalidate ( & guard , key , _cache . find ( key ) ) ; <nl> if ( auto evicted = _cache . add ( <nl> - key , std : : make_shared < StoredValue > ( this , key , std : : forward < Value > ( value ) ) ) ) { <nl> + key , <nl> + std : : make_shared < StoredValue > ( this , + + _epoch , key , std : : forward < Value > ( value ) ) ) ) { <nl> const auto & evictedKey = evicted - > first ; <nl> auto & evictedValue = evicted - > second ; <nl> <nl> class InvalidatingLRUCache { <nl> LockGuardWithPostUnlockDestructor guard ( _mutex ) ; <nl> _invalidate ( & guard , key , _cache . find ( key ) ) ; <nl> if ( auto evicted = _cache . add ( <nl> - key , std : : make_shared < StoredValue > ( this , key , std : : forward < Value > ( value ) ) ) ) { <nl> + key , <nl> + std : : make_shared < StoredValue > ( this , + + _epoch , key , std : : forward < Value > ( value ) ) ) ) { <nl> const auto & evictedKey = evicted - > first ; <nl> auto & evictedValue = evicted - > second ; <nl> <nl> class InvalidatingLRUCache { <nl> using EvictedCheckedOutValuesMap = stdx : : unordered_map < Key , std : : weak_ptr < StoredValue > > ; <nl> EvictedCheckedOutValuesMap _evictedCheckedOutValues ; <nl> <nl> + / / An always - incrementing counter from which to obtain " identities " for each value stored in the <nl> + / / cache , so that different instantiations for the same key can be differentiated <nl> + uint64_t _epoch { 0 } ; <nl> + <nl> Cache _cache ; <nl> } ; <nl> <nl> mmm a / src / mongo / util / invalidating_lru_cache_test . cpp <nl> ppp b / src / mongo / util / invalidating_lru_cache_test . cpp <nl> TEST ( InvalidatingLRUCacheTest , CheckedOutItemsAreInvalidatedWithPredicateWhenEvi <nl> } <nl> } <nl> <nl> + TEST ( InvalidatingLRUCacheTest , OrderOfDestructionOfHandlesDiffersFromOrderOfInsertion ) { <nl> + TestValueCache cache ( 1 ) ; <nl> + <nl> + boost : : optional < TestValueCache : : ValueHandle > firstValue ( <nl> + cache . insertOrAssignAndGet ( 100 , { " Key 100 , Value 1 " } ) ) ; <nl> + ASSERT ( * firstValue ) ; <nl> + ASSERT ( firstValue - > isValid ( ) ) ; <nl> + <nl> + / / This will invalidate the first value of key 100 <nl> + auto secondValue = cache . insertOrAssignAndGet ( 100 , { " Key 100 , Value 2 " } ) ; <nl> + ASSERT ( secondValue ) ; <nl> + ASSERT ( secondValue . isValid ( ) ) ; <nl> + ASSERT ( ! firstValue - > isValid ( ) ) ; <nl> + <nl> + / / This will evict the second value of key 100 <nl> + cache . insertOrAssignAndGet ( 200 , { " Key 200 , Value 1 " } ) ; <nl> + ASSERT ( secondValue ) ; <nl> + ASSERT ( secondValue . isValid ( ) ) ; <nl> + ASSERT ( ! firstValue - > isValid ( ) ) ; <nl> + <nl> + / / This makes the first value of 100 ' s handle go away before the second value ' s hande <nl> + firstValue . reset ( ) ; <nl> + ASSERT ( secondValue . isValid ( ) ) ; <nl> + <nl> + cache . invalidate ( 100 ) ; <nl> + ASSERT ( ! secondValue . isValid ( ) ) ; <nl> + } <nl> + <nl> TEST ( InvalidatingLRUCacheTest , AssignWhileValueIsCheckedOutInvalidatesFirstValue ) { <nl> TestValueCache cache ( 1 ) ; <nl> <nl> mmm a / src / mongo / util / net / ssl_manager_openssl . cpp <nl> ppp b / src / mongo / util / net / ssl_manager_openssl . cpp <nl> StatusWith < OCSPValidationContext > extractOcspUris ( SSL_CTX * context , <nl> class OCSPCache : public ReadThroughCache < OCSPCacheKey , OCSPFetchResponse > { <nl> public : <nl> OCSPCache ( ServiceContext * service ) <nl> - : ReadThroughCache ( _mutex , service , _threadPool , tlsOCSPCacheSize ) { <nl> + : ReadThroughCache ( _mutex , service , _threadPool , _lookup , tlsOCSPCacheSize ) { <nl> _threadPool . startup ( ) ; <nl> } <nl> <nl> class OCSPCache : public ReadThroughCache < OCSPCacheKey , OCSPFetchResponse > { <nl> } <nl> <nl> private : <nl> - boost : : optional < OCSPFetchResponse > lookup ( OperationContext * opCtx , <nl> - const OCSPCacheKey & key ) final { <nl> + static boost : : optional < OCSPFetchResponse > _lookup ( OperationContext * opCtx , <nl> + const OCSPCacheKey & key ) { <nl> / / If there is a CRL file , we expect the CRL file to cover the certificate status <nl> / / information , and therefore we don ' t need to make a roundtrip . <nl> if ( ! getSSLGlobalParams ( ) . sslCRLFile . empty ( ) ) { <nl> mmm a / src / mongo / util / read_through_cache . h <nl> ppp b / src / mongo / util / read_through_cache . h <nl> class ReadThroughCache : public ReadThroughCacheBase { <nl> using Cache = InvalidatingLRUCache < Key , StoredValue > ; <nl> <nl> public : <nl> - using LookupFn = std : : function < boost : : optional < Value > ( OperationContext * , const Key & ) > ; <nl> - <nl> / * * <nl> * Common type for values returned from the cache . <nl> * / <nl> class ReadThroughCache : public ReadThroughCacheBase { <nl> typename Cache : : ValueHandle _valueHandle ; <nl> } ; <nl> <nl> + / * * <nl> + * Signature for a blocking function to provide the value for a key when there is a cache miss . <nl> + * <nl> + * The implementation must throw a uassertion to indicate an error while looking up the value , <nl> + * return boost : : none if the key is not found , or return an actual value . <nl> + * / <nl> + using LookupFn = unique_function < boost : : optional < Value > ( OperationContext * , const Key & ) > ; <nl> + <nl> / * * <nl> * If ' key ' is found in the cache , returns a set ValueHandle ( its operator bool will be true ) . <nl> * Otherwise , either causes the blocking ' lookup ' below to be asynchronously invoked to fetch <nl> class ReadThroughCache : public ReadThroughCacheBase { <nl> ReadThroughCache ( Mutex & mutex , <nl> ServiceContext * service , <nl> ThreadPoolInterface & threadPool , <nl> + LookupFn lookupFn , <nl> int cacheSize ) <nl> - : ReadThroughCacheBase ( mutex , service , threadPool ) , _cache ( cacheSize ) { } <nl> + : ReadThroughCacheBase ( mutex , service , threadPool ) , <nl> + _lookupFn ( std : : move ( lookupFn ) ) , <nl> + _cache ( cacheSize ) { } <nl> <nl> ~ ReadThroughCache ( ) { <nl> invariant ( _inProgressLookups . empty ( ) ) ; <nl> } <nl> <nl> private : <nl> - / * * <nl> - * Provide the value for a key when there is a cache miss . Sub - classes must implement this <nl> - * function appropriately . Throw a uassertion to indicate an error while looking up the value , <nl> - * or return value for this key , or boost : : none if this key has no value . <nl> - * / <nl> - virtual boost : : optional < Value > lookup ( OperationContext * opCtx , const Key & key ) = 0 ; <nl> - <nl> / / Refer to the comments on ' _asyncLookupWhileInvalidated ' for more detail on how this structure <nl> / / is used . <nl> struct InProgressLookup { <nl> class ReadThroughCache : public ReadThroughCacheBase { <nl> OperationContext * opCtx , const Status & status ) mutable noexcept { <nl> p - > setWith ( [ & ] ( ) mutable { <nl> uassertStatusOK ( status ) ; <nl> - auto value = lookup ( opCtx , inProgressLookup . key ) ; <nl> + auto value = _lookupFn ( opCtx , inProgressLookup . key ) ; <nl> uassert ( ErrorCodes : : ReadThroughCacheKeyNotFound , <nl> " Internal only : key not found " , <nl> value ) ; <nl> class ReadThroughCache : public ReadThroughCacheBase { <nl> return std : : move ( future ) ; <nl> } ; <nl> <nl> + / / Blocking function which will be invoked to retrieve entries from the backing store <nl> + const LookupFn _lookupFn ; <nl> + <nl> / / Contains all the currently cached keys . This structure is self - synchronising and doesn ' t <nl> / / require a mutex . However , on cache miss it is accessed under ' _mutex ' , which is safe , because <nl> / / _cache ' s mutex itself is at level 0 . <nl> mmm a / src / mongo / util / read_through_cache_test . cpp <nl> ppp b / src / mongo / util / read_through_cache_test . cpp <nl> struct CachedValue { <nl> class Cache : public ReadThroughCache < std : : string , CachedValue > { <nl> public : <nl> Cache ( ServiceContext * service , ThreadPoolInterface & threadPool , size_t size , LookupFn lookupFn ) <nl> - : ReadThroughCache ( _mutex , service , threadPool , size ) , _lookupFn ( std : : move ( lookupFn ) ) { } <nl> + : ReadThroughCache ( _mutex , service , threadPool , std : : move ( lookupFn ) , size ) { } <nl> <nl> private : <nl> - boost : : optional < CachedValue > lookup ( OperationContext * opCtx , const std : : string & key ) override { <nl> - return _lookupFn ( opCtx , key ) ; <nl> - } <nl> - <nl> Mutex _mutex = MONGO_MAKE_LATCH ( " ReadThroughCacheTest : : Cache " ) ; <nl> - <nl> - LookupFn _lookupFn ; <nl> } ; <nl> <nl> / * * <nl>
SERVER - 47916 Make InvalidatingLRUCache use an ' epoch ' when invalidating evicted checked - out values
mongodb/mongo
7ee768a17cbc78f42c8e8938df2c68635f871bdf
2020-05-07T05:42:43Z
mmm a / DEPS <nl> ppp b / DEPS <nl> vars = { <nl> <nl> deps = { <nl> ' v8 / build ' : <nl> - Var ( ' chromium_url ' ) + ' / chromium / src / build . git ' + ' @ ' + ' 74fd4a8c594b31e5279ffa69b8e7d550b9211ca0 ' , <nl> + Var ( ' chromium_url ' ) + ' / chromium / src / build . git ' + ' @ ' + ' 9ed511087c03666dc1816bef412012f067de6f69 ' , <nl> ' v8 / third_party / depot_tools ' : <nl> - Var ( ' chromium_url ' ) + ' / chromium / tools / depot_tools . git ' + ' @ ' + ' c903198758bdddd96d37fc5992d24b174623a2e5 ' , <nl> + Var ( ' chromium_url ' ) + ' / chromium / tools / depot_tools . git ' + ' @ ' + ' 71bae22f623ebe9ccf013b22497dae6177dec90a ' , <nl> ' v8 / third_party / icu ' : <nl> Var ( ' chromium_url ' ) + ' / chromium / deps / icu . git ' + ' @ ' + ' 8c67416ccb4da42d817e7081ff83a2193b1aabe7 ' , <nl> ' v8 / third_party / instrumented_libraries ' : <nl> deps = { <nl> ' condition ' : ' checkout_android ' , <nl> } , <nl> ' v8 / third_party / catapult ' : { <nl> - ' url ' : Var ( ' chromium_url ' ) + ' / catapult . git ' + ' @ ' + ' bd30f49227bf06fbb10640c8778722c2d35e8e97 ' , <nl> + ' url ' : Var ( ' chromium_url ' ) + ' / catapult . git ' + ' @ ' + ' b3bee2e7d9f156928d5d2b1efa1360478e99f856 ' , <nl> ' condition ' : ' checkout_android ' , <nl> } , <nl> ' v8 / third_party / colorama / src ' : { <nl>
Update V8 DEPS .
v8/v8
efafc8e829235c95adb8d5389c3fef2e9fb1e8b2
2019-03-03T03:33:20Z
mmm a / dbms / src / Storages / MergeTree / ReplicatedMergeTreeLogEntry . h <nl> ppp b / dbms / src / Storages / MergeTree / ReplicatedMergeTreeLogEntry . h <nl> struct ReplicatedMergeTreeLogEntryData <nl> <nl> / / / The quorum value ( for GET_PART ) is a non - zero value when the quorum write is enabled . <nl> size_t quorum = 0 ; <nl> + <nl> + / / / If this MUTATE_PART entry caused by alter ( modify / drop ) query . <nl> + bool isAlterMutation ( ) const <nl> + { <nl> + return type = = MUTATE_PART & & alter_version ! = - 1 ; <nl> + } <nl> } ; <nl> <nl> <nl> mmm a / dbms / src / Storages / MergeTree / ReplicatedMergeTreeMutationEntry . h <nl> ppp b / dbms / src / Storages / MergeTree / ReplicatedMergeTreeMutationEntry . h <nl> struct ReplicatedMergeTreeMutationEntry <nl> / / / Version of metadata . Not equal to - 1 only if this mutation <nl> / / / was created by ALTER MODIFY / DROP queries . <nl> int alter_version = - 1 ; <nl> + <nl> + bool isAlterMutation ( ) const { return alter_version ! = - 1 ; } <nl> } ; <nl> <nl> using ReplicatedMergeTreeMutationEntryPtr = std : : shared_ptr < const ReplicatedMergeTreeMutationEntry > ; <nl> mmm a / dbms / src / Storages / MergeTree / ReplicatedMergeTreeQueue . cpp <nl> ppp b / dbms / src / Storages / MergeTree / ReplicatedMergeTreeQueue . cpp <nl> void ReplicatedMergeTreeQueue : : updateMutations ( zkutil : : ZooKeeperPtr zookeeper , C <nl> } <nl> <nl> / / / otherwise it ' s already done <nl> - if ( entry - > alter_version ! = - 1 & & entry - > znode_name > mutation_pointer ) <nl> + if ( entry - > isAlterMutation ( ) & & entry - > znode_name > mutation_pointer ) <nl> { <nl> LOG_TRACE ( log , " Adding mutation " < < entry - > znode_name < < " with alter version " < < entry - > alter_version < < " to the queue " ) ; <nl> alter_chain . addMutationForAlter ( entry - > alter_version , state_lock ) ; <nl> ReplicatedMergeTreeMutationEntryPtr ReplicatedMergeTreeQueue : : removeMutation ( <nl> mutations_by_partition . erase ( partition_and_block_num . first ) ; <nl> } <nl> <nl> - if ( entry - > alter_version ! = - 1 ) <nl> + if ( entry - > isAlterMutation ( ) ) <nl> { <nl> LOG_DEBUG ( log , " Removed alter " < < entry - > alter_version < < " because mutation " + entry - > znode_name + " were killed . " ) ; <nl> alter_chain . finishDataAlter ( entry - > alter_version , state_lock ) ; <nl> bool ReplicatedMergeTreeQueue : : shouldExecuteLogEntry ( <nl> MergeTreeData & data , <nl> std : : lock_guard < std : : mutex > & state_lock ) const <nl> { <nl> + / / / If our entry produce part which is alredy covered by <nl> + / / / some other entry which is currently executing , then we can postpone this entry . <nl> if ( entry . type = = LogEntry : : MERGE_PARTS <nl> | | entry . type = = LogEntry : : GET_PART <nl> | | entry . type = = LogEntry : : MUTATE_PART ) <nl> bool ReplicatedMergeTreeQueue : : shouldExecuteLogEntry ( <nl> } <nl> } <nl> <nl> + / / / Alters must be executed one by one . First metadata change , and after that data alter ( MUTATE_PART entries with ) . <nl> + / / / corresponding alter_version . <nl> if ( entry . type = = LogEntry : : ALTER_METADATA ) <nl> { <nl> if ( ! alter_chain . canExecuteMetaAlter ( entry . alter_version , state_lock ) ) <nl> bool ReplicatedMergeTreeQueue : : shouldExecuteLogEntry ( <nl> } <nl> } <nl> <nl> - if ( entry . type = = LogEntry : : MUTATE_PART & & entry . alter_version ! = - 1 ) <nl> + / / / If this MUTATE_PART is part of alter modify / drop query , than we have to execute them one by one <nl> + if ( entry . isAlterMutation ( ) ) <nl> { <nl> if ( ! alter_chain . canExecuteDataAlter ( entry . alter_version , state_lock ) ) <nl> { <nl> bool ReplicatedMergeTreeQueue : : shouldExecuteLogEntry ( <nl> out_postpone_reason = " Cannot execute alter data with version : " + std : : to_string ( entry . alter_version ) <nl> + " because another alter " + std : : to_string ( head_alter ) + " must be executed before " ; <nl> <nl> - <nl> return false ; <nl> } <nl> } <nl> bool ReplicatedMergeTreeQueue : : tryFinalizeMutations ( zkutil : : ZooKeeperPtr zookeep <nl> { <nl> LOG_TRACE ( log , " Mutation " < < entry - > znode_name < < " is done " ) ; <nl> it - > second . is_done = true ; <nl> - if ( entry - > alter_version ! = - 1 ) <nl> + if ( entry - > isAlterMutation ( ) ) <nl> { <nl> LOG_TRACE ( log , " Finishing data alter with version " < < entry - > alter_version < < " for entry " < < entry - > znode_name ) ; <nl> alter_chain . finishDataAlter ( entry - > alter_version , lock ) ; <nl> mmm a / dbms / src / Storages / MergeTree / ReplicatedMergeTreeQueue . h <nl> ppp b / dbms / src / Storages / MergeTree / ReplicatedMergeTreeQueue . h <nl> class ReplicatedMergeTreeQueue <nl> void updateMutations ( zkutil : : ZooKeeperPtr zookeeper , Coordination : : WatchCallback watch_callback = { } ) ; <nl> <nl> / / / Remove a mutation from ZooKeeper and from the local set . Returns the removed entry or nullptr <nl> - / / / if it could not be found . <nl> + / / / if it could not be found . Called during KILL MUTATION query execution . <nl> ReplicatedMergeTreeMutationEntryPtr removeMutation ( zkutil : : ZooKeeperPtr zookeeper , const String & mutation_id ) ; <nl> <nl> / * * Remove the action from the queue with the parts covered by part_name ( from ZK and from the RAM ) . <nl> class ReplicatedMergeTreeMergePredicate <nl> const MergeTreeData : : DataPartPtr & left , const MergeTreeData : : DataPartPtr & right , <nl> String * out_reason = nullptr ) const ; <nl> <nl> - / / / Return nonempty optional if the part can and should be mutated . <nl> - / / / Returned mutation version number is always the biggest possible . <nl> + / / / Return nonempty optional of desired mutation version and alter version . <nl> + / / / If we have no alter ( modify / drop ) mutations in mutations queue , than we return biggest possible <nl> + / / / mutation version ( and - 1 as alter version ) . In other case , we return biggest mutation version with <nl> + / / / smallest alter version . This required , because we have to execute alter mutations sequentially and <nl> + / / / don ' t glue them together . Alter is rare operation , so it shouldn ' t affect performance . <nl> std : : optional < std : : pair < Int64 , int > > getDesiredMutationVersion ( const MergeTreeData : : DataPartPtr & part ) const ; <nl> <nl> bool isMutationFinished ( const ReplicatedMergeTreeMutationEntry & mutation ) const ; <nl> mmm a / dbms / src / Storages / StorageReplicatedMergeTree . cpp <nl> ppp b / dbms / src / Storages / StorageReplicatedMergeTree . cpp <nl> bool StorageReplicatedMergeTree : : executeLogEntry ( LogEntry & entry ) <nl> } <nl> else if ( entry . type = = LogEntry : : MERGE_PARTS ) <nl> { <nl> + / / / Sometimes it ' s better to fetch merged part instead of merge <nl> + / / / For example when we don ' t have all source parts for merge <nl> do_fetch = ! tryExecuteMerge ( entry ) ; <nl> } <nl> else if ( entry . type = = LogEntry : : MUTATE_PART ) <nl> { <nl> + / / / Sometimes it ' s better to fetch mutated part instead of merge <nl> do_fetch = ! tryExecutePartMutation ( entry ) ; <nl> } <nl> else if ( entry . type = = LogEntry : : ALTER_METADATA ) <nl> bool StorageReplicatedMergeTree : : tryExecutePartMutation ( const StorageReplicatedM <nl> <nl> bool StorageReplicatedMergeTree : : executeFetch ( LogEntry & entry ) <nl> { <nl> + / / / Looking for covering part . After that entry . actual_new_part_name may be filled . <nl> String replica = findReplicaHavingCoveringPart ( entry , true ) ; <nl> const auto storage_settings_ptr = getSettings ( ) ; <nl> <nl> bool StorageReplicatedMergeTree : : executeMetadataAlter ( const StorageReplicatedMer <nl> zookeeper - > multi ( requests ) ; <nl> <nl> { <nl> + / / / TODO ( relax this lock ) <nl> auto table_lock = lockExclusively ( RWLockImpl : : NO_QUERY ) ; <nl> <nl> LOG_INFO ( log , " Metadata changed in ZooKeeper . Applying changes locally . " ) ; <nl> bool StorageReplicatedMergeTree : : executeMetadataAlter ( const StorageReplicatedMer <nl> LOG_INFO ( log , " Applied changes to the metadata of the table . Current metadata version : " < < metadata_version ) ; <nl> } <nl> <nl> - / / / This transaction may not happen , but it ' s ok , because on the next retry we will eventually create this node <nl> + / / / This transaction may not happen , but it ' s OK , because on the next retry we will eventually create / update this node <nl> zookeeper - > createOrUpdate ( replica_path + " / metadata_version " , std : : to_string ( metadata_version ) , zkutil : : CreateMode : : Persistent ) ; <nl> <nl> recalculateColumnSizes ( ) ; <nl> void StorageReplicatedMergeTree : : alter ( <nl> std : : optional < EphemeralLocksInAllPartitions > lock_holder ; <nl> <nl> / / / No we will prepare mutations record <nl> + / / / This code pretty same with mutate ( ) function but process results slightly differently <nl> if ( alter_entry - > have_mutation ) <nl> { <nl> String mutations_path = zookeeper_path + " / mutations " ; <nl> void StorageReplicatedMergeTree : : alter ( <nl> { <nl> if ( alter_entry - > have_mutation ) <nl> { <nl> - / / / Record in replication / log <nl> + / / / ALTER_METADATA record in replication / log <nl> String alter_path = dynamic_cast < const Coordination : : CreateResponse & > ( * results [ 2 ] ) . path_created ; <nl> alter_entry - > znode_name = alter_path . substr ( alter_path . find_last_of ( ' / ' ) + 1 ) ; <nl> <nl> - / / / Record in / mutations <nl> + / / / ReplicatedMergeTreeMutationEntry record in / mutations <nl> String mutation_path = dynamic_cast < const Coordination : : CreateResponse & > ( * results . back ( ) ) . path_created ; <nl> mutation_znode = mutation_path . substr ( mutation_path . find_last_of ( ' / ' ) + 1 ) ; <nl> } <nl> else <nl> { <nl> - / / / Record in replication / log <nl> + / / / ALTER_METADATA record in replication / log <nl> String alter_path = dynamic_cast < const Coordination : : CreateResponse & > ( * results . back ( ) ) . path_created ; <nl> alter_entry - > znode_name = alter_path . substr ( alter_path . find_last_of ( ' / ' ) + 1 ) ; <nl> } <nl> void StorageReplicatedMergeTree : : alter ( <nl> if ( dynamic_cast < const Coordination : : SetResponse & > ( * results [ 0 ] ) . error ) <nl> throw Exception ( " Metadata on replica is not up to date with common metadata in Zookeeper . Cannot alter " , ErrorCodes : : CANNOT_ASSIGN_ALTER ) ; <nl> <nl> - LOG_TRACE ( log , " We have version conflict with inserts because of concurrent inserts . Will try to assign alter one more time . " ) ; <nl> continue ; <nl> } <nl> else <nl> mmm a / dbms / src / Storages / StorageReplicatedMergeTree . h <nl> ppp b / dbms / src / Storages / StorageReplicatedMergeTree . h <nl> class StorageReplicatedMergeTree : public ext : : shared_ptr_helper < StorageReplicat <nl> / / / Do the merge or recommend to make the fetch instead of the merge <nl> bool tryExecuteMerge ( const LogEntry & entry ) ; <nl> <nl> + / / / Execute alter of table metadata . Set replica / metdata and replica / columns <nl> + / / / nodes in zookeeper and also changes in memory metadata . <nl> + / / / New metadata and columns values stored in entry . <nl> bool executeMetadataAlter ( const LogEntry & entry ) ; <nl> <nl> + / / / Execute MUTATE_PART entry . Part name and mutation commands <nl> + / / / stored in entry . This function relies on MergerMutator class . <nl> bool tryExecutePartMutation ( const LogEntry & entry ) ; <nl> <nl> <nl> + / / / Fetch part from other replica ( inserted or merged / mutated ) <nl> + / / / NOTE : Attention ! First of all tries to find covering part on other replica <nl> + / / / and set it into entry . actual_new_part_name . After that tries to fetch this new covering part . <nl> + / / / If fetch was not successful , clears entry . actual_new_part_name . <nl> bool executeFetch ( LogEntry & entry ) ; <nl> <nl> void executeClearColumnOrIndexInPartition ( const LogEntry & entry ) ; <nl>
More comments and slightly better code
ClickHouse/ClickHouse
382f6ab720c7f7c384e729edf49811a29d118f01
2020-02-17T16:33:05Z
similarity index 95 % <nl> rename from Examples / DataCollectorSGM . h <nl> rename to Examples / DataCollection / DataCollectorSGM . h <nl> mmm a / Examples / DataCollectorSGM . h <nl> ppp b / Examples / DataCollection / DataCollectorSGM . h <nl> <nl> # include " vehicles / multirotor / api / MultirotorRpcLibClient . hpp " <nl> # include " vehicles / multirotor / api / MultirotorApiBase . hpp " <nl> # include " RandomPointPoseGeneratorNoRoll . h " <nl> - # include " . . / SGM / src / sgmstereo / sgmstereo . h " <nl> - # include " . . / SGM / src / stereoPipeline / StateStereo . h " <nl> + # include " . . / . . / SGM / src / sgmstereo / sgmstereo . h " <nl> + # include " . . / . . / SGM / src / stereoPipeline / StateStereo . h " <nl> # include " writePNG . h " <nl> STRICT_MODE_OFF <nl> # ifndef RPCLIB_MSGPACK <nl> STRICT_MODE_OFF <nl> # include " rpc / rpc_error . h " <nl> STRICT_MODE_ON <nl> <nl> - <nl> + / / NOTE : baseline ( float B ) and FOV ( float fov ) need to be set correctly ! <nl> class DataCollectorSGM { <nl> + <nl> + private : <nl> + / / baseline * focal_length = depth * disparity <nl> + float fov = Utils : : degreesToRadians ( 90 . 0f ) ; <nl> + float B = 0 . 25 ; <nl> + float f = w / ( 2 * tan ( fov / 2 ) ) ; <nl> + <nl> public : <nl> DataCollectorSGM ( std : : string storage_dir ) <nl> : storage_dir_ ( storage_dir ) <nl> class DataCollectorSGM { <nl> int h ; <nl> float dtime = 0 ; <nl> <nl> - / / baseline * focal_length = depth * disparity <nl> - float fov = Utils : : degreesToRadians ( 90 . 0f ) ; <nl> - float f = w / ( 2 * tan ( fov / 2 ) ) ; <nl> - float B = 0 . 25 ; <nl> - <nl> private : <nl> struct ImagesResult { <nl> std : : vector < ImageResponse > response ; <nl> class DataCollectorSGM { <nl> <nl> auto process_time = clock - > nowNanos ( ) ; <nl> <nl> + / / Initialze file names <nl> std : : string left_file_name = Utils : : stringf ( " left / % 06d . png " , result - > sample ) ; <nl> std : : string right_file_name = Utils : : stringf ( " right / % 06d . png " , result - > sample ) ; <nl> std : : string depth_gt_file_name = Utils : : stringf ( " depth_gt / % 06d . pfm " , result - > sample ) ; <nl> class DataCollectorSGM { <nl> std : : string disparity_sgm_viz_file_name = Utils : : stringf ( " disparity_sgm_viz / % 06d . png " , result - > sample ) ; <nl> std : : string confidence_sgm_file_name = Utils : : stringf ( " confidence_sgm / % 06d . png " , result - > sample ) ; <nl> <nl> - / / Remove alpha <nl> + / / Initialize data containers <nl> std : : vector < uint8_t > left_img ( h * w * 3 ) ; <nl> std : : vector < uint8_t > right_img ( h * w * 3 ) ; <nl> + std : : vector < float > gt_depth_data = result - > response . at ( 2 ) . image_data_float ; <nl> + std : : vector < float > gt_disparity_data = result - > response . at ( 3 ) . image_data_float ; <nl> + std : : vector < float > sgm_depth_data ( h * w ) ; <nl> + std : : vector < float > sgm_disparity_data ( h * w ) ; <nl> + std : : vector < uint8_t > sgm_confidence_data ( h * w ) ; <nl> + <nl> + / / Remove alpha from RGB images <nl> int counter = 0 ; <nl> for ( int idx = 0 ; idx < ( h * w * 4 ) ; idx + + ) { <nl> if ( ( idx + 1 ) % 4 = = 0 ) { <nl> class DataCollectorSGM { <nl> right_img [ idx - counter ] = result - > response . at ( 1 ) . image_data_uint8 [ idx ] ; <nl> } <nl> <nl> - std : : vector < float > gt_depth_data = result - > response . at ( 2 ) . image_data_float ; <nl> - std : : vector < float > gt_disparity_data = result - > response . at ( 3 ) . image_data_float ; <nl> - <nl> - std : : vector < float > sgm_depth_data ( h * w ) ; <nl> - std : : vector < float > sgm_disparity_data ( h * w ) ; <nl> - std : : vector < uint8_t > sgm_confidence_data ( h * w ) ; <nl> - <nl> + / / Get SGM disparity and confidence <nl> p_state - > ProcessFrameAirSim ( result - > sample , dtime , left_img , right_img ) ; <nl> <nl> + / / Get adjust SGM disparity and compute depth <nl> for ( int idx = 0 ; idx < ( h * w ) ; idx + + ) <nl> { <nl> float d = p_state - > dispMap [ idx ] ; <nl> class DataCollectorSGM { <nl> <nl> } <nl> <nl> + / / Write files to disk <nl> + / / Left and right RGB image <nl> FILE * img_l = fopen ( FileSystem : : combine ( result - > storage_dir_ , left_file_name ) . c_str ( ) , " wb " ) ; <nl> svpng ( img_l , w , h , reinterpret_cast < const unsigned char * > ( left_img . data ( ) ) , 0 ) ; <nl> fclose ( img_l ) ; <nl> - <nl> FILE * img_r = fopen ( FileSystem : : combine ( result - > storage_dir_ , right_file_name ) . c_str ( ) , " wb " ) ; <nl> svpng ( img_r , w , h , reinterpret_cast < const unsigned char * > ( right_img . data ( ) ) , 0 ) ; <nl> fclose ( img_r ) ; <nl> - <nl> - / / below is not needed because we get disparity directly <nl> - / / convertToPlanDepth ( depth_data , w , h ) ; <nl> - / / float f = result . response . at ( 2 ) . width / 2 . 0f - 1 ; <nl> - / / convertToDisparity ( depth_data , f , 25 / 100 . 0f ) ; <nl> <nl> + / / GT disparity and depth <nl> Utils : : writePfmFile ( gt_depth_data . data ( ) , w , h , FileSystem : : combine ( result - > storage_dir_ , depth_gt_file_name ) ) ; <nl> denormalizeDisparity ( gt_disparity_data , w ) ; <nl> Utils : : writePfmFile ( gt_disparity_data . data ( ) , w , h , FileSystem : : combine ( result - > storage_dir_ , disparity_gt_file_name ) ) ; <nl> <nl> + / / SGM depth disparity and confidence <nl> Utils : : writePfmFile ( sgm_depth_data . data ( ) , w , h , FileSystem : : combine ( result - > storage_dir_ , depth_sgm_file_name ) ) ; <nl> Utils : : writePfmFile ( sgm_disparity_data . data ( ) , w , h , FileSystem : : combine ( result - > storage_dir_ , disparity_sgm_file_name ) ) ; <nl> - <nl> FILE * sgm_c = fopen ( FileSystem : : combine ( result - > storage_dir_ , confidence_sgm_file_name ) . c_str ( ) , " wb " ) ; <nl> svpng ( sgm_c , w , h , reinterpret_cast < const unsigned char * > ( sgm_confidence_data . data ( ) ) , 0 , 1 ) ; <nl> fclose ( sgm_c ) ; <nl> <nl> - / / Disparity for visulatization <nl> + / / GT and SGM disparity for visulatization <nl> std : : vector < uint8_t > sgm_disparity_viz ( h * w * 3 ) ; <nl> getColorVisualization ( sgm_disparity_data , sgm_disparity_viz , h , w , 0 . 05f * w ) ; <nl> FILE * disparity_sgm = fopen ( FileSystem : : combine ( result - > storage_dir_ , disparity_sgm_viz_file_name ) . c_str ( ) , " wb " ) ; <nl> svpng ( disparity_sgm , w , h , reinterpret_cast < const unsigned char * > ( sgm_disparity_viz . data ( ) ) , 0 ) ; <nl> fclose ( disparity_sgm ) ; <nl> - <nl> std : : vector < uint8_t > gt_disparity_viz ( h * w * 3 ) ; <nl> getColorVisualization ( gt_disparity_data , gt_disparity_viz , h , w , 0 . 05f * w ) ; <nl> FILE * disparity_gt = fopen ( FileSystem : : combine ( result - > storage_dir_ , disparity_gt_viz_file_name ) . c_str ( ) , " wb " ) ; <nl> svpng ( disparity_gt , w , h , reinterpret_cast < const unsigned char * > ( gt_disparity_viz . data ( ) ) , 0 ) ; <nl> fclose ( disparity_gt ) ; <nl> <nl> + / / Add all to file record <nl> ( * result - > file_list ) < < left_file_name < < " , " < < right_file_name < < " , " < < depth_gt_file_name < < " , " < < disparity_gt_file_name < < " , " < < depth_sgm_file_name < < " , " < < disparity_sgm_file_name < < " , " < < confidence_sgm_file_name < < std : : endl ; <nl> <nl> std : : cout < < " Image # " < < result - > sample <nl> similarity index 93 % <nl> rename from Examples / DataCollectorSGM_settings . json <nl> rename to Examples / DataCollection / DataCollectorSGM_settings . json <nl> mmm a / Examples / DataCollectorSGM_settings . json <nl> ppp b / Examples / DataCollection / DataCollectorSGM_settings . json <nl> <nl> " CaptureSettings " : [ <nl> { <nl> " ImageType " : 0 , <nl> + " TargetGamma " : 1 . 5 , <nl> " Width " : 960 , <nl> " Height " : 540 , <nl> " FOV_Degrees " : 90 <nl> <nl> { " WindowID " : 2 , " CameraID " : 2 , " ImageType " : 3 , " Visible " : true } <nl> ] , <nl> " Recording " : { <nl> - " RecordOnMove " : false , <nl> - " RecordInterval " : 0 . 05 , <nl> + " RecordOnMove " : true , <nl> + " RecordInterval " : 1 , <nl> " Cameras " : [ <nl> { " CameraID " : 0 , " ImageType " : 0 , " PixelsAsFloat " : false , " Compress " : true } , <nl> { " CameraID " : 1 , " ImageType " : 0 , " PixelsAsFloat " : false , " Compress " : true } , <nl> similarity index 100 % <nl> rename from Examples / RandomPointPoseGenerator . hpp <nl> rename to Examples / DataCollection / RandomPointPoseGenerator . hpp <nl> similarity index 100 % <nl> rename from Examples / RandomPointPoseGeneratorNoRoll . h <nl> rename to Examples / DataCollection / RandomPointPoseGeneratorNoRoll . h <nl> similarity index 100 % <nl> rename from Examples / StereoImageGenerator . hpp <nl> rename to Examples / DataCollection / StereoImageGenerator . hpp <nl> new file mode 100644 <nl> index 000000000 . . 329672514 <nl> Binary files / dev / null and b / Examples / DataCollection / exe / DataCollectorSGM . exe differ <nl> new file mode 100644 <nl> index 000000000 . . 9883e56de <nl> mmm / dev / null <nl> ppp b / Examples / DataCollection / exe / getData . bat <nl> <nl> + ECHO OFF <nl> + SET NUM = 1000 <nl> + SET AIRSIMPATH = E : \ AirSimBinaries <nl> + SET DATAPATH = D : \ Data \ AirSim <nl> + SET EXE = DataCollectorSGM . exe <nl> + <nl> + mkdir % DATAPATH % <nl> + <nl> + START / I % AIRSIMPATH % \ Africa \ Africa_001 . exe - windowed <nl> + TIMEOUT 30 & REM Waits 30 seconds <nl> + START / B / wait % EXE % % NUM % % DATAPATH % \ AA <nl> + TIMEOUT 10 & REM Waits 10 seconds <nl> + TASKKILL / F / IM Africa_001 . exe <nl> + <nl> + START / I % AIRSIMPATH % \ AirSimNH \ AirSimNH . exe - windowed <nl> + TIMEOUT 30 & REM Waits 30 seconds <nl> + START / B / wait % EXE % % NUM % % DATAPATH % \ NH <nl> + TIMEOUT 10 & REM Waits 10 seconds <nl> + TASKKILL / F / IM AirSimNH . exe <nl> + <nl> + START / I % AIRSIMPATH % \ CityEnviron \ CityEnviron . exe - windowed <nl> + TIMEOUT 30 & REM Waits 30 seconds <nl> + START / B / wait % EXE % % NUM % % DATAPATH % \ CE <nl> + TIMEOUT 10 & REM Waits 10 seconds <nl> + TASKKILL / F / IM CityEnviron . exe <nl> + <nl> + START / I % AIRSIMPATH % \ Coastline \ Coastline . exe - windowed <nl> + TIMEOUT 30 & REM Waits 30 seconds <nl> + START / B / wait % EXE % % NUM % % DATAPATH % \ CL <nl> + TIMEOUT 10 & REM Waits 10 seconds <nl> + TASKKILL / F / IM Coastline . exe <nl> + <nl> + START / I % AIRSIMPATH % \ Forest \ Forest . exe - windowed <nl> + TIMEOUT 30 & REM Waits 30 seconds <nl> + START / B / wait % EXE % % NUM % % DATAPATH % \ FT <nl> + TIMEOUT 10 & REM Waits 10 seconds <nl> + TASKKILL / F / IM Forest . exe <nl> + <nl> + START / I % AIRSIMPATH % \ LandscapeMountains \ LandscapeMountains . exe - windowed <nl> + TIMEOUT 30 & REM Waits 30 seconds <nl> + START / B / wait % EXE % % NUM % % DATAPATH % \ LM <nl> + TIMEOUT 10 & REM Waits 10 seconds <nl> + TASKKILL / F / IM LandscapeMountains . exe <nl> + <nl> + START / I % AIRSIMPATH % \ SimpleMaze \ Car_Maze . exe - windowed <nl> + TIMEOUT 30 & REM Waits 30 seconds <nl> + START / B / wait % EXE % % NUM % % DATAPATH % \ SM <nl> + TIMEOUT 10 & REM Waits 10 seconds <nl> + TASKKILL / F / IM Car_Maze . exe <nl> + <nl> + START / I % AIRSIMPATH % \ Warehouse \ Factory . exe - windowed <nl> + TIMEOUT 30 & REM Waits 30 seconds <nl> + START / B / wait % EXE % % NUM % % DATAPATH % \ WH <nl> + TIMEOUT 10 & REM Waits 10 seconds <nl> + TASKKILL / F / IM Factory . exe <nl> + <nl> + START / I % AIRSIMPATH % \ ZhangJiaJie \ ZhangJiaJie . exe - windowed <nl> + TIMEOUT 30 & REM Waits 30 seconds <nl> + START / B / wait % EXE % % NUM % % DATAPATH % \ ZJ <nl> + TIMEOUT 10 & REM Waits 10 seconds <nl> + TASKKILL / F / IM ZhangJiaJie . exe <nl> \ No newline at end of file <nl> similarity index 100 % <nl> rename from Examples / writePNG . h <nl> rename to Examples / DataCollection / writePNG . h <nl> mmm a / Examples / DepthNav / DepthNav . hpp <nl> ppp b / Examples / DepthNav / DepthNav . hpp <nl> STRICT_MODE_ON <nl> # include " common / Common . hpp " <nl> # include < exception > <nl> <nl> - # include " . . / SGM / src / sgmstereo / sgmstereo . h " <nl> - # include " . . / SGM / src / stereoPipeline / StateStereo . h " <nl> + # include " . . / . . / SGM / src / sgmstereo / sgmstereo . h " <nl> + # include " . . / . . / SGM / src / stereoPipeline / StateStereo . h " <nl> namespace msr { namespace airlib { <nl> <nl> class DepthNav { <nl> class DepthNav { <nl> real_T rotation_step_limit = Utils : : degreesToRadians ( 5 . 0f ) ; <nl> <nl> / / depth image dimension , index of pixel x , y = x * width + y <nl> - unsigned int depth_width = 256 , depth_height = 144 ; <nl> + unsigned int depth_width , depth_height ; <nl> <nl> / / Number of cells the depth image gets divided in to . Each cell is square . <nl> unsigned int M , N ; <nl> class DepthNav { <nl> <nl> DepthNav ( const Params & params = Params ( ) ) <nl> : params_ ( params ) <nl> - { <nl> + { } <nl> + <nl> + void initialize ( RpcLibClientBase & client , const std : : vector < ImageCaptureBase : : ImageRequest > & request ) { <nl> + const std : : vector < ImageCaptureBase : : ImageResponse > & response_init = client . simGetImages ( request ) ; <nl> + params_ . depth_width = response_init . at ( 0 ) . width ; <nl> + params_ . depth_height = response_init . at ( 0 ) . height ; <nl> params_ . vehicle_height_px = int ( ceil ( params_ . depth_height * params_ . vehicle_height / ( tan ( params_ . fov / 2 ) * params_ . max_allowed_obs_dist * 2 ) ) ) ; / / height <nl> - params_ . vehicle_width_px = int ( ceil ( params_ . depth_width * params_ . vehicle_width / ( tan ( hfov2vfov ( params_ . fov , params_ . depth_height , params_ . depth_width ) / 2 ) * params_ . max_allowed_obs_dist * 2 ) ) ) ; / / width <nl> - } <nl> + params_ . vehicle_width_px = int ( ceil ( params_ . depth_width * params_ . vehicle_width / ( tan ( hfov2vfov ( params_ . fov , params_ . depth_height , params_ . depth_width ) / 2 ) * params_ . max_allowed_obs_dist * 2 ) ) ) ; / / width <nl> + } <nl> <nl> - virtual void gotoGoal ( const Pose & goal_pose , RpcLibClientBase & client ) <nl> + virtual void gotoGoal ( const Pose & goal_pose , RpcLibClientBase & client , const std : : vector < ImageCaptureBase : : ImageRequest > & request ) <nl> { <nl> - typedef ImageCaptureBase : : ImageRequest ImageRequest ; <nl> + <nl> typedef ImageCaptureBase : : ImageResponse ImageResponse ; <nl> - typedef ImageCaptureBase : : ImageType ImageType ; <nl> - <nl> - std : : vector < ImageRequest > request = { <nl> - ImageRequest ( " 1 " , ImageType : : DepthPlanner , true ) / * , <nl> - ImageRequest ( " 1 " , ImageType : : Scene ) , <nl> - ImageRequest ( " 1 " , ImageType : : DisparityNormalized , true ) * / <nl> - } ; <nl> <nl> do { <nl> const Pose current_pose = client . simGetVehiclePose ( ) ; <nl> class DepthNav { <nl> <nl> <nl> <nl> - virtual void gotoGoalSGM ( const Pose & goal_pose , RpcLibClientBase & client , CStateStereo * p_state ) <nl> + virtual void gotoGoalSGM ( const Pose & goal_pose , RpcLibClientBase & client , const std : : vector < ImageCaptureBase : : ImageRequest > & request , CStateStereo * p_state ) <nl> { <nl> - typedef ImageCaptureBase : : ImageRequest ImageRequest ; <nl> + <nl> typedef ImageCaptureBase : : ImageResponse ImageResponse ; <nl> - typedef ImageCaptureBase : : ImageType ImageType ; <nl> typedef common_utils : : FileSystem FileSystem ; <nl> <nl> float dtime = 0 ; <nl> int counter = 0 ; <nl> - std : : vector < float > sgm_depth_image ( params_ . depth_height * params_ . depth_width ) ; <nl> <nl> - std : : vector < ImageRequest > request = { <nl> - ImageRequest ( " front_left " , ImageType : : Scene , false , false ) , <nl> - ImageRequest ( " front_right " , ImageType : : Scene , false , false ) , / * <nl> - ImageRequest ( " front_left " , ImageType : : DepthPlanner , true ) , <nl> - ImageRequest ( " front_left " , ImageType : : DisparityNormalized , true ) * / <nl> - } ; <nl> + std : : vector < float > sgm_depth_image ( params_ . depth_height * params_ . depth_width ) ; <nl> <nl> do { <nl> const Pose current_pose = client . simGetVehiclePose ( ) ; <nl> mmm a / Examples / DepthNav / DepthNav_settings . json <nl> ppp b / Examples / DepthNav / DepthNav_settings . json <nl> <nl> " CaptureSettings " : [ <nl> { <nl> " ImageType " : 0 , <nl> + " TargetGamma " : 1 . 5 , <nl> " Width " : 256 , <nl> " Height " : 144 , <nl> " FOV_Degrees " : 90 <nl> mmm a / Examples / Examples . vcxproj <nl> ppp b / Examples / Examples . vcxproj <nl> <nl> < ClCompile Include = " main . cpp " / > <nl> < / ItemGroup > <nl> < ItemGroup > <nl> - < ClInclude Include = " DataCollectorSGM . h " / > <nl> + < ClInclude Include = " DataCollection \ DataCollectorSGM . h " / > <nl> + < ClInclude Include = " DataCollection \ RandomPointPoseGenerator . hpp " / > <nl> + < ClInclude Include = " DataCollection \ RandomPointPoseGeneratorNoRoll . h " / > <nl> + < ClInclude Include = " DataCollection \ StereoImageGenerator . hpp " / > <nl> + < ClInclude Include = " DataCollection \ writePNG . h " / > <nl> < ClInclude Include = " DepthNav \ DepthNav . hpp " / > <nl> < ClInclude Include = " DepthNav \ DepthNavCost . hpp " / > <nl> < ClInclude Include = " DepthNav \ DepthNavOptAStar . hpp " / > <nl> < ClInclude Include = " DepthNav \ DepthNavThreshold . hpp " / > <nl> < ClInclude Include = " GaussianMarkovTest . hpp " / > <nl> - < ClInclude Include = " RandomPointPoseGenerator . hpp " / > <nl> - < ClInclude Include = " RandomPointPoseGeneratorNoRoll . h " / > <nl> < ClInclude Include = " StandAlonePhysics . hpp " / > <nl> < ClInclude Include = " StandAloneSensors . hpp " / > <nl> - < ClInclude Include = " StereoImageGenerator . hpp " / > <nl> - < ClInclude Include = " writePNG . h " / > <nl> < / ItemGroup > <nl> < Import Project = " $ ( VCTargetsPath ) \ Microsoft . Cpp . targets " / > <nl> < ImportGroup Label = " ExtensionTargets " > <nl> mmm a / Examples / Examples . vcxproj . filters <nl> ppp b / Examples / Examples . vcxproj . filters <nl> <nl> < UniqueIdentifier > { 67DA6AB6 - F800 - 4c08 - 8B7A - 83BB121AAD01 } < / UniqueIdentifier > <nl> < Extensions > rc ; ico ; cur ; bmp ; dlg ; rc2 ; rct ; bin ; rgs ; gif ; jpg ; jpeg ; jpe ; resx ; tiff ; tif ; png ; wav ; mfcribbon - ms < / Extensions > <nl> < / Filter > <nl> + < Filter Include = " Header Files \ DepthNav " > <nl> + < UniqueIdentifier > { 18b89111 - 7869 - 4b4b - 8728 - 23bdc23b8ec6 } < / UniqueIdentifier > <nl> + < / Filter > <nl> + < Filter Include = " Header Files \ DataCollection " > <nl> + < UniqueIdentifier > { 42fbde54 - 9eb9 - 489e - a1e2 - aa075456f0b3 } < / UniqueIdentifier > <nl> + < / Filter > <nl> < / ItemGroup > <nl> < ItemGroup > <nl> < ClCompile Include = " main . cpp " > <nl> <nl> < ClInclude Include = " StandAlonePhysics . hpp " > <nl> < Filter > Header Files < / Filter > <nl> < / ClInclude > <nl> - < ClInclude Include = " StereoImageGenerator . hpp " > <nl> - < Filter > Header Files < / Filter > <nl> - < / ClInclude > <nl> - < ClInclude Include = " RandomPointPoseGenerator . hpp " > <nl> - < Filter > Header Files < / Filter > <nl> - < / ClInclude > <nl> < ClInclude Include = " GaussianMarkovTest . hpp " > <nl> < Filter > Header Files < / Filter > <nl> < / ClInclude > <nl> < ClInclude Include = " DepthNav \ DepthNav . hpp " > <nl> - < Filter > Header Files < / Filter > <nl> - < / ClInclude > <nl> - < ClInclude Include = " DepthNav \ DepthNavThreshold . hpp " > <nl> - < Filter > Header Files < / Filter > <nl> + < Filter > Header Files \ DepthNav < / Filter > <nl> < / ClInclude > <nl> < ClInclude Include = " DepthNav \ DepthNavCost . hpp " > <nl> - < Filter > Header Files < / Filter > <nl> + < Filter > Header Files \ DepthNav < / Filter > <nl> < / ClInclude > <nl> < ClInclude Include = " DepthNav \ DepthNavOptAStar . hpp " > <nl> - < Filter > Header Files < / Filter > <nl> + < Filter > Header Files \ DepthNav < / Filter > <nl> < / ClInclude > <nl> - < ClInclude Include = " writePNG . h " > <nl> - < Filter > Header Files < / Filter > <nl> + < ClInclude Include = " DepthNav \ DepthNavThreshold . hpp " > <nl> + < Filter > Header Files \ DepthNav < / Filter > <nl> < / ClInclude > <nl> - < ClInclude Include = " RandomPointPoseGeneratorNoRoll . h " > <nl> - < Filter > Header Files < / Filter > <nl> + < ClInclude Include = " DataCollection \ DataCollectorSGM . h " > <nl> + < Filter > Header Files \ DataCollection < / Filter > <nl> < / ClInclude > <nl> - < ClInclude Include = " DataCollectorSGM . h " > <nl> - < Filter > Header Files < / Filter > <nl> + < ClInclude Include = " DataCollection \ RandomPointPoseGenerator . hpp " > <nl> + < Filter > Header Files \ DataCollection < / Filter > <nl> + < / ClInclude > <nl> + < ClInclude Include = " DataCollection \ RandomPointPoseGeneratorNoRoll . h " > <nl> + < Filter > Header Files \ DataCollection < / Filter > <nl> + < / ClInclude > <nl> + < ClInclude Include = " DataCollection \ StereoImageGenerator . hpp " > <nl> + < Filter > Header Files \ DataCollection < / Filter > <nl> + < / ClInclude > <nl> + < ClInclude Include = " DataCollection \ writePNG . h " > <nl> + < Filter > Header Files \ DataCollection < / Filter > <nl> < / ClInclude > <nl> < / ItemGroup > <nl> < / Project > <nl> \ No newline at end of file <nl> mmm a / Examples / main . cpp <nl> ppp b / Examples / main . cpp <nl> <nl> # include " StandAloneSensors . hpp " <nl> # include " StandAlonePhysics . hpp " <nl> - # include " StereoImageGenerator . hpp " <nl> - # include " DataCollectorSGM . h " <nl> + # include " DataCollection / StereoImageGenerator . hpp " <nl> + # include " DataCollection / DataCollectorSGM . h " <nl> # include " GaussianMarkovTest . hpp " <nl> # include " DepthNav / DepthNavCost . hpp " <nl> # include " DepthNav / DepthNavThreshold . hpp " <nl> # include " DepthNav / DepthNavOptAStar . hpp " <nl> # include < iostream > <nl> # include < string > <nl> - # include " . . / SGM / src / sgmstereo / sgmstereo . h " <nl> - # include " . . / SGM / src / stereoPipeline / StateStereo . h " <nl> # include < sys / stat . h > <nl> # ifndef _USE_MATH_DEFINES <nl> # define _USE_MATH_DEFINES <nl> # endif <nl> - # include < math . h > <nl> - # include " writePNG . h " <nl> + # include < math . h > <nl> <nl> int runStandAloneSensors ( int argc , const char * argv [ ] ) <nl> { <nl> void runGaussianMarkovTest ( ) <nl> <nl> void runDepthNavGT ( ) <nl> { <nl> + typedef ImageCaptureBase : : ImageRequest ImageRequest ; <nl> + typedef ImageCaptureBase : : ImageType ImageType ; <nl> + <nl> + std : : vector < ImageRequest > request = { <nl> + ImageRequest ( " front_left " , ImageType : : DepthPlanner , true ) / * , <nl> + ImageRequest ( " front_left " , ImageType : : Scene ) , <nl> + ImageRequest ( " front_left " , ImageType : : DisparityNormalized , true ) * / <nl> + } ; <nl> + <nl> Pose startPose = Pose ( Vector3r ( 0 , 0 , - 1 ) , Quaternionr ( 1 , 0 , 0 , 0 ) ) ; / / start pose <nl> Pose goalPose = Pose ( Vector3r ( 50 , 105 , - 1 ) , Quaternionr ( 1 , 0 , 0 , 0 ) ) ; / / final pose <nl> / / Pose goalPose = client . simGetObjectPose ( " OrangeBall " ) ; <nl> void runDepthNavGT ( ) <nl> / / DepthNavThreshold depthNav ; <nl> DepthNavCost depthNav ; <nl> / / DepthNavOptAStar depthNav ; <nl> - depthNav . gotoGoal ( goalPose , client ) ; <nl> + depthNav . initialize ( client , request ) ; <nl> + depthNav . gotoGoal ( goalPose , client , request ) ; <nl> } <nl> <nl> void runDepthNavSGM ( ) <nl> { <nl> + typedef ImageCaptureBase : : ImageRequest ImageRequest ; <nl> + typedef ImageCaptureBase : : ImageType ImageType ; <nl> + <nl> + std : : vector < ImageRequest > request = { <nl> + ImageRequest ( " front_left " , ImageType : : Scene , false , false ) , <nl> + ImageRequest ( " front_right " , ImageType : : Scene , false , false ) , / * <nl> + ImageRequest ( " front_left " , ImageType : : DepthPlanner , true ) , <nl> + ImageRequest ( " front_left " , ImageType : : DisparityNormalized , true ) * / <nl> + } ; <nl> + <nl> Pose startPose = Pose ( Vector3r ( 0 , 0 , - 1 ) , Quaternionr ( 1 , 0 , 0 , 0 ) ) ; / / start pose <nl> Pose goalPose = Pose ( Vector3r ( 50 , 105 , - 1 ) , Quaternionr ( 1 , 0 , 0 , 0 ) ) ; / / final pose <nl> <nl> void runDepthNavSGM ( ) <nl> <nl> / / DepthNavThreshold depthNav ; <nl> DepthNavCost depthNav ; <nl> - / / DepthNavOptAStar depthNav ; <nl> + / / DepthNavOptAStar depthNav ; <nl> + depthNav . initialize ( client , request ) ; <nl> + <nl> SGMOptions params ; <nl> CStateStereo * p_state ; <nl> <nl> void runDepthNavSGM ( ) <nl> p_state = new CStateStereo ( ) ; <nl> p_state - > Initialize ( params , depthNav . params_ . depth_height , depthNav . params_ . depth_width ) ; <nl> <nl> - depthNav . gotoGoalSGM ( goalPose , client , p_state ) ; <nl> + depthNav . gotoGoalSGM ( goalPose , client , request , p_state ) ; <nl> <nl> / / Cleanup <nl> delete p_state ; <nl> void runDepthNavSGM ( ) <nl> <nl> int main ( int argc , const char * argv [ ] ) <nl> { <nl> - runDepthNavGT ( ) ; <nl> + / / runDepthNavGT ( ) ; <nl> / / runDepthNavSGM ( ) ; <nl> - / / runDataCollectorSGM ( argc , argv ) ; <nl> + runDataCollectorSGM ( argc , argv ) ; <nl> <nl> return 0 ; <nl> } <nl> \ No newline at end of file <nl>
Merge pull request from Microsoft / sgm
microsoft/AirSim
f9b4e282690faac6ebc56b8fc851a6d96de7f04d
2018-09-07T01:13:58Z
mmm a / tensorflow / compiler / xla / service / algebraic_simplifier . cc <nl> ppp b / tensorflow / compiler / xla / service / algebraic_simplifier . cc <nl> class AlgebraicSimplifierVisitor : public DfsHloVisitorWithDefault { <nl> Status HandleDynamicUpdateSlice ( <nl> HloInstruction * dynamic_update_slice ) override ; <nl> <nl> + Status HandleSelect ( HloInstruction * select ) override ; <nl> + <nl> Status HandleSort ( HloInstruction * sort ) override ; <nl> <nl> Status HandleTranspose ( HloInstruction * transpose ) override ; <nl> Status AlgebraicSimplifierVisitor : : HandleReduceWindow ( <nl> / * reduce_computation = * / function ) ) ; <nl> } <nl> <nl> + Status AlgebraicSimplifierVisitor : : HandleSelect ( HloInstruction * select ) { <nl> + / / select ( x , y , y ) - > y . <nl> + if ( select - > operand ( 1 ) = = select - > operand ( 2 ) ) { <nl> + return ReplaceInstruction ( select , select - > mutable_operand ( 1 ) ) ; <nl> + } <nl> + / / select ( true , x , y ) - > x . <nl> + if ( IsAll ( select - > operand ( 0 ) , true ) ) { <nl> + return ReplaceInstruction ( select , select - > mutable_operand ( 1 ) ) ; <nl> + } <nl> + / / select ( false , x , y ) - > y . <nl> + if ( IsAll ( select - > operand ( 0 ) , false ) ) { <nl> + return ReplaceInstruction ( select , select - > mutable_operand ( 2 ) ) ; <nl> + } <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> Status AlgebraicSimplifierVisitor : : HandleSort ( HloInstruction * sort ) { <nl> auto operand = sort - > mutable_operand ( 0 ) ; <nl> int64 dimension_to_sort = sort - > dimensions ( 0 ) ; <nl> mmm a / tensorflow / compiler / xla / service / algebraic_simplifier_test . cc <nl> ppp b / tensorflow / compiler / xla / service / algebraic_simplifier_test . cc <nl> TEST_F ( AlgebraicSimplifierTest , MulZero ) { <nl> EXPECT_EQ ( computation - > root_instruction ( ) , zero ) ; <nl> } <nl> <nl> + / / Test that select ( true , a , b ) is simplified to a <nl> + TEST_F ( AlgebraicSimplifierTest , SelectTrue ) { <nl> + Shape r0s32 = ShapeUtil : : MakeShape ( S32 , { } ) ; <nl> + HloComputation : : Builder builder ( TestName ( ) ) ; <nl> + HloInstruction * param0 = builder . AddInstruction ( <nl> + HloInstruction : : CreateParameter ( 0 , r0s32 , " param0 " ) ) ; <nl> + HloInstruction * param1 = builder . AddInstruction ( <nl> + HloInstruction : : CreateParameter ( 1 , r0s32 , " param1 " ) ) ; <nl> + HloInstruction * one = builder . AddInstruction ( <nl> + HloInstruction : : CreateConstant ( LiteralUtil : : CreateR0 < bool > ( true ) ) ) ; <nl> + builder . AddInstruction ( HloInstruction : : CreateTernary ( <nl> + r0s32 , HloOpcode : : kSelect , one , param0 , param1 ) ) ; <nl> + <nl> + auto module = CreateNewVerifiedModule ( ) ; <nl> + auto computation = module - > AddEntryComputation ( builder . Build ( ) ) ; <nl> + HloInstruction * root = computation - > root_instruction ( ) ; <nl> + EXPECT_EQ ( root - > opcode ( ) , HloOpcode : : kSelect ) ; <nl> + AlgebraicSimplifier simplifier ( / * is_layout_sensitive = * / false , <nl> + non_bitcasting_callback ( ) ) ; <nl> + ASSERT_TRUE ( simplifier . Run ( module . get ( ) ) . ValueOrDie ( ) ) ; <nl> + EXPECT_EQ ( computation - > root_instruction ( ) , param0 ) ; <nl> + } <nl> + <nl> + / / Test that select ( false , a , b ) is simplified to b <nl> + TEST_F ( AlgebraicSimplifierTest , SelectFalse ) { <nl> + Shape r0s32 = ShapeUtil : : MakeShape ( S32 , { } ) ; <nl> + HloComputation : : Builder builder ( TestName ( ) ) ; <nl> + HloInstruction * param0 = builder . AddInstruction ( <nl> + HloInstruction : : CreateParameter ( 0 , r0s32 , " param0 " ) ) ; <nl> + HloInstruction * param1 = builder . AddInstruction ( <nl> + HloInstruction : : CreateParameter ( 1 , r0s32 , " param1 " ) ) ; <nl> + HloInstruction * zero = builder . AddInstruction ( <nl> + HloInstruction : : CreateConstant ( LiteralUtil : : CreateR0 < bool > ( false ) ) ) ; <nl> + builder . AddInstruction ( HloInstruction : : CreateTernary ( <nl> + r0s32 , HloOpcode : : kSelect , zero , param0 , param1 ) ) ; <nl> + <nl> + auto module = CreateNewVerifiedModule ( ) ; <nl> + auto computation = module - > AddEntryComputation ( builder . Build ( ) ) ; <nl> + HloInstruction * root = computation - > root_instruction ( ) ; <nl> + EXPECT_EQ ( root - > opcode ( ) , HloOpcode : : kSelect ) ; <nl> + AlgebraicSimplifier simplifier ( / * is_layout_sensitive = * / false , <nl> + non_bitcasting_callback ( ) ) ; <nl> + ASSERT_TRUE ( simplifier . Run ( module . get ( ) ) . ValueOrDie ( ) ) ; <nl> + EXPECT_EQ ( computation - > root_instruction ( ) , param1 ) ; <nl> + } <nl> + <nl> + / / Test that select ( a , b , b ) is simplified to b <nl> + TEST_F ( AlgebraicSimplifierTest , SelectIdentical ) { <nl> + Shape r0s32 = ShapeUtil : : MakeShape ( S32 , { } ) ; <nl> + HloComputation : : Builder builder ( TestName ( ) ) ; <nl> + HloInstruction * param0 = builder . AddInstruction ( <nl> + HloInstruction : : CreateParameter ( 0 , r0s32 , " param0 " ) ) ; <nl> + HloInstruction * param1 = builder . AddInstruction ( <nl> + HloInstruction : : CreateParameter ( 1 , r0s32 , " param1 " ) ) ; <nl> + builder . AddInstruction ( HloInstruction : : CreateTernary ( <nl> + r0s32 , HloOpcode : : kSelect , param0 , param1 , param1 ) ) ; <nl> + <nl> + auto module = CreateNewVerifiedModule ( ) ; <nl> + auto computation = module - > AddEntryComputation ( builder . Build ( ) ) ; <nl> + HloInstruction * root = computation - > root_instruction ( ) ; <nl> + EXPECT_EQ ( root - > opcode ( ) , HloOpcode : : kSelect ) ; <nl> + AlgebraicSimplifier simplifier ( / * is_layout_sensitive = * / false , <nl> + non_bitcasting_callback ( ) ) ; <nl> + ASSERT_TRUE ( simplifier . Run ( module . get ( ) ) . ValueOrDie ( ) ) ; <nl> + EXPECT_EQ ( computation - > root_instruction ( ) , param1 ) ; <nl> + } <nl> + <nl> / / Test that Reduce ( Reduce ( A ) ) - > Reduce ( A ) <nl> TEST_F ( AlgebraicSimplifierTest , TwoReducesToOne ) { <nl> HloComputation : : Builder builder ( TestName ( ) ) ; <nl>
[ XLA ] Fold select to its operands when possible
tensorflow/tensorflow
5473b48a761ee1746686efe697bee7661bbaa612
2018-10-16T03:44:27Z
mmm a / BUILD . gn <nl> ppp b / BUILD . gn <nl> v8_source_set ( " v8_base_without_compiler " ) { <nl> " src / heap / paged - spaces - inl . h " , <nl> " src / heap / paged - spaces . cc " , <nl> " src / heap / paged - spaces . h " , <nl> - " src / heap / parallel - work - item . h " , <nl> " src / heap / read - only - heap - inl . h " , <nl> " src / heap / read - only - heap . cc " , <nl> " src / heap / read - only - heap . h " , <nl> deleted file mode 100644 <nl> index 9f58d305196 . . 00000000000 <nl> mmm a / src / heap / parallel - work - item . h <nl> ppp / dev / null <nl> <nl> - / / Copyright 2020 the V8 project authors . All rights reserved . <nl> - / / Use of this source code is governed by a BSD - style license that can be <nl> - / / found in the LICENSE file . <nl> - <nl> - # ifndef V8_HEAP_PARALLEL_WORK_ITEM_H_ <nl> - # define V8_HEAP_PARALLEL_WORK_ITEM_H_ <nl> - <nl> - # include < atomic > <nl> - <nl> - namespace v8 { <nl> - namespace internal { <nl> - <nl> - class ParallelWorkItem { <nl> - public : <nl> - ParallelWorkItem ( ) = default ; <nl> - <nl> - bool TryAcquire ( ) { <nl> - / / memory_order_relaxed is sufficient as the work item ' s state itself hasn ' t <nl> - / / been modified since the beginning of its associated job . This is only <nl> - / / atomically acquiring the right to work on it . <nl> - return reinterpret_cast < std : : atomic < bool > * > ( & acquire_ ) - > exchange ( <nl> - true , std : : memory_order_relaxed ) = = false ; <nl> - } <nl> - <nl> - private : <nl> - bool acquire_ { false } ; <nl> - } ; <nl> - <nl> - } / / namespace internal <nl> - } / / namespace v8 <nl> - <nl> - # endif / / V8_HEAP_PARALLEL_WORK_ITEM_H_ <nl> mmm a / src / heap / scavenger - inl . h <nl> ppp b / src / heap / scavenger - inl . h <nl> bool Scavenger : : PromotionList : : View : : Pop ( struct PromotionListEntry * entry ) { <nl> return promotion_list_ - > Pop ( task_id_ , entry ) ; <nl> } <nl> <nl> - void Scavenger : : PromotionList : : View : : FlushToGlobal ( ) { <nl> - promotion_list_ - > FlushToGlobal ( task_id_ ) ; <nl> - } <nl> - <nl> bool Scavenger : : PromotionList : : View : : IsGlobalPoolEmpty ( ) { <nl> return promotion_list_ - > IsGlobalPoolEmpty ( ) ; <nl> } <nl> bool Scavenger : : PromotionList : : Pop ( int task_id , <nl> return large_object_promotion_list_ . Pop ( task_id , entry ) ; <nl> } <nl> <nl> - void Scavenger : : PromotionList : : FlushToGlobal ( int task_id ) { <nl> - regular_object_promotion_list_ . FlushToGlobal ( task_id ) ; <nl> - large_object_promotion_list_ . FlushToGlobal ( task_id ) ; <nl> - } <nl> - <nl> - size_t Scavenger : : PromotionList : : GlobalPoolSize ( ) const { <nl> - return regular_object_promotion_list_ . GlobalPoolSize ( ) + <nl> - large_object_promotion_list_ . GlobalPoolSize ( ) ; <nl> - } <nl> - <nl> bool Scavenger : : PromotionList : : IsGlobalPoolEmpty ( ) { <nl> return regular_object_promotion_list_ . IsGlobalPoolEmpty ( ) & & <nl> large_object_promotion_list_ . IsGlobalPoolEmpty ( ) ; <nl> mmm a / src / heap / scavenger . cc <nl> ppp b / src / heap / scavenger . cc <nl> <nl> namespace v8 { <nl> namespace internal { <nl> <nl> + class PageScavengingItem final : public ItemParallelJob : : Item { <nl> + public : <nl> + explicit PageScavengingItem ( MemoryChunk * chunk ) : chunk_ ( chunk ) { } <nl> + ~ PageScavengingItem ( ) override = default ; <nl> + <nl> + void Process ( Scavenger * scavenger ) { scavenger - > ScavengePage ( chunk_ ) ; } <nl> + <nl> + private : <nl> + MemoryChunk * const chunk_ ; <nl> + } ; <nl> + <nl> + class ScavengingTask final : public ItemParallelJob : : Task { <nl> + public : <nl> + ScavengingTask ( Heap * heap , Scavenger * scavenger , OneshotBarrier * barrier ) <nl> + : ItemParallelJob : : Task ( heap - > isolate ( ) ) , <nl> + heap_ ( heap ) , <nl> + scavenger_ ( scavenger ) , <nl> + barrier_ ( barrier ) { } <nl> + <nl> + void RunInParallel ( Runner runner ) final { <nl> + if ( runner = = Runner : : kForeground ) { <nl> + TRACE_GC ( heap_ - > tracer ( ) , GCTracer : : Scope : : SCAVENGER_SCAVENGE_PARALLEL ) ; <nl> + ProcessItems ( ) ; <nl> + } else { <nl> + TRACE_BACKGROUND_GC ( <nl> + heap_ - > tracer ( ) , <nl> + GCTracer : : BackgroundScope : : SCAVENGER_BACKGROUND_SCAVENGE_PARALLEL ) ; <nl> + ProcessItems ( ) ; <nl> + } <nl> + } <nl> + <nl> + private : <nl> + void ProcessItems ( ) { <nl> + double scavenging_time = 0 . 0 ; <nl> + { <nl> + barrier_ - > Start ( ) ; <nl> + TimedScope scope ( & scavenging_time ) ; <nl> + PageScavengingItem * item = nullptr ; <nl> + while ( ( item = GetItem < PageScavengingItem > ( ) ) ! = nullptr ) { <nl> + item - > Process ( scavenger_ ) ; <nl> + item - > MarkFinished ( ) ; <nl> + } <nl> + do { <nl> + scavenger_ - > Process ( barrier_ ) ; <nl> + } while ( ! barrier_ - > Wait ( ) ) ; <nl> + scavenger_ - > Process ( ) ; <nl> + } <nl> + if ( FLAG_trace_parallel_scavenge ) { <nl> + PrintIsolate ( heap_ - > isolate ( ) , <nl> + " scavenge [ % p ] : time = % . 2f copied = % zu promoted = % zu \ n " , <nl> + static_cast < void * > ( this ) , scavenging_time , <nl> + scavenger_ - > bytes_copied ( ) , scavenger_ - > bytes_promoted ( ) ) ; <nl> + } <nl> + } <nl> + Heap * const heap_ ; <nl> + Scavenger * const scavenger_ ; <nl> + OneshotBarrier * const barrier_ ; <nl> + } ; <nl> + <nl> class IterateAndScavengePromotedObjectsVisitor final : public ObjectVisitor { <nl> public : <nl> IterateAndScavengePromotedObjectsVisitor ( Scavenger * scavenger , <nl> class ScavengeWeakObjectRetainer : public WeakObjectRetainer { <nl> } <nl> } ; <nl> <nl> - ScavengerCollector : : JobTask : : JobTask ( <nl> - ScavengerCollector * outer , <nl> - std : : vector < std : : unique_ptr < Scavenger > > * scavengers , <nl> - std : : vector < std : : pair < ParallelWorkItem , MemoryChunk * > > memory_chunks , <nl> - Scavenger : : CopiedList * copied_list , <nl> - Scavenger : : PromotionList * promotion_list ) <nl> - : outer_ ( outer ) , <nl> - scavengers_ ( scavengers ) , <nl> - memory_chunks_ ( std : : move ( memory_chunks ) ) , <nl> - remaining_memory_chunks_ ( memory_chunks_ . size ( ) ) , <nl> - generator_ ( memory_chunks_ . size ( ) ) , <nl> - copied_list_ ( copied_list ) , <nl> - promotion_list_ ( promotion_list ) { } <nl> - <nl> - void ScavengerCollector : : JobTask : : Run ( JobDelegate * delegate ) { <nl> - Scavenger * scavenger = ( * scavengers_ ) [ delegate - > GetTaskId ( ) ] . get ( ) ; <nl> - if ( delegate - > IsJoiningThread ( ) ) { <nl> - TRACE_GC ( outer_ - > heap_ - > tracer ( ) , <nl> - GCTracer : : Scope : : SCAVENGER_SCAVENGE_PARALLEL ) ; <nl> - ProcessItems ( delegate , scavenger ) ; <nl> - } else { <nl> - TRACE_BACKGROUND_GC ( <nl> - outer_ - > heap_ - > tracer ( ) , <nl> - GCTracer : : BackgroundScope : : SCAVENGER_BACKGROUND_SCAVENGE_PARALLEL ) ; <nl> - ProcessItems ( delegate , scavenger ) ; <nl> - } <nl> - } <nl> - <nl> - size_t ScavengerCollector : : JobTask : : GetMaxConcurrency ( <nl> - size_t worker_count ) const { <nl> - / / We need to account for local segments held by worker_count in addition to <nl> - / / GlobalPoolSize ( ) of copied_list_ and promotion_list_ . <nl> - return std : : min < size_t > ( <nl> - scavengers_ - > size ( ) , <nl> - std : : max < size_t > ( remaining_memory_chunks_ . load ( std : : memory_order_relaxed ) , <nl> - worker_count + copied_list_ - > GlobalPoolSize ( ) + <nl> - promotion_list_ - > GlobalPoolSize ( ) ) ) ; <nl> - } <nl> - <nl> - void ScavengerCollector : : JobTask : : ProcessItems ( JobDelegate * delegate , <nl> - Scavenger * scavenger ) { <nl> - double scavenging_time = 0 . 0 ; <nl> - { <nl> - TimedScope scope ( & scavenging_time ) ; <nl> - ConcurrentScavengePages ( scavenger ) ; <nl> - scavenger - > Process ( delegate ) ; <nl> - } <nl> - if ( FLAG_trace_parallel_scavenge ) { <nl> - PrintIsolate ( outer_ - > heap_ - > isolate ( ) , <nl> - " scavenge [ % p ] : time = % . 2f copied = % zu promoted = % zu \ n " , <nl> - static_cast < void * > ( this ) , scavenging_time , <nl> - scavenger - > bytes_copied ( ) , scavenger - > bytes_promoted ( ) ) ; <nl> - } <nl> - } <nl> - <nl> - void ScavengerCollector : : JobTask : : ConcurrentScavengePages ( <nl> - Scavenger * scavenger ) { <nl> - while ( remaining_memory_chunks_ . load ( std : : memory_order_relaxed ) > 0 ) { <nl> - base : : Optional < size_t > index = generator_ . GetNext ( ) ; <nl> - if ( ! index ) return ; <nl> - for ( size_t i = * index ; i < memory_chunks_ . size ( ) ; + + i ) { <nl> - auto & work_item = memory_chunks_ [ i ] ; <nl> - if ( ! work_item . first . TryAcquire ( ) ) break ; <nl> - scavenger - > ScavengePage ( work_item . second ) ; <nl> - if ( remaining_memory_chunks_ . fetch_sub ( 1 , std : : memory_order_relaxed ) < = <nl> - 1 ) { <nl> - return ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - <nl> ScavengerCollector : : ScavengerCollector ( Heap * heap ) <nl> - : isolate_ ( heap - > isolate ( ) ) , heap_ ( heap ) { } <nl> + : isolate_ ( heap - > isolate ( ) ) , heap_ ( heap ) , parallel_scavenge_semaphore_ ( 0 ) { } <nl> <nl> / / Remove this crashkey after chromium : 1010312 is fixed . <nl> class ScopedFullHeapCrashKey { <nl> void ScavengerCollector : : CollectGarbage ( ) { <nl> } <nl> <nl> DCHECK ( surviving_new_large_objects_ . empty ( ) ) ; <nl> - std : : vector < std : : unique_ptr < Scavenger > > scavengers ; <nl> - Worklist < MemoryChunk * , 64 > empty_chunks ; <nl> + ItemParallelJob job ( isolate_ - > cancelable_task_manager ( ) , <nl> + & parallel_scavenge_semaphore_ ) ; <nl> + const int kMainThreadId = 0 ; <nl> + Scavenger * scavengers [ kMaxScavengerTasks ] ; <nl> + const bool is_logging = isolate_ - > LogObjectRelocation ( ) ; <nl> const int num_scavenge_tasks = NumberOfScavengeTasks ( ) ; <nl> + OneshotBarrier barrier ( base : : TimeDelta : : FromMilliseconds ( kMaxWaitTimeMs ) ) ; <nl> + Worklist < MemoryChunk * , 64 > empty_chunks ; <nl> Scavenger : : CopiedList copied_list ( num_scavenge_tasks ) ; <nl> Scavenger : : PromotionList promotion_list ( num_scavenge_tasks ) ; <nl> EphemeronTableList ephemeron_table_list ( num_scavenge_tasks ) ; <nl> + for ( int i = 0 ; i < num_scavenge_tasks ; i + + ) { <nl> + scavengers [ i ] = <nl> + new Scavenger ( this , heap_ , is_logging , & empty_chunks , & copied_list , <nl> + & promotion_list , & ephemeron_table_list , i ) ; <nl> + job . AddTask ( new ScavengingTask ( heap_ , scavengers [ i ] , & barrier ) ) ; <nl> + } <nl> <nl> { <nl> Sweeper * sweeper = heap_ - > mark_compact_collector ( ) - > sweeper ( ) ; <nl> void ScavengerCollector : : CollectGarbage ( ) { <nl> return ! page - > ContainsSlots < OLD_TO_NEW > ( ) & & ! page - > sweeping_slot_set ( ) ; <nl> } ) ; <nl> <nl> - const bool is_logging = isolate_ - > LogObjectRelocation ( ) ; <nl> - for ( int i = 0 ; i < num_scavenge_tasks ; + + i ) { <nl> - scavengers . emplace_back ( <nl> - new Scavenger ( this , heap_ , is_logging , & empty_chunks , & copied_list , <nl> - & promotion_list , & ephemeron_table_list , i ) ) ; <nl> - } <nl> - <nl> - std : : vector < std : : pair < ParallelWorkItem , MemoryChunk * > > memory_chunks ; <nl> RememberedSet < OLD_TO_NEW > : : IterateMemoryChunks ( <nl> - heap_ , [ & memory_chunks ] ( MemoryChunk * chunk ) { <nl> - memory_chunks . emplace_back ( ParallelWorkItem { } , chunk ) ; <nl> + heap_ , [ & job ] ( MemoryChunk * chunk ) { <nl> + job . AddItem ( new PageScavengingItem ( chunk ) ) ; <nl> } ) ; <nl> <nl> - RootScavengeVisitor root_scavenge_visitor ( scavengers [ kMainThreadId ] . get ( ) ) ; <nl> + RootScavengeVisitor root_scavenge_visitor ( scavengers [ kMainThreadId ] ) ; <nl> <nl> { <nl> / / Identify weak unmodified handles . Requires an unmodified graph . <nl> void ScavengerCollector : : CollectGarbage ( ) { <nl> heap_ - > IterateRoots ( & root_scavenge_visitor , options ) ; <nl> isolate_ - > global_handles ( ) - > IterateYoungStrongAndDependentRoots ( <nl> & root_scavenge_visitor ) ; <nl> - scavengers [ kMainThreadId ] - > Flush ( ) ; <nl> } <nl> { <nl> / / Parallel phase scavenging all copied and promoted objects . <nl> TRACE_GC ( heap_ - > tracer ( ) , GCTracer : : Scope : : SCAVENGER_SCAVENGE_PARALLEL ) ; <nl> - V8 : : GetCurrentPlatform ( ) <nl> - - > PostJob ( v8 : : TaskPriority : : kUserBlocking , <nl> - std : : make_unique < JobTask > ( this , & scavengers , <nl> - std : : move ( memory_chunks ) , <nl> - & copied_list , & promotion_list ) ) <nl> - - > Join ( ) ; <nl> + job . Run ( ) ; <nl> DCHECK ( copied_list . IsEmpty ( ) ) ; <nl> DCHECK ( promotion_list . IsEmpty ( ) ) ; <nl> } <nl> <nl> if ( V8_UNLIKELY ( FLAG_scavenge_separate_stack_scanning ) ) { <nl> - IterateStackAndScavenge ( & root_scavenge_visitor , & scavengers , <nl> - kMainThreadId ) ; <nl> + IterateStackAndScavenge ( & root_scavenge_visitor , scavengers , <nl> + num_scavenge_tasks , kMainThreadId ) ; <nl> DCHECK ( copied_list . IsEmpty ( ) ) ; <nl> DCHECK ( promotion_list . IsEmpty ( ) ) ; <nl> } <nl> void ScavengerCollector : : CollectGarbage ( ) { <nl> <nl> DCHECK ( surviving_new_large_objects_ . empty ( ) ) ; <nl> <nl> - for ( auto & scavenger : scavengers ) { <nl> - scavenger - > Finalize ( ) ; <nl> + for ( int i = 0 ; i < num_scavenge_tasks ; i + + ) { <nl> + scavengers [ i ] - > Finalize ( ) ; <nl> + delete scavengers [ i ] ; <nl> } <nl> - scavengers . clear ( ) ; <nl> <nl> HandleSurvivingNewLargeObjects ( ) ; <nl> } <nl> void ScavengerCollector : : CollectGarbage ( ) { <nl> } <nl> <nl> void ScavengerCollector : : IterateStackAndScavenge ( <nl> - <nl> - RootScavengeVisitor * root_scavenge_visitor , <nl> - std : : vector < std : : unique_ptr < Scavenger > > * scavengers , int main_thread_id ) { <nl> + RootScavengeVisitor * root_scavenge_visitor , Scavenger * * scavengers , <nl> + int num_scavenge_tasks , int main_thread_id ) { <nl> / / Scan the stack , scavenge the newly discovered objects , and report <nl> / / the survival statistics before and afer the stack scanning . <nl> / / This code is not intended for production . <nl> TRACE_GC ( heap_ - > tracer ( ) , GCTracer : : Scope : : SCAVENGER_SCAVENGE_STACK_ROOTS ) ; <nl> size_t survived_bytes_before = 0 ; <nl> - for ( auto & scavenger : * scavengers ) { <nl> + for ( int i = 0 ; i < num_scavenge_tasks ; i + + ) { <nl> survived_bytes_before + = <nl> - scavenger - > bytes_copied ( ) + scavenger - > bytes_promoted ( ) ; <nl> + scavengers [ i ] - > bytes_copied ( ) + scavengers [ i ] - > bytes_promoted ( ) ; <nl> } <nl> heap_ - > IterateStackRoots ( root_scavenge_visitor ) ; <nl> - ( * scavengers ) [ main_thread_id ] - > Process ( ) ; <nl> + scavengers [ main_thread_id ] - > Process ( ) ; <nl> size_t survived_bytes_after = 0 ; <nl> - for ( auto & scavenger : * scavengers ) { <nl> + for ( int i = 0 ; i < num_scavenge_tasks ; i + + ) { <nl> survived_bytes_after + = <nl> - scavenger - > bytes_copied ( ) + scavenger - > bytes_promoted ( ) ; <nl> + scavengers [ i ] - > bytes_copied ( ) + scavengers [ i ] - > bytes_promoted ( ) ; <nl> } <nl> TRACE_EVENT2 ( TRACE_DISABLED_BY_DEFAULT ( " v8 . gc " ) , <nl> " V8 . GCScavengerStackScanning " , " survived_bytes_before " , <nl> void Scavenger : : ScavengePage ( MemoryChunk * page ) { <nl> AddPageToSweeperIfNecessary ( page ) ; <nl> } <nl> <nl> - void Scavenger : : Process ( JobDelegate * delegate ) { <nl> + void Scavenger : : Process ( OneshotBarrier * barrier ) { <nl> ScavengeVisitor scavenge_visitor ( this ) ; <nl> <nl> + const bool have_barrier = barrier ! = nullptr ; <nl> bool done ; <nl> size_t objects = 0 ; <nl> do { <nl> void Scavenger : : Process ( JobDelegate * delegate ) { <nl> copied_list_ . Pop ( & object_and_size ) ) { <nl> scavenge_visitor . Visit ( object_and_size . first ) ; <nl> done = false ; <nl> - if ( delegate & & ( ( + + objects % kInterruptThreshold ) = = 0 ) ) { <nl> + if ( have_barrier & & ( ( + + objects % kInterruptThreshold ) = = 0 ) ) { <nl> if ( ! copied_list_ . IsGlobalPoolEmpty ( ) ) { <nl> - delegate - > NotifyConcurrencyIncrease ( ) ; <nl> + barrier - > NotifyAll ( ) ; <nl> } <nl> } <nl> } <nl> void Scavenger : : Process ( JobDelegate * delegate ) { <nl> HeapObject target = entry . heap_object ; <nl> IterateAndScavengePromotedObject ( target , entry . map , entry . size ) ; <nl> done = false ; <nl> - if ( delegate & & ( ( + + objects % kInterruptThreshold ) = = 0 ) ) { <nl> + if ( have_barrier & & ( ( + + objects % kInterruptThreshold ) = = 0 ) ) { <nl> if ( ! promotion_list_ . IsGlobalPoolEmpty ( ) ) { <nl> - delegate - > NotifyConcurrencyIncrease ( ) ; <nl> + barrier - > NotifyAll ( ) ; <nl> } <nl> } <nl> } <nl> void Scavenger : : Finalize ( ) { <nl> } <nl> } <nl> <nl> - void Scavenger : : Flush ( ) { <nl> - copied_list_ . FlushToGlobal ( ) ; <nl> - promotion_list_ . FlushToGlobal ( ) ; <nl> - } <nl> - <nl> void Scavenger : : AddEphemeronHashTable ( EphemeronHashTable table ) { <nl> ephemeron_table_list_ . Push ( table ) ; <nl> } <nl> mmm a / src / heap / scavenger . h <nl> ppp b / src / heap / scavenger . h <nl> <nl> # define V8_HEAP_SCAVENGER_H_ <nl> <nl> # include " src / base / platform / condition - variable . h " <nl> - # include " src / heap / index - generator . h " <nl> # include " src / heap / local - allocator . h " <nl> # include " src / heap / objects - visiting . h " <nl> - # include " src / heap / parallel - work - item . h " <nl> # include " src / heap / slot - set . h " <nl> # include " src / heap / worklist . h " <nl> <nl> constexpr int kEphemeronTableListSegmentSize = 128 ; <nl> using EphemeronTableList = <nl> Worklist < EphemeronHashTable , kEphemeronTableListSegmentSize > ; <nl> <nl> - class ScavengerCollector ; <nl> + class ScavengerCollector { <nl> + public : <nl> + static const int kMaxScavengerTasks = 8 ; <nl> + static const int kMaxWaitTimeMs = 2 ; <nl> + <nl> + explicit ScavengerCollector ( Heap * heap ) ; <nl> + <nl> + void CollectGarbage ( ) ; <nl> + <nl> + private : <nl> + void MergeSurvivingNewLargeObjects ( <nl> + const SurvivingNewLargeObjectsMap & objects ) ; <nl> + <nl> + int NumberOfScavengeTasks ( ) ; <nl> + <nl> + void ProcessWeakReferences ( EphemeronTableList * ephemeron_table_list ) ; <nl> + void ClearYoungEphemerons ( EphemeronTableList * ephemeron_table_list ) ; <nl> + void ClearOldEphemerons ( ) ; <nl> + void HandleSurvivingNewLargeObjects ( ) ; <nl> + <nl> + void SweepArrayBufferExtensions ( ) ; <nl> + <nl> + void IterateStackAndScavenge ( RootScavengeVisitor * root_scavenge_visitor , <nl> + Scavenger * * scavengers , int num_scavenge_tasks , <nl> + int main_thread_id ) ; <nl> + Isolate * const isolate_ ; <nl> + Heap * const heap_ ; <nl> + base : : Semaphore parallel_scavenge_semaphore_ ; <nl> + SurvivingNewLargeObjectsMap surviving_new_large_objects_ ; <nl> + <nl> + friend class Scavenger ; <nl> + } ; <nl> <nl> class Scavenger { <nl> public : <nl> class Scavenger { <nl> inline bool Pop ( struct PromotionListEntry * entry ) ; <nl> inline bool IsGlobalPoolEmpty ( ) ; <nl> inline bool ShouldEagerlyProcessPromotionList ( ) ; <nl> - inline void FlushToGlobal ( ) ; <nl> <nl> private : <nl> PromotionList * promotion_list_ ; <nl> class Scavenger { <nl> inline void PushLargeObject ( int task_id , HeapObject object , Map map , <nl> int size ) ; <nl> inline bool IsEmpty ( ) ; <nl> - inline size_t GlobalPoolSize ( ) const ; <nl> inline size_t LocalPushSegmentSize ( int task_id ) ; <nl> inline bool Pop ( int task_id , struct PromotionListEntry * entry ) ; <nl> inline bool IsGlobalPoolEmpty ( ) ; <nl> inline bool ShouldEagerlyProcessPromotionList ( int task_id ) ; <nl> - inline void FlushToGlobal ( int task_id ) ; <nl> <nl> private : <nl> static const int kRegularObjectPromotionListSegmentSize = 256 ; <nl> class Scavenger { <nl> <nl> / / Processes remaining work ( = objects ) after single objects have been <nl> / / manually scavenged using ScavengeObject or CheckAndScavengeObject . <nl> - void Process ( JobDelegate * delegate = nullptr ) ; <nl> + void Process ( OneshotBarrier * barrier = nullptr ) ; <nl> <nl> / / Finalize the Scavenger . Needs to be called from the main thread . <nl> void Finalize ( ) ; <nl> - void Flush ( ) ; <nl> <nl> void AddEphemeronHashTable ( EphemeronHashTable table ) ; <nl> <nl> class ScavengeVisitor final : public NewSpaceVisitor < ScavengeVisitor > { <nl> Scavenger * const scavenger_ ; <nl> } ; <nl> <nl> - class ScavengerCollector { <nl> - public : <nl> - static const int kMaxScavengerTasks = 8 ; <nl> - static const int kMainThreadId = 0 ; <nl> - <nl> - explicit ScavengerCollector ( Heap * heap ) ; <nl> - <nl> - void CollectGarbage ( ) ; <nl> - <nl> - private : <nl> - class JobTask : public v8 : : JobTask { <nl> - public : <nl> - explicit JobTask ( <nl> - ScavengerCollector * outer , <nl> - std : : vector < std : : unique_ptr < Scavenger > > * scavengers , <nl> - std : : vector < std : : pair < ParallelWorkItem , MemoryChunk * > > memory_chunks , <nl> - Scavenger : : CopiedList * copied_list , <nl> - Scavenger : : PromotionList * promotion_list ) ; <nl> - <nl> - void Run ( JobDelegate * delegate ) override ; <nl> - size_t GetMaxConcurrency ( size_t worker_count ) const override ; <nl> - <nl> - private : <nl> - void ProcessItems ( JobDelegate * delegate , Scavenger * scavenger ) ; <nl> - void ConcurrentScavengePages ( Scavenger * scavenger ) ; <nl> - <nl> - ScavengerCollector * outer_ ; <nl> - <nl> - std : : vector < std : : unique_ptr < Scavenger > > * scavengers_ ; <nl> - std : : vector < std : : pair < ParallelWorkItem , MemoryChunk * > > memory_chunks_ ; <nl> - std : : atomic < size_t > remaining_memory_chunks_ { 0 } ; <nl> - IndexGenerator generator_ ; <nl> - <nl> - Scavenger : : CopiedList * copied_list_ ; <nl> - Scavenger : : PromotionList * promotion_list_ ; <nl> - } ; <nl> - <nl> - void MergeSurvivingNewLargeObjects ( <nl> - const SurvivingNewLargeObjectsMap & objects ) ; <nl> - <nl> - int NumberOfScavengeTasks ( ) ; <nl> - <nl> - void ProcessWeakReferences ( EphemeronTableList * ephemeron_table_list ) ; <nl> - void ClearYoungEphemerons ( EphemeronTableList * ephemeron_table_list ) ; <nl> - void ClearOldEphemerons ( ) ; <nl> - void HandleSurvivingNewLargeObjects ( ) ; <nl> - <nl> - void SweepArrayBufferExtensions ( ) ; <nl> - <nl> - void IterateStackAndScavenge ( <nl> - RootScavengeVisitor * root_scavenge_visitor , <nl> - std : : vector < std : : unique_ptr < Scavenger > > * scavengers , int main_thread_id ) ; <nl> - <nl> - Isolate * const isolate_ ; <nl> - Heap * const heap_ ; <nl> - SurvivingNewLargeObjectsMap surviving_new_large_objects_ ; <nl> - <nl> - friend class Scavenger ; <nl> - } ; <nl> - <nl> } / / namespace internal <nl> } / / namespace v8 <nl> <nl>
Revert " Reland " [ Heap ] ScavengerCollector use Jobs . " "
v8/v8
4822d3b22a3dc1c60cb06773e61f4fbde8eefb1a
2020-09-25T17:06:41Z
mmm a / utils / buildbot - script . sh <nl> ppp b / utils / buildbot - script . sh <nl> if [ \ ! " $ SKIP_TEST_SWIFT_PERFORMANCE " ] ; then <nl> echo " mmm Running Swift Performance Tests mmm " <nl> export CLANG = " $ TOOLCHAIN / usr / bin / clang " <nl> export SWIFT = " $ WORKSPACE / swift / build / bin / swift " <nl> - ( cd " $ WORKSPACE / swift / build " & & <nl> - " $ WORKSPACE / llvm / build / bin / llvm - lit " - v benchmark \ <nl> - - j1 - - output benchmark / results . json ) | | exit 1 <nl> + if ( cd " $ WORKSPACE / swift / build " & & <nl> + " $ WORKSPACE / llvm / build / bin / llvm - lit " - v benchmark \ <nl> + - j1 - - output benchmark / results . json ) ; then <nl> + PERFORMANCE_TESTS_PASSED = 1 <nl> + else <nl> + PERFORMANCE_TESTS_PASSED = 0 <nl> + fi <nl> echo " mmm Submitting Swift Performance Tests mmm " <nl> swift_source_revision = " $ ( " $ WORKSPACE / llvm / utils / GetSourceVersion " " $ WORKSPACE / swift " ) " <nl> ( cd " $ WORKSPACE / swift / build " & & <nl> if [ \ ! " $ SKIP_TEST_SWIFT_PERFORMANCE " ] ; then <nl> - - machine - name " matte . apple . com - - $ { BUILD_TYPE } - - x86_64 - - O3 " \ <nl> - - run - order " $ swift_source_revision " \ <nl> - - submit http : / / localhost : 32169 / submitRun ) | | exit 1 <nl> + <nl> + # If the performance tests failed , fail the build . <nl> + if [ " $ PERFORMANCE_TESTS_PASSED " - ne 0 ] ; then <nl> + echo " * * * ERROR : Swift Performance Tests failed * * * " <nl> + exit 1 <nl> + fi <nl> fi <nl> <nl> if [ " $ PACKAGE " - a \ ! " $ SKIP_PACKAGE_SWIFT " ] ; then <nl>
[ perftests ] Always submit performance test results , even with failures .
apple/swift
e82167c92e853499abc7d182dd0e1eb322289f2a
2013-10-17T18:55:49Z
mmm a / src / gui / Src / BasicView / ReferenceView . cpp <nl> ppp b / src / gui / Src / BasicView / ReferenceView . cpp <nl> void ReferenceView : : setupContextMenu ( ) <nl> <nl> void ReferenceView : : connectBridge ( ) <nl> { <nl> - connect ( Bridge : : getBridge ( ) , SIGNAL ( referenceAddColumnAt ( int , QString ) ) , this , SLOT ( addColumnAtRef ( int , QString ) ) ) ; <nl> - connect ( Bridge : : getBridge ( ) , SIGNAL ( referenceSetRowCount ( dsint ) ) , this , SLOT ( setRowCount ( dsint ) ) ) ; <nl> - connect ( Bridge : : getBridge ( ) , SIGNAL ( referenceSetCellContent ( int , int , QString ) ) , this , SLOT ( setCellContent ( int , int , QString ) ) ) ; <nl> - connect ( Bridge : : getBridge ( ) , SIGNAL ( referenceReloadData ( ) ) , this , SLOT ( reloadData ( ) ) ) ; <nl> + connect ( Bridge : : getBridge ( ) , SIGNAL ( referenceReloadData ( ) ) , this , SLOT ( reloadDataSlot ( ) ) ) ; <nl> connect ( Bridge : : getBridge ( ) , SIGNAL ( referenceSetSingleSelection ( int , bool ) ) , this , SLOT ( setSingleSelection ( int , bool ) ) ) ; <nl> connect ( Bridge : : getBridge ( ) , SIGNAL ( referenceSetProgress ( int ) ) , this , SLOT ( referenceSetProgressSlot ( int ) ) ) ; <nl> connect ( Bridge : : getBridge ( ) , SIGNAL ( referenceSetCurrentTaskProgress ( int , QString ) ) , this , SLOT ( referenceSetCurrentTaskProgressSlot ( int , QString ) ) ) ; <nl> - connect ( Bridge : : getBridge ( ) , SIGNAL ( referenceSetSearchStartCol ( int ) ) , this , SLOT ( setSearchStartCol ( int ) ) ) ; <nl> connect ( Bridge : : getBridge ( ) , SIGNAL ( referenceAddCommand ( QString , QString ) ) , this , SLOT ( addCommand ( QString , QString ) ) ) ; <nl> connect ( stdSearchList ( ) , SIGNAL ( selectionChangedSignal ( int ) ) , this , SLOT ( searchSelectionChanged ( int ) ) ) ; <nl> connect ( stdList ( ) , SIGNAL ( selectionChangedSignal ( int ) ) , this , SLOT ( searchSelectionChanged ( int ) ) ) ; <nl> void ReferenceView : : connectBridge ( ) <nl> <nl> void ReferenceView : : disconnectBridge ( ) <nl> { <nl> - disconnect ( Bridge : : getBridge ( ) , SIGNAL ( referenceAddColumnAt ( int , QString ) ) , this , SLOT ( addColumnAtRef ( int , QString ) ) ) ; <nl> - disconnect ( Bridge : : getBridge ( ) , SIGNAL ( referenceSetRowCount ( dsint ) ) , this , SLOT ( setRowCount ( dsint ) ) ) ; <nl> - disconnect ( Bridge : : getBridge ( ) , SIGNAL ( referenceSetCellContent ( int , int , QString ) ) , this , SLOT ( setCellContent ( int , int , QString ) ) ) ; <nl> - disconnect ( Bridge : : getBridge ( ) , SIGNAL ( referenceReloadData ( ) ) , this , SLOT ( reloadData ( ) ) ) ; <nl> + disconnect ( Bridge : : getBridge ( ) , SIGNAL ( referenceReloadData ( ) ) , this , SLOT ( reloadDataSlot ( ) ) ) ; <nl> disconnect ( Bridge : : getBridge ( ) , SIGNAL ( referenceSetSingleSelection ( int , bool ) ) , this , SLOT ( setSingleSelection ( int , bool ) ) ) ; <nl> - disconnect ( Bridge : : getBridge ( ) , SIGNAL ( referenceSetProgress ( int ) ) , mSearchTotalProgress , SLOT ( setValue ( int ) ) ) ; <nl> + disconnect ( Bridge : : getBridge ( ) , SIGNAL ( referenceSetProgress ( int ) ) , this , SLOT ( referenceSetProgressSlot ( int ) ) ) ; <nl> disconnect ( Bridge : : getBridge ( ) , SIGNAL ( referenceSetCurrentTaskProgress ( int , QString ) ) , this , SLOT ( referenceSetCurrentTaskProgressSlot ( int , QString ) ) ) ; <nl> - disconnect ( Bridge : : getBridge ( ) , SIGNAL ( referenceSetSearchStartCol ( int ) ) , this , SLOT ( setSearchStartCol ( int ) ) ) ; <nl> disconnect ( Bridge : : getBridge ( ) , SIGNAL ( referenceAddCommand ( QString , QString ) ) , this , SLOT ( addCommand ( QString , QString ) ) ) ; <nl> disconnect ( stdSearchList ( ) , SIGNAL ( selectionChangedSignal ( int ) ) , this , SLOT ( searchSelectionChanged ( int ) ) ) ; <nl> disconnect ( stdList ( ) , SIGNAL ( selectionChangedSignal ( int ) ) , this , SLOT ( searchSelectionChanged ( int ) ) ) ; <nl> void ReferenceView : : refreshShortcutsSlot ( ) <nl> <nl> void ReferenceView : : referenceSetProgressSlot ( int progress ) <nl> { <nl> - mSearchTotalProgress - > setValue ( progress ) ; <nl> - mSearchTotalProgress - > setAlignment ( Qt : : AlignCenter ) ; <nl> - mSearchTotalProgress - > setFormat ( tr ( " Total Progress % 1 % " ) . arg ( QString : : number ( progress ) ) ) ; <nl> + if ( mSearchTotalProgress - > value ( ) ! = progress ) <nl> + { <nl> + mSearchTotalProgress - > setValue ( progress ) ; <nl> + mSearchTotalProgress - > setAlignment ( Qt : : AlignCenter ) ; <nl> + mSearchTotalProgress - > setFormat ( tr ( " Total Progress % 1 % " ) . arg ( QString : : number ( progress ) ) ) ; <nl> + mCountTotalLabel - > setText ( QString ( " % 1 " ) . arg ( stdList ( ) - > getRowCount ( ) ) ) ; <nl> + } <nl> } <nl> <nl> void ReferenceView : : referenceSetCurrentTaskProgressSlot ( int progress , QString taskTitle ) <nl> { <nl> - mSearchCurrentTaskProgress - > setValue ( progress ) ; <nl> - mSearchCurrentTaskProgress - > setAlignment ( Qt : : AlignCenter ) ; <nl> - mSearchCurrentTaskProgress - > setFormat ( taskTitle + " " + QString : : number ( progress ) + " % " ) ; <nl> + if ( mSearchCurrentTaskProgress - > value ( ) ! = progress ) <nl> + { <nl> + mSearchCurrentTaskProgress - > setValue ( progress ) ; <nl> + mSearchCurrentTaskProgress - > setAlignment ( Qt : : AlignCenter ) ; <nl> + mSearchCurrentTaskProgress - > setFormat ( taskTitle + " " + QString : : number ( progress ) + " % " ) ; <nl> + } <nl> } <nl> <nl> void ReferenceView : : searchSelectionChanged ( int index ) <nl> void ReferenceView : : searchSelectionChanged ( int index ) <nl> DbgValToString ( " $ __dump_refindex " , index ) ; <nl> } <nl> <nl> + void ReferenceView : : reloadDataSlot ( ) <nl> + { <nl> + if ( mUpdateCountLabel ) <nl> + { <nl> + mUpdateCountLabel = true ; <nl> + mCountTotalLabel - > setText ( QString ( " % 1 " ) . arg ( stdList ( ) - > getRowCount ( ) ) ) ; <nl> + } <nl> + reloadData ( ) ; <nl> + } <nl> + <nl> void ReferenceView : : addColumnAtRef ( int width , QString title ) <nl> { <nl> int charwidth = getCharWidth ( ) ; <nl> void ReferenceView : : setRowCount ( dsint count ) <nl> { <nl> if ( ! stdList ( ) - > getRowCount ( ) & & count ) / / from zero to N rows <nl> searchSelectionChanged ( 0 ) ; <nl> - emit mCountTotalLabel - > setText ( QString ( " % 1 " ) . arg ( count ) ) ; <nl> + mUpdateCountLabel = true ; <nl> StdSearchListView : : setRowCount ( count ) ; <nl> - Bridge : : getBridge ( ) - > setResult ( BridgeResult : : RefSetRowCount , 1 ) ; <nl> } <nl> <nl> void ReferenceView : : setSingleSelection ( int index , bool scroll ) <nl> mmm a / src / gui / Src / BasicView / ReferenceView . h <nl> ppp b / src / gui / Src / BasicView / ReferenceView . h <nl> public slots : <nl> void referenceSetProgressSlot ( int progress ) ; <nl> void referenceSetCurrentTaskProgressSlot ( int progress , QString taskTitle ) ; <nl> void searchSelectionChanged ( int index ) ; <nl> + void reloadDataSlot ( ) ; <nl> <nl> signals : <nl> void showCpu ( ) ; <nl> private slots : <nl> QAction * mRemoveBreakpointOnAllCommands ; <nl> QAction * mSetBreakpointOnAllApiCalls ; <nl> QAction * mRemoveBreakpointOnAllApiCalls ; <nl> + bool mUpdateCountLabel = false ; <nl> QLabel * mCountTotalLabel ; <nl> QVector < QString > mCommandTitles ; <nl> QVector < QString > mCommands ; <nl> mmm a / src / gui / Src / Bridge / Bridge . cpp <nl> ppp b / src / gui / Src / Bridge / Bridge . cpp <nl> void * Bridge : : processMessage ( GUIMSG type , void * param1 , void * param2 ) <nl> case GUI_REF_SETROWCOUNT : <nl> { <nl> if ( referenceManager - > currentReferenceView ( ) ) <nl> - { <nl> - BridgeResult result ( BridgeResult : : RefSetRowCount ) ; <nl> - emit referenceSetRowCount ( ( dsint ) param1 ) ; <nl> - result . Wait ( ) ; <nl> - } <nl> + referenceManager - > currentReferenceView ( ) - > setRowCount ( ( dsint ) param1 ) ; <nl> } <nl> break ; <nl> <nl> void * Bridge : : processMessage ( GUIMSG type , void * param1 , void * param2 ) <nl> case GUI_REF_SETCELLCONTENT : <nl> { <nl> CELLINFO * info = ( CELLINFO * ) param1 ; <nl> - emit referenceSetCellContent ( info - > row , info - > col , QString ( info - > str ) ) ; <nl> + if ( referenceManager - > currentReferenceView ( ) ) <nl> + referenceManager - > currentReferenceView ( ) - > setCellContent ( info - > row , info - > col , QString ( info - > str ) ) ; <nl> } <nl> break ; <nl> <nl> void * Bridge : : processMessage ( GUIMSG type , void * param1 , void * param2 ) <nl> break ; <nl> <nl> case GUI_REF_SETSEARCHSTARTCOL : <nl> - emit referenceSetSearchStartCol ( ( int ) param1 ) ; <nl> + if ( referenceManager - > currentReferenceView ( ) ) <nl> + referenceManager - > currentReferenceView ( ) - > setSearchStartCol ( ( int ) param1 ) ; <nl> break ; <nl> <nl> case GUI_REF_INITIALIZE : <nl> mmm a / src / gui / Src / Bridge / BridgeResult . h <nl> ppp b / src / gui / Src / Bridge / BridgeResult . h <nl> class BridgeResult <nl> ScriptAdd , <nl> ScriptMessage , <nl> RefInitialize , <nl> - RefSetRowCount , <nl> MenuAddToList , <nl> MenuAdd , <nl> MenuAddEntry , <nl>
GUI : improve performance of ReferenceView API
x64dbg/x64dbg
aac246b27fada5587b5e2e702bf946469e5d9767
2020-02-10T02:10:31Z
mmm a / CMakeLists . txt <nl> ppp b / CMakeLists . txt <nl> if ( BUILD_TESTS ) <nl> folly_define_tests ( <nl> DIRECTORY concurrency / test / <nl> TEST cache_locality_test SOURCES CacheLocalityTest . cpp <nl> - DIRECTORY executors / test / <nl> - TEST async_test SOURCES AsyncTest . cpp <nl> + <nl> + DIRECTORY executors / test / <nl> + TEST async_helpers_test SOURCES AsyncTest . cpp <nl> TEST codel_test SOURCES CodelTest . cpp <nl> TEST fiber_io_executor_test SOURCES FiberIOExecutorTest . cpp <nl> TEST global_executor_test SOURCES GlobalExecutorTest . cpp <nl> if ( BUILD_TESTS ) <nl> TEST thread_pool_executor_test SOURCES ThreadPoolExecutorTest . cpp <nl> TEST threaded_executor_test SOURCES ThreadedExecutorTest . cpp <nl> TEST unbounded_blocking_queue_test SOURCES UnboundedBlockingQueueTest . cpp <nl> + <nl> DIRECTORY experimental / test / <nl> TEST autotimer_test SOURCES AutoTimerTest . cpp <nl> TEST bits_test_2 SOURCES BitsTest . cpp <nl> if ( BUILD_TESTS ) <nl> TEST parallel_map_test SOURCES ParallelMapTest . cpp <nl> TEST parallel_test SOURCES ParallelTest . cpp <nl> <nl> + DIRECTORY hash / test / <nl> + TEST spooky_hash_v1_test SOURCES SpookyHashV1Test . cpp <nl> + TEST spooky_hash_v2_test SOURCES SpookyHashV2Test . cpp <nl> + <nl> DIRECTORY io / test / <nl> TEST compression_test SOURCES CompressionTest . cpp <nl> TEST iobuf_test SOURCES IOBufTest . cpp <nl> if ( BUILD_TESTS ) <nl> TEST small_vector_test SOURCES small_vector_test . cpp <nl> TEST sorted_vector_types_test SOURCES sorted_vector_test . cpp <nl> TEST sparse_byte_set_test SOURCES SparseByteSetTest . cpp <nl> - TEST spooky_hash_v1_test SOURCES SpookyHashV1Test . cpp <nl> - TEST spooky_hash_v2_test SOURCES SpookyHashV2Test . cpp <nl> TEST string_test SOURCES StringTest . cpp <nl> # TEST subprocess_test SOURCES SubprocessTest . cpp <nl> TEST synchronized_test SOURCES SynchronizedTest . cpp <nl>
Fix CMake build
facebook/folly
14b0638329890bc8ac0bcd517d191e8517d58e76
2017-09-12T02:20:00Z
mmm a / extra_fonts / README . txt <nl> ppp b / extra_fonts / README . txt <nl> <nl> Load . TTF file with : <nl> <nl> ImGuiIO & io = ImGui : : GetIO ( ) ; <nl> - io . Fonts - > AddFontFromFileTTF ( " myfontfile . ttf " , size_pixels ) ; <nl> + io . Fonts - > AddFontFromFileTTF ( " font . ttf " , size_pixels ) ; <nl> <nl> Detailed options : <nl> <nl> <nl> config . OversampleH = 3 ; <nl> config . OversampleV = 3 ; <nl> config . GlyphExtraSpacing . x = 1 . 0f ; <nl> - io . Fonts - > AddFontFromFileTTF ( " myfontfile . ttf " , size_pixels , & config ) ; <nl> + io . Fonts - > AddFontFromFileTTF ( " font . ttf " , size_pixels , & config ) ; <nl> <nl> Combine two fonts into one : <nl> <nl> <nl> ImFontConfig config ; <nl> config . MergeMode = true ; <nl> io . Fonts - > AddFontFromFileTTF ( " fontawesome - webfont . ttf " , 16 . 0f , & config , ranges ) ; <nl> - io . Fonts - > AddFontFromFileTTF ( " myfontfile . ttf " , size_pixels , & config , io . Fonts - > GetGlyphRangesJapanese ( ) ) ; <nl> + io . Fonts - > AddFontFromFileTTF ( " font . ttf " , size_pixels , & config , io . Fonts - > GetGlyphRangesJapanese ( ) ) ; <nl> <nl> Add a fourth parameter to bake specific font ranges only : <nl> <nl> / / Basic Latin , Extended Latin <nl> - io . Fonts - > AddFontFromFileTTF ( " myfontfile . ttf " , size_pixels , NULL , io . Fonts - > GetGlyphRangesDefault ( ) ) ; <nl> + io . Fonts - > AddFontFromFileTTF ( " font . ttf " , size_pixels , NULL , io . Fonts - > GetGlyphRangesDefault ( ) ) ; <nl> <nl> / / Include full set of about 21000 CJK Unified Ideographs <nl> - io . Fonts - > AddFontFromFileTTF ( " myfontfile . ttf " , size_pixels , NULL , io . Fonts - > GetGlyphRangesJapanese ( ) ) ; <nl> + io . Fonts - > AddFontFromFileTTF ( " font . ttf " , size_pixels , NULL , io . Fonts - > GetGlyphRangesJapanese ( ) ) ; <nl> <nl> / / Default + Hiragana , Katakana , Half - Width , Selection of 1946 Ideographs <nl> - io . Fonts - > AddFontFromFileTTF ( " myfontfile . ttf " , size_pixels , NULL , io . Fonts - > GetGlyphRangesChinese ( ) ) ; <nl> + io . Fonts - > AddFontFromFileTTF ( " font . ttf " , size_pixels , NULL , io . Fonts - > GetGlyphRangesChinese ( ) ) ; <nl> <nl> Offset font vertically by altering the io . Font - > DisplayOffset value : <nl> <nl> - ImFont * font = io . Fonts - > AddFontFromFileTTF ( " myfontfile . ttf " , size_pixels ) ; <nl> + ImFont * font = io . Fonts - > AddFontFromFileTTF ( " font . ttf " , size_pixels ) ; <nl> font - > DisplayOffset . y + = 1 ; / / Render 1 pixel down <nl> <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl>
Update documentation
ocornut/imgui
96a7873622e65a97af26fc1de035907851331d93
2015-08-06T04:00:27Z
mmm a / lib / AST / ASTWalker . cpp <nl> ppp b / lib / AST / ASTWalker . cpp <nl> class Traversal : public ASTVisitor < Traversal , Expr * , Stmt * , <nl> if ( doIt ( Inherit ) ) <nl> return true ; <nl> } <nl> + <nl> + if ( auto * ATD = dyn_cast < AssociatedTypeDecl > ( TPD ) ) { <nl> + if ( auto * WhereClause = ATD - > getTrailingWhereClause ( ) ) { <nl> + for ( auto & Req : WhereClause - > getRequirements ( ) ) { <nl> + if ( doIt ( Req ) ) <nl> + return true ; <nl> + } <nl> + } <nl> + } <nl> return false ; <nl> } <nl> <nl> class Traversal : public ASTVisitor < Traversal , Expr * , Stmt * , <nl> } <nl> / / Visit param conformance <nl> for ( auto & Req : NTD - > getGenericParams ( ) - > getRequirements ( ) ) { <nl> - switch ( Req . getKind ( ) ) { <nl> - case RequirementReprKind : : SameType : <nl> - if ( doIt ( Req . getFirstTypeLoc ( ) ) | | doIt ( Req . getSecondTypeLoc ( ) ) ) <nl> - return true ; <nl> - break ; <nl> - case RequirementReprKind : : TypeConstraint : <nl> - if ( doIt ( Req . getSubjectLoc ( ) ) | | doIt ( Req . getConstraintLoc ( ) ) ) <nl> - return true ; <nl> - break ; <nl> - case RequirementReprKind : : LayoutConstraint : <nl> - if ( doIt ( Req . getFirstTypeLoc ( ) ) ) <nl> - return true ; <nl> - break ; <nl> - } <nl> + if ( doIt ( Req ) ) <nl> + return true ; <nl> } <nl> } <nl> <nl> class Traversal : public ASTVisitor < Traversal , Expr * , Stmt * , <nl> if ( doIt ( Inherit ) ) <nl> return true ; <nl> } <nl> + <nl> + if ( auto * Protocol = dyn_cast < ProtocolDecl > ( NTD ) ) { <nl> + if ( auto * WhereClause = Protocol - > getTrailingWhereClause ( ) ) { <nl> + for ( auto & Req : WhereClause - > getRequirements ( ) ) { <nl> + if ( doIt ( Req ) ) <nl> + return true ; <nl> + } <nl> + } <nl> + } <nl> + <nl> for ( Decl * Member : NTD - > getMembers ( ) ) <nl> if ( doIt ( Member ) ) <nl> return true ; <nl> class Traversal : public ASTVisitor < Traversal , Expr * , Stmt * , <nl> <nl> / / Visit param conformance <nl> for ( auto & Req : AFD - > getGenericParams ( ) - > getRequirements ( ) ) { <nl> - switch ( Req . getKind ( ) ) { <nl> - case RequirementReprKind : : SameType : <nl> - if ( doIt ( Req . getFirstTypeLoc ( ) ) | | doIt ( Req . getSecondTypeLoc ( ) ) ) <nl> - return true ; <nl> - break ; <nl> - case RequirementReprKind : : TypeConstraint : <nl> - if ( doIt ( Req . getSubjectLoc ( ) ) | | doIt ( Req . getConstraintLoc ( ) ) ) <nl> - return true ; <nl> - break ; <nl> - case RequirementReprKind : : LayoutConstraint : <nl> - if ( doIt ( Req . getSubjectLoc ( ) ) ) <nl> - return true ; <nl> - break ; <nl> - } <nl> + if ( doIt ( Req ) ) <nl> + return true ; <nl> } <nl> } <nl> <nl> class Traversal : public ASTVisitor < Traversal , Expr * , Stmt * , <nl> / / If we didn ' t bail out , do post - order visitation . <nl> return ! Walker . walkToTypeReprPost ( T ) ; <nl> } <nl> + <nl> + bool doIt ( RequirementRepr & Req ) { <nl> + switch ( Req . getKind ( ) ) { <nl> + case RequirementReprKind : : SameType : <nl> + if ( doIt ( Req . getFirstTypeLoc ( ) ) | | doIt ( Req . getSecondTypeLoc ( ) ) ) <nl> + return true ; <nl> + break ; <nl> + case RequirementReprKind : : TypeConstraint : <nl> + if ( doIt ( Req . getSubjectLoc ( ) ) | | doIt ( Req . getConstraintLoc ( ) ) ) <nl> + return true ; <nl> + break ; <nl> + case RequirementReprKind : : LayoutConstraint : <nl> + if ( doIt ( Req . getFirstTypeLoc ( ) ) ) <nl> + return true ; <nl> + break ; <nl> + } <nl> + return false ; <nl> + } <nl> } ; <nl> <nl> } / / end anonymous namespace <nl> mmm a / test / Index / roles . swift <nl> ppp b / test / Index / roles . swift <nl> protocol X { <nl> / / CHECK - NEXT RelChild , RelAcc | instance - property / Swift | reqProp_USR | [ [ reqProp_USR ] ] <nl> } <nl> <nl> - class ImplementsX : X { <nl> + protocol Y { } <nl> + / / CHECK : [ [ @ LINE - 1 ] ] : 10 | protocol / Swift | Y | [ [ Y_USR : . * ] ] | Def | rel : 0 <nl> + <nl> + class ImplementsX : X , Y { <nl> / / CHECK : [ [ @ LINE - 1 ] ] : 7 | class / Swift | ImplementsX | [ [ ImplementsX_USR : . * ] ] | Def | rel : 0 <nl> / / CHECK : [ [ @ LINE - 2 ] ] : 21 | protocol / Swift | X | [ [ X_USR ] ] | Ref , RelBase | rel : 1 <nl> / / CHECK - NEXT : RelBase | class / Swift | ImplementsX | [ [ ImplementsX_USR ] ] <nl> func TestX ( x : X ) { <nl> protocol AProtocol { <nl> / / CHECK : [ [ @ LINE - 1 ] ] : 10 | protocol / Swift | AProtocol | [ [ AProtocol_USR : . * ] ] | Def | rel : 0 <nl> <nl> - associatedtype T : X <nl> - / / CHECK : [ [ @ LINE - 1 ] ] : 18 | type - alias / associated - type / Swift | T | s : 14swift_ide_test9AProtocolP1T | Def , RelChild | rel : 1 <nl> + associatedtype T : X where T : Y <nl> + / / CHECK : [ [ @ LINE - 1 ] ] : 18 | type - alias / associated - type / Swift | T | [ [ AProtocol_T_USR : . * ] ] | Def , RelChild | rel : 1 <nl> / / CHECK - NEXT : RelChild | protocol / Swift | AProtocol | [ [ AProtocol_USR ] ] <nl> / / CHECK : [ [ @ LINE - 3 ] ] : 22 | protocol / Swift | X | [ [ X_USR ] ] | Ref | rel : 0 <nl> + / / CHECK : [ [ @ LINE - 4 ] ] : 30 | type - alias / associated - type / Swift | T | [ [ AProtocol_T_USR ] ] | Ref | rel : 0 <nl> + / / CHECK : [ [ @ LINE - 5 ] ] : 32 | protocol / Swift | Y | [ [ Y_USR ] ] | Ref | rel : 0 <nl> <nl> func foo ( ) - > Int <nl> / / CHECK : [ [ @ LINE - 1 ] ] : 8 | instance - method / Swift | foo ( ) | s : 14swift_ide_test9AProtocolP3fooSiyF | Def , Dyn , RelChild | rel : 1 <nl> / / CHECK - NEXT : RelChild | protocol / Swift | AProtocol | s : 14swift_ide_test9AProtocolP <nl> } <nl> <nl> + protocol Q where Self : AProtocol { } <nl> + / / CHECK : [ [ @ LINE - 1 ] ] : 24 | protocol / Swift | AProtocol | [ [ AProtocol_USR ] ] | Ref | rel : 0 <nl> + <nl> class ASubClass : AClass , AProtocol { <nl> / / CHECK : [ [ @ LINE - 1 ] ] : 7 | class / Swift | ASubClass | s : 14swift_ide_test9ASubClassC | Def | rel : 0 <nl> / / CHECK : [ [ @ LINE - 2 ] ] : 19 | class / Swift | AClass | s : 14swift_ide_test6AClassC | Ref , RelBase | rel : 1 <nl> mmm a / test / SourceKit / CursorInfo / cursor_label . swift <nl> ppp b / test / SourceKit / CursorInfo / cursor_label . swift <nl> class C1 { <nl> init ( cc : Int ) { } <nl> func foo ( aa : Int ) { } <nl> subscript ( aa : Int , bb : Int ) - > Int { get { return 0 } set { } } <nl> + func foo ( _ aa : Int ) { } <nl> + init ( _ cc : Int ) { } <nl> + subscript ( _ aa : Int ) - > Int { get { return 0 } set { } } <nl> } <nl> let c = C1 ( cc : 1 ) <nl> c . foo ( aa : 1 ) <nl> c . foo ( aa : 1 ) <nl> / / RUN : % sourcekitd - test - req = cursor - pos = 2 : 9 % s - - % s | % FileCheck % s - check - prefix = CHECK1 <nl> / / RUN : % sourcekitd - test - req = cursor - pos = 3 : 13 % s - - % s | % FileCheck % s - check - prefix = CHECK2 <nl> / / RUN : % sourcekitd - test - req = cursor - pos = 4 : 24 % s - - % s | % FileCheck % s - check - prefix = CHECK3 <nl> + / / RUN : % sourcekitd - test - req = cursor - pos = 5 : 15 % s - - % s | % FileCheck % s - check - prefix = CHECK - NONE <nl> + / / RUN : % sourcekitd - test - req = cursor - pos = 6 : 11 % s - - % s | % FileCheck % s - check - prefix = CHECK - NONE <nl> + / / RUN : % sourcekitd - test - req = cursor - pos = 7 : 16 % s - - % s | % FileCheck % s - check - prefix = CHECK - NONE <nl> <nl> / / CHECK1 : PARENT OFFSET : 13 <nl> / / CHECK2 : PARENT OFFSET : 37 <nl> / / CHECK3 : PARENT OFFSET : 56 <nl> + / / CHECK - NONE - NOT : PARENT OFFSET : <nl> mmm a / tools / SourceKit / lib / SwiftLang / SwiftSourceDocInfo . cpp <nl> ppp b / tools / SourceKit / lib / SwiftLang / SwiftSourceDocInfo . cpp <nl> static bool passCursorInfoForModule ( ModuleEntity Mod , <nl> return false ; <nl> } <nl> <nl> - static Optional < unsigned > getParamParentNameOffset ( const ValueDecl * VD ) { <nl> + static Optional < unsigned > <nl> + getParamParentNameOffset ( const ValueDecl * VD , SourceLoc Cursor ) { <nl> + if ( Cursor . isInvalid ( ) ) <nl> + return None ; <nl> SourceLoc Loc ; <nl> if ( auto PD = dyn_cast < ParamDecl > ( VD ) ) { <nl> + <nl> + / / Avoid returning parent loc for internal - only names . <nl> + if ( PD - > getArgumentNameLoc ( ) . isValid ( ) & & PD - > getNameLoc ( ) = = Cursor ) <nl> + return None ; <nl> auto * DC = PD - > getDeclContext ( ) ; <nl> switch ( DC - > getContextKind ( ) ) { <nl> case DeclContextKind : : SubscriptDecl : <nl> static bool passCursorInfoForDecl ( const ValueDecl * VD , <nl> const Type ContainerTy , <nl> bool IsRef , <nl> Optional < unsigned > OrigBufferID , <nl> + SourceLoc CursorLoc , <nl> SwiftLangSupport & Lang , <nl> const CompilerInvocation & Invok , <nl> ArrayRef < ImmutableTextSnapshotRef > PreviousASTSnaps , <nl> static bool passCursorInfoForDecl ( const ValueDecl * VD , <nl> Info . LocalizationKey = LocalizationKey ; <nl> Info . IsSystem = IsSystem ; <nl> Info . TypeInterface = StringRef ( ) ; <nl> - Info . ParentNameOffset = getParamParentNameOffset ( VD ) ; <nl> + Info . ParentNameOffset = getParamParentNameOffset ( VD , CursorLoc ) ; <nl> Receiver ( Info ) ; <nl> return false ; <nl> } <nl> static void resolveCursor ( SwiftLangSupport & Lang , <nl> bool Failed = passCursorInfoForDecl ( VD , MainModule , <nl> SemaTok . ContainerType , <nl> SemaTok . ContainerType , <nl> - SemaTok . IsRef , BufferID , Lang , <nl> + SemaTok . IsRef , BufferID , Loc , Lang , <nl> CompInvok , getPreviousASTSnaps ( ) , <nl> Receiver ) ; <nl> if ( Failed ) { <nl> void SwiftLangSupport : : getCursorInfo ( <nl> / / it ' s not necessary . <nl> passCursorInfoForDecl ( <nl> Entity . Dcl , / * MainModule * / nullptr , Type ( ) , Type ( ) , Entity . IsRef , <nl> - / * OrigBufferID = * / None , * this , Invok , { } , Receiver ) ; <nl> + / * OrigBufferID = * / None , SourceLoc ( ) , * this , Invok , { } , Receiver ) ; <nl> } <nl> } else { <nl> Receiver ( { } ) ; <nl> resolveCursorFromUSR ( SwiftLangSupport & Lang , StringRef InputFile , StringRef USR , <nl> } <nl> bool Failed = <nl> passCursorInfoForDecl ( VD , MainModule , selfTy , Type ( ) , <nl> - / * IsRef = * / false , BufferID , Lang , CompInvok , <nl> - PreviousASTSnaps , Receiver ) ; <nl> + / * IsRef = * / false , BufferID , SourceLoc ( ) , Lang , <nl> + CompInvok , PreviousASTSnaps , Receiver ) ; <nl> if ( Failed ) { <nl> if ( ! PreviousASTSnaps . empty ( ) ) { <nl> / / Attempt again using the up - to - date AST . <nl>
Merge remote - tracking branch ' origin / master ' into master - next
apple/swift
d62f14e627849754dbe60ce197d2454019221ad4
2017-05-04T20:08:33Z
mmm a / dbms / programs / server / TCPHandler . cpp <nl> ppp b / dbms / programs / server / TCPHandler . cpp <nl> void TCPHandler : : processOrdinaryQueryWithProcessors ( size_t num_threads ) <nl> auto lazy_format = std : : make_shared < LazyOutputFormat > ( pipeline . getHeader ( ) ) ; <nl> pipeline . setOutput ( lazy_format ) ; <nl> <nl> - ThreadPool pool ( 1 , 1 , 1 , CurrentThread : : getGroup ( ) ) ; <nl> + ThreadPool pool ( 1 , 1 , 1 ) ; <nl> auto executor = pipeline . execute ( num_threads ) ; <nl> bool exception = false ; <nl> + auto thread_group = CurrentThread : : getGroup ( ) ; <nl> <nl> pool . schedule ( [ & ] ( ) <nl> { <nl> CurrentMetrics : : Increment query_thread_metric_increment { CurrentMetrics : : QueryThread } ; <nl> setThreadName ( " QueryPipelineEx " ) ; <nl> <nl> + if ( thread_group ) <nl> + CurrentThread : : attachTo ( thread_group ) ; <nl> + <nl> + SCOPE_EXIT ( <nl> + if ( thread_group ) <nl> + CurrentThread : : detachQueryIfNotDetached ( ) ; <nl> + ) ; <nl> + <nl> try <nl> { <nl> executor - > execute ( ) ; <nl> mmm a / dbms / src / Common / ThreadPool . cpp <nl> ppp b / dbms / src / Common / ThreadPool . cpp <nl> size_t ThreadPoolImpl < Thread > : : active ( ) const <nl> template < typename Thread > <nl> void ThreadPoolImpl < Thread > : : worker ( typename std : : list < Thread > : : iterator thread_it ) <nl> { <nl> - if ( thread_group ) <nl> - DB : : CurrentThread : : attachTo ( thread_group ) ; <nl> - <nl> - SCOPE_EXIT ( <nl> - if ( thread_group ) <nl> - DB : : CurrentThread : : detachQueryIfNotDetached ( ) <nl> - ) ; <nl> - <nl> while ( true ) <nl> { <nl> Job job ; <nl> mmm a / dbms / src / Common / ThreadPool . h <nl> ppp b / dbms / src / Common / ThreadPool . h <nl> <nl> # include < Poco / Event . h > <nl> # include < Common / ThreadStatus . h > <nl> <nl> - namespace DB <nl> - { <nl> - <nl> - class ThreadGroupStatus ; <nl> - using ThreadGroupStatusPtr = std : : shared_ptr < ThreadGroupStatus > ; <nl> - <nl> - } <nl> <nl> / * * Very simple thread pool similar to boost : : threadpool . <nl> * Advantages : <nl> class ThreadPoolImpl <nl> using Job = std : : function < void ( ) > ; <nl> <nl> / / / Size is constant . Up to num_threads are created on demand and then run until shutdown . <nl> - explicit ThreadPoolImpl ( size_t max_threads , DB : : ThreadGroupStatusPtr thread_group_ = nullptr ) ; <nl> + explicit ThreadPoolImpl ( size_t max_threads ) ; <nl> <nl> / / / queue_size - maximum number of running plus scheduled jobs . It can be greater than max_threads . Zero means unlimited . <nl> - / / / Specify thread_group if thread pool is used for concrete query execution ( or leave it it nullptr and attach to thread group manually ) . <nl> - ThreadPoolImpl ( size_t max_threads , size_t max_free_threads , size_t queue_size , DB : : ThreadGroupStatusPtr thread_group_ = nullptr ) ; <nl> + ThreadPoolImpl ( size_t max_threads , size_t max_free_threads , size_t queue_size ) ; <nl> <nl> / / / Add new job . Locks until number of scheduled jobs is less than maximum or exception in one of threads was thrown . <nl> / / / If an exception in some thread was thrown , method silently returns , and exception will be rethrown only on call to ' wait ' function . <nl>
Undo add thread_group to ThreadPool
ClickHouse/ClickHouse
a07b592a954a5a701e1fe9464e555977017777b5
2019-04-18T18:40:55Z
mmm a / modules / videostab / include / opencv2 / videostab / global_motion . hpp <nl> ppp b / modules / videostab / include / opencv2 / videostab / global_motion . hpp <nl> class CV_EXPORTS PyrLkRobustMotionEstimator : public GlobalMotionEstimatorBase <nl> void setRansacParams ( const RansacParams & val ) { ransacParams_ = val ; } <nl> RansacParams ransacParams ( ) const { return ransacParams_ ; } <nl> <nl> - void setMaxRmse ( float val ) { maxRmse_ = val ; } <nl> - float maxRmse ( ) const { return maxRmse_ ; } <nl> - <nl> void setMinInlierRatio ( float val ) { minInlierRatio_ = val ; } <nl> float minInlierRatio ( ) const { return minInlierRatio_ ; } <nl> <nl> class CV_EXPORTS PyrLkRobustMotionEstimator : public GlobalMotionEstimatorBase <nl> std : : vector < KeyPoint > keypointsPrev_ ; <nl> std : : vector < Point2f > pointsPrev_ , points_ ; <nl> std : : vector < Point2f > pointsPrevGood_ , pointsGood_ ; <nl> - float maxRmse_ ; <nl> float minInlierRatio_ ; <nl> Size gridSize_ ; <nl> } ; <nl> mmm a / modules / videostab / src / global_motion . cpp <nl> ppp b / modules / videostab / src / global_motion . cpp <nl> PyrLkRobustMotionEstimator : : PyrLkRobustMotionEstimator ( MotionModel model ) <nl> ransac . size * = 2 ; / / we use more points than needed , but result looks better <nl> setRansacParams ( ransac ) ; <nl> <nl> - setMaxRmse ( 0 . 5f ) ; <nl> setMinInlierRatio ( 0 . 1f ) ; <nl> setGridSize ( Size ( 0 , 0 ) ) ; <nl> } <nl> Mat PyrLkRobustMotionEstimator : : estimate ( const Mat & frame0 , const Mat & frame1 , b <nl> } <nl> } <nl> <nl> - float rmse ; <nl> int ninliers ; <nl> Mat_ < float > M ; <nl> <nl> if ( motionModel_ ! = MM_HOMOGRAPHY ) <nl> M = estimateGlobalMotionRobust ( <nl> - pointsPrevGood_ , pointsGood_ , motionModel_ , ransacParams_ , & rmse , & ninliers ) ; <nl> + pointsPrevGood_ , pointsGood_ , motionModel_ , ransacParams_ , 0 , & ninliers ) ; <nl> else <nl> { <nl> vector < uchar > mask ; <nl> M = findHomography ( pointsPrevGood_ , pointsGood_ , mask , CV_RANSAC , ransacParams_ . thresh ) ; <nl> <nl> ninliers = 0 ; <nl> - rmse = 0 ; <nl> - <nl> - Point2f p0 , p1 ; <nl> - float x , y , z ; <nl> - <nl> for ( size_t i = 0 ; i < pointsGood_ . size ( ) ; + + i ) <nl> - { <nl> - if ( mask [ i ] ) <nl> - { <nl> - p0 = pointsPrevGood_ [ i ] ; p1 = pointsGood_ [ i ] ; <nl> - x = M ( 0 , 0 ) * p0 . x + M ( 0 , 1 ) * p0 . y + M ( 0 , 2 ) ; <nl> - y = M ( 1 , 0 ) * p0 . x + M ( 1 , 1 ) * p0 . y + M ( 1 , 2 ) ; <nl> - z = M ( 2 , 0 ) * p0 . x + M ( 2 , 1 ) * p0 . y + M ( 2 , 2 ) ; <nl> - x / = z ; y / = z ; <nl> - rmse + = sqr ( x - p1 . x ) + sqr ( y - p1 . y ) ; <nl> - ninliers + + ; <nl> - } <nl> - } <nl> - <nl> - rmse = sqrt ( rmse / static_cast < float > ( ninliers ) ) ; <nl> + if ( mask [ i ] ) ninliers + + ; <nl> } <nl> <nl> if ( ok ) * ok = true ; <nl> - if ( rmse > maxRmse_ | | static_cast < float > ( ninliers ) / pointsGood_ . size ( ) < minInlierRatio_ ) <nl> + if ( static_cast < float > ( ninliers ) / pointsGood_ . size ( ) < minInlierRatio_ ) <nl> { <nl> M = Mat : : eye ( 3 , 3 , CV_32F ) ; <nl> if ( ok ) * ok = false ; <nl> mmm a / modules / videostab / src / motion_stabilizing . cpp <nl> ppp b / modules / videostab / src / motion_stabilizing . cpp <nl> Mat GaussianMotionFilter : : stabilize ( int idx , const vector < Mat > & motions , pair < in <nl> } <nl> <nl> <nl> - static inline int areaSign ( Point2f a , Point2f b , Point2f c ) <nl> - { <nl> - double area = ( b - a ) . cross ( c - a ) ; <nl> - if ( area < - 1e - 5 ) return - 1 ; <nl> - if ( area > 1e - 5 ) return 1 ; <nl> - return 0 ; <nl> - } <nl> - <nl> - <nl> - static inline bool segmentsIntersect ( Point2f a , Point2f b , Point2f c , Point2f d ) <nl> - { <nl> - return areaSign ( a , b , c ) * areaSign ( a , b , d ) < 0 & & <nl> - areaSign ( c , d , a ) * areaSign ( c , d , b ) < 0 ; <nl> - } <nl> - <nl> - <nl> - / / Checks if rect a ( with sides parallel to axis ) is inside rect b ( arbitrary ) . <nl> - / / Rects must be passed in the [ ( 0 , 0 ) , ( w , 0 ) , ( w , h ) , ( 0 , h ) ] order . <nl> - static inline bool isRectInside ( const Point2f a [ 4 ] , const Point2f b [ 4 ] ) <nl> - { <nl> - for ( int i = 0 ; i < 4 ; + + i ) <nl> - if ( b [ i ] . x > a [ 0 ] . x & & b [ i ] . x < a [ 2 ] . x & & b [ i ] . y > a [ 0 ] . y & & b [ i ] . y < a [ 2 ] . y ) <nl> - return false ; <nl> - for ( int i = 0 ; i < 4 ; + + i ) <nl> - for ( int j = 0 ; j < 4 ; + + j ) <nl> - if ( segmentsIntersect ( a [ i ] , a [ ( i + 1 ) % 4 ] , b [ j ] , b [ ( j + 1 ) % 4 ] ) ) <nl> - return false ; <nl> - return true ; <nl> - } <nl> - <nl> - <nl> - static inline bool isGoodMotion ( const float M [ ] , float w , float h , float dx , float dy ) <nl> - { <nl> - Point2f pt [ 4 ] = { Point2f ( 0 , 0 ) , Point2f ( w , 0 ) , Point2f ( w , h ) , Point2f ( 0 , h ) } ; <nl> - Point2f Mpt [ 4 ] ; <nl> - <nl> - for ( int i = 0 ; i < 4 ; + + i ) <nl> - { <nl> - Mpt [ i ] . x = M [ 0 ] * pt [ i ] . x + M [ 1 ] * pt [ i ] . y + M [ 2 ] ; <nl> - Mpt [ i ] . y = M [ 3 ] * pt [ i ] . x + M [ 4 ] * pt [ i ] . y + M [ 5 ] ; <nl> - } <nl> - <nl> - pt [ 0 ] = Point2f ( dx , dy ) ; <nl> - pt [ 1 ] = Point2f ( w - dx , dy ) ; <nl> - pt [ 2 ] = Point2f ( w - dx , h - dy ) ; <nl> - pt [ 3 ] = Point2f ( dx , h - dy ) ; <nl> - <nl> - return isRectInside ( pt , Mpt ) ; <nl> - } <nl> - <nl> - <nl> - static inline void relaxMotion ( const float M [ ] , float t , float res [ ] ) <nl> - { <nl> - res [ 0 ] = M [ 0 ] * ( 1 . f - t ) + t ; <nl> - res [ 1 ] = M [ 1 ] * ( 1 . f - t ) ; <nl> - res [ 2 ] = M [ 2 ] * ( 1 . f - t ) ; <nl> - res [ 3 ] = M [ 3 ] * ( 1 . f - t ) ; <nl> - res [ 4 ] = M [ 4 ] * ( 1 . f - t ) + t ; <nl> - res [ 5 ] = M [ 5 ] * ( 1 . f - t ) ; <nl> - } <nl> - <nl> - <nl> - Mat ensureInclusionConstraint ( const Mat & M , Size size , float trimRatio ) <nl> - { <nl> - CV_Assert ( M . size ( ) = = Size ( 3 , 3 ) & & M . type ( ) = = CV_32F ) ; <nl> - <nl> - const float w = static_cast < float > ( size . width ) ; <nl> - const float h = static_cast < float > ( size . height ) ; <nl> - const float dx = floor ( w * trimRatio ) ; <nl> - const float dy = floor ( h * trimRatio ) ; <nl> - const float srcM [ 6 ] = <nl> - { M . at < float > ( 0 , 0 ) , M . at < float > ( 0 , 1 ) , M . at < float > ( 0 , 2 ) , <nl> - M . at < float > ( 1 , 0 ) , M . at < float > ( 1 , 1 ) , M . at < float > ( 1 , 2 ) } ; <nl> - <nl> - float curM [ 6 ] ; <nl> - float t = 0 ; <nl> - relaxMotion ( srcM , t , curM ) ; <nl> - if ( isGoodMotion ( curM , w , h , dx , dy ) ) <nl> - return M ; <nl> - <nl> - float l = 0 , r = 1 ; <nl> - while ( r - l > 1e - 3f ) <nl> - { <nl> - t = ( l + r ) * 0 . 5f ; <nl> - relaxMotion ( srcM , t , curM ) ; <nl> - if ( isGoodMotion ( curM , w , h , dx , dy ) ) <nl> - r = t ; <nl> - else <nl> - l = t ; <nl> - } <nl> - <nl> - return ( 1 - r ) * M + r * Mat : : eye ( 3 , 3 , CV_32F ) ; <nl> - } <nl> - <nl> - <nl> - / / TODO can be estimated for O ( 1 ) time <nl> - float estimateOptimalTrimRatio ( const Mat & M , Size size ) <nl> - { <nl> - CV_Assert ( M . size ( ) = = Size ( 3 , 3 ) & & M . type ( ) = = CV_32F ) ; <nl> - <nl> - const float w = static_cast < float > ( size . width ) ; <nl> - const float h = static_cast < float > ( size . height ) ; <nl> - Mat_ < float > M_ ( M ) ; <nl> - <nl> - Point2f pt [ 4 ] = { Point2f ( 0 , 0 ) , Point2f ( w , 0 ) , Point2f ( w , h ) , Point2f ( 0 , h ) } ; <nl> - Point2f Mpt [ 4 ] ; <nl> - <nl> - for ( int i = 0 ; i < 4 ; + + i ) <nl> - { <nl> - Mpt [ i ] . x = M_ ( 0 , 0 ) * pt [ i ] . x + M_ ( 0 , 1 ) * pt [ i ] . y + M_ ( 0 , 2 ) ; <nl> - Mpt [ i ] . y = M_ ( 1 , 0 ) * pt [ i ] . x + M_ ( 1 , 1 ) * pt [ i ] . y + M_ ( 1 , 2 ) ; <nl> - } <nl> - <nl> - float l = 0 , r = 0 . 5f ; <nl> - while ( r - l > 1e - 3f ) <nl> - { <nl> - float t = ( l + r ) * 0 . 5f ; <nl> - float dx = floor ( w * t ) ; <nl> - float dy = floor ( h * t ) ; <nl> - pt [ 0 ] = Point2f ( dx , dy ) ; <nl> - pt [ 1 ] = Point2f ( w - dx , dy ) ; <nl> - pt [ 2 ] = Point2f ( w - dx , h - dy ) ; <nl> - pt [ 3 ] = Point2f ( dx , h - dy ) ; <nl> - if ( isRectInside ( pt , Mpt ) ) <nl> - r = t ; <nl> - else <nl> - l = t ; <nl> - } <nl> - <nl> - return r ; <nl> - } <nl> - <nl> - <nl> LpMotionStabilizer : : LpMotionStabilizer ( MotionModel model ) <nl> { <nl> setMotionModel ( model ) ; <nl> void LpMotionStabilizer : : stabilize ( int , const vector < Mat > & , pair < int , int > , Mat * ) <nl> void LpMotionStabilizer : : stabilize ( <nl> int size , const vector < Mat > & motions , pair < int , int > range , Mat * stabilizationMotions ) <nl> { <nl> - CV_Assert ( model_ = = MM_LINEAR_SIMILARITY ) ; <nl> + CV_Assert ( model_ < = MM_AFFINE ) ; <nl> <nl> int N = size ; <nl> const vector < Mat > & M = motions ; <nl> void LpMotionStabilizer : : stabilize ( <nl> } <nl> } <nl> <nl> + <nl> # endif / / # ifndef HAVE_CLP <nl> <nl> + <nl> + static inline int areaSign ( Point2f a , Point2f b , Point2f c ) <nl> + { <nl> + double area = ( b - a ) . cross ( c - a ) ; <nl> + if ( area < - 1e - 5 ) return - 1 ; <nl> + if ( area > 1e - 5 ) return 1 ; <nl> + return 0 ; <nl> + } <nl> + <nl> + <nl> + static inline bool segmentsIntersect ( Point2f a , Point2f b , Point2f c , Point2f d ) <nl> + { <nl> + return areaSign ( a , b , c ) * areaSign ( a , b , d ) < 0 & & <nl> + areaSign ( c , d , a ) * areaSign ( c , d , b ) < 0 ; <nl> + } <nl> + <nl> + <nl> + / / Checks if rect a ( with sides parallel to axis ) is inside rect b ( arbitrary ) . <nl> + / / Rects must be passed in the [ ( 0 , 0 ) , ( w , 0 ) , ( w , h ) , ( 0 , h ) ] order . <nl> + static inline bool isRectInside ( const Point2f a [ 4 ] , const Point2f b [ 4 ] ) <nl> + { <nl> + for ( int i = 0 ; i < 4 ; + + i ) <nl> + if ( b [ i ] . x > a [ 0 ] . x & & b [ i ] . x < a [ 2 ] . x & & b [ i ] . y > a [ 0 ] . y & & b [ i ] . y < a [ 2 ] . y ) <nl> + return false ; <nl> + for ( int i = 0 ; i < 4 ; + + i ) <nl> + for ( int j = 0 ; j < 4 ; + + j ) <nl> + if ( segmentsIntersect ( a [ i ] , a [ ( i + 1 ) % 4 ] , b [ j ] , b [ ( j + 1 ) % 4 ] ) ) <nl> + return false ; <nl> + return true ; <nl> + } <nl> + <nl> + <nl> + static inline bool isGoodMotion ( const float M [ ] , float w , float h , float dx , float dy ) <nl> + { <nl> + Point2f pt [ 4 ] = { Point2f ( 0 , 0 ) , Point2f ( w , 0 ) , Point2f ( w , h ) , Point2f ( 0 , h ) } ; <nl> + Point2f Mpt [ 4 ] ; <nl> + <nl> + for ( int i = 0 ; i < 4 ; + + i ) <nl> + { <nl> + Mpt [ i ] . x = M [ 0 ] * pt [ i ] . x + M [ 1 ] * pt [ i ] . y + M [ 2 ] ; <nl> + Mpt [ i ] . y = M [ 3 ] * pt [ i ] . x + M [ 4 ] * pt [ i ] . y + M [ 5 ] ; <nl> + } <nl> + <nl> + pt [ 0 ] = Point2f ( dx , dy ) ; <nl> + pt [ 1 ] = Point2f ( w - dx , dy ) ; <nl> + pt [ 2 ] = Point2f ( w - dx , h - dy ) ; <nl> + pt [ 3 ] = Point2f ( dx , h - dy ) ; <nl> + <nl> + return isRectInside ( pt , Mpt ) ; <nl> + } <nl> + <nl> + <nl> + static inline void relaxMotion ( const float M [ ] , float t , float res [ ] ) <nl> + { <nl> + res [ 0 ] = M [ 0 ] * ( 1 . f - t ) + t ; <nl> + res [ 1 ] = M [ 1 ] * ( 1 . f - t ) ; <nl> + res [ 2 ] = M [ 2 ] * ( 1 . f - t ) ; <nl> + res [ 3 ] = M [ 3 ] * ( 1 . f - t ) ; <nl> + res [ 4 ] = M [ 4 ] * ( 1 . f - t ) + t ; <nl> + res [ 5 ] = M [ 5 ] * ( 1 . f - t ) ; <nl> + } <nl> + <nl> + <nl> + Mat ensureInclusionConstraint ( const Mat & M , Size size , float trimRatio ) <nl> + { <nl> + CV_Assert ( M . size ( ) = = Size ( 3 , 3 ) & & M . type ( ) = = CV_32F ) ; <nl> + <nl> + const float w = static_cast < float > ( size . width ) ; <nl> + const float h = static_cast < float > ( size . height ) ; <nl> + const float dx = floor ( w * trimRatio ) ; <nl> + const float dy = floor ( h * trimRatio ) ; <nl> + const float srcM [ 6 ] = <nl> + { M . at < float > ( 0 , 0 ) , M . at < float > ( 0 , 1 ) , M . at < float > ( 0 , 2 ) , <nl> + M . at < float > ( 1 , 0 ) , M . at < float > ( 1 , 1 ) , M . at < float > ( 1 , 2 ) } ; <nl> + <nl> + float curM [ 6 ] ; <nl> + float t = 0 ; <nl> + relaxMotion ( srcM , t , curM ) ; <nl> + if ( isGoodMotion ( curM , w , h , dx , dy ) ) <nl> + return M ; <nl> + <nl> + float l = 0 , r = 1 ; <nl> + while ( r - l > 1e - 3f ) <nl> + { <nl> + t = ( l + r ) * 0 . 5f ; <nl> + relaxMotion ( srcM , t , curM ) ; <nl> + if ( isGoodMotion ( curM , w , h , dx , dy ) ) <nl> + r = t ; <nl> + else <nl> + l = t ; <nl> + } <nl> + <nl> + return ( 1 - r ) * M + r * Mat : : eye ( 3 , 3 , CV_32F ) ; <nl> + } <nl> + <nl> + <nl> + / / TODO can be estimated for O ( 1 ) time <nl> + float estimateOptimalTrimRatio ( const Mat & M , Size size ) <nl> + { <nl> + CV_Assert ( M . size ( ) = = Size ( 3 , 3 ) & & M . type ( ) = = CV_32F ) ; <nl> + <nl> + const float w = static_cast < float > ( size . width ) ; <nl> + const float h = static_cast < float > ( size . height ) ; <nl> + Mat_ < float > M_ ( M ) ; <nl> + <nl> + Point2f pt [ 4 ] = { Point2f ( 0 , 0 ) , Point2f ( w , 0 ) , Point2f ( w , h ) , Point2f ( 0 , h ) } ; <nl> + Point2f Mpt [ 4 ] ; <nl> + <nl> + for ( int i = 0 ; i < 4 ; + + i ) <nl> + { <nl> + Mpt [ i ] . x = M_ ( 0 , 0 ) * pt [ i ] . x + M_ ( 0 , 1 ) * pt [ i ] . y + M_ ( 0 , 2 ) ; <nl> + Mpt [ i ] . y = M_ ( 1 , 0 ) * pt [ i ] . x + M_ ( 1 , 1 ) * pt [ i ] . y + M_ ( 1 , 2 ) ; <nl> + } <nl> + <nl> + float l = 0 , r = 0 . 5f ; <nl> + while ( r - l > 1e - 3f ) <nl> + { <nl> + float t = ( l + r ) * 0 . 5f ; <nl> + float dx = floor ( w * t ) ; <nl> + float dy = floor ( h * t ) ; <nl> + pt [ 0 ] = Point2f ( dx , dy ) ; <nl> + pt [ 1 ] = Point2f ( w - dx , dy ) ; <nl> + pt [ 2 ] = Point2f ( w - dx , h - dy ) ; <nl> + pt [ 3 ] = Point2f ( dx , h - dy ) ; <nl> + if ( isRectInside ( pt , Mpt ) ) <nl> + r = t ; <nl> + else <nl> + l = t ; <nl> + } <nl> + <nl> + return r ; <nl> + } <nl> + <nl> + <nl> + / / TODO should process left open and right open segments ? <nl> + void interpolateMotions ( vector < Mat > & motions , vector < uchar > & mask ) <nl> + { <nl> + CV_Assert ( motions . size ( ) = = mask . size ( ) & & motions . size ( ) > 0 ) ; <nl> + <nl> + enum { INIT , IN_SEGMENT , LEFT_OPEN } state = mask [ 0 ] ? INIT : LEFT_OPEN ; <nl> + int left = - 1 ; <nl> + <nl> + for ( int i = 1 ; i < static_cast < int > ( motions . size ( ) ) ; + + i ) <nl> + { <nl> + if ( state = = INIT ) <nl> + { <nl> + if ( ! mask [ i ] ) <nl> + { <nl> + state = IN_SEGMENT ; <nl> + left = i - 1 ; <nl> + } <nl> + } <nl> + else if ( state = = IN_SEGMENT ) <nl> + { <nl> + if ( mask [ i ] ) <nl> + { <nl> + for ( int j = left ; j < i ; + + j ) <nl> + { <nl> + Mat_ < float > M = Mat : : eye ( 3 , 3 , CV_32F ) ; <nl> + Mat_ < float > Ml = motions [ left ] ; <nl> + Mat_ < float > Mr = motions [ i ] ; <nl> + <nl> + float d1 = j - left ; <nl> + float d2 = i - j ; <nl> + <nl> + for ( int l = 0 ; l < 3 ; + + l ) <nl> + for ( int s = 0 ; s < 3 ; + + s ) <nl> + M ( l , s ) = ( d2 * Ml ( l , s ) + d1 * Mr ( l , s ) ) / ( d1 + d2 ) ; <nl> + <nl> + motions [ i ] = M ; <nl> + mask [ i ] = 1 ; <nl> + } <nl> + } <nl> + } <nl> + else if ( state = = LEFT_OPEN ) <nl> + { <nl> + if ( mask [ i ] ) state = INIT ; <nl> + } <nl> + } <nl> + } <nl> + <nl> } / / namespace videostab <nl> } / / namespace cv <nl> mmm a / modules / videostab / src / stabilizer . cpp <nl> ppp b / modules / videostab / src / stabilizer . cpp <nl> void TwoPassStabilizer : : runPrePassIfNecessary ( ) <nl> <nl> bool ok = true , ok2 = true ; <nl> <nl> + / / estimate motions <nl> + <nl> while ( ! ( frame = frameSource_ - > nextFrame ( ) ) . empty ( ) ) <nl> { <nl> if ( frameCount_ > 0 ) <nl> void TwoPassStabilizer : : runPrePassIfNecessary ( ) <nl> else log_ - > print ( " x " ) ; <nl> } <nl> <nl> + / / add aux . motions <nl> + <nl> for ( int i = 0 ; i < radius_ ; + + i ) <nl> motions_ . push_back ( Mat : : eye ( 3 , 3 , CV_32F ) ) ; <nl> log_ - > print ( " \ n " ) ; <nl> <nl> - stabilizationMotions_ . resize ( frameCount_ ) ; <nl> + / / stabilize <nl> <nl> + stabilizationMotions_ . resize ( frameCount_ ) ; <nl> motionStabilizer_ - > stabilize ( <nl> frameCount_ , motions_ , make_pair ( 0 , frameCount_ - 1 ) , & stabilizationMotions_ [ 0 ] ) ; <nl> <nl> / / save motions <nl> + <nl> / * ofstream fm ( " log_motions . csv " ) ; <nl> for ( int i = 0 ; i < frameCount_ - 1 ; + + i ) <nl> { <nl> void TwoPassStabilizer : : runPrePassIfNecessary ( ) <nl> < < M ( 2 , 0 ) < < " " < < M ( 2 , 1 ) < < " " < < M ( 2 , 2 ) < < endl ; <nl> } * / <nl> <nl> + / / estimate optimal trim ratio if necessary <nl> + <nl> if ( mustEstTrimRatio_ ) <nl> { <nl> trimRatio_ = 0 ; <nl> mmm a / samples / cpp / videostab . cpp <nl> ppp b / samples / cpp / videostab . cpp <nl> void printHelp ( ) <nl> " Set motion model . The default is affine . \ n " <nl> " - - subset = ( < int_number > | auto ) \ n " <nl> " Number of random samples per one motion hypothesis . The default is auto . \ n " <nl> + " - - thresh = ( < float_number > | auto ) \ n " <nl> + " Maximum error to classify match as inlier . The default is auto . \ n " <nl> " - - outlier - ratio = < float_number > \ n " <nl> " Motion estimation outlier ratio hypothesis . The default is 0 . 5 . \ n " <nl> " - - min - inlier - ratio = < float_number > \ n " <nl> void printHelp ( ) <nl> " estimation model ) . The default is homography . \ n " <nl> " - - ws - subset = ( < int_number > | auto ) \ n " <nl> " Number of random samples per one motion hypothesis . The default is auto . \ n " <nl> + " - - ws - thresh = ( < float_number > | auto ) \ n " <nl> + " Maximum error to classify match as inlier . The default is auto . \ n " <nl> " - - ws - outlier - ratio = < float_number > \ n " <nl> " Motion estimation outlier ratio hypothesis . The default is 0 . 5 . \ n " <nl> " - - ws - min - inlier - ratio = < float_number > \ n " <nl> int main ( int argc , const char * * argv ) <nl> " { 1 | | | | } " <nl> " { m | model | affine | } " <nl> " { | subset | auto | } " <nl> + " { | thresh | auto | } " <nl> " { | outlier - ratio | 0 . 5 | } " <nl> " { | min - inlier - ratio | 0 . 1 | } " <nl> " { | nkps | 1000 | } " <nl> int main ( int argc , const char * * argv ) <nl> " { | ws - period | 30 | } " <nl> " { | ws - model | homography | } " <nl> " { | ws - subset | auto | } " <nl> + " { | ws - thresh | auto | } " <nl> " { | ws - outlier - ratio | 0 . 5 | } " <nl> " { | ws - min - inlier - ratio | 0 . 1 | } " <nl> " { | ws - nkps | 1000 | } " <nl> int main ( int argc , const char * * argv ) <nl> RansacParams ransac = est - > ransacParams ( ) ; <nl> if ( arg ( " ws - subset " ) ! = " auto " ) <nl> ransac . size = argi ( " ws - subset " ) ; <nl> + if ( arg ( " ws - thresh " ) ! = " auto " ) <nl> + ransac . thresh = argi ( " ws - thresh " ) ; <nl> ransac . eps = argf ( " ws - outlier - ratio " ) ; <nl> est - > setRansacParams ( ransac ) ; <nl> est - > setMinInlierRatio ( argf ( " ws - min - inlier - ratio " ) ) ; <nl> int main ( int argc , const char * * argv ) <nl> RansacParams ransac = est - > ransacParams ( ) ; <nl> if ( arg ( " subset " ) ! = " auto " ) <nl> ransac . size = argi ( " subset " ) ; <nl> + if ( arg ( " thresh " ) ! = " auto " ) <nl> + ransac . thresh = argi ( " thresh " ) ; <nl> ransac . eps = argf ( " outlier - ratio " ) ; <nl> est - > setRansacParams ( ransac ) ; <nl> est - > setMinInlierRatio ( argf ( " min - inlier - ratio " ) ) ; <nl>
Refactored videostab module
opencv/opencv
19c30eaa11a5860f9e9b6672aa966c1901b26fdb
2012-04-17T09:12:14Z
mmm a / DEPS <nl> ppp b / DEPS <nl> deps = { <nl> ' v8 / tools / gyp ' : <nl> Var ( ' chromium_url ' ) + ' / external / gyp . git ' + ' @ ' + ' d61a9397e668fa9843c4aa7da9e79460fe590bfb ' , <nl> ' v8 / third_party / depot_tools ' : <nl> - Var ( ' chromium_url ' ) + ' / chromium / tools / depot_tools . git ' + ' @ ' + ' e09b6845cf720ac429578b209267cb6dd1c901da ' , <nl> + Var ( ' chromium_url ' ) + ' / chromium / tools / depot_tools . git ' + ' @ ' + ' d91a468aa50d111c76cc80381f3a443fcc1bd9d1 ' , <nl> ' v8 / third_party / icu ' : <nl> Var ( ' chromium_url ' ) + ' / chromium / deps / icu . git ' + ' @ ' + ' f61e46dbee9d539a32551493e3bcc1dea92f83ec ' , <nl> ' v8 / third_party / instrumented_libraries ' : <nl> Var ( ' chromium_url ' ) + ' / chromium / src / third_party / instrumented_libraries . git ' + ' @ ' + ' 323cf32193caecbf074d1a0cb5b02b905f163e0f ' , <nl> ' v8 / buildtools ' : <nl> - Var ( ' chromium_url ' ) + ' / chromium / buildtools . git ' + ' @ ' + ' 6f4dae280c6a542acacd8db281decc5c0b2a9823 ' , <nl> + Var ( ' chromium_url ' ) + ' / chromium / buildtools . git ' + ' @ ' + ' 5941c1b3df96c1db756a2834343533335c394c4a ' , <nl> ' v8 / base / trace_event / common ' : <nl> Var ( ' chromium_url ' ) + ' / chromium / src / base / trace_event / common . git ' + ' @ ' + ' 211b3ed9d0481b4caddbee1322321b86a483ca1f ' , <nl> ' v8 / third_party / android_ndk ' : { <nl> deps = { <nl> ' condition ' : ' checkout_android ' , <nl> } , <nl> ' v8 / third_party / android_tools ' : { <nl> - ' url ' : Var ( ' chromium_url ' ) + ' / android_tools . git ' + ' @ ' + ' c22a664c39af72dd8f89200220713dcad811300a ' , <nl> + ' url ' : Var ( ' chromium_url ' ) + ' / android_tools . git ' + ' @ ' + ' 3545ab5b9883087a54cb9e5337c32617cb2a443d ' , <nl> ' condition ' : ' checkout_android ' , <nl> } , <nl> ' v8 / third_party / catapult ' : { <nl> - ' url ' : Var ( ' chromium_url ' ) + ' / catapult . git ' + ' @ ' + ' fdacd1639e2adc4631fc1d57f68e4d3715cef5ba ' , <nl> + ' url ' : Var ( ' chromium_url ' ) + ' / catapult . git ' + ' @ ' + ' 2e625dcb82db59c137245a55abc5fae34eceb361 ' , <nl> ' condition ' : ' checkout_android ' , <nl> } , <nl> ' v8 / third_party / colorama / src ' : { <nl> deps = { <nl> ' condition ' : ' checkout_fuchsia ' , <nl> } , <nl> ' v8 / third_party / googletest / src ' : <nl> - Var ( ' chromium_url ' ) + ' / external / github . com / google / googletest . git ' + ' @ ' + ' 9077ec7efe5b652468ab051e93c67589d5cb8f85 ' , <nl> + Var ( ' chromium_url ' ) + ' / external / github . com / google / googletest . git ' + ' @ ' + ' ce468a17c434e4e79724396ee1b51d86bfc8a88b ' , <nl> ' v8 / third_party / jinja2 ' : <nl> Var ( ' chromium_url ' ) + ' / chromium / src / third_party / jinja2 . git ' + ' @ ' + ' 45571de473282bd1d8b63a8dfcb1fd268d0635d2 ' , <nl> ' v8 / third_party / markupsafe ' : <nl> Var ( ' chromium_url ' ) + ' / chromium / src / third_party / markupsafe . git ' + ' @ ' + ' 8f45f5cfa0009d2a70589bcda0349b8cb2b72783 ' , <nl> ' v8 / tools / swarming_client ' : <nl> - Var ( ' chromium_url ' ) + ' / infra / luci / client - py . git ' + ' @ ' + ' 281c390193ec8c02e60279f8dac1b86ac52fa4be ' , <nl> + Var ( ' chromium_url ' ) + ' / infra / luci / client - py . git ' + ' @ ' + ' 9a518d097dca20b7b00ce3bdfc5d418ccc79893a ' , <nl> ' v8 / test / benchmarks / data ' : <nl> Var ( ' chromium_url ' ) + ' / v8 / deps / third_party / benchmarks . git ' + ' @ ' + ' 05d7188267b4560491ff9155c5ee13e207ecd65f ' , <nl> ' v8 / test / mozilla / data ' : <nl> deps = { <nl> ' v8 / test / test262 / harness ' : <nl> Var ( ' chromium_url ' ) + ' / external / github . com / test262 - utils / test262 - harness - py . git ' + ' @ ' + ' 0f2acdd882c84cff43b9d60df7574a1901e2cdcd ' , <nl> ' v8 / tools / clang ' : <nl> - Var ( ' chromium_url ' ) + ' / chromium / src / tools / clang . git ' + ' @ ' + ' 37fc68b9adb4c9062b1a54e5a84e0d3bf2406e57 ' , <nl> + Var ( ' chromium_url ' ) + ' / chromium / src / tools / clang . git ' + ' @ ' + ' c6e5ea26ee09d51be2f816325d59f98b8477b42f ' , <nl> ' v8 / tools / luci - go ' : <nl> - Var ( ' chromium_url ' ) + ' / chromium / src / tools / luci - go . git ' + ' @ ' + ' 4cc6820b99a9371bba031a4caec72df01c4b43c4 ' , <nl> + Var ( ' chromium_url ' ) + ' / chromium / src / tools / luci - go . git ' + ' @ ' + ' 0e27f885f2fc5b81e2df6105b8285f8151e2a6fe ' , <nl> ' v8 / test / wasm - js ' : <nl> Var ( ' chromium_url ' ) + ' / external / github . com / WebAssembly / spec . git ' + ' @ ' + ' 27d63f22e72395248d314520b3ad5b1e0943fc10 ' , <nl> } <nl>
Update V8 DEPS .
v8/v8
a47c946d041f0e35ea8e21e4e1120cfb0fcb7644
2018-06-25T10:51:45Z
mmm a / modules / core / include / opencv2 / core / operations . hpp <nl> ppp b / modules / core / include / opencv2 / core / operations . hpp <nl> <nl> # include < cstdio > <nl> <nl> # if defined ( __GNUC__ ) | | defined ( __clang__ ) / / at least GCC 3 . 1 + , clang 3 . 5 + <nl> - # define CV_FORMAT_PRINTF ( string_idx , first_to_check ) __attribute__ ( ( format ( printf , string_idx , first_to_check ) ) ) <nl> + # if defined ( __MINGW_PRINTF_FORMAT ) / / https : / / sourceforge . net / p / mingw - w64 / wiki2 / gnu % 20printf / . <nl> + # define CV_FORMAT_PRINTF ( string_idx , first_to_check ) __attribute__ ( ( format ( __MINGW_PRINTF_FORMAT , string_idx , first_to_check ) ) ) <nl> + # else <nl> + # define CV_FORMAT_PRINTF ( string_idx , first_to_check ) __attribute__ ( ( format ( printf , string_idx , first_to_check ) ) ) <nl> + # endif <nl> # else <nl> # define CV_FORMAT_PRINTF ( A , B ) <nl> # endif <nl> mmm a / modules / core / include / opencv2 / core / private . hpp <nl> ppp b / modules / core / include / opencv2 / core / private . hpp <nl> Passed subdirectories are used in LIFO order . <nl> * / <nl> CV_EXPORTS void addDataSearchSubDirectory ( const cv : : String & subdir ) ; <nl> <nl> - / * * @ brief Return location of OpenCV libraries or current executable <nl> + / * * @ brief Retrieve location of OpenCV libraries or current executable <nl> * / <nl> - CV_EXPORTS std : : string getBinLocation ( ) ; <nl> + CV_EXPORTS bool getBinLocation ( std : : string & dst ) ; <nl> + <nl> + # if defined ( _WIN32 ) <nl> + / * * @ brief Retrieve location of OpenCV libraries or current executable <nl> + <nl> + @ note WIN32 only <nl> + * / <nl> + CV_EXPORTS bool getBinLocation ( std : : wstring & dst ) ; <nl> + # endif <nl> <nl> / / ! @ } <nl> <nl> mmm a / modules / core / include / opencv2 / core / utils / filesystem . hpp <nl> ppp b / modules / core / include / opencv2 / core / utils / filesystem . hpp <nl> CV_EXPORTS cv : : String join ( const cv : : String & base , const cv : : String & path ) ; <nl> <nl> / * * Get parent directory * / <nl> CV_EXPORTS cv : : String getParent ( const cv : : String & path ) ; <nl> + CV_EXPORTS std : : wstring getParent ( const std : : wstring & path ) ; <nl> <nl> / * * <nl> * Generate a list of all files that match the globbing pattern . <nl> mmm a / modules / core / src / utils / datafile . cpp <nl> ppp b / modules / core / src / utils / datafile . cpp <nl> static cv : : String getModuleLocation ( const void * addr ) <nl> return cv : : String ( ) ; <nl> } <nl> <nl> - std : : string getBinLocation ( ) <nl> + bool getBinLocation ( std : : string & dst ) <nl> { <nl> - return getModuleLocation ( ( void * ) getModuleLocation ) ; / / use code addr , doesn ' t work with static linkage ! <nl> + dst = getModuleLocation ( ( void * ) getModuleLocation ) ; / / using code address , doesn ' t work with static linkage ! <nl> + return ! dst . empty ( ) ; <nl> } <nl> <nl> + # ifdef _WIN32 <nl> + bool getBinLocation ( std : : wstring & dst ) <nl> + { <nl> + void * addr = ( void * ) getModuleLocation ; / / using code address , doesn ' t work with static linkage ! <nl> + HMODULE m = 0 ; <nl> + # if _WIN32_WINNT > = 0x0501 <nl> + : : GetModuleHandleEx ( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT , <nl> + reinterpret_cast < LPCTSTR > ( addr ) , <nl> + & m ) ; <nl> + # endif <nl> + if ( m ) <nl> + { <nl> + wchar_t path [ 4096 ] ; <nl> + const size_t path_size = sizeof ( path ) / sizeof ( * path ) ; <nl> + size_t sz = GetModuleFileNameW ( m , path , path_size ) ; <nl> + if ( sz > 0 & & sz < path_size ) <nl> + { <nl> + path [ sz ] = ' \ 0 ' ; <nl> + dst . assign ( path , sz ) ; <nl> + return true ; <nl> + } <nl> + } <nl> + return false ; <nl> + } <nl> + # endif <nl> + <nl> cv : : String findDataFile ( const cv : : String & relative_path , <nl> const char * configuration_parameter , <nl> const std : : vector < String > * search_paths , <nl> cv : : String findDataFile ( const cv : : String & relative_path , <nl> } <nl> } <nl> <nl> - cv : : String module_path = getBinLocation ( ) ; <nl> - CV_LOG_DEBUG ( NULL , " Detected module path : ' " < < module_path < < ' \ ' ' ) ; <nl> + cv : : String module_path ; <nl> + if ( getBinLocation ( module_path ) ) <nl> + { <nl> + CV_LOG_DEBUG ( NULL , " Detected module path : ' " < < module_path < < ' \ ' ' ) ; <nl> + } <nl> + else <nl> + { <nl> + CV_LOG_INFO ( NULL , " Can ' t detect module binaries location " ) ; <nl> + } <nl> <nl> if ( ! has_tested_build_directory & & <nl> ( isSubDirectory ( build_dir , module_path ) | | isSubDirectory ( utils : : fs : : canonical ( build_dir ) , utils : : fs : : canonical ( module_path ) ) ) <nl> mmm a / modules / core / src / utils / filesystem . cpp <nl> ppp b / modules / core / src / utils / filesystem . cpp <nl> CV_EXPORTS cv : : String getParent ( const cv : : String & path ) <nl> return std : : string ( path , 0 , loc ) ; <nl> } <nl> <nl> + CV_EXPORTS std : : wstring getParent ( const std : : wstring & path ) <nl> + { <nl> + std : : wstring : : size_type loc = path . find_last_of ( L " / \ \ " ) ; <nl> + if ( loc = = std : : wstring : : npos ) <nl> + return std : : wstring ( ) ; <nl> + return std : : wstring ( path , 0 , loc ) ; <nl> + } <nl> + <nl> # if OPENCV_HAVE_FILESYSTEM_SUPPORT <nl> <nl> cv : : String canonical ( const cv : : String & path ) <nl> mmm a / modules / videoio / CMakeLists . txt <nl> ppp b / modules / videoio / CMakeLists . txt <nl> if ( TARGET ocv . 3rdparty . ximea ) <nl> endif ( ) <nl> <nl> if ( TARGET ocv . 3rdparty . ffmpeg ) <nl> - if ( " ffmpeg " IN_LIST VIDEOIO_PLUGIN_LIST ) <nl> + if ( HAVE_FFMPEG_WRAPPER ) <nl> + list ( APPEND tgts ocv . 3rdparty . ffmpeg ) <nl> + elseif ( " ffmpeg " IN_LIST VIDEOIO_PLUGIN_LIST ) <nl> ocv_create_builtin_videoio_plugin ( " opencv_videoio_ffmpeg " ocv . 3rdparty . ffmpeg " cap_ffmpeg . cpp " ) <nl> else ( ) <nl> list ( APPEND videoio_hdrs $ { CMAKE_CURRENT_LIST_DIR } / src / cap_ffmpeg_impl . hpp ) <nl> ocv_target_link_libraries ( $ { the_module } LINK_PRIVATE $ { tgts } ) <nl> # copy FFmpeg dll to the output folder <nl> if ( WIN32 AND HAVE_FFMPEG_WRAPPER ) <nl> if ( MSVC64 OR MINGW64 ) <nl> - set ( FFMPEG_SUFFIX _64 ) <nl> + set ( FFMPEG_SUFFIX " _64 " ) <nl> endif ( ) <nl> set ( ffmpeg_dir " $ { OpenCV_BINARY_DIR } / 3rdparty / ffmpeg " ) <nl> set ( ffmpeg_bare_name " opencv_ffmpeg $ { FFMPEG_SUFFIX } . dll " ) <nl> mmm a / modules / videoio / cmake / detect_ffmpeg . cmake <nl> ppp b / modules / videoio / cmake / detect_ffmpeg . cmake <nl> endif ( ) <nl> <nl> # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> <nl> - if ( HAVE_FFMPEG ) <nl> - set ( defs " HAVE_FFMPEG " ) <nl> - if ( HAVE_FFMPEG_WRAPPER ) <nl> - list ( APPEND defs " HAVE_FFMPEG_WRAPPER " ) <nl> - endif ( ) <nl> - ocv_add_external_target ( ffmpeg " $ { FFMPEG_INCLUDE_DIRS } " " $ { FFMPEG_LIBRARIES } " " $ { defs } " ) <nl> + if ( HAVE_FFMPEG_WRAPPER ) <nl> + ocv_add_external_target ( ffmpeg " " " " " HAVE_FFMPEG_WRAPPER " ) <nl> + elseif ( HAVE_FFMPEG ) <nl> + ocv_add_external_target ( ffmpeg " $ { FFMPEG_INCLUDE_DIRS } " " $ { FFMPEG_LIBRARIES } " " HAVE_FFMPEG " ) <nl> endif ( ) <nl> <nl> set ( HAVE_FFMPEG $ { HAVE_FFMPEG } PARENT_SCOPE ) <nl> mmm a / modules / videoio / cmake / plugin . cmake <nl> ppp b / modules / videoio / cmake / plugin . cmake <nl> function ( ocv_create_builtin_videoio_plugin name target ) <nl> ocv_target_include_directories ( $ { name } PRIVATE " $ { OPENCV_MODULE_ $ { mod } _LOCATION } / include " ) <nl> endforeach ( ) <nl> <nl> + if ( WIN32 ) <nl> + set ( OPENCV_PLUGIN_VERSION " $ { OPENCV_DLLVERSION } " CACHE STRING " " ) <nl> + if ( CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 8 ) <nl> + set ( OPENCV_PLUGIN_ARCH " _64 " CACHE STRING " " ) <nl> + else ( ) <nl> + set ( OPENCV_PLUGIN_ARCH " " CACHE STRING " " ) <nl> + endif ( ) <nl> + else ( ) <nl> + set ( OPENCV_PLUGIN_VERSION " " CACHE STRING " " ) <nl> + set ( OPENCV_PLUGIN_ARCH " " CACHE STRING " " ) <nl> + endif ( ) <nl> + <nl> set_target_properties ( $ { name } PROPERTIES <nl> CXX_STANDARD 11 <nl> CXX_VISIBILITY_PRESET hidden <nl> + OUTPUT_NAME " $ { name } $ { OPENCV_PLUGIN_VERSION } $ { OPENCV_PLUGIN_ARCH } " <nl> ) <nl> <nl> if ( WIN32 ) <nl> mmm a / modules / videoio / cmake / plugin_standalone . cmake <nl> ppp b / modules / videoio / cmake / plugin_standalone . cmake <nl> function ( ocv_create_videoio_plugin default_name target target_desc videoio_src_f <nl> message ( FATAL_ERROR " $ { target_desc } was not found ! " ) <nl> endif ( ) <nl> <nl> - set ( modules_ROOT " $ { CMAKE_CURRENT_LIST_DIR } / . . / . . / . . " ) <nl> + get_filename_component ( modules_ROOT " $ { CMAKE_CURRENT_LIST_DIR } / . . / . . / . . " ABSOLUTE ) <nl> set ( videoio_ROOT " $ { modules_ROOT } / videoio " ) <nl> set ( core_ROOT " $ { modules_ROOT } / core " ) <nl> set ( imgproc_ROOT " $ { modules_ROOT } / imgproc " ) <nl> function ( ocv_create_videoio_plugin default_name target target_desc videoio_src_f <nl> ) <nl> target_compile_definitions ( $ { OPENCV_PLUGIN_NAME } PRIVATE BUILD_PLUGIN ) <nl> <nl> - # Fixes for build <nl> - target_compile_definitions ( $ { OPENCV_PLUGIN_NAME } PRIVATE __OPENCV_BUILD ) <nl> - file ( WRITE " $ { CMAKE_CURRENT_BINARY_DIR } / cvconfig . h " " # pragma once " ) <nl> - file ( WRITE " $ { CMAKE_CURRENT_BINARY_DIR } / cv_cpu_config . h " " # pragma once " ) <nl> - file ( WRITE " $ { CMAKE_CURRENT_BINARY_DIR } / opencv2 / opencv_modules . hpp " " # pragma once " ) <nl> - <nl> target_link_libraries ( $ { OPENCV_PLUGIN_NAME } PRIVATE $ { target } ) <nl> set_target_properties ( $ { OPENCV_PLUGIN_NAME } PROPERTIES <nl> CXX_STANDARD 11 <nl> CXX_VISIBILITY_PRESET hidden <nl> ) <nl> <nl> + if ( DEFINED OPENCV_PLUGIN_MODULE_PREFIX ) <nl> + set_target_properties ( $ { OPENCV_PLUGIN_NAME } PROPERTIES PREFIX " $ { OPENCV_PLUGIN_MODULE_PREFIX } " ) <nl> + endif ( ) <nl> + <nl> # Hack for Windows <nl> if ( WIN32 ) <nl> find_package ( OpenCV REQUIRED core imgproc videoio ) <nl> - target_link_libraries ( $ { OPENCV_PLUGIN_NAME } $ { OpenCV_LIBS } ) <nl> + target_link_libraries ( $ { OPENCV_PLUGIN_NAME } PRIVATE $ { OpenCV_LIBS } ) <nl> endif ( ) <nl> <nl> if ( OPENCV_PLUGIN_DESTINATION ) <nl> function ( ocv_create_videoio_plugin default_name target target_desc videoio_src_f <nl> message ( STATUS " Output destination : $ { OPENCV_PLUGIN_DESTINATION } " ) <nl> endif ( ) <nl> <nl> + install ( TARGETS $ { OPENCV_PLUGIN_NAME } LIBRARY DESTINATION . COMPONENT plugins ) <nl> + <nl> message ( STATUS " Library name : $ { OPENCV_PLUGIN_NAME } " ) <nl> <nl> endfunction ( ) <nl> mmm a / modules / videoio / src / backend_plugin . cpp <nl> ppp b / modules / videoio / src / backend_plugin . cpp <nl> namespace cv { namespace impl { <nl> <nl> # if defined ( _WIN32 ) <nl> typedef HMODULE LibHandle_t ; <nl> - # elif defined ( __linux__ ) | | defined ( __APPLE__ ) | | defined ( __OpenBSD__ ) | | defined ( __FreeBSD__ ) <nl> + typedef wchar_t FileSystemChar_t ; <nl> + typedef std : : wstring FileSystemPath_t ; <nl> + <nl> + static <nl> + FileSystemPath_t toFileSystemPath ( const std : : string & p ) <nl> + { <nl> + FileSystemPath_t result ; <nl> + result . resize ( p . size ( ) ) ; <nl> + for ( size_t i = 0 ; i < p . size ( ) ; i + + ) <nl> + result [ i ] = ( wchar_t ) p [ i ] ; <nl> + return result ; <nl> + } <nl> + static <nl> + std : : string toPrintablePath ( const FileSystemPath_t & p ) <nl> + { <nl> + std : : string result ; <nl> + result . resize ( p . size ( ) ) ; <nl> + for ( size_t i = 0 ; i < p . size ( ) ; i + + ) <nl> + { <nl> + wchar_t ch = p [ i ] ; <nl> + if ( ( int ) ch > = ' ' & & ( int ) ch < 128 ) <nl> + result [ i ] = ( char ) ch ; <nl> + else <nl> + result [ i ] = ' ? ' ; <nl> + } <nl> + return result ; <nl> + } <nl> + # else / / ! _WIN32 <nl> typedef void * LibHandle_t ; <nl> + typedef char FileSystemChar_t ; <nl> + typedef std : : string FileSystemPath_t ; <nl> + <nl> + static inline FileSystemPath_t toFileSystemPath ( const std : : string & p ) { return p ; } <nl> + static inline std : : string toPrintablePath ( const FileSystemPath_t & p ) { return p ; } <nl> # endif <nl> <nl> + <nl> static Mutex & getInitializationMutex ( ) <nl> { <nl> static Mutex initializationMutex ; <nl> void * getSymbol_ ( LibHandle_t h , const char * symbolName ) <nl> } <nl> <nl> static inline <nl> - LibHandle_t libraryLoad_ ( const char * filename ) <nl> + LibHandle_t libraryLoad_ ( const FileSystemPath_t & filename ) <nl> { <nl> # if defined ( _WIN32 ) <nl> - return LoadLibraryA ( filename ) ; <nl> + # ifdef WINRT <nl> + return LoadPackagedLibrary ( filename . c_str ( ) , 0 ) ; <nl> + # else <nl> + return LoadLibraryW ( filename . c_str ( ) ) ; <nl> + # endif <nl> # elif defined ( __linux__ ) | | defined ( __APPLE__ ) | | defined ( __OpenBSD__ ) | | defined ( __FreeBSD__ ) <nl> - return dlopen ( filename , RTLD_LAZY ) ; <nl> + return dlopen ( filename . c_str ( ) , RTLD_LAZY ) ; <nl> # endif <nl> } <nl> <nl> static inline <nl> std : : string libraryPrefix ( ) <nl> { <nl> # if defined ( _WIN32 ) <nl> - return string ( ) ; <nl> + return " " ; <nl> # else <nl> return " lib " ; <nl> # endif <nl> static inline <nl> std : : string librarySuffix ( ) <nl> { <nl> # if defined ( _WIN32 ) <nl> - return " . dll " ; <nl> - # elif defined ( __APPLE__ ) <nl> - return " . dylib " ; <nl> + const char * suffix = " " <nl> + CVAUX_STR ( CV_MAJOR_VERSION ) CVAUX_STR ( CV_MINOR_VERSION ) CVAUX_STR ( CV_SUBMINOR_VERSION ) <nl> + # if ( defined _MSC_VER & & defined _M_X64 ) | | ( defined __GNUC__ & & defined __x86_64__ ) <nl> + " _64 " <nl> + # endif <nl> + " . dll " ; <nl> + return suffix ; <nl> # else <nl> return " . so " ; <nl> # endif <nl> class DynamicLib <nl> { <nl> private : <nl> LibHandle_t handle ; <nl> - const std : : string fname ; <nl> + const FileSystemPath_t fname ; <nl> <nl> public : <nl> - DynamicLib ( const std : : string & filename ) <nl> + DynamicLib ( const FileSystemPath_t & filename ) <nl> : handle ( 0 ) , fname ( filename ) <nl> { <nl> libraryLoad ( filename ) ; <nl> class DynamicLib <nl> } <nl> void * res = getSymbol_ ( handle , symbolName ) ; <nl> if ( ! res ) <nl> - CV_LOG_ERROR ( NULL , " No symbol ' " < < symbolName < < " ' in " < < fname ) ; <nl> + CV_LOG_ERROR ( NULL , " No symbol ' " < < symbolName < < " ' in " < < toPrintablePath ( fname ) ) ; <nl> return res ; <nl> } <nl> - const std : : string & getName ( ) const { return fname ; } <nl> + const std : : string getName ( ) const { return toPrintablePath ( fname ) ; } <nl> private : <nl> - void libraryLoad ( const std : : string & filename ) <nl> + void libraryLoad ( const FileSystemPath_t & filename ) <nl> { <nl> - handle = libraryLoad_ ( filename . c_str ( ) ) ; <nl> - CV_LOG_INFO ( NULL , " load " < < filename < < " = > " < < ( handle ? " OK " : " FAILED " ) ) ; <nl> + handle = libraryLoad_ ( filename ) ; <nl> + CV_LOG_INFO ( NULL , " load " < < toPrintablePath ( filename ) < < " = > " < < ( handle ? " OK " : " FAILED " ) ) ; <nl> } <nl> void libraryRelease ( ) <nl> { <nl> - CV_LOG_INFO ( NULL , " unload " < < fname ) ; <nl> if ( handle ) <nl> { <nl> + CV_LOG_INFO ( NULL , " unload " < < toPrintablePath ( fname ) ) ; <nl> libraryRelease_ ( handle ) ; <nl> handle = 0 ; <nl> } <nl> class PluginBackendFactory : public IBackendFactory <nl> } ; <nl> <nl> static <nl> - std : : vector < string > getPluginCandidates ( const std : : string & baseName ) <nl> + std : : vector < FileSystemPath_t > getPluginCandidates ( const std : : string & baseName ) <nl> { <nl> using namespace cv : : utils ; <nl> using namespace cv : : utils : : fs ; <nl> + const string baseName_l = toLowerCase ( baseName ) ; <nl> + const string baseName_u = toUpperCase ( baseName ) ; <nl> + const FileSystemPath_t baseName_l_fs = toFileSystemPath ( baseName_l ) ; <nl> + vector < FileSystemPath_t > paths ; <nl> + const vector < string > paths_ = getConfigurationParameterPaths ( " OPENCV_VIDEOIO_PLUGIN_PATH " , vector < string > ( ) ) ; <nl> + if ( paths_ . size ( ) ! = 0 ) <nl> + { <nl> + for ( size_t i = 0 ; i < paths_ . size ( ) ; i + + ) <nl> + { <nl> + paths . push_back ( toFileSystemPath ( paths_ [ i ] ) ) ; <nl> + } <nl> + } <nl> + else <nl> + { <nl> + FileSystemPath_t binaryLocation ; <nl> + if ( getBinLocation ( binaryLocation ) ) <nl> + { <nl> + binaryLocation = getParent ( binaryLocation ) ; <nl> # ifndef CV_VIDEOIO_PLUGIN_SUBDIRECTORY <nl> - # define CV_VIDEOIO_PLUGIN_SUBDIRECTORY_STR " " <nl> + paths . push_back ( binaryLocation ) ; <nl> # else <nl> - # define CV_VIDEOIO_PLUGIN_SUBDIRECTORY_STR CVAUX_STR ( CV_VIDEOIO_PLUGIN_SUBDIRECTORY ) <nl> + paths . push_back ( binaryLocation + toFileSystemPath ( " / " ) + toFileSystemPath ( CV_VIDEOIO_PLUGIN_SUBDIRECTORY_STR ) ) ; <nl> # endif <nl> - const vector < string > default_paths = { utils : : fs : : join ( getParent ( getBinLocation ( ) ) , CV_VIDEOIO_PLUGIN_SUBDIRECTORY_STR ) } ; <nl> - const vector < string > paths = getConfigurationParameterPaths ( " OPENCV_VIDEOIO_PLUGIN_PATH " , default_paths ) ; <nl> - const string baseName_l = toLowerCase ( baseName ) ; <nl> - const string baseName_u = toUpperCase ( baseName ) ; <nl> + } <nl> + } <nl> const string default_expr = libraryPrefix ( ) + " opencv_videoio_ " + baseName_l + " * " + librarySuffix ( ) ; <nl> - const string expr = getConfigurationParameterString ( ( std : : string ( " OPENCV_VIDEOIO_PLUGIN_ " ) + baseName_u ) . c_str ( ) , default_expr . c_str ( ) ) ; <nl> - CV_LOG_INFO ( NULL , " VideoIO pluigin ( " < < baseName < < " ) : glob is ' " < < expr < < " ' , " < < paths . size ( ) < < " location ( s ) " ) ; <nl> - vector < string > results ; <nl> - for ( const string & path : paths ) <nl> + const string plugin_expr = getConfigurationParameterString ( ( std : : string ( " OPENCV_VIDEOIO_PLUGIN_ " ) + baseName_u ) . c_str ( ) , default_expr . c_str ( ) ) ; <nl> + vector < FileSystemPath_t > results ; <nl> + # ifdef _WIN32 <nl> + FileSystemPath_t moduleName = toFileSystemPath ( libraryPrefix ( ) + " opencv_videoio_ " + baseName_l + librarySuffix ( ) ) ; <nl> + # ifndef WINRT <nl> + if ( baseName_u = = " FFMPEG " ) / / backward compatibility <nl> + { <nl> + const wchar_t * ffmpeg_env_path = _wgetenv ( L " OPENCV_FFMPEG_DLL_DIR " ) ; <nl> + if ( ffmpeg_env_path ) <nl> + { <nl> + results . push_back ( FileSystemPath_t ( ffmpeg_env_path ) + L " \ \ " + moduleName ) ; <nl> + } <nl> + } <nl> + # endif <nl> + if ( plugin_expr ! = default_expr ) <nl> + { <nl> + moduleName = toFileSystemPath ( plugin_expr ) ; <nl> + results . push_back ( moduleName ) ; <nl> + } <nl> + for ( const FileSystemPath_t & path : paths ) <nl> + { <nl> + results . push_back ( path + L " \ \ " + moduleName ) ; <nl> + } <nl> + results . push_back ( moduleName ) ; <nl> + # else <nl> + CV_LOG_INFO ( NULL , " VideoIO pluigin ( " < < baseName < < " ) : glob is ' " < < plugin_expr < < " ' , " < < paths . size ( ) < < " location ( s ) " ) ; <nl> + for ( const string & path : paths ) <nl> { <nl> if ( path . empty ( ) ) <nl> continue ; <nl> vector < string > candidates ; <nl> - cv : : glob ( utils : : fs : : join ( path , expr ) , candidates ) ; <nl> + cv : : glob ( utils : : fs : : join ( path , plugin_expr ) , candidates ) ; <nl> CV_LOG_INFO ( NULL , " - " < < path < < " : " < < candidates . size ( ) ) ; <nl> copy ( candidates . begin ( ) , candidates . end ( ) , back_inserter ( results ) ) ; <nl> } <nl> + # endif <nl> CV_LOG_INFO ( NULL , " Found " < < results . size ( ) < < " plugin ( s ) for " < < baseName ) ; <nl> return results ; <nl> } <nl> <nl> void PluginBackendFactory : : loadPlugin ( ) <nl> { <nl> - for ( const std : : string & plugin : getPluginCandidates ( baseName_ ) ) <nl> + for ( const FileSystemPath_t & plugin : getPluginCandidates ( baseName_ ) ) <nl> { <nl> Ptr < DynamicLib > lib = makePtr < DynamicLib > ( plugin ) ; <nl> if ( ! lib - > isLoaded ( ) ) <nl> void PluginBackendFactory : : loadPlugin ( ) <nl> } <nl> catch ( . . . ) <nl> { <nl> - CV_LOG_INFO ( NULL , " Video I / O : exception during plugin initialization : " < < plugin < < " . SKIP " ) ; <nl> + CV_LOG_WARNING ( NULL , " Video I / O : exception during plugin initialization : " < < toPrintablePath ( plugin ) < < " . SKIP " ) ; <nl> } <nl> } <nl> } <nl> mmm a / modules / videoio / src / cap_ffmpeg . cpp <nl> ppp b / modules / videoio / src / cap_ffmpeg . cpp <nl> <nl> <nl> # include " precomp . hpp " <nl> <nl> - # if defined ( HAVE_FFMPEG ) <nl> + # if ! defined ( HAVE_FFMPEG ) <nl> + # error " Build configuration error " <nl> + # endif <nl> <nl> # include < string > <nl> <nl> - # if ! defined ( HAVE_FFMPEG_WRAPPER ) <nl> # include " cap_ffmpeg_impl . hpp " <nl> <nl> # define icvCreateFileCapture_FFMPEG_p cvCreateFileCapture_FFMPEG <nl> <nl> # define icvReleaseVideoWriter_FFMPEG_p cvReleaseVideoWriter_FFMPEG <nl> # define icvWriteFrame_FFMPEG_p cvWriteFrame_FFMPEG <nl> <nl> - # else <nl> - <nl> - # include " cap_ffmpeg_api . hpp " <nl> - <nl> - namespace cv { namespace { <nl> - <nl> - static CvCreateFileCapture_Plugin icvCreateFileCapture_FFMPEG_p = 0 ; <nl> - static CvReleaseCapture_Plugin icvReleaseCapture_FFMPEG_p = 0 ; <nl> - static CvGrabFrame_Plugin icvGrabFrame_FFMPEG_p = 0 ; <nl> - static CvRetrieveFrame_Plugin icvRetrieveFrame_FFMPEG_p = 0 ; <nl> - static CvSetCaptureProperty_Plugin icvSetCaptureProperty_FFMPEG_p = 0 ; <nl> - static CvGetCaptureProperty_Plugin icvGetCaptureProperty_FFMPEG_p = 0 ; <nl> - static CvCreateVideoWriter_Plugin icvCreateVideoWriter_FFMPEG_p = 0 ; <nl> - static CvReleaseVideoWriter_Plugin icvReleaseVideoWriter_FFMPEG_p = 0 ; <nl> - static CvWriteFrame_Plugin icvWriteFrame_FFMPEG_p = 0 ; <nl> - <nl> - static cv : : Mutex _icvInitFFMPEG_mutex ; <nl> - <nl> - # if defined _WIN32 <nl> - static const HMODULE cv_GetCurrentModule ( ) <nl> - { <nl> - HMODULE h = 0 ; <nl> - # if _WIN32_WINNT > = 0x0501 <nl> - : : GetModuleHandleEx ( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT , <nl> - reinterpret_cast < LPCTSTR > ( cv_GetCurrentModule ) , <nl> - & h ) ; <nl> - # endif <nl> - return h ; <nl> - } <nl> - # endif <nl> - <nl> - class icvInitFFMPEG <nl> - { <nl> - public : <nl> - static void Init ( ) <nl> - { <nl> - cv : : AutoLock al ( _icvInitFFMPEG_mutex ) ; <nl> - static icvInitFFMPEG init ; <nl> - } <nl> - <nl> - private : <nl> - # if defined _WIN32 <nl> - HMODULE icvFFOpenCV ; <nl> - <nl> - ~ icvInitFFMPEG ( ) <nl> - { <nl> - if ( icvFFOpenCV ) <nl> - { <nl> - FreeLibrary ( icvFFOpenCV ) ; <nl> - icvFFOpenCV = 0 ; <nl> - } <nl> - } <nl> - # endif <nl> - <nl> - icvInitFFMPEG ( ) <nl> - { <nl> - # if defined _WIN32 <nl> - const wchar_t * module_name_ = L " opencv_ffmpeg " <nl> - CVAUX_STRW ( CV_MAJOR_VERSION ) CVAUX_STRW ( CV_MINOR_VERSION ) CVAUX_STRW ( CV_SUBMINOR_VERSION ) <nl> - # if ( defined _MSC_VER & & defined _M_X64 ) | | ( defined __GNUC__ & & defined __x86_64__ ) <nl> - L " _64 " <nl> - # endif <nl> - L " . dll " ; <nl> - # ifdef WINRT <nl> - icvFFOpenCV = LoadPackagedLibrary ( module_name_ , 0 ) ; <nl> - # else <nl> - const std : : wstring module_name ( module_name_ ) ; <nl> - <nl> - const wchar_t * ffmpeg_env_path = _wgetenv ( L " OPENCV_FFMPEG_DLL_DIR " ) ; <nl> - std : : wstring module_path = <nl> - ffmpeg_env_path <nl> - ? ( ( std : : wstring ( ffmpeg_env_path ) + L " \ \ " ) + module_name ) <nl> - : module_name ; <nl> - <nl> - icvFFOpenCV = LoadLibraryW ( module_path . c_str ( ) ) ; <nl> - if ( ! icvFFOpenCV & & ! ffmpeg_env_path ) <nl> - { <nl> - HMODULE m = cv_GetCurrentModule ( ) ; <nl> - if ( m ) <nl> - { <nl> - wchar_t path [ MAX_PATH ] ; <nl> - const size_t path_size = sizeof ( path ) / sizeof ( * path ) ; <nl> - size_t sz = GetModuleFileNameW ( m , path , path_size ) ; <nl> - / * Don ' t handle paths longer than MAX_PATH until that becomes a real issue * / <nl> - if ( sz > 0 & & sz < path_size ) <nl> - { <nl> - wchar_t * s = wcsrchr ( path , L ' \ \ ' ) ; <nl> - if ( s ) <nl> - { <nl> - s [ 0 ] = 0 ; <nl> - module_path = ( std : : wstring ( path ) + L " \ \ " ) + module_name ; <nl> - icvFFOpenCV = LoadLibraryW ( module_path . c_str ( ) ) ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - # endif <nl> - <nl> - if ( icvFFOpenCV ) <nl> - { <nl> - icvCreateFileCapture_FFMPEG_p = <nl> - ( CvCreateFileCapture_Plugin ) GetProcAddress ( icvFFOpenCV , " cvCreateFileCapture_FFMPEG " ) ; <nl> - icvReleaseCapture_FFMPEG_p = <nl> - ( CvReleaseCapture_Plugin ) GetProcAddress ( icvFFOpenCV , " cvReleaseCapture_FFMPEG " ) ; <nl> - icvGrabFrame_FFMPEG_p = <nl> - ( CvGrabFrame_Plugin ) GetProcAddress ( icvFFOpenCV , " cvGrabFrame_FFMPEG " ) ; <nl> - icvRetrieveFrame_FFMPEG_p = <nl> - ( CvRetrieveFrame_Plugin ) GetProcAddress ( icvFFOpenCV , " cvRetrieveFrame_FFMPEG " ) ; <nl> - icvSetCaptureProperty_FFMPEG_p = <nl> - ( CvSetCaptureProperty_Plugin ) GetProcAddress ( icvFFOpenCV , " cvSetCaptureProperty_FFMPEG " ) ; <nl> - icvGetCaptureProperty_FFMPEG_p = <nl> - ( CvGetCaptureProperty_Plugin ) GetProcAddress ( icvFFOpenCV , " cvGetCaptureProperty_FFMPEG " ) ; <nl> - icvCreateVideoWriter_FFMPEG_p = <nl> - ( CvCreateVideoWriter_Plugin ) GetProcAddress ( icvFFOpenCV , " cvCreateVideoWriter_FFMPEG " ) ; <nl> - icvReleaseVideoWriter_FFMPEG_p = <nl> - ( CvReleaseVideoWriter_Plugin ) GetProcAddress ( icvFFOpenCV , " cvReleaseVideoWriter_FFMPEG " ) ; <nl> - icvWriteFrame_FFMPEG_p = <nl> - ( CvWriteFrame_Plugin ) GetProcAddress ( icvFFOpenCV , " cvWriteFrame_FFMPEG " ) ; <nl> - # endif / / _WIN32 <nl> - # if 0 <nl> - if ( icvCreateFileCapture_FFMPEG_p ! = 0 & & <nl> - icvReleaseCapture_FFMPEG_p ! = 0 & & <nl> - icvGrabFrame_FFMPEG_p ! = 0 & & <nl> - icvRetrieveFrame_FFMPEG_p ! = 0 & & <nl> - icvSetCaptureProperty_FFMPEG_p ! = 0 & & <nl> - icvGetCaptureProperty_FFMPEG_p ! = 0 & & <nl> - icvCreateVideoWriter_FFMPEG_p ! = 0 & & <nl> - icvReleaseVideoWriter_FFMPEG_p ! = 0 & & <nl> - icvWriteFrame_FFMPEG_p ! = 0 ) <nl> - { <nl> - printf ( " Successfully initialized ffmpeg plugin ! \ n " ) ; <nl> - } <nl> - else <nl> - { <nl> - printf ( " Failed to load FFMPEG plugin : module handle = % p \ n " , icvFFOpenCV ) ; <nl> - } <nl> - # endif <nl> - } <nl> - } <nl> - } ; <nl> - <nl> - <nl> - } } / / namespace <nl> - # endif / / HAVE_FFMPEG_WRAPPER <nl> - <nl> - <nl> <nl> namespace cv { <nl> namespace { <nl> class CvCapture_FFMPEG_proxy CV_FINAL : public cv : : IVideoCapture <nl> } <nl> virtual void close ( ) <nl> { <nl> - if ( ffmpegCapture <nl> - # if defined ( HAVE_FFMPEG_WRAPPER ) <nl> - & & icvReleaseCapture_FFMPEG_p <nl> - # endif <nl> - ) <nl> + if ( ffmpegCapture ) <nl> icvReleaseCapture_FFMPEG_p ( & ffmpegCapture ) ; <nl> CV_Assert ( ffmpegCapture = = 0 ) ; <nl> ffmpegCapture = 0 ; <nl> class CvCapture_FFMPEG_proxy CV_FINAL : public cv : : IVideoCapture <nl> <nl> cv : : Ptr < cv : : IVideoCapture > cvCreateFileCapture_FFMPEG_proxy ( const std : : string & filename ) <nl> { <nl> - # if defined ( HAVE_FFMPEG_WRAPPER ) <nl> - icvInitFFMPEG : : Init ( ) ; <nl> - if ( ! icvCreateFileCapture_FFMPEG_p ) <nl> - return cv : : Ptr < cv : : IVideoCapture > ( ) ; <nl> - # endif <nl> cv : : Ptr < CvCapture_FFMPEG_proxy > capture = cv : : makePtr < CvCapture_FFMPEG_proxy > ( filename ) ; <nl> if ( capture & & capture - > isOpened ( ) ) <nl> return capture ; <nl> class CvVideoWriter_FFMPEG_proxy CV_FINAL : <nl> <nl> virtual void close ( ) <nl> { <nl> - if ( ffmpegWriter <nl> - # if defined ( HAVE_FFMPEG_WRAPPER ) <nl> - & & icvReleaseVideoWriter_FFMPEG_p <nl> - # endif <nl> - ) <nl> + if ( ffmpegWriter ) <nl> icvReleaseVideoWriter_FFMPEG_p ( & ffmpegWriter ) ; <nl> CV_Assert ( ffmpegWriter = = 0 ) ; <nl> ffmpegWriter = 0 ; <nl> class CvVideoWriter_FFMPEG_proxy CV_FINAL : <nl> <nl> cv : : Ptr < cv : : IVideoWriter > cvCreateVideoWriter_FFMPEG_proxy ( const std : : string & filename , int fourcc , double fps , const cv : : Size & frameSize , bool isColor ) <nl> { <nl> - # if defined ( HAVE_FFMPEG_WRAPPER ) <nl> - icvInitFFMPEG : : Init ( ) ; <nl> - if ( ! icvCreateVideoWriter_FFMPEG_p ) <nl> - return cv : : Ptr < cv : : IVideoWriter > ( ) ; <nl> - # endif <nl> cv : : Ptr < CvVideoWriter_FFMPEG_proxy > writer = cv : : makePtr < CvVideoWriter_FFMPEG_proxy > ( filename , fourcc , fps , frameSize , isColor ! = 0 ) ; <nl> if ( writer & & writer - > isOpened ( ) ) <nl> return writer ; <nl> cv : : Ptr < cv : : IVideoWriter > cvCreateVideoWriter_FFMPEG_proxy ( const std : : string & fi <nl> <nl> } / / namespace <nl> <nl> - # endif / / defined ( HAVE_FFMPEG ) <nl> + <nl> <nl> / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> <nl> deleted file mode 100644 <nl> index fe246ac68fb . . 00000000000 <nl> mmm a / modules / videoio / src / cap_ffmpeg_api . hpp <nl> ppp / dev / null <nl> <nl> - # ifndef __OPENCV_FFMPEG_H__ <nl> - # define __OPENCV_FFMPEG_H__ <nl> - <nl> - # ifdef __cplusplus <nl> - extern " C " <nl> - { <nl> - # endif <nl> - <nl> - # ifndef OPENCV_FFMPEG_API <nl> - # if defined ( __OPENCV_BUILD ) | | defined ( BUILD_PLUGIN ) <nl> - # define OPENCV_FFMPEG_API <nl> - # elif defined _WIN32 <nl> - # define OPENCV_FFMPEG_API __declspec ( dllexport ) <nl> - # elif defined __GNUC__ & & __GNUC__ > = 4 <nl> - # define OPENCV_FFMPEG_API __attribute__ ( ( visibility ( " default " ) ) ) <nl> - # else <nl> - # define OPENCV_FFMPEG_API <nl> - # endif <nl> - # endif <nl> - <nl> - enum <nl> - { <nl> - CV_FFMPEG_CAP_PROP_POS_MSEC = 0 , <nl> - CV_FFMPEG_CAP_PROP_POS_FRAMES = 1 , <nl> - CV_FFMPEG_CAP_PROP_POS_AVI_RATIO = 2 , <nl> - CV_FFMPEG_CAP_PROP_FRAME_WIDTH = 3 , <nl> - CV_FFMPEG_CAP_PROP_FRAME_HEIGHT = 4 , <nl> - CV_FFMPEG_CAP_PROP_FPS = 5 , <nl> - CV_FFMPEG_CAP_PROP_FOURCC = 6 , <nl> - CV_FFMPEG_CAP_PROP_FRAME_COUNT = 7 , <nl> - CV_FFMPEG_CAP_PROP_SAR_NUM = 40 , <nl> - CV_FFMPEG_CAP_PROP_SAR_DEN = 41 <nl> - } ; <nl> - <nl> - typedef struct CvCapture_FFMPEG CvCapture_FFMPEG ; <nl> - typedef struct CvVideoWriter_FFMPEG CvVideoWriter_FFMPEG ; <nl> - <nl> - OPENCV_FFMPEG_API struct CvCapture_FFMPEG * cvCreateFileCapture_FFMPEG ( const char * filename ) ; <nl> - OPENCV_FFMPEG_API int cvSetCaptureProperty_FFMPEG ( struct CvCapture_FFMPEG * cap , <nl> - int prop , double value ) ; <nl> - OPENCV_FFMPEG_API double cvGetCaptureProperty_FFMPEG ( struct CvCapture_FFMPEG * cap , int prop ) ; <nl> - OPENCV_FFMPEG_API int cvGrabFrame_FFMPEG ( struct CvCapture_FFMPEG * cap ) ; <nl> - OPENCV_FFMPEG_API int cvRetrieveFrame_FFMPEG ( struct CvCapture_FFMPEG * capture , unsigned char * * data , <nl> - int * step , int * width , int * height , int * cn ) ; <nl> - OPENCV_FFMPEG_API void cvReleaseCapture_FFMPEG ( struct CvCapture_FFMPEG * * cap ) ; <nl> - <nl> - OPENCV_FFMPEG_API struct CvVideoWriter_FFMPEG * cvCreateVideoWriter_FFMPEG ( const char * filename , <nl> - int fourcc , double fps , int width , int height , int isColor ) ; <nl> - OPENCV_FFMPEG_API int cvWriteFrame_FFMPEG ( struct CvVideoWriter_FFMPEG * writer , const unsigned char * data , <nl> - int step , int width , int height , int cn , int origin ) ; <nl> - OPENCV_FFMPEG_API void cvReleaseVideoWriter_FFMPEG ( struct CvVideoWriter_FFMPEG * * writer ) ; <nl> - <nl> - typedef CvCapture_FFMPEG * ( * CvCreateFileCapture_Plugin ) ( const char * filename ) ; <nl> - typedef CvCapture_FFMPEG * ( * CvCreateCameraCapture_Plugin ) ( int index ) ; <nl> - typedef int ( * CvGrabFrame_Plugin ) ( CvCapture_FFMPEG * capture_handle ) ; <nl> - typedef int ( * CvRetrieveFrame_Plugin ) ( CvCapture_FFMPEG * capture_handle , unsigned char * * data , int * step , <nl> - int * width , int * height , int * cn ) ; <nl> - typedef int ( * CvSetCaptureProperty_Plugin ) ( CvCapture_FFMPEG * capture_handle , int prop_id , double value ) ; <nl> - typedef double ( * CvGetCaptureProperty_Plugin ) ( CvCapture_FFMPEG * capture_handle , int prop_id ) ; <nl> - typedef void ( * CvReleaseCapture_Plugin ) ( CvCapture_FFMPEG * * capture_handle ) ; <nl> - typedef CvVideoWriter_FFMPEG * ( * CvCreateVideoWriter_Plugin ) ( const char * filename , int fourcc , <nl> - double fps , int width , int height , int iscolor ) ; <nl> - typedef int ( * CvWriteFrame_Plugin ) ( CvVideoWriter_FFMPEG * writer_handle , const unsigned char * data , int step , <nl> - int width , int height , int cn , int origin ) ; <nl> - typedef void ( * CvReleaseVideoWriter_Plugin ) ( CvVideoWriter_FFMPEG * * writer ) ; <nl> - <nl> - / * <nl> - * For CUDA encoder <nl> - * / <nl> - <nl> - OPENCV_FFMPEG_API struct OutputMediaStream_FFMPEG * create_OutputMediaStream_FFMPEG ( const char * fileName , int width , int height , double fps ) ; <nl> - OPENCV_FFMPEG_API void release_OutputMediaStream_FFMPEG ( struct OutputMediaStream_FFMPEG * stream ) ; <nl> - OPENCV_FFMPEG_API void write_OutputMediaStream_FFMPEG ( struct OutputMediaStream_FFMPEG * stream , unsigned char * data , int size , int keyFrame ) ; <nl> - <nl> - typedef struct OutputMediaStream_FFMPEG * ( * Create_OutputMediaStream_FFMPEG_Plugin ) ( const char * fileName , int width , int height , double fps ) ; <nl> - typedef void ( * Release_OutputMediaStream_FFMPEG_Plugin ) ( struct OutputMediaStream_FFMPEG * stream ) ; <nl> - typedef void ( * Write_OutputMediaStream_FFMPEG_Plugin ) ( struct OutputMediaStream_FFMPEG * stream , unsigned char * data , int size , int keyFrame ) ; <nl> - <nl> - / * <nl> - * For CUDA decoder <nl> - * / <nl> - <nl> - OPENCV_FFMPEG_API struct InputMediaStream_FFMPEG * create_InputMediaStream_FFMPEG ( const char * fileName , int * codec , int * chroma_format , int * width , int * height ) ; <nl> - OPENCV_FFMPEG_API void release_InputMediaStream_FFMPEG ( struct InputMediaStream_FFMPEG * stream ) ; <nl> - OPENCV_FFMPEG_API int read_InputMediaStream_FFMPEG ( struct InputMediaStream_FFMPEG * stream , unsigned char * * data , int * size , int * endOfFile ) ; <nl> - <nl> - typedef struct InputMediaStream_FFMPEG * ( * Create_InputMediaStream_FFMPEG_Plugin ) ( const char * fileName , int * codec , int * chroma_format , int * width , int * height ) ; <nl> - typedef void ( * Release_InputMediaStream_FFMPEG_Plugin ) ( struct InputMediaStream_FFMPEG * stream ) ; <nl> - typedef int ( * Read_InputMediaStream_FFMPEG_Plugin ) ( struct InputMediaStream_FFMPEG * stream , unsigned char * * data , int * size , int * endOfFile ) ; <nl> - <nl> - # ifdef __cplusplus <nl> - } <nl> - # endif <nl> - <nl> - # endif <nl> mmm a / modules / videoio / src / cap_ffmpeg_impl . hpp <nl> ppp b / modules / videoio / src / cap_ffmpeg_impl . hpp <nl> <nl> / / <nl> / / M * / <nl> <nl> - # include " cap_ffmpeg_api . hpp " <nl> + # include " cap_ffmpeg_legacy_api . hpp " <nl> + <nl> + using namespace cv ; <nl> + <nl> # if ! ( defined ( _WIN32 ) | | defined ( WINCE ) ) <nl> # include < pthread . h > <nl> # endif <nl> void CvCapture_FFMPEG : : close ( ) <nl> # define AVSEEK_FLAG_ANY 1 <nl> # endif <nl> <nl> + # if defined ( __OPENCV_BUILD ) | | defined ( BUILD_PLUGIN ) <nl> + typedef cv : : Mutex ImplMutex ; <nl> + # else <nl> class ImplMutex <nl> { <nl> public : <nl> void ImplMutex : : lock ( ) { impl - > lock ( ) ; } <nl> void ImplMutex : : unlock ( ) { impl - > unlock ( ) ; } <nl> bool ImplMutex : : trylock ( ) { return impl - > trylock ( ) ; } <nl> <nl> + class AutoLock <nl> + { <nl> + public : <nl> + AutoLock ( ImplMutex & m ) : mutex ( & m ) { mutex - > lock ( ) ; } <nl> + ~ AutoLock ( ) { mutex - > unlock ( ) ; } <nl> + protected : <nl> + ImplMutex * mutex ; <nl> + private : <nl> + AutoLock ( const AutoLock & ) ; / / disabled <nl> + AutoLock & operator = ( const AutoLock & ) ; / / disabled <nl> + } ; <nl> + # endif <nl> + <nl> + static ImplMutex _mutex ; <nl> + <nl> static int LockCallBack ( void * * mutex , AVLockOp op ) <nl> { <nl> ImplMutex * localMutex = reinterpret_cast < ImplMutex * > ( * mutex ) ; <nl> switch ( op ) <nl> { <nl> case AV_LOCK_CREATE : <nl> - localMutex = reinterpret_cast < ImplMutex * > ( malloc ( sizeof ( ImplMutex ) ) ) ; <nl> + localMutex = new ImplMutex ( ) ; <nl> if ( ! localMutex ) <nl> return 1 ; <nl> - localMutex - > init ( ) ; <nl> * mutex = localMutex ; <nl> if ( ! * mutex ) <nl> return 1 ; <nl> static int LockCallBack ( void * * mutex , AVLockOp op ) <nl> break ; <nl> <nl> case AV_LOCK_DESTROY : <nl> - localMutex - > destroy ( ) ; <nl> - free ( localMutex ) ; <nl> + delete localMutex ; <nl> localMutex = NULL ; <nl> * mutex = NULL ; <nl> break ; <nl> static int LockCallBack ( void * * mutex , AVLockOp op ) <nl> return 0 ; <nl> } <nl> <nl> - static ImplMutex _mutex ; <nl> - <nl> - class AutoLock <nl> - { <nl> - public : <nl> - AutoLock ( ImplMutex & m ) : mutex ( & m ) { mutex - > lock ( ) ; } <nl> - ~ AutoLock ( ) { mutex - > unlock ( ) ; } <nl> - protected : <nl> - ImplMutex * mutex ; <nl> - private : <nl> - AutoLock ( const AutoLock & ) ; / / disabled <nl> - AutoLock & operator = ( const AutoLock & ) ; / / disabled <nl> - } ; <nl> <nl> static void ffmpeg_log_callback ( void * ptr , int level , const char * fmt , va_list vargs ) <nl> { <nl> double CvCapture_FFMPEG : : getProperty ( int property_id ) const <nl> <nl> switch ( property_id ) <nl> { <nl> - case CV_FFMPEG_CAP_PROP_POS_MSEC : <nl> + case CAP_PROP_POS_MSEC : <nl> return 1000 . 0 * ( double ) frame_number / get_fps ( ) ; <nl> - case CV_FFMPEG_CAP_PROP_POS_FRAMES : <nl> + case CAP_PROP_POS_FRAMES : <nl> return ( double ) frame_number ; <nl> - case CV_FFMPEG_CAP_PROP_POS_AVI_RATIO : <nl> + case CAP_PROP_POS_AVI_RATIO : <nl> return r2d ( ic - > streams [ video_stream ] - > time_base ) ; <nl> - case CV_FFMPEG_CAP_PROP_FRAME_COUNT : <nl> + case CAP_PROP_FRAME_COUNT : <nl> return ( double ) get_total_frames ( ) ; <nl> - case CV_FFMPEG_CAP_PROP_FRAME_WIDTH : <nl> + case CAP_PROP_FRAME_WIDTH : <nl> return ( double ) frame . width ; <nl> - case CV_FFMPEG_CAP_PROP_FRAME_HEIGHT : <nl> + case CAP_PROP_FRAME_HEIGHT : <nl> return ( double ) frame . height ; <nl> - case CV_FFMPEG_CAP_PROP_FPS : <nl> + case CAP_PROP_FPS : <nl> return get_fps ( ) ; <nl> - case CV_FFMPEG_CAP_PROP_FOURCC : <nl> + case CAP_PROP_FOURCC : <nl> # if LIBAVFORMAT_BUILD > 4628 <nl> codec_id = video_st - > codec - > codec_id ; <nl> codec_tag = ( double ) video_st - > codec - > codec_tag ; <nl> double CvCapture_FFMPEG : : getProperty ( int property_id ) const <nl> } <nl> <nl> return ( double ) CV_FOURCC ( codec_fourcc [ 0 ] , codec_fourcc [ 1 ] , codec_fourcc [ 2 ] , codec_fourcc [ 3 ] ) ; <nl> - case CV_FFMPEG_CAP_PROP_SAR_NUM : <nl> + case CAP_PROP_SAR_NUM : <nl> return _opencv_ffmpeg_get_sample_aspect_ratio ( ic - > streams [ video_stream ] ) . num ; <nl> - case CV_FFMPEG_CAP_PROP_SAR_DEN : <nl> + case CAP_PROP_SAR_DEN : <nl> return _opencv_ffmpeg_get_sample_aspect_ratio ( ic - > streams [ video_stream ] ) . den ; <nl> default : <nl> break ; <nl> bool CvCapture_FFMPEG : : setProperty ( int property_id , double value ) <nl> <nl> switch ( property_id ) <nl> { <nl> - case CV_FFMPEG_CAP_PROP_POS_MSEC : <nl> - case CV_FFMPEG_CAP_PROP_POS_FRAMES : <nl> - case CV_FFMPEG_CAP_PROP_POS_AVI_RATIO : <nl> + case CAP_PROP_POS_MSEC : <nl> + case CAP_PROP_POS_FRAMES : <nl> + case CAP_PROP_POS_AVI_RATIO : <nl> { <nl> switch ( property_id ) <nl> { <nl> - case CV_FFMPEG_CAP_PROP_POS_FRAMES : <nl> + case CAP_PROP_POS_FRAMES : <nl> seek ( ( int64_t ) value ) ; <nl> break ; <nl> <nl> - case CV_FFMPEG_CAP_PROP_POS_MSEC : <nl> + case CAP_PROP_POS_MSEC : <nl> seek ( value / 1000 . 0 ) ; <nl> break ; <nl> <nl> - case CV_FFMPEG_CAP_PROP_POS_AVI_RATIO : <nl> + case CAP_PROP_POS_AVI_RATIO : <nl> seek ( ( int64_t ) ( value * ic - > duration ) ) ; <nl> break ; <nl> } <nl> int cvWriteFrame_FFMPEG ( CvVideoWriter_FFMPEG * writer , <nl> { <nl> return writer - > writeFrame ( data , step , width , height , cn , origin ) ; <nl> } <nl> - <nl> - <nl> - <nl> - / * <nl> - * For CUDA encoder <nl> - * / <nl> - <nl> - struct OutputMediaStream_FFMPEG <nl> - { <nl> - bool open ( const char * fileName , int width , int height , double fps ) ; <nl> - void close ( ) ; <nl> - <nl> - void write ( unsigned char * data , int size , int keyFrame ) ; <nl> - <nl> - / / add a video output stream to the container <nl> - static AVStream * addVideoStream ( AVFormatContext * oc , CV_CODEC_ID codec_id , int w , int h , int bitrate , double fps , AVPixelFormat pixel_format ) ; <nl> - <nl> - AVOutputFormat * fmt_ ; <nl> - AVFormatContext * oc_ ; <nl> - AVStream * video_st_ ; <nl> - } ; <nl> - <nl> - void OutputMediaStream_FFMPEG : : close ( ) <nl> - { <nl> - / / no more frame to compress . The codec has a latency of a few <nl> - / / frames if using B frames , so we get the last frames by <nl> - / / passing the same picture again <nl> - <nl> - / / TODO - - do we need to account for latency here ? <nl> - <nl> - if ( oc_ ) <nl> - { <nl> - / / write the trailer , if any <nl> - av_write_trailer ( oc_ ) ; <nl> - <nl> - / / free the streams <nl> - for ( unsigned int i = 0 ; i < oc_ - > nb_streams ; + + i ) <nl> - { <nl> - av_freep ( & oc_ - > streams [ i ] - > codec ) ; <nl> - av_freep ( & oc_ - > streams [ i ] ) ; <nl> - } <nl> - <nl> - if ( ! ( fmt_ - > flags & AVFMT_NOFILE ) & & oc_ - > pb ) <nl> - { <nl> - / / close the output file <nl> - <nl> - # if LIBAVCODEC_VERSION_INT < ( ( 52 < < 16 ) + ( 123 < < 8 ) + 0 ) <nl> - # if LIBAVCODEC_VERSION_INT > = ( ( 51 < < 16 ) + ( 49 < < 8 ) + 0 ) <nl> - url_fclose ( oc_ - > pb ) ; <nl> - # else <nl> - url_fclose ( & oc_ - > pb ) ; <nl> - # endif <nl> - # else <nl> - avio_close ( oc_ - > pb ) ; <nl> - # endif <nl> - } <nl> - <nl> - / / free the stream <nl> - av_free ( oc_ ) ; <nl> - } <nl> - } <nl> - <nl> - AVStream * OutputMediaStream_FFMPEG : : addVideoStream ( AVFormatContext * oc , CV_CODEC_ID codec_id , int w , int h , int bitrate , double fps , AVPixelFormat pixel_format ) <nl> - { <nl> - AVCodec * codec = avcodec_find_encoder ( codec_id ) ; <nl> - if ( ! codec ) <nl> - { <nl> - fprintf ( stderr , " Could not find encoder for codec id % d \ n " , codec_id ) ; <nl> - return NULL ; <nl> - } <nl> - <nl> - # if LIBAVFORMAT_BUILD > = CALC_FFMPEG_VERSION ( 53 , 10 , 0 ) <nl> - AVStream * st = avformat_new_stream ( oc , 0 ) ; <nl> - # else <nl> - AVStream * st = av_new_stream ( oc , 0 ) ; <nl> - # endif <nl> - if ( ! st ) <nl> - return 0 ; <nl> - <nl> - # if LIBAVFORMAT_BUILD > 4628 <nl> - AVCodecContext * c = st - > codec ; <nl> - # else <nl> - AVCodecContext * c = & ( st - > codec ) ; <nl> - # endif <nl> - <nl> - c - > codec_id = codec_id ; <nl> - c - > codec_type = AVMEDIA_TYPE_VIDEO ; <nl> - <nl> - / / put sample parameters <nl> - c - > bit_rate = bitrate ; <nl> - <nl> - / / took advice from <nl> - / / http : / / ffmpeg - users . 933282 . n4 . nabble . com / warning - clipping - 1 - dct - coefficients - to - 127 - 127 - td934297 . html <nl> - c - > qmin = 3 ; <nl> - <nl> - / / resolution must be a multiple of two <nl> - c - > width = w ; <nl> - c - > height = h ; <nl> - <nl> - / / time base : this is the fundamental unit of time ( in seconds ) in terms <nl> - / / of which frame timestamps are represented . for fixed - fps content , <nl> - / / timebase should be 1 / framerate and timestamp increments should be <nl> - / / identically 1 <nl> - <nl> - int frame_rate = static_cast < int > ( fps + 0 . 5 ) ; <nl> - int frame_rate_base = 1 ; <nl> - while ( fabs ( ( static_cast < double > ( frame_rate ) / frame_rate_base ) - fps ) > 0 . 001 ) <nl> - { <nl> - frame_rate_base * = 10 ; <nl> - frame_rate = static_cast < int > ( fps * frame_rate_base + 0 . 5 ) ; <nl> - } <nl> - c - > time_base . den = frame_rate ; <nl> - c - > time_base . num = frame_rate_base ; <nl> - <nl> - # if LIBAVFORMAT_BUILD > 4752 <nl> - / / adjust time base for supported framerates <nl> - if ( codec & & codec - > supported_framerates ) <nl> - { <nl> - AVRational req = { frame_rate , frame_rate_base } ; <nl> - const AVRational * best = NULL ; <nl> - AVRational best_error = { INT_MAX , 1 } ; <nl> - <nl> - for ( const AVRational * p = codec - > supported_framerates ; p - > den ! = 0 ; + + p ) <nl> - { <nl> - AVRational error = av_sub_q ( req , * p ) ; <nl> - <nl> - if ( error . num < 0 ) <nl> - error . num * = - 1 ; <nl> - <nl> - if ( av_cmp_q ( error , best_error ) < 0 ) <nl> - { <nl> - best_error = error ; <nl> - best = p ; <nl> - } <nl> - } <nl> - <nl> - if ( best = = NULL ) <nl> - return NULL ; <nl> - c - > time_base . den = best - > num ; <nl> - c - > time_base . num = best - > den ; <nl> - } <nl> - # endif <nl> - <nl> - c - > gop_size = 12 ; / / emit one intra frame every twelve frames at most <nl> - c - > pix_fmt = pixel_format ; <nl> - <nl> - if ( c - > codec_id = = CV_CODEC ( CODEC_ID_MPEG2VIDEO ) ) <nl> - c - > max_b_frames = 2 ; <nl> - <nl> - if ( c - > codec_id = = CV_CODEC ( CODEC_ID_MPEG1VIDEO ) | | c - > codec_id = = CV_CODEC ( CODEC_ID_MSMPEG4V3 ) ) <nl> - { <nl> - / / needed to avoid using macroblocks in which some coeffs overflow <nl> - / / this doesn ' t happen with normal video , it just happens here as the <nl> - / / motion of the chroma plane doesn ' t match the luma plane <nl> - <nl> - / / avoid FFMPEG warning ' clipping 1 dct coefficients . . . ' <nl> - <nl> - c - > mb_decision = 2 ; <nl> - } <nl> - <nl> - # if LIBAVCODEC_VERSION_INT > 0x000409 <nl> - / / some formats want stream headers to be separate <nl> - if ( oc - > oformat - > flags & AVFMT_GLOBALHEADER ) <nl> - { <nl> - # if LIBAVCODEC_BUILD > CALC_FFMPEG_VERSION ( 56 , 35 , 0 ) <nl> - c - > flags | = AV_CODEC_FLAG_GLOBAL_HEADER ; <nl> - # else <nl> - c - > flags | = CODEC_FLAG_GLOBAL_HEADER ; <nl> - # endif <nl> - } <nl> - # endif <nl> - <nl> - return st ; <nl> - } <nl> - <nl> - bool OutputMediaStream_FFMPEG : : open ( const char * fileName , int width , int height , double fps ) <nl> - { <nl> - fmt_ = 0 ; <nl> - oc_ = 0 ; <nl> - video_st_ = 0 ; <nl> - <nl> - / / auto detect the output format from the name and fourcc code <nl> - # if LIBAVFORMAT_BUILD > = CALC_FFMPEG_VERSION ( 53 , 2 , 0 ) <nl> - fmt_ = av_guess_format ( NULL , fileName , NULL ) ; <nl> - # else <nl> - fmt_ = guess_format ( NULL , fileName , NULL ) ; <nl> - # endif <nl> - if ( ! fmt_ ) <nl> - return false ; <nl> - <nl> - CV_CODEC_ID codec_id = CV_CODEC ( CODEC_ID_H264 ) ; <nl> - <nl> - / / alloc memory for context <nl> - # if LIBAVFORMAT_BUILD > = CALC_FFMPEG_VERSION ( 53 , 2 , 0 ) <nl> - oc_ = avformat_alloc_context ( ) ; <nl> - # else <nl> - oc_ = av_alloc_format_context ( ) ; <nl> - # endif <nl> - if ( ! oc_ ) <nl> - return false ; <nl> - <nl> - / / set some options <nl> - oc_ - > oformat = fmt_ ; <nl> - snprintf ( oc_ - > filename , sizeof ( oc_ - > filename ) , " % s " , fileName ) ; <nl> - <nl> - oc_ - > max_delay = ( int ) ( 0 . 7 * AV_TIME_BASE ) ; / / This reduces buffer underrun warnings with MPEG <nl> - <nl> - / / set a few optimal pixel formats for lossless codecs of interest . . <nl> - AVPixelFormat codec_pix_fmt = AV_PIX_FMT_YUV420P ; <nl> - int bitrate_scale = 64 ; <nl> - <nl> - / / TODO - - safe to ignore output audio stream ? <nl> - video_st_ = addVideoStream ( oc_ , codec_id , width , height , width * height * bitrate_scale , fps , codec_pix_fmt ) ; <nl> - if ( ! video_st_ ) <nl> - return false ; <nl> - <nl> - / / set the output parameters ( must be done even if no parameters ) <nl> - # if LIBAVFORMAT_BUILD < CALC_FFMPEG_VERSION ( 53 , 2 , 0 ) <nl> - if ( av_set_parameters ( oc_ , NULL ) < 0 ) <nl> - return false ; <nl> - # endif <nl> - <nl> - / / now that all the parameters are set , we can open the audio and <nl> - / / video codecs and allocate the necessary encode buffers <nl> - <nl> - # if LIBAVFORMAT_BUILD > 4628 <nl> - AVCodecContext * c = ( video_st_ - > codec ) ; <nl> - # else <nl> - AVCodecContext * c = & ( video_st_ - > codec ) ; <nl> - # endif <nl> - <nl> - c - > codec_tag = MKTAG ( ' H ' , ' 2 ' , ' 6 ' , ' 4 ' ) ; <nl> - c - > bit_rate_tolerance = c - > bit_rate ; <nl> - <nl> - / / open the output file , if needed <nl> - if ( ! ( fmt_ - > flags & AVFMT_NOFILE ) ) <nl> - { <nl> - # if LIBAVFORMAT_BUILD < CALC_FFMPEG_VERSION ( 53 , 2 , 0 ) <nl> - int err = url_fopen ( & oc_ - > pb , fileName , URL_WRONLY ) ; <nl> - # else <nl> - int err = avio_open ( & oc_ - > pb , fileName , AVIO_FLAG_WRITE ) ; <nl> - # endif <nl> - <nl> - if ( err ! = 0 ) <nl> - return false ; <nl> - } <nl> - <nl> - / / write the stream header , if any <nl> - int header_err = <nl> - # if LIBAVFORMAT_BUILD < CALC_FFMPEG_VERSION ( 53 , 2 , 0 ) <nl> - av_write_header ( oc_ ) ; <nl> - # else <nl> - avformat_write_header ( oc_ , NULL ) ; <nl> - # endif <nl> - if ( header_err ! = 0 ) <nl> - return false ; <nl> - <nl> - return true ; <nl> - } <nl> - <nl> - void OutputMediaStream_FFMPEG : : write ( unsigned char * data , int size , int keyFrame ) <nl> - { <nl> - / / if zero size , it means the image was buffered <nl> - if ( size > 0 ) <nl> - { <nl> - AVPacket pkt ; <nl> - av_init_packet ( & pkt ) ; <nl> - <nl> - if ( keyFrame ) <nl> - pkt . flags | = PKT_FLAG_KEY ; <nl> - <nl> - pkt . stream_index = video_st_ - > index ; <nl> - pkt . data = data ; <nl> - pkt . size = size ; <nl> - <nl> - / / write the compressed frame in the media file <nl> - av_write_frame ( oc_ , & pkt ) ; <nl> - } <nl> - } <nl> - <nl> - struct OutputMediaStream_FFMPEG * create_OutputMediaStream_FFMPEG ( const char * fileName , int width , int height , double fps ) <nl> - { <nl> - OutputMediaStream_FFMPEG * stream = ( OutputMediaStream_FFMPEG * ) malloc ( sizeof ( OutputMediaStream_FFMPEG ) ) ; <nl> - if ( ! stream ) <nl> - return 0 ; <nl> - <nl> - if ( stream - > open ( fileName , width , height , fps ) ) <nl> - return stream ; <nl> - <nl> - stream - > close ( ) ; <nl> - free ( stream ) ; <nl> - <nl> - return 0 ; <nl> - } <nl> - <nl> - void release_OutputMediaStream_FFMPEG ( struct OutputMediaStream_FFMPEG * stream ) <nl> - { <nl> - stream - > close ( ) ; <nl> - free ( stream ) ; <nl> - } <nl> - <nl> - void write_OutputMediaStream_FFMPEG ( struct OutputMediaStream_FFMPEG * stream , unsigned char * data , int size , int keyFrame ) <nl> - { <nl> - stream - > write ( data , size , keyFrame ) ; <nl> - } <nl> - <nl> - / * <nl> - * For CUDA decoder <nl> - * / <nl> - <nl> - enum <nl> - { <nl> - VideoCodec_MPEG1 = 0 , <nl> - VideoCodec_MPEG2 , <nl> - VideoCodec_MPEG4 , <nl> - VideoCodec_VC1 , <nl> - VideoCodec_H264 , <nl> - VideoCodec_JPEG , <nl> - VideoCodec_H264_SVC , <nl> - VideoCodec_H264_MVC , <nl> - <nl> - / / Uncompressed YUV <nl> - VideoCodec_YUV420 = ( ( ' I ' < < 24 ) | ( ' Y ' < < 16 ) | ( ' U ' < < 8 ) | ( ' V ' ) ) , / / Y , U , V ( 4 : 2 : 0 ) <nl> - VideoCodec_YV12 = ( ( ' Y ' < < 24 ) | ( ' V ' < < 16 ) | ( ' 1 ' < < 8 ) | ( ' 2 ' ) ) , / / Y , V , U ( 4 : 2 : 0 ) <nl> - VideoCodec_NV12 = ( ( ' N ' < < 24 ) | ( ' V ' < < 16 ) | ( ' 1 ' < < 8 ) | ( ' 2 ' ) ) , / / Y , UV ( 4 : 2 : 0 ) <nl> - VideoCodec_YUYV = ( ( ' Y ' < < 24 ) | ( ' U ' < < 16 ) | ( ' Y ' < < 8 ) | ( ' V ' ) ) , / / YUYV / YUY2 ( 4 : 2 : 2 ) <nl> - VideoCodec_UYVY = ( ( ' U ' < < 24 ) | ( ' Y ' < < 16 ) | ( ' V ' < < 8 ) | ( ' Y ' ) ) / / UYVY ( 4 : 2 : 2 ) <nl> - } ; <nl> - <nl> - enum <nl> - { <nl> - VideoChromaFormat_Monochrome = 0 , <nl> - VideoChromaFormat_YUV420 , <nl> - VideoChromaFormat_YUV422 , <nl> - VideoChromaFormat_YUV444 <nl> - } ; <nl> - <nl> - struct InputMediaStream_FFMPEG <nl> - { <nl> - public : <nl> - bool open ( const char * fileName , int * codec , int * chroma_format , int * width , int * height ) ; <nl> - void close ( ) ; <nl> - <nl> - bool read ( unsigned char * * data , int * size , int * endOfFile ) ; <nl> - <nl> - private : <nl> - InputMediaStream_FFMPEG ( const InputMediaStream_FFMPEG & ) ; <nl> - InputMediaStream_FFMPEG & operator = ( const InputMediaStream_FFMPEG & ) ; <nl> - <nl> - AVFormatContext * ctx_ ; <nl> - int video_stream_id_ ; <nl> - AVPacket pkt_ ; <nl> - <nl> - # if USE_AV_INTERRUPT_CALLBACK <nl> - AVInterruptCallbackMetadata interrupt_metadata ; <nl> - # endif <nl> - } ; <nl> - <nl> - bool InputMediaStream_FFMPEG : : open ( const char * fileName , int * codec , int * chroma_format , int * width , int * height ) <nl> - { <nl> - int err ; <nl> - <nl> - ctx_ = 0 ; <nl> - video_stream_id_ = - 1 ; <nl> - memset ( & pkt_ , 0 , sizeof ( AVPacket ) ) ; <nl> - <nl> - # if USE_AV_INTERRUPT_CALLBACK <nl> - / * interrupt callback * / <nl> - interrupt_metadata . timeout_after_ms = LIBAVFORMAT_INTERRUPT_OPEN_TIMEOUT_MS ; <nl> - get_monotonic_time ( & interrupt_metadata . value ) ; <nl> - <nl> - ctx_ = avformat_alloc_context ( ) ; <nl> - ctx_ - > interrupt_callback . callback = _opencv_ffmpeg_interrupt_callback ; <nl> - ctx_ - > interrupt_callback . opaque = & interrupt_metadata ; <nl> - # endif <nl> - <nl> - # if LIBAVFORMAT_BUILD > = CALC_FFMPEG_VERSION ( 53 , 13 , 0 ) <nl> - avformat_network_init ( ) ; <nl> - # endif <nl> - <nl> - # if LIBAVFORMAT_BUILD > = CALC_FFMPEG_VERSION ( 53 , 6 , 0 ) <nl> - err = avformat_open_input ( & ctx_ , fileName , 0 , 0 ) ; <nl> - # else <nl> - err = av_open_input_file ( & ctx_ , fileName , 0 , 0 , 0 ) ; <nl> - # endif <nl> - if ( err < 0 ) <nl> - return false ; <nl> - <nl> - # if LIBAVFORMAT_BUILD > = CALC_FFMPEG_VERSION ( 53 , 6 , 0 ) <nl> - err = avformat_find_stream_info ( ctx_ , 0 ) ; <nl> - # else <nl> - err = av_find_stream_info ( ctx_ ) ; <nl> - # endif <nl> - if ( err < 0 ) <nl> - return false ; <nl> - <nl> - for ( unsigned int i = 0 ; i < ctx_ - > nb_streams ; + + i ) <nl> - { <nl> - # if LIBAVFORMAT_BUILD > 4628 <nl> - AVCodecContext * enc = ctx_ - > streams [ i ] - > codec ; <nl> - # else <nl> - AVCodecContext * enc = & ctx_ - > streams [ i ] - > codec ; <nl> - # endif <nl> - <nl> - if ( enc - > codec_type = = AVMEDIA_TYPE_VIDEO ) <nl> - { <nl> - video_stream_id_ = static_cast < int > ( i ) ; <nl> - <nl> - switch ( enc - > codec_id ) <nl> - { <nl> - case CV_CODEC ( CODEC_ID_MPEG1VIDEO ) : <nl> - * codec = : : VideoCodec_MPEG1 ; <nl> - break ; <nl> - <nl> - case CV_CODEC ( CODEC_ID_MPEG2VIDEO ) : <nl> - * codec = : : VideoCodec_MPEG2 ; <nl> - break ; <nl> - <nl> - case CV_CODEC ( CODEC_ID_MPEG4 ) : <nl> - * codec = : : VideoCodec_MPEG4 ; <nl> - break ; <nl> - <nl> - case CV_CODEC ( CODEC_ID_VC1 ) : <nl> - * codec = : : VideoCodec_VC1 ; <nl> - break ; <nl> - <nl> - case CV_CODEC ( CODEC_ID_H264 ) : <nl> - * codec = : : VideoCodec_H264 ; <nl> - break ; <nl> - <nl> - default : <nl> - return false ; <nl> - } ; <nl> - <nl> - switch ( enc - > pix_fmt ) <nl> - { <nl> - case AV_PIX_FMT_YUV420P : <nl> - * chroma_format = : : VideoChromaFormat_YUV420 ; <nl> - break ; <nl> - <nl> - case AV_PIX_FMT_YUV422P : <nl> - * chroma_format = : : VideoChromaFormat_YUV422 ; <nl> - break ; <nl> - <nl> - case AV_PIX_FMT_YUV444P : <nl> - * chroma_format = : : VideoChromaFormat_YUV444 ; <nl> - break ; <nl> - <nl> - default : <nl> - return false ; <nl> - } <nl> - <nl> - * width = enc - > coded_width ; <nl> - * height = enc - > coded_height ; <nl> - <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - if ( video_stream_id_ < 0 ) <nl> - return false ; <nl> - <nl> - av_init_packet ( & pkt_ ) ; <nl> - <nl> - # if USE_AV_INTERRUPT_CALLBACK <nl> - / / deactivate interrupt callback <nl> - interrupt_metadata . timeout_after_ms = 0 ; <nl> - # endif <nl> - <nl> - return true ; <nl> - } <nl> - <nl> - void InputMediaStream_FFMPEG : : close ( ) <nl> - { <nl> - if ( ctx_ ) <nl> - { <nl> - # if LIBAVFORMAT_BUILD > = CALC_FFMPEG_VERSION ( 53 , 24 , 2 ) <nl> - avformat_close_input ( & ctx_ ) ; <nl> - # else <nl> - av_close_input_file ( ctx_ ) ; <nl> - # endif <nl> - } <nl> - <nl> - / / free last packet if exist <nl> - if ( pkt_ . data ) <nl> - _opencv_ffmpeg_av_packet_unref ( & pkt_ ) ; <nl> - } <nl> - <nl> - bool InputMediaStream_FFMPEG : : read ( unsigned char * * data , int * size , int * endOfFile ) <nl> - { <nl> - bool result = false ; <nl> - <nl> - # if USE_AV_INTERRUPT_CALLBACK <nl> - / / activate interrupt callback <nl> - get_monotonic_time ( & interrupt_metadata . value ) ; <nl> - interrupt_metadata . timeout_after_ms = LIBAVFORMAT_INTERRUPT_READ_TIMEOUT_MS ; <nl> - # endif <nl> - <nl> - / / free last packet if exist <nl> - if ( pkt_ . data ) <nl> - _opencv_ffmpeg_av_packet_unref ( & pkt_ ) ; <nl> - <nl> - / / get the next frame <nl> - for ( ; ; ) <nl> - { <nl> - # if USE_AV_INTERRUPT_CALLBACK <nl> - if ( interrupt_metadata . timeout ) <nl> - { <nl> - break ; <nl> - } <nl> - # endif <nl> - <nl> - int ret = av_read_frame ( ctx_ , & pkt_ ) ; <nl> - <nl> - if ( ret = = AVERROR ( EAGAIN ) ) <nl> - continue ; <nl> - <nl> - if ( ret < 0 ) <nl> - { <nl> - if ( ret = = ( int ) AVERROR_EOF ) <nl> - * endOfFile = true ; <nl> - break ; <nl> - } <nl> - <nl> - if ( pkt_ . stream_index ! = video_stream_id_ ) <nl> - { <nl> - _opencv_ffmpeg_av_packet_unref ( & pkt_ ) ; <nl> - continue ; <nl> - } <nl> - <nl> - result = true ; <nl> - break ; <nl> - } <nl> - <nl> - # if USE_AV_INTERRUPT_CALLBACK <nl> - / / deactivate interrupt callback <nl> - interrupt_metadata . timeout_after_ms = 0 ; <nl> - # endif <nl> - <nl> - if ( result ) <nl> - { <nl> - * data = pkt_ . data ; <nl> - * size = pkt_ . size ; <nl> - * endOfFile = false ; <nl> - } <nl> - <nl> - return result ; <nl> - } <nl> - <nl> - InputMediaStream_FFMPEG * create_InputMediaStream_FFMPEG ( const char * fileName , int * codec , int * chroma_format , int * width , int * height ) <nl> - { <nl> - InputMediaStream_FFMPEG * stream = ( InputMediaStream_FFMPEG * ) malloc ( sizeof ( InputMediaStream_FFMPEG ) ) ; <nl> - if ( ! stream ) <nl> - return 0 ; <nl> - <nl> - if ( stream & & stream - > open ( fileName , codec , chroma_format , width , height ) ) <nl> - return stream ; <nl> - <nl> - stream - > close ( ) ; <nl> - free ( stream ) ; <nl> - <nl> - return 0 ; <nl> - } <nl> - <nl> - void release_InputMediaStream_FFMPEG ( InputMediaStream_FFMPEG * stream ) <nl> - { <nl> - stream - > close ( ) ; <nl> - free ( stream ) ; <nl> - } <nl> - <nl> - int read_InputMediaStream_FFMPEG ( InputMediaStream_FFMPEG * stream , unsigned char * * data , int * size , int * endOfFile ) <nl> - { <nl> - return stream - > read ( data , size , endOfFile ) ; <nl> - } <nl> new file mode 100644 <nl> index 00000000000 . . d918765e2e3 <nl> mmm / dev / null <nl> ppp b / modules / videoio / src / cap_ffmpeg_legacy_api . hpp <nl> <nl> + / / This file is part of OpenCV project . <nl> + / / It is subject to the license terms in the LICENSE file found in the top - level directory <nl> + / / of this distribution and at http : / / opencv . org / license . html . <nl> + # ifndef __OPENCV_FFMPEG_LEGACY_API_H__ <nl> + # define __OPENCV_FFMPEG_LEGACY_API_H__ <nl> + <nl> + # ifdef __cplusplus <nl> + extern " C " <nl> + { <nl> + # endif <nl> + <nl> + # ifndef OPENCV_FFMPEG_API <nl> + # if defined ( __OPENCV_BUILD ) <nl> + # define OPENCV_FFMPEG_API <nl> + # elif defined _WIN32 <nl> + # define OPENCV_FFMPEG_API __declspec ( dllexport ) <nl> + # elif defined __GNUC__ & & __GNUC__ > = 4 <nl> + # define OPENCV_FFMPEG_API __attribute__ ( ( visibility ( " default " ) ) ) <nl> + # else <nl> + # define OPENCV_FFMPEG_API <nl> + # endif <nl> + # endif <nl> + <nl> + typedef struct CvCapture_FFMPEG CvCapture_FFMPEG ; <nl> + typedef struct CvVideoWriter_FFMPEG CvVideoWriter_FFMPEG ; <nl> + <nl> + OPENCV_FFMPEG_API struct CvCapture_FFMPEG * cvCreateFileCapture_FFMPEG ( const char * filename ) ; <nl> + OPENCV_FFMPEG_API int cvSetCaptureProperty_FFMPEG ( struct CvCapture_FFMPEG * cap , <nl> + int prop , double value ) ; <nl> + OPENCV_FFMPEG_API double cvGetCaptureProperty_FFMPEG ( struct CvCapture_FFMPEG * cap , int prop ) ; <nl> + OPENCV_FFMPEG_API int cvGrabFrame_FFMPEG ( struct CvCapture_FFMPEG * cap ) ; <nl> + OPENCV_FFMPEG_API int cvRetrieveFrame_FFMPEG ( struct CvCapture_FFMPEG * capture , unsigned char * * data , <nl> + int * step , int * width , int * height , int * cn ) ; <nl> + OPENCV_FFMPEG_API void cvReleaseCapture_FFMPEG ( struct CvCapture_FFMPEG * * cap ) ; <nl> + <nl> + OPENCV_FFMPEG_API struct CvVideoWriter_FFMPEG * cvCreateVideoWriter_FFMPEG ( const char * filename , <nl> + int fourcc , double fps , int width , int height , int isColor ) ; <nl> + OPENCV_FFMPEG_API int cvWriteFrame_FFMPEG ( struct CvVideoWriter_FFMPEG * writer , const unsigned char * data , <nl> + int step , int width , int height , int cn , int origin ) ; <nl> + OPENCV_FFMPEG_API void cvReleaseVideoWriter_FFMPEG ( struct CvVideoWriter_FFMPEG * * writer ) ; <nl> + <nl> + # ifdef __cplusplus <nl> + } <nl> + # endif <nl> + <nl> + # endif / / __OPENCV_FFMPEG_LEGACY_API_H__ <nl> mmm a / modules / videoio / src / precomp . hpp <nl> ppp b / modules / videoio / src / precomp . hpp <nl> <nl> # include " opencv2 / videoio / legacy / constants_c . h " <nl> <nl> # include " opencv2 / core / utility . hpp " <nl> + # ifdef __OPENCV_BUILD <nl> # include " opencv2 / core / private . hpp " <nl> + # endif <nl> <nl> # include < opencv2 / core / utils / configuration . private . hpp > <nl> # include < opencv2 / core / utils / logger . hpp > <nl> mmm a / modules / videoio / src / videoio_registry . cpp <nl> ppp b / modules / videoio / src / videoio_registry . cpp <nl> static const struct VideoBackendInfo builtin_backends [ ] = <nl> { <nl> # ifdef HAVE_FFMPEG <nl> DECLARE_STATIC_BACKEND ( CAP_FFMPEG , " FFMPEG " , MODE_CAPTURE_BY_FILENAME | MODE_WRITER , cvCreateFileCapture_FFMPEG_proxy , 0 , cvCreateVideoWriter_FFMPEG_proxy ) , <nl> - # elif defined ( ENABLE_PLUGINS ) <nl> + # elif defined ( ENABLE_PLUGINS ) | | defined ( HAVE_FFMPEG_WRAPPER ) <nl> DECLARE_DYNAMIC_BACKEND ( CAP_FFMPEG , " FFMPEG " , MODE_CAPTURE_BY_FILENAME | MODE_WRITER ) , <nl> # endif <nl> <nl>
videoio : plugins support on Win32
opencv/opencv
7b099e0fe2d929e55d6705b6ad510c2c9081606b
2019-06-16T15:25:25Z
mmm a / modules / core / src / arithm . cpp <nl> ppp b / modules / core / src / arithm . cpp <nl> static bool ocl_arithm_op ( InputArray _src1 , InputArray _src2 , OutputArray _dst , <nl> if ( ! doubleSupport & & ( depth2 = = CV_64F | | depth1 = = CV_64F ) ) <nl> return false ; <nl> <nl> - if ( ( oclop = = OCL_OP_MUL_SCALE | | oclop = = OCL_OP_DIV_SCALE ) & & ( depth1 > = CV_32F | | depth2 > = CV_32F | | ddepth > = CV_32F ) ) <nl> - return false ; <nl> - <nl> int kercn = haveMask | | haveScalar ? cn : ocl : : predictOptimalVectorWidth ( _src1 , _src2 , _dst ) ; <nl> int scalarcn = kercn = = 3 ? 4 : kercn , rowsPerWI = d . isIntel ( ) ? 4 : 1 ; <nl> <nl> mmm a / modules / core / src / copy . cpp <nl> ppp b / modules / core / src / copy . cpp <nl> void flip ( InputArray _src , OutputArray _dst , int flip_mode ) <nl> flipHoriz ( dst . data , dst . step , dst . data , dst . step , dst . size ( ) , esz ) ; <nl> } <nl> <nl> - / * # ifdef HAVE_OPENCL <nl> + # if defined HAVE_OPENCL & & ! defined __APPLE__ <nl> <nl> static bool ocl_repeat ( InputArray _src , int ny , int nx , OutputArray _dst ) <nl> { <nl> static bool ocl_repeat ( InputArray _src , int ny , int nx , OutputArray _dst ) <nl> return k . run ( 2 , globalsize , NULL , false ) ; <nl> } <nl> <nl> - # endif * / <nl> + # endif <nl> <nl> void repeat ( InputArray _src , int ny , int nx , OutputArray _dst ) <nl> { <nl> void repeat ( InputArray _src , int ny , int nx , OutputArray _dst ) <nl> Size ssize = _src . size ( ) ; <nl> _dst . create ( ssize . height * ny , ssize . width * nx , _src . type ( ) ) ; <nl> <nl> - / * CV_OCL_RUN ( _dst . isUMat ( ) , <nl> - ocl_repeat ( _src , ny , nx , _dst ) ) * / <nl> + # if ! defined __APPLE__ <nl> + CV_OCL_RUN ( _dst . isUMat ( ) , <nl> + ocl_repeat ( _src , ny , nx , _dst ) ) <nl> + # endif <nl> <nl> Mat src = _src . getMat ( ) , dst = _dst . getMat ( ) ; <nl> Size dsize = dst . size ( ) ; <nl> mmm a / modules / core / test / ocl / test_arithm . cpp <nl> ppp b / modules / core / test / ocl / test_arithm . cpp <nl> OCL_TEST_P ( Mul , Mat_Scalar_Scale ) <nl> OCL_OFF ( cv : : multiply ( src1_roi , val , dst1_roi , val [ 0 ] ) ) ; <nl> OCL_ON ( cv : : multiply ( usrc1_roi , val , udst1_roi , val [ 0 ] ) ) ; <nl> <nl> - Near ( udst1_roi . depth ( ) > = CV_32F ? 1e - 2 : 1 ) ; <nl> + Near ( udst1_roi . depth ( ) > = CV_32F ? 2e - 2 : 1 ) ; <nl> } <nl> } <nl> <nl> OCL_TEST_P ( Div , Mat_Scale ) <nl> OCL_OFF ( cv : : divide ( src1_roi , src2_roi , dst1_roi , val [ 0 ] ) ) ; <nl> OCL_ON ( cv : : divide ( usrc1_roi , usrc2_roi , udst1_roi , val [ 0 ] ) ) ; <nl> <nl> - Near ( udst1_roi . depth ( ) > = CV_32F ? 4e - 3 : 1 ) ; <nl> + Near ( udst1_roi . depth ( ) > = CV_32F ? 2e - 2 : 1 ) ; <nl> } <nl> } <nl> <nl>
Merge pull request from vpisarev : restore_ocl_div_mul_and_repeat
opencv/opencv
12c69ad490db8631e39a9c4be61d29f57735abea
2014-08-13T13:56:19Z
mmm a / hphp / runtime / ext / collections / ext_collections - idl . cpp <nl> ppp b / hphp / runtime / ext / collections / ext_collections - idl . cpp <nl> BaseMap : : php_differenceByKey ( const Variant & it ) { <nl> auto ret = Object : : attach ( target ) ; <nl> if ( obj - > isCollection ( ) ) { <nl> if ( isMapCollection ( obj - > collectionType ( ) ) ) { <nl> - auto mp = static_cast < BaseMap * > ( obj ) ; <nl> - auto * eLimit = mp - > elmLimit ( ) ; <nl> - for ( auto * e = mp - > firstElm ( ) ; e ! = eLimit ; e = nextElm ( e , eLimit ) ) { <nl> + auto map = static_cast < BaseMap * > ( obj ) ; <nl> + auto * eLimit = map - > elmLimit ( ) ; <nl> + for ( auto * e = map - > firstElm ( ) ; e ! = eLimit ; e = nextElm ( e , eLimit ) ) { <nl> if ( e - > hasIntKey ( ) ) { <nl> target - > remove ( ( int64_t ) e - > ikey ) ; <nl> } else { <nl> BaseMap : : php_map ( const Variant & callback , MakeArgs makeArgs ) const { <nl> SystemLib : : throwInvalidArgumentExceptionObject ( <nl> " Parameter must be a valid callback " ) ; <nl> } <nl> - auto mp = req : : make < TMap > ( ) ; <nl> - if ( ! m_size ) return Object { std : : move ( mp ) } ; <nl> + auto map = req : : make < TMap > ( ) ; <nl> + if ( ! m_size ) return Object { std : : move ( map ) } ; <nl> assert ( posLimit ( ) ! = 0 ) ; <nl> assert ( hashSize ( ) > 0 ) ; <nl> - assert ( mp - > arrayData ( ) = = staticEmptyMixedArray ( ) ) ; <nl> - mp - > m_arr = MixedArray : : asMixed ( MixedArray : : MakeReserveMixed ( cap ( ) ) ) ; <nl> - mp - > setIntLikeStrKeys ( intLikeStrKeys ( ) ) ; <nl> - wordcpy ( mp - > hashTab ( ) , hashTab ( ) , hashSize ( ) ) ; <nl> + assert ( map - > arrayData ( ) = = staticEmptyMixedArray ( ) ) ; <nl> + map - > m_arr = MixedArray : : asMixed ( MixedArray : : MakeReserveMixed ( cap ( ) ) ) ; <nl> + map - > setIntLikeStrKeys ( intLikeStrKeys ( ) ) ; <nl> + wordcpy ( map - > hashTab ( ) , hashTab ( ) , hashSize ( ) ) ; <nl> { <nl> uint32_t used = posLimit ( ) ; <nl> int32_t version = m_version ; <nl> BaseMap : : php_map ( const Variant & callback , MakeArgs makeArgs ) const { <nl> / / make sure that posLimit ( ) get set to the correct value and <nl> / / that m_pos gets set to point to the first element . <nl> SCOPE_EXIT { <nl> - mp - > setPosLimit ( i ) ; <nl> - mp - > arrayData ( ) - > m_pos = mp - > nthElmPos ( 0 ) ; <nl> + map - > setPosLimit ( i ) ; <nl> + map - > arrayData ( ) - > m_pos = map - > nthElmPos ( 0 ) ; <nl> } ; <nl> for ( ; i < used ; + + i ) { <nl> const Elm & e = data ( ) [ i ] ; <nl> - Elm & ne = mp - > data ( ) [ i ] ; <nl> + Elm & ne = map - > data ( ) [ i ] ; <nl> if ( isTombstone ( i ) ) { <nl> ne . data . m_type = e . data . m_type ; <nl> continue ; <nl> BaseMap : : php_map ( const Variant & callback , MakeArgs makeArgs ) const { <nl> } <nl> ne . ikey = e . ikey ; <nl> ne . data . hash ( ) = e . data . hash ( ) ; <nl> - mp - > incSize ( ) ; <nl> + map - > incSize ( ) ; <nl> / / Needed so that the new elements are accounted for when GC scanning . <nl> - mp - > incPosLimit ( ) ; <nl> + map - > incPosLimit ( ) ; <nl> } <nl> } <nl> - return Object { std : : move ( mp ) } ; <nl> + return Object { std : : move ( map ) } ; <nl> } <nl> <nl> Object c_ImmMap : : t_values ( ) { <nl> typename std : : enable_if < <nl> BaseMap : : php_zip ( const Variant & iterable ) const { <nl> size_t sz ; <nl> ArrayIter iter = getArrayIterHelper ( iterable , sz ) ; <nl> - auto mp = req : : make < TMap > ( ) ; <nl> + auto map = req : : make < TMap > ( ) ; <nl> if ( ! m_size ) { <nl> - return Object { std : : move ( mp ) } ; <nl> + return Object { std : : move ( map ) } ; <nl> } <nl> - mp - > reserve ( std : : min ( sz , size_t ( m_size ) ) ) ; <nl> + map - > reserve ( std : : min ( sz , size_t ( m_size ) ) ) ; <nl> uint32_t used = posLimit ( ) ; <nl> for ( uint32_t i = 0 ; i < used & & iter ; + + i ) { <nl> if ( isTombstone ( i ) ) continue ; <nl> BaseMap : : php_zip ( const Variant & iterable ) const { <nl> tv . m_data . pobj = pair . detach ( ) ; <nl> tv . m_type = KindOfObject ; <nl> if ( e . hasIntKey ( ) ) { <nl> - mp - > setRaw ( e . ikey , & tv ) ; <nl> + map - > setRaw ( e . ikey , & tv ) ; <nl> } else { <nl> assert ( e . hasStrKey ( ) ) ; <nl> - mp - > setRaw ( e . skey , & tv ) ; <nl> + map - > setRaw ( e . skey , & tv ) ; <nl> } <nl> + + iter ; <nl> } <nl> - return Object { std : : move ( mp ) } ; <nl> + return Object { std : : move ( map ) } ; <nl> } <nl> <nl> Object c_ImmMap : : t_zip ( const Variant & iterable ) { <nl> Object c_Map : : getImmutableCopy ( ) { <nl> bool BaseMap : : Equals ( EqualityFlavor eq , <nl> const ObjectData * obj1 , const ObjectData * obj2 ) { <nl> <nl> - auto mp1 = static_cast < const BaseMap * > ( obj1 ) ; <nl> - auto mp2 = static_cast < const BaseMap * > ( obj2 ) ; <nl> - auto size = mp1 - > size ( ) ; <nl> + auto map1 = static_cast < const BaseMap * > ( obj1 ) ; <nl> + auto map2 = static_cast < const BaseMap * > ( obj2 ) ; <nl> + auto size = map1 - > size ( ) ; <nl> <nl> - if ( size ! = mp2 - > size ( ) ) { return false ; } <nl> + if ( size ! = map2 - > size ( ) ) { return false ; } <nl> if ( size = = 0 ) { return true ; } <nl> <nl> switch ( eq ) { <nl> bool BaseMap : : Equals ( EqualityFlavor eq , <nl> / / obj1 and obj2 must have the exact same set of keys , and the values <nl> / / for each key must compare equal ( = = ) . This equality behavior <nl> / / matches that of = = on two PHP ( associative ) arrays . <nl> - for ( uint32_t i = 0 ; i < mp1 - > posLimit ( ) ; + + i ) { <nl> - if ( mp1 - > isTombstone ( i ) ) continue ; <nl> - const HashCollection : : Elm & e = mp1 - > data ( ) [ i ] ; <nl> + for ( uint32_t i = 0 ; i < map1 - > posLimit ( ) ; + + i ) { <nl> + if ( map1 - > isTombstone ( i ) ) continue ; <nl> + const HashCollection : : Elm & e = map1 - > data ( ) [ i ] ; <nl> TypedValue * tv2 ; <nl> if ( e . hasIntKey ( ) ) { <nl> - tv2 = mp2 - > get ( e . ikey ) ; <nl> + tv2 = map2 - > get ( e . ikey ) ; <nl> } else { <nl> assert ( e . hasStrKey ( ) ) ; <nl> - tv2 = mp2 - > get ( e . skey ) ; <nl> + tv2 = map2 - > get ( e . skey ) ; <nl> } <nl> if ( ! tv2 ) return false ; <nl> if ( ! HPHP : : equal ( tvAsCVarRef ( & e . data ) , tvAsCVarRef ( tv2 ) ) ) return false ; <nl> bool BaseMap : : Equals ( EqualityFlavor eq , <nl> / / same iteration order . <nl> uint32_t compared = 0 ; <nl> for ( uint32_t ix1 = 0 , ix2 = 0 ; <nl> - ix1 < mp1 - > posLimit ( ) & & ix2 < mp2 - > posLimit ( ) ; ) { <nl> + ix1 < map1 - > posLimit ( ) & & ix2 < map2 - > posLimit ( ) ; ) { <nl> <nl> - auto tomb1 = mp1 - > isTombstone ( ix1 ) ; <nl> - auto tomb2 = mp2 - > isTombstone ( ix2 ) ; <nl> + auto tomb1 = map1 - > isTombstone ( ix1 ) ; <nl> + auto tomb2 = map2 - > isTombstone ( ix2 ) ; <nl> <nl> if ( tomb1 | | tomb2 ) { <nl> if ( tomb1 ) { + + ix1 ; } <nl> bool BaseMap : : Equals ( EqualityFlavor eq , <nl> continue ; <nl> } <nl> <nl> - const HashCollection : : Elm & e1 = mp1 - > data ( ) [ ix1 ] ; <nl> - const HashCollection : : Elm & e2 = mp2 - > data ( ) [ ix2 ] ; <nl> + const HashCollection : : Elm & e1 = map1 - > data ( ) [ ix1 ] ; <nl> + const HashCollection : : Elm & e2 = map2 - > data ( ) [ ix2 ] ; <nl> <nl> if ( e1 . hasIntKey ( ) ) { <nl> if ( ! e2 . hasIntKey ( ) | | <nl> bool BaseSet : : ToBool ( const ObjectData * obj ) { <nl> / / already exist ) and then return it <nl> Object c_Set : : getImmutableCopy ( ) { <nl> if ( m_immCopy . isNull ( ) ) { <nl> - auto st = req : : make < c_ImmSet > ( ) ; <nl> - st - > m_size = m_size ; <nl> - st - > m_version = m_version ; <nl> - st - > m_arr = m_arr ; <nl> - st - > setIntLikeStrKeys ( intLikeStrKeys ( ) ) ; <nl> - m_immCopy = std : : move ( st ) ; <nl> + auto set = req : : make < c_ImmSet > ( ) ; <nl> + set - > m_size = m_size ; <nl> + set - > m_version = m_version ; <nl> + set - > m_arr = m_arr ; <nl> + set - > setIntLikeStrKeys ( intLikeStrKeys ( ) ) ; <nl> + m_immCopy = std : : move ( set ) ; <nl> arrayData ( ) - > incRefCount ( ) ; <nl> } <nl> assert ( ! m_immCopy . isNull ( ) ) ; <nl> Object c_Set : : t_remove ( const Variant & key ) { <nl> <nl> bool BaseSet : : OffsetIsset ( ObjectData * obj , const TypedValue * key ) { <nl> assert ( key - > m_type ! = KindOfRef ) ; <nl> - auto st = static_cast < BaseSet * > ( obj ) ; <nl> + auto set = static_cast < BaseSet * > ( obj ) ; <nl> if ( key - > m_type = = KindOfInt64 ) { <nl> - return st - > contains ( key - > m_data . num ) ; <nl> - } else if ( isStringType ( key - > m_type ) ) { <nl> - return st - > contains ( key - > m_data . pstr ) ; <nl> - } else { <nl> - throwBadValueType ( ) ; <nl> - return false ; <nl> + return set - > contains ( key - > m_data . num ) ; <nl> + } <nl> + if ( isStringType ( key - > m_type ) ) { <nl> + return set - > contains ( key - > m_data . pstr ) ; <nl> } <nl> + throwBadValueType ( ) ; <nl> + return false ; <nl> } <nl> <nl> bool BaseSet : : OffsetEmpty ( ObjectData * obj , const TypedValue * key ) { <nl> assert ( key - > m_type ! = KindOfRef ) ; <nl> - auto st = static_cast < BaseSet * > ( obj ) ; <nl> + auto set = static_cast < BaseSet * > ( obj ) ; <nl> if ( key - > m_type = = KindOfInt64 ) { <nl> - return st - > contains ( key - > m_data . num ) ? ! cellToBool ( * key ) : true ; <nl> - } else if ( isStringType ( key - > m_type ) ) { <nl> - return st - > contains ( key - > m_data . pstr ) ? ! cellToBool ( * key ) : true ; <nl> - } else { <nl> - throwBadValueType ( ) ; <nl> - return true ; <nl> + return set - > contains ( key - > m_data . num ) ? ! cellToBool ( * key ) : true ; <nl> + } <nl> + if ( isStringType ( key - > m_type ) ) { <nl> + return set - > contains ( key - > m_data . pstr ) ? ! cellToBool ( * key ) : true ; <nl> } <nl> + throwBadValueType ( ) ; <nl> + return true ; <nl> } <nl> <nl> bool BaseSet : : OffsetContains ( ObjectData * obj , const TypedValue * key ) { <nl> assert ( key - > m_type ! = KindOfRef ) ; <nl> - auto st = static_cast < BaseSet * > ( obj ) ; <nl> + auto set = static_cast < BaseSet * > ( obj ) ; <nl> if ( key - > m_type = = KindOfInt64 ) { <nl> - return st - > contains ( key - > m_data . num ) ; <nl> - } else if ( isStringType ( key - > m_type ) ) { <nl> - return st - > contains ( key - > m_data . pstr ) ; <nl> - } else { <nl> - throwBadValueType ( ) ; <nl> - return false ; <nl> + return set - > contains ( key - > m_data . num ) ; <nl> + } <nl> + if ( isStringType ( key - > m_type ) ) { <nl> + return set - > contains ( key - > m_data . pstr ) ; <nl> } <nl> + throwBadValueType ( ) ; <nl> + return false ; <nl> } <nl> <nl> void BaseSet : : OffsetUnset ( ObjectData * obj , const TypedValue * key ) { <nl> assert ( key - > m_type ! = KindOfRef ) ; <nl> - auto st = static_cast < BaseSet * > ( obj ) ; <nl> + auto set = static_cast < BaseSet * > ( obj ) ; <nl> if ( key - > m_type = = KindOfInt64 ) { <nl> - st - > remove ( key - > m_data . num ) ; <nl> + set - > remove ( key - > m_data . num ) ; <nl> return ; <nl> } <nl> if ( isStringType ( key - > m_type ) ) { <nl> - st - > remove ( key - > m_data . pstr ) ; <nl> + set - > remove ( key - > m_data . pstr ) ; <nl> return ; <nl> } <nl> throwBadValueType ( ) ; <nl> BaseSet : : php_map ( const Variant & callback , MakeArgs makeArgs ) const { <nl> SystemLib : : throwInvalidArgumentExceptionObject ( <nl> " Parameter must be a valid callback " ) ; <nl> } <nl> - auto st = req : : make < TSet > ( ) ; <nl> - if ( ! m_size ) return Object { std : : move ( st ) } ; <nl> + auto set = req : : make < TSet > ( ) ; <nl> + if ( ! m_size ) return Object { std : : move ( set ) } ; <nl> assert ( posLimit ( ) ! = 0 ) ; <nl> assert ( hashSize ( ) > 0 ) ; <nl> - assert ( st - > arrayData ( ) = = staticEmptyMixedArray ( ) ) ; <nl> - auto oldCap = st - > cap ( ) ; <nl> - st - > reserve ( posLimit ( ) ) ; / / presume minimum collisions . . . <nl> - assert ( st - > canMutateBuffer ( ) ) ; <nl> + assert ( set - > arrayData ( ) = = staticEmptyMixedArray ( ) ) ; <nl> + auto oldCap = set - > cap ( ) ; <nl> + set - > reserve ( posLimit ( ) ) ; / / presume minimum collisions . . . <nl> + assert ( set - > canMutateBuffer ( ) ) ; <nl> for ( ssize_t pos = iter_begin ( ) ; iter_valid ( pos ) ; pos = iter_next ( pos ) ) { <nl> auto * e = iter_elm ( pos ) ; <nl> TypedValue tvCbRet ; <nl> BaseSet : : php_map ( const Variant & callback , MakeArgs makeArgs ) const { <nl> / / Now that tvCbRet is live , make sure to decref even if we throw . <nl> SCOPE_EXIT { tvRefcountedDecRef ( & tvCbRet ) ; } ; <nl> if ( UNLIKELY ( m_version ! = pVer ) ) throw_collection_modified ( ) ; <nl> - st - > addRaw ( & tvCbRet ) ; <nl> + set - > addRaw ( & tvCbRet ) ; <nl> } <nl> / / . . . and shrink back if that was incorrect <nl> - st - > shrinkIfCapacityTooHigh ( oldCap ) ; <nl> - return Object { std : : move ( st ) } ; <nl> + set - > shrinkIfCapacityTooHigh ( oldCap ) ; <nl> + return Object { std : : move ( set ) } ; <nl> } <nl> <nl> template < typename TSet , class MakeArgs > <nl> mmm a / hphp / runtime / ext / collections / ext_collections - idl . h <nl> ppp b / hphp / runtime / ext / collections / ext_collections - idl . h <nl> class BaseMap : public HashCollection { <nl> template < bool throwOnMiss > <nl> static TypedValue * OffsetAt ( ObjectData * obj , const TypedValue * key ) { <nl> assertx ( key - > m_type ! = KindOfRef ) ; <nl> - auto mp = static_cast < BaseMap * > ( obj ) ; <nl> + auto map = static_cast < BaseMap * > ( obj ) ; <nl> if ( key - > m_type = = KindOfInt64 ) { <nl> - return throwOnMiss ? mp - > at ( key - > m_data . num ) <nl> - : mp - > get ( key - > m_data . num ) ; <nl> + return throwOnMiss ? map - > at ( key - > m_data . num ) <nl> + : map - > get ( key - > m_data . num ) ; <nl> } <nl> if ( isStringType ( key - > m_type ) ) { <nl> - return throwOnMiss ? mp - > at ( key - > m_data . pstr ) <nl> - : mp - > get ( key - > m_data . pstr ) ; <nl> + return throwOnMiss ? map - > at ( key - > m_data . pstr ) <nl> + : map - > get ( key - > m_data . pstr ) ; <nl> } <nl> throwBadKeyType ( ) ; <nl> return nullptr ; <nl> class BaseSet : public HashCollection { <nl> template < bool throwOnMiss > <nl> static TypedValue * OffsetAt ( ObjectData * obj , const TypedValue * key ) { <nl> assertx ( key - > m_type ! = KindOfRef ) ; <nl> - auto st = static_cast < BaseSet * > ( obj ) ; <nl> + auto set = static_cast < BaseSet * > ( obj ) ; <nl> ssize_t p ; <nl> if ( key - > m_type = = KindOfInt64 ) { <nl> - p = st - > find ( key - > m_data . num ) ; <nl> + p = set - > find ( key - > m_data . num ) ; <nl> } else if ( isStringType ( key - > m_type ) ) { <nl> - p = st - > find ( key - > m_data . pstr , key - > m_data . pstr - > hash ( ) ) ; <nl> + p = set - > find ( key - > m_data . pstr , key - > m_data . pstr - > hash ( ) ) ; <nl> } else { <nl> BaseSet : : throwBadValueType ( ) ; <nl> } <nl> if ( LIKELY ( p ! = Empty ) ) { <nl> - return reinterpret_cast < TypedValue * > ( & st - > data ( ) [ p ] . data ) ; <nl> + return reinterpret_cast < TypedValue * > ( & set - > data ( ) [ p ] . data ) ; <nl> } <nl> if ( ! throwOnMiss ) { <nl> return nullptr ; <nl>
buy a vowel for collections
facebook/hhvm
b40aa18e76560cc2f23e80f169129bd5d61bb9d1
2015-09-02T01:01:55Z
mmm a / stdlib / public / core / SIMDVector . swift <nl> ppp b / stdlib / public / core / SIMDVector . swift <nl> where T : SIMD , T . Scalar : FloatingPoint { <nl> } <nl> return result <nl> } <nl> + <nl> + / / Break the ambiguity between AdditiveArithmetic and SIMD for + = and - = <nl> + extension SIMD where Self : AdditiveArithmetic , Self . Scalar : FloatingPoint { <nl> + @ _alwaysEmitIntoClient <nl> + public static func + = ( lhs : inout Self , rhs : Self ) { <nl> + lhs = lhs + rhs <nl> + } <nl> + <nl> + @ _alwaysEmitIntoClient <nl> + public static func - = ( lhs : inout Self , rhs : Self ) { <nl> + lhs = lhs - rhs <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 000000000000 . . f2641a396c7e <nl> mmm / dev / null <nl> ppp b / test / stdlib / SIMD_as_AdditiveArithmetic . swift <nl> <nl> + / / RUN : % target - typecheck - verify - swift <nl> + extension SIMD2 : AdditiveArithmetic where Scalar : FloatingPoint { } <nl> + extension SIMD3 : AdditiveArithmetic where Scalar : FloatingPoint { } <nl> + extension SIMD4 : AdditiveArithmetic where Scalar : FloatingPoint { } <nl> + extension SIMD8 : AdditiveArithmetic where Scalar : FloatingPoint { } <nl>
Merge pull request from DougGregor / simd - as - additivearithmetic
apple/swift
c5ae17d5445495622cd4995ecff419b672cca9b8
2019-09-13T05:47:06Z
mmm a / modules / ml / doc / ml_intro . markdown <nl> ppp b / modules / ml / doc / ml_intro . markdown <nl> components : <nl> vector responses . <nl> - Another optional component is the mask of missing measurements . Most algorithms require all the <nl> components in all the training samples be valid , but some other algorithms , such as decision <nl> - tress , can handle the cases of missing measurements . <nl> + trees , can handle the cases of missing measurements . <nl> - In the case of classification problem user may want to give different weights to different <nl> classes . This is useful , for example , when : <nl> - user wants to shift prediction accuracy towards lower false - alarm rate or higher hit - rate . <nl>
Merge pull request from unrandomness : master
opencv/opencv
b7ca3d77a6732d1f999f391f7f873ba33235f4b4
2019-05-01T22:00:02Z
mmm a / setup . py <nl> ppp b / setup . py <nl> def _is_ndk_root_valid ( self , ndk_root ) : <nl> if not ndk_root : <nl> return False <nl> <nl> - ndk_build_path = os . path . join ( ndk_root , ' ndk - build ' ) <nl> + if self . _isWindows ( ) : <nl> + ndk_build_path = os . path . join ( ndk_root , ' ndk - build . cmd ' ) <nl> + else : <nl> + ndk_build_path = os . path . join ( ndk_root , ' ndk - build ' ) <nl> + <nl> if os . path . isfile ( ndk_build_path ) : <nl> return True <nl> else : <nl>
Change the implementation of checking NDK path on windows .
cocos2d/cocos2d-x
c2d930df0032beb7dfe153d41a6249e761e40aa0
2016-06-23T09:09:07Z
mmm a / test / Parse / foreach . swift <nl> ppp b / test / Parse / foreach . swift <nl> func for_each ( r : Range < Int > , iir : IntRange < Int > ) { <nl> var sum = 0 <nl> <nl> / / Simple foreach loop , using the variable in the body <nl> - for i in r { <nl> + for i in RangeOfStrideable ( r ) { <nl> sum = sum + i <nl> } <nl> / / Check scoping of variable introduced with foreach loop <nl> func for_each ( r : Range < Int > , iir : IntRange < Int > ) { <nl> / / Parse errors <nl> for i r { / / expected - error 2 { { expected ' ; ' in ' for ' statement } } expected - error { { use of unresolved identifier ' i ' } } expected - error { { type ' Range < Int > ' does not conform to protocol ' Boolean ' } } <nl> } <nl> - for i in r sum = sum + i ; / / expected - error { { expected ' { ' to start the body of for - each loop } } <nl> + for i in RangeOfStrideable ( r ) sum = sum + i ; / / expected - error { { expected ' { ' to start the body of for - each loop } } <nl> } <nl>
New indexing model : fix test / Parse / foreach . swift
apple/swift
4ea9db7959fea566b1358ec3589c65cf7874d0a2
2016-03-15T02:40:21Z
mmm a / src / codegen / mips / macro - assembler - mips . cc <nl> ppp b / src / codegen / mips / macro - assembler - mips . cc <nl> void TurboAssembler : : Call ( Handle < Code > code , RelocInfo : : Mode rmode , <nl> } <nl> <nl> DCHECK ( RelocInfo : : IsCodeTarget ( rmode ) ) ; <nl> + DCHECK ( code - > IsExecutable ( ) ) ; <nl> Call ( code . address ( ) , rmode , cond , rs , rt , bd ) ; <nl> } <nl> <nl> void MacroAssembler : : DecrementCounter ( StatsCounter * counter , int value , <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> / / Debugging . <nl> <nl> + void TurboAssembler : : Trap ( ) { stop ( ) ; } <nl> + <nl> void TurboAssembler : : Assert ( Condition cc , AbortReason reason , Register rs , <nl> Operand rt ) { <nl> if ( emit_debug_code ( ) ) Check ( cc , reason , rs , rt ) ; <nl> mmm a / src / codegen / mips / macro - assembler - mips . h <nl> ppp b / src / codegen / mips / macro - assembler - mips . h <nl> class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase { <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> / / Debugging . <nl> <nl> + void Trap ( ) override ; <nl> + <nl> / / Calls Abort ( msg ) if the condition cc is not satisfied . <nl> / / Use - - debug_code to enable . <nl> void Assert ( Condition cc , AbortReason reason , Register rs , Operand rt ) ; <nl> mmm a / src / codegen / mips64 / macro - assembler - mips64 . cc <nl> ppp b / src / codegen / mips64 / macro - assembler - mips64 . cc <nl> void TurboAssembler : : Call ( Handle < Code > code , RelocInfo : : Mode rmode , <nl> } <nl> <nl> DCHECK ( RelocInfo : : IsCodeTarget ( rmode ) ) ; <nl> + DCHECK ( code - > IsExecutable ( ) ) ; <nl> Call ( code . address ( ) , rmode , cond , rs , rt , bd ) ; <nl> } <nl> <nl> void MacroAssembler : : DecrementCounter ( StatsCounter * counter , int value , <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> / / Debugging . <nl> <nl> + void TurboAssembler : : Trap ( ) { stop ( ) ; } <nl> + <nl> void TurboAssembler : : Assert ( Condition cc , AbortReason reason , Register rs , <nl> Operand rt ) { <nl> if ( emit_debug_code ( ) ) Check ( cc , reason , rs , rt ) ; <nl> mmm a / src / codegen / mips64 / macro - assembler - mips64 . h <nl> ppp b / src / codegen / mips64 / macro - assembler - mips64 . h <nl> class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase { <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> / / Debugging . <nl> <nl> + void Trap ( ) override ; <nl> + <nl> / / Calls Abort ( msg ) if the condition cc is not satisfied . <nl> / / Use - - debug_code to enable . <nl> void Assert ( Condition cc , AbortReason reason , Register rs , Operand rt ) ; <nl>
[ mips ] [ builtins ] Move non - JS linkage builtins code objects into RO_SPACE
v8/v8
c8dfd2cf4a4a2c79d3089a8df789850937a1a172
2019-11-05T16:17:10Z
mmm a / include / swift / AST / Builtins . def <nl> ppp b / include / swift / AST / Builtins . def <nl> BUILTIN_SIL_OPERATION ( CondFail , " condfail " , Special ) <nl> BUILTIN ( Id , Name , Attrs ) <nl> # endif <nl> <nl> - / / / Sizeof has type ( metatype < T > ) - > Int64 <nl> + / / / Sizeof has type ( metatype < T > ) - > Int <nl> BUILTIN_MISC_OPERATION ( Sizeof , " sizeof " , " n " , Special ) <nl> <nl> - / / / Strideof has type ( metatype < T > ) - > Int64 <nl> + / / / Strideof has type ( metatype < T > ) - > Int <nl> BUILTIN_MISC_OPERATION ( Strideof , " strideof " , " n " , Special ) <nl> <nl> - / / / Alignof has type ( metatype < T > ) - > Int64 <nl> + / / / Alignof has type ( metatype < T > ) - > Int <nl> BUILTIN_MISC_OPERATION ( Alignof , " alignof " , " n " , Special ) <nl> <nl> - / / / AllocRaw has type ( Int64 , Int64 ) - > Builtin . RawPointer <nl> + / / / AllocRaw has type ( Int , Int ) - > Builtin . RawPointer <nl> BUILTIN_MISC_OPERATION ( AllocRaw , " allocRaw " , " " , Special ) <nl> <nl> - / / / DeallocRaw has type ( Builtin . RawPointer , Int64 ) - > ( ) <nl> + / / / DeallocRaw has type ( Builtin . RawPointer , Int ) - > ( ) <nl> BUILTIN_MISC_OPERATION ( DeallocRaw , " deallocRaw " , " " , Special ) <nl> <nl> / / / Fence has type ( ) - > ( ) . <nl> mmm a / include / swift / Runtime / Alloc . h <nl> ppp b / include / swift / Runtime / Alloc . h <nl> struct HeapObject { <nl> <nl> uint32_t refCount ; <nl> uint32_t weakRefCount ; <nl> - # ifndef __LP64__ <nl> - # error " FIXME - - allocate two words of metadata on 32 - bit platforms " <nl> - # endif <nl> + / / FIXME : allocate two words of metadata on 32 - bit platforms <nl> } ; <nl> <nl> / / / Allocates a new heap object . The returned memory is <nl> extern " C " BoxPair swift_allocBox ( Metadata const * type ) ; <nl> / / For example , a 12 byte allocation with 8 byte alignment becomes 16 . <nl> # define SWIFT_TRYALLOC 0x0001 <nl> # define SWIFT_RAWALLOC 0x0002 <nl> - extern " C " void * swift_slowAlloc ( size_t bytes , uint64_t flags ) ; <nl> + extern " C " void * swift_slowAlloc ( size_t bytes , uintptr_t flags ) ; <nl> <nl> / / These exist as fast entry points for the above slow API . <nl> / / <nl> mmm a / lib / IRGen / OptimizeARC . cpp <nl> ppp b / lib / IRGen / OptimizeARC . cpp <nl> static bool performARCExpansion ( Function & F ) { <nl> / / Scan through all the returns to see if there are any that can be optimized . <nl> / / FIXME : swift_retainAndReturnThree runtime call <nl> / / is currently implemented only on x86_64 . <nl> + / / FIXME : optimizeReturn3 ( ) implementation assumes 64 - bit <nl> if ( llvm : : Triple ( F . getParent ( ) - > getTargetTriple ( ) ) . getArchName ( ) = = " x86_64 " ) <nl> for ( ReturnInst * RI : Returns ) <nl> Changed | = optimizeReturn3 ( RI ) ; <nl> mmm a / stdlib / objc / Foundation / Misc . mm <nl> ppp b / stdlib / objc / Foundation / Misc . mm <nl> <nl> return x = = y ; <nl> } <nl> <nl> - / / FIXME : Assumes Int is 64 - bit . <nl> - extern " C " int64_t swift_hashObject ( id obj ) { <nl> + extern " C " intptr_t swift_hashObject ( id obj ) { <nl> [ obj release ] ; <nl> - return ( int64_t ) obj ; <nl> + return ( intptr_t ) obj ; <nl> } <nl> mmm a / stdlib / runtime / Alloc . cpp <nl> ppp b / stdlib / runtime / Alloc . cpp <nl> swift : : swift_allocObject ( HeapMetadata const * metadata , <nl> / / / occupies < size > bytes of maximally - aligned storage . The object is <nl> / / / uninitialized except for its header . <nl> extern " C " HeapObject * swift_bufferAllocate ( <nl> - HeapMetadata const * bufferType , int64_t size ) <nl> + HeapMetadata const * bufferType , intptr_t size ) <nl> { <nl> return swift : : swift_allocObject ( bufferType , size , 0 ) ; <nl> } <nl> <nl> - extern " C " int64_t swift_bufferHeaderSize ( ) { return sizeof ( HeapObject ) ; } <nl> + extern " C " intptr_t swift_bufferHeaderSize ( ) { return sizeof ( HeapObject ) ; } <nl> <nl> / / / A do - nothing destructor for POD metadata . <nl> static void destroyPOD ( HeapObject * ) { } <nl> void swift : : swift_deallocObject ( HeapObject * object , size_t allocatedSize ) { <nl> <nl> __attribute__ ( ( noinline , used ) ) <nl> static void * <nl> - _swift_slowAlloc_fixup ( AllocIndex idx , uint64_t flags ) <nl> + _swift_slowAlloc_fixup ( AllocIndex idx , uintptr_t flags ) <nl> { <nl> size_t sz ; <nl> <nl> _swift_slowAlloc_fixup ( AllocIndex idx , uint64_t flags ) <nl> } <nl> <nl> extern " C " LLVM_LIBRARY_VISIBILITY <nl> - void _swift_refillThreadAllocCache ( AllocIndex idx , uint64_t flags ) { <nl> + void _swift_refillThreadAllocCache ( AllocIndex idx , uintptr_t flags ) { <nl> void * tmp = _swift_slowAlloc_fixup ( idx , flags ) ; <nl> if ( ! tmp ) { <nl> return ; <nl> void _swift_refillThreadAllocCache ( AllocIndex idx , uint64_t flags ) { <nl> } <nl> } <nl> <nl> - void * swift : : swift_slowAlloc ( size_t bytes , uint64_t flags ) { <nl> + void * swift : : swift_slowAlloc ( size_t bytes , uintptr_t flags ) { <nl> void * r ; <nl> <nl> do { <nl> mmm a / stdlib / runtime / BlockShims . mm <nl> ppp b / stdlib / runtime / BlockShims . mm <nl> static block_type shim ( code_type code , HeapObject * context ) { <nl> VOID ) , <nl> void ( void ) ) ; <nl> <nl> - / / / ( int64_t ) - > Void <nl> + / / / ( Int ) - > Void <nl> MAKE_BLOCK_SHIM ( FUNC ( DIRECT ( Si ) , <nl> VOID ) , <nl> - void ( int64_t ) ) ; <nl> + void ( NSInteger ) ) ; <nl> <nl> / / / NSDictionary enumerator <nl> / / / ( id , id , UnsafePointer < BOOL > ) - > Void <nl> mmm a / stdlib / runtime / Stubs . cpp <nl> ppp b / stdlib / runtime / Stubs . cpp <nl> <nl> <nl> / / type func String ( v : Int64 , radix : Int ) - > String <nl> extern " C " <nl> - unsigned long long <nl> - print_int ( char * TmpBuffer , __int64_t buf_len , __int64_t X , uint64_t Radix , <nl> + uint64_t <nl> + print_int ( char * TmpBuffer , intptr_t buf_len , int64_t X , intptr_t Radix , <nl> bool uppercase ) { <nl> assert ( Radix ! = 0 & & Radix < = 36 & & " Invalid radix for string conversion " ) ; <nl> char * P = TmpBuffer ; <nl> print_int ( char * TmpBuffer , __int64_t buf_len , __int64_t X , uint64_t Radix , <nl> <nl> / / type func String ( v : UInt64 , radix : Int ) - > String <nl> extern " C " <nl> - unsigned long long <nl> - print_uint ( char * TmpBuffer , __int64_t buf_len , __uint64_t Y , uint64_t Radix , <nl> + uint64_t <nl> + print_uint ( char * TmpBuffer , intptr_t buf_len , uint64_t Y , intptr_t Radix , <nl> bool uppercase ) { <nl> assert ( Radix ! = 0 & & Radix < = 36 & & " Invalid radix for string conversion " ) ; <nl> char * P = TmpBuffer ; <nl> print_uint ( char * TmpBuffer , __int64_t buf_len , __uint64_t Y , uint64_t Radix , <nl> <nl> / / type func String ( v : Double ) - > String <nl> extern " C " <nl> - unsigned long long <nl> + uint64_t <nl> print_double ( char * Buffer , double X ) { <nl> long long i = sprintf ( Buffer , " % g " , X ) ; <nl> / / Add " . 0 " to a float that ( a ) is not in scientific notation , ( b ) does not <nl> print_double ( char * Buffer , double X ) { <nl> / / FIXME : We shouldn ' t be writing implemenetations for functions in the swift <nl> / / module in C , and this isn ' t really an ideal place to put those <nl> / / implementations . <nl> - extern " C " void _TSs5printFT3valSi_T_ ( int64_t l ) { <nl> + extern " C " void print_Int64 ( int64_t l ) { <nl> printf ( " % lld " , l ) ; <nl> } <nl> <nl> - extern " C " void _TSs5printFT3valSu_T_ ( uint64_t l ) { <nl> + extern " C " void print_UInt64 ( uint64_t l ) { <nl> printf ( " % llu " , l ) ; <nl> } <nl> <nl> - extern " C " void _TSs5printFT3valSd_T_ ( double l ) { <nl> + extern " C " void print_Double ( double l ) { <nl> char Buffer [ 256 ] ; <nl> - unsigned long long i = print_double ( Buffer , l ) ; <nl> + uint64_t i = print_double ( Buffer , l ) ; <nl> Buffer [ i ] = ' \ 0 ' ; <nl> printf ( " % s " , Buffer ) ; <nl> } <nl> swift_replOutputIsUTF8 ( void ) { <nl> return rval ; <nl> } <nl> <nl> - extern " C " <nl> - int <nl> - swift_file_open ( const char * filename ) <nl> - { <nl> - return open ( filename , O_RDONLY ) ; <nl> - } <nl> - <nl> - extern " C " <nl> - int <nl> - swift_file_close ( int fd ) <nl> - { <nl> - return close ( fd ) ; <nl> - } <nl> - <nl> - extern " C " <nl> - size_t <nl> - swift_file_read ( int fd , char * buf , size_t nb ) <nl> - { <nl> - return read ( fd , buf , nb ) ; <nl> - } <nl> - <nl> - extern " C " <nl> - size_t <nl> - swift_fd_size ( int fd ) <nl> - { <nl> - struct stat buf ; <nl> - int err = fstat ( fd , & buf ) ; <nl> - assert ( err = = 0 ) ; <nl> - ( void ) err ; <nl> - return buf . st_size ; <nl> - } <nl> - <nl> - struct readdir_tuple_s { <nl> - char * str ; <nl> - int64_t len ; <nl> - } ; <nl> - <nl> - extern " C " <nl> - struct readdir_tuple_s <nl> - posix_readdir_hack ( DIR * d ) <nl> - { <nl> - struct readdir_tuple_s rval = { NULL , 0 } ; <nl> - struct dirent * dp ; <nl> - if ( ( dp = readdir ( d ) ) ) { <nl> - rval . str = dp - > d_name ; <nl> - rval . len = dp - > d_namlen ; <nl> - } <nl> - return rval ; <nl> - } <nl> - <nl> - extern " C " <nl> - int64_t <nl> - posix_isDirectory_hack ( const char * path ) <nl> - { <nl> - struct stat sb ; <nl> - int r = stat ( path , & sb ) ; <nl> - ( void ) r ; <nl> - assert ( r ! = - 1 ) ; <nl> - return S_ISDIR ( sb . st_mode ) ; <nl> - } <nl> - <nl> - extern " C " <nl> - int <nl> - posix_get_errno ( void ) <nl> - { <nl> - return errno ; / / errno is not a global , but a macro <nl> - } <nl> - <nl> - extern " C " <nl> - void <nl> - posix_set_errno ( int value ) <nl> - { <nl> - errno = value ; / / errno is not a global , but a macro <nl> - } <nl> - <nl> # if __arm64__ <nl> <nl> / / FIXME : rdar : / / 14883575 Libcompiler_rt omits muloti4 <nl>
Clena up some 32 / 64 mismatches . Remove some dead posix stubs .
apple/swift
95c2fc43f84abdc7a1a2bf134483ecd8a04611f8
2014-01-30T09:34:26Z
mmm a / include / swift / Parse / Parser . h <nl> ppp b / include / swift / Parse / Parser . h <nl> class Parser { <nl> ParsedAccessors & accessors , <nl> AbstractStorageDecl * storage , <nl> SourceLoc StaticLoc ) ; <nl> - ParserResult < VarDecl > parseDeclVarGetSet ( Pattern * pattern , <nl> + ParserResult < VarDecl > parseDeclVarGetSet ( PatternBindingEntry & entry , <nl> ParseDeclOptions Flags , <nl> SourceLoc StaticLoc , <nl> StaticSpellingKind StaticSpelling , <nl> mmm a / lib / IDE / SyntaxModel . cpp <nl> ppp b / lib / IDE / SyntaxModel . cpp <nl> bool ModelASTWalker : : walkToDeclPre ( Decl * D ) { <nl> if ( bracesRange . isValid ( ) ) <nl> SN . BodyRange = innerCharSourceRangeFromSourceRange ( SM , bracesRange ) ; <nl> SourceLoc NRStart = VD - > getNameLoc ( ) ; <nl> - SourceLoc NREnd = NRStart . getAdvancedLoc ( VD - > getName ( ) . getLength ( ) ) ; <nl> + SourceLoc NREnd = ( ! VD - > getName ( ) . empty ( ) <nl> + ? NRStart . getAdvancedLoc ( VD - > getName ( ) . getLength ( ) ) <nl> + : NRStart ) ; <nl> SN . NameRange = CharSourceRange ( SM , NRStart , NREnd ) ; <nl> SN . TypeRange = charSourceRangeFromSourceRange ( SM , <nl> VD - > getTypeSourceRangeForDiagnostics ( ) ) ; <nl> mmm a / lib / Parse / ParseDecl . cpp <nl> ppp b / lib / Parse / ParseDecl . cpp <nl> ParserStatus Parser : : parseGetSet ( ParseDeclOptions Flags , <nl> <nl> / / / Parse the brace - enclosed getter and setter for a variable . <nl> ParserResult < VarDecl > <nl> - Parser : : parseDeclVarGetSet ( Pattern * pattern , ParseDeclOptions Flags , <nl> + Parser : : parseDeclVarGetSet ( PatternBindingEntry & entry , ParseDeclOptions Flags , <nl> SourceLoc StaticLoc , <nl> StaticSpellingKind StaticSpelling , <nl> SourceLoc VarLoc , bool hasInitializer , <nl> const DeclAttributes & Attributes , <nl> SmallVectorImpl < Decl * > & Decls ) { <nl> bool Invalid = false ; <nl> - <nl> + <nl> + auto * pattern = entry . getPattern ( ) ; <nl> + <nl> / / The grammar syntactically requires a simple identifier for the variable <nl> / / name . Complain if that isn ' t what we got . But for recovery purposes , <nl> / / make an effort to look through other things anyway . <nl> Parser : : parseDeclVarGetSet ( Pattern * pattern , ParseDeclOptions Flags , <nl> VarDecl : : Introducer : : Var , <nl> VarLoc , Identifier ( ) , <nl> CurDeclContext ) ; <nl> - storage - > setImplicit ( true ) ; <nl> storage - > setInvalid ( ) ; <nl> <nl> - Pattern * pattern = <nl> + pattern = <nl> TypedPattern : : createImplicit ( Context , new ( Context ) NamedPattern ( storage ) , <nl> ErrorType : : get ( Context ) ) ; <nl> - PatternBindingEntry entry ( pattern , / * EqualLoc * / SourceLoc ( ) , <nl> - / * Init * / nullptr , / * InitContext * / nullptr ) ; <nl> - auto binding = PatternBindingDecl : : create ( Context , StaticLoc , <nl> - StaticSpelling , <nl> - VarLoc , entry , CurDeclContext ) ; <nl> - binding - > setInvalid ( ) ; <nl> - storage - > setParentPatternBinding ( binding ) ; <nl> - <nl> - Decls . push_back ( binding ) ; <nl> - Decls . push_back ( storage ) ; <nl> + entry . setPattern ( pattern ) ; <nl> } <nl> <nl> / / Parse getter and setter . <nl> Parser : : parseDeclVar ( ParseDeclOptions Flags , <nl> if ( Tok . is ( tok : : l_brace ) ) { <nl> HasAccessors = true ; <nl> auto boundVar = <nl> - parseDeclVarGetSet ( pattern , Flags , StaticLoc , StaticSpelling , VarLoc , <nl> + parseDeclVarGetSet ( PBDEntries . back ( ) , <nl> + Flags , StaticLoc , StaticSpelling , VarLoc , <nl> PatternInit ! = nullptr , Attributes , Decls ) ; <nl> if ( boundVar . hasCodeCompletion ( ) ) <nl> return makeResult ( makeParserCodeCompletionStatus ( ) ) ; <nl> mmm a / test / Index / invalid_code . swift <nl> ppp b / test / Index / invalid_code . swift <nl> <nl> / / RUN : % target - swift - ide - test - print - indexed - symbols - include - locals - source - filename % s | % FileCheck % s <nl> <nl> - / / CHECK : [ [ @ LINE + 1 ] ] : 8 | struct / Swift | Int | { { . * } } | Ref | rel : 0 <nl> var _ : Int { get { return 1 } } <nl> <nl> func test ( ) { <nl> mmm a / test / Parse / pattern_without_variables . swift <nl> ppp b / test / Parse / pattern_without_variables . swift <nl> func testVarLetPattern ( a : SimpleEnum ) { <nl> <nl> class SR10903 { <nl> static var _ : Int { 0 } / / expected - error { { getter / setter can only be defined for a single variable } } <nl> - / / expected - error @ - 1 { { property declaration does not bind any variables } } <nl> } <nl> mmm a / test / SourceKit / DocumentStructure / structure . swift . foobar . response <nl> ppp b / test / SourceKit / DocumentStructure / structure . swift . foobar . response <nl> <nl> key . kind : source . lang . swift . decl . var . global , <nl> key . accessibility : source . lang . swift . accessibility . internal , <nl> key . setter_accessibility : source . lang . swift . accessibility . internal , <nl> - key . name : " Qtys " , <nl> key . offset : 1079 , <nl> - key . length : 15 , <nl> - key . nameoffset : 1089 , <nl> - key . namelength : 4 <nl> + key . length : 3 , <nl> + key . nameoffset : 1079 , <nl> + key . namelength : 0 <nl> } , <nl> { <nl> key . kind : source . lang . swift . stmt . foreach , <nl> mmm a / test / SourceKit / DocumentStructure / structure . swift . response <nl> ppp b / test / SourceKit / DocumentStructure / structure . swift . response <nl> <nl> key . kind : source . lang . swift . decl . var . global , <nl> key . accessibility : source . lang . swift . accessibility . internal , <nl> key . setter_accessibility : source . lang . swift . accessibility . internal , <nl> - key . name : " Qtys " , <nl> key . offset : 1079 , <nl> - key . length : 15 , <nl> - key . nameoffset : 1089 , <nl> - key . namelength : 4 <nl> + key . length : 3 , <nl> + key . nameoffset : 1079 , <nl> + key . namelength : 0 <nl> } , <nl> { <nl> key . kind : source . lang . swift . stmt . foreach , <nl>
Parse : Don ' t create PatternBindingDecls with overlapping source ranges
apple/swift
fa4f7dd664e5745e31214ee5e9729ae33b391f80
2020-09-22T04:16:54Z
mmm a / lib / Parser / Parser . cpp <nl> ppp b / lib / Parser / Parser . cpp <nl> ParseResult AffineParser : : parseAffineMapOrIntegerSetInline ( AffineMap & map , <nl> bool isArrow = getToken ( ) . is ( Token : : arrow ) ; <nl> bool isColon = getToken ( ) . is ( Token : : colon ) ; <nl> if ( ! isArrow & & ! isColon ) { <nl> - return ParseFailure ; <nl> + return emitError ( " expected ' - > ' or ' : ' " ) ; <nl> } else if ( isArrow ) { <nl> parseToken ( Token : : arrow , " expected ' - > ' or ' [ ' " ) ; <nl> map = parseAffineMapRange ( numDims , numSymbols ) ; <nl> mmm a / test / IR / invalid . mlir <nl> ppp b / test / IR / invalid . mlir <nl> func @ invalid_tensor_literal ( ) { <nl> / / mmm - - <nl> <nl> # set_without_constraints = ( i , j ) : ( ) / / expected - error { { expected a valid affine constraint } } <nl> + <nl> + / / mmm - - <nl> + <nl> + func @ invalid_affine_structure ( ) { <nl> + % c0 = constant 0 : index <nl> + % idx = affine_apply ( d0 , d1 ) ( % c0 , % c0 ) / / expected - error { { expected ' - > ' or ' : ' } } <nl> + return <nl> + } <nl>
Emit an error when parsing an affine structure if ' - > ' or ' : ' is not found
tensorflow/tensorflow
a5fb5854212df122b0f65e7ecf3c80d8b4ba30ce
2019-03-29T23:07:40Z
mmm a / etc / evergreen . yml <nl> ppp b / etc / evergreen . yml <nl> functions : <nl> set - o igncr <nl> fi ; <nl> <nl> - git checkout osx - 3 . 3 - ssl <nl> + git checkout r3 . 3 . 4 <nl> . . / $ { set_tools_gopath | set_gopath . sh } <nl> <nl> # In RHEL 5 . 5 , / usr / bin / ld can ' t handle - - build - id parameters , so <nl>
bump tools to 3 . 3 . 4
mongodb/mongo
9418954cb5c6dc12d2ac1b24c61898f10076fb93
2016-04-04T21:18:49Z
mmm a / dlib / image_transforms / fhog . h <nl> ppp b / dlib / image_transforms / fhog . h <nl> namespace dlib <nl> > <nl> matrix < unsigned char > draw_fhog ( <nl> const dlib : : array < array2d < T , mm1 > , mm2 > & hog , <nl> - const long cell_draw_size = 15 <nl> + const long cell_draw_size = 15 , <nl> + const float min_response_threshold = 0 . 0 <nl> ) <nl> { <nl> / / make sure requires clause is not broken <nl> namespace dlib <nl> const float val = hog [ d ] [ r / cell_draw_size ] [ c / cell_draw_size ] + <nl> hog [ d + mbars . size ( ) ] [ r / cell_draw_size ] [ c / cell_draw_size ] + <nl> hog [ d + mbars . size ( ) * 2 ] [ r / cell_draw_size ] [ c / cell_draw_size ] ; <nl> - if ( val > 0 ) <nl> + if ( val > min_response_threshold ) <nl> { <nl> set_subm ( himg , r , c , cell_draw_size , cell_draw_size ) + = val * mbars [ d % mbars . size ( ) ] ; <nl> } <nl> namespace dlib <nl> > <nl> matrix < unsigned char > draw_fhog ( <nl> const std : : vector < matrix < T > > & hog , <nl> - const long cell_draw_size = 15 <nl> + const long cell_draw_size = 15 , <nl> + const float min_response_threshold = 0 . 0 <nl> ) <nl> { <nl> / / make sure requires clause is not broken <nl> namespace dlib <nl> } <nl> } <nl> } <nl> - return draw_fhog ( temp , cell_draw_size ) ; <nl> + return draw_fhog ( temp , cell_draw_size , min_response_threshold ) ; <nl> } <nl> <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> namespace dlib <nl> > <nl> matrix < unsigned char > draw_fhog ( <nl> const array2d < matrix < T , 31 , 1 > , mm > & hog , <nl> - const long cell_draw_size = 15 <nl> + const long cell_draw_size = 15 , <nl> + const float min_response_threshold = 0 . 0 <nl> ) <nl> { <nl> / / make sure requires clause is not broken <nl> namespace dlib <nl> const float val = hog [ r / cell_draw_size ] [ c / cell_draw_size ] ( d ) + <nl> hog [ r / cell_draw_size ] [ c / cell_draw_size ] ( d + mbars . size ( ) ) + <nl> hog [ r / cell_draw_size ] [ c / cell_draw_size ] ( d + mbars . size ( ) * 2 ) ; <nl> - if ( val > 0 ) <nl> + if ( val > min_response_threshold ) <nl> { <nl> set_subm ( himg , r , c , cell_draw_size , cell_draw_size ) + = val * mbars [ d % mbars . size ( ) ] ; <nl> } <nl> mmm a / dlib / image_transforms / fhog_abstract . h <nl> ppp b / dlib / image_transforms / fhog_abstract . h <nl> namespace dlib <nl> > <nl> matrix < unsigned char > draw_fhog ( <nl> const dlib : : array < array2d < T , mm1 > , mm2 > & hog , <nl> - const long cell_draw_size = 15 <nl> + const long cell_draw_size = 15 , <nl> + const float min_response_threshold = 0 . 0 <nl> ) ; <nl> / * ! <nl> requires <nl> namespace dlib <nl> then returned . <nl> - The size of the cells in the output image will be rendered as cell_draw_size <nl> pixels wide and tall . <nl> + - HOG cells with a response value less than min_response_threshold are not <nl> + drawn . <nl> ! * / <nl> <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> namespace dlib <nl> > <nl> matrix < unsigned char > draw_fhog ( <nl> const std : : vector < matrix < T > > & hog , <nl> - const long cell_draw_size = 15 <nl> + const long cell_draw_size = 15 , <nl> + const float min_response_threshold = 0 . 0 <nl> ) ; <nl> / * ! <nl> requires <nl> namespace dlib <nl> ensures <nl> - This function just converts the given hog object into an array < array2d < T > > <nl> and passes it to the above draw_fhog ( ) routine and returns the results . <nl> + - HOG cells with a response value less than min_response_threshold are not <nl> + drawn . <nl> ! * / <nl> <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> namespace dlib <nl> > <nl> matrix < unsigned char > draw_fhog ( <nl> const array2d < matrix < T , 31 , 1 > , mm > & hog , <nl> - const long cell_draw_size = 15 <nl> + const long cell_draw_size = 15 , <nl> + const float min_response_threshold = 0 . 0 <nl> ) ; <nl> / * ! <nl> requires <nl> namespace dlib <nl> then returned . <nl> - The size of the cells in the output image will be rendered as cell_draw_size <nl> pixels wide and tall . <nl> + - HOG cells with a response value less than min_response_threshold are not <nl> + drawn . <nl> ! * / <nl> <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl>
Merged and also updated documentation to reflect these changes .
davisking/dlib
5165ae1b8c46aeeab135617039bedfef61678bf6
2016-03-26T16:21:40Z
mmm a / src / csharp / Grpc . Core . Tests / ClientServerTest . cs <nl> ppp b / src / csharp / Grpc . Core . Tests / ClientServerTest . cs <nl> public void CleanupClass ( ) <nl> [ Test ] <nl> public void UnaryCall ( ) <nl> { <nl> - var callDetails = new CallInvocationDetails < string , string > ( channel , EchoMethod , new CallContext ( ) ) ; <nl> + var callDetails = new CallInvocationDetails < string , string > ( channel , EchoMethod , new CallOptions ( ) ) ; <nl> Assert . AreEqual ( " ABC " , Calls . BlockingUnaryCall ( callDetails , " ABC " ) ) ; <nl> } <nl> <nl> [ Test ] <nl> public void UnaryCall_ServerHandlerThrows ( ) <nl> { <nl> - var callDetails = new CallInvocationDetails < string , string > ( channel , EchoMethod , new CallContext ( ) ) ; <nl> + var callDetails = new CallInvocationDetails < string , string > ( channel , EchoMethod , new CallOptions ( ) ) ; <nl> try <nl> { <nl> Calls . BlockingUnaryCall ( callDetails , " THROW " ) ; <nl> public void UnaryCall_ServerHandlerThrows ( ) <nl> [ Test ] <nl> public void UnaryCall_ServerHandlerThrowsRpcException ( ) <nl> { <nl> - var callDetails = new CallInvocationDetails < string , string > ( channel , EchoMethod , new CallContext ( ) ) ; <nl> + var callDetails = new CallInvocationDetails < string , string > ( channel , EchoMethod , new CallOptions ( ) ) ; <nl> try <nl> { <nl> Calls . BlockingUnaryCall ( callDetails , " THROW_UNAUTHENTICATED " ) ; <nl> public void UnaryCall_ServerHandlerThrowsRpcException ( ) <nl> [ Test ] <nl> public void UnaryCall_ServerHandlerSetsStatus ( ) <nl> { <nl> - var callDetails = new CallInvocationDetails < string , string > ( channel , EchoMethod , new CallContext ( ) ) ; <nl> + var callDetails = new CallInvocationDetails < string , string > ( channel , EchoMethod , new CallOptions ( ) ) ; <nl> try <nl> { <nl> Calls . BlockingUnaryCall ( callDetails , " SET_UNAUTHENTICATED " ) ; <nl> public void UnaryCall_ServerHandlerSetsStatus ( ) <nl> [ Test ] <nl> public async Task AsyncUnaryCall ( ) <nl> { <nl> - var callDetails = new CallInvocationDetails < string , string > ( channel , EchoMethod , new CallContext ( ) ) ; <nl> + var callDetails = new CallInvocationDetails < string , string > ( channel , EchoMethod , new CallOptions ( ) ) ; <nl> var result = await Calls . AsyncUnaryCall ( callDetails , " ABC " ) ; <nl> Assert . AreEqual ( " ABC " , result ) ; <nl> } <nl> public async Task AsyncUnaryCall ( ) <nl> [ Test ] <nl> public async Task AsyncUnaryCall_ServerHandlerThrows ( ) <nl> { <nl> - var callDetails = new CallInvocationDetails < string , string > ( channel , EchoMethod , new CallContext ( ) ) ; <nl> + var callDetails = new CallInvocationDetails < string , string > ( channel , EchoMethod , new CallOptions ( ) ) ; <nl> try <nl> { <nl> await Calls . AsyncUnaryCall ( callDetails , " THROW " ) ; <nl> public async Task AsyncUnaryCall_ServerHandlerThrows ( ) <nl> [ Test ] <nl> public async Task ClientStreamingCall ( ) <nl> { <nl> - var callDetails = new CallInvocationDetails < string , string > ( channel , ConcatAndEchoMethod , new CallContext ( ) ) ; <nl> + var callDetails = new CallInvocationDetails < string , string > ( channel , ConcatAndEchoMethod , new CallOptions ( ) ) ; <nl> var call = Calls . AsyncClientStreamingCall ( callDetails ) ; <nl> <nl> await call . RequestStream . WriteAll ( new string [ ] { " A " , " B " , " C " } ) ; <nl> public async Task ClientStreamingCall ( ) <nl> public async Task ClientStreamingCall_CancelAfterBegin ( ) <nl> { <nl> var cts = new CancellationTokenSource ( ) ; <nl> - var callDetails = new CallInvocationDetails < string , string > ( channel , ConcatAndEchoMethod , new CallContext ( cancellationToken : cts . Token ) ) ; <nl> + var callDetails = new CallInvocationDetails < string , string > ( channel , ConcatAndEchoMethod , new CallOptions ( cancellationToken : cts . Token ) ) ; <nl> var call = Calls . AsyncClientStreamingCall ( callDetails ) ; <nl> <nl> / / TODO ( jtattermusch ) : we need this to ensure call has been initiated once we cancel it . <nl> public void AsyncUnaryCall_EchoMetadata ( ) <nl> new Metadata . Entry ( " ascii - header " , " abcdefg " ) , <nl> new Metadata . Entry ( " binary - header - bin " , new byte [ ] { 1 , 2 , 3 , 0 , 0xff } ) , <nl> } ; <nl> - var callDetails = new CallInvocationDetails < string , string > ( channel , EchoMethod , new CallContext ( headers : headers ) ) ; <nl> + var callDetails = new CallInvocationDetails < string , string > ( channel , EchoMethod , new CallOptions ( headers : headers ) ) ; <nl> var call = Calls . AsyncUnaryCall ( callDetails , " ABC " ) ; <nl> <nl> Assert . AreEqual ( " ABC " , call . ResponseAsync . Result ) ; <nl> public void UnaryCall_DisposedChannel ( ) <nl> { <nl> channel . Dispose ( ) ; <nl> <nl> - var callDetails = new CallInvocationDetails < string , string > ( channel , EchoMethod , new CallContext ( ) ) ; <nl> + var callDetails = new CallInvocationDetails < string , string > ( channel , EchoMethod , new CallOptions ( ) ) ; <nl> Assert . Throws ( typeof ( ObjectDisposedException ) , ( ) = > Calls . BlockingUnaryCall ( callDetails , " ABC " ) ) ; <nl> } <nl> <nl> [ Test ] <nl> public void UnaryCallPerformance ( ) <nl> { <nl> - var callDetails = new CallInvocationDetails < string , string > ( channel , EchoMethod , new CallContext ( ) ) ; <nl> + var callDetails = new CallInvocationDetails < string , string > ( channel , EchoMethod , new CallOptions ( ) ) ; <nl> BenchmarkUtil . RunBenchmark ( 100 , 100 , <nl> ( ) = > { Calls . BlockingUnaryCall ( callDetails , " ABC " ) ; } ) ; <nl> } <nl> public void UnaryCallPerformance ( ) <nl> [ Test ] <nl> public void UnknownMethodHandler ( ) <nl> { <nl> - var callDetails = new CallInvocationDetails < string , string > ( channel , NonexistentMethod , new CallContext ( ) ) ; <nl> + var callDetails = new CallInvocationDetails < string , string > ( channel , NonexistentMethod , new CallOptions ( ) ) ; <nl> try <nl> { <nl> Calls . BlockingUnaryCall ( callDetails , " ABC " ) ; <nl> public void UnknownMethodHandler ( ) <nl> [ Test ] <nl> public void UserAgentStringPresent ( ) <nl> { <nl> - var callDetails = new CallInvocationDetails < string , string > ( channel , EchoMethod , new CallContext ( ) ) ; <nl> + var callDetails = new CallInvocationDetails < string , string > ( channel , EchoMethod , new CallOptions ( ) ) ; <nl> string userAgent = Calls . BlockingUnaryCall ( callDetails , " RETURN - USER - AGENT " ) ; <nl> Assert . IsTrue ( userAgent . StartsWith ( " grpc - csharp / " ) ) ; <nl> } <nl> public void UserAgentStringPresent ( ) <nl> [ Test ] <nl> public void PeerInfoPresent ( ) <nl> { <nl> - var callDetails = new CallInvocationDetails < string , string > ( channel , EchoMethod , new CallContext ( ) ) ; <nl> + var callDetails = new CallInvocationDetails < string , string > ( channel , EchoMethod , new CallOptions ( ) ) ; <nl> string peer = Calls . BlockingUnaryCall ( callDetails , " RETURN - PEER " ) ; <nl> Assert . IsTrue ( peer . Contains ( Host ) ) ; <nl> } <nl> public async Task Channel_WaitForStateChangedAsync ( ) <nl> <nl> var stateChangedTask = channel . WaitForStateChangedAsync ( channel . State ) ; <nl> <nl> - var callDetails = new CallInvocationDetails < string , string > ( channel , EchoMethod , new CallContext ( ) ) ; <nl> + var callDetails = new CallInvocationDetails < string , string > ( channel , EchoMethod , new CallOptions ( ) ) ; <nl> await Calls . AsyncUnaryCall ( callDetails , " abc " ) ; <nl> <nl> await stateChangedTask ; <nl> mmm a / src / csharp / Grpc . Core . Tests / TimeoutsTest . cs <nl> ppp b / src / csharp / Grpc . Core . Tests / TimeoutsTest . cs <nl> public void CleanupClass ( ) <nl> public void InfiniteDeadline ( ) <nl> { <nl> / / no deadline specified , check server sees infinite deadline <nl> - var callDetails = new CallInvocationDetails < string , string > ( channel , TestMethod , new CallContext ( ) ) ; <nl> + var callDetails = new CallInvocationDetails < string , string > ( channel , TestMethod , new CallOptions ( ) ) ; <nl> Assert . AreEqual ( " DATETIME_MAXVALUE " , Calls . BlockingUnaryCall ( callDetails , " RETURN_DEADLINE " ) ) ; <nl> <nl> / / DateTime . MaxValue deadline specified , check server sees infinite deadline <nl> - var callDetails2 = new CallInvocationDetails < string , string > ( channel , TestMethod , new CallContext ( ) ) ; <nl> + var callDetails2 = new CallInvocationDetails < string , string > ( channel , TestMethod , new CallOptions ( ) ) ; <nl> Assert . AreEqual ( " DATETIME_MAXVALUE " , Calls . BlockingUnaryCall ( callDetails2 , " RETURN_DEADLINE " ) ) ; <nl> } <nl> <nl> public void DeadlineTransferredToServer ( ) <nl> var remainingTimeClient = TimeSpan . FromDays ( 7 ) ; <nl> var deadline = DateTime . UtcNow + remainingTimeClient ; <nl> Thread . Sleep ( 1000 ) ; <nl> - var callDetails = new CallInvocationDetails < string , string > ( channel , TestMethod , new CallContext ( deadline : deadline ) ) ; <nl> + var callDetails = new CallInvocationDetails < string , string > ( channel , TestMethod , new CallOptions ( deadline : deadline ) ) ; <nl> <nl> var serverDeadlineTicksString = Calls . BlockingUnaryCall ( callDetails , " RETURN_DEADLINE " ) ; <nl> var serverDeadline = new DateTime ( long . Parse ( serverDeadlineTicksString ) , DateTimeKind . Utc ) ; <nl> public void DeadlineTransferredToServer ( ) <nl> [ Test ] <nl> public void DeadlineInThePast ( ) <nl> { <nl> - var callDetails = new CallInvocationDetails < string , string > ( channel , TestMethod , new CallContext ( deadline : DateTime . MinValue ) ) ; <nl> + var callDetails = new CallInvocationDetails < string , string > ( channel , TestMethod , new CallOptions ( deadline : DateTime . MinValue ) ) ; <nl> <nl> try <nl> { <nl> public void DeadlineInThePast ( ) <nl> public void DeadlineExceededStatusOnTimeout ( ) <nl> { <nl> var deadline = DateTime . UtcNow . Add ( TimeSpan . FromSeconds ( 5 ) ) ; <nl> - var callDetails = new CallInvocationDetails < string , string > ( channel , TestMethod , new CallContext ( deadline : deadline ) ) ; <nl> + var callDetails = new CallInvocationDetails < string , string > ( channel , TestMethod , new CallOptions ( deadline : deadline ) ) ; <nl> <nl> try <nl> { <nl> public void DeadlineExceededStatusOnTimeout ( ) <nl> public void ServerReceivesCancellationOnTimeout ( ) <nl> { <nl> var deadline = DateTime . UtcNow . Add ( TimeSpan . FromSeconds ( 5 ) ) ; <nl> - var callDetails = new CallInvocationDetails < string , string > ( channel , TestMethod , new CallContext ( deadline : deadline ) ) ; <nl> + var callDetails = new CallInvocationDetails < string , string > ( channel , TestMethod , new CallOptions ( deadline : deadline ) ) ; <nl> <nl> try <nl> { <nl> deleted file mode 100644 <nl> index 2787d3f5b3a . . 00000000000 <nl> mmm a / src / csharp / Grpc . Core / CallContext . cs <nl> ppp / dev / null <nl> <nl> - # region Copyright notice and license <nl> - <nl> - / / Copyright 2015 , Google Inc . <nl> - / / All rights reserved . <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - # endregion <nl> - <nl> - using System ; <nl> - using System . Threading ; <nl> - <nl> - using Grpc . Core . Internal ; <nl> - using Grpc . Core . Utils ; <nl> - <nl> - namespace Grpc . Core <nl> - { <nl> - / / / < summary > <nl> - / / / Context for calls made by client . <nl> - / / / < / summary > <nl> - public class CallContext <nl> - { <nl> - readonly Metadata headers ; <nl> - readonly DateTime deadline ; <nl> - readonly CancellationToken cancellationToken ; <nl> - <nl> - / / / < summary > <nl> - / / / Creates a new call context . <nl> - / / / < / summary > <nl> - / / / < param name = " headers " > Headers to be sent with the call . < / param > <nl> - / / / < param name = " deadline " > Deadline for the call to finish . null means no deadline . < / param > <nl> - / / / < param name = " cancellationToken " > Can be used to request cancellation of the call . < / param > <nl> - public CallContext ( Metadata headers = null , DateTime ? deadline = null , CancellationToken cancellationToken = default ( CancellationToken ) ) <nl> - { <nl> - / / TODO ( jtattermusch ) : consider only creating metadata object once it ' s really needed . <nl> - this . headers = headers ! = null ? headers : new Metadata ( ) ; <nl> - this . deadline = deadline . HasValue ? deadline . Value : DateTime . MaxValue ; <nl> - this . cancellationToken = cancellationToken ; <nl> - } <nl> - <nl> - / / / < summary > <nl> - / / / Headers to send at the beginning of the call . <nl> - / / / < / summary > <nl> - public Metadata Headers <nl> - { <nl> - get { return headers ; } <nl> - } <nl> - <nl> - / / / < summary > <nl> - / / / Call deadline . <nl> - / / / < / summary > <nl> - public DateTime Deadline <nl> - { <nl> - get { return deadline ; } <nl> - } <nl> - <nl> - / / / < summary > <nl> - / / / Token that can be used for cancelling the call . <nl> - / / / < / summary > <nl> - public CancellationToken CancellationToken <nl> - { <nl> - get { return cancellationToken ; } <nl> - } <nl> - } <nl> - } <nl> mmm a / src / csharp / Grpc . Core / CallInvocationDetails . cs <nl> ppp b / src / csharp / Grpc . Core / CallInvocationDetails . cs <nl> public class CallInvocationDetails < TRequest , TResponse > <nl> readonly string host ; <nl> readonly Marshaller < TRequest > requestMarshaller ; <nl> readonly Marshaller < TResponse > responseMarshaller ; <nl> - readonly CallContext context ; <nl> + readonly CallOptions options ; <nl> <nl> - <nl> - public CallInvocationDetails ( Channel channel , Method < TRequest , TResponse > method , CallContext context ) : <nl> - this ( channel , method . FullName , null , method . RequestMarshaller , method . ResponseMarshaller , context ) <nl> + public CallInvocationDetails ( Channel channel , Method < TRequest , TResponse > method , CallOptions options ) : <nl> + this ( channel , method . FullName , null , method . RequestMarshaller , method . ResponseMarshaller , options ) <nl> { <nl> } <nl> <nl> - public CallInvocationDetails ( Channel channel , string method , string host , Marshaller < TRequest > requestMarshaller , Marshaller < TResponse > responseMarshaller , CallContext context ) <nl> + public CallInvocationDetails ( Channel channel , string method , string host , Marshaller < TRequest > requestMarshaller , Marshaller < TResponse > responseMarshaller , CallOptions options ) <nl> { <nl> this . channel = Preconditions . CheckNotNull ( channel ) ; <nl> this . method = Preconditions . CheckNotNull ( method ) ; <nl> this . host = host ; <nl> this . requestMarshaller = Preconditions . CheckNotNull ( requestMarshaller ) ; <nl> this . responseMarshaller = Preconditions . CheckNotNull ( responseMarshaller ) ; <nl> - this . context = Preconditions . CheckNotNull ( context ) ; <nl> + this . options = Preconditions . CheckNotNull ( options ) ; <nl> } <nl> <nl> public Channel Channel <nl> public Marshaller < TResponse > ResponseMarshaller <nl> return this . responseMarshaller ; <nl> } <nl> } <nl> - <nl> - / / / < summary > <nl> - / / / Call context . <nl> - / / / < / summary > <nl> - public CallContext Context <nl> + <nl> + public CallOptions Options <nl> { <nl> get <nl> { <nl> - return context ; <nl> + return options ; <nl> } <nl> } <nl> } <nl> mmm a / src / csharp / Grpc . Core / CallOptions . cs <nl> ppp b / src / csharp / Grpc . Core / CallOptions . cs <nl> public class CallOptions <nl> readonly CancellationToken cancellationToken ; <nl> <nl> / / / < summary > <nl> - / / / Creates a new call context . <nl> + / / / Creates a new instance of < c > CallOptions < / c > . <nl> / / / < / summary > <nl> / / / < param name = " headers " > Headers to be sent with the call . < / param > <nl> / / / < param name = " deadline " > Deadline for the call to finish . null means no deadline . < / param > <nl> mmm a / src / csharp / Grpc . Core / ClientBase . cs <nl> ppp b / src / csharp / Grpc . Core / ClientBase . cs <nl> public Channel Channel <nl> / / / < summary > <nl> / / / Creates a new call to given method . <nl> / / / < / summary > <nl> - protected CallInvocationDetails < TRequest , TResponse > CreateCall < TRequest , TResponse > ( Method < TRequest , TResponse > method , CallContext context ) <nl> + protected CallInvocationDetails < TRequest , TResponse > CreateCall < TRequest , TResponse > ( Method < TRequest , TResponse > method , CallOptions options ) <nl> where TRequest : class <nl> where TResponse : class <nl> { <nl> var interceptor = HeaderInterceptor ; <nl> if ( interceptor ! = null ) <nl> { <nl> - interceptor ( context . Headers ) ; <nl> - context . Headers . Freeze ( ) ; <nl> + interceptor ( options . Headers ) ; <nl> + options . Headers . Freeze ( ) ; <nl> } <nl> - return new CallInvocationDetails < TRequest , TResponse > ( channel , method , context ) ; <nl> + return new CallInvocationDetails < TRequest , TResponse > ( channel , method , options ) ; <nl> } <nl> } <nl> } <nl> mmm a / src / csharp / Grpc . Core / Grpc . Core . csproj <nl> ppp b / src / csharp / Grpc . Core / Grpc . Core . csproj <nl> <nl> < ItemGroup > <nl> < Compile Include = " AsyncDuplexStreamingCall . cs " / > <nl> < Compile Include = " AsyncServerStreamingCall . cs " / > <nl> - < Compile Include = " CallContext . cs " / > <nl> < Compile Include = " IClientStreamWriter . cs " / > <nl> < Compile Include = " IServerStreamWriter . cs " / > <nl> < Compile Include = " IAsyncStreamWriter . cs " / > <nl> <nl> < Compile Include = " Internal \ NativeLogRedirector . cs " / > <nl> < Compile Include = " ChannelState . cs " / > <nl> < Compile Include = " CallInvocationDetails . cs " / > <nl> + < Compile Include = " CallOptions . cs " / > <nl> < / ItemGroup > <nl> < ItemGroup > <nl> < None Include = " Grpc . Core . nuspec " / > <nl> mmm a / src / csharp / Grpc . Core / Internal / AsyncCall . cs <nl> ppp b / src / csharp / Grpc . Core / Internal / AsyncCall . cs <nl> public TResponse UnaryCall ( TRequest msg ) <nl> readingDone = true ; <nl> } <nl> <nl> - using ( var metadataArray = MetadataArraySafeHandle . Create ( callDetails . Context . Headers ) ) <nl> + using ( var metadataArray = MetadataArraySafeHandle . Create ( callDetails . Options . Headers ) ) <nl> { <nl> using ( var ctx = BatchContextSafeHandle . Create ( ) ) <nl> { <nl> public Task < TResponse > UnaryCallAsync ( TRequest msg ) <nl> byte [ ] payload = UnsafeSerialize ( msg ) ; <nl> <nl> unaryResponseTcs = new TaskCompletionSource < TResponse > ( ) ; <nl> - using ( var metadataArray = MetadataArraySafeHandle . Create ( callDetails . Context . Headers ) ) <nl> + using ( var metadataArray = MetadataArraySafeHandle . Create ( callDetails . Options . Headers ) ) <nl> { <nl> call . StartUnary ( payload , HandleUnaryResponse , metadataArray ) ; <nl> } <nl> public Task < TResponse > ClientStreamingCallAsync ( ) <nl> readingDone = true ; <nl> <nl> unaryResponseTcs = new TaskCompletionSource < TResponse > ( ) ; <nl> - using ( var metadataArray = MetadataArraySafeHandle . Create ( callDetails . Context . Headers ) ) <nl> + using ( var metadataArray = MetadataArraySafeHandle . Create ( callDetails . Options . Headers ) ) <nl> { <nl> call . StartClientStreaming ( HandleUnaryResponse , metadataArray ) ; <nl> } <nl> public void StartServerStreamingCall ( TRequest msg ) <nl> <nl> byte [ ] payload = UnsafeSerialize ( msg ) ; <nl> <nl> - using ( var metadataArray = MetadataArraySafeHandle . Create ( callDetails . Context . Headers ) ) <nl> + using ( var metadataArray = MetadataArraySafeHandle . Create ( callDetails . Options . Headers ) ) <nl> { <nl> call . StartServerStreaming ( payload , HandleFinished , metadataArray ) ; <nl> } <nl> public void StartDuplexStreamingCall ( ) <nl> <nl> Initialize ( callDetails . Channel . Environment . CompletionQueue ) ; <nl> <nl> - using ( var metadataArray = MetadataArraySafeHandle . Create ( callDetails . Context . Headers ) ) <nl> + using ( var metadataArray = MetadataArraySafeHandle . Create ( callDetails . Options . Headers ) ) <nl> { <nl> call . StartDuplexStreaming ( HandleFinished , metadataArray ) ; <nl> } <nl> protected override void OnReleaseResources ( ) <nl> private void Initialize ( CompletionQueueSafeHandle cq ) <nl> { <nl> var call = callDetails . Channel . Handle . CreateCall ( callDetails . Channel . Environment . CompletionRegistry , cq , <nl> - callDetails . Method , callDetails . Host , Timespec . FromDateTime ( callDetails . Context . Deadline ) ) ; <nl> + callDetails . Method , callDetails . Host , Timespec . FromDateTime ( callDetails . Options . Deadline ) ) ; <nl> callDetails . Channel . Environment . DebugStats . ActiveClientCalls . Increment ( ) ; <nl> InitializeInternal ( call ) ; <nl> RegisterCancellationCallback ( ) ; <nl> private void Initialize ( CompletionQueueSafeHandle cq ) <nl> / / Make sure that once cancellationToken for this call is cancelled , Cancel ( ) will be called . <nl> private void RegisterCancellationCallback ( ) <nl> { <nl> - var token = callDetails . Context . CancellationToken ; <nl> + var token = callDetails . Options . CancellationToken ; <nl> if ( token . CanBeCanceled ) <nl> { <nl> token . Register ( ( ) = > this . Cancel ( ) ) ; <nl>
renamed CallContext to CallOptions
grpc/grpc
5c371f83763b9f2328a45eccd093ef7a60c37e72
2015-08-05T21:55:17Z
mmm a / src / core / ext / lb_policy / grpclb / grpclb . c <nl> ppp b / src / core / ext / lb_policy / grpclb / grpclb . c <nl> static void wrapped_rr_closure ( grpc_exec_ctx * exec_ctx , void * arg , <nl> NULL ) ; <nl> <nl> if ( wc_arg - > rr_policy ! = NULL ) { <nl> - / * if target is NULL , no pick has been made by the RR policy ( eg , all <nl> + / * if * target is NULL , no pick has been made by the RR policy ( eg , all <nl> * addresses failed to connect ) . There won ' t be any user_data / token <nl> * available * / <nl> - if ( wc_arg - > target ! = NULL ) { <nl> + if ( * wc_arg - > target ! = NULL ) { <nl> if ( wc_arg - > lb_token ! = NULL ) { <nl> initial_metadata_add_lb_token ( wc_arg - > initial_metadata , <nl> wc_arg - > lb_token_mdelem_storage , <nl>
Merge pull request from dgquintas / grpclb_right_target
grpc/grpc
01eda53c817fe766c6d63cb486f70284d9e3ee4d
2016-11-22T20:52:07Z
mmm a / . travis . yml <nl> ppp b / . travis . yml <nl> matrix : <nl> compiler : clang <nl> before_install : echo - n | openssl s_client - connect scan . coverity . com : 443 | sed - ne ' / - BEGIN CERTIFICATE - / , / - END CERTIFICATE - / p ' | sudo tee - a / etc / ssl / certs / ca - certificates . crt <nl> addons : <nl> - apt : <nl> - sources : [ ' ubuntu - toolchain - r - test ' ] <nl> - packages : [ ' valgrind ' ] <nl> coverity_scan : <nl> project : <nl> name : " nlohmann / json " <nl>
: construction_worker : trying to fix coverity task
nlohmann/json
9952a3c456e4af1bffb4e5c85968fdf32a122e08
2016-12-18T17:17:26Z
mmm a / SConstruct <nl> ppp b / SConstruct <nl> clientEnv = env . Clone ( ) ; <nl> clientEnv . Append ( CPPPATH = [ " . . / " ] ) <nl> clientEnv . Prepend ( LIBS = [ " mongoclient " ] ) <nl> clientEnv . Prepend ( LIBPATH = [ " . " ] ) <nl> - clientEnv [ " CPPDEFINES " ] . remove ( " MONGO_EXPOSE_MACROS " ) <nl> + # clientEnv [ " CPPDEFINES " ] . remove ( " MONGO_EXPOSE_MACROS " ) <nl> l = clientEnv [ " LIBS " ] <nl> removeIfInList ( l , " pcre " ) <nl> removeIfInList ( l , " pcrecpp " ) <nl> clientTests + = [ clientEnv . Program ( " secondExample " , [ " client / examples / second . <nl> clientTests + = [ clientEnv . Program ( " whereExample " , [ " client / examples / whereExample . cpp " ] ) ] <nl> clientTests + = [ clientEnv . Program ( " authTest " , [ " client / examples / authTest . cpp " ] ) ] <nl> clientTests + = [ clientEnv . Program ( " httpClientTest " , [ " client / examples / httpClientTest . cpp " ] ) ] <nl> - clientTests + = [ clientEnv . Program ( " bsondemo " , [ " bson / bsondemo / bsondemo . cpp " ] ) ] <nl> + # clientTests + = [ clientEnv . Program ( " bsondemo " , [ " bson / bsondemo / bsondemo . cpp " ] ) ] # TODO <nl> <nl> # testing <nl> test = testEnv . Program ( " test " , Glob ( " dbtests / * . cpp " ) ) <nl>
don ' t do bsondemo right now
mongodb/mongo
9a847036926d8da49854962025990e6eb157e825
2010-07-02T14:59:27Z
mmm a / modules / dreamview / conf / hmi_modes / vehicle_calibration . pb . txt <nl> ppp b / modules / dreamview / conf / hmi_modes / vehicle_calibration . pb . txt <nl> <nl> cyber_modules { <nl> - key : " Vehicle Calibration Modules " <nl> + key : " Sensors " <nl> value : { <nl> dag_files : " / apollo / modules / drivers / gnss / dag / gnss . dag " <nl> dag_files : " / apollo / modules / localization / dag / dag_streaming_rtk_localization . dag " <nl> - dag_files : " / apollo / modules / canbus / dag / canbus . dag " <nl> process_group : " compute_sched " <nl> } <nl> } <nl> + cyber_modules { <nl> + key : " Canbus " <nl> + value : { <nl> + dag_files : " / apollo / modules / canbus / dag / canbus . dag " <nl> + } <nl> + } <nl> modules { <nl> key : " Recorder " <nl> value : { <nl>
Dreamview : seperate canbus and other sensors in vehicle calibration mode
ApolloAuto/apollo
c7aae52cce8483461a5a53f56431181c79f00f30
2019-04-12T02:29:05Z
mmm a / src / rdb_protocol / btree . cc <nl> ppp b / src / rdb_protocol / btree . cc <nl> void rdb_update_single_sindex ( <nl> sindex_multi_bool_t multi ; <nl> deserialize_sindex_info ( sindex - > sindex . opaque_definition , & mapping , & multi ) ; <nl> <nl> - / / TODO we have no rdb context here . People should not be able to do anything <nl> - / / that requires an environment like gets from other tables etc . but we don ' t <nl> - / / have a nice way to disallow those things so for now we pass null and it will <nl> - / / segfault if an illegal sindex mapping is passed . <nl> + / / TODO we have no rdb context here . We should be evaluating a deterministic <nl> + / / function here so it should be a non - issue . We also don ' t have any global <nl> + / / optargs affecting evaluation . <nl> cond_t non_interruptor ; <nl> ql : : env_t env ( & non_interruptor ) ; <nl> <nl> mmm a / src / rdb_protocol / env . hpp <nl> ppp b / src / rdb_protocol / env . hpp <nl> class env_t : public home_thread_mixin_t { <nl> std : : map < std : : string , wire_func_t > optargs , <nl> profile : : trace_t * trace ) ; <nl> <nl> + / / Used in unittest and one unfortunate place in rdb_update_single_sindex ( for <nl> + / / evaluating a deterministic function ) . <nl> explicit env_t ( signal_t * interruptor ) ; <nl> <nl> ~ env_t ( ) ; <nl>
Improved comments about single - argument env_t constructor .
rethinkdb/rethinkdb
7d8a3afb6e43ae5b303c274ed471ea17f23fd8a9
2014-07-26T05:19:43Z
mmm a / dbms / src / AggregateFunctions / AggregateFunctionHistogram . cpp <nl> ppp b / dbms / src / AggregateFunctions / AggregateFunctionHistogram . cpp <nl> namespace ErrorCodes <nl> extern const int ILLEGAL_TYPE_OF_ARGUMENT ; <nl> extern const int BAD_ARGUMENTS ; <nl> extern const int UNSUPPORTED_PARAMETER ; <nl> + extern const int PARAMETER_OUT_OF_BOUND ; <nl> } <nl> <nl> namespace <nl> AggregateFunctionPtr createAggregateFunctionHistogram ( const std : : string & name , <nl> <nl> UInt32 bins_count = applyVisitor ( FieldVisitorConvertToNumber < UInt32 > ( ) , params [ 0 ] ) ; <nl> <nl> + auto limit = AggregateFunctionHistogramData : : bins_count_limit ; <nl> + if ( bins_count > limit ) <nl> + throw Exception ( " Unsupported bins count . Should not be greater than " + std : : to_string ( limit ) , ErrorCodes : : PARAMETER_OUT_OF_BOUND ) ; <nl> + <nl> if ( bins_count = = 0 ) <nl> throw Exception ( " Bin count should be positive " , ErrorCodes : : BAD_ARGUMENTS ) ; <nl> <nl> mmm a / dbms / src / AggregateFunctions / AggregateFunctionHistogram . h <nl> ppp b / dbms / src / AggregateFunctions / AggregateFunctionHistogram . h <nl> <nl> # pragma once <nl> <nl> # include < Common / Arena . h > <nl> - # include < Common / PODArray . h > <nl> - # include < Common / AutoArray . h > <nl> <nl> # include < Columns / ColumnVector . h > <nl> # include < Columns / ColumnTuple . h > <nl> class AggregateFunctionHistogramData <nl> using Mean = Float64 ; <nl> using Weight = Float64 ; <nl> <nl> + constexpr static size_t bins_count_limit = 250 ; <nl> + <nl> private : <nl> struct WeightedValue <nl> { <nl> class AggregateFunctionHistogramData <nl> } ) ; <nl> } <nl> <nl> + template < typename T > <nl> + struct PriorityQueueStorage <nl> + { <nl> + size_t size = 0 ; <nl> + T * data_ptr ; <nl> + <nl> + PriorityQueueStorage ( T * value ) <nl> + : data_ptr ( value ) <nl> + { <nl> + } <nl> + <nl> + void push_back ( T val ) <nl> + { <nl> + data_ptr [ size ] = std : : move ( val ) ; <nl> + + + size ; <nl> + } <nl> + <nl> + void pop_back ( ) { - - size ; } <nl> + T * begin ( ) { return data_ptr ; } <nl> + T * end ( ) const { return data_ptr + size ; } <nl> + bool empty ( ) const { return size = = 0 ; } <nl> + T & front ( ) { return * data_ptr ; } <nl> + const T & front ( ) const { return * data_ptr ; } <nl> + <nl> + using value_type = T ; <nl> + using reference = T & ; <nl> + using const_reference = const T & ; <nl> + using size_type = size_t ; <nl> + } ; <nl> + <nl> / * * <nl> * Repeatedly fuse most close values until max_bins bins left <nl> * / <nl> class AggregateFunctionHistogramData <nl> <nl> / / Maintain doubly - linked list of " active " points <nl> / / and store neighbour pairs in priority queue by distance <nl> - AutoArray < UInt32 > previous ( size + 1 ) ; <nl> - AutoArray < UInt32 > next ( size + 1 ) ; <nl> - AutoArray < bool > active ( size + 1 , true ) ; <nl> + UInt32 previous [ size + 1 ] ; <nl> + UInt32 next [ size + 1 ] ; <nl> + bool active [ size + 1 ] ; <nl> + std : : fill ( active , active + size , true ) ; <nl> active [ size ] = false ; <nl> <nl> auto delete_node = [ & ] ( UInt32 i ) <nl> class AggregateFunctionHistogramData <nl> <nl> using QueueItem = std : : pair < Mean , UInt32 > ; <nl> <nl> - std : : vector < QueueItem > storage ; <nl> - storage . reserve ( 2 * size - max_bins ) ; <nl> - std : : priority_queue < QueueItem , std : : vector < QueueItem > , std : : greater < QueueItem > > queue ; <nl> + QueueItem storage [ 2 * size - max_bins ] ; <nl> + <nl> + std : : priority_queue < <nl> + QueueItem , <nl> + PriorityQueueStorage < QueueItem > , <nl> + std : : greater < QueueItem > > <nl> + queue { std : : greater < QueueItem > ( ) , <nl> + PriorityQueueStorage < QueueItem > ( storage ) } ; <nl> <nl> auto quality = [ & ] ( UInt32 i ) { return points [ next [ i ] ] . mean - points [ i ] . mean ; } ; <nl> <nl>
remove temporary allocations
ClickHouse/ClickHouse
877acef7d5b0603c78973c3a6b9d829d76a04f79
2018-07-08T13:56:33Z
mmm a / folly / experimental / Gen . h <nl> ppp b / folly / experimental / Gen . h <nl> <nl> * As an example , the ' lengths ' generator ( above ) won ' t actually invoke the <nl> * provided lambda until values are needed : <nl> * <nl> - * auto lengthVector = lengths | asVector ( ) ; <nl> + * auto lengthVector = lengths | as < std : : vector > ( ) ; <nl> * auto totalLength = lengths | sum ; <nl> * <nl> * ' auto ' is useful in here because the actual types of the generators objects <nl>
Update example in folly : : gen
facebook/folly
b88cb304b1bd93ae65c8cf1d05be9ffdf3666db0
2013-02-04T17:26:28Z
mmm a / 3rdParty / CMakeLists . txt <nl> ppp b / 3rdParty / CMakeLists . txt <nl> <nl> - # add_subdirectory ( boost ) <nl> - # add_subdirectory ( etcd ) <nl> - # add_subdirectory ( linenoise - ng ) <nl> - # add_subdirectory ( valgrind ) <nl> - # add_subdirectory ( velocypack ) <nl> - # add_subdirectory ( zlib - 1 . 2 . 7 ) <nl> <nl> include ( ExternalProject ) <nl> <nl> macro ( import_target tname tdep tinclude tpath ) <nl> endmacro ( ) <nl> <nl> # ETCD <nl> - if ( MSVC ) <nl> - set ( ETCD_BUILD_COMMAND build . bat ) <nl> - else ( ) <nl> - set ( ETCD_BUILD_COMMAND . / build ) <nl> + if ( GO_FOUND ) <nl> + if ( MSVC ) <nl> + set ( ETCD_BUILD_COMMAND build . bat ) <nl> + else ( ) <nl> + set ( ETCD_BUILD_COMMAND . / build ) <nl> + endif ( ) <nl> + ExternalProject_Add ( etcd_build <nl> + SOURCE_DIR $ { CMAKE_CURRENT_SOURCE_DIR } / etcd <nl> + CONFIGURE_COMMAND " " <nl> + BUILD_IN_SOURCE TRUE <nl> + BUILD_COMMAND " $ { ETCD_BUILD_COMMAND } " <nl> + INSTALL_COMMAND " " ) <nl> endif ( ) <nl> - ExternalProject_Add ( etcd_build <nl> - SOURCE_DIR $ { CMAKE_CURRENT_SOURCE_DIR } / etcd <nl> - CONFIGURE_COMMAND " " <nl> - BUILD_IN_SOURCE TRUE <nl> - BUILD_COMMAND " $ { ETCD_BUILD_COMMAND } " <nl> - INSTALL_COMMAND " " ) <nl> - <nl> <nl> # ZLIB <nl> if ( UNIX ) <nl> mmm a / CMakeLists . txt <nl> ppp b / CMakeLists . txt <nl> include ( OptimizeForArchitecture ) <nl> OptimizeForArchitecture ( ) <nl> set ( CMAKE_CXX_FLAGS " $ { CMAKE_CXX_FLAGS } $ { Vc_ARCHITECTURE_FLAGS } " ) <nl> <nl> + # GO mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + find_package ( Go 1 . 2 ) <nl> + if ( NOT GO_FOUND ) <nl> + message ( " Go version > = 1 . 2 not found . etcd will not be built . " ) <nl> + endif ( ) <nl> + <nl> # Enable Backtrace mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> option ( USE_BACKTRACE " whether we should try to generate c - level stacktraces " <nl> OFF ) <nl> find_package ( BISON ) <nl> # FLEX mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> find_package ( FLEX ) <nl> <nl> - # GO mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> - find_package ( Go 1 . 2 ) <nl> - <nl> # Python <nl> find_package ( PythonInterp 2 ) <nl> set ( ENV { PYTHON_EXECUTABLE } $ { PYTHON_EXECUTABLE } ) <nl>
Build of etcd should only be attempted , when Go is found > = 1 . 2
arangodb/arangodb
d5ba21ff61600c58ad863857e328f32769304c26
2016-02-17T09:22:07Z
mmm a / atom / browser / resources / mac / Info . plist <nl> ppp b / atom / browser / resources / mac / Info . plist <nl> <nl> < key > CFBundleIconFile < / key > <nl> < string > atom . icns < / string > <nl> < key > CFBundleVersion < / key > <nl> - < string > 0 . 19 . 1 < / string > <nl> + < string > 0 . 19 . 2 < / string > <nl> < key > LSMinimumSystemVersion < / key > <nl> < string > 10 . 8 . 0 < / string > <nl> < key > NSMainNibFile < / key > <nl> mmm a / atom / browser / resources / win / atom . rc <nl> ppp b / atom / browser / resources / win / atom . rc <nl> END <nl> / / <nl> <nl> VS_VERSION_INFO VERSIONINFO <nl> - FILEVERSION 0 , 19 , 1 , 0 <nl> - PRODUCTVERSION 0 , 19 , 1 , 0 <nl> + FILEVERSION 0 , 19 , 2 , 0 <nl> + PRODUCTVERSION 0 , 19 , 2 , 0 <nl> FILEFLAGSMASK 0x3fL <nl> # ifdef _DEBUG <nl> FILEFLAGS 0x1L <nl> BEGIN <nl> BEGIN <nl> VALUE " CompanyName " , " GitHub , Inc . " <nl> VALUE " FileDescription " , " Atom - Shell " <nl> - VALUE " FileVersion " , " 0 . 19 . 1 " <nl> + VALUE " FileVersion " , " 0 . 19 . 2 " <nl> VALUE " InternalName " , " atom . exe " <nl> VALUE " LegalCopyright " , " Copyright ( C ) 2013 GitHub , Inc . All rights reserved . " <nl> VALUE " OriginalFilename " , " atom . exe " <nl> VALUE " ProductName " , " Atom - Shell " <nl> - VALUE " ProductVersion " , " 0 . 19 . 1 " <nl> + VALUE " ProductVersion " , " 0 . 19 . 2 " <nl> VALUE " SquirrelAwareVersion " , " 1 " <nl> END <nl> END <nl> mmm a / atom / common / atom_version . h <nl> ppp b / atom / common / atom_version . h <nl> <nl> <nl> # define ATOM_MAJOR_VERSION 0 <nl> # define ATOM_MINOR_VERSION 19 <nl> - # define ATOM_PATCH_VERSION 1 <nl> + # define ATOM_PATCH_VERSION 2 <nl> <nl> # define ATOM_VERSION_IS_RELEASE 1 <nl> <nl> mmm a / package . json <nl> ppp b / package . json <nl> <nl> { <nl> " name " : " atom - shell " , <nl> - " version " : " 0 . 19 . 1 " , <nl> + " version " : " 0 . 19 . 2 " , <nl> <nl> " licenses " : [ <nl> { <nl>
Bump v0 . 19 . 2 .
electron/electron
b27abd20113c51f36963999b6e1fc50fcc88be6b
2014-11-15T07:18:01Z
mmm a / src / builtins / builtins - math - gen . cc <nl> ppp b / src / builtins / builtins - math - gen . cc <nl> TF_BUILTIN ( MathAbs , CodeStubAssembler ) { <nl> <nl> Bind ( & if_xissmi ) ; <nl> { <nl> - / / Check if { x } is already positive . <nl> - Label if_xispositive ( this ) , if_xisnotpositive ( this ) ; <nl> - BranchIfSmiLessThanOrEqual ( SmiConstant ( Smi : : FromInt ( 0 ) ) , x , <nl> - & if_xispositive , & if_xisnotpositive ) ; <nl> + Label if_overflow ( this , Label : : kDeferred ) , if_notoverflow ( this ) ; <nl> + Node * pair = NULL ; <nl> <nl> - Bind ( & if_xispositive ) ; <nl> - { <nl> - / / Just return the input { x } . <nl> - Return ( x ) ; <nl> - } <nl> - <nl> - Bind ( & if_xisnotpositive ) ; <nl> - { <nl> - / / Try to negate the { x } value . <nl> - Node * pair = <nl> - IntPtrSubWithOverflow ( IntPtrConstant ( 0 ) , BitcastTaggedToWord ( x ) ) ; <nl> + / / check if support abs function <nl> + if ( IsIntPtrAbsWithOverflowSupported ( ) ) { <nl> + pair = IntPtrAbsWithOverflow ( x ) ; <nl> Node * overflow = Projection ( 1 , pair ) ; <nl> - Label if_overflow ( this , Label : : kDeferred ) , if_notoverflow ( this ) ; <nl> Branch ( overflow , & if_overflow , & if_notoverflow ) ; <nl> + } else { <nl> + / / Check if { x } is already positive . <nl> + Label if_xispositive ( this ) , if_xisnotpositive ( this ) ; <nl> + BranchIfSmiLessThanOrEqual ( SmiConstant ( Smi : : FromInt ( 0 ) ) , x , <nl> + & if_xispositive , & if_xisnotpositive ) ; <nl> + <nl> + Bind ( & if_xispositive ) ; <nl> + { <nl> + / / Just return the input { x } . <nl> + Return ( x ) ; <nl> + } <nl> <nl> - Bind ( & if_notoverflow ) ; <nl> + Bind ( & if_xisnotpositive ) ; <nl> { <nl> - / / There is a Smi representation for negated { x } . <nl> - Node * result = Projection ( 0 , pair ) ; <nl> - Return ( BitcastWordToTagged ( result ) ) ; <nl> + / / Try to negate the { x } value . <nl> + pair = <nl> + IntPtrSubWithOverflow ( IntPtrConstant ( 0 ) , BitcastTaggedToWord ( x ) ) ; <nl> + Node * overflow = Projection ( 1 , pair ) ; <nl> + Branch ( overflow , & if_overflow , & if_notoverflow ) ; <nl> } <nl> + } <nl> <nl> - Bind ( & if_overflow ) ; <nl> - { Return ( NumberConstant ( 0 . 0 - Smi : : kMinValue ) ) ; } <nl> + Bind ( & if_notoverflow ) ; <nl> + { <nl> + / / There is a Smi representation for negated { x } . <nl> + Node * result = Projection ( 0 , pair ) ; <nl> + Return ( BitcastWordToTagged ( result ) ) ; <nl> } <nl> + <nl> + Bind ( & if_overflow ) ; <nl> + { Return ( NumberConstant ( 0 . 0 - Smi : : kMinValue ) ) ; } <nl> } <nl> <nl> Bind ( & if_xisnotsmi ) ; <nl> mmm a / src / compiler / arm / instruction - selector - arm . cc <nl> ppp b / src / compiler / arm / instruction - selector - arm . cc <nl> SIMD_BINOP_LIST ( SIMD_VISIT_BINOP ) <nl> SIMD_FORMAT_LIST ( SIMD_VISIT_SELECT_OP ) <nl> # undef SIMD_VISIT_SELECT_OP <nl> <nl> + void InstructionSelector : : VisitInt32AbsWithOverflow ( Node * node ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + void InstructionSelector : : VisitInt64AbsWithOverflow ( Node * node ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> / / static <nl> MachineOperatorBuilder : : Flags <nl> InstructionSelector : : SupportedMachineOperatorFlags ( ) { <nl> mmm a / src / compiler / arm64 / instruction - selector - arm64 . cc <nl> ppp b / src / compiler / arm64 / instruction - selector - arm64 . cc <nl> void InstructionSelector : : VisitAtomicCompareExchange ( Node * node ) { <nl> Emit ( code , 1 , outputs , input_count , inputs , 2 , temp ) ; <nl> } <nl> <nl> + void InstructionSelector : : VisitInt32AbsWithOverflow ( Node * node ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + void InstructionSelector : : VisitInt64AbsWithOverflow ( Node * node ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> / / static <nl> MachineOperatorBuilder : : Flags <nl> InstructionSelector : : SupportedMachineOperatorFlags ( ) { <nl> mmm a / src / compiler / code - assembler . cc <nl> ppp b / src / compiler / code - assembler . cc <nl> bool CodeAssembler : : IsFloat64RoundTruncateSupported ( ) const { <nl> return raw_assembler ( ) - > machine ( ) - > Float64RoundTruncate ( ) . IsSupported ( ) ; <nl> } <nl> <nl> + bool CodeAssembler : : IsInt32AbsWithOverflowSupported ( ) const { <nl> + return raw_assembler ( ) - > machine ( ) - > Int32AbsWithOverflow ( ) . IsSupported ( ) ; <nl> + } <nl> + <nl> + bool CodeAssembler : : IsInt64AbsWithOverflowSupported ( ) const { <nl> + return raw_assembler ( ) - > machine ( ) - > Int64AbsWithOverflow ( ) . IsSupported ( ) ; <nl> + } <nl> + <nl> + bool CodeAssembler : : IsIntPtrAbsWithOverflowSupported ( ) const { <nl> + return Is64 ( ) ? IsInt64AbsWithOverflowSupported ( ) <nl> + : IsInt32AbsWithOverflowSupported ( ) ; <nl> + } <nl> + <nl> Node * CodeAssembler : : Int32Constant ( int32_t value ) { <nl> return raw_assembler ( ) - > Int32Constant ( value ) ; <nl> } <nl> mmm a / src / compiler / code - assembler . h <nl> ppp b / src / compiler / code - assembler . h <nl> typedef std : : function < void ( ) > CodeAssemblerCallback ; <nl> V ( Float64RoundTruncate ) \ <nl> V ( Word32Clz ) \ <nl> V ( Word32Not ) \ <nl> + V ( Int32AbsWithOverflow ) \ <nl> + V ( Int64AbsWithOverflow ) \ <nl> + V ( IntPtrAbsWithOverflow ) \ <nl> V ( Word32BinaryNot ) <nl> <nl> / / A " public " interface used by components outside of compiler directory to <nl> class V8_EXPORT_PRIVATE CodeAssembler { <nl> bool IsFloat64RoundDownSupported ( ) const ; <nl> bool IsFloat64RoundTiesEvenSupported ( ) const ; <nl> bool IsFloat64RoundTruncateSupported ( ) const ; <nl> + bool IsInt32AbsWithOverflowSupported ( ) const ; <nl> + bool IsInt64AbsWithOverflowSupported ( ) const ; <nl> + bool IsIntPtrAbsWithOverflowSupported ( ) const ; <nl> <nl> / / Shortened aliases for use in CodeAssembler subclasses . <nl> typedef CodeAssemblerLabel Label ; <nl> mmm a / src / compiler / ia32 / instruction - selector - ia32 . cc <nl> ppp b / src / compiler / ia32 / instruction - selector - ia32 . cc <nl> void InstructionSelector : : VisitI32x4ReplaceLane ( Node * node ) { <nl> g . Use ( node - > InputAt ( 1 ) ) ) ; <nl> } <nl> <nl> + void InstructionSelector : : VisitInt32AbsWithOverflow ( Node * node ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + void InstructionSelector : : VisitInt64AbsWithOverflow ( Node * node ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> / / static <nl> MachineOperatorBuilder : : Flags <nl> InstructionSelector : : SupportedMachineOperatorFlags ( ) { <nl> mmm a / src / compiler / instruction - selector . cc <nl> ppp b / src / compiler / instruction - selector . cc <nl> void InstructionSelector : : VisitNode ( Node * node ) { <nl> return MarkAsWord32 ( node ) , VisitWord32ReverseBits ( node ) ; <nl> case IrOpcode : : kWord32ReverseBytes : <nl> return MarkAsWord32 ( node ) , VisitWord32ReverseBytes ( node ) ; <nl> + case IrOpcode : : kInt32AbsWithOverflow : <nl> + return MarkAsWord32 ( node ) , VisitInt32AbsWithOverflow ( node ) ; <nl> case IrOpcode : : kWord32Popcnt : <nl> return MarkAsWord32 ( node ) , VisitWord32Popcnt ( node ) ; <nl> case IrOpcode : : kWord64Popcnt : <nl> void InstructionSelector : : VisitNode ( Node * node ) { <nl> return MarkAsWord64 ( node ) , VisitWord64ReverseBits ( node ) ; <nl> case IrOpcode : : kWord64ReverseBytes : <nl> return MarkAsWord64 ( node ) , VisitWord64ReverseBytes ( node ) ; <nl> + case IrOpcode : : kInt64AbsWithOverflow : <nl> + return MarkAsWord64 ( node ) , VisitInt64AbsWithOverflow ( node ) ; <nl> case IrOpcode : : kWord64Equal : <nl> return VisitWord64Equal ( node ) ; <nl> case IrOpcode : : kInt32Add : <nl> void InstructionSelector : : VisitProjection ( Node * node ) { <nl> case IrOpcode : : kWord32PairShl : <nl> case IrOpcode : : kWord32PairShr : <nl> case IrOpcode : : kWord32PairSar : <nl> + case IrOpcode : : kInt32AbsWithOverflow : <nl> + case IrOpcode : : kInt64AbsWithOverflow : <nl> if ( ProjectionIndexOf ( node - > op ( ) ) = = 0u ) { <nl> Emit ( kArchNop , g . DefineSameAsFirst ( node ) , g . Use ( value ) ) ; <nl> } else { <nl> mmm a / src / compiler / machine - operator . cc <nl> ppp b / src / compiler / machine - operator . cc <nl> MachineType AtomicCompareExchangeRepresentationOf ( Operator const * op ) { <nl> V ( Word64ReverseBits , Operator : : kNoProperties , 1 , 0 , 1 ) \ <nl> V ( Word32ReverseBytes , Operator : : kNoProperties , 1 , 0 , 1 ) \ <nl> V ( Word64ReverseBytes , Operator : : kNoProperties , 1 , 0 , 1 ) \ <nl> + V ( Int32AbsWithOverflow , Operator : : kNoProperties , 1 , 0 , 1 ) \ <nl> + V ( Int64AbsWithOverflow , Operator : : kNoProperties , 1 , 0 , 1 ) \ <nl> V ( Word32Popcnt , Operator : : kNoProperties , 1 , 0 , 1 ) \ <nl> V ( Word64Popcnt , Operator : : kNoProperties , 1 , 0 , 1 ) \ <nl> V ( Float32RoundDown , Operator : : kNoProperties , 1 , 0 , 1 ) \ <nl> mmm a / src / compiler / machine - operator . h <nl> ppp b / src / compiler / machine - operator . h <nl> class V8_EXPORT_PRIVATE MachineOperatorBuilder final <nl> kWord64ReverseBits = 1u < < 17 , <nl> kWord32ReverseBytes = 1u < < 18 , <nl> kWord64ReverseBytes = 1u < < 19 , <nl> - kAllOptionalOps = kFloat32RoundDown | kFloat64RoundDown | kFloat32RoundUp | <nl> - kFloat64RoundUp | kFloat32RoundTruncate | <nl> - kFloat64RoundTruncate | kFloat64RoundTiesAway | <nl> - kFloat32RoundTiesEven | kFloat64RoundTiesEven | <nl> - kWord32Ctz | kWord64Ctz | kWord32Popcnt | kWord64Popcnt | <nl> - kWord32ReverseBits | kWord64ReverseBits | <nl> - kWord32ReverseBytes | kWord64ReverseBytes <nl> + kInt32AbsWithOverflow = 1u < < 20 , <nl> + kInt64AbsWithOverflow = 1u < < 21 , <nl> + kAllOptionalOps = <nl> + kFloat32RoundDown | kFloat64RoundDown | kFloat32RoundUp | <nl> + kFloat64RoundUp | kFloat32RoundTruncate | kFloat64RoundTruncate | <nl> + kFloat64RoundTiesAway | kFloat32RoundTiesEven | kFloat64RoundTiesEven | <nl> + kWord32Ctz | kWord64Ctz | kWord32Popcnt | kWord64Popcnt | <nl> + kWord32ReverseBits | kWord64ReverseBits | kWord32ReverseBytes | <nl> + kWord64ReverseBytes | kInt32AbsWithOverflow | kInt64AbsWithOverflow <nl> } ; <nl> typedef base : : Flags < Flag , unsigned > Flags ; <nl> <nl> class V8_EXPORT_PRIVATE MachineOperatorBuilder final <nl> const OptionalOperator Word64ReverseBits ( ) ; <nl> const OptionalOperator Word32ReverseBytes ( ) ; <nl> const OptionalOperator Word64ReverseBytes ( ) ; <nl> + const OptionalOperator Int32AbsWithOverflow ( ) ; <nl> + const OptionalOperator Int64AbsWithOverflow ( ) ; <nl> bool Word32ShiftIsSafe ( ) const { return flags_ & kWord32ShiftIsSafe ; } <nl> <nl> const Operator * Word64And ( ) ; <nl> mmm a / src / compiler / mips / instruction - selector - mips . cc <nl> ppp b / src / compiler / mips / instruction - selector - mips . cc <nl> void InstructionSelector : : VisitAtomicCompareExchange ( Node * node ) { <nl> UNIMPLEMENTED ( ) ; <nl> } <nl> <nl> + void InstructionSelector : : VisitInt32AbsWithOverflow ( Node * node ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + void InstructionSelector : : VisitInt64AbsWithOverflow ( Node * node ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> / / static <nl> MachineOperatorBuilder : : Flags <nl> InstructionSelector : : SupportedMachineOperatorFlags ( ) { <nl> mmm a / src / compiler / mips64 / instruction - selector - mips64 . cc <nl> ppp b / src / compiler / mips64 / instruction - selector - mips64 . cc <nl> void InstructionSelector : : VisitAtomicCompareExchange ( Node * node ) { <nl> UNIMPLEMENTED ( ) ; <nl> } <nl> <nl> + void InstructionSelector : : VisitInt32AbsWithOverflow ( Node * node ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + void InstructionSelector : : VisitInt64AbsWithOverflow ( Node * node ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> / / static <nl> MachineOperatorBuilder : : Flags <nl> InstructionSelector : : SupportedMachineOperatorFlags ( ) { <nl> mmm a / src / compiler / opcodes . h <nl> ppp b / src / compiler / opcodes . h <nl> <nl> # define MACHINE_UNOP_32_LIST ( V ) \ <nl> V ( Word32Clz ) \ <nl> V ( Word32Ctz ) \ <nl> + V ( Int32AbsWithOverflow ) \ <nl> V ( Word32ReverseBits ) \ <nl> V ( Word32ReverseBytes ) <nl> <nl> <nl> V ( Word64Ctz ) \ <nl> V ( Word64ReverseBits ) \ <nl> V ( Word64ReverseBytes ) \ <nl> + V ( Int64AbsWithOverflow ) \ <nl> V ( BitcastTaggedToWord ) \ <nl> V ( BitcastWordToTagged ) \ <nl> V ( BitcastWordToTaggedSigned ) \ <nl> mmm a / src / compiler / ppc / instruction - selector - ppc . cc <nl> ppp b / src / compiler / ppc / instruction - selector - ppc . cc <nl> void InstructionSelector : : VisitAtomicCompareExchange ( Node * node ) { <nl> UNIMPLEMENTED ( ) ; <nl> } <nl> <nl> + void InstructionSelector : : VisitInt32AbsWithOverflow ( Node * node ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + void InstructionSelector : : VisitInt64AbsWithOverflow ( Node * node ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> / / static <nl> MachineOperatorBuilder : : Flags <nl> InstructionSelector : : SupportedMachineOperatorFlags ( ) { <nl> mmm a / src / compiler / raw - machine - assembler . h <nl> ppp b / src / compiler / raw - machine - assembler . h <nl> class V8_EXPORT_PRIVATE RawMachineAssembler { <nl> <nl> # undef UINTPTR_BINOP <nl> <nl> + Node * Int32AbsWithOverflow ( Node * a ) { <nl> + return AddNode ( machine ( ) - > Int32AbsWithOverflow ( ) . op ( ) , a ) ; <nl> + } <nl> + <nl> + Node * Int64AbsWithOverflow ( Node * a ) { <nl> + return AddNode ( machine ( ) - > Int64AbsWithOverflow ( ) . op ( ) , a ) ; <nl> + } <nl> + <nl> + Node * IntPtrAbsWithOverflow ( Node * a ) { <nl> + return kPointerSize = = 8 ? Int64AbsWithOverflow ( a ) <nl> + : Int32AbsWithOverflow ( a ) ; <nl> + } <nl> + <nl> Node * Float32Add ( Node * a , Node * b ) { <nl> return AddNode ( machine ( ) - > Float32Add ( ) , a , b ) ; <nl> } <nl> mmm a / src / compiler / s390 / code - generator - s390 . cc <nl> ppp b / src / compiler / s390 / code - generator - s390 . cc <nl> Condition FlagsConditionToCondition ( FlagsCondition condition , ArchOpcode op ) { <nl> case kS390_Add64 : <nl> case kS390_Sub32 : <nl> case kS390_Sub64 : <nl> + case kS390_Abs64 : <nl> + case kS390_Abs32 : <nl> return overflow ; <nl> default : <nl> break ; <nl> CodeGenerator : : CodeGenResult CodeGenerator : : AssembleArchInstruction ( <nl> Operand ( offset . offset ( ) ) ) ; <nl> break ; <nl> } <nl> + case kS390_Abs32 : <nl> + / / TODO ( john . yan ) : zero - ext <nl> + __ lpr ( i . OutputRegister ( 0 ) , i . InputRegister ( 0 ) ) ; <nl> + break ; <nl> + case kS390_Abs64 : <nl> + __ lpgr ( i . OutputRegister ( 0 ) , i . InputRegister ( 0 ) ) ; <nl> + break ; <nl> case kS390_And32 : <nl> / / zero - ext <nl> if ( CpuFeatures : : IsSupported ( DISTINCT_OPS ) ) { <nl> CodeGenerator : : CodeGenResult CodeGenerator : : AssembleArchInstruction ( <nl> if ( HasRegisterInput ( instr , 1 ) ) { <nl> __ And ( r0 , i . InputRegister ( 0 ) , i . InputRegister ( 1 ) ) ; <nl> } else { <nl> + / / detect tmlh / tmhl / tmhh case <nl> Operand opnd = i . InputImmediate ( 1 ) ; <nl> if ( is_uint16 ( opnd . immediate ( ) ) ) { <nl> __ tmll ( i . InputRegister ( 0 ) , opnd ) ; <nl> mmm a / src / compiler / s390 / instruction - codes - s390 . h <nl> ppp b / src / compiler / s390 / instruction - codes - s390 . h <nl> namespace compiler { <nl> / / S390 - specific opcodes that specify which assembly sequence to emit . <nl> / / Most opcodes specify a single instruction . <nl> # define TARGET_ARCH_OPCODE_LIST ( V ) \ <nl> + V ( S390_Abs32 ) \ <nl> + V ( S390_Abs64 ) \ <nl> V ( S390_And32 ) \ <nl> V ( S390_And64 ) \ <nl> V ( S390_Or32 ) \ <nl> mmm a / src / compiler / s390 / instruction - scheduler - s390 . cc <nl> ppp b / src / compiler / s390 / instruction - scheduler - s390 . cc <nl> bool InstructionScheduler : : SchedulerSupported ( ) { return true ; } <nl> int InstructionScheduler : : GetTargetInstructionFlags ( <nl> const Instruction * instr ) const { <nl> switch ( instr - > arch_opcode ( ) ) { <nl> + case kS390_Abs32 : <nl> + case kS390_Abs64 : <nl> case kS390_And32 : <nl> case kS390_And64 : <nl> case kS390_Or32 : <nl> mmm a / src / compiler / s390 / instruction - selector - s390 . cc <nl> ppp b / src / compiler / s390 / instruction - selector - s390 . cc <nl> bool ProduceWord32Result ( Node * node ) { <nl> switch ( load_rep . representation ( ) ) { <nl> case MachineRepresentation : : kWord32 : <nl> return true ; <nl> + case MachineRepresentation : : kWord8 : <nl> + if ( load_rep . IsSigned ( ) ) <nl> + return false ; <nl> + else <nl> + return true ; <nl> default : <nl> return false ; <nl> } <nl> void VisitBinOp ( InstructionSelector * selector , Node * node , <nl> V ( Word32 , Unary , [ ] ( ArchOpcode opcode ) { \ <nl> return opcode = = kS390_LoadWordS32 | | opcode = = kS390_LoadWordU32 ; \ <nl> } ) \ <nl> + V ( Word64 , Unary , \ <nl> + [ ] ( ArchOpcode opcode ) { return opcode = = kS390_LoadWord64 ; } ) \ <nl> V ( Float32 , Unary , \ <nl> [ ] ( ArchOpcode opcode ) { return opcode = = kS390_LoadFloat32 ; } ) \ <nl> V ( Float64 , Unary , \ <nl> void VisitBinOp ( InstructionSelector * selector , Node * node , <nl> # if V8_TARGET_ARCH_S390X <nl> # define VISIT_OP_LIST ( V ) \ <nl> VISIT_OP_LIST_32 ( V ) \ <nl> - V ( Word64 , Unary , \ <nl> - [ ] ( ArchOpcode opcode ) { return opcode = = kS390_LoadWord64 ; } ) \ <nl> V ( Word64 , Bin , [ ] ( ArchOpcode opcode ) { return opcode = = kS390_LoadWord64 ; } ) <nl> # else <nl> # define VISIT_OP_LIST VISIT_OP_LIST_32 <nl> void InstructionSelector : : VisitWord32ReverseBits ( Node * node ) { UNREACHABLE ( ) ; } <nl> void InstructionSelector : : VisitWord64ReverseBits ( Node * node ) { UNREACHABLE ( ) ; } <nl> # endif <nl> <nl> + void InstructionSelector : : VisitInt32AbsWithOverflow ( Node * node ) { <nl> + VisitWord32UnaryOp ( this , node , kS390_Abs32 , OperandMode : : kNone ) ; <nl> + } <nl> + <nl> + void InstructionSelector : : VisitInt64AbsWithOverflow ( Node * node ) { <nl> + VisitWord64UnaryOp ( this , node , kS390_Abs64 , OperandMode : : kNone ) ; <nl> + } <nl> + <nl> void InstructionSelector : : VisitWord64ReverseBytes ( Node * node ) { <nl> S390OperandGenerator g ( this ) ; <nl> Emit ( kS390_LoadReverse64RR , g . DefineAsRegister ( node ) , <nl> void VisitWordCompareZero ( InstructionSelector * selector , Node * user , <nl> selector , node , kS390_Mul32WithOverflow , <nl> OperandMode : : kInt32Imm | OperandMode : : kAllowDistinctOps , <nl> cont ) ; <nl> + case IrOpcode : : kInt32AbsWithOverflow : <nl> + cont - > OverwriteAndNegateIfEqual ( kOverflow ) ; <nl> + return VisitWord32UnaryOp ( selector , node , kS390_Abs32 , <nl> + OperandMode : : kNone , cont ) ; <nl> # if V8_TARGET_ARCH_S390X <nl> + case IrOpcode : : kInt64AbsWithOverflow : <nl> + cont - > OverwriteAndNegateIfEqual ( kOverflow ) ; <nl> + return VisitWord64UnaryOp ( selector , node , kS390_Abs64 , <nl> + OperandMode : : kNone , cont ) ; <nl> case IrOpcode : : kInt64AddWithOverflow : <nl> cont - > OverwriteAndNegateIfEqual ( kOverflow ) ; <nl> return VisitWord64BinOp ( selector , node , kS390_Add64 , <nl> InstructionSelector : : SupportedMachineOperatorFlags ( ) { <nl> MachineOperatorBuilder : : kWord32Popcnt | <nl> MachineOperatorBuilder : : kWord32ReverseBytes | <nl> MachineOperatorBuilder : : kWord64ReverseBytes | <nl> + MachineOperatorBuilder : : kInt32AbsWithOverflow | <nl> + MachineOperatorBuilder : : kInt64AbsWithOverflow | <nl> MachineOperatorBuilder : : kWord64Popcnt ; <nl> } <nl> <nl> mmm a / src / compiler / verifier . cc <nl> ppp b / src / compiler / verifier . cc <nl> void Verifier : : Visitor : : Check ( Node * node ) { <nl> case IrOpcode : : kWord32Ctz : <nl> case IrOpcode : : kWord32ReverseBits : <nl> case IrOpcode : : kWord32ReverseBytes : <nl> + case IrOpcode : : kInt32AbsWithOverflow : <nl> case IrOpcode : : kWord32Popcnt : <nl> case IrOpcode : : kWord64And : <nl> case IrOpcode : : kWord64Or : <nl> void Verifier : : Visitor : : Check ( Node * node ) { <nl> case IrOpcode : : kWord64Ctz : <nl> case IrOpcode : : kWord64ReverseBits : <nl> case IrOpcode : : kWord64ReverseBytes : <nl> + case IrOpcode : : kInt64AbsWithOverflow : <nl> case IrOpcode : : kWord64Equal : <nl> case IrOpcode : : kInt32Add : <nl> case IrOpcode : : kInt32AddWithOverflow : <nl> mmm a / src / compiler / x64 / instruction - selector - x64 . cc <nl> ppp b / src / compiler / x64 / instruction - selector - x64 . cc <nl> void InstructionSelector : : VisitS32x4Select ( Node * node ) { <nl> g . UseRegister ( node - > InputAt ( 2 ) ) ) ; <nl> } <nl> <nl> + void InstructionSelector : : VisitInt32AbsWithOverflow ( Node * node ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + void InstructionSelector : : VisitInt64AbsWithOverflow ( Node * node ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> / / static <nl> MachineOperatorBuilder : : Flags <nl> InstructionSelector : : SupportedMachineOperatorFlags ( ) { <nl> mmm a / src / compiler / x87 / instruction - selector - x87 . cc <nl> ppp b / src / compiler / x87 / instruction - selector - x87 . cc <nl> void InstructionSelector : : VisitAtomicStore ( Node * node ) { <nl> Emit ( code , 0 , nullptr , input_count , inputs ) ; <nl> } <nl> <nl> + void InstructionSelector : : VisitInt32AbsWithOverflow ( Node * node ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> + void InstructionSelector : : VisitInt64AbsWithOverflow ( Node * node ) { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> / / static <nl> MachineOperatorBuilder : : Flags <nl> InstructionSelector : : SupportedMachineOperatorFlags ( ) { <nl> mmm a / src / s390 / disasm - s390 . cc <nl> ppp b / src / s390 / disasm - s390 . cc <nl> bool Decoder : : DecodeFourByte ( Instruction * instr ) { <nl> break ; <nl> } <nl> case LPGR : <nl> - Format ( instr , " lpgr \ t ' r1 , ' r2 " ) ; <nl> + Format ( instr , " lpgr \ t ' r5 , ' r6 " ) ; <nl> break ; <nl> case LPGFR : <nl> - Format ( instr , " lpgfr \ t ' r1 , ' r2 " ) ; <nl> + Format ( instr , " lpgfr \ t ' r5 , ' r6 " ) ; <nl> break ; <nl> default : <nl> return false ; <nl>
[ turbofan ] introduce Int32 / 64AbsWithOverflow optional operator
v8/v8
ab5a0e2fed25e8215d160c25962141dd41fcafca
2017-03-31T14:12:46Z
mmm a / modules / stitching / src / blenders . cpp <nl> ppp b / modules / stitching / src / blenders . cpp <nl> static bool ocl_normalizeUsingWeightMap ( InputArray _weight , InputOutputArray _ma <nl> <nl> void normalizeUsingWeightMap ( InputArray _weight , InputOutputArray _src ) <nl> { <nl> - Mat src = _src . getMat ( ) ; <nl> - Mat weight = _weight . getMat ( ) ; <nl> + Mat src ; <nl> + Mat weight ; <nl> # ifdef HAVE_TEGRA_OPTIMIZATION <nl> + src = _src . getMat ( ) ; <nl> + weight = _weight . getMat ( ) ; <nl> if ( tegra : : normalizeUsingWeightMap ( weight , src ) ) <nl> return ; <nl> # endif <nl> void normalizeUsingWeightMap ( InputArray _weight , InputOutputArray _src ) <nl> ! ocl_normalizeUsingWeightMap ( _weight , _src ) ) <nl> # endif <nl> { <nl> + src = _src . getMat ( ) ; <nl> + weight = _weight . getMat ( ) ; <nl> + <nl> CV_Assert ( src . type ( ) = = CV_16SC3 ) ; <nl> <nl> - if ( weight . type ( ) = = CV_32FC1 ) <nl> + if ( weight . type ( ) = = CV_32FC1 ) <nl> { <nl> for ( int y = 0 ; y < src . rows ; + + y ) <nl> { <nl>
Accuracy fix for blenaders in stitching module .
opencv/opencv
cc97c57fd495c25c7872d25a7acef7c100e5cfed
2015-01-18T17:45:57Z
mmm a / lib / Sema / CSApply . cpp <nl> ppp b / lib / Sema / CSApply . cpp <nl> Expr * ExprRewriter : : coerceToType ( Expr * expr , Type toType , <nl> fromType = expr - > getType ( ) ; <nl> } <nl> <nl> + / / Coercion of a SuperRefExpr . Refine the type of the ' super ' reference <nl> + / / instead of inserting a derived - to - base conversion . <nl> + if ( auto superRef = dyn_cast < SuperRefExpr > ( expr ) ) { <nl> + assert ( tc . isSubtypeOf ( fromType , toType , dc ) & & <nl> + " coercing super expr to non - supertype ? ! " ) ; <nl> + superRef - > setType ( toType ) ; <nl> + return expr ; <nl> + } <nl> + <nl> / / Coercion from subclass to superclass . <nl> return new ( tc . Context ) DerivedToBaseExpr ( expr , toType ) ; <nl> } <nl> Expr * ExprRewriter : : coerceToType ( Expr * expr , Type toType , <nl> return expr ; <nl> } <nl> <nl> + / / Coercion of a SuperRefExpr . Refine the type of the ' super ' reference <nl> + / / instead of inserting a derived - to - base conversion . <nl> + if ( auto superRef = dyn_cast < SuperRefExpr > ( expr ) ) { <nl> + assert ( tc . isSubtypeOf ( fromType , toType , dc ) & & <nl> + " coercing super expr to non - supertype ? ! " ) ; <nl> + superRef - > setType ( toType ) ; <nl> + return expr ; <nl> + } <nl> + <nl> / / Coercion from subclass to superclass . <nl> expr = new ( tc . Context ) DerivedToBaseExpr ( expr , toType ) ; <nl> return expr ; <nl>
Revert r14559 ; we still need to cannibalize SuperRefExprs for DI .
apple/swift
b9c1785421214cb6e8a753da9b7430b21b8ef1f1
2014-03-01T22:36:27Z
mmm a / src / objects . cc <nl> ppp b / src / objects . cc <nl> void JSObject : : AddProperty ( Handle < JSObject > object , Handle < Name > name , <nl> <nl> / / static <nl> void ExecutableAccessorInfo : : ClearSetter ( Handle < ExecutableAccessorInfo > info ) { <nl> - info - > set_setter ( * v8 : : FromCData ( info - > GetIsolate ( ) , nullptr ) ) ; <nl> + Handle < Object > object = v8 : : FromCData ( info - > GetIsolate ( ) , nullptr ) ; <nl> + info - > set_setter ( * object ) ; <nl> } <nl> <nl> <nl>
Fix GCMole issue
v8/v8
b263ac33b5ef9d9a39aec62db0948f08f43cf059
2015-06-11T15:41:24Z
mmm a / setup . py <nl> ppp b / setup . py <nl> <nl> from distutils . command . build import build as _build <nl> from distutils . errors import DistutilsSetupError <nl> from distutils . spawn import find_executable <nl> + from distutils . sysconfig import get_python_inc , get_python_version <nl> from distutils import log <nl> import os <nl> import sys <nl> def build_dlib ( ) : <nl> <nl> # make sure build artifacts are generated for the version of Python currently running <nl> cmake_extra_arch = [ ] <nl> + if sys . version_info > = ( 3 , 0 ) : <nl> + cmake_extra_arch + = [ ' - DPYTHON3 = yes ' ] <nl> + <nl> if platform_arch = = ' 64bit ' : <nl> - cmake_extra_arch = [ ' - DCMAKE_SIZEOF_VOID_P = 8 ' ] <nl> + cmake_extra_arch + = [ ' - DCMAKE_SIZEOF_VOID_P = 8 ' ] <nl> elif platform_arch = = ' 32bit ' : <nl> - cmake_extra_arch = [ ' - DCMAKE_SIZEOF_VOID_P = 4 ' ] <nl> + cmake_extra_arch + = [ ' - DCMAKE_SIZEOF_VOID_P = 4 ' ] <nl> + <nl> + if platform_arch = = ' 64bit ' and sys . platform = = " win32 " : <nl> + # help cmake to find Python library in 64bit Python in Windows <nl> + # because cmake is 32bit and cannot find PYTHON_LIBRARY from registry . <nl> + inc_dir = get_python_inc ( ) <nl> + cmake_extra_arch + = [ ' - DPYTHON_INCLUDE_DIR = { inc } ' . format ( inc = inc_dir ) ] <nl> + <nl> + # this imitates cmake in path resolution <nl> + py_ver = get_python_version ( ) <nl> + for ext in [ py_ver . replace ( " . " , " " ) + ' . lib ' , py_ver + ' mu . lib ' , py_ver + ' m . lib ' , py_ver + ' u . lib ' ] : <nl> + py_lib = os . path . abspath ( os . path . join ( inc_dir , ' . . / libs / ' , ' python ' + ext ) ) <nl> + if os . path . exists ( py_lib ) : <nl> + cmake_extra_arch + = [ ' - DPYTHON_LIBRARY = { lib } ' . format ( lib = py_lib ) ] <nl> + break <nl> <nl> build_dir = os . path . join ( script_dir , " . / tools / python / build " ) <nl> if os . path . exists ( build_dir ) : <nl>
find 64bit Python libraries on 64bit Windows when cmake is 32bit
davisking/dlib
6e2ed37f76b15d23d588f67a346c8bec007d5cb2
2015-08-26T21:53:13Z
mmm a / utils / build - script - impl <nl> ppp b / utils / build - script - impl <nl> for host in " $ { ALL_HOSTS [ @ ] } " ; do <nl> fi <nl> <nl> # Construct dotest arguments . We use semicolons so CMake interprets this as a list . <nl> - DOTEST_ARGS = " - - build - dir ; $ { lldb_build_dir } / lldb - test - build . noindex ; $ { LLDB_TEST_CATEGORIES } ; - t " <nl> + DOTEST_ARGS = " - - build - dir ; $ { lldb_build_dir } / lldb - test - build . noindex ; $ { LLDB_TEST_CATEGORIES } " <nl> <nl> # Only set the extra arguments if they ' re not empty . <nl> if [ [ - n " $ { DOTEST_EXTRA } " ] ] ; then <nl>
Merge remote - tracking branch ' origin / main ' into next
apple/swift
f7019e988c1cdbc6e00c8af77d061cccd5424316
2020-10-03T22:46:56Z
mmm a / doc / classes / Color . xml <nl> ppp b / doc / classes / Color . xml <nl> <nl> < return type = " Color " > <nl> < / return > <nl> < description > <nl> - Returns the inverted color [ code ] ( 1 - r , 1 - g , 1 - b , 1 - a ) [ / code ] . <nl> + Returns the inverted color [ code ] ( 1 - r , 1 - g , 1 - b , a ) [ / code ] . <nl> [ codeblock ] <nl> var c = Color ( 0 . 3 , 0 . 4 , 0 . 9 ) <nl> var inverted_color = c . inverted ( ) # a color of an RGBA ( 178 , 153 , 26 , 255 ) <nl>
Fixing returned alpha component for inverted method
godotengine/godot
024d5958507814164bcf5c9794d8ae3763f05cf0
2019-06-07T23:44:25Z
mmm a / src / node / ext / call_credentials . cc <nl> ppp b / src / node / ext / call_credentials . cc <nl> using v8 : : Value ; <nl> Nan : : Callback * CallCredentials : : constructor ; <nl> Persistent < FunctionTemplate > CallCredentials : : fun_tpl ; <nl> <nl> + static Callback * plugin_callback ; <nl> + <nl> CallCredentials : : CallCredentials ( grpc_call_credentials * credentials ) <nl> : wrapped_credentials ( credentials ) { } <nl> <nl> void CallCredentials : : Init ( Local < Object > exports ) { <nl> Nan : : New < FunctionTemplate > ( CreateFromPlugin ) ) . ToLocalChecked ( ) ) ; <nl> Nan : : Set ( exports , Nan : : New ( " CallCredentials " ) . ToLocalChecked ( ) , ctr ) ; <nl> constructor = new Nan : : Callback ( ctr ) ; <nl> + <nl> + Local < FunctionTemplate > callback_tpl = <nl> + Nan : : New < FunctionTemplate > ( PluginCallback ) ; <nl> + plugin_callback = new Callback ( <nl> + Nan : : GetFunction ( callback_tpl ) . ToLocalChecked ( ) ) ; <nl> } <nl> <nl> bool CallCredentials : : HasInstance ( Local < Value > val ) { <nl> NAN_METHOD ( PluginCallback ) { <nl> return Nan : : ThrowTypeError ( <nl> " The callback ' s third argument must be an object " ) ; <nl> } <nl> + if ( ! info [ 3 ] - > IsObject ( ) ) { <nl> + return Nan : : ThrowTypeError ( <nl> + " The callback ' s fourth argument must be an object " ) ; <nl> + } <nl> shared_ptr < Resources > resources ( new Resources ) ; <nl> grpc_status_code code = static_cast < grpc_status_code > ( <nl> Nan : : To < uint32_t > ( info [ 0 ] ) . FromJust ( ) ) ; <nl> Utf8String details_utf8_str ( info [ 1 ] ) ; <nl> char * details = * details_utf8_str ; <nl> grpc_metadata_array array ; <nl> + Local < Object > callback_data = Nan : : To < Object > ( info [ 3 ] ) . ToLocalChecked ( ) ; <nl> if ( ! CreateMetadataArray ( Nan : : To < Object > ( info [ 2 ] ) . ToLocalChecked ( ) , <nl> & array , resources ) ) { <nl> return Nan : : ThrowError ( " Failed to parse metadata " ) ; <nl> } <nl> grpc_credentials_plugin_metadata_cb cb = <nl> reinterpret_cast < grpc_credentials_plugin_metadata_cb > ( <nl> - Nan : : Get ( info . Callee ( ) , <nl> + Nan : : Get ( callback_data , <nl> Nan : : New ( " cb " ) . ToLocalChecked ( ) <nl> ) . ToLocalChecked ( ) . As < External > ( ) - > Value ( ) ) ; <nl> void * user_data = <nl> - Nan : : Get ( info . Callee ( ) , <nl> + Nan : : Get ( callback_data , <nl> Nan : : New ( " user_data " ) . ToLocalChecked ( ) <nl> ) . ToLocalChecked ( ) . As < External > ( ) - > Value ( ) ; <nl> cb ( user_data , array . metadata , array . count , code , details ) ; <nl> NAUV_WORK_CB ( SendPluginCallback ) { <nl> while ( ! callbacks . empty ( ) ) { <nl> plugin_callback_data * data = callbacks . front ( ) ; <nl> callbacks . pop_front ( ) ; <nl> - / / Attach cb and user_data to plugin_callback so that it can access them later <nl> - v8 : : Local < v8 : : Function > plugin_callback = Nan : : GetFunction ( <nl> - Nan : : New < v8 : : FunctionTemplate > ( PluginCallback ) ) . ToLocalChecked ( ) ; <nl> - Nan : : Set ( plugin_callback , Nan : : New ( " cb " ) . ToLocalChecked ( ) , <nl> + Local < Object > callback_data = Nan : : New < Object > ( ) ; <nl> + Nan : : Set ( callback_data , Nan : : New ( " cb " ) . ToLocalChecked ( ) , <nl> Nan : : New < v8 : : External > ( reinterpret_cast < void * > ( data - > cb ) ) ) ; <nl> - Nan : : Set ( plugin_callback , Nan : : New ( " user_data " ) . ToLocalChecked ( ) , <nl> + Nan : : Set ( callback_data , Nan : : New ( " user_data " ) . ToLocalChecked ( ) , <nl> Nan : : New < v8 : : External > ( data - > user_data ) ) ; <nl> - const int argc = 2 ; <nl> + const int argc = 3 ; <nl> v8 : : Local < v8 : : Value > argv [ argc ] = { <nl> Nan : : New ( data - > service_url ) . ToLocalChecked ( ) , <nl> - plugin_callback <nl> + callback_data , <nl> + / / Get Local < Function > from Nan : : Callback * <nl> + * * plugin_callback <nl> } ; <nl> Nan : : Callback * callback = state - > callback ; <nl> callback - > Call ( argc , argv ) ; <nl> mmm a / src / node / src / credentials . js <nl> ppp b / src / node / src / credentials . js <nl> exports . createSsl = ChannelCredentials . createSsl ; <nl> * @ return { CallCredentials } The credentials object <nl> * / <nl> exports . createFromMetadataGenerator = function ( metadata_generator ) { <nl> - return CallCredentials . createFromPlugin ( function ( service_url , callback ) { <nl> + return CallCredentials . createFromPlugin ( function ( service_url , cb_data , <nl> + callback ) { <nl> metadata_generator ( { service_url : service_url } , function ( error , metadata ) { <nl> var code = grpc . status . OK ; <nl> var message = ' ' ; <nl> exports . createFromMetadataGenerator = function ( metadata_generator ) { <nl> metadata = new Metadata ( ) ; <nl> } <nl> } <nl> - callback ( code , message , metadata . _getCoreRepresentation ( ) ) ; <nl> + callback ( code , message , metadata . _getCoreRepresentation ( ) , cb_data ) ; <nl> } ) ; <nl> } ) ; <nl> } ; <nl>
Fix a memory leak in Node call credentials
grpc/grpc
ef55d7e02f719d56b9abfb4fb785e9e5b7c44e77
2016-07-14T20:22:22Z
mmm a / hphp / hack / src / emitter / emitter_types . ml <nl> ppp b / hphp / hack / src / emitter / emitter_types . ml <nl> let fmt_prim x = <nl> | N . Tbool - > " HH \ \ bool " <nl> | N . Tfloat - > " HH \ \ float " <nl> | N . Tstring - > " HH \ \ string " <nl> - | N . Tclassname _ - > " HH \ \ string " <nl> | N . Tnum - > " HH \ \ num " <nl> | N . Tresource - > " HH \ \ resource " <nl> | N . Tarraykey - > " HH \ \ arraykey " <nl> mmm a / hphp / hack / src / naming / nast . ml <nl> ppp b / hphp / hack / src / naming / nast . ml <nl> and tprim = <nl> | Tbool <nl> | Tfloat <nl> | Tstring <nl> - | Tclassname of string ( * C : : class * ) <nl> | Tresource <nl> | Tnum <nl> | Tarraykey <nl> mmm a / hphp / hack / src / typing / typing . ml <nl> ppp b / hphp / hack / src / typing / typing . ml <nl> and class_const env p ( cid , mid ) = <nl> | CIstatic | CIvar _ - > ( ) ; <nl> | _ - > Errors . abstract_const_usage p ( Reason . to_pos r ) n ; ( ) <nl> in env , const_ty <nl> - | r , Tprim ( Tclassname name ) when ( snd mid ) = SN . Members . mClass - > <nl> - ( * X : : class is a Tclassname ; $ foo : : class is a classname < Foo > * ) <nl> - ( match cid with <nl> - | CIstatic | CIvar _ | CIparent - > <nl> - let r_witness = Reason . Rwitness p in <nl> - let cls_ty = r , Tclass ( ( Reason . to_pos r , name ) , [ ] ) in <nl> - let classname_ty = r_witness , <nl> - Tabstract ( AKnewtype ( SN . Classes . cClassname , [ cls_ty ] ) , None ) in <nl> - env , classname_ty <nl> - | CI _ | CIself - > env , const_ty <nl> - ) <nl> | _ - > <nl> env , const_ty <nl> <nl> mmm a / hphp / hack / src / typing / typingEqualityCheck . ml <nl> ppp b / hphp / hack / src / typing / typingEqualityCheck . ml <nl> let rec assert_nontrivial p bop env ty1 ty2 = <nl> match ty1 , ty2 with <nl> | ( _ , Tprim N . Tnum ) , ( _ , Tprim ( N . Tint | N . Tfloat ) ) <nl> | ( _ , Tprim ( N . Tint | N . Tfloat ) ) , ( _ , Tprim N . Tnum ) - > ( ) <nl> - | ( _ , Tprim N . Tstring ) , ( _ , Tprim ( N . Tclassname _ ) ) <nl> - | ( _ , Tprim ( N . Tclassname _ ) ) , ( _ , Tprim N . Tstring ) - > ( ) <nl> - | ( _ , Tprim N . Tarraykey ) , ( _ , Tprim ( N . Tint | N . Tstring | N . Tclassname _ ) ) <nl> - | ( _ , Tprim ( N . Tint | N . Tstring | N . Tclassname _ ) ) , ( _ , Tprim N . Tarraykey ) - > ( ) <nl> + | ( _ , Tprim N . Tarraykey ) , ( _ , Tprim ( N . Tint | N . Tstring ) ) <nl> + | ( _ , Tprim ( N . Tint | N . Tstring ) ) , ( _ , Tprim N . Tarraykey ) - > ( ) <nl> | ( r , Tprim N . Tnoreturn ) , _ <nl> | _ , ( r , Tprim N . Tnoreturn ) - > <nl> Errors . noreturn_usage p ( Reason . to_string ( " This always throws or exits " ) r ) <nl> mmm a / hphp / hack / src / typing / typing_decl . ml <nl> ppp b / hphp / hack / src / typing / typing_decl . ml <nl> and class_const_decl c ( env , acc ) ( h , id , e ) = <nl> and class_class_decl class_id = <nl> let pos , name = class_id in <nl> let reason = Reason . Rclass_class ( pos , name ) in <nl> - let classname_ty = ( reason , Tprim ( Tclassname name ) ) in <nl> + let classname_ty = <nl> + reason , Tapply ( ( pos , SN . Classes . cClassname ) , <nl> + [ reason , Tapply ( class_id , [ ] ) ] ) in <nl> { <nl> ce_final = false ; <nl> ce_is_xhp_attr = false ; <nl> mmm a / hphp / hack / src / typing / typing_enum . ml <nl> ppp b / hphp / hack / src / typing / typing_enum . ml <nl> let check_valid_array_key_type f_fail ~ allow_any : allow_any env p t = <nl> let env , ( r , t ' ) , trail = <nl> Typing_tdef . force_expand_typedef ~ ety_env env t in <nl> ( match t ' with <nl> - | Tprim ( Tint | Tstring | Tclassname _ ) - > ( ) <nl> + | Tprim ( Tint | Tstring ) - > ( ) <nl> ( * Enums have to be valid array keys * ) <nl> | Tabstract ( AKenum _ , _ ) - > ( ) <nl> | Tany when allow_any - > ( ) <nl> mmm a / hphp / hack / src / typing / typing_env . ml <nl> ppp b / hphp / hack / src / typing / typing_env . ml <nl> let rec debug stack env ( r , ty ) = <nl> | Tbool - > o " Tbool " <nl> | Tfloat - > o " Tfloat " <nl> | Tstring - > o " Tstring " <nl> - | Tclassname s - > o " Tclassname < " ; o s ; o " > " <nl> | Tnum - > o " Tnum " <nl> | Tresource - > o " Tresource " <nl> | Tarraykey - > o " Tarraykey " <nl> mmm a / hphp / hack / src / typing / typing_print . ml <nl> ppp b / hphp / hack / src / typing / typing_print . ml <nl> module ErrorString = struct <nl> | Nast . Tbool - > " a bool " <nl> | Nast . Tfloat - > " a float " <nl> | Nast . Tstring - > " a string " <nl> - | Nast . Tclassname s - > " string ( " ^ s ^ " : : class ) " <nl> | Nast . Tnum - > " a num ( int / float ) " <nl> | Nast . Tresource - > " a resource " <nl> | Nast . Tarraykey - > " an array key ( int / string ) " <nl> module Suggest = struct <nl> | Nast . Tbool - > " bool " <nl> | Nast . Tfloat - > " float " <nl> | Nast . Tstring - > " string " <nl> - | Nast . Tclassname s - > " string ( " ^ s ^ " : : class ) " <nl> | Nast . Tnum - > " num ( int / float ) " <nl> | Nast . Tresource - > " resource " <nl> | Nast . Tarraykey - > " arraykey ( int / string ) " <nl> module Full = struct <nl> | Nast . Tbool - > " bool " <nl> | Nast . Tfloat - > " float " <nl> | Nast . Tstring - > " string " <nl> - | Nast . Tclassname s - > " string ( " ^ s ^ " : : class ) " <nl> | Nast . Tnum - > " num " <nl> | Nast . Tresource - > " resource " <nl> | Nast . Tarraykey - > " arraykey " <nl> mmm a / hphp / hack / src / typing / typing_subtype . ml <nl> ppp b / hphp / hack / src / typing / typing_subtype . ml <nl> and sub_type_with_uenv env ( uenv_super , ty_super ) ( uenv_sub , ty_sub ) = <nl> end <nl> | ( _ , Tmixed ) , _ - > env <nl> | ( _ , Tprim Nast . Tnum ) , ( _ , Tprim ( Nast . Tint | Nast . Tfloat ) ) - > env <nl> - | ( _ , Tprim Nast . Tarraykey ) , ( _ , Tprim ( Nast . Tint | Nast . Tstring | Nast . Tclassname _ ) ) - > env <nl> - | ( _ , Tprim Nast . Tstring ) , ( _ , Tprim ( Nast . Tclassname _ ) ) - > env <nl> + | ( _ , Tprim Nast . Tarraykey ) , ( _ , Tprim ( Nast . Tint | Nast . Tstring ) ) - > env <nl> | ( _ , Tprim ( Nast . Tstring | Nast . Tarraykey ) ) , ( _ , Tabstract ( ak , _ ) ) <nl> when AbstractKind . is_classname ak - > env <nl> | ( _ , Tclass ( ( _ , coll ) , [ tv_super ] ) ) , ( _ , Tarray ( ty3 , ty4 ) ) <nl> and sub_type_with_uenv env ( uenv_super , ty_super ) ( uenv_sub , ty_sub ) = <nl> sub_type env tv_super ty4 <nl> ) <nl> ) <nl> - | ( _ , Tclass ( ( _ , stringish ) , _ ) ) , ( _ , Tprim ( Nast . Tstring | Nast . Tclassname _ ) ) <nl> + | ( _ , Tclass ( ( _ , stringish ) , _ ) ) , ( _ , Tprim Nast . Tstring ) <nl> when stringish = SN . Classes . cStringish - > env <nl> | ( _ , Tclass ( ( _ , xhp_child ) , _ ) ) , ( _ , Tarray _ ) <nl> - | ( _ , Tclass ( ( _ , xhp_child ) , _ ) ) , ( _ , Tprim ( Nast . Tint | Nast . Tfloat | Nast . Tstring | Nast . Tclassname _ | Nast . Tnum ) ) <nl> + | ( _ , Tclass ( ( _ , xhp_child ) , _ ) ) , ( _ , Tprim ( Nast . Tint | Nast . Tfloat | Nast . Tstring | Nast . Tnum ) ) <nl> when xhp_child = SN . Classes . cXHPChild - > env <nl> | ( _ , ( Tarray ( Some ty_super , None ) ) ) , ( _ , ( Tarray ( Some ty_sub , None ) ) ) - > <nl> sub_type env ty_super ty_sub <nl> and sub_type_with_uenv env ( uenv_super , ty_super ) ( uenv_sub , ty_sub ) = <nl> ( env , None ) <nl> ( r_super , fields_known_super , fdm_super ) <nl> ( r_sub , fields_known_sub , fdm_sub ) ) <nl> - | ( _ , Tabstract ( AKnewtype ( name_classname , [ tyl1 ] ) , _ ) ) , <nl> - ( r_sub , Tprim ( Nast . Tclassname name_cls ) ) <nl> - when name_classname = SN . Classes . cClassname - > <nl> - ( * XXX : Do we need to look up the class and add missing Tanys ? * ) <nl> - let p_sub = Reason . to_pos r_sub in <nl> - let ty_cls = r_sub , Tclass ( ( p_sub , name_cls ) , [ ] ) in <nl> - sub_type env tyl1 ty_cls <nl> | ( _ , Tabstract ( AKnewtype ( name_super , tyl_super ) , _ ) ) , <nl> ( _ , Tabstract ( AKnewtype ( name_sub , tyl_sub ) , _ ) ) <nl> when name_super = name_sub - > <nl> mmm a / hphp / hack / src / typing / typing_unify . ml <nl> ppp b / hphp / hack / src / typing / typing_unify . ml <nl> and unify_var env ( r1 , uenv1 , n1 ) ( r2 , uenv2 , n2 ) = <nl> <nl> and unify_ env r1 ty1 r2 ty2 = <nl> match ty1 , ty2 with <nl> - | Tprim ( Nast . Tclassname _ ) , Tprim ( Nast . Tclassname _ ) - > <nl> - env , ty1 <nl> - | Tprim ( Nast . Tclassname _ ) , Tprim ( Nast . Tstring ) <nl> - | Tprim ( Nast . Tstring ) , Tprim ( Nast . Tclassname _ ) - > <nl> - ( * Tclassname is created solely within class_class_decl ; as such , treating <nl> - * it as interchangeable with a string for the purposes of unification <nl> - * should be fairly safe . A typical scenario for the unification is array <nl> - * literals like " array ( ' foo ' , ' bar ' , C1 : : class , . . . ) " * ) <nl> - env , Tprim ( Nast . Tstring ) <nl> | Tprim x , Tprim y - > <nl> if x = = y then env , Tprim x <nl> else <nl> mmm a / hphp / hack / test / typecheck / classname / acts_as_string . php . exp <nl> ppp b / hphp / hack / test / typecheck / classname / acts_as_string . php . exp <nl> <nl> - Tclassname < \ Tr > <nl> + App \ classname < App \ Tr < > , > <nl> No errors <nl> mmm a / hphp / hack / test / typecheck / classname / acts_as_string_bad . php . exp <nl> ppp b / hphp / hack / test / typecheck / classname / acts_as_string_bad . php . exp <nl> Invalid return type ( Typing [ 4110 ] ) <nl> File " acts_as_string_bad . php " , line 14 , characters 15 - 17 : <nl> This is an int <nl> File " acts_as_string_bad . php " , line 12 , characters 7 - 7 : <nl> - It is incompatible with string ( \ C : : class ) ; implicitly defined constant : : class is a string that contains the fully qualified name of C <nl> + It is incompatible with a classname string ; implicitly defined constant : : class is a string that contains the fully qualified name of C <nl> mmm a / hphp / hack / test / typecheck / classname / array_literal . php . exp <nl> ppp b / hphp / hack / test / typecheck / classname / array_literal . php . exp <nl> <nl> - array < [ 1 ] intersect ( Tstring ) > <nl> - array < [ 2 ] intersect ( Tstring ) , [ 3 ] intersect ( array < [ 4 ] intersect ( Tstring ) , [ 5 ] intersect ( Tclassname < \ C1 > ) > , Tclassname < \ C2 > ) > <nl> + array < [ 1 ] intersect ( Tstring , App \ classname < App \ C1 < > , > ) > <nl> + array < [ 2 ] intersect ( Tstring ) , [ 3 ] intersect ( array < [ 4 ] intersect ( Tstring ) , [ 5 ] intersect ( App \ classname < App \ I < > , > , App \ classname < App \ C1 < > , > ) > , App \ classname < App \ C2 < > , > ) > <nl> No errors <nl> mmm a / hphp / hack / test / typecheck / classname / array_literal_bad . php <nl> ppp b / hphp / hack / test / typecheck / classname / array_literal_bad . php <nl> class C1 implements I { } <nl> class C2 implements I { } <nl> class D { } <nl> <nl> - function condition ( ) : bool { <nl> - / / UNSAFE_BLOCK <nl> - } <nl> - <nl> - function test_ordering_limitation ( ) : array < string , classname < I > > { <nl> - / * unification of array literal types is not entirely sound . . . <nl> - * there ' s an attempt to do piece - wise unification * / <nl> + function f ( ) : array < string , classname < I > > { <nl> $ arr = array ( ' good1 ' = > C1 : : class , ' bad ' = > D : : class , ' good2 ' = > C2 : : class ) ; <nl> hh_show ( $ arr ) ; <nl> return $ arr ; <nl> } <nl> - <nl> - function test_ok_if_last ( ) : array < string , classname < I > > { <nl> - $ arr = array ( ' good1 ' = > C1 : : class , ' good2 ' = > C2 : : class , ' bad ' = > D : : class ) ; <nl> - hh_show ( $ arr ) ; <nl> - return $ arr ; <nl> - } <nl> mmm a / hphp / hack / test / typecheck / classname / array_literal_bad . php . exp <nl> ppp b / hphp / hack / test / typecheck / classname / array_literal_bad . php . exp <nl> <nl> - array < [ 1 ] intersect ( Tstring ) , [ 2 ] intersect ( Tclassname < \ C2 > ) > <nl> - array < [ 3 ] intersect ( Tstring ) , [ 4 ] intersect ( Tclassname < \ D > ) > <nl> - File " array_literal_bad . php " , line 23 , characters 10 - 13 : <nl> + array < [ 1 ] intersect ( Tstring ) , [ 2 ] intersect ( App \ classname < App \ D < > , > , App \ classname < App \ C2 < > , > , App \ classname < App \ C1 < > , > ) > <nl> + File " array_literal_bad . php " , line 11 , characters 10 - 13 : <nl> Invalid return type ( Typing [ 4110 ] ) <nl> - File " array_literal_bad . php " , line 20 , characters 53 - 53 : <nl> + File " array_literal_bad . php " , line 8 , characters 39 - 39 : <nl> This is an object of type I <nl> - File " array_literal_bad . php " , line 4 , characters 7 - 8 : <nl> - It is incompatible with an object of type D ; implicitly defined constant : : class is a string that contains the fully qualified name of C1 <nl> + File " array_literal_bad . php " , line 6 , characters 7 - 7 : <nl> + It is incompatible with an object of type D ; implicitly defined constant : : class is a string that contains the fully qualified name of D <nl>
Remove Tclassname
facebook/hhvm
9bd952a3d8b9bb2cb5d2789fba3e9bc266f9ced7
2015-08-11T00:02:34Z
mmm a / api / envoy / api / v2 / cds . proto <nl> ppp b / api / envoy / api / v2 / cds . proto <nl> service ClusterDiscoveryService { <nl> / / [ # protodoc - title : Clusters ] <nl> <nl> / / Configuration for a single upstream cluster . <nl> - / / [ # comment : next free field : 42 ] <nl> + / / [ # comment : next free field : 43 ] <nl> message Cluster { <nl> / / Supplies the name of the cluster which must be unique across all clusters . <nl> / / The cluster name is used when emitting <nl> message Cluster { <nl> / / : ref : ` lb_policy < envoy_api_field_Cluster . lb_policy > ` field has the value <nl> / / : ref : ` LOAD_BALANCING_POLICY_CONFIG < envoy_api_enum_value_Cluster . LbPolicy . LOAD_BALANCING_POLICY_CONFIG > ` . <nl> LoadBalancingPolicy load_balancing_policy = 41 ; <nl> + <nl> + / / [ # not - implemented - hide : ] <nl> + / / If present , tells the client where to send load reports via LRS . If not present , the <nl> + / / client will fall back to a client - side default , which may be either ( a ) don ' t send any <nl> + / / load reports or ( b ) send load reports for all clusters to a single default server <nl> + / / ( which may be configured in the bootstrap file ) . <nl> + / / <nl> + / / Note that if multiple clusters point to the same LRS server , the client may choose to <nl> + / / create a separate stream for each cluster or it may choose to coalesce the data for <nl> + / / multiple clusters onto a single stream . Either way , the client must make sure to send <nl> + / / the data for any given cluster on no more than one stream . <nl> + / / <nl> + / / [ # next - major - version : In the v3 API , we should consider restructuring this somehow , <nl> + / / maybe by allowing LRS to go on the ADS stream , or maybe by moving some of the negotiation <nl> + / / from the LRS stream here . ] <nl> + core . ConfigSource lrs_server = 42 ; <nl> } <nl> <nl> / / [ # not - implemented - hide : ] Extensible load balancing policy configuration . <nl> mmm a / tools / spelling_dictionary . txt <nl> ppp b / tools / spelling_dictionary . txt <nl> LDS <nl> LEV <nl> LHS <nl> LF <nl> + LRS <nl> MB <nl> MD <nl> MGET <nl>
cds : Configure LRS in CDS response ( )
envoyproxy/envoy
ca3056b3aeabcfbe3750d611a8dfe44a3a7de1cf
2019-09-20T19:57:54Z
mmm a / src / video_core / buffer_cache / buffer_block . h <nl> ppp b / src / video_core / buffer_cache / buffer_block . h <nl> <nl> <nl> # pragma once <nl> <nl> - # include < unordered_set > <nl> - # include < utility > <nl> - <nl> - # include " common / alignment . h " <nl> # include " common / common_types . h " <nl> - # include " video_core / gpu . h " <nl> <nl> namespace VideoCommon { <nl> <nl> class BufferBlock { <nl> public : <nl> - bool Overlaps ( VAddr start , VAddr end ) const { <nl> + [ [ nodiscard ] ] bool Overlaps ( VAddr start , VAddr end ) const { <nl> return ( cpu_addr < end ) & & ( cpu_addr_end > start ) ; <nl> } <nl> <nl> - bool IsInside ( VAddr other_start , VAddr other_end ) const { <nl> + [ [ nodiscard ] ] bool IsInside ( VAddr other_start , VAddr other_end ) const { <nl> return cpu_addr < = other_start & & other_end < = cpu_addr_end ; <nl> } <nl> <nl> - std : : size_t Offset ( VAddr in_addr ) const { <nl> + [ [ nodiscard ] ] std : : size_t Offset ( VAddr in_addr ) const { <nl> return static_cast < std : : size_t > ( in_addr - cpu_addr ) ; <nl> } <nl> <nl> - VAddr CpuAddr ( ) const { <nl> + [ [ nodiscard ] ] VAddr CpuAddr ( ) const { <nl> return cpu_addr ; <nl> } <nl> <nl> - VAddr CpuAddrEnd ( ) const { <nl> + [ [ nodiscard ] ] VAddr CpuAddrEnd ( ) const { <nl> return cpu_addr_end ; <nl> } <nl> <nl> class BufferBlock { <nl> cpu_addr_end = new_addr + size ; <nl> } <nl> <nl> - std : : size_t Size ( ) const { <nl> + [ [ nodiscard ] ] std : : size_t Size ( ) const { <nl> return size ; <nl> } <nl> <nl> - u64 Epoch ( ) const { <nl> + [ [ nodiscard ] ] u64 Epoch ( ) const { <nl> return epoch ; <nl> } <nl> <nl>
Merge pull request from lioncash / buffer - header
yuzu-emu/yuzu
3ef35207c1f03cfb0de75f511566582d587db084
2020-12-07T07:57:40Z
mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / ConnectionsModel . cpp <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / ConnectionsModel . cpp <nl> <nl> # include " ModelUtils . h " <nl> <nl> # include < IEditorImpl . h > <nl> - # include < ImplItem . h > <nl> + # include < IImplItem . h > <nl> # include < CrySystem / File / CryFile . h > <nl> # include < QtUtil . h > <nl> # include < CryIcon . h > <nl> QVariant CConnectionModel : : data ( QModelIndex const & index , int role ) const <nl> <nl> if ( pConnection ! = nullptr ) <nl> { <nl> - CImplItem const * const pImplItem = g_pEditorImpl - > GetControl ( pConnection - > GetID ( ) ) ; <nl> + IImplItem const * const pImplItem = g_pEditorImpl - > GetImplItem ( pConnection - > GetID ( ) ) ; <nl> <nl> if ( pImplItem ! = nullptr ) <nl> { <nl> QVariant CConnectionModel : : data ( QModelIndex const & index , int role ) const <nl> { <nl> variant = CryIcon ( ModelUtils : : GetItemNotificationIcon ( ModelUtils : : EItemStatus : : Placeholder ) ) ; <nl> } <nl> - else if ( pImplItem - > IsLocalised ( ) ) <nl> + else if ( pImplItem - > IsLocalized ( ) ) <nl> { <nl> variant = CryIcon ( ModelUtils : : GetItemNotificationIcon ( ModelUtils : : EItemStatus : : Localized ) ) ; <nl> } <nl> QVariant CConnectionModel : : data ( QModelIndex const & index , int role ) const <nl> { <nl> variant = tr ( " Item not found in middleware project " ) ; <nl> } <nl> - else if ( pImplItem - > IsLocalised ( ) ) <nl> + else if ( pImplItem - > IsLocalized ( ) ) <nl> { <nl> variant = tr ( " Item is localized " ) ; <nl> } <nl> QVariant CConnectionModel : : data ( QModelIndex const & index , int role ) const <nl> case Qt : : ToolTipRole : <nl> { <nl> QString path ; <nl> - CImplItem const * pImplItemParent = pImplItem - > GetParent ( ) ; <nl> + IImplItem const * pImplItemParent = pImplItem - > GetParent ( ) ; <nl> <nl> while ( pImplItemParent ! = nullptr ) <nl> { <nl> QModelIndex CConnectionModel : : index ( int row , int column , QModelIndex const & pare <nl> <nl> if ( pConnection ! = nullptr ) <nl> { <nl> - CImplItem const * const pImplItem = g_pEditorImpl - > GetControl ( pConnection - > GetID ( ) ) ; <nl> + IImplItem const * const pImplItem = g_pEditorImpl - > GetImplItem ( pConnection - > GetID ( ) ) ; <nl> <nl> if ( pImplItem ! = nullptr ) <nl> { <nl> bool CConnectionModel : : canDropMimeData ( QMimeData const * pData , Qt : : DropAction ac <nl> <nl> for ( auto const id : ids ) <nl> { <nl> - CImplItem const * const pImplItem = g_pEditorImpl - > GetControl ( id ) ; <nl> + IImplItem const * const pImplItem = g_pEditorImpl - > GetImplItem ( id ) ; <nl> <nl> if ( pImplItem ! = nullptr ) <nl> { <nl> bool CConnectionModel : : dropMimeData ( QMimeData const * pData , Qt : : DropAction actio <nl> <nl> for ( auto const id : ids ) <nl> { <nl> - CImplItem * const pImplItem = g_pEditorImpl - > GetControl ( id ) ; <nl> + IImplItem * const pImplItem = g_pEditorImpl - > GetImplItem ( id ) ; <nl> <nl> if ( pImplItem ! = nullptr ) <nl> { <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / ConnectionsWidget . cpp <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / ConnectionsWidget . cpp <nl> <nl> # include " ConnectionsModel . h " <nl> <nl> # include < IEditorImpl . h > <nl> - # include < ImplItem . h > <nl> + # include < IImplItem . h > <nl> # include < IEditor . h > <nl> # include < QtUtil . h > <nl> # include < Controls / QuestionDialog . h > <nl> void CConnectionsWidget : : OnContextMenu ( QPoint const & pos ) <nl> <nl> if ( selectionCount > 0 ) <nl> { <nl> - QMenu * const pContextMenu = new QMenu ( this ) ; <nl> + auto const pContextMenu = new QMenu ( this ) ; <nl> <nl> char const * actionName = " Remove Connection " ; <nl> <nl> void CConnectionsWidget : : OnContextMenu ( QPoint const & pos ) <nl> if ( g_pEditorImpl ! = nullptr ) <nl> { <nl> CID const itemId = selection [ 0 ] . data ( static_cast < int > ( CConnectionModel : : ERoles : : Id ) ) . toInt ( ) ; <nl> - CImplItem const * const pImplControl = g_pEditorImpl - > GetControl ( itemId ) ; <nl> + IImplItem const * const pImplItem = g_pEditorImpl - > GetImplItem ( itemId ) ; <nl> <nl> - if ( ( pImplControl ! = nullptr ) & & ! pImplControl - > IsPlaceholder ( ) ) <nl> + if ( ( pImplItem ! = nullptr ) & & ! pImplItem - > IsPlaceholder ( ) ) <nl> { <nl> pContextMenu - > addSeparator ( ) ; <nl> pContextMenu - > addAction ( tr ( " Select in Middleware Data " ) , [ = ] ( ) <nl> void CConnectionsWidget : : RemoveSelectedConnection ( ) <nl> { <nl> if ( g_pEditorImpl ! = nullptr ) <nl> { <nl> - std : : vector < CImplItem * > implItems ; <nl> + std : : vector < IImplItem * > implItems ; <nl> implItems . reserve ( selectedIndexes . size ( ) ) ; <nl> <nl> for ( QModelIndex const & index : selectedIndexes ) <nl> { <nl> CID const id = index . data ( static_cast < int > ( CConnectionModel : : ERoles : : Id ) ) . toInt ( ) ; <nl> - implItems . emplace_back ( g_pEditorImpl - > GetControl ( id ) ) ; <nl> + implItems . emplace_back ( g_pEditorImpl - > GetImplItem ( id ) ) ; <nl> } <nl> <nl> - for ( CImplItem * const pImplItem : implItems ) <nl> + for ( IImplItem * const pImplItem : implItems ) <nl> { <nl> if ( pImplItem ! = nullptr ) <nl> { <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorFmod / CMakeLists . txt <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorFmod / CMakeLists . txt <nl> add_sources ( " EditorFmod_uber_0 . cpp " <nl> " EditorImpl . h " <nl> " ImplConnections . cpp " <nl> " ImplConnections . h " <nl> - " ImplControls . cpp " <nl> - " ImplControls . h " <nl> + " ImplItem . cpp " <nl> + " ImplItem . h " <nl> " ImplTypes . h " <nl> " ImplUtils . cpp " <nl> " ImplUtils . h " <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorFmod / EditorImpl . cpp <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorFmod / EditorImpl . cpp <nl> string TypeToEditorFolderName ( EImplItemType const type ) <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - CImplItem * SearchForControl ( CImplItem * const pImplItem , string const & name , ItemType const type ) <nl> + CImplItem * SearchForItem ( CImplItem * const pImplItem , string const & name , ItemType const type ) <nl> { <nl> CImplItem * pItem = nullptr ; <nl> <nl> CImplItem * SearchForControl ( CImplItem * const pImplItem , string const & name , Item <nl> } <nl> else <nl> { <nl> - int const count = pImplItem - > ChildCount ( ) ; <nl> + size_t const count = pImplItem - > GetNumChildren ( ) ; <nl> <nl> - for ( int i = 0 ; i < count ; + + i ) <nl> + for ( size_t i = 0 ; i < count ; + + i ) <nl> { <nl> - CImplItem * const pFoundImplControl = SearchForControl ( pImplItem - > GetChildAt ( i ) , name , type ) ; <nl> + CImplItem * const pFoundImplItem = SearchForItem ( static_cast < CImplItem * const > ( pImplItem - > GetChildAt ( i ) ) , name , type ) ; <nl> <nl> - if ( pFoundImplControl ! = nullptr ) <nl> + if ( pFoundImplItem ! = nullptr ) <nl> { <nl> - pItem = pFoundImplControl ; <nl> + pItem = pFoundImplItem ; <nl> break ; <nl> } <nl> } <nl> void CEditorImpl : : Reload ( bool const preserveConnectionStatus ) <nl> { <nl> Clear ( ) ; <nl> <nl> - CProjectLoader ( GetSettings ( ) - > GetProjectPath ( ) , GetSettings ( ) - > GetAssetsPath ( ) , m_rootControl , m_controlsCache ) ; <nl> + CProjectLoader ( GetSettings ( ) - > GetProjectPath ( ) , GetSettings ( ) - > GetAssetsPath ( ) , m_rootItem , m_itemCache , * this ) ; <nl> <nl> if ( preserveConnectionStatus ) <nl> { <nl> void CEditorImpl : : Reload ( bool const preserveConnectionStatus ) <nl> { <nl> if ( connection . second > 0 ) <nl> { <nl> - CImplItem * const pImplControl = GetControl ( connection . first ) ; <nl> + auto const pImplItem = static_cast < CImplItem * const > ( GetImplItem ( connection . first ) ) ; <nl> <nl> - if ( pImplControl ! = nullptr ) <nl> + if ( pImplItem ! = nullptr ) <nl> { <nl> - pImplControl - > SetConnected ( true ) ; <nl> + pImplItem - > SetConnected ( true ) ; <nl> } <nl> } <nl> } <nl> void CEditorImpl : : Reload ( bool const preserveConnectionStatus ) <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - CImplItem * CEditorImpl : : GetControl ( CID const id ) const <nl> + IImplItem * CEditorImpl : : GetImplItem ( CID const id ) const <nl> { <nl> CImplItem * pImplItem = nullptr ; <nl> <nl> if ( id > = 0 ) <nl> { <nl> - pImplItem = stl : : find_in_map ( m_controlsCache , id , nullptr ) ; <nl> + pImplItem = stl : : find_in_map ( m_itemCache , id , nullptr ) ; <nl> } <nl> <nl> return pImplItem ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - char const * CEditorImpl : : GetTypeIcon ( CImplItem const * const pImplItem ) const <nl> + char const * CEditorImpl : : GetTypeIcon ( IImplItem const * const pImplItem ) const <nl> { <nl> char const * szIconPath = " icons : Dialogs / dialog - error . ico " ; <nl> auto const type = static_cast < EImplItemType > ( pImplItem - > GetType ( ) ) ; <nl> string const & CEditorImpl : : GetFolderName ( ) const <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - bool CEditorImpl : : IsTypeCompatible ( ESystemItemType const systemType , CImplItem const * const pImplItem ) const <nl> + bool CEditorImpl : : IsTypeCompatible ( ESystemItemType const systemType , IImplItem const * const pImplItem ) const <nl> { <nl> bool isCompatible = false ; <nl> auto const implType = static_cast < EImplItemType > ( pImplItem - > GetType ( ) ) ; <nl> bool CEditorImpl : : IsTypeCompatible ( ESystemItemType const systemType , CImplItem c <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - ESystemItemType CEditorImpl : : ImplTypeToSystemType ( CImplItem const * const pImplItem ) const <nl> + ESystemItemType CEditorImpl : : ImplTypeToSystemType ( IImplItem const * const pImplItem ) const <nl> { <nl> ESystemItemType systemType = ESystemItemType : : Invalid ; <nl> auto const implType = static_cast < EImplItemType > ( pImplItem - > GetType ( ) ) ; <nl> ESystemItemType CEditorImpl : : ImplTypeToSystemType ( CImplItem const * const pImplIt <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - ConnectionPtr CEditorImpl : : CreateConnectionToControl ( ESystemItemType const controlType , CImplItem * const pImplItem ) <nl> + ConnectionPtr CEditorImpl : : CreateConnectionToControl ( ESystemItemType const controlType , IImplItem * const pImplItem ) <nl> { <nl> ConnectionPtr pConnection = nullptr ; <nl> <nl> ConnectionPtr CEditorImpl : : CreateConnectionFromXMLNode ( XmlNodeRef pNode , ESystem <nl> } <nl> else <nl> { <nl> - pImplItem = SearchForControl ( & m_rootControl , name , static_cast < ItemType > ( type ) ) ; <nl> + pImplItem = SearchForItem ( & m_rootItem , name , static_cast < ItemType > ( type ) ) ; <nl> } <nl> <nl> if ( ( pImplItem = = nullptr ) | | ( type ! = static_cast < EImplItemType > ( pImplItem - > GetType ( ) ) ) ) <nl> { <nl> - / / If control not found , create a placeholder . <nl> + / / If item not found , create a placeholder . <nl> / / We want to keep that connection even if it ' s not in the middleware as the user could <nl> / / be using the engine without the fmod project <nl> <nl> XmlNodeRef CEditorImpl : : CreateXMLNodeFromConnection ( ConnectionPtr const pConnect <nl> { <nl> XmlNodeRef pConnectionNode = nullptr ; <nl> <nl> - CImplItem * const pImplControl = GetControl ( pConnection - > GetID ( ) ) ; <nl> + auto const pImplItem = static_cast < CImplItem * const > ( GetImplItem ( pConnection - > GetID ( ) ) ) ; <nl> <nl> - if ( pImplControl ! = nullptr ) <nl> + if ( pImplItem ! = nullptr ) <nl> { <nl> - auto const type = static_cast < EImplItemType > ( pImplControl - > GetType ( ) ) ; <nl> + auto const type = static_cast < EImplItemType > ( pImplItem - > GetType ( ) ) ; <nl> pConnectionNode = GetISystem ( ) - > CreateXmlNode ( TypeToTag ( type ) ) ; <nl> <nl> switch ( type ) <nl> { <nl> case EImplItemType : : Event : <nl> { <nl> - pConnectionNode - > setAttr ( CryAudio : : s_szNameAttribute , Utils : : GetPathName ( pImplControl , m_rootControl ) ) ; <nl> + pConnectionNode - > setAttr ( CryAudio : : s_szNameAttribute , Utils : : GetPathName ( pImplItem , m_rootItem ) ) ; <nl> auto const pEventConnection = static_cast < const CEventConnection * > ( pConnection . get ( ) ) ; <nl> <nl> if ( pEventConnection ! = nullptr ) <nl> XmlNodeRef CEditorImpl : : CreateXMLNodeFromConnection ( ConnectionPtr const pConnect <nl> break ; <nl> case EImplItemType : : Snapshot : <nl> { <nl> - pConnectionNode - > setAttr ( CryAudio : : s_szNameAttribute , Utils : : GetPathName ( pImplControl , m_rootControl ) ) ; <nl> + pConnectionNode - > setAttr ( CryAudio : : s_szNameAttribute , Utils : : GetPathName ( pImplItem , m_rootItem ) ) ; <nl> auto const pEventConnection = static_cast < const CSnapshotConnection * > ( pConnection . get ( ) ) ; <nl> <nl> if ( ( pEventConnection ! = nullptr ) & & ( pEventConnection - > GetType ( ) = = ESnapshotType : : Stop ) ) <nl> XmlNodeRef CEditorImpl : : CreateXMLNodeFromConnection ( ConnectionPtr const pConnect <nl> break ; <nl> case EImplItemType : : Return : <nl> { <nl> - pConnectionNode - > setAttr ( CryAudio : : s_szNameAttribute , Utils : : GetPathName ( pImplControl , m_rootControl ) ) ; <nl> + pConnectionNode - > setAttr ( CryAudio : : s_szNameAttribute , Utils : : GetPathName ( pImplItem , m_rootItem ) ) ; <nl> } <nl> break ; <nl> case EImplItemType : : Parameter : <nl> case EImplItemType : : VCA : <nl> { <nl> - pConnectionNode - > setAttr ( CryAudio : : s_szNameAttribute , pImplControl - > GetName ( ) ) ; <nl> + pConnectionNode - > setAttr ( CryAudio : : s_szNameAttribute , pImplItem - > GetName ( ) ) ; <nl> <nl> if ( controlType = = ESystemItemType : : State ) <nl> { <nl> XmlNodeRef CEditorImpl : : CreateXMLNodeFromConnection ( ConnectionPtr const pConnect <nl> break ; <nl> case EImplItemType : : Bank : <nl> { <nl> - pConnectionNode - > setAttr ( CryAudio : : s_szNameAttribute , pImplControl - > GetName ( ) ) ; <nl> + pConnectionNode - > setAttr ( CryAudio : : s_szNameAttribute , pImplItem - > GetName ( ) ) ; <nl> <nl> - if ( pImplControl - > IsLocalised ( ) ) <nl> + if ( pImplItem - > IsLocalized ( ) ) <nl> { <nl> pConnectionNode - > setAttr ( CryAudio : : Impl : : Fmod : : s_szLocalizedAttribute , CryAudio : : Impl : : Fmod : : s_szTrueValue ) ; <nl> } <nl> XmlNodeRef CEditorImpl : : CreateXMLNodeFromConnection ( ConnectionPtr const pConnect <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> void CEditorImpl : : EnableConnection ( ConnectionPtr const pConnection ) <nl> { <nl> - CImplItem * const pImplControl = GetControl ( pConnection - > GetID ( ) ) ; <nl> + auto const pImplItem = static_cast < CImplItem * const > ( GetImplItem ( pConnection - > GetID ( ) ) ) ; <nl> <nl> - if ( pImplControl ! = nullptr ) <nl> + if ( pImplItem ! = nullptr ) <nl> { <nl> - + + m_connectionsByID [ pImplControl - > GetId ( ) ] ; <nl> - pImplControl - > SetConnected ( true ) ; <nl> + + + m_connectionsByID [ pImplItem - > GetId ( ) ] ; <nl> + pImplItem - > SetConnected ( true ) ; <nl> } <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> void CEditorImpl : : DisableConnection ( ConnectionPtr const pConnection ) <nl> { <nl> - CImplItem * const pImplControl = GetControl ( pConnection - > GetID ( ) ) ; <nl> + auto const pImplItem = static_cast < CImplItem * const > ( GetImplItem ( pConnection - > GetID ( ) ) ) ; <nl> <nl> - if ( pImplControl ! = nullptr ) <nl> + if ( pImplItem ! = nullptr ) <nl> { <nl> - int connectionCount = m_connectionsByID [ pImplControl - > GetId ( ) ] - 1 ; <nl> + int connectionCount = m_connectionsByID [ pImplItem - > GetId ( ) ] - 1 ; <nl> <nl> if ( connectionCount < = 0 ) <nl> { <nl> connectionCount = 0 ; <nl> - pImplControl - > SetConnected ( false ) ; <nl> + pImplItem - > SetConnected ( false ) ; <nl> } <nl> <nl> - m_connectionsByID [ pImplControl - > GetId ( ) ] = connectionCount ; <nl> + m_connectionsByID [ pImplItem - > GetId ( ) ] = connectionCount ; <nl> } <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> void CEditorImpl : : Clear ( ) <nl> { <nl> - / / Delete all the controls <nl> - for ( auto const & controlPair : m_controlsCache ) <nl> + / / Delete all the items <nl> + for ( auto const & itemPair : m_itemCache ) <nl> { <nl> - CImplItem const * const pImplControl = controlPair . second ; <nl> + CImplItem const * const pImplItem = itemPair . second ; <nl> <nl> - if ( pImplControl ! = nullptr ) <nl> + if ( pImplItem ! = nullptr ) <nl> { <nl> - delete pImplControl ; <nl> + delete pImplItem ; <nl> } <nl> } <nl> <nl> - m_controlsCache . clear ( ) ; <nl> + m_itemCache . clear ( ) ; <nl> <nl> - / / Clean up the root control <nl> - m_rootControl = CImplItem ( ) ; <nl> + / / Clean up the root item <nl> + m_rootItem . Clear ( ) ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> CImplItem * CEditorImpl : : CreateItem ( string const & name , EImplItemType const type , CImplItem * const pParent ) <nl> { <nl> - CID const id = Utils : : GetId ( type , name , pParent , m_rootControl ) ; <nl> + CID const id = Utils : : GetId ( type , name , pParent , m_rootItem ) ; <nl> <nl> - CImplItem * pImplItem = GetControl ( id ) ; <nl> + auto pImplItem = static_cast < CImplItem * > ( GetImplItem ( id ) ) ; <nl> <nl> if ( pImplItem ! = nullptr ) <nl> { <nl> CImplItem * CEditorImpl : : CreateItem ( string const & name , EImplItemType const type , <nl> while ( pParentItem ! = nullptr ) <nl> { <nl> pParentItem - > SetPlaceholder ( false ) ; <nl> - pParentItem = pParentItem - > GetParent ( ) ; <nl> + pParentItem = static_cast < CImplItem * > ( pParentItem - > GetParent ( ) ) ; <nl> } <nl> } <nl> } <nl> else <nl> { <nl> - if ( type = = EImplItemType : : Folder ) <nl> + if ( type = = EImplItemType : : EditorFolder ) <nl> { <nl> - pImplItem = new CImplFolder ( name , id ) ; <nl> - } <nl> - else if ( type = = EImplItemType : : MixerGroup ) <nl> - { <nl> - pImplItem = new CImplMixerGroup ( name , id ) ; <nl> + pImplItem = new CImplItem ( name , id , static_cast < ItemType > ( type ) , EImplItemFlags : : IsContainer ) ; <nl> } <nl> else <nl> { <nl> pImplItem = new CImplItem ( name , id , static_cast < ItemType > ( type ) ) ; <nl> - <nl> - if ( type = = EImplItemType : : EditorFolder ) <nl> - { <nl> - pImplItem - > SetContainer ( true ) ; <nl> - } <nl> } <nl> <nl> if ( pParent ! = nullptr ) <nl> CImplItem * CEditorImpl : : CreateItem ( string const & name , EImplItemType const type , <nl> } <nl> else <nl> { <nl> - m_rootControl . AddChild ( pImplItem ) ; <nl> + m_rootItem . AddChild ( pImplItem ) ; <nl> } <nl> <nl> - m_controlsCache [ id ] = pImplItem ; <nl> + m_itemCache [ id ] = pImplItem ; <nl> <nl> } <nl> <nl> CImplItem * CEditorImpl : : CreateItem ( string const & name , EImplItemType const type , <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> CImplItem * CEditorImpl : : GetItemFromPath ( string const & fullpath ) <nl> { <nl> - CImplItem * pItem = & m_rootControl ; <nl> + CImplItem * pItem = & m_rootItem ; <nl> int start = 0 ; <nl> string token = fullpath . Tokenize ( " / " , start ) ; <nl> <nl> CImplItem * CEditorImpl : : GetItemFromPath ( string const & fullpath ) <nl> { <nl> token . Trim ( ) ; <nl> CImplItem * pChild = nullptr ; <nl> - int const size = pItem - > ChildCount ( ) ; <nl> + int const size = pItem - > GetNumChildren ( ) ; <nl> <nl> for ( int i = 0 ; i < size ; + + i ) <nl> { <nl> - CImplItem * const pNextChild = pItem - > GetChildAt ( i ) ; <nl> + auto const pNextChild = static_cast < CImplItem * const > ( pItem - > GetChildAt ( i ) ) ; <nl> <nl> if ( ( pNextChild ! = nullptr ) & & ( pNextChild - > GetName ( ) = = token ) ) <nl> { <nl> CImplItem * CEditorImpl : : GetItemFromPath ( string const & fullpath ) <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> CImplItem * CEditorImpl : : CreatePlaceholderFolderPath ( string const & path ) <nl> { <nl> - CImplItem * pImplItem = & m_rootControl ; <nl> + CImplItem * pImplItem = & m_rootItem ; <nl> int start = 0 ; <nl> string token = path . Tokenize ( " / " , start ) ; <nl> <nl> CImplItem * CEditorImpl : : CreatePlaceholderFolderPath ( string const & path ) <nl> { <nl> token . Trim ( ) ; <nl> CImplItem * pFoundChild = nullptr ; <nl> - int const size = pImplItem - > ChildCount ( ) ; <nl> + int const size = pImplItem - > GetNumChildren ( ) ; <nl> <nl> for ( int i = 0 ; i < size ; + + i ) <nl> { <nl> - CImplItem * const pChild = pImplItem - > GetChildAt ( i ) ; <nl> + auto const pChild = static_cast < CImplItem * const > ( pImplItem - > GetChildAt ( i ) ) ; <nl> <nl> if ( ( pChild ! = nullptr ) & & ( pChild - > GetName ( ) = = token ) ) <nl> { <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorFmod / EditorImpl . h <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorFmod / EditorImpl . h <nl> <nl> <nl> # include < IEditorImpl . h > <nl> <nl> - # include " ImplControls . h " <nl> + # include " ImplItem . h " <nl> <nl> # include < CryAudio / IAudioSystem . h > <nl> # include < CrySystem / File / CryFile . h > <nl> class CImplSettings final : public IImplSettings <nl> CImplSettings ( ) ; <nl> <nl> / / IImplSettings <nl> - virtual char const * GetAssetsPath ( ) const override { return m_assetsPath . c_str ( ) ; } <nl> - virtual char const * GetProjectPath ( ) const override { return m_projectPath . c_str ( ) ; } <nl> + virtual char const * GetAssetsPath ( ) const override { return m_assetsPath . c_str ( ) ; } <nl> + virtual char const * GetProjectPath ( ) const override { return m_projectPath . c_str ( ) ; } <nl> virtual void SetProjectPath ( char const * szPath ) override ; <nl> - virtual bool IsProjectPathEditable ( ) const override { return true ; } <nl> + virtual bool SupportsProjects ( ) const override { return true ; } <nl> / / ~ IImplSettings <nl> <nl> void Serialize ( Serialization : : IArchive & ar ) ; <nl> class CEditorImpl final : public IEditorImpl <nl> <nl> / / IEditorImpl <nl> virtual void Reload ( bool const preserveConnectionStatus = true ) override ; <nl> - virtual CImplItem * GetRoot ( ) override { return & m_rootControl ; } <nl> - virtual CImplItem * GetControl ( CID const id ) const override ; <nl> - virtual char const * GetTypeIcon ( CImplItem const * const pImplItem ) const override ; <nl> + virtual IImplItem * GetRoot ( ) override { return & m_rootItem ; } <nl> + virtual IImplItem * GetImplItem ( CID const id ) const override ; <nl> + virtual char const * GetTypeIcon ( IImplItem const * const pImplItem ) const override ; <nl> virtual string const & GetName ( ) const override ; <nl> virtual string const & GetFolderName ( ) const override ; <nl> virtual IImplSettings * GetSettings ( ) override { return & m_implSettings ; } <nl> virtual bool IsSystemTypeSupported ( ESystemItemType const systemType ) const override { return true ; } <nl> - virtual bool IsTypeCompatible ( ESystemItemType const systemType , CImplItem const * const pImplItem ) const override ; <nl> - virtual ESystemItemType ImplTypeToSystemType ( CImplItem const * const pImplItem ) const override ; <nl> - virtual ConnectionPtr CreateConnectionToControl ( ESystemItemType const controlType , CImplItem * const pImplItem ) override ; <nl> + virtual bool IsTypeCompatible ( ESystemItemType const systemType , IImplItem const * const pImplItem ) const override ; <nl> + virtual ESystemItemType ImplTypeToSystemType ( IImplItem const * const pImplItem ) const override ; <nl> + virtual ConnectionPtr CreateConnectionToControl ( ESystemItemType const controlType , IImplItem * const pImplItem ) override ; <nl> virtual ConnectionPtr CreateConnectionFromXMLNode ( XmlNodeRef pNode , ESystemItemType const controlType ) override ; <nl> virtual XmlNodeRef CreateXMLNodeFromConnection ( ConnectionPtr const pConnection , ESystemItemType const controlType ) override ; <nl> virtual void EnableConnection ( ConnectionPtr const pConnection ) override ; <nl> class CEditorImpl final : public IEditorImpl <nl> <nl> using ConnectionsMap = std : : map < CID , int > ; <nl> <nl> - CImplItem m_rootControl ; <nl> - ControlsCache m_controlsCache ; / / cache of the controls stored by id for faster access <nl> + CImplItem m_rootItem { " " , ACE_INVALID_ID , AUDIO_SYSTEM_INVALID_TYPE } ; <nl> + ItemCache m_itemCache ; / / cache of the items stored by id for faster access <nl> ConnectionsMap m_connectionsByID ; <nl> CImplSettings m_implSettings ; <nl> CryAudio : : SImplInfo m_implInfo ; <nl> deleted file mode 100644 <nl> index 0e4579d404 . . 0000000000 <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorFmod / ImplControls . cpp <nl> ppp / dev / null <nl> <nl> - / / Copyright 2001 - 2016 Crytek GmbH / Crytek Group . All rights reserved . <nl> - <nl> - # include " StdAfx . h " <nl> - # include " ImplControls . h " <nl> - <nl> - namespace ACE <nl> - { <nl> - namespace Fmod <nl> - { <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - CImplControl : : CImplControl ( string const & name , CID const id , ItemType const type ) <nl> - : CImplItem ( name , id , type ) <nl> - { <nl> - } <nl> - } / / namespace Fmod <nl> - } / / namespace ACE <nl> deleted file mode 100644 <nl> index 64614dbaa3 . . 0000000000 <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorFmod / ImplControls . h <nl> ppp / dev / null <nl> <nl> - / / Copyright 2001 - 2018 Crytek GmbH / Crytek Group . All rights reserved . <nl> - <nl> - # pragma once <nl> - <nl> - # include < ImplItem . h > <nl> - # include " ImplTypes . h " <nl> - <nl> - namespace ACE <nl> - { <nl> - namespace Fmod <nl> - { <nl> - using ControlsCache = std : : map < CID , CImplItem * > ; <nl> - <nl> - class CImplControl final : public CImplItem <nl> - { <nl> - public : <nl> - <nl> - CImplControl ( ) = default ; <nl> - CImplControl ( string const & name , CID const id , ItemType const type ) ; <nl> - } ; <nl> - <nl> - class CImplFolder final : public CImplItem <nl> - { <nl> - public : <nl> - <nl> - CImplFolder ( string const & name , CID const id ) <nl> - : CImplItem ( name , id , static_cast < ItemType > ( EImplItemType : : Folder ) ) <nl> - { <nl> - SetContainer ( true ) ; <nl> - } <nl> - } ; <nl> - <nl> - class CImplMixerGroup final : public CImplItem <nl> - { <nl> - public : <nl> - <nl> - CImplMixerGroup ( string const & name , CID const id ) <nl> - : CImplItem ( name , id , static_cast < ItemType > ( EImplItemType : : MixerGroup ) ) <nl> - { <nl> - SetContainer ( true ) ; <nl> - } <nl> - } ; <nl> - } / / namespace Fmod <nl> - } / / namespace ACE <nl> new file mode 100644 <nl> index 0000000000 . . f4c99e2fe8 <nl> mmm / dev / null <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorFmod / ImplItem . cpp <nl> <nl> + / / Copyright 2001 - 2018 Crytek GmbH / Crytek Group . All rights reserved . <nl> + <nl> + # include " StdAfx . h " <nl> + # include " ImplItem . h " <nl> + <nl> + namespace ACE <nl> + { <nl> + namespace Fmod <nl> + { <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void CImplItem : : SetConnected ( bool const isConnected ) <nl> + { <nl> + if ( isConnected ) <nl> + { <nl> + m_flags | = EImplItemFlags : : IsConnected ; <nl> + } <nl> + else <nl> + { <nl> + m_flags & = ~ EImplItemFlags : : IsConnected ; <nl> + } <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void CImplItem : : SetPlaceholder ( bool const isPlaceholder ) <nl> + { <nl> + if ( isPlaceholder ) <nl> + { <nl> + m_flags | = EImplItemFlags : : IsPlaceHolder ; <nl> + } <nl> + else <nl> + { <nl> + m_flags & = ~ EImplItemFlags : : IsPlaceHolder ; <nl> + } <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void CImplItem : : AddChild ( CImplItem * const pChild ) <nl> + { <nl> + m_children . push_back ( pChild ) ; <nl> + pChild - > SetParent ( this ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void CImplItem : : RemoveChild ( CImplItem * const pChild ) <nl> + { <nl> + stl : : find_and_erase ( m_children , pChild ) ; <nl> + pChild - > SetParent ( nullptr ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void CImplItem : : Clear ( ) <nl> + { <nl> + m_children . clear ( ) ; <nl> + } <nl> + } / / namespace Fmod <nl> + } / / namespace ACE <nl> new file mode 100644 <nl> index 0000000000 . . bc62517812 <nl> mmm / dev / null <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorFmod / ImplItem . h <nl> <nl> + / / Copyright 2001 - 2018 Crytek GmbH / Crytek Group . All rights reserved . <nl> + <nl> + # pragma once <nl> + <nl> + # include < IImplItem . h > <nl> + # include " ImplTypes . h " <nl> + <nl> + namespace ACE <nl> + { <nl> + namespace Fmod <nl> + { <nl> + enum class EImplItemFlags <nl> + { <nl> + None = 0 , <nl> + IsPlaceHolder = BIT ( 0 ) , <nl> + IsLocalized = BIT ( 1 ) , <nl> + IsConnected = BIT ( 2 ) , <nl> + IsContainer = BIT ( 3 ) , <nl> + } ; <nl> + CRY_CREATE_ENUM_FLAG_OPERATORS ( EImplItemFlags ) ; <nl> + <nl> + class CImplItem final : public IImplItem <nl> + { <nl> + public : <nl> + <nl> + explicit CImplItem ( <nl> + string const & name , <nl> + CID const id , <nl> + ItemType const type , <nl> + EImplItemFlags const flags = EImplItemFlags : : None , <nl> + string const & filePath = " " ) <nl> + : m_name ( name ) <nl> + , m_id ( id ) <nl> + , m_type ( type ) <nl> + , m_flags ( flags ) <nl> + , m_filePath ( filePath ) <nl> + , m_pParent ( nullptr ) <nl> + { } <nl> + <nl> + virtual ~ CImplItem ( ) override = default ; <nl> + <nl> + CImplItem ( ) = delete ; <nl> + <nl> + / / IImplItem <nl> + virtual CID GetId ( ) const override { return m_id ; } <nl> + virtual ItemType GetType ( ) const override { return m_type ; } <nl> + virtual string GetName ( ) const override { return m_name ; } <nl> + virtual string const & GetFilePath ( ) const override { return m_filePath ; } <nl> + virtual float GetRadius ( ) const override { return 0 . 0f ; } <nl> + <nl> + virtual size_t GetNumChildren ( ) const override { return m_children . size ( ) ; } <nl> + virtual IImplItem * GetChildAt ( size_t const index ) const override { return m_children [ index ] ; } <nl> + virtual IImplItem * GetParent ( ) const override { return m_pParent ; } <nl> + <nl> + virtual bool IsPlaceholder ( ) const override { return ( m_flags & EImplItemFlags : : IsPlaceHolder ) ! = 0 ; } <nl> + virtual bool IsLocalized ( ) const override { return ( m_flags & EImplItemFlags : : IsLocalized ) ! = 0 ; } <nl> + virtual bool IsConnected ( ) const override { return ( m_flags & EImplItemFlags : : IsConnected ) ! = 0 ; } <nl> + virtual bool IsContainer ( ) const override { return ( m_flags & EImplItemFlags : : IsContainer ) ! = 0 ; } <nl> + / / ~ IImplItem <nl> + <nl> + void SetConnected ( bool const isConnected ) ; <nl> + void SetPlaceholder ( bool const isPlaceholder ) ; <nl> + <nl> + void AddChild ( CImplItem * const pChild ) ; <nl> + void RemoveChild ( CImplItem * const pChild ) ; <nl> + <nl> + void Clear ( ) ; <nl> + <nl> + private : <nl> + <nl> + void SetParent ( CImplItem * const pParent ) { m_pParent = pParent ; } <nl> + <nl> + CID const m_id ; <nl> + ItemType const m_type ; <nl> + string const m_name ; <nl> + string const m_filePath ; <nl> + std : : vector < CImplItem * > m_children ; <nl> + CImplItem * m_pParent ; <nl> + EImplItemFlags m_flags ; <nl> + } ; <nl> + <nl> + using ItemCache = std : : map < CID , CImplItem * > ; <nl> + } / / namespace Fmod <nl> + } / / namespace ACE <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorFmod / ImplUtils . cpp <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorFmod / ImplUtils . cpp <nl> namespace Fmod <nl> namespace Utils <nl> { <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - CID GetId ( EImplItemType const type , string const & name , CImplItem * const pParent , CImplItem const & rootControl ) <nl> + CID GetId ( EImplItemType const type , string const & name , CImplItem * const pParent , CImplItem const & rootItem ) <nl> { <nl> - string const fullname = Utils : : GetTypeName ( type ) + Utils : : GetPathName ( pParent , rootControl ) + CRY_NATIVE_PATH_SEPSTR + name ; <nl> + string const fullname = Utils : : GetTypeName ( type ) + Utils : : GetPathName ( pParent , rootItem ) + CRY_NATIVE_PATH_SEPSTR + name ; <nl> return CryAudio : : StringToId ( fullname . c_str ( ) ) ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - string GetPathName ( CImplItem const * const pImplItem , CImplItem const & rootControl ) <nl> + string GetPathName ( CImplItem const * const pImplItem , CImplItem const & rootItem ) <nl> { <nl> string pathName = " " ; <nl> auto const editorFolderType = static_cast < ItemType > ( EImplItemType : : EditorFolder ) ; <nl> string GetPathName ( CImplItem const * const pImplItem , CImplItem const & rootContro <nl> if ( pImplItem ! = nullptr ) <nl> { <nl> string fullname = pImplItem - > GetName ( ) ; <nl> - CImplItem const * pParent = pImplItem - > GetParent ( ) ; <nl> + IImplItem const * pParent = pImplItem - > GetParent ( ) ; <nl> <nl> - while ( ( pParent ! = nullptr ) & & ( pParent - > GetType ( ) ! = editorFolderType ) & & ( pParent ! = & rootControl ) ) <nl> + while ( ( pParent ! = nullptr ) & & ( pParent - > GetType ( ) ! = editorFolderType ) & & ( pParent ! = & rootItem ) ) <nl> { <nl> / / The id needs to represent the full path , as we can have items with the same name in different folders <nl> fullname = pParent - > GetName ( ) + " / " + fullname ; <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorFmod / ImplUtils . h <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorFmod / ImplUtils . h <nl> <nl> <nl> # pragma once <nl> <nl> - # include " ImplControls . h " <nl> + # include " ImplItem . h " <nl> <nl> namespace ACE <nl> { <nl> static string const g_vcasFolderName = " VCAs " ; <nl> <nl> namespace Utils <nl> { <nl> - CID GetId ( EImplItemType const type , string const & name , CImplItem * const pParent , CImplItem const & rootControl ) ; <nl> - string GetPathName ( CImplItem const * const pImplItem , CImplItem const & rootControl ) ; <nl> + CID GetId ( EImplItemType const type , string const & name , CImplItem * const pParent , CImplItem const & rootItem ) ; <nl> + string GetPathName ( CImplItem const * const pImplItem , CImplItem const & rootItem ) ; <nl> string GetTypeName ( EImplItemType const type ) ; <nl> } / / namespace Utils <nl> } / / namespace Fmod <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorFmod / ProjectLoader . cpp <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorFmod / ProjectLoader . cpp <nl> string const g_returnsPath = " / metadata / return / " ; <nl> string const g_vcasPath = " / metadata / vca / " ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - CProjectLoader : : CProjectLoader ( string const & projectPath , string const & soundbanksPath , CImplItem & root , ControlsCache & controlsCache ) <nl> - : m_root ( root ) <nl> - , m_controlsCache ( controlsCache ) <nl> + CProjectLoader : : CProjectLoader ( string const & projectPath , string const & soundbanksPath , CImplItem & rootItem , ItemCache & itemCache , CEditorImpl & editorImpl ) <nl> + : m_rootItem ( rootItem ) <nl> + , m_itemCache ( itemCache ) <nl> , m_projectPath ( projectPath ) <nl> + , m_editorImpl ( editorImpl ) <nl> { <nl> - CImplItem * const pSoundBanks = CreateItem ( g_soundBanksFolderName , EImplItemType : : EditorFolder , & m_root ) ; <nl> - LoadBanks ( soundbanksPath , false , * pSoundBanks ) ; <nl> - <nl> - ParseFolder ( projectPath + g_eventFoldersPath , g_eventsFolderName , root ) ; / / Event folders <nl> - ParseFolder ( projectPath + g_parametersFoldersPath , g_parametersFolderName , root ) ; / / Parameter folders <nl> - ParseFolder ( projectPath + g_snapshotGroupsPath , g_snapshotsFolderName , root ) ; / / Snapshot groups <nl> - ParseFolder ( projectPath + g_mixerGroupsPath , g_returnsFolderName , root ) ; / / Mixer groups <nl> - ParseFolder ( projectPath + g_eventsPath , g_eventsFolderName , root ) ; / / Events <nl> - ParseFolder ( projectPath + g_parametersPath , g_parametersFolderName , root ) ; / / Parameters <nl> - ParseFolder ( projectPath + g_snapshotsPath , g_snapshotsFolderName , root ) ; / / Snapshots <nl> - ParseFolder ( projectPath + g_returnsPath , g_returnsFolderName , root ) ; / / Returns <nl> - ParseFolder ( projectPath + g_vcasPath , g_vcasFolderName , root ) ; / / VCAs <nl> + CImplItem * const pSoundBanksFolder = CreateItem ( g_soundBanksFolderName , EImplItemType : : EditorFolder , & m_rootItem ) ; <nl> + LoadBanks ( soundbanksPath , false , * pSoundBanksFolder ) ; <nl> + <nl> + CImplItem * const pEventsFolder = CreateItem ( g_eventsFolderName , EImplItemType : : EditorFolder , & m_rootItem ) ; <nl> + CImplItem * const pParametersFolder = CreateItem ( g_parametersFolderName , EImplItemType : : EditorFolder , & m_rootItem ) ; <nl> + CImplItem * const pSnapshotsFolder = CreateItem ( g_snapshotsFolderName , EImplItemType : : EditorFolder , & m_rootItem ) ; <nl> + CImplItem * const pReturnsFolder = CreateItem ( g_returnsFolderName , EImplItemType : : EditorFolder , & m_rootItem ) ; <nl> + CImplItem * const pVcasFolder = CreateItem ( g_vcasFolderName , EImplItemType : : EditorFolder , & m_rootItem ) ; <nl> + <nl> + ParseFolder ( projectPath + g_eventFoldersPath , * pEventsFolder , rootItem ) ; / / Event folders <nl> + ParseFolder ( projectPath + g_parametersFoldersPath , * pParametersFolder , rootItem ) ; / / Parameter folders <nl> + ParseFolder ( projectPath + g_snapshotGroupsPath , * pSnapshotsFolder , rootItem ) ; / / Snapshot groups <nl> + ParseFolder ( projectPath + g_mixerGroupsPath , * pReturnsFolder , rootItem ) ; / / Mixer groups <nl> + ParseFolder ( projectPath + g_eventsPath , * pEventsFolder , rootItem ) ; / / Events <nl> + ParseFolder ( projectPath + g_parametersPath , * pParametersFolder , rootItem ) ; / / Parameters <nl> + ParseFolder ( projectPath + g_snapshotsPath , * pSnapshotsFolder , rootItem ) ; / / Snapshots <nl> + ParseFolder ( projectPath + g_returnsPath , * pReturnsFolder , rootItem ) ; / / Returns <nl> + ParseFolder ( projectPath + g_vcasPath , * pVcasFolder , rootItem ) ; / / VCAs <nl> <nl> RemoveEmptyMixerGroups ( ) ; <nl> + <nl> + RemoveEmptyEditorFolders ( pSoundBanksFolder ) ; <nl> + RemoveEmptyEditorFolders ( pEventsFolder ) ; <nl> + RemoveEmptyEditorFolders ( pParametersFolder ) ; <nl> + RemoveEmptyEditorFolders ( pSnapshotsFolder ) ; <nl> + RemoveEmptyEditorFolders ( pReturnsFolder ) ; <nl> + RemoveEmptyEditorFolders ( pVcasFolder ) ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> void CProjectLoader : : LoadBanks ( string const & folderPath , bool const isLocalized , <nl> { <nl> if ( filename . compare ( 0 , masterBankName . length ( ) , masterBankName ) ! = 0 ) <nl> { <nl> - CImplItem * const pSoundBank = CreateItem ( filename , EImplItemType : : Bank , & parent ) ; <nl> - pSoundBank - > SetFilePath ( folderPath + CRY_NATIVE_PATH_SEPSTR + filename ) ; <nl> + CImplItem * const pSoundBank = CreateItem ( filename , EImplItemType : : Bank , & parent , folderPath + CRY_NATIVE_PATH_SEPSTR + filename ) ; <nl> } <nl> } <nl> <nl> void CProjectLoader : : LoadBanks ( string const & folderPath , bool const isLocalized , <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - void CProjectLoader : : ParseFolder ( string const & folderPath , string const & folderName , CImplItem & parent ) <nl> + void CProjectLoader : : ParseFolder ( string const & folderPath , CImplItem & editorFolder , CImplItem & parent ) <nl> { <nl> _finddata_t fd ; <nl> ICryPak * const pCryPak = gEnv - > pCryPak ; <nl> void CProjectLoader : : ParseFolder ( string const & folderPath , string const & folderN <nl> <nl> if ( handle ! = - 1 ) <nl> { <nl> - CImplItem * const pEditorFolder = CreateItem ( folderName , EImplItemType : : EditorFolder , & parent ) ; <nl> - <nl> do <nl> { <nl> string const filename = fd . name ; <nl> <nl> if ( ( filename ! = " . " ) & & ( filename ! = " . . " ) & & ! filename . empty ( ) ) <nl> { <nl> - ParseFile ( folderPath + filename , * pEditorFolder ) ; <nl> + ParseFile ( folderPath + filename , editorFolder ) ; <nl> } <nl> } <nl> while ( pCryPak - > FindNext ( handle , & fd ) > = 0 ) ; <nl> CImplItem * CProjectLoader : : LoadVca ( XmlNodeRef const pNode , CImplItem & parent ) <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - CImplItem * CProjectLoader : : CreateItem ( string const & name , EImplItemType const type , CImplItem * const pParent ) <nl> + CImplItem * CProjectLoader : : CreateItem ( string const & name , EImplItemType const type , CImplItem * const pParent , string const & filePath / * = " " * / ) <nl> { <nl> - CID const id = Utils : : GetId ( type , name , pParent , m_root ) ; <nl> - CImplItem * pImplItem = GetControl ( id ) ; <nl> + CID const id = Utils : : GetId ( type , name , pParent , m_rootItem ) ; <nl> + auto pImplItem = static_cast < CImplItem * > ( m_editorImpl . GetImplItem ( id ) ) ; <nl> <nl> if ( pImplItem ! = nullptr ) <nl> { <nl> CImplItem * CProjectLoader : : CreateItem ( string const & name , EImplItemType const ty <nl> while ( pParentItem ! = nullptr ) <nl> { <nl> pParentItem - > SetPlaceholder ( false ) ; <nl> - pParentItem = pParentItem - > GetParent ( ) ; <nl> + pParentItem = static_cast < CImplItem * > ( pParentItem - > GetParent ( ) ) ; <nl> } <nl> } <nl> } <nl> else <nl> { <nl> - if ( type = = EImplItemType : : Folder ) <nl> + if ( type = = EImplItemType : : Bank ) <nl> { <nl> - pImplItem = new CImplFolder ( name , id ) ; <nl> + pImplItem = new CImplItem ( name , id , static_cast < ItemType > ( type ) , EImplItemFlags : : None , filePath ) ; <nl> } <nl> - else if ( type = = EImplItemType : : MixerGroup ) <nl> + else if ( type = = EImplItemType : : EditorFolder ) <nl> { <nl> - pImplItem = new CImplMixerGroup ( name , id ) ; <nl> - m_emptyMixerGroups . push_back ( static_cast < CImplMixerGroup * > ( pImplItem ) ) ; <nl> + pImplItem = new CImplItem ( name , id , static_cast < ItemType > ( type ) , EImplItemFlags : : IsContainer ) ; <nl> } <nl> else <nl> { <nl> pImplItem = new CImplItem ( name , id , static_cast < ItemType > ( type ) ) ; <nl> <nl> - if ( type = = EImplItemType : : EditorFolder ) <nl> + if ( type = = EImplItemType : : MixerGroup ) <nl> { <nl> - pImplItem - > SetContainer ( true ) ; <nl> + m_emptyMixerGroups . push_back ( pImplItem ) ; <nl> } <nl> } <nl> <nl> CImplItem * CProjectLoader : : CreateItem ( string const & name , EImplItemType const ty <nl> } <nl> else <nl> { <nl> - m_root . AddChild ( pImplItem ) ; <nl> + m_rootItem . AddChild ( pImplItem ) ; <nl> } <nl> <nl> - m_controlsCache [ id ] = pImplItem ; <nl> - <nl> - } <nl> - <nl> - return pImplItem ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - CImplItem * CProjectLoader : : GetControl ( CID const id ) const <nl> - { <nl> - CImplItem * pImplItem = nullptr ; <nl> + m_itemCache [ id ] = pImplItem ; <nl> <nl> - if ( id > = 0 ) <nl> - { <nl> - pImplItem = stl : : find_in_map ( m_controlsCache , id , nullptr ) ; <nl> } <nl> <nl> return pImplItem ; <nl> void CProjectLoader : : RemoveEmptyMixerGroups ( ) <nl> <nl> if ( pMixerGroup ! = nullptr ) <nl> { <nl> - auto const pParent = pMixerGroup - > GetParent ( ) ; <nl> + auto const pParent = static_cast < CImplItem * const > ( pMixerGroup - > GetParent ( ) ) ; <nl> <nl> if ( pParent ! = nullptr ) <nl> { <nl> pParent - > RemoveChild ( pMixerGroup ) ; <nl> } <nl> <nl> - size_t const childCount = pMixerGroup - > ChildCount ( ) ; <nl> + size_t const numChildren = pMixerGroup - > GetNumChildren ( ) ; <nl> <nl> - for ( size_t i = 0 ; i < childCount ; + + i ) <nl> + for ( size_t i = 0 ; i < numChildren ; + + i ) <nl> { <nl> - auto const pChild = pMixerGroup - > GetChildAt ( i ) ; <nl> + auto const pChild = static_cast < CImplItem * const > ( pMixerGroup - > GetChildAt ( i ) ) ; <nl> <nl> if ( pChild ! = nullptr ) <nl> { <nl> void CProjectLoader : : RemoveEmptyMixerGroups ( ) <nl> } <nl> <nl> auto const id = pMixerGroup - > GetId ( ) ; <nl> - auto const cacheIter = m_controlsCache . find ( id ) ; <nl> + auto const cacheIter = m_itemCache . find ( id ) ; <nl> <nl> - if ( cacheIter ! = m_controlsCache . end ( ) ) <nl> + if ( cacheIter ! = m_itemCache . end ( ) ) <nl> { <nl> - m_controlsCache . erase ( cacheIter ) ; <nl> + m_itemCache . erase ( cacheIter ) ; <nl> } <nl> <nl> delete pMixerGroup ; <nl> void CProjectLoader : : RemoveEmptyMixerGroups ( ) <nl> <nl> m_emptyMixerGroups . clear ( ) ; <nl> } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void CProjectLoader : : RemoveEmptyEditorFolders ( CImplItem * const pEditorFolder ) <nl> + { <nl> + if ( pEditorFolder - > GetNumChildren ( ) = = 0 ) <nl> + { <nl> + m_rootItem . RemoveChild ( pEditorFolder ) ; <nl> + ItemCache : : const_iterator const it ( m_itemCache . find ( pEditorFolder - > GetId ( ) ) ) ; <nl> + <nl> + if ( it ! = m_itemCache . end ( ) ) <nl> + { <nl> + m_itemCache . erase ( it ) ; <nl> + } <nl> + <nl> + delete pEditorFolder ; <nl> + } <nl> + } <nl> } / / namespace Fmod <nl> } / / namespace ACE <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorFmod / ProjectLoader . h <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorFmod / ProjectLoader . h <nl> <nl> <nl> # pragma once <nl> <nl> - # include " ImplControls . h " <nl> + # include " ImplItem . h " <nl> <nl> # include < CrySystem / XML / IXml . h > <nl> # include < SystemTypes . h > <nl> namespace ACE <nl> { <nl> namespace Fmod <nl> { <nl> + class CEditorImpl ; <nl> + <nl> class CProjectLoader final <nl> { <nl> public : <nl> <nl> - CProjectLoader ( string const & projectPath , string const & soundbanksPath , CImplItem & root , ControlsCache & controlsCache ) ; <nl> + CProjectLoader ( string const & projectPath , string const & soundbanksPath , CImplItem & rootItem , ItemCache & itemCache , CEditorImpl & editorImpl ) ; <nl> <nl> private : <nl> <nl> - CImplItem * CreateItem ( string const & name , EImplItemType const type , CImplItem * const pParent ) ; <nl> - CImplItem * GetControl ( CID const id ) const ; <nl> + CImplItem * CreateItem ( string const & name , EImplItemType const type , CImplItem * const pParent , string const & filePath = " " ) ; <nl> <nl> void LoadBanks ( string const & folderPath , bool const isLocalized , CImplItem & parent ) ; <nl> - void ParseFolder ( string const & folderPath , string const & folderName , CImplItem & parent ) ; <nl> + void ParseFolder ( string const & folderPath , CImplItem & editorFolder , CImplItem & parent ) ; <nl> void ParseFile ( string const & filepath , CImplItem & parent ) ; <nl> void RemoveEmptyMixerGroups ( ) ; <nl> + void RemoveEmptyEditorFolders ( CImplItem * const pEditorFolder ) ; <nl> <nl> CImplItem * GetContainer ( string const & id , EImplItemType const type , CImplItem & parent ) ; <nl> CImplItem * LoadContainer ( XmlNodeRef const pNode , EImplItemType const type , string const & relationshipParamName , CImplItem & parent ) ; <nl> class CProjectLoader final <nl> <nl> using ItemIds = std : : map < string , CImplItem * > ; <nl> <nl> - CImplItem & m_root ; <nl> - ControlsCache & m_controlsCache ; <nl> - ItemIds m_containerIds ; <nl> - ItemIds m_snapshotGroupItems ; <nl> - std : : vector < CImplMixerGroup * > m_emptyMixerGroups ; <nl> - string const m_projectPath ; <nl> + CEditorImpl & m_editorImpl ; <nl> + CImplItem & m_rootItem ; <nl> + ItemCache & m_itemCache ; <nl> + ItemIds m_containerIds ; <nl> + ItemIds m_snapshotGroupItems ; <nl> + std : : vector < CImplItem * > m_emptyMixerGroups ; <nl> + string const m_projectPath ; <nl> } ; <nl> } / / namespace Fmod <nl> } / / namespace ACE <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorPortAudio / CMakeLists . txt <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorPortAudio / CMakeLists . txt <nl> add_sources ( " EditorPortAudio_uber_0 . cpp " <nl> " EditorImpl . h " <nl> " ImplConnections . cpp " <nl> " ImplConnections . h " <nl> - " ImplControls . cpp " <nl> - " ImplControls . h " <nl> + " ImplItem . cpp " <nl> + " ImplItem . h " <nl> " ImplTypes . h " <nl> " main . cpp " <nl> " ProjectLoader . h " <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorPortAudio / EditorImpl . cpp <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorPortAudio / EditorImpl . cpp <nl> CImplSettings : : CImplSettings ( ) <nl> CryAudio : : Impl : : PortAudio : : s_szImplFolderName + <nl> CRY_NATIVE_PATH_SEPSTR + <nl> CryAudio : : s_szAssetsFolderName ) <nl> - { <nl> - } <nl> + { } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> CEditorImpl : : CEditorImpl ( ) <nl> void CEditorImpl : : Reload ( bool const preserveConnectionStatus ) <nl> { <nl> Clear ( ) ; <nl> <nl> - CProjectLoader ( GetSettings ( ) - > GetProjectPath ( ) , m_rootControl ) ; <nl> + CProjectLoader ( GetSettings ( ) - > GetProjectPath ( ) , m_rootItem ) ; <nl> <nl> - CreateControlCache ( & m_rootControl ) ; <nl> + CreateItemCache ( & m_rootItem ) ; <nl> <nl> if ( preserveConnectionStatus ) <nl> { <nl> void CEditorImpl : : Reload ( bool const preserveConnectionStatus ) <nl> { <nl> if ( connection . second > 0 ) <nl> { <nl> - CImplItem * const pImplControl = GetControl ( connection . first ) ; <nl> + auto const pImplItem = static_cast < CImplItem * const > ( GetImplItem ( connection . first ) ) ; <nl> <nl> - if ( pImplControl ! = nullptr ) <nl> + if ( pImplItem ! = nullptr ) <nl> { <nl> - pImplControl - > SetConnected ( true ) ; <nl> + pImplItem - > SetConnected ( true ) ; <nl> } <nl> } <nl> } <nl> void CEditorImpl : : Reload ( bool const preserveConnectionStatus ) <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - CImplItem * CEditorImpl : : GetControl ( CID const id ) const <nl> + IImplItem * CEditorImpl : : GetImplItem ( CID const id ) const <nl> { <nl> CImplItem * pImplItem = nullptr ; <nl> <nl> if ( id > = 0 ) <nl> { <nl> - pImplItem = stl : : find_in_map ( m_controlsCache , id , nullptr ) ; <nl> + pImplItem = stl : : find_in_map ( m_itemCache , id , nullptr ) ; <nl> } <nl> <nl> return pImplItem ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - char const * CEditorImpl : : GetTypeIcon ( CImplItem const * const pImplItem ) const <nl> + char const * CEditorImpl : : GetTypeIcon ( IImplItem const * const pImplItem ) const <nl> { <nl> char const * szIconPath = " icons : Dialogs / dialog - error . ico " ; <nl> auto const type = static_cast < EImpltemType > ( pImplItem - > GetType ( ) ) ; <nl> bool CEditorImpl : : IsSystemTypeSupported ( ESystemItemType const systemType ) const <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - bool CEditorImpl : : IsTypeCompatible ( ESystemItemType const systemType , CImplItem const * const pImplItem ) const <nl> + bool CEditorImpl : : IsTypeCompatible ( ESystemItemType const systemType , IImplItem const * const pImplItem ) const <nl> { <nl> bool isCompatible = false ; <nl> auto const implType = static_cast < EImpltemType > ( pImplItem - > GetType ( ) ) ; <nl> bool CEditorImpl : : IsTypeCompatible ( ESystemItemType const systemType , CImplItem c <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - ESystemItemType CEditorImpl : : ImplTypeToSystemType ( CImplItem const * const pImplItem ) const <nl> + ESystemItemType CEditorImpl : : ImplTypeToSystemType ( IImplItem const * const pImplItem ) const <nl> { <nl> ESystemItemType systemType = ESystemItemType : : Invalid ; <nl> auto const implType = static_cast < EImpltemType > ( pImplItem - > GetType ( ) ) ; <nl> ESystemItemType CEditorImpl : : ImplTypeToSystemType ( CImplItem const * const pImplIt <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - ConnectionPtr CEditorImpl : : CreateConnectionToControl ( ESystemItemType const controlType , CImplItem * const pImplItem ) <nl> + ConnectionPtr CEditorImpl : : CreateConnectionToControl ( ESystemItemType const controlType , IImplItem * const pImplItem ) <nl> { <nl> ConnectionPtr pConnection = nullptr ; <nl> <nl> ConnectionPtr CEditorImpl : : CreateConnectionFromXMLNode ( XmlNodeRef pNode , ESystem <nl> id = GetId ( path + CRY_NATIVE_PATH_SEPSTR + name ) ; <nl> } <nl> <nl> - CImplItem * pImplControl = GetControl ( id ) ; <nl> + auto pImplItem = static_cast < CImplItem * > ( GetImplItem ( id ) ) ; <nl> <nl> - if ( pImplControl = = nullptr ) <nl> + if ( pImplItem = = nullptr ) <nl> { <nl> - pImplControl = new CImplControl ( name , id , static_cast < ItemType > ( EImpltemType : : Event ) ) ; <nl> - pImplControl - > SetPlaceholder ( true ) ; <nl> - m_controlsCache [ id ] = pImplControl ; <nl> + pImplItem = new CImplItem ( name , id , static_cast < ItemType > ( EImpltemType : : Event ) , EImplItemFlags : : IsPlaceHolder ) ; <nl> + m_itemCache [ id ] = pImplItem ; <nl> } <nl> <nl> - if ( pImplControl ! = nullptr ) <nl> + if ( pImplItem ! = nullptr ) <nl> { <nl> - auto const pConnection = std : : make_shared < CConnection > ( pImplControl - > GetId ( ) ) ; <nl> + auto const pConnection = std : : make_shared < CConnection > ( pImplItem - > GetId ( ) ) ; <nl> string connectionType = pNode - > getAttr ( CryAudio : : s_szTypeAttribute ) ; <nl> # if defined ( USE_BACKWARDS_COMPATIBILITY ) <nl> if ( connectionType . IsEmpty ( ) & & pNode - > haveAttr ( " event_type " ) ) <nl> XmlNodeRef CEditorImpl : : CreateXMLNodeFromConnection ( ConnectionPtr const pConnect <nl> XmlNodeRef pConnectionNode = nullptr ; <nl> <nl> std : : shared_ptr < CConnection const > const pImplConnection = std : : static_pointer_cast < CConnection const > ( pConnection ) ; <nl> - CImplItem const * const pImplControl = GetControl ( pConnection - > GetID ( ) ) ; <nl> + auto const pImplItem = static_cast < CImplItem const * const > ( GetImplItem ( pConnection - > GetID ( ) ) ) ; <nl> <nl> - if ( ( pImplControl ! = nullptr ) & & ( pImplConnection ! = nullptr ) & & ( controlType = = ESystemItemType : : Trigger ) ) <nl> + if ( ( pImplItem ! = nullptr ) & & ( pImplConnection ! = nullptr ) & & ( controlType = = ESystemItemType : : Trigger ) ) <nl> { <nl> pConnectionNode = GetISystem ( ) - > CreateXmlNode ( CryAudio : : s_szEventTag ) ; <nl> - pConnectionNode - > setAttr ( CryAudio : : s_szNameAttribute , pImplControl - > GetName ( ) ) ; <nl> + pConnectionNode - > setAttr ( CryAudio : : s_szNameAttribute , pImplItem - > GetName ( ) ) ; <nl> <nl> string path ; <nl> - CImplItem const * pParent = pImplControl - > GetParent ( ) ; <nl> + IImplItem const * pParent = pImplItem - > GetParent ( ) ; <nl> <nl> while ( pParent ! = nullptr ) <nl> { <nl> XmlNodeRef CEditorImpl : : CreateXMLNodeFromConnection ( ConnectionPtr const pConnect <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> void CEditorImpl : : EnableConnection ( ConnectionPtr const pConnection ) <nl> { <nl> - CImplItem * const pImplControl = GetControl ( pConnection - > GetID ( ) ) ; <nl> + auto const pImplItem = static_cast < CImplItem * const > ( GetImplItem ( pConnection - > GetID ( ) ) ) ; <nl> <nl> - if ( pImplControl ! = nullptr ) <nl> + if ( pImplItem ! = nullptr ) <nl> { <nl> - + + m_connectionsByID [ pImplControl - > GetId ( ) ] ; <nl> - pImplControl - > SetConnected ( true ) ; <nl> + + + m_connectionsByID [ pImplItem - > GetId ( ) ] ; <nl> + pImplItem - > SetConnected ( true ) ; <nl> } <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> void CEditorImpl : : DisableConnection ( ConnectionPtr const pConnection ) <nl> { <nl> - CImplItem * const pImplControl = GetControl ( pConnection - > GetID ( ) ) ; <nl> + auto const pImplItem = static_cast < CImplItem * const > ( GetImplItem ( pConnection - > GetID ( ) ) ) ; <nl> <nl> - if ( pImplControl ! = nullptr ) <nl> + if ( pImplItem ! = nullptr ) <nl> { <nl> - int connectionCount = m_connectionsByID [ pImplControl - > GetId ( ) ] - 1 ; <nl> + int connectionCount = m_connectionsByID [ pImplItem - > GetId ( ) ] - 1 ; <nl> <nl> if ( connectionCount < = 0 ) <nl> { <nl> connectionCount = 0 ; <nl> - pImplControl - > SetConnected ( false ) ; <nl> + pImplItem - > SetConnected ( false ) ; <nl> } <nl> <nl> - m_connectionsByID [ pImplControl - > GetId ( ) ] = connectionCount ; <nl> + m_connectionsByID [ pImplItem - > GetId ( ) ] = connectionCount ; <nl> } <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> void CEditorImpl : : Clear ( ) <nl> { <nl> - / / Delete all the controls <nl> - for ( auto const & controlPair : m_controlsCache ) <nl> + / / Delete all the items <nl> + for ( auto const & itemPair : m_itemCache ) <nl> { <nl> - CImplItem const * const pImplControl = controlPair . second ; <nl> + CImplItem const * const pImplItem = itemPair . second ; <nl> <nl> - if ( pImplControl ! = nullptr ) <nl> + if ( pImplItem ! = nullptr ) <nl> { <nl> - delete pImplControl ; <nl> + delete pImplItem ; <nl> } <nl> } <nl> <nl> - m_controlsCache . clear ( ) ; <nl> + m_itemCache . clear ( ) ; <nl> <nl> - / / Clean up the root control <nl> - m_rootControl = CImplItem ( ) ; <nl> + / / Clean up the root item <nl> + m_rootItem . Clear ( ) ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - void CEditorImpl : : CreateControlCache ( CImplItem const * const pParent ) <nl> + void CEditorImpl : : CreateItemCache ( CImplItem const * const pParent ) <nl> { <nl> if ( pParent ! = nullptr ) <nl> { <nl> - size_t const count = pParent - > ChildCount ( ) ; <nl> + size_t const count = pParent - > GetNumChildren ( ) ; <nl> <nl> for ( size_t i = 0 ; i < count ; + + i ) <nl> { <nl> - CImplItem * const pChild = pParent - > GetChildAt ( i ) ; <nl> + auto const pChild = static_cast < CImplItem * const > ( pParent - > GetChildAt ( i ) ) ; <nl> <nl> if ( pChild ! = nullptr ) <nl> { <nl> - m_controlsCache [ pChild - > GetId ( ) ] = pChild ; <nl> - CreateControlCache ( pChild ) ; <nl> + m_itemCache [ pChild - > GetId ( ) ] = pChild ; <nl> + CreateItemCache ( pChild ) ; <nl> } <nl> } <nl> } <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorPortAudio / EditorImpl . h <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorPortAudio / EditorImpl . h <nl> <nl> <nl> # include < IEditorImpl . h > <nl> <nl> - # include " ImplControls . h " <nl> + # include " ImplItem . h " <nl> <nl> # include < CryAudio / IAudioSystem . h > <nl> # include < CrySystem / File / CryFile . h > <nl> class CImplSettings final : public IImplSettings <nl> virtual char const * GetAssetsPath ( ) const override { return m_assetAndProjectPath . c_str ( ) ; } <nl> virtual char const * GetProjectPath ( ) const override { return m_assetAndProjectPath . c_str ( ) ; } <nl> virtual void SetProjectPath ( char const * szPath ) override { } <nl> - virtual bool IsProjectPathEditable ( ) const override { return false ; } <nl> + virtual bool SupportsProjects ( ) const override { return false ; } <nl> / / ~ IImplSettings <nl> <nl> private : <nl> class CEditorImpl final : public IEditorImpl <nl> <nl> / / IEditorImpl <nl> virtual void Reload ( bool const preserveConnectionStatus = true ) override ; <nl> - virtual CImplItem * GetRoot ( ) override { return & m_rootControl ; } <nl> - virtual CImplItem * GetControl ( CID const id ) const override ; <nl> - virtual char const * GetTypeIcon ( CImplItem const * const pImplItem ) const override ; <nl> + virtual IImplItem * GetRoot ( ) override { return & m_rootItem ; } <nl> + virtual IImplItem * GetImplItem ( CID const id ) const override ; <nl> + virtual char const * GetTypeIcon ( IImplItem const * const pImplItem ) const override ; <nl> virtual string const & GetName ( ) const override ; <nl> virtual string const & GetFolderName ( ) const override ; <nl> virtual IImplSettings * GetSettings ( ) override { return & m_implSettings ; } <nl> virtual bool IsSystemTypeSupported ( ESystemItemType const systemType ) const override ; <nl> - virtual bool IsTypeCompatible ( ESystemItemType const systemType , CImplItem const * const pImplItem ) const override ; <nl> - virtual ESystemItemType ImplTypeToSystemType ( CImplItem const * const pImplItem ) const override ; <nl> - virtual ConnectionPtr CreateConnectionToControl ( ESystemItemType const controlType , CImplItem * const pImplItem ) override ; <nl> + virtual bool IsTypeCompatible ( ESystemItemType const systemType , IImplItem const * const pImplItem ) const override ; <nl> + virtual ESystemItemType ImplTypeToSystemType ( IImplItem const * const pImplItem ) const override ; <nl> + virtual ConnectionPtr CreateConnectionToControl ( ESystemItemType const controlType , IImplItem * const pImplItem ) override ; <nl> virtual ConnectionPtr CreateConnectionFromXMLNode ( XmlNodeRef pNode , ESystemItemType const controlType ) override ; <nl> virtual XmlNodeRef CreateXMLNodeFromConnection ( ConnectionPtr const pConnection , ESystemItemType const controlType ) override ; <nl> virtual void EnableConnection ( ConnectionPtr const pConnection ) override ; <nl> class CEditorImpl final : public IEditorImpl <nl> private : <nl> <nl> void Clear ( ) ; <nl> - void CreateControlCache ( CImplItem const * const pParent ) ; <nl> + void CreateItemCache ( CImplItem const * const pParent ) ; <nl> CID GetId ( string const & name ) const ; <nl> <nl> static string const s_itemNameTag ; <nl> class CEditorImpl final : public IEditorImpl <nl> static string const s_volumeTag ; <nl> static string const s_loopCountTag ; <nl> <nl> - using ControlsCache = std : : map < CID , CImplItem * > ; <nl> + using ItemCache = std : : map < CID , CImplItem * > ; <nl> using ConnectionsMap = std : : map < CID , int > ; <nl> <nl> - CImplItem m_rootControl ; <nl> - ControlsCache m_controlsCache ; / / cache of the controls stored by id for faster access <nl> + CImplItem m_rootItem { " " , ACE_INVALID_ID , AUDIO_SYSTEM_INVALID_TYPE } ; <nl> + ItemCache m_itemCache ; / / cache of the items stored by id for faster access <nl> ConnectionsMap m_connectionsByID ; <nl> CImplSettings m_implSettings ; <nl> CryAudio : : SImplInfo m_implInfo ; <nl> deleted file mode 100644 <nl> index f78aebf372 . . 0000000000 <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorPortAudio / ImplControls . cpp <nl> ppp / dev / null <nl> <nl> - / / Copyright 2001 - 2016 Crytek GmbH / Crytek Group . All rights reserved . <nl> - <nl> - # include " StdAfx . h " <nl> - # include " ImplControls . h " <nl> - <nl> - namespace ACE <nl> - { <nl> - namespace PortAudio <nl> - { <nl> - CImplControl : : CImplControl ( string const & name , CID const id , ItemType const type ) <nl> - : CImplItem ( name , id , type ) <nl> - { <nl> - } <nl> - } / / namespace PortAudio <nl> - } / / namespace ACE <nl> deleted file mode 100644 <nl> index c6502688dc . . 0000000000 <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorPortAudio / ImplControls . h <nl> ppp / dev / null <nl> <nl> - / / Copyright 2001 - 2016 Crytek GmbH / Crytek Group . All rights reserved . <nl> - <nl> - # pragma once <nl> - <nl> - # include < ImplItem . h > <nl> - # include " ImplTypes . h " <nl> - <nl> - namespace ACE <nl> - { <nl> - namespace PortAudio <nl> - { <nl> - class CImplControl final : public CImplItem <nl> - { <nl> - public : <nl> - <nl> - CImplControl ( ) = default ; <nl> - CImplControl ( string const & name , CID const id , ItemType const type ) ; <nl> - } ; <nl> - } / / namespace PortAudio <nl> - } / / namespace ACE <nl> new file mode 100644 <nl> index 0000000000 . . 8d9a84ea38 <nl> mmm / dev / null <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorPortAudio / ImplItem . cpp <nl> <nl> + / / Copyright 2001 - 2018 Crytek GmbH / Crytek Group . All rights reserved . <nl> + <nl> + # include " StdAfx . h " <nl> + # include " ImplItem . h " <nl> + <nl> + namespace ACE <nl> + { <nl> + namespace PortAudio <nl> + { <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void CImplItem : : SetConnected ( bool const isConnected ) <nl> + { <nl> + if ( isConnected ) <nl> + { <nl> + m_flags | = EImplItemFlags : : IsConnected ; <nl> + } <nl> + else <nl> + { <nl> + m_flags & = ~ EImplItemFlags : : IsConnected ; <nl> + } <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void CImplItem : : AddChild ( CImplItem * const pChild ) <nl> + { <nl> + m_children . push_back ( pChild ) ; <nl> + pChild - > SetParent ( this ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void CImplItem : : Clear ( ) <nl> + { <nl> + m_children . clear ( ) ; <nl> + } <nl> + } / / namespace PortAudio <nl> + } / / namespace ACE <nl> new file mode 100644 <nl> index 0000000000 . . 2890d1e9da <nl> mmm / dev / null <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorPortAudio / ImplItem . h <nl> <nl> + / / Copyright 2001 - 2018 Crytek GmbH / Crytek Group . All rights reserved . <nl> + <nl> + # pragma once <nl> + <nl> + # include < IImplItem . h > <nl> + # include " ImplTypes . h " <nl> + <nl> + namespace ACE <nl> + { <nl> + namespace PortAudio <nl> + { <nl> + enum class EImplItemFlags <nl> + { <nl> + None = 0 , <nl> + IsPlaceHolder = BIT ( 0 ) , <nl> + IsConnected = BIT ( 1 ) , <nl> + IsContainer = BIT ( 2 ) , <nl> + } ; <nl> + CRY_CREATE_ENUM_FLAG_OPERATORS ( EImplItemFlags ) ; <nl> + <nl> + class CImplItem final : public IImplItem <nl> + { <nl> + public : <nl> + <nl> + explicit CImplItem ( <nl> + string const & name , <nl> + CID const id , <nl> + ItemType const type , <nl> + EImplItemFlags const flags = EImplItemFlags : : None , <nl> + string const & filePath = " " ) <nl> + : m_name ( name ) <nl> + , m_id ( id ) <nl> + , m_type ( type ) <nl> + , m_flags ( flags ) <nl> + , m_filePath ( filePath ) <nl> + , m_pParent ( nullptr ) <nl> + { } <nl> + <nl> + virtual ~ CImplItem ( ) override = default ; <nl> + <nl> + CImplItem ( ) = delete ; <nl> + <nl> + / / IImplItem <nl> + virtual CID GetId ( ) const override { return m_id ; } <nl> + virtual ItemType GetType ( ) const override { return m_type ; } <nl> + virtual string GetName ( ) const override { return m_name ; } <nl> + virtual string const & GetFilePath ( ) const override { return m_filePath ; } <nl> + virtual float GetRadius ( ) const override { return 0 . 0f ; } <nl> + <nl> + virtual size_t GetNumChildren ( ) const override { return m_children . size ( ) ; } <nl> + virtual IImplItem * GetChildAt ( size_t const index ) const override { return m_children [ index ] ; } <nl> + virtual IImplItem * GetParent ( ) const override { return m_pParent ; } <nl> + <nl> + virtual bool IsPlaceholder ( ) const override { return ( m_flags & EImplItemFlags : : IsPlaceHolder ) ! = 0 ; } <nl> + virtual bool IsLocalized ( ) const override { return false ; } <nl> + virtual bool IsConnected ( ) const override { return ( m_flags & EImplItemFlags : : IsConnected ) ! = 0 ; } <nl> + virtual bool IsContainer ( ) const override { return ( m_flags & EImplItemFlags : : IsContainer ) ! = 0 ; } <nl> + / / ~ IImplItem <nl> + <nl> + void SetConnected ( bool const isConnected ) ; <nl> + void AddChild ( CImplItem * const pChild ) ; <nl> + <nl> + void Clear ( ) ; <nl> + <nl> + private : <nl> + <nl> + void SetParent ( CImplItem * const pParent ) { m_pParent = pParent ; } <nl> + <nl> + CID const m_id ; <nl> + ItemType const m_type ; <nl> + string const m_name ; <nl> + string const m_filePath ; <nl> + std : : vector < CImplItem * > m_children ; <nl> + CImplItem * m_pParent ; <nl> + EImplItemFlags m_flags ; <nl> + } ; <nl> + } / / namespace PortAudio <nl> + } / / namespace ACE <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorPortAudio / ProjectLoader . cpp <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorPortAudio / ProjectLoader . cpp <nl> <nl> - / / Copyright 2001 - 2016 Crytek GmbH / Crytek Group . All rights reserved . <nl> + / / Copyright 2001 - 2018 Crytek GmbH / Crytek Group . All rights reserved . <nl> <nl> # include " StdAfx . h " <nl> # include " ProjectLoader . h " <nl> CImplItem * CProjectLoader : : CreateItem ( string const & name , string const & path , EI <nl> filePath + = ( path + CRY_NATIVE_PATH_SEPSTR + name ) ; <nl> } <nl> <nl> - CImplControl * const pControl = new CImplControl ( name , id , static_cast < ItemType > ( type ) ) ; <nl> - pControl - > SetFilePath ( filePath ) ; <nl> + EImplItemFlags const flags = type = = EImpltemType : : Folder ? EImplItemFlags : : IsContainer : EImplItemFlags : : None ; <nl> + auto const pImplItem = new CImplItem ( name , id , static_cast < ItemType > ( type ) , flags , filePath ) ; <nl> <nl> - if ( type = = EImpltemType : : Folder ) <nl> - { <nl> - pControl - > SetContainer ( true ) ; <nl> - } <nl> - <nl> - rootItem . AddChild ( pControl ) ; <nl> - return pControl ; <nl> + rootItem . AddChild ( pImplItem ) ; <nl> + return pImplItem ; <nl> } <nl> } / / namespace PortAudio <nl> } / / namespace ACE <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorPortAudio / ProjectLoader . h <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorPortAudio / ProjectLoader . h <nl> <nl> - / / Copyright 2001 - 2016 Crytek GmbH / Crytek Group . All rights reserved . <nl> + / / Copyright 2001 - 2018 Crytek GmbH / Crytek Group . All rights reserved . <nl> <nl> # pragma once <nl> <nl> - # include " ImplControls . h " <nl> + # include " ImplItem . h " <nl> <nl> # include < CrySystem / XML / IXml . h > <nl> # include < SystemTypes . h > <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorSDLMixer / CMakeLists . txt <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorSDLMixer / CMakeLists . txt <nl> add_sources ( " EditorSDLMixer_uber_0 . cpp " <nl> " EditorImpl . h " <nl> " ImplConnections . cpp " <nl> " ImplConnections . h " <nl> - " ImplControls . cpp " <nl> - " ImplControls . h " <nl> + " ImplItem . cpp " <nl> + " ImplItem . h " <nl> " ImplTypes . h " <nl> " main . cpp " <nl> " ProjectLoader . h " <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorSDLMixer / EditorImpl . cpp <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorSDLMixer / EditorImpl . cpp <nl> CImplSettings : : CImplSettings ( ) <nl> CryAudio : : Impl : : SDL_mixer : : s_szImplFolderName + <nl> CRY_NATIVE_PATH_SEPSTR + <nl> CryAudio : : s_szAssetsFolderName ) <nl> - { <nl> - } <nl> + { } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> CEditorImpl : : CEditorImpl ( ) <nl> void CEditorImpl : : Reload ( bool const preserveConnectionStatus ) <nl> { <nl> Clear ( ) ; <nl> <nl> - CProjectLoader ( GetSettings ( ) - > GetProjectPath ( ) , m_rootControl ) ; <nl> + CProjectLoader ( GetSettings ( ) - > GetProjectPath ( ) , m_rootItem ) ; <nl> <nl> - CreateControlCache ( & m_rootControl ) ; <nl> + CreateItemCache ( & m_rootItem ) ; <nl> <nl> if ( preserveConnectionStatus ) <nl> { <nl> void CEditorImpl : : Reload ( bool const preserveConnectionStatus ) <nl> { <nl> if ( connection . second > 0 ) <nl> { <nl> - CImplItem * const pImplControl = GetControl ( connection . first ) ; <nl> + auto const pImplItem = static_cast < CImplItem * const > ( GetImplItem ( connection . first ) ) ; <nl> <nl> - if ( pImplControl ! = nullptr ) <nl> + if ( pImplItem ! = nullptr ) <nl> { <nl> - pImplControl - > SetConnected ( true ) ; <nl> + pImplItem - > SetConnected ( true ) ; <nl> } <nl> } <nl> } <nl> void CEditorImpl : : Reload ( bool const preserveConnectionStatus ) <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - CImplItem * CEditorImpl : : GetControl ( CID const id ) const <nl> + IImplItem * CEditorImpl : : GetImplItem ( CID const id ) const <nl> { <nl> - CImplItem * pImplItem = nullptr ; <nl> + IImplItem * pImplItem = nullptr ; <nl> <nl> if ( id > = 0 ) <nl> { <nl> - pImplItem = stl : : find_in_map ( m_controlsCache , id , nullptr ) ; <nl> + pImplItem = stl : : find_in_map ( m_itemCache , id , nullptr ) ; <nl> } <nl> <nl> return pImplItem ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - char const * CEditorImpl : : GetTypeIcon ( CImplItem const * const pImplItem ) const <nl> + char const * CEditorImpl : : GetTypeIcon ( IImplItem const * const pImplItem ) const <nl> { <nl> char const * szIconPath = " icons : Dialogs / dialog - error . ico " ; <nl> auto const type = static_cast < EImpltemType > ( pImplItem - > GetType ( ) ) ; <nl> bool CEditorImpl : : IsSystemTypeSupported ( ESystemItemType const systemType ) const <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - bool CEditorImpl : : IsTypeCompatible ( ESystemItemType const systemType , CImplItem const * const pImplItem ) const <nl> + bool CEditorImpl : : IsTypeCompatible ( ESystemItemType const systemType , IImplItem const * const pImplItem ) const <nl> { <nl> bool isCompatible = false ; <nl> auto const implType = static_cast < EImpltemType > ( pImplItem - > GetType ( ) ) ; <nl> bool CEditorImpl : : IsTypeCompatible ( ESystemItemType const systemType , CImplItem c <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - ESystemItemType CEditorImpl : : ImplTypeToSystemType ( CImplItem const * const pImplItem ) const <nl> + ESystemItemType CEditorImpl : : ImplTypeToSystemType ( IImplItem const * const pImplItem ) const <nl> { <nl> ESystemItemType systemType = ESystemItemType : : Invalid ; <nl> auto const implType = static_cast < EImpltemType > ( pImplItem - > GetType ( ) ) ; <nl> ESystemItemType CEditorImpl : : ImplTypeToSystemType ( CImplItem const * const pImplIt <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - ConnectionPtr CEditorImpl : : CreateConnectionToControl ( ESystemItemType const controlType , CImplItem * const pImplItem ) <nl> + ConnectionPtr CEditorImpl : : CreateConnectionToControl ( ESystemItemType const controlType , IImplItem * const pImplItem ) <nl> { <nl> ConnectionPtr pConnection = nullptr ; <nl> <nl> ConnectionPtr CEditorImpl : : CreateConnectionFromXMLNode ( XmlNodeRef pNode , ESystem <nl> id = GetId ( path + CRY_NATIVE_PATH_SEPSTR + name ) ; <nl> } <nl> <nl> - CImplItem * pImplControl = GetControl ( id ) ; <nl> + auto pImplItem = static_cast < CImplItem * > ( GetImplItem ( id ) ) ; <nl> <nl> - if ( pImplControl = = nullptr ) <nl> + if ( pImplItem = = nullptr ) <nl> { <nl> - pImplControl = new CImplControl ( name , id , static_cast < ItemType > ( EImpltemType : : Event ) ) ; <nl> - pImplControl - > SetPlaceholder ( true ) ; <nl> - m_controlsCache [ id ] = pImplControl ; <nl> + pImplItem = new CImplItem ( name , id , static_cast < ItemType > ( EImpltemType : : Event ) , EImplItemFlags : : IsPlaceHolder ) ; <nl> + m_itemCache [ id ] = pImplItem ; <nl> } <nl> <nl> - if ( pImplControl ! = nullptr ) <nl> + if ( pImplItem ! = nullptr ) <nl> { <nl> - auto const pConnection = std : : make_shared < CConnection > ( pImplControl - > GetId ( ) ) ; <nl> + auto const pConnection = std : : make_shared < CConnection > ( pImplItem - > GetId ( ) ) ; <nl> string connectionType = pNode - > getAttr ( CryAudio : : s_szTypeAttribute ) ; <nl> # if defined ( USE_BACKWARDS_COMPATIBILITY ) <nl> if ( connectionType . IsEmpty ( ) & & pNode - > haveAttr ( " event_type " ) ) <nl> XmlNodeRef CEditorImpl : : CreateXMLNodeFromConnection ( ConnectionPtr const pConnect <nl> XmlNodeRef pConnectionNode = nullptr ; <nl> <nl> std : : shared_ptr < CConnection const > const pImplConnection = std : : static_pointer_cast < CConnection const > ( pConnection ) ; <nl> - CImplItem const * const pImplControl = GetControl ( pConnection - > GetID ( ) ) ; <nl> + auto const pImplItem = static_cast < CImplItem const * const > ( GetImplItem ( pConnection - > GetID ( ) ) ) ; <nl> <nl> - if ( ( pImplControl ! = nullptr ) & & ( pImplConnection ! = nullptr ) & & ( controlType = = ESystemItemType : : Trigger ) ) <nl> + if ( ( pImplItem ! = nullptr ) & & ( pImplConnection ! = nullptr ) & & ( controlType = = ESystemItemType : : Trigger ) ) <nl> { <nl> pConnectionNode = GetISystem ( ) - > CreateXmlNode ( CryAudio : : s_szEventTag ) ; <nl> - pConnectionNode - > setAttr ( CryAudio : : s_szNameAttribute , pImplControl - > GetName ( ) ) ; <nl> + pConnectionNode - > setAttr ( CryAudio : : s_szNameAttribute , pImplItem - > GetName ( ) ) ; <nl> <nl> string path ; <nl> - CImplItem const * pParent = pImplControl - > GetParent ( ) ; <nl> + IImplItem const * pParent = pImplItem - > GetParent ( ) ; <nl> <nl> while ( pParent ! = nullptr ) <nl> { <nl> XmlNodeRef CEditorImpl : : CreateXMLNodeFromConnection ( ConnectionPtr const pConnect <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> void CEditorImpl : : EnableConnection ( ConnectionPtr const pConnection ) <nl> { <nl> - CImplItem * const pImplControl = GetControl ( pConnection - > GetID ( ) ) ; <nl> + auto const pImplItem = static_cast < CImplItem * const > ( GetImplItem ( pConnection - > GetID ( ) ) ) ; <nl> <nl> - if ( pImplControl ! = nullptr ) <nl> + if ( pImplItem ! = nullptr ) <nl> { <nl> - + + m_connectionsByID [ pImplControl - > GetId ( ) ] ; <nl> - pImplControl - > SetConnected ( true ) ; <nl> + + + m_connectionsByID [ pImplItem - > GetId ( ) ] ; <nl> + pImplItem - > SetConnected ( true ) ; <nl> } <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> void CEditorImpl : : DisableConnection ( ConnectionPtr const pConnection ) <nl> { <nl> - CImplItem * const pImplControl = GetControl ( pConnection - > GetID ( ) ) ; <nl> + auto const pImplItem = static_cast < CImplItem * const > ( GetImplItem ( pConnection - > GetID ( ) ) ) ; <nl> <nl> - if ( pImplControl ! = nullptr ) <nl> + if ( pImplItem ! = nullptr ) <nl> { <nl> - int connectionCount = m_connectionsByID [ pImplControl - > GetId ( ) ] - 1 ; <nl> + int connectionCount = m_connectionsByID [ pImplItem - > GetId ( ) ] - 1 ; <nl> <nl> if ( connectionCount < = 0 ) <nl> { <nl> connectionCount = 0 ; <nl> - pImplControl - > SetConnected ( false ) ; <nl> + pImplItem - > SetConnected ( false ) ; <nl> } <nl> <nl> - m_connectionsByID [ pImplControl - > GetId ( ) ] = connectionCount ; <nl> + m_connectionsByID [ pImplItem - > GetId ( ) ] = connectionCount ; <nl> } <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> void CEditorImpl : : Clear ( ) <nl> { <nl> - / / Delete all the controls <nl> - for ( auto const & controlPair : m_controlsCache ) <nl> + / / Delete all the items <nl> + for ( auto const & itemPair : m_itemCache ) <nl> { <nl> - CImplItem const * const pImplControl = controlPair . second ; <nl> + CImplItem const * const pImplItem = itemPair . second ; <nl> <nl> - if ( pImplControl ! = nullptr ) <nl> + if ( pImplItem ! = nullptr ) <nl> { <nl> - delete pImplControl ; <nl> + delete pImplItem ; <nl> } <nl> } <nl> <nl> - m_controlsCache . clear ( ) ; <nl> + m_itemCache . clear ( ) ; <nl> <nl> - / / Clean up the root control <nl> - m_rootControl = CImplItem ( ) ; <nl> + / / Clean up the root item <nl> + m_rootItem . Clear ( ) ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - void CEditorImpl : : CreateControlCache ( CImplItem const * const pParent ) <nl> + void CEditorImpl : : CreateItemCache ( CImplItem const * const pParent ) <nl> { <nl> if ( pParent ! = nullptr ) <nl> { <nl> - size_t const count = pParent - > ChildCount ( ) ; <nl> + size_t const count = pParent - > GetNumChildren ( ) ; <nl> <nl> for ( size_t i = 0 ; i < count ; + + i ) <nl> { <nl> - CImplItem * const pChild = pParent - > GetChildAt ( i ) ; <nl> + auto const pChild = static_cast < CImplItem * const > ( pParent - > GetChildAt ( i ) ) ; <nl> <nl> if ( pChild ! = nullptr ) <nl> { <nl> - m_controlsCache [ pChild - > GetId ( ) ] = pChild ; <nl> - CreateControlCache ( pChild ) ; <nl> + m_itemCache [ pChild - > GetId ( ) ] = pChild ; <nl> + CreateItemCache ( pChild ) ; <nl> } <nl> } <nl> } <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorSDLMixer / EditorImpl . h <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorSDLMixer / EditorImpl . h <nl> <nl> <nl> # include < IEditorImpl . h > <nl> <nl> - # include " ImplControls . h " <nl> + # include " ImplItem . h " <nl> <nl> # include < CryAudio / IAudioSystem . h > <nl> # include < CrySystem / File / CryFile . h > <nl> class CImplSettings final : public IImplSettings <nl> virtual char const * GetAssetsPath ( ) const override { return m_assetAndProjectPath . c_str ( ) ; } <nl> virtual char const * GetProjectPath ( ) const override { return m_assetAndProjectPath . c_str ( ) ; } <nl> virtual void SetProjectPath ( char const * szPath ) override { } <nl> - virtual bool IsProjectPathEditable ( ) const override { return false ; } <nl> + virtual bool SupportsProjects ( ) const override { return false ; } <nl> / / ~ IImplSettings <nl> <nl> private : <nl> class CEditorImpl final : public IEditorImpl <nl> <nl> / / IEditorImpl <nl> virtual void Reload ( bool const preserveConnectionStatus = true ) override ; <nl> - virtual CImplItem * GetRoot ( ) override { return & m_rootControl ; } <nl> - virtual CImplItem * GetControl ( CID const id ) const override ; <nl> - virtual char const * GetTypeIcon ( CImplItem const * const pImplItem ) const override ; <nl> + virtual IImplItem * GetRoot ( ) override { return & m_rootItem ; } <nl> + virtual IImplItem * GetImplItem ( CID const id ) const override ; <nl> + virtual char const * GetTypeIcon ( IImplItem const * const pImplItem ) const override ; <nl> virtual string const & GetName ( ) const override ; <nl> virtual string const & GetFolderName ( ) const override ; <nl> virtual IImplSettings * GetSettings ( ) override { return & m_implSettings ; } <nl> virtual bool IsSystemTypeSupported ( ESystemItemType const systemType ) const override ; <nl> - virtual bool IsTypeCompatible ( ESystemItemType const systemType , CImplItem const * const pImplItem ) const override ; <nl> - virtual ESystemItemType ImplTypeToSystemType ( CImplItem const * const pImplItem ) const override ; <nl> - virtual ConnectionPtr CreateConnectionToControl ( ESystemItemType const controlType , CImplItem * const pImplItem ) override ; <nl> + virtual bool IsTypeCompatible ( ESystemItemType const systemType , IImplItem const * const pImplItem ) const override ; <nl> + virtual ESystemItemType ImplTypeToSystemType ( IImplItem const * const pImplItem ) const override ; <nl> + virtual ConnectionPtr CreateConnectionToControl ( ESystemItemType const controlType , IImplItem * const pImplItem ) override ; <nl> virtual ConnectionPtr CreateConnectionFromXMLNode ( XmlNodeRef pNode , ESystemItemType const controlType ) override ; <nl> virtual XmlNodeRef CreateXMLNodeFromConnection ( ConnectionPtr const pConnection , ESystemItemType const controlType ) override ; <nl> virtual void EnableConnection ( ConnectionPtr const pConnection ) override ; <nl> class CEditorImpl final : public IEditorImpl <nl> private : <nl> <nl> void Clear ( ) ; <nl> - void CreateControlCache ( CImplItem const * const pParent ) ; <nl> + void CreateItemCache ( CImplItem const * const pParent ) ; <nl> CID GetId ( string const & name ) const ; <nl> <nl> - using ControlsCache = std : : map < CID , CImplItem * > ; <nl> + using ItemCache = std : : map < CID , CImplItem * > ; <nl> using ConnectionsMap = std : : map < CID , int > ; <nl> <nl> - CImplItem m_rootControl ; <nl> - ControlsCache m_controlsCache ; / / cache of the controls stored by id for faster access <nl> + CImplItem m_rootItem { " " , ACE_INVALID_ID , AUDIO_SYSTEM_INVALID_TYPE } ; <nl> + ItemCache m_itemCache ; / / cache of the items stored by id for faster access <nl> ConnectionsMap m_connectionsByID ; <nl> CImplSettings m_implSettings ; <nl> CryAudio : : SImplInfo m_implInfo ; <nl> deleted file mode 100644 <nl> index f179edf3c7 . . 0000000000 <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorSDLMixer / ImplControls . cpp <nl> ppp / dev / null <nl> <nl> - / / Copyright 2001 - 2016 Crytek GmbH / Crytek Group . All rights reserved . <nl> - <nl> - # include " StdAfx . h " <nl> - # include " ImplControls . h " <nl> - <nl> - namespace ACE <nl> - { <nl> - namespace SDLMixer <nl> - { <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - CImplControl : : CImplControl ( string const & name , CID const id , ItemType const type ) <nl> - : CImplItem ( name , id , type ) <nl> - { <nl> - } <nl> - } / / namespace SDLMixer <nl> - } / / namespace ACE <nl> deleted file mode 100644 <nl> index 72ae4d30b9 . . 0000000000 <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorSDLMixer / ImplControls . h <nl> ppp / dev / null <nl> <nl> - / / Copyright 2001 - 2016 Crytek GmbH / Crytek Group . All rights reserved . <nl> - <nl> - # pragma once <nl> - <nl> - # include < ImplItem . h > <nl> - # include " ImplTypes . h " <nl> - <nl> - namespace ACE <nl> - { <nl> - namespace SDLMixer <nl> - { <nl> - class CImplControl final : public CImplItem <nl> - { <nl> - public : <nl> - <nl> - CImplControl ( ) = default ; <nl> - CImplControl ( string const & name , CID const id , ItemType const type ) ; <nl> - } ; <nl> - } / / namespace SDLMixer <nl> - } / / namespace ACE <nl> new file mode 100644 <nl> index 0000000000 . . 04b11e1a83 <nl> mmm / dev / null <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorSDLMixer / ImplItem . cpp <nl> <nl> + / / Copyright 2001 - 2018 Crytek GmbH / Crytek Group . All rights reserved . <nl> + <nl> + # include " StdAfx . h " <nl> + # include " ImplItem . h " <nl> + <nl> + namespace ACE <nl> + { <nl> + namespace SDLMixer <nl> + { <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void CImplItem : : SetConnected ( bool const isConnected ) <nl> + { <nl> + if ( isConnected ) <nl> + { <nl> + m_flags | = EImplItemFlags : : IsConnected ; <nl> + } <nl> + else <nl> + { <nl> + m_flags & = ~ EImplItemFlags : : IsConnected ; <nl> + } <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void CImplItem : : AddChild ( CImplItem * const pChild ) <nl> + { <nl> + m_children . push_back ( pChild ) ; <nl> + pChild - > SetParent ( this ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void CImplItem : : Clear ( ) <nl> + { <nl> + m_children . clear ( ) ; <nl> + } <nl> + } / / namespace SDLMixer <nl> + } / / namespace ACE <nl> new file mode 100644 <nl> index 0000000000 . . 253a598cdc <nl> mmm / dev / null <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorSDLMixer / ImplItem . h <nl> <nl> + / / Copyright 2001 - 2018 Crytek GmbH / Crytek Group . All rights reserved . <nl> + <nl> + # pragma once <nl> + <nl> + # include < IImplItem . h > <nl> + # include " ImplTypes . h " <nl> + <nl> + namespace ACE <nl> + { <nl> + namespace SDLMixer <nl> + { <nl> + enum class EImplItemFlags <nl> + { <nl> + None = 0 , <nl> + IsPlaceHolder = BIT ( 0 ) , <nl> + IsConnected = BIT ( 1 ) , <nl> + IsContainer = BIT ( 2 ) , <nl> + } ; <nl> + CRY_CREATE_ENUM_FLAG_OPERATORS ( EImplItemFlags ) ; <nl> + <nl> + class CImplItem final : public IImplItem <nl> + { <nl> + public : <nl> + <nl> + explicit CImplItem ( <nl> + string const & name , <nl> + CID const id , <nl> + ItemType const type , <nl> + EImplItemFlags const flags = EImplItemFlags : : None , <nl> + string const & filePath = " " ) <nl> + : m_name ( name ) <nl> + , m_id ( id ) <nl> + , m_type ( type ) <nl> + , m_flags ( flags ) <nl> + , m_filePath ( filePath ) <nl> + , m_pParent ( nullptr ) <nl> + { } <nl> + <nl> + virtual ~ CImplItem ( ) override = default ; <nl> + <nl> + CImplItem ( ) = delete ; <nl> + <nl> + / / IImplItem <nl> + virtual CID GetId ( ) const override { return m_id ; } <nl> + virtual ItemType GetType ( ) const override { return m_type ; } <nl> + virtual string GetName ( ) const override { return m_name ; } <nl> + virtual string const & GetFilePath ( ) const override { return m_filePath ; } <nl> + virtual float GetRadius ( ) const override { return 0 . 0f ; } <nl> + <nl> + virtual size_t GetNumChildren ( ) const override { return m_children . size ( ) ; } <nl> + virtual IImplItem * GetChildAt ( size_t const index ) const override { return m_children [ index ] ; } <nl> + virtual IImplItem * GetParent ( ) const override { return m_pParent ; } <nl> + <nl> + virtual bool IsPlaceholder ( ) const override { return ( m_flags & EImplItemFlags : : IsPlaceHolder ) ! = 0 ; } <nl> + virtual bool IsLocalized ( ) const override { return false ; } <nl> + virtual bool IsConnected ( ) const override { return ( m_flags & EImplItemFlags : : IsConnected ) ! = 0 ; } <nl> + virtual bool IsContainer ( ) const override { return ( m_flags & EImplItemFlags : : IsContainer ) ! = 0 ; } <nl> + / / ~ IImplItem <nl> + <nl> + void SetConnected ( bool const isConnected ) ; <nl> + void AddChild ( CImplItem * const pChild ) ; <nl> + <nl> + void Clear ( ) ; <nl> + <nl> + private : <nl> + <nl> + void SetParent ( CImplItem * const pParent ) { m_pParent = pParent ; } <nl> + <nl> + CID const m_id ; <nl> + ItemType const m_type ; <nl> + string const m_name ; <nl> + string const m_filePath ; <nl> + std : : vector < CImplItem * > m_children ; <nl> + CImplItem * m_pParent ; <nl> + EImplItemFlags m_flags ; <nl> + } ; <nl> + } / / namespace SDLMixer <nl> + } / / namespace ACE <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorSDLMixer / ProjectLoader . cpp <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorSDLMixer / ProjectLoader . cpp <nl> <nl> - / / Copyright 2001 - 2016 Crytek GmbH / Crytek Group . All rights reserved . <nl> + / / Copyright 2001 - 2018 Crytek GmbH / Crytek Group . All rights reserved . <nl> <nl> # include " StdAfx . h " <nl> # include " ProjectLoader . h " <nl> void CProjectLoader : : LoadFolder ( string const & folderPath , CImplItem & parent ) <nl> if ( posExtension ! = string : : npos ) <nl> { <nl> if ( ( stricmp ( name . data ( ) + posExtension , " . mp3 " ) = = 0 ) | | <nl> - ( stricmp ( name . data ( ) + posExtension , " . ogg " ) = = 0 ) | | <nl> - ( stricmp ( name . data ( ) + posExtension , " . wav " ) = = 0 ) ) <nl> + ( stricmp ( name . data ( ) + posExtension , " . ogg " ) = = 0 ) | | <nl> + ( stricmp ( name . data ( ) + posExtension , " . wav " ) = = 0 ) ) <nl> { <nl> / / Create the event with the same name as the file <nl> CreateItem ( name , folderPath , EImpltemType : : Event , parent ) ; <nl> CImplItem * CProjectLoader : : CreateItem ( string const & name , string const & path , EI <nl> filePath + = ( path + CRY_NATIVE_PATH_SEPSTR + name ) ; <nl> } <nl> <nl> - CImplControl * const pControl = new CImplControl ( name , id , static_cast < ItemType > ( type ) ) ; <nl> - pControl - > SetFilePath ( filePath ) ; <nl> + EImplItemFlags const flags = type = = EImpltemType : : Folder ? EImplItemFlags : : IsContainer : EImplItemFlags : : None ; <nl> + auto const pImplItem = new CImplItem ( name , id , static_cast < ItemType > ( type ) , flags , filePath ) ; <nl> <nl> - if ( type = = EImpltemType : : Folder ) <nl> - { <nl> - pControl - > SetContainer ( true ) ; <nl> - } <nl> - <nl> - rootItem . AddChild ( pControl ) ; <nl> - return pControl ; <nl> + rootItem . AddChild ( pImplItem ) ; <nl> + return pImplItem ; <nl> } <nl> } / / namespace SDLMixer <nl> } / / namespace ACE <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorSDLMixer / ProjectLoader . h <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorSDLMixer / ProjectLoader . h <nl> <nl> - / / Copyright 2001 - 2016 Crytek GmbH / Crytek Group . All rights reserved . <nl> + / / Copyright 2001 - 2018 Crytek GmbH / Crytek Group . All rights reserved . <nl> <nl> # pragma once <nl> <nl> - # include " ImplControls . h " <nl> + # include " ImplItem . h " <nl> <nl> # include < CrySystem / XML / IXml . h > <nl> # include < SystemTypes . h > <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorWwise / CMakeLists . txt <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorWwise / CMakeLists . txt <nl> add_sources ( " EditorWwise_uber_0 . cpp " <nl> " EditorImpl . h " <nl> " ImplConnections . cpp " <nl> " ImplConnections . h " <nl> - " ImplControls . cpp " <nl> - " ImplControls . h " <nl> + " ImplItem . cpp " <nl> + " ImplItem . h " <nl> " ImplTypes . h " <nl> " main . cpp " <nl> " ProjectLoader . h " <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorWwise / EditorImpl . cpp <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorWwise / EditorImpl . cpp <nl> char const * TypeToTag ( EImpltemType const type ) <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - CImplItem * SearchForControl ( CImplItem * const pImplItem , string const & name , ItemType const type ) <nl> + CImplItem * SearchForItem ( CImplItem * const pImplItem , string const & name , ItemType const type ) <nl> { <nl> - CImplItem * pImplControl = nullptr ; <nl> + CImplItem * pSearchedImplItem = nullptr ; <nl> <nl> if ( ( pImplItem - > GetName ( ) = = name ) & & ( pImplItem - > GetType ( ) = = type ) ) <nl> { <nl> - pImplControl = pImplItem ; <nl> + pSearchedImplItem = pImplItem ; <nl> } <nl> else <nl> { <nl> - int const count = pImplItem - > ChildCount ( ) ; <nl> + int const count = pImplItem - > GetNumChildren ( ) ; <nl> <nl> for ( int i = 0 ; i < count ; + + i ) <nl> { <nl> - CImplItem * const pFoundImplControl = SearchForControl ( pImplItem - > GetChildAt ( i ) , name , type ) ; <nl> + CImplItem * const pFoundImplItem = SearchForItem ( static_cast < CImplItem * const > ( pImplItem - > GetChildAt ( i ) ) , name , type ) ; <nl> <nl> - if ( pFoundImplControl ! = nullptr ) <nl> + if ( pFoundImplItem ! = nullptr ) <nl> { <nl> - pImplControl = pFoundImplControl ; <nl> + pSearchedImplItem = pFoundImplItem ; <nl> break ; <nl> } <nl> } <nl> } <nl> <nl> - return pImplControl ; <nl> + return pSearchedImplItem ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> void CEditorImpl : : Reload ( bool const preserveConnectionStatus ) <nl> { <nl> Clear ( ) ; <nl> <nl> - CProjectLoader ( GetSettings ( ) - > GetProjectPath ( ) , GetSettings ( ) - > GetAssetsPath ( ) , m_rootControl , m_controlsCache ) ; <nl> + CProjectLoader ( GetSettings ( ) - > GetProjectPath ( ) , GetSettings ( ) - > GetAssetsPath ( ) , m_rootItem , m_itemCache ) ; <nl> <nl> if ( preserveConnectionStatus ) <nl> { <nl> void CEditorImpl : : Reload ( bool const preserveConnectionStatus ) <nl> { <nl> if ( connection . second > 0 ) <nl> { <nl> - CImplItem * const pImplControl = GetControl ( connection . first ) ; <nl> + auto const pImplItem = static_cast < CImplItem * const > ( GetImplItem ( connection . first ) ) ; <nl> <nl> - if ( pImplControl ! = nullptr ) <nl> + if ( pImplItem ! = nullptr ) <nl> { <nl> - pImplControl - > SetConnected ( true ) ; <nl> + pImplItem - > SetConnected ( true ) ; <nl> } <nl> } <nl> } <nl> void CEditorImpl : : Reload ( bool const preserveConnectionStatus ) <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - CImplItem * CEditorImpl : : GetControl ( CID const id ) const <nl> + IImplItem * CEditorImpl : : GetImplItem ( CID const id ) const <nl> { <nl> - CImplItem * pImplItem = nullptr ; <nl> + IImplItem * pImplItem = nullptr ; <nl> <nl> if ( id > = 0 ) <nl> { <nl> - pImplItem = stl : : find_in_map ( m_controlsCache , id , nullptr ) ; <nl> + pImplItem = stl : : find_in_map ( m_itemCache , id , nullptr ) ; <nl> } <nl> <nl> return pImplItem ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - char const * CEditorImpl : : GetTypeIcon ( CImplItem const * const pImplItem ) const <nl> + char const * CEditorImpl : : GetTypeIcon ( IImplItem const * const pImplItem ) const <nl> { <nl> char const * szIconPath = " icons : Dialogs / dialog - error . ico " ; <nl> auto const type = static_cast < EImpltemType > ( pImplItem - > GetType ( ) ) ; <nl> string const & CEditorImpl : : GetFolderName ( ) const <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - bool CEditorImpl : : IsTypeCompatible ( ESystemItemType const systemType , CImplItem const * const pImplItem ) const <nl> + bool CEditorImpl : : IsTypeCompatible ( ESystemItemType const systemType , IImplItem const * const pImplItem ) const <nl> { <nl> bool isCompatible = false ; <nl> auto const implType = static_cast < EImpltemType > ( pImplItem - > GetType ( ) ) ; <nl> bool CEditorImpl : : IsTypeCompatible ( ESystemItemType const systemType , CImplItem c <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - ESystemItemType CEditorImpl : : ImplTypeToSystemType ( CImplItem const * const pImplItem ) const <nl> + ESystemItemType CEditorImpl : : ImplTypeToSystemType ( IImplItem const * const pImplItem ) const <nl> { <nl> ESystemItemType systemType = ESystemItemType : : Invalid ; <nl> auto const itemType = static_cast < EImpltemType > ( pImplItem - > GetType ( ) ) ; <nl> ESystemItemType CEditorImpl : : ImplTypeToSystemType ( CImplItem const * const pImplIt <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - ConnectionPtr CEditorImpl : : CreateConnectionToControl ( ESystemItemType const controlType , CImplItem * const pImplItem ) <nl> + ConnectionPtr CEditorImpl : : CreateConnectionToControl ( ESystemItemType const controlType , IImplItem * const pImplItem ) <nl> { <nl> ConnectionPtr pConnection = nullptr ; <nl> <nl> ConnectionPtr CEditorImpl : : CreateConnectionFromXMLNode ( XmlNodeRef pNode , ESystem <nl> # endif / / USE_BACKWARDS_COMPATIBILITY <nl> bool const isLocalized = ( localizedAttribute . compareNoCase ( CryAudio : : Impl : : Wwise : : s_szTrueValue ) = = 0 ) ; <nl> <nl> - CImplItem * pImplControl = SearchForControl ( & m_rootControl , name , static_cast < ItemType > ( type ) ) ; <nl> + CImplItem * pImplItem = SearchForItem ( & m_rootItem , name , static_cast < ItemType > ( type ) ) ; <nl> <nl> - / / If control not found , create a placeholder . <nl> + / / If item not found , create a placeholder . <nl> / / We want to keep that connection even if it ' s not in the middleware . <nl> / / The user could be using the engine without the wwise project <nl> - if ( pImplControl = = nullptr ) <nl> + if ( pImplItem = = nullptr ) <nl> { <nl> - CID const id = GenerateID ( name , isLocalized , & m_rootControl ) ; <nl> - pImplControl = new CImplControl ( name , id , static_cast < ItemType > ( type ) ) ; <nl> - pImplControl - > SetLocalised ( isLocalized ) ; <nl> - pImplControl - > SetPlaceholder ( true ) ; <nl> + CID const id = GenerateID ( name , isLocalized , & m_rootItem ) ; <nl> + EImplItemFlags const flags = isLocalized ? ( EImplItemFlags : : IsPlaceHolder | EImplItemFlags : : IsLocalized ) : EImplItemFlags : : IsPlaceHolder ; <nl> <nl> - m_controlsCache [ id ] = pImplControl ; <nl> + pImplItem = new CImplItem ( name , id , static_cast < ItemType > ( type ) , flags ) ; <nl> + <nl> + m_itemCache [ id ] = pImplItem ; <nl> } <nl> <nl> / / If it ' s a switch we actually connect to one of the states within the switch <nl> ConnectionPtr CEditorImpl : : CreateConnectionFromXMLNode ( XmlNodeRef pNode , ESystem <nl> } <nl> # endif / / USE_BACKWARDS_COMPATIBILITY <nl> <nl> - CImplItem * pStateControl = nullptr ; <nl> - size_t const count = pImplControl - > ChildCount ( ) ; <nl> + CImplItem * pStateItem = nullptr ; <nl> + size_t const count = pImplItem - > GetNumChildren ( ) ; <nl> <nl> for ( size_t i = 0 ; i < count ; + + i ) <nl> { <nl> - CImplItem * const pChild = pImplControl - > GetChildAt ( i ) ; <nl> + auto const pChild = static_cast < CImplItem * const > ( pImplItem - > GetChildAt ( i ) ) ; <nl> <nl> if ( ( pChild ! = nullptr ) & & ( pChild - > GetName ( ) = = childName ) ) <nl> { <nl> - pStateControl = pChild ; <nl> + pStateItem = pChild ; <nl> } <nl> } <nl> <nl> - if ( pStateControl = = nullptr ) <nl> + if ( pStateItem = = nullptr ) <nl> { <nl> CID const id = GenerateID ( childName ) ; <nl> - pStateControl = new CImplControl ( childName , id , static_cast < ItemType > ( type = = EImpltemType : : SwitchGroup ? EImpltemType : : Switch : EImpltemType : : State ) ) ; <nl> - pStateControl - > SetLocalised ( false ) ; <nl> - pStateControl - > SetPlaceholder ( true ) ; <nl> - pImplControl - > AddChild ( pStateControl ) ; <nl> + pStateItem = new CImplItem ( childName , id , static_cast < ItemType > ( type = = EImpltemType : : SwitchGroup ? EImpltemType : : Switch : EImpltemType : : State ) , EImplItemFlags : : IsPlaceHolder ) ; <nl> + pImplItem - > AddChild ( pStateItem ) ; <nl> <nl> - m_controlsCache [ id ] = pStateControl ; <nl> + m_itemCache [ id ] = pStateItem ; <nl> } <nl> <nl> - pImplControl = pStateControl ; <nl> + pImplItem = pStateItem ; <nl> } <nl> } <nl> else <nl> ConnectionPtr CEditorImpl : : CreateConnectionFromXMLNode ( XmlNodeRef pNode , ESystem <nl> } <nl> } <nl> <nl> - if ( pImplControl ! = nullptr ) <nl> + if ( pImplItem ! = nullptr ) <nl> { <nl> if ( type = = EImpltemType : : Parameter ) <nl> { <nl> ConnectionPtr CEditorImpl : : CreateConnectionFromXMLNode ( XmlNodeRef pNode , ESystem <nl> case ESystemItemType : : Parameter : <nl> case ESystemItemType : : Environment : <nl> { <nl> - ParameterConnectionPtr const pConnection = std : : make_shared < CParameterConnection > ( pImplControl - > GetId ( ) ) ; <nl> + ParameterConnectionPtr const pConnection = std : : make_shared < CParameterConnection > ( pImplItem - > GetId ( ) ) ; <nl> float mult = pConnection - > GetMultiplier ( ) ; <nl> float shift = pConnection - > GetShift ( ) ; <nl> <nl> ConnectionPtr CEditorImpl : : CreateConnectionFromXMLNode ( XmlNodeRef pNode , ESystem <nl> break ; <nl> case ESystemItemType : : State : <nl> { <nl> - StateConnectionPtr const pConnection = std : : make_shared < CStateToParameterConnection > ( pImplControl - > GetId ( ) ) ; <nl> + StateConnectionPtr const pConnection = std : : make_shared < CStateToParameterConnection > ( pImplItem - > GetId ( ) ) ; <nl> float value = pConnection - > GetValue ( ) ; <nl> <nl> pNode - > getAttr ( CryAudio : : Impl : : Wwise : : s_szValueAttribute , value ) ; <nl> ConnectionPtr CEditorImpl : : CreateConnectionFromXMLNode ( XmlNodeRef pNode , ESystem <nl> } <nl> break ; <nl> default : <nl> - pConnectionPtr = std : : make_shared < CImplConnection > ( pImplControl - > GetId ( ) ) ; <nl> + pConnectionPtr = std : : make_shared < CImplConnection > ( pImplItem - > GetId ( ) ) ; <nl> break ; <nl> } <nl> } <nl> else <nl> { <nl> - pConnectionPtr = std : : make_shared < CImplConnection > ( pImplControl - > GetId ( ) ) ; <nl> + pConnectionPtr = std : : make_shared < CImplConnection > ( pImplItem - > GetId ( ) ) ; <nl> } <nl> } <nl> } <nl> XmlNodeRef CEditorImpl : : CreateXMLNodeFromConnection ( ConnectionPtr const pConnect <nl> { <nl> XmlNodeRef pNode = nullptr ; <nl> <nl> - CImplItem const * const pImplControl = GetControl ( pConnection - > GetID ( ) ) ; <nl> + auto const pImplItem = static_cast < CImplItem const * const > ( GetImplItem ( pConnection - > GetID ( ) ) ) ; <nl> <nl> - if ( pImplControl ! = nullptr ) <nl> + if ( pImplItem ! = nullptr ) <nl> { <nl> - auto const itemType = static_cast < EImpltemType > ( pImplControl - > GetType ( ) ) ; <nl> + auto const itemType = static_cast < EImpltemType > ( pImplItem - > GetType ( ) ) ; <nl> <nl> - switch ( static_cast < EImpltemType > ( pImplControl - > GetType ( ) ) ) <nl> + switch ( static_cast < EImpltemType > ( pImplItem - > GetType ( ) ) ) <nl> { <nl> case EImpltemType : : Switch : <nl> case EImpltemType : : SwitchGroup : <nl> case EImpltemType : : State : <nl> case EImpltemType : : StateGroup : <nl> { <nl> - CImplItem const * const pParent = pImplControl - > GetParent ( ) ; <nl> + IImplItem const * const pParent = pImplItem - > GetParent ( ) ; <nl> <nl> if ( pParent ! = nullptr ) <nl> { <nl> XmlNodeRef CEditorImpl : : CreateXMLNodeFromConnection ( ConnectionPtr const pConnect <nl> pSwitchNode - > setAttr ( CryAudio : : s_szNameAttribute , pParent - > GetName ( ) ) ; <nl> <nl> XmlNodeRef const pStateNode = pSwitchNode - > createNode ( CryAudio : : Impl : : Wwise : : s_szValueTag ) ; <nl> - pStateNode - > setAttr ( CryAudio : : s_szNameAttribute , pImplControl - > GetName ( ) ) ; <nl> + pStateNode - > setAttr ( CryAudio : : s_szNameAttribute , pImplItem - > GetName ( ) ) ; <nl> pSwitchNode - > addChild ( pStateNode ) ; <nl> <nl> pNode = pSwitchNode ; <nl> XmlNodeRef CEditorImpl : : CreateXMLNodeFromConnection ( ConnectionPtr const pConnect <nl> { <nl> XmlNodeRef pConnectionNode ; <nl> pConnectionNode = GetISystem ( ) - > CreateXmlNode ( TypeToTag ( itemType ) ) ; <nl> - pConnectionNode - > setAttr ( CryAudio : : s_szNameAttribute , pImplControl - > GetName ( ) ) ; <nl> + pConnectionNode - > setAttr ( CryAudio : : s_szNameAttribute , pImplItem - > GetName ( ) ) ; <nl> <nl> if ( ( controlType = = ESystemItemType : : Parameter ) | | ( controlType = = ESystemItemType : : Environment ) ) <nl> { <nl> XmlNodeRef CEditorImpl : : CreateXMLNodeFromConnection ( ConnectionPtr const pConnect <nl> { <nl> XmlNodeRef pConnectionNode ; <nl> pConnectionNode = GetISystem ( ) - > CreateXmlNode ( TypeToTag ( itemType ) ) ; <nl> - pConnectionNode - > setAttr ( CryAudio : : s_szNameAttribute , pImplControl - > GetName ( ) ) ; <nl> + pConnectionNode - > setAttr ( CryAudio : : s_szNameAttribute , pImplItem - > GetName ( ) ) ; <nl> pNode = pConnectionNode ; <nl> } <nl> break ; <nl> XmlNodeRef CEditorImpl : : CreateXMLNodeFromConnection ( ConnectionPtr const pConnect <nl> { <nl> XmlNodeRef pConnectionNode ; <nl> pConnectionNode = GetISystem ( ) - > CreateXmlNode ( TypeToTag ( itemType ) ) ; <nl> - pConnectionNode - > setAttr ( CryAudio : : s_szNameAttribute , pImplControl - > GetName ( ) ) ; <nl> + pConnectionNode - > setAttr ( CryAudio : : s_szNameAttribute , pImplItem - > GetName ( ) ) ; <nl> pNode = pConnectionNode ; <nl> } <nl> break ; <nl> case EImpltemType : : SoundBank : <nl> { <nl> XmlNodeRef pConnectionNode = GetISystem ( ) - > CreateXmlNode ( TypeToTag ( itemType ) ) ; <nl> - pConnectionNode - > setAttr ( CryAudio : : s_szNameAttribute , pImplControl - > GetName ( ) ) ; <nl> + pConnectionNode - > setAttr ( CryAudio : : s_szNameAttribute , pImplItem - > GetName ( ) ) ; <nl> <nl> - if ( pImplControl - > IsLocalised ( ) ) <nl> + if ( pImplItem - > IsLocalized ( ) ) <nl> { <nl> pConnectionNode - > setAttr ( CryAudio : : Impl : : Wwise : : s_szLocalizedAttribute , CryAudio : : Impl : : Wwise : : s_szTrueValue ) ; <nl> } <nl> XmlNodeRef CEditorImpl : : CreateXMLNodeFromConnection ( ConnectionPtr const pConnect <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> void CEditorImpl : : EnableConnection ( ConnectionPtr const pConnection ) <nl> { <nl> - CImplItem * const pImplControl = GetControl ( pConnection - > GetID ( ) ) ; <nl> + auto const pImplItem = static_cast < CImplItem * const > ( GetImplItem ( pConnection - > GetID ( ) ) ) ; <nl> <nl> - if ( pImplControl ! = nullptr ) <nl> + if ( pImplItem ! = nullptr ) <nl> { <nl> - + + m_connectionsByID [ pImplControl - > GetId ( ) ] ; <nl> - pImplControl - > SetConnected ( true ) ; <nl> + + + m_connectionsByID [ pImplItem - > GetId ( ) ] ; <nl> + pImplItem - > SetConnected ( true ) ; <nl> } <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> void CEditorImpl : : DisableConnection ( ConnectionPtr const pConnection ) <nl> { <nl> - CImplItem * const pImplControl = GetControl ( pConnection - > GetID ( ) ) ; <nl> + auto const pImplItem = static_cast < CImplItem * const > ( GetImplItem ( pConnection - > GetID ( ) ) ) ; <nl> <nl> - if ( pImplControl ! = nullptr ) <nl> + if ( pImplItem ! = nullptr ) <nl> { <nl> - int connectionCount = m_connectionsByID [ pImplControl - > GetId ( ) ] - 1 ; <nl> + int connectionCount = m_connectionsByID [ pImplItem - > GetId ( ) ] - 1 ; <nl> <nl> if ( connectionCount < = 0 ) <nl> { <nl> connectionCount = 0 ; <nl> - pImplControl - > SetConnected ( false ) ; <nl> + pImplItem - > SetConnected ( false ) ; <nl> } <nl> <nl> - m_connectionsByID [ pImplControl - > GetId ( ) ] = connectionCount ; <nl> + m_connectionsByID [ pImplItem - > GetId ( ) ] = connectionCount ; <nl> } <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> void CEditorImpl : : Clear ( ) <nl> { <nl> - / / Delete all the controls <nl> - for ( auto const & controlPair : m_controlsCache ) <nl> + / / Delete all the items <nl> + for ( auto const & itemPair : m_itemCache ) <nl> { <nl> - CImplItem const * const pImplControl = controlPair . second ; <nl> + CImplItem const * const pImplItem = itemPair . second ; <nl> <nl> - if ( pImplControl ! = nullptr ) <nl> + if ( pImplItem ! = nullptr ) <nl> { <nl> - delete pImplControl ; <nl> + delete pImplItem ; <nl> } <nl> } <nl> <nl> - m_controlsCache . clear ( ) ; <nl> + m_itemCache . clear ( ) ; <nl> <nl> - / / Clean up the root control <nl> - m_rootControl = CImplItem ( ) ; <nl> + / / Clean up the root item <nl> + m_rootItem . Clear ( ) ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> CID CEditorImpl : : GenerateID ( string const & fullPathName ) const <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - CID CEditorImpl : : GenerateID ( string const & controlName , bool isLocalized , CImplItem * pParent ) const <nl> + CID CEditorImpl : : GenerateID ( string const & name , bool isLocalized , CImplItem * pParent ) const <nl> { <nl> - string pathName = ( pParent ! = nullptr & & ! pParent - > GetName ( ) . empty ( ) ) ? pParent - > GetName ( ) + CRY_NATIVE_PATH_SEPSTR + controlName : controlName ; <nl> + string pathName = ( pParent ! = nullptr & & ! pParent - > GetName ( ) . empty ( ) ) ? pParent - > GetName ( ) + CRY_NATIVE_PATH_SEPSTR + name : name ; <nl> <nl> if ( isLocalized ) <nl> { <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorWwise / EditorImpl . h <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorWwise / EditorImpl . h <nl> <nl> <nl> # include < IEditorImpl . h > <nl> <nl> - # include " ImplControls . h " <nl> + # include " ImplItem . h " <nl> <nl> # include < CryAudio / IAudioSystem . h > <nl> # include < CrySystem / File / CryFile . h > <nl> class CImplSettings final : public IImplSettings <nl> CImplSettings ( ) ; <nl> <nl> / / IImplSettings <nl> - virtual char const * GetAssetsPath ( ) const override { return m_assetsPath . c_str ( ) ; } <nl> - virtual char const * GetProjectPath ( ) const override { return m_projectPath . c_str ( ) ; } <nl> + virtual char const * GetAssetsPath ( ) const override { return m_assetsPath . c_str ( ) ; } <nl> + virtual char const * GetProjectPath ( ) const override { return m_projectPath . c_str ( ) ; } <nl> virtual void SetProjectPath ( char const * szPath ) override ; <nl> - virtual bool IsProjectPathEditable ( ) const override { return true ; } <nl> + virtual bool SupportsProjects ( ) const override { return true ; } <nl> / / ~ IImplSettings <nl> <nl> void Serialize ( Serialization : : IArchive & ar ) ; <nl> class CEditorImpl final : public IEditorImpl <nl> <nl> / / IEditorImpl <nl> virtual void Reload ( bool const preserveConnectionStatus = true ) override ; <nl> - virtual CImplItem * GetRoot ( ) override { return & m_rootControl ; } <nl> - virtual CImplItem * GetControl ( CID const id ) const override ; <nl> - virtual char const * GetTypeIcon ( CImplItem const * const pImplItem ) const override ; <nl> + virtual IImplItem * GetRoot ( ) override { return & m_rootItem ; } <nl> + virtual IImplItem * GetImplItem ( CID const id ) const override ; <nl> + virtual char const * GetTypeIcon ( IImplItem const * const pImplItem ) const override ; <nl> virtual string const & GetName ( ) const override ; <nl> virtual string const & GetFolderName ( ) const override ; <nl> virtual IImplSettings * GetSettings ( ) override { return & m_implSettings ; } <nl> virtual bool IsSystemTypeSupported ( ESystemItemType const systemType ) const override { return true ; } <nl> - virtual bool IsTypeCompatible ( ESystemItemType const systemType , CImplItem const * const pImplItem ) const override ; <nl> - virtual ESystemItemType ImplTypeToSystemType ( CImplItem const * const pImplItem ) const override ; <nl> - virtual ConnectionPtr CreateConnectionToControl ( ESystemItemType const controlType , CImplItem * const pImplItem ) override ; <nl> + virtual bool IsTypeCompatible ( ESystemItemType const systemType , IImplItem const * const pImplItem ) const override ; <nl> + virtual ESystemItemType ImplTypeToSystemType ( IImplItem const * const pImplItem ) const override ; <nl> + virtual ConnectionPtr CreateConnectionToControl ( ESystemItemType const controlType , IImplItem * const pImplItem ) override ; <nl> virtual ConnectionPtr CreateConnectionFromXMLNode ( XmlNodeRef pNode , ESystemItemType const controlType ) override ; <nl> virtual XmlNodeRef CreateXMLNodeFromConnection ( ConnectionPtr const pConnection , ESystemItemType const controlType ) override ; <nl> virtual void EnableConnection ( ConnectionPtr const pConnection ) override ; <nl> class CEditorImpl final : public IEditorImpl <nl> <nl> void Clear ( ) ; <nl> <nl> - / / Generates the ID of the control given its full path name . <nl> - CID GenerateID ( string const & controlName , bool isLocalized , CImplItem * pParent ) const ; <nl> + / / Generates the ID of the item given its full path name . <nl> + CID GenerateID ( string const & name , bool isLocalized , CImplItem * pParent ) const ; <nl> / / Convenience function to form the full path name . <nl> - / / Controls can have the same name if they ' re under different parents so knowledge of the parent name is needed . <nl> - / / Localized controls live in different areas of disk so we also need to know if its localized . <nl> + / / Items can have the same name if they ' re under different parents so knowledge of the parent name is needed . <nl> + / / Localized items live in different areas of disk so we also need to know if its localized . <nl> CID GenerateID ( string const & fullPathName ) const ; <nl> <nl> - using ControlsCache = std : : map < CID , CImplItem * > ; <nl> using ConnectionsMap = std : : map < CID , int > ; <nl> <nl> - CImplItem m_rootControl ; <nl> - ControlsCache m_controlsCache ; / / cache of the controls stored by id for faster access <nl> + CImplItem m_rootItem { " " , ACE_INVALID_ID , AUDIO_SYSTEM_INVALID_TYPE } ; <nl> + ItemCache m_itemCache ; / / cache of the items stored by id for faster access <nl> ConnectionsMap m_connectionsByID ; <nl> CImplSettings m_implSettings ; <nl> CryAudio : : SImplInfo m_implInfo ; <nl> deleted file mode 100644 <nl> index f7106ce189 . . 0000000000 <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorWwise / ImplControls . cpp <nl> ppp / dev / null <nl> <nl> - / / Copyright 2001 - 2016 Crytek GmbH / Crytek Group . All rights reserved . <nl> - <nl> - # include " StdAfx . h " <nl> - # include " ImplControls . h " <nl> - <nl> - namespace ACE <nl> - { <nl> - namespace Wwise <nl> - { <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - CImplControl : : CImplControl ( string const & name , CID const id , ItemType const type ) <nl> - : CImplItem ( name , id , type ) <nl> - { <nl> - } <nl> - } / / namespace Wwise <nl> - } / / namespace ACE <nl> deleted file mode 100644 <nl> index 9c67b5ee53 . . 0000000000 <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorWwise / ImplControls . h <nl> ppp / dev / null <nl> <nl> - / / Copyright 2001 - 2018 Crytek GmbH / Crytek Group . All rights reserved . <nl> - <nl> - # pragma once <nl> - <nl> - # include < ImplItem . h > <nl> - # include " ImplTypes . h " <nl> - <nl> - namespace ACE <nl> - { <nl> - namespace Wwise <nl> - { <nl> - using ControlsCache = std : : map < CID , CImplItem * > ; <nl> - <nl> - class CImplControl final : public CImplItem <nl> - { <nl> - public : <nl> - <nl> - CImplControl ( ) = default ; <nl> - CImplControl ( string const & name , CID const id , ItemType const type ) ; <nl> - } ; <nl> - } / / namespace Wwise <nl> - } / / namespace ACE <nl> new file mode 100644 <nl> index 0000000000 . . 84247fcddc <nl> mmm / dev / null <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorWwise / ImplItem . cpp <nl> <nl> + / / Copyright 2001 - 2018 Crytek GmbH / Crytek Group . All rights reserved . <nl> + <nl> + # include " StdAfx . h " <nl> + # include " ImplItem . h " <nl> + <nl> + namespace ACE <nl> + { <nl> + namespace Wwise <nl> + { <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void CImplItem : : SetConnected ( bool const isConnected ) <nl> + { <nl> + if ( isConnected ) <nl> + { <nl> + m_flags | = EImplItemFlags : : IsConnected ; <nl> + } <nl> + else <nl> + { <nl> + m_flags & = ~ EImplItemFlags : : IsConnected ; <nl> + } <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void CImplItem : : AddChild ( CImplItem * const pChild ) <nl> + { <nl> + m_children . push_back ( pChild ) ; <nl> + pChild - > SetParent ( this ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void CImplItem : : RemoveChild ( CImplItem * const pChild ) <nl> + { <nl> + stl : : find_and_erase ( m_children , pChild ) ; <nl> + pChild - > SetParent ( nullptr ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void CImplItem : : Clear ( ) <nl> + { <nl> + m_children . clear ( ) ; <nl> + } <nl> + } / / namespace Wwise <nl> + } / / namespace ACE <nl> new file mode 100644 <nl> index 0000000000 . . f56e4db1c5 <nl> mmm / dev / null <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorWwise / ImplItem . h <nl> <nl> + / / Copyright 2001 - 2018 Crytek GmbH / Crytek Group . All rights reserved . <nl> + <nl> + # pragma once <nl> + <nl> + # include < IImplItem . h > <nl> + # include " ImplTypes . h " <nl> + <nl> + namespace ACE <nl> + { <nl> + namespace Wwise <nl> + { <nl> + enum class EImplItemFlags <nl> + { <nl> + None = 0 , <nl> + IsPlaceHolder = BIT ( 0 ) , <nl> + IsLocalized = BIT ( 1 ) , <nl> + IsConnected = BIT ( 2 ) , <nl> + IsContainer = BIT ( 3 ) , <nl> + } ; <nl> + CRY_CREATE_ENUM_FLAG_OPERATORS ( EImplItemFlags ) ; <nl> + <nl> + class CImplItem final : public IImplItem <nl> + { <nl> + public : <nl> + <nl> + explicit CImplItem ( <nl> + string const & name , <nl> + CID const id , <nl> + ItemType const type , <nl> + EImplItemFlags const flags = EImplItemFlags : : None , <nl> + string const & filePath = " " ) <nl> + : m_name ( name ) <nl> + , m_id ( id ) <nl> + , m_type ( type ) <nl> + , m_flags ( flags ) <nl> + , m_filePath ( filePath ) <nl> + , m_pParent ( nullptr ) <nl> + , m_radius ( 0 . 0f ) <nl> + { } <nl> + <nl> + virtual ~ CImplItem ( ) override = default ; <nl> + <nl> + CImplItem ( ) = delete ; <nl> + <nl> + / / IImplItem <nl> + virtual CID GetId ( ) const override { return m_id ; } <nl> + virtual ItemType GetType ( ) const override { return m_type ; } <nl> + virtual string GetName ( ) const override { return m_name ; } <nl> + virtual string const & GetFilePath ( ) const override { return m_filePath ; } <nl> + virtual float GetRadius ( ) const override { return m_radius ; } <nl> + <nl> + virtual size_t GetNumChildren ( ) const override { return m_children . size ( ) ; } <nl> + virtual IImplItem * GetChildAt ( size_t const index ) const override { return m_children [ index ] ; } <nl> + virtual IImplItem * GetParent ( ) const override { return m_pParent ; } <nl> + <nl> + virtual bool IsPlaceholder ( ) const override { return ( m_flags & EImplItemFlags : : IsPlaceHolder ) ! = 0 ; } <nl> + virtual bool IsLocalized ( ) const override { return ( m_flags & EImplItemFlags : : IsLocalized ) ! = 0 ; } <nl> + virtual bool IsConnected ( ) const override { return ( m_flags & EImplItemFlags : : IsConnected ) ! = 0 ; } <nl> + virtual bool IsContainer ( ) const override { return ( m_flags & EImplItemFlags : : IsContainer ) ! = 0 ; } <nl> + / / ~ IImplItem <nl> + <nl> + void SetConnected ( bool const isConnected ) ; <nl> + void SetRadius ( float const radius ) { m_radius = radius ; } <nl> + <nl> + void AddChild ( CImplItem * const pChild ) ; <nl> + void RemoveChild ( CImplItem * const pChild ) ; <nl> + <nl> + void Clear ( ) ; <nl> + <nl> + private : <nl> + <nl> + void SetParent ( CImplItem * const pParent ) { m_pParent = pParent ; } <nl> + <nl> + CID const m_id ; <nl> + ItemType const m_type ; <nl> + string const m_name ; <nl> + string const m_filePath ; <nl> + std : : vector < CImplItem * > m_children ; <nl> + CImplItem * m_pParent ; <nl> + float m_radius ; <nl> + EImplItemFlags m_flags ; <nl> + } ; <nl> + <nl> + using ItemCache = std : : map < CID , CImplItem * > ; <nl> + } / / namespace Wwise <nl> + } / / namespace ACE <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorWwise / ImplTypes . h <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorWwise / ImplTypes . h <nl> <nl> - / / Copyright 2001 - 2016 Crytek GmbH / Crytek Group . All rights reserved . <nl> + / / Copyright 2001 - 2018 Crytek GmbH / Crytek Group . All rights reserved . <nl> <nl> # pragma once <nl> <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorWwise / ProjectLoader . cpp <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorWwise / ProjectLoader . cpp <nl> string const g_eventsFolderName = " Events " ; <nl> string const g_environmentsFolderName = " Master - Mixer Hierarchy " ; <nl> string const g_soundBanksFolderName = " SoundBanks " ; <nl> string const g_soundBanksInfoFileName = " SoundbanksInfo . xml " ; <nl> + CID g_soundBanksFolderId = ACE_INVALID_ID ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> EImpltemType TagToItemType ( string const & tag ) <nl> EImpltemType TagToItemType ( string const & tag ) <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - string BuildPath ( CImplItem const * const pImplItem ) <nl> + string BuildPath ( IImplItem const * const pImplItem ) <nl> { <nl> string buildPath = " " ; <nl> <nl> if ( pImplItem ! = nullptr ) <nl> { <nl> - CImplItem const * const pParent = pImplItem - > GetParent ( ) ; <nl> + IImplItem const * const pParent = pImplItem - > GetParent ( ) ; <nl> <nl> if ( pParent ! = nullptr ) <nl> { <nl> string BuildPath ( CImplItem const * const pImplItem ) <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - CProjectLoader : : CProjectLoader ( string const & projectPath , string const & soundbanksPath , CImplItem & root , ControlsCache & controlsCache ) <nl> - : m_root ( root ) <nl> - , m_controlsCache ( controlsCache ) <nl> + CProjectLoader : : CProjectLoader ( string const & projectPath , string const & soundbanksPath , CImplItem & rootItem , ItemCache & itemCache ) <nl> + : m_rootItem ( rootItem ) <nl> + , m_itemCache ( itemCache ) <nl> , m_projectPath ( projectPath ) <nl> { <nl> LoadEventsMetadata ( soundbanksPath ) ; <nl> CProjectLoader : : CProjectLoader ( string const & projectPath , string const & soundban <nl> BuildFileCache ( g_eventsFolderName ) ; <nl> BuildFileCache ( g_environmentsFolderName ) ; <nl> <nl> - LoadFolder ( " " , g_parametersFolderName , m_root ) ; <nl> - LoadFolder ( " " , g_statesFolderName , m_root ) ; <nl> - LoadFolder ( " " , g_switchesFolderName , m_root ) ; <nl> - LoadFolder ( " " , g_eventsFolderName , m_root ) ; <nl> - LoadFolder ( " " , g_environmentsFolderName , m_root ) ; <nl> + LoadFolder ( " " , g_parametersFolderName , m_rootItem ) ; <nl> + LoadFolder ( " " , g_statesFolderName , m_rootItem ) ; <nl> + LoadFolder ( " " , g_switchesFolderName , m_rootItem ) ; <nl> + LoadFolder ( " " , g_eventsFolderName , m_rootItem ) ; <nl> + LoadFolder ( " " , g_environmentsFolderName , m_rootItem ) ; <nl> <nl> - CImplItem * const pSoundBanks = CreateItem ( g_soundBanksFolderName , EImpltemType : : PhysicalFolder , m_root ) ; <nl> + CImplItem * const pSoundBanks = CreateItem ( g_soundBanksFolderName , EImpltemType : : PhysicalFolder , m_rootItem ) ; <nl> + g_soundBanksFolderId = pSoundBanks - > GetId ( ) ; <nl> LoadSoundBanks ( soundbanksPath , false , * pSoundBanks ) ; <nl> <nl> char const * const szLanguage = gEnv - > pSystem - > GetLocalizationManager ( ) - > GetLanguage ( ) ; <nl> CProjectLoader : : CProjectLoader ( string const & projectPath , string const & soundban <nl> CryAudio : : s_szAssetsFolderName ; <nl> LoadSoundBanks ( locaFolder , true , * pSoundBanks ) ; <nl> <nl> - if ( pSoundBanks - > ChildCount ( ) = = 0 ) <nl> + if ( pSoundBanks - > GetNumChildren ( ) = = 0 ) <nl> { <nl> - m_root . RemoveChild ( pSoundBanks ) ; <nl> - ControlsCache : : const_iterator const it ( m_controlsCache . find ( pSoundBanks - > GetId ( ) ) ) ; <nl> + m_rootItem . RemoveChild ( pSoundBanks ) ; <nl> + ItemCache : : const_iterator const it ( m_itemCache . find ( pSoundBanks - > GetId ( ) ) ) ; <nl> <nl> - if ( it ! = m_controlsCache . end ( ) ) <nl> + if ( it ! = m_itemCache . end ( ) ) <nl> { <nl> - m_controlsCache . erase ( it ) ; <nl> + m_itemCache . erase ( it ) ; <nl> } <nl> <nl> delete pSoundBanks ; <nl> void CProjectLoader : : LoadSoundBanks ( string const & folderPath , bool const isLocal <nl> { <nl> string const fullname = folderPath + CRY_NATIVE_PATH_SEPSTR + name ; <nl> CID const id = CryAudio : : StringToId ( fullname ) ; <nl> - CImplItem * const pImplControl = stl : : find_in_map ( m_controlsCache , id , nullptr ) ; <nl> + CImplItem * const pImplItem = stl : : find_in_map ( m_itemCache , id , nullptr ) ; <nl> <nl> - if ( pImplControl = = nullptr ) <nl> + if ( pImplItem = = nullptr ) <nl> { <nl> - CImplControl * const pSoundBank = new CImplControl ( name , id , static_cast < ItemType > ( EImpltemType : : SoundBank ) ) ; <nl> - parent . AddChild ( pSoundBank ) ; <nl> - pSoundBank - > SetLocalised ( isLocalized ) ; <nl> + EImplItemFlags flags = EImplItemFlags : : None ; <nl> + string filePath ; <nl> <nl> if ( isLocalized ) <nl> { <nl> - pSoundBank - > SetFilePath ( PathUtil : : GetGameFolder ( ) + CRY_NATIVE_PATH_SEPSTR + fullname ) ; <nl> + flags = EImplItemFlags : : IsLocalized ; <nl> + filePath = PathUtil : : GetGameFolder ( ) + CRY_NATIVE_PATH_SEPSTR + fullname ; <nl> } <nl> else <nl> { <nl> - pSoundBank - > SetFilePath ( fullname ) ; <nl> + filePath = fullname ; <nl> } <nl> <nl> - m_controlsCache [ id ] = pSoundBank ; <nl> + auto const pSoundBank = new CImplItem ( name , id , static_cast < ItemType > ( EImpltemType : : SoundBank ) , flags , filePath ) ; <nl> + parent . AddChild ( pSoundBank ) ; <nl> + m_itemCache [ id ] = pSoundBank ; <nl> } <nl> } <nl> } <nl> void CProjectLoader : : LoadWorkUnitFile ( const string & filePath , CImplItem & parent ) <nl> } <nl> } <nl> <nl> - / / Each files starts with the type of controls and then the WorkUnit <nl> + / / Each files starts with the type of item and then the WorkUnit <nl> int const childCount = pRoot - > getChildCount ( ) ; <nl> <nl> for ( int i = 0 ; i < childCount ; + + i ) <nl> void CProjectLoader : : LoadXml ( XmlNodeRef const pRoot , CImplItem & parent ) <nl> { <nl> if ( pRoot ! = nullptr ) <nl> { <nl> - CImplItem * pControl = & parent ; <nl> + CImplItem * pImplItem = & parent ; <nl> EImpltemType const type = TagToItemType ( pRoot - > getTag ( ) ) ; <nl> <nl> if ( type ! = EImpltemType : : Invalid ) <nl> void CProjectLoader : : LoadXml ( XmlNodeRef const pRoot , CImplItem & parent ) <nl> <nl> if ( it ! = m_items . end ( ) ) <nl> { <nl> - pControl = it - > second ; <nl> + pImplItem = it - > second ; <nl> } <nl> else <nl> { <nl> - pControl = CreateItem ( name , type , parent ) ; <nl> - m_items [ itemId ] = pControl ; <nl> + pImplItem = CreateItem ( name , type , parent ) ; <nl> + m_items [ itemId ] = pImplItem ; <nl> } <nl> } <nl> <nl> void CProjectLoader : : LoadXml ( XmlNodeRef const pRoot , CImplItem & parent ) <nl> int const childCount = pChildren - > getChildCount ( ) ; <nl> for ( int i = 0 ; i < childCount ; + + i ) <nl> { <nl> - LoadXml ( pChildren - > getChild ( i ) , * pControl ) ; <nl> + LoadXml ( pChildren - > getChild ( i ) , * pImplItem ) ; <nl> } <nl> } <nl> } <nl> CImplItem * CProjectLoader : : CreateItem ( const string & name , EImpltemType const typ <nl> string const path = BuildPath ( & parent ) ; <nl> string const fullPathName = path + CRY_NATIVE_PATH_SEPSTR + name ; <nl> <nl> - / / The id is always the path of the control from the root of the wwise project <nl> + / / The id is always the path of the item from the root of the wwise project <nl> CID const id = CryAudio : : StringToId ( fullPathName ) ; <nl> <nl> - CImplItem * pImplControl = stl : : find_in_map ( m_controlsCache , id , nullptr ) ; <nl> + CImplItem * pImplItem = stl : : find_in_map ( m_itemCache , id , nullptr ) ; <nl> <nl> - if ( pImplControl = = nullptr ) <nl> + if ( pImplItem = = nullptr ) <nl> { <nl> - pImplControl = new CImplControl ( name , id , static_cast < ItemType > ( type ) ) ; <nl> - <nl> - if ( type = = EImpltemType : : Event ) <nl> - { <nl> - pImplControl - > SetRadius ( m_eventsInfoMap [ CryAudio : : StringToId ( name . c_str ( ) ) ] . maxRadius ) ; <nl> - } <nl> - else if ( type = = EImpltemType : : WorkUnit ) <nl> - { <nl> - pImplControl - > SetContainer ( true ) ; <nl> - pImplControl - > SetFilePath ( m_projectPath + fullPathName + " . wwu " ) ; <nl> - } <nl> - else if ( type = = EImpltemType : : PhysicalFolder ) <nl> + switch ( type ) <nl> { <nl> - pImplControl - > SetContainer ( true ) ; <nl> - <nl> - if ( name ! = g_soundBanksFolderName ) <nl> + case EImpltemType : : WorkUnit : <nl> { <nl> - pImplControl - > SetFilePath ( m_projectPath + fullPathName ) ; <nl> + pImplItem = new CImplItem ( name , id , static_cast < ItemType > ( type ) , EImplItemFlags : : IsContainer , m_projectPath + fullPathName + " . wwu " ) ; <nl> } <nl> - } <nl> - else if ( ( type = = EImpltemType : : VirtualFolder ) | | ( type = = EImpltemType : : SwitchGroup ) | | ( type = = EImpltemType : : StateGroup ) ) <nl> - { <nl> - pImplControl - > SetContainer ( true ) ; <nl> + break ; <nl> + case EImpltemType : : PhysicalFolder : <nl> + { <nl> + if ( id ! = g_soundBanksFolderId ) <nl> + { <nl> + pImplItem = new CImplItem ( name , id , static_cast < ItemType > ( type ) , EImplItemFlags : : IsContainer , m_projectPath + fullPathName ) ; <nl> + } <nl> + else <nl> + { <nl> + pImplItem = new CImplItem ( name , id , static_cast < ItemType > ( type ) , EImplItemFlags : : IsContainer ) ; <nl> + } <nl> + } <nl> + break ; <nl> + case EImpltemType : : VirtualFolder : <nl> + case EImpltemType : : SwitchGroup : <nl> + case EImpltemType : : StateGroup : <nl> + { <nl> + pImplItem = new CImplItem ( name , id , static_cast < ItemType > ( type ) , EImplItemFlags : : IsContainer ) ; <nl> + } <nl> + break ; <nl> + default : <nl> + { <nl> + pImplItem = new CImplItem ( name , id , static_cast < ItemType > ( type ) ) ; <nl> + <nl> + if ( type = = EImpltemType : : Event ) <nl> + { <nl> + pImplItem - > SetRadius ( m_eventsInfoMap [ CryAudio : : StringToId ( name . c_str ( ) ) ] . maxRadius ) ; <nl> + } <nl> + } <nl> + break ; <nl> } <nl> <nl> - parent . AddChild ( pImplControl ) ; <nl> - m_controlsCache [ id ] = pImplControl ; <nl> + parent . AddChild ( pImplItem ) ; <nl> + m_itemCache [ id ] = pImplItem ; <nl> } <nl> <nl> - return pImplControl ; <nl> + return pImplItem ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> void CProjectLoader : : LoadEventsMetadata ( const string & soundbanksPath ) <nl> } <nl> } <nl> <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - CImplItem * CProjectLoader : : GetControlByName ( string const & name , bool const isLocalised , CImplItem const * const pParent ) const <nl> - { <nl> - string fullName = ( pParent ! = nullptr ) ? ( pParent - > GetName ( ) + CRY_NATIVE_PATH_SEPSTR + name ) : name ; <nl> - <nl> - if ( isLocalised ) <nl> - { <nl> - fullName = PathUtil : : GetLocalizationFolder ( ) + CRY_NATIVE_PATH_SEPSTR + fullName ; <nl> - } <nl> - <nl> - return stl : : find_in_map ( m_controlsCache , CryAudio : : StringToId ( fullName ) , nullptr ) ; <nl> - } <nl> - <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> void CProjectLoader : : BuildFileCache ( string const & folderPath ) <nl> { <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorWwise / ProjectLoader . h <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorWwise / ProjectLoader . h <nl> <nl> <nl> # pragma once <nl> <nl> - # include " ImplControls . h " <nl> + # include " ImplItem . h " <nl> <nl> # include < CrySystem / XML / IXml . h > <nl> # include < SystemTypes . h > <nl> class CProjectLoader final <nl> { <nl> public : <nl> <nl> - CProjectLoader ( string const & projectPath , string const & soundbanksPath , CImplItem & root , ControlsCache & controlsCache ) ; <nl> + CProjectLoader ( string const & projectPath , string const & soundbanksPath , CImplItem & rootItem , ItemCache & itemCache ) ; <nl> <nl> private : <nl> <nl> class CProjectLoader final <nl> CImplItem * CreateItem ( string const & name , EImpltemType const type , CImplItem & pParent ) ; <nl> void LoadEventsMetadata ( string const & soundbanksPath ) ; <nl> <nl> - CImplItem * GetControlByName ( string const & name , bool const isLocalised = false , CImplItem const * const pParent = nullptr ) const ; <nl> - <nl> void BuildFileCache ( string const & folderPath ) ; <nl> <nl> private : <nl> class CProjectLoader final <nl> using FilesCache = std : : map < uint32 , string > ; <nl> using Items = std : : map < uint32 , CImplItem * > ; <nl> <nl> - EventsInfoMap m_eventsInfoMap ; <nl> - CImplItem & m_root ; <nl> - ControlsCache & m_controlsCache ; <nl> - string const m_projectPath ; <nl> + EventsInfoMap m_eventsInfoMap ; <nl> + CImplItem & m_rootItem ; <nl> + ItemCache & m_itemCache ; <nl> + string const m_projectPath ; <nl> <nl> / / This maps holds the items with the internal IDs given in the Wwise files . <nl> Items m_items ; <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / FileMonitor . cpp <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / FileMonitor . cpp <nl> void CFileMonitorMiddleware : : Enable ( ) <nl> int const gameFolderPathLength = ( PathUtil : : GetGameFolder ( ) + CRY_NATIVE_PATH_SEPSTR ) . GetLength ( ) ; <nl> <nl> string const & soundBanksPath = pImplSettings - > GetAssetsPath ( ) ; <nl> - string const & soundBanksPathSubstr = ( soundBanksPath ) . substr ( gameFolderPathLength ) ; <nl> + string const & soundBanksPathSubstr = soundBanksPath . substr ( gameFolderPathLength ) ; <nl> m_monitorFolders . emplace_back ( soundBanksPathSubstr . c_str ( ) ) ; <nl> <nl> string const & localizationPath = PathUtil : : GetLocalizationFolder ( ) ; <nl> m_monitorFolders . emplace_back ( localizationPath . c_str ( ) ) ; <nl> <nl> - string const & projectPath = pImplSettings - > GetProjectPath ( ) ; <nl> - <nl> - if ( projectPath ! = soundBanksPath ) <nl> + if ( pImplSettings - > SupportsProjects ( ) ) <nl> { <nl> - string const & projectPathSubstr = projectPath . substr ( gameFolderPathLength ) ; <nl> + string const projectPath = pImplSettings - > GetProjectPath ( ) ; <nl> + string const projectPathSubstr = projectPath . substr ( gameFolderPathLength ) ; <nl> m_monitorFolders . emplace_back ( projectPathSubstr . c_str ( ) ) ; <nl> } <nl> <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / FileWriter . cpp <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / FileWriter . cpp <nl> <nl> # include " ImplementationManager . h " <nl> <nl> # include < IEditorImpl . h > <nl> - # include < ImplItem . h > <nl> + # include < IImplItem . h > <nl> # include < CryString / StringUtils . h > <nl> # include < CrySystem / File / CryFile . h > <nl> # include < CrySystem / ISystem . h > <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / MiddlewareDataModel . cpp <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / MiddlewareDataModel . cpp <nl> <nl> # include " ModelUtils . h " <nl> <nl> # include < IEditorImpl . h > <nl> - # include < ImplItem . h > <nl> + # include < IImplItem . h > <nl> # include < CrySystem / File / CryFile . h > <nl> # include < CrySandbox / CrySignal . h > <nl> # include < CryIcon . h > <nl> int CMiddlewareDataModel : : rowCount ( QModelIndex const & parent ) const <nl> <nl> if ( g_pEditorImpl ! = nullptr ) <nl> { <nl> - CImplItem const * pImplItem = ItemFromIndex ( parent ) ; <nl> + IImplItem const * pImplItem = ItemFromIndex ( parent ) ; <nl> <nl> if ( pImplItem = = nullptr ) <nl> { <nl> int CMiddlewareDataModel : : rowCount ( QModelIndex const & parent ) const <nl> <nl> if ( pImplItem ! = nullptr ) <nl> { <nl> - rowCount = pImplItem - > ChildCount ( ) ; <nl> + rowCount = pImplItem - > GetNumChildren ( ) ; <nl> } <nl> } <nl> <nl> QVariant CMiddlewareDataModel : : data ( QModelIndex const & index , int role ) const <nl> { <nl> if ( index . isValid ( ) ) <nl> { <nl> - CImplItem const * const pImplItem = ItemFromIndex ( index ) ; <nl> + IImplItem const * const pImplItem = ItemFromIndex ( index ) ; <nl> <nl> if ( pImplItem ! = nullptr ) <nl> { <nl> QVariant CMiddlewareDataModel : : data ( QModelIndex const & index , int role ) const <nl> { <nl> variant = CryIcon ( ModelUtils : : GetItemNotificationIcon ( ModelUtils : : EItemStatus : : NoConnection ) ) ; <nl> } <nl> - else if ( pImplItem - > IsLocalised ( ) ) <nl> + else if ( pImplItem - > IsLocalized ( ) ) <nl> { <nl> variant = CryIcon ( ModelUtils : : GetItemNotificationIcon ( ModelUtils : : EItemStatus : : Localized ) ) ; <nl> } <nl> QVariant CMiddlewareDataModel : : data ( QModelIndex const & index , int role ) const <nl> { <nl> variant = tr ( " Item is not connected to any audio system control " ) ; <nl> } <nl> - else if ( pImplItem - > IsLocalised ( ) ) <nl> + else if ( pImplItem - > IsLocalized ( ) ) <nl> { <nl> variant = tr ( " Item is localized " ) ; <nl> } <nl> QVariant CMiddlewareDataModel : : data ( QModelIndex const & index , int role ) const <nl> case static_cast < int > ( EColumns : : Localized ) : <nl> if ( ( role = = Qt : : CheckStateRole ) & & ! pImplItem - > IsContainer ( ) ) <nl> { <nl> - variant = pImplItem - > IsLocalised ( ) ? Qt : : Checked : Qt : : Unchecked ; <nl> + variant = pImplItem - > IsLocalized ( ) ? Qt : : Checked : Qt : : Unchecked ; <nl> } <nl> break ; <nl> case static_cast < int > ( EColumns : : Name ) : <nl> Qt : : ItemFlags CMiddlewareDataModel : : flags ( QModelIndex const & index ) const <nl> <nl> if ( index . isValid ( ) & & ( g_pEditorImpl ! = nullptr ) ) <nl> { <nl> - CImplItem const * const pImplItem = ItemFromIndex ( index ) ; <nl> + IImplItem const * const pImplItem = ItemFromIndex ( index ) ; <nl> <nl> if ( ( pImplItem ! = nullptr ) & & ! pImplItem - > IsPlaceholder ( ) & & ( g_pEditorImpl - > ImplTypeToSystemType ( pImplItem ) ! = ESystemItemType : : NumTypes ) ) <nl> { <nl> QModelIndex CMiddlewareDataModel : : index ( int row , int column , QModelIndex const & <nl> { <nl> if ( ( row > = 0 ) & & ( column > = 0 ) ) <nl> { <nl> - CImplItem const * pParent = ItemFromIndex ( parent ) ; <nl> + IImplItem const * pParent = ItemFromIndex ( parent ) ; <nl> <nl> if ( pParent = = nullptr ) <nl> { <nl> pParent = g_pEditorImpl - > GetRoot ( ) ; <nl> } <nl> <nl> - if ( ( pParent ! = nullptr ) & & pParent - > ChildCount ( ) > row ) <nl> + if ( ( pParent ! = nullptr ) & & pParent - > GetNumChildren ( ) > row ) <nl> { <nl> - CImplItem const * const pImplItem = pParent - > GetChildAt ( row ) ; <nl> + IImplItem const * const pImplItem = pParent - > GetChildAt ( row ) ; <nl> <nl> if ( pImplItem ! = nullptr ) <nl> { <nl> QModelIndex CMiddlewareDataModel : : parent ( QModelIndex const & index ) const <nl> <nl> if ( index . isValid ( ) ) <nl> { <nl> - CImplItem const * const pItem = ItemFromIndex ( index ) ; <nl> + IImplItem const * const pItem = ItemFromIndex ( index ) ; <nl> <nl> if ( pItem ! = nullptr ) <nl> { <nl> QMimeData * CMiddlewareDataModel : : mimeData ( QModelIndexList const & indexes ) const <nl> <nl> for ( auto const & index : nameIndexes ) <nl> { <nl> - CImplItem const * const pImplItem = ItemFromIndex ( index ) ; <nl> + IImplItem const * const pImplItem = ItemFromIndex ( index ) ; <nl> <nl> if ( pImplItem ! = nullptr ) <nl> { <nl> QMimeData * CMiddlewareDataModel : : mimeData ( QModelIndexList const & indexes ) const <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - CImplItem * CMiddlewareDataModel : : ItemFromIndex ( QModelIndex const & index ) const <nl> + IImplItem * CMiddlewareDataModel : : ItemFromIndex ( QModelIndex const & index ) const <nl> { <nl> - CImplItem * pImplItem = nullptr ; <nl> + IImplItem * pImplItem = nullptr ; <nl> <nl> if ( index . isValid ( ) ) <nl> { <nl> - pImplItem = static_cast < CImplItem * > ( index . internalPointer ( ) ) ; <nl> + pImplItem = static_cast < IImplItem * > ( index . internalPointer ( ) ) ; <nl> } <nl> <nl> return pImplItem ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - QModelIndex CMiddlewareDataModel : : IndexFromItem ( CImplItem const * const pImplItem ) const <nl> + QModelIndex CMiddlewareDataModel : : IndexFromItem ( IImplItem const * const pImplItem ) const <nl> { <nl> QModelIndex modelIndex = QModelIndex ( ) ; <nl> <nl> if ( pImplItem ! = nullptr ) <nl> { <nl> - CImplItem const * pParent = pImplItem - > GetParent ( ) ; <nl> + IImplItem const * pParent = pImplItem - > GetParent ( ) ; <nl> <nl> if ( pParent = = nullptr ) <nl> { <nl> QModelIndex CMiddlewareDataModel : : IndexFromItem ( CImplItem const * const pImplItem <nl> <nl> if ( pParent ! = nullptr ) <nl> { <nl> - int const size = pParent - > ChildCount ( ) ; <nl> + int const size = pParent - > GetNumChildren ( ) ; <nl> <nl> for ( int i = 0 ; i < size ; + + i ) <nl> { <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / MiddlewareDataModel . h <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / MiddlewareDataModel . h <nl> class CItemModelAttribute ; <nl> <nl> namespace ACE <nl> { <nl> - class CImplItem ; <nl> + struct IImplItem ; <nl> <nl> class CMiddlewareDataModel final : public QAbstractItemModel <nl> { <nl> class CMiddlewareDataModel final : public QAbstractItemModel <nl> private : <nl> <nl> void ConnectSignals ( ) ; <nl> - CImplItem * ItemFromIndex ( QModelIndex const & index ) const ; <nl> - QModelIndex IndexFromItem ( CImplItem const * const pImplItem ) const ; <nl> + IImplItem * ItemFromIndex ( QModelIndex const & index ) const ; <nl> + QModelIndex IndexFromItem ( IImplItem const * const pImplItem ) const ; <nl> } ; <nl> <nl> class CMiddlewareFilterProxyModel final : public QAttributeFilterProxyModel <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / MiddlewareDataWidget . cpp <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / MiddlewareDataWidget . cpp <nl> <nl> # include " TreeView . h " <nl> <nl> # include < IEditorImpl . h > <nl> - # include < ImplItem . h > <nl> + # include < IImplItem . h > <nl> # include < QFilteringPanel . h > <nl> # include < QSearchBox . h > <nl> # include < QtUtil . h > <nl> CMiddlewareDataWidget : : ~ CMiddlewareDataWidget ( ) <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> void CMiddlewareDataWidget : : OnContextMenu ( QPoint const & pos ) <nl> { <nl> - QMenu * const pContextMenu = new QMenu ( this ) ; <nl> + auto const pContextMenu = new QMenu ( this ) ; <nl> auto const & selection = m_pTreeView - > selectionModel ( ) - > selectedRows ( m_nameColumn ) ; <nl> <nl> if ( ! selection . isEmpty ( ) ) <nl> void CMiddlewareDataWidget : : OnContextMenu ( QPoint const & pos ) <nl> if ( g_pEditorImpl ! = nullptr ) <nl> { <nl> CID const itemId = selection [ 0 ] . data ( static_cast < int > ( CMiddlewareDataModel : : ERoles : : Id ) ) . toInt ( ) ; <nl> - CImplItem const * const pImplControl = g_pEditorImpl - > GetControl ( itemId ) ; <nl> + IImplItem const * const pImplItem = g_pEditorImpl - > GetImplItem ( itemId ) ; <nl> <nl> - if ( ( pImplControl ! = nullptr ) & & pImplControl - > IsConnected ( ) ) <nl> + if ( ( pImplItem ! = nullptr ) & & pImplItem - > IsConnected ( ) ) <nl> { <nl> QMenu * const pConnectionsMenu = new QMenu ( pContextMenu ) ; <nl> auto const controls = m_pAssetsManager - > GetControls ( ) ; <nl> void CMiddlewareDataWidget : : OnContextMenu ( QPoint const & pos ) <nl> <nl> for ( auto const pControl : controls ) <nl> { <nl> - if ( pControl - > GetConnection ( pImplControl ) ! = nullptr ) <nl> + if ( pControl - > GetConnection ( pImplItem ) ! = nullptr ) <nl> { <nl> pConnectionsMenu - > addAction ( GetItemTypeIcon ( pControl - > GetType ( ) ) , tr ( pControl - > GetName ( ) ) , [ = ] ( ) <nl> { <nl> - SignalSelectConnectedSystemControl ( * pControl , pImplControl - > GetId ( ) ) ; <nl> + SignalSelectConnectedSystemControl ( * pControl , pImplItem - > GetId ( ) ) ; <nl> } ) ; <nl> <nl> + + count ; <nl> void CMiddlewareDataWidget : : OnContextMenu ( QPoint const & pos ) <nl> } <nl> } <nl> <nl> - if ( ( pImplControl ! = nullptr ) & & ! pImplControl - > GetFilePath ( ) . IsEmpty ( ) ) <nl> + if ( ( pImplItem ! = nullptr ) & & ! pImplItem - > GetFilePath ( ) . IsEmpty ( ) ) <nl> { <nl> pContextMenu - > addAction ( tr ( " Open Containing Folder " ) , [ & ] ( ) <nl> { <nl> - QtUtil : : OpenInExplorer ( PathUtil : : Make ( GetISystem ( ) - > GetIProjectManager ( ) - > GetCurrentProjectDirectoryAbsolute ( ) , pImplControl - > GetFilePath ( ) ) . c_str ( ) ) ; <nl> + QtUtil : : OpenInExplorer ( PathUtil : : Make ( GetISystem ( ) - > GetIProjectManager ( ) - > GetCurrentProjectDirectoryAbsolute ( ) , pImplItem - > GetFilePath ( ) . c_str ( ) ) ) ; <nl> } ) ; <nl> <nl> pContextMenu - > addSeparator ( ) ; <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / ModelUtils . cpp <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / ModelUtils . cpp <nl> <nl> - / / Copyright 2001 - 2016 Crytek GmbH / Crytek Group . All rights reserved . <nl> + / / Copyright 2001 - 2018 Crytek GmbH / Crytek Group . All rights reserved . <nl> <nl> # include " StdAfx . h " <nl> <nl> # include " ModelUtils . h " <nl> # include " AudioControlsEditorPlugin . h " <nl> <nl> - # include < ImplItem . h > <nl> + # include < IImplItem . h > <nl> # include < IEditorImpl . h > <nl> # include < ConfigurationManager . h > <nl> <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / ModelUtils . h <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / ModelUtils . h <nl> <nl> - / / Copyright 2001 - 2016 Crytek GmbH / Crytek Group . All rights reserved . <nl> + / / Copyright 2001 - 2018 Crytek GmbH / Crytek Group . All rights reserved . <nl> <nl> # pragma once <nl> <nl> <nl> <nl> namespace ACE <nl> { <nl> - class CImplItem ; <nl> + struct IImplItem ; <nl> <nl> namespace ModelUtils <nl> { <nl> enum class EItemStatus <nl> NotificationHeader , <nl> } ; <nl> <nl> - void GetPlatformNames ( ) ; <nl> - QStringList GetScopeNames ( ) ; <nl> + void GetPlatformNames ( ) ; <nl> + QStringList GetScopeNames ( ) ; <nl> <nl> inline char const * GetItemNotificationIcon ( EItemStatus const status ) <nl> { <nl> inline char const * GetItemNotificationIcon ( EItemStatus const status ) <nl> <nl> static char const * const s_szSystemMimeType = " AudioSystemItems " ; <nl> static char const * const s_szImplMimeType = " AudioImplItems " ; <nl> - static QStringList const s_typeFilterList { " Trigger " , " Parameter " , " Switch " , " State " , " Environment " , " Preload " } ; <nl> + static QStringList const s_typeFilterList { <nl> + " Trigger " , " Parameter " , " Switch " , " State " , " Environment " , " Preload " <nl> + } ; <nl> <nl> - static CItemModelAttribute s_notificationAttribute ( " Notification " , eAttributeType_String , CItemModelAttribute : : Visible , false ) ; <nl> - static CItemModelAttribute s_placeholderAttribute ( " Valid Connection " , eAttributeType_Boolean , CItemModelAttribute : : AlwaysHidden , true , Qt : : Unchecked ) ; <nl> - static CItemModelAttribute s_connectedAttribute ( " Connected " , eAttributeType_Boolean , CItemModelAttribute : : AlwaysHidden , true , Qt : : Unchecked ) ; <nl> - static CItemModelAttribute s_localizedAttribute ( " Localized " , eAttributeType_Boolean , CItemModelAttribute : : AlwaysHidden , true , Qt : : Checked ) ; <nl> - static CItemModelAttribute s_noControlAttribute ( " Empty " , eAttributeType_Boolean , CItemModelAttribute : : AlwaysHidden , true , Qt : : Checked ) ; <nl> - static CItemModelAttribute s_pathAttribute ( " Path " , eAttributeType_String , CItemModelAttribute : : Visible , false ) ; <nl> - static CItemModelAttributeEnum s_typeAttribute ( " Type " , s_typeFilterList , CItemModelAttribute : : AlwaysHidden , true ) ; <nl> - static CItemModelAttributeEnumFunc s_scopeAttribute ( " Scope " , & GetScopeNames , CItemModelAttribute : : StartHidden , true ) ; <nl> + static CItemModelAttribute s_notificationAttribute ( " Notification " , eAttributeType_String , CItemModelAttribute : : Visible , false ) ; <nl> + static CItemModelAttribute s_placeholderAttribute ( " Valid Connection " , eAttributeType_Boolean , CItemModelAttribute : : AlwaysHidden , true , Qt : : Unchecked ) ; <nl> + static CItemModelAttribute s_connectedAttribute ( " Connected " , eAttributeType_Boolean , CItemModelAttribute : : AlwaysHidden , true , Qt : : Unchecked ) ; <nl> + static CItemModelAttribute s_localizedAttribute ( " Localized " , eAttributeType_Boolean , CItemModelAttribute : : AlwaysHidden , true , Qt : : Checked ) ; <nl> + static CItemModelAttribute s_noControlAttribute ( " Empty " , eAttributeType_Boolean , CItemModelAttribute : : AlwaysHidden , true , Qt : : Checked ) ; <nl> + static CItemModelAttribute s_pathAttribute ( " Path " , eAttributeType_String , CItemModelAttribute : : Visible , false ) ; <nl> + static CItemModelAttributeEnum s_typeAttribute ( " Type " , s_typeFilterList , CItemModelAttribute : : AlwaysHidden , true ) ; <nl> + static CItemModelAttributeEnumFunc s_scopeAttribute ( " Scope " , & GetScopeNames , CItemModelAttribute : : StartHidden , true ) ; <nl> static std : : vector < CItemModelAttribute > s_platformModellAttributes ; <nl> } / / namespace ModelUtils <nl> } / / namespace ACE <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / PreferencesDialog . cpp <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / PreferencesDialog . cpp <nl> CPreferencesDialog : : CPreferencesDialog ( QWidget * const pParent ) <nl> QToolButton * const pBrowseButton = new QToolButton ( this ) ; <nl> pBrowseButton - > setText ( " . . . " ) ; <nl> <nl> - if ( pImplSettings - > IsProjectPathEditable ( ) ) <nl> + if ( pImplSettings - > SupportsProjects ( ) ) <nl> { <nl> QObject : : connect ( pLineEdit , & QLineEdit : : textChanged , [ = ] ( QString const & projectPath ) <nl> { <nl> CPreferencesDialog : : CPreferencesDialog ( QWidget * const pParent ) <nl> } <nl> else <nl> { <nl> + pLineEdit - > setText ( tr ( " The selected middleware doesn ' t support projects . " ) ) ; <nl> pLineEdit - > setEnabled ( false ) ; <nl> pBrowseButton - > setEnabled ( false ) ; <nl> } <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / SystemAssets . cpp <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / SystemAssets . cpp <nl> <nl> # include " ImplementationManager . h " <nl> <nl> # include < IEditor . h > <nl> - # include < ImplItem . h > <nl> + # include < IImplItem . h > <nl> # include < CrySerialization / StringList . h > <nl> # include < CryMath / Cry_Geo . h > <nl> # include < Util / Math . h > <nl> void CSystemAsset : : SetParent ( CSystemAsset * const pParent ) <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> void CSystemAsset : : AddChild ( CSystemAsset * const pChildControl ) <nl> { <nl> - m_children . emplace_back ( pChildControl ) ; <nl> + m_children . push_back ( pChildControl ) ; <nl> SetModified ( true ) ; <nl> } <nl> <nl> ConnectionPtr CSystemControl : : GetConnection ( CID const id ) const <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - ConnectionPtr CSystemControl : : GetConnection ( CImplItem const * const pAudioSystemControl ) const <nl> + ConnectionPtr CSystemControl : : GetConnection ( IImplItem const * const pAudioSystemControl ) const <nl> { <nl> return GetConnection ( pAudioSystemControl - > GetId ( ) ) ; <nl> } <nl> void CSystemControl : : AddConnection ( ConnectionPtr const pConnection ) <nl> { <nl> if ( g_pEditorImpl ! = nullptr ) <nl> { <nl> - CImplItem * const pImplControl = g_pEditorImpl - > GetControl ( pConnection - > GetID ( ) ) ; <nl> + IImplItem * const pImplItem = g_pEditorImpl - > GetImplItem ( pConnection - > GetID ( ) ) ; <nl> <nl> - if ( pImplControl ! = nullptr ) <nl> + if ( pImplItem ! = nullptr ) <nl> { <nl> g_pEditorImpl - > EnableConnection ( pConnection ) ; <nl> pConnection - > SignalConnectionChanged . Connect ( this , & CSystemControl : : SignalConnectionModified ) ; <nl> - m_connectedControls . emplace_back ( pConnection ) ; <nl> + m_connectedControls . push_back ( pConnection ) ; <nl> MatchRadiusToAttenuation ( ) ; <nl> - SignalConnectionAdded ( pImplControl ) ; <nl> + SignalConnectionAdded ( pImplItem ) ; <nl> SignalControlModified ( ) ; <nl> } <nl> } <nl> void CSystemControl : : RemoveConnection ( ConnectionPtr const pConnection ) <nl> { <nl> if ( g_pEditorImpl ! = nullptr ) <nl> { <nl> - CImplItem * const pImplControl = g_pEditorImpl - > GetControl ( pConnection - > GetID ( ) ) ; <nl> + IImplItem * const pImplItem = g_pEditorImpl - > GetImplItem ( pConnection - > GetID ( ) ) ; <nl> <nl> - if ( pImplControl ! = nullptr ) <nl> + if ( pImplItem ! = nullptr ) <nl> { <nl> g_pEditorImpl - > DisableConnection ( pConnection ) ; <nl> m_connectedControls . erase ( it ) ; <nl> MatchRadiusToAttenuation ( ) ; <nl> - SignalConnectionRemoved ( pImplControl ) ; <nl> + SignalConnectionRemoved ( pImplItem ) ; <nl> SignalControlModified ( ) ; <nl> } <nl> } <nl> void CSystemControl : : ClearConnections ( ) <nl> for ( ConnectionPtr const & connection : m_connectedControls ) <nl> { <nl> g_pEditorImpl - > DisableConnection ( connection ) ; <nl> - CImplItem * const pImplControl = g_pEditorImpl - > GetControl ( connection - > GetID ( ) ) ; <nl> + IImplItem * const pImplItem = g_pEditorImpl - > GetImplItem ( connection - > GetID ( ) ) ; <nl> <nl> - if ( pImplControl ! = nullptr ) <nl> + if ( pImplItem ! = nullptr ) <nl> { <nl> - SignalConnectionRemoved ( pImplControl ) ; <nl> + SignalConnectionRemoved ( pImplItem ) ; <nl> } <nl> } <nl> } <nl> void CSystemControl : : ClearConnections ( ) <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - void CSystemControl : : RemoveConnection ( CImplItem * const pImplControl ) <nl> + void CSystemControl : : RemoveConnection ( IImplItem * const pImplItem ) <nl> { <nl> - if ( pImplControl ! = nullptr ) <nl> + if ( pImplItem ! = nullptr ) <nl> { <nl> - CID const id = pImplControl - > GetId ( ) ; <nl> + CID const id = pImplItem - > GetId ( ) ; <nl> auto it = m_connectedControls . begin ( ) ; <nl> auto const end = m_connectedControls . end ( ) ; <nl> <nl> void CSystemControl : : RemoveConnection ( CImplItem * const pImplControl ) <nl> <nl> m_connectedControls . erase ( it ) ; <nl> MatchRadiusToAttenuation ( ) ; <nl> - SignalConnectionRemoved ( pImplControl ) ; <nl> + SignalConnectionRemoved ( pImplItem ) ; <nl> SignalControlModified ( ) ; <nl> break ; <nl> } <nl> void CSystemControl : : SignalControlAboutToBeModified ( ) <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - void CSystemControl : : SignalConnectionAdded ( CImplItem * const pImplControl ) <nl> + void CSystemControl : : SignalConnectionAdded ( IImplItem * const pImplItem ) <nl> { <nl> - CAudioControlsEditorPlugin : : GetAssetsManager ( ) - > OnConnectionAdded ( this , pImplControl ) ; <nl> + CAudioControlsEditorPlugin : : GetAssetsManager ( ) - > OnConnectionAdded ( this , pImplItem ) ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - void CSystemControl : : SignalConnectionRemoved ( CImplItem * const pImplControl ) <nl> + void CSystemControl : : SignalConnectionRemoved ( IImplItem * const pImplItem ) <nl> { <nl> - CAudioControlsEditorPlugin : : GetAssetsManager ( ) - > OnConnectionRemoved ( this , pImplControl ) ; <nl> + CAudioControlsEditorPlugin : : GetAssetsManager ( ) - > OnConnectionRemoved ( this , pImplItem ) ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> void CSystemControl : : Serialize ( Serialization : : IArchive & ar ) <nl> <nl> for ( auto const & connection : m_connectedControls ) <nl> { <nl> - CImplItem const * const pImplControl = g_pEditorImpl - > GetControl ( connection - > GetID ( ) ) ; <nl> + IImplItem const * const pImplItem = g_pEditorImpl - > GetImplItem ( connection - > GetID ( ) ) ; <nl> <nl> - if ( ( pImplControl ! = nullptr ) & & ! pImplControl - > IsPlaceholder ( ) ) <nl> + if ( ( pImplItem ! = nullptr ) & & ! pImplItem - > IsPlaceholder ( ) ) <nl> { <nl> - connectionMaxRadius = std : : max ( connectionMaxRadius , pImplControl - > GetRadius ( ) ) ; <nl> + connectionMaxRadius = std : : max ( connectionMaxRadius , pImplItem - > GetRadius ( ) ) ; <nl> } <nl> else <nl> { <nl> void CSystemControl : : MatchRadiusToAttenuation ( ) <nl> <nl> for ( auto const & connection : m_connectedControls ) <nl> { <nl> - CImplItem const * const pImplControl = g_pEditorImpl - > GetControl ( connection - > GetID ( ) ) ; <nl> + IImplItem const * const pImplItem = g_pEditorImpl - > GetImplItem ( connection - > GetID ( ) ) ; <nl> <nl> - if ( ( pImplControl ! = nullptr ) & & ! pImplControl - > IsPlaceholder ( ) ) <nl> + if ( ( pImplItem ! = nullptr ) & & ! pImplItem - > IsPlaceholder ( ) ) <nl> { <nl> - radius = std : : max ( radius , pImplControl - > GetRadius ( ) ) ; <nl> + radius = std : : max ( radius , pImplItem - > GetRadius ( ) ) ; <nl> } <nl> else <nl> { <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / SystemAssets . h <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / SystemAssets . h <nl> <nl> <nl> namespace ACE <nl> { <nl> - class CImplItem ; <nl> + struct IImplItem ; <nl> <nl> struct SRawConnectionData <nl> { <nl> class CSystemControl final : public CSystemAsset <nl> size_t GetConnectionCount ( ) const { return m_connectedControls . size ( ) ; } <nl> void AddConnection ( ConnectionPtr const pConnection ) ; <nl> void RemoveConnection ( ConnectionPtr const pConnection ) ; <nl> - void RemoveConnection ( CImplItem * const pImplControl ) ; <nl> + void RemoveConnection ( IImplItem * const pImplItem ) ; <nl> void ClearConnections ( ) ; <nl> ConnectionPtr GetConnectionAt ( size_t const index ) const ; <nl> ConnectionPtr GetConnection ( CID const id ) const ; <nl> - ConnectionPtr GetConnection ( CImplItem const * const pImplControl ) const ; <nl> + ConnectionPtr GetConnection ( IImplItem const * const pImplItem ) const ; <nl> void ReloadConnections ( ) ; <nl> void LoadConnectionFromXML ( XmlNodeRef const xmlNode , int const platformIndex = - 1 ) ; <nl> <nl> class CSystemControl final : public CSystemAsset <nl> <nl> void SignalControlAboutToBeModified ( ) ; <nl> void SignalControlModified ( ) ; <nl> - void SignalConnectionAdded ( CImplItem * const pImplControl ) ; <nl> - void SignalConnectionRemoved ( CImplItem * const pImplControl ) ; <nl> + void SignalConnectionAdded ( IImplItem * const pImplItem ) ; <nl> + void SignalConnectionRemoved ( IImplItem * const pImplItem ) ; <nl> void SignalConnectionModified ( ) ; <nl> <nl> CID m_id = ACE_INVALID_ID ; <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / SystemAssetsManager . cpp <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / SystemAssetsManager . cpp <nl> <nl> # include " ImplementationManager . h " <nl> <nl> # include < IEditorImpl . h > <nl> - # include < ImplItem . h > <nl> + # include < IImplItem . h > <nl> <nl> # include < CryAudio / IAudioSystem . h > <nl> # include < CryString / StringUtils . h > <nl> void CSystemAssetsManager : : OnControlAboutToBeModified ( CSystemControl * const pCon <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - void CSystemAssetsManager : : OnConnectionAdded ( CSystemControl * const pControl , CImplItem * const pImplControl ) <nl> + void CSystemAssetsManager : : OnConnectionAdded ( CSystemControl * const pControl , IImplItem * const pImplItem ) <nl> { <nl> SignalConnectionAdded ( pControl ) ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - void CSystemAssetsManager : : OnConnectionRemoved ( CSystemControl * const pControl , CImplItem * const pImplControl ) <nl> + void CSystemAssetsManager : : OnConnectionRemoved ( CSystemControl * const pControl , IImplItem * const pImplItem ) <nl> { <nl> SignalConnectionRemoved ( pControl ) ; <nl> } <nl> void CSystemAssetsManager : : UpdateAssetConnectionStates ( CSystemAsset * const pAsse <nl> <nl> if ( g_pEditorImpl ! = nullptr ) <nl> { <nl> - CImplItem const * const pImpleControl = g_pEditorImpl - > GetControl ( pControl - > GetConnectionAt ( i ) - > GetID ( ) ) ; <nl> + IImplItem const * const pImpleControl = g_pEditorImpl - > GetImplItem ( pControl - > GetConnectionAt ( i ) - > GetID ( ) ) ; <nl> <nl> if ( pImpleControl ! = nullptr ) <nl> { <nl> void CSystemAssetsManager : : MoveItems ( CSystemAsset * const pParent , std : : vector < CS <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - void CSystemAssetsManager : : CreateAndConnectImplItems ( CImplItem * const pImplItem , CSystemAsset * const pParent ) <nl> + void CSystemAssetsManager : : CreateAndConnectImplItems ( IImplItem * const pImplItem , CSystemAsset * const pParent ) <nl> { <nl> SignalItemAboutToBeAdded ( pParent ) ; <nl> CSystemAsset * pItem = CreateAndConnectImplItemsRecursively ( pImplItem , pParent ) ; <nl> void CSystemAssetsManager : : CreateAndConnectImplItems ( CImplItem * const pImplItem , <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - CSystemAsset * CSystemAssetsManager : : CreateAndConnectImplItemsRecursively ( CImplItem * const pImplItem , CSystemAsset * const pParent ) <nl> + CSystemAsset * CSystemAssetsManager : : CreateAndConnectImplItemsRecursively ( IImplItem * const pImplItem , CSystemAsset * const pParent ) <nl> { <nl> CSystemAsset * pItem = nullptr ; <nl> <nl> CSystemAsset * CSystemAssetsManager : : CreateAndConnectImplItemsRecursively ( CImplIt <nl> pItem = pFolder ; <nl> } <nl> <nl> - size_t const size = pImplItem - > ChildCount ( ) ; <nl> + size_t const size = pImplItem - > GetNumChildren ( ) ; <nl> <nl> for ( size_t i = 0 ; i < size ; + + i ) <nl> { <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / SystemAssetsManager . h <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / SystemAssetsManager . h <nl> <nl> <nl> namespace ACE <nl> { <nl> - class CImplItem ; <nl> + struct IImplItem ; <nl> <nl> class CSystemAssetsManager <nl> { <nl> class CSystemAssetsManager <nl> void ClearAllConnections ( ) ; <nl> void ReloadAllConnections ( ) ; <nl> void MoveItems ( CSystemAsset * const pParent , std : : vector < CSystemAsset * > const & items ) ; <nl> - void CreateAndConnectImplItems ( CImplItem * const pImplItem , CSystemAsset * const pParent ) ; <nl> + void CreateAndConnectImplItems ( IImplItem * const pImplItem , CSystemAsset * const pParent ) ; <nl> <nl> bool IsTypeDirty ( ESystemItemType const type ) const ; <nl> bool IsDirty ( ) const ; <nl> class CSystemAssetsManager <nl> <nl> void OnControlAboutToBeModified ( CSystemControl * const pControl ) ; <nl> void OnControlModified ( CSystemControl * const pControl ) ; <nl> - void OnConnectionAdded ( CSystemControl * const pControl , CImplItem * const pImplControl ) ; <nl> - void OnConnectionRemoved ( CSystemControl * const pControl , CImplItem * const pImplControl ) ; <nl> + void OnConnectionAdded ( CSystemControl * const pControl , IImplItem * const pImplItem ) ; <nl> + void OnConnectionRemoved ( CSystemControl * const pControl , IImplItem * const pImplItem ) ; <nl> void OnAssetRenamed ( ) ; <nl> <nl> void UpdateFolderPaths ( ) ; <nl> class CSystemAssetsManager <nl> <nl> private : <nl> <nl> - CSystemAsset * CreateAndConnectImplItemsRecursively ( CImplItem * const pImplItem , CSystemAsset * const pParent ) ; <nl> + CSystemAsset * CreateAndConnectImplItemsRecursively ( IImplItem * const pImplItem , CSystemAsset * const pParent ) ; <nl> CID GenerateUniqueId ( ) { return m_nextId + + ; } <nl> <nl> using ScopesInfo = std : : map < Scope , SScopeInfo > ; <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / SystemControlsModel . cpp <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / SystemControlsModel . cpp <nl> <nl> # include " SystemControlsIcons . h " <nl> # include " ModelUtils . h " <nl> <nl> - # include < ImplItem . h > <nl> + # include < IImplItem . h > <nl> # include < QtUtil . h > <nl> # include < DragDrop . h > <nl> <nl> QMimeData * GetDragDropData ( QModelIndexList const & list ) <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - void DecodeImplMimeData ( const QMimeData * pData , std : : vector < CImplItem * > & outItems ) <nl> + void DecodeImplMimeData ( const QMimeData * pData , std : : vector < IImplItem * > & outItems ) <nl> { <nl> CDragDropData const * const pDragDropData = CDragDropData : : FromMimeData ( pData ) ; <nl> <nl> void DecodeImplMimeData ( const QMimeData * pData , std : : vector < CImplItem * > & outItem <nl> <nl> if ( id ! = ACE_INVALID_ID ) <nl> { <nl> - CImplItem * const pImplControl = g_pEditorImpl - > GetControl ( id ) ; <nl> + IImplItem * const pImplItem = g_pEditorImpl - > GetImplItem ( id ) ; <nl> <nl> - if ( pImplControl ! = nullptr ) <nl> + if ( pImplItem ! = nullptr ) <nl> { <nl> - outItems . emplace_back ( pImplControl ) ; <nl> + outItems . push_back ( pImplItem ) ; <nl> } <nl> } <nl> } <nl> bool CanDropMimeData ( QMimeData const * const pData , CSystemAsset const & parent ) <nl> bool hasValidParent = true ; <nl> <nl> / / Handle first if mime data is an external ( from the implementation side ) source . <nl> - std : : vector < CImplItem * > implItems ; <nl> + std : : vector < IImplItem * > implItems ; <nl> SystemModelUtils : : DecodeImplMimeData ( pData , implItems ) ; <nl> <nl> if ( ! implItems . empty ( ) ) <nl> { <nl> - for ( CImplItem const * const pImplItem : implItems ) <nl> + for ( IImplItem const * const pImplItem : implItems ) <nl> { <nl> if ( ! IsParentValid ( parent , g_pEditorImpl - > ImplTypeToSystemType ( pImplItem ) ) ) <nl> { <nl> bool CanDropMimeData ( QMimeData const * const pData , CSystemAsset const & parent ) <nl> void DropMimeData ( QMimeData const * const pData , CSystemAsset * const pParent ) <nl> { <nl> / / Handle first if mime data is an external ( from the implementation side ) source <nl> - std : : vector < CImplItem * > implItems ; <nl> + std : : vector < IImplItem * > implItems ; <nl> SystemModelUtils : : DecodeImplMimeData ( pData , implItems ) ; <nl> <nl> if ( ! implItems . empty ( ) ) <nl> { <nl> CSystemAssetsManager * const pAssetsManager = CAudioControlsEditorPlugin : : GetAssetsManager ( ) ; <nl> <nl> - for ( CImplItem * const pImplControl : implItems ) <nl> + for ( IImplItem * const pImplItem : implItems ) <nl> { <nl> - pAssetsManager - > CreateAndConnectImplItems ( pImplControl , pParent ) ; <nl> + pAssetsManager - > CreateAndConnectImplItems ( pImplItem , pParent ) ; <nl> } <nl> } <nl> else <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / SystemControlsModel . h <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / SystemControlsModel . h <nl> <nl> - / / Copyright 2001 - 2016 Crytek GmbH / Crytek Group . All rights reserved . <nl> + / / Copyright 2001 - 2018 Crytek GmbH / Crytek Group . All rights reserved . <nl> <nl> # pragma once <nl> <nl> class QMimeData ; <nl> <nl> namespace ACE <nl> { <nl> - class CImplItem ; <nl> + struct IImplItem ; <nl> class CSystemControl ; <nl> class CSystemLibrary ; <nl> class CSystemFolder ; <nl> void GetAssetsFromIndexesSeparated ( QModelIndexList const & list , <nl> void GetAssetsFromIndexesCombined ( QModelIndexList const & list , std : : vector < CSystemAsset * > & outAssets ) ; <nl> CSystemAsset * GetAssetFromIndex ( QModelIndex const & index , int const column ) ; <nl> QMimeData * GetDragDropData ( QModelIndexList const & list ) ; <nl> - void DecodeImplMimeData ( const QMimeData * pData , std : : vector < CImplItem * > & outItems ) ; <nl> + void DecodeImplMimeData ( const QMimeData * pData , std : : vector < IImplItem * > & outItems ) ; <nl> } / / namespace SystemModelUtils <nl> <nl> class CSystemSourceModel : public QAbstractItemModel <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / SystemControlsWidget . cpp <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / SystemControlsWidget . cpp <nl> void CSystemControlsWidget : : CreateParentFolder ( ) <nl> <nl> for ( auto const pFolder : folders ) <nl> { <nl> - assetsToMove . emplace_back ( static_cast < CSystemAsset * > ( pFolder ) ) ; <nl> + assetsToMove . push_back ( static_cast < CSystemAsset * > ( pFolder ) ) ; <nl> } <nl> <nl> for ( auto const pControl : controls ) <nl> { <nl> - assetsToMove . emplace_back ( static_cast < CSystemAsset * > ( pControl ) ) ; <nl> + assetsToMove . push_back ( static_cast < CSystemAsset * > ( pControl ) ) ; <nl> } <nl> <nl> auto const pParent = assetsToMove [ 0 ] - > GetParent ( ) ; <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / common / CMakeLists . txt <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / common / CMakeLists . txt <nl> add_sources ( " NoUberFile " <nl> SOURCE_GROUP " Root " <nl> " IEditorImpl . h " <nl> " ImplConnection . h " <nl> - " ImplItem . h " <nl> + " IImplItem . h " <nl> " SystemTypes . h " <nl> ) <nl> <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / common / IEditorImpl . h <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / common / IEditorImpl . h <nl> <nl> <nl> namespace ACE <nl> { <nl> - class CImplItem ; <nl> + struct IImplItem ; <nl> <nl> struct IImplSettings <nl> { <nl> virtual char const * GetAssetsPath ( ) const = 0 ; <nl> virtual char const * GetProjectPath ( ) const = 0 ; <nl> virtual void SetProjectPath ( char const * szPath ) = 0 ; <nl> - virtual bool IsProjectPathEditable ( ) const = 0 ; <nl> + virtual bool SupportsProjects ( ) const = 0 ; <nl> } ; <nl> <nl> struct IEditorImpl <nl> struct IEditorImpl <nl> / / A pointer to the root of the control tree . <nl> / / See Also : <nl> / / GetControl <nl> - virtual CImplItem * GetRoot ( ) = 0 ; <nl> + virtual IImplItem * GetRoot ( ) = 0 ; <nl> <nl> / / < title GetControl > <nl> / / Description : <nl> struct IEditorImpl <nl> / / A pointer to the control that corresponds to the passed id . If none is found NULL is returned . <nl> / / See Also : <nl> / / GetRoot <nl> - virtual CImplItem * GetControl ( CID const id ) const = 0 ; <nl> + virtual IImplItem * GetImplItem ( CID const id ) const = 0 ; <nl> <nl> / / < title GetTypeIcon > <nl> / / Description : <nl> struct IEditorImpl <nl> / / A string with the path to the icon corresponding to the control type <nl> / / See Also : <nl> / / <nl> - virtual char const * GetTypeIcon ( CImplItem const * const pItem ) const = 0 ; <nl> + virtual char const * GetTypeIcon ( IImplItem const * const pItem ) const = 0 ; <nl> <nl> / / < title GetName > <nl> / / Description : <nl> struct IEditorImpl <nl> / / A bool if the types are compatible or not . <nl> / / See Also : <nl> / / ImplTypeToSystemType <nl> - virtual bool IsTypeCompatible ( ESystemItemType const systemType , CImplItem const * const pImplItem ) const = 0 ; <nl> + virtual bool IsTypeCompatible ( ESystemItemType const systemType , IImplItem const * const pImplItem ) const = 0 ; <nl> <nl> / / < title ImplTypeToSystemType > <nl> / / Description : <nl> struct IEditorImpl <nl> / / An audio system control type that corresponds to the middleware control type passed as argument . <nl> / / See Also : <nl> / / GetCompatibleTypes <nl> - virtual ESystemItemType ImplTypeToSystemType ( CImplItem const * const pItem ) const = 0 ; <nl> + virtual ESystemItemType ImplTypeToSystemType ( IImplItem const * const pItem ) const = 0 ; <nl> <nl> / / < title CreateConnectionToControl > <nl> / / Description : <nl> struct IEditorImpl <nl> / / See Also : <nl> / / CreateConnectionFromXMLNode <nl> <nl> - virtual ConnectionPtr CreateConnectionToControl ( ESystemItemType const controlType , CImplItem * const pMiddlewareControl ) = 0 ; <nl> + virtual ConnectionPtr CreateConnectionToControl ( ESystemItemType const controlType , IImplItem * const pMiddlewareControl ) = 0 ; <nl> <nl> / / < title CreateConnectionFromXMLNode > <nl> / / Description : <nl> new file mode 100644 <nl> index 0000000000 . . b259646e5c <nl> mmm / dev / null <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / common / IImplItem . h <nl> <nl> + / / Copyright 2001 - 2018 Crytek GmbH / Crytek Group . All rights reserved . <nl> + <nl> + # pragma once <nl> + <nl> + # include " SystemTypes . h " <nl> + <nl> + # include < CryCore / Platform / platform . h > <nl> + # include < CryString / CryString . h > <nl> + <nl> + namespace ACE <nl> + { <nl> + struct IImplItem <nl> + { <nl> + virtual ~ IImplItem ( ) = default ; <nl> + <nl> + / / ! Returns id of the item . <nl> + virtual CID GetId ( ) const = 0 ; <nl> + <nl> + / / ! Returns type of the item . <nl> + virtual ItemType GetType ( ) const = 0 ; <nl> + <nl> + / / ! Returns name of the item . <nl> + virtual string GetName ( ) const = 0 ; / / char * const ? <nl> + <nl> + / / ! Returns file path of the item . <nl> + / / ! If the item is not a file , an empty path is returned . <nl> + virtual string const & GetFilePath ( ) const = 0 ; <nl> + <nl> + / / ! Returns radius of the item . <nl> + / / ! The radius is used to calculate the activity radius of the connected audio system trigger . <nl> + virtual float GetRadius ( ) const = 0 ; <nl> + <nl> + / / ! Returns the number of children . <nl> + virtual size_t GetNumChildren ( ) const = 0 ; / / NumChilds ? <nl> + <nl> + / / ! Returns a pointer to the child item at the given index . <nl> + / / ! \ param index Index of the child slot . <nl> + virtual IImplItem * GetChildAt ( size_t const index ) const = 0 ; <nl> + <nl> + / / ! Returns a pointer to the parent item . <nl> + virtual IImplItem * GetParent ( ) const = 0 ; <nl> + <nl> + / / ! Returns a bool if the item is a placeholder or not . <nl> + / / ! Placeholders are items that exist as connections in audio system XML files , but not in the middleware project . <nl> + / / ! These placeholders are filtered by the middleware model and are not visible in the middleware tree view . <nl> + virtual bool IsPlaceholder ( ) const = 0 ; <nl> + <nl> + / / ! Returns a bool if the item is localized or not . <nl> + virtual bool IsLocalized ( ) const = 0 ; <nl> + <nl> + / / ! Returns a bool if the item is connected or not . <nl> + virtual bool IsConnected ( ) const = 0 ; <nl> + <nl> + / / ! Returns bool if the item is a container or not . <nl> + virtual bool IsContainer ( ) const = 0 ; <nl> + } ; <nl> + } / / namespace ACE <nl> deleted file mode 100644 <nl> index b4ca4c37fc . . 0000000000 <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / common / ImplItem . h <nl> ppp / dev / null <nl> <nl> - / / Copyright 2001 - 2018 Crytek GmbH / Crytek Group . All rights reserved . <nl> - <nl> - # pragma once <nl> - <nl> - # include " SystemTypes . h " <nl> - <nl> - # include < CryCore / Platform / platform . h > <nl> - # include < CryString / CryString . h > <nl> - <nl> - namespace ACE <nl> - { <nl> - <nl> - enum class EImplItemFlags <nl> - { <nl> - None = 0 , <nl> - IsPlaceHolder = BIT ( 0 ) , <nl> - IsLocalized = BIT ( 1 ) , <nl> - IsModified = BIT ( 2 ) , <nl> - IsConnected = BIT ( 3 ) , <nl> - IsContainer = BIT ( 4 ) , <nl> - } ; <nl> - CRY_CREATE_ENUM_FLAG_OPERATORS ( EImplItemFlags ) ; <nl> - <nl> - class CImplItem <nl> - { <nl> - public : <nl> - <nl> - CImplItem ( ) = default ; <nl> - CImplItem ( string const & name , CID const id , ItemType const type ) <nl> - : m_name ( name ) <nl> - , m_id ( id ) <nl> - , m_type ( type ) <nl> - , m_flags ( EImplItemFlags : : None ) <nl> - , m_filePath ( " " ) <nl> - { <nl> - } <nl> - <nl> - virtual ~ CImplItem ( ) = default ; <nl> - <nl> - / / unique id for this control <nl> - CID GetId ( ) const { return m_id ; } <nl> - <nl> - ItemType GetType ( ) const { return m_type ; } <nl> - <nl> - string GetName ( ) const { return m_name ; } <nl> - <nl> - string const & GetFilePath ( ) const { return m_filePath ; } <nl> - void SetFilePath ( string const & filePath ) { m_filePath = filePath ; } <nl> - <nl> - size_t ChildCount ( ) const { return m_children . size ( ) ; } <nl> - void AddChild ( CImplItem * const pChild ) { m_children . push_back ( pChild ) ; pChild - > SetParent ( this ) ; } <nl> - void RemoveChild ( CImplItem * const pChild ) { stl : : find_and_erase ( m_children , pChild ) ; pChild - > SetParent ( nullptr ) ; } <nl> - CImplItem * GetChildAt ( size_t const index ) const { return m_children [ index ] ; } <nl> - CImplItem * GetParent ( ) const { return m_pParent ; } <nl> - void SetParent ( CImplItem * const pParent ) { m_pParent = pParent ; } <nl> - <nl> - float GetRadius ( ) const { return m_radius ; } <nl> - void SetRadius ( float const radius ) { m_radius = radius ; } <nl> - <nl> - bool IsPlaceholder ( ) const { return ( m_flags & EImplItemFlags : : IsPlaceHolder ) ! = 0 ; } <nl> - bool IsLocalised ( ) const { return ( m_flags & EImplItemFlags : : IsLocalized ) ! = 0 ; } <nl> - bool IsConnected ( ) const { return ( m_flags & EImplItemFlags : : IsConnected ) ! = 0 ; } <nl> - bool IsContainer ( ) const { return ( m_flags & EImplItemFlags : : IsContainer ) ! = 0 ; } <nl> - <nl> - void SetPlaceholder ( bool const isPlaceholder ) <nl> - { <nl> - if ( isPlaceholder ) <nl> - { <nl> - m_flags | = EImplItemFlags : : IsPlaceHolder ; <nl> - } <nl> - else <nl> - { <nl> - m_flags & = ~ EImplItemFlags : : IsPlaceHolder ; <nl> - } <nl> - } <nl> - <nl> - void SetLocalised ( bool const isLocalised ) <nl> - { <nl> - if ( isLocalised ) <nl> - { <nl> - m_flags | = EImplItemFlags : : IsLocalized ; <nl> - } <nl> - else <nl> - { <nl> - m_flags & = ~ EImplItemFlags : : IsLocalized ; <nl> - } <nl> - } <nl> - <nl> - void SetConnected ( bool const isConnected ) <nl> - { <nl> - if ( isConnected ) <nl> - { <nl> - m_flags | = EImplItemFlags : : IsConnected ; <nl> - } <nl> - else <nl> - { <nl> - m_flags & = ~ EImplItemFlags : : IsConnected ; <nl> - } <nl> - } <nl> - <nl> - void SetContainer ( bool const isContainer ) <nl> - { <nl> - if ( isContainer ) <nl> - { <nl> - m_flags | = EImplItemFlags : : IsContainer ; <nl> - } <nl> - else <nl> - { <nl> - m_flags & = ~ EImplItemFlags : : IsContainer ; <nl> - } <nl> - } <nl> - <nl> - private : <nl> - <nl> - CID m_id = ACE_INVALID_ID ; <nl> - ItemType m_type = AUDIO_SYSTEM_INVALID_TYPE ; <nl> - string m_name ; <nl> - string m_filePath ; <nl> - std : : vector < CImplItem * > m_children ; <nl> - CImplItem * m_pParent = nullptr ; <nl> - float m_radius = 0 . 0f ; <nl> - EImplItemFlags m_flags ; <nl> - } ; <nl> - } / / namespace ACE <nl>
! XI ( Audio ) ce / main_stabilisation to ce / main
CRYTEK/CRYENGINE
d9caec6cbf023b543ccafc71ddbef44131b2b91e
2018-02-12T11:23:49Z
mmm a / src / core / base . c <nl> ppp b / src / core / base . c <nl> void swoole_fcntl_set_option ( int sock , int nonblock , int cloexec ) <nl> opts = opts & ~ O_NONBLOCK ; <nl> } <nl> <nl> - # ifdef O_CLOEXEC <nl> + # ifdef FD_CLOEXEC <nl> if ( cloexec ) <nl> { <nl> - opts = opts | O_CLOEXEC ; <nl> + opts = opts | FD_CLOEXEC ; <nl> } <nl> else <nl> { <nl> - opts = opts & ~ O_CLOEXEC ; <nl> + opts = opts & ~ FD_CLOEXEC ; <nl> } <nl> # endif <nl> <nl>
fcntl flag should be FD_CLOEXEC not O_CLOEXEC .
swoole/swoole-src
47b4abdece4327aa92a3b4228e8a2b35ed4a80b7
2017-05-08T11:13:55Z
mmm a / lib / Frontend / CompilerInvocation . cpp <nl> ppp b / lib / Frontend / CompilerInvocation . cpp <nl> static bool ParseFrontendArgs ( FrontendOptions & Opts , ArgList & Args , <nl> } <nl> <nl> case FrontendOptions : : EmitBC : { <nl> - if ( Opts . OutputFilename . empty ( ) ) <nl> - Opts . OutputFilename = " - " ; <nl> - else <nl> - Suffix = " bc " ; <nl> + Suffix = " bc " ; <nl> break ; <nl> } <nl> <nl> static bool ParseFrontendArgs ( FrontendOptions & Opts , ArgList & Args , <nl> else { <nl> / / We have a suffix , so determine an appropriate name . <nl> llvm : : SmallString < 128 > Path ( Opts . OutputFilename ) ; <nl> - <nl> + <nl> StringRef BaseName ; <nl> if ( Opts . PrimaryInput . hasValue ( ) & & Opts . PrimaryInput - > isFilename ( ) ) { <nl> unsigned Index = Opts . PrimaryInput - > Index ; <nl> static bool ParseFrontendArgs ( FrontendOptions & Opts , ArgList & Args , <nl> llvm : : sys : : path : : append ( Path , BaseName ) ; <nl> llvm : : sys : : path : : replace_extension ( Path , Suffix ) ; <nl> <nl> - Opts . OutputFilename = Path . c_str ( ) ; <nl> + Opts . OutputFilename = Path . str ( ) ; <nl> } <nl> } <nl> <nl>
[ driver ] LLVM bitcode is a binary format ; don ' t write it to stdout .
apple/swift
8dc6098104a9a5ea869c05bb09b12f928eb473ed
2014-01-28T03:16:46Z
mmm a / scene / gui / tree . cpp <nl> ppp b / scene / gui / tree . cpp <nl> void Tree : : _gui_input ( Ref < InputEvent > p_event ) { <nl> <nl> Ref < InputEventKey > k = p_event ; <nl> <nl> + bool is_command = k . is_valid ( ) & & k - > get_command ( ) ; <nl> if ( p_event - > is_action ( " ui_right " ) & & p_event - > is_pressed ( ) ) { <nl> <nl> if ( ! cursor_can_exit_tree ) accept_event ( ) ; <nl> void Tree : : _gui_input ( Ref < InputEvent > p_event ) { <nl> _go_left ( ) ; <nl> } <nl> <nl> - } else if ( p_event - > is_action ( " ui_up " ) & & p_event - > is_pressed ( ) & & ! k - > get_command ( ) ) { <nl> + } else if ( p_event - > is_action ( " ui_up " ) & & p_event - > is_pressed ( ) & & ! is_command ) { <nl> <nl> if ( ! cursor_can_exit_tree ) accept_event ( ) ; <nl> <nl> _go_up ( ) ; <nl> <nl> - } else if ( p_event - > is_action ( " ui_down " ) & & p_event - > is_pressed ( ) & & ! k - > get_command ( ) ) { <nl> + } else if ( p_event - > is_action ( " ui_down " ) & & p_event - > is_pressed ( ) & & ! is_command ) { <nl> <nl> if ( ! cursor_can_exit_tree ) accept_event ( ) ; <nl> <nl>
Merge pull request from Faless / fix_joypad_tree_crash
godotengine/godot
b04b83bdcefcbc7e49c68eecd04ffa57175b488b
2018-10-07T16:41:35Z
mmm a / test / functional / feature_fee_estimation . py <nl> ppp b / test / functional / feature_fee_estimation . py <nl> <nl> # Associated ScriptSig ' s to spend satisfy P2SH_1 and P2SH_2 <nl> SCRIPT_SIG = [ CScript ( [ OP_TRUE , REDEEM_SCRIPT_1 ] ) , CScript ( [ OP_TRUE , REDEEM_SCRIPT_2 ] ) ] <nl> <nl> + <nl> def small_txpuzzle_randfee ( from_node , conflist , unconflist , amount , min_fee , fee_increment ) : <nl> " " " Create and send a transaction with a random fee . <nl> <nl> def small_txpuzzle_randfee ( from_node , conflist , unconflist , amount , min_fee , fee <nl> <nl> return ( ToHex ( tx ) , fee ) <nl> <nl> + <nl> def split_inputs ( from_node , txins , txouts , initial_split = False ) : <nl> " " " Generate a lot of inputs so we can generate a ton of transactions . <nl> <nl> def split_inputs ( from_node , txins , txouts , initial_split = False ) : <nl> txouts . append ( { " txid " : txid , " vout " : 0 , " amount " : half_change } ) <nl> txouts . append ( { " txid " : txid , " vout " : 1 , " amount " : rem_change } ) <nl> <nl> + <nl> def check_estimates ( node , fees_seen ) : <nl> " " " Call estimatesmartfee and verify that the estimates meet certain invariants . " " " <nl> <nl> def run_test ( self ) : <nl> split_inputs ( self . nodes [ 0 ] , self . nodes [ 0 ] . listunspent ( 0 ) , self . txouts , True ) <nl> <nl> # Mine <nl> - while ( len ( self . nodes [ 0 ] . getrawmempool ( ) ) > 0 ) : <nl> + while len ( self . nodes [ 0 ] . getrawmempool ( ) ) > 0 : <nl> self . nodes [ 0 ] . generate ( 1 ) <nl> <nl> # Repeatedly split those 2 outputs , doubling twice for each rep <nl> # Use txouts to monitor the available utxo , since these won ' t be tracked in wallet <nl> reps = 0 <nl> - while ( reps < 5 ) : <nl> + while reps < 5 : <nl> # Double txouts to txouts2 <nl> - while ( len ( self . txouts ) > 0 ) : <nl> + while len ( self . txouts ) > 0 : <nl> split_inputs ( self . nodes [ 0 ] , self . txouts , self . txouts2 ) <nl> - while ( len ( self . nodes [ 0 ] . getrawmempool ( ) ) > 0 ) : <nl> + while len ( self . nodes [ 0 ] . getrawmempool ( ) ) > 0 : <nl> self . nodes [ 0 ] . generate ( 1 ) <nl> # Double txouts2 to txouts <nl> - while ( len ( self . txouts2 ) > 0 ) : <nl> + while len ( self . txouts2 ) > 0 : <nl> split_inputs ( self . nodes [ 0 ] , self . txouts2 , self . txouts ) <nl> - while ( len ( self . nodes [ 0 ] . getrawmempool ( ) ) > 0 ) : <nl> + while len ( self . nodes [ 0 ] . getrawmempool ( ) ) > 0 : <nl> self . nodes [ 0 ] . generate ( 1 ) <nl> reps + = 1 <nl> self . log . info ( " Finished splitting " ) <nl> def run_test ( self ) : <nl> self . log . info ( " Final estimates after emptying mempools " ) <nl> check_estimates ( self . nodes [ 1 ] , self . fees_per_kb ) <nl> <nl> + <nl> if __name__ = = ' __main__ ' : <nl> EstimateFeeTest ( ) . main ( ) <nl>
test : Format feature_fee_estimation with pep8
bitcoin/bitcoin
faff85a69a5eb0fdfd8d9a24bc27d1812e49a152
2019-08-02T15:08:07Z
mmm a / arangod / V8Server / ApplicationV8 . cpp <nl> ppp b / arangod / V8Server / ApplicationV8 . cpp <nl> ApplicationV8 : : ApplicationV8 ( TRI_server_t * server , <nl> _useActions ( true ) , <nl> _developmentMode ( false ) , <nl> _frontendDevelopmentMode ( false ) , <nl> + _frontendVersionCheck ( true ) , <nl> _gcInterval ( 1000 ) , <nl> _gcFrequency ( 10 . 0 ) , <nl> _v8Options ( " " ) , <nl> void ApplicationV8 : : setupOptions ( map < string , basics : : ProgramOptionsDescription > <nl> <nl> options [ " Hidden Options " ] <nl> ( " javascript . frontend - development " , & _frontendDevelopmentMode , " allows rebuild frontend assets " ) <nl> + ( " frontend - version - check " , & _frontendVersionCheck , " show new versions in the frontend " ) <nl> <nl> / / deprecated options <nl> ( " javascript . action - directory " , & DeprecatedPath , " path to the JavaScript action directory ( deprecated ) " ) <nl> bool ApplicationV8 : : prepareV8Instance ( const string & name , size_t i , bool useAct <nl> TRI_AddGlobalVariableVocbase ( isolate , localContext , TRI_V8_ASCII_STRING ( " DEV_APP_PATH " ) , TRI_V8_STD_STRING ( _devAppPath ) ) ; <nl> TRI_AddGlobalVariableVocbase ( isolate , localContext , TRI_V8_ASCII_STRING ( " DEVELOPMENT_MODE " ) , v8 : : Boolean : : New ( isolate , _developmentMode ) ) ; <nl> TRI_AddGlobalVariableVocbase ( isolate , localContext , TRI_V8_ASCII_STRING ( " FE_DEVELOPMENT_MODE " ) , v8 : : Boolean : : New ( isolate , _frontendDevelopmentMode ) ) ; <nl> + TRI_AddGlobalVariableVocbase ( isolate , localContext , TRI_V8_ASCII_STRING ( " FE_VERSION_CHECK " ) , v8 : : Boolean : : New ( isolate , _frontendVersionCheck ) ) ; <nl> <nl> for ( auto j : _definedBooleans ) { <nl> localContext - > Global ( ) - > ForceSet ( TRI_V8_STD_STRING ( j . first ) , v8 : : Boolean : : New ( isolate , j . second ) , v8 : : ReadOnly ) ; <nl> mmm a / arangod / V8Server / ApplicationV8 . h <nl> ppp b / arangod / V8Server / ApplicationV8 . h <nl> namespace triagens { <nl> <nl> bool _frontendDevelopmentMode ; <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief enables frontend version check <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + bool _frontendVersionCheck ; <nl> + <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief JavaScript garbage collection interval ( each x requests ) <nl> / / / @ startDocuBlock jsStartupGcInterval <nl> mmm a / js / server / bootstrap / module - internal . js <nl> ppp b / js / server / bootstrap / module - internal . js <nl> <nl> REPLICATION_APPLIER_CONFIGURE , REPLICATION_APPLIER_START , REPLICATION_APPLIER_SHUTDOWN , <nl> REPLICATION_APPLIER_FORGET , REPLICATION_APPLIER_STATE , REPLICATION_SYNCHRONISE , <nl> ENABLE_STATISTICS , DISPATCHER_THREADS , SYS_CREATE_NAMED_QUEUE , SYS_ADD_JOB , <nl> - SYS_RAW_REQUEST_BODY , SYS_REQUEST_PARTS * / <nl> + SYS_RAW_REQUEST_BODY , SYS_REQUEST_PARTS , FE_VERSION_CHECK * / <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief module " internal " <nl> <nl> internal . dispatcherThreads = DISPATCHER_THREADS ; <nl> delete DISPATCHER_THREADS ; <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief frontendVersionCheck <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + internal . frontendVersionCheck = FE_VERSION_CHECK ; <nl> + delete FE_VERSION_CHECK ; <nl> + <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> / / - - SECTION - - private functions <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> mmm a / js / server / modules / org / arangodb / configuration . js <nl> ppp b / js / server / modules / org / arangodb / configuration . js <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> var db = require ( " org / arangodb " ) . db ; <nl> + var internal = require ( " internal " ) ; <nl> <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> / / - - SECTION - - module " org / arangodb / configuration " <nl> exports . notifications . versions = function ( ) { <nl> d . versions = { } ; <nl> } <nl> <nl> + if ( ! internal . frontendVersionCheck ) { <nl> + d . enableVersionNotification = false ; <nl> + } <nl> + <nl> return d . versions ; <nl> } ; <nl> <nl>
added hidden option - - fronend - version - check
arangodb/arangodb
3e35e94a8371d31497a675335b759b31bc32f578
2015-02-10T20:24:24Z
mmm a / src / buffer_cache / mirrored / mirrored . cc <nl> ppp b / src / buffer_cache / mirrored / mirrored . cc <nl> void mc_cache_t : : create ( serializer_t * serializer , mirrored_cache_static_config_t <nl> index_write_op_t op ( SUPERBLOCK_ID ) ; <nl> op . token = serializer - > block_write ( superblock , SUPERBLOCK_ID , DEFAULT_DISK_ACCOUNT ) ; <nl> op . recency = repli_timestamp_t : : invalid ; <nl> - op . delete_bit = false ; / / I ' m not sure why this is necessary , but it is . XXX DO NOT COMMIT <nl> serializer_index_write ( serializer , op , DEFAULT_DISK_ACCOUNT ) ; <nl> <nl> serializer - > free ( superblock ) ; <nl> mmm a / src / buffer_cache / mirrored / patch_disk_storage . cc <nl> ppp b / src / buffer_cache / mirrored / patch_disk_storage . cc <nl> void patch_disk_storage_t : : create ( serializer_t * serializer , block_id_t start_id , <nl> index_write_op_t op ( start_id ) ; <nl> op . token = serializer - > block_write ( c , start_id , DEFAULT_DISK_ACCOUNT ) ; <nl> op . recency = repli_timestamp_t : : invalid ; <nl> - op . delete_bit = false ; <nl> serializer_index_write ( serializer , op , DEFAULT_DISK_ACCOUNT ) ; <nl> <nl> serializer - > free ( c ) ; <nl> mmm a / src / buffer_cache / mock . cc <nl> ppp b / src / buffer_cache / mock . cc <nl> void mock_cache_t : : create ( serializer_t * serializer , UNUSED mirrored_cache_static <nl> index_write_op_t op ( SUPERBLOCK_ID ) ; <nl> op . token = serializer - > block_write ( superblock , SUPERBLOCK_ID , DEFAULT_DISK_ACCOUNT ) ; <nl> op . recency = repli_timestamp_t : : invalid ; <nl> - op . delete_bit = false ; <nl> serializer_index_write ( serializer , op , DEFAULT_DISK_ACCOUNT ) ; <nl> <nl> serializer - > free ( superblock ) ; <nl> mmm a / src / fsck / checker . cc <nl> ppp b / src / fsck / checker . cc <nl> void check_and_load_diff_log ( slicecx_t * cx , diff_log_errors * errs ) { <nl> info = locker . block_info ( ) [ ser_block_id ] ; <nl> } <nl> <nl> - if ( ! info . offset . parts . is_delete ) { <nl> + if ( ! info . offset . get_delete_bit ( ) ) { <nl> block_t b ; <nl> b . init ( cx - > block_size ( ) , cx - > file , info . offset . parts . value , ser_block_id ) ; <nl> { <nl> void check_slice_other_blocks ( slicecx_t * cx , other_block_errors * errs ) { <nl> read_locker_t locker ( cx - > knog ) ; <nl> info = locker . block_info ( ) [ id ] ; <nl> } <nl> + / / TODO ( sam ) : Fix this up for the simpler flagged_off64_t . <nl> if ( info . offset . get_delete_bit ( ) ) { <nl> / / Do nothing . <nl> } else if ( ! info . offset . has_value ( ) ) { <nl> void check_slice_other_blocks ( slicecx_t * cx , other_block_errors * errs ) { <nl> errs - > contiguity_failure = first_valueless_block ; <nl> } <nl> <nl> - if ( ! info . offset . parts . is_delete & & info . block_sequence_id = = NULL_BLOCK_SEQUENCE_ID ) { <nl> + if ( info . block_sequence_id = = NULL_BLOCK_SEQUENCE_ID ) { <nl> / / Aha ! We have an orphan block ! Crap . <nl> rogue_block_description desc ; <nl> desc . block_id = id ; <nl> void check_slice_other_blocks ( slicecx_t * cx , other_block_errors * errs ) { <nl> } <nl> <nl> errs - > orphan_blocks . push_back ( desc ) ; <nl> - } else if ( info . offset . parts . is_delete ) { <nl> - rassert ( info . block_sequence_id = = NULL_BLOCK_SEQUENCE_ID ) ; <nl> - rogue_block_description desc ; <nl> - desc . block_id = id ; <nl> } <nl> } <nl> } <nl> mmm a / src / serializer / log / lba / disk_format . hpp <nl> ppp b / src / serializer / log / lba / disk_format . hpp <nl> union flagged_off64_t { <nl> off64_t whole_value ; <nl> struct { <nl> / / The actual offset into the file . <nl> - off64_t value : 63 ; <nl> - <nl> - / / TODO ( sam ) : Remove is_delete . <nl> - / / This block id was deleted , and the offset points to a zeroed <nl> - / / out buffer . <nl> - int is_delete : 1 ; <nl> + off64_t value ; <nl> } parts ; <nl> <nl> void set_value ( off64_t o ) { <nl> union flagged_off64_t { <nl> return parts . value ; <nl> } <nl> <nl> - void set_delete_bit ( bool b ) { <nl> - rassert ( ! is_padding ( ) ) ; <nl> - if ( b ) parts . is_delete = 1 ; <nl> - else parts . is_delete = 0 ; <nl> - } <nl> bool get_delete_bit ( ) const { <nl> rassert ( ! is_padding ( ) ) ; <nl> - return parts . is_delete ! = 0 ; <nl> + return parts . value < 0 ; <nl> } <nl> <nl> static inline flagged_off64_t padding ( ) { <nl> union flagged_off64_t { <nl> static inline flagged_off64_t unused ( ) { <nl> flagged_off64_t ret ; <nl> ret . whole_value = 0 ; <nl> - ret . set_delete_bit ( true ) ; <nl> ret . remove_value ( ) ; <nl> return ret ; <nl> } <nl> mmm a / src / serializer / log / log_serializer . cc <nl> ppp b / src / serializer / log / log_serializer . cc <nl> void log_serializer_t : : index_write ( const std : : vector < index_write_op_t > & write_op <nl> / * mark the life * / <nl> data_block_manager - > mark_live ( offset . get_value ( ) ) ; <nl> } <nl> - else <nl> + else { <nl> offset . remove_value ( ) ; <nl> + } <nl> } <nl> <nl> - / / Update block info ( delete bit , recency ) <nl> - if ( op . delete_bit ) offset . set_delete_bit ( op . delete_bit . get ( ) ) ; <nl> repli_timestamp_t recency = op . recency ? op . recency . get ( ) <nl> : lba_index - > get_block_recency ( op . block_id ) ; <nl> <nl> mmm a / src / serializer / semantic_checking . tcc <nl> ppp b / src / serializer / semantic_checking . tcc <nl> index_write ( const std : : vector < index_write_op_t > & write_ops , file_account_t * io_a <nl> info = token - > info ; <nl> guarantee ( token - > block_id = = op . block_id , <nl> " indexing token with block id % u under block id % u " , token - > block_id , op . block_id ) ; <nl> + } else { <nl> + info . state = scs_block_info_t : : state_deleted ; <nl> } <nl> } <nl> <nl> - if ( op . delete_bit & & op . delete_bit . get ( ) ) { <nl> - info . state = scs_block_info_t : : state_deleted ; <nl> - # ifdef SERIALIZER_DEBUG_PRINT <nl> - printf ( " Setting delete bit for % u \ n " , op . block_id ) ; <nl> - # endif <nl> - } else if ( info . state = = scs_block_info_t : : state_have_crc ) { <nl> - # ifdef SERIALIZER_DEBUG_PRINT <nl> - printf ( " Indexing under block id % u : % u \ n " , op . block_id , info . crc ) ; <nl> - # endif <nl> - } <nl> - <nl> / / Update the info and add it to the semantic checker file . <nl> update_block_info ( op . block_id , info ) ; <nl> / / Add possibly modified op to the op vector <nl> mmm a / src / serializer / serializer . cc <nl> ppp b / src / serializer / serializer . cc <nl> struct write_performer_t : public boost : : static_visitor < void > { <nl> op - > token = serializer - > block_write ( update . buf , op - > block_id , io_account , block_write_conds - > back ( ) ) ; <nl> if ( update . launch_callback ) <nl> update . launch_callback - > on_write_launched ( op - > token . get ( ) ) ; <nl> - op - > delete_bit = false ; <nl> op - > recency = update . recency ; <nl> } <nl> <nl> void operator ( ) ( UNUSED const serializer_t : : write_t : : delete_t & del ) { <nl> op - > token = boost : : intrusive_ptr < standard_block_token_t > ( ) ; <nl> - op - > delete_bit = true ; <nl> op - > recency = repli_timestamp_t : : invalid ; <nl> } <nl> <nl> mmm a / src / serializer / serializer . hpp <nl> ppp b / src / serializer / serializer . hpp <nl> struct index_write_op_t { <nl> / / Buf to write . None if not to be modified . Initialized but a null ptr if to be removed from lba . <nl> boost : : optional < boost : : intrusive_ptr < standard_block_token_t > > token ; <nl> boost : : optional < repli_timestamp_t > recency ; / / Recency , if it should be modified . <nl> - boost : : optional < bool > delete_bit ; / / Delete bit , if it should be modified . <nl> <nl> index_write_op_t ( block_id_t _block_id , <nl> boost : : optional < boost : : intrusive_ptr < standard_block_token_t > > _token = boost : : none , <nl> - boost : : optional < repli_timestamp_t > _recency = boost : : none , <nl> - boost : : optional < bool > _delete_bit = boost : : none ) <nl> - : block_id ( _block_id ) , token ( _token ) , recency ( _recency ) , delete_bit ( _delete_bit ) { } <nl> + boost : : optional < repli_timestamp_t > _recency = boost : : none ) <nl> + : block_id ( _block_id ) , token ( _token ) , recency ( _recency ) { } <nl> } ; <nl> <nl> / * serializer_t is an abstract interface that describes how each serializer should <nl> mmm a / src / serializer / translator . cc <nl> ppp b / src / serializer / translator . cc <nl> void prep_serializer ( <nl> index_write_op_t op ( CONFIG_BLOCK_ID . ser_id ) ; <nl> op . token = ser - > block_write ( c , CONFIG_BLOCK_ID . ser_id , DEFAULT_DISK_ACCOUNT ) ; <nl> op . recency = repli_timestamp_t : : invalid ; <nl> - op . delete_bit = false ; <nl> serializer_index_write ( ser , op , DEFAULT_DISK_ACCOUNT ) ; <nl> <nl> ser - > free ( c ) ; <nl> mmm a / src / unittest / disk_format_test . cc <nl> ppp b / src / unittest / disk_format_test . cc <nl> TEST ( DiskFormatTest , FlaggedOff64T ) { <nl> off64_t off = offs [ i ] ; <nl> flagged_off64_t real = flagged_off64_t : : unused ( ) ; <nl> real . set_value ( off ) ; <nl> - real . set_delete_bit ( false ) ; <nl> flagged_off64_t deleteblock = flagged_off64_t : : unused ( ) ; <nl> deleteblock . set_value ( off ) ; <nl> - deleteblock . set_delete_bit ( true ) ; <nl> EXPECT_TRUE ( real . has_value ( ) ) ; <nl> EXPECT_TRUE ( deleteblock . has_value ( ) ) ; <nl> EXPECT_FALSE ( real . is_padding ( ) ) ; <nl> EXPECT_FALSE ( deleteblock . is_padding ( ) ) ; <nl> - EXPECT_FALSE ( real . parts . is_delete ) ; <nl> - EXPECT_TRUE ( deleteblock . parts . is_delete ) ; <nl> <nl> real . parts . value = 73 ; <nl> deleteblock . parts . value = 95 ; <nl> TEST ( DiskFormatTest , FlaggedOff64T ) { <nl> EXPECT_TRUE ( deleteblock . has_value ( ) ) ; <nl> EXPECT_FALSE ( real . is_padding ( ) ) ; <nl> EXPECT_FALSE ( deleteblock . is_padding ( ) ) ; <nl> - EXPECT_FALSE ( real . parts . is_delete ) ; <nl> - EXPECT_TRUE ( deleteblock . parts . is_delete ) ; <nl> } <nl> <nl> <nl> TEST ( DiskFormatTest , LbaEntryT ) { <nl> ASSERT_TRUE ( lba_entry_t : : is_padding ( & ent ) ) ; <nl> flagged_off64_t real = flagged_off64_t : : unused ( ) ; <nl> real . set_value ( 1 ) ; <nl> - real . set_delete_bit ( false ) ; <nl> ent = lba_entry_t : : make ( 1 , repli_timestamp_t : : invalid , real ) ; <nl> ASSERT_FALSE ( lba_entry_t : : is_padding ( & ent ) ) ; <nl> flagged_off64_t deleteblock = flagged_off64_t : : unused ( ) ; <nl> deleteblock . set_value ( 1 ) ; <nl> - deleteblock . set_delete_bit ( true ) ; <nl> ent = lba_entry_t : : make ( 1 , repli_timestamp_t : : invalid , deleteblock ) ; <nl> ASSERT_FALSE ( lba_entry_t : : is_padding ( & ent ) ) ; <nl> } <nl>
Removed the is_delete field from flagged_off64_t , albeit with some ugliness .
rethinkdb/rethinkdb
fae25bca298ce6b8d37465043e476667992ccaed
2011-08-26T23:16:54Z
mmm a / js / apps / system / aardvark / frontend / js / models / graph . js <nl> ppp b / js / apps / system / aardvark / frontend / js / models / graph . js <nl> <nl> <nl> idAttribute : " _key " , <nl> <nl> - url : function ( ) { <nl> - if ( this . isNew ( ) ) { <nl> - return " / _api / graph / " ; <nl> - } else { <nl> - return " / _api / graph / " + this . get ( " _key " ) ; <nl> - } <nl> + urlRoot : " / _api / graph " , <nl> + <nl> + isNew : function ( ) { <nl> + return ! this . get ( " _id " ) ; <nl> + } , <nl> + <nl> + parse : function ( raw ) { <nl> + return raw . graph | | raw ; <nl> } , <nl> <nl> defaults : { <nl> mmm a / js / apps / system / aardvark / frontend / js / routers / router . js <nl> ppp b / js / apps / system / aardvark / frontend / js / routers / router . js <nl> <nl> } , <nl> <nl> graphAddNew : function ( ) { <nl> - <nl> + if ( ! this . addNewGraphView ) { <nl> + this . addNewGraphView = new window . AddNewGraphView ( { <nl> + collection : window . arangoCollectionsStore , <nl> + graphs : this . graphs <nl> + } ) ; <nl> + } <nl> + this . addNewGraphView . render ( ) ; <nl> + this . naviView . selectMenuItem ( ' graphviewer - menu ' ) ; <nl> } , <nl> <nl> applications : function ( ) { <nl> mmm a / js / apps / system / aardvark / frontend / js / templates / addNewGraphView . ejs <nl> ppp b / js / apps / system / aardvark / frontend / js / templates / addNewGraphView . ejs <nl> <nl> - < % var appInfos = attributes . app . split ( " : " ) ; % > <nl> - < div id = " change - foxx " class = " modal hide fade " tabindex = " - 1 " role = " dialog " aria - labelledby = " myModalLabel " aria - hidden = " true " style = " display : none " > <nl> + < div id = " add - graph " class = " modal hide fade " tabindex = " - 1 " role = " dialog " aria - labelledby = " myModalLabel " aria - hidden = " true " style = " display : none " > <nl> < div class = " modal - header " > <nl> < button type = " button " class = " close " data - dismiss = " modal " aria - hidden = " true " > × < / button > <nl> - < a class = " arangoHeader " > Modify Application < / a > <nl> + < a class = " arangoHeader " > Add new Graph < / a > <nl> < / div > <nl> < div class = " modal - body " > <nl> < table > <nl> < tr > <nl> < th class = " collectionTh " > Name : < / th > <nl> - < th class = " collectionTh " > < strong > < % = appInfos [ 1 ] % > < / strong > < / th > <nl> + < th class = " collectionTh " > < input type = " text " id = " newGraphName " placeholder = " graphName " > < / input > < / th > <nl> + < th > < a class = " modalTooltips " title = " The name to identify the graph . Has to be unique . " > < i class = " icon - info - sign " > < / i > < / a > < / th > <nl> < / tr > <nl> < tr > <nl> - < th class = " collectionTh " > & nbsp ; < / th > <nl> - < th class = " collectionTh " > & nbsp ; < / th > <nl> + < th class = " collectionTh " > Vertices : < / th > <nl> + < th class = " collectionTh " > < input type = " text " id = " newGraphVertices " placehilder = " Vertex Collection > " > < / input > < / th > <nl> + < th > < a class = " modalTooltips " title = " The path name of the document collection that should be used as vertices . If this does not exists it will be created . " > < i class = " icon - info - sign " > < / i > < / a > < / th > <nl> < / tr > <nl> < tr > <nl> - < th class = " collectionTh " > Mount : < / th > <nl> - < th class = " collectionTh " > < input type = " text " id = " change - mount - point " name = " mountpoint " value = " < % = attributes . mount % > " / > < / th > <nl> - < th > < a class = " modalTooltips " title = " The path where the app can be reached . " > < i class = " icon - info - sign " > < / i > < / a > < / th > <nl> - < / tr > <nl> - < tr > <nl> - < th class = " collectionTh " > Version : < / th > <nl> - < th class = " collectionTh " > <nl> - < select > <nl> - < option selected > < % = appInfos [ 2 ] % > < / option > <nl> - < / select > <nl> - < th > <nl> - < / tr > <nl> - < tr > <nl> - < th class = " collectionTh " > System : < / th > <nl> - < th class = " collectionTh " > <nl> - < % = attributes . isSystem ? " Yes " : " No " % > <nl> - < th > <nl> - < / tr > <nl> - < tr > <nl> - < th class = " collectionTh " > Status : < / th > <nl> - < th class = " collectionTh " > <nl> - < % if ( attributes . active ) { % > <nl> - < div class = " modal - text active " > <nl> - Active <nl> - < / div > <nl> - < % } else { % > <nl> - < div class = " modal - text inactive " > <nl> - Inactive <nl> - < / div > <nl> - < % } % > <nl> - < / th > <nl> + < th class = " collectionTh " > Edges : < / th > <nl> + < th class = " collectionTh " > < input type = " text " id = " newGraphEdges " placehilder = " Edge Collection > " > < / input > < / th > <nl> + < th > < a class = " modalTooltips " title = " The path name of the edge collection that should be used as edges . If this does not exists it will be created . " > < i class = " icon - info - sign " > < / i > < / a > < / th > <nl> < / tr > <nl> < / table > <nl> < / div > <nl> - < div id = " colFooter " class = " modal - footer " > <nl> - < button id = " uninstall " class = " btn btn - danger " < % = ( attributes . isSystem | | attributes . development ) ? " disabled " : " " % > > Uninstall < / button > <nl> - < button id = " change " class = " btn btn - success pull - right " > Save < / button > <nl> - < % if ( false & & attributes . active ) { % > <nl> - < button id = " deactivate " class = " btn btn - warning pull - right " style = " margin - right : 8px " disabled > Deactivate < / button > <nl> - < % } else if ( false ) { % > <nl> - < button id = " activate " class = " btn btn - success pull - right " style = " margin - right : 8px " disabled > Activate < / button > <nl> - < % } % > <nl> - <nl> + < div class = " modal - footer " > <nl> + < button id = " cancel " class = " btn btn - warning " > Cancel < / button > <nl> + < button id = " createGraph " class = " btn btn - success pull - right " > Create < / button > <nl> < / div > <nl> < / div > <nl> mmm a / js / apps / system / aardvark / frontend / js / templates / manageGraphsView . ejs <nl> ppp b / js / apps / system / aardvark / frontend / js / templates / manageGraphsView . ejs <nl> <nl> < ul class = " thumbnails2 " > <nl> < div id = " transparentHeader " > <nl> - < div id = " graphManagerToolbar " class = " pagination pagination - small pagination - right " > <nl> + < div id = " graphManagerToolbar " class = " pagination pagination - small pagination - right " style = " display : none ; " > <nl> < ul > < li class = " enabled " > < a id = " filterGraphs " > < span class = " glyphicon glyphicon - filter " title = " Filter graphs " > < / span > < / a > < / li > < / ul > <nl> < / div > <nl> < / div > <nl> <nl> < / div > <nl> <nl> < div id = " graphManagementDiv " > <nl> + < div id = " graphTable_wrapper " class = " dataTables_wrapper " role = " grid " > <nl> <nl> - < table cellpadding = " 0 " cellspacing = " 0 " border = " 0 " class = " display " id = " graphsTable " > <nl> - < thead > <nl> - < tr > <nl> - < th > Name < / th > <nl> - < th > Vertices < / th > <nl> - < th > Edges < / th > <nl> - < th > <nl> - < a id = " addGraphButton " class = " pull - right " > < span class = " glyphicon glyphicon - plus - sign " title = " Add a graph " > < / span > < / a > <nl> - < / th > <nl> - < / tr > <nl> - < / thead > <nl> - < tbody > <nl> - < % <nl> - var odd = true ; <nl> - graphs . each ( function ( g ) { <nl> - % > <nl> - < tr class = " < % = odd ? ' odd ' : ' even ' % > " > <nl> - < td > < % = g . get ( " _key " ) % > < / td > <nl> - < td > < % = g . get ( " vertices " ) % > < / td > <nl> - < td > < % = g . get ( " edges " ) % > < / td > <nl> - < td class = " docsThirdCol " > <nl> - < a class = " deleteGraph " id = " < % = g . get ( ' _key ' ) % > " > <nl> - < span class = " glyphicon glyphicon - minus - sign " data - original - title = " Delete document " > < / span > <nl> - < / a > <nl> - < / td > <nl> - < / tr > <nl> + < table cellpadding = " 0 " cellspacing = " 0 " border = " 0 " class = " display dataTable dataTable - fixed " id = " graphsTable " > <nl> + < thead > <nl> + < tr > <nl> + < th > Name < / th > <nl> + < th > Vertices < / th > <nl> + < th > Edges < / th > <nl> + < th > <nl> + < a id = " addGraphButton " class = " pull - right " > < span class = " glyphicon glyphicon - plus - sign " title = " Add a graph " > < / span > < / a > <nl> + < / th > <nl> + < / tr > <nl> + < / thead > <nl> + < tbody > <nl> < % <nl> - odd = ! odd ; <nl> - } ) ; <nl> - % > <nl> - < / tbody > <nl> - < / tbody > <nl> - < / table > <nl> + var odd = true ; <nl> + graphs . each ( function ( g ) { <nl> + % > <nl> + < tr class = " < % = odd ? ' odd ' : ' even ' % > " > <nl> + < td > < % = g . get ( " _key " ) % > < / td > <nl> + < td > < % = g . get ( " vertices " ) % > < / td > <nl> + < td > < % = g . get ( " edges " ) % > < / td > <nl> + < td class = " docsThirdCol " > <nl> + < a class = " deleteGraph " id = " < % = g . get ( ' _key ' ) % > " > <nl> + < span class = " glyphicon glyphicon - minus - sign " data - original - title = " Delete document " > < / span > <nl> + < / a > <nl> + < / td > <nl> + < / tr > <nl> + < % <nl> + odd = ! odd ; <nl> + } ) ; <nl> + % > <nl> + < / tbody > <nl> + < / tbody > <nl> + < / table > <nl> + < / div > <nl> <nl> < div id = " documentsToolbarFL " > <nl> < div id = " documentsToolbarF " class = " pagination pagination - small pagination - centered " > <nl> mmm a / js / apps / system / aardvark / frontend / js / views / addNewGraphView . js <nl> ppp b / js / apps / system / aardvark / frontend / js / views / addNewGraphView . js <nl> <nl> el : ' # modalPlaceholder ' , <nl> template : templateEngine . createTemplate ( " addNewGraphView . ejs " ) , <nl> <nl> - initilize : function ( ) { <nl> + initialize : function ( ) { <nl> this . graphs = this . options . graphs ; <nl> } , <nl> <nl> events : { <nl> + " click # cancel " : " hide " , <nl> + " hidden " : " hidden " , <nl> + " click # createGraph " : " createGraph " <nl> + } , <nl> + <nl> + createGraph : function ( ) { <nl> + this . graphs . create ( { <nl> + _key : $ ( " # newGraphName " ) . val ( ) , <nl> + vertices : $ ( " # newGraphVertices " ) . val ( ) , <nl> + edges : $ ( " # newGraphEdges " ) . val ( ) <nl> + } ) ; <nl> + this . hide ( ) ; <nl> + } , <nl> + <nl> + hide : function ( ) { <nl> + $ ( ' # add - graph ' ) . modal ( ' hide ' ) ; <nl> + } , <nl> + <nl> + hidden : function ( ) { <nl> + this . undelegateEvents ( ) ; <nl> + window . App . navigate ( " graphManagement " , { trigger : true } ) ; <nl> } , <nl> <nl> render : function ( ) { <nl> <nl> collections : this . collection , <nl> graphs : this . graphs <nl> } ) ) ; <nl> - $ ( ' # change - foxx ' ) . modal ( ' show ' ) ; <nl> + $ ( ' # add - graph ' ) . modal ( ' show ' ) ; <nl> $ ( ' . modalTooltips ' ) . tooltip ( { <nl> placement : " left " <nl> } ) ; <nl> mmm a / js / apps / system / aardvark / frontend / js / views / graphManagementView . js <nl> ppp b / js / apps / system / aardvark / frontend / js / views / graphManagementView . js <nl> <nl> } , <nl> <nl> deleteGraph : function ( e ) { <nl> - var key = e . target . id ; <nl> + var key = $ ( e . target ) . closest ( " a " ) . attr ( " id " ) , <nl> + self = this ; <nl> / / Ask user for permission <nl> - this . collection . get ( key ) . destroy ( ) ; <nl> + this . collection . get ( key ) . destroy ( { <nl> + success : function ( ) { <nl> + self . render ( ) ; <nl> + } <nl> + } ) ; <nl> } , <nl> <nl> render : function ( ) { <nl> new file mode 100644 <nl> index 00000000000 . . e09831f09e2 <nl> mmm / dev / null <nl> ppp b / js / apps / system / aardvark / test / specs / models / graphSpec . js <nl> <nl> + / * jslint indent : 2 , nomen : true , maxlen : 100 , white : true plusplus : true , browser : true * / <nl> + / * global describe , beforeEach , afterEach , it , spyOn , expect * / <nl> + / * global $ * / <nl> + <nl> + ( function ( ) { <nl> + " use strict " ; <nl> + <nl> + describe ( " The current database " , function ( ) { <nl> + <nl> + var model , myKey , ajaxVerify , server_result , e , v ; <nl> + <nl> + beforeEach ( function ( ) { <nl> + myKey = " graph " ; <nl> + e = " e " ; <nl> + v = " v " ; <nl> + server_result = { <nl> + graph : { <nl> + _id : " _graph / " + myKey , <nl> + _key : myKey , <nl> + _rev : " 123541 " , <nl> + edges : e , <nl> + vertices : v <nl> + } , <nl> + code : 201 , <nl> + error : false <nl> + } ; <nl> + ajaxVerify = function ( ) { } ; <nl> + spyOn ( $ , " ajax " ) . andCallFake ( function ( opt ) { <nl> + ajaxVerify ( opt ) ; <nl> + opt . success ( server_result ) ; <nl> + } ) ; <nl> + model = new window . Graph ( { <nl> + _key : myKey , <nl> + vertices : v , <nl> + edges : e <nl> + } ) ; <nl> + } ) ; <nl> + <nl> + it ( " should request / _api / graph on save " , function ( ) { <nl> + ajaxVerify = function ( opt ) { <nl> + expect ( opt . url ) . toEqual ( " / _api / graph " ) ; <nl> + expect ( opt . type ) . toEqual ( " POST " ) ; <nl> + } ; <nl> + model . save ( ) ; <nl> + expect ( $ . ajax ) . toHaveBeenCalled ( ) ; <nl> + } ) ; <nl> + <nl> + it ( " should store the attributes in the model " , function ( ) { <nl> + var id = " _graph / " + myKey , <nl> + rev = " 12345 " ; <nl> + server_result . graph . _id = id ; <nl> + server_result . graph . _rev = rev ; <nl> + model . save ( ) ; <nl> + expect ( model . get ( " _id " ) ) . toEqual ( id ) ; <nl> + expect ( model . get ( " _rev " ) ) . toEqual ( rev ) ; <nl> + expect ( model . get ( " _key " ) ) . toEqual ( myKey ) ; <nl> + expect ( model . get ( " edges " ) ) . toEqual ( e ) ; <nl> + expect ( model . get ( " vertices " ) ) . toEqual ( v ) ; <nl> + expect ( model . get ( " error " ) ) . toBeUndefined ( ) ; <nl> + expect ( model . get ( " code " ) ) . toBeUndefined ( ) ; <nl> + expect ( model . get ( " graph " ) ) . toBeUndefined ( ) ; <nl> + <nl> + } ) ; <nl> + <nl> + it ( " should request / _api / graph / _key on delete " , function ( ) { <nl> + model . save ( ) ; <nl> + ajaxVerify = function ( opt ) { <nl> + expect ( opt . url ) . toEqual ( " / _api / graph / " + myKey ) ; <nl> + expect ( opt . type ) . toEqual ( " DELETE " ) ; <nl> + } ; <nl> + model . destroy ( ) ; <nl> + expect ( $ . ajax ) . toHaveBeenCalled ( ) ; <nl> + } ) ; <nl> + <nl> + } ) ; <nl> + <nl> + } ( ) ) ; <nl> mmm a / js / apps / system / aardvark / test / specs / router / routerSpec . js <nl> ppp b / js / apps / system / aardvark / test / specs / router / routerSpec . js <nl> <nl> var <nl> jQueryDummy , <nl> fakeDB , <nl> + graphDummy , <nl> storeDummy , <nl> naviDummy , <nl> footerDummy , <nl> documentDummy , <nl> documentsDummy , <nl> sessionDummy , <nl> - graphDummy , <nl> + graphsDummy , <nl> logsDummy ; <nl> <nl> / / Spy on all views that are initialized by startup <nl> beforeEach ( function ( ) { <nl> naviDummy = { <nl> + id : " navi " , <nl> render : function ( ) { } , <nl> - handleResize : function ( ) { } <nl> + handleResize : function ( ) { } , <nl> + selectMenuItem : function ( ) { } <nl> } ; <nl> footerDummy = { <nl> + id : " footer " , <nl> render : function ( ) { } , <nl> handleResize : function ( ) { } <nl> } ; <nl> - documentDummy = { } ; <nl> - documentsDummy = { } ; <nl> + documentDummy = { id : " document " } ; <nl> + documentsDummy = { id : " documents " } ; <nl> graphDummy = { <nl> + id : " graph " , <nl> handleResize : function ( ) { } <nl> } ; <nl> - storeDummy = { fetch : function ( ) { } } ; <nl> - logsDummy = { fetch : function ( ) { } } ; <nl> - fakeDB = { fetch : function ( ) { } } ; <nl> + storeDummy = { <nl> + id : " store " , <nl> + fetch : function ( ) { } <nl> + } ; <nl> + graphsDummy = { id : " graphs " } ; <nl> + logsDummy = { <nl> + id : " logs " , <nl> + fetch : function ( ) { } <nl> + } ; <nl> + fakeDB = { <nl> + id : " fakeDB " , <nl> + fetch : function ( ) { } <nl> + } ; <nl> jQueryDummy = { <nl> + id : " jquery " , <nl> resize : function ( ) { } , <nl> width : function ( ) { } , <nl> height : function ( ) { } , <nl> <nl> spyOn ( window , " ArangoSession " ) . andReturn ( sessionDummy ) ; <nl> spyOn ( window , " arangoDocuments " ) . andReturn ( documentsDummy ) ; <nl> spyOn ( window , " arangoDocument " ) . andReturn ( documentDummy ) ; <nl> + spyOn ( window , " GraphCollection " ) . andReturn ( graphsDummy ) ; <nl> spyOn ( window , " CollectionsView " ) ; <nl> spyOn ( window , " CollectionView " ) ; <nl> spyOn ( window , " CollectionInfoView " ) ; <nl> <nl> spyOn ( footerDummy , " render " ) ; <nl> spyOn ( window , " NavigationView " ) . andReturn ( naviDummy ) ; <nl> spyOn ( naviDummy , " render " ) ; <nl> + spyOn ( naviDummy , " selectMenuItem " ) ; <nl> spyOn ( window , " GraphView " ) . andReturn ( graphDummy ) ; <nl> spyOn ( window , " $ " ) . andReturn ( jQueryDummy ) ; <nl> spyOn ( jQueryDummy , " resize " ) . andCallFake ( function ( ) { <nl> <nl> <nl> it ( " should create a graph view " , function ( ) { <nl> expect ( window . GraphView ) . toHaveBeenCalledWith ( { <nl> - collection : storeDummy <nl> + collection : storeDummy , <nl> + graphs : graphsDummy <nl> } ) ; <nl> } ) ; <nl> <nl> <nl> expect ( fakeDB . fetch ) . toHaveBeenCalled ( ) ; <nl> } ) ; <nl> } ) ; <nl> + <nl> + describe ( " navigation " , function ( ) { <nl> + <nl> + var r ; <nl> + <nl> + beforeEach ( function ( ) { <nl> + r = new window . Router ( ) ; <nl> + } ) ; <nl> + <nl> + it ( " should offer the add new graph view " , function ( ) { <nl> + var route = r . routes [ " graphManagement / add " ] , <nl> + view = { render : function ( ) { } } ; <nl> + expect ( route ) . toBeDefined ( ) ; <nl> + spyOn ( window , " AddNewGraphView " ) . andReturn ( view ) ; <nl> + spyOn ( view , " render " ) ; <nl> + r [ route ] ( ) ; <nl> + expect ( window . AddNewGraphView ) . toHaveBeenCalledWith ( { <nl> + collection : storeDummy , <nl> + graphs : graphsDummy <nl> + } ) ; <nl> + expect ( view . render ) . toHaveBeenCalled ( ) ; <nl> + expect ( naviDummy . selectMenuItem ) . toHaveBeenCalledWith ( " graphviewer - menu " ) ; <nl> + } ) ; <nl> + <nl> + } ) ; <nl> } ) ; <nl> } ( ) ) ; <nl> mmm a / js / apps / system / aardvark / test / specs / views / graphManagementViewSpec . js <nl> ppp b / js / apps / system / aardvark / test / specs / views / graphManagementViewSpec . js <nl> <nl> <nl> it ( " should be able to delete " , function ( ) { <nl> var lg = graphs . get ( " g3 " ) ; <nl> - spyOn ( lg , " destroy " ) ; <nl> - $ ( " # " + g3 . _key ) . click ( ) ; <nl> + spyOn ( lg , " destroy " ) . andCallFake ( function ( opt ) { <nl> + opt . success ( ) ; <nl> + } ) ; <nl> + spyOn ( view , " render " ) ; <nl> + $ ( " # " + g3 . _key + " > span " ) . click ( ) ; <nl> expect ( lg . destroy ) . toHaveBeenCalled ( ) ; <nl> + expect ( view . render ) . toHaveBeenCalled ( ) ; <nl> } ) ; <nl> <nl> } ) ; <nl> mmm a / js / apps / system / aardvark / test / specs / views / graphViewSpec . js <nl> ppp b / js / apps / system / aardvark / test / specs / views / graphViewSpec . js <nl> <nl> expect ( templateEngine . createTemplate ) . toHaveBeenCalledWith ( " graphViewGroupByEntry . ejs " ) ; <nl> } ) ; <nl> <nl> - it ( " should setup a new graph collection " , function ( ) { <nl> - spyOn ( window , " GraphCollection " ) ; <nl> - view = new GraphView ( ) ; <nl> - expect ( window . GraphCollection ) . toHaveBeenCalled ( ) ; <nl> - } ) ; <nl> - <nl> - it ( " should setup a graph management view " , function ( ) { <nl> - spyOn ( window , " GraphManagementView " ) ; <nl> - view = new GraphView ( ) ; <nl> - expect ( window . GraphManagementView ) . toHaveBeenCalled ( ) ; <nl> - } ) ; <nl> - <nl> describe ( " after view creation " , function ( ) { <nl> <nl> var graphs , g1 , g2 , v1 , v2 , e1 , e2 , <nl> <nl> return graphs ; <nl> } ) ; <nl> view = new GraphView ( { <nl> - collection : myStore <nl> + collection : myStore , <nl> + graphs : graphs <nl> } ) ; <nl> spyOn ( $ , " ajax " ) . andCallFake ( function ( opts ) { <nl> throw " Test not implemented " ; <nl> <nl> <nl> describe ( " Graph Management " , function ( ) { <nl> <nl> - it ( " should load the view " , function ( ) { <nl> - spyOn ( view . managementView , " render " ) ; <nl> + it ( " should navigate to the management view " , function ( ) { <nl> + spyOn ( window . App , " navigate " ) ; <nl> $ ( " # manageGraphs " ) . click ( ) ; <nl> - expect ( view . managementView . render ) . toHaveBeenCalled ( ) ; <nl> + expect ( window . App . navigate ) . toHaveBeenCalledWith ( " graphManagement " , { trigger : true } ) ; <nl> } ) ; <nl> } ) ; <nl> <nl>
Functionality of the graph management implemented . CSS to go
arangodb/arangodb
103f36f223c6f5acdb2ded73e930e63b439ea03b
2013-11-29T13:51:48Z
mmm a / src / objects / objects . cc <nl> ppp b / src / objects / objects . cc <nl> Maybe < bool > JSArray : : ArraySetLength ( Isolate * isolate , Handle < JSArray > a , <nl> new_len_desc , should_throw ) ; <nl> } <nl> / / 13 . If oldLenDesc . [ [ Writable ] ] is false , return false . <nl> - if ( ! old_len_desc . writable ( ) ) { <nl> + if ( ! old_len_desc . writable ( ) | | <nl> + / / Also handle the { configurable : true } case since we later use <nl> + / / JSArray : : SetLength instead of OrdinaryDefineOwnProperty to change <nl> + / / the length , and it doesn ' t have access to the descriptor anymore . <nl> + new_len_desc - > configurable ( ) ) { <nl> RETURN_FAILURE ( isolate , GetShouldThrow ( isolate , should_throw ) , <nl> NewTypeError ( MessageTemplate : : kRedefineDisallowed , <nl> isolate - > factory ( ) - > length_string ( ) ) ) ; <nl> new file mode 100644 <nl> index 00000000000 . . b9db175a560 <nl> mmm / dev / null <nl> ppp b / test / mjsunit / regress / regress - v8 - 9460 . js <nl> <nl> + / / Copyright 2019 the V8 project authors . All rights reserved . <nl> + / / Use of this source code is governed by a BSD - style license that can be <nl> + / / found in the LICENSE file . <nl> + <nl> + var arr = [ 0 , 1 ] ; <nl> + <nl> + assertThrows ( <nl> + ( ) = > Object . defineProperty ( arr , ' length ' , { value : 1 , configurable : true } ) , <nl> + TypeError ) ; <nl> + assertEquals ( 2 , arr . length ) ; <nl> + <nl> + assertThrows ( <nl> + ( ) = > Object . defineProperty ( arr , ' length ' , { value : 2 , configurable : true } ) , <nl> + TypeError ) ; <nl> + assertEquals ( 2 , arr . length ) ; <nl> + <nl> + assertThrows ( <nl> + ( ) = > Object . defineProperty ( arr , ' length ' , { value : 3 , configurable : true } ) , <nl> + TypeError ) ; <nl> + assertEquals ( 2 , arr . length ) ; <nl>
[ runtime ] Always throw when asked to make an array ' s length configurable
v8/v8
40624b5b41b775e52ff165d2cd8fd060fdcfdf8d
2019-07-22T17:16:10Z
mmm a / python / taichi / lang / expr . py <nl> ppp b / python / taichi / lang / expr . py <nl> def initialize_accessor ( self ) : <nl> return <nl> snode = self . ptr . snode ( ) <nl> <nl> - if self . snode ( ) . data_type ( ) = = f32 or self . snode ( ) . data_type ( ) = = f64 : <nl> + if self . dtype = = f32 or self . dtype = = f64 : <nl> <nl> def getter ( * key ) : <nl> assert len ( key ) = = taichi_lang_core . get_max_num_indices ( ) <nl> def setter ( value , * key ) : <nl> assert len ( key ) = = taichi_lang_core . get_max_num_indices ( ) <nl> snode . write_float ( key , value ) <nl> else : <nl> - if taichi_lang_core . is_signed ( self . snode ( ) . data_type ( ) ) : <nl> + if taichi_lang_core . is_signed ( self . dtype ) : <nl> <nl> def getter ( * key ) : <nl> assert len ( key ) = = taichi_lang_core . get_max_num_indices ( ) <nl> def shape ( self ) : <nl> def dim ( self ) : <nl> return len ( self . shape ) <nl> <nl> + @ property <nl> + def dtype ( self ) : <nl> + return self . snode ( ) . dtype <nl> + <nl> + @ deprecated ( ' x . data_type ( ) ' , ' x . dtype ' ) <nl> def data_type ( self ) : <nl> - return self . snode ( ) . data_type ( ) <nl> + return self . snode ( ) . dtype <nl> <nl> @ python_scope <nl> def to_numpy ( self ) : <nl> from . meta import tensor_to_ext_arr <nl> import numpy as np <nl> - arr = np . zeros ( shape = self . shape , <nl> - dtype = to_numpy_type ( self . snode ( ) . data_type ( ) ) ) <nl> + arr = np . zeros ( shape = self . shape , dtype = to_numpy_type ( self . dtype ) ) <nl> tensor_to_ext_arr ( self , arr ) <nl> import taichi as ti <nl> ti . sync ( ) <nl> def to_torch ( self , device = None ) : <nl> from . meta import tensor_to_ext_arr <nl> import torch <nl> arr = torch . zeros ( size = self . shape , <nl> - dtype = to_pytorch_type ( self . snode ( ) . data_type ( ) ) , <nl> + dtype = to_pytorch_type ( self . dtype ) , <nl> device = device ) <nl> tensor_to_ext_arr ( self , arr ) <nl> import taichi as ti <nl> mmm a / python / taichi / lang / matrix . py <nl> ppp b / python / taichi / lang / matrix . py <nl> def shape ( self ) : <nl> def dim ( self ) : <nl> return len ( self . shape ) <nl> <nl> + @ property <nl> + def dtype ( self ) : <nl> + return self . loop_range ( ) . dtype <nl> + <nl> + @ deprecated ( ' x . data_type ( ) ' , ' x . dtype ' ) <nl> def data_type ( self ) : <nl> - return self . loop_range ( ) . data_type ( ) <nl> + return self . dtype <nl> <nl> def make_grad ( self ) : <nl> ret = self . empty_copy ( ) <nl> def to_numpy ( self , keep_dims = False , as_vector = None ) : <nl> if not self . is_global ( ) : <nl> return np . array ( self . entries ) . reshape ( shape_ext ) <nl> <nl> - ret = np . empty ( self . loop_range ( ) . shape + shape_ext , <nl> - dtype = to_numpy_type ( <nl> - self . loop_range ( ) . snode ( ) . data_type ( ) ) ) <nl> + ret = np . empty ( self . shape + shape_ext , dtype = to_numpy_type ( self . dtype ) ) <nl> from . meta import matrix_to_ext_arr <nl> matrix_to_ext_arr ( self , ret , as_vector ) <nl> import taichi as ti <nl> def to_torch ( self , device = None , keep_dims = False ) : <nl> import torch <nl> as_vector = self . m = = 1 and not keep_dims <nl> shape_ext = ( self . n , ) if as_vector else ( self . n , self . m ) <nl> - ret = torch . empty ( self . loop_range ( ) . shape + shape_ext , <nl> - dtype = to_pytorch_type ( <nl> - self . loop_range ( ) . snode ( ) . data_type ( ) ) , <nl> + ret = torch . empty ( self . shape + shape_ext , <nl> + dtype = to_pytorch_type ( self . dtype ) , <nl> device = device ) <nl> from . meta import matrix_to_ext_arr <nl> matrix_to_ext_arr ( self , ret , as_vector ) <nl> mmm a / python / taichi / lang / snode . py <nl> ppp b / python / taichi / lang / snode . py <nl> def parent ( self , n = 1 ) : <nl> return impl . root <nl> return SNode ( p ) <nl> <nl> - def data_type ( self ) : <nl> + @ property <nl> + def dtype ( self ) : <nl> return self . ptr . data_type ( ) <nl> <nl> + @ deprecated ( ' x . data_type ( ) ' , ' x . dtype ' ) <nl> + def data_type ( self ) : <nl> + return self . dtype <nl> + <nl> @ deprecated ( ' x . dim ( ) ' , ' len ( x . shape ) ' ) <nl> def dim ( self ) : <nl> return len ( self . shape ) <nl> mmm a / python / taichi / misc / gui . py <nl> ppp b / python / taichi / misc / gui . py <nl> def set_image ( self , img ) : <nl> import taichi as ti <nl> <nl> if isinstance ( img , ti . Expr ) : <nl> - if ti . core . is_integral ( img . data_type ( ) ) or len ( img . shape ) ! = 2 : <nl> + if ti . core . is_integral ( img . dtype ) or len ( img . shape ) ! = 2 : <nl> # Images of uint is not optimized by xxx_to_image <nl> self . img = self . cook_image ( img . to_numpy ( ) ) <nl> else : <nl> def set_image ( self , img ) : <nl> ti . sync ( ) <nl> <nl> elif isinstance ( img , ti . Matrix ) : <nl> - if ti . core . is_integral ( img . data_type ( ) ) : <nl> + if ti . core . is_integral ( img . dtype ) : <nl> self . img = self . cook_image ( img . to_numpy ( ) ) <nl> else : <nl> # Type matched ! We can use an optimized copy kernel . <nl> mmm a / tests / python / test_tensor_reflection . py <nl> ppp b / tests / python / test_tensor_reflection . py <nl> def test_POT ( ) : <nl> ti . root . dense ( ti . i , n ) . dense ( ti . j , m ) . dense ( ti . k , p ) . place ( val ) <nl> <nl> assert val . shape = = ( n , m , p ) <nl> - assert val . data_type ( ) = = ti . i32 <nl> + assert val . dtype = = ti . i32 <nl> <nl> <nl> @ ti . all_archs <nl> def test_non_POT ( ) : <nl> blk3 . place ( val ) <nl> <nl> assert val . shape = = ( n , m , p ) <nl> - assert val . data_type ( ) = = ti . i32 <nl> + assert val . dtype = = ti . i32 <nl> <nl> <nl> @ ti . all_archs <nl> def test_unordered ( ) : <nl> blk3 = blk2 . dense ( ti . j , p ) <nl> blk3 . place ( val ) <nl> <nl> - assert val . data_type ( ) = = ti . i32 <nl> + assert val . dtype = = ti . i32 <nl> assert val . shape = = ( n , m , p ) <nl> assert val . snode ( ) . parent ( 0 ) = = val . snode ( ) <nl> assert val . snode ( ) . parent ( ) = = blk3 <nl> def test_unordered_matrix ( ) : <nl> blk3 . place ( val ) <nl> <nl> assert val . shape = = ( n , m , p ) <nl> - assert val . data_type ( ) = = ti . i32 <nl> + assert val . dtype = = ti . i32 <nl> assert val . loop_range ( ) . snode ( ) . parent ( 0 ) = = val . loop_range ( ) . snode ( ) <nl> assert val . loop_range ( ) . snode ( ) . parent ( ) = = blk3 <nl> assert val . loop_range ( ) . snode ( ) . parent ( 1 ) = = blk3 <nl> def test_deprecated ( ) : <nl> blk3 . place ( val , mat ) <nl> <nl> assert val . dim ( ) = = 3 <nl> + assert val . data_type ( ) = = ti . f32 <nl> assert val . shape ( ) = = ( n , m , p ) <nl> assert mat . dim ( ) = = 3 <nl> + assert mat . data_type ( ) = = ti . i32 <nl> assert mat . shape ( ) = = ( n , m , p ) <nl> assert blk3 . dim ( ) = = 3 <nl> assert blk3 . shape ( ) = = ( n , m , p ) <nl>
[ refactor ] [ Lang ] Deprecate x . data_type ( ) and use x . dtype instead ( )
taichi-dev/taichi
a6ad3669fc52c1779153ece37e091ffe2e4e7107
2020-07-03T17:26:15Z
mmm a / include / swift / Driver / Compilation . h <nl> ppp b / include / swift / Driver / Compilation . h <nl> class Compilation { <nl> / / / parallel . <nl> unsigned NumberOfParallelCommands ; <nl> <nl> + / / / \ brief Indicates whether this Compilation should use skip execution of <nl> + / / / subtasks during performJobs ( ) by using a dummy TaskQueue . <nl> + / / / <nl> + / / / \ note For testing purposes only ; similar user - facing features should be <nl> + / / / implemented separately , as the dummy TaskQueue may provide faked output . <nl> + bool SkipTaskExecution ; <nl> + <nl> public : <nl> Compilation ( const Driver & D , const ToolChain & DefaultToolChain , <nl> std : : unique_ptr < llvm : : opt : : InputArgList > InputArgs , <nl> std : : unique_ptr < llvm : : opt : : DerivedArgList > TranslatedArgs , <nl> - unsigned NumberOfParallelCommands = 1 ) ; <nl> + unsigned NumberOfParallelCommands = 1 , <nl> + bool SkipTaskExecution = false ) ; <nl> ~ Compilation ( ) ; <nl> <nl> const Driver & getDriver ( ) const { return TheDriver ; } <nl> mmm a / include / swift / Driver / Options . td <nl> ppp b / include / swift / Driver / Options . td <nl> def driver_print_bindings : Flag < [ " - " ] , " driver - print - bindings " > , <nl> InternalDebugOpt , HelpText < " Dump list of bindings " > ; <nl> def driver_print_jobs : Flag < [ " - " ] , " driver - print - jobs " > , InternalDebugOpt , <nl> HelpText < " Dump list of jobs to execute " > ; <nl> + def driver_skip_execution : Flag < [ " - " ] , " driver - skip - execution " > , <nl> + InternalDebugOpt , <nl> + HelpText < " Skip execution of subtasks when performing compilation " > ; <nl> <nl> def help : Flag < [ " - " , " - - " ] , " help " > , Flags < [ DriverOption , FrontendOption ] > , <nl> HelpText < " Display available options " > ; <nl> mmm a / lib / Driver / Compilation . cpp <nl> ppp b / lib / Driver / Compilation . cpp <nl> using namespace llvm : : opt ; <nl> Compilation : : Compilation ( const Driver & D , const ToolChain & DefaultToolChain , <nl> std : : unique_ptr < InputArgList > InputArgs , <nl> std : : unique_ptr < DerivedArgList > TranslatedArgs , <nl> - unsigned NumberOfParallelCommands ) <nl> + unsigned NumberOfParallelCommands , <nl> + bool SkipTaskExecution ) <nl> : TheDriver ( D ) , DefaultToolChain ( DefaultToolChain ) , Jobs ( new JobList ) , <nl> InputArgs ( std : : move ( InputArgs ) ) , TranslatedArgs ( std : : move ( TranslatedArgs ) ) , <nl> - NumberOfParallelCommands ( NumberOfParallelCommands ) { <nl> + NumberOfParallelCommands ( NumberOfParallelCommands ) , <nl> + SkipTaskExecution ( SkipTaskExecution ) { <nl> } ; <nl> <nl> Compilation : : ~ Compilation ( ) = default ; <nl> void Compilation : : addJob ( Job * J ) { <nl> } <nl> <nl> int Compilation : : performJobsInList ( const JobList & JL ) { <nl> - / / Create a TaskQueue for execution , if possible . <nl> - TaskQueue TQ ( NumberOfParallelCommands ) ; <nl> + / / Create a TaskQueue for execution . <nl> + std : : unique_ptr < TaskQueue > TQ ; <nl> + if ( SkipTaskExecution ) <nl> + TQ . reset ( new DummyTaskQueue ( NumberOfParallelCommands ) ) ; <nl> + else <nl> + TQ . reset ( new TaskQueue ( NumberOfParallelCommands ) ) ; <nl> <nl> / / Store pointers to the Commands which have already been scheduled <nl> / / to execute . <nl> int Compilation : : performJobsInList ( const JobList & JL ) { <nl> / / Set up scheduleCommandIfNecessary and supportsBufferingOutput . <nl> auto scheduleCommandIfNecessary = [ & ] ( const Command * Cmd ) { <nl> if ( ScheduledCommands . insert ( Cmd ) . second ) { <nl> - TQ . addTask ( Cmd - > getExecutable ( ) , Cmd - > getArguments ( ) , llvm : : None , <nl> + TQ - > addTask ( Cmd - > getExecutable ( ) , Cmd - > getArguments ( ) , llvm : : None , <nl> ( void * ) Cmd ) ; <nl> } <nl> } ; <nl> int Compilation : : performJobsInList ( const JobList & JL ) { <nl> } ; <nl> <nl> / / Ask the TaskQueue to execute . <nl> - TQ . execute ( taskBegan , taskFinished ) ; <nl> + TQ - > execute ( taskBegan , taskFinished ) ; <nl> <nl> return Result ; <nl> } <nl> mmm a / lib / Driver / Driver . cpp <nl> ppp b / lib / Driver / Driver . cpp <nl> std : : unique_ptr < Compilation > Driver : : buildCompilation ( <nl> bool DriverPrintActions = ArgList - > hasArg ( options : : OPT_driver_print_actions ) ; <nl> DriverPrintBindings = ArgList - > hasArg ( options : : OPT_driver_print_bindings ) ; <nl> bool DriverPrintJobs = ArgList - > hasArg ( options : : OPT_driver_print_jobs ) ; <nl> + bool DriverSkipExecution = <nl> + ArgList - > hasArg ( options : : OPT_driver_skip_execution ) ; <nl> <nl> std : : unique_ptr < DerivedArgList > TranslatedArgList ( <nl> translateInputArgs ( * ArgList ) ) ; <nl> std : : unique_ptr < Compilation > Driver : : buildCompilation ( <nl> <nl> std : : unique_ptr < Compilation > C ( new Compilation ( * this , TC , std : : move ( ArgList ) , <nl> std : : move ( TranslatedArgList ) , <nl> - NumberOfParallelCommands ) ) ; <nl> + NumberOfParallelCommands , <nl> + DriverSkipExecution ) ) ; <nl> <nl> buildJobs ( * C , Actions ) ; <nl> if ( DriverPrintBindings ) { <nl>
[ driver ] Add a new - driver - skip - execution flag .
apple/swift
d5f95cd574bb12f8b0a4ce2766fe2af28e9d7e6b
2014-01-15T21:27:56Z
mmm a / tools / release / chromium_roll . py <nl> ppp b / tools / release / chromium_roll . py <nl> <nl> https : / / code . google . com / p / v8 - wiki / wiki / TriagingIssues <nl> <nl> Please close rolling in case of a roll revert : <nl> - https : / / v8 - roll . appspot . com / " " " ) <nl> + https : / / v8 - roll . appspot . com / <nl> + This only works with a Google account . " " " ) <nl> <nl> class Preparation ( Step ) : <nl> MESSAGE = " Preparation . " <nl> mmm a / tools / release / test_scripts . py <nl> ppp b / tools / release / test_scripts . py <nl> def CheckVersionCommit ( ) : <nl> <nl> Please close rolling in case of a roll revert : <nl> https : / / v8 - roll . appspot . com / <nl> + This only works with a Google account . <nl> <nl> TBR = g_name @ chromium . org , reviewer @ chromium . org " " " <nl> <nl>
[ Release ] More information on how to close auto - roller
v8/v8
86c27e01e9f8627ee1187a1a327b1f4d087c9f2e
2015-10-30T09:09:45Z
mmm a / editor / editor_settings . cpp <nl> ppp b / editor / editor_settings . cpp <nl> void EditorSettings : : _load_defaults ( Ref < ConfigFile > p_extra_config ) { <nl> <nl> _THREAD_SAFE_METHOD_ <nl> <nl> + / * Languages * / <nl> + <nl> { <nl> String lang_hint = " en " ; <nl> String host_lang = OS : : get_singleton ( ) - > get_locale ( ) ; <nl> void EditorSettings : : _load_defaults ( Ref < ConfigFile > p_extra_config ) { <nl> hints [ " interface / editor / editor_language " ] = PropertyInfo ( Variant : : STRING , " interface / editor / editor_language " , PROPERTY_HINT_ENUM , lang_hint , PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED ) ; <nl> } <nl> <nl> + / * Interface * / <nl> + <nl> + / / Editor <nl> _initial_set ( " interface / editor / display_scale " , 0 ) ; <nl> hints [ " interface / editor / display_scale " ] = PropertyInfo ( Variant : : INT , " interface / editor / display_scale " , PROPERTY_HINT_ENUM , " Auto , 75 % , 100 % , 125 % , 150 % , 175 % , 200 % , Custom " , PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED ) ; <nl> _initial_set ( " interface / editor / custom_display_scale " , 1 . 0f ) ; <nl> hints [ " interface / editor / custom_display_scale " ] = PropertyInfo ( Variant : : REAL , " interface / editor / custom_display_scale " , PROPERTY_HINT_RANGE , " 0 . 75 , 3 , 0 . 01 " , PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED ) ; <nl> - _initial_set ( " interface / scene_tabs / show_script_button " , false ) ; <nl> _initial_set ( " interface / editor / main_font_size " , 14 ) ; <nl> hints [ " interface / editor / main_font_size " ] = PropertyInfo ( Variant : : INT , " interface / editor / main_font_size " , PROPERTY_HINT_RANGE , " 10 , 40 , 1 " , PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED ) ; <nl> _initial_set ( " interface / editor / code_font_size " , 14 ) ; <nl> void EditorSettings : : _load_defaults ( Ref < ConfigFile > p_extra_config ) { <nl> hints [ " interface / editor / dim_amount " ] = PropertyInfo ( Variant : : REAL , " interface / editor / dim_amount " , PROPERTY_HINT_RANGE , " 0 , 1 , 0 . 01 " , PROPERTY_USAGE_DEFAULT ) ; <nl> _initial_set ( " interface / editor / dim_transition_time " , 0 . 08f ) ; <nl> hints [ " interface / editor / dim_transition_time " ] = PropertyInfo ( Variant : : REAL , " interface / editor / dim_transition_time " , PROPERTY_HINT_RANGE , " 0 , 1 , 0 . 001 " , PROPERTY_USAGE_DEFAULT ) ; <nl> - <nl> _initial_set ( " interface / editor / separate_distraction_mode " , false ) ; <nl> - <nl> _initial_set ( " interface / editor / save_each_scene_on_quit " , true ) ; / / Regression <nl> _initial_set ( " interface / editor / quit_confirmation " , true ) ; <nl> <nl> + / / Theme <nl> _initial_set ( " interface / theme / preset " , " Default " ) ; <nl> hints [ " interface / theme / preset " ] = PropertyInfo ( Variant : : STRING , " interface / theme / preset " , PROPERTY_HINT_ENUM , " Default , Alien , Arc , Godot 2 , Grey , Light , Solarized ( Dark ) , Solarized ( Light ) , Custom " , PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED ) ; <nl> _initial_set ( " interface / theme / icon_and_font_color " , 0 ) ; <nl> void EditorSettings : : _load_defaults ( Ref < ConfigFile > p_extra_config ) { <nl> _initial_set ( " interface / theme / custom_theme " , " " ) ; <nl> hints [ " interface / theme / custom_theme " ] = PropertyInfo ( Variant : : STRING , " interface / theme / custom_theme " , PROPERTY_HINT_GLOBAL_FILE , " * . res , * . tres , * . theme " , PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED ) ; <nl> <nl> + / / Scene tabs <nl> _initial_set ( " interface / scene_tabs / show_extension " , false ) ; <nl> _initial_set ( " interface / scene_tabs / show_thumbnail_on_hover " , true ) ; <nl> _initial_set ( " interface / scene_tabs / resize_if_many_tabs " , true ) ; <nl> _initial_set ( " interface / scene_tabs / minimum_width " , 50 ) ; <nl> hints [ " interface / scene_tabs / minimum_width " ] = PropertyInfo ( Variant : : INT , " interface / scene_tabs / minimum_width " , PROPERTY_HINT_RANGE , " 50 , 500 , 1 " , PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED ) ; <nl> + _initial_set ( " interface / scene_tabs / show_script_button " , false ) ; <nl> + <nl> + / * Filesystem * / <nl> <nl> + / / Directories <nl> _initial_set ( " filesystem / directories / autoscan_project_path " , " " ) ; <nl> hints [ " filesystem / directories / autoscan_project_path " ] = PropertyInfo ( Variant : : STRING , " filesystem / directories / autoscan_project_path " , PROPERTY_HINT_GLOBAL_DIR ) ; <nl> _initial_set ( " filesystem / directories / default_project_path " , OS : : get_singleton ( ) - > has_environment ( " HOME " ) ? OS : : get_singleton ( ) - > get_environment ( " HOME " ) : OS : : get_singleton ( ) - > get_system_dir ( OS : : SYSTEM_DIR_DOCUMENTS ) ) ; <nl> hints [ " filesystem / directories / default_project_path " ] = PropertyInfo ( Variant : : STRING , " filesystem / directories / default_project_path " , PROPERTY_HINT_GLOBAL_DIR ) ; <nl> - _initial_set ( " filesystem / directories / default_project_export_path " , " " ) ; <nl> - hints [ " filesystem / directories / default_project_export_path " ] = PropertyInfo ( Variant : : STRING , " filesystem / directories / default_project_export_path " , PROPERTY_HINT_GLOBAL_DIR ) ; <nl> - _initial_set ( " interface / scene_tabs / show_script_button " , false ) ; <nl> <nl> + / / On save <nl> + _initial_set ( " filesystem / on_save / compress_binary_resources " , true ) ; <nl> + _initial_set ( " filesystem / on_save / safe_save_on_backup_then_rename " , true ) ; <nl> + <nl> + / / File dialog <nl> + _initial_set ( " filesystem / file_dialog / show_hidden_files " , false ) ; <nl> + _initial_set ( " filesystem / file_dialog / display_mode " , 0 ) ; <nl> + hints [ " filesystem / file_dialog / display_mode " ] = PropertyInfo ( Variant : : INT , " filesystem / file_dialog / display_mode " , PROPERTY_HINT_ENUM , " Thumbnails , List " ) ; <nl> + _initial_set ( " filesystem / file_dialog / thumbnail_size " , 64 ) ; <nl> + hints [ " filesystem / file_dialog / thumbnail_size " ] = PropertyInfo ( Variant : : INT , " filesystem / file_dialog / thumbnail_size " , PROPERTY_HINT_RANGE , " 32 , 128 , 16 " ) ; <nl> + <nl> + / / Import <nl> + _initial_set ( " filesystem / import / pvrtc_texture_tool " , " " ) ; <nl> + # ifdef WINDOWS_ENABLED <nl> + hints [ " filesystem / import / pvrtc_texture_tool " ] = PropertyInfo ( Variant : : STRING , " filesystem / import / pvrtc_texture_tool " , PROPERTY_HINT_GLOBAL_FILE , " * . exe " ) ; <nl> + # else <nl> + hints [ " filesystem / import / pvrtc_texture_tool " ] = PropertyInfo ( Variant : : STRING , " filesystem / import / pvrtc_texture_tool " , PROPERTY_HINT_GLOBAL_FILE , " " ) ; <nl> + # endif <nl> + _initial_set ( " filesystem / import / pvrtc_fast_conversion " , false ) ; <nl> + <nl> + / * Docks * / <nl> + <nl> + / / SceneTree <nl> + _initial_set ( " docks / scene_tree / start_create_dialog_fully_expanded " , false ) ; <nl> + _initial_set ( " docks / scene_tree / draw_relationship_lines " , true ) ; <nl> + _initial_set ( " docks / scene_tree / relationship_line_color " , Color : : html ( " 464646 " ) ) ; <nl> + <nl> + / / FileSystem <nl> + _initial_set ( " docks / filesystem / display_mode " , 0 ) ; <nl> + hints [ " docks / filesystem / display_mode " ] = PropertyInfo ( Variant : : INT , " docks / filesystem / display_mode " , PROPERTY_HINT_ENUM , " Tree only , Split " ) ; <nl> + _initial_set ( " docks / filesystem / thumbnail_size " , 64 ) ; <nl> + hints [ " docks / filesystem / thumbnail_size " ] = PropertyInfo ( Variant : : INT , " docks / filesystem / thumbnail_size " , PROPERTY_HINT_RANGE , " 32 , 128 , 16 " ) ; <nl> + _initial_set ( " docks / filesystem / files_display_mode " , 0 ) ; <nl> + hints [ " docks / filesystem / files_display_mode " ] = PropertyInfo ( Variant : : INT , " docks / filesystem / files_display_mode " , PROPERTY_HINT_ENUM , " Thumbnails , List " ) ; <nl> + _initial_set ( " docks / filesystem / always_show_folders " , true ) ; <nl> + <nl> + / / Property editor <nl> + _initial_set ( " docks / property_editor / auto_refresh_interval " , 0 . 3 ) ; <nl> + <nl> + / * Text editor * / <nl> + <nl> + / / Theme <nl> _initial_set ( " text_editor / theme / color_theme " , " Adaptive " ) ; <nl> hints [ " text_editor / theme / color_theme " ] = PropertyInfo ( Variant : : STRING , " text_editor / theme / color_theme " , PROPERTY_HINT_ENUM , " Adaptive , Default , Custom " ) ; <nl> - <nl> _initial_set ( " text_editor / theme / line_spacing " , 6 ) ; <nl> _initial_set ( " text_editor / theme / selection_color " , Color : : html ( " 40808080 " ) ) ; <nl> <nl> _load_default_text_editor_theme ( ) ; <nl> <nl> + / / Highlighting <nl> _initial_set ( " text_editor / highlighting / syntax_highlighting " , true ) ; <nl> - <nl> _initial_set ( " text_editor / highlighting / highlight_all_occurrences " , true ) ; <nl> _initial_set ( " text_editor / highlighting / highlight_current_line " , true ) ; <nl> _initial_set ( " text_editor / highlighting / highlight_type_safe_lines " , true ) ; <nl> - _initial_set ( " text_editor / cursor / scroll_past_end_of_file " , false ) ; <nl> <nl> + / / Indent <nl> _initial_set ( " text_editor / indent / type " , 0 ) ; <nl> hints [ " text_editor / indent / type " ] = PropertyInfo ( Variant : : INT , " text_editor / indent / type " , PROPERTY_HINT_ENUM , " Tabs , Spaces " ) ; <nl> _initial_set ( " text_editor / indent / size " , 4 ) ; <nl> void EditorSettings : : _load_defaults ( Ref < ConfigFile > p_extra_config ) { <nl> _initial_set ( " text_editor / indent / draw_indent_guides " , true ) ; <nl> _initial_set ( " text_editor / indent / draw_tabs " , true ) ; <nl> <nl> + / / Line numbers <nl> _initial_set ( " text_editor / line_numbers / show_line_numbers " , true ) ; <nl> _initial_set ( " text_editor / line_numbers / line_numbers_zero_padded " , false ) ; <nl> _initial_set ( " text_editor / line_numbers / show_breakpoint_gutter " , true ) ; <nl> void EditorSettings : : _load_defaults ( Ref < ConfigFile > p_extra_config ) { <nl> _initial_set ( " text_editor / line_numbers / line_length_guideline_column " , 80 ) ; <nl> hints [ " text_editor / line_numbers / line_length_guideline_column " ] = PropertyInfo ( Variant : : INT , " text_editor / line_numbers / line_length_guideline_column " , PROPERTY_HINT_RANGE , " 20 , 160 , 1 " ) ; <nl> <nl> + / / Open scripts <nl> _initial_set ( " text_editor / open_scripts / smooth_scrolling " , true ) ; <nl> _initial_set ( " text_editor / open_scripts / v_scroll_speed " , 80 ) ; <nl> _initial_set ( " text_editor / open_scripts / show_members_overview " , true ) ; <nl> <nl> + / / Files <nl> _initial_set ( " text_editor / files / trim_trailing_whitespace_on_save " , false ) ; <nl> - _initial_set ( " text_editor / completion / idle_parse_delay " , 2 ) ; <nl> + _initial_set ( " text_editor / files / autosave_interval_secs " , 0 ) ; <nl> + _initial_set ( " text_editor / files / restore_scripts_on_load " , true ) ; <nl> + <nl> + / / Tools <nl> _initial_set ( " text_editor / tools / create_signal_callbacks " , true ) ; <nl> _initial_set ( " text_editor / tools / sort_members_outline_alphabetically " , false ) ; <nl> - _initial_set ( " text_editor / files / autosave_interval_secs " , 0 ) ; <nl> <nl> + / / Cursor <nl> + _initial_set ( " text_editor / cursor / scroll_past_end_of_file " , false ) ; <nl> _initial_set ( " text_editor / cursor / block_caret " , false ) ; <nl> _initial_set ( " text_editor / cursor / caret_blink " , true ) ; <nl> _initial_set ( " text_editor / cursor / caret_blink_speed " , 0 . 5 ) ; <nl> hints [ " text_editor / cursor / caret_blink_speed " ] = PropertyInfo ( Variant : : REAL , " text_editor / cursor / caret_blink_speed " , PROPERTY_HINT_RANGE , " 0 . 1 , 10 , 0 . 01 " ) ; <nl> _initial_set ( " text_editor / cursor / right_click_moves_caret " , true ) ; <nl> <nl> + / / Completion <nl> + _initial_set ( " text_editor / completion / idle_parse_delay " , 2 ) ; <nl> _initial_set ( " text_editor / completion / auto_brace_complete " , false ) ; <nl> _initial_set ( " text_editor / completion / put_callhint_tooltip_below_current_line " , true ) ; <nl> _initial_set ( " text_editor / completion / callhint_tooltip_offset " , Vector2 ( ) ) ; <nl> - _initial_set ( " text_editor / files / restore_scripts_on_load " , true ) ; <nl> _initial_set ( " text_editor / completion / complete_file_paths " , true ) ; <nl> _initial_set ( " text_editor / completion / add_type_hints " , false ) ; <nl> <nl> - _initial_set ( " docks / scene_tree / start_create_dialog_fully_expanded " , false ) ; <nl> - _initial_set ( " docks / scene_tree / draw_relationship_lines " , true ) ; <nl> - _initial_set ( " docks / scene_tree / relationship_line_color " , Color : : html ( " 464646 " ) ) ; <nl> + / / Help <nl> + _initial_set ( " text_editor / help / show_help_index " , true ) ; <nl> <nl> + / * Editors * / <nl> + <nl> + / / GridMap <nl> _initial_set ( " editors / grid_map / pick_distance " , 5000 . 0 ) ; <nl> <nl> + / / 3D <nl> _initial_set ( " editors / 3d / primary_grid_color " , Color : : html ( " 909090 " ) ) ; <nl> hints [ " editors / 3d / primary_grid_color " ] = PropertyInfo ( Variant : : COLOR , " editors / 3d / primary_grid_color " , PROPERTY_HINT_COLOR_NO_ALPHA , " " , PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED ) ; <nl> <nl> void EditorSettings : : _load_defaults ( Ref < ConfigFile > p_extra_config ) { <nl> _initial_set ( " editors / 3d / default_z_near " , 0 . 05 ) ; <nl> _initial_set ( " editors / 3d / default_z_far " , 500 . 0 ) ; <nl> <nl> - / / navigation <nl> + / / 3D : Navigation <nl> _initial_set ( " editors / 3d / navigation / navigation_scheme " , 0 ) ; <nl> _initial_set ( " editors / 3d / navigation / invert_y_axis " , false ) ; <nl> hints [ " editors / 3d / navigation / navigation_scheme " ] = PropertyInfo ( Variant : : INT , " editors / 3d / navigation / navigation_scheme " , PROPERTY_HINT_ENUM , " Godot , Maya , Modo " ) ; <nl> void EditorSettings : : _load_defaults ( Ref < ConfigFile > p_extra_config ) { <nl> hints [ " editors / 3d / navigation / pan_modifier " ] = PropertyInfo ( Variant : : INT , " editors / 3d / navigation / pan_modifier " , PROPERTY_HINT_ENUM , " None , Shift , Alt , Meta , Ctrl " ) ; <nl> _initial_set ( " editors / 3d / navigation / zoom_modifier " , 4 ) ; <nl> hints [ " editors / 3d / navigation / zoom_modifier " ] = PropertyInfo ( Variant : : INT , " editors / 3d / navigation / zoom_modifier " , PROPERTY_HINT_ENUM , " None , Shift , Alt , Meta , Ctrl " ) ; <nl> - <nl> - / / _initial_set ( " editors / 3d / navigation / emulate_numpad " , false ) ; not used at the moment <nl> _initial_set ( " editors / 3d / navigation / warped_mouse_panning " , true ) ; <nl> <nl> - / / navigation feel <nl> + / / 3D : Navigation feel <nl> _initial_set ( " editors / 3d / navigation_feel / orbit_sensitivity " , 0 . 4 ) ; <nl> hints [ " editors / 3d / navigation_feel / orbit_sensitivity " ] = PropertyInfo ( Variant : : REAL , " editors / 3d / navigation_feel / orbit_sensitivity " , PROPERTY_HINT_RANGE , " 0 . 0 , 2 , 0 . 01 " ) ; <nl> - <nl> _initial_set ( " editors / 3d / navigation_feel / orbit_inertia " , 0 . 05 ) ; <nl> hints [ " editors / 3d / navigation_feel / orbit_inertia " ] = PropertyInfo ( Variant : : REAL , " editors / 3d / navigation_feel / orbit_inertia " , PROPERTY_HINT_RANGE , " 0 . 0 , 1 , 0 . 01 " ) ; <nl> _initial_set ( " editors / 3d / navigation_feel / translation_inertia " , 0 . 15 ) ; <nl> void EditorSettings : : _load_defaults ( Ref < ConfigFile > p_extra_config ) { <nl> _initial_set ( " editors / 3d / navigation_feel / manipulation_translation_inertia " , 0 . 075 ) ; <nl> hints [ " editors / 3d / navigation_feel / manipulation_translation_inertia " ] = PropertyInfo ( Variant : : REAL , " editors / 3d / navigation_feel / manipulation_translation_inertia " , PROPERTY_HINT_RANGE , " 0 . 0 , 1 , 0 . 01 " ) ; <nl> <nl> - / / freelook <nl> + / / 3D : Freelook <nl> _initial_set ( " editors / 3d / freelook / freelook_inertia " , 0 . 1 ) ; <nl> hints [ " editors / 3d / freelook / freelook_inertia " ] = PropertyInfo ( Variant : : REAL , " editors / 3d / freelook / freelook_inertia " , PROPERTY_HINT_RANGE , " 0 . 0 , 1 , 0 . 01 " ) ; <nl> _initial_set ( " editors / 3d / freelook / freelook_base_speed " , 5 . 0 ) ; <nl> void EditorSettings : : _load_defaults ( Ref < ConfigFile > p_extra_config ) { <nl> hints [ " editors / 3d / freelook / freelook_modifier_speed_factor " ] = PropertyInfo ( Variant : : REAL , " editors / 3d / freelook / freelook_modifier_speed_factor " , PROPERTY_HINT_RANGE , " 0 . 0 , 10 . 0 , 0 . 1 " ) ; <nl> _initial_set ( " editors / 3d / freelook / freelook_speed_zoom_link " , false ) ; <nl> <nl> + / / 2D <nl> _initial_set ( " editors / 2d / grid_color " , Color ( 1 . 0 , 1 . 0 , 1 . 0 , 0 . 07 ) ) ; <nl> _initial_set ( " editors / 2d / guides_color " , Color ( 0 . 6 , 0 . 0 , 0 . 8 ) ) ; <nl> _initial_set ( " editors / 2d / bone_width " , 5 ) ; <nl> void EditorSettings : : _load_defaults ( Ref < ConfigFile > p_extra_config ) { <nl> _initial_set ( " editors / 2d / scroll_to_pan " , false ) ; <nl> _initial_set ( " editors / 2d / pan_speed " , 20 ) ; <nl> <nl> + / / Polygon editor <nl> _initial_set ( " editors / poly_editor / point_grab_radius " , 8 ) ; <nl> _initial_set ( " editors / poly_editor / show_previous_outline " , true ) ; <nl> <nl> + / / Animation <nl> + _initial_set ( " editors / animation / autorename_animation_tracks " , true ) ; <nl> + _initial_set ( " editors / animation / confirm_insert_track " , true ) ; <nl> + _initial_set ( " editors / animation / onion_layers_past_color " , Color ( 1 , 0 , 0 ) ) ; <nl> + _initial_set ( " editors / animation / onion_layers_future_color " , Color ( 0 , 1 , 0 ) ) ; <nl> + <nl> + / * Run * / <nl> + <nl> + / / Window placement <nl> _initial_set ( " run / window_placement / rect " , 1 ) ; <nl> hints [ " run / window_placement / rect " ] = PropertyInfo ( Variant : : INT , " run / window_placement / rect " , PROPERTY_HINT_ENUM , " Top Left , Centered , Custom Position , Force Maximized , Force Fullscreen " ) ; <nl> String screen_hints = " Same as Editor , Previous Monitor , Next Monitor " ; <nl> void EditorSettings : : _load_defaults ( Ref < ConfigFile > p_extra_config ) { <nl> _initial_set ( " run / window_placement / screen " , 0 ) ; <nl> hints [ " run / window_placement / screen " ] = PropertyInfo ( Variant : : INT , " run / window_placement / screen " , PROPERTY_HINT_ENUM , screen_hints ) ; <nl> <nl> - _initial_set ( " filesystem / on_save / compress_binary_resources " , true ) ; <nl> - _initial_set ( " filesystem / on_save / save_modified_external_resources " , true ) ; <nl> - <nl> - _initial_set ( " text_editor / tools / create_signal_callbacks " , true ) ; <nl> - <nl> - _initial_set ( " filesystem / file_dialog / show_hidden_files " , false ) ; <nl> - _initial_set ( " filesystem / file_dialog / display_mode " , 0 ) ; <nl> - hints [ " filesystem / file_dialog / display_mode " ] = PropertyInfo ( Variant : : INT , " filesystem / file_dialog / display_mode " , PROPERTY_HINT_ENUM , " Thumbnails , List " ) ; <nl> - <nl> - _initial_set ( " filesystem / file_dialog / thumbnail_size " , 64 ) ; <nl> - hints [ " filesystem / file_dialog / thumbnail_size " ] = PropertyInfo ( Variant : : INT , " filesystem / file_dialog / thumbnail_size " , PROPERTY_HINT_RANGE , " 32 , 128 , 16 " ) ; <nl> - <nl> - _initial_set ( " docks / filesystem / display_mode " , 0 ) ; <nl> - hints [ " docks / filesystem / display_mode " ] = PropertyInfo ( Variant : : INT , " docks / filesystem / display_mode " , PROPERTY_HINT_ENUM , " Tree only , Split " ) ; <nl> - _initial_set ( " docks / filesystem / thumbnail_size " , 64 ) ; <nl> - hints [ " docks / filesystem / thumbnail_size " ] = PropertyInfo ( Variant : : INT , " docks / filesystem / thumbnail_size " , PROPERTY_HINT_RANGE , " 32 , 128 , 16 " ) ; <nl> - _initial_set ( " docks / filesystem / files_display_mode " , 0 ) ; <nl> - hints [ " docks / filesystem / files_display_mode " ] = PropertyInfo ( Variant : : INT , " docks / filesystem / files_display_mode " , PROPERTY_HINT_ENUM , " Thumbnails , List " ) ; <nl> - _initial_set ( " docks / filesystem / always_show_folders " , true ) ; <nl> - <nl> - _initial_set ( " editors / animation / autorename_animation_tracks " , true ) ; <nl> - _initial_set ( " editors / animation / confirm_insert_track " , true ) ; <nl> - _initial_set ( " editors / animation / onion_layers_past_color " , Color ( 1 , 0 , 0 ) ) ; <nl> - _initial_set ( " editors / animation / onion_layers_future_color " , Color ( 0 , 1 , 0 ) ) ; <nl> - <nl> - _initial_set ( " docks / property_editor / texture_preview_width " , 48 ) ; <nl> - _initial_set ( " docks / property_editor / auto_refresh_interval " , 0 . 3 ) ; <nl> - _initial_set ( " text_editor / help / show_help_index " , true ) ; <nl> - <nl> - _initial_set ( " filesystem / import / ask_save_before_reimport " , false ) ; <nl> - <nl> - _initial_set ( " filesystem / import / pvrtc_texture_tool " , " " ) ; <nl> - # ifdef WINDOWS_ENABLED <nl> - hints [ " filesystem / import / pvrtc_texture_tool " ] = PropertyInfo ( Variant : : STRING , " filesystem / import / pvrtc_texture_tool " , PROPERTY_HINT_GLOBAL_FILE , " * . exe " ) ; <nl> - # else <nl> - hints [ " filesystem / import / pvrtc_texture_tool " ] = PropertyInfo ( Variant : : STRING , " filesystem / import / pvrtc_texture_tool " , PROPERTY_HINT_GLOBAL_FILE , " " ) ; <nl> - # endif <nl> - _initial_set ( " filesystem / import / pvrtc_fast_conversion " , false ) ; <nl> - <nl> + / / Auto save <nl> _initial_set ( " run / auto_save / save_before_running " , true ) ; <nl> + <nl> + / / Output <nl> _initial_set ( " run / output / always_clear_output_on_play " , true ) ; <nl> _initial_set ( " run / output / always_open_output_on_play " , true ) ; <nl> _initial_set ( " run / output / always_close_output_on_stop " , false ) ; <nl> - _initial_set ( " filesystem / resources / save_compressed_resources " , true ) ; <nl> - _initial_set ( " filesystem / resources / auto_reload_modified_images " , true ) ; <nl> <nl> - _initial_set ( " filesystem / import / automatic_reimport_on_sources_changed " , true ) ; <nl> - _initial_set ( " filesystem / on_save / safe_save_on_backup_then_rename " , true ) ; <nl> + / * Extra config * / <nl> <nl> if ( p_extra_config . is_valid ( ) ) { <nl> <nl>
Merge pull request from akien - mga / editorsettings - cleanup
godotengine/godot
ecc588867482c0b32c3896591f55630baba1ef7c
2018-12-12T08:22:49Z
mmm a / test / full_test / os_tests . test <nl> ppp b / test / full_test / os_tests . test <nl> <nl> - os_list = [ <nl> - ( " ubuntu " , " build / ubuntu " , " deb " ) , <nl> - ( " redhat5_1 " , " build / redhat5_1 " , " rpm " ) , <nl> - ( " debian " , " build / debian " , " deb " ) , <nl> - ( " centos5_5 " , " build / centos5_5 " , " rpm " ) , <nl> - ( " suse2 " , " build / suse " , " rpm " ) , <nl> - ( " centos6 " , " build / centos6 " , " rpm " ) <nl> - ] <nl> - <nl> - for os_name , build_folder , pkg_type in os_list : <nl> - mode = build_folder [ len ( " build / " ) : ] <nl> - generate_test ( <nl> - " $ RETHINKDB / scripts / VirtuaBuild / vm_access . py - - vm - name % s - - command ' cd rethinkdb & & scripts / VirtuaBuild / smoke_test . py - - mode % s - - pkg - type % s ' " % ( os_name , mode , pkg_type ) , <nl> - repeat = 1 , <nl> - inputs = [ build_folder , " test / scenarios " , " test / common " , " scripts / VirtuaBuild " , " test / memcached_workloads " ] <nl> - ) <nl> + # os_list = [ <nl> + # ( " ubuntu " , " build / ubuntu " , " deb " ) , <nl> + # ( " redhat5_1 " , " build / redhat5_1 " , " rpm " ) , <nl> + # ( " debian " , " build / debian " , " deb " ) , <nl> + # ( " centos5_5 " , " build / centos5_5 " , " rpm " ) , <nl> + # ( " suse2 " , " build / suse " , " rpm " ) , <nl> + # ( " centos6 " , " build / centos6 " , " rpm " ) <nl> + # ] <nl> + # <nl> + # for os_name , build_folder , pkg_type in os_list : <nl> + # mode = build_folder [ len ( " build / " ) : ] <nl> + # generate_test ( <nl> + # " $ RETHINKDB / scripts / VirtuaBuild / vm_access . py - - vm - name % s - - command ' cd rethinkdb & & scripts / VirtuaBuild / smoke_test . py - - mode % s - - pkg - type % s ' " % ( os_name , mode , pkg_type ) , <nl> + # repeat = 1 , <nl> + # inputs = [ build_folder , " test / scenarios " , " test / common " , " scripts / VirtuaBuild " , " test / memcached_workloads " ] <nl> + # ) <nl>
commenting out os tests from automated tests , because they are not set up correctly
rethinkdb/rethinkdb
5dad7ef9403db649fb700d1360e127c3449df094
2012-11-29T23:36:20Z
mmm a / gles_builders . py <nl> ppp b / gles_builders . py <nl> def include_file_in_rd_header ( filename , header_data , depth ) : <nl> <nl> return header_data <nl> <nl> + <nl> def build_rd_header ( filename ) : <nl> header_data = RDHeaderStruct ( ) <nl> include_file_in_rd_header ( filename , header_data , 0 ) <nl> def build_rd_header ( filename ) : <nl> fd . write ( " # define " + out_file_ifdef + " _RD \ n " ) <nl> <nl> out_file_class = out_file_base . replace ( " . glsl . gen . h " , " " ) . title ( ) . replace ( " _ " , " " ) . replace ( " . " , " " ) + " ShaderRD " <nl> - fd . write ( " \ n \ n " ) <nl> - fd . write ( " # include \ " servers / visual / rasterizer_rd / shader_rd . h \ " \ n \ n \ n " ) <nl> + fd . write ( " \ n " ) <nl> + fd . write ( " # include \ " servers / visual / rasterizer_rd / shader_rd . h \ " \ n \ n " ) <nl> fd . write ( " class " + out_file_class + " : public ShaderRD { \ n \ n " ) <nl> fd . write ( " public : \ n \ n " ) <nl> <nl> - <nl> - fd . write ( " \ t " + out_file_class + " ( ) { \ n \ n " ) <nl> + fd . write ( " \ t " + out_file_class + " ( ) { \ n \ n " ) <nl> <nl> if ( len ( header_data . compute_lines ) ) : <nl> <nl> - fd . write ( " \ t \ tstatic const char _compute_code [ ] = { \ n " ) <nl> + fd . write ( " \ t \ tstatic const char _compute_code [ ] = { \ n " ) <nl> for x in header_data . compute_lines : <nl> for c in x : <nl> fd . write ( str ( ord ( c ) ) + " , " ) <nl> - <nl> fd . write ( str ( ord ( ' \ n ' ) ) + " , " ) <nl> - <nl> fd . write ( " \ t \ t0 } ; \ n \ n " ) <nl> - fd . write ( " \ t \ tsetup ( nullptr , nullptr , _compute_code , \ " " + out_file_class + " \ " ) ; \ n " ) <nl> + <nl> + fd . write ( " \ t \ tsetup ( nullptr , nullptr , _compute_code , \ " " + out_file_class + " \ " ) ; \ n " ) <nl> fd . write ( " \ t } \ n " ) <nl> <nl> else : <nl> <nl> - fd . write ( " \ t \ tstatic const char _vertex_code [ ] = { \ n " ) <nl> + fd . write ( " \ t \ tstatic const char _vertex_code [ ] = { \ n " ) <nl> for x in header_data . vertex_lines : <nl> for c in x : <nl> fd . write ( str ( ord ( c ) ) + " , " ) <nl> - <nl> fd . write ( str ( ord ( ' \ n ' ) ) + " , " ) <nl> fd . write ( " \ t \ t0 } ; \ n \ n " ) <nl> <nl> fd . write ( " \ t \ tstatic const char _fragment_code [ ] = { \ n " ) <nl> for x in header_data . fragment_lines : <nl> for c in x : <nl> - fd . write ( str ( ord ( c ) ) + " , " ) <nl> - <nl> + fd . write ( str ( ord ( c ) ) + " , " ) <nl> fd . write ( str ( ord ( ' \ n ' ) ) + " , " ) <nl> - <nl> fd . write ( " \ t \ t0 } ; \ n \ n " ) <nl> - fd . write ( " \ t \ tsetup ( _vertex_code , _fragment_code , nullptr , \ " " + out_file_class + " \ " ) ; \ n " ) <nl> - fd . write ( " \ t } \ n " ) <nl> <nl> + fd . write ( " \ t \ tsetup ( _vertex_code , _fragment_code , nullptr , \ " " + out_file_class + " \ " ) ; \ n " ) <nl> + fd . write ( " \ t } \ n " ) <nl> <nl> fd . write ( " } ; \ n \ n " ) <nl> <nl> - fd . write ( " # endif \ n \ n " ) <nl> + fd . write ( " # endif \ n " ) <nl> fd . close ( ) <nl> <nl> <nl>
Better format generated shader headers
godotengine/godot
af6a3a419a97d1b623d74c1170ed79cf1eba1c78
2020-02-11T11:03:05Z
mmm a / xbmc / epg / EpgContainer . cpp <nl> ppp b / xbmc / epg / EpgContainer . cpp <nl> void CEpgContainer : : Process ( void ) <nl> m_bIsInitialising = false ; <nl> <nl> / * clean up old entries * / <nl> - if ( ! m_bStop & & iNow > = m_iLastEpgCleanup ) <nl> + if ( ! m_bStop & & iNow > = m_iLastEpgCleanup + g_advancedSettings . m_iEpgCleanupInterval ) <nl> RemoveOldEntries ( ) ; <nl> <nl> / * check for pending manual EPG updates * / <nl> bool CEpgContainer : : RemoveOldEntries ( void ) <nl> <nl> CSingleLock lock ( m_critSection ) ; <nl> CDateTime : : GetCurrentDateTime ( ) . GetAsUTCDateTime ( ) . GetAsTime ( m_iLastEpgCleanup ) ; <nl> - m_iLastEpgCleanup + = g_advancedSettings . m_iEpgCleanupInterval ; <nl> <nl> return true ; <nl> } <nl>
[ epg ] refactor : align m_iLastEpgCleanup naming with actual usage
xbmc/xbmc
6db9f73f3c970b6de87d0f362c518e20677e0a0e
2016-06-17T09:11:15Z
mmm a / lib / SILGen / SILGenExpr . cpp <nl> ppp b / lib / SILGen / SILGenExpr . cpp <nl> SILGenFunction : : emitSiblingMethodRef ( SILLocation loc , <nl> SILValue selfValue , <nl> SILDeclRef methodConstant , <nl> ArrayRef < Substitution > subs ) { <nl> - SILValue methodValue = emitGlobalFunctionRef ( loc , methodConstant ) ; <nl> + SILValue methodValue ; <nl> + <nl> + / / If the method is dynamic , access it through runtime - hookable virtual <nl> + / / dispatch ( viz . objc_msgSend for now ) . <nl> + if ( getASTContext ( ) . LangOpts . EnableDynamic <nl> + & & methodConstant . hasDecl ( ) <nl> + & & methodConstant . getDecl ( ) - > getAttrs ( ) . hasAttribute < DynamicAttr > ( ) ) <nl> + methodValue = emitDynamicMethodRef ( loc , methodConstant , <nl> + SGM . Types . getConstantInfo ( methodConstant ) ) ; <nl> + else <nl> + methodValue = emitGlobalFunctionRef ( loc , methodConstant ) ; <nl> <nl> SILType methodTy = methodValue . getType ( ) ; <nl> <nl> mmm a / test / SILGen / dynamic . swift <nl> ppp b / test / SILGen / dynamic . swift <nl> protocol Proto { <nl> <nl> / / TODO : dynamic initializing ctor must be objc dispatched <nl> / / CHECK - LABEL : sil @ _TFC7dynamic3FooCfMS0_FT7dynamicSi_S0_ <nl> - / / C / HECK : class_method [ volatile ] XXX <nl> + / / CHECK : function_ref @ _TFC7dynamic3FoocfMS0_FT7dynamicSi_S0__dynamic <nl> + / / CHECK - LABEL : sil private [ transparent ] @ _TFC7dynamic3FoocfMS0_FT7dynamicSi_S0__dynamic <nl> + / / CHECK : class_method [ volatile ] % 1 : $ Foo , # Foo . init ! initializer . 1 . foreign : <nl> <nl> / / CHECK - LABEL : sil @ _TToFC7dynamic3FoocfMS0_FT7dynamicSi_S0_ <nl> / / CHECK - LABEL : sil @ _TToFC7dynamic3Foo13dynamicMethodfS0_FT_T_ <nl>
SILGen : Honor ' dynamic ' when invoking initializing ctors from allocating ctors .
apple/swift
fed9b8daa234e69845729783e8e03f94ae089a1c
2014-07-12T00:06:35Z
mmm a / include / grpc / grpc . h <nl> ppp b / include / grpc / grpc . h <nl> typedef enum grpc_call_error { <nl> GRPC_CALL_ERROR_INVALID_FLAGS <nl> } grpc_call_error ; <nl> <nl> - / * Result of a grpc operation * / <nl> - typedef enum grpc_op_error { <nl> - / * everything went ok * / <nl> - GRPC_OP_OK = 0 , <nl> - / * something failed , we don ' t know what * / <nl> - GRPC_OP_ERROR <nl> - } grpc_op_error ; <nl> - <nl> / * Write Flags : * / <nl> / * Hint that the write may be buffered and need not go out on the wire <nl> immediately . GRPC is free to buffer the message until the next non - buffered <nl> typedef struct grpc_metadata { <nl> } grpc_metadata ; <nl> <nl> typedef enum grpc_completion_type { <nl> - GRPC_QUEUE_SHUTDOWN , / * Shutting down * / <nl> - GRPC_OP_COMPLETE , / * operation completion * / <nl> - GRPC_SERVER_SHUTDOWN , / * The server has finished shutting down * / <nl> - GRPC_COMPLETION_DO_NOT_USE / * must be last , forces users to include <nl> - a default : case * / <nl> + GRPC_QUEUE_SHUTDOWN , / * Shutting down * / <nl> + GRPC_QUEUE_TIMEOUT , / * No event before timeout * / <nl> + GRPC_OP_COMPLETE / * operation completion * / <nl> } grpc_completion_type ; <nl> <nl> typedef struct grpc_event { <nl> grpc_completion_type type ; <nl> + int success ; <nl> void * tag ; <nl> - grpc_call * call ; <nl> - / * Data associated with the completion type . Field names match the type of <nl> - completion as listed in grpc_completion_type . * / <nl> - union { <nl> - grpc_op_error op_complete ; <nl> - } data ; <nl> } grpc_event ; <nl> <nl> typedef struct { <nl> grpc_completion_queue * grpc_completion_queue_create ( void ) ; <nl> <nl> Callers must not call grpc_completion_queue_next and <nl> grpc_completion_queue_pluck simultaneously on the same completion queue . * / <nl> - grpc_event * grpc_completion_queue_next ( grpc_completion_queue * cq , <nl> - gpr_timespec deadline ) ; <nl> + grpc_event grpc_completion_queue_next ( grpc_completion_queue * cq , <nl> + gpr_timespec deadline ) ; <nl> <nl> / * Blocks until an event with tag ' tag ' is available , the completion queue is <nl> being shutdown or deadline is reached . Returns NULL on timeout , or a pointer <nl> grpc_event * grpc_completion_queue_next ( grpc_completion_queue * cq , <nl> <nl> Callers must not call grpc_completion_queue_next and <nl> grpc_completion_queue_pluck simultaneously on the same completion queue . * / <nl> - grpc_event * grpc_completion_queue_pluck ( grpc_completion_queue * cq , void * tag , <nl> - gpr_timespec deadline ) ; <nl> - <nl> - / * Clean up any data owned by the event * / <nl> - void grpc_event_finish ( grpc_event * event ) ; <nl> + grpc_event grpc_completion_queue_pluck ( grpc_completion_queue * cq , void * tag , <nl> + gpr_timespec deadline ) ; <nl> <nl> / * Begin destruction of a completion queue . Once all possible events are <nl> drained then grpc_completion_queue_next will start to produce <nl> mmm a / src / core / surface / call . c <nl> ppp b / src / core / surface / call . c <nl> typedef enum { <nl> typedef struct { <nl> grpc_ioreq_completion_func on_complete ; <nl> void * user_data ; <nl> - grpc_op_error status ; <nl> + int success ; <nl> } completed_request ; <nl> <nl> / * See request_set in grpc_call below for a description * / <nl> typedef struct { <nl> typedef struct { <nl> / * Overall status of the operation : starts OK , may degrade to <nl> non - OK * / <nl> - grpc_op_error status ; <nl> + int success ; <nl> / * Completion function to call at the end of the operation * / <nl> grpc_ioreq_completion_func on_complete ; <nl> void * user_data ; <nl> struct grpc_call { <nl> y = temp ; \ <nl> } while ( 0 ) <nl> <nl> - static void do_nothing ( void * ignored , grpc_op_error also_ignored ) { } <nl> static void set_deadline_alarm ( grpc_call * call , gpr_timespec deadline ) ; <nl> static void call_on_done_recv ( void * call , int success ) ; <nl> static void call_on_done_send ( void * call , int success ) ; <nl> static void unlock ( grpc_call * call ) { <nl> <nl> if ( completing_requests > 0 ) { <nl> for ( i = 0 ; i < completing_requests ; i + + ) { <nl> - completed_requests [ i ] . on_complete ( call , completed_requests [ i ] . status , <nl> + completed_requests [ i ] . on_complete ( call , completed_requests [ i ] . success , <nl> completed_requests [ i ] . user_data ) ; <nl> } <nl> lock ( call ) ; <nl> static void get_final_details ( grpc_call * call , grpc_ioreq_data out ) { <nl> } <nl> <nl> static void finish_live_ioreq_op ( grpc_call * call , grpc_ioreq_op op , <nl> - grpc_op_error status ) { <nl> + int success ) { <nl> completed_request * cr ; <nl> gpr_uint8 master_set = call - > request_set [ op ] ; <nl> reqinfo_master * master ; <nl> static void finish_live_ioreq_op ( grpc_call * call , grpc_ioreq_op op , <nl> / * ioreq is live : we need to do something * / <nl> master = & call - > masters [ master_set ] ; <nl> master - > complete_mask | = 1u < < op ; <nl> - if ( status ! = GRPC_OP_OK ) { <nl> - master - > status = status ; <nl> + if ( ! success ) { <nl> + master - > success = 0 ; <nl> } <nl> if ( master - > complete_mask = = master - > need_mask ) { <nl> for ( i = 0 ; i < GRPC_IOREQ_OP_COUNT ; i + + ) { <nl> static void finish_live_ioreq_op ( grpc_call * call , grpc_ioreq_op op , <nl> switch ( ( grpc_ioreq_op ) i ) { <nl> case GRPC_IOREQ_RECV_MESSAGE : <nl> case GRPC_IOREQ_SEND_MESSAGE : <nl> - if ( master - > status = = GRPC_OP_OK ) { <nl> + if ( master - > success ) { <nl> call - > request_set [ i ] = REQSET_EMPTY ; <nl> } else { <nl> call - > write_state = WRITE_STATE_WRITE_CLOSED ; <nl> static void finish_live_ioreq_op ( grpc_call * call , grpc_ioreq_op op , <nl> } <nl> } <nl> cr = & call - > completed_requests [ call - > num_completed_requests + + ] ; <nl> - cr - > status = master - > status ; <nl> + cr - > success = master - > success ; <nl> cr - > on_complete = master - > on_complete ; <nl> cr - > user_data = master - > user_data ; <nl> } <nl> } <nl> <nl> - static void finish_ioreq_op ( grpc_call * call , grpc_ioreq_op op , <nl> - grpc_op_error status ) { <nl> + static void finish_ioreq_op ( grpc_call * call , grpc_ioreq_op op , int success ) { <nl> if ( is_op_live ( call , op ) ) { <nl> - finish_live_ioreq_op ( call , op , status ) ; <nl> + finish_live_ioreq_op ( call , op , success ) ; <nl> } <nl> } <nl> <nl> static void call_on_done_send ( void * pc , int success ) { <nl> grpc_call * call = pc ; <nl> - grpc_op_error error = success ? GRPC_OP_OK : GRPC_OP_ERROR ; <nl> lock ( call ) ; <nl> if ( call - > last_send_contains & ( 1 < < GRPC_IOREQ_SEND_INITIAL_METADATA ) ) { <nl> - finish_ioreq_op ( call , GRPC_IOREQ_SEND_INITIAL_METADATA , error ) ; <nl> + finish_ioreq_op ( call , GRPC_IOREQ_SEND_INITIAL_METADATA , success ) ; <nl> } <nl> if ( call - > last_send_contains & ( 1 < < GRPC_IOREQ_SEND_MESSAGE ) ) { <nl> - finish_ioreq_op ( call , GRPC_IOREQ_SEND_MESSAGE , error ) ; <nl> + finish_ioreq_op ( call , GRPC_IOREQ_SEND_MESSAGE , success ) ; <nl> } <nl> if ( call - > last_send_contains & ( 1 < < GRPC_IOREQ_SEND_CLOSE ) ) { <nl> - finish_ioreq_op ( call , GRPC_IOREQ_SEND_TRAILING_METADATA , error ) ; <nl> - finish_ioreq_op ( call , GRPC_IOREQ_SEND_STATUS , error ) ; <nl> - finish_ioreq_op ( call , GRPC_IOREQ_SEND_CLOSE , GRPC_OP_OK ) ; <nl> + finish_ioreq_op ( call , GRPC_IOREQ_SEND_TRAILING_METADATA , success ) ; <nl> + finish_ioreq_op ( call , GRPC_IOREQ_SEND_STATUS , success ) ; <nl> + finish_ioreq_op ( call , GRPC_IOREQ_SEND_CLOSE , 1 ) ; <nl> } <nl> call - > last_send_contains = 0 ; <nl> call - > sending = 0 ; <nl> static void call_on_done_recv ( void * pc , int success ) { <nl> } <nl> finish_read_ops ( call ) ; <nl> } else { <nl> - finish_ioreq_op ( call , GRPC_IOREQ_RECV_MESSAGE , GRPC_OP_ERROR ) ; <nl> - finish_ioreq_op ( call , GRPC_IOREQ_RECV_STATUS , GRPC_OP_ERROR ) ; <nl> - finish_ioreq_op ( call , GRPC_IOREQ_RECV_CLOSE , GRPC_OP_ERROR ) ; <nl> - finish_ioreq_op ( call , GRPC_IOREQ_RECV_TRAILING_METADATA , GRPC_OP_ERROR ) ; <nl> - finish_ioreq_op ( call , GRPC_IOREQ_RECV_INITIAL_METADATA , GRPC_OP_ERROR ) ; <nl> - finish_ioreq_op ( call , GRPC_IOREQ_RECV_STATUS_DETAILS , GRPC_OP_ERROR ) ; <nl> + finish_ioreq_op ( call , GRPC_IOREQ_RECV_MESSAGE , 0 ) ; <nl> + finish_ioreq_op ( call , GRPC_IOREQ_RECV_STATUS , 0 ) ; <nl> + finish_ioreq_op ( call , GRPC_IOREQ_RECV_CLOSE , 0 ) ; <nl> + finish_ioreq_op ( call , GRPC_IOREQ_RECV_TRAILING_METADATA , 0 ) ; <nl> + finish_ioreq_op ( call , GRPC_IOREQ_RECV_INITIAL_METADATA , 0 ) ; <nl> + finish_ioreq_op ( call , GRPC_IOREQ_RECV_STATUS_DETAILS , 0 ) ; <nl> } <nl> call - > recv_ops . nops = 0 ; <nl> unlock ( call ) ; <nl> static void finish_read_ops ( grpc_call * call ) { <nl> ( NULL = = ( * call - > request_data [ GRPC_IOREQ_RECV_MESSAGE ] . recv_message = <nl> grpc_bbq_pop ( & call - > incoming_queue ) ) ) ; <nl> if ( ! empty ) { <nl> - finish_live_ioreq_op ( call , GRPC_IOREQ_RECV_MESSAGE , GRPC_OP_OK ) ; <nl> + finish_live_ioreq_op ( call , GRPC_IOREQ_RECV_MESSAGE , 1 ) ; <nl> empty = grpc_bbq_empty ( & call - > incoming_queue ) ; <nl> } <nl> } else { <nl> static void finish_read_ops ( grpc_call * call ) { <nl> switch ( call - > read_state ) { <nl> case READ_STATE_STREAM_CLOSED : <nl> if ( empty ) { <nl> - finish_ioreq_op ( call , GRPC_IOREQ_RECV_CLOSE , GRPC_OP_OK ) ; <nl> + finish_ioreq_op ( call , GRPC_IOREQ_RECV_CLOSE , 1 ) ; <nl> } <nl> / * fallthrough * / <nl> case READ_STATE_READ_CLOSED : <nl> if ( empty ) { <nl> - finish_ioreq_op ( call , GRPC_IOREQ_RECV_MESSAGE , GRPC_OP_OK ) ; <nl> + finish_ioreq_op ( call , GRPC_IOREQ_RECV_MESSAGE , 1 ) ; <nl> } <nl> - finish_ioreq_op ( call , GRPC_IOREQ_RECV_STATUS , GRPC_OP_OK ) ; <nl> - finish_ioreq_op ( call , GRPC_IOREQ_RECV_STATUS_DETAILS , GRPC_OP_OK ) ; <nl> - finish_ioreq_op ( call , GRPC_IOREQ_RECV_TRAILING_METADATA , GRPC_OP_OK ) ; <nl> + finish_ioreq_op ( call , GRPC_IOREQ_RECV_STATUS , 1 ) ; <nl> + finish_ioreq_op ( call , GRPC_IOREQ_RECV_STATUS_DETAILS , 1 ) ; <nl> + finish_ioreq_op ( call , GRPC_IOREQ_RECV_TRAILING_METADATA , 1 ) ; <nl> / * fallthrough * / <nl> case READ_STATE_GOT_INITIAL_METADATA : <nl> - finish_ioreq_op ( call , GRPC_IOREQ_RECV_INITIAL_METADATA , GRPC_OP_OK ) ; <nl> + finish_ioreq_op ( call , GRPC_IOREQ_RECV_INITIAL_METADATA , 1 ) ; <nl> / * fallthrough * / <nl> case READ_STATE_INITIAL : <nl> / * do nothing * / <nl> static void finish_read_ops ( grpc_call * call ) { <nl> static void early_out_write_ops ( grpc_call * call ) { <nl> switch ( call - > write_state ) { <nl> case WRITE_STATE_WRITE_CLOSED : <nl> - finish_ioreq_op ( call , GRPC_IOREQ_SEND_MESSAGE , GRPC_OP_ERROR ) ; <nl> - finish_ioreq_op ( call , GRPC_IOREQ_SEND_STATUS , GRPC_OP_ERROR ) ; <nl> - finish_ioreq_op ( call , GRPC_IOREQ_SEND_TRAILING_METADATA , GRPC_OP_ERROR ) ; <nl> - finish_ioreq_op ( call , GRPC_IOREQ_SEND_CLOSE , GRPC_OP_OK ) ; <nl> + finish_ioreq_op ( call , GRPC_IOREQ_SEND_MESSAGE , 0 ) ; <nl> + finish_ioreq_op ( call , GRPC_IOREQ_SEND_STATUS , 0 ) ; <nl> + finish_ioreq_op ( call , GRPC_IOREQ_SEND_TRAILING_METADATA , 0 ) ; <nl> + finish_ioreq_op ( call , GRPC_IOREQ_SEND_CLOSE , 1 ) ; <nl> / * fallthrough * / <nl> case WRITE_STATE_STARTED : <nl> - finish_ioreq_op ( call , GRPC_IOREQ_SEND_INITIAL_METADATA , GRPC_OP_ERROR ) ; <nl> + finish_ioreq_op ( call , GRPC_IOREQ_SEND_INITIAL_METADATA , 0 ) ; <nl> / * fallthrough * / <nl> case WRITE_STATE_INITIAL : <nl> / * do nothing * / <nl> static grpc_call_error start_ioreq ( grpc_call * call , const grpc_ioreq * reqs , <nl> } <nl> <nl> master = & call - > masters [ set ] ; <nl> - master - > status = GRPC_OP_OK ; <nl> + master - > success = 1 ; <nl> master - > need_mask = have_ops ; <nl> master - > complete_mask = 0 ; <nl> master - > on_complete = completion ; <nl> static void set_cancelled_value ( grpc_status_code status , void * dest ) { <nl> * ( grpc_status_code * ) dest = ( status ! = GRPC_STATUS_OK ) ; <nl> } <nl> <nl> - static void finish_batch ( grpc_call * call , grpc_op_error result , void * tag ) { <nl> - grpc_cq_end_op ( call - > cq , tag , call , do_nothing , NULL , GRPC_OP_OK ) ; <nl> + static void finish_batch ( grpc_call * call , int success , void * tag ) { <nl> + grpc_cq_end_op ( call - > cq , tag , call , 1 ) ; <nl> } <nl> <nl> grpc_call_error grpc_call_start_batch ( grpc_call * call , const grpc_op * ops , <nl> grpc_call_error grpc_call_start_batch ( grpc_call * call , const grpc_op * ops , <nl> GRPC_CALL_LOG_BATCH ( GPR_INFO , call , ops , nops , tag ) ; <nl> <nl> if ( nops = = 0 ) { <nl> - grpc_cq_begin_op ( call - > cq , call , GRPC_OP_COMPLETE ) ; <nl> - grpc_cq_end_op ( call - > cq , tag , call , do_nothing , NULL , GRPC_OP_OK ) ; <nl> + grpc_cq_begin_op ( call - > cq , call ) ; <nl> + grpc_cq_end_op ( call - > cq , tag , call , 1 ) ; <nl> return GRPC_CALL_OK ; <nl> } <nl> <nl> grpc_call_error grpc_call_start_batch ( grpc_call * call , const grpc_op * ops , <nl> } <nl> } <nl> <nl> - grpc_cq_begin_op ( call - > cq , call , GRPC_OP_COMPLETE ) ; <nl> + grpc_cq_begin_op ( call - > cq , call ) ; <nl> <nl> return grpc_call_start_ioreq_and_call_back ( call , reqs , out , finish_batch , <nl> tag ) ; <nl> mmm a / src / core / surface / call . h <nl> ppp b / src / core / surface / call . h <nl> typedef struct { <nl> grpc_ioreq_data data ; <nl> } grpc_ioreq ; <nl> <nl> - typedef void ( * grpc_ioreq_completion_func ) ( grpc_call * call , <nl> - grpc_op_error status , <nl> + typedef void ( * grpc_ioreq_completion_func ) ( grpc_call * call , int success , <nl> void * user_data ) ; <nl> <nl> grpc_call * grpc_call_create ( grpc_channel * channel , grpc_completion_queue * cq , <nl> mmm a / src / core / surface / completion_queue . c <nl> ppp b / src / core / surface / completion_queue . c <nl> <nl> function ( on_finish ) that is hidden from outside this module * / <nl> typedef struct event { <nl> grpc_event base ; <nl> - grpc_event_finish_func on_finish ; <nl> - void * on_finish_user_data ; <nl> struct event * queue_next ; <nl> struct event * queue_prev ; <nl> struct event * bucket_next ; <nl> struct grpc_completion_queue { <nl> event * queue ; <nl> / * Fixed size chained hash table of events for pluck ( ) * / <nl> event * buckets [ NUM_TAG_BUCKETS ] ; <nl> - <nl> - # ifndef NDEBUG <nl> - / * Debug support : track which operations are in flight at any given time * / <nl> - gpr_atm pending_op_count [ GRPC_COMPLETION_DO_NOT_USE ] ; <nl> - # endif <nl> } ; <nl> <nl> - / * Default do - nothing on_finish function * / <nl> - static void null_on_finish ( void * user_data , grpc_op_error error ) { } <nl> - <nl> grpc_completion_queue * grpc_completion_queue_create ( void ) { <nl> grpc_completion_queue * cc = gpr_malloc ( sizeof ( grpc_completion_queue ) ) ; <nl> memset ( cc , 0 , sizeof ( * cc ) ) ; <nl> void grpc_completion_queue_dont_poll_test_only ( grpc_completion_queue * cc ) { <nl> members can be filled in . <nl> Requires GRPC_POLLSET_MU ( & cc - > pollset ) locked . * / <nl> static event * add_locked ( grpc_completion_queue * cc , grpc_completion_type type , <nl> - void * tag , grpc_call * call , <nl> - grpc_event_finish_func on_finish , void * user_data ) { <nl> + void * tag , grpc_call * call ) { <nl> event * ev = gpr_malloc ( sizeof ( event ) ) ; <nl> gpr_uintptr bucket = ( ( gpr_uintptr ) tag ) % NUM_TAG_BUCKETS ; <nl> ev - > base . type = type ; <nl> ev - > base . tag = tag ; <nl> - ev - > base . call = call ; <nl> - ev - > on_finish = on_finish ? on_finish : null_on_finish ; <nl> - ev - > on_finish_user_data = user_data ; <nl> if ( cc - > queue = = NULL ) { <nl> cc - > queue = ev - > queue_next = ev - > queue_prev = ev ; <nl> } else { <nl> static event * add_locked ( grpc_completion_queue * cc , grpc_completion_type type , <nl> return ev ; <nl> } <nl> <nl> - void grpc_cq_begin_op ( grpc_completion_queue * cc , grpc_call * call , <nl> - grpc_completion_type type ) { <nl> + void grpc_cq_begin_op ( grpc_completion_queue * cc , grpc_call * call ) { <nl> gpr_ref ( & cc - > refs ) ; <nl> if ( call ) GRPC_CALL_INTERNAL_REF ( call , " cq " ) ; <nl> - # ifndef NDEBUG <nl> - gpr_atm_no_barrier_fetch_add ( & cc - > pending_op_count [ type ] , 1 ) ; <nl> - # endif <nl> } <nl> <nl> / * Signal the end of an operation - if this is the last waiting - to - be - queued <nl> event , then enter shutdown mode * / <nl> static void end_op_locked ( grpc_completion_queue * cc , <nl> grpc_completion_type type ) { <nl> - # ifndef NDEBUG <nl> - GPR_ASSERT ( gpr_atm_full_fetch_add ( & cc - > pending_op_count [ type ] , - 1 ) > 0 ) ; <nl> - # endif <nl> if ( gpr_unref ( & cc - > refs ) ) { <nl> GPR_ASSERT ( ! cc - > shutdown ) ; <nl> GPR_ASSERT ( cc - > shutdown_called ) ; <nl> static void end_op_locked ( grpc_completion_queue * cc , <nl> } <nl> } <nl> <nl> - void grpc_cq_end_server_shutdown ( grpc_completion_queue * cc , void * tag ) { <nl> - gpr_mu_lock ( GRPC_POLLSET_MU ( & cc - > pollset ) ) ; <nl> - add_locked ( cc , GRPC_SERVER_SHUTDOWN , tag , NULL , NULL , NULL ) ; <nl> - end_op_locked ( cc , GRPC_SERVER_SHUTDOWN ) ; <nl> - gpr_mu_unlock ( GRPC_POLLSET_MU ( & cc - > pollset ) ) ; <nl> - } <nl> - <nl> void grpc_cq_end_op ( grpc_completion_queue * cc , void * tag , grpc_call * call , <nl> - grpc_event_finish_func on_finish , void * user_data , <nl> - grpc_op_error error ) { <nl> + int success ) { <nl> event * ev ; <nl> gpr_mu_lock ( GRPC_POLLSET_MU ( & cc - > pollset ) ) ; <nl> - ev = add_locked ( cc , GRPC_OP_COMPLETE , tag , call , on_finish , user_data ) ; <nl> - ev - > base . data . op_complete = error ; <nl> + ev = add_locked ( cc , GRPC_OP_COMPLETE , tag , call ) ; <nl> + ev - > base . success = success ; <nl> end_op_locked ( cc , GRPC_OP_COMPLETE ) ; <nl> gpr_mu_unlock ( GRPC_POLLSET_MU ( & cc - > pollset ) ) ; <nl> } <nl> void grpc_cq_end_op ( grpc_completion_queue * cc , void * tag , grpc_call * call , <nl> static event * create_shutdown_event ( void ) { <nl> event * ev = gpr_malloc ( sizeof ( event ) ) ; <nl> ev - > base . type = GRPC_QUEUE_SHUTDOWN ; <nl> - ev - > base . call = NULL ; <nl> ev - > base . tag = NULL ; <nl> - ev - > on_finish = null_on_finish ; <nl> return ev ; <nl> } <nl> <nl> - grpc_event * grpc_completion_queue_next ( grpc_completion_queue * cc , <nl> - gpr_timespec deadline ) { <nl> + grpc_event grpc_completion_queue_next ( grpc_completion_queue * cc , <nl> + gpr_timespec deadline ) { <nl> event * ev = NULL ; <nl> + grpc_event ret ; <nl> <nl> gpr_mu_lock ( GRPC_POLLSET_MU ( & cc - > pollset ) ) ; <nl> for ( ; ; ) { <nl> grpc_event * grpc_completion_queue_next ( grpc_completion_queue * cc , <nl> if ( gpr_cv_wait ( GRPC_POLLSET_CV ( & cc - > pollset ) , <nl> GRPC_POLLSET_MU ( & cc - > pollset ) , deadline ) ) { <nl> gpr_mu_unlock ( GRPC_POLLSET_MU ( & cc - > pollset ) ) ; <nl> - return NULL ; <nl> + memset ( & ret , 0 , sizeof ( ret ) ) ; <nl> + ret . type = GRPC_QUEUE_TIMEOUT ; <nl> + return ret ; <nl> } <nl> } <nl> gpr_mu_unlock ( GRPC_POLLSET_MU ( & cc - > pollset ) ) ; <nl> - GRPC_SURFACE_TRACE_RETURNED_EVENT ( cc , & ev - > base ) ; <nl> - return & ev - > base ; <nl> + ret = ev - > base ; <nl> + gpr_free ( ev ) ; <nl> + GRPC_SURFACE_TRACE_RETURNED_EVENT ( cc , & ret ) ; <nl> + return ret ; <nl> } <nl> <nl> static event * pluck_event ( grpc_completion_queue * cc , void * tag ) { <nl> static event * pluck_event ( grpc_completion_queue * cc , void * tag ) { <nl> return NULL ; <nl> } <nl> <nl> - grpc_event * grpc_completion_queue_pluck ( grpc_completion_queue * cc , void * tag , <nl> - gpr_timespec deadline ) { <nl> + grpc_event grpc_completion_queue_pluck ( grpc_completion_queue * cc , void * tag , <nl> + gpr_timespec deadline ) { <nl> event * ev = NULL ; <nl> + grpc_event ret ; <nl> <nl> gpr_mu_lock ( GRPC_POLLSET_MU ( & cc - > pollset ) ) ; <nl> for ( ; ; ) { <nl> grpc_event * grpc_completion_queue_pluck ( grpc_completion_queue * cc , void * tag , <nl> if ( gpr_cv_wait ( GRPC_POLLSET_CV ( & cc - > pollset ) , <nl> GRPC_POLLSET_MU ( & cc - > pollset ) , deadline ) ) { <nl> gpr_mu_unlock ( GRPC_POLLSET_MU ( & cc - > pollset ) ) ; <nl> - return NULL ; <nl> + memset ( & ret , 0 , sizeof ( ret ) ) ; <nl> + ret . type = GRPC_QUEUE_TIMEOUT ; <nl> + return ret ; <nl> } <nl> } <nl> gpr_mu_unlock ( GRPC_POLLSET_MU ( & cc - > pollset ) ) ; <nl> + ret = ev - > base ; <nl> + gpr_free ( ev ) ; <nl> GRPC_SURFACE_TRACE_RETURNED_EVENT ( cc , & ev - > base ) ; <nl> - return & ev - > base ; <nl> + return ret ; <nl> } <nl> <nl> / * Shutdown simply drops a ref that we reserved at creation time ; if we drop <nl> void grpc_completion_queue_destroy ( grpc_completion_queue * cc ) { <nl> grpc_cq_internal_unref ( cc ) ; <nl> } <nl> <nl> - void grpc_event_finish ( grpc_event * base ) { <nl> - event * ev = ( event * ) base ; <nl> - ev - > on_finish ( ev - > on_finish_user_data , GRPC_OP_OK ) ; <nl> - if ( ev - > base . call ) { <nl> - GRPC_CALL_INTERNAL_UNREF ( ev - > base . call , " cq " , 1 ) ; <nl> - } <nl> - gpr_free ( ev ) ; <nl> - } <nl> - <nl> - void grpc_cq_dump_pending_ops ( grpc_completion_queue * cc ) { <nl> - # ifndef NDEBUG <nl> - char tmp [ GRPC_COMPLETION_DO_NOT_USE * ( 1 + GPR_LTOA_MIN_BUFSIZE ) ] ; <nl> - char * p = tmp ; <nl> - int i ; <nl> - <nl> - for ( i = 0 ; i < GRPC_COMPLETION_DO_NOT_USE ; i + + ) { <nl> - * p + + = ' ' ; <nl> - p + = gpr_ltoa ( cc - > pending_op_count [ i ] , p ) ; <nl> - } <nl> - <nl> - gpr_log ( GPR_INFO , " pending ops : % s " , tmp ) ; <nl> - # endif <nl> - } <nl> - <nl> grpc_pollset * grpc_cq_pollset ( grpc_completion_queue * cc ) { <nl> return & cc - > pollset ; <nl> } <nl> mmm a / src / core / surface / completion_queue . h <nl> ppp b / src / core / surface / completion_queue . h <nl> <nl> # include " src / core / iomgr / pollset . h " <nl> # include < grpc / grpc . h > <nl> <nl> - / * A finish func is executed whenever the event consumer calls <nl> - grpc_event_finish * / <nl> - typedef void ( * grpc_event_finish_func ) ( void * user_data , grpc_op_error error ) ; <nl> - <nl> void grpc_cq_internal_ref ( grpc_completion_queue * cc ) ; <nl> void grpc_cq_internal_unref ( grpc_completion_queue * cc ) ; <nl> <nl> / * Flag that an operation is beginning : the completion channel will not finish <nl> shutdown until a corrensponding grpc_cq_end_ * call is made * / <nl> - void grpc_cq_begin_op ( grpc_completion_queue * cc , grpc_call * call , <nl> - grpc_completion_type type ) ; <nl> + void grpc_cq_begin_op ( grpc_completion_queue * cc , grpc_call * call ) ; <nl> <nl> / * grpc_cq_end_ * functions pair with a grpc_cq_begin_op <nl> <nl> void grpc_cq_begin_op ( grpc_completion_queue * cc , grpc_call * call , <nl> <nl> / * Queue a GRPC_OP_COMPLETED operation * / <nl> void grpc_cq_end_op ( grpc_completion_queue * cc , void * tag , grpc_call * call , <nl> - grpc_event_finish_func on_finish , void * user_data , <nl> - grpc_op_error error ) ; <nl> - <nl> - void grpc_cq_end_server_shutdown ( grpc_completion_queue * cc , void * tag ) ; <nl> + int success ) ; <nl> <nl> / * disable polling for some tests * / <nl> void grpc_completion_queue_dont_poll_test_only ( grpc_completion_queue * cc ) ; <nl> <nl> - void grpc_cq_dump_pending_ops ( grpc_completion_queue * cc ) ; <nl> - <nl> grpc_pollset * grpc_cq_pollset ( grpc_completion_queue * cc ) ; <nl> <nl> void grpc_cq_hack_spin_pollset ( grpc_completion_queue * cc ) ; <nl> mmm a / src / core / surface / event_string . c <nl> ppp b / src / core / surface / event_string . c <nl> <nl> <nl> static void addhdr ( gpr_strvec * buf , grpc_event * ev ) { <nl> char * tmp ; <nl> - gpr_asprintf ( & tmp , " tag : % p call : % p " , ev - > tag , ( void * ) ev - > call ) ; <nl> + gpr_asprintf ( & tmp , " tag : % p " , ev - > tag ) ; <nl> gpr_strvec_add ( buf , tmp ) ; <nl> } <nl> <nl> - static const char * errstr ( grpc_op_error err ) { <nl> - switch ( err ) { <nl> - case GRPC_OP_OK : <nl> - return " OK " ; <nl> - case GRPC_OP_ERROR : <nl> - return " ERROR " ; <nl> - } <nl> - return " UNKNOWN_UNKNOWN " ; <nl> - } <nl> + static const char * errstr ( int success ) { return success ? " OK " : " ERROR " ; } <nl> <nl> - static void adderr ( gpr_strvec * buf , grpc_op_error err ) { <nl> + static void adderr ( gpr_strvec * buf , int success ) { <nl> char * tmp ; <nl> - gpr_asprintf ( & tmp , " err = % s " , errstr ( err ) ) ; <nl> + gpr_asprintf ( & tmp , " % s " , errstr ( success ) ) ; <nl> gpr_strvec_add ( buf , tmp ) ; <nl> } <nl> <nl> char * grpc_event_string ( grpc_event * ev ) { <nl> gpr_strvec_init ( & buf ) ; <nl> <nl> switch ( ev - > type ) { <nl> - case GRPC_SERVER_SHUTDOWN : <nl> - gpr_strvec_add ( & buf , gpr_strdup ( " SERVER_SHUTDOWN " ) ) ; <nl> + case GRPC_QUEUE_TIMEOUT : <nl> + gpr_strvec_add ( & buf , gpr_strdup ( " QUEUE_TIMEOUT " ) ) ; <nl> break ; <nl> case GRPC_QUEUE_SHUTDOWN : <nl> gpr_strvec_add ( & buf , gpr_strdup ( " QUEUE_SHUTDOWN " ) ) ; <nl> char * grpc_event_string ( grpc_event * ev ) { <nl> case GRPC_OP_COMPLETE : <nl> gpr_strvec_add ( & buf , gpr_strdup ( " OP_COMPLETE : " ) ) ; <nl> addhdr ( & buf , ev ) ; <nl> - adderr ( & buf , ev - > data . op_complete ) ; <nl> - break ; <nl> - case GRPC_COMPLETION_DO_NOT_USE : <nl> - gpr_strvec_add ( & buf , gpr_strdup ( " DO_NOT_USE ( this is a bug ) " ) ) ; <nl> - addhdr ( & buf , ev ) ; <nl> + adderr ( & buf , ev - > success ) ; <nl> break ; <nl> } <nl> <nl> mmm a / src / core / surface / server . c <nl> ppp b / src / core / surface / server . c <nl> struct call_data { <nl> # define SERVER_FROM_CALL_ELEM ( elem ) \ <nl> ( ( ( channel_data * ) ( elem ) - > channel_data ) - > server ) <nl> <nl> - static void do_nothing ( void * unused , grpc_op_error ignored ) { } <nl> - <nl> static void begin_call ( grpc_server * server , call_data * calld , <nl> requested_call * rc ) ; <nl> static void fail_call ( grpc_server * server , requested_call * rc ) ; <nl> static void destroy_call_elem ( grpc_call_element * elem ) { <nl> if ( chand - > server - > shutdown & & chand - > server - > lists [ ALL_CALLS ] = = NULL ) { <nl> for ( i = 0 ; i < chand - > server - > num_shutdown_tags ; i + + ) { <nl> for ( j = 0 ; j < chand - > server - > cq_count ; j + + ) { <nl> - grpc_cq_end_server_shutdown ( chand - > server - > cqs [ j ] , <nl> - chand - > server - > shutdown_tags [ i ] ) ; <nl> + grpc_cq_end_op ( chand - > server - > cqs [ j ] , chand - > server - > shutdown_tags [ i ] , <nl> + NULL , 1 ) ; <nl> } <nl> } <nl> } <nl> static void shutdown_internal ( grpc_server * server , gpr_uint8 have_shutdown_tag , <nl> gpr_mu_lock ( & server - > mu ) ; <nl> if ( have_shutdown_tag ) { <nl> for ( i = 0 ; i < server - > cq_count ; i + + ) { <nl> - grpc_cq_begin_op ( server - > cqs [ i ] , NULL , GRPC_SERVER_SHUTDOWN ) ; <nl> + grpc_cq_begin_op ( server - > cqs [ i ] , NULL ) ; <nl> } <nl> server - > shutdown_tags = <nl> gpr_realloc ( server - > shutdown_tags , <nl> static void shutdown_internal ( grpc_server * server , gpr_uint8 have_shutdown_tag , <nl> if ( server - > lists [ ALL_CALLS ] = = NULL ) { <nl> for ( i = 0 ; i < server - > num_shutdown_tags ; i + + ) { <nl> for ( j = 0 ; j < server - > cq_count ; j + + ) { <nl> - grpc_cq_end_server_shutdown ( server - > cqs [ j ] , server - > shutdown_tags [ i ] ) ; <nl> + grpc_cq_end_op ( server - > cqs [ j ] , server - > shutdown_tags [ i ] , NULL , 1 ) ; <nl> } <nl> } <nl> } <nl> grpc_call_error grpc_server_request_call ( grpc_server * server , grpc_call * * call , <nl> grpc_completion_queue * cq_bind , <nl> void * tag ) { <nl> requested_call rc ; <nl> - grpc_cq_begin_op ( server - > unregistered_cq , NULL , GRPC_OP_COMPLETE ) ; <nl> + grpc_cq_begin_op ( server - > unregistered_cq , NULL ) ; <nl> rc . type = BATCH_CALL ; <nl> rc . tag = tag ; <nl> rc . data . batch . cq_bind = cq_bind ; <nl> grpc_call_error grpc_server_request_registered_call ( <nl> grpc_completion_queue * cq_bind , void * tag ) { <nl> requested_call rc ; <nl> registered_method * registered_method = rm ; <nl> - grpc_cq_begin_op ( registered_method - > cq , NULL , GRPC_OP_COMPLETE ) ; <nl> + grpc_cq_begin_op ( registered_method - > cq , NULL ) ; <nl> rc . type = REGISTERED_CALL ; <nl> rc . tag = tag ; <nl> rc . data . registered . cq_bind = cq_bind ; <nl> grpc_call_error grpc_server_request_registered_call ( <nl> return queue_call_request ( server , & rc ) ; <nl> } <nl> <nl> - static void publish_registered_or_batch ( grpc_call * call , grpc_op_error status , <nl> + static void publish_registered_or_batch ( grpc_call * call , int success , <nl> void * tag ) ; <nl> - static void publish_was_not_set ( grpc_call * call , grpc_op_error status , <nl> - void * tag ) { <nl> + static void publish_was_not_set ( grpc_call * call , int success , void * tag ) { <nl> abort ( ) ; <nl> } <nl> <nl> static void fail_call ( grpc_server * server , requested_call * rc ) { <nl> case BATCH_CALL : <nl> * rc - > data . batch . call = NULL ; <nl> rc - > data . batch . initial_metadata - > count = 0 ; <nl> - grpc_cq_end_op ( server - > unregistered_cq , rc - > tag , NULL , do_nothing , NULL , <nl> - GRPC_OP_ERROR ) ; <nl> + grpc_cq_end_op ( server - > unregistered_cq , rc - > tag , NULL , 0 ) ; <nl> break ; <nl> case REGISTERED_CALL : <nl> * rc - > data . registered . call = NULL ; <nl> rc - > data . registered . initial_metadata - > count = 0 ; <nl> grpc_cq_end_op ( rc - > data . registered . registered_method - > cq , rc - > tag , NULL , <nl> - do_nothing , NULL , GRPC_OP_ERROR ) ; <nl> + 0 ) ; <nl> break ; <nl> } <nl> } <nl> <nl> - static void publish_registered_or_batch ( grpc_call * call , grpc_op_error status , <nl> + static void publish_registered_or_batch ( grpc_call * call , int success , <nl> void * tag ) { <nl> grpc_call_element * elem = <nl> grpc_call_stack_element ( grpc_call_get_call_stack ( call ) , 0 ) ; <nl> call_data * calld = elem - > call_data ; <nl> - grpc_cq_end_op ( calld - > cq_new , tag , call , do_nothing , NULL , status ) ; <nl> + grpc_cq_end_op ( calld - > cq_new , tag , call , success ) ; <nl> } <nl> <nl> const grpc_channel_args * grpc_server_get_channel_args ( grpc_server * server ) { <nl> mmm a / src / cpp / client / client_context . cc <nl> ppp b / src / cpp / client / client_context . cc <nl> ClientContext : : ~ ClientContext ( ) { <nl> grpc_call_destroy ( call_ ) ; <nl> } <nl> if ( cq_ ) { <nl> - grpc_completion_queue_shutdown ( cq_ ) ; <nl> / / Drain cq_ . <nl> - grpc_event * ev ; <nl> - grpc_completion_type t ; <nl> - do { <nl> - ev = grpc_completion_queue_next ( cq_ , gpr_inf_future ) ; <nl> - t = ev - > type ; <nl> - grpc_event_finish ( ev ) ; <nl> - } while ( t ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> + grpc_completion_queue_shutdown ( cq_ ) ; <nl> + while ( grpc_completion_queue_next ( cq_ , gpr_inf_future ) . type ! = <nl> + GRPC_QUEUE_SHUTDOWN ) <nl> + ; <nl> grpc_completion_queue_destroy ( cq_ ) ; <nl> } <nl> } <nl> mmm a / src / cpp / common / completion_queue . cc <nl> ppp b / src / cpp / common / completion_queue . cc <nl> CompletionQueue : : ~ CompletionQueue ( ) { grpc_completion_queue_destroy ( cq_ ) ; } <nl> <nl> void CompletionQueue : : Shutdown ( ) { grpc_completion_queue_shutdown ( cq_ ) ; } <nl> <nl> - / / Helper class so we can declare a unique_ptr with grpc_event <nl> - class EventDeleter { <nl> - public : <nl> - void operator ( ) ( grpc_event * ev ) { <nl> - if ( ev ) grpc_event_finish ( ev ) ; <nl> - } <nl> - } ; <nl> - <nl> CompletionQueue : : NextStatus CompletionQueue : : AsyncNextInternal ( <nl> void * * tag , bool * ok , gpr_timespec deadline ) { <nl> - std : : unique_ptr < grpc_event , EventDeleter > ev ; <nl> - <nl> for ( ; ; ) { <nl> - ev . reset ( grpc_completion_queue_next ( cq_ , deadline ) ) ; <nl> - if ( ! ev ) { / * got a NULL back because deadline passed * / <nl> - return TIMEOUT ; <nl> - } <nl> - if ( ev - > type = = GRPC_QUEUE_SHUTDOWN ) { <nl> - return SHUTDOWN ; <nl> - } <nl> - auto cq_tag = static_cast < CompletionQueueTag * > ( ev - > tag ) ; <nl> - * ok = ev - > data . op_complete = = GRPC_OP_OK ; <nl> - * tag = cq_tag ; <nl> - if ( cq_tag - > FinalizeResult ( tag , ok ) ) { <nl> - return GOT_EVENT ; <nl> + auto ev = grpc_completion_queue_next ( cq_ , deadline ) ; <nl> + switch ( ev . type ) { <nl> + case GRPC_QUEUE_TIMEOUT : <nl> + return TIMEOUT ; <nl> + case GRPC_QUEUE_SHUTDOWN : <nl> + return SHUTDOWN ; <nl> + case GRPC_OP_COMPLETE : <nl> + auto cq_tag = static_cast < CompletionQueueTag * > ( ev . tag ) ; <nl> + * ok = ev . success ! = 0 ; <nl> + * tag = cq_tag ; <nl> + if ( cq_tag - > FinalizeResult ( tag , ok ) ) { <nl> + return GOT_EVENT ; <nl> + } <nl> + break ; <nl> } <nl> } <nl> } <nl> <nl> bool CompletionQueue : : Pluck ( CompletionQueueTag * tag ) { <nl> - std : : unique_ptr < grpc_event , EventDeleter > ev ; <nl> - <nl> - ev . reset ( grpc_completion_queue_pluck ( cq_ , tag , gpr_inf_future ) ) ; <nl> - bool ok = ev - > data . op_complete = = GRPC_OP_OK ; <nl> + auto ev = grpc_completion_queue_pluck ( cq_ , tag , gpr_inf_future ) ; <nl> + bool ok = ev . success ! = 0 ; <nl> void * ignored = tag ; <nl> GPR_ASSERT ( tag - > FinalizeResult ( & ignored , & ok ) ) ; <nl> GPR_ASSERT ( ignored = = tag ) ; <nl> / / Ignore mutations by FinalizeResult : Pluck returns the C API status <nl> - return ev - > data . op_complete = = GRPC_OP_OK ; <nl> + return ev . success ! = 0 ; <nl> } <nl> <nl> void CompletionQueue : : TryPluck ( CompletionQueueTag * tag ) { <nl> - std : : unique_ptr < grpc_event , EventDeleter > ev ; <nl> - <nl> - ev . reset ( grpc_completion_queue_pluck ( cq_ , tag , gpr_time_0 ) ) ; <nl> - if ( ! ev ) return ; <nl> - bool ok = ev - > data . op_complete = = GRPC_OP_OK ; <nl> + auto ev = grpc_completion_queue_pluck ( cq_ , tag , gpr_time_0 ) ; <nl> + if ( ev . type = = GRPC_QUEUE_TIMEOUT ) return ; <nl> + bool ok = ev . success ! = 0 ; <nl> void * ignored = tag ; <nl> / / the tag must be swallowed if using TryPluck <nl> GPR_ASSERT ( ! tag - > FinalizeResult ( & ignored , & ok ) ) ; <nl> mmm a / src / csharp / ext / grpc_csharp_ext . c <nl> ppp b / src / csharp / ext / grpc_csharp_ext . c <nl> grpc_byte_buffer * string_to_byte_buffer ( const char * buffer , size_t len ) { <nl> return bb ; <nl> } <nl> <nl> - typedef void ( GPR_CALLTYPE * callback_funcptr ) ( grpc_op_error op_error , <nl> - void * batch_context ) ; <nl> + typedef void ( GPR_CALLTYPE * callback_funcptr ) ( int success , void * batch_context ) ; <nl> <nl> / * <nl> * Helper to maintain lifetime of batch op inputs and store batch op outputs . <nl> grpcsharp_completion_queue_destroy ( grpc_completion_queue * cq ) { <nl> <nl> GPR_EXPORT grpc_completion_type GPR_CALLTYPE <nl> grpcsharp_completion_queue_next_with_callback ( grpc_completion_queue * cq ) { <nl> - grpc_event * ev ; <nl> + grpc_event ev ; <nl> grpcsharp_batch_context * batch_context ; <nl> grpc_completion_type t ; <nl> void ( GPR_CALLTYPE * callback ) ( grpc_event * ) ; <nl> <nl> ev = grpc_completion_queue_next ( cq , gpr_inf_future ) ; <nl> - t = ev - > type ; <nl> - if ( t = = GRPC_OP_COMPLETE & & ev - > tag ) { <nl> + t = ev . type ; <nl> + if ( t = = GRPC_OP_COMPLETE & & ev . tag ) { <nl> / * NEW API handler * / <nl> - batch_context = ( grpcsharp_batch_context * ) ev - > tag ; <nl> - batch_context - > callback ( ev - > data . op_complete , batch_context ) ; <nl> + batch_context = ( grpcsharp_batch_context * ) ev . tag ; <nl> + batch_context - > callback ( ev . success , batch_context ) ; <nl> grpcsharp_batch_context_destroy ( batch_context ) ; <nl> - } else if ( ev - > tag ) { <nl> + } else if ( ev . tag ) { <nl> / * call the callback in ev - > tag * / <nl> / * C forbids to cast object pointers to function pointers , so <nl> * we cast to intptr first . <nl> * / <nl> - callback = ( void ( GPR_CALLTYPE * ) ( grpc_event * ) ) ( gpr_intptr ) ev - > tag ; <nl> - ( * callback ) ( ev ) ; <nl> + callback = ( void ( GPR_CALLTYPE * ) ( grpc_event * ) ) ( gpr_intptr ) ev . tag ; <nl> + ( * callback ) ( & ev ) ; <nl> } <nl> - grpc_event_finish ( ev ) ; <nl> <nl> / * return completion type to allow some handling for events that have no <nl> * tag - such as GRPC_QUEUE_SHUTDOWN <nl> GPR_EXPORT void GPR_CALLTYPE grpcsharp_redirect_log ( grpcsharp_log_func func ) { <nl> / * For testing * / <nl> GPR_EXPORT void GPR_CALLTYPE <nl> grpcsharp_test_callback ( callback_funcptr callback ) { <nl> - callback ( GRPC_OP_OK , NULL ) ; <nl> + callback ( 1 , NULL ) ; <nl> } <nl> <nl> / * For testing * / <nl> mmm a / src / node / ext / completion_queue_async_worker . cc <nl> ppp b / src / node / ext / completion_queue_async_worker . cc <nl> CompletionQueueAsyncWorker : : ~ CompletionQueueAsyncWorker ( ) { } <nl> <nl> void CompletionQueueAsyncWorker : : Execute ( ) { <nl> result = grpc_completion_queue_next ( queue , gpr_inf_future ) ; <nl> - if ( result - > data . op_complete ! = GRPC_OP_OK ) { <nl> + if ( ! result . success ) { <nl> SetErrorMessage ( " The batch encountered an error " ) ; <nl> } <nl> } <nl> void CompletionQueueAsyncWorker : : HandleOKCallback ( ) { <nl> } else { <nl> current_threads - = 1 ; <nl> } <nl> - NanCallback * callback = GetTagCallback ( result - > tag ) ; <nl> - Handle < Value > argv [ ] = { NanNull ( ) , GetTagNodeValue ( result - > tag ) } ; <nl> + NanCallback * callback = GetTagCallback ( result . tag ) ; <nl> + Handle < Value > argv [ ] = { NanNull ( ) , GetTagNodeValue ( result . tag ) } ; <nl> callback - > Call ( 2 , argv ) ; <nl> <nl> - DestroyTag ( result - > tag ) ; <nl> - grpc_event_finish ( result ) ; <nl> - result = NULL ; <nl> + DestroyTag ( result . tag ) ; <nl> } <nl> <nl> void CompletionQueueAsyncWorker : : HandleErrorCallback ( ) { <nl> NanScope ( ) ; <nl> - NanCallback * callback = GetTagCallback ( result - > tag ) ; <nl> + NanCallback * callback = GetTagCallback ( result . tag ) ; <nl> Handle < Value > argv [ ] = { NanError ( ErrorMessage ( ) ) } ; <nl> <nl> callback - > Call ( 1 , argv ) ; <nl> <nl> - DestroyTag ( result - > tag ) ; <nl> - grpc_event_finish ( result ) ; <nl> - result = NULL ; <nl> + DestroyTag ( result . tag ) ; <nl> } <nl> <nl> } / / namespace node <nl> mmm a / src / node / ext / completion_queue_async_worker . h <nl> ppp b / src / node / ext / completion_queue_async_worker . h <nl> class CompletionQueueAsyncWorker : public NanAsyncWorker { <nl> void HandleErrorCallback ( ) ; <nl> <nl> private : <nl> - grpc_event * result ; <nl> + grpc_event result ; <nl> <nl> static grpc_completion_queue * queue ; <nl> <nl> mmm a / src / php / ext / grpc / call . c <nl> ppp b / src / php / ext / grpc / call . c <nl> zend_class_entry * grpc_ce_call ; <nl> / * Frees and destroys an instance of wrapped_grpc_call * / <nl> void free_wrapped_grpc_call ( void * object TSRMLS_DC ) { <nl> wrapped_grpc_call * call = ( wrapped_grpc_call * ) object ; <nl> - grpc_event * event ; <nl> if ( call - > owned & & call - > wrapped ! = NULL ) { <nl> if ( call - > queue ! = NULL ) { <nl> grpc_completion_queue_shutdown ( call - > queue ) ; <nl> - event = grpc_completion_queue_next ( call - > queue , gpr_inf_future ) ; <nl> - while ( event ! = NULL ) { <nl> - if ( event - > type = = GRPC_QUEUE_SHUTDOWN ) { <nl> - break ; <nl> - } <nl> - event = grpc_completion_queue_next ( call - > queue , gpr_inf_future ) ; <nl> - } <nl> + while ( grpc_completion_queue_next ( call - > queue , gpr_inf_future ) . type ! = <nl> + GRPC_QUEUE_SHUTDOWN ) <nl> + ; <nl> grpc_completion_queue_destroy ( call - > queue ) ; <nl> } <nl> grpc_call_destroy ( call - > wrapped ) ; <nl> PHP_METHOD ( Call , startBatch ) { <nl> grpc_byte_buffer * message ; <nl> int cancelled ; <nl> grpc_call_error error ; <nl> - grpc_event * event ; <nl> + grpc_event event ; <nl> zval * result ; <nl> char * message_str ; <nl> size_t message_len ; <nl> PHP_METHOD ( Call , startBatch ) { <nl> } <nl> event = grpc_completion_queue_pluck ( call - > queue , call - > wrapped , <nl> gpr_inf_future ) ; <nl> - if ( event - > data . op_complete ! = GRPC_OP_OK ) { <nl> + if ( ! event . success ) { <nl> zend_throw_exception ( spl_ce_LogicException , <nl> " The batch failed for some reason " , <nl> 1 TSRMLS_CC ) ; <nl> mmm a / src / php / ext / grpc / server . c <nl> ppp b / src / php / ext / grpc / server . c <nl> zend_class_entry * grpc_ce_server ; <nl> / * Frees and destroys an instance of wrapped_grpc_server * / <nl> void free_wrapped_grpc_server ( void * object TSRMLS_DC ) { <nl> wrapped_grpc_server * server = ( wrapped_grpc_server * ) object ; <nl> - grpc_event * event ; <nl> if ( server - > queue ! = NULL ) { <nl> grpc_completion_queue_shutdown ( server - > queue ) ; <nl> - event = grpc_completion_queue_next ( server - > queue , gpr_inf_future ) ; <nl> - while ( event ! = NULL ) { <nl> - if ( event - > type = = GRPC_QUEUE_SHUTDOWN ) { <nl> - break ; <nl> - } <nl> - event = grpc_completion_queue_next ( server - > queue , gpr_inf_future ) ; <nl> - } <nl> + while ( grpc_completion_queue_next ( server - > queue , gpr_inf_future ) . type ! = <nl> + GRPC_QUEUE_SHUTDOWN ) <nl> + ; <nl> grpc_completion_queue_destroy ( server - > queue ) ; <nl> } <nl> if ( server - > wrapped ! = NULL ) { <nl> PHP_METHOD ( Server , requestCall ) { <nl> grpc_call_details details ; <nl> grpc_metadata_array metadata ; <nl> zval * result ; <nl> - grpc_event * event ; <nl> + grpc_event event ; <nl> MAKE_STD_ZVAL ( result ) ; <nl> object_init ( result ) ; <nl> grpc_call_details_init ( & details ) ; <nl> PHP_METHOD ( Server , requestCall ) { <nl> goto cleanup ; <nl> } <nl> event = grpc_completion_queue_pluck ( server - > queue , NULL , gpr_inf_future ) ; <nl> - if ( event - > data . op_complete ! = GRPC_OP_OK ) { <nl> + if ( ! event . success ) { <nl> zend_throw_exception ( spl_ce_LogicException , <nl> " Failed to request a call for some reason " , <nl> 1 TSRMLS_CC ) ; <nl> mmm a / src / python / src / grpc / _adapter / _completion_queue . c <nl> ppp b / src / python / src / grpc / _adapter / _completion_queue . c <nl> static PyObject * pygrpc_completion_queue_get ( CompletionQueue * self , <nl> PyObject * deadline ; <nl> double double_deadline ; <nl> gpr_timespec deadline_timespec ; <nl> - grpc_event * c_event ; <nl> + grpc_event c_event ; <nl> <nl> PyObject * event_args ; <nl> PyObject * event ; <nl> static PyObject * pygrpc_completion_queue_get ( CompletionQueue * self , <nl> grpc_completion_queue_next ( self - > c_completion_queue , deadline_timespec ) ; <nl> Py_END_ALLOW_THREADS ; <nl> <nl> - if ( c_event = = NULL ) { <nl> - Py_RETURN_NONE ; <nl> - } <nl> - <nl> - tag = ( pygrpc_tag * ) c_event - > tag ; <nl> + tag = ( pygrpc_tag * ) c_event . tag ; <nl> <nl> - switch ( c_event - > type ) { <nl> + switch ( c_event . type ) { <nl> + case GRPC_QUEUE_TIMEOUT : <nl> + Py_RETURN_NONE ; <nl> + break ; <nl> case GRPC_QUEUE_SHUTDOWN : <nl> - event_args = pygrpc_stop_event_args ( c_event ) ; <nl> + event_args = pygrpc_stop_event_args ( & c_event ) ; <nl> break ; <nl> case GRPC_OP_COMPLETE : { <nl> if ( ! tag ) { <nl> static PyObject * pygrpc_completion_queue_get ( CompletionQueue * self , <nl> if ( tag ) { <nl> pygrpc_tag_destroy ( tag ) ; <nl> } <nl> - grpc_event_finish ( c_event ) ; <nl> return pygrpc_completion_queue_get ( self , args ) ; <nl> case PYGRPC_WRITE_ACCEPTED : <nl> - event_args = pygrpc_write_event_args ( c_event ) ; <nl> + event_args = pygrpc_write_event_args ( & c_event ) ; <nl> break ; <nl> case PYGRPC_FINISH_ACCEPTED : <nl> - event_args = pygrpc_complete_event_args ( c_event ) ; <nl> + event_args = pygrpc_complete_event_args ( & c_event ) ; <nl> break ; <nl> case PYGRPC_SERVER_RPC_NEW : <nl> - event_args = pygrpc_service_event_args ( c_event ) ; <nl> + event_args = pygrpc_service_event_args ( & c_event ) ; <nl> break ; <nl> case PYGRPC_READ : <nl> - event_args = pygrpc_read_event_args ( c_event ) ; <nl> + event_args = pygrpc_read_event_args ( & c_event ) ; <nl> break ; <nl> case PYGRPC_CLIENT_METADATA_READ : <nl> - event_args = pygrpc_metadata_event_args ( c_event ) ; <nl> + event_args = pygrpc_metadata_event_args ( & c_event ) ; <nl> break ; <nl> case PYGRPC_FINISHED_CLIENT : <nl> - event_args = pygrpc_finished_client_event_args ( c_event ) ; <nl> + event_args = pygrpc_finished_client_event_args ( & c_event ) ; <nl> break ; <nl> case PYGRPC_FINISHED_SERVER : <nl> - event_args = pygrpc_finished_server_event_args ( c_event ) ; <nl> + event_args = pygrpc_finished_server_event_args ( & c_event ) ; <nl> break ; <nl> default : <nl> PyErr_SetString ( PyExc_Exception , " Unrecognized op event type ! " ) ; <nl> mmm a / test / core / end2end / cq_verifier . c <nl> ppp b / test / core / end2end / cq_verifier . c <nl> <nl> # include < grpc / support / time . h > <nl> # include < grpc / support / useful . h > <nl> <nl> + # define ROOT_EXPECTATION 1000 <nl> + <nl> / * a set of metadata we expect to find on an event * / <nl> typedef struct metadata { <nl> size_t count ; <nl> typedef struct expectation { <nl> struct expectation * prev ; <nl> grpc_completion_type type ; <nl> void * tag ; <nl> - union { <nl> - grpc_op_error op_complete ; <nl> - } data ; <nl> + int success ; <nl> } expectation ; <nl> <nl> / * the verifier itself * / <nl> struct cq_verifier { <nl> <nl> cq_verifier * cq_verifier_create ( grpc_completion_queue * cq ) { <nl> cq_verifier * v = gpr_malloc ( sizeof ( cq_verifier ) ) ; <nl> - v - > expect . type = GRPC_COMPLETION_DO_NOT_USE ; <nl> + v - > expect . type = ROOT_EXPECTATION ; <nl> v - > expect . tag = NULL ; <nl> v - > expect . next = & v - > expect ; <nl> v - > expect . prev = & v - > expect ; <nl> static void verify_matches ( expectation * e , grpc_event * ev ) { <nl> abort ( ) ; <nl> break ; <nl> case GRPC_OP_COMPLETE : <nl> - GPR_ASSERT ( e - > data . op_complete = = ev - > data . op_complete ) ; <nl> - break ; <nl> - case GRPC_SERVER_SHUTDOWN : <nl> + GPR_ASSERT ( e - > success = = ev - > success ) ; <nl> break ; <nl> - case GRPC_COMPLETION_DO_NOT_USE : <nl> + case GRPC_QUEUE_TIMEOUT : <nl> gpr_log ( GPR_ERROR , " not implemented " ) ; <nl> abort ( ) ; <nl> break ; <nl> static void expectation_to_strvec ( gpr_strvec * buf , expectation * e ) { <nl> <nl> switch ( e - > type ) { <nl> case GRPC_OP_COMPLETE : <nl> - gpr_asprintf ( & tmp , " GRPC_OP_COMPLETE result = % d " , e - > data . op_complete ) ; <nl> + gpr_asprintf ( & tmp , " GRPC_OP_COMPLETE result = % d " , e - > success ) ; <nl> gpr_strvec_add ( buf , tmp ) ; <nl> break ; <nl> - case GRPC_SERVER_SHUTDOWN : <nl> - gpr_strvec_add ( buf , gpr_strdup ( " GRPC_SERVER_SHUTDOWN " ) ) ; <nl> - break ; <nl> - case GRPC_COMPLETION_DO_NOT_USE : <nl> + case GRPC_QUEUE_TIMEOUT : <nl> case GRPC_QUEUE_SHUTDOWN : <nl> gpr_log ( GPR_ERROR , " not implemented " ) ; <nl> abort ( ) ; <nl> static void fail_no_event_received ( cq_verifier * v ) { <nl> <nl> void cq_verify ( cq_verifier * v ) { <nl> gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE ( 10 ) ; <nl> - grpc_event * ev ; <nl> + grpc_event ev ; <nl> expectation * e ; <nl> char * s ; <nl> gpr_strvec have_tags ; <nl> void cq_verify ( cq_verifier * v ) { <nl> <nl> while ( v - > expect . next ! = & v - > expect ) { <nl> ev = grpc_completion_queue_next ( v - > cq , deadline ) ; <nl> - if ( ! ev ) { <nl> + if ( ev . type = = GRPC_QUEUE_TIMEOUT ) { <nl> fail_no_event_received ( v ) ; <nl> + break ; <nl> } <nl> <nl> for ( e = v - > expect . next ; e ! = & v - > expect ; e = e - > next ) { <nl> gpr_asprintf ( & s , " % p " , e - > tag ) ; <nl> gpr_strvec_add ( & have_tags , s ) ; <nl> - if ( e - > tag = = ev - > tag ) { <nl> - verify_matches ( e , ev ) ; <nl> + if ( e - > tag = = ev . tag ) { <nl> + verify_matches ( e , & ev ) ; <nl> e - > next - > prev = e - > prev ; <nl> e - > prev - > next = e - > next ; <nl> gpr_free ( e ) ; <nl> void cq_verify ( cq_verifier * v ) { <nl> } <nl> } <nl> if ( e = = & v - > expect ) { <nl> - s = grpc_event_string ( ev ) ; <nl> + s = grpc_event_string ( & ev ) ; <nl> gpr_log ( GPR_ERROR , " event not found : % s " , s ) ; <nl> gpr_free ( s ) ; <nl> s = gpr_strvec_flatten ( & have_tags , NULL ) ; <nl> void cq_verify ( cq_verifier * v ) { <nl> gpr_strvec_destroy ( & have_tags ) ; <nl> abort ( ) ; <nl> } <nl> - <nl> - grpc_event_finish ( ev ) ; <nl> } <nl> <nl> gpr_strvec_destroy ( & have_tags ) ; <nl> void cq_verify ( cq_verifier * v ) { <nl> <nl> void cq_verify_empty ( cq_verifier * v ) { <nl> gpr_timespec deadline = gpr_time_add ( gpr_now ( ) , gpr_time_from_seconds ( 1 ) ) ; <nl> - grpc_event * ev ; <nl> + grpc_event ev ; <nl> <nl> GPR_ASSERT ( v - > expect . next = = & v - > expect & & " expectation queue must be empty " ) ; <nl> <nl> ev = grpc_completion_queue_next ( v - > cq , deadline ) ; <nl> - if ( ev ! = NULL ) { <nl> - char * s = grpc_event_string ( ev ) ; <nl> + if ( ev . type ! = GRPC_QUEUE_TIMEOUT ) { <nl> + char * s = grpc_event_string ( & ev ) ; <nl> gpr_log ( GPR_ERROR , " unexpected event ( expected nothing ) : % s " , s ) ; <nl> gpr_free ( s ) ; <nl> abort ( ) ; <nl> static expectation * add ( cq_verifier * v , grpc_completion_type type , void * tag ) { <nl> return e ; <nl> } <nl> <nl> - void cq_expect_completion ( cq_verifier * v , void * tag , grpc_op_error result ) { <nl> - add ( v , GRPC_OP_COMPLETE , tag ) - > data . op_complete = result ; <nl> - } <nl> - <nl> - void cq_expect_server_shutdown ( cq_verifier * v , void * tag ) { <nl> - add ( v , GRPC_SERVER_SHUTDOWN , tag ) ; <nl> + void cq_expect_completion ( cq_verifier * v , void * tag , int success ) { <nl> + add ( v , GRPC_OP_COMPLETE , tag ) - > success = success ; <nl> } <nl> mmm a / test / core / end2end / cq_verifier . h <nl> ppp b / test / core / end2end / cq_verifier . h <nl> void cq_verify_empty ( cq_verifier * v ) ; <nl> Any functions taking . . . expect a NULL terminated list of key / value pairs <nl> ( each pair using two parameter slots ) of metadata that MUST be present in <nl> the event . * / <nl> - void cq_expect_completion ( cq_verifier * v , void * tag , grpc_op_error result ) ; <nl> - void cq_expect_server_shutdown ( cq_verifier * v , void * tag ) ; <nl> + void cq_expect_completion ( cq_verifier * v , void * tag , int success ) ; <nl> <nl> int byte_buffer_eq_string ( grpc_byte_buffer * byte_buffer , const char * string ) ; <nl> int contains_metadata ( grpc_metadata_array * array , const char * key , const char * value ) ; <nl> mmm a / test / core / end2end / dualstack_socket_test . c <nl> ppp b / test / core / end2end / dualstack_socket_test . c <nl> static gpr_timespec ms_from_now ( int ms ) { <nl> } <nl> <nl> static void drain_cq ( grpc_completion_queue * cq ) { <nl> - grpc_event * ev ; <nl> - grpc_completion_type type ; <nl> + grpc_event ev ; <nl> do { <nl> ev = grpc_completion_queue_next ( cq , ms_from_now ( 5000 ) ) ; <nl> - GPR_ASSERT ( ev ) ; <nl> - type = ev - > type ; <nl> - grpc_event_finish ( ev ) ; <nl> - gpr_log ( GPR_INFO , " Drained event type % d " , type ) ; <nl> - } while ( type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> + } while ( ev . type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> } <nl> <nl> void test_connect ( const char * server_host , const char * client_host , int port , <nl> void test_connect ( const char * server_host , const char * client_host , int port , <nl> & call_details , <nl> & request_metadata_recv , <nl> server_cq , tag ( 101 ) ) ) ; <nl> - cq_expect_completion ( v_server , tag ( 101 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 101 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> op = ops ; <nl> void test_connect ( const char * server_host , const char * client_host , int port , <nl> GPR_ASSERT ( GRPC_CALL_OK = = <nl> grpc_call_start_batch ( s , ops , op - ops , tag ( 102 ) ) ) ; <nl> <nl> - cq_expect_completion ( v_server , tag ( 102 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 102 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> - cq_expect_completion ( v_client , tag ( 1 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_client , tag ( 1 ) , 1 ) ; <nl> cq_verify ( v_client ) ; <nl> <nl> GPR_ASSERT ( status = = GRPC_STATUS_UNIMPLEMENTED ) ; <nl> void test_connect ( const char * server_host , const char * client_host , int port , <nl> grpc_call_destroy ( s ) ; <nl> } else { <nl> / * Check for a failed connection . * / <nl> - cq_expect_completion ( v_client , tag ( 1 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_client , tag ( 1 ) , 1 ) ; <nl> cq_verify ( v_client ) ; <nl> <nl> GPR_ASSERT ( status = = GRPC_STATUS_DEADLINE_EXCEEDED ) ; <nl> mmm a / test / core / end2end / no_server_test . c <nl> ppp b / test / core / end2end / no_server_test . c <nl> int main ( int argc , char * * argv ) { <nl> gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE ( 2 ) ; <nl> grpc_completion_queue * cq ; <nl> cq_verifier * cqv ; <nl> - grpc_event * ev ; <nl> - int done ; <nl> grpc_op ops [ 6 ] ; <nl> grpc_op * op ; <nl> grpc_metadata_array trailing_metadata_recv ; <nl> int main ( int argc , char * * argv ) { <nl> GPR_ASSERT ( GRPC_CALL_OK = = <nl> grpc_call_start_batch ( call , ops , op - ops , tag ( 1 ) ) ) ; <nl> / * verify that all tags get completed * / <nl> - cq_expect_completion ( cqv , tag ( 1 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( cqv , tag ( 1 ) , 1 ) ; <nl> cq_verify ( cqv ) ; <nl> <nl> GPR_ASSERT ( status = = GRPC_STATUS_DEADLINE_EXCEEDED ) ; <nl> <nl> grpc_completion_queue_shutdown ( cq ) ; <nl> - for ( done = 0 ; ! done ; ) { <nl> - ev = grpc_completion_queue_next ( cq , gpr_inf_future ) ; <nl> - done = ev - > type = = GRPC_QUEUE_SHUTDOWN ; <nl> - grpc_event_finish ( ev ) ; <nl> - } <nl> + while ( grpc_completion_queue_next ( cq , gpr_inf_future ) . type ! = <nl> + GRPC_QUEUE_SHUTDOWN ) <nl> + ; <nl> grpc_completion_queue_destroy ( cq ) ; <nl> grpc_call_destroy ( call ) ; <nl> grpc_channel_destroy ( chan ) ; <nl> mmm a / test / core / end2end / tests / bad_hostname . c <nl> ppp b / test / core / end2end / tests / bad_hostname . c <nl> static gpr_timespec n_seconds_time ( int n ) { <nl> static gpr_timespec five_seconds_time ( void ) { return n_seconds_time ( 5 ) ; } <nl> <nl> static void drain_cq ( grpc_completion_queue * cq ) { <nl> - grpc_event * ev ; <nl> - grpc_completion_type type ; <nl> + grpc_event ev ; <nl> do { <nl> ev = grpc_completion_queue_next ( cq , five_seconds_time ( ) ) ; <nl> - GPR_ASSERT ( ev ) ; <nl> - type = ev - > type ; <nl> - grpc_event_finish ( ev ) ; <nl> - } while ( type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> + } while ( ev . type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> } <nl> <nl> static void shutdown_server ( grpc_end2end_test_fixture * f ) { <nl> static void simple_request_body ( grpc_end2end_test_fixture f ) { <nl> op + + ; <nl> GPR_ASSERT ( GRPC_CALL_OK = = grpc_call_start_batch ( c , ops , op - ops , tag ( 1 ) ) ) ; <nl> <nl> - cq_expect_completion ( v_client , tag ( 1 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_client , tag ( 1 ) , 1 ) ; <nl> cq_verify ( v_client ) ; <nl> <nl> GPR_ASSERT ( status = = GRPC_STATUS_UNAUTHENTICATED ) ; <nl> mmm a / test / core / end2end / tests / cancel_after_accept . c <nl> ppp b / test / core / end2end / tests / cancel_after_accept . c <nl> static gpr_timespec n_seconds_time ( int n ) { <nl> static gpr_timespec five_seconds_time ( void ) { return n_seconds_time ( 5 ) ; } <nl> <nl> static void drain_cq ( grpc_completion_queue * cq ) { <nl> - grpc_event * ev ; <nl> - grpc_completion_type type ; <nl> + grpc_event ev ; <nl> do { <nl> ev = grpc_completion_queue_next ( cq , five_seconds_time ( ) ) ; <nl> - GPR_ASSERT ( ev ) ; <nl> - type = ev - > type ; <nl> - grpc_event_finish ( ev ) ; <nl> - } while ( type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> + } while ( ev . type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> } <nl> <nl> static void shutdown_server ( grpc_end2end_test_fixture * f ) { <nl> static void test_cancel_after_accept ( grpc_end2end_test_config config , <nl> GPR_ASSERT ( GRPC_CALL_OK = = grpc_server_request_call ( <nl> f . server , & s , & call_details , <nl> & request_metadata_recv , f . server_cq , tag ( 2 ) ) ) ; <nl> - cq_expect_completion ( v_server , tag ( 2 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 2 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> op = ops ; <nl> static void test_cancel_after_accept ( grpc_end2end_test_config config , <nl> <nl> GPR_ASSERT ( GRPC_CALL_OK = = mode . initiate_cancel ( c ) ) ; <nl> <nl> - cq_expect_completion ( v_server , tag ( 3 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 3 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> - cq_expect_completion ( v_client , tag ( 1 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_client , tag ( 1 ) , 1 ) ; <nl> cq_verify ( v_client ) ; <nl> <nl> GPR_ASSERT ( status = = mode . expect_status ) ; <nl> mmm a / test / core / end2end / tests / cancel_after_accept_and_writes_closed . c <nl> ppp b / test / core / end2end / tests / cancel_after_accept_and_writes_closed . c <nl> static gpr_timespec n_seconds_time ( int n ) { <nl> static gpr_timespec five_seconds_time ( void ) { return n_seconds_time ( 5 ) ; } <nl> <nl> static void drain_cq ( grpc_completion_queue * cq ) { <nl> - grpc_event * ev ; <nl> - grpc_completion_type type ; <nl> + grpc_event ev ; <nl> do { <nl> ev = grpc_completion_queue_next ( cq , five_seconds_time ( ) ) ; <nl> - GPR_ASSERT ( ev ) ; <nl> - type = ev - > type ; <nl> - grpc_event_finish ( ev ) ; <nl> - } while ( type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> + } while ( ev . type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> } <nl> <nl> static void shutdown_server ( grpc_end2end_test_fixture * f ) { <nl> static void test_cancel_after_accept_and_writes_closed ( <nl> GPR_ASSERT ( GRPC_CALL_OK = = grpc_server_request_call ( <nl> f . server , & s , & call_details , <nl> & request_metadata_recv , f . server_cq , tag ( 2 ) ) ) ; <nl> - cq_expect_completion ( v_server , tag ( 2 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 2 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> op = ops ; <nl> static void test_cancel_after_accept_and_writes_closed ( <nl> <nl> GPR_ASSERT ( GRPC_CALL_OK = = mode . initiate_cancel ( c ) ) ; <nl> <nl> - cq_expect_completion ( v_server , tag ( 3 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 3 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> - cq_expect_completion ( v_client , tag ( 1 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_client , tag ( 1 ) , 1 ) ; <nl> cq_verify ( v_client ) ; <nl> <nl> GPR_ASSERT ( status = = mode . expect_status ) ; <nl> mmm a / test / core / end2end / tests / cancel_after_invoke . c <nl> ppp b / test / core / end2end / tests / cancel_after_invoke . c <nl> static gpr_timespec n_seconds_time ( int n ) { <nl> static gpr_timespec five_seconds_time ( void ) { return n_seconds_time ( 5 ) ; } <nl> <nl> static void drain_cq ( grpc_completion_queue * cq ) { <nl> - grpc_event * ev ; <nl> - grpc_completion_type type ; <nl> + grpc_event ev ; <nl> do { <nl> ev = grpc_completion_queue_next ( cq , five_seconds_time ( ) ) ; <nl> - GPR_ASSERT ( ev ) ; <nl> - type = ev - > type ; <nl> - grpc_event_finish ( ev ) ; <nl> - } while ( type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> + } while ( ev . type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> } <nl> <nl> static void shutdown_server ( grpc_end2end_test_fixture * f ) { <nl> static void test_cancel_after_invoke ( grpc_end2end_test_config config , <nl> <nl> GPR_ASSERT ( GRPC_CALL_OK = = mode . initiate_cancel ( c ) ) ; <nl> <nl> - cq_expect_completion ( v_client , tag ( 1 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_client , tag ( 1 ) , 1 ) ; <nl> cq_verify ( v_client ) ; <nl> <nl> GPR_ASSERT ( status = = mode . expect_status ) ; <nl> mmm a / test / core / end2end / tests / cancel_before_invoke . c <nl> ppp b / test / core / end2end / tests / cancel_before_invoke . c <nl> static gpr_timespec n_seconds_time ( int n ) { <nl> static gpr_timespec five_seconds_time ( void ) { return n_seconds_time ( 5 ) ; } <nl> <nl> static void drain_cq ( grpc_completion_queue * cq ) { <nl> - grpc_event * ev ; <nl> - grpc_completion_type type ; <nl> + grpc_event ev ; <nl> do { <nl> ev = grpc_completion_queue_next ( cq , five_seconds_time ( ) ) ; <nl> - GPR_ASSERT ( ev ) ; <nl> - type = ev - > type ; <nl> - grpc_event_finish ( ev ) ; <nl> - } while ( type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> + } while ( ev . type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> } <nl> <nl> static void shutdown_server ( grpc_end2end_test_fixture * f ) { <nl> static void test_cancel_before_invoke ( grpc_end2end_test_config config , <nl> op + + ; <nl> GPR_ASSERT ( GRPC_CALL_OK = = grpc_call_start_batch ( c , ops , test_ops , tag ( 1 ) ) ) ; <nl> <nl> - cq_expect_completion ( v_client , tag ( 1 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_client , tag ( 1 ) , 1 ) ; <nl> cq_verify ( v_client ) ; <nl> <nl> GPR_ASSERT ( status = = GRPC_STATUS_CANCELLED ) ; <nl> mmm a / test / core / end2end / tests / cancel_in_a_vacuum . c <nl> ppp b / test / core / end2end / tests / cancel_in_a_vacuum . c <nl> static gpr_timespec n_seconds_time ( int n ) { <nl> static gpr_timespec five_seconds_time ( void ) { return n_seconds_time ( 5 ) ; } <nl> <nl> static void drain_cq ( grpc_completion_queue * cq ) { <nl> - grpc_event * ev ; <nl> - grpc_completion_type type ; <nl> + grpc_event ev ; <nl> do { <nl> ev = grpc_completion_queue_next ( cq , five_seconds_time ( ) ) ; <nl> - GPR_ASSERT ( ev ) ; <nl> - type = ev - > type ; <nl> - grpc_event_finish ( ev ) ; <nl> - } while ( type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> + } while ( ev . type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> } <nl> <nl> static void shutdown_server ( grpc_end2end_test_fixture * f ) { <nl> mmm a / test / core / end2end / tests / census_simple_request . c <nl> ppp b / test / core / end2end / tests / census_simple_request . c <nl> static void shutdown_client ( grpc_end2end_test_fixture * f ) { <nl> } <nl> <nl> static void drain_cq ( grpc_completion_queue * cq ) { <nl> - grpc_event * ev ; <nl> - grpc_completion_type type ; <nl> + grpc_event ev ; <nl> do { <nl> ev = grpc_completion_queue_next ( cq , n_seconds_time ( 5 ) ) ; <nl> - GPR_ASSERT ( ev ) ; <nl> - type = ev - > type ; <nl> - grpc_event_finish ( ev ) ; <nl> - } while ( type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> + } while ( ev . type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> } <nl> <nl> static void end_test ( grpc_end2end_test_fixture * f ) { <nl> static void test_body ( grpc_end2end_test_fixture f ) { <nl> & call_details , <nl> & request_metadata_recv , <nl> f . server_cq , tag ( 101 ) ) ) ; <nl> - cq_expect_completion ( v_server , tag ( 101 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 101 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> op = ops ; <nl> static void test_body ( grpc_end2end_test_fixture f ) { <nl> op + + ; <nl> GPR_ASSERT ( GRPC_CALL_OK = = grpc_call_start_batch ( s , ops , op - ops , tag ( 102 ) ) ) ; <nl> <nl> - cq_expect_completion ( v_server , tag ( 102 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 102 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> - cq_expect_completion ( v_client , tag ( 1 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_client , tag ( 1 ) , 1 ) ; <nl> cq_verify ( v_client ) ; <nl> <nl> GPR_ASSERT ( status = = GRPC_STATUS_UNIMPLEMENTED ) ; <nl> mmm a / test / core / end2end / tests / disappearing_server . c <nl> ppp b / test / core / end2end / tests / disappearing_server . c <nl> static gpr_timespec n_seconds_time ( int n ) { <nl> static gpr_timespec five_seconds_time ( void ) { return n_seconds_time ( 5 ) ; } <nl> <nl> static void drain_cq ( grpc_completion_queue * cq ) { <nl> - grpc_event * ev ; <nl> - grpc_completion_type type ; <nl> + grpc_event ev ; <nl> do { <nl> ev = grpc_completion_queue_next ( cq , five_seconds_time ( ) ) ; <nl> - GPR_ASSERT ( ev ) ; <nl> - type = ev - > type ; <nl> - grpc_event_finish ( ev ) ; <nl> - } while ( type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> + } while ( ev . type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> } <nl> <nl> static void shutdown_server ( grpc_end2end_test_fixture * f ) { <nl> static void do_request_and_shutdown_server ( grpc_end2end_test_fixture * f , <nl> & call_details , <nl> & request_metadata_recv , <nl> f - > server_cq , tag ( 101 ) ) ) ; <nl> - cq_expect_completion ( v_server , tag ( 101 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 101 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> / * should be able to shut down the server early <nl> static void do_request_and_shutdown_server ( grpc_end2end_test_fixture * f , <nl> op + + ; <nl> GPR_ASSERT ( GRPC_CALL_OK = = grpc_call_start_batch ( s , ops , op - ops , tag ( 102 ) ) ) ; <nl> <nl> - cq_expect_completion ( v_server , tag ( 102 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 102 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> - cq_expect_completion ( v_client , tag ( 1 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_client , tag ( 1 ) , 1 ) ; <nl> cq_verify ( v_client ) ; <nl> <nl> GPR_ASSERT ( status = = GRPC_STATUS_UNIMPLEMENTED ) ; <nl> mmm a / test / core / end2end / tests / early_server_shutdown_finishes_inflight_calls . c <nl> ppp b / test / core / end2end / tests / early_server_shutdown_finishes_inflight_calls . c <nl> static gpr_timespec n_seconds_time ( int n ) { <nl> static gpr_timespec five_seconds_time ( void ) { return n_seconds_time ( 5 ) ; } <nl> <nl> static void drain_cq ( grpc_completion_queue * cq ) { <nl> - grpc_event * ev ; <nl> - grpc_completion_type type ; <nl> + grpc_event ev ; <nl> do { <nl> ev = grpc_completion_queue_next ( cq , five_seconds_time ( ) ) ; <nl> - GPR_ASSERT ( ev ) ; <nl> - type = ev - > type ; <nl> - grpc_event_finish ( ev ) ; <nl> - } while ( type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> + } while ( ev . type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> } <nl> <nl> static void shutdown_server ( grpc_end2end_test_fixture * f ) { <nl> static void test_early_server_shutdown_finishes_inflight_calls ( <nl> & call_details , <nl> & request_metadata_recv , <nl> f . server_cq , tag ( 101 ) ) ) ; <nl> - cq_expect_completion ( v_server , tag ( 101 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 101 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> op = ops ; <nl> static void test_early_server_shutdown_finishes_inflight_calls ( <nl> / * shutdown and destroy the server * / <nl> shutdown_server ( & f ) ; <nl> <nl> - cq_expect_completion ( v_server , tag ( 102 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 102 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> - cq_expect_completion ( v_client , tag ( 1 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_client , tag ( 1 ) , 1 ) ; <nl> cq_verify ( v_client ) ; <nl> <nl> GPR_ASSERT ( status = = GRPC_STATUS_UNAVAILABLE ) ; <nl> mmm a / test / core / end2end / tests / early_server_shutdown_finishes_tags . c <nl> ppp b / test / core / end2end / tests / early_server_shutdown_finishes_tags . c <nl> static gpr_timespec n_seconds_time ( int n ) { <nl> static gpr_timespec five_seconds_time ( void ) { return n_seconds_time ( 5 ) ; } <nl> <nl> static void drain_cq ( grpc_completion_queue * cq ) { <nl> - grpc_event * ev ; <nl> - grpc_completion_type type ; <nl> + grpc_event ev ; <nl> do { <nl> ev = grpc_completion_queue_next ( cq , five_seconds_time ( ) ) ; <nl> - GPR_ASSERT ( ev ) ; <nl> - type = ev - > type ; <nl> - grpc_event_finish ( ev ) ; <nl> - } while ( type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> + } while ( ev . type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> } <nl> <nl> static void shutdown_server ( grpc_end2end_test_fixture * f ) { <nl> static void test_early_server_shutdown_finishes_tags ( <nl> & request_metadata_recv , <nl> f . server_cq , tag ( 101 ) ) ) ; <nl> grpc_server_shutdown ( f . server ) ; <nl> - cq_expect_completion ( v_server , tag ( 101 ) , GRPC_OP_ERROR ) ; <nl> + cq_expect_completion ( v_server , tag ( 101 ) , 0 ) ; <nl> cq_verify ( v_server ) ; <nl> GPR_ASSERT ( s = = NULL ) ; <nl> <nl> mmm a / test / core / end2end / tests / empty_batch . c <nl> ppp b / test / core / end2end / tests / empty_batch . c <nl> static gpr_timespec n_seconds_time ( int n ) { <nl> static gpr_timespec five_seconds_time ( void ) { return n_seconds_time ( 5 ) ; } <nl> <nl> static void drain_cq ( grpc_completion_queue * cq ) { <nl> - grpc_event * ev ; <nl> - grpc_completion_type type ; <nl> + grpc_event ev ; <nl> do { <nl> ev = grpc_completion_queue_next ( cq , five_seconds_time ( ) ) ; <nl> - GPR_ASSERT ( ev ) ; <nl> - type = ev - > type ; <nl> - grpc_event_finish ( ev ) ; <nl> - } while ( type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> + } while ( ev . type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> } <nl> <nl> static void shutdown_server ( grpc_end2end_test_fixture * f ) { <nl> static void empty_batch_body ( grpc_end2end_test_fixture f ) { <nl> GPR_ASSERT ( c ) ; <nl> <nl> GPR_ASSERT ( GRPC_CALL_OK = = grpc_call_start_batch ( c , op , 0 , tag ( 1 ) ) ) ; <nl> - cq_expect_completion ( v_client , tag ( 1 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_client , tag ( 1 ) , 1 ) ; <nl> cq_verify ( v_client ) ; <nl> <nl> grpc_call_destroy ( c ) ; <nl> mmm a / test / core / end2end / tests / graceful_server_shutdown . c <nl> ppp b / test / core / end2end / tests / graceful_server_shutdown . c <nl> static gpr_timespec n_seconds_time ( int n ) { <nl> static gpr_timespec five_seconds_time ( void ) { return n_seconds_time ( 5 ) ; } <nl> <nl> static void drain_cq ( grpc_completion_queue * cq ) { <nl> - grpc_event * ev ; <nl> - grpc_completion_type type ; <nl> + grpc_event ev ; <nl> do { <nl> ev = grpc_completion_queue_next ( cq , five_seconds_time ( ) ) ; <nl> - GPR_ASSERT ( ev ) ; <nl> - type = ev - > type ; <nl> - grpc_event_finish ( ev ) ; <nl> - } while ( type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> + } while ( ev . type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> } <nl> <nl> static void shutdown_server ( grpc_end2end_test_fixture * f ) { <nl> static void test_early_server_shutdown_finishes_inflight_calls ( <nl> & call_details , <nl> & request_metadata_recv , <nl> f . server_cq , tag ( 101 ) ) ) ; <nl> - cq_expect_completion ( v_server , tag ( 101 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 101 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> / * shutdown and destroy the server * / <nl> static void test_early_server_shutdown_finishes_inflight_calls ( <nl> op + + ; <nl> GPR_ASSERT ( GRPC_CALL_OK = = grpc_call_start_batch ( s , ops , op - ops , tag ( 102 ) ) ) ; <nl> <nl> - cq_expect_completion ( v_server , tag ( 102 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 102 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> grpc_call_destroy ( s ) ; <nl> - cq_expect_server_shutdown ( v_server , tag ( 0xdead ) ) ; <nl> + cq_expect_completion ( v_server , tag ( 0xdead ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> - cq_expect_completion ( v_client , tag ( 1 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_client , tag ( 1 ) , 1 ) ; <nl> cq_verify ( v_client ) ; <nl> <nl> GPR_ASSERT ( status = = GRPC_STATUS_UNIMPLEMENTED ) ; <nl> mmm a / test / core / end2end / tests / invoke_large_request . c <nl> ppp b / test / core / end2end / tests / invoke_large_request . c <nl> static gpr_timespec n_seconds_time ( int n ) { <nl> } <nl> <nl> static void drain_cq ( grpc_completion_queue * cq ) { <nl> - grpc_event * ev ; <nl> - grpc_completion_type type ; <nl> + grpc_event ev ; <nl> do { <nl> ev = grpc_completion_queue_next ( cq , n_seconds_time ( 5 ) ) ; <nl> - GPR_ASSERT ( ev ) ; <nl> - type = ev - > type ; <nl> - grpc_event_finish ( ev ) ; <nl> - } while ( type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> + } while ( ev . type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> } <nl> <nl> static void shutdown_server ( grpc_end2end_test_fixture * f ) { <nl> static void test_invoke_large_request ( grpc_end2end_test_config config ) { <nl> & call_details , <nl> & request_metadata_recv , <nl> f . server_cq , tag ( 101 ) ) ) ; <nl> - cq_expect_completion ( v_server , tag ( 101 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 101 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> op = ops ; <nl> static void test_invoke_large_request ( grpc_end2end_test_config config ) { <nl> op + + ; <nl> GPR_ASSERT ( GRPC_CALL_OK = = grpc_call_start_batch ( s , ops , op - ops , tag ( 102 ) ) ) ; <nl> <nl> - cq_expect_completion ( v_server , tag ( 102 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 102 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> - cq_expect_completion ( v_client , tag ( 1 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_client , tag ( 1 ) , 1 ) ; <nl> cq_verify ( v_client ) ; <nl> <nl> GPR_ASSERT ( status = = GRPC_STATUS_UNIMPLEMENTED ) ; <nl> mmm a / test / core / end2end / tests / max_concurrent_streams . c <nl> ppp b / test / core / end2end / tests / max_concurrent_streams . c <nl> static gpr_timespec n_seconds_time ( int n ) { <nl> static gpr_timespec five_seconds_time ( void ) { return n_seconds_time ( 5 ) ; } <nl> <nl> static void drain_cq ( grpc_completion_queue * cq ) { <nl> - grpc_event * ev ; <nl> - grpc_completion_type type ; <nl> + grpc_event ev ; <nl> do { <nl> ev = grpc_completion_queue_next ( cq , five_seconds_time ( ) ) ; <nl> - GPR_ASSERT ( ev ) ; <nl> - type = ev - > type ; <nl> - grpc_event_finish ( ev ) ; <nl> - } while ( type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> + } while ( ev . type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> } <nl> <nl> static void shutdown_server ( grpc_end2end_test_fixture * f ) { <nl> static void simple_request_body ( grpc_end2end_test_fixture f ) { <nl> & call_details , <nl> & request_metadata_recv , <nl> f . server_cq , tag ( 101 ) ) ) ; <nl> - cq_expect_completion ( v_server , tag ( 101 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 101 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> op = ops ; <nl> static void simple_request_body ( grpc_end2end_test_fixture f ) { <nl> op + + ; <nl> GPR_ASSERT ( GRPC_CALL_OK = = grpc_call_start_batch ( s , ops , op - ops , tag ( 102 ) ) ) ; <nl> <nl> - cq_expect_completion ( v_server , tag ( 102 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 102 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> - cq_expect_completion ( v_client , tag ( 1 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_client , tag ( 1 ) , 1 ) ; <nl> cq_verify ( v_client ) ; <nl> <nl> GPR_ASSERT ( status = = GRPC_STATUS_UNIMPLEMENTED ) ; <nl> static void test_max_concurrent_streams ( grpc_end2end_test_config config ) { <nl> gpr_timespec deadline ; <nl> cq_verifier * v_client ; <nl> cq_verifier * v_server ; <nl> - grpc_event * ev ; <nl> + grpc_event ev ; <nl> grpc_call_details call_details ; <nl> grpc_metadata_array request_metadata_recv ; <nl> grpc_metadata_array initial_metadata_recv1 ; <nl> static void test_max_concurrent_streams ( grpc_end2end_test_config config ) { <nl> GPR_ASSERT ( GRPC_CALL_OK = = <nl> grpc_call_start_batch ( c2 , ops , op - ops , tag ( 402 ) ) ) ; <nl> <nl> - cq_expect_completion ( v_server , tag ( 101 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 101 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> ev = grpc_completion_queue_next ( f . client_cq , <nl> GRPC_TIMEOUT_SECONDS_TO_DEADLINE ( 3 ) ) ; <nl> - GPR_ASSERT ( ev ) ; <nl> - GPR_ASSERT ( ev - > type = = GRPC_OP_COMPLETE ) ; <nl> - GPR_ASSERT ( ev - > data . op_complete = = GRPC_OP_OK ) ; <nl> - GPR_ASSERT ( ev - > tag = = tag ( 301 ) | | ev - > tag = = tag ( 401 ) ) ; <nl> + GPR_ASSERT ( ev . type = = GRPC_OP_COMPLETE ) ; <nl> + GPR_ASSERT ( ev . success ) ; <nl> + GPR_ASSERT ( ev . tag = = tag ( 301 ) | | ev . tag = = tag ( 401 ) ) ; <nl> / * The / alpha or / beta calls started above could be invoked ( but NOT both ) ; <nl> * check this here * / <nl> / * We ' ll get tag 303 or 403 , we want 300 , 400 * / <nl> - live_call = ( ( int ) ( gpr_intptr ) ev - > tag ) - 1 ; <nl> - grpc_event_finish ( ev ) ; <nl> + live_call = ( ( int ) ( gpr_intptr ) ev . tag ) - 1 ; <nl> <nl> op = ops ; <nl> op - > op = GRPC_OP_SEND_INITIAL_METADATA ; <nl> static void test_max_concurrent_streams ( grpc_end2end_test_config config ) { <nl> GPR_ASSERT ( GRPC_CALL_OK = = <nl> grpc_call_start_batch ( s1 , ops , op - ops , tag ( 102 ) ) ) ; <nl> <nl> - cq_expect_completion ( v_server , tag ( 102 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 102 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> - cq_expect_completion ( v_client , tag ( live_call + 2 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_client , tag ( live_call + 2 ) , 1 ) ; <nl> / * first request is finished , we should be able to start the second * / <nl> live_call = ( live_call = = 300 ) ? 400 : 300 ; <nl> - cq_expect_completion ( v_client , tag ( live_call + 1 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_client , tag ( live_call + 1 ) , 1 ) ; <nl> cq_verify ( v_client ) ; <nl> <nl> GPR_ASSERT ( GRPC_CALL_OK = = grpc_server_request_call ( f . server , & s2 , <nl> & call_details , <nl> & request_metadata_recv , <nl> f . server_cq , tag ( 201 ) ) ) ; <nl> - cq_expect_completion ( v_server , tag ( 201 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 201 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> op = ops ; <nl> static void test_max_concurrent_streams ( grpc_end2end_test_config config ) { <nl> GPR_ASSERT ( GRPC_CALL_OK = = <nl> grpc_call_start_batch ( s2 , ops , op - ops , tag ( 202 ) ) ) ; <nl> <nl> - cq_expect_completion ( v_client , tag ( live_call + 2 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_client , tag ( live_call + 2 ) , 1 ) ; <nl> cq_verify ( v_client ) ; <nl> <nl> - cq_expect_completion ( v_server , tag ( 202 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 202 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> cq_verifier_destroy ( v_client ) ; <nl> mmm a / test / core / end2end / tests / no_op . c <nl> ppp b / test / core / end2end / tests / no_op . c <nl> static gpr_timespec n_seconds_time ( int n ) { <nl> static gpr_timespec five_seconds_time ( void ) { return n_seconds_time ( 5 ) ; } <nl> <nl> static void drain_cq ( grpc_completion_queue * cq ) { <nl> - grpc_event * ev ; <nl> - grpc_completion_type type ; <nl> + grpc_event ev ; <nl> do { <nl> ev = grpc_completion_queue_next ( cq , five_seconds_time ( ) ) ; <nl> - GPR_ASSERT ( ev ) ; <nl> - type = ev - > type ; <nl> - grpc_event_finish ( ev ) ; <nl> - } while ( type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> + } while ( ev . type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> } <nl> <nl> static void shutdown_server ( grpc_end2end_test_fixture * f ) { <nl> mmm a / test / core / end2end / tests / ping_pong_streaming . c <nl> ppp b / test / core / end2end / tests / ping_pong_streaming . c <nl> static gpr_timespec n_seconds_time ( int n ) { <nl> static gpr_timespec five_seconds_time ( void ) { return n_seconds_time ( 5 ) ; } <nl> <nl> static void drain_cq ( grpc_completion_queue * cq ) { <nl> - grpc_event * ev ; <nl> - grpc_completion_type type ; <nl> + grpc_event ev ; <nl> do { <nl> ev = grpc_completion_queue_next ( cq , five_seconds_time ( ) ) ; <nl> - GPR_ASSERT ( ev ) ; <nl> - type = ev - > type ; <nl> - grpc_event_finish ( ev ) ; <nl> - } while ( type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> + } while ( ev . type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> } <nl> <nl> static void shutdown_server ( grpc_end2end_test_fixture * f ) { <nl> static void test_pingpong_streaming ( grpc_end2end_test_config config , <nl> & call_details , <nl> & request_metadata_recv , <nl> f . server_cq , tag ( 100 ) ) ) ; <nl> - cq_expect_completion ( v_server , tag ( 100 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 100 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> op = ops ; <nl> static void test_pingpong_streaming ( grpc_end2end_test_config config , <nl> op + + ; <nl> GPR_ASSERT ( GRPC_CALL_OK = = <nl> grpc_call_start_batch ( s , ops , op - ops , tag ( 102 ) ) ) ; <nl> - cq_expect_completion ( v_server , tag ( 102 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 102 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> op = ops ; <nl> static void test_pingpong_streaming ( grpc_end2end_test_config config , <nl> op + + ; <nl> GPR_ASSERT ( GRPC_CALL_OK = = <nl> grpc_call_start_batch ( s , ops , op - ops , tag ( 103 ) ) ) ; <nl> - cq_expect_completion ( v_server , tag ( 103 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 103 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> - cq_expect_completion ( v_client , tag ( 2 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_client , tag ( 2 ) , 1 ) ; <nl> cq_verify ( v_client ) ; <nl> <nl> grpc_byte_buffer_destroy ( request_payload ) ; <nl> static void test_pingpong_streaming ( grpc_end2end_test_config config , <nl> op + + ; <nl> GPR_ASSERT ( GRPC_CALL_OK = = grpc_call_start_batch ( s , ops , op - ops , tag ( 104 ) ) ) ; <nl> <nl> - cq_expect_completion ( v_client , tag ( 1 ) , GRPC_OP_OK ) ; <nl> - cq_expect_completion ( v_client , tag ( 3 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_client , tag ( 1 ) , 1 ) ; <nl> + cq_expect_completion ( v_client , tag ( 3 ) , 1 ) ; <nl> cq_verify ( v_client ) ; <nl> <nl> - cq_expect_completion ( v_server , tag ( 101 ) , GRPC_OP_OK ) ; <nl> - cq_expect_completion ( v_server , tag ( 104 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 101 ) , 1 ) ; <nl> + cq_expect_completion ( v_server , tag ( 104 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> grpc_call_destroy ( c ) ; <nl> mmm a / test / core / end2end / tests / registered_call . c <nl> ppp b / test / core / end2end / tests / registered_call . c <nl> static gpr_timespec n_seconds_time ( int n ) { <nl> static gpr_timespec five_seconds_time ( void ) { return n_seconds_time ( 5 ) ; } <nl> <nl> static void drain_cq ( grpc_completion_queue * cq ) { <nl> - grpc_event * ev ; <nl> - grpc_completion_type type ; <nl> + grpc_event ev ; <nl> do { <nl> ev = grpc_completion_queue_next ( cq , five_seconds_time ( ) ) ; <nl> - GPR_ASSERT ( ev ) ; <nl> - type = ev - > type ; <nl> - grpc_event_finish ( ev ) ; <nl> - } while ( type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> + } while ( ev . type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> } <nl> <nl> static void shutdown_server ( grpc_end2end_test_fixture * f ) { <nl> static void simple_request_body ( grpc_end2end_test_fixture f , void * rc ) { <nl> & call_details , <nl> & request_metadata_recv , <nl> f . server_cq , tag ( 101 ) ) ) ; <nl> - cq_expect_completion ( v_server , tag ( 101 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 101 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> op = ops ; <nl> static void simple_request_body ( grpc_end2end_test_fixture f , void * rc ) { <nl> op + + ; <nl> GPR_ASSERT ( GRPC_CALL_OK = = grpc_call_start_batch ( s , ops , op - ops , tag ( 102 ) ) ) ; <nl> <nl> - cq_expect_completion ( v_server , tag ( 102 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 102 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> - cq_expect_completion ( v_client , tag ( 1 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_client , tag ( 1 ) , 1 ) ; <nl> cq_verify ( v_client ) ; <nl> <nl> GPR_ASSERT ( status = = GRPC_STATUS_UNIMPLEMENTED ) ; <nl> mmm a / test / core / end2end / tests / request_response_with_binary_metadata_and_payload . c <nl> ppp b / test / core / end2end / tests / request_response_with_binary_metadata_and_payload . c <nl> static gpr_timespec n_seconds_time ( int n ) { <nl> static gpr_timespec five_seconds_time ( void ) { return n_seconds_time ( 5 ) ; } <nl> <nl> static void drain_cq ( grpc_completion_queue * cq ) { <nl> - grpc_event * ev ; <nl> - grpc_completion_type type ; <nl> + grpc_event ev ; <nl> do { <nl> ev = grpc_completion_queue_next ( cq , five_seconds_time ( ) ) ; <nl> - GPR_ASSERT ( ev ) ; <nl> - type = ev - > type ; <nl> - grpc_event_finish ( ev ) ; <nl> - } while ( type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> + } while ( ev . type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> } <nl> <nl> static void shutdown_server ( grpc_end2end_test_fixture * f ) { <nl> static void test_request_response_with_metadata_and_payload ( <nl> & call_details , <nl> & request_metadata_recv , <nl> f . server_cq , tag ( 101 ) ) ) ; <nl> - cq_expect_completion ( v_server , tag ( 101 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 101 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> op = ops ; <nl> static void test_request_response_with_metadata_and_payload ( <nl> op + + ; <nl> GPR_ASSERT ( GRPC_CALL_OK = = grpc_call_start_batch ( s , ops , op - ops , tag ( 102 ) ) ) ; <nl> <nl> - cq_expect_completion ( v_server , tag ( 102 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 102 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> - cq_expect_completion ( v_client , tag ( 1 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_client , tag ( 1 ) , 1 ) ; <nl> cq_verify ( v_client ) ; <nl> <nl> GPR_ASSERT ( status = = GRPC_STATUS_UNIMPLEMENTED ) ; <nl> mmm a / test / core / end2end / tests / request_response_with_metadata_and_payload . c <nl> ppp b / test / core / end2end / tests / request_response_with_metadata_and_payload . c <nl> static gpr_timespec n_seconds_time ( int n ) { <nl> static gpr_timespec five_seconds_time ( void ) { return n_seconds_time ( 5 ) ; } <nl> <nl> static void drain_cq ( grpc_completion_queue * cq ) { <nl> - grpc_event * ev ; <nl> - grpc_completion_type type ; <nl> + grpc_event ev ; <nl> do { <nl> ev = grpc_completion_queue_next ( cq , five_seconds_time ( ) ) ; <nl> - GPR_ASSERT ( ev ) ; <nl> - type = ev - > type ; <nl> - grpc_event_finish ( ev ) ; <nl> - } while ( type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> + } while ( ev . type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> } <nl> <nl> static void shutdown_server ( grpc_end2end_test_fixture * f ) { <nl> static void test_request_response_with_metadata_and_payload ( <nl> & call_details , <nl> & request_metadata_recv , <nl> f . server_cq , tag ( 101 ) ) ) ; <nl> - cq_expect_completion ( v_server , tag ( 101 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 101 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> op = ops ; <nl> static void test_request_response_with_metadata_and_payload ( <nl> op + + ; <nl> GPR_ASSERT ( GRPC_CALL_OK = = grpc_call_start_batch ( s , ops , op - ops , tag ( 102 ) ) ) ; <nl> <nl> - cq_expect_completion ( v_server , tag ( 102 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 102 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> - cq_expect_completion ( v_client , tag ( 1 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_client , tag ( 1 ) , 1 ) ; <nl> cq_verify ( v_client ) ; <nl> <nl> GPR_ASSERT ( status = = GRPC_STATUS_UNIMPLEMENTED ) ; <nl> mmm a / test / core / end2end / tests / request_response_with_payload . c <nl> ppp b / test / core / end2end / tests / request_response_with_payload . c <nl> static gpr_timespec n_seconds_time ( int n ) { <nl> static gpr_timespec five_seconds_time ( void ) { return n_seconds_time ( 5 ) ; } <nl> <nl> static void drain_cq ( grpc_completion_queue * cq ) { <nl> - grpc_event * ev ; <nl> - grpc_completion_type type ; <nl> + grpc_event ev ; <nl> do { <nl> ev = grpc_completion_queue_next ( cq , five_seconds_time ( ) ) ; <nl> - GPR_ASSERT ( ev ) ; <nl> - type = ev - > type ; <nl> - grpc_event_finish ( ev ) ; <nl> - } while ( type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> + } while ( ev . type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> } <nl> <nl> static void shutdown_server ( grpc_end2end_test_fixture * f ) { <nl> static void request_response_with_payload ( grpc_end2end_test_fixture f ) { <nl> & call_details , <nl> & request_metadata_recv , <nl> f . server_cq , tag ( 101 ) ) ) ; <nl> - cq_expect_completion ( v_server , tag ( 101 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 101 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> op = ops ; <nl> static void request_response_with_payload ( grpc_end2end_test_fixture f ) { <nl> op + + ; <nl> GPR_ASSERT ( GRPC_CALL_OK = = grpc_call_start_batch ( s , ops , op - ops , tag ( 102 ) ) ) ; <nl> <nl> - cq_expect_completion ( v_server , tag ( 102 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 102 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> - cq_expect_completion ( v_client , tag ( 1 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_client , tag ( 1 ) , 1 ) ; <nl> cq_verify ( v_client ) ; <nl> <nl> GPR_ASSERT ( status = = GRPC_STATUS_UNIMPLEMENTED ) ; <nl> mmm a / test / core / end2end / tests / request_response_with_trailing_metadata_and_payload . c <nl> ppp b / test / core / end2end / tests / request_response_with_trailing_metadata_and_payload . c <nl> static void test_request_response_with_metadata_and_payload ( <nl> & call_details , <nl> & request_metadata_recv , <nl> f . server_cq , tag ( 101 ) ) ) ; <nl> - cq_expect_completion ( v_server , tag ( 101 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 101 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> op = ops ; <nl> static void test_request_response_with_metadata_and_payload ( <nl> op + + ; <nl> GPR_ASSERT ( GRPC_CALL_OK = = grpc_call_start_batch ( s , ops , op - ops , tag ( 102 ) ) ) ; <nl> <nl> - cq_expect_completion ( v_server , tag ( 102 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 102 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> - cq_expect_completion ( v_client , tag ( 1 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_client , tag ( 1 ) , 1 ) ; <nl> cq_verify ( v_client ) ; <nl> <nl> GPR_ASSERT ( status = = GRPC_STATUS_UNIMPLEMENTED ) ; <nl> mmm a / test / core / end2end / tests / request_with_large_metadata . c <nl> ppp b / test / core / end2end / tests / request_with_large_metadata . c <nl> static gpr_timespec n_seconds_time ( int n ) { <nl> static gpr_timespec five_seconds_time ( void ) { return n_seconds_time ( 5 ) ; } <nl> <nl> static void drain_cq ( grpc_completion_queue * cq ) { <nl> - grpc_event * ev ; <nl> - grpc_completion_type type ; <nl> + grpc_event ev ; <nl> do { <nl> ev = grpc_completion_queue_next ( cq , five_seconds_time ( ) ) ; <nl> - GPR_ASSERT ( ev ) ; <nl> - type = ev - > type ; <nl> - grpc_event_finish ( ev ) ; <nl> - } while ( type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> + } while ( ev . type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> } <nl> <nl> static void shutdown_server ( grpc_end2end_test_fixture * f ) { <nl> static void test_request_with_large_metadata ( grpc_end2end_test_config config ) { <nl> & call_details , <nl> & request_metadata_recv , <nl> f . server_cq , tag ( 101 ) ) ) ; <nl> - cq_expect_completion ( v_server , tag ( 101 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 101 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> op = ops ; <nl> static void test_request_with_large_metadata ( grpc_end2end_test_config config ) { <nl> op + + ; <nl> GPR_ASSERT ( GRPC_CALL_OK = = grpc_call_start_batch ( s , ops , op - ops , tag ( 102 ) ) ) ; <nl> <nl> - cq_expect_completion ( v_server , tag ( 102 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 102 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> - cq_expect_completion ( v_client , tag ( 1 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_client , tag ( 1 ) , 1 ) ; <nl> cq_verify ( v_client ) ; <nl> <nl> GPR_ASSERT ( status = = GRPC_STATUS_UNIMPLEMENTED ) ; <nl> mmm a / test / core / end2end / tests / request_with_payload . c <nl> ppp b / test / core / end2end / tests / request_with_payload . c <nl> static gpr_timespec n_seconds_time ( int n ) { <nl> static gpr_timespec five_seconds_time ( void ) { return n_seconds_time ( 5 ) ; } <nl> <nl> static void drain_cq ( grpc_completion_queue * cq ) { <nl> - grpc_event * ev ; <nl> - grpc_completion_type type ; <nl> + grpc_event ev ; <nl> do { <nl> ev = grpc_completion_queue_next ( cq , five_seconds_time ( ) ) ; <nl> - GPR_ASSERT ( ev ) ; <nl> - type = ev - > type ; <nl> - grpc_event_finish ( ev ) ; <nl> - } while ( type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> + } while ( ev . type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> } <nl> <nl> static void shutdown_server ( grpc_end2end_test_fixture * f ) { <nl> static void test_invoke_request_with_payload ( grpc_end2end_test_config config ) { <nl> & call_details , <nl> & request_metadata_recv , <nl> f . server_cq , tag ( 101 ) ) ) ; <nl> - cq_expect_completion ( v_server , tag ( 101 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 101 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> op = ops ; <nl> static void test_invoke_request_with_payload ( grpc_end2end_test_config config ) { <nl> op + + ; <nl> GPR_ASSERT ( GRPC_CALL_OK = = grpc_call_start_batch ( s , ops , op - ops , tag ( 102 ) ) ) ; <nl> <nl> - cq_expect_completion ( v_server , tag ( 102 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 102 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> - cq_expect_completion ( v_client , tag ( 1 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_client , tag ( 1 ) , 1 ) ; <nl> cq_verify ( v_client ) ; <nl> <nl> GPR_ASSERT ( status = = GRPC_STATUS_UNIMPLEMENTED ) ; <nl> mmm a / test / core / end2end / tests / simple_delayed_request . c <nl> ppp b / test / core / end2end / tests / simple_delayed_request . c <nl> static gpr_timespec n_seconds_time ( int n ) { <nl> static gpr_timespec five_seconds_time ( void ) { return n_seconds_time ( 5 ) ; } <nl> <nl> static void drain_cq ( grpc_completion_queue * cq ) { <nl> - grpc_event * ev ; <nl> - grpc_completion_type type ; <nl> + grpc_event ev ; <nl> do { <nl> ev = grpc_completion_queue_next ( cq , five_seconds_time ( ) ) ; <nl> - GPR_ASSERT ( ev ) ; <nl> - type = ev - > type ; <nl> - grpc_event_finish ( ev ) ; <nl> - } while ( type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> + } while ( ev . type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> } <nl> <nl> static void shutdown_server ( grpc_end2end_test_fixture * f ) { <nl> static void simple_delayed_request_body ( grpc_end2end_test_config config , <nl> & call_details , <nl> & request_metadata_recv , <nl> f - > server_cq , tag ( 101 ) ) ) ; <nl> - cq_expect_completion ( v_server , tag ( 101 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 101 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> op = ops ; <nl> static void simple_delayed_request_body ( grpc_end2end_test_config config , <nl> op + + ; <nl> GPR_ASSERT ( GRPC_CALL_OK = = grpc_call_start_batch ( s , ops , op - ops , tag ( 102 ) ) ) ; <nl> <nl> - cq_expect_completion ( v_server , tag ( 102 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 102 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> - cq_expect_completion ( v_client , tag ( 1 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_client , tag ( 1 ) , 1 ) ; <nl> cq_verify ( v_client ) ; <nl> <nl> GPR_ASSERT ( status = = GRPC_STATUS_UNIMPLEMENTED ) ; <nl> mmm a / test / core / end2end / tests / simple_request . c <nl> ppp b / test / core / end2end / tests / simple_request . c <nl> static gpr_timespec n_seconds_time ( int n ) { <nl> static gpr_timespec five_seconds_time ( void ) { return n_seconds_time ( 5 ) ; } <nl> <nl> static void drain_cq ( grpc_completion_queue * cq ) { <nl> - grpc_event * ev ; <nl> - grpc_completion_type type ; <nl> + grpc_event ev ; <nl> do { <nl> ev = grpc_completion_queue_next ( cq , five_seconds_time ( ) ) ; <nl> - GPR_ASSERT ( ev ) ; <nl> - type = ev - > type ; <nl> - grpc_event_finish ( ev ) ; <nl> - } while ( type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> + } while ( ev . type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> } <nl> <nl> static void shutdown_server ( grpc_end2end_test_fixture * f ) { <nl> static void simple_request_body ( grpc_end2end_test_fixture f ) { <nl> & call_details , <nl> & request_metadata_recv , <nl> f . server_cq , tag ( 101 ) ) ) ; <nl> - cq_expect_completion ( v_server , tag ( 101 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 101 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> op = ops ; <nl> static void simple_request_body ( grpc_end2end_test_fixture f ) { <nl> op + + ; <nl> GPR_ASSERT ( GRPC_CALL_OK = = grpc_call_start_batch ( s , ops , op - ops , tag ( 102 ) ) ) ; <nl> <nl> - cq_expect_completion ( v_server , tag ( 102 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_server , tag ( 102 ) , 1 ) ; <nl> cq_verify ( v_server ) ; <nl> <nl> - cq_expect_completion ( v_client , tag ( 1 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( v_client , tag ( 1 ) , 1 ) ; <nl> cq_verify ( v_client ) ; <nl> <nl> GPR_ASSERT ( status = = GRPC_STATUS_UNIMPLEMENTED ) ; <nl> mmm a / test / core / fling / client . c <nl> ppp b / test / core / fling / client . c <nl> static void step_ping_pong_request ( void ) { <nl> " localhost " , gpr_inf_future ) ; <nl> GPR_ASSERT ( GRPC_CALL_OK = = <nl> grpc_call_start_batch ( call , ops , op - ops , ( void * ) 1 ) ) ; <nl> - grpc_event_finish ( grpc_completion_queue_next ( cq , gpr_inf_future ) ) ; <nl> + grpc_completion_queue_next ( cq , gpr_inf_future ) ; <nl> grpc_call_destroy ( call ) ; <nl> grpc_byte_buffer_destroy ( response_payload_recv ) ; <nl> call = NULL ; <nl> static void init_ping_pong_stream ( void ) { <nl> stream_init_op . data . send_initial_metadata . count = 0 ; <nl> GPR_ASSERT ( GRPC_CALL_OK = = <nl> grpc_call_start_batch ( call , & stream_init_op , 1 , ( void * ) 1 ) ) ; <nl> - grpc_event_finish ( grpc_completion_queue_next ( cq , gpr_inf_future ) ) ; <nl> + grpc_completion_queue_next ( cq , gpr_inf_future ) ; <nl> <nl> grpc_metadata_array_init ( & initial_metadata_recv ) ; <nl> <nl> static void init_ping_pong_stream ( void ) { <nl> static void step_ping_pong_stream ( void ) { <nl> GPR_ASSERT ( GRPC_CALL_OK = = <nl> grpc_call_start_batch ( call , stream_step_ops , 2 , ( void * ) 1 ) ) ; <nl> - grpc_event_finish ( grpc_completion_queue_next ( cq , gpr_inf_future ) ) ; <nl> + grpc_completion_queue_next ( cq , gpr_inf_future ) ; <nl> grpc_byte_buffer_destroy ( response_payload_recv ) ; <nl> } <nl> <nl> int main ( int argc , char * * argv ) { <nl> char * fake_argv [ 1 ] ; <nl> <nl> int payload_size = 1 ; <nl> - int done ; <nl> int secure = 0 ; <nl> char * target = " localhost : 443 " ; <nl> gpr_cmdline * cl ; <nl> int main ( int argc , char * * argv ) { <nl> <nl> grpc_channel_destroy ( channel ) ; <nl> grpc_completion_queue_shutdown ( cq ) ; <nl> - done = 0 ; <nl> - while ( ! done ) { <nl> - grpc_event * ev = grpc_completion_queue_next ( cq , gpr_inf_future ) ; <nl> - done = ( ev - > type = = GRPC_QUEUE_SHUTDOWN ) ; <nl> - grpc_event_finish ( ev ) ; <nl> - } <nl> + while ( grpc_completion_queue_next ( cq , gpr_inf_future ) . type ! = <nl> + GRPC_QUEUE_SHUTDOWN ) <nl> + ; <nl> grpc_completion_queue_destroy ( cq ) ; <nl> grpc_byte_buffer_destroy ( the_buffer ) ; <nl> gpr_slice_unref ( slice ) ; <nl> mmm a / test / core / fling / server . c <nl> ppp b / test / core / fling / server . c <nl> static void start_send_status ( void ) { <nl> static void sigint_handler ( int x ) { _exit ( 0 ) ; } <nl> <nl> int main ( int argc , char * * argv ) { <nl> - grpc_event * ev ; <nl> + grpc_event ev ; <nl> call_state * s ; <nl> char * addr_buf = NULL ; <nl> gpr_cmdline * cl ; <nl> int main ( int argc , char * * argv ) { <nl> } <nl> ev = grpc_completion_queue_next ( <nl> cq , gpr_time_add ( gpr_now ( ) , gpr_time_from_micros ( 1000000 ) ) ) ; <nl> - if ( ! ev ) continue ; <nl> - s = ev - > tag ; <nl> - switch ( ev - > type ) { <nl> + s = ev . tag ; <nl> + switch ( ev . type ) { <nl> case GRPC_OP_COMPLETE : <nl> switch ( ( gpr_intptr ) s ) { <nl> case FLING_SERVER_NEW_REQUEST : <nl> int main ( int argc , char * * argv ) { <nl> GPR_ASSERT ( shutdown_started ) ; <nl> shutdown_finished = 1 ; <nl> break ; <nl> - default : <nl> - GPR_ASSERT ( 0 ) ; <nl> + case GRPC_QUEUE_TIMEOUT : <nl> + break ; <nl> } <nl> - grpc_event_finish ( ev ) ; <nl> } <nl> grpc_profiler_stop ( ) ; <nl> grpc_call_details_destroy ( & call_details ) ; <nl> mmm a / test / core / surface / completion_queue_test . c <nl> ppp b / test / core / surface / completion_queue_test . c <nl> <nl> <nl> # define LOG_TEST ( ) gpr_log ( GPR_INFO , " % s " , __FUNCTION__ ) <nl> <nl> - static void increment_int_on_finish ( void * user_data , grpc_op_error error ) { <nl> - + + * ( int * ) user_data ; <nl> - } <nl> - <nl> static void * create_test_tag ( void ) { <nl> static gpr_intptr i = 0 ; <nl> return ( void * ) ( + + i ) ; <nl> static void * create_test_tag ( void ) { <nl> <nl> / * helper for tests to shutdown correctly and tersely * / <nl> static void shutdown_and_destroy ( grpc_completion_queue * cc ) { <nl> - grpc_event * ev ; <nl> + grpc_event ev ; <nl> grpc_completion_queue_shutdown ( cc ) ; <nl> ev = grpc_completion_queue_next ( cc , gpr_inf_past ) ; <nl> - GPR_ASSERT ( ev ! = NULL ) ; <nl> - GPR_ASSERT ( ev - > type = = GRPC_QUEUE_SHUTDOWN ) ; <nl> - grpc_event_finish ( ev ) ; <nl> + GPR_ASSERT ( ev . type = = GRPC_QUEUE_SHUTDOWN ) ; <nl> grpc_completion_queue_destroy ( cc ) ; <nl> } <nl> <nl> static void test_wait_empty ( void ) { <nl> LOG_TEST ( ) ; <nl> <nl> cc = grpc_completion_queue_create ( ) ; <nl> - GPR_ASSERT ( grpc_completion_queue_next ( cc , gpr_now ( ) ) = = NULL ) ; <nl> + GPR_ASSERT ( grpc_completion_queue_next ( cc , gpr_now ( ) ) . type = = <nl> + GRPC_QUEUE_TIMEOUT ) ; <nl> shutdown_and_destroy ( cc ) ; <nl> } <nl> <nl> static void test_cq_end_op ( void ) { <nl> - grpc_event * ev ; <nl> + grpc_event ev ; <nl> grpc_completion_queue * cc ; <nl> - int on_finish_called = 0 ; <nl> void * tag = create_test_tag ( ) ; <nl> <nl> LOG_TEST ( ) ; <nl> <nl> cc = grpc_completion_queue_create ( ) ; <nl> <nl> - grpc_cq_begin_op ( cc , NULL , GRPC_OP_COMPLETE ) ; <nl> - grpc_cq_end_op ( cc , tag , NULL , increment_int_on_finish , & on_finish_called , <nl> - GRPC_OP_OK ) ; <nl> + grpc_cq_begin_op ( cc , NULL ) ; <nl> + grpc_cq_end_op ( cc , tag , NULL , 1 ) ; <nl> <nl> ev = grpc_completion_queue_next ( cc , gpr_inf_past ) ; <nl> - GPR_ASSERT ( ev ! = NULL ) ; <nl> - GPR_ASSERT ( ev - > type = = GRPC_OP_COMPLETE ) ; <nl> - GPR_ASSERT ( ev - > tag = = tag ) ; <nl> - GPR_ASSERT ( ev - > data . op_complete = = GRPC_OP_OK ) ; <nl> - GPR_ASSERT ( on_finish_called = = 0 ) ; <nl> - grpc_event_finish ( ev ) ; <nl> - GPR_ASSERT ( on_finish_called = = 1 ) ; <nl> + GPR_ASSERT ( ev . type = = GRPC_OP_COMPLETE ) ; <nl> + GPR_ASSERT ( ev . tag = = tag ) ; <nl> + GPR_ASSERT ( ev . success ) ; <nl> <nl> shutdown_and_destroy ( cc ) ; <nl> } <nl> <nl> static void test_pluck ( void ) { <nl> - grpc_event * ev ; <nl> + grpc_event ev ; <nl> grpc_completion_queue * cc ; <nl> void * tags [ 128 ] ; <nl> unsigned i , j ; <nl> - int on_finish_called = 0 ; <nl> <nl> LOG_TEST ( ) ; <nl> <nl> static void test_pluck ( void ) { <nl> cc = grpc_completion_queue_create ( ) ; <nl> <nl> for ( i = 0 ; i < GPR_ARRAY_SIZE ( tags ) ; i + + ) { <nl> - grpc_cq_begin_op ( cc , NULL , GRPC_OP_COMPLETE ) ; <nl> - grpc_cq_end_op ( cc , tags [ i ] , NULL , increment_int_on_finish , <nl> - & on_finish_called , GRPC_OP_OK ) ; <nl> + grpc_cq_begin_op ( cc , NULL ) ; <nl> + grpc_cq_end_op ( cc , tags [ i ] , NULL , 1 ) ; <nl> } <nl> <nl> for ( i = 0 ; i < GPR_ARRAY_SIZE ( tags ) ; i + + ) { <nl> ev = grpc_completion_queue_pluck ( cc , tags [ i ] , gpr_inf_past ) ; <nl> - GPR_ASSERT ( ev - > tag = = tags [ i ] ) ; <nl> - grpc_event_finish ( ev ) ; <nl> + GPR_ASSERT ( ev . tag = = tags [ i ] ) ; <nl> } <nl> <nl> - GPR_ASSERT ( on_finish_called = = GPR_ARRAY_SIZE ( tags ) ) ; <nl> - <nl> for ( i = 0 ; i < GPR_ARRAY_SIZE ( tags ) ; i + + ) { <nl> - grpc_cq_begin_op ( cc , NULL , GRPC_OP_COMPLETE ) ; <nl> - grpc_cq_end_op ( cc , tags [ i ] , NULL , increment_int_on_finish , <nl> - & on_finish_called , GRPC_OP_OK ) ; <nl> + grpc_cq_begin_op ( cc , NULL ) ; <nl> + grpc_cq_end_op ( cc , tags [ i ] , NULL , 1 ) ; <nl> } <nl> <nl> for ( i = 0 ; i < GPR_ARRAY_SIZE ( tags ) ; i + + ) { <nl> ev = grpc_completion_queue_pluck ( cc , tags [ GPR_ARRAY_SIZE ( tags ) - i - 1 ] , <nl> gpr_inf_past ) ; <nl> - GPR_ASSERT ( ev - > tag = = tags [ GPR_ARRAY_SIZE ( tags ) - i - 1 ] ) ; <nl> - grpc_event_finish ( ev ) ; <nl> + GPR_ASSERT ( ev . tag = = tags [ GPR_ARRAY_SIZE ( tags ) - i - 1 ] ) ; <nl> } <nl> <nl> - GPR_ASSERT ( on_finish_called = = 2 * GPR_ARRAY_SIZE ( tags ) ) ; <nl> - <nl> shutdown_and_destroy ( cc ) ; <nl> } <nl> <nl> static void producer_thread ( void * arg ) { <nl> <nl> gpr_log ( GPR_INFO , " producer % d phase 1 " , opt - > id ) ; <nl> for ( i = 0 ; i < TEST_THREAD_EVENTS ; i + + ) { <nl> - grpc_cq_begin_op ( opt - > cc , NULL , GRPC_OP_COMPLETE ) ; <nl> + grpc_cq_begin_op ( opt - > cc , NULL ) ; <nl> } <nl> <nl> gpr_log ( GPR_INFO , " producer % d phase 1 done " , opt - > id ) ; <nl> static void producer_thread ( void * arg ) { <nl> <nl> gpr_log ( GPR_INFO , " producer % d phase 2 " , opt - > id ) ; <nl> for ( i = 0 ; i < TEST_THREAD_EVENTS ; i + + ) { <nl> - grpc_cq_end_op ( opt - > cc , ( void * ) ( gpr_intptr ) 1 , NULL , NULL , NULL , <nl> - GRPC_OP_OK ) ; <nl> + grpc_cq_end_op ( opt - > cc , ( void * ) ( gpr_intptr ) 1 , NULL , 1 ) ; <nl> opt - > events_triggered + + ; <nl> } <nl> <nl> static void producer_thread ( void * arg ) { <nl> <nl> static void consumer_thread ( void * arg ) { <nl> test_thread_options * opt = arg ; <nl> - grpc_event * ev ; <nl> + grpc_event ev ; <nl> <nl> gpr_log ( GPR_INFO , " consumer % d started " , opt - > id ) ; <nl> gpr_event_set ( & opt - > on_started , ( void * ) ( gpr_intptr ) 1 ) ; <nl> static void consumer_thread ( void * arg ) { <nl> gpr_log ( GPR_INFO , " consumer % d phase 2 " , opt - > id ) ; <nl> for ( ; ; ) { <nl> ev = grpc_completion_queue_next ( opt - > cc , ten_seconds_time ( ) ) ; <nl> - GPR_ASSERT ( ev ) ; <nl> - switch ( ev - > type ) { <nl> + switch ( ev . type ) { <nl> case GRPC_OP_COMPLETE : <nl> - GPR_ASSERT ( ev - > data . op_complete = = GRPC_OP_OK ) ; <nl> + GPR_ASSERT ( ev . success ) ; <nl> opt - > events_triggered + + ; <nl> - grpc_event_finish ( ev ) ; <nl> break ; <nl> case GRPC_QUEUE_SHUTDOWN : <nl> gpr_log ( GPR_INFO , " consumer % d phase 2 done " , opt - > id ) ; <nl> gpr_event_set ( & opt - > on_finished , ( void * ) ( gpr_intptr ) 1 ) ; <nl> - grpc_event_finish ( ev ) ; <nl> return ; <nl> - default : <nl> - gpr_log ( GPR_ERROR , " Invalid event received : % d " , ev - > type ) ; <nl> + case GRPC_QUEUE_TIMEOUT : <nl> + gpr_log ( GPR_ERROR , " Invalid timeout received " ) ; <nl> abort ( ) ; <nl> } <nl> } <nl> mmm a / test / core / surface / lame_client_test . c <nl> ppp b / test / core / surface / lame_client_test . c <nl> int main ( int argc , char * * argv ) { <nl> grpc_call_start_batch ( call , ops , op - ops , tag ( 1 ) ) ) ; <nl> <nl> / * the call should immediately fail * / <nl> - cq_expect_completion ( cqv , tag ( 1 ) , GRPC_OP_OK ) ; <nl> + cq_expect_completion ( cqv , tag ( 1 ) , 1 ) ; <nl> cq_verify ( cqv ) ; <nl> <nl> grpc_call_destroy ( call ) ; <nl>
C Core API cleanup .
grpc/grpc
64be9f7a30a4bcb9ce3647f11ba9e06994aa3bb7
2015-05-04T21:53:51Z
mmm a / src / terminal / terminaldisplay . cc <nl> ppp b / src / terminal / terminaldisplay . cc <nl> std : : string Display : : new_frame ( bool initialized , const Framebuffer & last , const <nl> / * has xterm mouse mode changed ? * / <nl> if ( ( ! initialized ) <nl> | | ( f . ds . xterm_extended_mouse ! = frame . last_frame . ds . xterm_extended_mouse ) ) { <nl> - frame . append ( f . ds . xterm_extended_mouse ? " \ 033 [ ? 1006h \ 033 [ ? 1002h " : " \ 033 [ ? 1006l \ 033 [ ? 1002l " ) ; <nl> + frame . append ( f . ds . xterm_extended_mouse ? " \ 033 [ ? 1006h " : " \ 033 [ ? 1006l " ) ; <nl> } <nl> <nl> return frame . str ; <nl>
Revert bb369334722b23120bf0b0e91e6a6c69e0884474
mobile-shell/mosh
94a35958c254daea8f0851c957925c0e9c805b47
2014-12-09T01:40:38Z
mmm a / tensorflow / core / public / version . h <nl> ppp b / tensorflow / core / public / version . h <nl> limitations under the License . <nl> <nl> # define TF_GRAPH_DEF_VERSION_MIN_PRODUCER 0 <nl> # define TF_GRAPH_DEF_VERSION_MIN_CONSUMER 0 <nl> - # define TF_GRAPH_DEF_VERSION 595 / / Updated : 2020 / 11 / 24 <nl> + # define TF_GRAPH_DEF_VERSION 596 / / Updated : 2020 / 11 / 25 <nl> <nl> / / Checkpoint compatibility versions ( the versions field in SavedSliceMeta ) . <nl> / / <nl>
Update GraphDef version to 596 .
tensorflow/tensorflow
2e9f7214536a57fdfec0088d2362ac088d353b94
2020-11-25T09:12:54Z
mmm a / src / mongo / db / catalog / catalog_control_test . cpp <nl> ppp b / src / mongo / db / catalog / catalog_control_test . cpp <nl> class MockStorageEngine : public StorageEngine { <nl> return false ; <nl> } <nl> void setCachePressureForTest ( int pressure ) final { } <nl> - void replicationBatchIsComplete ( ) const final { } <nl> + void triggerJournalFlush ( ) const final { } <nl> StatusWith < std : : vector < CollectionIndexNamePair > > reconcileCatalogAndIdents ( <nl> OperationContext * opCtx ) final { <nl> return std : : vector < CollectionIndexNamePair > ( ) ; <nl> mmm a / src / mongo / db / repl / oplog_applier_impl . cpp <nl> ppp b / src / mongo / db / repl / oplog_applier_impl . cpp <nl> StatusWith < OpTime > OplogApplierImpl : : _applyOplogBatch ( OperationContext * opCtx , <nl> } <nl> } <nl> <nl> - / / Notify the storage engine that a replication batch has completed . This means that all the <nl> - / / writes associated with the oplog entries in the batch are finished and no new writes with <nl> - / / timestamps associated with those oplog entries will show up in the future . <nl> + / / Tell the storage engine to flush the journal now that a replication batch has completed . This <nl> + / / means that all the writes associated with the oplog entries in the batch are finished and no <nl> + / / new writes with timestamps associated with those oplog entries will show up in the future . We <nl> + / / want to flush the journal as soon as possible in order to free ops waiting with ' j ' write <nl> + / / concern . <nl> const auto storageEngine = opCtx - > getServiceContext ( ) - > getStorageEngine ( ) ; <nl> - storageEngine - > replicationBatchIsComplete ( ) ; <nl> + storageEngine - > triggerJournalFlush ( ) ; <nl> <nl> / / Use this fail point to hold the PBWM lock and prevent the batch from completing . <nl> if ( MONGO_unlikely ( pauseBatchApplicationBeforeCompletion . shouldFail ( ) ) ) { <nl> mmm a / src / mongo / db / storage / kv / kv_engine . h <nl> ppp b / src / mongo / db / storage / kv / kv_engine . h <nl> class KVEngine { <nl> } <nl> <nl> / * * <nl> - * See ` StorageEngine : : replicationBatchIsComplete ( ) ` <nl> + * See ` StorageEngine : : triggerJournalFlush ( ) ` <nl> * / <nl> - virtual void replicationBatchIsComplete ( ) const { } ; <nl> + virtual void triggerJournalFlush ( ) const { } ; <nl> <nl> / * * <nl> * Methods to access the storage engine ' s timestamps . <nl> mmm a / src / mongo / db / storage / storage_engine . h <nl> ppp b / src / mongo / db / storage / storage_engine . h <nl> class StorageEngine { <nl> virtual void setCachePressureForTest ( int pressure ) = 0 ; <nl> <nl> / * * <nl> - * Notifies the storage engine that a replication batch has completed . <nl> - * This means that all the writes associated with the oplog entries in the batch are <nl> - * finished and no new writes with timestamps associated with those oplog entries will show <nl> - * up in the future . <nl> - * This function can be used to ensure oplog visibility rules are not broken , for example . <nl> + * Prompts an immediate journal flush . <nl> * / <nl> - virtual void replicationBatchIsComplete ( ) const = 0 ; <nl> + virtual void triggerJournalFlush ( ) const = 0 ; <nl> <nl> / / ( CollectionName , IndexName ) <nl> typedef std : : pair < std : : string , std : : string > CollectionIndexNamePair ; <nl> mmm a / src / mongo / db / storage / storage_engine_impl . cpp <nl> ppp b / src / mongo / db / storage / storage_engine_impl . cpp <nl> void StorageEngineImpl : : clearDropPendingState ( ) { <nl> _dropPendingIdentReaper . clearDropPendingState ( ) ; <nl> } <nl> <nl> - void StorageEngineImpl : : replicationBatchIsComplete ( ) const { <nl> - return _engine - > replicationBatchIsComplete ( ) ; <nl> + void StorageEngineImpl : : triggerJournalFlush ( ) const { <nl> + return _engine - > triggerJournalFlush ( ) ; <nl> } <nl> <nl> Timestamp StorageEngineImpl : : getAllDurableTimestamp ( ) const { <nl> mmm a / src / mongo / db / storage / storage_engine_impl . h <nl> ppp b / src / mongo / db / storage / storage_engine_impl . h <nl> class StorageEngineImpl final : public StorageEngineInterface , public StorageEng <nl> <nl> void clearDropPendingState ( ) final ; <nl> <nl> - virtual void replicationBatchIsComplete ( ) const override ; <nl> + void triggerJournalFlush ( ) const final ; <nl> <nl> SnapshotManager * getSnapshotManager ( ) const final ; <nl> <nl> mmm a / src / mongo / db / storage / wiredtiger / wiredtiger_kv_engine . cpp <nl> ppp b / src / mongo / db / storage / wiredtiger / wiredtiger_kv_engine . cpp <nl> class WiredTigerKVEngine : : WiredTigerJournalFlusher : public BackgroundJob { <nl> ThreadClient tc ( name ( ) , getGlobalServiceContext ( ) ) ; <nl> LOG ( 1 ) < < " starting " < < name ( ) < < " thread " ; <nl> <nl> - while ( ! _shuttingDown . load ( ) ) { <nl> + while ( true ) { <nl> auto opCtx = tc - > makeOperationContext ( ) ; <nl> try { <nl> - const bool forceCheckpoint = false ; <nl> - const bool stableCheckpoint = false ; <nl> - _sessionCache - > waitUntilDurable ( opCtx . get ( ) , forceCheckpoint , stableCheckpoint ) ; <nl> + _sessionCache - > waitUntilDurable ( <nl> + opCtx . get ( ) , / * forceCheckpoint * / false , / * stableCheckpoint * / false ) ; <nl> } catch ( const AssertionException & e ) { <nl> invariant ( e . code ( ) = = ErrorCodes : : ShutdownInProgress ) ; <nl> } <nl> <nl> - int ms = storageGlobalParams . journalCommitIntervalMs . load ( ) ; <nl> + / / Wait until either journalCommitIntervalMs passes or an immediate journal flush is <nl> + / / requested ( or shutdown ) . <nl> + <nl> + auto deadline = <nl> + Date_t : : now ( ) + Milliseconds ( storageGlobalParams . journalCommitIntervalMs . load ( ) ) ; <nl> + stdx : : unique_lock < Latch > lk ( _stateMutex ) ; <nl> <nl> MONGO_IDLE_THREAD_BLOCK ; <nl> - sleepmillis ( ms ) ; <nl> + _flushJournalNowCV . wait_until ( lk , deadline . toSystemTimePoint ( ) , [ & ] { <nl> + return _flushJournalNow | | _shuttingDown ; <nl> + } ) ; <nl> + <nl> + _flushJournalNow = false ; <nl> + <nl> + if ( _shuttingDown ) { <nl> + LOG ( 1 ) < < " stopping " < < name ( ) < < " thread " ; <nl> + return ; <nl> + } <nl> } <nl> - LOG ( 1 ) < < " stopping " < < name ( ) < < " thread " ; <nl> } <nl> <nl> + / * * <nl> + * Signals the thread to quit and then waits until it does . <nl> + * / <nl> void shutdown ( ) { <nl> - _shuttingDown . store ( true ) ; <nl> + { <nl> + stdx : : lock_guard < Latch > lk ( _stateMutex ) ; <nl> + _shuttingDown = true ; <nl> + _flushJournalNowCV . notify_one ( ) ; <nl> + } <nl> wait ( ) ; <nl> } <nl> <nl> + / * * <nl> + * Signals an immediate journal flush . <nl> + * / <nl> + void triggerJournalFlush ( ) { <nl> + stdx : : lock_guard < Latch > lk ( _stateMutex ) ; <nl> + if ( ! _flushJournalNow ) { <nl> + _flushJournalNow = true ; <nl> + _flushJournalNowCV . notify_one ( ) ; <nl> + } <nl> + } <nl> + <nl> private : <nl> WiredTigerSessionCache * _sessionCache ; <nl> - AtomicWord < bool > _shuttingDown { false } ; <nl> + <nl> + / / Protects the state below . <nl> + mutable Mutex _stateMutex = MONGO_MAKE_LATCH ( " WiredTigerJournalFlusherStateMutex " ) ; <nl> + <nl> + / / Signaled to wake up the thread , if the thread is waiting . The thread will check whether <nl> + / / _flushJournalNow or _shuttingDown is set . <nl> + mutable stdx : : condition_variable _flushJournalNowCV ; <nl> + <nl> + bool _flushJournalNow = false ; <nl> + bool _shuttingDown = false ; <nl> } ; <nl> <nl> namespace { <nl> void WiredTigerKVEngine : : haltOplogManager ( ) { <nl> } <nl> } <nl> <nl> - void WiredTigerKVEngine : : replicationBatchIsComplete ( ) const { <nl> - _oplogManager - > triggerJournalFlush ( ) ; <nl> + void WiredTigerKVEngine : : triggerJournalFlush ( ) const { <nl> + if ( _journalFlusher ) { <nl> + _journalFlusher - > triggerJournalFlush ( ) ; <nl> + } <nl> } <nl> <nl> bool WiredTigerKVEngine : : isCacheUnderPressure ( OperationContext * opCtx ) const { <nl> mmm a / src / mongo / db / storage / wiredtiger / wiredtiger_kv_engine . h <nl> ppp b / src / mongo / db / storage / wiredtiger / wiredtiger_kv_engine . h <nl> class WiredTigerKVEngine final : public KVEngine { <nl> <nl> bool supportsOplogStones ( ) const final override ; <nl> <nl> - / * <nl> - * This function is called when replication has completed a batch . In this function , we <nl> - * refresh our oplog visiblity read - at - timestamp value . <nl> - * / <nl> - void replicationBatchIsComplete ( ) const override ; <nl> + void triggerJournalFlush ( ) const override ; <nl> <nl> bool isCacheUnderPressure ( OperationContext * opCtx ) const override ; <nl> <nl> mmm a / src / mongo / db / storage / wiredtiger / wiredtiger_record_store . cpp <nl> ppp b / src / mongo / db / storage / wiredtiger / wiredtiger_record_store . cpp <nl> Status WiredTigerRecordStore : : oplogDiskLocRegister ( OperationContext * opCtx , <nl> const Timestamp & ts , <nl> bool orderedCommit ) { <nl> opCtx - > recoveryUnit ( ) - > setOrderedCommit ( orderedCommit ) ; <nl> + <nl> if ( ! orderedCommit ) { <nl> / / This labels the current transaction with a timestamp . <nl> / / This is required for oplog visibility to work correctly , as WiredTiger uses the <nl> / / transaction list to determine where there are holes in the oplog . <nl> return opCtx - > recoveryUnit ( ) - > setTimestamp ( ts ) ; <nl> } <nl> + <nl> / / This handles non - primary ( secondary ) state behavior ; we simply set the oplog visiblity read <nl> / / timestamp here , as there cannot be visible holes prior to the opTime passed in . <nl> _kvEngine - > getOplogManager ( ) - > setOplogReadTimestamp ( ts ) ; <nl> + <nl> + / / Inserts and updates usually notify waiters on commit , but the oplog collection has special <nl> + / / visibility rules and waiters must be notified whenever the oplog read timestamp is forwarded . <nl> + notifyCappedWaitersIfNeeded ( ) ; <nl> + <nl> return Status : : OK ( ) ; <nl> } <nl> <nl> mmm a / src / mongo / util / background . h <nl> ppp b / src / mongo / util / background . h <nl> class BackgroundJob { <nl> / * * <nl> * wait for completion . <nl> * <nl> - * @ param msTimeOut maximum amount of time to wait in milliseconds <nl> + * @ param msTimeOut maximum amount of time to wait in milliseconds . Default wait of 0 <nl> + * ms will wait without deadline . <nl> * @ return true if did not time out . false otherwise . <nl> * <nl> * @ note you can call wait ( ) more than once if the first call times out . <nl>
SERVER - 44180 repl batch applier thread should prompt WiredTigerJournalFlusher thread to flush the journal rather than the oplog visibility thread
mongodb/mongo
b96794b6a5fb8805ebc226d2e6f26c78107fdee2
2019-11-05T20:42:59Z
mmm a / modules / ocl / src / mcwutil . cpp <nl> ppp b / modules / ocl / src / mcwutil . cpp <nl> namespace cv <nl> <nl> bool support_image2d ( Context * clCxt ) <nl> { <nl> - const cv : : ocl : : ProgramEntry _kernel = { NULL , " __kernel void test_func ( image2d_t img ) { } " , NULL } ; <nl> + const cv : : ocl : : ProgramEntry _kernel = { " test_func " , " __kernel void test_func ( image2d_t img ) { } " , NULL } ; <nl> static bool _isTested = false ; <nl> static bool _support = false ; <nl> if ( _isTested ) <nl>
Merge pull request from ilya - lavrenov : ocl_fix_tvl1_and_sparse
opencv/opencv
c0265c60f37c73880daa13fec31cc0ca2309ba4e
2013-10-11T12:22:59Z
mmm a / include / grpc + + / impl / codegen / server_interface . h <nl> ppp b / include / grpc + + / impl / codegen / server_interface . h <nl> <nl> namespace grpc { <nl> <nl> class AsyncGenericService ; <nl> - class AsynchronousService ; <nl> class GenericServerContext ; <nl> class RpcService ; <nl> class ServerAsyncStreamingInterface ; <nl> class ServerInterface : public CallHook { <nl> virtual void Wait ( ) = 0 ; <nl> <nl> protected : <nl> - friend class AsynchronousService ; <nl> friend class Service ; <nl> <nl> / / / Register a service . This call does not take ownership of the service . <nl>
Merge pull request from dgquintas / server_interface_cleanup
grpc/grpc
f79366a3c99592eccd9c719c86dca2f976804d3d
2016-02-11T09:05:10Z
mmm a / test / core / iomgr / tcp_server_posix_test . c <nl> ppp b / test / core / iomgr / tcp_server_posix_test . c <nl> static void test_no_op_with_port_and_start ( void ) { <nl> grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT ; <nl> struct sockaddr_in addr ; <nl> grpc_tcp_server * s ; <nl> - GPR_ASSERT ( GRPC_ERROR_NONE = = grpc_tcp_server_create ( NULL , NULL , & s ) ) ; <nl> + GPR_ASSERT ( GRPC_ERROR_NONE = = grpc_tcp_server_create ( NULL , NULL , & s ) ) ; <nl> LOG_TEST ( " test_no_op_with_port_and_start " ) ; <nl> int port ; <nl> <nl> mmm a / test / core / surface / server_chttp2_test . c <nl> ppp b / test / core / surface / server_chttp2_test . c <nl> void test_add_same_port_twice ( ) { <nl> a . key = GRPC_ARG_ALLOW_REUSEPORT ; <nl> a . value . integer = 0 ; <nl> grpc_channel_args args = { 1 , & a } ; <nl> - <nl> + <nl> int port = grpc_pick_unused_port_or_die ( ) ; <nl> char * addr = NULL ; <nl> grpc_completion_queue * cq = grpc_completion_queue_create ( NULL ) ; <nl> mmm a / test / core / util / test_tcp_server . c <nl> ppp b / test / core / util / test_tcp_server . c <nl> void test_tcp_server_start ( test_tcp_server * server , int port ) { <nl> addr . sin_port = htons ( ( uint16_t ) port ) ; <nl> memset ( & addr . sin_addr , 0 , sizeof ( addr . sin_addr ) ) ; <nl> <nl> - grpc_error * error = <nl> - grpc_tcp_server_create ( & server - > shutdown_complete , NULL , & server - > tcp_server ) ; <nl> + grpc_error * error = grpc_tcp_server_create ( & server - > shutdown_complete , NULL , <nl> + & server - > tcp_server ) ; <nl> GPR_ASSERT ( error = = GRPC_ERROR_NONE ) ; <nl> error = grpc_tcp_server_add_port ( server - > tcp_server , & addr , sizeof ( addr ) , <nl> & port_added ) ; <nl>
clang - format
grpc/grpc
e63246d1007516ca5c74043139304a371c0ce672
2016-06-21T16:03:11Z
mmm a / lib / Sema / MiscDiagnostics . cpp <nl> ppp b / lib / Sema / MiscDiagnostics . cpp <nl> static void diagSyntacticUseRestrictions ( TypeChecker & TC , const Expr * E ) { <nl> / / Check function calls , looking through implicit conversions on the <nl> / / function and inspecting the arguments directly . <nl> if ( auto * Call = dyn_cast < ApplyExpr > ( E ) ) { <nl> - / / Check the callee . <nl> - if ( auto * DRE = dyn_cast < DeclRefExpr > ( Call - > getFn ( ) ) ) <nl> + / / Check the callee , looking through implicit conversions . <nl> + auto Base = Call - > getFn ( ) ; <nl> + while ( auto Conv = dyn_cast < ImplicitConversionExpr > ( Base ) ) <nl> + Base = Conv - > getSubExpr ( ) ; <nl> + if ( auto * DRE = dyn_cast < DeclRefExpr > ( Base ) ) <nl> checkNoEscapeParameterUse ( DRE , Call ) ; <nl> <nl> / / The argument is either a ParenExpr or TupleExpr . <nl> static void diagSyntacticUseRestrictions ( TypeChecker & TC , const Expr * E ) { <nl> <nl> / / Check each argument . <nl> for ( auto arg : arguments ) { <nl> + while ( auto conv = dyn_cast < ImplicitConversionExpr > ( arg ) ) <nl> + arg = conv - > getSubExpr ( ) ; <nl> if ( auto * DRE = dyn_cast < DeclRefExpr > ( arg ) ) <nl> checkNoEscapeParameterUse ( DRE , Call ) ; <nl> } <nl> mmm a / test / attr / attr_noescape . swift <nl> ppp b / test / attr / attr_noescape . swift <nl> class SomeClass { <nl> takesNoEscapeClosure { x } <nl> } <nl> } <nl> + <nl> + <nl> + / / Implicit conversions ( in this case to @ objc_block ) are ok . <nl> + @ asmname ( " whatever " ) <nl> + func takeNoEscapeAsObjCBlock ( @ __noescape @ objc_block ( ) - > Void ) <nl> + func takeNoEscapeTest2 ( @ __noescape fn : ( ) - > ( ) ) { <nl> + takeNoEscapeAsObjCBlock ( fn ) <nl> + } <nl>
Implicit conversions of noescape pointers are ok when they add qualifiers .
apple/swift
fcdb304bc4213c9494195ef8c1847139384e2fc0
2014-12-24T00:57:07Z
mmm a / admin / static / coffee / namespaces / index . coffee <nl> ppp b / admin / static / coffee / namespaces / index . coffee <nl> module ' NamespaceView ' , - > <nl> else <nl> log_action ' add namespace button clicked ' <nl> @ add_namespace_dialog . render ( ) <nl> + $ ( ' # focus_namespace_name ' ) . focus ( ) <nl> <nl> remove_namespace : ( event ) = > <nl> log_action ' remove namespace button clicked ' <nl> mmm a / admin / static / coffee / namespaces / index . html <nl> ppp b / admin / static / coffee / namespaces / index . html <nl> < h3 class = " name " > <nl> < div class = " clearfix " > <nl> < label for = " name " > Name < / label > <nl> < div class = " input " > <nl> - < input class = " xlarge " name = " name " size = " 30 " type = " text " / > <nl> + < input class = " xlarge " id = " focus_namespace_name " name = " name " size = " 30 " type = " text " / > <nl> < / div > <nl> < / div > <nl> < div class = " clearfix " > <nl> mmm a / admin / static / coffee / namespaces / replicas . coffee <nl> ppp b / admin / static / coffee / namespaces / replicas . coffee <nl> module ' NamespaceView ' , - > <nl> render : - > <nl> log_render ' ( rendering ) modify replicas dialog ( outer ) ' <nl> super ( @ compute_json ( ) ) <nl> + $ ( ' # focus_num_replicas ' ) . focus ( ) <nl> <nl> on_submit : = > <nl> super <nl> mmm a / admin / static / coffee / namespaces / replicas . html <nl> ppp b / admin / static / coffee / namespaces / replicas . html <nl> <nl> < h4 > Number of replicas : < / h4 > <nl> < / label > <nl> < div class = " input " > <nl> - < input class = " xlarge " name = " num_replicas " type = " text " value = " { { # if nreplicas_input } } { { nreplicas_input } } { { else } } { { num_replicas } } { { / if } } " / > <nl> + < input class = " xlarge " id = " focus_num_replicas " name = " num_replicas " type = " text " value = " { { # if nreplicas_input } } { { nreplicas_input } } { { else } } { { num_replicas } } { { / if } } " / > <nl> < p class = " current " > Current replicas : { { num_replicas } } < / p > <nl> < p class = " max " > Max replicas : { { total_machines } } < / p > <nl> < / div > <nl> mmm a / admin / static / coffee / namespaces / shards . coffee <nl> ppp b / admin / static / coffee / namespaces / shards . coffee <nl> module ' NamespaceView ' , - > <nl> @ reset_button_enable ( ) <nl> else <nl> @ reset_button_disable ( ) <nl> - <nl> + $ ( ' # focus_num_shards ' ) . focus ( ) <nl> return @ <nl> <nl> render_only_shards : = > <nl> mmm a / admin / static / coffee / namespaces / shards . html <nl> ppp b / admin / static / coffee / namespaces / shards . html <nl> < h4 > Suggest sharding scheme : < / h4 > <nl> { { / if } } <nl> < div class = " shard_suggest_elements " > <nl> < label for = " replicas " > Number of shards : < / label > <nl> - < input class = " num_shards " name = " num_shards " type = " text " value = " { { new_shard_count } } " / > <nl> + < input class = " num_shards " id = " focus_num_shards " name = " num_shards " type = " text " value = " { { new_shard_count } } " / > <nl> < button class = " btn btn - compute - shards - suggestion " data - loading - text = " Calculating . . . " > Suggest < / button > <nl> < / div > <nl> < p class = " current " > Current shards : < strong > { { current_shards_count } } < / strong > , Max shards : < strong > { { max_shard_count } } < / strong > < / p > <nl> mmm a / admin / static / coffee / ui_components / modals . coffee <nl> ppp b / admin / static / coffee / ui_components / modals . coffee <nl> module ' UIComponents ' , - > <nl> modal_title : ' Rename ' + @ item_type <nl> btn_primary_text : ' Rename ' <nl> <nl> + $ ( ' # focus_new_name ' ) . focus ( ) <nl> + <nl> + <nl> on_submit : - > <nl> super <nl> @ old_name = @ get_item_object ( ) . get ( ' name ' ) <nl> mmm a / admin / static / coffee / ui_components / modals . html <nl> ppp b / admin / static / coffee / ui_components / modals . html <nl> < h2 > { { message } } < / h2 > <nl> < label for = " new_name " > New name < / label > <nl> <nl> < div class = " input " > <nl> - < input class = " xlarge " name = " new_name " size = " 30 " type = " text " / > <nl> + < input class = " xlarge " id = " focus_new_name " name = " new_name " size = " 30 " type = " text " / > <nl> < / div > <nl> < / div > <nl> < / fieldset > <nl>
Five focus to all input type = text when created .
rethinkdb/rethinkdb
22b5013de262a41db87c7c4edfd9df822fb56c2f
2012-06-14T23:53:24Z
mmm a / Telegram / Resources / uwp / AppX / AppxManifest . xml <nl> ppp b / Telegram / Resources / uwp / AppX / AppxManifest . xml <nl> <nl> < Identity Name = " TelegramMessengerLLP . TelegramDesktop " <nl> ProcessorArchitecture = " ARCHITECTURE " <nl> Publisher = " CN = 536BC709 - 8EE1 - 4478 - AF22 - F0F0F26FF64A " <nl> - Version = " 1 . 9 . 1 . 9 " / > <nl> + Version = " 1 . 9 . 1 . 10 " / > <nl> < Properties > <nl> < DisplayName > Telegram Desktop < / DisplayName > <nl> < PublisherDisplayName > Telegram FZ - LLC < / PublisherDisplayName > <nl> mmm a / Telegram / Resources / winrc / Telegram . rc <nl> ppp b / Telegram / Resources / winrc / Telegram . rc <nl> IDI_ICON1 ICON " . . \ \ art \ \ icon256 . ico " <nl> / / <nl> <nl> VS_VERSION_INFO VERSIONINFO <nl> - FILEVERSION 1 , 9 , 1 , 9 <nl> - PRODUCTVERSION 1 , 9 , 1 , 9 <nl> + FILEVERSION 1 , 9 , 1 , 10 <nl> + PRODUCTVERSION 1 , 9 , 1 , 10 <nl> FILEFLAGSMASK 0x3fL <nl> # ifdef _DEBUG <nl> FILEFLAGS 0x1L <nl> BEGIN <nl> BEGIN <nl> VALUE " CompanyName " , " Telegram FZ - LLC " <nl> VALUE " FileDescription " , " Telegram Desktop " <nl> - VALUE " FileVersion " , " 1 . 9 . 1 . 9 " <nl> + VALUE " FileVersion " , " 1 . 9 . 1 . 10 " <nl> VALUE " LegalCopyright " , " Copyright ( C ) 2014 - 2019 " <nl> VALUE " ProductName " , " Telegram Desktop " <nl> - VALUE " ProductVersion " , " 1 . 9 . 1 . 9 " <nl> + VALUE " ProductVersion " , " 1 . 9 . 1 . 10 " <nl> END <nl> END <nl> BLOCK " VarFileInfo " <nl> mmm a / Telegram / Resources / winrc / Updater . rc <nl> ppp b / Telegram / Resources / winrc / Updater . rc <nl> LANGUAGE LANG_ENGLISH , SUBLANG_ENGLISH_US <nl> / / <nl> <nl> VS_VERSION_INFO VERSIONINFO <nl> - FILEVERSION 1 , 9 , 1 , 9 <nl> - PRODUCTVERSION 1 , 9 , 1 , 9 <nl> + FILEVERSION 1 , 9 , 1 , 10 <nl> + PRODUCTVERSION 1 , 9 , 1 , 10 <nl> FILEFLAGSMASK 0x3fL <nl> # ifdef _DEBUG <nl> FILEFLAGS 0x1L <nl> BEGIN <nl> BEGIN <nl> VALUE " CompanyName " , " Telegram FZ - LLC " <nl> VALUE " FileDescription " , " Telegram Desktop Updater " <nl> - VALUE " FileVersion " , " 1 . 9 . 1 . 9 " <nl> + VALUE " FileVersion " , " 1 . 9 . 1 . 10 " <nl> VALUE " LegalCopyright " , " Copyright ( C ) 2014 - 2019 " <nl> VALUE " ProductName " , " Telegram Desktop " <nl> - VALUE " ProductVersion " , " 1 . 9 . 1 . 9 " <nl> + VALUE " ProductVersion " , " 1 . 9 . 1 . 10 " <nl> END <nl> END <nl> BLOCK " VarFileInfo " <nl> mmm a / Telegram / SourceFiles / core / version . h <nl> ppp b / Telegram / SourceFiles / core / version . h <nl> For license and copyright information please follow this link : <nl> * / <nl> # pragma once <nl> <nl> - # define TDESKTOP_REQUESTED_ALPHA_VERSION ( 1009001009ULL ) <nl> + # define TDESKTOP_REQUESTED_ALPHA_VERSION ( 1009001010ULL ) <nl> <nl> # ifdef TDESKTOP_ALLOW_CLOSED_ALPHA <nl> # define TDESKTOP_ALPHA_VERSION TDESKTOP_REQUESTED_ALPHA_VERSION <nl> mmm a / Telegram / build / version <nl> ppp b / Telegram / build / version <nl> AppVersionStrMajor 1 . 9 <nl> AppVersionStrSmall 1 . 9 . 1 <nl> AppVersionStr 1 . 9 . 1 <nl> BetaChannel 0 <nl> - AlphaVersion 1009001009 <nl> - AppVersionOriginal 1 . 9 . 1 . 9 <nl> + AlphaVersion 1009001010 <nl> + AppVersionOriginal 1 . 9 . 1 . 10 <nl>
Closed alpha 1 . 9 . 1 . 10 : Stream videos in chat .
telegramdesktop/tdesktop
7f033c1cc4ef58e5fe480898d88545c712138aa5
2019-12-19T15:29:19Z
mmm a / . circleci / config . yml <nl> ppp b / . circleci / config . yml <nl> jobs : <nl> . / emsdk - - notty activate latest <nl> cd - <nl> # Remove the emsdk version of emscripten to save space in the <nl> - # persistent workspace and to avoid any confusion with that version <nl> + # persistent workspace and to avoid any confusion with the version <nl> # we are trying to test . <nl> rm - r ~ / emsdk - master / emscripten / <nl> # Use Binaryen from the ports version . <nl> echo BINARYEN_ROOT = " ' ' " > > ~ / . emscripten <nl> + echo " final . emscripten : " <nl> + cat ~ / . emscripten <nl> - run : <nl> name : embuilder build ALL <nl> command : | <nl> jobs : <nl> tar - xf master . tar . gz <nl> cd emsdk - master <nl> . / emsdk - - notty update - tags <nl> - export WATERFALL_LKGR = ` python - c " print [ x . split ( ' \ " ' ) [ 3 ] for x in open ( ' upstream / lkgr . json ' ) . readlines ( ) if ' \ " build \ " ' in x ] [ 0 ] " ` <nl> - echo " LKGR : $ WATERFALL_LKGR " <nl> - . / emsdk - - notty install node - 8 . 9 . 1 - 64bit # TODO : should emsdk install this automatically ? <nl> - . / emsdk - - notty install clang - upstream - $ WATERFALL_LKGR - 64bit <nl> - . / emsdk - - notty activate clang - upstream - $ WATERFALL_LKGR - 64bit <nl> - cd - <nl> - # Use LLVM , clang , lld binaries from the emsdk <nl> - export LLVM = " $ HOME / emsdk - master / upstream / $ WATERFALL_LKGR / bin " <nl> + . / emsdk - - notty install latest - upstream <nl> + . / emsdk - - notty activate latest - upstream <nl> # Remove the emsdk version of emscripten to save space in the <nl> - # persistent workspace and to avoid any confusion with that version <nl> + # persistent workspace and to avoid any confusion with the version <nl> # we are trying to test . <nl> - rm - r ~ / emsdk - master / upstream / $ WATERFALL_LKGR / emscripten / <nl> + rm - Rf ` find - name " emscripten " ` <nl> + cd - <nl> # Use Binaryen from the ports version . <nl> echo BINARYEN_ROOT = " ' ' " > > ~ / . emscripten <nl> - # FIXME fix node <nl> - echo NODE_JS = " ' $ HOME / emsdk - master / node / 8 . 9 . 1_64bit / bin / node ' " > > ~ / . emscripten <nl> - echo " COMPILER_ENGINE = NODE_JS " > > ~ / . emscripten <nl> - echo " JS_ENGINES = [ NODE_JS ] " > > ~ / . emscripten <nl> + echo " final . emscripten : " <nl> + cat ~ / . emscripten <nl> - run : <nl> name : embuilder build ALL <nl> command : | <nl>
Update emsdk CI code ( )
emscripten-core/emscripten
a7d046becef674cfb86076ec116dc69b89fc2ac3
2018-12-20T21:27:30Z
mmm a / include / swift / AST / Expr . h <nl> ppp b / include / swift / AST / Expr . h <nl> <nl> <nl> # include " swift / AST / DeclContext . h " <nl> # include " swift / AST / Identifier . h " <nl> + # include " swift / AST / Substitution . h " <nl> # include " swift / AST / Type . h " <nl> # include " swift / AST / TypeLoc . h " <nl> # include " swift / Basic / SourceLoc . h " <nl> class ArchetypeMemberRefExpr : public Expr { <nl> } <nl> } ; <nl> <nl> - / / / Substitution - A substitution into a generic specialization . <nl> - class Substitution { <nl> - public : <nl> - ArchetypeType * Archetype ; <nl> - Type Replacement ; <nl> - ArrayRef < ProtocolConformance * > Conformance ; <nl> - } ; <nl> - <nl> class GenericMemberRefExpr : public Expr { <nl> Expr * Base ; <nl> ValueDecl * Value ; <nl> new file mode 100644 <nl> index 000000000000 . . 5630d870f01b <nl> mmm / dev / null <nl> ppp b / include / swift / AST / Substitution . h <nl> <nl> + / / = = = mmm Substitution . h - Swift Generic Substitution ASTs mmmmmm - * - C + + - * - = = = / / <nl> + / / <nl> + / / This source file is part of the Swift . org open source project <nl> + / / <nl> + / / Copyright ( c ) 2014 - 2015 Apple Inc . and the Swift project authors <nl> + / / Licensed under Apache License v2 . 0 with Runtime Library Exception <nl> + / / <nl> + / / See http : / / swift . org / LICENSE . txt for license information <nl> + / / See http : / / swift . org / CONTRIBUTORS . txt for the list of Swift project authors <nl> + / / <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + / / <nl> + / / This file defines the Substitution class . <nl> + / / <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + <nl> + # ifndef SWIFT_AST_SUBSTITUTION_H <nl> + # define SWIFT_AST_SUBSTITUTION_H <nl> + <nl> + # include " swift / AST / Type . h " <nl> + # include " llvm / ADT / ArrayRef . h " <nl> + <nl> + namespace swift { <nl> + class ArchetypeType ; <nl> + class ProtocolConformance ; <nl> + <nl> + / / / Substitution - A substitution into a generic specialization . <nl> + class Substitution { <nl> + public : <nl> + ArchetypeType * Archetype ; <nl> + Type Replacement ; <nl> + ArrayRef < ProtocolConformance * > Conformance ; <nl> + } ; <nl> + <nl> + } / / end namespace swift <nl> + <nl> + # endif <nl>
The world demands a common generics header , and who am I
apple/swift
00126779d69c3fb09c259c4a5550368dc61d326e
2012-10-03T08:57:36Z
mmm a / bazel / grpc_build_system . bzl <nl> ppp b / bazel / grpc_build_system . bzl <nl> def ios_cc_test ( <nl> deps = ios_test_deps , <nl> ) <nl> <nl> - def grpc_cc_test ( name , srcs = [ ] , deps = [ ] , external_deps = [ ] , args = [ ] , data = [ ] , uses_polling = True , language = " C + + " , size = " medium " , timeout = None , tags = [ ] , exec_compatible_with = [ ] , exec_properties = { } , shard_count = None ) : <nl> + def grpc_cc_test ( name , srcs = [ ] , deps = [ ] , external_deps = [ ] , args = [ ] , data = [ ] , uses_polling = True , language = " C + + " , size = " medium " , timeout = None , tags = [ ] , exec_compatible_with = [ ] , exec_properties = { } , shard_count = None , flaky = None ) : <nl> copts = if_mac ( [ " - DGRPC_CFSTREAM " ] ) <nl> if language . upper ( ) = = " C " : <nl> copts = copts + if_not_windows ( [ " - std = c99 " ] ) <nl> def grpc_cc_test ( name , srcs = [ ] , deps = [ ] , external_deps = [ ] , args = [ ] , data <nl> " exec_compatible_with " : exec_compatible_with , <nl> " exec_properties " : exec_properties , <nl> " shard_count " : shard_count , <nl> + " flaky " : flaky , <nl> } <nl> if uses_polling : <nl> # the vanilla version of the test should run on platforms that only <nl> def grpc_cc_test ( name , srcs = [ ] , deps = [ ] , external_deps = [ ] , args = [ ] , data <nl> exec_compatible_with = exec_compatible_with , <nl> exec_properties = exec_properties , <nl> shard_count = shard_count , <nl> + flaky = flaky , <nl> ) <nl> else : <nl> # the test behavior doesn ' t depend on polling , just generate the test <nl> mmm a / test / core / transport / chttp2 / BUILD <nl> ppp b / test / core / transport / chttp2 / BUILD <nl> grpc_cc_test ( <nl> external_deps = [ <nl> " gtest " , <nl> ] , <nl> + flaky = True , # TODO ( b / 148399919 ) <nl> language = " C + + " , <nl> deps = [ <nl> " / / : gpr " , <nl> mmm a / test / cpp / end2end / BUILD <nl> ppp b / test / cpp / end2end / BUILD <nl> grpc_cc_test ( <nl> external_deps = [ <nl> " gtest " , <nl> ] , <nl> + flaky = True , # TODO ( b / 144705388 ) <nl> shard_count = 10 , <nl> tags = [ <nl> " no_test_ios " , <nl> mmm a / test / cpp / microbenchmarks / BUILD <nl> ppp b / test / cpp / microbenchmarks / BUILD <nl> grpc_cc_test ( <nl> srcs = [ <nl> " bm_fullstack_streaming_pump . cc " , <nl> ] , <nl> + flaky = True , # TODO ( b / 150422385 ) <nl> tags = [ <nl> " no_mac " , # to emulate " excluded_poll_engines : poll " <nl> " no_windows " , <nl> grpc_cc_test ( <nl> grpc_cc_test ( <nl> name = " bm_metadata " , <nl> srcs = [ " bm_metadata . cc " ] , <nl> + flaky = True , # TODO ( b / 149998903 ) <nl> tags = [ <nl> " no_mac " , <nl> " no_windows " , <nl>
Merge pull request from jtattermusch / start_marking_as_flaky
grpc/grpc
b430c46e1bbc681bf47624ece494fc4058478c5f
2020-02-28T19:44:47Z
mmm a / include / swift / SIL / SILBasicBlock . h <nl> ppp b / include / swift / SIL / SILBasicBlock . h <nl> public llvm : : ilist_node < SILBasicBlock > , public SILAllocated < SILBasicBlock > { <nl> / / / Returns - 1 if the block is not contained in a function . <nl> / / / Warning : This function is slow . Therefore it should only be used for <nl> / / / debug output . <nl> - int getDebugID ( ) ; <nl> + int getDebugID ( ) const ; <nl> <nl> SILFunction * getParent ( ) { return Parent ; } <nl> const SILFunction * getParent ( ) const { return Parent ; } <nl> mmm a / lib / SIL / SILBasicBlock . cpp <nl> ppp b / lib / SIL / SILBasicBlock . cpp <nl> SILBasicBlock : : ~ SILBasicBlock ( ) { <nl> InstList . clearAndLeakNodesUnsafely ( ) ; <nl> } <nl> <nl> - int SILBasicBlock : : getDebugID ( ) { <nl> + int SILBasicBlock : : getDebugID ( ) const { <nl> if ( ! getParent ( ) ) <nl> return - 1 ; <nl> int idx = 0 ; <nl> mmm a / lib / SILOptimizer / Transforms / SILCodeMotion . cpp <nl> ppp b / lib / SILOptimizer / Transforms / SILCodeMotion . cpp <nl> static void createRefCountOpForPayload ( SILBuilder & Builder , SILInstruction * I , <nl> } <nl> <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> - / / Generic Sinking Code <nl> + / / Enum Tag Dataflow <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> <nl> - / / / \ brief Hoist release on a SILArgument to its predecessors . <nl> - static bool hoistSILArgumentReleaseInst ( SILBasicBlock * BB ) { <nl> - / / There is no block to hoist releases to . <nl> - if ( BB - > pred_empty ( ) ) <nl> - return false ; <nl> + namespace { <nl> <nl> - / / Only try to hoist the first instruction . RRCM should have hoisted the release <nl> - / / to the beginning of the block if it can . <nl> - auto Head = & * BB - > begin ( ) ; <nl> - / / Make sure it is a release instruction . <nl> - if ( ! isReleaseInstruction ( & * Head ) ) <nl> - return false ; <nl> + class EnumCaseDataflowContext ; <nl> <nl> - / / Make sure it is a release on a SILArgument of the current basic block . . <nl> - auto * SA = dyn_cast < SILArgument > ( Head - > getOperand ( 0 ) ) ; <nl> - if ( ! SA | | SA - > getParent ( ) ! = BB ) <nl> - return false ; <nl> + using EnumBBCaseList = <nl> + llvm : : SmallVector < std : : pair < SILBasicBlock * , EnumElementDecl * > , 2 > ; <nl> <nl> - / / Make sure the release will not be blocked by the terminator instructions <nl> - / / Make sure the terminator does not block , nor is a branch with multiple targets . <nl> - for ( auto P : BB - > getPredecessorBlocks ( ) ) { <nl> - if ( ! isa < BranchInst > ( P - > getTerminator ( ) ) ) <nl> - return false ; <nl> - } <nl> + / / / Class that performs enum tag state dataflow on the given BB . <nl> + class BBEnumTagDataflowState <nl> + : public SILInstructionVisitor < BBEnumTagDataflowState , bool > { <nl> + EnumCaseDataflowContext * Context ; <nl> + NullablePtr < SILBasicBlock > BB ; <nl> <nl> - / / Make sure we can get all the incoming values . <nl> - llvm : : SmallVector < SILValue , 4 > PredValues ; <nl> - if ( ! SA - > getIncomingValues ( PredValues ) ) <nl> - return false ; <nl> + SmallBlotMapVector < unsigned , EnumElementDecl * , 4 > ValueToCaseMap ; <nl> + SmallBlotMapVector < unsigned , EnumBBCaseList , 4 > EnumToEnumBBCaseListMap ; <nl> <nl> - / / Ok , we can get all the incoming values and create releases for them . <nl> - unsigned indices = 0 ; <nl> - for ( auto P : BB - > getPredecessorBlocks ( ) ) { <nl> - createDecrementBefore ( PredValues [ indices + + ] , P - > getTerminator ( ) ) ; <nl> - } <nl> - / / Erase the old instruction . <nl> - Head - > eraseFromParent ( ) ; <nl> - + + NumSILArgumentReleaseHoisted ; <nl> - return true ; <nl> - } <nl> + public : <nl> + BBEnumTagDataflowState ( ) = default ; <nl> + BBEnumTagDataflowState ( const BBEnumTagDataflowState & Other ) = default ; <nl> + ~ BBEnumTagDataflowState ( ) = default ; <nl> <nl> - static const int SinkSearchWindow = 6 ; <nl> + LLVM_ATTRIBUTE_DEPRECATED ( void dump ( ) const LLVM_ATTRIBUTE_USED , <nl> + " only for use within the debugger " ) ; <nl> <nl> - / / / \ brief Returns True if we can sink this instruction to another basic block . <nl> - static bool canSinkInstruction ( SILInstruction * Inst ) { <nl> - return ! Inst - > hasUsesOfAnyResult ( ) & & ! isa < TermInst > ( Inst ) ; <nl> - } <nl> + bool init ( EnumCaseDataflowContext & Context , SILBasicBlock * NewBB ) ; <nl> <nl> - / / / \ brief Returns true if this instruction is a skip barrier , which means that <nl> - / / / we can ' t sink other instructions past it . <nl> - static bool isSinkBarrier ( SILInstruction * Inst ) { <nl> - if ( isa < TermInst > ( Inst ) ) <nl> - return false ; <nl> + SILBasicBlock * getBB ( ) { return BB . get ( ) ; } <nl> <nl> - if ( Inst - > mayHaveSideEffects ( ) ) <nl> - return true ; <nl> + using iterator = decltype ( ValueToCaseMap ) : : iterator ; <nl> + iterator begin ( ) { return ValueToCaseMap . getItems ( ) . begin ( ) ; } <nl> + iterator end ( ) { return ValueToCaseMap . getItems ( ) . begin ( ) ; } <nl> <nl> - return false ; <nl> - } <nl> + void clear ( ) { ValueToCaseMap . clear ( ) ; } <nl> <nl> - using ValueInBlock = std : : pair < SILValue , SILBasicBlock * > ; <nl> - using ValueToBBArgIdxMap = llvm : : DenseMap < ValueInBlock , int > ; <nl> + bool visitSILInstruction ( SILInstruction * I ) { return false ; } <nl> <nl> - enum OperandRelation { <nl> - / / / Uninitialized state . <nl> - NotDeterminedYet , <nl> - <nl> - / / / The original operand values are equal . <nl> - AlwaysEqual , <nl> - <nl> - / / / The operand values are equal after replacing with the successor block <nl> - / / / arguments . <nl> - EqualAfterMove <nl> - } ; <nl> + bool visitEnumInst ( EnumInst * EI ) ; <nl> + bool visitUncheckedEnumDataInst ( UncheckedEnumDataInst * UEDI ) ; <nl> + bool visitRetainValueInst ( RetainValueInst * RVI ) ; <nl> + bool visitReleaseValueInst ( ReleaseValueInst * RVI ) ; <nl> + bool process ( ) ; <nl> + bool hoistDecrementsIntoSwitchRegions ( AliasAnalysis * AA ) ; <nl> + bool sinkIncrementsOutOfSwitchRegions ( AliasAnalysis * AA , <nl> + RCIdentityFunctionInfo * RCIA ) ; <nl> + void handlePredSwitchEnum ( SwitchEnumInst * S ) ; <nl> + void handlePredCondSelectEnum ( CondBranchInst * CondBr ) ; <nl> <nl> - / / / \ brief Find a root value for operand \ p In . This function inspects a sil <nl> - / / / value and strips trivial conversions such as values that are passed <nl> - / / / as arguments to basic blocks with a single predecessor or type casts . <nl> - / / / This is a shallow one - step search and not a deep recursive search . <nl> - / / / <nl> - / / / For example , in the SIL code below , the root of % 10 is % 3 , because it is <nl> - / / / the only possible incoming value . <nl> - / / / <nl> - / / / bb1 : <nl> - / / / % 3 = unchecked_enum_data % 0 : $ Optional < X > , # Optional . Some ! enumelt . 1 <nl> - / / / checked_cast_br [ exact ] % 3 : $ X to $ X , bb4 , bb5 / / id : % 4 <nl> - / / / <nl> - / / / bb4 ( % 10 : $ X ) : / / Preds : bb1 <nl> - / / / strong_release % 10 : $ X <nl> - / / / br bb2 <nl> - / / / <nl> - static SILValue findValueShallowRoot ( const SILValue & In ) { <nl> - / / If this is a basic block argument with a single caller <nl> - / / then we know exactly which value is passed to the argument . <nl> - if ( auto * Arg = dyn_cast < SILArgument > ( In ) ) { <nl> - SILBasicBlock * Parent = Arg - > getParent ( ) ; <nl> - SILBasicBlock * Pred = Parent - > getSinglePredecessorBlock ( ) ; <nl> - if ( ! Pred ) return In ; <nl> + / / / Helper method which initializes this state map with the data from the <nl> + / / / first predecessor BB . <nl> + / / / <nl> + / / / We will be performing an intersection in a later step of the merging . <nl> + bool initWithFirstPred ( SILBasicBlock * FirstPredBB ) ; <nl> <nl> - / / If the terminator is a cast instruction then use the pre - cast value . <nl> - if ( auto CCBI = dyn_cast < CheckedCastBranchInst > ( Pred - > getTerminator ( ) ) ) { <nl> - assert ( CCBI - > getSuccessBB ( ) = = Parent & & " Inspecting the wrong block " ) ; <nl> + / / / Top level merging function for predecessors . <nl> + void mergePredecessorStates ( ) ; <nl> <nl> - / / In swift it is legal to cast non reference - counted references into <nl> - / / object references . For example : func f ( x : C . Type ) - > Any { return x } <nl> - / / Here we check that the uncasted reference is reference counted . <nl> - SILValue V = CCBI - > getOperand ( ) ; <nl> - if ( V - > getType ( ) . isReferenceCounted ( Pred - > getParent ( ) - > getModule ( ) ) ) { <nl> - return V ; <nl> - } <nl> - } <nl> + / / / If we have a single predecessor , see if the predecessor ' s terminator was a <nl> + / / / switch_enum or a ( cond_br + select_enum ) . If so , track in this block the <nl> + / / / enum state of the operand . <nl> + void mergeSinglePredTermInfoIntoState ( SILBasicBlock * Pred ) ; <nl> <nl> - / / If the single predecessor terminator is a branch then the root is <nl> - / / the argument to the terminator . <nl> - if ( auto BI = dyn_cast < BranchInst > ( Pred - > getTerminator ( ) ) ) { <nl> - assert ( BI - > getDestBB ( ) = = Parent & & " Invalid terminator " ) ; <nl> - unsigned Idx = Arg - > getIndex ( ) ; <nl> - return BI - > getArg ( Idx ) ; <nl> - } <nl> + private : <nl> + EnumCaseDataflowContext & getContext ( ) const ; <nl> + unsigned getIDForValue ( SILValue V ) const ; <nl> + SILValue getValueForID ( unsigned ID ) const ; <nl> + } ; <nl> <nl> - if ( auto CBI = dyn_cast < CondBranchInst > ( Pred - > getTerminator ( ) ) ) { <nl> - return CBI - > getArgForDestBB ( Parent , Arg ) ; <nl> + / / / Map all blocks to BBEnumTagDataflowState in RPO order . <nl> + class EnumCaseDataflowContext { <nl> + PostOrderFunctionInfo * PO ; <nl> + std : : vector < BBEnumTagDataflowState > BBToStateVec ; <nl> + std : : vector < SILValue > IDToEnumValueMap ; <nl> + llvm : : DenseMap < SILValue , unsigned > EnumValueToIDMap ; <nl> + <nl> + public : <nl> + EnumCaseDataflowContext ( PostOrderFunctionInfo * PO ) : PO ( PO ) , BBToStateVec ( ) { <nl> + BBToStateVec . resize ( PO - > size ( ) ) ; <nl> + unsigned RPOIdx = 0 ; <nl> + for ( SILBasicBlock * BB : PO - > getReversePostOrder ( ) ) { <nl> + BBToStateVec [ RPOIdx ] . init ( * this , BB ) ; <nl> + + + RPOIdx ; <nl> } <nl> + } <nl> <nl> + / / / Return true if we have a valid value for the given ID ; <nl> + bool hasValueForID ( unsigned ID ) const { <nl> + return ID < IDToEnumValueMap . size ( ) & & IDToEnumValueMap [ ID ] ; <nl> } <nl> - return In ; <nl> - } <nl> <nl> - / / / \ brief Search for an instruction that is identical to \ p Iden by scanning <nl> - / / / \ p BB starting at the end of the block , stopping on sink barriers . <nl> - / / / The \ p opRelation must be consistent for all operand comparisons . <nl> - SILInstruction * findIdenticalInBlock ( SILBasicBlock * BB , SILInstruction * Iden , <nl> - const ValueToBBArgIdxMap & valueToArgIdxMap , <nl> - OperandRelation & opRelation ) { <nl> - int SkipBudget = SinkSearchWindow ; <nl> + SILValue getValueForID ( unsigned ID ) const { return IDToEnumValueMap [ ID ] ; } <nl> <nl> - SILBasicBlock : : iterator InstToSink = BB - > getTerminator ( ) - > getIterator ( ) ; <nl> - SILBasicBlock * IdenBlock = Iden - > getParent ( ) ; <nl> - <nl> - / / The compare function for instruction operands . <nl> - auto operandCompare = [ & ] ( const SILValue & Op1 , const SILValue & Op2 ) - > bool { <nl> - <nl> - if ( opRelation ! = EqualAfterMove & & Op1 = = Op2 ) { <nl> - / / The trivial case . <nl> - opRelation = AlwaysEqual ; <nl> - return true ; <nl> - } <nl> + unsigned getIDForValue ( SILValue V ) const { <nl> + / / We are being a little tricky here . Here is what is happening : <nl> + / / <nl> + / / 1 . When we start we do not know if we are already tracking V , so we <nl> + / / prepare / as if / V was new . <nl> + / / <nl> + / / 2 . When we perform the insertion , if V already has a value associated <nl> + / / with it , we return the iterator to that value . The iterator contains <nl> + / / inside of it the actual index . <nl> + / / <nl> + / / 3 . Otherwise , we initialize V in EnumValueToIDMap with NewID . Rather than <nl> + / / re - accessing the iterator , we just return the value we have already <nl> + / / computed . <nl> + unsigned NewID = IDToEnumValueMap . size ( ) ; <nl> + auto & This = const_cast < EnumCaseDataflowContext & > ( * this ) ; <nl> + auto Iter = This . EnumValueToIDMap . insert ( { V , NewID } ) ; <nl> + if ( ! Iter . second ) <nl> + return Iter . first - > second ; <nl> + This . IDToEnumValueMap . emplace_back ( V ) ; <nl> + return NewID ; <nl> + } <nl> <nl> - / / Check if both operand values are passed to the same block argument in the <nl> - / / successor block . This means that the operands are equal after we move the <nl> - / / instruction into the successor block . <nl> - if ( opRelation ! = AlwaysEqual ) { <nl> - auto Iter1 = valueToArgIdxMap . find ( { Op1 , IdenBlock } ) ; <nl> - if ( Iter1 ! = valueToArgIdxMap . end ( ) ) { <nl> - auto Iter2 = valueToArgIdxMap . find ( { Op2 , BB } ) ; <nl> - if ( Iter2 ! = valueToArgIdxMap . end ( ) & & Iter1 - > second = = Iter2 - > second ) { <nl> - opRelation = EqualAfterMove ; <nl> - return true ; <nl> - } <nl> - } <nl> - } <nl> - return false ; <nl> - } ; <nl> - <nl> - while ( SkipBudget ) { <nl> - / / If we found a sinkable instruction that is identical to our goal <nl> - / / then return it . <nl> - if ( canSinkInstruction ( & * InstToSink ) & & <nl> - Iden - > isIdenticalTo ( & * InstToSink , operandCompare ) ) { <nl> - DEBUG ( llvm : : dbgs ( ) < < " Found an identical instruction . " ) ; <nl> - return & * InstToSink ; <nl> + void blotValue ( SILValue V ) { <nl> + unsigned ID = getIDForValue ( V ) ; <nl> + IDToEnumValueMap [ ID ] = SILValue ( ) ; <nl> + } <nl> + <nl> + unsigned size ( ) const { return BBToStateVec . size ( ) ; } <nl> + BBEnumTagDataflowState & getRPOState ( unsigned RPOIdx ) { <nl> + return BBToStateVec [ RPOIdx ] ; <nl> + } <nl> + / / / \ return BBEnumTagDataflowState or NULL for unreachable blocks . <nl> + BBEnumTagDataflowState * getBBState ( SILBasicBlock * BB ) { <nl> + if ( auto ID = PO - > getRPONumber ( BB ) ) { <nl> + return & getRPOState ( * ID ) ; <nl> } <nl> + return nullptr ; <nl> + } <nl> + } ; <nl> <nl> - / / If this instruction is a skip - barrier end the scan . <nl> - if ( isSinkBarrier ( & * InstToSink ) ) <nl> - return nullptr ; <nl> + } / / end anonymous namespace <nl> <nl> - / / If this is the first instruction in the block then we are done . <nl> - if ( InstToSink = = BB - > begin ( ) ) <nl> - return nullptr ; <nl> + EnumCaseDataflowContext & BBEnumTagDataflowState : : getContext ( ) const { <nl> + / / Context and BB are initialized together , so we only need to check one . <nl> + assert ( BB . isNonNull ( ) & & " Uninitialized state ? ! " ) ; <nl> + return * Context ; <nl> + } <nl> <nl> - SkipBudget - - ; <nl> - InstToSink = std : : prev ( InstToSink ) ; <nl> - DEBUG ( llvm : : dbgs ( ) < < " Continuing scan . Next inst : " < < * InstToSink ) ; <nl> - } <nl> + unsigned BBEnumTagDataflowState : : getIDForValue ( SILValue V ) const { <nl> + return getContext ( ) . getIDForValue ( V ) ; <nl> + } <nl> <nl> - return nullptr ; <nl> + SILValue BBEnumTagDataflowState : : getValueForID ( unsigned ID ) const { <nl> + return getContext ( ) . getValueForID ( ID ) ; <nl> } <nl> <nl> - / / / The 2 instructions given are not identical , but are passed as arguments <nl> - / / / to a common successor . It may be cheaper to pass one of their operands <nl> - / / / to the successor instead of the whole instruction . <nl> - / / / Return None if no such operand could be found , otherwise return the index <nl> - / / / of a suitable operand . <nl> - static llvm : : Optional < unsigned > <nl> - cheaperToPassOperandsAsArguments ( SILInstruction * First , <nl> - SILInstruction * Second ) { <nl> - / / This will further enable to sink strong_retain_unowned instructions , <nl> - / / which provides more opportunities for the unowned - optimization in <nl> - / / LLVMARCOpts . <nl> - auto * UTORI1 = dyn_cast < UnownedToRefInst > ( First ) ; <nl> - auto * UTORI2 = dyn_cast < UnownedToRefInst > ( Second ) ; <nl> - if ( UTORI1 & & UTORI2 ) { <nl> - return 0 ; <nl> - } <nl> + void BBEnumTagDataflowState : : handlePredSwitchEnum ( SwitchEnumInst * S ) { <nl> <nl> - / / TODO : Add more cases than Struct <nl> - auto * FirstStruct = dyn_cast < StructInst > ( First ) ; <nl> - auto * SecondStruct = dyn_cast < StructInst > ( Second ) ; <nl> + / / Find the tag associated with our BB and set the state of the <nl> + / / enum we switch on to that value . This is important so we can determine <nl> + / / covering switches for enums that have cases without payload . <nl> <nl> - if ( ! FirstStruct | | ! SecondStruct ) <nl> - return None ; <nl> + / / Next check if we are the target of a default switch_enum case . If we are , <nl> + / / no interesting information can be extracted , so bail . . . <nl> + if ( S - > hasDefault ( ) & & S - > getDefaultBB ( ) = = getBB ( ) ) <nl> + return ; <nl> <nl> - assert ( FirstStruct - > getNumOperands ( ) = = SecondStruct - > getNumOperands ( ) & & <nl> - FirstStruct - > getType ( ) = = SecondStruct - > getType ( ) & & <nl> - " Types should be identical " ) ; <nl> + / / Otherwise , attempt to find the tag associated with this BB in the switch <nl> + / / enum . . . <nl> + for ( unsigned i = 0 , e = S - > getNumCases ( ) ; i ! = e ; + + i ) { <nl> + auto P = S - > getCase ( i ) ; <nl> <nl> - llvm : : Optional < unsigned > DifferentOperandIndex ; <nl> + / / If this case of the switch is not matched up with this BB , skip the <nl> + / / case . . . <nl> + if ( P . second ! = getBB ( ) ) <nl> + continue ; <nl> <nl> - / / Check operands . <nl> - for ( unsigned i = 0 , e = First - > getNumOperands ( ) ; i ! = e ; + + i ) { <nl> - if ( FirstStruct - > getOperand ( i ) ! = SecondStruct - > getOperand ( i ) ) { <nl> - / / Only track one different operand for now <nl> - if ( DifferentOperandIndex ) <nl> - return None ; <nl> - DifferentOperandIndex = i ; <nl> - } <nl> + / / Ok , we found the case for our BB . If we don ' t have an enum tag ( which can <nl> + / / happen if we have a default statement ) , return . There is nothing more we <nl> + / / can do . <nl> + if ( ! P . first ) <nl> + return ; <nl> + <nl> + / / Ok , we have a matching BB and a matching enum tag . Set the state and <nl> + / / return . <nl> + ValueToCaseMap [ getIDForValue ( S - > getOperand ( ) ) ] = P . first ; <nl> + return ; <nl> } <nl> + llvm_unreachable ( " A successor of a switch_enum terminated BB should be in " <nl> + " the switch_enum . " ) ; <nl> + } <nl> <nl> - if ( ! DifferentOperandIndex ) <nl> - return None ; <nl> + void BBEnumTagDataflowState : : handlePredCondSelectEnum ( CondBranchInst * CondBr ) { <nl> <nl> - / / Found a different operand , now check to see if its type is something <nl> - / / cheap enough to sink . <nl> - / / TODO : Sink more than just integers . <nl> - SILType ArgTy = FirstStruct - > getOperand ( * DifferentOperandIndex ) - > getType ( ) ; <nl> - if ( ! ArgTy . is < BuiltinIntegerType > ( ) ) <nl> - return None ; <nl> + auto * EITI = dyn_cast < SelectEnumInst > ( CondBr - > getCondition ( ) ) ; <nl> + if ( ! EITI ) <nl> + return ; <nl> <nl> - return * DifferentOperandIndex ; <nl> - } <nl> + NullablePtr < EnumElementDecl > TrueElement = EITI - > getSingleTrueElement ( ) ; <nl> + if ( TrueElement . isNull ( ) ) <nl> + return ; <nl> <nl> - / / / Return the value that ' s passed from block \ p From to block \ p To <nl> - / / / ( if there is a branch between From and To ) as the Nth argument . <nl> - SILValue getArgForBlock ( SILBasicBlock * From , SILBasicBlock * To , <nl> - unsigned ArgNum ) { <nl> - TermInst * Term = From - > getTerminator ( ) ; <nl> - if ( auto * CondBr = dyn_cast < CondBranchInst > ( Term ) ) { <nl> - if ( CondBr - > getFalseBB ( ) = = To ) <nl> - return CondBr - > getFalseArgs ( ) [ ArgNum ] ; <nl> + / / Find the tag associated with our BB and set the state of the <nl> + / / enum we switch on to that value . This is important so we can determine <nl> + / / covering switches for enums that have cases without payload . <nl> <nl> - if ( CondBr - > getTrueBB ( ) = = To ) <nl> - return CondBr - > getTrueArgs ( ) [ ArgNum ] ; <nl> + / / Check if we are the true case , ie , we know that we are the given tag . <nl> + const auto & Operand = EITI - > getEnumOperand ( ) ; <nl> + if ( CondBr - > getTrueBB ( ) = = getBB ( ) ) { <nl> + ValueToCaseMap [ getIDForValue ( Operand ) ] = TrueElement . get ( ) ; <nl> + return ; <nl> } <nl> <nl> - if ( auto * Br = dyn_cast < BranchInst > ( Term ) ) <nl> - return Br - > getArg ( ArgNum ) ; <nl> - <nl> - return SILValue ( ) ; <nl> + / / If the enum only has 2 values and its tag isn ' t the true branch , then we <nl> + / / know the true branch must be the other tag . <nl> + if ( EnumDecl * E = Operand - > getType ( ) . getEnumOrBoundGenericEnum ( ) ) { <nl> + / / Look for a single other element on this enum . <nl> + EnumElementDecl * OtherElt = nullptr ; <nl> + for ( EnumElementDecl * Elt : E - > getAllElements ( ) ) { <nl> + / / Skip the case where we find the select_enum element <nl> + if ( Elt = = TrueElement . get ( ) ) <nl> + continue ; <nl> + / / If we find another element , then we must have more than 2 , so bail . <nl> + if ( OtherElt ) <nl> + return ; <nl> + OtherElt = Elt ; <nl> + } <nl> + / / Only a single enum element ? How would this even get here ? We should <nl> + / / handle it in SILCombine . <nl> + if ( ! OtherElt ) <nl> + return ; <nl> + / / FIXME : Can we ever not be the false BB here ? <nl> + if ( CondBr - > getTrueBB ( ) ! = getBB ( ) ) { <nl> + ValueToCaseMap [ getIDForValue ( Operand ) ] = OtherElt ; <nl> + return ; <nl> + } <nl> + } <nl> } <nl> <nl> - / / Try to sink values from the Nth argument \ p ArgNum . <nl> - static bool sinkLiteralArguments ( SILBasicBlock * BB , unsigned ArgNum ) { <nl> - assert ( ArgNum < BB - > getNumArguments ( ) & & " Invalid argument " ) ; <nl> + bool BBEnumTagDataflowState : : initWithFirstPred ( SILBasicBlock * FirstPredBB ) { <nl> + / / Try to look up the state for the first pred BB . <nl> + BBEnumTagDataflowState * FirstPredState = getContext ( ) . getBBState ( FirstPredBB ) ; <nl> <nl> - / / Check if the argument passed to the first predecessor is a literal inst . <nl> - SILBasicBlock * FirstPred = * BB - > pred_begin ( ) ; <nl> - SILValue FirstArg = getArgForBlock ( FirstPred , BB , ArgNum ) ; <nl> - LiteralInst * FirstLiteral = dyn_cast_or_null < LiteralInst > ( FirstArg ) ; <nl> - if ( ! FirstLiteral ) <nl> + / / If we fail , we found an unreachable block , bail . <nl> + if ( FirstPredState = = nullptr ) { <nl> + DEBUG ( llvm : : dbgs ( ) < < " Found an unreachable block ! \ n " ) ; <nl> return false ; <nl> + } <nl> <nl> - / / Check if the Nth argument in all predecessors is identical . <nl> - for ( auto P : BB - > getPredecessorBlocks ( ) ) { <nl> - if ( P = = FirstPred ) <nl> - continue ; <nl> + / / Ok , our state is in the map , copy in the predecessors value to case map . <nl> + ValueToCaseMap = FirstPredState - > ValueToCaseMap ; <nl> <nl> - / / Check that the incoming value is identical to the first literal . <nl> - SILValue PredArg = getArgForBlock ( P , BB , ArgNum ) ; <nl> - LiteralInst * PredLiteral = dyn_cast_or_null < LiteralInst > ( PredArg ) ; <nl> - if ( ! PredLiteral | | ! PredLiteral - > isIdenticalTo ( FirstLiteral ) ) <nl> - return false ; <nl> + / / If we are predecessors only successor , we can potentially hoist releases <nl> + / / into it , so associate the first pred BB and the case for each value that we <nl> + / / are tracking with it . <nl> + / / <nl> + / / TODO : I am writing this too fast . Clean this up later . <nl> + if ( FirstPredBB - > getSingleSuccessorBlock ( ) ) { <nl> + for ( auto P : ValueToCaseMap . getItems ( ) ) { <nl> + if ( ! P . hasValue ( ) ) <nl> + continue ; <nl> + EnumToEnumBBCaseListMap [ P - > first ] . push_back ( { FirstPredBB , P - > second } ) ; <nl> + } <nl> } <nl> <nl> - / / Replace the use of the argument with the cloned literal . <nl> - auto Cloned = FirstLiteral - > clone ( & * BB - > begin ( ) ) ; <nl> - BB - > getArgument ( ArgNum ) - > replaceAllUsesWith ( Cloned ) ; <nl> - <nl> return true ; <nl> } <nl> <nl> - / / Try to sink values from the Nth argument \ p ArgNum . <nl> - static bool sinkArgument ( SILBasicBlock * BB , unsigned ArgNum ) { <nl> - assert ( ArgNum < BB - > getNumArguments ( ) & & " Invalid argument " ) ; <nl> + void BBEnumTagDataflowState : : mergeSinglePredTermInfoIntoState ( <nl> + SILBasicBlock * Pred ) { <nl> + / / Grab the terminator of our one predecessor and if it is a switch enum , mix <nl> + / / it into this state . <nl> + TermInst * PredTerm = Pred - > getTerminator ( ) ; <nl> + if ( auto * S = dyn_cast < SwitchEnumInst > ( PredTerm ) ) { <nl> + handlePredSwitchEnum ( S ) ; <nl> + return ; <nl> + } <nl> <nl> - / / Find the first predecessor , the first terminator and the Nth argument . <nl> - SILBasicBlock * FirstPred = * BB - > pred_begin ( ) ; <nl> - TermInst * FirstTerm = FirstPred - > getTerminator ( ) ; <nl> - auto FirstPredArg = FirstTerm - > getOperand ( ArgNum ) ; <nl> - auto * FSI = dyn_cast < SingleValueInstruction > ( FirstPredArg ) ; <nl> - / / TODO : MultiValueInstruction ? <nl> + auto * CondBr = dyn_cast < CondBranchInst > ( PredTerm ) ; <nl> + if ( ! CondBr ) <nl> + return ; <nl> <nl> - / / We only move instructions with a single use . <nl> - if ( ! FSI | | ! hasOneNonDebugUse ( FSI ) ) <nl> - return false ; <nl> + handlePredCondSelectEnum ( CondBr ) ; <nl> + } <nl> <nl> - / / The list of identical instructions . <nl> - SmallVector < SingleValueInstruction * , 8 > Clones ; <nl> - Clones . push_back ( FSI ) ; <nl> + void BBEnumTagDataflowState : : mergePredecessorStates ( ) { <nl> <nl> - / / Don ' t move instructions that are sensitive to their location . <nl> - / / <nl> - / / If this instruction can read memory , we try to be conservatively not to <nl> - / / move it , as there may be instructions that can clobber the read memory <nl> - / / from current place to the place where it is moved to . <nl> - if ( FSI - > mayReadFromMemory ( ) | | ( FSI - > mayHaveSideEffects ( ) & & <nl> - ! isa < AllocationInst > ( FSI ) ) ) <nl> - return false ; <nl> + / / If we have no predecessors , there is nothing to do so return early . . . <nl> + if ( getBB ( ) - > pred_empty ( ) ) { <nl> + DEBUG ( llvm : : dbgs ( ) < < " No Preds . \ n " ) ; <nl> + return ; <nl> + } <nl> <nl> - / / If the instructions are different , but only in terms of a cheap operand <nl> - / / then we can still sink it , and create new arguments for this operand . <nl> - llvm : : Optional < unsigned > DifferentOperandIndex ; <nl> + auto PI = getBB ( ) - > pred_begin ( ) , PE = getBB ( ) - > pred_end ( ) ; <nl> + if ( * PI = = getBB ( ) ) { <nl> + DEBUG ( llvm : : dbgs ( ) < < " Found a self loop . Bailing ! \ n " ) ; <nl> + return ; <nl> + } <nl> <nl> - / / Check if the Nth argument in all predecessors is identical . <nl> - for ( auto P : BB - > getPredecessorBlocks ( ) ) { <nl> - if ( P = = FirstPred ) <nl> - continue ; <nl> + / / Grab the first predecessor BB . <nl> + SILBasicBlock * FirstPred = * PI ; <nl> + + + PI ; <nl> <nl> - / / Only handle branch or conditional branch instructions . <nl> - TermInst * TI = P - > getTerminator ( ) ; <nl> - if ( ! isa < BranchInst > ( TI ) & & ! isa < CondBranchInst > ( TI ) ) <nl> - return false ; <nl> + / / Attempt to initialize our state with our first predecessor ' s state by just <nl> + / / copying . We will be doing an intersection with all of the other BB . <nl> + if ( ! initWithFirstPred ( FirstPred ) ) <nl> + return ; <nl> <nl> - / / Find the Nth argument passed to BB . <nl> - SILValue Arg = TI - > getOperand ( ArgNum ) ; <nl> + / / If we only have one predecessor see if we can gain any information and or <nl> + / / knowledge from the terminator of our one predecessor . There is nothing more <nl> + / / that we can do , return . <nl> + / / <nl> + / / This enables us to get enum information from switch_enum and cond_br about <nl> + / / the value that an enum can take in our block . This is a common case that <nl> + / / comes up . <nl> + if ( PI = = PE ) { <nl> + mergeSinglePredTermInfoIntoState ( FirstPred ) ; <nl> + return ; <nl> + } <nl> <nl> - / / If it ' s not the same basic kind of node , neither isIdenticalTo nor <nl> - / / cheaperToPassOperandsAsArguments will return true . <nl> - if ( Arg - > getKind ( ) ! = FSI - > getValueKind ( ) ) <nl> - return false ; <nl> + DEBUG ( llvm : : dbgs ( ) < < " Merging in rest of predecessors . . . \ n " ) ; <nl> <nl> - / / Since it ' s the same kind , Arg must also be a single - value instruction . <nl> - auto * SI = cast < SingleValueInstruction > ( Arg ) ; <nl> + / / Enum values that while merging we found conflicting values for . We blot <nl> + / / them after the loop in order to ensure that we can still find the ends of <nl> + / / switch regions . <nl> + llvm : : SmallVector < unsigned , 4 > CurBBValuesToBlot ; <nl> <nl> - if ( ! hasOneNonDebugUse ( SI ) ) <nl> - return false ; <nl> + / / If we do not find state for a specific value in any of our predecessor BBs , <nl> + / / we cannot be the end of a switch region since we cannot cover our <nl> + / / predecessor BBs with enum decls . Blot after the loop . <nl> + llvm : : SmallVector < unsigned , 4 > PredBBValuesToBlot ; <nl> <nl> - if ( SI - > isIdenticalTo ( FSI ) ) { <nl> - Clones . push_back ( SI ) ; <nl> - continue ; <nl> + / / And for each remaining predecessor . . . <nl> + do { <nl> + / / If we loop on ourselves , bail . . . <nl> + if ( * PI = = getBB ( ) ) { <nl> + DEBUG ( llvm : : dbgs ( ) < < " Found a self loop . Bailing ! \ n " ) ; <nl> + return ; <nl> } <nl> <nl> - / / If the instructions are close enough , then we should sink them anyway . <nl> - / / For example , we should sink ' struct S ( % 0 ) ' if % 0 is small , eg , an integer <nl> - auto MaybeDifferentOp = cheaperToPassOperandsAsArguments ( FSI , SI ) ; <nl> - / / Couldn ' t find a suitable operand , so bail . <nl> - if ( ! MaybeDifferentOp ) <nl> - return false ; <nl> - unsigned DifferentOp = * MaybeDifferentOp ; <nl> - / / Make sure we found the same operand as prior iterations . <nl> - if ( DifferentOperandIndex & & DifferentOp ! = * DifferentOperandIndex ) <nl> - return false ; <nl> - <nl> - DifferentOperandIndex = DifferentOp ; <nl> - Clones . push_back ( SI ) ; <nl> - } <nl> - <nl> - auto * Undef = SILUndef : : get ( FSI - > getType ( ) , BB - > getModule ( ) ) ; <nl> + / / Grab the predecessors state . . . <nl> + SILBasicBlock * PredBB = * PI ; <nl> <nl> - / / Delete the debug info of the instruction that we are about to sink . <nl> - deleteAllDebugUses ( FSI ) ; <nl> + BBEnumTagDataflowState * PredBBState = getContext ( ) . getBBState ( PredBB ) ; <nl> + if ( PredBBState = = nullptr ) { <nl> + DEBUG ( llvm : : dbgs ( ) < < " Found an unreachable block ! \ n " ) ; <nl> + return ; <nl> + } <nl> <nl> - if ( DifferentOperandIndex ) { <nl> - / / Sink one of the instructions to BB <nl> - FSI - > moveBefore ( & * BB - > begin ( ) ) ; <nl> + + + PI ; <nl> <nl> - / / The instruction we are lowering has an argument which is different <nl> - / / for each predecessor . We need to sink the instruction , then add <nl> - / / arguments for each predecessor . <nl> - BB - > getArgument ( ArgNum ) - > replaceAllUsesWith ( FSI ) ; <nl> + / / Then for each ( SILValue , Enum Tag ) that we are tracking . . . <nl> + for ( auto P : ValueToCaseMap . getItems ( ) ) { <nl> + / / If this SILValue was blotted , there is nothing left to do , we found <nl> + / / some sort of conflicting definition and are being conservative . <nl> + if ( ! P . hasValue ( ) ) <nl> + continue ; <nl> <nl> - const auto & ArgType = FSI - > getOperand ( * DifferentOperandIndex ) - > getType ( ) ; <nl> - BB - > replacePHIArgument ( ArgNum , ArgType , ValueOwnershipKind : : Owned ) ; <nl> + / / Then attempt to look up the enum state associated in our SILValue in <nl> + / / the predecessor we are processing . <nl> + auto PredIter = PredBBState - > ValueToCaseMap . find ( P - > first ) ; <nl> <nl> - / / Update all branch instructions in the predecessors to pass the new <nl> - / / argument to this BB . <nl> - auto CloneIt = Clones . begin ( ) ; <nl> - for ( auto P : BB - > getPredecessorBlocks ( ) ) { <nl> - / / Only handle branch or conditional branch instructions . <nl> - TermInst * TI = P - > getTerminator ( ) ; <nl> - assert ( ( isa < BranchInst > ( TI ) | | isa < CondBranchInst > ( TI ) ) & & <nl> - " Branch instruction required " ) ; <nl> + / / If we cannot find the state associated with this SILValue in this <nl> + / / predecessor or the ID in the corresponding predecessor was blotted , we <nl> + / / cannot find a covering switch for this BB or forward any enum tag <nl> + / / information for this enum value . <nl> + if ( PredIter = = PredBBState - > ValueToCaseMap . end ( ) | | <nl> + ! ( * PredIter ) . hasValue ( ) ) { <nl> + / / Otherwise , we are conservative and do not forward the EnumTag that we <nl> + / / are tracking . Blot it ! <nl> + DEBUG ( llvm : : dbgs ( ) < < " Blotting : " < < P - > first ) ; <nl> + CurBBValuesToBlot . push_back ( P - > first ) ; <nl> + PredBBValuesToBlot . push_back ( P - > first ) ; <nl> + continue ; <nl> + } <nl> <nl> - / / TODO : MultiValueInstruction <nl> - auto * CloneInst = * CloneIt ; <nl> - TI - > setOperand ( ArgNum , CloneInst - > getOperand ( * DifferentOperandIndex ) ) ; <nl> - / / Now delete the clone as we only needed it operand . <nl> - if ( CloneInst ! = FSI ) <nl> - recursivelyDeleteTriviallyDeadInstructions ( CloneInst ) ; <nl> - + + CloneIt ; <nl> - } <nl> - assert ( CloneIt = = Clones . end ( ) & & " Clone / pred mismatch " ) ; <nl> + / / Then try to lookup the actual value associated with the ID . If we do <nl> + / / not find one , then the enum was destroyed by another part of the pass . <nl> + SILValue PredValue = getValueForID ( ( * PredIter ) - > first ) ; <nl> + if ( ! PredValue ) <nl> + continue ; <nl> <nl> - / / The sunk instruction should now read from the argument of the BB it <nl> - / / was moved to . <nl> - FSI - > setOperand ( * DifferentOperandIndex , BB - > getArgument ( ArgNum ) ) ; <nl> - return true ; <nl> - } <nl> + / / Check if out predecessor has any other successors . If that is true we <nl> + / / clear all the state since we cannot hoist safely . <nl> + if ( ! PredBB - > getSingleSuccessorBlock ( ) ) { <nl> + EnumToEnumBBCaseListMap . clear ( ) ; <nl> + DEBUG ( llvm : : dbgs ( ) < < " Predecessor has other " <nl> + " successors . Clearing BB cast list map . \ n " ) ; <nl> + } else { <nl> + / / Otherwise , add this case to our predecessor case list . We will unique <nl> + / / this after we have finished processing all predecessors . <nl> + auto Case = std : : make_pair ( PredBB , ( * PredIter ) - > second ) ; <nl> + EnumToEnumBBCaseListMap [ ( * PredIter ) - > first ] . push_back ( Case ) ; <nl> + } <nl> <nl> - / / Sink one of the copies of the instruction . <nl> - FSI - > replaceAllUsesWithUndef ( ) ; <nl> - FSI - > moveBefore ( & * BB - > begin ( ) ) ; <nl> - BB - > getArgument ( ArgNum ) - > replaceAllUsesWith ( FSI ) ; <nl> + / / And the states match , the enum state propagates to this BB . <nl> + if ( ( * PredIter ) - > second = = P - > second ) <nl> + continue ; <nl> <nl> - / / The argument is no longer in use . Replace all incoming inputs with undef <nl> - / / and try to delete the instruction . <nl> - for ( auto S : Clones ) <nl> - if ( S ! = FSI ) { <nl> - deleteAllDebugUses ( S ) ; <nl> - S - > replaceAllUsesWith ( Undef ) ; <nl> - auto DeadArgInst = cast < SILInstruction > ( S ) ; <nl> - recursivelyDeleteTriviallyDeadInstructions ( DeadArgInst ) ; <nl> + / / Otherwise , we are conservative and do not forward the EnumTag that we <nl> + / / are tracking . Blot it ! <nl> + DEBUG ( llvm : : dbgs ( ) < < " Blotting : " < < P - > first ) ; <nl> + CurBBValuesToBlot . push_back ( P - > first ) ; <nl> } <nl> + } while ( PI ! = PE ) ; <nl> <nl> - return true ; <nl> + for ( unsigned ID : CurBBValuesToBlot ) { <nl> + ValueToCaseMap . blot ( ID ) ; <nl> + } <nl> + for ( unsigned ID : PredBBValuesToBlot ) { <nl> + EnumToEnumBBCaseListMap . blot ( ID ) ; <nl> + } <nl> } <nl> <nl> + bool BBEnumTagDataflowState : : visitEnumInst ( EnumInst * EI ) { <nl> + unsigned ID = getIDForValue ( SILValue ( EI ) ) ; <nl> + DEBUG ( llvm : : dbgs ( ) < < " Storing enum into map . ID : " < < ID <nl> + < < " . Value : " < < * EI ) ; <nl> + ValueToCaseMap [ ID ] = EI - > getElement ( ) ; <nl> + return false ; <nl> + } <nl> <nl> - / / / Try to sink literals that are passed to arguments that are coming from <nl> - / / / multiple predecessors . <nl> - / / / Notice that unlike other sinking methods in this file we do allow sinking <nl> - / / / of literals from blocks with multiple successors . <nl> - static bool sinkLiteralsFromPredecessors ( SILBasicBlock * BB ) { <nl> - if ( BB - > pred_empty ( ) | | BB - > getSinglePredecessorBlock ( ) ) <nl> + bool BBEnumTagDataflowState : : visitUncheckedEnumDataInst ( <nl> + UncheckedEnumDataInst * UEDI ) { <nl> + unsigned ID = getIDForValue ( UEDI - > getOperand ( ) ) ; <nl> + DEBUG ( llvm : : dbgs ( ) < < " Storing unchecked enum data into map . ID : " < < ID <nl> + < < " . Value : " < < * UEDI ) ; <nl> + ValueToCaseMap [ ID ] = UEDI - > getElement ( ) ; <nl> + return false ; <nl> + } <nl> + <nl> + bool BBEnumTagDataflowState : : visitRetainValueInst ( RetainValueInst * RVI ) { <nl> + auto FindResult = ValueToCaseMap . find ( getIDForValue ( RVI - > getOperand ( ) ) ) ; <nl> + if ( FindResult = = ValueToCaseMap . end ( ) ) <nl> return false ; <nl> <nl> - / / Try to sink values from each of the arguments to the basic block . <nl> - bool Changed = false ; <nl> - for ( int i = 0 , e = BB - > getNumArguments ( ) ; i < e ; + + i ) <nl> - Changed | = sinkLiteralArguments ( BB , i ) ; <nl> + / / If we do not have any argument , kill the retain_value . <nl> + if ( ! ( * FindResult ) - > second - > hasAssociatedValues ( ) ) { <nl> + RVI - > eraseFromParent ( ) ; <nl> + return true ; <nl> + } <nl> <nl> - return Changed ; <nl> + DEBUG ( llvm : : dbgs ( ) < < " Found RetainValue : " < < * RVI ) ; <nl> + DEBUG ( llvm : : dbgs ( ) < < " Paired to Enum Oracle : " <nl> + < < ( * FindResult ) - > first ) ; <nl> + <nl> + SILBuilderWithScope Builder ( RVI ) ; <nl> + createRefCountOpForPayload ( Builder , RVI , ( * FindResult ) - > second ) ; <nl> + RVI - > eraseFromParent ( ) ; <nl> + return true ; <nl> } <nl> <nl> - / / / Try to sink identical arguments coming from multiple predecessors . <nl> - static bool sinkArgumentsFromPredecessors ( SILBasicBlock * BB ) { <nl> - if ( BB - > pred_empty ( ) | | BB - > getSinglePredecessorBlock ( ) ) <nl> + bool BBEnumTagDataflowState : : visitReleaseValueInst ( ReleaseValueInst * RVI ) { <nl> + auto FindResult = ValueToCaseMap . find ( getIDForValue ( RVI - > getOperand ( ) ) ) ; <nl> + if ( FindResult = = ValueToCaseMap . end ( ) ) <nl> return false ; <nl> <nl> - / / This block must be the only successor of all the predecessors . <nl> - for ( auto P : BB - > getPredecessorBlocks ( ) ) <nl> - if ( P - > getSingleSuccessorBlock ( ) ! = BB ) <nl> - return false ; <nl> + / / If we do not have any argument , just delete the release value . <nl> + if ( ! ( * FindResult ) - > second - > hasAssociatedValues ( ) ) { <nl> + RVI - > eraseFromParent ( ) ; <nl> + return true ; <nl> + } <nl> <nl> - / / Try to sink values from each of the arguments to the basic block . <nl> - bool Changed = false ; <nl> - for ( int i = 0 , e = BB - > getNumArguments ( ) ; i < e ; + + i ) <nl> - Changed | = sinkArgument ( BB , i ) ; <nl> + DEBUG ( llvm : : dbgs ( ) < < " Found ReleaseValue : " < < * RVI ) ; <nl> + DEBUG ( llvm : : dbgs ( ) < < " Paired to Enum Oracle : " <nl> + < < ( * FindResult ) - > first ) ; <nl> <nl> - return Changed ; <nl> + SILBuilderWithScope Builder ( RVI ) ; <nl> + createRefCountOpForPayload ( Builder , RVI , ( * FindResult ) - > second ) ; <nl> + RVI - > eraseFromParent ( ) ; <nl> + return true ; <nl> } <nl> <nl> - / / / \ brief canonicalize retain / release instructions and make them amenable to <nl> - / / / sinking by selecting canonical pointers . We reduce the number of possible <nl> - / / / inputs by replacing values that are unlikely to be a canonical values . <nl> - / / / Reducing the search space increases the chances of matching ref count <nl> - / / / instructions to one another and the chance of sinking them . We replace <nl> - / / / values that come from basic block arguments with the caller values and <nl> - / / / strip casts . <nl> - static bool canonicalizeRefCountInstrs ( SILBasicBlock * BB ) { <nl> - bool Changed = false ; <nl> - for ( auto I = BB - > begin ( ) , E = BB - > end ( ) ; I ! = E ; + + I ) { <nl> - if ( ! isa < StrongReleaseInst > ( I ) & & ! isa < StrongRetainInst > ( I ) ) <nl> - continue ; <nl> - <nl> - SILValue Ref = I - > getOperand ( 0 ) ; <nl> - SILValue Root = findValueShallowRoot ( Ref ) ; <nl> - if ( Ref ! = Root ) { <nl> - I - > setOperand ( 0 , Root ) ; <nl> - Changed = true ; <nl> - } <nl> - } <nl> - <nl> - return Changed ; <nl> + bool BBEnumTagDataflowState : : process ( ) { <nl> + bool Changed = false ; <nl> + <nl> + auto SI = getBB ( ) - > begin ( ) ; <nl> + while ( SI ! = getBB ( ) - > end ( ) ) { <nl> + SILInstruction * I = & * SI ; <nl> + + + SI ; <nl> + Changed | = visit ( I ) ; <nl> + } <nl> + <nl> + return Changed ; <nl> } <nl> <nl> - static bool sinkCodeFromPredecessors ( SILBasicBlock * BB ) { <nl> + bool BBEnumTagDataflowState : : hoistDecrementsIntoSwitchRegions ( <nl> + AliasAnalysis * AA ) { <nl> bool Changed = false ; <nl> - if ( BB - > pred_empty ( ) ) <nl> - return Changed ; <nl> + unsigned NumPreds = std : : distance ( getBB ( ) - > pred_begin ( ) , getBB ( ) - > pred_end ( ) ) ; <nl> <nl> - / / This block must be the only successor of all the predecessors . <nl> - for ( auto P : BB - > getPredecessorBlocks ( ) ) <nl> - if ( P - > getSingleSuccessorBlock ( ) ! = BB ) <nl> - return Changed ; <nl> + for ( auto II = getBB ( ) - > begin ( ) , IE = getBB ( ) - > end ( ) ; II ! = IE ; ) { <nl> + auto * RVI = dyn_cast < ReleaseValueInst > ( & * II ) ; <nl> + + + II ; <nl> <nl> - SILBasicBlock * FirstPred = * BB - > pred_begin ( ) ; <nl> - / / The first Pred must have at least one non - terminator . <nl> - if ( FirstPred - > getTerminator ( ) = = & * FirstPred - > begin ( ) ) <nl> - return Changed ; <nl> + / / If this instruction is not a release , skip it . . . <nl> + if ( ! RVI ) <nl> + continue ; <nl> <nl> - DEBUG ( llvm : : dbgs ( ) < < " Sinking values from predecessors . \ n " ) ; <nl> + DEBUG ( llvm : : dbgs ( ) < < " Visiting release : " < < * RVI ) ; <nl> <nl> - / / Map values in predecessor blocks to argument indices of the successor <nl> - / / block . For example : <nl> - / / <nl> - / / bb1 : <nl> - / / br bb3 ( % a , % b ) / / % a - > 0 , % b - > 1 <nl> - / / bb2 : <nl> - / / br bb3 ( % c , % d ) / / % c - > 0 , % d - > 1 <nl> - / / bb3 ( % x , % y ) : <nl> - / / . . . <nl> - ValueToBBArgIdxMap valueToArgIdxMap ; <nl> - for ( auto P : BB - > getPredecessorBlocks ( ) ) { <nl> - if ( auto * BI = dyn_cast < BranchInst > ( P - > getTerminator ( ) ) ) { <nl> - auto Args = BI - > getArgs ( ) ; <nl> - for ( size_t idx = 0 , size = Args . size ( ) ; idx < size ; idx + + ) { <nl> - valueToArgIdxMap [ { Args [ idx ] , P } ] = idx ; <nl> - } <nl> + / / Grab the operand of the release value inst . <nl> + SILValue Op = RVI - > getOperand ( ) ; <nl> + <nl> + / / Lookup the [ ( BB , EnumTag ) ] list for this operand . <nl> + unsigned ID = getIDForValue ( Op ) ; <nl> + auto R = EnumToEnumBBCaseListMap . find ( ID ) ; <nl> + / / If we don ' t have one , skip this release value inst . <nl> + if ( R = = EnumToEnumBBCaseListMap . end ( ) ) { <nl> + DEBUG ( llvm : : dbgs ( ) < < " Could not find [ ( BB , EnumTag ) ] " <nl> + " list for release_value ' s operand . Bailing ! \ n " ) ; <nl> + continue ; <nl> } <nl> - } <nl> <nl> - unsigned SkipBudget = SinkSearchWindow ; <nl> + auto & EnumBBCaseList = ( * R ) - > second ; <nl> + / / If we don ' t have an enum tag for each predecessor of this BB , bail since <nl> + / / we do not know how to handle that BB . <nl> + if ( EnumBBCaseList . size ( ) ! = NumPreds ) { <nl> + DEBUG ( llvm : : dbgs ( ) < < " Found [ ( BB , EnumTag ) ] list for " <nl> + " release_value ' s operand , but we do not have an " <nl> + " enum tag for each predecessor . Bailing ! \ n " ) ; <nl> + DEBUG ( llvm : : dbgs ( ) < < " List : \ n " ) ; <nl> + DEBUG ( for ( auto P <nl> + : EnumBBCaseList ) { <nl> + llvm : : dbgs ( ) < < " " ; <nl> + P . second - > dump ( llvm : : dbgs ( ) ) ; <nl> + } ) ; <nl> + continue ; <nl> + } <nl> <nl> - / / Start scanning backwards from the terminator . <nl> - auto InstToSink = FirstPred - > getTerminator ( ) - > getIterator ( ) ; <nl> + / / Finally ensure that we have no users of this operand preceding the <nl> + / / release_value in this BB . If we have users like that we cannot hoist the <nl> + / / release past them unless we know that there is an additional set of <nl> + / / releases that together post - dominate this release . If we cannot do this , <nl> + / / skip this release . <nl> + / / <nl> + / / TODO : We need information from the ARC optimizer to prove that property <nl> + / / if we are going to use it . <nl> + if ( valueHasARCUsesInInstructionRange ( Op , getBB ( ) - > begin ( ) , <nl> + SILBasicBlock : : iterator ( RVI ) , AA ) ) { <nl> + DEBUG ( llvm : : dbgs ( ) < < " Release value has use that stops " <nl> + " hoisting ! Bailing ! \ n " ) ; <nl> + continue ; <nl> + } <nl> <nl> - while ( SkipBudget ) { <nl> - DEBUG ( llvm : : dbgs ( ) < < " Processing : " < < * InstToSink ) ; <nl> + DEBUG ( llvm : : dbgs ( ) < < " Its safe to perform the " <nl> + " transformation ! \ n " ) ; <nl> <nl> - / / Save the duplicated instructions in case we need to remove them . <nl> - SmallVector < SILInstruction * , 4 > Dups ; <nl> + / / Otherwise perform the transformation . <nl> + for ( auto P : EnumBBCaseList ) { <nl> + / / If we don ' t have an argument for this case , there is nothing to <nl> + / / do . . . continue . . . <nl> + if ( ! P . second - > hasAssociatedValues ( ) ) <nl> + continue ; <nl> <nl> - if ( canSinkInstruction ( & * InstToSink ) ) { <nl> + / / Otherwise create the release_value before the terminator of the <nl> + / / predecessor . <nl> + assert ( P . first - > getSingleSuccessorBlock ( ) & & <nl> + " Cannot hoist release into BB that has multiple successors " ) ; <nl> + SILBuilderWithScope Builder ( P . first - > getTerminator ( ) , RVI ) ; <nl> + createRefCountOpForPayload ( Builder , RVI , P . second ) ; <nl> + } <nl> <nl> - OperandRelation opRelation = NotDeterminedYet ; <nl> + RVI - > eraseFromParent ( ) ; <nl> + + + NumHoisted ; <nl> + Changed = true ; <nl> + } <nl> <nl> - / / For all preds : <nl> - for ( auto P : BB - > getPredecessorBlocks ( ) ) { <nl> - if ( P = = FirstPred ) <nl> - continue ; <nl> + return Changed ; <nl> + } <nl> <nl> - / / Search the duplicated instruction in the predecessor . <nl> - if ( SILInstruction * DupInst = findIdenticalInBlock ( <nl> - P , & * InstToSink , valueToArgIdxMap , opRelation ) ) { <nl> - Dups . push_back ( DupInst ) ; <nl> - } else { <nl> - DEBUG ( llvm : : dbgs ( ) < < " Instruction mismatch . \ n " ) ; <nl> - Dups . clear ( ) ; <nl> - break ; <nl> - } <nl> - } <nl> + static SILInstruction * findLastSinkableMatchingEnumValueRCIncrementInPred ( <nl> + AliasAnalysis * AA , RCIdentityFunctionInfo * RCIA , SILValue EnumValue , <nl> + SILBasicBlock * BB ) { <nl> + / / Otherwise , see if we can find a retain_value or strong_retain associated <nl> + / / with that enum in the relevant predecessor . <nl> + auto FirstInc = std : : find_if ( <nl> + BB - > rbegin ( ) , BB - > rend ( ) , <nl> + [ & RCIA , & EnumValue ] ( const SILInstruction & I ) - > bool { <nl> + / / If I is not an increment , ignore it . <nl> + if ( ! isa < StrongRetainInst > ( I ) & & ! isa < RetainValueInst > ( I ) ) <nl> + return false ; <nl> + <nl> + / / Otherwise , if the increments operand stripped of RC identity <nl> + / / preserving <nl> + / / ops matches EnumValue , it is the first increment we are interested <nl> + / / in . <nl> + return EnumValue = = RCIA - > getRCIdentityRoot ( I . getOperand ( 0 ) ) ; <nl> + } ) ; <nl> + <nl> + / / If we do not find a ref count increment in the relevant BB , skip this <nl> + / / enum since there is nothing we can do . <nl> + if ( FirstInc = = BB - > rend ( ) ) <nl> + return nullptr ; <nl> <nl> - / / If we found duplicated instructions , sink one of the copies and delete <nl> - / / the rest . <nl> - if ( Dups . size ( ) ) { <nl> - DEBUG ( llvm : : dbgs ( ) < < " Moving : " < < * InstToSink ) ; <nl> - InstToSink - > moveBefore ( & * BB - > begin ( ) ) ; <nl> + / / Otherwise , see if there are any instructions in between FirstPredInc and <nl> + / / the end of the given basic block that could decrement first pred . If such <nl> + / / an instruction exists , we cannot perform this optimization so continue . <nl> + if ( valueHasARCDecrementOrCheckInInstructionRange ( <nl> + EnumValue , ( * FirstInc ) . getIterator ( ) , <nl> + BB - > getTerminator ( ) - > getIterator ( ) , AA ) ) <nl> + return nullptr ; <nl> <nl> - if ( opRelation = = EqualAfterMove ) { <nl> - / / Replace operand values ( which are passed to the successor block ) <nl> - / / with corresponding block arguments . <nl> - for ( size_t idx = 0 , numOps = InstToSink - > getNumOperands ( ) ; <nl> - idx < numOps ; idx + + ) { <nl> - ValueInBlock OpInFirstPred ( InstToSink - > getOperand ( idx ) , FirstPred ) ; <nl> - assert ( valueToArgIdxMap . count ( OpInFirstPred ) ! = 0 ) ; <nl> - int argIdx = valueToArgIdxMap [ OpInFirstPred ] ; <nl> - InstToSink - > setOperand ( idx , BB - > getArgument ( argIdx ) ) ; <nl> - } <nl> - } <nl> - Changed = true ; <nl> - for ( auto I : Dups ) { <nl> - I - > replaceAllUsesPairwiseWith ( & * InstToSink ) ; <nl> - I - > eraseFromParent ( ) ; <nl> - NumSunk + + ; <nl> - } <nl> + return & * FirstInc ; <nl> + } <nl> <nl> - / / Restart the scan . <nl> - InstToSink = FirstPred - > getTerminator ( ) - > getIterator ( ) ; <nl> - DEBUG ( llvm : : dbgs ( ) < < " Restarting scan . Next inst : " < < * InstToSink ) ; <nl> - continue ; <nl> - } <nl> - } <nl> + static bool findRetainsSinkableFromSwitchRegionForEnum ( <nl> + AliasAnalysis * AA , RCIdentityFunctionInfo * RCIA , SILValue EnumValue , <nl> + EnumBBCaseList & Map , SmallVectorImpl < SILInstruction * > & DeleteList ) { <nl> <nl> - / / If this instruction was a barrier then we can ' t sink anything else . <nl> - if ( isSinkBarrier ( & * InstToSink ) ) { <nl> - DEBUG ( llvm : : dbgs ( ) < < " Aborting on barrier : " < < * InstToSink ) ; <nl> - return Changed ; <nl> - } <nl> + / / For each predecessor with argument type . . . <nl> + for ( auto & P : Map ) { <nl> + SILBasicBlock * PredBB = P . first ; <nl> + EnumElementDecl * Decl = P . second ; <nl> <nl> - / / This is the first instruction , we are done . <nl> - if ( InstToSink = = FirstPred - > begin ( ) ) { <nl> - DEBUG ( llvm : : dbgs ( ) < < " Reached the first instruction . " ) ; <nl> - return Changed ; <nl> - } <nl> + / / If the case does not have an argument type , skip the predecessor since <nl> + / / there will not be a retain to sink . <nl> + if ( ! Decl - > hasAssociatedValues ( ) ) <nl> + continue ; <nl> <nl> - SkipBudget - - ; <nl> - InstToSink = std : : prev ( InstToSink ) ; <nl> - DEBUG ( llvm : : dbgs ( ) < < " Continuing scan . Next inst : " < < * InstToSink ) ; <nl> + / / Ok , we found a payloaded predecessor . Look backwards through the <nl> + / / predecessor for the first ref count increment on EnumValue . If there <nl> + / / are no ref count decrements in between the increment and the terminator <nl> + / / of the BB , then we can sink the retain out of the switch enum . <nl> + auto * Inc = findLastSinkableMatchingEnumValueRCIncrementInPred ( <nl> + AA , RCIA , EnumValue , PredBB ) ; <nl> + / / If we do not find such an increment , there is nothing we can do , bail . <nl> + if ( ! Inc ) <nl> + return false ; <nl> + <nl> + / / Otherwise add the increment to the delete list . <nl> + DeleteList . push_back ( Inc ) ; <nl> } <nl> <nl> - return Changed ; <nl> + / / If we were able to process each predecessor successfully , return true . <nl> + return true ; <nl> } <nl> <nl> - / / / Sink retain_value , release_value before switch_enum to be retain_value , <nl> - / / / release_value on the payload of the switch_enum in the destination BBs . We <nl> - / / / only do this if the destination BBs have only the switch enum as its <nl> - / / / predecessor . <nl> - static bool tryToSinkRefCountAcrossSwitch ( SwitchEnumInst * Switch , <nl> - SILBasicBlock : : iterator RV , <nl> - AliasAnalysis * AA , <nl> - RCIdentityFunctionInfo * RCIA ) { <nl> - / / If this instruction is not a retain_value , there is nothing left for us to <nl> - / / do . . . bail . . . <nl> - if ( ! isa < RetainValueInst > ( RV ) ) <nl> - return false ; <nl> + bool BBEnumTagDataflowState : : sinkIncrementsOutOfSwitchRegions ( <nl> + AliasAnalysis * AA , RCIdentityFunctionInfo * RCIA ) { <nl> + bool Changed = false ; <nl> + unsigned NumPreds = std : : distance ( getBB ( ) - > pred_begin ( ) , getBB ( ) - > pred_end ( ) ) ; <nl> + llvm : : SmallVector < SILInstruction * , 4 > DeleteList ; <nl> <nl> - SILValue Ptr = RV - > getOperand ( 0 ) ; <nl> + / / For each ( EnumValue , [ ( BB , EnumTag ) ] ) that we are tracking . . . <nl> + for ( auto & P : EnumToEnumBBCaseListMap ) { <nl> + / / Clear our delete list . <nl> + DeleteList . clear ( ) ; <nl> <nl> - / / Next go over all instructions after I in the basic block . If none of them <nl> - / / can decrement our ptr value , we can move the retain over the ref count <nl> - / / inst . If any of them do potentially decrement the ref count of Ptr , we can <nl> - / / not move it . <nl> - auto SwitchIter = Switch - > getIterator ( ) ; <nl> - if ( auto B = valueHasARCDecrementOrCheckInInstructionRange ( Ptr , RV , <nl> - SwitchIter , <nl> - AA ) ) { <nl> - RV - > moveBefore ( & * * B ) ; <nl> - return true ; <nl> + / / If EnumValue is null , we deleted this entry . There is nothing to do for <nl> + / / this value . . . Skip it . <nl> + if ( ! P . hasValue ( ) ) <nl> + continue ; <nl> + <nl> + / / Look up the actual enum value using our index to make sure that other <nl> + / / parts of the pass have not destroyed the value . In such a case , just <nl> + / / continue . <nl> + SILValue EnumValue = getContext ( ) . getValueForID ( P - > first ) ; <nl> + if ( ! EnumValue ) <nl> + continue ; <nl> + EnumValue = RCIA - > getRCIdentityRoot ( EnumValue ) ; <nl> + EnumBBCaseList & Map = P - > second ; <nl> + <nl> + / / If we do not have a tag associated with this enum value for each <nl> + / / predecessor , we are not a switch region exit for this enum value . Skip <nl> + / / this value . <nl> + if ( Map . size ( ) ! = NumPreds ) <nl> + continue ; <nl> + <nl> + / / Look through our predecessors for a set of ref count increments on our <nl> + / / enum value for every payloaded case that * could * be sunk . If we miss an <nl> + / / increment from any of the payloaded case there is nothing we can do here , <nl> + / / so skip this enum value . <nl> + if ( ! findRetainsSinkableFromSwitchRegionForEnum ( AA , RCIA , EnumValue , Map , <nl> + DeleteList ) ) <nl> + continue ; <nl> + <nl> + / / If we do not have any payload arguments , then we should have an empty <nl> + / / delete list and there is nothing to do here . <nl> + if ( DeleteList . empty ( ) ) <nl> + continue ; <nl> + <nl> + / / Ok , we can perform this transformation ! Insert the new retain_value and <nl> + / / delete all of the ref count increments from the predecessor BBs . <nl> + / / <nl> + / / TODO : Which debug loc should we use here ? Using one of the locs from the <nl> + / / delete list seems reasonable for now . . . <nl> + SILBuilder Builder ( getBB ( ) - > begin ( ) ) ; <nl> + Builder . createRetainValue ( <nl> + DeleteList [ 0 ] - > getLoc ( ) , EnumValue , <nl> + cast < RefCountingInst > ( DeleteList [ 0 ] ) - > getAtomicity ( ) ) ; <nl> + for ( auto * I : DeleteList ) <nl> + I - > eraseFromParent ( ) ; <nl> + + + NumSunk ; <nl> + Changed = true ; <nl> } <nl> <nl> - / / If the retain value ' s argument is not the switch ' s argument , we can ' t do <nl> - / / anything with our simplistic analysis . . . bail . . . <nl> - if ( RCIA - > getRCIdentityRoot ( Ptr ) ! = <nl> - RCIA - > getRCIdentityRoot ( Switch - > getOperand ( ) ) ) <nl> - return false ; <nl> + return Changed ; <nl> + } <nl> <nl> - / / If S has a default case bail since the default case could represent <nl> - / / multiple cases . <nl> - / / <nl> - / / TODO : I am currently just disabling this behavior so we can get this out <nl> - / / for Seed 5 . After Seed 5 , we should be able to recognize if a switch_enum <nl> - / / handles all cases except for 1 and has a default case . We might be able to <nl> - / / stick code into SILBuilder that has this behavior . <nl> - if ( Switch - > hasDefault ( ) ) <nl> - return false ; <nl> + void BBEnumTagDataflowState : : dump ( ) const { <nl> + # ifndef NDEBUG <nl> + llvm : : dbgs ( ) < < " Dumping state for BB " < < BB . get ( ) - > getDebugID ( ) < < " \ n " ; <nl> + llvm : : dbgs ( ) < < " Block States : \ n " ; <nl> + for ( auto & P : ValueToCaseMap ) { <nl> + if ( ! P . hasValue ( ) ) { <nl> + llvm : : dbgs ( ) < < " Skipping blotted value . \ n " ; <nl> + continue ; <nl> + } <nl> + unsigned ID = P - > first ; <nl> + SILValue V = getContext ( ) . getValueForID ( ID ) ; <nl> + if ( ! V ) { <nl> + llvm : : dbgs ( ) < < " ID : " < < ID < < " . Value : BLOTTED . \ n " ; <nl> + continue ; <nl> + } <nl> + llvm : : dbgs ( ) < < " ID : " < < ID < < " . Value : " < < V ; <nl> + } <nl> <nl> - / / Ok , we have a ref count instruction , sink it ! <nl> - SILBuilderWithScope Builder ( Switch , & * RV ) ; <nl> - for ( unsigned i = 0 , e = Switch - > getNumCases ( ) ; i ! = e ; + + i ) { <nl> - auto Case = Switch - > getCase ( i ) ; <nl> - EnumElementDecl * Enum = Case . first ; <nl> - SILBasicBlock * Succ = Case . second ; <nl> - Builder . setInsertionPoint ( & * Succ - > begin ( ) ) ; <nl> - if ( Enum - > hasAssociatedValues ( ) ) <nl> - createRefCountOpForPayload ( Builder , & * RV , Enum , Switch - > getOperand ( ) ) ; <nl> + llvm : : dbgs ( ) < < " Predecessor States : \ n " ; <nl> + / / For each ( EnumValue , [ ( BB , EnumTag ) ] ) that we are tracking . . . <nl> + for ( auto & P : EnumToEnumBBCaseListMap ) { <nl> + if ( ! P . hasValue ( ) ) { <nl> + llvm : : dbgs ( ) < < " Skipping blotted value . \ n " ; <nl> + continue ; <nl> + } <nl> + unsigned ID = P - > first ; <nl> + SILValue V = getContext ( ) . getValueForID ( ID ) ; <nl> + if ( ! V ) { <nl> + llvm : : dbgs ( ) < < " ID : " < < ID < < " . Value : BLOTTED . \ n " ; <nl> + continue ; <nl> + } <nl> + llvm : : dbgs ( ) < < " ID : " < < ID < < " . Value : " < < V ; <nl> + llvm : : dbgs ( ) < < " Case List : \ n " ; <nl> + for ( auto & P2 : P - > second ) { <nl> + llvm : : dbgs ( ) < < " BB " < < P2 . first - > getDebugID ( ) < < " : " ; <nl> + P2 . second - > dump ( llvm : : dbgs ( ) ) ; <nl> + llvm : : dbgs ( ) < < " \ n " ; <nl> + } <nl> + llvm : : dbgs ( ) < < " End Case List . \ n " ; <nl> } <nl> + # endif <nl> + } <nl> <nl> - RV - > eraseFromParent ( ) ; <nl> - NumSunk + + ; <nl> + bool BBEnumTagDataflowState : : init ( EnumCaseDataflowContext & NewContext , <nl> + SILBasicBlock * NewBB ) { <nl> + assert ( NewBB & & " NewBB should not be null " ) ; <nl> + Context = & NewContext ; <nl> + BB = NewBB ; <nl> return true ; <nl> } <nl> <nl> - / / / Sink retain_value , release_value before select_enum to be retain_value , <nl> - / / / release_value on the payload of the switch_enum in the destination BBs . We <nl> - / / / only do this if the destination BBs have only the switch enum as its <nl> - / / / predecessor . <nl> - static bool tryToSinkRefCountAcrossSelectEnum ( CondBranchInst * CondBr , <nl> - SILBasicBlock : : iterator I , <nl> - AliasAnalysis * AA , <nl> - RCIdentityFunctionInfo * RCIA ) { <nl> - / / If this instruction is not a retain_value , there is nothing left for us to <nl> - / / do . . . bail . . . <nl> - if ( ! isa < RetainValueInst > ( I ) ) <nl> - return false ; <nl> - <nl> - / / Make sure the condition comes from a select_enum <nl> - auto * SEI = dyn_cast < SelectEnumInst > ( CondBr - > getCondition ( ) ) ; <nl> - if ( ! SEI ) <nl> - return false ; <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + / / Generic Sinking Code <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> <nl> - / / Try to find a single literal " true " case . <nl> - / / TODO : More general conditions in which we can relate the BB to a single <nl> - / / case , such as when there ' s a single literal " false " case . <nl> - NullablePtr < EnumElementDecl > TrueElement = SEI - > getSingleTrueElement ( ) ; <nl> - if ( TrueElement . isNull ( ) ) <nl> + / / / \ brief Hoist release on a SILArgument to its predecessors . <nl> + static bool hoistSILArgumentReleaseInst ( SILBasicBlock * BB ) { <nl> + / / There is no block to hoist releases to . <nl> + if ( BB - > pred_empty ( ) ) <nl> return false ; <nl> - <nl> - / / Next go over all instructions after I in the basic block . If none of them <nl> - / / can decrement our ptr value , we can move the retain over the ref count <nl> - / / inst . If any of them do potentially decrement the ref count of Ptr , we can <nl> - / / not move it . <nl> <nl> - SILValue Ptr = I - > getOperand ( 0 ) ; <nl> - auto CondBrIter = CondBr - > getIterator ( ) ; <nl> - if ( auto B = valueHasARCDecrementOrCheckInInstructionRange ( Ptr , std : : next ( I ) , <nl> - CondBrIter , AA ) ) { <nl> - I - > moveBefore ( & * * B ) ; <nl> + / / Only try to hoist the first instruction . RRCM should have hoisted the <nl> + / / release <nl> + / / to the beginning of the block if it can . <nl> + auto Head = & * BB - > begin ( ) ; <nl> + / / Make sure it is a release instruction . <nl> + if ( ! isReleaseInstruction ( & * Head ) ) <nl> return false ; <nl> - } <nl> <nl> - / / If the retain value ' s argument is not the cond_br ' s argument , we can ' t do <nl> - / / anything with our simplistic analysis . . . bail . . . <nl> - if ( RCIA - > getRCIdentityRoot ( Ptr ) ! = <nl> - RCIA - > getRCIdentityRoot ( SEI - > getEnumOperand ( ) ) ) <nl> - return false ; <nl> - <nl> - / / Work out which enum element is the true branch , and which is false . <nl> - / / If the enum only has 2 values and its tag isn ' t the true branch , then we <nl> - / / know the true branch must be the other tag . <nl> - EnumElementDecl * Elts [ 2 ] = { TrueElement . get ( ) , nullptr } ; <nl> - EnumDecl * E = SEI - > getEnumOperand ( ) - > getType ( ) . getEnumOrBoundGenericEnum ( ) ; <nl> - if ( ! E ) <nl> + / / Make sure it is a release on a SILArgument of the current basic block . . <nl> + auto * SA = dyn_cast < SILArgument > ( Head - > getOperand ( 0 ) ) ; <nl> + if ( ! SA | | SA - > getParent ( ) ! = BB ) <nl> return false ; <nl> <nl> - / / Look for a single other element on this enum . <nl> - EnumElementDecl * OtherElt = nullptr ; <nl> - for ( EnumElementDecl * Elt : E - > getAllElements ( ) ) { <nl> - / / Skip the case where we find the select_enum element <nl> - if ( Elt = = TrueElement . get ( ) ) <nl> - continue ; <nl> - / / If we find another element , then we must have more than 2 , so bail . <nl> - if ( OtherElt ) <nl> + / / Make sure the release will not be blocked by the terminator instructions <nl> + / / Make sure the terminator does not block , nor is a branch with multiple <nl> + / / targets . <nl> + for ( auto P : BB - > getPredecessorBlocks ( ) ) { <nl> + if ( ! isa < BranchInst > ( P - > getTerminator ( ) ) ) <nl> return false ; <nl> - OtherElt = Elt ; <nl> } <nl> - / / Only a single enum element ? How would this even get here ? We should <nl> - / / handle it in SILCombine . <nl> - if ( ! OtherElt ) <nl> - return false ; <nl> <nl> - Elts [ 1 ] = OtherElt ; <nl> - <nl> - SILBuilderWithScope Builder ( SEI , & * I ) ; <nl> + / / Make sure we can get all the incoming values . <nl> + llvm : : SmallVector < SILValue , 4 > PredValues ; <nl> + if ( ! SA - > getIncomingValues ( PredValues ) ) <nl> + return false ; <nl> <nl> - / / Ok , we have a ref count instruction , sink it ! <nl> - for ( unsigned i = 0 ; i ! = 2 ; + + i ) { <nl> - EnumElementDecl * Enum = Elts [ i ] ; <nl> - SILBasicBlock * Succ = i = = 0 ? CondBr - > getTrueBB ( ) : CondBr - > getFalseBB ( ) ; <nl> - Builder . setInsertionPoint ( & * Succ - > begin ( ) ) ; <nl> - if ( Enum - > hasAssociatedValues ( ) ) <nl> - createRefCountOpForPayload ( Builder , & * I , Enum , SEI - > getEnumOperand ( ) ) ; <nl> + / / Ok , we can get all the incoming values and create releases for them . <nl> + unsigned indices = 0 ; <nl> + for ( auto P : BB - > getPredecessorBlocks ( ) ) { <nl> + createDecrementBefore ( PredValues [ indices + + ] , P - > getTerminator ( ) ) ; <nl> } <nl> - <nl> - I - > eraseFromParent ( ) ; <nl> - NumSunk + + ; <nl> + / / Erase the old instruction . <nl> + Head - > eraseFromParent ( ) ; <nl> + + + NumSILArgumentReleaseHoisted ; <nl> return true ; <nl> } <nl> <nl> - static bool tryTosinkIncrementsIntoSwitchRegions ( SILBasicBlock : : iterator T , <nl> - SILBasicBlock : : iterator I , <nl> - bool CanSinkToSuccessors , <nl> - AliasAnalysis * AA , <nl> - RCIdentityFunctionInfo * RCIA ) { <nl> - / / The following methods should only be attempted if we can sink to our <nl> - / / successor . <nl> - if ( CanSinkToSuccessors ) { <nl> - / / If we have a switch , try to sink ref counts across it and then return <nl> - / / that result . We do not keep processing since the code below cannot <nl> - / / properly sink ref counts over switch_enums so we might as well exit <nl> - / / early . <nl> - if ( auto * S = dyn_cast < SwitchEnumInst > ( T ) ) <nl> - return tryToSinkRefCountAcrossSwitch ( S , I , AA , RCIA ) ; <nl> - <nl> - / / In contrast , even if we do not sink ref counts across a cond_br from a <nl> - / / select_enum , we may be able to sink anyways . So we do not return on a <nl> - / / failure case . <nl> - if ( auto * CondBr = dyn_cast < CondBranchInst > ( T ) ) <nl> - if ( tryToSinkRefCountAcrossSelectEnum ( CondBr , I , AA , RCIA ) ) <nl> - return true ; <nl> - } <nl> + static const int SinkSearchWindow = 6 ; <nl> <nl> - / / At this point , this is a retain on a regular SSA value , leave it to retain <nl> - / / release code motion to sink . <nl> - return false ; <nl> + / / / \ brief Returns True if we can sink this instruction to another basic block . <nl> + static bool canSinkInstruction ( SILInstruction * Inst ) { <nl> + return ! Inst - > hasUsesOfAnyResult ( ) & & ! isa < TermInst > ( Inst ) ; <nl> } <nl> <nl> - / / / Try sink a retain as far as possible . This is either to successor BBs , <nl> - / / / or as far down the current BB as possible <nl> - static bool sinkIncrementsIntoSwitchRegions ( SILBasicBlock * BB , AliasAnalysis * AA , <nl> - RCIdentityFunctionInfo * RCIA ) { <nl> - / / Make sure that each one of our successors only has one predecessor , <nl> - / / us . <nl> - / / If that condition is not true , we can still sink to the end of this BB , <nl> - / / but not to successors . <nl> - bool CanSinkToSuccessor = std : : none_of ( BB - > succ_begin ( ) , BB - > succ_end ( ) , <nl> - [ ] ( const SILSuccessor & S ) - > bool { <nl> - SILBasicBlock * SuccBB = S . getBB ( ) ; <nl> - return ! SuccBB | | ! SuccBB - > getSinglePredecessorBlock ( ) ; <nl> - } ) ; <nl> - <nl> - SILInstruction * S = BB - > getTerminator ( ) ; <nl> - auto SI = S - > getIterator ( ) , SE = BB - > begin ( ) ; <nl> - if ( SI = = SE ) <nl> + / / / \ brief Returns true if this instruction is a skip barrier , which means that <nl> + / / / we can ' t sink other instructions past it . <nl> + static bool isSinkBarrier ( SILInstruction * Inst ) { <nl> + if ( isa < TermInst > ( Inst ) ) <nl> return false ; <nl> <nl> - bool Changed = false ; <nl> - <nl> - / / Walk from the terminator up the BB . Try move retains either to the next <nl> - / / BB , or the end of this BB . Note that ordering is maintained of retains <nl> - / / within this BB . <nl> - SI = std : : prev ( SI ) ; <nl> - while ( SI ! = SE ) { <nl> - SILInstruction * Inst = & * SI ; <nl> - SI = std : : prev ( SI ) ; <nl> - <nl> - / / Try to : <nl> - / / <nl> - / / 1 . If there are no decrements between our ref count inst and <nl> - / / terminator , sink the ref count inst into either our successors . <nl> - / / 2 . If there are such decrements , move the retain right before that <nl> - / / decrement . <nl> - Changed | = tryTosinkIncrementsIntoSwitchRegions ( S - > getIterator ( ) , <nl> - Inst - > getIterator ( ) , <nl> - CanSinkToSuccessor , <nl> - AA , RCIA ) ; <nl> - } <nl> + if ( Inst - > mayHaveSideEffects ( ) ) <nl> + return true ; <nl> <nl> - / / Handle the first instruction in the BB . <nl> - Changed | = <nl> - tryTosinkIncrementsIntoSwitchRegions ( S - > getIterator ( ) , SI , <nl> - CanSinkToSuccessor , AA , RCIA ) ; <nl> - return Changed ; <nl> + return false ; <nl> } <nl> <nl> - / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> - / / Enum Tag Dataflow <nl> - / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> - <nl> - namespace { <nl> + using ValueInBlock = std : : pair < SILValue , SILBasicBlock * > ; <nl> + using ValueToBBArgIdxMap = llvm : : DenseMap < ValueInBlock , int > ; <nl> <nl> - class BBToDataflowStateMap ; <nl> + enum OperandRelation { <nl> + / / / Uninitialized state . <nl> + NotDeterminedYet , <nl> <nl> - using EnumBBCaseList = llvm : : SmallVector < std : : pair < SILBasicBlock * , <nl> - EnumElementDecl * > , 2 > ; <nl> + / / / The original operand values are equal . <nl> + AlwaysEqual , <nl> <nl> - / / / Class that performs enum tag state dataflow on the given BB . <nl> - class BBEnumTagDataflowState <nl> - : public SILInstructionVisitor < BBEnumTagDataflowState , bool > { <nl> - NullablePtr < SILBasicBlock > BB ; <nl> + / / / The operand values are equal after replacing with the successor block <nl> + / / / arguments . <nl> + EqualAfterMove <nl> + } ; <nl> <nl> - using ValueToCaseSmallBlotMapVectorTy = <nl> - SmallBlotMapVector < SILValue , EnumElementDecl * , 4 > ; <nl> - ValueToCaseSmallBlotMapVectorTy ValueToCaseMap ; <nl> + / / / \ brief Find a root value for operand \ p In . This function inspects a sil <nl> + / / / value and strips trivial conversions such as values that are passed <nl> + / / / as arguments to basic blocks with a single predecessor or type casts . <nl> + / / / This is a shallow one - step search and not a deep recursive search . <nl> + / / / <nl> + / / / For example , in the SIL code below , the root of % 10 is % 3 , because it is <nl> + / / / the only possible incoming value . <nl> + / / / <nl> + / / / bb1 : <nl> + / / / % 3 = unchecked_enum_data % 0 : $ Optional < X > , # Optional . Some ! enumelt . 1 <nl> + / / / checked_cast_br [ exact ] % 3 : $ X to $ X , bb4 , bb5 / / id : % 4 <nl> + / / / <nl> + / / / bb4 ( % 10 : $ X ) : / / Preds : bb1 <nl> + / / / strong_release % 10 : $ X <nl> + / / / br bb2 <nl> + / / / <nl> + static SILValue findValueShallowRoot ( const SILValue & In ) { <nl> + / / If this is a basic block argument with a single caller <nl> + / / then we know exactly which value is passed to the argument . <nl> + if ( auto * Arg = dyn_cast < SILArgument > ( In ) ) { <nl> + SILBasicBlock * Parent = Arg - > getParent ( ) ; <nl> + SILBasicBlock * Pred = Parent - > getSinglePredecessorBlock ( ) ; <nl> + if ( ! Pred ) <nl> + return In ; <nl> <nl> - using EnumToEnumBBCaseListMapTy = <nl> - SmallBlotMapVector < SILValue , EnumBBCaseList , 4 > ; <nl> + / / If the terminator is a cast instruction then use the pre - cast value . <nl> + if ( auto CCBI = dyn_cast < CheckedCastBranchInst > ( Pred - > getTerminator ( ) ) ) { <nl> + assert ( CCBI - > getSuccessBB ( ) = = Parent & & " Inspecting the wrong block " ) ; <nl> <nl> - EnumToEnumBBCaseListMapTy EnumToEnumBBCaseListMap ; <nl> + / / In swift it is legal to cast non reference - counted references into <nl> + / / object references . For example : func f ( x : C . Type ) - > Any { return x } <nl> + / / Here we check that the uncasted reference is reference counted . <nl> + SILValue V = CCBI - > getOperand ( ) ; <nl> + if ( V - > getType ( ) . isReferenceCounted ( Pred - > getParent ( ) - > getModule ( ) ) ) { <nl> + return V ; <nl> + } <nl> + } <nl> <nl> - public : <nl> - BBEnumTagDataflowState ( ) = default ; <nl> - BBEnumTagDataflowState ( const BBEnumTagDataflowState & Other ) = default ; <nl> - ~ BBEnumTagDataflowState ( ) = default ; <nl> + / / If the single predecessor terminator is a branch then the root is <nl> + / / the argument to the terminator . <nl> + if ( auto BI = dyn_cast < BranchInst > ( Pred - > getTerminator ( ) ) ) { <nl> + assert ( BI - > getDestBB ( ) = = Parent & & " Invalid terminator " ) ; <nl> + unsigned Idx = Arg - > getIndex ( ) ; <nl> + return BI - > getArg ( Idx ) ; <nl> + } <nl> <nl> - bool init ( SILBasicBlock * NewBB ) { <nl> - assert ( NewBB & & " NewBB should not be null " ) ; <nl> - BB = NewBB ; <nl> - return true ; <nl> + if ( auto CBI = dyn_cast < CondBranchInst > ( Pred - > getTerminator ( ) ) ) { <nl> + return CBI - > getArgForDestBB ( Parent , Arg ) ; <nl> + } <nl> } <nl> + return In ; <nl> + } <nl> <nl> - SILBasicBlock * getBB ( ) { return BB . get ( ) ; } <nl> - <nl> - using iterator = decltype ( ValueToCaseMap ) : : iterator ; <nl> - iterator begin ( ) { return ValueToCaseMap . getItems ( ) . begin ( ) ; } <nl> - iterator end ( ) { return ValueToCaseMap . getItems ( ) . begin ( ) ; } <nl> + / / / \ brief Search for an instruction that is identical to \ p Iden by scanning <nl> + / / / \ p BB starting at the end of the block , stopping on sink barriers . <nl> + / / / The \ p opRelation must be consistent for all operand comparisons . <nl> + SILInstruction * findIdenticalInBlock ( SILBasicBlock * BB , SILInstruction * Iden , <nl> + const ValueToBBArgIdxMap & valueToArgIdxMap , <nl> + OperandRelation & opRelation ) { <nl> + int SkipBudget = SinkSearchWindow ; <nl> <nl> - void clear ( ) { ValueToCaseMap . clear ( ) ; } <nl> + SILBasicBlock : : iterator InstToSink = BB - > getTerminator ( ) - > getIterator ( ) ; <nl> + SILBasicBlock * IdenBlock = Iden - > getParent ( ) ; <nl> <nl> - bool visitSILInstruction ( SILInstruction * I ) { return false ; } <nl> + / / The compare function for instruction operands . <nl> + auto operandCompare = [ & ] ( const SILValue & Op1 , const SILValue & Op2 ) - > bool { <nl> <nl> - bool visitEnumInst ( EnumInst * EI ) { <nl> - DEBUG ( llvm : : dbgs ( ) < < " Storing enum into map : " < < * EI ) ; <nl> - ValueToCaseMap [ SILValue ( EI ) ] = EI - > getElement ( ) ; <nl> - return false ; <nl> - } <nl> + if ( opRelation ! = EqualAfterMove & & Op1 = = Op2 ) { <nl> + / / The trivial case . <nl> + opRelation = AlwaysEqual ; <nl> + return true ; <nl> + } <nl> <nl> - bool visitUncheckedEnumDataInst ( UncheckedEnumDataInst * UEDI ) { <nl> - DEBUG ( <nl> - llvm : : dbgs ( ) < < " Storing unchecked enum data into map : " < < * UEDI ) ; <nl> - ValueToCaseMap [ SILValue ( UEDI - > getOperand ( ) ) ] = UEDI - > getElement ( ) ; <nl> + / / Check if both operand values are passed to the same block argument in the <nl> + / / successor block . This means that the operands are equal after we move the <nl> + / / instruction into the successor block . <nl> + if ( opRelation ! = AlwaysEqual ) { <nl> + auto Iter1 = valueToArgIdxMap . find ( { Op1 , IdenBlock } ) ; <nl> + if ( Iter1 ! = valueToArgIdxMap . end ( ) ) { <nl> + auto Iter2 = valueToArgIdxMap . find ( { Op2 , BB } ) ; <nl> + if ( Iter2 ! = valueToArgIdxMap . end ( ) & & Iter1 - > second = = Iter2 - > second ) { <nl> + opRelation = EqualAfterMove ; <nl> + return true ; <nl> + } <nl> + } <nl> + } <nl> return false ; <nl> - } <nl> + } ; <nl> <nl> - bool visitRetainValueInst ( RetainValueInst * RVI ) ; <nl> - bool visitReleaseValueInst ( ReleaseValueInst * RVI ) ; <nl> - bool process ( ) ; <nl> - bool hoistDecrementsIntoSwitchRegions ( AliasAnalysis * AA ) ; <nl> - bool sinkIncrementsOutOfSwitchRegions ( AliasAnalysis * AA , <nl> - RCIdentityFunctionInfo * RCIA ) ; <nl> - void handlePredSwitchEnum ( SwitchEnumInst * S ) ; <nl> - void handlePredCondSelectEnum ( CondBranchInst * CondBr ) ; <nl> + while ( SkipBudget ) { <nl> + / / If we found a sinkable instruction that is identical to our goal <nl> + / / then return it . <nl> + if ( canSinkInstruction ( & * InstToSink ) & & <nl> + Iden - > isIdenticalTo ( & * InstToSink , operandCompare ) ) { <nl> + DEBUG ( llvm : : dbgs ( ) < < " Found an identical instruction . " ) ; <nl> + return & * InstToSink ; <nl> + } <nl> <nl> - / / / Helper method which initializes this state map with the data from the <nl> - / / / first predecessor BB . <nl> - / / / <nl> - / / / We will be performing an intersection in a later step of the merging . <nl> - bool initWithFirstPred ( BBToDataflowStateMap & BBToStateMap , <nl> - SILBasicBlock * FirstPredBB ) ; <nl> + / / If this instruction is a skip - barrier end the scan . <nl> + if ( isSinkBarrier ( & * InstToSink ) ) <nl> + return nullptr ; <nl> <nl> - / / / Top level merging function for predecessors . <nl> - void mergePredecessorStates ( BBToDataflowStateMap & BBToStateMap ) ; <nl> + / / If this is the first instruction in the block then we are done . <nl> + if ( InstToSink = = BB - > begin ( ) ) <nl> + return nullptr ; <nl> <nl> - / / / <nl> - void mergeSinglePredTermInfoIntoState ( BBToDataflowStateMap & BBToStateMap , <nl> - SILBasicBlock * Pred ) ; <nl> + SkipBudget - - ; <nl> + InstToSink = std : : prev ( InstToSink ) ; <nl> + DEBUG ( llvm : : dbgs ( ) < < " Continuing scan . Next inst : " < < * InstToSink ) ; <nl> + } <nl> <nl> - } ; <nl> + return nullptr ; <nl> + } <nl> <nl> - / / / Map all blocks to BBEnumTagDataflowState in RPO order . <nl> - class BBToDataflowStateMap { <nl> - PostOrderFunctionInfo * PO ; <nl> - std : : vector < BBEnumTagDataflowState > BBToStateVec ; <nl> - public : <nl> - BBToDataflowStateMap ( PostOrderFunctionInfo * PO ) : PO ( PO ) , BBToStateVec ( ) { <nl> - BBToStateVec . resize ( PO - > size ( ) ) ; <nl> - unsigned RPOIdx = 0 ; <nl> - for ( SILBasicBlock * BB : PO - > getReversePostOrder ( ) ) { <nl> - BBToStateVec [ RPOIdx ] . init ( BB ) ; <nl> - + + RPOIdx ; <nl> - } <nl> - } <nl> - unsigned size ( ) const { <nl> - return BBToStateVec . size ( ) ; <nl> - } <nl> - BBEnumTagDataflowState & getRPOState ( unsigned RPOIdx ) { <nl> - return BBToStateVec [ RPOIdx ] ; <nl> - } <nl> - / / / \ return BBEnumTagDataflowState or NULL for unreachable blocks . <nl> - BBEnumTagDataflowState * getBBState ( SILBasicBlock * BB ) { <nl> - if ( auto ID = PO - > getRPONumber ( BB ) ) { <nl> - return & getRPOState ( * ID ) ; <nl> - } <nl> - return nullptr ; <nl> + / / / The 2 instructions given are not identical , but are passed as arguments <nl> + / / / to a common successor . It may be cheaper to pass one of their operands <nl> + / / / to the successor instead of the whole instruction . <nl> + / / / Return None if no such operand could be found , otherwise return the index <nl> + / / / of a suitable operand . <nl> + static llvm : : Optional < unsigned > <nl> + cheaperToPassOperandsAsArguments ( SILInstruction * First , <nl> + SILInstruction * Second ) { <nl> + / / This will further enable to sink strong_retain_unowned instructions , <nl> + / / which provides more opportunities for the unowned - optimization in <nl> + / / LLVMARCOpts . <nl> + auto * UTORI1 = dyn_cast < UnownedToRefInst > ( First ) ; <nl> + auto * UTORI2 = dyn_cast < UnownedToRefInst > ( Second ) ; <nl> + if ( UTORI1 & & UTORI2 ) { <nl> + return 0 ; <nl> } <nl> - } ; <nl> <nl> - } / / end anonymous namespace <nl> + / / TODO : Add more cases than Struct <nl> + auto * FirstStruct = dyn_cast < StructInst > ( First ) ; <nl> + auto * SecondStruct = dyn_cast < StructInst > ( Second ) ; <nl> <nl> - void BBEnumTagDataflowState : : handlePredSwitchEnum ( SwitchEnumInst * S ) { <nl> + if ( ! FirstStruct | | ! SecondStruct ) <nl> + return None ; <nl> <nl> - / / Find the tag associated with our BB and set the state of the <nl> - / / enum we switch on to that value . This is important so we can determine <nl> - / / covering switches for enums that have cases without payload . <nl> + assert ( FirstStruct - > getNumOperands ( ) = = SecondStruct - > getNumOperands ( ) & & <nl> + FirstStruct - > getType ( ) = = SecondStruct - > getType ( ) & & <nl> + " Types should be identical " ) ; <nl> <nl> - / / Next check if we are the target of a default switch_enum case . If we are , <nl> - / / no interesting information can be extracted , so bail . . . <nl> - if ( S - > hasDefault ( ) & & S - > getDefaultBB ( ) = = getBB ( ) ) <nl> - return ; <nl> + llvm : : Optional < unsigned > DifferentOperandIndex ; <nl> <nl> - / / Otherwise , attempt to find the tag associated with this BB in the switch <nl> - / / enum . . . <nl> - for ( unsigned i = 0 , e = S - > getNumCases ( ) ; i ! = e ; + + i ) { <nl> - auto P = S - > getCase ( i ) ; <nl> - <nl> - / / If this case of the switch is not matched up with this BB , skip the <nl> - / / case . . . <nl> - if ( P . second ! = getBB ( ) ) <nl> - continue ; <nl> - <nl> - / / Ok , we found the case for our BB . If we don ' t have an enum tag ( which can <nl> - / / happen if we have a default statement ) , return . There is nothing more we <nl> - / / can do . <nl> - if ( ! P . first ) <nl> - return ; <nl> - <nl> - / / Ok , we have a matching BB and a matching enum tag . Set the state and <nl> - / / return . <nl> - ValueToCaseMap [ S - > getOperand ( ) ] = P . first ; <nl> - return ; <nl> + / / Check operands . <nl> + for ( unsigned i = 0 , e = First - > getNumOperands ( ) ; i ! = e ; + + i ) { <nl> + if ( FirstStruct - > getOperand ( i ) ! = SecondStruct - > getOperand ( i ) ) { <nl> + / / Only track one different operand for now <nl> + if ( DifferentOperandIndex ) <nl> + return None ; <nl> + DifferentOperandIndex = i ; <nl> + } <nl> } <nl> - llvm_unreachable ( " A successor of a switch_enum terminated BB should be in " <nl> - " the switch_enum . " ) ; <nl> - } <nl> <nl> - void BBEnumTagDataflowState : : handlePredCondSelectEnum ( CondBranchInst * CondBr ) { <nl> + if ( ! DifferentOperandIndex ) <nl> + return None ; <nl> <nl> - auto * EITI = dyn_cast < SelectEnumInst > ( CondBr - > getCondition ( ) ) ; <nl> - if ( ! EITI ) <nl> - return ; <nl> + / / Found a different operand , now check to see if its type is something <nl> + / / cheap enough to sink . <nl> + / / TODO : Sink more than just integers . <nl> + SILType ArgTy = FirstStruct - > getOperand ( * DifferentOperandIndex ) - > getType ( ) ; <nl> + if ( ! ArgTy . is < BuiltinIntegerType > ( ) ) <nl> + return None ; <nl> <nl> - NullablePtr < EnumElementDecl > TrueElement = EITI - > getSingleTrueElement ( ) ; <nl> - if ( TrueElement . isNull ( ) ) <nl> - return ; <nl> + return * DifferentOperandIndex ; <nl> + } <nl> <nl> - / / Find the tag associated with our BB and set the state of the <nl> - / / enum we switch on to that value . This is important so we can determine <nl> - / / covering switches for enums that have cases without payload . <nl> + / / / Return the value that ' s passed from block \ p From to block \ p To <nl> + / / / ( if there is a branch between From and To ) as the Nth argument . <nl> + SILValue getArgForBlock ( SILBasicBlock * From , SILBasicBlock * To , <nl> + unsigned ArgNum ) { <nl> + TermInst * Term = From - > getTerminator ( ) ; <nl> + if ( auto * CondBr = dyn_cast < CondBranchInst > ( Term ) ) { <nl> + if ( CondBr - > getFalseBB ( ) = = To ) <nl> + return CondBr - > getFalseArgs ( ) [ ArgNum ] ; <nl> <nl> - / / Check if we are the true case , ie , we know that we are the given tag . <nl> - const auto & Operand = EITI - > getEnumOperand ( ) ; <nl> - if ( CondBr - > getTrueBB ( ) = = getBB ( ) ) { <nl> - ValueToCaseMap [ Operand ] = TrueElement . get ( ) ; <nl> - return ; <nl> + if ( CondBr - > getTrueBB ( ) = = To ) <nl> + return CondBr - > getTrueArgs ( ) [ ArgNum ] ; <nl> } <nl> <nl> - / / If the enum only has 2 values and its tag isn ' t the true branch , then we <nl> - / / know the true branch must be the other tag . <nl> - if ( EnumDecl * E = Operand - > getType ( ) . getEnumOrBoundGenericEnum ( ) ) { <nl> - / / Look for a single other element on this enum . <nl> - EnumElementDecl * OtherElt = nullptr ; <nl> - for ( EnumElementDecl * Elt : E - > getAllElements ( ) ) { <nl> - / / Skip the case where we find the select_enum element <nl> - if ( Elt = = TrueElement . get ( ) ) <nl> - continue ; <nl> - / / If we find another element , then we must have more than 2 , so bail . <nl> - if ( OtherElt ) <nl> - return ; <nl> - OtherElt = Elt ; <nl> - } <nl> - / / Only a single enum element ? How would this even get here ? We should <nl> - / / handle it in SILCombine . <nl> - if ( ! OtherElt ) <nl> - return ; <nl> - / / FIXME : Can we ever not be the false BB here ? <nl> - if ( CondBr - > getTrueBB ( ) ! = getBB ( ) ) { <nl> - ValueToCaseMap [ Operand ] = OtherElt ; <nl> - return ; <nl> - } <nl> - } <nl> + if ( auto * Br = dyn_cast < BranchInst > ( Term ) ) <nl> + return Br - > getArg ( ArgNum ) ; <nl> + <nl> + return SILValue ( ) ; <nl> } <nl> <nl> - bool <nl> - BBEnumTagDataflowState : : <nl> - initWithFirstPred ( BBToDataflowStateMap & BBToStateMap , <nl> - SILBasicBlock * FirstPredBB ) { <nl> - / / Try to look up the state for the first pred BB . <nl> - BBEnumTagDataflowState * FirstPredState = BBToStateMap . getBBState ( FirstPredBB ) ; <nl> + / / Try to sink values from the Nth argument \ p ArgNum . <nl> + static bool sinkLiteralArguments ( SILBasicBlock * BB , unsigned ArgNum ) { <nl> + assert ( ArgNum < BB - > getNumArguments ( ) & & " Invalid argument " ) ; <nl> <nl> - / / If we fail , we found an unreachable block , bail . <nl> - if ( FirstPredState = = nullptr ) { <nl> - DEBUG ( llvm : : dbgs ( ) < < " Found an unreachable block ! \ n " ) ; <nl> + / / Check if the argument passed to the first predecessor is a literal inst . <nl> + SILBasicBlock * FirstPred = * BB - > pred_begin ( ) ; <nl> + SILValue FirstArg = getArgForBlock ( FirstPred , BB , ArgNum ) ; <nl> + LiteralInst * FirstLiteral = dyn_cast_or_null < LiteralInst > ( FirstArg ) ; <nl> + if ( ! FirstLiteral ) <nl> return false ; <nl> - } <nl> <nl> - / / Ok , our state is in the map , copy in the predecessors value to case map . <nl> - ValueToCaseMap = FirstPredState - > ValueToCaseMap ; <nl> + / / Check if the Nth argument in all predecessors is identical . <nl> + for ( auto P : BB - > getPredecessorBlocks ( ) ) { <nl> + if ( P = = FirstPred ) <nl> + continue ; <nl> <nl> - / / If we are predecessors only successor , we can potentially hoist releases <nl> - / / into it , so associate the first pred BB and the case for each value that we <nl> - / / are tracking with it . <nl> - / / <nl> - / / TODO : I am writing this too fast . Clean this up later . <nl> - if ( FirstPredBB - > getSingleSuccessorBlock ( ) ) { <nl> - for ( auto P : ValueToCaseMap . getItems ( ) ) { <nl> - if ( ! P . hasValue ( ) ) <nl> - continue ; <nl> - EnumToEnumBBCaseListMap [ P - > first ] . push_back ( { FirstPredBB , P - > second } ) ; <nl> - } <nl> + / / Check that the incoming value is identical to the first literal . <nl> + SILValue PredArg = getArgForBlock ( P , BB , ArgNum ) ; <nl> + LiteralInst * PredLiteral = dyn_cast_or_null < LiteralInst > ( PredArg ) ; <nl> + if ( ! PredLiteral | | ! PredLiteral - > isIdenticalTo ( FirstLiteral ) ) <nl> + return false ; <nl> } <nl> <nl> + / / Replace the use of the argument with the cloned literal . <nl> + auto Cloned = FirstLiteral - > clone ( & * BB - > begin ( ) ) ; <nl> + BB - > getArgument ( ArgNum ) - > replaceAllUsesWith ( Cloned ) ; <nl> + <nl> return true ; <nl> } <nl> <nl> - void <nl> - BBEnumTagDataflowState : : <nl> - mergeSinglePredTermInfoIntoState ( BBToDataflowStateMap & BBToStateMap , <nl> - SILBasicBlock * Pred ) { <nl> - / / Grab the terminator of our one predecessor and if it is a switch enum , mix <nl> - / / it into this state . <nl> - TermInst * PredTerm = Pred - > getTerminator ( ) ; <nl> - if ( auto * S = dyn_cast < SwitchEnumInst > ( PredTerm ) ) { <nl> - handlePredSwitchEnum ( S ) ; <nl> - return ; <nl> - } <nl> + / / Try to sink values from the Nth argument \ p ArgNum . <nl> + static bool sinkArgument ( EnumCaseDataflowContext & Context , SILBasicBlock * BB , unsigned ArgNum ) { <nl> + assert ( ArgNum < BB - > getNumArguments ( ) & & " Invalid argument " ) ; <nl> <nl> - auto * CondBr = dyn_cast < CondBranchInst > ( PredTerm ) ; <nl> - if ( ! CondBr ) <nl> - return ; <nl> + / / Find the first predecessor , the first terminator and the Nth argument . <nl> + SILBasicBlock * FirstPred = * BB - > pred_begin ( ) ; <nl> + TermInst * FirstTerm = FirstPred - > getTerminator ( ) ; <nl> + auto FirstPredArg = FirstTerm - > getOperand ( ArgNum ) ; <nl> + auto * FSI = dyn_cast < SingleValueInstruction > ( FirstPredArg ) ; <nl> + / / TODO : MultiValueInstruction ? <nl> <nl> - handlePredCondSelectEnum ( CondBr ) ; <nl> - } <nl> + / / We only move instructions with a single use . <nl> + if ( ! FSI | | ! hasOneNonDebugUse ( FSI ) ) <nl> + return false ; <nl> <nl> - void <nl> - BBEnumTagDataflowState : : <nl> - mergePredecessorStates ( BBToDataflowStateMap & BBToStateMap ) { <nl> + / / The list of identical instructions . <nl> + SmallVector < SingleValueInstruction * , 8 > Clones ; <nl> + Clones . push_back ( FSI ) ; <nl> <nl> - / / If we have no predecessors , there is nothing to do so return early . . . <nl> - if ( getBB ( ) - > pred_empty ( ) ) { <nl> - DEBUG ( llvm : : dbgs ( ) < < " No Preds . \ n " ) ; <nl> - return ; <nl> - } <nl> + / / Don ' t move instructions that are sensitive to their location . <nl> + / / <nl> + / / If this instruction can read memory , we try to be conservatively not to <nl> + / / move it , as there may be instructions that can clobber the read memory <nl> + / / from current place to the place where it is moved to . <nl> + if ( FSI - > mayReadFromMemory ( ) | | <nl> + ( FSI - > mayHaveSideEffects ( ) & & ! isa < AllocationInst > ( FSI ) ) ) <nl> + return false ; <nl> <nl> - auto PI = getBB ( ) - > pred_begin ( ) , PE = getBB ( ) - > pred_end ( ) ; <nl> - if ( * PI = = getBB ( ) ) { <nl> - DEBUG ( llvm : : dbgs ( ) < < " Found a self loop . Bailing ! \ n " ) ; <nl> - return ; <nl> - } <nl> + / / If the instructions are different , but only in terms of a cheap operand <nl> + / / then we can still sink it , and create new arguments for this operand . <nl> + llvm : : Optional < unsigned > DifferentOperandIndex ; <nl> <nl> - / / Grab the first predecessor BB . <nl> - SILBasicBlock * FirstPred = * PI ; <nl> - + + PI ; <nl> + / / Check if the Nth argument in all predecessors is identical . <nl> + for ( auto P : BB - > getPredecessorBlocks ( ) ) { <nl> + if ( P = = FirstPred ) <nl> + continue ; <nl> <nl> - / / Attempt to initialize our state with our first predecessor ' s state by just <nl> - / / copying . We will be doing an intersection with all of the other BB . <nl> - if ( ! initWithFirstPred ( BBToStateMap , FirstPred ) ) <nl> - return ; <nl> + / / Only handle branch or conditional branch instructions . <nl> + TermInst * TI = P - > getTerminator ( ) ; <nl> + if ( ! isa < BranchInst > ( TI ) & & ! isa < CondBranchInst > ( TI ) ) <nl> + return false ; <nl> <nl> - / / If we only have one predecessor see if we can gain any information and or <nl> - / / knowledge from the terminator of our one predecessor . There is nothing more <nl> - / / that we can do , return . <nl> - / / <nl> - / / This enables us to get enum information from switch_enum and cond_br about <nl> - / / the value that an enum can take in our block . This is a common case that <nl> - / / comes up . <nl> - if ( PI = = PE ) { <nl> - mergeSinglePredTermInfoIntoState ( BBToStateMap , FirstPred ) ; <nl> - return ; <nl> - } <nl> + / / Find the Nth argument passed to BB . <nl> + SILValue Arg = TI - > getOperand ( ArgNum ) ; <nl> <nl> - DEBUG ( llvm : : dbgs ( ) < < " Merging in rest of predecessors . . . \ n " ) ; <nl> + / / If it ' s not the same basic kind of node , neither isIdenticalTo nor <nl> + / / cheaperToPassOperandsAsArguments will return true . <nl> + if ( Arg - > getKind ( ) ! = FSI - > getValueKind ( ) ) <nl> + return false ; <nl> <nl> - / / Enum values that while merging we found conflicting values for . We blot <nl> - / / them after the loop in order to ensure that we can still find the ends of <nl> - / / switch regions . <nl> - llvm : : SmallVector < SILValue , 4 > CurBBValuesToBlot ; <nl> + / / Since it ' s the same kind , Arg must also be a single - value instruction . <nl> + auto * SI = cast < SingleValueInstruction > ( Arg ) ; <nl> <nl> - / / If we do not find state for a specific value in any of our predecessor BBs , <nl> - / / we cannot be the end of a switch region since we cannot cover our <nl> - / / predecessor BBs with enum decls . Blot after the loop . <nl> - llvm : : SmallVector < SILValue , 4 > PredBBValuesToBlot ; <nl> + if ( ! hasOneNonDebugUse ( SI ) ) <nl> + return false ; <nl> <nl> - / / And for each remaining predecessor . . . <nl> - do { <nl> - / / If we loop on ourselves , bail . . . <nl> - if ( * PI = = getBB ( ) ) { <nl> - DEBUG ( llvm : : dbgs ( ) < < " Found a self loop . Bailing ! \ n " ) ; <nl> - return ; <nl> + if ( SI - > isIdenticalTo ( FSI ) ) { <nl> + Clones . push_back ( SI ) ; <nl> + continue ; <nl> } <nl> <nl> - / / Grab the predecessors state . . . <nl> - SILBasicBlock * PredBB = * PI ; <nl> + / / If the instructions are close enough , then we should sink them anyway . <nl> + / / For example , we should sink ' struct S ( % 0 ) ' if % 0 is small , eg , an integer <nl> + auto MaybeDifferentOp = cheaperToPassOperandsAsArguments ( FSI , SI ) ; <nl> + / / Couldn ' t find a suitable operand , so bail . <nl> + if ( ! MaybeDifferentOp ) <nl> + return false ; <nl> + unsigned DifferentOp = * MaybeDifferentOp ; <nl> + / / Make sure we found the same operand as prior iterations . <nl> + if ( DifferentOperandIndex & & DifferentOp ! = * DifferentOperandIndex ) <nl> + return false ; <nl> <nl> - BBEnumTagDataflowState * PredBBState = BBToStateMap . getBBState ( PredBB ) ; <nl> - if ( PredBBState = = nullptr ) { <nl> - DEBUG ( llvm : : dbgs ( ) < < " Found an unreachable block ! \ n " ) ; <nl> - return ; <nl> - } <nl> + DifferentOperandIndex = DifferentOp ; <nl> + Clones . push_back ( SI ) ; <nl> + } <nl> <nl> - + + PI ; <nl> + auto * Undef = SILUndef : : get ( FSI - > getType ( ) , BB - > getModule ( ) ) ; <nl> <nl> - / / Then for each ( SILValue , Enum Tag ) that we are tracking . . . <nl> - for ( auto P : ValueToCaseMap . getItems ( ) ) { <nl> - / / If this SILValue was blotted , there is nothing left to do , we found <nl> - / / some sort of conflicting definition and are being conservative . <nl> - if ( ! P . hasValue ( ) ) <nl> - continue ; <nl> + / / Delete the debug info of the instruction that we are about to sink . <nl> + deleteAllDebugUses ( FSI ) ; <nl> <nl> - / / Then attempt to look up the enum state associated in our SILValue in <nl> - / / the predecessor we are processing . <nl> - auto PredValue = PredBBState - > ValueToCaseMap . find ( P - > first ) ; <nl> + if ( DifferentOperandIndex ) { <nl> + / / Sink one of the instructions to BB <nl> + FSI - > moveBefore ( & * BB - > begin ( ) ) ; <nl> <nl> - / / If we cannot find the state associated with this SILValue in this <nl> - / / predecessor or the value in the corresponding predecessor was blotted , <nl> - / / we cannot find a covering switch for this BB or forward any enum tag <nl> - / / information for this enum value . <nl> - if ( PredValue = = PredBBState - > ValueToCaseMap . end ( ) | | ! ( * PredValue ) - > first ) { <nl> - / / Otherwise , we are conservative and do not forward the EnumTag that we <nl> - / / are tracking . Blot it ! <nl> - DEBUG ( llvm : : dbgs ( ) < < " Blotting : " < < P - > first ) ; <nl> - CurBBValuesToBlot . push_back ( P - > first ) ; <nl> - PredBBValuesToBlot . push_back ( P - > first ) ; <nl> - continue ; <nl> - } <nl> + / / The instruction we are lowering has an argument which is different <nl> + / / for each predecessor . We need to sink the instruction , then add <nl> + / / arguments for each predecessor . <nl> + BB - > getArgument ( ArgNum ) - > replaceAllUsesWith ( FSI ) ; <nl> <nl> - / / Check if out predecessor has any other successors . If that is true we <nl> - / / clear all the state since we cannot hoist safely . <nl> - if ( ! PredBB - > getSingleSuccessorBlock ( ) ) { <nl> - EnumToEnumBBCaseListMap . clear ( ) ; <nl> - DEBUG ( llvm : : dbgs ( ) < < " Predecessor has other " <nl> - " successors . Clearing BB cast list map . \ n " ) ; <nl> - } else { <nl> - / / Otherwise , add this case to our predecessor case list . We will unique <nl> - / / this after we have finished processing all predecessors . <nl> - auto Case = std : : make_pair ( PredBB , ( * PredValue ) - > second ) ; <nl> - EnumToEnumBBCaseListMap [ ( * PredValue ) - > first ] . push_back ( Case ) ; <nl> - } <nl> + const auto & ArgType = FSI - > getOperand ( * DifferentOperandIndex ) - > getType ( ) ; <nl> + BB - > replacePHIArgument ( ArgNum , ArgType , ValueOwnershipKind : : Owned ) ; <nl> <nl> - / / And the states match , the enum state propagates to this BB . <nl> - if ( ( * PredValue ) - > second = = P - > second ) <nl> - continue ; <nl> + / / Update all branch instructions in the predecessors to pass the new <nl> + / / argument to this BB . <nl> + auto CloneIt = Clones . begin ( ) ; <nl> + for ( auto P : BB - > getPredecessorBlocks ( ) ) { <nl> + / / Only handle branch or conditional branch instructions . <nl> + TermInst * TI = P - > getTerminator ( ) ; <nl> + assert ( ( isa < BranchInst > ( TI ) | | isa < CondBranchInst > ( TI ) ) & & <nl> + " Branch instruction required " ) ; <nl> <nl> - / / Otherwise , we are conservative and do not forward the EnumTag that we <nl> - / / are tracking . Blot it ! <nl> - DEBUG ( llvm : : dbgs ( ) < < " Blotting : " < < P - > first ) ; <nl> - CurBBValuesToBlot . push_back ( P - > first ) ; <nl> + / / TODO : MultiValueInstruction <nl> + auto * CloneInst = * CloneIt ; <nl> + TI - > setOperand ( ArgNum , CloneInst - > getOperand ( * DifferentOperandIndex ) ) ; <nl> + / / Now delete the clone as we only needed it operand . <nl> + if ( CloneInst ! = FSI ) <nl> + recursivelyDeleteTriviallyDeadInstructions ( CloneInst ) ; <nl> + + + CloneIt ; <nl> } <nl> - } while ( PI ! = PE ) ; <nl> + assert ( CloneIt = = Clones . end ( ) & & " Clone / pred mismatch " ) ; <nl> <nl> - for ( SILValue V : CurBBValuesToBlot ) { <nl> - ValueToCaseMap . blot ( V ) ; <nl> - } <nl> - for ( SILValue V : PredBBValuesToBlot ) { <nl> - EnumToEnumBBCaseListMap . blot ( V ) ; <nl> + / / The sunk instruction should now read from the argument of the BB it <nl> + / / was moved to . <nl> + FSI - > setOperand ( * DifferentOperandIndex , BB - > getArgument ( ArgNum ) ) ; <nl> + return true ; <nl> } <nl> - } <nl> <nl> - bool BBEnumTagDataflowState : : visitRetainValueInst ( RetainValueInst * RVI ) { <nl> - auto FindResult = ValueToCaseMap . find ( RVI - > getOperand ( ) ) ; <nl> - if ( FindResult = = ValueToCaseMap . end ( ) ) <nl> - return false ; <nl> + / / Sink one of the copies of the instruction . <nl> + FSI - > replaceAllUsesWithUndef ( ) ; <nl> + FSI - > moveBefore ( & * BB - > begin ( ) ) ; <nl> + BB - > getArgument ( ArgNum ) - > replaceAllUsesWith ( FSI ) ; <nl> <nl> - / / If we do not have any argument , kill the retain_value . <nl> - if ( ! ( * FindResult ) - > second - > hasAssociatedValues ( ) ) { <nl> - RVI - > eraseFromParent ( ) ; <nl> - return true ; <nl> + / / The argument is no longer in use . Replace all incoming inputs with undef <nl> + / / and try to delete the instruction . <nl> + for ( auto S : Clones ) { <nl> + if ( S ! = FSI ) { <nl> + deleteAllDebugUses ( S ) ; <nl> + S - > replaceAllUsesWith ( Undef ) ; <nl> + auto DeadArgInst = cast < SILInstruction > ( S ) ; <nl> + for ( SILValue Result : DeadArgInst - > getResults ( ) ) { <nl> + Context . blotValue ( Result ) ; <nl> + } <nl> + DeadArgInst - > eraseFromParent ( ) ; <nl> + } <nl> } <nl> <nl> - DEBUG ( llvm : : dbgs ( ) < < " Found RetainValue : " < < * RVI ) ; <nl> - DEBUG ( llvm : : dbgs ( ) < < " Paired to Enum Oracle : " < < ( * FindResult ) - > first ) ; <nl> - <nl> - SILBuilderWithScope Builder ( RVI ) ; <nl> - createRefCountOpForPayload ( Builder , RVI , ( * FindResult ) - > second ) ; <nl> - RVI - > eraseFromParent ( ) ; <nl> return true ; <nl> } <nl> <nl> - bool BBEnumTagDataflowState : : visitReleaseValueInst ( ReleaseValueInst * RVI ) { <nl> - auto FindResult = ValueToCaseMap . find ( RVI - > getOperand ( ) ) ; <nl> - if ( FindResult = = ValueToCaseMap . end ( ) ) <nl> + / / / Try to sink literals that are passed to arguments that are coming from <nl> + / / / multiple predecessors . <nl> + / / / Notice that unlike other sinking methods in this file we do allow sinking <nl> + / / / of literals from blocks with multiple successors . <nl> + static bool sinkLiteralsFromPredecessors ( SILBasicBlock * BB ) { <nl> + if ( BB - > pred_empty ( ) | | BB - > getSinglePredecessorBlock ( ) ) <nl> return false ; <nl> <nl> - / / If we do not have any argument , just delete the release value . <nl> - if ( ! ( * FindResult ) - > second - > hasAssociatedValues ( ) ) { <nl> - RVI - > eraseFromParent ( ) ; <nl> - return true ; <nl> - } <nl> - <nl> - DEBUG ( llvm : : dbgs ( ) < < " Found ReleaseValue : " < < * RVI ) ; <nl> - DEBUG ( llvm : : dbgs ( ) < < " Paired to Enum Oracle : " < < ( * FindResult ) - > first ) ; <nl> + / / Try to sink values from each of the arguments to the basic block . <nl> + bool Changed = false ; <nl> + for ( int i = 0 , e = BB - > getNumArguments ( ) ; i < e ; + + i ) <nl> + Changed | = sinkLiteralArguments ( BB , i ) ; <nl> <nl> - SILBuilderWithScope Builder ( RVI ) ; <nl> - createRefCountOpForPayload ( Builder , RVI , ( * FindResult ) - > second ) ; <nl> - RVI - > eraseFromParent ( ) ; <nl> - return true ; <nl> + return Changed ; <nl> } <nl> <nl> - bool BBEnumTagDataflowState : : process ( ) { <nl> - bool Changed = false ; <nl> + / / / Try to sink identical arguments coming from multiple predecessors . <nl> + static bool sinkArgumentsFromPredecessors ( EnumCaseDataflowContext & Context , <nl> + SILBasicBlock * BB ) { <nl> + if ( BB - > pred_empty ( ) | | BB - > getSinglePredecessorBlock ( ) ) <nl> + return false ; <nl> <nl> - auto SI = getBB ( ) - > begin ( ) ; <nl> - while ( SI ! = getBB ( ) - > end ( ) ) { <nl> - SILInstruction * I = & * SI ; <nl> - + + SI ; <nl> - Changed | = visit ( I ) ; <nl> - } <nl> + / / This block must be the only successor of all the predecessors . <nl> + for ( auto P : BB - > getPredecessorBlocks ( ) ) <nl> + if ( P - > getSingleSuccessorBlock ( ) ! = BB ) <nl> + return false ; <nl> + <nl> + / / Try to sink values from each of the arguments to the basic block . <nl> + bool Changed = false ; <nl> + for ( int i = 0 , e = BB - > getNumArguments ( ) ; i < e ; + + i ) <nl> + Changed | = sinkArgument ( Context , BB , i ) ; <nl> <nl> return Changed ; <nl> } <nl> <nl> - bool <nl> - BBEnumTagDataflowState : : hoistDecrementsIntoSwitchRegions ( AliasAnalysis * AA ) { <nl> + / / / \ brief canonicalize retain / release instructions and make them amenable to <nl> + / / / sinking by selecting canonical pointers . We reduce the number of possible <nl> + / / / inputs by replacing values that are unlikely to be a canonical values . <nl> + / / / Reducing the search space increases the chances of matching ref count <nl> + / / / instructions to one another and the chance of sinking them . We replace <nl> + / / / values that come from basic block arguments with the caller values and <nl> + / / / strip casts . <nl> + static bool canonicalizeRefCountInstrs ( SILBasicBlock * BB ) { <nl> bool Changed = false ; <nl> - unsigned NumPreds = std : : distance ( getBB ( ) - > pred_begin ( ) , getBB ( ) - > pred_end ( ) ) ; <nl> - <nl> - for ( auto II = getBB ( ) - > begin ( ) , IE = getBB ( ) - > end ( ) ; II ! = IE ; ) { <nl> - auto * RVI = dyn_cast < ReleaseValueInst > ( & * II ) ; <nl> - + + II ; <nl> - <nl> - / / If this instruction is not a release , skip it . . . <nl> - if ( ! RVI ) <nl> + for ( auto I = BB - > begin ( ) , E = BB - > end ( ) ; I ! = E ; + + I ) { <nl> + if ( ! isa < StrongReleaseInst > ( I ) & & ! isa < StrongRetainInst > ( I ) ) <nl> continue ; <nl> <nl> - DEBUG ( llvm : : dbgs ( ) < < " Visiting release : " < < * RVI ) ; <nl> - <nl> - / / Grab the operand of the release value inst . <nl> - SILValue Op = RVI - > getOperand ( ) ; <nl> - <nl> - / / Lookup the [ ( BB , EnumTag ) ] list for this operand . <nl> - auto R = EnumToEnumBBCaseListMap . find ( Op ) ; <nl> - / / If we don ' t have one , skip this release value inst . <nl> - if ( R = = EnumToEnumBBCaseListMap . end ( ) ) { <nl> - DEBUG ( llvm : : dbgs ( ) < < " Could not find [ ( BB , EnumTag ) ] " <nl> - " list for release_value ' s operand . Bailing ! \ n " ) ; <nl> - continue ; <nl> + SILValue Ref = I - > getOperand ( 0 ) ; <nl> + SILValue Root = findValueShallowRoot ( Ref ) ; <nl> + if ( Ref ! = Root ) { <nl> + I - > setOperand ( 0 , Root ) ; <nl> + Changed = true ; <nl> } <nl> + } <nl> <nl> - auto & EnumBBCaseList = ( * R ) - > second ; <nl> - / / If we don ' t have an enum tag for each predecessor of this BB , bail since <nl> - / / we do not know how to handle that BB . <nl> - if ( EnumBBCaseList . size ( ) ! = NumPreds ) { <nl> - DEBUG ( llvm : : dbgs ( ) < < " Found [ ( BB , EnumTag ) ] " <nl> - " list for release_value ' s operand , but we do not have an enum tag " <nl> - " for each predecessor . Bailing ! \ n " ) ; <nl> - DEBUG ( llvm : : dbgs ( ) < < " List : \ n " ) ; <nl> - DEBUG ( for ( auto P : EnumBBCaseList ) { <nl> - llvm : : dbgs ( ) < < " " ; P . second - > dump ( llvm : : dbgs ( ) ) ; <nl> - } ) ; <nl> - continue ; <nl> - } <nl> + return Changed ; <nl> + } <nl> <nl> - / / Finally ensure that we have no users of this operand preceding the <nl> - / / release_value in this BB . If we have users like that we cannot hoist the <nl> - / / release past them unless we know that there is an additional set of <nl> - / / releases that together post - dominate this release . If we cannot do this , <nl> - / / skip this release . <nl> - / / <nl> - / / TODO : We need information from the ARC optimizer to prove that property <nl> - / / if we are going to use it . <nl> - if ( valueHasARCUsesInInstructionRange ( Op , getBB ( ) - > begin ( ) , <nl> - SILBasicBlock : : iterator ( RVI ) , <nl> - AA ) ) { <nl> - DEBUG ( llvm : : dbgs ( ) < < " Release value has use that stops " <nl> - " hoisting ! Bailing ! \ n " ) ; <nl> - continue ; <nl> - } <nl> + static bool sinkCodeFromPredecessors ( EnumCaseDataflowContext & Context , <nl> + SILBasicBlock * BB ) { <nl> + bool Changed = false ; <nl> + if ( BB - > pred_empty ( ) ) <nl> + return Changed ; <nl> <nl> - DEBUG ( llvm : : dbgs ( ) < < " Its safe to perform the " <nl> - " transformation ! \ n " ) ; <nl> + / / This block must be the only successor of all the predecessors . <nl> + for ( auto P : BB - > getPredecessorBlocks ( ) ) <nl> + if ( P - > getSingleSuccessorBlock ( ) ! = BB ) <nl> + return Changed ; <nl> <nl> - / / Otherwise perform the transformation . <nl> - for ( auto P : EnumBBCaseList ) { <nl> - / / If we don ' t have an argument for this case , there is nothing to <nl> - / / do . . . continue . . . <nl> - if ( ! P . second - > hasAssociatedValues ( ) ) <nl> - continue ; <nl> + SILBasicBlock * FirstPred = * BB - > pred_begin ( ) ; <nl> + / / The first Pred must have at least one non - terminator . <nl> + if ( FirstPred - > getTerminator ( ) = = & * FirstPred - > begin ( ) ) <nl> + return Changed ; <nl> <nl> - / / Otherwise create the release_value before the terminator of the <nl> - / / predecessor . <nl> - assert ( P . first - > getSingleSuccessorBlock ( ) & & <nl> - " Cannot hoist release into BB that has multiple successors " ) ; <nl> - SILBuilderWithScope Builder ( P . first - > getTerminator ( ) , RVI ) ; <nl> - createRefCountOpForPayload ( Builder , RVI , P . second ) ; <nl> - } <nl> + DEBUG ( llvm : : dbgs ( ) < < " Sinking values from predecessors . \ n " ) ; <nl> <nl> - RVI - > eraseFromParent ( ) ; <nl> - + + NumHoisted ; <nl> - Changed = true ; <nl> + / / Map values in predecessor blocks to argument indices of the successor <nl> + / / block . For example : <nl> + / / <nl> + / / bb1 : <nl> + / / br bb3 ( % a , % b ) / / % a - > 0 , % b - > 1 <nl> + / / bb2 : <nl> + / / br bb3 ( % c , % d ) / / % c - > 0 , % d - > 1 <nl> + / / bb3 ( % x , % y ) : <nl> + / / . . . <nl> + ValueToBBArgIdxMap valueToArgIdxMap ; <nl> + for ( auto P : BB - > getPredecessorBlocks ( ) ) { <nl> + if ( auto * BI = dyn_cast < BranchInst > ( P - > getTerminator ( ) ) ) { <nl> + auto Args = BI - > getArgs ( ) ; <nl> + for ( size_t idx = 0 , size = Args . size ( ) ; idx < size ; idx + + ) { <nl> + valueToArgIdxMap [ { Args [ idx ] , P } ] = idx ; <nl> + } <nl> + } <nl> } <nl> <nl> - return Changed ; <nl> - } <nl> + unsigned SkipBudget = SinkSearchWindow ; <nl> <nl> - static SILInstruction * <nl> - findLastSinkableMatchingEnumValueRCIncrementInPred ( AliasAnalysis * AA , <nl> - RCIdentityFunctionInfo * RCIA , <nl> - SILValue EnumValue , <nl> - SILBasicBlock * BB ) { <nl> - / / Otherwise , see if we can find a retain_value or strong_retain associated <nl> - / / with that enum in the relevant predecessor . <nl> - auto FirstInc = std : : find_if ( BB - > rbegin ( ) , BB - > rend ( ) , <nl> - [ & RCIA , & EnumValue ] ( const SILInstruction & I ) - > bool { <nl> - / / If I is not an increment , ignore it . <nl> - if ( ! isa < StrongRetainInst > ( I ) & & ! isa < RetainValueInst > ( I ) ) <nl> - return false ; <nl> + / / Start scanning backwards from the terminator . <nl> + auto InstToSink = FirstPred - > getTerminator ( ) - > getIterator ( ) ; <nl> <nl> - / / Otherwise , if the increments operand stripped of RC identity preserving <nl> - / / ops matches EnumValue , it is the first increment we are interested in . <nl> - return EnumValue = = RCIA - > getRCIdentityRoot ( I . getOperand ( 0 ) ) ; <nl> - } ) ; <nl> + while ( SkipBudget ) { <nl> + DEBUG ( llvm : : dbgs ( ) < < " Processing : " < < * InstToSink ) ; <nl> <nl> - / / If we do not find a ref count increment in the relevant BB , skip this <nl> - / / enum since there is nothing we can do . <nl> - if ( FirstInc = = BB - > rend ( ) ) <nl> - return nullptr ; <nl> + / / Save the duplicated instructions in case we need to remove them . <nl> + SmallVector < SILInstruction * , 4 > Dups ; <nl> <nl> - / / Otherwise , see if there are any instructions in between FirstPredInc and <nl> - / / the end of the given basic block that could decrement first pred . If such <nl> - / / an instruction exists , we cannot perform this optimization so continue . <nl> - if ( valueHasARCDecrementOrCheckInInstructionRange ( <nl> - EnumValue , ( * FirstInc ) . getIterator ( ) , <nl> - BB - > getTerminator ( ) - > getIterator ( ) , AA ) ) <nl> - return nullptr ; <nl> + if ( canSinkInstruction ( & * InstToSink ) ) { <nl> <nl> - return & * FirstInc ; <nl> - } <nl> + OperandRelation opRelation = NotDeterminedYet ; <nl> <nl> - static bool <nl> - findRetainsSinkableFromSwitchRegionForEnum ( <nl> - AliasAnalysis * AA , RCIdentityFunctionInfo * RCIA , SILValue EnumValue , <nl> - EnumBBCaseList & Map , SmallVectorImpl < SILInstruction * > & DeleteList ) { <nl> + / / For all preds : <nl> + for ( auto P : BB - > getPredecessorBlocks ( ) ) { <nl> + if ( P = = FirstPred ) <nl> + continue ; <nl> <nl> - / / For each predecessor with argument type . . . <nl> - for ( auto & P : Map ) { <nl> - SILBasicBlock * PredBB = P . first ; <nl> - EnumElementDecl * Decl = P . second ; <nl> + / / Search the duplicated instruction in the predecessor . <nl> + if ( SILInstruction * DupInst = findIdenticalInBlock ( <nl> + P , & * InstToSink , valueToArgIdxMap , opRelation ) ) { <nl> + Dups . push_back ( DupInst ) ; <nl> + } else { <nl> + DEBUG ( llvm : : dbgs ( ) < < " Instruction mismatch . \ n " ) ; <nl> + Dups . clear ( ) ; <nl> + break ; <nl> + } <nl> + } <nl> <nl> - / / If the case does not have an argument type , skip the predecessor since <nl> - / / there will not be a retain to sink . <nl> - if ( ! Decl - > hasAssociatedValues ( ) ) <nl> - continue ; <nl> + / / If we found duplicated instructions , sink one of the copies and delete <nl> + / / the rest . <nl> + if ( Dups . size ( ) ) { <nl> + DEBUG ( llvm : : dbgs ( ) < < " Moving : " < < * InstToSink ) ; <nl> + InstToSink - > moveBefore ( & * BB - > begin ( ) ) ; <nl> <nl> - / / Ok , we found a payloaded predecessor . Look backwards through the <nl> - / / predecessor for the first ref count increment on EnumValue . If there <nl> - / / are no ref count decrements in between the increment and the terminator <nl> - / / of the BB , then we can sink the retain out of the switch enum . <nl> - auto * Inc = findLastSinkableMatchingEnumValueRCIncrementInPred ( AA , <nl> - RCIA , <nl> - EnumValue , <nl> - PredBB ) ; <nl> - / / If we do not find such an increment , there is nothing we can do , bail . <nl> - if ( ! Inc ) <nl> - return false ; <nl> + if ( opRelation = = EqualAfterMove ) { <nl> + / / Replace operand values ( which are passed to the successor block ) <nl> + / / with corresponding block arguments . <nl> + for ( size_t idx = 0 , numOps = InstToSink - > getNumOperands ( ) ; <nl> + idx < numOps ; idx + + ) { <nl> + ValueInBlock OpInFirstPred ( InstToSink - > getOperand ( idx ) , FirstPred ) ; <nl> + assert ( valueToArgIdxMap . count ( OpInFirstPred ) ! = 0 ) ; <nl> + int argIdx = valueToArgIdxMap [ OpInFirstPred ] ; <nl> + InstToSink - > setOperand ( idx , BB - > getArgument ( argIdx ) ) ; <nl> + } <nl> + } <nl> + Changed = true ; <nl> + for ( auto I : Dups ) { <nl> + I - > replaceAllUsesPairwiseWith ( & * InstToSink ) ; <nl> + for ( SILValue Result : I - > getResults ( ) ) { <nl> + Context . blotValue ( Result ) ; <nl> + } <nl> + I - > eraseFromParent ( ) ; <nl> + NumSunk + + ; <nl> + } <nl> <nl> - / / Otherwise add the increment to the delete list . <nl> - DeleteList . push_back ( Inc ) ; <nl> + / / Restart the scan . <nl> + InstToSink = FirstPred - > getTerminator ( ) - > getIterator ( ) ; <nl> + DEBUG ( llvm : : dbgs ( ) < < " Restarting scan . Next inst : " < < * InstToSink ) ; <nl> + continue ; <nl> + } <nl> + } <nl> + <nl> + / / If this instruction was a barrier then we can ' t sink anything else . <nl> + if ( isSinkBarrier ( & * InstToSink ) ) { <nl> + DEBUG ( llvm : : dbgs ( ) < < " Aborting on barrier : " < < * InstToSink ) ; <nl> + return Changed ; <nl> + } <nl> + <nl> + / / This is the first instruction , we are done . <nl> + if ( InstToSink = = FirstPred - > begin ( ) ) { <nl> + DEBUG ( llvm : : dbgs ( ) < < " Reached the first instruction . " ) ; <nl> + return Changed ; <nl> + } <nl> + <nl> + SkipBudget - - ; <nl> + InstToSink = std : : prev ( InstToSink ) ; <nl> + DEBUG ( llvm : : dbgs ( ) < < " Continuing scan . Next inst : " < < * InstToSink ) ; <nl> } <nl> <nl> - / / If we were able to process each predecessor successfully , return true . <nl> + return Changed ; <nl> + } <nl> + <nl> + / / / Sink retain_value , release_value before switch_enum to be retain_value , <nl> + / / / release_value on the payload of the switch_enum in the destination BBs . We <nl> + / / / only do this if the destination BBs have only the switch enum as its <nl> + / / / predecessor . <nl> + static bool tryToSinkRefCountAcrossSwitch ( SwitchEnumInst * Switch , <nl> + SILBasicBlock : : iterator RV , <nl> + AliasAnalysis * AA , <nl> + RCIdentityFunctionInfo * RCIA ) { <nl> + / / If this instruction is not a retain_value , there is nothing left for us to <nl> + / / do . . . bail . . . <nl> + if ( ! isa < RetainValueInst > ( RV ) ) <nl> + return false ; <nl> + <nl> + SILValue Ptr = RV - > getOperand ( 0 ) ; <nl> + <nl> + / / Next go over all instructions after I in the basic block . If none of them <nl> + / / can decrement our ptr value , we can move the retain over the ref count <nl> + / / inst . If any of them do potentially decrement the ref count of Ptr , we can <nl> + / / not move it . <nl> + auto SwitchIter = Switch - > getIterator ( ) ; <nl> + if ( auto B = valueHasARCDecrementOrCheckInInstructionRange ( Ptr , RV , <nl> + SwitchIter , AA ) ) { <nl> + RV - > moveBefore ( & * * B ) ; <nl> + return true ; <nl> + } <nl> + <nl> + / / If the retain value ' s argument is not the switch ' s argument , we can ' t do <nl> + / / anything with our simplistic analysis . . . bail . . . <nl> + if ( RCIA - > getRCIdentityRoot ( Ptr ) ! = <nl> + RCIA - > getRCIdentityRoot ( Switch - > getOperand ( ) ) ) <nl> + return false ; <nl> + <nl> + / / If S has a default case bail since the default case could represent <nl> + / / multiple cases . <nl> + / / <nl> + / / TODO : I am currently just disabling this behavior so we can get this out <nl> + / / for Seed 5 . After Seed 5 , we should be able to recognize if a switch_enum <nl> + / / handles all cases except for 1 and has a default case . We might be able to <nl> + / / stick code into SILBuilder that has this behavior . <nl> + if ( Switch - > hasDefault ( ) ) <nl> + return false ; <nl> + <nl> + / / Ok , we have a ref count instruction , sink it ! <nl> + SILBuilderWithScope Builder ( Switch , & * RV ) ; <nl> + for ( unsigned i = 0 , e = Switch - > getNumCases ( ) ; i ! = e ; + + i ) { <nl> + auto Case = Switch - > getCase ( i ) ; <nl> + EnumElementDecl * Enum = Case . first ; <nl> + SILBasicBlock * Succ = Case . second ; <nl> + Builder . setInsertionPoint ( & * Succ - > begin ( ) ) ; <nl> + if ( Enum - > hasAssociatedValues ( ) ) <nl> + createRefCountOpForPayload ( Builder , & * RV , Enum , Switch - > getOperand ( ) ) ; <nl> + } <nl> + <nl> + RV - > eraseFromParent ( ) ; <nl> + NumSunk + + ; <nl> return true ; <nl> } <nl> <nl> - bool <nl> - BBEnumTagDataflowState : : <nl> - sinkIncrementsOutOfSwitchRegions ( AliasAnalysis * AA , <nl> - RCIdentityFunctionInfo * RCIA ) { <nl> - bool Changed = false ; <nl> - unsigned NumPreds = std : : distance ( getBB ( ) - > pred_begin ( ) , getBB ( ) - > pred_end ( ) ) ; <nl> - llvm : : SmallVector < SILInstruction * , 4 > DeleteList ; <nl> + / / / Sink retain_value , release_value before select_enum to be retain_value , <nl> + / / / release_value on the payload of the switch_enum in the destination BBs . We <nl> + / / / only do this if the destination BBs have only the switch enum as its <nl> + / / / predecessor . <nl> + static bool tryToSinkRefCountAcrossSelectEnum ( CondBranchInst * CondBr , <nl> + SILBasicBlock : : iterator I , <nl> + AliasAnalysis * AA , <nl> + RCIdentityFunctionInfo * RCIA ) { <nl> + / / If this instruction is not a retain_value , there is nothing left for us to <nl> + / / do . . . bail . . . <nl> + if ( ! isa < RetainValueInst > ( I ) ) <nl> + return false ; <nl> <nl> - / / For each ( EnumValue , [ ( BB , EnumTag ) ] ) that we are tracking . . . <nl> - for ( auto & P : EnumToEnumBBCaseListMap ) { <nl> - / / Clear our delete list . <nl> - DeleteList . clear ( ) ; <nl> + / / Make sure the condition comes from a select_enum <nl> + auto * SEI = dyn_cast < SelectEnumInst > ( CondBr - > getCondition ( ) ) ; <nl> + if ( ! SEI ) <nl> + return false ; <nl> <nl> - / / If EnumValue is null , we deleted this entry . There is nothing to do for <nl> - / / this value . . . Skip it . <nl> - if ( ! P . hasValue ( ) ) <nl> - continue ; <nl> - SILValue EnumValue = RCIA - > getRCIdentityRoot ( P - > first ) ; <nl> - EnumBBCaseList & Map = P - > second ; <nl> + / / Try to find a single literal " true " case . <nl> + / / TODO : More general conditions in which we can relate the BB to a single <nl> + / / case , such as when there ' s a single literal " false " case . <nl> + NullablePtr < EnumElementDecl > TrueElement = SEI - > getSingleTrueElement ( ) ; <nl> + if ( TrueElement . isNull ( ) ) <nl> + return false ; <nl> <nl> - / / If we do not have a tag associated with this enum value for each <nl> - / / predecessor , we are not a switch region exit for this enum value . Skip <nl> - / / this value . <nl> - if ( Map . size ( ) ! = NumPreds ) <nl> - continue ; <nl> + / / Next go over all instructions after I in the basic block . If none of them <nl> + / / can decrement our ptr value , we can move the retain over the ref count <nl> + / / inst . If any of them do potentially decrement the ref count of Ptr , we can <nl> + / / not move it . <nl> <nl> - / / Look through our predecessors for a set of ref count increments on our <nl> - / / enum value for every payloaded case that * could * be sunk . If we miss an <nl> - / / increment from any of the payloaded case there is nothing we can do here , <nl> - / / so skip this enum value . <nl> - if ( ! findRetainsSinkableFromSwitchRegionForEnum ( AA , RCIA , EnumValue , Map , <nl> - DeleteList ) ) <nl> - continue ; <nl> + SILValue Ptr = I - > getOperand ( 0 ) ; <nl> + auto CondBrIter = CondBr - > getIterator ( ) ; <nl> + if ( auto B = valueHasARCDecrementOrCheckInInstructionRange ( Ptr , std : : next ( I ) , <nl> + CondBrIter , AA ) ) { <nl> + I - > moveBefore ( & * * B ) ; <nl> + return false ; <nl> + } <nl> <nl> - / / If we do not have any payload arguments , then we should have an empty <nl> - / / delete list and there is nothing to do here . <nl> - if ( DeleteList . empty ( ) ) <nl> + / / If the retain value ' s argument is not the cond_br ' s argument , we can ' t do <nl> + / / anything with our simplistic analysis . . . bail . . . <nl> + if ( RCIA - > getRCIdentityRoot ( Ptr ) ! = <nl> + RCIA - > getRCIdentityRoot ( SEI - > getEnumOperand ( ) ) ) <nl> + return false ; <nl> + <nl> + / / Work out which enum element is the true branch , and which is false . <nl> + / / If the enum only has 2 values and its tag isn ' t the true branch , then we <nl> + / / know the true branch must be the other tag . <nl> + EnumElementDecl * Elts [ 2 ] = { TrueElement . get ( ) , nullptr } ; <nl> + EnumDecl * E = SEI - > getEnumOperand ( ) - > getType ( ) . getEnumOrBoundGenericEnum ( ) ; <nl> + if ( ! E ) <nl> + return false ; <nl> + <nl> + / / Look for a single other element on this enum . <nl> + EnumElementDecl * OtherElt = nullptr ; <nl> + for ( EnumElementDecl * Elt : E - > getAllElements ( ) ) { <nl> + / / Skip the case where we find the select_enum element <nl> + if ( Elt = = TrueElement . get ( ) ) <nl> continue ; <nl> + / / If we find another element , then we must have more than 2 , so bail . <nl> + if ( OtherElt ) <nl> + return false ; <nl> + OtherElt = Elt ; <nl> + } <nl> + / / Only a single enum element ? How would this even get here ? We should <nl> + / / handle it in SILCombine . <nl> + if ( ! OtherElt ) <nl> + return false ; <nl> <nl> - / / Ok , we can perform this transformation ! Insert the new retain_value and <nl> - / / delete all of the ref count increments from the predecessor BBs . <nl> + Elts [ 1 ] = OtherElt ; <nl> + <nl> + SILBuilderWithScope Builder ( SEI , & * I ) ; <nl> + <nl> + / / Ok , we have a ref count instruction , sink it ! <nl> + for ( unsigned i = 0 ; i ! = 2 ; + + i ) { <nl> + EnumElementDecl * Enum = Elts [ i ] ; <nl> + SILBasicBlock * Succ = i = = 0 ? CondBr - > getTrueBB ( ) : CondBr - > getFalseBB ( ) ; <nl> + Builder . setInsertionPoint ( & * Succ - > begin ( ) ) ; <nl> + if ( Enum - > hasAssociatedValues ( ) ) <nl> + createRefCountOpForPayload ( Builder , & * I , Enum , SEI - > getEnumOperand ( ) ) ; <nl> + } <nl> + <nl> + I - > eraseFromParent ( ) ; <nl> + NumSunk + + ; <nl> + return true ; <nl> + } <nl> + <nl> + static bool tryTosinkIncrementsIntoSwitchRegions ( SILBasicBlock : : iterator T , <nl> + SILBasicBlock : : iterator I , <nl> + bool CanSinkToSuccessors , <nl> + AliasAnalysis * AA , <nl> + RCIdentityFunctionInfo * RCIA ) { <nl> + / / The following methods should only be attempted if we can sink to our <nl> + / / successor . <nl> + if ( CanSinkToSuccessors ) { <nl> + / / If we have a switch , try to sink ref counts across it and then return <nl> + / / that result . We do not keep processing since the code below cannot <nl> + / / properly sink ref counts over switch_enums so we might as well exit <nl> + / / early . <nl> + if ( auto * S = dyn_cast < SwitchEnumInst > ( T ) ) <nl> + return tryToSinkRefCountAcrossSwitch ( S , I , AA , RCIA ) ; <nl> + <nl> + / / In contrast , even if we do not sink ref counts across a cond_br from a <nl> + / / select_enum , we may be able to sink anyways . So we do not return on a <nl> + / / failure case . <nl> + if ( auto * CondBr = dyn_cast < CondBranchInst > ( T ) ) <nl> + if ( tryToSinkRefCountAcrossSelectEnum ( CondBr , I , AA , RCIA ) ) <nl> + return true ; <nl> + } <nl> + <nl> + / / At this point , this is a retain on a regular SSA value , leave it to retain <nl> + / / release code motion to sink . <nl> + return false ; <nl> + } <nl> + <nl> + / / / Try sink a retain as far as possible . This is either to successor BBs , <nl> + / / / or as far down the current BB as possible <nl> + static bool sinkIncrementsIntoSwitchRegions ( SILBasicBlock * BB , <nl> + AliasAnalysis * AA , <nl> + RCIdentityFunctionInfo * RCIA ) { <nl> + / / Make sure that each one of our successors only has one predecessor , <nl> + / / us . <nl> + / / If that condition is not true , we can still sink to the end of this BB , <nl> + / / but not to successors . <nl> + bool CanSinkToSuccessor = std : : none_of ( <nl> + BB - > succ_begin ( ) , BB - > succ_end ( ) , [ ] ( const SILSuccessor & S ) - > bool { <nl> + SILBasicBlock * SuccBB = S . getBB ( ) ; <nl> + return ! SuccBB | | ! SuccBB - > getSinglePredecessorBlock ( ) ; <nl> + } ) ; <nl> + <nl> + SILInstruction * S = BB - > getTerminator ( ) ; <nl> + auto SI = S - > getIterator ( ) , SE = BB - > begin ( ) ; <nl> + if ( SI = = SE ) <nl> + return false ; <nl> + <nl> + bool Changed = false ; <nl> + <nl> + / / Walk from the terminator up the BB . Try move retains either to the next <nl> + / / BB , or the end of this BB . Note that ordering is maintained of retains <nl> + / / within this BB . <nl> + SI = std : : prev ( SI ) ; <nl> + while ( SI ! = SE ) { <nl> + SILInstruction * Inst = & * SI ; <nl> + SI = std : : prev ( SI ) ; <nl> + <nl> + / / Try to : <nl> / / <nl> - / / TODO : Which debug loc should we use here ? Using one of the locs from the <nl> - / / delete list seems reasonable for now . . . <nl> - SILBuilder Builder ( getBB ( ) - > begin ( ) ) ; <nl> - Builder . createRetainValue ( DeleteList [ 0 ] - > getLoc ( ) , EnumValue , <nl> - cast < RefCountingInst > ( DeleteList [ 0 ] ) - > getAtomicity ( ) ) ; <nl> - for ( auto * I : DeleteList ) <nl> - I - > eraseFromParent ( ) ; <nl> - + + NumSunk ; <nl> - Changed = true ; <nl> + / / 1 . If there are no decrements between our ref count inst and <nl> + / / terminator , sink the ref count inst into either our successors . <nl> + / / 2 . If there are such decrements , move the retain right before that <nl> + / / decrement . <nl> + Changed | = tryTosinkIncrementsIntoSwitchRegions ( <nl> + S - > getIterator ( ) , Inst - > getIterator ( ) , CanSinkToSuccessor , AA , RCIA ) ; <nl> } <nl> <nl> + / / Handle the first instruction in the BB . <nl> + Changed | = tryTosinkIncrementsIntoSwitchRegions ( S - > getIterator ( ) , SI , <nl> + CanSinkToSuccessor , AA , RCIA ) ; <nl> return Changed ; <nl> } <nl> <nl> static bool processFunction ( SILFunction * F , AliasAnalysis * AA , <nl> <nl> bool Changed = false ; <nl> <nl> - BBToDataflowStateMap BBToStateMap ( PO ) ; <nl> + EnumCaseDataflowContext BBToStateMap ( PO ) ; <nl> for ( unsigned RPOIdx = 0 , RPOEnd = BBToStateMap . size ( ) ; RPOIdx < RPOEnd ; <nl> + + RPOIdx ) { <nl> <nl> static bool processFunction ( SILFunction * F , AliasAnalysis * AA , <nl> / / predecessors to avoid memory invalidation issues due to copying in the <nl> / / dense map . <nl> DEBUG ( llvm : : dbgs ( ) < < " Merging predecessors ! \ n " ) ; <nl> - State . mergePredecessorStates ( BBToStateMap ) ; <nl> + State . mergePredecessorStates ( ) ; <nl> <nl> / / If our predecessors cover any of our enum values , attempt to hoist <nl> / / releases up the CFG onto enum payloads or sink retains out of switch <nl> static bool processFunction ( SILFunction * F , AliasAnalysis * AA , <nl> / / predecessors since the hoisted releases will be on the enum payload <nl> / / instead of the enum itself . <nl> Changed | = canonicalizeRefCountInstrs ( State . getBB ( ) ) ; <nl> - Changed | = sinkCodeFromPredecessors ( State . getBB ( ) ) ; <nl> - Changed | = sinkArgumentsFromPredecessors ( State . getBB ( ) ) ; <nl> + Changed | = sinkCodeFromPredecessors ( BBToStateMap , State . getBB ( ) ) ; <nl> + Changed | = sinkArgumentsFromPredecessors ( BBToStateMap , State . getBB ( ) ) ; <nl> Changed | = sinkLiteralsFromPredecessors ( State . getBB ( ) ) ; <nl> / / Try to hoist release of a SILArgument to predecessors . <nl> Changed | = hoistSILArgumentReleaseInst ( State . getBB ( ) ) ; <nl> mmm a / test / SILOptimizer / earlycodemotion . sil <nl> ppp b / test / SILOptimizer / earlycodemotion . sil <nl> enum Optional < T > { <nl> case some ( T ) <nl> } <nl> <nl> + class Klass { } <nl> + <nl> sil @ user : $ @ convention ( thin ) ( Builtin . NativeObject ) - > ( ) <nl> sil @ user_int : $ @ convention ( thin ) ( Int ) - > ( ) <nl> sil @ optional_user : $ @ convention ( thin ) ( Optional < Builtin . Int32 > ) - > ( ) <nl> bb3 ( % 20 : $ Int ) : / / Preds : bb1 bb2 <nl> return % 23 : $ ( ) / / id : % 25 <nl> } <nl> <nl> + / / Make sure that we properly perform global blotting of values and do not crash <nl> + / / on this code . This will only fail reliably in ASAN builds of swift in such a <nl> + / / case . <nl> + sil @ test_global_blotting : $ @ convention ( thin ) ( ) - > ( ) { <nl> + bbBegin : <nl> + % 0a = enum $ Optional < Klass > , # Optional . none ! enumelt <nl> + cond_br undef , bb1 , bb2 <nl> + <nl> + bb1 : <nl> + br bb8 ( % 0a : $ Optional < Klass > ) <nl> + <nl> + bb2 : <nl> + % 0 = enum $ Optional < Klass > , # Optional . none ! enumelt <nl> + cond_br undef , bb7 , bb3 <nl> + <nl> + bb3 : <nl> + cond_br undef , bb4 , bb5 <nl> + <nl> + bb4 : <nl> + br bb6 <nl> + <nl> + bb5 : <nl> + br bb6 <nl> + <nl> + bb6 : <nl> + br bb9 <nl> + <nl> + bb7 : <nl> + br bb8 ( % 0 : $ Optional < Klass > ) <nl> + <nl> + bb8 ( % result : $ Optional < Klass > ) : <nl> + release_value % result : $ Optional < Klass > <nl> + br bb9 <nl> + <nl> + bb9 : <nl> + % 9999 = tuple ( ) <nl> + return % 9999 : $ ( ) <nl> + } <nl>
Merge pull request from gottesmm / rdar_36032876
apple/swift
12095924218f56bbe8c14b32671ccb0428fb2e8b
2017-12-20T00:09:16Z
mmm a / examples / vn_trader / run . py <nl> ppp b / examples / vn_trader / run . py <nl> <nl> # from vnpy . gateway . oes import OesGateway <nl> # from vnpy . gateway . okex import OkexGateway <nl> # from vnpy . gateway . huobi import HuobiGateway <nl> - # from vnpy . gateway . bitfinex import BitfinexGateway <nl> + from vnpy . gateway . bitfinex import BitfinexGateway <nl> # from vnpy . gateway . onetoken import OnetokenGateway <nl> from vnpy . gateway . okexf import OkexfGateway <nl> from vnpy . gateway . okexs import OkexsGateway <nl> def main ( ) : <nl> # main_engine . add_gateway ( OesGateway ) <nl> # main_engine . add_gateway ( OkexGateway ) <nl> # main_engine . add_gateway ( HuobiGateway ) <nl> - # main_engine . add_gateway ( BitfinexGateway ) <nl> + main_engine . add_gateway ( BitfinexGateway ) <nl> # main_engine . add_gateway ( OnetokenGateway ) <nl> # main_engine . add_gateway ( OkexfGateway ) <nl> # main_engine . add_gateway ( HbdmGateway ) <nl> mmm a / vnpy / gateway / bitfinex / bitfinex_gateway . py <nl> ppp b / vnpy / gateway / bitfinex / bitfinex_gateway . py <nl> def on_data_update ( self , data ) : <nl> <nl> # ASK <nl> ask_keys = ask . keys ( ) <nl> - askPriceList = sorted ( ask_keys , reverse = True ) <nl> + askPriceList = sorted ( ask_keys ) <nl> <nl> tick . ask_price_1 = askPriceList [ 0 ] <nl> tick . ask_price_2 = askPriceList [ 1 ] <nl>
[ Fix ] close
vnpy/vnpy
69f9a21c3e5ad3ea3cc10a279edfd1f757c23205
2019-09-17T15:41:10Z
mmm a / etc / evergreen . yml <nl> ppp b / etc / evergreen . yml <nl> tasks : <nl> crash_options : - - crashMethod = kill - - crashWaitTime = 45 - - jitterForCrashWaitTime = 5 - - instanceId = $ { instance_id } <nl> mongod_extra_options : - - mongodOptions = \ " - - setParameter enableTestCommands = 1 - - setParameter logComponentVerbosity = ' { storage : { recovery : 2 } } ' - - storageEngine wiredTiger \ " <nl> <nl> - - name : powercycle_fcv3 . 6 <nl> + - name : powercycle_fcv4 . 0 <nl> exec_timeout_secs : 7200 # 2 hour timeout for the task overall <nl> depends_on : <nl> - name : compile <nl> tasks : <nl> vars : <nl> < < : * powercycle_test <nl> client_options : - - numCrudClients = 20 - - numFsmClients = 20 <nl> - mongod_options : - - mongodUsablePorts $ { standard_port } $ { secret_port } - - dbPath = $ { db_path } - - logPath = $ { log_path } - - fcv = 3 . 6 <nl> + mongod_options : - - mongodUsablePorts $ { standard_port } $ { secret_port } - - dbPath = $ { db_path } - - logPath = $ { log_path } - - fcv = 4 . 0 <nl> mongod_extra_options : - - mongodOptions = \ " - - setParameter enableTestCommands = 1 - - setParameter logComponentVerbosity = ' { storage : { recovery : 2 } } ' - - storageEngine wiredTiger \ " <nl> <nl> - name : powercycle_replication <nl> buildvariants : <nl> - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - name : powercycle <nl> - - name : powercycle_fcv3 . 6 <nl> + - name : powercycle_fcv4 . 0 <nl> - name : powercycle_kill_mongod <nl> - name : powercycle_replication <nl> - name : powercycle_replication_smalloplog <nl> buildvariants : <nl> - name : parallel <nl> - name : parallel_compatibility <nl> - name : powercycle <nl> - - name : powercycle_fcv3 . 6 <nl> + - name : powercycle_fcv4 . 0 <nl> - name : powercycle_kill_mongod <nl> - name : powercycle_replication <nl> - name : powercycle_syncdelay <nl>
SERVER - 35959 Update powercycle_fcv3 . 6 to powercycle_fcv4 . 0
mongodb/mongo
96608712ee598b8fd4f0feb14daa1aa232c2c50b
2018-07-04T18:23:19Z
mmm a / xbmc / pvr / dialogs / GUIDialogPVRChannelsOSD . cpp <nl> ppp b / xbmc / pvr / dialogs / GUIDialogPVRChannelsOSD . cpp <nl> CGUIDialogPVRChannelsOSD : : ~ CGUIDialogPVRChannelsOSD ( ) <nl> { <nl> delete m_vecItems ; <nl> <nl> - if ( IsObserving ( g_infoManager ) ) <nl> - g_infoManager . UnregisterObserver ( this ) ; <nl> - if ( IsObserving ( g_EpgContainer ) ) <nl> - g_EpgContainer . UnregisterObserver ( this ) ; <nl> + g_infoManager . UnregisterObserver ( this ) ; <nl> + g_EpgContainer . UnregisterObserver ( this ) ; <nl> } <nl> <nl> bool CGUIDialogPVRChannelsOSD : : OnMessage ( CGUIMessage & message ) <nl> CPVRChannelGroupPtr CGUIDialogPVRChannelsOSD : : GetPlayingGroup ( ) <nl> <nl> void CGUIDialogPVRChannelsOSD : : Update ( ) <nl> { <nl> + g_infoManager . RegisterObserver ( this ) ; <nl> + g_EpgContainer . RegisterObserver ( this ) ; <nl> + <nl> / / lock our display , as this window is rendered from the player thread <nl> g_graphicsContext . Lock ( ) ; <nl> - <nl> - if ( ! IsObserving ( g_infoManager ) ) <nl> - g_infoManager . RegisterObserver ( this ) ; <nl> - if ( ! IsObserving ( g_EpgContainer ) ) <nl> - g_EpgContainer . RegisterObserver ( this ) ; <nl> - <nl> m_viewControl . SetCurrentView ( DEFAULT_VIEW_LIST ) ; <nl> <nl> / / empty the list ready for population <nl> mmm a / xbmc / utils / Observer . cpp <nl> ppp b / xbmc / utils / Observer . cpp <nl> <nl> <nl> # include < algorithm > <nl> <nl> - Observer : : ~ Observer ( void ) <nl> - { <nl> - StopObserving ( ) ; <nl> - } <nl> - <nl> - void Observer : : StopObserving ( void ) <nl> - { <nl> - CSingleLock lock ( m_obsCritSection ) ; <nl> - for ( auto & observable : m_observables ) <nl> - observable - > UnregisterObserver ( this ) ; <nl> - } <nl> - <nl> - bool Observer : : IsObserving ( const Observable & obs ) const <nl> - { <nl> - CSingleLock lock ( m_obsCritSection ) ; <nl> - return find ( m_observables . begin ( ) , m_observables . end ( ) , & obs ) ! = m_observables . end ( ) ; <nl> - } <nl> - <nl> - void Observer : : RegisterObservable ( Observable * obs ) <nl> - { <nl> - CSingleLock lock ( m_obsCritSection ) ; <nl> - if ( ! IsObserving ( * obs ) ) <nl> - m_observables . push_back ( obs ) ; <nl> - } <nl> - <nl> - void Observer : : UnregisterObservable ( Observable * obs ) <nl> - { <nl> - CSingleLock lock ( m_obsCritSection ) ; <nl> - std : : vector < Observable * > : : iterator it = find ( m_observables . begin ( ) , m_observables . end ( ) , obs ) ; <nl> - if ( it ! = m_observables . end ( ) ) <nl> - m_observables . erase ( it ) ; <nl> - } <nl> - <nl> - Observable : : Observable ( ) : <nl> - m_bObservableChanged ( false ) <nl> - { <nl> - } <nl> - <nl> - Observable : : ~ Observable ( ) <nl> - { <nl> - StopObserver ( ) ; <nl> - } <nl> - <nl> Observable & Observable : : operator = ( const Observable & observable ) <nl> { <nl> CSingleLock lock ( m_obsCritSection ) ; <nl> <nl> - m_bObservableChanged = observable . m_bObservableChanged ; <nl> - m_observers . clear ( ) ; <nl> - for ( unsigned int iObsPtr = 0 ; iObsPtr < observable . m_observers . size ( ) ; iObsPtr + + ) <nl> - m_observers . push_back ( observable . m_observers . at ( iObsPtr ) ) ; <nl> + m_bObservableChanged = static_cast < bool > ( observable . m_bObservableChanged ) ; <nl> + m_observers = observable . m_observers ; <nl> <nl> return * this ; <nl> } <nl> <nl> - void Observable : : StopObserver ( void ) <nl> - { <nl> - CSingleLock lock ( m_obsCritSection ) ; <nl> - for ( auto & observer : m_observers ) <nl> - observer - > UnregisterObservable ( this ) ; <nl> - } <nl> - <nl> bool Observable : : IsObserving ( const Observer & obs ) const <nl> { <nl> CSingleLock lock ( m_obsCritSection ) ; <nl> - return find ( m_observers . begin ( ) , m_observers . end ( ) , & obs ) ! = m_observers . end ( ) ; <nl> + return std : : find ( m_observers . begin ( ) , m_observers . end ( ) , & obs ) ! = m_observers . end ( ) ; <nl> } <nl> <nl> void Observable : : RegisterObserver ( Observer * obs ) <nl> void Observable : : RegisterObserver ( Observer * obs ) <nl> if ( ! IsObserving ( * obs ) ) <nl> { <nl> m_observers . push_back ( obs ) ; <nl> - obs - > RegisterObservable ( this ) ; <nl> } <nl> } <nl> <nl> void Observable : : UnregisterObserver ( Observer * obs ) <nl> { <nl> CSingleLock lock ( m_obsCritSection ) ; <nl> - std : : vector < Observer * > : : iterator it = find ( m_observers . begin ( ) , m_observers . end ( ) , obs ) ; <nl> - if ( it ! = m_observers . end ( ) ) <nl> - { <nl> - obs - > UnregisterObservable ( this ) ; <nl> - m_observers . erase ( it ) ; <nl> - } <nl> + std : : remove ( m_observers . begin ( ) , m_observers . end ( ) , obs ) ; <nl> } <nl> <nl> void Observable : : NotifyObservers ( const ObservableMessage message / * = ObservableMessageNone * / ) <nl> { <nl> - bool bNotify ( false ) ; <nl> - { <nl> - CSingleLock lock ( m_obsCritSection ) ; <nl> - if ( m_bObservableChanged ) <nl> - bNotify = true ; <nl> - m_bObservableChanged = false ; <nl> - } <nl> + / / Make sure the set / compare is atomic <nl> + / / so we don ' t clobber the variable in a race condition <nl> + auto bNotify = m_bObservableChanged . exchange ( false ) ; <nl> <nl> if ( bNotify ) <nl> SendMessage ( message ) ; <nl> void Observable : : NotifyObservers ( const ObservableMessage message / * = Observable <nl> <nl> void Observable : : SetChanged ( bool SetTo ) <nl> { <nl> - CSingleLock lock ( m_obsCritSection ) ; <nl> m_bObservableChanged = SetTo ; <nl> } <nl> <nl> void Observable : : SendMessage ( const ObservableMessage message ) <nl> { <nl> CSingleLock lock ( m_obsCritSection ) ; <nl> + <nl> for ( auto & observer : m_observers ) <nl> { <nl> observer - > Notify ( * this , message ) ; <nl> mmm a / xbmc / utils / Observer . h <nl> ppp b / xbmc / utils / Observer . h <nl> <nl> * / <nl> <nl> # include " threads / CriticalSection . h " <nl> + # include < atomic > <nl> # include < vector > <nl> <nl> class Observable ; <nl> typedef enum <nl> <nl> class Observer <nl> { <nl> - friend class Observable ; <nl> - <nl> public : <nl> - Observer ( void ) { } ; <nl> - virtual ~ Observer ( void ) ; <nl> - <nl> - / * ! <nl> - * @ brief Remove this observer from all observables . <nl> - * / <nl> - virtual void StopObserving ( void ) ; <nl> - <nl> - / * ! <nl> - * @ brief Check whether this observer is observing an observable . <nl> - * @ param obs The observable to check . <nl> - * @ return True if this observer is observing the given observable , false otherwise . <nl> - * / <nl> - virtual bool IsObserving ( const Observable & obs ) const ; <nl> - <nl> + Observer ( ) = default ; <nl> + virtual ~ Observer ( ) = default ; <nl> / * ! <nl> * @ brief Process a message from an observable . <nl> * @ param obs The observable that sends the message . <nl> * @ param msg The message . <nl> * / <nl> virtual void Notify ( const Observable & obs , const ObservableMessage msg ) = 0 ; <nl> - <nl> - protected : <nl> - / * ! <nl> - * @ brief Callback to register an observable . <nl> - * @ param obs The observable to register . <nl> - * / <nl> - virtual void RegisterObservable ( Observable * obs ) ; <nl> - <nl> - / * ! <nl> - * @ brief Callback to unregister an observable . <nl> - * @ param obs The observable to unregister . <nl> - * / <nl> - virtual void UnregisterObservable ( Observable * obs ) ; <nl> - <nl> - std : : vector < Observable * > m_observables ; / * ! < all observables that are watched * / <nl> - CCriticalSection m_obsCritSection ; / * ! < mutex * / <nl> } ; <nl> <nl> class Observable <nl> class Observable <nl> friend class ObservableMessageJob ; <nl> <nl> public : <nl> - Observable ( ) ; <nl> - virtual ~ Observable ( ) ; <nl> + Observable ( ) = default ; <nl> + virtual ~ Observable ( ) = default ; <nl> virtual Observable & operator = ( const Observable & observable ) ; <nl> <nl> - / * ! <nl> - * @ brief Remove this observable from all observers . <nl> - * / <nl> - virtual void StopObserver ( void ) ; <nl> - <nl> / * ! <nl> * @ brief Register an observer . <nl> * @ param obs The observer to register . <nl> class Observable <nl> * / <nl> void SendMessage ( const ObservableMessage message ) ; <nl> <nl> - bool m_bObservableChanged ; / * ! < true when the observable is marked as changed , false otherwise * / <nl> - std : : vector < Observer * > m_observers ; / * ! < all observers * / <nl> - CCriticalSection m_obsCritSection ; / * ! < mutex * / <nl> + std : : atomic < bool > m_bObservableChanged { false } ; / * ! < true when the observable is marked as changed , false otherwise * / <nl> + std : : vector < Observer * > m_observers ; / * ! < all observers * / <nl> + CCriticalSection m_obsCritSection ; / * ! < mutex * / <nl> } ; <nl>
Merge pull request from Paxxi / observer
xbmc/xbmc
16d30f32ba193e31c1d215aef8f62ba6cb81b74d
2016-08-02T09:09:40Z
mmm a / Telegram / SourceFiles / ui / text / text_entity . cpp <nl> ppp b / Telegram / SourceFiles / ui / text / text_entity . cpp <nl> MarkdownPart GetMarkdownPart ( EntityInTextType type , const QString & text , int mat <nl> Unexpected ( " Type in GetMardownPart ( ) " ) ; <nl> } ; <nl> <nl> + if ( matchFromOffset > 1 ) { <nl> + / / If matchFromOffset is after some separator that is allowed to <nl> + / / start our markdown tag the tag itself will start where we want it . <nl> + / / So we allow to see this separator and make a match . <nl> + - - matchFromOffset ; <nl> + } <nl> auto match = regexp ( ) . match ( text , matchFromOffset ) ; <nl> if ( ! match . hasMatch ( ) ) { <nl> return result ; <nl>
Improve markdown parsing .
telegramdesktop/tdesktop
8550099110dc2d90412bad4bd6826ea85c1522dc
2017-07-06T15:59:38Z
deleted file mode 100644 <nl> index 72ef68dc8 . . 000000000 <nl> mmm a / include / tesseract / apitypes . h <nl> ppp / dev / null <nl> <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / File : apitypes . h <nl> - / / Description : Types used in both the API and internally <nl> - / / Author : Ray Smith <nl> - / / <nl> - / / ( C ) Copyright 2010 , Google Inc . <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> - / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> - / / Unless required by applicable law or agreed to in writing , software <nl> - / / distributed under the License is distributed on an " AS IS " BASIS , <nl> - / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> - / / See the License for the specific language governing permissions and <nl> - / / limitations under the License . <nl> - / / <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - # ifndef TESSERACT_API_APITYPES_H_ <nl> - # define TESSERACT_API_APITYPES_H_ <nl> - <nl> - # include " publictypes . h " <nl> - <nl> - / / The types used by the API and Page / ResultIterator can be found in : <nl> - / / ccstruct / publictypes . h <nl> - / / ccmain / resultiterator . h <nl> - / / ccmain / pageiterator . h <nl> - / / API interfaces and API users should be sure to include this file , rather <nl> - / / than the lower - level one , and lower - level code should be sure to include <nl> - / / only the lower - level file . <nl> - <nl> - # endif / / TESSERACT_API_APITYPES_H_ <nl> mmm a / include / tesseract / baseapi . h <nl> ppp b / include / tesseract / baseapi . h <nl> <nl> # include " config_auto . h " / / DISABLED_LEGACY_ENGINE <nl> # endif <nl> <nl> - # include " apitypes . h " <nl> # include " pageiterator . h " <nl> # include " platform . h " <nl> # include " publictypes . h " <nl>
Remove public empty header .
tesseract-ocr/tesseract
8bd1227c3ebfc9eaaea14c07bdc325482cd92359
2020-12-30T23:05:47Z
mmm a / tensorflow / python / training / queue_runner_test . py <nl> ppp b / tensorflow / python / training / queue_runner_test . py <nl> def testGracePeriod ( self ) : <nl> coord . request_stop ( ) <nl> # We should be able to join because the RequestStop ( ) will cause <nl> # the queue to be closed and the enqueue to terminate . <nl> - coord . join ( stop_grace_period_secs = 0 . 05 ) <nl> + coord . join ( stop_grace_period_secs = 1 . 0 ) <nl> <nl> def testMultipleSessions ( self ) : <nl> with self . test_session ( ) as sess : <nl>
Fix : Bump the grace period in queue_runner_test .
tensorflow/tensorflow
3921ed26bf22c761a8a82d2c2736bf694158ad64
2017-01-20T21:25:14Z
mmm a / tests / hello_world_gles . c <nl> ppp b / tests / hello_world_gles . c <nl> main ( int argc , char * argv [ ] ) <nl> glutCreateWindow ( " es2gears " ) ; <nl> <nl> / * Set up glut callback functions * / <nl> - glutIdleFunc ( gears_idle ) ; <nl> + gears_idle ( ) ; <nl> glutReshapeFunc ( gears_reshape ) ; <nl> glutDisplayFunc ( gears_draw ) ; <nl> glutSpecialFunc ( gears_special ) ; <nl>
Disable the animation in the test to make it more robust
emscripten-core/emscripten
e254b0fdf6e011f497e4ec12743aecc572a1020c
2012-01-27T23:04:11Z
mmm a / servers / physics_2d / broad_phase_2d_hash_grid . cpp <nl> ppp b / servers / physics_2d / broad_phase_2d_hash_grid . cpp <nl> int BroadPhase2DHashGrid : : cull_segment ( const Vector2 & p_from , const Vector2 & p_t <nl> delta . x = cell_size / delta . x ; <nl> delta . y = cell_size / delta . y ; <nl> <nl> - Point2i pos = p_from . floor ( ) / cell_size ; <nl> - Point2i end = p_to . floor ( ) / cell_size ; <nl> - Point2i step = Vector2 ( SGN ( dir . x ) , SGN ( dir . y ) ) ; <nl> + Point2i pos = ( p_from / cell_size ) . floor ( ) ; <nl> + Point2i end = ( p_to / cell_size ) . floor ( ) ; <nl> + <nl> + Point2i step = Vector2 ( SGN ( dir . x ) , SGN ( dir . y ) ) ; <nl> <nl> Vector2 max ; <nl> <nl>
casting line into physics on negative space now works properly , fixes
godotengine/godot
f971ae32e1f16e453afdc4fd11cb29f8f3b0cf2a
2015-04-25T01:41:31Z
mmm a / src / mongo / db / index_builds_coordinator . cpp <nl> ppp b / src / mongo / db / index_builds_coordinator . cpp <nl> void IndexBuildsCoordinator : : _runIndexBuildInner ( OperationContext * opCtx , <nl> / / Set up the thread ' s currentOp information to display createIndexes cmd information . <nl> _updateCurOpOpDescription ( opCtx , * nss , replState - > indexSpecs ) ; <nl> <nl> - AutoGetDb autoDb ( opCtx , nss - > db ( ) , MODE_IX ) ; <nl> - <nl> - / / Do not use AutoGetCollection since the lock will be in various modes throughout the index <nl> - / / build . <nl> - boost : : optional < Lock : : CollectionLock > collLock ; <nl> - collLock . emplace ( opCtx , * nss , MODE_X ) ; <nl> + / / Do not use AutoGetOrCreateDb because we may relock the database in mode IX . <nl> + boost : : optional < Lock : : DBLock > dbLock ; <nl> + dbLock . emplace ( opCtx , nss - > db ( ) , MODE_X ) ; <nl> <nl> / / Allow the strong lock acquisition above to be interrupted , but from this point forward do <nl> / / not allow locks or re - locks to be interrupted . <nl> void IndexBuildsCoordinator : : _runIndexBuildInner ( OperationContext * opCtx , <nl> / / accordingly ( checkForInterrupt ( ) will throw an exception while <nl> / / checkForInterruptNoAssert ( ) returns an error Status ) . <nl> opCtx - > runWithoutInterruptionExceptAtGlobalShutdown ( <nl> - [ & , this ] { _buildIndex ( opCtx , collection , * nss , replState , & collLock ) ; } ) ; <nl> + [ & , this ] { _buildIndex ( opCtx , collection , * nss , replState , & * dbLock ) ; } ) ; <nl> } else { <nl> - _buildIndex ( opCtx , collection , * nss , replState , & collLock ) ; <nl> + _buildIndex ( opCtx , collection , * nss , replState , & * dbLock ) ; <nl> } <nl> replState - > stats . numIndexesAfter = _getNumIndexesTotal ( opCtx , collection ) ; <nl> status = Status : : OK ( ) ; <nl> void IndexBuildsCoordinator : : _runIndexBuildInner ( OperationContext * opCtx , <nl> status = ex . toStatus ( ) ; <nl> } <nl> <nl> + / / We could return from _buildIndex without the DBLock , if the build was interrupted while <nl> + / / yielding . <nl> + if ( ! opCtx - > lockState ( ) - > isDbLockedForMode ( replState - > dbName , MODE_X ) ) { <nl> + dbLock . reset ( ) ; / / Might still have the Global lock , so be sure to clear it out first here . <nl> + dbLock . emplace ( opCtx , nss - > db ( ) , MODE_X ) ; <nl> + } <nl> + <nl> if ( replSetAndNotPrimary & & status = = ErrorCodes : : InterruptedAtShutdown ) { <nl> / / Leave it as - if kill - 9 happened . This will be handled on restart . <nl> _indexBuildsManager . interruptIndexBuild ( opCtx , replState - > buildUUID , " shutting down " ) ; <nl> void IndexBuildsCoordinator : : _buildIndex ( OperationContext * opCtx , <nl> Collection * collection , <nl> const NamespaceString & nss , <nl> std : : shared_ptr < ReplIndexBuildState > replState , <nl> - boost : : optional < Lock : : CollectionLock > * collLock ) { <nl> - invariant ( opCtx - > lockState ( ) - > isDbLockedForMode ( nss . db ( ) , MODE_IX ) ) ; <nl> - invariant ( opCtx - > lockState ( ) - > isCollectionLockedForMode ( nss , MODE_X ) ) ; <nl> - invariant ( _indexBuildsManager . isBackgroundBuilding ( replState - > buildUUID ) ) ; <nl> + Lock : : DBLock * dbLock ) { <nl> + invariant ( opCtx - > lockState ( ) - > isDbLockedForMode ( replState - > dbName , MODE_X ) ) ; <nl> + <nl> <nl> / / Index builds can safely ignore prepare conflicts . On secondaries , prepare operations wait for <nl> / / index builds to complete . <nl> opCtx - > recoveryUnit ( ) - > abandonSnapshot ( ) ; <nl> opCtx - > recoveryUnit ( ) - > setIgnorePrepared ( true ) ; <nl> <nl> + / / If we ' re a background index , replace exclusive db lock with an intent lock , so that <nl> + / / other readers and writers can proceed during this phase . <nl> + if ( _indexBuildsManager . isBackgroundBuilding ( replState - > buildUUID ) ) { <nl> + dbLock - > relockWithMode ( MODE_IX ) ; <nl> + } <nl> + <nl> / / Collection scan and insert into index , followed by a drain of writes received in the <nl> / / background . <nl> - collLock - > emplace ( opCtx , nss , MODE_IX ) ; <nl> - uassertStatusOK ( <nl> - _indexBuildsManager . startBuildingIndex ( opCtx , collection , replState - > buildUUID ) ) ; <nl> + { <nl> + Lock : : CollectionLock colLock ( opCtx , nss , MODE_IX ) ; <nl> + uassertStatusOK ( <nl> + _indexBuildsManager . startBuildingIndex ( opCtx , collection , replState - > buildUUID ) ) ; <nl> + } <nl> <nl> if ( MONGO_FAIL_POINT ( hangAfterIndexBuildDumpsInsertsFromBulk ) ) { <nl> log ( ) < < " Hanging after dumping inserts from bulk builder " ; <nl> void IndexBuildsCoordinator : : _buildIndex ( OperationContext * opCtx , <nl> } <nl> <nl> / / Perform the first drain while holding an intent lock . <nl> - opCtx - > recoveryUnit ( ) - > abandonSnapshot ( ) ; <nl> - collLock - > emplace ( opCtx , nss , MODE_IS ) ; <nl> - uassertStatusOK ( _indexBuildsManager . drainBackgroundWrites ( <nl> - opCtx , replState - > buildUUID , RecoveryUnit : : ReadSource : : kUnset ) ) ; <nl> + { <nl> + opCtx - > recoveryUnit ( ) - > abandonSnapshot ( ) ; <nl> + Lock : : CollectionLock colLock ( opCtx , nss , MODE_IS ) ; <nl> + <nl> + uassertStatusOK ( _indexBuildsManager . drainBackgroundWrites ( <nl> + opCtx , replState - > buildUUID , RecoveryUnit : : ReadSource : : kUnset ) ) ; <nl> + } <nl> <nl> if ( MONGO_FAIL_POINT ( hangAfterIndexBuildFirstDrain ) ) { <nl> log ( ) < < " Hanging after index build first drain " ; <nl> void IndexBuildsCoordinator : : _buildIndex ( OperationContext * opCtx , <nl> } <nl> <nl> / / Perform the second drain while stopping writes on the collection . <nl> - opCtx - > recoveryUnit ( ) - > abandonSnapshot ( ) ; <nl> - collLock - > emplace ( opCtx , nss , MODE_S ) ; <nl> - uassertStatusOK ( _indexBuildsManager . drainBackgroundWrites ( <nl> - opCtx , replState - > buildUUID , RecoveryUnit : : ReadSource : : kUnset ) ) ; <nl> + { <nl> + opCtx - > recoveryUnit ( ) - > abandonSnapshot ( ) ; <nl> + Lock : : CollectionLock colLock ( opCtx , nss , MODE_S ) ; <nl> + <nl> + uassertStatusOK ( _indexBuildsManager . drainBackgroundWrites ( <nl> + opCtx , replState - > buildUUID , RecoveryUnit : : ReadSource : : kUnset ) ) ; <nl> + } <nl> <nl> if ( MONGO_FAIL_POINT ( hangAfterIndexBuildSecondDrain ) ) { <nl> log ( ) < < " Hanging after index build second drain " ; <nl> MONGO_FAIL_POINT_PAUSE_WHILE_SET ( hangAfterIndexBuildSecondDrain ) ; <nl> } <nl> <nl> - / / Need to return the collection lock back to exclusive mode , to complete the index build . <nl> - opCtx - > recoveryUnit ( ) - > abandonSnapshot ( ) ; <nl> - collLock - > emplace ( opCtx , nss , MODE_X ) ; <nl> - <nl> - / / We hold the database MODE_IX lock throughout the index build . <nl> - auto db = DatabaseHolder : : get ( opCtx ) - > getDb ( opCtx , nss . db ( ) ) ; <nl> - if ( db ) { <nl> - auto & dss = DatabaseShardingState : : get ( db ) ; <nl> - auto dssLock = DatabaseShardingState : : DSSLock : : lock ( opCtx , & dss ) ; <nl> - dss . checkDbVersion ( opCtx , dssLock ) ; <nl> - } <nl> + / / Need to return db lock back to exclusive , to complete the index build . <nl> + if ( _indexBuildsManager . isBackgroundBuilding ( replState - > buildUUID ) ) { <nl> + opCtx - > recoveryUnit ( ) - > abandonSnapshot ( ) ; <nl> + dbLock - > relockWithMode ( MODE_X ) ; <nl> <nl> - invariant ( db , <nl> - str : : stream ( ) < < " Database not found after relocking . Index build : " <nl> - < < replState - > buildUUID <nl> - < < " : " <nl> - < < nss <nl> - < < " ( " <nl> - < < replState - > collectionUUID <nl> - < < " ) " ) ; <nl> - <nl> - invariant ( db - > getCollection ( opCtx , nss ) , <nl> - str : : stream ( ) < < " Collection not found after relocking . Index build : " <nl> - < < replState - > buildUUID <nl> - < < " : " <nl> - < < nss <nl> - < < " ( " <nl> - < < replState - > collectionUUID <nl> - < < " ) " ) ; <nl> + auto db = DatabaseHolder : : get ( opCtx ) - > getDb ( opCtx , nss . db ( ) ) ; <nl> + if ( db ) { <nl> + auto & dss = DatabaseShardingState : : get ( db ) ; <nl> + auto dssLock = DatabaseShardingState : : DSSLock : : lock ( opCtx , & dss ) ; <nl> + dss . checkDbVersion ( opCtx , dssLock ) ; <nl> + } <nl> + <nl> + invariant ( db , <nl> + str : : stream ( ) < < " Database not found after relocking . Index build : " <nl> + < < replState - > buildUUID <nl> + < < " : " <nl> + < < nss <nl> + < < " ( " <nl> + < < replState - > collectionUUID <nl> + < < " ) " ) ; <nl> + invariant ( db - > getCollection ( opCtx , nss ) , <nl> + str : : stream ( ) < < " Collection not found after relocking . Index build : " <nl> + < < replState - > buildUUID <nl> + < < " : " <nl> + < < nss <nl> + < < " ( " <nl> + < < replState - > collectionUUID <nl> + < < " ) " ) ; <nl> + } <nl> <nl> / / Perform the third and final drain after releasing a shared lock and reacquiring an <nl> / / exclusive lock on the database . <nl> mmm a / src / mongo / db / index_builds_coordinator . h <nl> ppp b / src / mongo / db / index_builds_coordinator . h <nl> class IndexBuildsCoordinator { <nl> Collection * collection , <nl> const NamespaceString & nss , <nl> std : : shared_ptr < ReplIndexBuildState > replState , <nl> - boost : : optional < Lock : : CollectionLock > * collLock ) ; <nl> + Lock : : DBLock * dbLock ) ; <nl> / * * <nl> * Returns total number of indexes in collection , including unfinished / in - progress indexes . <nl> * <nl>
Revert " SERVER - 41141 Remove DB X lock acquisition for secondary index builds "
mongodb/mongo
16a18a5370f276ca5ec91bfc13b2738390b319e8
2019-06-03T15:13:18Z
mmm a / src / arch / io / network . cc <nl> ppp b / src / arch / io / network . cc <nl> linux_nonthrowing_tcp_listener_t : : linux_nonthrowing_tcp_listener_t ( <nl> <nl> bool linux_nonthrowing_tcp_listener_t : : begin_listening ( ) { <nl> if ( ! bound & & ! bind_sockets ( ) ) { <nl> - logERR ( " Could not bind to port % d " , port ) ; <nl> return false ; <nl> } <nl> <nl> mmm a / src / arch / types . hpp <nl> ppp b / src / arch / types . hpp <nl> class address_in_use_exc_t : public std : : exception { <nl> info = strprintf ( " The address at % s : % d is reserved or already in use " , hostname , port ) ; <nl> } <nl> } <nl> + <nl> + address_in_use_exc_t ( const std : : string & msg ) throw ( ) { <nl> + info . assign ( msg ) ; <nl> + } <nl> + <nl> ~ address_in_use_exc_t ( ) throw ( ) { } <nl> <nl> const char * what ( ) const throw ( ) { <nl> mmm a / src / clustering / administration / main / serve . cc <nl> ppp b / src / clustering / administration / main / serve . cc <nl> bool do_serve ( <nl> metadata_field ( & cluster_semilattice_metadata_t : : machines , semilattice_manager_cluster . get_root_view ( ) ) ) ; <nl> <nl> message_multiplexer_t : : run_t message_multiplexer_run ( & message_multiplexer ) ; <nl> - connectivity_cluster_t : : run_t connectivity_cluster_run ( & connectivity_cluster , <nl> - address_ports . local_addresses , <nl> - address_ports . port , <nl> - & message_multiplexer_run , <nl> - address_ports . client_port , <nl> - & heartbeat_manager ) ; <nl> + object_buffer_t < connectivity_cluster_t : : run_t > connectivity_cluster_run ; <nl> + <nl> + try { <nl> + connectivity_cluster_run . create ( & connectivity_cluster , <nl> + address_ports . local_addresses , <nl> + address_ports . port , <nl> + & message_multiplexer_run , <nl> + address_ports . client_port , <nl> + & heartbeat_manager ) ; <nl> + } catch ( const address_in_use_exc_t & ex ) { <nl> + throw address_in_use_exc_t ( strprintf ( " Could not bind to cluster port : % s " , ex . what ( ) ) ) ; <nl> + } <nl> <nl> / / If ( 0 = = port ) , then we asked the OS to give us a port number . <nl> if ( address_ports . port ! = 0 ) { <nl> - guarantee ( address_ports . port = = connectivity_cluster_run . get_port ( ) ) ; <nl> + guarantee ( address_ports . port = = connectivity_cluster_run - > get_port ( ) ) ; <nl> } <nl> - logINF ( " Listening for intracluster connections on port % d \ n " , connectivity_cluster_run . get_port ( ) ) ; <nl> + logINF ( " Listening for intracluster connections on port % d \ n " , connectivity_cluster_run - > get_port ( ) ) ; <nl> <nl> auto_reconnector_t auto_reconnector ( <nl> & connectivity_cluster , <nl> - & connectivity_cluster_run , <nl> + connectivity_cluster_run . get ( ) , <nl> directory_read_manager . get_root_view ( ) - > subview ( <nl> field_getter_t < machine_id_t , cluster_directory_metadata_t > ( & cluster_directory_metadata_t : : machine_id ) ) , <nl> metadata_field ( & cluster_semilattice_metadata_t : : machines , semilattice_manager_cluster . get_root_view ( ) ) ) ; <nl> bool do_serve ( <nl> <nl> scoped_ptr_t < initial_joiner_t > initial_joiner ; <nl> if ( ! joins . empty ( ) ) { <nl> - initial_joiner . init ( new initial_joiner_t ( & connectivity_cluster , & connectivity_cluster_run , joins ) ) ; <nl> + initial_joiner . init ( new initial_joiner_t ( & connectivity_cluster , connectivity_cluster_run . get ( ) , joins ) ) ; <nl> try { <nl> wait_interruptible ( initial_joiner - > get_ready_signal ( ) , stop_cond ) ; <nl> } catch ( const interrupted_exc_t & ) { <nl> bool do_serve ( <nl> logINF ( " Storage engine shut down . \ n " ) ; <nl> <nl> } catch ( const address_in_use_exc_t & ex ) { <nl> - logERR ( " % s . Cannot bind to cluster port . Exiting . \ n " , ex . what ( ) ) ; <nl> + logERR ( " % s . \ n " , ex . what ( ) ) ; <nl> return false ; <nl> } <nl> <nl> mmm a / src / containers / object_buffer . hpp <nl> ppp b / src / containers / object_buffer . hpp <nl> class object_buffer_t { <nl> T * create ( const Args & . . . args ) { <nl> rassert ( state = = EMPTY ) ; <nl> state = CONSTRUCTING ; <nl> - new ( & object_data [ 0 ] ) T ( args . . . ) ; <nl> + try { <nl> + new ( & object_data [ 0 ] ) T ( args . . . ) ; <nl> + } catch ( . . . ) { <nl> + state = EMPTY ; <nl> + throw ; <nl> + } <nl> state = INSTANTIATED ; <nl> return get ( ) ; <nl> } <nl> mmm a / src / http / http . cc <nl> ppp b / src / http / http . cc <nl> http_server_t : : http_server_t ( const std : : set < ip_address_t > & local_addresses , <nl> int port , <nl> http_app_t * _application ) : <nl> application ( _application ) { <nl> - boost : : optional < address_in_use_exc_t > address_exception ; <nl> try { <nl> tcp_listener . init ( new tcp_listener_t ( local_addresses , port , boost : : bind ( & http_server_t : : handle_conn , this , _1 , auto_drainer_t : : lock_t ( & auto_drainer ) ) ) ) ; <nl> } catch ( const address_in_use_exc_t & ex ) { <nl> - / / Super awkward , but we can ' t crash in an exception clause and still log the error <nl> - address_exception . reset ( ex ) ; <nl> - } <nl> - <nl> - if ( address_exception ) { <nl> - nice_crash ( " % s . Could not bind to http port . Exiting . \ n " , address_exception - > what ( ) ) ; <nl> + throw address_in_use_exc_t ( strprintf ( " Could not bind to http port : % s " , ex . what ( ) ) ) ; <nl> } <nl> } <nl> <nl> mmm a / src / protob / protob . tcc <nl> ppp b / src / protob / protob . tcc <nl> protob_server_t < request_t , response_t , context_t > : : protob_server_t ( <nl> rassert ( s = = & shutting_down_conds [ i ] ) ; <nl> } <nl> <nl> - boost : : optional < address_in_use_exc_t > address_exception ; <nl> try { <nl> tcp_listener . init ( new tcp_listener_t ( <nl> local_addresses , <nl> protob_server_t < request_t , response_t , context_t > : : protob_server_t ( <nl> boost : : bind ( & protob_server_t < request_t , response_t , context_t > : : handle_conn , <nl> this , _1 , auto_drainer_t : : lock_t ( & auto_drainer ) ) ) ) ; <nl> } catch ( const address_in_use_exc_t & ex ) { <nl> - / / Super awkward , but we can ' t crash in an exception clause and still log the error <nl> - address_exception . reset ( ex ) ; <nl> - } <nl> - <nl> - if ( address_exception ) { <nl> - nice_crash ( " % s . Cannot bind to RDB protocol port . Exiting . \ n " , address_exception - > what ( ) ) ; <nl> + throw address_in_use_exc_t ( strprintf ( " Could not bind to RDB protocol port : % s " , ex . what ( ) ) ) ; <nl> } <nl> } <nl> template < class request_t , class response_t , class context_t > <nl>
stopped using nice_crash in exceptions , just because it ' s a little silly , unified address in use exception catching , and fixed a bug in object_buffer_t when create ( ) causes an exception
rethinkdb/rethinkdb
f5a6c0071e8d4656bf6aadf62e7712567dae76d9
2013-07-11T20:19:03Z
mmm a / src / reactor / ReactorPoll . c <nl> ppp b / src / reactor / ReactorPoll . c <nl> int swReactorPoll_create ( swReactor * reactor , int max_fd_num ) <nl> if ( object - > fds = = NULL ) <nl> { <nl> swWarn ( " malloc [ 1 ] failed " ) ; <nl> + sw_free ( object ) ; <nl> return SW_ERR ; <nl> } <nl> object - > events = sw_calloc ( max_fd_num , sizeof ( struct pollfd ) ) ; <nl> if ( object - > events = = NULL ) <nl> { <nl> swWarn ( " malloc [ 2 ] failed " ) ; <nl> + sw_free ( object ) ; <nl> return SW_ERR ; <nl> } <nl> object - > max_fd_num = max_fd_num ; <nl>
Merge pull request from tutanhamon / patch - 11
swoole/swoole-src
2d8bc75a03433446138b75bc7a98c4e634077651
2017-01-31T13:57:02Z
mmm a / tensorflow / compiler / xla / service / cpu / xfeed_manager_test . cc <nl> ppp b / tensorflow / compiler / xla / service / cpu / xfeed_manager_test . cc <nl> TEST_F ( InfeedManagerTest , MultiThreaded ) { <nl> <nl> const int32 length = 64 ; <nl> <nl> - pool . Schedule ( [ xfeed ] ( ) { <nl> + pool . Schedule ( [ length , & xfeed ] ( ) { <nl> / / Spin for 100 milliseconds <nl> int64 start_micros = tensorflow : : Env : : Default ( ) - > NowMicros ( ) ; <nl> while ( true ) { <nl> mmm a / tensorflow / compiler / xla / service / hlo_memory_scheduler_test . cc <nl> ppp b / tensorflow / compiler / xla / service / hlo_memory_scheduler_test . cc <nl> ENTRY entry { <nl> <nl> TEST_F ( HloSchedulingTest , TuplesAreAccountedCorrectly ) { <nl> auto builder = HloComputation : : Builder ( TestName ( ) ) ; <nl> - const auto TUPLE_SIZE = 1 ; <nl> const Shape r1f32 = ShapeUtil : : MakeShape ( xla : : F32 , { 6 } ) ; <nl> <nl> / / Wrap lit in abs because constants are considered free by <nl> TEST_F ( HloSchedulingTest , TuplesAreAccountedCorrectly ) { <nl> ScheduleModule ( <nl> module . get ( ) , <nl> [ ] ( const BufferValue & buffer ) { <nl> - return ShapeUtil : : ByteSizeOf ( buffer . shape ( ) , TUPLE_SIZE ) ; <nl> + return ShapeUtil : : ByteSizeOf ( buffer . shape ( ) , 1 ) ; <nl> } , <nl> ComputationSchedulerToModuleScheduler ( ListMemoryScheduler ) ) ) ; <nl> <nl>
Explicitly tell lambdas to capture existing local variables by copy .
tensorflow/tensorflow
a1e96a58eadf21e532bb36e52aca0a222d39f446
2020-02-05T22:52:20Z
new file mode 100755 <nl> index 000000000000 . . 3b1654f92077 <nl> mmm / dev / null <nl> ppp b / test / functional / p2p_invalid_locator . py <nl> <nl> + # ! / usr / bin / env python3 <nl> + # Copyright ( c ) 2015 - 2017 The Bitcoin Core developers <nl> + # Distributed under the MIT software license , see the accompanying <nl> + # file COPYING or http : / / www . opensource . org / licenses / mit - license . php . <nl> + " " " Test node responses to invalid locators . <nl> + " " " <nl> + <nl> + from test_framework . messages import msg_getheaders , msg_getblocks , MAX_LOCATOR_SZ <nl> + from test_framework . mininode import P2PInterface <nl> + from test_framework . test_framework import BitcoinTestFramework <nl> + <nl> + <nl> + class InvalidLocatorTest ( BitcoinTestFramework ) : <nl> + def set_test_params ( self ) : <nl> + self . num_nodes = 1 <nl> + self . setup_clean_chain = False <nl> + <nl> + def run_test ( self ) : <nl> + node = self . nodes [ 0 ] # convenience reference to the node <nl> + node . generate ( 1 ) # Get node out of IBD <nl> + <nl> + self . log . info ( ' Test max locator size ' ) <nl> + block_count = node . getblockcount ( ) <nl> + for msg in [ msg_getheaders ( ) , msg_getblocks ( ) ] : <nl> + self . log . info ( ' Wait for disconnect when sending { } hashes in locator ' . format ( MAX_LOCATOR_SZ + 1 ) ) <nl> + node . add_p2p_connection ( P2PInterface ( ) ) <nl> + msg . locator . vHave = [ int ( node . getblockhash ( i - 1 ) , 16 ) for i in range ( block_count , block_count - ( MAX_LOCATOR_SZ + 1 ) , - 1 ) ] <nl> + node . p2p . send_message ( msg ) <nl> + node . p2p . wait_for_disconnect ( ) <nl> + node . disconnect_p2ps ( ) <nl> + <nl> + self . log . info ( ' Wait for response when sending { } hashes in locator ' . format ( MAX_LOCATOR_SZ ) ) <nl> + node . add_p2p_connection ( P2PInterface ( ) ) <nl> + msg . locator . vHave = [ int ( node . getblockhash ( i - 1 ) , 16 ) for i in range ( block_count , block_count - ( MAX_LOCATOR_SZ ) , - 1 ) ] <nl> + node . p2p . send_message ( msg ) <nl> + if type ( msg ) = = msg_getheaders : <nl> + node . p2p . wait_for_header ( int ( node . getbestblockhash ( ) , 16 ) ) <nl> + else : <nl> + node . p2p . wait_for_block ( int ( node . getbestblockhash ( ) , 16 ) ) <nl> + <nl> + <nl> + if __name__ = = ' __main__ ' : <nl> + InvalidLocatorTest ( ) . main ( ) <nl> mmm a / test / functional / test_framework / messages . py <nl> ppp b / test / functional / test_framework / messages . py <nl> <nl> MY_RELAY = 1 # from version 70001 onwards , fRelay should be appended to version messages ( BIP37 ) <nl> <nl> MAX_INV_SZ = 50000 <nl> + MAX_LOCATOR_SZ = 101 <nl> MAX_BLOCK_BASE_SIZE = 1000000 <nl> <nl> COIN = 100000000 # 1 btc in satoshis <nl> mmm a / test / functional / test_framework / mininode . py <nl> ppp b / test / functional / test_framework / mininode . py <nl> def wait_for_block ( self , blockhash , timeout = 60 ) : <nl> test_function = lambda : self . last_message . get ( " block " ) and self . last_message [ " block " ] . block . rehash ( ) = = blockhash <nl> wait_until ( test_function , timeout = timeout , lock = mininode_lock ) <nl> <nl> + def wait_for_header ( self , blockhash , timeout = 60 ) : <nl> + def test_function ( ) : <nl> + last_headers = self . last_message . get ( ' headers ' ) <nl> + if not last_headers : <nl> + return False <nl> + return last_headers . headers [ 0 ] . rehash ( ) = = blockhash <nl> + <nl> + wait_until ( test_function , timeout = timeout , lock = mininode_lock ) <nl> + <nl> def wait_for_getdata ( self , timeout = 60 ) : <nl> " " " Waits for a getdata message . <nl> <nl> mmm a / test / functional / test_runner . py <nl> ppp b / test / functional / test_runner . py <nl> <nl> ' wallet_keypool . py ' , <nl> ' p2p_mempool . py ' , <nl> ' mining_prioritisetransaction . py ' , <nl> + ' p2p_invalid_locator . py ' , <nl> ' p2p_invalid_block . py ' , <nl> ' p2p_invalid_tx . py ' , <nl> ' rpc_createmultisig . py ' , <nl>
Merge : [ qa ] Add test for max number of entries in locator
bitcoin/bitcoin
a04888a075506c3cafe1d188c204bcb440089566
2018-08-11T10:59:14Z
mmm a / programs / launcher / CMakeLists . txt <nl> ppp b / programs / launcher / CMakeLists . txt <nl> configure_file ( config . hpp . in config . hpp ESCAPE_QUOTES ) <nl> target_include_directories ( launcher PUBLIC $ { CMAKE_CURRENT_BINARY_DIR } ) <nl> <nl> target_link_libraries ( launcher <nl> - PRIVATE fc $ { CMAKE_DL_LIBS } $ { PLATFORM_SPECIFIC_LIBS } ) <nl> + PRIVATE fc eos_native_contract $ { CMAKE_DL_LIBS } $ { PLATFORM_SPECIFIC_LIBS } ) <nl> <nl> install ( TARGETS <nl> launcher <nl> mmm a / programs / launcher / main . cpp <nl> ppp b / programs / launcher / main . cpp <nl> <nl> # include < sys / types . h > <nl> # include < netinet / in . h > <nl> # include < net / if . h > <nl> + # include < eos / native_contract / native_contract_chain_initializer . hpp > <nl> <nl> # include " config . hpp " <nl> <nl> using boost : : asio : : ip : : host_name ; <nl> using bpo : : options_description ; <nl> using bpo : : variables_map ; <nl> <nl> - struct localIdentity { <nl> + struct local_identity { <nl> vector < fc : : ip : : address > addrs ; <nl> vector < string > names ; <nl> <nl> void initialize ( ) { <nl> names . push_back ( " localhost " ) ; <nl> + names . push_back ( " 127 . 0 . 0 . 1 " ) ; <nl> + <nl> boost : : system : : error_code ec ; <nl> string hn = host_name ( ec ) ; <nl> if ( ec . value ( ) ! = boost : : system : : errc : : success ) { <nl> struct keypair { <nl> { } <nl> } ; <nl> <nl> - struct eosd_def { <nl> - eosd_def ( ) <nl> - : genesis ( " genesis . json " ) , <nl> - remote ( false ) , <nl> + class eosd_def ; <nl> + <nl> + class host_def { <nl> + public : <nl> + host_def ( ) <nl> + : genesis ( " . / genesis . json " ) , <nl> ssh_identity ( " " ) , <nl> ssh_args ( " " ) , <nl> eos_root_dir ( ) , <nl> - data_dir ( ) , <nl> - hostname ( " 127 . 0 . 0 . 1 " ) , <nl> + host_name ( " 127 . 0 . 0 . 1 " ) , <nl> public_name ( " localhost " ) , <nl> - p2p_port ( 9876 ) , <nl> - http_port ( 8888 ) , <nl> - filesize ( 8192 ) , <nl> - keys ( ) , <nl> - peers ( ) , <nl> - producers ( ) , <nl> - onhost_set ( false ) , <nl> - onhost ( true ) , <nl> - localaddrs ( ) , <nl> - dot_alias_str ( ) <nl> + listen_addr ( " 0 . 0 . 0 . 0 " ) , <nl> + base_p2p_port ( 9876 ) , <nl> + base_http_port ( 8888 ) , <nl> + def_file_size ( 8192 ) , <nl> + instances ( ) , <nl> + p2p_count ( 0 ) , <nl> + http_count ( 0 ) , <nl> + dot_label_str ( ) <nl> { } <nl> <nl> - bool on_host ( ) { <nl> - if ( ! onhost_set ) { <nl> - onhost_set = true ; <nl> - onhost = local_id . contains ( hostname ) ; <nl> - } <nl> - return onhost ; <nl> + string genesis ; <nl> + string ssh_identity ; <nl> + string ssh_args ; <nl> + string eos_root_dir ; <nl> + string host_name ; <nl> + string public_name ; <nl> + string listen_addr ; <nl> + uint16_t base_p2p_port ; <nl> + uint16_t base_http_port ; <nl> + uint16_t def_file_size ; <nl> + vector < eosd_def > instances ; <nl> + <nl> + uint16_t p2p_port ( ) { <nl> + return base_p2p_port + p2p_count + + ; <nl> + } <nl> + <nl> + uint16_t http_port ( ) { <nl> + return base_http_port + http_count + + ; <nl> + } <nl> + <nl> + bool is_local ( ) { <nl> + return local_id . contains ( host_name ) ; <nl> } <nl> <nl> - string p2p_endpoint ( ) { <nl> - if ( p2p_endpoint_str . empty ( ) ) { <nl> - p2p_endpoint_str = public_name + " : " + boost : : lexical_cast < string , uint16_t > ( p2p_port ) ; <nl> + const string & dot_label ( ) { <nl> + if ( dot_label_str . empty ( ) ) { <nl> + mk_dot_label ( ) ; <nl> } <nl> - return p2p_endpoint_str ; <nl> + return dot_label_str ; <nl> } <nl> <nl> - const string & dot_alias ( const string & name ) { <nl> - if ( dot_alias_str . empty ( ) ) { <nl> - dot_alias_str = name + " \ \ nprod = " ; <nl> - if ( producers . empty ( ) ) { <nl> - dot_alias_str + = " < none > " ; <nl> - } <nl> - else { <nl> - bool docomma = false ; <nl> - for ( auto & prod : producers ) { <nl> - if ( docomma ) <nl> - dot_alias_str + = " , " ; <nl> - else <nl> - docomma = true ; <nl> - dot_alias_str + = prod ; <nl> - } <nl> - } <nl> + <nl> + private : <nl> + uint16_t p2p_count ; <nl> + uint16_t http_count ; <nl> + string dot_label_str ; <nl> + <nl> + protected : <nl> + void mk_dot_label ( ) { <nl> + if ( public_name . empty ( ) ) { <nl> + dot_label_str = host_name ; <nl> } <nl> - return dot_alias_str ; <nl> + else if ( boost : : iequals ( public_name , host_name ) ) { <nl> + dot_label_str = public_name ; <nl> + } <nl> + else <nl> + dot_label_str = public_name + " / " + host_name ; <nl> } <nl> + } ; <nl> <nl> - string genesis ; <nl> - bool remote ; <nl> - string ssh_identity ; <nl> - string ssh_args ; <nl> - string eos_root_dir ; <nl> - string data_dir ; <nl> - string hostname ; <nl> - string public_name ; <nl> - uint16_t p2p_port ; <nl> - uint16_t http_port ; <nl> - uint16_t filesize ; <nl> - vector < keypair > keys ; <nl> - vector < string > peers ; <nl> - vector < string > producers ; <nl> + class tn_node_def ; <nl> + <nl> + class eosd_def { <nl> + public : <nl> + string data_dir ; <nl> + uint16_t p2p_port ; <nl> + uint16_t http_port ; <nl> + uint16_t file_size ; <nl> + bool has_db ; <nl> + string name ; <nl> + tn_node_def * node ; <nl> + string host ; <nl> + string p2p_endpoint ; <nl> + <nl> + void set_host ( host_def * h ) ; <nl> + void mk_dot_label ( ) ; <nl> + const string & dot_label ( ) { <nl> + if ( dot_label_str . empty ( ) ) { <nl> + mk_dot_label ( ) ; <nl> + } <nl> + return dot_label_str ; <nl> + } <nl> <nl> private : <nl> - string p2p_endpoint_str ; <nl> - bool onhost_set ; <nl> - bool onhost ; <nl> - vector < fc : : ip : : address > localaddrs ; <nl> - string dot_alias_str ; <nl> + string dot_label_str ; <nl> + } ; <nl> + <nl> + class tn_node_def { <nl> + public : <nl> + string name ; <nl> + vector < keypair > keys ; <nl> + vector < string > peers ; <nl> + vector < string > producers ; <nl> + eosd_def * instance ; <nl> } ; <nl> <nl> + void <nl> + eosd_def : : mk_dot_label ( ) { <nl> + dot_label_str = name + " \ \ nprod = " ; <nl> + if ( node = = 0 | | node - > producers . empty ( ) ) { <nl> + dot_label_str + = " < none > " ; <nl> + } <nl> + else { <nl> + bool docomma = false ; <nl> + for ( auto & prod : node - > producers ) { <nl> + if ( docomma ) <nl> + dot_label_str + = " , " ; <nl> + else <nl> + docomma = true ; <nl> + dot_label_str + = prod ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + void <nl> + eosd_def : : set_host ( host_def * h ) { <nl> + host = h - > host_name ; <nl> + has_db = false ; <nl> + p2p_port = h - > p2p_port ( ) ; <nl> + http_port = h - > http_port ( ) ; <nl> + file_size = h - > def_file_size ; <nl> + p2p_endpoint = h - > public_name + " : " + boost : : lexical_cast < string , uint16_t > ( p2p_port ) ; <nl> + } <nl> + <nl> struct remote_deploy { <nl> string ssh_cmd = " / usr / bin / ssh " ; <nl> string scp_cmd = " / usr / bin / scp " ; <nl> struct remote_deploy { <nl> string local_config_file = " temp_config " ; <nl> } ; <nl> <nl> + struct host_map_def { <nl> + map < string , host_def > bindings ; <nl> + } ; <nl> + <nl> struct testnet_def { <nl> remote_deploy ssh_helper ; <nl> - map < string , eosd_def > nodes ; <nl> + map < string , tn_node_def > nodes ; <nl> } ; <nl> <nl> <nl> enum launch_modes { <nl> LM_NONE , <nl> LM_LOCAL , <nl> LM_REMOTE , <nl> - LM_ALL <nl> + LM_NAMED , <nl> + LM_ALL , <nl> + LM_VERIFY <nl> } ; <nl> <nl> enum allowed_connection : char { <nl> struct launcher_def { <nl> size_t producers ; <nl> size_t total_nodes ; <nl> size_t prod_nodes ; <nl> + size_t next_node ; <nl> string shape ; <nl> allowed_connection allowed_connections = PC_NONE ; <nl> bf : : path genesis ; <nl> bf : : path output ; <nl> + bf : : path host_map_file ; <nl> + string data_dir_base ; <nl> bool skip_transaction_signatures = false ; <nl> string eosd_extra_args ; <nl> testnet_def network ; <nl> - string data_dir_base ; <nl> string alias_base ; <nl> vector < string > aliases ; <nl> + host_map_def host_map ; <nl> last_run_def last_run ; <nl> int start_delay ; <nl> - bool random_start ; <nl> + bool nogen ; <nl> + string launch_name ; <nl> + <nl> + void assign_name ( eosd_def & node ) ; <nl> <nl> void set_options ( bpo : : options_description & cli ) ; <nl> void initialize ( const variables_map & vmap ) ; <nl> bool generate ( ) ; <nl> - void define_nodes ( ) ; <nl> - void write_config_file ( eosd_def & node ) ; <nl> + void define_local ( ) ; <nl> + void bind_nodes ( ) ; <nl> + void write_config_file ( tn_node_def & node ) ; <nl> void make_ring ( ) ; <nl> void make_star ( ) ; <nl> void make_mesh ( ) ; <nl> void make_custom ( ) ; <nl> void write_dot_file ( ) ; <nl> - void format_ssh ( const string & cmd , const string & hostname , string & ssh_cmd_line ) ; <nl> - bool do_ssh ( const string & cmd , const string & hostname ) ; <nl> + void format_ssh ( const string & cmd , const string & host_name , string & ssh_cmd_line ) ; <nl> + bool do_ssh ( const string & cmd , const string & host_name ) ; <nl> void prep_remote_config_dir ( eosd_def & node ) ; <nl> void launch ( eosd_def & node , string & gts ) ; <nl> void kill ( launch_modes mode , string sig_opt ) ; <nl> launcher_def : : set_options ( bpo : : options_description & cli ) { <nl> ( " nodes , n " , bpo : : value < size_t > ( & total_nodes ) - > default_value ( 1 ) , " total number of nodes to configure and launch " ) <nl> ( " pnodes , p " , bpo : : value < size_t > ( & prod_nodes ) - > default_value ( 1 ) , " number of nodes that are producers " ) <nl> ( " mode , m " , bpo : : value < vector < string > > ( ) - > multitoken ( ) - > default_value ( { " any " } , " any " ) , " connection mode , combination of \ " any \ " , \ " producers \ " , \ " specified \ " , \ " none \ " " ) <nl> - ( " shape , s " , bpo : : value < string > ( & shape ) - > default_value ( " star " ) , " network topology , use \ " ring \ " \ " star \ " \ " mesh \ " or give a filename for custom " ) <nl> + ( " shape , s " , bpo : : value < string > ( & shape ) - > default_value ( " star " ) , " network topology , use \ " star \ " \ " mesh \ " or give a filename for custom " ) <nl> ( " genesis , g " , bpo : : value < bf : : path > ( & genesis ) - > default_value ( " . / genesis . json " ) , " set the path to genesis . json " ) <nl> ( " output , o " , bpo : : value < bf : : path > ( & output ) , " save a copy of the generated topology in this file " ) <nl> ( " skip - signature " , bpo : : bool_switch ( & skip_transaction_signatures ) - > default_value ( false ) , " EOSD does not require transaction signatures . " ) <nl> ( " eosd " , bpo : : value < string > ( & eosd_extra_args ) , " forward eosd command line argument ( s ) to each instance of eosd , enclose arg in quotes " ) <nl> ( " delay , d " , bpo : : value < int > ( & start_delay ) - > default_value ( 0 ) , " seconds delay before starting each node after the first " ) <nl> - ( " random " , bpo : : bool_switch ( & random_start ) - > default_value ( false ) , " start the nodes in a random order " ) <nl> + ( " nogen " , bpo : : bool_switch ( & nogen ) - > default_value ( false ) , " launch nodes without writing new config files " ) <nl> + ( " host_map " , bpo : : value < bf : : path > ( & host_map_file ) - > default_value ( " " ) , " a file containing mapping specific nodes to hosts . Used to enhance the custom shape argument " ) <nl> ; <nl> } <nl> <nl> launcher_def : : initialize ( const variables_map & vmap ) { <nl> } <nl> } <nl> } <nl> + <nl> + if ( ! ( shape . empty ( ) | | <nl> + boost : : iequals ( shape , " ring " ) | | <nl> + boost : : iequals ( shape , " star " ) | | <nl> + boost : : iequals ( shape , " mesh " ) ) & & <nl> + host_map_file . empty ( ) ) { <nl> + bf : : path src = shape ; <nl> + host_map_file = src . stem ( ) . string ( ) + " _hosts . json " ; <nl> + } <nl> + <nl> + if ( ! host_map_file . empty ( ) ) { <nl> + try { <nl> + fc : : json : : from_file ( host_map_file ) . as < host_map_def > ( host_map ) ; <nl> + for ( auto & binding : host_map . bindings ) { <nl> + for ( auto & eosd : binding . second . instances ) { <nl> + aliases . push_back ( eosd . name ) ; <nl> + } <nl> + } <nl> + } catch ( . . . ) { / / this is an optional feature , so an exception is OK <nl> + } <nl> + } <nl> + <nl> producers = 21 ; <nl> data_dir_base = " tn_data_ " ; <nl> alias_base = " testnet_ " ; <nl> + next_node = 0 ; <nl> <nl> if ( prod_nodes > producers ) <nl> prod_nodes = producers ; <nl> if ( prod_nodes > total_nodes ) <nl> total_nodes = prod_nodes ; <nl> + <nl> + if ( host_map . bindings . empty ( ) ) { <nl> + define_local ( ) ; <nl> + } <nl> + } <nl> + <nl> + void <nl> + launcher_def : : assign_name ( eosd_def & node ) { <nl> + string dex = boost : : lexical_cast < string , int > ( next_node + + ) ; <nl> + node . name = alias_base + dex ; <nl> + node . data_dir = data_dir_base + dex ; <nl> } <nl> <nl> bool <nl> launcher_def : : generate ( ) { <nl> + <nl> if ( boost : : iequals ( shape , " ring " ) ) { <nl> make_ring ( ) ; <nl> } <nl> launcher_def : : generate ( ) { <nl> else { <nl> make_custom ( ) ; <nl> } <nl> - for ( auto & node : network . nodes ) { <nl> + <nl> + if ( ! nogen ) { <nl> + for ( auto & node : network . nodes ) { <nl> write_config_file ( node . second ) ; <nl> + } <nl> + write_dot_file ( ) ; <nl> } <nl> <nl> - write_dot_file ( ) ; <nl> - <nl> if ( ! output . empty ( ) ) { <nl> bf : : path savefile = output ; <nl> - bf : : ofstream sf ( savefile ) ; <nl> + { <nl> + bf : : ofstream sf ( savefile ) ; <nl> + <nl> + sf < < fc : : json : : to_pretty_string ( network ) < < endl ; <nl> + sf . close ( ) ; <nl> + } <nl> + <nl> + savefile = bf : : path ( output . stem ( ) . string ( ) + " _hosts . json " ) ; <nl> + { <nl> + <nl> + bf : : ofstream sf ( savefile ) ; <nl> + <nl> + sf < < fc : : json : : to_pretty_string ( host_map ) < < endl ; <nl> + sf . close ( ) ; <nl> + } <nl> <nl> - sf < < fc : : json : : to_pretty_string ( network ) < < endl ; <nl> - sf . close ( ) ; <nl> return false ; <nl> } <nl> return true ; <nl> launcher_def : : write_dot_file ( ) { <nl> df < < " digraph G \ n { \ nlayout = \ " circo \ " ; \ n " ; <nl> for ( auto & node : network . nodes ) { <nl> for ( const auto & p : node . second . peers ) { <nl> - string pname = network . nodes . find ( p ) - > second . dot_alias ( p ) ; <nl> - df < < " \ " " < < node . second . dot_alias ( node . first ) <nl> + string pname = network . nodes . find ( p ) - > second . instance - > dot_label ( ) ; <nl> + df < < " \ " " < < node . second . instance - > dot_label ( ) <nl> < < " \ " - > \ " " < < pname <nl> < < " \ " [ dir = \ " forward \ " ] ; " < < std : : endl ; <nl> } <nl> launcher_def : : write_dot_file ( ) { <nl> } <nl> <nl> void <nl> - launcher_def : : define_nodes ( ) { <nl> + launcher_def : : define_local ( ) { <nl> + host_def local_host ; <nl> + local_host . eos_root_dir = getenv ( " EOS_ROOT_DIR " ) ; <nl> + local_host . genesis = genesis . string ( ) ; <nl> + <nl> + for ( size_t i = 0 ; i < total_nodes ; i + + ) { <nl> + eosd_def eosd ; <nl> + <nl> + assign_name ( eosd ) ; <nl> + aliases . push_back ( eosd . name ) ; <nl> + eosd . set_host ( & local_host ) ; <nl> + local_host . instances . emplace_back ( move ( eosd ) ) ; <nl> + } <nl> + host_map . bindings [ local_host . host_name ] = move ( local_host ) ; <nl> + } <nl> + <nl> + void <nl> + launcher_def : : bind_nodes ( ) { <nl> int per_node = producers / prod_nodes ; <nl> int extra = producers % prod_nodes ; <nl> - for ( size_t i = 0 ; i < total_nodes ; i + + ) { <nl> - eosd_def node ; <nl> - string dex = boost : : lexical_cast < string , int > ( i ) ; <nl> - string name = alias_base + dex ; <nl> - aliases . push_back ( name ) ; <nl> - node . genesis = genesis . string ( ) ; <nl> - node . data_dir = data_dir_base + dex ; <nl> - node . hostname = " 127 . 0 . 0 . 1 " ; <nl> - node . public_name = " localhost " ; <nl> - node . remote = false ; <nl> - node . p2p_port + = i ; <nl> - node . http_port + = i ; <nl> - keypair kp ; <nl> - node . keys . push_back ( kp ) ; <nl> - if ( i < prod_nodes ) { <nl> - int count = per_node ; <nl> - if ( extra ) { <nl> - + + count ; <nl> - - - extra ; <nl> - } <nl> - char ext = ' a ' + i ; <nl> - string pname = " init " ; <nl> - while ( count - - ) { <nl> - node . producers . push_back ( pname + ext ) ; <nl> - ext + = prod_nodes ; <nl> + int i = 0 ; <nl> + for ( auto & h : host_map . bindings ) { <nl> + for ( auto & inst : h . second . instances ) { <nl> + tn_node_def node ; <nl> + node . name = inst . name ; <nl> + node . instance = & inst ; <nl> + keypair kp ; <nl> + node . keys . emplace_back ( move ( kp ) ) ; <nl> + if ( i < prod_nodes ) { <nl> + int count = per_node ; <nl> + if ( extra ) { <nl> + + + count ; <nl> + - - extra ; <nl> + } <nl> + char ext = ' a ' + i ; <nl> + string pname = " init " ; <nl> + while ( count - - ) { <nl> + node . producers . push_back ( pname + ext ) ; <nl> + ext + = prod_nodes ; <nl> + } <nl> } <nl> + network . nodes [ node . name ] = move ( node ) ; <nl> + i + + ; <nl> } <nl> - network . nodes . insert ( pair < string , eosd_def > ( name , node ) ) ; <nl> - <nl> } <nl> } <nl> <nl> void <nl> - launcher_def : : write_config_file ( eosd_def & node ) { <nl> + launcher_def : : write_config_file ( tn_node_def & node ) { <nl> bf : : path filename ; <nl> boost : : system : : error_code ec ; <nl> - <nl> - if ( node . on_host ( ) ) { <nl> - bf : : path dd ( node . data_dir ) ; <nl> + eosd_def & instance = * node . instance ; <nl> + host_def * host = & host_map . bindings [ instance . host ] ; <nl> + if ( host - > is_local ( ) ) { <nl> + bf : : path dd = bf : : path ( host - > eos_root_dir ) / instance . data_dir ; <nl> filename = dd / " config . ini " ; <nl> if ( bf : : exists ( dd ) ) { <nl> int64_t count = bf : : remove_all ( dd , ec ) ; <nl> launcher_def : : write_config_file ( eosd_def & node ) { <nl> exit ( - 1 ) ; <nl> } <nl> } <nl> - if ( ! bf : : create_directory ( node . data_dir , ec ) & & ec . value ( ) ) { <nl> - cerr < < " could not create new directory : " < < node . data_dir <nl> + if ( ! bf : : create_directory ( instance . data_dir , ec ) & & ec . value ( ) ) { <nl> + cerr < < " could not create new directory : " < < instance . data_dir <nl> < < " errno " < < ec . value ( ) < < " " < < strerror ( ec . value ( ) ) < < endl ; <nl> exit ( - 1 ) ; <nl> } <nl> launcher_def : : write_config_file ( eosd_def & node ) { <nl> exit ( - 1 ) ; <nl> } <nl> <nl> - cfg < < " genesis - json = " < < node . genesis < < " \ n " <nl> + cfg < < " genesis - json = " < < host - > genesis < < " \ n " <nl> < < " block - log - dir = blocks \ n " <nl> < < " readonly = 0 \ n " <nl> < < " send - whole - blocks = true \ n " <nl> < < " shared - file - dir = blockchain \ n " <nl> - < < " shared - file - size = " < < node . filesize < < " \ n " <nl> - < < " http - server - endpoint = " < < node . hostname < < " : " < < node . http_port < < " \ n " <nl> - < < " listen - endpoint = 0 . 0 . 0 . 0 : " < < node . p2p_port < < " \ n " <nl> - < < " public - endpoint = " < < node . public_name < < " : " < < node . p2p_port < < " \ n " ; <nl> + < < " shared - file - size = " < < instance . file_size < < " \ n " <nl> + < < " http - server - endpoint = " < < host - > host_name < < " : " < < instance . http_port < < " \ n " <nl> + < < " listen - endpoint = " < < host - > listen_addr < < " : " < < instance . p2p_port < < " \ n " <nl> + < < " public - endpoint = " < < host - > public_name < < " : " < < instance . p2p_port < < " \ n " ; <nl> if ( allowed_connections & PC_ANY ) { <nl> cfg < < " allowed - connection = any \ n " ; <nl> } <nl> launcher_def : : write_config_file ( eosd_def & node ) { <nl> } <nl> } <nl> for ( const auto & p : node . peers ) { <nl> - cfg < < " remote - endpoint = " < < network . nodes . find ( p ) - > second . p2p_endpoint ( ) < < " \ n " ; <nl> + cfg < < " remote - endpoint = " < < network . nodes . find ( p ) - > second . instance - > p2p_endpoint < < " \ n " ; <nl> } <nl> if ( node . producers . size ( ) ) { <nl> cfg < < " required - participation = true \ n " ; <nl> launcher_def : : write_config_file ( eosd_def & node ) { <nl> } <nl> cfg < < " plugin = eosio : : producer_plugin \ n " ; <nl> } <nl> + if ( instance . has_db ) { <nl> + if ( ! node . producers . size ( ) ) { <nl> + cfg < < " plugin = eosio : : producer_plugin \ n " ; <nl> + } <nl> + cfg < < " plugin = eosio : : db_plugin \ n " ; <nl> + } <nl> cfg < < " plugin = eosio : : chain_api_plugin \ n " <nl> < < " plugin = eosio : : wallet_api_plugin \ n " <nl> - < < " plugin = eosio : : db_plugin \ n " <nl> < < " plugin = eosio : : account_history_plugin \ n " <nl> < < " plugin = eosio : : account_history_api_plugin \ n " ; <nl> cfg . close ( ) ; <nl> - if ( ! node . on_host ( ) ) { <nl> - prep_remote_config_dir ( node ) ; <nl> + if ( ! host - > is_local ( ) ) { <nl> + prep_remote_config_dir ( instance ) ; <nl> string scp_cmd_line = network . ssh_helper . scp_cmd + " " ; <nl> - const string & args = node . ssh_args . length ( ) ? node . ssh_args : network . ssh_helper . ssh_args ; <nl> + const string & args = host - > ssh_args . length ( ) ? host - > ssh_args : network . ssh_helper . ssh_args ; <nl> if ( args . length ( ) ) { <nl> scp_cmd_line + = args + " " ; <nl> } <nl> scp_cmd_line + = filename . string ( ) + " " ; <nl> <nl> - const string & uid = node . ssh_identity . length ( ) ? node . ssh_identity : network . ssh_helper . ssh_identity ; <nl> + const string & uid = host - > ssh_identity . length ( ) ? host - > ssh_identity : network . ssh_helper . ssh_identity ; <nl> if ( uid . length ( ) ) { <nl> scp_cmd_line + = uid + " @ " ; <nl> } <nl> <nl> - bf : : path dpath = bf : : path ( node . eos_root_dir ) / node . data_dir / " config . ini " ; <nl> - scp_cmd_line + = node . hostname + " : " + dpath . string ( ) ; <nl> + bf : : path dpath = bf : : path ( host - > eos_root_dir ) / instance . data_dir / " config . ini " ; <nl> + scp_cmd_line + = host - > host_name + " : " + dpath . string ( ) ; <nl> <nl> cerr < < " cmdline = " < < scp_cmd_line < < endl ; <nl> - int res = boost : : process : : system ( scp_cmd_line ) ; <nl> + int res = 1 ; / / boost : : process : : system ( scp_cmd_line ) ; <nl> if ( res ! = 0 ) { <nl> - cerr < < " unable to scp config file to host " < < node . hostname < < endl ; <nl> + cerr < < " unable to scp config file to host " < < host - > host_name < < endl ; <nl> exit ( - 1 ) ; <nl> } <nl> } <nl> launcher_def : : write_config_file ( eosd_def & node ) { <nl> <nl> void <nl> launcher_def : : make_ring ( ) { <nl> - define_nodes ( ) ; <nl> + bind_nodes ( ) ; <nl> if ( total_nodes > 2 ) { <nl> - <nl> for ( size_t i = 0 ; i < total_nodes ; i + + ) { <nl> size_t front = ( i + 1 ) % total_nodes ; <nl> network . nodes . find ( aliases [ i ] ) - > second . peers . push_back ( aliases [ front ] ) ; <nl> launcher_def : : make_ring ( ) { <nl> <nl> void <nl> launcher_def : : make_star ( ) { <nl> + bind_nodes ( ) ; <nl> if ( total_nodes < 4 ) { <nl> make_ring ( ) ; <nl> return ; <nl> } <nl> - define_nodes ( ) ; <nl> + <nl> size_t links = 3 ; <nl> if ( total_nodes > 12 ) { <nl> links = ( size_t ) sqrt ( total_nodes ) ; <nl> launcher_def : : make_star ( ) { <nl> ndx = 0 ; <nl> } <nl> <nl> - <nl> peer = aliases [ ndx ] ; <nl> <nl> found = true ; <nl> launcher_def : : make_star ( ) { <nl> <nl> void <nl> launcher_def : : make_mesh ( ) { <nl> - define_nodes ( ) ; <nl> + bind_nodes ( ) ; <nl> / / use to prevent duplicates since all connections are bidirectional <nl> std : : map < string , std : : set < string > > peers_to_from ; <nl> for ( size_t i = 0 ; i < total_nodes ; i + + ) { <nl> launcher_def : : make_mesh ( ) { <nl> <nl> void <nl> launcher_def : : make_custom ( ) { <nl> - / / don ' t need to define nodes here <nl> bf : : path source = shape ; <nl> fc : : json : : from_file ( source ) . as < testnet_def > ( network ) ; <nl> + for ( auto & h : host_map . bindings ) { <nl> + for ( auto & inst : h . second . instances ) { <nl> + tn_node_def * node = & network . nodes [ inst . name ] ; <nl> + node - > instance = & inst ; <nl> + inst . node = node ; <nl> + } <nl> + } <nl> } <nl> <nl> void <nl> launcher_def : : format_ssh ( const string & cmd , <nl> - const string & hostname , <nl> + const string & host_name , <nl> string & ssh_cmd_line ) { <nl> <nl> ssh_cmd_line = network . ssh_helper . ssh_cmd + " " ; <nl> launcher_def : : format_ssh ( const string & cmd , <nl> if ( network . ssh_helper . ssh_identity . length ( ) ) { <nl> ssh_cmd_line + = network . ssh_helper . ssh_identity + " @ " ; <nl> } <nl> - ssh_cmd_line + = hostname + " \ " " + cmd + " \ " " ; <nl> + ssh_cmd_line + = host_name + " \ " " + cmd + " \ " " ; <nl> cerr < < " cmdline = " < < ssh_cmd_line < < endl ; <nl> } <nl> <nl> bool <nl> - launcher_def : : do_ssh ( const string & cmd , const string & hostname ) { <nl> + launcher_def : : do_ssh ( const string & cmd , const string & host_name ) { <nl> string ssh_cmd_line ; <nl> - format_ssh ( cmd , hostname , ssh_cmd_line ) ; <nl> + format_ssh ( cmd , host_name , ssh_cmd_line ) ; <nl> int res = boost : : process : : system ( ssh_cmd_line ) ; <nl> return ( res = = 0 ) ; <nl> } <nl> <nl> void <nl> launcher_def : : prep_remote_config_dir ( eosd_def & node ) { <nl> - bf : : path abs_data_dir = bf : : path ( node . eos_root_dir ) / node . data_dir ; <nl> + host_def * host = & host_map . bindings [ node . host ] ; <nl> + bf : : path abs_data_dir = bf : : path ( host - > eos_root_dir ) / node . data_dir ; <nl> string add = abs_data_dir . string ( ) ; <nl> - string cmd = " cd " + node . eos_root_dir ; <nl> - if ( ! do_ssh ( cmd , node . hostname ) ) { <nl> - cerr < < " Unable to switch to path " < < node . eos_root_dir <nl> - < < " on host " < < node . hostname < < endl ; <nl> + string cmd = " cd " + host - > eos_root_dir ; <nl> + if ( ! do_ssh ( cmd , host - > host_name ) ) { <nl> + cerr < < " Unable to switch to path " < < host - > eos_root_dir <nl> + < < " on host " < < host - > host_name < < endl ; <nl> exit ( - 1 ) ; <nl> } <nl> cmd = " cd " + add ; <nl> - if ( do_ssh ( cmd , node . hostname ) ) { <nl> + if ( do_ssh ( cmd , host - > host_name ) ) { <nl> cmd = " rm - rf " + add + " / block * " ; <nl> - if ( ! do_ssh ( cmd , node . hostname ) ) { <nl> + if ( ! do_ssh ( cmd , host - > host_name ) ) { <nl> cerr < < " Unable to remove old data directories on host " <nl> - < < node . hostname < < endl ; <nl> + < < host - > host_name < < endl ; <nl> exit ( - 1 ) ; <nl> } <nl> } <nl> else { <nl> cmd = " mkdir " + add ; <nl> - if ( ! do_ssh ( cmd , node . hostname ) ) { <nl> + if ( ! do_ssh ( cmd , host - > host_name ) ) { <nl> cerr < < " Unable to invoke " < < cmd < < " on host " <nl> - < < node . hostname < < endl ; <nl> + < < host - > host_name < < endl ; <nl> exit ( - 1 ) ; <nl> } <nl> } <nl> launcher_def : : launch ( eosd_def & node , string & gts ) { <nl> bf : : path reerr = dd / " stderr . txt " ; <nl> bf : : path pidf = dd / " eosd . pid " ; <nl> <nl> + host_def * host = & host_map . bindings [ node . host ] ; <nl> + <nl> node_rt_info info ; <nl> - info . remote = node . remote ; <nl> + info . remote = ! host - > is_local ( ) ; <nl> <nl> string eosdcmd = " programs / eosd / eosd " ; <nl> if ( skip_transaction_signatures ) { <nl> launcher_def : : launch ( eosd_def & node , string & gts ) { <nl> eosdcmd + = " - - genesis - timestamp " + gts ; <nl> } <nl> <nl> - if ( ! node . on_host ( ) ) { <nl> + if ( info . remote ) { <nl> string cmdl ( " cd " ) ; <nl> - cmdl + = node . eos_root_dir + " ; nohup " + eosdcmd + " > " <nl> + cmdl + = host - > eos_root_dir + " ; nohup " + eosdcmd + " > " <nl> + reout . string ( ) + " 2 > " + reerr . string ( ) + " & echo $ ! > " + pidf . string ( ) ; <nl> - if ( ! do_ssh ( cmdl , node . hostname ) ) { <nl> + if ( ! do_ssh ( cmdl , host - > host_name ) ) { <nl> cerr < < " Unable to invoke " < < cmdl <nl> - < < " on host " < < node . hostname < < endl ; <nl> + < < " on host " < < host - > host_name < < endl ; <nl> exit ( - 1 ) ; <nl> } <nl> <nl> - string cmd = " cd " + node . eos_root_dir + " ; kill - 9 ` cat " + pidf . string ( ) + " ` " ; <nl> - format_ssh ( cmd , node . hostname , info . kill_cmd ) ; <nl> + string cmd = " cd " + host - > eos_root_dir + " ; kill - 9 ` cat " + pidf . string ( ) + " ` " ; <nl> + format_ssh ( cmd , host - > host_name , info . kill_cmd ) ; <nl> } <nl> else { <nl> cerr < < " spawning child , " < < eosdcmd < < endl ; <nl> launcher_def : : launch ( eosd_def & node , string & gts ) { <nl> } <nl> c . detach ( ) ; <nl> } <nl> - last_run . running_nodes . push_back ( info ) ; <nl> + last_run . running_nodes . emplace_back ( move ( info ) ) ; <nl> } <nl> <nl> void <nl> launcher_def : : kill ( launch_modes mode , string sig_opt ) { <nl> <nl> void <nl> launcher_def : : start_all ( string & gts , launch_modes mode ) { <nl> - if ( mode = = LM_NONE ) <nl> + switch ( mode ) { <nl> + case LM_NONE : <nl> return ; <nl> - <nl> - if ( random_start ) { <nl> - / / recompute start order - implemenation deferred <nl> - } else { <nl> - for ( auto & node : network . nodes ) { <nl> - if ( mode ! = LM_ALL ) { <nl> - if ( ( mode = = LM_LOCAL & & node . second . remote ) | | <nl> - ( mode = = LM_REMOTE & & ! node . second . remote ) ) { <nl> - continue ; <nl> + case LM_VERIFY : <nl> + / / validate configuration , report findings , exit <nl> + return ; <nl> + case LM_NAMED : { <nl> + try { <nl> + auto node = network . nodes . find ( launch_name ) ; <nl> + launch ( * node - > second . instance , gts ) ; <nl> + } catch ( . . . ) { <nl> + / / failed to start . <nl> + } <nl> + break ; <nl> + } <nl> + case LM_ALL : <nl> + case LM_REMOTE : <nl> + case LM_LOCAL : { <nl> + for ( auto & h : host_map . bindings ) { <nl> + if ( mode = = LM_ALL | | <nl> + ( h . second . is_local ( ) ? mode = = LM_LOCAL : mode = = LM_REMOTE ) ) { <nl> + for ( auto & inst : h . second . instances ) { <nl> + launch ( inst , gts ) ; <nl> + sleep ( start_delay ) ; <nl> } <nl> } <nl> - launch ( node . second , gts ) ; <nl> - sleep ( start_delay ) ; <nl> } <nl> + break ; <nl> + } <nl> } <nl> bf : : path savefile = " last_run . json " ; <nl> bf : : ofstream sf ( savefile ) ; <nl> int main ( int argc , char * argv [ ] ) { <nl> mode = LM_REMOTE ; <nl> else if ( boost : : iequals ( l , " none " ) ) <nl> mode = LM_NONE ; <nl> + else if ( boost : : iequals ( l , " verify " ) ) <nl> + mode = LM_VERIFY ; <nl> else { <nl> + mode = LM_NAMED ; <nl> + top . launch_name = l ; <nl> cerr < < " unrecognized launch mode : " < < l < < endl ; <nl> exit ( - 1 ) ; <nl> } <nl> FC_REFLECT ( keypair , ( public_key ) ( wif_private_key ) ) <nl> FC_REFLECT ( remote_deploy , <nl> ( ssh_cmd ) ( scp_cmd ) ( ssh_identity ) ( ssh_args ) ) <nl> <nl> + FC_REFLECT ( host_def , <nl> + ( genesis ) ( ssh_identity ) ( ssh_args ) ( eos_root_dir ) <nl> + ( host_name ) ( public_name ) <nl> + ( base_p2p_port ) ( base_http_port ) ( def_file_size ) <nl> + ( instances ) ) <nl> + <nl> FC_REFLECT ( eosd_def , <nl> - ( genesis ) ( remote ) ( ssh_identity ) ( ssh_args ) ( eos_root_dir ) ( data_dir ) <nl> - ( hostname ) ( public_name ) ( p2p_port ) ( http_port ) ( filesize ) <nl> - ( keys ) ( peers ) ( producers ) ) <nl> + ( name ) ( data_dir ) ( has_db ) ( host ) ( p2p_endpoint ) <nl> + ( p2p_port ) ( http_port ) ( file_size ) ) <nl> + <nl> + FC_REFLECT ( tn_node_def , ( name ) ( keys ) ( peers ) ( producers ) ) <nl> + <nl> + FC_REFLECT ( testnet_def , ( ssh_helper ) ( nodes ) ) <nl> <nl> - FC_REFLECT ( testnet_def , <nl> - ( ssh_helper ) ( nodes ) ) <nl> + FC_REFLECT ( host_map_def , ( bindings ) ) <nl> <nl> - FC_REFLECT ( node_rt_info , <nl> - ( remote ) ( pid_file ) ( kill_cmd ) ) <nl> + FC_REFLECT ( node_rt_info , ( remote ) ( pid_file ) ( kill_cmd ) ) <nl> <nl> - FC_REFLECT ( last_run_def , <nl> - ( running_nodes ) ) <nl> + FC_REFLECT ( last_run_def , ( running_nodes ) ) <nl>
Refactored launcher app to separate out the eosd instances from the hosts they run on .
EOSIO/eos
2ba2b03deadd1f2dd2f0f1d6dcce715e11987e7e
2017-11-21T19:46:43Z
mmm a / PowerEditor / src / Notepad_plus . cpp <nl> ppp b / PowerEditor / src / Notepad_plus . cpp <nl> BOOL Notepad_plus : : notify ( SCNotification * notification ) <nl> lpttt = ( LPTOOLTIPTEXT ) notification ; <nl> lpttt - > hinst = _hInst ; <nl> <nl> - / / Specify the resource identifier of the descriptive <nl> - / / text for the given button . <nl> - int idButton = int ( lpttt - > hdr . idFrom ) ; <nl> + POINT p ; <nl> + : : GetCursorPos ( & p ) ; <nl> + : : ScreenToClient ( _hSelf , & p ) ; <nl> + HWND hWin = : : RealChildWindowFromPoint ( _hSelf , p ) ; <nl> + <nl> static string tip ; <nl> - getNameStrFromCmd ( idButton , tip ) ; <nl> + int id = int ( lpttt - > hdr . idFrom ) ; <nl> + <nl> + if ( hWin = = _rebarTop . getHSelf ( ) ) <nl> + { <nl> + getNameStrFromCmd ( id , tip ) ; <nl> + } <nl> + else if ( hWin = = _mainDocTab . getHSelf ( ) ) <nl> + { <nl> + tip = _mainEditView . getBufferAt ( id ) . getFileName ( ) ; <nl> + } <nl> + else if ( hWin = = _subDocTab . getHSelf ( ) ) <nl> + { <nl> + tip = _subEditView . getBufferAt ( id ) . getFileName ( ) ; <nl> + } <nl> + else <nl> + break ; <nl> + <nl> lpttt - > lpszText = ( LPSTR ) tip . c_str ( ) ; <nl> } <nl> break ; <nl> void Notepad_plus : : dropFiles ( HDROP hdrop ) <nl> / / Determinate in which view the file ( s ) is ( are ) dropped <nl> POINT p ; <nl> : : DragQueryPoint ( hdrop , & p ) ; <nl> - / / HWND hWin = : : ChildWindowFromPoint ( _hSelf , p ) ; <nl> HWND hWin = : : RealChildWindowFromPoint ( _hSelf , p ) ; <nl> if ( ! hWin ) return ; <nl> <nl> mmm a / PowerEditor / src / WinControls / TabBar / TabBar . cpp <nl> ppp b / PowerEditor / src / WinControls / TabBar / TabBar . cpp <nl> void TabBarPlus : : init ( HINSTANCE hInst , HWND parent , bool isVertical , bool isTrad <nl> int multiLine = isMultiLine ? ( _isTraditional ? TCS_MULTILINE : 0 ) : 0 ; <nl> <nl> int style = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE | \ <nl> - TCS_FOCUSNEVER | TCS_TABS | vertical | multiLine ; <nl> + TCS_TOOLTIPS | TCS_FOCUSNEVER | TCS_TABS | vertical | multiLine ; <nl> <nl> / / if ( isOwnerDrawTab ( ) & & ( ! _isTraditional ) ) <nl> { <nl>
[ NEW_FEATURE ] Add tooltips in document tab to display the full file name path .
notepad-plus-plus/notepad-plus-plus
7085e6972494253aa1d7c0a787ae8414c8f9387e
2008-05-21T00:34:17Z
mmm a / src / core / hle / kernel / svc . cpp <nl> ppp b / src / core / hle / kernel / svc . cpp <nl> ResultCode MapUnmapMemorySanityChecks ( const VMManager & vm_manager , VAddr dst_add <nl> <nl> const VAddr dst_end_address = dst_addr + size ; <nl> if ( dst_end_address > vm_manager . GetHeapRegionBaseAddress ( ) & & <nl> - dst_addr < vm_manager . GetHeapRegionEndAddress ( ) ) { <nl> + vm_manager . GetHeapRegionEndAddress ( ) > dst_addr ) { <nl> return ERR_INVALID_MEMORY_RANGE ; <nl> } <nl> <nl> - if ( dst_end_address > vm_manager . GetNewMapRegionBaseAddress ( ) & & <nl> - dst_addr < vm_manager . GetMapRegionEndAddress ( ) ) { <nl> + if ( dst_end_address > vm_manager . GetMapRegionBaseAddress ( ) & & <nl> + vm_manager . GetMapRegionEndAddress ( ) > dst_addr ) { <nl> return ERR_INVALID_MEMORY_RANGE ; <nl> } <nl> <nl>
svc : Fix typos in sanitizing checks for MapMemory / UnmapMemory
yuzu-emu/yuzu
4ccf30dfaafaeed6f2520066bcfdf898023fd812
2018-10-12T05:48:26Z
mmm a / docs / api / window - open . md <nl> ppp b / docs / api / window - open . md <nl> has to be a field of ` BrowserWindow ` ' s options . <nl> <nl> * Node integration will always be disabled in the opened ` window ` if it is <nl> disabled on the parent window . <nl> + * Context isolation will always be enabled in the opened ` window ` if it is <nl> + enabled on the parent window . <nl> + * JavaScript will always be disabled in the opened ` window ` if it is disabled on <nl> + the parent window . <nl> * Non - standard features ( that are not handled by Chromium or Electron ) given in <nl> ` features ` will be passed to any registered ` webContent ` ' s ` new - window ` event <nl> handler in the ` additionalFeatures ` argument . <nl>
Document other inherited web preferences
electron/electron
87db1b8aa718530a7b9ad050d145d21dee985cc4
2017-04-25T19:57:53Z
mmm a / src / clustering / administration / artificial_reql_cluster_interface . cc <nl> ppp b / src / clustering / administration / artificial_reql_cluster_interface . cc <nl> bool artificial_reql_cluster_interface_t : : table_find ( const name_string_t & name , <nl> <nl> bool artificial_reql_cluster_interface_t : : table_config ( <nl> counted_t < const ql : : db_t > db , <nl> - const std : : vector < name_string_t > & tables , <nl> + const std : : set < name_string_t > & tables , <nl> const ql : : protob_t < const Backtrace > & bt , signal_t * interruptor , <nl> scoped_ptr_t < ql : : val_t > * resp_out , std : : string * error_out ) { <nl> if ( db - > name = = database . str ( ) ) { <nl> bool artificial_reql_cluster_interface_t : : table_config ( <nl> <nl> bool artificial_reql_cluster_interface_t : : table_status ( <nl> counted_t < const ql : : db_t > db , <nl> - const std : : vector < name_string_t > & tables , <nl> + const std : : set < name_string_t > & tables , <nl> const ql : : protob_t < const Backtrace > & bt , signal_t * interruptor , <nl> scoped_ptr_t < ql : : val_t > * resp_out , std : : string * error_out ) { <nl> if ( db - > name = = database . str ( ) ) { <nl> bool artificial_reql_cluster_interface_t : : table_status ( <nl> <nl> bool artificial_reql_cluster_interface_t : : table_wait ( <nl> counted_t < const ql : : db_t > db , <nl> - const std : : vector < name_string_t > & tables , <nl> + const std : : set < name_string_t > & tables , <nl> const ql : : protob_t < const Backtrace > & bt , signal_t * interruptor , <nl> scoped_ptr_t < ql : : val_t > * resp_out , std : : string * error_out ) { <nl> if ( db - > name = = database . str ( ) ) { <nl> mmm a / src / clustering / administration / artificial_reql_cluster_interface . hpp <nl> ppp b / src / clustering / administration / artificial_reql_cluster_interface . hpp <nl> class artificial_reql_cluster_interface_t : public reql_cluster_interface_t { <nl> signal_t * interruptor , scoped_ptr_t < base_table_t > * table_out , <nl> std : : string * error_out ) ; <nl> bool table_config ( counted_t < const ql : : db_t > db , <nl> - const std : : vector < name_string_t > & tables , <nl> + const std : : set < name_string_t > & tables , <nl> const ql : : protob_t < const Backtrace > & bt , <nl> signal_t * interruptor , scoped_ptr_t < ql : : val_t > * resp_out , <nl> std : : string * error_out ) ; <nl> bool table_status ( counted_t < const ql : : db_t > db , <nl> - const std : : vector < name_string_t > & tables , <nl> + const std : : set < name_string_t > & tables , <nl> const ql : : protob_t < const Backtrace > & bt , <nl> signal_t * interruptor , scoped_ptr_t < ql : : val_t > * resp_out , <nl> std : : string * error_out ) ; <nl> bool table_wait ( counted_t < const ql : : db_t > db , <nl> - const std : : vector < name_string_t > & tables , <nl> + const std : : set < name_string_t > & tables , <nl> const ql : : protob_t < const Backtrace > & bt , <nl> signal_t * interruptor , scoped_ptr_t < ql : : val_t > * resp_out , <nl> std : : string * error_out ) ; <nl> mmm a / src / clustering / administration / real_reql_cluster_interface . cc <nl> ppp b / src / clustering / administration / real_reql_cluster_interface . cc <nl> bool real_reql_cluster_interface_t : : table_find ( const name_string_t & name , <nl> return true ; <nl> } <nl> <nl> + bool real_reql_cluster_interface_t : : get_table_ids_for_query ( <nl> + counted_t < const ql : : db_t > db , <nl> + const std : : set < name_string_t > & table_names , <nl> + std : : set < namespace_id_t > * table_ids_out , <nl> + std : : string * error_out ) { <nl> + guarantee ( db - > name ! = " rethinkdb " , <nl> + " real_reql_cluster_interface_t should never get queries for system tables " ) ; <nl> + <nl> + table_ids_out - > clear ( ) ; <nl> + cow_ptr_t < namespaces_semilattice_metadata_t > ns_metadata = get_namespaces_metadata ( ) ; <nl> + const_metadata_searcher_t < namespace_semilattice_metadata_t > ns_searcher ( <nl> + & ns_metadata - > namespaces ) ; <nl> + <nl> + if ( table_names . empty ( ) ) { <nl> + namespace_predicate_t pred ( & db - > id ) ; <nl> + for ( auto it = ns_searcher . find_next ( ns_searcher . begin ( ) , pred ) ; <nl> + it ! = ns_searcher . end ( ) ; <nl> + it = ns_searcher . find_next ( + + it , pred ) ) { <nl> + guarantee ( ! it - > second . is_deleted ( ) ) ; <nl> + table_ids_out - > insert ( it - > first ) ; <nl> + } <nl> + } else { <nl> + for ( auto const & name : table_names ) { <nl> + namespace_predicate_t pred ( & name , & db - > id ) ; <nl> + metadata_search_status_t status ; <nl> + auto it = ns_searcher . find_uniq ( pred , & status ) ; <nl> + if ( ! check_metadata_status ( status , " Table " , db - > name + " . " + name . str ( ) , true , <nl> + error_out ) ) return false ; <nl> + guarantee ( ! it - > second . is_deleted ( ) ) ; <nl> + table_ids_out - > insert ( it - > first ) ; <nl> + } <nl> + } <nl> + return true ; <nl> + } <nl> + <nl> bool real_reql_cluster_interface_t : : table_config ( <nl> counted_t < const ql : : db_t > db , <nl> - const std : : vector < name_string_t > & tables , <nl> + const std : : set < name_string_t > & tables , <nl> const ql : : protob_t < const Backtrace > & bt , <nl> signal_t * interruptor , scoped_ptr_t < ql : : val_t > * resp_out , <nl> std : : string * error_out ) { <nl> - return table_config_or_status ( <nl> + std : : set < namespace_id_t > table_ids ; <nl> + if ( ! get_table_ids_for_query ( db , tables , & table_ids , error_out ) ) { <nl> + return false ; <nl> + } <nl> + <nl> + return table_meta_read ( <nl> admin_tables - > table_config_backend . get ( ) , " table_config " , <nl> - db , tables , bt , interruptor , resp_out , error_out ) ; <nl> + table_ids , bt , interruptor , resp_out , error_out ) ; <nl> } <nl> <nl> bool real_reql_cluster_interface_t : : table_status ( <nl> counted_t < const ql : : db_t > db , <nl> - const std : : vector < name_string_t > & tables , <nl> + const std : : set < name_string_t > & tables , <nl> const ql : : protob_t < const Backtrace > & bt , <nl> signal_t * interruptor , scoped_ptr_t < ql : : val_t > * resp_out , <nl> std : : string * error_out ) { <nl> - return table_config_or_status ( <nl> + std : : set < namespace_id_t > table_ids ; <nl> + if ( ! get_table_ids_for_query ( db , tables , & table_ids , error_out ) ) { <nl> + return false ; <nl> + } <nl> + <nl> + return table_meta_read ( <nl> admin_tables - > table_status_backend . get ( ) , " table_status " , <nl> - db , tables , bt , interruptor , resp_out , error_out ) ; <nl> + table_ids , bt , interruptor , resp_out , error_out ) ; <nl> } <nl> <nl> + class table_waiter_t { <nl> + public : <nl> + table_waiter_t ( watchable_map_t < std : : pair < peer_id_t , namespace_id_t > , <nl> + namespace_directory_metadata_t > * directory , <nl> + namespace_id_t table_id ) : <nl> + table_directory ( directory , table_id ) { } <nl> + <nl> + enum class waited_t { <nl> + WAITED , <nl> + IMMEDIATE <nl> + } ; <nl> + <nl> + waited_t wait_ready ( signal_t * interruptor ) { <nl> + int num_checks = 0 ; <nl> + table_directory . run_all_until_satisfied ( <nl> + [ & ] ( watchable_map_t < peer_id_t , namespace_directory_metadata_t > * d ) - > bool { <nl> + + + num_checks ; <nl> + return do_check ( d ) ; <nl> + } , <nl> + interruptor ) ; <nl> + return num_checks > 1 ? waited_t : : WAITED : waited_t : : IMMEDIATE ; <nl> + } <nl> + <nl> + bool check_ready ( ) { <nl> + return do_check ( & table_directory ) ; <nl> + } <nl> + <nl> + private : <nl> + / / TODO : this is copy / pasta from namespace_interface_repository_t - consolidate ? <nl> + class table_directory_t : <nl> + public watchable_map_transform_t < <nl> + std : : pair < peer_id_t , namespace_id_t > , <nl> + namespace_directory_metadata_t , <nl> + peer_id_t , <nl> + namespace_directory_metadata_t > <nl> + { <nl> + public : <nl> + table_directory_t ( <nl> + watchable_map_t < std : : pair < peer_id_t , namespace_id_t > , <nl> + namespace_directory_metadata_t > * _directory , <nl> + namespace_id_t _namespace_id ) : <nl> + watchable_map_transform_t ( _directory ) , <nl> + nid ( _namespace_id ) { } <nl> + bool key_1_to_2 ( const std : : pair < peer_id_t , namespace_id_t > & key1 , <nl> + peer_id_t * key2_out ) { <nl> + if ( key1 . second = = nid ) { <nl> + * key2_out = key1 . first ; <nl> + return true ; <nl> + } else { <nl> + return false ; <nl> + } <nl> + } <nl> + void value_1_to_2 ( const namespace_directory_metadata_t * value1 , <nl> + const namespace_directory_metadata_t * * value2_out ) { <nl> + * value2_out = value1 ; <nl> + } <nl> + bool key_2_to_1 ( const peer_id_t & key2 , <nl> + std : : pair < peer_id_t , namespace_id_t > * key1_out ) { <nl> + key1_out - > first = key2 ; <nl> + key1_out - > second = nid ; <nl> + return true ; <nl> + } <nl> + namespace_id_t nid ; <nl> + } table_directory ; <nl> + <nl> + bool do_check ( watchable_map_t < peer_id_t , namespace_directory_metadata_t > * dir ) { <nl> + return false ; <nl> + } <nl> + } ; <nl> + <nl> bool real_reql_cluster_interface_t : : table_wait ( <nl> - UNUSED counted_t < const ql : : db_t > db , <nl> - UNUSED const std : : vector < name_string_t > & tables , <nl> - UNUSED const ql : : protob_t < const Backtrace > & bt , <nl> - UNUSED signal_t * interruptor , <nl> - UNUSED scoped_ptr_t < ql : : val_t > * resp_out , <nl> - UNUSED std : : string * error_out ) { <nl> - / / TODO : implement this <nl> - error_out - > assign ( " unimplemented " ) ; <nl> - return false ; <nl> + counted_t < const ql : : db_t > db , <nl> + const std : : set < name_string_t > & tables , <nl> + const ql : : protob_t < const Backtrace > & bt , <nl> + signal_t * interruptor , <nl> + scoped_ptr_t < ql : : val_t > * resp_out , <nl> + std : : string * error_out ) { <nl> + std : : set < namespace_id_t > table_ids ; <nl> + if ( ! get_table_ids_for_query ( db , tables , & table_ids , error_out ) ) { <nl> + return false ; <nl> + } <nl> + <nl> + std : : vector < scoped_ptr_t < table_waiter_t > > waiters ; <nl> + for ( auto const & id : table_ids ) { <nl> + waiters . push_back ( scoped_ptr_t < table_waiter_t > ( <nl> + new table_waiter_t ( directory_root_view , id ) ) ) ; <nl> + } <nl> + <nl> + / / Loop until all tables are ready <nl> + while ( true ) { <nl> + bool immediate = true ; <nl> + for ( auto const & w : waiters ) { <nl> + table_waiter_t : : waited_t res = w - > wait_ready ( interruptor ) ; <nl> + immediate = immediate & & ( res = = table_waiter_t : : waited_t : : IMMEDIATE ) ; <nl> + } <nl> + <nl> + if ( ! immediate ) { <nl> + / / Do a second pass to make sure no tables changed while we were waiting <nl> + bool redo = false ; <nl> + for ( auto const & w : waiters ) { <nl> + if ( ! w - > check_ready ( ) ) { <nl> + redo = true ; <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + if ( redo ) { <nl> + continue ; <nl> + } <nl> + } <nl> + break ; <nl> + } <nl> + <nl> + return table_meta_read ( <nl> + admin_tables - > table_status_backend . get ( ) , " table_wait " , <nl> + table_ids , bt , interruptor , resp_out , error_out ) ; <nl> } <nl> <nl> bool real_reql_cluster_interface_t : : table_reconfigure ( <nl> void real_reql_cluster_interface_t : : get_databases_metadata ( <nl> ph : : _1 , out ) ) ; <nl> } <nl> <nl> - bool real_reql_cluster_interface_t : : table_config_or_status ( <nl> + bool real_reql_cluster_interface_t : : table_meta_read ( <nl> artificial_table_backend_t * backend , const char * backend_name , <nl> - counted_t < const ql : : db_t > db , <nl> - const std : : vector < name_string_t > & tables , <nl> + const std : : set < namespace_id_t > & table_ids , <nl> const ql : : protob_t < const Backtrace > & bt , <nl> signal_t * interruptor , scoped_ptr_t < ql : : val_t > * resp_out , <nl> std : : string * error_out ) { <nl> - guarantee ( db - > name ! = " rethinkdb " , <nl> - " real_reql_cluster_interface_t should never get queries for system tables " ) ; <nl> counted_t < ql : : table_t > table = make_counted < ql : : table_t > ( <nl> scoped_ptr_t < base_table_t > ( new artificial_table_t ( backend ) ) , <nl> make_counted < const ql : : db_t > ( nil_uuid ( ) , " rethinkdb " ) , backend_name , false , bt ) ; <nl> - cow_ptr_t < namespaces_semilattice_metadata_t > namespaces_metadata <nl> - = get_namespaces_metadata ( ) ; <nl> - const_metadata_searcher_t < namespace_semilattice_metadata_t > <nl> - ns_searcher ( & namespaces_metadata . get ( ) - > namespaces ) ; <nl> - if ( tables . size ( ) > 0 ) { <nl> - / / TODO : search for all the tables <nl> - namespace_predicate_t pred ( & tables [ 0 ] , & db - > id ) ; <nl> - metadata_search_status_t status ; <nl> - auto ns_metadata_it = ns_searcher . find_uniq ( pred , & status ) ; <nl> - if ( ! check_metadata_status ( status , " Table " , db - > name + " . " + tables [ 0 ] . str ( ) , true , <nl> - error_out ) ) return false ; <nl> - guarantee ( ! ns_metadata_it - > second . is_deleted ( ) ) ; <nl> - ql : : datum_t pkey = convert_uuid_to_datum ( ns_metadata_it - > first ) ; <nl> + if ( table_ids . size ( ) = = 1 ) { <nl> + ql : : datum_t pkey = convert_uuid_to_datum ( * table_ids . begin ( ) ) ; <nl> ql : : datum_t row ; <nl> if ( ! backend - > read_row ( pkey , interruptor , & row , error_out ) ) { <nl> return false ; <nl> bool real_reql_cluster_interface_t : : table_config_or_status ( <nl> return true ; <nl> } else { <nl> ql : : datum_array_builder_t array_builder ( ql : : configured_limits_t : : unlimited ) ; <nl> - namespace_predicate_t pred ( & db - > id ) ; <nl> - for ( auto it = ns_searcher . find_next ( ns_searcher . begin ( ) , pred ) ; <nl> - it ! = ns_searcher . end ( ) ; <nl> - it = ns_searcher . find_next ( + + it , pred ) ) { <nl> + for ( auto const & id : table_ids ) { <nl> ql : : datum_t row ; <nl> - if ( ! backend - > read_row ( convert_uuid_to_datum ( it - > first ) , interruptor , <nl> - & row , error_out ) ) { <nl> + if ( ! backend - > read_row ( convert_uuid_to_datum ( id ) , interruptor , & row , error_out ) ) { <nl> return false ; <nl> } <nl> array_builder . add ( row ) ; <nl> mmm a / src / clustering / administration / real_reql_cluster_interface . hpp <nl> ppp b / src / clustering / administration / real_reql_cluster_interface . hpp <nl> class real_reql_cluster_interface_t : public reql_cluster_interface_t { <nl> signal_t * interruptor , scoped_ptr_t < base_table_t > * table_out , <nl> std : : string * error_out ) ; <nl> bool table_config ( counted_t < const ql : : db_t > db , <nl> - const std : : vector < name_string_t > & tables , <nl> + const std : : set < name_string_t > & tables , <nl> const ql : : protob_t < const Backtrace > & bt , <nl> signal_t * interruptor , scoped_ptr_t < ql : : val_t > * resp_out , <nl> std : : string * error_out ) ; <nl> bool table_status ( counted_t < const ql : : db_t > db , <nl> - const std : : vector < name_string_t > & tables , <nl> + const std : : set < name_string_t > & tables , <nl> const ql : : protob_t < const Backtrace > & bt , <nl> signal_t * interruptor , scoped_ptr_t < ql : : val_t > * resp_out , <nl> std : : string * error_out ) ; <nl> bool table_wait ( counted_t < const ql : : db_t > db , <nl> - const std : : vector < name_string_t > & tables , <nl> + const std : : set < name_string_t > & tables , <nl> const ql : : protob_t < const Backtrace > & bt , <nl> signal_t * interruptor , scoped_ptr_t < ql : : val_t > * resp_out , <nl> std : : string * error_out ) ; <nl> class real_reql_cluster_interface_t : public reql_cluster_interface_t { <nl> / / This could soooo be optimized if you don ' t want to copy the whole thing . <nl> void get_databases_metadata ( databases_semilattice_metadata_t * out ) ; <nl> <nl> - bool table_config_or_status ( artificial_table_backend_t * backend , <nl> - const char * backend_name , counted_t < const ql : : db_t > db , <nl> - const std : : vector < name_string_t > & tables , <nl> + bool get_table_ids_for_query ( <nl> + counted_t < const ql : : db_t > db , <nl> + const std : : set < name_string_t > & table_names , <nl> + std : : set < namespace_id_t > * table_ids_out , <nl> + std : : string * error_out ) ; <nl> + <nl> + bool table_meta_read ( artificial_table_backend_t * backend , <nl> + const char * backend_name , <nl> + const std : : set < namespace_id_t > & table_ids , <nl> const ql : : protob_t < const Backtrace > & bt , <nl> signal_t * interruptor , scoped_ptr_t < ql : : val_t > * resp_out , <nl> std : : string * error_out ) ; <nl> mmm a / src / rdb_protocol / context . hpp <nl> ppp b / src / rdb_protocol / context . hpp <nl> class reql_cluster_interface_t { <nl> signal_t * interruptor , scoped_ptr_t < base_table_t > * table_out , <nl> std : : string * error_out ) = 0 ; <nl> virtual bool table_config ( counted_t < const ql : : db_t > db , <nl> - const std : : vector < name_string_t > & tables , <nl> + const std : : set < name_string_t > & tables , <nl> const ql : : protob_t < const Backtrace > & bt , <nl> signal_t * interruptor , <nl> scoped_ptr_t < ql : : val_t > * resp_out , <nl> std : : string * error_out ) = 0 ; <nl> virtual bool table_status ( counted_t < const ql : : db_t > db , <nl> - const std : : vector < name_string_t > & tables , <nl> + const std : : set < name_string_t > & tables , <nl> const ql : : protob_t < const Backtrace > & bt , <nl> signal_t * interruptor , <nl> scoped_ptr_t < ql : : val_t > * resp_out , <nl> std : : string * error_out ) = 0 ; <nl> virtual bool table_wait ( counted_t < const ql : : db_t > db , <nl> - const std : : vector < name_string_t > & tables , <nl> + const std : : set < name_string_t > & tables , <nl> const ql : : protob_t < const Backtrace > & bt , <nl> signal_t * interruptor , <nl> scoped_ptr_t < ql : : val_t > * resp_out , <nl> mmm a / src / rdb_protocol / terms / db_table . cc <nl> ppp b / src / rdb_protocol / terms / db_table . cc <nl> class table_list_term_t : public meta_op_term_t { <nl> virtual const char * name ( ) const { return " table_list " ; } <nl> } ; <nl> <nl> - class table_config_or_status_term_t : public meta_op_term_t { <nl> + class table_meta_read_term_t : public meta_op_term_t { <nl> public : <nl> - table_config_or_status_term_t ( compile_env_t * env , const protob_t < const Term > & term ) : <nl> + table_meta_read_term_t ( compile_env_t * env , const protob_t < const Term > & term ) : <nl> meta_op_term_t ( env , term , argspec_t ( 0 , 2 ) ) { } <nl> protected : <nl> virtual bool impl ( scope_env_t * env , <nl> counted_t < const db_t > db , <nl> - const std : : vector < name_string_t > & tables , <nl> + const std : : set < name_string_t > & tables , <nl> scoped_ptr_t < val_t > * resp_out , <nl> std : : string * error_out ) const = 0 ; <nl> private : <nl> class table_config_or_status_term_t : public meta_op_term_t { <nl> <nl> virtual scoped_ptr_t < val_t > eval_impl ( scope_env_t * env , args_t * args , eval_flags_t ) const { <nl> counted_t < const db_t > db ; <nl> - std : : vector < name_string_t > tables ; <nl> + std : : set < name_string_t > tables ; <nl> <nl> if ( args - > num_args ( ) > 0 ) { <nl> for ( size_t i = 0 ; i < args - > num_args ( ) ; + + i ) { <nl> class table_config_or_status_term_t : public meta_op_term_t { <nl> if ( i = = 0 & & arg - > get_type ( ) . is_convertible ( val_t : : type_t : : DB ) ) { <nl> db = arg - > as_db ( ) ; <nl> } else { <nl> - tables . push_back ( get_name ( arg , this , " Table " ) ) ; <nl> + tables . insert ( get_name ( arg , this , " Table " ) ) ; <nl> } <nl> } <nl> } <nl> class table_config_or_status_term_t : public meta_op_term_t { <nl> } <nl> } ; <nl> <nl> - class table_config_term_t : public table_config_or_status_term_t { <nl> + class table_config_term_t : public table_meta_read_term_t { <nl> public : <nl> table_config_term_t ( compile_env_t * env , const protob_t < const Term > & term ) : <nl> - table_config_or_status_term_t ( env , term ) { } <nl> + table_meta_read_term_t ( env , term ) { } <nl> private : <nl> bool impl ( scope_env_t * env , <nl> counted_t < const db_t > db , <nl> - const std : : vector < name_string_t > & tables , <nl> + const std : : set < name_string_t > & tables , <nl> scoped_ptr_t < val_t > * resp_out , <nl> std : : string * error_out ) const { <nl> return env - > env - > reql_cluster_interface ( ) - > table_config ( <nl> class table_config_term_t : public table_config_or_status_term_t { <nl> virtual const char * name ( ) const { return " table_config " ; } <nl> } ; <nl> <nl> - class table_status_term_t : public table_config_or_status_term_t { <nl> + class table_status_term_t : public table_meta_read_term_t { <nl> public : <nl> table_status_term_t ( compile_env_t * env , const protob_t < const Term > & term ) : <nl> - table_config_or_status_term_t ( env , term ) { } <nl> + table_meta_read_term_t ( env , term ) { } <nl> private : <nl> bool impl ( scope_env_t * env , <nl> counted_t < const db_t > db , <nl> - const std : : vector < name_string_t > & tables , <nl> + const std : : set < name_string_t > & tables , <nl> scoped_ptr_t < val_t > * resp_out , <nl> std : : string * error_out ) const { <nl> return env - > env - > reql_cluster_interface ( ) - > table_status ( <nl> class table_status_term_t : public table_config_or_status_term_t { <nl> virtual const char * name ( ) const { return " table_status " ; } <nl> } ; <nl> <nl> - class table_wait_term_t : public table_config_or_status_term_t { <nl> + class table_wait_term_t : public table_meta_read_term_t { <nl> public : <nl> table_wait_term_t ( compile_env_t * env , const protob_t < const Term > & term ) : <nl> - table_config_or_status_term_t ( env , term ) { } <nl> + table_meta_read_term_t ( env , term ) { } <nl> private : <nl> bool impl ( scope_env_t * env , <nl> counted_t < const db_t > db , <nl> - const std : : vector < name_string_t > & tables , <nl> + const std : : set < name_string_t > & tables , <nl> scoped_ptr_t < val_t > * resp_out , <nl> std : : string * error_out ) const { <nl> return env - > env - > reql_cluster_interface ( ) - > table_wait ( <nl> mmm a / src / unittest / rdb_env . cc <nl> ppp b / src / unittest / rdb_env . cc <nl> bool test_rdb_env_t : : instance_t : : table_find ( const name_string_t & name , <nl> <nl> bool test_rdb_env_t : : instance_t : : table_config ( <nl> UNUSED counted_t < const ql : : db_t > db , <nl> - UNUSED const std : : vector < name_string_t > & tables , <nl> + UNUSED const std : : set < name_string_t > & tables , <nl> UNUSED const ql : : protob_t < const Backtrace > & bt , <nl> UNUSED signal_t * local_interruptor , <nl> UNUSED scoped_ptr_t < ql : : val_t > * resp_out , <nl> bool test_rdb_env_t : : instance_t : : table_config ( <nl> <nl> bool test_rdb_env_t : : instance_t : : table_status ( <nl> UNUSED counted_t < const ql : : db_t > db , <nl> - UNUSED const std : : vector < name_string_t > & tables , <nl> + UNUSED const std : : set < name_string_t > & tables , <nl> UNUSED const ql : : protob_t < const Backtrace > & bt , <nl> UNUSED signal_t * local_interruptor , <nl> UNUSED scoped_ptr_t < ql : : val_t > * resp_out , <nl> bool test_rdb_env_t : : instance_t : : table_status ( <nl> <nl> bool test_rdb_env_t : : instance_t : : table_wait ( <nl> UNUSED counted_t < const ql : : db_t > db , <nl> - UNUSED const std : : vector < name_string_t > & tables , <nl> + UNUSED const std : : set < name_string_t > & tables , <nl> UNUSED const ql : : protob_t < const Backtrace > & bt , <nl> UNUSED signal_t * local_interruptor , <nl> UNUSED scoped_ptr_t < ql : : val_t > * resp_out , <nl> mmm a / src / unittest / rdb_env . hpp <nl> ppp b / src / unittest / rdb_env . hpp <nl> class test_rdb_env_t { <nl> signal_t * interruptor , scoped_ptr_t < base_table_t > * table_out , <nl> std : : string * error_out ) ; <nl> bool table_config ( counted_t < const ql : : db_t > db , <nl> - const std : : vector < name_string_t > & tables , <nl> + const std : : set < name_string_t > & tables , <nl> const ql : : protob_t < const Backtrace > & bt , <nl> signal_t * interruptor , scoped_ptr_t < ql : : val_t > * resp_out , <nl> std : : string * error_out ) ; <nl> bool table_status ( counted_t < const ql : : db_t > db , <nl> - const std : : vector < name_string_t > & tables , <nl> + const std : : set < name_string_t > & tables , <nl> const ql : : protob_t < const Backtrace > & bt , <nl> signal_t * interruptor , scoped_ptr_t < ql : : val_t > * resp_out , <nl> std : : string * error_out ) ; <nl> bool table_wait ( counted_t < const ql : : db_t > db , <nl> - const std : : vector < name_string_t > & tables , <nl> + const std : : set < name_string_t > & tables , <nl> const ql : : protob_t < const Backtrace > & bt , <nl> signal_t * interruptor , scoped_ptr_t < ql : : val_t > * resp_out , <nl> std : : string * error_out ) ; <nl>
most of the table_wait logic is implemented , needs to check the directory now
rethinkdb/rethinkdb
b7f831baef2f83ebc15a172bab79a5011a74f74d
2014-10-29T23:25:13Z
mmm a / selfdrive / car / hyundai / carstate . py <nl> ppp b / selfdrive / car / hyundai / carstate . py <nl> def update ( self , cp , cp_cam ) : <nl> <nl> ret . stockAeb = cp . vl [ " FCA11 " ] [ ' FCA_CmdAct ' ] ! = 0 <nl> ret . stockFcw = cp . vl [ " FCA11 " ] [ ' CF_VSM_Warn ' ] = = 2 <nl> + <nl> + ret . leftBlindspot = cp . vl [ " LCA11 " ] [ " CF_Lca_IndLeft " ] ! = 0 <nl> + ret . rightBlindspot = cp . vl [ " LCA11 " ] [ " CF_Lca_IndRight " ] ! = 0 <nl> <nl> # save the entire LKAS11 and CLU11 <nl> self . lkas11 = cp_cam . vl [ " LKAS11 " ] <nl> def get_can_parser ( CP ) : <nl> ( " ESC_Off_Step " , " TCS15 " , 0 ) , <nl> <nl> ( " CF_Lvr_GearInf " , " LVR11 " , 0 ) , # Transmission Gear ( 0 = N or P , 1 - 8 = Fwd , 14 = Rev ) <nl> + <nl> + ( " CF_Lca_IndLeft " , " LCA11 " , 0 ) , <nl> + ( " CF_Lca_IndRight " , " LCA11 " , 0 ) , <nl> <nl> ( " CR_Mdps_StrColTq " , " MDPS12 " , 0 ) , <nl> ( " CF_Mdps_ToiActive " , " MDPS12 " , 0 ) , <nl> def get_can_parser ( CP ) : <nl> ( " SCC11 " , 50 ) , <nl> ( " SCC12 " , 50 ) , <nl> ( " FCA11 " , 50 ) , <nl> + ( " LCA11 " , 50 ) , <nl> ] <nl> <nl> if CP . carFingerprint in EV_HYBRID : <nl> mmm a / selfdrive / test / process_replay / ref_commit <nl> ppp b / selfdrive / test / process_replay / ref_commit <nl> @ @ - 1 + 1 @ @ <nl> - f0ff304da1765fd9cfd36d8c730f280315df91bf <nl> \ No newline at end of file <nl> + 98d3ab8081d04d481adb83980c7852dec8881de5 <nl>
Add Hyundai BSM signals ( )
commaai/openpilot
57f29968a2662bb49807f15165fd69254da0cc93
2020-06-26T19:16:06Z
mmm a / tools / swift - demangle / swift - demangle . cpp <nl> ppp b / tools / swift - demangle / swift - demangle . cpp <nl> static void demangle ( llvm : : raw_ostream & os , llvm : : StringRef name , <nl> remangled = name ; <nl> } else { <nl> remangled = swift : : Demangle : : mangleNode ( pointer , <nl> - / * NewMangling * / name . startswith ( " _S " ) ) ; <nl> + / * NewMangling * / name . startswith ( MANGLING_PREFIX_STR ) ) ; <nl> if ( name ! = remangled ) { <nl> llvm : : errs ( ) < < " \ nError : re - mangled name \ n " < < remangled <nl> < < " \ ndoes not match original name \ n " < < name < < ' \ n ' ; <nl>
swift - demangle : don ’ t hardcode the mangling prefix when processing the - test - remangle option
apple/swift
ea7f27e4cb74d261b769b69b9d8eb1c64205b9d3
2016-12-15T00:39:00Z