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 / caffe / common . hpp <nl> ppp b / include / caffe / common . hpp <nl> <nl> - / / Copyright 2013 Yangqing Jia <nl> - / / Copyright 2014 Evan Shelhamer <nl> + / / Copyright 2014 BVLC and contributors . <nl> <nl> # ifndef CAFFE_COMMON_HPP_ <nl> # define CAFFE_COMMON_HPP_ <nl> mmm a / include / caffe / util / rng . hpp <nl> ppp b / include / caffe / util / rng . hpp <nl> <nl> - / / Copyright 2014 Evan Shelhamer <nl> + / / Copyright 2014 BVLC and contributors . <nl> <nl> # ifndef CAFFE_RNG_CPP_HPP_ <nl> # define CAFFE_RNG_CPP_HPP_ <nl> mmm a / src / caffe / common . cpp <nl> ppp b / src / caffe / common . cpp <nl> <nl> - / / Copyright 2013 Yangqing Jia <nl> - / / Copyright 2014 Evan Shelhamer <nl> + / / Copyright 2014 BVLC and contributors . <nl> <nl> # include < cstdio > <nl> # include < ctime > <nl> mmm a / src / caffe / test / test_random_number_generator . cpp <nl> ppp b / src / caffe / test / test_random_number_generator . cpp <nl> <nl> - / / Copyright 2014 kloudkl @ github <nl> - / / Copyright 2014 Jeff Donahue <nl> - / / Copyright 2014 Alejandro Dubrovsky <nl> - / / Copyright 2014 Evan Shelhamer <nl> + / / Copyright 2014 BVLC and contributors . <nl> <nl> # include < cuda_runtime . h > <nl> # include < cmath > <nl> mmm a / src / caffe / util / math_functions . cpp <nl> ppp b / src / caffe / util / math_functions . cpp <nl> <nl> - / / Copyright 2013 Yangqing Jia <nl> - / / Copyright 2014 kloudkl @ github <nl> - / / Copyright 2014 Evan Shelhamer <nl> + / / Copyright 2014 BVLC and contributors . <nl> <nl> # include < boost / math / special_functions / next . hpp > <nl> # include < boost / random . hpp > <nl>
|
Set copyright to BVLC and contributors .
|
BVLC/caffe
|
bece205114fa666ed390e17dd84a522c43a4f2d6
|
2014-03-22T19:09:39Z
|
mmm a / src / api . cc <nl> ppp b / src / api . cc <nl> enum CompressedStartupDataItems { <nl> kSnapshotContext , <nl> kLibraries , <nl> kExperimentalLibraries , <nl> + # if defined ( V8_I18N_SUPPORT ) <nl> + kI18NExtension , <nl> + # endif <nl> kCompressedStartupDataCount <nl> } ; <nl> <nl> void V8 : : GetCompressedStartupData ( StartupData * compressed_data ) { <nl> exp_libraries_source . length ( ) ; <nl> compressed_data [ kExperimentalLibraries ] . raw_size = <nl> i : : ExperimentalNatives : : GetRawScriptsSize ( ) ; <nl> + <nl> + # if defined ( V8_I18N_SUPPORT ) <nl> + i : : Vector < const ii : byte > i18n_extension_source = <nl> + i : : I18NNatives : : GetScriptsSource ( ) ; <nl> + compressed_data [ kI18NExtension ] . data = <nl> + reinterpret_cast < const char * > ( i18n_extension_source . start ( ) ) ; <nl> + compressed_data [ kI18NExtension ] . compressed_size = <nl> + i18n_extension_source . length ( ) ; <nl> + compressed_data [ kI18NExtension ] . raw_size = <nl> + i : : I18NNatives : : GetRawScriptsSize ( ) ; <nl> + # endif <nl> # endif <nl> } <nl> <nl> void V8 : : SetDecompressedStartupData ( StartupData * decompressed_data ) { <nl> decompressed_data [ kExperimentalLibraries ] . data , <nl> decompressed_data [ kExperimentalLibraries ] . raw_size ) ; <nl> i : : ExperimentalNatives : : SetRawScriptsSource ( exp_libraries_source ) ; <nl> + <nl> + # if defined ( V8_I18N_SUPPORT ) <nl> + ASSERT_EQ ( i : : I18NNatives : : GetRawScriptsSize ( ) , <nl> + decompressed_data [ kI18NExtension ] . raw_size ) ; <nl> + i : : Vector < const char > i18n_extension_source ( <nl> + decompressed_data [ kI18NExtension ] . data , <nl> + decompressed_data [ kI18NExtension ] . raw_size ) ; <nl> + i : : I18NNatives : : SetRawScriptsSource ( i18n_extension_source ) ; <nl> + # endif <nl> # endif <nl> } <nl> <nl> mmm a / src / bootstrapper . cc <nl> ppp b / src / bootstrapper . cc <nl> <nl> # include " extensions / statistics - extension . h " <nl> # include " code - stubs . h " <nl> <nl> + # if defined ( V8_I18N_SUPPORT ) <nl> + # include " extensions / i18n / i18n - extension . h " <nl> + # endif <nl> + <nl> namespace v8 { <nl> namespace internal { <nl> <nl> void Bootstrapper : : InitializeOncePerProcess ( ) { <nl> GCExtension : : Register ( ) ; <nl> ExternalizeStringExtension : : Register ( ) ; <nl> StatisticsExtension : : Register ( ) ; <nl> + # if defined ( V8_I18N_SUPPORT ) <nl> + v8_i18n : : Extension : : Register ( ) ; <nl> + # endif <nl> } <nl> <nl> <nl> bool Genesis : : InstallExtensions ( Handle < Context > native_context , <nl> InstallExtension ( isolate , " v8 / statistics " , & extension_states ) ; <nl> } <nl> <nl> + # if defined ( V8_I18N_SUPPORT ) <nl> + if ( FLAG_enable_i18n ) { <nl> + InstallExtension ( isolate , " v8 / i18n " , & extension_states ) ; <nl> + } <nl> + # endif <nl> + <nl> if ( extensions = = NULL ) return true ; <nl> / / Install required extensions <nl> int count = v8 : : ImplementationUtilities : : GetNameCount ( extensions ) ; <nl> new file mode 100644 <nl> index 00000000000 . . 898bd5dedb5 <nl> mmm / dev / null <nl> ppp b / src / extensions / i18n / break - iterator . js <nl> <nl> + / / Copyright 2013 the V8 project authors . All rights reserved . <nl> + / / Redistribution and use in source and binary forms , with or without <nl> + / / modification , are permitted provided that the following conditions are <nl> + / / met : <nl> + / / <nl> + / / * Redistributions of source code must retain the above copyright <nl> + / / notice , this list of conditions and the following disclaimer . <nl> + / / * Redistributions in binary form must reproduce the above <nl> + / / copyright notice , this list of conditions and the following <nl> + / / disclaimer in the documentation and / or other materials provided <nl> + / / with the distribution . <nl> + / / * Neither the name of Google Inc . nor the names of its <nl> + / / contributors may be used to endorse or promote products derived <nl> + / / from this software without specific prior written permission . <nl> + / / <nl> + / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + / / limitations under the License . <nl> + <nl> + / / ECMAScript 402 API implementation is broken into separate files for <nl> + / / each service . The build system combines them together into one <nl> + / / Intl namespace . <nl> + <nl> + / * * <nl> + * Initializes the given object so it ' s a valid BreakIterator instance . <nl> + * Useful for subclassing . <nl> + * / <nl> + function initializeBreakIterator ( iterator , locales , options ) { <nl> + if ( iterator . hasOwnProperty ( ' __initializedIntlObject ' ) ) { <nl> + throw new TypeError ( ' Trying to re - initialize v8BreakIterator object . ' ) ; <nl> + } <nl> + <nl> + if ( options = = = undefined ) { <nl> + options = { } ; <nl> + } <nl> + <nl> + var getOption = getGetOption ( options , ' breakiterator ' ) ; <nl> + <nl> + var internalOptions = { } ; <nl> + <nl> + defineWEProperty ( internalOptions , ' type ' , getOption ( <nl> + ' type ' , ' string ' , [ ' character ' , ' word ' , ' sentence ' , ' line ' ] , ' word ' ) ) ; <nl> + <nl> + var locale = resolveLocale ( ' breakiterator ' , locales , options ) ; <nl> + var resolved = Object . defineProperties ( { } , { <nl> + requestedLocale : { value : locale . locale , writable : true } , <nl> + type : { value : internalOptions . type , writable : true } , <nl> + locale : { writable : true } <nl> + } ) ; <nl> + <nl> + var internalIterator = % CreateBreakIterator ( locale . locale , <nl> + internalOptions , <nl> + resolved ) ; <nl> + <nl> + Object . defineProperty ( iterator , ' iterator ' , { value : internalIterator } ) ; <nl> + Object . defineProperty ( iterator , ' resolved ' , { value : resolved } ) ; <nl> + Object . defineProperty ( iterator , ' __initializedIntlObject ' , <nl> + { value : ' breakiterator ' } ) ; <nl> + <nl> + return iterator ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Constructs Intl . v8BreakIterator object given optional locales and options <nl> + * parameters . <nl> + * <nl> + * @ constructor <nl> + * / <nl> + % SetProperty ( Intl , ' v8BreakIterator ' , function ( ) { <nl> + var locales = arguments [ 0 ] ; <nl> + var options = arguments [ 1 ] ; <nl> + <nl> + if ( ! this | | this = = = Intl ) { <nl> + / / Constructor is called as a function . <nl> + return new Intl . v8BreakIterator ( locales , options ) ; <nl> + } <nl> + <nl> + return initializeBreakIterator ( toObject ( this ) , locales , options ) ; <nl> + } , <nl> + ATTRIBUTES . DONT_ENUM <nl> + ) ; <nl> + <nl> + <nl> + / * * <nl> + * BreakIterator resolvedOptions method . <nl> + * / <nl> + % SetProperty ( Intl . v8BreakIterator . prototype , ' resolvedOptions ' , function ( ) { <nl> + if ( % _IsConstructCall ( ) ) { <nl> + throw new TypeError ( ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR ) ; <nl> + } <nl> + <nl> + if ( ! this | | typeof this ! = = ' object ' | | <nl> + this . __initializedIntlObject ! = = ' breakiterator ' ) { <nl> + throw new TypeError ( ' resolvedOptions method called on a non - object or ' + <nl> + ' on a object that is not Intl . v8BreakIterator . ' ) ; <nl> + } <nl> + <nl> + var segmenter = this ; <nl> + var locale = getOptimalLanguageTag ( segmenter . resolved . requestedLocale , <nl> + segmenter . resolved . locale ) ; <nl> + <nl> + return { <nl> + locale : locale , <nl> + type : segmenter . resolved . type <nl> + } ; <nl> + } , <nl> + ATTRIBUTES . DONT_ENUM <nl> + ) ; <nl> + % FunctionSetName ( Intl . v8BreakIterator . prototype . resolvedOptions , <nl> + ' resolvedOptions ' ) ; <nl> + % FunctionRemovePrototype ( Intl . v8BreakIterator . prototype . resolvedOptions ) ; <nl> + % SetNativeFlag ( Intl . v8BreakIterator . prototype . resolvedOptions ) ; <nl> + <nl> + <nl> + / * * <nl> + * Returns the subset of the given locale list for which this locale list <nl> + * has a matching ( possibly fallback ) locale . Locales appear in the same <nl> + * order in the returned list as in the input list . <nl> + * Options are optional parameter . <nl> + * / <nl> + % SetProperty ( Intl . v8BreakIterator , ' supportedLocalesOf ' , function ( locales ) { <nl> + if ( % _IsConstructCall ( ) ) { <nl> + throw new TypeError ( ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR ) ; <nl> + } <nl> + <nl> + return supportedLocalesOf ( ' breakiterator ' , locales , arguments [ 1 ] ) ; <nl> + } , <nl> + ATTRIBUTES . DONT_ENUM <nl> + ) ; <nl> + % FunctionSetName ( Intl . v8BreakIterator . supportedLocalesOf , ' supportedLocalesOf ' ) ; <nl> + % FunctionRemovePrototype ( Intl . v8BreakIterator . supportedLocalesOf ) ; <nl> + % SetNativeFlag ( Intl . v8BreakIterator . supportedLocalesOf ) ; <nl> + <nl> + <nl> + / * * <nl> + * Adopts text to segment using the iterator . Old text , if present , <nl> + * gets discarded . <nl> + * / <nl> + function adoptText ( iterator , text ) { <nl> + % BreakIteratorAdoptText ( iterator . iterator , String ( text ) ) ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Returns index of the first break in the string and moves current pointer . <nl> + * / <nl> + function first ( iterator ) { <nl> + return % BreakIteratorFirst ( iterator . iterator ) ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Returns the index of the next break and moves the pointer . <nl> + * / <nl> + function next ( iterator ) { <nl> + return % BreakIteratorNext ( iterator . iterator ) ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Returns index of the current break . <nl> + * / <nl> + function current ( iterator ) { <nl> + return % BreakIteratorCurrent ( iterator . iterator ) ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Returns type of the current break . <nl> + * / <nl> + function breakType ( iterator ) { <nl> + return % BreakIteratorBreakType ( iterator . iterator ) ; <nl> + } <nl> + <nl> + <nl> + addBoundMethod ( Intl . v8BreakIterator , ' adoptText ' , adoptText , 1 ) ; <nl> + addBoundMethod ( Intl . v8BreakIterator , ' first ' , first , 0 ) ; <nl> + addBoundMethod ( Intl . v8BreakIterator , ' next ' , next , 0 ) ; <nl> + addBoundMethod ( Intl . v8BreakIterator , ' current ' , current , 0 ) ; <nl> + addBoundMethod ( Intl . v8BreakIterator , ' breakType ' , breakType , 0 ) ; <nl> new file mode 100644 <nl> index 00000000000 . . d8d247b36f4 <nl> mmm / dev / null <nl> ppp b / src / extensions / i18n / collator . js <nl> <nl> + / / Copyright 2013 the V8 project authors . All rights reserved . <nl> + / / Redistribution and use in source and binary forms , with or without <nl> + / / modification , are permitted provided that the following conditions are <nl> + / / met : <nl> + / / <nl> + / / * Redistributions of source code must retain the above copyright <nl> + / / notice , this list of conditions and the following disclaimer . <nl> + / / * Redistributions in binary form must reproduce the above <nl> + / / copyright notice , this list of conditions and the following <nl> + / / disclaimer in the documentation and / or other materials provided <nl> + / / with the distribution . <nl> + / / * Neither the name of Google Inc . nor the names of its <nl> + / / contributors may be used to endorse or promote products derived <nl> + / / from this software without specific prior written permission . <nl> + / / <nl> + / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + / / limitations under the License . <nl> + <nl> + / / ECMAScript 402 API implementation is broken into separate files for <nl> + / / each service . The build system combines them together into one <nl> + / / Intl namespace . <nl> + <nl> + / * * <nl> + * Initializes the given object so it ' s a valid Collator instance . <nl> + * Useful for subclassing . <nl> + * / <nl> + function initializeCollator ( collator , locales , options ) { <nl> + if ( collator . hasOwnProperty ( ' __initializedIntlObject ' ) ) { <nl> + throw new TypeError ( ' Trying to re - initialize Collator object . ' ) ; <nl> + } <nl> + <nl> + if ( options = = = undefined ) { <nl> + options = { } ; <nl> + } <nl> + <nl> + var getOption = getGetOption ( options , ' collator ' ) ; <nl> + <nl> + var internalOptions = { } ; <nl> + <nl> + defineWEProperty ( internalOptions , ' usage ' , getOption ( <nl> + ' usage ' , ' string ' , [ ' sort ' , ' search ' ] , ' sort ' ) ) ; <nl> + <nl> + var sensitivity = getOption ( ' sensitivity ' , ' string ' , <nl> + [ ' base ' , ' accent ' , ' case ' , ' variant ' ] ) ; <nl> + if ( sensitivity = = = undefined & & internalOptions . usage = = = ' sort ' ) { <nl> + sensitivity = ' variant ' ; <nl> + } <nl> + defineWEProperty ( internalOptions , ' sensitivity ' , sensitivity ) ; <nl> + <nl> + defineWEProperty ( internalOptions , ' ignorePunctuation ' , getOption ( <nl> + ' ignorePunctuation ' , ' boolean ' , undefined , false ) ) ; <nl> + <nl> + var locale = resolveLocale ( ' collator ' , locales , options ) ; <nl> + <nl> + / / ICU can ' t take kb , kc . . . parameters through localeID , so we need to pass <nl> + / / them as options . <nl> + / / One exception is - co - which has to be part of the extension , but only for <nl> + / / usage : sort , and its value can ' t be ' standard ' or ' search ' . <nl> + var extensionMap = parseExtension ( locale . extension ) ; <nl> + setOptions ( <nl> + options , extensionMap , COLLATOR_KEY_MAP , getOption , internalOptions ) ; <nl> + <nl> + var collation = ' default ' ; <nl> + var extension = ' ' ; <nl> + if ( extensionMap . hasOwnProperty ( ' co ' ) & & internalOptions . usage = = = ' sort ' ) { <nl> + if ( ALLOWED_CO_VALUES . indexOf ( extensionMap . co ) ! = = - 1 ) { <nl> + extension = ' - u - co - ' + extensionMap . co ; <nl> + / / ICU can ' t tell us what the collation is , so save user ' s input . <nl> + collation = extensionMap . co ; <nl> + } <nl> + } else if ( internalOptions . usage = = = ' search ' ) { <nl> + extension = ' - u - co - search ' ; <nl> + } <nl> + defineWEProperty ( internalOptions , ' collation ' , collation ) ; <nl> + <nl> + var requestedLocale = locale . locale + extension ; <nl> + <nl> + / / We define all properties C + + code may produce , to prevent security <nl> + / / problems . If malicious user decides to redefine Object . prototype . locale <nl> + / / we can ' t just use plain x . locale = ' us ' or in C + + Set ( " locale " , " us " ) . <nl> + / / Object . defineProperties will either succeed defining or throw an error . <nl> + var resolved = Object . defineProperties ( { } , { <nl> + caseFirst : { writable : true } , <nl> + collation : { value : internalOptions . collation , writable : true } , <nl> + ignorePunctuation : { writable : true } , <nl> + locale : { writable : true } , <nl> + numeric : { writable : true } , <nl> + requestedLocale : { value : requestedLocale , writable : true } , <nl> + sensitivity : { writable : true } , <nl> + strength : { writable : true } , <nl> + usage : { value : internalOptions . usage , writable : true } <nl> + } ) ; <nl> + <nl> + var internalCollator = % CreateCollator ( requestedLocale , <nl> + internalOptions , <nl> + resolved ) ; <nl> + <nl> + / / Writable , configurable and enumerable are set to false by default . <nl> + Object . defineProperty ( collator , ' collator ' , { value : internalCollator } ) ; <nl> + Object . defineProperty ( collator , ' __initializedIntlObject ' , <nl> + { value : ' collator ' } ) ; <nl> + Object . defineProperty ( collator , ' resolved ' , { value : resolved } ) ; <nl> + <nl> + return collator ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Constructs Intl . Collator object given optional locales and options <nl> + * parameters . <nl> + * <nl> + * @ constructor <nl> + * / <nl> + % SetProperty ( Intl , ' Collator ' , function ( ) { <nl> + var locales = arguments [ 0 ] ; <nl> + var options = arguments [ 1 ] ; <nl> + <nl> + if ( ! this | | this = = = Intl ) { <nl> + / / Constructor is called as a function . <nl> + return new Intl . Collator ( locales , options ) ; <nl> + } <nl> + <nl> + return initializeCollator ( toObject ( this ) , locales , options ) ; <nl> + } , <nl> + ATTRIBUTES . DONT_ENUM <nl> + ) ; <nl> + <nl> + <nl> + / * * <nl> + * Collator resolvedOptions method . <nl> + * / <nl> + % SetProperty ( Intl . Collator . prototype , ' resolvedOptions ' , function ( ) { <nl> + if ( % _IsConstructCall ( ) ) { <nl> + throw new TypeError ( ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR ) ; <nl> + } <nl> + <nl> + if ( ! this | | typeof this ! = = ' object ' | | <nl> + this . __initializedIntlObject ! = = ' collator ' ) { <nl> + throw new TypeError ( ' resolvedOptions method called on a non - object ' + <nl> + ' or on a object that is not Intl . Collator . ' ) ; <nl> + } <nl> + <nl> + var coll = this ; <nl> + var locale = getOptimalLanguageTag ( coll . resolved . requestedLocale , <nl> + coll . resolved . locale ) ; <nl> + <nl> + return { <nl> + locale : locale , <nl> + usage : coll . resolved . usage , <nl> + sensitivity : coll . resolved . sensitivity , <nl> + ignorePunctuation : coll . resolved . ignorePunctuation , <nl> + numeric : coll . resolved . numeric , <nl> + caseFirst : coll . resolved . caseFirst , <nl> + collation : coll . resolved . collation <nl> + } ; <nl> + } , <nl> + ATTRIBUTES . DONT_ENUM <nl> + ) ; <nl> + % FunctionSetName ( Intl . Collator . prototype . resolvedOptions , ' resolvedOptions ' ) ; <nl> + % FunctionRemovePrototype ( Intl . Collator . prototype . resolvedOptions ) ; <nl> + % SetNativeFlag ( Intl . Collator . prototype . resolvedOptions ) ; <nl> + <nl> + <nl> + / * * <nl> + * Returns the subset of the given locale list for which this locale list <nl> + * has a matching ( possibly fallback ) locale . Locales appear in the same <nl> + * order in the returned list as in the input list . <nl> + * Options are optional parameter . <nl> + * / <nl> + % SetProperty ( Intl . Collator , ' supportedLocalesOf ' , function ( locales ) { <nl> + if ( % _IsConstructCall ( ) ) { <nl> + throw new TypeError ( ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR ) ; <nl> + } <nl> + <nl> + return supportedLocalesOf ( ' collator ' , locales , arguments [ 1 ] ) ; <nl> + } , <nl> + ATTRIBUTES . DONT_ENUM <nl> + ) ; <nl> + % FunctionSetName ( Intl . Collator . supportedLocalesOf , ' supportedLocalesOf ' ) ; <nl> + % FunctionRemovePrototype ( Intl . Collator . supportedLocalesOf ) ; <nl> + % SetNativeFlag ( Intl . Collator . supportedLocalesOf ) ; <nl> + <nl> + <nl> + / * * <nl> + * When the compare method is called with two arguments x and y , it returns a <nl> + * Number other than NaN that represents the result of a locale - sensitive <nl> + * String comparison of x with y . <nl> + * The result is intended to order String values in the sort order specified <nl> + * by the effective locale and collation options computed during construction <nl> + * of this Collator object , and will be negative , zero , or positive , depending <nl> + * on whether x comes before y in the sort order , the Strings are equal under <nl> + * the sort order , or x comes after y in the sort order , respectively . <nl> + * / <nl> + function compare ( collator , x , y ) { <nl> + return % InternalCompare ( collator . collator , String ( x ) , String ( y ) ) ; <nl> + } ; <nl> + <nl> + <nl> + addBoundMethod ( Intl . Collator , ' compare ' , compare , 2 ) ; <nl> new file mode 100644 <nl> index 00000000000 . . b1d28e535cd <nl> mmm / dev / null <nl> ppp b / src / extensions / i18n / date - format . js <nl> <nl> + / / Copyright 2013 the V8 project authors . All rights reserved . <nl> + / / Redistribution and use in source and binary forms , with or without <nl> + / / modification , are permitted provided that the following conditions are <nl> + / / met : <nl> + / / <nl> + / / * Redistributions of source code must retain the above copyright <nl> + / / notice , this list of conditions and the following disclaimer . <nl> + / / * Redistributions in binary form must reproduce the above <nl> + / / copyright notice , this list of conditions and the following <nl> + / / disclaimer in the documentation and / or other materials provided <nl> + / / with the distribution . <nl> + / / * Neither the name of Google Inc . nor the names of its <nl> + / / contributors may be used to endorse or promote products derived <nl> + / / from this software without specific prior written permission . <nl> + / / <nl> + / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + / / limitations under the License . <nl> + <nl> + / / ECMAScript 402 API implementation is broken into separate files for <nl> + / / each service . The build system combines them together into one <nl> + / / Intl namespace . <nl> + <nl> + / * * <nl> + * Returns a string that matches LDML representation of the options object . <nl> + * / <nl> + function toLDMLString ( options ) { <nl> + var getOption = getGetOption ( options , ' dateformat ' ) ; <nl> + <nl> + var ldmlString = ' ' ; <nl> + <nl> + var option = getOption ( ' weekday ' , ' string ' , [ ' narrow ' , ' short ' , ' long ' ] ) ; <nl> + ldmlString + = appendToLDMLString ( <nl> + option , { narrow : ' EEEEE ' , short : ' EEE ' , long : ' EEEE ' } ) ; <nl> + <nl> + option = getOption ( ' era ' , ' string ' , [ ' narrow ' , ' short ' , ' long ' ] ) ; <nl> + ldmlString + = appendToLDMLString ( <nl> + option , { narrow : ' GGGGG ' , short : ' GGG ' , long : ' GGGG ' } ) ; <nl> + <nl> + option = getOption ( ' year ' , ' string ' , [ ' 2 - digit ' , ' numeric ' ] ) ; <nl> + ldmlString + = appendToLDMLString ( option , { ' 2 - digit ' : ' yy ' , ' numeric ' : ' y ' } ) ; <nl> + <nl> + option = getOption ( ' month ' , ' string ' , <nl> + [ ' 2 - digit ' , ' numeric ' , ' narrow ' , ' short ' , ' long ' ] ) ; <nl> + ldmlString + = appendToLDMLString ( option , { ' 2 - digit ' : ' MM ' , ' numeric ' : ' M ' , <nl> + ' narrow ' : ' MMMMM ' , ' short ' : ' MMM ' , ' long ' : ' MMMM ' } ) ; <nl> + <nl> + option = getOption ( ' day ' , ' string ' , [ ' 2 - digit ' , ' numeric ' ] ) ; <nl> + ldmlString + = appendToLDMLString ( <nl> + option , { ' 2 - digit ' : ' dd ' , ' numeric ' : ' d ' } ) ; <nl> + <nl> + var hr12 = getOption ( ' hour12 ' , ' boolean ' ) ; <nl> + option = getOption ( ' hour ' , ' string ' , [ ' 2 - digit ' , ' numeric ' ] ) ; <nl> + if ( hr12 = = = undefined ) { <nl> + ldmlString + = appendToLDMLString ( option , { ' 2 - digit ' : ' jj ' , ' numeric ' : ' j ' } ) ; <nl> + } else if ( hr12 = = = true ) { <nl> + ldmlString + = appendToLDMLString ( option , { ' 2 - digit ' : ' hh ' , ' numeric ' : ' h ' } ) ; <nl> + } else { <nl> + ldmlString + = appendToLDMLString ( option , { ' 2 - digit ' : ' HH ' , ' numeric ' : ' H ' } ) ; <nl> + } <nl> + <nl> + option = getOption ( ' minute ' , ' string ' , [ ' 2 - digit ' , ' numeric ' ] ) ; <nl> + ldmlString + = appendToLDMLString ( option , { ' 2 - digit ' : ' mm ' , ' numeric ' : ' m ' } ) ; <nl> + <nl> + option = getOption ( ' second ' , ' string ' , [ ' 2 - digit ' , ' numeric ' ] ) ; <nl> + ldmlString + = appendToLDMLString ( option , { ' 2 - digit ' : ' ss ' , ' numeric ' : ' s ' } ) ; <nl> + <nl> + option = getOption ( ' timeZoneName ' , ' string ' , [ ' short ' , ' long ' ] ) ; <nl> + ldmlString + = appendToLDMLString ( option , { short : ' v ' , long : ' vv ' } ) ; <nl> + <nl> + return ldmlString ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Returns either LDML equivalent of the current option or empty string . <nl> + * / <nl> + function appendToLDMLString ( option , pairs ) { <nl> + if ( option ! = = undefined ) { <nl> + return pairs [ option ] ; <nl> + } else { <nl> + return ' ' ; <nl> + } <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Returns object that matches LDML representation of the date . <nl> + * / <nl> + function fromLDMLString ( ldmlString ) { <nl> + / / First remove ' ' quoted text , so we lose ' Uhr ' strings . <nl> + ldmlString = ldmlString . replace ( QUOTED_STRING_RE , ' ' ) ; <nl> + <nl> + var options = { } ; <nl> + var match = ldmlString . match ( / E { 3 , 5 } / g ) ; <nl> + options = appendToDateTimeObject ( <nl> + options , ' weekday ' , match , { EEEEE : ' narrow ' , EEE : ' short ' , EEEE : ' long ' } ) ; <nl> + <nl> + match = ldmlString . match ( / G { 3 , 5 } / g ) ; <nl> + options = appendToDateTimeObject ( <nl> + options , ' era ' , match , { GGGGG : ' narrow ' , GGG : ' short ' , GGGG : ' long ' } ) ; <nl> + <nl> + match = ldmlString . match ( / y { 1 , 2 } / g ) ; <nl> + options = appendToDateTimeObject ( <nl> + options , ' year ' , match , { y : ' numeric ' , yy : ' 2 - digit ' } ) ; <nl> + <nl> + match = ldmlString . match ( / M { 1 , 5 } / g ) ; <nl> + options = appendToDateTimeObject ( options , ' month ' , match , { MM : ' 2 - digit ' , <nl> + M : ' numeric ' , MMMMM : ' narrow ' , MMM : ' short ' , MMMM : ' long ' } ) ; <nl> + <nl> + / / Sometimes we get L instead of M for month - standalone name . <nl> + match = ldmlString . match ( / L { 1 , 5 } / g ) ; <nl> + options = appendToDateTimeObject ( options , ' month ' , match , { LL : ' 2 - digit ' , <nl> + L : ' numeric ' , LLLLL : ' narrow ' , LLL : ' short ' , LLLL : ' long ' } ) ; <nl> + <nl> + match = ldmlString . match ( / d { 1 , 2 } / g ) ; <nl> + options = appendToDateTimeObject ( <nl> + options , ' day ' , match , { d : ' numeric ' , dd : ' 2 - digit ' } ) ; <nl> + <nl> + match = ldmlString . match ( / h { 1 , 2 } / g ) ; <nl> + if ( match ! = = null ) { <nl> + options [ ' hour12 ' ] = true ; <nl> + } <nl> + options = appendToDateTimeObject ( <nl> + options , ' hour ' , match , { h : ' numeric ' , hh : ' 2 - digit ' } ) ; <nl> + <nl> + match = ldmlString . match ( / H { 1 , 2 } / g ) ; <nl> + if ( match ! = = null ) { <nl> + options [ ' hour12 ' ] = false ; <nl> + } <nl> + options = appendToDateTimeObject ( <nl> + options , ' hour ' , match , { H : ' numeric ' , HH : ' 2 - digit ' } ) ; <nl> + <nl> + match = ldmlString . match ( / m { 1 , 2 } / g ) ; <nl> + options = appendToDateTimeObject ( <nl> + options , ' minute ' , match , { m : ' numeric ' , mm : ' 2 - digit ' } ) ; <nl> + <nl> + match = ldmlString . match ( / s { 1 , 2 } / g ) ; <nl> + options = appendToDateTimeObject ( <nl> + options , ' second ' , match , { s : ' numeric ' , ss : ' 2 - digit ' } ) ; <nl> + <nl> + match = ldmlString . match ( / v { 1 , 2 } / g ) ; <nl> + options = appendToDateTimeObject ( <nl> + options , ' timeZoneName ' , match , { v : ' short ' , vv : ' long ' } ) ; <nl> + <nl> + return options ; <nl> + } <nl> + <nl> + <nl> + function appendToDateTimeObject ( options , option , match , pairs ) { <nl> + if ( match = = = null ) { <nl> + if ( ! options . hasOwnProperty ( option ) ) { <nl> + defineWEProperty ( options , option , undefined ) ; <nl> + } <nl> + return options ; <nl> + } <nl> + <nl> + var property = match [ 0 ] ; <nl> + defineWEProperty ( options , option , pairs [ property ] ) ; <nl> + <nl> + return options ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Returns options with at least default values in it . <nl> + * / <nl> + function toDateTimeOptions ( options , required , defaults ) { <nl> + if ( options = = = undefined ) { <nl> + options = null ; <nl> + } else { <nl> + options = toObject ( options ) ; <nl> + } <nl> + <nl> + options = Object . apply ( this , [ options ] ) ; <nl> + <nl> + var needsDefault = true ; <nl> + if ( ( required = = = ' date ' | | required = = = ' any ' ) & & <nl> + ( options . weekday ! = = undefined | | options . year ! = = undefined | | <nl> + options . month ! = = undefined | | options . day ! = = undefined ) ) { <nl> + needsDefault = false ; <nl> + } <nl> + <nl> + if ( ( required = = = ' time ' | | required = = = ' any ' ) & & <nl> + ( options . hour ! = = undefined | | options . minute ! = = undefined | | <nl> + options . second ! = = undefined ) ) { <nl> + needsDefault = false ; <nl> + } <nl> + <nl> + if ( needsDefault & & ( defaults = = = ' date ' | | defaults = = = ' all ' ) ) { <nl> + Object . defineProperty ( options , ' year ' , { value : ' numeric ' , <nl> + writable : true , <nl> + enumerable : true , <nl> + configurable : true } ) ; <nl> + Object . defineProperty ( options , ' month ' , { value : ' numeric ' , <nl> + writable : true , <nl> + enumerable : true , <nl> + configurable : true } ) ; <nl> + Object . defineProperty ( options , ' day ' , { value : ' numeric ' , <nl> + writable : true , <nl> + enumerable : true , <nl> + configurable : true } ) ; <nl> + } <nl> + <nl> + if ( needsDefault & & ( defaults = = = ' time ' | | defaults = = = ' all ' ) ) { <nl> + Object . defineProperty ( options , ' hour ' , { value : ' numeric ' , <nl> + writable : true , <nl> + enumerable : true , <nl> + configurable : true } ) ; <nl> + Object . defineProperty ( options , ' minute ' , { value : ' numeric ' , <nl> + writable : true , <nl> + enumerable : true , <nl> + configurable : true } ) ; <nl> + Object . defineProperty ( options , ' second ' , { value : ' numeric ' , <nl> + writable : true , <nl> + enumerable : true , <nl> + configurable : true } ) ; <nl> + } <nl> + <nl> + return options ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Initializes the given object so it ' s a valid DateTimeFormat instance . <nl> + * Useful for subclassing . <nl> + * / <nl> + function initializeDateTimeFormat ( dateFormat , locales , options ) { <nl> + <nl> + if ( dateFormat . hasOwnProperty ( ' __initializedIntlObject ' ) ) { <nl> + throw new TypeError ( ' Trying to re - initialize DateTimeFormat object . ' ) ; <nl> + } <nl> + <nl> + if ( options = = = undefined ) { <nl> + options = { } ; <nl> + } <nl> + <nl> + var locale = resolveLocale ( ' dateformat ' , locales , options ) ; <nl> + <nl> + options = toDateTimeOptions ( options , ' any ' , ' date ' ) ; <nl> + <nl> + var getOption = getGetOption ( options , ' dateformat ' ) ; <nl> + <nl> + / / We implement only best fit algorithm , but still need to check <nl> + / / if the formatMatcher values are in range . <nl> + var matcher = getOption ( ' formatMatcher ' , ' string ' , <nl> + [ ' basic ' , ' best fit ' ] , ' best fit ' ) ; <nl> + <nl> + / / Build LDML string for the skeleton that we pass to the formatter . <nl> + var ldmlString = toLDMLString ( options ) ; <nl> + <nl> + / / Filter out supported extension keys so we know what to put in resolved <nl> + / / section later on . <nl> + / / We need to pass calendar and number system to the method . <nl> + var tz = canonicalizeTimeZoneID ( options . timeZone ) ; <nl> + <nl> + / / ICU prefers options to be passed using - u - extension key / values , so <nl> + / / we need to build that . <nl> + var internalOptions = { } ; <nl> + var extensionMap = parseExtension ( locale . extension ) ; <nl> + var extension = setOptions ( options , extensionMap , DATETIME_FORMAT_KEY_MAP , <nl> + getOption , internalOptions ) ; <nl> + <nl> + var requestedLocale = locale . locale + extension ; <nl> + var resolved = Object . defineProperties ( { } , { <nl> + calendar : { writable : true } , <nl> + day : { writable : true } , <nl> + era : { writable : true } , <nl> + hour12 : { writable : true } , <nl> + hour : { writable : true } , <nl> + locale : { writable : true } , <nl> + minute : { writable : true } , <nl> + month : { writable : true } , <nl> + numberingSystem : { writable : true } , <nl> + pattern : { writable : true } , <nl> + requestedLocale : { value : requestedLocale , writable : true } , <nl> + second : { writable : true } , <nl> + timeZone : { writable : true } , <nl> + timeZoneName : { writable : true } , <nl> + tz : { value : tz , writable : true } , <nl> + weekday : { writable : true } , <nl> + year : { writable : true } <nl> + } ) ; <nl> + <nl> + var formatter = % CreateDateTimeFormat ( <nl> + requestedLocale , { skeleton : ldmlString , timeZone : tz } , resolved ) ; <nl> + <nl> + if ( tz ! = = undefined & & tz ! = = resolved . timeZone ) { <nl> + throw new RangeError ( ' Unsupported time zone specified ' + tz ) ; <nl> + } <nl> + <nl> + Object . defineProperty ( dateFormat , ' formatter ' , { value : formatter } ) ; <nl> + Object . defineProperty ( dateFormat , ' resolved ' , { value : resolved } ) ; <nl> + Object . defineProperty ( dateFormat , ' __initializedIntlObject ' , <nl> + { value : ' dateformat ' } ) ; <nl> + <nl> + return dateFormat ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Constructs Intl . DateTimeFormat object given optional locales and options <nl> + * parameters . <nl> + * <nl> + * @ constructor <nl> + * / <nl> + % SetProperty ( Intl , ' DateTimeFormat ' , function ( ) { <nl> + var locales = arguments [ 0 ] ; <nl> + var options = arguments [ 1 ] ; <nl> + <nl> + if ( ! this | | this = = = Intl ) { <nl> + / / Constructor is called as a function . <nl> + return new Intl . DateTimeFormat ( locales , options ) ; <nl> + } <nl> + <nl> + return initializeDateTimeFormat ( toObject ( this ) , locales , options ) ; <nl> + } , <nl> + ATTRIBUTES . DONT_ENUM <nl> + ) ; <nl> + <nl> + <nl> + / * * <nl> + * DateTimeFormat resolvedOptions method . <nl> + * / <nl> + % SetProperty ( Intl . DateTimeFormat . prototype , ' resolvedOptions ' , function ( ) { <nl> + if ( % _IsConstructCall ( ) ) { <nl> + throw new TypeError ( ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR ) ; <nl> + } <nl> + <nl> + if ( ! this | | typeof this ! = = ' object ' | | <nl> + this . __initializedIntlObject ! = = ' dateformat ' ) { <nl> + throw new TypeError ( ' resolvedOptions method called on a non - object or ' + <nl> + ' on a object that is not Intl . DateTimeFormat . ' ) ; <nl> + } <nl> + <nl> + var format = this ; <nl> + var fromPattern = fromLDMLString ( format . resolved . pattern ) ; <nl> + var userCalendar = ICU_CALENDAR_MAP [ format . resolved . calendar ] ; <nl> + if ( userCalendar = = = undefined ) { <nl> + / / Use ICU name if we don ' t have a match . It shouldn ' t happen , but <nl> + / / it would be too strict to throw for this . <nl> + userCalendar = format . resolved . calendar ; <nl> + } <nl> + <nl> + var locale = getOptimalLanguageTag ( format . resolved . requestedLocale , <nl> + format . resolved . locale ) ; <nl> + <nl> + var result = { <nl> + locale : locale , <nl> + numberingSystem : format . resolved . numberingSystem , <nl> + calendar : userCalendar , <nl> + timeZone : format . resolved . timeZone <nl> + } ; <nl> + <nl> + addWECPropertyIfDefined ( result , ' timeZoneName ' , fromPattern . timeZoneName ) ; <nl> + addWECPropertyIfDefined ( result , ' era ' , fromPattern . era ) ; <nl> + addWECPropertyIfDefined ( result , ' year ' , fromPattern . year ) ; <nl> + addWECPropertyIfDefined ( result , ' month ' , fromPattern . month ) ; <nl> + addWECPropertyIfDefined ( result , ' day ' , fromPattern . day ) ; <nl> + addWECPropertyIfDefined ( result , ' weekday ' , fromPattern . weekday ) ; <nl> + addWECPropertyIfDefined ( result , ' hour12 ' , fromPattern . hour12 ) ; <nl> + addWECPropertyIfDefined ( result , ' hour ' , fromPattern . hour ) ; <nl> + addWECPropertyIfDefined ( result , ' minute ' , fromPattern . minute ) ; <nl> + addWECPropertyIfDefined ( result , ' second ' , fromPattern . second ) ; <nl> + <nl> + return result ; <nl> + } , <nl> + ATTRIBUTES . DONT_ENUM <nl> + ) ; <nl> + % FunctionSetName ( Intl . DateTimeFormat . prototype . resolvedOptions , <nl> + ' resolvedOptions ' ) ; <nl> + % FunctionRemovePrototype ( Intl . DateTimeFormat . prototype . resolvedOptions ) ; <nl> + % SetNativeFlag ( Intl . DateTimeFormat . prototype . resolvedOptions ) ; <nl> + <nl> + <nl> + / * * <nl> + * Returns the subset of the given locale list for which this locale list <nl> + * has a matching ( possibly fallback ) locale . Locales appear in the same <nl> + * order in the returned list as in the input list . <nl> + * Options are optional parameter . <nl> + * / <nl> + % SetProperty ( Intl . DateTimeFormat , ' supportedLocalesOf ' , function ( locales ) { <nl> + if ( % _IsConstructCall ( ) ) { <nl> + throw new TypeError ( ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR ) ; <nl> + } <nl> + <nl> + return supportedLocalesOf ( ' dateformat ' , locales , arguments [ 1 ] ) ; <nl> + } , <nl> + ATTRIBUTES . DONT_ENUM <nl> + ) ; <nl> + % FunctionSetName ( Intl . DateTimeFormat . supportedLocalesOf , ' supportedLocalesOf ' ) ; <nl> + % FunctionRemovePrototype ( Intl . DateTimeFormat . supportedLocalesOf ) ; <nl> + % SetNativeFlag ( Intl . DateTimeFormat . supportedLocalesOf ) ; <nl> + <nl> + <nl> + / * * <nl> + * Returns a String value representing the result of calling ToNumber ( date ) <nl> + * according to the effective locale and the formatting options of this <nl> + * DateTimeFormat . <nl> + * / <nl> + function formatDate ( formatter , dateValue ) { <nl> + var dateMs ; <nl> + if ( dateValue = = = undefined ) { <nl> + dateMs = Date . now ( ) ; <nl> + } else { <nl> + dateMs = Number ( dateValue ) ; <nl> + } <nl> + <nl> + if ( ! isFinite ( dateMs ) ) { <nl> + throw new RangeError ( ' Provided date is not in valid range . ' ) ; <nl> + } <nl> + <nl> + return % InternalDateFormat ( formatter . formatter , new Date ( dateMs ) ) ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Returns a Date object representing the result of calling ToString ( value ) <nl> + * according to the effective locale and the formatting options of this <nl> + * DateTimeFormat . <nl> + * Returns undefined if date string cannot be parsed . <nl> + * / <nl> + function parseDate ( formatter , value ) { <nl> + return % InternalDateParse ( formatter . formatter , String ( value ) ) ; <nl> + } <nl> + <nl> + <nl> + / / 0 because date is optional argument . <nl> + addBoundMethod ( Intl . DateTimeFormat , ' format ' , formatDate , 0 ) ; <nl> + addBoundMethod ( Intl . DateTimeFormat , ' v8Parse ' , parseDate , 1 ) ; <nl> + <nl> + <nl> + / * * <nl> + * Returns canonical Area / Location name , or throws an exception if the zone <nl> + * name is invalid IANA name . <nl> + * / <nl> + function canonicalizeTimeZoneID ( tzID ) { <nl> + / / Skip undefined zones . <nl> + if ( tzID = = = undefined ) { <nl> + return tzID ; <nl> + } <nl> + <nl> + / / Special case handling ( UTC , GMT ) . <nl> + var upperID = tzID . toUpperCase ( ) ; <nl> + if ( upperID = = = ' UTC ' | | upperID = = = ' GMT ' | | <nl> + upperID = = = ' ETC / UTC ' | | upperID = = = ' ETC / GMT ' ) { <nl> + return ' UTC ' ; <nl> + } <nl> + <nl> + / / We expect only _ and / beside ASCII letters . <nl> + / / All inputs should conform to Area / Location from now on . <nl> + var match = TIMEZONE_NAME_CHECK_RE . exec ( tzID ) ; <nl> + if ( match = = = null ) { <nl> + throw new RangeError ( ' Expected Area / Location for time zone , got ' + tzID ) ; <nl> + } <nl> + <nl> + var result = toTitleCaseWord ( match [ 1 ] ) + ' / ' + toTitleCaseWord ( match [ 2 ] ) ; <nl> + var i = 3 ; <nl> + while ( match [ i ] ! = = undefined & & i < match . length ) { <nl> + result = result + ' _ ' + toTitleCaseWord ( match [ i ] ) ; <nl> + i + + ; <nl> + } <nl> + <nl> + return result ; <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . ac33f1e2422 <nl> mmm / dev / null <nl> ppp b / src / extensions / i18n / footer . js <nl> <nl> + / / Copyright 2013 the V8 project authors . All rights reserved . <nl> + / / Redistribution and use in source and binary forms , with or without <nl> + / / modification , are permitted provided that the following conditions are <nl> + / / met : <nl> + / / <nl> + / / * Redistributions of source code must retain the above copyright <nl> + / / notice , this list of conditions and the following disclaimer . <nl> + / / * Redistributions in binary form must reproduce the above <nl> + / / copyright notice , this list of conditions and the following <nl> + / / disclaimer in the documentation and / or other materials provided <nl> + / / with the distribution . <nl> + / / * Neither the name of Google Inc . nor the names of its <nl> + / / contributors may be used to endorse or promote products derived <nl> + / / from this software without specific prior written permission . <nl> + / / <nl> + / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + / / limitations under the License . <nl> + <nl> + / / ECMAScript 402 API implementation is broken into separate files for <nl> + / / each service . The build system combines them together into one <nl> + / / Intl namespace . <nl> + <nl> + / / Fix RegExp global state so we don ' t fail WebKit layout test : <nl> + / / fast / js / regexp - caching . html <nl> + / / It seems that ' g ' or test ( ) operations leave state changed . <nl> + var CLEANUP_RE = new RegExp ( ' ' ) ; <nl> + CLEANUP_RE . test ( ' ' ) ; <nl> + <nl> + return Intl ; <nl> + } ( ) ) ; <nl> new file mode 100644 <nl> index 00000000000 . . 68fabe777f5 <nl> mmm / dev / null <nl> ppp b / src / extensions / i18n / globals . js <nl> <nl> + / / Copyright 2013 the V8 project authors . All rights reserved . <nl> + / / Redistribution and use in source and binary forms , with or without <nl> + / / modification , are permitted provided that the following conditions are <nl> + / / met : <nl> + / / <nl> + / / * Redistributions of source code must retain the above copyright <nl> + / / notice , this list of conditions and the following disclaimer . <nl> + / / * Redistributions in binary form must reproduce the above <nl> + / / copyright notice , this list of conditions and the following <nl> + / / disclaimer in the documentation and / or other materials provided <nl> + / / with the distribution . <nl> + / / * Neither the name of Google Inc . nor the names of its <nl> + / / contributors may be used to endorse or promote products derived <nl> + / / from this software without specific prior written permission . <nl> + / / <nl> + / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + / / limitations under the License . <nl> + <nl> + <nl> + / * * <nl> + * List of available services . <nl> + * / <nl> + var AVAILABLE_SERVICES = [ ' collator ' , <nl> + ' numberformat ' , <nl> + ' dateformat ' , <nl> + ' breakiterator ' ] ; <nl> + <nl> + / * * <nl> + * Caches available locales for each service . <nl> + * / <nl> + var AVAILABLE_LOCALES = { <nl> + ' collator ' : undefined , <nl> + ' numberformat ' : undefined , <nl> + ' dateformat ' : undefined , <nl> + ' breakiterator ' : undefined <nl> + } ; <nl> + <nl> + / * * <nl> + * Caches default ICU locale . <nl> + * / <nl> + var DEFAULT_ICU_LOCALE = undefined ; <nl> + <nl> + / * * <nl> + * Unicode extension regular expression . <nl> + * / <nl> + var UNICODE_EXTENSION_RE = new RegExp ( ' - u ( - [ a - z0 - 9 ] { 2 , 8 } ) + ' , ' g ' ) ; <nl> + <nl> + / * * <nl> + * Matches any Unicode extension . <nl> + * / <nl> + var ANY_EXTENSION_RE = new RegExp ( ' - [ a - z0 - 9 ] { 1 } - . * ' , ' g ' ) ; <nl> + <nl> + / * * <nl> + * Replace quoted text ( single quote , anything but the quote and quote again ) . <nl> + * / <nl> + var QUOTED_STRING_RE = new RegExp ( " ' [ ^ ' ] + ' " , ' g ' ) ; <nl> + <nl> + / * * <nl> + * Matches valid service name . <nl> + * / <nl> + var SERVICE_RE = <nl> + new RegExp ( ' ^ ( collator | numberformat | dateformat | breakiterator ) $ ' ) ; <nl> + <nl> + / * * <nl> + * Validates a language tag against bcp47 spec . <nl> + * Actual value is assigned on first run . <nl> + * / <nl> + var LANGUAGE_TAG_RE = undefined ; <nl> + <nl> + / * * <nl> + * Helps find duplicate variants in the language tag . <nl> + * / <nl> + var LANGUAGE_VARIANT_RE = undefined ; <nl> + <nl> + / * * <nl> + * Helps find duplicate singletons in the language tag . <nl> + * / <nl> + var LANGUAGE_SINGLETON_RE = undefined ; <nl> + <nl> + / * * <nl> + * Matches valid IANA time zone names . <nl> + * / <nl> + var TIMEZONE_NAME_CHECK_RE = <nl> + new RegExp ( ' ^ ( [ A - Za - z ] + ) / ( [ A - Za - z ] + ) ( ? : _ ( [ A - Za - z ] + ) ) * $ ' ) ; <nl> + <nl> + / * * <nl> + * Maps ICU calendar names into LDML type . <nl> + * / <nl> + var ICU_CALENDAR_MAP = { <nl> + ' gregorian ' : ' gregory ' , <nl> + ' japanese ' : ' japanese ' , <nl> + ' buddhist ' : ' buddhist ' , <nl> + ' roc ' : ' roc ' , <nl> + ' persian ' : ' persian ' , <nl> + ' islamic - civil ' : ' islamicc ' , <nl> + ' islamic ' : ' islamic ' , <nl> + ' hebrew ' : ' hebrew ' , <nl> + ' chinese ' : ' chinese ' , <nl> + ' indian ' : ' indian ' , <nl> + ' coptic ' : ' coptic ' , <nl> + ' ethiopic ' : ' ethiopic ' , <nl> + ' ethiopic - amete - alem ' : ' ethioaa ' <nl> + } ; <nl> + <nl> + / * * <nl> + * Map of Unicode extensions to option properties , and their values and types , <nl> + * for a collator . <nl> + * / <nl> + var COLLATOR_KEY_MAP = { <nl> + ' kn ' : { ' property ' : ' numeric ' , ' type ' : ' boolean ' } , <nl> + ' kf ' : { ' property ' : ' caseFirst ' , ' type ' : ' string ' , <nl> + ' values ' : [ ' false ' , ' lower ' , ' upper ' ] } <nl> + } ; <nl> + <nl> + / * * <nl> + * Map of Unicode extensions to option properties , and their values and types , <nl> + * for a number format . <nl> + * / <nl> + var NUMBER_FORMAT_KEY_MAP = { <nl> + ' nu ' : { ' property ' : undefined , ' type ' : ' string ' } <nl> + } ; <nl> + <nl> + / * * <nl> + * Map of Unicode extensions to option properties , and their values and types , <nl> + * for a date / time format . <nl> + * / <nl> + var DATETIME_FORMAT_KEY_MAP = { <nl> + ' ca ' : { ' property ' : undefined , ' type ' : ' string ' } , <nl> + ' nu ' : { ' property ' : undefined , ' type ' : ' string ' } <nl> + } ; <nl> + <nl> + / * * <nl> + * Allowed - u - co - values . List taken from : <nl> + * http : / / unicode . org / repos / cldr / trunk / common / bcp47 / collation . xml <nl> + * / <nl> + var ALLOWED_CO_VALUES = [ <nl> + ' big5han ' , ' dict ' , ' direct ' , ' ducet ' , ' gb2312 ' , ' phonebk ' , ' phonetic ' , <nl> + ' pinyin ' , ' reformed ' , ' searchjl ' , ' stroke ' , ' trad ' , ' unihan ' , ' zhuyin ' <nl> + ] ; <nl> + <nl> + / * * <nl> + * Object attributes ( configurable , writable , enumerable ) . <nl> + * To combine attributes , OR them . <nl> + * Values / names are copied from v8 / include / v8 . h : PropertyAttribute <nl> + * / <nl> + var ATTRIBUTES = { <nl> + ' NONE ' : 0 , <nl> + ' READ_ONLY ' : 1 , <nl> + ' DONT_ENUM ' : 2 , <nl> + ' DONT_DELETE ' : 4 <nl> + } ; <nl> + <nl> + / * * <nl> + * Error message for when function object is created with new and it ' s not <nl> + * a constructor . <nl> + * / <nl> + var ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR = <nl> + ' Function object that \ ' s not a constructor was created with new ' ; <nl> new file mode 100644 <nl> index 00000000000 . . 1c0a2d8874b <nl> mmm / dev / null <nl> ppp b / src / extensions / i18n / header . js <nl> <nl> + / / Copyright 2013 the V8 project authors . All rights reserved . <nl> + / / Redistribution and use in source and binary forms , with or without <nl> + / / modification , are permitted provided that the following conditions are <nl> + / / met : <nl> + / / <nl> + / / * Redistributions of source code must retain the above copyright <nl> + / / notice , this list of conditions and the following disclaimer . <nl> + / / * Redistributions in binary form must reproduce the above <nl> + / / copyright notice , this list of conditions and the following <nl> + / / disclaimer in the documentation and / or other materials provided <nl> + / / with the distribution . <nl> + / / * Neither the name of Google Inc . nor the names of its <nl> + / / contributors may be used to endorse or promote products derived <nl> + / / from this software without specific prior written permission . <nl> + / / <nl> + / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + / / limitations under the License . <nl> + <nl> + / / ECMAScript 402 API implementation is broken into separate files for <nl> + / / each service . The build system combines them together into one <nl> + / / Intl namespace . <nl> + <nl> + / * * <nl> + * Intl object is a single object that has some named properties , <nl> + * all of which are constructors . <nl> + * / <nl> + var Intl = ( function ( ) { <nl> + <nl> + ' use strict ' ; <nl> + <nl> + var Intl = { } ; <nl> new file mode 100644 <nl> index 00000000000 . . b5f28631e1f <nl> mmm / dev / null <nl> ppp b / src / extensions / i18n / i18n - extension . cc <nl> <nl> + / / Copyright 2013 the V8 project authors . All rights reserved . <nl> + / / Redistribution and use in source and binary forms , with or without <nl> + / / modification , are permitted provided that the following conditions are <nl> + / / met : <nl> + / / <nl> + / / * Redistributions of source code must retain the above copyright <nl> + / / notice , this list of conditions and the following disclaimer . <nl> + / / * Redistributions in binary form must reproduce the above <nl> + / / copyright notice , this list of conditions and the following <nl> + / / disclaimer in the documentation and / or other materials provided <nl> + / / with the distribution . <nl> + / / * Neither the name of Google Inc . nor the names of its <nl> + / / contributors may be used to endorse or promote products derived <nl> + / / from this software without specific prior written permission . <nl> + / / <nl> + / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + / / limitations under the License . <nl> + <nl> + # include " i18n - extension . h " <nl> + <nl> + # include " natives . h " <nl> + <nl> + using v8 : : internal : : I18NNatives ; <nl> + <nl> + namespace v8_i18n { <nl> + <nl> + Extension : : Extension ( ) <nl> + : v8 : : Extension ( " v8 / i18n " , <nl> + reinterpret_cast < const char * > ( <nl> + I18NNatives : : GetScriptsSource ( ) . start ( ) ) , <nl> + 0 , <nl> + 0 , <nl> + I18NNatives : : GetScriptsSource ( ) . length ( ) ) { } <nl> + <nl> + <nl> + void Extension : : Register ( ) { <nl> + static Extension i18n_extension ; <nl> + static v8 : : DeclareExtension extension_declaration ( & i18n_extension ) ; <nl> + } <nl> + <nl> + } / / namespace v8_i18n <nl> new file mode 100644 <nl> index 00000000000 . . 9e538cb2ddc <nl> mmm / dev / null <nl> ppp b / src / extensions / i18n / i18n - extension . h <nl> <nl> + / / Copyright 2013 the V8 project authors . All rights reserved . <nl> + / / Redistribution and use in source and binary forms , with or without <nl> + / / modification , are permitted provided that the following conditions are <nl> + / / met : <nl> + / / <nl> + / / * Redistributions of source code must retain the above copyright <nl> + / / notice , this list of conditions and the following disclaimer . <nl> + / / * Redistributions in binary form must reproduce the above <nl> + / / copyright notice , this list of conditions and the following <nl> + / / disclaimer in the documentation and / or other materials provided <nl> + / / with the distribution . <nl> + / / * Neither the name of Google Inc . nor the names of its <nl> + / / contributors may be used to endorse or promote products derived <nl> + / / from this software without specific prior written permission . <nl> + / / <nl> + / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + / / limitations under the License . <nl> + <nl> + # ifndef V8_EXTENSIONS_I18N_I18N_EXTENSION_H_ <nl> + # define V8_EXTENSIONS_I18N_I18N_EXTENSION_H_ <nl> + <nl> + # include " v8 . h " <nl> + <nl> + namespace v8_i18n { <nl> + <nl> + class Extension : public v8 : : Extension { <nl> + public : <nl> + Extension ( ) ; <nl> + <nl> + static void Register ( ) ; <nl> + <nl> + private : <nl> + static Extension * extension_ ; <nl> + } ; <nl> + <nl> + } / / namespace v8_i18n <nl> + <nl> + # endif / / V8_EXTENSIONS_I18N_I18N_EXTENSION_H_ <nl> new file mode 100644 <nl> index 00000000000 . . 545082ecbba <nl> mmm / dev / null <nl> ppp b / src / extensions / i18n / i18n - utils . js <nl> <nl> + / / Copyright 2013 the V8 project authors . All rights reserved . <nl> + / / Redistribution and use in source and binary forms , with or without <nl> + / / modification , are permitted provided that the following conditions are <nl> + / / met : <nl> + / / <nl> + / / * Redistributions of source code must retain the above copyright <nl> + / / notice , this list of conditions and the following disclaimer . <nl> + / / * Redistributions in binary form must reproduce the above <nl> + / / copyright notice , this list of conditions and the following <nl> + / / disclaimer in the documentation and / or other materials provided <nl> + / / with the distribution . <nl> + / / * Neither the name of Google Inc . nor the names of its <nl> + / / contributors may be used to endorse or promote products derived <nl> + / / from this software without specific prior written permission . <nl> + / / <nl> + / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + / / limitations under the License . <nl> + <nl> + / / ECMAScript 402 API implementation is broken into separate files for <nl> + / / each service . The build system combines them together into one <nl> + / / Intl namespace . <nl> + <nl> + / * * <nl> + * Adds bound method to the prototype of the given object . <nl> + * / <nl> + function addBoundMethod ( obj , methodName , implementation , length ) { <nl> + function getter ( ) { <nl> + if ( ! this | | typeof this ! = = ' object ' | | <nl> + this . __initializedIntlObject = = = undefined ) { <nl> + throw new TypeError ( ' Method ' + methodName + ' called on a ' + <nl> + ' non - object or on a wrong type of object . ' ) ; <nl> + } <nl> + var internalName = ' __bound ' + methodName + ' __ ' ; <nl> + if ( this [ internalName ] = = = undefined ) { <nl> + var that = this ; <nl> + var boundMethod ; <nl> + if ( length = = = undefined | | length = = = 2 ) { <nl> + boundMethod = function ( x , y ) { <nl> + if ( % _IsConstructCall ( ) ) { <nl> + throw new TypeError ( ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR ) ; <nl> + } <nl> + return implementation ( that , x , y ) ; <nl> + } <nl> + } else if ( length = = = 1 ) { <nl> + boundMethod = function ( x ) { <nl> + if ( % _IsConstructCall ( ) ) { <nl> + throw new TypeError ( ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR ) ; <nl> + } <nl> + return implementation ( that , x ) ; <nl> + } <nl> + } else { <nl> + boundMethod = function ( ) { <nl> + if ( % _IsConstructCall ( ) ) { <nl> + throw new TypeError ( ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR ) ; <nl> + } <nl> + / / DateTimeFormat . format needs to be 0 arg method , but can stil <nl> + / / receive optional dateValue param . If one was provided , pass it <nl> + / / along . <nl> + if ( arguments . length > 0 ) { <nl> + return implementation ( that , arguments [ 0 ] ) ; <nl> + } else { <nl> + return implementation ( that ) ; <nl> + } <nl> + } <nl> + } <nl> + % FunctionSetName ( boundMethod , internalName ) ; <nl> + % FunctionRemovePrototype ( boundMethod ) ; <nl> + % SetNativeFlag ( boundMethod ) ; <nl> + this [ internalName ] = boundMethod ; <nl> + } <nl> + return this [ internalName ] ; <nl> + } <nl> + <nl> + % FunctionSetName ( getter , methodName ) ; <nl> + % FunctionRemovePrototype ( getter ) ; <nl> + % SetNativeFlag ( getter ) ; <nl> + <nl> + Object . defineProperty ( obj . prototype , methodName , { <nl> + get : getter , <nl> + enumerable : false , <nl> + configurable : true <nl> + } ) ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Returns an intersection of locales and service supported locales . <nl> + * Parameter locales is treated as a priority list . <nl> + * / <nl> + function supportedLocalesOf ( service , locales , options ) { <nl> + if ( service . match ( SERVICE_RE ) = = = null ) { <nl> + throw new Error ( ' Internal error , wrong service type : ' + service ) ; <nl> + } <nl> + <nl> + / / Provide defaults if matcher was not specified . <nl> + if ( options = = = undefined ) { <nl> + options = { } ; <nl> + } else { <nl> + options = toObject ( options ) ; <nl> + } <nl> + <nl> + var matcher = options . localeMatcher ; <nl> + if ( matcher ! = = undefined ) { <nl> + matcher = String ( matcher ) ; <nl> + if ( matcher ! = = ' lookup ' & & matcher ! = = ' best fit ' ) { <nl> + throw new RangeError ( ' Illegal value for localeMatcher : ' + matcher ) ; <nl> + } <nl> + } else { <nl> + matcher = ' best fit ' ; <nl> + } <nl> + <nl> + var requestedLocales = initializeLocaleList ( locales ) ; <nl> + <nl> + / / Cache these , they don ' t ever change per service . <nl> + if ( AVAILABLE_LOCALES [ service ] = = = undefined ) { <nl> + AVAILABLE_LOCALES [ service ] = getAvailableLocalesOf ( service ) ; <nl> + } <nl> + <nl> + / / Use either best fit or lookup algorithm to match locales . <nl> + if ( matcher = = = ' best fit ' ) { <nl> + return initializeLocaleList ( bestFitSupportedLocalesOf ( <nl> + requestedLocales , AVAILABLE_LOCALES [ service ] ) ) ; <nl> + } <nl> + <nl> + return initializeLocaleList ( lookupSupportedLocalesOf ( <nl> + requestedLocales , AVAILABLE_LOCALES [ service ] ) ) ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Returns the subset of the provided BCP 47 language priority list for which <nl> + * this service has a matching locale when using the BCP 47 Lookup algorithm . <nl> + * Locales appear in the same order in the returned list as in the input list . <nl> + * / <nl> + function lookupSupportedLocalesOf ( requestedLocales , availableLocales ) { <nl> + var matchedLocales = [ ] ; <nl> + for ( var i = 0 ; i < requestedLocales . length ; + + i ) { <nl> + / / Remove - u - extension . <nl> + var locale = requestedLocales [ i ] . replace ( UNICODE_EXTENSION_RE , ' ' ) ; <nl> + do { <nl> + if ( availableLocales [ locale ] ! = = undefined ) { <nl> + / / Push requested locale not the resolved one . <nl> + matchedLocales . push ( requestedLocales [ i ] ) ; <nl> + break ; <nl> + } <nl> + / / Truncate locale if possible , if not break . <nl> + var pos = locale . lastIndexOf ( ' - ' ) ; <nl> + if ( pos = = = - 1 ) { <nl> + break ; <nl> + } <nl> + locale = locale . substring ( 0 , pos ) ; <nl> + } while ( true ) ; <nl> + } <nl> + <nl> + return matchedLocales ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Returns the subset of the provided BCP 47 language priority list for which <nl> + * this service has a matching locale when using the implementation <nl> + * dependent algorithm . <nl> + * Locales appear in the same order in the returned list as in the input list . <nl> + * / <nl> + function bestFitSupportedLocalesOf ( requestedLocales , availableLocales ) { <nl> + / / TODO ( cira ) : implement better best fit algorithm . <nl> + return lookupSupportedLocalesOf ( requestedLocales , availableLocales ) ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Returns a getOption function that extracts property value for given <nl> + * options object . If property is missing it returns defaultValue . If value <nl> + * is out of range for that property it throws RangeError . <nl> + * / <nl> + function getGetOption ( options , caller ) { <nl> + if ( options = = = undefined ) { <nl> + throw new Error ( ' Internal ' + caller + ' error . ' + <nl> + ' Default options are missing . ' ) ; <nl> + } <nl> + <nl> + var getOption = function getOption ( property , type , values , defaultValue ) { <nl> + if ( options [ property ] ! = = undefined ) { <nl> + var value = options [ property ] ; <nl> + switch ( type ) { <nl> + case ' boolean ' : <nl> + value = Boolean ( value ) ; <nl> + break ; <nl> + case ' string ' : <nl> + value = String ( value ) ; <nl> + break ; <nl> + case ' number ' : <nl> + value = Number ( value ) ; <nl> + break ; <nl> + default : <nl> + throw new Error ( ' Internal error . Wrong value type . ' ) ; <nl> + } <nl> + if ( values ! = = undefined & & values . indexOf ( value ) = = = - 1 ) { <nl> + throw new RangeError ( ' Value ' + value + ' out of range for ' + caller + <nl> + ' options property ' + property ) ; <nl> + } <nl> + <nl> + return value ; <nl> + } <nl> + <nl> + return defaultValue ; <nl> + } <nl> + <nl> + return getOption ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Compares a BCP 47 language priority list requestedLocales against the locales <nl> + * in availableLocales and determines the best available language to meet the <nl> + * request . Two algorithms are available to match the locales : the Lookup <nl> + * algorithm described in RFC 4647 section 3 . 4 , and an implementation dependent <nl> + * best - fit algorithm . Independent of the locale matching algorithm , options <nl> + * specified through Unicode locale extension sequences are negotiated <nl> + * separately , taking the caller ' s relevant extension keys and locale data as <nl> + * well as client - provided options into consideration . Returns an object with <nl> + * a locale property whose value is the language tag of the selected locale , <nl> + * and properties for each key in relevantExtensionKeys providing the selected <nl> + * value for that key . <nl> + * / <nl> + function resolveLocale ( service , requestedLocales , options ) { <nl> + requestedLocales = initializeLocaleList ( requestedLocales ) ; <nl> + <nl> + var getOption = getGetOption ( options , service ) ; <nl> + var matcher = getOption ( ' localeMatcher ' , ' string ' , <nl> + [ ' lookup ' , ' best fit ' ] , ' best fit ' ) ; <nl> + var resolved ; <nl> + if ( matcher = = = ' lookup ' ) { <nl> + resolved = lookupMatcher ( service , requestedLocales ) ; <nl> + } else { <nl> + resolved = bestFitMatcher ( service , requestedLocales ) ; <nl> + } <nl> + <nl> + return resolved ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Returns best matched supported locale and extension info using basic <nl> + * lookup algorithm . <nl> + * / <nl> + function lookupMatcher ( service , requestedLocales ) { <nl> + if ( service . match ( SERVICE_RE ) = = = null ) { <nl> + throw new Error ( ' Internal error , wrong service type : ' + service ) ; <nl> + } <nl> + <nl> + / / Cache these , they don ' t ever change per service . <nl> + if ( AVAILABLE_LOCALES [ service ] = = = undefined ) { <nl> + AVAILABLE_LOCALES [ service ] = getAvailableLocalesOf ( service ) ; <nl> + } <nl> + <nl> + for ( var i = 0 ; i < requestedLocales . length ; + + i ) { <nl> + / / Remove all extensions . <nl> + var locale = requestedLocales [ i ] . replace ( ANY_EXTENSION_RE , ' ' ) ; <nl> + do { <nl> + if ( AVAILABLE_LOCALES [ service ] [ locale ] ! = = undefined ) { <nl> + / / Return the resolved locale and extension . <nl> + var extensionMatch = requestedLocales [ i ] . match ( UNICODE_EXTENSION_RE ) ; <nl> + var extension = ( extensionMatch = = = null ) ? ' ' : extensionMatch [ 0 ] ; <nl> + return { ' locale ' : locale , ' extension ' : extension , ' position ' : i } ; <nl> + } <nl> + / / Truncate locale if possible . <nl> + var pos = locale . lastIndexOf ( ' - ' ) ; <nl> + if ( pos = = = - 1 ) { <nl> + break ; <nl> + } <nl> + locale = locale . substring ( 0 , pos ) ; <nl> + } while ( true ) ; <nl> + } <nl> + <nl> + / / Didn ' t find a match , return default . <nl> + if ( DEFAULT_ICU_LOCALE = = = undefined ) { <nl> + DEFAULT_ICU_LOCALE = % GetDefaultICULocale ( ) ; <nl> + } <nl> + <nl> + return { ' locale ' : DEFAULT_ICU_LOCALE , ' extension ' : ' ' , ' position ' : - 1 } ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Returns best matched supported locale and extension info using <nl> + * implementation dependend algorithm . <nl> + * / <nl> + function bestFitMatcher ( service , requestedLocales ) { <nl> + / / TODO ( cira ) : implement better best fit algorithm . <nl> + return lookupMatcher ( service , requestedLocales ) ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Parses Unicode extension into key - value map . <nl> + * Returns empty object if the extension string is invalid . <nl> + * We are not concerned with the validity of the values at this point . <nl> + * / <nl> + function parseExtension ( extension ) { <nl> + var extensionSplit = extension . split ( ' - ' ) ; <nl> + <nl> + / / Assume [ ' ' , ' u ' , . . . ] input , but don ' t throw . <nl> + if ( extensionSplit . length < = 2 | | <nl> + ( extensionSplit [ 0 ] ! = = ' ' & & extensionSplit [ 1 ] ! = = ' u ' ) ) { <nl> + return { } ; <nl> + } <nl> + <nl> + / / Key is { 2 } alphanum , value is { 3 , 8 } alphanum . <nl> + / / Some keys may not have explicit values ( booleans ) . <nl> + var extensionMap = { } ; <nl> + var previousKey = undefined ; <nl> + for ( var i = 2 ; i < extensionSplit . length ; + + i ) { <nl> + var length = extensionSplit [ i ] . length ; <nl> + var element = extensionSplit [ i ] ; <nl> + if ( length = = = 2 ) { <nl> + extensionMap [ element ] = undefined ; <nl> + previousKey = element ; <nl> + } else if ( length > = 3 & & length < = 8 & & previousKey ! = = undefined ) { <nl> + extensionMap [ previousKey ] = element ; <nl> + previousKey = undefined ; <nl> + } else { <nl> + / / There is a value that ' s too long , or that doesn ' t have a key . <nl> + return { } ; <nl> + } <nl> + } <nl> + <nl> + return extensionMap ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Converts parameter to an Object if possible . <nl> + * / <nl> + function toObject ( value ) { <nl> + if ( value = = = undefined | | value = = = null ) { <nl> + throw new TypeError ( ' Value cannot be converted to an Object . ' ) ; <nl> + } <nl> + <nl> + return Object ( value ) ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Populates internalOptions object with boolean key - value pairs <nl> + * from extensionMap and options . <nl> + * Returns filtered extension ( number and date format constructors use <nl> + * Unicode extensions for passing parameters to ICU ) . <nl> + * It ' s used for extension - option pairs only , e . g . kn - normalization , but not <nl> + * for ' sensitivity ' since it doesn ' t have extension equivalent . <nl> + * Extensions like nu and ca don ' t have options equivalent , so we place <nl> + * undefined in the map . property to denote that . <nl> + * / <nl> + function setOptions ( inOptions , extensionMap , keyValues , getOption , outOptions ) { <nl> + var extension = ' ' ; <nl> + <nl> + var updateExtension = function updateExtension ( key , value ) { <nl> + return ' - ' + key + ' - ' + String ( value ) ; <nl> + } <nl> + <nl> + var updateProperty = function updateProperty ( property , type , value ) { <nl> + if ( type = = = ' boolean ' & & ( typeof value = = = ' string ' ) ) { <nl> + value = ( value = = = ' true ' ) ? true : false ; <nl> + } <nl> + <nl> + if ( property ! = = undefined ) { <nl> + defineWEProperty ( outOptions , property , value ) ; <nl> + } <nl> + } <nl> + <nl> + for ( var key in keyValues ) { <nl> + if ( keyValues . hasOwnProperty ( key ) ) { <nl> + var value = undefined ; <nl> + var map = keyValues [ key ] ; <nl> + if ( map . property ! = = undefined ) { <nl> + / / This may return true if user specifies numeric : ' false ' , since <nl> + / / Boolean ( ' nonempty ' ) = = = true . <nl> + value = getOption ( map . property , map . type , map . values ) ; <nl> + } <nl> + if ( value ! = = undefined ) { <nl> + updateProperty ( map . property , map . type , value ) ; <nl> + extension + = updateExtension ( key , value ) ; <nl> + continue ; <nl> + } <nl> + / / User options didn ' t have it , check Unicode extension . <nl> + / / Here we want to convert strings ' true ' , ' false ' into proper Boolean <nl> + / / values ( not a user error ) . <nl> + if ( extensionMap . hasOwnProperty ( key ) ) { <nl> + value = extensionMap [ key ] ; <nl> + if ( value ! = = undefined ) { <nl> + updateProperty ( map . property , map . type , value ) ; <nl> + extension + = updateExtension ( key , value ) ; <nl> + } else if ( map . type = = = ' boolean ' ) { <nl> + / / Boolean keys are allowed not to have values in Unicode extension . <nl> + / / Those default to true . <nl> + updateProperty ( map . property , map . type , true ) ; <nl> + extension + = updateExtension ( key , true ) ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + <nl> + return extension = = = ' ' ? ' ' : ' - u ' + extension ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Converts all OwnProperties into <nl> + * configurable : false , writable : false , enumerable : true . <nl> + * / <nl> + function freezeArray ( array ) { <nl> + array . forEach ( function ( element , index ) { <nl> + Object . defineProperty ( array , index , { value : element , <nl> + configurable : false , <nl> + writable : false , <nl> + enumerable : true } ) ; <nl> + } ) ; <nl> + <nl> + Object . defineProperty ( array , ' length ' , { value : array . length , <nl> + writable : false } ) ; <nl> + <nl> + return array ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * It ' s sometimes desireable to leave user requested locale instead of ICU <nl> + * supported one ( zh - TW is equivalent to zh - Hant - TW , so we should keep shorter <nl> + * one , if that was what user requested ) . <nl> + * This function returns user specified tag if its maximized form matches ICU <nl> + * resolved locale . If not we return ICU result . <nl> + * / <nl> + function getOptimalLanguageTag ( original , resolved ) { <nl> + / / Returns Array < Object > , where each object has maximized and base properties . <nl> + / / Maximized : zh - > zh - Hans - CN <nl> + / / Base : zh - CN - u - ca - gregory - > zh - CN <nl> + / / Take care of grandfathered or simple cases . <nl> + if ( original = = = resolved ) { <nl> + return original ; <nl> + } <nl> + <nl> + var locales = % GetLanguageTagVariants ( [ original , resolved ] ) ; <nl> + if ( locales [ 0 ] . maximized ! = = locales [ 1 ] . maximized ) { <nl> + return resolved ; <nl> + } <nl> + <nl> + / / Preserve extensions of resolved locale , but swap base tags with original . <nl> + var resolvedBase = new RegExp ( ' ^ ' + locales [ 1 ] . base ) ; <nl> + return resolved . replace ( resolvedBase , locales [ 0 ] . base ) ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Returns an Object that contains all of supported locales for a given <nl> + * service . <nl> + * In addition to the supported locales we add xx - ZZ locale for each xx - Yyyy - ZZ <nl> + * that is supported . This is required by the spec . <nl> + * / <nl> + function getAvailableLocalesOf ( service ) { <nl> + var available = % AvailableLocalesOf ( service ) ; <nl> + <nl> + for ( var i in available ) { <nl> + if ( available . hasOwnProperty ( i ) ) { <nl> + var parts = i . match ( / ^ ( [ a - z ] { 2 , 3 } ) - ( [ A - Z ] [ a - z ] { 3 } ) - ( [ A - Z ] { 2 } ) $ / ) ; <nl> + if ( parts ! = = null ) { <nl> + / / Build xx - ZZ . We don ' t care about the actual value , <nl> + / / as long it ' s not undefined . <nl> + available [ parts [ 1 ] + ' - ' + parts [ 3 ] ] = null ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + return available ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Defines a property and sets writable and enumerable to true . <nl> + * Configurable is false by default . <nl> + * / <nl> + function defineWEProperty ( object , property , value ) { <nl> + Object . defineProperty ( object , property , <nl> + { value : value , writable : true , enumerable : true } ) ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Adds property to an object if the value is not undefined . <nl> + * Sets configurable descriptor to false . <nl> + * / <nl> + function addWEPropertyIfDefined ( object , property , value ) { <nl> + if ( value ! = = undefined ) { <nl> + defineWEProperty ( object , property , value ) ; <nl> + } <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Defines a property and sets writable , enumerable and configurable to true . <nl> + * / <nl> + function defineWECProperty ( object , property , value ) { <nl> + Object . defineProperty ( object , property , <nl> + { value : value , <nl> + writable : true , <nl> + enumerable : true , <nl> + configurable : true } ) ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Adds property to an object if the value is not undefined . <nl> + * Sets all descriptors to true . <nl> + * / <nl> + function addWECPropertyIfDefined ( object , property , value ) { <nl> + if ( value ! = = undefined ) { <nl> + defineWECProperty ( object , property , value ) ; <nl> + } <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Returns titlecased word , aMeRricA - > America . <nl> + * / <nl> + function toTitleCaseWord ( word ) { <nl> + return word . substr ( 0 , 1 ) . toUpperCase ( ) + word . substr ( 1 ) . toLowerCase ( ) ; <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . e4783277e64 <nl> mmm / dev / null <nl> ppp b / src / extensions / i18n / locale . js <nl> <nl> + / / Copyright 2013 the V8 project authors . All rights reserved . <nl> + / / Redistribution and use in source and binary forms , with or without <nl> + / / modification , are permitted provided that the following conditions are <nl> + / / met : <nl> + / / <nl> + / / * Redistributions of source code must retain the above copyright <nl> + / / notice , this list of conditions and the following disclaimer . <nl> + / / * Redistributions in binary form must reproduce the above <nl> + / / copyright notice , this list of conditions and the following <nl> + / / disclaimer in the documentation and / or other materials provided <nl> + / / with the distribution . <nl> + / / * Neither the name of Google Inc . nor the names of its <nl> + / / contributors may be used to endorse or promote products derived <nl> + / / from this software without specific prior written permission . <nl> + / / <nl> + / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + / / limitations under the License . <nl> + <nl> + / / ECMAScript 402 API implementation is broken into separate files for <nl> + / / each service . The build system combines them together into one <nl> + / / Intl namespace . <nl> + <nl> + / * * <nl> + * Canonicalizes the language tag , or throws in case the tag is invalid . <nl> + * / <nl> + function canonicalizeLanguageTag ( localeID ) { <nl> + / / null is typeof ' object ' so we have to do extra check . <nl> + if ( typeof localeID ! = = ' string ' & & typeof localeID ! = = ' object ' | | <nl> + localeID = = = null ) { <nl> + throw new TypeError ( ' Language ID should be string or object . ' ) ; <nl> + } <nl> + <nl> + var localeString = String ( localeID ) ; <nl> + <nl> + if ( isValidLanguageTag ( localeString ) = = = false ) { <nl> + throw new RangeError ( ' Invalid language tag : ' + localeString ) ; <nl> + } <nl> + <nl> + / / This call will strip - kn but not - kn - true extensions . <nl> + / / ICU bug filled - http : / / bugs . icu - project . org / trac / ticket / 9265 . <nl> + / / TODO ( cira ) : check if - u - kn - true - kc - true - kh - true still throws after <nl> + / / upgrade to ICU 4 . 9 . <nl> + var tag = % CanonicalizeLanguageTag ( localeString ) ; <nl> + if ( tag = = = ' invalid - tag ' ) { <nl> + throw new RangeError ( ' Invalid language tag : ' + localeString ) ; <nl> + } <nl> + <nl> + return tag ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Returns an array where all locales are canonicalized and duplicates removed . <nl> + * Throws on locales that are not well formed BCP47 tags . <nl> + * / <nl> + function initializeLocaleList ( locales ) { <nl> + var seen = [ ] ; <nl> + if ( locales = = = undefined ) { <nl> + / / Constructor is called without arguments . <nl> + seen = [ ] ; <nl> + } else { <nl> + / / We allow single string localeID . <nl> + if ( typeof locales = = = ' string ' ) { <nl> + seen . push ( canonicalizeLanguageTag ( locales ) ) ; <nl> + return freezeArray ( seen ) ; <nl> + } <nl> + <nl> + var o = toObject ( locales ) ; <nl> + / / Converts it to UInt32 ( > > > is shr on 32bit integers ) . <nl> + var len = o . length > > > 0 ; <nl> + <nl> + for ( var k = 0 ; k < len ; k + + ) { <nl> + if ( k in o ) { <nl> + var value = o [ k ] ; <nl> + <nl> + var tag = canonicalizeLanguageTag ( value ) ; <nl> + <nl> + if ( seen . indexOf ( tag ) = = = - 1 ) { <nl> + seen . push ( tag ) ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + <nl> + return freezeArray ( seen ) ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Validates the language tag . Section 2 . 2 . 9 of the bcp47 spec <nl> + * defines a valid tag . <nl> + * <nl> + * ICU is too permissible and lets invalid tags , like <nl> + * hant - cmn - cn , through . <nl> + * <nl> + * Returns false if the language tag is invalid . <nl> + * / <nl> + function isValidLanguageTag ( locale ) { <nl> + / / Check if it ' s well - formed , including grandfadered tags . <nl> + if ( LANGUAGE_TAG_RE . test ( locale ) = = = false ) { <nl> + return false ; <nl> + } <nl> + <nl> + / / Just return if it ' s a x - form . It ' s all private . <nl> + if ( locale . indexOf ( ' x - ' ) = = = 0 ) { <nl> + return true ; <nl> + } <nl> + <nl> + / / Check if there are any duplicate variants or singletons ( extensions ) . <nl> + <nl> + / / Remove private use section . <nl> + locale = locale . split ( / - x - / ) [ 0 ] ; <nl> + <nl> + / / Skip language since it can match variant regex , so we start from 1 . <nl> + / / We are matching i - klingon here , but that ' s ok , since i - klingon - klingon <nl> + / / is not valid and would fail LANGUAGE_TAG_RE test . <nl> + var variants = [ ] ; <nl> + var extensions = [ ] ; <nl> + var parts = locale . split ( / - / ) ; <nl> + for ( var i = 1 ; i < parts . length ; i + + ) { <nl> + var value = parts [ i ] ; <nl> + if ( LANGUAGE_VARIANT_RE . test ( value ) = = = true & & extensions . length = = = 0 ) { <nl> + if ( variants . indexOf ( value ) = = = - 1 ) { <nl> + variants . push ( value ) ; <nl> + } else { <nl> + return false ; <nl> + } <nl> + } <nl> + <nl> + if ( LANGUAGE_SINGLETON_RE . test ( value ) = = = true ) { <nl> + if ( extensions . indexOf ( value ) = = = - 1 ) { <nl> + extensions . push ( value ) ; <nl> + } else { <nl> + return false ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Builds a regular expresion that validates the language tag <nl> + * against bcp47 spec . <nl> + * Uses http : / / tools . ietf . org / html / bcp47 , section 2 . 1 , ABNF . <nl> + * Runs on load and initializes the global REs . <nl> + * / <nl> + ( function ( ) { <nl> + var alpha = ' [ a - zA - Z ] ' ; <nl> + var digit = ' [ 0 - 9 ] ' ; <nl> + var alphanum = ' ( ' + alpha + ' | ' + digit + ' ) ' ; <nl> + var regular = ' ( art - lojban | cel - gaulish | no - bok | no - nyn | zh - guoyu | zh - hakka | ' + <nl> + ' zh - min | zh - min - nan | zh - xiang ) ' ; <nl> + var irregular = ' ( en - GB - oed | i - ami | i - bnn | i - default | i - enochian | i - hak | ' + <nl> + ' i - klingon | i - lux | i - mingo | i - navajo | i - pwn | i - tao | i - tay | ' + <nl> + ' i - tsu | sgn - BE - FR | sgn - BE - NL | sgn - CH - DE ) ' ; <nl> + var grandfathered = ' ( ' + irregular + ' | ' + regular + ' ) ' ; <nl> + var privateUse = ' ( x ( - ' + alphanum + ' { 1 , 8 } ) + ) ' ; <nl> + <nl> + var singleton = ' ( ' + digit + ' | [ A - WY - Za - wy - z ] ) ' ; <nl> + LANGUAGE_SINGLETON_RE = new RegExp ( ' ^ ' + singleton + ' $ ' , ' i ' ) ; <nl> + <nl> + var extension = ' ( ' + singleton + ' ( - ' + alphanum + ' { 2 , 8 } ) + ) ' ; <nl> + <nl> + var variant = ' ( ' + alphanum + ' { 5 , 8 } | ( ' + digit + alphanum + ' { 3 } ) ) ' ; <nl> + LANGUAGE_VARIANT_RE = new RegExp ( ' ^ ' + variant + ' $ ' , ' i ' ) ; <nl> + <nl> + var region = ' ( ' + alpha + ' { 2 } | ' + digit + ' { 3 } ) ' ; <nl> + var script = ' ( ' + alpha + ' { 4 } ) ' ; <nl> + var extLang = ' ( ' + alpha + ' { 3 } ( - ' + alpha + ' { 3 } ) { 0 , 2 } ) ' ; <nl> + var language = ' ( ' + alpha + ' { 2 , 3 } ( - ' + extLang + ' ) ? | ' + alpha + ' { 4 } | ' + <nl> + alpha + ' { 5 , 8 } ) ' ; <nl> + var langTag = language + ' ( - ' + script + ' ) ? ( - ' + region + ' ) ? ( - ' + <nl> + variant + ' ) * ( - ' + extension + ' ) * ( - ' + privateUse + ' ) ? ' ; <nl> + <nl> + var languageTag = <nl> + ' ^ ( ' + langTag + ' | ' + privateUse + ' | ' + grandfathered + ' ) $ ' ; <nl> + LANGUAGE_TAG_RE = new RegExp ( languageTag , ' i ' ) ; <nl> + } ) ( ) ; <nl> new file mode 100644 <nl> index 00000000000 . . 5722a5dc1f3 <nl> mmm / dev / null <nl> ppp b / src / extensions / i18n / number - format . js <nl> <nl> + / / Copyright 2013 the V8 project authors . All rights reserved . <nl> + / / Redistribution and use in source and binary forms , with or without <nl> + / / modification , are permitted provided that the following conditions are <nl> + / / met : <nl> + / / <nl> + / / * Redistributions of source code must retain the above copyright <nl> + / / notice , this list of conditions and the following disclaimer . <nl> + / / * Redistributions in binary form must reproduce the above <nl> + / / copyright notice , this list of conditions and the following <nl> + / / disclaimer in the documentation and / or other materials provided <nl> + / / with the distribution . <nl> + / / * Neither the name of Google Inc . nor the names of its <nl> + / / contributors may be used to endorse or promote products derived <nl> + / / from this software without specific prior written permission . <nl> + / / <nl> + / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + / / limitations under the License . <nl> + <nl> + / / ECMAScript 402 API implementation is broken into separate files for <nl> + / / each service . The build system combines them together into one <nl> + / / Intl namespace . <nl> + <nl> + / * * <nl> + * Verifies that the input is a well - formed ISO 4217 currency code . <nl> + * Don ' t uppercase to test . It could convert invalid code into a valid one . <nl> + * For example \ u00DFP ( Eszett + P ) becomes SSP . <nl> + * / <nl> + function isWellFormedCurrencyCode ( currency ) { <nl> + return typeof currency = = " string " & & <nl> + currency . length = = 3 & & <nl> + currency . match ( / [ ^ A - Za - z ] / ) = = null ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Returns the valid digit count for a property , or throws RangeError on <nl> + * a value out of the range . <nl> + * / <nl> + function getNumberOption ( options , property , min , max , fallback ) { <nl> + var value = options [ property ] ; <nl> + if ( value ! = = undefined ) { <nl> + value = Number ( value ) ; <nl> + if ( isNaN ( value ) | | value < min | | value > max ) { <nl> + throw new RangeError ( property + ' value is out of range . ' ) ; <nl> + } <nl> + return Math . floor ( value ) ; <nl> + } <nl> + <nl> + return fallback ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Initializes the given object so it ' s a valid NumberFormat instance . <nl> + * Useful for subclassing . <nl> + * / <nl> + function initializeNumberFormat ( numberFormat , locales , options ) { <nl> + if ( numberFormat . hasOwnProperty ( ' __initializedIntlObject ' ) ) { <nl> + throw new TypeError ( ' Trying to re - initialize NumberFormat object . ' ) ; <nl> + } <nl> + <nl> + if ( options = = = undefined ) { <nl> + options = { } ; <nl> + } <nl> + <nl> + var getOption = getGetOption ( options , ' numberformat ' ) ; <nl> + <nl> + var locale = resolveLocale ( ' numberformat ' , locales , options ) ; <nl> + <nl> + var internalOptions = { } ; <nl> + defineWEProperty ( internalOptions , ' style ' , getOption ( <nl> + ' style ' , ' string ' , [ ' decimal ' , ' percent ' , ' currency ' ] , ' decimal ' ) ) ; <nl> + <nl> + var currency = getOption ( ' currency ' , ' string ' ) ; <nl> + if ( currency ! = = undefined & & ! isWellFormedCurrencyCode ( currency ) ) { <nl> + throw new RangeError ( ' Invalid currency code : ' + currency ) ; <nl> + } <nl> + <nl> + if ( internalOptions . style = = = ' currency ' & & currency = = = undefined ) { <nl> + throw new TypeError ( ' Currency code is required with currency style . ' ) ; <nl> + } <nl> + <nl> + var currencyDisplay = getOption ( <nl> + ' currencyDisplay ' , ' string ' , [ ' code ' , ' symbol ' , ' name ' ] , ' symbol ' ) ; <nl> + if ( internalOptions . style = = = ' currency ' ) { <nl> + defineWEProperty ( internalOptions , ' currency ' , currency . toUpperCase ( ) ) ; <nl> + defineWEProperty ( internalOptions , ' currencyDisplay ' , currencyDisplay ) ; <nl> + } <nl> + <nl> + / / Digit ranges . <nl> + var mnid = getNumberOption ( options , ' minimumIntegerDigits ' , 1 , 21 , 1 ) ; <nl> + defineWEProperty ( internalOptions , ' minimumIntegerDigits ' , mnid ) ; <nl> + <nl> + var mnfd = getNumberOption ( options , ' minimumFractionDigits ' , 0 , 20 , 0 ) ; <nl> + defineWEProperty ( internalOptions , ' minimumFractionDigits ' , mnfd ) ; <nl> + <nl> + var mxfd = getNumberOption ( options , ' maximumFractionDigits ' , mnfd , 20 , 3 ) ; <nl> + defineWEProperty ( internalOptions , ' maximumFractionDigits ' , mxfd ) ; <nl> + <nl> + var mnsd = options [ ' minimumSignificantDigits ' ] ; <nl> + var mxsd = options [ ' maximumSignificantDigits ' ] ; <nl> + if ( mnsd ! = = undefined | | mxsd ! = = undefined ) { <nl> + mnsd = getNumberOption ( options , ' minimumSignificantDigits ' , 1 , 21 , 0 ) ; <nl> + defineWEProperty ( internalOptions , ' minimumSignificantDigits ' , mnsd ) ; <nl> + <nl> + mxsd = getNumberOption ( options , ' maximumSignificantDigits ' , mnsd , 21 , 21 ) ; <nl> + defineWEProperty ( internalOptions , ' maximumSignificantDigits ' , mxsd ) ; <nl> + } <nl> + <nl> + / / Grouping . <nl> + defineWEProperty ( internalOptions , ' useGrouping ' , getOption ( <nl> + ' useGrouping ' , ' boolean ' , undefined , true ) ) ; <nl> + <nl> + / / ICU prefers options to be passed using - u - extension key / values for <nl> + / / number format , so we need to build that . <nl> + var extensionMap = parseExtension ( locale . extension ) ; <nl> + var extension = setOptions ( options , extensionMap , NUMBER_FORMAT_KEY_MAP , <nl> + getOption , internalOptions ) ; <nl> + <nl> + var requestedLocale = locale . locale + extension ; <nl> + var resolved = Object . defineProperties ( { } , { <nl> + currency : { writable : true } , <nl> + currencyDisplay : { writable : true } , <nl> + locale : { writable : true } , <nl> + maximumFractionDigits : { writable : true } , <nl> + minimumFractionDigits : { writable : true } , <nl> + minimumIntegerDigits : { writable : true } , <nl> + numberingSystem : { writable : true } , <nl> + requestedLocale : { value : requestedLocale , writable : true } , <nl> + style : { value : internalOptions . style , writable : true } , <nl> + useGrouping : { writable : true } <nl> + } ) ; <nl> + if ( internalOptions . hasOwnProperty ( ' minimumSignificantDigits ' ) ) { <nl> + defineWEProperty ( resolved , ' minimumSignificantDigits ' , undefined ) ; <nl> + } <nl> + if ( internalOptions . hasOwnProperty ( ' maximumSignificantDigits ' ) ) { <nl> + defineWEProperty ( resolved , ' maximumSignificantDigits ' , undefined ) ; <nl> + } <nl> + var formatter = % CreateNumberFormat ( requestedLocale , <nl> + internalOptions , <nl> + resolved ) ; <nl> + <nl> + / / We can ' t get information about number or currency style from ICU , so we <nl> + / / assume user request was fulfilled . <nl> + if ( internalOptions . style = = = ' currency ' ) { <nl> + Object . defineProperty ( resolved , ' currencyDisplay ' , { value : currencyDisplay , <nl> + writable : true } ) ; <nl> + } <nl> + <nl> + Object . defineProperty ( numberFormat , ' formatter ' , { value : formatter } ) ; <nl> + Object . defineProperty ( numberFormat , ' resolved ' , { value : resolved } ) ; <nl> + Object . defineProperty ( numberFormat , ' __initializedIntlObject ' , <nl> + { value : ' numberformat ' } ) ; <nl> + <nl> + return numberFormat ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Constructs Intl . NumberFormat object given optional locales and options <nl> + * parameters . <nl> + * <nl> + * @ constructor <nl> + * / <nl> + % SetProperty ( Intl , ' NumberFormat ' , function ( ) { <nl> + var locales = arguments [ 0 ] ; <nl> + var options = arguments [ 1 ] ; <nl> + <nl> + if ( ! this | | this = = = Intl ) { <nl> + / / Constructor is called as a function . <nl> + return new Intl . NumberFormat ( locales , options ) ; <nl> + } <nl> + <nl> + return initializeNumberFormat ( toObject ( this ) , locales , options ) ; <nl> + } , <nl> + ATTRIBUTES . DONT_ENUM <nl> + ) ; <nl> + <nl> + <nl> + / * * <nl> + * NumberFormat resolvedOptions method . <nl> + * / <nl> + % SetProperty ( Intl . NumberFormat . prototype , ' resolvedOptions ' , function ( ) { <nl> + if ( % _IsConstructCall ( ) ) { <nl> + throw new TypeError ( ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR ) ; <nl> + } <nl> + <nl> + if ( ! this | | typeof this ! = = ' object ' | | <nl> + this . __initializedIntlObject ! = = ' numberformat ' ) { <nl> + throw new TypeError ( ' resolvedOptions method called on a non - object ' + <nl> + ' or on a object that is not Intl . NumberFormat . ' ) ; <nl> + } <nl> + <nl> + var format = this ; <nl> + var locale = getOptimalLanguageTag ( format . resolved . requestedLocale , <nl> + format . resolved . locale ) ; <nl> + <nl> + var result = { <nl> + locale : locale , <nl> + numberingSystem : format . resolved . numberingSystem , <nl> + style : format . resolved . style , <nl> + useGrouping : format . resolved . useGrouping , <nl> + minimumIntegerDigits : format . resolved . minimumIntegerDigits , <nl> + minimumFractionDigits : format . resolved . minimumFractionDigits , <nl> + maximumFractionDigits : format . resolved . maximumFractionDigits , <nl> + } ; <nl> + <nl> + if ( result . style = = = ' currency ' ) { <nl> + defineWECProperty ( result , ' currency ' , format . resolved . currency ) ; <nl> + defineWECProperty ( result , ' currencyDisplay ' , <nl> + format . resolved . currencyDisplay ) ; <nl> + } <nl> + <nl> + if ( format . resolved . hasOwnProperty ( ' minimumSignificantDigits ' ) ) { <nl> + defineWECProperty ( result , ' minimumSignificantDigits ' , <nl> + format . resolved . minimumSignificantDigits ) ; <nl> + } <nl> + <nl> + if ( format . resolved . hasOwnProperty ( ' maximumSignificantDigits ' ) ) { <nl> + defineWECProperty ( result , ' maximumSignificantDigits ' , <nl> + format . resolved . maximumSignificantDigits ) ; <nl> + } <nl> + <nl> + return result ; <nl> + } , <nl> + ATTRIBUTES . DONT_ENUM <nl> + ) ; <nl> + % FunctionSetName ( Intl . NumberFormat . prototype . resolvedOptions , <nl> + ' resolvedOptions ' ) ; <nl> + % FunctionRemovePrototype ( Intl . NumberFormat . prototype . resolvedOptions ) ; <nl> + % SetNativeFlag ( Intl . NumberFormat . prototype . resolvedOptions ) ; <nl> + <nl> + <nl> + / * * <nl> + * Returns the subset of the given locale list for which this locale list <nl> + * has a matching ( possibly fallback ) locale . Locales appear in the same <nl> + * order in the returned list as in the input list . <nl> + * Options are optional parameter . <nl> + * / <nl> + % SetProperty ( Intl . NumberFormat , ' supportedLocalesOf ' , function ( locales ) { <nl> + if ( % _IsConstructCall ( ) ) { <nl> + throw new TypeError ( ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR ) ; <nl> + } <nl> + <nl> + return supportedLocalesOf ( ' numberformat ' , locales , arguments [ 1 ] ) ; <nl> + } , <nl> + ATTRIBUTES . DONT_ENUM <nl> + ) ; <nl> + % FunctionSetName ( Intl . NumberFormat . supportedLocalesOf , ' supportedLocalesOf ' ) ; <nl> + % FunctionRemovePrototype ( Intl . NumberFormat . supportedLocalesOf ) ; <nl> + % SetNativeFlag ( Intl . NumberFormat . supportedLocalesOf ) ; <nl> + <nl> + <nl> + / * * <nl> + * Returns a String value representing the result of calling ToNumber ( value ) <nl> + * according to the effective locale and the formatting options of this <nl> + * NumberFormat . <nl> + * / <nl> + function formatNumber ( formatter , value ) { <nl> + / / Spec treats - 0 and + 0 as 0 . <nl> + var number = Number ( value ) ; <nl> + if ( number = = = - 0 ) { <nl> + number = 0 ; <nl> + } <nl> + <nl> + return % InternalNumberFormat ( formatter . formatter , number ) ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Returns a Number that represents string value that was passed in . <nl> + * / <nl> + function parseNumber ( formatter , value ) { <nl> + return % InternalNumberParse ( formatter . formatter , String ( value ) ) ; <nl> + } <nl> + <nl> + <nl> + addBoundMethod ( Intl . NumberFormat , ' format ' , formatNumber , 1 ) ; <nl> + addBoundMethod ( Intl . NumberFormat , ' v8Parse ' , parseNumber , 1 ) ; <nl> new file mode 100644 <nl> index 00000000000 . . b2d60b3fc67 <nl> mmm / dev / null <nl> ppp b / src / extensions / i18n / overrides . js <nl> <nl> + / / Copyright 2013 the V8 project authors . All rights reserved . <nl> + / / Redistribution and use in source and binary forms , with or without <nl> + / / modification , are permitted provided that the following conditions are <nl> + / / met : <nl> + / / <nl> + / / * Redistributions of source code must retain the above copyright <nl> + / / notice , this list of conditions and the following disclaimer . <nl> + / / * Redistributions in binary form must reproduce the above <nl> + / / copyright notice , this list of conditions and the following <nl> + / / disclaimer in the documentation and / or other materials provided <nl> + / / with the distribution . <nl> + / / * Neither the name of Google Inc . nor the names of its <nl> + / / contributors may be used to endorse or promote products derived <nl> + / / from this software without specific prior written permission . <nl> + / / <nl> + / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + / / limitations under the License . <nl> + <nl> + / / ECMAScript 402 API implementation is broken into separate files for <nl> + / / each service . The build system combines them together into one <nl> + / / Intl namespace . <nl> + <nl> + <nl> + / / Save references to Intl objects and methods we use , for added security . <nl> + var savedObjects = { <nl> + ' collator ' : Intl . Collator , <nl> + ' numberformat ' : Intl . NumberFormat , <nl> + ' dateformatall ' : Intl . DateTimeFormat , <nl> + ' dateformatdate ' : Intl . DateTimeFormat , <nl> + ' dateformattime ' : Intl . DateTimeFormat <nl> + } ; <nl> + <nl> + <nl> + / / Default ( created with undefined locales and options parameters ) collator , <nl> + / / number and date format instances . They ' ll be created as needed . <nl> + var defaultObjects = { <nl> + ' collator ' : undefined , <nl> + ' numberformat ' : undefined , <nl> + ' dateformatall ' : undefined , <nl> + ' dateformatdate ' : undefined , <nl> + ' dateformattime ' : undefined , <nl> + } ; <nl> + <nl> + <nl> + / * * <nl> + * Returns cached or newly created instance of a given service . <nl> + * We cache only default instances ( where no locales or options are provided ) . <nl> + * / <nl> + function cachedOrNewService ( service , locales , options , defaults ) { <nl> + var useOptions = ( defaults = = = undefined ) ? options : defaults ; <nl> + if ( locales = = = undefined & & options = = = undefined ) { <nl> + if ( defaultObjects [ service ] = = = undefined ) { <nl> + defaultObjects [ service ] = new savedObjects [ service ] ( locales , useOptions ) ; <nl> + } <nl> + return defaultObjects [ service ] ; <nl> + } <nl> + return new savedObjects [ service ] ( locales , useOptions ) ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Compares this and that , and returns less than 0 , 0 or greater than 0 value . <nl> + * Overrides the built - in method . <nl> + * / <nl> + Object . defineProperty ( String . prototype , ' localeCompare ' , { <nl> + value : function ( that ) { <nl> + if ( % _IsConstructCall ( ) ) { <nl> + throw new TypeError ( ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR ) ; <nl> + } <nl> + <nl> + if ( this = = = undefined | | this = = = null ) { <nl> + throw new TypeError ( ' Method invoked on undefined or null value . ' ) ; <nl> + } <nl> + <nl> + var locales = arguments [ 1 ] ; <nl> + var options = arguments [ 2 ] ; <nl> + var collator = cachedOrNewService ( ' collator ' , locales , options ) ; <nl> + return compare ( collator , this , that ) ; <nl> + } , <nl> + writable : true , <nl> + configurable : true , <nl> + enumerable : false <nl> + } ) ; <nl> + % FunctionSetName ( String . prototype . localeCompare , ' localeCompare ' ) ; <nl> + % FunctionRemovePrototype ( String . prototype . localeCompare ) ; <nl> + % SetNativeFlag ( String . prototype . localeCompare ) ; <nl> + <nl> + <nl> + / * * <nl> + * Formats a Number object ( this ) using locale and options values . <nl> + * If locale or options are omitted , defaults are used . <nl> + * / <nl> + Object . defineProperty ( Number . prototype , ' toLocaleString ' , { <nl> + value : function ( ) { <nl> + if ( % _IsConstructCall ( ) ) { <nl> + throw new TypeError ( ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR ) ; <nl> + } <nl> + <nl> + if ( ! ( this instanceof Number ) & & typeof ( this ) ! = = ' number ' ) { <nl> + throw new TypeError ( ' Method invoked on an object that is not Number . ' ) ; <nl> + } <nl> + <nl> + var locales = arguments [ 0 ] ; <nl> + var options = arguments [ 1 ] ; <nl> + var numberFormat = cachedOrNewService ( ' numberformat ' , locales , options ) ; <nl> + return formatNumber ( numberFormat , this ) ; <nl> + } , <nl> + writable : true , <nl> + configurable : true , <nl> + enumerable : false <nl> + } ) ; <nl> + % FunctionSetName ( Number . prototype . toLocaleString , ' toLocaleString ' ) ; <nl> + % FunctionRemovePrototype ( Number . prototype . toLocaleString ) ; <nl> + % SetNativeFlag ( Number . prototype . toLocaleString ) ; <nl> + <nl> + <nl> + / * * <nl> + * Returns actual formatted date or fails if date parameter is invalid . <nl> + * / <nl> + function toLocaleDateTime ( date , locales , options , required , defaults , service ) { <nl> + if ( ! ( date instanceof Date ) ) { <nl> + throw new TypeError ( ' Method invoked on an object that is not Date . ' ) ; <nl> + } <nl> + <nl> + if ( isNaN ( date ) ) { <nl> + return ' Invalid Date ' ; <nl> + } <nl> + <nl> + var internalOptions = toDateTimeOptions ( options , required , defaults ) ; <nl> + <nl> + var dateFormat = <nl> + cachedOrNewService ( service , locales , options , internalOptions ) ; <nl> + <nl> + return formatDate ( dateFormat , date ) ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Formats a Date object ( this ) using locale and options values . <nl> + * If locale or options are omitted , defaults are used - both date and time are <nl> + * present in the output . <nl> + * / <nl> + Object . defineProperty ( Date . prototype , ' toLocaleString ' , { <nl> + value : function ( ) { <nl> + if ( % _IsConstructCall ( ) ) { <nl> + throw new TypeError ( ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR ) ; <nl> + } <nl> + <nl> + var locales = arguments [ 0 ] ; <nl> + var options = arguments [ 1 ] ; <nl> + return toLocaleDateTime ( <nl> + this , locales , options , ' any ' , ' all ' , ' dateformatall ' ) ; <nl> + } , <nl> + writable : true , <nl> + configurable : true , <nl> + enumerable : false <nl> + } ) ; <nl> + % FunctionSetName ( Date . prototype . toLocaleString , ' toLocaleString ' ) ; <nl> + % FunctionRemovePrototype ( Date . prototype . toLocaleString ) ; <nl> + % SetNativeFlag ( Date . prototype . toLocaleString ) ; <nl> + <nl> + <nl> + / * * <nl> + * Formats a Date object ( this ) using locale and options values . <nl> + * If locale or options are omitted , defaults are used - only date is present <nl> + * in the output . <nl> + * / <nl> + Object . defineProperty ( Date . prototype , ' toLocaleDateString ' , { <nl> + value : function ( ) { <nl> + if ( % _IsConstructCall ( ) ) { <nl> + throw new TypeError ( ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR ) ; <nl> + } <nl> + <nl> + var locales = arguments [ 0 ] ; <nl> + var options = arguments [ 1 ] ; <nl> + return toLocaleDateTime ( <nl> + this , locales , options , ' date ' , ' date ' , ' dateformatdate ' ) ; <nl> + } , <nl> + writable : true , <nl> + configurable : true , <nl> + enumerable : false <nl> + } ) ; <nl> + % FunctionSetName ( Date . prototype . toLocaleDateString , ' toLocaleDateString ' ) ; <nl> + % FunctionRemovePrototype ( Date . prototype . toLocaleDateString ) ; <nl> + % SetNativeFlag ( Date . prototype . toLocaleDateString ) ; <nl> + <nl> + <nl> + / * * <nl> + * Formats a Date object ( this ) using locale and options values . <nl> + * If locale or options are omitted , defaults are used - only time is present <nl> + * in the output . <nl> + * / <nl> + Object . defineProperty ( Date . prototype , ' toLocaleTimeString ' , { <nl> + value : function ( ) { <nl> + if ( % _IsConstructCall ( ) ) { <nl> + throw new TypeError ( ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR ) ; <nl> + } <nl> + <nl> + var locales = arguments [ 0 ] ; <nl> + var options = arguments [ 1 ] ; <nl> + return toLocaleDateTime ( <nl> + this , locales , options , ' time ' , ' time ' , ' dateformattime ' ) ; <nl> + } , <nl> + writable : true , <nl> + configurable : true , <nl> + enumerable : false <nl> + } ) ; <nl> + % FunctionSetName ( Date . prototype . toLocaleTimeString , ' toLocaleTimeString ' ) ; <nl> + % FunctionRemovePrototype ( Date . prototype . toLocaleTimeString ) ; <nl> + % SetNativeFlag ( Date . prototype . toLocaleTimeString ) ; <nl> mmm a / src / flag - definitions . h <nl> ppp b / src / flag - definitions . h <nl> DEFINE_bool ( enable_vldr_imm , false , <nl> " enable use of constant pools for double immediate ( ARM only ) " ) <nl> <nl> / / bootstrapper . cc <nl> + DEFINE_bool ( enable_i18n , true , " enable i18n extension " ) <nl> DEFINE_string ( expose_natives_as , NULL , " expose natives in global object " ) <nl> DEFINE_string ( expose_debug_as , NULL , " expose debug in global object " ) <nl> DEFINE_bool ( expose_gc , false , " expose gc extension " ) <nl> deleted file mode 100644 <nl> index 882d43f6380 . . 00000000000 <nl> mmm a / src / i18n . js <nl> ppp / dev / null <nl> <nl> - / / Copyright 2013 the V8 project authors . All rights reserved . <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following <nl> - / / disclaimer in the documentation and / or other materials provided <nl> - / / with the distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived <nl> - / / from this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - / / limitations under the License . <nl> - <nl> - / / ECMAScript 402 API implementation . <nl> - <nl> - / * * <nl> - * Intl object is a single object that has some named properties , <nl> - * all of which are constructors . <nl> - * / <nl> - $ Object . defineProperty ( global , " Intl " , { enumerable : false , value : ( function ( ) { <nl> - <nl> - ' use strict ' ; <nl> - <nl> - var Intl = { } ; <nl> - <nl> - var undefined = global . undefined ; <nl> - <nl> - var AVAILABLE_SERVICES = [ ' collator ' , <nl> - ' numberformat ' , <nl> - ' dateformat ' , <nl> - ' breakiterator ' ] ; <nl> - <nl> - / * * <nl> - * Caches available locales for each service . <nl> - * / <nl> - var AVAILABLE_LOCALES = { <nl> - ' collator ' : undefined , <nl> - ' numberformat ' : undefined , <nl> - ' dateformat ' : undefined , <nl> - ' breakiterator ' : undefined <nl> - } ; <nl> - <nl> - / * * <nl> - * Caches default ICU locale . <nl> - * / <nl> - var DEFAULT_ICU_LOCALE = undefined ; <nl> - <nl> - / * * <nl> - * Unicode extension regular expression . <nl> - * / <nl> - var UNICODE_EXTENSION_RE = undefined ; <nl> - <nl> - function GetUnicodeExtensionRE ( ) { <nl> - if ( UNICODE_EXTENSION_RE = = = undefined ) { <nl> - UNICODE_EXTENSION_RE = new $ RegExp ( ' - u ( - [ a - z0 - 9 ] { 2 , 8 } ) + ' , ' g ' ) ; <nl> - } <nl> - return UNICODE_EXTENSION_RE ; <nl> - } <nl> - <nl> - / * * <nl> - * Matches any Unicode extension . <nl> - * / <nl> - var ANY_EXTENSION_RE = undefined ; <nl> - <nl> - function GetAnyExtensionRE ( ) { <nl> - if ( ANY_EXTENSION_RE = = = undefined ) { <nl> - ANY_EXTENSION_RE = new $ RegExp ( ' - [ a - z0 - 9 ] { 1 } - . * ' , ' g ' ) ; <nl> - } <nl> - return ANY_EXTENSION_RE ; <nl> - } <nl> - <nl> - / * * <nl> - * Replace quoted text ( single quote , anything but the quote and quote again ) . <nl> - * / <nl> - var QUOTED_STRING_RE = undefined ; <nl> - <nl> - function GetQuotedStringRE ( ) { <nl> - if ( QUOTED_STRING_RE = = = undefined ) { <nl> - QUOTED_STRING_RE = new $ RegExp ( " ' [ ^ ' ] + ' " , ' g ' ) ; <nl> - } <nl> - return QUOTED_STRING_RE ; <nl> - } <nl> - <nl> - / * * <nl> - * Matches valid service name . <nl> - * / <nl> - var SERVICE_RE = undefined ; <nl> - <nl> - function GetServiceRE ( ) { <nl> - if ( SERVICE_RE = = = undefined ) { <nl> - SERVICE_RE = <nl> - new $ RegExp ( ' ^ ( collator | numberformat | dateformat | breakiterator ) $ ' ) ; <nl> - } <nl> - return SERVICE_RE ; <nl> - } <nl> - <nl> - / * * <nl> - * Validates a language tag against bcp47 spec . <nl> - * Actual value is assigned on first run . <nl> - * / <nl> - var LANGUAGE_TAG_RE = undefined ; <nl> - <nl> - function GetLanguageTagRE ( ) { <nl> - if ( LANGUAGE_TAG_RE = = = undefined ) { <nl> - BuildLanguageTagREs ( ) ; <nl> - } <nl> - return LANGUAGE_TAG_RE ; <nl> - } <nl> - <nl> - / * * <nl> - * Helps find duplicate variants in the language tag . <nl> - * / <nl> - var LANGUAGE_VARIANT_RE = undefined ; <nl> - <nl> - function GetLanguageVariantRE ( ) { <nl> - if ( LANGUAGE_VARIANT_RE = = = undefined ) { <nl> - BuildLanguageTagREs ( ) ; <nl> - } <nl> - return LANGUAGE_VARIANT_RE ; <nl> - } <nl> - <nl> - / * * <nl> - * Helps find duplicate singletons in the language tag . <nl> - * / <nl> - var LANGUAGE_SINGLETON_RE = undefined ; <nl> - <nl> - function GetLanguageSingletonRE ( ) { <nl> - if ( LANGUAGE_SINGLETON_RE = = = undefined ) { <nl> - BuildLanguageTagREs ( ) ; <nl> - } <nl> - return LANGUAGE_SINGLETON_RE ; <nl> - } <nl> - <nl> - / * * <nl> - * Matches valid IANA time zone names . <nl> - * / <nl> - var TIMEZONE_NAME_CHECK_RE = undefined ; <nl> - <nl> - function GetTimezoneNameCheckRE ( ) { <nl> - if ( TIMEZONE_NAME_CHECK_RE = = = undefined ) { <nl> - TIMEZONE_NAME_CHECK_RE = <nl> - new $ RegExp ( ' ^ ( [ A - Za - z ] + ) / ( [ A - Za - z ] + ) ( ? : _ ( [ A - Za - z ] + ) ) * $ ' ) ; <nl> - } <nl> - return TIMEZONE_NAME_CHECK_RE ; <nl> - } <nl> - <nl> - / * * <nl> - * Maps ICU calendar names into LDML type . <nl> - * / <nl> - var ICU_CALENDAR_MAP = { <nl> - ' gregorian ' : ' gregory ' , <nl> - ' japanese ' : ' japanese ' , <nl> - ' buddhist ' : ' buddhist ' , <nl> - ' roc ' : ' roc ' , <nl> - ' persian ' : ' persian ' , <nl> - ' islamic - civil ' : ' islamicc ' , <nl> - ' islamic ' : ' islamic ' , <nl> - ' hebrew ' : ' hebrew ' , <nl> - ' chinese ' : ' chinese ' , <nl> - ' indian ' : ' indian ' , <nl> - ' coptic ' : ' coptic ' , <nl> - ' ethiopic ' : ' ethiopic ' , <nl> - ' ethiopic - amete - alem ' : ' ethioaa ' <nl> - } ; <nl> - <nl> - / * * <nl> - * Map of Unicode extensions to option properties , and their values and types , <nl> - * for a collator . <nl> - * / <nl> - var COLLATOR_KEY_MAP = { <nl> - ' kn ' : { ' property ' : ' numeric ' , ' type ' : ' boolean ' } , <nl> - ' kf ' : { ' property ' : ' caseFirst ' , ' type ' : ' string ' , <nl> - ' values ' : [ ' false ' , ' lower ' , ' upper ' ] } <nl> - } ; <nl> - <nl> - / * * <nl> - * Map of Unicode extensions to option properties , and their values and types , <nl> - * for a number format . <nl> - * / <nl> - var NUMBER_FORMAT_KEY_MAP = { <nl> - ' nu ' : { ' property ' : undefined , ' type ' : ' string ' } <nl> - } ; <nl> - <nl> - / * * <nl> - * Map of Unicode extensions to option properties , and their values and types , <nl> - * for a date / time format . <nl> - * / <nl> - var DATETIME_FORMAT_KEY_MAP = { <nl> - ' ca ' : { ' property ' : undefined , ' type ' : ' string ' } , <nl> - ' nu ' : { ' property ' : undefined , ' type ' : ' string ' } <nl> - } ; <nl> - <nl> - / * * <nl> - * Allowed - u - co - values . List taken from : <nl> - * http : / / unicode . org / repos / cldr / trunk / common / bcp47 / collation . xml <nl> - * / <nl> - var ALLOWED_CO_VALUES = [ <nl> - ' big5han ' , ' dict ' , ' direct ' , ' ducet ' , ' gb2312 ' , ' phonebk ' , ' phonetic ' , <nl> - ' pinyin ' , ' reformed ' , ' searchjl ' , ' stroke ' , ' trad ' , ' unihan ' , ' zhuyin ' <nl> - ] ; <nl> - <nl> - / * * <nl> - * Error message for when function object is created with new and it ' s not <nl> - * a constructor . <nl> - * / <nl> - var ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR = <nl> - ' Function object that \ ' s not a constructor was created with new ' ; <nl> - <nl> - <nl> - / * * <nl> - * Adds bound method to the prototype of the given object . <nl> - * / <nl> - function addBoundMethod ( obj , methodName , implementation , length ) { <nl> - function getter ( ) { <nl> - if ( ! this | | typeof this ! = = ' object ' | | <nl> - this . __initializedIntlObject = = = undefined ) { <nl> - throw new $ TypeError ( ' Method ' + methodName + ' called on a ' + <nl> - ' non - object or on a wrong type of object . ' ) ; <nl> - } <nl> - var internalName = ' __bound ' + methodName + ' __ ' ; <nl> - if ( this [ internalName ] = = = undefined ) { <nl> - var that = this ; <nl> - var boundMethod ; <nl> - if ( length = = = undefined | | length = = = 2 ) { <nl> - boundMethod = function ( x , y ) { <nl> - if ( % _IsConstructCall ( ) ) { <nl> - throw new $ TypeError ( ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR ) ; <nl> - } <nl> - return implementation ( that , x , y ) ; <nl> - } <nl> - } else if ( length = = = 1 ) { <nl> - boundMethod = function ( x ) { <nl> - if ( % _IsConstructCall ( ) ) { <nl> - throw new $ TypeError ( ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR ) ; <nl> - } <nl> - return implementation ( that , x ) ; <nl> - } <nl> - } else { <nl> - boundMethod = function ( ) { <nl> - if ( % _IsConstructCall ( ) ) { <nl> - throw new $ TypeError ( ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR ) ; <nl> - } <nl> - / / DateTimeFormat . format needs to be 0 arg method , but can stil <nl> - / / receive optional dateValue param . If one was provided , pass it <nl> - / / along . <nl> - if ( arguments . length > 0 ) { <nl> - return implementation ( that , arguments [ 0 ] ) ; <nl> - } else { <nl> - return implementation ( that ) ; <nl> - } <nl> - } <nl> - } <nl> - % FunctionSetName ( boundMethod , internalName ) ; <nl> - % FunctionRemovePrototype ( boundMethod ) ; <nl> - % SetNativeFlag ( boundMethod ) ; <nl> - this [ internalName ] = boundMethod ; <nl> - } <nl> - return this [ internalName ] ; <nl> - } <nl> - <nl> - % FunctionSetName ( getter , methodName ) ; <nl> - % FunctionRemovePrototype ( getter ) ; <nl> - % SetNativeFlag ( getter ) ; <nl> - <nl> - $ Object . defineProperty ( obj . prototype , methodName , { <nl> - get : getter , <nl> - enumerable : false , <nl> - configurable : true <nl> - } ) ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Returns an intersection of locales and service supported locales . <nl> - * Parameter locales is treated as a priority list . <nl> - * / <nl> - function supportedLocalesOf ( service , locales , options ) { <nl> - if ( service . match ( GetServiceRE ( ) ) = = = null ) { <nl> - throw new $ Error ( ' Internal error , wrong service type : ' + service ) ; <nl> - } <nl> - <nl> - / / Provide defaults if matcher was not specified . <nl> - if ( options = = = undefined ) { <nl> - options = { } ; <nl> - } else { <nl> - options = toObject ( options ) ; <nl> - } <nl> - <nl> - var matcher = options . localeMatcher ; <nl> - if ( matcher ! = = undefined ) { <nl> - matcher = $ String ( matcher ) ; <nl> - if ( matcher ! = = ' lookup ' & & matcher ! = = ' best fit ' ) { <nl> - throw new $ RangeError ( ' Illegal value for localeMatcher : ' + matcher ) ; <nl> - } <nl> - } else { <nl> - matcher = ' best fit ' ; <nl> - } <nl> - <nl> - var requestedLocales = initializeLocaleList ( locales ) ; <nl> - <nl> - / / Cache these , they don ' t ever change per service . <nl> - if ( AVAILABLE_LOCALES [ service ] = = = undefined ) { <nl> - AVAILABLE_LOCALES [ service ] = getAvailableLocalesOf ( service ) ; <nl> - } <nl> - <nl> - / / Use either best fit or lookup algorithm to match locales . <nl> - if ( matcher = = = ' best fit ' ) { <nl> - return initializeLocaleList ( bestFitSupportedLocalesOf ( <nl> - requestedLocales , AVAILABLE_LOCALES [ service ] ) ) ; <nl> - } <nl> - <nl> - return initializeLocaleList ( lookupSupportedLocalesOf ( <nl> - requestedLocales , AVAILABLE_LOCALES [ service ] ) ) ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Returns the subset of the provided BCP 47 language priority list for which <nl> - * this service has a matching locale when using the BCP 47 Lookup algorithm . <nl> - * Locales appear in the same order in the returned list as in the input list . <nl> - * / <nl> - function lookupSupportedLocalesOf ( requestedLocales , availableLocales ) { <nl> - var matchedLocales = [ ] ; <nl> - for ( var i = 0 ; i < requestedLocales . length ; + + i ) { <nl> - / / Remove - u - extension . <nl> - var locale = requestedLocales [ i ] . replace ( GetUnicodeExtensionRE ( ) , ' ' ) ; <nl> - do { <nl> - if ( availableLocales [ locale ] ! = = undefined ) { <nl> - / / Push requested locale not the resolved one . <nl> - matchedLocales . push ( requestedLocales [ i ] ) ; <nl> - break ; <nl> - } <nl> - / / Truncate locale if possible , if not break . <nl> - var pos = locale . lastIndexOf ( ' - ' ) ; <nl> - if ( pos = = = - 1 ) { <nl> - break ; <nl> - } <nl> - locale = locale . substring ( 0 , pos ) ; <nl> - } while ( true ) ; <nl> - } <nl> - <nl> - return matchedLocales ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Returns the subset of the provided BCP 47 language priority list for which <nl> - * this service has a matching locale when using the implementation <nl> - * dependent algorithm . <nl> - * Locales appear in the same order in the returned list as in the input list . <nl> - * / <nl> - function bestFitSupportedLocalesOf ( requestedLocales , availableLocales ) { <nl> - / / TODO ( cira ) : implement better best fit algorithm . <nl> - return lookupSupportedLocalesOf ( requestedLocales , availableLocales ) ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Returns a getOption function that extracts property value for given <nl> - * options object . If property is missing it returns defaultValue . If value <nl> - * is out of range for that property it throws RangeError . <nl> - * / <nl> - function getGetOption ( options , caller ) { <nl> - if ( options = = = undefined ) { <nl> - throw new $ Error ( ' Internal ' + caller + ' error . ' + <nl> - ' Default options are missing . ' ) ; <nl> - } <nl> - <nl> - var getOption = function getOption ( property , type , values , defaultValue ) { <nl> - if ( options [ property ] ! = = undefined ) { <nl> - var value = options [ property ] ; <nl> - switch ( type ) { <nl> - case ' boolean ' : <nl> - value = Boolean ( value ) ; <nl> - break ; <nl> - case ' string ' : <nl> - value = $ String ( value ) ; <nl> - break ; <nl> - case ' number ' : <nl> - value = $ Number ( value ) ; <nl> - break ; <nl> - default : <nl> - throw new $ Error ( ' Internal error . Wrong value type . ' ) ; <nl> - } <nl> - if ( values ! = = undefined & & values . indexOf ( value ) = = = - 1 ) { <nl> - throw new $ RangeError ( ' Value ' + value + ' out of range for ' + caller + <nl> - ' options property ' + property ) ; <nl> - } <nl> - <nl> - return value ; <nl> - } <nl> - <nl> - return defaultValue ; <nl> - } <nl> - <nl> - return getOption ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Compares a BCP 47 language priority list requestedLocales against the locales <nl> - * in availableLocales and determines the best available language to meet the <nl> - * request . Two algorithms are available to match the locales : the Lookup <nl> - * algorithm described in RFC 4647 section 3 . 4 , and an implementation dependent <nl> - * best - fit algorithm . Independent of the locale matching algorithm , options <nl> - * specified through Unicode locale extension sequences are negotiated <nl> - * separately , taking the caller ' s relevant extension keys and locale data as <nl> - * well as client - provided options into consideration . Returns an object with <nl> - * a locale property whose value is the language tag of the selected locale , <nl> - * and properties for each key in relevantExtensionKeys providing the selected <nl> - * value for that key . <nl> - * / <nl> - function resolveLocale ( service , requestedLocales , options ) { <nl> - requestedLocales = initializeLocaleList ( requestedLocales ) ; <nl> - <nl> - var getOption = getGetOption ( options , service ) ; <nl> - var matcher = getOption ( ' localeMatcher ' , ' string ' , <nl> - [ ' lookup ' , ' best fit ' ] , ' best fit ' ) ; <nl> - var resolved ; <nl> - if ( matcher = = = ' lookup ' ) { <nl> - resolved = lookupMatcher ( service , requestedLocales ) ; <nl> - } else { <nl> - resolved = bestFitMatcher ( service , requestedLocales ) ; <nl> - } <nl> - <nl> - return resolved ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Returns best matched supported locale and extension info using basic <nl> - * lookup algorithm . <nl> - * / <nl> - function lookupMatcher ( service , requestedLocales ) { <nl> - if ( service . match ( GetServiceRE ( ) ) = = = null ) { <nl> - throw new $ Error ( ' Internal error , wrong service type : ' + service ) ; <nl> - } <nl> - <nl> - / / Cache these , they don ' t ever change per service . <nl> - if ( AVAILABLE_LOCALES [ service ] = = = undefined ) { <nl> - AVAILABLE_LOCALES [ service ] = getAvailableLocalesOf ( service ) ; <nl> - } <nl> - <nl> - for ( var i = 0 ; i < requestedLocales . length ; + + i ) { <nl> - / / Remove all extensions . <nl> - var locale = requestedLocales [ i ] . replace ( GetAnyExtensionRE ( ) , ' ' ) ; <nl> - do { <nl> - if ( AVAILABLE_LOCALES [ service ] [ locale ] ! = = undefined ) { <nl> - / / Return the resolved locale and extension . <nl> - var extensionMatch = requestedLocales [ i ] . match ( GetUnicodeExtensionRE ( ) ) ; <nl> - var extension = ( extensionMatch = = = null ) ? ' ' : extensionMatch [ 0 ] ; <nl> - return { ' locale ' : locale , ' extension ' : extension , ' position ' : i } ; <nl> - } <nl> - / / Truncate locale if possible . <nl> - var pos = locale . lastIndexOf ( ' - ' ) ; <nl> - if ( pos = = = - 1 ) { <nl> - break ; <nl> - } <nl> - locale = locale . substring ( 0 , pos ) ; <nl> - } while ( true ) ; <nl> - } <nl> - <nl> - / / Didn ' t find a match , return default . <nl> - if ( DEFAULT_ICU_LOCALE = = = undefined ) { <nl> - DEFAULT_ICU_LOCALE = % GetDefaultICULocale ( ) ; <nl> - } <nl> - <nl> - return { ' locale ' : DEFAULT_ICU_LOCALE , ' extension ' : ' ' , ' position ' : - 1 } ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Returns best matched supported locale and extension info using <nl> - * implementation dependend algorithm . <nl> - * / <nl> - function bestFitMatcher ( service , requestedLocales ) { <nl> - / / TODO ( cira ) : implement better best fit algorithm . <nl> - return lookupMatcher ( service , requestedLocales ) ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Parses Unicode extension into key - value map . <nl> - * Returns empty object if the extension string is invalid . <nl> - * We are not concerned with the validity of the values at this point . <nl> - * / <nl> - function parseExtension ( extension ) { <nl> - var extensionSplit = extension . split ( ' - ' ) ; <nl> - <nl> - / / Assume [ ' ' , ' u ' , . . . ] input , but don ' t throw . <nl> - if ( extensionSplit . length < = 2 | | <nl> - ( extensionSplit [ 0 ] ! = = ' ' & & extensionSplit [ 1 ] ! = = ' u ' ) ) { <nl> - return { } ; <nl> - } <nl> - <nl> - / / Key is { 2 } alphanum , value is { 3 , 8 } alphanum . <nl> - / / Some keys may not have explicit values ( booleans ) . <nl> - var extensionMap = { } ; <nl> - var previousKey = undefined ; <nl> - for ( var i = 2 ; i < extensionSplit . length ; + + i ) { <nl> - var length = extensionSplit [ i ] . length ; <nl> - var element = extensionSplit [ i ] ; <nl> - if ( length = = = 2 ) { <nl> - extensionMap [ element ] = undefined ; <nl> - previousKey = element ; <nl> - } else if ( length > = 3 & & length < = 8 & & previousKey ! = = undefined ) { <nl> - extensionMap [ previousKey ] = element ; <nl> - previousKey = undefined ; <nl> - } else { <nl> - / / There is a value that ' s too long , or that doesn ' t have a key . <nl> - return { } ; <nl> - } <nl> - } <nl> - <nl> - return extensionMap ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Converts parameter to an Object if possible . <nl> - * / <nl> - function toObject ( value ) { <nl> - if ( value = = = undefined | | value = = = null ) { <nl> - throw new $ TypeError ( ' Value cannot be converted to an Object . ' ) ; <nl> - } <nl> - <nl> - return $ Object ( value ) ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Populates internalOptions object with boolean key - value pairs <nl> - * from extensionMap and options . <nl> - * Returns filtered extension ( number and date format constructors use <nl> - * Unicode extensions for passing parameters to ICU ) . <nl> - * It ' s used for extension - option pairs only , e . g . kn - normalization , but not <nl> - * for ' sensitivity ' since it doesn ' t have extension equivalent . <nl> - * Extensions like nu and ca don ' t have options equivalent , so we place <nl> - * undefined in the map . property to denote that . <nl> - * / <nl> - function setOptions ( inOptions , extensionMap , keyValues , getOption , outOptions ) { <nl> - var extension = ' ' ; <nl> - <nl> - var updateExtension = function updateExtension ( key , value ) { <nl> - return ' - ' + key + ' - ' + $ String ( value ) ; <nl> - } <nl> - <nl> - var updateProperty = function updateProperty ( property , type , value ) { <nl> - if ( type = = = ' boolean ' & & ( typeof value = = = ' string ' ) ) { <nl> - value = ( value = = = ' true ' ) ? true : false ; <nl> - } <nl> - <nl> - if ( property ! = = undefined ) { <nl> - defineWEProperty ( outOptions , property , value ) ; <nl> - } <nl> - } <nl> - <nl> - for ( var key in keyValues ) { <nl> - if ( keyValues . hasOwnProperty ( key ) ) { <nl> - var value = undefined ; <nl> - var map = keyValues [ key ] ; <nl> - if ( map . property ! = = undefined ) { <nl> - / / This may return true if user specifies numeric : ' false ' , since <nl> - / / Boolean ( ' nonempty ' ) = = = true . <nl> - value = getOption ( map . property , map . type , map . values ) ; <nl> - } <nl> - if ( value ! = = undefined ) { <nl> - updateProperty ( map . property , map . type , value ) ; <nl> - extension + = updateExtension ( key , value ) ; <nl> - continue ; <nl> - } <nl> - / / User options didn ' t have it , check Unicode extension . <nl> - / / Here we want to convert strings ' true ' , ' false ' into proper Boolean <nl> - / / values ( not a user error ) . <nl> - if ( extensionMap . hasOwnProperty ( key ) ) { <nl> - value = extensionMap [ key ] ; <nl> - if ( value ! = = undefined ) { <nl> - updateProperty ( map . property , map . type , value ) ; <nl> - extension + = updateExtension ( key , value ) ; <nl> - } else if ( map . type = = = ' boolean ' ) { <nl> - / / Boolean keys are allowed not to have values in Unicode extension . <nl> - / / Those default to true . <nl> - updateProperty ( map . property , map . type , true ) ; <nl> - extension + = updateExtension ( key , true ) ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - <nl> - return extension = = = ' ' ? ' ' : ' - u ' + extension ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Converts all OwnProperties into <nl> - * configurable : false , writable : false , enumerable : true . <nl> - * / <nl> - function freezeArray ( array ) { <nl> - array . forEach ( function ( element , index ) { <nl> - $ Object . defineProperty ( array , index , { value : element , <nl> - configurable : false , <nl> - writable : false , <nl> - enumerable : true } ) ; <nl> - } ) ; <nl> - <nl> - $ Object . defineProperty ( array , ' length ' , { value : array . length , <nl> - writable : false } ) ; <nl> - <nl> - return array ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * It ' s sometimes desireable to leave user requested locale instead of ICU <nl> - * supported one ( zh - TW is equivalent to zh - Hant - TW , so we should keep shorter <nl> - * one , if that was what user requested ) . <nl> - * This function returns user specified tag if its maximized form matches ICU <nl> - * resolved locale . If not we return ICU result . <nl> - * / <nl> - function getOptimalLanguageTag ( original , resolved ) { <nl> - / / Returns Array < Object > , where each object has maximized and base properties . <nl> - / / Maximized : zh - > zh - Hans - CN <nl> - / / Base : zh - CN - u - ca - gregory - > zh - CN <nl> - / / Take care of grandfathered or simple cases . <nl> - if ( original = = = resolved ) { <nl> - return original ; <nl> - } <nl> - <nl> - var locales = % GetLanguageTagVariants ( [ original , resolved ] ) ; <nl> - if ( locales [ 0 ] . maximized ! = = locales [ 1 ] . maximized ) { <nl> - return resolved ; <nl> - } <nl> - <nl> - / / Preserve extensions of resolved locale , but swap base tags with original . <nl> - var resolvedBase = new $ RegExp ( ' ^ ' + locales [ 1 ] . base ) ; <nl> - return resolved . replace ( resolvedBase , locales [ 0 ] . base ) ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Returns an Object that contains all of supported locales for a given <nl> - * service . <nl> - * In addition to the supported locales we add xx - ZZ locale for each xx - Yyyy - ZZ <nl> - * that is supported . This is required by the spec . <nl> - * / <nl> - function getAvailableLocalesOf ( service ) { <nl> - var available = % AvailableLocalesOf ( service ) ; <nl> - <nl> - for ( var i in available ) { <nl> - if ( available . hasOwnProperty ( i ) ) { <nl> - var parts = i . match ( / ^ ( [ a - z ] { 2 , 3 } ) - ( [ A - Z ] [ a - z ] { 3 } ) - ( [ A - Z ] { 2 } ) $ / ) ; <nl> - if ( parts ! = = null ) { <nl> - / / Build xx - ZZ . We don ' t care about the actual value , <nl> - / / as long it ' s not undefined . <nl> - available [ parts [ 1 ] + ' - ' + parts [ 3 ] ] = null ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - return available ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Defines a property and sets writable and enumerable to true . <nl> - * Configurable is false by default . <nl> - * / <nl> - function defineWEProperty ( object , property , value ) { <nl> - $ Object . defineProperty ( object , property , <nl> - { value : value , writable : true , enumerable : true } ) ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Adds property to an object if the value is not undefined . <nl> - * Sets configurable descriptor to false . <nl> - * / <nl> - function addWEPropertyIfDefined ( object , property , value ) { <nl> - if ( value ! = = undefined ) { <nl> - defineWEProperty ( object , property , value ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Defines a property and sets writable , enumerable and configurable to true . <nl> - * / <nl> - function defineWECProperty ( object , property , value ) { <nl> - $ Object . defineProperty ( object , property , <nl> - { value : value , <nl> - writable : true , <nl> - enumerable : true , <nl> - configurable : true } ) ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Adds property to an object if the value is not undefined . <nl> - * Sets all descriptors to true . <nl> - * / <nl> - function addWECPropertyIfDefined ( object , property , value ) { <nl> - if ( value ! = = undefined ) { <nl> - defineWECProperty ( object , property , value ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Returns titlecased word , aMeRricA - > America . <nl> - * / <nl> - function toTitleCaseWord ( word ) { <nl> - return word . substr ( 0 , 1 ) . toUpperCase ( ) + word . substr ( 1 ) . toLowerCase ( ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Canonicalizes the language tag , or throws in case the tag is invalid . <nl> - * / <nl> - function canonicalizeLanguageTag ( localeID ) { <nl> - / / null is typeof ' object ' so we have to do extra check . <nl> - if ( typeof localeID ! = = ' string ' & & typeof localeID ! = = ' object ' | | <nl> - localeID = = = null ) { <nl> - throw new $ TypeError ( ' Language ID should be string or object . ' ) ; <nl> - } <nl> - <nl> - var localeString = $ String ( localeID ) ; <nl> - <nl> - if ( isValidLanguageTag ( localeString ) = = = false ) { <nl> - throw new $ RangeError ( ' Invalid language tag : ' + localeString ) ; <nl> - } <nl> - <nl> - / / This call will strip - kn but not - kn - true extensions . <nl> - / / ICU bug filled - http : / / bugs . icu - project . org / trac / ticket / 9265 . <nl> - / / TODO ( cira ) : check if - u - kn - true - kc - true - kh - true still throws after <nl> - / / upgrade to ICU 4 . 9 . <nl> - var tag = % CanonicalizeLanguageTag ( localeString ) ; <nl> - if ( tag = = = ' invalid - tag ' ) { <nl> - throw new $ RangeError ( ' Invalid language tag : ' + localeString ) ; <nl> - } <nl> - <nl> - return tag ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Returns an array where all locales are canonicalized and duplicates removed . <nl> - * Throws on locales that are not well formed BCP47 tags . <nl> - * / <nl> - function initializeLocaleList ( locales ) { <nl> - var seen = [ ] ; <nl> - if ( locales = = = undefined ) { <nl> - / / Constructor is called without arguments . <nl> - seen = [ ] ; <nl> - } else { <nl> - / / We allow single string localeID . <nl> - if ( typeof locales = = = ' string ' ) { <nl> - seen . push ( canonicalizeLanguageTag ( locales ) ) ; <nl> - return freezeArray ( seen ) ; <nl> - } <nl> - <nl> - var o = toObject ( locales ) ; <nl> - / / Converts it to UInt32 ( > > > is shr on 32bit integers ) . <nl> - var len = o . length > > > 0 ; <nl> - <nl> - for ( var k = 0 ; k < len ; k + + ) { <nl> - if ( k in o ) { <nl> - var value = o [ k ] ; <nl> - <nl> - var tag = canonicalizeLanguageTag ( value ) ; <nl> - <nl> - if ( seen . indexOf ( tag ) = = = - 1 ) { <nl> - seen . push ( tag ) ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - <nl> - return freezeArray ( seen ) ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Validates the language tag . Section 2 . 2 . 9 of the bcp47 spec <nl> - * defines a valid tag . <nl> - * <nl> - * ICU is too permissible and lets invalid tags , like <nl> - * hant - cmn - cn , through . <nl> - * <nl> - * Returns false if the language tag is invalid . <nl> - * / <nl> - function isValidLanguageTag ( locale ) { <nl> - / / Check if it ' s well - formed , including grandfadered tags . <nl> - if ( GetLanguageTagRE ( ) . test ( locale ) = = = false ) { <nl> - return false ; <nl> - } <nl> - <nl> - / / Just return if it ' s a x - form . It ' s all private . <nl> - if ( locale . indexOf ( ' x - ' ) = = = 0 ) { <nl> - return true ; <nl> - } <nl> - <nl> - / / Check if there are any duplicate variants or singletons ( extensions ) . <nl> - <nl> - / / Remove private use section . <nl> - locale = locale . split ( / - x - / ) [ 0 ] ; <nl> - <nl> - / / Skip language since it can match variant regex , so we start from 1 . <nl> - / / We are matching i - klingon here , but that ' s ok , since i - klingon - klingon <nl> - / / is not valid and would fail LANGUAGE_TAG_RE test . <nl> - var variants = [ ] ; <nl> - var extensions = [ ] ; <nl> - var parts = locale . split ( / - / ) ; <nl> - for ( var i = 1 ; i < parts . length ; i + + ) { <nl> - var value = parts [ i ] ; <nl> - if ( GetLanguageVariantRE ( ) . test ( value ) = = = true & & extensions . length = = = 0 ) { <nl> - if ( variants . indexOf ( value ) = = = - 1 ) { <nl> - variants . push ( value ) ; <nl> - } else { <nl> - return false ; <nl> - } <nl> - } <nl> - <nl> - if ( GetLanguageSingletonRE ( ) . test ( value ) = = = true ) { <nl> - if ( extensions . indexOf ( value ) = = = - 1 ) { <nl> - extensions . push ( value ) ; <nl> - } else { <nl> - return false ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - return true ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Builds a regular expresion that validates the language tag <nl> - * against bcp47 spec . <nl> - * Uses http : / / tools . ietf . org / html / bcp47 , section 2 . 1 , ABNF . <nl> - * Runs on load and initializes the global REs . <nl> - * / <nl> - function BuildLanguageTagREs ( ) { <nl> - var alpha = ' [ a - zA - Z ] ' ; <nl> - var digit = ' [ 0 - 9 ] ' ; <nl> - var alphanum = ' ( ' + alpha + ' | ' + digit + ' ) ' ; <nl> - var regular = ' ( art - lojban | cel - gaulish | no - bok | no - nyn | zh - guoyu | zh - hakka | ' + <nl> - ' zh - min | zh - min - nan | zh - xiang ) ' ; <nl> - var irregular = ' ( en - GB - oed | i - ami | i - bnn | i - default | i - enochian | i - hak | ' + <nl> - ' i - klingon | i - lux | i - mingo | i - navajo | i - pwn | i - tao | i - tay | ' + <nl> - ' i - tsu | sgn - BE - FR | sgn - BE - NL | sgn - CH - DE ) ' ; <nl> - var grandfathered = ' ( ' + irregular + ' | ' + regular + ' ) ' ; <nl> - var privateUse = ' ( x ( - ' + alphanum + ' { 1 , 8 } ) + ) ' ; <nl> - <nl> - var singleton = ' ( ' + digit + ' | [ A - WY - Za - wy - z ] ) ' ; <nl> - LANGUAGE_SINGLETON_RE = new $ RegExp ( ' ^ ' + singleton + ' $ ' , ' i ' ) ; <nl> - <nl> - var extension = ' ( ' + singleton + ' ( - ' + alphanum + ' { 2 , 8 } ) + ) ' ; <nl> - <nl> - var variant = ' ( ' + alphanum + ' { 5 , 8 } | ( ' + digit + alphanum + ' { 3 } ) ) ' ; <nl> - LANGUAGE_VARIANT_RE = new $ RegExp ( ' ^ ' + variant + ' $ ' , ' i ' ) ; <nl> - <nl> - var region = ' ( ' + alpha + ' { 2 } | ' + digit + ' { 3 } ) ' ; <nl> - var script = ' ( ' + alpha + ' { 4 } ) ' ; <nl> - var extLang = ' ( ' + alpha + ' { 3 } ( - ' + alpha + ' { 3 } ) { 0 , 2 } ) ' ; <nl> - var language = ' ( ' + alpha + ' { 2 , 3 } ( - ' + extLang + ' ) ? | ' + alpha + ' { 4 } | ' + <nl> - alpha + ' { 5 , 8 } ) ' ; <nl> - var langTag = language + ' ( - ' + script + ' ) ? ( - ' + region + ' ) ? ( - ' + <nl> - variant + ' ) * ( - ' + extension + ' ) * ( - ' + privateUse + ' ) ? ' ; <nl> - <nl> - var languageTag = <nl> - ' ^ ( ' + langTag + ' | ' + privateUse + ' | ' + grandfathered + ' ) $ ' ; <nl> - LANGUAGE_TAG_RE = new $ RegExp ( languageTag , ' i ' ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Initializes the given object so it ' s a valid Collator instance . <nl> - * Useful for subclassing . <nl> - * / <nl> - function initializeCollator ( collator , locales , options ) { <nl> - if ( collator . hasOwnProperty ( ' __initializedIntlObject ' ) ) { <nl> - throw new $ TypeError ( ' Trying to re - initialize Collator object . ' ) ; <nl> - } <nl> - <nl> - if ( options = = = undefined ) { <nl> - options = { } ; <nl> - } <nl> - <nl> - var getOption = getGetOption ( options , ' collator ' ) ; <nl> - <nl> - var internalOptions = { } ; <nl> - <nl> - defineWEProperty ( internalOptions , ' usage ' , getOption ( <nl> - ' usage ' , ' string ' , [ ' sort ' , ' search ' ] , ' sort ' ) ) ; <nl> - <nl> - var sensitivity = getOption ( ' sensitivity ' , ' string ' , <nl> - [ ' base ' , ' accent ' , ' case ' , ' variant ' ] ) ; <nl> - if ( sensitivity = = = undefined & & internalOptions . usage = = = ' sort ' ) { <nl> - sensitivity = ' variant ' ; <nl> - } <nl> - defineWEProperty ( internalOptions , ' sensitivity ' , sensitivity ) ; <nl> - <nl> - defineWEProperty ( internalOptions , ' ignorePunctuation ' , getOption ( <nl> - ' ignorePunctuation ' , ' boolean ' , undefined , false ) ) ; <nl> - <nl> - var locale = resolveLocale ( ' collator ' , locales , options ) ; <nl> - <nl> - / / ICU can ' t take kb , kc . . . parameters through localeID , so we need to pass <nl> - / / them as options . <nl> - / / One exception is - co - which has to be part of the extension , but only for <nl> - / / usage : sort , and its value can ' t be ' standard ' or ' search ' . <nl> - var extensionMap = parseExtension ( locale . extension ) ; <nl> - setOptions ( <nl> - options , extensionMap , COLLATOR_KEY_MAP , getOption , internalOptions ) ; <nl> - <nl> - var collation = ' default ' ; <nl> - var extension = ' ' ; <nl> - if ( extensionMap . hasOwnProperty ( ' co ' ) & & internalOptions . usage = = = ' sort ' ) { <nl> - if ( ALLOWED_CO_VALUES . indexOf ( extensionMap . co ) ! = = - 1 ) { <nl> - extension = ' - u - co - ' + extensionMap . co ; <nl> - / / ICU can ' t tell us what the collation is , so save user ' s input . <nl> - collation = extensionMap . co ; <nl> - } <nl> - } else if ( internalOptions . usage = = = ' search ' ) { <nl> - extension = ' - u - co - search ' ; <nl> - } <nl> - defineWEProperty ( internalOptions , ' collation ' , collation ) ; <nl> - <nl> - var requestedLocale = locale . locale + extension ; <nl> - <nl> - / / We define all properties C + + code may produce , to prevent security <nl> - / / problems . If malicious user decides to redefine Object . prototype . locale <nl> - / / we can ' t just use plain x . locale = ' us ' or in C + + Set ( " locale " , " us " ) . <nl> - / / Object . defineProperties will either succeed defining or throw an error . <nl> - var resolved = $ Object . defineProperties ( { } , { <nl> - caseFirst : { writable : true } , <nl> - collation : { value : internalOptions . collation , writable : true } , <nl> - ignorePunctuation : { writable : true } , <nl> - locale : { writable : true } , <nl> - numeric : { writable : true } , <nl> - requestedLocale : { value : requestedLocale , writable : true } , <nl> - sensitivity : { writable : true } , <nl> - strength : { writable : true } , <nl> - usage : { value : internalOptions . usage , writable : true } <nl> - } ) ; <nl> - <nl> - var internalCollator = % CreateCollator ( requestedLocale , <nl> - internalOptions , <nl> - resolved ) ; <nl> - <nl> - / / Writable , configurable and enumerable are set to false by default . <nl> - $ Object . defineProperty ( collator , ' collator ' , { value : internalCollator } ) ; <nl> - $ Object . defineProperty ( collator , ' __initializedIntlObject ' , <nl> - { value : ' collator ' } ) ; <nl> - $ Object . defineProperty ( collator , ' resolved ' , { value : resolved } ) ; <nl> - <nl> - return collator ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Constructs Intl . Collator object given optional locales and options <nl> - * parameters . <nl> - * <nl> - * @ constructor <nl> - * / <nl> - % SetProperty ( Intl , ' Collator ' , function ( ) { <nl> - var locales = arguments [ 0 ] ; <nl> - var options = arguments [ 1 ] ; <nl> - <nl> - if ( ! this | | this = = = Intl ) { <nl> - / / Constructor is called as a function . <nl> - return new Intl . Collator ( locales , options ) ; <nl> - } <nl> - <nl> - return initializeCollator ( toObject ( this ) , locales , options ) ; <nl> - } , <nl> - DONT_ENUM <nl> - ) ; <nl> - <nl> - <nl> - / * * <nl> - * Collator resolvedOptions method . <nl> - * / <nl> - % SetProperty ( Intl . Collator . prototype , ' resolvedOptions ' , function ( ) { <nl> - if ( % _IsConstructCall ( ) ) { <nl> - throw new $ TypeError ( ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR ) ; <nl> - } <nl> - <nl> - if ( ! this | | typeof this ! = = ' object ' | | <nl> - this . __initializedIntlObject ! = = ' collator ' ) { <nl> - throw new $ TypeError ( ' resolvedOptions method called on a non - object ' + <nl> - ' or on a object that is not Intl . Collator . ' ) ; <nl> - } <nl> - <nl> - var coll = this ; <nl> - var locale = getOptimalLanguageTag ( coll . resolved . requestedLocale , <nl> - coll . resolved . locale ) ; <nl> - <nl> - return { <nl> - locale : locale , <nl> - usage : coll . resolved . usage , <nl> - sensitivity : coll . resolved . sensitivity , <nl> - ignorePunctuation : coll . resolved . ignorePunctuation , <nl> - numeric : coll . resolved . numeric , <nl> - caseFirst : coll . resolved . caseFirst , <nl> - collation : coll . resolved . collation <nl> - } ; <nl> - } , <nl> - DONT_ENUM <nl> - ) ; <nl> - % FunctionSetName ( Intl . Collator . prototype . resolvedOptions , ' resolvedOptions ' ) ; <nl> - % FunctionRemovePrototype ( Intl . Collator . prototype . resolvedOptions ) ; <nl> - % SetNativeFlag ( Intl . Collator . prototype . resolvedOptions ) ; <nl> - <nl> - <nl> - / * * <nl> - * Returns the subset of the given locale list for which this locale list <nl> - * has a matching ( possibly fallback ) locale . Locales appear in the same <nl> - * order in the returned list as in the input list . <nl> - * Options are optional parameter . <nl> - * / <nl> - % SetProperty ( Intl . Collator , ' supportedLocalesOf ' , function ( locales ) { <nl> - if ( % _IsConstructCall ( ) ) { <nl> - throw new $ TypeError ( ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR ) ; <nl> - } <nl> - <nl> - return supportedLocalesOf ( ' collator ' , locales , arguments [ 1 ] ) ; <nl> - } , <nl> - DONT_ENUM <nl> - ) ; <nl> - % FunctionSetName ( Intl . Collator . supportedLocalesOf , ' supportedLocalesOf ' ) ; <nl> - % FunctionRemovePrototype ( Intl . Collator . supportedLocalesOf ) ; <nl> - % SetNativeFlag ( Intl . Collator . supportedLocalesOf ) ; <nl> - <nl> - <nl> - / * * <nl> - * When the compare method is called with two arguments x and y , it returns a <nl> - * Number other than NaN that represents the result of a locale - sensitive <nl> - * String comparison of x with y . <nl> - * The result is intended to order String values in the sort order specified <nl> - * by the effective locale and collation options computed during construction <nl> - * of this Collator object , and will be negative , zero , or positive , depending <nl> - * on whether x comes before y in the sort order , the Strings are equal under <nl> - * the sort order , or x comes after y in the sort order , respectively . <nl> - * / <nl> - function compare ( collator , x , y ) { <nl> - return % InternalCompare ( collator . collator , $ String ( x ) , $ String ( y ) ) ; <nl> - } ; <nl> - <nl> - <nl> - addBoundMethod ( Intl . Collator , ' compare ' , compare , 2 ) ; <nl> - <nl> - / * * <nl> - * Verifies that the input is a well - formed ISO 4217 currency code . <nl> - * Don ' t uppercase to test . It could convert invalid code into a valid one . <nl> - * For example \ u00DFP ( Eszett + P ) becomes SSP . <nl> - * / <nl> - function isWellFormedCurrencyCode ( currency ) { <nl> - return typeof currency = = " string " & & <nl> - currency . length = = 3 & & <nl> - currency . match ( / [ ^ A - Za - z ] / ) = = null ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Returns the valid digit count for a property , or throws RangeError on <nl> - * a value out of the range . <nl> - * / <nl> - function getNumberOption ( options , property , min , max , fallback ) { <nl> - var value = options [ property ] ; <nl> - if ( value ! = = undefined ) { <nl> - value = $ Number ( value ) ; <nl> - if ( $ isNaN ( value ) | | value < min | | value > max ) { <nl> - throw new $ RangeError ( property + ' value is out of range . ' ) ; <nl> - } <nl> - return $ floor ( value ) ; <nl> - } <nl> - <nl> - return fallback ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Initializes the given object so it ' s a valid NumberFormat instance . <nl> - * Useful for subclassing . <nl> - * / <nl> - function initializeNumberFormat ( numberFormat , locales , options ) { <nl> - if ( numberFormat . hasOwnProperty ( ' __initializedIntlObject ' ) ) { <nl> - throw new $ TypeError ( ' Trying to re - initialize NumberFormat object . ' ) ; <nl> - } <nl> - <nl> - if ( options = = = undefined ) { <nl> - options = { } ; <nl> - } <nl> - <nl> - var getOption = getGetOption ( options , ' numberformat ' ) ; <nl> - <nl> - var locale = resolveLocale ( ' numberformat ' , locales , options ) ; <nl> - <nl> - var internalOptions = { } ; <nl> - defineWEProperty ( internalOptions , ' style ' , getOption ( <nl> - ' style ' , ' string ' , [ ' decimal ' , ' percent ' , ' currency ' ] , ' decimal ' ) ) ; <nl> - <nl> - var currency = getOption ( ' currency ' , ' string ' ) ; <nl> - if ( currency ! = = undefined & & ! isWellFormedCurrencyCode ( currency ) ) { <nl> - throw new $ RangeError ( ' Invalid currency code : ' + currency ) ; <nl> - } <nl> - <nl> - if ( internalOptions . style = = = ' currency ' & & currency = = = undefined ) { <nl> - throw new $ TypeError ( ' Currency code is required with currency style . ' ) ; <nl> - } <nl> - <nl> - var currencyDisplay = getOption ( <nl> - ' currencyDisplay ' , ' string ' , [ ' code ' , ' symbol ' , ' name ' ] , ' symbol ' ) ; <nl> - if ( internalOptions . style = = = ' currency ' ) { <nl> - defineWEProperty ( internalOptions , ' currency ' , currency . toUpperCase ( ) ) ; <nl> - defineWEProperty ( internalOptions , ' currencyDisplay ' , currencyDisplay ) ; <nl> - } <nl> - <nl> - / / Digit ranges . <nl> - var mnid = getNumberOption ( options , ' minimumIntegerDigits ' , 1 , 21 , 1 ) ; <nl> - defineWEProperty ( internalOptions , ' minimumIntegerDigits ' , mnid ) ; <nl> - <nl> - var mnfd = getNumberOption ( options , ' minimumFractionDigits ' , 0 , 20 , 0 ) ; <nl> - defineWEProperty ( internalOptions , ' minimumFractionDigits ' , mnfd ) ; <nl> - <nl> - var mxfd = getNumberOption ( options , ' maximumFractionDigits ' , mnfd , 20 , 3 ) ; <nl> - defineWEProperty ( internalOptions , ' maximumFractionDigits ' , mxfd ) ; <nl> - <nl> - var mnsd = options [ ' minimumSignificantDigits ' ] ; <nl> - var mxsd = options [ ' maximumSignificantDigits ' ] ; <nl> - if ( mnsd ! = = undefined | | mxsd ! = = undefined ) { <nl> - mnsd = getNumberOption ( options , ' minimumSignificantDigits ' , 1 , 21 , 0 ) ; <nl> - defineWEProperty ( internalOptions , ' minimumSignificantDigits ' , mnsd ) ; <nl> - <nl> - mxsd = getNumberOption ( options , ' maximumSignificantDigits ' , mnsd , 21 , 21 ) ; <nl> - defineWEProperty ( internalOptions , ' maximumSignificantDigits ' , mxsd ) ; <nl> - } <nl> - <nl> - / / Grouping . <nl> - defineWEProperty ( internalOptions , ' useGrouping ' , getOption ( <nl> - ' useGrouping ' , ' boolean ' , undefined , true ) ) ; <nl> - <nl> - / / ICU prefers options to be passed using - u - extension key / values for <nl> - / / number format , so we need to build that . <nl> - var extensionMap = parseExtension ( locale . extension ) ; <nl> - var extension = setOptions ( options , extensionMap , NUMBER_FORMAT_KEY_MAP , <nl> - getOption , internalOptions ) ; <nl> - <nl> - var requestedLocale = locale . locale + extension ; <nl> - var resolved = $ Object . defineProperties ( { } , { <nl> - currency : { writable : true } , <nl> - currencyDisplay : { writable : true } , <nl> - locale : { writable : true } , <nl> - maximumFractionDigits : { writable : true } , <nl> - minimumFractionDigits : { writable : true } , <nl> - minimumIntegerDigits : { writable : true } , <nl> - numberingSystem : { writable : true } , <nl> - requestedLocale : { value : requestedLocale , writable : true } , <nl> - style : { value : internalOptions . style , writable : true } , <nl> - useGrouping : { writable : true } <nl> - } ) ; <nl> - if ( internalOptions . hasOwnProperty ( ' minimumSignificantDigits ' ) ) { <nl> - defineWEProperty ( resolved , ' minimumSignificantDigits ' , undefined ) ; <nl> - } <nl> - if ( internalOptions . hasOwnProperty ( ' maximumSignificantDigits ' ) ) { <nl> - defineWEProperty ( resolved , ' maximumSignificantDigits ' , undefined ) ; <nl> - } <nl> - var formatter = % CreateNumberFormat ( requestedLocale , <nl> - internalOptions , <nl> - resolved ) ; <nl> - <nl> - / / We can ' t get information about number or currency style from ICU , so we <nl> - / / assume user request was fulfilled . <nl> - if ( internalOptions . style = = = ' currency ' ) { <nl> - $ Object . defineProperty ( resolved , ' currencyDisplay ' , { value : currencyDisplay , <nl> - writable : true } ) ; <nl> - } <nl> - <nl> - $ Object . defineProperty ( numberFormat , ' formatter ' , { value : formatter } ) ; <nl> - $ Object . defineProperty ( numberFormat , ' resolved ' , { value : resolved } ) ; <nl> - $ Object . defineProperty ( numberFormat , ' __initializedIntlObject ' , <nl> - { value : ' numberformat ' } ) ; <nl> - <nl> - return numberFormat ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Constructs Intl . NumberFormat object given optional locales and options <nl> - * parameters . <nl> - * <nl> - * @ constructor <nl> - * / <nl> - % SetProperty ( Intl , ' NumberFormat ' , function ( ) { <nl> - var locales = arguments [ 0 ] ; <nl> - var options = arguments [ 1 ] ; <nl> - <nl> - if ( ! this | | this = = = Intl ) { <nl> - / / Constructor is called as a function . <nl> - return new Intl . NumberFormat ( locales , options ) ; <nl> - } <nl> - <nl> - return initializeNumberFormat ( toObject ( this ) , locales , options ) ; <nl> - } , <nl> - DONT_ENUM <nl> - ) ; <nl> - <nl> - <nl> - / * * <nl> - * NumberFormat resolvedOptions method . <nl> - * / <nl> - % SetProperty ( Intl . NumberFormat . prototype , ' resolvedOptions ' , function ( ) { <nl> - if ( % _IsConstructCall ( ) ) { <nl> - throw new $ TypeError ( ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR ) ; <nl> - } <nl> - <nl> - if ( ! this | | typeof this ! = = ' object ' | | <nl> - this . __initializedIntlObject ! = = ' numberformat ' ) { <nl> - throw new $ TypeError ( ' resolvedOptions method called on a non - object ' + <nl> - ' or on a object that is not Intl . NumberFormat . ' ) ; <nl> - } <nl> - <nl> - var format = this ; <nl> - var locale = getOptimalLanguageTag ( format . resolved . requestedLocale , <nl> - format . resolved . locale ) ; <nl> - <nl> - var result = { <nl> - locale : locale , <nl> - numberingSystem : format . resolved . numberingSystem , <nl> - style : format . resolved . style , <nl> - useGrouping : format . resolved . useGrouping , <nl> - minimumIntegerDigits : format . resolved . minimumIntegerDigits , <nl> - minimumFractionDigits : format . resolved . minimumFractionDigits , <nl> - maximumFractionDigits : format . resolved . maximumFractionDigits , <nl> - } ; <nl> - <nl> - if ( result . style = = = ' currency ' ) { <nl> - defineWECProperty ( result , ' currency ' , format . resolved . currency ) ; <nl> - defineWECProperty ( result , ' currencyDisplay ' , <nl> - format . resolved . currencyDisplay ) ; <nl> - } <nl> - <nl> - if ( format . resolved . hasOwnProperty ( ' minimumSignificantDigits ' ) ) { <nl> - defineWECProperty ( result , ' minimumSignificantDigits ' , <nl> - format . resolved . minimumSignificantDigits ) ; <nl> - } <nl> - <nl> - if ( format . resolved . hasOwnProperty ( ' maximumSignificantDigits ' ) ) { <nl> - defineWECProperty ( result , ' maximumSignificantDigits ' , <nl> - format . resolved . maximumSignificantDigits ) ; <nl> - } <nl> - <nl> - return result ; <nl> - } , <nl> - DONT_ENUM <nl> - ) ; <nl> - % FunctionSetName ( Intl . NumberFormat . prototype . resolvedOptions , <nl> - ' resolvedOptions ' ) ; <nl> - % FunctionRemovePrototype ( Intl . NumberFormat . prototype . resolvedOptions ) ; <nl> - % SetNativeFlag ( Intl . NumberFormat . prototype . resolvedOptions ) ; <nl> - <nl> - <nl> - / * * <nl> - * Returns the subset of the given locale list for which this locale list <nl> - * has a matching ( possibly fallback ) locale . Locales appear in the same <nl> - * order in the returned list as in the input list . <nl> - * Options are optional parameter . <nl> - * / <nl> - % SetProperty ( Intl . NumberFormat , ' supportedLocalesOf ' , function ( locales ) { <nl> - if ( % _IsConstructCall ( ) ) { <nl> - throw new $ TypeError ( ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR ) ; <nl> - } <nl> - <nl> - return supportedLocalesOf ( ' numberformat ' , locales , arguments [ 1 ] ) ; <nl> - } , <nl> - DONT_ENUM <nl> - ) ; <nl> - % FunctionSetName ( Intl . NumberFormat . supportedLocalesOf , ' supportedLocalesOf ' ) ; <nl> - % FunctionRemovePrototype ( Intl . NumberFormat . supportedLocalesOf ) ; <nl> - % SetNativeFlag ( Intl . NumberFormat . supportedLocalesOf ) ; <nl> - <nl> - <nl> - / * * <nl> - * Returns a String value representing the result of calling ToNumber ( value ) <nl> - * according to the effective locale and the formatting options of this <nl> - * NumberFormat . <nl> - * / <nl> - function formatNumber ( formatter , value ) { <nl> - / / Spec treats - 0 and + 0 as 0 . <nl> - var number = $ Number ( value ) ; <nl> - if ( number = = = - 0 ) { <nl> - number = 0 ; <nl> - } <nl> - <nl> - return % InternalNumberFormat ( formatter . formatter , number ) ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Returns a Number that represents string value that was passed in . <nl> - * / <nl> - function parseNumber ( formatter , value ) { <nl> - return % InternalNumberParse ( formatter . formatter , $ String ( value ) ) ; <nl> - } <nl> - <nl> - <nl> - addBoundMethod ( Intl . NumberFormat , ' format ' , formatNumber , 1 ) ; <nl> - addBoundMethod ( Intl . NumberFormat , ' v8Parse ' , parseNumber , 1 ) ; <nl> - <nl> - / * * <nl> - * Returns a string that matches LDML representation of the options object . <nl> - * / <nl> - function toLDMLString ( options ) { <nl> - var getOption = getGetOption ( options , ' dateformat ' ) ; <nl> - <nl> - var ldmlString = ' ' ; <nl> - <nl> - var option = getOption ( ' weekday ' , ' string ' , [ ' narrow ' , ' short ' , ' long ' ] ) ; <nl> - ldmlString + = appendToLDMLString ( <nl> - option , { narrow : ' EEEEE ' , short : ' EEE ' , long : ' EEEE ' } ) ; <nl> - <nl> - option = getOption ( ' era ' , ' string ' , [ ' narrow ' , ' short ' , ' long ' ] ) ; <nl> - ldmlString + = appendToLDMLString ( <nl> - option , { narrow : ' GGGGG ' , short : ' GGG ' , long : ' GGGG ' } ) ; <nl> - <nl> - option = getOption ( ' year ' , ' string ' , [ ' 2 - digit ' , ' numeric ' ] ) ; <nl> - ldmlString + = appendToLDMLString ( option , { ' 2 - digit ' : ' yy ' , ' numeric ' : ' y ' } ) ; <nl> - <nl> - option = getOption ( ' month ' , ' string ' , <nl> - [ ' 2 - digit ' , ' numeric ' , ' narrow ' , ' short ' , ' long ' ] ) ; <nl> - ldmlString + = appendToLDMLString ( option , { ' 2 - digit ' : ' MM ' , ' numeric ' : ' M ' , <nl> - ' narrow ' : ' MMMMM ' , ' short ' : ' MMM ' , ' long ' : ' MMMM ' } ) ; <nl> - <nl> - option = getOption ( ' day ' , ' string ' , [ ' 2 - digit ' , ' numeric ' ] ) ; <nl> - ldmlString + = appendToLDMLString ( <nl> - option , { ' 2 - digit ' : ' dd ' , ' numeric ' : ' d ' } ) ; <nl> - <nl> - var hr12 = getOption ( ' hour12 ' , ' boolean ' ) ; <nl> - option = getOption ( ' hour ' , ' string ' , [ ' 2 - digit ' , ' numeric ' ] ) ; <nl> - if ( hr12 = = = undefined ) { <nl> - ldmlString + = appendToLDMLString ( option , { ' 2 - digit ' : ' jj ' , ' numeric ' : ' j ' } ) ; <nl> - } else if ( hr12 = = = true ) { <nl> - ldmlString + = appendToLDMLString ( option , { ' 2 - digit ' : ' hh ' , ' numeric ' : ' h ' } ) ; <nl> - } else { <nl> - ldmlString + = appendToLDMLString ( option , { ' 2 - digit ' : ' HH ' , ' numeric ' : ' H ' } ) ; <nl> - } <nl> - <nl> - option = getOption ( ' minute ' , ' string ' , [ ' 2 - digit ' , ' numeric ' ] ) ; <nl> - ldmlString + = appendToLDMLString ( option , { ' 2 - digit ' : ' mm ' , ' numeric ' : ' m ' } ) ; <nl> - <nl> - option = getOption ( ' second ' , ' string ' , [ ' 2 - digit ' , ' numeric ' ] ) ; <nl> - ldmlString + = appendToLDMLString ( option , { ' 2 - digit ' : ' ss ' , ' numeric ' : ' s ' } ) ; <nl> - <nl> - option = getOption ( ' timeZoneName ' , ' string ' , [ ' short ' , ' long ' ] ) ; <nl> - ldmlString + = appendToLDMLString ( option , { short : ' v ' , long : ' vv ' } ) ; <nl> - <nl> - return ldmlString ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Returns either LDML equivalent of the current option or empty string . <nl> - * / <nl> - function appendToLDMLString ( option , pairs ) { <nl> - if ( option ! = = undefined ) { <nl> - return pairs [ option ] ; <nl> - } else { <nl> - return ' ' ; <nl> - } <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Returns object that matches LDML representation of the date . <nl> - * / <nl> - function fromLDMLString ( ldmlString ) { <nl> - / / First remove ' ' quoted text , so we lose ' Uhr ' strings . <nl> - ldmlString = ldmlString . replace ( GetQuotedStringRE ( ) , ' ' ) ; <nl> - <nl> - var options = { } ; <nl> - var match = ldmlString . match ( / E { 3 , 5 } / g ) ; <nl> - options = appendToDateTimeObject ( <nl> - options , ' weekday ' , match , { EEEEE : ' narrow ' , EEE : ' short ' , EEEE : ' long ' } ) ; <nl> - <nl> - match = ldmlString . match ( / G { 3 , 5 } / g ) ; <nl> - options = appendToDateTimeObject ( <nl> - options , ' era ' , match , { GGGGG : ' narrow ' , GGG : ' short ' , GGGG : ' long ' } ) ; <nl> - <nl> - match = ldmlString . match ( / y { 1 , 2 } / g ) ; <nl> - options = appendToDateTimeObject ( <nl> - options , ' year ' , match , { y : ' numeric ' , yy : ' 2 - digit ' } ) ; <nl> - <nl> - match = ldmlString . match ( / M { 1 , 5 } / g ) ; <nl> - options = appendToDateTimeObject ( options , ' month ' , match , { MM : ' 2 - digit ' , <nl> - M : ' numeric ' , MMMMM : ' narrow ' , MMM : ' short ' , MMMM : ' long ' } ) ; <nl> - <nl> - / / Sometimes we get L instead of M for month - standalone name . <nl> - match = ldmlString . match ( / L { 1 , 5 } / g ) ; <nl> - options = appendToDateTimeObject ( options , ' month ' , match , { LL : ' 2 - digit ' , <nl> - L : ' numeric ' , LLLLL : ' narrow ' , LLL : ' short ' , LLLL : ' long ' } ) ; <nl> - <nl> - match = ldmlString . match ( / d { 1 , 2 } / g ) ; <nl> - options = appendToDateTimeObject ( <nl> - options , ' day ' , match , { d : ' numeric ' , dd : ' 2 - digit ' } ) ; <nl> - <nl> - match = ldmlString . match ( / h { 1 , 2 } / g ) ; <nl> - if ( match ! = = null ) { <nl> - options [ ' hour12 ' ] = true ; <nl> - } <nl> - options = appendToDateTimeObject ( <nl> - options , ' hour ' , match , { h : ' numeric ' , hh : ' 2 - digit ' } ) ; <nl> - <nl> - match = ldmlString . match ( / H { 1 , 2 } / g ) ; <nl> - if ( match ! = = null ) { <nl> - options [ ' hour12 ' ] = false ; <nl> - } <nl> - options = appendToDateTimeObject ( <nl> - options , ' hour ' , match , { H : ' numeric ' , HH : ' 2 - digit ' } ) ; <nl> - <nl> - match = ldmlString . match ( / m { 1 , 2 } / g ) ; <nl> - options = appendToDateTimeObject ( <nl> - options , ' minute ' , match , { m : ' numeric ' , mm : ' 2 - digit ' } ) ; <nl> - <nl> - match = ldmlString . match ( / s { 1 , 2 } / g ) ; <nl> - options = appendToDateTimeObject ( <nl> - options , ' second ' , match , { s : ' numeric ' , ss : ' 2 - digit ' } ) ; <nl> - <nl> - match = ldmlString . match ( / v { 1 , 2 } / g ) ; <nl> - options = appendToDateTimeObject ( <nl> - options , ' timeZoneName ' , match , { v : ' short ' , vv : ' long ' } ) ; <nl> - <nl> - return options ; <nl> - } <nl> - <nl> - <nl> - function appendToDateTimeObject ( options , option , match , pairs ) { <nl> - if ( match = = = null ) { <nl> - if ( ! options . hasOwnProperty ( option ) ) { <nl> - defineWEProperty ( options , option , undefined ) ; <nl> - } <nl> - return options ; <nl> - } <nl> - <nl> - var property = match [ 0 ] ; <nl> - defineWEProperty ( options , option , pairs [ property ] ) ; <nl> - <nl> - return options ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Returns options with at least default values in it . <nl> - * / <nl> - function toDateTimeOptions ( options , required , defaults ) { <nl> - if ( options = = = undefined ) { <nl> - options = null ; <nl> - } else { <nl> - options = toObject ( options ) ; <nl> - } <nl> - <nl> - options = $ Object . apply ( this , [ options ] ) ; <nl> - <nl> - var needsDefault = true ; <nl> - if ( ( required = = = ' date ' | | required = = = ' any ' ) & & <nl> - ( options . weekday ! = = undefined | | options . year ! = = undefined | | <nl> - options . month ! = = undefined | | options . day ! = = undefined ) ) { <nl> - needsDefault = false ; <nl> - } <nl> - <nl> - if ( ( required = = = ' time ' | | required = = = ' any ' ) & & <nl> - ( options . hour ! = = undefined | | options . minute ! = = undefined | | <nl> - options . second ! = = undefined ) ) { <nl> - needsDefault = false ; <nl> - } <nl> - <nl> - if ( needsDefault & & ( defaults = = = ' date ' | | defaults = = = ' all ' ) ) { <nl> - $ Object . defineProperty ( options , ' year ' , { value : ' numeric ' , <nl> - writable : true , <nl> - enumerable : true , <nl> - configurable : true } ) ; <nl> - $ Object . defineProperty ( options , ' month ' , { value : ' numeric ' , <nl> - writable : true , <nl> - enumerable : true , <nl> - configurable : true } ) ; <nl> - $ Object . defineProperty ( options , ' day ' , { value : ' numeric ' , <nl> - writable : true , <nl> - enumerable : true , <nl> - configurable : true } ) ; <nl> - } <nl> - <nl> - if ( needsDefault & & ( defaults = = = ' time ' | | defaults = = = ' all ' ) ) { <nl> - $ Object . defineProperty ( options , ' hour ' , { value : ' numeric ' , <nl> - writable : true , <nl> - enumerable : true , <nl> - configurable : true } ) ; <nl> - $ Object . defineProperty ( options , ' minute ' , { value : ' numeric ' , <nl> - writable : true , <nl> - enumerable : true , <nl> - configurable : true } ) ; <nl> - $ Object . defineProperty ( options , ' second ' , { value : ' numeric ' , <nl> - writable : true , <nl> - enumerable : true , <nl> - configurable : true } ) ; <nl> - } <nl> - <nl> - return options ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Initializes the given object so it ' s a valid DateTimeFormat instance . <nl> - * Useful for subclassing . <nl> - * / <nl> - function initializeDateTimeFormat ( dateFormat , locales , options ) { <nl> - <nl> - if ( dateFormat . hasOwnProperty ( ' __initializedIntlObject ' ) ) { <nl> - throw new $ TypeError ( ' Trying to re - initialize DateTimeFormat object . ' ) ; <nl> - } <nl> - <nl> - if ( options = = = undefined ) { <nl> - options = { } ; <nl> - } <nl> - <nl> - var locale = resolveLocale ( ' dateformat ' , locales , options ) ; <nl> - <nl> - options = toDateTimeOptions ( options , ' any ' , ' date ' ) ; <nl> - <nl> - var getOption = getGetOption ( options , ' dateformat ' ) ; <nl> - <nl> - / / We implement only best fit algorithm , but still need to check <nl> - / / if the formatMatcher values are in range . <nl> - var matcher = getOption ( ' formatMatcher ' , ' string ' , <nl> - [ ' basic ' , ' best fit ' ] , ' best fit ' ) ; <nl> - <nl> - / / Build LDML string for the skeleton that we pass to the formatter . <nl> - var ldmlString = toLDMLString ( options ) ; <nl> - <nl> - / / Filter out supported extension keys so we know what to put in resolved <nl> - / / section later on . <nl> - / / We need to pass calendar and number system to the method . <nl> - var tz = canonicalizeTimeZoneID ( options . timeZone ) ; <nl> - <nl> - / / ICU prefers options to be passed using - u - extension key / values , so <nl> - / / we need to build that . <nl> - var internalOptions = { } ; <nl> - var extensionMap = parseExtension ( locale . extension ) ; <nl> - var extension = setOptions ( options , extensionMap , DATETIME_FORMAT_KEY_MAP , <nl> - getOption , internalOptions ) ; <nl> - <nl> - var requestedLocale = locale . locale + extension ; <nl> - var resolved = $ Object . defineProperties ( { } , { <nl> - calendar : { writable : true } , <nl> - day : { writable : true } , <nl> - era : { writable : true } , <nl> - hour12 : { writable : true } , <nl> - hour : { writable : true } , <nl> - locale : { writable : true } , <nl> - minute : { writable : true } , <nl> - month : { writable : true } , <nl> - numberingSystem : { writable : true } , <nl> - pattern : { writable : true } , <nl> - requestedLocale : { value : requestedLocale , writable : true } , <nl> - second : { writable : true } , <nl> - timeZone : { writable : true } , <nl> - timeZoneName : { writable : true } , <nl> - tz : { value : tz , writable : true } , <nl> - weekday : { writable : true } , <nl> - year : { writable : true } <nl> - } ) ; <nl> - <nl> - var formatter = % CreateDateTimeFormat ( <nl> - requestedLocale , { skeleton : ldmlString , timeZone : tz } , resolved ) ; <nl> - <nl> - if ( tz ! = = undefined & & tz ! = = resolved . timeZone ) { <nl> - throw new $ RangeError ( ' Unsupported time zone specified ' + tz ) ; <nl> - } <nl> - <nl> - $ Object . defineProperty ( dateFormat , ' formatter ' , { value : formatter } ) ; <nl> - $ Object . defineProperty ( dateFormat , ' resolved ' , { value : resolved } ) ; <nl> - $ Object . defineProperty ( dateFormat , ' __initializedIntlObject ' , <nl> - { value : ' dateformat ' } ) ; <nl> - <nl> - return dateFormat ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Constructs Intl . DateTimeFormat object given optional locales and options <nl> - * parameters . <nl> - * <nl> - * @ constructor <nl> - * / <nl> - % SetProperty ( Intl , ' DateTimeFormat ' , function ( ) { <nl> - var locales = arguments [ 0 ] ; <nl> - var options = arguments [ 1 ] ; <nl> - <nl> - if ( ! this | | this = = = Intl ) { <nl> - / / Constructor is called as a function . <nl> - return new Intl . DateTimeFormat ( locales , options ) ; <nl> - } <nl> - <nl> - return initializeDateTimeFormat ( toObject ( this ) , locales , options ) ; <nl> - } , <nl> - DONT_ENUM <nl> - ) ; <nl> - <nl> - <nl> - / * * <nl> - * DateTimeFormat resolvedOptions method . <nl> - * / <nl> - % SetProperty ( Intl . DateTimeFormat . prototype , ' resolvedOptions ' , function ( ) { <nl> - if ( % _IsConstructCall ( ) ) { <nl> - throw new $ TypeError ( ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR ) ; <nl> - } <nl> - <nl> - if ( ! this | | typeof this ! = = ' object ' | | <nl> - this . __initializedIntlObject ! = = ' dateformat ' ) { <nl> - throw new $ TypeError ( ' resolvedOptions method called on a non - object or ' + <nl> - ' on a object that is not Intl . DateTimeFormat . ' ) ; <nl> - } <nl> - <nl> - var format = this ; <nl> - var fromPattern = fromLDMLString ( format . resolved . pattern ) ; <nl> - var userCalendar = ICU_CALENDAR_MAP [ format . resolved . calendar ] ; <nl> - if ( userCalendar = = = undefined ) { <nl> - / / Use ICU name if we don ' t have a match . It shouldn ' t happen , but <nl> - / / it would be too strict to throw for this . <nl> - userCalendar = format . resolved . calendar ; <nl> - } <nl> - <nl> - var locale = getOptimalLanguageTag ( format . resolved . requestedLocale , <nl> - format . resolved . locale ) ; <nl> - <nl> - var result = { <nl> - locale : locale , <nl> - numberingSystem : format . resolved . numberingSystem , <nl> - calendar : userCalendar , <nl> - timeZone : format . resolved . timeZone <nl> - } ; <nl> - <nl> - addWECPropertyIfDefined ( result , ' timeZoneName ' , fromPattern . timeZoneName ) ; <nl> - addWECPropertyIfDefined ( result , ' era ' , fromPattern . era ) ; <nl> - addWECPropertyIfDefined ( result , ' year ' , fromPattern . year ) ; <nl> - addWECPropertyIfDefined ( result , ' month ' , fromPattern . month ) ; <nl> - addWECPropertyIfDefined ( result , ' day ' , fromPattern . day ) ; <nl> - addWECPropertyIfDefined ( result , ' weekday ' , fromPattern . weekday ) ; <nl> - addWECPropertyIfDefined ( result , ' hour12 ' , fromPattern . hour12 ) ; <nl> - addWECPropertyIfDefined ( result , ' hour ' , fromPattern . hour ) ; <nl> - addWECPropertyIfDefined ( result , ' minute ' , fromPattern . minute ) ; <nl> - addWECPropertyIfDefined ( result , ' second ' , fromPattern . second ) ; <nl> - <nl> - return result ; <nl> - } , <nl> - DONT_ENUM <nl> - ) ; <nl> - % FunctionSetName ( Intl . DateTimeFormat . prototype . resolvedOptions , <nl> - ' resolvedOptions ' ) ; <nl> - % FunctionRemovePrototype ( Intl . DateTimeFormat . prototype . resolvedOptions ) ; <nl> - % SetNativeFlag ( Intl . DateTimeFormat . prototype . resolvedOptions ) ; <nl> - <nl> - <nl> - / * * <nl> - * Returns the subset of the given locale list for which this locale list <nl> - * has a matching ( possibly fallback ) locale . Locales appear in the same <nl> - * order in the returned list as in the input list . <nl> - * Options are optional parameter . <nl> - * / <nl> - % SetProperty ( Intl . DateTimeFormat , ' supportedLocalesOf ' , function ( locales ) { <nl> - if ( % _IsConstructCall ( ) ) { <nl> - throw new $ TypeError ( ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR ) ; <nl> - } <nl> - <nl> - return supportedLocalesOf ( ' dateformat ' , locales , arguments [ 1 ] ) ; <nl> - } , <nl> - DONT_ENUM <nl> - ) ; <nl> - % FunctionSetName ( Intl . DateTimeFormat . supportedLocalesOf , ' supportedLocalesOf ' ) ; <nl> - % FunctionRemovePrototype ( Intl . DateTimeFormat . supportedLocalesOf ) ; <nl> - % SetNativeFlag ( Intl . DateTimeFormat . supportedLocalesOf ) ; <nl> - <nl> - <nl> - / * * <nl> - * Returns a String value representing the result of calling ToNumber ( date ) <nl> - * according to the effective locale and the formatting options of this <nl> - * DateTimeFormat . <nl> - * / <nl> - function formatDate ( formatter , dateValue ) { <nl> - var dateMs ; <nl> - if ( dateValue = = = undefined ) { <nl> - dateMs = $ Date . now ( ) ; <nl> - } else { <nl> - dateMs = $ Number ( dateValue ) ; <nl> - } <nl> - <nl> - if ( ! $ isFinite ( dateMs ) ) { <nl> - throw new $ RangeError ( ' Provided date is not in valid range . ' ) ; <nl> - } <nl> - <nl> - return % InternalDateFormat ( formatter . formatter , new $ Date ( dateMs ) ) ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Returns a Date object representing the result of calling ToString ( value ) <nl> - * according to the effective locale and the formatting options of this <nl> - * DateTimeFormat . <nl> - * Returns undefined if date string cannot be parsed . <nl> - * / <nl> - function parseDate ( formatter , value ) { <nl> - return % InternalDateParse ( formatter . formatter , $ String ( value ) ) ; <nl> - } <nl> - <nl> - <nl> - / / 0 because date is optional argument . <nl> - addBoundMethod ( Intl . DateTimeFormat , ' format ' , formatDate , 0 ) ; <nl> - addBoundMethod ( Intl . DateTimeFormat , ' v8Parse ' , parseDate , 1 ) ; <nl> - <nl> - <nl> - / * * <nl> - * Returns canonical Area / Location name , or throws an exception if the zone <nl> - * name is invalid IANA name . <nl> - * / <nl> - function canonicalizeTimeZoneID ( tzID ) { <nl> - / / Skip undefined zones . <nl> - if ( tzID = = = undefined ) { <nl> - return tzID ; <nl> - } <nl> - <nl> - / / Special case handling ( UTC , GMT ) . <nl> - var upperID = tzID . toUpperCase ( ) ; <nl> - if ( upperID = = = ' UTC ' | | upperID = = = ' GMT ' | | <nl> - upperID = = = ' ETC / UTC ' | | upperID = = = ' ETC / GMT ' ) { <nl> - return ' UTC ' ; <nl> - } <nl> - <nl> - / / We expect only _ and / beside ASCII letters . <nl> - / / All inputs should conform to Area / Location from now on . <nl> - var match = GetTimezoneNameCheckRE ( ) . exec ( tzID ) ; <nl> - if ( match = = = null ) { <nl> - throw new $ RangeError ( ' Expected Area / Location for time zone , got ' + tzID ) ; <nl> - } <nl> - <nl> - var result = toTitleCaseWord ( match [ 1 ] ) + ' / ' + toTitleCaseWord ( match [ 2 ] ) ; <nl> - var i = 3 ; <nl> - while ( match [ i ] ! = = undefined & & i < match . length ) { <nl> - result = result + ' _ ' + toTitleCaseWord ( match [ i ] ) ; <nl> - i + + ; <nl> - } <nl> - <nl> - return result ; <nl> - } <nl> - <nl> - / * * <nl> - * Initializes the given object so it ' s a valid BreakIterator instance . <nl> - * Useful for subclassing . <nl> - * / <nl> - function initializeBreakIterator ( iterator , locales , options ) { <nl> - if ( iterator . hasOwnProperty ( ' __initializedIntlObject ' ) ) { <nl> - throw new $ TypeError ( ' Trying to re - initialize v8BreakIterator object . ' ) ; <nl> - } <nl> - <nl> - if ( options = = = undefined ) { <nl> - options = { } ; <nl> - } <nl> - <nl> - var getOption = getGetOption ( options , ' breakiterator ' ) ; <nl> - <nl> - var internalOptions = { } ; <nl> - <nl> - defineWEProperty ( internalOptions , ' type ' , getOption ( <nl> - ' type ' , ' string ' , [ ' character ' , ' word ' , ' sentence ' , ' line ' ] , ' word ' ) ) ; <nl> - <nl> - var locale = resolveLocale ( ' breakiterator ' , locales , options ) ; <nl> - var resolved = $ Object . defineProperties ( { } , { <nl> - requestedLocale : { value : locale . locale , writable : true } , <nl> - type : { value : internalOptions . type , writable : true } , <nl> - locale : { writable : true } <nl> - } ) ; <nl> - <nl> - var internalIterator = % CreateBreakIterator ( locale . locale , <nl> - internalOptions , <nl> - resolved ) ; <nl> - <nl> - $ Object . defineProperty ( iterator , ' iterator ' , { value : internalIterator } ) ; <nl> - $ Object . defineProperty ( iterator , ' resolved ' , { value : resolved } ) ; <nl> - $ Object . defineProperty ( iterator , ' __initializedIntlObject ' , <nl> - { value : ' breakiterator ' } ) ; <nl> - <nl> - return iterator ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Constructs Intl . v8BreakIterator object given optional locales and options <nl> - * parameters . <nl> - * <nl> - * @ constructor <nl> - * / <nl> - % SetProperty ( Intl , ' v8BreakIterator ' , function ( ) { <nl> - var locales = arguments [ 0 ] ; <nl> - var options = arguments [ 1 ] ; <nl> - <nl> - if ( ! this | | this = = = Intl ) { <nl> - / / Constructor is called as a function . <nl> - return new Intl . v8BreakIterator ( locales , options ) ; <nl> - } <nl> - <nl> - return initializeBreakIterator ( toObject ( this ) , locales , options ) ; <nl> - } , <nl> - DONT_ENUM <nl> - ) ; <nl> - <nl> - <nl> - / * * <nl> - * BreakIterator resolvedOptions method . <nl> - * / <nl> - % SetProperty ( Intl . v8BreakIterator . prototype , ' resolvedOptions ' , function ( ) { <nl> - if ( % _IsConstructCall ( ) ) { <nl> - throw new $ TypeError ( ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR ) ; <nl> - } <nl> - <nl> - if ( ! this | | typeof this ! = = ' object ' | | <nl> - this . __initializedIntlObject ! = = ' breakiterator ' ) { <nl> - throw new $ TypeError ( ' resolvedOptions method called on a non - object or ' + <nl> - ' on a object that is not Intl . v8BreakIterator . ' ) ; <nl> - } <nl> - <nl> - var segmenter = this ; <nl> - var locale = getOptimalLanguageTag ( segmenter . resolved . requestedLocale , <nl> - segmenter . resolved . locale ) ; <nl> - <nl> - return { <nl> - locale : locale , <nl> - type : segmenter . resolved . type <nl> - } ; <nl> - } , <nl> - DONT_ENUM <nl> - ) ; <nl> - % FunctionSetName ( Intl . v8BreakIterator . prototype . resolvedOptions , <nl> - ' resolvedOptions ' ) ; <nl> - % FunctionRemovePrototype ( Intl . v8BreakIterator . prototype . resolvedOptions ) ; <nl> - % SetNativeFlag ( Intl . v8BreakIterator . prototype . resolvedOptions ) ; <nl> - <nl> - <nl> - / * * <nl> - * Returns the subset of the given locale list for which this locale list <nl> - * has a matching ( possibly fallback ) locale . Locales appear in the same <nl> - * order in the returned list as in the input list . <nl> - * Options are optional parameter . <nl> - * / <nl> - % SetProperty ( Intl . v8BreakIterator , ' supportedLocalesOf ' , function ( locales ) { <nl> - if ( % _IsConstructCall ( ) ) { <nl> - throw new $ TypeError ( ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR ) ; <nl> - } <nl> - <nl> - return supportedLocalesOf ( ' breakiterator ' , locales , arguments [ 1 ] ) ; <nl> - } , <nl> - DONT_ENUM <nl> - ) ; <nl> - % FunctionSetName ( Intl . v8BreakIterator . supportedLocalesOf , ' supportedLocalesOf ' ) ; <nl> - % FunctionRemovePrototype ( Intl . v8BreakIterator . supportedLocalesOf ) ; <nl> - % SetNativeFlag ( Intl . v8BreakIterator . supportedLocalesOf ) ; <nl> - <nl> - <nl> - / * * <nl> - * Adopts text to segment using the iterator . Old text , if present , <nl> - * gets discarded . <nl> - * / <nl> - function adoptText ( iterator , text ) { <nl> - % BreakIteratorAdoptText ( iterator . iterator , $ String ( text ) ) ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Returns index of the first break in the string and moves current pointer . <nl> - * / <nl> - function first ( iterator ) { <nl> - return % BreakIteratorFirst ( iterator . iterator ) ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Returns the index of the next break and moves the pointer . <nl> - * / <nl> - function next ( iterator ) { <nl> - return % BreakIteratorNext ( iterator . iterator ) ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Returns index of the current break . <nl> - * / <nl> - function current ( iterator ) { <nl> - return % BreakIteratorCurrent ( iterator . iterator ) ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Returns type of the current break . <nl> - * / <nl> - function breakType ( iterator ) { <nl> - return % BreakIteratorBreakType ( iterator . iterator ) ; <nl> - } <nl> - <nl> - <nl> - addBoundMethod ( Intl . v8BreakIterator , ' adoptText ' , adoptText , 1 ) ; <nl> - addBoundMethod ( Intl . v8BreakIterator , ' first ' , first , 0 ) ; <nl> - addBoundMethod ( Intl . v8BreakIterator , ' next ' , next , 0 ) ; <nl> - addBoundMethod ( Intl . v8BreakIterator , ' current ' , current , 0 ) ; <nl> - addBoundMethod ( Intl . v8BreakIterator , ' breakType ' , breakType , 0 ) ; <nl> - <nl> - / / Save references to Intl objects and methods we use , for added security . <nl> - var savedObjects = { <nl> - ' collator ' : Intl . Collator , <nl> - ' numberformat ' : Intl . NumberFormat , <nl> - ' dateformatall ' : Intl . DateTimeFormat , <nl> - ' dateformatdate ' : Intl . DateTimeFormat , <nl> - ' dateformattime ' : Intl . DateTimeFormat <nl> - } ; <nl> - <nl> - <nl> - / / Default ( created with undefined locales and options parameters ) collator , <nl> - / / number and date format instances . They ' ll be created as needed . <nl> - var defaultObjects = { <nl> - ' collator ' : undefined , <nl> - ' numberformat ' : undefined , <nl> - ' dateformatall ' : undefined , <nl> - ' dateformatdate ' : undefined , <nl> - ' dateformattime ' : undefined , <nl> - } ; <nl> - <nl> - <nl> - / * * <nl> - * Returns cached or newly created instance of a given service . <nl> - * We cache only default instances ( where no locales or options are provided ) . <nl> - * / <nl> - function cachedOrNewService ( service , locales , options , defaults ) { <nl> - var useOptions = ( defaults = = = undefined ) ? options : defaults ; <nl> - if ( locales = = = undefined & & options = = = undefined ) { <nl> - if ( defaultObjects [ service ] = = = undefined ) { <nl> - defaultObjects [ service ] = new savedObjects [ service ] ( locales , useOptions ) ; <nl> - } <nl> - return defaultObjects [ service ] ; <nl> - } <nl> - return new savedObjects [ service ] ( locales , useOptions ) ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Compares this and that , and returns less than 0 , 0 or greater than 0 value . <nl> - * Overrides the built - in method . <nl> - * / <nl> - $ Object . defineProperty ( $ String . prototype , ' localeCompare ' , { <nl> - value : function ( that ) { <nl> - if ( % _IsConstructCall ( ) ) { <nl> - throw new $ TypeError ( ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR ) ; <nl> - } <nl> - <nl> - if ( this = = = undefined | | this = = = null ) { <nl> - throw new $ TypeError ( ' Method invoked on undefined or null value . ' ) ; <nl> - } <nl> - <nl> - var locales = arguments [ 1 ] ; <nl> - var options = arguments [ 2 ] ; <nl> - var collator = cachedOrNewService ( ' collator ' , locales , options ) ; <nl> - return compare ( collator , this , that ) ; <nl> - } , <nl> - writable : true , <nl> - configurable : true , <nl> - enumerable : false <nl> - } ) ; <nl> - % FunctionSetName ( $ String . prototype . localeCompare , ' localeCompare ' ) ; <nl> - % FunctionRemovePrototype ( $ String . prototype . localeCompare ) ; <nl> - % SetNativeFlag ( $ String . prototype . localeCompare ) ; <nl> - <nl> - <nl> - / * * <nl> - * Formats a Number object ( this ) using locale and options values . <nl> - * If locale or options are omitted , defaults are used . <nl> - * / <nl> - $ Object . defineProperty ( $ Number . prototype , ' toLocaleString ' , { <nl> - value : function ( ) { <nl> - if ( % _IsConstructCall ( ) ) { <nl> - throw new $ TypeError ( ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR ) ; <nl> - } <nl> - <nl> - if ( ! ( this instanceof $ Number ) & & typeof ( this ) ! = = ' number ' ) { <nl> - throw new $ TypeError ( ' Method invoked on an object that is not Number . ' ) ; <nl> - } <nl> - <nl> - var locales = arguments [ 0 ] ; <nl> - var options = arguments [ 1 ] ; <nl> - var numberFormat = cachedOrNewService ( ' numberformat ' , locales , options ) ; <nl> - return formatNumber ( numberFormat , this ) ; <nl> - } , <nl> - writable : true , <nl> - configurable : true , <nl> - enumerable : false <nl> - } ) ; <nl> - % FunctionSetName ( $ Number . prototype . toLocaleString , ' toLocaleString ' ) ; <nl> - % FunctionRemovePrototype ( $ Number . prototype . toLocaleString ) ; <nl> - % SetNativeFlag ( $ Number . prototype . toLocaleString ) ; <nl> - <nl> - <nl> - / * * <nl> - * Returns actual formatted date or fails if date parameter is invalid . <nl> - * / <nl> - function toLocaleDateTime ( date , locales , options , required , defaults , service ) { <nl> - if ( ! ( date instanceof $ Date ) ) { <nl> - throw new $ TypeError ( ' Method invoked on an object that is not Date . ' ) ; <nl> - } <nl> - <nl> - if ( $ isNaN ( date ) ) { <nl> - return ' Invalid Date ' ; <nl> - } <nl> - <nl> - var internalOptions = toDateTimeOptions ( options , required , defaults ) ; <nl> - <nl> - var dateFormat = <nl> - cachedOrNewService ( service , locales , options , internalOptions ) ; <nl> - <nl> - return formatDate ( dateFormat , date ) ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Formats a Date object ( this ) using locale and options values . <nl> - * If locale or options are omitted , defaults are used - both date and time are <nl> - * present in the output . <nl> - * / <nl> - $ Object . defineProperty ( $ Date . prototype , ' toLocaleString ' , { <nl> - value : function ( ) { <nl> - if ( % _IsConstructCall ( ) ) { <nl> - throw new $ TypeError ( ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR ) ; <nl> - } <nl> - <nl> - var locales = arguments [ 0 ] ; <nl> - var options = arguments [ 1 ] ; <nl> - return toLocaleDateTime ( <nl> - this , locales , options , ' any ' , ' all ' , ' dateformatall ' ) ; <nl> - } , <nl> - writable : true , <nl> - configurable : true , <nl> - enumerable : false <nl> - } ) ; <nl> - % FunctionSetName ( $ Date . prototype . toLocaleString , ' toLocaleString ' ) ; <nl> - % FunctionRemovePrototype ( $ Date . prototype . toLocaleString ) ; <nl> - % SetNativeFlag ( $ Date . prototype . toLocaleString ) ; <nl> - <nl> - <nl> - / * * <nl> - * Formats a Date object ( this ) using locale and options values . <nl> - * If locale or options are omitted , defaults are used - only date is present <nl> - * in the output . <nl> - * / <nl> - $ Object . defineProperty ( $ Date . prototype , ' toLocaleDateString ' , { <nl> - value : function ( ) { <nl> - if ( % _IsConstructCall ( ) ) { <nl> - throw new $ TypeError ( ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR ) ; <nl> - } <nl> - <nl> - var locales = arguments [ 0 ] ; <nl> - var options = arguments [ 1 ] ; <nl> - return toLocaleDateTime ( <nl> - this , locales , options , ' date ' , ' date ' , ' dateformatdate ' ) ; <nl> - } , <nl> - writable : true , <nl> - configurable : true , <nl> - enumerable : false <nl> - } ) ; <nl> - % FunctionSetName ( $ Date . prototype . toLocaleDateString , ' toLocaleDateString ' ) ; <nl> - % FunctionRemovePrototype ( $ Date . prototype . toLocaleDateString ) ; <nl> - % SetNativeFlag ( $ Date . prototype . toLocaleDateString ) ; <nl> - <nl> - <nl> - / * * <nl> - * Formats a Date object ( this ) using locale and options values . <nl> - * If locale or options are omitted , defaults are used - only time is present <nl> - * in the output . <nl> - * / <nl> - $ Object . defineProperty ( $ Date . prototype , ' toLocaleTimeString ' , { <nl> - value : function ( ) { <nl> - if ( % _IsConstructCall ( ) ) { <nl> - throw new $ TypeError ( ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR ) ; <nl> - } <nl> - <nl> - var locales = arguments [ 0 ] ; <nl> - var options = arguments [ 1 ] ; <nl> - return toLocaleDateTime ( <nl> - this , locales , options , ' time ' , ' time ' , ' dateformattime ' ) ; <nl> - } , <nl> - writable : true , <nl> - configurable : true , <nl> - enumerable : false <nl> - } ) ; <nl> - % FunctionSetName ( $ Date . prototype . toLocaleTimeString , ' toLocaleTimeString ' ) ; <nl> - % FunctionRemovePrototype ( $ Date . prototype . toLocaleTimeString ) ; <nl> - % SetNativeFlag ( $ Date . prototype . toLocaleTimeString ) ; <nl> - <nl> - return Intl ; <nl> - } ( ) ) } ) ; <nl> mmm a / src / mksnapshot . cc <nl> ppp b / src / mksnapshot . cc <nl> int main ( int argc , char * * argv ) { <nl> / / By default , log code create information in the snapshot . <nl> i : : FLAG_log_code = true ; <nl> <nl> + / / Disable the i18n extension , as it doesn ' t support being snapshotted yet . <nl> + i : : FLAG_enable_i18n = false ; <nl> + <nl> / / Print the usage if an error occurs when parsing the command line <nl> / / flags or if the help flag is set . <nl> int result = i : : FlagList : : SetFlagsFromCommandLine ( & argc , argv , true ) ; <nl> mmm a / src / natives . h <nl> ppp b / src / natives . h <nl> typedef bool ( * NativeSourceCallback ) ( Vector < const char > name , <nl> int index ) ; <nl> <nl> enum NativeType { <nl> - CORE , EXPERIMENTAL , D8 , TEST <nl> + CORE , EXPERIMENTAL , D8 , TEST , I18N <nl> } ; <nl> <nl> template < NativeType type > <nl> class NativesCollection { <nl> <nl> typedef NativesCollection < CORE > Natives ; <nl> typedef NativesCollection < EXPERIMENTAL > ExperimentalNatives ; <nl> + typedef NativesCollection < I18N > I18NNatives ; <nl> <nl> } } / / namespace v8 : : internal <nl> <nl> mmm a / test / cctest / test - heap . cc <nl> ppp b / test / cctest / test - heap . cc <nl> TEST ( Regress169209 ) { <nl> i : : FLAG_allow_natives_syntax = true ; <nl> i : : FLAG_flush_code_incrementally = true ; <nl> <nl> + / / Disable loading the i18n extension which breaks the assumptions of this <nl> + / / test about the heap layout . <nl> + i : : FLAG_enable_i18n = false ; <nl> + <nl> CcTest : : InitializeVM ( ) ; <nl> Isolate * isolate = Isolate : : Current ( ) ; <nl> Heap * heap = isolate - > heap ( ) ; <nl> mmm a / test / mjsunit / debug - script . js <nl> ppp b / test / mjsunit / debug - script . js <nl> for ( i = 0 ; i < scripts . length ; i + + ) { <nl> } <nl> <nl> / / This has to be updated if the number of native scripts change . <nl> - assertTrue ( named_native_count = = 16 | | named_native_count = = 17 ) ; <nl> - / / Only the ' gc ' extension is loaded . <nl> - assertEquals ( 1 , extension_count ) ; <nl> + assertEquals ( 16 , named_native_count ) ; <nl> + / / Only the ' gc ' and ( depending on flags ) the ' i18n ' extensions are loaded . <nl> + assertTrue ( extension_count = = 1 | | extension_count = = 2 ) ; <nl> / / This script and mjsunit . js has been loaded . If using d8 , d8 loads <nl> / / a normal script during startup too . <nl> assertTrue ( normal_count = = 2 | | normal_count = = 3 ) ; <nl> mmm a / tools / gyp / v8 . gyp <nl> ppp b / tools / gyp / v8 . gyp <nl> <nl> ] , <nl> } , <nl> } ] , <nl> + [ ' v8_enable_i18n_support = = 1 ' , { <nl> + ' sources ' : [ <nl> + ' < ( SHARED_INTERMEDIATE_DIR ) / i18n - libraries . cc ' , <nl> + ] , <nl> + } ] , <nl> ] , <nl> ' dependencies ' : [ <nl> ' v8_base . < ( v8_target_arch ) ' , <nl> <nl> ' V8_SHARED ' , <nl> ] , <nl> } ] , <nl> + [ ' v8_enable_i18n_support = = 1 ' , { <nl> + ' sources ' : [ <nl> + ' < ( SHARED_INTERMEDIATE_DIR ) / i18n - libraries . cc ' , <nl> + ] , <nl> + } ] , <nl> ] <nl> } , <nl> { <nl> <nl> ] <nl> } ] , <nl> [ ' v8_enable_i18n_support = = 1 ' , { <nl> + ' sources ' : [ <nl> + ' . . / . . / src / extensions / i18n / i18n - extension . cc ' , <nl> + ' . . / . . / src / extensions / i18n / i18n - extension . h ' , <nl> + ] , <nl> ' dependencies ' : [ <nl> ' < ( DEPTH ) / third_party / icu / icu . gyp : icui18n ' , <nl> ' < ( DEPTH ) / third_party / icu / icu . gyp : icuuc ' , <nl> <nl> ' toolsets ' : [ ' target ' ] , <nl> } ] , <nl> [ ' v8_enable_i18n_support = = 1 ' , { <nl> - ' variables ' : { <nl> - ' i18n_library_files ' : [ <nl> - ' . . / . . / src / i18n . js ' , <nl> + ' actions ' : [ { <nl> + ' action_name ' : ' js2c_i18n ' , <nl> + ' inputs ' : [ <nl> + ' . . / . . / tools / js2c . py ' , <nl> + ' < @ ( i18n_library_files ) ' , <nl> ] , <nl> - } , <nl> - } , { <nl> - ' variables ' : { <nl> - ' i18n_library_files ' : [ ] , <nl> - } , <nl> + ' outputs ' : [ <nl> + ' < ( SHARED_INTERMEDIATE_DIR ) / i18n - libraries . cc ' , <nl> + ] , <nl> + ' action ' : [ <nl> + ' python ' , <nl> + ' . . / . . / tools / js2c . py ' , <nl> + ' < @ ( _outputs ) ' , <nl> + ' I18N ' , <nl> + ' < ( v8_compress_startup_data ) ' , <nl> + ' < @ ( i18n_library_files ) ' <nl> + ] , <nl> + } ] , <nl> } ] , <nl> ] , <nl> ' variables ' : { <nl> <nl> ' . . / . . / src / harmony - string . js ' , <nl> ' . . / . . / src / harmony - array . js ' , <nl> ] , <nl> + ' i18n_library_files ' : [ <nl> + ' . . / . . / src / extensions / i18n / header . js ' , <nl> + ' . . / . . / src / extensions / i18n / globals . js ' , <nl> + ' . . / . . / src / extensions / i18n / locale . js ' , <nl> + ' . . / . . / src / extensions / i18n / collator . js ' , <nl> + ' . . / . . / src / extensions / i18n / number - format . js ' , <nl> + ' . . / . . / src / extensions / i18n / date - format . js ' , <nl> + ' . . / . . / src / extensions / i18n / break - iterator . js ' , <nl> + ' . . / . . / src / extensions / i18n / i18n - utils . js ' , <nl> + ' . . / . . / src / extensions / i18n / overrides . js ' , <nl> + ' . . / . . / src / extensions / i18n / footer . js ' , <nl> + ] , <nl> } , <nl> ' actions ' : [ <nl> { <nl> <nl> ' inputs ' : [ <nl> ' . . / . . / tools / js2c . py ' , <nl> ' < @ ( library_files ) ' , <nl> - ' < @ ( i18n_library_files ) ' , <nl> ] , <nl> ' outputs ' : [ <nl> ' < ( SHARED_INTERMEDIATE_DIR ) / libraries . cc ' , <nl> <nl> ' < @ ( _outputs ) ' , <nl> ' CORE ' , <nl> ' < ( v8_compress_startup_data ) ' , <nl> - ' < @ ( library_files ) ' , <nl> - ' < @ ( i18n_library_files ) ' , <nl> + ' < @ ( library_files ) ' <nl> ] , <nl> } , <nl> { <nl>
|
Revert " Snapshot i18n Javascript code " and " Fix mjsunit / debug - script after r16298 " .
|
v8/v8
|
caba24c8138bf7b387c1a6125e8e582559689c42
|
2013-08-26T17:00:58Z
|
mmm a / fdbserver / RestoreMaster . actor . h <nl> ppp b / fdbserver / RestoreMaster . actor . h <nl> struct RestoreMasterData : RestoreRoleData , public ReferenceCounted < RestoreMaste <nl> . detail ( " UsedLogFiles " , curLogFiles . size ( ) ) ; <nl> <nl> ASSERT ( prevEndVersion < nextVersion ) ; / / Ensure progress <nl> - if ( vb . size + nextVersionSize < = SERVER_KNOBS - > FASTRESTORE_VERSIONBATCH_MAX_BYTES ) { <nl> + if ( vb . size + nextVersionSize < = SERVER_KNOBS - > FASTRESTORE_VERSIONBATCH_MAX_BYTES | | <nl> + ( vb . size < 1 & & prevEndVersion + 1 = = nextVersion ) ) { <nl> + / / In case the batch size at a single version > FASTRESTORE_VERSIONBATCH_MAX_BYTES , <nl> + / / the version batch should include the single version to avoid false positive in simulation . <nl> + if ( vb . size + nextVersionSize > SERVER_KNOBS - > FASTRESTORE_VERSIONBATCH_MAX_BYTES ) { <nl> + TraceEvent ( g_network - > isSimulated ( ) ? SevWarnAlways : SevError , " FastRestoreBuildVersionBatch " ) <nl> + . detail ( " NextVersion " , nextVersion ) <nl> + . detail ( " PreviousEndVersion " , prevEndVersion ) <nl> + . detail ( " NextVersionIntervalSize " , nextVersionSize ) <nl> + . detail ( " VersionBatchSizeThreshold " , SERVER_KNOBS - > FASTRESTORE_VERSIONBATCH_MAX_BYTES ) <nl> + . detail ( " SuggestedMinimumVersionBatchSizeThreshold " , nextVersionSize * 2 ) ; <nl> + } <nl> / / nextVersion should be included in this batch <nl> vb . size + = nextVersionSize ; <nl> while ( rangeIdx < nextRangeIdx ) { <nl> struct RestoreMasterData : RestoreRoleData , public ReferenceCounted < RestoreMaste <nl> . detail ( " PreviousEndVersion " , prevEndVersion ) <nl> . detail ( " NextVersionIntervalSize " , nextVersionSize ) <nl> . detail ( " VersionBatchSizeThreshold " , SERVER_KNOBS - > FASTRESTORE_VERSIONBATCH_MAX_BYTES ) <nl> - . detail ( " SuggestedMinimumVersionBatchSizeThreshold " , nextVersion ) ; <nl> + . detail ( " SuggestedMinimumVersionBatchSizeThreshold " , nextVersionSize * 2 ) ; <nl> / / Exit restore early if it won ' t succeed <nl> flushAndExit ( FDB_EXIT_ERROR ) ; <nl> } <nl>
|
FastRestore : A single version may be larger than version batch threshold
|
apple/foundationdb
|
75dc34f775660667a47d1e37a9bee811d7a5d8b3
|
2020-01-27T20:17:20Z
|
mmm a / tensorflow / core / kernels / BUILD <nl> ppp b / tensorflow / core / kernels / BUILD <nl> tf_kernel_library ( <nl> " maxpooling_op . h " , <nl> " pooling_ops_3d . h " , <nl> " pooling_ops_common . h " , <nl> - ] , <nl> + ] + if_sycl ( [ " pooling_ops_3d_sycl . h " ] ) , <nl> gpu_srcs = [ <nl> " avgpooling_op . h " , <nl> " avgpooling_op_gpu . cu . cc " , <nl> mmm a / tensorflow / core / kernels / pooling_ops_3d . cc <nl> ppp b / tensorflow / core / kernels / pooling_ops_3d . cc <nl> limitations under the License . <nl> # include " tensorflow / core / kernels / cudnn_pooling_gpu . h " <nl> # include " tensorflow / core / kernels / pooling_ops_3d_gpu . h " <nl> # endif <nl> + <nl> + # ifdef TENSORFLOW_USE_SYCL <nl> + # include " tensorflow / core / kernels / pooling_ops_3d_sycl . h " <nl> + # endif / / TENSORFLOW_USE_SYCL <nl> + <nl> namespace tensorflow { <nl> <nl> typedef Eigen : : ThreadPoolDevice CPUDevice ; <nl> typedef Eigen : : GpuDevice GPUDevice ; <nl> + # ifdef TENSORFLOW_USE_SYCL <nl> + typedef Eigen : : SyclDevice SYCLDevice ; <nl> + # endif / / TENSORFLOW_USE_SYCL <nl> <nl> Pool3dParameters : : Pool3dParameters ( OpKernelContext * context , <nl> const std : : vector < int32 > & ksize , <nl> TensorShape Pool3dParameters : : forward_output_shape ( ) { <nl> { { out_plane , out_height , out_width } } , depth ) ; <nl> } <nl> <nl> - enum PoolingType { MAX , AVG } ; <nl> - <nl> - template < typename Device , typename T , PoolingType Type > <nl> - struct LaunchPoolingOp ; <nl> - <nl> template < typename T > <nl> struct LaunchPoolingOp < CPUDevice , T , AVG > { <nl> static void launch ( OpKernelContext * context , const Tensor & tensor_in , <nl> class Pooling3DOp : public UnaryOp < T > { <nl> TensorFormat data_format_ ; <nl> } ; <nl> <nl> - template < typename Device , typename T > <nl> - struct LaunchMaxPooling3dGradOp ; <nl> - <nl> template < typename T > <nl> struct LaunchMaxPooling3dGradOp < CPUDevice , T > { <nl> static void launch ( OpKernelContext * context , const Tensor & tensor_in , <nl> class MaxPooling3dGradOp : public OpKernel { <nl> TensorFormat data_format_ ; <nl> } ; <nl> <nl> - template < typename Device , typename T > <nl> - struct LaunchAvgPooling3dGradOp ; <nl> - <nl> template < typename T > <nl> struct LaunchAvgPooling3dGradOp < CPUDevice , T > { <nl> static void launch ( OpKernelContext * context , <nl> class AvgPooling3dGradOp : public OpKernel { <nl> TensorFormat data_format_ ; <nl> } ; <nl> <nl> - template < typename Device , typename T > <nl> - struct LaunchMaxPooling3dGradGradOp ; <nl> - <nl> template < typename T > <nl> struct LaunchMaxPooling3dGradGradOp < CPUDevice , T > { <nl> static void launch ( OpKernelContext * context , const Pool3dParameters & params , <nl> TF_CALL_float ( REGISTER_GPU_KERNELS ) TF_CALL_half ( REGISTER_GPU_KERNELS ) <nl> <nl> # endif / / GOOGLE_CUDA <nl> <nl> + # ifdef TENSORFLOW_USE_SYCL <nl> + # define REGISTER_SYCL_KERNELS ( T ) REGISTER_KERNELS ( SYCL , T ) <nl> + TF_CALL_GPU_NUMBER_TYPES_NO_HALF ( REGISTER_SYCL_KERNELS ) <nl> + # undef REGISTER_SYCL_KERNELS <nl> + # endif / / TENSORFLOW_USE_SYCL <nl> + <nl> # undef REGISTER_KERNELS <nl> <nl> } / / namespace tensorflow <nl> mmm a / tensorflow / core / kernels / pooling_ops_3d . h <nl> ppp b / tensorflow / core / kernels / pooling_ops_3d . h <nl> limitations under the License . <nl> <nl> namespace tensorflow { <nl> <nl> + enum PoolingType { MAX , AVG } ; <nl> + <nl> + template < typename Device , typename T , PoolingType Type > <nl> + struct LaunchPoolingOp ; <nl> + <nl> + template < typename Device , typename T > <nl> + struct LaunchAvgPooling3dGradOp ; <nl> + <nl> + template < typename Device , typename T > <nl> + struct LaunchMaxPooling3dGradOp ; <nl> + <nl> + template < typename Device , typename T > <nl> + struct LaunchMaxPooling3dGradGradOp ; <nl> + <nl> / / A helper class to manage sizes and shapes for 3d pooling operations . <nl> struct Pool3dParameters { <nl> / / Updates context - > status if there is an invalid input . <nl> new file mode 100644 <nl> index 0000000000000 . . d8cbc589a1bdd <nl> mmm / dev / null <nl> ppp b / tensorflow / core / kernels / pooling_ops_3d_sycl . h <nl> <nl> + / * Copyright 2017 The TensorFlow Authors . All Rights Reserved . <nl> + <nl> + Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + you may not use this file except in compliance with the License . <nl> + You may obtain a copy of the License at <nl> + <nl> + http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + <nl> + Unless required by applicable law or agreed to in writing , software <nl> + distributed under the License is distributed on an " AS IS " BASIS , <nl> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + See the License for the specific language governing permissions and <nl> + limitations under the License . <nl> + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> + <nl> + # if ! TENSORFLOW_USE_SYCL <nl> + # error This file must only be included when building with SYCL support <nl> + # endif <nl> + <nl> + # ifndef TENSORFLOW_CORE_KERNELS_POOLING_OP_3D_SYCL_H_ <nl> + # define TENSORFLOW_CORE_KERNELS_POOLING_OP_3D_SYCL_H_ <nl> + <nl> + # include " tensorflow / core / kernels / pooling_ops_3d . h " <nl> + <nl> + namespace tensorflow { <nl> + <nl> + typedef Eigen : : SyclDevice SYCLDevice ; <nl> + <nl> + / / Helper struct to contain the various pool parameters used in the SYCL <nl> + / / pooling kernels . Similar to the Pool3dParameters , but with a number of <nl> + / / convenient constructors . <nl> + struct SYCL3DPoolParams { <nl> + SYCL3DPoolParams ( const int depth , const int batch , const int in_planes , <nl> + const int in_rows , const int in_cols , const int out_planes , <nl> + const int out_rows , const int out_cols , <nl> + const std : : array < int64 , 3 > & window , <nl> + const std : : array < int64 , 3 > & stride , <nl> + const std : : array < int64 , 3 > & padding ) <nl> + : depth_ ( depth ) , <nl> + batch_ ( batch ) , <nl> + in_planes_ ( in_planes ) , <nl> + in_rows_ ( in_rows ) , <nl> + in_cols_ ( in_cols ) , <nl> + window_planes_ ( window [ 2 ] ) , <nl> + window_rows_ ( window [ 1 ] ) , <nl> + window_cols_ ( window [ 0 ] ) , <nl> + stride_planes_ ( stride [ 2 ] ) , <nl> + stride_rows_ ( stride [ 1 ] ) , <nl> + stride_cols_ ( stride [ 0 ] ) , <nl> + out_planes_ ( out_planes ) , <nl> + out_rows_ ( out_rows ) , <nl> + out_cols_ ( out_cols ) , <nl> + pad_planes_ ( padding [ 2 ] ) , <nl> + pad_rows_ ( padding [ 1 ] ) , <nl> + pad_cols_ ( padding [ 0 ] ) { } <nl> + <nl> + SYCL3DPoolParams ( const int depth , const int batch , const int in_planes , <nl> + const int in_rows , const int in_cols , <nl> + const std : : array < int64 , 3 > & out_shape , <nl> + const std : : array < int64 , 3 > & window , <nl> + const std : : array < int64 , 3 > & stride , <nl> + const std : : array < int64 , 3 > & padding ) <nl> + : SYCL3DPoolParams ( depth , batch , in_planes , in_rows , in_cols , <nl> + out_shape [ 2 ] , out_shape [ 1 ] , out_shape [ 0 ] , window , <nl> + stride , padding ) { } <nl> + <nl> + SYCL3DPoolParams ( const Pool3dParameters & params ) <nl> + : depth_ ( params . depth ) , <nl> + batch_ ( params . tensor_in_batch ) , <nl> + in_planes_ ( params . tensor_in_planes ) , <nl> + in_rows_ ( params . tensor_in_rows ) , <nl> + in_cols_ ( params . tensor_in_cols ) , <nl> + window_planes_ ( params . window_planes ) , <nl> + window_rows_ ( params . window_rows ) , <nl> + window_cols_ ( params . window_cols ) , <nl> + stride_planes_ ( params . plane_stride ) , <nl> + stride_rows_ ( params . row_stride ) , <nl> + stride_cols_ ( params . col_stride ) , <nl> + out_planes_ ( params . out_plane ) , <nl> + out_rows_ ( params . out_height ) , <nl> + out_cols_ ( params . out_width ) , <nl> + pad_planes_ ( params . pad_planes ) , <nl> + pad_rows_ ( params . pad_rows ) , <nl> + pad_cols_ ( params . pad_cols ) { } <nl> + <nl> + const int depth_ ; <nl> + const int batch_ ; <nl> + const int in_planes_ ; <nl> + const int in_rows_ ; <nl> + const int in_cols_ ; <nl> + <nl> + const int window_planes_ ; <nl> + const int window_rows_ ; <nl> + const int window_cols_ ; <nl> + <nl> + const int stride_planes_ ; <nl> + const int stride_rows_ ; <nl> + const int stride_cols_ ; <nl> + <nl> + const int out_planes_ ; <nl> + const int out_rows_ ; <nl> + const int out_cols_ ; <nl> + <nl> + const int pad_planes_ ; <nl> + const int pad_rows_ ; <nl> + const int pad_cols_ ; <nl> + } ; <nl> + / / MaxPool3d SYCL kernel . Expects the number of threads to be equal to the <nl> + / / number of elements in the output tensor . <nl> + / / <nl> + / / For each output element , find the corresponding input window and run over <nl> + / / all values in the window to find the maximum value . This value is then <nl> + / / copied into that output element . <nl> + template < typename T > <nl> + class MaxPool3DSYCL { <nl> + using write_accessor = <nl> + cl : : sycl : : accessor < uint8_t , 1 , cl : : sycl : : access : : mode : : write , <nl> + cl : : sycl : : access : : target : : global_buffer > ; <nl> + using read_accessor = <nl> + cl : : sycl : : accessor < uint8_t , 1 , cl : : sycl : : access : : mode : : read , <nl> + cl : : sycl : : access : : target : : global_buffer > ; <nl> + <nl> + public : <nl> + MaxPool3DSYCL ( const int depth , const int batch , const int in_planes , <nl> + const int in_rows , const int in_cols , const int out_planes , <nl> + const int out_rows , const int out_cols , <nl> + const std : : array < int64 , 3 > & window , <nl> + const std : : array < int64 , 3 > & stride , <nl> + const std : : array < int64 , 3 > & padding , <nl> + const read_accessor input_accessor , <nl> + write_accessor output_accessor ) <nl> + : p_ ( depth , batch , in_planes , in_rows , in_cols , out_planes , out_rows , <nl> + out_cols , window , stride , padding ) , <nl> + input_accessor_ ( input_accessor ) , <nl> + output_accessor_ ( output_accessor ) { } <nl> + void operator ( ) ( cl : : sycl : : item < 1 > item ) { <nl> + T * input_data = ConvertToActualTypeSycl ( T , input_accessor_ ) ; <nl> + T * output_data = ConvertToActualTypeSycl ( T , output_accessor_ ) ; <nl> + <nl> + int index = item . get_linear_id ( ) ; <nl> + int n = index ; <nl> + int d = n % p_ . depth_ ; <nl> + n / = p_ . depth_ ; <nl> + int cstart = ( n % p_ . out_cols_ ) * p_ . stride_cols_ - p_ . pad_cols_ ; <nl> + int cend = std : : min ( cstart + p_ . window_cols_ , p_ . in_cols_ ) ; <nl> + cstart = std : : max ( cstart , 0 ) ; <nl> + n / = p_ . out_cols_ ; <nl> + int rstart = ( n % p_ . out_rows_ ) * p_ . stride_rows_ - p_ . pad_rows_ ; <nl> + int rend = std : : min ( rstart + p_ . window_rows_ , p_ . in_rows_ ) ; <nl> + rstart = std : : max ( rstart , 0 ) ; <nl> + n / = p_ . out_rows_ ; <nl> + int pstart = ( n % p_ . out_planes_ ) * p_ . stride_planes_ - p_ . pad_planes_ ; <nl> + int pend = std : : min ( pstart + p_ . window_planes_ , p_ . in_planes_ ) ; <nl> + pstart = std : : max ( pstart , 0 ) ; <nl> + n / = p_ . out_planes_ ; <nl> + T maxval = Eigen : : NumTraits < T > : : lowest ( ) ; <nl> + const T * input_data_n = <nl> + input_data + n * p_ . in_planes_ * p_ . in_cols_ * p_ . in_rows_ * p_ . depth_ ; <nl> + for ( int p = pstart ; p < pend ; + + p ) { <nl> + for ( int r = rstart ; r < rend ; + + r ) { <nl> + for ( int c = cstart ; c < cend ; + + c ) { <nl> + int idx = ( ( p * p_ . in_rows_ + r ) * p_ . in_cols_ + c ) * p_ . depth_ + d ; <nl> + if ( input_data_n [ idx ] > maxval ) { <nl> + maxval = input_data_n [ idx ] ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + output_data [ index ] = maxval ; <nl> + } <nl> + <nl> + private : <nl> + const SYCL3DPoolParams p_ ; <nl> + const read_accessor input_accessor_ ; <nl> + write_accessor output_accessor_ ; <nl> + } ; <nl> + template < typename T > <nl> + struct LaunchPoolingOp < SYCLDevice , T , MAX > { <nl> + static void launch ( OpKernelContext * context , const Tensor & tensor_in , <nl> + const std : : array < int64 , 3 > & window , <nl> + const std : : array < int64 , 3 > & stride , <nl> + const std : : array < int64 , 3 > & padding , <nl> + TensorFormat data_format , Padding padding_type , <nl> + Tensor * output ) { <nl> + const SYCLDevice & device = context - > eigen_device < SYCLDevice > ( ) ; <nl> + const int out_planes = GetTensorDim ( * output , data_format , ' 0 ' ) ; <nl> + const int out_rows = GetTensorDim ( * output , data_format , ' 1 ' ) ; <nl> + const int out_cols = GetTensorDim ( * output , data_format , ' 2 ' ) ; <nl> + const int batch = GetTensorDim ( tensor_in , data_format , ' N ' ) ; <nl> + const int in_planes = GetTensorDim ( tensor_in , data_format , ' 0 ' ) ; <nl> + const int in_rows = GetTensorDim ( tensor_in , data_format , ' 1 ' ) ; <nl> + const int in_cols = GetTensorDim ( tensor_in , data_format , ' 2 ' ) ; <nl> + const int depth = GetTensorDim ( tensor_in , data_format , ' C ' ) ; <nl> + <nl> + const int num_threads = output - > NumElements ( ) ; <nl> + <nl> + auto input_buffer = <nl> + device . get_sycl_buffer ( tensor_in . template flat < T > ( ) . data ( ) ) ; <nl> + auto output_buffer = <nl> + device . get_sycl_buffer ( output - > template flat < T > ( ) . data ( ) ) ; <nl> + <nl> + device . sycl_queue ( ) . submit ( [ & ] ( cl : : sycl : : handler & cgh ) { <nl> + auto input_access = <nl> + input_buffer . template get_access < cl : : sycl : : access : : mode : : read > ( cgh ) ; <nl> + auto output_access = <nl> + output_buffer . template get_access < cl : : sycl : : access : : mode : : write > ( cgh ) ; <nl> + MaxPool3DSYCL < T > max_pool ( depth , batch , in_planes , in_rows , in_cols , <nl> + out_planes , out_rows , out_cols , window , stride , <nl> + padding , input_access , output_access ) ; <nl> + <nl> + cgh . parallel_for ( cl : : sycl : : range < 1 > ( num_threads ) , max_pool ) ; <nl> + } ) ; <nl> + } <nl> + } ; <nl> + / / MaxPool3DGrad SYCL kernel . Expects the number of threads to be equal to the <nl> + / / number of elements in the output backprop tenor ( i . e . the number of elements <nl> + / / in the input data tensor ) . <nl> + / / <nl> + / / For each output backprop element we compute the possible window of values in <nl> + / / the input backprop tensor which might contribute to this element . Then for <nl> + / / each error in this window , compute the corresponding input window which was <nl> + / / pooled into that element in the output . Walk through this input window to <nl> + / / determine whether the input value is the first maximum value , and so the <nl> + / / error should be propagated back to the corresponding backprop element . <nl> + template < typename T > <nl> + class MaxPool3DGradSYCL { <nl> + using write_accessor = <nl> + cl : : sycl : : accessor < uint8_t , 1 , cl : : sycl : : access : : mode : : write , <nl> + cl : : sycl : : access : : target : : global_buffer > ; <nl> + using read_accessor = <nl> + cl : : sycl : : accessor < uint8_t , 1 , cl : : sycl : : access : : mode : : read , <nl> + cl : : sycl : : access : : target : : global_buffer > ; <nl> + <nl> + public : <nl> + MaxPool3DGradSYCL ( const int depth , const int batch , const int in_planes , <nl> + const int in_rows , const int in_cols , <nl> + const std : : array < int64 , 3 > & output_shape , <nl> + const std : : array < int64 , 3 > & window , <nl> + const std : : array < int64 , 3 > & stride , <nl> + const std : : array < int64 , 3 > & padding , <nl> + const read_accessor input_data_accessor , <nl> + const read_accessor output_data_accessor , <nl> + const read_accessor input_backprop_accessor , <nl> + write_accessor output_backprop_accessor ) <nl> + : p_ ( depth , batch , in_planes , in_rows , in_cols , output_shape , window , <nl> + stride , padding ) , <nl> + input_data_accessor_ ( input_data_accessor ) , <nl> + output_data_accessor_ ( output_data_accessor ) , <nl> + input_backprop_accessor_ ( input_backprop_accessor ) , <nl> + output_backprop_accessor_ ( output_backprop_accessor ) { } <nl> + void operator ( ) ( cl : : sycl : : item < 1 > item ) { <nl> + T * input_data = ConvertToActualTypeSycl ( T , input_data_accessor_ ) ; <nl> + T * output_data = ConvertToActualTypeSycl ( T , output_data_accessor_ ) ; <nl> + T * input_backprop = ConvertToActualTypeSycl ( T , input_backprop_accessor_ ) ; <nl> + T * output_backprop = ConvertToActualTypeSycl ( T , output_backprop_accessor_ ) ; <nl> + <nl> + const int index = item . get_linear_id ( ) ; <nl> + T output_value = 0 ; <nl> + int n = index ; <nl> + const int d = n % p_ . depth_ ; <nl> + n / = p_ . depth_ ; <nl> + const int c = ( n % p_ . in_cols_ ) + p_ . pad_cols_ ; <nl> + const int poolcstart = <nl> + ( c < p_ . window_cols_ ) ? 0 : ( c - p_ . window_cols_ ) / p_ . stride_cols_ + 1 ; <nl> + const int poolcend = std : : min ( c / p_ . stride_cols_ + 1 , p_ . out_cols_ ) ; <nl> + n / = p_ . in_cols_ ; <nl> + const int r = ( n % p_ . in_rows_ ) + p_ . pad_rows_ ; <nl> + const int poolrstart = <nl> + ( r < p_ . window_rows_ ) ? 0 : ( r - p_ . window_rows_ ) / p_ . stride_rows_ + 1 ; <nl> + const int poolrend = std : : min ( r / p_ . stride_rows_ + 1 , p_ . out_rows_ ) ; <nl> + n / = p_ . in_rows_ ; <nl> + const int p = ( n % p_ . in_planes_ ) + p_ . pad_planes_ ; <nl> + const int poolpstart = <nl> + ( p < p_ . window_planes_ ) <nl> + ? 0 <nl> + : ( p - p_ . window_planes_ ) / p_ . stride_planes_ + 1 ; <nl> + const int poolpend = std : : min ( p / p_ . stride_planes_ + 1 , p_ . out_planes_ ) ; <nl> + n / = p_ . in_planes_ ; <nl> + const int index_no_n = <nl> + index - n * p_ . in_planes_ * p_ . in_cols_ * p_ . in_rows_ * p_ . depth_ ; <nl> + <nl> + const T * input_data_n = <nl> + input_data + n * p_ . in_planes_ * p_ . in_cols_ * p_ . in_rows_ * p_ . depth_ ; <nl> + const T * output_data_n = <nl> + output_data + <nl> + n * p_ . out_planes_ * p_ . out_cols_ * p_ . out_rows_ * p_ . depth_ ; <nl> + const T * input_backprop_n = <nl> + input_backprop + <nl> + n * p_ . out_planes_ * p_ . out_cols_ * p_ . out_rows_ * p_ . depth_ ; <nl> + for ( int poolp = poolpstart ; poolp < poolpend ; + + poolp ) { <nl> + int pstart = poolp * p_ . stride_planes_ - p_ . pad_planes_ ; <nl> + const int pend = std : : min ( pstart + p_ . window_planes_ , p_ . in_planes_ ) ; <nl> + pstart = std : : max ( pstart , 0 ) ; <nl> + <nl> + for ( int poolr = poolrstart ; poolr < poolrend ; + + poolr ) { <nl> + int rstart = poolr * p_ . stride_rows_ - p_ . pad_rows_ ; <nl> + const int rend = std : : min ( rstart + p_ . window_rows_ , p_ . in_rows_ ) ; <nl> + rstart = std : : max ( rstart , 0 ) ; <nl> + <nl> + for ( int poolc = poolcstart ; poolc < poolcend ; + + poolc ) { <nl> + int cstart = poolc * p_ . stride_cols_ - p_ . pad_cols_ ; <nl> + const int cend = std : : min ( cstart + p_ . window_cols_ , p_ . in_cols_ ) ; <nl> + cstart = std : : max ( cstart , 0 ) ; <nl> + <nl> + const int output_data_idx = <nl> + ( ( poolp * p_ . out_rows_ + poolr ) * p_ . out_cols_ + poolc ) * <nl> + p_ . depth_ + <nl> + d ; <nl> + bool should_continue = true ; <nl> + bool is_max = ( input_data [ index ] = = output_data_n [ output_data_idx ] ) ; <nl> + for ( int win_p = pstart ; win_p < pend & & should_continue ; + + win_p ) { <nl> + for ( int win_r = rstart ; win_r < rend & & should_continue ; + + win_r ) { <nl> + for ( int win_c = cstart ; win_c < cend & & should_continue ; <nl> + + + win_c ) { <nl> + const int input_data_idx = <nl> + ( ( win_p * p_ . in_rows_ + win_r ) * p_ . in_cols_ + win_c ) * <nl> + p_ . depth_ + <nl> + d ; <nl> + if ( input_data_idx = = index_no_n ) { <nl> + should_continue = false ; <nl> + } else if ( input_data_n [ input_data_idx ] = = <nl> + output_data_n [ output_data_idx ] ) { <nl> + should_continue = false ; <nl> + is_max = false ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + if ( is_max ) { <nl> + output_value + = input_backprop_n [ output_data_idx ] ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + output_backprop [ index ] = output_value ; <nl> + } <nl> + <nl> + private : <nl> + const SYCL3DPoolParams p_ ; <nl> + <nl> + const read_accessor input_data_accessor_ ; <nl> + const read_accessor output_data_accessor_ ; <nl> + const read_accessor input_backprop_accessor_ ; <nl> + write_accessor output_backprop_accessor_ ; <nl> + } ; <nl> + template < typename T > <nl> + struct LaunchMaxPooling3dGradOp < SYCLDevice , T > { <nl> + static void launch ( OpKernelContext * context , const Tensor & tensor_in , <nl> + const Tensor & tensor_out , const Tensor & out_backprop , <nl> + const std : : array < int64 , 3 > & window , <nl> + const std : : array < int64 , 3 > & stride , <nl> + const std : : array < int64 , 3 > & out , <nl> + const std : : array < int64 , 3 > & padding , <nl> + TensorFormat data_format , Tensor * output ) { <nl> + const SYCLDevice & device = context - > eigen_device < SYCLDevice > ( ) ; <nl> + const int batch = GetTensorDim ( tensor_in , data_format , ' N ' ) ; <nl> + const int in_planes = GetTensorDim ( tensor_in , data_format , ' 0 ' ) ; <nl> + const int in_rows = GetTensorDim ( tensor_in , data_format , ' 1 ' ) ; <nl> + const int in_cols = GetTensorDim ( tensor_in , data_format , ' 2 ' ) ; <nl> + const int depth = GetTensorDim ( tensor_in , data_format , ' C ' ) ; <nl> + <nl> + const int output_size = output - > NumElements ( ) ; <nl> + <nl> + auto input_data_buffer = <nl> + device . get_sycl_buffer ( tensor_in . template flat < T > ( ) . data ( ) ) ; <nl> + auto output_data_buffer = <nl> + device . get_sycl_buffer ( tensor_out . template flat < T > ( ) . data ( ) ) ; <nl> + auto input_backprop_buffer = <nl> + device . get_sycl_buffer ( out_backprop . template flat < T > ( ) . data ( ) ) ; <nl> + auto output_backprop_buffer = <nl> + device . get_sycl_buffer ( output - > template flat < T > ( ) . data ( ) ) ; <nl> + <nl> + device . sycl_queue ( ) . submit ( [ & ] ( cl : : sycl : : handler & cgh ) { <nl> + auto input_data_access = <nl> + input_data_buffer . template get_access < cl : : sycl : : access : : mode : : read > ( <nl> + cgh ) ; <nl> + auto output_data_access = <nl> + output_data_buffer . template get_access < cl : : sycl : : access : : mode : : read > ( <nl> + cgh ) ; <nl> + auto input_backprop_access = <nl> + input_backprop_buffer <nl> + . template get_access < cl : : sycl : : access : : mode : : read > ( cgh ) ; <nl> + auto output_backprop_access = <nl> + output_backprop_buffer <nl> + . template get_access < cl : : sycl : : access : : mode : : write > ( cgh ) ; <nl> + MaxPool3DGradSYCL < T > max_pool ( <nl> + depth , batch , in_planes , in_rows , in_cols , out , window , stride , <nl> + padding , input_data_access , output_data_access , input_backprop_access , <nl> + output_backprop_access ) ; <nl> + <nl> + cgh . parallel_for ( cl : : sycl : : range < 1 > ( output_size ) , max_pool ) ; <nl> + } ) ; <nl> + } <nl> + } ; <nl> + / / MaxPool3DGradGrad SYCL kernel . Expects the number of threads to be equal to <nl> + / / the number of elements in the output backprop tensor , i . e . the number of <nl> + / / elements in the output tensor . <nl> + / / <nl> + / / For each element in the output backprop tensor , find the corresponding input <nl> + / / window , and compare the input and output data to find the index of the <nl> + / / maximum value in the input tensor . This is then the index of the gradient to <nl> + / / pass through to the output backprop tensor . <nl> + template < typename T > <nl> + class MaxPool3DGradGradSYCL { <nl> + using write_accessor = <nl> + cl : : sycl : : accessor < uint8_t , 1 , cl : : sycl : : access : : mode : : write , <nl> + cl : : sycl : : access : : target : : global_buffer > ; <nl> + using read_accessor = <nl> + cl : : sycl : : accessor < uint8_t , 1 , cl : : sycl : : access : : mode : : read , <nl> + cl : : sycl : : access : : target : : global_buffer > ; <nl> + <nl> + public : <nl> + MaxPool3DGradGradSYCL ( const Pool3dParameters & params , <nl> + const read_accessor input_data_accessor , <nl> + const read_accessor output_data_accessor , <nl> + const read_accessor input_backprop_accessor , <nl> + write_accessor output_backprop_accessor ) <nl> + : p_ ( params ) , <nl> + input_data_accessor_ ( input_data_accessor ) , <nl> + output_data_accessor_ ( output_data_accessor ) , <nl> + input_backprop_accessor_ ( input_backprop_accessor ) , <nl> + output_backprop_accessor_ ( output_backprop_accessor ) { } <nl> + void operator ( ) ( cl : : sycl : : item < 1 > item ) { <nl> + T * input_data = ConvertToActualTypeSycl ( T , input_data_accessor_ ) ; <nl> + T * output_data = ConvertToActualTypeSycl ( T , output_data_accessor_ ) ; <nl> + T * input_backprop = ConvertToActualTypeSycl ( T , input_backprop_accessor_ ) ; <nl> + T * output_backprop = ConvertToActualTypeSycl ( T , output_backprop_accessor_ ) ; <nl> + <nl> + int index = item . get_linear_id ( ) ; <nl> + int n = index ; <nl> + int d = n % p_ . depth_ ; <nl> + n / = p_ . depth_ ; <nl> + int cstart = ( n % p_ . out_cols_ ) * p_ . stride_cols_ - p_ . pad_cols_ ; <nl> + int cend = std : : min ( cstart + p_ . window_cols_ , p_ . in_cols_ ) ; <nl> + cstart = std : : max ( cstart , 0 ) ; <nl> + n / = p_ . out_cols_ ; <nl> + int rstart = ( n % p_ . out_rows_ ) * p_ . stride_rows_ - p_ . pad_rows_ ; <nl> + int rend = std : : min ( rstart + p_ . window_rows_ , p_ . in_rows_ ) ; <nl> + rstart = std : : max ( rstart , 0 ) ; <nl> + n / = p_ . out_rows_ ; <nl> + int pstart = ( n % p_ . out_planes_ ) * p_ . stride_planes_ - p_ . pad_planes_ ; <nl> + int pend = std : : min ( pstart + p_ . window_planes_ , p_ . in_planes_ ) ; <nl> + pstart = std : : max ( pstart , 0 ) ; <nl> + n / = p_ . out_planes_ ; <nl> + int maxidx = - 1 ; <nl> + bool should_stop = false ; <nl> + const T * input_data_n = <nl> + input_data + n * p_ . in_planes_ * p_ . in_cols_ * p_ . in_rows_ * p_ . depth_ ; <nl> + for ( int p = pstart ; p < pend & & ! should_stop ; + + p ) { <nl> + for ( int r = rstart ; r < rend & & ! should_stop ; + + r ) { <nl> + for ( int c = cstart ; c < cend & & ! should_stop ; + + c ) { <nl> + int idx = ( ( p * p_ . in_rows_ + r ) * p_ . in_cols_ + c ) * p_ . depth_ + d ; <nl> + if ( output_data [ index ] = = input_data_n [ idx ] ) { <nl> + maxidx = idx ; <nl> + should_stop = true ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + if ( maxidx ! = - 1 ) { <nl> + output_backprop [ index ] = input_backprop [ n * p_ . in_planes_ * p_ . in_rows_ * <nl> + p_ . in_cols_ * p_ . depth_ + <nl> + maxidx ] ; <nl> + } <nl> + } <nl> + <nl> + private : <nl> + const SYCL3DPoolParams p_ ; <nl> + <nl> + const read_accessor input_data_accessor_ ; <nl> + const read_accessor output_data_accessor_ ; <nl> + const read_accessor input_backprop_accessor_ ; <nl> + write_accessor output_backprop_accessor_ ; <nl> + } ; <nl> + template < typename T > <nl> + struct LaunchMaxPooling3dGradGradOp < SYCLDevice , T > { <nl> + static void launch ( OpKernelContext * context , const Pool3dParameters & params , <nl> + const Tensor & tensor_in , const Tensor & tensor_out , <nl> + const Tensor & out_backprop , Tensor * output ) { <nl> + const SYCLDevice & device = context - > eigen_device < SYCLDevice > ( ) ; <nl> + <nl> + const int num_threads = output - > NumElements ( ) ; <nl> + <nl> + auto input_data_buffer = <nl> + device . get_sycl_buffer ( tensor_in . template flat < T > ( ) . data ( ) ) ; <nl> + auto output_data_buffer = <nl> + device . get_sycl_buffer ( tensor_out . template flat < T > ( ) . data ( ) ) ; <nl> + auto input_backprop_buffer = <nl> + device . get_sycl_buffer ( out_backprop . template flat < T > ( ) . data ( ) ) ; <nl> + auto output_backprop_buffer = <nl> + device . get_sycl_buffer ( output - > template flat < T > ( ) . data ( ) ) ; <nl> + <nl> + device . sycl_queue ( ) . submit ( [ & ] ( cl : : sycl : : handler & cgh ) { <nl> + auto input_data_access = <nl> + input_data_buffer . template get_access < cl : : sycl : : access : : mode : : read > ( <nl> + cgh ) ; <nl> + auto output_data_access = <nl> + output_data_buffer . template get_access < cl : : sycl : : access : : mode : : read > ( <nl> + cgh ) ; <nl> + auto input_backprop_access = <nl> + input_backprop_buffer <nl> + . template get_access < cl : : sycl : : access : : mode : : read > ( cgh ) ; <nl> + auto output_backprop_access = <nl> + output_backprop_buffer <nl> + . template get_access < cl : : sycl : : access : : mode : : write > ( cgh ) ; <nl> + MaxPool3DGradGradSYCL < T > functor ( <nl> + params , input_data_access , output_data_access , input_backprop_access , <nl> + output_backprop_access ) ; <nl> + <nl> + cgh . parallel_for ( cl : : sycl : : range < 1 > ( num_threads ) , functor ) ; <nl> + } ) ; <nl> + } <nl> + } ; <nl> + / / AvgPool3D SYCL kernel . Expects the number of threads to be equal to the <nl> + / / number of elements in the output tensor . <nl> + / / <nl> + / / For each output value find the corresponding input window , and run through <nl> + / / the window accumulating the values to form an average . We divide each value <nl> + / / before accumulating to prevent the accumulator from becoming significantly <nl> + / / bigger than the values we are adding and so decrease any errors . <nl> + template < typename T > <nl> + class AvgPool3DSYCL { <nl> + using write_accessor = <nl> + cl : : sycl : : accessor < uint8_t , 1 , cl : : sycl : : access : : mode : : write , <nl> + cl : : sycl : : access : : target : : global_buffer > ; <nl> + using read_accessor = <nl> + cl : : sycl : : accessor < uint8_t , 1 , cl : : sycl : : access : : mode : : read , <nl> + cl : : sycl : : access : : target : : global_buffer > ; <nl> + <nl> + public : <nl> + AvgPool3DSYCL ( const int depth , const int batch , const int in_planes , <nl> + const int in_rows , const int in_cols , const int out_planes , <nl> + const int out_rows , const int out_cols , <nl> + const std : : array < int64 , 3 > & window , <nl> + const std : : array < int64 , 3 > & stride , <nl> + const std : : array < int64 , 3 > & padding , <nl> + const read_accessor input_accessor , <nl> + write_accessor output_accessor ) <nl> + : p_ ( depth , batch , in_planes , in_rows , in_cols , out_planes , out_rows , <nl> + out_cols , window , stride , padding ) , <nl> + input_accessor_ ( input_accessor ) , <nl> + output_accessor_ ( output_accessor ) { } <nl> + void operator ( ) ( cl : : sycl : : item < 1 > item ) { <nl> + T * input_data = ConvertToActualTypeSycl ( T , input_accessor_ ) ; <nl> + T * output_data = ConvertToActualTypeSycl ( T , output_accessor_ ) ; <nl> + <nl> + int index = item . get_linear_id ( ) ; <nl> + int n = index ; <nl> + int d = n % p_ . depth_ ; <nl> + n / = p_ . depth_ ; <nl> + int cstart = ( n % p_ . out_cols_ ) * p_ . stride_cols_ - p_ . pad_cols_ ; <nl> + int cend = std : : min ( cstart + p_ . window_cols_ , p_ . in_cols_ ) ; <nl> + cstart = std : : max ( cstart , 0 ) ; <nl> + n / = p_ . out_cols_ ; <nl> + int rstart = ( n % p_ . out_rows_ ) * p_ . stride_rows_ - p_ . pad_rows_ ; <nl> + int rend = std : : min ( rstart + p_ . window_rows_ , p_ . in_rows_ ) ; <nl> + rstart = std : : max ( rstart , 0 ) ; <nl> + n / = p_ . out_rows_ ; <nl> + int pstart = ( n % p_ . out_planes_ ) * p_ . stride_planes_ - p_ . pad_planes_ ; <nl> + int pend = std : : min ( pstart + p_ . window_planes_ , p_ . in_planes_ ) ; <nl> + pstart = std : : max ( pstart , 0 ) ; <nl> + n / = p_ . out_planes_ ; <nl> + T accum = T ( 0 ) ; <nl> + T count = <nl> + static_cast < T > ( ( pend - pstart ) * ( rend - rstart ) * ( cend - cstart ) ) ; <nl> + const T * input_data_n = <nl> + input_data + n * p_ . in_planes_ * p_ . in_cols_ * p_ . in_rows_ * p_ . depth_ ; <nl> + for ( int p = pstart ; p < pend ; + + p ) { <nl> + for ( int r = rstart ; r < rend ; + + r ) { <nl> + for ( int c = cstart ; c < cend ; + + c ) { <nl> + int idx = ( ( p * p_ . in_rows_ + r ) * p_ . in_cols_ + c ) * p_ . depth_ + d ; <nl> + accum + = input_data_n [ idx ] / count ; <nl> + } <nl> + } <nl> + } <nl> + output_data [ index ] = accum ; <nl> + } <nl> + <nl> + private : <nl> + const SYCL3DPoolParams p_ ; <nl> + const read_accessor input_accessor_ ; <nl> + write_accessor output_accessor_ ; <nl> + } ; <nl> + template < typename T > <nl> + struct LaunchPoolingOp < SYCLDevice , T , AVG > { <nl> + static void launch ( OpKernelContext * context , const Tensor & tensor_in , <nl> + const std : : array < int64 , 3 > & window , <nl> + const std : : array < int64 , 3 > & stride , <nl> + const std : : array < int64 , 3 > & padding , <nl> + TensorFormat data_format , Padding padding_type , <nl> + Tensor * output ) { <nl> + const SYCLDevice & device = context - > eigen_device < SYCLDevice > ( ) ; <nl> + const int out_planes = GetTensorDim ( * output , data_format , ' 0 ' ) ; <nl> + const int out_rows = GetTensorDim ( * output , data_format , ' 1 ' ) ; <nl> + const int out_cols = GetTensorDim ( * output , data_format , ' 2 ' ) ; <nl> + const int batch = GetTensorDim ( tensor_in , data_format , ' N ' ) ; <nl> + const int in_planes = GetTensorDim ( tensor_in , data_format , ' 0 ' ) ; <nl> + const int in_rows = GetTensorDim ( tensor_in , data_format , ' 1 ' ) ; <nl> + const int in_cols = GetTensorDim ( tensor_in , data_format , ' 2 ' ) ; <nl> + const int depth = GetTensorDim ( tensor_in , data_format , ' C ' ) ; <nl> + <nl> + const int num_threads = output - > NumElements ( ) ; <nl> + <nl> + auto input_buffer = <nl> + device . get_sycl_buffer ( tensor_in . template flat < T > ( ) . data ( ) ) ; <nl> + auto output_buffer = <nl> + device . get_sycl_buffer ( output - > template flat < T > ( ) . data ( ) ) ; <nl> + <nl> + device . sycl_queue ( ) . submit ( [ & ] ( cl : : sycl : : handler & cgh ) { <nl> + auto input_access = <nl> + input_buffer . template get_access < cl : : sycl : : access : : mode : : read > ( cgh ) ; <nl> + auto output_access = <nl> + output_buffer . template get_access < cl : : sycl : : access : : mode : : write > ( cgh ) ; <nl> + AvgPool3DSYCL < T > avg_pool ( depth , batch , in_planes , in_rows , in_cols , <nl> + out_planes , out_rows , out_cols , window , stride , <nl> + padding , input_access , output_access ) ; <nl> + <nl> + cgh . parallel_for ( cl : : sycl : : range < 1 > ( num_threads ) , avg_pool ) ; <nl> + } ) ; <nl> + } <nl> + } ; <nl> + / / AvgPool3DGrad SYCL kernel . Expects the number of threads to be equal to the <nl> + / / number of elements in the output backprop tensor , i . e . the number of <nl> + / / elements in the input tensor . <nl> + / / <nl> + / / For each output backprop index find a window in the input backprop tensor <nl> + / / which corresponds to all the values of the output which were affected by the <nl> + / / input value at this index . Then for each gradient in this window , compute <nl> + / / the size of the input window which was averaged to give this output , and use <nl> + / / this size to scale the gradient accordingly . Add this scaled gradient to the <nl> + / / output backprop value . <nl> + template < typename T > <nl> + class AvgPool3DGradSYCL { <nl> + using write_accessor = <nl> + cl : : sycl : : accessor < uint8_t , 1 , cl : : sycl : : access : : mode : : write , <nl> + cl : : sycl : : access : : target : : global_buffer > ; <nl> + using read_accessor = <nl> + cl : : sycl : : accessor < uint8_t , 1 , cl : : sycl : : access : : mode : : read , <nl> + cl : : sycl : : access : : target : : global_buffer > ; <nl> + <nl> + public : <nl> + AvgPool3DGradSYCL ( const int depth , const int batch , const int in_planes , <nl> + const int in_rows , const int in_cols , <nl> + const std : : array < int64 , 3 > & out_shape , <nl> + const std : : array < int64 , 3 > & window , <nl> + const std : : array < int64 , 3 > & stride , <nl> + const std : : array < int64 , 3 > & padding , <nl> + const read_accessor input_backprop_accessor , <nl> + write_accessor output_backprop_accessor ) <nl> + : p_ ( depth , batch , in_planes , in_rows , in_cols , out_shape , window , stride , <nl> + padding ) , <nl> + input_backprop_accessor_ ( input_backprop_accessor ) , <nl> + output_backprop_accessor_ ( output_backprop_accessor ) { } <nl> + void operator ( ) ( cl : : sycl : : item < 1 > item ) { <nl> + T * input_backprop = ConvertToActualTypeSycl ( T , input_backprop_accessor_ ) ; <nl> + T * output_backprop = ConvertToActualTypeSycl ( T , output_backprop_accessor_ ) ; <nl> + <nl> + const int index = item . get_linear_id ( ) ; <nl> + int n = index ; <nl> + const int d = n % p_ . depth_ ; <nl> + n / = p_ . depth_ ; <nl> + const int c = ( n % p_ . in_cols_ ) + p_ . pad_cols_ ; <nl> + const int poolcstart = <nl> + ( c < p_ . window_cols_ ) ? 0 : ( c - p_ . window_cols_ ) / p_ . stride_cols_ + 1 ; <nl> + const int poolcend = std : : min ( c / p_ . stride_cols_ + 1 , p_ . out_cols_ ) ; <nl> + n / = p_ . in_cols_ ; <nl> + const int r = ( n % p_ . in_rows_ ) + p_ . pad_rows_ ; <nl> + const int poolrstart = <nl> + ( r < p_ . window_rows_ ) ? 0 : ( r - p_ . window_rows_ ) / p_ . stride_rows_ + 1 ; <nl> + const int poolrend = std : : min ( r / p_ . stride_rows_ + 1 , p_ . out_rows_ ) ; <nl> + n / = p_ . in_rows_ ; <nl> + const int p = ( n % p_ . in_planes_ ) + p_ . pad_planes_ ; <nl> + const int poolpstart = <nl> + ( p < p_ . window_planes_ ) <nl> + ? 0 <nl> + : ( p - p_ . window_planes_ ) / p_ . stride_planes_ + 1 ; <nl> + const int poolpend = std : : min ( p / p_ . stride_planes_ + 1 , p_ . out_planes_ ) ; <nl> + n / = p_ . in_planes_ ; <nl> + <nl> + T gradient = T ( 0 ) ; <nl> + const T * input_backprop_n = <nl> + input_backprop + <nl> + n * p_ . out_planes_ * p_ . out_cols_ * p_ . out_rows_ * p_ . depth_ ; <nl> + for ( int poolp = poolpstart ; poolp < poolpend ; + + poolp ) { <nl> + int pstart = poolp * p_ . stride_planes_ - p_ . pad_planes_ ; <nl> + const int pend = std : : min ( pstart + p_ . window_planes_ , p_ . in_planes_ ) ; <nl> + pstart = std : : max ( pstart , 0 ) ; <nl> + const int plane_window_size = pend - pstart ; <nl> + for ( int poolr = poolrstart ; poolr < poolrend ; + + poolr ) { <nl> + int rstart = poolr * p_ . stride_rows_ - p_ . pad_rows_ ; <nl> + const int rend = std : : min ( rstart + p_ . window_rows_ , p_ . in_rows_ ) ; <nl> + rstart = std : : max ( rstart , 0 ) ; <nl> + const int row_window_size = rend - rstart ; <nl> + for ( int poolc = poolcstart ; poolc < poolcend ; + + poolc ) { <nl> + const int idx = <nl> + ( ( poolp * p_ . out_rows_ + poolr ) * p_ . out_cols_ + poolc ) * <nl> + p_ . depth_ + <nl> + d ; <nl> + int cstart = poolc * p_ . stride_cols_ - p_ . pad_cols_ ; <nl> + const int cend = std : : min ( cstart + p_ . window_cols_ , p_ . in_cols_ ) ; <nl> + cstart = std : : max ( cstart , 0 ) ; <nl> + const int col_window_size = cend - cstart ; <nl> + const int window_size = <nl> + plane_window_size * row_window_size * col_window_size ; <nl> + gradient + = input_backprop_n [ idx ] / static_cast < T > ( window_size ) ; <nl> + } <nl> + } <nl> + } <nl> + output_backprop [ index ] = gradient ; <nl> + } <nl> + <nl> + private : <nl> + const SYCL3DPoolParams p_ ; <nl> + const read_accessor input_backprop_accessor_ ; <nl> + write_accessor output_backprop_accessor_ ; <nl> + } ; <nl> + template < typename T > <nl> + struct LaunchAvgPooling3dGradOp < SYCLDevice , T > { <nl> + static void launch ( OpKernelContext * context , <nl> + const TensorShape & tensor_in_shape , <nl> + const Tensor & out_backprop , <nl> + const std : : array < int64 , 3 > & window , <nl> + const std : : array < int64 , 3 > & stride , <nl> + const std : : array < int64 , 3 > & output_shape , <nl> + const std : : array < int64 , 3 > & padding , <nl> + TensorFormat data_format , Tensor * output ) { <nl> + const SYCLDevice & device = context - > eigen_device < SYCLDevice > ( ) ; <nl> + const int batch = GetTensorDim ( tensor_in_shape , data_format , ' N ' ) ; <nl> + const int in_planes = GetTensorDim ( tensor_in_shape , data_format , ' 0 ' ) ; <nl> + const int in_rows = GetTensorDim ( tensor_in_shape , data_format , ' 1 ' ) ; <nl> + const int in_cols = GetTensorDim ( tensor_in_shape , data_format , ' 2 ' ) ; <nl> + const int depth = GetTensorDim ( tensor_in_shape , data_format , ' C ' ) ; <nl> + <nl> + const int num_threads = output - > NumElements ( ) ; <nl> + <nl> + auto input_backprop_buffer = <nl> + device . get_sycl_buffer ( out_backprop . template flat < T > ( ) . data ( ) ) ; <nl> + auto output_backprop_buffer = <nl> + device . get_sycl_buffer ( output - > template flat < T > ( ) . data ( ) ) ; <nl> + <nl> + device . sycl_queue ( ) . submit ( [ & ] ( cl : : sycl : : handler & cgh ) { <nl> + auto input_backprop_access = <nl> + input_backprop_buffer <nl> + . template get_access < cl : : sycl : : access : : mode : : read > ( cgh ) ; <nl> + auto output_backprop_access = <nl> + output_backprop_buffer <nl> + . template get_access < cl : : sycl : : access : : mode : : write > ( cgh ) ; <nl> + AvgPool3DGradSYCL < T > functor ( <nl> + depth , batch , in_planes , in_rows , in_cols , output_shape , window , <nl> + stride , padding , input_backprop_access , output_backprop_access ) ; <nl> + <nl> + cgh . parallel_for ( cl : : sycl : : range < 1 > ( num_threads ) , functor ) ; <nl> + } ) ; <nl> + } <nl> + } ; <nl> + <nl> + } / / namespace tensorflow <nl> + <nl> + # endif / / TENSORFLOW_CORE_KERNELS_POOLING_OP_3D_SYCL_H_ <nl>
|
[ OpenCL ] Provides SYCL kernels for 3D pooling ( ) ( )
|
tensorflow/tensorflow
|
e6fee141e3bdde3bac5741b2aadfdd41bd2a7b24
|
2017-08-02T23:34:42Z
|
mmm a / drivers / python / rethinkdb / _export . py <nl> ppp b / drivers / python / rethinkdb / _export . py <nl> def read_table_into_queue ( progress , conn , db , table , pkey , task_queue , progress_ <nl> finally : <nl> progress_info [ 0 ] . value + = read_rows % 20 <nl> <nl> + # Export is done - since we used estimates earlier , update the actual table size <nl> + progress_info [ 1 ] . value = progress_info [ 0 ] . value <nl> + <nl> def json_writer ( filename , fields , task_queue , error_queue ) : <nl> try : <nl> with open ( filename , " w " ) as out : <nl> def launch_writer ( format , directory , db , table , fields , task_queue , error_queue ) <nl> raise RuntimeError ( " unknown format type : % s " % format ) <nl> <nl> def get_table_size ( progress , conn , db , table , progress_info ) : <nl> - table_size = r . db ( db ) . table ( table ) . count ( ) . run ( conn ) <nl> + table_size = r . db ( db ) . table ( table ) . info ( ) [ ' doc_count_estimates ' ] . sum ( ) . run ( conn ) <nl> progress_info [ 1 ] . value = table_size <nl> progress_info [ 0 ] . value = 0 <nl> <nl>
|
changing export table size count to use estimates for performance
|
rethinkdb/rethinkdb
|
92c739030b6beb92316ee994e167645364e396f0
|
2015-01-02T23:57:19Z
|
mmm a / dbms / src / Interpreters / DDLWorker . cpp <nl> ppp b / dbms / src / Interpreters / DDLWorker . cpp <nl> struct DDLLogEntry <nl> Strings hosts ; <nl> String initiator ; / / optional <nl> <nl> - static constexpr int CURRENT_VERSION = ' 1 ' ; <nl> + static constexpr int CURRENT_VERSION = 1 ; <nl> <nl> String toString ( ) <nl> { <nl> struct DDLLogEntry <nl> { <nl> WriteBufferFromString wb ( res ) ; <nl> <nl> - wb < < " version : " < < CURRENT_VERSION < < " \ n " ; <nl> + auto version = CURRENT_VERSION ; <nl> + wb < < " version : " < < version < < " \ n " ; <nl> wb < < " query : " < < escape < < query < < " \ n " ; <nl> wb < < " hosts : " < < hosts < < " \ n " ; <nl> wb < < " initiator : " < < initiator < < " \ n " ; <nl> mmm a / dbms / src / Server / config . xml <nl> ppp b / dbms / src / Server / config . xml <nl> <nl> < task_queue_path > / clickhouse / task_queue < / task_queue_path > <nl> < / resharding > <nl> <nl> + < ! - - Allow to execute distributed DDL queries ( CREATE , DROP , ALTER , RENAME ) on cluster . <nl> + Works only if ZooKeeper is enabled . Comment it if such functionality isn ' t required . - - > <nl> + < distributed_ddl > <nl> + < ! - - Path in ZooKeeper to queue with DDL queries - - > <nl> + < path > / clickhouse / task_queue / ddl < / path > <nl> + < / distributed_ddl > <nl> + <nl> < ! - - Settings to fine tune MergeTree tables . See documentation in source code , in MergeTreeSettings . h - - > <nl> < ! - - <nl> < merge_tree > <nl>
|
Fix DDLLogEntry : : CURRENT_VERSION variable issue . [ # CLICKHOUSE - 5 ]
|
ClickHouse/ClickHouse
|
1c367fc666d5df4b56bff3ad8bedcd9c7e705f94
|
2017-06-01T10:49:22Z
|
mmm a / third_party / fbgemm <nl> ppp b / third_party / fbgemm <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit 00dfc2c82e0073305ca2a8f73ca94b392f94b5ef <nl> + Subproject commit cf7a2fb510d61f1fca8ed3e2bad50cf335b1a38a <nl>
|
Updating submodules
|
pytorch/pytorch
|
e80e42cb2c8a9656284602cabcb1651a09dd3ead
|
2019-10-23T16:42:44Z
|
mmm a / tools / darwin / depends / libcec / Makefile <nl> ppp b / tools / darwin / depends / libcec / Makefile <nl> include . . / Makefile . include <nl> <nl> # lib name , version <nl> LIBNAME = libcec <nl> - VERSION = 1 . 0 . 0 <nl> + VERSION = 1 . 1 . 0 <nl> SOURCE = $ ( LIBNAME ) - $ ( VERSION ) <nl> ARCHIVE = $ ( SOURCE ) . tar . gz <nl> <nl>
|
[ osx ] bump to libcec - 1 . 1 . 0
|
xbmc/xbmc
|
74b464d80bfb02070bacfdccf416a36855752d8f
|
2011-11-12T01:12:37Z
|
mmm a / core / io / marshalls . cpp <nl> ppp b / core / io / marshalls . cpp <nl> static void _encode_string ( const String & p_string , uint8_t * & buf , int & r_len ) { <nl> encode_uint32 ( utf8 . length ( ) , buf ) ; <nl> buf + = 4 ; <nl> copymem ( buf , utf8 . get_data ( ) , utf8 . length ( ) ) ; <nl> + buf + = utf8 . length ( ) ; <nl> } <nl> <nl> r_len + = 4 + utf8 . length ( ) ; <nl> - while ( r_len % 4 ) <nl> + while ( r_len % 4 ) { <nl> r_len + + ; / / pad <nl> + if ( buf ) { <nl> + buf + + ; <nl> + } <nl> + } <nl> } <nl> <nl> Error encode_variant ( const Variant & p_variant , uint8_t * r_buffer , int & r_len , bool p_object_as_id ) { <nl>
|
Fix binary object marshalling , closes
|
godotengine/godot
|
1be30f35a68a9fb2c156ded45c8689cc44f26f29
|
2017-08-21T14:22:08Z
|
mmm a / ChangeLog <nl> ppp b / ChangeLog <nl> <nl> + 2009 - 05 - 27 Tatsuhiro Tsujikawa < t - tujikawa @ users . sourceforge . net > <nl> + <nl> + Rewritten the help message for - - allow - overwrite option . <nl> + * doc / aria2c . 1 . txt <nl> + * src / usage_text . h <nl> + <nl> 2009 - 05 - 27 Tatsuhiro Tsujikawa < t - tujikawa @ users . sourceforge . net > <nl> <nl> Fixed typo <nl> mmm a / doc / aria2c . 1 <nl> ppp b / doc / aria2c . 1 <nl> Set XML \ - RPC user \ & . <nl> . RS 4 <nl> If <nl> \ fIfalse \ fR <nl> - is given , aria2 doesn \ ( cqt download a file which already exists but the corresponding \ & . aria2 file doesn \ ( cqt exist \ & . In HTTP ( S ) / FTP download , if <nl> - \ fB \ - \ - auto \ - file \ - renaming \ fR = \ fItrue \ fR <nl> - then , file name will be renamed \ & . See <nl> + is given , and a file already exists but the corresponding control file ( filename \ & . aria2 ) doesn \ ( cqt exist , then aria2 will not re \ - download the file \ & . See also <nl> \ fB \ - \ - auto \ - file \ - renaming \ fR <nl> - for details \ & . Default : <nl> + option \ & . Default : <nl> \ fIfalse \ fR <nl> . RE <nl> . PP <nl> mmm a / doc / aria2c . 1 . html <nl> ppp b / doc / aria2c . 1 . html <nl> < h3 id = " _advanced_options " > Advanced Options < / h3 > < div style = " clear : left " > < / div > <nl> < / dt > <nl> < dd > <nl> < p > <nl> - If < em > false < / em > is given , aria2 doesn & # 8217 ; t download a file which already exists but <nl> - the corresponding . aria2 file doesn & # 8217 ; t exist . <nl> - In HTTP ( S ) / FTP download , if < strong > - - auto - file - renaming < / strong > = < em > true < / em > then , <nl> - file name will be renamed . See < strong > - - auto - file - renaming < / strong > for details . <nl> + If < em > false < / em > is given , and a file already exists but the corresponding <nl> + control file ( filename . aria2 ) doesn & # 8217 ; t exist , then aria2 will not <nl> + re - download the file . See also < strong > - - auto - file - renaming < / strong > option . <nl> Default : < em > false < / em > <nl> < / p > <nl> < / dd > <nl> < h2 id = " _copyright " > COPYRIGHT < / h2 > <nl> < / div > <nl> < div id = " footer " > <nl> < div id = " footer - text " > <nl> - Last updated 2009 - 05 - 27 21 : 37 : 30 JST <nl> + Last updated 2009 - 05 - 27 21 : 56 : 45 JST <nl> < / div > <nl> < / div > <nl> < / body > <nl> mmm a / doc / aria2c . 1 . txt <nl> ppp b / doc / aria2c . 1 . txt <nl> XML - RPC Options <nl> Advanced Options <nl> ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ <nl> * - - allow - overwrite * = ' true ' | ' false ' : : <nl> - If ' false ' is given , aria2 doesn ' t download a file which already exists but <nl> - the corresponding . aria2 file doesn ' t exist . <nl> - In HTTP ( S ) / FTP download , if * - - auto - file - renaming * = ' true ' then , <nl> - file name will be renamed . See * - - auto - file - renaming * for details . <nl> + <nl> + If ' false ' is given , and a file already exists but the corresponding <nl> + control file ( filename . aria2 ) doesn ' t exist , then aria2 will not <nl> + re - download the file . See also * - - auto - file - renaming * option . <nl> Default : ' false ' <nl> <nl> * - - allow - piece - length - change * = ' true ' | ' false ' : : <nl> mmm a / src / usage_text . h <nl> ppp b / src / usage_text . h <nl> _ ( " - - enable - direct - io [ = true | false ] Enable directI / O , which lowers cpu usage whi <nl> " allocating files . \ n " \ <nl> " Turn off if you encounter any error " ) <nl> # define TEXT_ALLOW_OVERWRITE \ <nl> - _ ( " - - allow - overwrite = true | false If false , aria2 doesn ' t download a file which \ n " \ <nl> - " already exists but the corresponding . aria2 file \ n " \ <nl> - " doesn ' t exist . " ) <nl> + _ ( " - - allow - overwrite = true | false If false is given , and a file already exists but \ n " \ <nl> + " the corresponding control file ( filename . aria2 ) \ n " \ <nl> + " doesn ' t exist , then aria2 will not re - download \ n " \ <nl> + " the file . See also - - auto - file - renaming option . " ) <nl> # define TEXT_ALLOW_PIECE_LENGTH_CHANGE \ <nl> _ ( " - - allow - piece - length - change = true | false If false is given , aria2 aborts download \ n " \ <nl> " when a piece length is different from one in \ n " \ <nl>
|
2009 - 05 - 27 Tatsuhiro Tsujikawa < t - tujikawa @ users . sourceforge . net >
|
aria2/aria2
|
7a8e2fdadb596c44d83aed45ed1f5980830b1099
|
2009-05-27T12:58:33Z
|
mmm a / scene / resources / curve . cpp <nl> ppp b / scene / resources / curve . cpp <nl> Vector2 Curve2D : : interpolate_baked ( float p_offset , bool p_cubic ) const { <nl> if ( p_offset > = baked_max_ofs ) <nl> return r [ bpc - 1 ] ; <nl> <nl> - int idx = Math : : floor ( p_offset / bake_interval ) ; <nl> + int idx = Math : : floor ( ( double ) p_offset / ( double ) bake_interval ) ; <nl> float frac = Math : : fmod ( p_offset , bake_interval ) ; <nl> <nl> if ( idx > = bpc - 1 ) { <nl> Vector3 Curve3D : : interpolate_baked ( float p_offset , bool p_cubic ) const { <nl> if ( p_offset > = baked_max_ofs ) <nl> return r [ bpc - 1 ] ; <nl> <nl> - int idx = Math : : floor ( p_offset / bake_interval ) ; <nl> + int idx = Math : : floor ( ( double ) p_offset / ( double ) bake_interval ) ; <nl> float frac = Math : : fmod ( p_offset , bake_interval ) ; <nl> <nl> if ( idx > = bpc - 1 ) { <nl> float Curve3D : : interpolate_baked_tilt ( float p_offset ) const { <nl> if ( p_offset > = baked_max_ofs ) <nl> return r [ bpc - 1 ] ; <nl> <nl> - int idx = Math : : floor ( p_offset / bake_interval ) ; <nl> + int idx = Math : : floor ( ( double ) p_offset / ( double ) bake_interval ) ; <nl> float frac = Math : : fmod ( p_offset , bake_interval ) ; <nl> <nl> if ( idx > = bpc - 1 ) { <nl>
|
Merge pull request from Algrin6 / patch - 1
|
godotengine/godot
|
bafcabb15714b03ab5f381066017793a91cb7591
|
2016-07-24T14:44:42Z
|
mmm a / tensorflow / core / kernels / data / fixed_length_record_dataset_op_test . cc <nl> ppp b / tensorflow / core / kernels / data / fixed_length_record_dataset_op_test . cc <nl> namespace { <nl> constexpr char kNodeName [ ] = " fixed_length_record_dataset " ; <nl> constexpr int kOpVersion = 2 ; <nl> <nl> + tstring LocalTempFilename ( ) { <nl> + std : : string path ; <nl> + CHECK ( Env : : Default ( ) - > LocalTempFilename ( & path ) ) ; <nl> + return tstring ( path ) ; <nl> + } <nl> + <nl> class FixedLengthRecordDatasetParams : public DatasetParams { <nl> public : <nl> FixedLengthRecordDatasetParams ( const std : : vector < tstring > & filenames , <nl> Status CreateTestFiles ( const std : : vector < tstring > & filenames , <nl> <nl> / / Test case 1 : multiple fixed - length record files with ZLIB compression . <nl> FixedLengthRecordDatasetParams FixedLengthRecordDatasetParams1 ( ) { <nl> - std : : vector < tstring > filenames = { <nl> - absl : : StrCat ( testing : : TmpDir ( ) , " / text_line_ZLIB_1 " ) , <nl> - absl : : StrCat ( testing : : TmpDir ( ) , " / text_line_ZLIB_2 " ) } ; <nl> + std : : vector < tstring > filenames = { LocalTempFilename ( ) , LocalTempFilename ( ) } ; <nl> std : : vector < string > contents = { <nl> absl : : StrCat ( " HHHHH " , " 111 " , " 222 " , " 333 " , " FF " ) , <nl> absl : : StrCat ( " HHHHH " , " aaa " , " bbb " , " FF " ) } ; <nl> FixedLengthRecordDatasetParams FixedLengthRecordDatasetParams1 ( ) { <nl> <nl> / / Test case 2 : multiple fixed - length record files with GZIP compression . <nl> FixedLengthRecordDatasetParams FixedLengthRecordDatasetParams2 ( ) { <nl> - std : : vector < tstring > filenames = { <nl> - absl : : StrCat ( testing : : TmpDir ( ) , " / text_line_GZIP_1 " ) , <nl> - absl : : StrCat ( testing : : TmpDir ( ) , " / text_line_GZIP_2 " ) } ; <nl> + std : : vector < tstring > filenames = { LocalTempFilename ( ) , LocalTempFilename ( ) } ; <nl> std : : vector < string > contents = { <nl> absl : : StrCat ( " HHHHH " , " 111 " , " 222 " , " 333 " , " FF " ) , <nl> absl : : StrCat ( " HHHHH " , " aaa " , " bbb " , " FF " ) } ; <nl> FixedLengthRecordDatasetParams FixedLengthRecordDatasetParams2 ( ) { <nl> <nl> / / Test case 3 : multiple fixed - length record files without compression . <nl> FixedLengthRecordDatasetParams FixedLengthRecordDatasetParams3 ( ) { <nl> - std : : vector < tstring > filenames = { <nl> - absl : : StrCat ( testing : : TmpDir ( ) , " / text_line_UNCOMPRESSED_1 " ) , <nl> - absl : : StrCat ( testing : : TmpDir ( ) , " / text_line_UNCOMPRESSED_2 " ) } ; <nl> + std : : vector < tstring > filenames = { LocalTempFilename ( ) , LocalTempFilename ( ) } ; <nl> std : : vector < string > contents = { <nl> absl : : StrCat ( " HHHHH " , " 111 " , " 222 " , " 333 " , " FF " ) , <nl> absl : : StrCat ( " HHHHH " , " aaa " , " bbb " , " FF " ) } ; <nl>
|
Use Env : : LocalTempFilename for a temp filename .
|
tensorflow/tensorflow
|
0fa7a0b0339c3fd7264f1259a4a60be43bb6c5dc
|
2020-02-20T18:27:38Z
|
mmm a / modules / canbus / vehicle / transit / transit_controller . cc <nl> ppp b / modules / canbus / vehicle / transit / transit_controller . cc <nl> using : : apollo : : control : : ControlCommand ; <nl> using : : apollo : : drivers : : canbus : : ProtocolData ; <nl> <nl> namespace { <nl> - <nl> const int32_t kMaxFailAttempt = 10 ; <nl> const int32_t CHECK_RESPONSE_STEER_UNIT_FLAG = 1 ; <nl> const int32_t CHECK_RESPONSE_SPEED_UNIT_FLAG = 2 ; <nl> Chassis TransitController : : chassis ( ) { <nl> / / 3 <nl> chassis_ . set_engine_started ( true ) ; <nl> / / 4 <nl> - if ( chassis_detail . has_ems ( ) & & chassis_detail . ems ( ) . has_engine_rpm ( ) ) { <nl> - chassis_ . set_engine_rpm ( chassis_detail . ems ( ) . engine_rpm ( ) ) ; <nl> - } else { <nl> - chassis_ . set_engine_rpm ( 0 ) ; <nl> - } <nl> - / / 5 <nl> - if ( chassis_detail . has_vehicle_spd ( ) & & <nl> - chassis_detail . vehicle_spd ( ) . has_vehicle_spd ( ) ) { <nl> - chassis_ . set_speed_mps ( chassis_detail . vehicle_spd ( ) . vehicle_spd ( ) ) ; <nl> - chassis_ . mutable_wheel_speed ( ) - > set_is_wheel_spd_rr_valid ( <nl> - chassis_detail . vehicle_spd ( ) . is_wheel_spd_rr_valid ( ) ) ; <nl> - chassis_ . mutable_wheel_speed ( ) - > set_wheel_direction_rr ( <nl> - chassis_detail . vehicle_spd ( ) . wheel_direction_rr ( ) ) ; <nl> - chassis_ . mutable_wheel_speed ( ) - > set_wheel_spd_rr ( <nl> - chassis_detail . vehicle_spd ( ) . wheel_spd_rr ( ) ) ; <nl> - <nl> - chassis_ . mutable_wheel_speed ( ) - > set_is_wheel_spd_rl_valid ( <nl> - chassis_detail . vehicle_spd ( ) . is_wheel_spd_rl_valid ( ) ) ; <nl> - chassis_ . mutable_wheel_speed ( ) - > set_wheel_direction_rl ( <nl> - chassis_detail . vehicle_spd ( ) . wheel_direction_rl ( ) ) ; <nl> - chassis_ . mutable_wheel_speed ( ) - > set_wheel_spd_rl ( <nl> - chassis_detail . vehicle_spd ( ) . wheel_spd_rl ( ) ) ; <nl> - <nl> - chassis_ . mutable_wheel_speed ( ) - > set_is_wheel_spd_fr_valid ( <nl> - chassis_detail . vehicle_spd ( ) . is_wheel_spd_fr_valid ( ) ) ; <nl> - chassis_ . mutable_wheel_speed ( ) - > set_wheel_direction_fr ( <nl> - chassis_detail . vehicle_spd ( ) . wheel_direction_fr ( ) ) ; <nl> - chassis_ . mutable_wheel_speed ( ) - > set_wheel_spd_fr ( <nl> - chassis_detail . vehicle_spd ( ) . wheel_spd_fr ( ) ) ; <nl> - <nl> - chassis_ . mutable_wheel_speed ( ) - > set_is_wheel_spd_fl_valid ( <nl> - chassis_detail . vehicle_spd ( ) . is_wheel_spd_fl_valid ( ) ) ; <nl> - chassis_ . mutable_wheel_speed ( ) - > set_wheel_direction_fl ( <nl> - chassis_detail . vehicle_spd ( ) . wheel_direction_fl ( ) ) ; <nl> - chassis_ . mutable_wheel_speed ( ) - > set_wheel_spd_fl ( <nl> - chassis_detail . vehicle_spd ( ) . wheel_spd_fl ( ) ) ; <nl> - <nl> - } else { <nl> - chassis_ . set_speed_mps ( 0 ) ; <nl> - } <nl> - / / 6 <nl> - if ( chassis_detail . has_basic ( ) & & chassis_detail . basic ( ) . has_odo_meter ( ) ) { <nl> - / / odo_meter is in km <nl> - chassis_ . set_odometer_m ( chassis_detail . basic ( ) . odo_meter ( ) * 1000 ) ; <nl> - } else { <nl> - chassis_ . set_odometer_m ( 0 ) ; <nl> - } <nl> - <nl> - / / 7 <nl> - / / lincoln only has fuel percentage <nl> - / / to avoid confusing , just don ' t set <nl> - chassis_ . set_fuel_range_m ( 0 ) ; <nl> - / / 8 <nl> - if ( chassis_detail . has_gas ( ) & & chassis_detail . gas ( ) . has_throttle_output ( ) ) { <nl> - chassis_ . set_throttle_percentage ( chassis_detail . gas ( ) . throttle_output ( ) ) ; <nl> - } else { <nl> - chassis_ . set_throttle_percentage ( 0 ) ; <nl> - } <nl> - / / 9 <nl> - if ( chassis_detail . has_brake ( ) & & chassis_detail . brake ( ) . has_brake_output ( ) ) { <nl> - chassis_ . set_brake_percentage ( chassis_detail . brake ( ) . brake_output ( ) ) ; <nl> - } else { <nl> - chassis_ . set_brake_percentage ( 0 ) ; <nl> - } <nl> - / / 23 , previously 10 <nl> - if ( chassis_detail . has_gear ( ) & & chassis_detail . gear ( ) . has_gear_state ( ) ) { <nl> - chassis_ . set_gear_location ( chassis_detail . gear ( ) . gear_state ( ) ) ; <nl> - } else { <nl> - chassis_ . set_gear_location ( Chassis : : GEAR_NONE ) ; <nl> - } <nl> - / / 11 <nl> - if ( chassis_detail . has_eps ( ) & & chassis_detail . eps ( ) . has_steering_angle ( ) ) { <nl> - chassis_ . set_steering_percentage ( chassis_detail . eps ( ) . steering_angle ( ) * <nl> - 100 . 0 / vehicle_params_ . max_steer_angle ( ) * <nl> - M_PI / 180 . 0 ) ; <nl> - } else { <nl> - chassis_ . set_steering_percentage ( 0 ) ; <nl> - } <nl> - / / 12 <nl> - if ( chassis_detail . has_eps ( ) & & chassis_detail . eps ( ) . has_epas_torque ( ) ) { <nl> - chassis_ . set_steering_torque_nm ( chassis_detail . eps ( ) . epas_torque ( ) ) ; <nl> - } else { <nl> - chassis_ . set_steering_torque_nm ( 0 ) ; <nl> - } <nl> - / / 13 <nl> - if ( chassis_detail . has_eps ( ) & & <nl> - chassis_detail . epb ( ) . has_parking_brake_status ( ) ) { <nl> - chassis_ . set_parking_brake ( chassis_detail . epb ( ) . parking_brake_status ( ) = = <nl> - Epb : : PBRAKE_ON ) ; <nl> - } else { <nl> - chassis_ . set_parking_brake ( false ) ; <nl> - } <nl> - <nl> - / / 14 , 15 <nl> - if ( chassis_detail . has_light ( ) & & <nl> - chassis_detail . light ( ) . has_lincoln_lamp_type ( ) ) { <nl> - chassis_ . mutable_signal ( ) - > set_high_beam ( <nl> - chassis_detail . light ( ) . lincoln_lamp_type ( ) = = Light : : BEAM_HIGH ) ; <nl> - } else { <nl> - chassis_ . mutable_signal ( ) - > set_high_beam ( false ) ; <nl> - } <nl> - <nl> - / / 16 , 17 <nl> - if ( chassis_detail . has_light ( ) & & <nl> - chassis_detail . light ( ) . has_turn_light_type ( ) & & <nl> - chassis_detail . light ( ) . turn_light_type ( ) ! = Light : : TURN_LIGHT_OFF ) { <nl> - if ( chassis_detail . light ( ) . turn_light_type ( ) = = Light : : TURN_LEFT_ON ) { <nl> - chassis_ . mutable_signal ( ) - > set_turn_signal ( <nl> - common : : VehicleSignal : : TURN_LEFT ) ; <nl> - } else if ( chassis_detail . light ( ) . turn_light_type ( ) = = <nl> - Light : : TURN_RIGHT_ON ) { <nl> - chassis_ . mutable_signal ( ) - > set_turn_signal ( <nl> - common : : VehicleSignal : : TURN_RIGHT ) ; <nl> - } else { <nl> - chassis_ . mutable_signal ( ) - > set_turn_signal ( <nl> - common : : VehicleSignal : : TURN_NONE ) ; <nl> + auto & transit = chassis_detail . transit ( ) ; <nl> + / / TODO ( luoqi ) : revisit it later <nl> + / / can ' t find speed <nl> + auto & motion = transit . llc_motionfeedback1_20 ( ) ; <nl> + if ( motion . has_llc_fbk_throttleposition ( ) ) { <nl> + chassis_ . set_throttle_percentage ( motion . llc_fbk_throttleposition ( ) ) ; <nl> + } <nl> + / / can ' t find brake percentage <nl> + / / can ' t find steering percentage <nl> + if ( motion . has_llc_fbk_gear ( ) ) { <nl> + switch ( motion . llc_fbk_gear ( ) ) { <nl> + case Llc_motionfeedback1_20 : : LLC_FBK_GEAR_P_PARK : <nl> + chassis_ . set_gear_location ( Chassis : : GEAR_PARKING ) ; <nl> + break ; <nl> + case Llc_motionfeedback1_20 : : LLC_FBK_GEAR_D_DRIVE : <nl> + chassis_ . set_gear_location ( Chassis : : GEAR_DRIVE ) ; <nl> + break ; <nl> + case Llc_motionfeedback1_20 : : LLC_FBK_GEAR_N_NEUTRAL : <nl> + chassis_ . set_gear_location ( Chassis : : GEAR_NEUTRAL ) ; <nl> + break ; <nl> + case Llc_motionfeedback1_20 : : LLC_FBK_GEAR_R_REVERSE : <nl> + chassis_ . set_gear_location ( Chassis : : GEAR_REVERSE ) ; <nl> + break ; <nl> + default : <nl> + break ; <nl> } <nl> - } else { <nl> - chassis_ . mutable_signal ( ) - > set_turn_signal ( <nl> - common : : VehicleSignal : : TURN_NONE ) ; <nl> - } <nl> - / / 18 <nl> - if ( chassis_detail . has_light ( ) & & chassis_detail . light ( ) . has_is_horn_on ( ) & & <nl> - chassis_detail . light ( ) . is_horn_on ( ) ) { <nl> - chassis_ . mutable_signal ( ) - > set_horn ( true ) ; <nl> - } else { <nl> - chassis_ . mutable_signal ( ) - > set_horn ( false ) ; <nl> - } <nl> - <nl> - / / 24 <nl> - if ( chassis_detail . has_eps ( ) & & chassis_detail . eps ( ) . has_timestamp_65 ( ) ) { <nl> - chassis_ . set_steering_timestamp ( chassis_detail . eps ( ) . timestamp_65 ( ) ) ; <nl> - } <nl> - / / 26 <nl> - if ( chassis_error_mask_ ) { <nl> - chassis_ . set_chassis_error_mask ( chassis_error_mask_ ) ; <nl> - } <nl> - <nl> - / / 6d , 6e , 6f , if gps valid is availiable , assume all gps related field <nl> - / / available <nl> - if ( chassis_detail . basic ( ) . has_gps_valid ( ) ) { <nl> - chassis_ . mutable_chassis_gps ( ) - > set_latitude ( <nl> - chassis_detail . basic ( ) . latitude ( ) ) ; <nl> - chassis_ . mutable_chassis_gps ( ) - > set_longitude ( <nl> - chassis_detail . basic ( ) . longitude ( ) ) ; <nl> - chassis_ . mutable_chassis_gps ( ) - > set_gps_valid ( <nl> - chassis_detail . basic ( ) . gps_valid ( ) ) ; <nl> - chassis_ . mutable_chassis_gps ( ) - > set_year ( chassis_detail . basic ( ) . year ( ) ) ; <nl> - chassis_ . mutable_chassis_gps ( ) - > set_month ( chassis_detail . basic ( ) . month ( ) ) ; <nl> - chassis_ . mutable_chassis_gps ( ) - > set_day ( chassis_detail . basic ( ) . day ( ) ) ; <nl> - chassis_ . mutable_chassis_gps ( ) - > set_hours ( chassis_detail . basic ( ) . hours ( ) ) ; <nl> - chassis_ . mutable_chassis_gps ( ) - > set_minutes ( <nl> - chassis_detail . basic ( ) . minutes ( ) ) ; <nl> - chassis_ . mutable_chassis_gps ( ) - > set_seconds ( <nl> - chassis_detail . basic ( ) . seconds ( ) ) ; <nl> - chassis_ . mutable_chassis_gps ( ) - > set_compass_direction ( <nl> - chassis_detail . basic ( ) . compass_direction ( ) ) ; <nl> - chassis_ . mutable_chassis_gps ( ) - > set_pdop ( chassis_detail . basic ( ) . pdop ( ) ) ; <nl> - chassis_ . mutable_chassis_gps ( ) - > set_is_gps_fault ( <nl> - chassis_detail . basic ( ) . is_gps_fault ( ) ) ; <nl> - chassis_ . mutable_chassis_gps ( ) - > set_is_inferred ( <nl> - chassis_detail . basic ( ) . is_inferred ( ) ) ; <nl> - chassis_ . mutable_chassis_gps ( ) - > set_altitude ( <nl> - chassis_detail . basic ( ) . altitude ( ) ) ; <nl> - chassis_ . mutable_chassis_gps ( ) - > set_heading ( <nl> - chassis_detail . basic ( ) . heading ( ) ) ; <nl> - chassis_ . mutable_chassis_gps ( ) - > set_hdop ( chassis_detail . basic ( ) . hdop ( ) ) ; <nl> - chassis_ . mutable_chassis_gps ( ) - > set_vdop ( chassis_detail . basic ( ) . vdop ( ) ) ; <nl> - chassis_ . mutable_chassis_gps ( ) - > set_quality ( <nl> - chassis_detail . basic ( ) . quality ( ) ) ; <nl> - chassis_ . mutable_chassis_gps ( ) - > set_num_satellites ( <nl> - chassis_detail . basic ( ) . num_satellites ( ) ) ; <nl> - chassis_ . mutable_chassis_gps ( ) - > set_gps_speed ( <nl> - chassis_detail . basic ( ) . gps_speed ( ) ) ; <nl> - } else { <nl> - chassis_ . mutable_chassis_gps ( ) - > set_gps_valid ( false ) ; <nl> } <nl> - <nl> - / / vin number will be written into KVDB once . <nl> - if ( chassis_detail . license ( ) . has_vin ( ) ) { <nl> - chassis_ . mutable_license ( ) - > set_vin ( chassis_detail . license ( ) . vin ( ) ) ; <nl> - if ( ! received_vin_ ) { <nl> - apollo : : common : : KVDB : : Put ( " apollo : canbus : vin " , <nl> - chassis_detail . license ( ) . vin ( ) ) ; <nl> - received_vin_ = true ; <nl> + auto & aux = transit . llc_auxiliaryfeedback_120 ( ) ; <nl> + if ( aux . has_llc_fbk_turnsignal ( ) ) { <nl> + switch ( aux . llc_fbk_turnsignal ( ) ) { <nl> + case Adc_auxiliarycontrol_110 : : ADC_CMD_TURNSIGNAL_LEFT : <nl> + chassis_ . mutable_signal ( ) <nl> + - > set_turn_signal ( common : : VehicleSignal : : TURN_LEFT ) ; <nl> + case Adc_auxiliarycontrol_110 : : ADC_CMD_TURNSIGNAL_RIGHT : <nl> + chassis_ . mutable_signal ( ) <nl> + - > set_turn_signal ( common : : VehicleSignal : : TURN_RIGHT ) ; <nl> + case Adc_auxiliarycontrol_110 : : ADC_CMD_TURNSIGNAL_NONE : <nl> + chassis_ . mutable_signal ( ) <nl> + - > set_turn_signal ( common : : VehicleSignal : : TURN_NONE ) ; <nl> } <nl> } <nl> <nl> - if ( chassis_detail . has_surround ( ) ) { <nl> - chassis_ . mutable_surround ( ) - > CopyFrom ( chassis_detail . surround ( ) ) ; <nl> - } <nl> - / / give engage_advice based on error_code and canbus feedback <nl> - if ( chassis_error_mask_ | | ( chassis_ . throttle_percentage ( ) = = 0 . 0 ) | | <nl> - ( chassis_ . brake_percentage ( ) = = 0 . 0 ) ) { <nl> - chassis_ . mutable_engage_advice ( ) - > set_advice ( <nl> - apollo : : common : : EngageAdvice : : DISALLOW_ENGAGE ) ; <nl> - chassis_ . mutable_engage_advice ( ) - > set_reason ( " Chassis error ! " ) ; <nl> - } else if ( chassis_ . parking_brake ( ) | | CheckSafetyError ( chassis_detail ) ) { <nl> - chassis_ . mutable_engage_advice ( ) - > set_advice ( <nl> - apollo : : common : : EngageAdvice : : DISALLOW_ENGAGE ) ; <nl> - chassis_ . mutable_engage_advice ( ) - > set_reason ( <nl> - " Vehicle is not in a safe state to engage ! " ) ; <nl> - } else { <nl> - chassis_ . mutable_engage_advice ( ) - > set_advice ( <nl> - apollo : : common : : EngageAdvice : : READY_TO_ENGAGE ) ; <nl> - } <nl> return chassis_ ; <nl> } <nl> <nl>
|
canbus : use transit setup there
|
ApolloAuto/apollo
|
468058386a8f8f327ac513e3aae43d6b23f70e1c
|
2018-12-13T23:18:31Z
|
mmm a / DEPS <nl> ppp b / DEPS <nl> deps = { <nl> " v8 / third_party / icu " : <nl> Var ( " git_url " ) + " / chromium / deps / icu . git " + " @ " + " 8d342a405be5ae8aacb1e16f0bc31c3a4fbf26a2 " , <nl> " v8 / buildtools " : <nl> - Var ( " git_url " ) + " / chromium / buildtools . git " + " @ " + " 0f8e6e4b126ee88137930a0ae4776c4741808740 " , <nl> + Var ( " git_url " ) + " / chromium / buildtools . git " + " @ " + " cf8c4332f5c9d0da4b4782d7f0122df74a16819b " , <nl> " v8 / base / trace_event / common " : <nl> Var ( " git_url " ) + " / chromium / src / base / trace_event / common . git " + " @ " + " d83d44b13d07c2fd0a40101a7deef9b93b841732 " , <nl> " v8 / tools / swarming_client " : <nl> - Var ( ' git_url ' ) + ' / external / swarming . client . git ' + ' @ ' + " 9cdd76171e517a430a72dcd7d66ade67e109aa00 " , <nl> + Var ( ' git_url ' ) + ' / external / swarming . client . git ' + ' @ ' + " 0b908f18767c8304dc089454bc1c91755d21f1f5 " , <nl> " v8 / testing / gtest " : <nl> Var ( " git_url " ) + " / external / github . com / google / googletest . git " + " @ " + " 6f8a66431cb592dad629028a50b3dd418a408c87 " , <nl> " v8 / testing / gmock " : <nl> deps = { <nl> " v8 / test / test262 / data " : <nl> Var ( " git_url " ) + " / external / github . com / tc39 / test262 . git " + " @ " + " 67ba34b03a46bac4254223ae25f42c7b959540f0 " , <nl> " v8 / tools / clang " : <nl> - Var ( " git_url " ) + " / chromium / src / tools / clang . git " + " @ " + " 9c45873bbb82dc33f5f88f5c7dbc06ee9ecc7e8f " , <nl> + Var ( " git_url " ) + " / chromium / src / tools / clang . git " + " @ " + " e47364ad9fb37e8255a7a5cdf7891781b3f8256e " , <nl> } <nl> <nl> deps_os = { <nl>
|
Update V8 DEPS .
|
v8/v8
|
adb2fa879346b10d96b4c4a1de09845432a5186a
|
2016-01-22T04:22:39Z
|
mmm a / include / swift / AST / Module . h <nl> ppp b / include / swift / AST / Module . h <nl> class ModuleDecl : public DeclContext , public TypeDecl { <nl> void <nl> getImportedModulesForLookup ( SmallVectorImpl < ImportedModule > & imports ) const ; <nl> <nl> + / / / Has \ p module been imported via an ' @ _implementationOnly ' import <nl> + / / / instead of another kind of import ? <nl> + / / / <nl> + / / / This assumes that \ p module was imported . <nl> + bool isImportedImplementationOnly ( const ModuleDecl * module ) const ; <nl> + <nl> / / / Uniques the items in \ p imports , ignoring the source locations of the <nl> / / / access paths . <nl> / / / <nl> mmm a / lib / AST / ASTPrinter . cpp <nl> ppp b / lib / AST / ASTPrinter . cpp <nl> PrintOptions PrintOptions : : printSwiftInterfaceFile ( bool preferTypeRepr , <nl> if ( auto * ED = dyn_cast < ExtensionDecl > ( D ) ) { <nl> if ( ! shouldPrint ( ED - > getExtendedNominal ( ) , options ) ) <nl> return false ; <nl> + <nl> + / / Skip extensions to implementation - only imported types that have <nl> + / / no public members . <nl> + auto localModule = ED - > getParentModule ( ) ; <nl> + auto nominalModule = ED - > getExtendedNominal ( ) - > getParentModule ( ) ; <nl> + if ( localModule ! = nominalModule & & <nl> + localModule - > isImportedImplementationOnly ( nominalModule ) ) { <nl> + <nl> + bool shouldPrintMembers = llvm : : any_of ( <nl> + ED - > getMembers ( ) , <nl> + [ & ] ( const Decl * member ) - > bool { <nl> + return shouldPrint ( member , options ) ; <nl> + } ) ; <nl> + <nl> + if ( ! shouldPrintMembers ) <nl> + return false ; <nl> + } <nl> + <nl> for ( const Requirement & req : ED - > getGenericRequirements ( ) ) { <nl> if ( ! isPublicOrUsableFromInline ( req . getFirstType ( ) ) ) <nl> return false ; <nl> mmm a / lib / AST / Module . cpp <nl> ppp b / lib / AST / Module . cpp <nl> bool SourceFile : : isImportedImplementationOnly ( const ModuleDecl * module ) const { <nl> return ! imports . isImportedBy ( module , getParentModule ( ) ) ; <nl> } <nl> <nl> + bool ModuleDecl : : isImportedImplementationOnly ( const ModuleDecl * module ) const { <nl> + auto & imports = getASTContext ( ) . getImportCache ( ) ; <nl> + <nl> + / / Look through non - implementation - only imports to see if module is imported <nl> + / / in some other way . Otherwise we assume it ' s implementation - only imported . <nl> + ModuleDecl : : ImportFilter filter = { <nl> + ModuleDecl : : ImportFilterKind : : Public , <nl> + ModuleDecl : : ImportFilterKind : : Private , <nl> + ModuleDecl : : ImportFilterKind : : SPIAccessControl , <nl> + ModuleDecl : : ImportFilterKind : : ShadowedBySeparateOverlay } ; <nl> + SmallVector < ModuleDecl : : ImportedModule , 4 > results ; <nl> + getImportedModules ( results , filter ) ; <nl> + <nl> + for ( auto & desc : results ) { <nl> + if ( imports . isImportedBy ( module , desc . importedModule ) ) <nl> + return false ; <nl> + } <nl> + <nl> + return true ; <nl> + } <nl> + <nl> void SourceFile : : lookupImportedSPIGroups ( <nl> const ModuleDecl * importedModule , <nl> llvm : : SmallSetVector < Identifier , 4 > & spiGroups ) const { <nl> new file mode 100644 <nl> index 000000000000 . . 65323afcbcf8 <nl> mmm / dev / null <nl> ppp b / test / ModuleInterface / empty - extension . swift <nl> <nl> + / / Test that we don ' t print extensions to implementation - only imported types . <nl> + <nl> + / / RUN : % empty - directory ( % t ) <nl> + <nl> + / / RUN : % target - swift - frontend - emit - module % s - DIOI_LIB - module - name IOILib - emit - module - path % t / IOILib . swiftmodule <nl> + / / RUN : % target - swift - frontend - emit - module % s - DEXPORTED_LIB - module - name IndirectLib - emit - module - path % t / IndirectLib . swiftmodule - I % t <nl> + / / RUN : % target - swift - frontend - emit - module % s - DLIB - module - name Lib - emit - module - path % t / Lib . swiftmodule - I % t <nl> + <nl> + / / RUN : % target - swift - frontend - typecheck - emit - module - interface - path % t / out . swiftinterface % s - I % t - swift - version 5 - enable - library - evolution <nl> + / / RUN : % FileCheck % s < % t / out . swiftinterface <nl> + <nl> + # if IOI_LIB <nl> + <nl> + public struct IOIImportedType { <nl> + public func foo ( ) { } <nl> + } <nl> + <nl> + # elseif EXPORTED_LIB <nl> + <nl> + public struct ExportedType { <nl> + public func foo ( ) { } <nl> + } <nl> + <nl> + # elseif LIB <nl> + <nl> + @ _exported import IndirectLib <nl> + <nl> + public struct NormalImportedType { <nl> + public func foo ( ) { } <nl> + } <nl> + <nl> + # else / / Client <nl> + <nl> + import Lib <nl> + @ _implementationOnly import IOILib <nl> + <nl> + public protocol PublicProto { <nl> + func foo ( ) <nl> + } <nl> + extension IOIImportedType : PublicProto { } <nl> + / / CHECK - NOT : IOIImportedType <nl> + <nl> + extension NormalImportedType : PublicProto { } <nl> + / / CHECK : extension NormalImportedType <nl> + <nl> + extension ExportedType : PublicProto { } <nl> + / / CHECK : extension ExportedType <nl> + <nl> + # endif <nl> new file mode 100644 <nl> index 000000000000 . . f885a21d07f6 <nl> mmm / dev / null <nl> ppp b / test / SPI / Inputs / ioi_helper . swift <nl> @ @ - 0 , 0 + 1 @ @ <nl> + public struct IOIPublicStruct { } <nl> mmm a / test / SPI / experimental_spi_imports_swiftinterface . swift <nl> ppp b / test / SPI / experimental_spi_imports_swiftinterface . swift <nl> <nl> <nl> / / / Generate 3 empty modules . <nl> / / RUN : touch % t / empty . swift <nl> - / / RUN : % target - swift - frontend - emit - module % t / empty . swift - module - name ExperimentalImported - emit - module - path % t / ExperimentalImported . swiftmodule - swift - version 5 - enable - library - evolution <nl> + / / RUN : % target - swift - frontend - emit - module % S / Inputs / ioi_helper . swift - module - name ExperimentalImported - emit - module - path % t / ExperimentalImported . swiftmodule - swift - version 5 - enable - library - evolution <nl> / / RUN : % target - swift - frontend - emit - module % t / empty . swift - module - name IOIImported - emit - module - path % t / IOIImported . swiftmodule - swift - version 5 - enable - library - evolution <nl> / / RUN : % target - swift - frontend - emit - module % t / empty . swift - module - name SPIImported - emit - module - path % t / SPIImported . swiftmodule - swift - version 5 - enable - library - evolution <nl> <nl> <nl> @ _spi ( dummy ) import SPIImported <nl> / / CHECK - PUBLIC : { { ^ } } import SPIImported <nl> / / CHECK - PRIVATE : @ _spi { { . * } } import SPIImported <nl> + <nl> + @ _spi ( X ) <nl> + extension IOIPublicStruct { <nl> + public func foo ( ) { } <nl> + } <nl> + / / CHECK - PUBLIC - NOT : IOIPublicStruct <nl> + / / CHECK - PRIVATE : @ _spi { { . * } } extension IOIPublicStruct <nl> mmm a / test / SPI / private_swiftinterface . swift <nl> ppp b / test / SPI / private_swiftinterface . swift <nl> <nl> <nl> / / RUN : % empty - directory ( % t ) <nl> / / RUN : % target - swift - frontend - emit - module % S / Inputs / spi_helper . swift - module - name SPIHelper - emit - module - path % t / SPIHelper . swiftmodule - swift - version 5 - enable - library - evolution - emit - module - interface - path % t / SPIHelper . swiftinterface - emit - private - module - interface - path % t / SPIHelper . private . swiftinterface <nl> + / / RUN : % target - swift - frontend - emit - module % S / Inputs / ioi_helper . swift - module - name IOIHelper - emit - module - path % t / IOIHelper . swiftmodule - swift - version 5 - enable - library - evolution - emit - module - interface - path % t / IOIHelper . swiftinterface - emit - private - module - interface - path % t / IOIHelper . private . swiftinterface <nl> <nl> / / / Make sure that the public swiftinterface of spi_helper doesn ' t leak SPI . <nl> / / RUN : % FileCheck - check - prefix = CHECK - HELPER % s < % t / SPIHelper . swiftinterface <nl> <nl> / / CHECK - PUBLIC : import SPIHelper <nl> / / CHECK - PRIVATE : @ _spi ( OtherSPI ) @ _spi ( HelperSPI ) import SPIHelper <nl> <nl> + @ _implementationOnly import IOIHelper <nl> public func foo ( ) { } <nl> / / CHECK - PUBLIC : foo ( ) <nl> / / CHECK - PRIVATE : foo ( ) <nl> extension PublicType : SPIProto2 where T : SPIProto2 { } <nl> / / CHECK - PRIVATE : extension PublicType : { { . * } } . SPIProto2 where T : { { . * } } . SPIProto2 <nl> / / CHECK - PUBLIC - NOT : _ConstraintThatIsNotPartOfTheAPIOfThisLibrary <nl> <nl> + public protocol LocalPublicProto { } <nl> + extension IOIPublicStruct : LocalPublicProto { } <nl> + / / CHECK - PRIVATE - NOT : IOIPublicStruct <nl> + / / CHECK - PUBLIC - NOT : IOIPublicStruct <nl> + <nl> / / The dummy conformance should be only in the private swiftinterface for <nl> / / SPI extensions . <nl> @ _spi ( LocalSPI ) <nl>
|
Merge remote - tracking branch ' origin / master ' into master - next
|
apple/swift
|
24de3c75ac9cd340faff19cbe12496727dc0b2a2
|
2020-08-24T17:55:48Z
|
mmm a / src / core / ext / filters / client_channel / lb_policy / xds / xds_cluster_impl . cc <nl> ppp b / src / core / ext / filters / client_channel / lb_policy / xds / xds_cluster_impl . cc <nl> <nl> # include " src / core / lib / gpr / string . h " <nl> # include " src / core / lib / gprpp / orphanable . h " <nl> # include " src / core / lib / gprpp / ref_counted_ptr . h " <nl> + # include " src / core / lib / gprpp / sync . h " <nl> # include " src / core / lib / iomgr / work_serializer . h " <nl> <nl> namespace grpc_core { <nl> TraceFlag grpc_xds_cluster_impl_lb_trace ( false , " xds_cluster_impl_lb " ) ; <nl> <nl> namespace { <nl> <nl> + / / <nl> + / / global circuit breaker atomic map <nl> + / / <nl> + <nl> + class CircuitBreakerCallCounterMap { <nl> + public : <nl> + using Key = <nl> + std : : pair < std : : string / * cluster * / , std : : string / * eds_service_name * / > ; <nl> + <nl> + class CallCounter : public RefCounted < CallCounter > { <nl> + public : <nl> + explicit CallCounter ( Key key ) : key_ ( std : : move ( key ) ) { } <nl> + ~ CallCounter ( ) override ; <nl> + <nl> + uint32_t Increment ( ) { return concurrent_requests_ . FetchAdd ( 1 ) ; } <nl> + void Decrement ( ) { concurrent_requests_ . FetchSub ( 1 ) ; } <nl> + <nl> + private : <nl> + Key key_ ; <nl> + Atomic < uint32_t > concurrent_requests_ { 0 } ; <nl> + } ; <nl> + <nl> + RefCountedPtr < CallCounter > GetOrCreate ( const std : : string & cluster , <nl> + const std : : string & eds_service_name ) ; <nl> + <nl> + private : <nl> + Mutex mu_ ; <nl> + std : : map < Key , CallCounter * > map_ ; <nl> + } ; <nl> + <nl> + CircuitBreakerCallCounterMap * g_call_counter_map = nullptr ; <nl> + <nl> + RefCountedPtr < CircuitBreakerCallCounterMap : : CallCounter > <nl> + CircuitBreakerCallCounterMap : : GetOrCreate ( const std : : string & cluster , <nl> + const std : : string & eds_service_name ) { <nl> + Key key ( cluster , eds_service_name ) ; <nl> + RefCountedPtr < CallCounter > result ; <nl> + MutexLock lock ( & mu_ ) ; <nl> + auto it = map_ . find ( key ) ; <nl> + if ( it = = map_ . end ( ) ) { <nl> + it = map_ . insert ( { key , nullptr } ) . first ; <nl> + } else { <nl> + result = it - > second - > RefIfNonZero ( ) ; <nl> + } <nl> + if ( result = = nullptr ) { <nl> + result = MakeRefCounted < CallCounter > ( std : : move ( key ) ) ; <nl> + it - > second = result . get ( ) ; <nl> + } <nl> + return result ; <nl> + } <nl> + <nl> + CircuitBreakerCallCounterMap : : CallCounter : : ~ CallCounter ( ) { <nl> + MutexLock lock ( & g_call_counter_map - > mu_ ) ; <nl> + auto it = g_call_counter_map - > map_ . find ( key_ ) ; <nl> + if ( it ! = g_call_counter_map - > map_ . end ( ) & & it - > second = = this ) { <nl> + g_call_counter_map - > map_ . erase ( it ) ; <nl> + } <nl> + } <nl> + <nl> + / / <nl> + / / LB policy <nl> + / / <nl> + <nl> constexpr char kXdsClusterImpl [ ] = " xds_cluster_impl_experimental " ; <nl> <nl> / / TODO ( donnadionne ) : Check to see if circuit breaking is enabled , this will be <nl> class XdsClusterImplLb : public LoadBalancingPolicy { <nl> / / A picker that wraps the picker from the child to perform drops . <nl> class Picker : public SubchannelPicker { <nl> public : <nl> - Picker ( RefCountedPtr < XdsClusterImplLb > xds_cluster_impl_lb , <nl> + Picker ( XdsClusterImplLb * xds_cluster_impl_lb , <nl> RefCountedPtr < RefCountedPicker > picker ) ; <nl> <nl> PickResult Pick ( PickArgs args ) override ; <nl> <nl> private : <nl> - RefCountedPtr < XdsClusterImplLb > xds_cluster_impl_lb_ ; <nl> + RefCountedPtr < CircuitBreakerCallCounterMap : : CallCounter > call_counter_ ; <nl> bool xds_circuit_breaking_enabled_ ; <nl> uint32_t max_concurrent_requests_ ; <nl> RefCountedPtr < XdsApi : : EdsUpdate : : DropConfig > drop_config_ ; <nl> class XdsClusterImplLb : public LoadBalancingPolicy { <nl> / / Current config from the resolver . <nl> RefCountedPtr < XdsClusterImplLbConfig > config_ ; <nl> <nl> - / / Current concurrent number of requests ; <nl> - Atomic < uint32_t > concurrent_requests_ { 0 } ; <nl> + / / Current concurrent number of requests . <nl> + RefCountedPtr < CircuitBreakerCallCounterMap : : CallCounter > call_counter_ ; <nl> <nl> / / Internal state . <nl> bool shutting_down_ = false ; <nl> class XdsClusterImplLb : public LoadBalancingPolicy { <nl> / / XdsClusterImplLb : : Picker <nl> / / <nl> <nl> - XdsClusterImplLb : : Picker : : Picker ( <nl> - RefCountedPtr < XdsClusterImplLb > xds_cluster_impl_lb , <nl> - RefCountedPtr < RefCountedPicker > picker ) <nl> - : xds_cluster_impl_lb_ ( std : : move ( xds_cluster_impl_lb ) ) , <nl> + XdsClusterImplLb : : Picker : : Picker ( XdsClusterImplLb * xds_cluster_impl_lb , <nl> + RefCountedPtr < RefCountedPicker > picker ) <nl> + : call_counter_ ( xds_cluster_impl_lb - > call_counter_ ) , <nl> xds_circuit_breaking_enabled_ ( XdsCircuitBreakingEnabled ( ) ) , <nl> max_concurrent_requests_ ( <nl> - xds_cluster_impl_lb_ - > config_ - > max_concurrent_requests ( ) ) , <nl> - drop_config_ ( xds_cluster_impl_lb_ - > config_ - > drop_config ( ) ) , <nl> - drop_stats_ ( xds_cluster_impl_lb_ - > drop_stats_ ) , <nl> + xds_cluster_impl_lb - > config_ - > max_concurrent_requests ( ) ) , <nl> + drop_config_ ( xds_cluster_impl_lb - > config_ - > drop_config ( ) ) , <nl> + drop_stats_ ( xds_cluster_impl_lb - > drop_stats_ ) , <nl> picker_ ( std : : move ( picker ) ) { <nl> if ( GRPC_TRACE_FLAG_ENABLED ( grpc_xds_cluster_impl_lb_trace ) ) { <nl> gpr_log ( GPR_INFO , " [ xds_cluster_impl_lb % p ] constructed new picker % p " , <nl> - xds_cluster_impl_lb_ . get ( ) , this ) ; <nl> + xds_cluster_impl_lb , this ) ; <nl> } <nl> } <nl> <nl> LoadBalancingPolicy : : PickResult XdsClusterImplLb : : Picker : : Pick ( <nl> return result ; <nl> } <nl> / / Handle circuit breaking . <nl> - uint32_t current = xds_cluster_impl_lb_ - > concurrent_requests_ . FetchAdd ( 1 ) ; <nl> + uint32_t current = call_counter_ - > Increment ( ) ; <nl> if ( xds_circuit_breaking_enabled_ ) { <nl> / / Check and see if we exceeded the max concurrent requests count . <nl> if ( current > = max_concurrent_requests_ ) { <nl> - xds_cluster_impl_lb_ - > concurrent_requests_ . FetchSub ( 1 ) ; <nl> + call_counter_ - > Decrement ( ) ; <nl> if ( drop_stats_ ! = nullptr ) drop_stats_ - > AddUncategorizedDrops ( ) ; <nl> PickResult result ; <nl> result . type = PickResult : : PICK_COMPLETE ; <nl> LoadBalancingPolicy : : PickResult XdsClusterImplLb : : Picker : : Pick ( <nl> GRPC_ERROR_CREATE_FROM_STATIC_STRING ( <nl> " xds_cluster_impl picker not given any child picker " ) , <nl> GRPC_ERROR_INT_GRPC_STATUS , GRPC_STATUS_INTERNAL ) ; <nl> - xds_cluster_impl_lb_ - > concurrent_requests_ . FetchSub ( 1 ) ; <nl> + call_counter_ - > Decrement ( ) ; <nl> return result ; <nl> } <nl> / / Not dropping , so delegate to child picker . <nl> LoadBalancingPolicy : : PickResult XdsClusterImplLb : : Picker : : Pick ( <nl> result . subchannel = subchannel_wrapper - > wrapped_subchannel ( ) ; <nl> } <nl> / / Intercept the recv_trailing_metadata op to record call completion . <nl> - XdsClusterImplLb * xds_cluster_impl_lb = static_cast < XdsClusterImplLb * > ( <nl> - xds_cluster_impl_lb_ - > Ref ( DEBUG_LOCATION , " DropPickPicker + call " ) <nl> - . release ( ) ) ; <nl> + auto * call_counter = call_counter_ - > Ref ( DEBUG_LOCATION , " call " ) . release ( ) ; <nl> auto original_recv_trailing_metadata_ready = <nl> result . recv_trailing_metadata_ready ; <nl> result . recv_trailing_metadata_ready = <nl> / / Note : This callback does not run in either the control plane <nl> / / work serializer or in the data plane mutex . <nl> - [ locality_stats , original_recv_trailing_metadata_ready , <nl> - xds_cluster_impl_lb ] ( grpc_error * error , MetadataInterface * metadata , <nl> - CallState * call_state ) { <nl> + [ locality_stats , original_recv_trailing_metadata_ready , call_counter ] ( <nl> + grpc_error * error , MetadataInterface * metadata , <nl> + CallState * call_state ) { <nl> / / Record call completion for load reporting . <nl> if ( locality_stats ! = nullptr ) { <nl> const bool call_failed = error ! = GRPC_ERROR_NONE ; <nl> LoadBalancingPolicy : : PickResult XdsClusterImplLb : : Picker : : Pick ( <nl> locality_stats - > Unref ( DEBUG_LOCATION , " LocalityStats + call " ) ; <nl> } <nl> / / Decrement number of calls in flight . <nl> - xds_cluster_impl_lb - > concurrent_requests_ . FetchSub ( 1 ) ; <nl> - xds_cluster_impl_lb - > Unref ( DEBUG_LOCATION , " DropPickPicker + call " ) ; <nl> + call_counter - > Decrement ( ) ; <nl> + call_counter - > Unref ( DEBUG_LOCATION , " call " ) ; <nl> / / Invoke the original recv_trailing_metadata_ready callback , if any . <nl> if ( original_recv_trailing_metadata_ready ! = nullptr ) { <nl> original_recv_trailing_metadata_ready ( error , metadata , call_state ) ; <nl> LoadBalancingPolicy : : PickResult XdsClusterImplLb : : Picker : : Pick ( <nl> / / where a pick fails . This is challenging , because we don ' t know which <nl> / / picks are for wait_for_ready RPCs or how many times we ' ll return a <nl> / / failure for the same wait_for_ready RPC . <nl> - xds_cluster_impl_lb_ - > concurrent_requests_ . FetchSub ( 1 ) ; <nl> + call_counter_ - > Decrement ( ) ; <nl> } <nl> return result ; <nl> } <nl> void XdsClusterImplLb : : UpdateLocked ( UpdateArgs args ) { <nl> config_ - > lrs_load_reporting_server_name ( ) . value ( ) , <nl> config_ - > cluster_name ( ) , config_ - > eds_service_name ( ) ) ; <nl> } <nl> + call_counter_ = g_call_counter_map - > GetOrCreate ( <nl> + config_ - > cluster_name ( ) , config_ - > eds_service_name ( ) ) ; <nl> } else { <nl> / / Cluster name , EDS service name , and LRS server name should never <nl> / / change , because the EDS policy above us should be swapped out if <nl> void XdsClusterImplLb : : MaybeUpdatePickerLocked ( ) { <nl> / / If we ' re dropping all calls , report READY , regardless of what ( or <nl> / / whether ) the child has reported . <nl> if ( config_ - > drop_config ( ) ! = nullptr & & config_ - > drop_config ( ) - > drop_all ( ) ) { <nl> - auto drop_picker = <nl> - absl : : make_unique < Picker > ( Ref ( DEBUG_LOCATION , " Picker " ) , picker_ ) ; <nl> + auto drop_picker = absl : : make_unique < Picker > ( this , picker_ ) ; <nl> if ( GRPC_TRACE_FLAG_ENABLED ( grpc_xds_cluster_impl_lb_trace ) ) { <nl> gpr_log ( GPR_INFO , <nl> " [ xds_cluster_impl_lb % p ] updating connectivity ( drop all ) : " <nl> void XdsClusterImplLb : : MaybeUpdatePickerLocked ( ) { <nl> } <nl> / / Otherwise , update only if we have a child picker . <nl> if ( picker_ ! = nullptr ) { <nl> - auto drop_picker = <nl> - absl : : make_unique < Picker > ( Ref ( DEBUG_LOCATION , " Picker " ) , picker_ ) ; <nl> + auto drop_picker = absl : : make_unique < Picker > ( this , picker_ ) ; <nl> if ( GRPC_TRACE_FLAG_ENABLED ( grpc_xds_cluster_impl_lb_trace ) ) { <nl> gpr_log ( GPR_INFO , <nl> " [ xds_cluster_impl_lb % p ] updating connectivity : state = % s " <nl> class XdsClusterImplLbFactory : public LoadBalancingPolicyFactory { <nl> / / <nl> <nl> void grpc_lb_policy_xds_cluster_impl_init ( ) { <nl> + grpc_core : : g_call_counter_map = new grpc_core : : CircuitBreakerCallCounterMap ( ) ; <nl> grpc_core : : LoadBalancingPolicyRegistry : : Builder : : <nl> RegisterLoadBalancingPolicyFactory ( <nl> absl : : make_unique < grpc_core : : XdsClusterImplLbFactory > ( ) ) ; <nl> } <nl> <nl> - void grpc_lb_policy_xds_cluster_impl_shutdown ( ) { } <nl> + void grpc_lb_policy_xds_cluster_impl_shutdown ( ) { <nl> + delete grpc_core : : g_call_counter_map ; <nl> + } <nl> mmm a / test / cpp / end2end / xds_end2end_test . cc <nl> ppp b / test / cpp / end2end / xds_end2end_test . cc <nl> class XdsEnd2endTest : public : : testing : : TestWithParam < TestType > { <nl> } <nl> <nl> std : : shared_ptr < Channel > CreateChannel ( <nl> - int failover_timeout = 0 , const char * server_name = kServerName ) { <nl> + int failover_timeout = 0 , const char * server_name = kServerName , <nl> + grpc_core : : FakeResolverResponseGenerator * response_generator = nullptr ) { <nl> ChannelArguments args ; <nl> if ( failover_timeout > 0 ) { <nl> args . SetInt ( GRPC_ARG_PRIORITY_FAILOVER_TIMEOUT_MS , failover_timeout ) ; <nl> class XdsEnd2endTest : public : : testing : : TestWithParam < TestType > { <nl> / / If the parent channel is using the fake resolver , we inject the <nl> / / response generator here . <nl> if ( ! GetParam ( ) . use_xds_resolver ( ) ) { <nl> + if ( response_generator = = nullptr ) { <nl> + response_generator = response_generator_ . get ( ) ; <nl> + } <nl> args . SetPointer ( GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR , <nl> - response_generator_ . get ( ) ) ; <nl> + response_generator ) ; <nl> } <nl> std : : string uri = absl : : StrCat ( <nl> GetParam ( ) . use_xds_resolver ( ) ? " xds " : " fake " , " : / / / " , server_name ) ; <nl> class XdsEnd2endTest : public : : testing : : TestWithParam < TestType > { <nl> return addresses ; <nl> } <nl> <nl> - void SetNextResolution ( const std : : vector < int > & ports ) { <nl> + void SetNextResolution ( <nl> + const std : : vector < int > & ports , <nl> + grpc_core : : FakeResolverResponseGenerator * response_generator = nullptr ) { <nl> if ( GetParam ( ) . use_xds_resolver ( ) ) return ; / / Not used with xds resolver . <nl> grpc_core : : ExecCtx exec_ctx ; <nl> grpc_core : : Resolver : : Result result ; <nl> class XdsEnd2endTest : public : : testing : : TestWithParam < TestType > { <nl> grpc_core : : ServiceConfig : : Create ( nullptr , service_config_json , & error ) ; <nl> ASSERT_EQ ( error , GRPC_ERROR_NONE ) < < grpc_error_string ( error ) ; <nl> ASSERT_NE ( result . service_config . get ( ) , nullptr ) ; <nl> - response_generator_ - > SetResponse ( std : : move ( result ) ) ; <nl> + if ( response_generator = = nullptr ) { <nl> + response_generator = response_generator_ . get ( ) ; <nl> + } <nl> + response_generator - > SetResponse ( std : : move ( result ) ) ; <nl> } <nl> <nl> void SetNextResolutionForLbChannelAllBalancers ( <nl> class XdsEnd2endTest : public : : testing : : TestWithParam < TestType > { <nl> std : : shared_ptr < LrsServiceImpl > lrs_service_ ; <nl> } ; <nl> <nl> + class LongRunningRpc { <nl> + public : <nl> + void StartRpc ( grpc : : testing : : EchoTestService : : Stub * stub ) { <nl> + sender_thread_ = std : : thread ( [ this , stub ] ( ) { <nl> + EchoResponse response ; <nl> + EchoRequest request ; <nl> + request . mutable_param ( ) - > set_client_cancel_after_us ( 1 * 1000 * 1000 ) ; <nl> + request . set_message ( kRequestMessage ) ; <nl> + stub - > Echo ( & context_ , request , & response ) ; <nl> + } ) ; <nl> + } <nl> + <nl> + void CancelRpc ( ) { <nl> + context_ . TryCancel ( ) ; <nl> + sender_thread_ . join ( ) ; <nl> + } <nl> + <nl> + private : <nl> + std : : thread sender_thread_ ; <nl> + ClientContext context_ ; <nl> + } ; <nl> + <nl> const size_t num_backends_ ; <nl> const size_t num_balancers_ ; <nl> const int client_load_reporting_interval_seconds_ ; <nl> TEST_P ( XdsResolverOnlyTest , DefaultRouteSpecifiesSlashPrefix ) { <nl> } <nl> <nl> TEST_P ( XdsResolverOnlyTest , CircuitBreaking ) { <nl> - class TestRpc { <nl> - public : <nl> - TestRpc ( ) { } <nl> - <nl> - void StartRpc ( grpc : : testing : : EchoTestService : : Stub * stub ) { <nl> - sender_thread_ = std : : thread ( [ this , stub ] ( ) { <nl> - EchoResponse response ; <nl> - EchoRequest request ; <nl> - request . mutable_param ( ) - > set_client_cancel_after_us ( 1 * 1000 * 1000 ) ; <nl> - request . set_message ( kRequestMessage ) ; <nl> - status_ = stub - > Echo ( & context_ , request , & response ) ; <nl> - } ) ; <nl> - } <nl> - <nl> - void CancelRpc ( ) { <nl> - context_ . TryCancel ( ) ; <nl> - sender_thread_ . join ( ) ; <nl> - } <nl> - <nl> - private : <nl> - std : : thread sender_thread_ ; <nl> - ClientContext context_ ; <nl> - Status status_ ; <nl> - } ; <nl> - <nl> gpr_setenv ( " GRPC_XDS_EXPERIMENTAL_CIRCUIT_BREAKING " , " true " ) ; <nl> constexpr size_t kMaxConcurrentRequests = 10 ; <nl> SetNextResolution ( { } ) ; <nl> TEST_P ( XdsResolverOnlyTest , CircuitBreaking ) { <nl> threshold - > mutable_max_requests ( ) - > set_value ( kMaxConcurrentRequests ) ; <nl> balancers_ [ 0 ] - > ads_service ( ) - > SetCdsResource ( cluster ) ; <nl> / / Send exactly max_concurrent_requests long RPCs . <nl> - TestRpc rpcs [ kMaxConcurrentRequests ] ; <nl> + LongRunningRpc rpcs [ kMaxConcurrentRequests ] ; <nl> for ( size_t i = 0 ; i < kMaxConcurrentRequests ; + + i ) { <nl> rpcs [ i ] . StartRpc ( stub_ . get ( ) ) ; <nl> } <nl> TEST_P ( XdsResolverOnlyTest , CircuitBreaking ) { <nl> gpr_unsetenv ( " GRPC_XDS_EXPERIMENTAL_CIRCUIT_BREAKING " ) ; <nl> } <nl> <nl> - TEST_P ( XdsResolverOnlyTest , CircuitBreakingDisabled ) { <nl> - class TestRpc { <nl> - public : <nl> - TestRpc ( ) { } <nl> - <nl> - void StartRpc ( grpc : : testing : : EchoTestService : : Stub * stub ) { <nl> - sender_thread_ = std : : thread ( [ this , stub ] ( ) { <nl> - EchoResponse response ; <nl> - EchoRequest request ; <nl> - request . mutable_param ( ) - > set_client_cancel_after_us ( 1 * 1000 * 1000 ) ; <nl> - request . set_message ( kRequestMessage ) ; <nl> - status_ = stub - > Echo ( & context_ , request , & response ) ; <nl> - } ) ; <nl> - } <nl> - <nl> - void CancelRpc ( ) { <nl> - context_ . TryCancel ( ) ; <nl> - sender_thread_ . join ( ) ; <nl> - } <nl> - <nl> - private : <nl> - std : : thread sender_thread_ ; <nl> - ClientContext context_ ; <nl> - Status status_ ; <nl> - } ; <nl> + TEST_P ( XdsResolverOnlyTest , CircuitBreakingMultipleChannelsShareCallCounter ) { <nl> + gpr_setenv ( " GRPC_XDS_EXPERIMENTAL_CIRCUIT_BREAKING " , " true " ) ; <nl> + constexpr size_t kMaxConcurrentRequests = 10 ; <nl> + / / Populate new EDS resources . <nl> + AdsServiceImpl : : EdsResourceArgs args ( { <nl> + { " locality0 " , GetBackendPorts ( 0 , 1 ) } , <nl> + } ) ; <nl> + balancers_ [ 0 ] - > ads_service ( ) - > SetEdsResource ( <nl> + AdsServiceImpl : : BuildEdsResource ( args ) ) ; <nl> + / / Update CDS resource to set max concurrent request . <nl> + CircuitBreakers circuit_breaks ; <nl> + Cluster cluster = balancers_ [ 0 ] - > ads_service ( ) - > default_cluster ( ) ; <nl> + auto * threshold = cluster . mutable_circuit_breakers ( ) - > add_thresholds ( ) ; <nl> + threshold - > set_priority ( RoutingPriority : : DEFAULT ) ; <nl> + threshold - > mutable_max_requests ( ) - > set_value ( kMaxConcurrentRequests ) ; <nl> + balancers_ [ 0 ] - > ads_service ( ) - > SetCdsResource ( cluster ) ; <nl> + / / Create second channel . <nl> + auto response_generator2 = <nl> + grpc_core : : MakeRefCounted < grpc_core : : FakeResolverResponseGenerator > ( ) ; <nl> + auto channel2 = CreateChannel ( <nl> + / * failover_timeout = * / 0 , / * server_name = * / kServerName , <nl> + response_generator2 . get ( ) ) ; <nl> + auto stub2 = grpc : : testing : : EchoTestService : : NewStub ( channel2 ) ; <nl> + / / Set resolution results for both channels and for the xDS channel . <nl> + SetNextResolution ( { } ) ; <nl> + SetNextResolution ( { } , response_generator2 . get ( ) ) ; <nl> + SetNextResolutionForLbChannelAllBalancers ( ) ; <nl> + / / Send exactly max_concurrent_requests long RPCs , alternating between <nl> + / / the two channels . <nl> + LongRunningRpc rpcs [ kMaxConcurrentRequests ] ; <nl> + for ( size_t i = 0 ; i < kMaxConcurrentRequests ; + + i ) { <nl> + rpcs [ i ] . StartRpc ( i % 2 = = 0 ? stub_ . get ( ) : stub2 . get ( ) ) ; <nl> + } <nl> + / / Wait for all RPCs to be in flight . <nl> + while ( backends_ [ 0 ] - > backend_service ( ) - > RpcsWaitingForClientCancel ( ) < <nl> + kMaxConcurrentRequests ) { <nl> + gpr_sleep_until ( gpr_time_add ( gpr_now ( GPR_CLOCK_REALTIME ) , <nl> + gpr_time_from_micros ( 1 * 1000 , GPR_TIMESPAN ) ) ) ; <nl> + } <nl> + / / Sending a RPC now should fail , the error message should tell us <nl> + / / we hit the max concurrent requests limit and got dropped . <nl> + Status status = SendRpc ( ) ; <nl> + EXPECT_FALSE ( status . ok ( ) ) ; <nl> + EXPECT_EQ ( status . error_message ( ) , " Call dropped by load balancing policy " ) ; <nl> + / / Cancel one RPC to allow another one through <nl> + rpcs [ 0 ] . CancelRpc ( ) ; <nl> + status = SendRpc ( ) ; <nl> + EXPECT_TRUE ( status . ok ( ) ) ; <nl> + for ( size_t i = 1 ; i < kMaxConcurrentRequests ; + + i ) { <nl> + rpcs [ i ] . CancelRpc ( ) ; <nl> + } <nl> + / / Make sure RPCs go to the correct backend : <nl> + EXPECT_EQ ( kMaxConcurrentRequests + 1 , <nl> + backends_ [ 0 ] - > backend_service ( ) - > request_count ( ) ) ; <nl> + gpr_unsetenv ( " GRPC_XDS_EXPERIMENTAL_CIRCUIT_BREAKING " ) ; <nl> + } <nl> <nl> + TEST_P ( XdsResolverOnlyTest , CircuitBreakingDisabled ) { <nl> constexpr size_t kMaxConcurrentRequests = 10 ; <nl> SetNextResolution ( { } ) ; <nl> SetNextResolutionForLbChannelAllBalancers ( ) ; <nl> TEST_P ( XdsResolverOnlyTest , CircuitBreakingDisabled ) { <nl> threshold - > mutable_max_requests ( ) - > set_value ( kMaxConcurrentRequests ) ; <nl> balancers_ [ 0 ] - > ads_service ( ) - > SetCdsResource ( cluster ) ; <nl> / / Send exactly max_concurrent_requests long RPCs . <nl> - TestRpc rpcs [ kMaxConcurrentRequests ] ; <nl> + LongRunningRpc rpcs [ kMaxConcurrentRequests ] ; <nl> for ( size_t i = 0 ; i < kMaxConcurrentRequests ; + + i ) { <nl> rpcs [ i ] . StartRpc ( stub_ . get ( ) ) ; <nl> } <nl>
|
Use a global atomic for circuit breaking call counter .
|
grpc/grpc
|
b607080400d1fbc298de7e5c6bccdcd91aa42f85
|
2020-10-19T22:15:32Z
|
mmm a / hphp / hack / src / globals / find_refs . ml <nl> ppp b / hphp / hack / src / globals / find_refs . ml <nl> <nl> * of patent rights can be found in the PATENTS file in the same directory . <nl> * <nl> * ) <nl> - open Utils <nl> <nl> ( * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ) <nl> ( * Find local references mode * ) <nl> let is_find_method_target pos = <nl> let l , start , end_ = Pos . info_pos pos in <nl> l = line & & start < = char_pos & & char_pos - 1 < = end_ <nl> <nl> - ( * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ) <nl> - ( * Find method references mode * ) <nl> - ( * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ) <nl> - <nl> - let ( find_refs_class_name : ( SSet . t option ) ref ) = ref None <nl> - let ( find_refs_method_name : string option ref ) = ref None <nl> - let find_refs_results = ref Pos . Map . empty <nl> - <nl> - let process_class_ref p class_name called_method_opt = <nl> - ( match ! find_refs_class_name , ! find_refs_method_name with <nl> - | Some c_names , None - > <nl> - if ( SSet . mem class_name c_names ) <nl> - then begin <nl> - let class_name = match called_method_opt with <nl> - | None - > class_name <nl> - | Some n - > class_name ^ " : : " ^ n in <nl> - find_refs_results : = Pos . Map . add p class_name ! find_refs_results <nl> - end ; <nl> - ( ) <nl> - | _ - > ( ) ) ; <nl> + let process_class_ref p class_name _ = <nl> if is_find_method_target p <nl> then begin <nl> find_method_at_cursor_result : = Some { name = class_name ; <nl> let process_class_ref p class_name called_method_opt = <nl> end <nl> <nl> let process_find_refs class_name method_name p = <nl> - ( match ( ! find_refs_class_name , ! find_refs_method_name , class_name ) with <nl> - | ( Some c_names , Some m_name , Some class_name ) - > <nl> - if m_name = method_name & & ( SSet . mem class_name c_names ) then <nl> - find_refs_results : = Pos . Map . add p ( class_name ^ " : : " ^ method_name ) <nl> - ! find_refs_results ; <nl> - ( ) <nl> - | ( None , Some m_name , None ) - > <nl> - if m_name = method_name then <nl> - find_refs_results : = Pos . Map . add p method_name <nl> - ! find_refs_results ; <nl> - ( ) <nl> - | _ - > ( ) <nl> - ) ; <nl> if is_find_method_target p <nl> then begin <nl> match class_name with <nl> let process_find_refs class_name method_name p = <nl> pos = p <nl> } <nl> end <nl> - <nl> + <nl> let process_var_ref p name = <nl> if is_find_method_target p <nl> then begin <nl> mmm a / hphp / hack / src / server / findRefsService . ml <nl> ppp b / hphp / hack / src / server / findRefsService . ml <nl> <nl> <nl> open Utils <nl> <nl> + let process_fun_id results_acc target_fun id = <nl> + if target_fun = ( snd id ) <nl> + then results_acc : = Pos . Map . add ( fst id ) ( snd id ) ! results_acc <nl> + <nl> + let process_method_id results_acc target_classes target_method class_ id _ _ = <nl> + let class_name = class_ . Typing_defs . tc_name in <nl> + if target_method = ( snd id ) & & ( SSet . mem class_name target_classes ) <nl> + then <nl> + results_acc : = <nl> + Pos . Map . add ( fst id ) ( class_name ^ " : : " ^ ( snd id ) ) ! results_acc <nl> + <nl> + let process_constructor results_acc target_classes target_method class_ _ p = <nl> + process_method_id <nl> + results_acc target_classes target_method class_ ( p , " __construct " ) ( ) ( ) <nl> + <nl> + let process_class_id results_acc target_classes cid mid_option = <nl> + if ( SSet . mem ( snd cid ) target_classes ) <nl> + then begin <nl> + let class_name = match mid_option with <nl> + | None - > snd cid <nl> + | Some n - > ( snd cid ) ^ " : : " ^ ( snd n ) in <nl> + results_acc : = Pos . Map . add ( fst cid ) class_name ! results_acc <nl> + end <nl> + <nl> + let attach_hooks results_acc target_classes target_fun = <nl> + match target_classes , target_fun with <nl> + | Some classes , Some method_name - > <nl> + let process_method_id = <nl> + process_method_id results_acc classes method_name <nl> + in <nl> + Typing_hooks . attach_cmethod_hook process_method_id ; <nl> + Typing_hooks . attach_smethod_hook process_method_id ; <nl> + Typing_hooks . attach_constructor_hook <nl> + ( process_constructor results_acc classes method_name ) ; <nl> + | None , Some fun_name - > <nl> + Typing_hooks . attach_fun_id_hook ( process_fun_id results_acc fun_name ) <nl> + | Some classes , None - > <nl> + Typing_hooks . attach_class_id_hook ( process_class_id results_acc classes ) <nl> + | _ - > assert false <nl> + <nl> + let detach_hooks ( ) = <nl> + Typing_hooks . remove_all_hooks ( ) <nl> + <nl> let check_if_extends_class target_class_name class_name acc = <nl> let class_ = Typing_env . Classes . get class_name in <nl> match class_ with <nl> let get_deps_set_function f_name = <nl> with Not_found - > Relative_path . Set . empty <nl> <nl> let find_refs target_classes target_method acc fileinfo_l = <nl> - Find_refs . find_refs_class_name : = target_classes ; <nl> - Find_refs . find_refs_method_name : = target_method ; <nl> - Find_refs . find_refs_results : = Pos . Map . empty ; <nl> + let results_acc = ref Pos . Map . empty in <nl> + attach_hooks results_acc target_classes target_method ; <nl> ServerIdeUtils . recheck fileinfo_l ; <nl> - let result = ! Find_refs . find_refs_results in <nl> - Find_refs . find_refs_class_name : = None ; <nl> - Find_refs . find_refs_method_name : = None ; <nl> - Find_refs . find_refs_results : = Pos . Map . empty ; <nl> + detach_hooks ( ) ; <nl> Pos . Map . fold begin fun p str acc - > <nl> ( str , p ) : : acc <nl> - end result [ ] <nl> + end ! results_acc [ ] <nl> <nl> let parallel_find_refs workers fileinfo_l target_classes target_method = <nl> MultiWorker . call <nl> mmm a / hphp / hack / src / typing / typing . ml <nl> ppp b / hphp / hack / src / typing / typing . ml <nl> and dispatch_call p env call_type ( fpos , fun_expr as e ) el uel = <nl> call p env fty el uel <nl> <nl> and fun_type_of_id env x = <nl> + Typing_hooks . dispatch_fun_id_hook x ; <nl> Find_refs . process_find_refs None ( snd x ) ( fst x ) ; <nl> let env , fty = <nl> match Env . get_fun env ( snd x ) with <nl> and static_class_id p env = function <nl> and call_construct p env class_ params el uel = <nl> let cstr = Env . get_construct env class_ in <nl> let mode = Env . get_mode env in <nl> + Typing_hooks . dispatch_constructor_hook class_ env p ; <nl> Find_refs . process_find_refs ( Some class_ . tc_name ) SN . Members . __construct p ; <nl> match ( fst cstr ) with <nl> | None - > <nl> mmm a / hphp / hack / src / typing / typing_hint . ml <nl> ppp b / hphp / hack / src / typing / typing_hint . ml <nl> and hint_ p env = function <nl> env , Tany <nl> | Happly ( ( ( p , c ) as id ) , argl ) - > <nl> Find_refs . process_class_ref p c None ; <nl> + Typing_hooks . dispatch_class_id_hook id None ; <nl> Env . add_wclass env c ; <nl> let env , argl = lfold hint env argl in <nl> env , Tapply ( id , argl ) <nl> and hint_ p env = function <nl> | CIstatic - > Some SCIstatic <nl> | CI ( pos , class_ ) - > <nl> Find_refs . process_class_ref pos class_ None ; <nl> + Typing_hooks . dispatch_class_id_hook id None ; <nl> Env . add_wclass env class_ ; <nl> Some ( SCI ( pos , class_ ) ) <nl> | CIparent - > <nl> mmm a / hphp / hack / src / typing / typing_hooks . ml <nl> ppp b / hphp / hack / src / typing / typing_hooks . ml <nl> let ( lvar_hooks : ( Pos . t * Ident . t - > Typing_env . env - > <nl> let ( fun_call_hooks : ( ( string option * Typing_defs . ty ) list - > Pos . t list - > <nl> Typing_env . env - > unit ) list ref ) = ref [ ] <nl> <nl> - let ( new_id_hooks : ( Nast . class_id - > Typing_env . env - > unit ) list ref ) = ref [ ] <nl> + let ( new_id_hooks : ( Nast . class_id - > Typing_env . env - > unit ) list ref ) = ref [ ] <nl> + <nl> + let ( fun_id_hooks : ( Pos . t * string - > unit ) list ref ) = ref [ ] <nl> + <nl> + let ( constructor_hooks : ( Typing_defs . class_type - > <nl> + Typing_env . env - > Pos . t - > unit ) list ref ) = ref [ ] <nl> + <nl> + let ( class_id_hooks : ( Pos . t * string - > <nl> + ( Pos . t * string ) option - > unit ) list ref ) = ref [ ] <nl> <nl> let attach_smethod_hook hook = <nl> smethod_hooks : = hook : : ! smethod_hooks <nl> let attach_fun_call_hook hook = <nl> let attach_new_id_hook hook = <nl> new_id_hooks : = hook : : ! new_id_hooks <nl> <nl> + let attach_fun_id_hook hook = <nl> + fun_id_hooks : = hook : : ! fun_id_hooks <nl> + <nl> + let attach_constructor_hook hook = <nl> + constructor_hooks : = hook : : ! constructor_hooks <nl> + <nl> + let attach_class_id_hook hook = <nl> + class_id_hooks : = hook : : ! class_id_hooks <nl> + <nl> let dispatch_id_hook id env = <nl> List . iter begin fun hook - > hook id env end ! id_hooks <nl> <nl> let dispatch_fun_call_hooks ft_params posl env = <nl> let dispatch_new_id_hook cid env = <nl> List . iter begin fun hook - > hook cid env end ! new_id_hooks <nl> <nl> + let dispatch_fun_id_hook id = <nl> + List . iter begin fun hook - > hook id end ! fun_id_hooks <nl> + <nl> + let dispatch_constructor_hook c env p = <nl> + List . iter begin fun hook - > hook c env p end ! constructor_hooks <nl> + <nl> + let dispatch_class_id_hook c_id m_id_optional = <nl> + List . iter begin fun hook - > hook c_id m_id_optional end ! class_id_hooks <nl> + <nl> let remove_all_hooks ( ) = <nl> id_hooks : = [ ] ; <nl> cmethod_hooks : = [ ] ; <nl> let remove_all_hooks ( ) = <nl> lvar_hooks : = [ ] ; <nl> fun_call_hooks : = [ ] ; <nl> new_id_hooks : = [ ] ; <nl> + fun_id_hooks : = [ ] ; <nl> + constructor_hooks : = [ ] ; <nl> + class_id_hooks : = [ ] <nl> mmm a / hphp / hack / src / typing / typing_utils . ml <nl> ppp b / hphp / hack / src / typing / typing_utils . ml <nl> let uerror r1 ty1 r2 ty2 = <nl> <nl> let process_static_find_ref cid mid = <nl> match cid with <nl> - | Nast . CI c - > Find_refs . process_class_ref ( fst c ) ( snd c ) ( Some ( snd mid ) ) <nl> + | Nast . CI c - > <nl> + Typing_hooks . dispatch_class_id_hook c ( Some mid ) ; <nl> + Find_refs . process_class_ref ( fst c ) ( snd c ) ( Some ( snd mid ) ) <nl> | _ - > ( ) <nl> <nl> ( * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ) <nl> mmm a / hphp / hack / test / integration / test_save_restore . py <nl> ppp b / hphp / hack / test / integration / test_save_restore . py <nl> def test_ide_tools ( self ) : <nl> ' 1 total results ' <nl> ] , options = [ ' - - find - refs ' , ' h ' ] ) <nl> <nl> + self . check_cmd ( [ <nl> + ' File " { root } foo_3 . php " , line 10 , characters 13 - 21 : Foo : : __construct ' , <nl> + ' 1 total results ' <nl> + ] , options = [ ' - - find - refs ' , ' Foo : : __construct ' ] ) <nl> + <nl> self . check_cmd ( [ <nl> ' File " { root } foo_3 . php " , line 10 , characters 17 - 19 : Foo : : __construct ' , <nl> ' 1 total results ' <nl>
|
Switch Find Refs to use Hooks
|
facebook/hhvm
|
4d0ba3ec5b63d216949507fc70727fb188aaa34e
|
2014-12-17T21:30:30Z
|
mmm a / tools / internal_ci / helper_scripts / prepare_build_macos_rc <nl> ppp b / tools / internal_ci / helper_scripts / prepare_build_macos_rc <nl> <nl> <nl> # Source this rc script to prepare the environment for macos builds <nl> <nl> - ulimit - n 1000 <nl> + sudo launchctl limit maxfiles unlimited unlimited <nl> + <nl> + # show current maxfiles <nl> + launchctl limit maxfiles <nl> + <nl> + ulimit - n 10000 <nl> <nl> # show current limits <nl> ulimit - a <nl> gem install bundler <nl> # cocoapods <nl> export LANG = en_US . UTF - 8 <nl> gem install cocoapods <nl> + gem install xcpretty <nl> pod repo update # needed by python <nl> <nl> # python <nl> sudo pip install - U six tox setuptools <nl> wget - q https : / / www . python . org / ftp / python / 3 . 4 . 4 / python - 3 . 4 . 4 - macosx10 . 6 . pkg <nl> sudo installer - pkg python - 3 . 4 . 4 - macosx10 . 6 . pkg - target / <nl> <nl> + # set xcode version for Obj - C tests <nl> + sudo xcode - select - switch / Applications / Xcode_8 . 2 . 1 . app / Contents / Developer <nl> + <nl> git submodule update - - init <nl>
|
Merge pull request from jtattermusch / kokoro_objc_fix
|
grpc/grpc
|
fd5eb2412206ab3620644f8e800fb1f44a18ccdd
|
2017-07-11T14:50:37Z
|
new file mode 100644 <nl> index 0000000 . . c61256e <nl> mmm / dev / null <nl> ppp b / . gitignore <nl> <nl> + bin / <nl> + obj / <nl> + / bazel - * <nl> new file mode 100644 <nl> index 0000000 . . 8432a64 <nl> mmm / dev / null <nl> ppp b / Makefile <nl> <nl> + # GNU Make workspace makefile autogenerated by Premake <nl> + <nl> + . NOTPARALLEL : <nl> + <nl> + ifndef config <nl> + config = release <nl> + endif <nl> + <nl> + ifndef verbose <nl> + SILENT = @ <nl> + endif <nl> + <nl> + ifeq ( $ ( config ) , release ) <nl> + guetzli_config = release <nl> + endif <nl> + ifeq ( $ ( config ) , debug ) <nl> + guetzli_config = debug <nl> + endif <nl> + <nl> + PROJECTS : = guetzli <nl> + <nl> + . PHONY : all clean help $ ( PROJECTS ) <nl> + <nl> + all : $ ( PROJECTS ) <nl> + <nl> + guetzli : <nl> + ifneq ( , $ ( guetzli_config ) ) <nl> + @ echo " = = = = Building guetzli ( $ ( guetzli_config ) ) = = = = " <nl> + @ $ { MAKE } - - no - print - directory - C . - f guetzli . make config = $ ( guetzli_config ) <nl> + endif <nl> + <nl> + clean : <nl> + @ $ { MAKE } - - no - print - directory - C . - f guetzli . make clean <nl> + <nl> + help : <nl> + @ echo " Usage : make [ config = name ] [ target ] " <nl> + @ echo " " <nl> + @ echo " CONFIGURATIONS : " <nl> + @ echo " release " <nl> + @ echo " debug " <nl> + @ echo " " <nl> + @ echo " TARGETS : " <nl> + @ echo " all ( default ) " <nl> + @ echo " clean " <nl> + @ echo " guetzli " <nl> + @ echo " " <nl> + @ echo " For more information , see http : / / industriousone . com / premake / quick - start " <nl> \ No newline at end of file <nl> mmm a / README . md <nl> ppp b / README . md <nl> sequential ( nonprogressive ) JPEGs due to faster decompression speeds they offer . <nl> downloading an <nl> [ archive ] ( https : / / github . com / google / guetzli / archive / master . zip ) and <nl> unpacking it . <nl> - 2 . Install [ Bazel ] ( https : / / www . bazel . io ) by following its [ installation <nl> - instructions ] ( https : / / www . bazel . io / versions / master / docs / install . html ) . <nl> - 3 . Run ` bazel build - c opt : guetzli ` in the directory this README file is in . <nl> + 2 . Install [ libpng ] ( http : / / www . libpng . org / pub / png / libpng . html ) and <nl> + [ gflags ] ( https : / / github . com / gflags / gflags ) . If using your operating system <nl> + package manager , install development versions of the packages if the <nl> + distinction exists . <nl> + * On Ubuntu , do ` apt - get install libpng - dev libgflags - dev ` . <nl> + * On Arch Linux , do ` pacman - S libpng gflags ` . <nl> + 3 . Run ` make ` and expect the binary to be created in ` bin / Release / guetzli ` . <nl> + <nl> + There ' s also a [ Bazel ] ( https : / / bazel . build ) build configuration provided . If <nl> + you have Bazel installed , you can also compile Guetzli by running <nl> + ` bazel - c opt : guetzli ` . <nl> <nl> # Using <nl> <nl> To try out Guetzli you need to [ build ] ( # building ) or <nl> binary reads a PNG or JPEG image and creates an optimized JPEG image : <nl> <nl> ` ` ` bash <nl> - bazel - bin / guetzli [ - - quality Q ] [ - - verbose ] original . png output . jpg <nl> - bazel - bin / guetzli [ - - quality Q ] [ - - verbose ] original . jpg output . jpg <nl> + guetzli [ - - quality Q ] [ - - verbose ] original . png output . jpg <nl> + guetzli [ - - quality Q ] [ - - verbose ] original . jpg output . jpg <nl> ` ` ` <nl> <nl> Note that Guetzli is designed to work on high quality images ( e . g . that haven ' t <nl> mmm a / WORKSPACE <nl> ppp b / WORKSPACE <nl> bind ( <nl> actual = " @ gflags_git / / : gflags " , <nl> ) <nl> <nl> - git_repository ( <nl> + local_repository ( <nl> name = " butteraugli " , <nl> - commit = " 037eff792f5b1cc7c21cc2cdd325de712c387e11 " , <nl> - remote = " https : / / github . com / google / butteraugli " , <nl> + path = " third_party / butteraugli / " , <nl> ) <nl> new file mode 100644 <nl> index 0000000 . . a55b4bd <nl> mmm / dev / null <nl> ppp b / guetzli . make <nl> <nl> + # GNU Make project makefile autogenerated by Premake <nl> + <nl> + ifndef config <nl> + config = release <nl> + endif <nl> + <nl> + ifndef verbose <nl> + SILENT = @ <nl> + endif <nl> + <nl> + . PHONY : clean prebuild prelink <nl> + <nl> + ifeq ( $ ( config ) , release ) <nl> + RESCOMP = windres <nl> + TARGETDIR = bin / Release <nl> + TARGET = $ ( TARGETDIR ) / guetzli <nl> + OBJDIR = obj / Release <nl> + DEFINES + = - DGFLAGS_NAMESPACE = google <nl> + INCLUDES + = - I . - Ithird_party / butteraugli <nl> + FORCE_INCLUDE + = <nl> + ALL_CPPFLAGS + = $ ( CPPFLAGS ) - MMD - MP $ ( DEFINES ) $ ( INCLUDES ) <nl> + ALL_CFLAGS + = $ ( CFLAGS ) $ ( ALL_CPPFLAGS ) - O3 <nl> + ALL_CXXFLAGS + = $ ( CXXFLAGS ) $ ( ALL_CFLAGS ) - std = c + + 11 <nl> + ALL_RESFLAGS + = $ ( RESFLAGS ) $ ( DEFINES ) $ ( INCLUDES ) <nl> + LIBS + = <nl> + LDDEPS + = <nl> + ALL_LDFLAGS + = $ ( LDFLAGS ) - s - lpng - lgflags_nothreads <nl> + LINKCMD = $ ( CXX ) - o " $ @ " $ ( OBJECTS ) $ ( RESOURCES ) $ ( ALL_LDFLAGS ) $ ( LIBS ) <nl> + define PREBUILDCMDS <nl> + endef <nl> + define PRELINKCMDS <nl> + endef <nl> + define POSTBUILDCMDS <nl> + endef <nl> + all : $ ( TARGETDIR ) $ ( OBJDIR ) prebuild prelink $ ( TARGET ) <nl> + @ : <nl> + <nl> + endif <nl> + <nl> + ifeq ( $ ( config ) , debug ) <nl> + RESCOMP = windres <nl> + TARGETDIR = bin / Debug <nl> + TARGET = $ ( TARGETDIR ) / guetzli <nl> + OBJDIR = obj / Debug <nl> + DEFINES + = - DGFLAGS_NAMESPACE = google <nl> + INCLUDES + = - I . - Ithird_party / butteraugli <nl> + FORCE_INCLUDE + = <nl> + ALL_CPPFLAGS + = $ ( CPPFLAGS ) - MMD - MP $ ( DEFINES ) $ ( INCLUDES ) <nl> + ALL_CFLAGS + = $ ( CFLAGS ) $ ( ALL_CPPFLAGS ) - g <nl> + ALL_CXXFLAGS + = $ ( CXXFLAGS ) $ ( ALL_CFLAGS ) - std = c + + 11 <nl> + ALL_RESFLAGS + = $ ( RESFLAGS ) $ ( DEFINES ) $ ( INCLUDES ) <nl> + LIBS + = <nl> + LDDEPS + = <nl> + ALL_LDFLAGS + = $ ( LDFLAGS ) - lpng - lgflags_nothreads <nl> + LINKCMD = $ ( CXX ) - o " $ @ " $ ( OBJECTS ) $ ( RESOURCES ) $ ( ALL_LDFLAGS ) $ ( LIBS ) <nl> + define PREBUILDCMDS <nl> + endef <nl> + define PRELINKCMDS <nl> + endef <nl> + define POSTBUILDCMDS <nl> + endef <nl> + all : $ ( TARGETDIR ) $ ( OBJDIR ) prebuild prelink $ ( TARGET ) <nl> + @ : <nl> + <nl> + endif <nl> + <nl> + OBJECTS : = \ <nl> + $ ( OBJDIR ) / butteraugli_comparator . o \ <nl> + $ ( OBJDIR ) / dct_double . o \ <nl> + $ ( OBJDIR ) / debug_print . o \ <nl> + $ ( OBJDIR ) / entropy_encode . o \ <nl> + $ ( OBJDIR ) / fdct . o \ <nl> + $ ( OBJDIR ) / gamma_correct . o \ <nl> + $ ( OBJDIR ) / guetzli . o \ <nl> + $ ( OBJDIR ) / idct . o \ <nl> + $ ( OBJDIR ) / jpeg_data . o \ <nl> + $ ( OBJDIR ) / jpeg_data_decoder . o \ <nl> + $ ( OBJDIR ) / jpeg_data_encoder . o \ <nl> + $ ( OBJDIR ) / jpeg_data_reader . o \ <nl> + $ ( OBJDIR ) / jpeg_data_writer . o \ <nl> + $ ( OBJDIR ) / jpeg_huffman_decode . o \ <nl> + $ ( OBJDIR ) / output_image . o \ <nl> + $ ( OBJDIR ) / preprocess_downsample . o \ <nl> + $ ( OBJDIR ) / processor . o \ <nl> + $ ( OBJDIR ) / quality . o \ <nl> + $ ( OBJDIR ) / quantize . o \ <nl> + $ ( OBJDIR ) / score . o \ <nl> + $ ( OBJDIR ) / butteraugli . o \ <nl> + <nl> + RESOURCES : = \ <nl> + <nl> + CUSTOMFILES : = \ <nl> + <nl> + SHELLTYPE : = msdos <nl> + ifeq ( , $ ( ComSpec ) $ ( COMSPEC ) ) <nl> + SHELLTYPE : = posix <nl> + endif <nl> + ifeq ( / bin , $ ( findstring / bin , $ ( SHELL ) ) ) <nl> + SHELLTYPE : = posix <nl> + endif <nl> + <nl> + $ ( TARGET ) : $ ( GCH ) $ { CUSTOMFILES } $ ( OBJECTS ) $ ( LDDEPS ) $ ( RESOURCES ) <nl> + @ echo Linking guetzli <nl> + $ ( SILENT ) $ ( LINKCMD ) <nl> + $ ( POSTBUILDCMDS ) <nl> + <nl> + $ ( TARGETDIR ) : <nl> + @ echo Creating $ ( TARGETDIR ) <nl> + ifeq ( posix , $ ( SHELLTYPE ) ) <nl> + $ ( SILENT ) mkdir - p $ ( TARGETDIR ) <nl> + else <nl> + $ ( SILENT ) mkdir $ ( subst / , \ \ , $ ( TARGETDIR ) ) <nl> + endif <nl> + <nl> + $ ( OBJDIR ) : <nl> + @ echo Creating $ ( OBJDIR ) <nl> + ifeq ( posix , $ ( SHELLTYPE ) ) <nl> + $ ( SILENT ) mkdir - p $ ( OBJDIR ) <nl> + else <nl> + $ ( SILENT ) mkdir $ ( subst / , \ \ , $ ( OBJDIR ) ) <nl> + endif <nl> + <nl> + clean : <nl> + @ echo Cleaning guetzli <nl> + ifeq ( posix , $ ( SHELLTYPE ) ) <nl> + $ ( SILENT ) rm - f $ ( TARGET ) <nl> + $ ( SILENT ) rm - rf $ ( OBJDIR ) <nl> + else <nl> + $ ( SILENT ) if exist $ ( subst / , \ \ , $ ( TARGET ) ) del $ ( subst / , \ \ , $ ( TARGET ) ) <nl> + $ ( SILENT ) if exist $ ( subst / , \ \ , $ ( OBJDIR ) ) rmdir / s / q $ ( subst / , \ \ , $ ( OBJDIR ) ) <nl> + endif <nl> + <nl> + prebuild : <nl> + $ ( PREBUILDCMDS ) <nl> + <nl> + prelink : <nl> + $ ( PRELINKCMDS ) <nl> + <nl> + ifneq ( , $ ( PCH ) ) <nl> + $ ( OBJECTS ) : $ ( GCH ) $ ( PCH ) <nl> + $ ( GCH ) : $ ( PCH ) <nl> + @ echo $ ( notdir $ < ) <nl> + $ ( SILENT ) $ ( CXX ) - x c + + - header $ ( ALL_CXXFLAGS ) - o " $ @ " - MF " $ ( @ : % . gch = % . d ) " - c " $ < " <nl> + endif <nl> + <nl> + $ ( OBJDIR ) / butteraugli_comparator . o : guetzli / butteraugli_comparator . cc <nl> + @ echo $ ( notdir $ < ) <nl> + $ ( SILENT ) $ ( CXX ) $ ( ALL_CXXFLAGS ) $ ( FORCE_INCLUDE ) - o " $ @ " - MF " $ ( @ : % . o = % . d ) " - c " $ < " <nl> + $ ( OBJDIR ) / dct_double . o : guetzli / dct_double . cc <nl> + @ echo $ ( notdir $ < ) <nl> + $ ( SILENT ) $ ( CXX ) $ ( ALL_CXXFLAGS ) $ ( FORCE_INCLUDE ) - o " $ @ " - MF " $ ( @ : % . o = % . d ) " - c " $ < " <nl> + $ ( OBJDIR ) / debug_print . o : guetzli / debug_print . cc <nl> + @ echo $ ( notdir $ < ) <nl> + $ ( SILENT ) $ ( CXX ) $ ( ALL_CXXFLAGS ) $ ( FORCE_INCLUDE ) - o " $ @ " - MF " $ ( @ : % . o = % . d ) " - c " $ < " <nl> + $ ( OBJDIR ) / entropy_encode . o : guetzli / entropy_encode . cc <nl> + @ echo $ ( notdir $ < ) <nl> + $ ( SILENT ) $ ( CXX ) $ ( ALL_CXXFLAGS ) $ ( FORCE_INCLUDE ) - o " $ @ " - MF " $ ( @ : % . o = % . d ) " - c " $ < " <nl> + $ ( OBJDIR ) / fdct . o : guetzli / fdct . cc <nl> + @ echo $ ( notdir $ < ) <nl> + $ ( SILENT ) $ ( CXX ) $ ( ALL_CXXFLAGS ) $ ( FORCE_INCLUDE ) - o " $ @ " - MF " $ ( @ : % . o = % . d ) " - c " $ < " <nl> + $ ( OBJDIR ) / gamma_correct . o : guetzli / gamma_correct . cc <nl> + @ echo $ ( notdir $ < ) <nl> + $ ( SILENT ) $ ( CXX ) $ ( ALL_CXXFLAGS ) $ ( FORCE_INCLUDE ) - o " $ @ " - MF " $ ( @ : % . o = % . d ) " - c " $ < " <nl> + $ ( OBJDIR ) / guetzli . o : guetzli / guetzli . cc <nl> + @ echo $ ( notdir $ < ) <nl> + $ ( SILENT ) $ ( CXX ) $ ( ALL_CXXFLAGS ) $ ( FORCE_INCLUDE ) - o " $ @ " - MF " $ ( @ : % . o = % . d ) " - c " $ < " <nl> + $ ( OBJDIR ) / idct . o : guetzli / idct . cc <nl> + @ echo $ ( notdir $ < ) <nl> + $ ( SILENT ) $ ( CXX ) $ ( ALL_CXXFLAGS ) $ ( FORCE_INCLUDE ) - o " $ @ " - MF " $ ( @ : % . o = % . d ) " - c " $ < " <nl> + $ ( OBJDIR ) / jpeg_data . o : guetzli / jpeg_data . cc <nl> + @ echo $ ( notdir $ < ) <nl> + $ ( SILENT ) $ ( CXX ) $ ( ALL_CXXFLAGS ) $ ( FORCE_INCLUDE ) - o " $ @ " - MF " $ ( @ : % . o = % . d ) " - c " $ < " <nl> + $ ( OBJDIR ) / jpeg_data_decoder . o : guetzli / jpeg_data_decoder . cc <nl> + @ echo $ ( notdir $ < ) <nl> + $ ( SILENT ) $ ( CXX ) $ ( ALL_CXXFLAGS ) $ ( FORCE_INCLUDE ) - o " $ @ " - MF " $ ( @ : % . o = % . d ) " - c " $ < " <nl> + $ ( OBJDIR ) / jpeg_data_encoder . o : guetzli / jpeg_data_encoder . cc <nl> + @ echo $ ( notdir $ < ) <nl> + $ ( SILENT ) $ ( CXX ) $ ( ALL_CXXFLAGS ) $ ( FORCE_INCLUDE ) - o " $ @ " - MF " $ ( @ : % . o = % . d ) " - c " $ < " <nl> + $ ( OBJDIR ) / jpeg_data_reader . o : guetzli / jpeg_data_reader . cc <nl> + @ echo $ ( notdir $ < ) <nl> + $ ( SILENT ) $ ( CXX ) $ ( ALL_CXXFLAGS ) $ ( FORCE_INCLUDE ) - o " $ @ " - MF " $ ( @ : % . o = % . d ) " - c " $ < " <nl> + $ ( OBJDIR ) / jpeg_data_writer . o : guetzli / jpeg_data_writer . cc <nl> + @ echo $ ( notdir $ < ) <nl> + $ ( SILENT ) $ ( CXX ) $ ( ALL_CXXFLAGS ) $ ( FORCE_INCLUDE ) - o " $ @ " - MF " $ ( @ : % . o = % . d ) " - c " $ < " <nl> + $ ( OBJDIR ) / jpeg_huffman_decode . o : guetzli / jpeg_huffman_decode . cc <nl> + @ echo $ ( notdir $ < ) <nl> + $ ( SILENT ) $ ( CXX ) $ ( ALL_CXXFLAGS ) $ ( FORCE_INCLUDE ) - o " $ @ " - MF " $ ( @ : % . o = % . d ) " - c " $ < " <nl> + $ ( OBJDIR ) / output_image . o : guetzli / output_image . cc <nl> + @ echo $ ( notdir $ < ) <nl> + $ ( SILENT ) $ ( CXX ) $ ( ALL_CXXFLAGS ) $ ( FORCE_INCLUDE ) - o " $ @ " - MF " $ ( @ : % . o = % . d ) " - c " $ < " <nl> + $ ( OBJDIR ) / preprocess_downsample . o : guetzli / preprocess_downsample . cc <nl> + @ echo $ ( notdir $ < ) <nl> + $ ( SILENT ) $ ( CXX ) $ ( ALL_CXXFLAGS ) $ ( FORCE_INCLUDE ) - o " $ @ " - MF " $ ( @ : % . o = % . d ) " - c " $ < " <nl> + $ ( OBJDIR ) / processor . o : guetzli / processor . cc <nl> + @ echo $ ( notdir $ < ) <nl> + $ ( SILENT ) $ ( CXX ) $ ( ALL_CXXFLAGS ) $ ( FORCE_INCLUDE ) - o " $ @ " - MF " $ ( @ : % . o = % . d ) " - c " $ < " <nl> + $ ( OBJDIR ) / quality . o : guetzli / quality . cc <nl> + @ echo $ ( notdir $ < ) <nl> + $ ( SILENT ) $ ( CXX ) $ ( ALL_CXXFLAGS ) $ ( FORCE_INCLUDE ) - o " $ @ " - MF " $ ( @ : % . o = % . d ) " - c " $ < " <nl> + $ ( OBJDIR ) / quantize . o : guetzli / quantize . cc <nl> + @ echo $ ( notdir $ < ) <nl> + $ ( SILENT ) $ ( CXX ) $ ( ALL_CXXFLAGS ) $ ( FORCE_INCLUDE ) - o " $ @ " - MF " $ ( @ : % . o = % . d ) " - c " $ < " <nl> + $ ( OBJDIR ) / score . o : guetzli / score . cc <nl> + @ echo $ ( notdir $ < ) <nl> + $ ( SILENT ) $ ( CXX ) $ ( ALL_CXXFLAGS ) $ ( FORCE_INCLUDE ) - o " $ @ " - MF " $ ( @ : % . o = % . d ) " - c " $ < " <nl> + $ ( OBJDIR ) / butteraugli . o : third_party / butteraugli / butteraugli / butteraugli . cc <nl> + @ echo $ ( notdir $ < ) <nl> + $ ( SILENT ) $ ( CXX ) $ ( ALL_CXXFLAGS ) $ ( FORCE_INCLUDE ) - o " $ @ " - MF " $ ( @ : % . o = % . d ) " - c " $ < " <nl> + <nl> + - include $ ( OBJECTS : % . o = % . d ) <nl> + ifneq ( , $ ( PCH ) ) <nl> + - include $ ( OBJDIR ) / $ ( notdir $ ( PCH ) ) . d <nl> + endif <nl> \ No newline at end of file <nl> mmm a / guetzli / guetzli . cc <nl> ppp b / guetzli / guetzli . cc <nl> <nl> # include " guetzli / quality . h " <nl> # include " guetzli / stats . h " <nl> <nl> + # ifndef GFLAGS_NAMESPACE <nl> + using namespace gflags ; <nl> + # else <nl> + using namespace GFLAGS_NAMESPACE ; <nl> + # endif <nl> + <nl> <nl> DEFINE_bool ( verbose , false , <nl> " Print a verbose trace of all attempts to standard output . " ) ; <nl> void WriteFileOrDie ( FILE * f , const std : : string & contents ) { <nl> } / / namespace <nl> <nl> int main ( int argc , char * * argv ) { <nl> - gflags : : SetUsageMessage ( " Guetzli JPEG compressor . Usage : \ n " <nl> - " guetzli [ flags ] input_filename output_filename " ) ; <nl> - gflags : : ParseCommandLineFlags ( & argc , & argv , true ) ; <nl> + SetUsageMessage ( <nl> + " Guetzli JPEG compressor . Usage : \ n " <nl> + " guetzli [ flags ] input_filename output_filename " ) ; <nl> + ParseCommandLineFlags ( & argc , & argv , true ) ; <nl> <nl> if ( argc ! = 3 ) { <nl> - gflags : : ShowUsageWithFlags ( argv [ 0 ] ) ; <nl> + ShowUsageWithFlags ( argv [ 0 ] ) ; <nl> return 1 ; <nl> } <nl> <nl> new file mode 100644 <nl> index 0000000 . . c018058 <nl> mmm / dev / null <nl> ppp b / premake5 . lua <nl> <nl> + workspace " guetzli " <nl> + configurations { " Release " , " Debug " } <nl> + <nl> + flags { " C + + 11 " } <nl> + <nl> + filter " configurations : Debug " <nl> + symbols " On " <nl> + filter " configurations : Release " <nl> + optimize " Full " <nl> + <nl> + project " guetzli " <nl> + kind " ConsoleApp " <nl> + language " C + + " <nl> + nuget { " gflags : 2 . 1 . 2 . 1 " , " libpng : 1 . 6 . 26 . 1 " } <nl> + includedirs { " . " , " third_party / butteraugli " } <nl> + linkoptions { " - lpng " , " - lgflags_nothreads " } <nl> + - - This should work with gflags 2 . x . The gflags namespace is absent in <nl> + - - gflags - 2 . 0 , which is the version in Ubuntu Trusty package repository . <nl> + defines { " GFLAGS_NAMESPACE = google " } <nl> + files <nl> + { <nl> + " guetzli / * . cc " , <nl> + " guetzli / * . h " , <nl> + " third_party / butteraugli / butteraugli / butteraugli . cc " , <nl> + " third_party / butteraugli / butteraugli / butteraugli . h " <nl> + } <nl>
|
Change default build system to make .
|
google/guetzli
|
6f99b17ade9dbceaae2b050b93e46b6a85a7e29c
|
2016-11-28T13:58:48Z
|
mmm a / src / mongo / db / storage / wiredtiger / wiredtiger_record_store . cpp <nl> ppp b / src / mongo / db / storage / wiredtiger / wiredtiger_record_store . cpp <nl> bool WiredTigerRecordStore : : yieldAndAwaitOplogDeletionRequest ( OperationContext * <nl> <nl> / / The top - level locks were freed , so also release any potential low - level ( storage engine ) <nl> / / locks that might be held . <nl> - opCtx - > recoveryUnit ( ) - > abandonSnapshot ( ) ; <nl> + WiredTigerRecoveryUnit * recoveryUnit = ( WiredTigerRecoveryUnit * ) opCtx - > recoveryUnit ( ) ; <nl> + recoveryUnit - > abandonSnapshot ( ) ; <nl> + recoveryUnit - > beginIdle ( ) ; <nl> <nl> / / Wait for an oplog deletion request , or for this record store to have been destroyed . <nl> oplogStones - > awaitHasExcessStonesOrDead ( ) ; <nl> mmm a / src / mongo / db / storage / wiredtiger / wiredtiger_recovery_unit . cpp <nl> ppp b / src / mongo / db / storage / wiredtiger / wiredtiger_recovery_unit . cpp <nl> void WiredTigerRecoveryUnit : : setIsOplogReader ( ) { <nl> _isOplogReader = true ; <nl> } <nl> <nl> + void WiredTigerRecoveryUnit : : beginIdle ( ) { <nl> + / / Close all cursors , we don ' t want to keep any old cached cursors around . <nl> + if ( _session ) { <nl> + _session - > closeAllCursors ( " " ) ; <nl> + } <nl> + } <nl> + <nl> / / mmmmmmmmmmmmmmmmmmmmm <nl> <nl> WiredTigerCursor : : WiredTigerCursor ( const std : : string & uri , <nl> mmm a / src / mongo / db / storage / wiredtiger / wiredtiger_recovery_unit . h <nl> ppp b / src / mongo / db / storage / wiredtiger / wiredtiger_recovery_unit . h <nl> class WiredTigerRecoveryUnit final : public RecoveryUnit { <nl> WiredTigerSession * getSession ( ) ; <nl> void setIsOplogReader ( ) ; <nl> <nl> + / * * <nl> + * Enter a period of wait or computation during which there are no WT calls . <nl> + * Any non - relevant cached handles can be closed . <nl> + * / <nl> + void beginIdle ( ) ; <nl> + <nl> / * * <nl> * Returns a session without starting a new WT txn on the session . Will not close any already <nl> * running session . <nl> mmm a / src / mongo / db / storage / wiredtiger / wiredtiger_session_cache . cpp <nl> ppp b / src / mongo / db / storage / wiredtiger / wiredtiger_session_cache . cpp <nl> void WiredTigerSession : : releaseCursor ( uint64_t id , WT_CURSOR * cursor ) { <nl> void WiredTigerSession : : closeAllCursors ( const std : : string & uri ) { <nl> invariant ( _session ) ; <nl> <nl> + bool all = ( uri = = " " ) ; <nl> for ( auto i = _cursors . begin ( ) ; i ! = _cursors . end ( ) ; ) { <nl> WT_CURSOR * cursor = i - > _cursor ; <nl> - if ( cursor & & uri = = cursor - > uri ) { <nl> + if ( cursor & & ( all | | uri = = cursor - > uri ) ) { <nl> invariantWTOK ( cursor - > close ( cursor ) ) ; <nl> i = _cursors . erase ( i ) ; <nl> } else <nl> mmm a / src / mongo / db / storage / wiredtiger / wiredtiger_session_cache . h <nl> ppp b / src / mongo / db / storage / wiredtiger / wiredtiger_session_cache . h <nl> class WiredTigerSession { <nl> <nl> void closeCursorsForQueuedDrops ( WiredTigerKVEngine * engine ) ; <nl> <nl> + / * * <nl> + * Closes all cached cursors matching the uri . If the uri is empty , <nl> + * all cached cursors are closed . <nl> + * / <nl> void closeAllCursors ( const std : : string & uri ) ; <nl> <nl> int cursorsOut ( ) const { <nl> class WiredTigerSessionCache { <nl> void closeCursorsForQueuedDrops ( ) ; <nl> <nl> / * * <nl> - * Closes all cached cursors and ensures that previously opened cursors will be closed on <nl> - * release . <nl> + * Closes all cached cursors matching the uri . If the uri is empty , <nl> + * all cached cursors are closed . <nl> * / <nl> void closeAllCursors ( const std : : string & uri ) ; <nl> <nl>
|
SERVER - 31590 Release unused cursors in the cache before awaiting oplog deletion
|
mongodb/mongo
|
2a8818d4fd7b833b82997c9996aca9eb14471f09
|
2017-10-31T17:54:10Z
|
mmm a / CHANGELOG <nl> ppp b / CHANGELOG <nl> <nl> devel <nl> mmm - - <nl> <nl> + * Fix a bad deadlock because transaction cleanup was pushed with too low <nl> + priority . <nl> + <nl> * Allow specifying graph names as unquoted string in an AQL graph traversal <nl> query , e . g . ` FOR . . . IN . . . GRAPH abc ` . Previously , the graph name had <nl> to be a bind parameter or a string enclosed in quotes . <nl> mmm a / arangod / Transaction / ManagerFeature . cpp <nl> ppp b / arangod / Transaction / ManagerFeature . cpp <nl> void queueGarbageCollection ( std : : mutex & mutex , arangodb : : Scheduler : : WorkHandle & <nl> arangodb : : basics : : function_utils : : retryUntilTimeout < arangodb : : Scheduler : : WorkHandle > ( <nl> [ & gcfunc ] ( ) - > std : : pair < bool , arangodb : : Scheduler : : WorkHandle > { <nl> auto off = std : : chrono : : seconds ( 1 ) ; <nl> - return arangodb : : SchedulerFeature : : SCHEDULER - > queueDelay ( arangodb : : RequestLane : : INTERNAL_LOW , <nl> + / / The RequestLane needs to be something which is ` HIGH ` priority , otherwise <nl> + / / all threads executing this might be blocking , waiting for a lock to be <nl> + / / released . <nl> + return arangodb : : SchedulerFeature : : SCHEDULER - > queueDelay ( arangodb : : RequestLane : : CLUSTER_INTERNAL , <nl> off , gcfunc ) ; <nl> } , <nl> arangodb : : Logger : : TRANSACTIONS , <nl>
|
Solve a deadlock problem in the cluster . ( )
|
arangodb/arangodb
|
7d480d625d5d5ede3902d013b9df452682ee6ca5
|
2020-05-08T11:52:38Z
|
mmm a / ios / sdk / WeexSDK / Sources / Component / WXTextComponent . m <nl> ppp b / ios / sdk / WeexSDK / Sources / Component / WXTextComponent . m <nl> - ( void ) repaintText : ( NSNotification * ) notification <nl> } ) ; <nl> } <nl> <nl> - - ( NSMutableAttributedString * ) buildCTAttributeString { <nl> - <nl> - NSString * string = [ self text ] ? : @ " " ; <nl> + - ( NSMutableAttributedString * ) buildCTAttributeString <nl> + { <nl> + NSMutableString * string = [ NSMutableString stringWithFormat : @ " % @ " , [ self text ] ? : @ " " ] ; <nl> NSMutableAttributedString * attributedString = [ [ NSMutableAttributedString alloc ] initWithString : string ] ; <nl> if ( _color ) { <nl> [ attributedString addAttribute : NSForegroundColorAttributeName value : _color range : NSMakeRange ( 0 , string . length ) ] ; <nl> - ( CTLineRef ) buildTruncatedLineWithRuns : ( CFArrayRef ) runs lines : ( NSMutableArray * ) <nl> / / default truncationType is kCTLineTruncationEnd <nl> CTLineTruncationType truncationType = kCTLineTruncationEnd ; <nl> NSAttributedString * attributedString = [ self buildCTAttributeString ] ; <nl> - NSAttributedString * lastLineText = [ attributedString attributedSubstringFromRange : WXNSRangeFromCFRange ( CTLineGetStringRange ( lastLine ) ) ] ; <nl> + NSAttributedString * lastLineText = nil ; <nl> + @ try { <nl> + lastLineText = [ attributedString attributedSubstringFromRange : WXNSRangeFromCFRange ( CTLineGetStringRange ( lastLine ) ) ] ; <nl> + } @ catch ( NSException * exception ) { <nl> + lastLineText = attributedString ; <nl> + } @ finally { <nl> + if ( ! lastLineText ) { <nl> + lastLineText = attributedString ; <nl> + } <nl> + / / nothing <nl> + } <nl> + <nl> NSMutableAttributedString * mutableLastLineText = lastLineText . mutableCopy ; <nl> [ mutableLastLineText appendAttributedString : truncationToken ] ; <nl> CTLineRef ctLastLineExtend = CTLineCreateWithAttributedString ( ( __bridge CFAttributedStringRef ) mutableLastLineText ) ; <nl>
|
* [ ios ] try to fix text crash
|
apache/incubator-weex
|
b1070991edd41a2e78eb55d204a2df16efb83d4d
|
2017-06-02T02:27:00Z
|
new file mode 100644 <nl> index 00000000000 . . bf793edcc66 <nl> mmm / dev / null <nl> ppp b / examples / csharp / HelloworldXamarin / . gitignore <nl> <nl> + # Autosave files <nl> + * ~ <nl> + <nl> + # build <nl> + [ Oo ] bj / <nl> + [ Bb ] in / <nl> + packages / <nl> + TestResults / <nl> + <nl> + # globs <nl> + Makefile . in <nl> + * . DS_Store <nl> + * . sln . cache <nl> + * . suo <nl> + * . cache <nl> + * . pidb <nl> + * . userprefs <nl> + * . usertasks <nl> + config . log <nl> + config . make <nl> + config . status <nl> + aclocal . m4 <nl> + install - sh <nl> + autom4te . cache / <nl> + * . user <nl> + * . tar . gz <nl> + tarballs / <nl> + test - results / <nl> + Thumbs . db <nl> + . vs / <nl> + <nl> + # Mac bundle stuff <nl> + * . dmg <nl> + * . app <nl> + <nl> + # resharper <nl> + * _Resharper . * <nl> + * . Resharper <nl> + <nl> + # dotCover <nl> + * . dotCover <nl> new file mode 100644 <nl> index 00000000000 . . a9b0638eb1b <nl> mmm / dev / null <nl> ppp b / examples / csharp / HelloworldXamarin / Droid / Assets / AboutAssets . txt <nl> <nl> + Any raw assets you want to be deployed with your application can be placed in <nl> + this directory ( and child directories ) and given a Build Action of " AndroidAsset " . <nl> + <nl> + These files will be deployed with your package and will be accessible using Android ' s <nl> + AssetManager , like this : <nl> + <nl> + public class ReadAsset : Activity <nl> + { <nl> + protected override void OnCreate ( Bundle bundle ) <nl> + { <nl> + base . OnCreate ( bundle ) ; <nl> + <nl> + InputStream input = Assets . Open ( " my_asset . txt " ) ; <nl> + } <nl> + } <nl> + <nl> + Additionally , some Android functions will automatically load asset files : <nl> + <nl> + Typeface tf = Typeface . CreateFromAsset ( Context . Assets , " fonts / samplefont . ttf " ) ; <nl> new file mode 100644 <nl> index 00000000000 . . 20f1cedb872 <nl> mmm / dev / null <nl> ppp b / examples / csharp / HelloworldXamarin / Droid / HelloworldXamarin . Droid . csproj <nl> <nl> + < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> + < Project DefaultTargets = " Build " ToolsVersion = " 4 . 0 " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> + < PropertyGroup > <nl> + < Configuration Condition = " ' $ ( Configuration ) ' = = ' ' " > Debug < / Configuration > <nl> + < Platform Condition = " ' $ ( Platform ) ' = = ' ' " > AnyCPU < / Platform > <nl> + < ProjectGuid > { B9B0D41C - 1C07 - 4590 - A919 - 5865E741B2EA } < / ProjectGuid > <nl> + < ProjectTypeGuids > { EFBA0AD7 - 5A72 - 4C68 - AF49 - 83D382785DCF } ; { FAE04EC0 - 301F - 11D3 - BF4B - 00C04F79EFBC } < / ProjectTypeGuids > <nl> + < OutputType > Library < / OutputType > <nl> + < RootNamespace > HelloworldXamarin . Droid < / RootNamespace > <nl> + < AssemblyName > HelloworldXamarin . Droid < / AssemblyName > <nl> + < TargetFrameworkVersion > v8 . 1 < / TargetFrameworkVersion > <nl> + < AndroidApplication > True < / AndroidApplication > <nl> + < AndroidResgenFile > Resources \ Resource . designer . cs < / AndroidResgenFile > <nl> + < AndroidResgenClass > Resource < / AndroidResgenClass > <nl> + < AndroidManifest > Properties \ AndroidManifest . xml < / AndroidManifest > <nl> + < MonoAndroidResourcePrefix > Resources < / MonoAndroidResourcePrefix > <nl> + < MonoAndroidAssetsPrefix > Assets < / MonoAndroidAssetsPrefix > <nl> + < AndroidUseLatestPlatformSdk > true < / AndroidUseLatestPlatformSdk > <nl> + < / PropertyGroup > <nl> + < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | AnyCPU ' " > <nl> + < DebugSymbols > true < / DebugSymbols > <nl> + < DebugType > full < / DebugType > <nl> + < Optimize > false < / Optimize > <nl> + < OutputPath > bin \ Debug < / OutputPath > <nl> + < DefineConstants > DEBUG ; < / DefineConstants > <nl> + < ErrorReport > prompt < / ErrorReport > <nl> + < WarningLevel > 4 < / WarningLevel > <nl> + < AndroidLinkMode > None < / AndroidLinkMode > <nl> + < / PropertyGroup > <nl> + < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Release | AnyCPU ' " > <nl> + < DebugSymbols > true < / DebugSymbols > <nl> + < DebugType > pdbonly < / DebugType > <nl> + < Optimize > true < / Optimize > <nl> + < OutputPath > bin \ Release < / OutputPath > <nl> + < ErrorReport > prompt < / ErrorReport > <nl> + < WarningLevel > 4 < / WarningLevel > <nl> + < AndroidManagedSymbols > true < / AndroidManagedSymbols > <nl> + < AndroidUseSharedRuntime > false < / AndroidUseSharedRuntime > <nl> + < / PropertyGroup > <nl> + < ItemGroup > <nl> + < Reference Include = " System " / > <nl> + < Reference Include = " System . Xml " / > <nl> + < Reference Include = " System . Core " / > <nl> + < Reference Include = " Mono . Android " / > <nl> + < / ItemGroup > <nl> + < ItemGroup > <nl> + < Compile Include = " MainActivity . cs " / > <nl> + < Compile Include = " Resources \ Resource . designer . cs " / > <nl> + < Compile Include = " Properties \ AssemblyInfo . cs " / > <nl> + < / ItemGroup > <nl> + < ItemGroup > <nl> + < None Include = " Resources \ AboutResources . txt " / > <nl> + < None Include = " Properties \ AndroidManifest . xml " / > <nl> + < None Include = " Assets \ AboutAssets . txt " / > <nl> + < / ItemGroup > <nl> + < ItemGroup > <nl> + < AndroidResource Include = " Resources \ layout \ Main . axml " / > <nl> + < AndroidResource Include = " Resources \ values \ Strings . xml " / > <nl> + < AndroidResource Include = " Resources \ mipmap - hdpi \ Icon . png " / > <nl> + < AndroidResource Include = " Resources \ mipmap - mdpi \ Icon . png " / > <nl> + < AndroidResource Include = " Resources \ mipmap - xhdpi \ Icon . png " / > <nl> + < AndroidResource Include = " Resources \ mipmap - xxhdpi \ Icon . png " / > <nl> + < AndroidResource Include = " Resources \ mipmap - xxxhdpi \ Icon . png " / > <nl> + < / ItemGroup > <nl> + < Import Project = " . . \ HelloworldXamarin \ HelloworldXamarin . projitems " Label = " Shared " Condition = " Exists ( ' . . \ HelloworldXamarin \ HelloworldXamarin . projitems ' ) " / > <nl> + < Import Project = " $ ( MSBuildExtensionsPath ) \ Xamarin \ Android \ Xamarin . Android . CSharp . targets " / > <nl> + < / Project > <nl> \ No newline at end of file <nl> new file mode 100644 <nl> index 00000000000 . . 20982422f28 <nl> mmm / dev / null <nl> ppp b / examples / csharp / HelloworldXamarin / Droid / MainActivity . cs <nl> <nl> + using Android . App ; <nl> + using Android . Widget ; <nl> + using Android . OS ; <nl> + <nl> + namespace HelloworldXamarin . Droid <nl> + { <nl> + [ Activity ( Label = " HelloworldXamarin " , MainLauncher = true , Icon = " @ mipmap / icon " ) ] <nl> + public class MainActivity : Activity <nl> + { <nl> + int count = 1 ; <nl> + <nl> + protected override void OnCreate ( Bundle savedInstanceState ) <nl> + { <nl> + base . OnCreate ( savedInstanceState ) ; <nl> + <nl> + / / Set our view from the " main " layout resource <nl> + SetContentView ( Resource . Layout . Main ) ; <nl> + <nl> + / / Get our button from the layout resource , <nl> + / / and attach an event to it <nl> + Button button = FindViewById < Button > ( Resource . Id . myButton ) ; <nl> + <nl> + button . Click + = delegate { button . Text = $ " { count + + } clicks ! " ; } ; <nl> + } <nl> + } <nl> + } <nl> + <nl> new file mode 100644 <nl> index 00000000000 . . 4f2167a1a03 <nl> mmm / dev / null <nl> ppp b / examples / csharp / HelloworldXamarin / Droid / Properties / AndroidManifest . xml <nl> <nl> + < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> + < manifest xmlns : android = " http : / / schemas . android . com / apk / res / android " android : versionCode = " 1 " android : versionName = " 1 . 0 " package = " io . grpc . examples . HelloworldXamarin " > <nl> + < uses - sdk android : minSdkVersion = " 15 " / > <nl> + < application android : label = " HelloworldXamarin " > <nl> + < / application > <nl> + < / manifest > <nl> new file mode 100644 <nl> index 00000000000 . . 4c952aa1911 <nl> mmm / dev / null <nl> ppp b / examples / csharp / HelloworldXamarin / Droid / Properties / AssemblyInfo . cs <nl> <nl> + using System . Reflection ; <nl> + using System . Runtime . CompilerServices ; <nl> + using Android . App ; <nl> + <nl> + / / Information about this assembly is defined by the following attributes . <nl> + / / Change them to the values specific to your project . <nl> + <nl> + [ assembly : AssemblyTitle ( " HelloworldXamarin . Droid " ) ] <nl> + [ assembly : AssemblyDescription ( " " ) ] <nl> + [ assembly : AssemblyConfiguration ( " " ) ] <nl> + [ assembly : AssemblyCompany ( " " ) ] <nl> + [ assembly : AssemblyProduct ( " " ) ] <nl> + [ assembly : AssemblyCopyright ( " $ { AuthorCopyright } " ) ] <nl> + [ assembly : AssemblyTrademark ( " " ) ] <nl> + [ assembly : AssemblyCulture ( " " ) ] <nl> + <nl> + / / The assembly version has the format " { Major } . { Minor } . { Build } . { Revision } " . <nl> + / / The form " { Major } . { Minor } . * " will automatically update the build and revision , <nl> + / / and " { Major } . { Minor } . { Build } . * " will update just the revision . <nl> + <nl> + [ assembly : AssemblyVersion ( " 1 . 0 . 0 " ) ] <nl> + <nl> + / / The following attributes are used to specify the signing key for the assembly , <nl> + / / if desired . See the Mono documentation for more information about signing . <nl> + <nl> + / / [ assembly : AssemblyDelaySign ( false ) ] <nl> + / / [ assembly : AssemblyKeyFile ( " " ) ] <nl> new file mode 100644 <nl> index 00000000000 . . 10f52d46021 <nl> mmm / dev / null <nl> ppp b / examples / csharp / HelloworldXamarin / Droid / Resources / AboutResources . txt <nl> <nl> + Images , layout descriptions , binary blobs and string dictionaries can be included <nl> + in your application as resource files . Various Android APIs are designed to <nl> + operate on the resource IDs instead of dealing with images , strings or binary blobs <nl> + directly . <nl> + <nl> + For example , a sample Android app that contains a user interface layout ( main . axml ) , <nl> + an internationalization string table ( strings . xml ) and some icons ( drawable - XXX / icon . png ) <nl> + would keep its resources in the " Resources " directory of the application : <nl> + <nl> + Resources / <nl> + drawable / <nl> + icon . png <nl> + <nl> + layout / <nl> + main . axml <nl> + <nl> + values / <nl> + strings . xml <nl> + <nl> + In order to get the build system to recognize Android resources , set the build action to <nl> + " AndroidResource " . The native Android APIs do not operate directly with filenames , but <nl> + instead operate on resource IDs . When you compile an Android application that uses resources , <nl> + the build system will package the resources for distribution and generate a class called " R " <nl> + ( this is an Android convention ) that contains the tokens for each one of the resources <nl> + included . For example , for the above Resources layout , this is what the R class would expose : <nl> + <nl> + public class R { <nl> + public class drawable { <nl> + public const int icon = 0x123 ; <nl> + } <nl> + <nl> + public class layout { <nl> + public const int main = 0x456 ; <nl> + } <nl> + <nl> + public class strings { <nl> + public const int first_string = 0xabc ; <nl> + public const int second_string = 0xbcd ; <nl> + } <nl> + } <nl> + <nl> + You would then use R . drawable . icon to reference the drawable / icon . png file , or R . layout . main <nl> + to reference the layout / main . axml file , or R . strings . first_string to reference the first <nl> + string in the dictionary file values / strings . xml . <nl> new file mode 100644 <nl> index 00000000000 . . f475dda40b2 <nl> mmm / dev / null <nl> ppp b / examples / csharp / HelloworldXamarin / Droid / Resources / Resource . designer . cs <nl> <nl> + namespace HelloworldXamarin . Droid . Resources <nl> + { <nl> + <nl> + <nl> + public partial class Resource <nl> + { <nl> + <nl> + public partial class Attribute <nl> + { <nl> + <nl> + private Attribute ( ) <nl> + { <nl> + } <nl> + } <nl> + <nl> + public partial class Drawable <nl> + { <nl> + <nl> + / / aapt resource value : 0x7f020000 <nl> + public const int icon = 2130837504 ; <nl> + <nl> + private Drawable ( ) <nl> + { <nl> + } <nl> + } <nl> + <nl> + public partial class Layout <nl> + { <nl> + <nl> + / / aapt resource value : 0x7f030000 <nl> + public const int Main = 2130903040 ; <nl> + <nl> + private Layout ( ) <nl> + { <nl> + } <nl> + } <nl> + <nl> + public partial class String <nl> + { <nl> + <nl> + / / aapt resource value : 0x7f040000 <nl> + public const int hello = 2130968576 ; <nl> + <nl> + / / aapt resource value : 0x7f040001 <nl> + public const int app_name = 2130968577 ; <nl> + <nl> + private String ( ) <nl> + { <nl> + } <nl> + } <nl> + <nl> + public partial class Id <nl> + { <nl> + <nl> + / / aapt resource value : 0x7f050000 <nl> + public const int myButton = 2131034112 ; <nl> + <nl> + private Id ( ) <nl> + { <nl> + } <nl> + } <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 8cb72282b94 <nl> mmm / dev / null <nl> ppp b / examples / csharp / HelloworldXamarin / Droid / Resources / layout / Main . axml <nl> <nl> + < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> + < LinearLayout xmlns : android = " http : / / schemas . android . com / apk / res / android " android : orientation = " vertical " android : layout_width = " match_parent " android : layout_height = " match_parent " > <nl> + < Button android : id = " @ + id / myButton " android : layout_width = " match_parent " android : layout_height = " wrap_content " android : text = " @ string / hello " / > <nl> + < / LinearLayout > <nl> new file mode 100644 <nl> index 00000000000 . . f4c804644c5 <nl> Binary files / dev / null and b / examples / csharp / HelloworldXamarin / Droid / Resources / mipmap - hdpi / Icon . png differ <nl> new file mode 100644 <nl> index 00000000000 . . ef1e1ee7dc3 <nl> Binary files / dev / null and b / examples / csharp / HelloworldXamarin / Droid / Resources / mipmap - mdpi / Icon . png differ <nl> new file mode 100644 <nl> index 00000000000 . . b7e2e57aa90 <nl> Binary files / dev / null and b / examples / csharp / HelloworldXamarin / Droid / Resources / mipmap - xhdpi / Icon . png differ <nl> new file mode 100644 <nl> index 00000000000 . . 8d20a38d178 <nl> Binary files / dev / null and b / examples / csharp / HelloworldXamarin / Droid / Resources / mipmap - xxhdpi / Icon . png differ <nl> new file mode 100644 <nl> index 00000000000 . . 6d9919c41a3 <nl> Binary files / dev / null and b / examples / csharp / HelloworldXamarin / Droid / Resources / mipmap - xxxhdpi / Icon . png differ <nl> new file mode 100644 <nl> index 00000000000 . . 0a47c047e26 <nl> mmm / dev / null <nl> ppp b / examples / csharp / HelloworldXamarin / Droid / Resources / values / Strings . xml <nl> <nl> + < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> + < resources > <nl> + < string name = " hello " > Hello World , Click Me ! < / string > <nl> + < string name = " app_name " > HelloworldXamarin . Droid < / string > <nl> + < / resources > <nl> new file mode 100644 <nl> index 00000000000 . . e2a738f157e <nl> mmm / dev / null <nl> ppp b / examples / csharp / HelloworldXamarin / HelloworldXamarin . sln <nl> <nl> + <nl> + Microsoft Visual Studio Solution File , Format Version 12 . 00 <nl> + # Visual Studio 2012 <nl> + Project ( " { D954291E - 2A0B - 460D - 934E - DC6B0785DB48 } " ) = " HelloworldXamarin " , " HelloworldXamarin \ HelloworldXamarin . shproj " , " { 42FFF3D8 - 934F - 4475 - 8E68 - 08DA340BF6E8 } " <nl> + EndProject <nl> + Project ( " { FAE04EC0 - 301F - 11D3 - BF4B - 00C04F79EFBC } " ) = " HelloworldXamarin . Droid " , " Droid \ HelloworldXamarin . Droid . csproj " , " { B9B0D41C - 1C07 - 4590 - A919 - 5865E741B2EA } " <nl> + EndProject <nl> + Project ( " { FAE04EC0 - 301F - 11D3 - BF4B - 00C04F79EFBC } " ) = " HelloworldXamarin . iOS " , " iOS \ HelloworldXamarin . iOS . csproj " , " { 62336DF0 - 60D8 - 478F - 8140 - B3CB089B417E } " <nl> + EndProject <nl> + Global <nl> + GlobalSection ( SolutionConfigurationPlatforms ) = preSolution <nl> + Debug | Any CPU = Debug | Any CPU <nl> + Release | Any CPU = Release | Any CPU <nl> + Debug | iPhoneSimulator = Debug | iPhoneSimulator <nl> + Release | iPhone = Release | iPhone <nl> + Release | iPhoneSimulator = Release | iPhoneSimulator <nl> + Debug | iPhone = Debug | iPhone <nl> + EndGlobalSection <nl> + GlobalSection ( ProjectConfigurationPlatforms ) = postSolution <nl> + { B9B0D41C - 1C07 - 4590 - A919 - 5865E741B2EA } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> + { B9B0D41C - 1C07 - 4590 - A919 - 5865E741B2EA } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> + { B9B0D41C - 1C07 - 4590 - A919 - 5865E741B2EA } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> + { B9B0D41C - 1C07 - 4590 - A919 - 5865E741B2EA } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> + { B9B0D41C - 1C07 - 4590 - A919 - 5865E741B2EA } . Debug | iPhoneSimulator . ActiveCfg = Debug | Any CPU <nl> + { B9B0D41C - 1C07 - 4590 - A919 - 5865E741B2EA } . Debug | iPhoneSimulator . Build . 0 = Debug | Any CPU <nl> + { B9B0D41C - 1C07 - 4590 - A919 - 5865E741B2EA } . Release | iPhone . ActiveCfg = Release | Any CPU <nl> + { B9B0D41C - 1C07 - 4590 - A919 - 5865E741B2EA } . Release | iPhone . Build . 0 = Release | Any CPU <nl> + { B9B0D41C - 1C07 - 4590 - A919 - 5865E741B2EA } . Release | iPhoneSimulator . ActiveCfg = Release | Any CPU <nl> + { B9B0D41C - 1C07 - 4590 - A919 - 5865E741B2EA } . Release | iPhoneSimulator . Build . 0 = Release | Any CPU <nl> + { B9B0D41C - 1C07 - 4590 - A919 - 5865E741B2EA } . Debug | iPhone . ActiveCfg = Debug | Any CPU <nl> + { B9B0D41C - 1C07 - 4590 - A919 - 5865E741B2EA } . Debug | iPhone . Build . 0 = Debug | Any CPU <nl> + { 62336DF0 - 60D8 - 478F - 8140 - B3CB089B417E } . Debug | Any CPU . ActiveCfg = Debug | iPhoneSimulator <nl> + { 62336DF0 - 60D8 - 478F - 8140 - B3CB089B417E } . Debug | Any CPU . Build . 0 = Debug | iPhoneSimulator <nl> + { 62336DF0 - 60D8 - 478F - 8140 - B3CB089B417E } . Release | Any CPU . ActiveCfg = Release | iPhone <nl> + { 62336DF0 - 60D8 - 478F - 8140 - B3CB089B417E } . Release | Any CPU . Build . 0 = Release | iPhone <nl> + { 62336DF0 - 60D8 - 478F - 8140 - B3CB089B417E } . Debug | iPhoneSimulator . ActiveCfg = Debug | iPhoneSimulator <nl> + { 62336DF0 - 60D8 - 478F - 8140 - B3CB089B417E } . Debug | iPhoneSimulator . Build . 0 = Debug | iPhoneSimulator <nl> + { 62336DF0 - 60D8 - 478F - 8140 - B3CB089B417E } . Release | iPhone . ActiveCfg = Release | iPhone <nl> + { 62336DF0 - 60D8 - 478F - 8140 - B3CB089B417E } . Release | iPhone . Build . 0 = Release | iPhone <nl> + { 62336DF0 - 60D8 - 478F - 8140 - B3CB089B417E } . Release | iPhoneSimulator . ActiveCfg = Release | iPhoneSimulator <nl> + { 62336DF0 - 60D8 - 478F - 8140 - B3CB089B417E } . Release | iPhoneSimulator . Build . 0 = Release | iPhoneSimulator <nl> + { 62336DF0 - 60D8 - 478F - 8140 - B3CB089B417E } . Debug | iPhone . ActiveCfg = Debug | iPhone <nl> + { 62336DF0 - 60D8 - 478F - 8140 - B3CB089B417E } . Debug | iPhone . Build . 0 = Debug | iPhone <nl> + EndGlobalSection <nl> + EndGlobal <nl> new file mode 100644 <nl> index 00000000000 . . 87466cb4a72 <nl> mmm / dev / null <nl> ppp b / examples / csharp / HelloworldXamarin / HelloworldXamarin / HelloworldXamarin . projitems <nl> <nl> + < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> + < Project xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> + < PropertyGroup > <nl> + < MSBuildAllProjects > $ ( MSBuildAllProjects ) ; $ ( MSBuildThisFileFullPath ) < / MSBuildAllProjects > <nl> + < HasSharedItems > true < / HasSharedItems > <nl> + < SharedGUID > { 42FFF3D8 - 934F - 4475 - 8E68 - 08DA340BF6E8 } < / SharedGUID > <nl> + < / PropertyGroup > <nl> + < PropertyGroup Label = " Configuration " > <nl> + < Import_RootNamespace > HelloworldXamarin < / Import_RootNamespace > <nl> + < / PropertyGroup > <nl> + < ItemGroup > <nl> + < Compile Include = " $ ( MSBuildThisFileDirectory ) MyClass . cs " / > <nl> + < / ItemGroup > <nl> + < / Project > <nl> \ No newline at end of file <nl> new file mode 100644 <nl> index 00000000000 . . 0eb2448b25f <nl> mmm / dev / null <nl> ppp b / examples / csharp / HelloworldXamarin / HelloworldXamarin / HelloworldXamarin . shproj <nl> <nl> + < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> + < Project ToolsVersion = " 4 . 0 " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> + < PropertyGroup > <nl> + < ProjectGuid > { 42FFF3D8 - 934F - 4475 - 8E68 - 08DA340BF6E8 } < / ProjectGuid > <nl> + < / PropertyGroup > <nl> + < Import Project = " $ ( MSBuildExtensionsPath ) \ $ ( MSBuildToolsVersion ) \ Microsoft . Common . props " Condition = " Exists ( ' $ ( MSBuildExtensionsPath ) \ $ ( MSBuildToolsVersion ) \ Microsoft . Common . props ' ) " / > <nl> + < Import Project = " $ ( MSBuildExtensionsPath32 ) \ Microsoft \ VisualStudio \ v $ ( VisualStudioVersion ) \ CodeSharing \ Microsoft . CodeSharing . Common . Default . props " / > <nl> + < Import Project = " $ ( MSBuildExtensionsPath32 ) \ Microsoft \ VisualStudio \ v $ ( VisualStudioVersion ) \ CodeSharing \ Microsoft . CodeSharing . Common . props " / > <nl> + < Import Project = " HelloworldXamarin . projitems " Label = " Shared " / > <nl> + < Import Project = " $ ( MSBuildExtensionsPath32 ) \ Microsoft \ VisualStudio \ v $ ( VisualStudioVersion ) \ CodeSharing \ Microsoft . CodeSharing . CSharp . targets " / > <nl> + < / Project > <nl> \ No newline at end of file <nl> new file mode 100644 <nl> index 00000000000 . . e3fa67641ab <nl> mmm / dev / null <nl> ppp b / examples / csharp / HelloworldXamarin / HelloworldXamarin / MyClass . cs <nl> <nl> + using System ; <nl> + namespace HelloworldXamarin <nl> + { <nl> + public class MyClass <nl> + { <nl> + public MyClass ( ) <nl> + { <nl> + } <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 5c953590879 <nl> mmm / dev / null <nl> ppp b / examples / csharp / HelloworldXamarin / iOS / AppDelegate . cs <nl> <nl> + using Foundation ; <nl> + using UIKit ; <nl> + <nl> + namespace HelloworldXamarin . iOS <nl> + { <nl> + / / The UIApplicationDelegate for the application . This class is responsible for launching the <nl> + / / User Interface of the application , as well as listening ( and optionally responding ) to application events from iOS . <nl> + [ Register ( " AppDelegate " ) ] <nl> + public class AppDelegate : UIApplicationDelegate <nl> + { <nl> + / / class - level declarations <nl> + <nl> + public override UIWindow Window <nl> + { <nl> + get ; <nl> + set ; <nl> + } <nl> + <nl> + public override bool FinishedLaunching ( UIApplication application , NSDictionary launchOptions ) <nl> + { <nl> + / / Override point for customization after application launch . <nl> + / / If not required for your application you can safely delete this method <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + public override void OnResignActivation ( UIApplication application ) <nl> + { <nl> + / / Invoked when the application is about to move from active to inactive state . <nl> + / / This can occur for certain types of temporary interruptions ( such as an incoming phone call or SMS message ) <nl> + / / or when the user quits the application and it begins the transition to the background state . <nl> + / / Games should use this method to pause the game . <nl> + } <nl> + <nl> + public override void DidEnterBackground ( UIApplication application ) <nl> + { <nl> + / / Use this method to release shared resources , save user data , invalidate timers and store the application state . <nl> + / / If your application supports background exection this method is called instead of WillTerminate when the user quits . <nl> + } <nl> + <nl> + public override void WillEnterForeground ( UIApplication application ) <nl> + { <nl> + / / Called as part of the transiton from background to active state . <nl> + / / Here you can undo many of the changes made on entering the background . <nl> + } <nl> + <nl> + public override void OnActivated ( UIApplication application ) <nl> + { <nl> + / / Restart any tasks that were paused ( or not yet started ) while the application was inactive . <nl> + / / If the application was previously in the background , optionally refresh the user interface . <nl> + } <nl> + <nl> + public override void WillTerminate ( UIApplication application ) <nl> + { <nl> + / / Called when the application is about to terminate . Save data , if needed . See also DidEnterBackground . <nl> + } <nl> + } <nl> + } <nl> + <nl> new file mode 100644 <nl> index 00000000000 . . 64d0e3ddf87 <nl> mmm / dev / null <nl> ppp b / examples / csharp / HelloworldXamarin / iOS / Assets . xcassets / AppIcon . appiconset / Contents . json <nl> <nl> + { <nl> + " images " : [ <nl> + { <nl> + " idiom " : " iphone " , <nl> + " size " : " 20x20 " , <nl> + " scale " : " 2x " <nl> + } , <nl> + { <nl> + " idiom " : " iphone " , <nl> + " size " : " 20x20 " , <nl> + " scale " : " 3x " <nl> + } , <nl> + { <nl> + " idiom " : " iphone " , <nl> + " size " : " 29x29 " , <nl> + " scale " : " 2x " <nl> + } , <nl> + { <nl> + " idiom " : " iphone " , <nl> + " size " : " 29x29 " , <nl> + " scale " : " 3x " <nl> + } , <nl> + { <nl> + " idiom " : " iphone " , <nl> + " size " : " 40x40 " , <nl> + " scale " : " 2x " <nl> + } , <nl> + { <nl> + " idiom " : " iphone " , <nl> + " size " : " 40x40 " , <nl> + " scale " : " 3x " <nl> + } , <nl> + { <nl> + " idiom " : " iphone " , <nl> + " size " : " 60x60 " , <nl> + " scale " : " 2x " <nl> + } , <nl> + { <nl> + " idiom " : " iphone " , <nl> + " size " : " 60x60 " , <nl> + " scale " : " 3x " <nl> + } , <nl> + { <nl> + " idiom " : " ipad " , <nl> + " size " : " 20x20 " , <nl> + " scale " : " 1x " <nl> + } , <nl> + { <nl> + " idiom " : " ipad " , <nl> + " size " : " 20x20 " , <nl> + " scale " : " 2x " <nl> + } , <nl> + { <nl> + " idiom " : " ipad " , <nl> + " size " : " 29x29 " , <nl> + " scale " : " 1x " <nl> + } , <nl> + { <nl> + " idiom " : " ipad " , <nl> + " size " : " 29x29 " , <nl> + " scale " : " 2x " <nl> + } , <nl> + { <nl> + " idiom " : " ipad " , <nl> + " size " : " 40x40 " , <nl> + " scale " : " 1x " <nl> + } , <nl> + { <nl> + " idiom " : " ipad " , <nl> + " size " : " 40x40 " , <nl> + " scale " : " 2x " <nl> + } , <nl> + { <nl> + " idiom " : " ipad " , <nl> + " size " : " 76x76 " , <nl> + " scale " : " 1x " <nl> + } , <nl> + { <nl> + " idiom " : " ipad " , <nl> + " size " : " 76x76 " , <nl> + " scale " : " 2x " <nl> + } , <nl> + { <nl> + " idiom " : " ipad " , <nl> + " size " : " 83 . 5x83 . 5 " , <nl> + " scale " : " 2x " <nl> + } , <nl> + { <nl> + " idiom " : " ios - marketing " , <nl> + " size " : " 1024x1024 " , <nl> + " scale " : " 1x " <nl> + } , <nl> + { <nl> + " size " : " 24x24 " , <nl> + " idiom " : " watch " , <nl> + " scale " : " 2x " , <nl> + " role " : " notificationCenter " , <nl> + " subtype " : " 38mm " <nl> + } , <nl> + { <nl> + " size " : " 27 . 5x27 . 5 " , <nl> + " idiom " : " watch " , <nl> + " scale " : " 2x " , <nl> + " role " : " notificationCenter " , <nl> + " subtype " : " 42mm " <nl> + } , <nl> + { <nl> + " size " : " 29x29 " , <nl> + " idiom " : " watch " , <nl> + " role " : " companionSettings " , <nl> + " scale " : " 2x " <nl> + } , <nl> + { <nl> + " size " : " 29x29 " , <nl> + " idiom " : " watch " , <nl> + " role " : " companionSettings " , <nl> + " scale " : " 3x " <nl> + } , <nl> + { <nl> + " size " : " 40x40 " , <nl> + " idiom " : " watch " , <nl> + " scale " : " 2x " , <nl> + " role " : " appLauncher " , <nl> + " subtype " : " 38mm " <nl> + } , <nl> + { <nl> + " size " : " 44x44 " , <nl> + " idiom " : " watch " , <nl> + " scale " : " 2x " , <nl> + " role " : " longLook " , <nl> + " subtype " : " 42mm " <nl> + } , <nl> + { <nl> + " size " : " 86x86 " , <nl> + " idiom " : " watch " , <nl> + " scale " : " 2x " , <nl> + " role " : " quickLook " , <nl> + " subtype " : " 38mm " <nl> + } , <nl> + { <nl> + " size " : " 98x98 " , <nl> + " idiom " : " watch " , <nl> + " scale " : " 2x " , <nl> + " role " : " quickLook " , <nl> + " subtype " : " 42mm " <nl> + } , <nl> + { <nl> + " idiom " : " mac " , <nl> + " size " : " 16x16 " , <nl> + " scale " : " 1x " <nl> + } , <nl> + { <nl> + " idiom " : " mac " , <nl> + " size " : " 16x16 " , <nl> + " scale " : " 2x " <nl> + } , <nl> + { <nl> + " idiom " : " mac " , <nl> + " size " : " 32x32 " , <nl> + " scale " : " 1x " <nl> + } , <nl> + { <nl> + " idiom " : " mac " , <nl> + " size " : " 32x32 " , <nl> + " scale " : " 2x " <nl> + } , <nl> + { <nl> + " idiom " : " mac " , <nl> + " size " : " 128x128 " , <nl> + " scale " : " 1x " <nl> + } , <nl> + { <nl> + " idiom " : " mac " , <nl> + " size " : " 128x128 " , <nl> + " scale " : " 2x " <nl> + } , <nl> + { <nl> + " idiom " : " mac " , <nl> + " size " : " 256x256 " , <nl> + " scale " : " 1x " <nl> + } , <nl> + { <nl> + " idiom " : " mac " , <nl> + " size " : " 256x256 " , <nl> + " scale " : " 2x " <nl> + } , <nl> + { <nl> + " idiom " : " mac " , <nl> + " size " : " 512x512 " , <nl> + " scale " : " 1x " <nl> + } , <nl> + { <nl> + " idiom " : " mac " , <nl> + " size " : " 512x512 " , <nl> + " scale " : " 2x " <nl> + } <nl> + ] , <nl> + " info " : { <nl> + " version " : 1 , <nl> + " author " : " xcode " <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 4caf392f92c <nl> mmm / dev / null <nl> ppp b / examples / csharp / HelloworldXamarin / iOS / Assets . xcassets / Contents . json <nl> <nl> + { <nl> + " info " : { <nl> + " version " : 1 , <nl> + " author " : " xcode " <nl> + } <nl> + } <nl> \ No newline at end of file <nl> new file mode 100644 <nl> index 00000000000 . . 9ae599370b4 <nl> mmm / dev / null <nl> ppp b / examples / csharp / HelloworldXamarin / iOS / Entitlements . plist <nl> <nl> + < ? xml version = " 1 . 0 " encoding = " UTF - 8 " ? > <nl> + < ! DOCTYPE plist PUBLIC " - / / Apple / / DTD PLIST 1 . 0 / / EN " " http : / / www . apple . com / DTDs / PropertyList - 1 . 0 . dtd " > <nl> + < plist version = " 1 . 0 " > <nl> + < dict > <nl> + < / dict > <nl> + < / plist > <nl> new file mode 100644 <nl> index 00000000000 . . 27cb1c41ab4 <nl> mmm / dev / null <nl> ppp b / examples / csharp / HelloworldXamarin / iOS / HelloworldXamarin . iOS . csproj <nl> <nl> + < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> + < Project DefaultTargets = " Build " ToolsVersion = " 4 . 0 " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> + < PropertyGroup > <nl> + < Configuration Condition = " ' $ ( Configuration ) ' = = ' ' " > Debug < / Configuration > <nl> + < Platform Condition = " ' $ ( Platform ) ' = = ' ' " > iPhoneSimulator < / Platform > <nl> + < ProjectGuid > { 62336DF0 - 60D8 - 478F - 8140 - B3CB089B417E } < / ProjectGuid > <nl> + < ProjectTypeGuids > { FEACFBD2 - 3405 - 455C - 9665 - 78FE426C6842 } ; { FAE04EC0 - 301F - 11D3 - BF4B - 00C04F79EFBC } < / ProjectTypeGuids > <nl> + < OutputType > Exe < / OutputType > <nl> + < RootNamespace > HelloworldXamarin . iOS < / RootNamespace > <nl> + < AssemblyName > HelloworldXamarin . iOS < / AssemblyName > <nl> + < IPhoneResourcePrefix > Resources < / IPhoneResourcePrefix > <nl> + < / PropertyGroup > <nl> + < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | iPhoneSimulator ' " > <nl> + < DebugSymbols > true < / DebugSymbols > <nl> + < DebugType > full < / DebugType > <nl> + < Optimize > false < / Optimize > <nl> + < OutputPath > bin \ iPhoneSimulator \ Debug < / OutputPath > <nl> + < DefineConstants > DEBUG ; ENABLE_TEST_CLOUD ; < / DefineConstants > <nl> + < ErrorReport > prompt < / ErrorReport > <nl> + < WarningLevel > 4 < / WarningLevel > <nl> + < CodesignKey > iPhone Developer < / CodesignKey > <nl> + < MtouchDebug > true < / MtouchDebug > <nl> + < MtouchNoSymbolStrip > true < / MtouchNoSymbolStrip > <nl> + < MtouchFastDev > true < / MtouchFastDev > <nl> + < IOSDebuggerPort > 45216 < / IOSDebuggerPort > <nl> + < MtouchLink > None < / MtouchLink > <nl> + < MtouchArch > x86_64 < / MtouchArch > <nl> + < MtouchHttpClientHandler > HttpClientHandler < / MtouchHttpClientHandler > <nl> + < PlatformTarget > x86 < / PlatformTarget > <nl> + < / PropertyGroup > <nl> + < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Release | iPhone ' " > <nl> + < DebugType > pdbonly < / DebugType > <nl> + < Optimize > true < / Optimize > <nl> + < OutputPath > bin \ iPhone \ Release < / OutputPath > <nl> + < ErrorReport > prompt < / ErrorReport > <nl> + < WarningLevel > 4 < / WarningLevel > <nl> + < CodesignKey > iPhone Developer < / CodesignKey > <nl> + < MtouchFloat32 > true < / MtouchFloat32 > <nl> + < CodesignEntitlements > Entitlements . plist < / CodesignEntitlements > <nl> + < MtouchLink > SdkOnly < / MtouchLink > <nl> + < MtouchArch > ARM64 < / MtouchArch > <nl> + < MtouchHttpClientHandler > HttpClientHandler < / MtouchHttpClientHandler > <nl> + < PlatformTarget > x86 < / PlatformTarget > <nl> + < / PropertyGroup > <nl> + < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Release | iPhoneSimulator ' " > <nl> + < DebugType > pdbonly < / DebugType > <nl> + < Optimize > true < / Optimize > <nl> + < OutputPath > bin \ iPhoneSimulator \ Release < / OutputPath > <nl> + < ErrorReport > prompt < / ErrorReport > <nl> + < WarningLevel > 4 < / WarningLevel > <nl> + < CodesignKey > iPhone Developer < / CodesignKey > <nl> + < MtouchNoSymbolStrip > true < / MtouchNoSymbolStrip > <nl> + < MtouchLink > None < / MtouchLink > <nl> + < MtouchArch > x86_64 < / MtouchArch > <nl> + < MtouchHttpClientHandler > HttpClientHandler < / MtouchHttpClientHandler > <nl> + < PlatformTarget > x86 < / PlatformTarget > <nl> + < / PropertyGroup > <nl> + < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | iPhone ' " > <nl> + < DebugSymbols > true < / DebugSymbols > <nl> + < DebugType > full < / DebugType > <nl> + < Optimize > false < / Optimize > <nl> + < OutputPath > bin \ iPhone \ Debug < / OutputPath > <nl> + < DefineConstants > DEBUG ; ENABLE_TEST_CLOUD ; < / DefineConstants > <nl> + < ErrorReport > prompt < / ErrorReport > <nl> + < WarningLevel > 4 < / WarningLevel > <nl> + < CodesignKey > iPhone Developer < / CodesignKey > <nl> + < DeviceSpecificBuild > true < / DeviceSpecificBuild > <nl> + < MtouchDebug > true < / MtouchDebug > <nl> + < MtouchNoSymbolStrip > true < / MtouchNoSymbolStrip > <nl> + < MtouchFastDev > true < / MtouchFastDev > <nl> + < MtouchFloat32 > true < / MtouchFloat32 > <nl> + < CodesignEntitlements > Entitlements . plist < / CodesignEntitlements > <nl> + < IOSDebuggerPort > 35164 < / IOSDebuggerPort > <nl> + < MtouchLink > SdkOnly < / MtouchLink > <nl> + < MtouchArch > ARM64 < / MtouchArch > <nl> + < MtouchHttpClientHandler > HttpClientHandler < / MtouchHttpClientHandler > <nl> + < PlatformTarget > x86 < / PlatformTarget > <nl> + < / PropertyGroup > <nl> + < ItemGroup > <nl> + < Reference Include = " System " / > <nl> + < Reference Include = " System . Xml " / > <nl> + < Reference Include = " System . Core " / > <nl> + < Reference Include = " Xamarin . iOS " / > <nl> + < / ItemGroup > <nl> + < ItemGroup > <nl> + < ImageAsset Include = " Assets . xcassets \ AppIcon . appiconset \ Contents . json " / > <nl> + < ImageAsset Include = " Assets . xcassets \ Contents . json " / > <nl> + < / ItemGroup > <nl> + < ItemGroup > <nl> + < Folder Include = " Resources \ " / > <nl> + < / ItemGroup > <nl> + < ItemGroup > <nl> + < InterfaceDefinition Include = " LaunchScreen . storyboard " / > <nl> + < InterfaceDefinition Include = " Main . storyboard " / > <nl> + < / ItemGroup > <nl> + < ItemGroup > <nl> + < None Include = " Info . plist " / > <nl> + < None Include = " Entitlements . plist " / > <nl> + < / ItemGroup > <nl> + < ItemGroup > <nl> + < Compile Include = " Main . cs " / > <nl> + < Compile Include = " AppDelegate . cs " / > <nl> + < Compile Include = " ViewController . cs " / > <nl> + < Compile Include = " ViewController . designer . cs " > <nl> + < DependentUpon > ViewController . cs < / DependentUpon > <nl> + < / Compile > <nl> + < / ItemGroup > <nl> + < Import Project = " . . \ HelloworldXamarin \ HelloworldXamarin . projitems " Label = " Shared " Condition = " Exists ( ' . . \ HelloworldXamarin \ HelloworldXamarin . projitems ' ) " / > <nl> + < Import Project = " $ ( MSBuildExtensionsPath ) \ Xamarin \ iOS \ Xamarin . iOS . CSharp . targets " / > <nl> + < / Project > <nl> \ No newline at end of file <nl> new file mode 100644 <nl> index 00000000000 . . 1663f194523 <nl> mmm / dev / null <nl> ppp b / examples / csharp / HelloworldXamarin / iOS / Info . plist <nl> <nl> + < ? xml version = " 1 . 0 " encoding = " UTF - 8 " ? > <nl> + < ! DOCTYPE plist PUBLIC " - / / Apple / / DTD PLIST 1 . 0 / / EN " " http : / / www . apple . com / DTDs / PropertyList - 1 . 0 . dtd " > <nl> + < plist version = " 1 . 0 " > <nl> + < dict > <nl> + < key > CFBundleName < / key > <nl> + < string > HelloworldXamarin < / string > <nl> + < key > CFBundleIdentifier < / key > <nl> + < string > io . grpc . examples . HelloworldXamarin < / string > <nl> + < key > CFBundleShortVersionString < / key > <nl> + < string > 1 . 0 < / string > <nl> + < key > CFBundleVersion < / key > <nl> + < string > 1 . 0 < / string > <nl> + < key > LSRequiresIPhoneOS < / key > <nl> + < true / > <nl> + < key > MinimumOSVersion < / key > <nl> + < string > 8 . 0 < / string > <nl> + < key > UIDeviceFamily < / key > <nl> + < array > <nl> + < integer > 1 < / integer > <nl> + < integer > 2 < / integer > <nl> + < / array > <nl> + < key > UILaunchStoryboardName < / key > <nl> + < string > LaunchScreen < / string > <nl> + < key > UIMainStoryboardFile < / key > <nl> + < string > Main < / string > <nl> + < key > UIMainStoryboardFile ~ ipad < / key > <nl> + < string > Main < / string > <nl> + < key > UIRequiredDeviceCapabilities < / key > <nl> + < array > <nl> + < string > armv7 < / string > <nl> + < / array > <nl> + < key > UISupportedInterfaceOrientations < / key > <nl> + < array > <nl> + < string > UIInterfaceOrientationPortrait < / string > <nl> + < string > UIInterfaceOrientationLandscapeLeft < / string > <nl> + < string > UIInterfaceOrientationLandscapeRight < / string > <nl> + < / array > <nl> + < key > UISupportedInterfaceOrientations ~ ipad < / key > <nl> + < array > <nl> + < string > UIInterfaceOrientationPortrait < / string > <nl> + < string > UIInterfaceOrientationPortraitUpsideDown < / string > <nl> + < string > UIInterfaceOrientationLandscapeLeft < / string > <nl> + < string > UIInterfaceOrientationLandscapeRight < / string > <nl> + < / array > <nl> + < key > XSAppIconAssets < / key > <nl> + < string > Assets . xcassets / AppIcon . appiconset < / string > <nl> + < / dict > <nl> + < / plist > <nl> new file mode 100644 <nl> index 00000000000 . . 5d2e905aa80 <nl> mmm / dev / null <nl> ppp b / examples / csharp / HelloworldXamarin / iOS / LaunchScreen . storyboard <nl> <nl> + < ? xml version = " 1 . 0 " encoding = " UTF - 8 " standalone = " no " ? > <nl> + < document type = " com . apple . InterfaceBuilder3 . CocoaTouch . Storyboard . XIB " version = " 3 . 0 " toolsVersion = " 9532 " systemVersion = " 15D21 " targetRuntime = " iOS . CocoaTouch " propertyAccessControl = " none " useAutolayout = " YES " launchScreen = " YES " useTraitCollections = " YES " initialViewController = " 01J - lp - oVM " > <nl> + < dependencies > <nl> + < deployment identifier = " iOS " / > <nl> + < plugIn identifier = " com . apple . InterfaceBuilder . IBCocoaTouchPlugin " version = " 9530 " / > <nl> + < / dependencies > <nl> + < scenes > <nl> + < ! - - View Controller - - > <nl> + < scene sceneID = " EHf - IW - A2E " > <nl> + < objects > <nl> + < viewController id = " 01J - lp - oVM " sceneMemberID = " viewController " > <nl> + < layoutGuides > <nl> + < viewControllerLayoutGuide type = " top " id = " Llm - lL - Icb " / > <nl> + < viewControllerLayoutGuide type = " bottom " id = " xb3 - aO - Qok " / > <nl> + < / layoutGuides > <nl> + < view key = " view " contentMode = " scaleToFill " id = " Ze5 - 6b - 2t3 " > <nl> + < rect key = " frame " x = " 0 . 0 " y = " 0 . 0 " width = " 600 " height = " 600 " / > <nl> + < autoresizingMask key = " autoresizingMask " widthSizable = " YES " heightSizable = " YES " / > <nl> + < color key = " backgroundColor " white = " 1 " alpha = " 1 " colorSpace = " custom " customColorSpace = " calibratedWhite " / > <nl> + < / view > <nl> + < / viewController > <nl> + < placeholder placeholderIdentifier = " IBFirstResponder " id = " iYj - Kq - Ea1 " userLabel = " First Responder " sceneMemberID = " firstResponder " / > <nl> + < / objects > <nl> + < point key = " canvasLocation " x = " 53 " y = " 375 " / > <nl> + < / scene > <nl> + < / scenes > <nl> + < / document > <nl> new file mode 100644 <nl> index 00000000000 . . 76b1598577f <nl> mmm / dev / null <nl> ppp b / examples / csharp / HelloworldXamarin / iOS / Main . cs <nl> <nl> + using System ; <nl> + using System . Collections . Generic ; <nl> + using System . Linq ; <nl> + <nl> + using Foundation ; <nl> + using UIKit ; <nl> + <nl> + namespace HelloworldXamarin . iOS <nl> + { <nl> + public class Application <nl> + { <nl> + / / This is the main entry point of the application . <nl> + static void Main ( string [ ] args ) <nl> + { <nl> + / / if you want to use a different Application Delegate class from " AppDelegate " <nl> + / / you can specify it here . <nl> + UIApplication . Main ( args , null , " AppDelegate " ) ; <nl> + } <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 92a28ce08d1 <nl> mmm / dev / null <nl> ppp b / examples / csharp / HelloworldXamarin / iOS / Main . storyboard <nl> <nl> + < ? xml version = " 1 . 0 " encoding = " UTF - 8 " standalone = " no " ? > <nl> + < document type = " com . apple . InterfaceBuilder3 . CocoaTouch . Storyboard . XIB " version = " 3 . 0 " toolsVersion = " 6750 " systemVersion = " 14C109 " targetRuntime = " iOS . CocoaTouch " propertyAccessControl = " none " useAutolayout = " YES " useTraitCollections = " YES " initialViewController = " BYZ - 38 - t0r " > <nl> + < dependencies > <nl> + < plugIn identifier = " com . apple . InterfaceBuilder . IBCocoaTouchPlugin " version = " 6735 " / > <nl> + < / dependencies > <nl> + < scenes > <nl> + < ! - - View Controller - - > <nl> + < scene sceneID = " tne - QT - ifu " > <nl> + < objects > <nl> + < viewController id = " BYZ - 38 - t0r " customClass = " ViewController " sceneMemberID = " viewController " > <nl> + < layoutGuides > <nl> + < viewControllerLayoutGuide type = " top " id = " y3c - jy - aDJ " / > <nl> + < viewControllerLayoutGuide type = " bottom " id = " wfy - db - euE " / > <nl> + < / layoutGuides > <nl> + < view key = " view " contentMode = " scaleToFill " id = " 8bC - Xf - vdC " > <nl> + < rect key = " frame " x = " 0 . 0 " y = " 0 . 0 " width = " 600 " height = " 600 " / > <nl> + < autoresizingMask key = " autoresizingMask " widthSizable = " YES " heightSizable = " YES " / > <nl> + < subviews > <nl> + < button opaque = " NO " contentMode = " scaleToFill " contentHorizontalAlignment = " center " contentVerticalAlignment = " center " buttonType = " roundedRect " lineBreakMode = " middleTruncation " translatesAutoresizingMaskIntoConstraints = " NO " id = " oBE - Ac - vcx " > <nl> + < rect key = " frame " x = " 224 " y = " 285 " width = " 152 " height = " 30 " / > <nl> + < state key = " normal " title = " Hello World , Click Me ! " > <nl> + < color key = " titleShadowColor " white = " 0 . 5 " alpha = " 1 " colorSpace = " calibratedWhite " / > <nl> + < / state > <nl> + < / button > <nl> + < / subviews > <nl> + < color key = " backgroundColor " white = " 1 " alpha = " 1 " colorSpace = " custom " customColorSpace = " calibratedWhite " / > <nl> + < constraints > <nl> + < constraint firstItem = " oBE - Ac - vcx " firstAttribute = " centerX " secondItem = " 8bC - Xf - vdC " secondAttribute = " centerX " id = " HiD - uS - i16 " / > <nl> + < constraint firstItem = " oBE - Ac - vcx " firstAttribute = " centerY " secondItem = " 8bC - Xf - vdC " secondAttribute = " centerY " id = " YgX - 7e - bMc " / > <nl> + < / constraints > <nl> + < / view > <nl> + < connections > <nl> + < outlet property = " Button " destination = " oBE - Ac - vcx " id = " OkX - 0Z - gth " / > <nl> + < / connections > <nl> + < / viewController > <nl> + < placeholder placeholderIdentifier = " IBFirstResponder " id = " dkx - z0 - nzr " sceneMemberID = " firstResponder " / > <nl> + < / objects > <nl> + < / scene > <nl> + < / scenes > <nl> + < / document > <nl> new file mode 100644 <nl> index 00000000000 . . dfbaf084b6d <nl> mmm / dev / null <nl> ppp b / examples / csharp / HelloworldXamarin / iOS / ViewController . cs <nl> <nl> + using System ; <nl> + <nl> + using UIKit ; <nl> + <nl> + namespace HelloworldXamarin . iOS <nl> + { <nl> + public partial class ViewController : UIViewController <nl> + { <nl> + int count = 1 ; <nl> + <nl> + public ViewController ( IntPtr handle ) : base ( handle ) <nl> + { <nl> + } <nl> + <nl> + public override void ViewDidLoad ( ) <nl> + { <nl> + base . ViewDidLoad ( ) ; <nl> + <nl> + / / Perform any additional setup after loading the view , typically from a nib . <nl> + Button . AccessibilityIdentifier = " myButton " ; <nl> + Button . TouchUpInside + = delegate <nl> + { <nl> + var title = string . Format ( " { 0 } clicks ! " , count + + ) ; <nl> + Button . SetTitle ( title , UIControlState . Normal ) ; <nl> + } ; <nl> + } <nl> + <nl> + public override void DidReceiveMemoryWarning ( ) <nl> + { <nl> + base . DidReceiveMemoryWarning ( ) ; <nl> + / / Release any cached data , images , etc that aren ' t in use . <nl> + } <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 2677a068dca <nl> mmm / dev / null <nl> ppp b / examples / csharp / HelloworldXamarin / iOS / ViewController . designer . cs <nl> <nl> + / / <nl> + / / This file has been generated automatically by MonoDevelop to store outlets and <nl> + / / actions made in the Xcode designer . If it is removed , they will be lost . <nl> + / / Manual changes to this file may not be handled correctly . <nl> + / / <nl> + using Foundation ; <nl> + <nl> + namespace HelloworldXamarin . iOS <nl> + { <nl> + [ Register ( " ViewController " ) ] <nl> + partial class ViewController <nl> + { <nl> + [ Outlet ] <nl> + UIKit . UIButton Button { get ; set ; } <nl> + <nl> + void ReleaseDesignerOutlets ( ) <nl> + { <nl> + if ( Button ! = null ) <nl> + { <nl> + Button . Dispose ( ) ; <nl> + Button = null ; <nl> + } <nl> + } <nl> + } <nl> + } <nl>
|
add HelloworldXamarin scaffolding
|
grpc/grpc
|
3c497bf4c9259781f5e85442e4ea56924a16fd2d
|
2018-07-31T10:42:47Z
|
mmm a / . travis . yml <nl> ppp b / . travis . yml <nl> <nl> - # errata : <nl> - # - A travis bug causes caches to trample eachother when using the same <nl> - # compiler key ( which we don ' t use anyway ) . This is worked around for now by <nl> - # replacing the " compilers " with a build name prefixed by the no - op " : " <nl> - # command . See : https : / / github . com / travis - ci / travis - ci / issues / 4393 <nl> - # - sudo / dist / group are set so as to get Blue Box VMs , necessary for [ loopback ] <nl> - # IPv6 support <nl> - <nl> sudo : required <nl> dist : trusty <nl> <nl> + # workaround for https : / / github . com / travis - ci / travis - ci / issues / 5227 <nl> + addons : <nl> + hostname : bitcoin - tester <nl> + <nl> os : linux <nl> - language : cpp <nl> - compiler : gcc <nl> + language : generic <nl> + cache : <nl> + directories : <nl> + - depends / built <nl> + - depends / sdk - sources <nl> + - $ HOME / . ccache <nl> env : <nl> global : <nl> - MAKEJOBS = - j3 <nl> env : <nl> - SDK_URL = https : / / bitcoincore . org / depends - sources / sdks <nl> - PYTHON_DEBUG = 1 <nl> - WINEDEBUG = fixme - all <nl> - cache : <nl> - apt : true <nl> - directories : <nl> - - depends / built <nl> - - depends / sdk - sources <nl> - - $ HOME / . ccache <nl> - matrix : <nl> - fast_finish : true <nl> - include : <nl> - - compiler : " : ARM " <nl> - env : HOST = arm - linux - gnueabihf PACKAGES = " g + + - arm - linux - gnueabihf " DEP_OPTS = " NO_QT = 1 " CHECK_DOC = 1 GOAL = " install " BITCOIN_CONFIG = " - - enable - glibc - back - compat - - enable - reduce - exports " <nl> - - compiler : " : Win32 " <nl> - env : HOST = i686 - w64 - mingw32 DPKG_ADD_ARCH = " i386 " DEP_OPTS = " NO_QT = 1 " PACKAGES = " python3 nsis g + + - mingw - w64 - i686 wine1 . 6 bc " RUN_TESTS = true GOAL = " install " BITCOIN_CONFIG = " - - enable - reduce - exports " <nl> - - compiler : " : 32 - bit + dash " <nl> - env : HOST = i686 - pc - linux - gnu PACKAGES = " g + + - multilib bc python3 - zmq " DEP_OPTS = " NO_QT = 1 " RUN_TESTS = true GOAL = " install " BITCOIN_CONFIG = " - - enable - zmq - - enable - glibc - back - compat - - enable - reduce - exports LDFLAGS = - static - libstdc + + " USE_SHELL = " / bin / dash " <nl> - - compiler : " : Win64 " <nl> - env : HOST = x86_64 - w64 - mingw32 DPKG_ADD_ARCH = " i386 " DEP_OPTS = " NO_QT = 1 " PACKAGES = " python3 nsis g + + - mingw - w64 - x86 - 64 wine1 . 6 bc " RUN_TESTS = true GOAL = " install " BITCOIN_CONFIG = " - - enable - reduce - exports " <nl> - - compiler : " : bitcoind " <nl> - env : HOST = x86_64 - unknown - linux - gnu PACKAGES = " bc python3 - zmq " DEP_OPTS = " NO_QT = 1 NO_UPNP = 1 DEBUG = 1 " RUN_TESTS = true GOAL = " install " BITCOIN_CONFIG = " - - enable - zmq - - enable - glibc - back - compat - - enable - reduce - exports CPPFLAGS = - DDEBUG_LOCKORDER " <nl> - - compiler : " : No wallet " <nl> - env : HOST = x86_64 - unknown - linux - gnu PACKAGES = " python3 " DEP_OPTS = " NO_WALLET = 1 " RUN_TESTS = true GOAL = " install " BITCOIN_CONFIG = " - - enable - glibc - back - compat - - enable - reduce - exports " <nl> - - compiler : " : Cross - Mac " <nl> - env : HOST = x86_64 - apple - darwin11 PACKAGES = " cmake imagemagick libcap - dev librsvg2 - bin libz - dev libbz2 - dev libtiff - tools python - dev " BITCOIN_CONFIG = " - - enable - reduce - exports " OSX_SDK = 10 . 9 GOAL = " deploy " <nl> - exclude : <nl> - - compiler : gcc <nl> + matrix : <nl> + # ARM <nl> + - HOST = arm - linux - gnueabihf PACKAGES = " g + + - arm - linux - gnueabihf " DEP_OPTS = " NO_QT = 1 " CHECK_DOC = 1 GOAL = " install " BITCOIN_CONFIG = " - - enable - glibc - back - compat - - enable - reduce - exports " <nl> + # Win32 <nl> + - HOST = i686 - w64 - mingw32 DPKG_ADD_ARCH = " i386 " DEP_OPTS = " NO_QT = 1 " PACKAGES = " python3 nsis g + + - mingw - w64 - i686 wine1 . 6 bc openjdk - 7 - jre - headless " RUN_TESTS = true GOAL = " install " BITCOIN_CONFIG = " - - enable - reduce - exports " <nl> + # 32 - bit + dash <nl> + - HOST = i686 - pc - linux - gnu PACKAGES = " g + + - multilib bc python3 - zmq openjdk - 7 - jre - headless " DEP_OPTS = " NO_QT = 1 " RUN_TESTS = true GOAL = " install " BITCOIN_CONFIG = " - - enable - zmq - - enable - glibc - back - compat - - enable - reduce - exports LDFLAGS = - static - libstdc + + " USE_SHELL = " / bin / dash " <nl> + # Win64 <nl> + - HOST = x86_64 - w64 - mingw32 DPKG_ADD_ARCH = " i386 " DEP_OPTS = " NO_QT = 1 " PACKAGES = " python3 nsis g + + - mingw - w64 - x86 - 64 wine1 . 6 bc openjdk - 7 - jre - headless " RUN_TESTS = true GOAL = " install " BITCOIN_CONFIG = " - - enable - reduce - exports " <nl> + # bitcoind <nl> + - HOST = x86_64 - unknown - linux - gnu PACKAGES = " bc python3 - zmq openjdk - 7 - jre - headless " DEP_OPTS = " NO_QT = 1 NO_UPNP = 1 DEBUG = 1 " RUN_TESTS = true GOAL = " install " BITCOIN_CONFIG = " - - enable - zmq - - enable - glibc - back - compat - - enable - reduce - exports CPPFLAGS = - DDEBUG_LOCKORDER " <nl> + # No wallet <nl> + - HOST = x86_64 - unknown - linux - gnu PACKAGES = " openjdk - 7 - jre - headless python3 " DEP_OPTS = " NO_WALLET = 1 " RUN_TESTS = true GOAL = " install " BITCOIN_CONFIG = " - - enable - glibc - back - compat - - enable - reduce - exports " <nl> + # Cross - Mac <nl> + - HOST = x86_64 - apple - darwin11 PACKAGES = " cmake imagemagick libcap - dev librsvg2 - bin libz - dev libbz2 - dev libtiff - tools python - dev " BITCOIN_CONFIG = " - - enable - reduce - exports " OSX_SDK = 10 . 9 GOAL = " deploy " <nl> + <nl> before_install : <nl> - export PATH = $ ( echo $ PATH | tr ' : ' " \ n " | sed ' / \ / opt \ / python / d ' | tr " \ n " " : " | sed " s | : : | : | g " ) <nl> install : <nl> - - if [ - n " $ PACKAGES " ] ; then sudo rm - f / etc / apt / sources . list . d / google - chrome . list ; fi <nl> - if [ - n " $ PPA " ] ; then travis_retry sudo add - apt - repository " $ PPA " - y ; fi <nl> - if [ - n " $ DPKG_ADD_ARCH " ] ; then sudo dpkg - - add - architecture " $ DPKG_ADD_ARCH " ; fi <nl> - if [ - n " $ PACKAGES " ] ; then travis_retry sudo apt - get update ; fi <nl> script : <nl> after_script : <nl> - echo $ TRAVIS_COMMIT_RANGE <nl> - echo $ TRAVIS_COMMIT_LOG <nl> - - if [ " $ TRAVIS_PULL_REQUEST " ! = " false " ] ; then ( echo " Upload goes here . Something like : scp - r $ BASE_OUTDIR server " | | echo " upload failed " ) ; fi <nl>
|
Merge : travis : use slim generic image , and some fixups
|
bitcoin/bitcoin
|
3e4cf8fe26440cae179aaca44ccadd476b464994
|
2016-06-10T13:41:00Z
|
mmm a / modules / imgcodecs / CMakeLists . txt <nl> ppp b / modules / imgcodecs / CMakeLists . txt <nl> list ( APPEND grfmt_hdrs $ { CMAKE_CURRENT_LIST_DIR } / src / bitstrm . hpp ) <nl> list ( APPEND grfmt_srcs $ { CMAKE_CURRENT_LIST_DIR } / src / bitstrm . cpp ) <nl> list ( APPEND grfmt_hdrs $ { CMAKE_CURRENT_LIST_DIR } / src / rgbe . hpp ) <nl> list ( APPEND grfmt_srcs $ { CMAKE_CURRENT_LIST_DIR } / src / rgbe . cpp ) <nl> - list ( APPEND grfmt_hdrs $ { CMAKE_CURRENT_LIST_DIR } / src / jpeg_exif . hpp ) <nl> - list ( APPEND grfmt_srcs $ { CMAKE_CURRENT_LIST_DIR } / src / jpeg_exif . cpp ) <nl> + list ( APPEND grfmt_hdrs $ { CMAKE_CURRENT_LIST_DIR } / src / exif . hpp ) <nl> + list ( APPEND grfmt_srcs $ { CMAKE_CURRENT_LIST_DIR } / src / exif . cpp ) <nl> <nl> source_group ( " Src \ \ grfmts " FILES $ { grfmt_hdrs } $ { grfmt_srcs } ) <nl> <nl> mmm a / modules / imgcodecs / include / opencv2 / imgcodecs . hpp <nl> ppp b / modules / imgcodecs / include / opencv2 / imgcodecs . hpp <nl> enum ImreadModes { <nl> IMREAD_REDUCED_GRAYSCALE_4 = 32 , / / ! < If set , always convert image to the single channel grayscale image and the image size reduced 1 / 4 . <nl> IMREAD_REDUCED_COLOR_4 = 33 , / / ! < If set , always convert image to the 3 channel BGR color image and the image size reduced 1 / 4 . <nl> IMREAD_REDUCED_GRAYSCALE_8 = 64 , / / ! < If set , always convert image to the single channel grayscale image and the image size reduced 1 / 8 . <nl> - IMREAD_REDUCED_COLOR_8 = 65 / / ! < If set , always convert image to the 3 channel BGR color image and the image size reduced 1 / 8 . <nl> + IMREAD_REDUCED_COLOR_8 = 65 , / / ! < If set , always convert image to the 3 channel BGR color image and the image size reduced 1 / 8 . <nl> + IMREAD_IGNORE_ORIENTATION = 128 / / ! < If set , do not rotate the image according to EXIF ' s orientation flag . <nl> } ; <nl> <nl> / / ! Imwrite flags <nl> mmm a / modules / imgcodecs / include / opencv2 / imgcodecs / imgcodecs_c . h <nl> ppp b / modules / imgcodecs / include / opencv2 / imgcodecs / imgcodecs_c . h <nl> enum <nl> / * any depth , ? * / <nl> CV_LOAD_IMAGE_ANYDEPTH = 2 , <nl> / * ? , any color * / <nl> - CV_LOAD_IMAGE_ANYCOLOR = 4 <nl> + CV_LOAD_IMAGE_ANYCOLOR = 4 , <nl> + / * ? , no rotate * / <nl> + CV_LOAD_IMAGE_IGNORE_ORIENTATION = 128 <nl> } ; <nl> <nl> / * load image from file <nl> similarity index 99 % <nl> rename from modules / imgcodecs / src / jpeg_exif . cpp <nl> rename to modules / imgcodecs / src / exif . cpp <nl> mmm a / modules / imgcodecs / src / jpeg_exif . cpp <nl> ppp b / modules / imgcodecs / src / exif . cpp <nl> <nl> / / <nl> / / M * / <nl> <nl> - # include " jpeg_exif . hpp " <nl> + # include " exif . hpp " <nl> <nl> namespace { <nl> <nl> ExifReader : : ~ ExifReader ( ) <nl> } <nl> <nl> / * * <nl> - * @ brief Parsing the jpeg file and prepare ( internally ) exif directory structure <nl> + * @ brief Parsing the file and prepare ( internally ) exif directory structure <nl> * @ return true if parsing was successful and exif information exists in JpegReader object <nl> * false in case of unsuccessful parsing <nl> * / <nl> ExifEntry_t ExifReader : : getTag ( const ExifTagName tag ) <nl> <nl> <nl> / * * <nl> - * @ brief Get exif directory structure contained in jpeg file ( if any ) <nl> + * @ brief Get exif directory structure contained in file ( if any ) <nl> * This is internal function and is not exposed to client <nl> * <nl> * @ return Map where key is tag number and value is ExifEntry_t structure <nl> similarity index 90 % <nl> rename from modules / imgcodecs / src / jpeg_exif . hpp <nl> rename to modules / imgcodecs / src / exif . hpp <nl> mmm a / modules / imgcodecs / src / jpeg_exif . hpp <nl> ppp b / modules / imgcodecs / src / exif . hpp <nl> <nl> / / M * / <nl> <nl> <nl> - # ifndef _OPENCV_JPEG_EXIF_HPP_ <nl> - # define _OPENCV_JPEG_EXIF_HPP_ <nl> + # ifndef _OPENCV_EXIF_HPP_ <nl> + # define _OPENCV_EXIF_HPP_ <nl> <nl> # include < cstdio > <nl> # include < map > <nl> struct ExifEntry_t <nl> } ; <nl> <nl> / * * <nl> - * @ brief Picture orientation which may be taken from JPEG ' s EXIF <nl> + * @ brief Picture orientation which may be taken from EXIF <nl> * Orientation usually matters when the picture is taken by <nl> * smartphone or other camera with orientation sensor support <nl> * Corresponds to EXIF 2 . 3 Specification <nl> * / <nl> - enum JpegOrientation <nl> + enum ImageOrientation <nl> { <nl> - JPEG_ORIENTATION_TL = 1 , / / / < 0th row = = visual top , 0th column = = visual left - hand side <nl> - JPEG_ORIENTATION_TR = 2 , / / / < 0th row = = visual top , 0th column = = visual right - hand side <nl> - JPEG_ORIENTATION_BR = 3 , / / / < 0th row = = visual bottom , 0th column = = visual right - hand side <nl> - JPEG_ORIENTATION_BL = 4 , / / / < 0th row = = visual bottom , 0th column = = visual left - hand side <nl> - JPEG_ORIENTATION_LT = 5 , / / / < 0th row = = visual left - hand side , 0th column = = visual top <nl> - JPEG_ORIENTATION_RT = 6 , / / / < 0th row = = visual right - hand side , 0th column = = visual top <nl> - JPEG_ORIENTATION_RB = 7 , / / / < 0th row = = visual right - hand side , 0th column = = visual bottom <nl> - JPEG_ORIENTATION_LB = 8 / / / < 0th row = = visual left - hand side , 0th column = = visual bottom <nl> + IMAGE_ORIENTATION_TL = 1 , / / / < Horizontal ( normal ) <nl> + IMAGE_ORIENTATION_TR = 2 , / / / < Mirrored horizontal <nl> + IMAGE_ORIENTATION_BR = 3 , / / / < Rotate 180 <nl> + IMAGE_ORIENTATION_BL = 4 , / / / < Mirrored vertical <nl> + IMAGE_ORIENTATION_LT = 5 , / / / < Mirrored horizontal & rotate 270 CW <nl> + IMAGE_ORIENTATION_RT = 6 , / / / < Rotate 90 CW <nl> + IMAGE_ORIENTATION_RB = 7 , / / / < Mirrored horizontal & rotate 90 CW <nl> + IMAGE_ORIENTATION_LB = 8 / / / < Rotate 270 CW <nl> } ; <nl> <nl> / * * <nl> class ExifReader <nl> <nl> } <nl> <nl> - # endif / * JPEG_EXIF_HPP_ * / <nl> + # endif / * _OPENCV_EXIF_HPP_ * / <nl> mmm a / modules / imgcodecs / src / grfmt_jpeg . cpp <nl> ppp b / modules / imgcodecs / src / grfmt_jpeg . cpp <nl> <nl> <nl> # include " precomp . hpp " <nl> # include " grfmt_jpeg . hpp " <nl> - # include " jpeg_exif . hpp " <nl> <nl> # ifdef HAVE_JPEG <nl> <nl> JpegDecoder : : JpegDecoder ( ) <nl> m_state = 0 ; <nl> m_f = 0 ; <nl> m_buf_supported = true ; <nl> - m_orientation = JPEG_ORIENTATION_TL ; <nl> } <nl> <nl> <nl> bool JpegDecoder : : readHeader ( ) <nl> } <nl> } <nl> <nl> - m_orientation = getOrientation ( ) ; <nl> - <nl> if ( ! result ) <nl> close ( ) ; <nl> <nl> return result ; <nl> } <nl> <nl> - int JpegDecoder : : getOrientation ( ) <nl> - { <nl> - int orientation = JPEG_ORIENTATION_TL ; <nl> - <nl> - if ( m_filename . size ( ) > 0 ) <nl> - { <nl> - ExifReader reader ( m_filename ) ; <nl> - if ( reader . parse ( ) ) <nl> - { <nl> - ExifEntry_t entry = reader . getTag ( ORIENTATION ) ; <nl> - if ( entry . tag ! = INVALID_TAG ) <nl> - { <nl> - orientation = entry . field_u16 ; / / orientation is unsigned short , so check field_u16 <nl> - } <nl> - } <nl> - } <nl> - <nl> - return orientation ; <nl> - } <nl> - <nl> - void JpegDecoder : : setOrientation ( Mat & img ) <nl> - { <nl> - switch ( m_orientation ) <nl> - { <nl> - case JPEG_ORIENTATION_TL : / / 0th row = = visual top , 0th column = = visual left - hand side <nl> - / / do nothing , the image already has proper orientation <nl> - break ; <nl> - case JPEG_ORIENTATION_TR : / / 0th row = = visual top , 0th column = = visual right - hand side <nl> - flip ( img , img , 1 ) ; / / flip horizontally <nl> - break ; <nl> - case JPEG_ORIENTATION_BR : / / 0th row = = visual bottom , 0th column = = visual right - hand side <nl> - flip ( img , img , - 1 ) ; / / flip both horizontally and vertically <nl> - break ; <nl> - case JPEG_ORIENTATION_BL : / / 0th row = = visual bottom , 0th column = = visual left - hand side <nl> - flip ( img , img , 0 ) ; / / flip vertically <nl> - break ; <nl> - case JPEG_ORIENTATION_LT : / / 0th row = = visual left - hand side , 0th column = = visual top <nl> - transpose ( img , img ) ; <nl> - break ; <nl> - case JPEG_ORIENTATION_RT : / / 0th row = = visual right - hand side , 0th column = = visual top <nl> - transpose ( img , img ) ; <nl> - flip ( img , img , 1 ) ; / / flip horizontally <nl> - break ; <nl> - case JPEG_ORIENTATION_RB : / / 0th row = = visual right - hand side , 0th column = = visual bottom <nl> - transpose ( img , img ) ; <nl> - flip ( img , img , - 1 ) ; / / flip both horizontally and vertically <nl> - break ; <nl> - case JPEG_ORIENTATION_LB : / / 0th row = = visual left - hand side , 0th column = = visual bottom <nl> - transpose ( img , img ) ; <nl> - flip ( img , img , 0 ) ; / / flip vertically <nl> - break ; <nl> - default : <nl> - / / by default the image read has normal ( JPEG_ORIENTATION_TL ) orientation <nl> - break ; <nl> - } <nl> - } <nl> - <nl> / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> * following code is for supporting MJPEG image files <nl> * based on a message of Laurent Pinchart on the video4linux mailing list <nl> bool JpegDecoder : : readData ( Mat & img ) <nl> <nl> result = true ; <nl> jpeg_finish_decompress ( cinfo ) ; <nl> - setOrientation ( img ) ; <nl> } <nl> } <nl> <nl> mmm a / modules / imgcodecs / src / grfmt_jpeg . hpp <nl> ppp b / modules / imgcodecs / src / grfmt_jpeg . hpp <nl> class JpegDecoder : public BaseImageDecoder <nl> <nl> FILE * m_f ; <nl> void * m_state ; <nl> - <nl> - private : <nl> - / / Support for handling exif orientation tag in Jpeg file <nl> - int m_orientation ; <nl> - int getOrientation ( ) ; <nl> - void setOrientation ( Mat & img ) ; <nl> } ; <nl> <nl> <nl> mmm a / modules / imgcodecs / src / loadsave . cpp <nl> ppp b / modules / imgcodecs / src / loadsave . cpp <nl> <nl> <nl> # include " precomp . hpp " <nl> # include " grfmts . hpp " <nl> + # include " utils . hpp " <nl> + # include " exif . hpp " <nl> # undef min <nl> # undef max <nl> # include < iostream > <nl> static ImageEncoder findEncoder ( const String & _ext ) <nl> return ImageEncoder ( ) ; <nl> } <nl> <nl> + <nl> enum { LOAD_CVMAT = 0 , LOAD_IMAGE = 1 , LOAD_MAT = 2 } ; <nl> <nl> + static void ApplyExifOrientation ( const String & filename , Mat & img ) <nl> + { <nl> + int orientation = IMAGE_ORIENTATION_TL ; <nl> + <nl> + if ( filename . size ( ) > 0 ) <nl> + { <nl> + ExifReader reader ( filename ) ; <nl> + if ( reader . parse ( ) ) <nl> + { <nl> + ExifEntry_t entry = reader . getTag ( ORIENTATION ) ; <nl> + if ( entry . tag ! = INVALID_TAG ) <nl> + { <nl> + orientation = entry . field_u16 ; / / orientation is unsigned short , so check field_u16 <nl> + } <nl> + } <nl> + } <nl> + <nl> + switch ( orientation ) <nl> + { <nl> + case IMAGE_ORIENTATION_TL : / / 0th row = = visual top , 0th column = = visual left - hand side <nl> + / / do nothing , the image already has proper orientation <nl> + break ; <nl> + case IMAGE_ORIENTATION_TR : / / 0th row = = visual top , 0th column = = visual right - hand side <nl> + flip ( img , img , 1 ) ; / / flip horizontally <nl> + break ; <nl> + case IMAGE_ORIENTATION_BR : / / 0th row = = visual bottom , 0th column = = visual right - hand side <nl> + flip ( img , img , - 1 ) ; / / flip both horizontally and vertically <nl> + break ; <nl> + case IMAGE_ORIENTATION_BL : / / 0th row = = visual bottom , 0th column = = visual left - hand side <nl> + flip ( img , img , 0 ) ; / / flip vertically <nl> + break ; <nl> + case IMAGE_ORIENTATION_LT : / / 0th row = = visual left - hand side , 0th column = = visual top <nl> + transpose ( img , img ) ; <nl> + break ; <nl> + case IMAGE_ORIENTATION_RT : / / 0th row = = visual right - hand side , 0th column = = visual top <nl> + transpose ( img , img ) ; <nl> + flip ( img , img , 1 ) ; / / flip horizontally <nl> + break ; <nl> + case IMAGE_ORIENTATION_RB : / / 0th row = = visual right - hand side , 0th column = = visual bottom <nl> + transpose ( img , img ) ; <nl> + flip ( img , img , - 1 ) ; / / flip both horizontally and vertically <nl> + break ; <nl> + case IMAGE_ORIENTATION_LB : / / 0th row = = visual left - hand side , 0th column = = visual bottom <nl> + transpose ( img , img ) ; <nl> + flip ( img , img , 0 ) ; / / flip vertically <nl> + break ; <nl> + default : <nl> + / / by default the image read has normal ( JPEG_ORIENTATION_TL ) orientation <nl> + break ; <nl> + } <nl> + } <nl> + <nl> / * * <nl> * Read an image into memory and return the information <nl> * <nl> imreadmulti_ ( const String & filename , int flags , std : : vector < Mat > & mats ) <nl> Mat mat ( decoder - > height ( ) , decoder - > width ( ) , type ) ; <nl> if ( ! decoder - > readData ( mat ) ) <nl> { <nl> + / / optionally rotate the data if EXIF ' orientation flag says so <nl> + if ( ( flags & IMREAD_IGNORE_ORIENTATION ) = = 0 & & flags ! = IMREAD_UNCHANGED ) <nl> + { <nl> + ApplyExifOrientation ( filename , mat ) ; <nl> + } <nl> + <nl> break ; <nl> } <nl> <nl> Mat imread ( const String & filename , int flags ) <nl> / / / load the data <nl> imread_ ( filename , flags , LOAD_MAT , & img ) ; <nl> <nl> + / / / optionally rotate the data if EXIF ' orientation flag says so <nl> + if ( ( flags & IMREAD_IGNORE_ORIENTATION ) = = 0 & & flags ! = IMREAD_UNCHANGED ) <nl> + { <nl> + ApplyExifOrientation ( filename , img ) ; <nl> + } <nl> + <nl> / / / return a reference to the data <nl> return img ; <nl> } <nl>
|
Merge pull request from ArkadiuszRaj : move - exif - from - jpeg - to - loadsave
|
opencv/opencv
|
099be88f02ad0981043a377588cf116931dea3df
|
2016-11-14T13:37:42Z
|
mmm a / doc / files . md <nl> ppp b / doc / files . md <nl> Subdirectory | File ( s ) | Description <nl> ` indexes / blockfilter / basic / ` | ` fltrNNNNN . dat ` < sup > [ \ [ 2 \ ] ] ( # note2 ) < / sup > | Blockfilter index filters for the basic filtertype ; * optional * , used if ` - blockfilterindex = basic ` <nl> ` wallets / ` | | [ Contains wallets ] ( # multi - wallet - environment ) ; can be specified by ` - walletdir ` option ; if ` wallets / ` subdirectory does not exist , a wallet resides in the data directory <nl> ` . / ` | ` banlist . dat ` | Stores the IPs / subnets of banned nodes <nl> - ` . / ` | ` bitcoin . conf ` | Contains [ configuration settings ] ( bitcoin - conf . md ) for ` bitcoind ` or ` bitcoin - qt ` ; can be specified by ` - conf ` option <nl> + ` . / ` | ` bitcoin . conf ` | User - defined [ configuration settings ] ( bitcoin - conf . md ) for ` bitcoind ` or ` bitcoin - qt ` . File is not written to by the software and must be created manually . Path can be specified by ` - conf ` option <nl> ` . / ` | ` bitcoind . pid ` | Stores the process ID ( PID ) of ` bitcoind ` or ` bitcoin - qt ` while running ; created at start and deleted on shutdown ; can be specified by ` - pid ` option <nl> ` . / ` | ` debug . log ` | Contains debug information and general logging generated by ` bitcoind ` or ` bitcoin - qt ` ; can be specified by ` - debuglogfile ` option <nl> ` . / ` | ` fee_estimates . dat ` | Stores statistics used to estimate minimum transaction fees and priorities required for confirmation <nl> Subdirectory | File ( s ) | Description <nl> ` . / ` | ` mempool . dat ` | Dump of the mempool ' s transactions <nl> ` . / ` | ` onion_private_key ` | Cached Tor hidden service private key for ` - listenonion ` option <nl> ` . / ` | ` peers . dat ` | Peer IP address database ( custom format ) <nl> + ` . / ` | ` settings . json ` | Read - write settings set through GUI or RPC interfaces , augmenting manual settings from [ bitcoin . conf ] ( bitcoin - conf . md ) . File is created automatically if read - write settings storage is not disabled with ` - nosettings ` option . Path can be specified with ` - settings ` option <nl> ` . / ` | ` . cookie ` | Session RPC authentication cookie ; if used , created at start and deleted on shutdown ; can be specified by ` - rpccookiefile ` option <nl> ` . / ` | ` . lock ` | Data directory lock file <nl> <nl> mmm a / src / bitcoind . cpp <nl> ppp b / src / bitcoind . cpp <nl> static bool AppInit ( int argc , char * argv [ ] ) <nl> } <nl> } <nl> <nl> + if ( ! gArgs . InitSettings ( error ) ) { <nl> + InitError ( Untranslated ( error ) ) ; <nl> + return false ; <nl> + } <nl> + <nl> / / - server defaults to true for bitcoind but not for the GUI so do this here <nl> gArgs . SoftSetBoolArg ( " - server " , true ) ; <nl> / / Set this early so that parameter interactions go to console <nl> mmm a / src / init . cpp <nl> ppp b / src / init . cpp <nl> void SetupServerArgs ( NodeContext & node ) <nl> # endif <nl> gArgs . AddArg ( " - blockreconstructionextratxn = < n > " , strprintf ( " Extra transactions to keep in memory for compact block reconstructions ( default : % u ) " , DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN ) , ArgsManager : : ALLOW_ANY , OptionsCategory : : OPTIONS ) ; <nl> gArgs . AddArg ( " - blocksonly " , strprintf ( " Whether to reject transactions from network peers . Automatic broadcast and rebroadcast of any transactions from inbound peers is disabled , unless the peer has the ' forcerelay ' permission . RPC transactions are not affected . ( default : % u ) " , DEFAULT_BLOCKSONLY ) , ArgsManager : : ALLOW_ANY , OptionsCategory : : OPTIONS ) ; <nl> - gArgs . AddArg ( " - conf = < file > " , strprintf ( " Specify configuration file . Relative paths will be prefixed by datadir location . ( default : % s ) " , BITCOIN_CONF_FILENAME ) , ArgsManager : : ALLOW_ANY , OptionsCategory : : OPTIONS ) ; <nl> + gArgs . AddArg ( " - conf = < file > " , strprintf ( " Specify path to read - only configuration file . Relative paths will be prefixed by datadir location . ( default : % s ) " , BITCOIN_CONF_FILENAME ) , ArgsManager : : ALLOW_ANY , OptionsCategory : : OPTIONS ) ; <nl> gArgs . AddArg ( " - datadir = < dir > " , " Specify data directory " , ArgsManager : : ALLOW_ANY , OptionsCategory : : OPTIONS ) ; <nl> gArgs . AddArg ( " - dbbatchsize " , strprintf ( " Maximum database write batch size in bytes ( default : % u ) " , nDefaultDbBatchSize ) , ArgsManager : : ALLOW_ANY | ArgsManager : : DEBUG_ONLY , OptionsCategory : : OPTIONS ) ; <nl> gArgs . AddArg ( " - dbcache = < n > " , strprintf ( " Maximum database cache size < n > MiB ( % d to % d , default : % d ) . In addition , unused mempool memory is shared for this cache ( see - maxmempool ) . " , nMinDbCache , nMaxDbCache , nDefaultDbCache ) , ArgsManager : : ALLOW_ANY , OptionsCategory : : OPTIONS ) ; <nl> void SetupServerArgs ( NodeContext & node ) <nl> " ( default : 0 = disable pruning blocks , 1 = allow manual pruning via RPC , > = % u = automatically prune block files to stay under the specified target size in MiB ) " , MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024 ) , ArgsManager : : ALLOW_ANY , OptionsCategory : : OPTIONS ) ; <nl> gArgs . AddArg ( " - reindex " , " Rebuild chain state and block index from the blk * . dat files on disk " , ArgsManager : : ALLOW_ANY , OptionsCategory : : OPTIONS ) ; <nl> gArgs . AddArg ( " - reindex - chainstate " , " Rebuild chain state from the currently indexed blocks . When in pruning mode or if blocks on disk might be corrupted , use full - reindex instead . " , ArgsManager : : ALLOW_ANY , OptionsCategory : : OPTIONS ) ; <nl> + gArgs . AddArg ( " - settings = < file > " , strprintf ( " Specify path to dynamic settings data file . Can be disabled with - nosettings . File is written at runtime and not meant to be edited by users ( use % s instead for custom settings ) . Relative paths will be prefixed by datadir location . ( default : % s ) " , BITCOIN_CONF_FILENAME , BITCOIN_SETTINGS_FILENAME ) , ArgsManager : : ALLOW_ANY , OptionsCategory : : OPTIONS ) ; <nl> # ifndef WIN32 <nl> gArgs . AddArg ( " - sysperms " , " Create new files with system default permissions , instead of umask 077 ( only effective with disabled wallet functionality ) " , ArgsManager : : ALLOW_ANY , OptionsCategory : : OPTIONS ) ; <nl> # else <nl> mmm a / src / interfaces / node . cpp <nl> ppp b / src / interfaces / node . cpp <nl> class NodeImpl : public Node <nl> bool softSetArg ( const std : : string & arg , const std : : string & value ) override { return gArgs . SoftSetArg ( arg , value ) ; } <nl> bool softSetBoolArg ( const std : : string & arg , bool value ) override { return gArgs . SoftSetBoolArg ( arg , value ) ; } <nl> void selectParams ( const std : : string & network ) override { SelectParams ( network ) ; } <nl> + bool initSettings ( std : : string & error ) override { return gArgs . InitSettings ( error ) ; } <nl> uint64_t getAssumedBlockchainSize ( ) override { return Params ( ) . AssumedBlockchainSize ( ) ; } <nl> uint64_t getAssumedChainStateSize ( ) override { return Params ( ) . AssumedChainStateSize ( ) ; } <nl> std : : string getNetwork ( ) override { return Params ( ) . NetworkIDString ( ) ; } <nl> mmm a / src / interfaces / node . h <nl> ppp b / src / interfaces / node . h <nl> class Node <nl> / / ! Choose network parameters . <nl> virtual void selectParams ( const std : : string & network ) = 0 ; <nl> <nl> + / / ! Read and update < datadir > / settings . json file with saved settings . This <nl> + / / ! needs to be called after selectParams ( ) because the settings file <nl> + / / ! location is network - specific . <nl> + virtual bool initSettings ( std : : string & error ) = 0 ; <nl> + <nl> / / ! Get the ( assumed ) blockchain size . <nl> virtual uint64_t getAssumedBlockchainSize ( ) = 0 ; <nl> <nl> mmm a / src / qt / bitcoin . cpp <nl> ppp b / src / qt / bitcoin . cpp <nl> int GuiMain ( int argc , char * argv [ ] ) <nl> / / Parse URIs on command line - - this can affect Params ( ) <nl> PaymentServer : : ipcParseCommandLine ( * node , argc , argv ) ; <nl> # endif <nl> + if ( ! node - > initSettings ( error ) ) { <nl> + node - > initError ( Untranslated ( error ) ) ; <nl> + QMessageBox : : critical ( nullptr , PACKAGE_NAME , QObject : : tr ( " Error initializing settings : % 1 " ) . arg ( QString : : fromStdString ( error ) ) ) ; <nl> + return EXIT_FAILURE ; <nl> + } <nl> <nl> QScopedPointer < const NetworkStyle > networkStyle ( NetworkStyle : : instantiate ( Params ( ) . NetworkIDString ( ) ) ) ; <nl> assert ( ! networkStyle . isNull ( ) ) ; <nl> mmm a / src / test / settings_tests . cpp <nl> ppp b / src / test / settings_tests . cpp <nl> <nl> # include < univalue . h > <nl> # include < util / strencodings . h > <nl> # include < util / string . h > <nl> + # include < util / system . h > <nl> # include < vector > <nl> <nl> + inline bool operator = = ( const util : : SettingsValue & a , const util : : SettingsValue & b ) <nl> + { <nl> + return a . write ( ) = = b . write ( ) ; <nl> + } <nl> + <nl> + inline std : : ostream & operator < < ( std : : ostream & os , const util : : SettingsValue & value ) <nl> + { <nl> + os < < value . write ( ) ; <nl> + return os ; <nl> + } <nl> + <nl> + inline std : : ostream & operator < < ( std : : ostream & os , const std : : pair < std : : string , util : : SettingsValue > & kv ) <nl> + { <nl> + util : : SettingsValue out ( util : : SettingsValue : : VOBJ ) ; <nl> + out . __pushKV ( kv . first , kv . second ) ; <nl> + os < < out . write ( ) ; <nl> + return os ; <nl> + } <nl> + <nl> + inline void WriteText ( const fs : : path & path , const std : : string & text ) <nl> + { <nl> + fsbridge : : ofstream file ; <nl> + file . open ( path ) ; <nl> + file < < text ; <nl> + } <nl> + <nl> BOOST_FIXTURE_TEST_SUITE ( settings_tests , BasicTestingSetup ) <nl> <nl> + BOOST_AUTO_TEST_CASE ( ReadWrite ) <nl> + { <nl> + fs : : path path = GetDataDir ( ) / " settings . json " ; <nl> + <nl> + WriteText ( path , R " ( { <nl> + " string " : " string " , <nl> + " num " : 5 , <nl> + " bool " : true , <nl> + " null " : null <nl> + } ) " ) ; <nl> + <nl> + std : : map < std : : string , util : : SettingsValue > expected { <nl> + { " string " , " string " } , <nl> + { " num " , 5 } , <nl> + { " bool " , true } , <nl> + { " null " , { } } , <nl> + } ; <nl> + <nl> + / / Check file read . <nl> + std : : map < std : : string , util : : SettingsValue > values ; <nl> + std : : vector < std : : string > errors ; <nl> + BOOST_CHECK ( util : : ReadSettings ( path , values , errors ) ) ; <nl> + BOOST_CHECK_EQUAL_COLLECTIONS ( values . begin ( ) , values . end ( ) , expected . begin ( ) , expected . end ( ) ) ; <nl> + BOOST_CHECK ( errors . empty ( ) ) ; <nl> + <nl> + / / Check no errors if file doesn ' t exist . <nl> + fs : : remove ( path ) ; <nl> + BOOST_CHECK ( util : : ReadSettings ( path , values , errors ) ) ; <nl> + BOOST_CHECK ( values . empty ( ) ) ; <nl> + BOOST_CHECK ( errors . empty ( ) ) ; <nl> + <nl> + / / Check duplicate keys not allowed <nl> + WriteText ( path , R " ( { <nl> + " dupe " : " string " , <nl> + " dupe " : " dupe " <nl> + } ) " ) ; <nl> + BOOST_CHECK ( ! util : : ReadSettings ( path , values , errors ) ) ; <nl> + std : : vector < std : : string > dup_keys = { strprintf ( " Found duplicate key dupe in settings file % s " , path . string ( ) ) } ; <nl> + BOOST_CHECK_EQUAL_COLLECTIONS ( errors . begin ( ) , errors . end ( ) , dup_keys . begin ( ) , dup_keys . end ( ) ) ; <nl> + <nl> + / / Check non - kv json files not allowed <nl> + WriteText ( path , R " ( " non - kv " ) " ) ; <nl> + BOOST_CHECK ( ! util : : ReadSettings ( path , values , errors ) ) ; <nl> + std : : vector < std : : string > non_kv = { strprintf ( " Found non - object value \ " non - kv \ " in settings file % s " , path . string ( ) ) } ; <nl> + BOOST_CHECK_EQUAL_COLLECTIONS ( errors . begin ( ) , errors . end ( ) , non_kv . begin ( ) , non_kv . end ( ) ) ; <nl> + <nl> + / / Check invalid json not allowed <nl> + WriteText ( path , R " ( invalid json ) " ) ; <nl> + BOOST_CHECK ( ! util : : ReadSettings ( path , values , errors ) ) ; <nl> + std : : vector < std : : string > fail_parse = { strprintf ( " Unable to parse settings file % s " , path . string ( ) ) } ; <nl> + BOOST_CHECK_EQUAL_COLLECTIONS ( errors . begin ( ) , errors . end ( ) , fail_parse . begin ( ) , fail_parse . end ( ) ) ; <nl> + } <nl> + <nl> / / ! Check settings struct contents against expected json strings . <nl> static void CheckValues ( const util : : Settings & settings , const std : : string & single_val , const std : : string & list_val ) <nl> { <nl> mmm a / src / test / util_tests . cpp <nl> ppp b / src / test / util_tests . cpp <nl> <nl> # include < key . h > / / For CKey <nl> # include < optional . h > <nl> # include < sync . h > <nl> + # include < test / util / logging . h > <nl> # include < test / util / setup_common . h > <nl> # include < test / util / str . h > <nl> # include < uint256 . h > <nl> BOOST_FIXTURE_TEST_CASE ( util_ChainMerge , ChainMergeTestingSetup ) <nl> BOOST_CHECK_EQUAL ( out_sha_hex , " f0b3a3c29869edc765d579c928f7f1690a71fbb673b49ccf39cbc4de18156a0d " ) ; <nl> } <nl> <nl> + BOOST_AUTO_TEST_CASE ( util_ReadWriteSettings ) <nl> + { <nl> + / / Test writing setting . <nl> + TestArgsManager args1 ; <nl> + args1 . LockSettings ( [ & ] ( util : : Settings & settings ) { settings . rw_settings [ " name " ] = " value " ; } ) ; <nl> + args1 . WriteSettingsFile ( ) ; <nl> + <nl> + / / Test reading setting . <nl> + TestArgsManager args2 ; <nl> + args2 . ReadSettingsFile ( ) ; <nl> + args2 . LockSettings ( [ & ] ( util : : Settings & settings ) { BOOST_CHECK_EQUAL ( settings . rw_settings [ " name " ] . get_str ( ) , " value " ) ; } ) ; <nl> + <nl> + / / Test error logging , and remove previously written setting . <nl> + { <nl> + ASSERT_DEBUG_LOG ( " Failed renaming settings file " ) ; <nl> + fs : : remove ( GetDataDir ( ) / " settings . json " ) ; <nl> + fs : : create_directory ( GetDataDir ( ) / " settings . json " ) ; <nl> + args2 . WriteSettingsFile ( ) ; <nl> + fs : : remove ( GetDataDir ( ) / " settings . json " ) ; <nl> + } <nl> + } <nl> + <nl> BOOST_AUTO_TEST_CASE ( util_FormatMoney ) <nl> { <nl> BOOST_CHECK_EQUAL ( FormatMoney ( 0 ) , " 0 . 00 " ) ; <nl> mmm a / src / util / settings . cpp <nl> ppp b / src / util / settings . cpp <nl> <nl> <nl> # include < util / settings . h > <nl> <nl> + # include < tinyformat . h > <nl> # include < univalue . h > <nl> <nl> namespace util { <nl> namespace { <nl> enum class Source { <nl> FORCED , <nl> COMMAND_LINE , <nl> + RW_SETTINGS , <nl> CONFIG_FILE_NETWORK_SECTION , <nl> CONFIG_FILE_DEFAULT_SECTION <nl> } ; <nl> <nl> / / ! Merge settings from multiple sources in precedence order : <nl> - / / ! Forced config > command line > config file network - specific section > config file default section <nl> + / / ! Forced config > command line > read - write settings file > config file network - specific section > config file default section <nl> / / ! <nl> / / ! This function is provided with a callback function fn that contains <nl> / / ! specific logic for how to merge the sources . <nl> static void MergeSettings ( const Settings & settings , const std : : string & section , <nl> if ( auto * values = FindKey ( settings . command_line_options , name ) ) { <nl> fn ( SettingsSpan ( * values ) , Source : : COMMAND_LINE ) ; <nl> } <nl> + / / Merge in the read - write settings <nl> + if ( const SettingsValue * value = FindKey ( settings . rw_settings , name ) ) { <nl> + fn ( SettingsSpan ( * value ) , Source : : RW_SETTINGS ) ; <nl> + } <nl> / / Merge in the network - specific section of the config file <nl> if ( ! section . empty ( ) ) { <nl> if ( auto * map = FindKey ( settings . ro_config , section ) ) { <nl> static void MergeSettings ( const Settings & settings , const std : : string & section , <nl> } <nl> } / / namespace <nl> <nl> + bool ReadSettings ( const fs : : path & path , std : : map < std : : string , SettingsValue > & values , std : : vector < std : : string > & errors ) <nl> + { <nl> + values . clear ( ) ; <nl> + errors . clear ( ) ; <nl> + <nl> + fsbridge : : ifstream file ; <nl> + file . open ( path ) ; <nl> + if ( ! file . is_open ( ) ) return true ; / / Ok for file not to exist . <nl> + <nl> + SettingsValue in ; <nl> + if ( ! in . read ( std : : string { std : : istreambuf_iterator < char > ( file ) , std : : istreambuf_iterator < char > ( ) } ) ) { <nl> + errors . emplace_back ( strprintf ( " Unable to parse settings file % s " , path . string ( ) ) ) ; <nl> + return false ; <nl> + } <nl> + <nl> + if ( file . fail ( ) ) { <nl> + errors . emplace_back ( strprintf ( " Failed reading settings file % s " , path . string ( ) ) ) ; <nl> + return false ; <nl> + } <nl> + file . close ( ) ; / / Done with file descriptor . Release while copying data . <nl> + <nl> + if ( ! in . isObject ( ) ) { <nl> + errors . emplace_back ( strprintf ( " Found non - object value % s in settings file % s " , in . write ( ) , path . string ( ) ) ) ; <nl> + return false ; <nl> + } <nl> + <nl> + const std : : vector < std : : string > & in_keys = in . getKeys ( ) ; <nl> + const std : : vector < SettingsValue > & in_values = in . getValues ( ) ; <nl> + for ( size_t i = 0 ; i < in_keys . size ( ) ; + + i ) { <nl> + auto inserted = values . emplace ( in_keys [ i ] , in_values [ i ] ) ; <nl> + if ( ! inserted . second ) { <nl> + errors . emplace_back ( strprintf ( " Found duplicate key % s in settings file % s " , in_keys [ i ] , path . string ( ) ) ) ; <nl> + } <nl> + } <nl> + return errors . empty ( ) ; <nl> + } <nl> + <nl> + bool WriteSettings ( const fs : : path & path , <nl> + const std : : map < std : : string , SettingsValue > & values , <nl> + std : : vector < std : : string > & errors ) <nl> + { <nl> + SettingsValue out ( SettingsValue : : VOBJ ) ; <nl> + for ( const auto & value : values ) { <nl> + out . __pushKV ( value . first , value . second ) ; <nl> + } <nl> + fsbridge : : ofstream file ; <nl> + file . open ( path ) ; <nl> + if ( file . fail ( ) ) { <nl> + errors . emplace_back ( strprintf ( " Error : Unable to open settings file % s for writing " , path . string ( ) ) ) ; <nl> + return false ; <nl> + } <nl> + file < < out . write ( / * prettyIndent = * / 1 , / * indentLevel = * / 4 ) < < std : : endl ; <nl> + file . close ( ) ; <nl> + return true ; <nl> + } <nl> + <nl> SettingsValue GetSetting ( const Settings & settings , <nl> const std : : string & section , <nl> const std : : string & name , <nl> mmm a / src / util / settings . h <nl> ppp b / src / util / settings . h <nl> <nl> # ifndef BITCOIN_UTIL_SETTINGS_H <nl> # define BITCOIN_UTIL_SETTINGS_H <nl> <nl> + # include < fs . h > <nl> + <nl> # include < map > <nl> # include < string > <nl> # include < vector > <nl> namespace util { <nl> / / ! https : / / github . com / bitcoin / bitcoin / pull / 15934 / files # r337691812 ) <nl> using SettingsValue = UniValue ; <nl> <nl> - / / ! Stored bitcoin settings . This struct combines settings from the command line <nl> - / / ! and a read - only configuration file . <nl> + / / ! Stored settings . This struct combines settings from the command line , a <nl> + / / ! read - only configuration file , and a read - write runtime settings file . <nl> struct Settings { <nl> / / ! Map of setting name to forced setting value . <nl> std : : map < std : : string , SettingsValue > forced_settings ; <nl> / / ! Map of setting name to list of command line values . <nl> std : : map < std : : string , std : : vector < SettingsValue > > command_line_options ; <nl> + / / ! Map of setting name to read - write file setting value . <nl> + std : : map < std : : string , SettingsValue > rw_settings ; <nl> / / ! Map of config section name and setting name to list of config file values . <nl> std : : map < std : : string , std : : map < std : : string , std : : vector < SettingsValue > > > ro_config ; <nl> } ; <nl> <nl> + / / ! Read settings file . <nl> + bool ReadSettings ( const fs : : path & path , <nl> + std : : map < std : : string , SettingsValue > & values , <nl> + std : : vector < std : : string > & errors ) ; <nl> + <nl> + / / ! Write settings file . <nl> + bool WriteSettings ( const fs : : path & path , <nl> + const std : : map < std : : string , SettingsValue > & values , <nl> + std : : vector < std : : string > & errors ) ; <nl> + <nl> / / ! Get settings value from combined sources : forced settings , command line <nl> - / / ! arguments and the read - only config file . <nl> + / / ! arguments , runtime read - write settings , and the read - only config file . <nl> / / ! <nl> / / ! @ param ignore_default_section_config - ignore values in the default section <nl> / / ! of the config file ( part before any <nl> mmm a / src / util / system . cpp <nl> ppp b / src / util / system . cpp <nl> <nl> const int64_t nStartupTime = GetTime ( ) ; <nl> <nl> const char * const BITCOIN_CONF_FILENAME = " bitcoin . conf " ; <nl> + const char * const BITCOIN_SETTINGS_FILENAME = " settings . json " ; <nl> <nl> ArgsManager gArgs ; <nl> <nl> bool ArgsManager : : IsArgSet ( const std : : string & strArg ) const <nl> return ! GetSetting ( strArg ) . isNull ( ) ; <nl> } <nl> <nl> + bool ArgsManager : : InitSettings ( std : : string & error ) <nl> + { <nl> + if ( ! GetSettingsPath ( ) ) { <nl> + return true ; / / Do nothing if settings file disabled . <nl> + } <nl> + <nl> + std : : vector < std : : string > errors ; <nl> + if ( ! ReadSettingsFile ( & errors ) ) { <nl> + error = strprintf ( " Failed loading settings file : \ n - % s \ n " , Join ( errors , " \ n - " ) ) ; <nl> + return false ; <nl> + } <nl> + if ( ! WriteSettingsFile ( & errors ) ) { <nl> + error = strprintf ( " Failed saving settings file : \ n - % s \ n " , Join ( errors , " \ n - " ) ) ; <nl> + return false ; <nl> + } <nl> + return true ; <nl> + } <nl> + <nl> + bool ArgsManager : : GetSettingsPath ( fs : : path * filepath , bool temp ) const <nl> + { <nl> + if ( IsArgNegated ( " - settings " ) ) { <nl> + return false ; <nl> + } <nl> + if ( filepath ) { <nl> + std : : string settings = GetArg ( " - settings " , BITCOIN_SETTINGS_FILENAME ) ; <nl> + * filepath = fs : : absolute ( temp ? settings + " . tmp " : settings , GetDataDir ( / * net_specific = * / true ) ) ; <nl> + } <nl> + return true ; <nl> + } <nl> + <nl> + static void SaveErrors ( const std : : vector < std : : string > errors , std : : vector < std : : string > * error_out ) <nl> + { <nl> + for ( const auto & error : errors ) { <nl> + if ( error_out ) { <nl> + error_out - > emplace_back ( error ) ; <nl> + } else { <nl> + LogPrintf ( " % s \ n " , error ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + bool ArgsManager : : ReadSettingsFile ( std : : vector < std : : string > * errors ) <nl> + { <nl> + fs : : path path ; <nl> + if ( ! GetSettingsPath ( & path , / * temp = * / false ) ) { <nl> + return true ; / / Do nothing if settings file disabled . <nl> + } <nl> + <nl> + LOCK ( cs_args ) ; <nl> + m_settings . rw_settings . clear ( ) ; <nl> + std : : vector < std : : string > read_errors ; <nl> + if ( ! util : : ReadSettings ( path , m_settings . rw_settings , read_errors ) ) { <nl> + SaveErrors ( read_errors , errors ) ; <nl> + return false ; <nl> + } <nl> + return true ; <nl> + } <nl> + <nl> + bool ArgsManager : : WriteSettingsFile ( std : : vector < std : : string > * errors ) const <nl> + { <nl> + fs : : path path , path_tmp ; <nl> + if ( ! GetSettingsPath ( & path , / * temp = * / false ) | | ! GetSettingsPath ( & path_tmp , / * temp = * / true ) ) { <nl> + throw std : : logic_error ( " Attempt to write settings file when dynamic settings are disabled . " ) ; <nl> + } <nl> + <nl> + LOCK ( cs_args ) ; <nl> + std : : vector < std : : string > write_errors ; <nl> + if ( ! util : : WriteSettings ( path_tmp , m_settings . rw_settings , write_errors ) ) { <nl> + SaveErrors ( write_errors , errors ) ; <nl> + return false ; <nl> + } <nl> + if ( ! RenameOver ( path_tmp , path ) ) { <nl> + SaveErrors ( { strprintf ( " Failed renaming settings file % s to % s \ n " , path_tmp . string ( ) , path . string ( ) ) } , errors ) ; <nl> + return false ; <nl> + } <nl> + return true ; <nl> + } <nl> + <nl> bool ArgsManager : : IsArgNegated ( const std : : string & strArg ) const <nl> { <nl> return GetSetting ( strArg ) . isFalse ( ) ; <nl> void ArgsManager : : LogArgs ( ) const <nl> for ( const auto & section : m_settings . ro_config ) { <nl> logArgsPrefix ( " Config file arg : " , section . first , section . second ) ; <nl> } <nl> + for ( const auto & setting : m_settings . rw_settings ) { <nl> + LogPrintf ( " Setting file arg : % s = % s \ n " , setting . first , setting . second . write ( ) ) ; <nl> + } <nl> logArgsPrefix ( " Command - line arg : " , " " , m_settings . command_line_options ) ; <nl> } <nl> <nl> mmm a / src / util / system . h <nl> ppp b / src / util / system . h <nl> <nl> int64_t GetStartupTime ( ) ; <nl> <nl> extern const char * const BITCOIN_CONF_FILENAME ; <nl> + extern const char * const BITCOIN_SETTINGS_FILENAME ; <nl> <nl> void SetupEnvironment ( ) ; <nl> bool SetupNetworking ( ) ; <nl> class ArgsManager <nl> * / <nl> Optional < unsigned int > GetArgFlags ( const std : : string & name ) const ; <nl> <nl> + / * * <nl> + * Read and update settings file with saved settings . This needs to be <nl> + * called after SelectParams ( ) because the settings file location is <nl> + * network - specific . <nl> + * / <nl> + bool InitSettings ( std : : string & error ) ; <nl> + <nl> + / * * <nl> + * Get settings file path , or return false if read - write settings were <nl> + * disabled with - nosettings . <nl> + * / <nl> + bool GetSettingsPath ( fs : : path * filepath = nullptr , bool temp = false ) const ; <nl> + <nl> + / * * <nl> + * Read settings file . Push errors to vector , or log them if null . <nl> + * / <nl> + bool ReadSettingsFile ( std : : vector < std : : string > * errors = nullptr ) ; <nl> + <nl> + / * * <nl> + * Write settings file . Push errors to vector , or log them if null . <nl> + * / <nl> + bool WriteSettingsFile ( std : : vector < std : : string > * errors = nullptr ) const ; <nl> + <nl> + / * * <nl> + * Access settings with lock held . <nl> + * / <nl> + template < typename Fn > <nl> + void LockSettings ( Fn & & fn ) <nl> + { <nl> + LOCK ( cs_args ) ; <nl> + fn ( m_settings ) ; <nl> + } <nl> + <nl> / * * <nl> * Log the config file options and the command line arguments , <nl> * useful for troubleshooting . <nl> new file mode 100755 <nl> index 000000000000 . . c565854bb0be <nl> mmm / dev / null <nl> ppp b / test / functional / feature_settings . py <nl> <nl> + # ! / usr / bin / env python3 <nl> + # Copyright ( c ) 2017 - 2020 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 various command line arguments and configuration file parameters . " " " <nl> + <nl> + import json <nl> + <nl> + from pathlib import Path <nl> + <nl> + from test_framework . test_framework import BitcoinTestFramework <nl> + from test_framework . test_node import ErrorMatch <nl> + from test_framework . util import assert_equal <nl> + <nl> + <nl> + class SettingsTest ( BitcoinTestFramework ) : <nl> + def set_test_params ( self ) : <nl> + self . setup_clean_chain = True <nl> + self . num_nodes = 1 <nl> + <nl> + def run_test ( self ) : <nl> + node , = self . nodes <nl> + settings = Path ( node . datadir , self . chain , " settings . json " ) <nl> + conf = Path ( node . datadir , " bitcoin . conf " ) <nl> + <nl> + # Assert empty settings file was created <nl> + self . stop_node ( 0 ) <nl> + with settings . open ( ) as fp : <nl> + assert_equal ( json . load ( fp ) , { } ) <nl> + <nl> + # Assert settings are parsed and logged <nl> + with settings . open ( " w " ) as fp : <nl> + json . dump ( { " string " : " string " , " num " : 5 , " bool " : True , " null " : None , " list " : [ 6 , 7 ] } , fp ) <nl> + with node . assert_debug_log ( expected_msgs = [ <nl> + ' Setting file arg : string = " string " ' , <nl> + ' Setting file arg : num = 5 ' , <nl> + ' Setting file arg : bool = true ' , <nl> + ' Setting file arg : null = null ' , <nl> + ' Setting file arg : list = [ 6 , 7 ] ' ] ) : <nl> + self . start_node ( 0 ) <nl> + self . stop_node ( 0 ) <nl> + <nl> + # Assert settings are unchanged after shutdown <nl> + with settings . open ( ) as fp : <nl> + assert_equal ( json . load ( fp ) , { " string " : " string " , " num " : 5 , " bool " : True , " null " : None , " list " : [ 6 , 7 ] } ) <nl> + <nl> + # Test invalid json <nl> + with settings . open ( " w " ) as fp : <nl> + fp . write ( " invalid json " ) <nl> + node . assert_start_raises_init_error ( expected_msg = ' Unable to parse settings file ' , match = ErrorMatch . PARTIAL_REGEX ) <nl> + <nl> + # Test invalid json object <nl> + with settings . open ( " w " ) as fp : <nl> + fp . write ( ' " string " ' ) <nl> + node . assert_start_raises_init_error ( expected_msg = ' Found non - object value " string " in settings file ' , match = ErrorMatch . PARTIAL_REGEX ) <nl> + <nl> + # Test invalid settings file containing duplicate keys <nl> + with settings . open ( " w " ) as fp : <nl> + fp . write ( ' { " key " : 1 , " key " : 2 } ' ) <nl> + node . assert_start_raises_init_error ( expected_msg = ' Found duplicate key key in settings file ' , match = ErrorMatch . PARTIAL_REGEX ) <nl> + <nl> + # Test invalid settings file is ignored with command line - nosettings <nl> + with node . assert_debug_log ( expected_msgs = [ ' Command - line arg : settings = false ' ] ) : <nl> + self . start_node ( 0 , extra_args = [ " - nosettings " ] ) <nl> + self . stop_node ( 0 ) <nl> + <nl> + # Test invalid settings file is ignored with config file - nosettings <nl> + with conf . open ( ' a ' ) as conf : <nl> + conf . write ( ' nosettings = 1 \ n ' ) <nl> + with node . assert_debug_log ( expected_msgs = [ ' Config file arg : [ regtest ] settings = false ' ] ) : <nl> + self . start_node ( 0 ) <nl> + self . stop_node ( 0 ) <nl> + <nl> + # Test alternate settings path <nl> + altsettings = Path ( node . datadir , " altsettings . json " ) <nl> + with altsettings . open ( " w " ) as fp : <nl> + fp . write ( ' { " key " : " value " } ' ) <nl> + with node . assert_debug_log ( expected_msgs = [ ' Setting file arg : key = " value " ' ] ) : <nl> + self . start_node ( 0 , extra_args = [ " - settings = { } " . format ( altsettings ) ] ) <nl> + self . stop_node ( 0 ) <nl> + <nl> + <nl> + if __name__ = = ' __main__ ' : <nl> + SettingsTest ( ) . main ( ) <nl> mmm a / test / functional / test_runner . py <nl> ppp b / test / functional / test_runner . py <nl> <nl> ' p2p_permissions . py ' , <nl> ' feature_blocksdir . py ' , <nl> ' feature_config_args . py ' , <nl> + ' feature_settings . py ' , <nl> ' rpc_getdescriptorinfo . py ' , <nl> ' rpc_getpeerinfo_banscore_deprecation . py ' , <nl> ' rpc_help . py ' , <nl>
|
Merge : Add < datadir > / settings . json persistent settings storage
|
bitcoin/bitcoin
|
f4cfa6d01900aa4c4696d6e1eac65e1b42f6b762
|
2020-07-23T16:39:42Z
|
mmm a / tensorflow / stream_executor / cuda / cuda_dnn . cc <nl> ppp b / tensorflow / stream_executor / cuda / cuda_dnn . cc <nl> class ScopedFilterDescriptor { <nl> / / A helper function to decide whether to enable the TENSOR_OP_MATH math type <nl> static bool TensorOpMathEnabled ( ) { <nl> static bool is_enabled = [ ] { <nl> - bool is_disabled ; <nl> + bool is_disabled = false ; <nl> TF_CHECK_OK ( <nl> tensorflow : : ReadBoolFromEnvVar ( " TF_DISABLE_CUDNN_TENSOR_OP_MATH " , <nl> / * default_val = * / false , & is_disabled ) ) ; <nl> static bool TensorOpMathEnabled ( ) { <nl> return is_enabled ; <nl> } <nl> <nl> + / / A helper function to decide whether to use CUDNN_BATCHNORM_SPATIAL_PERSISTENT <nl> + / / in batchnorm . This mode can be faster in some tasks because an optimized path <nl> + / / may be selected for CUDNN_DATA_FLOAT and CUDNN_DATA_HALF data types , compute <nl> + / / capability 6 . 0 or higher . The reason we set it to false by default is that <nl> + / / this mode may use scaled atomic integer reduction that may cause a numerical <nl> + / / overflow for certain input data range . <nl> + / / TODO ( yangzihao ) : Use autotune to choose between this mode and <nl> + / / CUDNN_BATCHNORM_SPATIAL mode . <nl> + static bool BatchnormSpatialPersistentEnabled ( ) { <nl> + static bool is_enabled = [ ] { <nl> + bool is_enabled = false ; <nl> + TF_CHECK_OK ( tensorflow : : ReadBoolFromEnvVar ( <nl> + " TF_USE_CUDNN_BATCHNORM_SPATIAL_PERSISTENT " , <nl> + / * default_val = * / false , & is_enabled ) ) ; <nl> + return is_enabled ; <nl> + } ( ) ; <nl> + return is_enabled ; <nl> + } <nl> + <nl> / / Turns a ConvolutionDescriptor structure into a cudnn convolution handle <nl> / / within a scope . <nl> class ScopedConvolutionDescriptor { <nl> bool CudnnSupport : : DoBatchNormalizationForwardImpl ( <nl> ScopedTensorDescriptor scale_offset_descriptor { <nl> parent_ , scale_offset_desc , ToCudnnDataType ( scale_data_type ) } ; <nl> cudnnBatchNormMode_t mode = CUDNN_BATCHNORM_SPATIAL ; <nl> + # if CUDNN_VERSION > = 7000 <nl> + if ( BatchnormSpatialPersistentEnabled ( ) ) { <nl> + mode = CUDNN_BATCHNORM_SPATIAL_PERSISTENT ; <nl> + } <nl> + # endif <nl> float one = 1 . 0 ; <nl> float zero = 0 . 0 ; <nl> <nl> bool CudnnSupport : : DoBatchNormalizationBackwardImpl ( <nl> parent_ , scale_offset_desc , <nl> static_cast < cudnnDataType_t > ( cudnn_scale_type ) } ; <nl> cudnnBatchNormMode_t mode = CUDNN_BATCHNORM_SPATIAL ; <nl> + # if CUDNN_VERSION > = 7000 <nl> + if ( BatchnormSpatialPersistentEnabled ( ) ) { <nl> + mode = CUDNN_BATCHNORM_SPATIAL_PERSISTENT ; <nl> + } <nl> + # endif <nl> float one = 1 . 0 ; <nl> float zero = 0 . 0 ; <nl> <nl>
|
Add env - var to specify whether to use CUDNN_BATCHNORM_SPATIAL_PERSISTENT for cudnn batchnorm .
|
tensorflow/tensorflow
|
5b3b689cc307632d38f08b1c7f6952bbe7a7ad7e
|
2018-02-15T01:32:38Z
|
mmm a / src / mongo / db / repl / bgsync . cpp <nl> ppp b / src / mongo / db / repl / bgsync . cpp <nl> void BackgroundSync : : _runRollback ( OperationContext * opCtx , <nl> if ( _state ! = ProducerState : : Running ) { <nl> return ; <nl> } <nl> - _rollback = stdx : : make_unique < RollbackImpl > ( executor , <nl> - & localOplog , <nl> - source , <nl> - requiredRBID , <nl> - _replCoord , <nl> - storageInterface , <nl> - onRollbackShutdownCallbackFn ) ; <nl> + _rollback = stdx : : make_unique < RollbackImpl > ( <nl> + executor , <nl> + & localOplog , <nl> + source , <nl> + NamespaceString ( rsOplogName ) , <nl> + _replicationCoordinatorExternalState - > getOplogFetcherMaxFetcherRestarts ( ) , <nl> + requiredRBID , <nl> + _replCoord , <nl> + storageInterface , <nl> + onRollbackShutdownCallbackFn ) ; <nl> rollback = _rollback . get ( ) ; <nl> } catch ( . . . ) { <nl> fassertFailedWithStatus ( 40401 , exceptionToStatus ( ) ) ; <nl> mmm a / src / mongo / db / repl / rollback_impl . cpp <nl> ppp b / src / mongo / db / repl / rollback_impl . cpp <nl> ServiceContext : : UniqueOperationContext makeOpCtx ( ) { <nl> RollbackImpl : : RollbackImpl ( executor : : TaskExecutor * executor , <nl> OplogInterface * localOplog , <nl> const HostAndPort & syncSource , <nl> + const NamespaceString & remoteOplogNss , <nl> + std : : size_t maxFetcherRestarts , <nl> int requiredRollbackId , <nl> ReplicationCoordinator * replicationCoordinator , <nl> StorageInterface * storageInterface , <nl> RollbackImpl : : RollbackImpl ( executor : : TaskExecutor * executor , <nl> : AbstractAsyncComponent ( executor , " rollback " ) , <nl> _localOplog ( localOplog ) , <nl> _syncSource ( syncSource ) , <nl> + _remoteOplogNss ( remoteOplogNss ) , <nl> + _maxFetcherRestarts ( maxFetcherRestarts ) , <nl> _requiredRollbackId ( requiredRollbackId ) , <nl> _replicationCoordinator ( replicationCoordinator ) , <nl> _storageInterface ( storageInterface ) , <nl> mmm a / src / mongo / db / repl / rollback_impl . h <nl> ppp b / src / mongo / db / repl / rollback_impl . h <nl> class RollbackImpl : public AbstractAsyncComponent , public Rollback { <nl> RollbackImpl ( executor : : TaskExecutor * executor , <nl> OplogInterface * localOplog , <nl> const HostAndPort & syncSource , <nl> + const NamespaceString & remoteOplogNss , <nl> + std : : size_t maxFetcherRestarts , <nl> int requiredRollbackId , <nl> ReplicationCoordinator * replicationCoordinator , <nl> StorageInterface * storageInterface , <nl> class RollbackImpl : public AbstractAsyncComponent , public Rollback { <nl> / / Host and port of the sync source we are rolling back against . <nl> const HostAndPort _syncSource ; / / ( R ) <nl> <nl> + / / Fully qualified namespace of the remote oplog . <nl> + const NamespaceString _remoteOplogNss ; / / ( R ) <nl> + <nl> + / / Number of times to restart the query in the RollbackCommonPointResolver and OplogFetcher . <nl> + std : : size_t _maxFetcherRestarts ; / / ( R ) <nl> + <nl> / / This is the current rollback ID on the sync source that we are rolling back against . <nl> / / It is an error if the rollback ID on the sync source changes before rollback is complete . <nl> const int _requiredRollbackId ; / / ( R ) <nl> mmm a / src / mongo / db / repl / rollback_impl_test . cpp <nl> ppp b / src / mongo / db / repl / rollback_impl_test . cpp <nl> namespace { <nl> using namespace mongo ; <nl> using namespace mongo : : repl ; <nl> <nl> + NamespaceString nss ( " local . oplog . rs " ) ; <nl> + <nl> / * * <nl> * Unit test for rollback implementation introduced in 3 . 6 . <nl> * / <nl> void RollbackImplTest : : setUp ( ) { <nl> _taskExecutorMock . get ( ) , <nl> _localOplog . get ( ) , <nl> syncSource , <nl> + nss , <nl> + 0 , <nl> _requiredRollbackId , <nl> _coordinator , <nl> & _storageInterface , <nl> TEST_F ( RollbackImplTest , InvalidConstruction ) { <nl> ASSERT_THROWS_CODE_AND_WHAT ( RollbackImpl ( nullptr , <nl> & emptyOplog , <nl> syncSource , <nl> + nss , <nl> + 0 , <nl> requiredRollbackId , <nl> replicationCoordinator , <nl> storageInterface , <nl> TEST_F ( RollbackImplTest , InvalidConstruction ) { <nl> ASSERT_THROWS_CODE_AND_WHAT ( RollbackImpl ( executor , <nl> & emptyOplog , <nl> HostAndPort ( ) , <nl> + nss , <nl> + 0 , <nl> requiredRollbackId , <nl> replicationCoordinator , <nl> storageInterface , <nl> TEST_F ( RollbackImplTest , RollbackResetsOnCompletionCallbackFunctionPointerUponCo <nl> _taskExecutorMock . get ( ) , <nl> _localOplog . get ( ) , <nl> HostAndPort ( " localhost " , 1234 ) , <nl> + nss , <nl> + 0 , <nl> _requiredRollbackId , <nl> _coordinator , <nl> & _storageInterface , <nl>
|
SERVER - 28214 add remoteOplogNss and maxFetcherRestarts arguments to RollbackImpl constructor
|
mongodb/mongo
|
f1730beea3b55c31e33ece40e8bc1f9b4ed78b9a
|
2017-05-04T18:11:21Z
|
mmm a / HelloLua / android / src / org / cocos2dx / lib / Cocos2dxBitmap . java <nl> ppp b / HelloLua / android / src / org / cocos2dx / lib / Cocos2dxBitmap . java <nl> <nl> public static void createTextBitmap ( String content , String fontName , <nl> int fontSize , int alignment , int width , int height ) { <nl> <nl> - / / Avoid error when content is " " <nl> - if ( content . compareTo ( " " ) = = 0 ) { <nl> - content = " " ; <nl> - } <nl> - <nl> + content = refactorString ( content ) ; <nl> Paint paint = newPaint ( fontName , fontSize , alignment ) ; <nl> <nl> TextProperty textProperty = getTextWidthAndHeight ( content , paint , width , height ) ; <nl> private static Paint newPaint ( String fontName , int fontSize , int alignment ) { <nl> return paint ; <nl> } <nl> <nl> + private static String refactorString ( String str ) { <nl> + / / Avoid error when content is " " <nl> + if ( str . compareTo ( " " ) = = 0 ) { <nl> + return " " ; <nl> + } <nl> + <nl> + / * <nl> + * If the font of " \ n " is " " or " \ n " , insert " " in front of it . <nl> + * <nl> + * For example : <nl> + * " \ nabc " - > " \ nabc " <nl> + * " \ nabc \ n \ n " - > " \ nabc \ n \ n " <nl> + * / <nl> + StringBuilder strBuilder = new StringBuilder ( str ) ; <nl> + int start = 0 ; <nl> + int index = strBuilder . indexOf ( " \ n " ) ; <nl> + while ( index ! = - 1 ) { <nl> + if ( index = = 0 | | strBuilder . charAt ( index - 1 ) = = ' \ n ' ) { <nl> + strBuilder . insert ( start , " " ) ; <nl> + start = index + 2 ; <nl> + } else { <nl> + start = index + 1 ; <nl> + } <nl> + <nl> + if ( start > strBuilder . length ( ) | | index = = strBuilder . length ( ) ) { <nl> + break ; <nl> + } <nl> + <nl> + index = strBuilder . indexOf ( " \ n " , start ) ; <nl> + } <nl> + <nl> + return strBuilder . toString ( ) ; <nl> + } <nl> + <nl> private static void initNativeObject ( Bitmap bitmap ) { <nl> byte [ ] pixels = getPixels ( bitmap ) ; <nl> if ( pixels = = null ) { <nl> mmm a / HelloWorld / android / src / org / cocos2dx / lib / Cocos2dxBitmap . java <nl> ppp b / HelloWorld / android / src / org / cocos2dx / lib / Cocos2dxBitmap . java <nl> <nl> public static void createTextBitmap ( String content , String fontName , <nl> int fontSize , int alignment , int width , int height ) { <nl> <nl> - / / Avoid error when content is " " <nl> - if ( content . compareTo ( " " ) = = 0 ) { <nl> - content = " " ; <nl> - } <nl> - <nl> + content = refactorString ( content ) ; <nl> Paint paint = newPaint ( fontName , fontSize , alignment ) ; <nl> <nl> TextProperty textProperty = getTextWidthAndHeight ( content , paint , width , height ) ; <nl> private static Paint newPaint ( String fontName , int fontSize , int alignment ) { <nl> return paint ; <nl> } <nl> <nl> + private static String refactorString ( String str ) { <nl> + / / Avoid error when content is " " <nl> + if ( str . compareTo ( " " ) = = 0 ) { <nl> + return " " ; <nl> + } <nl> + <nl> + / * <nl> + * If the font of " \ n " is " " or " \ n " , insert " " in front of it . <nl> + * <nl> + * For example : <nl> + * " \ nabc " - > " \ nabc " <nl> + * " \ nabc \ n \ n " - > " \ nabc \ n \ n " <nl> + * / <nl> + StringBuilder strBuilder = new StringBuilder ( str ) ; <nl> + int start = 0 ; <nl> + int index = strBuilder . indexOf ( " \ n " ) ; <nl> + while ( index ! = - 1 ) { <nl> + if ( index = = 0 | | strBuilder . charAt ( index - 1 ) = = ' \ n ' ) { <nl> + strBuilder . insert ( start , " " ) ; <nl> + start = index + 2 ; <nl> + } else { <nl> + start = index + 1 ; <nl> + } <nl> + <nl> + if ( start > strBuilder . length ( ) | | index = = strBuilder . length ( ) ) { <nl> + break ; <nl> + } <nl> + <nl> + index = strBuilder . indexOf ( " \ n " , start ) ; <nl> + } <nl> + <nl> + return strBuilder . toString ( ) ; <nl> + } <nl> + <nl> private static void initNativeObject ( Bitmap bitmap ) { <nl> byte [ ] pixels = getPixels ( bitmap ) ; <nl> if ( pixels = = null ) { <nl> mmm a / cocos2dx / Android . mk <nl> ppp b / cocos2dx / Android . mk <nl> platform / platform . cpp \ <nl> platform / android / CCEGLView_android . cpp \ <nl> platform / android / CCAccelerometer_android . cpp \ <nl> platform / android / CCApplication_android . cpp \ <nl> - platform / android / Cocos2dJni . cpp \ <nl> + platform / android / jni / JniHelper . cpp \ <nl> + platform / android / jni / IMEJni . cpp \ <nl> + platform / android / jni / MessageJni . cpp \ <nl> + platform / android / jni / SensorJni . cpp \ <nl> + platform / android / jni / SystemInfoJni . cpp \ <nl> + platform / android / jni / TouchesJni . cpp \ <nl> script_support / CCScriptSupport . cpp \ <nl> sprite_nodes / CCAnimation . cpp \ <nl> sprite_nodes / CCAnimationCache . cpp \ <nl> tileMap_parallax_nodes / CCTMXTiledMap . cpp \ <nl> tileMap_parallax_nodes / CCTMXXMLParser . cpp \ <nl> tileMap_parallax_nodes / CCTileMapAtlas . cpp \ <nl> touch_dispatcher / CCTouchDispatcher . cpp \ <nl> - touch_dispatcher / CCTouchHandler . cpp \ <nl> + touch_dispatcher / CCTouchHandler . cpp <nl> <nl> <nl> <nl> mmm a / cocos2dx / CCScheduler . cpp <nl> ppp b / cocos2dx / CCScheduler . cpp <nl> void CCTimer : : update ( ccTime dt ) <nl> <nl> if ( m_fElapsed > = m_fInterval ) <nl> { <nl> - if ( NULL ! = m_pfnSelector ) <nl> + if ( 0 ! = m_pfnSelector ) <nl> { <nl> ( m_pTarget - > * m_pfnSelector ) ( m_fElapsed ) ; <nl> m_fElapsed = 0 ; <nl> mmm a / cocos2dx / platform / CCCommon . cpp <nl> ppp b / cocos2dx / platform / CCCommon . cpp <nl> NS_CC_END ; <nl> <nl> # include < android / log . h > <nl> # include < stdio . h > <nl> + # include < jni . h > <nl> <nl> - # include " android / Cocos2dJni . h " <nl> + # include " android / jni / MessageJni . h " <nl> <nl> NS_CC_BEGIN ; <nl> <nl> mmm a / cocos2dx / platform / android / CCAccelerometer_android . cpp <nl> ppp b / cocos2dx / platform / android / CCAccelerometer_android . cpp <nl> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> THE SOFTWARE . <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> # include " CCAccelerometer_android . h " <nl> + # include " jni / SensorJni . h " <nl> # include < stdio . h > <nl> # include < android / log . h > <nl> <nl> mmm a / cocos2dx / platform / android / CCAccelerometer_android . h <nl> ppp b / cocos2dx / platform / android / CCAccelerometer_android . h <nl> THE SOFTWARE . <nl> <nl> # include " CCCommon . h " <nl> # include " CCAccelerometerDelegate . h " <nl> - # include " Cocos2dJni . h " <nl> # include < list > <nl> <nl> namespace cocos2d { <nl> mmm a / cocos2dx / platform / android / CCApplication_android . cpp <nl> ppp b / cocos2dx / platform / android / CCApplication_android . cpp <nl> <nl> # include " CCApplication . h " <nl> - <nl> + # include " jni / JniHelper . h " <nl> # include " CCDirector . h " <nl> # include " CCEGLView . h " <nl> - # include " Cocos2dJni . h " <nl> + # include " android / jni / SystemInfoJni . h " <nl> # include < android / log . h > <nl> # include < jni . h > <nl> <nl> int CCApplication : : run ( ) <nl> <nl> void CCApplication : : setAnimationInterval ( double interval ) <nl> { <nl> - jmethodID ret = 0 ; <nl> - JNIEnv * env = 0 ; <nl> - jclass classOfCocos2dxRenderer = 0 ; <nl> - <nl> - if ( ! gJavaVM ) <nl> + JniMethodInfo methodInfo ; <nl> + if ( ! JniHelper : : getStaticMethodInfo ( methodInfo , " org / cocos2dx / lib / Cocos2dxRenderer " , " setAnimationInterval " , <nl> + " ( D ) V " ) ) <nl> { <nl> - LOGD ( " have not java vm " ) ; <nl> - return ; <nl> + CCLOG ( " % s % d : error to get methodInfo " , __FILE__ , __LINE__ ) ; <nl> } <nl> - <nl> - / / get jni environment and java class for Cocos2dxActivity <nl> - if ( gJavaVM - > GetEnv ( ( void * * ) & env , JNI_VERSION_1_4 ) ! = JNI_OK ) <nl> + else <nl> { <nl> - LOGD ( " Failed to get the environment using GetEnv ( ) " ) ; <nl> - return ; <nl> - } <nl> - <nl> - if ( gJavaVM - > AttachCurrentThread ( & env , 0 ) < 0 ) <nl> - { <nl> - LOGD ( " Failed to get the environment using AttachCurrentThread ( ) " ) ; <nl> - return ; <nl> - } <nl> - <nl> - classOfCocos2dxRenderer = env - > FindClass ( " org / cocos2dx / lib / Cocos2dxRenderer " ) ; <nl> - if ( ! classOfCocos2dxRenderer ) <nl> - { <nl> - LOGD ( " Failed to find class of org / cocos2dx / lib / Cocos2dxRenderer " ) ; <nl> - return ; <nl> - } <nl> - <nl> - if ( env ! = 0 & & classOfCocos2dxRenderer ! = 0 ) <nl> - { <nl> - ret = env - > GetStaticMethodID ( classOfCocos2dxRenderer , " setAnimationInterval " , " ( D ) V " ) ; <nl> - <nl> - if ( ret ! = 0 ) <nl> - { <nl> - env - > CallStaticVoidMethod ( classOfCocos2dxRenderer , ret , interval ) ; <nl> - } <nl> + methodInfo . env - > CallStaticVoidMethod ( methodInfo . classID , methodInfo . methodID , interval ) ; <nl> } <nl> } <nl> <nl> mmm a / cocos2dx / platform / android / CCEGLView_android . cpp <nl> ppp b / cocos2dx / platform / android / CCEGLView_android . cpp <nl> THE SOFTWARE . <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> # include " CCEGLView_android . h " <nl> # include " GLES / gl . h " <nl> - <nl> # include " CCSet . h " <nl> # include " CCDirector . h " <nl> # include " ccMacros . h " <nl> # include " CCTouchDispatcher . h " <nl> - # include " Cocos2dJni . h " <nl> + # include " jni / IMEJni . h " <nl> + # include " jni / MessageJni . h " <nl> <nl> # include < stdlib . h > <nl> <nl> mmm a / cocos2dx / platform / android / CCFileUtils_android . cpp <nl> ppp b / cocos2dx / platform / android / CCFileUtils_android . cpp <nl> THE SOFTWARE . <nl> NS_CC_BEGIN ; <nl> <nl> # include " CCCommon . h " <nl> - # include " Cocos2dJni . h " <nl> + # include " jni / SystemInfoJni . h " <nl> <nl> # define MAX_PATH 256 <nl> <nl> mmm a / cocos2dx / platform / android / CCImage_android . cpp <nl> ppp b / cocos2dx / platform / android / CCImage_android . cpp <nl> THE SOFTWARE . <nl> # include < jni . h > <nl> <nl> # include " CCPlatformMacros . h " <nl> - # include " Cocos2dJni . h " <nl> # include " CCImage . h " <nl> + # include " jni / JniHelper . h " <nl> <nl> <nl> NS_CC_BEGIN ; <nl> class BitmapDC <nl> <nl> bool getBitmapFromJava ( const char * text , int nWidth , int nHeight , CCImage : : ETextAlign eAlignMask , const char * pFontName , float fontSize ) <nl> { <nl> - / / get env <nl> - if ( gJavaVM - > GetEnv ( ( void * * ) & env , JNI_VERSION_1_4 ) < 0 ) <nl> + JniMethodInfo methodInfo ; <nl> + if ( ! JniHelper : : getStaticMethodInfo ( methodInfo , " org / cocos2dx / lib / Cocos2dxBitmap " , " createTextBitmap " , <nl> + " ( Ljava / lang / String ; Ljava / lang / String ; IIII ) V " ) ) <nl> { <nl> - if ( gJavaVM - > AttachCurrentThread ( & env , NULL ) < 0 ) <nl> - { <nl> - return false ; <nl> - } <nl> - } <nl> - <nl> - / / get class <nl> - jclass mClass = env - > FindClass ( " org / cocos2dx / lib / Cocos2dxBitmap " ) ; <nl> - if ( ! mClass ) <nl> - { <nl> - CCLOG ( " can not find org . cocos2dx . Cocos2dJNI " ) ; <nl> - return false ; <nl> - } <nl> - <nl> - / / get method of createBitmap <nl> - jmethodID midCreateTextBitmap = env - > GetStaticMethodID ( mClass , " createTextBitmap " , " ( Ljava / lang / String ; Ljava / lang / String ; IIII ) V " ) ; <nl> - if ( ! midCreateTextBitmap ) <nl> - { <nl> - CCLOG ( " can not find method createTextBitmap " ) ; <nl> + CCLOG ( " % s % d : error to get methodInfo " , __FILE__ , __LINE__ ) ; <nl> return false ; <nl> } <nl> <nl> class BitmapDC <nl> * and data . <nl> * use this appoach to decrease the jni call number <nl> * / <nl> - env - > CallStaticVoidMethod ( mClass , midCreateTextBitmap , env - > NewStringUTF ( text ) , env - > NewStringUTF ( pFontName ) , <nl> - ( int ) fontSize , eAlignMask , nWidth , nHeight ) ; <nl> + methodInfo . env - > CallStaticVoidMethod ( methodInfo . classID , methodInfo . methodID , methodInfo . env - > NewStringUTF ( text ) , <nl> + methodInfo . env - > NewStringUTF ( pFontName ) , ( int ) fontSize , eAlignMask , nWidth , nHeight ) ; <nl> <nl> return true ; <nl> } <nl> extern " C " <nl> cocos2d : : sharedBitmapDC ( ) . m_nWidth = width ; <nl> cocos2d : : sharedBitmapDC ( ) . m_nHeight = height ; <nl> cocos2d : : sharedBitmapDC ( ) . m_pData = new unsigned char [ size ] ; <nl> - cocos2d : : sharedBitmapDC ( ) . env - > GetByteArrayRegion ( pixels , 0 , size , ( jbyte * ) cocos2d : : sharedBitmapDC ( ) . m_pData ) ; <nl> + env - > GetByteArrayRegion ( pixels , 0 , size , ( jbyte * ) cocos2d : : sharedBitmapDC ( ) . m_pData ) ; <nl> <nl> / / swap data <nl> unsigned int * tempPtr = ( unsigned int * ) cocos2d : : sharedBitmapDC ( ) . m_pData ; <nl> deleted file mode 100644 <nl> index 8df86aadbbf6 . . 000000000000 <nl> mmm a / cocos2dx / platform / android / Cocos2dJni . cpp <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2010 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - # include " Cocos2dJni . h " <nl> - # include " CCSet . h " <nl> - # include " CCDirector . h " <nl> - # include " CCKeypadDispatcher . h " <nl> - # include " CCTouch . h " <nl> - # include " CCTouchDispatcher . h " <nl> - # include " CCFileUtils . h " <nl> - # include " CCGeometry . h " <nl> - # include " CCAccelerometer . h " <nl> - # include " CCApplication . h " <nl> - # include " CCIMEDispatcher . h " <nl> - # include " CCAccelerometer_android . h " <nl> - # include < android / log . h > <nl> - <nl> - # if 0 <nl> - # define LOG_TAG " Cocos2dJni " <nl> - # define LOGD ( . . . ) __android_log_print ( ANDROID_LOG_DEBUG , LOG_TAG , __VA_ARGS__ ) <nl> - # else <nl> - # define LOGD ( . . . ) <nl> - # endif <nl> - <nl> - using namespace cocos2d ; <nl> - <nl> - extern " C " <nl> - { <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / java vm helper function <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - JavaVM * gJavaVM = NULL ; <nl> - <nl> - jint JNI_OnLoad ( JavaVM * vm , void * reserved ) <nl> - { <nl> - gJavaVM = vm ; <nl> - return JNI_VERSION_1_4 ; <nl> - } <nl> - <nl> - struct TMethodJNI <nl> - { <nl> - JNIEnv * env ; <nl> - jclass classID ; <nl> - jmethodID methodID ; <nl> - } ; <nl> - static bool getMethodID ( struct TMethodJNI & t , const char * className , const char * methodName , const char * paramCode ) <nl> - { <nl> - bool ret = 0 ; <nl> - do <nl> - { <nl> - if ( gJavaVM - > GetEnv ( ( void * * ) & t . env , JNI_VERSION_1_4 ) ! = JNI_OK ) <nl> - { <nl> - LOGD ( " Failed to get the environment using GetEnv ( ) " ) ; <nl> - break ; <nl> - } <nl> - <nl> - if ( gJavaVM - > AttachCurrentThread ( & t . env , 0 ) < 0 ) <nl> - { <nl> - LOGD ( " Failed to get the environment using AttachCurrentThread ( ) " ) ; <nl> - break ; <nl> - } <nl> - <nl> - t . classID = t . env - > FindClass ( className ) ; <nl> - if ( ! t . classID ) <nl> - { <nl> - LOGD ( " Failed to find class of % s " , className ) ; <nl> - break ; <nl> - } <nl> - <nl> - t . methodID = t . env - > GetStaticMethodID ( t . classID , methodName , paramCode ) ; <nl> - if ( ! t . methodID ) <nl> - { <nl> - LOGD ( " Failed to find method id of % s " , methodName ) ; <nl> - break ; <nl> - } <nl> - ret = true ; <nl> - } while ( 0 ) ; <nl> - <nl> - return ret ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / native renderer <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - # define MAX_TOUCHES 5 <nl> - static CCTouch * s_pTouches [ MAX_TOUCHES ] = { NULL } ; <nl> - <nl> - void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeRender ( JNIEnv * env ) <nl> - { <nl> - cocos2d : : CCDirector : : sharedDirector ( ) - > mainLoop ( ) ; <nl> - } <nl> - <nl> - / / handle touch event <nl> - void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesBegin ( JNIEnv * env , jobject thiz , jint id , jfloat x , jfloat y ) <nl> - { <nl> - CCRect rcRect = CCEGLView : : sharedOpenGLView ( ) . getViewPort ( ) ; <nl> - float fScreenScaleFactor = CCEGLView : : sharedOpenGLView ( ) . getScreenScaleFactor ( ) ; <nl> - CCSet set ; <nl> - <nl> - CCTouch * pTouch = s_pTouches [ id ] ; <nl> - if ( ! pTouch ) <nl> - { <nl> - LOGD ( " Beginning touches with id : % d , x = % f , y = % f " , id , x , y ) ; <nl> - <nl> - pTouch = new CCTouch ( ) ; <nl> - pTouch - > SetTouchInfo ( 0 , ( x - rcRect . origin . x ) / fScreenScaleFactor , ( y - rcRect . origin . y ) / fScreenScaleFactor ) ; <nl> - s_pTouches [ id ] = pTouch ; <nl> - set . addObject ( pTouch ) ; <nl> - <nl> - cocos2d : : CCDirector : : sharedDirector ( ) - > getOpenGLView ( ) - > getDelegate ( ) - > touchesBegan ( & set , NULL ) ; <nl> - } <nl> - else <nl> - { <nl> - LOGD ( " Beginnig touches with id : % d error " , id ) ; <nl> - } <nl> - } <nl> - <nl> - void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesEnd ( JNIEnv * env , jobject thiz , jint id , jfloat x , jfloat y ) <nl> - { <nl> - CCRect rcRect = CCEGLView : : sharedOpenGLView ( ) . getViewPort ( ) ; <nl> - float fScreenScaleFactor = CCEGLView : : sharedOpenGLView ( ) . getScreenScaleFactor ( ) ; <nl> - CCSet set ; <nl> - <nl> - / * Add to the set to send to the director * / <nl> - CCTouch * pTouch = s_pTouches [ id ] ; <nl> - if ( pTouch ) <nl> - { <nl> - LOGD ( " Ending touches with id : % d , x = % f , y = % f " , id , x , y ) ; <nl> - <nl> - pTouch - > SetTouchInfo ( 0 , ( x - rcRect . origin . x ) / fScreenScaleFactor , ( y - rcRect . origin . y ) / fScreenScaleFactor ) ; <nl> - set . addObject ( pTouch ) ; <nl> - <nl> - / / release the object <nl> - pTouch - > release ( ) ; <nl> - s_pTouches [ id ] = NULL ; <nl> - <nl> - cocos2d : : CCDirector : : sharedDirector ( ) - > getOpenGLView ( ) - > getDelegate ( ) - > touchesEnded ( & set , NULL ) ; <nl> - } else { <nl> - LOGD ( " Ending touches with id : % d error " , id ) ; <nl> - } <nl> - } <nl> - <nl> - void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesMove ( JNIEnv * env , jobject thiz , jintArray ids , jfloatArray xs , jfloatArray ys ) <nl> - { <nl> - int size = env - > GetArrayLength ( ids ) ; <nl> - jint id [ size ] ; <nl> - jfloat x [ size ] ; <nl> - jfloat y [ size ] ; <nl> - CCRect rcRect = CCEGLView : : sharedOpenGLView ( ) . getViewPort ( ) ; <nl> - float fScreenScaleFactor = CCEGLView : : sharedOpenGLView ( ) . getScreenScaleFactor ( ) ; <nl> - CCSet set ; <nl> - <nl> - env - > GetIntArrayRegion ( ids , 0 , size , id ) ; <nl> - env - > GetFloatArrayRegion ( xs , 0 , size , x ) ; <nl> - env - > GetFloatArrayRegion ( ys , 0 , size , y ) ; <nl> - <nl> - for ( int i = 0 ; i < size ; i + + ) { <nl> - LOGD ( " Moving touches with id : % d , x = % f , y = % f " , id [ i ] , x [ i ] , y [ i ] ) ; <nl> - cocos2d : : CCTouch * pTouch = s_pTouches [ id [ i ] ] ; <nl> - if ( pTouch ) <nl> - { <nl> - pTouch - > SetTouchInfo ( 0 , ( x [ i ] - rcRect . origin . x ) / fScreenScaleFactor , <nl> - ( y [ i ] - rcRect . origin . y ) / fScreenScaleFactor ) ; <nl> - set . addObject ( pTouch ) ; <nl> - } <nl> - else <nl> - { <nl> - / / It is error , should return . <nl> - LOGD ( " Moving touches with id : % d error " , id [ i ] ) ; <nl> - return ; <nl> - } <nl> - } <nl> - <nl> - cocos2d : : CCDirector : : sharedDirector ( ) - > getOpenGLView ( ) - > getDelegate ( ) - > touchesMoved ( & set , NULL ) ; <nl> - } <nl> - <nl> - void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesCancel ( JNIEnv * env , jobject thiz , jintArray ids , jfloatArray xs , jfloatArray ys ) <nl> - { <nl> - int size = env - > GetArrayLength ( ids ) ; <nl> - jint id [ size ] ; <nl> - jfloat x [ size ] ; <nl> - jfloat y [ size ] ; <nl> - CCRect rcRect = CCEGLView : : sharedOpenGLView ( ) . getViewPort ( ) ; <nl> - float fScreenScaleFactor = CCEGLView : : sharedOpenGLView ( ) . getScreenScaleFactor ( ) ; <nl> - CCSet set ; <nl> - <nl> - env - > GetIntArrayRegion ( ids , 0 , size , id ) ; <nl> - env - > GetFloatArrayRegion ( xs , 0 , size , x ) ; <nl> - env - > GetFloatArrayRegion ( ys , 0 , size , y ) ; <nl> - <nl> - for ( int i = 0 ; i < size ; i + + ) { <nl> - cocos2d : : CCTouch * pTouch = s_pTouches [ id [ i ] ] ; <nl> - if ( pTouch ) <nl> - { <nl> - pTouch - > SetTouchInfo ( 0 , ( x [ i ] - rcRect . origin . x ) / fScreenScaleFactor , <nl> - ( y [ i ] - rcRect . origin . y ) / fScreenScaleFactor ) ; <nl> - set . addObject ( pTouch ) ; <nl> - s_pTouches [ id [ i ] ] = NULL ; <nl> - pTouch - > release ( ) ; <nl> - } <nl> - } <nl> - <nl> - cocos2d : : CCDirector : : sharedDirector ( ) - > getOpenGLView ( ) - > getDelegate ( ) - > touchesCancelled ( & set , NULL ) ; <nl> - } <nl> - <nl> - / / handle onPause and onResume <nl> - <nl> - void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnPause ( ) <nl> - { <nl> - CCApplication : : sharedApplication ( ) . applicationDidEnterBackground ( ) ; <nl> - } <nl> - <nl> - void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnResume ( ) <nl> - { <nl> - / / Shared OpenGL View instance doesn ' t exist yet when Activity . onResume is first called <nl> - if ( CCDirector : : sharedDirector ( ) - > getOpenGLView ( ) ) <nl> - CCApplication : : sharedApplication ( ) . applicationWillEnterForeground ( ) ; <nl> - } <nl> - <nl> - # define KEYCODE_BACK 0x04 <nl> - # define KEYCODE_MENU 0x52 <nl> - <nl> - / / handle keydown event <nl> - <nl> - jboolean Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeKeyDown ( JNIEnv * env , jobject thiz , jint keyCode ) <nl> - { <nl> - switch ( keyCode ) <nl> - { <nl> - case KEYCODE_BACK : <nl> - if ( CCKeypadDispatcher : : sharedDispatcher ( ) - > dispatchKeypadMSG ( kTypeBackClicked ) ) <nl> - return JNI_TRUE ; <nl> - break ; <nl> - case KEYCODE_MENU : <nl> - if ( CCKeypadDispatcher : : sharedDispatcher ( ) - > dispatchKeypadMSG ( kTypeMenuClicked ) ) <nl> - return JNI_TRUE ; <nl> - break ; <nl> - default : <nl> - return JNI_FALSE ; <nl> - } <nl> - return JNI_FALSE ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / handle accelerometer changes <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - void Java_org_cocos2dx_lib_Cocos2dxAccelerometer_onSensorChanged ( JNIEnv * env , jobject thiz , jfloat x , jfloat y , jfloat z , jlong timeStamp ) <nl> - { <nl> - / / We need to invert to make it compatible with iOS . <nl> - CCRect rcRect = CCEGLView : : sharedOpenGLView ( ) . getViewPort ( ) ; <nl> - float fScreenScaleFactor = CCEGLView : : sharedOpenGLView ( ) . getScreenScaleFactor ( ) ; <nl> - cocos2d : : CCAccelerometer : : sharedAccelerometer ( ) - > update ( ( x - rcRect . origin . x ) / fScreenScaleFactor , <nl> - ( y - rcRect . origin . y ) / fScreenScaleFactor , <nl> - z , <nl> - timeStamp ) ; <nl> - } <nl> - <nl> - void Java_org_cocos2dx_lib_Cocos2dxActivity_nativeSetPaths ( JNIEnv * env , jobject thiz , jstring apkPath ) <nl> - { <nl> - const char * str ; <nl> - jboolean isCopy ; <nl> - str = env - > GetStringUTFChars ( apkPath , & isCopy ) ; <nl> - if ( isCopy ) { <nl> - cocos2d : : CCFileUtils : : setResourcePath ( str ) ; <nl> - env - > ReleaseStringUTFChars ( apkPath , str ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - void enableAccelerometerJNI ( ) <nl> - { <nl> - TMethodJNI t ; <nl> - if ( getMethodID ( t <nl> - , " org / cocos2dx / lib / Cocos2dxActivity " <nl> - , " enableAccelerometer " <nl> - , " ( ) V " ) ) <nl> - { <nl> - t . env - > CallStaticVoidMethod ( t . classID , t . methodID ) ; <nl> - } <nl> - } <nl> - <nl> - void disableAccelerometerJNI ( ) <nl> - { <nl> - TMethodJNI t ; <nl> - <nl> - if ( getMethodID ( t <nl> - , " org / cocos2dx / lib / Cocos2dxActivity " <nl> - , " disableAccelerometer " <nl> - , " ( ) V " ) ) <nl> - { <nl> - t . env - > CallStaticVoidMethod ( t . classID , t . methodID ) ; <nl> - } <nl> - } <nl> - <nl> - void showMessageBoxJNI ( const char * pszMsg , const char * pszTitle ) <nl> - { <nl> - if ( ! pszMsg ) <nl> - { <nl> - return ; <nl> - } <nl> - <nl> - TMethodJNI t ; <nl> - if ( getMethodID ( t <nl> - , " org / cocos2dx / lib / Cocos2dxActivity " <nl> - , " showMessageBox " <nl> - , " ( Ljava / lang / String ; Ljava / lang / String ; ) V " ) ) <nl> - { <nl> - jstring StringArg1 ; <nl> - <nl> - if ( ! pszTitle ) <nl> - { <nl> - StringArg1 = t . env - > NewStringUTF ( " " ) ; <nl> - } <nl> - else <nl> - { <nl> - StringArg1 = t . env - > NewStringUTF ( pszTitle ) ; <nl> - } <nl> - <nl> - jstring StringArg2 = t . env - > NewStringUTF ( pszMsg ) ; <nl> - t . env - > CallStaticVoidMethod ( t . classID , t . methodID , StringArg1 , StringArg2 ) ; <nl> - } <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / handle IME message <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - void setKeyboardStateJNI ( int bOpen ) <nl> - { <nl> - TMethodJNI t ; <nl> - / / jint open = bOpen ; <nl> - if ( getMethodID ( t <nl> - , " org / cocos2dx / lib / Cocos2dxGLSurfaceView " <nl> - , ( bOpen ) ? " openIMEKeyboard " : " closeIMEKeyboard " <nl> - , " ( ) V " ) ) <nl> - { <nl> - t . env - > CallStaticVoidMethod ( t . classID , t . methodID ) ; <nl> - } <nl> - } <nl> - <nl> - void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInsertText ( JNIEnv * env , jobject thiz , jstring text ) <nl> - { <nl> - jboolean isCopy = 0 ; <nl> - const char * pszText = env - > GetStringUTFChars ( text , & isCopy ) ; <nl> - if ( isCopy ) <nl> - { <nl> - cocos2d : : CCIMEDispatcher : : sharedDispatcher ( ) - > dispatchInsertText ( pszText , strlen ( pszText ) ) ; <nl> - env - > ReleaseStringUTFChars ( text , pszText ) ; <nl> - } <nl> - } <nl> - <nl> - void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeDeleteBackward ( JNIEnv * env , jobject thiz ) <nl> - { <nl> - cocos2d : : CCIMEDispatcher : : sharedDispatcher ( ) - > dispatchDeleteBackward ( ) ; <nl> - } <nl> - <nl> - jstring Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeGetContentText ( ) <nl> - { <nl> - JNIEnv * env = 0 ; <nl> - <nl> - if ( gJavaVM - > GetEnv ( ( void * * ) & env , JNI_VERSION_1_4 ) ! = JNI_OK | | ! env ) <nl> - { <nl> - return 0 ; <nl> - } <nl> - const char * pszText = cocos2d : : CCIMEDispatcher : : sharedDispatcher ( ) - > getContentText ( ) ; <nl> - return env - > NewStringUTF ( pszText ) ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / get package name <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - static char * jstringTostring ( JNIEnv * env , jstring jstr ) <nl> - { <nl> - char * rtn = NULL ; <nl> - <nl> - / / convert jstring to byte array <nl> - jclass clsstring = env - > FindClass ( " java / lang / String " ) ; <nl> - jstring strencode = env - > NewStringUTF ( " utf - 8 " ) ; <nl> - jmethodID mid = env - > GetMethodID ( clsstring , " getBytes " , " ( Ljava / lang / String ; ) [ B " ) ; <nl> - jbyteArray barr = ( jbyteArray ) env - > CallObjectMethod ( jstr , mid , strencode ) ; <nl> - jsize alen = env - > GetArrayLength ( barr ) ; <nl> - jbyte * ba = env - > GetByteArrayElements ( barr , JNI_FALSE ) ; <nl> - <nl> - / / copy byte array into char [ ] <nl> - if ( alen > 0 ) <nl> - { <nl> - rtn = new char [ alen + 1 ] ; <nl> - memcpy ( rtn , ba , alen ) ; <nl> - rtn [ alen ] = 0 ; <nl> - } <nl> - env - > ReleaseByteArrayElements ( barr , ba , 0 ) ; <nl> - <nl> - return rtn ; <nl> - } <nl> - <nl> - char * getPackageNameJNI ( ) <nl> - { <nl> - TMethodJNI t ; <nl> - char * ret = NULL ; <nl> - <nl> - if ( getMethodID ( t , <nl> - " org / cocos2dx / lib / Cocos2dxActivity " , <nl> - " getCocos2dxPackageName " , <nl> - " ( ) Ljava / lang / String ; " ) ) <nl> - { <nl> - jstring str = ( jstring ) t . env - > CallStaticObjectMethod ( t . classID , t . methodID ) ; <nl> - ret = jstringTostring ( t . env , str ) ; <nl> - <nl> - LOGD ( " package name % s " , ret ) ; <nl> - } <nl> - <nl> - return ret ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / handle get current language <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - char * getCurrentLanguageJNI ( ) <nl> - { <nl> - TMethodJNI t ; <nl> - char * ret = NULL ; <nl> - <nl> - if ( getMethodID ( t <nl> - , " org / cocos2dx / lib / Cocos2dxActivity " <nl> - , " getCurrentLanguage " <nl> - , " ( ) Ljava / lang / String ; " ) ) <nl> - { <nl> - jstring str = ( jstring ) t . env - > CallStaticObjectMethod ( t . classID , t . methodID ) ; <nl> - ret = jstringTostring ( t . env , str ) ; <nl> - <nl> - LOGD ( " language name % s " , ret ) ; <nl> - } <nl> - <nl> - return ret ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / terminate the process <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - void terminateProcessJNI ( ) <nl> - { <nl> - TMethodJNI t ; <nl> - <nl> - if ( getMethodID ( t <nl> - , " org / cocos2dx / lib / Cocos2dxActivity " <nl> - , " terminateProcess " <nl> - , " ( ) V " ) ) <nl> - { <nl> - t . env - > CallStaticObjectMethod ( t . classID , t . methodID ) ; <nl> - } <nl> - } <nl> - } <nl> new file mode 100644 <nl> index 000000000000 . . b6d1a5b9bdb5 <nl> mmm / dev / null <nl> ppp b / cocos2dx / platform / android / jni / IMEJni . cpp <nl> <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + Copyright ( c ) 2010 cocos2d - x . org <nl> + <nl> + http : / / www . cocos2d - x . org <nl> + <nl> + Permission is hereby granted , free of charge , to any person obtaining a copy <nl> + of this software and associated documentation files ( the " Software " ) , to deal <nl> + in the Software without restriction , including without limitation the rights <nl> + to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> + copies of the Software , and to permit persons to whom the Software is <nl> + furnished to do so , subject to the following conditions : <nl> + <nl> + The above copyright notice and this permission notice shall be included in <nl> + all copies or substantial portions of the Software . <nl> + <nl> + THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> + IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> + LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> + THE SOFTWARE . <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # include " IMEJni . h " <nl> + # include " CCIMEDispatcher . h " <nl> + # include " JniHelper . h " <nl> + <nl> + # include < android / log . h > <nl> + # include < string . h > <nl> + # include < jni . h > <nl> + <nl> + # if 0 <nl> + # define LOG_TAG " IMEJni " <nl> + # define LOGD ( . . . ) __android_log_print ( ANDROID_LOG_DEBUG , LOG_TAG , __VA_ARGS__ ) <nl> + # else <nl> + # define LOGD ( . . . ) <nl> + # endif <nl> + <nl> + using namespace cocos2d ; <nl> + <nl> + extern " C " <nl> + { <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / handle IME message <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + void setKeyboardStateJNI ( int bOpen ) <nl> + { <nl> + JniMethodInfo t ; <nl> + <nl> + if ( JniHelper : : getMethodInfo ( t , <nl> + " org / cocos2dx / lib / Cocos2dxGLSurfaceView " , <nl> + ( bOpen ) ? " openIMEKeyboard " : " closeIMEKeyboard " , <nl> + " ( ) V " ) ) <nl> + { <nl> + t . env - > CallStaticVoidMethod ( t . classID , t . methodID ) ; <nl> + } <nl> + } <nl> + <nl> + void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInsertText ( JNIEnv * env , jobject thiz , jstring text ) <nl> + { <nl> + jboolean isCopy = 0 ; <nl> + const char * pszText = env - > GetStringUTFChars ( text , & isCopy ) ; <nl> + if ( isCopy ) <nl> + { <nl> + cocos2d : : CCIMEDispatcher : : sharedDispatcher ( ) - > dispatchInsertText ( pszText , strlen ( pszText ) ) ; <nl> + env - > ReleaseStringUTFChars ( text , pszText ) ; <nl> + } <nl> + } <nl> + <nl> + void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeDeleteBackward ( JNIEnv * env , jobject thiz ) <nl> + { <nl> + cocos2d : : CCIMEDispatcher : : sharedDispatcher ( ) - > dispatchDeleteBackward ( ) ; <nl> + } <nl> + <nl> + jstring Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeGetContentText ( ) <nl> + { <nl> + JNIEnv * env = 0 ; <nl> + <nl> + if ( JniHelper : : getJavaVM ( ) - > GetEnv ( ( void * * ) & env , JNI_VERSION_1_4 ) ! = JNI_OK | | ! env ) <nl> + { <nl> + return 0 ; <nl> + } <nl> + const char * pszText = cocos2d : : CCIMEDispatcher : : sharedDispatcher ( ) - > getContentText ( ) ; <nl> + return env - > NewStringUTF ( pszText ) ; <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 000000000000 . . 75dfad756e65 <nl> mmm / dev / null <nl> ppp b / cocos2dx / platform / android / jni / IMEJni . h <nl> <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + Copyright ( c ) 2010 cocos2d - x . org <nl> + <nl> + http : / / www . cocos2d - x . org <nl> + <nl> + Permission is hereby granted , free of charge , to any person obtaining a copy <nl> + of this software and associated documentation files ( the " Software " ) , to deal <nl> + in the Software without restriction , including without limitation the rights <nl> + to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> + copies of the Software , and to permit persons to whom the Software is <nl> + furnished to do so , subject to the following conditions : <nl> + <nl> + The above copyright notice and this permission notice shall be included in <nl> + all copies or substantial portions of the Software . <nl> + <nl> + THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> + IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> + LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> + THE SOFTWARE . <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # ifndef __ANDROID_IME_JNI_H__ <nl> + # define __ANDROID_IME_JNI_H__ <nl> + <nl> + extern " C " <nl> + <nl> + { <nl> + extern void setKeyboardStateJNI ( int bOpen ) ; <nl> + } <nl> + <nl> + # endif / / __ANDROID_IME_JNI_H__ <nl> new file mode 100644 <nl> index 000000000000 . . da26eba7a787 <nl> mmm / dev / null <nl> ppp b / cocos2dx / platform / android / jni / JniHelper . cpp <nl> <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + Copyright ( c ) 2010 cocos2d - x . org <nl> + <nl> + http : / / www . cocos2d - x . org <nl> + <nl> + Permission is hereby granted , free of charge , to any person obtaining a copy <nl> + of this software and associated documentation files ( the " Software " ) , to deal <nl> + in the Software without restriction , including without limitation the rights <nl> + to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> + copies of the Software , and to permit persons to whom the Software is <nl> + furnished to do so , subject to the following conditions : <nl> + <nl> + The above copyright notice and this permission notice shall be included in <nl> + all copies or substantial portions of the Software . <nl> + <nl> + THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> + IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> + LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> + THE SOFTWARE . <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # include " JniHelper . h " <nl> + # include < android / log . h > <nl> + # include < string . h > <nl> + <nl> + # if 1 <nl> + # define LOG_TAG " JniHelper " <nl> + # define LOGD ( . . . ) __android_log_print ( ANDROID_LOG_DEBUG , LOG_TAG , __VA_ARGS__ ) <nl> + # else <nl> + # define LOGD ( . . . ) <nl> + # endif <nl> + <nl> + # define JAVAVM cocos2d : : JniHelper : : getJavaVM ( ) <nl> + <nl> + extern " C " <nl> + { <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / java vm helper function <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + jint JNI_OnLoad ( JavaVM * vm , void * reserved ) <nl> + { <nl> + cocos2d : : JniHelper : : setJavaVM ( vm ) ; <nl> + return JNI_VERSION_1_4 ; <nl> + } <nl> + <nl> + static bool getEnv ( JNIEnv * * env ) <nl> + { <nl> + bool bRet = false ; <nl> + <nl> + do <nl> + { <nl> + if ( JAVAVM - > GetEnv ( ( void * * ) env , JNI_VERSION_1_4 ) ! = JNI_OK ) <nl> + { <nl> + LOGD ( " Failed to get the environment using GetEnv ( ) " ) ; <nl> + break ; <nl> + } <nl> + <nl> + if ( JAVAVM - > AttachCurrentThread ( env , 0 ) < 0 ) <nl> + { <nl> + LOGD ( " Failed to get the environment using AttachCurrentThread ( ) " ) ; <nl> + break ; <nl> + } <nl> + <nl> + bRet = true ; <nl> + } while ( 0 ) ; <nl> + <nl> + return bRet ; <nl> + } <nl> + <nl> + static jclass getClassID_ ( const char * className , JNIEnv * env ) <nl> + { <nl> + JNIEnv * pEnv = env ; <nl> + jclass ret = 0 ; <nl> + <nl> + do <nl> + { <nl> + if ( ! pEnv ) <nl> + { <nl> + if ( ! getEnv ( & pEnv ) ) <nl> + { <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + ret = pEnv - > FindClass ( className ) ; <nl> + if ( ! ret ) <nl> + { <nl> + LOGD ( " Failed to find class of % s " , className ) ; <nl> + break ; <nl> + } <nl> + } while ( 0 ) ; <nl> + <nl> + return ret ; <nl> + } <nl> + <nl> + static bool getStaticMethodInfo_ ( cocos2d : : JniMethodInfo & methodinfo , const char * className , const char * methodName , const char * paramCode ) <nl> + { <nl> + jmethodID methodID = 0 ; <nl> + JNIEnv * pEnv = 0 ; <nl> + bool bRet = false ; <nl> + <nl> + do <nl> + { <nl> + if ( ! getEnv ( & pEnv ) ) <nl> + { <nl> + break ; <nl> + } <nl> + <nl> + jclass classID = getClassID_ ( className , pEnv ) ; <nl> + <nl> + methodID = pEnv - > GetStaticMethodID ( classID , methodName , paramCode ) ; <nl> + if ( ! methodID ) <nl> + { <nl> + LOGD ( " Failed to find static method id of % s " , methodName ) ; <nl> + break ; <nl> + } <nl> + <nl> + methodinfo . classID = classID ; <nl> + methodinfo . env = pEnv ; <nl> + methodinfo . methodID = methodID ; <nl> + <nl> + bRet = true ; <nl> + } while ( 0 ) ; <nl> + <nl> + return bRet ; <nl> + } <nl> + <nl> + static bool getMethodInfo_ ( cocos2d : : JniMethodInfo & methodinfo , const char * className , const char * methodName , const char * paramCode ) <nl> + { <nl> + jmethodID methodID = 0 ; <nl> + JNIEnv * pEnv = 0 ; <nl> + bool bRet = false ; <nl> + <nl> + do <nl> + { <nl> + if ( ! getEnv ( & pEnv ) ) <nl> + { <nl> + break ; <nl> + } <nl> + <nl> + jclass classID = getClassID_ ( className , pEnv ) ; <nl> + <nl> + methodID = pEnv - > GetMethodID ( classID , methodName , paramCode ) ; <nl> + if ( ! methodID ) <nl> + { <nl> + LOGD ( " Failed to find method id of % s " , methodName ) ; <nl> + break ; <nl> + } <nl> + <nl> + methodinfo . classID = classID ; <nl> + methodinfo . env = pEnv ; <nl> + methodinfo . methodID = methodID ; <nl> + <nl> + bRet = true ; <nl> + } while ( 0 ) ; <nl> + <nl> + return bRet ; <nl> + } <nl> + <nl> + static char * jstringToChar_ ( jstring jstr ) <nl> + { <nl> + char * rtn = 0 ; <nl> + JNIEnv * env = 0 ; <nl> + <nl> + if ( ! getEnv ( & env ) ) <nl> + { <nl> + return 0 ; <nl> + } <nl> + <nl> + / / convert jstring to byte array <nl> + jclass clsstring = env - > FindClass ( " java / lang / String " ) ; <nl> + jstring strencode = env - > NewStringUTF ( " utf - 8 " ) ; <nl> + jmethodID mid = env - > GetMethodID ( clsstring , " getBytes " , " ( Ljava / lang / String ; ) [ B " ) ; <nl> + jbyteArray barr = ( jbyteArray ) env - > CallObjectMethod ( jstr , mid , strencode ) ; <nl> + jsize alen = env - > GetArrayLength ( barr ) ; <nl> + jbyte * ba = env - > GetByteArrayElements ( barr , JNI_FALSE ) ; <nl> + <nl> + / / copy byte array into char [ ] <nl> + if ( alen > 0 ) <nl> + { <nl> + rtn = new char [ alen + 1 ] ; <nl> + memcpy ( rtn , ba , alen ) ; <nl> + rtn [ alen ] = 0 ; <nl> + } <nl> + env - > ReleaseByteArrayElements ( barr , ba , 0 ) ; <nl> + <nl> + return rtn ; <nl> + } <nl> + } <nl> + <nl> + namespace cocos2d { <nl> + <nl> + JavaVM * JniHelper : : m_psJavaVM = NULL ; <nl> + <nl> + JavaVM * JniHelper : : getJavaVM ( ) <nl> + { <nl> + return m_psJavaVM ; <nl> + } <nl> + <nl> + void JniHelper : : setJavaVM ( JavaVM * javaVM ) <nl> + { <nl> + m_psJavaVM = javaVM ; <nl> + } <nl> + <nl> + jclass JniHelper : : getClassID ( const char * className , JNIEnv * env ) <nl> + { <nl> + return getClassID_ ( className , env ) ; <nl> + } <nl> + <nl> + bool JniHelper : : getStaticMethodInfo ( JniMethodInfo & methodinfo , const char * className , const char * methodName , const char * paramCode ) <nl> + { <nl> + return getStaticMethodInfo_ ( methodinfo , className , methodName , paramCode ) ; <nl> + } <nl> + <nl> + bool JniHelper : : getMethodInfo ( JniMethodInfo & methodinfo , const char * className , const char * methodName , const char * paramCode ) <nl> + { <nl> + return getMethodInfo_ ( methodinfo , className , methodName , paramCode ) ; <nl> + } <nl> + <nl> + char * JniHelper : : jstringToChar ( jstring str ) <nl> + { <nl> + return jstringToChar_ ( str ) ; <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 000000000000 . . cc49571c4473 <nl> mmm / dev / null <nl> ppp b / cocos2dx / platform / android / jni / JniHelper . h <nl> <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + Copyright ( c ) 2010 - 2011 cocos2d - x . org <nl> + <nl> + http : / / www . cocos2d - x . org <nl> + <nl> + Permission is hereby granted , free of charge , to any person obtaining a copy <nl> + of this software and associated documentation files ( the " Software " ) , to deal <nl> + in the Software without restriction , including without limitation the rights <nl> + to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> + copies of the Software , and to permit persons to whom the Software is <nl> + furnished to do so , subject to the following conditions : <nl> + <nl> + The above copyright notice and this permission notice shall be included in <nl> + all copies or substantial portions of the Software . <nl> + <nl> + THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> + IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> + LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> + THE SOFTWARE . <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # ifndef __ANDROID_JNI_HELPER_H__ <nl> + # define __ANDROID_JNI_HELPER_H__ <nl> + <nl> + # include < jni . h > <nl> + # include " CCPlatformMacros . h " <nl> + <nl> + namespace cocos2d { <nl> + <nl> + typedef struct JniMethodInfo_ <nl> + { <nl> + JNIEnv * env ; <nl> + jclass classID ; <nl> + jmethodID methodID ; <nl> + } JniMethodInfo ; <nl> + <nl> + class CC_DLL JniHelper <nl> + { <nl> + public : <nl> + static JavaVM * getJavaVM ( ) ; <nl> + static void setJavaVM ( JavaVM * javaVM ) ; <nl> + static jclass getClassID ( const char * className , JNIEnv * env = 0 ) ; <nl> + static bool getStaticMethodInfo ( JniMethodInfo & methodinfo , const char * className , const char * methodName , const char * paramCode ) ; <nl> + static bool getMethodInfo ( JniMethodInfo & methodinfo , const char * className , const char * methodName , const char * paramCode ) ; <nl> + static char * jstringToChar ( jstring str ) ; <nl> + <nl> + private : <nl> + static JavaVM * m_psJavaVM ; <nl> + } ; <nl> + } <nl> + <nl> + # endif / / __ANDROID_JNI_HELPER_H__ <nl> new file mode 100644 <nl> index 000000000000 . . b77a5ff1e84b <nl> mmm / dev / null <nl> ppp b / cocos2dx / platform / android / jni / MessageJni . cpp <nl> <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + Copyright ( c ) 2010 cocos2d - x . org <nl> + <nl> + http : / / www . cocos2d - x . org <nl> + <nl> + Permission is hereby granted , free of charge , to any person obtaining a copy <nl> + of this software and associated documentation files ( the " Software " ) , to deal <nl> + in the Software without restriction , including without limitation the rights <nl> + to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> + copies of the Software , and to permit persons to whom the Software is <nl> + furnished to do so , subject to the following conditions : <nl> + <nl> + The above copyright notice and this permission notice shall be included in <nl> + all copies or substantial portions of the Software . <nl> + <nl> + THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> + IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> + LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> + THE SOFTWARE . <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # include " MessageJni . h " <nl> + # include " CCDirector . h " <nl> + # include " JniHelper . h " <nl> + # include " CCApplication . h " <nl> + <nl> + # include < android / log . h > <nl> + # include < jni . h > <nl> + <nl> + <nl> + # if 0 <nl> + # define LOG_TAG " MessageJni " <nl> + # define LOGD ( . . . ) __android_log_print ( ANDROID_LOG_DEBUG , LOG_TAG , __VA_ARGS__ ) <nl> + # else <nl> + # define LOGD ( . . . ) <nl> + # endif <nl> + <nl> + using namespace cocos2d ; <nl> + <nl> + extern " C " <nl> + { <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / native renderer <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeRender ( JNIEnv * env ) <nl> + { <nl> + cocos2d : : CCDirector : : sharedDirector ( ) - > mainLoop ( ) ; <nl> + } <nl> + <nl> + / / handle onPause and onResume <nl> + <nl> + void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnPause ( ) <nl> + { <nl> + CCApplication : : sharedApplication ( ) . applicationDidEnterBackground ( ) ; <nl> + } <nl> + <nl> + void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnResume ( ) <nl> + { <nl> + / / Shared OpenGL View instance doesn ' t exist yet when Activity . onResume is first called <nl> + if ( CCDirector : : sharedDirector ( ) - > getOpenGLView ( ) ) <nl> + { <nl> + CCApplication : : sharedApplication ( ) . applicationWillEnterForeground ( ) ; <nl> + } <nl> + } <nl> + <nl> + void showMessageBoxJNI ( const char * pszMsg , const char * pszTitle ) <nl> + { <nl> + if ( ! pszMsg ) <nl> + { <nl> + return ; <nl> + } <nl> + <nl> + JniMethodInfo t ; <nl> + if ( JniHelper : : getMethodInfo ( t <nl> + , " org / cocos2dx / lib / Cocos2dxActivity " <nl> + , " showMessageBox " <nl> + , " ( Ljava / lang / String ; Ljava / lang / String ; ) V " ) ) <nl> + { <nl> + jstring StringArg1 ; <nl> + <nl> + if ( ! pszTitle ) <nl> + { <nl> + StringArg1 = t . env - > NewStringUTF ( " " ) ; <nl> + } <nl> + else <nl> + { <nl> + StringArg1 = t . env - > NewStringUTF ( pszTitle ) ; <nl> + } <nl> + <nl> + jstring StringArg2 = t . env - > NewStringUTF ( pszMsg ) ; <nl> + t . env - > CallStaticVoidMethod ( t . classID , t . methodID , StringArg1 , StringArg2 ) ; <nl> + } <nl> + } <nl> + <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / terminate the process <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void terminateProcessJNI ( ) <nl> + { <nl> + JniMethodInfo t ; <nl> + <nl> + if ( JniHelper : : getMethodInfo ( t <nl> + , " org / cocos2dx / lib / Cocos2dxActivity " <nl> + , " terminateProcess " <nl> + , " ( ) V " ) ) <nl> + { <nl> + t . env - > CallStaticObjectMethod ( t . classID , t . methodID ) ; <nl> + } <nl> + } <nl> + } <nl> similarity index 77 % <nl> rename from cocos2dx / platform / android / Cocos2dJni . h <nl> rename to cocos2dx / platform / android / jni / MessageJni . h <nl> mmm a / cocos2dx / platform / android / Cocos2dJni . h <nl> ppp b / cocos2dx / platform / android / jni / MessageJni . h <nl> LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> THE SOFTWARE . <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - # ifndef __ANDROID_COCOS2D_JNI_H__ <nl> - # define __ANDROID_COCOS2D_JNI_H__ <nl> - <nl> - # include < jni . h > <nl> + # ifndef __ANDROID_MESSAGE_JNI_H__ <nl> + # define __ANDROID_MESSAGE_JNI_H__ <nl> <nl> extern " C " <nl> <nl> { <nl> - extern JavaVM * gJavaVM ; <nl> - extern void enableAccelerometerJNI ( ) ; <nl> - extern void disableAccelerometerJNI ( ) ; <nl> extern void showMessageBoxJNI ( const char * pszMsg , const char * pszTitle ) ; <nl> - extern void setKeyboardStateJNI ( int bOpen ) ; <nl> - extern char * getCurrentLanguageJNI ( ) ; <nl> - extern char * getPackageNameJNI ( ) ; <nl> extern void terminateProcessJNI ( ) ; <nl> } <nl> <nl> - # endif / / __ANDROID_COCOS2D_JNI_H__ <nl> + # endif / / __ANDROID_MESSAGE_JNI_H__ <nl> new file mode 100644 <nl> index 000000000000 . . 1fe073bcd5b9 <nl> mmm / dev / null <nl> ppp b / cocos2dx / platform / android / jni / SensorJni . cpp <nl> <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + Copyright ( c ) 2010 cocos2d - x . org <nl> + <nl> + http : / / www . cocos2d - x . org <nl> + <nl> + Permission is hereby granted , free of charge , to any person obtaining a copy <nl> + of this software and associated documentation files ( the " Software " ) , to deal <nl> + in the Software without restriction , including without limitation the rights <nl> + to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> + copies of the Software , and to permit persons to whom the Software is <nl> + furnished to do so , subject to the following conditions : <nl> + <nl> + The above copyright notice and this permission notice shall be included in <nl> + all copies or substantial portions of the Software . <nl> + <nl> + THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> + IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> + LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> + THE SOFTWARE . <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # include " SensorJni . h " <nl> + # include " CCGeometry . h " <nl> + # include " CCAccelerometer . h " <nl> + # include " platform / android / CCAccelerometer_android . h " <nl> + # include " CCEGLView . h " <nl> + # include " CCFileUtils . h " <nl> + # include " JniHelper . h " <nl> + # include < android / log . h > <nl> + # include < jni . h > <nl> + <nl> + <nl> + # if 0 <nl> + # define LOG_TAG " SensorJni " <nl> + # define LOGD ( . . . ) __android_log_print ( ANDROID_LOG_DEBUG , LOG_TAG , __VA_ARGS__ ) <nl> + # else <nl> + # define LOGD ( . . . ) <nl> + # endif <nl> + <nl> + using namespace cocos2d ; <nl> + <nl> + extern " C " <nl> + { <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / handle accelerometer changes <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + void Java_org_cocos2dx_lib_Cocos2dxAccelerometer_onSensorChanged ( JNIEnv * env , jobject thiz , jfloat x , jfloat y , jfloat z , jlong timeStamp ) <nl> + { <nl> + / / We need to invert to make it compatible with iOS . <nl> + CCRect rcRect = CCEGLView : : sharedOpenGLView ( ) . getViewPort ( ) ; <nl> + float fScreenScaleFactor = CCEGLView : : sharedOpenGLView ( ) . getScreenScaleFactor ( ) ; <nl> + cocos2d : : CCAccelerometer : : sharedAccelerometer ( ) - > update ( ( x - rcRect . origin . x ) / fScreenScaleFactor , <nl> + ( y - rcRect . origin . y ) / fScreenScaleFactor , <nl> + z , <nl> + timeStamp ) ; <nl> + } <nl> + <nl> + void Java_org_cocos2dx_lib_Cocos2dxActivity_nativeSetPaths ( JNIEnv * env , jobject thiz , jstring apkPath ) <nl> + { <nl> + const char * str ; <nl> + jboolean isCopy ; <nl> + str = env - > GetStringUTFChars ( apkPath , & isCopy ) ; <nl> + if ( isCopy ) { <nl> + cocos2d : : CCFileUtils : : setResourcePath ( str ) ; <nl> + env - > ReleaseStringUTFChars ( apkPath , str ) ; <nl> + } <nl> + } <nl> + <nl> + <nl> + void enableAccelerometerJNI ( ) <nl> + { <nl> + JniMethodInfo t ; <nl> + <nl> + if ( JniHelper : : getMethodInfo ( t , <nl> + " org / cocos2dx / lib / Cocos2dxActivity " , <nl> + " enableAccelerometer " , <nl> + " ( ) V " ) ) <nl> + { <nl> + t . env - > CallStaticVoidMethod ( t . classID , t . methodID ) ; <nl> + } <nl> + } <nl> + <nl> + void disableAccelerometerJNI ( ) <nl> + { <nl> + JniMethodInfo t ; <nl> + <nl> + if ( JniHelper : : getMethodInfo ( t , <nl> + " org / cocos2dx / lib / Cocos2dxActivity " , <nl> + " disableAccelerometer " , <nl> + " ( ) V " ) ) <nl> + { <nl> + t . env - > CallStaticVoidMethod ( t . classID , t . methodID ) ; <nl> + } <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 000000000000 . . 90a85f7ff746 <nl> mmm / dev / null <nl> ppp b / cocos2dx / platform / android / jni / SensorJni . h <nl> <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + Copyright ( c ) 2010 cocos2d - x . org <nl> + <nl> + http : / / www . cocos2d - x . org <nl> + <nl> + Permission is hereby granted , free of charge , to any person obtaining a copy <nl> + of this software and associated documentation files ( the " Software " ) , to deal <nl> + in the Software without restriction , including without limitation the rights <nl> + to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> + copies of the Software , and to permit persons to whom the Software is <nl> + furnished to do so , subject to the following conditions : <nl> + <nl> + The above copyright notice and this permission notice shall be included in <nl> + all copies or substantial portions of the Software . <nl> + <nl> + THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> + IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> + LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> + THE SOFTWARE . <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # ifndef __ANDROID_SENSOR_JNI_H__ <nl> + # define __ANDROID_SENSOR_JNI_H__ <nl> + <nl> + extern " C " <nl> + <nl> + { <nl> + extern void enableAccelerometerJNI ( ) ; <nl> + extern void disableAccelerometerJNI ( ) ; <nl> + } <nl> + <nl> + # endif / / __ANDROID_SENSOR_JNI_H__ <nl> new file mode 100644 <nl> index 000000000000 . . b25b04f3a728 <nl> mmm / dev / null <nl> ppp b / cocos2dx / platform / android / jni / SystemInfoJni . cpp <nl> <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + Copyright ( c ) 2010 cocos2d - x . org <nl> + <nl> + http : / / www . cocos2d - x . org <nl> + <nl> + Permission is hereby granted , free of charge , to any person obtaining a copy <nl> + of this software and associated documentation files ( the " Software " ) , to deal <nl> + in the Software without restriction , including without limitation the rights <nl> + to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> + copies of the Software , and to permit persons to whom the Software is <nl> + furnished to do so , subject to the following conditions : <nl> + <nl> + The above copyright notice and this permission notice shall be included in <nl> + all copies or substantial portions of the Software . <nl> + <nl> + THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> + IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> + LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> + THE SOFTWARE . <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # include " SystemInfoJni . h " <nl> + # include " JniHelper . h " <nl> + <nl> + # include < android / log . h > <nl> + # include < jni . h > <nl> + <nl> + <nl> + # if 0 <nl> + # define LOG_TAG " SystemInfoJni " <nl> + # define LOGD ( . . . ) __android_log_print ( ANDROID_LOG_DEBUG , LOG_TAG , __VA_ARGS__ ) <nl> + # else <nl> + # define LOGD ( . . . ) <nl> + # endif <nl> + <nl> + using namespace cocos2d ; <nl> + <nl> + extern " C " <nl> + { <nl> + char * getPackageNameJNI ( ) <nl> + { <nl> + JniMethodInfo t ; <nl> + char * ret = 0 ; <nl> + <nl> + if ( JniHelper : : getMethodInfo ( t , <nl> + " org / cocos2dx / lib / Cocos2dxActivity " , <nl> + " getCocos2dxPackageName " , <nl> + " ( ) Ljava / lang / String ; " ) ) <nl> + { <nl> + jstring str = ( jstring ) t . env - > CallStaticObjectMethod ( t . classID , t . methodID ) ; <nl> + ret = JniHelper : : jstringToChar ( str ) ; <nl> + <nl> + LOGD ( " package name % s " , ret ) ; <nl> + } <nl> + <nl> + return ret ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / handle get current language <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + char * getCurrentLanguageJNI ( ) <nl> + { <nl> + JniMethodInfo t ; <nl> + char * ret = 0 ; <nl> + <nl> + if ( JniHelper : : getMethodInfo ( t <nl> + , " org / cocos2dx / lib / Cocos2dxActivity " <nl> + , " getCurrentLanguage " <nl> + , " ( ) Ljava / lang / String ; " ) ) <nl> + { <nl> + jstring str = ( jstring ) t . env - > CallStaticObjectMethod ( t . classID , t . methodID ) ; <nl> + ret = JniHelper : : jstringToChar ( str ) ; <nl> + <nl> + LOGD ( " language name % s " , ret ) ; <nl> + } <nl> + <nl> + return ret ; <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 000000000000 . . dfcccb67e11b <nl> mmm / dev / null <nl> ppp b / cocos2dx / platform / android / jni / SystemInfoJni . h <nl> <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + Copyright ( c ) 2010 cocos2d - x . org <nl> + <nl> + http : / / www . cocos2d - x . org <nl> + <nl> + Permission is hereby granted , free of charge , to any person obtaining a copy <nl> + of this software and associated documentation files ( the " Software " ) , to deal <nl> + in the Software without restriction , including without limitation the rights <nl> + to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> + copies of the Software , and to permit persons to whom the Software is <nl> + furnished to do so , subject to the following conditions : <nl> + <nl> + The above copyright notice and this permission notice shall be included in <nl> + all copies or substantial portions of the Software . <nl> + <nl> + THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> + IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> + LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> + THE SOFTWARE . <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # ifndef __ANDROID_SYSTEM_INFO_JNI_H__ <nl> + # define __ANDROID_SYSTEM_INFO_JNI_H__ <nl> + <nl> + # include < jni . h > <nl> + <nl> + extern " C " <nl> + <nl> + { <nl> + extern char * getCurrentLanguageJNI ( ) ; <nl> + extern char * getPackageNameJNI ( ) ; <nl> + } <nl> + <nl> + # endif / / __ANDROID_SYSTEM_INFO_JNI_H__ <nl> new file mode 100644 <nl> index 000000000000 . . ca0e0b84255a <nl> mmm / dev / null <nl> ppp b / cocos2dx / platform / android / jni / TouchesJni . cpp <nl> <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + Copyright ( c ) 2010 cocos2d - x . org <nl> + <nl> + http : / / www . cocos2d - x . org <nl> + <nl> + Permission is hereby granted , free of charge , to any person obtaining a copy <nl> + of this software and associated documentation files ( the " Software " ) , to deal <nl> + in the Software without restriction , including without limitation the rights <nl> + to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> + copies of the Software , and to permit persons to whom the Software is <nl> + furnished to do so , subject to the following conditions : <nl> + <nl> + The above copyright notice and this permission notice shall be included in <nl> + all copies or substantial portions of the Software . <nl> + <nl> + THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> + IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> + LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> + THE SOFTWARE . <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # include " CCSet . h " <nl> + # include " CCDirector . h " <nl> + # include " CCKeypadDispatcher . h " <nl> + # include " CCTouch . h " <nl> + # include " CCEGLView . h " <nl> + # include " CCTouchDispatcher . h " <nl> + <nl> + # include < android / log . h > <nl> + # include < jni . h > <nl> + <nl> + # if 0 <nl> + # define LOG_TAG " NativeTouchesJni " <nl> + # define LOGD ( . . . ) __android_log_print ( ANDROID_LOG_DEBUG , LOG_TAG , __VA_ARGS__ ) <nl> + # else <nl> + # define LOGD ( . . . ) <nl> + # endif <nl> + <nl> + using namespace cocos2d ; <nl> + <nl> + extern " C " <nl> + { <nl> + <nl> + # define MAX_TOUCHES 5 <nl> + static CCTouch * s_pTouches [ MAX_TOUCHES ] = { NULL } ; <nl> + <nl> + / / handle touch event <nl> + void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesBegin ( JNIEnv * env , jobject thiz , jint id , jfloat x , jfloat y ) <nl> + { <nl> + CCRect rcRect = CCEGLView : : sharedOpenGLView ( ) . getViewPort ( ) ; <nl> + float fScreenScaleFactor = CCEGLView : : sharedOpenGLView ( ) . getScreenScaleFactor ( ) ; <nl> + CCSet set ; <nl> + <nl> + CCTouch * pTouch = s_pTouches [ id ] ; <nl> + if ( ! pTouch ) <nl> + { <nl> + LOGD ( " Beginning touches with id : % d , x = % f , y = % f " , id , x , y ) ; <nl> + <nl> + pTouch = new CCTouch ( ) ; <nl> + pTouch - > SetTouchInfo ( 0 , ( x - rcRect . origin . x ) / fScreenScaleFactor , ( y - rcRect . origin . y ) / fScreenScaleFactor ) ; <nl> + s_pTouches [ id ] = pTouch ; <nl> + set . addObject ( pTouch ) ; <nl> + <nl> + cocos2d : : CCDirector : : sharedDirector ( ) - > getOpenGLView ( ) - > getDelegate ( ) - > touchesBegan ( & set , NULL ) ; <nl> + } <nl> + else <nl> + { <nl> + LOGD ( " Beginnig touches with id : % d error " , id ) ; <nl> + } <nl> + } <nl> + <nl> + void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesEnd ( JNIEnv * env , jobject thiz , jint id , jfloat x , jfloat y ) <nl> + { <nl> + CCRect rcRect = CCEGLView : : sharedOpenGLView ( ) . getViewPort ( ) ; <nl> + float fScreenScaleFactor = CCEGLView : : sharedOpenGLView ( ) . getScreenScaleFactor ( ) ; <nl> + CCSet set ; <nl> + <nl> + / * Add to the set to send to the director * / <nl> + CCTouch * pTouch = s_pTouches [ id ] ; <nl> + if ( pTouch ) <nl> + { <nl> + LOGD ( " Ending touches with id : % d , x = % f , y = % f " , id , x , y ) ; <nl> + <nl> + pTouch - > SetTouchInfo ( 0 , ( x - rcRect . origin . x ) / fScreenScaleFactor , ( y - rcRect . origin . y ) / fScreenScaleFactor ) ; <nl> + set . addObject ( pTouch ) ; <nl> + <nl> + / / release the object <nl> + pTouch - > release ( ) ; <nl> + s_pTouches [ id ] = NULL ; <nl> + <nl> + cocos2d : : CCDirector : : sharedDirector ( ) - > getOpenGLView ( ) - > getDelegate ( ) - > touchesEnded ( & set , NULL ) ; <nl> + } else { <nl> + LOGD ( " Ending touches with id : % d error " , id ) ; <nl> + } <nl> + } <nl> + <nl> + void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesMove ( JNIEnv * env , jobject thiz , jintArray ids , jfloatArray xs , jfloatArray ys ) <nl> + { <nl> + int size = env - > GetArrayLength ( ids ) ; <nl> + jint id [ size ] ; <nl> + jfloat x [ size ] ; <nl> + jfloat y [ size ] ; <nl> + CCRect rcRect = CCEGLView : : sharedOpenGLView ( ) . getViewPort ( ) ; <nl> + float fScreenScaleFactor = CCEGLView : : sharedOpenGLView ( ) . getScreenScaleFactor ( ) ; <nl> + CCSet set ; <nl> + <nl> + env - > GetIntArrayRegion ( ids , 0 , size , id ) ; <nl> + env - > GetFloatArrayRegion ( xs , 0 , size , x ) ; <nl> + env - > GetFloatArrayRegion ( ys , 0 , size , y ) ; <nl> + <nl> + for ( int i = 0 ; i < size ; i + + ) { <nl> + LOGD ( " Moving touches with id : % d , x = % f , y = % f " , id [ i ] , x [ i ] , y [ i ] ) ; <nl> + cocos2d : : CCTouch * pTouch = s_pTouches [ id [ i ] ] ; <nl> + if ( pTouch ) <nl> + { <nl> + pTouch - > SetTouchInfo ( 0 , ( x [ i ] - rcRect . origin . x ) / fScreenScaleFactor , <nl> + ( y [ i ] - rcRect . origin . y ) / fScreenScaleFactor ) ; <nl> + set . addObject ( pTouch ) ; <nl> + } <nl> + else <nl> + { <nl> + / / It is error , should return . <nl> + LOGD ( " Moving touches with id : % d error " , id [ i ] ) ; <nl> + return ; <nl> + } <nl> + } <nl> + <nl> + cocos2d : : CCDirector : : sharedDirector ( ) - > getOpenGLView ( ) - > getDelegate ( ) - > touchesMoved ( & set , NULL ) ; <nl> + } <nl> + <nl> + void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesCancel ( JNIEnv * env , jobject thiz , jintArray ids , jfloatArray xs , jfloatArray ys ) <nl> + { <nl> + int size = env - > GetArrayLength ( ids ) ; <nl> + jint id [ size ] ; <nl> + jfloat x [ size ] ; <nl> + jfloat y [ size ] ; <nl> + CCRect rcRect = CCEGLView : : sharedOpenGLView ( ) . getViewPort ( ) ; <nl> + float fScreenScaleFactor = CCEGLView : : sharedOpenGLView ( ) . getScreenScaleFactor ( ) ; <nl> + CCSet set ; <nl> + <nl> + env - > GetIntArrayRegion ( ids , 0 , size , id ) ; <nl> + env - > GetFloatArrayRegion ( xs , 0 , size , x ) ; <nl> + env - > GetFloatArrayRegion ( ys , 0 , size , y ) ; <nl> + <nl> + for ( int i = 0 ; i < size ; i + + ) { <nl> + cocos2d : : CCTouch * pTouch = s_pTouches [ id [ i ] ] ; <nl> + if ( pTouch ) <nl> + { <nl> + pTouch - > SetTouchInfo ( 0 , ( x [ i ] - rcRect . origin . x ) / fScreenScaleFactor , <nl> + ( y [ i ] - rcRect . origin . y ) / fScreenScaleFactor ) ; <nl> + set . addObject ( pTouch ) ; <nl> + s_pTouches [ id [ i ] ] = NULL ; <nl> + pTouch - > release ( ) ; <nl> + } <nl> + } <nl> + <nl> + cocos2d : : CCDirector : : sharedDirector ( ) - > getOpenGLView ( ) - > getDelegate ( ) - > touchesCancelled ( & set , NULL ) ; <nl> + } <nl> + <nl> + # define KEYCODE_BACK 0x04 <nl> + # define KEYCODE_MENU 0x52 <nl> + <nl> + / / handle keydown event <nl> + <nl> + jboolean Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeKeyDown ( JNIEnv * env , jobject thiz , jint keyCode ) <nl> + { <nl> + switch ( keyCode ) <nl> + { <nl> + case KEYCODE_BACK : <nl> + if ( CCKeypadDispatcher : : sharedDispatcher ( ) - > dispatchKeypadMSG ( kTypeBackClicked ) ) <nl> + return JNI_TRUE ; <nl> + break ; <nl> + case KEYCODE_MENU : <nl> + if ( CCKeypadDispatcher : : sharedDispatcher ( ) - > dispatchKeypadMSG ( kTypeMenuClicked ) ) <nl> + return JNI_TRUE ; <nl> + break ; <nl> + default : <nl> + return JNI_FALSE ; <nl> + } <nl> + return JNI_FALSE ; <nl> + } <nl> + } <nl> mmm a / tests / test . android / src / org / cocos2dx / lib / Cocos2dxBitmap . java <nl> ppp b / tests / test . android / src / org / cocos2dx / lib / Cocos2dxBitmap . java <nl> <nl> public static void createTextBitmap ( String content , String fontName , <nl> int fontSize , int alignment , int width , int height ) { <nl> <nl> - / / Avoid error when content is " " <nl> - if ( content . compareTo ( " " ) = = 0 ) { <nl> - content = " " ; <nl> - } <nl> - <nl> + content = refactorString ( content ) ; <nl> Paint paint = newPaint ( fontName , fontSize , alignment ) ; <nl> <nl> TextProperty textProperty = getTextWidthAndHeight ( content , paint , width , height ) ; <nl> private static Paint newPaint ( String fontName , int fontSize , int alignment ) { <nl> return paint ; <nl> } <nl> <nl> + private static String refactorString ( String str ) { <nl> + / / Avoid error when content is " " <nl> + if ( str . compareTo ( " " ) = = 0 ) { <nl> + return " " ; <nl> + } <nl> + <nl> + / * <nl> + * If the font of " \ n " is " " or " \ n " , insert " " in front of it . <nl> + * <nl> + * For example : <nl> + * " \ nabc " - > " \ nabc " <nl> + * " \ nabc \ n \ n " - > " \ nabc \ n \ n " <nl> + * / <nl> + StringBuilder strBuilder = new StringBuilder ( str ) ; <nl> + int start = 0 ; <nl> + int index = strBuilder . indexOf ( " \ n " ) ; <nl> + while ( index ! = - 1 ) { <nl> + if ( index = = 0 | | strBuilder . charAt ( index - 1 ) = = ' \ n ' ) { <nl> + strBuilder . insert ( start , " " ) ; <nl> + start = index + 2 ; <nl> + } else { <nl> + start = index + 1 ; <nl> + } <nl> + <nl> + if ( start > strBuilder . length ( ) | | index = = strBuilder . length ( ) ) { <nl> + break ; <nl> + } <nl> + <nl> + index = strBuilder . indexOf ( " \ n " , start ) ; <nl> + } <nl> + <nl> + return strBuilder . toString ( ) ; <nl> + } <nl> + <nl> private static void initNativeObject ( Bitmap bitmap ) { <nl> byte [ ] pixels = getPixels ( bitmap ) ; <nl> if ( pixels = = null ) { <nl>
|
Merge remote branch ' origin / master '
|
cocos2d/cocos2d-x
|
20bba80c73cb23617df3aade00c1ad0f192239ed
|
2011-07-25T07:02:41Z
|
mmm a / tensorflow / c / experimental / filesystem / plugins / hadoop / hadoop_filesystem . cc <nl> ppp b / tensorflow / c / experimental / filesystem / plugins / hadoop / hadoop_filesystem . cc <nl> hdfsFS Connect ( tf_hadoop_filesystem : : HadoopFile * hadoop_file , <nl> ParseHadoopPath ( path , & scheme , & namenode , & hdfs_path ) ; <nl> <nl> std : : string cacheKey ( scheme ) ; <nl> - hdfsBuilder * builder = libhdfs - > hdfsNewBuilder ( ) ; <nl> if ( scheme = = " file " ) { <nl> - libhdfs - > hdfsBuilderSetNameNode ( builder , nullptr ) ; <nl> + namenode = " " ; <nl> } else if ( scheme = = " viewfs " ) { <nl> char * defaultFS = nullptr ; <nl> libhdfs - > hdfsConfGetStr ( " fs . defaultFS " , & defaultFS ) ; <nl> hdfsFS Connect ( tf_hadoop_filesystem : : HadoopFile * hadoop_file , <nl> / / The default NameNode configuration will be used ( from the XML <nl> / / configuration files ) . See : <nl> / / https : / / github . com / tensorflow / tensorflow / blob / v1 . 0 . 0 / third_party / hadoop / hdfs . h # L259 <nl> - libhdfs - > hdfsBuilderSetNameNode ( builder , " default " ) ; <nl> + namenode = " default " ; <nl> } else if ( scheme = = " har " ) { <nl> std : : string path_har = path ; <nl> SplitArchiveNameAndPath ( & path_har , & namenode , status ) ; <nl> if ( TF_GetCode ( status ) ! = TF_OK ) return nullptr ; <nl> - libhdfs - > hdfsBuilderSetNameNode ( builder , namenode . c_str ( ) ) ; <nl> - cacheKey + = namenode ; <nl> } else { <nl> - libhdfs - > hdfsBuilderSetNameNode ( <nl> - builder , namenode . empty ( ) ? " default " : namenode . c_str ( ) ) ; <nl> - cacheKey + = namenode ; <nl> + if ( namenode . empty ( ) ) { <nl> + namenode = " default " ; <nl> + } <nl> } <nl> + cacheKey + = namenode ; <nl> + <nl> absl : : MutexLock l ( & hadoop_file - > connection_cache_lock ) ; <nl> if ( hadoop_file - > connection_cache . find ( cacheKey ) = = <nl> hadoop_file - > connection_cache . end ( ) ) { <nl> + hdfsBuilder * builder = libhdfs - > hdfsNewBuilder ( ) ; <nl> + libhdfs - > hdfsBuilderSetNameNode ( builder , namenode . empty ( ) ? <nl> + nullptr : namenode . c_str ( ) ) ; <nl> auto cacheFs = libhdfs - > hdfsBuilderConnect ( builder ) ; <nl> if ( cacheFs = = nullptr ) { <nl> TF_SetStatusFromIOError ( status , TF_NOT_FOUND , strerror ( errno ) ) ; <nl> mmm a / tensorflow / core / platform / hadoop / hadoop_file_system . cc <nl> ppp b / tensorflow / core / platform / hadoop / hadoop_file_system . cc <nl> Status HadoopFileSystem : : Connect ( StringPiece fname , hdfsFS * fs ) { <nl> string nn ( namenode ) ; <nl> <nl> string cacheKey ( scheme . data ( ) , scheme . size ( ) ) ; <nl> - hdfsBuilder * builder = libhdfs ( ) - > hdfsNewBuilder ( ) ; <nl> if ( scheme = = " file " ) { <nl> - libhdfs ( ) - > hdfsBuilderSetNameNode ( builder , nullptr ) ; <nl> + nn = " " ; <nl> } else if ( scheme = = " viewfs " ) { <nl> char * defaultFS = nullptr ; <nl> libhdfs ( ) - > hdfsConfGetStr ( " fs . defaultFS " , & defaultFS ) ; <nl> Status HadoopFileSystem : : Connect ( StringPiece fname , hdfsFS * fs ) { <nl> / / The default NameNode configuration will be used ( from the XML <nl> / / configuration files ) . See : <nl> / / https : / / github . com / tensorflow / tensorflow / blob / v1 . 0 . 0 / third_party / hadoop / hdfs . h # L259 <nl> - libhdfs ( ) - > hdfsBuilderSetNameNode ( builder , " default " ) ; <nl> + nn = " default " ; <nl> } else if ( scheme = = " har " ) { <nl> TF_RETURN_IF_ERROR ( SplitArchiveNameAndPath ( path , nn ) ) ; <nl> - libhdfs ( ) - > hdfsBuilderSetNameNode ( builder , nn . c_str ( ) ) ; <nl> - cacheKey + = nn ; <nl> } else { <nl> - libhdfs ( ) - > hdfsBuilderSetNameNode ( builder , <nl> - nn . empty ( ) ? " default " : nn . c_str ( ) ) ; <nl> - cacheKey + = nn ; <nl> + if ( nn . empty ( ) ) { <nl> + nn = " default " ; <nl> + } <nl> } <nl> + cacheKey + = nn ; <nl> { <nl> mutex_lock lock ( mu_ ) ; <nl> if ( connectionCache_ . find ( cacheKey ) = = connectionCache_ . end ( ) ) { <nl> + hdfsBuilder * builder = libhdfs ( ) - > hdfsNewBuilder ( ) ; <nl> + libhdfs ( ) - > hdfsBuilderSetNameNode ( builder , <nl> + nn . empty ( ) ? nullptr : nn . c_str ( ) ) ; <nl> hdfsFS cacheFs = libhdfs ( ) - > hdfsBuilderConnect ( builder ) ; <nl> if ( cacheFs = = nullptr ) { <nl> return errors : : NotFound ( strerror ( errno ) ) ; <nl>
|
fix hdfsNewBuilder memory leak
|
tensorflow/tensorflow
|
6a77d0e573f630409aa844ddaae21a711d72f2f8
|
2020-10-16T09:41:44Z
|
mmm a / src / flag - definitions . h <nl> ppp b / src / flag - definitions . h <nl> struct MaybeBoolFlag { <nl> # define DEFINE_MAYBE_BOOL ( nam , cmt ) \ <nl> FLAG ( MAYBE_BOOL , MaybeBoolFlag , nam , { false COMMA false } , cmt ) <nl> # define DEFINE_INT ( nam , def , cmt ) FLAG ( INT , int , nam , def , cmt ) <nl> + # define DEFINE_INTPTR ( nam , def , cmt ) FLAG ( INTPTR , intptr_t , nam , def , cmt ) <nl> # define DEFINE_FLOAT ( nam , def , cmt ) FLAG ( FLOAT , double , nam , def , cmt ) <nl> # define DEFINE_STRING ( nam , def , cmt ) FLAG ( STRING , const char * , nam , def , cmt ) <nl> # define DEFINE_ARGS ( nam , cmt ) FLAG ( ARGS , JSArguments , nam , { 0 COMMA NULL } , cmt ) <nl> DEFINE_BOOL ( enable_liveedit , true , " enable liveedit experimental feature " ) <nl> DEFINE_BOOL ( hard_abort , true , " abort by crashing " ) <nl> <nl> / / execution . cc <nl> - DEFINE_INT ( stack_size , V8_DEFAULT_STACK_SIZE_KB , <nl> - " default size of stack region v8 is allowed to use ( in kBytes ) " ) <nl> + DEFINE_INTPTR ( stack_size , V8_DEFAULT_STACK_SIZE_KB , <nl> + " default size of stack region v8 is allowed to use ( in kBytes ) " ) <nl> <nl> / / frames . cc <nl> DEFINE_INT ( max_stack_trace_source_length , 300 , <nl> DEFINE_BOOL ( always_inline_smi_code , false , <nl> " always inline smi code in non - opt code " ) <nl> <nl> / / heap . cc <nl> - DEFINE_INT ( min_semi_space_size , 0 , <nl> - " min size of a semi - space ( in MBytes ) , the new space consists of two " <nl> - " semi - spaces " ) <nl> - DEFINE_INT ( target_semi_space_size , 0 , <nl> - " target size of a semi - space ( in MBytes ) before triggering a GC " ) <nl> - DEFINE_INT ( max_semi_space_size , 0 , <nl> - " max size of a semi - space ( in MBytes ) , the new space consists of two " <nl> - " semi - spaces " ) <nl> + DEFINE_INTPTR ( min_semi_space_size , 0 , <nl> + " min size of a semi - space ( in MBytes ) , the new space consists " <nl> + " of two semi - spaces " ) <nl> + DEFINE_INTPTR ( target_semi_space_size , 0 , <nl> + " target size of a semi - space ( in MBytes ) before triggering a GC " ) <nl> + DEFINE_INTPTR ( max_semi_space_size , 0 , <nl> + " max size of a semi - space ( in MBytes ) , the new space consists " <nl> + " of two semi - spaces " ) <nl> DEFINE_INT ( semi_space_growth_factor , 2 , " factor by which to grow the new space " ) <nl> DEFINE_BOOL ( experimental_new_space_growth_heuristic , false , <nl> " Grow the new space based on the percentage of survivors instead " <nl> " of their absolute value . " ) <nl> - DEFINE_INT ( max_old_space_size , 0 , " max size of the old space ( in Mbytes ) " ) <nl> - DEFINE_INT ( initial_old_space_size , 0 , " initial old space size ( in Mbytes ) " ) <nl> - DEFINE_INT ( max_executable_size , 0 , " max size of executable memory ( in Mbytes ) " ) <nl> + DEFINE_INTPTR ( max_old_space_size , 0 , " max size of the old space ( in Mbytes ) " ) <nl> + DEFINE_INTPTR ( initial_old_space_size , 0 , " initial old space size ( in Mbytes ) " ) <nl> + DEFINE_INTPTR ( max_executable_size , 0 , <nl> + " max size of executable memory ( in Mbytes ) " ) <nl> DEFINE_BOOL ( gc_global , false , " always perform global GCs " ) <nl> DEFINE_INT ( gc_interval , - 1 , " garbage collect after < n > allocations " ) <nl> DEFINE_BOOL ( trace_gc , false , <nl> mmm a / src / flags . cc <nl> ppp b / src / flags . cc <nl> namespace { <nl> / / to the actual flag , default value , comment , etc . This is designed to be POD <nl> / / initialized as to avoid requiring static constructors . <nl> struct Flag { <nl> - enum FlagType { TYPE_BOOL , TYPE_MAYBE_BOOL , TYPE_INT , TYPE_FLOAT , <nl> - TYPE_STRING , TYPE_ARGS } ; <nl> + enum FlagType { TYPE_BOOL , TYPE_MAYBE_BOOL , TYPE_INT , TYPE_INTPTR , <nl> + TYPE_FLOAT , TYPE_STRING , TYPE_ARGS } ; <nl> <nl> FlagType type_ ; / / What type of flag , bool , int , or string . <nl> const char * name_ ; / / Name of the flag , ex " my_flag " . <nl> struct Flag { <nl> return reinterpret_cast < int * > ( valptr_ ) ; <nl> } <nl> <nl> + intptr_t * intptr_variable ( ) const { <nl> + DCHECK ( type_ = = TYPE_INTPTR ) ; <nl> + return reinterpret_cast < intptr_t * > ( valptr_ ) ; <nl> + } <nl> + <nl> double * float_variable ( ) const { <nl> DCHECK ( type_ = = TYPE_FLOAT ) ; <nl> return reinterpret_cast < double * > ( valptr_ ) ; <nl> struct Flag { <nl> return * reinterpret_cast < const int * > ( defptr_ ) ; <nl> } <nl> <nl> + int intptr_default ( ) const { <nl> + DCHECK ( type_ = = TYPE_INTPTR ) ; <nl> + return * reinterpret_cast < const intptr_t * > ( defptr_ ) ; <nl> + } <nl> + <nl> double float_default ( ) const { <nl> DCHECK ( type_ = = TYPE_FLOAT ) ; <nl> return * reinterpret_cast < const double * > ( defptr_ ) ; <nl> struct Flag { <nl> return maybe_bool_variable ( ) - > has_value = = false ; <nl> case TYPE_INT : <nl> return * int_variable ( ) = = int_default ( ) ; <nl> + case TYPE_INTPTR : <nl> + return * intptr_variable ( ) = = intptr_default ( ) ; <nl> case TYPE_FLOAT : <nl> return * float_variable ( ) = = float_default ( ) ; <nl> case TYPE_STRING : { <nl> struct Flag { <nl> case TYPE_INT : <nl> * int_variable ( ) = int_default ( ) ; <nl> break ; <nl> + case TYPE_INTPTR : <nl> + * intptr_variable ( ) = intptr_default ( ) ; <nl> + break ; <nl> case TYPE_FLOAT : <nl> * float_variable ( ) = float_default ( ) ; <nl> break ; <nl> static const char * Type2String ( Flag : : FlagType type ) { <nl> case Flag : : TYPE_BOOL : return " bool " ; <nl> case Flag : : TYPE_MAYBE_BOOL : return " maybe_bool " ; <nl> case Flag : : TYPE_INT : return " int " ; <nl> + case Flag : : TYPE_INTPTR : return " intptr_t " ; <nl> case Flag : : TYPE_FLOAT : return " float " ; <nl> case Flag : : TYPE_STRING : return " string " ; <nl> case Flag : : TYPE_ARGS : return " arguments " ; <nl> std : : ostream & operator < < ( std : : ostream & os , const Flag & flag ) { / / NOLINT <nl> case Flag : : TYPE_INT : <nl> os < < * flag . int_variable ( ) ; <nl> break ; <nl> + case Flag : : TYPE_INTPTR : <nl> + os < < * flag . intptr_variable ( ) ; <nl> + break ; <nl> case Flag : : TYPE_FLOAT : <nl> os < < * flag . float_variable ( ) ; <nl> break ; <nl> int FlagList : : SetFlagsFromCommandLine ( int * argc , <nl> case Flag : : TYPE_INT : <nl> * flag - > int_variable ( ) = strtol ( value , & endp , 10 ) ; / / NOLINT <nl> break ; <nl> + case Flag : : TYPE_INTPTR : <nl> + / / TODO ( bnoordhuis ) Use strtoll ( ) ? C + + 11 library feature <nl> + / / that may not be available everywhere yet . <nl> + * flag - > intptr_variable ( ) = strtol ( value , & endp , 10 ) ; / / NOLINT <nl> + break ; <nl> case Flag : : TYPE_FLOAT : <nl> * flag - > float_variable ( ) = strtod ( value , & endp ) ; <nl> break ; <nl>
|
Fix - - max_old_space_size = 4096 integer overflow .
|
v8/v8
|
6253aa8908c55535473ddbe1db8e5a6f5e559b73
|
2015-01-31T20:45:46Z
|
mmm a / swoole_client_coro . cc <nl> ppp b / swoole_client_coro . cc <nl> void php_swoole_client_coro_check_setting ( Socket * cli , zval * zset ) <nl> else <nl> { <nl> _open_tcp_nodelay : <nl> - if ( cli - > type = = SW_SOCK_TCP ) <nl> + if ( cli - > type = = SW_SOCK_TCP | | cli - > type = = SW_SOCK_TCP6 ) <nl> { <nl> value = 1 ; <nl> if ( setsockopt ( cli - > socket - > fd , IPPROTO_TCP , TCP_NODELAY , & value , sizeof ( value ) ) < 0 ) <nl>
|
Improve .
|
swoole/swoole-src
|
8e49b800146d587acc76a708e48f67124feed8a7
|
2018-12-17T09:31:13Z
|
mmm a / src / node / ext / call . cc <nl> ppp b / src / node / ext / call . cc <nl> NAN_METHOD ( Call : : New ) { <nl> return NanThrowTypeError ( <nl> " Call ' s third argument must be a date or a number " ) ; <nl> } <nl> + / / These arguments are at the end because they are optional <nl> + grpc_call * parent_call = NULL ; <nl> + if ( Call : : HasInstance ( args [ 4 ] ) ) { <nl> + Call * parent_obj = ObjectWrap : : Unwrap < Call > ( args [ 4 ] - > ToObject ( ) ) ; <nl> + parent_call = parent_obj - > wrapped_call ; <nl> + } else if ( ! ( args [ 4 ] - > IsUndefined ( ) | | args [ 4 ] - > IsNull ( ) ) ) { <nl> + return NanThrowTypeError ( <nl> + " Call ' s fifth argument must be another call , if provided " ) ; <nl> + } <nl> + gpr_uint32 propagate_flags = GRPC_PROPAGATE_DEFAULTS ; <nl> + if ( args [ 5 ] - > IsUint32 ( ) ) { <nl> + propagate_flags = args [ 5 ] - > Uint32Value ( ) ; <nl> + } else if ( ! ( args [ 5 ] - > IsUndefined ( ) | | args [ 5 ] - > IsNull ( ) ) ) { <nl> + return NanThrowTypeError ( <nl> + " Call ' s fifth argument must be propagate flags , if provided " ) ; <nl> + } <nl> Handle < Object > channel_object = args [ 0 ] - > ToObject ( ) ; <nl> Channel * channel = ObjectWrap : : Unwrap < Channel > ( channel_object ) ; <nl> if ( channel - > GetWrappedChannel ( ) = = NULL ) { <nl> NAN_METHOD ( Call : : New ) { <nl> if ( args [ 3 ] - > IsString ( ) ) { <nl> NanUtf8String host_override ( args [ 3 ] ) ; <nl> wrapped_call = grpc_channel_create_call ( <nl> - wrapped_channel , NULL , GRPC_PROPAGATE_DEFAULTS , <nl> + wrapped_channel , parent_call , propagate_flags , <nl> CompletionQueueAsyncWorker : : GetQueue ( ) , * method , <nl> * host_override , MillisecondsToTimespec ( deadline ) ) ; <nl> } else if ( args [ 3 ] - > IsUndefined ( ) | | args [ 3 ] - > IsNull ( ) ) { <nl> wrapped_call = grpc_channel_create_call ( <nl> - wrapped_channel , NULL , GRPC_PROPAGATE_DEFAULTS , <nl> + wrapped_channel , parent_call , propagate_flags , <nl> CompletionQueueAsyncWorker : : GetQueue ( ) , * method , <nl> NULL , MillisecondsToTimespec ( deadline ) ) ; <nl> } else { <nl> mmm a / src / node / ext / node_grpc . cc <nl> ppp b / src / node / ext / node_grpc . cc <nl> void InitOpTypeConstants ( Handle < Object > exports ) { <nl> op_type - > Set ( NanNew ( " RECV_CLOSE_ON_SERVER " ) , RECV_CLOSE_ON_SERVER ) ; <nl> } <nl> <nl> + void InitPropagateConstants ( Handle < Object > exports ) { <nl> + NanScope ( ) ; <nl> + Handle < Object > propagate = NanNew < Object > ( ) ; <nl> + exports - > Set ( NanNew ( " propagate " ) , propagate ) ; <nl> + Handle < Value > DEADLINE ( NanNew < Uint32 , uint32_t > ( GRPC_PROPAGATE_DEADLINE ) ) ; <nl> + propagate - > Set ( NanNew ( " DEADLINE " ) , DEADLINE ) ; <nl> + Handle < Value > CENSUS_STATS_CONTEXT ( <nl> + NanNew < Uint32 , uint32_t > ( GRPC_PROPAGATE_CENSUS_STATS_CONTEXT ) ) ; <nl> + propagate - > Set ( NanNew ( " CENSUS_STATS_CONTEXT " ) , CENSUS_STATS_CONTEXT ) ; <nl> + Handle < Value > CENSUS_TRACING_CONTEXT ( <nl> + NanNew < Uint32 , uint32_t > ( GRPC_PROPAGATE_CENSUS_TRACING_CONTEXT ) ) ; <nl> + propagate - > Set ( NanNew ( " CENSUS_TRACING_CONTEXT " ) , CENSUS_TRACING_CONTEXT ) ; <nl> + Handle < Value > CANCELLATION ( <nl> + NanNew < Uint32 , uint32_t > ( GRPC_PROPAGATE_CANCELLATION ) ) ; <nl> + propagate - > Set ( NanNew ( " CANCELLATION " ) , CANCELLATION ) ; <nl> + Handle < Value > DEFAULTS ( NanNew < Uint32 , uint32_t > ( GRPC_PROPAGATE_DEFAULTS ) ) ; <nl> + propagate - > Set ( NanNew ( " DEFAULTS " ) , DEFAULTS ) ; <nl> + } <nl> + <nl> void init ( Handle < Object > exports ) { <nl> NanScope ( ) ; <nl> grpc_init ( ) ; <nl> InitStatusConstants ( exports ) ; <nl> InitCallErrorConstants ( exports ) ; <nl> InitOpTypeConstants ( exports ) ; <nl> + InitPropagateConstants ( exports ) ; <nl> <nl> grpc : : node : : Call : : Init ( exports ) ; <nl> grpc : : node : : Channel : : Init ( exports ) ; <nl> mmm a / src / node / src / client . js <nl> ppp b / src / node / src / client . js <nl> ClientDuplexStream . prototype . getPeer = getPeer ; <nl> function getCall ( channel , method , options ) { <nl> var deadline ; <nl> var host ; <nl> + var parent ; <nl> + var propagate_flags ; <nl> if ( options ) { <nl> deadline = options . deadline ; <nl> host = options . host ; <nl> + parent = _ . get ( options , ' parent . call ' ) ; <nl> + propagate_flags = options . propagate_flags ; <nl> } <nl> if ( deadline = = = undefined ) { <nl> deadline = Infinity ; <nl> } <nl> - return new grpc . Call ( channel , method , deadline , host ) ; <nl> + return new grpc . Call ( channel , method , deadline , host , <nl> + parent , propagate_flags ) ; <nl> } <nl> <nl> / * * <nl> mmm a / src / node / src / server . js <nl> ppp b / src / node / src / server . js <nl> function handleUnary ( call , handler , metadata ) { <nl> } ) ; <nl> emitter . metadata = metadata ; <nl> waitForCancel ( call , emitter ) ; <nl> + emitter . call = call ; <nl> var batch = { } ; <nl> batch [ grpc . opType . RECV_MESSAGE ] = true ; <nl> call . startBatch ( batch , function ( err , result ) { <nl> mmm a / src / node / test / constant_test . js <nl> ppp b / src / node / test / constant_test . js <nl> var callErrorNames = [ <nl> ' INVALID_FLAGS ' <nl> ] ; <nl> <nl> + / * * <nl> + * List of all propagate flag names <nl> + * @ const <nl> + * @ type { Array . < string > } <nl> + * / <nl> + var propagateFlagNames = [ <nl> + ' DEADLINE ' , <nl> + ' CENSUS_STATS_CONTEXT ' , <nl> + ' CENSUS_TRACING_CONTEXT ' , <nl> + ' CANCELLATION ' <nl> + ] ; <nl> + <nl> describe ( ' constants ' , function ( ) { <nl> it ( ' should have all of the status constants ' , function ( ) { <nl> for ( var i = 0 ; i < statusNames . length ; i + + ) { <nl> describe ( ' constants ' , function ( ) { <nl> ' call error missing : ' + callErrorNames [ i ] ) ; <nl> } <nl> } ) ; <nl> + it ( ' should have all of the propagate flags ' , function ( ) { <nl> + for ( var i = 0 ; i < propagateFlagNames . length ; i + + ) { <nl> + assert ( grpc . propagate . hasOwnProperty ( propagateFlagNames [ i ] ) , <nl> + ' call error missing : ' + propagateFlagNames [ i ] ) ; <nl> + } <nl> + } ) ; <nl> } ) ; <nl> mmm a / src / node / test / surface_test . js <nl> ppp b / src / node / test / surface_test . js <nl> var mathService = math_proto . lookup ( ' math . Math ' ) ; <nl> <nl> var _ = require ( ' lodash ' ) ; <nl> <nl> + / * * <nl> + * This is used for testing functions with multiple asynchronous calls that <nl> + * can happen in different orders . This should be passed the number of async <nl> + * function invocations that can occur last , and each of those should call this <nl> + * function ' s return value <nl> + * @ param { function ( ) } done The function that should be called when a test is <nl> + * complete . <nl> + * @ param { number } count The number of calls to the resulting function if the <nl> + * test passes . <nl> + * @ return { function ( ) } The function that should be called at the end of each <nl> + * sequence of asynchronous functions . <nl> + * / <nl> + function multiDone ( done , count ) { <nl> + return function ( ) { <nl> + count - = 1 ; <nl> + if ( count < = 0 ) { <nl> + done ( ) ; <nl> + } <nl> + } ; <nl> + } <nl> + <nl> var server_insecure_creds = grpc . ServerCredentials . createInsecure ( ) ; <nl> <nl> describe ( ' File loader ' , function ( ) { <nl> describe ( ' Echo metadata ' , function ( ) { <nl> } ) ; <nl> } ) ; <nl> describe ( ' Other conditions ' , function ( ) { <nl> + var test_service ; <nl> + var Client ; <nl> var client ; <nl> var server ; <nl> var port ; <nl> before ( function ( ) { <nl> var test_proto = ProtoBuf . loadProtoFile ( __dirname + ' / test_service . proto ' ) ; <nl> - var test_service = test_proto . lookup ( ' TestService ' ) ; <nl> + test_service = test_proto . lookup ( ' TestService ' ) ; <nl> server = new grpc . Server ( ) ; <nl> server . addProtoService ( test_service , { <nl> unary : function ( call , cb ) { <nl> describe ( ' Other conditions ' , function ( ) { <nl> } <nl> } ) ; <nl> port = server . bind ( ' localhost : 0 ' , server_insecure_creds ) ; <nl> - var Client = surface_client . makeProtobufClientConstructor ( test_service ) ; <nl> + Client = surface_client . makeProtobufClientConstructor ( test_service ) ; <nl> client = new Client ( ' localhost : ' + port , grpc . Credentials . createInsecure ( ) ) ; <nl> server . start ( ) ; <nl> } ) ; <nl> describe ( ' Other conditions ' , function ( ) { <nl> } ) ; <nl> } ) ; <nl> } ) ; <nl> + describe ( ' Call propagation ' , function ( ) { <nl> + var proxy ; <nl> + var proxy_impl ; <nl> + beforeEach ( function ( ) { <nl> + proxy = new grpc . Server ( ) ; <nl> + proxy_impl = { <nl> + unary : function ( call ) { } , <nl> + clientStream : function ( stream ) { } , <nl> + serverStream : function ( stream ) { } , <nl> + bidiStream : function ( stream ) { } <nl> + } ; <nl> + } ) ; <nl> + afterEach ( function ( ) { <nl> + console . log ( ' Shutting down server ' ) ; <nl> + proxy . shutdown ( ) ; <nl> + } ) ; <nl> + describe ( ' Cancellation ' , function ( ) { <nl> + it ( ' With a unary call ' , function ( done ) { <nl> + done = multiDone ( done , 2 ) ; <nl> + proxy_impl . unary = function ( parent , callback ) { <nl> + client . unary ( parent . request , function ( err , value ) { <nl> + try { <nl> + assert ( err ) ; <nl> + assert . strictEqual ( err . code , grpc . status . CANCELLED ) ; <nl> + } finally { <nl> + callback ( err , value ) ; <nl> + done ( ) ; <nl> + } <nl> + } , null , { parent : parent } ) ; <nl> + call . cancel ( ) ; <nl> + } ; <nl> + proxy . addProtoService ( test_service , proxy_impl ) ; <nl> + var proxy_port = proxy . bind ( ' localhost : 0 ' , server_insecure_creds ) ; <nl> + proxy . start ( ) ; <nl> + var proxy_client = new Client ( ' localhost : ' + proxy_port , <nl> + grpc . Credentials . createInsecure ( ) ) ; <nl> + var call = proxy_client . unary ( { } , function ( err , value ) { <nl> + done ( ) ; <nl> + } ) ; <nl> + } ) ; <nl> + it ( ' With a client stream call ' , function ( done ) { <nl> + done = multiDone ( done , 2 ) ; <nl> + proxy_impl . clientStream = function ( parent , callback ) { <nl> + client . clientStream ( function ( err , value ) { <nl> + try { <nl> + assert ( err ) ; <nl> + assert . strictEqual ( err . code , grpc . status . CANCELLED ) ; <nl> + } finally { <nl> + callback ( err , value ) ; <nl> + done ( ) ; <nl> + } <nl> + } , null , { parent : parent } ) ; <nl> + call . cancel ( ) ; <nl> + } ; <nl> + proxy . addProtoService ( test_service , proxy_impl ) ; <nl> + var proxy_port = proxy . bind ( ' localhost : 0 ' , server_insecure_creds ) ; <nl> + proxy . start ( ) ; <nl> + var proxy_client = new Client ( ' localhost : ' + proxy_port , <nl> + grpc . Credentials . createInsecure ( ) ) ; <nl> + var call = proxy_client . clientStream ( function ( err , value ) { <nl> + done ( ) ; <nl> + } ) ; <nl> + } ) ; <nl> + it ( ' With a server stream call ' , function ( done ) { <nl> + done = multiDone ( done , 2 ) ; <nl> + proxy_impl . serverStream = function ( parent ) { <nl> + var child = client . serverStream ( parent . request , null , <nl> + { parent : parent } ) ; <nl> + child . on ( ' error ' , function ( err ) { <nl> + assert ( err ) ; <nl> + assert . strictEqual ( err . code , grpc . status . CANCELLED ) ; <nl> + done ( ) ; <nl> + } ) ; <nl> + call . cancel ( ) ; <nl> + } ; <nl> + proxy . addProtoService ( test_service , proxy_impl ) ; <nl> + var proxy_port = proxy . bind ( ' localhost : 0 ' , server_insecure_creds ) ; <nl> + proxy . start ( ) ; <nl> + var proxy_client = new Client ( ' localhost : ' + proxy_port , <nl> + grpc . Credentials . createInsecure ( ) ) ; <nl> + var call = proxy_client . serverStream ( { } ) ; <nl> + call . on ( ' error ' , function ( err ) { <nl> + done ( ) ; <nl> + } ) ; <nl> + } ) ; <nl> + it ( ' With a bidi stream call ' , function ( done ) { <nl> + done = multiDone ( done , 2 ) ; <nl> + proxy_impl . bidiStream = function ( parent ) { <nl> + var child = client . bidiStream ( null , { parent : parent } ) ; <nl> + child . on ( ' error ' , function ( err ) { <nl> + assert ( err ) ; <nl> + assert . strictEqual ( err . code , grpc . status . CANCELLED ) ; <nl> + done ( ) ; <nl> + } ) ; <nl> + call . cancel ( ) ; <nl> + } ; <nl> + proxy . addProtoService ( test_service , proxy_impl ) ; <nl> + var proxy_port = proxy . bind ( ' localhost : 0 ' , server_insecure_creds ) ; <nl> + proxy . start ( ) ; <nl> + var proxy_client = new Client ( ' localhost : ' + proxy_port , <nl> + grpc . Credentials . createInsecure ( ) ) ; <nl> + var call = proxy_client . bidiStream ( ) ; <nl> + call . on ( ' error ' , function ( err ) { <nl> + done ( ) ; <nl> + } ) ; <nl> + } ) ; <nl> + } ) ; <nl> + describe ( ' Deadline ' , function ( ) { <nl> + it . skip ( ' With a client stream call ' , function ( done ) { <nl> + done = multiDone ( done , 2 ) ; <nl> + proxy_impl . clientStream = function ( parent , callback ) { <nl> + client . clientStream ( function ( err , value ) { <nl> + try { <nl> + assert ( err ) ; <nl> + assert . strictEqual ( err . code , grpc . status . DEADLINE_EXCEEDED ) ; <nl> + } finally { <nl> + callback ( err , value ) ; <nl> + done ( ) ; <nl> + } <nl> + } , null , { parent : parent } ) ; <nl> + } ; <nl> + proxy . addProtoService ( test_service , proxy_impl ) ; <nl> + var proxy_port = proxy . bind ( ' localhost : 0 ' , server_insecure_creds ) ; <nl> + proxy . start ( ) ; <nl> + var proxy_client = new Client ( ' localhost : ' + proxy_port , <nl> + grpc . Credentials . createInsecure ( ) ) ; <nl> + var deadline = new Date ( ) ; <nl> + deadline . setSeconds ( deadline . getSeconds ( ) + 1 ) ; <nl> + var call = proxy_client . clientStream ( function ( err , value ) { <nl> + done ( ) ; <nl> + } , null , { deadline : deadline } ) ; <nl> + } ) ; <nl> + it . skip ( ' With a bidi stream call ' , function ( done ) { <nl> + done = multiDone ( done , 2 ) ; <nl> + proxy_impl . bidiStream = function ( parent ) { <nl> + var child = client . bidiStream ( null , { parent : parent } ) ; <nl> + child . on ( ' error ' , function ( err ) { <nl> + assert ( err ) ; <nl> + assert . strictEqual ( err . code , grpc . status . DEADLINE_EXCEEDED ) ; <nl> + done ( ) ; <nl> + } ) ; <nl> + } ; <nl> + proxy . addProtoService ( test_service , proxy_impl ) ; <nl> + var proxy_port = proxy . bind ( ' localhost : 0 ' , server_insecure_creds ) ; <nl> + proxy . start ( ) ; <nl> + var proxy_client = new Client ( ' localhost : ' + proxy_port , <nl> + grpc . Credentials . createInsecure ( ) ) ; <nl> + var deadline = new Date ( ) ; <nl> + deadline . setSeconds ( deadline . getSeconds ( ) + 1 ) ; <nl> + var call = proxy_client . bidiStream ( null , { deadline : deadline } ) ; <nl> + call . on ( ' error ' , function ( err ) { <nl> + done ( ) ; <nl> + } ) ; <nl> + } ) ; <nl> + } ) ; <nl> + } ) ; <nl> } ) ; <nl> describe ( ' Cancelling surface client ' , function ( ) { <nl> var client ; <nl>
|
Add parent call propagation API to Node library
|
grpc/grpc
|
99e21047587ac543e7885f07934e0cd2547ff2b1
|
2015-08-14T17:35:43Z
|
mmm a / yarn . lock <nl> ppp b / yarn . lock <nl> bcrypt - pbkdf @ ^ 1 . 0 . 0 : <nl> tweetnacl " ^ 0 . 14 . 3 " <nl> <nl> beachball @ ^ 1 . 13 . 4 : <nl> - version " 1 . 29 . 1 " <nl> - resolved " https : / / registry . yarnpkg . com / beachball / - / beachball - 1 . 29 . 1 . tgz # 6893ccf7118f9652cfdf9a46b30b4c0a1a212ad0 " <nl> - integrity sha512 - xoRLCm1P1s6SdqXQah17WMtUf6B2AjTEU1hfqX2QODK + UhSloikM4Weu9aeJcdFxvryH8PlGTc60dll1rme23g = = <nl> + version " 1 . 30 . 2 " <nl> + resolved " https : / / registry . yarnpkg . com / beachball / - / beachball - 1 . 30 . 2 . tgz # c0e645b783d74de23fea404ed220dac59aab651d " <nl> + integrity sha512 - d / 2 + T5 + vQD / 32wAQAMY7hRVyVunjD0mRCVYLPYqfxBeYHMJeQ / Irwm8u1rhhjCf94oIdoVGn2dXtWLm99RcttA = = <nl> dependencies : <nl> cosmiconfig " ^ 6 . 0 . 0 " <nl> fs - extra " ^ 8 . 0 . 1 " <nl> beachball @ ^ 1 . 13 . 4 : <nl> minimatch " ^ 3 . 0 . 4 " <nl> prompts " ~ 2 . 1 . 0 " <nl> semver " ^ 6 . 1 . 1 " <nl> + toposort " ^ 2 . 0 . 2 " <nl> yargs - parser " ^ 13 . 1 . 0 " <nl> <nl> before - after - hook @ ^ 2 . 0 . 0 : <nl> toidentifier @ 1 . 0 . 0 : <nl> resolved " https : / / registry . yarnpkg . com / toidentifier / - / toidentifier - 1 . 0 . 0 . tgz # 7e1be3470f1e77948bc43d94a3c8f4d7752ba553 " <nl> integrity sha512 - yaOH / Pk / VEhBWWTlhI + qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw = = <nl> <nl> + toposort @ ^ 2 . 0 . 2 : <nl> + version " 2 . 0 . 2 " <nl> + resolved " https : / / registry . yarnpkg . com / toposort / - / toposort - 2 . 0 . 2 . tgz # ae21768175d1559d48bef35420b2f4962f09c330 " <nl> + integrity sha1 - riF2gXXRVZ1IvvNUILL0li8JwzA = <nl> + <nl> tough - cookie @ ^ 2 . 3 . 3 , tough - cookie @ ^ 2 . 3 . 4 : <nl> version " 2 . 5 . 0 " <nl> resolved " https : / / registry . yarnpkg . com / tough - cookie / - / tough - cookie - 2 . 5 . 0 . tgz # cd9fb2a0aa1d5a12b473bd9fb96fa3dcff65ade2 " <nl>
|
Bump beachball from 1 . 29 . 1 to 1 . 30 . 2 ( )
|
microsoft/react-native-windows
|
94f2b3f49681bd84fcd2791b815a732db5a12d95
|
2020-04-21T19:08:23Z
|
mmm a / torch / utils / tensorboard / summary . py <nl> ppp b / torch / utils / tensorboard / summary . py <nl> def hparams ( hparam_dict = None , metric_dict = None ) : <nl> <nl> ssi = SessionStartInfo ( ) <nl> for k , v in hparam_dict . items ( ) : <nl> + if v is None : <nl> + continue <nl> if isinstance ( v , int ) or isinstance ( v , float ) : <nl> ssi . hparams [ k ] . number_value = v <nl> continue <nl> mmm a / torch / utils / tensorboard / writer . py <nl> ppp b / torch / utils / tensorboard / writer . py <nl> def add_hparams ( self , hparam_dict = None , metric_dict = None ) : <nl> Args : <nl> hparam_dict ( dict ) : Each key - value pair in the dictionary is the <nl> name of the hyper parameter and it ' s corresponding value . <nl> + The type of the value can be one of ` bool ` , ` string ` , ` float ` , <nl> + ` int ` , or ` None ` . <nl> metric_dict ( dict ) : Each key - value pair in the dictionary is the <nl> name of the metric and it ' s corresponding value . Note that the key used <nl> here should be unique in the tensorboard record . Otherwise the value <nl>
|
[ TensorBoard ] fix ( )
|
pytorch/pytorch
|
c49de6ce0d0fb86ecc6d33b01dbd7efed5d434f8
|
2020-04-14T00:44:09Z
|
mmm a / tensorflow / c / experimental / filesystem / plugins / hadoop / hadoop_filesystem . cc <nl> ppp b / tensorflow / c / experimental / filesystem / plugins / hadoop / hadoop_filesystem . cc <nl> void Stat ( const TF_Filesystem * filesystem , const char * path , <nl> TF_SetStatus ( status , TF_OK , " " ) ; <nl> } <nl> <nl> + int64_t GetFileSize ( const TF_Filesystem * filesystem , const char * path , <nl> + TF_Status * status ) { <nl> + auto libhdfs = static_cast < LibHDFS * > ( filesystem - > plugin_filesystem ) ; <nl> + auto fs = Connect ( libhdfs , path , status ) ; <nl> + if ( TF_GetCode ( status ) ! = TF_OK ) return - 1 ; <nl> + <nl> + std : : string scheme , namenode , hdfs_path ; <nl> + ParseHadoopPath ( path , & scheme , & namenode , & hdfs_path ) ; <nl> + <nl> + auto info = libhdfs - > hdfsGetPathInfo ( fs , hdfs_path . c_str ( ) ) ; <nl> + if ( info = = nullptr ) { <nl> + TF_SetStatusFromIOError ( status , errno , path ) ; <nl> + return - 1 ; <nl> + } <nl> + <nl> + TF_SetStatus ( status , TF_OK , " " ) ; <nl> + auto size = static_cast < int64_t > ( info - > mSize ) ; <nl> + libhdfs - > hdfsFreeFileInfo ( info , 1 ) ; <nl> + return size ; <nl> + } <nl> + <nl> / / TODO ( vnvo2409 ) : Implement later <nl> <nl> } / / namespace tf_hadoop_filesystem <nl>
|
Add GetFileSize
|
tensorflow/tensorflow
|
9fee1f54b2ce504cbdc31d5f2958a6277cadb3c0
|
2020-08-04T09:29:39Z
|
mmm a / tensorflow / compiler / mlir / lite / BUILD <nl> ppp b / tensorflow / compiler / mlir / lite / BUILD <nl> cc_library ( <nl> deps = [ <nl> " : tensorflow_lite_ops_inc_gen " , <nl> " : validators " , <nl> + " / / tensorflow / compiler / mlir / tensorflow " , <nl> " / / tensorflow / compiler / mlir / tensorflow : tensorflow_types " , <nl> " / / tensorflow / lite / schema : schema_fbs " , <nl> " @ llvm - project / / llvm : support " , <nl> cc_library ( <nl> cc_library ( <nl> name = " flatbuffer_translate_lib " , <nl> srcs = [ <nl> - " flatbuffer_export . cc " , <nl> " flatbuffer_import . cc " , <nl> + " flatbuffer_translate . cc " , <nl> " utils / convert_type . cc " , <nl> ] , <nl> hdrs = [ <nl> - " flatbuffer_export . h " , <nl> - " flatbuffer_export_flags . h " , <nl> " flatbuffer_import . h " , <nl> + " flatbuffer_translate . h " , <nl> + " flatbuffer_translate_flags . h " , <nl> " utils / convert_type . h " , <nl> ] , <nl> deps = [ <nl> cc_library ( <nl> " / / tensorflow / compiler / mlir / tensorflow : tensorflow_types " , <nl> " / / tensorflow / compiler / xla : statusor " , <nl> " / / tensorflow / core : framework " , <nl> + " / / tensorflow / core : lib " , <nl> " / / tensorflow / core : protos_all_cc " , <nl> - " / / tensorflow / core / platform : errors " , <nl> - " / / tensorflow / core / platform : logging " , <nl> - " / / tensorflow / core / platform : status " , <nl> " / / tensorflow / lite : framework " , <nl> " / / tensorflow / lite : schema_fbs_version " , <nl> " / / tensorflow / lite : string_util " , <nl> cc_library ( <nl> " @ llvm - project / / mlir : Support " , <nl> " @ llvm - project / / mlir : Translation " , <nl> ] , <nl> - ) <nl> - <nl> - cc_library ( <nl> - name = " flatbuffer_translate_registeration " , <nl> - srcs = [ <nl> - " flatbuffer_translate . cc " , <nl> - ] , <nl> - deps = [ <nl> - " : flatbuffer_translate_lib " , <nl> - " / / tensorflow / compiler / mlir / tensorflow : mlir_roundtrip_flags " , <nl> - " @ llvm - project / / llvm : support " , <nl> - " @ llvm - project / / mlir : IR " , <nl> - " @ llvm - project / / mlir : LoopOpsTransforms " , <nl> - " @ llvm - project / / mlir : MlirTranslateMain " , <nl> - " @ llvm - project / / mlir : QuantOps " , <nl> - " @ llvm - project / / mlir : StandardOps " , <nl> - " @ llvm - project / / mlir : Support " , <nl> - " @ llvm - project / / mlir : Translation " , <nl> - ] , <nl> alwayslink = 1 , <nl> ) <nl> <nl> tf_cc_binary ( <nl> name = " flatbuffer_translate " , <nl> deps = [ <nl> - " : flatbuffer_translate_registeration " , <nl> + " : flatbuffer_translate_lib " , <nl> + " @ llvm - project / / mlir : LoopOpsTransforms " , <nl> + " @ llvm - project / / mlir : MlirTranslateMain " , <nl> ] , <nl> ) <nl> <nl> filegroup ( <nl> <nl> tf_cc_binary ( <nl> name = " tf_tfl_translate " , <nl> - srcs = [ <nl> - " : tf_tfl_translate_main " , <nl> - ] , <nl> + srcs = [ " : tf_tfl_translate_main " ] , <nl> deps = [ <nl> " : common " , <nl> " : flatbuffer_translate_lib " , <nl> - " : flatbuffer_translate_registeration " , <nl> " : tensorflow_lite " , <nl> " : tf_tfl_passes " , <nl> " : tf_tfl_translate_cl_options " , <nl> tf_cc_binary ( <nl> <nl> tf_cc_binary ( <nl> name = " mlir - tflite - runner " , <nl> - srcs = [ <nl> - " mlir_tflite_runner . cc " , <nl> - ] , <nl> + srcs = [ " mlir_tflite_runner . cc " ] , <nl> deps = [ <nl> " : flatbuffer_translate_lib " , <nl> - " : flatbuffer_translate_registeration " , <nl> - " / / tensorflow / compiler / mlir / tensorflow : mlir_roundtrip_flags " , <nl> " / / tensorflow / core : lib " , <nl> " / / tensorflow / core / platform : logging " , <nl> " / / tensorflow / lite : framework " , <nl> " / / tensorflow / lite / delegates / flex : delegate " , <nl> " / / tensorflow / lite / kernels : builtin_ops " , <nl> + " @ com_google_absl / / absl / base : core_headers " , <nl> " @ com_google_absl / / absl / strings " , <nl> " @ llvm - project / / llvm : support " , <nl> " @ llvm - project / / mlir : IR " , <nl> deleted file mode 100644 <nl> index 72e9b8c742afb . . 0000000000000 <nl> mmm a / tensorflow / compiler / mlir / lite / flatbuffer_export . cc <nl> ppp / dev / null <nl> <nl> - / * Copyright 2019 The TensorFlow Authors . All Rights Reserved . <nl> - <nl> - Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> - you may not use this file except in compliance with the License . <nl> - You may obtain a copy of the License at <nl> - <nl> - http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> - <nl> - Unless required by applicable law or agreed to in writing , software <nl> - distributed under the License is distributed on an " AS IS " BASIS , <nl> - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> - See the License for the specific language governing permissions and <nl> - limitations under the License . <nl> - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> - <nl> - # include " tensorflow / compiler / mlir / lite / flatbuffer_export . h " <nl> - <nl> - # include < stddef . h > <nl> - # include < stdlib . h > <nl> - <nl> - # include < cstdint > <nl> - # include < memory > <nl> - # include < string > <nl> - # include < utility > <nl> - # include < vector > <nl> - <nl> - # include " absl / base / attributes . h " <nl> - # include " absl / container / flat_hash_map . h " <nl> - # include " absl / container / flat_hash_set . h " <nl> - # include " absl / strings / match . h " <nl> - # include " absl / strings / str_cat . h " <nl> - # include " absl / strings / str_join . h " <nl> - # include " absl / strings / string_view . h " <nl> - # include " flatbuffers / flatbuffers . h " / / TF : flatbuffers <nl> - # include " flatbuffers / flexbuffers . h " / / TF : flatbuffers <nl> - # include " llvm / ADT / ArrayRef . h " <nl> - # include " llvm / ADT / DenseMap . h " <nl> - # include " llvm / ADT / None . h " <nl> - # include " llvm / ADT / Optional . h " <nl> - # include " llvm / ADT / StringRef . h " <nl> - # include " llvm / Support / CommandLine . h " <nl> - # include " llvm / Support / FormatVariadic . h " <nl> - # include " llvm / Support / ToolOutputFile . h " <nl> - # include " llvm / Support / raw_ostream . h " <nl> - # include " mlir / Dialect / Quant / QuantTypes . h " / / TF : llvm - project <nl> - # include " mlir / Dialect / StandardOps / IR / Ops . h " / / TF : llvm - project <nl> - # include " mlir / IR / Attributes . h " / / TF : llvm - project <nl> - # include " mlir / IR / Builders . h " / / TF : llvm - project <nl> - # include " mlir / IR / Function . h " / / TF : llvm - project <nl> - # include " mlir / IR / Location . h " / / TF : llvm - project <nl> - # include " mlir / IR / MLIRContext . h " / / TF : llvm - project <nl> - # include " mlir / IR / Module . h " / / TF : llvm - project <nl> - # include " mlir / IR / Operation . h " / / TF : llvm - project <nl> - # include " mlir / IR / StandardTypes . h " / / TF : llvm - project <nl> - # include " mlir / IR / Types . h " / / TF : llvm - project <nl> - # include " mlir / IR / Value . h " / / TF : llvm - project <nl> - # include " mlir / Support / LogicalResult . h " / / TF : llvm - project <nl> - # include " mlir / Translation . h " / / TF : llvm - project <nl> - # include " tensorflow / compiler / mlir / lite / flatbuffer_operator . h " <nl> - # include " tensorflow / compiler / mlir / lite / ir / tfl_ops . h " <nl> - # include " tensorflow / compiler / mlir / lite / utils / convert_type . h " <nl> - # include " tensorflow / compiler / mlir / lite / utils / stateful_ops_utils . h " <nl> - # include " tensorflow / compiler / mlir / op_or_arg_name_mapper . h " <nl> - # include " tensorflow / compiler / mlir / tensorflow / ir / tf_ops . h " <nl> - # include " tensorflow / compiler / mlir / tensorflow / ir / tf_types . h " <nl> - # include " tensorflow / compiler / mlir / tensorflow / translate / export_tf_dialect_op . h " <nl> - # include " tensorflow / compiler / mlir / tensorflow / utils / convert_tensor . h " <nl> - # include " tensorflow / compiler / xla / statusor . h " <nl> - # include " tensorflow / core / framework / attr_value . pb . h " <nl> - # include " tensorflow / core / framework / node_def . pb . h " <nl> - # include " tensorflow / core / framework / tensor . h " <nl> - # include " tensorflow / core / platform / errors . h " <nl> - # include " tensorflow / core / platform / status . h " <nl> - # include " tensorflow / core / platform / logging . h " <nl> - # include " tensorflow / lite / delegates / flex / whitelisted_flex_ops . h " <nl> - # include " tensorflow / lite / kernels / internal / kernel_utils . h " <nl> - # include " tensorflow / lite / schema / schema_generated . h " <nl> - # include " tensorflow / lite / string_util . h " <nl> - # include " tensorflow / lite / tools / versioning / op_version . h " <nl> - # include " tensorflow / lite / tools / versioning / runtime_version . h " <nl> - # include " tensorflow / lite / version . h " <nl> - <nl> - using llvm : : dyn_cast ; <nl> - using llvm : : formatv ; <nl> - using llvm : : isa ; <nl> - using llvm : : Optional ; <nl> - using llvm : : StringRef ; <nl> - using llvm : : Twine ; <nl> - using mlir : : Dialect ; <nl> - using mlir : : ElementsAttr ; <nl> - using mlir : : FuncOp ; <nl> - using mlir : : MLIRContext ; <nl> - using mlir : : ModuleOp ; <nl> - using mlir : : NoneType ; <nl> - using mlir : : Operation ; <nl> - using mlir : : Region ; <nl> - using mlir : : StringAttr ; <nl> - using mlir : : TensorType ; <nl> - using mlir : : Type ; <nl> - using mlir : : UnknownLoc ; <nl> - using mlir : : Value ; <nl> - using tensorflow : : OpOrArgLocNameMapper ; <nl> - using tensorflow : : OpOrArgNameMapper ; <nl> - using tensorflow : : Status ; <nl> - using tflite : : flex : : IsWhitelistedFlexOp ; <nl> - using xla : : StatusOr ; <nl> - <nl> - template < typename T > <nl> - using BufferOffset = flatbuffers : : Offset < T > ; <nl> - <nl> - template < typename T > <nl> - using VectorBufferOffset = flatbuffers : : Offset < flatbuffers : : Vector < T > > ; <nl> - <nl> - using CustomOptionsOffset = VectorBufferOffset < uint8_t > ; <nl> - <nl> - namespace error = tensorflow : : error ; <nl> - namespace tfl = mlir : : TFL ; <nl> - <nl> - ABSL_CONST_INIT const absl : : string_view kFlexOpNamePrefix = " Flex " ; <nl> - <nl> - / / Use initial buffer size in flatbuffer builder to be same as the initial size <nl> - / / used by the TOCO export . ( It does not explain rationale for this choice . ) <nl> - constexpr size_t kInitialBufferSize = 10240 ; <nl> - <nl> - / / Set ` isSigned ` to false if the ` type ` is an 8 - bit unsigned integer type . <nl> - / / Since tflite doesn ' t support unsigned for other types , returns error if <nl> - / / ` isSigned ` is set to false for other types . <nl> - static StatusOr < tflite : : TensorType > GetTFLiteType ( Type type , <nl> - bool is_signed = true ) { <nl> - if ( ! is_signed & & type . isSignlessInteger ( 8 ) ) { <nl> - return tflite : : TensorType_UINT8 ; <nl> - } <nl> - if ( ! is_signed ) { <nl> - return Status ( error : : INVALID_ARGUMENT , <nl> - " ' isSigned ' can only be set for 8 - bits integer type " ) ; <nl> - } <nl> - switch ( type . getKind ( ) ) { <nl> - case mlir : : StandardTypes : : F32 : <nl> - return tflite : : TensorType_FLOAT32 ; <nl> - case mlir : : StandardTypes : : F16 : <nl> - return tflite : : TensorType_FLOAT16 ; <nl> - case mlir : : TF : : TensorFlowTypes : : STRING : <nl> - return tflite : : TensorType_STRING ; <nl> - case mlir : : TF : : TensorFlowTypes : : QUINT8 : <nl> - return tflite : : TensorType_UINT8 ; <nl> - case mlir : : StandardTypes : : Complex : { <nl> - auto ftype = type . cast < mlir : : ComplexType > ( ) . getElementType ( ) ; <nl> - if ( ftype & & ftype . isF32 ( ) ) { <nl> - return tflite : : TensorType_COMPLEX64 ; <nl> - } <nl> - return Status ( error : : INVALID_ARGUMENT , " Unsupported type " ) ; <nl> - } <nl> - case mlir : : StandardTypes : : Integer : { <nl> - const auto & itype = type . cast < mlir : : IntegerType > ( ) ; <nl> - switch ( itype . getWidth ( ) ) { <nl> - case 1 : <nl> - return tflite : : TensorType_BOOL ; <nl> - case 8 : <nl> - return itype . isUnsigned ( ) ? tflite : : TensorType_UINT8 <nl> - : tflite : : TensorType_INT8 ; <nl> - case 16 : <nl> - return tflite : : TensorType_INT16 ; <nl> - case 32 : <nl> - return tflite : : TensorType_INT32 ; <nl> - case 64 : <nl> - return tflite : : TensorType_INT64 ; <nl> - } <nl> - } <nl> - case mlir : : quant : : QuantizationTypes : : UniformQuantized : { <nl> - auto qtype = type . cast < mlir : : quant : : UniformQuantizedType > ( ) ; <nl> - return GetTFLiteType ( qtype . getStorageType ( ) , qtype . isSigned ( ) ) ; <nl> - } <nl> - case mlir : : quant : : QuantizationTypes : : UniformQuantizedPerAxis : { <nl> - auto qtype = type . cast < mlir : : quant : : UniformQuantizedPerAxisType > ( ) ; <nl> - return GetTFLiteType ( qtype . getStorageType ( ) , qtype . isSigned ( ) ) ; <nl> - } <nl> - case mlir : : TF : : TensorFlowTypes : : RESOURCE : { <nl> - / / Treat tf . resource values as integer values in flatbuffer . <nl> - / / TODO ( b / 146131919 ) : Maybe need to have a detailed design for supporting <nl> - / / other resource types beyonds hash table resources and resource <nl> - / / variables . <nl> - return tflite : : TensorType_INT32 ; <nl> - } <nl> - default : <nl> - / / TFLite export fills FLOAT32 for unknown data types . Returning an error <nl> - / / for now for safety and this could be revisited when required . <nl> - return Status ( error : : INVALID_ARGUMENT , " Unsupported type " ) ; <nl> - } <nl> - } <nl> - <nl> - static bool IsConst ( Operation * op ) { <nl> - return isa < mlir : : ConstantOp > ( op ) | | isa < mlir : : TF : : ConstOp > ( op ) | | <nl> - isa < tfl : : ConstOp > ( op ) | | isa < tfl : : QConstOp > ( op ) ; <nl> - } <nl> - <nl> - template < typename T > <nl> - static bool HasValidTFLiteType ( Value value , T & error_handler ) { <nl> - / / None type is allowed to represent unspecified operands . <nl> - if ( value . getType ( ) . isa < NoneType > ( ) ) return true ; <nl> - <nl> - auto type = value . getType ( ) . dyn_cast < TensorType > ( ) ; <nl> - if ( ! type ) { <nl> - if ( auto op = value . getDefiningOp ( ) ) { <nl> - error_handler . emitError ( ) <nl> - < < ' \ ' ' < < op < < " ' should produce value of tensor type instead of " <nl> - < < value . getType ( ) ; <nl> - return false ; <nl> - } <nl> - error_handler . emitError ( " expected tensor type , got " ) < < value . getType ( ) ; <nl> - return false ; <nl> - } <nl> - <nl> - Type element_type = type . getElementType ( ) ; <nl> - auto status = GetTFLiteType ( element_type ) ; <nl> - if ( ! status . ok ( ) ) { <nl> - return error_handler . emitError ( <nl> - formatv ( " Failed to convert element type ' { 0 } ' : { 1 } " , <nl> - element_type , status . status ( ) . error_message ( ) ) ) , <nl> - false ; <nl> - } <nl> - return true ; <nl> - } <nl> - <nl> - / / Returns true if the module holds all the invariants expected by the <nl> - / / Translator class . <nl> - / / TODO ( hinsu ) : Now that translation is done by making a single pass over the <nl> - / / MLIR module , consider inlining these validation checks at the place where <nl> - / / these invariants are assumed instead of checking upfront . <nl> - static bool IsValidTFLiteMlirModule ( ModuleOp module ) { <nl> - MLIRContext * context = module . getContext ( ) ; <nl> - <nl> - / / Verify that module has a function named main . <nl> - FuncOp main_fn = module . lookupSymbol < FuncOp > ( " main " ) ; <nl> - if ( ! main_fn ) { <nl> - return emitError ( UnknownLoc : : get ( context ) , <nl> - " should have a function named ' main ' " ) , <nl> - false ; <nl> - } <nl> - <nl> - for ( auto fn : module . getOps < FuncOp > ( ) ) { <nl> - if ( fn . getBlocks ( ) . size ( ) ! = 1 ) { <nl> - return fn . emitError ( " should have exactly one basic block " ) , false ; <nl> - } <nl> - auto & bb = fn . getBlocks ( ) . front ( ) ; <nl> - <nl> - for ( auto arg : bb . getArguments ( ) ) { <nl> - if ( ! HasValidTFLiteType ( arg , fn ) ) <nl> - return fn . emitError ( " invalid TFLite type : " ) < < arg . getType ( ) , false ; <nl> - } <nl> - <nl> - / / Verify that all operations except the terminator have exactly one <nl> - / / result of type supported by TFLite . <nl> - for ( auto & inst : bb ) { <nl> - if ( inst . isKnownTerminator ( ) ) break ; <nl> - <nl> - for ( auto result : inst . getResults ( ) ) { <nl> - if ( ! HasValidTFLiteType ( result , inst ) ) <nl> - return fn . emitError ( " invalid TFLite type : " ) < < result . getType ( ) , <nl> - false ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - return true ; <nl> - } <nl> - <nl> - static std : : unique_ptr < : : tensorflow : : NodeDef > GetTensorFlowNodeDef ( <nl> - : : mlir : : Operation * inst ) { <nl> - / / We pass empty string for the original node_def name since Flex runtime <nl> - / / does not care about this being set correctly on node_def . There is no <nl> - / / " easy " ( see b / 120948529 ) way yet to get this from MLIR inst . <nl> - auto status_or_node_def = tensorflow : : ConvertTFDialectOpToNodeDef ( <nl> - inst , / * name = * / " " , / * ignore_unregistered_attrs = * / true ) ; <nl> - if ( ! status_or_node_def . ok ( ) ) { <nl> - inst - > emitOpError ( <nl> - Twine ( " failed to obtain TensorFlow nodedef with status : " + <nl> - status_or_node_def . status ( ) . ToString ( ) ) ) ; <nl> - return { } ; <nl> - } <nl> - return std : : move ( status_or_node_def . ValueOrDie ( ) ) ; <nl> - } <nl> - <nl> - / / Converts a mlir padding StringRef to TfLitePadding . <nl> - / / Returns llvm : : None if conversion fails . <nl> - static Optional < TfLitePadding > GetTflitePadding ( Operation * inst , <nl> - llvm : : StringRef padding ) { <nl> - const tflite : : Padding padding_attr = <nl> - std : : move ( llvm : : StringSwitch < tflite : : Padding > ( padding ) <nl> - . Case ( " SAME " , tflite : : Padding_SAME ) <nl> - . Case ( " VALID " , tflite : : Padding_VALID ) ) ; <nl> - if ( padding_attr = = tflite : : Padding_SAME ) { <nl> - return kTfLitePaddingSame ; <nl> - } <nl> - if ( padding_attr = = tflite : : Padding_VALID ) { <nl> - return kTfLitePaddingValid ; <nl> - } <nl> - <nl> - return inst - > emitOpError ( ) < < " Invalid padding attribute : " < < padding , <nl> - llvm : : None ; <nl> - } <nl> - <nl> - / / Extracts TfLitePoolParams from a TFL custom op . <nl> - / / Template parameter , TFLOp , should be a TFL custom op containing attributes <nl> - / / generated from TfLitePoolParams . <nl> - / / Returns llvm : : None if conversion fails . <nl> - template < typename TFLOp > <nl> - static Optional < TfLitePoolParams > GetTflitePoolParams ( Operation * inst , <nl> - TFLOp op ) { <nl> - TfLitePoolParams pool_params ; <nl> - pool_params . stride_height = op . stride_h ( ) . getSExtValue ( ) ; <nl> - pool_params . stride_width = op . stride_w ( ) . getSExtValue ( ) ; <nl> - pool_params . filter_height = op . filter_h ( ) . getSExtValue ( ) ; <nl> - pool_params . filter_width = op . filter_w ( ) . getSExtValue ( ) ; <nl> - const auto padding = GetTflitePadding ( inst , op . padding ( ) ) ; <nl> - if ( padding ) { <nl> - pool_params . padding = * padding ; <nl> - pool_params . activation = kTfLiteActNone ; <nl> - pool_params . computed . padding = TfLitePaddingValues { 0 , 0 , 0 , 0 } ; <nl> - return pool_params ; <nl> - } <nl> - <nl> - return llvm : : None ; <nl> - } <nl> - <nl> - namespace { <nl> - <nl> - / / Translates an MLIR module in TFLite dialect to TFLite FlatBuffer . <nl> - class Translator { <nl> - public : <nl> - / / Translates the given MLIR module into TFLite FlatBuffer format and returns <nl> - / / the serialized output . Returns llvm : : None on unsupported , invalid inputs or <nl> - / / internal error . <nl> - static Optional < std : : string > Translate ( <nl> - ModuleOp module , bool emit_builtin_tflite_ops , bool emit_select_tf_ops , <nl> - bool emit_custom_ops , OpOrArgNameMapper * op_or_arg_name_mapper ) ; <nl> - <nl> - private : <nl> - enum class OpType : char { kTfliteBuiltin , kSelectTf , kCustomOp } ; <nl> - explicit Translator ( ModuleOp module , bool emit_builtin_tflite_ops , <nl> - bool emit_select_tf_ops , bool emit_custom_ops , <nl> - OpOrArgNameMapper * op_or_arg_name_mapper ) <nl> - : module_ ( module ) , <nl> - name_mapper_ ( * op_or_arg_name_mapper ) , <nl> - builder_ ( kInitialBufferSize ) { <nl> - / / The first buffer must be empty according to the schema definition . <nl> - empty_buffer_ = tflite : : CreateBuffer ( builder_ ) ; <nl> - buffers_ . push_back ( empty_buffer_ ) ; <nl> - if ( emit_builtin_tflite_ops ) { <nl> - enabled_op_types_ . emplace ( OpType : : kTfliteBuiltin ) ; <nl> - } <nl> - if ( emit_select_tf_ops ) { <nl> - enabled_op_types_ . emplace ( OpType : : kSelectTf ) ; <nl> - } <nl> - if ( emit_custom_ops ) { <nl> - enabled_op_types_ . emplace ( OpType : : kCustomOp ) ; <nl> - } <nl> - tf_dialect_ = module . getContext ( ) - > getRegisteredDialect ( " tf " ) ; <nl> - tfl_dialect_ = module . getContext ( ) - > getRegisteredDialect ( " tfl " ) ; <nl> - } <nl> - <nl> - Optional < std : : string > TranslateInternal ( ) ; <nl> - <nl> - / / Returns TFLite buffer populated with constant value if the operation is <nl> - / / TFLite constant operation . Otherwise , returns an empty buffer . Emits error <nl> - / / and returns llvm : : None on failure . <nl> - Optional < BufferOffset < tflite : : Buffer > > BuildBuffer ( Operation * inst ) ; <nl> - <nl> - / / Build TFLite tensor from the given type . This function is for tfl . lstm <nl> - / / intermediates , which should have UniformQuantizedType . <nl> - Optional < BufferOffset < tflite : : Tensor > > BuildTensorFromType ( <nl> - mlir : : Type type , const std : : string & name ) ; <nl> - <nl> - / / Builds TFLite tensor from the given value . ` buffer_idx ` is index of the <nl> - / / corresponding buffer . Emits error and returns llvm : : None on failure . <nl> - Optional < BufferOffset < tflite : : Tensor > > BuildTensor ( Value value , <nl> - const std : : string & name , <nl> - unsigned buffer_idx ) ; <nl> - <nl> - / / TODO ( b / 137395003 ) : Legalize control flow ops to TFLite dialect , and remove <nl> - / / these 2 functions here . <nl> - BufferOffset < tflite : : Operator > BuildIfOperator ( <nl> - mlir : : TF : : IfOp op , const std : : vector < int32_t > & operands , <nl> - const std : : vector < int32_t > & results ) ; <nl> - BufferOffset < tflite : : Operator > BuildWhileOperator ( <nl> - mlir : : TF : : WhileOp op , const std : : vector < int32_t > & operands , <nl> - const std : : vector < int32_t > & results ) ; <nl> - <nl> - / / Build while operator where cond & body are regions . <nl> - Optional < BufferOffset < tflite : : Operator > > BuildWhileOperator ( <nl> - mlir : : TFL : : WhileOp op , const std : : vector < int32_t > & operands , <nl> - const std : : vector < int32_t > & results ) ; <nl> - <nl> - / / Builds custom operators . <nl> - / / Templated on a ) data type of custom_option to be stored into flatbuffer , <nl> - / / and b ) TFL custom op type . <nl> - template < typename CustomOptionType , typename TFLOp > <nl> - BufferOffset < tflite : : Operator > BuildCustomOperator ( <nl> - const CustomOptionType & custom_option , const std : : string & opcode_name , <nl> - TFLOp op , const std : : vector < int32_t > & operands , <nl> - const std : : vector < int32_t > & results ) ; <nl> - <nl> - BufferOffset < tflite : : Operator > BuildNumericVerifyOperator ( <nl> - mlir : : TFL : : NumericVerifyOp op , const std : : vector < int32_t > & operands , <nl> - const std : : vector < int32_t > & results ) ; <nl> - Optional < BufferOffset < tflite : : Operator > > <nl> - BuildConvolution2DTransposeBiasOperator ( <nl> - Operation * inst , mlir : : TFL : : Convolution2DTransposeBiasOp op , <nl> - const std : : vector < int32_t > & operands , <nl> - const std : : vector < int32_t > & results ) ; <nl> - Optional < BufferOffset < tflite : : Operator > > BuildMaxPoolingWithArgMax2DOperator ( <nl> - Operation * inst , mlir : : TFL : : MaxPoolingWithArgMax2DOp op , <nl> - const std : : vector < int32_t > & operands , <nl> - const std : : vector < int32_t > & results ) ; <nl> - Optional < BufferOffset < tflite : : Operator > > BuildMaxUnpooling2DOperator ( <nl> - Operation * inst , mlir : : TFL : : MaxUnpooling2DOp op , <nl> - const std : : vector < int32_t > & operands , <nl> - const std : : vector < int32_t > & results ) ; <nl> - <nl> - Optional < CustomOptionsOffset > CreateFlexOpCustomOptions ( <nl> - const : : tensorflow : : NodeDef & node_def , const mlir : : Location & loc ) ; <nl> - <nl> - Optional < CustomOptionsOffset > CreateCustomOpCustomOptions ( <nl> - const : : tensorflow : : NodeDef & node_def , const mlir : : Location & loc ) ; <nl> - <nl> - std : : unique_ptr < flexbuffers : : Builder > CreateFlexBuilderWithNodeAttrs ( <nl> - const : : tensorflow : : NodeDef & node_def , const mlir : : Location & loc ) ; <nl> - <nl> - / / Returns opcode index for op identified by the op_name , if already <nl> - / / available . Otherwise , creates a new OperatorCode using the given ` builtin ` <nl> - / / operator and associates it with ` op_name ` . <nl> - uint32_t GetOpcodeIndex ( const std : : string & op_name , <nl> - tflite : : BuiltinOperator builtin ) ; <nl> - <nl> - / / Builds operator for the given operation with specified operand and result <nl> - / / tensor indices . Emits an error and returns llvm : : None on failure . <nl> - Optional < BufferOffset < tflite : : Operator > > BuildOperator ( <nl> - Operation * inst , const std : : vector < int32_t > & operands , <nl> - const std : : vector < int32_t > & results , <nl> - const std : : vector < int32_t > & intermediates ) ; <nl> - <nl> - / / Build a subgraph with a given name out of the region either corresponding <nl> - / / to a function ' s body or while op . <nl> - Optional < BufferOffset < tflite : : SubGraph > > BuildSubGraph ( <nl> - const std : : string & name , Region * region ) ; <nl> - <nl> - / / Builds Metadata with the given ` name ` and buffer ` content ` . <nl> - BufferOffset < tflite : : Metadata > BuildMetadata ( StringRef name , <nl> - StringRef content ) ; <nl> - <nl> - / / Encodes the ` tfl . metadata ` dictionary attribute of the module to the <nl> - / / metadata section in the final model . <nl> - Optional < VectorBufferOffset < BufferOffset < tflite : : Metadata > > > <nl> - CreateMetadataVector ( ) ; <nl> - <nl> - / / Uses the tf . entry_function attribute ( if set ) to initialize the op to name <nl> - / / mapping . <nl> - void InitializeNamesFromAttribute ( FuncOp fn , bool * has_input_attr ) ; <nl> - <nl> - / / Determines if the specified operation op ' s operand at operand_index <nl> - / / is marked as a stateful operand . <nl> - bool IsStatefulOperand ( mlir : : Operation * op , int operand_index ) ; <nl> - <nl> - / / Returns a unique name for ` val ` . <nl> - std : : string UniqueName ( mlir : : Value val ) ; <nl> - <nl> - ModuleOp module_ ; <nl> - <nl> - tensorflow : : OpOrArgNameMapper & name_mapper_ ; <nl> - <nl> - flatbuffers : : FlatBufferBuilder builder_ ; <nl> - BufferOffset < tflite : : Buffer > empty_buffer_ ; <nl> - <nl> - std : : vector < BufferOffset < tflite : : Buffer > > buffers_ ; <nl> - <nl> - / / Maps op name to index of the corresponding OperatorCode in opcodes_ vector . <nl> - absl : : flat_hash_map < std : : string , uint32_t > opcode_index_map_ ; <nl> - std : : vector < BufferOffset < tflite : : OperatorCode > > opcodes_ ; <nl> - <nl> - / / Maps function name to index of the corresponding subgraph in the FlatBuffer <nl> - / / model . <nl> - absl : : flat_hash_map < std : : string , int > subgraph_index_map_ ; <nl> - absl : : flat_hash_set < OpType > enabled_op_types_ ; <nl> - <nl> - / / Points to TensorFlow and TFLite dialects , respectively . nullptr if the <nl> - / / dialect is not registered . <nl> - const Dialect * tf_dialect_ ; <nl> - const Dialect * tfl_dialect_ ; <nl> - <nl> - / / The failed ops during legalization . <nl> - std : : set < std : : string > failed_flex_ops_ ; <nl> - std : : set < std : : string > failed_custom_ops_ ; <nl> - } ; <nl> - <nl> - std : : string Translator : : UniqueName ( mlir : : Value val ) { <nl> - return std : : string ( name_mapper_ . GetUniqueName ( val ) ) ; <nl> - } <nl> - <nl> - Optional < BufferOffset < tflite : : Buffer > > Translator : : BuildBuffer ( <nl> - Operation * inst ) { <nl> - ElementsAttr attr ; <nl> - if ( auto cst = dyn_cast < mlir : : ConstantOp > ( inst ) ) { <nl> - / / ConstantOp have ElementAttr at this point due to validation of the TFLite <nl> - / / module . <nl> - attr = cst . getValue ( ) . cast < ElementsAttr > ( ) ; <nl> - } else if ( auto cst = dyn_cast < mlir : : TF : : ConstOp > ( inst ) ) { <nl> - attr = cst . value ( ) ; <nl> - } else if ( auto cst = dyn_cast < tfl : : ConstOp > ( inst ) ) { <nl> - attr = cst . value ( ) ; <nl> - } else if ( auto cst = dyn_cast < tfl : : QConstOp > ( inst ) ) { <nl> - attr = cst . value ( ) ; <nl> - } else if ( auto cst = dyn_cast < tfl : : SparseConstOp > ( inst ) ) { <nl> - attr = cst . value ( ) ; <nl> - } else if ( auto cst = dyn_cast < tfl : : SparseQConstOp > ( inst ) ) { <nl> - attr = cst . value ( ) ; <nl> - } else { <nl> - return empty_buffer_ ; <nl> - } <nl> - <nl> - tensorflow : : Tensor tensor ; <nl> - auto status = tensorflow : : ConvertToTensor ( attr , & tensor ) ; <nl> - if ( ! status . ok ( ) ) { <nl> - inst - > emitError ( <nl> - Twine ( " failed to convert value attribute to tensor with error : " + <nl> - status . ToString ( ) ) ) ; <nl> - return llvm : : None ; <nl> - } <nl> - <nl> - / / TensorFlow and TensorFlow Lite use different string encoding formats . <nl> - / / Convert to TensorFlow Lite format is it ' s a constant string tensor . <nl> - if ( tensor . dtype ( ) = = tensorflow : : DT_STRING ) { <nl> - : : tflite : : DynamicBuffer dynamic_buffer ; <nl> - auto flat = tensor . flat < : : tensorflow : : tstring > ( ) ; <nl> - for ( int i = 0 ; i < flat . size ( ) ; + + i ) { <nl> - const auto & str = flat ( i ) ; <nl> - dynamic_buffer . AddString ( str . c_str ( ) , str . length ( ) ) ; <nl> - } <nl> - char * tensor_buffer ; <nl> - int bytes = dynamic_buffer . WriteToBuffer ( & tensor_buffer ) ; <nl> - auto buffer_data = <nl> - builder_ . CreateVector ( reinterpret_cast < uint8_t * > ( tensor_buffer ) , bytes ) ; <nl> - free ( tensor_buffer ) ; <nl> - return tflite : : CreateBuffer ( builder_ , buffer_data ) ; <nl> - } <nl> - <nl> - absl : : string_view tensor_data = tensor . tensor_data ( ) ; <nl> - auto buffer_data = builder_ . CreateVector ( <nl> - reinterpret_cast < const uint8_t * > ( tensor_data . data ( ) ) , tensor_data . size ( ) ) ; <nl> - return tflite : : CreateBuffer ( builder_ , buffer_data ) ; <nl> - } <nl> - <nl> - Optional < BufferOffset < tflite : : Tensor > > Translator : : BuildTensorFromType ( <nl> - mlir : : Type type , const std : : string & name ) { <nl> - auto tensor_type = type . cast < TensorType > ( ) ; <nl> - <nl> - if ( ! tensor_type . hasStaticShape ( ) ) { <nl> - return llvm : : None ; <nl> - } <nl> - llvm : : ArrayRef < int64_t > shape_ref = tensor_type . getShape ( ) ; <nl> - std : : vector < int32_t > shape ( shape_ref . begin ( ) , shape_ref . end ( ) ) ; <nl> - <nl> - auto element_type = tensor_type . getElementType ( ) ; <nl> - tflite : : TensorType tflite_element_type = <nl> - GetTFLiteType ( tensor_type . getElementType ( ) ) . ValueOrDie ( ) ; <nl> - BufferOffset < tflite : : QuantizationParameters > q_params ; <nl> - auto qtype = element_type . dyn_cast < mlir : : quant : : UniformQuantizedType > ( ) ; <nl> - if ( ! qtype ) { <nl> - return llvm : : None ; <nl> - } <nl> - q_params = tflite : : CreateQuantizationParameters ( <nl> - builder_ , / * min = * / 0 , / * max = * / 0 , <nl> - builder_ . CreateVector < float > ( { static_cast < float > ( qtype . getScale ( ) ) } ) , <nl> - builder_ . CreateVector < int64_t > ( { qtype . getZeroPoint ( ) } ) ) ; <nl> - return tflite : : CreateTensor ( <nl> - builder_ , builder_ . CreateVector ( shape ) , tflite_element_type , <nl> - / * buffer = * / 0 , builder_ . CreateString ( name ) , q_params , <nl> - / * is_variable = * / false ) ; <nl> - } <nl> - <nl> - Optional < BufferOffset < tflite : : Tensor > > Translator : : BuildTensor ( <nl> - Value value , const std : : string & name , unsigned buffer_idx ) { <nl> - auto type = value . getType ( ) . cast < TensorType > ( ) ; <nl> - <nl> - / / TFLite requires tensor shape only for the inputs and constants . <nl> - / / However , we output all known shapes for better round - tripping <nl> - auto check_shape = <nl> - [ & ] ( llvm : : ArrayRef < int64_t > shape_ref ) - > mlir : : LogicalResult { <nl> - auto is_out_of_range = [ ] ( int64_t dim ) { <nl> - return dim > std : : numeric_limits < int32_t > : : max ( ) ; <nl> - } ; <nl> - <nl> - if ( std : : any_of ( shape_ref . begin ( ) , shape_ref . end ( ) , is_out_of_range ) ) <nl> - return mlir : : emitError ( <nl> - value . getLoc ( ) , <nl> - " result shape dimensions out of 32 bit int type range " ) ; <nl> - <nl> - return mlir : : success ( ) ; <nl> - } ; <nl> - <nl> - std : : vector < int32_t > shape ; <nl> - std : : vector < int32_t > shape_signature ; <nl> - if ( type . hasStaticShape ( ) ) { <nl> - llvm : : ArrayRef < int64_t > shape_ref = type . getShape ( ) ; <nl> - if ( mlir : : failed ( check_shape ( shape_ref ) ) ) return llvm : : None ; <nl> - <nl> - shape = std : : vector < int32_t > ( shape_ref . begin ( ) , shape_ref . end ( ) ) ; <nl> - } else if ( auto * inst = value . getDefiningOp ( ) ) { <nl> - if ( IsConst ( inst ) ) { <nl> - / / Const op can have a result of dynamic shaped type ( e . g . due to constant <nl> - / / folding ) , but we can still derive the shape of a constant tensor for <nl> - / / its attribute type . <nl> - mlir : : Attribute tensor_attr = inst - > getAttr ( " value " ) ; <nl> - llvm : : ArrayRef < int64_t > shape_ref = <nl> - tensor_attr . getType ( ) . cast < TensorType > ( ) . getShape ( ) ; <nl> - if ( mlir : : failed ( check_shape ( shape_ref ) ) ) return llvm : : None ; <nl> - <nl> - shape = std : : vector < int32_t > ( shape_ref . begin ( ) , shape_ref . end ( ) ) ; <nl> - } <nl> - } else if ( type . hasRank ( ) ) { <nl> - llvm : : ArrayRef < int64_t > shape_ref = type . getShape ( ) ; <nl> - if ( mlir : : failed ( check_shape ( shape_ref ) ) ) return llvm : : None ; <nl> - <nl> - shape . reserve ( shape_ref . size ( ) ) ; <nl> - for ( auto & dim : shape_ref ) { <nl> - shape . push_back ( dim = = - 1 ? 1 : dim ) ; <nl> - } <nl> - shape_signature = std : : vector < int32_t > ( shape_ref . begin ( ) , shape_ref . end ( ) ) ; <nl> - } <nl> - <nl> - if ( auto * inst = value . getDefiningOp ( ) ) { <nl> - if ( auto cst = dyn_cast < tfl : : SparseConstOp > ( inst ) ) { <nl> - / / CreateSparsityParameters ( cst . s_param ( ) ) ; <nl> - } else if ( auto cst = dyn_cast < tfl : : SparseQConstOp > ( inst ) ) { <nl> - / / CreateSparsityParameters ( cst . s_param ( ) ) ; <nl> - } <nl> - } <nl> - <nl> - Type element_type = type . getElementType ( ) ; <nl> - tflite : : TensorType tflite_element_type = <nl> - GetTFLiteType ( type . getElementType ( ) ) . ValueOrDie ( ) ; <nl> - <nl> - BufferOffset < tflite : : QuantizationParameters > q_params ; <nl> - if ( auto qtype = element_type . dyn_cast < mlir : : quant : : UniformQuantizedType > ( ) ) { <nl> - q_params = tflite : : CreateQuantizationParameters ( <nl> - / / TODO ( fengliuai ) : min and max values are not stored in the <nl> - / / quantized type , so both are set to 0 . The model couldn ' t be imported <nl> - / / to TensorFlow because of this . <nl> - builder_ , / * min = * / 0 , / * max = * / 0 , <nl> - builder_ . CreateVector < float > ( { static_cast < float > ( qtype . getScale ( ) ) } ) , <nl> - builder_ . CreateVector < int64_t > ( { qtype . getZeroPoint ( ) } ) ) ; <nl> - } else if ( auto qtype = <nl> - element_type <nl> - . dyn_cast < mlir : : quant : : UniformQuantizedPerAxisType > ( ) ) { <nl> - std : : vector < float > scales ( qtype . getScales ( ) . begin ( ) , <nl> - qtype . getScales ( ) . end ( ) ) ; <nl> - q_params = tflite : : CreateQuantizationParameters ( <nl> - builder_ , / * min = * / 0 , / * max = * / 0 , builder_ . CreateVector < float > ( scales ) , <nl> - builder_ . CreateVector < int64_t > ( qtype . getZeroPoints ( ) ) , <nl> - tflite : : QuantizationDetails_NONE , / * details = * / 0 , <nl> - qtype . getQuantizedDimension ( ) ) ; <nl> - } else { <nl> - q_params = tflite : : CreateQuantizationParameters ( builder_ ) ; <nl> - } <nl> - / / Check if the value ' s uses includes an op and usage at an operand index <nl> - / / marked as a stateful . If so , set the tensor ' s is_variable as true <nl> - / / This is v1 ref variable semantics in the TFLite runtime . <nl> - bool is_variable = false ; <nl> - for ( auto & use : value . getUses ( ) ) { <nl> - is_variable = IsStatefulOperand ( use . getOwner ( ) , use . getOperandNumber ( ) ) ; <nl> - if ( is_variable ) { <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - if ( shape_signature . empty ( ) ) { <nl> - return tflite : : CreateTensor ( <nl> - builder_ , builder_ . CreateVector ( shape ) , tflite_element_type , <nl> - ( is_variable ? 0 : buffer_idx ) , builder_ . CreateString ( name ) , q_params , <nl> - / * is_variable = * / is_variable ) ; <nl> - } else { <nl> - return tflite : : CreateTensor ( <nl> - builder_ , builder_ . CreateVector ( shape ) , tflite_element_type , <nl> - ( is_variable ? 0 : buffer_idx ) , builder_ . CreateString ( name ) , q_params , <nl> - / * is_variable = * / is_variable , / * sparsity = * / 0 , <nl> - / * shape_signature = * / builder_ . CreateVector ( shape_signature ) ) ; <nl> - } <nl> - } <nl> - <nl> - BufferOffset < tflite : : Operator > Translator : : BuildIfOperator ( <nl> - mlir : : TF : : IfOp op , const std : : vector < int32_t > & operands , <nl> - const std : : vector < int32_t > & results ) { <nl> - auto opcode_index = GetOpcodeIndex ( " if " , tflite : : BuiltinOperator_IF ) ; <nl> - int then_subgraph_index = subgraph_index_map_ . at ( op . then_branch ( ) . str ( ) ) ; <nl> - int else_subgraph_index = subgraph_index_map_ . at ( op . else_branch ( ) . str ( ) ) ; <nl> - auto builtin_options = tflite : : CreateIfOptions ( builder_ , then_subgraph_index , <nl> - else_subgraph_index ) <nl> - . Union ( ) ; <nl> - auto inputs = builder_ . CreateVector ( operands ) ; <nl> - auto outputs = builder_ . CreateVector ( results ) ; <nl> - return tflite : : CreateOperator ( builder_ , opcode_index , inputs , outputs , <nl> - tflite : : BuiltinOptions_IfOptions , <nl> - builtin_options ) ; <nl> - } <nl> - <nl> - BufferOffset < tflite : : Operator > Translator : : BuildWhileOperator ( <nl> - mlir : : TF : : WhileOp op , const std : : vector < int32_t > & operands , <nl> - const std : : vector < int32_t > & results ) { <nl> - auto opcode_index = GetOpcodeIndex ( " while " , tflite : : BuiltinOperator_WHILE ) ; <nl> - int cond_subgraph_index = subgraph_index_map_ . at ( op . cond ( ) . str ( ) ) ; <nl> - int body_subgraph_index = subgraph_index_map_ . at ( op . body ( ) . str ( ) ) ; <nl> - auto builtin_options = tflite : : CreateWhileOptions ( <nl> - builder_ , cond_subgraph_index , body_subgraph_index ) <nl> - . Union ( ) ; <nl> - auto inputs = builder_ . CreateVector ( operands ) ; <nl> - auto outputs = builder_ . CreateVector ( results ) ; <nl> - return tflite : : CreateOperator ( builder_ , opcode_index , inputs , outputs , <nl> - tflite : : BuiltinOptions_WhileOptions , <nl> - builtin_options ) ; <nl> - } <nl> - <nl> - Optional < BufferOffset < tflite : : Operator > > Translator : : BuildWhileOperator ( <nl> - mlir : : TFL : : WhileOp op , const std : : vector < int32_t > & operands , <nl> - const std : : vector < int32_t > & results ) { <nl> - auto opcode_index = GetOpcodeIndex ( " while " , tflite : : BuiltinOperator_WHILE ) ; <nl> - auto get_call_index = [ & ] ( mlir : : Block & b ) - > Optional < int > { <nl> - if ( b . getOperations ( ) . size ( ) ! = 2 ) return llvm : : None ; <nl> - if ( auto call_op = dyn_cast < mlir : : CallOp > ( b . front ( ) ) ) <nl> - return subgraph_index_map_ . at ( call_op . callee ( ) . str ( ) ) ; <nl> - return llvm : : None ; <nl> - } ; <nl> - auto body_subgraph_index = get_call_index ( op . body ( ) . front ( ) ) ; <nl> - auto cond_subgraph_index = get_call_index ( op . cond ( ) . front ( ) ) ; <nl> - if ( ! body_subgraph_index | | ! cond_subgraph_index ) <nl> - return op . emitOpError ( " only single call cond / body while export supported " ) , <nl> - llvm : : None ; <nl> - auto builtin_options = <nl> - tflite : : CreateWhileOptions ( builder_ , * cond_subgraph_index , <nl> - * body_subgraph_index ) <nl> - . Union ( ) ; <nl> - auto inputs = builder_ . CreateVector ( operands ) ; <nl> - auto outputs = builder_ . CreateVector ( results ) ; <nl> - return tflite : : CreateOperator ( builder_ , opcode_index , inputs , outputs , <nl> - tflite : : BuiltinOptions_WhileOptions , <nl> - builtin_options ) ; <nl> - } <nl> - <nl> - template < typename CustomOptionType , typename TFLOp > <nl> - BufferOffset < tflite : : Operator > Translator : : BuildCustomOperator ( <nl> - const CustomOptionType & custom_option , const std : : string & opcode_name , <nl> - TFLOp op , const std : : vector < int32_t > & operands , <nl> - const std : : vector < int32_t > & results ) { <nl> - std : : vector < uint8_t > custom_option_vector ( sizeof ( CustomOptionType ) ) ; <nl> - memcpy ( custom_option_vector . data ( ) , & custom_option , sizeof ( CustomOptionType ) ) ; <nl> - auto opcode_index = <nl> - GetOpcodeIndex ( opcode_name , tflite : : BuiltinOperator_CUSTOM ) ; <nl> - return tflite : : CreateOperator ( <nl> - builder_ , opcode_index , builder_ . CreateVector ( operands ) , <nl> - builder_ . CreateVector ( results ) , tflite : : BuiltinOptions_NONE , <nl> - / * builtin_options = * / 0 , <nl> - builder_ . CreateVector < uint8_t > ( custom_option_vector ) , <nl> - tflite : : CustomOptionsFormat_FLEXBUFFERS ) ; <nl> - } <nl> - <nl> - BufferOffset < tflite : : Operator > Translator : : BuildNumericVerifyOperator ( <nl> - mlir : : TFL : : NumericVerifyOp op , const std : : vector < int32_t > & operands , <nl> - const std : : vector < int32_t > & results ) { <nl> - float tolerance = op . tolerance ( ) . convertToFloat ( ) ; <nl> - return BuildCustomOperator ( tolerance , " NumericVerify " , op , operands , results ) ; <nl> - } <nl> - <nl> - Optional < BufferOffset < tflite : : Operator > > <nl> - Translator : : BuildConvolution2DTransposeBiasOperator ( <nl> - Operation * inst , mlir : : TFL : : Convolution2DTransposeBiasOp op , <nl> - const std : : vector < int32_t > & operands , const std : : vector < int32_t > & results ) { <nl> - TfLiteTransposeConvParams conv_params ; <nl> - conv_params . stride_height = op . stride_h ( ) . getSExtValue ( ) ; <nl> - conv_params . stride_width = op . stride_w ( ) . getSExtValue ( ) ; <nl> - const auto padding = GetTflitePadding ( inst , op . padding ( ) ) ; <nl> - if ( padding ) { <nl> - conv_params . padding = * padding ; <nl> - return BuildCustomOperator ( conv_params , " Convolution2DTransposeBias " , op , <nl> - operands , results ) ; <nl> - } <nl> - <nl> - return llvm : : None ; <nl> - } <nl> - <nl> - Optional < BufferOffset < tflite : : Operator > > <nl> - Translator : : BuildMaxPoolingWithArgMax2DOperator ( <nl> - Operation * inst , mlir : : TFL : : MaxPoolingWithArgMax2DOp op , <nl> - const std : : vector < int32_t > & operands , const std : : vector < int32_t > & results ) { <nl> - const auto pool_params = GetTflitePoolParams ( inst , op ) ; <nl> - if ( pool_params ) { <nl> - return BuildCustomOperator ( * pool_params , " MaxPoolingWithArgmax2D " , op , <nl> - operands , results ) ; <nl> - } <nl> - <nl> - return llvm : : None ; <nl> - } <nl> - <nl> - Optional < BufferOffset < tflite : : Operator > > <nl> - Translator : : BuildMaxUnpooling2DOperator ( Operation * inst , <nl> - mlir : : TFL : : MaxUnpooling2DOp op , <nl> - const std : : vector < int32_t > & operands , <nl> - const std : : vector < int32_t > & results ) { <nl> - const auto pool_params = GetTflitePoolParams ( inst , op ) ; <nl> - if ( pool_params ) { <nl> - return BuildCustomOperator ( * pool_params , " MaxUnpooling2D " , op , operands , <nl> - results ) ; <nl> - } <nl> - <nl> - return llvm : : None ; <nl> - } <nl> - <nl> - Optional < CustomOptionsOffset > Translator : : CreateFlexOpCustomOptions ( <nl> - const : : tensorflow : : NodeDef & node_def , const mlir : : Location & loc ) { <nl> - std : : string node_def_str ; <nl> - if ( ! node_def . SerializeToString ( & node_def_str ) ) { <nl> - return emitError ( loc , " failed to serialize tensorflow node_def " ) , <nl> - llvm : : None ; <nl> - } <nl> - <nl> - auto flex_builder = absl : : make_unique < flexbuffers : : Builder > ( ) ; <nl> - flex_builder - > Vector ( [ & ] ( ) { <nl> - flex_builder - > String ( node_def . op ( ) ) ; <nl> - flex_builder - > String ( node_def_str ) ; <nl> - } ) ; <nl> - flex_builder - > Finish ( ) ; <nl> - return builder_ . CreateVector ( flex_builder - > GetBuffer ( ) ) ; <nl> - } <nl> - <nl> - Optional < CustomOptionsOffset > Translator : : CreateCustomOpCustomOptions ( <nl> - const : : tensorflow : : NodeDef & node_def , const mlir : : Location & loc ) { <nl> - std : : string node_def_str ; <nl> - if ( ! node_def . SerializeToString ( & node_def_str ) ) { <nl> - return emitError ( loc , " failed to serialize tensorflow node_def " ) , <nl> - llvm : : None ; <nl> - } <nl> - auto flex_builder = CreateFlexBuilderWithNodeAttrs ( node_def , loc ) ; <nl> - return builder_ . CreateVector ( flex_builder - > GetBuffer ( ) ) ; <nl> - } <nl> - <nl> - std : : unique_ptr < flexbuffers : : Builder > <nl> - Translator : : CreateFlexBuilderWithNodeAttrs ( <nl> - const : : tensorflow : : NodeDef & node_def , const mlir : : Location & loc ) { <nl> - auto flex_builder = absl : : make_unique < flexbuffers : : Builder > ( ) ; <nl> - size_t map_start = flex_builder - > StartMap ( ) ; <nl> - for ( const auto & pair : node_def . attr ( ) ) { <nl> - const char * key = pair . first . c_str ( ) ; <nl> - const auto & attr = pair . second ; <nl> - switch ( attr . value_case ( ) ) { <nl> - case : : tensorflow : : AttrValue : : kS : <nl> - flex_builder - > String ( key , attr . s ( ) ) ; <nl> - break ; <nl> - case : : tensorflow : : AttrValue : : kType : { <nl> - auto status_or_tfl_type = tflite : : TfTypeToTflType ( attr . type ( ) ) ; <nl> - if ( status_or_tfl_type . ok ( ) ) { <nl> - flex_builder - > Int ( key , status_or_tfl_type . ValueOrDie ( ) ) ; <nl> - } else { <nl> - emitWarning ( loc , " ignoring unsupported tensorflow type : " ) <nl> - < < std : : to_string ( attr . type ( ) ) ; <nl> - } <nl> - break ; <nl> - } <nl> - case : : tensorflow : : AttrValue : : kI : <nl> - flex_builder - > Int ( key , attr . i ( ) ) ; <nl> - break ; <nl> - case : : tensorflow : : AttrValue : : kF : <nl> - flex_builder - > Float ( key , attr . f ( ) ) ; <nl> - break ; <nl> - case : : tensorflow : : AttrValue : : kB : <nl> - flex_builder - > Bool ( key , attr . b ( ) ) ; <nl> - break ; <nl> - case tensorflow : : AttrValue : : kList : <nl> - if ( attr . list ( ) . s_size ( ) > 0 ) { <nl> - auto start = flex_builder - > StartVector ( key ) ; <nl> - for ( const std : : string & v : attr . list ( ) . s ( ) ) { <nl> - flex_builder - > Add ( v ) ; <nl> - } <nl> - flex_builder - > EndVector ( start , / * typed = * / true , / * fixed = * / false ) ; <nl> - } else if ( attr . list ( ) . i_size ( ) > 0 ) { <nl> - auto start = flex_builder - > StartVector ( key ) ; <nl> - for ( const int64_t v : attr . list ( ) . i ( ) ) { <nl> - flex_builder - > Add ( v ) ; <nl> - } <nl> - flex_builder - > EndVector ( start , / * typed = * / true , / * fixed = * / false ) ; <nl> - } else if ( attr . list ( ) . f_size ( ) > 0 ) { <nl> - auto start = flex_builder - > StartVector ( key ) ; <nl> - for ( const float v : attr . list ( ) . f ( ) ) { <nl> - flex_builder - > Add ( v ) ; <nl> - } <nl> - flex_builder - > EndVector ( start , / * typed = * / true , / * fixed = * / false ) ; <nl> - } else { <nl> - emitWarning ( loc , <nl> - " ignoring unsupported type in list attribute with key : " ) <nl> - < < key ; <nl> - } <nl> - break ; <nl> - default : <nl> - emitWarning ( loc , " ignoring unsupported attribute type with key : " ) <nl> - < < key ; <nl> - break ; <nl> - } <nl> - } <nl> - flex_builder - > EndMap ( map_start ) ; <nl> - flex_builder - > Finish ( ) ; <nl> - return flex_builder ; <nl> - } <nl> - <nl> - uint32_t Translator : : GetOpcodeIndex ( const std : : string & op_name , <nl> - tflite : : BuiltinOperator builtin ) { <nl> - auto it = opcode_index_map_ . insert ( { op_name , 0 } ) ; <nl> - <nl> - / / If the insert succeeded , the opcode has not been created already . Create a <nl> - / / new operator code and update its index value in the map . <nl> - if ( it . second ) { <nl> - it . first - > second = opcodes_ . size ( ) ; <nl> - auto custom_code = builtin = = tflite : : BuiltinOperator_CUSTOM <nl> - ? builder_ . CreateString ( op_name ) <nl> - : BufferOffset < flatbuffers : : String > ( ) ; <nl> - / / Use version 0 for builtin op . This is a way to serialize version field to <nl> - / / flatbuffer ( since 0 is non default ) and it will be corrected later . <nl> - int32_t op_version = builtin ! = tflite : : BuiltinOperator_CUSTOM ? 0 : 1 ; <nl> - opcodes_ . push_back ( CreateOperatorCode ( builder_ , / * builtin_code = * / builtin , <nl> - custom_code , op_version ) ) ; <nl> - } <nl> - return it . first - > second ; <nl> - } <nl> - <nl> - Optional < BufferOffset < tflite : : Operator > > Translator : : BuildOperator ( <nl> - Operation * inst , const std : : vector < int32_t > & operands , <nl> - const std : : vector < int32_t > & results , <nl> - const std : : vector < int32_t > & intermediates ) { <nl> - const auto * dialect = inst - > getDialect ( ) ; <nl> - if ( ! dialect ) { <nl> - inst - > emitOpError ( " dialect is not registered " ) ; <nl> - return llvm : : None ; <nl> - } <nl> - <nl> - / / If TFLite built in op , create operator as a builtin op . <nl> - if ( dialect = = tfl_dialect_ ) { <nl> - / / Only if built - in TFLite op emission is enabled , would legalization have <nl> - / / converted any TF - > TFL . <nl> - if ( ! enabled_op_types_ . contains ( OpType : : kTfliteBuiltin ) ) { <nl> - return inst - > emitOpError ( <nl> - " is a TFLite builtin op but builtin emission is not enabled " ) , <nl> - llvm : : None ; <nl> - } <nl> - <nl> - auto builtin_code = GetBuiltinOpCode ( inst ) ; <nl> - if ( ! builtin_code ) { <nl> - if ( auto verify_op = dyn_cast < mlir : : TFL : : NumericVerifyOp > ( inst ) ) { <nl> - return BuildNumericVerifyOperator ( verify_op , operands , results ) ; <nl> - } <nl> - if ( auto conv_transpose_bias_op = <nl> - dyn_cast < mlir : : TFL : : Convolution2DTransposeBiasOp > ( inst ) ) { <nl> - return BuildConvolution2DTransposeBiasOperator ( <nl> - inst , conv_transpose_bias_op , operands , results ) ; <nl> - } <nl> - if ( auto max_pooling_with_arg_max_op = <nl> - dyn_cast < mlir : : TFL : : MaxPoolingWithArgMax2DOp > ( inst ) ) { <nl> - return BuildMaxPoolingWithArgMax2DOperator ( <nl> - inst , max_pooling_with_arg_max_op , operands , results ) ; <nl> - } <nl> - if ( auto max_unpooling_op = dyn_cast < mlir : : TFL : : MaxUnpooling2DOp > ( inst ) ) { <nl> - return BuildMaxUnpooling2DOperator ( inst , max_unpooling_op , operands , <nl> - results ) ; <nl> - } <nl> - if ( auto whileOp = dyn_cast < mlir : : TFL : : WhileOp > ( inst ) ) { <nl> - if ( inst - > getNumOperands ( ) ! = inst - > getNumResults ( ) ) { <nl> - inst - > emitOpError ( <nl> - " number of operands and results don ' t match , only canonical " <nl> - " TFL While supported " ) ; <nl> - return llvm : : None ; <nl> - } <nl> - return BuildWhileOperator ( whileOp , operands , results ) ; <nl> - } <nl> - <nl> - inst - > emitOpError ( " is not a supported TFLite op " ) ; <nl> - return llvm : : None ; <nl> - } <nl> - <nl> - std : : string op_name = inst - > getName ( ) . getStringRef ( ) . str ( ) ; <nl> - uint32_t opcode_index = GetOpcodeIndex ( op_name , * builtin_code ) ; <nl> - auto offset = CreateFlatBufferOperator ( inst , opcode_index , operands , <nl> - results , intermediates , & builder_ ) ; <nl> - if ( ! offset ) { <nl> - inst - > emitOpError ( " is not a supported TFLite op " ) ; <nl> - } <nl> - return offset ; <nl> - } <nl> - <nl> - if ( dialect = = tf_dialect_ ) { <nl> - std : : string op_name ; <nl> - if ( auto ifOp = dyn_cast < mlir : : TF : : IfOp > ( inst ) ) { <nl> - return BuildIfOperator ( ifOp , operands , results ) ; <nl> - } else if ( auto whileOp = dyn_cast < mlir : : TF : : WhileOp > ( inst ) ) { <nl> - return BuildWhileOperator ( whileOp , operands , results ) ; <nl> - } <nl> - <nl> - CustomOptionsOffset custom_options ; <nl> - <nl> - / / Ops in TF dialect can either be custom ops or flex ops . <nl> - / / The reason we go directly from TensorFlow dialect MLIR to tensorflow <nl> - / / node instead of going to TF table gen ' d ops via generated code is that <nl> - / / we do not want to restrict custom and flex op conversion support to <nl> - / / only those TF ops that are currently registered in MLIR . The current <nl> - / / model is of an open op system . <nl> - / / <nl> - / / The following algorithm is followed : <nl> - / / if flex is enabled and the op is whitelisted as flex <nl> - / / we emit op as flex . <nl> - / / if custom is enabled <nl> - / / we emit the op as custom . <nl> - auto node_def = GetTensorFlowNodeDef ( inst ) ; <nl> - if ( ! node_def ) { <nl> - return llvm : : None ; <nl> - } <nl> - <nl> - / / Flex op case <nl> - / / Eventually , the whitelist will go away and we will rely on some TF op <nl> - / / trait ( e . g . No side effect ) to determine if it is a supported " Flex " <nl> - / / op or not . <nl> - if ( enabled_op_types_ . contains ( OpType : : kSelectTf ) & & <nl> - IsWhitelistedFlexOp ( node_def - > op ( ) ) ) { <nl> - / / Construct ops as flex op encoding TensorFlow node definition <nl> - / / as custom options . <nl> - / / Flex ops are named with the kFlexOpNamePrefix prefix to the actual <nl> - / / TF op name . <nl> - op_name = std : : string ( kFlexOpNamePrefix ) + node_def - > op ( ) ; <nl> - if ( auto options = CreateFlexOpCustomOptions ( * node_def , inst - > getLoc ( ) ) ) { <nl> - custom_options = * options ; <nl> - } else { <nl> - return llvm : : None ; <nl> - } <nl> - } else if ( enabled_op_types_ . contains ( OpType : : kCustomOp ) ) { <nl> - / / Generic case of custom ops - write using flex buffers since that <nl> - / / is the only custom options supported by TFLite today . <nl> - op_name = node_def - > op ( ) ; <nl> - if ( auto options = <nl> - CreateCustomOpCustomOptions ( * node_def , inst - > getLoc ( ) ) ) { <nl> - custom_options = * options ; <nl> - } else { <nl> - return llvm : : None ; <nl> - } <nl> - } else { <nl> - / / Create description of operation that could not be converted . <nl> - const int kLargeElementsAttr = 16 ; <nl> - std : : string op_str ; <nl> - llvm : : raw_string_ostream os ( op_str ) ; <nl> - inst - > getName ( ) . print ( os ) ; <nl> - / / Print out attributes except for large elementsattributes ( which should <nl> - / / rarely be the cause why the legalization didn ' t happen ) . <nl> - if ( ! inst - > getAttrList ( ) . getAttrs ( ) . empty ( ) ) { <nl> - os < < " { " ; <nl> - bool first = true ; <nl> - for ( auto & named_attr : inst - > getAttrList ( ) . getDictionary ( ) ) { <nl> - os < < ( ! first ? " , " : " " ) ; <nl> - first = false ; <nl> - named_attr . first . print ( os ) ; <nl> - os < < " = " ; <nl> - if ( auto element_attr = named_attr . second . dyn_cast < ElementsAttr > ( ) ) { <nl> - if ( element_attr . getNumElements ( ) < = kLargeElementsAttr ) { <nl> - element_attr . print ( os ) ; <nl> - } else { <nl> - os < < " < large > " ; <nl> - } <nl> - } else { <nl> - named_attr . second . print ( os ) ; <nl> - } <nl> - } <nl> - os < < " } " ; <nl> - } <nl> - <nl> - / / Insert failed op to ` flex_ops ` or ` custom_ops ` . <nl> - if ( IsWhitelistedFlexOp ( node_def - > op ( ) ) ) { <nl> - failed_flex_ops_ . insert ( os . str ( ) ) ; <nl> - } else { <nl> - failed_custom_ops_ . insert ( os . str ( ) ) ; <nl> - } <nl> - return inst - > emitOpError ( " is neither a custom op nor a flex op " ) , <nl> - llvm : : None ; <nl> - } <nl> - <nl> - uint32_t opcode_index = <nl> - GetOpcodeIndex ( op_name , tflite : : BuiltinOperator_CUSTOM ) ; <nl> - auto inputs = builder_ . CreateVector ( operands ) ; <nl> - auto outputs = builder_ . CreateVector ( results ) ; <nl> - <nl> - return tflite : : CreateOperator ( builder_ , opcode_index , inputs , outputs , <nl> - tflite : : BuiltinOptions_NONE , <nl> - / * builtin_options = * / 0 , <nl> - / * custom_options = * / custom_options , <nl> - tflite : : CustomOptionsFormat_FLEXBUFFERS , <nl> - / * mutating_variable_inputs = * / 0 ) ; <nl> - } <nl> - <nl> - return inst - > emitOpError ( <nl> - " is not any of a builtin TFLite op , a flex TensorFlow op or a " <nl> - " custom TensorFlow op " ) , <nl> - llvm : : None ; <nl> - } <nl> - <nl> - void Translator : : InitializeNamesFromAttribute ( FuncOp fn , bool * has_input_attr ) { <nl> - auto dict_attr = fn . getAttrOfType < mlir : : DictionaryAttr > ( " tf . entry_function " ) ; <nl> - if ( ! dict_attr ) return ; <nl> - <nl> - llvm : : SmallVector < llvm : : StringRef , 2 > input_names ; <nl> - llvm : : SmallVector < llvm : : StringRef , 2 > output_names ; <nl> - if ( auto str = dict_attr . get ( " inputs " ) . dyn_cast_or_null < mlir : : StringAttr > ( ) ) { <nl> - str . getValue ( ) . split ( input_names , ' , ' , / * MaxSplit = * / - 1 , <nl> - / * KeepEmpty = * / false ) ; <nl> - if ( input_names . size ( ) ! = fn . getNumArguments ( ) ) { <nl> - fn . emitWarning ( ) < < " invalid entry function specification " ; <nl> - return ; <nl> - } <nl> - for ( auto it : llvm : : enumerate ( fn . getArguments ( ) ) ) { <nl> - name_mapper_ . InitOpName ( it . value ( ) , input_names [ it . index ( ) ] . trim ( ) ) ; <nl> - } <nl> - * has_input_attr = true ; <nl> - } <nl> - <nl> - if ( auto str = <nl> - dict_attr . get ( " outputs " ) . dyn_cast_or_null < mlir : : StringAttr > ( ) ) { <nl> - str . getValue ( ) . split ( output_names , ' , ' , / * MaxSplit = * / - 1 , <nl> - / * KeepEmpty = * / false ) ; <nl> - auto term = fn . getBlocks ( ) . back ( ) . getTerminator ( ) ; <nl> - if ( output_names . size ( ) ! = term - > getNumOperands ( ) ) { <nl> - fn . emitWarning ( ) < < " output names ( " < < output_names . size ( ) <nl> - < < " ) ! = terminator operands ( " < < term - > getNumOperands ( ) <nl> - < < " ) " ; <nl> - return ; <nl> - } <nl> - for ( const auto & it : llvm : : enumerate ( term - > getOperands ( ) ) ) { <nl> - name_mapper_ . InitOpName ( it . value ( ) , output_names [ it . index ( ) ] . trim ( ) ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - bool Translator : : IsStatefulOperand ( mlir : : Operation * op , int operand_index ) { <nl> - std : : vector < int > operand_indices ; <nl> - if ( ! mlir : : TFL : : IsStatefulOp ( op , & operand_indices ) ) return false ; <nl> - return absl : : c_find ( operand_indices , operand_index ) ! = operand_indices . end ( ) ; <nl> - } <nl> - <nl> - Optional < BufferOffset < tflite : : SubGraph > > Translator : : BuildSubGraph ( <nl> - const std : : string & name , Region * region ) { <nl> - bool has_input_attr = false ; <nl> - if ( auto fn = dyn_cast < FuncOp > ( region - > getParentOp ( ) ) ) { <nl> - InitializeNamesFromAttribute ( fn , & has_input_attr ) ; <nl> - } <nl> - std : : vector < BufferOffset < tflite : : Tensor > > tensors ; <nl> - llvm : : DenseMap < Value , int > tensor_index_map ; <nl> - <nl> - / / Builds tensor and buffer for argument or operation result . Returns false <nl> - / / on failure . <nl> - auto build_tensor_and_buffer = [ & ] ( Value value , const std : : string & name ) { <nl> - / / NoneType represents optional and may be skipped here . <nl> - if ( value . getType ( ) . isa < NoneType > ( ) ) { <nl> - return true ; <nl> - } <nl> - <nl> - tensor_index_map . insert ( { value , tensors . size ( ) } ) ; <nl> - auto tensor_or = BuildTensor ( value , name , buffers_ . size ( ) ) ; <nl> - if ( ! tensor_or ) return false ; <nl> - tensors . push_back ( * tensor_or ) ; <nl> - <nl> - / / TODO ( ashwinm ) : Check if for stateful tensors , if it is also needed to <nl> - / / make the Buffer empty apart from setting the buffer_idx = 0 in the Tensor . <nl> - / / This does not seem to affect runtime behavior for RNN / LSTM , but would be <nl> - / / good for reducing memory footprint . <nl> - if ( auto * inst = value . getDefiningOp ( ) ) { <nl> - auto buffer_or = BuildBuffer ( inst ) ; <nl> - if ( ! buffer_or ) return false ; <nl> - buffers_ . push_back ( * buffer_or ) ; <nl> - } else { <nl> - buffers_ . push_back ( empty_buffer_ ) ; <nl> - } <nl> - return true ; <nl> - } ; <nl> - <nl> - std : : vector < BufferOffset < tflite : : Operator > > operators ; <nl> - auto & bb = region - > front ( ) ; <nl> - <nl> - / / Main function ' s arguments are first passed to ` input ` op so they don ' t <nl> - / / have associated tensor and buffer . Build FlatBuffer tensor and buffer for <nl> - / / other functions . <nl> - for ( unsigned i = 0 , e = bb . getNumArguments ( ) ; i < e ; + + i ) { <nl> - mlir : : BlockArgument arg = bb . getArgument ( i ) ; <nl> - std : : string name ; <nl> - if ( has_input_attr ) name = std : : string ( name_mapper_ . GetUniqueName ( arg ) ) ; <nl> - if ( name . empty ( ) ) name = absl : : StrCat ( " arg " , i ) ; <nl> - if ( ! build_tensor_and_buffer ( arg , name ) ) return llvm : : None ; <nl> - } <nl> - <nl> - bool failed_once = false ; <nl> - for ( auto & inst : bb ) { <nl> - if ( inst . isKnownTerminator ( ) ) break ; <nl> - std : : vector < int32_t > intermediates ; <nl> - / / Build intermediate tensors for tfl . lstm and insert these tensors into <nl> - / / flatbuffer . <nl> - if ( llvm : : isa < mlir : : TFL : : LSTMOp > ( inst ) ) { <nl> - std : : vector < std : : string > intermediate_names = { <nl> - " input_to_input_intermediate " , " input_to_forget_intermediate " , <nl> - " input_to_cell_intermediate " , " input_to_output_intermediate " , <nl> - " effective_hidden_scale_intermediate " } ; <nl> - for ( const std : : string & intermediate : intermediate_names ) { <nl> - auto intermediate_attr = inst . getAttr ( intermediate ) ; <nl> - if ( auto attr = intermediate_attr . dyn_cast_or_null < mlir : : TypeAttr > ( ) ) { <nl> - Type qtype = attr . getValue ( ) ; <nl> - auto tensor_or = BuildTensorFromType ( <nl> - qtype , name_mapper_ . GetUniqueName ( intermediate ) . str ( ) ) ; <nl> - if ( ! tensor_or . hasValue ( ) ) { <nl> - continue ; <nl> - } else { <nl> - intermediates . push_back ( tensors . size ( ) ) ; <nl> - tensors . push_back ( tensor_or . getValue ( ) ) ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - <nl> - for ( auto val : inst . getResults ( ) ) { <nl> - std : : string name = UniqueName ( val ) ; <nl> - if ( ! build_tensor_and_buffer ( val , name ) ) return llvm : : None ; <nl> - } <nl> - <nl> - / / Skip constant ops as they don ' t represent a TFLite operator . <nl> - if ( IsConst ( & inst ) ) continue ; <nl> - <nl> - / / Fetch operand and result tensor indices . <nl> - std : : vector < int32_t > operands ; <nl> - operands . reserve ( inst . getNumOperands ( ) ) ; <nl> - for ( auto operand : inst . getOperands ( ) ) { <nl> - if ( operand . getType ( ) . isa < NoneType > ( ) ) <nl> - operands . push_back ( kTfLiteOptionalTensor ) ; <nl> - else <nl> - operands . push_back ( tensor_index_map . lookup ( operand ) ) ; <nl> - } <nl> - std : : vector < int32_t > results ; <nl> - results . reserve ( inst . getNumOperands ( ) ) ; <nl> - for ( auto result : inst . getResults ( ) ) { <nl> - results . push_back ( tensor_index_map . lookup ( result ) ) ; <nl> - } <nl> - <nl> - if ( auto tfl_operator = <nl> - BuildOperator ( & inst , operands , results , intermediates ) ) <nl> - operators . push_back ( * tfl_operator ) ; <nl> - else <nl> - failed_once = true ; <nl> - } <nl> - <nl> - if ( failed_once ) return llvm : : None ; <nl> - <nl> - / / Get input and output tensor indices for the subgraph . <nl> - std : : vector < int32_t > inputs , outputs ; <nl> - for ( auto arg : bb . getArguments ( ) ) { <nl> - inputs . push_back ( tensor_index_map [ arg ] ) ; <nl> - } <nl> - for ( auto result : bb . getTerminator ( ) - > getOperands ( ) ) { <nl> - outputs . push_back ( tensor_index_map [ result ] ) ; <nl> - } <nl> - <nl> - return tflite : : CreateSubGraph ( <nl> - builder_ , builder_ . CreateVector ( tensors ) , builder_ . CreateVector ( inputs ) , <nl> - builder_ . CreateVector ( outputs ) , builder_ . CreateVector ( operators ) , <nl> - / * name = * / builder_ . CreateString ( name ) ) ; <nl> - } <nl> - <nl> - BufferOffset < tflite : : Metadata > Translator : : BuildMetadata ( StringRef name , <nl> - StringRef content ) { <nl> - auto buffer_index = buffers_ . size ( ) ; <nl> - auto buffer_data = builder_ . CreateVector ( <nl> - reinterpret_cast < const uint8_t * > ( content . data ( ) ) , content . size ( ) ) ; <nl> - buffers_ . push_back ( tflite : : CreateBuffer ( builder_ , buffer_data ) ) ; <nl> - return tflite : : CreateMetadataDirect ( builder_ , name . data ( ) , buffer_index ) ; <nl> - } <nl> - <nl> - Optional < VectorBufferOffset < BufferOffset < tflite : : Metadata > > > <nl> - Translator : : CreateMetadataVector ( ) { <nl> - auto dict_attr = module_ . getAttrOfType < mlir : : DictionaryAttr > ( " tfl . metadata " ) ; <nl> - std : : vector < BufferOffset < tflite : : Metadata > > metadata ; <nl> - if ( dict_attr ) { <nl> - for ( const auto & named_attr : dict_attr ) { <nl> - StringRef name = named_attr . first ; <nl> - mlir : : Attribute attr = named_attr . second ; <nl> - if ( auto content = attr . dyn_cast < StringAttr > ( ) ) { <nl> - metadata . push_back ( BuildMetadata ( name , content . getValue ( ) ) ) ; <nl> - } else { <nl> - module_ . emitError ( <nl> - " all values in tfl . metadata ' s dictionary key - value pairs should be " <nl> - " string attributes " ) ; <nl> - return llvm : : None ; <nl> - } <nl> - } <nl> - } <nl> - / / Runtime version string is generated after we update the op <nl> - / / versions . Here we put a 16 - byte dummy string as a placeholder . We choose <nl> - / / 16 - byte because it ' s the alignment of buffers in flatbuffer , so it won ' t <nl> - / / cause any waste of space if the actual string is shorter than 16 bytes . <nl> - metadata . push_back ( <nl> - BuildMetadata ( " min_runtime_version " , std : : string ( 16 , ' \ 0 ' ) ) ) ; <nl> - return builder_ . CreateVector ( metadata ) ; <nl> - } <nl> - <nl> - bool UpdateEntryFunction ( ModuleOp module ) { <nl> - if ( module . lookupSymbol < FuncOp > ( " main " ) ! = nullptr ) { <nl> - / / We already have an entry function . <nl> - return true ; <nl> - } <nl> - <nl> - int entry_func_count = 0 ; <nl> - FuncOp entry_func = nullptr ; <nl> - for ( auto fn : module . getOps < FuncOp > ( ) ) { <nl> - auto attrs = fn . getAttrOfType < mlir : : DictionaryAttr > ( " tf . entry_function " ) ; <nl> - if ( attrs & & ! attrs . empty ( ) ) { <nl> - entry_func_count + + ; <nl> - entry_func = fn ; <nl> - } <nl> - } <nl> - <nl> - / / We should have one & only have one entry function . <nl> - if ( entry_func_count ! = 1 ) return false ; <nl> - <nl> - / / Update the entry func to main . <nl> - entry_func . setName ( " main " ) ; <nl> - return true ; <nl> - } <nl> - <nl> - Optional < std : : string > Translator : : Translate ( <nl> - ModuleOp module , bool emit_builtin_tflite_ops , bool emit_select_tf_ops , <nl> - bool emit_custom_ops , OpOrArgNameMapper * op_or_arg_name_mapper ) { <nl> - if ( ! UpdateEntryFunction ( module ) ) return llvm : : None ; <nl> - if ( ! IsValidTFLiteMlirModule ( module ) ) return llvm : : None ; <nl> - Translator translator ( module , emit_builtin_tflite_ops , emit_select_tf_ops , <nl> - emit_custom_ops , op_or_arg_name_mapper ) ; <nl> - return translator . TranslateInternal ( ) ; <nl> - } <nl> - <nl> - Optional < std : : string > Translator : : TranslateInternal ( ) { <nl> - / / A list of named regions in the module with main function being the first in <nl> - / / the list . The main function is required as the first subgraph in the model <nl> - / / is entry point for the model . <nl> - std : : vector < std : : pair < std : : string , Region * > > named_regions ; <nl> - named_regions . reserve ( std : : distance ( module_ . begin ( ) , module_ . end ( ) ) ) ; <nl> - <nl> - int subgraph_idx = 0 ; <nl> - FuncOp main_fn = module_ . lookupSymbol < FuncOp > ( " main " ) ; <nl> - subgraph_index_map_ [ main_fn . getName ( ) . str ( ) ] = subgraph_idx + + ; <nl> - named_regions . emplace_back ( " main " , & main_fn . getBody ( ) ) ; <nl> - / / Walk over the module collection ops with functions and while ops . <nl> - module_ . walk ( [ & ] ( FuncOp fn ) { <nl> - if ( fn ! = main_fn ) { <nl> - subgraph_index_map_ [ fn . getName ( ) . str ( ) ] = subgraph_idx + + ; <nl> - named_regions . emplace_back ( fn . getName ( ) . str ( ) , & fn . getBody ( ) ) ; <nl> - } <nl> - } ) ; <nl> - <nl> - / / Build subgraph for each of the named regions . <nl> - std : : vector < BufferOffset < tflite : : SubGraph > > subgraphs ; <nl> - subgraphs . reserve ( named_regions . size ( ) ) ; <nl> - int first_failed_func = - 1 ; <nl> - for ( auto it : llvm : : enumerate ( named_regions ) ) { <nl> - auto subgraph_or = BuildSubGraph ( it . value ( ) . first , it . value ( ) . second ) ; <nl> - if ( ! subgraph_or ) { <nl> - if ( first_failed_func = = - 1 ) <nl> - / / Record the index of the first region that cannot be converted . <nl> - / / Keep looping through all subgraphs in the module to make sure that <nl> - / / we collect the list of missing ops from the entire module . <nl> - first_failed_func = it . index ( ) ; <nl> - } else { <nl> - subgraphs . push_back ( * subgraph_or ) ; <nl> - } <nl> - } <nl> - <nl> - if ( first_failed_func ! = - 1 ) { <nl> - std : : string failed_flex_ops_list = absl : : StrJoin ( failed_flex_ops_ , " \ n \ t " ) ; <nl> - std : : string failed_custom_ops_list = <nl> - absl : : StrJoin ( failed_custom_ops_ , " \ n \ t " ) ; <nl> - std : : string err ; <nl> - if ( ! failed_flex_ops_list . empty ( ) ) <nl> - err + = <nl> - " Ops that can be supported by the flex runtime ( enabled via setting " <nl> - " the - emit - select - tf - ops flag ) : \ n \ t " + <nl> - failed_flex_ops_list ; <nl> - if ( ! failed_custom_ops_list . empty ( ) ) <nl> - err + = <nl> - " Ops that need custom implementation ( enabled via setting the " <nl> - " - emit - custom - ops flag ) : \ n \ t " + <nl> - failed_custom_ops_list ; <nl> - <nl> - auto & failed_region = named_regions [ first_failed_func ] ; <nl> - return failed_region . second - > getParentOp ( ) - > emitError ( ) <nl> - < < " failed while converting : ' " < < failed_region . first <nl> - < < " ' : " < < err , <nl> - llvm : : None ; <nl> - } <nl> - <nl> - std : : string model_description ; <nl> - if ( auto attr = module_ . getAttrOfType < StringAttr > ( " tfl . description " ) ) { <nl> - model_description = attr . getValue ( ) . str ( ) ; <nl> - } else { <nl> - model_description = " MLIR Converted . " ; <nl> - } <nl> - <nl> - / / Build the model and finish the model building process . <nl> - auto description = builder_ . CreateString ( model_description . data ( ) ) ; <nl> - VectorBufferOffset < int32_t > metadata_buffer = 0 ; / / Deprecated <nl> - auto metadata = CreateMetadataVector ( ) ; <nl> - if ( ! metadata ) return llvm : : None ; <nl> - <nl> - auto model = tflite : : CreateModel ( <nl> - builder_ , TFLITE_SCHEMA_VERSION , builder_ . CreateVector ( opcodes_ ) , <nl> - builder_ . CreateVector ( subgraphs ) , description , <nl> - builder_ . CreateVector ( buffers_ ) , metadata_buffer , * metadata ) ; <nl> - tflite : : FinishModelBuffer ( builder_ , model ) ; <nl> - tflite : : UpdateOpVersion ( builder_ . GetBufferPointer ( ) ) ; <nl> - tflite : : UpdateMinimumRuntimeVersionForModel ( builder_ . GetBufferPointer ( ) ) ; <nl> - <nl> - / / Return serialized string for the built FlatBuffer . <nl> - return std : : string ( reinterpret_cast < const char * > ( builder_ . GetBufferPointer ( ) ) , <nl> - builder_ . GetSize ( ) ) ; <nl> - } <nl> - <nl> - } / / namespace <nl> - <nl> - / / Translates the given MLIR module in the TFLite dialect to TFLite FlatBuffer <nl> - / / format . Returns false on success . <nl> - / / <nl> - / / TODO ( hinsu ) : Support all valid MLIR modules in TFLite dialect by supporting <nl> - / / the following : <nl> - / / <nl> - / / * Quantization <nl> - / / * Ops with variable tensors <nl> - / / <nl> - bool tflite : : MlirToFlatBufferTranslateFunction ( <nl> - ModuleOp module , std : : string * serialized_flatbuffer , <nl> - bool emit_builtin_tflite_ops , bool emit_select_tf_ops , bool emit_custom_ops , <nl> - OpOrArgNameMapper * op_or_arg_name_mapper ) { <nl> - auto maybe_translated = <nl> - Translator : : Translate ( module , emit_builtin_tflite_ops , emit_select_tf_ops , <nl> - emit_custom_ops , op_or_arg_name_mapper ) ; <nl> - if ( ! maybe_translated ) return true ; <nl> - * serialized_flatbuffer = std : : move ( * maybe_translated ) ; <nl> - return false ; <nl> - } <nl> - <nl> - bool tflite : : MlirToFlatBufferTranslateFunction ( <nl> - ModuleOp module , std : : string * serialized_flatbuffer , <nl> - bool emit_builtin_tflite_ops , bool emit_select_tf_ops , <nl> - bool emit_custom_ops ) { <nl> - OpOrArgLocNameMapper op_or_arg_name_mapper ; <nl> - return MlirToFlatBufferTranslateFunction ( <nl> - module , serialized_flatbuffer , emit_builtin_tflite_ops , <nl> - emit_select_tf_ops , emit_custom_ops , & op_or_arg_name_mapper ) ; <nl> - } <nl> mmm a / tensorflow / compiler / mlir / lite / flatbuffer_import . cc <nl> ppp b / tensorflow / compiler / mlir / lite / flatbuffer_import . cc <nl> limitations under the License . <nl> # include " mlir / Support / LLVM . h " / / TF : llvm - project <nl> # include " mlir / Translation . h " / / TF : llvm - project <nl> # include " tensorflow / compiler / mlir / lite / flatbuffer_operator . h " <nl> + # include " tensorflow / compiler / mlir / lite / flatbuffer_translate . h " <nl> + # include " tensorflow / compiler / mlir / lite / flatbuffer_translate_flags . h " <nl> # include " tensorflow / compiler / mlir / lite / ir / tfl_ops . h " <nl> # include " tensorflow / compiler / mlir / lite / utils / convert_type . h " <nl> # include " tensorflow / compiler / mlir / tensorflow / ir / tf_ops . h " <nl> # include " tensorflow / compiler / mlir / tensorflow / ir / tf_types . h " <nl> + # include " tensorflow / compiler / mlir / tensorflow / translate / mlir_roundtrip_flags . h " <nl> # include " tensorflow / compiler / mlir / tensorflow / utils / mangling_util . h " <nl> # include " tensorflow / compiler / xla / statusor . h " <nl> # include " tensorflow / core / framework / tensor . pb . h " <nl> # include " tensorflow / core / framework / tensor_shape . pb . h " <nl> + # include " tensorflow / core / lib / core / errors . h " <nl> + # include " tensorflow / core / lib / core / status . h " <nl> # include " tensorflow / core / platform / errors . h " <nl> - # include " tensorflow / core / platform / status . h " <nl> # include " tensorflow / lite / model . h " <nl> # include " tensorflow / lite / schema / schema_generated . h " <nl> <nl> using xla : : StatusOr ; <nl> namespace errors = tensorflow : : errors ; <nl> namespace tfl = mlir : : TFL ; <nl> <nl> + using llvm : : cl : : opt ; <nl> + <nl> + / / Commandline flag to enable the control of flatbuffer import . <nl> + bool use_external_constant ; <nl> + <nl> + / / Commandline flag to enable graph pruning . <nl> + bool experimental_prune_unreachable_nodes_unconditionally ; <nl> + <nl> + / / NOLINTNEXTLINE <nl> + static opt < bool , true > use_external_constant_flag ( <nl> + " use - external - constant " , <nl> + llvm : : cl : : desc ( " Use external constant during flatbuffer import " ) , <nl> + llvm : : cl : : location ( use_external_constant ) , llvm : : cl : : init ( false ) ) ; <nl> + <nl> + / / TODO ( b / 147111261 ) : After the importer supports generic custom ops , we should <nl> + / / change the flag to a more lightwise flag , e . g . <nl> + / / " import_custom_ops_as_side_effect_free_ops " , and let the MLIR DCE to prune <nl> + / / the operations . <nl> + / / NOLINTNEXTLINE <nl> + static opt < bool , true > experimental_prune_unreachable_nodes_unconditionally_flg ( <nl> + " experimental - prune - unreachable - nodes - unconditionally " , <nl> + llvm : : cl : : desc ( " Prune nodes that are not ancestors of the output nodes . " ) , <nl> + llvm : : cl : : location ( experimental_prune_unreachable_nodes_unconditionally ) , <nl> + llvm : : cl : : init ( false ) ) ; <nl> + <nl> + / / NOLINTNEXTLINE <nl> + static opt < std : : string > input_arrays_flag ( <nl> + " input - arrays " , <nl> + llvm : : cl : : desc ( <nl> + " List of input tensors , if different from the default inputs " ) , <nl> + llvm : : cl : : init ( " " ) ) ; <nl> + <nl> + / / NOLINTNEXTLINE <nl> + static opt < std : : string > output_arrays_flag ( <nl> + " output - arrays " , <nl> + llvm : : cl : : desc ( <nl> + " List of output tensors , if different from the default outputs " ) , <nl> + llvm : : cl : : init ( " " ) ) ; <nl> + <nl> namespace { <nl> bool IsScalar ( const TensorT & tensor ) { <nl> / / TODO ( b / 138222071 ) We can ' t distinguish scalars and unranked tensors <nl> OwningModuleRef tflite : : FlatBufferToMlir ( <nl> <nl> return OwningModuleRef ( module ) ; <nl> } <nl> + <nl> + static OwningModuleRef FlatBufferFileToMlirTrans ( <nl> + llvm : : SourceMgr * source_mgr , MLIRContext * context , <nl> + bool use_external_constant , <nl> + bool experimental_prune_unreachable_nodes_unconditionally ) { <nl> + const llvm : : MemoryBuffer * input = <nl> + source_mgr - > getMemoryBuffer ( source_mgr - > getMainFileID ( ) ) ; <nl> + std : : string error ; <nl> + auto loc = <nl> + mlir : : FileLineColLoc : : get ( input - > getBufferIdentifier ( ) , 0 , 0 , context ) ; <nl> + <nl> + / / Parses input / output names from command line options . <nl> + std : : vector < std : : string > inputs ; <nl> + std : : vector < std : : string > outputs ; <nl> + / / Use output parser since we only have tensor names . <nl> + if ( ! tensorflow : : ParseOutputArrayInfo ( input_arrays_flag , & inputs ) . ok ( ) ) { <nl> + return emitError ( loc , " parsing input array info failed " ) <nl> + < < input_arrays_flag , <nl> + nullptr ; <nl> + } <nl> + if ( ! tensorflow : : ParseOutputArrayInfo ( output_arrays_flag , & outputs ) . ok ( ) ) { <nl> + return emitError ( loc , " parsing output array info failed " ) <nl> + < < output_arrays_flag , <nl> + nullptr ; <nl> + } <nl> + <nl> + return tflite : : FlatBufferToMlir ( <nl> + absl : : string_view ( input - > getBufferStart ( ) , input - > getBufferSize ( ) ) , <nl> + context , loc , use_external_constant , inputs , outputs , <nl> + experimental_prune_unreachable_nodes_unconditionally ) ; <nl> + } <nl> + <nl> + static mlir : : TranslateToMLIRRegistration FlatBufferFileToMlirTransReg ( <nl> + " tflite - flatbuffer - to - mlir " , <nl> + [ ] ( llvm : : SourceMgr & source_mgr , MLIRContext * context ) { <nl> + return FlatBufferFileToMlirTrans ( <nl> + & source_mgr , context , use_external_constant , <nl> + experimental_prune_unreachable_nodes_unconditionally ) ; <nl> + } ) ; <nl> mmm a / tensorflow / compiler / mlir / lite / flatbuffer_translate . cc <nl> ppp b / tensorflow / compiler / mlir / lite / flatbuffer_translate . cc <nl> See the License for the specific language governing permissions and <nl> limitations under the License . <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> <nl> + # include " tensorflow / compiler / mlir / lite / flatbuffer_translate . h " <nl> + <nl> + # include < stddef . h > <nl> + # include < stdlib . h > <nl> + <nl> + # include < cstdint > <nl> + # include < memory > <nl> + # include < string > <nl> + # include < utility > <nl> + # include < vector > <nl> + <nl> + # include " absl / base / attributes . h " <nl> + # include " absl / container / flat_hash_map . h " <nl> + # include " absl / container / flat_hash_set . h " <nl> + # include " absl / strings / match . h " <nl> + # include " absl / strings / str_cat . h " <nl> + # include " absl / strings / str_join . h " <nl> + # include " absl / strings / string_view . h " <nl> + # include " flatbuffers / flatbuffers . h " / / TF : flatbuffers <nl> + # include " flatbuffers / flexbuffers . h " / / TF : flatbuffers <nl> + # include " llvm / ADT / ArrayRef . h " <nl> + # include " llvm / ADT / DenseMap . h " <nl> + # include " llvm / ADT / None . h " <nl> + # include " llvm / ADT / Optional . h " <nl> + # include " llvm / ADT / StringRef . h " <nl> # include " llvm / Support / CommandLine . h " <nl> # include " llvm / Support / FormatVariadic . h " <nl> # include " llvm / Support / ToolOutputFile . h " <nl> limitations under the License . <nl> # include " mlir / IR / Value . h " / / TF : llvm - project <nl> # include " mlir / Support / LogicalResult . h " / / TF : llvm - project <nl> # include " mlir / Translation . h " / / TF : llvm - project <nl> - # include " tensorflow / compiler / mlir / lite / flatbuffer_export . h " <nl> - # include " tensorflow / compiler / mlir / lite / flatbuffer_import . h " <nl> - # include " tensorflow / compiler / mlir / tensorflow / translate / mlir_roundtrip_flags . h " <nl> + # include " tensorflow / compiler / mlir / lite / flatbuffer_operator . h " <nl> + # include " tensorflow / compiler / mlir / lite / ir / tfl_ops . h " <nl> + # include " tensorflow / compiler / mlir / lite / utils / convert_type . h " <nl> + # include " tensorflow / compiler / mlir / lite / utils / stateful_ops_utils . h " <nl> + # include " tensorflow / compiler / mlir / op_or_arg_name_mapper . h " <nl> + # include " tensorflow / compiler / mlir / tensorflow / ir / tf_ops . h " <nl> + # include " tensorflow / compiler / mlir / tensorflow / ir / tf_types . h " <nl> + # include " tensorflow / compiler / mlir / tensorflow / translate / export_tf_dialect_op . h " <nl> + # include " tensorflow / compiler / mlir / tensorflow / utils / convert_tensor . h " <nl> + # include " tensorflow / compiler / xla / statusor . h " <nl> + # include " tensorflow / core / framework / attr_value . pb . h " <nl> + # include " tensorflow / core / framework / node_def . pb . h " <nl> + # include " tensorflow / core / framework / tensor . h " <nl> + # include " tensorflow / core / lib / core / errors . h " <nl> + # include " tensorflow / core / lib / core / status . h " <nl> + # include " tensorflow / core / platform / logging . h " <nl> + # include " tensorflow / lite / delegates / flex / whitelisted_flex_ops . h " <nl> + # include " tensorflow / lite / kernels / internal / kernel_utils . h " <nl> + # include " tensorflow / lite / schema / schema_generated . h " <nl> + # include " tensorflow / lite / string_util . h " <nl> + # include " tensorflow / lite / tools / versioning / op_version . h " <nl> + # include " tensorflow / lite / tools / versioning / runtime_version . h " <nl> + # include " tensorflow / lite / version . h " <nl> <nl> - using llvm : : cl : : opt ; <nl> + using llvm : : dyn_cast ; <nl> + using llvm : : formatv ; <nl> + using llvm : : isa ; <nl> + using llvm : : Optional ; <nl> + using llvm : : StringRef ; <nl> + using llvm : : Twine ; <nl> + using mlir : : Dialect ; <nl> + using mlir : : ElementsAttr ; <nl> + using mlir : : FuncOp ; <nl> + using mlir : : MLIRContext ; <nl> + using mlir : : ModuleOp ; <nl> + using mlir : : NoneType ; <nl> + using mlir : : Operation ; <nl> + using mlir : : Region ; <nl> + using mlir : : StringAttr ; <nl> + using mlir : : TensorType ; <nl> + using mlir : : TranslateFromMLIRRegistration ; <nl> + using mlir : : Type ; <nl> + using mlir : : UnknownLoc ; <nl> + using mlir : : Value ; <nl> + using tensorflow : : OpOrArgLocNameMapper ; <nl> + using tensorflow : : OpOrArgNameMapper ; <nl> + using tensorflow : : Status ; <nl> + using tflite : : flex : : IsWhitelistedFlexOp ; <nl> + using xla : : StatusOr ; <nl> <nl> - / / Commandline flag to enable the control of flatbuffer import . <nl> - bool use_external_constant ; <nl> + template < typename T > <nl> + using BufferOffset = flatbuffers : : Offset < T > ; <nl> <nl> - / / Commandline flag to enable graph pruning . <nl> - bool experimental_prune_unreachable_nodes_unconditionally ; <nl> + template < typename T > <nl> + using VectorBufferOffset = flatbuffers : : Offset < flatbuffers : : Vector < T > > ; <nl> <nl> - / / NOLINTNEXTLINE <nl> - static opt < bool , true > use_external_constant_flag ( <nl> - " use - external - constant " , <nl> - llvm : : cl : : desc ( " Use external constant during flatbuffer import " ) , <nl> - llvm : : cl : : location ( use_external_constant ) , llvm : : cl : : init ( false ) ) ; <nl> - <nl> - / / TODO ( b / 147111261 ) : After the importer supports generic custom ops , we should <nl> - / / change the flag to a more lightwise flag , e . g . <nl> - / / " import_custom_ops_as_side_effect_free_ops " , and let the MLIR DCE to prune <nl> - / / the operations . <nl> - / / NOLINTNEXTLINE <nl> - static opt < bool , true > experimental_prune_unreachable_nodes_unconditionally_flg ( <nl> - " experimental - prune - unreachable - nodes - unconditionally " , <nl> - llvm : : cl : : desc ( " Prune nodes that are not ancestors of the output nodes . " ) , <nl> - llvm : : cl : : location ( experimental_prune_unreachable_nodes_unconditionally ) , <nl> - llvm : : cl : : init ( false ) ) ; <nl> + using CustomOptionsOffset = VectorBufferOffset < uint8_t > ; <nl> <nl> - / / NOLINTNEXTLINE <nl> - static opt < std : : string > input_arrays_flag ( <nl> - " input - arrays " , <nl> - llvm : : cl : : desc ( <nl> - " List of input tensors , if different from the default inputs " ) , <nl> - llvm : : cl : : init ( " " ) ) ; <nl> + namespace error = tensorflow : : error ; <nl> + namespace tfl = mlir : : TFL ; <nl> <nl> - / / NOLINTNEXTLINE <nl> - static opt < std : : string > output_arrays_flag ( <nl> - " output - arrays " , <nl> - llvm : : cl : : desc ( <nl> - " List of output tensors , if different from the default outputs " ) , <nl> - llvm : : cl : : init ( " " ) ) ; <nl> using llvm : : cl : : opt ; <nl> <nl> / / These command line flags enable control of the translation implementation . <nl> static opt < bool , true > strip_debug_info_flag ( <nl> " strip - debug - info " , llvm : : cl : : desc ( " Strip debug info during export " ) , <nl> llvm : : cl : : location ( strip_debug_info ) , llvm : : cl : : init ( false ) ) ; <nl> <nl> - namespace mlir { <nl> + ABSL_CONST_INIT const absl : : string_view kFlexOpNamePrefix = " Flex " ; <nl> + <nl> + / / Use initial buffer size in flatbuffer builder to be same as the initial size <nl> + / / used by the TOCO export . ( It does not explain rationale for this choice . ) <nl> + constexpr size_t kInitialBufferSize = 10240 ; <nl> + <nl> + / / Set ` isSigned ` to false if the ` type ` is an 8 - bit unsigned integer type . <nl> + / / Since tflite doesn ' t support unsigned for other types , returns error if <nl> + / / ` isSigned ` is set to false for other types . <nl> + static StatusOr < tflite : : TensorType > GetTFLiteType ( Type type , <nl> + bool is_signed = true ) { <nl> + if ( ! is_signed & & type . isSignlessInteger ( 8 ) ) { <nl> + return tflite : : TensorType_UINT8 ; <nl> + } <nl> + if ( ! is_signed ) { <nl> + return Status ( error : : INVALID_ARGUMENT , <nl> + " ' isSigned ' can only be set for 8 - bits integer type " ) ; <nl> + } <nl> + switch ( type . getKind ( ) ) { <nl> + case mlir : : StandardTypes : : F32 : <nl> + return tflite : : TensorType_FLOAT32 ; <nl> + case mlir : : StandardTypes : : F16 : <nl> + return tflite : : TensorType_FLOAT16 ; <nl> + case mlir : : TF : : TensorFlowTypes : : STRING : <nl> + return tflite : : TensorType_STRING ; <nl> + case mlir : : TF : : TensorFlowTypes : : QUINT8 : <nl> + return tflite : : TensorType_UINT8 ; <nl> + case mlir : : StandardTypes : : Complex : { <nl> + auto ftype = type . cast < mlir : : ComplexType > ( ) . getElementType ( ) ; <nl> + if ( ftype & & ftype . isF32 ( ) ) { <nl> + return tflite : : TensorType_COMPLEX64 ; <nl> + } <nl> + return Status ( error : : INVALID_ARGUMENT , " Unsupported type " ) ; <nl> + } <nl> + case mlir : : StandardTypes : : Integer : { <nl> + const auto & itype = type . cast < mlir : : IntegerType > ( ) ; <nl> + switch ( itype . getWidth ( ) ) { <nl> + case 1 : <nl> + return tflite : : TensorType_BOOL ; <nl> + case 8 : <nl> + return itype . isUnsigned ( ) ? tflite : : TensorType_UINT8 <nl> + : tflite : : TensorType_INT8 ; <nl> + case 16 : <nl> + return tflite : : TensorType_INT16 ; <nl> + case 32 : <nl> + return tflite : : TensorType_INT32 ; <nl> + case 64 : <nl> + return tflite : : TensorType_INT64 ; <nl> + } <nl> + } <nl> + case mlir : : quant : : QuantizationTypes : : UniformQuantized : { <nl> + auto qtype = type . cast < mlir : : quant : : UniformQuantizedType > ( ) ; <nl> + return GetTFLiteType ( qtype . getStorageType ( ) , qtype . isSigned ( ) ) ; <nl> + } <nl> + case mlir : : quant : : QuantizationTypes : : UniformQuantizedPerAxis : { <nl> + auto qtype = type . cast < mlir : : quant : : UniformQuantizedPerAxisType > ( ) ; <nl> + return GetTFLiteType ( qtype . getStorageType ( ) , qtype . isSigned ( ) ) ; <nl> + } <nl> + case mlir : : TF : : TensorFlowTypes : : RESOURCE : { <nl> + / / Treat tf . resource values as integer values in flatbuffer . <nl> + / / TODO ( b / 146131919 ) : Maybe need to have a detailed design for supporting <nl> + / / other resource types beyonds hash table resources and resource <nl> + / / variables . <nl> + return tflite : : TensorType_INT32 ; <nl> + } <nl> + default : <nl> + / / TFLite export fills FLOAT32 for unknown data types . Returning an error <nl> + / / for now for safety and this could be revisited when required . <nl> + return Status ( error : : INVALID_ARGUMENT , " Unsupported type " ) ; <nl> + } <nl> + } <nl> + <nl> + static bool IsConst ( Operation * op ) { <nl> + return isa < mlir : : ConstantOp > ( op ) | | isa < mlir : : TF : : ConstOp > ( op ) | | <nl> + isa < tfl : : ConstOp > ( op ) | | isa < tfl : : QConstOp > ( op ) ; <nl> + } <nl> + <nl> + template < typename T > <nl> + static bool HasValidTFLiteType ( Value value , T & error_handler ) { <nl> + / / None type is allowed to represent unspecified operands . <nl> + if ( value . getType ( ) . isa < NoneType > ( ) ) return true ; <nl> + <nl> + auto type = value . getType ( ) . dyn_cast < TensorType > ( ) ; <nl> + if ( ! type ) { <nl> + if ( auto op = value . getDefiningOp ( ) ) { <nl> + error_handler . emitError ( ) <nl> + < < ' \ ' ' < < op < < " ' should produce value of tensor type instead of " <nl> + < < value . getType ( ) ; <nl> + return false ; <nl> + } <nl> + error_handler . emitError ( " expected tensor type , got " ) < < value . getType ( ) ; <nl> + return false ; <nl> + } <nl> + <nl> + Type element_type = type . getElementType ( ) ; <nl> + auto status = GetTFLiteType ( element_type ) ; <nl> + if ( ! status . ok ( ) ) { <nl> + return error_handler . emitError ( <nl> + formatv ( " Failed to convert element type ' { 0 } ' : { 1 } " , <nl> + element_type , status . status ( ) . error_message ( ) ) ) , <nl> + false ; <nl> + } <nl> + return true ; <nl> + } <nl> + <nl> + / / Returns true if the module holds all the invariants expected by the <nl> + / / Translator class . <nl> + / / TODO ( hinsu ) : Now that translation is done by making a single pass over the <nl> + / / MLIR module , consider inlining these validation checks at the place where <nl> + / / these invariants are assumed instead of checking upfront . <nl> + static bool IsValidTFLiteMlirModule ( ModuleOp module ) { <nl> + MLIRContext * context = module . getContext ( ) ; <nl> + <nl> + / / Verify that module has a function named main . <nl> + FuncOp main_fn = module . lookupSymbol < FuncOp > ( " main " ) ; <nl> + if ( ! main_fn ) { <nl> + return emitError ( UnknownLoc : : get ( context ) , <nl> + " should have a function named ' main ' " ) , <nl> + false ; <nl> + } <nl> + <nl> + for ( auto fn : module . getOps < FuncOp > ( ) ) { <nl> + if ( fn . getBlocks ( ) . size ( ) ! = 1 ) { <nl> + return fn . emitError ( " should have exactly one basic block " ) , false ; <nl> + } <nl> + auto & bb = fn . getBlocks ( ) . front ( ) ; <nl> + <nl> + for ( auto arg : bb . getArguments ( ) ) { <nl> + if ( ! HasValidTFLiteType ( arg , fn ) ) <nl> + return fn . emitError ( " invalid TFLite type : " ) < < arg . getType ( ) , false ; <nl> + } <nl> + <nl> + / / Verify that all operations except the terminator have exactly one <nl> + / / result of type supported by TFLite . <nl> + for ( auto & inst : bb ) { <nl> + if ( inst . isKnownTerminator ( ) ) break ; <nl> + <nl> + for ( auto result : inst . getResults ( ) ) { <nl> + if ( ! HasValidTFLiteType ( result , inst ) ) <nl> + return fn . emitError ( " invalid TFLite type : " ) < < result . getType ( ) , <nl> + false ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + static std : : unique_ptr < : : tensorflow : : NodeDef > GetTensorFlowNodeDef ( <nl> + : : mlir : : Operation * inst ) { <nl> + / / We pass empty string for the original node_def name since Flex runtime <nl> + / / does not care about this being set correctly on node_def . There is no <nl> + / / " easy " ( see b / 120948529 ) way yet to get this from MLIR inst . <nl> + auto status_or_node_def = tensorflow : : ConvertTFDialectOpToNodeDef ( <nl> + inst , / * name = * / " " , / * ignore_unregistered_attrs = * / true ) ; <nl> + if ( ! status_or_node_def . ok ( ) ) { <nl> + inst - > emitOpError ( <nl> + Twine ( " failed to obtain TensorFlow nodedef with status : " + <nl> + status_or_node_def . status ( ) . ToString ( ) ) ) ; <nl> + return { } ; <nl> + } <nl> + return std : : move ( status_or_node_def . ValueOrDie ( ) ) ; <nl> + } <nl> + <nl> + / / Converts a mlir padding StringRef to TfLitePadding . <nl> + / / Returns llvm : : None if conversion fails . <nl> + static Optional < TfLitePadding > GetTflitePadding ( Operation * inst , <nl> + llvm : : StringRef padding ) { <nl> + const tflite : : Padding padding_attr = <nl> + std : : move ( llvm : : StringSwitch < tflite : : Padding > ( padding ) <nl> + . Case ( " SAME " , tflite : : Padding_SAME ) <nl> + . Case ( " VALID " , tflite : : Padding_VALID ) ) ; <nl> + if ( padding_attr = = tflite : : Padding_SAME ) { <nl> + return kTfLitePaddingSame ; <nl> + } <nl> + if ( padding_attr = = tflite : : Padding_VALID ) { <nl> + return kTfLitePaddingValid ; <nl> + } <nl> + <nl> + return inst - > emitOpError ( ) < < " Invalid padding attribute : " < < padding , <nl> + llvm : : None ; <nl> + } <nl> + <nl> + / / Extracts TfLitePoolParams from a TFL custom op . <nl> + / / Template parameter , TFLOp , should be a TFL custom op containing attributes <nl> + / / generated from TfLitePoolParams . <nl> + / / Returns llvm : : None if conversion fails . <nl> + template < typename TFLOp > <nl> + static Optional < TfLitePoolParams > GetTflitePoolParams ( Operation * inst , <nl> + TFLOp op ) { <nl> + TfLitePoolParams pool_params ; <nl> + pool_params . stride_height = op . stride_h ( ) . getSExtValue ( ) ; <nl> + pool_params . stride_width = op . stride_w ( ) . getSExtValue ( ) ; <nl> + pool_params . filter_height = op . filter_h ( ) . getSExtValue ( ) ; <nl> + pool_params . filter_width = op . filter_w ( ) . getSExtValue ( ) ; <nl> + const auto padding = GetTflitePadding ( inst , op . padding ( ) ) ; <nl> + if ( padding ) { <nl> + pool_params . padding = * padding ; <nl> + pool_params . activation = kTfLiteActNone ; <nl> + pool_params . computed . padding = TfLitePaddingValues { 0 , 0 , 0 , 0 } ; <nl> + return pool_params ; <nl> + } <nl> + <nl> + return llvm : : None ; <nl> + } <nl> + <nl> namespace { <nl> - static OwningModuleRef FlatBufferFileToMlirTrans ( <nl> - llvm : : SourceMgr * source_mgr , MLIRContext * context , <nl> - bool use_external_constant , <nl> - bool experimental_prune_unreachable_nodes_unconditionally ) { <nl> - const llvm : : MemoryBuffer * input = <nl> - source_mgr - > getMemoryBuffer ( source_mgr - > getMainFileID ( ) ) ; <nl> - std : : string error ; <nl> - auto loc = <nl> - mlir : : FileLineColLoc : : get ( input - > getBufferIdentifier ( ) , 0 , 0 , context ) ; <nl> - <nl> - / / Parses input / output names from command line options . <nl> - std : : vector < std : : string > inputs ; <nl> - std : : vector < std : : string > outputs ; <nl> - / / Use output parser since we only have tensor names . <nl> - if ( ! tensorflow : : ParseOutputArrayInfo ( input_arrays_flag , & inputs ) . ok ( ) ) { <nl> - return emitError ( loc , " parsing input array info failed " ) <nl> - < < input_arrays_flag , <nl> - nullptr ; <nl> - } <nl> - if ( ! tensorflow : : ParseOutputArrayInfo ( output_arrays_flag , & outputs ) . ok ( ) ) { <nl> - return emitError ( loc , " parsing output array info failed " ) <nl> - < < output_arrays_flag , <nl> - nullptr ; <nl> - } <nl> - return tflite : : FlatBufferToMlir ( <nl> - absl : : string_view ( input - > getBufferStart ( ) , input - > getBufferSize ( ) ) , <nl> - context , loc , use_external_constant , inputs , outputs , <nl> - experimental_prune_unreachable_nodes_unconditionally ) ; <nl> - } <nl> - <nl> - static LogicalResult MlirToFlatBufferFileTranslateFunction ( <nl> + <nl> + / / Translates an MLIR module in TFLite dialect to TFLite FlatBuffer . <nl> + class Translator { <nl> + public : <nl> + / / Translates the given MLIR module into TFLite FlatBuffer format and returns <nl> + / / the serialized output . Returns llvm : : None on unsupported , invalid inputs or <nl> + / / internal error . <nl> + static Optional < std : : string > Translate ( <nl> + ModuleOp module , bool emit_builtin_tflite_ops , bool emit_select_tf_ops , <nl> + bool emit_custom_ops , OpOrArgNameMapper * op_or_arg_name_mapper ) ; <nl> + <nl> + private : <nl> + enum class OpType : char { kTfliteBuiltin , kSelectTf , kCustomOp } ; <nl> + explicit Translator ( ModuleOp module , bool emit_builtin_tflite_ops , <nl> + bool emit_select_tf_ops , bool emit_custom_ops , <nl> + OpOrArgNameMapper * op_or_arg_name_mapper ) <nl> + : module_ ( module ) , <nl> + name_mapper_ ( * op_or_arg_name_mapper ) , <nl> + builder_ ( kInitialBufferSize ) { <nl> + / / The first buffer must be empty according to the schema definition . <nl> + empty_buffer_ = tflite : : CreateBuffer ( builder_ ) ; <nl> + buffers_ . push_back ( empty_buffer_ ) ; <nl> + if ( emit_builtin_tflite_ops ) { <nl> + enabled_op_types_ . emplace ( OpType : : kTfliteBuiltin ) ; <nl> + } <nl> + if ( emit_select_tf_ops ) { <nl> + enabled_op_types_ . emplace ( OpType : : kSelectTf ) ; <nl> + } <nl> + if ( emit_custom_ops ) { <nl> + enabled_op_types_ . emplace ( OpType : : kCustomOp ) ; <nl> + } <nl> + tf_dialect_ = module . getContext ( ) - > getRegisteredDialect ( " tf " ) ; <nl> + tfl_dialect_ = module . getContext ( ) - > getRegisteredDialect ( " tfl " ) ; <nl> + } <nl> + <nl> + Optional < std : : string > TranslateInternal ( ) ; <nl> + <nl> + / / Returns TFLite buffer populated with constant value if the operation is <nl> + / / TFLite constant operation . Otherwise , returns an empty buffer . Emits error <nl> + / / and returns llvm : : None on failure . <nl> + Optional < BufferOffset < tflite : : Buffer > > BuildBuffer ( Operation * inst ) ; <nl> + <nl> + / / Build TFLite tensor from the given type . This function is for tfl . lstm <nl> + / / intermediates , which should have UniformQuantizedType . <nl> + Optional < BufferOffset < tflite : : Tensor > > BuildTensorFromType ( <nl> + mlir : : Type type , const std : : string & name ) ; <nl> + <nl> + / / Builds TFLite tensor from the given value . ` buffer_idx ` is index of the <nl> + / / corresponding buffer . Emits error and returns llvm : : None on failure . <nl> + Optional < BufferOffset < tflite : : Tensor > > BuildTensor ( Value value , <nl> + const std : : string & name , <nl> + unsigned buffer_idx ) ; <nl> + <nl> + / / TODO ( b / 137395003 ) : Legalize control flow ops to TFLite dialect , and remove <nl> + / / these 2 functions here . <nl> + BufferOffset < tflite : : Operator > BuildIfOperator ( <nl> + mlir : : TF : : IfOp op , const std : : vector < int32_t > & operands , <nl> + const std : : vector < int32_t > & results ) ; <nl> + BufferOffset < tflite : : Operator > BuildWhileOperator ( <nl> + mlir : : TF : : WhileOp op , const std : : vector < int32_t > & operands , <nl> + const std : : vector < int32_t > & results ) ; <nl> + <nl> + / / Build while operator where cond & body are regions . <nl> + Optional < BufferOffset < tflite : : Operator > > BuildWhileOperator ( <nl> + mlir : : TFL : : WhileOp op , const std : : vector < int32_t > & operands , <nl> + const std : : vector < int32_t > & results ) ; <nl> + <nl> + / / Builds custom operators . <nl> + / / Templated on a ) data type of custom_option to be stored into flatbuffer , <nl> + / / and b ) TFL custom op type . <nl> + template < typename CustomOptionType , typename TFLOp > <nl> + BufferOffset < tflite : : Operator > BuildCustomOperator ( <nl> + const CustomOptionType & custom_option , const std : : string & opcode_name , <nl> + TFLOp op , const std : : vector < int32_t > & operands , <nl> + const std : : vector < int32_t > & results ) ; <nl> + <nl> + BufferOffset < tflite : : Operator > BuildNumericVerifyOperator ( <nl> + mlir : : TFL : : NumericVerifyOp op , const std : : vector < int32_t > & operands , <nl> + const std : : vector < int32_t > & results ) ; <nl> + Optional < BufferOffset < tflite : : Operator > > <nl> + BuildConvolution2DTransposeBiasOperator ( <nl> + Operation * inst , mlir : : TFL : : Convolution2DTransposeBiasOp op , <nl> + const std : : vector < int32_t > & operands , <nl> + const std : : vector < int32_t > & results ) ; <nl> + Optional < BufferOffset < tflite : : Operator > > BuildMaxPoolingWithArgMax2DOperator ( <nl> + Operation * inst , mlir : : TFL : : MaxPoolingWithArgMax2DOp op , <nl> + const std : : vector < int32_t > & operands , <nl> + const std : : vector < int32_t > & results ) ; <nl> + Optional < BufferOffset < tflite : : Operator > > BuildMaxUnpooling2DOperator ( <nl> + Operation * inst , mlir : : TFL : : MaxUnpooling2DOp op , <nl> + const std : : vector < int32_t > & operands , <nl> + const std : : vector < int32_t > & results ) ; <nl> + <nl> + Optional < CustomOptionsOffset > CreateFlexOpCustomOptions ( <nl> + const : : tensorflow : : NodeDef & node_def , const mlir : : Location & loc ) ; <nl> + <nl> + Optional < CustomOptionsOffset > CreateCustomOpCustomOptions ( <nl> + const : : tensorflow : : NodeDef & node_def , const mlir : : Location & loc ) ; <nl> + <nl> + std : : unique_ptr < flexbuffers : : Builder > CreateFlexBuilderWithNodeAttrs ( <nl> + const : : tensorflow : : NodeDef & node_def , const mlir : : Location & loc ) ; <nl> + <nl> + / / Returns opcode index for op identified by the op_name , if already <nl> + / / available . Otherwise , creates a new OperatorCode using the given ` builtin ` <nl> + / / operator and associates it with ` op_name ` . <nl> + uint32_t GetOpcodeIndex ( const std : : string & op_name , <nl> + tflite : : BuiltinOperator builtin ) ; <nl> + <nl> + / / Builds operator for the given operation with specified operand and result <nl> + / / tensor indices . Emits an error and returns llvm : : None on failure . <nl> + Optional < BufferOffset < tflite : : Operator > > BuildOperator ( <nl> + Operation * inst , const std : : vector < int32_t > & operands , <nl> + const std : : vector < int32_t > & results , <nl> + const std : : vector < int32_t > & intermediates ) ; <nl> + <nl> + / / Build a subgraph with a given name out of the region either corresponding <nl> + / / to a function ' s body or while op . <nl> + Optional < BufferOffset < tflite : : SubGraph > > BuildSubGraph ( <nl> + const std : : string & name , Region * region ) ; <nl> + <nl> + / / Builds Metadata with the given ` name ` and buffer ` content ` . <nl> + BufferOffset < tflite : : Metadata > BuildMetadata ( StringRef name , <nl> + StringRef content ) ; <nl> + <nl> + / / Encodes the ` tfl . metadata ` dictionary attribute of the module to the <nl> + / / metadata section in the final model . <nl> + Optional < VectorBufferOffset < BufferOffset < tflite : : Metadata > > > <nl> + CreateMetadataVector ( ) ; <nl> + <nl> + / / Uses the tf . entry_function attribute ( if set ) to initialize the op to name <nl> + / / mapping . <nl> + void InitializeNamesFromAttribute ( FuncOp fn , bool * has_input_attr ) ; <nl> + <nl> + / / Determines if the specified operation op ' s operand at operand_index <nl> + / / is marked as a stateful operand . <nl> + bool IsStatefulOperand ( mlir : : Operation * op , int operand_index ) ; <nl> + <nl> + / / Returns a unique name for ` val ` . <nl> + std : : string UniqueName ( mlir : : Value val ) ; <nl> + <nl> + ModuleOp module_ ; <nl> + <nl> + tensorflow : : OpOrArgNameMapper & name_mapper_ ; <nl> + <nl> + flatbuffers : : FlatBufferBuilder builder_ ; <nl> + BufferOffset < tflite : : Buffer > empty_buffer_ ; <nl> + <nl> + std : : vector < BufferOffset < tflite : : Buffer > > buffers_ ; <nl> + <nl> + / / Maps op name to index of the corresponding OperatorCode in opcodes_ vector . <nl> + absl : : flat_hash_map < std : : string , uint32_t > opcode_index_map_ ; <nl> + std : : vector < BufferOffset < tflite : : OperatorCode > > opcodes_ ; <nl> + <nl> + / / Maps function name to index of the corresponding subgraph in the FlatBuffer <nl> + / / model . <nl> + absl : : flat_hash_map < std : : string , int > subgraph_index_map_ ; <nl> + absl : : flat_hash_set < OpType > enabled_op_types_ ; <nl> + <nl> + / / Points to TensorFlow and TFLite dialects , respectively . nullptr if the <nl> + / / dialect is not registered . <nl> + const Dialect * tf_dialect_ ; <nl> + const Dialect * tfl_dialect_ ; <nl> + <nl> + / / The failed ops during legalization . <nl> + std : : set < std : : string > failed_flex_ops_ ; <nl> + std : : set < std : : string > failed_custom_ops_ ; <nl> + } ; <nl> + <nl> + std : : string Translator : : UniqueName ( mlir : : Value val ) { <nl> + return std : : string ( name_mapper_ . GetUniqueName ( val ) ) ; <nl> + } <nl> + <nl> + Optional < BufferOffset < tflite : : Buffer > > Translator : : BuildBuffer ( <nl> + Operation * inst ) { <nl> + ElementsAttr attr ; <nl> + if ( auto cst = dyn_cast < mlir : : ConstantOp > ( inst ) ) { <nl> + / / ConstantOp have ElementAttr at this point due to validation of the TFLite <nl> + / / module . <nl> + attr = cst . getValue ( ) . cast < ElementsAttr > ( ) ; <nl> + } else if ( auto cst = dyn_cast < mlir : : TF : : ConstOp > ( inst ) ) { <nl> + attr = cst . value ( ) ; <nl> + } else if ( auto cst = dyn_cast < tfl : : ConstOp > ( inst ) ) { <nl> + attr = cst . value ( ) ; <nl> + } else if ( auto cst = dyn_cast < tfl : : QConstOp > ( inst ) ) { <nl> + attr = cst . value ( ) ; <nl> + } else if ( auto cst = dyn_cast < tfl : : SparseConstOp > ( inst ) ) { <nl> + attr = cst . value ( ) ; <nl> + } else if ( auto cst = dyn_cast < tfl : : SparseQConstOp > ( inst ) ) { <nl> + attr = cst . value ( ) ; <nl> + } else { <nl> + return empty_buffer_ ; <nl> + } <nl> + <nl> + tensorflow : : Tensor tensor ; <nl> + auto status = tensorflow : : ConvertToTensor ( attr , & tensor ) ; <nl> + if ( ! status . ok ( ) ) { <nl> + inst - > emitError ( <nl> + Twine ( " failed to convert value attribute to tensor with error : " + <nl> + status . ToString ( ) ) ) ; <nl> + return llvm : : None ; <nl> + } <nl> + <nl> + / / TensorFlow and TensorFlow Lite use different string encoding formats . <nl> + / / Convert to TensorFlow Lite format is it ' s a constant string tensor . <nl> + if ( tensor . dtype ( ) = = tensorflow : : DT_STRING ) { <nl> + : : tflite : : DynamicBuffer dynamic_buffer ; <nl> + auto flat = tensor . flat < : : tensorflow : : tstring > ( ) ; <nl> + for ( int i = 0 ; i < flat . size ( ) ; + + i ) { <nl> + const auto & str = flat ( i ) ; <nl> + dynamic_buffer . AddString ( str . c_str ( ) , str . length ( ) ) ; <nl> + } <nl> + char * tensor_buffer ; <nl> + int bytes = dynamic_buffer . WriteToBuffer ( & tensor_buffer ) ; <nl> + auto buffer_data = <nl> + builder_ . CreateVector ( reinterpret_cast < uint8_t * > ( tensor_buffer ) , bytes ) ; <nl> + free ( tensor_buffer ) ; <nl> + return tflite : : CreateBuffer ( builder_ , buffer_data ) ; <nl> + } <nl> + <nl> + absl : : string_view tensor_data = tensor . tensor_data ( ) ; <nl> + auto buffer_data = builder_ . CreateVector ( <nl> + reinterpret_cast < const uint8_t * > ( tensor_data . data ( ) ) , tensor_data . size ( ) ) ; <nl> + return tflite : : CreateBuffer ( builder_ , buffer_data ) ; <nl> + } <nl> + <nl> + Optional < BufferOffset < tflite : : Tensor > > Translator : : BuildTensorFromType ( <nl> + mlir : : Type type , const std : : string & name ) { <nl> + auto tensor_type = type . cast < TensorType > ( ) ; <nl> + <nl> + if ( ! tensor_type . hasStaticShape ( ) ) { <nl> + return llvm : : None ; <nl> + } <nl> + llvm : : ArrayRef < int64_t > shape_ref = tensor_type . getShape ( ) ; <nl> + std : : vector < int32_t > shape ( shape_ref . begin ( ) , shape_ref . end ( ) ) ; <nl> + <nl> + auto element_type = tensor_type . getElementType ( ) ; <nl> + tflite : : TensorType tflite_element_type = <nl> + GetTFLiteType ( tensor_type . getElementType ( ) ) . ValueOrDie ( ) ; <nl> + BufferOffset < tflite : : QuantizationParameters > q_params ; <nl> + auto qtype = element_type . dyn_cast < mlir : : quant : : UniformQuantizedType > ( ) ; <nl> + if ( ! qtype ) { <nl> + return llvm : : None ; <nl> + } <nl> + q_params = tflite : : CreateQuantizationParameters ( <nl> + builder_ , / * min = * / 0 , / * max = * / 0 , <nl> + builder_ . CreateVector < float > ( { static_cast < float > ( qtype . getScale ( ) ) } ) , <nl> + builder_ . CreateVector < int64_t > ( { qtype . getZeroPoint ( ) } ) ) ; <nl> + return tflite : : CreateTensor ( <nl> + builder_ , builder_ . CreateVector ( shape ) , tflite_element_type , <nl> + / * buffer = * / 0 , builder_ . CreateString ( name ) , q_params , <nl> + / * is_variable = * / false ) ; <nl> + } <nl> + <nl> + Optional < BufferOffset < tflite : : Tensor > > Translator : : BuildTensor ( <nl> + Value value , const std : : string & name , unsigned buffer_idx ) { <nl> + auto type = value . getType ( ) . cast < TensorType > ( ) ; <nl> + <nl> + / / TFLite requires tensor shape only for the inputs and constants . <nl> + / / However , we output all known shapes for better round - tripping <nl> + auto check_shape = <nl> + [ & ] ( llvm : : ArrayRef < int64_t > shape_ref ) - > mlir : : LogicalResult { <nl> + auto is_out_of_range = [ ] ( int64_t dim ) { <nl> + return dim > std : : numeric_limits < int32_t > : : max ( ) ; <nl> + } ; <nl> + <nl> + if ( std : : any_of ( shape_ref . begin ( ) , shape_ref . end ( ) , is_out_of_range ) ) <nl> + return mlir : : emitError ( <nl> + value . getLoc ( ) , <nl> + " result shape dimensions out of 32 bit int type range " ) ; <nl> + <nl> + return mlir : : success ( ) ; <nl> + } ; <nl> + <nl> + std : : vector < int32_t > shape ; <nl> + std : : vector < int32_t > shape_signature ; <nl> + if ( type . hasStaticShape ( ) ) { <nl> + llvm : : ArrayRef < int64_t > shape_ref = type . getShape ( ) ; <nl> + if ( mlir : : failed ( check_shape ( shape_ref ) ) ) return llvm : : None ; <nl> + <nl> + shape = std : : vector < int32_t > ( shape_ref . begin ( ) , shape_ref . end ( ) ) ; <nl> + } else if ( auto * inst = value . getDefiningOp ( ) ) { <nl> + if ( IsConst ( inst ) ) { <nl> + / / Const op can have a result of dynamic shaped type ( e . g . due to constant <nl> + / / folding ) , but we can still derive the shape of a constant tensor for <nl> + / / its attribute type . <nl> + mlir : : Attribute tensor_attr = inst - > getAttr ( " value " ) ; <nl> + llvm : : ArrayRef < int64_t > shape_ref = <nl> + tensor_attr . getType ( ) . cast < TensorType > ( ) . getShape ( ) ; <nl> + if ( mlir : : failed ( check_shape ( shape_ref ) ) ) return llvm : : None ; <nl> + <nl> + shape = std : : vector < int32_t > ( shape_ref . begin ( ) , shape_ref . end ( ) ) ; <nl> + } <nl> + } else if ( type . hasRank ( ) ) { <nl> + llvm : : ArrayRef < int64_t > shape_ref = type . getShape ( ) ; <nl> + if ( mlir : : failed ( check_shape ( shape_ref ) ) ) return llvm : : None ; <nl> + <nl> + shape . reserve ( shape_ref . size ( ) ) ; <nl> + for ( auto & dim : shape_ref ) { <nl> + shape . push_back ( dim = = - 1 ? 1 : dim ) ; <nl> + } <nl> + shape_signature = std : : vector < int32_t > ( shape_ref . begin ( ) , shape_ref . end ( ) ) ; <nl> + } <nl> + <nl> + if ( auto * inst = value . getDefiningOp ( ) ) { <nl> + if ( auto cst = dyn_cast < tfl : : SparseConstOp > ( inst ) ) { <nl> + / / CreateSparsityParameters ( cst . s_param ( ) ) ; <nl> + } else if ( auto cst = dyn_cast < tfl : : SparseQConstOp > ( inst ) ) { <nl> + / / CreateSparsityParameters ( cst . s_param ( ) ) ; <nl> + } <nl> + } <nl> + <nl> + Type element_type = type . getElementType ( ) ; <nl> + tflite : : TensorType tflite_element_type = <nl> + GetTFLiteType ( type . getElementType ( ) ) . ValueOrDie ( ) ; <nl> + <nl> + BufferOffset < tflite : : QuantizationParameters > q_params ; <nl> + if ( auto qtype = element_type . dyn_cast < mlir : : quant : : UniformQuantizedType > ( ) ) { <nl> + q_params = tflite : : CreateQuantizationParameters ( <nl> + / / TODO ( fengliuai ) : min and max values are not stored in the <nl> + / / quantized type , so both are set to 0 . The model couldn ' t be imported <nl> + / / to TensorFlow because of this . <nl> + builder_ , / * min = * / 0 , / * max = * / 0 , <nl> + builder_ . CreateVector < float > ( { static_cast < float > ( qtype . getScale ( ) ) } ) , <nl> + builder_ . CreateVector < int64_t > ( { qtype . getZeroPoint ( ) } ) ) ; <nl> + } else if ( auto qtype = <nl> + element_type <nl> + . dyn_cast < mlir : : quant : : UniformQuantizedPerAxisType > ( ) ) { <nl> + std : : vector < float > scales ( qtype . getScales ( ) . begin ( ) , <nl> + qtype . getScales ( ) . end ( ) ) ; <nl> + q_params = tflite : : CreateQuantizationParameters ( <nl> + builder_ , / * min = * / 0 , / * max = * / 0 , builder_ . CreateVector < float > ( scales ) , <nl> + builder_ . CreateVector < int64_t > ( qtype . getZeroPoints ( ) ) , <nl> + tflite : : QuantizationDetails_NONE , / * details = * / 0 , <nl> + qtype . getQuantizedDimension ( ) ) ; <nl> + } else { <nl> + q_params = tflite : : CreateQuantizationParameters ( builder_ ) ; <nl> + } <nl> + / / Check if the value ' s uses includes an op and usage at an operand index <nl> + / / marked as a stateful . If so , set the tensor ' s is_variable as true <nl> + / / This is v1 ref variable semantics in the TFLite runtime . <nl> + bool is_variable = false ; <nl> + for ( auto & use : value . getUses ( ) ) { <nl> + is_variable = IsStatefulOperand ( use . getOwner ( ) , use . getOperandNumber ( ) ) ; <nl> + if ( is_variable ) { <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + if ( shape_signature . empty ( ) ) { <nl> + return tflite : : CreateTensor ( <nl> + builder_ , builder_ . CreateVector ( shape ) , tflite_element_type , <nl> + ( is_variable ? 0 : buffer_idx ) , builder_ . CreateString ( name ) , q_params , <nl> + / * is_variable = * / is_variable ) ; <nl> + } else { <nl> + return tflite : : CreateTensor ( <nl> + builder_ , builder_ . CreateVector ( shape ) , tflite_element_type , <nl> + ( is_variable ? 0 : buffer_idx ) , builder_ . CreateString ( name ) , q_params , <nl> + / * is_variable = * / is_variable , / * sparsity = * / 0 , <nl> + / * shape_signature = * / builder_ . CreateVector ( shape_signature ) ) ; <nl> + } <nl> + } <nl> + <nl> + BufferOffset < tflite : : Operator > Translator : : BuildIfOperator ( <nl> + mlir : : TF : : IfOp op , const std : : vector < int32_t > & operands , <nl> + const std : : vector < int32_t > & results ) { <nl> + auto opcode_index = GetOpcodeIndex ( " if " , tflite : : BuiltinOperator_IF ) ; <nl> + int then_subgraph_index = subgraph_index_map_ . at ( op . then_branch ( ) . str ( ) ) ; <nl> + int else_subgraph_index = subgraph_index_map_ . at ( op . else_branch ( ) . str ( ) ) ; <nl> + auto builtin_options = tflite : : CreateIfOptions ( builder_ , then_subgraph_index , <nl> + else_subgraph_index ) <nl> + . Union ( ) ; <nl> + auto inputs = builder_ . CreateVector ( operands ) ; <nl> + auto outputs = builder_ . CreateVector ( results ) ; <nl> + return tflite : : CreateOperator ( builder_ , opcode_index , inputs , outputs , <nl> + tflite : : BuiltinOptions_IfOptions , <nl> + builtin_options ) ; <nl> + } <nl> + <nl> + BufferOffset < tflite : : Operator > Translator : : BuildWhileOperator ( <nl> + mlir : : TF : : WhileOp op , const std : : vector < int32_t > & operands , <nl> + const std : : vector < int32_t > & results ) { <nl> + auto opcode_index = GetOpcodeIndex ( " while " , tflite : : BuiltinOperator_WHILE ) ; <nl> + int cond_subgraph_index = subgraph_index_map_ . at ( op . cond ( ) . str ( ) ) ; <nl> + int body_subgraph_index = subgraph_index_map_ . at ( op . body ( ) . str ( ) ) ; <nl> + auto builtin_options = tflite : : CreateWhileOptions ( <nl> + builder_ , cond_subgraph_index , body_subgraph_index ) <nl> + . Union ( ) ; <nl> + auto inputs = builder_ . CreateVector ( operands ) ; <nl> + auto outputs = builder_ . CreateVector ( results ) ; <nl> + return tflite : : CreateOperator ( builder_ , opcode_index , inputs , outputs , <nl> + tflite : : BuiltinOptions_WhileOptions , <nl> + builtin_options ) ; <nl> + } <nl> + <nl> + Optional < BufferOffset < tflite : : Operator > > Translator : : BuildWhileOperator ( <nl> + mlir : : TFL : : WhileOp op , const std : : vector < int32_t > & operands , <nl> + const std : : vector < int32_t > & results ) { <nl> + auto opcode_index = GetOpcodeIndex ( " while " , tflite : : BuiltinOperator_WHILE ) ; <nl> + auto get_call_index = [ & ] ( mlir : : Block & b ) - > Optional < int > { <nl> + if ( b . getOperations ( ) . size ( ) ! = 2 ) return llvm : : None ; <nl> + if ( auto call_op = dyn_cast < mlir : : CallOp > ( b . front ( ) ) ) <nl> + return subgraph_index_map_ . at ( call_op . callee ( ) . str ( ) ) ; <nl> + return llvm : : None ; <nl> + } ; <nl> + auto body_subgraph_index = get_call_index ( op . body ( ) . front ( ) ) ; <nl> + auto cond_subgraph_index = get_call_index ( op . cond ( ) . front ( ) ) ; <nl> + if ( ! body_subgraph_index | | ! cond_subgraph_index ) <nl> + return op . emitOpError ( " only single call cond / body while export supported " ) , <nl> + llvm : : None ; <nl> + auto builtin_options = <nl> + tflite : : CreateWhileOptions ( builder_ , * cond_subgraph_index , <nl> + * body_subgraph_index ) <nl> + . Union ( ) ; <nl> + auto inputs = builder_ . CreateVector ( operands ) ; <nl> + auto outputs = builder_ . CreateVector ( results ) ; <nl> + return tflite : : CreateOperator ( builder_ , opcode_index , inputs , outputs , <nl> + tflite : : BuiltinOptions_WhileOptions , <nl> + builtin_options ) ; <nl> + } <nl> + <nl> + template < typename CustomOptionType , typename TFLOp > <nl> + BufferOffset < tflite : : Operator > Translator : : BuildCustomOperator ( <nl> + const CustomOptionType & custom_option , const std : : string & opcode_name , <nl> + TFLOp op , const std : : vector < int32_t > & operands , <nl> + const std : : vector < int32_t > & results ) { <nl> + std : : vector < uint8_t > custom_option_vector ( sizeof ( CustomOptionType ) ) ; <nl> + memcpy ( custom_option_vector . data ( ) , & custom_option , sizeof ( CustomOptionType ) ) ; <nl> + auto opcode_index = <nl> + GetOpcodeIndex ( opcode_name , tflite : : BuiltinOperator_CUSTOM ) ; <nl> + return tflite : : CreateOperator ( <nl> + builder_ , opcode_index , builder_ . CreateVector ( operands ) , <nl> + builder_ . CreateVector ( results ) , tflite : : BuiltinOptions_NONE , <nl> + / * builtin_options = * / 0 , <nl> + builder_ . CreateVector < uint8_t > ( custom_option_vector ) , <nl> + tflite : : CustomOptionsFormat_FLEXBUFFERS ) ; <nl> + } <nl> + <nl> + BufferOffset < tflite : : Operator > Translator : : BuildNumericVerifyOperator ( <nl> + mlir : : TFL : : NumericVerifyOp op , const std : : vector < int32_t > & operands , <nl> + const std : : vector < int32_t > & results ) { <nl> + float tolerance = op . tolerance ( ) . convertToFloat ( ) ; <nl> + return BuildCustomOperator ( tolerance , " NumericVerify " , op , operands , results ) ; <nl> + } <nl> + <nl> + Optional < BufferOffset < tflite : : Operator > > <nl> + Translator : : BuildConvolution2DTransposeBiasOperator ( <nl> + Operation * inst , mlir : : TFL : : Convolution2DTransposeBiasOp op , <nl> + const std : : vector < int32_t > & operands , const std : : vector < int32_t > & results ) { <nl> + TfLiteTransposeConvParams conv_params ; <nl> + conv_params . stride_height = op . stride_h ( ) . getSExtValue ( ) ; <nl> + conv_params . stride_width = op . stride_w ( ) . getSExtValue ( ) ; <nl> + const auto padding = GetTflitePadding ( inst , op . padding ( ) ) ; <nl> + if ( padding ) { <nl> + conv_params . padding = * padding ; <nl> + return BuildCustomOperator ( conv_params , " Convolution2DTransposeBias " , op , <nl> + operands , results ) ; <nl> + } <nl> + <nl> + return llvm : : None ; <nl> + } <nl> + <nl> + Optional < BufferOffset < tflite : : Operator > > <nl> + Translator : : BuildMaxPoolingWithArgMax2DOperator ( <nl> + Operation * inst , mlir : : TFL : : MaxPoolingWithArgMax2DOp op , <nl> + const std : : vector < int32_t > & operands , const std : : vector < int32_t > & results ) { <nl> + const auto pool_params = GetTflitePoolParams ( inst , op ) ; <nl> + if ( pool_params ) { <nl> + return BuildCustomOperator ( * pool_params , " MaxPoolingWithArgmax2D " , op , <nl> + operands , results ) ; <nl> + } <nl> + <nl> + return llvm : : None ; <nl> + } <nl> + <nl> + Optional < BufferOffset < tflite : : Operator > > <nl> + Translator : : BuildMaxUnpooling2DOperator ( Operation * inst , <nl> + mlir : : TFL : : MaxUnpooling2DOp op , <nl> + const std : : vector < int32_t > & operands , <nl> + const std : : vector < int32_t > & results ) { <nl> + const auto pool_params = GetTflitePoolParams ( inst , op ) ; <nl> + if ( pool_params ) { <nl> + return BuildCustomOperator ( * pool_params , " MaxUnpooling2D " , op , operands , <nl> + results ) ; <nl> + } <nl> + <nl> + return llvm : : None ; <nl> + } <nl> + <nl> + Optional < CustomOptionsOffset > Translator : : CreateFlexOpCustomOptions ( <nl> + const : : tensorflow : : NodeDef & node_def , const mlir : : Location & loc ) { <nl> + std : : string node_def_str ; <nl> + if ( ! node_def . SerializeToString ( & node_def_str ) ) { <nl> + return emitError ( loc , " failed to serialize tensorflow node_def " ) , <nl> + llvm : : None ; <nl> + } <nl> + <nl> + auto flex_builder = absl : : make_unique < flexbuffers : : Builder > ( ) ; <nl> + flex_builder - > Vector ( [ & ] ( ) { <nl> + flex_builder - > String ( node_def . op ( ) ) ; <nl> + flex_builder - > String ( node_def_str ) ; <nl> + } ) ; <nl> + flex_builder - > Finish ( ) ; <nl> + return builder_ . CreateVector ( flex_builder - > GetBuffer ( ) ) ; <nl> + } <nl> + <nl> + Optional < CustomOptionsOffset > Translator : : CreateCustomOpCustomOptions ( <nl> + const : : tensorflow : : NodeDef & node_def , const mlir : : Location & loc ) { <nl> + std : : string node_def_str ; <nl> + if ( ! node_def . SerializeToString ( & node_def_str ) ) { <nl> + return emitError ( loc , " failed to serialize tensorflow node_def " ) , <nl> + llvm : : None ; <nl> + } <nl> + auto flex_builder = CreateFlexBuilderWithNodeAttrs ( node_def , loc ) ; <nl> + return builder_ . CreateVector ( flex_builder - > GetBuffer ( ) ) ; <nl> + } <nl> + <nl> + std : : unique_ptr < flexbuffers : : Builder > <nl> + Translator : : CreateFlexBuilderWithNodeAttrs ( <nl> + const : : tensorflow : : NodeDef & node_def , const mlir : : Location & loc ) { <nl> + auto flex_builder = absl : : make_unique < flexbuffers : : Builder > ( ) ; <nl> + size_t map_start = flex_builder - > StartMap ( ) ; <nl> + for ( const auto & pair : node_def . attr ( ) ) { <nl> + const char * key = pair . first . c_str ( ) ; <nl> + const auto & attr = pair . second ; <nl> + switch ( attr . value_case ( ) ) { <nl> + case : : tensorflow : : AttrValue : : kS : <nl> + flex_builder - > String ( key , attr . s ( ) ) ; <nl> + break ; <nl> + case : : tensorflow : : AttrValue : : kType : { <nl> + auto status_or_tfl_type = tflite : : TfTypeToTflType ( attr . type ( ) ) ; <nl> + if ( status_or_tfl_type . ok ( ) ) { <nl> + flex_builder - > Int ( key , status_or_tfl_type . ValueOrDie ( ) ) ; <nl> + } else { <nl> + emitWarning ( loc , " ignoring unsupported tensorflow type : " ) <nl> + < < std : : to_string ( attr . type ( ) ) ; <nl> + } <nl> + break ; <nl> + } <nl> + case : : tensorflow : : AttrValue : : kI : <nl> + flex_builder - > Int ( key , attr . i ( ) ) ; <nl> + break ; <nl> + case : : tensorflow : : AttrValue : : kF : <nl> + flex_builder - > Float ( key , attr . f ( ) ) ; <nl> + break ; <nl> + case : : tensorflow : : AttrValue : : kB : <nl> + flex_builder - > Bool ( key , attr . b ( ) ) ; <nl> + break ; <nl> + case tensorflow : : AttrValue : : kList : <nl> + if ( attr . list ( ) . s_size ( ) > 0 ) { <nl> + auto start = flex_builder - > StartVector ( key ) ; <nl> + for ( const std : : string & v : attr . list ( ) . s ( ) ) { <nl> + flex_builder - > Add ( v ) ; <nl> + } <nl> + flex_builder - > EndVector ( start , / * typed = * / true , / * fixed = * / false ) ; <nl> + } else if ( attr . list ( ) . i_size ( ) > 0 ) { <nl> + auto start = flex_builder - > StartVector ( key ) ; <nl> + for ( const int64_t v : attr . list ( ) . i ( ) ) { <nl> + flex_builder - > Add ( v ) ; <nl> + } <nl> + flex_builder - > EndVector ( start , / * typed = * / true , / * fixed = * / false ) ; <nl> + } else if ( attr . list ( ) . f_size ( ) > 0 ) { <nl> + auto start = flex_builder - > StartVector ( key ) ; <nl> + for ( const float v : attr . list ( ) . f ( ) ) { <nl> + flex_builder - > Add ( v ) ; <nl> + } <nl> + flex_builder - > EndVector ( start , / * typed = * / true , / * fixed = * / false ) ; <nl> + } else { <nl> + emitWarning ( loc , <nl> + " ignoring unsupported type in list attribute with key : " ) <nl> + < < key ; <nl> + } <nl> + break ; <nl> + default : <nl> + emitWarning ( loc , " ignoring unsupported attribute type with key : " ) <nl> + < < key ; <nl> + break ; <nl> + } <nl> + } <nl> + flex_builder - > EndMap ( map_start ) ; <nl> + flex_builder - > Finish ( ) ; <nl> + return flex_builder ; <nl> + } <nl> + <nl> + uint32_t Translator : : GetOpcodeIndex ( const std : : string & op_name , <nl> + tflite : : BuiltinOperator builtin ) { <nl> + auto it = opcode_index_map_ . insert ( { op_name , 0 } ) ; <nl> + <nl> + / / If the insert succeeded , the opcode has not been created already . Create a <nl> + / / new operator code and update its index value in the map . <nl> + if ( it . second ) { <nl> + it . first - > second = opcodes_ . size ( ) ; <nl> + auto custom_code = builtin = = tflite : : BuiltinOperator_CUSTOM <nl> + ? builder_ . CreateString ( op_name ) <nl> + : BufferOffset < flatbuffers : : String > ( ) ; <nl> + / / Use version 0 for builtin op . This is a way to serialize version field to <nl> + / / flatbuffer ( since 0 is non default ) and it will be corrected later . <nl> + int32_t op_version = builtin ! = tflite : : BuiltinOperator_CUSTOM ? 0 : 1 ; <nl> + opcodes_ . push_back ( CreateOperatorCode ( builder_ , / * builtin_code = * / builtin , <nl> + custom_code , op_version ) ) ; <nl> + } <nl> + return it . first - > second ; <nl> + } <nl> + <nl> + Optional < BufferOffset < tflite : : Operator > > Translator : : BuildOperator ( <nl> + Operation * inst , const std : : vector < int32_t > & operands , <nl> + const std : : vector < int32_t > & results , <nl> + const std : : vector < int32_t > & intermediates ) { <nl> + const auto * dialect = inst - > getDialect ( ) ; <nl> + if ( ! dialect ) { <nl> + inst - > emitOpError ( " dialect is not registered " ) ; <nl> + return llvm : : None ; <nl> + } <nl> + <nl> + / / If TFLite built in op , create operator as a builtin op . <nl> + if ( dialect = = tfl_dialect_ ) { <nl> + / / Only if built - in TFLite op emission is enabled , would legalization have <nl> + / / converted any TF - > TFL . <nl> + if ( ! enabled_op_types_ . contains ( OpType : : kTfliteBuiltin ) ) { <nl> + return inst - > emitOpError ( <nl> + " is a TFLite builtin op but builtin emission is not enabled " ) , <nl> + llvm : : None ; <nl> + } <nl> + <nl> + auto builtin_code = GetBuiltinOpCode ( inst ) ; <nl> + if ( ! builtin_code ) { <nl> + if ( auto verify_op = dyn_cast < mlir : : TFL : : NumericVerifyOp > ( inst ) ) { <nl> + return BuildNumericVerifyOperator ( verify_op , operands , results ) ; <nl> + } <nl> + if ( auto conv_transpose_bias_op = <nl> + dyn_cast < mlir : : TFL : : Convolution2DTransposeBiasOp > ( inst ) ) { <nl> + return BuildConvolution2DTransposeBiasOperator ( <nl> + inst , conv_transpose_bias_op , operands , results ) ; <nl> + } <nl> + if ( auto max_pooling_with_arg_max_op = <nl> + dyn_cast < mlir : : TFL : : MaxPoolingWithArgMax2DOp > ( inst ) ) { <nl> + return BuildMaxPoolingWithArgMax2DOperator ( <nl> + inst , max_pooling_with_arg_max_op , operands , results ) ; <nl> + } <nl> + if ( auto max_unpooling_op = dyn_cast < mlir : : TFL : : MaxUnpooling2DOp > ( inst ) ) { <nl> + return BuildMaxUnpooling2DOperator ( inst , max_unpooling_op , operands , <nl> + results ) ; <nl> + } <nl> + if ( auto whileOp = dyn_cast < mlir : : TFL : : WhileOp > ( inst ) ) { <nl> + if ( inst - > getNumOperands ( ) ! = inst - > getNumResults ( ) ) { <nl> + inst - > emitOpError ( <nl> + " number of operands and results don ' t match , only canonical " <nl> + " TFL While supported " ) ; <nl> + return llvm : : None ; <nl> + } <nl> + return BuildWhileOperator ( whileOp , operands , results ) ; <nl> + } <nl> + <nl> + inst - > emitOpError ( " is not a supported TFLite op " ) ; <nl> + return llvm : : None ; <nl> + } <nl> + <nl> + std : : string op_name = inst - > getName ( ) . getStringRef ( ) . str ( ) ; <nl> + uint32_t opcode_index = GetOpcodeIndex ( op_name , * builtin_code ) ; <nl> + auto offset = CreateFlatBufferOperator ( inst , opcode_index , operands , <nl> + results , intermediates , & builder_ ) ; <nl> + if ( ! offset ) { <nl> + inst - > emitOpError ( " is not a supported TFLite op " ) ; <nl> + } <nl> + return offset ; <nl> + } <nl> + <nl> + if ( dialect = = tf_dialect_ ) { <nl> + std : : string op_name ; <nl> + if ( auto ifOp = dyn_cast < mlir : : TF : : IfOp > ( inst ) ) { <nl> + return BuildIfOperator ( ifOp , operands , results ) ; <nl> + } else if ( auto whileOp = dyn_cast < mlir : : TF : : WhileOp > ( inst ) ) { <nl> + return BuildWhileOperator ( whileOp , operands , results ) ; <nl> + } <nl> + <nl> + CustomOptionsOffset custom_options ; <nl> + <nl> + / / Ops in TF dialect can either be custom ops or flex ops . <nl> + / / The reason we go directly from TensorFlow dialect MLIR to tensorflow <nl> + / / node instead of going to TF table gen ' d ops via generated code is that <nl> + / / we do not want to restrict custom and flex op conversion support to <nl> + / / only those TF ops that are currently registered in MLIR . The current <nl> + / / model is of an open op system . <nl> + / / <nl> + / / The following algorithm is followed : <nl> + / / if flex is enabled and the op is whitelisted as flex <nl> + / / we emit op as flex . <nl> + / / if custom is enabled <nl> + / / we emit the op as custom . <nl> + auto node_def = GetTensorFlowNodeDef ( inst ) ; <nl> + if ( ! node_def ) { <nl> + return llvm : : None ; <nl> + } <nl> + <nl> + / / Flex op case <nl> + / / Eventually , the whitelist will go away and we will rely on some TF op <nl> + / / trait ( e . g . No side effect ) to determine if it is a supported " Flex " <nl> + / / op or not . <nl> + if ( enabled_op_types_ . contains ( OpType : : kSelectTf ) & & <nl> + IsWhitelistedFlexOp ( node_def - > op ( ) ) ) { <nl> + / / Construct ops as flex op encoding TensorFlow node definition <nl> + / / as custom options . <nl> + / / Flex ops are named with the kFlexOpNamePrefix prefix to the actual <nl> + / / TF op name . <nl> + op_name = std : : string ( kFlexOpNamePrefix ) + node_def - > op ( ) ; <nl> + if ( auto options = CreateFlexOpCustomOptions ( * node_def , inst - > getLoc ( ) ) ) { <nl> + custom_options = * options ; <nl> + } else { <nl> + return llvm : : None ; <nl> + } <nl> + } else if ( enabled_op_types_ . contains ( OpType : : kCustomOp ) ) { <nl> + / / Generic case of custom ops - write using flex buffers since that <nl> + / / is the only custom options supported by TFLite today . <nl> + op_name = node_def - > op ( ) ; <nl> + if ( auto options = <nl> + CreateCustomOpCustomOptions ( * node_def , inst - > getLoc ( ) ) ) { <nl> + custom_options = * options ; <nl> + } else { <nl> + return llvm : : None ; <nl> + } <nl> + } else { <nl> + / / Create description of operation that could not be converted . <nl> + const int kLargeElementsAttr = 16 ; <nl> + std : : string op_str ; <nl> + llvm : : raw_string_ostream os ( op_str ) ; <nl> + inst - > getName ( ) . print ( os ) ; <nl> + / / Print out attributes except for large elementsattributes ( which should <nl> + / / rarely be the cause why the legalization didn ' t happen ) . <nl> + if ( ! inst - > getAttrList ( ) . getAttrs ( ) . empty ( ) ) { <nl> + os < < " { " ; <nl> + bool first = true ; <nl> + for ( auto & named_attr : inst - > getAttrList ( ) . getDictionary ( ) ) { <nl> + os < < ( ! first ? " , " : " " ) ; <nl> + first = false ; <nl> + named_attr . first . print ( os ) ; <nl> + os < < " = " ; <nl> + if ( auto element_attr = named_attr . second . dyn_cast < ElementsAttr > ( ) ) { <nl> + if ( element_attr . getNumElements ( ) < = kLargeElementsAttr ) { <nl> + element_attr . print ( os ) ; <nl> + } else { <nl> + os < < " < large > " ; <nl> + } <nl> + } else { <nl> + named_attr . second . print ( os ) ; <nl> + } <nl> + } <nl> + os < < " } " ; <nl> + } <nl> + <nl> + / / Insert failed op to ` flex_ops ` or ` custom_ops ` . <nl> + if ( IsWhitelistedFlexOp ( node_def - > op ( ) ) ) { <nl> + failed_flex_ops_ . insert ( os . str ( ) ) ; <nl> + } else { <nl> + failed_custom_ops_ . insert ( os . str ( ) ) ; <nl> + } <nl> + return inst - > emitOpError ( " is neither a custom op nor a flex op " ) , <nl> + llvm : : None ; <nl> + } <nl> + <nl> + uint32_t opcode_index = <nl> + GetOpcodeIndex ( op_name , tflite : : BuiltinOperator_CUSTOM ) ; <nl> + auto inputs = builder_ . CreateVector ( operands ) ; <nl> + auto outputs = builder_ . CreateVector ( results ) ; <nl> + <nl> + return tflite : : CreateOperator ( builder_ , opcode_index , inputs , outputs , <nl> + tflite : : BuiltinOptions_NONE , <nl> + / * builtin_options = * / 0 , <nl> + / * custom_options = * / custom_options , <nl> + tflite : : CustomOptionsFormat_FLEXBUFFERS , <nl> + / * mutating_variable_inputs = * / 0 ) ; <nl> + } <nl> + <nl> + return inst - > emitOpError ( <nl> + " is not any of a builtin TFLite op , a flex TensorFlow op or a " <nl> + " custom TensorFlow op " ) , <nl> + llvm : : None ; <nl> + } <nl> + <nl> + void Translator : : InitializeNamesFromAttribute ( FuncOp fn , bool * has_input_attr ) { <nl> + auto dict_attr = fn . getAttrOfType < mlir : : DictionaryAttr > ( " tf . entry_function " ) ; <nl> + if ( ! dict_attr ) return ; <nl> + <nl> + llvm : : SmallVector < llvm : : StringRef , 2 > input_names ; <nl> + llvm : : SmallVector < llvm : : StringRef , 2 > output_names ; <nl> + if ( auto str = dict_attr . get ( " inputs " ) . dyn_cast_or_null < mlir : : StringAttr > ( ) ) { <nl> + str . getValue ( ) . split ( input_names , ' , ' , / * MaxSplit = * / - 1 , <nl> + / * KeepEmpty = * / false ) ; <nl> + if ( input_names . size ( ) ! = fn . getNumArguments ( ) ) { <nl> + fn . emitWarning ( ) < < " invalid entry function specification " ; <nl> + return ; <nl> + } <nl> + for ( auto it : llvm : : enumerate ( fn . getArguments ( ) ) ) { <nl> + name_mapper_ . InitOpName ( it . value ( ) , input_names [ it . index ( ) ] . trim ( ) ) ; <nl> + } <nl> + * has_input_attr = true ; <nl> + } <nl> + <nl> + if ( auto str = <nl> + dict_attr . get ( " outputs " ) . dyn_cast_or_null < mlir : : StringAttr > ( ) ) { <nl> + str . getValue ( ) . split ( output_names , ' , ' , / * MaxSplit = * / - 1 , <nl> + / * KeepEmpty = * / false ) ; <nl> + auto term = fn . getBlocks ( ) . back ( ) . getTerminator ( ) ; <nl> + if ( output_names . size ( ) ! = term - > getNumOperands ( ) ) { <nl> + fn . emitWarning ( ) < < " output names ( " < < output_names . size ( ) <nl> + < < " ) ! = terminator operands ( " < < term - > getNumOperands ( ) <nl> + < < " ) " ; <nl> + return ; <nl> + } <nl> + for ( const auto & it : llvm : : enumerate ( term - > getOperands ( ) ) ) { <nl> + name_mapper_ . InitOpName ( it . value ( ) , output_names [ it . index ( ) ] . trim ( ) ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + bool Translator : : IsStatefulOperand ( mlir : : Operation * op , int operand_index ) { <nl> + std : : vector < int > operand_indices ; <nl> + if ( ! mlir : : TFL : : IsStatefulOp ( op , & operand_indices ) ) return false ; <nl> + return absl : : c_find ( operand_indices , operand_index ) ! = operand_indices . end ( ) ; <nl> + } <nl> + <nl> + Optional < BufferOffset < tflite : : SubGraph > > Translator : : BuildSubGraph ( <nl> + const std : : string & name , Region * region ) { <nl> + bool has_input_attr = false ; <nl> + if ( auto fn = dyn_cast < FuncOp > ( region - > getParentOp ( ) ) ) { <nl> + InitializeNamesFromAttribute ( fn , & has_input_attr ) ; <nl> + } <nl> + std : : vector < BufferOffset < tflite : : Tensor > > tensors ; <nl> + llvm : : DenseMap < Value , int > tensor_index_map ; <nl> + <nl> + / / Builds tensor and buffer for argument or operation result . Returns false <nl> + / / on failure . <nl> + auto build_tensor_and_buffer = [ & ] ( Value value , const std : : string & name ) { <nl> + / / NoneType represents optional and may be skipped here . <nl> + if ( value . getType ( ) . isa < NoneType > ( ) ) { <nl> + return true ; <nl> + } <nl> + <nl> + tensor_index_map . insert ( { value , tensors . size ( ) } ) ; <nl> + auto tensor_or = BuildTensor ( value , name , buffers_ . size ( ) ) ; <nl> + if ( ! tensor_or ) return false ; <nl> + tensors . push_back ( * tensor_or ) ; <nl> + <nl> + / / TODO ( ashwinm ) : Check if for stateful tensors , if it is also needed to <nl> + / / make the Buffer empty apart from setting the buffer_idx = 0 in the Tensor . <nl> + / / This does not seem to affect runtime behavior for RNN / LSTM , but would be <nl> + / / good for reducing memory footprint . <nl> + if ( auto * inst = value . getDefiningOp ( ) ) { <nl> + auto buffer_or = BuildBuffer ( inst ) ; <nl> + if ( ! buffer_or ) return false ; <nl> + buffers_ . push_back ( * buffer_or ) ; <nl> + } else { <nl> + buffers_ . push_back ( empty_buffer_ ) ; <nl> + } <nl> + return true ; <nl> + } ; <nl> + <nl> + std : : vector < BufferOffset < tflite : : Operator > > operators ; <nl> + auto & bb = region - > front ( ) ; <nl> + <nl> + / / Main function ' s arguments are first passed to ` input ` op so they don ' t <nl> + / / have associated tensor and buffer . Build FlatBuffer tensor and buffer for <nl> + / / other functions . <nl> + for ( unsigned i = 0 , e = bb . getNumArguments ( ) ; i < e ; + + i ) { <nl> + mlir : : BlockArgument arg = bb . getArgument ( i ) ; <nl> + std : : string name ; <nl> + if ( has_input_attr ) name = std : : string ( name_mapper_ . GetUniqueName ( arg ) ) ; <nl> + if ( name . empty ( ) ) name = absl : : StrCat ( " arg " , i ) ; <nl> + if ( ! build_tensor_and_buffer ( arg , name ) ) return llvm : : None ; <nl> + } <nl> + <nl> + bool failed_once = false ; <nl> + for ( auto & inst : bb ) { <nl> + if ( inst . isKnownTerminator ( ) ) break ; <nl> + std : : vector < int32_t > intermediates ; <nl> + / / Build intermediate tensors for tfl . lstm and insert these tensors into <nl> + / / flatbuffer . <nl> + if ( llvm : : isa < mlir : : TFL : : LSTMOp > ( inst ) ) { <nl> + std : : vector < std : : string > intermediate_names = { <nl> + " input_to_input_intermediate " , " input_to_forget_intermediate " , <nl> + " input_to_cell_intermediate " , " input_to_output_intermediate " , <nl> + " effective_hidden_scale_intermediate " } ; <nl> + for ( const std : : string & intermediate : intermediate_names ) { <nl> + auto intermediate_attr = inst . getAttr ( intermediate ) ; <nl> + if ( auto attr = intermediate_attr . dyn_cast_or_null < mlir : : TypeAttr > ( ) ) { <nl> + Type qtype = attr . getValue ( ) ; <nl> + auto tensor_or = BuildTensorFromType ( <nl> + qtype , name_mapper_ . GetUniqueName ( intermediate ) . str ( ) ) ; <nl> + if ( ! tensor_or . hasValue ( ) ) { <nl> + continue ; <nl> + } else { <nl> + intermediates . push_back ( tensors . size ( ) ) ; <nl> + tensors . push_back ( tensor_or . getValue ( ) ) ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + <nl> + for ( auto val : inst . getResults ( ) ) { <nl> + std : : string name = UniqueName ( val ) ; <nl> + if ( ! build_tensor_and_buffer ( val , name ) ) return llvm : : None ; <nl> + } <nl> + <nl> + / / Skip constant ops as they don ' t represent a TFLite operator . <nl> + if ( IsConst ( & inst ) ) continue ; <nl> + <nl> + / / Fetch operand and result tensor indices . <nl> + std : : vector < int32_t > operands ; <nl> + operands . reserve ( inst . getNumOperands ( ) ) ; <nl> + for ( auto operand : inst . getOperands ( ) ) { <nl> + if ( operand . getType ( ) . isa < NoneType > ( ) ) <nl> + operands . push_back ( kTfLiteOptionalTensor ) ; <nl> + else <nl> + operands . push_back ( tensor_index_map . lookup ( operand ) ) ; <nl> + } <nl> + std : : vector < int32_t > results ; <nl> + results . reserve ( inst . getNumOperands ( ) ) ; <nl> + for ( auto result : inst . getResults ( ) ) { <nl> + results . push_back ( tensor_index_map . lookup ( result ) ) ; <nl> + } <nl> + <nl> + if ( auto tfl_operator = <nl> + BuildOperator ( & inst , operands , results , intermediates ) ) <nl> + operators . push_back ( * tfl_operator ) ; <nl> + else <nl> + failed_once = true ; <nl> + } <nl> + <nl> + if ( failed_once ) return llvm : : None ; <nl> + <nl> + / / Get input and output tensor indices for the subgraph . <nl> + std : : vector < int32_t > inputs , outputs ; <nl> + for ( auto arg : bb . getArguments ( ) ) { <nl> + inputs . push_back ( tensor_index_map [ arg ] ) ; <nl> + } <nl> + for ( auto result : bb . getTerminator ( ) - > getOperands ( ) ) { <nl> + outputs . push_back ( tensor_index_map [ result ] ) ; <nl> + } <nl> + <nl> + return tflite : : CreateSubGraph ( <nl> + builder_ , builder_ . CreateVector ( tensors ) , builder_ . CreateVector ( inputs ) , <nl> + builder_ . CreateVector ( outputs ) , builder_ . CreateVector ( operators ) , <nl> + / * name = * / builder_ . CreateString ( name ) ) ; <nl> + } <nl> + <nl> + BufferOffset < tflite : : Metadata > Translator : : BuildMetadata ( StringRef name , <nl> + StringRef content ) { <nl> + auto buffer_index = buffers_ . size ( ) ; <nl> + auto buffer_data = builder_ . CreateVector ( <nl> + reinterpret_cast < const uint8_t * > ( content . data ( ) ) , content . size ( ) ) ; <nl> + buffers_ . push_back ( tflite : : CreateBuffer ( builder_ , buffer_data ) ) ; <nl> + return tflite : : CreateMetadataDirect ( builder_ , name . data ( ) , buffer_index ) ; <nl> + } <nl> + <nl> + Optional < VectorBufferOffset < BufferOffset < tflite : : Metadata > > > <nl> + Translator : : CreateMetadataVector ( ) { <nl> + auto dict_attr = module_ . getAttrOfType < mlir : : DictionaryAttr > ( " tfl . metadata " ) ; <nl> + std : : vector < BufferOffset < tflite : : Metadata > > metadata ; <nl> + if ( dict_attr ) { <nl> + for ( const auto & named_attr : dict_attr ) { <nl> + StringRef name = named_attr . first ; <nl> + mlir : : Attribute attr = named_attr . second ; <nl> + if ( auto content = attr . dyn_cast < StringAttr > ( ) ) { <nl> + metadata . push_back ( BuildMetadata ( name , content . getValue ( ) ) ) ; <nl> + } else { <nl> + module_ . emitError ( <nl> + " all values in tfl . metadata ' s dictionary key - value pairs should be " <nl> + " string attributes " ) ; <nl> + return llvm : : None ; <nl> + } <nl> + } <nl> + } <nl> + / / Runtime version string is generated after we update the op <nl> + / / versions . Here we put a 16 - byte dummy string as a placeholder . We choose <nl> + / / 16 - byte because it ' s the alignment of buffers in flatbuffer , so it won ' t <nl> + / / cause any waste of space if the actual string is shorter than 16 bytes . <nl> + metadata . push_back ( <nl> + BuildMetadata ( " min_runtime_version " , std : : string ( 16 , ' \ 0 ' ) ) ) ; <nl> + return builder_ . CreateVector ( metadata ) ; <nl> + } <nl> + <nl> + bool UpdateEntryFunction ( ModuleOp module ) { <nl> + if ( module . lookupSymbol < FuncOp > ( " main " ) ! = nullptr ) { <nl> + / / We already have an entry function . <nl> + return true ; <nl> + } <nl> + <nl> + int entry_func_count = 0 ; <nl> + FuncOp entry_func = nullptr ; <nl> + for ( auto fn : module . getOps < FuncOp > ( ) ) { <nl> + auto attrs = fn . getAttrOfType < mlir : : DictionaryAttr > ( " tf . entry_function " ) ; <nl> + if ( attrs & & ! attrs . empty ( ) ) { <nl> + entry_func_count + + ; <nl> + entry_func = fn ; <nl> + } <nl> + } <nl> + <nl> + / / We should have one & only have one entry function . <nl> + if ( entry_func_count ! = 1 ) return false ; <nl> + <nl> + / / Update the entry func to main . <nl> + entry_func . setName ( " main " ) ; <nl> + return true ; <nl> + } <nl> + <nl> + Optional < std : : string > Translator : : Translate ( <nl> + ModuleOp module , bool emit_builtin_tflite_ops , bool emit_select_tf_ops , <nl> + bool emit_custom_ops , OpOrArgNameMapper * op_or_arg_name_mapper ) { <nl> + if ( ! UpdateEntryFunction ( module ) ) return llvm : : None ; <nl> + if ( ! IsValidTFLiteMlirModule ( module ) ) return llvm : : None ; <nl> + Translator translator ( module , emit_builtin_tflite_ops , emit_select_tf_ops , <nl> + emit_custom_ops , op_or_arg_name_mapper ) ; <nl> + return translator . TranslateInternal ( ) ; <nl> + } <nl> + <nl> + Optional < std : : string > Translator : : TranslateInternal ( ) { <nl> + / / A list of named regions in the module with main function being the first in <nl> + / / the list . The main function is required as the first subgraph in the model <nl> + / / is entry point for the model . <nl> + std : : vector < std : : pair < std : : string , Region * > > named_regions ; <nl> + named_regions . reserve ( std : : distance ( module_ . begin ( ) , module_ . end ( ) ) ) ; <nl> + <nl> + int subgraph_idx = 0 ; <nl> + FuncOp main_fn = module_ . lookupSymbol < FuncOp > ( " main " ) ; <nl> + subgraph_index_map_ [ main_fn . getName ( ) . str ( ) ] = subgraph_idx + + ; <nl> + named_regions . emplace_back ( " main " , & main_fn . getBody ( ) ) ; <nl> + / / Walk over the module collection ops with functions and while ops . <nl> + module_ . walk ( [ & ] ( FuncOp fn ) { <nl> + if ( fn ! = main_fn ) { <nl> + subgraph_index_map_ [ fn . getName ( ) . str ( ) ] = subgraph_idx + + ; <nl> + named_regions . emplace_back ( fn . getName ( ) . str ( ) , & fn . getBody ( ) ) ; <nl> + } <nl> + } ) ; <nl> + <nl> + / / Build subgraph for each of the named regions . <nl> + std : : vector < BufferOffset < tflite : : SubGraph > > subgraphs ; <nl> + subgraphs . reserve ( named_regions . size ( ) ) ; <nl> + int first_failed_func = - 1 ; <nl> + for ( auto it : llvm : : enumerate ( named_regions ) ) { <nl> + auto subgraph_or = BuildSubGraph ( it . value ( ) . first , it . value ( ) . second ) ; <nl> + if ( ! subgraph_or ) { <nl> + if ( first_failed_func = = - 1 ) <nl> + / / Record the index of the first region that cannot be converted . <nl> + / / Keep looping through all subgraphs in the module to make sure that <nl> + / / we collect the list of missing ops from the entire module . <nl> + first_failed_func = it . index ( ) ; <nl> + } else { <nl> + subgraphs . push_back ( * subgraph_or ) ; <nl> + } <nl> + } <nl> + <nl> + if ( first_failed_func ! = - 1 ) { <nl> + std : : string failed_flex_ops_list = absl : : StrJoin ( failed_flex_ops_ , " \ n \ t " ) ; <nl> + std : : string failed_custom_ops_list = <nl> + absl : : StrJoin ( failed_custom_ops_ , " \ n \ t " ) ; <nl> + std : : string err ; <nl> + if ( ! failed_flex_ops_list . empty ( ) ) <nl> + err + = <nl> + " Ops that can be supported by the flex runtime ( enabled via setting " <nl> + " the - emit - select - tf - ops flag ) : \ n \ t " + <nl> + failed_flex_ops_list ; <nl> + if ( ! failed_custom_ops_list . empty ( ) ) <nl> + err + = <nl> + " Ops that need custom implementation ( enabled via setting the " <nl> + " - emit - custom - ops flag ) : \ n \ t " + <nl> + failed_custom_ops_list ; <nl> + <nl> + auto & failed_region = named_regions [ first_failed_func ] ; <nl> + return failed_region . second - > getParentOp ( ) - > emitError ( ) <nl> + < < " failed while converting : ' " < < failed_region . first <nl> + < < " ' : " < < err , <nl> + llvm : : None ; <nl> + } <nl> + <nl> + std : : string model_description ; <nl> + if ( auto attr = module_ . getAttrOfType < StringAttr > ( " tfl . description " ) ) { <nl> + model_description = attr . getValue ( ) . str ( ) ; <nl> + } else { <nl> + model_description = " MLIR Converted . " ; <nl> + } <nl> + <nl> + / / Build the model and finish the model building process . <nl> + auto description = builder_ . CreateString ( model_description . data ( ) ) ; <nl> + VectorBufferOffset < int32_t > metadata_buffer = 0 ; / / Deprecated <nl> + auto metadata = CreateMetadataVector ( ) ; <nl> + if ( ! metadata ) return llvm : : None ; <nl> + <nl> + auto model = tflite : : CreateModel ( <nl> + builder_ , TFLITE_SCHEMA_VERSION , builder_ . CreateVector ( opcodes_ ) , <nl> + builder_ . CreateVector ( subgraphs ) , description , <nl> + builder_ . CreateVector ( buffers_ ) , metadata_buffer , * metadata ) ; <nl> + tflite : : FinishModelBuffer ( builder_ , model ) ; <nl> + tflite : : UpdateOpVersion ( builder_ . GetBufferPointer ( ) ) ; <nl> + tflite : : UpdateMinimumRuntimeVersionForModel ( builder_ . GetBufferPointer ( ) ) ; <nl> + <nl> + / / Return serialized string for the built FlatBuffer . <nl> + return std : : string ( reinterpret_cast < const char * > ( builder_ . GetBufferPointer ( ) ) , <nl> + builder_ . GetSize ( ) ) ; <nl> + } <nl> + <nl> + } / / namespace <nl> + <nl> + / / Translates the given MLIR module in the TFLite dialect to TFLite FlatBuffer <nl> + / / format . Returns false on success . <nl> + / / <nl> + / / TODO ( hinsu ) : Support all valid MLIR modules in TFLite dialect by supporting <nl> + / / the following : <nl> + / / <nl> + / / * Quantization <nl> + / / * Ops with variable tensors <nl> + / / <nl> + bool tflite : : MlirToFlatBufferTranslateFunction ( <nl> + ModuleOp module , std : : string * serialized_flatbuffer , <nl> + bool emit_builtin_tflite_ops , bool emit_select_tf_ops , bool emit_custom_ops , <nl> + OpOrArgNameMapper * op_or_arg_name_mapper ) { <nl> + auto maybe_translated = <nl> + Translator : : Translate ( module , emit_builtin_tflite_ops , emit_select_tf_ops , <nl> + emit_custom_ops , op_or_arg_name_mapper ) ; <nl> + if ( ! maybe_translated ) return true ; <nl> + * serialized_flatbuffer = std : : move ( * maybe_translated ) ; <nl> + return false ; <nl> + } <nl> + <nl> + bool tflite : : MlirToFlatBufferTranslateFunction ( <nl> + ModuleOp module , std : : string * serialized_flatbuffer , <nl> + bool emit_builtin_tflite_ops , bool emit_select_tf_ops , <nl> + bool emit_custom_ops ) { <nl> + OpOrArgLocNameMapper op_or_arg_name_mapper ; <nl> + return MlirToFlatBufferTranslateFunction ( <nl> + module , serialized_flatbuffer , emit_builtin_tflite_ops , <nl> + emit_select_tf_ops , emit_custom_ops , & op_or_arg_name_mapper ) ; <nl> + } <nl> + <nl> + static mlir : : LogicalResult MlirToFlatBufferFileTranslateFunction ( <nl> ModuleOp module , llvm : : raw_ostream & output ) { <nl> std : : string serialized_flatbuffer ; <nl> - std : : unique_ptr < tensorflow : : OpOrArgNameMapper > op_or_arg_name_mapper ; <nl> + std : : unique_ptr < OpOrArgNameMapper > op_or_arg_name_mapper ; <nl> if ( strip_debug_info ) { <nl> op_or_arg_name_mapper = <nl> std : : make_unique < tensorflow : : OpOrArgStripNameMapper > ( ) ; <nl> } else { <nl> - op_or_arg_name_mapper = <nl> - std : : make_unique < tensorflow : : OpOrArgLocNameMapper > ( ) ; <nl> + op_or_arg_name_mapper = std : : make_unique < OpOrArgLocNameMapper > ( ) ; <nl> } <nl> if ( tflite : : MlirToFlatBufferTranslateFunction ( <nl> module , & serialized_flatbuffer , emit_builtin_tflite_ops , <nl> static LogicalResult MlirToFlatBufferFileTranslateFunction ( <nl> return mlir : : failure ( ) ; <nl> <nl> output < < serialized_flatbuffer ; <nl> - return success ( ) ; <nl> + return mlir : : success ( ) ; <nl> } <nl> - } / / namespace <nl> - <nl> - static TranslateToMLIRRegistration FlatBufferFileToMlirTransReg ( <nl> - " tflite - flatbuffer - to - mlir " , <nl> - [ ] ( llvm : : SourceMgr & source_mgr , MLIRContext * context ) { <nl> - return FlatBufferFileToMlirTrans ( <nl> - & source_mgr , context , use_external_constant , <nl> - experimental_prune_unreachable_nodes_unconditionally ) ; <nl> - } ) ; <nl> <nl> static TranslateFromMLIRRegistration MLIRToFlatBufferTranslate ( <nl> " mlir - to - tflite - flatbuffer " , MlirToFlatBufferFileTranslateFunction ) ; <nl> - } / / namespace mlir <nl> similarity index 90 % <nl> rename from tensorflow / compiler / mlir / lite / flatbuffer_export . h <nl> rename to tensorflow / compiler / mlir / lite / flatbuffer_translate . h <nl> mmm a / tensorflow / compiler / mlir / lite / flatbuffer_export . h <nl> ppp b / tensorflow / compiler / mlir / lite / flatbuffer_translate . h <nl> See the License for the specific language governing permissions and <nl> limitations under the License . <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> <nl> - # ifndef TENSORFLOW_COMPILER_MLIR_LITE_FLATBUFFER_EXPORT_H_ <nl> - # define TENSORFLOW_COMPILER_MLIR_LITE_FLATBUFFER_EXPORT_H_ <nl> + # ifndef TENSORFLOW_COMPILER_MLIR_LITE_FLATBUFFER_TRANSLATE_H_ <nl> + # define TENSORFLOW_COMPILER_MLIR_LITE_FLATBUFFER_TRANSLATE_H_ <nl> <nl> # include < string > <nl> <nl> bool MlirToFlatBufferTranslateFunction ( <nl> tensorflow : : OpOrArgNameMapper * op_or_arg_name_mapper ) ; <nl> } / / namespace tflite <nl> <nl> - # endif / / TENSORFLOW_COMPILER_MLIR_LITE_FLATBUFFER_EXPORT_H_ <nl> + # endif / / TENSORFLOW_COMPILER_MLIR_LITE_FLATBUFFER_TRANSLATE_H_ <nl> similarity index 84 % <nl> rename from tensorflow / compiler / mlir / lite / flatbuffer_export_flags . h <nl> rename to tensorflow / compiler / mlir / lite / flatbuffer_translate_flags . h <nl> mmm a / tensorflow / compiler / mlir / lite / flatbuffer_export_flags . h <nl> ppp b / tensorflow / compiler / mlir / lite / flatbuffer_translate_flags . h <nl> See the License for the specific language governing permissions and <nl> limitations under the License . <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> <nl> - # ifndef TENSORFLOW_COMPILER_MLIR_LITE_FLATBUFFER_EXPORT_FLAGS_H_ <nl> - # define TENSORFLOW_COMPILER_MLIR_LITE_FLATBUFFER_EXPORT_FLAGS_H_ <nl> + # ifndef TENSORFLOW_COMPILER_MLIR_LITE_FLATBUFFER_TRANSLATE_FLAGS_H_ <nl> + # define TENSORFLOW_COMPILER_MLIR_LITE_FLATBUFFER_TRANSLATE_FLAGS_H_ <nl> <nl> # include < string > <nl> <nl> extern bool lower_tensor_list_ops ; <nl> / / The flag to control whether debug info gets stripped on export . <nl> extern bool strip_debug_info ; <nl> <nl> - # endif / / TENSORFLOW_COMPILER_MLIR_LITE_FLATBUFFER_EXPORT_FLAGS_H_ <nl> + # endif / / TENSORFLOW_COMPILER_MLIR_LITE_FLATBUFFER_TRANSLATE_FLAGS_H_ <nl> mmm a / tensorflow / compiler / mlir / lite / mlir_tflite_runner . cc <nl> ppp b / tensorflow / compiler / mlir / lite / mlir_tflite_runner . cc <nl> limitations under the License . <nl> # include " mlir / IR / MLIRContext . h " / / TF : llvm - project <nl> # include " mlir / IR / Module . h " / / TF : llvm - project <nl> # include " mlir / Parser . h " / / TF : llvm - project <nl> - # include " tensorflow / compiler / mlir / lite / flatbuffer_export . h " <nl> - # include " tensorflow / compiler / mlir / lite / flatbuffer_export_flags . h " <nl> + # include " tensorflow / compiler / mlir / lite / flatbuffer_translate . h " <nl> + # include " tensorflow / compiler / mlir / lite / flatbuffer_translate_flags . h " <nl> # include " tensorflow / core / platform / init_main . h " <nl> # include " tensorflow / core / platform / logging . h " <nl> # include " tensorflow / lite / delegates / flex / delegate . h " <nl> mmm a / tensorflow / compiler / mlir / lite / quantization / lite / quantize_model . cc <nl> ppp b / tensorflow / compiler / mlir / lite / quantization / lite / quantize_model . cc <nl> limitations under the License . <nl> # include " mlir / Pass / Pass . h " / / TF : llvm - project <nl> # include " mlir / Pass / PassManager . h " / / TF : llvm - project <nl> # include " tensorflow / compiler / mlir / lite / common / tfl_pass_config . h " <nl> - # include " tensorflow / compiler / mlir / lite / flatbuffer_export . h " <nl> # include " tensorflow / compiler / mlir / lite / flatbuffer_import . h " <nl> + # include " tensorflow / compiler / mlir / lite / flatbuffer_translate . h " <nl> # include " tensorflow / compiler / mlir / lite / quantization / quantization_config . h " <nl> # include " tensorflow / compiler / mlir / lite / transforms / passes . h " <nl> # include " tensorflow / compiler / mlir / lite / utils / convert_type . h " <nl> mmm a / tensorflow / compiler / mlir / lite / sparsity / sparsify_model . cc <nl> ppp b / tensorflow / compiler / mlir / lite / sparsity / sparsify_model . cc <nl> limitations under the License . <nl> # include " mlir / Pass / Pass . h " / / TF : llvm - project <nl> # include " mlir / Pass / PassManager . h " / / TF : llvm - project <nl> # include " tensorflow / compiler / mlir / lite / common / tfl_pass_config . h " <nl> - # include " tensorflow / compiler / mlir / lite / flatbuffer_export . h " <nl> # include " tensorflow / compiler / mlir / lite / flatbuffer_import . h " <nl> + # include " tensorflow / compiler / mlir / lite / flatbuffer_translate . h " <nl> # include " tensorflow / compiler / mlir / lite / utils / convert_type . h " <nl> # include " tensorflow / compiler / mlir / tensorflow / utils / error_util . h " <nl> # include " tensorflow / core / framework / types . pb . h " <nl> mmm a / tensorflow / compiler / mlir / lite / tf_tfl_translate . cc <nl> ppp b / tensorflow / compiler / mlir / lite / tf_tfl_translate . cc <nl> limitations under the License . <nl> # include " mlir / Support / FileUtilities . h " / / TF : llvm - project <nl> # include " tensorflow / compiler / mlir / init_mlir . h " <nl> # include " tensorflow / compiler / mlir / lite / common / tfl_pass_config . h " <nl> - # include " tensorflow / compiler / mlir / lite / flatbuffer_export . h " <nl> - # include " tensorflow / compiler / mlir / lite / flatbuffer_export_flags . h " <nl> + # include " tensorflow / compiler / mlir / lite / flatbuffer_translate . h " <nl> + # include " tensorflow / compiler / mlir / lite / flatbuffer_translate_flags . h " <nl> # include " tensorflow / compiler / mlir / lite / tf_tfl_passes . h " <nl> # include " tensorflow / compiler / mlir / lite / tf_tfl_translate_cl . h " <nl> # include " tensorflow / compiler / mlir / lite / tf_to_tfl_flatbuffer . h " <nl> mmm a / tensorflow / compiler / mlir / lite / tf_to_tfl_flatbuffer . cc <nl> ppp b / tensorflow / compiler / mlir / lite / tf_to_tfl_flatbuffer . cc <nl> limitations under the License . <nl> # include " mlir / Pass / Pass . h " / / TF : llvm - project <nl> # include " mlir / Support / FileUtilities . h " / / TF : llvm - project <nl> # include " mlir / Transforms / Passes . h " / / TF : llvm - project <nl> - # include " tensorflow / compiler / mlir / lite / flatbuffer_export . h " <nl> + # include " tensorflow / compiler / mlir / lite / flatbuffer_translate . h " <nl> # include " tensorflow / compiler / mlir / lite / quantization / quantization_config . h " <nl> # include " tensorflow / compiler / mlir / lite / transforms / passes . h " <nl> # include " tensorflow / compiler / mlir / tensorflow / transforms / decode_constant . h " <nl> mmm a / tensorflow / compiler / mlir / tensorflow / BUILD <nl> ppp b / tensorflow / compiler / mlir / tensorflow / BUILD <nl> cc_library ( <nl> srcs = [ " utils / error_util . cc " ] , <nl> hdrs = [ " utils / error_util . h " ] , <nl> deps = [ <nl> - " / / tensorflow / core / platform : errors " , <nl> - " / / tensorflow / core / platform : status " , <nl> + " / / tensorflow / core : lib " , <nl> " @ llvm - project / / llvm : support " , <nl> " @ llvm - project / / mlir : IR " , <nl> ] , <nl> mmm a / tensorflow / compiler / mlir / tensorflow / utils / error_util . cc <nl> ppp b / tensorflow / compiler / mlir / tensorflow / utils / error_util . cc <nl> limitations under the License . <nl> <nl> # include " tensorflow / compiler / mlir / tensorflow / utils / error_util . h " <nl> <nl> - # include " tensorflow / core / platform / errors . h " <nl> + # include " tensorflow / core / lib / core / errors . h " <nl> <nl> namespace mlir { <nl> <nl> mmm a / tensorflow / compiler / mlir / tensorflow / utils / error_util . h <nl> ppp b / tensorflow / compiler / mlir / tensorflow / utils / error_util . h <nl> limitations under the License . <nl> # include " mlir / IR / Diagnostics . h " / / TF : llvm - project <nl> # include " mlir / IR / Location . h " / / TF : llvm - project <nl> # include " mlir / IR / MLIRContext . h " / / TF : llvm - project <nl> - # include " tensorflow / core / platform / status . h " <nl> + # include " tensorflow / core / lib / core / status . h " <nl> <nl> / / Error utilities for MLIR when interacting with code using Status returns . <nl> namespace mlir { <nl>
|
Make flatbuffer_translate_lib dynamic linked
|
tensorflow/tensorflow
|
7116a21f176031da4b818234c70b4616ff484cf7
|
2020-03-23T05:49:32Z
|
mmm a / DEPS <nl> ppp b / DEPS <nl> deps = { <nl> " v8 / testing / gmock " : <nl> Var ( " git_url " ) + " / external / googlemock . git @ 896ba0e03f520fb9b6ed582bde2bd00847e3c3f2 " , <nl> " v8 / tools / clang " : <nl> - Var ( " git_url " ) + " / chromium / src / tools / clang . git @ 327e26ee7f6ae6f86fb335113b46cb86ed3cb0dc " , <nl> + Var ( " git_url " ) + " / chromium / src / tools / clang . git @ 72cba933544c8283c173083fbc5f162d00198081 " , <nl> } <nl> <nl> deps_os = { <nl>
|
Update V8 DEPS .
|
v8/v8
|
c174d14578e063ccaf096721154b14c8db091a03
|
2014-12-05T04:27:56Z
|
mmm a / docs / CHANGELOG . txt <nl> ppp b / docs / CHANGELOG . txt <nl> Other Changes : <nl> scrolling policy enabled ) or if is currently appearing . <nl> - TabBar : Fixed Tab tooltip code making drag and drop tooltip disappear during the frame where <nl> the drag payload activate a tab . <nl> + - TabBar : Reworked scrolling policy ( when ImGuiTabBarFlags_FittingPolicyScroll is set ) to <nl> + teleport the view when aiming at a tab far away the visible section , and otherwise accelerate <nl> + the scrolling speed to cap the scrolling time to 0 . 3 seconds . <nl> - Text : Fixed large Text / TextUnformatted call not declaring its size when starting below the <nl> lower point of the current clipping rectangle . Somehow this bug has been there since v1 . 0 ! <nl> It was hardly noticeable but would affect the scrolling range , which in turn would affect <nl> mmm a / imgui_internal . h <nl> ppp b / imgui_internal . h <nl> struct ImGuiTabBar <nl> float OffsetNextTab ; / / Distance from BarRect . Min . x , incremented with each BeginTabItem ( ) call , not used if ImGuiTabBarFlags_Reorderable if set . <nl> float ScrollingAnim ; <nl> float ScrollingTarget ; <nl> + float ScrollingTargetDistToVisibility ; <nl> + float ScrollingSpeed ; <nl> ImGuiTabBarFlags Flags ; <nl> ImGuiID ReorderRequestTabId ; <nl> int ReorderRequestDir ; <nl> mmm a / imgui_widgets . cpp <nl> ppp b / imgui_widgets . cpp <nl> ImGuiTabBar : : ImGuiTabBar ( ) <nl> CurrFrameVisible = PrevFrameVisible = - 1 ; <nl> ContentsHeight = 0 . 0f ; <nl> OffsetMax = OffsetNextTab = 0 . 0f ; <nl> - ScrollingAnim = ScrollingTarget = 0 . 0f ; <nl> + ScrollingAnim = ScrollingTarget = ScrollingTargetDistToVisibility = ScrollingSpeed = 0 . 0f ; <nl> Flags = ImGuiTabBarFlags_None ; <nl> ReorderRequestTabId = 0 ; <nl> ReorderRequestDir = 0 ; <nl> static void ImGui : : TabBarLayout ( ImGuiTabBar * tab_bar ) <nl> TabBarScrollToTab ( tab_bar , scroll_track_selected_tab ) ; <nl> tab_bar - > ScrollingAnim = TabBarScrollClamp ( tab_bar , tab_bar - > ScrollingAnim ) ; <nl> tab_bar - > ScrollingTarget = TabBarScrollClamp ( tab_bar , tab_bar - > ScrollingTarget ) ; <nl> - const float scrolling_speed = ( tab_bar - > PrevFrameVisible + 1 < g . FrameCount ) ? FLT_MAX : ( g . IO . DeltaTime * g . FontSize * 70 . 0f ) ; <nl> if ( tab_bar - > ScrollingAnim ! = tab_bar - > ScrollingTarget ) <nl> - tab_bar - > ScrollingAnim = ImLinearSweep ( tab_bar - > ScrollingAnim , tab_bar - > ScrollingTarget , scrolling_speed ) ; <nl> + { <nl> + / / Scrolling speed adjust itself so we can always reach our target in 1 / 3 seconds . <nl> + / / Teleport if we are aiming far off the visible line <nl> + tab_bar - > ScrollingSpeed = ImMax ( tab_bar - > ScrollingSpeed , 70 . 0f * g . FontSize ) ; <nl> + tab_bar - > ScrollingSpeed = ImMax ( tab_bar - > ScrollingSpeed , ImFabs ( tab_bar - > ScrollingTarget - tab_bar - > ScrollingAnim ) / 0 . 3f ) ; <nl> + const bool teleport = ( tab_bar - > PrevFrameVisible + 1 < g . FrameCount ) | | ( tab_bar - > ScrollingTargetDistToVisibility > 10 . 0f * g . FontSize ) ; <nl> + tab_bar - > ScrollingAnim = teleport ? tab_bar - > ScrollingTarget : ImLinearSweep ( tab_bar - > ScrollingAnim , tab_bar - > ScrollingTarget , g . IO . DeltaTime * tab_bar - > ScrollingSpeed ) ; <nl> + } <nl> + else <nl> + { <nl> + tab_bar - > ScrollingSpeed = 0 . 0f ; <nl> + } <nl> <nl> / / Clear name buffers <nl> if ( ( tab_bar - > Flags & ImGuiTabBarFlags_DockNode ) = = 0 ) <nl> static void ImGui : : TabBarScrollToTab ( ImGuiTabBar * tab_bar , ImGuiTabItem * tab ) <nl> int order = tab_bar - > GetTabOrder ( tab ) ; <nl> float tab_x1 = tab - > Offset + ( order > 0 ? - margin : 0 . 0f ) ; <nl> float tab_x2 = tab - > Offset + tab - > Width + ( order + 1 < tab_bar - > Tabs . Size ? margin : 1 . 0f ) ; <nl> + tab_bar - > ScrollingTargetDistToVisibility = 0 . 0f ; <nl> if ( tab_bar - > ScrollingTarget > tab_x1 ) <nl> + { <nl> + tab_bar - > ScrollingTargetDistToVisibility = ImMax ( tab_bar - > ScrollingAnim - tab_x2 , 0 . 0f ) ; <nl> tab_bar - > ScrollingTarget = tab_x1 ; <nl> - if ( tab_bar - > ScrollingTarget + tab_bar - > BarRect . GetWidth ( ) < tab_x2 ) <nl> + } <nl> + else if ( tab_bar - > ScrollingTarget < tab_x2 - tab_bar - > BarRect . GetWidth ( ) ) <nl> + { <nl> + tab_bar - > ScrollingTargetDistToVisibility = ImMax ( ( tab_x1 - tab_bar - > BarRect . GetWidth ( ) ) - tab_bar - > ScrollingAnim , 0 . 0f ) ; <nl> tab_bar - > ScrollingTarget = tab_x2 - tab_bar - > BarRect . GetWidth ( ) ; <nl> + } <nl> } <nl> <nl> void ImGui : : TabBarQueueChangeTabOrder ( ImGuiTabBar * tab_bar , const ImGuiTabItem * tab , int dir ) <nl>
|
TabBar : Reworked scrolling policy ( when ImGuiTabBarFlags_FittingPolicyScroll is set ) to teleport the view when aiming at a tab far away the visible section , and otherwise accelerate the scrolling speed to cap the scrolling time to 0 . 3 seconds .
|
ocornut/imgui
|
53e0c13be20c9986d52b385fd07f35504350a6de
|
2019-03-12T19:57:02Z
|
mmm a / build_tools / build_detect_platform <nl> ppp b / build_tools / build_detect_platform <nl> EOF <nl> JAVA_LDFLAGS = " $ JAVA_LDFLAGS - lsnappy " <nl> fi <nl> <nl> - <nl> # Test whether gflags library is installed <nl> # http : / / code . google . com / p / gflags / <nl> # check if the namespace is gflags <nl> - $ CXX $ CFLAGS - x c + + - - o / dev / null 2 > / dev / null < < EOF <nl> - # include < gflags / gflags . h > <nl> - using namespace gflags ; <nl> - int main ( ) { } <nl> - EOF <nl> - if [ " $ ? " = 0 ] ; then <nl> + if echo " # include < gflags / gflags . h > \ nusing namespace gflags ; \ nint main ( ) { } " | \ <nl> + $ CXX $ CFLAGS - x c + + - - o / dev / null 2 > / dev / null ; then <nl> COMMON_FLAGS = " $ COMMON_FLAGS - DGFLAGS = gflags " <nl> PLATFORM_LDFLAGS = " $ PLATFORM_LDFLAGS - lgflags " <nl> - fi <nl> - <nl> - # check if namespace is google <nl> - $ CXX $ CFLAGS - x c + + - - o / dev / null 2 > / dev / null < < EOF <nl> - # include < gflags / gflags . h > <nl> - using namespace google ; <nl> - int main ( ) { } <nl> - EOF <nl> - if [ " $ ? " = 0 ] ; then <nl> - COMMON_FLAGS = " $ COMMON_FLAGS - DGFLAGS = google " <nl> - PLATFORM_LDFLAGS = " $ PLATFORM_LDFLAGS - lgflags " <nl> + else <nl> + if echo " # include < gflags / gflags . h > \ nusing namespace google ; \ nint main ( ) { } " | \ <nl> + $ CXX $ CFLAGS - x c + + - - o / dev / null ; then <nl> + COMMON_FLAGS = " $ COMMON_FLAGS - DGFLAGS = google " <nl> + PLATFORM_LDFLAGS = " $ PLATFORM_LDFLAGS - lgflags " <nl> + fi <nl> fi <nl> <nl> # Test whether zlib library is installed <nl>
|
Fix compile with two gflags
|
facebook/rocksdb
|
742fa9e316a10403ba7321596cc58eac63867f13
|
2015-04-20T17:55:17Z
|
mmm a / drivers / python / rethinkdb / ast . py <nl> ppp b / drivers / python / rethinkdb / ast . py <nl> <nl> import types <nl> import sys <nl> from errors import * <nl> + from net import Connection <nl> <nl> class RqlQuery ( object ) : <nl> <nl> def __init__ ( self , * args , * * optargs ) : <nl> self . optargs [ k ] = expr ( optargs [ k ] ) <nl> <nl> # Send this query to the server to be executed <nl> - def run ( self , c , * * global_opt_args ) : <nl> + def run ( self , c = None , * * global_opt_args ) : <nl> + if not c : <nl> + if Connection . repl_connection : <nl> + c = Connection . repl_connection <nl> + else : <nl> + raise RqlDriverError ( " RqlQuery . run must be given a connection to run on . " ) <nl> + <nl> return c . _start ( self , * * global_opt_args ) <nl> <nl> def __str__ ( self ) : <nl> mmm a / drivers / python / rethinkdb / net . py <nl> ppp b / drivers / python / rethinkdb / net . py <nl> def close ( self ) : <nl> self . conn . _end ( self . query , self . term ) <nl> <nl> class Connection ( object ) : <nl> + repl_connection = None <nl> <nl> def __init__ ( self , host , port , db = ' test ' ) : <nl> self . socket = None <nl> def close ( self ) : <nl> self . socket . close ( ) <nl> self . socket = None <nl> <nl> + # Not thread safe . Sets this connection as global state that will be used <nl> + # by subsequence calls to ` query . run ` . Useful for trying out RethinkDB in <nl> + # a Python repl environment . <nl> + def repl ( self ) : <nl> + Connection . repl_connection = self <nl> + return self <nl> + <nl> def _start ( self , term , * * global_opt_args ) : <nl> token = self . next_token <nl> self . next_token + = 1 <nl>
|
adds ' . repl ' to python connections as per
|
rethinkdb/rethinkdb
|
32e4e603ae85df32bf22a4f46a3a655b6a85b300
|
2013-03-12T02:15:06Z
|
mmm a / db / pipeline / document_source . h <nl> ppp b / db / pipeline / document_source . h <nl> namespace mongo { <nl> * / <nl> void populate ( ) ; <nl> bool populated ; <nl> - long long limit ; <nl> - long long skip ; <nl> long long count ; <nl> <nl> / * these two parallel each other * / <nl> namespace mongo { <nl> virtual intrusive_ptr < Document > getCurrent ( ) ; <nl> <nl> / * <nl> - Create a new sorting DocumentSource . <nl> + Create a new limiting DocumentSource . <nl> <nl> @ param pCtx the expression context <nl> @ returns the DocumentSource <nl> namespace mongo { <nl> const intrusive_ptr < ExpressionContext > & pCtx ) ; <nl> <nl> / * <nl> - Add sort key field . <nl> - <nl> - Adds a sort key field to the key being built up . A concatenated <nl> - key is built up by calling this repeatedly . <nl> - <nl> - @ params fieldPath the field path to the key component <nl> - @ params ascending if true , use the key for an ascending sort , <nl> - otherwise , use it for descending <nl> - * / <nl> - void addKey ( const string & fieldPath , bool ascending ) ; <nl> - <nl> - / * <nl> - Create a sorting DocumentSource from BSON . <nl> + Create a limiting DocumentSource from BSON . <nl> <nl> This is a convenience method that uses the above , and operates on <nl> a BSONElement that has been deteremined to be an Object with an <nl> - element named $ group . <nl> + element named $ limit . <nl> <nl> - @ param pBsonElement the BSONELement that defines the group <nl> + @ param pBsonElement the BSONELement that defines the limit <nl> @ param pCtx the expression context <nl> @ returns the grouping DocumentSource <nl> * / <nl> namespace mongo { <nl> virtual intrusive_ptr < Document > getCurrent ( ) ; <nl> <nl> / * <nl> - Create a new sorting DocumentSource . <nl> + Create a new skipping DocumentSource . <nl> <nl> @ param pCtx the expression context <nl> @ returns the DocumentSource <nl> namespace mongo { <nl> const intrusive_ptr < ExpressionContext > & pCtx ) ; <nl> <nl> / * <nl> - Add sort key field . <nl> - <nl> - Adds a sort key field to the key being built up . A concatenated <nl> - key is built up by calling this repeatedly . <nl> - <nl> - @ params fieldPath the field path to the key component <nl> - @ params ascending if true , use the key for an ascending sort , <nl> - otherwise , use it for descending <nl> - * / <nl> - void addKey ( const string & fieldPath , bool ascending ) ; <nl> - <nl> - / * <nl> - Create a sorting DocumentSource from BSON . <nl> + Create a skipping DocumentSource from BSON . <nl> <nl> This is a convenience method that uses the above , and operates on <nl> a BSONElement that has been deteremined to be an Object with an <nl> - element named $ group . <nl> + element named $ skip . <nl> <nl> - @ param pBsonElement the BSONELement that defines the group <nl> + @ param pBsonElement the BSONELement that defines the skip <nl> @ param pCtx the expression context <nl> @ returns the grouping DocumentSource <nl> * / <nl>
|
fix copy - paste issues in header file
|
mongodb/mongo
|
58a5a1ad68dd5865bb81b7b6a9697756d9bad8bc
|
2011-09-26T16:36:27Z
|
mmm a / tensorflow / python / training / warm_starting_util . py <nl> ppp b / tensorflow / python / training / warm_starting_util . py <nl> def _infer_var_name ( var ) : <nl> return list ( name_to_var_dict . keys ( ) ) [ 0 ] <nl> <nl> <nl> - def _warm_start_var ( var , prev_ckpt , prev_tensor_name = None ) : <nl> - " " " Warm - starts given variable from ` prev_tensor_name ` tensor in ` prev_ckpt ` . <nl> + def _get_var_info ( var , prev_tensor_name = None ) : <nl> + " " " Helper method for standarizing Variable and naming . <nl> <nl> Args : <nl> var : Current graph ' s variable that needs to be warm - started ( initialized ) . <nl> - Can be either of the following : <nl> - ( i ) ` Variable ` <nl> - ( ii ) ` ResourceVariable ` <nl> + Can be either of the following : ( i ) ` Variable ` ( ii ) ` ResourceVariable ` <nl> ( iii ) list of ` Variable ` : The list must contain slices of the same larger <nl> - variable . <nl> - ( iv ) ` PartitionedVariable ` <nl> - prev_ckpt : A string specifying the directory with checkpoint file ( s ) or path <nl> - to checkpoint . The given checkpoint must have tensor with name <nl> - ` prev_tensor_name ` ( if not None ) or tensor with name same as given ` var ` . <nl> + variable . ( iv ) ` PartitionedVariable ` <nl> prev_tensor_name : Name of the tensor to lookup in provided ` prev_ckpt ` . If <nl> None , we lookup tensor with same name as given ` var ` . <nl> + <nl> + Returns : <nl> + A tuple of the Tensor name and var . <nl> " " " <nl> if checkpoint_utils . _is_variable ( var ) : # pylint : disable = protected - access <nl> current_var_name = _infer_var_name ( [ var ] ) <nl> def _warm_start_var ( var , prev_ckpt , prev_tensor_name = None ) : <nl> if not prev_tensor_name : <nl> # Assume tensor name remains the same . <nl> prev_tensor_name = current_var_name <nl> - checkpoint_utils . init_from_checkpoint ( prev_ckpt , { prev_tensor_name : var } ) <nl> + <nl> + return prev_tensor_name , var <nl> <nl> <nl> # pylint : disable = protected - access <nl> def warm_start ( ckpt_to_initialize_from , <nl> prev_var_name_used = set ( ) <nl> vocab_info_used = set ( ) <nl> <nl> + # Group the vocabless vars into one call to init_from_checkpoint . <nl> + vocabless_vars = { } <nl> for var_name , variable in six . iteritems ( grouped_variables ) : <nl> prev_var_name = var_name_to_prev_var_name . get ( var_name ) <nl> if prev_var_name : <nl> def warm_start ( ckpt_to_initialize_from , <nl> # for init_from_checkpoint logic to work correctly . <nl> if len ( variable ) = = 1 : <nl> variable = variable [ 0 ] <nl> - _warm_start_var ( variable , ckpt_to_initialize_from , prev_var_name ) <nl> + prev_tensor_name , var = _get_var_info ( variable , prev_var_name ) <nl> + vocabless_vars [ prev_tensor_name ] = var <nl> <nl> + checkpoint_utils . init_from_checkpoint ( ckpt_to_initialize_from , vocabless_vars ) <nl> prev_var_name_not_used = set ( <nl> var_name_to_prev_var_name . keys ( ) ) - prev_var_name_used <nl> vocab_info_not_used = set ( var_name_to_vocab_info . keys ( ) ) - vocab_info_used <nl> mmm a / tensorflow / python / training / warm_starting_util_test . py <nl> ppp b / tensorflow / python / training / warm_starting_util_test . py <nl> <nl> from tensorflow . python . ops import variable_scope <nl> from tensorflow . python . ops import variables <nl> from tensorflow . python . platform import test <nl> + from tensorflow . python . training import checkpoint_utils <nl> from tensorflow . python . training import saver as saver_lib <nl> from tensorflow . python . training import warm_starting_util as ws_util <nl> <nl> def testWarmStartVar ( self ) : <nl> with self . session ( graph = g ) as sess : <nl> fruit_weights = variable_scope . get_variable ( <nl> " fruit_weights " , initializer = [ [ 0 . ] , [ 0 . ] , [ 0 . ] , [ 0 . ] ] ) <nl> - ws_util . _warm_start_var ( fruit_weights , self . get_temp_dir ( ) ) <nl> + prev_tensor_name , var = ws_util . _get_var_info ( fruit_weights ) <nl> + checkpoint_utils . init_from_checkpoint ( self . get_temp_dir ( ) , <nl> + { prev_tensor_name : var } ) <nl> sess . run ( variables . global_variables_initializer ( ) ) <nl> self . assertAllClose ( prev_val , fruit_weights . eval ( sess ) ) <nl> <nl> def testWarmStartVarPrevVarPartitioned ( self ) : <nl> with self . session ( graph = g ) as sess : <nl> fruit_weights = variable_scope . get_variable ( <nl> " fruit_weights " , initializer = [ [ 0 . ] , [ 0 . ] , [ 0 . ] , [ 0 . ] ] ) <nl> - ws_util . _warm_start_var ( fruit_weights , self . get_temp_dir ( ) ) <nl> + prev_tensor_name , var = ws_util . _get_var_info ( fruit_weights ) <nl> + checkpoint_utils . init_from_checkpoint ( self . get_temp_dir ( ) , <nl> + { prev_tensor_name : var } ) <nl> sess . run ( variables . global_variables_initializer ( ) ) <nl> self . assertAllClose ( prev_val , fruit_weights . eval ( sess ) ) <nl> <nl> def testWarmStartVarCurrentVarPartitioned ( self ) : <nl> partitioner = lambda shape , dtype : [ 2 , 1 ] ) <nl> self . assertTrue ( <nl> isinstance ( fruit_weights , variables . PartitionedVariable ) ) <nl> - ws_util . _warm_start_var ( fruit_weights , self . get_temp_dir ( ) ) <nl> + prev_tensor_name , var = ws_util . _get_var_info ( fruit_weights ) <nl> + checkpoint_utils . init_from_checkpoint ( self . get_temp_dir ( ) , <nl> + { prev_tensor_name : var } ) <nl> sess . run ( variables . global_variables_initializer ( ) ) <nl> fruit_weights = fruit_weights . _get_variable_list ( ) <nl> new_val = np . concatenate ( <nl> def testWarmStartVarBothVarsPartitioned ( self ) : <nl> partitioner = lambda shape , dtype : [ 2 , 1 ] ) <nl> self . assertTrue ( <nl> isinstance ( fruit_weights , variables . PartitionedVariable ) ) <nl> - ws_util . _warm_start_var ( <nl> - fruit_weights , <nl> - self . get_temp_dir ( ) , <nl> - prev_tensor_name = " old_scope / fruit_weights " ) <nl> + prev_tensor_name , var = ws_util . _get_var_info ( <nl> + fruit_weights , prev_tensor_name = " old_scope / fruit_weights " ) <nl> + checkpoint_utils . init_from_checkpoint ( self . get_temp_dir ( ) , <nl> + { prev_tensor_name : var } ) <nl> sess . run ( variables . global_variables_initializer ( ) ) <nl> fruit_weights = fruit_weights . _get_variable_list ( ) <nl> new_val = np . concatenate ( <nl>
|
Group the warm - starting of no - vocab variables into one init_from_checkpoint call for efficiency .
|
tensorflow/tensorflow
|
f348ee8a0931c5048a3ed4f8d16b2f47a7466d39
|
2018-10-26T20:47:00Z
|
mmm a / python - package / xgboost / core . py <nl> ppp b / python - package / xgboost / core . py <nl> def predict ( self , data , output_margin = False , ntree_limit = 0 , pred_leaf = False ) : <nl> preds = preds . astype ( np . int32 ) <nl> nrow = data . num_row ( ) <nl> if preds . size ! = nrow and preds . size % nrow = = 0 : <nl> - preds = preds . reshape ( nrow , preds . size / nrow ) <nl> + ncol = int ( preds . size / nrow ) <nl> + preds = preds . reshape ( nrow , ncol ) <nl> return preds <nl> <nl> def save_model ( self , fname ) : <nl> mmm a / python - package / xgboost / training . py <nl> ppp b / python - package / xgboost / training . py <nl> def mknfold ( dall , nfold , param , seed , evals = ( ) , fpreproc = None , stratified = False , <nl> <nl> if stratified is False and folds is None : <nl> randidx = np . random . permutation ( dall . num_row ( ) ) <nl> - kstep = len ( randidx ) / nfold <nl> + kstep = int ( len ( randidx ) / nfold ) <nl> idset = [ randidx [ ( i * kstep ) : min ( len ( randidx ) , ( i + 1 ) * kstep ) ] for i in range ( nfold ) ] <nl> elif folds is not None : <nl> idset = [ x [ 1 ] for x in folds ] <nl>
|
Merge pull request from shaynekang / visible_deprecation_warning
|
dmlc/xgboost
|
bab69919d2f91b082c8c533c82587a9886cf4cf2
|
2016-05-07T18:11:58Z
|
mmm a / torch / csrc / jit / register_c10_ops . cpp <nl> ppp b / torch / csrc / jit / register_c10_ops . cpp <nl> at : : Tensor unwrap_tensor ( at : : Tensor & & tensor ) { <nl> if ( tensor . requires_grad ( ) ) { <nl> throw std : : runtime_error ( " Autograd not yet supported for c10 ops . " ) ; <nl> } <nl> - return torch : : autograd : : Variable ( std : : move ( tensor ) ) . data ( ) ; <nl> + if ( tensor . is_variable ( ) ) { <nl> + return torch : : autograd : : Variable ( std : : move ( tensor ) ) . data ( ) ; <nl> + } else { <nl> + return std : : move ( tensor ) ; <nl> + } <nl> } <nl> <nl> IValue unwrap ( IValue & & ivalue ) { <nl> IValue unwrap ( IValue & & ivalue ) { <nl> } <nl> <nl> at : : Tensor wrap_tensor ( at : : Tensor & & tensor ) { <nl> - return torch : : autograd : : make_variable ( tensor ) ; <nl> + if ( tensor . is_variable ( ) ) { <nl> + return std : : move ( tensor ) ; <nl> + } else { <nl> + return torch : : autograd : : make_variable ( std : : move ( tensor ) ) ; <nl> + } <nl> } <nl> <nl> IValue wrap ( IValue & & ivalue ) { <nl>
|
Allow both Variables and Tensors in c10 kernel interface ( )
|
pytorch/pytorch
|
98928f4d798e66503f6dd4a15ea406e157ecfd71
|
2019-05-22T23:03:12Z
|
mmm a / src / arch / io / disk / aio / getevents_eventfd . cc <nl> ppp b / src / arch / io / disk / aio / getevents_eventfd . cc <nl> void linux_aio_getevents_eventfd_t : : prep ( iocb * req ) { <nl> void linux_aio_getevents_eventfd_t : : on_event ( int event_mask ) { <nl> <nl> if ( event_mask ! = poll_event_in ) { <nl> - logERR ( " Unexpected event mask : % d \ n " , event_mask ) ; <nl> + logERR ( " Unexpected event mask : % d " , event_mask ) ; <nl> } <nl> <nl> eventfd_t nevents_total ; <nl> mmm a / src / arch / io / disk / aio / getevents_noeventfd . cc <nl> ppp b / src / arch / io / disk / aio / getevents_noeventfd . cc <nl> void linux_aio_getevents_noeventfd_t : : prep ( UNUSED iocb * req ) { <nl> void linux_aio_getevents_noeventfd_t : : on_event ( int event_mask ) { <nl> <nl> if ( event_mask ! = poll_event_in ) { <nl> - logERR ( " Unexpected event mask : % d \ n " , event_mask ) ; <nl> + logERR ( " Unexpected event mask : % d " , event_mask ) ; <nl> } <nl> <nl> / / Make sure we flush the pipe <nl> mmm a / src / arch / io / io_utils . cc <nl> ppp b / src / arch / io / io_utils . cc <nl> fd_t scoped_fd_t : : reset ( fd_t f2 ) { <nl> if ( fd ! = INVALID_FD ) { <nl> int res = close ( fd ) ; <nl> if ( res ! = 0 ) { <nl> - logERR ( " Error in close ( ) : % s \ n " , strerror ( errno ) ) ; <nl> + logERR ( " Error in close ( ) : % s " , strerror ( errno ) ) ; <nl> } <nl> } <nl> fd = f2 ; <nl> mmm a / src / arch / io / network . cc <nl> ppp b / src / arch / io / network . cc <nl> fd_t connect_to ( const char * host , int port , int local_port ) { <nl> <nl> / * make the connection * / <nl> if ( getaddrinfo ( host , port_str . c_str ( ) , NULL , & res ) ! = 0 ) { <nl> - logERR ( " Failed to look up address % s : % d . \ n " , host , port ) ; <nl> + logERR ( " Failed to look up address % s : % d . " , host , port ) ; <nl> goto ERROR_BREAKOUT ; <nl> } <nl> <nl> { <nl> scoped_fd_t sock ( socket ( res - > ai_family , res - > ai_socktype , res - > ai_protocol ) ) ; <nl> if ( sock . get ( ) = = INVALID_FD ) { <nl> - logERR ( " Failed to create a socket \ n " ) ; <nl> + logERR ( " Failed to create a socket " ) ; <nl> goto ERROR_BREAKOUT ; <nl> } <nl> if ( local_port ! = 0 ) { <nl> / / Set the socket to reusable so we don ' t block out other sockets from this port <nl> int reuse = 1 ; <nl> if ( setsockopt ( sock . get ( ) , SOL_SOCKET , SO_REUSEADDR , & reuse , sizeof ( reuse ) ) ! = 0 ) <nl> - logINF ( " Failed to set socket reuse to true : % s \ n " , strerror ( errno ) ) ; <nl> + logINF ( " Failed to set socket reuse to true : % s " , strerror ( errno ) ) ; <nl> struct sockaddr_in addr ; <nl> addr . sin_family = AF_INET ; <nl> addr . sin_port = htons ( local_port ) ; <nl> addr . sin_addr . s_addr = INADDR_ANY ; <nl> bzero ( addr . sin_zero , sizeof ( addr . sin_zero ) ) ; <nl> if ( bind ( sock . get ( ) , reinterpret_cast < struct sockaddr * > ( & addr ) , sizeof ( addr ) ) ! = 0 ) <nl> - logINF ( " Failed to bind to local port % d : % s \ n " , local_port , strerror ( errno ) ) ; <nl> + logINF ( " Failed to bind to local port % d : % s " , local_port , strerror ( errno ) ) ; <nl> } <nl> if ( connect ( sock . get ( ) , res - > ai_addr , res - > ai_addrlen ) ! = 0 ) { <nl> / * for some reason the connection failed * / <nl> - logERR ( " Failed to make a connection with error : % s \ n " , strerror ( errno ) ) ; <nl> + logERR ( " Failed to make a connection with error : % s " , strerror ( errno ) ) ; <nl> goto ERROR_BREAKOUT ; <nl> } <nl> <nl> fd_t connect_to ( const ip_address_t & host , int port , int local_port ) { <nl> / / Set the socket to reusable so we don ' t block out other sockets from this port <nl> int reuse = 1 ; <nl> if ( setsockopt ( sock . get ( ) , SOL_SOCKET , SO_REUSEADDR , & reuse , sizeof ( reuse ) ) ! = 0 ) <nl> - logINF ( " Failed to set socket reuse to true : % s \ n " , strerror ( errno ) ) ; <nl> + logINF ( " Failed to set socket reuse to true : % s " , strerror ( errno ) ) ; <nl> addr . sin_family = AF_INET ; <nl> addr . sin_port = htons ( local_port ) ; <nl> addr . sin_addr . s_addr = INADDR_ANY ; <nl> bzero ( addr . sin_zero , sizeof ( addr . sin_zero ) ) ; <nl> if ( bind ( sock . get ( ) , reinterpret_cast < struct sockaddr * > ( & addr ) , sizeof ( addr ) ) ! = 0 ) <nl> - logINF ( " Failed to bind to local port % d : % s \ n " , local_port , strerror ( errno ) ) ; <nl> + logINF ( " Failed to bind to local port % d : % s " , local_port , strerror ( errno ) ) ; <nl> } <nl> <nl> addr . sin_family = AF_INET ; <nl> fd_t connect_to ( const ip_address_t & host , int port , int local_port ) { <nl> <nl> if ( connect ( sock . get ( ) , reinterpret_cast < struct sockaddr * > ( & addr ) , sizeof ( addr ) ) ! = 0 ) { <nl> / * for some reason the connection failed * / <nl> - logINF ( " Failed to make a connection with error : % s \ n " , strerror ( errno ) ) ; <nl> + logINF ( " Failed to make a connection with error : % s " , strerror ( errno ) ) ; <nl> throw linux_tcp_conn_t : : connect_failed_exc_t ( ) ; <nl> } <nl> <nl> size_t linux_tcp_conn_t : : read_internal ( void * buffer , size_t size ) { <nl> } else if ( res = = - 1 ) { <nl> / * Unknown error . This is not expected , but it will probably happen sometime so we <nl> shouldn ' t crash . * / <nl> - logERR ( " Could not read from socket : % s \ n " , strerror ( errno ) ) ; <nl> + logERR ( " Could not read from socket : % s " , strerror ( errno ) ) ; <nl> on_shutdown_read ( ) ; <nl> throw read_closed_exc_t ( ) ; <nl> <nl> void linux_tcp_conn_t : : shutdown_read ( ) { <nl> assert_thread ( ) ; <nl> int res = : : shutdown ( sock . get ( ) , SHUT_RD ) ; <nl> if ( res ! = 0 & & errno ! = ENOTCONN ) { <nl> - logERR ( " Could not shutdown socket for reading : % s \ n " , strerror ( errno ) ) ; <nl> + logERR ( " Could not shutdown socket for reading : % s " , strerror ( errno ) ) ; <nl> } <nl> on_shutdown_read ( ) ; <nl> } <nl> void linux_tcp_conn_t : : perform_write ( const void * buf , size_t size ) { <nl> } else if ( res = = - 1 ) { <nl> / * In theory this should never happen , but it probably will . So we write a log message <nl> and then shut down normally . * / <nl> - logERR ( " Could not write to socket : % s \ n " , strerror ( errno ) ) ; <nl> + logERR ( " Could not write to socket : % s " , strerror ( errno ) ) ; <nl> on_shutdown_write ( ) ; <nl> break ; <nl> <nl> } else if ( res = = 0 ) { <nl> / * This should never happen either , but it ' s better to write an error message than to <nl> crash completely . * / <nl> - logERR ( " Didn ' t expect write ( ) to return 0 . \ n " ) ; <nl> + logERR ( " Didn ' t expect write ( ) to return 0 . " ) ; <nl> on_shutdown_write ( ) ; <nl> break ; <nl> <nl> void linux_tcp_conn_t : : shutdown_write ( ) { <nl> <nl> int res = : : shutdown ( sock . get ( ) , SHUT_WR ) ; <nl> if ( res ! = 0 & & errno ! = ENOTCONN ) { <nl> - logERR ( " Could not shutdown socket for writing : % s \ n " , strerror ( errno ) ) ; <nl> + logERR ( " Could not shutdown socket for writing : % s " , strerror ( errno ) ) ; <nl> } <nl> <nl> on_shutdown_write ( ) ; <nl> void linux_tcp_conn_t : : on_event ( int events ) { <nl> <nl> } else { <nl> / * We don ' t know why we got this , so log it and then shut down the socket * / <nl> - logERR ( " Unexpected epoll err / hup / rdhup . events = % s , reading = % s , writing = % s \ n " , <nl> + logERR ( " Unexpected epoll err / hup / rdhup . events = % s , reading = % s , writing = % s " , <nl> format_poll_event ( events ) . c_str ( ) , <nl> reading ? " yes " : " no " , <nl> writing ? " yes " : " no " ) ; <nl> linux_tcp_listener_t : : linux_tcp_listener_t ( <nl> res = fcntl ( sock . get ( ) , F_SETFL , O_NONBLOCK ) ; <nl> guarantee_err ( res = = 0 , " Could not make socket non - blocking " ) ; <nl> <nl> - logINF ( " Listening on port % d \ n " , port ) ; <nl> + logINF ( " Listening on port % d " , port ) ; <nl> <nl> / / Start the accept loop <nl> accept_loop_drainer . reset ( new auto_drainer_t ) ; <nl> void linux_tcp_listener_t : : accept_loop ( auto_drainer_t : : lock_t lock ) { <nl> } else { <nl> / * Unexpected error . Log it unless it ' s a repeat error . * / <nl> if ( log_next_error ) { <nl> - logERR ( " accept ( ) failed : % s . \ n " , <nl> + logERR ( " accept ( ) failed : % s . " , <nl> strerror ( errno ) ) ; <nl> log_next_error = false ; <nl> } <nl> void linux_tcp_listener_t : : on_event ( int events ) { <nl> via event_listener . watch ( ) . * / <nl> <nl> if ( log_next_error ) { <nl> - logERR ( " poll ( ) / epoll ( ) sent linux_tcp_listener_t errors : % d . \ n " , events ) ; <nl> + logERR ( " poll ( ) / epoll ( ) sent linux_tcp_listener_t errors : % d . " , events ) ; <nl> log_next_error = false ; <nl> } <nl> } <nl> mmm a / src / arch / io / perfmon_system . cc <nl> ppp b / src / arch / io / perfmon_system . cc <nl> struct perfmon_system_t : <nl> } catch ( proc_pid_stat_exc_t e ) { <nl> if ( ! have_reported_error ) { <nl> logWRN ( " Error in reporting system stats : % s ( Further errors like this will " <nl> - " be suppressed . ) \ n " , e . what ( ) ) ; <nl> + " be suppressed . ) " , e . what ( ) ) ; <nl> have_reported_error = true ; <nl> } <nl> return ; <nl> struct perfmon_system_t : <nl> } <nl> void put_timestamp ( perfmon_stats_t * dest ) { <nl> time_t now = time ( NULL ) ; <nl> - ( * dest ) [ " uptime " ] = strprintf ( " % d " , now - start_time ) ; <nl> + ( * dest ) [ " uptime " ] = strprintf ( " % d " , int ( difftime ( start_time , now ) ) ) ; <nl> ( * dest ) [ " timestamp " ] = format_time ( now ) ; <nl> } <nl> <nl> void poll_system_stats ( void * ) { <nl> } catch ( proc_pid_stat_exc_t e ) { <nl> if ( ! TLS_get_have_reported_stats_error ( ) ) { <nl> logWRN ( " Error in reporting per - thread stats : % s ( Further errors like this will " <nl> - " be suppressed . ) \ n " , e . what ( ) ) ; <nl> + " be suppressed . ) " , e . what ( ) ) ; <nl> TLS_set_have_reported_stats_error ( true ) ; <nl> } <nl> } <nl> mmm a / src / arch / io / timer / timerfd_provider . cc <nl> ppp b / src / arch / io / timer / timerfd_provider . cc <nl> timerfd_provider_t : : ~ timerfd_provider_t ( ) { <nl> <nl> void timerfd_provider_t : : on_event ( int events ) { <nl> if ( events ! = poll_event_in ) { <nl> - logERR ( " Unexpected event mask : % d \ n " , events ) ; <nl> + logERR ( " Unexpected event mask : % d " , events ) ; <nl> } <nl> <nl> int res ; <nl> mmm a / src / arch / runtime / message_hub . cc <nl> ppp b / src / arch / runtime / message_hub . cc <nl> void linux_message_hub_t : : insert_external_message ( linux_thread_message_t * msg ) { <nl> void linux_message_hub_t : : notify_t : : on_event ( int events ) { <nl> <nl> if ( events ! = poll_event_in ) { <nl> - logERR ( " Unexpected event mask : % d \ n " , events ) ; <nl> + logERR ( " Unexpected event mask : % d " , events ) ; <nl> } <nl> <nl> / / Read from the event so level - triggered mechanism such as poll <nl> mmm a / src / arch / runtime / runtime_utils . cc <nl> ppp b / src / arch / runtime / runtime_utils . cc <nl> void pet_watchdog ( ) { <nl> uint64_t delta = get_and_check_clock_cycles ( watchdog_start_time , MAX_WATCHDOG_DELTA ) ; <nl> <nl> if ( delta ! = 0 ) { <nl> - logWRN ( " task triggered watchdog , elapsed cycles : % lu , running coroutine : % s \ n " , delta , <nl> + logWRN ( " task triggered watchdog , elapsed cycles : % lu , running coroutine : % s " , delta , <nl> ( coro_t : : self ( ) = = NULL ) ? " n / a " : coro_t : : self ( ) - > get_coroutine_type ( ) . c_str ( ) ) ; <nl> } <nl> } <nl> mmm a / src / arch / runtime / thread_pool . cc <nl> ppp b / src / arch / runtime / thread_pool . cc <nl> void linux_thread_pool_t : : run ( linux_thread_message_t * initial_message ) { <nl> <nl> for ( std : : map < std : : string , size_t > : : iterator i = total_coroutine_counts . begin ( ) ; <nl> i ! = total_coroutine_counts . end ( ) ; + + i ) { <nl> - logDBG ( " % ld coroutines ran with type % s \ n " , i - > second , i - > first . c_str ( ) ) ; <nl> + logDBG ( " % ld coroutines ran with type % s " , i - > second , i - > first . c_str ( ) ) ; <nl> } <nl> } <nl> # endif <nl> void linux_thread_t : : on_event ( int events ) { <nl> / / so it can shut down . <nl> <nl> if ( events ! = poll_event_in ) { <nl> - logERR ( " Unexpected event mask : % d \ n " , events ) ; <nl> + logERR ( " Unexpected event mask : % d " , events ) ; <nl> } <nl> } <nl> <nl> mmm a / src / arch / timer . cc <nl> ppp b / src / arch / timer . cc <nl> timer_handler_t : : ~ timer_handler_t ( ) { <nl> / * This is an error . However , the best way to debug this error is to have <nl> the timer token leak and have Valgrind tell us where the leaked block originated <nl> from . So we just write a warning message . * / <nl> - logERR ( " Internal error : leaked timer . \ n " ) ; <nl> + logERR ( " Internal error : leaked timer . " ) ; <nl> } <nl> } <nl> } <nl> mmm a / src / buffer_cache / buf_patch . cc <nl> ppp b / src / buffer_cache / buf_patch . cc <nl> buf_patch_t * buf_patch_t : : load_patch ( const char * source ) { <nl> result - > set_block_sequence_id ( applies_to_block_sequence_id ) ; <nl> return result ; <nl> } catch ( patch_deserialization_error_t & e ) { <nl> - logERR ( " % s \ n " , e . c_str ( ) ) ; <nl> + logERR ( " % s " , e . c_str ( ) ) ; <nl> throw e ; <nl> } <nl> } <nl> mmm a / src / buffer_cache / mirrored / page_repl_random . cc <nl> ppp b / src / buffer_cache / mirrored / page_repl_random . cc <nl> void page_repl_random_t : : make_space ( unsigned int space_needed ) { <nl> <nl> if ( ! block_to_unload ) { <nl> if ( array . size ( ) > target + ( target / 100 ) + 10 ) <nl> - logDBG ( " cache % p exceeding memory target . % d blocks in memory , % d dirty , target is % d . \ n " , <nl> + logWRN ( " cache % p exceeding memory target . % d blocks in memory , % d dirty , target is % d . " , <nl> cache , array . size ( ) , cache - > writeback . num_dirty_blocks ( ) , target ) ; <nl> break ; <nl> } <nl> mmm a / src / clustering / administration / http / directory_app . cc <nl> ppp b / src / clustering / administration / http / directory_app . cc <nl> http_res_t directory_http_app_t : : handle ( const http_req_t & req ) { <nl> unreachable ( ) ; <nl> } catch ( schema_mismatch_exc_t & e ) { <nl> http_res_t res ( 404 ) ; <nl> - logINF ( " HTTP request threw a schema_mismatch_exc_t with what = : \ n % s \ n " , e . what ( ) ) ; <nl> + logINF ( " HTTP request threw a schema_mismatch_exc_t with what = % s " , e . what ( ) ) ; <nl> res . set_body ( " application / text " , e . what ( ) ) ; <nl> return res ; <nl> } catch ( permission_denied_exc_t & e ) { <nl> http_res_t res ( 403 ) ; / / TODO : should that be 405 Method Not Allowed ? <nl> - logINF ( " HTTP request threw a permission_denied_exc_t with what = : \ n % s \ n " , e . what ( ) ) ; <nl> + logINF ( " HTTP request threw a permission_denied_exc_t with what = % s " , e . what ( ) ) ; <nl> res . set_body ( " application / text " , e . what ( ) ) ; <nl> return res ; <nl> } <nl> mmm a / src / clustering / administration / http / log_app . cc <nl> ppp b / src / clustering / administration / http / log_app . cc <nl> <nl> # include " arch / timing . hpp " <nl> # include " clustering / administration / machine_id_to_peer_id . hpp " <nl> <nl> + template < class ctx_t > <nl> + cJSON * render_as_json ( log_message_t * message , const ctx_t & ) { <nl> + scoped_cJSON_t json ( cJSON_CreateObject ( ) ) ; <nl> + cJSON_AddItemToObject ( json . get ( ) , " timestamp " , cJSON_CreateNumber ( message - > timestamp ) ) ; <nl> + cJSON_AddItemToObject ( json . get ( ) , " uptime " , cJSON_CreateNumber ( message - > uptime . tv_sec + message - > uptime . tv_nsec / 1000000000 . 0 ) ) ; <nl> + cJSON_AddItemToObject ( json . get ( ) , " level " , cJSON_CreateString ( format_log_level ( message - > level ) . c_str ( ) ) ) ; <nl> + cJSON_AddItemToObject ( json . get ( ) , " message " , cJSON_CreateString ( message - > message . c_str ( ) ) ) ; <nl> + return json . release ( ) ; <nl> + } <nl> + <nl> log_http_app_t : : log_http_app_t ( <nl> mailbox_manager_t * mm , <nl> - const clone_ptr_t < watchable_t < std : : map < peer_id_t , mailbox_addr_t < void ( mailbox_addr_t < void ( std : : vector < std : : string > ) > ) > > > > & lmv , <nl> + const clone_ptr_t < watchable_t < std : : map < peer_id_t , log_server_business_card_t > > > & lmv , <nl> const clone_ptr_t < watchable_t < std : : map < peer_id_t , machine_id_t > > > & mitt ) : <nl> mailbox_manager ( mm ) , <nl> log_mailbox_view ( lmv ) , <nl> http_res_t log_http_app_t : : handle ( const http_req_t & req ) { <nl> if ( it ! = req . resource . end ( ) ) { <nl> return http_res_t ( 404 ) ; <nl> } <nl> - machine_id_t machine_id ; <nl> - try { <nl> - machine_id = str_to_uuid ( machine_id_str ) ; <nl> - } catch ( std : : runtime_error ) { <nl> - return http_res_t ( 404 ) ; <nl> + <nl> + std : : vector < machine_id_t > machine_ids ; <nl> + std : : map < peer_id_t , machine_id_t > all_machines = machine_id_translation_table - > get ( ) ; <nl> + if ( machine_id_str = = " _ " ) { <nl> + for ( std : : map < peer_id_t , machine_id_t > : : iterator it = all_machines . begin ( ) ; it ! = all_machines . end ( ) ; it + + ) { <nl> + machine_ids . push_back ( it - > second ) ; <nl> + } <nl> + } else { <nl> + const char * p = machine_id_str . c_str ( ) , * start = p ; <nl> + while ( true ) { <nl> + while ( * p & & * p ! = ' + ' ) p + + ; <nl> + try { <nl> + machine_ids . push_back ( str_to_uuid ( std : : string ( start , p - start ) ) ) ; <nl> + } catch ( std : : runtime_error ) { <nl> + return http_res_t ( 404 ) ; <nl> + } <nl> + if ( ! * p ) { <nl> + break ; <nl> + } else { <nl> + / * Step over the ` + ` * / <nl> + p + + ; <nl> + } <nl> + } <nl> } <nl> - peer_id_t peer_id = machine_id_to_peer_id ( machine_id , machine_id_translation_table - > get ( ) ) ; <nl> - if ( peer_id . is_nil ( ) ) { <nl> - return http_res_t ( 404 ) ; <nl> + <nl> + std : : vector < peer_id_t > peer_ids ; <nl> + for ( std : : vector < machine_id_t > : : iterator it = machine_ids . begin ( ) ; it ! = machine_ids . end ( ) ; it + + ) { <nl> + peer_id_t pid = machine_id_to_peer_id ( * it , machine_id_translation_table - > get ( ) ) ; <nl> + if ( pid . is_nil ( ) ) { <nl> + return http_res_t ( 404 ) ; <nl> + } <nl> + peer_ids . push_back ( pid ) ; <nl> } <nl> - std : : map < peer_id_t , mailbox_addr_t < void ( mailbox_addr_t < void ( std : : vector < std : : string > ) > ) > > log_mailboxes = <nl> - log_mailbox_view - > get ( ) ; <nl> - std : : map < peer_id_t , mailbox_addr_t < void ( mailbox_addr_t < void ( std : : vector < std : : string > ) > ) > > : : iterator jt = <nl> - log_mailboxes . find ( peer_id ) ; <nl> - if ( jt = = log_mailboxes . end ( ) ) { <nl> - / * We get here if they disconnect after we look up their peer ID but <nl> - before we look up their log mailbox . * / <nl> - return http_res_t ( 404 ) ; <nl> + <nl> + scoped_cJSON_t map_to_fill ( cJSON_CreateObject ( ) ) ; <nl> + <nl> + cond_t non_interruptor ; <nl> + pmap ( peer_ids . size ( ) , boost : : bind ( <nl> + & log_http_app_t : : fetch_logs , this , _1 , <nl> + machine_ids , peer_ids , <nl> + 100 , 0 , time ( NULL ) , <nl> + map_to_fill . get ( ) , <nl> + & non_interruptor ) ) ; <nl> + <nl> + http_res_t res ( 200 ) ; <nl> + res . set_body ( " application / json " , cJSON_print_std_string ( map_to_fill . get ( ) ) ) ; <nl> + return res ; <nl> + } <nl> + <nl> + void log_http_app_t : : fetch_logs ( int i , <nl> + const std : : vector < machine_id_t > & machines , const std : : vector < peer_id_t > & peers , <nl> + int max_messages , time_t min_timestamp , time_t max_timestamp , <nl> + cJSON * map_to_fill , <nl> + signal_t * interruptor ) THROWS_NOTHING { <nl> + std : : map < peer_id_t , log_server_business_card_t > bcards = log_mailbox_view - > get ( ) ; <nl> + std : : string key = uuid_to_str ( machines [ i ] ) ; <nl> + if ( bcards . count ( peers [ i ] ) = = 0 ) { <nl> + cJSON_AddItemToObject ( map_to_fill , key . c_str ( ) , cJSON_CreateString ( " lost contact with peer while fetching log " ) ) ; <nl> } <nl> - signal_timer_t timeout ( 1000 ) ; <nl> - std : : vector < std : : string > log_lines ; <nl> try { <nl> - log_lines = fetch_log_file ( mailbox_manager , jt - > second , & timeout ) ; <nl> + std : : vector < log_message_t > messages = fetch_log_file ( <nl> + mailbox_manager , bcards [ peers [ i ] ] , <nl> + max_messages , min_timestamp , max_timestamp , <nl> + interruptor ) ; <nl> + cJSON_AddItemToObject ( map_to_fill , key . c_str ( ) , render_as_json ( & messages , 0 ) ) ; <nl> } catch ( interrupted_exc_t ) { <nl> - return http_res_t ( 500 ) ; <nl> + / * ignore * / <nl> + } catch ( std : : runtime_error e ) { <nl> + cJSON_AddItemToObject ( map_to_fill , key . c_str ( ) , cJSON_CreateString ( e . what ( ) ) ) ; <nl> } catch ( resource_lost_exc_t ) { <nl> - return http_res_t ( 404 ) ; <nl> - } <nl> - / * TODO this is N ^ 2 * / <nl> - std : : string concatenated ; <nl> - for ( std : : vector < std : : string > : : iterator kt = log_lines . begin ( ) ; kt ! = log_lines . end ( ) ; kt + + ) { <nl> - concatenated + = * kt ; <nl> + cJSON_AddItemToObject ( map_to_fill , key . c_str ( ) , cJSON_CreateString ( " lost contact with peer while fetching log " ) ) ; <nl> } <nl> - http_res_t res ( 200 ) ; <nl> - res . set_body ( " text / plain " , concatenated ) ; <nl> - return res ; <nl> } <nl> mmm a / src / clustering / administration / http / log_app . hpp <nl> ppp b / src / clustering / administration / http / log_app . hpp <nl> <nl> # ifndef CLUSTERING_ADMINISTRATION_HTTP_LOG_APP_HPP_ <nl> # define CLUSTERING_ADMINISTRATION_HTTP_LOG_APP_HPP_ <nl> <nl> - # include " clustering / administration / logger . hpp " <nl> + # include " clustering / administration / log_transfer . hpp " <nl> # include " clustering / administration / machine_metadata . hpp " <nl> # include " http / http . hpp " <nl> <nl> class log_http_app_t : public http_app_t { <nl> public : <nl> log_http_app_t ( <nl> mailbox_manager_t * mm , <nl> - const clone_ptr_t < watchable_t < std : : map < peer_id_t , mailbox_addr_t < void ( mailbox_addr_t < void ( std : : vector < std : : string > ) > ) > > > > & log_mailbox_view , <nl> + const clone_ptr_t < watchable_t < std : : map < peer_id_t , log_server_business_card_t > > > & log_mailbox_view , <nl> const clone_ptr_t < watchable_t < std : : map < peer_id_t , machine_id_t > > > & machine_id_translation_table ) ; <nl> <nl> http_res_t handle ( const http_req_t & req ) ; <nl> <nl> private : <nl> + void fetch_logs ( int i , <nl> + const std : : vector < machine_id_t > & machines , const std : : vector < peer_id_t > & peers , <nl> + int max_messages , time_t min_timestamp , time_t max_timestamp , <nl> + cJSON * map_to_fill , <nl> + signal_t * interruptor ) THROWS_NOTHING ; <nl> + <nl> mailbox_manager_t * mailbox_manager ; <nl> - clone_ptr_t < watchable_t < std : : map < peer_id_t , mailbox_addr_t < void ( mailbox_addr_t < void ( std : : vector < std : : string > ) > ) > > > > log_mailbox_view ; <nl> + clone_ptr_t < watchable_t < std : : map < peer_id_t , log_server_business_card_t > > > log_mailbox_view ; <nl> clone_ptr_t < watchable_t < std : : map < peer_id_t , machine_id_t > > > machine_id_translation_table ; <nl> } ; <nl> <nl> mmm a / src / clustering / administration / http / semilattice_app . cc <nl> ppp b / src / clustering / administration / http / semilattice_app . cc <nl> http_res_t semilattice_http_app_t : : handle ( const http_req_t & req ) { <nl> { <nl> boost : : optional < std : : string > content_type = req . find_header_line ( " Content - Type " ) ; <nl> if ( ! content_type | | content_type . get ( ) ! = " application / json " ) { <nl> - logINF ( " Bad request , Content - Type should be application / json . \ n " ) ; <nl> + logINF ( " Bad request , Content - Type should be application / json . " ) ; <nl> return http_res_t ( 415 ) ; <nl> } <nl> } <nl> # endif <nl> scoped_cJSON_t change ( cJSON_Parse ( req . body . c_str ( ) ) ) ; <nl> if ( ! change . get ( ) ) { / / A null value indicates that parsing failed <nl> - logINF ( " Json body failed to parse . \ n Here ' s the data that failed : % s \ n " , req . body . c_str ( ) ) ; <nl> + logINF ( " Json body failed to parse . Here ' s the data that failed : % s " , req . body . c_str ( ) ) ; <nl> return http_res_t ( 400 ) ; <nl> } <nl> <nl> - logINF ( " Applying data % s \ n " , req . body . c_str ( ) ) ; <nl> + logINF ( " Applying data % s " , req . body . c_str ( ) ) ; <nl> json_adapter_head - > apply ( change . get ( ) , json_ctx ) ; <nl> <nl> / * Fill in the blueprints * / <nl> http_res_t semilattice_http_app_t : : handle ( const http_req_t & req ) { <nl> { <nl> boost : : optional < std : : string > content_type = req . find_header_line ( " Content - Type " ) ; <nl> if ( ! content_type | | content_type . get ( ) ! = " application / json " ) { <nl> - logINF ( " Bad request , Content - Type should be application / json . \ n " ) ; <nl> + logINF ( " Bad request , Content - Type should be application / json . " ) ; <nl> return http_res_t ( 415 ) ; <nl> } <nl> } <nl> http_res_t semilattice_http_app_t : : handle ( const http_req_t & req ) { <nl> return http_res_t ( 400 ) ; <nl> } <nl> <nl> - logINF ( " Applying data % s \ n " , req . body . c_str ( ) ) ; <nl> + logINF ( " Applying data % s " , req . body . c_str ( ) ) ; <nl> json_adapter_head - > reset ( json_ctx ) ; <nl> json_adapter_head - > apply ( change . get ( ) , json_ctx ) ; <nl> <nl> http_res_t semilattice_http_app_t : : handle ( const http_req_t & req ) { <nl> } <nl> } catch ( schema_mismatch_exc_t & e ) { <nl> http_res_t res ( 400 ) ; <nl> - logINF ( " HTTP request throw a schema_mismatch_exc_t with what = : \ n % s \ n " , e . what ( ) ) ; <nl> + logINF ( " HTTP request throw a schema_mismatch_exc_t with what = % s " , e . what ( ) ) ; <nl> res . set_body ( " application / text " , e . what ( ) ) ; <nl> return res ; <nl> } catch ( permission_denied_exc_t & e ) { <nl> http_res_t res ( 400 ) ; <nl> - logINF ( " HTTP request throw a permission_denied_exc_t with what = : \ n % s \ n " , e . what ( ) ) ; <nl> + logINF ( " HTTP request throw a permission_denied_exc_t with what = % s " , e . what ( ) ) ; <nl> res . set_body ( " application / text " , e . what ( ) ) ; <nl> return res ; <nl> } catch ( cannot_satisfy_goals_exc_t & e ) { <nl> http_res_t res ( 500 ) ; <nl> - logINF ( " The server was given a set of goals for which it couldn ' t find a valid blueprint . % s \ n " , e . what ( ) ) ; <nl> + logINF ( " The server was given a set of goals for which it couldn ' t find a valid blueprint . % s " , e . what ( ) ) ; <nl> res . set_body ( " application / text " , e . what ( ) ) ; <nl> return res ; <nl> } <nl> mmm a / src / clustering / administration / http / server . cc <nl> ppp b / src / clustering / administration / http / server . cc <nl> <nl> # include " http / routing_app . hpp " <nl> # include " rpc / directory / watchable_copier . hpp " <nl> <nl> - std : : map < peer_id_t , mailbox_addr_t < void ( mailbox_addr_t < void ( std : : vector < std : : string > ) > ) > > get_log_mailbox ( const std : : map < peer_id_t , cluster_directory_metadata_t > & md ) { <nl> - std : : map < peer_id_t , mailbox_addr_t < void ( mailbox_addr_t < void ( std : : vector < std : : string > ) > ) > > out ; <nl> + std : : map < peer_id_t , log_server_business_card_t > get_log_mailbox ( const std : : map < peer_id_t , cluster_directory_metadata_t > & md ) { <nl> + std : : map < peer_id_t , log_server_business_card_t > out ; <nl> for ( std : : map < peer_id_t , cluster_directory_metadata_t > : : const_iterator it = md . begin ( ) ; it ! = md . end ( ) ; it + + ) { <nl> out . insert ( std : : make_pair ( it - > first , it - > second . log_mailbox ) ) ; <nl> } <nl> new file mode 100644 <nl> index 00000000000 . . 2807b1f66ea <nl> mmm / dev / null <nl> ppp b / src / clustering / administration / log_transfer . cc <nl> <nl> + # include " clustering / administration / log_transfer . hpp " <nl> + <nl> + # include " concurrency / promise . hpp " <nl> + <nl> + log_server_t : : log_server_t ( mailbox_manager_t * mm , log_writer_t * lw ) : <nl> + mailbox_manager ( mm ) , writer ( lw ) , <nl> + request_mailbox ( mailbox_manager , boost : : bind ( & log_server_t : : handle_request , this , _1 , _2 , _3 , _4 , auto_drainer_t : : lock_t ( & drainer ) ) ) <nl> + { } <nl> + <nl> + log_server_business_card_t log_server_t : : get_business_card ( ) { <nl> + return log_server_business_card_t ( request_mailbox . get_address ( ) ) ; <nl> + } <nl> + <nl> + void log_server_t : : handle_request ( int max_lines , time_t min_timestamp , time_t max_timestamp , log_server_business_card_t : : result_mailbox_t : : address_t cont , auto_drainer_t : : lock_t keepalive ) { <nl> + try { <nl> + std : : vector < log_message_t > messages = <nl> + writer - > tail ( max_lines , min_timestamp , max_timestamp , keepalive . get_drain_signal ( ) ) ; <nl> + send ( mailbox_manager , cont , log_server_business_card_t : : result_t ( messages ) ) ; <nl> + } catch ( std : : runtime_error e ) { <nl> + send ( mailbox_manager , cont , log_server_business_card_t : : result_t ( e . what ( ) ) ) ; <nl> + } catch ( interrupted_exc_t ) { <nl> + / * don ' t respond ; we ' ll shut down in a moment * / <nl> + } <nl> + } <nl> + <nl> + std : : vector < log_message_t > fetch_log_file ( <nl> + mailbox_manager_t * mm , <nl> + const log_server_business_card_t & bcard , <nl> + int max_lines , time_t min_timestamp , time_t max_timestamp , <nl> + signal_t * interruptor ) THROWS_ONLY ( resource_lost_exc_t , std : : runtime_error , interrupted_exc_t ) { <nl> + promise_t < log_server_business_card_t : : result_t > promise ; <nl> + log_server_business_card_t : : result_mailbox_t reply_mailbox ( <nl> + mm , boost : : bind ( & promise_t < log_server_business_card_t : : result_t > : : pulse , & promise , _1 ) ) ; <nl> + disconnect_watcher_t dw ( mm - > get_connectivity_service ( ) , bcard . address . get_peer ( ) ) ; <nl> + send ( mm , bcard . address , max_lines , min_timestamp , max_timestamp , reply_mailbox . get_address ( ) ) ; <nl> + wait_any_t waiter ( promise . get_ready_signal ( ) , & dw ) ; <nl> + wait_interruptible ( & waiter , interruptor ) ; <nl> + if ( promise . get_ready_signal ( ) - > is_pulsed ( ) ) { <nl> + log_server_business_card_t : : result_t res = promise . get_value ( ) ; <nl> + if ( std : : vector < log_message_t > * messages = boost : : get < std : : vector < log_message_t > > ( & res ) ) { <nl> + return * messages ; <nl> + } else { <nl> + throw std : : runtime_error ( boost : : get < std : : string > ( res ) ) ; <nl> + } <nl> + } else { <nl> + throw resource_lost_exc_t ( ) ; <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 5f7c83bc9a2 <nl> mmm / dev / null <nl> ppp b / src / clustering / administration / log_transfer . hpp <nl> <nl> + # ifndef CLUSTERING_ADMINISTRATION_LOG_TRANSFER_HPP_ <nl> + # define CLUSTERING_ADMINISTRATION_LOG_TRANSFER_HPP_ <nl> + <nl> + # include " clustering / administration / logger . hpp " <nl> + # include " clustering / resource . hpp " <nl> + <nl> + class log_server_business_card_t { <nl> + public : <nl> + typedef boost : : variant < std : : vector < log_message_t > , std : : string > result_t ; <nl> + typedef mailbox_t < void ( result_t ) > result_mailbox_t ; <nl> + typedef mailbox_t < void ( int , time_t , time_t , result_mailbox_t : : address_t ) > request_mailbox_t ; <nl> + <nl> + log_server_business_card_t ( ) { } <nl> + log_server_business_card_t ( const request_mailbox_t : : address_t & a ) : address ( a ) { } <nl> + <nl> + request_mailbox_t : : address_t address ; <nl> + <nl> + RDB_MAKE_ME_SERIALIZABLE_1 ( address ) ; <nl> + } ; <nl> + <nl> + class log_server_t { <nl> + public : <nl> + log_server_t ( mailbox_manager_t * mm , log_writer_t * w ) ; <nl> + log_server_business_card_t get_business_card ( ) ; <nl> + private : <nl> + void handle_request ( <nl> + int max_lines , time_t min_timestamp , time_t max_timestamp , <nl> + log_server_business_card_t : : result_mailbox_t : : address_t cont , auto_drainer_t : : lock_t keepalive ) ; <nl> + mailbox_manager_t * mailbox_manager ; <nl> + log_writer_t * writer ; <nl> + auto_drainer_t drainer ; <nl> + log_server_business_card_t : : request_mailbox_t request_mailbox ; <nl> + } ; <nl> + <nl> + std : : vector < log_message_t > fetch_log_file ( <nl> + mailbox_manager_t * mailbox_manager , <nl> + const log_server_business_card_t & server_bcard , <nl> + int max_entries , time_t min_timestamp , time_t max_timestamp , <nl> + signal_t * interruptor ) THROWS_ONLY ( resource_lost_exc_t , std : : runtime_error , interrupted_exc_t ) ; <nl> + <nl> + # endif / * CLUSTERING_ADMINISTRATION_LOG_TRANSFER_HPP_ * / <nl> mmm a / src / clustering / administration / logger . cc <nl> ppp b / src / clustering / administration / logger . cc <nl> <nl> # include " clustering / administration / logger . hpp " <nl> <nl> + # include < fcntl . h > <nl> + <nl> # include " errors . hpp " <nl> + # include < boost / lexical_cast . hpp > <nl> # include < boost / scoped_array . hpp > <nl> <nl> + # include " arch / runtime / thread_pool . hpp " / * for ` run_in_blocker_pool ( ) ` * / <nl> + # include " clustering / administration / persist . hpp " <nl> # include " concurrency / promise . hpp " <nl> <nl> std : : string format_log_level ( log_level_t l ) { <nl> std : : string format_log_message ( const log_message_t & m ) { <nl> # endif <nl> return strprintf ( " % s % d . % 06ds % s : % s \ n " , <nl> format_time ( m . timestamp ) . c_str ( ) , <nl> - m . uptime . tv_sec , <nl> - m . uptime . tv_nsec / 1e3 , <nl> + int ( m . uptime . tv_sec ) , <nl> + int ( m . uptime . tv_nsec / 1000 ) , <nl> format_log_level ( m . level ) . c_str ( ) , <nl> m . message . c_str ( ) <nl> ) ; <nl> log_message_t parse_log_message ( const std : : string & s ) THROWS_ONLY ( std : : runtime_e <nl> p + + ; <nl> if ( * p ) throw std : : runtime_error ( " cannot parse log message " ) ; <nl> <nl> - time_t timestamp = parse_timestamp ( std : : string ( start_timestamp , end_timestamp - start_timestamp ) ) ; <nl> + time_t timestamp = parse_time ( std : : string ( start_timestamp , end_timestamp - start_timestamp ) ) ; <nl> struct timespec uptime ; <nl> try { <nl> uptime . tv_sec = boost : : lexical_cast < int > ( std : : string ( start_uptime_ipart , end_uptime_ipart - start_uptime_ipart ) ) ; <nl> static void throw_unless ( bool condition , const std : : string & where ) { <nl> class file_reverse_reader_t { <nl> public : <nl> file_reverse_reader_t ( const std : : string & filename ) : <nl> - fd ( open ( filename . c_str ( ) , " r " ) ) , <nl> + fd ( open ( filename . c_str ( ) , O_RDONLY ) ) , <nl> current_chunk ( new char [ chunk_size ] ) { <nl> throw_unless ( fd . get ( ) ! = - 1 , strprintf ( " could not open ' % s ' for reading . " , filename . c_str ( ) ) ) ; <nl> off64_t size = lseek ( fd . get ( ) , SEEK_END , 0 ) ; <nl> class file_reverse_reader_t { <nl> if ( current_chunk_start ! = 0 ) { <nl> current_chunk_start - = chunk_size ; <nl> int res = pread ( fd . get ( ) , current_chunk . get ( ) , chunk_size , current_chunk_start ) ; <nl> - if ( res ! = remaining_in_current_chunk ) { <nl> - throw file_io_exc_t ( " could not read from file " , errno ) ; <nl> - } <nl> + throw_unless ( res = = remaining_in_current_chunk , " could not read from file " ) ; <nl> remaining_in_current_chunk = chunk_size ; <nl> } else { <nl> remaining_in_current_chunk = 0 ; <nl> class file_reverse_reader_t { <nl> <nl> private : <nl> static const int chunk_size = 4096 ; <nl> + scoped_fd_t fd ; <nl> boost : : scoped_array < char > current_chunk ; <nl> int remaining_in_current_chunk ; <nl> off64_t current_chunk_start ; <nl> } ; <nl> <nl> - static __thread log_file_writer_t * global_log_writer = NULL ; <nl> + static __thread log_writer_t * global_log_writer = NULL ; <nl> static __thread auto_drainer_t * global_log_drainer = NULL ; <nl> <nl> - log_file_writer_t : : log_file_writer_t ( const std : : string & filename ) : filename ( filename ) , last_time ( time ( NULL ) ) { <nl> - pmap ( get_num_threads ( ) , boost : : bind ( & log_file_writer_t : : install_on_thread , this , _1 ) ) ; <nl> + log_writer_t : : log_writer_t ( const std : : string & filename , local_issue_tracker_t * it ) : filename ( filename ) , issue_tracker ( it ) { <nl> + <nl> + int res = clock_gettime ( CLOCK_MONOTONIC , & uptime_reference ) ; <nl> + guarantee_err ( res = = 0 , " clock_gettime ( CLOCK_MONOTONIC ) failed " ) ; <nl> + <nl> + pmap ( get_num_threads ( ) , boost : : bind ( & log_writer_t : : install_on_thread , this , _1 ) ) ; <nl> + } <nl> + <nl> + log_writer_t : : ~ log_writer_t ( ) { <nl> + pmap ( get_num_threads ( ) , boost : : bind ( & log_writer_t : : uninstall_on_thread , this , _1 ) ) ; <nl> } <nl> <nl> - log_file_writer_t : : ~ log_file_writer_t ( ) { <nl> - pmap ( get_num_threads ( ) , boost : : bind ( & log_file_writer_t : : uninstall_on_thread , this , _1 ) ) ; <nl> + std : : vector < log_message_t > log_writer_t : : tail ( int max_lines , time_t min_timestamp , time_t max_timestamp , signal_t * interruptor ) THROWS_ONLY ( std : : runtime_error , interrupted_exc_t ) { <nl> + volatile bool cancel = false ; <nl> + class cancel_subscription_t : public signal_t : : subscription_t { <nl> + public : <nl> + cancel_subscription_t ( volatile bool * c ) : cancel ( c ) { } <nl> + void run ( ) { <nl> + * cancel = true ; <nl> + } <nl> + volatile bool * cancel ; <nl> + } subscription ( & cancel ) ; <nl> + subscription . reset ( interruptor ) ; <nl> + <nl> + std : : vector < log_message_t > log_messages ; <nl> + std : : string error_message ; <nl> + bool ok = thread_pool_t : : run_in_blocker_pool < bool > ( <nl> + boost : : bind ( & log_writer_t : : tail_blocking , this , max_lines , min_timestamp , max_timestamp , & cancel , & log_messages , & error_message ) ) ; <nl> + if ( ok ) { <nl> + if ( cancel ) { <nl> + throw interrupted_exc_t ( ) ; <nl> + } else { <nl> + return log_messages ; <nl> + } <nl> + } else { <nl> + throw std : : runtime_error ( error_message ) ; <nl> + } <nl> } <nl> <nl> - void log_file_writer_t : : install_on_thread ( int i ) { <nl> + void log_writer_t : : install_on_thread ( int i ) { <nl> on_thread_t thread_switcher ( i ) ; <nl> rassert ( global_log_writer = = NULL ) ; <nl> global_log_drainer = new auto_drainer_t ; <nl> global_log_writer = this ; <nl> } <nl> <nl> - void log_file_writer_t : : uninstall_on_thread ( int i ) { <nl> + void log_writer_t : : uninstall_on_thread ( int i ) { <nl> on_thread_t thread_switcher ( i ) ; <nl> rassert ( global_log_writer = = this ) ; <nl> global_log_writer = NULL ; <nl> void log_file_writer_t : : uninstall_on_thread ( int i ) { <nl> global_log_drainer = NULL ; <nl> } <nl> <nl> - void log_file_writer_t : : write_log_message ( const log_message_t & lm ) { <nl> - if ( fd . get ( ) = = - 1 ) { <nl> - fd . reset ( open ( filename . c_str ( ) , " a " ) ) ; <nl> - if ( fd . get ( ) = = - 1 ) { <nl> - if ( ! issue . get ( ) ) { <nl> - issue . reset ( new local_issue_tracker_t : : entry_t ( <nl> - issue_tracker , <nl> - clone_ptr_t < local_issue_t > ( new metadata_persistence : : persistence_issue_t ( <nl> - std : : string ( " cannot open log file : " ) + strerror ( errno ) <nl> - ) ) ; <nl> - ) ) ; <nl> - } <nl> - return ; <nl> - } else { <nl> - issue . reset ( ) ; <nl> - } <nl> - } <nl> - std : : string formatted = format_log_message ( lm ) ; <nl> - int res = write ( fd . get ( ) , formatted . data ( ) , formatted . length ( ) ) ; <nl> - if ( res ! = 0 ) { <nl> - if ( ! issue . get ( ) ) { <nl> + void log_writer_t : : write ( const log_message_t & lm ) { <nl> + mutex_t : : acq_t write_mutex_acq ( & write_mutex ) ; <nl> + std : : string error_message ; <nl> + bool ok = thread_pool_t : : run_in_blocker_pool < bool > ( <nl> + boost : : bind ( & log_writer_t : : write_blocking , this , lm , & error_message ) ) ; <nl> + if ( ok ) { <nl> + issue . reset ( ) ; <nl> + } else { <nl> + if ( ! issue ) { <nl> issue . reset ( new local_issue_tracker_t : : entry_t ( <nl> issue_tracker , <nl> clone_ptr_t < local_issue_t > ( new metadata_persistence : : persistence_issue_t ( <nl> - std : : string ( " cannot write to log file : " ) + strerror ( errno ) <nl> - ) ) ; <nl> + error_message <nl> + ) ) <nl> ) ) ; <nl> } <nl> - } else { <nl> - issue . reset ( ) ; <nl> } <nl> } <nl> <nl> - / * Declared in ` logger . hpp ` , not ` clustering / administration / logger . hpp ` like the <nl> - other things in this file . * / <nl> - void log_internal ( UNUSED const char * src_file , UNUSED int src_line , log_level_t level , const char * format , . . . ) { <nl> - if ( log_file_writer_t * writer = global_log_writer ) { <nl> - auto_drainer_t : : lock_t lock ( global_log_drainer ) ; <nl> - on_thread_t thread_switcher ( writer - > home_thread ( ) ) ; <nl> - <nl> - time_t timestamp = time ( NULL ) ; <nl> - <nl> - struct timespec uptime ; <nl> - res = clock_gettime ( CLOCK_MONOTONIC , & uptime ) ; <nl> - guarantee_err ( res = = 0 , " clock_gettime ( CLOCK_MONOTONIC ) failed " ) ; <nl> - <nl> - va_list args ; <nl> - va_begin ( format , args ) ; <nl> - std : : string message = vstrprintf ( format , args ) ; <nl> - va_end ( args ) ; <nl> - <nl> - writer - > write ( log_message_t ( timestamp , uptime , level , message ) ) ; <nl> + bool log_writer_t : : write_blocking ( const log_message_t & msg , std : : string * error_out ) { <nl> + if ( fd . get ( ) = = - 1 ) { <nl> + fd . reset ( open ( filename . c_str ( ) , O_WRONLY | O_APPEND | O_CREAT , 0644 ) ) ; <nl> + if ( fd . get ( ) = = - 1 ) { <nl> + * error_out = std : : string ( " cannot open log file : " ) + strerror ( errno ) ; <nl> + return false ; <nl> + } <nl> + } <nl> + std : : string formatted = format_log_message ( msg ) ; <nl> + int res = : : write ( fd . get ( ) , formatted . data ( ) , formatted . length ( ) ) ; <nl> + if ( res ! = 0 ) { <nl> + * error_out = std : : string ( " cannot write to log file : " ) + strerror ( errno ) ; <nl> + return false ; <nl> } <nl> + return true ; <nl> } <nl> <nl> - <nl> - void read_log_file_blocking ( const std : : string & filename , <nl> - int max_lines , time_t min_timestamp , time_t max_timestamp , <nl> - std : : vector < log_message_t > * messages_out , std : : string * error_out , bool * result_out ) { <nl> + bool log_writer_t : : tail_blocking ( int max_lines , time_t min_timestamp , time_t max_timestamp , volatile bool * cancel , std : : vector < log_message_t > * messages_out , std : : string * error_out ) { <nl> try { <nl> - file_reverse_reader_t reader ; <nl> + file_reverse_reader_t reader ( filename ) ; <nl> std : : string line ; <nl> - while ( messages_out - > size ( ) < max_lines & & reader . get_next ( & line ) ) { <nl> + while ( int ( messages_out - > size ( ) ) < max_lines & & reader . get_next ( & line ) & & ! * cancel ) { <nl> log_message_t lm = parse_log_message ( line ) ; <nl> if ( lm . timestamp > max_timestamp ) continue ; <nl> if ( lm . timestamp < min_timestamp ) break ; <nl> messages_out - > push_back ( lm ) ; <nl> } <nl> - * result_out = true ; <nl> + return true ; <nl> } catch ( std : : runtime_error & e ) { <nl> * error_out = e . what ( ) ; <nl> - * result_out = false ; <nl> + return false ; <nl> } <nl> } <nl> <nl> - std : : vector < log_message_t > read_log_file ( const std : : string & filename , <nl> - int max_lines , precise_time_t min_date , precise_time_t max_date ) { <nl> - <nl> - } <nl> + / * Declared in ` logger . hpp ` , not ` clustering / administration / logger . hpp ` like the <nl> + other things in this file . * / <nl> + void log_internal ( UNUSED const char * src_file , UNUSED int src_line , log_level_t level , const char * format , . . . ) { <nl> + if ( log_writer_t * writer = global_log_writer ) { <nl> + auto_drainer_t : : lock_t lock ( global_log_drainer ) ; <nl> + on_thread_t thread_switcher ( writer - > home_thread ( ) ) ; <nl> <nl> - log_file_server_t : : log_file_server_t ( mailbox_manager_t * mm , log_file_writer_t * lfw ) : <nl> - mailbox_manager ( mm ) , writer ( lfw ) , <nl> - mailbox ( mailbox_manager , boost : : bind ( & log_file_server_t : : handle_request , this , _1 , auto_drainer_t : : lock_t ( & drainer ) ) ) <nl> - { } <nl> + time_t timestamp = time ( NULL ) ; <nl> <nl> - mailbox_addr_t < void ( mailbox_addr_t < void ( std : : vector < std : : string > ) > ) > log_file_server_t : : get_business_card ( ) { <nl> - return mailbox . get_address ( ) ; <nl> - } <nl> + struct timespec uptime ; <nl> + int res = clock_gettime ( CLOCK_MONOTONIC , & uptime ) ; <nl> + guarantee_err ( res = = 0 , " clock_gettime ( CLOCK_MONOTONIC ) failed " ) ; <nl> + if ( uptime . tv_nsec < writer - > uptime_reference . tv_nsec ) { <nl> + uptime . tv_nsec + = 1000000000 ; <nl> + uptime . tv_sec - = 1 ; <nl> + } <nl> + uptime . tv_nsec - = writer - > uptime_reference . tv_nsec ; <nl> + uptime . tv_sec - = writer - > uptime_reference . tv_sec ; <nl> <nl> - void log_file_server_t : : handle_request ( const mailbox_addr_t < void ( std : : vector < std : : string > ) > & cont , auto_drainer_t : : lock_t ) { <nl> - send ( mailbox_manager , cont , writer - > get_lines ( ) ) ; <nl> - } <nl> + va_list args ; <nl> + va_start ( args , format ) ; <nl> + std : : string message = vstrprintf ( format , args ) ; <nl> + va_end ( args ) ; <nl> <nl> - std : : vector < std : : string > fetch_log_file ( <nl> - mailbox_manager_t * mm , <nl> - const mailbox_addr_t < void ( mailbox_addr_t < void ( std : : vector < std : : string > ) > ) > & mbox , <nl> - signal_t * interruptor ) THROWS_ONLY ( resource_lost_exc_t , interrupted_exc_t ) { <nl> - promise_t < std : : vector < std : : string > > promise ; <nl> - mailbox_t < void ( std : : vector < std : : string > ) > reply_mailbox ( mm , boost : : bind ( & promise_t < std : : vector < std : : string > > : : pulse , & promise , _1 ) ) ; <nl> - disconnect_watcher_t dw ( mm - > get_connectivity_service ( ) , mbox . get_peer ( ) ) ; <nl> - send ( mm , mbox , reply_mailbox . get_address ( ) ) ; <nl> - wait_any_t waiter ( promise . get_ready_signal ( ) , & dw ) ; <nl> - wait_interruptible ( & waiter , interruptor ) ; <nl> - if ( promise . get_ready_signal ( ) - > is_pulsed ( ) ) { <nl> - return promise . get_value ( ) ; <nl> - } else { <nl> - throw resource_lost_exc_t ( ) ; <nl> + writer - > write ( log_message_t ( timestamp , uptime , level , message ) ) ; <nl> } <nl> } <nl> mmm a / src / clustering / administration / logger . hpp <nl> ppp b / src / clustering / administration / logger . hpp <nl> <nl> # include " errors . hpp " <nl> # include < boost / circular_buffer . hpp > <nl> <nl> - # include " clustering / resource . hpp " <nl> + # include " clustering / administration / issues / local . hpp " <nl> # include " logger . hpp " <nl> # include " rpc / mailbox / typed . hpp " <nl> # include " utils . hpp " <nl> <nl> + ARCHIVE_PRIM_MAKE_RANGED_SERIALIZABLE ( log_level_t , int , log_level_debug , log_level_error ) ; <nl> + RDB_MAKE_SERIALIZABLE_2 ( struct timespec , tv_sec , tv_nsec ) ; <nl> + <nl> class log_message_t { <nl> public : <nl> - log_message_t ( time_t t , struct timestamp u , log_level_t l , std : : string m ) : <nl> + log_message_t ( ) { } <nl> + log_message_t ( time_t t , struct timespec u , log_level_t l , std : : string m ) : <nl> timestamp ( t ) , uptime ( u ) , level ( l ) , message ( m ) { } <nl> time_t timestamp ; <nl> struct timespec uptime ; <nl> log_level_t level ; <nl> std : : string message ; <nl> - RDB_MAKE_ME_SERIALIZABLE_4 ( timestamp , uptime , log_level , message ) ; <nl> - } ; <nl> - <nl> - class log_issue_t : public local_issue_t { <nl> - public : <nl> - log_issue_t ( ) { } / / for serialization <nl> - <nl> - explicit log_issue_t ( const std : : string & _message ) : message ( _message ) { } <nl> - <nl> - std : : string get_description ( ) const { <nl> - return " There was a problem when trying to write to the log file " <nl> - " locally : " + message ; <nl> - } <nl> - cJSON * get_json_description ( ) const { <nl> - issue_json_t json ; <nl> - json . critical = true ; <nl> - json . description = get_description ( ) ; <nl> - json . time = get_secs ( ) ; <nl> - json . type . issue_type = LOG_ISSUE ; <nl> - <nl> - return render_as_json ( & json , 0 ) ; <nl> - } <nl> - <nl> - log_issue_t * clone ( ) const { <nl> - return new log_issue_t ( message ) ; <nl> - } <nl> - <nl> - std : : string message ; <nl> - <nl> - RDB_MAKE_ME_SERIALIZABLE_1 ( message ) ; <nl> + RDB_MAKE_ME_SERIALIZABLE_4 ( timestamp , uptime , level , message ) ; <nl> } ; <nl> <nl> std : : string format_log_level ( log_level_t l ) ; <nl> log_level_t parse_log_level ( const std : : string & s ) THROWS_ONLY ( std : : runtime_error <nl> std : : string format_log_message ( const log_message_t & m ) ; <nl> log_message_t parse_log_message ( const std : : string & s ) THROWS_ONLY ( std : : runtime_error ) ; <nl> <nl> - class log_file_writer_t : public home_thread_mixin_t { <nl> + class log_writer_t : public home_thread_mixin_t { <nl> public : <nl> - log_file_writer_t ( const std : : string & filename , local_issue_tracker_t * issue_tracker ) ; <nl> - ~ log_file_writer_t ( ) ; <nl> + log_writer_t ( const std : : string & filename , local_issue_tracker_t * issue_tracker ) ; <nl> + ~ log_writer_t ( ) ; <nl> <nl> - std : : vector < log_message_t > tail ( int max_lines , time_t min_timestamp , time_t max_timestamp ) ; <nl> + std : : vector < log_message_t > tail ( int max_lines , time_t min_timestamp , time_t max_timestamp , signal_t * interruptor ) THROWS_ONLY ( std : : runtime_error , interrupted_exc_t ) ; <nl> <nl> private : <nl> friend void log_internal ( const char * src_file , int src_line , log_level_t level , const char * format , . . . ) ; <nl> void install_on_thread ( int i ) ; <nl> void uninstall_on_thread ( int i ) ; <nl> void write ( const log_message_t & msg ) ; <nl> + bool write_blocking ( const log_message_t & msg , std : : string * error_out ) ; <nl> + bool tail_blocking ( int max_lines , time_t min_timestamp , time_t max_timestamp , volatile bool * cancel , std : : vector < log_message_t > * messages_out , std : : string * error_out ) ; <nl> std : : string filename ; <nl> + struct timespec uptime_reference ; <nl> mutex_t write_mutex ; <nl> scoped_fd_t fd ; <nl> local_issue_tracker_t * issue_tracker ; <nl> - boost : : scoped_ptr < local_issue_t > issue ; <nl> - time_t last_time ; <nl> - } ; <nl> - <nl> - class log_file_server_t { <nl> - public : <nl> - log_file_server_t ( mailbox_manager_t * mm , std : : string filename ) ; <nl> - mailbox_addr_t < void ( mailbox_addr_t < void ( std : : vector < std : : string > ) > ) > get_business_card ( ) ; <nl> - private : <nl> - void handle_request ( const mailbox_addr_t < void ( std : : vector < std : : string > ) > & , auto_drainer_t : : lock_t ) ; <nl> - mailbox_manager_t * mailbox_manager ; <nl> - log_file_writer_t * writer ; <nl> - auto_drainer_t drainer ; <nl> - mailbox_t < void ( mailbox_addr_t < void ( std : : vector < std : : string > ) > ) > mailbox ; <nl> + boost : : scoped_ptr < local_issue_tracker_t : : entry_t > issue ; <nl> } ; <nl> <nl> - std : : vector < std : : string > fetch_log_file ( <nl> - mailbox_manager_t * mailbox_manager , <nl> - const mailbox_addr_t < void ( mailbox_addr_t < void ( std : : vector < std : : string > ) > ) > & mbox , <nl> - signal_t * interruptor ) THROWS_ONLY ( resource_lost_exc_t , interrupted_exc_t ) ; <nl> - <nl> # endif / * CLUSTERING_ADMINISTRATION_LOGGER_HPP_ * / <nl> mmm a / src / clustering / administration / main / initial_join . cc <nl> ppp b / src / clustering / administration / main / initial_join . cc <nl> void initial_joiner_t : : main_coro ( connectivity_cluster_t : : run_t * cluster_run , aut <nl> for ( it + + ; it ! = peers_not_heard_from . end ( ) ; it + + ) { <nl> stringstream < < " , " < < it - > ip . as_dotted_decimal ( ) < < " : " < < it - > port ; <nl> } <nl> - logWRN ( " We were unable to connect to the following peer ( s ) : % s \ n " , stringstream . str ( ) . c_str ( ) ) ; <nl> + logWRN ( " We were unable to connect to the following peer ( s ) : % s " , stringstream . str ( ) . c_str ( ) ) ; <nl> } <nl> } catch ( interrupted_exc_t ) { <nl> / * ignore * / <nl> mmm a / src / clustering / administration / main / serve . cc <nl> ppp b / src / clustering / administration / main / serve . cc <nl> <nl> <nl> bool serve ( const std : : string & filepath , const std : : set < peer_address_t > & joins , int port , int client_port , machine_id_t machine_id , const cluster_semilattice_metadata_t & semilattice_metadata , std : : string web_assets ) { <nl> <nl> - log_file_writer_t log_file_writer ( filepath + " / log_file " ) ; <nl> - <nl> local_issue_tracker_t local_issue_tracker ; <nl> <nl> + log_writer_t log_writer ( filepath + " / log_file " , & local_issue_tracker ) ; <nl> + <nl> printf ( " Establishing cluster node on port % d . . . \ n " , port ) ; <nl> <nl> connectivity_cluster_t connectivity_cluster ; <nl> bool serve ( const std : : string & filepath , const std : : set < peer_address_t > & joins , i <nl> semilattice_manager_t < cluster_semilattice_metadata_t > semilattice_manager_cluster ( & semilattice_manager_client , semilattice_metadata ) ; <nl> message_multiplexer_t : : client_t : : run_t semilattice_manager_client_run ( & semilattice_manager_client , & semilattice_manager_cluster ) ; <nl> <nl> - log_file_server_t log_file_server ( & mailbox_manager , & log_file_writer ) ; <nl> + log_server_t log_server ( & mailbox_manager , & log_writer ) ; <nl> <nl> / / Initialize the stat manager before the directory manager so that we <nl> / / could initialize the cluster directory metadata with the proper <nl> bool serve ( const std : : string & filepath , const std : : set < peer_address_t > & joins , i <nl> cluster_directory_metadata_t cluster_directory_metadata_iv ( <nl> machine_id , <nl> stat_manager . get_address ( ) , <nl> - log_file_server . get_business_card ( ) ) ; <nl> + log_server . get_business_card ( ) ) ; <nl> <nl> message_multiplexer_t : : client_t directory_manager_client ( & message_multiplexer , ' D ' ) ; <nl> directory_readwrite_manager_t < cluster_directory_metadata_t > directory_manager ( & directory_manager_client , cluster_directory_metadata_iv ) ; <nl> mmm a / src / clustering / administration / metadata . hpp <nl> ppp b / src / clustering / administration / metadata . hpp <nl> <nl> <nl> # include " clustering / administration / datacenter_metadata . hpp " <nl> # include " clustering / administration / issues / local . hpp " <nl> + # include " clustering / administration / log_transfer . hpp " <nl> # include " clustering / administration / machine_metadata . hpp " <nl> # include " clustering / administration / namespace_metadata . hpp " <nl> # include " clustering / administration / stat_manager . hpp " <nl> class cluster_directory_metadata_t { <nl> cluster_directory_metadata_t ( <nl> machine_id_t mid , <nl> const get_stats_mailbox_address_t & _stats_mailbox , <nl> - const mailbox_addr_t < void ( mailbox_addr_t < void ( std : : vector < std : : string > ) > ) > & lmb ) : <nl> + const log_server_business_card_t & lmb ) : <nl> machine_id ( mid ) , get_stats_mailbox_address ( _stats_mailbox ) , log_mailbox ( lmb ) { } <nl> <nl> namespaces_directory_metadata_t < mock : : dummy_protocol_t > dummy_namespaces ; <nl> class cluster_directory_metadata_t { <nl> machine_id_t machine_id ; <nl> <nl> get_stats_mailbox_address_t get_stats_mailbox_address ; <nl> - mailbox_addr_t < void ( mailbox_addr_t < void ( std : : vector < std : : string > ) > ) > log_mailbox ; <nl> + log_server_business_card_t log_mailbox ; <nl> std : : list < clone_ptr_t < local_issue_t > > local_issues ; <nl> <nl> RDB_MAKE_ME_SERIALIZABLE_6 ( dummy_namespaces , memcached_namespaces , machine_id , get_stats_mailbox_address , log_mailbox , local_issues ) ; <nl> mmm a / src / clustering / administration / suggester . tcc <nl> ppp b / src / clustering / administration / suggester . tcc <nl> std : : map < namespace_id_t , persistable_blueprint_t < protocol_t > > suggest_blueprint <nl> machine_data_centers <nl> ) ) ) ; <nl> } catch ( cannot_satisfy_goals_exc_t & e ) { <nl> - logERR ( " Namespace % s has unsatisfiable goals \ n " , uuid_to_str ( it - > first ) . c_str ( ) ) ; <nl> + logERR ( " Namespace % s has unsatisfiable goals " , uuid_to_str ( it - > first ) . c_str ( ) ) ; <nl> } catch ( in_conflict_exc_t & e ) { <nl> - logERR ( " Namespace % s has internal conflicts \ n " , uuid_to_str ( it - > first ) . c_str ( ) ) ; <nl> + logERR ( " Namespace % s has internal conflicts " , uuid_to_str ( it - > first ) . c_str ( ) ) ; <nl> } <nl> } <nl> } <nl> mmm a / src / concurrency / signal . hpp <nl> ppp b / src / concurrency / signal . hpp <nl> class signal_t : <nl> <nl> class subscription_t : public home_thread_mixin_t { <nl> public : <nl> - subscription_t ( ) : subs ( this ) { } <nl> + subscription_t ( ) : subs ( this ) { } <nl> void reset ( signal_t * s = NULL ) { <nl> if ( s ) { <nl> mutex_assertion_t : : acq_t acq ( & s - > lock ) ; <nl> class signal_t : <nl> } <nl> } <nl> <nl> - virtual void run ( ) = 0 ; <nl> + virtual void run ( ) = 0 ; <nl> private : <nl> - publisher_t < subscription_t * > : : subscription_t subs ; <nl> - DISABLE_COPYING ( subscription_t ) ; <nl> + publisher_t < subscription_t * > : : subscription_t subs ; <nl> + DISABLE_COPYING ( subscription_t ) ; <nl> } ; <nl> <nl> / * The coro that calls ` wait_lazily_ordered ( ) ` will be pushed onto the event <nl> mmm a / src / http / file_app . cc <nl> ppp b / src / http / file_app . cc <nl> http_res_t file_http_app_t : : handle ( const http_req_t & req ) { <nl> } <nl> std : : string resource ( req . resource . as_string ( ) ) ; <nl> if ( resource ! = " / " & & resource ! = " " & & ! std_contains ( whitelist , resource ) ) { <nl> - logINF ( " Someone asked for the nonwhitelisted file % s , if this should be accessible add it to the whitelist . \ n " , resource . c_str ( ) ) ; <nl> + logINF ( " Someone asked for the nonwhitelisted file % s , if this should be accessible add it to the whitelist . " , resource . c_str ( ) ) ; <nl> return http_res_t ( 403 ) ; <nl> } <nl> <nl> http_res_t file_http_app_t : : handle ( const http_req_t & req ) { <nl> std : : ifstream f ( ( asset_dir + filename ) . c_str ( ) ) ; <nl> <nl> if ( f . fail ( ) ) { <nl> - logINF ( " File % s was requested and is on the whitelist but we didn ' t find it in the directory . \ n " , ( asset_dir + resource ) . c_str ( ) ) ; <nl> + logINF ( " File % s was requested and is on the whitelist but we didn ' t find it in the directory . " , ( asset_dir + resource ) . c_str ( ) ) ; <nl> return http_res_t ( 404 ) ; <nl> } <nl> <nl> mmm a / src / http / json / json_adapter . tcc <nl> ppp b / src / http / json / json_adapter . tcc <nl> void apply_as_directory ( cJSON * change , T * target , const ctx_t & ctx ) { <nl> while ( ( val = it . next ( ) ) ) { <nl> if ( elements . find ( val - > string ) = = elements . end ( ) ) { <nl> # ifndef NDEBUG <nl> - logERR ( " Error , couldn ' t find element % s in adapter map . \ n " , val - > string ) ; <nl> + logERR ( " Error , couldn ' t find element % s in adapter map . " , val - > string ) ; <nl> # else <nl> throw schema_mismatch_exc_t ( strprintf ( " Couldn ' t find element % s . " , val - > string ) ) ; <nl> # endif <nl> mmm a / src / memcached / clustering . cc <nl> ppp b / src / memcached / clustering . cc <nl> void memcached_parser_maker_t : : on_change ( ) { <nl> / / We ' re feeling lucky <nl> namespace_id_t tmp = it - > first ; <nl> parsers . insert ( tmp , new parser_and_namespace_if_t ( it - > first , this , port ) ) ; <nl> - logINF ( " Setup an mc parser on % d \ n " , port ) ; <nl> + logINF ( " Setup an mc parser on % d " , port ) ; <nl> } else if ( parsers . find ( it - > first ) ! = parsers . end ( ) & & ! it - > second . is_deleted ( ) & & <nl> parsers . find ( it - > first ) - > second - > parser . port ! = get_port ( it - > second . get ( ) <nl> # ifndef NDEBUG <nl> void memcached_parser_maker_t : : on_change ( ) { <nl> / / We ' re feeling lucky <nl> namespace_id_t tmp = it - > first ; <nl> parsers . insert ( tmp , new parser_and_namespace_if_t ( it - > first , this , port ) ) ; <nl> - logINF ( " Setup an mc parser on % d \ n " , port ) ; <nl> + logINF ( " Setup an mc parser on % d " , port ) ; <nl> } else if ( parsers . find ( it - > first ) ! = parsers . end ( ) & & it - > second . is_deleted ( ) ) { <nl> / / The namespace has been deleted . . . get rid of the parser <nl> coro_t : : spawn_sometime ( boost : : bind ( & do_delete , new memcached_parser_maker_t : : parser_map_t : : auto_type ( parsers . release ( parsers . find ( it - > first ) ) ) ) ) ; <nl> mmm a / src / memcached / parser . cc <nl> ppp b / src / memcached / parser . cc <nl> bool parse_debug_command ( txt_memcached_handler_t * rh , pipeliner_t * pipeliner , st <nl> <nl> / * Handle memcached , takes a txt_memcached_handler_t and handles the memcached commands that come in on it * / <nl> void handle_memcache ( memcached_interface_t * interface , namespace_interface_t < memcached_protocol_t > * nsi , int max_concurrent_queries_per_connection ) { <nl> - logDBG ( " Opened memcached stream : % p \ n " , coro_t : : self ( ) ) ; <nl> + logDBG ( " Opened memcached stream : % p " , coro_t : : self ( ) ) ; <nl> <nl> / * This object just exists to group everything together so we don ' t have to pass a lot of <nl> context around . * / <nl> void handle_memcache ( memcached_interface_t * interface , namespace_interface_t < mem <nl> pipeliner_acq . begin_write ( ) ; <nl> pipeliner_acq . end_write ( ) ; <nl> <nl> - logDBG ( " Closed memcached stream : % p \ n " , coro_t : : self ( ) ) ; <nl> + logDBG ( " Closed memcached stream : % p " , coro_t : : self ( ) ) ; <nl> } <nl> <nl> mmm a / src / memcached / tcp_conn . cc <nl> ppp b / src / memcached / tcp_conn . cc <nl> struct tcp_conn_memcached_interface_t : public memcached_interface_t , public hom <nl> / / because they are read from the socket via a different <nl> / / mechanism . ) There are better ways to handle this <nl> / / situation . <nl> - logERR ( " Aborting connection % p because we got more than % ld bytes without a CRLF \ n " , <nl> + logERR ( " Aborting connection % p because we got more than % ld bytes without a CRLF " , <nl> coro_t : : self ( ) , threshold ) ; <nl> conn - > shutdown_read ( ) ; <nl> throw tcp_conn_t : : read_closed_exc_t ( ) ; <nl> mmm a / src / mock / dummy_protocol_parser . cc <nl> ppp b / src / mock / dummy_protocol_parser . cc <nl> void dummy_protocol_parser_maker_t : : on_change ( ) { <nl> / / We ' re feeling lucky <nl> namespace_id_t tmp = it - > first ; <nl> parsers . insert ( tmp , new parser_and_namespace_if_t ( it - > first , this , port ) ) ; <nl> - logINF ( " Setup a parser on % d \ n " , port ) ; <nl> + logINF ( " Setup a parser on % d " , port ) ; <nl> } else if ( parsers . find ( it - > first ) ! = parsers . end ( ) & & it - > second . is_deleted ( ) ) { <nl> / / The namespace has been deleted . . . get rid of the parser <nl> parsers . erase ( it - > first ) ; <nl> mmm a / src / rpc / mailbox / mailbox . cc <nl> ppp b / src / rpc / mailbox / mailbox . cc <nl> void mailbox_manager_t : : on_message ( UNUSED peer_id_t source_peer , read_stream_t * <nl> dest_address . thread = dest_thread ; <nl> dest_address . mailbox_id = dest_mailbox_id ; <nl> <nl> - logDBG ( " Message dropped because mailbox % s no longer exists . ( This doesn ' t necessarily indicate a bug . ) \ n " , dest_address . human_readable ( ) . c_str ( ) ) ; <nl> + logDBG ( " Message dropped because mailbox % s no longer exists . ( This doesn ' t necessarily indicate a bug . ) " , dest_address . human_readable ( ) . c_str ( ) ) ; <nl> } <nl> } <nl> mmm a / src / unittest / utils_test . cc <nl> ppp b / src / unittest / utils_test . cc <nl> TEST ( UtilsTest , StrtofooStrict ) { <nl> <nl> TEST ( UtilsTest , Time ) { <nl> time_t time = 1334799841 ; <nl> - std : : string formatted = format_time ( time , buf , 100 ) ; <nl> + std : : string formatted = format_time ( time ) ; <nl> EXPECT_EQ ( " 2012 - 04 - 18T06 : 44 : 01 " , formatted ) ; <nl> time_t parsed = parse_time ( formatted ) ; <nl> EXPECT_EQ ( time , parsed ) ; <nl> mmm a / src / utils . cc <nl> ppp b / src / utils . cc <nl> void print_hd ( const void * vbuf , size_t offset , size_t ulength ) { <nl> <nl> void format_time ( time_t time , char * buf , size_t max_chars ) { <nl> struct tm t ; <nl> - struct tm * res1 = gmtime_r ( time , & t ) ; <nl> - guarantee_err ( res1 = = NULL , " gmtime_r ( ) failed . " ) ; <nl> - int res = snprintf ( buf , max_chars , <nl> + struct tm * res1 = gmtime_r ( & time , & t ) ; <nl> + guarantee_err ( res1 = = & t , " gmtime_r ( ) failed . " ) ; <nl> + int res2 = snprintf ( buf , max_chars , <nl> " % 04d - % 02d - % 02dT % 02d : % 02d : % 02d " , <nl> t . tm_year + 1900 , <nl> t . tm_mon + 1 , <nl> void format_time ( time_t time , char * buf , size_t max_chars ) { <nl> t . tm_hour , <nl> t . tm_min , <nl> t . tm_sec ) ; <nl> - ( void ) res ; <nl> - rassert ( 0 < = res ) ; <nl> + ( void ) res2 ; <nl> + rassert ( 0 < = res2 ) ; <nl> } <nl> <nl> std : : string format_time ( time_t time ) { <nl> std : : string format_time ( time_t time ) { <nl> <nl> time_t parse_time ( const std : : string & str ) THROWS_ONLY ( std : : runtime_error ) { <nl> struct tm t ; <nl> - int year , mon , mday , hour , min , sec , us ; <nl> - int res = sscanf ( str . c_str ( ) , <nl> + int res1 = sscanf ( str . c_str ( ) , <nl> " % 04d - % 02d - % 02dT % 02d : % 02d : % 02d " , <nl> - & t . year , <nl> - & t . mon , <nl> - & t . mday , <nl> - & t . hour , <nl> - & t . min , <nl> - & t . sec ) ; <nl> - if ( res ! = 6 ) { <nl> + & t . tm_year , <nl> + & t . tm_mon , <nl> + & t . tm_mday , <nl> + & t . tm_hour , <nl> + & t . tm_min , <nl> + & t . tm_sec ) ; <nl> + if ( res1 ! = 6 ) { <nl> throw std : : runtime_error ( " badly formatted time " ) ; <nl> } <nl> - t . year - = 1900 ; <nl> - t . mon - = 1 ; <nl> - t . isdst = - 1 ; <nl> - time_t res = mktime ( & t ) ; <nl> - if ( res = = - 1 ) { <nl> + t . tm_year - = 1900 ; <nl> + t . tm_mon - = 1 ; <nl> + t . tm_isdst = - 1 ; <nl> + time_t res2 = mktime ( & t ) ; <nl> + if ( res2 = = - 1 ) { <nl> throw std : : runtime_error ( " invalid time " ) ; <nl> } <nl> - return res ; <nl> + return res2 ; <nl> } <nl> <nl> # ifndef NDEBUG <nl> mmm a / src / utils . hpp <nl> ppp b / src / utils . hpp <nl> <nl> # include < stdio . h > <nl> # include < stdlib . h > <nl> <nl> + # include < stdexcept > <nl> # include < string > <nl> # include < vector > <nl> <nl> struct demangle_failed_exc_t : public std : : exception { <nl> } ; <nl> std : : string demangle_cpp_name ( const char * mangled_name ) ; <nl> <nl> - / / Precise time ( time + nanoseconds ) for logging , etc . <nl> - struct precise_time_t : public tm { <nl> - uint32_t ns ; / / nanoseconds since the start of the second <nl> - / / beware : <nl> - / / tm : : tm_year is number of years since 1970 , <nl> - / / tm : : tm_mon is number of months since January , <nl> - / / tm : : tm_sec is from 0 to 60 ( to account for leap seconds ) <nl> - / / For more information see man gmtime ( 3 ) <nl> - } ; <nl> - <nl> - void initialize_precise_time ( ) ; / / should be called during startup <nl> - void set_precise_time_offset ( timespec hi_res_clock , time_t low_res_clock ) ; / / used in unit - tests <nl> - timespec get_uptime ( ) ; / / returns relative time since initialize_precise_time ( ) , <nl> - / / can return low precision time if clock_gettime call fails <nl> - precise_time_t get_absolute_time ( const timespec & relative_time ) ; / / converts relative time to absolute <nl> - precise_time_t get_time_now ( ) ; / / equivalent to get_absolute_time ( get_uptime ( ) ) <nl> - <nl> / / formatted time : <nl> / / yyyy - mm - dd hh : mm : ss ( 19 characters ) <nl> - const size_t formatted_precise_time_length = 19 ; / / not including null <nl> + const size_t formatted_time_length = 19 ; / / not including null <nl> <nl> void format_time ( time_t time , char * buf , size_t max_chars ) ; <nl> std : : string format_time ( time_t time ) ; <nl>
|
WIP on advanced logging
|
rethinkdb/rethinkdb
|
0881484ea633c4e691b6d9cfc97fd8967a09be3a
|
2012-04-20T20:23:03Z
|
mmm a / imgui . cpp <nl> ppp b / imgui . cpp <nl> void ImGui : : ShowMetricsWindow ( bool * p_open ) <nl> { <nl> ImDrawList * draw_list = ImGui : : GetForegroundDrawList ( ) ; <nl> draw_list - > AddRect ( tab_bar - > BarRect . Min , tab_bar - > BarRect . Max , IM_COL32 ( 255 , 255 , 0 , 255 ) ) ; <nl> - if ( tab_bar - > Sections [ 0 ] . Width > 0 . 0f ) <nl> - draw_list - > AddLine ( ImVec2 ( tab_bar - > BarRect . Min . x + tab_bar - > Sections [ 0 ] . Width , tab_bar - > BarRect . Min . y ) , ImVec2 ( tab_bar - > BarRect . Min . x + tab_bar - > Sections [ 0 ] . Width , tab_bar - > BarRect . Max . y ) , IM_COL32 ( 0 , 255 , 0 , 255 ) ) ; <nl> - if ( tab_bar - > Sections [ 2 ] . Width > 0 . 0f ) <nl> - draw_list - > AddLine ( ImVec2 ( tab_bar - > BarRect . Max . x - tab_bar - > Sections [ 2 ] . Width , tab_bar - > BarRect . Min . y ) , ImVec2 ( tab_bar - > BarRect . Max . x - tab_bar - > Sections [ 2 ] . Width , tab_bar - > BarRect . Max . y ) , IM_COL32 ( 0 , 255 , 0 , 255 ) ) ; <nl> + draw_list - > AddLine ( ImVec2 ( tab_bar - > ScrollingRectMinX , tab_bar - > BarRect . Min . y ) , ImVec2 ( tab_bar - > ScrollingRectMinX , tab_bar - > BarRect . Max . y ) , IM_COL32 ( 0 , 255 , 0 , 255 ) ) ; <nl> + draw_list - > AddLine ( ImVec2 ( tab_bar - > ScrollingRectMaxX , tab_bar - > BarRect . Min . y ) , ImVec2 ( tab_bar - > ScrollingRectMaxX , tab_bar - > BarRect . Max . y ) , IM_COL32 ( 0 , 255 , 0 , 255 ) ) ; <nl> } <nl> if ( open ) <nl> { <nl> mmm a / imgui_internal . h <nl> ppp b / imgui_internal . h <nl> struct ImGuiTabItem <nl> ImGuiTabItem ( ) { ID = 0 ; Flags = ImGuiTabItemFlags_None ; LastFrameVisible = LastFrameSelected = - 1 ; NameOffset = - 1 ; Offset = Width = ContentWidth = 0 . 0f ; BeginOrder = - 1 ; IndexDuringLayout = - 1 ; WantClose = false ; } <nl> } ; <nl> <nl> - struct ImGuiTabBarSection <nl> - { <nl> - int TabStartIndex ; / / Index of first tab in this section . <nl> - int TabCount ; / / Number of tabs in this section . <nl> - float Width ; / / Sum of width of tabs in this section ( after shrinking down ) <nl> - float Spacing ; / / Horizontal spacing at the end of the section . <nl> - <nl> - ImGuiTabBarSection ( ) { memset ( this , 0 , sizeof ( * this ) ) ; } <nl> - } ; <nl> - <nl> / / Storage for a tab bar ( sizeof ( ) 92 ~ 96 bytes ) <nl> struct ImGuiTabBar <nl> { <nl> struct ImGuiTabBar <nl> float ScrollingTarget ; <nl> float ScrollingTargetDistToVisibility ; <nl> float ScrollingSpeed ; <nl> + float ScrollingRectMinX ; <nl> + float ScrollingRectMaxX ; <nl> ImGuiTabBarFlags Flags ; <nl> ImGuiID ReorderRequestTabId ; <nl> ImS8 ReorderRequestDir ; <nl> struct ImGuiTabBar <nl> bool TabsAddedNew ; / / Set to true when a new tab item or button has been added to the tab bar during last frame <nl> short LastTabItemIdx ; / / Index of last BeginTabItem ( ) tab for use by EndTabItem ( ) <nl> ImVec2 FramePadding ; / / style . FramePadding locked at the time of BeginTabBar ( ) <nl> - ImGuiTabBarSection Sections [ 3 ] ; / / Layout sections : Leading , Central , Trailing <nl> ImGuiTextBuffer TabsNames ; / / For non - docking tab bar we re - append names in a contiguous buffer . <nl> <nl> ImGuiTabBar ( ) ; <nl> mmm a / imgui_widgets . cpp <nl> ppp b / imgui_widgets . cpp <nl> bool ImGui : : MenuItem ( const char * label , const char * shortcut , bool * p_selected , <nl> / / - TabBarTabListPopupButton ( ) [ Internal ] <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> <nl> + struct ImGuiTabBarSection <nl> + { <nl> + int TabCount ; / / Number of tabs in this section . <nl> + float Width ; / / Sum of width of tabs in this section ( after shrinking down ) <nl> + float Spacing ; / / Horizontal spacing at the end of the section . <nl> + <nl> + ImGuiTabBarSection ( ) { memset ( this , 0 , sizeof ( * this ) ) ; } <nl> + } ; <nl> + <nl> namespace ImGui <nl> { <nl> static void TabBarLayout ( ImGuiTabBar * tab_bar ) ; <nl> static ImU32 TabBarCalcTabID ( ImGuiTabBar * tab_bar , const char * label ) ; <nl> static float TabBarCalcMaxTabWidth ( ) ; <nl> static float TabBarScrollClamp ( ImGuiTabBar * tab_bar , float scrolling ) ; <nl> - static void TabBarScrollToTab ( ImGuiTabBar * tab_bar , ImGuiTabItem * tab ) ; <nl> + static void TabBarScrollToTab ( ImGuiTabBar * tab_bar , ImGuiTabItem * tab , ImGuiTabBarSection * sections ) ; <nl> static ImGuiTabItem * TabBarScrollingButtons ( ImGuiTabBar * tab_bar ) ; <nl> static ImGuiTabItem * TabBarTabListPopupButton ( ImGuiTabBar * tab_bar ) ; <nl> } <nl> ImGuiTabBar : : ImGuiTabBar ( ) <nl> LastTabContentHeight = 0 . 0f ; <nl> WidthAllTabs = WidthAllTabsIdeal = 0 . 0f ; <nl> ScrollingAnim = ScrollingTarget = ScrollingTargetDistToVisibility = ScrollingSpeed = 0 . 0f ; <nl> + ScrollingRectMinX = ScrollingRectMaxX = 0 . 0f ; <nl> Flags = ImGuiTabBarFlags_None ; <nl> ReorderRequestTabId = 0 ; <nl> ReorderRequestDir = 0 ; <nl> static ImGuiPtrOrIndex GetTabBarRefFromTabBar ( ImGuiTabBar * tab_bar ) <nl> return ImGuiPtrOrIndex ( tab_bar ) ; <nl> } <nl> <nl> - static ImVec2 GetTabBarScrollingButtonSize ( ) <nl> - { <nl> - ImGuiContext & g = * GImGui ; <nl> - return ImVec2 ( g . FontSize - 2 . 0f , g . FontSize + g . Style . FramePadding . y * 2 . 0f ) ; <nl> - } <nl> - <nl> bool ImGui : : BeginTabBar ( const char * str_id , ImGuiTabBarFlags flags ) <nl> { <nl> ImGuiContext & g = * GImGui ; <nl> void ImGui : : EndTabBar ( ) <nl> static void ImGui : : TabBarLayout ( ImGuiTabBar * tab_bar ) <nl> { <nl> ImGuiContext & g = * GImGui ; <nl> - ImGuiTabBarSection * sections = tab_bar - > Sections ; <nl> tab_bar - > WantLayout = false ; <nl> <nl> / / Garbage collect by compacting list <nl> / / Detect if we need to sort out tab list ( e . g . in rare case where a tab changed section ) <nl> int tab_dst_n = 0 ; <nl> bool need_sort_by_section = false ; <nl> - sections [ 0 ] . TabCount = sections [ 1 ] . TabCount = sections [ 2 ] . TabCount = 0 ; <nl> + ImGuiTabBarSection sections [ 3 ] ; / / Layout sections : Leading , Central , Trailing <nl> for ( int tab_src_n = 0 ; tab_src_n < tab_bar - > Tabs . Size ; tab_src_n + + ) <nl> { <nl> ImGuiTabItem * tab = & tab_bar - > Tabs [ tab_src_n ] ; <nl> static void ImGui : : TabBarLayout ( ImGuiTabBar * tab_bar ) <nl> / / Calculate spacing between sections <nl> sections [ 0 ] . Spacing = sections [ 0 ] . TabCount > 0 & & ( sections [ 1 ] . TabCount + sections [ 2 ] . TabCount ) > 0 ? g . Style . ItemInnerSpacing . x : 0 . 0f ; <nl> sections [ 1 ] . Spacing = sections [ 1 ] . TabCount > 0 & & sections [ 2 ] . TabCount > 0 ? g . Style . ItemInnerSpacing . x : 0 . 0f ; <nl> - sections [ 2 ] . Spacing = 0 . 0f ; <nl> - sections [ 0 ] . TabStartIndex = 0 ; <nl> - sections [ 1 ] . TabStartIndex = sections [ 0 ] . TabStartIndex + sections [ 0 ] . TabCount ; <nl> - sections [ 2 ] . TabStartIndex = sections [ 1 ] . TabStartIndex + sections [ 1 ] . TabCount ; <nl> - sections [ 0 ] . Width = 0 . 0f ; <nl> - sections [ 1 ] . Width = 0 . 0f ; <nl> - sections [ 2 ] . Width = 0 . 0f ; <nl> <nl> / / Setup next selected tab <nl> ImGuiID scroll_track_selected_tab_id = 0 ; <nl> static void ImGui : : TabBarLayout ( ImGuiTabBar * tab_bar ) <nl> <nl> / / Compute ideal tabs widths + store them into shrink buffer <nl> ImGuiTabItem * most_recently_selected_tab = NULL ; <nl> + int curr_section_n = - 1 ; <nl> bool found_selected_tab_id = false ; <nl> for ( int tab_n = 0 ; tab_n < tab_bar - > Tabs . Size ; tab_n + + ) <nl> { <nl> static void ImGui : : TabBarLayout ( ImGuiTabBar * tab_bar ) <nl> <nl> int section_n = ( tab - > Flags & ImGuiTabItemFlags_Leading ) ? 0 : ( tab - > Flags & ImGuiTabItemFlags_Trailing ) ? 2 : 1 ; <nl> ImGuiTabBarSection * section = & sections [ section_n ] ; <nl> - section - > Width + = tab - > ContentWidth + ( tab_n > section - > TabStartIndex ? g . Style . ItemInnerSpacing . x : 0 . 0f ) ; <nl> + section - > Width + = tab - > ContentWidth + ( section_n = = curr_section_n ? g . Style . ItemInnerSpacing . x : 0 . 0f ) ; <nl> + curr_section_n = section_n ; <nl> <nl> / / Store data so we can build an array sorted by width if we need to shrink tabs down <nl> int shrink_buffer_index = shrink_buffer_indexes [ section_n ] + + ; <nl> static void ImGui : : TabBarLayout ( ImGuiTabBar * tab_bar ) <nl> } <nl> <nl> / / Layout all active tabs <nl> - float next_tab_offset = 0 . 0f ; <nl> + int section_tab_index = 0 ; <nl> + float tab_offset = 0 . 0f ; <nl> tab_bar - > WidthAllTabs = 0 . 0f ; <nl> for ( int section_n = 0 ; section_n < 3 ; section_n + + ) <nl> { <nl> - / / FIXME : The + 1 . 0f is in TabBarScrollingButtons ( ) <nl> ImGuiTabBarSection * section = & sections [ section_n ] ; <nl> if ( section_n = = 2 ) <nl> - next_tab_offset = ImMin ( tab_bar - > BarRect . GetWidth ( ) - section - > Width , next_tab_offset ) ; <nl> + tab_offset = ImMin ( ImMax ( 0 . 0f , tab_bar - > BarRect . GetWidth ( ) - section - > Width ) , tab_offset ) ; <nl> <nl> for ( int tab_n = 0 ; tab_n < section - > TabCount ; tab_n + + ) <nl> { <nl> - ImGuiTabItem * tab = & tab_bar - > Tabs [ section - > TabStartIndex + tab_n ] ; <nl> - tab - > Offset = next_tab_offset ; <nl> - next_tab_offset + = tab - > Width + ( tab_n < section - > TabCount - 1 ? g . Style . ItemInnerSpacing . x : 0 . 0f ) ; <nl> + ImGuiTabItem * tab = & tab_bar - > Tabs [ section_tab_index + tab_n ] ; <nl> + tab - > Offset = tab_offset ; <nl> + tab_offset + = tab - > Width + ( tab_n < section - > TabCount - 1 ? g . Style . ItemInnerSpacing . x : 0 . 0f ) ; <nl> } <nl> tab_bar - > WidthAllTabs + = ImMax ( section - > Width + section - > Spacing , 0 . 0f ) ; <nl> - next_tab_offset + = section - > Spacing ; <nl> + tab_offset + = section - > Spacing ; <nl> + section_tab_index + = section - > TabCount ; <nl> } <nl> <nl> / / If we have lost the selected tab , select the next most recently active one <nl> static void ImGui : : TabBarLayout ( ImGuiTabBar * tab_bar ) <nl> / / Update scrolling <nl> if ( scroll_track_selected_tab_id ) <nl> if ( ImGuiTabItem * scroll_track_selected_tab = TabBarFindTabByID ( tab_bar , scroll_track_selected_tab_id ) ) <nl> - TabBarScrollToTab ( tab_bar , scroll_track_selected_tab ) ; <nl> + TabBarScrollToTab ( tab_bar , scroll_track_selected_tab , sections ) ; <nl> tab_bar - > ScrollingAnim = TabBarScrollClamp ( tab_bar , tab_bar - > ScrollingAnim ) ; <nl> tab_bar - > ScrollingTarget = TabBarScrollClamp ( tab_bar , tab_bar - > ScrollingTarget ) ; <nl> if ( tab_bar - > ScrollingAnim ! = tab_bar - > ScrollingTarget ) <nl> static void ImGui : : TabBarLayout ( ImGuiTabBar * tab_bar ) <nl> { <nl> tab_bar - > ScrollingSpeed = 0 . 0f ; <nl> } <nl> + tab_bar - > ScrollingRectMinX = tab_bar - > BarRect . Min . x + sections [ 0 ] . Width + sections [ 0 ] . Spacing ; <nl> + tab_bar - > ScrollingRectMaxX = tab_bar - > BarRect . Max . x - sections [ 2 ] . Width - sections [ 1 ] . Spacing ; <nl> <nl> / / Clear name buffers <nl> if ( ( tab_bar - > Flags & ImGuiTabBarFlags_DockNode ) = = 0 ) <nl> static float ImGui : : TabBarScrollClamp ( ImGuiTabBar * tab_bar , float scrolling ) <nl> return ImMax ( scrolling , 0 . 0f ) ; <nl> } <nl> <nl> - static void ImGui : : TabBarScrollToTab ( ImGuiTabBar * tab_bar , ImGuiTabItem * tab ) <nl> + static void ImGui : : TabBarScrollToTab ( ImGuiTabBar * tab_bar , ImGuiTabItem * tab , ImGuiTabBarSection * sections ) <nl> { <nl> if ( tab - > Flags & ( ImGuiTabItemFlags_Leading | ImGuiTabItemFlags_Trailing ) ) <nl> return ; <nl> <nl> ImGuiContext & g = * GImGui ; <nl> - ImGuiTabBarSection * sections = tab_bar - > Sections ; <nl> float margin = g . FontSize * 1 . 0f ; / / When to scroll to make Tab N + 1 visible always make a bit of N visible to suggest more scrolling area ( since we don ' t have a scrollbar ) <nl> int order = tab_bar - > GetTabOrder ( tab ) ; <nl> <nl> static ImGuiTabItem * ImGui : : TabBarScrollingButtons ( ImGuiTabBar * tab_bar ) <nl> ImGuiContext & g = * GImGui ; <nl> ImGuiWindow * window = g . CurrentWindow ; <nl> <nl> - const ImVec2 arrow_button_size = GetTabBarScrollingButtonSize ( ) ; <nl> + const ImVec2 arrow_button_size ( g . FontSize - 2 . 0f , g . FontSize + g . Style . FramePadding . y * 2 . 0f ) ; <nl> const float scrolling_buttons_width = arrow_button_size . x * 2 . 0f ; <nl> <nl> const ImVec2 backup_cursor_pos = window - > DC . CursorPos ; <nl> bool ImGui : : TabItemEx ( ImGuiTabBar * tab_bar , const char * label , bool * p_open , <nl> const ImVec2 backup_main_cursor_pos = window - > DC . CursorPos ; <nl> <nl> / / Layout <nl> + const bool is_central_section = ( tab - > Flags & ( ImGuiTabItemFlags_Leading | ImGuiTabItemFlags_Trailing ) ) = = 0 ; <nl> size . x = tab - > Width ; <nl> - if ( tab - > Flags & ( ImGuiTabItemFlags_Leading | ImGuiTabItemFlags_Trailing ) ) <nl> - window - > DC . CursorPos = tab_bar - > BarRect . Min + ImVec2 ( tab - > Offset , 0 . 0f ) ; <nl> - else <nl> + if ( is_central_section ) <nl> window - > DC . CursorPos = tab_bar - > BarRect . Min + ImVec2 ( IM_FLOOR ( tab - > Offset - tab_bar - > ScrollingAnim ) , 0 . 0f ) ; <nl> + else <nl> + window - > DC . CursorPos = tab_bar - > BarRect . Min + ImVec2 ( tab - > Offset , 0 . 0f ) ; <nl> ImVec2 pos = window - > DC . CursorPos ; <nl> ImRect bb ( pos , pos + size ) ; <nl> <nl> / / We don ' t have CPU clipping primitives to clip the CloseButton ( until it becomes a texture ) , so need to add an extra draw call ( temporary in the case of vertical animation ) <nl> - / / Leading buttons will be clipped by BarRect . Max . x , Trailing buttons will be clipped at BarRect . Min . x + LeadingsWidth ( + spacing if there are some buttons ) , and central tabs will be clipped inbetween <nl> - float offset_trailing = ( flags & ( ImGuiTabItemFlags_Trailing | ImGuiTabItemFlags_Leading ) ) ? 0 . 0f : tab_bar - > Sections [ 2 ] . Width + tab_bar - > Sections [ 1 ] . Spacing ; <nl> - float offset_leading = ( flags & ImGuiTabItemFlags_Leading ) ? 0 . 0f : tab_bar - > Sections [ 0 ] . Width + tab_bar - > Sections [ 0 ] . Spacing ; <nl> - bool want_clip_rect = ( bb . Min . x < tab_bar - > BarRect . Min . x + offset_leading ) | | ( bb . Max . x > tab_bar - > BarRect . Max . x - offset_trailing ) ; <nl> + const bool want_clip_rect = is_central_section & & ( bb . Min . x < tab_bar - > ScrollingRectMinX | | bb . Max . x > tab_bar - > ScrollingRectMaxX ) ; <nl> if ( want_clip_rect ) <nl> - PushClipRect ( ImVec2 ( ImMax ( bb . Min . x , tab_bar - > BarRect . Min . x + offset_leading ) , bb . Min . y - 1 ) , ImVec2 ( tab_bar - > BarRect . Max . x - offset_trailing , bb . Max . y ) , true ) ; <nl> + PushClipRect ( ImVec2 ( ImMax ( bb . Min . x , tab_bar - > ScrollingRectMinX ) , bb . Min . y - 1 ) , ImVec2 ( tab_bar - > ScrollingRectMaxX , bb . Max . y ) , true ) ; <nl> <nl> ImVec2 backup_cursor_max_pos = window - > DC . CursorMaxPos ; <nl> ItemSize ( bb . GetSize ( ) , style . FramePadding . y ) ; <nl>
|
Tab Bar : Further simplification of section / clip rect handling . ( )
|
ocornut/imgui
|
1ec464eb9aa077b7eae81e50fce8844a85625cc7
|
2020-09-22T14:43:40Z
|
mmm a / source / extensions / filters / http / csrf / csrf_filter . cc <nl> ppp b / source / extensions / filters / http / csrf / csrf_filter . cc <nl> bool CsrfFilter : : isValid ( const absl : : string_view source_origin , Http : : HeaderMap & <nl> return true ; <nl> } <nl> <nl> - for ( const auto & additional_origin : policy_ - > additional_origins ( ) ) { <nl> + for ( const auto & additional_origin : policy_ - > additionalOrigins ( ) ) { <nl> if ( additional_origin - > match ( source_origin ) ) { <nl> return true ; <nl> } <nl> mmm a / source / extensions / filters / http / csrf / csrf_filter . h <nl> ppp b / source / extensions / filters / http / csrf / csrf_filter . h <nl> class CsrfPolicy : public Router : : RouteSpecificFilterConfig { <nl> shadow_enabled . default_value ( ) ) ; <nl> } <nl> <nl> - const std : : vector < Matchers : : StringMatcherPtr > & additional_origins ( ) const { <nl> + const std : : vector < Matchers : : StringMatcherPtr > & additionalOrigins ( ) const { <nl> return additional_origins_ ; <nl> } ; <nl> <nl>
|
csrf filter : fix casing of additional origins method ( )
|
envoyproxy/envoy
|
d6950726bd871688cb237dea406658d2c0263170
|
2019-10-08T02:43:49Z
|
mmm a / CONTRIBUTING . md <nl> ppp b / CONTRIBUTING . md <nl> In order to run all of the tests we provide , you will need valgrind and clang . <nl> More specifically , under debian , you will need the package libc + + - dev to <nl> properly run all the tests . <nl> <nl> + Compiling and running grpc C + + tests depend on protobuf 3 . 0 . 0 , gtest and gflags . <nl> + Although gflags is provided in third_party , you will need to manually install <nl> + that dependency on your system to run these tests . Under a Debian or Ubuntu <nl> + system , you can install the gtests and gflags packages using apt - get : <nl> + <nl> + ` ` ` sh <nl> + $ [ sudo ] apt - get install libgflags - dev libgtest - dev <nl> + ` ` ` <nl> + <nl> If you are planning to work on any of the languages other than C and C + + , you <nl> will also need their appropriate development environments . <nl> <nl>
|
Merge pull request from yang - g / gflags_mention
|
grpc/grpc
|
9b9c40cfe8aab8699cc446087313af9059e8db3a
|
2016-03-07T22:53:15Z
|
mmm a / editor / editor_run_native . cpp <nl> ppp b / editor / editor_run_native . cpp <nl> void EditorRunNative : : _run_native ( int p_idx , int p_platform ) { <nl> } <nl> <nl> if ( preset . is_null ( ) ) { <nl> - EditorNode : : get_singleton ( ) - > show_warning ( TTR ( " No runnable export preset found for this platform . \ nPlease add a runnable preset in the export menu . " ) ) ; <nl> + EditorNode : : get_singleton ( ) - > show_warning ( TTR ( " No runnable export preset found for this platform . \ nPlease add a runnable preset in the Export menu or define an existing preset as runnable . " ) ) ; <nl> return ; <nl> } <nl> <nl> mmm a / editor / plugins / debugger_editor_plugin . cpp <nl> ppp b / editor / plugins / debugger_editor_plugin . cpp <nl> DebuggerEditorPlugin : : DebuggerEditorPlugin ( EditorNode * p_editor , MenuButton * p_d <nl> ED_SHORTCUT ( " debugger / keep_debugger_open " , TTR ( " Keep Debugger Open " ) ) ; <nl> ED_SHORTCUT ( " debugger / debug_with_external_editor " , TTR ( " Debug with External Editor " ) ) ; <nl> <nl> - / / File Server for deploy with remote fs . <nl> + / / File Server for deploy with remote filesystem . <nl> file_server = memnew ( EditorFileServer ) ; <nl> <nl> EditorDebuggerNode * debugger = memnew ( EditorDebuggerNode ) ; <nl> DebuggerEditorPlugin : : DebuggerEditorPlugin ( EditorNode * p_editor , MenuButton * p_d <nl> PopupMenu * p = debug_menu - > get_popup ( ) ; <nl> p - > set_hide_on_checkable_item_selection ( false ) ; <nl> p - > add_check_shortcut ( ED_SHORTCUT ( " editor / deploy_with_remote_debug " , TTR ( " Deploy with Remote Debug " ) ) , RUN_DEPLOY_REMOTE_DEBUG ) ; <nl> - p - > set_item_tooltip ( p - > get_item_count ( ) - 1 , TTR ( " When exporting or deploying , the resulting executable will attempt to connect to the IP of this computer in order to be debugged . " ) ) ; <nl> - p - > add_check_shortcut ( ED_SHORTCUT ( " editor / small_deploy_with_network_fs " , TTR ( " Small Deploy with Network FS " ) ) , RUN_FILE_SERVER ) ; <nl> - p - > set_item_tooltip ( p - > get_item_count ( ) - 1 , TTR ( " When this option is enabled , export or deploy will produce a minimal executable . \ nThe filesystem will be provided from the project by the editor over the network . \ nOn Android , deploy will use the USB cable for faster performance . This option speeds up testing for games with a large footprint . " ) ) ; <nl> + p - > set_item_tooltip ( <nl> + p - > get_item_count ( ) - 1 , <nl> + TTR ( " When this option is enabled , using one - click deploy will make the executable attempt to connect to this computer ' s IP so the running project can be debugged . \ nThis option is intended to be used for remote debugging ( typically with a mobile device ) . \ nYou don ' t need to enable it to use the GDScript debugger locally . " ) ) ; <nl> + p - > add_check_shortcut ( ED_SHORTCUT ( " editor / small_deploy_with_network_fs " , TTR ( " Small Deploy with Network Filesystem " ) ) , RUN_FILE_SERVER ) ; <nl> + p - > set_item_tooltip ( <nl> + p - > get_item_count ( ) - 1 , <nl> + TTR ( " When this option is enabled , using one - click deploy for Android will only export an executable without the project data . \ nThe filesystem will be provided from the project by the editor over the network . \ nOn Android , deploying will use the USB cable for faster performance . This option speeds up testing for projects with large assets . " ) ) ; <nl> p - > add_separator ( ) ; <nl> p - > add_check_shortcut ( ED_SHORTCUT ( " editor / visible_collision_shapes " , TTR ( " Visible Collision Shapes " ) ) , RUN_DEBUG_COLLISONS ) ; <nl> - p - > set_item_tooltip ( p - > get_item_count ( ) - 1 , TTR ( " Collision shapes and raycast nodes ( for 2D and 3D ) will be visible on the running game if this option is turned on . " ) ) ; <nl> + p - > set_item_tooltip ( <nl> + p - > get_item_count ( ) - 1 , <nl> + TTR ( " When this option is enabled , collision shapes and raycast nodes ( for 2D and 3D ) will be visible in the running project . " ) ) ; <nl> p - > add_check_shortcut ( ED_SHORTCUT ( " editor / visible_navigation " , TTR ( " Visible Navigation " ) ) , RUN_DEBUG_NAVIGATION ) ; <nl> - p - > set_item_tooltip ( p - > get_item_count ( ) - 1 , TTR ( " Navigation meshes and polygons will be visible on the running game if this option is turned on . " ) ) ; <nl> + p - > set_item_tooltip ( <nl> + p - > get_item_count ( ) - 1 , <nl> + TTR ( " When this option is enabled , navigation meshes and polygons will be visible in the running project . " ) ) ; <nl> p - > add_separator ( ) ; <nl> - p - > add_check_shortcut ( ED_SHORTCUT ( " editor / sync_scene_changes " , TTR ( " Sync Scene Changes " ) ) , RUN_LIVE_DEBUG ) ; <nl> - p - > set_item_tooltip ( p - > get_item_count ( ) - 1 , TTR ( " When this option is turned on , any changes made to the scene in the editor will be replicated in the running game . \ nWhen used remotely on a device , this is more efficient with network filesystem . " ) ) ; <nl> - p - > add_check_shortcut ( ED_SHORTCUT ( " editor / sync_script_changes " , TTR ( " Sync Script Changes " ) ) , RUN_RELOAD_SCRIPTS ) ; <nl> - p - > set_item_tooltip ( p - > get_item_count ( ) - 1 , TTR ( " When this option is turned on , any script that is saved will be reloaded on the running game . \ nWhen used remotely on a device , this is more efficient with network filesystem . " ) ) ; <nl> + p - > add_check_shortcut ( ED_SHORTCUT ( " editor / sync_scene_changes " , TTR ( " Synchronize Scene Changes " ) ) , RUN_LIVE_DEBUG ) ; <nl> + p - > set_item_tooltip ( <nl> + p - > get_item_count ( ) - 1 , <nl> + TTR ( " When this option is enabled , any changes made to the scene in the editor will be replicated in the running project . \ nWhen used remotely on a device , this is more efficient when the network filesystem option is enabled . " ) ) ; <nl> + p - > add_check_shortcut ( ED_SHORTCUT ( " editor / sync_script_changes " , TTR ( " Synchronize Script Changes " ) ) , RUN_RELOAD_SCRIPTS ) ; <nl> + p - > set_item_tooltip ( <nl> + p - > get_item_count ( ) - 1 , <nl> + TTR ( " When this option is enabled , any script that is saved will be reloaded in the running project . \ nWhen used remotely on a device , this is more efficient when the network filesystem option is enabled . " ) ) ; <nl> <nl> / / Multi - instance , start / stop <nl> instances_menu = memnew ( PopupMenu ) ; <nl>
|
Merge pull request from Calinou / improve - debug - editor - tooltips
|
godotengine/godot
|
dc8d8d1b5d4dd936cc9bb1c69414444bce0eabc3
|
2020-09-04T08:07:21Z
|
mmm a / dbms / cmake / version . cmake <nl> ppp b / dbms / cmake / version . cmake <nl> <nl> # This strings autochanged from release_lib . sh : <nl> - set ( VERSION_DESCRIBE v1 . 1 . 54361 - testing ) <nl> - set ( VERSION_REVISION 54361 ) <nl> + set ( VERSION_DESCRIBE v1 . 1 . 54362 - testing ) <nl> + set ( VERSION_REVISION 54362 ) <nl> # end of autochange <nl> <nl> set ( VERSION_MAJOR 1 ) <nl> mmm a / debian / changelog <nl> ppp b / debian / changelog <nl> <nl> - clickhouse ( 1 . 1 . 54361 ) unstable ; urgency = low <nl> + clickhouse ( 1 . 1 . 54362 ) unstable ; urgency = low <nl> <nl> * Modified source code <nl> <nl> - - - < robot - metrika - test @ yandex - team . ru > Sat , 10 Mar 2018 02 : 53 : 58 + 0300 <nl> + - - < robot - metrika - test @ yandex - team . ru > Sat , 10 Mar 2018 23 : 15 : 14 + 0300 <nl>
|
Auto version update to [ 54362 ]
|
ClickHouse/ClickHouse
|
48d90ed960ee68cb7310516560e09edda2519529
|
2018-03-10T20:15:15Z
|
mmm a / src / arm / stub - cache - arm . cc <nl> ppp b / src / arm / stub - cache - arm . cc <nl> void StoreStubCompiler : : GenerateStoreViaSetter ( <nl> Handle < Code > StoreStubCompiler : : CompileStoreInterceptor ( <nl> Handle < JSObject > object , <nl> Handle < Name > name ) { <nl> - Label miss ; <nl> - <nl> - / / Check that the map of the object hasn ' t changed . <nl> - __ CheckMap ( receiver ( ) , scratch1 ( ) , Handle < Map > ( object - > map ( ) ) , & miss , <nl> - DO_SMI_CHECK ) ; <nl> - <nl> - / / Perform global security token check if needed . <nl> - if ( object - > IsJSGlobalProxy ( ) ) { <nl> - __ CheckAccessGlobalProxy ( receiver ( ) , scratch1 ( ) , & miss ) ; <nl> - } <nl> - <nl> - / / Stub is never generated for non - global objects that require access <nl> - / / checks . <nl> - ASSERT ( object - > IsJSGlobalProxy ( ) | | ! object - > IsAccessCheckNeeded ( ) ) ; <nl> - <nl> __ Push ( receiver ( ) , this - > name ( ) , value ( ) ) ; <nl> <nl> / / Do tail - call to the runtime system . <nl> Handle < Code > StoreStubCompiler : : CompileStoreInterceptor ( <nl> ExternalReference ( IC_Utility ( IC : : kStoreInterceptorProperty ) , isolate ( ) ) ; <nl> __ TailCallExternalReference ( store_ic_property , 3 , 1 ) ; <nl> <nl> - / / Handle store cache miss . <nl> - __ bind ( & miss ) ; <nl> - TailCallBuiltin ( masm ( ) , MissBuiltin ( kind ( ) ) ) ; <nl> - <nl> / / Return the generated code . <nl> return GetCode ( kind ( ) , Code : : FAST , name ) ; <nl> } <nl> mmm a / src / code - stubs - hydrogen . cc <nl> ppp b / src / code - stubs - hydrogen . cc <nl> HValue * CodeStubGraphBuilder < StoreGlobalStub > : : BuildCodeInitializedStub ( ) { <nl> Handle < PropertyCell > placeholder_cell = <nl> isolate ( ) - > factory ( ) - > NewPropertyCell ( placeholer_value ) ; <nl> <nl> - HParameter * receiver = GetParameter ( 0 ) ; <nl> HParameter * value = GetParameter ( 2 ) ; <nl> <nl> - / / Check that the map of the global has not changed : use a placeholder map <nl> - / / that will be replaced later with the global object ' s map . <nl> - Handle < Map > placeholder_map = isolate ( ) - > factory ( ) - > meta_map ( ) ; <nl> - Add < HCheckMaps > ( receiver , placeholder_map , top_info ( ) ) ; <nl> + if ( stub - > check_global ( ) ) { <nl> + / / Check that the map of the global has not changed : use a placeholder map <nl> + / / that will be replaced later with the global object ' s map . <nl> + Handle < Map > placeholder_map = isolate ( ) - > factory ( ) - > meta_map ( ) ; <nl> + HValue * global = Add < HConstant > ( <nl> + StoreGlobalStub : : global_placeholder ( isolate ( ) ) ) ; <nl> + Add < HCheckMaps > ( global , placeholder_map , top_info ( ) ) ; <nl> + } <nl> <nl> HValue * cell = Add < HConstant > ( placeholder_cell ) ; <nl> HObjectAccess access ( HObjectAccess : : ForCellPayload ( isolate ( ) ) ) ; <nl> mmm a / src / code - stubs . h <nl> ppp b / src / code - stubs . h <nl> class LoadFieldStub : public HandlerStub { <nl> <nl> class StoreGlobalStub : public HandlerStub { <nl> public : <nl> - explicit StoreGlobalStub ( bool is_constant ) { <nl> - bit_field_ = IsConstantBits : : encode ( is_constant ) ; <nl> + explicit StoreGlobalStub ( bool is_constant , bool check_global ) { <nl> + bit_field_ = IsConstantBits : : encode ( is_constant ) | <nl> + CheckGlobalBits : : encode ( check_global ) ; <nl> + } <nl> + <nl> + static Handle < HeapObject > global_placeholder ( Isolate * isolate ) { <nl> + return isolate - > factory ( ) - > uninitialized_value ( ) ; <nl> } <nl> <nl> Handle < Code > GetCodeCopyFromTemplate ( Isolate * isolate , <nl> - Map * receiver_map , <nl> + GlobalObject * global , <nl> PropertyCell * cell ) { <nl> Handle < Code > code = CodeStub : : GetCodeCopyFromTemplate ( isolate ) ; <nl> - / / Replace the placeholder cell and global object map with the actual global <nl> - / / cell and receiver map . <nl> + if ( check_global ( ) ) { <nl> + / / Replace the placeholder cell and global object map with the actual <nl> + / / global cell and receiver map . <nl> + code - > ReplaceNthObject ( 1 , global_placeholder ( isolate ) - > map ( ) , global ) ; <nl> + code - > ReplaceNthObject ( 1 , isolate - > heap ( ) - > meta_map ( ) , global - > map ( ) ) ; <nl> + } <nl> Map * cell_map = isolate - > heap ( ) - > global_property_cell_map ( ) ; <nl> code - > ReplaceNthObject ( 1 , cell_map , cell ) ; <nl> - code - > ReplaceNthObject ( 1 , isolate - > heap ( ) - > meta_map ( ) , receiver_map ) ; <nl> return code ; <nl> } <nl> <nl> class StoreGlobalStub : public HandlerStub { <nl> Isolate * isolate , <nl> CodeStubInterfaceDescriptor * descriptor ) ; <nl> <nl> - bool is_constant ( ) { <nl> + bool is_constant ( ) const { <nl> return IsConstantBits : : decode ( bit_field_ ) ; <nl> } <nl> + bool check_global ( ) const { <nl> + return CheckGlobalBits : : decode ( bit_field_ ) ; <nl> + } <nl> void set_is_constant ( bool value ) { <nl> bit_field_ = IsConstantBits : : update ( bit_field_ , value ) ; <nl> } <nl> class StoreGlobalStub : public HandlerStub { <nl> <nl> class IsConstantBits : public BitField < bool , 0 , 1 > { } ; <nl> class RepresentationBits : public BitField < Representation : : Kind , 1 , 8 > { } ; <nl> + class CheckGlobalBits : public BitField < bool , 9 , 1 > { } ; <nl> <nl> DISALLOW_COPY_AND_ASSIGN ( StoreGlobalStub ) ; <nl> } ; <nl> mmm a / src / ic . cc <nl> ppp b / src / ic . cc <nl> MaybeObject * KeyedLoadIC : : Load ( Handle < Object > object , Handle < Object > key ) { <nl> maybe_object = LoadIC : : Load ( object , Handle < String > : : cast ( key ) ) ; <nl> if ( maybe_object - > IsFailure ( ) ) return maybe_object ; <nl> } else if ( FLAG_use_ic & & ! object - > IsAccessCheckNeeded ( ) ) { <nl> - ASSERT ( ! object - > IsJSGlobalProxy ( ) ) ; <nl> + ASSERT ( ! object - > IsAccessCheckNeeded ( ) ) ; <nl> if ( object - > IsString ( ) & & key - > IsNumber ( ) ) { <nl> if ( state ( ) = = UNINITIALIZED ) stub = string_stub ( ) ; <nl> } else if ( object - > IsJSObject ( ) ) { <nl> static bool LookupForWrite ( Handle < JSObject > receiver , <nl> Handle < JSObject > holder = receiver ; <nl> receiver - > Lookup ( * name , lookup ) ; <nl> if ( lookup - > IsFound ( ) ) { <nl> - if ( lookup - > IsReadOnly ( ) | | ! lookup - > IsCacheable ( ) ) return false ; <nl> - <nl> - if ( lookup - > holder ( ) = = * receiver ) { <nl> - if ( lookup - > IsInterceptor ( ) & & ! HasInterceptorSetter ( * receiver ) ) { <nl> - receiver - > LocalLookupRealNamedProperty ( * name , lookup ) ; <nl> - return lookup - > IsFound ( ) & & <nl> - ! lookup - > IsReadOnly ( ) & & <nl> - lookup - > CanHoldValue ( value ) & & <nl> - lookup - > IsCacheable ( ) ; <nl> - } <nl> - return lookup - > CanHoldValue ( value ) ; <nl> + if ( lookup - > IsInterceptor ( ) & & ! HasInterceptorSetter ( lookup - > holder ( ) ) ) { <nl> + receiver - > LocalLookupRealNamedProperty ( * name , lookup ) ; <nl> + if ( ! lookup - > IsFound ( ) ) return false ; <nl> } <nl> <nl> + if ( lookup - > IsReadOnly ( ) | | ! lookup - > IsCacheable ( ) ) return false ; <nl> + if ( lookup - > holder ( ) = = * receiver ) return lookup - > CanHoldValue ( value ) ; <nl> if ( lookup - > IsPropertyCallbacks ( ) ) return true ; <nl> - / / JSGlobalProxy always goes via the runtime , so it ' s safe to cache . <nl> + / / JSGlobalProxy either stores on the global object in the prototype , or <nl> + / / goes into the runtime if access checks are needed , so this is always <nl> + / / safe . <nl> if ( receiver - > IsJSGlobalProxy ( ) ) return true ; <nl> / / Currently normal holders in the prototype chain are not supported . They <nl> / / would require a runtime positive lookup and verification that the details <nl> Handle < Code > StoreIC : : CompileHandler ( LookupResult * lookup , <nl> Handle < String > name , <nl> Handle < Object > value , <nl> InlineCacheHolderFlag cache_holder ) { <nl> - if ( object - > IsJSGlobalProxy ( ) ) return slow_stub ( ) ; <nl> + if ( object - > IsAccessCheckNeeded ( ) ) return slow_stub ( ) ; <nl> ASSERT ( cache_holder = = OWN_MAP ) ; <nl> / / This is currently guaranteed by checks in StoreIC : : Store . <nl> Handle < JSObject > receiver = Handle < JSObject > : : cast ( object ) ; <nl> Handle < Code > StoreIC : : CompileHandler ( LookupResult * lookup , <nl> } <nl> case NORMAL : <nl> if ( kind ( ) = = Code : : KEYED_STORE_IC ) break ; <nl> - if ( receiver - > IsGlobalObject ( ) ) { <nl> + if ( receiver - > IsJSGlobalProxy ( ) | | receiver - > IsGlobalObject ( ) ) { <nl> / / The stub generated for the global object picks the value directly <nl> / / from the property cell . So the property must be directly on the <nl> / / global object . <nl> - Handle < GlobalObject > global = Handle < GlobalObject > : : cast ( receiver ) ; <nl> + Handle < GlobalObject > global = receiver - > IsJSGlobalProxy ( ) <nl> + ? handle ( GlobalObject : : cast ( receiver - > GetPrototype ( ) ) ) <nl> + : Handle < GlobalObject > : : cast ( receiver ) ; <nl> Handle < PropertyCell > cell ( global - > GetPropertyCell ( lookup ) , isolate ( ) ) ; <nl> Handle < HeapType > union_type = PropertyCell : : UpdatedType ( cell , value ) ; <nl> - StoreGlobalStub stub ( union_type - > IsConstant ( ) ) ; <nl> - <nl> + StoreGlobalStub stub ( <nl> + union_type - > IsConstant ( ) , receiver - > IsJSGlobalProxy ( ) ) ; <nl> Handle < Code > code = stub . GetCodeCopyFromTemplate ( <nl> - isolate ( ) , receiver - > map ( ) , * cell ) ; <nl> + isolate ( ) , * global , * cell ) ; <nl> / / TODO ( verwaest ) : Move caching of these NORMAL stubs outside as well . <nl> HeapObject : : UpdateMapCodeCache ( receiver , name , code ) ; <nl> return code ; <nl> Handle < Code > StoreIC : : CompileHandler ( LookupResult * lookup , <nl> } <nl> case INTERCEPTOR : <nl> if ( kind ( ) = = Code : : KEYED_STORE_IC ) break ; <nl> - ASSERT ( HasInterceptorSetter ( * receiver ) ) ; <nl> + ASSERT ( HasInterceptorSetter ( * holder ) ) ; <nl> return compiler . CompileStoreInterceptor ( receiver , name ) ; <nl> case CONSTANT : <nl> break ; <nl> MaybeObject * KeyedStoreIC : : Store ( Handle < Object > object , <nl> } <nl> <nl> if ( use_ic ) { <nl> - ASSERT ( ! object - > IsJSGlobalProxy ( ) ) ; <nl> + ASSERT ( ! object - > IsAccessCheckNeeded ( ) ) ; <nl> <nl> if ( object - > IsJSObject ( ) ) { <nl> Handle < JSObject > receiver = Handle < JSObject > : : cast ( object ) ; <nl> mmm a / src / isolate . cc <nl> ppp b / src / isolate . cc <nl> static MayAccessDecision MayAccessPreCheck ( Isolate * isolate , <nl> <nl> bool Isolate : : MayNamedAccess ( JSObject * receiver , Object * key , <nl> v8 : : AccessType type ) { <nl> - ASSERT ( receiver - > IsAccessCheckNeeded ( ) ) ; <nl> + ASSERT ( receiver - > IsJSGlobalProxy ( ) | | receiver - > IsAccessCheckNeeded ( ) ) ; <nl> <nl> / / The callers of this method are not expecting a GC . <nl> DisallowHeapAllocation no_gc ; <nl> bool Isolate : : MayNamedAccess ( JSObject * receiver , Object * key , <nl> bool Isolate : : MayIndexedAccess ( JSObject * receiver , <nl> uint32_t index , <nl> v8 : : AccessType type ) { <nl> - ASSERT ( receiver - > IsAccessCheckNeeded ( ) ) ; <nl> + ASSERT ( receiver - > IsJSGlobalProxy ( ) | | receiver - > IsAccessCheckNeeded ( ) ) ; <nl> / / Check for compatibility between the security tokens in the <nl> / / current lexical context and the accessed object . <nl> ASSERT ( context ( ) ) ; <nl> mmm a / src / objects - inl . h <nl> ppp b / src / objects - inl . h <nl> bool Object : : IsJSGlobalProxy ( ) { <nl> bool result = IsHeapObject ( ) & & <nl> ( HeapObject : : cast ( this ) - > map ( ) - > instance_type ( ) = = <nl> JS_GLOBAL_PROXY_TYPE ) ; <nl> - ASSERT ( ! result | | IsAccessCheckNeeded ( ) ) ; <nl> + ASSERT ( ! result | | <nl> + HeapObject : : cast ( this ) - > map ( ) - > is_access_check_needed ( ) ) ; <nl> return result ; <nl> } <nl> <nl> bool Object : : IsUndetectableObject ( ) { <nl> <nl> <nl> bool Object : : IsAccessCheckNeeded ( ) { <nl> - return IsHeapObject ( ) <nl> - & & HeapObject : : cast ( this ) - > map ( ) - > is_access_check_needed ( ) ; <nl> + if ( ! IsHeapObject ( ) ) return false ; <nl> + if ( IsJSGlobalProxy ( ) ) { <nl> + JSGlobalProxy * proxy = JSGlobalProxy : : cast ( this ) ; <nl> + GlobalObject * global = <nl> + proxy - > GetIsolate ( ) - > context ( ) - > global_object ( ) ; <nl> + return proxy - > IsDetachedFrom ( global ) ; <nl> + } <nl> + return HeapObject : : cast ( this ) - > map ( ) - > is_access_check_needed ( ) ; <nl> } <nl> <nl> <nl> mmm a / src / objects . h <nl> ppp b / src / objects . h <nl> class JSObject : public JSReceiver { <nl> / / been modified since it was created . May give false positives . <nl> bool IsDirty ( ) ; <nl> <nl> - / / If the receiver is a JSGlobalProxy this method will return its prototype , <nl> - / / otherwise the result is the receiver itself . <nl> - inline Object * BypassGlobalProxy ( ) ; <nl> - <nl> / / Accessors for hidden properties object . <nl> / / <nl> / / Hidden properties are not local properties of the object itself . <nl> mmm a / src / runtime . cc <nl> ppp b / src / runtime . cc <nl> RUNTIME_FUNCTION ( MaybeObject * , Runtime_IsAccessAllowedForObserver ) { <nl> ASSERT ( args . length ( ) = = 3 ) ; <nl> CONVERT_ARG_HANDLE_CHECKED ( JSFunction , observer , 0 ) ; <nl> CONVERT_ARG_HANDLE_CHECKED ( JSObject , object , 1 ) ; <nl> - ASSERT ( object - > IsAccessCheckNeeded ( ) ) ; <nl> + ASSERT ( object - > map ( ) - > is_access_check_needed ( ) ) ; <nl> Handle < Object > key = args . at < Object > ( 2 ) ; <nl> SaveContext save ( isolate ) ; <nl> isolate - > set_context ( observer - > context ( ) ) ; <nl>
|
Reland " Allow ICs to be generated for own global proxy . "
|
v8/v8
|
2f9f49798a54c9a369090e14986ae0c49a77aeb4
|
2014-02-18T10:10:06Z
|
mmm a / src / init / OWNERS <nl> ppp b / src / init / OWNERS <nl> <nl> ahaas @ chromium . org <nl> bmeurer @ chromium . org <nl> - jkummerow @ chromium . org <nl> - jgruber @ chromium . org <nl> - yangguo @ chromium . org <nl> - gsathya @ chromium . org <nl> ftang @ chromium . org <nl> + gsathya @ chromium . org <nl> + ishell @ chromium . org <nl> + jgruber @ chromium . org <nl> + jkummerow @ chromium . org <nl> marja @ chromium . org <nl> mathias @ chromium . org <nl> ulan @ chromium . org <nl> + verwaest @ chromium . org <nl> + yangguo @ chromium . org <nl> <nl> # COMPONENT : Blink > JavaScript > Runtime <nl>
|
Add ishell @ and verwaest @ to src / init / OWNERS
|
v8/v8
|
8829005fd772597e6d8d0d6276a0b7393310c685
|
2019-06-06T20:55:04Z
|
mmm a / aten / src / THC / generic / THCTensorMathMagma . cu <nl> ppp b / aten / src / THC / generic / THCTensorMathMagma . cu <nl> THC_API void THCTensor_ ( syev ) ( THCState * state , THCTensor * re_ , THCTensor * rv_ , T <nl> else if ( info < 0 ) <nl> THError ( " MAGMA syev : Argument % d : illegal value " , - info ) ; <nl> } <nl> - THCTensor_ ( freeCopyTo ) ( state , input , rv_ ) ; <nl> + if ( jobzs [ 0 ] = = ' N ' ) { <nl> + / / If eigenvector is not needed , fill the result with zeros . <nl> + THCTensor_ ( zero ) ( state , rv_ ) ; <nl> + THCTensor_ ( free ) ( state , input ) ; <nl> + } else { <nl> + THCTensor_ ( freeCopyTo ) ( state , input , rv_ ) ; <nl> + } <nl> # else <nl> THError ( NoMagma ( syev ) ) ; <nl> # endif <nl> mmm a / test / test_cuda . py <nl> ppp b / test / test_cuda . py <nl> def test ( use_double = False ) : <nl> <nl> @ unittest . skipIf ( not TEST_MAGMA , " no MAGMA library detected " ) <nl> def test_symeig ( self ) : <nl> - # Small case <nl> - tensor = torch . randn ( 3 , 3 ) . cuda ( ) <nl> - tensor = torch . mm ( tensor , tensor . t ( ) ) <nl> - eigval , eigvec = torch . symeig ( tensor , eigenvectors = True ) <nl> - self . assertEqual ( tensor , torch . mm ( torch . mm ( eigvec , eigval . diag ( ) ) , eigvec . t ( ) ) ) <nl> - <nl> - # Large case <nl> - tensor = torch . randn ( 257 , 257 ) . cuda ( ) <nl> - tensor = torch . mm ( tensor , tensor . t ( ) ) <nl> - eigval , eigvec = torch . symeig ( tensor , eigenvectors = True ) <nl> - self . assertEqual ( tensor , torch . mm ( torch . mm ( eigvec , eigval . diag ( ) ) , eigvec . t ( ) ) ) <nl> + TestTorch . _test_symeig ( self , lambda t : t . cuda ( ) ) <nl> <nl> def test_arange ( self ) : <nl> for t in [ ' IntTensor ' , ' LongTensor ' , ' FloatTensor ' , ' DoubleTensor ' ] : <nl> mmm a / test / test_torch . py <nl> ppp b / test / test_torch . py <nl> def test_eig ( self ) : <nl> Xhat = torch . mm ( torch . mm ( v , torch . diag ( e . select ( 1 , 0 ) ) ) , v . t ( ) ) <nl> self . assertEqual ( X , Xhat , 1e - 8 , ' VeV \ ' wrong ' ) <nl> <nl> - @ skipIfNoLapack <nl> - @ skipIfRocm <nl> - def test_symeig ( self ) : <nl> - xval = torch . rand ( 100 , 3 ) <nl> + @ staticmethod <nl> + def _test_symeig ( self , conv_fn ) : <nl> + xval = conv_fn ( torch . rand ( 100 , 3 ) ) <nl> cov = torch . mm ( xval . t ( ) , xval ) <nl> - rese = torch . zeros ( 3 ) <nl> - resv = torch . zeros ( 3 , 3 ) <nl> + rese = conv_fn ( torch . zeros ( 3 ) ) <nl> + resv = conv_fn ( torch . zeros ( 3 , 3 ) ) <nl> <nl> # First call to symeig <nl> self . assertTrue ( resv . is_contiguous ( ) , ' resv is not contiguous ' ) <nl> def test_symeig ( self ) : <nl> ahat = torch . mm ( torch . mm ( resv , torch . diag ( rese ) ) , resv . t ( ) ) <nl> self . assertEqual ( cov , ahat , 1e - 8 , ' VeV \ ' wrong ' ) <nl> <nl> + # test eigenvectors = False <nl> + rese2 = conv_fn ( torch . zeros ( 3 ) ) <nl> + resv2 = conv_fn ( torch . randn ( 3 , 3 ) ) <nl> + expected_resv2 = conv_fn ( torch . zeros ( 3 , 3 ) ) <nl> + torch . symeig ( cov . clone ( ) , False , out = ( rese2 , resv2 ) ) <nl> + self . assertEqual ( rese , rese2 ) <nl> + self . assertEqual ( resv2 , expected_resv2 ) <nl> + <nl> # test non - contiguous <nl> - X = torch . rand ( 5 , 5 ) <nl> + X = conv_fn ( torch . rand ( 5 , 5 ) ) <nl> X = X . t ( ) * X <nl> - e = torch . zeros ( 4 , 2 ) . select ( 1 , 1 ) <nl> - v = torch . zeros ( 4 , 2 , 4 ) [ : , 1 ] <nl> + e = conv_fn ( torch . zeros ( 4 , 2 ) ) . select ( 1 , 1 ) <nl> + v = conv_fn ( torch . zeros ( 4 , 2 , 4 ) ) [ : , 1 ] <nl> self . assertFalse ( v . is_contiguous ( ) , ' V is contiguous ' ) <nl> self . assertFalse ( e . is_contiguous ( ) , ' E is contiguous ' ) <nl> torch . symeig ( X , True , out = ( e , v ) ) <nl> Xhat = torch . mm ( torch . mm ( v , torch . diag ( e ) ) , v . t ( ) ) <nl> self . assertEqual ( X , Xhat , 1e - 8 , ' VeV \ ' wrong ' ) <nl> <nl> + @ skipIfNoLapack <nl> + @ skipIfRocm <nl> + def test_symeig ( self ) : <nl> + self . _test_symeig ( self , lambda x : x ) <nl> + <nl> @ skipIfNoLapack <nl> def test_svd ( self ) : <nl> a = torch . Tensor ( ( ( 8 . 79 , 6 . 11 , - 9 . 15 , 9 . 57 , - 3 . 49 , 9 . 84 ) , <nl> mmm a / torch / _torch_docs . py <nl> ppp b / torch / _torch_docs . py <nl> def parse_kwargs ( desc ) : <nl> upper ( boolean , optional ) : controls whether to consider upper - triangular or lower - triangular region <nl> out ( tuple , optional ) : the output tuple of ( Tensor , Tensor ) <nl> <nl> + Returns : <nl> + ( Tensor , Tensor ) : A tuple containing <nl> + <nl> + - * * e * * ( * Tensor * ) : Shape : math : ` ( m ) ` . Each element is an eigenvalue of ` ` input ` ` , <nl> + The eigenvalues are in ascending order . <nl> + - * * V * * ( * Tensor * ) : Shape : math : ` ( m \ times m ) ` . <nl> + If ` ` eigenvectors = False ` ` , it ' s a tensor filled with zeros . <nl> + Otherwise , this tensor contains the orthonormal eigenvectors of the ` ` input ` ` . <nl> + <nl> Examples : : <nl> <nl> <nl>
|
Fill eigenvector with zeros if not required ( )
|
pytorch/pytorch
|
a9469c9c8ab046a7961c1c357d84f60063507c4b
|
2018-08-29T17:55:22Z
|
mmm a / brightray / brightray . gyp <nl> ppp b / brightray / brightray . gyp <nl> <nl> ' - Wl , - - no - whole - archive ' , <nl> ] , <nl> } <nl> - } , { <nl> + } , { # ( Release build on Linux ) <nl> ' link_settings ' : { <nl> ' libraries ' : [ ' < @ ( libchromiumcontent_libraries ) ' ] <nl> } , <nl> - } ] , <nl> + } ] , # ( Normal builds ) <nl> + # Linux specific link settings . <nl> [ ' OS = = " linux " ' , { <nl> ' link_settings ' : { <nl> ' ldflags ' : [ <nl> <nl> } , <nl> } ] , <nl> ] , <nl> - } ] , <nl> + } ] , # OS = = " linux " <nl> [ ' OS = = " mac " ' , { <nl> ' link_settings ' : { <nl> ' libraries ' : [ <nl> ' $ ( SDKROOT ) / System / Library / Frameworks / AppKit . framework ' , <nl> ] , <nl> } , <nl> - } ] , <nl> - [ ' OS = = " mac " and libchromiumcontent_component = = 0 ' , { <nl> - ' link_settings ' : { <nl> - ' libraries ' : [ <nl> - # ui_base . gypi : <nl> - ' $ ( SDKROOT ) / System / Library / Frameworks / Accelerate . framework ' , <nl> - # net . gypi : <nl> - ' $ ( SDKROOT ) / System / Library / Frameworks / Foundation . framework ' , <nl> - ' $ ( SDKROOT ) / System / Library / Frameworks / Security . framework ' , <nl> - ' $ ( SDKROOT ) / System / Library / Frameworks / SystemConfiguration . framework ' , <nl> - ' $ ( SDKROOT ) / usr / lib / libresolv . dylib ' , <nl> - # media . gyp : <nl> - ' $ ( SDKROOT ) / System / Library / Frameworks / AudioToolbox . framework ' , <nl> - ' $ ( SDKROOT ) / System / Library / Frameworks / AudioUnit . framework ' , <nl> - ' $ ( SDKROOT ) / System / Library / Frameworks / CoreAudio . framework ' , <nl> - ' $ ( SDKROOT ) / System / Library / Frameworks / CoreMIDI . framework ' , <nl> - ' $ ( SDKROOT ) / System / Library / Frameworks / CoreVideo . framework ' , <nl> - ' $ ( SDKROOT ) / System / Library / Frameworks / OpenGL . framework ' , <nl> - ' $ ( SDKROOT ) / System / Library / Frameworks / QTKit . framework ' , <nl> - # surface . gyp : <nl> - ' $ ( SDKROOT ) / System / Library / Frameworks / IOSurface . framework ' , <nl> - # content_common . gypi : <nl> - ' $ ( SDKROOT ) / System / Library / Frameworks / QuartzCore . framework ' , <nl> - # base . gyp : <nl> - ' $ ( SDKROOT ) / System / Library / Frameworks / ApplicationServices . framework ' , <nl> - ' $ ( SDKROOT ) / System / Library / Frameworks / Carbon . framework ' , <nl> - ' $ ( SDKROOT ) / System / Library / Frameworks / CoreFoundation . framework ' , <nl> - ' $ ( SDKROOT ) / System / Library / Frameworks / IOKit . framework ' , <nl> - # content_browser . gypi : <nl> - ' $ ( SDKROOT ) / usr / lib / libbsm . dylib ' , <nl> - ] , <nl> - } , <nl> - } ] , <nl> - [ ' OS = = " win " and libchromiumcontent_component = = 1 ' , { <nl> - ' link_settings ' : { <nl> - ' libraries ' : [ <nl> - ' < ( libchromiumcontent_dir ) / base_static . lib ' , <nl> - ' < ( libchromiumcontent_dir ) / sandbox . lib ' , <nl> - ] , <nl> - } , <nl> - } ] , <nl> - [ ' OS = = " win " and libchromiumcontent_component = = 0 ' , { <nl> - ' link_settings ' : { <nl> - ' libraries ' : [ <nl> - ' < ( libchromiumcontent_dir ) / ffmpegsumo . lib ' , <nl> - ' < ( libchromiumcontent_dir ) / libyuv . lib ' , <nl> - # content_browser . gypi : <nl> - ' - lsensorsapi . lib ' , <nl> - ' - lportabledeviceguids . lib ' , <nl> - # content_common . gypi : <nl> - ' - ld3d9 . lib ' , <nl> - ' - ldxva2 . lib ' , <nl> - ' - lstrmiids . lib ' , <nl> - ' - lmf . lib ' , <nl> - ' - lmfplat . lib ' , <nl> - ' - lmfuuid . lib ' , <nl> - # media . gyp : <nl> - ' - lmfreadwrite . lib ' , <nl> - ] , <nl> - ' msvs_settings ' : { <nl> - ' VCLinkerTool ' : { <nl> - ' AdditionalDependencies ' : [ <nl> - ' advapi32 . lib ' , <nl> - ' dbghelp . lib ' , <nl> - ' dwmapi . lib ' , <nl> - ' gdi32 . lib ' , <nl> - ' netapi32 . lib ' , <nl> - ' oleacc . lib ' , <nl> - ' powrprof . lib ' , <nl> - ' user32 . lib ' , <nl> - ' usp10 . lib ' , <nl> - ' version . lib ' , <nl> - ' winspool . lib ' , <nl> + ' conditions ' : [ <nl> + # Link with system frameworks . <nl> + [ ' libchromiumcontent_component = = 0 ' , { <nl> + ' link_settings ' : { <nl> + ' libraries ' : [ <nl> + # ui_base . gypi : <nl> + ' $ ( SDKROOT ) / System / Library / Frameworks / Accelerate . framework ' , <nl> + # net . gypi : <nl> + ' $ ( SDKROOT ) / System / Library / Frameworks / Foundation . framework ' , <nl> + ' $ ( SDKROOT ) / System / Library / Frameworks / Security . framework ' , <nl> + ' $ ( SDKROOT ) / System / Library / Frameworks / SystemConfiguration . framework ' , <nl> + ' $ ( SDKROOT ) / usr / lib / libresolv . dylib ' , <nl> + # media . gyp : <nl> + ' $ ( SDKROOT ) / System / Library / Frameworks / AudioToolbox . framework ' , <nl> + ' $ ( SDKROOT ) / System / Library / Frameworks / AudioUnit . framework ' , <nl> + ' $ ( SDKROOT ) / System / Library / Frameworks / CoreAudio . framework ' , <nl> + ' $ ( SDKROOT ) / System / Library / Frameworks / CoreMIDI . framework ' , <nl> + ' $ ( SDKROOT ) / System / Library / Frameworks / CoreVideo . framework ' , <nl> + ' $ ( SDKROOT ) / System / Library / Frameworks / OpenGL . framework ' , <nl> + ' $ ( SDKROOT ) / System / Library / Frameworks / QTKit . framework ' , <nl> + # surface . gyp : <nl> + ' $ ( SDKROOT ) / System / Library / Frameworks / IOSurface . framework ' , <nl> + # content_common . gypi : <nl> + ' $ ( SDKROOT ) / System / Library / Frameworks / QuartzCore . framework ' , <nl> + # base . gyp : <nl> + ' $ ( SDKROOT ) / System / Library / Frameworks / ApplicationServices . framework ' , <nl> + ' $ ( SDKROOT ) / System / Library / Frameworks / Carbon . framework ' , <nl> + ' $ ( SDKROOT ) / System / Library / Frameworks / CoreFoundation . framework ' , <nl> + ' $ ( SDKROOT ) / System / Library / Frameworks / IOKit . framework ' , <nl> + # content_browser . gypi : <nl> + ' $ ( SDKROOT ) / usr / lib / libbsm . dylib ' , <nl> ] , <nl> - ' DelayLoadDLLs ' : [ <nl> - ' ffmpegsumo . dll ' , <nl> + } , <nl> + } ] , <nl> + ] <nl> + } ] , # OS = = " mac " <nl> + [ ' OS = = " win " ' , { <nl> + ' conditions ' : [ <nl> + [ ' libchromiumcontent_component ' , { <nl> + # sandbox and base_static are always linked statically . <nl> + ' link_settings ' : { <nl> + ' libraries ' : [ <nl> + ' < ( libchromiumcontent_dir ) / base_static . lib ' , <nl> + ' < ( libchromiumcontent_dir ) / sandbox . lib ' , <nl> + ] , <nl> + } , <nl> + } , { <nl> + # Link with system libraries . <nl> + ' link_settings ' : { <nl> + ' libraries ' : [ <nl> + # ffmpegsumo . lib is required for linking with ffmpegsumo . dll <nl> + ' < ( libchromiumcontent_dir ) / ffmpegsumo . lib ' , <nl> + # content_browser . gypi : <nl> + ' - lsensorsapi . lib ' , <nl> + ' - lportabledeviceguids . lib ' , <nl> # content_common . gypi : <nl> - ' d3d9 . dll ' , <nl> - ' dxva2 . dll ' , <nl> - ' mf . dll ' , <nl> - ' mfplat . dll ' , <nl> + ' - ld3d9 . lib ' , <nl> + ' - ldxva2 . lib ' , <nl> + ' - lstrmiids . lib ' , <nl> + ' - lmf . lib ' , <nl> + ' - lmfplat . lib ' , <nl> + ' - lmfuuid . lib ' , <nl> + # media . gyp : <nl> + ' - lmfreadwrite . lib ' , <nl> ] , <nl> + ' msvs_settings ' : { <nl> + ' VCLinkerTool ' : { <nl> + ' AdditionalDependencies ' : [ <nl> + ' advapi32 . lib ' , <nl> + ' dbghelp . lib ' , <nl> + ' dwmapi . lib ' , <nl> + ' gdi32 . lib ' , <nl> + ' netapi32 . lib ' , <nl> + ' oleacc . lib ' , <nl> + ' powrprof . lib ' , <nl> + ' user32 . lib ' , <nl> + ' usp10 . lib ' , <nl> + ' version . lib ' , <nl> + ' winspool . lib ' , <nl> + ] , <nl> + ' DelayLoadDLLs ' : [ <nl> + ' ffmpegsumo . dll ' , <nl> + # content_common . gypi : <nl> + ' d3d9 . dll ' , <nl> + ' dxva2 . dll ' , <nl> + ' mf . dll ' , <nl> + ' mfplat . dll ' , <nl> + ] , <nl> + } , <nl> + } , <nl> } , <nl> - } , <nl> - } , <nl> - } ] , <nl> + } ] , # libchromiumcontent_component <nl> + ] , <nl> + } ] , # OS = = " win " <nl> ] , <nl> } , <nl> ] , <nl>
|
Cleanup the brightray . gyp file
|
electron/electron
|
decf522f48e4d091eea8eeff4fe8e6f9f3c5a36a
|
2015-04-11T05:35:22Z
|
mmm a / Marlin / temperature . h <nl> ppp b / Marlin / temperature . h <nl> class Temperature { <nl> # endif <nl> } <nl> <nl> + # if ENABLED ( BABYSTEPPING ) <nl> + <nl> + FORCE_INLINE void babystep_axis ( AxisEnum axis , int distance ) { <nl> + # if ENABLED ( COREXY ) | | ENABLED ( COREXZ ) <nl> + # if ENABLED ( BABYSTEP_XY ) <nl> + switch ( axis ) { <nl> + case X_AXIS : / / X on CoreXY and CoreXZ <nl> + babystepsTodo [ A_AXIS ] + = distance * 2 ; <nl> + babystepsTodo [ CORE_AXIS_2 ] + = distance * 2 ; <nl> + break ; <nl> + case CORE_AXIS_2 : / / Y on CoreXY , Z on CoreXZ <nl> + babystepsTodo [ A_AXIS ] + = distance * 2 ; <nl> + babystepsTodo [ CORE_AXIS_2 ] - = distance * 2 ; <nl> + break ; <nl> + case CORE_AXIS_3 : / / Z on CoreXY , Y on CoreXZ <nl> + babystepsTodo [ CORE_AXIS_3 ] + = distance ; <nl> + break ; <nl> + } <nl> + # elif ENABLED ( COREXZ ) <nl> + babystepsTodo [ A_AXIS ] + = distance * 2 ; <nl> + babystepsTodo [ C_AXIS ] - = distance * 2 ; <nl> + # else <nl> + babystepsTodo [ Z_AXIS ] + = distance ; <nl> + # endif <nl> + # else <nl> + babystepsTodo [ axis ] + = distance ; <nl> + # endif <nl> + } <nl> + <nl> + # endif / / BABYSTEPPING <nl> + <nl> private : <nl> <nl> void set_current_temp_raw ( ) ; <nl> mmm a / Marlin / ultralcd . cpp <nl> ppp b / Marlin / ultralcd . cpp <nl> void lcd_set_home_offsets ( ) { <nl> int distance = ( int32_t ) encoderPosition * BABYSTEP_MULTIPLICATOR ; <nl> encoderPosition = 0 ; <nl> lcdDrawUpdate = LCDVIEW_REDRAW_NOW ; <nl> - # if ENABLED ( COREXY ) | | ENABLED ( COREXZ ) <nl> - # if ENABLED ( BABYSTEP_XY ) <nl> - switch ( axis ) { <nl> - case X_AXIS : / / X on CoreXY and CoreXZ <nl> - thermalManager . babystepsTodo [ A_AXIS ] + = distance * 2 ; <nl> - thermalManager . babystepsTodo [ CORE_AXIS_2 ] + = distance * 2 ; <nl> - break ; <nl> - case CORE_AXIS_2 : / / Y on CoreXY , Z on CoreXZ <nl> - thermalManager . babystepsTodo [ A_AXIS ] + = distance * 2 ; <nl> - thermalManager . babystepsTodo [ CORE_AXIS_2 ] - = distance * 2 ; <nl> - break ; <nl> - case CORE_AXIS_3 : / / Z on CoreXY , Y on CoreXZ <nl> - thermalManager . babystepsTodo [ CORE_AXIS_3 ] + = distance ; <nl> - break ; <nl> - } <nl> - # elif ENABLED ( COREXZ ) <nl> - thermalManager . babystepsTodo [ A_AXIS ] + = distance * 2 ; <nl> - thermalManager . babystepsTodo [ C_AXIS ] - = distance * 2 ; <nl> - # else <nl> - thermalManager . babystepsTodo [ Z_AXIS ] + = distance ; <nl> - # endif <nl> - # else <nl> - thermalManager . babystepsTodo [ axis ] + = distance ; <nl> - # endif <nl> - <nl> + thermalManager . babystep_axis ( axis , distance ) ; <nl> babysteps_done + = distance ; <nl> } <nl> if ( lcdDrawUpdate ) lcd_implementation_drawedit ( msg , itostr3sign ( babysteps_done ) ) ; <nl>
|
Localize babystepping in the Temperature class
|
MarlinFirmware/Marlin
|
b65ea98d6bf407c2ff4d9ecfdef45888e6686406
|
2016-05-05T22:00:31Z
|
mmm a / tensorflow / compiler / mlir / lite / tests / legalize - tf - while . mlir <nl> ppp b / tensorflow / compiler / mlir / lite / tests / legalize - tf - while . mlir <nl> func @ while_cond_10_frozen0 ( % arg0 : tensor < * xi32 > , % arg1 : tensor < * xi32 > , % arg2 : t <nl> / / INLINE : ^ bb0 ( [ [ ARGS ] ] ) : <nl> / / INLINE : % cst_2 = constant <nl> / / INLINE : yield <nl> - / / INLINE : while_body <nl> - / / INLINE : while_cond <nl> + / / INLINE - NOT : while_body <nl> + / / INLINE - NOT : while_cond <nl> <nl> / / CANON - LABEL : func @ while_main <nl> / / CANON - SAME : ( [ [ VAL_0 : % . * ] ] : tensor < ? x256x256xf32 > ) <nl> mmm a / tensorflow / compiler / mlir / lite / tests / mlir2exec / tfl_while_op . mlir <nl> ppp b / tensorflow / compiler / mlir / lite / tests / mlir2exec / tfl_while_op . mlir <nl> <nl> / / CHECK - NEXT : Tensor 2 val kTfLiteFloat32 kTfLiteMmapRo 4 bytes <nl> / / CHECK - NEXT : Tensor 3 tfl . while kTfLiteInt32 kTfLiteArenaRw 4 bytes <nl> / / CHECK - NEXT : Tensor 4 result kTfLiteFloat32 kTfLiteArenaRw 4 bytes <nl> - / / CHECK - NEXT : Tensor 5 tfl . while : 2 kTfLiteInt32 kTfLiteArenaRw 4 bytes <nl> <nl> / / Verify while was not folded away : <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> mmm a / tensorflow / compiler / mlir / lite / tests / tfl_while_outline . mlir <nl> ppp b / tensorflow / compiler / mlir / lite / tests / tfl_while_outline . mlir <nl> func @ while ( ) - > tensor < 1xf32 > <nl> % 0 : 2 = " tfl . while " ( % cst0 , % cst1 ) ( { <nl> ^ bb0 ( % arg2 : tensor < * xi32 > , % arg3 : tensor < * xf32 > ) : <nl> / / CHECK : call @ WhileOp_cond <nl> - / / CHECK - SAME : ( tensor < * xi32 > , tensor < * xf32 > , tensor < i32 > ) <nl> + / / CHECK - SAME : ( tensor < * xi32 > , tensor < * xf32 > ) <nl> % cst_0 = constant dense < 0 > : tensor < i32 > <nl> % 1 = " tfl . greater " ( % arg2 , % cst_0 ) : ( tensor < * xi32 > , tensor < i32 > ) - > tensor < i1 > <nl> " tfl . yield " ( % 1 ) : ( tensor < i1 > ) - > ( ) <nl> } , { <nl> ^ bb0 ( % arg2 : tensor < * xi32 > , % arg3 : tensor < * xf32 > ) : <nl> / / CHECK : call @ WhileOp_body <nl> - / / CHECK - SAME : ( tensor < * xi32 > , tensor < * xf32 > , tensor < i32 > ) <nl> + / / CHECK - SAME : ( tensor < * xi32 > , tensor < * xf32 > ) <nl> % 1 = " tfl . sub " ( % arg2 , % cst ) { fused_activation_function = " NONE " } : <nl> ( tensor < * xi32 > , tensor < i32 > ) - > tensor < * xi32 > <nl> % 2 = tfl . add % arg3 , % arg3 { fused_activation_function = " NONE " } : tensor < * xf32 > <nl> func @ while ( ) - > tensor < 1xf32 > <nl> <nl> / / CHECK - LABEL : func @ while2 <nl> / / Verify that while body / / cond with implicitly captured values result in changing while operands / results . <nl> - func @ while2 ( ) - > tensor < 1xf32 > attributes { tf . entry_function = { outputs = " result " } } { <nl> - % cst = constant dense < 1 > : tensor < i32 > <nl> + func @ while2 ( % cst : tensor < i32 > ) - > tensor < 1xf32 > attributes { tf . entry_function = { outputs = " result " } } { <nl> % cst_0 = constant dense < 5 > : tensor < i32 > <nl> % cst_1 = constant dense < 3 . 000000e + 00 > : tensor < 1xf32 > <nl> / / Verifies 3 operands post outlining . <nl> func @ rnn ( % arg0 : tensor < 4x4x3xf32 > { tf . device = " / device : CPU : 0 " } ) - > tensor < 4x ? x <nl> / / CHECK : tfl . while <nl> / / CHECK : tfl . yield <nl> / / CHECK - SAME : ( tensor < i1 > ) - > ( ) <nl> - / / CHECK : [ [ VAL_41 : % . * ] ] : 18 = <nl> + / / CHECK : [ [ VAL_30 : % . * ] ] : 7 = <nl> / / CHECK : call @ tfl . while_body <nl> / / CHECK : tfl . yield <nl> - / / CHECK - SAME : ( tensor < i32 > , tensor < i32 > , tensor < * xf32 > , tensor < 4x2xf32 > , tensor < 4x2xf32 > , tensor < * xf32 > , tensor < i32 > , tensor < i32 > , tensor < 4x4x3xf32 > , tensor < 8x5xf32 > , tensor < 8xf32 > , tensor < f32 > , tensor < 1xi32 > , tensor < i32 > , tensor < 1xi32 > , tensor < 1xi32 > , tensor < i32 > , tensor < 1xi32 > ) - > ( ) <nl> + / / CHECK - SAME : ( tensor < i32 > , tensor < i32 > , tensor < * xf32 > , tensor < 4x2xf32 > , tensor < 4x2xf32 > , tensor < * xf32 > , tensor < 4x4x3xf32 > ) - > ( ) <nl> <nl> / / CHECK - LABEL : func @ tfl . while_cond ( <nl> - / / CHECK - SAME : [ [ VAL_56 : % . * ] ] : tensor < i32 > , [ [ VAL_57 : % . * ] ] : tensor < i32 > , [ [ VAL_58 : % . * ] ] : tensor < * xf32 > , [ [ VAL_59 : % . * ] ] : tensor < 4x2xf32 > , [ [ VAL_60 : % . * ] ] : tensor < 4x2xf32 > , [ [ VAL_61 : % . * ] ] : tensor < * xf32 > , [ [ VAL_62 : % . * ] ] : tensor < i32 > , [ [ VAL_63 : % . * ] ] : tensor < i32 > , [ [ VAL_64 : % . * ] ] : tensor < 4x4x3xf32 > , [ [ VAL_65 : % . * ] ] : tensor < 8x5xf32 > , [ [ VAL_66 : % . * ] ] : tensor < 8xf32 > , [ [ VAL_67 : % . * ] ] : tensor < f32 > , [ [ VAL_68 : % . * ] ] : tensor < 1xi32 > , [ [ VAL_69 : % . * ] ] : tensor < i32 > , [ [ VAL_70 : % . * ] ] : tensor < 1xi32 > , [ [ VAL_71 : % . * ] ] : tensor < 1xi32 > , [ [ VAL_72 : % . * ] ] : tensor < i32 > , [ [ VAL_73 : % . * ] ] : tensor < 1xi32 > ) - > tensor < i1 > attributes { sym_visibility = " private " } { <nl> + / / CHECK - SAME : [ [ VAL_35 : % . * ] ] : tensor < i32 > , [ [ VAL_36 : % . * ] ] : tensor < i32 > , [ [ VAL_37 : % . * ] ] : tensor < * xf32 > , [ [ VAL_38 : % . * ] ] : tensor < 4x2xf32 > , [ [ VAL_39 : % . * ] ] : tensor < 4x2xf32 > , [ [ VAL_40 : % . * ] ] : tensor < * xf32 > , [ [ VAL_41 : % . * ] ] : tensor < 4x4x3xf32 > ) - > tensor < i1 > attributes { sym_visibility = " private " } { <nl> / / CHECK : return <nl> / / CHECK - SAME : tensor < i1 > <nl> / / CHECK : } <nl> <nl> / / CHECK - LABEL : func @ tfl . while_body ( <nl> - / / CHECK - SAME : [ [ VAL_77 : % . * ] ] : tensor < i32 > , [ [ VAL_78 : % . * ] ] : tensor < i32 > , [ [ VAL_79 : % . * ] ] : tensor < * xf32 > , [ [ VAL_80 : % . * ] ] : tensor < 4x2xf32 > , [ [ VAL_81 : % . * ] ] : tensor < 4x2xf32 > , [ [ VAL_82 : % . * ] ] : tensor < * xf32 > , [ [ VAL_83 : % . * ] ] : tensor < i32 > , [ [ VAL_84 : % . * ] ] : tensor < i32 > , [ [ VAL_85 : % . * ] ] : tensor < 4x4x3xf32 > , [ [ VAL_86 : % . * ] ] : tensor < 8x5xf32 > , [ [ VAL_87 : % . * ] ] : tensor < 8xf32 > , [ [ VAL_88 : % . * ] ] : tensor < f32 > , [ [ VAL_89 : % . * ] ] : tensor < 1xi32 > , [ [ VAL_90 : % . * ] ] : tensor < i32 > , [ [ VAL_91 : % . * ] ] : tensor < 1xi32 > , [ [ VAL_92 : % . * ] ] : tensor < 1xi32 > , [ [ VAL_93 : % . * ] ] : tensor < i32 > , [ [ VAL_94 : % . * ] ] : tensor < 1xi32 > ) - > ( tensor < i32 > , tensor < i32 > , tensor < * xf32 > , tensor < 4x2xf32 > , tensor < 4x2xf32 > , tensor < * xf32 > , tensor < i32 > , tensor < i32 > , tensor < 4x4x3xf32 > , tensor < 8x5xf32 > , tensor < 8xf32 > , tensor < f32 > , tensor < 1xi32 > , tensor < i32 > , tensor < 1xi32 > , tensor < 1xi32 > , tensor < i32 > , tensor < 1xi32 > ) attributes { sym_visibility = " private " } { <nl> - / / CHECK : [ [ VAL_123 : % . * ] ] = " tfl . cast " <nl> + / / CHECK - SAME : [ [ VAL_46 : % . * ] ] : tensor < i32 > , [ [ VAL_47 : % . * ] ] : tensor < i32 > , [ [ VAL_48 : % . * ] ] : tensor < * xf32 > , [ [ VAL_49 : % . * ] ] : tensor < 4x2xf32 > , [ [ VAL_50 : % . * ] ] : tensor < 4x2xf32 > , [ [ VAL_51 : % . * ] ] : tensor < * xf32 > , [ [ VAL_52 : % . * ] ] : tensor < 4x4x3xf32 > ) - > ( tensor < i32 > , tensor < i32 > , tensor < * xf32 > , tensor < 4x2xf32 > , tensor < 4x2xf32 > , tensor < * xf32 > , tensor < 4x4x3xf32 > ) attributes { sym_visibility = " private " } { <nl> + / / CHECK : [ [ VAL_91 : % . * ] ] = " tfl . cast " <nl> / / CHECK : return <nl> - / / CHECK - SAME : [ [ VAL_123 ] ] , [ [ VAL_83 ] ] , [ [ VAL_84 ] ] , [ [ VAL_85 ] ] , [ [ VAL_86 ] ] , [ [ VAL_87 ] ] , [ [ VAL_88 ] ] , [ [ VAL_89 ] ] , [ [ VAL_90 ] ] , [ [ VAL_91 ] ] , [ [ VAL_92 ] ] , [ [ VAL_93 ] ] , [ [ VAL_94 ] ] : tensor < i32 > , tensor < i32 > , tensor < * xf32 > , tensor < 4x2xf32 > , tensor < 4x2xf32 > , tensor < * xf32 > , tensor < i32 > , tensor < i32 > , tensor < 4x4x3xf32 > , tensor < 8x5xf32 > , tensor < 8xf32 > , tensor < f32 > , tensor < 1xi32 > , tensor < i32 > , tensor < 1xi32 > , tensor < 1xi32 > , tensor < i32 > , tensor < 1xi32 > <nl> + / / CHECK - SAME : [ [ VAL_91 ] ] , [ [ VAL_52 ] ] : tensor < i32 > , tensor < i32 > , tensor < * xf32 > , tensor < 4x2xf32 > , tensor < 4x2xf32 > , tensor < * xf32 > , tensor < 4x4x3xf32 > <nl> / / CHECK : } <nl> / / CHECK : } <nl> - <nl> mmm a / tensorflow / compiler / mlir / lite / tf_tfl_passes . cc <nl> ppp b / tensorflow / compiler / mlir / lite / tf_tfl_passes . cc <nl> void AddTFToTFLConversionPasses ( const mlir : : TFL : : PassConfig & pass_config , <nl> / / that work on TF dialect and before inliner so that the function calls in <nl> / / body and cond are inlined for optimization . <nl> if ( pass_config . legalize_tf_while ) { <nl> - pass_manager - > addNestedPass < mlir : : FuncOp > ( <nl> - mlir : : TFL : : CreateLegalizeTFWhilePass ( ) ) ; <nl> + pass_manager - > addPass ( mlir : : TFL : : CreateLegalizeTFWhilePass ( ) ) ; <nl> } <nl> <nl> / / Add function inlining pass . Both TF and TFLite dialects are opted into <nl> mmm a / tensorflow / compiler / mlir / lite / transforms / legalize_tf_while . cc <nl> ppp b / tensorflow / compiler / mlir / lite / transforms / legalize_tf_while . cc <nl> namespace { <nl> <nl> / / Legalize TF While to TFL While with calls to the original functions from the <nl> / / cond and body regions . <nl> - struct LegalizeWhile : public FunctionPass < LegalizeWhile > { <nl> - void runOnFunction ( ) override { <nl> - auto func = getFunction ( ) ; <nl> - / / Convert all TF WhileOps inside the function body to TFL While ops . <nl> - func . getBody ( ) . walk ( [ ] ( TF : : WhileOp while_op ) { <nl> - Operation * op = while_op . getOperation ( ) ; <nl> - / / Create new TFL While op that will be used to replace TF While op . <nl> - auto new_op = OpBuilder ( op ) . create < TFL : : WhileOp > ( <nl> - op - > getLoc ( ) , op - > getResultTypes ( ) , op - > getOperands ( ) , <nl> - while_op . is_stateless ( ) ) ; <nl> - / / Insert call to the given function into the ' region ' . <nl> - auto create_region_with_call = [ & while_op ] ( FlatSymbolRefAttr symbol , <nl> - Region & region ) { <nl> - OpBuilder builder ( region ) ; <nl> - auto block = builder . createBlock ( & region ) ; <nl> - SmallVector < Value , 4 > new_operands ; <nl> - auto func = while_op . getParentOfType < ModuleOp > ( ) . lookupSymbol < FuncOp > ( <nl> - symbol . getValue ( ) ) ; <nl> - for ( Type t : func . getType ( ) . getInputs ( ) ) <nl> - new_operands . push_back ( block - > addArgument ( t ) ) ; <nl> - auto call = <nl> - builder . create < CallOp > ( while_op . getLoc ( ) , symbol , <nl> - func . getType ( ) . getResults ( ) , new_operands ) ; <nl> - builder . create < YieldOp > ( while_op . getLoc ( ) , call . getResults ( ) ) ; <nl> - } ; <nl> - create_region_with_call ( while_op . condAttr ( ) , new_op . cond ( ) ) ; <nl> - create_region_with_call ( while_op . bodyAttr ( ) , new_op . body ( ) ) ; <nl> + struct LegalizeWhile : public ModulePass < LegalizeWhile > { <nl> + void RunOnFunction ( FuncOp func ) ; <nl> <nl> - op - > replaceAllUsesWith ( new_op . getResults ( ) ) ; <nl> - op - > erase ( ) ; <nl> - } ) ; <nl> + void runOnModule ( ) override { <nl> + for ( auto op : getModule ( ) . getOps < FuncOp > ( ) ) RunOnFunction ( op ) ; <nl> } <nl> } ; <nl> <nl> } / / namespace <nl> <nl> + void RunOnWhile ( TF : : WhileOp while_op ) { <nl> + Operation * op = while_op . getOperation ( ) ; <nl> + / / Create new TFL While op that will be used to replace TF While op . <nl> + auto new_op = OpBuilder ( op ) . create < TFL : : WhileOp > ( <nl> + op - > getLoc ( ) , op - > getResultTypes ( ) , op - > getOperands ( ) , <nl> + while_op . is_stateless ( ) ) ; <nl> + / / Insert call to the given function into the ' region ' . <nl> + auto create_region_with_call = [ & while_op ] ( FlatSymbolRefAttr symbol , <nl> + Region & region ) { <nl> + OpBuilder builder ( region ) ; <nl> + auto block = builder . createBlock ( & region ) ; <nl> + SmallVector < Value , 4 > new_operands ; <nl> + auto func = while_op . getParentOfType < ModuleOp > ( ) . lookupSymbol < FuncOp > ( <nl> + symbol . getValue ( ) ) ; <nl> + for ( Type t : func . getType ( ) . getInputs ( ) ) <nl> + new_operands . push_back ( block - > addArgument ( t ) ) ; <nl> + auto call = builder . create < CallOp > ( <nl> + while_op . getLoc ( ) , symbol , func . getType ( ) . getResults ( ) , new_operands ) ; <nl> + builder . create < YieldOp > ( while_op . getLoc ( ) , call . getResults ( ) ) ; <nl> + / / Mark old function as private so that it can be DCE ' d if not called . <nl> + func . setVisibility ( SymbolTable : : Visibility : : Private ) ; <nl> + } ; <nl> + create_region_with_call ( while_op . condAttr ( ) , new_op . cond ( ) ) ; <nl> + create_region_with_call ( while_op . bodyAttr ( ) , new_op . body ( ) ) ; <nl> + <nl> + op - > replaceAllUsesWith ( new_op . getResults ( ) ) ; <nl> + op - > erase ( ) ; <nl> + } <nl> + <nl> + void LegalizeWhile : : RunOnFunction ( FuncOp func ) { <nl> + / / Convert all TF WhileOps inside the function body to TFL While ops . <nl> + func . getBody ( ) . walk ( [ ] ( TF : : WhileOp while_op ) { RunOnWhile ( while_op ) ; } ) ; <nl> + } <nl> + <nl> / / Creates an instance of the TensorFlow While to TFLite While pass . <nl> - std : : unique_ptr < OpPassBase < FuncOp > > CreateLegalizeTFWhilePass ( ) { <nl> + std : : unique_ptr < OpPassBase < ModuleOp > > CreateLegalizeTFWhilePass ( ) { <nl> return std : : make_unique < LegalizeWhile > ( ) ; <nl> } <nl> <nl> mmm a / tensorflow / compiler / mlir / lite / transforms / passes . h <nl> ppp b / tensorflow / compiler / mlir / lite / transforms / passes . h <nl> std : : unique_ptr < OpPassBase < FuncOp > > CreateDefaultQuantParamsPass ( <nl> std : : unique_ptr < OpPassBase < FuncOp > > CreateDenseToSparsePass ( ) ; <nl> <nl> / / Creates function pass to legalize TF While to TFL While . <nl> - std : : unique_ptr < OpPassBase < FuncOp > > CreateLegalizeTFWhilePass ( ) ; <nl> + std : : unique_ptr < OpPassBase < ModuleOp > > CreateLegalizeTFWhilePass ( ) ; <nl> <nl> / / Creates an instance of the TensorFlow Lite dialect WhileOp outline pass . <nl> std : : unique_ptr < OpPassBase < ModuleOp > > CreateWhileOutlinePass ( ) ; <nl> mmm a / tensorflow / compiler / mlir / lite / transforms / while_loop_outline . cc <nl> ppp b / tensorflow / compiler / mlir / lite / transforms / while_loop_outline . cc <nl> limitations under the License . <nl> # include " mlir / IR / Identifier . h " / / from @ llvm - project <nl> # include " mlir / IR / Location . h " / / from @ llvm - project <nl> # include " mlir / IR / MLIRContext . h " / / from @ llvm - project <nl> + # include " mlir / IR / Matchers . h " / / from @ llvm - project <nl> # include " mlir / IR / StandardTypes . h " / / from @ llvm - project <nl> # include " mlir / IR / SymbolTable . h " / / from @ llvm - project <nl> # include " mlir / Pass / Pass . h " / / from @ llvm - project <nl> void WhileOutlinePass : : OutlineWhile ( WhileOp while_op ) { <nl> llvm : : SmallVector < Region * , 2 > regions { & while_op . cond ( ) , & while_op . body ( ) } ; <nl> for ( auto it : llvm : : enumerate ( regions ) ) { <nl> llvm : : SetVector < Value > region_extern_values ; <nl> - Value const_none = nullptr ; <nl> getUsedValuesDefinedAbove ( * it . value ( ) , region_extern_values ) ; <nl> <nl> - / / Sink down none type constants into the functions . <nl> + / / Sink down constants into the functions . <nl> for ( auto extern_value : region_extern_values ) { <nl> - if ( ! extern_value . getType ( ) . isa < NoneType > ( ) ) { <nl> + if ( ! matchPattern ( extern_value , m_Constant ( ) ) ) { <nl> extern_values . insert ( extern_value ) ; <nl> continue ; <nl> } <nl> - if ( ! const_none ) { <nl> - / / Add constant at start of region . <nl> - auto const_builder = <nl> - OpBuilder ( & it . value ( ) - > front ( ) , it . value ( ) - > front ( ) . begin ( ) ) ; <nl> - const_none = const_builder . create < ConstantOp > ( <nl> - while_op . getLoc ( ) , extern_value . getType ( ) , <nl> - const_builder . getUnitAttr ( ) ) ; <nl> - } <nl> - replaceAllUsesInRegionWith ( extern_value , const_none , * it . value ( ) ) ; <nl> + / / Add constant at start of region . <nl> + auto const_builder = <nl> + OpBuilder ( & it . value ( ) - > front ( ) , it . value ( ) - > front ( ) . begin ( ) ) ; <nl> + auto const_value = const_builder . clone ( * extern_value . getDefiningOp ( ) ) ; <nl> + replaceAllUsesInRegionWith ( extern_value , const_value - > getResult ( 0 ) , <nl> + * it . value ( ) ) ; <nl> } <nl> } <nl> <nl>
|
Sink all constants into functions when outlining while
|
tensorflow/tensorflow
|
f76195954f45adf6ef3b613554101367065b469a
|
2020-03-26T13:56:12Z
|
mmm a / contrib / lz4 <nl> ppp b / contrib / lz4 <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit 780aac520b69d6369f4e3995624c37e56d75498d <nl> + Subproject commit 7a4e3b1fac5cd9d4ec7c8d0091329ba107ec2131 <nl> mmm a / dbms / src / Compression / LZ4_decompress_faster . cpp <nl> ppp b / dbms / src / Compression / LZ4_decompress_faster . cpp <nl> <nl> # include < emmintrin . h > <nl> # endif <nl> <nl> + # ifdef __AVX__ <nl> + # include < immintrin . h > <nl> + # endif <nl> + <nl> # ifdef __SSSE3__ <nl> # include < tmmintrin . h > <nl> # endif <nl> template < > void inline wildCopy < 16 > ( UInt8 * dst , const UInt8 * src , UInt8 * dst <nl> template < > void inline copyOverlap < 16 , false > ( UInt8 * op , const UInt8 * & match , const size_t offset ) { copyOverlap16 ( op , match , offset ) ; } <nl> template < > void inline copyOverlap < 16 , true > ( UInt8 * op , const UInt8 * & match , const size_t offset ) { copyOverlap16Shuffle ( op , match , offset ) ; } <nl> <nl> + inline void copy32 ( UInt8 * dst , const UInt8 * src ) <nl> + { <nl> + # if defined ( __AVX__ ) <nl> + _mm256_storeu_si256 ( reinterpret_cast < __m256i * > ( dst ) , <nl> + _mm256_loadu_si256 ( reinterpret_cast < const __m256i * > ( src ) ) ) ; <nl> + # elif defined ( __SSE2__ ) <nl> + _mm_storeu_si128 ( reinterpret_cast < __m128i * > ( dst ) , <nl> + _mm_loadu_si128 ( reinterpret_cast < const __m128i * > ( src ) ) ) ; <nl> + _mm_storeu_si128 ( reinterpret_cast < __m128i * > ( dst + 16 ) , <nl> + _mm_loadu_si128 ( reinterpret_cast < const __m128i * > ( src + 16 ) ) ) ; <nl> + # else <nl> + memcpy ( dst , src , 16 ) ; <nl> + # endif <nl> + } <nl> + <nl> + inline void wildCopy32 ( UInt8 * dst , const UInt8 * src , UInt8 * dst_end ) <nl> + { <nl> + do <nl> + { <nl> + copy32 ( dst , src ) ; <nl> + dst + = 32 ; <nl> + src + = 32 ; <nl> + } while ( dst < dst_end ) ; <nl> + } <nl> + <nl> + template < > void inline copy < 32 > ( UInt8 * dst , const UInt8 * src ) { copy32 ( dst , src ) ; } <nl> + template < > void inline wildCopy < 32 > ( UInt8 * dst , const UInt8 * src , UInt8 * dst_end ) { wildCopy32 ( dst , src , dst_end ) ; } <nl> + <nl> + inline void copyUsingOffset ( UInt8 * dst , const UInt8 * src , UInt8 * dst_end , const size_t offset ) <nl> + { <nl> + UInt8 v [ 8 ] ; <nl> + switch ( offset ) <nl> + { <nl> + case 1 : <nl> + memset ( v , * src , 8 ) ; <nl> + goto copy_loop ; <nl> + case 2 : <nl> + memcpy ( v , src , 2 ) ; <nl> + memcpy ( & v [ 2 ] , src , 2 ) ; <nl> + memcpy ( & v [ 4 ] , & v [ 0 ] , 4 ) ; <nl> + goto copy_loop ; <nl> + case 4 : <nl> + memcpy ( v , src , 4 ) ; <nl> + memcpy ( & v [ 4 ] , src , 4 ) ; <nl> + goto copy_loop ; <nl> + default : <nl> + if ( offset < 8 ) <nl> + { <nl> + copyOverlap < 8 , false > ( dst , src , offset ) ; <nl> + dst + = 8 ; <nl> + } <nl> + else <nl> + { <nl> + memcpy ( dst , src , 8 ) ; <nl> + dst + = 8 ; <nl> + src + = 8 ; <nl> + } <nl> + wildCopy < 8 > ( dst , src , dst_end ) ; <nl> + return ; <nl> + } <nl> + copy_loop : <nl> + memcpy ( dst , v , 8 ) ; <nl> + dst + = 8 ; <nl> + while ( dst < dst_end ) <nl> + { <nl> + memcpy ( dst , v , 8 ) ; <nl> + dst + = 8 ; <nl> + } <nl> + } <nl> <nl> / / / See also https : / / stackoverflow . com / a / 30669632 <nl> <nl> <nl> - template < size_t copy_amount , bool use_shuffle > <nl> + / / / use_optimized_new_lz4_version is for the new optimized LZ4 decompression that was introduced in LZ4 1 . 9 . 0 <nl> + / / / With experiments it turned out to be faster for big columns , so we decided to add it to the statistics choice . <nl> + <nl> + template < size_t copy_amount , size_t guaranteed_minimal_dest_size , bool use_shuffle , bool use_optimized_new_lz4_version > <nl> void NO_INLINE decompressImpl ( <nl> const char * const source , <nl> char * const dest , <nl> + [ [ maybe_unused ] ] size_t source_size , <nl> size_t dest_size ) <nl> { <nl> const UInt8 * ip = reinterpret_cast < const UInt8 * > ( source ) ; <nl> + [ [ maybe_unused ] ] const UInt8 * const input_end = reinterpret_cast < const UInt8 * > ( source ) + source_size ; <nl> UInt8 * op = reinterpret_cast < UInt8 * > ( dest ) ; <nl> UInt8 * const output_end = op + dest_size ; <nl> + UInt8 * copy_end ; <nl> + unsigned token ; <nl> + size_t length ; <nl> + size_t offset ; <nl> + const UInt8 * match ; <nl> <nl> - while ( 1 ) <nl> + auto continue_read_length = [ & ] <nl> { <nl> - size_t length ; <nl> + unsigned s ; <nl> + do <nl> + { <nl> + s = * ip + + ; <nl> + length + = s ; <nl> + } while ( unlikely ( s = = 255 ) ) ; <nl> + } ; <nl> <nl> - auto continue_read_length = [ & ] <nl> + if ( use_optimized_new_lz4_version ) <nl> + { <nl> + if ( guaranteed_minimal_dest_size > = 64 | | dest_size > = 64 ) <nl> { <nl> - unsigned s ; <nl> - do <nl> + while ( 1 ) <nl> { <nl> - s = * ip + + ; <nl> - length + = s ; <nl> - } while ( unlikely ( s = = 255 ) ) ; <nl> - } ; <nl> + / / / Get literal length . <nl> + token = * ip + + ; <nl> + length = token > > 4 ; <nl> + if ( length = = 0x0F ) <nl> + { <nl> + continue_read_length ( ) ; <nl> + copy_end = op + length ; <nl> + if ( copy_end > output_end - 32 | | ip + length > input_end - 32 ) <nl> + goto literal_copy ; <nl> + wildCopy < 32 > ( op , ip , copy_end ) ; <nl> + ip + = length ; <nl> + op = copy_end ; <nl> + } <nl> + else <nl> + { <nl> + copy_end = op + length ; <nl> + if ( ip > input_end - 17 ) <nl> + goto literal_copy ; <nl> + copy < 16 > ( op , ip ) ; <nl> + ip + = length ; <nl> + op = copy_end ; <nl> + } <nl> + <nl> + offset = unalignedLoad < UInt16 > ( ip ) ; <nl> + ip + = 2 ; <nl> + match = op - offset ; <nl> + <nl> + / / / Get match length . <nl> + length = token & 0x0F ; <nl> + if ( length = = 0x0F ) <nl> + { <nl> + continue_read_length ( ) ; <nl> + length + = 4 ; <nl> + if ( op + length > = output_end - 64 ) <nl> + goto match_copy ; <nl> + } <nl> + else <nl> + { <nl> + length + = 4 ; <nl> + if ( op + length > = output_end - 64 ) <nl> + goto match_copy ; <nl> + if ( offset > = 8 ) <nl> + { <nl> + memcpy ( op , match , 8 ) ; <nl> + memcpy ( op + 8 , match + 8 , 8 ) ; <nl> + memcpy ( op + 16 , match + 16 , 2 ) ; <nl> + op + = length ; <nl> + continue ; <nl> + } <nl> + } <nl> + <nl> + / / / Copy match within block , that produce overlapping pattern . Match may replicate itself . <nl> + copy_end = op + length ; <nl> + if ( unlikely ( offset < 16 ) ) <nl> + copyUsingOffset ( op , match , copy_end , offset ) ; <nl> + else <nl> + wildCopy < 32 > ( op , match , copy_end ) ; <nl> + <nl> + op = copy_end ; <nl> + } <nl> + } <nl> + } <nl> <nl> + while ( 1 ) <nl> + { <nl> / / / Get literal length . <nl> - <nl> - const unsigned token = * ip + + ; <nl> + token = * ip + + ; <nl> length = token > > 4 ; <nl> if ( length = = 0x0F ) <nl> continue_read_length ( ) ; <nl> - <nl> / / / Copy literals . <nl> - <nl> - UInt8 * copy_end = op + length ; <nl> - <nl> + copy_end = op + length ; <nl> + literal_copy : <nl> / / / input : Hello , world <nl> / / / ^ - ip <nl> / / / output : xyz <nl> void NO_INLINE decompressImpl ( <nl> / / / ^ - ip <nl> / / / output : xyzHello , w <nl> / / / ^ - op ( we will overwrite excessive bytes on next iteration ) <nl> - <nl> - wildCopy < copy_amount > ( op , ip , copy_end ) ; / / / Here we can write up to copy_amount - 1 bytes after buffer . <nl> + wildCopy < copy_amount > ( op , ip , copy_end ) ; <nl> <nl> ip + = length ; <nl> op = copy_end ; <nl> void NO_INLINE decompressImpl ( <nl> return ; <nl> <nl> / / / Get match offset . <nl> - <nl> - size_t offset = unalignedLoad < UInt16 > ( ip ) ; <nl> + offset = unalignedLoad < UInt16 > ( ip ) ; <nl> ip + = 2 ; <nl> - const UInt8 * match = op - offset ; <nl> + match = op - offset ; <nl> <nl> / / / Get match length . <nl> - <nl> length = token & 0x0F ; <nl> if ( length = = 0x0F ) <nl> continue_read_length ( ) ; <nl> length + = 4 ; <nl> <nl> + match_copy : <nl> / / / Copy match within block , that produce overlapping pattern . Match may replicate itself . <nl> - <nl> copy_end = op + length ; <nl> <nl> / * * Here we can write up to copy_amount - 1 - 4 * 2 bytes after buffer . <nl> void NO_INLINE decompressImpl ( <nl> / / / <nl> / / / output : HelloHelloHel <nl> / / / ^ - match ^ - op <nl> - <nl> copyOverlap < copy_amount , use_shuffle > ( op , match , offset ) ; <nl> } <nl> else <nl> void NO_INLINE decompressImpl ( <nl> <nl> } <nl> <nl> - <nl> void decompress ( <nl> const char * const source , <nl> char * const dest , <nl> void decompress ( <nl> { <nl> if ( source_size = = 0 | | dest_size = = 0 ) <nl> return ; <nl> - <nl> + static constexpr size_t small_block_threshold = 32768 ; <nl> / / / Don ' t run timer if the block is too small . <nl> - if ( dest_size > = 32768 ) <nl> + if ( dest_size > = small_block_threshold ) <nl> { <nl> size_t best_variant = statistics . select ( ) ; <nl> <nl> void decompress ( <nl> Stopwatch watch ; <nl> <nl> if ( best_variant = = 0 ) <nl> - decompressImpl < 16 , true > ( source , dest , dest_size ) ; <nl> + decompressImpl < 16 , small_block_threshold , true , false > ( source , dest , source_size , dest_size ) ; <nl> if ( best_variant = = 1 ) <nl> - decompressImpl < 16 , false > ( source , dest , dest_size ) ; <nl> + decompressImpl < 16 , small_block_threshold , false , false > ( source , dest , source_size , dest_size ) ; <nl> if ( best_variant = = 2 ) <nl> - decompressImpl < 8 , true > ( source , dest , dest_size ) ; <nl> + decompressImpl < 8 , small_block_threshold , true , false > ( source , dest , source_size , dest_size ) ; <nl> + if ( best_variant = = 3 ) <nl> + decompressImpl < 8 , small_block_threshold , false , true > ( source , dest , source_size , dest_size ) ; <nl> <nl> watch . stop ( ) ; <nl> <nl> void decompress ( <nl> } <nl> else <nl> { <nl> - decompressImpl < 8 , false > ( source , dest , dest_size ) ; <nl> + decompressImpl < 8 , 0 , false , false > ( source , dest , source_size , dest_size ) ; <nl> } <nl> } <nl> <nl> mmm a / dbms / src / Compression / LZ4_decompress_faster . h <nl> ppp b / dbms / src / Compression / LZ4_decompress_faster . h <nl> struct PerformanceStatistics <nl> } ; <nl> <nl> / / / Number of different algorithms to select from . <nl> - static constexpr size_t NUM_ELEMENTS = 3 ; <nl> + static constexpr size_t NUM_ELEMENTS = 4 ; <nl> <nl> / / / Cold invocations may be affected by additional memory latencies . Don ' t take first invocations into account . <nl> static constexpr double NUM_INVOCATIONS_TO_THROW_OFF = 2 ; <nl>
|
Faster LZ4 decompression because of new release
|
ClickHouse/ClickHouse
|
2caf3d39ffa469d28d8d1e6c52950f25426707f8
|
2019-04-21T17:31:15Z
|
mmm a / aten / src / ATen / native / EmbeddingBag . cpp <nl> ppp b / aten / src / ATen / native / EmbeddingBag . cpp <nl> void index_select_scale_add < float > ( const Tensor & select_indices , <nl> <nl> } / / namespace <nl> <nl> - static void make_bag_size ( const Tensor & offsets , const Tensor & indices , <nl> - const int64_t mode , Tensor & bag_size ) { <nl> + static at : : Tensor make_bag_size ( const Tensor & offsets , const Tensor & indices , <nl> + const int64_t mode , const bool requires_grad ) { <nl> + at : : Tensor bag_size ; <nl> if ( mode = = MODE_MEAN | | mode = = MODE_MAX ) { <nl> + bag_size = at : : zeros ( offsets . sizes ( ) , indices . options ( ) ) ; <nl> / / Compute this for MODE_MEAN and MODE_MAX ( latter needed for backwards ) <nl> if ( offsets . size ( 0 ) ! = 1 ) { <nl> bag_size . slice ( 0 , 0 , bag_size . size ( 0 ) - 1 , 1 ) = <nl> static void make_bag_size ( const Tensor & offsets , const Tensor & indices , <nl> offsets . slice ( 0 , 0 , offsets . size ( 0 ) - 1 , 1 ) ; <nl> } <nl> bag_size [ - 1 ] = indices . size ( 0 ) - offsets [ - 1 ] ; <nl> + } else if ( requires_grad ) { <nl> + / / in MODE_SUM , only initialize bag_size if we need gradients <nl> + bag_size = at : : zeros ( offsets . sizes ( ) , indices . options ( ) ) ; <nl> } <nl> + return bag_size ; <nl> } <nl> <nl> static Tensor apply_bag_size ( const Tensor & offsets , const Tensor & indices , <nl> _embedding_bag_cpu ( const Tensor & weight , const Tensor & indices , <nl> AT_ASSERT ( per_sample_weights . numel ( ) = = indices . numel ( ) ) ; <nl> } <nl> <nl> - auto bag_size = at : : zeros ( offsets . sizes ( ) , indices . options ( ) ) ; <nl> - make_bag_size ( offsets , indices , mode , bag_size ) ; <nl> + auto bag_size = make_bag_size ( offsets , indices , mode , weight . requires_grad ( ) ) ; <nl> <nl> auto output = at : : zeros ( { offsets . size ( 0 ) , weight . size ( 1 ) } , weight . options ( ) ) ; <nl> <nl>
|
embedding_bag make_bag_size optimization ( )
|
pytorch/pytorch
|
8d35b6cec7146f0cffded101b806eb4dc3d47daf
|
2019-12-07T00:17:16Z
|
mmm a / lib / AST / GenericSignatureBuilder . cpp <nl> ppp b / lib / AST / GenericSignatureBuilder . cpp <nl> ConstraintResult GenericSignatureBuilder : : addRequirement ( <nl> <nl> switch ( req . getKind ( ) ) { <nl> case RequirementKind : : Superclass : <nl> - case RequirementKind : : Conformance : <nl> - return addTypeRequirement ( subst ( req . getFirstType ( ) ) , <nl> - subst ( req . getSecondType ( ) ) , <nl> - source , <nl> + case RequirementKind : : Conformance : { <nl> + auto firstType = subst ( req . getFirstType ( ) ) ; <nl> + auto secondType = subst ( req . getSecondType ( ) ) ; <nl> + if ( ! firstType | | ! secondType ) <nl> + return ConstraintResult : : Conflicting ; <nl> + <nl> + return addTypeRequirement ( firstType , secondType , source , <nl> UnresolvedHandlingKind : : GenerateConstraints , <nl> & Visited ) ; <nl> + } <nl> <nl> - case RequirementKind : : Layout : <nl> - return addLayoutRequirement ( subst ( req . getFirstType ( ) ) , <nl> - req . getLayoutConstraint ( ) , <nl> - source , <nl> + case RequirementKind : : Layout : { <nl> + auto firstType = subst ( req . getFirstType ( ) ) ; <nl> + if ( ! firstType ) <nl> + return ConstraintResult : : Conflicting ; <nl> + <nl> + return addLayoutRequirement ( firstType , req . getLayoutConstraint ( ) , source , <nl> UnresolvedHandlingKind : : GenerateConstraints ) ; <nl> + } <nl> + <nl> + case RequirementKind : : SameType : { <nl> + auto firstType = subst ( req . getFirstType ( ) ) ; <nl> + auto secondType = subst ( req . getSecondType ( ) ) ; <nl> + if ( ! firstType | | ! secondType ) <nl> + return ConstraintResult : : Conflicting ; <nl> <nl> - case RequirementKind : : SameType : <nl> return addSameTypeRequirement ( <nl> - subst ( req . getFirstType ( ) ) , subst ( req . getSecondType ( ) ) , source , <nl> + firstType , secondType , source , <nl> UnresolvedHandlingKind : : GenerateConstraints , <nl> [ & ] ( Type type1 , Type type2 ) { <nl> if ( source . getLoc ( ) . isValid ( ) ) <nl> ConstraintResult GenericSignatureBuilder : : addRequirement ( <nl> type1 , type2 ) ; <nl> } ) ; <nl> } <nl> + } <nl> <nl> llvm_unreachable ( " Unhandled requirement ? " ) ; <nl> } <nl> mmm a / lib / Sema / TypeCheckProtocol . cpp <nl> ppp b / lib / Sema / TypeCheckProtocol . cpp <nl> RequirementEnvironment : : RequirementEnvironment ( <nl> / / interface types into the abstract type parameters ) . <nl> auto source = <nl> GenericSignatureBuilder : : FloatingRequirementSource : : forAbstract ( ) ; <nl> - for ( auto & reqReq : reqSig - > getRequirements ( ) ) { <nl> - switch ( reqReq . getKind ( ) ) { <nl> - case RequirementKind : : Conformance : { <nl> - / / Substitute the constrained types . <nl> - auto first = reqReq . getFirstType ( ) . subst ( reqToSyntheticEnvMap , <nl> - SubstFlags : : UseErrorType ) ; <nl> - if ( ! first - > isTypeParameter ( ) ) break ; <nl> - <nl> - builder . addRequirement ( Requirement ( RequirementKind : : Conformance , <nl> - first , reqReq . getSecondType ( ) ) , <nl> - source ) ; <nl> - break ; <nl> - } <nl> - <nl> - case RequirementKind : : Layout : { <nl> - / / Substitute the constrained types . <nl> - auto first = reqReq . getFirstType ( ) . subst ( reqToSyntheticEnvMap ) ; <nl> - if ( ! first - > isTypeParameter ( ) ) break ; <nl> - <nl> - builder . addRequirement ( Requirement ( RequirementKind : : Layout , first , <nl> - reqReq . getLayoutConstraint ( ) ) , <nl> - source ) ; <nl> - break ; <nl> - } <nl> - <nl> - case RequirementKind : : Superclass : { <nl> - / / Substitute the constrained types . <nl> - auto first = reqReq . getFirstType ( ) . subst ( reqToSyntheticEnvMap , <nl> - SubstFlags : : UseErrorType ) ; <nl> - auto second = reqReq . getSecondType ( ) . subst ( reqToSyntheticEnvMap , <nl> - SubstFlags : : UseErrorType ) ; <nl> - <nl> - if ( ! first - > isTypeParameter ( ) ) break ; <nl> - <nl> - builder . addRequirement ( Requirement ( RequirementKind : : Superclass , <nl> - first , second ) , <nl> - source ) ; <nl> - break ; <nl> - } <nl> - <nl> - case RequirementKind : : SameType : { <nl> - / / Substitute the constrained types . <nl> - auto first = reqReq . getFirstType ( ) . subst ( reqToSyntheticEnvMap , <nl> - SubstFlags : : UseErrorType ) ; <nl> - auto second = reqReq . getSecondType ( ) . subst ( reqToSyntheticEnvMap , <nl> - SubstFlags : : UseErrorType ) ; <nl> - <nl> - / / FIXME : We really want to check hasTypeParameter here , but the <nl> - / / GenericSignatureBuilder isn ' t ready for that . <nl> - if ( ! first - > isTypeParameter ( ) ) { <nl> - / / When the second is not a type parameter either , drop the requirement . <nl> - / / If the types were different , this requirement will be unsatisfiable . <nl> - if ( ! second - > isTypeParameter ( ) ) continue ; <nl> - <nl> - / / Put the type parameter first . <nl> - std : : swap ( first , second ) ; <nl> - } <nl> - <nl> - builder . addRequirement ( Requirement ( RequirementKind : : SameType , <nl> - first , second ) , <nl> - source ) ; <nl> - break ; <nl> - } <nl> - } <nl> + for ( auto & req : reqSig - > getRequirements ( ) ) { <nl> + builder . addRequirement ( req , source , & reqToSyntheticEnvMap ) ; <nl> } <nl> <nl> / / Finalize the generic signature builder . <nl>
|
[ Type checker ] Use GenericSignatureBuilder ' s substitution logic .
|
apple/swift
|
c3b507f462f4b73e91cc76616dd76344cbcd72fb
|
2017-04-15T00:19:02Z
|
mmm a / tools / system - analyzer / index . html <nl> ppp b / tools / system - analyzer / index . html <nl> <nl> } <nl> < / style > <nl> < script type = " module " > <nl> - import { globalSearchBarEvent , globalDataUpload , showMaps , handleSelectIcEvents } from ' . / index . mjs ' ; <nl> - / / TODO ( zcankara ) : Build an App component that has these methods , rather than using globals <nl> - globalThis . globalDataUpload = globalDataUpload ; <nl> - globalThis . globalSearchBarEvent = globalSearchBarEvent ; <nl> - globalThis . showMaps = showMaps ; <nl> - globalThis . handleSelectIcEvents = handleSelectIcEvents ; <nl> + import { App } from ' . / index . mjs ' ; <nl> + <nl> + globalThis . app = new App ( ) ; <nl> < / script > <nl> < / head > <nl> < body > <nl> < div id = " content " > <nl> < section id = " file - reader " > <nl> < br > < / br > <nl> - < log - file - reader id = " log - file - reader " onchange = " globalDataUpload ( event ) " > < / log - file - reader > <nl> + < log - file - reader id = " log - file - reader " onchange = " app . globalDataUpload ( event ) " > < / log - file - reader > <nl> < br > < / br > <nl> < / section > <nl> < div id = " container " style = " display : none ; " > <nl> < timeline - panel id = " timeline - panel " > < / timeline - panel > <nl> - < map - panel id = " map - panel " onclick = " globalSearchBarEvent ( event ) " onchange = " showMaps ( event ) " > < / map - panel > <nl> - < ic - panel id = " ic - panel " onchange = " handleSelectIcEvents ( event ) " > < / ic - panel > <nl> + < map - panel id = " map - panel " onclick = " app . globalSearchBarEvent ( event ) " onchange = " showMaps ( event ) " > < / map - panel > <nl> + < ic - panel id = " ic - panel " onchange = " app . handleSelectIcEvents ( event ) " > < / ic - panel > <nl> < / div > <nl> < / div > <nl> <nl> mmm a / tools / system - analyzer / index . mjs <nl> ppp b / tools / system - analyzer / index . mjs <nl> function handleSelectIcEvents ( e ) { <nl> document . state . filteredEntries = e . detail ; <nl> } <nl> <nl> - export { globalSearchBarEvent , globalDataUpload , showMaps , handleSelectIcEvents } ; <nl> + class App { <nl> + globalDataUpload = globalDataUpload ; <nl> + globalSearchBarEvent = globalSearchBarEvent ; <nl> + showMaps = showMaps ; <nl> + handleSelectIcEvents = handleSelectIcEvents ; <nl> + } <nl> + <nl> + export { App } ; <nl>
|
[ tools ] [ system - analyzer ] Create an app class
|
v8/v8
|
32234d0251a86b2630edb8d222bddac23f80f76a
|
2020-07-15T13:29:13Z
|
mmm a / tensorflow / python / distribute / BUILD <nl> ppp b / tensorflow / python / distribute / BUILD <nl> py_library ( <nl> " / / tensorflow / python : config " , <nl> " / / tensorflow / python : platform " , <nl> " / / tensorflow / python : tf2 " , <nl> - " / / tensorflow / python : training " , <nl> " / / tensorflow / python : util " , <nl> " / / tensorflow / python / distribute / cluster_resolver : tpu_cluster_resolver_py " , <nl> " / / tensorflow / python / eager : context " , <nl> " / / tensorflow / python / eager : remote " , <nl> - " / / tensorflow / python / keras / optimizer_v2 " , <nl> " / / tensorflow / python / tpu : tpu_lib " , <nl> ] , <nl> ) <nl> distribute_py_test ( <nl> ] , <nl> ) <nl> <nl> - distribute_py_test ( <nl> - name = " minimize_loss_test " , <nl> - srcs = [ " minimize_loss_test . py " ] , <nl> - main = " minimize_loss_test . py " , <nl> - tags = [ <nl> - " multi_and_single_gpu " , <nl> - " no_oss " , # TODO ( b / 139815303 ) : enable after this is fixed . <nl> - " noguitar " , # TODO ( b / 140755528 ) : enable after this is fixed . <nl> - " notap " , # TODO ( b / 139815303 ) : enable after this is fixed . <nl> - ] , <nl> - deps = [ <nl> - " : combinations " , <nl> - " : mirrored_strategy " , <nl> - " : single_loss_example " , <nl> - " : strategy_combinations " , <nl> - " : strategy_test_lib " , <nl> - " / / tensorflow / python : control_flow_ops " , <nl> - " / / tensorflow / python : control_flow_v2_toggles " , <nl> - " / / tensorflow / python : framework_ops " , <nl> - " / / tensorflow / python : math_ops " , <nl> - " / / tensorflow / python : variable_scope " , <nl> - " / / tensorflow / python : variables " , <nl> - " / / tensorflow / python / data / ops : dataset_ops " , <nl> - " / / tensorflow / python / eager : context " , <nl> - " / / tensorflow / python / eager : test " , <nl> - " / / tensorflow / python / ops / losses " , <nl> - " / / third_party / py / numpy " , <nl> - " @ absl_py / / absl / testing : parameterized " , <nl> - ] , <nl> - ) <nl> - <nl> py_library ( <nl> name = " single_loss_example " , <nl> srcs = [ " single_loss_example . py " ] , <nl> py_library ( <nl> ] , <nl> ) <nl> <nl> - distribute_py_test ( <nl> - name = " step_fn_test " , <nl> - srcs = [ " step_fn_test . py " ] , <nl> - main = " step_fn_test . py " , <nl> - tags = [ <nl> - " multi_and_single_gpu " , <nl> - ] , <nl> - deps = [ <nl> - " : combinations " , <nl> - " : single_loss_example " , <nl> - " : strategy_combinations " , <nl> - " / / tensorflow / python : framework_test_lib " , <nl> - " / / tensorflow / python : variables " , <nl> - " / / tensorflow / python / eager : context " , <nl> - " / / tensorflow / python / eager : test " , <nl> - " / / third_party / py / numpy " , <nl> - " @ absl_py / / absl / testing : parameterized " , <nl> - ] , <nl> - ) <nl> - <nl> cuda_py_test ( <nl> name = " warm_starting_util_test " , <nl> size = " medium " , <nl> mmm a / tensorflow / python / distribute / strategy_combinations . py <nl> ppp b / tensorflow / python / distribute / strategy_combinations . py <nl> <nl> # See the License for the specific language governing permissions and <nl> # limitations under the License . <nl> # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - " " " Strategy and optimizer combinations for combinations . combine ( ) . " " " <nl> + " " " Strategy combinations for combinations . combine ( ) . " " " <nl> <nl> from __future__ import absolute_import <nl> from __future__ import division <nl> <nl> from tensorflow . python . eager import context <nl> from tensorflow . python . eager import remote <nl> from tensorflow . python . framework import config <nl> - from tensorflow . python . keras . optimizer_v2 import adadelta as adadelta_keras_v2 <nl> - from tensorflow . python . keras . optimizer_v2 import adagrad as adagrad_keras_v2 <nl> - from tensorflow . python . keras . optimizer_v2 import adam as adam_keras_v2 <nl> - from tensorflow . python . keras . optimizer_v2 import adamax as adamax_keras_v2 <nl> - from tensorflow . python . keras . optimizer_v2 import ftrl as ftrl_keras_v2 <nl> - from tensorflow . python . keras . optimizer_v2 import gradient_descent as gradient_descent_keras_v2 <nl> - from tensorflow . python . keras . optimizer_v2 import nadam as nadam_keras_v2 <nl> - from tensorflow . python . keras . optimizer_v2 import rmsprop as rmsprop_keras_v2 <nl> from tensorflow . python . platform import flags <nl> from tensorflow . python . tpu import device_assignment as device_assignment_lib <nl> from tensorflow . python . tpu import tpu_strategy_util <nl> - from tensorflow . python . training import adagrad <nl> - from tensorflow . python . training import adam <nl> - from tensorflow . python . training import ftrl <nl> - from tensorflow . python . training import gradient_descent <nl> - from tensorflow . python . training import rmsprop <nl> <nl> FLAGS = flags . FLAGS <nl> <nl> def _shutdown_at_exit ( ) : <nl> atexit . register ( _shutdown_at_exit ) <nl> <nl> <nl> - gradient_descent_optimizer_v1_fn = combinations . NamedObject ( <nl> - " GradientDescentV1 " , <nl> - lambda : gradient_descent . GradientDescentOptimizer ( 0 . 001 ) ) <nl> - adagrad_optimizer_v1_fn = combinations . NamedObject ( <nl> - " AdagradV1 " , lambda : adagrad . AdagradOptimizer ( 0 . 001 ) ) <nl> - adam_optimizer_v1_fn = combinations . NamedObject ( <nl> - " AdamV1 " , lambda : adam . AdamOptimizer ( 0 . 001 , epsilon = 1 ) ) <nl> - ftrl_optimizer_v1_fn = combinations . NamedObject ( <nl> - " FtrlV1 " , lambda : ftrl . FtrlOptimizer ( 0 . 001 ) ) <nl> - rmsprop_optimizer_v1_fn = combinations . NamedObject ( <nl> - " RmsPropV1 " , lambda : rmsprop . RMSPropOptimizer ( 0 . 001 ) ) <nl> - <nl> - # TODO ( shiningsun ) : consider adding the other v1 optimizers <nl> - optimizers_v1 = [ <nl> - gradient_descent_optimizer_v1_fn , adagrad_optimizer_v1_fn , <nl> - ftrl_optimizer_v1_fn , rmsprop_optimizer_v1_fn <nl> - ] <nl> - <nl> - adadelta_optimizer_keras_v2_fn = combinations . NamedObject ( <nl> - " AdadeltaKerasV2 " , lambda : adadelta_keras_v2 . Adadelta ( 0 . 001 ) ) <nl> - adagrad_optimizer_keras_v2_fn = combinations . NamedObject ( <nl> - " AdagradKerasV2 " , lambda : adagrad_keras_v2 . Adagrad ( 0 . 001 ) ) <nl> - adam_optimizer_keras_v2_fn = combinations . NamedObject ( <nl> - " AdamKerasV2 " , lambda : adam_keras_v2 . Adam ( 0 . 001 , epsilon = 1 . 0 ) ) <nl> - adamax_optimizer_keras_v2_fn = combinations . NamedObject ( <nl> - " AdamaxKerasV2 " , lambda : adamax_keras_v2 . Adamax ( 0 . 001 , epsilon = 1 . 0 ) ) <nl> - nadam_optimizer_keras_v2_fn = combinations . NamedObject ( <nl> - " NadamKerasV2 " , lambda : nadam_keras_v2 . Nadam ( 0 . 001 , epsilon = 1 . 0 ) ) <nl> - ftrl_optimizer_keras_v2_fn = combinations . NamedObject ( <nl> - " FtrlKerasV2 " , lambda : ftrl_keras_v2 . Ftrl ( 0 . 001 ) ) <nl> - gradient_descent_optimizer_keras_v2_fn = combinations . NamedObject ( <nl> - " GradientDescentKerasV2 " , lambda : gradient_descent_keras_v2 . SGD ( 0 . 001 ) ) <nl> - rmsprop_optimizer_keras_v2_fn = combinations . NamedObject ( <nl> - " RmsPropKerasV2 " , lambda : rmsprop_keras_v2 . RMSprop ( 0 . 001 ) ) <nl> - <nl> - # TODO ( shiningsun ) : consider adding the other v2 optimizers <nl> - optimizers_v2 = [ <nl> - gradient_descent_optimizer_keras_v2_fn , adagrad_optimizer_keras_v2_fn <nl> - ] <nl> - <nl> - optimizers_v1_and_v2 = optimizers_v1 + optimizers_v2 <nl> - <nl> graph_and_eager_modes = [ " graph " , " eager " ] <nl> <nl> <nl> def set_virtual_cpus_to_at_least ( num_virtual_cpus ) : <nl> ( len ( configs ) , num_virtual_cpus ) ) <nl> <nl> <nl> - def distributions_and_v1_optimizers ( ) : <nl> - " " " A common set of combination with DistributionStrategies and Optimizers . " " " <nl> - return combinations . combine ( <nl> - distribution = [ <nl> - one_device_strategy , <nl> - mirrored_strategy_with_gpu_and_cpu , <nl> - mirrored_strategy_with_two_gpus , <nl> - ] , <nl> - optimizer_fn = optimizers_v1 ) <nl> - <nl> - <nl> - def distributions_and_v2_optimizers ( ) : <nl> - " " " A common set of combination with DistributionStrategies and Optimizers . " " " <nl> - return combinations . combine ( <nl> - distribution = [ <nl> - one_device_strategy , <nl> - mirrored_strategy_with_gpu_and_cpu , <nl> - mirrored_strategy_with_two_gpus , <nl> - ] , <nl> - optimizer_fn = optimizers_v2 ) <nl> - <nl> - <nl> - def distributions_and_v1_and_v2_optimizers ( ) : <nl> - " " " A common set of combination with DistributionStrategies and Optimizers . " " " <nl> - return combinations . combine ( <nl> - distribution = [ <nl> - one_device_strategy , <nl> - mirrored_strategy_with_gpu_and_cpu , <nl> - mirrored_strategy_with_two_gpus , <nl> - ] , <nl> - optimizer_fn = optimizers_v1_and_v2 ) <nl> - <nl> - <nl> strategies_minus_tpu = [ <nl> default_strategy , <nl> one_device_strategy , <nl> mmm a / tensorflow / python / keras / distribute / BUILD <nl> ppp b / tensorflow / python / keras / distribute / BUILD <nl> py_library ( <nl> ] , <nl> ) <nl> <nl> + py_library ( <nl> + name = " optimizer_combinations " , <nl> + srcs = [ " optimizer_combinations . py " ] , <nl> + srcs_version = " PY2AND3 " , <nl> + deps = [ <nl> + " / / tensorflow / python : training " , <nl> + " / / tensorflow / python / distribute : combinations " , <nl> + " / / tensorflow / python / distribute : strategy_combinations " , <nl> + " / / tensorflow / python / keras / optimizer_v2 " , <nl> + ] , <nl> + ) <nl> + <nl> py_library ( <nl> name = " worker_training_state " , <nl> srcs = [ <nl> distribute_py_test ( <nl> " multi_and_single_gpu " , <nl> ] , <nl> deps = [ <nl> + " : optimizer_combinations " , <nl> " / / tensorflow / python : platform_test " , <nl> " / / tensorflow / python : util " , <nl> " / / tensorflow / python / compat : v2_compat " , <nl> py_library ( <nl> " distribute_strategy_test . py " , <nl> ] , <nl> deps = [ <nl> + " : optimizer_combinations " , <nl> " / / tensorflow / python : client_testlib " , <nl> " / / tensorflow / python : training " , <nl> " / / tensorflow / python / distribute : combinations " , <nl> distribute_py_test ( <nl> ] , <nl> deps = [ <nl> " : distribute_strategy_test_lib " , <nl> + " : optimizer_combinations " , <nl> ] , <nl> ) <nl> <nl> distribute_py_test ( <nl> ] , <nl> deps = [ <nl> " : keras_test_lib " , <nl> + " : optimizer_combinations " , <nl> " / / tensorflow / python / distribute : parameter_server_strategy " , <nl> " / / tensorflow / python / keras / distribute : distribute_strategy_test_lib " , <nl> ] , <nl> cuda_py_test ( <nl> ] , <nl> ) <nl> <nl> + distribute_py_test ( <nl> + name = " minimize_loss_test " , <nl> + srcs = [ " minimize_loss_test . py " ] , <nl> + main = " minimize_loss_test . py " , <nl> + tags = [ <nl> + " multi_and_single_gpu " , <nl> + " no_oss " , # TODO ( b / 139815303 ) : enable after this is fixed . <nl> + " noguitar " , # TODO ( b / 140755528 ) : enable after this is fixed . <nl> + " notap " , # TODO ( b / 139815303 ) : enable after this is fixed . <nl> + ] , <nl> + deps = [ <nl> + " : optimizer_combinations " , <nl> + " / / tensorflow / python : control_flow_ops " , <nl> + " / / tensorflow / python : control_flow_v2_toggles " , <nl> + " / / tensorflow / python : framework_ops " , <nl> + " / / tensorflow / python : math_ops " , <nl> + " / / tensorflow / python : variable_scope " , <nl> + " / / tensorflow / python : variables " , <nl> + " / / tensorflow / python / data / ops : dataset_ops " , <nl> + " / / tensorflow / python / distribute : combinations " , <nl> + " / / tensorflow / python / distribute : mirrored_strategy " , <nl> + " / / tensorflow / python / distribute : single_loss_example " , <nl> + " / / tensorflow / python / distribute : strategy_combinations " , <nl> + " / / tensorflow / python / distribute : strategy_test_lib " , <nl> + " / / tensorflow / python / eager : context " , <nl> + " / / tensorflow / python / eager : test " , <nl> + " / / tensorflow / python / ops / losses " , <nl> + " / / third_party / py / numpy " , <nl> + " @ absl_py / / absl / testing : parameterized " , <nl> + ] , <nl> + ) <nl> + <nl> cuda_py_test ( <nl> name = " mirrored_strategy_test " , <nl> srcs = [ " mirrored_strategy_test . py " ] , <nl> distribute_py_test ( <nl> " / / tensorflow / python / keras / saving " , <nl> ] , <nl> ) <nl> + <nl> + distribute_py_test ( <nl> + name = " step_fn_test " , <nl> + srcs = [ " step_fn_test . py " ] , <nl> + main = " step_fn_test . py " , <nl> + tags = [ <nl> + " multi_and_single_gpu " , <nl> + ] , <nl> + deps = [ <nl> + " : optimizer_combinations " , <nl> + " / / tensorflow / python : framework_test_lib " , <nl> + " / / tensorflow / python : variables " , <nl> + " / / tensorflow / python / distribute : combinations " , <nl> + " / / tensorflow / python / distribute : single_loss_example " , <nl> + " / / tensorflow / python / distribute : strategy_combinations " , <nl> + " / / tensorflow / python / eager : context " , <nl> + " / / tensorflow / python / eager : test " , <nl> + " / / third_party / py / numpy " , <nl> + " @ absl_py / / absl / testing : parameterized " , <nl> + ] , <nl> + ) <nl> mmm a / tensorflow / python / keras / distribute / ctl_correctness_test . py <nl> ppp b / tensorflow / python / keras / distribute / ctl_correctness_test . py <nl> <nl> from tensorflow . python . eager import test <nl> from tensorflow . python . framework import dtypes <nl> from tensorflow . python . framework import random_seed <nl> + from tensorflow . python . keras . distribute import optimizer_combinations <nl> from tensorflow . python . ops import math_ops <nl> from tensorflow . python . ops import nn <nl> <nl> def setUp ( self ) : <nl> @ combinations . generate ( <nl> combinations . combine ( <nl> distribution = strategy_combinations . all_strategies , <nl> - optimizer_fn = strategy_combinations . optimizers_v2 , <nl> + optimizer_fn = optimizer_combinations . optimizers_v2 , <nl> mode = [ ' eager ' ] , <nl> iteration_type = [ ' iterator ' , ' dataset ' ] , <nl> inside_func = [ False , True ] , <nl> mmm a / tensorflow / python / keras / distribute / distribute_strategy_test . py <nl> ppp b / tensorflow / python / keras / distribute / distribute_strategy_test . py <nl> <nl> from tensorflow . python . framework import sparse_tensor <nl> from tensorflow . python . keras import testing_utils <nl> from tensorflow . python . keras . distribute import distributed_training_utils <nl> + from tensorflow . python . keras . distribute import optimizer_combinations <nl> from tensorflow . python . keras . engine import base_layer_utils <nl> from tensorflow . python . keras . mixed_precision . experimental import policy <nl> from tensorflow . python . keras . optimizer_v2 import gradient_descent as gradient_descent_keras <nl> def strategy_and_optimizer_combinations ( ) : <nl> strategy_minus_tpu_combinations ( ) , <nl> combinations . combine ( <nl> optimizer = [ <nl> - strategy_combinations . adagrad_optimizer_v1_fn , <nl> - strategy_combinations . adam_optimizer_v1_fn , <nl> - strategy_combinations . gradient_descent_optimizer_v1_fn , <nl> - strategy_combinations . rmsprop_optimizer_v1_fn , <nl> - strategy_combinations . adadelta_optimizer_keras_v2_fn , <nl> - strategy_combinations . adagrad_optimizer_keras_v2_fn , <nl> - strategy_combinations . adam_optimizer_keras_v2_fn , <nl> - strategy_combinations . adamax_optimizer_keras_v2_fn , <nl> - strategy_combinations . gradient_descent_optimizer_keras_v2_fn , <nl> - strategy_combinations . nadam_optimizer_keras_v2_fn , <nl> - strategy_combinations . rmsprop_optimizer_keras_v2_fn , <nl> - strategy_combinations . ftrl_optimizer_keras_v2_fn <nl> + optimizer_combinations . adagrad_optimizer_v1_fn , <nl> + optimizer_combinations . adam_optimizer_v1_fn , <nl> + optimizer_combinations . gradient_descent_optimizer_v1_fn , <nl> + optimizer_combinations . rmsprop_optimizer_v1_fn , <nl> + optimizer_combinations . adadelta_optimizer_keras_v2_fn , <nl> + optimizer_combinations . adagrad_optimizer_keras_v2_fn , <nl> + optimizer_combinations . adam_optimizer_keras_v2_fn , <nl> + optimizer_combinations . adamax_optimizer_keras_v2_fn , <nl> + optimizer_combinations . gradient_descent_optimizer_keras_v2_fn , <nl> + optimizer_combinations . nadam_optimizer_keras_v2_fn , <nl> + optimizer_combinations . rmsprop_optimizer_keras_v2_fn , <nl> + optimizer_combinations . ftrl_optimizer_keras_v2_fn <nl> ] ) ) <nl> tpu_strategies_graph = combinations . combine ( <nl> distribution = tpu_strategies , <nl> mode = [ ' graph ' ] , <nl> optimizer = [ <nl> - strategy_combinations . adagrad_optimizer_v1_fn , <nl> - strategy_combinations . adam_optimizer_v1_fn , <nl> - strategy_combinations . gradient_descent_optimizer_v1_fn , <nl> - strategy_combinations . rmsprop_optimizer_v1_fn , <nl> - strategy_combinations . adagrad_optimizer_keras_v2_fn , <nl> - strategy_combinations . adam_optimizer_keras_v2_fn , <nl> - strategy_combinations . gradient_descent_optimizer_keras_v2_fn , <nl> - strategy_combinations . rmsprop_optimizer_keras_v2_fn <nl> + optimizer_combinations . adagrad_optimizer_v1_fn , <nl> + optimizer_combinations . adam_optimizer_v1_fn , <nl> + optimizer_combinations . gradient_descent_optimizer_v1_fn , <nl> + optimizer_combinations . rmsprop_optimizer_v1_fn , <nl> + optimizer_combinations . adagrad_optimizer_keras_v2_fn , <nl> + optimizer_combinations . adam_optimizer_keras_v2_fn , <nl> + optimizer_combinations . gradient_descent_optimizer_keras_v2_fn , <nl> + optimizer_combinations . rmsprop_optimizer_keras_v2_fn <nl> ] ) <nl> tpu_strategies_eager = combinations . combine ( <nl> distribution = tpu_strategies , <nl> mode = [ ' eager ' ] , <nl> optimizer = [ <nl> - strategy_combinations . adagrad_optimizer_keras_v2_fn , <nl> - strategy_combinations . adam_optimizer_keras_v2_fn , <nl> - strategy_combinations . gradient_descent_optimizer_keras_v2_fn , <nl> - strategy_combinations . rmsprop_optimizer_keras_v2_fn <nl> + optimizer_combinations . adagrad_optimizer_keras_v2_fn , <nl> + optimizer_combinations . adam_optimizer_keras_v2_fn , <nl> + optimizer_combinations . gradient_descent_optimizer_keras_v2_fn , <nl> + optimizer_combinations . rmsprop_optimizer_keras_v2_fn <nl> ] ) <nl> return non_tpu_strategies + tpu_strategies_eager + tpu_strategies_graph <nl> <nl> mmm a / tensorflow / python / keras / distribute / keras_utils_test . py <nl> ppp b / tensorflow / python / keras / distribute / keras_utils_test . py <nl> <nl> from tensorflow . python . keras import losses <nl> from tensorflow . python . keras . distribute import distribute_strategy_test as keras_test_lib <nl> from tensorflow . python . keras . distribute import distributed_training_utils <nl> + from tensorflow . python . keras . distribute import optimizer_combinations <nl> from tensorflow . python . platform import test <nl> from tensorflow . python . training import gradient_descent <nl> <nl> class TestDistributionStrategyWithLossMasking ( test . TestCase , <nl> strategy_combinations . mirrored_strategy_with_gpu_and_cpu , <nl> ] , <nl> mode = [ ' graph ' , ' eager ' ] , <nl> - optimizer = strategy_combinations . gradient_descent_optimizer_keras_v2_fn <nl> + optimizer = optimizer_combinations <nl> + . gradient_descent_optimizer_keras_v2_fn <nl> ) ) <nl> def test_masking ( self , distribution , optimizer ) : <nl> with self . cached_session ( ) : <nl> class TestDistributionStrategyWithNormalizationLayer ( test . TestCase , <nl> keras_test_lib . all_strategy_combinations ( ) , <nl> combinations . combine ( <nl> fused = [ True , False ] , <nl> - optimizer = strategy_combinations <nl> + optimizer = optimizer_combinations <nl> . gradient_descent_optimizer_keras_v2_fn ) ) ) <nl> def test_batchnorm_correctness ( self , distribution , fused , optimizer ) : <nl> with self . cached_session ( ) : <nl> class TestDistributionStrategySaveLoadWeights ( test . TestCase , <nl> combinations . times ( <nl> keras_test_lib . all_strategy_combinations_minus_default ( ) , <nl> combinations . combine ( <nl> - optimizer = strategy_combinations . rmsprop_optimizer_keras_v2_fn ) ) ) <nl> + optimizer = optimizer_combinations . rmsprop_optimizer_keras_v2_fn ) ) ) <nl> def test_save_load_h5 ( self , distribution , optimizer ) : <nl> with self . cached_session ( ) : <nl> dataset = keras_test_lib . get_dataset ( distribution ) <nl> def test_save_load_h5 ( self , distribution , optimizer ) : <nl> combinations . times ( <nl> keras_test_lib . all_strategy_combinations_minus_default ( ) , <nl> combinations . combine ( <nl> - optimizer = strategy_combinations . rmsprop_optimizer_keras_v2_fn ) ) ) <nl> + optimizer = optimizer_combinations . rmsprop_optimizer_keras_v2_fn ) ) ) <nl> def test_save_load_trackable ( self , distribution , optimizer ) : <nl> # TODO ( b / 123533246 ) : Enable the test for TPU once bug is fixed <nl> if ( isinstance ( distribution , <nl> similarity index 94 % <nl> rename from tensorflow / python / distribute / minimize_loss_test . py <nl> rename to tensorflow / python / keras / distribute / minimize_loss_test . py <nl> mmm a / tensorflow / python / distribute / minimize_loss_test . py <nl> ppp b / tensorflow / python / keras / distribute / minimize_loss_test . py <nl> <nl> from tensorflow . python . framework import constant_op <nl> from tensorflow . python . framework import dtypes <nl> from tensorflow . python . framework import ops <nl> + from tensorflow . python . keras . distribute import optimizer_combinations <nl> from tensorflow . python . ops import array_ops <nl> from tensorflow . python . ops import control_flow_ops <nl> from tensorflow . python . ops import control_flow_v2_toggles <nl> def _get_iterator ( self , strategy , input_fn ) : <nl> <nl> @ combinations . generate ( <nl> combinations . times ( <nl> - strategy_combinations . distributions_and_v1_optimizers ( ) , <nl> + optimizer_combinations . distributions_and_v1_optimizers ( ) , <nl> combinations . combine ( mode = [ " graph " ] , use_callable_loss = [ True , False ] ) <nl> + combinations . combine ( mode = [ " eager " ] , use_callable_loss = [ True ] ) ) + <nl> combinations . times ( <nl> - strategy_combinations . distributions_and_v2_optimizers ( ) , <nl> + optimizer_combinations . distributions_and_v2_optimizers ( ) , <nl> combinations . combine ( <nl> mode = [ " graph " , " eager " ] , use_callable_loss = [ True ] ) ) + <nl> combinations . combine ( <nl> distribution = [ strategy_combinations . tpu_strategy ] , <nl> - optimizer_fn = strategy_combinations . optimizers_v2 , <nl> + optimizer_fn = optimizer_combinations . optimizers_v2 , <nl> mode = [ " graph " ] , <nl> use_callable_loss = [ True ] ) + combinations . combine ( <nl> distribution = [ strategy_combinations . tpu_strategy ] , <nl> - optimizer_fn = strategy_combinations . optimizers_v1 , <nl> + optimizer_fn = optimizer_combinations . optimizers_v1 , <nl> mode = [ " graph " ] , <nl> use_callable_loss = [ True , False ] ) ) <nl> def testTrainNetwork ( self , distribution , optimizer_fn , use_callable_loss ) : <nl> def run_step ( ) : <nl> <nl> @ combinations . generate ( <nl> combinations . times ( <nl> - strategy_combinations . distributions_and_v1_optimizers ( ) , <nl> + optimizer_combinations . distributions_and_v1_optimizers ( ) , <nl> combinations . combine ( mode = [ " graph " ] , use_callable_loss = [ True , False ] ) <nl> + combinations . combine ( mode = [ " eager " ] , use_callable_loss = [ True ] ) ) + <nl> combinations . times ( <nl> - strategy_combinations . distributions_and_v2_optimizers ( ) , <nl> + optimizer_combinations . distributions_and_v2_optimizers ( ) , <nl> combinations . combine ( <nl> mode = [ " graph " , " eager " ] , use_callable_loss = [ True ] ) ) ) <nl> def testTrainNetworkByCallForEachReplica ( self , distribution , optimizer_fn , <nl> def run_step ( ) : <nl> <nl> @ combinations . generate ( <nl> combinations . times ( <nl> - strategy_combinations . distributions_and_v1_and_v2_optimizers ( ) , <nl> + optimizer_combinations . distributions_and_v1_and_v2_optimizers ( ) , <nl> combinations . combine ( mode = [ " graph " , " eager " ] ) ) + combinations . combine ( <nl> distribution = [ strategy_combinations . tpu_strategy ] , <nl> - optimizer_fn = strategy_combinations . optimizers_v1_and_v2 , <nl> + optimizer_fn = optimizer_combinations . optimizers_v1_and_v2 , <nl> mode = [ " graph " ] ) ) <nl> def testOptimizerInsideModelFn ( self , distribution , optimizer_fn ) : <nl> if ( not context . executing_eagerly ( ) and <nl> def get_expected_variables ( num_parameter_devices ) : <nl> combinations . times ( <nl> combinations . combine ( momentum = [ 0 . 8 , 0 . 9 , 0 . 99 ] , renorm = [ False , True ] ) , <nl> combinations . times ( <nl> - strategy_combinations . distributions_and_v1_and_v2_optimizers ( ) , <nl> + optimizer_combinations . distributions_and_v1_and_v2_optimizers ( ) , <nl> combinations . combine ( <nl> mode = [ " graph " , " eager " ] , <nl> # TODO ( isaprykin ) : Allow False here . Currently subsequent <nl> def get_expected_variables ( num_parameter_devices ) : <nl> update_ops_in_cross_replica_mode = [ True ] ) ) + <nl> combinations . combine ( <nl> distribution = [ strategy_combinations . tpu_strategy ] , <nl> - optimizer_fn = strategy_combinations . optimizers_v1_and_v2 , <nl> + optimizer_fn = optimizer_combinations . optimizers_v1_and_v2 , <nl> mode = [ " graph " ] , <nl> update_ops_in_cross_replica_mode = [ False ] ) ) ) <nl> def testTrainNetworkWithBatchNorm ( self , distribution , optimizer_fn , momentum , <nl> def averaged_batch_mean ( i ) : <nl> strategy_combinations . mirrored_strategy_with_two_gpus <nl> ] ) , <nl> combinations . times ( <nl> - combinations . combine ( optimizer_fn = strategy_combinations <nl> + combinations . combine ( optimizer_fn = optimizer_combinations <nl> . gradient_descent_optimizer_v1_fn ) , <nl> combinations . combine ( <nl> mode = [ " graph " ] , use_callable_loss = [ True , False ] ) + <nl> combinations . combine ( <nl> mode = [ " eager " ] , use_callable_loss = [ True ] ) ) + <nl> combinations . times ( <nl> - combinations . combine ( optimizer_fn = strategy_combinations <nl> + combinations . combine ( optimizer_fn = optimizer_combinations <nl> . gradient_descent_optimizer_keras_v2_fn ) , <nl> combinations . combine ( <nl> mode = [ " graph " , " eager " ] , use_callable_loss = [ True ] ) ) ) + <nl> combinations . combine ( <nl> distribution = [ strategy_combinations . tpu_strategy ] , <nl> - optimizer_fn = strategy_combinations <nl> + optimizer_fn = optimizer_combinations <nl> . gradient_descent_optimizer_v1_fn , <nl> mode = [ " graph " ] , <nl> use_callable_loss = [ True , False ] ) + combinations . combine ( <nl> distribution = [ strategy_combinations . tpu_strategy ] , <nl> - optimizer_fn = strategy_combinations <nl> + optimizer_fn = optimizer_combinations <nl> . gradient_descent_optimizer_keras_v2_fn , <nl> mode = [ " graph " ] , <nl> use_callable_loss = [ True ] ) ) ) <nl> def run_step ( ) : <nl> <nl> @ combinations . generate ( <nl> combinations . times ( <nl> - strategy_combinations . distributions_and_v1_and_v2_optimizers ( ) , <nl> + optimizer_combinations . distributions_and_v1_and_v2_optimizers ( ) , <nl> combinations . combine ( mode = [ " graph " , " eager " ] ) , <nl> combinations . combine ( is_tpu = [ False ] ) ) + combinations . combine ( <nl> distribution = [ strategy_combinations . tpu_strategy ] , <nl> - optimizer_fn = strategy_combinations . optimizers_v1_and_v2 , <nl> + optimizer_fn = optimizer_combinations . optimizers_v1_and_v2 , <nl> mode = [ " graph " ] , <nl> is_tpu = [ True ] ) ) <nl> def testRunStepsWithOutputContext ( self , distribution , optimizer_fn , is_tpu ) : <nl> def _verify_loss_output ( self , initial_loss , loss_output , reduced , <nl> self . assertEqual ( initial_loss . shape , loss_tensor . shape ) <nl> <nl> @ combinations . generate ( <nl> - strategy_combinations . distributions_and_v2_optimizers ( ) ) <nl> + optimizer_combinations . distributions_and_v2_optimizers ( ) ) <nl> def test_empty_var_list ( self , distribution , optimizer_fn ) : <nl> opt = optimizer_fn ( ) <nl> with distribution . scope ( ) : <nl> new file mode 100644 <nl> index 0000000000000 . . 495ee6c045696 <nl> mmm / dev / null <nl> ppp b / tensorflow / python / keras / distribute / optimizer_combinations . py <nl> <nl> + # Copyright 2018 The TensorFlow Authors . All Rights Reserved . <nl> + # <nl> + # Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + # you may not use this file except in compliance with the License . <nl> + # You may obtain a copy of the License at <nl> + # <nl> + # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + # <nl> + # Unless required by applicable law or agreed to in writing , software <nl> + # distributed under the License is distributed on an " AS IS " BASIS , <nl> + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + # See the License for the specific language governing permissions and <nl> + # limitations under the License . <nl> + # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + " " " Strategy and optimizer combinations for combinations . combine ( ) . " " " <nl> + <nl> + from __future__ import absolute_import <nl> + from __future__ import division <nl> + from __future__ import print_function <nl> + <nl> + from tensorflow . python . distribute import combinations <nl> + from tensorflow . python . distribute import strategy_combinations as strategy_combinations_base <nl> + from tensorflow . python . keras . optimizer_v2 import adadelta as adadelta_keras_v2 <nl> + from tensorflow . python . keras . optimizer_v2 import adagrad as adagrad_keras_v2 <nl> + from tensorflow . python . keras . optimizer_v2 import adam as adam_keras_v2 <nl> + from tensorflow . python . keras . optimizer_v2 import adamax as adamax_keras_v2 <nl> + from tensorflow . python . keras . optimizer_v2 import ftrl as ftrl_keras_v2 <nl> + from tensorflow . python . keras . optimizer_v2 import gradient_descent as gradient_descent_keras_v2 <nl> + from tensorflow . python . keras . optimizer_v2 import nadam as nadam_keras_v2 <nl> + from tensorflow . python . keras . optimizer_v2 import rmsprop as rmsprop_keras_v2 <nl> + from tensorflow . python . training import adagrad <nl> + from tensorflow . python . training import adam <nl> + from tensorflow . python . training import ftrl <nl> + from tensorflow . python . training import gradient_descent <nl> + from tensorflow . python . training import rmsprop <nl> + <nl> + <nl> + gradient_descent_optimizer_v1_fn = combinations . NamedObject ( <nl> + " GradientDescentV1 " , <nl> + lambda : gradient_descent . GradientDescentOptimizer ( 0 . 001 ) ) <nl> + adagrad_optimizer_v1_fn = combinations . NamedObject ( <nl> + " AdagradV1 " , lambda : adagrad . AdagradOptimizer ( 0 . 001 ) ) <nl> + adam_optimizer_v1_fn = combinations . NamedObject ( <nl> + " AdamV1 " , lambda : adam . AdamOptimizer ( 0 . 001 , epsilon = 1 ) ) <nl> + ftrl_optimizer_v1_fn = combinations . NamedObject ( <nl> + " FtrlV1 " , lambda : ftrl . FtrlOptimizer ( 0 . 001 ) ) <nl> + rmsprop_optimizer_v1_fn = combinations . NamedObject ( <nl> + " RmsPropV1 " , lambda : rmsprop . RMSPropOptimizer ( 0 . 001 ) ) <nl> + <nl> + # TODO ( shiningsun ) : consider adding the other v1 optimizers <nl> + optimizers_v1 = [ <nl> + gradient_descent_optimizer_v1_fn , adagrad_optimizer_v1_fn , <nl> + ftrl_optimizer_v1_fn , rmsprop_optimizer_v1_fn <nl> + ] <nl> + <nl> + adadelta_optimizer_keras_v2_fn = combinations . NamedObject ( <nl> + " AdadeltaKerasV2 " , lambda : adadelta_keras_v2 . Adadelta ( 0 . 001 ) ) <nl> + adagrad_optimizer_keras_v2_fn = combinations . NamedObject ( <nl> + " AdagradKerasV2 " , lambda : adagrad_keras_v2 . Adagrad ( 0 . 001 ) ) <nl> + adam_optimizer_keras_v2_fn = combinations . NamedObject ( <nl> + " AdamKerasV2 " , lambda : adam_keras_v2 . Adam ( 0 . 001 , epsilon = 1 . 0 ) ) <nl> + adamax_optimizer_keras_v2_fn = combinations . NamedObject ( <nl> + " AdamaxKerasV2 " , lambda : adamax_keras_v2 . Adamax ( 0 . 001 , epsilon = 1 . 0 ) ) <nl> + nadam_optimizer_keras_v2_fn = combinations . NamedObject ( <nl> + " NadamKerasV2 " , lambda : nadam_keras_v2 . Nadam ( 0 . 001 , epsilon = 1 . 0 ) ) <nl> + ftrl_optimizer_keras_v2_fn = combinations . NamedObject ( <nl> + " FtrlKerasV2 " , lambda : ftrl_keras_v2 . Ftrl ( 0 . 001 ) ) <nl> + gradient_descent_optimizer_keras_v2_fn = combinations . NamedObject ( <nl> + " GradientDescentKerasV2 " , lambda : gradient_descent_keras_v2 . SGD ( 0 . 001 ) ) <nl> + rmsprop_optimizer_keras_v2_fn = combinations . NamedObject ( <nl> + " RmsPropKerasV2 " , lambda : rmsprop_keras_v2 . RMSprop ( 0 . 001 ) ) <nl> + <nl> + # TODO ( shiningsun ) : consider adding the other v2 optimizers <nl> + optimizers_v2 = [ <nl> + gradient_descent_optimizer_keras_v2_fn , adagrad_optimizer_keras_v2_fn <nl> + ] <nl> + <nl> + optimizers_v1_and_v2 = optimizers_v1 + optimizers_v2 <nl> + <nl> + <nl> + def distributions_and_v1_optimizers ( ) : <nl> + " " " A common set of combination with DistributionStrategies and Optimizers . " " " <nl> + return combinations . combine ( <nl> + distribution = [ <nl> + strategy_combinations_base . one_device_strategy , <nl> + strategy_combinations_base . mirrored_strategy_with_gpu_and_cpu , <nl> + strategy_combinations_base . mirrored_strategy_with_two_gpus , <nl> + ] , <nl> + optimizer_fn = optimizers_v1 ) <nl> + <nl> + <nl> + def distributions_and_v2_optimizers ( ) : <nl> + " " " A common set of combination with DistributionStrategies and Optimizers . " " " <nl> + return combinations . combine ( <nl> + distribution = [ <nl> + strategy_combinations_base . one_device_strategy , <nl> + strategy_combinations_base . mirrored_strategy_with_gpu_and_cpu , <nl> + strategy_combinations_base . mirrored_strategy_with_two_gpus , <nl> + ] , <nl> + optimizer_fn = optimizers_v2 ) <nl> + <nl> + <nl> + def distributions_and_v1_and_v2_optimizers ( ) : <nl> + " " " A common set of combination with DistributionStrategies and Optimizers . " " " <nl> + return combinations . combine ( <nl> + distribution = [ <nl> + strategy_combinations_base . one_device_strategy , <nl> + strategy_combinations_base . mirrored_strategy_with_gpu_and_cpu , <nl> + strategy_combinations_base . mirrored_strategy_with_two_gpus , <nl> + ] , <nl> + optimizer_fn = optimizers_v1_and_v2 ) <nl> similarity index 92 % <nl> rename from tensorflow / python / distribute / step_fn_test . py <nl> rename to tensorflow / python / keras / distribute / step_fn_test . py <nl> mmm a / tensorflow / python / distribute / step_fn_test . py <nl> ppp b / tensorflow / python / keras / distribute / step_fn_test . py <nl> <nl> from tensorflow . python . eager import context <nl> from tensorflow . python . eager import test <nl> from tensorflow . python . framework import test_util <nl> + from tensorflow . python . keras . distribute import optimizer_combinations <nl> from tensorflow . python . ops import variables <nl> <nl> <nl> class SingleLossStepTest ( test . TestCase , parameterized . TestCase ) : <nl> <nl> @ combinations . generate ( <nl> combinations . times ( <nl> - strategy_combinations . distributions_and_v1_optimizers ( ) , <nl> + optimizer_combinations . distributions_and_v1_optimizers ( ) , <nl> combinations . combine ( <nl> mode = strategy_combinations . graph_and_eager_modes ) , <nl> combinations . combine ( is_tpu = [ False ] ) ) + combinations . combine ( <nl> distribution = [ strategy_combinations . tpu_strategy ] , <nl> - optimizer_fn = strategy_combinations . optimizers_v1 , <nl> + optimizer_fn = optimizer_combinations . optimizers_v1 , <nl> mode = [ " graph " ] , <nl> is_tpu = [ True ] ) ) <nl> def testTrainNetwork ( self , distribution , optimizer_fn , is_tpu ) : <nl>
|
Move the optimizer related combination / tests to keras / distribute .
|
tensorflow/tensorflow
|
393242481acb5bfb3bbd8ae074499888d5432ef2
|
2020-07-09T19:46:35Z
|
mmm a / hphp / hack / src / hhbc / emit_statement . ml <nl> ppp b / hphp / hack / src / hhbc / emit_statement . ml <nl> let rec emit_stmt env st = <nl> instr_popc ; <nl> ] <nl> | A . Expr ( _ , A . Binop ( A . Eq None , e_lhs , ( _ , A . Await e_await ) ) ) - > <nl> + let result = Local . scope @ @ fun ( ) - > emit_await env e_await in <nl> Local . scope @ @ fun ( ) - > <nl> let temp = Local . get_unnamed_local ( ) in <nl> let rhs_instrs = instr_pushl temp in <nl> let ( lhs , rhs , setop ) = <nl> emit_lval_op_nonlist_steps env LValOp . Set e_lhs rhs_instrs 1 in <nl> gather [ <nl> - emit_await env e_await ; <nl> + result ; <nl> instr_setl temp ; <nl> instr_popc ; <nl> with_temp_local temp ( fun _ _ - > lhs ) ; <nl>
|
use separate scope to evaluate right hand side of await
|
facebook/hhvm
|
5d5b0adac50c565c9dff6abc2d4847ef98aab98c
|
2017-09-21T01:27:18Z
|
mmm a / docs / TypeChecker . rst <nl> ppp b / docs / TypeChecker . rst <nl> and types generated from the primary expression kinds are : <nl> <nl> * * Subscripting * * <nl> A subscript operation ` ` a [ b ] ` ` is similar to function <nl> - application . A value member constraint ` ` T ( a ) . __subscript = = T0 - > T1 ` ` <nl> + application . A value member constraint ` ` T ( a ) . subscript = = T0 - > T1 ` ` <nl> treats the subscript as a function from the key type to the <nl> value type , represented by fresh type variables ` ` T0 ` ` and ` ` T1 ` ` , <nl> respectively . The constraint ` ` T ( b ) < c T0 ` ` requires the key <nl> mmm a / lib / ClangImporter / ClangImporter . cpp <nl> ppp b / lib / ClangImporter / ClangImporter . cpp <nl> static void lookupClassMembersImpl ( ClangImporter : : Implementation & Impl , <nl> clang : : IdentifierInfo * setObjectId = nullptr ; <nl> clang : : IdentifierInfo * atIndexedSubscriptId = nullptr ; <nl> clang : : IdentifierInfo * forKeyedSubscriptId = nullptr ; <nl> - bool isSubscript = ! name . empty ( ) & & name . str ( ) . equals ( " __subscript " ) ; <nl> + bool isSubscript = ! name . empty ( ) & & name . str ( ) . equals ( " subscript " ) ; <nl> if ( isSubscript ) { <nl> auto & identTable = S . Context . Idents ; <nl> objectAtIndexedSubscriptId = & identTable . get ( " objectAtIndexedSubscript " ) ; <nl> mmm a / lib / ClangImporter / ImportDecl . cpp <nl> ppp b / lib / ClangImporter / ImportDecl . cpp <nl> namespace { <nl> / / Build the subscript declaration . <nl> auto argPatterns = <nl> getterThunk - > getArgParamPatterns ( ) [ 1 ] - > clone ( context ) ; <nl> - auto name = context . getIdentifier ( " __subscript " ) ; <nl> + auto name = context . getIdentifier ( " subscript " ) ; <nl> auto subscript <nl> = new ( context ) SubscriptDecl ( name , decl - > getLoc ( ) , argPatterns , <nl> decl - > getLoc ( ) , <nl> mmm a / lib / Parse / ParseDecl . cpp <nl> ppp b / lib / Parse / ParseDecl . cpp <nl> ParserStatus Parser : : parseDeclSubscript ( bool HasContainerType , <nl> <nl> / / Build an AST for the subscript declaration . <nl> SubscriptDecl * Subscript <nl> - = new ( Context ) SubscriptDecl ( Context . getIdentifier ( " __subscript " ) , <nl> + = new ( Context ) SubscriptDecl ( Context . getIdentifier ( " subscript " ) , <nl> SubscriptLoc , Indices . get ( ) , ArrowLoc , <nl> ElementTy . get ( ) , DefRange , <nl> Get , Set , CurDeclContext ) ; <nl> mmm a / lib / Parse / ParseSIL . cpp <nl> ppp b / lib / Parse / ParseSIL . cpp <nl> bool SILParser : : parseSILIdentifier ( Identifier & Result , SourceLoc & Loc , <nl> switch ( P . Tok . getKind ( ) ) { <nl> case tok : : identifier : <nl> Result = P . Context . getIdentifier ( P . Tok . getText ( ) ) ; <nl> - Loc = P . Tok . getLoc ( ) ; <nl> - P . consumeToken ( ) ; <nl> - return false ; <nl> + break ; <nl> case tok : : kw_constructor : <nl> case tok : : kw_init : <nl> Result = P . Context . getIdentifier ( " init " ) ; <nl> - Loc = P . Tok . getLoc ( ) ; <nl> - P . consumeToken ( ) ; <nl> - return false ; <nl> + break ; <nl> + case tok : : kw_subscript : <nl> + Result = P . Context . getIdentifier ( " subscript " ) ; <nl> + break ; <nl> default : <nl> P . diagnose ( P . Tok , D ) ; <nl> return true ; <nl> } <nl> + <nl> + Loc = P . Tok . getLoc ( ) ; <nl> + P . consumeToken ( ) ; <nl> + return false ; <nl> } <nl> <nl> / / / diagnoseProblems - After a function is fully parse , emit any diagnostics <nl> mmm a / lib / Sema / TypeCheckConstraintsGen . cpp <nl> ppp b / lib / Sema / TypeCheckConstraintsGen . cpp <nl> namespace { <nl> / / FIXME : lame name ! <nl> auto baseTy = base - > getType ( ) ; <nl> auto fnTy = FunctionType : : get ( inputTv , outputTv , Context ) ; <nl> - CS . addValueMemberConstraint ( baseTy , Context . getIdentifier ( " __subscript " ) , <nl> + CS . addValueMemberConstraint ( baseTy , Context . getIdentifier ( " subscript " ) , <nl> fnTy , <nl> CS . getConstraintLocator ( expr , <nl> ConstraintLocator : : SubscriptMember ) ) ; <nl> mmm a / lib / Serialization / Deserialization . cpp <nl> ppp b / lib / Serialization / Deserialization . cpp <nl> Decl * ModuleFile : : getDecl ( DeclID DID , Optional < DeclContext * > ForcedContext , <nl> auto getter = cast_or_null < FuncDecl > ( getDecl ( getterID ) ) ; <nl> auto setter = cast_or_null < FuncDecl > ( getDecl ( setterID ) ) ; <nl> <nl> - auto subscript = new ( ctx ) SubscriptDecl ( ctx . getIdentifier ( " __subscript " ) , <nl> + auto subscript = new ( ctx ) SubscriptDecl ( ctx . getIdentifier ( " subscript " ) , <nl> SourceLoc ( ) , indices , SourceLoc ( ) , <nl> elemTy , SourceRange ( ) , <nl> getter , setter , DC ) ; <nl> mmm a / stdlib / objc / Foundation / BridgeNSString . mm <nl> ppp b / stdlib / objc / Foundation / BridgeNSString . mm <nl> <nl> _TSS4sizefRSSFT_Si ( void * swiftString ) ; <nl> <nl> uint32_t <nl> - _TSS11__subscriptFT3idxSi_Scg ( uint64_t idx , void * swiftString ) ; <nl> + _TSS9subscriptFT3idxSi_Scg ( uint64_t idx , void * swiftString ) ; <nl> <nl> void <nl> swift_NSStringToString ( NSString * nsstring , SwiftString * string ) ; <nl> - ( unichar ) characterAtIndex : ( NSUInteger ) idx { <nl> / / XXX FIXME <nl> / / Become bug - for - bug compatible with NSString being UTF16 . <nl> / / In practice , this API is oblivious to UTF16 surrogate pairs . <nl> - return _TSS11__subscriptFT3idxSi_Scg ( idx , & swiftString ) ; <nl> + return _TSS9subscriptFT3idxSi_Scg ( idx , & swiftString ) ; <nl> } <nl> <nl> - ( NSUInteger ) length { <nl> mmm a / test / IRGen / dynamic_lookup . sil <nl> ppp b / test / IRGen / dynamic_lookup . sil <nl> bb0 ( % 0 : $ X . metatype ) : <nl> return % 14 : $ ( ) <nl> } <nl> <nl> - sil @ _TToC14dynamic_lookup1X11__subscriptFT1iSi_Sig : $ [ cc ( objc_method ) , thin ] ( ( ) , ( i : Int64 ) , X ) - > Int64 { <nl> + sil @ _TToC14dynamic_lookup1X9subscriptFT1iSi_Sig : $ [ cc ( objc_method ) , thin ] ( ( ) , ( i : Int64 ) , X ) - > Int64 { <nl> bb0 ( % 0 : $ Int64 , % 1 : $ X ) : <nl> % 4 = function_ref @ _TSi33_convertFromBuiltinIntegerLiteralfMSiFT3valBi64__Si : $ [ thin ] ( ( val : Builtin . Int64 ) , Int64 . metatype ) - > Int64 / / user : % 7 <nl> % 5 = metatype $ Int64 . metatype / / user : % 7 <nl> bb0 ( % 0 : $ DynamicLookup , % 1 : $ Int64 ) : <nl> / / CHECK - NEXT : [ [ HAS_SEL : % [ 0 - 9 ] + ] ] = call i1 @ swift_objcRespondsToSelector ( % objc_object * % 0 , i8 * [ [ SEL ] ] ) # 0 <nl> / / CHECK - NEXT : br i1 [ [ HAS_SEL ] ] , label [ [ HAS_METHOD : % [ 0 - 9 ] + ] ] , label [ [ HAS_METHOD : % [ 0 - 9 ] + ] ] <nl> <nl> - dynamic_method_br % 11 : $ Builtin . ObjCPointer , # X . __subscript ! getter . 2 . foreign , bb1 , bb2 <nl> + dynamic_method_br % 11 : $ Builtin . ObjCPointer , # X . subscript ! getter . 2 . foreign , bb1 , bb2 <nl> <nl> bb1 ( % 13 : $ [ cc ( objc_method ) , thin ] ( ( ) , ( i : Int64 ) , Builtin . ObjCPointer ) - > Int64 ) : / / Preds : bb0 <nl> % 14 = partial_apply % 13 ( % 11 ) : $ [ cc ( objc_method ) , thin ] ( ( ) , ( i : Int64 ) , Builtin . ObjCPointer ) - > Int64 <nl>
|
Rename ' __subscript ' - > ' subscript ' .
|
apple/swift
|
f0773bcba1e25a11f86297bae484c092afcdf642
|
2013-09-30T19:17:29Z
|
mmm a / include / swift / AST / ASTNode . h <nl> ppp b / include / swift / AST / ASTNode . h <nl> <nl> # define SWIFT_AST_AST_NODE_H <nl> <nl> # include " llvm / ADT / PointerUnion . h " <nl> - # include " swift / AST / SourceEntityWalker . h " <nl> # include " swift / AST / TypeAlignments . h " <nl> <nl> namespace swift { <nl> namespace swift { <nl> void walk ( ASTWalker & Walker ) ; <nl> void walk ( ASTWalker & & walker ) { walk ( walker ) ; } <nl> <nl> - void walk ( SourceEntityWalker & Walker ) ; <nl> - void walk ( SourceEntityWalker & & walker ) { walk ( walker ) ; } <nl> - <nl> / / / \ brief get the underlying entity as a decl context if it is one , <nl> / / / otherwise , return nullptr ; <nl> DeclContext * getAsDeclContext ( ) const ; <nl> similarity index 94 % <nl> rename from include / swift / AST / SourceEntityWalker . h <nl> rename to include / swift / IDE / SourceEntityWalker . h <nl> mmm a / include / swift / AST / SourceEntityWalker . h <nl> ppp b / include / swift / IDE / SourceEntityWalker . h <nl> <nl> / / <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> <nl> - # ifndef SWIFT_AST_SOURCE_ENTITY_WALKER_H <nl> - # define SWIFT_AST_SOURCE_ENTITY_WALKER_H <nl> + # ifndef SWIFT_IDE_SOURCE_ENTITY_WALKER_H <nl> + # define SWIFT_IDE_SOURCE_ENTITY_WALKER_H <nl> <nl> # include " swift / AST / ASTWalker . h " <nl> # include " swift / Basic / LLVM . h " <nl> namespace swift { <nl> class Stmt ; <nl> class Expr ; <nl> class Type ; <nl> + struct ASTNode ; <nl> <nl> <nl> / / / An abstract class used to traverse the AST and provide source information . <nl> class SourceEntityWalker { <nl> / / / Walks the provided Expr . <nl> / / / \ returns true if traversal was aborted , false otherwise . <nl> bool walk ( Expr * E ) ; <nl> + / / / Walks the provided ASTNode . <nl> + / / / \ returns true if traversal was aborted , false otherwise . <nl> + bool walk ( ASTNode N ) ; <nl> <nl> / / / This method is called when first visiting a decl , before walking into its <nl> / / / children . If it returns false , the subtree is skipped . <nl> class SourceEntityWalker { <nl> / / / <nl> / / / \ param D the referenced decl . <nl> / / / \ param Range the source range of the source reference . <nl> + / / / \ param AccKind whether this is a read , write or read / write access . <nl> / / / \ param IsOpenBracket this is \ c true when the method is called on an <nl> / / / open bracket . <nl> virtual bool visitSubscriptReference ( ValueDecl * D , CharSourceRange Range , <nl> + Optional < AccessKind > AccKind , <nl> bool IsOpenBracket ) ; <nl> <nl> / / / This method is called for each keyword argument in a call expression . <nl> mmm a / include / swift / IDE / Utils . h <nl> ppp b / include / swift / IDE / Utils . h <nl> <nl> # include " swift / AST / DeclNameLoc . h " <nl> # include " swift / AST / Module . h " <nl> # include " swift / AST / ASTPrinter . h " <nl> - # include " swift / AST / SourceEntityWalker . h " <nl> + # include " swift / IDE / SourceEntityWalker . h " <nl> # include " swift / Parse / Token . h " <nl> # include " llvm / ADT / StringRef . h " <nl> # include < memory > <nl> class CursorInfoResolver : public SourceEntityWalker { <nl> bool tryResolve ( ModuleEntity Mod , SourceLoc Loc ) ; <nl> bool tryResolve ( Stmt * St ) ; <nl> bool visitSubscriptReference ( ValueDecl * D , CharSourceRange Range , <nl> + Optional < AccessKind > AccKind , <nl> bool IsOpenBracket ) override ; <nl> } ; <nl> <nl> mmm a / lib / AST / ASTNode . cpp <nl> ppp b / lib / AST / ASTNode . cpp <nl> void ASTNode : : walk ( ASTWalker & Walker ) { <nl> else <nl> llvm_unreachable ( " unsupported AST node " ) ; <nl> } <nl> - void ASTNode : : walk ( SourceEntityWalker & Walker ) { <nl> - if ( auto * E = this - > dyn_cast < Expr * > ( ) ) <nl> - Walker . walk ( E ) ; <nl> - else if ( auto * S = this - > dyn_cast < Stmt * > ( ) ) <nl> - Walker . walk ( S ) ; <nl> - else if ( auto * D = this - > dyn_cast < Decl * > ( ) ) <nl> - Walker . walk ( D ) ; <nl> - else <nl> - llvm_unreachable ( " unsupported AST node " ) ; <nl> - } <nl> <nl> # define FUNC ( T ) \ <nl> bool ASTNode : : is # # T ( T # # Kind Kind ) const { \ <nl> mmm a / lib / AST / CMakeLists . txt <nl> ppp b / lib / AST / CMakeLists . txt <nl> add_swift_library ( swiftAST STATIC <nl> SyntaxASTMap . cpp <nl> SILLayout . cpp <nl> Stmt . cpp <nl> - SourceEntityWalker . cpp <nl> Substitution . cpp <nl> SubstitutionList . cpp <nl> SubstitutionMap . cpp <nl> mmm a / lib / IDE / CMakeLists . txt <nl> ppp b / lib / IDE / CMakeLists . txt <nl> add_swift_library ( swiftIDE STATIC <nl> Utils . cpp <nl> IDETypeChecking . cpp <nl> APIDigesterData . cpp <nl> + SourceEntityWalker . cpp <nl> DEPENDS <nl> swift - syntax - generated - headers <nl> LINK_LIBRARIES <nl> mmm a / lib / IDE / Formatting . cpp <nl> ppp b / lib / IDE / Formatting . cpp <nl> <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> <nl> # include " swift / AST / ASTWalker . h " <nl> - # include " swift / AST / SourceEntityWalker . h " <nl> + # include " swift / IDE / SourceEntityWalker . h " <nl> # include " swift / Parse / Parser . h " <nl> # include " swift / Frontend / Frontend . h " <nl> # include " swift / Basic / SourceManager . h " <nl> mmm a / lib / IDE / Refactoring . cpp <nl> ppp b / lib / IDE / Refactoring . cpp <nl> ExtractCheckResult checkExtractConditions ( ResolvedRangeInfo & RangeInfo , <nl> <nl> / / We cannot extract expressions of l - value type . <nl> if ( auto Ty = RangeInfo . getType ( ) ) { <nl> - if ( Ty - > hasLValueType ( ) | | Ty - > getKind ( ) = = TypeKind : : InOut ) <nl> + if ( Ty - > hasLValueType ( ) | | Ty - > is < InOutType > ( ) ) <nl> return ExtractCheckResult ( ) ; <nl> <nl> / / Disallow extracting error type expressions / statements <nl> static StringRef correctNewDeclName ( DeclContext * DC , StringRef Name ) { <nl> static Type sanitizeType ( Type Ty ) { <nl> / / Transform lvalue type to inout type so that we can print it properly . <nl> return Ty . transform ( [ ] ( Type Ty ) { <nl> - if ( Ty - > getKind ( ) = = TypeKind : : LValue ) { <nl> + if ( Ty - > is < LValueType > ( ) ) { <nl> return Type ( InOutType : : get ( Ty - > getRValueType ( ) - > getCanonicalType ( ) ) ) ; <nl> } <nl> return Ty ; <nl> bool RefactoringActionExtractFunction : : performChange ( ) { <nl> for ( auto & RD : Parameters ) { <nl> <nl> / / Inout argument needs " & " . <nl> - if ( RD . Ty - > getKind ( ) = = TypeKind : : InOut ) <nl> + if ( RD . Ty - > is < InOutType > ( ) ) <nl> OS < < " & " ; <nl> OS < < RD . VD - > getBaseName ( ) . userFacingName ( ) ; <nl> if ( & RD ! = & Parameters . back ( ) ) <nl> similarity index 94 % <nl> rename from lib / AST / SourceEntityWalker . cpp <nl> rename to lib / IDE / SourceEntityWalker . cpp <nl> mmm a / lib / AST / SourceEntityWalker . cpp <nl> ppp b / lib / IDE / SourceEntityWalker . cpp <nl> <nl> / / <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> <nl> - # include " swift / AST / SourceEntityWalker . h " <nl> + # include " swift / IDE / SourceEntityWalker . h " <nl> # include " swift / Parse / Lexer . h " <nl> # include " swift / AST / ASTContext . h " <nl> # include " swift / AST / ASTWalker . h " <nl> class SemaAnnotator : public ASTWalker { <nl> bool passReference ( ValueDecl * D , Type Ty , DeclNameLoc Loc , ReferenceMetaData Data ) ; <nl> bool passReference ( ModuleEntity Mod , std : : pair < Identifier , SourceLoc > IdLoc ) ; <nl> <nl> - bool passSubscriptReference ( ValueDecl * D , SourceLoc Loc , bool IsOpenBracket ) ; <nl> + bool passSubscriptReference ( ValueDecl * D , SourceLoc Loc , <nl> + Optional < AccessKind > AccKind , <nl> + bool IsOpenBracket ) ; <nl> <nl> bool passCallArgNames ( Expr * Fn , TupleExpr * TupleE ) ; <nl> <nl> std : : pair < bool , Expr * > SemaAnnotator : : walkToExprPre ( Expr * E ) { <nl> SubscrD = SE - > getDecl ( ) . getDecl ( ) ; <nl> <nl> if ( SubscrD ) { <nl> - if ( ! passSubscriptReference ( SubscrD , E - > getLoc ( ) , true ) ) <nl> + if ( ! passSubscriptReference ( SubscrD , E - > getLoc ( ) , OpAccess , true ) ) <nl> return { false , nullptr } ; <nl> } <nl> <nl> std : : pair < bool , Expr * > SemaAnnotator : : walkToExprPre ( Expr * E ) { <nl> return { false , nullptr } ; <nl> <nl> if ( SubscrD ) { <nl> - if ( ! passSubscriptReference ( SubscrD , E - > getEndLoc ( ) , false ) ) <nl> + if ( ! passSubscriptReference ( SubscrD , E - > getEndLoc ( ) , OpAccess , false ) ) <nl> return { false , nullptr } ; <nl> } <nl> <nl> bool SemaAnnotator : : passModulePathElements ( <nl> } <nl> <nl> bool SemaAnnotator : : passSubscriptReference ( ValueDecl * D , SourceLoc Loc , <nl> + Optional < AccessKind > AccKind , <nl> bool IsOpenBracket ) { <nl> CharSourceRange Range = Loc . isValid ( ) <nl> ? CharSourceRange ( Loc , 1 ) <nl> : CharSourceRange ( ) ; <nl> <nl> - bool Continue = SEWalker . visitSubscriptReference ( D , Range , IsOpenBracket ) ; <nl> + bool Continue = SEWalker . visitSubscriptReference ( D , Range , AccKind , <nl> + IsOpenBracket ) ; <nl> if ( ! Continue ) <nl> Cancelled = true ; <nl> return Continue ; <nl> bool SourceEntityWalker : : walk ( DeclContext * DC ) { <nl> return DC - > walkContext ( Annotator ) ; <nl> } <nl> <nl> + bool SourceEntityWalker : : walk ( ASTNode N ) { <nl> + if ( auto * E = N . dyn_cast < Expr * > ( ) ) <nl> + return walk ( E ) ; <nl> + if ( auto * S = N . dyn_cast < Stmt * > ( ) ) <nl> + return walk ( S ) ; <nl> + if ( auto * D = N . dyn_cast < Decl * > ( ) ) <nl> + return walk ( D ) ; <nl> + <nl> + llvm_unreachable ( " unsupported AST node " ) ; <nl> + } <nl> + <nl> bool SourceEntityWalker : : visitDeclReference ( ValueDecl * D , CharSourceRange Range , <nl> TypeDecl * CtorTyRef , <nl> ExtensionDecl * ExtTyRef , Type T , <nl> bool SourceEntityWalker : : visitDeclReference ( ValueDecl * D , CharSourceRange Range , <nl> <nl> bool SourceEntityWalker : : visitSubscriptReference ( ValueDecl * D , <nl> CharSourceRange Range , <nl> + Optional < AccessKind > AccKind , <nl> bool IsOpenBracket ) { <nl> / / Most of the clients treat subscript reference the same way as a <nl> / / regular reference when called on the open bracket and <nl> / / ignore the closing one . <nl> return IsOpenBracket ? visitDeclReference ( D , Range , nullptr , nullptr , Type ( ) , <nl> - ReferenceMetaData ( SemaReferenceKind : : SubscriptRef , None ) ) : true ; <nl> + ReferenceMetaData ( SemaReferenceKind : : SubscriptRef , AccKind ) ) : true ; <nl> } <nl> <nl> bool SourceEntityWalker : : visitCallArgName ( Identifier Name , <nl> mmm a / lib / IDE / SwiftSourceDocInfo . cpp <nl> ppp b / lib / IDE / SwiftSourceDocInfo . cpp <nl> bool CursorInfoResolver : : tryResolve ( Stmt * St ) { <nl> } <nl> <nl> bool CursorInfoResolver : : visitSubscriptReference ( ValueDecl * D , CharSourceRange Range , <nl> - bool IsOpenBracket ) { <nl> + Optional < AccessKind > AccKind , <nl> + bool IsOpenBracket ) { <nl> / / We should treat both open and close brackets equally <nl> return visitDeclReference ( D , Range , nullptr , nullptr , Type ( ) , <nl> - ReferenceMetaData ( SemaReferenceKind : : SubscriptRef , None ) ) ; <nl> + ReferenceMetaData ( SemaReferenceKind : : SubscriptRef , AccKind ) ) ; <nl> } <nl> <nl> ResolvedCursorInfo CursorInfoResolver : : resolve ( SourceLoc Loc ) { <nl> static bool hasUnhandledError ( ArrayRef < ASTNode > Nodes ) { <nl> <nl> return Nodes . end ( ) ! = std : : find_if ( Nodes . begin ( ) , Nodes . end ( ) , [ ] ( ASTNode N ) { <nl> ThrowingEntityAnalyzer Analyzer ; <nl> - N . walk ( Analyzer ) ; <nl> + Analyzer . walk ( N ) ; <nl> return Analyzer . isThrowing ( ) ; <nl> } ) ; <nl> } <nl> struct RangeResolver : : Implementation { <nl> void postAnalysis ( ASTNode EndNode ) { <nl> / / Visit the content of this node thoroughly , because the walker may <nl> / / abort early . <nl> - EndNode . walk ( CompleteWalker ( this ) ) ; <nl> + CompleteWalker ( this ) . walk ( EndNode ) ; <nl> <nl> / / Analyze whether declared decls in the range is referenced outside of it . <nl> FurtherReferenceWalker ( this ) . walk ( getImmediateContext ( ) ) ; <nl> struct RangeResolver : : Implementation { <nl> } ; <nl> for ( auto N : Nodes ) { <nl> ControlFlowStmtSelector TheWalker ; <nl> - N . walk ( TheWalker ) ; <nl> + TheWalker . walk ( N ) ; <nl> for ( auto Pair : TheWalker . Ranges ) { <nl> <nl> / / If the entire range does not include the target ' s range , we find <nl> mmm a / lib / Index / Index . cpp <nl> ppp b / lib / Index / Index . cpp <nl> <nl> # include " swift / AST / Expr . h " <nl> # include " swift / AST / Module . h " <nl> # include " swift / AST / ParameterList . h " <nl> - # include " swift / AST / SourceEntityWalker . h " <nl> # include " swift / AST / Types . h " <nl> # include " swift / AST / USRGeneration . h " <nl> # include " swift / Basic / SourceManager . h " <nl> # include " swift / Basic / StringExtras . h " <nl> + # include " swift / IDE / SourceEntityWalker . h " <nl> # include " swift / Markup / Markup . h " <nl> # include " swift / Sema / IDETypeChecking . h " <nl> # include " llvm / ADT / APInt . h " <nl> class IndexSwiftASTWalker : public SourceEntityWalker { <nl> <nl> IndexSymbol Info ; <nl> if ( CtorTyRef ) <nl> - if ( ! reportRef ( CtorTyRef , Loc , Info ) ) <nl> + if ( ! reportRef ( CtorTyRef , Loc , Info , Data . AccKind ) ) <nl> return false ; <nl> - if ( ! reportRef ( D , Loc , Info ) ) <nl> + if ( ! reportRef ( D , Loc , Info , Data . AccKind ) ) <nl> return false ; <nl> <nl> return true ; <nl> class IndexSwiftASTWalker : public SourceEntityWalker { <nl> <nl> bool report ( ValueDecl * D ) ; <nl> bool reportExtension ( ExtensionDecl * D ) ; <nl> - bool reportRef ( ValueDecl * D , SourceLoc Loc , IndexSymbol & Info ) ; <nl> + bool reportRef ( ValueDecl * D , SourceLoc Loc , IndexSymbol & Info , <nl> + Optional < AccessKind > AccKind ) ; <nl> <nl> bool startEntity ( Decl * D , IndexSymbol & Info ) ; <nl> bool startEntityDecl ( ValueDecl * D ) ; <nl> class IndexSwiftASTWalker : public SourceEntityWalker { <nl> bool initFuncDeclIndexSymbol ( FuncDecl * D , IndexSymbol & Info ) ; <nl> bool initFuncRefIndexSymbol ( ValueDecl * D , SourceLoc Loc , IndexSymbol & Info ) ; <nl> bool initVarRefIndexSymbols ( Expr * CurrentE , ValueDecl * D , SourceLoc Loc , <nl> - IndexSymbol & Info ) ; <nl> + IndexSymbol & Info , Optional < AccessKind > AccKind ) ; <nl> <nl> bool indexComment ( const Decl * D ) ; <nl> <nl> bool IndexSwiftASTWalker : : reportRelatedRef ( ValueDecl * D , SourceLoc Loc , bool isI <nl> / / don ' t report this ref again when visitDeclReference reports it <nl> repressRefAtLoc ( Loc ) ; <nl> <nl> - if ( ! reportRef ( D , Loc , Info ) ) { <nl> + if ( ! reportRef ( D , Loc , Info , None ) ) { <nl> Cancelled = true ; <nl> return false ; <nl> } <nl> bool IndexSwiftASTWalker : : reportRelatedTypeRef ( const TypeLoc & Ty , SymbolRoleSet <nl> if ( auto * VD = Comps . back ( ) - > getBoundDecl ( ) ) { <nl> if ( auto * TAD = dyn_cast < TypeAliasDecl > ( VD ) ) { <nl> IndexSymbol Info ; <nl> - if ( ! reportRef ( TAD , IdLoc , Info ) ) <nl> + if ( ! reportRef ( TAD , IdLoc , Info , None ) ) <nl> return false ; <nl> if ( auto Ty = TAD - > getUnderlyingTypeLoc ( ) . getType ( ) ) { <nl> NTD = Ty - > getAnyNominal ( ) ; <nl> static bool hasUsefulRoleInSystemModule ( SymbolRoleSet roles ) { <nl> } <nl> <nl> bool IndexSwiftASTWalker : : reportRef ( ValueDecl * D , SourceLoc Loc , <nl> - IndexSymbol & Info ) { <nl> + IndexSymbol & Info , <nl> + Optional < AccessKind > AccKind ) { <nl> if ( ! shouldIndex ( D , / * IsRef = * / true ) ) <nl> return true ; / / keep walking <nl> <nl> bool IndexSwiftASTWalker : : reportRef ( ValueDecl * D , SourceLoc Loc , <nl> if ( initFuncRefIndexSymbol ( D , Loc , Info ) ) <nl> return true ; <nl> } else if ( isa < AbstractStorageDecl > ( D ) ) { <nl> - if ( initVarRefIndexSymbols ( getCurrentExpr ( ) , D , Loc , Info ) ) <nl> + if ( initVarRefIndexSymbols ( getCurrentExpr ( ) , D , Loc , Info , AccKind ) ) <nl> return true ; <nl> } else { <nl> if ( initIndexSymbol ( D , Loc , / * IsRef = * / true , Info ) ) <nl> bool IndexSwiftASTWalker : : initFuncRefIndexSymbol ( ValueDecl * D , SourceLoc Loc , <nl> return false ; <nl> } <nl> <nl> - bool IndexSwiftASTWalker : : initVarRefIndexSymbols ( Expr * CurrentE , ValueDecl * D , SourceLoc Loc , IndexSymbol & Info ) { <nl> + bool IndexSwiftASTWalker : : initVarRefIndexSymbols ( Expr * CurrentE , ValueDecl * D , <nl> + SourceLoc Loc , IndexSymbol & Info , <nl> + Optional < AccessKind > AccKind ) { <nl> <nl> if ( initIndexSymbol ( D , Loc , / * IsRef = * / true , Info ) ) <nl> return true ; <nl> bool IndexSwiftASTWalker : : initVarRefIndexSymbols ( Expr * CurrentE , ValueDecl * D , S <nl> if ( ! CurrentE ) <nl> return false ; <nl> <nl> - AccessKind Kind = CurrentE - > hasLValueAccessKind ( ) ? CurrentE - > getLValueAccessKind ( ) : AccessKind : : Read ; <nl> + AccessKind Kind = AccKind . hasValue ( ) ? * AccKind : AccessKind : : Read ; <nl> switch ( Kind ) { <nl> case swift : : AccessKind : : Read : <nl> Info . roles | = ( unsigned ) SymbolRole : : Read ; <nl> mmm a / lib / Migrator / TupleSplatMigratorPass . cpp <nl> ppp b / lib / Migrator / TupleSplatMigratorPass . cpp <nl> <nl> # include " swift / AST / Module . h " <nl> # include " swift / AST / ParameterList . h " <nl> # include " swift / AST / Types . h " <nl> + # include " swift / IDE / SourceEntityWalker . h " <nl> # include " swift / Migrator / ASTMigratorPass . h " <nl> # include " swift / Parse / Lexer . h " <nl> <nl> mmm a / lib / Migrator / TypeOfMigratorPass . cpp <nl> ppp b / lib / Migrator / TypeOfMigratorPass . cpp <nl> <nl> # include " swift / AST / NameLookup . h " <nl> # include " swift / AST / ParameterList . h " <nl> # include " swift / AST / Types . h " <nl> + # include " swift / IDE / SourceEntityWalker . h " <nl> # include " swift / Migrator / ASTMigratorPass . h " <nl> # include " swift / Parse / Lexer . h " <nl> <nl> mmm a / lib / Parse / ParseType . cpp <nl> ppp b / lib / Parse / ParseType . cpp <nl> <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> <nl> # include " swift / Parse / Parser . h " <nl> + # include " swift / AST / ASTWalker . h " <nl> # include " swift / AST / Attr . h " <nl> # include " swift / AST / TypeLoc . h " <nl> # include " swift / Parse / Lexer . h " <nl> mmm a / lib / SILGen / SILGenExpr . cpp <nl> ppp b / lib / SILGen / SILGenExpr . cpp <nl> void SILGenFunction : : emitOpenExistentialExprImpl ( <nl> llvm : : function_ref < void ( Expr * ) > emitSubExpr ) { <nl> Optional < FormalEvaluationScope > writebackScope ; <nl> <nl> - Type opaqueValueType = E - > getOpaqueValue ( ) - > getType ( ) - > getRValueType ( ) ; <nl> - <nl> / / Emit the existential value . <nl> - SILGenFunction : : OpaqueValueState state ; <nl> - <nl> - AccessKind accessKind ; <nl> if ( E - > getExistentialValue ( ) - > getType ( ) - > is < LValueType > ( ) ) { <nl> - / / Create a writeback scope for the access to the existential lvalue . <nl> - writebackScope . emplace ( * this ) ; <nl> - <nl> - Type formalRValueType = <nl> - E - > getOpaqueValue ( ) - > getType ( ) - > getWithoutSpecifierType ( ) ; <nl> - <nl> - accessKind = E - > getExistentialValue ( ) - > getLValueAccessKind ( ) ; <nl> - auto lv = emitLValue ( E - > getExistentialValue ( ) , accessKind ) ; <nl> - lv = emitOpenExistentialLValue ( E , std : : move ( lv ) , <nl> - CanArchetypeType ( E - > getOpenedArchetype ( ) ) , <nl> - formalRValueType - > getCanonicalType ( ) , <nl> - accessKind ) ; <nl> - auto addr = emitAddressOfLValue ( E , std : : move ( lv ) , accessKind ) ; <nl> - state = { addr , false , false } ; <nl> - } else { <nl> - accessKind = AccessKind : : Read ; <nl> - auto existentialValue = emitRValueAsSingleValue ( <nl> + bool inserted = OpaqueValueExprs . insert ( { E - > getOpaqueValue ( ) , E } ) . second ; <nl> + ( void ) inserted ; <nl> + assert ( inserted & & " already have this opened existential ? " ) ; <nl> + <nl> + emitSubExpr ( E - > getSubExpr ( ) ) ; <nl> + return ; <nl> + } <nl> + <nl> + auto existentialValue = emitRValueAsSingleValue ( <nl> E - > getExistentialValue ( ) , <nl> SGFContext : : AllowGuaranteedPlusZero ) ; <nl> - <nl> - state = emitOpenExistential ( <nl> + <nl> + Type opaqueValueType = E - > getOpaqueValue ( ) - > getType ( ) - > getRValueType ( ) ; <nl> + auto state = emitOpenExistential ( <nl> E , existentialValue , E - > getOpenedArchetype ( ) , <nl> - getLoweredType ( opaqueValueType ) , accessKind ) ; <nl> - } <nl> + getLoweredType ( opaqueValueType ) , <nl> + AccessKind : : Read ) ; <nl> <nl> / / Register the opaque value for the projected existential . <nl> SILGenFunction : : OpaqueValueRAII opaqueValueRAII ( <nl> mmm a / lib / SILOptimizer / SILCombiner / SILCombinerApplyVisitors . cpp <nl> ppp b / lib / SILOptimizer / SILCombiner / SILCombinerApplyVisitors . cpp <nl> SILCombiner : : optimizeApplyOfConvertFunctionInst ( FullApplySite AI , <nl> assert ( NewOpType . isAddress ( ) & & " Addresses should map to addresses . " ) ; <nl> auto UAC = Builder . createUncheckedAddrCast ( AI . getLoc ( ) , Op , NewOpType ) ; <nl> Args . push_back ( UAC ) ; <nl> - } else if ( SILType : : canRefCast ( OldOpType , NewOpType , AI . getModule ( ) ) ) { <nl> - auto URC = Builder . createUncheckedRefCast ( AI . getLoc ( ) , Op , NewOpType ) ; <nl> + } else if ( OldOpType . getSwiftRValueType ( ) ! = NewOpType . getSwiftRValueType ( ) ) { <nl> + auto URC = Builder . createUncheckedBitCast ( AI . getLoc ( ) , Op , NewOpType ) ; <nl> Args . push_back ( URC ) ; <nl> } else { <nl> - assert ( ( ! OldOpType . isHeapObjectReferenceType ( ) <nl> - & & ! NewOpType . isHeapObjectReferenceType ( ) ) & & <nl> - " ref argument types should map to refs . " ) ; <nl> Args . push_back ( Op ) ; <nl> } <nl> } <nl> mmm a / lib / Sema / InstrumenterSupport . h <nl> ppp b / lib / Sema / InstrumenterSupport . h <nl> <nl> <nl> # include " TypeChecker . h " <nl> <nl> + # include " swift / AST / ASTWalker . h " <nl> + <nl> namespace swift { <nl> namespace instrumenter_support { <nl> <nl> mmm a / test / SILGen / protocols . swift <nl> ppp b / test / SILGen / protocols . swift <nl> func use_subscript_rvalue_get ( _ i : Int ) - > Int { <nl> / / CHECK : [ [ PROJ : % [ 0 - 9 ] + ] ] = open_existential_addr immutable_access [ [ READ ] ] : $ * SubscriptableGet to $ * [ [ OPENED : @ opened ( . * ) SubscriptableGet ] ] <nl> / / CHECK : [ [ ALLOCSTACK : % [ 0 - 9 ] + ] ] = alloc_stack $ [ [ OPENED ] ] <nl> / / CHECK : copy_addr [ [ PROJ ] ] to [ initialization ] [ [ ALLOCSTACK ] ] : $ * [ [ OPENED ] ] <nl> + / / CHECK - NEXT : end_access [ [ READ ] ] : $ * SubscriptableGet <nl> / / CHECK - NEXT : [ [ METH : % [ 0 - 9 ] + ] ] = witness_method $ [ [ OPENED ] ] , # SubscriptableGet . subscript ! getter . 1 <nl> / / CHECK - NEXT : [ [ RESULT : % [ 0 - 9 ] + ] ] = apply [ [ METH ] ] < [ [ OPENED ] ] > ( % 0 , [ [ ALLOCSTACK ] ] ) <nl> / / CHECK - NEXT : destroy_addr [ [ ALLOCSTACK ] ] <nl> - / / CHECK - NEXT : end_access [ [ READ ] ] : $ * SubscriptableGet <nl> / / CHECK - NEXT : dealloc_stack [ [ ALLOCSTACK ] ] : $ * [ [ OPENED ] ] <nl> / / CHECK - NEXT : return [ [ RESULT ] ] <nl> <nl> func use_property_rvalue_get ( ) - > Int { <nl> / / CHECK : [ [ PROJ : % [ 0 - 9 ] + ] ] = open_existential_addr immutable_access [ [ READ ] ] : $ * PropertyWithGetter to $ * [ [ OPENED : @ opened ( . * ) PropertyWithGetter ] ] <nl> / / CHECK : [ [ COPY : % . * ] ] = alloc_stack $ [ [ OPENED ] ] <nl> / / CHECK - NEXT : copy_addr [ [ PROJ ] ] to [ initialization ] [ [ COPY ] ] : $ * [ [ OPENED ] ] <nl> + / / CHECK - NEXT : end_access [ [ READ ] ] : $ * PropertyWithGetter <nl> / / CHECK - NEXT : [ [ METH : % [ 0 - 9 ] + ] ] = witness_method $ [ [ OPENED ] ] , # PropertyWithGetter . a ! getter . 1 <nl> / / CHECK - NEXT : apply [ [ METH ] ] < [ [ OPENED ] ] > ( [ [ COPY ] ] ) <nl> <nl> mmm a / test / SILOptimizer / sil_combine_apply . sil <nl> ppp b / test / SILOptimizer / sil_combine_apply . sil <nl> bb11 ( % 128 : $ Error ) : <nl> bb99 : <nl> return % closure : $ @ callee_guaranteed ( @ guaranteed C ) - > @ error Error <nl> } <nl> + <nl> + / / Make sure convert_function - > apply does the right thing with metatypes <nl> + class Base { } <nl> + class Derived { } <nl> + <nl> + sil @ takesMetatype : $ @ convention ( thin ) ( @ thick Base . Type ) - > ( ) <nl> + <nl> + / / CHECK - LABEL : sil @ passesMetatype <nl> + / / CHECK : [ [ METATYPE : % . * ] ] = metatype $ @ thick Derived . Type <nl> + / / CHECK : [ [ FN : % . * ] ] = function_ref @ takesMetatype <nl> + / / CHECK : [ [ CONVERTED : % . * ] ] = unchecked_trivial_bit_cast [ [ METATYPE ] ] : $ @ thick Derived . Type to $ @ thick Base . Type <nl> + / / CHECK : [ [ RESULT : % . * ] ] = apply [ [ FN ] ] ( [ [ CONVERTED ] ] ) <nl> + <nl> + sil @ passesMetatype : $ @ convention ( thin ) ( ) - > ( ) { <nl> + bb0 : <nl> + % metatype = metatype $ @ thick Derived . Type <nl> + % fn = function_ref @ takesMetatype : $ @ convention ( thin ) ( @ thick Base . Type ) - > ( ) <nl> + % converted = convert_function % fn : $ @ convention ( thin ) ( @ thick Base . Type ) - > ( ) to $ @ convention ( thin ) ( @ thick Derived . Type ) - > ( ) <nl> + % result = apply % converted ( % metatype ) : $ @ convention ( thin ) ( @ thick Derived . Type ) - > ( ) <nl> + % return = tuple ( ) <nl> + return % return : $ ( ) <nl> + } <nl> mmm a / tools / SourceKit / lib / SwiftLang / SwiftDocSupport . cpp <nl> ppp b / tools / SourceKit / lib / SwiftLang / SwiftDocSupport . cpp <nl> <nl> # include " swift / AST / ASTPrinter . h " <nl> # include " swift / AST / ASTWalker . h " <nl> # include " swift / AST / GenericSignature . h " <nl> - # include " swift / AST / SourceEntityWalker . h " <nl> # include " swift / Frontend / Frontend . h " <nl> # include " swift / Frontend / PrintingDiagnosticConsumer . h " <nl> # include " swift / IDE / CommentConversion . h " <nl> # include " swift / IDE / ModuleInterfacePrinting . h " <nl> + # include " swift / IDE / SourceEntityWalker . h " <nl> # include " swift / IDE / SyntaxModel . h " <nl> # include " swift / IDE / Refactoring . h " <nl> / / This is included only for createLazyResolver ( ) . Move to different header ? <nl> class SourceDocASTWalker : public SourceEntityWalker { <nl> } <nl> <nl> bool visitSubscriptReference ( ValueDecl * D , CharSourceRange Range , <nl> + Optional < AccessKind > AccKind , <nl> bool IsOpenBracket ) override { <nl> / / Treat both open and close brackets equally <nl> return visitDeclReference ( D , Range , nullptr , nullptr , Type ( ) , <nl> - ReferenceMetaData ( SemaReferenceKind : : SubscriptRef , None ) ) ; <nl> + ReferenceMetaData ( SemaReferenceKind : : SubscriptRef , AccKind ) ) ; <nl> } <nl> <nl> bool isLocal ( Decl * D ) const { <nl> mmm a / tools / SourceKit / lib / SwiftLang / SwiftEditor . cpp <nl> ppp b / tools / SourceKit / lib / SwiftLang / SwiftEditor . cpp <nl> <nl> # include " swift / AST / ASTPrinter . h " <nl> # include " swift / AST / ASTVisitor . h " <nl> # include " swift / AST / ASTWalker . h " <nl> - # include " swift / AST / SourceEntityWalker . h " <nl> # include " swift / AST / DiagnosticsClangImporter . h " <nl> # include " swift / AST / DiagnosticsParse . h " <nl> # include " swift / Basic / SourceManager . h " <nl> <nl> # include " swift / IDE / CodeCompletion . h " <nl> # include " swift / IDE / CommentConversion . h " <nl> # include " swift / IDE / Formatting . h " <nl> + # include " swift / IDE / SourceEntityWalker . h " <nl> # include " swift / IDE / SyntaxModel . h " <nl> # include " swift / Subsystems . h " <nl> <nl> class SemanticAnnotator : public SourceEntityWalker { <nl> } <nl> <nl> bool visitSubscriptReference ( ValueDecl * D , CharSourceRange Range , <nl> + Optional < AccessKind > AccKind , <nl> bool IsOpenBracket ) override { <nl> / / We should treat both open and close brackets equally <nl> return visitDeclReference ( D , Range , nullptr , nullptr , Type ( ) , <nl> - ReferenceMetaData ( SemaReferenceKind : : SubscriptRef , None ) ) ; <nl> + ReferenceMetaData ( SemaReferenceKind : : SubscriptRef , AccKind ) ) ; <nl> } <nl> <nl> void annotate ( const Decl * D , bool IsRef , CharSourceRange Range ) { <nl> mmm a / tools / SourceKit / lib / SwiftLang / SwiftSourceDocInfo . cpp <nl> ppp b / tools / SourceKit / lib / SwiftLang / SwiftSourceDocInfo . cpp <nl> <nl> # include " swift / AST / ASTPrinter . h " <nl> # include " swift / AST / Decl . h " <nl> # include " swift / AST / NameLookup . h " <nl> - # include " swift / AST / SourceEntityWalker . h " <nl> # include " swift / AST / SwiftNameTranslation . h " <nl> # include " swift / Basic / SourceManager . h " <nl> # include " swift / Frontend / Frontend . h " <nl> # include " swift / Frontend / PrintingDiagnosticConsumer . h " <nl> # include " swift / IDE / CommentConversion . h " <nl> # include " swift / IDE / ModuleInterfacePrinting . h " <nl> + # include " swift / IDE / SourceEntityWalker . h " <nl> # include " swift / IDE / Utils . h " <nl> # include " swift / IDE / Refactoring . h " <nl> # include " swift / Markup / XMLUtils . h " <nl> mmm a / tools / swift - ide - test / swift - ide - test . cpp <nl> ppp b / tools / swift - ide - test / swift - ide - test . cpp <nl> <nl> # include " swift / AST / ASTMangler . h " <nl> # include " swift / AST / PrintOptions . h " <nl> # include " swift / AST / RawComment . h " <nl> - # include " swift / AST / SourceEntityWalker . h " <nl> # include " swift / AST / USRGeneration . h " <nl> # include " swift / Demangling / Demangle . h " <nl> # include " swift / Basic / LangOptions . h " <nl> <nl> # include " swift / IDE / CommentConversion . h " <nl> # include " swift / IDE / ModuleInterfacePrinting . h " <nl> # include " swift / IDE / REPLCodeCompletion . h " <nl> + # include " swift / IDE / SourceEntityWalker . h " <nl> # include " swift / IDE / SyntaxModel . h " <nl> # include " swift / IDE / Utils . h " <nl> # include " swift / Index / Index . h " <nl> class AnnotationPrinter : public SourceEntityWalker { <nl> } <nl> <nl> bool visitSubscriptReference ( ValueDecl * D , CharSourceRange Range , <nl> + Optional < AccessKind > AccKind , <nl> bool IsOpenBracket ) override { <nl> return visitDeclReference ( D , Range , nullptr , nullptr , Type ( ) , <nl> - ReferenceMetaData ( SemaReferenceKind : : SubscriptRef , None ) ) ; <nl> + ReferenceMetaData ( SemaReferenceKind : : SubscriptRef , AccKind ) ) ; <nl> } <nl> <nl> bool visitCallArgName ( Identifier Name , CharSourceRange Range , <nl> mmm a / validation - test / Evolution / test_superclass_methods . swift <nl> ppp b / validation - test / Evolution / test_superclass_methods . swift <nl> <nl> / / RUN : % target - resilience - test <nl> / / REQUIRES : executable_test <nl> <nl> - / / rdar : / / 35492775 <nl> - / / REQUIRES : swift_test_mode_optimize_none <nl> - <nl> import StdlibUnittest <nl> import superclass_methods <nl> <nl> mmm a / validation - test / Evolution / test_superclass_properties . swift <nl> ppp b / validation - test / Evolution / test_superclass_properties . swift <nl> <nl> / / RUN : % target - resilience - test <nl> / / REQUIRES : executable_test <nl> <nl> - / / rdar : / / 35492775 <nl> - / / REQUIRES : swift_test_mode_optimize_none <nl> - <nl> import StdlibUnittest <nl> import superclass_properties <nl> <nl>
|
Merge remote - tracking branch ' origin / master ' into master - next
|
apple/swift
|
1b03a420a7774c4826d440a7edd8808292720a71
|
2017-11-14T07:49:31Z
|
mmm a / trunk / src / app / srs_app_config . cpp <nl> ppp b / trunk / src / app / srs_app_config . cpp <nl> SrsConfDirective * SrsConfig : : get_vhost ( string vhost ) <nl> } <nl> } <nl> <nl> - if ( vhost ! = RTMP_VHOST_DEFAULT ) { <nl> - return get_vhost ( RTMP_VHOST_DEFAULT ) ; <nl> + if ( vhost ! = SRS_CONSTS_RTMP_DEFAULT_VHOST ) { <nl> + return get_vhost ( SRS_CONSTS_RTMP_DEFAULT_VHOST ) ; <nl> } <nl> <nl> return NULL ; <nl> int SrsConfig : : get_chunk_size ( string vhost ) <nl> SrsConfDirective * conf = get_vhost ( vhost ) ; <nl> <nl> if ( ! conf ) { <nl> - return SRS_CONF_DEFAULT_CHUNK_SIZE ; <nl> + return SRS_CONSTS_RTMP_SRS_CHUNK_SIZE ; <nl> } <nl> <nl> conf = conf - > get ( " chunk_size " ) ; <nl> int SrsConfig : : get_chunk_size ( string vhost ) <nl> / / use the global instead . <nl> conf = root - > get ( " chunk_size " ) ; <nl> if ( ! conf ) { <nl> - return SRS_CONF_DEFAULT_CHUNK_SIZE ; <nl> + return SRS_CONSTS_RTMP_SRS_CHUNK_SIZE ; <nl> } <nl> <nl> return : : atoi ( conf - > arg0 ( ) . c_str ( ) ) ; <nl> mmm a / trunk / src / app / srs_app_config . hpp <nl> ppp b / trunk / src / app / srs_app_config . hpp <nl> CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE . <nl> <nl> # include < srs_app_reload . hpp > <nl> <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / the value consts <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - # define SRS_CONSTS_NULL_FILE " / dev / null " <nl> - # define SRS_CONSTS_LOCALHOST " 127 . 0 . 0 . 1 " <nl> - <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / default consts values <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> mmm a / trunk / src / app / srs_app_edge . cpp <nl> ppp b / trunk / src / app / srs_app_edge . cpp <nl> int SrsEdgeIngester : : connect_server ( ) <nl> std : : string server = conf - > args . at ( origin_index % conf - > args . size ( ) ) ; <nl> origin_index = ( origin_index + 1 ) % conf - > args . size ( ) ; <nl> <nl> - std : : string s_port = RTMP_DEFAULT_PORT ; <nl> - int port = : : atoi ( RTMP_DEFAULT_PORT ) ; <nl> + std : : string s_port = SRS_CONSTS_RTMP_DEFAULT_PORT ; <nl> + int port = : : atoi ( SRS_CONSTS_RTMP_DEFAULT_PORT ) ; <nl> size_t pos = server . find ( " : " ) ; <nl> if ( pos ! = std : : string : : npos ) { <nl> s_port = server . substr ( pos + 1 ) ; <nl> int SrsEdgeForwarder : : connect_server ( ) <nl> std : : string server = conf - > args . at ( origin_index % conf - > args . size ( ) ) ; <nl> origin_index = ( origin_index + 1 ) % conf - > args . size ( ) ; <nl> <nl> - std : : string s_port = RTMP_DEFAULT_PORT ; <nl> - int port = : : atoi ( RTMP_DEFAULT_PORT ) ; <nl> + std : : string s_port = SRS_CONSTS_RTMP_DEFAULT_PORT ; <nl> + int port = : : atoi ( SRS_CONSTS_RTMP_DEFAULT_PORT ) ; <nl> size_t pos = server . find ( " : " ) ; <nl> if ( pos ! = std : : string : : npos ) { <nl> s_port = server . substr ( pos + 1 ) ; <nl> mmm a / trunk / src / app / srs_app_encoder . cpp <nl> ppp b / trunk / src / app / srs_app_encoder . cpp <nl> using namespace std ; <nl> # include < srs_protocol_stack . hpp > <nl> # include < srs_app_ffmpeg . hpp > <nl> # include < srs_kernel_utility . hpp > <nl> + # include < srs_kernel_consts . hpp > <nl> <nl> # ifdef SRS_AUTO_TRANSCODE <nl> <nl> mmm a / trunk / src / app / srs_app_forward . cpp <nl> ppp b / trunk / src / app / srs_app_forward . cpp <nl> int SrsForwarder : : on_publish ( SrsRequest * req , std : : string forward_server ) <nl> <nl> stream_name = req - > stream ; <nl> server = forward_server ; <nl> - std : : string s_port = RTMP_DEFAULT_PORT ; <nl> - port = : : atoi ( RTMP_DEFAULT_PORT ) ; <nl> + std : : string s_port = SRS_CONSTS_RTMP_DEFAULT_PORT ; <nl> + port = : : atoi ( SRS_CONSTS_RTMP_DEFAULT_PORT ) ; <nl> <nl> / / TODO : FIXME : parse complex params <nl> size_t pos = forward_server . find ( " : " ) ; <nl> mmm a / trunk / src / app / srs_app_ingest . cpp <nl> ppp b / trunk / src / app / srs_app_ingest . cpp <nl> using namespace std ; <nl> # include < srs_app_ffmpeg . hpp > <nl> # include < srs_app_pithy_print . hpp > <nl> # include < srs_kernel_utility . hpp > <nl> + # include < srs_kernel_consts . hpp > <nl> <nl> / / when error , ingester sleep for a while and retry . <nl> / / ingest never sleep a long time , for we must start the stream ASAP . <nl> mmm a / trunk / src / app / srs_app_rtmp_conn . cpp <nl> ppp b / trunk / src / app / srs_app_rtmp_conn . cpp <nl> int SrsRtmpConn : : connect_server ( int origin_index , st_netfd_t * pstsock ) <nl> std : : string server = conf - > args . at ( origin_index % conf - > args . size ( ) ) ; <nl> origin_index = ( origin_index + 1 ) % conf - > args . size ( ) ; <nl> <nl> - std : : string s_port = RTMP_DEFAULT_PORT ; <nl> - int port = : : atoi ( RTMP_DEFAULT_PORT ) ; <nl> + std : : string s_port = SRS_CONSTS_RTMP_DEFAULT_PORT ; <nl> + int port = : : atoi ( SRS_CONSTS_RTMP_DEFAULT_PORT ) ; <nl> size_t pos = server . find ( " : " ) ; <nl> if ( pos ! = std : : string : : npos ) { <nl> s_port = server . substr ( pos + 1 ) ; <nl> mmm a / trunk / src / app / srs_app_utility . cpp <nl> ppp b / trunk / src / app / srs_app_utility . cpp <nl> using namespace std ; <nl> # include < srs_kernel_error . hpp > <nl> # include < srs_app_kbps . hpp > <nl> # include < srs_app_json . hpp > <nl> + # include < srs_kernel_consts . hpp > <nl> <nl> int srs_socket_connect ( std : : string server , int port , int64_t timeout , st_netfd_t * pstfd ) <nl> { <nl> mmm a / trunk / src / kernel / srs_kernel_consts . hpp <nl> ppp b / trunk / src / kernel / srs_kernel_consts . hpp <nl> CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE . <nl> <nl> # include < srs_core . hpp > <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / RTMP consts values <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / default vhost of rtmp <nl> + # define SRS_CONSTS_RTMP_DEFAULT_VHOST " __defaultVhost__ " <nl> + / / default port of rtmp <nl> + # define SRS_CONSTS_RTMP_DEFAULT_PORT " 1935 " <nl> + <nl> + / / the default chunk size for system . <nl> + # define SRS_CONSTS_RTMP_SRS_CHUNK_SIZE 60000 <nl> + / / 6 . Chunking , RTMP protocol default chunk size . <nl> + # define SRS_CONSTS_RTMP_PROTOCOL_CHUNK_SIZE 128 <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / SRS consts values <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + # define SRS_CONSTS_NULL_FILE " / dev / null " <nl> + # define SRS_CONSTS_LOCALHOST " 127 . 0 . 0 . 1 " <nl> + <nl> + <nl> # endif <nl> mmm a / trunk / src / rtmp / srs_protocol_rtmp . cpp <nl> ppp b / trunk / src / rtmp / srs_protocol_rtmp . cpp <nl> int SrsRtmpClient : : play ( string stream , int stream_id ) <nl> / / SetChunkSize <nl> if ( true ) { <nl> SrsSetChunkSizePacket * pkt = new SrsSetChunkSizePacket ( ) ; <nl> - pkt - > chunk_size = SRS_CONF_DEFAULT_CHUNK_SIZE ; <nl> + pkt - > chunk_size = SRS_CONSTS_RTMP_SRS_CHUNK_SIZE ; <nl> if ( ( ret = protocol - > send_and_free_packet ( pkt , 0 ) ) ! = ERROR_SUCCESS ) { <nl> srs_error ( " send set chunk size failed . " <nl> " stream = % s , chunk_size = % d , ret = % d " , <nl> - stream . c_str ( ) , SRS_CONF_DEFAULT_CHUNK_SIZE , ret ) ; <nl> + stream . c_str ( ) , SRS_CONSTS_RTMP_SRS_CHUNK_SIZE , ret ) ; <nl> return ret ; <nl> } <nl> } <nl> int SrsRtmpClient : : publish ( string stream , int stream_id ) <nl> / / SetChunkSize <nl> if ( true ) { <nl> SrsSetChunkSizePacket * pkt = new SrsSetChunkSizePacket ( ) ; <nl> - pkt - > chunk_size = SRS_CONF_DEFAULT_CHUNK_SIZE ; <nl> + pkt - > chunk_size = SRS_CONSTS_RTMP_SRS_CHUNK_SIZE ; <nl> if ( ( ret = protocol - > send_and_free_packet ( pkt , 0 ) ) ! = ERROR_SUCCESS ) { <nl> srs_error ( " send set chunk size failed . " <nl> " stream = % s , chunk_size = % d , ret = % d " , <nl> - stream . c_str ( ) , SRS_CONF_DEFAULT_CHUNK_SIZE , ret ) ; <nl> + stream . c_str ( ) , SRS_CONSTS_RTMP_SRS_CHUNK_SIZE , ret ) ; <nl> return ret ; <nl> } <nl> } <nl> mmm a / trunk / src / rtmp / srs_protocol_stack . cpp <nl> ppp b / trunk / src / rtmp / srs_protocol_stack . cpp <nl> CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE . <nl> # include < srs_kernel_stream . hpp > <nl> # include < srs_core_autofree . hpp > <nl> # include < srs_kernel_utility . hpp > <nl> + # include < srs_kernel_consts . hpp > <nl> <nl> using namespace std ; <nl> <nl> messages . <nl> * good for high - bit rate streaming . Chunk size is maintained <nl> * independently for each direction . <nl> * / <nl> - # define RTMP_DEFAULT_CHUNK_SIZE 128 <nl> # define RTMP_MIN_CHUNK_SIZE 128 <nl> # define RTMP_MAX_CHUNK_SIZE 65536 <nl> <nl> SrsProtocol : : SrsProtocol ( ISrsProtocolReaderWriter * io ) <nl> in_buffer = new SrsBuffer ( ) ; <nl> skt = io ; <nl> <nl> - in_chunk_size = out_chunk_size = RTMP_DEFAULT_CHUNK_SIZE ; <nl> + in_chunk_size = out_chunk_size = SRS_CONSTS_RTMP_PROTOCOL_CHUNK_SIZE ; <nl> } <nl> <nl> SrsProtocol : : ~ SrsProtocol ( ) <nl> int SrsAcknowledgementPacket : : encode_packet ( SrsStream * stream ) <nl> <nl> SrsSetChunkSizePacket : : SrsSetChunkSizePacket ( ) <nl> { <nl> - chunk_size = RTMP_DEFAULT_CHUNK_SIZE ; <nl> + chunk_size = SRS_CONSTS_RTMP_PROTOCOL_CHUNK_SIZE ; <nl> } <nl> <nl> SrsSetChunkSizePacket : : ~ SrsSetChunkSizePacket ( ) <nl> mmm a / trunk / src / rtmp / srs_protocol_utility . cpp <nl> ppp b / trunk / src / rtmp / srs_protocol_utility . cpp <nl> void srs_discovery_tc_url ( <nl> srs_info ( " discovery host = % s " , host . c_str ( ) ) ; <nl> } <nl> <nl> - port = RTMP_DEFAULT_PORT ; <nl> + port = SRS_CONSTS_RTMP_DEFAULT_PORT ; <nl> if ( ( pos = host . find ( " : " ) ) ! = std : : string : : npos ) { <nl> port = host . substr ( pos + 1 ) ; <nl> host = host . substr ( 0 , pos ) ; <nl> string srs_generate_tc_url ( string ip , string vhost , string app , string port , str <nl> { <nl> string tcUrl = " rtmp : / / " ; <nl> <nl> - if ( vhost = = RTMP_VHOST_DEFAULT ) { <nl> + if ( vhost = = SRS_CONSTS_RTMP_DEFAULT_VHOST ) { <nl> tcUrl + = ip ; <nl> } else { <nl> tcUrl + = vhost ; <nl> } <nl> <nl> - if ( port ! = RTMP_DEFAULT_PORT ) { <nl> + if ( port ! = SRS_CONSTS_RTMP_DEFAULT_PORT ) { <nl> tcUrl + = " : " ; <nl> tcUrl + = port ; <nl> } <nl> mmm a / trunk / src / rtmp / srs_protocol_utility . hpp <nl> ppp b / trunk / src / rtmp / srs_protocol_utility . hpp <nl> CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE . <nl> <nl> # include < string > <nl> <nl> - / / default vhost of rtmp <nl> - # define RTMP_VHOST_DEFAULT " __defaultVhost__ " <nl> - / / default port of rtmp <nl> - # define RTMP_DEFAULT_PORT " 1935 " <nl> - <nl> - / / the default chunk size for system . <nl> - # define SRS_CONF_DEFAULT_CHUNK_SIZE 60000 <nl> + # include < srs_kernel_consts . hpp > <nl> <nl> / * * <nl> * parse the tcUrl , output the schema , host , vhost , app and port . <nl>
|
move some consts to kernel consts
|
ossrs/srs
|
736ec48c7114ac8126d062ec559a051ddb53e92d
|
2014-07-20T05:11:53Z
|
mmm a / js / node / VERSIONS <nl> ppp b / js / node / VERSIONS <nl> _stream_readable : 0 . 10 . 25 <nl> _stream_transform : 0 . 10 . 25 <nl> _stream_writable : 0 . 10 . 25 <nl> assert : 0 . 11 . 0 <nl> - buffer : 0 . 11 . 0 ( SlowBuffer ) <nl> - child_process : not supported <nl> + buffer : 0 . 11 . 0 ( SlowBuffer ) <nl> + child_process : not supported <nl> + console : compatibility <nl> + constants : not supported <nl> + crypto : not supported ( see org / arangodb / crypto ) <nl> events : 4 . 1 . 0 <nl> + fs : compatibility <nl> http : not supported <nl> https : not supported <nl> - net : compatibility <nl> + net : compatibility <nl> path : 0 . 11 . 0 ( process ) <nl> + process : compatibility <nl> punycode : 4 . 1 . 0 <nl> querystring : 4 . 1 . 0 <nl> stream : 0 . 10 . 25 <nl> - sys : not supported <nl> string_decoder : 4 . 1 . 0 <nl> + sys : not supported <nl> + tty : compatibility <nl> url : 4 . 1 . 0 <nl> util : compatibility <nl> vm : not supported <nl> \ No newline at end of file <nl>
|
Added unmentioned modules to VERSIONS
|
arangodb/arangodb
|
69a43523949f689009f04962490e0984af5bbfe5
|
2015-09-24T11:46:12Z
|
mmm a / api / bazel / repository_locations . bzl <nl> ppp b / api / bazel / repository_locations . bzl <nl> REPOSITORY_LOCATIONS = dict ( <nl> com_lyft_protoc_gen_validate = dict ( <nl> sha256 = PGV_SHA256 , <nl> strip_prefix = " protoc - gen - validate - " + PGV_RELEASE , <nl> - urls = [ " https : / / github . com / lyft / protoc - gen - validate / archive / v " + PGV_RELEASE + " . tar . gz " ] , <nl> + urls = [ " https : / / github . com / envoyproxy / protoc - gen - validate / archive / v " + PGV_RELEASE + " . tar . gz " ] , <nl> ) , <nl> googleapis = dict ( <nl> # TODO ( dio ) : Consider writing a Skylark macro for importing Google API proto . <nl>
|
build : update PGV url ( )
|
envoyproxy/envoy
|
70c408b858f9b9824ed9109f2264eacc20724d4d
|
2019-04-06T00:21:14Z
|
mmm a / src / miner . cpp <nl> ppp b / src / miner . cpp <nl> void BlockAssembler : : AddToBlock ( CTxMemPool : : txiter iter ) <nl> } <nl> } <nl> <nl> - void BlockAssembler : : addScoreTxs ( ) <nl> - { <nl> - std : : priority_queue < CTxMemPool : : txiter , std : : vector < CTxMemPool : : txiter > , ScoreCompare > clearedTxs ; <nl> - CTxMemPool : : setEntries waitSet ; <nl> - CTxMemPool : : indexed_transaction_set : : index < mining_score > : : type : : iterator mi = mempool . mapTx . get < mining_score > ( ) . begin ( ) ; <nl> - CTxMemPool : : txiter iter ; <nl> - while ( ! blockFinished & & ( mi ! = mempool . mapTx . get < mining_score > ( ) . end ( ) | | ! clearedTxs . empty ( ) ) ) <nl> - { <nl> - / / If no txs that were previously postponed are available to try <nl> - / / again , then try the next highest score tx <nl> - if ( clearedTxs . empty ( ) ) { <nl> - iter = mempool . mapTx . project < 0 > ( mi ) ; <nl> - mi + + ; <nl> - } <nl> - / / If a previously postponed tx is available to try again , then it <nl> - / / has higher score than all untried so far txs <nl> - else { <nl> - iter = clearedTxs . top ( ) ; <nl> - clearedTxs . pop ( ) ; <nl> - } <nl> - <nl> - / / If tx already in block , skip ( added by addPriorityTxs ) <nl> - if ( inBlock . count ( iter ) ) { <nl> - continue ; <nl> - } <nl> - <nl> - / / cannot accept witness transactions into a non - witness block <nl> - if ( ! fIncludeWitness & & ! iter - > GetTx ( ) . wit . IsNull ( ) ) <nl> - continue ; <nl> - <nl> - / / If tx is dependent on other mempool txs which haven ' t yet been included <nl> - / / then put it in the waitSet <nl> - if ( isStillDependent ( iter ) ) { <nl> - waitSet . insert ( iter ) ; <nl> - continue ; <nl> - } <nl> - <nl> - / / If the fee rate is below the min fee rate for mining , then we ' re done <nl> - / / adding txs based on score ( fee rate ) <nl> - if ( iter - > GetModifiedFee ( ) < : : minRelayTxFee . GetFee ( iter - > GetTxSize ( ) ) & & nBlockSize > = nBlockMinSize ) { <nl> - return ; <nl> - } <nl> - <nl> - / / If this tx fits in the block add it , otherwise keep looping <nl> - if ( TestForBlock ( iter ) ) { <nl> - AddToBlock ( iter ) ; <nl> - <nl> - / / This tx was successfully added , so <nl> - / / add transactions that depend on this one to the priority queue to try again <nl> - BOOST_FOREACH ( CTxMemPool : : txiter child , mempool . GetMemPoolChildren ( iter ) ) <nl> - { <nl> - if ( waitSet . count ( child ) ) { <nl> - clearedTxs . push ( child ) ; <nl> - waitSet . erase ( child ) ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } <nl> - <nl> void BlockAssembler : : UpdatePackagesForAdded ( const CTxMemPool : : setEntries & alreadyAdded , <nl> indexed_modified_transaction_set & mapModifiedTx ) <nl> { <nl> mmm a / src / miner . h <nl> ppp b / src / miner . h <nl> class BlockAssembler <nl> int64_t nLockTimeCutoff ; <nl> const CChainParams & chainparams ; <nl> <nl> - / / Variables used for addScoreTxs and addPriorityTxs <nl> + / / Variables used for addPriorityTxs <nl> int lastFewTxs ; <nl> bool blockFinished ; <nl> <nl> class BlockAssembler <nl> void AddToBlock ( CTxMemPool : : txiter iter ) ; <nl> <nl> / / Methods for how to add transactions to a block . <nl> - / * * Add transactions based on modified feerate * / <nl> - void addScoreTxs ( ) ; <nl> / * * Add transactions based on tx " priority " * / <nl> void addPriorityTxs ( ) ; <nl> / * * Add transactions based on feerate including unconfirmed ancestors * / <nl> void addPackageTxs ( ) ; <nl> <nl> - / / helper function for addScoreTxs and addPriorityTxs <nl> + / / helper function for addPriorityTxs <nl> / * * Test if tx will still " fit " in the block * / <nl> bool TestForBlock ( CTxMemPool : : txiter iter ) ; <nl> / * * Test if tx still has unconfirmed parents not yet in block * / <nl>
|
Remove addScoreTxs ( )
|
bitcoin/bitcoin
|
d2e46e1b5cf6c08829ec3bb2a923b4ba149ab3b7
|
2016-06-30T15:37:38Z
|
mmm a / modules / java / android_test / src / org / opencv / test / ConvertersTest . java <nl> ppp b / modules / java / android_test / src / org / opencv / test / ConvertersTest . java <nl> <nl> package org . opencv . test ; <nl> <nl> + import java . util . ArrayList ; <nl> + import java . util . List ; <nl> + <nl> <nl> public class ConvertersTest extends OpenCVTestCase { <nl> <nl> protected void setUp ( ) throws Exception { <nl> super . setUp ( ) ; <nl> } <nl> - <nl> + <nl> public void testMat_to_vector_float ( ) { <nl> fail ( " Not yet implemented " ) ; <nl> } <nl> mmm a / modules / java / android_test / src / org / opencv / test / OpenCVTestCase . java <nl> ppp b / modules / java / android_test / src / org / opencv / test / OpenCVTestCase . java <nl> <nl> package org . opencv . test ; <nl> <nl> + import java . util . List ; <nl> + <nl> import junit . framework . TestCase ; <nl> <nl> import org . opencv . core . CvType ; <nl> <nl> <nl> protected static int matSize = 10 ; <nl> protected static double EPS = 0 . 001 ; <nl> + protected static double weakEPS = 0 . 5 ; <nl> <nl> protected static Mat dst ; <nl> protected static Mat truth ; <nl> + <nl> + protected static Scalar colorBlack ; <nl> <nl> / / Naming notation : < channels info > _ [ depth ] _ [ dimensions ] _value <nl> / / examples : gray0 - single channel 8U 2d Mat filled with 0 <nl> <nl> <nl> protected static Mat v1 ; <nl> protected static Mat v2 ; <nl> - <nl> + <nl> @ Override <nl> protected void setUp ( ) throws Exception { <nl> super . setUp ( ) ; <nl> protected void setUp ( ) throws Exception { <nl> assertTrue ( dst . empty ( ) ) ; <nl> truth = new Mat ( ) ; <nl> assertTrue ( truth . empty ( ) ) ; <nl> + <nl> + colorBlack = new Scalar ( 0 ) ; <nl> <nl> gray0 = new Mat ( matSize , matSize , CvType . CV_8U , new Scalar ( 0 ) ) ; <nl> gray1 = new Mat ( matSize , matSize , CvType . CV_8U , new Scalar ( 1 ) ) ; <nl> protected void setUp ( ) throws Exception { <nl> gray255 = new Mat ( matSize , matSize , CvType . CV_8U , new Scalar ( 255 ) ) ; <nl> <nl> gray_16u_256 = new Mat ( matSize , matSize , CvType . CV_16U , new Scalar ( 256 ) ) ; <nl> - gray_16s_1024 = new Mat ( matSize , matSize , CvType . CV_16S , new Scalar ( <nl> - 1024 ) ) ; <nl> + gray_16s_1024 = new Mat ( matSize , matSize , CvType . CV_16S , new Scalar ( 1024 ) ) ; <nl> <nl> grayRnd = new Mat ( matSize , matSize , CvType . CV_8U ) ; <nl> Core . randu ( grayRnd , new Scalar ( 0 ) , new Scalar ( 256 ) ) ; <nl> protected void tearDown ( ) throws Exception { <nl> <nl> super . tearDown ( ) ; <nl> } <nl> - <nl> + <nl> + public static void assertListEqual ( List < Float > list1 , List < Float > list2 , double epsilon ) <nl> + { <nl> + if ( list1 . size ( ) ! = list2 . size ( ) ) { <nl> + throw new UnsupportedOperationException ( ) ; <nl> + } <nl> + <nl> + for ( int i = 0 ; i < list1 . size ( ) ; i + + ) <nl> + assertTrue ( Math . abs ( list1 . get ( i ) - list2 . get ( i ) ) < = epsilon ) ; <nl> + } <nl> + <nl> public static void assertMatEqual ( Mat m1 , Mat m2 ) { <nl> compareMats ( m1 , m2 , true ) ; <nl> } <nl> public static void assertKeyPointEqual ( KeyPoint expected , KeyPoint actual , doubl <nl> assertEquals ( expected . octave , actual . octave ) ; <nl> assertEquals ( expected . class_id , actual . class_id ) ; <nl> } <nl> + <nl> + public static void assertPointEquals ( Point expected , Point actual , double eps ) { <nl> + assertEquals ( expected . x , actual . x , eps ) ; <nl> + assertEquals ( expected . y , actual . y , eps ) ; <nl> + } <nl> <nl> static private void compareMats ( Mat expected , Mat actual , boolean isEqualityMeasured ) { <nl> if ( expected . type ( ) ! = actual . type ( ) | | expected . cols ( ) ! = actual . cols ( ) <nl> mmm a / modules / java / android_test / src / org / opencv / test / core / coreTest . java <nl> ppp b / modules / java / android_test / src / org / opencv / test / core / coreTest . java <nl> public void testCalcCovarMatrixMatMatMatInt ( ) { <nl> Mat covar = new Mat ( matSize , matSize , CvType . CV_64FC1 ) ; <nl> Mat mean = new Mat ( 1 , matSize , CvType . CV_64FC1 ) ; <nl> <nl> - Core . calcCovarMatrix ( gray0_32f , covar , mean , 8 | 1 / * <nl> - * TODO : <nl> - * CV_COVAR_NORMAL <nl> - * / ) ; <nl> + Core . calcCovarMatrix ( gray0_32f , covar , mean , Core . COVAR_ROWS | Core . COVAR_NORMAL ) ; <nl> + <nl> assertMatEqual ( gray0_64f , covar , EPS ) ; <nl> assertMatEqual ( gray0_64f_1d , mean , EPS ) ; <nl> } <nl> public void testCalcCovarMatrixMatMatMatIntInt ( ) { <nl> Mat covar = new Mat ( matSize , matSize , CvType . CV_32F ) ; <nl> Mat mean = new Mat ( 1 , matSize , CvType . CV_32F ) ; <nl> <nl> - Core . calcCovarMatrix ( gray0_32f , covar , mean , 8 | 1 / * <nl> - * TODO : <nl> - * CV_COVAR_NORMAL <nl> - * / , CvType . CV_32F ) ; <nl> + Core . calcCovarMatrix ( gray0_32f , covar , mean , Core . COVAR_ROWS | Core . COVAR_NORMAL , CvType . CV_32F ) ; <nl> assertMatEqual ( gray0_32f , covar , EPS ) ; <nl> assertMatEqual ( gray0_32f_1d , mean , EPS ) ; <nl> } <nl> public void testInvertMatMat ( ) { <nl> Core . invert ( src , dst ) ; <nl> assertMatEqual ( truth , dst , EPS ) ; <nl> <nl> - / / TODO : needs epsilon comparison <nl> - / / Mat m = grayRnd_32f . clone ( ) ; <nl> - / / Mat inv = m . inv ( ) ; <nl> - / / Core . gemm ( m , inv , 1 . 0 , new Mat ( ) , 0 . 0 , dst ) ; <nl> - / / assertMatEqual ( grayE_32f , dst ) ; <nl> + Core . gemm ( grayRnd_32f , grayRnd_32f . inv ( ) , 1 . 0 , new Mat ( ) , 0 . 0 , dst ) ; <nl> + assertMatEqual ( grayE_32f , dst , EPS ) ; <nl> } <nl> <nl> public void testInvertMatMatInt ( ) { <nl> public void testMagnitude ( ) { <nl> public void testMahalanobis ( ) { <nl> Mat covar = new Mat ( matSize , matSize , CvType . CV_32F ) ; <nl> Mat mean = new Mat ( 1 , matSize , CvType . CV_32F ) ; <nl> - Core . calcCovarMatrix ( grayRnd_32f , covar , mean , 8 | 1 / * <nl> - * TODO : <nl> - * CV_COVAR_NORMAL <nl> - * / , CvType . CV_32F ) ; <nl> + Core . calcCovarMatrix ( grayRnd_32f , covar , mean , Core . COVAR_ROWS | Core . COVAR_NORMAL , CvType . CV_32F ) ; <nl> covar . inv ( ) ; <nl> <nl> Mat line1 = grayRnd_32f . submat ( 0 , 1 , 0 , grayRnd_32f . cols ( ) ) ; <nl> public void testPolarToCartMatMatMatMat ( ) { <nl> Mat xCoordinate = new Mat ( ) ; <nl> Mat yCoordinate = new Mat ( ) ; <nl> <nl> - / / x . put ( 0 , 0 , 3 . 0 , 6 . 0 , 5 , 0 ) ; <nl> - / / y . put ( 0 , 0 , 4 . 0 , 8 . 0 , 12 . 0 ) ; <nl> - / / magnitude . put ( 0 , 0 , 5 . 0 , 10 . 0 , 13 . 0 ) ; <nl> - / / angle . put ( 0 , 0 , 0 . 92729962 , 0 . 92729962 , 1 . 1759995 ) ; <nl> - <nl> magnitude . put ( 0 , 0 , 5 . 0 , 10 . 0 , 13 . 0 ) ; <nl> angle . put ( 0 , 0 , 0 . 92729962 , 0 . 92729962 , 1 . 1759995 ) ; <nl> <nl> x . put ( 0 , 0 , 3 . 0 , 6 . 0 , 5 , 0 ) ; <nl> y . put ( 0 , 0 , 4 . 0 , 8 . 0 , 12 . 0 ) ; <nl> <nl> - / / TODO : needs epsilon comparison <nl> Core . polarToCart ( magnitude , angle , xCoordinate , yCoordinate ) ; <nl> assertMatEqual ( x , xCoordinate , EPS ) ; <nl> } <nl> public void testSort ( ) { <nl> Mat submat = gray0 . submat ( 0 , gray0 . rows ( ) / 2 , 0 , gray0 . cols ( ) / 2 ) ; <nl> submat . setTo ( new Scalar ( 1 . 0 ) ) ; <nl> <nl> - Core . sort ( gray0 , dst , 0 / * TODO : CV_SORT_EVERY_ROW * / ) ; <nl> + Core . sort ( gray0 , dst , Core . SORT_EVERY_ROW ) ; <nl> submat = dst . submat ( 0 , dst . rows ( ) / 2 , dst . cols ( ) / 2 , dst . cols ( ) ) ; <nl> assertTrue ( submat . total ( ) = = Core . countNonZero ( submat ) ) ; <nl> <nl> - Core . sort ( gray0 , dst , 1 / * TODO : CV_SORT_EVERY_COLUMN * / ) ; <nl> + Core . sort ( gray0 , dst , Core . SORT_EVERY_COLUMN ) ; <nl> submat = dst . submat ( dst . rows ( ) / 2 , dst . rows ( ) , 0 , dst . cols ( ) / 2 ) ; <nl> assertTrue ( submat . total ( ) = = Core . countNonZero ( submat ) ) ; <nl> } <nl> public void testSortIdx ( ) { <nl> truth . put ( 1 , 0 , 0 , 2 , 1 ) ; <nl> truth . put ( 2 , 0 , 0 , 1 , 2 ) ; <nl> <nl> - Core . sortIdx ( a , b , 0 + 0 / * TODO : CV_SORT_EVERY_ROW + CV_SORT_ASCENDING * / ) ; <nl> + Core . sortIdx ( a , b , Core . SORT_EVERY_ROW + Core . SORT_ASCENDING ) ; <nl> assertMatEqual ( truth , b ) ; <nl> } <nl> <nl> mmm a / modules / java / android_test / src / org / opencv / test / features2d / StarDetectorTest . java <nl> ppp b / modules / java / android_test / src / org / opencv / test / features2d / StarDetectorTest . java <nl> <nl> package org . opencv . test . features2d ; <nl> <nl> + import java . util . LinkedList ; <nl> + import java . util . List ; <nl> + <nl> import org . opencv . core . Core ; <nl> import org . opencv . core . CvType ; <nl> import org . opencv . core . Mat ; <nl> import org . opencv . core . Point ; <nl> - import org . opencv . core . RotatedRect ; <nl> import org . opencv . core . Scalar ; <nl> - import org . opencv . core . Size ; <nl> import org . opencv . features2d . KeyPoint ; <nl> import org . opencv . features2d . StarDetector ; <nl> import org . opencv . test . OpenCVTestCase ; <nl> - import org . opencv . test . OpenCVTestRunner ; <nl> - <nl> - import java . util . LinkedList ; <nl> - import java . util . List ; <nl> <nl> public class StarDetectorTest extends OpenCVTestCase { <nl> <nl> mmm a / modules / java / android_test / src / org / opencv / test / imgproc / imgprocTest . java <nl> ppp b / modules / java / android_test / src / org / opencv / test / imgproc / imgprocTest . java <nl> <nl> import java . util . ArrayList ; <nl> import java . util . List ; <nl> <nl> + import org . opencv . Converters ; <nl> import org . opencv . core . Core ; <nl> import org . opencv . core . CvType ; <nl> import org . opencv . core . Mat ; <nl> <nl> import org . opencv . core . RotatedRect ; <nl> import org . opencv . core . Scalar ; <nl> import org . opencv . core . Size ; <nl> + import org . opencv . core . TermCriteria ; <nl> import org . opencv . imgproc . Imgproc ; <nl> import org . opencv . test . OpenCVTestCase ; <nl> + import org . opencv . test . OpenCVTestRunner ; <nl> <nl> <nl> public class imgprocTest extends OpenCVTestCase { <nl> public void test_1 ( ) { <nl> } <nl> <nl> public void testAccumulateMatMat ( ) { <nl> - truth = new Mat ( imgprocSz , imgprocSz , CvType . CV_64F , new Scalar ( 2 ) ) ; <nl> Imgproc . accumulate ( gray_64f_2 , dst64F ) ; <nl> + truth = new Mat ( imgprocSz , imgprocSz , CvType . CV_64F , new Scalar ( 2 ) ) ; <nl> assertMatEqual ( truth , dst64F , EPS ) ; <nl> <nl> dst = new Mat ( matSize , matSize , CvType . CV_32FC1 , new Scalar ( 0 ) ) ; <nl> public void testAccumulateMatMat ( ) { <nl> } <nl> <nl> public void testAccumulateMatMatMat ( ) { <nl> + Imgproc . accumulate ( gray_64f_2 , dst64F , mask ) ; / / TODO : use better mask <nl> truth = new Mat ( imgprocSz , imgprocSz , CvType . CV_64F , new Scalar ( 2 ) ) ; <nl> - <nl> - Imgproc . accumulate ( gray_64f_2 , dst64F , mask ) ; / / TODO : use better mask <nl> assertMatEqual ( truth , dst64F , EPS ) ; <nl> } <nl> <nl> public void testAccumulateProductMatMatMat ( ) { <nl> src2 . put ( 0 , 0 , 2 , 1 ) ; <nl> src2 . put ( 1 , 0 , 1 , 2 ) ; <nl> <nl> + Mat dstImage = new Mat ( imgprocSz , imgprocSz , CvType . CV_64F , new Scalar ( 0 ) ) ; <nl> + Imgproc . accumulateProduct ( src1 , src2 , dstImage ) ; <nl> truth = new Mat ( imgprocSz , imgprocSz , CvType . CV_64F , new Scalar ( 2 ) ) ; <nl> truth . put ( 0 , 0 , 2 , 1 ) ; <nl> truth . put ( 1 , 0 , 1 , 2 ) ; <nl> - <nl> - Mat dstImage = new Mat ( imgprocSz , imgprocSz , CvType . CV_64F , new Scalar ( <nl> - 0 ) ) ; <nl> - Imgproc . accumulateProduct ( src1 , src2 , dstImage ) ; <nl> assertMatEqual ( truth , dstImage , EPS ) ; <nl> } <nl> <nl> public void testContourAreaMatBoolean ( ) { <nl> } <nl> <nl> public void testConvertMapsMatMatMatMatInt ( ) { <nl> - Mat map1 = new Mat ( 1 , 4 , CvType . CV_32FC1 , new Scalar ( 1 ) ) ; <nl> - Mat map2 = new Mat ( 1 , 4 , CvType . CV_32FC1 , new Scalar ( 1 ) ) ; <nl> + Mat map1 = new Mat ( 1 , 4 , CvType . CV_32FC1 , new Scalar ( 1 . 0 ) ) ; <nl> + Mat map2 = new Mat ( 1 , 4 , CvType . CV_32FC1 , new Scalar ( 2 . 0 ) ) ; <nl> Mat dstmap1 = new Mat ( 1 , 4 , CvType . CV_16SC2 ) ; <nl> Mat dstmap2 = new Mat ( 1 , 4 , CvType . CV_16UC1 ) ; <nl> + <nl> <nl> - / / FIXME : dstmap1 - Documentation says Cvtype but requires integer <nl> - Imgproc . convertMaps ( map1 , map2 , dstmap1 , dstmap2 , CvType . CV_32F ) ; <nl> - fail ( " Not yet implemented " ) ; <nl> + Imgproc . convertMaps ( map1 , map2 , dstmap1 , dstmap2 , CvType . CV_16SC2 ) ; <nl> + Mat truthMap1 = new Mat ( 1 , 4 , CvType . CV_16SC2 ) ; <nl> + truthMap1 . put ( 0 , 0 , 1 , 2 , 1 , 2 , 1 , 2 , 1 , 2 ) ; <nl> + assertMatEqual ( truthMap1 , dstmap1 ) ; <nl> + <nl> + Mat truthMap2 = new Mat ( 1 , 4 , CvType . CV_16UC1 , new Scalar ( 0 ) ) ; <nl> + assertMatEqual ( truthMap2 , dstmap2 ) ; <nl> } <nl> <nl> public void testConvertMapsMatMatMatMatIntBoolean ( ) { <nl> - fail ( " Not yet implemented " ) ; <nl> + Mat map1 = new Mat ( 1 , 3 , CvType . CV_32FC1 , new Scalar ( 2 . 0 ) ) ; <nl> + Mat map2 = new Mat ( 1 , 3 , CvType . CV_32FC1 , new Scalar ( 4 . 0 ) ) ; <nl> + Mat dstmap1 = new Mat ( 1 , 3 , CvType . CV_16SC2 ) ; <nl> + Mat dstmap2 = new Mat ( 1 , 3 , CvType . CV_16UC1 ) ; <nl> + <nl> + <nl> + Imgproc . convertMaps ( map1 , map2 , dstmap1 , dstmap2 , CvType . CV_16SC2 , false ) ; <nl> + Mat truthMap1 = new Mat ( 1 , 3 , CvType . CV_16SC2 ) ; <nl> + truthMap1 . put ( 0 , 0 , 2 , 4 , 2 , 4 , 2 , 4 ) ; <nl> + assertMatEqual ( truthMap1 , dstmap1 ) ; <nl> + <nl> + Mat truthMap2 = new Mat ( 1 , 3 , CvType . CV_16UC1 , new Scalar ( 0 ) ) ; <nl> + assertMatEqual ( truthMap2 , dstmap2 ) ; <nl> } <nl> <nl> public void testConvexHullMatMat ( ) { <nl> public void testCornerMinEigenValMatMatIntIntInt ( ) { <nl> truth . put ( 1 , 0 , 0 . 92708343 , 0 . 92708343 , 0 . 92708343 ) ; <nl> truth . put ( 2 , 0 , 0 . 58680564 , 0 . 92708343 , 0 . 68055564 ) ; <nl> <nl> - Imgproc . cornerMinEigenVal ( src , dst , blockSize , ksize , <nl> - Imgproc . BORDER_REFLECT ) ; <nl> + Imgproc . cornerMinEigenVal ( src , dst , blockSize , ksize , Imgproc . BORDER_REFLECT ) ; <nl> assertMatEqual ( truth , dst , EPS ) ; <nl> } <nl> <nl> public void testCornerSubPix ( ) { <nl> - fail ( " Not yet implemented " ) ; <nl> + Mat img = new Mat ( matSize , matSize , CvType . CV_8U , new Scalar ( 128 ) ) ; <nl> + <nl> + Point truthPosition = new Point ( img . cols ( ) / 2 , img . rows ( ) / 2 ) ; <nl> + <nl> + Rect r = new Rect ( new Point ( 0 , 0 ) , truthPosition ) ; <nl> + Core . rectangle ( img , r . tl ( ) , r . br ( ) , new Scalar ( 0 ) , - 1 / * TODO : CV_FILLED * / ) ; <nl> + <nl> + List < Point > corners = new ArrayList < Point > ( ) ; <nl> + corners . add ( new Point ( truthPosition . x + 1 , truthPosition . y + 1 ) ) ; <nl> + <nl> + Size winSize = new Size ( 2 , 2 ) ; <nl> + Size zeroZone = new Size ( - 1 , - 1 ) ; <nl> + TermCriteria criteria = new TermCriteria ( 2 / * TODO : CV_TERMCRIT_EPS * / , 0 , 0 . 01 ) ; <nl> + <nl> + Mat cornersMat = Converters . vector_Point2f_to_Mat ( corners ) ; <nl> + Imgproc . cornerSubPix ( img , cornersMat , winSize , zeroZone , criteria ) ; <nl> + Converters . Mat_to_vector_Point ( cornersMat , corners ) ; <nl> + assertPointEquals ( truthPosition , corners . get ( 0 ) , weakEPS ) ; <nl> } <nl> <nl> public void testCvtColorMatMatInt ( ) { <nl> public void testFindContoursMatListOfMatMatIntIntPoint ( ) { <nl> } <nl> <nl> public void testFitEllipse ( ) { <nl> - Mat points = new Mat ( 1 , 5 , CvType . CV_32FC2 ) ; / / TODO : use the list of <nl> - / / Points <nl> + Mat points = new Mat ( 1 , 5 , CvType . CV_32FC2 ) ; / / TODO : use the list of Points <nl> points . put ( 0 , 0 , 0 . 0 , 0 . 0 , - 1 . 0 , 1 . 0 , 1 . 0 , 1 . 0 , 1 . 0 , - 1 . 0 , - 1 . 0 , - 1 . 0 ) ; <nl> <nl> RotatedRect rrect = new RotatedRect ( ) ; <nl> public void testGrabCutMatMatRectMatMatIntInt ( ) { <nl> } <nl> <nl> public void testHoughCirclesMatMatIntDoubleDouble ( ) { <nl> - / / double minDist = gray255 . row ( 0 ) / 4 ; <nl> - / / Imgproc . HoughCircles ( gray255 , dst , Imgproc . CV_HOUGH_GRADIENT , 2 . 0 , <nl> - / / 0 . 5 ) ; <nl> - / / TODO : How do we test this ? <nl> - <nl> - fail ( " Not yet implemented " ) ; <nl> + int sz = 512 ; <nl> + Mat img = new Mat ( sz , sz , CvType . CV_8U , new Scalar ( 128 ) ) ; <nl> + <nl> + Mat circles = new Mat ( ) ; <nl> + <nl> + Imgproc . HoughCircles ( img , circles , Imgproc . CV_HOUGH_GRADIENT , 2 . 0 , img . rows ( ) / 4 ) ; <nl> + assertEquals ( 0 , circles . cols ( ) ) ; <nl> + <nl> + Point center = new Point ( img . cols ( ) / 2 , img . rows ( ) / 2 ) ; <nl> + int radius = Math . min ( img . cols ( ) / 4 , img . rows ( ) / 4 ) ; <nl> + Core . circle ( img , center , radius , colorBlack , 3 ) ; <nl> + <nl> + Imgproc . HoughCircles ( img , circles , Imgproc . CV_HOUGH_GRADIENT , 2 . 0 , img . rows ( ) / 4 ) ; <nl> + assertEquals ( 1 , circles . cols ( ) ) ; <nl> } <nl> <nl> public void testHoughCirclesMatMatIntDoubleDoubleDouble ( ) { <nl> public void testInitUndistortRectifyMap ( ) { <nl> Mat map1 = new Mat ( ) ; <nl> Mat map2 = new Mat ( ) ; <nl> <nl> - / / FIXME : dstmap1 - Documentation says Cvtype but requires integer <nl> - Imgproc . initUndistortRectifyMap ( cameraMatrix , distCoeffs , R , <nl> - newCameraMatrix , size , CvType . CV_32F , map1 , map2 ) ; <nl> + / / TODO : complete this test <nl> + Imgproc . initUndistortRectifyMap ( cameraMatrix , distCoeffs , <nl> + R , newCameraMatrix , size , CvType . CV_32F , map1 , map2 ) ; <nl> fail ( " Not yet implemented " ) ; <nl> } <nl> <nl> public void testLaplacianMatMatIntInt ( ) { <nl> public void testLaplacianMatMatIntIntDouble ( ) { <nl> Mat src = Mat . eye ( imgprocSz , imgprocSz , CvType . CV_32F ) ; <nl> <nl> + Imgproc . Laplacian ( src , dst , CvType . CV_32F , 1 , 2 . 0 ) ; <nl> truth = new Mat ( imgprocSz , imgprocSz , CvType . CV_32F ) ; <nl> - <nl> truth . put ( 0 , 0 , - 8 , 8 ) ; <nl> truth . put ( 1 , 0 , 8 , - 8 ) ; <nl> - <nl> - Imgproc . Laplacian ( src , dst , CvType . CV_32F , 1 , 2 . 0 ) ; <nl> assertMatEqual ( truth , dst , EPS ) ; <nl> } <nl> <nl> public void testMatchShapes ( ) { <nl> Mat contour2 = new Mat ( 1 , 4 , CvType . CV_32FC2 ) ; <nl> <nl> contour1 . put ( 0 , 0 , 1 . 0 , 1 . 0 , 5 . 0 , 1 . 0 , 4 . 0 , 3 . 0 , 6 . 0 , 2 . 0 ) ; <nl> - contour1 . put ( 0 , 0 , 1 . 0 , 1 . 0 , 6 . 0 , 1 . 0 , 4 . 0 , 1 . 0 , 2 . 0 , 5 . 0 ) ; <nl> + contour2 . put ( 0 , 0 , 1 . 0 , 1 . 0 , 6 . 0 , 1 . 0 , 4 . 0 , 1 . 0 , 2 . 0 , 5 . 0 ) ; <nl> <nl> - / / TODO : returns random comparers <nl> - double comparer = Imgproc . matchShapes ( contour1 , contour2 , <nl> - Imgproc . CV_CONTOURS_MATCH_I1 , 1 . 0 ) ; <nl> - double expComparer = 2 . 98 ; <nl> - assertEquals ( expComparer , comparer ) ; <nl> + double comparer = Imgproc . matchShapes ( contour1 , contour2 , Imgproc . CV_CONTOURS_MATCH_I1 , 1 . 0 ) ; <nl> + double truthComparer = 2 . 98 ; <nl> + assertEquals ( truthComparer , comparer , weakEPS ) ; <nl> } <nl> <nl> public void testMatchTemplate ( ) { <nl> public void testMinAreaRect ( ) { <nl> points . put ( 0 , 0 , 1 . 0 , 1 . 0 , 5 . 0 , 1 . 0 , 4 . 0 , 3 . 0 , 6 . 0 , 2 . 0 ) ; <nl> <nl> RotatedRect rrect = Imgproc . minAreaRect ( points ) ; <nl> - / / TODO - how to test rotated rectangle <nl> - fail ( " Not yet implemented " ) ; <nl> + assertEquals ( new Size ( 2 , 5 ) , rrect . size ) ; <nl> + assertEquals ( - 90 . 0 , rrect . angle ) ; <nl> + assertEquals ( new Point ( 3 . 5 , 2 ) , rrect . center ) ; <nl> } <nl> <nl> public void testMinEnclosingCircle ( ) { <nl> Mat points = new Mat ( 1 , 4 , CvType . CV_32FC2 ) ; <nl> - Point actualCenter = new Point ( ) ; <nl> - Point expCenter = new Point ( 0 , 0 ) ; <nl> - float radius = 0 . 0f ; <nl> - / / float expectedRadius = 1 . 0f ; <nl> points . put ( 0 , 0 , - 1 . 0 , 0 . 0 , 0 . 0 , 1 . 0 , 1 . 0 , 0 . 0 , 0 . 0 , - 1 . 0 ) ; <nl> - / / TODO : Unexpected radius is returned i . e 0 <nl> + <nl> + OpenCVTestRunner . Log ( points . toString ( ) ) ; <nl> + OpenCVTestRunner . Log ( points . dump ( ) ) ; <nl> + <nl> + Point actualCenter = new Point ( ) ; <nl> + float radius = 347 . 0f ; / / FIXME : Unexpected radius is returned i . e 0 <nl> Imgproc . minEnclosingCircle ( points , actualCenter , radius ) ; <nl> - assertEquals ( expCenter , actualCenter ) ; <nl> - / / assertEquals ( expectedRadius , radius ) ; <nl> - fail ( " Not yet implemented " ) ; <nl> + <nl> + Point truthCenter = new Point ( 0 , 0 ) ; <nl> + assertEquals ( truthCenter , actualCenter ) ; <nl> + <nl> + float truthRadius = 1 . 0f ; <nl> + OpenCVTestRunner . Log ( " " + radius ) ; <nl> + assertEquals ( truthRadius , radius , weakEPS ) ; <nl> } <nl> <nl> public void testMomentsMat ( ) { <nl> public void testPyrDownMatMatSize ( ) { <nl> <nl> public void testPyrMeanShiftFilteringMatMatDoubleDouble ( ) { <nl> Mat src = new Mat ( matSize , matSize , CvType . CV_8UC3 , new Scalar ( 0 . 0 ) ) ; <nl> - Imgproc . pyrMeanShiftFiltering ( src , dst , 2 . 0 , 4 . 0 ) ; <nl> - / / TODO : size of destination matrix not understandable <nl> - fail ( " Not yet implemented " ) ; <nl> + <nl> + Imgproc . pyrMeanShiftFiltering ( src , dst , 10 . 0 , 50 . 0 ) ; <nl> + truth = src . clone ( ) ; <nl> + assertMatEqual ( truth , dst ) ; <nl> } <nl> <nl> public void testPyrMeanShiftFilteringMatMatDoubleDoubleInt ( ) { <nl>
|
java tests : added some new asserts , and new tests by Hussein Abdinoor
|
opencv/opencv
|
edead9a2c21ad7050f4fca1591c57f0fbab601f4
|
2011-07-30T12:01:00Z
|
mmm a / arangod / HashIndex / hash - index . c <nl> ppp b / arangod / HashIndex / hash - index . c <nl> static TRI_index_result_t HashIndex_find ( TRI_hash_index_t * hashIndex , <nl> results . _documents = TRI_Allocate ( TRI_UNKNOWN_MEM_ZONE , 1 * sizeof ( TRI_doc_mptr_t * ) , false ) ; <nl> <nl> if ( results . _documents = = NULL ) { <nl> + / / no memory . prevent worst case by re - setting results length to 0 <nl> + results . _length = 0 ; <nl> return results ; <nl> } <nl> <nl> static TRI_index_result_t MultiHashIndex_find ( TRI_hash_index_t * hashIndex , <nl> false ) ; <nl> <nl> if ( results . _documents = = NULL ) { <nl> + / / no memory . prevent worst case by re - setting results length to 0 <nl> TRI_DestroyVectorPointer ( & result ) ; <nl> + results . _length = 0 ; <nl> + <nl> return results ; <nl> } <nl> <nl>
|
do not traverse invalid memory for hash index results
|
arangodb/arangodb
|
970619d6eee17ab9204e05b8a4f99ab18ddb925c
|
2013-07-02T15:16:35Z
|
mmm a / Makefile <nl> ppp b / Makefile <nl> <nl> - VENV : = build / venv <nl> DOCS_OUTPUT_DIR ? = generated / docs <nl> + DOCS_PUBLISH_DIR ? = . . / envoy - docs <nl> <nl> . PHONY : docs <nl> docs : <nl> rm - fr generated / docs <nl> mkdir - p generated / docs <nl> docs / build . sh $ ( DOCS_OUTPUT_DIR ) <nl> + <nl> + . PHONY : publish_docs <nl> + publish_docs : docs <nl> + docs / publish . sh $ ( DOCS_OUTPUT_DIR ) $ ( DOCS_PUBLISH_DIR ) <nl> + <nl> new file mode 100644 <nl> index 00000000000 . . fbe664acad6 <nl> mmm / dev / null <nl> ppp b / docs / README . md <nl> <nl> + How to publish new docs : <nl> + <nl> + * The docs are contained in the gh - pages branch in the repo . <nl> + * Clone a fresh copy of the repo into a parallel envoy - docs directory . <nl> + * Run : ` make publish_docs ` <nl> + * Run : ` cd . . / envoy - docs ` <nl> + * Verify the latest commit looks OK <nl> + * Run : ` git push origin gh - pages : gh - pages ` <nl> mmm a / docs / conf . py <nl> ppp b / docs / conf . py <nl> <nl> import sphinx_rtd_theme <nl> import sys <nl> import os <nl> + import git <nl> <nl> # If extensions ( or modules to document with autodoc ) are in another directory , <nl> # add these directories to sys . path here . If the directory is relative to the <nl> <nl> # The version info for the project you ' re documenting , acts as replacement for <nl> # | version | and | release | , also used in various other places throughout the <nl> # built documents . <nl> - # <nl> + <nl> + repo = git . Repo ( ' . . / ' ) <nl> + last_commit = str ( repo . head . commit ) [ : 6 ] <nl> + <nl> # The short X . Y version . <nl> - version = u ' 1 . 0 . 0 ' <nl> + version = u ' 1 . 1 . 0 - ' + last_commit <nl> # The full version , including alpha / beta / rc tags . <nl> - release = u ' 1 . 0 . 0 ' <nl> + release = u ' 1 . 1 . 0 - ' + last_commit <nl> <nl> # The language for content autogenerated by Sphinx . Refer to documentation <nl> # for a list of supported languages . <nl> new file mode 100755 <nl> index 00000000000 . . 70f91c839e2 <nl> mmm / dev / null <nl> ppp b / docs / publish . sh <nl> <nl> + # ! / bin / bash <nl> + <nl> + set - e <nl> + <nl> + DOCS_DIR = $ 1 <nl> + PUBLISH_DIR = $ 2 <nl> + BUILD_SHA = ` git rev - parse HEAD ` <nl> + <nl> + if [ [ ! - d $ PUBLISH_DIR ] ] ; then <nl> + echo " $ PUBLISH_DIR does not exist . Clone a fresh envoy repo . " <nl> + fi <nl> + <nl> + git - C $ PUBLISH_DIR fetch <nl> + git - C $ PUBLISH_DIR checkout - B gh - pages origin / gh - pages <nl> + rm - fr $ PUBLISH_DIR / * <nl> + cp - r $ DOCS_DIR / * $ PUBLISH_DIR <nl> + git - C $ PUBLISH_DIR add . <nl> + git - C $ PUBLISH_DIR commit - m " docs @ $ BUILD_SHA " <nl> + <nl> + echo <nl> + echo " * * * YOU MUST MANUALLY PUSH the gh - pages branch after verifying the commit * * * " <nl> mmm a / docs / requirements . txt <nl> ppp b / docs / requirements . txt <nl> <nl> sphinx = = 1 . 4 . 5 <nl> sphinx_rtd_theme = = 0 . 1 . 9 <nl> sphinxcontrib - httpdomain = = 1 . 5 . 0 <nl> + GitPython = = 2 . 0 . 8 <nl>
|
docs : add publish script ( )
|
envoyproxy/envoy
|
ead3d93cc22086522e66c88f0f3a6c5f997598c9
|
2016-09-28T19:30:28Z
|
mmm a / cmake / find / h3 . cmake <nl> ppp b / cmake / find / h3 . cmake <nl> if ( USE_INTERNAL_H3_LIBRARY ) <nl> set ( H3_LIBRARY h3 ) <nl> set ( H3_INCLUDE_DIR $ { ClickHouse_SOURCE_DIR } / contrib / h3 / src / h3lib / include ) <nl> elseif ( NOT MISSING_INTERNAL_H3_LIBRARY ) <nl> - set ( H3_INCLUDE_PATHS / usr / local / include / h3 ) <nl> find_library ( H3_LIBRARY h3 ) <nl> - find_path ( H3_INCLUDE_DIR NAMES h3api . h PATHS $ { H3_INCLUDE_PATHS } ) <nl> + find_path ( H3_INCLUDE_DIR NAMES h3 / h3api . h PATHS $ { H3_INCLUDE_PATHS } ) <nl> endif ( ) <nl> <nl> if ( H3_LIBRARY AND H3_INCLUDE_DIR ) <nl>
|
Fix H3_INCLUDE_DIR find
|
ClickHouse/ClickHouse
|
394714bca9b768fbe33f8b5106a774404efe79f9
|
2020-01-20T16:59:28Z
|
mmm a / caffe2 / python / attention . py <nl> ppp b / caffe2 / python / attention . py <nl> <nl> <nl> <nl> class AttentionType : <nl> - Regular , Recurrent , Dot = tuple ( range ( 3 ) ) <nl> + Regular , Recurrent , Dot , SoftCoverage = tuple ( range ( 4 ) ) <nl> <nl> <nl> def s ( scope , name ) : <nl> def apply_recurrent_attention ( <nl> scope = scope , <nl> name = ' weighted_decoder_hidden_state ' , <nl> ) <nl> - # [ encoder_length , batch_size , encoder_output_dim ] <nl> + # [ 1 , batch_size , encoder_output_dim ] <nl> decoder_hidden_encoder_outputs_sum_tmp = model . net . Add ( <nl> [ <nl> weighted_prev_attention_context , <nl> def apply_dot_attention ( <nl> scope = scope , <nl> ) <nl> return attention_weighted_encoder_context , attention_weights_3d , [ ] <nl> + <nl> + <nl> + def apply_soft_coverage_attention ( <nl> + model , <nl> + encoder_output_dim , <nl> + encoder_outputs_transposed , <nl> + weighted_encoder_outputs , <nl> + decoder_hidden_state_t , <nl> + decoder_hidden_state_dim , <nl> + scope , <nl> + encoder_lengths , <nl> + coverage_t_prev , <nl> + coverage_weights , <nl> + ) : <nl> + <nl> + weighted_decoder_hidden_state = _apply_fc_weight_for_sum_match ( <nl> + model = model , <nl> + input = decoder_hidden_state_t , <nl> + dim_in = decoder_hidden_state_dim , <nl> + dim_out = encoder_output_dim , <nl> + scope = scope , <nl> + name = ' weighted_decoder_hidden_state ' , <nl> + ) <nl> + <nl> + # [ encoder_length , batch_size , encoder_output_dim ] <nl> + decoder_hidden_encoder_outputs_sum = model . net . Add ( <nl> + [ weighted_encoder_outputs , weighted_decoder_hidden_state ] , <nl> + s ( scope , ' decoder_hidden_encoder_outputs_sum ' ) , <nl> + broadcast = 1 , <nl> + ) <nl> + # [ batch_size , encoder_length ] <nl> + coverage_t_prev_2d = model . net . Squeeze ( <nl> + coverage_t_prev , <nl> + s ( scope , ' coverage_t_prev_2d ' ) , <nl> + dims = [ 0 ] , <nl> + ) <nl> + # [ encoder_length , batch_size ] <nl> + coverage_t_prev_transposed = brew . transpose ( <nl> + model , <nl> + coverage_t_prev_2d , <nl> + s ( scope , ' coverage_t_prev_transposed ' ) , <nl> + ) <nl> + <nl> + # [ encoder_length , batch_size , encoder_output_dim ] <nl> + scaled_coverage_weights = model . net . Mul ( <nl> + [ coverage_weights , coverage_t_prev_transposed ] , <nl> + s ( scope , ' scaled_coverage_weights ' ) , <nl> + broadcast = 1 , <nl> + axis = 0 , <nl> + ) <nl> + <nl> + # [ encoder_length , batch_size , encoder_output_dim ] <nl> + decoder_hidden_encoder_outputs_sum = model . net . Add ( <nl> + [ decoder_hidden_encoder_outputs_sum , scaled_coverage_weights ] , <nl> + decoder_hidden_encoder_outputs_sum , <nl> + ) <nl> + <nl> + # [ batch_size , encoder_length , 1 ] <nl> + attention_logits_transposed = _calc_attention_logits_from_sum_match ( <nl> + model = model , <nl> + decoder_hidden_encoder_outputs_sum = decoder_hidden_encoder_outputs_sum , <nl> + encoder_output_dim = encoder_output_dim , <nl> + scope = scope , <nl> + ) <nl> + <nl> + # [ batch_size , encoder_length , 1 ] <nl> + attention_weights_3d = _calc_attention_weights ( <nl> + model = model , <nl> + attention_logits_transposed = attention_logits_transposed , <nl> + scope = scope , <nl> + encoder_lengths = encoder_lengths , <nl> + ) <nl> + <nl> + # [ batch_size , encoder_output_dim , 1 ] <nl> + attention_weighted_encoder_context = _calc_weighted_context ( <nl> + model = model , <nl> + encoder_outputs_transposed = encoder_outputs_transposed , <nl> + encoder_output_dim = encoder_output_dim , <nl> + attention_weights_3d = attention_weights_3d , <nl> + scope = scope , <nl> + ) <nl> + <nl> + # [ batch_size , encoder_length ] <nl> + attention_weights_2d = model . net . Squeeze ( <nl> + attention_weights_3d , <nl> + s ( scope , ' attention_weights_2d ' ) , <nl> + dims = [ 2 ] , <nl> + ) <nl> + <nl> + coverage_t = model . net . Add ( <nl> + [ coverage_t_prev , attention_weights_2d ] , <nl> + s ( scope , ' coverage_t ' ) , <nl> + broadcast = 1 , <nl> + ) <nl> + <nl> + return ( <nl> + attention_weighted_encoder_context , <nl> + attention_weights_3d , <nl> + [ decoder_hidden_encoder_outputs_sum ] , <nl> + coverage_t , <nl> + ) <nl> mmm a / caffe2 / python / operator_test / rnn_cell_test . py <nl> ppp b / caffe2 / python / operator_test / rnn_cell_test . py <nl> def compute_regular_attention_logits ( <nl> attention_v , <nl> weighted_encoder_outputs , <nl> encoder_outputs_for_dot_product , <nl> + coverage_prev , <nl> + coverage_weights , <nl> ) : <nl> weighted_hidden_t = np . dot ( <nl> hidden_t , <nl> def compute_recurrent_attention_logits ( <nl> attention_v , <nl> weighted_encoder_outputs , <nl> encoder_outputs_for_dot_product , <nl> + coverage_prev , <nl> + coverage_weights , <nl> ) : <nl> weighted_hidden_t = np . dot ( <nl> hidden_t , <nl> def compute_dot_attention_logits ( <nl> attention_v , <nl> weighted_encoder_outputs , <nl> encoder_outputs_for_dot_product , <nl> + coverage_prev , <nl> + coverage_weights , <nl> ) : <nl> hidden_t_for_dot_product = np . transpose ( hidden_t , axes = [ 1 , 2 , 0 ] ) <nl> if ( <nl> def compute_dot_attention_logits ( <nl> return np . transpose ( attention_logits_t ) <nl> <nl> <nl> + def compute_coverage_attention_logits ( <nl> + hidden_t , <nl> + weighted_decoder_hidden_state_t_w , <nl> + weighted_decoder_hidden_state_t_b , <nl> + attention_weighted_encoder_context_t_prev , <nl> + weighted_prev_attention_context_w , <nl> + weighted_prev_attention_context_b , <nl> + attention_v , <nl> + weighted_encoder_outputs , <nl> + encoder_outputs_for_dot_product , <nl> + coverage_prev , <nl> + coverage_weights , <nl> + ) : <nl> + weighted_hidden_t = np . dot ( <nl> + hidden_t , <nl> + weighted_decoder_hidden_state_t_w . T , <nl> + ) + weighted_decoder_hidden_state_t_b <nl> + coverage_part = coverage_prev . T * coverage_weights <nl> + encoder_part = weighted_encoder_outputs + coverage_part <nl> + attention_v = attention_v . reshape ( [ - 1 ] ) <nl> + return np . sum ( <nl> + attention_v * np . tanh ( encoder_part + weighted_hidden_t ) , <nl> + axis = 2 , <nl> + ) <nl> + <nl> + <nl> def lstm_with_attention_reference ( <nl> input , <nl> initial_hidden_state , <nl> def lstm_with_attention_reference ( <nl> weighted_decoder_hidden_state_t_w , <nl> weighted_decoder_hidden_state_t_b , <nl> weighted_encoder_outputs , <nl> + coverage_weights , <nl> attention_v , <nl> attention_zeros , <nl> compute_attention_logits , <nl> def lstm_with_attention_reference ( <nl> attention_weighted_encoder_context [ 0 , : , : ] = ( <nl> initial_attention_weighted_encoder_context <nl> ) <nl> + encoder_length = encoder_outputs . shape [ 0 ] <nl> + coverage = np . zeros ( <nl> + shape = ( decoder_input_length + 1 , batch_size , encoder_length ) ) <nl> for t in range ( decoder_input_length ) : <nl> input_t = input [ t ] . reshape ( 1 , batch_size , decoder_input_dim ) <nl> hidden_t_prev = hidden [ t ] . reshape ( 1 , batch_size , decoder_state_dim ) <nl> def lstm_with_attention_reference ( <nl> hidden [ t + 1 ] = hidden_t <nl> cell [ t + 1 ] = cell_t <nl> <nl> + coverage_prev = coverage [ t ] . reshape ( 1 , batch_size , encoder_length ) <nl> + <nl> attention_logits_t = compute_attention_logits ( <nl> hidden_t , <nl> weighted_decoder_hidden_state_t_w , <nl> def lstm_with_attention_reference ( <nl> attention_v , <nl> weighted_encoder_outputs , <nl> encoder_outputs_for_dot_product , <nl> + coverage_prev , <nl> + coverage_weights , <nl> ) <nl> <nl> attention_logits_t_exp = np . exp ( attention_logits_t ) <nl> def lstm_with_attention_reference ( <nl> attention_logits_t_exp / <nl> np . sum ( attention_logits_t_exp , axis = 0 ) . reshape ( [ 1 , - 1 ] ) <nl> ) <nl> + coverage [ t + 1 , : , : ] = coverage [ t , : , : ] + attention_weights_t . T <nl> attention_weighted_encoder_context [ t + 1 ] = np . sum ( <nl> ( <nl> encoder_outputs * <nl> def lstm_with_regular_attention_reference ( <nl> weighted_decoder_hidden_state_t_w = weighted_decoder_hidden_state_t_w , <nl> weighted_decoder_hidden_state_t_b = weighted_decoder_hidden_state_t_b , <nl> weighted_encoder_outputs = weighted_encoder_outputs , <nl> + coverage_weights = None , <nl> attention_v = attention_v , <nl> attention_zeros = attention_zeros , <nl> compute_attention_logits = compute_regular_attention_logits , <nl> def lstm_with_recurrent_attention_reference ( <nl> weighted_decoder_hidden_state_t_w = weighted_decoder_hidden_state_t_w , <nl> weighted_decoder_hidden_state_t_b = weighted_decoder_hidden_state_t_b , <nl> weighted_encoder_outputs = weighted_encoder_outputs , <nl> + coverage_weights = None , <nl> attention_v = attention_v , <nl> attention_zeros = attention_zeros , <nl> compute_attention_logits = compute_recurrent_attention_logits , <nl> def lstm_with_dot_attention_reference ( <nl> weighted_decoder_hidden_state_t_w = weighted_decoder_hidden_state_t_w , <nl> weighted_decoder_hidden_state_t_b = weighted_decoder_hidden_state_t_b , <nl> weighted_encoder_outputs = None , <nl> + coverage_weights = None , <nl> attention_v = None , <nl> attention_zeros = None , <nl> compute_attention_logits = compute_dot_attention_logits , <nl> def lstm_with_dot_attention_reference_different_dim ( <nl> ) <nl> <nl> <nl> + def lstm_with_coverage_attention_reference ( <nl> + input , <nl> + initial_hidden_state , <nl> + initial_cell_state , <nl> + initial_attention_weighted_encoder_context , <nl> + initial_coverage , <nl> + gates_w , <nl> + gates_b , <nl> + decoder_input_lengths , <nl> + weighted_decoder_hidden_state_t_w , <nl> + weighted_decoder_hidden_state_t_b , <nl> + weighted_encoder_outputs , <nl> + coverage_weights , <nl> + attention_v , <nl> + attention_zeros , <nl> + encoder_outputs_transposed , <nl> + ) : <nl> + return lstm_with_attention_reference ( <nl> + input = input , <nl> + initial_hidden_state = initial_hidden_state , <nl> + initial_cell_state = initial_cell_state , <nl> + initial_attention_weighted_encoder_context = ( <nl> + initial_attention_weighted_encoder_context <nl> + ) , <nl> + gates_w = gates_w , <nl> + gates_b = gates_b , <nl> + decoder_input_lengths = decoder_input_lengths , <nl> + encoder_outputs_transposed = encoder_outputs_transposed , <nl> + weighted_prev_attention_context_w = None , <nl> + weighted_prev_attention_context_b = None , <nl> + weighted_decoder_hidden_state_t_w = weighted_decoder_hidden_state_t_w , <nl> + weighted_decoder_hidden_state_t_b = weighted_decoder_hidden_state_t_b , <nl> + weighted_encoder_outputs = weighted_encoder_outputs , <nl> + coverage_weights = coverage_weights , <nl> + attention_v = attention_v , <nl> + attention_zeros = attention_zeros , <nl> + compute_attention_logits = compute_coverage_attention_logits , <nl> + ) <nl> + <nl> + <nl> def milstm_reference ( <nl> input , <nl> hidden_input , <nl> def test_lstm_with_dot_attention_different_dim ( <nl> gc , <nl> ) <nl> <nl> + @ given ( encoder_output_length = st . integers ( 2 , 3 ) , <nl> + encoder_output_dim = st . integers ( 1 , 3 ) , <nl> + decoder_input_length = st . integers ( 1 , 3 ) , <nl> + decoder_state_dim = st . integers ( 1 , 3 ) , <nl> + batch_size = st . integers ( 1 , 3 ) , <nl> + * * hu . gcs ) <nl> + def test_lstm_with_coverage_attention ( <nl> + self , <nl> + encoder_output_length , <nl> + encoder_output_dim , <nl> + decoder_input_length , <nl> + decoder_state_dim , <nl> + batch_size , <nl> + gc , <nl> + dc , <nl> + ) : <nl> + self . lstm_with_attention ( <nl> + partial ( <nl> + rnn_cell . LSTMWithAttention , <nl> + attention_type = AttentionType . SoftCoverage , <nl> + ) , <nl> + encoder_output_length , <nl> + encoder_output_dim , <nl> + decoder_input_length , <nl> + decoder_state_dim , <nl> + batch_size , <nl> + lstm_with_coverage_attention_reference , <nl> + gc , <nl> + ) <nl> + <nl> def lstm_with_attention ( <nl> self , <nl> create_lstm_with_attention , <nl> def lstm_with_attention ( <nl> encoder_output_dim , <nl> ) . astype ( np . float32 ) , <nl> ) <nl> + workspace . FeedBlob ( <nl> + ' external / LSTMWithAttention / coverage_weights ' , <nl> + np . random . randn ( <nl> + encoder_output_length , <nl> + batch_size , <nl> + encoder_output_dim , <nl> + ) . astype ( np . float32 ) , <nl> + ) <nl> workspace . FeedBlob ( <nl> decoder_input_lengths , <nl> np . random . randint ( <nl> def lstm_with_attention ( <nl> np . random . randn ( <nl> 1 , batch_size , encoder_output_dim ) . astype ( np . float32 ) <nl> ) <nl> + workspace . FeedBlob ( <nl> + ' external / LSTMWithAttention / initial_coverage ' , <nl> + np . zeros ( ( 1 , batch_size , encoder_output_length ) ) . astype ( np . float32 ) , <nl> + ) <nl> inputs = [ workspace . FetchBlob ( name ) for name in op . input ] <nl> self . assertReferenceChecks ( <nl> device_option = gc , <nl> mmm a / caffe2 / python / rnn_cell . py <nl> ppp b / caffe2 / python / rnn_cell . py <nl> <nl> apply_regular_attention , <nl> apply_recurrent_attention , <nl> apply_dot_attention , <nl> + apply_soft_coverage_attention , <nl> ) <nl> from caffe2 . python import core , recurrent , workspace , brew , scope <nl> from caffe2 . python . modeling . parameter_sharing import ParameterSharing <nl> def __init__ ( <nl> AttentionType . Regular , <nl> AttentionType . Recurrent , <nl> AttentionType . Dot , <nl> + AttentionType . SoftCoverage , <nl> ] <nl> self . attention_type = attention_type <nl> self . attention_memory_optimization = attention_memory_optimization <nl> def _apply ( <nl> timestep , <nl> extra_inputs = None , <nl> ) : <nl> - decoder_prev_states = states [ : - 1 ] <nl> - attention_weighted_encoder_context_t_prev = states [ - 1 ] <nl> + if self . attention_type = = AttentionType . SoftCoverage : <nl> + decoder_prev_states = states [ : - 2 ] <nl> + attention_weighted_encoder_context_t_prev = states [ - 2 ] <nl> + coverage_t_prev = states [ - 1 ] <nl> + else : <nl> + decoder_prev_states = states [ : - 1 ] <nl> + attention_weighted_encoder_context_t_prev = states [ - 1 ] <nl> <nl> assert extra_inputs is None <nl> <nl> def _apply ( <nl> scope = self . name , <nl> encoder_lengths = self . encoder_lengths , <nl> ) <nl> + elif self . attention_type = = AttentionType . SoftCoverage : <nl> + ( <nl> + attention_weighted_encoder_context_t , <nl> + self . attention_weights_3d , <nl> + attention_blobs , <nl> + coverage_t , <nl> + ) = apply_soft_coverage_attention ( <nl> + model = model , <nl> + encoder_output_dim = self . encoder_output_dim , <nl> + encoder_outputs_transposed = self . encoder_outputs_transposed , <nl> + weighted_encoder_outputs = self . weighted_encoder_outputs , <nl> + decoder_hidden_state_t = self . hidden_t_intermediate , <nl> + decoder_hidden_state_dim = self . decoder_state_dim , <nl> + scope = self . name , <nl> + encoder_lengths = self . encoder_lengths , <nl> + coverage_t_prev = coverage_t_prev , <nl> + coverage_weights = self . coverage_weights , <nl> + ) <nl> else : <nl> raise Exception ( ' Attention type { } not implemented ' . format ( <nl> self . attention_type <nl> def _apply ( <nl> self . recompute_blobs . extend ( attention_blobs ) <nl> <nl> output = list ( decoder_states ) + [ attention_weighted_encoder_context_t ] <nl> + if self . attention_type = = AttentionType . SoftCoverage : <nl> + output . append ( coverage_t ) <nl> + <nl> output [ self . decoder_cell . get_output_state_index ( ) ] = model . Copy ( <nl> output [ self . decoder_cell . get_output_state_index ( ) ] , <nl> self . scope ( ' hidden_t_external ' ) , <nl> def prepare_input ( self , model , input_blob ) : <nl> <nl> return self . decoder_cell . prepare_input ( model , input_blob ) <nl> <nl> + def build_initial_coverage ( self , model ) : <nl> + " " " <nl> + initial_coverage is always zeros of shape [ encoder_length ] , <nl> + which shape must be determined programmatically dureing network <nl> + computation . <nl> + <nl> + This method also sets self . coverage_weights , a separate transform <nl> + of encoder_outputs which is used to determine coverage contribution <nl> + tp attention . <nl> + " " " <nl> + assert self . attention_type = = AttentionType . SoftCoverage <nl> + <nl> + # [ encoder_length , batch_size , encoder_output_dim ] <nl> + self . coverage_weights = brew . fc ( <nl> + model , <nl> + self . encoder_outputs , <nl> + self . scope ( ' coverage_weights ' ) , <nl> + dim_in = self . encoder_output_dim , <nl> + dim_out = self . encoder_output_dim , <nl> + axis = 2 , <nl> + ) <nl> + <nl> + encoder_length = model . net . Slice ( <nl> + model . net . Shape ( self . encoder_outputs ) , <nl> + starts = [ 0 ] , <nl> + ends = [ 1 ] , <nl> + ) <nl> + if ( <nl> + scope . CurrentDeviceScope ( ) is not None and <nl> + scope . CurrentDeviceScope ( ) . device_type = = caffe2_pb2 . CUDA <nl> + ) : <nl> + encoder_length = model . net . CopyGPUToCPU ( <nl> + encoder_length , <nl> + ' encoder_length_cpu ' , <nl> + ) <nl> + # total attention weight applied across decoding steps_per_checkpoint <nl> + # shape : [ encoder_length ] <nl> + initial_coverage = model . net . ConstantFill ( <nl> + encoder_length , <nl> + self . scope ( ' initial_coverage ' ) , <nl> + value = 0 . 0 , <nl> + input_as_shape = 1 , <nl> + ) <nl> + return initial_coverage <nl> + <nl> def get_state_names ( self ) : <nl> state_names = list ( self . decoder_cell . get_state_names ( ) ) <nl> state_names [ self . get_output_state_index ( ) ] = self . scope ( <nl> ' hidden_t_external ' , <nl> ) <nl> state_names . append ( self . scope ( ' attention_weighted_encoder_context_t ' ) ) <nl> + if self . attention_type = = AttentionType . SoftCoverage : <nl> + state_names . append ( self . scope ( ' coverage_t ' ) ) <nl> return state_names <nl> <nl> def get_output_dim ( self ) : <nl> def get_output_state_index ( self ) : <nl> return self . decoder_cell . get_output_state_index ( ) <nl> <nl> def _prepare_output ( self , model , states ) : <nl> - attention_context = states [ - 1 ] <nl> + if self . attention_type = = AttentionType . SoftCoverage : <nl> + attention_context = states [ - 2 ] <nl> + else : <nl> + attention_context = states [ - 1 ] <nl> + <nl> with core . NameScope ( self . name or ' ' ) : <nl> output , _ = model . net . Concat ( <nl> [ self . hidden_t_intermediate , attention_context ] , <nl> def _prepare_output ( self , model , states ) : <nl> return output <nl> <nl> def _prepare_output_sequence ( self , model , state_outputs ) : <nl> + if self . attention_type = = AttentionType . SoftCoverage : <nl> + decoder_state_outputs = state_outputs [ : - 4 ] <nl> + else : <nl> + decoder_state_outputs = state_outputs [ : - 2 ] <nl> + <nl> decoder_output = self . decoder_cell . _prepare_output_sequence ( <nl> model , <nl> - state_outputs [ : - 2 ] , <nl> + decoder_state_outputs , <nl> ) <nl> - attention_context_index = 2 * ( len ( self . get_state_names ( ) ) - 1 ) <nl> + <nl> + if self . attention_type = = AttentionType . SoftCoverage : <nl> + attention_context_index = 2 * ( len ( self . get_state_names ( ) ) - 2 ) <nl> + else : <nl> + attention_context_index = 2 * ( len ( self . get_state_names ( ) ) - 1 ) <nl> + <nl> with core . NameScope ( self . name or ' ' ) : <nl> output , _ = model . net . Concat ( <nl> [ <nl> def LSTMWithAttention ( <nl> attention_memory_optimization = attention_memory_optimization , <nl> forward_only = forward_only , <nl> ) <nl> + initial_states = [ <nl> + initial_decoder_hidden_state , <nl> + initial_decoder_cell_state , <nl> + initial_attention_weighted_encoder_context , <nl> + ] <nl> + if attention_type = = AttentionType . SoftCoverage : <nl> + initial_states . append ( cell . build_initial_coverage ( model ) ) <nl> _ , result = cell . apply_over_sequence ( <nl> model = model , <nl> inputs = decoder_inputs , <nl> seq_lengths = decoder_input_lengths , <nl> - initial_states = ( <nl> - initial_decoder_hidden_state , <nl> - initial_decoder_cell_state , <nl> - initial_attention_weighted_encoder_context , <nl> - ) , <nl> + initial_states = initial_states , <nl> outputs_with_grads = outputs_with_grads , <nl> ) <nl> return result <nl>
|
soft - coverage attention
|
pytorch/pytorch
|
53ccbd9a6e944e9a070caa8ca5a84b2ab4b0cd20
|
2017-09-01T04:21:54Z
|
mmm a / c11logtest / c11logtest / c11logtest . vcxproj <nl> ppp b / c11logtest / c11logtest / c11logtest . vcxproj <nl> <nl> < Link > <nl> < SubSystem > Console < / SubSystem > <nl> < GenerateDebugInformation > true < / GenerateDebugInformation > <nl> + < Profile > true < / Profile > <nl> < / Link > <nl> < / ItemDefinitionGroup > <nl> < ItemDefinitionGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Release | Win32 ' " > <nl> <nl> < ClInclude Include = " . . \ . . \ include \ c11log \ details \ blocking_queue . h " / > <nl> < ClInclude Include = " . . \ . . \ include \ c11log \ details \ fast_oss . h " / > <nl> < ClInclude Include = " . . \ . . \ include \ c11log \ details \ flush_helper . h " / > <nl> + < ClInclude Include = " . . \ . . \ include \ c11log \ details \ fast_istostr . h " / > <nl> < ClInclude Include = " . . \ . . \ include \ c11log \ details \ line_logger . h " / > <nl> < ClInclude Include = " . . \ . . \ include \ c11log \ details \ log_msg . h " / > <nl> < ClInclude Include = " . . \ . . \ include \ c11log \ details \ null_mutex . h " / > <nl> <nl> < ClInclude Include = " . . \ . . \ include \ c11log \ factory . h " / > <nl> < ClInclude Include = " . . \ . . \ include \ c11log \ formatter . h " / > <nl> < ClInclude Include = " . . \ . . \ include \ c11log \ logger . h " / > <nl> + < ClInclude Include = " . . \ . . \ include \ c11log \ pattern_formatter . h " / > <nl> < ClInclude Include = " . . \ . . \ include \ c11log \ sinks \ async_sink . h " / > <nl> < ClInclude Include = " . . \ . . \ include \ c11log \ sinks \ base_sink . h " / > <nl> < ClInclude Include = " . . \ . . \ include \ c11log \ sinks \ ostream_sink . h " / > <nl> mmm a / c11logtest / c11logtest / c11logtest . vcxproj . filters <nl> ppp b / c11logtest / c11logtest / c11logtest . vcxproj . filters <nl> <nl> < ClInclude Include = " . . \ . . \ include \ c11log \ factory . h " > <nl> < Filter > Header Files \ c11log < / Filter > <nl> < / ClInclude > <nl> + < ClInclude Include = " . . \ . . \ include \ c11log \ pattern_formatter . h " > <nl> + < Filter > Header Files \ c11log \ sinks < / Filter > <nl> + < / ClInclude > <nl> + < ClInclude Include = " . . \ . . \ include \ c11log \ details \ fast_istostr . h " > <nl> + < Filter > Header Files \ c11log \ details < / Filter > <nl> + < / ClInclude > <nl> < / ItemGroup > <nl> < ItemGroup > <nl> < ClCompile Include = " stdafx . cpp " > <nl> mmm a / example / bench . cpp <nl> ppp b / example / bench . cpp <nl> <nl> / / <nl> # include < mutex > <nl> # include " c11log / logger . h " <nl> + # include " c11log / pattern_formatter . h " <nl> # include " c11log / sinks / async_sink . h " <nl> # include " c11log / sinks / file_sinks . h " <nl> # include " c11log / sinks / stdout_sinks . h " <nl> using namespace c11log ; <nl> using namespace utils ; <nl> <nl> <nl> - int main2 ( int argc , char * argv [ ] ) <nl> + int main ( int argc , char * argv [ ] ) <nl> { <nl> + const unsigned int howmany = argc < = 1 ? 500000 : atoi ( argv [ 1 ] ) ; <nl> <nl> - const unsigned int howmany = argc < = 1 ? 1000000 : atoi ( argv [ 1 ] ) ; <nl> + std : : string pattern = " % Y : % m : % d % H : % M : % S . % e [ % n : % l ] % t " ; <nl> + auto formatter1 = std : : unique_ptr < formatters : : formatter > ( new formatters : : pattern_formatter ( pattern ) ) ; <nl> <nl> - logger cout_logger ( " example " , std : : make_shared < sinks : : stderr_sink_mt > ( ) ) ; <nl> + logger cout_logger ( " bench " , std : : make_shared < sinks : : stderr_sink_mt > ( ) , std : : move ( formatter1 ) ) ; <nl> cout_logger . info ( ) < < " Hello logger " ; <nl> <nl> auto nullsink = std : : make_shared < sinks : : null_sink < details : : null_mutex > > ( ) ; <nl> <nl> <nl> - <nl> - <nl> - logger my_logger ( " my_logger " , nullsink ) ; <nl> - <nl> + auto formatter2 = std : : unique_ptr < formatters : : formatter > ( new formatters : : pattern_formatter ( pattern ) ) ; <nl> + logger my_logger ( " my_logger " , nullsink , std : : move ( formatter2 ) ) ; <nl> + / / logger my_logger ( " my_logger " , nullsink ) ; <nl> <nl> auto start = system_clock : : now ( ) ; <nl> for ( unsigned int i = 1 ; i < = howmany ; + + i ) <nl> - my_logger . info ( ) < < " Hello logger : msg # " < < i < < 1 < < 2 < < 3 < < 4 < < 5 < < 6 < < 7 < < 8 < < 9 < < 10 < < 11 < < 12 < < 13 < < 14 < < 15 < < 16 < < 17 < < 18 < < 19 ; <nl> - / / my_logger . info ( " Hello logger : msg # " , i , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 ) ; <nl> + my_logger . info ( ) < < " Hello logger : msg # " < < i ; <nl> + <nl> <nl> <nl> auto delta = system_clock : : now ( ) - start ; <nl> mmm a / example / example . cpp <nl> ppp b / example / example . cpp <nl> <nl> # include " c11log / sinks / file_sinks . h " <nl> using namespace std ; <nl> <nl> - int main ( int argc , char * argv [ ] ) <nl> + int main2 ( int argc , char * argv [ ] ) <nl> { <nl> <nl> auto console = c11log : : factory : : stdout_logger ( ) ; <nl> int main ( int argc , char * argv [ ] ) <nl> auto sink1 = std : : make_shared < c11log : : sinks : : stdout_sink_mt > ( ) ; <nl> auto sink2 = std : : make_shared < c11log : : sinks : : daily_file_sink_mt > ( " rotating " , " txt " ) ; <nl> c11log : : logger combined ( " combined " , { sink1 , sink2 } ) ; <nl> - <nl> + return 0 ; <nl> } <nl> <nl> mmm a / include / c11log / details / fast_oss . h <nl> ppp b / include / c11log / details / fast_oss . h <nl> <nl> <nl> # include < ostream > <nl> # include < iomanip > <nl> + # include " fast_istostr . h " <nl> # include " stack_buf . h " <nl> <nl> + <nl> namespace c11log <nl> { <nl> namespace details <nl> namespace details <nl> class stack_devicebuf : public std : : streambuf <nl> { <nl> public : <nl> - static const unsigned short stack_size = 192 ; <nl> + static const unsigned short stack_size = 256 ; <nl> using stackbuf_t = stack_buf < stack_size > ; <nl> <nl> stack_devicebuf ( ) = default ; <nl> class fast_oss : public std : : ostream <nl> _dev . clear ( ) ; <nl> } <nl> <nl> + / / The following were added because they add significant boost to perfromance <nl> + void putc ( char c ) <nl> + { <nl> + _dev . sputc ( c ) ; <nl> + } <nl> + <nl> + <nl> + / / put int and pad with zeroes if smalled than min_width <nl> + void put_int ( int n , int min_width ) <nl> + { <nl> + std : : string s ; <nl> + details : : fast_itostr ( n , s , min_width ) ; <nl> + _dev . sputn ( s . data ( ) , s . size ( ) ) ; <nl> + / / sprintf_s ( buf , " % d " , n ) ; <nl> + / / _dev . sputn ( buf , width ) ; <nl> + } <nl> + <nl> + void put_str ( const std : : string & str ) <nl> + { <nl> + _dev . sputn ( str . data ( ) , str . size ( ) ) ; <nl> + } <nl> + <nl> + <nl> private : <nl> stack_devicebuf _dev ; <nl> } ; <nl> mmm a / include / c11log / details / line_logger . h <nl> ppp b / include / c11log / details / line_logger . h <nl> class line_logger <nl> { <nl> _log_msg . logger_name = _callback_logger - > name ( ) ; <nl> _log_msg . time = log_clock : : now ( ) ; <nl> + _log_msg . tm_time = details : : os : : localtime ( log_clock : : to_time_t ( _log_msg . time ) ) ; <nl> _log_msg . raw = _oss . str ( ) ; <nl> _callback_logger - > _log_msg ( _log_msg ) ; <nl> } <nl> mmm a / include / c11log / details / log_msg . h <nl> ppp b / include / c11log / details / log_msg . h <nl> struct log_msg <nl> logger_name ( ) , <nl> level ( l ) , <nl> time ( ) , <nl> + tm_time ( ) , <nl> raw ( ) , <nl> formatted ( ) { } <nl> <nl> struct log_msg <nl> logger_name ( other . logger_name ) , <nl> level ( other . level ) , <nl> time ( other . time ) , <nl> + tm_time ( other . tm_time ) , <nl> raw ( other . raw ) , <nl> formatted ( other . formatted ) { } <nl> <nl> struct log_msg <nl> swap ( l . logger_name , r . logger_name ) ; <nl> swap ( l . level , r . level ) ; <nl> swap ( l . time , r . time ) ; <nl> + swap ( l . tm_time , r . tm_time ) ; <nl> swap ( l . raw , r . raw ) ; <nl> swap ( l . formatted , r . formatted ) ; <nl> } <nl> struct log_msg <nl> std : : string logger_name ; <nl> level : : level_enum level ; <nl> log_clock : : time_point time ; <nl> + std : : tm tm_time ; <nl> std : : string raw ; <nl> std : : string formatted ; <nl> <nl> + <nl> } ; <nl> } <nl> } <nl> mmm a / include / c11log / formatter . h <nl> ppp b / include / c11log / formatter . h <nl> class default_formatter : public formatter <nl> void format ( details : : log_msg & msg ) override <nl> { <nl> details : : fast_oss oss ; <nl> - _format_time ( msg . time , oss ) ; <nl> + _format_time ( msg , oss ) ; <nl> <nl> if ( ! msg . logger_name . empty ( ) ) <nl> oss < < " [ " < < msg . logger_name < < ' : ' < < c11log : : level : : to_str ( msg . level ) < < " ] " ; <nl> class default_formatter : public formatter <nl> msg . formatted = oss . str ( ) ; <nl> } <nl> private : <nl> - void _format_time ( const log_clock : : time_point & tp , std : : ostream & output ) ; <nl> + void _format_time ( const details : : log_msg & msg , std : : ostream & output ) ; <nl> <nl> } ; <nl> <nl> class default_formatter : public formatter <nl> } / / namespace c11log <nl> <nl> / / Format datetime like this : [ 2014 - 03 - 14 17 : 15 : 22 ] <nl> - inline void c11log : : formatters : : default_formatter : : _format_time ( const log_clock : : time_point & tp , std : : ostream & output ) <nl> + inline void c11log : : formatters : : default_formatter : : _format_time ( const details : : log_msg & msg , std : : ostream & output ) <nl> { <nl> - using namespace c11log : : details : : os ; <nl> - using namespace std : : chrono ; <nl> - <nl> - # ifdef _WIN32 / / VS2013 doesn ' t support yet thread_local keyword <nl> - __declspec ( thread ) static char s_cache_timestr [ 128 ] ; <nl> - __declspec ( thread ) static int s_cache_timesize = 0 ; <nl> - __declspec ( thread ) static std : : time_t s_cache_time_t = 0 ; <nl> - # else <nl> - thread_local static char s_cache_timestr [ 128 ] ; <nl> - thread_local static int s_cache_timesize = 0 ; <nl> - thread_local static std : : time_t s_cache_time_t = 0 ; <nl> - # endif <nl> - <nl> - / / Cache every second <nl> - std : : time_t tp_time_t = log_clock : : to_time_t ( tp ) ; <nl> - if ( tp_time_t ! = s_cache_time_t ) <nl> - { <nl> - auto tm_now = details : : os : : localtime ( tp_time_t ) ; <nl> - std : : ostringstream time_oss ; <nl> - time_oss . fill ( ' 0 ' ) ; <nl> - time_oss < < ' [ ' < < tm_now . tm_year + 1900 < < ' - ' ; <nl> - time_oss . width ( 2 ) ; <nl> - time_oss < < tm_now . tm_mon + 1 < < ' - ' ; <nl> - time_oss . width ( 2 ) ; <nl> - time_oss < < tm_now . tm_mday < < ' ' ; <nl> - time_oss . width ( 2 ) ; <nl> - time_oss < < tm_now . tm_hour < < ' : ' ; <nl> - time_oss . width ( 2 ) ; <nl> - time_oss < < tm_now . tm_min < < ' : ' ; <nl> - time_oss . width ( 2 ) ; <nl> - time_oss < < tm_now . tm_sec < < ' ] ' ; <nl> - / / Cache the resulted string and its size <nl> - s_cache_time_t = tp_time_t ; <nl> - const std : : string s = time_oss . str ( ) ; <nl> - s_cache_timesize = s . size ( ) ; <nl> - std : : memcpy ( s_cache_timestr , s . c_str ( ) , s_cache_timesize ) ; <nl> - } <nl> - output . write ( s_cache_timestr , s_cache_timesize ) ; <nl> + output . fill ( ' 0 ' ) ; <nl> + output < < ' [ ' < < msg . tm_time . tm_year + 1900 < < ' - ' ; <nl> + output . width ( 2 ) ; <nl> + output < < msg . tm_time . tm_mon + 1 < < ' - ' ; <nl> + output < < msg . tm_time . tm_mday < < ' ' ; <nl> + output < < msg . tm_time . tm_hour < < ' : ' ; <nl> + output < < msg . tm_time . tm_min < < ' : ' ; <nl> + output < < msg . tm_time . tm_sec < < ' ] ' ; <nl> } <nl> + <nl> new file mode 100644 <nl> index 00000000 . . 08917ab5 <nl> mmm / dev / null <nl> ppp b / include / c11log / pattern_formatter . h <nl> <nl> + # pragma once <nl> + <nl> + # include < string > <nl> + # include < chrono > <nl> + # include < memory > <nl> + # include < vector > <nl> + <nl> + # include " formatter . h " <nl> + # include " details / log_msg . h " <nl> + # include " details / fast_oss . h " <nl> + <nl> + <nl> + namespace c11log <nl> + { <nl> + namespace details { <nl> + class pattern_appender <nl> + { <nl> + public : <nl> + virtual void append ( const details : : log_msg & msg , details : : fast_oss & oss ) = 0 ; <nl> + } ; <nl> + <nl> + / / log name appender <nl> + class name_appender : public pattern_appender <nl> + { <nl> + void append ( const details : : log_msg & msg , details : : fast_oss & oss ) override <nl> + { <nl> + oss < < msg . logger_name ; <nl> + } <nl> + } ; <nl> + <nl> + / / log level appender <nl> + class level_appender : public pattern_appender <nl> + { <nl> + void append ( const details : : log_msg & msg , details : : fast_oss & oss ) override <nl> + { <nl> + oss < < level : : to_str ( msg . level ) ; <nl> + } <nl> + } ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / Date time pattern appenders <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + / / year - 4 digit <nl> + class Y_appender : public pattern_appender <nl> + { <nl> + void append ( const details : : log_msg & msg , details : : fast_oss & oss ) override <nl> + { <nl> + oss . put_int ( msg . tm_time . tm_year + 1900 , 4 ) ; <nl> + } <nl> + } ; <nl> + <nl> + / / year - 2 digit <nl> + class y_appender : public pattern_appender <nl> + { <nl> + void append ( const details : : log_msg & msg , details : : fast_oss & oss ) override <nl> + { <nl> + oss . put_int ( msg . tm_time . tm_year , 2 ) ; <nl> + } <nl> + } ; <nl> + / / month 1 - 12 <nl> + class m_appender : public pattern_appender <nl> + { <nl> + void append ( const details : : log_msg & msg , details : : fast_oss & oss ) override <nl> + { <nl> + oss . put_int ( msg . tm_time . tm_mon + 1 , 2 ) ; <nl> + } <nl> + } ; <nl> + <nl> + <nl> + / / day of month 1 - 31 <nl> + class d_appender : public pattern_appender <nl> + { <nl> + void append ( const details : : log_msg & msg , details : : fast_oss & oss ) override <nl> + { <nl> + oss . put_int ( msg . tm_time . tm_mday , 2 ) ; <nl> + } <nl> + } ; <nl> + <nl> + / / hours in 24 format 0 - 23 <nl> + class H_appender : public pattern_appender <nl> + { <nl> + void append ( const details : : log_msg & msg , details : : fast_oss & oss ) override <nl> + { <nl> + oss . put_int ( msg . tm_time . tm_hour , 2 ) ; <nl> + } <nl> + } ; <nl> + <nl> + / / hours in 12 format 1 - 12 <nl> + class I_appender : public pattern_appender <nl> + { <nl> + void append ( const details : : log_msg & msg , details : : fast_oss & oss ) override <nl> + { <nl> + oss . put_int ( ( msg . tm_time . tm_hour + 1 ) % 1 , 2 ) ; <nl> + } <nl> + } ; <nl> + <nl> + / / ninutes 0 - 59 <nl> + class M_appender : public pattern_appender <nl> + { <nl> + void append ( const details : : log_msg & msg , details : : fast_oss & oss ) override <nl> + { <nl> + oss . put_int ( msg . tm_time . tm_min , 2 ) ; <nl> + } <nl> + } ; <nl> + <nl> + / / seconds 0 - 59 <nl> + class S_appender : public pattern_appender <nl> + { <nl> + void append ( const details : : log_msg & msg , details : : fast_oss & oss ) override <nl> + { <nl> + oss . put_int ( msg . tm_time . tm_sec , 2 ) ; <nl> + } <nl> + } ; <nl> + <nl> + / / milliseconds <nl> + class e_appender : public pattern_appender <nl> + { <nl> + void append ( const details : : log_msg & msg , details : : fast_oss & oss ) override <nl> + { <nl> + auto duration = msg . time . time_since_epoch ( ) ; <nl> + auto millis = std : : chrono : : duration_cast < std : : chrono : : milliseconds > ( duration ) . count ( ) % 1000 ; <nl> + oss . put_int ( millis , 3 ) ; <nl> + } <nl> + } ; <nl> + <nl> + <nl> + class t_appender : public pattern_appender <nl> + { <nl> + void append ( const details : : log_msg & msg , details : : fast_oss & oss ) override <nl> + { <nl> + oss . put_str ( msg . raw ) ; <nl> + } <nl> + } ; <nl> + <nl> + class ch_appender : public pattern_appender <nl> + { <nl> + public : <nl> + explicit ch_appender ( char ch ) : _ch ( ch ) <nl> + { } <nl> + void append ( const details : : log_msg & msg , details : : fast_oss & oss ) override <nl> + { <nl> + oss . putc ( _ch ) ; <nl> + } <nl> + private : <nl> + char _ch ; <nl> + } ; <nl> + <nl> + <nl> + class str_appender : public pattern_appender <nl> + { <nl> + public : <nl> + str_appender ( ) <nl> + { } <nl> + void add_ch ( char ch ) <nl> + { <nl> + _str + = ch ; <nl> + } <nl> + void append ( const details : : log_msg & msg , details : : fast_oss & oss ) override <nl> + { <nl> + oss < < _str ; <nl> + } <nl> + private : <nl> + std : : string _str ; <nl> + } ; <nl> + } <nl> + <nl> + <nl> + namespace formatters <nl> + { <nl> + class pattern_formatter : public formatter <nl> + { <nl> + <nl> + public : <nl> + explicit pattern_formatter ( const std : : string & pattern ) ; <nl> + pattern_formatter ( const pattern_formatter & ) = delete ; <nl> + void format ( details : : log_msg & msg ) override ; <nl> + private : <nl> + const std : : string _pattern ; <nl> + std : : vector < std : : unique_ptr < details : : pattern_appender > > _appenders ; <nl> + void handle_flag ( char flag ) ; <nl> + void compile_pattern ( const std : : string & pattern ) ; <nl> + } ; <nl> + } <nl> + } <nl> + <nl> + <nl> + c11log : : formatters : : pattern_formatter : : pattern_formatter ( const std : : string & pattern ) <nl> + { <nl> + compile_pattern ( pattern ) ; <nl> + } <nl> + <nl> + <nl> + void c11log : : formatters : : pattern_formatter : : compile_pattern ( const std : : string & pattern ) <nl> + { <nl> + auto end = pattern . end ( ) ; <nl> + for ( auto it = pattern . begin ( ) ; it ! = end ; + + it ) <nl> + { <nl> + if ( * it = = ' % ' ) <nl> + { <nl> + if ( + + it ! = end ) <nl> + handle_flag ( * it ) ; <nl> + else <nl> + return ; <nl> + } <nl> + else <nl> + { <nl> + / / chars not following the % sign should be displayed as is <nl> + _appenders . push_back ( std : : unique_ptr < details : : pattern_appender > ( new details : : ch_appender ( * it ) ) ) ; <nl> + } <nl> + } <nl> + <nl> + } <nl> + void c11log : : formatters : : pattern_formatter : : handle_flag ( char flag ) <nl> + { <nl> + switch ( flag ) <nl> + { <nl> + / / logger name <nl> + case ' n ' : <nl> + _appenders . push_back ( std : : unique_ptr < details : : pattern_appender > ( new details : : name_appender ( ) ) ) ; <nl> + break ; <nl> + / / message log level <nl> + case ' l ' : <nl> + _appenders . push_back ( std : : unique_ptr < details : : pattern_appender > ( new details : : level_appender ( ) ) ) ; <nl> + break ; <nl> + / / message text <nl> + case ( ' t ' ) : <nl> + _appenders . push_back ( std : : unique_ptr < details : : pattern_appender > ( new details : : t_appender ( ) ) ) ; <nl> + break ; <nl> + / / year <nl> + case ( ' Y ' ) : <nl> + _appenders . push_back ( std : : unique_ptr < details : : pattern_appender > ( new details : : Y_appender ( ) ) ) ; <nl> + break ; <nl> + / / year 2 digits <nl> + case ( ' y ' ) : <nl> + _appenders . push_back ( std : : unique_ptr < details : : pattern_appender > ( new details : : y_appender ( ) ) ) ; <nl> + break ; <nl> + / / month <nl> + case ( ' m ' ) : <nl> + / / minute <nl> + _appenders . push_back ( std : : unique_ptr < details : : pattern_appender > ( new details : : m_appender ( ) ) ) ; <nl> + break ; <nl> + / / day in month <nl> + case ( ' d ' ) : <nl> + _appenders . push_back ( std : : unique_ptr < details : : pattern_appender > ( new details : : d_appender ( ) ) ) ; <nl> + break ; <nl> + / / hour ( 24 ) <nl> + case ( ' H ' ) : <nl> + _appenders . push_back ( std : : unique_ptr < details : : pattern_appender > ( new details : : H_appender ( ) ) ) ; <nl> + break ; <nl> + / / hour ( 12 ) <nl> + case ( ' I ' ) : <nl> + _appenders . push_back ( std : : unique_ptr < details : : pattern_appender > ( new details : : I_appender ( ) ) ) ; <nl> + break ; <nl> + / / minutes <nl> + case ( ' M ' ) : <nl> + _appenders . push_back ( std : : unique_ptr < details : : pattern_appender > ( new details : : M_appender ( ) ) ) ; <nl> + break ; <nl> + / / seconds <nl> + case ( ' S ' ) : <nl> + _appenders . push_back ( std : : unique_ptr < details : : pattern_appender > ( new details : : S_appender ( ) ) ) ; <nl> + break ; <nl> + / / milliseconds part <nl> + case ( ' e ' ) : <nl> + _appenders . push_back ( std : : unique_ptr < details : : pattern_appender > ( new details : : e_appender ( ) ) ) ; <nl> + break ; <nl> + / / % sign <nl> + case ( ' % ' ) : <nl> + _appenders . push_back ( std : : unique_ptr < details : : pattern_appender > ( new details : : ch_appender ( ' % ' ) ) ) ; <nl> + break ; <nl> + } <nl> + <nl> + } <nl> + <nl> + <nl> + void c11log : : formatters : : pattern_formatter : : format ( details : : log_msg & msg ) <nl> + { <nl> + details : : fast_oss oss ; <nl> + for ( auto & appender : _appenders ) <nl> + { <nl> + appender - > append ( msg , oss ) ; <nl> + } <nl> + oss . write ( details : : os : : eol ( ) , details : : os : : eol_size ( ) ) ; <nl> + msg . formatted = oss . str ( ) ; <nl> + } <nl> \ No newline at end of file <nl>
|
Added pattern formatter and updated related stuff
|
gabime/spdlog
|
481fdbcbb19482fe01a430976e982c24d6a5c95b
|
2014-10-14T00:44:40Z
|
mmm a / test / test - main . cc <nl> ppp b / test / test - main . cc <nl> <nl> <nl> # ifdef _WIN32 <nl> # include < windows . h > <nl> + # endif <nl> + <nl> + # ifdef _MSC_VER <nl> # include < crtdbg . h > <nl> + # else <nl> + # define _CrtSetReportFile ( a , b ) <nl> + # define _CrtSetReportMode ( a , b ) <nl> # endif <nl> <nl> int main ( int argc , char * * argv ) { <nl> int main ( int argc , char * * argv ) { <nl> / / doesn ' t help . <nl> SetErrorMode ( SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | <nl> SEM_NOOPENFILEERRORBOX ) ; <nl> + # endif <nl> / / Disable message boxes on assertion failures . <nl> _CrtSetReportMode ( _CRT_ERROR , _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG ) ; <nl> _CrtSetReportFile ( _CRT_ERROR , _CRTDBG_FILE_STDERR ) ; <nl> _CrtSetReportMode ( _CRT_ASSERT , _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG ) ; <nl> _CrtSetReportFile ( _CRT_ASSERT , _CRTDBG_FILE_STDERR ) ; <nl> - # endif <nl> testing : : InitGoogleTest ( & argc , argv ) ; <nl> return RUN_ALL_TESTS ( ) ; <nl> } <nl>
|
Only include crtdbg . h when compiling with MSVC
|
fmtlib/fmt
|
a530052b7eb2324ed340f9b690f6a6aad7490480
|
2015-03-17T01:05:45Z
|
mmm a / src / core / loader / deconstructed_rom_directory . cpp <nl> ppp b / src / core / loader / deconstructed_rom_directory . cpp <nl> <nl> # include " common / file_util . h " <nl> # include " common / logging / log . h " <nl> # include " common / string_util . h " <nl> + # include " core / file_sys / romfs_factory . h " <nl> # include " core / hle / kernel / process . h " <nl> # include " core / hle / kernel / resource_limit . h " <nl> + # include " core / hle / service / filesystem / filesystem . h " <nl> # include " core / loader / deconstructed_rom_directory . h " <nl> # include " core / loader / nso . h " <nl> # include " core / memory . h " <nl> <nl> namespace Loader { <nl> <nl> + static std : : string FindRomFS ( const std : : string & directory ) { <nl> + std : : string filepath_romfs ; <nl> + const auto callback = [ & filepath_romfs ] ( unsigned * , const std : : string & directory , <nl> + const std : : string & virtual_name ) - > bool { <nl> + const std : : string physical_name = directory + virtual_name ; <nl> + if ( FileUtil : : IsDirectory ( physical_name ) ) { <nl> + / / Skip directories <nl> + return true ; <nl> + } <nl> + <nl> + / / Verify extension <nl> + const std : : string extension = physical_name . substr ( physical_name . find_last_of ( " . " ) + 1 ) ; <nl> + if ( Common : : ToLower ( extension ) ! = " istorage " ) { <nl> + return true ; <nl> + } <nl> + <nl> + / / Found it - we are done <nl> + filepath_romfs = std : : move ( physical_name ) ; <nl> + return false ; <nl> + } ; <nl> + <nl> + / / Search the specified directory recursively , looking for the first . istorage file , which will <nl> + / / be used for the RomFS <nl> + FileUtil : : ForeachDirectoryEntry ( nullptr , directory , callback ) ; <nl> + <nl> + return filepath_romfs ; <nl> + } <nl> + <nl> AppLoader_DeconstructedRomDirectory : : AppLoader_DeconstructedRomDirectory ( FileUtil : : IOFile & & file , <nl> std : : string filepath ) <nl> : AppLoader ( std : : move ( file ) ) , filepath ( std : : move ( filepath ) ) { } <nl> ResultStatus AppLoader_DeconstructedRomDirectory : : Load ( <nl> <nl> / / Load NSO modules <nl> VAddr next_load_addr { Memory : : PROCESS_IMAGE_VADDR } ; <nl> + const std : : string directory = filepath . substr ( 0 , filepath . find_last_of ( " / \ \ " ) ) + DIR_SEP ; <nl> for ( const auto & module : { " rtld " , " main " , " subsdk0 " , " subsdk1 " , " subsdk2 " , " subsdk3 " , <nl> " subsdk4 " , " subsdk5 " , " subsdk6 " , " subsdk7 " , " sdk " } ) { <nl> - const std : : string path = <nl> - filepath . substr ( 0 , filepath . find_last_of ( " / \ \ " ) ) + DIR_SEP + module ; <nl> + const std : : string path = directory + DIR_SEP + module ; <nl> const VAddr load_addr = next_load_addr ; <nl> next_load_addr = AppLoader_NSO : : LoadModule ( path , load_addr ) ; <nl> if ( next_load_addr ) { <nl> ResultStatus AppLoader_DeconstructedRomDirectory : : Load ( <nl> Kernel : : ResourceLimit : : GetForCategory ( Kernel : : ResourceLimitCategory : : APPLICATION ) ; <nl> process - > Run ( Memory : : PROCESS_IMAGE_VADDR , 48 , Kernel : : DEFAULT_STACK_SIZE ) ; <nl> <nl> + / / Find the RomFS by searching for a " . istorage " file in this directory <nl> + filepath_romfs = FindRomFS ( directory ) ; <nl> + <nl> + / / Register the RomFS if a " . istorage " file was found <nl> + if ( ! filepath_romfs . empty ( ) ) { <nl> + Service : : FileSystem : : RegisterFileSystem ( std : : make_unique < FileSys : : RomFS_Factory > ( * this ) , <nl> + Service : : FileSystem : : Type : : RomFS ) ; <nl> + } <nl> + <nl> is_loaded = true ; <nl> return ResultStatus : : Success ; <nl> } <nl> <nl> + ResultStatus AppLoader_DeconstructedRomDirectory : : ReadRomFS ( <nl> + std : : shared_ptr < FileUtil : : IOFile > & romfs_file , u64 & offset , u64 & size ) { <nl> + <nl> + if ( filepath_romfs . empty ( ) ) { <nl> + LOG_DEBUG ( Loader , " No RomFS available " ) ; <nl> + return ResultStatus : : ErrorNotUsed ; <nl> + } <nl> + <nl> + / / We reopen the file , to allow its position to be independent <nl> + romfs_file = std : : make_shared < FileUtil : : IOFile > ( filepath_romfs , " rb " ) ; <nl> + if ( ! romfs_file - > IsOpen ( ) ) { <nl> + return ResultStatus : : Error ; <nl> + } <nl> + <nl> + offset = 0 ; <nl> + size = romfs_file - > GetSize ( ) ; <nl> + <nl> + LOG_DEBUG ( Loader , " RomFS offset : 0x % 08X " , offset ) ; <nl> + LOG_DEBUG ( Loader , " RomFS size : 0x % 08X " , size ) ; <nl> + <nl> + / / Reset read pointer <nl> + file . Seek ( 0 , SEEK_SET ) ; <nl> + <nl> + return ResultStatus : : Success ; <nl> + } <nl> + <nl> } / / namespace Loader <nl> mmm a / src / core / loader / deconstructed_rom_directory . h <nl> ppp b / src / core / loader / deconstructed_rom_directory . h <nl> class AppLoader_DeconstructedRomDirectory final : public AppLoader { <nl> <nl> ResultStatus Load ( Kernel : : SharedPtr < Kernel : : Process > & process ) override ; <nl> <nl> + ResultStatus ReadRomFS ( std : : shared_ptr < FileUtil : : IOFile > & romfs_file , u64 & offset , <nl> + u64 & size ) override ; <nl> + <nl> private : <nl> + std : : string filepath_romfs ; <nl> std : : string filepath ; <nl> } ; <nl> <nl>
|
deconstructed_rom_directory : Implement istorage loading for RomFS .
|
yuzu-emu/yuzu
|
d9a91d76785da6d0fa32ce32417e12023c8f394e
|
2018-01-21T20:39:31Z
|
mmm a / xbmc / video / VideoDatabase . cpp <nl> ppp b / xbmc / video / VideoDatabase . cpp <nl> void CVideoDatabase : : UpdateTables ( int iVersion ) <nl> <nl> int CVideoDatabase : : GetSchemaVersion ( ) const <nl> { <nl> - return 90 ; <nl> + return 91 ; <nl> } <nl> <nl> bool CVideoDatabase : : LookupByFolders ( const CStdString & path , bool shows ) <nl>
|
[ videodb ] bump version
|
xbmc/xbmc
|
a20872c2549b1ad63e78c835c2e46f49d3108883
|
2014-12-23T12:10:56Z
|
mmm a / BUILD <nl> ppp b / BUILD <nl> g_stands_for = " green " <nl> <nl> core_version = " 3 . 0 . 0 - dev " <nl> <nl> - version = " 1 . 2 . 0 " <nl> + version = " 1 . 3 . 0 - dev " <nl> <nl> grpc_cc_library ( <nl> name = " gpr " , <nl> grpc_cc_library ( <nl> " grpc_lb_policy_pick_first " , <nl> " grpc_lb_policy_round_robin " , <nl> " grpc_load_reporting " , <nl> + " grpc_max_age_filter " , <nl> " grpc_resolver_dns_ares " , <nl> " grpc_resolver_dns_native " , <nl> " grpc_resolver_sockaddr " , <nl> grpc_cc_library ( <nl> " grpc_transport_chttp2_client_secure " , <nl> " grpc_transport_chttp2_server_insecure " , <nl> " grpc_transport_chttp2_server_secure " , <nl> - " grpc_max_age_filter " , <nl> ] , <nl> ) <nl> <nl> grpc_cc_library ( <nl> " grpc_lb_policy_pick_first " , <nl> " grpc_lb_policy_round_robin " , <nl> " grpc_load_reporting " , <nl> + " grpc_max_age_filter " , <nl> " grpc_resolver_dns_native " , <nl> " grpc_resolver_sockaddr " , <nl> " grpc_transport_chttp2_client_insecure " , <nl> " grpc_transport_chttp2_server_insecure " , <nl> - " grpc_max_age_filter " , <nl> ] , <nl> ) <nl> <nl> grpc_cc_library ( <nl> ] , <nl> hdrs = [ <nl> " src / compiler / config . h " , <nl> - " src / compiler / schema_interface . h " , <nl> - " src / compiler / protobuf_plugin . h " , <nl> " src / compiler / cpp_generator . h " , <nl> " src / compiler / cpp_generator_helpers . h " , <nl> " src / compiler / csharp_generator . h " , <nl> grpc_cc_library ( <nl> " src / compiler / objective_c_generator_helpers . h " , <nl> " src / compiler / php_generator . h " , <nl> " src / compiler / php_generator_helpers . h " , <nl> + " src / compiler / protobuf_plugin . h " , <nl> " src / compiler / python_generator . h " , <nl> " src / compiler / python_generator_helpers . h " , <nl> " src / compiler / python_private_generator . h " , <nl> grpc_cc_library ( <nl> " src / compiler / ruby_generator_helpers - inl . h " , <nl> " src / compiler / ruby_generator_map - inl . h " , <nl> " src / compiler / ruby_generator_string - inl . h " , <nl> + " src / compiler / schema_interface . h " , <nl> ] , <nl> external_deps = [ <nl> " protobuf_clib " , <nl> grpc_cc_library ( <nl> " src / core / lib / iomgr / endpoint_pair_windows . c " , <nl> " src / core / lib / iomgr / error . c " , <nl> " src / core / lib / iomgr / ev_epoll_linux . c " , <nl> + " src / core / lib / iomgr / lockfree_event . c " , <nl> " src / core / lib / iomgr / ev_poll_posix . c " , <nl> " src / core / lib / iomgr / ev_posix . c " , <nl> " src / core / lib / iomgr / exec_ctx . c " , <nl> grpc_cc_library ( <nl> " src / core / lib / iomgr / error . h " , <nl> " src / core / lib / iomgr / error_internal . h " , <nl> " src / core / lib / iomgr / ev_epoll_linux . h " , <nl> + " src / core / lib / iomgr / lockfree_event . h " , <nl> " src / core / lib / iomgr / ev_poll_posix . h " , <nl> " src / core / lib / iomgr / ev_posix . h " , <nl> " src / core / lib / iomgr / exec_ctx . h " , <nl> grpc_cc_library ( <nl> " src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver . h " , <nl> " src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_wrapper . h " , <nl> ] , <nl> + external_deps = [ <nl> + " cares " , <nl> + ] , <nl> language = " c " , <nl> deps = [ <nl> " grpc_base " , <nl> " grpc_client_channel " , <nl> ] , <nl> - external_deps = [ <nl> - " cares " , <nl> - ] , <nl> ) <nl> <nl> grpc_cc_library ( <nl> mmm a / CMakeLists . txt <nl> ppp b / CMakeLists . txt <nl> <nl> # This file can be regenerated from the template by running <nl> # tools / buildgen / generate_projects . sh <nl> # <nl> - # Additionally , this is currently very experimental , and unsupported . <nl> - # Further work will happen on that file . <nl> - # <nl> # Copyright 2015 , Google Inc . <nl> # All rights reserved . <nl> # <nl> function ( protobuf_generate_grpc_cpp ) <nl> foreach ( FIL $ { ARGN } ) <nl> get_filename_component ( ABS_FIL $ { FIL } ABSOLUTE ) <nl> get_filename_component ( FIL_WE $ { FIL } NAME_WE ) <nl> - file ( RELATIVE_PATH REL_FIL $ { CMAKE_SOURCE_DIR } $ { ABS_FIL } ) <nl> + file ( RELATIVE_PATH REL_FIL $ { CMAKE_CURRENT_SOURCE_DIR } $ { ABS_FIL } ) <nl> get_filename_component ( REL_DIR $ { REL_FIL } DIRECTORY ) <nl> set ( RELFIL_WE " $ { REL_DIR } / $ { FIL_WE } " ) <nl> <nl> function ( protobuf_generate_grpc_cpp ) <nl> $ { _protobuf_include_path } <nl> $ { REL_FIL } <nl> DEPENDS $ { ABS_FIL } $ { _gRPC_PROTOBUF_PROTOC } grpc_cpp_plugin <nl> - WORKING_DIRECTORY $ { CMAKE_SOURCE_DIR } <nl> + WORKING_DIRECTORY $ { CMAKE_CURRENT_SOURCE_DIR } <nl> COMMENT " Running gRPC C + + protocol buffer compiler on $ { FIL } " <nl> VERBATIM ) <nl> <nl> if ( _gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX ) <nl> add_dependencies ( buildtests_cxx bm_cq ) <nl> endif ( ) <nl> if ( _gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX ) <nl> + add_dependencies ( buildtests_cxx bm_cq_multiple_threads ) <nl> + endif ( ) <nl> + if ( _gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX ) <nl> add_dependencies ( buildtests_cxx bm_error ) <nl> endif ( ) <nl> if ( _gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX ) <nl> add_library ( grpc <nl> src / core / lib / iomgr / iomgr_uv . c <nl> src / core / lib / iomgr / iomgr_windows . c <nl> src / core / lib / iomgr / load_file . c <nl> + src / core / lib / iomgr / lockfree_event . c <nl> src / core / lib / iomgr / network_status_tracker . c <nl> src / core / lib / iomgr / polling_entity . c <nl> src / core / lib / iomgr / pollset_set_uv . c <nl> add_library ( grpc_cronet <nl> src / core / lib / iomgr / iomgr_uv . c <nl> src / core / lib / iomgr / iomgr_windows . c <nl> src / core / lib / iomgr / load_file . c <nl> + src / core / lib / iomgr / lockfree_event . c <nl> src / core / lib / iomgr / network_status_tracker . c <nl> src / core / lib / iomgr / polling_entity . c <nl> src / core / lib / iomgr / pollset_set_uv . c <nl> add_library ( grpc_test_util <nl> src / core / lib / iomgr / iomgr_uv . c <nl> src / core / lib / iomgr / iomgr_windows . c <nl> src / core / lib / iomgr / load_file . c <nl> + src / core / lib / iomgr / lockfree_event . c <nl> src / core / lib / iomgr / network_status_tracker . c <nl> src / core / lib / iomgr / polling_entity . c <nl> src / core / lib / iomgr / pollset_set_uv . c <nl> add_library ( grpc_unsecure <nl> src / core / lib / iomgr / iomgr_uv . c <nl> src / core / lib / iomgr / iomgr_windows . c <nl> src / core / lib / iomgr / load_file . c <nl> + src / core / lib / iomgr / lockfree_event . c <nl> src / core / lib / iomgr / network_status_tracker . c <nl> src / core / lib / iomgr / polling_entity . c <nl> src / core / lib / iomgr / pollset_set_uv . c <nl> add_library ( grpc + + <nl> src / core / lib / iomgr / iomgr_uv . c <nl> src / core / lib / iomgr / iomgr_windows . c <nl> src / core / lib / iomgr / load_file . c <nl> + src / core / lib / iomgr / lockfree_event . c <nl> src / core / lib / iomgr / network_status_tracker . c <nl> src / core / lib / iomgr / polling_entity . c <nl> src / core / lib / iomgr / pollset_set_uv . c <nl> add_library ( grpc + + _cronet <nl> src / core / lib / iomgr / iomgr_uv . c <nl> src / core / lib / iomgr / iomgr_windows . c <nl> src / core / lib / iomgr / load_file . c <nl> + src / core / lib / iomgr / lockfree_event . c <nl> src / core / lib / iomgr / network_status_tracker . c <nl> src / core / lib / iomgr / polling_entity . c <nl> src / core / lib / iomgr / pollset_set_uv . c <nl> target_include_directories ( grpc + + _proto_reflection_desc_db <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> target_include_directories ( grpc + + _test_config <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> target_include_directories ( grpc + + _test_util <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> add_library ( grpc + + _unsecure <nl> src / core / lib / iomgr / iomgr_uv . c <nl> src / core / lib / iomgr / iomgr_windows . c <nl> src / core / lib / iomgr / load_file . c <nl> + src / core / lib / iomgr / lockfree_event . c <nl> src / core / lib / iomgr / network_status_tracker . c <nl> src / core / lib / iomgr / polling_entity . c <nl> src / core / lib / iomgr / pollset_set_uv . c <nl> target_include_directories ( grpc_benchmark <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> target_include_directories ( grpc_cli_libs <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> target_include_directories ( http2_client_main <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> target_include_directories ( interop_client_helper <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> target_include_directories ( interop_client_main <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> target_include_directories ( interop_server_helper <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> target_include_directories ( interop_server_lib <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> target_include_directories ( interop_server_main <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> target_include_directories ( qps <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( gRPC_BUILD_TESTS ) <nl> <nl> add_executable ( alarm_cpp_test <nl> test / cpp / common / alarm_cpp_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( alarm_cpp_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( gRPC_BUILD_TESTS ) <nl> <nl> add_executable ( async_end2end_test <nl> test / cpp / end2end / async_end2end_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( async_end2end_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( gRPC_BUILD_TESTS ) <nl> <nl> add_executable ( auth_property_iterator_test <nl> test / cpp / common / auth_property_iterator_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( auth_property_iterator_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( _gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX ) <nl> <nl> add_executable ( bm_arena <nl> test / cpp / microbenchmarks / bm_arena . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( bm_arena <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( _gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX ) <nl> <nl> add_executable ( bm_call_create <nl> test / cpp / microbenchmarks / bm_call_create . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( bm_call_create <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( _gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX ) <nl> <nl> add_executable ( bm_chttp2_hpack <nl> test / cpp / microbenchmarks / bm_chttp2_hpack . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( bm_chttp2_hpack <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( _gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX ) <nl> <nl> add_executable ( bm_chttp2_transport <nl> test / cpp / microbenchmarks / bm_chttp2_transport . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( bm_chttp2_transport <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( _gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX ) <nl> <nl> add_executable ( bm_closure <nl> test / cpp / microbenchmarks / bm_closure . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( bm_closure <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( _gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX ) <nl> <nl> add_executable ( bm_cq <nl> test / cpp / microbenchmarks / bm_cq . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( bm_cq <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> endif ( gRPC_BUILD_TESTS ) <nl> if ( gRPC_BUILD_TESTS ) <nl> if ( _gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX ) <nl> <nl> + add_executable ( bm_cq_multiple_threads <nl> + test / cpp / microbenchmarks / bm_cq_multiple_threads . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> + ) <nl> + <nl> + <nl> + target_include_directories ( bm_cq_multiple_threads <nl> + PRIVATE $ { CMAKE_CURRENT_SOURCE_DIR } <nl> + PRIVATE $ { CMAKE_CURRENT_SOURCE_DIR } / include <nl> + PRIVATE $ { BORINGSSL_ROOT_DIR } / include <nl> + PRIVATE $ { PROTOBUF_ROOT_DIR } / src <nl> + PRIVATE $ { BENCHMARK_ROOT_DIR } / include <nl> + PRIVATE $ { ZLIB_ROOT_DIR } <nl> + PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / zlib <nl> + PRIVATE $ { CARES_BUILD_INCLUDE_DIR } <nl> + PRIVATE $ { CARES_INCLUDE_DIR } <nl> + PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> + PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> + PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> + PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> + ) <nl> + <nl> + target_link_libraries ( bm_cq_multiple_threads <nl> + $ { _gRPC_PROTOBUF_LIBRARIES } <nl> + $ { _gRPC_ALLTARGETS_LIBRARIES } <nl> + grpc_benchmark <nl> + benchmark <nl> + grpc + + _test_util <nl> + grpc_test_util <nl> + grpc + + <nl> + grpc <nl> + gpr_test_util <nl> + gpr <nl> + $ { _gRPC_GFLAGS_LIBRARIES } <nl> + ) <nl> + <nl> + endif ( ) <nl> + endif ( gRPC_BUILD_TESTS ) <nl> + if ( gRPC_BUILD_TESTS ) <nl> + if ( _gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX ) <nl> + <nl> add_executable ( bm_error <nl> test / cpp / microbenchmarks / bm_error . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( bm_error <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( _gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX ) <nl> <nl> add_executable ( bm_fullstack_streaming_ping_pong <nl> test / cpp / microbenchmarks / bm_fullstack_streaming_ping_pong . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( bm_fullstack_streaming_ping_pong <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( _gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX ) <nl> <nl> add_executable ( bm_fullstack_streaming_pump <nl> test / cpp / microbenchmarks / bm_fullstack_streaming_pump . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( bm_fullstack_streaming_pump <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( _gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX ) <nl> <nl> add_executable ( bm_fullstack_trickle <nl> test / cpp / microbenchmarks / bm_fullstack_trickle . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( bm_fullstack_trickle <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( _gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX ) <nl> <nl> add_executable ( bm_fullstack_unary_ping_pong <nl> test / cpp / microbenchmarks / bm_fullstack_unary_ping_pong . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( bm_fullstack_unary_ping_pong <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( _gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX ) <nl> <nl> add_executable ( bm_metadata <nl> test / cpp / microbenchmarks / bm_metadata . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( bm_metadata <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( _gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX ) <nl> <nl> add_executable ( bm_pollset <nl> test / cpp / microbenchmarks / bm_pollset . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( bm_pollset <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( gRPC_BUILD_TESTS ) <nl> <nl> add_executable ( channel_arguments_test <nl> test / cpp / common / channel_arguments_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( channel_arguments_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( gRPC_BUILD_TESTS ) <nl> <nl> add_executable ( channel_filter_test <nl> test / cpp / common / channel_filter_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( channel_filter_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( gRPC_BUILD_TESTS ) <nl> <nl> add_executable ( cli_call_test <nl> test / cpp / util / cli_call_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( cli_call_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( _gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX ) <nl> <nl> add_executable ( client_crash_test <nl> test / cpp / end2end / client_crash_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( client_crash_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( gRPC_BUILD_TESTS ) <nl> <nl> add_executable ( client_crash_test_server <nl> test / cpp / end2end / client_crash_test_server . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( client_crash_test_server <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> add_executable ( codegen_test_full <nl> $ { _gRPC_PROTO_GENS_DIR } / src / proto / grpc / testing / stats . pb . h <nl> $ { _gRPC_PROTO_GENS_DIR } / src / proto / grpc / testing / stats . grpc . pb . h <nl> test / cpp / codegen / codegen_test_full . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> protobuf_generate_grpc_cpp ( <nl> target_include_directories ( codegen_test_full <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> add_executable ( codegen_test_minimal <nl> $ { _gRPC_PROTO_GENS_DIR } / src / proto / grpc / testing / stats . grpc . pb . h <nl> test / cpp / codegen / codegen_test_minimal . cc <nl> src / cpp / codegen / codegen_init . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> protobuf_generate_grpc_cpp ( <nl> target_include_directories ( codegen_test_minimal <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( gRPC_BUILD_TESTS ) <nl> <nl> add_executable ( credentials_test <nl> test / cpp / client / credentials_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( credentials_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( gRPC_BUILD_TESTS ) <nl> <nl> add_executable ( cxx_byte_buffer_test <nl> test / cpp / util / byte_buffer_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( cxx_byte_buffer_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( gRPC_BUILD_TESTS ) <nl> <nl> add_executable ( cxx_slice_test <nl> test / cpp / util / slice_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( cxx_slice_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( gRPC_BUILD_TESTS ) <nl> <nl> add_executable ( cxx_string_ref_test <nl> test / cpp / util / string_ref_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( cxx_string_ref_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( gRPC_BUILD_TESTS ) <nl> <nl> add_executable ( cxx_time_test <nl> test / cpp / util / time_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( cxx_time_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( gRPC_BUILD_TESTS ) <nl> <nl> add_executable ( end2end_test <nl> test / cpp / end2end / end2end_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( end2end_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( gRPC_BUILD_TESTS ) <nl> <nl> add_executable ( filter_end2end_test <nl> test / cpp / end2end / filter_end2end_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( filter_end2end_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( gRPC_BUILD_TESTS ) <nl> <nl> add_executable ( generic_end2end_test <nl> test / cpp / end2end / generic_end2end_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( generic_end2end_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> add_executable ( golden_file_test <nl> $ { _gRPC_PROTO_GENS_DIR } / src / proto / grpc / testing / compiler_test . pb . h <nl> $ { _gRPC_PROTO_GENS_DIR } / src / proto / grpc / testing / compiler_test . grpc . pb . h <nl> test / cpp / codegen / golden_file_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> protobuf_generate_grpc_cpp ( <nl> target_include_directories ( golden_file_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( gRPC_BUILD_TESTS ) <nl> <nl> add_executable ( grpc_cli <nl> test / cpp / util / grpc_cli . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( grpc_cli <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> add_executable ( grpc_tool_test <nl> $ { _gRPC_PROTO_GENS_DIR } / src / proto / grpc / testing / echo_messages . pb . h <nl> $ { _gRPC_PROTO_GENS_DIR } / src / proto / grpc / testing / echo_messages . grpc . pb . h <nl> test / cpp / util / grpc_tool_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> protobuf_generate_grpc_cpp ( <nl> target_include_directories ( grpc_tool_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> add_executable ( grpclb_api_test <nl> $ { _gRPC_PROTO_GENS_DIR } / src / proto / grpc / lb / v1 / load_balancer . pb . h <nl> $ { _gRPC_PROTO_GENS_DIR } / src / proto / grpc / lb / v1 / load_balancer . grpc . pb . h <nl> test / cpp / grpclb / grpclb_api_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> protobuf_generate_grpc_cpp ( <nl> target_include_directories ( grpclb_api_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> add_executable ( grpclb_test <nl> $ { _gRPC_PROTO_GENS_DIR } / src / proto / grpc / lb / v1 / load_balancer . pb . h <nl> $ { _gRPC_PROTO_GENS_DIR } / src / proto / grpc / lb / v1 / load_balancer . grpc . pb . h <nl> test / cpp / grpclb / grpclb_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> protobuf_generate_grpc_cpp ( <nl> target_include_directories ( grpclb_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( gRPC_BUILD_TESTS ) <nl> <nl> add_executable ( health_service_end2end_test <nl> test / cpp / end2end / health_service_end2end_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( health_service_end2end_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( gRPC_BUILD_TESTS ) <nl> if ( _gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX ) <nl> <nl> add_executable ( http2_client <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( http2_client <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( gRPC_BUILD_TESTS ) <nl> <nl> add_executable ( hybrid_end2end_test <nl> test / cpp / end2end / hybrid_end2end_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( hybrid_end2end_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( gRPC_BUILD_TESTS ) <nl> if ( _gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX ) <nl> <nl> add_executable ( interop_client <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( interop_client <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( gRPC_BUILD_TESTS ) <nl> if ( _gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX ) <nl> <nl> add_executable ( interop_server <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( interop_server <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( _gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX ) <nl> <nl> add_executable ( interop_test <nl> test / cpp / interop / interop_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( interop_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( _gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX ) <nl> <nl> add_executable ( json_run_localhost <nl> test / cpp / qps / json_run_localhost . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( json_run_localhost <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> add_executable ( metrics_client <nl> $ { _gRPC_PROTO_GENS_DIR } / src / proto / grpc / testing / metrics . pb . h <nl> $ { _gRPC_PROTO_GENS_DIR } / src / proto / grpc / testing / metrics . grpc . pb . h <nl> test / cpp / interop / metrics_client . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> protobuf_generate_grpc_cpp ( <nl> target_include_directories ( metrics_client <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( gRPC_BUILD_TESTS ) <nl> <nl> add_executable ( mock_test <nl> test / cpp / end2end / mock_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( mock_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( gRPC_BUILD_TESTS ) <nl> <nl> add_executable ( noop - benchmark <nl> test / cpp / microbenchmarks / noop - benchmark . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( noop - benchmark <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( gRPC_BUILD_TESTS ) <nl> <nl> add_executable ( proto_server_reflection_test <nl> test / cpp / end2end / proto_server_reflection_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( proto_server_reflection_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( gRPC_BUILD_TESTS ) <nl> <nl> add_executable ( proto_utils_test <nl> test / cpp / codegen / proto_utils_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( proto_utils_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( _gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX ) <nl> <nl> add_executable ( qps_interarrival_test <nl> test / cpp / qps / qps_interarrival_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( qps_interarrival_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( gRPC_BUILD_TESTS ) <nl> <nl> add_executable ( qps_json_driver <nl> test / cpp / qps / qps_json_driver . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( qps_json_driver <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( _gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX ) <nl> <nl> add_executable ( qps_openloop_test <nl> test / cpp / qps / qps_openloop_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( qps_openloop_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( gRPC_BUILD_TESTS ) <nl> <nl> add_executable ( qps_worker <nl> test / cpp / qps / worker . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( qps_worker <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> add_executable ( reconnect_interop_client <nl> $ { _gRPC_PROTO_GENS_DIR } / src / proto / grpc / testing / test . pb . h <nl> $ { _gRPC_PROTO_GENS_DIR } / src / proto / grpc / testing / test . grpc . pb . h <nl> test / cpp / interop / reconnect_interop_client . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> protobuf_generate_grpc_cpp ( <nl> target_include_directories ( reconnect_interop_client <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> add_executable ( reconnect_interop_server <nl> $ { _gRPC_PROTO_GENS_DIR } / src / proto / grpc / testing / test . pb . h <nl> $ { _gRPC_PROTO_GENS_DIR } / src / proto / grpc / testing / test . grpc . pb . h <nl> test / cpp / interop / reconnect_interop_server . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> protobuf_generate_grpc_cpp ( <nl> target_include_directories ( reconnect_interop_server <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( gRPC_BUILD_TESTS ) <nl> <nl> add_executable ( round_robin_end2end_test <nl> test / cpp / end2end / round_robin_end2end_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( round_robin_end2end_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( gRPC_BUILD_TESTS ) <nl> <nl> add_executable ( secure_auth_context_test <nl> test / cpp / common / secure_auth_context_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( secure_auth_context_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( _gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX ) <nl> <nl> add_executable ( secure_sync_unary_ping_pong_test <nl> test / cpp / qps / secure_sync_unary_ping_pong_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( secure_sync_unary_ping_pong_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( gRPC_BUILD_TESTS ) <nl> <nl> add_executable ( server_builder_plugin_test <nl> test / cpp / end2end / server_builder_plugin_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( server_builder_plugin_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> add_executable ( server_builder_test <nl> $ { _gRPC_PROTO_GENS_DIR } / src / proto / grpc / testing / echo . pb . h <nl> $ { _gRPC_PROTO_GENS_DIR } / src / proto / grpc / testing / echo . grpc . pb . h <nl> test / cpp / server / server_builder_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> protobuf_generate_grpc_cpp ( <nl> target_include_directories ( server_builder_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( gRPC_BUILD_TESTS ) <nl> <nl> add_executable ( server_context_test_spouse_test <nl> test / cpp / test / server_context_test_spouse_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( server_context_test_spouse_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( _gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX ) <nl> <nl> add_executable ( server_crash_test <nl> test / cpp / end2end / server_crash_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( server_crash_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( gRPC_BUILD_TESTS ) <nl> <nl> add_executable ( server_crash_test_client <nl> test / cpp / end2end / server_crash_test_client . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( server_crash_test_client <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( gRPC_BUILD_TESTS ) <nl> <nl> add_executable ( shutdown_test <nl> test / cpp / end2end / shutdown_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( shutdown_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( gRPC_BUILD_TESTS ) <nl> <nl> add_executable ( status_test <nl> test / cpp / util / status_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( status_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( _gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX ) <nl> <nl> add_executable ( streaming_throughput_test <nl> test / cpp / end2end / streaming_throughput_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( streaming_throughput_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> add_executable ( stress_test <nl> test / cpp / interop / stress_interop_client . cc <nl> test / cpp / interop / stress_test . cc <nl> test / cpp / util / metrics_server . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> protobuf_generate_grpc_cpp ( <nl> target_include_directories ( stress_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( gRPC_BUILD_TESTS ) <nl> <nl> add_executable ( thread_manager_test <nl> test / cpp / thread_manager / thread_manager_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( thread_manager_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( gRPC_BUILD_TESTS ) <nl> <nl> add_executable ( thread_stress_test <nl> test / cpp / end2end / thread_stress_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( thread_stress_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> if ( _gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX ) <nl> <nl> add_executable ( writes_per_rpc_test <nl> test / cpp / performance / writes_per_rpc_test . cc <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> ) <nl> <nl> <nl> target_include_directories ( writes_per_rpc_test <nl> PRIVATE $ { CARES_PLATFORM_INCLUDE_DIR } <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / cares / cares <nl> PRIVATE $ { CMAKE_CURRENT_BINARY_DIR } / third_party / gflags / include <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> PRIVATE $ { _gRPC_PROTO_GENS_DIR } <nl> ) <nl> <nl> mmm a / Makefile <nl> ppp b / Makefile <nl> AROPTS = $ ( GRPC_CROSS_AROPTS ) # e . g . , rc - - target = elf32 - little <nl> USE_BUILT_PROTOC = false <nl> endif <nl> <nl> - GTEST_LIB = - Ithird_party / googletest / include - Ithird_party / googletest third_party / googletest / src / gtest - all . cc <nl> + GTEST_LIB = - Ithird_party / googletest / googletest / include - Ithird_party / googletest / googletest third_party / googletest / googletest / src / gtest - all . cc <nl> GTEST_LIB + = - lgflags <nl> ifeq ( $ ( V ) , 1 ) <nl> E = @ : <nl> PROTOBUF_PKG_CONFIG = false <nl> PC_REQUIRES_GRPCXX = <nl> PC_LIBS_GRPCXX = <nl> <nl> - CPPFLAGS : = - Ithird_party / googletest / include $ ( CPPFLAGS ) <nl> + CPPFLAGS : = - Ithird_party / googletest / googletest / include $ ( CPPFLAGS ) <nl> <nl> PROTOC_PLUGINS_ALL = $ ( BINDIR ) / $ ( CONFIG ) / grpc_cpp_plugin $ ( BINDIR ) / $ ( CONFIG ) / grpc_csharp_plugin $ ( BINDIR ) / $ ( CONFIG ) / grpc_node_plugin $ ( BINDIR ) / $ ( CONFIG ) / grpc_objective_c_plugin $ ( BINDIR ) / $ ( CONFIG ) / grpc_php_plugin $ ( BINDIR ) / $ ( CONFIG ) / grpc_python_plugin $ ( BINDIR ) / $ ( CONFIG ) / grpc_ruby_plugin <nl> PROTOC_PLUGINS_DIR = $ ( BINDIR ) / $ ( CONFIG ) <nl> bm_chttp2_hpack : $ ( BINDIR ) / $ ( CONFIG ) / bm_chttp2_hpack <nl> bm_chttp2_transport : $ ( BINDIR ) / $ ( CONFIG ) / bm_chttp2_transport <nl> bm_closure : $ ( BINDIR ) / $ ( CONFIG ) / bm_closure <nl> bm_cq : $ ( BINDIR ) / $ ( CONFIG ) / bm_cq <nl> + bm_cq_multiple_threads : $ ( BINDIR ) / $ ( CONFIG ) / bm_cq_multiple_threads <nl> bm_error : $ ( BINDIR ) / $ ( CONFIG ) / bm_error <nl> bm_fullstack_streaming_ping_pong : $ ( BINDIR ) / $ ( CONFIG ) / bm_fullstack_streaming_ping_pong <nl> bm_fullstack_streaming_pump : $ ( BINDIR ) / $ ( CONFIG ) / bm_fullstack_streaming_pump <nl> buildtests_cxx : privatelibs_cxx \ <nl> $ ( BINDIR ) / $ ( CONFIG ) / bm_chttp2_transport \ <nl> $ ( BINDIR ) / $ ( CONFIG ) / bm_closure \ <nl> $ ( BINDIR ) / $ ( CONFIG ) / bm_cq \ <nl> + $ ( BINDIR ) / $ ( CONFIG ) / bm_cq_multiple_threads \ <nl> $ ( BINDIR ) / $ ( CONFIG ) / bm_error \ <nl> $ ( BINDIR ) / $ ( CONFIG ) / bm_fullstack_streaming_ping_pong \ <nl> $ ( BINDIR ) / $ ( CONFIG ) / bm_fullstack_streaming_pump \ <nl> buildtests_cxx : privatelibs_cxx \ <nl> $ ( BINDIR ) / $ ( CONFIG ) / bm_chttp2_transport \ <nl> $ ( BINDIR ) / $ ( CONFIG ) / bm_closure \ <nl> $ ( BINDIR ) / $ ( CONFIG ) / bm_cq \ <nl> + $ ( BINDIR ) / $ ( CONFIG ) / bm_cq_multiple_threads \ <nl> $ ( BINDIR ) / $ ( CONFIG ) / bm_error \ <nl> $ ( BINDIR ) / $ ( CONFIG ) / bm_fullstack_streaming_ping_pong \ <nl> $ ( BINDIR ) / $ ( CONFIG ) / bm_fullstack_streaming_pump \ <nl> test_cxx : buildtests_cxx <nl> $ ( Q ) $ ( BINDIR ) / $ ( CONFIG ) / bm_closure | | ( echo test bm_closure failed ; exit 1 ) <nl> $ ( E ) " [ RUN ] Testing bm_cq " <nl> $ ( Q ) $ ( BINDIR ) / $ ( CONFIG ) / bm_cq | | ( echo test bm_cq failed ; exit 1 ) <nl> + $ ( E ) " [ RUN ] Testing bm_cq_multiple_threads " <nl> + $ ( Q ) $ ( BINDIR ) / $ ( CONFIG ) / bm_cq_multiple_threads | | ( echo test bm_cq_multiple_threads failed ; exit 1 ) <nl> $ ( E ) " [ RUN ] Testing bm_error " <nl> $ ( Q ) $ ( BINDIR ) / $ ( CONFIG ) / bm_error | | ( echo test bm_error failed ; exit 1 ) <nl> $ ( E ) " [ RUN ] Testing bm_fullstack_streaming_ping_pong " <nl> ifeq ( $ ( NO_PROTOC ) , true ) <nl> $ ( GENDIR ) / src / proto / grpc / testing / services . pb . cc : protoc_dep_error <nl> $ ( GENDIR ) / src / proto / grpc / testing / services . grpc . pb . cc : protoc_dep_error <nl> else <nl> - $ ( GENDIR ) / src / proto / grpc / testing / services . pb . cc : src / proto / grpc / testing / services . proto $ ( PROTOBUF_DEP ) $ ( PROTOC_PLUGINS ) $ ( GENDIR ) / src / proto / grpc / testing / messages . pb . cc $ ( GENDIR ) / src / proto / grpc / testing / control . pb . cc <nl> + $ ( GENDIR ) / src / proto / grpc / testing / services . pb . cc : src / proto / grpc / testing / services . proto $ ( PROTOBUF_DEP ) $ ( PROTOC_PLUGINS ) $ ( GENDIR ) / src / proto / grpc / testing / messages . pb . cc $ ( GENDIR ) / src / proto / grpc / testing / control . pb . cc $ ( GENDIR ) / src / proto / grpc / testing / stats . pb . cc <nl> $ ( E ) " [ PROTOC ] Generating protobuf CC file from $ < " <nl> $ ( Q ) mkdir - p ` dirname $ @ ` <nl> $ ( Q ) $ ( PROTOC ) - Ithird_party / protobuf / src - I . - - cpp_out = $ ( GENDIR ) $ < <nl> <nl> - $ ( GENDIR ) / src / proto / grpc / testing / services . grpc . pb . cc : src / proto / grpc / testing / services . proto $ ( PROTOBUF_DEP ) $ ( PROTOC_PLUGINS ) $ ( GENDIR ) / src / proto / grpc / testing / messages . pb . cc $ ( GENDIR ) / src / proto / grpc / testing / messages . grpc . pb . cc $ ( GENDIR ) / src / proto / grpc / testing / control . pb . cc $ ( GENDIR ) / src / proto / grpc / testing / control . grpc . pb . cc <nl> + $ ( GENDIR ) / src / proto / grpc / testing / services . grpc . pb . cc : src / proto / grpc / testing / services . proto $ ( PROTOBUF_DEP ) $ ( PROTOC_PLUGINS ) $ ( GENDIR ) / src / proto / grpc / testing / messages . pb . cc $ ( GENDIR ) / src / proto / grpc / testing / messages . grpc . pb . cc $ ( GENDIR ) / src / proto / grpc / testing / control . pb . cc $ ( GENDIR ) / src / proto / grpc / testing / control . grpc . pb . cc $ ( GENDIR ) / src / proto / grpc / testing / stats . pb . cc $ ( GENDIR ) / src / proto / grpc / testing / stats . grpc . pb . cc <nl> $ ( E ) " [ GRPC ] Generating gRPC ' s protobuf service CC file from $ < " <nl> $ ( Q ) mkdir - p ` dirname $ @ ` <nl> $ ( Q ) $ ( PROTOC ) - Ithird_party / protobuf / src - I . - - grpc_out = $ ( GENDIR ) - - plugin = protoc - gen - grpc = $ ( PROTOC_PLUGINS_DIR ) / grpc_cpp_plugin $ ( EXECUTABLE_SUFFIX ) $ < <nl> LIBGRPC_SRC = \ <nl> src / core / lib / iomgr / iomgr_uv . c \ <nl> src / core / lib / iomgr / iomgr_windows . c \ <nl> src / core / lib / iomgr / load_file . c \ <nl> + src / core / lib / iomgr / lockfree_event . c \ <nl> src / core / lib / iomgr / network_status_tracker . c \ <nl> src / core / lib / iomgr / polling_entity . c \ <nl> src / core / lib / iomgr / pollset_set_uv . c \ <nl> LIBGRPC_CRONET_SRC = \ <nl> src / core / lib / iomgr / iomgr_uv . c \ <nl> src / core / lib / iomgr / iomgr_windows . c \ <nl> src / core / lib / iomgr / load_file . c \ <nl> + src / core / lib / iomgr / lockfree_event . c \ <nl> src / core / lib / iomgr / network_status_tracker . c \ <nl> src / core / lib / iomgr / polling_entity . c \ <nl> src / core / lib / iomgr / pollset_set_uv . c \ <nl> LIBGRPC_TEST_UTIL_SRC = \ <nl> src / core / lib / iomgr / iomgr_uv . c \ <nl> src / core / lib / iomgr / iomgr_windows . c \ <nl> src / core / lib / iomgr / load_file . c \ <nl> + src / core / lib / iomgr / lockfree_event . c \ <nl> src / core / lib / iomgr / network_status_tracker . c \ <nl> src / core / lib / iomgr / polling_entity . c \ <nl> src / core / lib / iomgr / pollset_set_uv . c \ <nl> LIBGRPC_UNSECURE_SRC = \ <nl> src / core / lib / iomgr / iomgr_uv . c \ <nl> src / core / lib / iomgr / iomgr_windows . c \ <nl> src / core / lib / iomgr / load_file . c \ <nl> + src / core / lib / iomgr / lockfree_event . c \ <nl> src / core / lib / iomgr / network_status_tracker . c \ <nl> src / core / lib / iomgr / polling_entity . c \ <nl> src / core / lib / iomgr / pollset_set_uv . c \ <nl> LIBGRPC + + _SRC = \ <nl> src / core / lib / iomgr / iomgr_uv . c \ <nl> src / core / lib / iomgr / iomgr_windows . c \ <nl> src / core / lib / iomgr / load_file . c \ <nl> + src / core / lib / iomgr / lockfree_event . c \ <nl> src / core / lib / iomgr / network_status_tracker . c \ <nl> src / core / lib / iomgr / polling_entity . c \ <nl> src / core / lib / iomgr / pollset_set_uv . c \ <nl> LIBGRPC + + _CRONET_SRC = \ <nl> src / core / lib / iomgr / iomgr_uv . c \ <nl> src / core / lib / iomgr / iomgr_windows . c \ <nl> src / core / lib / iomgr / load_file . c \ <nl> + src / core / lib / iomgr / lockfree_event . c \ <nl> src / core / lib / iomgr / network_status_tracker . c \ <nl> src / core / lib / iomgr / polling_entity . c \ <nl> src / core / lib / iomgr / pollset_set_uv . c \ <nl> LIBGRPC + + _UNSECURE_SRC = \ <nl> src / core / lib / iomgr / iomgr_uv . c \ <nl> src / core / lib / iomgr / iomgr_windows . c \ <nl> src / core / lib / iomgr / load_file . c \ <nl> + src / core / lib / iomgr / lockfree_event . c \ <nl> src / core / lib / iomgr / network_status_tracker . c \ <nl> src / core / lib / iomgr / polling_entity . c \ <nl> src / core / lib / iomgr / pollset_set_uv . c \ <nl> endif <nl> endif <nl> <nl> <nl> + BM_CQ_MULTIPLE_THREADS_SRC = \ <nl> + test / cpp / microbenchmarks / bm_cq_multiple_threads . cc \ <nl> + <nl> + BM_CQ_MULTIPLE_THREADS_OBJS = $ ( addprefix $ ( OBJDIR ) / $ ( CONFIG ) / , $ ( addsuffix . o , $ ( basename $ ( BM_CQ_MULTIPLE_THREADS_SRC ) ) ) ) <nl> + ifeq ( $ ( NO_SECURE ) , true ) <nl> + <nl> + # You can ' t build secure targets if you don ' t have OpenSSL . <nl> + <nl> + $ ( BINDIR ) / $ ( CONFIG ) / bm_cq_multiple_threads : openssl_dep_error <nl> + <nl> + else <nl> + <nl> + <nl> + <nl> + <nl> + ifeq ( $ ( NO_PROTOBUF ) , true ) <nl> + <nl> + # You can ' t build the protoc plugins or protobuf - enabled targets if you don ' t have protobuf 3 . 0 . 0 + . <nl> + <nl> + $ ( BINDIR ) / $ ( CONFIG ) / bm_cq_multiple_threads : protobuf_dep_error <nl> + <nl> + else <nl> + <nl> + $ ( BINDIR ) / $ ( CONFIG ) / bm_cq_multiple_threads : $ ( PROTOBUF_DEP ) $ ( BM_CQ_MULTIPLE_THREADS_OBJS ) $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc_benchmark . a $ ( LIBDIR ) / $ ( CONFIG ) / libbenchmark . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _test_util . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc_test_util . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc . a $ ( LIBDIR ) / $ ( CONFIG ) / libgpr_test_util . a $ ( LIBDIR ) / $ ( CONFIG ) / libgpr . a <nl> + $ ( E ) " [ LD ] Linking $ @ " <nl> + $ ( Q ) mkdir - p ` dirname $ @ ` <nl> + $ ( Q ) $ ( LDXX ) $ ( LDFLAGS ) $ ( BM_CQ_MULTIPLE_THREADS_OBJS ) $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc_benchmark . a $ ( LIBDIR ) / $ ( CONFIG ) / libbenchmark . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _test_util . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc_test_util . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc . a $ ( LIBDIR ) / $ ( CONFIG ) / libgpr_test_util . a $ ( LIBDIR ) / $ ( CONFIG ) / libgpr . a $ ( LDLIBSXX ) $ ( LDLIBS_PROTOBUF ) $ ( LDLIBS ) $ ( LDLIBS_SECURE ) $ ( GTEST_LIB ) - o $ ( BINDIR ) / $ ( CONFIG ) / bm_cq_multiple_threads <nl> + <nl> + endif <nl> + <nl> + endif <nl> + <nl> + $ ( BM_CQ_MULTIPLE_THREADS_OBJS ) : CPPFLAGS + = - Ithird_party / benchmark / include - DHAVE_POSIX_REGEX <nl> + $ ( OBJDIR ) / $ ( CONFIG ) / test / cpp / microbenchmarks / bm_cq_multiple_threads . o : $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc_benchmark . a $ ( LIBDIR ) / $ ( CONFIG ) / libbenchmark . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _test_util . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc_test_util . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc . a $ ( LIBDIR ) / $ ( CONFIG ) / libgpr_test_util . a $ ( LIBDIR ) / $ ( CONFIG ) / libgpr . a <nl> + <nl> + deps_bm_cq_multiple_threads : $ ( BM_CQ_MULTIPLE_THREADS_OBJS : . o = . dep ) <nl> + <nl> + ifneq ( $ ( NO_SECURE ) , true ) <nl> + ifneq ( $ ( NO_DEPS ) , true ) <nl> + - include $ ( BM_CQ_MULTIPLE_THREADS_OBJS : . o = . dep ) <nl> + endif <nl> + endif <nl> + <nl> + <nl> BM_ERROR_SRC = \ <nl> test / cpp / microbenchmarks / bm_error . cc \ <nl> <nl> mmm a / binding . gyp <nl> ppp b / binding . gyp <nl> <nl> # the OpenSSL headers , from the downloaded Node development package , <nl> # which is typically located in ` . node - gyp ` in your home directory . <nl> ' target_name ' : ' WINDOWS_BUILD_WARNING ' , <nl> - ' actions ' : [ <nl> + ' rules ' : [ <nl> { <nl> - ' action_name ' : ' WINDOWS_BUILD_WARNING ' , <nl> + ' rule_name ' : ' WINDOWS_BUILD_WARNING ' , <nl> + ' extension ' : ' S ' , <nl> ' inputs ' : [ <nl> ' package . json ' <nl> ] , <nl> <nl> ' src / core / lib / iomgr / iomgr_uv . c ' , <nl> ' src / core / lib / iomgr / iomgr_windows . c ' , <nl> ' src / core / lib / iomgr / load_file . c ' , <nl> + ' src / core / lib / iomgr / lockfree_event . c ' , <nl> ' src / core / lib / iomgr / network_status_tracker . c ' , <nl> ' src / core / lib / iomgr / polling_entity . c ' , <nl> ' src / core / lib / iomgr / pollset_set_uv . c ' , <nl> mmm a / build . yaml <nl> ppp b / build . yaml <nl> filegroups : <nl> - src / core / lib / iomgr / iomgr_internal . h <nl> - src / core / lib / iomgr / iomgr_posix . h <nl> - src / core / lib / iomgr / load_file . h <nl> + - src / core / lib / iomgr / lockfree_event . h <nl> - src / core / lib / iomgr / network_status_tracker . h <nl> - src / core / lib / iomgr / polling_entity . h <nl> - src / core / lib / iomgr / pollset . h <nl> filegroups : <nl> - src / core / lib / iomgr / iomgr_uv . c <nl> - src / core / lib / iomgr / iomgr_windows . c <nl> - src / core / lib / iomgr / load_file . c <nl> + - src / core / lib / iomgr / lockfree_event . c <nl> - src / core / lib / iomgr / network_status_tracker . c <nl> - src / core / lib / iomgr / polling_entity . c <nl> - src / core / lib / iomgr / pollset_set_uv . c <nl> targets : <nl> - mac <nl> - linux <nl> - posix <nl> + - name : bm_cq_multiple_threads <nl> + build : test <nl> + language : c + + <nl> + src : <nl> + - test / cpp / microbenchmarks / bm_cq_multiple_threads . cc <nl> + deps : <nl> + - grpc_benchmark <nl> + - benchmark <nl> + - grpc + + _test_util <nl> + - grpc_test_util <nl> + - grpc + + <nl> + - grpc <nl> + - gpr_test_util <nl> + - gpr <nl> + args : <nl> + - - - benchmark_min_time = 0 <nl> + defaults : benchmark <nl> + platforms : <nl> + - mac <nl> + - linux <nl> + - posix <nl> - name : bm_error <nl> build : test <nl> language : c + + <nl> mmm a / cmake / msvc_static_runtime . cmake <nl> ppp b / cmake / msvc_static_runtime . cmake <nl> option ( gRPC_MSVC_STATIC_RUNTIME " Link with static msvc runtime libraries " OFF ) <nl> if ( gRPC_MSVC_STATIC_RUNTIME ) <nl> # switch from dynamic to static linking of msvcrt <nl> foreach ( flag_var <nl> + CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE <nl> + CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO <nl> CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE <nl> CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO ) <nl> <nl> mmm a / config . m4 <nl> ppp b / config . m4 <nl> if test " $ PHP_GRPC " ! = " no " ; then <nl> src / core / lib / iomgr / iomgr_uv . c \ <nl> src / core / lib / iomgr / iomgr_windows . c \ <nl> src / core / lib / iomgr / load_file . c \ <nl> + src / core / lib / iomgr / lockfree_event . c \ <nl> src / core / lib / iomgr / network_status_tracker . c \ <nl> src / core / lib / iomgr / polling_entity . c \ <nl> src / core / lib / iomgr / pollset_set_uv . c \ <nl> mmm a / doc / PROTOCOL - WEB . md <nl> ppp b / doc / PROTOCOL - WEB . md <nl> in the body . <nl> <nl> User Agent <nl> <nl> - * U - A : grpc - web - javascript <nl> + * Do NOT use User - Agent header ( which is to be set by browsers , by default ) <nl> + * Use X - User - Agent : grpc - web - javascript / 0 . 1 ( follow the same format as specified in [ gRPC over HTTP2 ] ( http : / / www . grpc . io / docs / guides / wire . html ) ) <nl> <nl> mmm <nl> <nl> mmm a / etc / roots . pem <nl> ppp b / etc / roots . pem <nl> wKeI8lN3s2Berq4o2jUsbzRF0ybh3uxbTydrFny9RAQYgrOJeRcQcT16ohZO9QHN <nl> pGxlaKFJdlxDydi8NmdspZS11My5vWo1ViHe2MPr + 8ukYEywVaCge1ey <nl> mmm - - END CERTIFICATEmmm - - <nl> <nl> - # Issuer : CN = WellsSecure Public Root Certificate Authority O = Wells Fargo WellsSecure OU = Wells Fargo Bank NA <nl> - # Subject : CN = WellsSecure Public Root Certificate Authority O = Wells Fargo WellsSecure OU = Wells Fargo Bank NA <nl> - # Label : " WellsSecure Public Root Certificate Authority " <nl> - # Serial : 1 <nl> - # MD5 Fingerprint : 15 : ac : a5 : c2 : 92 : 2d : 79 : bc : e8 : 7f : cb : 67 : ed : 02 : cf : 36 <nl> - # SHA1 Fingerprint : e7 : b4 : f6 : 9d : 61 : ec : 90 : 69 : db : 7e : 90 : a7 : 40 : 1a : 3c : f4 : 7d : 4f : e8 : ee <nl> - # SHA256 Fingerprint : a7 : 12 : 72 : ae : aa : a3 : cf : e8 : 72 : 7f : 7f : b3 : 9f : 0f : b3 : d1 : e5 : 42 : 6e : 90 : 60 : b0 : 6e : e6 : f1 : 3e : 9a : 3c : 58 : 33 : cd : 43 <nl> mmmmmmBEGIN CERTIFICATEmmm - - <nl> - MIIEvTCCA6WgAwIBAgIBATANBgkqhkiG9w0BAQUFADCBhTELMAkGA1UEBhMCVVMx <nl> - IDAeBgNVBAoMF1dlbGxzIEZhcmdvIFdlbGxzU2VjdXJlMRwwGgYDVQQLDBNXZWxs <nl> - cyBGYXJnbyBCYW5rIE5BMTYwNAYDVQQDDC1XZWxsc1NlY3VyZSBQdWJsaWMgUm9v <nl> - dCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMDcxMjEzMTcwNzU0WhcNMjIxMjE0 <nl> - MDAwNzU0WjCBhTELMAkGA1UEBhMCVVMxIDAeBgNVBAoMF1dlbGxzIEZhcmdvIFdl <nl> - bGxzU2VjdXJlMRwwGgYDVQQLDBNXZWxscyBGYXJnbyBCYW5rIE5BMTYwNAYDVQQD <nl> - DC1XZWxsc1NlY3VyZSBQdWJsaWMgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkw <nl> - ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDub7S9eeKPCCGeOARBJe + r <nl> - WxxTkqxtnt3CxC5FlAM1iGd0V + PfjLindo8796jE2yljDpFoNoqXjopxaAkH5OjU <nl> - Dk / 41itMpBb570OYj7OeUt9tkTmPOL13i0Nj67eT / DBMHAGTthP796EfvyXhdDcs <nl> - HqRePGj4S78NuR4uNuip5Kf4D8uCdXw1LSLWwr8L87T8bJVhHlfXBIEyg1J55oNj <nl> - z7fLY4sR4r1e6 / aN7ZVyKLSsEmLpSjPmgzKuBXWVvYSV2ypcm44uDLiBK0HmOFaf <nl> - SZtsdvqKXfcBeYF8wYNABf5x / Qw / zE5gCQ5lRxAvAcAFP4 / 4s0HvWkJ + We / Slwxl <nl> - AgMBAAGjggE0MIIBMDAPBgNVHRMBAf8EBTADAQH / MDkGA1UdHwQyMDAwLqAsoCqG <nl> - KGh0dHA6Ly9jcmwucGtpLndlbGxzZmFyZ28uY29tL3dzcHJjYS5jcmwwDgYDVR0P <nl> - AQH / BAQDAgHGMB0GA1UdDgQWBBQmlRkQ2eihl5H / 3BnZtQQ + 0nMKajCBsgYDVR0j <nl> - BIGqMIGngBQmlRkQ2eihl5H / 3BnZtQQ + 0nMKaqGBi6SBiDCBhTELMAkGA1UEBhMC <nl> - VVMxIDAeBgNVBAoMF1dlbGxzIEZhcmdvIFdlbGxzU2VjdXJlMRwwGgYDVQQLDBNX <nl> - ZWxscyBGYXJnbyBCYW5rIE5BMTYwNAYDVQQDDC1XZWxsc1NlY3VyZSBQdWJsaWMg <nl> - Um9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHmCAQEwDQYJKoZIhvcNAQEFBQADggEB <nl> - ALkVsUSRzCPIK0134 / iaeycNzXK7mQDKfGYZUMbVmO2rvwNa5U3lHshPcZeG1eMd <nl> - / ZDJPHV3V3p9 + N701NX3leZ0bh08rnyd2wIDBSxxSyU + B + NemvVmFymIGjifz6pB <nl> - A4SXa5M4esowRBskRDPQ5NHcKDj0E0M1NSljqHyita04pO2t / caaH / + Xc / 77szWn <nl> - k4bGdpEA5qxRFsQnMlzbc9qlk1eOPm01JghZ1edE13YgY + esE2fDbbFwRnzVlhE9 <nl> - iW9dqKHrjQrawx0zbKPqZxmamX9LPYNRKh3KL4YMon4QLSvUFpULB6ouFJJJtylv <nl> - 2G0xffX8oRAHh84vWdw + WNs = <nl> mmmmmmEND CERTIFICATEmmm - - <nl> - <nl> # Issuer : CN = COMODO ECC Certification Authority O = COMODO CA Limited <nl> # Subject : CN = COMODO ECC Certification Authority O = COMODO CA Limited <nl> # Label : " COMODO ECC Certification Authority " <nl> Fj4A4xylNoEYokxSdsARo27mHbrjWr42U8U + dY + GaSlYU7Wcu2 + fXMUY7N0v4ZjJ <nl> / L7fCg0 = <nl> mmm - - END CERTIFICATEmmm - - <nl> <nl> - # Issuer : CN = Microsec e - Szigno Root CA O = Microsec Ltd . OU = e - Szigno CA <nl> - # Subject : CN = Microsec e - Szigno Root CA O = Microsec Ltd . OU = e - Szigno CA <nl> - # Label : " Microsec e - Szigno Root CA " <nl> - # Serial : 272122594155480254301341951808045322001 <nl> - # MD5 Fingerprint : f0 : 96 : b6 : 2f : c5 : 10 : d5 : 67 : 8e : 83 : 25 : 32 : e8 : 5e : 2e : e5 <nl> - # SHA1 Fingerprint : 23 : 88 : c9 : d3 : 71 : cc : 9e : 96 : 3d : ff : 7d : 3c : a7 : ce : fc : d6 : 25 : ec : 19 : 0d <nl> - # SHA256 Fingerprint : 32 : 7a : 3d : 76 : 1a : ba : de : a0 : 34 : eb : 99 : 84 : 06 : 27 : 5c : b1 : a4 : 77 : 6e : fd : ae : 2f : df : 6d : 01 : 68 : ea : 1c : 4f : 55 : 67 : d0 <nl> mmmmmmBEGIN CERTIFICATEmmm - - <nl> - MIIHqDCCBpCgAwIBAgIRAMy4579OKRr9otxmpRwsDxEwDQYJKoZIhvcNAQEFBQAw <nl> - cjELMAkGA1UEBhMCSFUxETAPBgNVBAcTCEJ1ZGFwZXN0MRYwFAYDVQQKEw1NaWNy <nl> - b3NlYyBMdGQuMRQwEgYDVQQLEwtlLVN6aWdubyBDQTEiMCAGA1UEAxMZTWljcm9z <nl> - ZWMgZS1Temlnbm8gUm9vdCBDQTAeFw0wNTA0MDYxMjI4NDRaFw0xNzA0MDYxMjI4 <nl> - NDRaMHIxCzAJBgNVBAYTAkhVMREwDwYDVQQHEwhCdWRhcGVzdDEWMBQGA1UEChMN <nl> - TWljcm9zZWMgTHRkLjEUMBIGA1UECxMLZS1Temlnbm8gQ0ExIjAgBgNVBAMTGU1p <nl> - Y3Jvc2VjIGUtU3ppZ25vIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw <nl> - ggEKAoIBAQDtyADVgXvNOABHzNuEwSFpLHSQDCHZU4ftPkNEU6 + r + ICbPHiN1I2u <nl> - uO / TEdyB5s87lozWbxXGd36hL + BfkrYn13aaHUM86tnsL + 4582pnS4uCzyL4ZVX + <nl> - LMsvfUh6PXX5qqAnu3jCBspRwn5mS6 / NoqdNAoI / gqyFxuEPkEeZlApxcpMqyabA <nl> - vjxWTHOSJ / FrtfX9 / DAFYJLG65Z + AZHCabEeHXtTRbjcQR / Ji3HWVBTji1R4P770 <nl> - Yjtb9aPs1ZJ04nQw7wHb4dSrmZsqa / i9phyGI0Jf7Enemotb9HI6QMVJPqW + jqpx <nl> - 62z69Rrkav17fVVA71hu5tnVvCSrwe + 3AgMBAAGjggQ3MIIEMzBnBggrBgEFBQcB <nl> - AQRbMFkwKAYIKwYBBQUHMAGGHGh0dHBzOi8vcmNhLmUtc3ppZ25vLmh1L29jc3Aw <nl> - LQYIKwYBBQUHMAKGIWh0dHA6Ly93d3cuZS1zemlnbm8uaHUvUm9vdENBLmNydDAP <nl> - BgNVHRMBAf8EBTADAQH / MIIBcwYDVR0gBIIBajCCAWYwggFiBgwrBgEEAYGoGAIB <nl> - AQEwggFQMCgGCCsGAQUFBwIBFhxodHRwOi8vd3d3LmUtc3ppZ25vLmh1L1NaU1ov <nl> - MIIBIgYIKwYBBQUHAgIwggEUHoIBEABBACAAdABhAG4A + gBzAO0AdAB2AOEAbgB5 <nl> - ACAA6QByAHQAZQBsAG0AZQB6AOkAcwDpAGgAZQB6ACAA6QBzACAAZQBsAGYAbwBn <nl> - AGEAZADhAHMA4QBoAG8AegAgAGEAIABTAHoAbwBsAGcA4QBsAHQAYQB0APMAIABT <nl> - AHoAbwBsAGcA4QBsAHQAYQB0AOEAcwBpACAAUwB6AGEAYgDhAGwAeQB6AGEAdABh <nl> - ACAAcwB6AGUAcgBpAG4AdAAgAGsAZQBsAGwAIABlAGwAagDhAHIAbgBpADoAIABo <nl> - AHQAdABwADoALwAvAHcAdwB3AC4AZQAtAHMAegBpAGcAbgBvAC4AaAB1AC8AUwBa <nl> - AFMAWgAvMIHIBgNVHR8EgcAwgb0wgbqggbeggbSGIWh0dHA6Ly93d3cuZS1zemln <nl> - bm8uaHUvUm9vdENBLmNybIaBjmxkYXA6Ly9sZGFwLmUtc3ppZ25vLmh1L0NOPU1p <nl> - Y3Jvc2VjJTIwZS1Temlnbm8lMjBSb290JTIwQ0EsT1U9ZS1Temlnbm8lMjBDQSxP <nl> - PU1pY3Jvc2VjJTIwTHRkLixMPUJ1ZGFwZXN0LEM9SFU / Y2VydGlmaWNhdGVSZXZv <nl> - Y2F0aW9uTGlzdDtiaW5hcnkwDgYDVR0PAQH / BAQDAgEGMIGWBgNVHREEgY4wgYuB <nl> - EGluZm9AZS1zemlnbm8uaHWkdzB1MSMwIQYDVQQDDBpNaWNyb3NlYyBlLVN6aWdu <nl> - w7MgUm9vdCBDQTEWMBQGA1UECwwNZS1TemlnbsOzIEhTWjEWMBQGA1UEChMNTWlj <nl> - cm9zZWMgS2Z0LjERMA8GA1UEBxMIQnVkYXBlc3QxCzAJBgNVBAYTAkhVMIGsBgNV <nl> - HSMEgaQwgaGAFMegSXUWYYTbMUuE0vE3QJDvTtz3oXakdDByMQswCQYDVQQGEwJI <nl> - VTERMA8GA1UEBxMIQnVkYXBlc3QxFjAUBgNVBAoTDU1pY3Jvc2VjIEx0ZC4xFDAS <nl> - BgNVBAsTC2UtU3ppZ25vIENBMSIwIAYDVQQDExlNaWNyb3NlYyBlLVN6aWdubyBS <nl> - b290IENBghEAzLjnv04pGv2i3GalHCwPETAdBgNVHQ4EFgQUx6BJdRZhhNsxS4TS <nl> - 8TdAkO9O3PcwDQYJKoZIhvcNAQEFBQADggEBANMTnGZjWS7KXHAM / IO8VbH0jgds <nl> - ZifOwTsgqRy7RlRw7lrMoHfqaEQn6 / Ip3Xep1fvj1KcExJW4C + FEaGAHQzAxQmHl <nl> - 7tnlJNUb3 + FKG6qfx1 / 4ehHqE5MAyopYse7tDk2016g2JnzgOsHVV4Lxdbb9iV / a <nl> - 86g4nzUGCM4ilb7N1fy + W955a9x6qWVmvrElWl / tftOsRm1M9DKHtCAE4Gx4sHfR <nl> - hUZLphK3dehKyVZs15KrnfVJONJPU + NVkBHbmJbGSfI + 9J8b4PeI3CVimUTYc78 / <nl> - MPMMNz7UwiiAc7EBt51alhQBS6kRnSlqLtBdgcDPsiBDxwPgN05dCtxZICU = <nl> mmmmmmEND CERTIFICATEmmm - - <nl> - <nl> # Issuer : CN = Certigna O = Dhimyotis <nl> # Subject : CN = Certigna O = Dhimyotis <nl> # Label : " Certigna " <nl> buXf6iFViZx9fX + Y9QCJ7uOEwFyWtcVG6kbghVW2G8kS1sHNzYDzAgE8yGnLRUhj <nl> 2JTQ7IUOO04RZfSCjKY9ri4ilAnIXOo8gV0WKgOXFlUJ24pBgp5mmxE = <nl> mmm - - END CERTIFICATEmmm - - <nl> <nl> - # Issuer : O = Japanese Government OU = ApplicationCA <nl> - # Subject : O = Japanese Government OU = ApplicationCA <nl> - # Label : " ApplicationCA - Japanese Government " <nl> - # Serial : 49 <nl> - # MD5 Fingerprint : 7e : 23 : 4e : 5b : a7 : a5 : b4 : 25 : e9 : 00 : 07 : 74 : 11 : 62 : ae : d6 <nl> - # SHA1 Fingerprint : 7f : 8a : b0 : cf : d0 : 51 : 87 : 6a : 66 : f3 : 36 : 0f : 47 : c8 : 8d : 8c : d3 : 35 : fc : 74 <nl> - # SHA256 Fingerprint : 2d : 47 : 43 : 7d : e1 : 79 : 51 : 21 : 5a : 12 : f3 : c5 : 8e : 51 : c7 : 29 : a5 : 80 : 26 : ef : 1f : cc : 0a : 5f : b3 : d9 : dc : 01 : 2f : 60 : 0d : 19 <nl> mmmmmmBEGIN CERTIFICATEmmm - - <nl> - MIIDoDCCAoigAwIBAgIBMTANBgkqhkiG9w0BAQUFADBDMQswCQYDVQQGEwJKUDEc <nl> - MBoGA1UEChMTSmFwYW5lc2UgR292ZXJubWVudDEWMBQGA1UECxMNQXBwbGljYXRp <nl> - b25DQTAeFw0wNzEyMTIxNTAwMDBaFw0xNzEyMTIxNTAwMDBaMEMxCzAJBgNVBAYT <nl> - AkpQMRwwGgYDVQQKExNKYXBhbmVzZSBHb3Zlcm5tZW50MRYwFAYDVQQLEw1BcHBs <nl> - aWNhdGlvbkNBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAp23gdE6H <nl> - j6UG3mii24aZS2QNcfAKBZuOquHMLtJqO8F6tJdhjYq + xpqcBrSGUeQ3DnR4fl + K <nl> - f5Sk10cI / VBaVuRorChzoHvpfxiSQE8tnfWuREhzNgaeZCw7NCPbXCbkcXmP1G55 <nl> - IrmTwcrNwVbtiGrXoDkhBFcsovW8R0FPXjQilbUfKW1eSvNNcr5BViCH / OlQR9cw <nl> - FO5cjFW6WY2H / CPek9AEjP3vbb3QesmlOmpyM8ZKDQUXKi17safY1vC + 9D / qDiht <nl> - QWEjdnjDuGWk81quzMKq2edY3rZ + nYVunyoKb58DKTCXKB28t89UKU5RMfkntigm <nl> - / qJj5kEW8DOYRwIDAQABo4GeMIGbMB0GA1UdDgQWBBRUWssmP3HMlEYNllPqa0jQ <nl> - k / 5CdTAOBgNVHQ8BAf8EBAMCAQYwWQYDVR0RBFIwUKROMEwxCzAJBgNVBAYTAkpQ <nl> - MRgwFgYDVQQKDA / ml6XmnKzlm73mlL / lupwxIzAhBgNVBAsMGuOCouODl + ODquOC <nl> - seODvOOCt + ODp + ODs0NBMA8GA1UdEwEB / wQFMAMBAf8wDQYJKoZIhvcNAQEFBQAD <nl> - ggEBADlqRHZ3ODrso2dGD / mLBqj7apAxzn7s2tGJfHrrLgy9mTLnsCTWw / / 1sogJ <nl> - hyzjVOGjprIIC8CFqMjSnHH2HZ9g / DgzE + Ge3Atf2hZQKXsvcJEPmbo0NI2VdMV + <nl> - eKlmXb3KIXdCEKxmJj3ekav9FfBv7WxfEPjzFvYDio + nEhEMy / 0 / ecGc / WLuo89U <nl> - DNErXxc + 4z6 / wCs + CZv + iKZ + tJIX / COUgb1up8WMwusRRdv4QcmWdupwX3kSa + Sj <nl> - B1oF7ydJzyGfikwJcGapJsErEU4z0g781mzSDjJkaP + tBXhfAx2o45CsJOAPQKdL <nl> - rosot4LKGAfmt1t06SAZf7IbiVQ = <nl> mmmmmmEND CERTIFICATEmmm - - <nl> - <nl> # Issuer : CN = GeoTrust Primary Certification Authority - G3 O = GeoTrust Inc . OU = ( c ) 2008 GeoTrust Inc . - For authorized use only <nl> # Subject : CN = GeoTrust Primary Certification Authority - G3 O = GeoTrust Inc . OU = ( c ) 2008 GeoTrust Inc . - For authorized use only <nl> # Label : " GeoTrust Primary Certification Authority - G3 " <nl> Yv4HAqGEVka + lgqaE9chTLd8B59OTj + RdPsnnRHM3eaxynFNExc5JsUpISuTKWqW <nl> + qtB4Uu2NQvAmxU = <nl> mmm - - END CERTIFICATEmmm - - <nl> <nl> - # Issuer : CN = TÜRKTRUST Elektronik Sertifika Hizmet Sağlayıcısı H6 O = TÜRKTRUST Bilgi İletişim ve Bilişim Güvenliği Hizmetleri A . Ş . <nl> - # Subject : CN = TÜRKTRUST Elektronik Sertifika Hizmet Sağlayıcısı H6 O = TÜRKTRUST Bilgi İletişim ve Bilişim Güvenliği Hizmetleri A . Ş . <nl> - # Label : " TÜRKTRUST Elektronik Sertifika Hizmet Sağlayıcısı H6 " <nl> - # Serial : 138134509972618 <nl> - # MD5 Fingerprint : f8 : c5 : ee : 2a : 6b : be : 95 : 8d : 08 : f7 : 25 : 4a : ea : 71 : 3e : 46 <nl> - # SHA1 Fingerprint : 8a : 5c : 8c : ee : a5 : 03 : e6 : 05 : 56 : ba : d8 : 1b : d4 : f6 : c9 : b0 : ed : e5 : 2f : e0 <nl> - # SHA256 Fingerprint : 8d : e7 : 86 : 55 : e1 : be : 7f : 78 : 47 : 80 : 0b : 93 : f6 : 94 : d2 : 1d : 36 : 8c : c0 : 6e : 03 : 3e : 7f : ab : 04 : bb : 5e : b9 : 9d : a6 : b7 : 00 <nl> mmmmmmBEGIN CERTIFICATEmmm - - <nl> - MIIEJjCCAw6gAwIBAgIGfaHyZeyKMA0GCSqGSIb3DQEBCwUAMIGxMQswCQYDVQQG <nl> - EwJUUjEPMA0GA1UEBwwGQW5rYXJhMU0wSwYDVQQKDERUw5xSS1RSVVNUIEJpbGdp <nl> - IMSwbGV0acWfaW0gdmUgQmlsacWfaW0gR8O8dmVubGnEn2kgSGl6bWV0bGVyaSBB <nl> - LsWeLjFCMEAGA1UEAww5VMOcUktUUlVTVCBFbGVrdHJvbmlrIFNlcnRpZmlrYSBI <nl> - aXptZXQgU2HEn2xhecSxY8Sxc8SxIEg2MB4XDTEzMTIxODA5MDQxMFoXDTIzMTIx <nl> - NjA5MDQxMFowgbExCzAJBgNVBAYTAlRSMQ8wDQYDVQQHDAZBbmthcmExTTBLBgNV <nl> - BAoMRFTDnFJLVFJVU1QgQmlsZ2kgxLBsZXRpxZ9pbSB2ZSBCaWxpxZ9pbSBHw7x2 <nl> - ZW5sacSfaSBIaXptZXRsZXJpIEEuxZ4uMUIwQAYDVQQDDDlUw5xSS1RSVVNUIEVs <nl> - ZWt0cm9uaWsgU2VydGlmaWthIEhpem1ldCBTYcSfbGF5xLFjxLFzxLEgSDYwggEi <nl> - MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCdsGjW6L0UlqMACprx9MfMkU1x <nl> - eHe59yEmFXNRFpQJRwXiM / VomjX / 3EsvMsew7eKC5W / a2uqsxgbPJQ1BgfbBOCK9 <nl> - + bGlprMBvD9QFyv26WZV1DOzXPhDIHiTVRZwGTLmiddk671IUP320EEDwnS3 / faA <nl> - z1vFq6TWlRKb55cTMgPp1KtDWxbtMyJkKbbSk60vbNg9tvYdDjTu0n2pVQ8g9P0p <nl> - u5FbHH3GQjhtQiht1AH7zYiXSX6484P4tZgvsycLSF5W506jM7NE1qXyGJTtHB6p <nl> - lVxiSvgNZ1GpryHV + DKdeboaX + UEVU0TRv / yz3THGmNtwx8XEsMeED5gCLMxAgMB <nl> - AAGjQjBAMB0GA1UdDgQWBBTdVRcT9qzoSCHK77Wv0QAy7Z6MtTAOBgNVHQ8BAf8E <nl> - BAMCAQYwDwYDVR0TAQH / BAUwAwEB / zANBgkqhkiG9w0BAQsFAAOCAQEAb1gNl0Oq <nl> - FlQ + v6nfkkU / hQu7VtMMUszIv3ZnXuaqs6fvuay0EBQNdH49ba3RfdCaqaXKGDsC <nl> - QC4qnFAUi / 5XfldcEQlLNkVS9z2sFP1E34uXI9TDwe7UU5X + LEr + DXCqu4svLcsy <nl> - o4LyVN / Y8t3XSHLuSqMplsNEzm61kod2pLv0kmzOLBQJZo6NrRa1xxsJYTvjIKID <nl> - gI6tflEATseWhvtDmHd9KMeP2Cpu54Rvl0EpABZeTeIT6lnAY2c6RPuY / ATTMHKm <nl> - 9ocJV612ph1jmv3XZch4gyt1O6VbuA1df74jrlZVlFjvH4GMKrLN5ptjnhi85WsG <nl> - tAuYSyher4hYyw = = <nl> mmmmmmEND CERTIFICATEmmm - - <nl> - <nl> # Issuer : CN = Certinomis - Root CA O = Certinomis OU = 0002 433998903 <nl> # Subject : CN = Certinomis - Root CA O = Certinomis OU = 0002 433998903 <nl> # Label : " Certinomis - Root CA " <nl> LSoSOcbDWjLtR5EWDrw4wVDej8oqkDQc7kGUnF4ZLvhFSZl0kbAEb + MEWrGrKqv + <nl> x9CWttrhSmQGbmBNvUJO / 3jaJMobtNeWOWyu8Q6qp31IiyBMz2TWuJdGsE7RKlY6 <nl> oJO9r4Ak4Ap + 58rVyuiFVdw2KuGUaJPHZnJED4AhMmwlxyOAgwrr <nl> mmm - - END CERTIFICATEmmm - - <nl> + <nl> + # Issuer : CN = TUBITAK Kamu SM SSL Kok Sertifikasi - Surum 1 O = Turkiye Bilimsel ve Teknolojik Arastirma Kurumu - TUBITAK OU = Kamu Sertifikasyon Merkezi - Kamu SM <nl> + # Subject : CN = TUBITAK Kamu SM SSL Kok Sertifikasi - Surum 1 O = Turkiye Bilimsel ve Teknolojik Arastirma Kurumu - TUBITAK OU = Kamu Sertifikasyon Merkezi - Kamu SM <nl> + # Label : " TUBITAK Kamu SM SSL Kok Sertifikasi - Surum 1 " <nl> + # Serial : 1 <nl> + # MD5 Fingerprint : dc : 00 : 81 : dc : 69 : 2f : 3e : 2f : b0 : 3b : f6 : 3d : 5a : 91 : 8e : 49 <nl> + # SHA1 Fingerprint : 31 : 43 : 64 : 9b : ec : ce : 27 : ec : ed : 3a : 3f : 0b : 8f : 0d : e4 : e8 : 91 : dd : ee : ca <nl> + # SHA256 Fingerprint : 46 : ed : c3 : 68 : 90 : 46 : d5 : 3a : 45 : 3f : b3 : 10 : 4a : b8 : 0d : ca : ec : 65 : 8b : 26 : 60 : ea : 16 : 29 : dd : 7e : 86 : 79 : 90 : 64 : 87 : 16 <nl> + mmm - - BEGIN CERTIFICATEmmm - - <nl> + MIIEYzCCA0ugAwIBAgIBATANBgkqhkiG9w0BAQsFADCB0jELMAkGA1UEBhMCVFIx <nl> + GDAWBgNVBAcTD0dlYnplIC0gS29jYWVsaTFCMEAGA1UEChM5VHVya2l5ZSBCaWxp <nl> + bXNlbCB2ZSBUZWtub2xvamlrIEFyYXN0aXJtYSBLdXJ1bXUgLSBUVUJJVEFLMS0w <nl> + KwYDVQQLEyRLYW11IFNlcnRpZmlrYXN5b24gTWVya2V6aSAtIEthbXUgU00xNjA0 <nl> + BgNVBAMTLVRVQklUQUsgS2FtdSBTTSBTU0wgS29rIFNlcnRpZmlrYXNpIC0gU3Vy <nl> + dW0gMTAeFw0xMzExMjUwODI1NTVaFw00MzEwMjUwODI1NTVaMIHSMQswCQYDVQQG <nl> + EwJUUjEYMBYGA1UEBxMPR2ViemUgLSBLb2NhZWxpMUIwQAYDVQQKEzlUdXJraXll <nl> + IEJpbGltc2VsIHZlIFRla25vbG9qaWsgQXJhc3Rpcm1hIEt1cnVtdSAtIFRVQklU <nl> + QUsxLTArBgNVBAsTJEthbXUgU2VydGlmaWthc3lvbiBNZXJrZXppIC0gS2FtdSBT <nl> + TTE2MDQGA1UEAxMtVFVCSVRBSyBLYW11IFNNIFNTTCBLb2sgU2VydGlmaWthc2kg <nl> + LSBTdXJ1bSAxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAr3UwM6q7 <nl> + a9OZLBI3hNmNe5eA027n / 5tQlT6QlVZC1xl8JoSNkvoBHToP4mQ4t4y86Ij5iySr <nl> + LqP1N + RAjhgleYN1Hzv / bKjFxlb4tO2KRKOrbEz8HdDc72i9z + SqzvBV96I01INr <nl> + N3wcwv61A + xXzry0tcXtAA9TNypN9E8Mg / uGz8v + jE69h / mniyFXnHrfA2eJLJ2X <nl> + YacQuFWQfw4tJzh03 + f92k4S400VIgLI4OD8D62K18lUUMw7D8oWgITQUVbDjlZ / <nl> + iSIzL + aFCr2lqBs23tPcLG07xxO9WSMs5uWk99gL7eqQQESolbuT1dCANLZGeA4f <nl> + AJNG4e7p + exPFwIDAQABo0IwQDAdBgNVHQ4EFgQUZT / HiobGPN08VFw1 + DrtUgxH <nl> + V8gwDgYDVR0PAQH / BAQDAgEGMA8GA1UdEwEB / wQFMAMBAf8wDQYJKoZIhvcNAQEL <nl> + BQADggEBACo / 4fEyjq7hmFxLXs9rHmoJ0iKpEsdeV31zVmSAhHqT5Am5EM2fKifh <nl> + AHe + SMg1qIGf5LgsyX8OsNJLN13qudULXjS99HMpw + 0mFZx + CFOKWI3QSyjfwbPf <nl> + IPP54 + M638yclNhOT8NrF7f3cuitZjO1JVOr4PhMqZ398g26rrnZqsZr + ZO7rqu4 <nl> + lzwDGrpDxpa5RXI4s6ehlj2Re37AIVNMh + 3yC1SVUZPVIqUNivGTDj5UDrDYyU7c <nl> + 8jEyVupk + eq1nRZmQnLzf9OxMUP8pI4X8W0jq5Rm + K37DwhuJi1 / FwcJsoz7UMCf <nl> + lo3Ptv0AnVoUmr8CRPXBwp8iXqIPoeM = <nl> + mmm - - END CERTIFICATEmmm - - <nl> mmm a / gRPC - Core . podspec <nl> ppp b / gRPC - Core . podspec <nl> Pod : : Spec . new do | s | <nl> ' src / core / lib / iomgr / iomgr_internal . h ' , <nl> ' src / core / lib / iomgr / iomgr_posix . h ' , <nl> ' src / core / lib / iomgr / load_file . h ' , <nl> + ' src / core / lib / iomgr / lockfree_event . h ' , <nl> ' src / core / lib / iomgr / network_status_tracker . h ' , <nl> ' src / core / lib / iomgr / polling_entity . h ' , <nl> ' src / core / lib / iomgr / pollset . h ' , <nl> Pod : : Spec . new do | s | <nl> ' src / core / lib / iomgr / iomgr_uv . c ' , <nl> ' src / core / lib / iomgr / iomgr_windows . c ' , <nl> ' src / core / lib / iomgr / load_file . c ' , <nl> + ' src / core / lib / iomgr / lockfree_event . c ' , <nl> ' src / core / lib / iomgr / network_status_tracker . c ' , <nl> ' src / core / lib / iomgr / polling_entity . c ' , <nl> ' src / core / lib / iomgr / pollset_set_uv . c ' , <nl> Pod : : Spec . new do | s | <nl> ' src / core / lib / iomgr / iomgr_internal . h ' , <nl> ' src / core / lib / iomgr / iomgr_posix . h ' , <nl> ' src / core / lib / iomgr / load_file . h ' , <nl> + ' src / core / lib / iomgr / lockfree_event . h ' , <nl> ' src / core / lib / iomgr / network_status_tracker . h ' , <nl> ' src / core / lib / iomgr / polling_entity . h ' , <nl> ' src / core / lib / iomgr / pollset . h ' , <nl> mmm a / grpc . gemspec <nl> ppp b / grpc . gemspec <nl> Gem : : Specification . new do | s | <nl> s . files + = Dir . glob ( ' include / grpc / * * / * ' ) <nl> s . test_files = Dir . glob ( ' src / ruby / spec / * * / * ' ) <nl> s . bindir = ' src / ruby / bin ' <nl> - s . require_paths = % w ( src / ruby / bin src / ruby / lib src / ruby / pb ) <nl> + s . require_paths = % w ( src / ruby / lib src / ruby / bin src / ruby / pb ) <nl> s . platform = Gem : : Platform : : RUBY <nl> <nl> s . add_dependency ' google - protobuf ' , ' ~ > 3 . 1 ' <nl> Gem : : Specification . new do | s | <nl> s . files + = % w ( src / core / lib / iomgr / iomgr_internal . h ) <nl> s . files + = % w ( src / core / lib / iomgr / iomgr_posix . h ) <nl> s . files + = % w ( src / core / lib / iomgr / load_file . h ) <nl> + s . files + = % w ( src / core / lib / iomgr / lockfree_event . h ) <nl> s . files + = % w ( src / core / lib / iomgr / network_status_tracker . h ) <nl> s . files + = % w ( src / core / lib / iomgr / polling_entity . h ) <nl> s . files + = % w ( src / core / lib / iomgr / pollset . h ) <nl> Gem : : Specification . new do | s | <nl> s . files + = % w ( src / core / lib / iomgr / iomgr_uv . c ) <nl> s . files + = % w ( src / core / lib / iomgr / iomgr_windows . c ) <nl> s . files + = % w ( src / core / lib / iomgr / load_file . c ) <nl> + s . files + = % w ( src / core / lib / iomgr / lockfree_event . c ) <nl> s . files + = % w ( src / core / lib / iomgr / network_status_tracker . c ) <nl> s . files + = % w ( src / core / lib / iomgr / polling_entity . c ) <nl> s . files + = % w ( src / core / lib / iomgr / pollset_set_uv . c ) <nl> mmm a / include / grpc + + / impl / codegen / call . h <nl> ppp b / include / grpc + + / impl / codegen / call . h <nl> class CallHook ; <nl> class CompletionQueue ; <nl> extern CoreCodegenInterface * g_core_codegen_interface ; <nl> <nl> + const char kBinaryErrorDetailsKey [ ] = " grpc - status - details - bin " ; <nl> + <nl> / / TODO ( yangg ) if the map is changed before we send , the pointers will be a <nl> / / mess . Make sure it does not happen . <nl> inline grpc_metadata * FillMetadataArray ( <nl> - const std : : multimap < grpc : : string , grpc : : string > & metadata ) { <nl> - if ( metadata . empty ( ) ) { <nl> + const std : : multimap < grpc : : string , grpc : : string > & metadata , <nl> + size_t * metadata_count , const grpc : : string & optional_error_details ) { <nl> + * metadata_count = metadata . size ( ) + ( optional_error_details . empty ( ) ? 0 : 1 ) ; <nl> + if ( * metadata_count = = 0 ) { <nl> return nullptr ; <nl> } <nl> grpc_metadata * metadata_array = <nl> ( grpc_metadata * ) ( g_core_codegen_interface - > gpr_malloc ( <nl> - metadata . size ( ) * sizeof ( grpc_metadata ) ) ) ; <nl> + ( * metadata_count ) * sizeof ( grpc_metadata ) ) ) ; <nl> size_t i = 0 ; <nl> for ( auto iter = metadata . cbegin ( ) ; iter ! = metadata . cend ( ) ; + + iter , + + i ) { <nl> metadata_array [ i ] . key = SliceReferencingString ( iter - > first ) ; <nl> metadata_array [ i ] . value = SliceReferencingString ( iter - > second ) ; <nl> } <nl> + if ( ! optional_error_details . empty ( ) ) { <nl> + metadata_array [ i ] . key = <nl> + g_core_codegen_interface - > grpc_slice_from_static_buffer ( <nl> + kBinaryErrorDetailsKey , sizeof ( kBinaryErrorDetailsKey ) - 1 ) ; <nl> + metadata_array [ i ] . value = SliceReferencingString ( optional_error_details ) ; <nl> + } <nl> return metadata_array ; <nl> } <nl> <nl> class CallOpSendInitialMetadata { <nl> maybe_compression_level_ . is_set = false ; <nl> send_ = true ; <nl> flags_ = flags ; <nl> - initial_metadata_count_ = metadata . size ( ) ; <nl> - initial_metadata_ = FillMetadataArray ( metadata ) ; <nl> + initial_metadata_ = <nl> + FillMetadataArray ( metadata , & initial_metadata_count_ , " " ) ; <nl> } <nl> <nl> void set_compression_level ( grpc_compression_level level ) { <nl> class CallOpServerSendStatus { <nl> void ServerSendStatus ( <nl> const std : : multimap < grpc : : string , grpc : : string > & trailing_metadata , <nl> const Status & status ) { <nl> - trailing_metadata_count_ = trailing_metadata . size ( ) ; <nl> - trailing_metadata_ = FillMetadataArray ( trailing_metadata ) ; <nl> + send_error_details_ = status . error_details ( ) ; <nl> + trailing_metadata_ = FillMetadataArray ( <nl> + trailing_metadata , & trailing_metadata_count_ , send_error_details_ ) ; <nl> send_status_available_ = true ; <nl> send_status_code_ = static_cast < grpc_status_code > ( GetCanonicalCode ( status ) ) ; <nl> - send_status_details_ = status . error_message ( ) ; <nl> + send_error_message_ = status . error_message ( ) ; <nl> } <nl> <nl> protected : <nl> class CallOpServerSendStatus { <nl> trailing_metadata_count_ ; <nl> op - > data . send_status_from_server . trailing_metadata = trailing_metadata_ ; <nl> op - > data . send_status_from_server . status = send_status_code_ ; <nl> - status_details_slice_ = SliceReferencingString ( send_status_details_ ) ; <nl> + error_message_slice_ = SliceReferencingString ( send_error_message_ ) ; <nl> op - > data . send_status_from_server . status_details = <nl> - send_status_details_ . empty ( ) ? nullptr : & status_details_slice_ ; <nl> + send_error_message_ . empty ( ) ? nullptr : & error_message_slice_ ; <nl> op - > flags = 0 ; <nl> op - > reserved = NULL ; <nl> } <nl> class CallOpServerSendStatus { <nl> private : <nl> bool send_status_available_ ; <nl> grpc_status_code send_status_code_ ; <nl> - grpc : : string send_status_details_ ; <nl> + grpc : : string send_error_details_ ; <nl> + grpc : : string send_error_message_ ; <nl> size_t trailing_metadata_count_ ; <nl> grpc_metadata * trailing_metadata_ ; <nl> - grpc_slice status_details_slice_ ; <nl> + grpc_slice error_message_slice_ ; <nl> } ; <nl> <nl> class CallOpRecvInitialMetadata { <nl> class CallOpClientRecvStatus { <nl> void ClientRecvStatus ( ClientContext * context , Status * status ) { <nl> metadata_map_ = & context - > trailing_metadata_ ; <nl> recv_status_ = status ; <nl> - status_details_ = g_core_codegen_interface - > grpc_empty_slice ( ) ; <nl> + error_message_ = g_core_codegen_interface - > grpc_empty_slice ( ) ; <nl> } <nl> <nl> protected : <nl> class CallOpClientRecvStatus { <nl> op - > op = GRPC_OP_RECV_STATUS_ON_CLIENT ; <nl> op - > data . recv_status_on_client . trailing_metadata = metadata_map_ - > arr ( ) ; <nl> op - > data . recv_status_on_client . status = & status_code_ ; <nl> - op - > data . recv_status_on_client . status_details = & status_details_ ; <nl> + op - > data . recv_status_on_client . status_details = & error_message_ ; <nl> op - > flags = 0 ; <nl> op - > reserved = NULL ; <nl> } <nl> class CallOpClientRecvStatus { <nl> void FinishOp ( bool * status ) { <nl> if ( recv_status_ = = nullptr ) return ; <nl> metadata_map_ - > FillMap ( ) ; <nl> + grpc : : string binary_error_details ; <nl> + auto iter = metadata_map_ - > map ( ) - > find ( kBinaryErrorDetailsKey ) ; <nl> + if ( iter ! = metadata_map_ - > map ( ) - > end ( ) ) { <nl> + binary_error_details = <nl> + grpc : : string ( iter - > second . begin ( ) , iter - > second . length ( ) ) ; <nl> + } <nl> * recv_status_ = Status ( static_cast < StatusCode > ( status_code_ ) , <nl> - grpc : : string ( GRPC_SLICE_START_PTR ( status_details_ ) , <nl> - GRPC_SLICE_END_PTR ( status_details_ ) ) ) ; <nl> - g_core_codegen_interface - > grpc_slice_unref ( status_details_ ) ; <nl> + grpc : : string ( GRPC_SLICE_START_PTR ( error_message_ ) , <nl> + GRPC_SLICE_END_PTR ( error_message_ ) ) , <nl> + binary_error_details ) ; <nl> + g_core_codegen_interface - > grpc_slice_unref ( error_message_ ) ; <nl> recv_status_ = nullptr ; <nl> } <nl> <nl> class CallOpClientRecvStatus { <nl> MetadataMap * metadata_map_ ; <nl> Status * recv_status_ ; <nl> grpc_status_code status_code_ ; <nl> - grpc_slice status_details_ ; <nl> + grpc_slice error_message_ ; <nl> } ; <nl> <nl> / / / An abstract collection of call ops , used to generate the <nl> mmm a / include / grpc + + / impl / codegen / status . h <nl> ppp b / include / grpc + + / impl / codegen / status . h <nl> class Status { <nl> / / / Construct an OK instance . <nl> Status ( ) : code_ ( StatusCode : : OK ) { } <nl> <nl> - / / / Construct an instance with associated \ a code and \ a details ( also <nl> - / / referred to as " error_message " ) . <nl> - Status ( StatusCode code , const grpc : : string & details ) <nl> - : code_ ( code ) , details_ ( details ) { } <nl> + / / / Construct an instance with associated \ a code and \ a error_message <nl> + Status ( StatusCode code , const grpc : : string & error_message ) <nl> + : code_ ( code ) , error_message_ ( error_message ) { } <nl> + <nl> + / / / Construct an instance with \ a code , \ a error_message and \ a error_details <nl> + Status ( StatusCode code , const grpc : : string & error_message , <nl> + const grpc : : string error_details ) <nl> + : code_ ( code ) , <nl> + error_message_ ( error_message ) , <nl> + binary_error_details_ ( error_details ) { } <nl> <nl> / / Pre - defined special status objects . <nl> / / / An OK pre - defined instance . <nl> class Status { <nl> / / / Return the instance ' s error code . <nl> StatusCode error_code ( ) const { return code_ ; } <nl> / / / Return the instance ' s error message . <nl> - grpc : : string error_message ( ) const { return details_ ; } <nl> + grpc : : string error_message ( ) const { return error_message_ ; } <nl> + / / / Return the ( binary ) error details . <nl> + / / Usually it contains a serialized google . rpc . Status proto . <nl> + grpc : : string error_details ( ) const { return binary_error_details_ ; } <nl> <nl> / / / Is the status OK ? <nl> bool ok ( ) const { return code_ = = StatusCode : : OK ; } <nl> <nl> private : <nl> StatusCode code_ ; <nl> - grpc : : string details_ ; <nl> + grpc : : string error_message_ ; <nl> + grpc : : string binary_error_details_ ; <nl> } ; <nl> <nl> } / / namespace grpc <nl> mmm a / include / grpc / impl / codegen / atm_windows . h <nl> ppp b / include / grpc / impl / codegen / atm_windows . h <nl> static __inline int gpr_atm_rel_cas ( gpr_atm * p , gpr_atm o , gpr_atm n ) { <nl> # endif <nl> } <nl> <nl> + static __inline int gpr_atm_full_cas ( gpr_atm * p , gpr_atm o , gpr_atm n ) { <nl> + # ifdef GPR_ARCH_64 <nl> + return o = = ( gpr_atm ) InterlockedCompareExchange64 ( ( volatile LONGLONG * ) p , <nl> + ( LONGLONG ) n , ( LONGLONG ) o ) ; <nl> + # else <nl> + return o = = ( gpr_atm ) InterlockedCompareExchange ( ( volatile LONG * ) p , ( LONG ) n , <nl> + ( LONG ) o ) ; <nl> + # endif <nl> + } <nl> + <nl> static __inline gpr_atm gpr_atm_no_barrier_fetch_add ( gpr_atm * p , <nl> gpr_atm delta ) { <nl> / * Use the CAS operation to get pointer - sized fetch and add * / <nl> mmm a / include / grpc / impl / codegen / grpc_types . h <nl> ppp b / include / grpc / impl / codegen / grpc_types . h <nl> typedef struct { <nl> * possible . * / <nl> # define GRPC_ARG_USE_CRONET_PACKET_COALESCING \ <nl> " grpc . use_cronet_packet_coalescing " <nl> + / * Channel arg ( integer ) setting how large a slice to try and read from the wire <nl> + each time recvmsg ( or equivalent ) is called * / <nl> + # define GRPC_ARG_TCP_READ_CHUNK_SIZE " grpc . experimental . tcp_read_chunk_size " <nl> + # define GRPC_TCP_DEFAULT_READ_SLICE_SIZE 8192 <nl> + # define GRPC_ARG_TCP_MIN_READ_CHUNK_SIZE \ <nl> + " grpc . experimental . tcp_min_read_chunk_size " <nl> + # define GRPC_ARG_TCP_MAX_READ_CHUNK_SIZE \ <nl> + " grpc . experimental . tcp_max_read_chunk_size " <nl> / * * \ } * / <nl> <nl> / * * Result of a grpc call . If the caller satisfies the prerequisites of a <nl> mmm a / include / grpc / impl / codegen / port_platform . h <nl> ppp b / include / grpc / impl / codegen / port_platform . h <nl> <nl> # define GPR_GETPID_IN_UNISTD_H 1 <nl> # define GPR_SUPPORT_CHANNELS_FROM_FD 1 <nl> # elif defined ( __linux__ ) <nl> - # define GPR_POSIX_CRASH_HANDLER 1 <nl> # define GPR_PLATFORM_STRING " linux " <nl> # ifndef _BSD_SOURCE <nl> # define _BSD_SOURCE <nl> <nl> # else / * _LP64 * / <nl> # define GPR_ARCH_32 1 <nl> # endif / * _LP64 * / <nl> + # ifdef __GLIBC__ <nl> + # define GPR_POSIX_CRASH_HANDLER 1 <nl> + # else / * musl libc * / <nl> + # define GRPC_MSG_IOVLEN_TYPE int <nl> + # endif <nl> # elif defined ( __APPLE__ ) <nl> # include < Availability . h > <nl> # include < TargetConditionals . h > <nl> mmm a / package . json <nl> ppp b / package . json <nl> <nl> " lodash " : " ^ 4 . 15 . 0 " , <nl> " nan " : " ^ 2 . 0 . 0 " , <nl> " node - pre - gyp " : " ^ 0 . 6 . 0 " , <nl> - " protobufjs " : " ^ 5 . 0 . 0 " , <nl> + " protobufjs " : " ^ 6 . 7 . 0 " , <nl> " cares " : " ^ 1 . 1 . 5 " <nl> } , <nl> " devDependencies " : { <nl> mmm a / package . xml <nl> ppp b / package . xml <nl> <nl> < file baseinstalldir = " / " name = " src / core / lib / iomgr / iomgr_internal . h " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / lib / iomgr / iomgr_posix . h " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / lib / iomgr / load_file . h " role = " src " / > <nl> + < file baseinstalldir = " / " name = " src / core / lib / iomgr / lockfree_event . h " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / lib / iomgr / network_status_tracker . h " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / lib / iomgr / polling_entity . h " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / lib / iomgr / pollset . h " role = " src " / > <nl> <nl> < file baseinstalldir = " / " name = " src / core / lib / iomgr / iomgr_uv . c " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / lib / iomgr / iomgr_windows . c " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / lib / iomgr / load_file . c " role = " src " / > <nl> + < file baseinstalldir = " / " name = " src / core / lib / iomgr / lockfree_event . c " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / lib / iomgr / network_status_tracker . c " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / lib / iomgr / polling_entity . c " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / lib / iomgr / pollset_set_uv . c " role = " src " / > <nl> mmm a / src / core / ext / census / grpc_plugin . c <nl> ppp b / src / core / ext / census / grpc_plugin . c <nl> <nl> * <nl> * / <nl> <nl> + # include < grpc / support / port_platform . h > <nl> + <nl> # include < limits . h > <nl> # include < string . h > <nl> <nl> mmm a / src / core / ext / filters / client_channel / client_channel . c <nl> ppp b / src / core / ext / filters / client_channel / client_channel . c <nl> static void subchannel_ready_locked ( grpc_exec_ctx * exec_ctx , void * arg , <nl> . arena = calld - > arena } ; <nl> grpc_error * new_error = grpc_connected_subchannel_create_call ( <nl> exec_ctx , calld - > connected_subchannel , & call_args , & subchannel_call ) ; <nl> + gpr_atm_rel_store ( & calld - > subchannel_call , <nl> + ( gpr_atm ) ( uintptr_t ) subchannel_call ) ; <nl> if ( new_error ! = GRPC_ERROR_NONE ) { <nl> new_error = grpc_error_add_child ( new_error , error ) ; <nl> - subchannel_call = CANCELLED_CALL ; <nl> fail_locked ( exec_ctx , calld , new_error ) ; <nl> + } else { <nl> + retry_waiting_locked ( exec_ctx , calld ) ; <nl> } <nl> - gpr_atm_rel_store ( & calld - > subchannel_call , <nl> - ( gpr_atm ) ( uintptr_t ) subchannel_call ) ; <nl> - retry_waiting_locked ( exec_ctx , calld ) ; <nl> } <nl> GRPC_CALL_STACK_UNREF ( exec_ctx , calld - > owning_call , " pick_subchannel " ) ; <nl> } <nl> static void start_transport_stream_op_batch_locked_inner ( <nl> . arena = calld - > arena } ; <nl> grpc_error * error = grpc_connected_subchannel_create_call ( <nl> exec_ctx , calld - > connected_subchannel , & call_args , & subchannel_call ) ; <nl> + gpr_atm_rel_store ( & calld - > subchannel_call , <nl> + ( gpr_atm ) ( uintptr_t ) subchannel_call ) ; <nl> if ( error ! = GRPC_ERROR_NONE ) { <nl> - subchannel_call = CANCELLED_CALL ; <nl> fail_locked ( exec_ctx , calld , GRPC_ERROR_REF ( error ) ) ; <nl> grpc_transport_stream_op_batch_finish_with_failure ( exec_ctx , op , error ) ; <nl> + } else { <nl> + retry_waiting_locked ( exec_ctx , calld ) ; <nl> + / * recurse to retry * / <nl> + start_transport_stream_op_batch_locked_inner ( exec_ctx , op , elem ) ; <nl> } <nl> - gpr_atm_rel_store ( & calld - > subchannel_call , <nl> - ( gpr_atm ) ( uintptr_t ) subchannel_call ) ; <nl> - retry_waiting_locked ( exec_ctx , calld ) ; <nl> - / * recurse to retry * / <nl> - start_transport_stream_op_batch_locked_inner ( exec_ctx , op , elem ) ; <nl> / * early out * / <nl> return ; <nl> } <nl> mmm a / src / core / ext / filters / client_channel / client_channel_plugin . c <nl> ppp b / src / core / ext / filters / client_channel / client_channel_plugin . c <nl> <nl> * <nl> * / <nl> <nl> + # include < grpc / support / port_platform . h > <nl> + <nl> # include < limits . h > <nl> # include < stdbool . h > <nl> # include < string . h > <nl> mmm a / src / core / ext / filters / client_channel / subchannel . c <nl> ppp b / src / core / ext / filters / client_channel / subchannel . c <nl> grpc_error * grpc_connected_subchannel_create_call ( <nl> * call = gpr_arena_alloc ( <nl> args - > arena , sizeof ( grpc_subchannel_call ) + chanstk - > call_stack_size ) ; <nl> grpc_call_stack * callstk = SUBCHANNEL_CALL_TO_CALL_STACK ( * call ) ; <nl> - ( * call ) - > connection = con ; / / Ref is added below . <nl> + ( * call ) - > connection = GRPC_CONNECTED_SUBCHANNEL_REF ( con , " subchannel_call " ) ; <nl> const grpc_call_element_args call_args = { . call_stack = callstk , <nl> . server_transport_data = NULL , <nl> . context = NULL , <nl> grpc_error * grpc_connected_subchannel_create_call ( <nl> gpr_log ( GPR_ERROR , " error : % s " , error_string ) ; <nl> return error ; <nl> } <nl> - GRPC_CONNECTED_SUBCHANNEL_REF ( con , " subchannel_call " ) ; <nl> grpc_call_stack_set_pollset_or_pollset_set ( exec_ctx , callstk , args - > pollent ) ; <nl> return GRPC_ERROR_NONE ; <nl> } <nl> mmm a / src / core / ext / filters / load_reporting / load_reporting . c <nl> ppp b / src / core / ext / filters / load_reporting / load_reporting . c <nl> <nl> * <nl> * / <nl> <nl> + # include < grpc / support / port_platform . h > <nl> + <nl> # include < limits . h > <nl> # include < string . h > <nl> <nl> mmm a / src / core / ext / filters / max_age / max_age_filter . c <nl> ppp b / src / core / ext / filters / max_age / max_age_filter . c <nl> <nl> * <nl> * / <nl> <nl> - # include " src / core / lib / channel / message_size_filter . h " <nl> + # include " src / core / ext / filters / max_age / max_age_filter . h " <nl> <nl> # include < limits . h > <nl> # include < string . h > <nl> <nl> # include " src / core / lib / iomgr / timer . h " <nl> # include " src / core / lib / surface / channel_init . h " <nl> # include " src / core / lib / transport / http2_errors . h " <nl> - # include " src / core / lib / transport / service_config . h " <nl> <nl> # define DEFAULT_MAX_CONNECTION_AGE_MS INT_MAX <nl> # define DEFAULT_MAX_CONNECTION_AGE_GRACE_MS INT_MAX <nl> static void start_max_age_grace_timer_after_goaway_op ( grpc_exec_ctx * exec_ctx , <nl> static void close_max_idle_channel ( grpc_exec_ctx * exec_ctx , void * arg , <nl> grpc_error * error ) { <nl> channel_data * chand = arg ; <nl> - gpr_atm_no_barrier_fetch_add ( & chand - > call_count , 1 ) ; <nl> if ( error = = GRPC_ERROR_NONE ) { <nl> + / * Prevent the max idle timer from being set again * / <nl> + gpr_atm_no_barrier_fetch_add ( & chand - > call_count , 1 ) ; <nl> grpc_transport_op * op = grpc_make_transport_op ( NULL ) ; <nl> op - > goaway_error = <nl> grpc_error_set_int ( GRPC_ERROR_CREATE_FROM_STATIC_STRING ( " max_idle " ) , <nl> mmm a / src / core / ext / transport / chttp2 / server / insecure / server_chttp2_posix . c <nl> ppp b / src / core / ext / transport / chttp2 / server / insecure / server_chttp2_posix . c <nl> void grpc_server_add_insecure_channel_from_fd ( grpc_server * server , <nl> char * name ; <nl> gpr_asprintf ( & name , " fd : % d " , fd ) ; <nl> <nl> - grpc_resource_quota * resource_quota = grpc_resource_quota_from_channel_args ( <nl> - grpc_server_get_channel_args ( server ) ) ; <nl> grpc_endpoint * server_endpoint = <nl> - grpc_tcp_create ( grpc_fd_create ( fd , name ) , resource_quota , <nl> - GRPC_TCP_DEFAULT_READ_SLICE_SIZE , name ) ; <nl> - grpc_resource_quota_unref_internal ( & exec_ctx , resource_quota ) ; <nl> + grpc_tcp_create ( & exec_ctx , grpc_fd_create ( fd , name ) , <nl> + grpc_server_get_channel_args ( server ) , name ) ; <nl> <nl> gpr_free ( name ) ; <nl> <nl> mmm a / src / core / lib / http / httpcli_security_connector . c <nl> ppp b / src / core / lib / http / httpcli_security_connector . c <nl> <nl> <nl> typedef struct { <nl> grpc_channel_security_connector base ; <nl> - tsi_ssl_handshaker_factory * handshaker_factory ; <nl> + tsi_ssl_client_handshaker_factory * handshaker_factory ; <nl> char * secure_peer_name ; <nl> } grpc_httpcli_ssl_channel_security_connector ; <nl> <nl> static void httpcli_ssl_destroy ( grpc_exec_ctx * exec_ctx , <nl> grpc_httpcli_ssl_channel_security_connector * c = <nl> ( grpc_httpcli_ssl_channel_security_connector * ) sc ; <nl> if ( c - > handshaker_factory ! = NULL ) { <nl> - tsi_ssl_handshaker_factory_destroy ( c - > handshaker_factory ) ; <nl> + tsi_ssl_client_handshaker_factory_destroy ( c - > handshaker_factory ) ; <nl> } <nl> if ( c - > secure_peer_name ! = NULL ) gpr_free ( c - > secure_peer_name ) ; <nl> gpr_free ( sc ) ; <nl> static void httpcli_ssl_add_handshakers ( grpc_exec_ctx * exec_ctx , <nl> ( grpc_httpcli_ssl_channel_security_connector * ) sc ; <nl> tsi_handshaker * handshaker = NULL ; <nl> if ( c - > handshaker_factory ! = NULL ) { <nl> - tsi_result result = tsi_ssl_handshaker_factory_create_handshaker ( <nl> + tsi_result result = tsi_ssl_client_handshaker_factory_create_handshaker ( <nl> c - > handshaker_factory , c - > secure_peer_name , & handshaker ) ; <nl> if ( result ! = TSI_OK ) { <nl> gpr_log ( GPR_ERROR , " Handshaker creation failed with error % s . " , <nl> mmm a / src / core / lib / iomgr / endpoint_pair . h <nl> ppp b / src / core / lib / iomgr / endpoint_pair . h <nl> typedef struct { <nl> grpc_endpoint * server ; <nl> } grpc_endpoint_pair ; <nl> <nl> - grpc_endpoint_pair grpc_iomgr_create_endpoint_pair ( <nl> - const char * name , grpc_resource_quota * resource_quota , <nl> - size_t read_slice_size ) ; <nl> + grpc_endpoint_pair grpc_iomgr_create_endpoint_pair ( const char * name , <nl> + grpc_channel_args * args ) ; <nl> <nl> # endif / * GRPC_CORE_LIB_IOMGR_ENDPOINT_PAIR_H * / <nl> mmm a / src / core / lib / iomgr / endpoint_pair_posix . c <nl> ppp b / src / core / lib / iomgr / endpoint_pair_posix . c <nl> static void create_sockets ( int sv [ 2 ] ) { <nl> GPR_ASSERT ( grpc_set_socket_no_sigpipe_if_possible ( sv [ 1 ] ) = = GRPC_ERROR_NONE ) ; <nl> } <nl> <nl> - grpc_endpoint_pair grpc_iomgr_create_endpoint_pair ( <nl> - const char * name , grpc_resource_quota * resource_quota , <nl> - size_t read_slice_size ) { <nl> + grpc_endpoint_pair grpc_iomgr_create_endpoint_pair ( const char * name , <nl> + grpc_channel_args * args ) { <nl> int sv [ 2 ] ; <nl> grpc_endpoint_pair p ; <nl> char * final_name ; <nl> create_sockets ( sv ) ; <nl> <nl> + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT ; <nl> + <nl> gpr_asprintf ( & final_name , " % s : client " , name ) ; <nl> - p . client = grpc_tcp_create ( grpc_fd_create ( sv [ 1 ] , final_name ) , resource_quota , <nl> - read_slice_size , " socketpair - server " ) ; <nl> + p . client = grpc_tcp_create ( & exec_ctx , grpc_fd_create ( sv [ 1 ] , final_name ) , args , <nl> + " socketpair - server " ) ; <nl> gpr_free ( final_name ) ; <nl> gpr_asprintf ( & final_name , " % s : server " , name ) ; <nl> - p . server = grpc_tcp_create ( grpc_fd_create ( sv [ 0 ] , final_name ) , resource_quota , <nl> - read_slice_size , " socketpair - client " ) ; <nl> + p . server = grpc_tcp_create ( & exec_ctx , grpc_fd_create ( sv [ 0 ] , final_name ) , args , <nl> + " socketpair - client " ) ; <nl> gpr_free ( final_name ) ; <nl> + <nl> + grpc_exec_ctx_finish ( & exec_ctx ) ; <nl> return p ; <nl> } <nl> <nl> mmm a / src / core / lib / iomgr / endpoint_pair_uv . c <nl> ppp b / src / core / lib / iomgr / endpoint_pair_uv . c <nl> <nl> <nl> # include " src / core / lib / iomgr / endpoint_pair . h " <nl> <nl> - grpc_endpoint_pair grpc_iomgr_create_endpoint_pair ( <nl> - const char * name , grpc_resource_quota * resource_quota , <nl> - size_t read_slice_size ) { <nl> + grpc_endpoint_pair grpc_iomgr_create_endpoint_pair ( const char * name , <nl> + grpc_channel_args * args ) { <nl> grpc_endpoint_pair endpoint_pair ; <nl> / / TODO ( mlumish ) : implement this properly under libuv <nl> GPR_ASSERT ( false & & <nl> mmm a / src / core / lib / iomgr / endpoint_pair_windows . c <nl> ppp b / src / core / lib / iomgr / endpoint_pair_windows . c <nl> static void create_sockets ( SOCKET sv [ 2 ] ) { <nl> } <nl> <nl> grpc_endpoint_pair grpc_iomgr_create_endpoint_pair ( <nl> - const char * name , grpc_resource_quota * resource_quota , <nl> - size_t read_slice_size ) { <nl> + const char * name , grpc_channel_args * channel_args ) { <nl> SOCKET sv [ 2 ] ; <nl> grpc_endpoint_pair p ; <nl> create_sockets ( sv ) ; <nl> - p . client = grpc_tcp_create ( grpc_winsocket_create ( sv [ 1 ] , " endpoint : client " ) , <nl> - resource_quota , " endpoint : server " ) ; <nl> - p . server = grpc_tcp_create ( grpc_winsocket_create ( sv [ 0 ] , " endpoint : server " ) , <nl> - resource_quota , " endpoint : client " ) ; <nl> + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT ; <nl> + p . client = grpc_tcp_create ( & exec_ctx , <nl> + grpc_winsocket_create ( sv [ 1 ] , " endpoint : client " ) , <nl> + channel_args , " endpoint : server " ) ; <nl> + p . server = grpc_tcp_create ( & exec_ctx , <nl> + grpc_winsocket_create ( sv [ 0 ] , " endpoint : server " ) , <nl> + channel_args , " endpoint : client " ) ; <nl> + grpc_exec_ctx_finish ( & exec_ctx ) ; <nl> return p ; <nl> } <nl> <nl> mmm a / src / core / lib / iomgr / error . c <nl> ppp b / src / core / lib / iomgr / error . c <nl> static uint8_t get_placement ( grpc_error * * err , size_t size ) { <nl> GPR_ASSERT ( * err ) ; <nl> uint8_t slots = ( uint8_t ) ( size / sizeof ( intptr_t ) ) ; <nl> if ( ( * err ) - > arena_size + slots > ( * err ) - > arena_capacity ) { <nl> - ( * err ) - > arena_capacity = ( uint8_t ) ( 3 * ( * err ) - > arena_capacity / 2 ) ; <nl> + ( * err ) - > arena_capacity = <nl> + ( uint8_t ) GPR_MIN ( UINT8_MAX - 1 , ( 3 * ( * err ) - > arena_capacity / 2 ) ) ; <nl> + if ( ( * err ) - > arena_size + slots > ( * err ) - > arena_capacity ) { <nl> + return UINT8_MAX ; <nl> + } <nl> * err = gpr_realloc ( <nl> * err , sizeof ( grpc_error ) + ( * err ) - > arena_capacity * sizeof ( intptr_t ) ) ; <nl> } <nl> static uint8_t get_placement ( grpc_error * * err , size_t size ) { <nl> <nl> static void internal_set_int ( grpc_error * * err , grpc_error_ints which , <nl> intptr_t value ) { <nl> - / / GPR_ASSERT ( ( * err ) - > ints [ which ] = = UINT8_MAX ) ; / / TODO , enforce this <nl> uint8_t slot = ( * err ) - > ints [ which ] ; <nl> if ( slot = = UINT8_MAX ) { <nl> slot = get_placement ( err , sizeof ( value ) ) ; <nl> + if ( slot = = UINT8_MAX ) { <nl> + gpr_log ( GPR_ERROR , " Error % p is full , dropping int { \ " % s \ " : % " PRIiPTR " } " , <nl> + * err , error_int_name ( which ) , value ) ; <nl> + return ; <nl> + } <nl> } <nl> ( * err ) - > ints [ which ] = slot ; <nl> ( * err ) - > arena [ slot ] = value ; <nl> static void internal_set_int ( grpc_error * * err , grpc_error_ints which , <nl> <nl> static void internal_set_str ( grpc_error * * err , grpc_error_strs which , <nl> grpc_slice value ) { <nl> - / / GPR_ASSERT ( ( * err ) - > strs [ which ] = = UINT8_MAX ) ; / / TODO , enforce this <nl> uint8_t slot = ( * err ) - > strs [ which ] ; <nl> if ( slot = = UINT8_MAX ) { <nl> slot = get_placement ( err , sizeof ( value ) ) ; <nl> + if ( slot = = UINT8_MAX ) { <nl> + const char * str = grpc_slice_to_c_string ( value ) ; <nl> + gpr_log ( GPR_ERROR , " Error % p is full , dropping string { \ " % s \ " : \ " % s \ " } " , <nl> + * err , error_str_name ( which ) , str ) ; <nl> + gpr_free ( ( void * ) str ) ; <nl> + return ; <nl> + } <nl> } else { <nl> unref_slice ( * ( grpc_slice * ) ( ( * err ) - > arena + slot ) ) ; <nl> } <nl> static void internal_set_str ( grpc_error * * err , grpc_error_strs which , <nl> memcpy ( ( * err ) - > arena + slot , & value , sizeof ( value ) ) ; <nl> } <nl> <nl> + static char * fmt_time ( gpr_timespec tm ) ; <nl> static void internal_set_time ( grpc_error * * err , grpc_error_times which , <nl> gpr_timespec value ) { <nl> - / / GPR_ASSERT ( ( * err ) - > times [ which ] = = UINT8_MAX ) ; / / TODO , enforce this <nl> uint8_t slot = ( * err ) - > times [ which ] ; <nl> if ( slot = = UINT8_MAX ) { <nl> slot = get_placement ( err , sizeof ( value ) ) ; <nl> + if ( slot = = UINT8_MAX ) { <nl> + const char * time_str = fmt_time ( value ) ; <nl> + gpr_log ( GPR_ERROR , " Error % p is full , dropping \ " % s \ " : \ " % s \ " } " , * err , <nl> + error_time_name ( which ) , time_str ) ; <nl> + gpr_free ( ( void * ) time_str ) ; <nl> + return ; <nl> + } <nl> } <nl> ( * err ) - > times [ which ] = slot ; <nl> memcpy ( ( * err ) - > arena + slot , & value , sizeof ( value ) ) ; <nl> static void internal_set_time ( grpc_error * * err , grpc_error_times which , <nl> static void internal_add_error ( grpc_error * * err , grpc_error * new ) { <nl> grpc_linked_error new_last = { new , UINT8_MAX } ; <nl> uint8_t slot = get_placement ( err , sizeof ( grpc_linked_error ) ) ; <nl> + if ( slot = = UINT8_MAX ) { <nl> + gpr_log ( GPR_ERROR , " Error % p is full , dropping error % p = % s " , * err , new , <nl> + grpc_error_string ( new ) ) ; <nl> + GRPC_ERROR_UNREF ( new ) ; <nl> + return ; <nl> + } <nl> if ( ( * err ) - > first_err = = UINT8_MAX ) { <nl> GPR_ASSERT ( ( * err ) - > last_err = = UINT8_MAX ) ; <nl> ( * err ) - > last_err = slot ; <nl> mmm a / src / core / lib / iomgr / ev_epoll_linux . c <nl> ppp b / src / core / lib / iomgr / ev_epoll_linux . c <nl> <nl> <nl> # include " src / core / lib / iomgr / ev_posix . h " <nl> # include " src / core / lib / iomgr / iomgr_internal . h " <nl> + # include " src / core / lib / iomgr / lockfree_event . h " <nl> # include " src / core / lib / iomgr / timer . h " <nl> # include " src / core / lib / iomgr / wakeup_fd_posix . h " <nl> # include " src / core / lib / iomgr / workqueue . h " <nl> struct grpc_fd { <nl> Ref / Unref by two to avoid altering the orphaned bit * / <nl> gpr_atm refst ; <nl> <nl> - / * Internally stores data of type ( grpc_error * ) . If the FD is shutdown , this <nl> - contains reason for shutdown ( i . e a pointer to grpc_error ) ORed with <nl> - FD_SHUTDOWN_BIT . Since address allocations are word - aligned , the lower bit <nl> - of ( grpc_error * ) addresses is guaranteed to be zero . Even if the <nl> - ( grpc_error * ) , is of special types like GRPC_ERROR_NONE , GRPC_ERROR_OOM <nl> - etc , the lower bit is guaranteed to be zero . <nl> - <nl> - Once an fd is shutdown , any pending or future read / write closures on the <nl> - fd should fail * / <nl> - gpr_atm shutdown_error ; <nl> - <nl> / * The fd is either closed or we relinquished control of it . In either <nl> cases , this indicates that the ' fd ' on this structure is no longer <nl> valid * / <nl> bool orphaned ; <nl> <nl> - / * Closures to call when the fd is readable or writable respectively . These <nl> - fields contain one of the following values : <nl> - CLOSURE_READY : The fd has an I / O event of interest but there is no <nl> - closure yet to execute <nl> - <nl> - CLOSURE_NOT_READY : The fd has no I / O event of interest <nl> - <nl> - closure ptr : The closure to be executed when the fd has an I / O <nl> - event of interest <nl> - <nl> - shutdown_error | FD_SHUTDOWN_BIT : <nl> - ' shutdown_error ' field ORed with FD_SHUTDOWN_BIT . <nl> - This indicates that the fd is shutdown . Since all <nl> - memory allocations are word - aligned , the lower two <nl> - bits of the shutdown_error pointer are always 0 . So <nl> - it is safe to OR these with FD_SHUTDOWN_BIT <nl> - <nl> - Valid state transitions : <nl> - <nl> - < closure ptr > < mmm - - 3mmmmmm CLOSURE_NOT_READY mmm - 1mmm - > CLOSURE_READY <nl> - | | ^ | ^ | | <nl> - | | | | | | | <nl> - | + mmmmmmmmmmmm - - 4mmmmmmmmm - + 6 + mmmmmmmmm2mmmmmmmmmmmmmmm + | <nl> - | | | <nl> - | v | <nl> - + mmm - - 5mmmmmm - > [ shutdown_error | FD_SHUTDOWN_BIT ] < mmm - 7mmmmmmmmm + <nl> - <nl> - For 1 , 4 : See set_ready ( ) function <nl> - For 2 , 3 : See notify_on ( ) function <nl> - For 5 , 6 , 7 : See set_shutdown ( ) function * / <nl> gpr_atm read_closure ; <nl> gpr_atm write_closure ; <nl> <nl> static void fd_unref ( grpc_fd * fd ) ; <nl> static void fd_global_init ( void ) ; <nl> static void fd_global_shutdown ( void ) ; <nl> <nl> - # define CLOSURE_NOT_READY ( ( gpr_atm ) 0 ) <nl> - # define CLOSURE_READY ( ( gpr_atm ) 2 ) <nl> - <nl> - # define FD_SHUTDOWN_BIT 1 <nl> - <nl> / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> * Polling island Declarations <nl> * / <nl> static void unref_by ( grpc_fd * fd , int n ) { <nl> fd_freelist = fd ; <nl> grpc_iomgr_unregister_object ( & fd - > iomgr_object ) ; <nl> <nl> - grpc_error * err = ( grpc_error * ) gpr_atm_acq_load ( & fd - > shutdown_error ) ; <nl> - / * Clear the least significant bit if it set ( in case fd was shutdown ) * / <nl> - err = ( grpc_error * ) ( ( intptr_t ) err & ~ FD_SHUTDOWN_BIT ) ; <nl> - GRPC_ERROR_UNREF ( err ) ; <nl> + grpc_lfev_destroy ( & fd - > read_closure ) ; <nl> + grpc_lfev_destroy ( & fd - > write_closure ) ; <nl> <nl> gpr_mu_unlock ( & fd_freelist_mu ) ; <nl> } else { <nl> static grpc_fd * fd_create ( int fd , const char * name ) { <nl> <nl> gpr_atm_rel_store ( & new_fd - > refst , ( gpr_atm ) 1 ) ; <nl> new_fd - > fd = fd ; <nl> - gpr_atm_no_barrier_store ( & new_fd - > shutdown_error , ( gpr_atm ) GRPC_ERROR_NONE ) ; <nl> new_fd - > orphaned = false ; <nl> - gpr_atm_no_barrier_store ( & new_fd - > read_closure , CLOSURE_NOT_READY ) ; <nl> - gpr_atm_no_barrier_store ( & new_fd - > write_closure , CLOSURE_NOT_READY ) ; <nl> + grpc_lfev_init ( & new_fd - > read_closure ) ; <nl> + grpc_lfev_init ( & new_fd - > write_closure ) ; <nl> gpr_atm_no_barrier_store ( & new_fd - > read_notifier_pollset , ( gpr_atm ) NULL ) ; <nl> <nl> new_fd - > freelist_next = NULL ; <nl> static void fd_orphan ( grpc_exec_ctx * exec_ctx , grpc_fd * fd , <nl> GRPC_ERROR_UNREF ( error ) ; <nl> } <nl> <nl> - static void notify_on ( grpc_exec_ctx * exec_ctx , grpc_fd * fd , gpr_atm * state , <nl> - grpc_closure * closure ) { <nl> - while ( true ) { <nl> - gpr_atm curr = gpr_atm_no_barrier_load ( state ) ; <nl> - switch ( curr ) { <nl> - case CLOSURE_NOT_READY : { <nl> - / * CLOSURE_NOT_READY - > < closure > . <nl> - <nl> - We ' re guaranteed by API that there ' s an acquire barrier before here , <nl> - so there ' s no need to double - dip and this can be a release - only . <nl> - <nl> - The release itself pairs with the acquire half of a set_ready full <nl> - barrier . * / <nl> - if ( gpr_atm_rel_cas ( state , CLOSURE_NOT_READY , ( gpr_atm ) closure ) ) { <nl> - return ; / * Successful . Return * / <nl> - } <nl> - <nl> - break ; / * retry * / <nl> - } <nl> - <nl> - case CLOSURE_READY : { <nl> - / * Change the state to CLOSURE_NOT_READY . Schedule the closure if <nl> - successful . If not , the state most likely transitioned to shutdown . <nl> - We should retry . <nl> - <nl> - This can be a no - barrier cas since the state is being transitioned to <nl> - CLOSURE_NOT_READY ; set_ready and set_shutdown do not schedule any <nl> - closure when transitioning out of CLOSURE_NO_READY state ( i . e there <nl> - is no other code that needs to ' happen - after ' this ) * / <nl> - if ( gpr_atm_no_barrier_cas ( state , CLOSURE_READY , CLOSURE_NOT_READY ) ) { <nl> - grpc_closure_sched ( exec_ctx , closure , GRPC_ERROR_NONE ) ; <nl> - return ; / * Successful . Return * / <nl> - } <nl> - <nl> - break ; / * retry * / <nl> - } <nl> - <nl> - default : { <nl> - / * ' curr ' is either a closure or the fd is shutdown ( in which case ' curr ' <nl> - contains a pointer to the shutdown - error ) . If the fd is shutdown , <nl> - schedule the closure with the shutdown error * / <nl> - if ( ( curr & FD_SHUTDOWN_BIT ) > 0 ) { <nl> - grpc_error * shutdown_err = ( grpc_error * ) ( curr & ~ FD_SHUTDOWN_BIT ) ; <nl> - grpc_closure_sched ( exec_ctx , closure , <nl> - GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING ( <nl> - " FD Shutdown " , & shutdown_err , 1 ) ) ; <nl> - return ; <nl> - } <nl> - <nl> - / * There is already a closure ! . This indicates a bug in the code * / <nl> - gpr_log ( GPR_ERROR , <nl> - " notify_on called with a previous callback still pending " ) ; <nl> - abort ( ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - GPR_UNREACHABLE_CODE ( return ) ; <nl> - } <nl> - <nl> - static void set_shutdown ( grpc_exec_ctx * exec_ctx , grpc_fd * fd , gpr_atm * state , <nl> - grpc_error * shutdown_err ) { <nl> - gpr_atm new_state = ( gpr_atm ) shutdown_err | FD_SHUTDOWN_BIT ; <nl> - <nl> - while ( true ) { <nl> - gpr_atm curr = gpr_atm_no_barrier_load ( state ) ; <nl> - switch ( curr ) { <nl> - case CLOSURE_READY : <nl> - case CLOSURE_NOT_READY : <nl> - / * Need a full barrier here so that the initial load in notify_on <nl> - doesn ' t need a barrier * / <nl> - if ( gpr_atm_full_cas ( state , curr , new_state ) ) { <nl> - return ; / * early out * / <nl> - } <nl> - break ; / * retry * / <nl> - <nl> - default : { <nl> - / * ' curr ' is either a closure or the fd is already shutdown * / <nl> - <nl> - / * If fd is already shutdown , we are done * / <nl> - if ( ( curr & FD_SHUTDOWN_BIT ) > 0 ) { <nl> - return ; <nl> - } <nl> - <nl> - / * Fd is not shutdown . Schedule the closure and move the state to <nl> - shutdown state . <nl> - Needs an acquire to pair with setting the closure ( and get a <nl> - happens - after on that edge ) , and a release to pair with anything <nl> - loading the shutdown state . * / <nl> - if ( gpr_atm_full_cas ( state , curr , new_state ) ) { <nl> - grpc_closure_sched ( exec_ctx , ( grpc_closure * ) curr , <nl> - GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING ( <nl> - " FD Shutdown " , & shutdown_err , 1 ) ) ; <nl> - return ; <nl> - } <nl> - <nl> - / * ' curr ' was a closure but now changed to a different state . We will <nl> - have to retry * / <nl> - break ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - GPR_UNREACHABLE_CODE ( return ) ; <nl> - } <nl> - <nl> - static void set_ready ( grpc_exec_ctx * exec_ctx , grpc_fd * fd , gpr_atm * state ) { <nl> - while ( true ) { <nl> - gpr_atm curr = gpr_atm_no_barrier_load ( state ) ; <nl> - <nl> - switch ( curr ) { <nl> - case CLOSURE_READY : { <nl> - / * Already ready . We are done here * / <nl> - return ; <nl> - } <nl> - <nl> - case CLOSURE_NOT_READY : { <nl> - / * No barrier required as we ' re transitioning to a state that does not <nl> - involve a closure * / <nl> - if ( gpr_atm_no_barrier_cas ( state , CLOSURE_NOT_READY , CLOSURE_READY ) ) { <nl> - return ; / * early out * / <nl> - } <nl> - break ; / * retry * / <nl> - } <nl> - <nl> - default : { <nl> - / * ' curr ' is either a closure or the fd is shutdown * / <nl> - if ( ( curr & FD_SHUTDOWN_BIT ) > 0 ) { <nl> - / * The fd is shutdown . Do nothing * / <nl> - return ; <nl> - } <nl> - / * Full cas : acquire pairs with this cas ' release in the event of a <nl> - spurious set_ready ; release pairs with this or the acquire in <nl> - notify_on ( or set_shutdown ) * / <nl> - else if ( gpr_atm_full_cas ( state , curr , CLOSURE_NOT_READY ) ) { <nl> - grpc_closure_sched ( exec_ctx , ( grpc_closure * ) curr , GRPC_ERROR_NONE ) ; <nl> - return ; <nl> - } <nl> - / * else the state changed again ( only possible by either a racing <nl> - set_ready or set_shutdown functions . In both these cases , the closure <nl> - would have been scheduled for execution . So we are done here * / <nl> - return ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - <nl> static grpc_pollset * fd_get_read_notifier_pollset ( grpc_exec_ctx * exec_ctx , <nl> grpc_fd * fd ) { <nl> gpr_atm notifier = gpr_atm_acq_load ( & fd - > read_notifier_pollset ) ; <nl> static grpc_pollset * fd_get_read_notifier_pollset ( grpc_exec_ctx * exec_ctx , <nl> } <nl> <nl> static bool fd_is_shutdown ( grpc_fd * fd ) { <nl> - grpc_error * err = ( grpc_error * ) gpr_atm_acq_load ( & fd - > shutdown_error ) ; <nl> - return ( ( ( intptr_t ) err & FD_SHUTDOWN_BIT ) > 0 ) ; <nl> + return grpc_lfev_is_shutdown ( & fd - > read_closure ) ; <nl> } <nl> <nl> / * Might be called multiple times * / <nl> static void fd_shutdown ( grpc_exec_ctx * exec_ctx , grpc_fd * fd , grpc_error * why ) { <nl> - / * Store the shutdown error ORed with FD_SHUTDOWN_BIT in fd - > shutdown_error * / <nl> - if ( gpr_atm_rel_cas ( & fd - > shutdown_error , ( gpr_atm ) GRPC_ERROR_NONE , <nl> - ( gpr_atm ) why | FD_SHUTDOWN_BIT ) ) { <nl> + if ( grpc_lfev_set_shutdown ( exec_ctx , & fd - > read_closure , <nl> + GRPC_ERROR_REF ( why ) ) ) { <nl> shutdown ( fd - > fd , SHUT_RDWR ) ; <nl> - <nl> - set_shutdown ( exec_ctx , fd , & fd - > read_closure , why ) ; <nl> - set_shutdown ( exec_ctx , fd , & fd - > write_closure , why ) ; <nl> - } else { <nl> - / * Shutdown already called * / <nl> - GRPC_ERROR_UNREF ( why ) ; <nl> + grpc_lfev_set_shutdown ( exec_ctx , & fd - > write_closure , GRPC_ERROR_REF ( why ) ) ; <nl> } <nl> + GRPC_ERROR_UNREF ( why ) ; <nl> } <nl> <nl> static void fd_notify_on_read ( grpc_exec_ctx * exec_ctx , grpc_fd * fd , <nl> grpc_closure * closure ) { <nl> - notify_on ( exec_ctx , fd , & fd - > read_closure , closure ) ; <nl> + grpc_lfev_notify_on ( exec_ctx , & fd - > read_closure , closure ) ; <nl> } <nl> <nl> static void fd_notify_on_write ( grpc_exec_ctx * exec_ctx , grpc_fd * fd , <nl> grpc_closure * closure ) { <nl> - notify_on ( exec_ctx , fd , & fd - > write_closure , closure ) ; <nl> + grpc_lfev_notify_on ( exec_ctx , & fd - > write_closure , closure ) ; <nl> } <nl> <nl> static grpc_workqueue * fd_get_workqueue ( grpc_fd * fd ) { <nl> static grpc_error * pollset_worker_kick ( grpc_pollset_worker * worker ) { <nl> if ( gpr_atm_no_barrier_cas ( & worker - > is_kicked , ( gpr_atm ) 0 , ( gpr_atm ) 1 ) ) { <nl> GRPC_POLLING_TRACE ( <nl> " pollset_worker_kick : Kicking worker : % p ( thread id : % ld ) " , <nl> - ( void * ) worker , worker - > pt_id ) ; <nl> + ( void * ) worker , ( long int ) worker - > pt_id ) ; <nl> int err_num = pthread_kill ( worker - > pt_id , grpc_wakeup_signal ) ; <nl> if ( err_num ! = 0 ) { <nl> err = GRPC_OS_ERROR ( err_num , " pthread_kill " ) ; <nl> static int poll_deadline_to_millis_timeout ( gpr_timespec deadline , <nl> <nl> static void fd_become_readable ( grpc_exec_ctx * exec_ctx , grpc_fd * fd , <nl> grpc_pollset * notifier ) { <nl> - set_ready ( exec_ctx , fd , & fd - > read_closure ) ; <nl> + grpc_lfev_set_ready ( exec_ctx , & fd - > read_closure ) ; <nl> <nl> / * Note , it is possible that fd_become_readable might be called twice with <nl> different ' notifier ' s when an fd becomes readable and it is in two epoll <nl> static void fd_become_readable ( grpc_exec_ctx * exec_ctx , grpc_fd * fd , <nl> } <nl> <nl> static void fd_become_writable ( grpc_exec_ctx * exec_ctx , grpc_fd * fd ) { <nl> - set_ready ( exec_ctx , fd , & fd - > write_closure ) ; <nl> + grpc_lfev_set_ready ( exec_ctx , & fd - > write_closure ) ; <nl> } <nl> <nl> static void pollset_release_polling_island ( grpc_exec_ctx * exec_ctx , <nl> static grpc_error * pollset_work ( grpc_exec_ctx * exec_ctx , grpc_pollset * pollset , <nl> worker . pt_id = pthread_self ( ) ; <nl> gpr_atm_no_barrier_store ( & worker . is_kicked , ( gpr_atm ) 0 ) ; <nl> <nl> - * worker_hdl = & worker ; <nl> + if ( worker_hdl ) * worker_hdl = & worker ; <nl> <nl> gpr_tls_set ( & g_current_thread_pollset , ( intptr_t ) pollset ) ; <nl> gpr_tls_set ( & g_current_thread_worker , ( intptr_t ) & worker ) ; <nl> static grpc_error * pollset_work ( grpc_exec_ctx * exec_ctx , grpc_pollset * pollset , <nl> gpr_mu_lock ( & pollset - > po . mu ) ; <nl> } <nl> <nl> - * worker_hdl = NULL ; <nl> + if ( worker_hdl ) * worker_hdl = NULL ; <nl> <nl> gpr_tls_set ( & g_current_thread_pollset , ( intptr_t ) 0 ) ; <nl> gpr_tls_set ( & g_current_thread_worker , ( intptr_t ) 0 ) ; <nl> mmm a / src / core / lib / iomgr / ev_poll_posix . c <nl> ppp b / src / core / lib / iomgr / ev_poll_posix . c <nl> static grpc_error * pollset_work ( grpc_exec_ctx * exec_ctx , grpc_pollset * pollset , <nl> grpc_pollset_worker * * worker_hdl , <nl> gpr_timespec now , gpr_timespec deadline ) { <nl> grpc_pollset_worker worker ; <nl> - * worker_hdl = & worker ; <nl> + if ( worker_hdl ) * worker_hdl = & worker ; <nl> grpc_error * error = GRPC_ERROR_NONE ; <nl> <nl> / * Avoid malloc for small number of elements . * / <nl> static grpc_error * pollset_work ( grpc_exec_ctx * exec_ctx , grpc_pollset * pollset , <nl> gpr_mu_lock ( & pollset - > mu ) ; <nl> } <nl> } <nl> - * worker_hdl = NULL ; <nl> + if ( worker_hdl ) * worker_hdl = NULL ; <nl> GPR_TIMER_END ( " pollset_work " , 0 ) ; <nl> GRPC_LOG_IF_ERROR ( " pollset_work " , GRPC_ERROR_REF ( error ) ) ; <nl> return error ; <nl> mmm a / src / core / lib / iomgr / ev_posix . c <nl> ppp b / src / core / lib / iomgr / ev_posix . c <nl> static void try_engine ( const char * engine ) { <nl> } <nl> } <nl> <nl> + / * This should be used for testing purposes ONLY * / <nl> + void grpc_set_event_engine_test_only ( <nl> + const grpc_event_engine_vtable * ev_engine ) { <nl> + g_event_engine = ev_engine ; <nl> + } <nl> + <nl> / * Call this only after calling grpc_event_engine_init ( ) * / <nl> const char * grpc_get_poll_strategy_name ( ) { return g_poll_strategy_name ; } <nl> <nl> mmm a / src / core / lib / iomgr / ev_posix . h <nl> ppp b / src / core / lib / iomgr / ev_posix . h <nl> void grpc_pollset_set_del_fd ( grpc_exec_ctx * exec_ctx , <nl> typedef int ( * grpc_poll_function_type ) ( struct pollfd * , nfds_t , int ) ; <nl> extern grpc_poll_function_type grpc_poll_function ; <nl> <nl> + / * This should be used for testing purposes ONLY * / <nl> + void grpc_set_event_engine_test_only ( const grpc_event_engine_vtable * ) ; <nl> + <nl> # endif / * GRPC_CORE_LIB_IOMGR_EV_POSIX_H * / <nl> new file mode 100644 <nl> index 00000000000 . . 17e3bbf7278 <nl> mmm / dev / null <nl> ppp b / src / core / lib / iomgr / lockfree_event . c <nl> <nl> + / * <nl> + * <nl> + * Copyright 2017 , 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> + * / <nl> + <nl> + # include " src / core / lib / iomgr / lockfree_event . h " <nl> + <nl> + # include < grpc / support / log . h > <nl> + <nl> + / * ' state ' holds the to call when the fd is readable or writable respectively . <nl> + It can contain one of the following values : <nl> + CLOSURE_READY : The fd has an I / O event of interest but there is no <nl> + closure yet to execute <nl> + <nl> + CLOSURE_NOT_READY : The fd has no I / O event of interest <nl> + <nl> + closure ptr : The closure to be executed when the fd has an I / O <nl> + event of interest <nl> + <nl> + shutdown_error | FD_SHUTDOWN_BIT : <nl> + ' shutdown_error ' field ORed with FD_SHUTDOWN_BIT . <nl> + This indicates that the fd is shutdown . Since all <nl> + memory allocations are word - aligned , the lower two <nl> + bits of the shutdown_error pointer are always 0 . So <nl> + it is safe to OR these with FD_SHUTDOWN_BIT <nl> + <nl> + Valid state transitions : <nl> + <nl> + < closure ptr > < mmm - - 3mmmmmm CLOSURE_NOT_READY mmm - 1mmm - > CLOSURE_READY <nl> + | | ^ | ^ | | <nl> + | | | | | | | <nl> + | + mmmmmmmmmmmm - - 4mmmmmmmmm - + 6 + mmmmmmmmm2mmmmmmmmmmmmmmm + | <nl> + | | | <nl> + | v | <nl> + + mmm - - 5mmmmmm - > [ shutdown_error | FD_SHUTDOWN_BIT ] < mmm - 7mmmmmmmmm + <nl> + <nl> + For 1 , 4 : See grpc_lfev_set_ready ( ) function <nl> + For 2 , 3 : See grpc_lfev_notify_on ( ) function <nl> + For 5 , 6 , 7 : See grpc_lfev_set_shutdown ( ) function * / <nl> + <nl> + # define CLOSURE_NOT_READY ( ( gpr_atm ) 0 ) <nl> + # define CLOSURE_READY ( ( gpr_atm ) 2 ) <nl> + <nl> + # define FD_SHUTDOWN_BIT ( ( gpr_atm ) 1 ) <nl> + <nl> + void grpc_lfev_init ( gpr_atm * state ) { <nl> + gpr_atm_no_barrier_store ( state , CLOSURE_NOT_READY ) ; <nl> + } <nl> + <nl> + void grpc_lfev_destroy ( gpr_atm * state ) { <nl> + gpr_atm curr = gpr_atm_no_barrier_load ( state ) ; <nl> + if ( curr & FD_SHUTDOWN_BIT ) { <nl> + GRPC_ERROR_UNREF ( ( grpc_error * ) ( curr & ~ FD_SHUTDOWN_BIT ) ) ; <nl> + } else { <nl> + GPR_ASSERT ( curr = = CLOSURE_NOT_READY | | curr = = CLOSURE_READY ) ; <nl> + } <nl> + } <nl> + <nl> + bool grpc_lfev_is_shutdown ( gpr_atm * state ) { <nl> + gpr_atm curr = gpr_atm_no_barrier_load ( state ) ; <nl> + return ( curr & FD_SHUTDOWN_BIT ) ! = 0 ; <nl> + } <nl> + <nl> + void grpc_lfev_notify_on ( grpc_exec_ctx * exec_ctx , gpr_atm * state , <nl> + grpc_closure * closure ) { <nl> + while ( true ) { <nl> + gpr_atm curr = gpr_atm_no_barrier_load ( state ) ; <nl> + switch ( curr ) { <nl> + case CLOSURE_NOT_READY : { <nl> + / * CLOSURE_NOT_READY - > < closure > . <nl> + <nl> + We ' re guaranteed by API that there ' s an acquire barrier before here , <nl> + so there ' s no need to double - dip and this can be a release - only . <nl> + <nl> + The release itself pairs with the acquire half of a set_ready full <nl> + barrier . * / <nl> + if ( gpr_atm_rel_cas ( state , CLOSURE_NOT_READY , ( gpr_atm ) closure ) ) { <nl> + return ; / * Successful . Return * / <nl> + } <nl> + <nl> + break ; / * retry * / <nl> + } <nl> + <nl> + case CLOSURE_READY : { <nl> + / * Change the state to CLOSURE_NOT_READY . Schedule the closure if <nl> + successful . If not , the state most likely transitioned to shutdown . <nl> + We should retry . <nl> + <nl> + This can be a no - barrier cas since the state is being transitioned to <nl> + CLOSURE_NOT_READY ; set_ready and set_shutdown do not schedule any <nl> + closure when transitioning out of CLOSURE_NO_READY state ( i . e there <nl> + is no other code that needs to ' happen - after ' this ) * / <nl> + if ( gpr_atm_no_barrier_cas ( state , CLOSURE_READY , CLOSURE_NOT_READY ) ) { <nl> + grpc_closure_sched ( exec_ctx , closure , GRPC_ERROR_NONE ) ; <nl> + return ; / * Successful . Return * / <nl> + } <nl> + <nl> + break ; / * retry * / <nl> + } <nl> + <nl> + default : { <nl> + / * ' curr ' is either a closure or the fd is shutdown ( in which case ' curr ' <nl> + contains a pointer to the shutdown - error ) . If the fd is shutdown , <nl> + schedule the closure with the shutdown error * / <nl> + if ( ( curr & FD_SHUTDOWN_BIT ) > 0 ) { <nl> + grpc_error * shutdown_err = ( grpc_error * ) ( curr & ~ FD_SHUTDOWN_BIT ) ; <nl> + grpc_closure_sched ( exec_ctx , closure , <nl> + GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING ( <nl> + " FD Shutdown " , & shutdown_err , 1 ) ) ; <nl> + return ; <nl> + } <nl> + <nl> + / * There is already a closure ! . This indicates a bug in the code * / <nl> + gpr_log ( GPR_ERROR , <nl> + " notify_on called with a previous callback still pending " ) ; <nl> + abort ( ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + GPR_UNREACHABLE_CODE ( return ) ; <nl> + } <nl> + <nl> + bool grpc_lfev_set_shutdown ( grpc_exec_ctx * exec_ctx , gpr_atm * state , <nl> + grpc_error * shutdown_err ) { <nl> + gpr_atm new_state = ( gpr_atm ) shutdown_err | FD_SHUTDOWN_BIT ; <nl> + <nl> + while ( true ) { <nl> + gpr_atm curr = gpr_atm_no_barrier_load ( state ) ; <nl> + switch ( curr ) { <nl> + case CLOSURE_READY : <nl> + case CLOSURE_NOT_READY : <nl> + / * Need a full barrier here so that the initial load in notify_on <nl> + doesn ' t need a barrier * / <nl> + if ( gpr_atm_full_cas ( state , curr , new_state ) ) { <nl> + return true ; / * early out * / <nl> + } <nl> + break ; / * retry * / <nl> + <nl> + default : { <nl> + / * ' curr ' is either a closure or the fd is already shutdown * / <nl> + <nl> + / * If fd is already shutdown , we are done * / <nl> + if ( ( curr & FD_SHUTDOWN_BIT ) > 0 ) { <nl> + GRPC_ERROR_UNREF ( shutdown_err ) ; <nl> + return false ; <nl> + } <nl> + <nl> + / * Fd is not shutdown . Schedule the closure and move the state to <nl> + shutdown state . <nl> + Needs an acquire to pair with setting the closure ( and get a <nl> + happens - after on that edge ) , and a release to pair with anything <nl> + loading the shutdown state . * / <nl> + if ( gpr_atm_full_cas ( state , curr , new_state ) ) { <nl> + grpc_closure_sched ( exec_ctx , ( grpc_closure * ) curr , <nl> + GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING ( <nl> + " FD Shutdown " , & shutdown_err , 1 ) ) ; <nl> + return true ; <nl> + } <nl> + <nl> + / * ' curr ' was a closure but now changed to a different state . We will <nl> + have to retry * / <nl> + break ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + GPR_UNREACHABLE_CODE ( return false ) ; <nl> + } <nl> + <nl> + void grpc_lfev_set_ready ( grpc_exec_ctx * exec_ctx , gpr_atm * state ) { <nl> + while ( true ) { <nl> + gpr_atm curr = gpr_atm_no_barrier_load ( state ) ; <nl> + <nl> + switch ( curr ) { <nl> + case CLOSURE_READY : { <nl> + / * Already ready . We are done here * / <nl> + return ; <nl> + } <nl> + <nl> + case CLOSURE_NOT_READY : { <nl> + / * No barrier required as we ' re transitioning to a state that does not <nl> + involve a closure * / <nl> + if ( gpr_atm_no_barrier_cas ( state , CLOSURE_NOT_READY , CLOSURE_READY ) ) { <nl> + return ; / * early out * / <nl> + } <nl> + break ; / * retry * / <nl> + } <nl> + <nl> + default : { <nl> + / * ' curr ' is either a closure or the fd is shutdown * / <nl> + if ( ( curr & FD_SHUTDOWN_BIT ) > 0 ) { <nl> + / * The fd is shutdown . Do nothing * / <nl> + return ; <nl> + } <nl> + / * Full cas : acquire pairs with this cas ' release in the event of a <nl> + spurious set_ready ; release pairs with this or the acquire in <nl> + notify_on ( or set_shutdown ) * / <nl> + else if ( gpr_atm_full_cas ( state , curr , CLOSURE_NOT_READY ) ) { <nl> + grpc_closure_sched ( exec_ctx , ( grpc_closure * ) curr , GRPC_ERROR_NONE ) ; <nl> + return ; <nl> + } <nl> + / * else the state changed again ( only possible by either a racing <nl> + set_ready or set_shutdown functions . In both these cases , the closure <nl> + would have been scheduled for execution . So we are done here * / <nl> + return ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 1d9119204ca <nl> mmm / dev / null <nl> ppp b / src / core / lib / iomgr / lockfree_event . h <nl> <nl> + / * <nl> + * <nl> + * Copyright 2017 , 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> + * / <nl> + <nl> + # ifndef GRPC_CORE_LIB_IOMGR_LOCKFREE_EVENT_H <nl> + # define GRPC_CORE_LIB_IOMGR_LOCKFREE_EVENT_H <nl> + <nl> + / * Lock free event notification for file descriptors * / <nl> + <nl> + # include < grpc / support / atm . h > <nl> + <nl> + # include " src / core / lib / iomgr / exec_ctx . h " <nl> + <nl> + void grpc_lfev_init ( gpr_atm * state ) ; <nl> + void grpc_lfev_destroy ( gpr_atm * state ) ; <nl> + bool grpc_lfev_is_shutdown ( gpr_atm * state ) ; <nl> + <nl> + void grpc_lfev_notify_on ( grpc_exec_ctx * exec_ctx , gpr_atm * state , <nl> + grpc_closure * closure ) ; <nl> + / * Returns true on first successful shutdown * / <nl> + bool grpc_lfev_set_shutdown ( grpc_exec_ctx * exec_ctx , gpr_atm * state , <nl> + grpc_error * shutdown_err ) ; <nl> + void grpc_lfev_set_ready ( grpc_exec_ctx * exec_ctx , gpr_atm * state ) ; <nl> + <nl> + # endif / * GRPC_CORE_LIB_IOMGR_LOCKFREE_EVENT_H * / <nl> mmm a / src / core / lib / iomgr / pollset . h <nl> ppp b / src / core / lib / iomgr / pollset . h <nl> void grpc_pollset_destroy ( grpc_pollset * pollset ) ; <nl> and it is guaranteed that it will not be released by grpc_pollset_work <nl> AFTER worker has been destroyed . <nl> <nl> + It ' s legal for worker to be NULL : in that case , this specific thread can not <nl> + be directly woken with a kick , but maybe be indirectly ( with a kick against <nl> + the pollset as a whole ) . <nl> + <nl> Tries not to block past deadline . <nl> May call grpc_closure_list_run on grpc_closure_list , without holding the <nl> pollset <nl> mmm a / src / core / lib / iomgr / pollset_windows . c <nl> ppp b / src / core / lib / iomgr / pollset_windows . c <nl> grpc_error * grpc_pollset_work ( grpc_exec_ctx * exec_ctx , grpc_pollset * pollset , <nl> grpc_pollset_worker * * worker_hdl , <nl> gpr_timespec now , gpr_timespec deadline ) { <nl> grpc_pollset_worker worker ; <nl> - * worker_hdl = & worker ; <nl> + if ( worker_hdl ) * worker_hdl = & worker ; <nl> <nl> int added_worker = 0 ; <nl> worker . links [ GRPC_POLLSET_WORKER_LINK_POLLSET ] . next = <nl> grpc_error * grpc_pollset_work ( grpc_exec_ctx * exec_ctx , grpc_pollset * pollset , <nl> remove_worker ( & worker , GRPC_POLLSET_WORKER_LINK_POLLSET ) ; <nl> } <nl> gpr_cv_destroy ( & worker . cv ) ; <nl> - * worker_hdl = NULL ; <nl> + if ( worker_hdl ) * worker_hdl = NULL ; <nl> return GRPC_ERROR_NONE ; <nl> } <nl> <nl> mmm a / src / core / lib / iomgr / port . h <nl> ppp b / src / core / lib / iomgr / port . h <nl> <nl> # define GRPC_LINUX_SOCKETUTILS 1 <nl> # endif <nl> # endif <nl> + # ifndef __GLIBC__ <nl> + # define GRPC_LINUX_EPOLL 1 <nl> + # define GRPC_LINUX_EVENTFD 1 <nl> + # endif <nl> # ifndef GRPC_LINUX_EVENTFD <nl> # define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1 <nl> # endif <nl> mmm a / src / core / lib / iomgr / resource_quota . c <nl> ppp b / src / core / lib / iomgr / resource_quota . c <nl> struct grpc_resource_quota { <nl> / * Amount of free memory in the resource quota * / <nl> int64_t free_pool ; <nl> <nl> + gpr_atm last_size ; <nl> + <nl> / * Has rq_step been scheduled to occur ? * / <nl> bool step_scheduled ; <nl> / * Are we currently reclaiming memory * / <nl> grpc_resource_quota * grpc_resource_quota_create ( const char * name ) { <nl> resource_quota - > combiner = grpc_combiner_create ( NULL ) ; <nl> resource_quota - > free_pool = INT64_MAX ; <nl> resource_quota - > size = INT64_MAX ; <nl> + gpr_atm_no_barrier_store ( & resource_quota - > last_size , GPR_ATM_MAX ) ; <nl> resource_quota - > step_scheduled = false ; <nl> resource_quota - > reclaiming = false ; <nl> gpr_atm_no_barrier_store ( & resource_quota - > memory_usage_estimation , 0 ) ; <nl> void grpc_resource_quota_resize ( grpc_resource_quota * resource_quota , <nl> rq_resize_args * a = gpr_malloc ( sizeof ( * a ) ) ; <nl> a - > resource_quota = grpc_resource_quota_ref_internal ( resource_quota ) ; <nl> a - > size = ( int64_t ) size ; <nl> + gpr_atm_no_barrier_store ( & resource_quota - > last_size , <nl> + ( gpr_atm ) GPR_MIN ( ( size_t ) GPR_ATM_MAX , size ) ) ; <nl> grpc_closure_init ( & a - > closure , rq_resize , a , grpc_schedule_on_exec_ctx ) ; <nl> grpc_closure_sched ( & exec_ctx , & a - > closure , GRPC_ERROR_NONE ) ; <nl> grpc_exec_ctx_finish ( & exec_ctx ) ; <nl> } <nl> <nl> + size_t grpc_resource_quota_peek_size ( grpc_resource_quota * resource_quota ) { <nl> + return ( size_t ) gpr_atm_no_barrier_load ( & resource_quota - > last_size ) ; <nl> + } <nl> + <nl> / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> * grpc_resource_user channel args api <nl> * / <nl> mmm a / src / core / lib / iomgr / resource_quota . h <nl> ppp b / src / core / lib / iomgr / resource_quota . h <nl> grpc_resource_quota * grpc_resource_quota_from_channel_args ( <nl> double grpc_resource_quota_get_memory_pressure ( <nl> grpc_resource_quota * resource_quota ) ; <nl> <nl> + size_t grpc_resource_quota_peek_size ( grpc_resource_quota * resource_quota ) ; <nl> + <nl> typedef struct grpc_resource_user grpc_resource_user ; <nl> <nl> grpc_resource_user * grpc_resource_user_create ( <nl> mmm a / src / core / lib / iomgr / tcp_client . h <nl> ppp b / src / core / lib / iomgr / tcp_client . h <nl> <nl> # include " src / core / lib / iomgr / pollset_set . h " <nl> # include " src / core / lib / iomgr / resolve_address . h " <nl> <nl> - / * Channel arg ( integer ) setting how large a slice to try and read from the wire <nl> - each time recvmsg ( or equivalent ) is called * / <nl> - # define GRPC_ARG_TCP_READ_CHUNK_SIZE " grpc . experimental . tcp_read_chunk_size " <nl> - <nl> / * Asynchronously connect to an address ( specified as ( addr , len ) ) , and call <nl> cb with arg and the completed connection when done ( or call cb with arg and <nl> NULL on failure ) . <nl> mmm a / src / core / lib / iomgr / tcp_client_posix . c <nl> ppp b / src / core / lib / iomgr / tcp_client_posix . c <nl> static void tc_on_alarm ( grpc_exec_ctx * exec_ctx , void * acp , grpc_error * error ) { <nl> grpc_endpoint * grpc_tcp_client_create_from_fd ( <nl> grpc_exec_ctx * exec_ctx , grpc_fd * fd , const grpc_channel_args * channel_args , <nl> const char * addr_str ) { <nl> - size_t tcp_read_chunk_size = GRPC_TCP_DEFAULT_READ_SLICE_SIZE ; <nl> - grpc_resource_quota * resource_quota = grpc_resource_quota_create ( NULL ) ; <nl> - if ( channel_args ! = NULL ) { <nl> - for ( size_t i = 0 ; i < channel_args - > num_args ; i + + ) { <nl> - if ( 0 = = <nl> - strcmp ( channel_args - > args [ i ] . key , GRPC_ARG_TCP_READ_CHUNK_SIZE ) ) { <nl> - grpc_integer_options options = { ( int ) tcp_read_chunk_size , 1 , <nl> - 8 * 1024 * 1024 } ; <nl> - tcp_read_chunk_size = ( size_t ) grpc_channel_arg_get_integer ( <nl> - & channel_args - > args [ i ] , options ) ; <nl> - } else if ( 0 = = <nl> - strcmp ( channel_args - > args [ i ] . key , GRPC_ARG_RESOURCE_QUOTA ) ) { <nl> - grpc_resource_quota_unref_internal ( exec_ctx , resource_quota ) ; <nl> - resource_quota = grpc_resource_quota_ref_internal ( <nl> - channel_args - > args [ i ] . value . pointer . p ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - grpc_endpoint * ep = <nl> - grpc_tcp_create ( fd , resource_quota , tcp_read_chunk_size , addr_str ) ; <nl> - grpc_resource_quota_unref_internal ( exec_ctx , resource_quota ) ; <nl> - return ep ; <nl> + return grpc_tcp_create ( exec_ctx , fd , channel_args , addr_str ) ; <nl> } <nl> <nl> static void on_writable ( grpc_exec_ctx * exec_ctx , void * acp , grpc_error * error ) { <nl> mmm a / src / core / lib / iomgr / tcp_client_windows . c <nl> ppp b / src / core / lib / iomgr / tcp_client_windows . c <nl> typedef struct { <nl> int refs ; <nl> grpc_closure on_connect ; <nl> grpc_endpoint * * endpoint ; <nl> - grpc_resource_quota * resource_quota ; <nl> + grpc_channel_args * channel_args ; <nl> } async_connect ; <nl> <nl> static void async_connect_unlock_and_cleanup ( grpc_exec_ctx * exec_ctx , <nl> static void async_connect_unlock_and_cleanup ( grpc_exec_ctx * exec_ctx , <nl> int done = ( - - ac - > refs = = 0 ) ; <nl> gpr_mu_unlock ( & ac - > mu ) ; <nl> if ( done ) { <nl> - grpc_resource_quota_unref_internal ( exec_ctx , ac - > resource_quota ) ; <nl> + grpc_channel_args_destroy ( exec_ctx , ac - > channel_args ) ; <nl> gpr_mu_destroy ( & ac - > mu ) ; <nl> gpr_free ( ac - > addr_name ) ; <nl> gpr_free ( ac ) ; <nl> static void on_connect ( grpc_exec_ctx * exec_ctx , void * acp , grpc_error * error ) { <nl> if ( ! wsa_success ) { <nl> error = GRPC_WSA_ERROR ( WSAGetLastError ( ) , " ConnectEx " ) ; <nl> } else { <nl> - * ep = grpc_tcp_create ( socket , ac - > resource_quota , ac - > addr_name ) ; <nl> + * ep = <nl> + grpc_tcp_create ( exec_ctx , socket , ac - > channel_args , ac - > addr_name ) ; <nl> socket = NULL ; <nl> } <nl> } else { <nl> static void tcp_client_connect_impl ( <nl> grpc_winsocket_callback_info * info ; <nl> grpc_error * error = GRPC_ERROR_NONE ; <nl> <nl> - grpc_resource_quota * resource_quota = grpc_resource_quota_create ( NULL ) ; <nl> - if ( channel_args ! = NULL ) { <nl> - for ( size_t i = 0 ; i < channel_args - > num_args ; i + + ) { <nl> - if ( 0 = = strcmp ( channel_args - > args [ i ] . key , GRPC_ARG_RESOURCE_QUOTA ) ) { <nl> - grpc_resource_quota_unref_internal ( exec_ctx , resource_quota ) ; <nl> - resource_quota = grpc_resource_quota_ref_internal ( <nl> - channel_args - > args [ i ] . value . pointer . p ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> * endpoint = NULL ; <nl> <nl> / * Use dualstack sockets where available . * / <nl> static void tcp_client_connect_impl ( <nl> ac - > refs = 2 ; <nl> ac - > addr_name = grpc_sockaddr_to_uri ( addr ) ; <nl> ac - > endpoint = endpoint ; <nl> - ac - > resource_quota = resource_quota ; <nl> + ac - > channel_args = grpc_channel_args_copy ( channel_args ) ; <nl> grpc_closure_init ( & ac - > on_connect , on_connect , ac , grpc_schedule_on_exec_ctx ) ; <nl> <nl> grpc_closure_init ( & ac - > on_alarm , on_alarm , ac , grpc_schedule_on_exec_ctx ) ; <nl> static void tcp_client_connect_impl ( <nl> } else if ( sock ! = INVALID_SOCKET ) { <nl> closesocket ( sock ) ; <nl> } <nl> - grpc_resource_quota_unref_internal ( exec_ctx , resource_quota ) ; <nl> grpc_closure_sched ( exec_ctx , on_done , final_error ) ; <nl> } <nl> <nl> mmm a / src / core / lib / iomgr / tcp_posix . c <nl> ppp b / src / core / lib / iomgr / tcp_posix . c <nl> <nl> # include < grpc / support / string_util . h > <nl> # include < grpc / support / sync . h > <nl> # include < grpc / support / time . h > <nl> + # include < grpc / support / useful . h > <nl> <nl> + # include " src / core / lib / channel / channel_args . h " <nl> # include " src / core / lib / debug / trace . h " <nl> # include " src / core / lib / iomgr / ev_posix . h " <nl> # include " src / core / lib / profiling / timers . h " <nl> typedef struct { <nl> int fd ; <nl> bool finished_edge ; <nl> msg_iovlen_type iov_size ; / * Number of slices to allocate per read attempt * / <nl> - size_t slice_size ; <nl> + double target_length ; <nl> + double bytes_read_this_round ; <nl> gpr_refcount refcount ; <nl> gpr_atm shutdown_count ; <nl> <nl> + int min_read_chunk_size ; <nl> + int max_read_chunk_size ; <nl> + <nl> / * garbage after the last read * / <nl> grpc_slice_buffer last_read_buffer ; <nl> <nl> typedef struct { <nl> grpc_resource_user_slice_allocator slice_allocator ; <nl> } grpc_tcp ; <nl> <nl> + static void add_to_estimate ( grpc_tcp * tcp , size_t bytes ) { <nl> + tcp - > bytes_read_this_round + = ( double ) bytes ; <nl> + } <nl> + <nl> + static void finish_estimate ( grpc_tcp * tcp ) { <nl> + / * If we read > 80 % of the target buffer in one read loop , increase the size <nl> + of the target buffer to either the amount read , or twice its previous <nl> + value * / <nl> + if ( tcp - > bytes_read_this_round > tcp - > target_length * 0 . 8 ) { <nl> + tcp - > target_length = <nl> + GPR_MAX ( 2 * tcp - > target_length , tcp - > bytes_read_this_round ) ; <nl> + } else { <nl> + tcp - > target_length = <nl> + 0 . 99 * tcp - > target_length + 0 . 01 * tcp - > bytes_read_this_round ; <nl> + } <nl> + tcp - > bytes_read_this_round = 0 ; <nl> + } <nl> + <nl> + static size_t get_target_read_size ( grpc_tcp * tcp ) { <nl> + grpc_resource_quota * rq = grpc_resource_user_quota ( tcp - > resource_user ) ; <nl> + double pressure = grpc_resource_quota_get_memory_pressure ( rq ) ; <nl> + double target = <nl> + tcp - > target_length * ( pressure > 0 . 8 ? ( 1 . 0 - pressure ) / 0 . 2 : 1 . 0 ) ; <nl> + size_t sz = ( ( ( size_t ) GPR_CLAMP ( target , tcp - > min_read_chunk_size , <nl> + tcp - > max_read_chunk_size ) ) + <nl> + 255 ) & <nl> + ~ ( size_t ) 255 ; <nl> + / * don ' t use more than 1 / 16th of the overall resource quota for a single read <nl> + * alloc * / <nl> + size_t rqmax = grpc_resource_quota_peek_size ( rq ) ; <nl> + if ( sz > rqmax / 16 & & rqmax > 1024 ) { <nl> + sz = rqmax / 16 ; <nl> + } <nl> + return sz ; <nl> + } <nl> + <nl> static grpc_error * tcp_annotate_error ( grpc_error * src_error , grpc_tcp * tcp ) { <nl> return grpc_error_set_str ( <nl> grpc_error_set_int ( src_error , GRPC_ERROR_INT_FD , tcp - > fd ) , <nl> static void tcp_do_read ( grpc_exec_ctx * exec_ctx , grpc_tcp * tcp ) { <nl> / * NB : After calling call_read_cb a parallel call of the read handler may <nl> * be running . * / <nl> if ( errno = = EAGAIN ) { <nl> - if ( tcp - > iov_size > 1 ) { <nl> - tcp - > iov_size / = 2 ; <nl> - } <nl> + finish_estimate ( tcp ) ; <nl> / * We ' ve consumed the edge , request a new one * / <nl> grpc_fd_notify_on_read ( exec_ctx , tcp - > em_fd , & tcp - > read_closure ) ; <nl> } else { <nl> static void tcp_do_read ( grpc_exec_ctx * exec_ctx , grpc_tcp * tcp ) { <nl> GRPC_ERROR_CREATE_FROM_STATIC_STRING ( " Socket closed " ) , tcp ) ) ; <nl> TCP_UNREF ( exec_ctx , tcp , " read " ) ; <nl> } else { <nl> + add_to_estimate ( tcp , ( size_t ) read_bytes ) ; <nl> GPR_ASSERT ( ( size_t ) read_bytes < = tcp - > incoming_buffer - > length ) ; <nl> if ( ( size_t ) read_bytes < tcp - > incoming_buffer - > length ) { <nl> grpc_slice_buffer_trim_end ( <nl> tcp - > incoming_buffer , <nl> tcp - > incoming_buffer - > length - ( size_t ) read_bytes , <nl> & tcp - > last_read_buffer ) ; <nl> - } else if ( tcp - > iov_size < MAX_READ_IOVEC ) { <nl> - + + tcp - > iov_size ; <nl> } <nl> GPR_ASSERT ( ( size_t ) read_bytes = = tcp - > incoming_buffer - > length ) ; <nl> call_read_cb ( exec_ctx , tcp , GRPC_ERROR_NONE ) ; <nl> static void tcp_read_allocation_done ( grpc_exec_ctx * exec_ctx , void * tcpp , <nl> } <nl> <nl> static void tcp_continue_read ( grpc_exec_ctx * exec_ctx , grpc_tcp * tcp ) { <nl> - if ( tcp - > incoming_buffer - > count < ( size_t ) tcp - > iov_size ) { <nl> - grpc_resource_user_alloc_slices ( <nl> - exec_ctx , & tcp - > slice_allocator , tcp - > slice_size , <nl> - ( size_t ) tcp - > iov_size - tcp - > incoming_buffer - > count , <nl> - tcp - > incoming_buffer ) ; <nl> + size_t target_read_size = get_target_read_size ( tcp ) ; <nl> + if ( tcp - > incoming_buffer - > length < target_read_size & & <nl> + tcp - > incoming_buffer - > count < MAX_READ_IOVEC ) { <nl> + grpc_resource_user_alloc_slices ( exec_ctx , & tcp - > slice_allocator , <nl> + target_read_size , 1 , tcp - > incoming_buffer ) ; <nl> } else { <nl> tcp_do_read ( exec_ctx , tcp ) ; <nl> } <nl> static const grpc_endpoint_vtable vtable = { tcp_read , <nl> tcp_get_peer , <nl> tcp_get_fd } ; <nl> <nl> - grpc_endpoint * grpc_tcp_create ( grpc_fd * em_fd , <nl> - grpc_resource_quota * resource_quota , <nl> - size_t slice_size , const char * peer_string ) { <nl> + # define MAX_CHUNK_SIZE 32 * 1024 * 1024 <nl> + <nl> + grpc_endpoint * grpc_tcp_create ( grpc_exec_ctx * exec_ctx , grpc_fd * em_fd , <nl> + const grpc_channel_args * channel_args , <nl> + const char * peer_string ) { <nl> + int tcp_read_chunk_size = GRPC_TCP_DEFAULT_READ_SLICE_SIZE ; <nl> + int tcp_max_read_chunk_size = 4 * 1024 * 1024 ; <nl> + int tcp_min_read_chunk_size = 256 ; <nl> + grpc_resource_quota * resource_quota = grpc_resource_quota_create ( NULL ) ; <nl> + if ( channel_args ! = NULL ) { <nl> + for ( size_t i = 0 ; i < channel_args - > num_args ; i + + ) { <nl> + if ( 0 = = <nl> + strcmp ( channel_args - > args [ i ] . key , GRPC_ARG_TCP_READ_CHUNK_SIZE ) ) { <nl> + grpc_integer_options options = { ( int ) tcp_read_chunk_size , 1 , <nl> + MAX_CHUNK_SIZE } ; <nl> + tcp_read_chunk_size = <nl> + grpc_channel_arg_get_integer ( & channel_args - > args [ i ] , options ) ; <nl> + } else if ( 0 = = strcmp ( channel_args - > args [ i ] . key , <nl> + GRPC_ARG_TCP_MIN_READ_CHUNK_SIZE ) ) { <nl> + grpc_integer_options options = { ( int ) tcp_read_chunk_size , 1 , <nl> + MAX_CHUNK_SIZE } ; <nl> + tcp_min_read_chunk_size = <nl> + grpc_channel_arg_get_integer ( & channel_args - > args [ i ] , options ) ; <nl> + } else if ( 0 = = strcmp ( channel_args - > args [ i ] . key , <nl> + GRPC_ARG_TCP_MAX_READ_CHUNK_SIZE ) ) { <nl> + grpc_integer_options options = { ( int ) tcp_read_chunk_size , 1 , <nl> + MAX_CHUNK_SIZE } ; <nl> + tcp_max_read_chunk_size = <nl> + grpc_channel_arg_get_integer ( & channel_args - > args [ i ] , options ) ; <nl> + } else if ( 0 = = <nl> + strcmp ( channel_args - > args [ i ] . key , GRPC_ARG_RESOURCE_QUOTA ) ) { <nl> + grpc_resource_quota_unref_internal ( exec_ctx , resource_quota ) ; <nl> + resource_quota = grpc_resource_quota_ref_internal ( <nl> + channel_args - > args [ i ] . value . pointer . p ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + if ( tcp_min_read_chunk_size > tcp_max_read_chunk_size ) { <nl> + tcp_min_read_chunk_size = tcp_max_read_chunk_size ; <nl> + } <nl> + tcp_read_chunk_size = GPR_CLAMP ( tcp_read_chunk_size , tcp_min_read_chunk_size , <nl> + tcp_max_read_chunk_size ) ; <nl> + <nl> grpc_tcp * tcp = ( grpc_tcp * ) gpr_malloc ( sizeof ( grpc_tcp ) ) ; <nl> tcp - > base . vtable = & vtable ; <nl> tcp - > peer_string = gpr_strdup ( peer_string ) ; <nl> grpc_endpoint * grpc_tcp_create ( grpc_fd * em_fd , <nl> tcp - > release_fd_cb = NULL ; <nl> tcp - > release_fd = NULL ; <nl> tcp - > incoming_buffer = NULL ; <nl> - tcp - > slice_size = slice_size ; <nl> + tcp - > target_length = ( double ) tcp_read_chunk_size ; <nl> + tcp - > min_read_chunk_size = tcp_min_read_chunk_size ; <nl> + tcp - > max_read_chunk_size = tcp_max_read_chunk_size ; <nl> + tcp - > bytes_read_this_round = 0 ; <nl> tcp - > iov_size = 1 ; <nl> tcp - > finished_edge = true ; <nl> / * paired with unref in grpc_tcp_destroy * / <nl> grpc_endpoint * grpc_tcp_create ( grpc_fd * em_fd , <nl> & tcp - > slice_allocator , tcp - > resource_user , tcp_read_allocation_done , tcp ) ; <nl> / * Tell network status tracker about new endpoint * / <nl> grpc_network_status_register_endpoint ( & tcp - > base ) ; <nl> + grpc_resource_quota_unref_internal ( exec_ctx , resource_quota ) ; <nl> <nl> return & tcp - > base ; <nl> } <nl> mmm a / src / core / lib / iomgr / tcp_posix . h <nl> ppp b / src / core / lib / iomgr / tcp_posix . h <nl> <nl> # include " src / core / lib / iomgr / endpoint . h " <nl> # include " src / core / lib / iomgr / ev_posix . h " <nl> <nl> - # define GRPC_TCP_DEFAULT_READ_SLICE_SIZE 8192 <nl> - <nl> extern int grpc_tcp_trace ; <nl> <nl> / * Create a tcp endpoint given a file desciptor and a read slice size . <nl> Takes ownership of fd . * / <nl> - grpc_endpoint * grpc_tcp_create ( grpc_fd * fd , grpc_resource_quota * resource_quota , <nl> - size_t read_slice_size , const char * peer_string ) ; <nl> + grpc_endpoint * grpc_tcp_create ( grpc_exec_ctx * exec_ctx , grpc_fd * fd , <nl> + const grpc_channel_args * args , <nl> + const char * peer_string ) ; <nl> <nl> / * Return the tcp endpoint ' s fd , or - 1 if this is not available . Does not <nl> release the fd . <nl> mmm a / src / core / lib / iomgr / tcp_server_posix . c <nl> ppp b / src / core / lib / iomgr / tcp_server_posix . c <nl> <nl> # include < grpc / support / time . h > <nl> # include < grpc / support / useful . h > <nl> <nl> + # include " src / core / lib / channel / channel_args . h " <nl> # include " src / core / lib / iomgr / resolve_address . h " <nl> # include " src / core / lib / iomgr / sockaddr . h " <nl> # include " src / core / lib / iomgr / sockaddr_utils . h " <nl> grpc_error * grpc_tcp_server_create ( grpc_exec_ctx * exec_ctx , <nl> <nl> grpc_tcp_server * s = gpr_zalloc ( sizeof ( grpc_tcp_server ) ) ; <nl> s - > so_reuseport = has_so_reuseport ; <nl> - s - > resource_quota = grpc_resource_quota_create ( NULL ) ; <nl> s - > expand_wildcard_addrs = false ; <nl> for ( size_t i = 0 ; i < ( args = = NULL ? 0 : args - > num_args ) ; i + + ) { <nl> if ( 0 = = strcmp ( GRPC_ARG_ALLOW_REUSEPORT , args - > args [ i ] . key ) ) { <nl> grpc_error * grpc_tcp_server_create ( grpc_exec_ctx * exec_ctx , <nl> s - > so_reuseport = <nl> has_so_reuseport & & ( args - > args [ i ] . value . integer ! = 0 ) ; <nl> } else { <nl> - grpc_resource_quota_unref_internal ( exec_ctx , s - > resource_quota ) ; <nl> gpr_free ( s ) ; <nl> return GRPC_ERROR_CREATE_FROM_STATIC_STRING ( GRPC_ARG_ALLOW_REUSEPORT <nl> " must be an integer " ) ; <nl> } <nl> - } else if ( 0 = = strcmp ( GRPC_ARG_RESOURCE_QUOTA , args - > args [ i ] . key ) ) { <nl> - if ( args - > args [ i ] . type = = GRPC_ARG_POINTER ) { <nl> - grpc_resource_quota_unref_internal ( exec_ctx , s - > resource_quota ) ; <nl> - s - > resource_quota = <nl> - grpc_resource_quota_ref_internal ( args - > args [ i ] . value . pointer . p ) ; <nl> - } else { <nl> - grpc_resource_quota_unref_internal ( exec_ctx , s - > resource_quota ) ; <nl> - gpr_free ( s ) ; <nl> - return GRPC_ERROR_CREATE_FROM_STATIC_STRING ( <nl> - GRPC_ARG_RESOURCE_QUOTA " must be a pointer to a buffer pool " ) ; <nl> - } <nl> } else if ( 0 = = strcmp ( GRPC_ARG_EXPAND_WILDCARD_ADDRS , args - > args [ i ] . key ) ) { <nl> if ( args - > args [ i ] . type = = GRPC_ARG_INTEGER ) { <nl> s - > expand_wildcard_addrs = ( args - > args [ i ] . value . integer ! = 0 ) ; <nl> } else { <nl> - grpc_resource_quota_unref_internal ( exec_ctx , s - > resource_quota ) ; <nl> gpr_free ( s ) ; <nl> return GRPC_ERROR_CREATE_FROM_STATIC_STRING ( <nl> GRPC_ARG_EXPAND_WILDCARD_ADDRS " must be an integer " ) ; <nl> grpc_error * grpc_tcp_server_create ( grpc_exec_ctx * exec_ctx , <nl> s - > head = NULL ; <nl> s - > tail = NULL ; <nl> s - > nports = 0 ; <nl> + s - > channel_args = grpc_channel_args_copy ( args ) ; <nl> gpr_atm_no_barrier_store ( & s - > next_pollset_to_assign , 0 ) ; <nl> * server = s ; <nl> return GRPC_ERROR_NONE ; <nl> static void finish_shutdown ( grpc_exec_ctx * exec_ctx , grpc_tcp_server * s ) { <nl> s - > head = sp - > next ; <nl> gpr_free ( sp ) ; <nl> } <nl> - <nl> - grpc_resource_quota_unref_internal ( exec_ctx , s - > resource_quota ) ; <nl> + grpc_channel_args_destroy ( exec_ctx , s - > channel_args ) ; <nl> <nl> gpr_free ( s ) ; <nl> } <nl> static void on_read ( grpc_exec_ctx * exec_ctx , void * arg , grpc_error * err ) { <nl> <nl> sp - > server - > on_accept_cb ( <nl> exec_ctx , sp - > server - > on_accept_cb_arg , <nl> - grpc_tcp_create ( fdobj , sp - > server - > resource_quota , <nl> - GRPC_TCP_DEFAULT_READ_SLICE_SIZE , addr_str ) , <nl> + grpc_tcp_create ( exec_ctx , fdobj , sp - > server - > channel_args , addr_str ) , <nl> read_notifier_pollset , acceptor ) ; <nl> <nl> gpr_free ( name ) ; <nl> mmm a / src / core / lib / iomgr / tcp_server_utils_posix . h <nl> ppp b / src / core / lib / iomgr / tcp_server_utils_posix . h <nl> struct grpc_tcp_server { <nl> / * next pollset to assign a channel to * / <nl> gpr_atm next_pollset_to_assign ; <nl> <nl> - grpc_resource_quota * resource_quota ; <nl> + / * channel args for this server * / <nl> + grpc_channel_args * channel_args ; <nl> } ; <nl> <nl> / * If successful , add a listener to \ a s for \ a addr , set \ a dsmode for the <nl> mmm a / src / core / lib / iomgr / tcp_server_windows . c <nl> ppp b / src / core / lib / iomgr / tcp_server_windows . c <nl> <nl> # include < grpc / support / sync . h > <nl> # include < grpc / support / time . h > <nl> <nl> + # include " src / core / lib / channel / channel_args . h " <nl> # include " src / core / lib / iomgr / iocp_windows . h " <nl> # include " src / core / lib / iomgr / pollset_windows . h " <nl> # include " src / core / lib / iomgr / resolve_address . h " <nl> struct grpc_tcp_server { <nl> / * shutdown callback * / <nl> grpc_closure * shutdown_complete ; <nl> <nl> - grpc_resource_quota * resource_quota ; <nl> + grpc_channel_args * channel_args ; <nl> } ; <nl> <nl> / * Public function . Allocates the proper data structures to hold a <nl> grpc_error * grpc_tcp_server_create ( grpc_exec_ctx * exec_ctx , <nl> const grpc_channel_args * args , <nl> grpc_tcp_server * * server ) { <nl> grpc_tcp_server * s = gpr_malloc ( sizeof ( grpc_tcp_server ) ) ; <nl> - s - > resource_quota = grpc_resource_quota_create ( NULL ) ; <nl> - for ( size_t i = 0 ; i < ( args = = NULL ? 0 : args - > num_args ) ; i + + ) { <nl> - if ( 0 = = strcmp ( GRPC_ARG_RESOURCE_QUOTA , args - > args [ i ] . key ) ) { <nl> - if ( args - > args [ i ] . type = = GRPC_ARG_POINTER ) { <nl> - grpc_resource_quota_unref_internal ( exec_ctx , s - > resource_quota ) ; <nl> - s - > resource_quota = <nl> - grpc_resource_quota_ref_internal ( args - > args [ i ] . value . pointer . p ) ; <nl> - } else { <nl> - grpc_resource_quota_unref_internal ( exec_ctx , s - > resource_quota ) ; <nl> - gpr_free ( s ) ; <nl> - return GRPC_ERROR_CREATE_FROM_STATIC_STRING ( <nl> - GRPC_ARG_RESOURCE_QUOTA " must be a pointer to a buffer pool " ) ; <nl> - } <nl> - } <nl> - } <nl> + s - > channel_args = grpc_channel_args_copy ( args ) ; <nl> gpr_ref_init ( & s - > refs , 1 ) ; <nl> gpr_mu_init ( & s - > mu ) ; <nl> s - > active_ports = 0 ; <nl> static void destroy_server ( grpc_exec_ctx * exec_ctx , void * arg , <nl> grpc_winsocket_destroy ( sp - > socket ) ; <nl> gpr_free ( sp ) ; <nl> } <nl> - grpc_resource_quota_unref_internal ( exec_ctx , s - > resource_quota ) ; <nl> + grpc_channel_args_destroy ( exec_ctx , s - > channel_args ) ; <nl> gpr_free ( s ) ; <nl> } <nl> <nl> static void on_accept ( grpc_exec_ctx * exec_ctx , void * arg , grpc_error * error ) { <nl> gpr_free ( utf8_message ) ; <nl> } <nl> gpr_asprintf ( & fd_name , " tcp_server : % s " , peer_name_string ) ; <nl> - ep = grpc_tcp_create ( grpc_winsocket_create ( sock , fd_name ) , <nl> - sp - > server - > resource_quota , peer_name_string ) ; <nl> + ep = grpc_tcp_create ( exec_ctx , grpc_winsocket_create ( sock , fd_name ) , <nl> + sp - > server - > channel_args , peer_name_string ) ; <nl> gpr_free ( fd_name ) ; <nl> gpr_free ( peer_name_string ) ; <nl> } else { <nl> mmm a / src / core / lib / iomgr / tcp_windows . c <nl> ppp b / src / core / lib / iomgr / tcp_windows . c <nl> static grpc_endpoint_vtable vtable = { win_read , <nl> win_get_peer , <nl> win_get_fd } ; <nl> <nl> - grpc_endpoint * grpc_tcp_create ( grpc_winsocket * socket , <nl> - grpc_resource_quota * resource_quota , <nl> + grpc_endpoint * grpc_tcp_create ( grpc_exec_ctx * exec_ctx , grpc_winsocket * socket , <nl> + grpc_channel_args * channel_args , <nl> char * peer_string ) { <nl> + grpc_resource_quota * resource_quota = grpc_resource_quota_create ( NULL ) ; <nl> + if ( channel_args ! = NULL ) { <nl> + for ( size_t i = 0 ; i < channel_args - > num_args ; i + + ) { <nl> + if ( 0 = = strcmp ( channel_args - > args [ i ] . key , GRPC_ARG_RESOURCE_QUOTA ) ) { <nl> + grpc_resource_quota_unref_internal ( exec_ctx , resource_quota ) ; <nl> + resource_quota = grpc_resource_quota_ref_internal ( <nl> + channel_args - > args [ i ] . value . pointer . p ) ; <nl> + } <nl> + } <nl> + } <nl> grpc_tcp * tcp = ( grpc_tcp * ) gpr_malloc ( sizeof ( grpc_tcp ) ) ; <nl> memset ( tcp , 0 , sizeof ( grpc_tcp ) ) ; <nl> tcp - > base . vtable = & vtable ; <nl> mmm a / src / core / lib / iomgr / tcp_windows . h <nl> ppp b / src / core / lib / iomgr / tcp_windows . h <nl> <nl> / * Create a tcp endpoint given a winsock handle . <nl> * Takes ownership of the handle . <nl> * / <nl> - grpc_endpoint * grpc_tcp_create ( grpc_winsocket * socket , <nl> - grpc_resource_quota * resource_quota , <nl> + grpc_endpoint * grpc_tcp_create ( grpc_exec_ctx * exec_ctx , grpc_winsocket * socket , <nl> + grpc_channel_args * channel_args , <nl> char * peer_string ) ; <nl> <nl> grpc_error * grpc_tcp_prepare_socket ( SOCKET sock ) ; <nl> mmm a / src / core / lib / security / credentials / credentials . h <nl> ppp b / src / core / lib / security / credentials / credentials . h <nl> typedef enum { <nl> <nl> # define GRPC_SECURE_TOKEN_REFRESH_THRESHOLD_SECS 60 <nl> <nl> - # define GRPC_COMPUTE_ENGINE_METADATA_HOST " metadata " <nl> + # define GRPC_COMPUTE_ENGINE_METADATA_HOST " metadata . google . internal " <nl> # define GRPC_COMPUTE_ENGINE_METADATA_TOKEN_PATH \ <nl> " / computeMetadata / v1 / instance / service - accounts / default / token " <nl> <nl> mmm a / src / core / lib / security / transport / security_connector . c <nl> ppp b / src / core / lib / security / transport / security_connector . c <nl> grpc_server_security_connector * grpc_fake_server_security_connector_create ( <nl> <nl> typedef struct { <nl> grpc_channel_security_connector base ; <nl> - tsi_ssl_handshaker_factory * handshaker_factory ; <nl> + tsi_ssl_client_handshaker_factory * handshaker_factory ; <nl> char * target_name ; <nl> char * overridden_target_name ; <nl> } grpc_ssl_channel_security_connector ; <nl> <nl> typedef struct { <nl> grpc_server_security_connector base ; <nl> - tsi_ssl_handshaker_factory * handshaker_factory ; <nl> + tsi_ssl_server_handshaker_factory * handshaker_factory ; <nl> } grpc_ssl_server_security_connector ; <nl> <nl> static void ssl_channel_destroy ( grpc_exec_ctx * exec_ctx , <nl> static void ssl_channel_destroy ( grpc_exec_ctx * exec_ctx , <nl> ( grpc_ssl_channel_security_connector * ) sc ; <nl> grpc_call_credentials_unref ( exec_ctx , c - > base . request_metadata_creds ) ; <nl> if ( c - > handshaker_factory ! = NULL ) { <nl> - tsi_ssl_handshaker_factory_destroy ( c - > handshaker_factory ) ; <nl> + tsi_ssl_client_handshaker_factory_destroy ( c - > handshaker_factory ) ; <nl> } <nl> if ( c - > target_name ! = NULL ) gpr_free ( c - > target_name ) ; <nl> if ( c - > overridden_target_name ! = NULL ) gpr_free ( c - > overridden_target_name ) ; <nl> static void ssl_server_destroy ( grpc_exec_ctx * exec_ctx , <nl> grpc_ssl_server_security_connector * c = <nl> ( grpc_ssl_server_security_connector * ) sc ; <nl> if ( c - > handshaker_factory ! = NULL ) { <nl> - tsi_ssl_handshaker_factory_destroy ( c - > handshaker_factory ) ; <nl> + tsi_ssl_server_handshaker_factory_destroy ( c - > handshaker_factory ) ; <nl> } <nl> gpr_free ( sc ) ; <nl> } <nl> <nl> - static grpc_security_status ssl_create_handshaker ( <nl> - tsi_ssl_handshaker_factory * handshaker_factory , bool is_client , <nl> - const char * peer_name , tsi_handshaker * * handshaker ) { <nl> - tsi_result result = TSI_OK ; <nl> - if ( handshaker_factory = = NULL ) return GRPC_SECURITY_ERROR ; <nl> - result = tsi_ssl_handshaker_factory_create_handshaker ( <nl> - handshaker_factory , is_client ? peer_name : NULL , handshaker ) ; <nl> - if ( result ! = TSI_OK ) { <nl> - gpr_log ( GPR_ERROR , " Handshaker creation failed with error % s . " , <nl> - tsi_result_to_string ( result ) ) ; <nl> - return GRPC_SECURITY_ERROR ; <nl> - } <nl> - return GRPC_SECURITY_OK ; <nl> - } <nl> - <nl> static void ssl_channel_add_handshakers ( grpc_exec_ctx * exec_ctx , <nl> grpc_channel_security_connector * sc , <nl> grpc_handshake_manager * handshake_mgr ) { <nl> static void ssl_channel_add_handshakers ( grpc_exec_ctx * exec_ctx , <nl> ( grpc_ssl_channel_security_connector * ) sc ; <nl> / / Instantiate TSI handshaker . <nl> tsi_handshaker * tsi_hs = NULL ; <nl> - ssl_create_handshaker ( c - > handshaker_factory , true / * is_client * / , <nl> - c - > overridden_target_name ! = NULL <nl> - ? c - > overridden_target_name <nl> - : c - > target_name , <nl> - & tsi_hs ) ; <nl> + tsi_result result = tsi_ssl_client_handshaker_factory_create_handshaker ( <nl> + c - > handshaker_factory , <nl> + c - > overridden_target_name ! = NULL ? c - > overridden_target_name <nl> + : c - > target_name , <nl> + & tsi_hs ) ; <nl> + if ( result ! = TSI_OK ) { <nl> + gpr_log ( GPR_ERROR , " Handshaker creation failed with error % s . " , <nl> + tsi_result_to_string ( result ) ) ; <nl> + return ; <nl> + } <nl> + <nl> / / Create handshakers . <nl> grpc_handshake_manager_add ( handshake_mgr , grpc_security_handshaker_create ( <nl> exec_ctx , tsi_hs , & sc - > base ) ) ; <nl> static void ssl_server_add_handshakers ( grpc_exec_ctx * exec_ctx , <nl> ( grpc_ssl_server_security_connector * ) sc ; <nl> / / Instantiate TSI handshaker . <nl> tsi_handshaker * tsi_hs = NULL ; <nl> - ssl_create_handshaker ( c - > handshaker_factory , false / * is_client * / , <nl> - NULL / * peer_name * / , & tsi_hs ) ; <nl> + tsi_result result = tsi_ssl_server_handshaker_factory_create_handshaker ( <nl> + c - > handshaker_factory , & tsi_hs ) ; <nl> + if ( result ! = TSI_OK ) { <nl> + gpr_log ( GPR_ERROR , " Handshaker creation failed with error % s . " , <nl> + tsi_result_to_string ( result ) ) ; <nl> + return ; <nl> + } <nl> + <nl> / / Create handshakers . <nl> grpc_handshake_manager_add ( handshake_mgr , grpc_security_handshaker_create ( <nl> exec_ctx , tsi_hs , & sc - > base ) ) ; <nl> mmm a / src / core / lib / slice / slice_buffer . c <nl> ppp b / src / core / lib / slice / slice_buffer . c <nl> <nl> # define GROW ( x ) ( 3 * ( x ) / 2 ) <nl> <nl> static void maybe_embiggen ( grpc_slice_buffer * sb ) { <nl> - if ( sb - > base_slices ! = sb - > slices ) { <nl> - memmove ( sb - > base_slices , sb - > slices , sb - > count * sizeof ( grpc_slice ) ) ; <nl> - sb - > slices = sb - > base_slices ; <nl> - } <nl> - <nl> / * How far away from sb - > base_slices is sb - > slices pointer * / <nl> size_t slice_offset = ( size_t ) ( sb - > slices - sb - > base_slices ) ; <nl> size_t slice_count = sb - > count + slice_offset ; <nl> <nl> if ( slice_count = = sb - > capacity ) { <nl> - sb - > capacity = GROW ( sb - > capacity ) ; <nl> - GPR_ASSERT ( sb - > capacity > slice_count ) ; <nl> - if ( sb - > base_slices = = sb - > inlined ) { <nl> - sb - > base_slices = gpr_malloc ( sb - > capacity * sizeof ( grpc_slice ) ) ; <nl> - memcpy ( sb - > base_slices , sb - > inlined , slice_count * sizeof ( grpc_slice ) ) ; <nl> + if ( sb - > base_slices ! = sb - > slices ) { <nl> + / * Make room by moving elements if there ' s still space unused * / <nl> + memmove ( sb - > base_slices , sb - > slices , sb - > count * sizeof ( grpc_slice ) ) ; <nl> + sb - > slices = sb - > base_slices ; <nl> } else { <nl> - sb - > base_slices = <nl> - gpr_realloc ( sb - > base_slices , sb - > capacity * sizeof ( grpc_slice ) ) ; <nl> - } <nl> + / * Allocate more memory if no more space is available * / <nl> + sb - > capacity = GROW ( sb - > capacity ) ; <nl> + GPR_ASSERT ( sb - > capacity > slice_count ) ; <nl> + if ( sb - > base_slices = = sb - > inlined ) { <nl> + sb - > base_slices = gpr_malloc ( sb - > capacity * sizeof ( grpc_slice ) ) ; <nl> + memcpy ( sb - > base_slices , sb - > inlined , slice_count * sizeof ( grpc_slice ) ) ; <nl> + } else { <nl> + sb - > base_slices = <nl> + gpr_realloc ( sb - > base_slices , sb - > capacity * sizeof ( grpc_slice ) ) ; <nl> + } <nl> <nl> - sb - > slices = sb - > base_slices + slice_offset ; <nl> + sb - > slices = sb - > base_slices + slice_offset ; <nl> + } <nl> } <nl> } <nl> <nl> mmm a / src / core / lib / support / cpu_linux . c <nl> ppp b / src / core / lib / support / cpu_linux . c <nl> unsigned gpr_cpu_num_cores ( void ) { <nl> } <nl> <nl> unsigned gpr_cpu_current_cpu ( void ) { <nl> + # ifdef __GLIBC__ <nl> int cpu = sched_getcpu ( ) ; <nl> if ( cpu < 0 ) { <nl> gpr_log ( GPR_ERROR , " Error determining current CPU : % s \ n " , strerror ( errno ) ) ; <nl> return 0 ; <nl> } <nl> return ( unsigned ) cpu ; <nl> + # else <nl> + / / sched_getcpu ( ) is undefined on musl <nl> + return 0 ; <nl> + # endif <nl> } <nl> <nl> # endif / * GPR_CPU_LINUX * / <nl> mmm a / src / core / lib / support / wrap_memcpy . c <nl> ppp b / src / core / lib / support / wrap_memcpy . c <nl> <nl> * / <nl> <nl> # ifdef __linux__ <nl> - # ifdef __x86_64__ <nl> + # if defined ( __x86_64__ ) & & defined ( __GNU_LIBRARY__ ) <nl> __asm__ ( " . symver memcpy , memcpy @ GLIBC_2 . 2 . 5 " ) ; <nl> void * __wrap_memcpy ( void * destination , const void * source , size_t num ) { <nl> return memcpy ( destination , source , num ) ; <nl> mmm a / src / core / lib / surface / call . c <nl> ppp b / src / core / lib / surface / call . c <nl> typedef struct batch_control { <nl> grpc_transport_stream_op_batch op ; <nl> } batch_control ; <nl> <nl> + typedef struct { <nl> + gpr_mu child_list_mu ; <nl> + grpc_call * first_child ; <nl> + } parent_call ; <nl> + <nl> + typedef struct { <nl> + grpc_call * parent ; <nl> + / * * siblings : children of the same parent form a list , and this list is <nl> + protected under <nl> + parent - > mu * / <nl> + grpc_call * sibling_next ; <nl> + grpc_call * sibling_prev ; <nl> + } child_call ; <nl> + <nl> struct grpc_call { <nl> gpr_refcount ext_ref ; <nl> gpr_arena * arena ; <nl> grpc_completion_queue * cq ; <nl> grpc_polling_entity pollent ; <nl> grpc_channel * channel ; <nl> - grpc_call * parent ; <nl> - grpc_call * first_child ; <nl> gpr_timespec start_time ; <nl> - / * protects first_child , and child next / prev links * / <nl> - gpr_mu child_list_mu ; <nl> + / * parent_call * * / gpr_atm parent_call_atm ; <nl> + child_call * child_call ; <nl> <nl> / * client or server call * / <nl> bool is_client ; <nl> struct grpc_call { <nl> int send_extra_metadata_count ; <nl> gpr_timespec send_deadline ; <nl> <nl> - / * * siblings : children of the same parent form a list , and this list is <nl> - protected under <nl> - parent - > mu * / <nl> - grpc_call * sibling_next ; <nl> - grpc_call * sibling_prev ; <nl> - <nl> grpc_slice_buffer_stream sending_stream ; <nl> <nl> grpc_byte_stream * receiving_stream ; <nl> void * grpc_call_arena_alloc ( grpc_call * call , size_t size ) { <nl> return gpr_arena_alloc ( call - > arena , size ) ; <nl> } <nl> <nl> + static parent_call * get_or_create_parent_call ( grpc_call * call ) { <nl> + parent_call * p = ( parent_call * ) gpr_atm_acq_load ( & call - > parent_call_atm ) ; <nl> + if ( p = = NULL ) { <nl> + p = gpr_arena_alloc ( call - > arena , sizeof ( * p ) ) ; <nl> + gpr_mu_init ( & p - > child_list_mu ) ; <nl> + if ( ! gpr_atm_rel_cas ( & call - > parent_call_atm , ( gpr_atm ) NULL , ( gpr_atm ) p ) ) { <nl> + gpr_mu_destroy ( & p - > child_list_mu ) ; <nl> + p = ( parent_call * ) gpr_atm_acq_load ( & call - > parent_call_atm ) ; <nl> + } <nl> + } <nl> + return p ; <nl> + } <nl> + <nl> + static parent_call * get_parent_call ( grpc_call * call ) { <nl> + return ( parent_call * ) gpr_atm_acq_load ( & call - > parent_call_atm ) ; <nl> + } <nl> + <nl> grpc_error * grpc_call_create ( grpc_exec_ctx * exec_ctx , <nl> const grpc_call_create_args * args , <nl> grpc_call * * out_call ) { <nl> grpc_error * grpc_call_create ( grpc_exec_ctx * exec_ctx , <nl> gpr_ref_init ( & call - > ext_ref , 1 ) ; <nl> call - > arena = arena ; <nl> * out_call = call ; <nl> - gpr_mu_init ( & call - > child_list_mu ) ; <nl> call - > channel = args - > channel ; <nl> call - > cq = args - > cq ; <nl> - call - > parent = args - > parent_call ; <nl> call - > start_time = gpr_now ( GPR_CLOCK_MONOTONIC ) ; <nl> / * Always support no compression * / <nl> GPR_BITSET ( & call - > encodings_accepted_by_peer , GRPC_COMPRESS_NONE ) ; <nl> grpc_error * grpc_call_create ( grpc_exec_ctx * exec_ctx , <nl> gpr_convert_clock_type ( args - > send_deadline , GPR_CLOCK_MONOTONIC ) ; <nl> <nl> if ( args - > parent_call ! = NULL ) { <nl> + child_call * cc = call - > child_call = <nl> + gpr_arena_alloc ( arena , sizeof ( child_call ) ) ; <nl> + call - > child_call - > parent = args - > parent_call ; <nl> + <nl> GRPC_CALL_INTERNAL_REF ( args - > parent_call , " child " ) ; <nl> GPR_ASSERT ( call - > is_client ) ; <nl> GPR_ASSERT ( ! args - > parent_call - > is_client ) ; <nl> <nl> - gpr_mu_lock ( & args - > parent_call - > child_list_mu ) ; <nl> + parent_call * pc = get_or_create_parent_call ( args - > parent_call ) ; <nl> + <nl> + gpr_mu_lock ( & pc - > child_list_mu ) ; <nl> <nl> if ( args - > propagation_mask & GRPC_PROPAGATE_DEADLINE ) { <nl> send_deadline = gpr_time_min ( <nl> grpc_error * grpc_call_create ( grpc_exec_ctx * exec_ctx , <nl> } <nl> } <nl> <nl> - if ( args - > parent_call - > first_child = = NULL ) { <nl> - args - > parent_call - > first_child = call ; <nl> - call - > sibling_next = call - > sibling_prev = call ; <nl> + if ( pc - > first_child = = NULL ) { <nl> + pc - > first_child = call ; <nl> + cc - > sibling_next = cc - > sibling_prev = call ; <nl> } else { <nl> - call - > sibling_next = args - > parent_call - > first_child ; <nl> - call - > sibling_prev = args - > parent_call - > first_child - > sibling_prev ; <nl> - call - > sibling_next - > sibling_prev = call - > sibling_prev - > sibling_next = <nl> - call ; <nl> + cc - > sibling_next = pc - > first_child ; <nl> + cc - > sibling_prev = pc - > first_child - > child_call - > sibling_prev ; <nl> + cc - > sibling_next - > child_call - > sibling_prev = <nl> + cc - > sibling_prev - > child_call - > sibling_next = call ; <nl> } <nl> <nl> - gpr_mu_unlock ( & args - > parent_call - > child_list_mu ) ; <nl> + gpr_mu_unlock ( & pc - > child_list_mu ) ; <nl> } <nl> <nl> call - > send_deadline = send_deadline ; <nl> static void destroy_call ( grpc_exec_ctx * exec_ctx , void * call , <nl> if ( c - > receiving_stream ! = NULL ) { <nl> grpc_byte_stream_destroy ( exec_ctx , c - > receiving_stream ) ; <nl> } <nl> - gpr_mu_destroy ( & c - > child_list_mu ) ; <nl> + parent_call * pc = get_parent_call ( c ) ; <nl> + if ( pc ! = NULL ) { <nl> + gpr_mu_destroy ( & pc - > child_list_mu ) ; <nl> + } <nl> for ( ii = 0 ; ii < c - > send_extra_metadata_count ; ii + + ) { <nl> GRPC_MDELEM_UNREF ( exec_ctx , c - > send_extra_metadata [ ii ] . md ) ; <nl> } <nl> void grpc_call_ref ( grpc_call * c ) { gpr_ref ( & c - > ext_ref ) ; } <nl> void grpc_call_unref ( grpc_call * c ) { <nl> if ( ! gpr_unref ( & c - > ext_ref ) ) return ; <nl> <nl> - int cancel ; <nl> - grpc_call * parent = c - > parent ; <nl> + child_call * cc = c - > child_call ; <nl> grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT ; <nl> <nl> GPR_TIMER_BEGIN ( " grpc_call_unref " , 0 ) ; <nl> GRPC_API_TRACE ( " grpc_call_unref ( c = % p ) " , 1 , ( c ) ) ; <nl> <nl> - if ( parent ) { <nl> - gpr_mu_lock ( & parent - > child_list_mu ) ; <nl> - if ( c = = parent - > first_child ) { <nl> - parent - > first_child = c - > sibling_next ; <nl> - if ( c = = parent - > first_child ) { <nl> - parent - > first_child = NULL ; <nl> + if ( cc ) { <nl> + parent_call * pc = get_parent_call ( cc - > parent ) ; <nl> + gpr_mu_lock ( & pc - > child_list_mu ) ; <nl> + if ( c = = pc - > first_child ) { <nl> + pc - > first_child = cc - > sibling_next ; <nl> + if ( c = = pc - > first_child ) { <nl> + pc - > first_child = NULL ; <nl> } <nl> } <nl> - c - > sibling_prev - > sibling_next = c - > sibling_next ; <nl> - c - > sibling_next - > sibling_prev = c - > sibling_prev ; <nl> - gpr_mu_unlock ( & parent - > child_list_mu ) ; <nl> - GRPC_CALL_INTERNAL_UNREF ( & exec_ctx , parent , " child " ) ; <nl> + cc - > sibling_prev - > child_call - > sibling_next = cc - > sibling_next ; <nl> + cc - > sibling_next - > child_call - > sibling_prev = cc - > sibling_prev ; <nl> + gpr_mu_unlock ( & pc - > child_list_mu ) ; <nl> + GRPC_CALL_INTERNAL_UNREF ( & exec_ctx , cc - > parent , " child " ) ; <nl> } <nl> <nl> GPR_ASSERT ( ! c - > destroy_called ) ; <nl> c - > destroy_called = 1 ; <nl> - cancel = gpr_atm_acq_load ( & c - > any_ops_sent_atm ) & & <nl> - ! gpr_atm_acq_load ( & c - > received_final_op_atm ) ; <nl> + bool cancel = gpr_atm_acq_load ( & c - > any_ops_sent_atm ) ! = 0 & & <nl> + gpr_atm_acq_load ( & c - > received_final_op_atm ) = = 0 ; <nl> if ( cancel ) { <nl> cancel_with_error ( & exec_ctx , c , STATUS_FROM_API_OVERRIDE , <nl> GRPC_ERROR_CANCELLED ) ; <nl> static grpc_error * consolidate_batch_errors ( batch_control * bctl ) { <nl> <nl> static void post_batch_completion ( grpc_exec_ctx * exec_ctx , <nl> batch_control * bctl ) { <nl> - grpc_call * child_call ; <nl> grpc_call * next_child_call ; <nl> grpc_call * call = bctl - > call ; <nl> grpc_error * error = consolidate_batch_errors ( bctl ) ; <nl> static void post_batch_completion ( grpc_exec_ctx * exec_ctx , <nl> <nl> / * propagate cancellation to any interested children * / <nl> gpr_atm_rel_store ( & call - > received_final_op_atm , 1 ) ; <nl> - gpr_mu_lock ( & call - > child_list_mu ) ; <nl> - child_call = call - > first_child ; <nl> - if ( child_call ! = NULL ) { <nl> - do { <nl> - next_child_call = child_call - > sibling_next ; <nl> - if ( child_call - > cancellation_is_inherited ) { <nl> - GRPC_CALL_INTERNAL_REF ( child_call , " propagate_cancel " ) ; <nl> - cancel_with_error ( exec_ctx , child_call , STATUS_FROM_API_OVERRIDE , <nl> - GRPC_ERROR_CANCELLED ) ; <nl> - GRPC_CALL_INTERNAL_UNREF ( exec_ctx , child_call , " propagate_cancel " ) ; <nl> - } <nl> - child_call = next_child_call ; <nl> - } while ( child_call ! = call - > first_child ) ; <nl> + parent_call * pc = get_parent_call ( call ) ; <nl> + if ( pc ! = NULL ) { <nl> + grpc_call * child ; <nl> + gpr_mu_lock ( & pc - > child_list_mu ) ; <nl> + child = pc - > first_child ; <nl> + if ( child ! = NULL ) { <nl> + do { <nl> + next_child_call = child - > child_call - > sibling_next ; <nl> + if ( child - > cancellation_is_inherited ) { <nl> + GRPC_CALL_INTERNAL_REF ( child , " propagate_cancel " ) ; <nl> + cancel_with_error ( exec_ctx , child , STATUS_FROM_API_OVERRIDE , <nl> + GRPC_ERROR_CANCELLED ) ; <nl> + GRPC_CALL_INTERNAL_UNREF ( exec_ctx , child , " propagate_cancel " ) ; <nl> + } <nl> + child = next_child_call ; <nl> + } while ( child ! = pc - > first_child ) ; <nl> + } <nl> + gpr_mu_unlock ( & pc - > child_list_mu ) ; <nl> } <nl> - gpr_mu_unlock ( & call - > child_list_mu ) ; <nl> <nl> if ( call - > is_client ) { <nl> get_final_status ( call , set_status_value_directly , <nl> mmm a / src / core / lib / surface / completion_queue . c <nl> ppp b / src / core / lib / surface / completion_queue . c <nl> static void dump_pending_tags ( grpc_completion_queue * cc ) { } <nl> grpc_event grpc_completion_queue_next ( grpc_completion_queue * cc , <nl> gpr_timespec deadline , void * reserved ) { <nl> grpc_event ret ; <nl> - grpc_pollset_worker * worker = NULL ; <nl> gpr_timespec now ; <nl> <nl> GPR_TIMER_BEGIN ( " grpc_completion_queue_next " , 0 ) ; <nl> grpc_event grpc_completion_queue_next ( grpc_completion_queue * cc , <nl> gpr_mu_lock ( cc - > mu ) ; <nl> continue ; <nl> } else { <nl> - grpc_error * err = grpc_pollset_work ( & exec_ctx , POLLSET_FROM_CQ ( cc ) , <nl> - & worker , now , iteration_deadline ) ; <nl> + grpc_error * err = grpc_pollset_work ( & exec_ctx , POLLSET_FROM_CQ ( cc ) , NULL , <nl> + now , iteration_deadline ) ; <nl> if ( err ! = GRPC_ERROR_NONE ) { <nl> gpr_mu_unlock ( cc - > mu ) ; <nl> const char * msg = grpc_error_string ( err ) ; <nl> mmm a / src / core / lib / surface / init_secure . c <nl> ppp b / src / core / lib / surface / init_secure . c <nl> <nl> * <nl> * / <nl> <nl> + # include < grpc / support / port_platform . h > <nl> + <nl> # include " src / core / lib / surface / init . h " <nl> <nl> # include < limits . h > <nl> mmm a / src / core / tsi / ssl_transport_security . c <nl> ppp b / src / core / tsi / ssl_transport_security . c <nl> <nl> <nl> / * mmm Structure definitions . mmm * / <nl> <nl> - struct tsi_ssl_handshaker_factory { <nl> - tsi_result ( * create_handshaker ) ( tsi_ssl_handshaker_factory * self , <nl> - const char * server_name_indication , <nl> - tsi_handshaker * * handshaker ) ; <nl> - void ( * destroy ) ( tsi_ssl_handshaker_factory * self ) ; <nl> - } ; <nl> - <nl> - typedef struct { <nl> - tsi_ssl_handshaker_factory base ; <nl> + struct tsi_ssl_client_handshaker_factory { <nl> SSL_CTX * ssl_context ; <nl> unsigned char * alpn_protocol_list ; <nl> size_t alpn_protocol_list_length ; <nl> - } tsi_ssl_client_handshaker_factory ; <nl> - <nl> - typedef struct { <nl> - tsi_ssl_handshaker_factory base ; <nl> + } ; <nl> <nl> + struct tsi_ssl_server_handshaker_factory { <nl> / * Several contexts to support SNI . <nl> The tsi_peer array contains the subject names of the server certificates <nl> associated with the contexts at the same index . * / <nl> typedef struct { <nl> size_t ssl_context_count ; <nl> unsigned char * alpn_protocol_list ; <nl> size_t alpn_protocol_list_length ; <nl> - } tsi_ssl_server_handshaker_factory ; <nl> + } ; <nl> <nl> typedef struct { <nl> tsi_handshaker base ; <nl> static const tsi_handshaker_vtable handshaker_vtable = { <nl> <nl> / * mmm tsi_ssl_handshaker_factory common methods . mmm * / <nl> <nl> - tsi_result tsi_ssl_handshaker_factory_create_handshaker ( <nl> - tsi_ssl_handshaker_factory * self , const char * server_name_indication , <nl> - tsi_handshaker * * handshaker ) { <nl> - if ( self = = NULL | | handshaker = = NULL ) return TSI_INVALID_ARGUMENT ; <nl> - return self - > create_handshaker ( self , server_name_indication , handshaker ) ; <nl> - } <nl> - <nl> - void tsi_ssl_handshaker_factory_destroy ( tsi_ssl_handshaker_factory * self ) { <nl> - if ( self = = NULL ) return ; <nl> - self - > destroy ( self ) ; <nl> - } <nl> - <nl> static tsi_result create_tsi_ssl_handshaker ( SSL_CTX * ctx , int is_client , <nl> const char * server_name_indication , <nl> tsi_handshaker * * handshaker ) { <nl> static int select_protocol_list ( const unsigned char * * out , <nl> return SSL_TLSEXT_ERR_NOACK ; <nl> } <nl> <nl> - / * mmm tsi_ssl__client_handshaker_factory methods implementation . mmm * / <nl> + / * mmm tsi_ssl_client_handshaker_factory methods implementation . mmm * / <nl> <nl> - static tsi_result ssl_client_handshaker_factory_create_handshaker ( <nl> - tsi_ssl_handshaker_factory * self , const char * server_name_indication , <nl> + tsi_result tsi_ssl_client_handshaker_factory_create_handshaker ( <nl> + tsi_ssl_client_handshaker_factory * self , const char * server_name_indication , <nl> tsi_handshaker * * handshaker ) { <nl> - tsi_ssl_client_handshaker_factory * impl = <nl> - ( tsi_ssl_client_handshaker_factory * ) self ; <nl> - return create_tsi_ssl_handshaker ( impl - > ssl_context , 1 , server_name_indication , <nl> + return create_tsi_ssl_handshaker ( self - > ssl_context , 1 , server_name_indication , <nl> handshaker ) ; <nl> } <nl> <nl> - static void ssl_client_handshaker_factory_destroy ( <nl> - tsi_ssl_handshaker_factory * self ) { <nl> - tsi_ssl_client_handshaker_factory * impl = <nl> - ( tsi_ssl_client_handshaker_factory * ) self ; <nl> - if ( impl - > ssl_context ! = NULL ) SSL_CTX_free ( impl - > ssl_context ) ; <nl> - if ( impl - > alpn_protocol_list ! = NULL ) gpr_free ( impl - > alpn_protocol_list ) ; <nl> - gpr_free ( impl ) ; <nl> + void tsi_ssl_client_handshaker_factory_destroy ( <nl> + tsi_ssl_client_handshaker_factory * self ) { <nl> + if ( self - > ssl_context ! = NULL ) SSL_CTX_free ( self - > ssl_context ) ; <nl> + if ( self - > alpn_protocol_list ! = NULL ) gpr_free ( self - > alpn_protocol_list ) ; <nl> + gpr_free ( self ) ; <nl> } <nl> <nl> static int client_handshaker_factory_npn_callback ( SSL * ssl , unsigned char * * out , <nl> static int client_handshaker_factory_npn_callback ( SSL * ssl , unsigned char * * out , <nl> <nl> / * mmm tsi_ssl_server_handshaker_factory methods implementation . mmm * / <nl> <nl> - static tsi_result ssl_server_handshaker_factory_create_handshaker ( <nl> - tsi_ssl_handshaker_factory * self , const char * server_name_indication , <nl> - tsi_handshaker * * handshaker ) { <nl> - tsi_ssl_server_handshaker_factory * impl = <nl> - ( tsi_ssl_server_handshaker_factory * ) self ; <nl> - if ( impl - > ssl_context_count = = 0 | | server_name_indication ! = NULL ) { <nl> - return TSI_INVALID_ARGUMENT ; <nl> - } <nl> + tsi_result tsi_ssl_server_handshaker_factory_create_handshaker ( <nl> + tsi_ssl_server_handshaker_factory * self , tsi_handshaker * * handshaker ) { <nl> + if ( self - > ssl_context_count = = 0 ) return TSI_INVALID_ARGUMENT ; <nl> / * Create the handshaker with the first context . We will switch if needed <nl> because of SNI in ssl_server_handshaker_factory_servername_callback . * / <nl> - return create_tsi_ssl_handshaker ( impl - > ssl_contexts [ 0 ] , 0 , NULL , handshaker ) ; <nl> + return create_tsi_ssl_handshaker ( self - > ssl_contexts [ 0 ] , 0 , NULL , handshaker ) ; <nl> } <nl> <nl> - static void ssl_server_handshaker_factory_destroy ( <nl> - tsi_ssl_handshaker_factory * self ) { <nl> - tsi_ssl_server_handshaker_factory * impl = <nl> - ( tsi_ssl_server_handshaker_factory * ) self ; <nl> + void tsi_ssl_server_handshaker_factory_destroy ( <nl> + tsi_ssl_server_handshaker_factory * self ) { <nl> size_t i ; <nl> - for ( i = 0 ; i < impl - > ssl_context_count ; i + + ) { <nl> - if ( impl - > ssl_contexts [ i ] ! = NULL ) { <nl> - SSL_CTX_free ( impl - > ssl_contexts [ i ] ) ; <nl> - tsi_peer_destruct ( & impl - > ssl_context_x509_subject_names [ i ] ) ; <nl> + for ( i = 0 ; i < self - > ssl_context_count ; i + + ) { <nl> + if ( self - > ssl_contexts [ i ] ! = NULL ) { <nl> + SSL_CTX_free ( self - > ssl_contexts [ i ] ) ; <nl> + tsi_peer_destruct ( & self - > ssl_context_x509_subject_names [ i ] ) ; <nl> } <nl> } <nl> - if ( impl - > ssl_contexts ! = NULL ) gpr_free ( impl - > ssl_contexts ) ; <nl> - if ( impl - > ssl_context_x509_subject_names ! = NULL ) { <nl> - gpr_free ( impl - > ssl_context_x509_subject_names ) ; <nl> + if ( self - > ssl_contexts ! = NULL ) gpr_free ( self - > ssl_contexts ) ; <nl> + if ( self - > ssl_context_x509_subject_names ! = NULL ) { <nl> + gpr_free ( self - > ssl_context_x509_subject_names ) ; <nl> } <nl> - if ( impl - > alpn_protocol_list ! = NULL ) gpr_free ( impl - > alpn_protocol_list ) ; <nl> - gpr_free ( impl ) ; <nl> + if ( self - > alpn_protocol_list ! = NULL ) gpr_free ( self - > alpn_protocol_list ) ; <nl> + gpr_free ( self ) ; <nl> } <nl> <nl> static int does_entry_match_name ( const char * entry , size_t entry_length , <nl> tsi_result tsi_create_ssl_client_handshaker_factory ( <nl> const unsigned char * pem_root_certs , size_t pem_root_certs_size , <nl> const char * cipher_list , const unsigned char * * alpn_protocols , <nl> const unsigned char * alpn_protocols_lengths , uint16_t num_alpn_protocols , <nl> - tsi_ssl_handshaker_factory * * factory ) { <nl> + tsi_ssl_client_handshaker_factory * * factory ) { <nl> SSL_CTX * ssl_context = NULL ; <nl> tsi_ssl_client_handshaker_factory * impl = NULL ; <nl> tsi_result result = TSI_OK ; <nl> tsi_result tsi_create_ssl_client_handshaker_factory ( <nl> } <nl> } while ( 0 ) ; <nl> if ( result ! = TSI_OK ) { <nl> - ssl_client_handshaker_factory_destroy ( & impl - > base ) ; <nl> + tsi_ssl_client_handshaker_factory_destroy ( impl ) ; <nl> return result ; <nl> } <nl> SSL_CTX_set_verify ( ssl_context , SSL_VERIFY_PEER , NULL ) ; <nl> / * TODO ( jboeuf ) : Add revocation verification . * / <nl> <nl> - impl - > base . create_handshaker = <nl> - ssl_client_handshaker_factory_create_handshaker ; <nl> - impl - > base . destroy = ssl_client_handshaker_factory_destroy ; <nl> - * factory = & impl - > base ; <nl> + * factory = impl ; <nl> return TSI_OK ; <nl> } <nl> <nl> tsi_result tsi_create_ssl_server_handshaker_factory ( <nl> size_t pem_client_root_certs_size , int force_client_auth , <nl> const char * cipher_list , const unsigned char * * alpn_protocols , <nl> const unsigned char * alpn_protocols_lengths , uint16_t num_alpn_protocols , <nl> - tsi_ssl_handshaker_factory * * factory ) { <nl> + tsi_ssl_server_handshaker_factory * * factory ) { <nl> return tsi_create_ssl_server_handshaker_factory_ex ( <nl> pem_private_keys , pem_private_keys_sizes , pem_cert_chains , <nl> pem_cert_chains_sizes , key_cert_pair_count , pem_client_root_certs , <nl> tsi_result tsi_create_ssl_server_handshaker_factory_ex ( <nl> tsi_client_certificate_request_type client_certificate_request , <nl> const char * cipher_list , const unsigned char * * alpn_protocols , <nl> const unsigned char * alpn_protocols_lengths , uint16_t num_alpn_protocols , <nl> - tsi_ssl_handshaker_factory * * factory ) { <nl> + tsi_ssl_server_handshaker_factory * * factory ) { <nl> tsi_ssl_server_handshaker_factory * impl = NULL ; <nl> tsi_result result = TSI_OK ; <nl> size_t i = 0 ; <nl> tsi_result tsi_create_ssl_server_handshaker_factory_ex ( <nl> } <nl> <nl> impl = gpr_zalloc ( sizeof ( * impl ) ) ; <nl> - impl - > base . create_handshaker = <nl> - ssl_server_handshaker_factory_create_handshaker ; <nl> - impl - > base . destroy = ssl_server_handshaker_factory_destroy ; <nl> impl - > ssl_contexts = gpr_zalloc ( key_cert_pair_count * sizeof ( SSL_CTX * ) ) ; <nl> impl - > ssl_context_x509_subject_names = <nl> gpr_zalloc ( key_cert_pair_count * sizeof ( tsi_peer ) ) ; <nl> if ( impl - > ssl_contexts = = NULL | | <nl> impl - > ssl_context_x509_subject_names = = NULL ) { <nl> - tsi_ssl_handshaker_factory_destroy ( & impl - > base ) ; <nl> + tsi_ssl_server_handshaker_factory_destroy ( impl ) ; <nl> return TSI_OUT_OF_RESOURCES ; <nl> } <nl> impl - > ssl_context_count = key_cert_pair_count ; <nl> tsi_result tsi_create_ssl_server_handshaker_factory_ex ( <nl> alpn_protocols , alpn_protocols_lengths , num_alpn_protocols , <nl> & impl - > alpn_protocol_list , & impl - > alpn_protocol_list_length ) ; <nl> if ( result ! = TSI_OK ) { <nl> - tsi_ssl_handshaker_factory_destroy ( & impl - > base ) ; <nl> + tsi_ssl_server_handshaker_factory_destroy ( impl ) ; <nl> return result ; <nl> } <nl> } <nl> tsi_result tsi_create_ssl_server_handshaker_factory_ex ( <nl> } while ( 0 ) ; <nl> <nl> if ( result ! = TSI_OK ) { <nl> - tsi_ssl_handshaker_factory_destroy ( & impl - > base ) ; <nl> + tsi_ssl_server_handshaker_factory_destroy ( impl ) ; <nl> return result ; <nl> } <nl> } <nl> - * factory = & impl - > base ; <nl> + * factory = impl ; <nl> return TSI_OK ; <nl> } <nl> <nl> mmm a / src / core / tsi / ssl_transport_security . h <nl> ppp b / src / core / tsi / ssl_transport_security . h <nl> extern " C " { <nl> <nl> # define TSI_SSL_ALPN_SELECTED_PROTOCOL " ssl_alpn_selected_protocol " <nl> <nl> - / * mmm tsi_ssl_handshaker_factory object mmm <nl> + / * mmm tsi_ssl_client_handshaker_factory object mmm <nl> <nl> - This object creates tsi_handshaker objects implemented in terms of the <nl> - TLS 1 . 2 specificiation . * / <nl> + This object creates a client tsi_handshaker objects implemented in terms of <nl> + the TLS 1 . 2 specificiation . * / <nl> <nl> - typedef struct tsi_ssl_handshaker_factory tsi_ssl_handshaker_factory ; <nl> + typedef struct tsi_ssl_client_handshaker_factory <nl> + tsi_ssl_client_handshaker_factory ; <nl> <nl> / * Creates a client handshaker factory . <nl> - pem_private_key is the buffer containing the PEM encoding of the client ' s <nl> tsi_result tsi_create_ssl_client_handshaker_factory ( <nl> const unsigned char * pem_root_certs , size_t pem_root_certs_size , <nl> const char * cipher_suites , const unsigned char * * alpn_protocols , <nl> const unsigned char * alpn_protocols_lengths , uint16_t num_alpn_protocols , <nl> - tsi_ssl_handshaker_factory * * factory ) ; <nl> + tsi_ssl_client_handshaker_factory * * factory ) ; <nl> + <nl> + / * Creates a client handshaker . <nl> + - self is the factory from which the handshaker will be created . <nl> + - server_name_indication indicates the name of the server the client is <nl> + trying to connect to which will be relayed to the server using the SNI <nl> + extension . <nl> + - handshaker is the address of the handshaker pointer to be created . <nl> + <nl> + - This method returns TSI_OK on success or TSI_INVALID_PARAMETER in the case <nl> + where a parameter is invalid . * / <nl> + tsi_result tsi_ssl_client_handshaker_factory_create_handshaker ( <nl> + tsi_ssl_client_handshaker_factory * self , const char * server_name_indication , <nl> + tsi_handshaker * * handshaker ) ; <nl> + <nl> + / * Destroys the handshaker factory . WARNING : it is unsafe to destroy a factory <nl> + while handshakers created with this factory are still in use . * / <nl> + void tsi_ssl_client_handshaker_factory_destroy ( <nl> + tsi_ssl_client_handshaker_factory * self ) ; <nl> + <nl> + / * mmm tsi_ssl_server_handshaker_factory object mmm <nl> + <nl> + This object creates a client tsi_handshaker objects implemented in terms of <nl> + the TLS 1 . 2 specificiation . * / <nl> + <nl> + typedef struct tsi_ssl_server_handshaker_factory <nl> + tsi_ssl_server_handshaker_factory ; <nl> <nl> / * Creates a server handshaker factory . <nl> - version indicates which version of the specification to use . <nl> tsi_result tsi_create_ssl_server_handshaker_factory ( <nl> size_t pem_client_root_certs_size , int force_client_auth , <nl> const char * cipher_suites , const unsigned char * * alpn_protocols , <nl> const unsigned char * alpn_protocols_lengths , uint16_t num_alpn_protocols , <nl> - tsi_ssl_handshaker_factory * * factory ) ; <nl> + tsi_ssl_server_handshaker_factory * * factory ) ; <nl> <nl> / * Same as tsi_create_ssl_server_handshaker_factory method except uses <nl> tsi_client_certificate_request_type to support more ways to handle client <nl> tsi_result tsi_create_ssl_server_handshaker_factory_ex ( <nl> tsi_client_certificate_request_type client_certificate_request , <nl> const char * cipher_suites , const unsigned char * * alpn_protocols , <nl> const unsigned char * alpn_protocols_lengths , uint16_t num_alpn_protocols , <nl> - tsi_ssl_handshaker_factory * * factory ) ; <nl> + tsi_ssl_server_handshaker_factory * * factory ) ; <nl> <nl> - / * Creates a handshaker . <nl> + / * Creates a server handshaker . <nl> - self is the factory from which the handshaker will be created . <nl> - - server_name_indication indicates the name of the server the client is <nl> - trying to connect to which will be relayed to the server using the SNI <nl> - extension . <nl> - This parameter must be NULL for a server handshaker factory . <nl> - - handhshaker is the address of the handshaker pointer to be created . <nl> + - handshaker is the address of the handshaker pointer to be created . <nl> <nl> - This method returns TSI_OK on success or TSI_INVALID_PARAMETER in the case <nl> where a parameter is invalid . * / <nl> - tsi_result tsi_ssl_handshaker_factory_create_handshaker ( <nl> - tsi_ssl_handshaker_factory * self , const char * server_name_indication , <nl> - tsi_handshaker * * handshaker ) ; <nl> + tsi_result tsi_ssl_server_handshaker_factory_create_handshaker ( <nl> + tsi_ssl_server_handshaker_factory * self , tsi_handshaker * * handshaker ) ; <nl> <nl> / * Destroys the handshaker factory . WARNING : it is unsafe to destroy a factory <nl> while handshakers created with this factory are still in use . * / <nl> - void tsi_ssl_handshaker_factory_destroy ( tsi_ssl_handshaker_factory * self ) ; <nl> + void tsi_ssl_server_handshaker_factory_destroy ( <nl> + tsi_ssl_server_handshaker_factory * self ) ; <nl> <nl> / * Util that checks that an ssl peer matches a specific name . <nl> Still TODO ( jboeuf ) : <nl> old mode 100644 <nl> new mode 100755 <nl> index 9ef98529e85 . . 6ac25aa1f02 <nl> mmm a / src / csharp / Grpc . Auth / Grpc . Auth . csproj <nl> ppp b / src / csharp / Grpc . Auth / Grpc . Auth . csproj <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project DefaultTargets = " Build " ToolsVersion = " 4 . 0 " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> + < Project Sdk = " Microsoft . NET . Sdk " > <nl> + <nl> + < Import Project = " . . \ Grpc . Core \ Version . csproj . include " / > <nl> + < Import Project = " . . \ Grpc . Core \ Common . csproj . include " / > <nl> + <nl> < PropertyGroup > <nl> - < Configuration Condition = " ' $ ( Configuration ) ' = = ' ' " > Debug < / Configuration > <nl> - < Platform Condition = " ' $ ( Platform ) ' = = ' ' " > AnyCPU < / Platform > <nl> - < ProjectGuid > { AE21D0EE - 9A2C - 4C15 - AB7F - 5224EED5B0EA } < / ProjectGuid > <nl> - < OutputType > Library < / OutputType > <nl> - < RootNamespace > Grpc . Auth < / RootNamespace > <nl> + < Copyright > Copyright 2015 , Google Inc . < / Copyright > <nl> + < AssemblyTitle > gRPC C # Auth < / AssemblyTitle > <nl> + < VersionPrefix > $ ( GrpcCsharpVersion ) < / VersionPrefix > <nl> + < Authors > Google Inc . < / Authors > <nl> + < TargetFrameworks > net45 ; netstandard1 . 5 < / TargetFrameworks > <nl> + < DefineConstants > $ ( DefineConstants ) ; SIGNED < / DefineConstants > <nl> < AssemblyName > Grpc . Auth < / AssemblyName > <nl> - < TargetFrameworkVersion > v4 . 5 < / TargetFrameworkVersion > <nl> - < DocumentationFile > bin \ $ ( Configuration ) \ Grpc . Auth . Xml < / DocumentationFile > <nl> - < NuGetPackageImportStamp > 455903a2 < / NuGetPackageImportStamp > <nl> - < / PropertyGroup > <nl> - < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | AnyCPU ' " > <nl> - < DebugSymbols > true < / DebugSymbols > <nl> - < DebugType > full < / DebugType > <nl> - < Optimize > false < / Optimize > <nl> - < OutputPath > bin \ Debug < / OutputPath > <nl> - < DefineConstants > DEBUG ; < / DefineConstants > <nl> - < ErrorReport > prompt < / ErrorReport > <nl> - < WarningLevel > 4 < / WarningLevel > <nl> - < ConsolePause > false < / ConsolePause > <nl> - < / PropertyGroup > <nl> - < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Release | AnyCPU ' " > <nl> - < DebugType > pdbonly < / DebugType > <nl> - < Optimize > true < / Optimize > <nl> - < OutputPath > bin \ Release < / OutputPath > <nl> - < ErrorReport > prompt < / ErrorReport > <nl> - < WarningLevel > 4 < / WarningLevel > <nl> - < ConsolePause > false < / ConsolePause > <nl> + < PackageId > Grpc . Auth < / PackageId > <nl> + < PackageTags > gRPC RPC Protocol HTTP / 2 Auth OAuth2 < / PackageTags > <nl> + < PackageProjectUrl > https : / / github . com / grpc / grpc < / PackageProjectUrl > <nl> + < PackageLicenseUrl > https : / / github . com / grpc / grpc / blob / master / LICENSE < / PackageLicenseUrl > <nl> + < NetStandardImplicitPackageVersion Condition = " ' $ ( TargetFramework ) ' = = ' netstandard1 . 5 ' " > 1 . 6 . 0 < / NetStandardImplicitPackageVersion > <nl> < / PropertyGroup > <nl> + <nl> < ItemGroup > <nl> - < Reference Include = " System " / > <nl> - < Reference Include = " System . Net " / > <nl> - < Reference Include = " System . Net . Http " / > <nl> - < Reference Include = " System . Net . Http . WebRequest " / > <nl> - < Reference Include = " Zlib . Portable " > <nl> - < HintPath > . . \ packages \ Zlib . Portable . Signed . 1 . 11 . 0 \ lib \ portable - net4 + sl5 + wp8 + win8 + wpa81 + MonoTouch + MonoAndroid \ Zlib . Portable . dll < / HintPath > <nl> - < / Reference > <nl> - < Reference Include = " Google . Apis . Core " > <nl> - < HintPath > . . \ packages \ Google . Apis . Core . 1 . 21 . 0 \ lib \ net45 \ Google . Apis . Core . dll < / HintPath > <nl> - < / Reference > <nl> - < Reference Include = " Google . Apis " > <nl> - < HintPath > . . \ packages \ Google . Apis . 1 . 21 . 0 \ lib \ net45 \ Google . Apis . dll < / HintPath > <nl> - < / Reference > <nl> - < Reference Include = " Google . Apis . PlatformServices " > <nl> - < HintPath > . . \ packages \ Google . Apis . 1 . 21 . 0 \ lib \ net45 \ Google . Apis . PlatformServices . dll < / HintPath > <nl> - < / Reference > <nl> - < Reference Include = " Google . Apis . Auth " > <nl> - < HintPath > . . \ packages \ Google . Apis . Auth . 1 . 21 . 0 \ lib \ net45 \ Google . Apis . Auth . dll < / HintPath > <nl> - < / Reference > <nl> - < Reference Include = " Google . Apis . Auth . PlatformServices " > <nl> - < HintPath > . . \ packages \ Google . Apis . Auth . 1 . 21 . 0 \ lib \ net45 \ Google . Apis . Auth . PlatformServices . dll < / HintPath > <nl> - < / Reference > <nl> - < Reference Include = " Newtonsoft . Json " > <nl> - < HintPath > . . \ packages \ Newtonsoft . Json . 9 . 0 . 1 \ lib \ net45 \ Newtonsoft . Json . dll < / HintPath > <nl> - < / Reference > <nl> + < Compile Include = " . . \ Grpc . Core \ Version . cs " / > <nl> < / ItemGroup > <nl> + <nl> < ItemGroup > <nl> - < Compile Include = " . . \ Grpc . Core \ Version . cs " > <nl> - < Link > Version . cs < / Link > <nl> - < / Compile > <nl> - < Compile Include = " GoogleGrpcCredentials . cs " / > <nl> - < Compile Include = " Properties \ AssemblyInfo . cs " / > <nl> - < Compile Include = " GoogleAuthInterceptors . cs " / > <nl> + < ProjectReference Include = " . . / Grpc . Core / Grpc . Core . csproj " / > <nl> < / ItemGroup > <nl> - < Import Project = " $ ( MSBuildBinPath ) \ Microsoft . CSharp . targets " / > <nl> + <nl> < ItemGroup > <nl> - < ProjectReference Include = " . . \ Grpc . Core \ Grpc . Core . csproj " > <nl> - < Project > { CCC4440E - 49F7 - 4790 - B0AF - FEABB0837AE7 } < / Project > <nl> - < Name > Grpc . Core < / Name > <nl> - < / ProjectReference > <nl> + < PackageReference Include = " Google . Apis . Auth " Version = " 1 . 21 . 0 " / > <nl> < / ItemGroup > <nl> - < ItemGroup > <nl> - < None Include = " Grpc . Auth . project . json " / > <nl> - < None Include = " packages . config " / > <nl> + <nl> + < ItemGroup Condition = " ' $ ( TargetFramework ) ' = = ' net45 ' " > <nl> + < Reference Include = " System " / > <nl> + < Reference Include = " Microsoft . CSharp " / > <nl> < / ItemGroup > <nl> - < / Project > <nl> \ No newline at end of file <nl> + <nl> + < / Project > <nl> deleted file mode 100644 <nl> index c2f5bcb1637 . . 00000000000 <nl> mmm a / src / csharp / Grpc . Auth / Grpc . Auth . project . json <nl> ppp / dev / null <nl> <nl> - { <nl> - " frameworks " : { <nl> - " net45 " : { } <nl> - } , <nl> - " runtimes " : { <nl> - " win " : { } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index dd3d94c574a . . 00000000000 <nl> mmm a / src / csharp / Grpc . Auth / Grpc . Auth . xproj <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project ToolsVersion = " 14 . 0 . 25123 " DefaultTargets = " Build " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> - < PropertyGroup > <nl> - < VisualStudioVersion Condition = " ' $ ( VisualStudioVersion ) ' = = ' ' " > 14 . 0 . 25123 < / VisualStudioVersion > <nl> - < VSToolsPath Condition = " ' $ ( VSToolsPath ) ' = = ' ' " > $ ( MSBuildExtensionsPath32 ) \ Microsoft \ VisualStudio \ v $ ( VisualStudioVersion ) < / VSToolsPath > <nl> - < / PropertyGroup > <nl> - < Import Project = " $ ( VSToolsPath ) \ DNX \ Microsoft . DNX . Props " Condition = " ' $ ( VSToolsPath ) ' ! = ' ' " / > <nl> - < PropertyGroup Label = " Globals " > <nl> - < ProjectGuid > c82631ed - 06d1 - 4458 - 87bc - 8257d12307a8 < / ProjectGuid > <nl> - < RootNamespace > Grpc . Auth < / RootNamespace > <nl> - < BaseIntermediateOutputPath Condition = " ' $ ( BaseIntermediateOutputPath ) ' = = ' ' " > . . \ Grpc . Core \ artifacts \ obj \ $ ( MSBuildProjectName ) < / BaseIntermediateOutputPath > <nl> - < OutputPath Condition = " ' $ ( OutputPath ) ' = = ' ' " > . \ bin \ < / OutputPath > <nl> - < / PropertyGroup > <nl> - < PropertyGroup > <nl> - < SchemaVersion > 2 . 0 < / SchemaVersion > <nl> - < / PropertyGroup > <nl> - < Import Project = " $ ( VSToolsPath ) \ DNX \ Microsoft . DNX . targets " Condition = " ' $ ( VSToolsPath ) ' ! = ' ' " / > <nl> - < / Project > <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index aecc65e8499 . . 00000000000 <nl> mmm a / src / csharp / Grpc . Auth / packages . config <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < packages > <nl> - < package id = " Google . Apis " version = " 1 . 21 . 0 " targetFramework = " net45 " / > <nl> - < package id = " Google . Apis . Auth " version = " 1 . 21 . 0 " targetFramework = " net45 " / > <nl> - < package id = " Google . Apis . Core " version = " 1 . 21 . 0 " targetFramework = " net45 " / > <nl> - < package id = " Newtonsoft . Json " version = " 9 . 0 . 1 " targetFramework = " net45 " / > <nl> - < package id = " Zlib . Portable . Signed " version = " 1 . 11 . 0 " targetFramework = " net45 " / > <nl> - < / packages > <nl> \ No newline at end of file <nl> old mode 100644 <nl> new mode 100755 <nl> index 9b0b3abf107 . . f4dd5105fc7 <nl> mmm a / src / csharp / Grpc . Core . Testing / Grpc . Core . Testing . csproj <nl> ppp b / src / csharp / Grpc . Core . Testing / Grpc . Core . Testing . csproj <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project ToolsVersion = " 4 . 0 " DefaultTargets = " Build " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> - < Import Project = " $ ( MSBuildExtensionsPath ) \ $ ( MSBuildToolsVersion ) \ Microsoft . Common . props " Condition = " Exists ( ' $ ( MSBuildExtensionsPath ) \ $ ( MSBuildToolsVersion ) \ Microsoft . Common . props ' ) " / > <nl> + < Project Sdk = " Microsoft . NET . Sdk " > <nl> + <nl> + < Import Project = " . . \ Grpc . Core \ Version . csproj . include " / > <nl> + < Import Project = " . . \ Grpc . Core \ Common . csproj . include " / > <nl> + <nl> < PropertyGroup > <nl> - < Configuration Condition = " ' $ ( Configuration ) ' = = ' ' " > Debug < / Configuration > <nl> - < Platform Condition = " ' $ ( Platform ) ' = = ' ' " > AnyCPU < / Platform > <nl> - < ProjectGuid > { 3AB047CA - 6CF9 - 435D - AA61 - 2D86C6FA2457 } < / ProjectGuid > <nl> - < OutputType > Library < / OutputType > <nl> - < AppDesignerFolder > Properties < / AppDesignerFolder > <nl> - < RootNamespace > Grpc . Core . Testing < / RootNamespace > <nl> + < Copyright > Copyright 2017 , Google Inc . < / Copyright > <nl> + < AssemblyTitle > gRPC C # Core Testing < / AssemblyTitle > <nl> + < VersionPrefix > $ ( GrpcCsharpVersion ) < / VersionPrefix > <nl> + < Authors > Google Inc . < / Authors > <nl> + < TargetFrameworks > net45 ; netstandard1 . 5 < / TargetFrameworks > <nl> + < GenerateDocumentationFile > true < / GenerateDocumentationFile > <nl> < AssemblyName > Grpc . Core . Testing < / AssemblyName > <nl> - < TargetFrameworkVersion > v4 . 5 < / TargetFrameworkVersion > <nl> - < FileAlignment > 512 < / FileAlignment > <nl> - < DocumentationFile > bin \ $ ( Configuration ) \ Grpc . Core . Testing . Xml < / DocumentationFile > <nl> - < / PropertyGroup > <nl> - < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | AnyCPU ' " > <nl> - < DebugSymbols > true < / DebugSymbols > <nl> - < DebugType > full < / DebugType > <nl> - < Optimize > false < / Optimize > <nl> - < OutputPath > bin \ Debug \ < / OutputPath > <nl> - < ErrorReport > prompt < / ErrorReport > <nl> - < WarningLevel > 4 < / WarningLevel > <nl> - < / PropertyGroup > <nl> - < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Release | AnyCPU ' " > <nl> - < DebugType > pdbonly < / DebugType > <nl> - < Optimize > true < / Optimize > <nl> - < OutputPath > bin \ Release \ < / OutputPath > <nl> - < ErrorReport > prompt < / ErrorReport > <nl> - < WarningLevel > 4 < / WarningLevel > <nl> + < PackageId > Grpc . Core . Testing < / PackageId > <nl> + < PackageTags > gRPC test testing < / PackageTags > <nl> + < PackageProjectUrl > https : / / github . com / grpc / grpc < / PackageProjectUrl > <nl> + < PackageLicenseUrl > https : / / github . com / grpc / grpc / blob / master / LICENSE < / PackageLicenseUrl > <nl> + < NetStandardImplicitPackageVersion Condition = " ' $ ( TargetFramework ) ' = = ' netstandard1 . 5 ' " > 1 . 6 . 0 < / NetStandardImplicitPackageVersion > <nl> < / PropertyGroup > <nl> + <nl> < ItemGroup > <nl> - < Reference Include = " System " / > <nl> - < Reference Include = " System . Core " / > <nl> - < Reference Include = " System . Xml . Linq " / > <nl> - < Reference Include = " System . Data . DataSetExtensions " / > <nl> - < Reference Include = " Microsoft . CSharp " / > <nl> - < Reference Include = " System . Data " / > <nl> - < Reference Include = " System . Xml " / > <nl> - < Reference Include = " System . Interactive . Async " > <nl> - < HintPath > . . \ packages \ System . Interactive . Async . 3 . 1 . 1 \ lib \ net45 \ System . Interactive . Async . dll < / HintPath > <nl> - < / Reference > <nl> + < Compile Include = " . . \ Grpc . Core \ Version . cs " / > <nl> < / ItemGroup > <nl> + <nl> < ItemGroup > <nl> - < Compile Include = " . . \ Grpc . Core \ Version . cs " > <nl> - < Link > Version . cs < / Link > <nl> - < / Compile > <nl> - < Compile Include = " Properties \ AssemblyInfo . cs " / > <nl> - < Compile Include = " TestCalls . cs " / > <nl> + < ProjectReference Include = " . . / Grpc . Core / Grpc . Core . csproj " / > <nl> < / ItemGroup > <nl> - < ItemGroup > <nl> - < None Include = " Grpc . Core . Testing . project . json " / > <nl> - < None Include = " packages . config " / > <nl> - < / ItemGroup > <nl> - < ItemGroup > <nl> - < ProjectReference Include = " . . \ Grpc . Core \ Grpc . Core . csproj " > <nl> - < Project > { CCC4440E - 49F7 - 4790 - B0AF - FEABB0837AE7 } < / Project > <nl> - < Name > Grpc . Core < / Name > <nl> - < / ProjectReference > <nl> + <nl> + < ItemGroup Condition = " ' $ ( TargetFramework ) ' = = ' net45 ' " > <nl> + < Reference Include = " System . Runtime " / > <nl> + < Reference Include = " System . IO " / > <nl> + < Reference Include = " System " / > <nl> + < Reference Include = " Microsoft . CSharp " / > <nl> < / ItemGroup > <nl> - < Import Project = " $ ( MSBuildToolsPath ) \ Microsoft . CSharp . targets " / > <nl> - < ! - - To modify your build process , add your task inside one of the targets below and uncomment it . <nl> - Other similar extension points exist , see Microsoft . Common . targets . <nl> - < Target Name = " BeforeBuild " > <nl> - < / Target > <nl> - < Target Name = " AfterBuild " > <nl> - < / Target > <nl> - - - > <nl> - < / Project > <nl> \ No newline at end of file <nl> + <nl> + < / Project > <nl> deleted file mode 100644 <nl> index c2f5bcb1637 . . 00000000000 <nl> mmm a / src / csharp / Grpc . Core . Testing / Grpc . Core . Testing . project . json <nl> ppp / dev / null <nl> <nl> - { <nl> - " frameworks " : { <nl> - " net45 " : { } <nl> - } , <nl> - " runtimes " : { <nl> - " win " : { } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index c9723870033 . . 00000000000 <nl> mmm a / src / csharp / Grpc . Core . Testing / Grpc . Core . Testing . xproj <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project ToolsVersion = " 14 . 0 . 25123 " DefaultTargets = " Build " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> - < PropertyGroup > <nl> - < VisualStudioVersion Condition = " ' $ ( VisualStudioVersion ) ' = = ' ' " > 14 . 0 . 25123 < / VisualStudioVersion > <nl> - < VSToolsPath Condition = " ' $ ( VSToolsPath ) ' = = ' ' " > $ ( MSBuildExtensionsPath32 ) \ Microsoft \ VisualStudio \ v $ ( VisualStudioVersion ) < / VSToolsPath > <nl> - < / PropertyGroup > <nl> - < Import Project = " $ ( VSToolsPath ) \ DNX \ Microsoft . DNX . Props " Condition = " ' $ ( VSToolsPath ) ' ! = ' ' " / > <nl> - < PropertyGroup Label = " Globals " > <nl> - < ProjectGuid > 2b372155 - 80ba - 4cf9 - 82d6 - 4b938e8ec3a0 < / ProjectGuid > <nl> - < RootNamespace > Grpc . Core . Testing < / RootNamespace > <nl> - < BaseIntermediateOutputPath Condition = " ' $ ( BaseIntermediateOutputPath ) ' = = ' ' " > . . \ artifacts \ obj \ $ ( MSBuildProjectName ) < / BaseIntermediateOutputPath > <nl> - < OutputPath Condition = " ' $ ( OutputPath ) ' = = ' ' " > . \ bin \ < / OutputPath > <nl> - < / PropertyGroup > <nl> - < PropertyGroup > <nl> - < SchemaVersion > 2 . 0 < / SchemaVersion > <nl> - < / PropertyGroup > <nl> - < Import Project = " $ ( VSToolsPath ) \ DNX \ Microsoft . DNX . targets " Condition = " ' $ ( VSToolsPath ) ' ! = ' ' " / > <nl> - < / Project > <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 53cfad52f0b . . 00000000000 <nl> mmm a / src / csharp / Grpc . Core . Testing / packages . config <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < packages > <nl> - < package id = " System . Interactive . Async " version = " 3 . 1 . 1 " targetFramework = " net45 " / > <nl> - < / packages > <nl> \ No newline at end of file <nl> old mode 100644 <nl> new mode 100755 <nl> index a1a2e4eebd1 . . 9be77c8875d <nl> mmm a / src / csharp / Grpc . Core . Tests / Grpc . Core . Tests . csproj <nl> ppp b / src / csharp / Grpc . Core . Tests / Grpc . Core . Tests . csproj <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project DefaultTargets = " Build " ToolsVersion = " 4 . 0 " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> + < Project Sdk = " Microsoft . NET . Sdk " > <nl> + <nl> + < Import Project = " . . \ Grpc . Core \ Version . csproj . include " / > <nl> + < Import Project = " . . \ Grpc . Core \ Common . csproj . include " / > <nl> + <nl> < PropertyGroup > <nl> - < Configuration Condition = " ' $ ( Configuration ) ' = = ' ' " > Debug < / Configuration > <nl> - < Platform Condition = " ' $ ( Platform ) ' = = ' ' " > AnyCPU < / Platform > <nl> - < ProjectGuid > { 86EC5CB4 - 4EA2 - 40A2 - 8057 - 86542A0353BB } < / ProjectGuid > <nl> - < OutputType > Exe < / OutputType > <nl> - < RootNamespace > Grpc . Core . Tests < / RootNamespace > <nl> + < TargetFrameworks > net45 ; netcoreapp1 . 0 < / TargetFrameworks > <nl> < AssemblyName > Grpc . Core . Tests < / AssemblyName > <nl> - < TargetFrameworkVersion > v4 . 5 < / TargetFrameworkVersion > <nl> - < / PropertyGroup > <nl> - < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | AnyCPU ' " > <nl> - < DebugSymbols > true < / DebugSymbols > <nl> - < DebugType > full < / DebugType > <nl> - < Optimize > false < / Optimize > <nl> - < OutputPath > bin \ Debug < / OutputPath > <nl> - < DefineConstants > DEBUG ; < / DefineConstants > <nl> - < ErrorReport > prompt < / ErrorReport > <nl> - < WarningLevel > 4 < / WarningLevel > <nl> - < / PropertyGroup > <nl> - < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Release | AnyCPU ' " > <nl> - < DebugType > pdbonly < / DebugType > <nl> - < Optimize > true < / Optimize > <nl> - < OutputPath > bin \ Release < / OutputPath > <nl> - < ErrorReport > prompt < / ErrorReport > <nl> - < WarningLevel > 4 < / WarningLevel > <nl> + < OutputType > Exe < / OutputType > <nl> + < PackageId > Grpc . Core . Tests < / PackageId > <nl> + < PackageTargetFallback Condition = " ' $ ( TargetFramework ) ' = = ' netcoreapp1 . 0 ' " > $ ( PackageTargetFallback ) ; portable - net45 < / PackageTargetFallback > <nl> + < RuntimeFrameworkVersion Condition = " ' $ ( TargetFramework ) ' = = ' netcoreapp1 . 0 ' " > 1 . 0 . 4 < / RuntimeFrameworkVersion > <nl> < / PropertyGroup > <nl> + <nl> < ItemGroup > <nl> - < Reference Include = " System " / > <nl> - < Reference Include = " System . Interactive . Async " > <nl> - < HintPath > . . \ packages \ System . Interactive . Async . 3 . 1 . 1 \ lib \ net45 \ System . Interactive . Async . dll < / HintPath > <nl> - < / Reference > <nl> - < Reference Include = " Newtonsoft . Json " > <nl> - < HintPath > . . \ packages \ Newtonsoft . Json . 9 . 0 . 1 \ lib \ net45 \ Newtonsoft . Json . dll < / HintPath > <nl> - < / Reference > <nl> - < Reference Include = " nunit . framework " > <nl> - < HintPath > . . \ packages \ NUnit . 3 . 6 . 0 \ lib \ net45 \ nunit . framework . dll < / HintPath > <nl> - < / Reference > <nl> - < Reference Include = " nunitlite " > <nl> - < HintPath > . . \ packages \ NUnitLite . 3 . 6 . 0 \ lib \ net45 \ nunitlite . dll < / HintPath > <nl> - < / Reference > <nl> + < ProjectReference Include = " . . / Grpc . Core / Grpc . Core . csproj " / > <nl> < / ItemGroup > <nl> + <nl> < ItemGroup > <nl> - < Compile Include = " . . \ Grpc . Core \ Version . cs " > <nl> - < Link > Version . cs < / Link > <nl> - < / Compile > <nl> - < Compile Include = " CallCredentialsTest . cs " / > <nl> - < Compile Include = " CallOptionsTest . cs " / > <nl> - < Compile Include = " UserAgentStringTest . cs " / > <nl> - < Compile Include = " FakeCredentials . cs " / > <nl> - < Compile Include = " MarshallingErrorsTest . cs " / > <nl> - < Compile Include = " ChannelCredentialsTest . cs " / > <nl> - < Compile Include = " ShutdownTest . cs " / > <nl> - < Compile Include = " Internal \ AsyncCallTest . cs " / > <nl> - < Compile Include = " Properties \ AssemblyInfo . cs " / > <nl> - < Compile Include = " ClientServerTest . cs " / > <nl> - < Compile Include = " ServerTest . cs " / > <nl> - < Compile Include = " GrpcEnvironmentTest . cs " / > <nl> - < Compile Include = " PInvokeTest . cs " / > <nl> - < Compile Include = " Internal \ MetadataArraySafeHandleTest . cs " / > <nl> - < Compile Include = " Internal \ CompletionQueueSafeHandleTest . cs " / > <nl> - < Compile Include = " Internal \ CompletionQueueEventTest . cs " / > <nl> - < Compile Include = " Internal \ ChannelArgsSafeHandleTest . cs " / > <nl> - < Compile Include = " ChannelOptionsTest . cs " / > <nl> - < Compile Include = " Internal \ TimespecTest . cs " / > <nl> - < Compile Include = " TimeoutsTest . cs " / > <nl> - < Compile Include = " ChannelTest . cs " / > <nl> - < Compile Include = " MockServiceHelper . cs " / > <nl> - < Compile Include = " ResponseHeadersTest . cs " / > <nl> - < Compile Include = " CompressionTest . cs " / > <nl> - < Compile Include = " ContextPropagationTest . cs " / > <nl> - < Compile Include = " MetadataTest . cs " / > <nl> - < Compile Include = " PerformanceTest . cs " / > <nl> - < Compile Include = " SanityTest . cs " / > <nl> - < Compile Include = " HalfcloseTest . cs " / > <nl> - < Compile Include = " NUnitMain . cs " / > <nl> - < Compile Include = " Internal \ FakeNativeCall . cs " / > <nl> - < Compile Include = " Internal \ AsyncCallServerTest . cs " / > <nl> - < Compile Include = " ShutdownHookServerTest . cs " / > <nl> - < Compile Include = " ShutdownHookPendingCallTest . cs " / > <nl> - < Compile Include = " ShutdownHookClientTest . cs " / > <nl> - < Compile Include = " AppDomainUnloadTest . cs " / > <nl> - < Compile Include = " AuthContextTest . cs " / > <nl> - < Compile Include = " AuthPropertyTest . cs " / > <nl> + < PackageReference Include = " Newtonsoft . Json " Version = " 9 . 0 . 1 " / > <nl> + < PackageReference Include = " NUnit " Version = " 3 . 6 . 0 " / > <nl> + < PackageReference Include = " NUnitLite " Version = " 3 . 6 . 0 " / > <nl> + < PackageReference Include = " NUnit . ConsoleRunner " Version = " 3 . 6 . 0 " / > <nl> + < PackageReference Include = " OpenCover " Version = " 4 . 6 . 519 " / > <nl> + < PackageReference Include = " ReportGenerator " Version = " 2 . 4 . 4 . 0 " / > <nl> < / ItemGroup > <nl> - < Import Project = " $ ( MSBuildBinPath ) \ Microsoft . CSharp . targets " / > <nl> - < ItemGroup > <nl> - < ProjectReference Include = " . . \ Grpc . Core \ Grpc . Core . csproj " > <nl> - < Project > { CCC4440E - 49F7 - 4790 - B0AF - FEABB0837AE7 } < / Project > <nl> - < Name > Grpc . Core < / Name > <nl> - < / ProjectReference > <nl> - < / ItemGroup > <nl> - < ItemGroup > <nl> - < None Include = " Grpc . Core . Tests . project . json " / > <nl> - < None Include = " packages . config " > <nl> - < SubType > Designer < / SubType > <nl> - < / None > <nl> + <nl> + < ItemGroup Condition = " ' $ ( TargetFramework ) ' = = ' net45 ' " > <nl> + < Reference Include = " System " / > <nl> + < Reference Include = " Microsoft . CSharp " / > <nl> < / ItemGroup > <nl> + <nl> < ItemGroup > <nl> - < Service Include = " { 82A7F48D - 3B50 - 4B1E - B82E - 3ADA8210C358 } " / > <nl> + < Compile Include = " . . \ Grpc . Core \ Version . cs " / > <nl> < / ItemGroup > <nl> - < ItemGroup / > <nl> + <nl> < / Project > <nl> deleted file mode 100644 <nl> index c2f5bcb1637 . . 00000000000 <nl> mmm a / src / csharp / Grpc . Core . Tests / Grpc . Core . Tests . project . json <nl> ppp / dev / null <nl> <nl> - { <nl> - " frameworks " : { <nl> - " net45 " : { } <nl> - } , <nl> - " runtimes " : { <nl> - " win " : { } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index 05823291542 . . 00000000000 <nl> mmm a / src / csharp / Grpc . Core . Tests / Grpc . Core . Tests . xproj <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project ToolsVersion = " 14 . 0 . 25123 " DefaultTargets = " Build " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> - < PropertyGroup > <nl> - < VisualStudioVersion Condition = " ' $ ( VisualStudioVersion ) ' = = ' ' " > 14 . 0 . 25123 < / VisualStudioVersion > <nl> - < VSToolsPath Condition = " ' $ ( VSToolsPath ) ' = = ' ' " > $ ( MSBuildExtensionsPath32 ) \ Microsoft \ VisualStudio \ v $ ( VisualStudioVersion ) < / VSToolsPath > <nl> - < / PropertyGroup > <nl> - < Import Project = " $ ( VSToolsPath ) \ DNX \ Microsoft . DNX . Props " Condition = " ' $ ( VSToolsPath ) ' ! = ' ' " / > <nl> - < PropertyGroup Label = " Globals " > <nl> - < ProjectGuid > 759e23b2 - fc04 - 4695 - 902d - b073cded3599 < / ProjectGuid > <nl> - < RootNamespace > Grpc . Core . Tests < / RootNamespace > <nl> - < BaseIntermediateOutputPath Condition = " ' $ ( BaseIntermediateOutputPath ) ' = = ' ' " > . . \ artifacts \ obj \ $ ( MSBuildProjectName ) < / BaseIntermediateOutputPath > <nl> - < OutputPath Condition = " ' $ ( OutputPath ) ' = = ' ' " > . \ bin \ < / OutputPath > <nl> - < / PropertyGroup > <nl> - < PropertyGroup > <nl> - < SchemaVersion > 2 . 0 < / SchemaVersion > <nl> - < / PropertyGroup > <nl> - < Import Project = " $ ( VSToolsPath ) \ DNX \ Microsoft . DNX . targets " Condition = " ' $ ( VSToolsPath ) ' ! = ' ' " / > <nl> - < / Project > <nl> \ No newline at end of file <nl> mmm a / src / csharp / Grpc . Core . Tests / SanityTest . cs <nl> ppp b / src / csharp / Grpc . Core . Tests / SanityTest . cs <nl> var testsFromFile <nl> private string ReadTestsJson ( ) <nl> { <nl> var assemblyDir = Path . GetDirectoryName ( Assembly . GetExecutingAssembly ( ) . Location ) ; <nl> - var testsJsonFile = Path . Combine ( assemblyDir , " . . " , " . . " , " . . " , " tests . json " ) ; <nl> + var testsJsonFile = Path . Combine ( assemblyDir , " . . " , " . . " , " . . " , " . . " , " tests . json " ) ; <nl> return File . ReadAllText ( testsJsonFile ) ; <nl> } <nl> <nl> deleted file mode 100644 <nl> index 994a2787629 . . 00000000000 <nl> mmm a / src / csharp / Grpc . Core . Tests / packages . config <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < packages > <nl> - < package id = " Newtonsoft . Json " version = " 9 . 0 . 1 " targetFramework = " net45 " / > <nl> - < package id = " NUnit " version = " 3 . 6 . 0 " targetFramework = " net45 " / > <nl> - < package id = " NUnitLite " version = " 3 . 6 . 0 " targetFramework = " net45 " / > <nl> - < package id = " OpenCover " version = " 4 . 6 . 519 " / > <nl> - < package id = " ReportGenerator " version = " 2 . 4 . 4 . 0 " / > <nl> - < package id = " System . Interactive . Async " version = " 3 . 1 . 1 " targetFramework = " net45 " / > <nl> - < / packages > <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 14e5ed51adb . . 00000000000 <nl> mmm a / src / csharp / Grpc . Core . Tests / project . json <nl> ppp / dev / null <nl> <nl> - { <nl> - " buildOptions " : { <nl> - " emitEntryPoint " : true <nl> - } , <nl> - " configurations " : { <nl> - " Debug " : { <nl> - " buildOptions " : { <nl> - " define " : [ " SIGNED " ] , <nl> - " keyFile " : " . . / keys / Grpc . snk " , <nl> - " xmlDoc " : true , <nl> - " compile " : { <nl> - " includeFiles " : [ " . . / Grpc . Core / Version . cs " ] <nl> - } , <nl> - " copyToOutput " : { <nl> - " mappings " : { <nl> - " grpc_csharp_ext . x64 . dll " : " . . / . . / . . / cmake / build / x64 / Debug / grpc_csharp_ext . dll " , <nl> - " grpc_csharp_ext . x86 . dll " : " . . / . . / . . / cmake / build / Win32 / Debug / grpc_csharp_ext . dll " , <nl> - " libgrpc_csharp_ext . x64 . so " : " . . / . . / . . / libs / dbg / libgrpc_csharp_ext . so " , <nl> - " libgrpc_csharp_ext . x64 . dylib " : " . . / . . / . . / libs / dbg / libgrpc_csharp_ext . dylib " <nl> - } <nl> - } <nl> - } <nl> - } , <nl> - " Release " : { <nl> - " buildOptions " : { <nl> - " define " : [ " SIGNED " ] , <nl> - " keyFile " : " . . / keys / Grpc . snk " , <nl> - " xmlDoc " : true , <nl> - " compile " : { <nl> - " includeFiles " : [ " . . / Grpc . Core / Version . cs " ] <nl> - } , <nl> - " copyToOutput " : { <nl> - " mappings " : { <nl> - " grpc_csharp_ext . x64 . dll " : " . . / . . / . . / cmake / build / x64 / Release / grpc_csharp_ext . dll " , <nl> - " grpc_csharp_ext . x86 . dll " : " . . / . . / . . / cmake / build / Win32 / Release / grpc_csharp_ext . dll " , <nl> - " libgrpc_csharp_ext . x64 . so " : " . . / . . / . . / libs / opt / libgrpc_csharp_ext . so " , <nl> - " libgrpc_csharp_ext . x64 . dylib " : " . . / . . / . . / libs / opt / libgrpc_csharp_ext . dylib " <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } , <nl> - <nl> - " dependencies " : { <nl> - " Grpc . Core " : { <nl> - " target " : " project " <nl> - } , <nl> - " Newtonsoft . Json " : " 9 . 0 . 1 " , <nl> - " NUnit " : " 3 . 6 . 0 " , <nl> - " NUnitLite " : " 3 . 6 . 0 " , <nl> - " NUnit . ConsoleRunner " : " 3 . 6 . 0 " , <nl> - " OpenCover " : " 4 . 6 . 519 " , <nl> - " ReportGenerator " : " 2 . 4 . 4 . 0 " <nl> - } , <nl> - " frameworks " : { <nl> - " net45 " : { } , <nl> - " netcoreapp1 . 0 " : { <nl> - " imports " : [ <nl> - " portable - net45 " <nl> - ] , <nl> - " dependencies " : { <nl> - " Microsoft . NETCore . App " : { <nl> - " type " : " platform " , <nl> - " version " : " 1 . 0 . 0 " <nl> - } <nl> - } <nl> - } <nl> - } , <nl> - } <nl> new file mode 100755 <nl> index 00000000000 . . 2cb990ba49e <nl> mmm / dev / null <nl> ppp b / src / csharp / Grpc . Core / Common . csproj . include <nl> <nl> + < ! - - Common definitions shared by all . csproj files - - > <nl> + < Project > <nl> + < PropertyGroup > <nl> + < GenerateAssemblyVersionAttribute > false < / GenerateAssemblyVersionAttribute > <nl> + < GenerateAssemblyFileVersionAttribute > false < / GenerateAssemblyFileVersionAttribute > <nl> + < GenerateAssemblyInformationalVersionAttribute > false < / GenerateAssemblyInformationalVersionAttribute > <nl> + < GenerateAssemblyTitleAttribute > false < / GenerateAssemblyTitleAttribute > <nl> + < GenerateAssemblyDescriptionAttribute > false < / GenerateAssemblyDescriptionAttribute > <nl> + < GenerateAssemblyConfigurationAttribute > false < / GenerateAssemblyConfigurationAttribute > <nl> + < GenerateAssemblyCompanyAttribute > false < / GenerateAssemblyCompanyAttribute > <nl> + < GenerateAssemblyProductAttribute > false < / GenerateAssemblyProductAttribute > <nl> + < GenerateAssemblyCopyrightAttribute > false < / GenerateAssemblyCopyrightAttribute > <nl> + < / PropertyGroup > <nl> + <nl> + < PropertyGroup > <nl> + < GenerateDocumentationFile > true < / GenerateDocumentationFile > <nl> + < / PropertyGroup > <nl> + <nl> + < PropertyGroup > <nl> + < DefineConstants > $ ( DefineConstants ) ; SIGNED < / DefineConstants > <nl> + < AssemblyOriginatorKeyFile > . . / keys / Grpc . snk < / AssemblyOriginatorKeyFile > <nl> + < SignAssembly > true < / SignAssembly > <nl> + < PublicSign Condition = " ' $ ( OS ) ' ! = ' Windows_NT ' " > true < / PublicSign > <nl> + < / PropertyGroup > <nl> + <nl> + < PropertyGroup Condition = " ' $ ( OS ) ' ! = ' Windows_NT ' " > <nl> + < ! - - Workaround for https : / / github . com / dotnet / sdk / issues / 335 - - > <nl> + < FrameworkPathOverride Condition = " Exists ( ' / usr / lib / mono / 4 . 5 - api ' ) " > / usr / lib / mono / 4 . 5 - api < / FrameworkPathOverride > <nl> + < FrameworkPathOverride Condition = " Exists ( ' / usr / local / lib / mono / 4 . 5 - api ' ) " > / usr / local / lib / mono / 4 . 5 - api < / FrameworkPathOverride > <nl> + < FrameworkPathOverride Condition = " Exists ( ' / Library / Frameworks / Mono . framework / Versions / Current / lib / mono / 4 . 5 - api ' ) " > / Library / Frameworks / Mono . framework / Versions / Current / lib / mono / 4 . 5 - api < / FrameworkPathOverride > <nl> + < / PropertyGroup > <nl> + < / Project > <nl> old mode 100644 <nl> new mode 100755 <nl> index d6d8dfac224 . . 7e0f3f053d0 <nl> mmm a / src / csharp / Grpc . Core / Grpc . Core . csproj <nl> ppp b / src / csharp / Grpc . Core / Grpc . Core . csproj <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project DefaultTargets = " Build " ToolsVersion = " 4 . 0 " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> + < Project Sdk = " Microsoft . NET . Sdk " > <nl> + <nl> + < Import Project = " Version . csproj . include " / > <nl> + < Import Project = " Common . csproj . include " / > <nl> + <nl> < PropertyGroup > <nl> - < Configuration Condition = " ' $ ( Configuration ) ' = = ' ' " > Debug < / Configuration > <nl> - < Platform Condition = " ' $ ( Platform ) ' = = ' ' " > AnyCPU < / Platform > <nl> - < ProjectGuid > { CCC4440E - 49F7 - 4790 - B0AF - FEABB0837AE7 } < / ProjectGuid > <nl> - < OutputType > Library < / OutputType > <nl> - < RootNamespace > Grpc . Core < / RootNamespace > <nl> + < Copyright > Copyright 2015 , Google Inc . < / Copyright > <nl> + < AssemblyTitle > gRPC C # Core < / AssemblyTitle > <nl> + < VersionPrefix > $ ( GrpcCsharpVersion ) < / VersionPrefix > <nl> + < Authors > Google Inc . < / Authors > <nl> + < TargetFrameworks > net45 ; netstandard1 . 5 < / TargetFrameworks > <nl> < AssemblyName > Grpc . Core < / AssemblyName > <nl> - < TargetFrameworkVersion > v4 . 5 < / TargetFrameworkVersion > <nl> - < NuGetPackageImportStamp > c0512805 < / NuGetPackageImportStamp > <nl> - < DocumentationFile > bin \ $ ( Configuration ) \ Grpc . Core . Xml < / DocumentationFile > <nl> - < / PropertyGroup > <nl> - < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | AnyCPU ' " > <nl> - < DebugSymbols > true < / DebugSymbols > <nl> - < DebugType > full < / DebugType > <nl> - < Optimize > false < / Optimize > <nl> - < OutputPath > bin \ Debug < / OutputPath > <nl> - < DefineConstants > DEBUG ; < / DefineConstants > <nl> - < ErrorReport > prompt < / ErrorReport > <nl> - < WarningLevel > 4 < / WarningLevel > <nl> - < / PropertyGroup > <nl> - < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Release | AnyCPU ' " > <nl> - < DebugType > pdbonly < / DebugType > <nl> - < Optimize > true < / Optimize > <nl> - < OutputPath > bin \ Release < / OutputPath > <nl> - < ErrorReport > prompt < / ErrorReport > <nl> - < WarningLevel > 4 < / WarningLevel > <nl> + < PackageId > Grpc . Core < / PackageId > <nl> + < PackageTags > gRPC RPC Protocol HTTP / 2 < / PackageTags > <nl> + < PackageProjectUrl > https : / / github . com / grpc / grpc < / PackageProjectUrl > <nl> + < PackageLicenseUrl > https : / / github . com / grpc / grpc / blob / master / LICENSE < / PackageLicenseUrl > <nl> + < NetStandardImplicitPackageVersion Condition = " ' $ ( TargetFramework ) ' = = ' netstandard1 . 5 ' " > 1 . 6 . 0 < / NetStandardImplicitPackageVersion > <nl> < / PropertyGroup > <nl> + <nl> < ItemGroup > <nl> - < Reference Include = " System " / > <nl> - < Reference Include = " System . Interactive . Async " > <nl> - < HintPath > . . \ packages \ System . Interactive . Async . 3 . 1 . 1 \ lib \ net45 \ System . Interactive . Async . dll < / HintPath > <nl> - < / Reference > <nl> + < EmbeddedResource Include = " . . \ . . \ . . \ etc \ roots . pem " / > <nl> + < Content Include = " . . \ nativelibs \ macosx_x64 \ libgrpc_csharp_ext . dylib " > <nl> + < PackagePath > runtimes / osx / native / libgrpc_csharp_ext . x64 . dylib < / PackagePath > <nl> + < Pack > true < / Pack > <nl> + < / Content > <nl> + < Content Include = " . . \ nativelibs \ macosx_x86 \ libgrpc_csharp_ext . dylib " > <nl> + < PackagePath > runtimes / osx / native / libgrpc_csharp_ext . x86 . dylib < / PackagePath > <nl> + < Pack > true < / Pack > <nl> + < / Content > <nl> + < Content Include = " . . \ nativelibs \ linux_x64 \ libgrpc_csharp_ext . so " > <nl> + < PackagePath > runtimes / linux / native / libgrpc_csharp_ext . x64 . so < / PackagePath > <nl> + < Pack > true < / Pack > <nl> + < / Content > <nl> + < Content Include = " . . \ nativelibs \ linux_x86 \ libgrpc_csharp_ext . so " > <nl> + < PackagePath > runtimes / linux / native / libgrpc_csharp_ext . x86 . so < / PackagePath > <nl> + < Pack > true < / Pack > <nl> + < / Content > <nl> + < Content Include = " . . \ nativelibs \ windows_x64 \ grpc_csharp_ext . dll " > <nl> + < PackagePath > runtimes / win / native / grpc_csharp_ext . x64 . dll < / PackagePath > <nl> + < Pack > true < / Pack > <nl> + < / Content > <nl> + < Content Include = " . . \ nativelibs \ windows_x86 \ grpc_csharp_ext . dll " > <nl> + < PackagePath > runtimes / win / native / grpc_csharp_ext . x86 . dll < / PackagePath > <nl> + < Pack > true < / Pack > <nl> + < / Content > <nl> + < Content Include = " Grpc . Core . targets " > <nl> + < PackagePath > build / net45 / < / PackagePath > <nl> + < Pack > true < / Pack > <nl> + < / Content > <nl> < / ItemGroup > <nl> + <nl> < ItemGroup > <nl> - < Compile Include = " AsyncDuplexStreamingCall . cs " / > <nl> - < Compile Include = " AsyncServerStreamingCall . cs " / > <nl> - < Compile Include = " AsyncAuthInterceptor . cs " / > <nl> - < Compile Include = " CallCredentials . cs " / > <nl> - < Compile Include = " IClientStreamWriter . cs " / > <nl> - < Compile Include = " Internal \ NativeMethods . cs " / > <nl> - < Compile Include = " Internal \ PlatformApis . cs " / > <nl> - < Compile Include = " Internal \ NativeExtension . cs " / > <nl> - < Compile Include = " Internal \ UnmanagedLibrary . cs " / > <nl> - < Compile Include = " Internal \ NativeMetadataCredentialsPlugin . cs " / > <nl> - < Compile Include = " Internal \ INativeCall . cs " / > <nl> - < Compile Include = " IServerStreamWriter . cs " / > <nl> - < Compile Include = " IAsyncStreamWriter . cs " / > <nl> - < Compile Include = " IAsyncStreamReader . cs " / > <nl> - < Compile Include = " Logging \ TextWriterLogger . cs " / > <nl> - < Compile Include = " Logging \ NullLogger . cs " / > <nl> - < Compile Include = " ServerPort . cs " / > <nl> - < Compile Include = " Version . cs " / > <nl> - < Compile Include = " Properties \ AssemblyInfo . cs " / > <nl> - < Compile Include = " RpcException . cs " / > <nl> - < Compile Include = " Calls . cs " / > <nl> - < Compile Include = " AsyncClientStreamingCall . cs " / > <nl> - < Compile Include = " GrpcEnvironment . cs " / > <nl> - < Compile Include = " Status . cs " / > <nl> - < Compile Include = " StatusCode . cs " / > <nl> - < Compile Include = " Server . cs " / > <nl> - < Compile Include = " Channel . cs " / > <nl> - < Compile Include = " Internal \ CallSafeHandle . cs " / > <nl> - < Compile Include = " Internal \ ChannelSafeHandle . cs " / > <nl> - < Compile Include = " Internal \ CompletionQueueSafeHandle . cs " / > <nl> - < Compile Include = " Internal \ SafeHandleZeroIsInvalid . cs " / > <nl> - < Compile Include = " Internal \ Timespec . cs " / > <nl> - < Compile Include = " Internal \ GrpcThreadPool . cs " / > <nl> - < Compile Include = " Internal \ ServerSafeHandle . cs " / > <nl> - < Compile Include = " Method . cs " / > <nl> - < Compile Include = " Internal \ ServerCallHandler . cs " / > <nl> - < Compile Include = " Marshaller . cs " / > <nl> - < Compile Include = " ServerServiceDefinition . cs " / > <nl> - < Compile Include = " Utils \ AsyncStreamExtensions . cs " / > <nl> - < Compile Include = " Utils \ BenchmarkUtil . cs " / > <nl> - < Compile Include = " ChannelCredentials . cs " / > <nl> - < Compile Include = " Internal \ ChannelArgsSafeHandle . cs " / > <nl> - < Compile Include = " Internal \ AsyncCallBase . cs " / > <nl> - < Compile Include = " Internal \ AsyncCallServer . cs " / > <nl> - < Compile Include = " Internal \ AsyncCall . cs " / > <nl> - < Compile Include = " Internal \ ServerCredentialsSafeHandle . cs " / > <nl> - < Compile Include = " ServerCredentials . cs " / > <nl> - < Compile Include = " Metadata . cs " / > <nl> - < Compile Include = " Internal \ MetadataArraySafeHandle . cs " / > <nl> - < Compile Include = " ClientBase . cs " / > <nl> - < Compile Include = " Internal \ ServerCalls . cs " / > <nl> - < Compile Include = " ServerMethods . cs " / > <nl> - < Compile Include = " Internal \ ClientRequestStream . cs " / > <nl> - < Compile Include = " Internal \ ClientResponseStream . cs " / > <nl> - < Compile Include = " Internal \ ServerRequestStream . cs " / > <nl> - < Compile Include = " Internal \ ServerResponseStream . cs " / > <nl> - < Compile Include = " Internal \ AtomicCounter . cs " / > <nl> - < Compile Include = " Internal \ DebugStats . cs " / > <nl> - < Compile Include = " ServerCallContext . cs " / > <nl> - < Compile Include = " Internal \ CompletionQueueEvent . cs " / > <nl> - < Compile Include = " Internal \ CompletionRegistry . cs " / > <nl> - < Compile Include = " Internal \ BatchContextSafeHandle . cs " / > <nl> - < Compile Include = " ChannelOptions . cs " / > <nl> - < Compile Include = " AsyncUnaryCall . cs " / > <nl> - < Compile Include = " VersionInfo . cs " / > <nl> - < Compile Include = " Internal \ CStringSafeHandle . cs " / > <nl> - < Compile Include = " KeyCertificatePair . cs " / > <nl> - < Compile Include = " Logging \ ILogger . cs " / > <nl> - < Compile Include = " Logging \ ConsoleLogger . cs " / > <nl> - < Compile Include = " Internal \ NativeLogRedirector . cs " / > <nl> - < Compile Include = " ChannelState . cs " / > <nl> - < Compile Include = " CallInvocationDetails . cs " / > <nl> - < Compile Include = " CallOptions . cs " / > <nl> - < Compile Include = " CompressionLevel . cs " / > <nl> - < Compile Include = " WriteOptions . cs " / > <nl> - < Compile Include = " ContextPropagationToken . cs " / > <nl> - < Compile Include = " Internal \ CallCredentialsSafeHandle . cs " / > <nl> - < Compile Include = " Internal \ ChannelCredentialsSafeHandle . cs " / > <nl> - < Compile Include = " Profiling \ ProfilerEntry . cs " / > <nl> - < Compile Include = " Profiling \ ProfilerScope . cs " / > <nl> - < Compile Include = " Profiling \ IProfiler . cs " / > <nl> - < Compile Include = " Profiling \ Profilers . cs " / > <nl> - < Compile Include = " Internal \ DefaultSslRootsOverride . cs " / > <nl> - < Compile Include = " Utils \ GrpcPreconditions . cs " / > <nl> - < Compile Include = " CallInvoker . cs " / > <nl> - < Compile Include = " DefaultCallInvoker . cs " / > <nl> - < Compile Include = " Internal \ UnimplementedCallInvoker . cs " / > <nl> - < Compile Include = " Internal \ InterceptingCallInvoker . cs " / > <nl> - < Compile Include = " Internal \ ServerRpcNew . cs " / > <nl> - < Compile Include = " Internal \ ClientSideStatus . cs " / > <nl> - < Compile Include = " Internal \ ClockType . cs " / > <nl> - < Compile Include = " Internal \ CallError . cs " / > <nl> - < Compile Include = " Logging \ LogLevel . cs " / > <nl> - < Compile Include = " Logging \ LogLevelFilterLogger . cs " / > <nl> - < Compile Include = " Internal \ RequestCallContextSafeHandle . cs " / > <nl> - < Compile Include = " Utils \ TaskUtils . cs " / > <nl> - < Compile Include = " Internal \ CallFlags . cs " / > <nl> - < Compile Include = " AuthContext . cs " / > <nl> - < Compile Include = " Internal \ AuthContextSafeHandle . cs " / > <nl> - < Compile Include = " Internal \ MarshalUtils . cs " / > <nl> - < Compile Include = " AuthProperty . cs " / > <nl> + < PackageReference Include = " System . Interactive . Async " Version = " 3 . 1 . 1 " / > <nl> < / ItemGroup > <nl> - < ItemGroup > <nl> - < None Include = " Grpc . Core . project . json " / > <nl> - < None Include = " packages . config " / > <nl> + <nl> + < ItemGroup Condition = " ' $ ( TargetFramework ) ' = = ' net45 ' " > <nl> + < Reference Include = " System " / > <nl> + < Reference Include = " Microsoft . CSharp " / > <nl> < / ItemGroup > <nl> - < Import Project = " NativeDeps . targets " / > <nl> - < Import Project = " $ ( MSBuildBinPath ) \ Microsoft . CSharp . targets " / > <nl> - < ItemGroup / > <nl> - < ItemGroup > <nl> - < EmbeddedResource Include = " . . \ . . \ . . \ etc \ roots . pem " > <nl> - < Link > roots . pem < / Link > <nl> - < / EmbeddedResource > <nl> + <nl> + < ItemGroup Condition = " ' $ ( TargetFramework ) ' = = ' netstandard1 . 5 ' " > <nl> + < PackageReference Include = " System . Runtime . Loader " Version = " 4 . 0 . 0 " / > <nl> + < PackageReference Include = " System . Threading . Thread " Version = " 4 . 0 . 0 " / > <nl> < / ItemGroup > <nl> - < / Project > <nl> \ No newline at end of file <nl> + <nl> + < Import Project = " NativeDeps . csproj . include " / > <nl> + <nl> + < / Project > <nl> deleted file mode 100644 <nl> index c2f5bcb1637 . . 00000000000 <nl> mmm a / src / csharp / Grpc . Core / Grpc . Core . project . json <nl> ppp / dev / null <nl> <nl> - { <nl> - " frameworks " : { <nl> - " net45 " : { } <nl> - } , <nl> - " runtimes " : { <nl> - " win " : { } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index 137236ffdb6 . . 00000000000 <nl> mmm a / src / csharp / Grpc . Core / Grpc . Core . xproj <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project ToolsVersion = " 14 . 0 " DefaultTargets = " Build " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> - < PropertyGroup > <nl> - < VisualStudioVersion Condition = " ' $ ( VisualStudioVersion ) ' = = ' ' " > 14 . 0 < / VisualStudioVersion > <nl> - < VSToolsPath Condition = " ' $ ( VSToolsPath ) ' = = ' ' " > $ ( MSBuildExtensionsPath32 ) \ Microsoft \ VisualStudio \ v $ ( VisualStudioVersion ) < / VSToolsPath > <nl> - < / PropertyGroup > <nl> - < Import Project = " $ ( VSToolsPath ) \ DNX \ Microsoft . DNX . Props " Condition = " ' $ ( VSToolsPath ) ' ! = ' ' " / > <nl> - < PropertyGroup Label = " Globals " > <nl> - < ProjectGuid > dc9908b6 - f291 - 4fc8 - a46d - 2ea2551790ec < / ProjectGuid > <nl> - < RootNamespace > Grpc . Core < / RootNamespace > <nl> - < BaseIntermediateOutputPath Condition = " ' $ ( BaseIntermediateOutputPath ) ' = = ' ' " > . . \ artifacts \ obj \ $ ( MSBuildProjectName ) < / BaseIntermediateOutputPath > <nl> - < OutputPath Condition = " ' $ ( OutputPath ) ' = = ' ' " > . \ bin \ < / OutputPath > <nl> - < / PropertyGroup > <nl> - < PropertyGroup > <nl> - < SchemaVersion > 2 . 0 < / SchemaVersion > <nl> - < / PropertyGroup > <nl> - < Import Project = " $ ( VSToolsPath ) \ DNX \ Microsoft . DNX . targets " Condition = " ' $ ( VSToolsPath ) ' ! = ' ' " / > <nl> - < / Project > <nl> \ No newline at end of file <nl> mmm a / src / csharp / Grpc . Core / Internal / CompletionRegistry . cs <nl> ppp b / src / csharp / Grpc . Core / Internal / CompletionRegistry . cs <nl> internal class CompletionRegistry <nl> static readonly ILogger Logger = GrpcEnvironment . Logger . ForType < CompletionRegistry > ( ) ; <nl> <nl> readonly GrpcEnvironment environment ; <nl> - readonly ConcurrentDictionary < IntPtr , OpCompletionDelegate > dict = new ConcurrentDictionary < IntPtr , OpCompletionDelegate > ( ) ; <nl> + readonly ConcurrentDictionary < IntPtr , OpCompletionDelegate > dict = new ConcurrentDictionary < IntPtr , OpCompletionDelegate > ( new IntPtrComparer ( ) ) ; <nl> <nl> public CompletionRegistry ( GrpcEnvironment environment ) <nl> { <nl> private static void HandleRequestCallCompletion ( bool success , RequestCallContext <nl> } <nl> } <nl> } <nl> + <nl> + / / / < summary > <nl> + / / / IntPtr doesn ' t implement < c > IEquatable { IntPtr } < / c > so we need to use custom comparer to avoid boxing . <nl> + / / / < / summary > <nl> + private class IntPtrComparer : IEqualityComparer < IntPtr > <nl> + { <nl> + public bool Equals ( IntPtr x , IntPtr y ) <nl> + { <nl> + return x = = y ; <nl> + } <nl> + <nl> + public int GetHashCode ( IntPtr obj ) <nl> + { <nl> + return obj . GetHashCode ( ) ; <nl> + } <nl> + } <nl> } <nl> } <nl> similarity index 60 % <nl> rename from src / csharp / Grpc . Core / NativeDeps . Linux . targets <nl> rename to src / csharp / Grpc . Core / NativeDeps . Linux . csproj . include <nl> mmm a / src / csharp / Grpc . Core / NativeDeps . Linux . targets <nl> ppp b / src / csharp / Grpc . Core / NativeDeps . Linux . csproj . include <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project DefaultTargets = " Build " ToolsVersion = " 4 . 0 " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> + < Project > <nl> < ItemGroup > <nl> < Content Include = " . . \ . . \ . . \ libs \ $ ( NativeDependenciesConfigurationUnix ) \ libgrpc_csharp_ext . so " > <nl> - < CopyToOutputDirectory > PreserveNewest < / CopyToOutputDirectory > <nl> < Link > libgrpc_csharp_ext . x64 . so < / Link > <nl> + < CopyToOutputDirectory > PreserveNewest < / CopyToOutputDirectory > <nl> + < Pack > false < / Pack > <nl> < / Content > <nl> < / ItemGroup > <nl> < / Project > <nl> \ No newline at end of file <nl> new file mode 100644 <nl> index 00000000000 . . f1b85c3730e <nl> mmm / dev / null <nl> ppp b / src / csharp / Grpc . Core / NativeDeps . Mac . csproj . include <nl> <nl> + < Project > <nl> + < ItemGroup > <nl> + < ! - - We are relying on run_tests . py to build grpc_csharp_ext with the right bitness <nl> + and we copy it as both x86 ( needed by net45 ) and x64 ( needed by netcoreapp1 . 0 ) as we don ' t <nl> + know which one will be needed to run the tests . - - > <nl> + < Content Include = " . . \ . . \ . . \ libs \ $ ( NativeDependenciesConfigurationUnix ) \ libgrpc_csharp_ext . dylib " > <nl> + < Link > libgrpc_csharp_ext . x86 . dylib < / Link > <nl> + < CopyToOutputDirectory > PreserveNewest < / CopyToOutputDirectory > <nl> + < Pack > false < / Pack > <nl> + < / Content > <nl> + < Content Include = " . . \ . . \ . . \ libs \ $ ( NativeDependenciesConfigurationUnix ) \ libgrpc_csharp_ext . dylib " > <nl> + < Link > libgrpc_csharp_ext . x64 . dylib < / Link > <nl> + < CopyToOutputDirectory > PreserveNewest < / CopyToOutputDirectory > <nl> + < Pack > false < / Pack > <nl> + < / Content > <nl> + < / ItemGroup > <nl> + < / Project > <nl> deleted file mode 100644 <nl> index e22c7384fc5 . . 00000000000 <nl> mmm a / src / csharp / Grpc . Core / NativeDeps . Mac . targets <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project DefaultTargets = " Build " ToolsVersion = " 4 . 0 " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> - < ItemGroup > <nl> - < Content Include = " . . \ . . \ . . \ libs \ $ ( NativeDependenciesConfigurationUnix ) \ libgrpc_csharp_ext . dylib " > <nl> - < CopyToOutputDirectory > PreserveNewest < / CopyToOutputDirectory > <nl> - < Link > libgrpc_csharp_ext . x86 . dylib < / Link > <nl> - < / Content > <nl> - < / ItemGroup > <nl> - < / Project > <nl> \ No newline at end of file <nl> new file mode 100644 <nl> index 00000000000 . . 04f3b077ace <nl> mmm / dev / null <nl> ppp b / src / csharp / Grpc . Core / NativeDeps . Windows . csproj . include <nl> <nl> + < Project > <nl> + < ItemGroup > <nl> + < Content Include = " . . \ . . \ . . \ cmake \ build \ x64 \ $ ( NativeDependenciesConfiguration ) \ grpc_csharp_ext . dll " > <nl> + < CopyToOutputDirectory > PreserveNewest < / CopyToOutputDirectory > <nl> + < Link > grpc_csharp_ext . x64 . dll < / Link > <nl> + < Pack > false < / Pack > <nl> + < / Content > <nl> + < / ItemGroup > <nl> + < / Project > <nl> deleted file mode 100644 <nl> index 623f58b95b0 . . 00000000000 <nl> mmm a / src / csharp / Grpc . Core / NativeDeps . Windows . targets <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project DefaultTargets = " Build " ToolsVersion = " 4 . 0 " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> - < ItemGroup > <nl> - < Content Include = " . . \ . . \ . . \ cmake \ build \ Win32 \ $ ( NativeDependenciesConfiguration ) \ grpc_csharp_ext . dll " > <nl> - < CopyToOutputDirectory > PreserveNewest < / CopyToOutputDirectory > <nl> - < Link > grpc_csharp_ext . x86 . dll < / Link > <nl> - < / Content > <nl> - < / ItemGroup > <nl> - < / Project > <nl> \ No newline at end of file <nl> old mode 100644 <nl> new mode 100755 <nl> similarity index 83 % <nl> rename from src / csharp / Grpc . Core / NativeDeps . targets <nl> rename to src / csharp / Grpc . Core / NativeDeps . csproj . include <nl> index e187f72d266 . . a62c63e11d0 <nl> mmm a / src / csharp / Grpc . Core / NativeDeps . targets <nl> ppp b / src / csharp / Grpc . Core / NativeDeps . csproj . include <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project DefaultTargets = " Build " ToolsVersion = " 4 . 0 " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> + < ! - - Ensures that native libraries are copied to the output directory for Exe targets - - > <nl> + < Project > <nl> <nl> < PropertyGroup Condition = " ' $ ( NativeDependenciesConfiguration ) ' = = ' ' " > <nl> < NativeDependenciesConfiguration Condition = " ' $ ( Configuration ) ' = = ' Debug ' " > Debug < / NativeDependenciesConfiguration > <nl> <nl> < NativeDepsPlatform > Linux < / NativeDepsPlatform > <nl> < / PropertyGroup > <nl> <nl> - < Import Project = " NativeDeps . $ ( NativeDepsPlatform ) . targets " / > <nl> - < / Project > <nl> \ No newline at end of file <nl> + < Import Project = " NativeDeps . $ ( NativeDepsPlatform ) . csproj . include " / > <nl> + <nl> + < / Project > <nl> new file mode 100755 <nl> index 00000000000 . . ce9d0d2d5d2 <nl> mmm / dev / null <nl> ppp b / src / csharp / Grpc . Core / Version . csproj . include <nl> <nl> + < ! - - This file is generated - - > <nl> + < Project > <nl> + < PropertyGroup > <nl> + < GrpcCsharpVersion > 1 . 3 . 0 - dev < / GrpcCsharpVersion > <nl> + < GoogleProtobufVersion > 3 . 2 . 0 < / GoogleProtobufVersion > <nl> + < / PropertyGroup > <nl> + < / Project > <nl> deleted file mode 100644 <nl> index 53cfad52f0b . . 00000000000 <nl> mmm a / src / csharp / Grpc . Core / packages . config <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < packages > <nl> - < package id = " System . Interactive . Async " version = " 3 . 1 . 1 " targetFramework = " net45 " / > <nl> - < / packages > <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index a1306baa876 . . 00000000000 <nl> mmm a / src / csharp / Grpc . Core / project . json <nl> ppp / dev / null <nl> <nl> - { <nl> - " version " : " 1 . 3 . 0 - dev " , <nl> - " title " : " gRPC C # Core " , <nl> - " authors " : [ " Google Inc . " ] , <nl> - " copyright " : " Copyright 2015 , Google Inc . " , <nl> - " packOptions " : { <nl> - " summary " : " Core C # implementation of gRPC - an RPC library and framework " , <nl> - " description " : " Core C # implementation of gRPC - an RPC library and framework . See project site for more info . " , <nl> - " owners " : [ " grpc - packages " ] , <nl> - " licenseUrl " : " https : / / github . com / grpc / grpc / blob / master / LICENSE " , <nl> - " projectUrl " : " https : / / github . com / grpc / grpc " , <nl> - " requireLicenseAcceptance " : false , <nl> - " tags " : [ " gRPC RPC Protocol HTTP / 2 " ] , <nl> - " files " : { <nl> - " mappings " : { <nl> - " build / net45 / " : " Grpc . Core . targets " , <nl> - " runtimes / win / native / grpc_csharp_ext . x86 . dll " : " . . / nativelibs / windows_x86 / grpc_csharp_ext . dll " , <nl> - " runtimes / win / native / grpc_csharp_ext . x64 . dll " : " . . / nativelibs / windows_x64 / grpc_csharp_ext . dll " , <nl> - " runtimes / linux / native / libgrpc_csharp_ext . x86 . so " : " . . / nativelibs / linux_x86 / libgrpc_csharp_ext . so " , <nl> - " runtimes / linux / native / libgrpc_csharp_ext . x64 . so " : " . . / nativelibs / linux_x64 / libgrpc_csharp_ext . so " , <nl> - " runtimes / osx / native / libgrpc_csharp_ext . x86 . dylib " : " . . / nativelibs / macosx_x86 / libgrpc_csharp_ext . dylib " , <nl> - " runtimes / osx / native / libgrpc_csharp_ext . x64 . dylib " : " . . / nativelibs / macosx_x64 / libgrpc_csharp_ext . dylib " <nl> - } <nl> - } <nl> - } , <nl> - " buildOptions " : { <nl> - " embed " : [ " . . / . . / . . / etc / roots . pem " ] , <nl> - " define " : [ " SIGNED " ] , <nl> - " keyFile " : " . . / keys / Grpc . snk " , <nl> - " xmlDoc " : true <nl> - } , <nl> - " dependencies " : { <nl> - " System . Interactive . Async " : " 3 . 1 . 1 " <nl> - } , <nl> - " frameworks " : { <nl> - " net45 " : { } , <nl> - " netstandard1 . 5 " : { <nl> - " dependencies " : { <nl> - " NETStandard . Library " : " 1 . 6 . 0 " , <nl> - " System . Runtime . Loader " : " 4 . 0 . 0 " , <nl> - " System . Threading . Thread " : " 4 . 0 . 0 " <nl> - } <nl> - } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index 824c6822f7e . . 00000000000 <nl> mmm a / src / csharp / Grpc . Dotnet . sln <nl> ppp / dev / null <nl> <nl> - <nl> - Microsoft Visual Studio Solution File , Format Version 12 . 00 <nl> - # Visual Studio 14 <nl> - VisualStudioVersion = 14 . 0 . 25420 . 1 <nl> - MinimumVisualStudioVersion = 10 . 0 . 40219 . 1 <nl> - Project ( " { 8BB2217D - 0F2D - 49D1 - 97BC - 3654ED321F3B } " ) = " Grpc . Core " , " Grpc . Core \ Grpc . Core . xproj " , " { DC9908B6 - F291 - 4FC8 - A46D - 2EA2551790EC } " <nl> - EndProject <nl> - Project ( " { 8BB2217D - 0F2D - 49D1 - 97BC - 3654ED321F3B } " ) = " Grpc . Auth " , " Grpc . Auth \ Grpc . Auth . xproj " , " { C82631ED - 06D1 - 4458 - 87BC - 8257D12307A8 } " <nl> - EndProject <nl> - Project ( " { 8BB2217D - 0F2D - 49D1 - 97BC - 3654ED321F3B } " ) = " Grpc . Core . Tests " , " Grpc . Core . Tests \ Grpc . Core . Tests . xproj " , " { 759E23B2 - FC04 - 4695 - 902D - B073CDED3599 } " <nl> - EndProject <nl> - Project ( " { 8BB2217D - 0F2D - 49D1 - 97BC - 3654ED321F3B } " ) = " Grpc . Examples " , " Grpc . Examples \ Grpc . Examples . xproj " , " { C77B792D - FC78 - 4CE2 - 9522 - B40B0803C636 } " <nl> - EndProject <nl> - Project ( " { 8BB2217D - 0F2D - 49D1 - 97BC - 3654ED321F3B } " ) = " Grpc . Examples . MathClient " , " Grpc . Examples . MathClient \ Grpc . Examples . MathClient . xproj " , " { FD48DECA - 1622 - 4173 - B1D9 - 2101CF5E7C5F } " <nl> - EndProject <nl> - Project ( " { 8BB2217D - 0F2D - 49D1 - 97BC - 3654ED321F3B } " ) = " Grpc . Examples . MathServer " , " Grpc . Examples . MathServer \ Grpc . Examples . MathServer . xproj " , " { 58579368 - 5372 - 4E67 - ACD6 - 9B59CB9FA698 } " <nl> - EndProject <nl> - Project ( " { 8BB2217D - 0F2D - 49D1 - 97BC - 3654ED321F3B } " ) = " Grpc . Examples . Tests " , " Grpc . Examples . Tests \ Grpc . Examples . Tests . xproj " , " { C61714A6 - F633 - 44FB - 97F4 - C91F425C1D15 } " <nl> - EndProject <nl> - Project ( " { 8BB2217D - 0F2D - 49D1 - 97BC - 3654ED321F3B } " ) = " Grpc . HealthCheck " , " Grpc . HealthCheck \ Grpc . HealthCheck . xproj " , " { 3BE4AD0B - 2BF0 - 4D68 - B625 - F6018EF0DCFA } " <nl> - EndProject <nl> - Project ( " { 8BB2217D - 0F2D - 49D1 - 97BC - 3654ED321F3B } " ) = " Grpc . HealthCheck . Tests " , " Grpc . HealthCheck . Tests \ Grpc . HealthCheck . Tests . xproj " , " { 43DAFAC6 - 5343 - 4621 - 960E - A8A977EA3F0B } " <nl> - EndProject <nl> - Project ( " { 8BB2217D - 0F2D - 49D1 - 97BC - 3654ED321F3B } " ) = " Grpc . IntegrationTesting " , " Grpc . IntegrationTesting \ Grpc . IntegrationTesting . xproj " , " { 20354386 - 3E71 - 4046 - A269 - 3BC2A06F3EC8 } " <nl> - EndProject <nl> - Project ( " { 8BB2217D - 0F2D - 49D1 - 97BC - 3654ED321F3B } " ) = " Grpc . IntegrationTesting . Client " , " Grpc . IntegrationTesting . Client \ Grpc . IntegrationTesting . Client . xproj " , " { 48EA5BBE - 70E2 - 4198 - 869D - D7E59C45F30D } " <nl> - EndProject <nl> - Project ( " { 8BB2217D - 0F2D - 49D1 - 97BC - 3654ED321F3B } " ) = " Grpc . IntegrationTesting . QpsWorker " , " Grpc . IntegrationTesting . QpsWorker \ Grpc . IntegrationTesting . QpsWorker . xproj " , " { 661B70D7 - F56A - 46E0 - 9B81 - 6227B591B5E7 } " <nl> - EndProject <nl> - Project ( " { 8BB2217D - 0F2D - 49D1 - 97BC - 3654ED321F3B } " ) = " Grpc . IntegrationTesting . Server " , " Grpc . IntegrationTesting . Server \ Grpc . IntegrationTesting . Server . xproj " , " { 881F7AD1 - A84E - 47A2 - 9402 - 115C63C4031E } " <nl> - EndProject <nl> - Project ( " { 8BB2217D - 0F2D - 49D1 - 97BC - 3654ED321F3B } " ) = " Grpc . IntegrationTesting . StressClient " , " Grpc . IntegrationTesting . StressClient \ Grpc . IntegrationTesting . StressClient . xproj " , " { 0EBC910B - 8867 - 4D3E - 8686 - 91F34183D839 } " <nl> - EndProject <nl> - Project ( " { 8BB2217D - 0F2D - 49D1 - 97BC - 3654ED321F3B } " ) = " Grpc . Reflection " , " Grpc . Reflection \ Grpc . Reflection . xproj " , " { 2B372155 - 80BA - 4CF9 - 82D6 - 4B938E8EC3A0 } " <nl> - EndProject <nl> - Project ( " { 8BB2217D - 0F2D - 49D1 - 97BC - 3654ED321F3B } " ) = " Grpc . Reflection . Tests " , " Grpc . Reflection . Tests \ Grpc . Reflection . Tests . xproj " , " { FE90181D - A4B3 - 4A5C - 8490 - F07561E18E3B } " <nl> - EndProject <nl> - Global <nl> - GlobalSection ( SolutionConfigurationPlatforms ) = preSolution <nl> - Debug | Any CPU = Debug | Any CPU <nl> - Release | Any CPU = Release | Any CPU <nl> - EndGlobalSection <nl> - GlobalSection ( ProjectConfigurationPlatforms ) = postSolution <nl> - { DC9908B6 - F291 - 4FC8 - A46D - 2EA2551790EC } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> - { DC9908B6 - F291 - 4FC8 - A46D - 2EA2551790EC } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> - { DC9908B6 - F291 - 4FC8 - A46D - 2EA2551790EC } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> - { DC9908B6 - F291 - 4FC8 - A46D - 2EA2551790EC } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> - { C82631ED - 06D1 - 4458 - 87BC - 8257D12307A8 } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> - { C82631ED - 06D1 - 4458 - 87BC - 8257D12307A8 } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> - { C82631ED - 06D1 - 4458 - 87BC - 8257D12307A8 } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> - { C82631ED - 06D1 - 4458 - 87BC - 8257D12307A8 } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> - { 759E23B2 - FC04 - 4695 - 902D - B073CDED3599 } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> - { 759E23B2 - FC04 - 4695 - 902D - B073CDED3599 } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> - { 759E23B2 - FC04 - 4695 - 902D - B073CDED3599 } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> - { 759E23B2 - FC04 - 4695 - 902D - B073CDED3599 } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> - { C77B792D - FC78 - 4CE2 - 9522 - B40B0803C636 } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> - { C77B792D - FC78 - 4CE2 - 9522 - B40B0803C636 } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> - { C77B792D - FC78 - 4CE2 - 9522 - B40B0803C636 } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> - { C77B792D - FC78 - 4CE2 - 9522 - B40B0803C636 } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> - { FD48DECA - 1622 - 4173 - B1D9 - 2101CF5E7C5F } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> - { FD48DECA - 1622 - 4173 - B1D9 - 2101CF5E7C5F } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> - { FD48DECA - 1622 - 4173 - B1D9 - 2101CF5E7C5F } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> - { FD48DECA - 1622 - 4173 - B1D9 - 2101CF5E7C5F } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> - { 58579368 - 5372 - 4E67 - ACD6 - 9B59CB9FA698 } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> - { 58579368 - 5372 - 4E67 - ACD6 - 9B59CB9FA698 } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> - { 58579368 - 5372 - 4E67 - ACD6 - 9B59CB9FA698 } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> - { 58579368 - 5372 - 4E67 - ACD6 - 9B59CB9FA698 } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> - { C61714A6 - F633 - 44FB - 97F4 - C91F425C1D15 } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> - { C61714A6 - F633 - 44FB - 97F4 - C91F425C1D15 } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> - { C61714A6 - F633 - 44FB - 97F4 - C91F425C1D15 } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> - { C61714A6 - F633 - 44FB - 97F4 - C91F425C1D15 } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> - { 3BE4AD0B - 2BF0 - 4D68 - B625 - F6018EF0DCFA } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> - { 3BE4AD0B - 2BF0 - 4D68 - B625 - F6018EF0DCFA } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> - { 3BE4AD0B - 2BF0 - 4D68 - B625 - F6018EF0DCFA } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> - { 3BE4AD0B - 2BF0 - 4D68 - B625 - F6018EF0DCFA } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> - { 43DAFAC6 - 5343 - 4621 - 960E - A8A977EA3F0B } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> - { 43DAFAC6 - 5343 - 4621 - 960E - A8A977EA3F0B } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> - { 43DAFAC6 - 5343 - 4621 - 960E - A8A977EA3F0B } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> - { 43DAFAC6 - 5343 - 4621 - 960E - A8A977EA3F0B } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> - { 20354386 - 3E71 - 4046 - A269 - 3BC2A06F3EC8 } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> - { 20354386 - 3E71 - 4046 - A269 - 3BC2A06F3EC8 } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> - { 20354386 - 3E71 - 4046 - A269 - 3BC2A06F3EC8 } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> - { 20354386 - 3E71 - 4046 - A269 - 3BC2A06F3EC8 } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> - { 48EA5BBE - 70E2 - 4198 - 869D - D7E59C45F30D } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> - { 48EA5BBE - 70E2 - 4198 - 869D - D7E59C45F30D } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> - { 48EA5BBE - 70E2 - 4198 - 869D - D7E59C45F30D } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> - { 48EA5BBE - 70E2 - 4198 - 869D - D7E59C45F30D } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> - { 661B70D7 - F56A - 46E0 - 9B81 - 6227B591B5E7 } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> - { 661B70D7 - F56A - 46E0 - 9B81 - 6227B591B5E7 } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> - { 661B70D7 - F56A - 46E0 - 9B81 - 6227B591B5E7 } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> - { 661B70D7 - F56A - 46E0 - 9B81 - 6227B591B5E7 } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> - { 881F7AD1 - A84E - 47A2 - 9402 - 115C63C4031E } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> - { 881F7AD1 - A84E - 47A2 - 9402 - 115C63C4031E } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> - { 881F7AD1 - A84E - 47A2 - 9402 - 115C63C4031E } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> - { 881F7AD1 - A84E - 47A2 - 9402 - 115C63C4031E } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> - { 0EBC910B - 8867 - 4D3E - 8686 - 91F34183D839 } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> - { 0EBC910B - 8867 - 4D3E - 8686 - 91F34183D839 } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> - { 0EBC910B - 8867 - 4D3E - 8686 - 91F34183D839 } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> - { 0EBC910B - 8867 - 4D3E - 8686 - 91F34183D839 } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> - { 2B372155 - 80BA - 4CF9 - 82D6 - 4B938E8EC3A0 } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> - { 2B372155 - 80BA - 4CF9 - 82D6 - 4B938E8EC3A0 } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> - { 2B372155 - 80BA - 4CF9 - 82D6 - 4B938E8EC3A0 } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> - { 2B372155 - 80BA - 4CF9 - 82D6 - 4B938E8EC3A0 } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> - { FE90181D - A4B3 - 4A5C - 8490 - F07561E18E3B } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> - { FE90181D - A4B3 - 4A5C - 8490 - F07561E18E3B } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> - { FE90181D - A4B3 - 4A5C - 8490 - F07561E18E3B } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> - { FE90181D - A4B3 - 4A5C - 8490 - F07561E18E3B } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> - EndGlobalSection <nl> - GlobalSection ( SolutionProperties ) = preSolution <nl> - HideSolutionNode = FALSE <nl> - EndGlobalSection <nl> - EndGlobal <nl> old mode 100644 <nl> new mode 100755 <nl> index de4005c2f66 . . 08df026a53a <nl> mmm a / src / csharp / Grpc . Examples . MathClient / Grpc . Examples . MathClient . csproj <nl> ppp b / src / csharp / Grpc . Examples . MathClient / Grpc . Examples . MathClient . csproj <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project DefaultTargets = " Build " ToolsVersion = " 4 . 0 " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> + < Project Sdk = " Microsoft . NET . Sdk " > <nl> + <nl> + < Import Project = " . . \ Grpc . Core \ Version . csproj . include " / > <nl> + < Import Project = " . . \ Grpc . Core \ Common . csproj . include " / > <nl> + <nl> < PropertyGroup > <nl> - < Configuration Condition = " ' $ ( Configuration ) ' = = ' ' " > Debug < / Configuration > <nl> - < Platform Condition = " ' $ ( Platform ) ' = = ' ' " > AnyCPU < / Platform > <nl> - < ProductVersion > 10 . 0 . 0 < / ProductVersion > <nl> - < SchemaVersion > 2 . 0 < / SchemaVersion > <nl> - < ProjectGuid > { 61ECB8EE - 0C96 - 4F8E - B187 - 8E4D227417C0 } < / ProjectGuid > <nl> + < TargetFrameworks > net45 ; netcoreapp1 . 0 < / TargetFrameworks > <nl> + < AssemblyName > Grpc . Examples . MathClient < / AssemblyName > <nl> < OutputType > Exe < / OutputType > <nl> - < RootNamespace > math < / RootNamespace > <nl> - < AssemblyName > MathClient < / AssemblyName > <nl> - < TargetFrameworkVersion > v4 . 5 < / TargetFrameworkVersion > <nl> - < / PropertyGroup > <nl> - < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | AnyCPU ' " > <nl> - < DebugSymbols > true < / DebugSymbols > <nl> - < DebugType > full < / DebugType > <nl> - < Optimize > false < / Optimize > <nl> - < OutputPath > bin \ Debug < / OutputPath > <nl> - < DefineConstants > DEBUG ; < / DefineConstants > <nl> - < ErrorReport > prompt < / ErrorReport > <nl> - < WarningLevel > 4 < / WarningLevel > <nl> - < / PropertyGroup > <nl> - < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Release | AnyCPU ' " > <nl> - < DebugType > pdbonly < / DebugType > <nl> - < Optimize > true < / Optimize > <nl> - < OutputPath > bin \ Release < / OutputPath > <nl> - < ErrorReport > prompt < / ErrorReport > <nl> - < WarningLevel > 4 < / WarningLevel > <nl> + < PackageId > Grpc . Examples . MathClient < / PackageId > <nl> + < RuntimeFrameworkVersion Condition = " ' $ ( TargetFramework ) ' = = ' netcoreapp1 . 0 ' " > 1 . 0 . 4 < / RuntimeFrameworkVersion > <nl> < / PropertyGroup > <nl> + <nl> < ItemGroup > <nl> - < Reference Include = " System " / > <nl> + < ProjectReference Include = " . . / Grpc . Examples / Grpc . Examples . csproj " / > <nl> < / ItemGroup > <nl> - < ItemGroup > <nl> - < Compile Include = " . . \ Grpc . Core \ Version . cs " > <nl> - < Link > Version . cs < / Link > <nl> - < / Compile > <nl> - < Compile Include = " Properties \ AssemblyInfo . cs " / > <nl> - < Compile Include = " MathClient . cs " / > <nl> - < / ItemGroup > <nl> - < Import Project = " $ ( MSBuildBinPath ) \ Microsoft . CSharp . targets " / > <nl> - < ItemGroup > <nl> - < ProjectReference Include = " . . \ Grpc . Core \ Grpc . Core . csproj " > <nl> - < Project > { CCC4440E - 49F7 - 4790 - B0AF - FEABB0837AE7 } < / Project > <nl> - < Name > Grpc . Core < / Name > <nl> - < / ProjectReference > <nl> - < ProjectReference Include = " . . \ Grpc . Examples \ Grpc . Examples . csproj " > <nl> - < Project > { 7DC1433E - 3225 - 42C7 - B7EA - 546D56E27A4B } < / Project > <nl> - < Name > Grpc . Examples < / Name > <nl> - < / ProjectReference > <nl> + <nl> + < ItemGroup Condition = " ' $ ( TargetFramework ) ' = = ' net45 ' " > <nl> + < Reference Include = " System " / > <nl> + < Reference Include = " Microsoft . CSharp " / > <nl> < / ItemGroup > <nl> + <nl> < ItemGroup > <nl> - < None Include = " Grpc . Examples . MathClient . project . json " / > <nl> + < Compile Include = " . . \ Grpc . Core \ Version . cs " / > <nl> < / ItemGroup > <nl> - < / Project > <nl> \ No newline at end of file <nl> + <nl> + < / Project > <nl> deleted file mode 100644 <nl> index c2f5bcb1637 . . 00000000000 <nl> mmm a / src / csharp / Grpc . Examples . MathClient / Grpc . Examples . MathClient . project . json <nl> ppp / dev / null <nl> <nl> - { <nl> - " frameworks " : { <nl> - " net45 " : { } <nl> - } , <nl> - " runtimes " : { <nl> - " win " : { } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index 4655bd43774 . . 00000000000 <nl> mmm a / src / csharp / Grpc . Examples . MathClient / Grpc . Examples . MathClient . xproj <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project ToolsVersion = " 14 . 0 . 25123 " DefaultTargets = " Build " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> - < PropertyGroup > <nl> - < VisualStudioVersion Condition = " ' $ ( VisualStudioVersion ) ' = = ' ' " > 14 . 0 . 25123 < / VisualStudioVersion > <nl> - < VSToolsPath Condition = " ' $ ( VSToolsPath ) ' = = ' ' " > $ ( MSBuildExtensionsPath32 ) \ Microsoft \ VisualStudio \ v $ ( VisualStudioVersion ) < / VSToolsPath > <nl> - < / PropertyGroup > <nl> - < Import Project = " $ ( VSToolsPath ) \ DNX \ Microsoft . DNX . Props " Condition = " ' $ ( VSToolsPath ) ' ! = ' ' " / > <nl> - < PropertyGroup Label = " Globals " > <nl> - < ProjectGuid > fd48deca - 1622 - 4173 - b1d9 - 2101cf5e7c5f < / ProjectGuid > <nl> - < RootNamespace > Grpc . Examples . MathClient < / RootNamespace > <nl> - < BaseIntermediateOutputPath Condition = " ' $ ( BaseIntermediateOutputPath ) ' = = ' ' " > . . \ artifacts \ obj \ $ ( MSBuildProjectName ) < / BaseIntermediateOutputPath > <nl> - < OutputPath Condition = " ' $ ( OutputPath ) ' = = ' ' " > . \ bin \ < / OutputPath > <nl> - < / PropertyGroup > <nl> - < PropertyGroup > <nl> - < SchemaVersion > 2 . 0 < / SchemaVersion > <nl> - < / PropertyGroup > <nl> - < Import Project = " $ ( VSToolsPath ) \ DNX \ Microsoft . DNX . targets " Condition = " ' $ ( VSToolsPath ) ' ! = ' ' " / > <nl> - < / Project > <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 79ece06bef6 . . 00000000000 <nl> mmm a / src / csharp / Grpc . Examples . MathClient / packages . config <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < packages > <nl> - < / packages > <nl> deleted file mode 100644 <nl> index 81c17151aa5 . . 00000000000 <nl> mmm a / src / csharp / Grpc . Examples . MathClient / project . json <nl> ppp / dev / null <nl> <nl> - { <nl> - " buildOptions " : { <nl> - " emitEntryPoint " : true <nl> - } , <nl> - " configurations " : { <nl> - " Debug " : { <nl> - " buildOptions " : { <nl> - " define " : [ " SIGNED " ] , <nl> - " keyFile " : " . . / keys / Grpc . snk " , <nl> - " xmlDoc " : true , <nl> - " compile " : { <nl> - " includeFiles " : [ " . . / Grpc . Core / Version . cs " ] <nl> - } , <nl> - " copyToOutput " : { <nl> - " mappings " : { <nl> - " grpc_csharp_ext . x64 . dll " : " . . / . . / . . / cmake / build / x64 / Debug / grpc_csharp_ext . dll " , <nl> - " grpc_csharp_ext . x86 . dll " : " . . / . . / . . / cmake / build / Win32 / Debug / grpc_csharp_ext . dll " , <nl> - " libgrpc_csharp_ext . x64 . so " : " . . / . . / . . / libs / dbg / libgrpc_csharp_ext . so " , <nl> - " libgrpc_csharp_ext . x64 . dylib " : " . . / . . / . . / libs / dbg / libgrpc_csharp_ext . dylib " <nl> - } <nl> - } <nl> - } <nl> - } , <nl> - " Release " : { <nl> - " buildOptions " : { <nl> - " define " : [ " SIGNED " ] , <nl> - " keyFile " : " . . / keys / Grpc . snk " , <nl> - " xmlDoc " : true , <nl> - " compile " : { <nl> - " includeFiles " : [ " . . / Grpc . Core / Version . cs " ] <nl> - } , <nl> - " copyToOutput " : { <nl> - " mappings " : { <nl> - " grpc_csharp_ext . x64 . dll " : " . . / . . / . . / cmake / build / x64 / Release / grpc_csharp_ext . dll " , <nl> - " grpc_csharp_ext . x86 . dll " : " . . / . . / . . / cmake / build / Win32 / Release / grpc_csharp_ext . dll " , <nl> - " libgrpc_csharp_ext . x64 . so " : " . . / . . / . . / libs / opt / libgrpc_csharp_ext . so " , <nl> - " libgrpc_csharp_ext . x64 . dylib " : " . . / . . / . . / libs / opt / libgrpc_csharp_ext . dylib " <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } , <nl> - <nl> - " dependencies " : { <nl> - " Grpc . Examples " : { <nl> - " target " : " project " <nl> - } <nl> - } , <nl> - " frameworks " : { <nl> - " net45 " : { } , <nl> - " netcoreapp1 . 0 " : { <nl> - " dependencies " : { <nl> - " Microsoft . NETCore . App " : { <nl> - " type " : " platform " , <nl> - " version " : " 1 . 0 . 0 " <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } <nl> old mode 100644 <nl> new mode 100755 <nl> index 3f38de2b714 . . a02937474a1 <nl> mmm a / src / csharp / Grpc . Examples . MathServer / Grpc . Examples . MathServer . csproj <nl> ppp b / src / csharp / Grpc . Examples . MathServer / Grpc . Examples . MathServer . csproj <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project DefaultTargets = " Build " ToolsVersion = " 4 . 0 " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> + < Project Sdk = " Microsoft . NET . Sdk " > <nl> + <nl> + < Import Project = " . . \ Grpc . Core \ Version . csproj . include " / > <nl> + < Import Project = " . . \ Grpc . Core \ Common . csproj . include " / > <nl> + <nl> < PropertyGroup > <nl> - < Configuration Condition = " ' $ ( Configuration ) ' = = ' ' " > Debug < / Configuration > <nl> - < Platform Condition = " ' $ ( Platform ) ' = = ' ' " > AnyCPU < / Platform > <nl> - < ProductVersion > 10 . 0 . 0 < / ProductVersion > <nl> - < SchemaVersion > 2 . 0 < / SchemaVersion > <nl> - < ProjectGuid > { BF62FE08 - 373A - 43D6 - 9D73 - 41CAA38B7011 } < / ProjectGuid > <nl> + < TargetFrameworks > net45 ; netcoreapp1 . 0 < / TargetFrameworks > <nl> + < AssemblyName > Grpc . Examples . MathServer < / AssemblyName > <nl> < OutputType > Exe < / OutputType > <nl> - < RootNamespace > Grpc . Examples . MathServer < / RootNamespace > <nl> - < AssemblyName > MathServer < / AssemblyName > <nl> - < TargetFrameworkVersion > v4 . 5 < / TargetFrameworkVersion > <nl> - < / PropertyGroup > <nl> - < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | AnyCPU ' " > <nl> - < DebugSymbols > true < / DebugSymbols > <nl> - < DebugType > full < / DebugType > <nl> - < Optimize > false < / Optimize > <nl> - < OutputPath > bin \ Debug < / OutputPath > <nl> - < DefineConstants > DEBUG ; < / DefineConstants > <nl> - < ErrorReport > prompt < / ErrorReport > <nl> - < WarningLevel > 4 < / WarningLevel > <nl> - < / PropertyGroup > <nl> - < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Release | AnyCPU ' " > <nl> - < DebugType > pdbonly < / DebugType > <nl> - < Optimize > true < / Optimize > <nl> - < OutputPath > bin \ Release < / OutputPath > <nl> - < ErrorReport > prompt < / ErrorReport > <nl> - < WarningLevel > 4 < / WarningLevel > <nl> + < PackageId > Grpc . Examples . MathServer < / PackageId > <nl> + < RuntimeFrameworkVersion Condition = " ' $ ( TargetFramework ) ' = = ' netcoreapp1 . 0 ' " > 1 . 0 . 4 < / RuntimeFrameworkVersion > <nl> < / PropertyGroup > <nl> + <nl> < ItemGroup > <nl> - < Reference Include = " System " / > <nl> + < ProjectReference Include = " . . / Grpc . Examples / Grpc . Examples . csproj " / > <nl> < / ItemGroup > <nl> - < ItemGroup > <nl> - < Compile Include = " . . \ Grpc . Core \ Version . cs " > <nl> - < Link > Version . cs < / Link > <nl> - < / Compile > <nl> - < Compile Include = " Properties \ AssemblyInfo . cs " / > <nl> - < Compile Include = " MathServer . cs " / > <nl> - < / ItemGroup > <nl> - < Import Project = " $ ( MSBuildBinPath ) \ Microsoft . CSharp . targets " / > <nl> - < ItemGroup > <nl> - < ProjectReference Include = " . . \ Grpc . Core \ Grpc . Core . csproj " > <nl> - < Project > { CCC4440E - 49F7 - 4790 - B0AF - FEABB0837AE7 } < / Project > <nl> - < Name > Grpc . Core < / Name > <nl> - < / ProjectReference > <nl> - < ProjectReference Include = " . . \ Grpc . Examples \ Grpc . Examples . csproj " > <nl> - < Project > { 7DC1433E - 3225 - 42C7 - B7EA - 546D56E27A4B } < / Project > <nl> - < Name > Grpc . Examples < / Name > <nl> - < / ProjectReference > <nl> + <nl> + < ItemGroup Condition = " ' $ ( TargetFramework ) ' = = ' net45 ' " > <nl> + < Reference Include = " System " / > <nl> + < Reference Include = " Microsoft . CSharp " / > <nl> < / ItemGroup > <nl> + <nl> < ItemGroup > <nl> - < None Include = " Grpc . Examples . MathServer . project . json " / > <nl> + < Compile Include = " . . \ Grpc . Core \ Version . cs " / > <nl> < / ItemGroup > <nl> - < / Project > <nl> \ No newline at end of file <nl> + <nl> + < / Project > <nl> deleted file mode 100644 <nl> index c2f5bcb1637 . . 00000000000 <nl> mmm a / src / csharp / Grpc . Examples . MathServer / Grpc . Examples . MathServer . project . json <nl> ppp / dev / null <nl> <nl> - { <nl> - " frameworks " : { <nl> - " net45 " : { } <nl> - } , <nl> - " runtimes " : { <nl> - " win " : { } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index 38a449e8f29 . . 00000000000 <nl> mmm a / src / csharp / Grpc . Examples . MathServer / Grpc . Examples . MathServer . xproj <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project ToolsVersion = " 14 . 0 . 25123 " DefaultTargets = " Build " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> - < PropertyGroup > <nl> - < VisualStudioVersion Condition = " ' $ ( VisualStudioVersion ) ' = = ' ' " > 14 . 0 . 25123 < / VisualStudioVersion > <nl> - < VSToolsPath Condition = " ' $ ( VSToolsPath ) ' = = ' ' " > $ ( MSBuildExtensionsPath32 ) \ Microsoft \ VisualStudio \ v $ ( VisualStudioVersion ) < / VSToolsPath > <nl> - < / PropertyGroup > <nl> - < Import Project = " $ ( VSToolsPath ) \ DNX \ Microsoft . DNX . Props " Condition = " ' $ ( VSToolsPath ) ' ! = ' ' " / > <nl> - < PropertyGroup Label = " Globals " > <nl> - < ProjectGuid > 58579368 - 5372 - 4e67 - acd6 - 9b59cb9fa698 < / ProjectGuid > <nl> - < RootNamespace > Grpc . Examples . MathServer < / RootNamespace > <nl> - < BaseIntermediateOutputPath Condition = " ' $ ( BaseIntermediateOutputPath ) ' = = ' ' " > . . \ artifacts \ obj \ $ ( MSBuildProjectName ) < / BaseIntermediateOutputPath > <nl> - < OutputPath Condition = " ' $ ( OutputPath ) ' = = ' ' " > . \ bin \ < / OutputPath > <nl> - < / PropertyGroup > <nl> - < PropertyGroup > <nl> - < SchemaVersion > 2 . 0 < / SchemaVersion > <nl> - < / PropertyGroup > <nl> - < Import Project = " $ ( VSToolsPath ) \ DNX \ Microsoft . DNX . targets " Condition = " ' $ ( VSToolsPath ) ' ! = ' ' " / > <nl> - < / Project > <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 79ece06bef6 . . 00000000000 <nl> mmm a / src / csharp / Grpc . Examples . MathServer / packages . config <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < packages > <nl> - < / packages > <nl> deleted file mode 100644 <nl> index 81c17151aa5 . . 00000000000 <nl> mmm a / src / csharp / Grpc . Examples . MathServer / project . json <nl> ppp / dev / null <nl> <nl> - { <nl> - " buildOptions " : { <nl> - " emitEntryPoint " : true <nl> - } , <nl> - " configurations " : { <nl> - " Debug " : { <nl> - " buildOptions " : { <nl> - " define " : [ " SIGNED " ] , <nl> - " keyFile " : " . . / keys / Grpc . snk " , <nl> - " xmlDoc " : true , <nl> - " compile " : { <nl> - " includeFiles " : [ " . . / Grpc . Core / Version . cs " ] <nl> - } , <nl> - " copyToOutput " : { <nl> - " mappings " : { <nl> - " grpc_csharp_ext . x64 . dll " : " . . / . . / . . / cmake / build / x64 / Debug / grpc_csharp_ext . dll " , <nl> - " grpc_csharp_ext . x86 . dll " : " . . / . . / . . / cmake / build / Win32 / Debug / grpc_csharp_ext . dll " , <nl> - " libgrpc_csharp_ext . x64 . so " : " . . / . . / . . / libs / dbg / libgrpc_csharp_ext . so " , <nl> - " libgrpc_csharp_ext . x64 . dylib " : " . . / . . / . . / libs / dbg / libgrpc_csharp_ext . dylib " <nl> - } <nl> - } <nl> - } <nl> - } , <nl> - " Release " : { <nl> - " buildOptions " : { <nl> - " define " : [ " SIGNED " ] , <nl> - " keyFile " : " . . / keys / Grpc . snk " , <nl> - " xmlDoc " : true , <nl> - " compile " : { <nl> - " includeFiles " : [ " . . / Grpc . Core / Version . cs " ] <nl> - } , <nl> - " copyToOutput " : { <nl> - " mappings " : { <nl> - " grpc_csharp_ext . x64 . dll " : " . . / . . / . . / cmake / build / x64 / Release / grpc_csharp_ext . dll " , <nl> - " grpc_csharp_ext . x86 . dll " : " . . / . . / . . / cmake / build / Win32 / Release / grpc_csharp_ext . dll " , <nl> - " libgrpc_csharp_ext . x64 . so " : " . . / . . / . . / libs / opt / libgrpc_csharp_ext . so " , <nl> - " libgrpc_csharp_ext . x64 . dylib " : " . . / . . / . . / libs / opt / libgrpc_csharp_ext . dylib " <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } , <nl> - <nl> - " dependencies " : { <nl> - " Grpc . Examples " : { <nl> - " target " : " project " <nl> - } <nl> - } , <nl> - " frameworks " : { <nl> - " net45 " : { } , <nl> - " netcoreapp1 . 0 " : { <nl> - " dependencies " : { <nl> - " Microsoft . NETCore . App " : { <nl> - " type " : " platform " , <nl> - " version " : " 1 . 0 . 0 " <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } <nl> old mode 100644 <nl> new mode 100755 <nl> index c96243b1c70 . . 9a8e62cc8be <nl> mmm a / src / csharp / Grpc . Examples . Tests / Grpc . Examples . Tests . csproj <nl> ppp b / src / csharp / Grpc . Examples . Tests / Grpc . Examples . Tests . csproj <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project DefaultTargets = " Build " ToolsVersion = " 4 . 0 " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> + < Project Sdk = " Microsoft . NET . Sdk " > <nl> + <nl> + < Import Project = " . . \ Grpc . Core \ Version . csproj . include " / > <nl> + < Import Project = " . . \ Grpc . Core \ Common . csproj . include " / > <nl> + <nl> < PropertyGroup > <nl> - < Configuration Condition = " ' $ ( Configuration ) ' = = ' ' " > Debug < / Configuration > <nl> - < Platform Condition = " ' $ ( Platform ) ' = = ' ' " > AnyCPU < / Platform > <nl> - < ProjectGuid > { 143B1C29 - C442 - 4BE0 - BF3F - A8F92288AC9F } < / ProjectGuid > <nl> - < OutputType > Exe < / OutputType > <nl> - < RootNamespace > Grpc . Examples . Tests < / RootNamespace > <nl> + < TargetFrameworks > net45 ; netcoreapp1 . 0 < / TargetFrameworks > <nl> < AssemblyName > Grpc . Examples . Tests < / AssemblyName > <nl> - < TargetFrameworkVersion > v4 . 5 < / TargetFrameworkVersion > <nl> - < / PropertyGroup > <nl> - < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | AnyCPU ' " > <nl> - < DebugSymbols > true < / DebugSymbols > <nl> - < DebugType > full < / DebugType > <nl> - < Optimize > false < / Optimize > <nl> - < OutputPath > bin \ Debug < / OutputPath > <nl> - < DefineConstants > DEBUG ; < / DefineConstants > <nl> - < ErrorReport > prompt < / ErrorReport > <nl> - < WarningLevel > 4 < / WarningLevel > <nl> - < / PropertyGroup > <nl> - < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Release | AnyCPU ' " > <nl> - < DebugType > pdbonly < / DebugType > <nl> - < Optimize > true < / Optimize > <nl> - < OutputPath > bin \ Release < / OutputPath > <nl> - < ErrorReport > prompt < / ErrorReport > <nl> - < WarningLevel > 4 < / WarningLevel > <nl> + < OutputType > Exe < / OutputType > <nl> + < PackageId > Grpc . Examples . Tests < / PackageId > <nl> + < PackageTargetFallback Condition = " ' $ ( TargetFramework ) ' = = ' netcoreapp1 . 0 ' " > $ ( PackageTargetFallback ) ; portable - net45 < / PackageTargetFallback > <nl> + < RuntimeFrameworkVersion Condition = " ' $ ( TargetFramework ) ' = = ' netcoreapp1 . 0 ' " > 1 . 0 . 4 < / RuntimeFrameworkVersion > <nl> < / PropertyGroup > <nl> + <nl> < ItemGroup > <nl> - < Reference Include = " System " / > <nl> - < Reference Include = " System . Interactive . Async " > <nl> - < HintPath > . . \ packages \ System . Interactive . Async . 3 . 1 . 1 \ lib \ net45 \ System . Interactive . Async . dll < / HintPath > <nl> - < / Reference > <nl> - < Reference Include = " nunit . framework " > <nl> - < HintPath > . . \ packages \ NUnit . 3 . 6 . 0 \ lib \ net45 \ nunit . framework . dll < / HintPath > <nl> - < / Reference > <nl> - < Reference Include = " nunitlite " > <nl> - < HintPath > . . \ packages \ NUnitLite . 3 . 6 . 0 \ lib \ net45 \ nunitlite . dll < / HintPath > <nl> - < / Reference > <nl> - < Reference Include = " Google . Protobuf " > <nl> - < HintPath > . . \ packages \ Google . Protobuf . 3 . 2 . 0 \ lib \ net45 \ Google . Protobuf . dll < / HintPath > <nl> - < / Reference > <nl> + < ProjectReference Include = " . . / Grpc . Examples / Grpc . Examples . csproj " / > <nl> < / ItemGroup > <nl> + <nl> < ItemGroup > <nl> - < Compile Include = " . . \ Grpc . Core \ Version . cs " > <nl> - < Link > Version . cs < / Link > <nl> - < / Compile > <nl> - < Compile Include = " Properties \ AssemblyInfo . cs " / > <nl> - < Compile Include = " MathClientServerTests . cs " / > <nl> - < Compile Include = " NUnitMain . cs " / > <nl> + < PackageReference Include = " NUnit " Version = " 3 . 6 . 0 " / > <nl> + < PackageReference Include = " NUnitLite " Version = " 3 . 6 . 0 " / > <nl> < / ItemGroup > <nl> - < Import Project = " $ ( MSBuildBinPath ) \ Microsoft . CSharp . targets " / > <nl> - < ItemGroup > <nl> - < ProjectReference Include = " . . \ Grpc . Core \ Grpc . Core . csproj " > <nl> - < Project > { CCC4440E - 49F7 - 4790 - B0AF - FEABB0837AE7 } < / Project > <nl> - < Name > Grpc . Core < / Name > <nl> - < / ProjectReference > <nl> - < ProjectReference Include = " . . \ Grpc . Examples \ Grpc . Examples . csproj " > <nl> - < Project > { 7DC1433E - 3225 - 42C7 - B7EA - 546D56E27A4B } < / Project > <nl> - < Name > Grpc . Examples < / Name > <nl> - < / ProjectReference > <nl> - < / ItemGroup > <nl> - < ItemGroup > <nl> - < None Include = " Grpc . Examples . Tests . project . json " / > <nl> - < None Include = " packages . config " / > <nl> + <nl> + < ItemGroup Condition = " ' $ ( TargetFramework ) ' = = ' net45 ' " > <nl> + < Reference Include = " System " / > <nl> + < Reference Include = " Microsoft . CSharp " / > <nl> < / ItemGroup > <nl> + <nl> < ItemGroup > <nl> - < Service Include = " { 82A7F48D - 3B50 - 4B1E - B82E - 3ADA8210C358 } " / > <nl> + < Compile Include = " . . \ Grpc . Core \ Version . cs " / > <nl> < / ItemGroup > <nl> + <nl> < / Project > <nl> deleted file mode 100644 <nl> index c2f5bcb1637 . . 00000000000 <nl> mmm a / src / csharp / Grpc . Examples . Tests / Grpc . Examples . Tests . project . json <nl> ppp / dev / null <nl> <nl> - { <nl> - " frameworks " : { <nl> - " net45 " : { } <nl> - } , <nl> - " runtimes " : { <nl> - " win " : { } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index 9cecd18b2e4 . . 00000000000 <nl> mmm a / src / csharp / Grpc . Examples . Tests / Grpc . Examples . Tests . xproj <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project ToolsVersion = " 14 . 0 . 25123 " DefaultTargets = " Build " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> - < PropertyGroup > <nl> - < VisualStudioVersion Condition = " ' $ ( VisualStudioVersion ) ' = = ' ' " > 14 . 0 . 25123 < / VisualStudioVersion > <nl> - < VSToolsPath Condition = " ' $ ( VSToolsPath ) ' = = ' ' " > $ ( MSBuildExtensionsPath32 ) \ Microsoft \ VisualStudio \ v $ ( VisualStudioVersion ) < / VSToolsPath > <nl> - < / PropertyGroup > <nl> - < Import Project = " $ ( VSToolsPath ) \ DNX \ Microsoft . DNX . Props " Condition = " ' $ ( VSToolsPath ) ' ! = ' ' " / > <nl> - < PropertyGroup Label = " Globals " > <nl> - < ProjectGuid > c61714a6 - f633 - 44fb - 97f4 - c91f425c1d15 < / ProjectGuid > <nl> - < RootNamespace > Grpc . Examples . Tests < / RootNamespace > <nl> - < BaseIntermediateOutputPath Condition = " ' $ ( BaseIntermediateOutputPath ) ' = = ' ' " > . . \ artifacts \ obj \ $ ( MSBuildProjectName ) < / BaseIntermediateOutputPath > <nl> - < OutputPath Condition = " ' $ ( OutputPath ) ' = = ' ' " > . \ bin \ < / OutputPath > <nl> - < / PropertyGroup > <nl> - < PropertyGroup > <nl> - < SchemaVersion > 2 . 0 < / SchemaVersion > <nl> - < / PropertyGroup > <nl> - < Import Project = " $ ( VSToolsPath ) \ DNX \ Microsoft . DNX . targets " Condition = " ' $ ( VSToolsPath ) ' ! = ' ' " / > <nl> - < / Project > <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 8a7f7a0652a . . 00000000000 <nl> mmm a / src / csharp / Grpc . Examples . Tests / packages . config <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < packages > <nl> - < package id = " Google . Protobuf " version = " 3 . 2 . 0 " targetFramework = " net45 " / > <nl> - < package id = " NUnit " version = " 3 . 6 . 0 " targetFramework = " net45 " / > <nl> - < package id = " NUnitLite " version = " 3 . 6 . 0 " targetFramework = " net45 " / > <nl> - < package id = " System . Interactive . Async " version = " 3 . 1 . 1 " targetFramework = " net45 " / > <nl> - < / packages > <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 4ffcaf57fd9 . . 00000000000 <nl> mmm a / src / csharp / Grpc . Examples . Tests / project . json <nl> ppp / dev / null <nl> <nl> - { <nl> - " buildOptions " : { <nl> - " emitEntryPoint " : true <nl> - } , <nl> - " configurations " : { <nl> - " Debug " : { <nl> - " buildOptions " : { <nl> - " define " : [ " SIGNED " ] , <nl> - " keyFile " : " . . / keys / Grpc . snk " , <nl> - " xmlDoc " : true , <nl> - " compile " : { <nl> - " includeFiles " : [ " . . / Grpc . Core / Version . cs " ] <nl> - } , <nl> - " copyToOutput " : { <nl> - " mappings " : { <nl> - " grpc_csharp_ext . x64 . dll " : " . . / . . / . . / cmake / build / x64 / Debug / grpc_csharp_ext . dll " , <nl> - " grpc_csharp_ext . x86 . dll " : " . . / . . / . . / cmake / build / Win32 / Debug / grpc_csharp_ext . dll " , <nl> - " libgrpc_csharp_ext . x64 . so " : " . . / . . / . . / libs / dbg / libgrpc_csharp_ext . so " , <nl> - " libgrpc_csharp_ext . x64 . dylib " : " . . / . . / . . / libs / dbg / libgrpc_csharp_ext . dylib " <nl> - } <nl> - } <nl> - } <nl> - } , <nl> - " Release " : { <nl> - " buildOptions " : { <nl> - " define " : [ " SIGNED " ] , <nl> - " keyFile " : " . . / keys / Grpc . snk " , <nl> - " xmlDoc " : true , <nl> - " compile " : { <nl> - " includeFiles " : [ " . . / Grpc . Core / Version . cs " ] <nl> - } , <nl> - " copyToOutput " : { <nl> - " mappings " : { <nl> - " grpc_csharp_ext . x64 . dll " : " . . / . . / . . / cmake / build / x64 / Release / grpc_csharp_ext . dll " , <nl> - " grpc_csharp_ext . x86 . dll " : " . . / . . / . . / cmake / build / Win32 / Release / grpc_csharp_ext . dll " , <nl> - " libgrpc_csharp_ext . x64 . so " : " . . / . . / . . / libs / opt / libgrpc_csharp_ext . so " , <nl> - " libgrpc_csharp_ext . x64 . dylib " : " . . / . . / . . / libs / opt / libgrpc_csharp_ext . dylib " <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } , <nl> - <nl> - " dependencies " : { <nl> - " Grpc . Examples " : { <nl> - " target " : " project " <nl> - } , <nl> - " NUnit " : " 3 . 6 . 0 " , <nl> - " NUnitLite " : " 3 . 6 . 0 " <nl> - } , <nl> - " frameworks " : { <nl> - " net45 " : { } , <nl> - " netcoreapp1 . 0 " : { <nl> - " imports " : [ <nl> - " portable - net45 " <nl> - ] , <nl> - " dependencies " : { <nl> - " Microsoft . NETCore . App " : { <nl> - " type " : " platform " , <nl> - " version " : " 1 . 0 . 0 " <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } <nl> old mode 100644 <nl> new mode 100755 <nl> index fc927543f73 . . 625c1723bc8 <nl> mmm a / src / csharp / Grpc . Examples / Grpc . Examples . csproj <nl> ppp b / src / csharp / Grpc . Examples / Grpc . Examples . csproj <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project DefaultTargets = " Build " ToolsVersion = " 4 . 0 " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> + < Project Sdk = " Microsoft . NET . Sdk " > <nl> + <nl> + < Import Project = " . . \ Grpc . Core \ Version . csproj . include " / > <nl> + < Import Project = " . . \ Grpc . Core \ Common . csproj . include " / > <nl> + <nl> < PropertyGroup > <nl> - < Configuration Condition = " ' $ ( Configuration ) ' = = ' ' " > Debug < / Configuration > <nl> - < Platform Condition = " ' $ ( Platform ) ' = = ' ' " > AnyCPU < / Platform > <nl> - < ProjectGuid > { 7DC1433E - 3225 - 42C7 - B7EA - 546D56E27A4B } < / ProjectGuid > <nl> - < OutputType > Library < / OutputType > <nl> - < RootNamespace > Grpc . Examples < / RootNamespace > <nl> + < TargetFrameworks > net45 ; netcoreapp1 . 0 < / TargetFrameworks > <nl> < AssemblyName > Grpc . Examples < / AssemblyName > <nl> - < TargetFrameworkVersion > v4 . 5 < / TargetFrameworkVersion > <nl> - < / PropertyGroup > <nl> - < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | AnyCPU ' " > <nl> - < DebugSymbols > true < / DebugSymbols > <nl> - < DebugType > full < / DebugType > <nl> - < Optimize > false < / Optimize > <nl> - < OutputPath > bin \ Debug < / OutputPath > <nl> - < DefineConstants > DEBUG ; < / DefineConstants > <nl> - < ErrorReport > prompt < / ErrorReport > <nl> - < WarningLevel > 4 < / WarningLevel > <nl> - < / PropertyGroup > <nl> - < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Release | AnyCPU ' " > <nl> - < DebugType > pdbonly < / DebugType > <nl> - < Optimize > true < / Optimize > <nl> - < OutputPath > bin \ Release < / OutputPath > <nl> - < ErrorReport > prompt < / ErrorReport > <nl> - < WarningLevel > 4 < / WarningLevel > <nl> + < PackageId > Grpc . Examples < / PackageId > <nl> + < RuntimeFrameworkVersion Condition = " ' $ ( TargetFramework ) ' = = ' netcoreapp1 . 0 ' " > 1 . 0 . 4 < / RuntimeFrameworkVersion > <nl> < / PropertyGroup > <nl> + <nl> < ItemGroup > <nl> - < Reference Include = " System " / > <nl> - < Reference Include = " System . Data . Linq " / > <nl> - < Reference Include = " System . Interactive . Async " > <nl> - < HintPath > . . \ packages \ System . Interactive . Async . 3 . 1 . 1 \ lib \ net45 \ System . Interactive . Async . dll < / HintPath > <nl> - < / Reference > <nl> - < Reference Include = " nunit . framework " > <nl> - < HintPath > . . \ packages \ NUnit . 3 . 6 . 0 \ lib \ net45 \ nunit . framework . dll < / HintPath > <nl> - < / Reference > <nl> - < Reference Include = " Google . Protobuf " > <nl> - < HintPath > . . \ packages \ Google . Protobuf . 3 . 2 . 0 \ lib \ net45 \ Google . Protobuf . dll < / HintPath > <nl> - < / Reference > <nl> + < Compile Include = " . . \ Grpc . Core \ Version . cs " / > <nl> < / ItemGroup > <nl> + <nl> < ItemGroup > <nl> - < Compile Include = " . . \ Grpc . Core \ Version . cs " > <nl> - < Link > Version . cs < / Link > <nl> - < / Compile > <nl> - < Compile Include = " Properties \ AssemblyInfo . cs " / > <nl> - < Compile Include = " Math . cs " / > <nl> - < Compile Include = " MathGrpc . cs " / > <nl> - < Compile Include = " MathServiceImpl . cs " / > <nl> - < Compile Include = " MathExamples . cs " / > <nl> + < ProjectReference Include = " . . / Grpc . Core / Grpc . Core . csproj " / > <nl> < / ItemGroup > <nl> - < Import Project = " $ ( MSBuildBinPath ) \ Microsoft . CSharp . targets " / > <nl> + <nl> < ItemGroup > <nl> - < ProjectReference Include = " . . \ Grpc . Core \ Grpc . Core . csproj " > <nl> - < Project > { CCC4440E - 49F7 - 4790 - B0AF - FEABB0837AE7 } < / Project > <nl> - < Name > Grpc . Core < / Name > <nl> - < / ProjectReference > <nl> + < PackageReference Include = " Google . Protobuf " Version = " $ ( GoogleProtobufVersion ) " / > <nl> < / ItemGroup > <nl> - < ItemGroup > <nl> - < None Include = " Grpc . Examples . project . json " / > <nl> - < None Include = " packages . config " / > <nl> + <nl> + < ItemGroup Condition = " ' $ ( TargetFramework ) ' = = ' net45 ' " > <nl> + < Reference Include = " System " / > <nl> + < Reference Include = " Microsoft . CSharp " / > <nl> < / ItemGroup > <nl> + <nl> < / Project > <nl> deleted file mode 100644 <nl> index c2f5bcb1637 . . 00000000000 <nl> mmm a / src / csharp / Grpc . Examples / Grpc . Examples . project . json <nl> ppp / dev / null <nl> <nl> - { <nl> - " frameworks " : { <nl> - " net45 " : { } <nl> - } , <nl> - " runtimes " : { <nl> - " win " : { } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index d1d7e6d9816 . . 00000000000 <nl> mmm a / src / csharp / Grpc . Examples / Grpc . Examples . xproj <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project ToolsVersion = " 14 . 0 . 25123 " DefaultTargets = " Build " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> - < PropertyGroup > <nl> - < VisualStudioVersion Condition = " ' $ ( VisualStudioVersion ) ' = = ' ' " > 14 . 0 . 25123 < / VisualStudioVersion > <nl> - < VSToolsPath Condition = " ' $ ( VSToolsPath ) ' = = ' ' " > $ ( MSBuildExtensionsPath32 ) \ Microsoft \ VisualStudio \ v $ ( VisualStudioVersion ) < / VSToolsPath > <nl> - < / PropertyGroup > <nl> - < Import Project = " $ ( VSToolsPath ) \ DNX \ Microsoft . DNX . Props " Condition = " ' $ ( VSToolsPath ) ' ! = ' ' " / > <nl> - < PropertyGroup Label = " Globals " > <nl> - < ProjectGuid > c77b792d - fc78 - 4ce2 - 9522 - b40b0803c636 < / ProjectGuid > <nl> - < RootNamespace > Grpc . Examples < / RootNamespace > <nl> - < BaseIntermediateOutputPath Condition = " ' $ ( BaseIntermediateOutputPath ) ' = = ' ' " > . . \ artifacts \ obj \ $ ( MSBuildProjectName ) < / BaseIntermediateOutputPath > <nl> - < OutputPath Condition = " ' $ ( OutputPath ) ' = = ' ' " > . \ bin \ < / OutputPath > <nl> - < / PropertyGroup > <nl> - < PropertyGroup > <nl> - < SchemaVersion > 2 . 0 < / SchemaVersion > <nl> - < / PropertyGroup > <nl> - < Import Project = " $ ( VSToolsPath ) \ DNX \ Microsoft . DNX . targets " Condition = " ' $ ( VSToolsPath ) ' ! = ' ' " / > <nl> - < / Project > <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 79a898081ed . . 00000000000 <nl> mmm a / src / csharp / Grpc . Examples / packages . config <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < packages > <nl> - < package id = " Google . Protobuf " version = " 3 . 2 . 0 " targetFramework = " net45 " / > <nl> - < package id = " NUnit " version = " 3 . 6 . 0 " targetFramework = " net45 " / > <nl> - < package id = " System . Interactive . Async " version = " 3 . 1 . 1 " targetFramework = " net45 " / > <nl> - < / packages > <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 3ee0a713569 . . 00000000000 <nl> mmm a / src / csharp / Grpc . Examples / project . json <nl> ppp / dev / null <nl> <nl> - { <nl> - " buildOptions " : { <nl> - } , <nl> - <nl> - " dependencies " : { <nl> - " Grpc . Core " : { <nl> - " target " : " project " <nl> - } , <nl> - " Google . Protobuf " : " 3 . 2 . 0 " <nl> - } , <nl> - " frameworks " : { <nl> - " net45 " : { } , <nl> - " netcoreapp1 . 0 " : { <nl> - " dependencies " : { <nl> - " Microsoft . NETCore . App " : { <nl> - " type " : " platform " , <nl> - " version " : " 1 . 0 . 0 " <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } <nl> old mode 100644 <nl> new mode 100755 <nl> index 71f0ee19b86 . . b0e2716e7e5 <nl> mmm a / src / csharp / Grpc . HealthCheck . Tests / Grpc . HealthCheck . Tests . csproj <nl> ppp b / src / csharp / Grpc . HealthCheck . Tests / Grpc . HealthCheck . Tests . csproj <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project ToolsVersion = " 4 . 0 " DefaultTargets = " Build " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> - < Import Project = " $ ( MSBuildExtensionsPath ) \ $ ( MSBuildToolsVersion ) \ Microsoft . Common . props " Condition = " Exists ( ' $ ( MSBuildExtensionsPath ) \ $ ( MSBuildToolsVersion ) \ Microsoft . Common . props ' ) " / > <nl> + < Project Sdk = " Microsoft . NET . Sdk " > <nl> + <nl> + < Import Project = " . . \ Grpc . Core \ Version . csproj . include " / > <nl> + < Import Project = " . . \ Grpc . Core \ Common . csproj . include " / > <nl> + <nl> < PropertyGroup > <nl> - < Configuration Condition = " ' $ ( Configuration ) ' = = ' ' " > Debug < / Configuration > <nl> - < Platform Condition = " ' $ ( Platform ) ' = = ' ' " > AnyCPU < / Platform > <nl> - < ProjectGuid > { F8C6D937 - C44B - 4EE3 - A431 - B0FBAEACE47D } < / ProjectGuid > <nl> - < OutputType > Exe < / OutputType > <nl> - < AppDesignerFolder > Properties < / AppDesignerFolder > <nl> - < RootNamespace > Grpc . HealthCheck . Tests < / RootNamespace > <nl> + < TargetFrameworks > net45 ; netcoreapp1 . 0 < / TargetFrameworks > <nl> < AssemblyName > Grpc . HealthCheck . Tests < / AssemblyName > <nl> - < TargetFrameworkVersion > v4 . 5 < / TargetFrameworkVersion > <nl> - < FileAlignment > 512 < / FileAlignment > <nl> - < / PropertyGroup > <nl> - < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | AnyCPU ' " > <nl> - < DebugSymbols > true < / DebugSymbols > <nl> - < DebugType > full < / DebugType > <nl> - < Optimize > false < / Optimize > <nl> - < OutputPath > bin \ Debug \ < / OutputPath > <nl> - < ErrorReport > prompt < / ErrorReport > <nl> - < WarningLevel > 4 < / WarningLevel > <nl> - < / PropertyGroup > <nl> - < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Release | AnyCPU ' " > <nl> - < DebugType > pdbonly < / DebugType > <nl> - < Optimize > true < / Optimize > <nl> - < OutputPath > bin \ Release \ < / OutputPath > <nl> - < ErrorReport > prompt < / ErrorReport > <nl> - < WarningLevel > 4 < / WarningLevel > <nl> + < OutputType > Exe < / OutputType > <nl> + < PackageId > Grpc . HealthCheck . Tests < / PackageId > <nl> + < PackageTargetFallback Condition = " ' $ ( TargetFramework ) ' = = ' netcoreapp1 . 0 ' " > $ ( PackageTargetFallback ) ; portable - net45 < / PackageTargetFallback > <nl> + < RuntimeFrameworkVersion Condition = " ' $ ( TargetFramework ) ' = = ' netcoreapp1 . 0 ' " > 1 . 0 . 4 < / RuntimeFrameworkVersion > <nl> < / PropertyGroup > <nl> + <nl> < ItemGroup > <nl> - < Reference Include = " System " / > <nl> - < Reference Include = " System . Core " / > <nl> - < Reference Include = " System . Xml . Linq " / > <nl> - < Reference Include = " System . Data . DataSetExtensions " / > <nl> - < Reference Include = " Microsoft . CSharp " / > <nl> - < Reference Include = " System . Data " / > <nl> - < Reference Include = " System . Xml " / > <nl> - < Reference Include = " Google . Protobuf " > <nl> - < HintPath > . . \ packages \ Google . Protobuf . 3 . 2 . 0 \ lib \ net45 \ Google . Protobuf . dll < / HintPath > <nl> - < / Reference > <nl> - < Reference Include = " nunit . framework " > <nl> - < HintPath > . . \ packages \ NUnit . 3 . 6 . 0 \ lib \ net45 \ nunit . framework . dll < / HintPath > <nl> - < / Reference > <nl> - < Reference Include = " nunitlite " > <nl> - < HintPath > . . \ packages \ NUnitLite . 3 . 6 . 0 \ lib \ net45 \ nunitlite . dll < / HintPath > <nl> - < / Reference > <nl> + < ProjectReference Include = " . . / Grpc . HealthCheck / Grpc . HealthCheck . csproj " / > <nl> < / ItemGroup > <nl> + <nl> < ItemGroup > <nl> - < Compile Include = " . . \ Grpc . Core \ Version . cs " > <nl> - < Link > Version . cs < / Link > <nl> - < / Compile > <nl> - < Compile Include = " HealthServiceImplTest . cs " / > <nl> - < Compile Include = " HealthClientServerTest . cs " / > <nl> - < Compile Include = " Properties \ AssemblyInfo . cs " / > <nl> - < Compile Include = " NUnitMain . cs " / > <nl> + < PackageReference Include = " NUnit " Version = " 3 . 6 . 0 " / > <nl> + < PackageReference Include = " NUnitLite " Version = " 3 . 6 . 0 " / > <nl> < / ItemGroup > <nl> - < ItemGroup > <nl> - < ProjectReference Include = " . . \ Grpc . Core \ Grpc . Core . csproj " > <nl> - < Project > { CCC4440E - 49F7 - 4790 - B0AF - FEABB0837AE7 } < / Project > <nl> - < Name > Grpc . Core < / Name > <nl> - < / ProjectReference > <nl> - < ProjectReference Include = " . . \ Grpc . HealthCheck \ Grpc . HealthCheck . csproj " > <nl> - < Project > { AA5E328A - 8835 - 49D7 - 98ED - C29F2B3049F0 } < / Project > <nl> - < Name > Grpc . HealthCheck < / Name > <nl> - < / ProjectReference > <nl> - < / ItemGroup > <nl> - < ItemGroup > <nl> - < None Include = " Grpc . HealthCheck . Tests . project . json " / > <nl> - < None Include = " packages . config " / > <nl> + <nl> + < ItemGroup Condition = " ' $ ( TargetFramework ) ' = = ' net45 ' " > <nl> + < Reference Include = " System " / > <nl> + < Reference Include = " Microsoft . CSharp " / > <nl> < / ItemGroup > <nl> + <nl> < ItemGroup > <nl> - < Service Include = " { 82A7F48D - 3B50 - 4B1E - B82E - 3ADA8210C358 } " / > <nl> + < Compile Include = " . . \ Grpc . Core \ Version . cs " / > <nl> < / ItemGroup > <nl> - < Import Project = " $ ( MSBuildToolsPath ) \ Microsoft . CSharp . targets " / > <nl> - < ! - - To modify your build process , add your task inside one of the targets below and uncomment it . <nl> - Other similar extension points exist , see Microsoft . Common . targets . <nl> - < Target Name = " BeforeBuild " > <nl> - < / Target > <nl> - < Target Name = " AfterBuild " > <nl> - < / Target > <nl> - - - > <nl> - < / Project > <nl> \ No newline at end of file <nl> + <nl> + < / Project > <nl> deleted file mode 100644 <nl> index c2f5bcb1637 . . 00000000000 <nl> mmm a / src / csharp / Grpc . HealthCheck . Tests / Grpc . HealthCheck . Tests . project . json <nl> ppp / dev / null <nl> <nl> - { <nl> - " frameworks " : { <nl> - " net45 " : { } <nl> - } , <nl> - " runtimes " : { <nl> - " win " : { } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index 724c5b2a160 . . 00000000000 <nl> mmm a / src / csharp / Grpc . HealthCheck . Tests / Grpc . HealthCheck . Tests . xproj <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project ToolsVersion = " 14 . 0 . 25123 " DefaultTargets = " Build " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> - < PropertyGroup > <nl> - < VisualStudioVersion Condition = " ' $ ( VisualStudioVersion ) ' = = ' ' " > 14 . 0 . 25123 < / VisualStudioVersion > <nl> - < VSToolsPath Condition = " ' $ ( VSToolsPath ) ' = = ' ' " > $ ( MSBuildExtensionsPath32 ) \ Microsoft \ VisualStudio \ v $ ( VisualStudioVersion ) < / VSToolsPath > <nl> - < / PropertyGroup > <nl> - < Import Project = " $ ( VSToolsPath ) \ DNX \ Microsoft . DNX . Props " Condition = " ' $ ( VSToolsPath ) ' ! = ' ' " / > <nl> - < PropertyGroup Label = " Globals " > <nl> - < ProjectGuid > 43dafac6 - 5343 - 4621 - 960e - a8a977ea3f0b < / ProjectGuid > <nl> - < RootNamespace > Grpc . HealthCheck . Tests < / RootNamespace > <nl> - < BaseIntermediateOutputPath Condition = " ' $ ( BaseIntermediateOutputPath ) ' = = ' ' " > . . \ artifacts \ obj \ $ ( MSBuildProjectName ) < / BaseIntermediateOutputPath > <nl> - < OutputPath Condition = " ' $ ( OutputPath ) ' = = ' ' " > . \ bin \ < / OutputPath > <nl> - < / PropertyGroup > <nl> - < PropertyGroup > <nl> - < SchemaVersion > 2 . 0 < / SchemaVersion > <nl> - < / PropertyGroup > <nl> - < Import Project = " $ ( VSToolsPath ) \ DNX \ Microsoft . DNX . targets " Condition = " ' $ ( VSToolsPath ) ' ! = ' ' " / > <nl> - < / Project > <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 48c94bc4a30 . . 00000000000 <nl> mmm a / src / csharp / Grpc . HealthCheck . Tests / packages . config <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < packages > <nl> - < package id = " Google . Protobuf " version = " 3 . 2 . 0 " targetFramework = " net45 " / > <nl> - < package id = " NUnit " version = " 3 . 6 . 0 " targetFramework = " net45 " / > <nl> - < package id = " NUnitLite " version = " 3 . 6 . 0 " targetFramework = " net45 " / > <nl> - < / packages > <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 2814cbfe466 . . 00000000000 <nl> mmm a / src / csharp / Grpc . HealthCheck . Tests / project . json <nl> ppp / dev / null <nl> <nl> - { <nl> - " buildOptions " : { <nl> - " emitEntryPoint " : true <nl> - } , <nl> - " configurations " : { <nl> - " Debug " : { <nl> - " buildOptions " : { <nl> - " define " : [ " SIGNED " ] , <nl> - " keyFile " : " . . / keys / Grpc . snk " , <nl> - " xmlDoc " : true , <nl> - " compile " : { <nl> - " includeFiles " : [ " . . / Grpc . Core / Version . cs " ] <nl> - } , <nl> - " copyToOutput " : { <nl> - " mappings " : { <nl> - " grpc_csharp_ext . x64 . dll " : " . . / . . / . . / cmake / build / x64 / Debug / grpc_csharp_ext . dll " , <nl> - " grpc_csharp_ext . x86 . dll " : " . . / . . / . . / cmake / build / Win32 / Debug / grpc_csharp_ext . dll " , <nl> - " libgrpc_csharp_ext . x64 . so " : " . . / . . / . . / libs / dbg / libgrpc_csharp_ext . so " , <nl> - " libgrpc_csharp_ext . x64 . dylib " : " . . / . . / . . / libs / dbg / libgrpc_csharp_ext . dylib " <nl> - } <nl> - } <nl> - } <nl> - } , <nl> - " Release " : { <nl> - " buildOptions " : { <nl> - " define " : [ " SIGNED " ] , <nl> - " keyFile " : " . . / keys / Grpc . snk " , <nl> - " xmlDoc " : true , <nl> - " compile " : { <nl> - " includeFiles " : [ " . . / Grpc . Core / Version . cs " ] <nl> - } , <nl> - " copyToOutput " : { <nl> - " mappings " : { <nl> - " grpc_csharp_ext . x64 . dll " : " . . / . . / . . / cmake / build / x64 / Release / grpc_csharp_ext . dll " , <nl> - " grpc_csharp_ext . x86 . dll " : " . . / . . / . . / cmake / build / Win32 / Release / grpc_csharp_ext . dll " , <nl> - " libgrpc_csharp_ext . x64 . so " : " . . / . . / . . / libs / opt / libgrpc_csharp_ext . so " , <nl> - " libgrpc_csharp_ext . x64 . dylib " : " . . / . . / . . / libs / opt / libgrpc_csharp_ext . dylib " <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } , <nl> - <nl> - " dependencies " : { <nl> - " Grpc . HealthCheck " : { <nl> - " target " : " project " <nl> - } , <nl> - " NUnit " : " 3 . 6 . 0 " , <nl> - " NUnitLite " : " 3 . 6 . 0 " <nl> - } , <nl> - " frameworks " : { <nl> - " net45 " : { } , <nl> - " netcoreapp1 . 0 " : { <nl> - " imports " : [ <nl> - " portable - net45 " <nl> - ] , <nl> - " dependencies " : { <nl> - " Microsoft . NETCore . App " : { <nl> - " type " : " platform " , <nl> - " version " : " 1 . 0 . 0 " <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } <nl> old mode 100644 <nl> new mode 100755 <nl> index 171525b7086 . . eac6e1fc95f <nl> mmm a / src / csharp / Grpc . HealthCheck / Grpc . HealthCheck . csproj <nl> ppp b / src / csharp / Grpc . HealthCheck / Grpc . HealthCheck . csproj <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project ToolsVersion = " 4 . 0 " DefaultTargets = " Build " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> - < Import Project = " $ ( MSBuildExtensionsPath ) \ $ ( MSBuildToolsVersion ) \ Microsoft . Common . props " Condition = " Exists ( ' $ ( MSBuildExtensionsPath ) \ $ ( MSBuildToolsVersion ) \ Microsoft . Common . props ' ) " / > <nl> + < Project Sdk = " Microsoft . NET . Sdk " > <nl> + <nl> + < Import Project = " . . \ Grpc . Core \ Version . csproj . include " / > <nl> + < Import Project = " . . \ Grpc . Core \ Common . csproj . include " / > <nl> + <nl> < PropertyGroup > <nl> - < Configuration Condition = " ' $ ( Configuration ) ' = = ' ' " > Debug < / Configuration > <nl> - < Platform Condition = " ' $ ( Platform ) ' = = ' ' " > AnyCPU < / Platform > <nl> - < ProjectGuid > { AA5E328A - 8835 - 49D7 - 98ED - C29F2B3049F0 } < / ProjectGuid > <nl> - < OutputType > Library < / OutputType > <nl> - < AppDesignerFolder > Properties < / AppDesignerFolder > <nl> - < RootNamespace > Grpc . HealthCheck < / RootNamespace > <nl> + < Copyright > Copyright 2015 , Google Inc . < / Copyright > <nl> + < AssemblyTitle > gRPC C # Healthchecking < / AssemblyTitle > <nl> + < VersionPrefix > $ ( GrpcCsharpVersion ) < / VersionPrefix > <nl> + < Authors > Google Inc . < / Authors > <nl> + < TargetFrameworks > net45 ; netstandard1 . 5 < / TargetFrameworks > <nl> < AssemblyName > Grpc . HealthCheck < / AssemblyName > <nl> - < TargetFrameworkVersion > v4 . 5 < / TargetFrameworkVersion > <nl> - < FileAlignment > 512 < / FileAlignment > <nl> - < DocumentationFile > bin \ $ ( Configuration ) \ Grpc . HealthCheck . Xml < / DocumentationFile > <nl> - < / PropertyGroup > <nl> - < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | AnyCPU ' " > <nl> - < DebugSymbols > true < / DebugSymbols > <nl> - < DebugType > full < / DebugType > <nl> - < Optimize > false < / Optimize > <nl> - < OutputPath > bin \ Debug \ < / OutputPath > <nl> - < ErrorReport > prompt < / ErrorReport > <nl> - < WarningLevel > 4 < / WarningLevel > <nl> - < / PropertyGroup > <nl> - < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Release | AnyCPU ' " > <nl> - < DebugType > pdbonly < / DebugType > <nl> - < Optimize > true < / Optimize > <nl> - < OutputPath > bin \ Release \ < / OutputPath > <nl> - < ErrorReport > prompt < / ErrorReport > <nl> - < WarningLevel > 4 < / WarningLevel > <nl> + < PackageId > Grpc . HealthCheck < / PackageId > <nl> + < PackageTags > gRPC health check < / PackageTags > <nl> + < PackageProjectUrl > https : / / github . com / grpc / grpc < / PackageProjectUrl > <nl> + < PackageLicenseUrl > https : / / github . com / grpc / grpc / blob / master / LICENSE < / PackageLicenseUrl > <nl> + < NetStandardImplicitPackageVersion Condition = " ' $ ( TargetFramework ) ' = = ' netstandard1 . 5 ' " > 1 . 6 . 0 < / NetStandardImplicitPackageVersion > <nl> < / PropertyGroup > <nl> + <nl> < ItemGroup > <nl> - < Reference Include = " System " / > <nl> - < Reference Include = " System . Core " / > <nl> - < Reference Include = " System . Xml . Linq " / > <nl> - < Reference Include = " System . Data . DataSetExtensions " / > <nl> - < Reference Include = " Microsoft . CSharp " / > <nl> - < Reference Include = " System . Data " / > <nl> - < Reference Include = " System . Xml " / > <nl> - < Reference Include = " System . Interactive . Async " > <nl> - < HintPath > . . \ packages \ System . Interactive . Async . 3 . 1 . 1 \ lib \ net45 \ System . Interactive . Async . dll < / HintPath > <nl> - < / Reference > <nl> - < Reference Include = " Google . Protobuf " > <nl> - < HintPath > . . \ packages \ Google . Protobuf . 3 . 2 . 0 \ lib \ net45 \ Google . Protobuf . dll < / HintPath > <nl> - < / Reference > <nl> + < Compile Include = " . . \ Grpc . Core \ Version . cs " / > <nl> < / ItemGroup > <nl> + <nl> < ItemGroup > <nl> - < Compile Include = " . . \ Grpc . Core \ Version . cs " > <nl> - < Link > Version . cs < / Link > <nl> - < / Compile > <nl> - < Compile Include = " HealthServiceImpl . cs " / > <nl> - < Compile Include = " Health . cs " / > <nl> - < Compile Include = " HealthGrpc . cs " / > <nl> - < Compile Include = " Properties \ AssemblyInfo . cs " / > <nl> + < ProjectReference Include = " . . / Grpc . Core / Grpc . Core . csproj " / > <nl> < / ItemGroup > <nl> + <nl> < ItemGroup > <nl> - < None Include = " Grpc . HealthCheck . project . json " / > <nl> - < None Include = " packages . config " / > <nl> + < PackageReference Include = " Google . Protobuf " Version = " $ ( GoogleProtobufVersion ) " / > <nl> < / ItemGroup > <nl> - < ItemGroup > <nl> - < ProjectReference Include = " . . \ Grpc . Core \ Grpc . Core . csproj " > <nl> - < Project > { CCC4440E - 49F7 - 4790 - B0AF - FEABB0837AE7 } < / Project > <nl> - < Name > Grpc . Core < / Name > <nl> - < / ProjectReference > <nl> + <nl> + < ItemGroup Condition = " ' $ ( TargetFramework ) ' = = ' net45 ' " > <nl> + < Reference Include = " System " / > <nl> + < Reference Include = " Microsoft . CSharp " / > <nl> < / ItemGroup > <nl> - < Import Project = " $ ( MSBuildToolsPath ) \ Microsoft . CSharp . targets " / > <nl> - < ! - - To modify your build process , add your task inside one of the targets below and uncomment it . <nl> - Other similar extension points exist , see Microsoft . Common . targets . <nl> - < Target Name = " BeforeBuild " > <nl> - < / Target > <nl> - < Target Name = " AfterBuild " > <nl> - < / Target > <nl> - - - > <nl> + <nl> < / Project > <nl> deleted file mode 100644 <nl> index c2f5bcb1637 . . 00000000000 <nl> mmm a / src / csharp / Grpc . HealthCheck / Grpc . HealthCheck . project . json <nl> ppp / dev / null <nl> <nl> - { <nl> - " frameworks " : { <nl> - " net45 " : { } <nl> - } , <nl> - " runtimes " : { <nl> - " win " : { } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index 5806a7af979 . . 00000000000 <nl> mmm a / src / csharp / Grpc . HealthCheck / Grpc . HealthCheck . xproj <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project ToolsVersion = " 14 . 0 . 25123 " DefaultTargets = " Build " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> - < PropertyGroup > <nl> - < VisualStudioVersion Condition = " ' $ ( VisualStudioVersion ) ' = = ' ' " > 14 . 0 . 25123 < / VisualStudioVersion > <nl> - < VSToolsPath Condition = " ' $ ( VSToolsPath ) ' = = ' ' " > $ ( MSBuildExtensionsPath32 ) \ Microsoft \ VisualStudio \ v $ ( VisualStudioVersion ) < / VSToolsPath > <nl> - < / PropertyGroup > <nl> - < Import Project = " $ ( VSToolsPath ) \ DNX \ Microsoft . DNX . Props " Condition = " ' $ ( VSToolsPath ) ' ! = ' ' " / > <nl> - < PropertyGroup Label = " Globals " > <nl> - < ProjectGuid > 3be4ad0b - 2bf0 - 4d68 - b625 - f6018ef0dcfa < / ProjectGuid > <nl> - < RootNamespace > Grpc . HealthCheck < / RootNamespace > <nl> - < BaseIntermediateOutputPath Condition = " ' $ ( BaseIntermediateOutputPath ) ' = = ' ' " > . . \ artifacts \ obj \ $ ( MSBuildProjectName ) < / BaseIntermediateOutputPath > <nl> - < OutputPath Condition = " ' $ ( OutputPath ) ' = = ' ' " > . \ bin \ < / OutputPath > <nl> - < / PropertyGroup > <nl> - < PropertyGroup > <nl> - < SchemaVersion > 2 . 0 < / SchemaVersion > <nl> - < / PropertyGroup > <nl> - < Import Project = " $ ( VSToolsPath ) \ DNX \ Microsoft . DNX . targets " Condition = " ' $ ( VSToolsPath ) ' ! = ' ' " / > <nl> - < / Project > <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index eec292b306d . . 00000000000 <nl> mmm a / src / csharp / Grpc . HealthCheck / packages . config <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < packages > <nl> - < package id = " Google . Protobuf " version = " 3 . 2 . 0 " targetFramework = " net45 " / > <nl> - < package id = " System . Interactive . Async " version = " 3 . 1 . 1 " targetFramework = " net45 " / > <nl> - < / packages > <nl> \ No newline at end of file <nl> old mode 100644 <nl> new mode 100755 <nl> index a793f3f6df8 . . dcb24c72166 <nl> mmm a / src / csharp / Grpc . IntegrationTesting . Client / Grpc . IntegrationTesting . Client . csproj <nl> ppp b / src / csharp / Grpc . IntegrationTesting . Client / Grpc . IntegrationTesting . Client . csproj <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project DefaultTargets = " Build " ToolsVersion = " 4 . 0 " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> + < Project Sdk = " Microsoft . NET . Sdk " > <nl> + <nl> + < Import Project = " . . \ Grpc . Core \ Version . csproj . include " / > <nl> + < Import Project = " . . \ Grpc . Core \ Common . csproj . include " / > <nl> + <nl> < PropertyGroup > <nl> - < Configuration Condition = " ' $ ( Configuration ) ' = = ' ' " > Debug < / Configuration > <nl> - < Platform Condition = " ' $ ( Platform ) ' = = ' ' " > AnyCPU < / Platform > <nl> - < ProjectGuid > { 3D166931 - BA2D - 416E - 95A3 - D36E8F6E90B9 } < / ProjectGuid > <nl> - < OutputType > Exe < / OutputType > <nl> - < RootNamespace > Grpc . IntegrationTesting . Client < / RootNamespace > <nl> + < TargetFrameworks > net45 ; netcoreapp1 . 0 < / TargetFrameworks > <nl> < AssemblyName > Grpc . IntegrationTesting . Client < / AssemblyName > <nl> - < StartupObject > Grpc . IntegrationTesting . Client . Program < / StartupObject > <nl> - < TargetFrameworkVersion > v4 . 5 < / TargetFrameworkVersion > <nl> - < NuGetPackageImportStamp > dfa56e6c < / NuGetPackageImportStamp > <nl> - < / PropertyGroup > <nl> - < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | AnyCPU ' " > <nl> - < DebugSymbols > true < / DebugSymbols > <nl> - < DebugType > full < / DebugType > <nl> - < Optimize > false < / Optimize > <nl> - < OutputPath > bin \ Debug < / OutputPath > <nl> - < DefineConstants > DEBUG ; < / DefineConstants > <nl> - < ErrorReport > prompt < / ErrorReport > <nl> - < WarningLevel > 4 < / WarningLevel > <nl> - < PlatformTarget > AnyCPU < / PlatformTarget > <nl> - < / PropertyGroup > <nl> - < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Release | AnyCPU ' " > <nl> - < DebugType > pdbonly < / DebugType > <nl> - < Optimize > true < / Optimize > <nl> - < OutputPath > bin \ Release < / OutputPath > <nl> - < ErrorReport > prompt < / ErrorReport > <nl> - < WarningLevel > 4 < / WarningLevel > <nl> - < PlatformTarget > AnyCPU < / PlatformTarget > <nl> + < OutputType > Exe < / OutputType > <nl> + < PackageId > Grpc . IntegrationTesting . Client < / PackageId > <nl> + < PackageTargetFallback Condition = " ' $ ( TargetFramework ) ' = = ' netcoreapp1 . 0 ' " > $ ( PackageTargetFallback ) ; portable - net45 < / PackageTargetFallback > <nl> + < RuntimeFrameworkVersion Condition = " ' $ ( TargetFramework ) ' = = ' netcoreapp1 . 0 ' " > 1 . 0 . 4 < / RuntimeFrameworkVersion > <nl> < / PropertyGroup > <nl> + <nl> < ItemGroup > <nl> - < Reference Include = " System " / > <nl> - < Reference Include = " System . Net " / > <nl> - < Reference Include = " System . Net . Http " / > <nl> - < Reference Include = " System . Net . Http . WebRequest " / > <nl> + < ProjectReference Include = " . . / Grpc . IntegrationTesting / Grpc . IntegrationTesting . csproj " / > <nl> < / ItemGroup > <nl> - < ItemGroup > <nl> - < Compile Include = " . . \ Grpc . Core \ Version . cs " > <nl> - < Link > Version . cs < / Link > <nl> - < / Compile > <nl> - < Compile Include = " Program . cs " / > <nl> - < Compile Include = " Properties \ AssemblyInfo . cs " / > <nl> - < / ItemGroup > <nl> - < Import Project = " $ ( MSBuildBinPath ) \ Microsoft . CSharp . targets " / > <nl> - < ItemGroup > <nl> - < ProjectReference Include = " . . \ Grpc . IntegrationTesting \ Grpc . IntegrationTesting . csproj " > <nl> - < Project > { C61154BA - DD4A - 4838 - 8420 - 0162A28925E0 } < / Project > <nl> - < Name > Grpc . IntegrationTesting < / Name > <nl> - < / ProjectReference > <nl> - < ProjectReference Include = " . . \ Grpc . Core \ Grpc . Core . csproj " > <nl> - < Project > { CCC4440E - 49F7 - 4790 - B0AF - FEABB0837AE7 } < / Project > <nl> - < Name > Grpc . Core < / Name > <nl> - < / ProjectReference > <nl> + <nl> + < ItemGroup Condition = " ' $ ( TargetFramework ) ' = = ' net45 ' " > <nl> + < Reference Include = " System " / > <nl> + < Reference Include = " Microsoft . CSharp " / > <nl> < / ItemGroup > <nl> + <nl> < ItemGroup > <nl> - < None Include = " Grpc . IntegrationTesting . Client . project . json " / > <nl> + < Compile Include = " . . \ Grpc . Core \ Version . cs " / > <nl> < / ItemGroup > <nl> - < / Project > <nl> \ No newline at end of file <nl> + <nl> + < / Project > <nl> deleted file mode 100644 <nl> index c2f5bcb1637 . . 00000000000 <nl> mmm a / src / csharp / Grpc . IntegrationTesting . Client / Grpc . IntegrationTesting . Client . project . json <nl> ppp / dev / null <nl> <nl> - { <nl> - " frameworks " : { <nl> - " net45 " : { } <nl> - } , <nl> - " runtimes " : { <nl> - " win " : { } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index 7f456cfaef1 . . 00000000000 <nl> mmm a / src / csharp / Grpc . IntegrationTesting . Client / Grpc . IntegrationTesting . Client . xproj <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project ToolsVersion = " 14 . 0 . 25123 " DefaultTargets = " Build " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> - < PropertyGroup > <nl> - < VisualStudioVersion Condition = " ' $ ( VisualStudioVersion ) ' = = ' ' " > 14 . 0 . 25123 < / VisualStudioVersion > <nl> - < VSToolsPath Condition = " ' $ ( VSToolsPath ) ' = = ' ' " > $ ( MSBuildExtensionsPath32 ) \ Microsoft \ VisualStudio \ v $ ( VisualStudioVersion ) < / VSToolsPath > <nl> - < / PropertyGroup > <nl> - < Import Project = " $ ( VSToolsPath ) \ DNX \ Microsoft . DNX . Props " Condition = " ' $ ( VSToolsPath ) ' ! = ' ' " / > <nl> - < PropertyGroup Label = " Globals " > <nl> - < ProjectGuid > 48ea5bbe - 70e2 - 4198 - 869d - d7e59c45f30d < / ProjectGuid > <nl> - < RootNamespace > Grpc . IntegrationTesting . Client < / RootNamespace > <nl> - < BaseIntermediateOutputPath Condition = " ' $ ( BaseIntermediateOutputPath ) ' = = ' ' " > . . \ artifacts \ obj \ $ ( MSBuildProjectName ) < / BaseIntermediateOutputPath > <nl> - < OutputPath Condition = " ' $ ( OutputPath ) ' = = ' ' " > . \ bin \ < / OutputPath > <nl> - < / PropertyGroup > <nl> - < PropertyGroup > <nl> - < SchemaVersion > 2 . 0 < / SchemaVersion > <nl> - < / PropertyGroup > <nl> - < Import Project = " $ ( VSToolsPath ) \ DNX \ Microsoft . DNX . targets " Condition = " ' $ ( VSToolsPath ) ' ! = ' ' " / > <nl> - < / Project > <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index f90528151b4 . . 00000000000 <nl> mmm a / src / csharp / Grpc . IntegrationTesting . Client / project . json <nl> ppp / dev / null <nl> <nl> - { <nl> - " buildOptions " : { <nl> - " emitEntryPoint " : true <nl> - } , <nl> - " configurations " : { <nl> - " Debug " : { <nl> - " buildOptions " : { <nl> - " define " : [ " SIGNED " ] , <nl> - " keyFile " : " . . / keys / Grpc . snk " , <nl> - " xmlDoc " : true , <nl> - " compile " : { <nl> - " includeFiles " : [ " . . / Grpc . Core / Version . cs " ] <nl> - } , <nl> - " copyToOutput " : { <nl> - " mappings " : { <nl> - " data / ca . pem " : " . . / Grpc . IntegrationTesting / data / ca . pem " , <nl> - " data / server1 . key " : " . . / Grpc . IntegrationTesting / data / server1 . key " , <nl> - " data / server1 . pem " : " . . / Grpc . IntegrationTesting / data / server1 . pem " , <nl> - " grpc_csharp_ext . x64 . dll " : " . . / . . / . . / cmake / build / x64 / Debug / grpc_csharp_ext . dll " , <nl> - " grpc_csharp_ext . x86 . dll " : " . . / . . / . . / cmake / build / Win32 / Debug / grpc_csharp_ext . dll " , <nl> - " libgrpc_csharp_ext . x64 . so " : " . . / . . / . . / libs / dbg / libgrpc_csharp_ext . so " , <nl> - " libgrpc_csharp_ext . x64 . dylib " : " . . / . . / . . / libs / dbg / libgrpc_csharp_ext . dylib " <nl> - } <nl> - } <nl> - } <nl> - } , <nl> - " Release " : { <nl> - " buildOptions " : { <nl> - " define " : [ " SIGNED " ] , <nl> - " keyFile " : " . . / keys / Grpc . snk " , <nl> - " xmlDoc " : true , <nl> - " compile " : { <nl> - " includeFiles " : [ " . . / Grpc . Core / Version . cs " ] <nl> - } , <nl> - " copyToOutput " : { <nl> - " mappings " : { <nl> - " data / ca . pem " : " . . / Grpc . IntegrationTesting / data / ca . pem " , <nl> - " data / server1 . key " : " . . / Grpc . IntegrationTesting / data / server1 . key " , <nl> - " data / server1 . pem " : " . . / Grpc . IntegrationTesting / data / server1 . pem " , <nl> - " grpc_csharp_ext . x64 . dll " : " . . / . . / . . / cmake / build / x64 / Release / grpc_csharp_ext . dll " , <nl> - " grpc_csharp_ext . x86 . dll " : " . . / . . / . . / cmake / build / Win32 / Release / grpc_csharp_ext . dll " , <nl> - " libgrpc_csharp_ext . x64 . so " : " . . / . . / . . / libs / opt / libgrpc_csharp_ext . so " , <nl> - " libgrpc_csharp_ext . x64 . dylib " : " . . / . . / . . / libs / opt / libgrpc_csharp_ext . dylib " <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } , <nl> - <nl> - " dependencies " : { <nl> - " Grpc . IntegrationTesting " : { <nl> - " target " : " project " <nl> - } <nl> - } , <nl> - " frameworks " : { <nl> - " net45 " : { } , <nl> - " netcoreapp1 . 0 " : { <nl> - " imports " : [ <nl> - " portable - net45 " <nl> - ] , <nl> - " dependencies " : { <nl> - " Microsoft . NETCore . App " : { <nl> - " type " : " platform " , <nl> - " version " : " 1 . 0 . 0 " <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } <nl> old mode 100644 <nl> new mode 100755 <nl> index 3b9587e3151 . . 43772020d6f <nl> mmm a / src / csharp / Grpc . IntegrationTesting . QpsWorker / Grpc . IntegrationTesting . QpsWorker . csproj <nl> ppp b / src / csharp / Grpc . IntegrationTesting . QpsWorker / Grpc . IntegrationTesting . QpsWorker . csproj <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project DefaultTargets = " Build " ToolsVersion = " 4 . 0 " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> + < Project Sdk = " Microsoft . NET . Sdk " > <nl> + <nl> + < Import Project = " . . \ Grpc . Core \ Version . csproj . include " / > <nl> + < Import Project = " . . \ Grpc . Core \ Common . csproj . include " / > <nl> + <nl> < PropertyGroup > <nl> - < Configuration Condition = " ' $ ( Configuration ) ' = = ' ' " > Debug < / Configuration > <nl> - < Platform Condition = " ' $ ( Platform ) ' = = ' ' " > AnyCPU < / Platform > <nl> - < ProjectGuid > { B82B7DFE - 7F7B - 40EF - B3D6 - 064FF2B01294 } < / ProjectGuid > <nl> - < OutputType > Exe < / OutputType > <nl> - < RootNamespace > Grpc . IntegrationTesting . QpsWorker < / RootNamespace > <nl> + < TargetFrameworks > net45 ; netcoreapp1 . 0 < / TargetFrameworks > <nl> < AssemblyName > Grpc . IntegrationTesting . QpsWorker < / AssemblyName > <nl> - < TargetFrameworkVersion > v4 . 5 < / TargetFrameworkVersion > <nl> - < / PropertyGroup > <nl> - < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | AnyCPU ' " > <nl> - < DebugSymbols > true < / DebugSymbols > <nl> - < DebugType > full < / DebugType > <nl> - < Optimize > false < / Optimize > <nl> - < OutputPath > bin \ Debug < / OutputPath > <nl> - < DefineConstants > DEBUG ; < / DefineConstants > <nl> - < ErrorReport > prompt < / ErrorReport > <nl> - < WarningLevel > 4 < / WarningLevel > <nl> - < PlatformTarget > AnyCPU < / PlatformTarget > <nl> - < / PropertyGroup > <nl> - < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Release | AnyCPU ' " > <nl> - < DebugType > pdbonly < / DebugType > <nl> - < Optimize > true < / Optimize > <nl> - < OutputPath > bin \ Release < / OutputPath > <nl> - < ErrorReport > prompt < / ErrorReport > <nl> - < WarningLevel > 4 < / WarningLevel > <nl> - < PlatformTarget > AnyCPU < / PlatformTarget > <nl> + < OutputType > Exe < / OutputType > <nl> + < PackageId > Grpc . IntegrationTesting . QpsWorker < / PackageId > <nl> + < ServerGarbageCollection > true < / ServerGarbageCollection > <nl> + < PackageTargetFallback Condition = " ' $ ( TargetFramework ) ' = = ' netcoreapp1 . 0 ' " > $ ( PackageTargetFallback ) ; portable - net45 < / PackageTargetFallback > <nl> + < RuntimeFrameworkVersion Condition = " ' $ ( TargetFramework ) ' = = ' netcoreapp1 . 0 ' " > 1 . 0 . 4 < / RuntimeFrameworkVersion > <nl> < / PropertyGroup > <nl> + <nl> < ItemGroup > <nl> - < Reference Include = " System " / > <nl> + < ProjectReference Include = " . . / Grpc . IntegrationTesting / Grpc . IntegrationTesting . csproj " / > <nl> < / ItemGroup > <nl> - < ItemGroup > <nl> - < Compile Include = " . . \ Grpc . Core \ Version . cs " > <nl> - < Link > Version . cs < / Link > <nl> - < / Compile > <nl> - < Compile Include = " Program . cs " / > <nl> - < Compile Include = " Properties \ AssemblyInfo . cs " / > <nl> - < / ItemGroup > <nl> - < Import Project = " $ ( MSBuildBinPath ) \ Microsoft . CSharp . targets " / > <nl> - < ItemGroup > <nl> - < ProjectReference Include = " . . \ Grpc . Core \ Grpc . Core . csproj " > <nl> - < Project > { CCC4440E - 49F7 - 4790 - B0AF - FEABB0837AE7 } < / Project > <nl> - < Name > Grpc . Core < / Name > <nl> - < / ProjectReference > <nl> - < ProjectReference Include = " . . \ Grpc . IntegrationTesting \ Grpc . IntegrationTesting . csproj " > <nl> - < Project > { C61154BA - DD4A - 4838 - 8420 - 0162A28925E0 } < / Project > <nl> - < Name > Grpc . IntegrationTesting < / Name > <nl> - < / ProjectReference > <nl> + <nl> + < ItemGroup Condition = " ' $ ( TargetFramework ) ' = = ' net45 ' " > <nl> + < Reference Include = " System " / > <nl> + < Reference Include = " Microsoft . CSharp " / > <nl> < / ItemGroup > <nl> + <nl> < ItemGroup > <nl> - < None Include = " Grpc . IntegrationTesting . QpsWorker . project . json " / > <nl> + < Compile Include = " . . \ Grpc . Core \ Version . cs " / > <nl> < / ItemGroup > <nl> - < / Project > <nl> \ No newline at end of file <nl> + <nl> + < / Project > <nl> deleted file mode 100644 <nl> index c2f5bcb1637 . . 00000000000 <nl> mmm a / src / csharp / Grpc . IntegrationTesting . QpsWorker / Grpc . IntegrationTesting . QpsWorker . project . json <nl> ppp / dev / null <nl> <nl> - { <nl> - " frameworks " : { <nl> - " net45 " : { } <nl> - } , <nl> - " runtimes " : { <nl> - " win " : { } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index 15bec443d6c . . 00000000000 <nl> mmm a / src / csharp / Grpc . IntegrationTesting . QpsWorker / Grpc . IntegrationTesting . QpsWorker . xproj <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project ToolsVersion = " 14 . 0 . 25123 " DefaultTargets = " Build " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> - < PropertyGroup > <nl> - < VisualStudioVersion Condition = " ' $ ( VisualStudioVersion ) ' = = ' ' " > 14 . 0 . 25123 < / VisualStudioVersion > <nl> - < VSToolsPath Condition = " ' $ ( VSToolsPath ) ' = = ' ' " > $ ( MSBuildExtensionsPath32 ) \ Microsoft \ VisualStudio \ v $ ( VisualStudioVersion ) < / VSToolsPath > <nl> - < / PropertyGroup > <nl> - < Import Project = " $ ( VSToolsPath ) \ DNX \ Microsoft . DNX . Props " Condition = " ' $ ( VSToolsPath ) ' ! = ' ' " / > <nl> - < PropertyGroup Label = " Globals " > <nl> - < ProjectGuid > 661b70d7 - f56a - 46e0 - 9b81 - 6227b591b5e7 < / ProjectGuid > <nl> - < RootNamespace > Grpc . IntegrationTesting . QpsWorker < / RootNamespace > <nl> - < BaseIntermediateOutputPath Condition = " ' $ ( BaseIntermediateOutputPath ) ' = = ' ' " > . . \ artifacts \ obj \ $ ( MSBuildProjectName ) < / BaseIntermediateOutputPath > <nl> - < OutputPath Condition = " ' $ ( OutputPath ) ' = = ' ' " > . \ bin \ < / OutputPath > <nl> - < / PropertyGroup > <nl> - < PropertyGroup > <nl> - < SchemaVersion > 2 . 0 < / SchemaVersion > <nl> - < / PropertyGroup > <nl> - < Import Project = " $ ( VSToolsPath ) \ DNX \ Microsoft . DNX . targets " Condition = " ' $ ( VSToolsPath ) ' ! = ' ' " / > <nl> - < / Project > <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 161e602abca . . 00000000000 <nl> mmm a / src / csharp / Grpc . IntegrationTesting . QpsWorker / project . json <nl> ppp / dev / null <nl> <nl> - { <nl> - " buildOptions " : { <nl> - " emitEntryPoint " : true <nl> - } , <nl> - " configurations " : { <nl> - " Debug " : { <nl> - " buildOptions " : { <nl> - " define " : [ " SIGNED " ] , <nl> - " keyFile " : " . . / keys / Grpc . snk " , <nl> - " xmlDoc " : true , <nl> - " compile " : { <nl> - " includeFiles " : [ " . . / Grpc . Core / Version . cs " ] <nl> - } , <nl> - " copyToOutput " : { <nl> - " mappings " : { <nl> - " data / ca . pem " : " . . / Grpc . IntegrationTesting / data / ca . pem " , <nl> - " data / server1 . key " : " . . / Grpc . IntegrationTesting / data / server1 . key " , <nl> - " data / server1 . pem " : " . . / Grpc . IntegrationTesting / data / server1 . pem " , <nl> - " grpc_csharp_ext . x64 . dll " : " . . / . . / . . / cmake / build / x64 / Debug / grpc_csharp_ext . dll " , <nl> - " grpc_csharp_ext . x86 . dll " : " . . / . . / . . / cmake / build / Win32 / Debug / grpc_csharp_ext . dll " , <nl> - " libgrpc_csharp_ext . x64 . so " : " . . / . . / . . / libs / dbg / libgrpc_csharp_ext . so " , <nl> - " libgrpc_csharp_ext . x64 . dylib " : " . . / . . / . . / libs / dbg / libgrpc_csharp_ext . dylib " <nl> - } <nl> - } <nl> - } <nl> - } , <nl> - " Release " : { <nl> - " buildOptions " : { <nl> - " define " : [ " SIGNED " ] , <nl> - " keyFile " : " . . / keys / Grpc . snk " , <nl> - " xmlDoc " : true , <nl> - " compile " : { <nl> - " includeFiles " : [ " . . / Grpc . Core / Version . cs " ] <nl> - } , <nl> - " copyToOutput " : { <nl> - " mappings " : { <nl> - " data / ca . pem " : " . . / Grpc . IntegrationTesting / data / ca . pem " , <nl> - " data / server1 . key " : " . . / Grpc . IntegrationTesting / data / server1 . key " , <nl> - " data / server1 . pem " : " . . / Grpc . IntegrationTesting / data / server1 . pem " , <nl> - " grpc_csharp_ext . x64 . dll " : " . . / . . / . . / cmake / build / x64 / Release / grpc_csharp_ext . dll " , <nl> - " grpc_csharp_ext . x86 . dll " : " . . / . . / . . / cmake / build / Win32 / Release / grpc_csharp_ext . dll " , <nl> - " libgrpc_csharp_ext . x64 . so " : " . . / . . / . . / libs / opt / libgrpc_csharp_ext . so " , <nl> - " libgrpc_csharp_ext . x64 . dylib " : " . . / . . / . . / libs / opt / libgrpc_csharp_ext . dylib " <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } , <nl> - <nl> - " dependencies " : { <nl> - " Grpc . IntegrationTesting " : { <nl> - " target " : " project " <nl> - } <nl> - } , <nl> - " frameworks " : { <nl> - " net45 " : { } , <nl> - " netcoreapp1 . 0 " : { <nl> - " imports " : [ <nl> - " portable - net45 " <nl> - ] , <nl> - " dependencies " : { <nl> - " Microsoft . NETCore . App " : { <nl> - " type " : " platform " , <nl> - " version " : " 1 . 0 . 0 " <nl> - } <nl> - } <nl> - } <nl> - } , <nl> - " runtimeOptions " : { <nl> - " configProperties " : { <nl> - " System . GC . Server " : true <nl> - } <nl> - } <nl> - } <nl> old mode 100644 <nl> new mode 100755 <nl> index 80d36363f71 . . db736baed05 <nl> mmm a / src / csharp / Grpc . IntegrationTesting . Server / Grpc . IntegrationTesting . Server . csproj <nl> ppp b / src / csharp / Grpc . IntegrationTesting . Server / Grpc . IntegrationTesting . Server . csproj <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project DefaultTargets = " Build " ToolsVersion = " 4 . 0 " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> + < Project Sdk = " Microsoft . NET . Sdk " > <nl> + <nl> + < Import Project = " . . \ Grpc . Core \ Version . csproj . include " / > <nl> + < Import Project = " . . \ Grpc . Core \ Common . csproj . include " / > <nl> + <nl> < PropertyGroup > <nl> - < Configuration Condition = " ' $ ( Configuration ) ' = = ' ' " > Debug < / Configuration > <nl> - < Platform Condition = " ' $ ( Platform ) ' = = ' ' " > AnyCPU < / Platform > <nl> - < ProjectGuid > { A654F3B8 - E859 - 4E6A - B30D - 227527DBEF0D } < / ProjectGuid > <nl> - < OutputType > Exe < / OutputType > <nl> - < RootNamespace > Grpc . IntegrationTesting . Server < / RootNamespace > <nl> + < TargetFrameworks > net45 ; netcoreapp1 . 0 < / TargetFrameworks > <nl> < AssemblyName > Grpc . IntegrationTesting . Server < / AssemblyName > <nl> - < StartupObject > Grpc . IntegrationTesting . Server . Program < / StartupObject > <nl> - < TargetFrameworkVersion > v4 . 5 < / TargetFrameworkVersion > <nl> - < NuGetPackageImportStamp > 7ceb739e < / NuGetPackageImportStamp > <nl> - < / PropertyGroup > <nl> - < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | AnyCPU ' " > <nl> - < DebugSymbols > true < / DebugSymbols > <nl> - < DebugType > full < / DebugType > <nl> - < Optimize > false < / Optimize > <nl> - < OutputPath > bin \ Debug < / OutputPath > <nl> - < DefineConstants > DEBUG ; < / DefineConstants > <nl> - < ErrorReport > prompt < / ErrorReport > <nl> - < WarningLevel > 4 < / WarningLevel > <nl> - < PlatformTarget > AnyCPU < / PlatformTarget > <nl> - < / PropertyGroup > <nl> - < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Release | AnyCPU ' " > <nl> - < DebugType > pdbonly < / DebugType > <nl> - < Optimize > true < / Optimize > <nl> - < OutputPath > bin \ Release < / OutputPath > <nl> - < ErrorReport > prompt < / ErrorReport > <nl> - < WarningLevel > 4 < / WarningLevel > <nl> - < PlatformTarget > AnyCPU < / PlatformTarget > <nl> + < OutputType > Exe < / OutputType > <nl> + < PackageId > Grpc . IntegrationTesting . Server < / PackageId > <nl> + < PackageTargetFallback Condition = " ' $ ( TargetFramework ) ' = = ' netcoreapp1 . 0 ' " > $ ( PackageTargetFallback ) ; portable - net45 < / PackageTargetFallback > <nl> + < RuntimeFrameworkVersion Condition = " ' $ ( TargetFramework ) ' = = ' netcoreapp1 . 0 ' " > 1 . 0 . 4 < / RuntimeFrameworkVersion > <nl> < / PropertyGroup > <nl> + <nl> < ItemGroup > <nl> - < Reference Include = " System " / > <nl> - < Reference Include = " System . Net " / > <nl> - < Reference Include = " System . Net . Http " / > <nl> - < Reference Include = " System . Net . Http . WebRequest " / > <nl> + < ProjectReference Include = " . . / Grpc . IntegrationTesting / Grpc . IntegrationTesting . csproj " / > <nl> < / ItemGroup > <nl> - < ItemGroup > <nl> - < Compile Include = " . . \ Grpc . Core \ Version . cs " > <nl> - < Link > Version . cs < / Link > <nl> - < / Compile > <nl> - < Compile Include = " Program . cs " / > <nl> - < Compile Include = " Properties \ AssemblyInfo . cs " / > <nl> - < / ItemGroup > <nl> - < Import Project = " $ ( MSBuildBinPath ) \ Microsoft . CSharp . targets " / > <nl> - < ItemGroup > <nl> - < ProjectReference Include = " . . \ Grpc . IntegrationTesting \ Grpc . IntegrationTesting . csproj " > <nl> - < Project > { C61154BA - DD4A - 4838 - 8420 - 0162A28925E0 } < / Project > <nl> - < Name > Grpc . IntegrationTesting < / Name > <nl> - < / ProjectReference > <nl> - < ProjectReference Include = " . . \ Grpc . Core \ Grpc . Core . csproj " > <nl> - < Project > { CCC4440E - 49F7 - 4790 - B0AF - FEABB0837AE7 } < / Project > <nl> - < Name > Grpc . Core < / Name > <nl> - < / ProjectReference > <nl> + <nl> + < ItemGroup Condition = " ' $ ( TargetFramework ) ' = = ' net45 ' " > <nl> + < Reference Include = " System " / > <nl> + < Reference Include = " Microsoft . CSharp " / > <nl> < / ItemGroup > <nl> + <nl> < ItemGroup > <nl> - < None Include = " Grpc . IntegrationTesting . Server . project . json " / > <nl> + < Compile Include = " . . \ Grpc . Core \ Version . cs " / > <nl> < / ItemGroup > <nl> - < / Project > <nl> \ No newline at end of file <nl> + <nl> + < / Project > <nl> deleted file mode 100644 <nl> index c2f5bcb1637 . . 00000000000 <nl> mmm a / src / csharp / Grpc . IntegrationTesting . Server / Grpc . IntegrationTesting . Server . project . json <nl> ppp / dev / null <nl> <nl> - { <nl> - " frameworks " : { <nl> - " net45 " : { } <nl> - } , <nl> - " runtimes " : { <nl> - " win " : { } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index 689eb0b8425 . . 00000000000 <nl> mmm a / src / csharp / Grpc . IntegrationTesting . Server / Grpc . IntegrationTesting . Server . xproj <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project ToolsVersion = " 14 . 0 . 25123 " DefaultTargets = " Build " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> - < PropertyGroup > <nl> - < VisualStudioVersion Condition = " ' $ ( VisualStudioVersion ) ' = = ' ' " > 14 . 0 . 25123 < / VisualStudioVersion > <nl> - < VSToolsPath Condition = " ' $ ( VSToolsPath ) ' = = ' ' " > $ ( MSBuildExtensionsPath32 ) \ Microsoft \ VisualStudio \ v $ ( VisualStudioVersion ) < / VSToolsPath > <nl> - < / PropertyGroup > <nl> - < Import Project = " $ ( VSToolsPath ) \ DNX \ Microsoft . DNX . Props " Condition = " ' $ ( VSToolsPath ) ' ! = ' ' " / > <nl> - < PropertyGroup Label = " Globals " > <nl> - < ProjectGuid > 881f7ad1 - a84e - 47a2 - 9402 - 115c63c4031e < / ProjectGuid > <nl> - < RootNamespace > Grpc . IntegrationTesting . Server < / RootNamespace > <nl> - < BaseIntermediateOutputPath Condition = " ' $ ( BaseIntermediateOutputPath ) ' = = ' ' " > . . \ artifacts \ obj \ $ ( MSBuildProjectName ) < / BaseIntermediateOutputPath > <nl> - < OutputPath Condition = " ' $ ( OutputPath ) ' = = ' ' " > . \ bin \ < / OutputPath > <nl> - < / PropertyGroup > <nl> - < PropertyGroup > <nl> - < SchemaVersion > 2 . 0 < / SchemaVersion > <nl> - < / PropertyGroup > <nl> - < Import Project = " $ ( VSToolsPath ) \ DNX \ Microsoft . DNX . targets " Condition = " ' $ ( VSToolsPath ) ' ! = ' ' " / > <nl> - < / Project > <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index f90528151b4 . . 00000000000 <nl> mmm a / src / csharp / Grpc . IntegrationTesting . Server / project . json <nl> ppp / dev / null <nl> <nl> - { <nl> - " buildOptions " : { <nl> - " emitEntryPoint " : true <nl> - } , <nl> - " configurations " : { <nl> - " Debug " : { <nl> - " buildOptions " : { <nl> - " define " : [ " SIGNED " ] , <nl> - " keyFile " : " . . / keys / Grpc . snk " , <nl> - " xmlDoc " : true , <nl> - " compile " : { <nl> - " includeFiles " : [ " . . / Grpc . Core / Version . cs " ] <nl> - } , <nl> - " copyToOutput " : { <nl> - " mappings " : { <nl> - " data / ca . pem " : " . . / Grpc . IntegrationTesting / data / ca . pem " , <nl> - " data / server1 . key " : " . . / Grpc . IntegrationTesting / data / server1 . key " , <nl> - " data / server1 . pem " : " . . / Grpc . IntegrationTesting / data / server1 . pem " , <nl> - " grpc_csharp_ext . x64 . dll " : " . . / . . / . . / cmake / build / x64 / Debug / grpc_csharp_ext . dll " , <nl> - " grpc_csharp_ext . x86 . dll " : " . . / . . / . . / cmake / build / Win32 / Debug / grpc_csharp_ext . dll " , <nl> - " libgrpc_csharp_ext . x64 . so " : " . . / . . / . . / libs / dbg / libgrpc_csharp_ext . so " , <nl> - " libgrpc_csharp_ext . x64 . dylib " : " . . / . . / . . / libs / dbg / libgrpc_csharp_ext . dylib " <nl> - } <nl> - } <nl> - } <nl> - } , <nl> - " Release " : { <nl> - " buildOptions " : { <nl> - " define " : [ " SIGNED " ] , <nl> - " keyFile " : " . . / keys / Grpc . snk " , <nl> - " xmlDoc " : true , <nl> - " compile " : { <nl> - " includeFiles " : [ " . . / Grpc . Core / Version . cs " ] <nl> - } , <nl> - " copyToOutput " : { <nl> - " mappings " : { <nl> - " data / ca . pem " : " . . / Grpc . IntegrationTesting / data / ca . pem " , <nl> - " data / server1 . key " : " . . / Grpc . IntegrationTesting / data / server1 . key " , <nl> - " data / server1 . pem " : " . . / Grpc . IntegrationTesting / data / server1 . pem " , <nl> - " grpc_csharp_ext . x64 . dll " : " . . / . . / . . / cmake / build / x64 / Release / grpc_csharp_ext . dll " , <nl> - " grpc_csharp_ext . x86 . dll " : " . . / . . / . . / cmake / build / Win32 / Release / grpc_csharp_ext . dll " , <nl> - " libgrpc_csharp_ext . x64 . so " : " . . / . . / . . / libs / opt / libgrpc_csharp_ext . so " , <nl> - " libgrpc_csharp_ext . x64 . dylib " : " . . / . . / . . / libs / opt / libgrpc_csharp_ext . dylib " <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } , <nl> - <nl> - " dependencies " : { <nl> - " Grpc . IntegrationTesting " : { <nl> - " target " : " project " <nl> - } <nl> - } , <nl> - " frameworks " : { <nl> - " net45 " : { } , <nl> - " netcoreapp1 . 0 " : { <nl> - " imports " : [ <nl> - " portable - net45 " <nl> - ] , <nl> - " dependencies " : { <nl> - " Microsoft . NETCore . App " : { <nl> - " type " : " platform " , <nl> - " version " : " 1 . 0 . 0 " <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } <nl> old mode 100644 <nl> new mode 100755 <nl> index 0f283404504 . . fe4e0da4171 <nl> mmm a / src / csharp / Grpc . IntegrationTesting . StressClient / Grpc . IntegrationTesting . StressClient . csproj <nl> ppp b / src / csharp / Grpc . IntegrationTesting . StressClient / Grpc . IntegrationTesting . StressClient . csproj <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project DefaultTargets = " Build " ToolsVersion = " 4 . 0 " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> + < Project Sdk = " Microsoft . NET . Sdk " > <nl> + <nl> + < Import Project = " . . \ Grpc . Core \ Version . csproj . include " / > <nl> + < Import Project = " . . \ Grpc . Core \ Common . csproj . include " / > <nl> + <nl> < PropertyGroup > <nl> - < Configuration Condition = " ' $ ( Configuration ) ' = = ' ' " > Debug < / Configuration > <nl> - < Platform Condition = " ' $ ( Platform ) ' = = ' ' " > AnyCPU < / Platform > <nl> - < ProjectGuid > { ADEBA147 - 80AE - 4710 - 82E9 - 5B7F93690266 } < / ProjectGuid > <nl> - < OutputType > Exe < / OutputType > <nl> - < RootNamespace > Grpc . IntegrationTesting . StressClient < / RootNamespace > <nl> + < TargetFrameworks > net45 ; netcoreapp1 . 0 < / TargetFrameworks > <nl> < AssemblyName > Grpc . IntegrationTesting . StressClient < / AssemblyName > <nl> - < TargetFrameworkVersion > v4 . 5 < / TargetFrameworkVersion > <nl> - < / PropertyGroup > <nl> - < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | AnyCPU ' " > <nl> - < DebugSymbols > true < / DebugSymbols > <nl> - < DebugType > full < / DebugType > <nl> - < Optimize > false < / Optimize > <nl> - < OutputPath > bin \ Debug < / OutputPath > <nl> - < DefineConstants > DEBUG ; < / DefineConstants > <nl> - < ErrorReport > prompt < / ErrorReport > <nl> - < WarningLevel > 4 < / WarningLevel > <nl> - < PlatformTarget > AnyCPU < / PlatformTarget > <nl> - < / PropertyGroup > <nl> - < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Release | AnyCPU ' " > <nl> - < DebugType > pdbonly < / DebugType > <nl> - < Optimize > true < / Optimize > <nl> - < OutputPath > bin \ Release < / OutputPath > <nl> - < ErrorReport > prompt < / ErrorReport > <nl> - < WarningLevel > 4 < / WarningLevel > <nl> - < PlatformTarget > AnyCPU < / PlatformTarget > <nl> + < OutputType > Exe < / OutputType > <nl> + < PackageId > Grpc . IntegrationTesting . StressClient < / PackageId > <nl> + < PackageTargetFallback Condition = " ' $ ( TargetFramework ) ' = = ' netcoreapp1 . 0 ' " > $ ( PackageTargetFallback ) ; portable - net45 < / PackageTargetFallback > <nl> + < RuntimeFrameworkVersion Condition = " ' $ ( TargetFramework ) ' = = ' netcoreapp1 . 0 ' " > 1 . 0 . 4 < / RuntimeFrameworkVersion > <nl> < / PropertyGroup > <nl> + <nl> < ItemGroup > <nl> - < Reference Include = " System " / > <nl> + < ProjectReference Include = " . . / Grpc . IntegrationTesting / Grpc . IntegrationTesting . csproj " / > <nl> < / ItemGroup > <nl> - < ItemGroup > <nl> - < Compile Include = " . . \ Grpc . Core \ Version . cs " > <nl> - < Link > Version . cs < / Link > <nl> - < / Compile > <nl> - < Compile Include = " Program . cs " / > <nl> - < Compile Include = " Properties \ AssemblyInfo . cs " / > <nl> - < / ItemGroup > <nl> - < Import Project = " $ ( MSBuildBinPath ) \ Microsoft . CSharp . targets " / > <nl> - < ItemGroup > <nl> - < ProjectReference Include = " . . \ Grpc . Core \ Grpc . Core . csproj " > <nl> - < Project > { CCC4440E - 49F7 - 4790 - B0AF - FEABB0837AE7 } < / Project > <nl> - < Name > Grpc . Core < / Name > <nl> - < / ProjectReference > <nl> - < ProjectReference Include = " . . \ Grpc . IntegrationTesting \ Grpc . IntegrationTesting . csproj " > <nl> - < Project > { C61154BA - DD4A - 4838 - 8420 - 0162A28925E0 } < / Project > <nl> - < Name > Grpc . IntegrationTesting < / Name > <nl> - < / ProjectReference > <nl> + <nl> + < ItemGroup Condition = " ' $ ( TargetFramework ) ' = = ' net45 ' " > <nl> + < Reference Include = " System " / > <nl> + < Reference Include = " Microsoft . CSharp " / > <nl> < / ItemGroup > <nl> + <nl> < ItemGroup > <nl> - < None Include = " Grpc . IntegrationTesting . StressClient . project . json " / > <nl> + < Compile Include = " . . \ Grpc . Core \ Version . cs " / > <nl> < / ItemGroup > <nl> - < / Project > <nl> \ No newline at end of file <nl> + <nl> + < / Project > <nl> deleted file mode 100644 <nl> index c2f5bcb1637 . . 00000000000 <nl> mmm a / src / csharp / Grpc . IntegrationTesting . StressClient / Grpc . IntegrationTesting . StressClient . project . json <nl> ppp / dev / null <nl> <nl> - { <nl> - " frameworks " : { <nl> - " net45 " : { } <nl> - } , <nl> - " runtimes " : { <nl> - " win " : { } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index 2f4fdcbb470 . . 00000000000 <nl> mmm a / src / csharp / Grpc . IntegrationTesting . StressClient / Grpc . IntegrationTesting . StressClient . xproj <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project ToolsVersion = " 14 . 0 . 25123 " DefaultTargets = " Build " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> - < PropertyGroup > <nl> - < VisualStudioVersion Condition = " ' $ ( VisualStudioVersion ) ' = = ' ' " > 14 . 0 . 25123 < / VisualStudioVersion > <nl> - < VSToolsPath Condition = " ' $ ( VSToolsPath ) ' = = ' ' " > $ ( MSBuildExtensionsPath32 ) \ Microsoft \ VisualStudio \ v $ ( VisualStudioVersion ) < / VSToolsPath > <nl> - < / PropertyGroup > <nl> - < Import Project = " $ ( VSToolsPath ) \ DotNet \ Microsoft . DotNet . Props " Condition = " ' $ ( VSToolsPath ) ' ! = ' ' " / > <nl> - < PropertyGroup Label = " Globals " > <nl> - < ProjectGuid > 0ebc910b - 8867 - 4d3e - 8686 - 91f34183d839 < / ProjectGuid > <nl> - < RootNamespace > Grpc . IntegrationTesting . StressClient < / RootNamespace > <nl> - < BaseIntermediateOutputPath Condition = " ' $ ( BaseIntermediateOutputPath ) ' = = ' ' " > . \ obj < / BaseIntermediateOutputPath > <nl> - < OutputPath Condition = " ' $ ( OutputPath ) ' = = ' ' " > . \ bin \ < / OutputPath > <nl> - < / PropertyGroup > <nl> - <nl> - < PropertyGroup > <nl> - < SchemaVersion > 2 . 0 < / SchemaVersion > <nl> - < / PropertyGroup > <nl> - < Import Project = " $ ( VSToolsPath ) \ DotNet \ Microsoft . DotNet . targets " Condition = " ' $ ( VSToolsPath ) ' ! = ' ' " / > <nl> - < / Project > <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index f90528151b4 . . 00000000000 <nl> mmm a / src / csharp / Grpc . IntegrationTesting . StressClient / project . json <nl> ppp / dev / null <nl> <nl> - { <nl> - " buildOptions " : { <nl> - " emitEntryPoint " : true <nl> - } , <nl> - " configurations " : { <nl> - " Debug " : { <nl> - " buildOptions " : { <nl> - " define " : [ " SIGNED " ] , <nl> - " keyFile " : " . . / keys / Grpc . snk " , <nl> - " xmlDoc " : true , <nl> - " compile " : { <nl> - " includeFiles " : [ " . . / Grpc . Core / Version . cs " ] <nl> - } , <nl> - " copyToOutput " : { <nl> - " mappings " : { <nl> - " data / ca . pem " : " . . / Grpc . IntegrationTesting / data / ca . pem " , <nl> - " data / server1 . key " : " . . / Grpc . IntegrationTesting / data / server1 . key " , <nl> - " data / server1 . pem " : " . . / Grpc . IntegrationTesting / data / server1 . pem " , <nl> - " grpc_csharp_ext . x64 . dll " : " . . / . . / . . / cmake / build / x64 / Debug / grpc_csharp_ext . dll " , <nl> - " grpc_csharp_ext . x86 . dll " : " . . / . . / . . / cmake / build / Win32 / Debug / grpc_csharp_ext . dll " , <nl> - " libgrpc_csharp_ext . x64 . so " : " . . / . . / . . / libs / dbg / libgrpc_csharp_ext . so " , <nl> - " libgrpc_csharp_ext . x64 . dylib " : " . . / . . / . . / libs / dbg / libgrpc_csharp_ext . dylib " <nl> - } <nl> - } <nl> - } <nl> - } , <nl> - " Release " : { <nl> - " buildOptions " : { <nl> - " define " : [ " SIGNED " ] , <nl> - " keyFile " : " . . / keys / Grpc . snk " , <nl> - " xmlDoc " : true , <nl> - " compile " : { <nl> - " includeFiles " : [ " . . / Grpc . Core / Version . cs " ] <nl> - } , <nl> - " copyToOutput " : { <nl> - " mappings " : { <nl> - " data / ca . pem " : " . . / Grpc . IntegrationTesting / data / ca . pem " , <nl> - " data / server1 . key " : " . . / Grpc . IntegrationTesting / data / server1 . key " , <nl> - " data / server1 . pem " : " . . / Grpc . IntegrationTesting / data / server1 . pem " , <nl> - " grpc_csharp_ext . x64 . dll " : " . . / . . / . . / cmake / build / x64 / Release / grpc_csharp_ext . dll " , <nl> - " grpc_csharp_ext . x86 . dll " : " . . / . . / . . / cmake / build / Win32 / Release / grpc_csharp_ext . dll " , <nl> - " libgrpc_csharp_ext . x64 . so " : " . . / . . / . . / libs / opt / libgrpc_csharp_ext . so " , <nl> - " libgrpc_csharp_ext . x64 . dylib " : " . . / . . / . . / libs / opt / libgrpc_csharp_ext . dylib " <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } , <nl> - <nl> - " dependencies " : { <nl> - " Grpc . IntegrationTesting " : { <nl> - " target " : " project " <nl> - } <nl> - } , <nl> - " frameworks " : { <nl> - " net45 " : { } , <nl> - " netcoreapp1 . 0 " : { <nl> - " imports " : [ <nl> - " portable - net45 " <nl> - ] , <nl> - " dependencies " : { <nl> - " Microsoft . NETCore . App " : { <nl> - " type " : " platform " , <nl> - " version " : " 1 . 0 . 0 " <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } <nl> old mode 100644 <nl> new mode 100755 <nl> index 38b9a5d3c59 . . 6f2f06a6522 <nl> mmm a / src / csharp / Grpc . IntegrationTesting / Grpc . IntegrationTesting . csproj <nl> ppp b / src / csharp / Grpc . IntegrationTesting / Grpc . IntegrationTesting . csproj <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project DefaultTargets = " Build " ToolsVersion = " 4 . 0 " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> + < Project Sdk = " Microsoft . NET . Sdk " > <nl> + <nl> + < Import Project = " . . \ Grpc . Core \ Version . csproj . include " / > <nl> + < Import Project = " . . \ Grpc . Core \ Common . csproj . include " / > <nl> + <nl> < PropertyGroup > <nl> - < Configuration Condition = " ' $ ( Configuration ) ' = = ' ' " > Debug < / Configuration > <nl> - < Platform Condition = " ' $ ( Platform ) ' = = ' ' " > AnyCPU < / Platform > <nl> - < ProjectGuid > { C61154BA - DD4A - 4838 - 8420 - 0162A28925E0 } < / ProjectGuid > <nl> - < OutputType > Exe < / OutputType > <nl> - < RootNamespace > Grpc . IntegrationTesting < / RootNamespace > <nl> + < TargetFrameworks > net45 ; netcoreapp1 . 0 < / TargetFrameworks > <nl> < AssemblyName > Grpc . IntegrationTesting < / AssemblyName > <nl> - < TargetFrameworkVersion > v4 . 5 < / TargetFrameworkVersion > <nl> - < NuGetPackageImportStamp > 3a1c655d < / NuGetPackageImportStamp > <nl> - < / PropertyGroup > <nl> - < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | AnyCPU ' " > <nl> - < DebugSymbols > true < / DebugSymbols > <nl> - < DebugType > full < / DebugType > <nl> - < Optimize > false < / Optimize > <nl> - < OutputPath > bin \ Debug < / OutputPath > <nl> - < DefineConstants > DEBUG ; < / DefineConstants > <nl> - < ErrorReport > prompt < / ErrorReport > <nl> - < WarningLevel > 4 < / WarningLevel > <nl> - < PlatformTarget > AnyCPU < / PlatformTarget > <nl> - < / PropertyGroup > <nl> - < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Release | AnyCPU ' " > <nl> - < DebugType > pdbonly < / DebugType > <nl> - < Optimize > true < / Optimize > <nl> - < OutputPath > bin \ Release < / OutputPath > <nl> - < ErrorReport > prompt < / ErrorReport > <nl> - < WarningLevel > 4 < / WarningLevel > <nl> - < PlatformTarget > AnyCPU < / PlatformTarget > <nl> + < OutputType > Exe < / OutputType > <nl> + < PackageId > Grpc . IntegrationTesting < / PackageId > <nl> + < PackageTargetFallback Condition = " ' $ ( TargetFramework ) ' = = ' netcoreapp1 . 0 ' " > $ ( PackageTargetFallback ) ; portable - net45 < / PackageTargetFallback > <nl> + < RuntimeFrameworkVersion Condition = " ' $ ( TargetFramework ) ' = = ' netcoreapp1 . 0 ' " > 1 . 0 . 4 < / RuntimeFrameworkVersion > <nl> < / PropertyGroup > <nl> + <nl> < ItemGroup > <nl> - < Reference Include = " System " / > <nl> - < Reference Include = " System . Net " / > <nl> - < Reference Include = " System . Net . Http " / > <nl> - < Reference Include = " System . Net . Http . WebRequest " / > <nl> - < Reference Include = " Zlib . Portable " > <nl> - < HintPath > . . \ packages \ Zlib . Portable . Signed . 1 . 11 . 0 \ lib \ portable - net4 + sl5 + wp8 + win8 + wpa81 + MonoTouch + MonoAndroid \ Zlib . Portable . dll < / HintPath > <nl> - < / Reference > <nl> - < Reference Include = " System . Interactive . Async " > <nl> - < HintPath > . . \ packages \ System . Interactive . Async . 3 . 1 . 1 \ lib \ net45 \ System . Interactive . Async . dll < / HintPath > <nl> - < / Reference > <nl> - < Reference Include = " Google . Apis . Core " > <nl> - < HintPath > . . \ packages \ Google . Apis . Core . 1 . 21 . 0 \ lib \ net45 \ Google . Apis . Core . dll < / HintPath > <nl> - < / Reference > <nl> - < Reference Include = " Google . Apis " > <nl> - < HintPath > . . \ packages \ Google . Apis . 1 . 21 . 0 \ lib \ net45 \ Google . Apis . dll < / HintPath > <nl> - < / Reference > <nl> - < Reference Include = " Google . Apis . PlatformServices " > <nl> - < HintPath > . . \ packages \ Google . Apis . 1 . 21 . 0 \ lib \ net45 \ Google . Apis . PlatformServices . dll < / HintPath > <nl> - < / Reference > <nl> - < Reference Include = " Google . Apis . Auth " > <nl> - < HintPath > . . \ packages \ Google . Apis . Auth . 1 . 21 . 0 \ lib \ net45 \ Google . Apis . Auth . dll < / HintPath > <nl> - < / Reference > <nl> - < Reference Include = " Google . Apis . Auth . PlatformServices " > <nl> - < HintPath > . . \ packages \ Google . Apis . Auth . 1 . 21 . 0 \ lib \ net45 \ Google . Apis . Auth . PlatformServices . dll < / HintPath > <nl> - < / Reference > <nl> - < Reference Include = " Google . Protobuf " > <nl> - < HintPath > . . \ packages \ Google . Protobuf . 3 . 2 . 0 \ lib \ net45 \ Google . Protobuf . dll < / HintPath > <nl> - < / Reference > <nl> - < Reference Include = " nunit . framework " > <nl> - < HintPath > . . \ packages \ NUnit . 3 . 6 . 0 \ lib \ net45 \ nunit . framework . dll < / HintPath > <nl> - < / Reference > <nl> - < Reference Include = " nunitlite " > <nl> - < HintPath > . . \ packages \ NUnitLite . 3 . 6 . 0 \ lib \ net45 \ nunitlite . dll < / HintPath > <nl> - < / Reference > <nl> - < Reference Include = " Newtonsoft . Json " > <nl> - < HintPath > . . \ packages \ Newtonsoft . Json . 9 . 0 . 1 \ lib \ net45 \ Newtonsoft . Json . dll < / HintPath > <nl> - < / Reference > <nl> - < Reference Include = " Castle . Core " > <nl> - < HintPath > . . \ packages \ Castle . Core . 4 . 0 . 0 \ lib \ net45 \ Castle . Core . dll < / HintPath > <nl> - < / Reference > <nl> - < Reference Include = " Moq " > <nl> - < HintPath > . . \ packages \ Moq . 4 . 7 . 0 \ lib \ net45 \ Moq . dll < / HintPath > <nl> - < / Reference > <nl> - < Reference Include = " CommandLine " > <nl> - < HintPath > . . \ packages \ CommandLineParser . 2 . 1 . 1 - beta \ lib \ net45 \ CommandLine . dll < / HintPath > <nl> - < / Reference > <nl> + < ProjectReference Include = " . . / Grpc . Auth / Grpc . Auth . csproj " / > <nl> + < ProjectReference Include = " . . / Grpc . Core / Grpc . Core . csproj " / > <nl> < / ItemGroup > <nl> + <nl> < ItemGroup > <nl> - < Compile Include = " . . \ Grpc . Core \ Version . cs " > <nl> - < Link > Version . cs < / Link > <nl> - < / Compile > <nl> - < Compile Include = " Properties \ AssemblyInfo . cs " / > <nl> - < Compile Include = " Empty . cs " / > <nl> - < Compile Include = " Messages . cs " / > <nl> - < Compile Include = " InteropClientServerTest . cs " / > <nl> - < Compile Include = " MetadataCredentialsTest . cs " / > <nl> - < Compile Include = " TestServiceImpl . cs " / > <nl> - < Compile Include = " InteropServer . cs " / > <nl> - < Compile Include = " InteropClient . cs " / > <nl> - < Compile Include = " TestCredentials . cs " / > <nl> - < Compile Include = " TestGrpc . cs " / > <nl> - < Compile Include = " SslCredentialsTest . cs " / > <nl> - < Compile Include = " Test . cs " / > <nl> - < Compile Include = " IClientRunner . cs " / > <nl> - < Compile Include = " ClientRunners . cs " / > <nl> - < Compile Include = " IServerRunner . cs " / > <nl> - < Compile Include = " ServerRunners . cs " / > <nl> - < Compile Include = " RunnerClientServerTest . cs " / > <nl> - < Compile Include = " Control . cs " / > <nl> - < Compile Include = " Payloads . cs " / > <nl> - < Compile Include = " Services . cs " / > <nl> - < Compile Include = " ServicesGrpc . cs " / > <nl> - < Compile Include = " Stats . cs " / > <nl> - < Compile Include = " BenchmarkServiceImpl . cs " / > <nl> - < Compile Include = " Histogram . cs " / > <nl> - < Compile Include = " HistogramTest . cs " / > <nl> - < Compile Include = " WorkerServiceImpl . cs " / > <nl> - < Compile Include = " QpsWorker . cs " / > <nl> - < Compile Include = " WallClockStopwatch . cs " / > <nl> - < Compile Include = " GenericService . cs " / > <nl> - < Compile Include = " GeneratedServiceBaseTest . cs " / > <nl> - < Compile Include = " GeneratedClientTest . cs " / > <nl> - < Compile Include = " InterarrivalTimers . cs " / > <nl> - < Compile Include = " NUnitMain . cs " / > <nl> - < Compile Include = " StressTestClient . cs " / > <nl> - < Compile Include = " Metrics . cs " / > <nl> - < Compile Include = " MetricsGrpc . cs " / > <nl> + < PackageReference Include = " Google . Protobuf " Version = " $ ( GoogleProtobufVersion ) " / > <nl> + < PackageReference Include = " CommandLineParser " Version = " 2 . 1 . 1 - beta " / > <nl> + < PackageReference Include = " Moq " Version = " 4 . 7 . 0 " / > <nl> + < PackageReference Include = " NUnit " Version = " 3 . 6 . 0 " / > <nl> + < PackageReference Include = " NUnitLite " Version = " 3 . 6 . 0 " / > <nl> < / ItemGroup > <nl> - < Import Project = " $ ( MSBuildBinPath ) \ Microsoft . CSharp . targets " / > <nl> + <nl> + < ItemGroup Condition = " ' $ ( TargetFramework ) ' = = ' net45 ' " > <nl> + < Reference Include = " System " / > <nl> + < Reference Include = " Microsoft . CSharp " / > <nl> + < / ItemGroup > <nl> + <nl> + < ItemGroup Condition = " ' $ ( TargetFramework ) ' = = ' netcoreapp1 . 0 ' " > <nl> + < PackageReference Include = " System . Linq . Expressions " Version = " 4 . 1 . 1 " / > <nl> + < / ItemGroup > <nl> + <nl> < ItemGroup > <nl> - < ProjectReference Include = " . . \ Grpc . Core \ Grpc . Core . csproj " > <nl> - < Project > { CCC4440E - 49F7 - 4790 - B0AF - FEABB0837AE7 } < / Project > <nl> - < Name > Grpc . Core < / Name > <nl> - < / ProjectReference > <nl> - < ProjectReference Include = " . . \ Grpc . Auth \ Grpc . Auth . csproj " > <nl> - < Project > { AE21D0EE - 9A2C - 4C15 - AB7F - 5224EED5B0EA } < / Project > <nl> - < Name > Grpc . Auth < / Name > <nl> - < / ProjectReference > <nl> + < Compile Include = " . . \ Grpc . Core \ Version . cs " / > <nl> < / ItemGroup > <nl> + <nl> < ItemGroup > <nl> - < None Include = " Grpc . IntegrationTesting . project . json " / > <nl> - < None Include = " packages . config " > <nl> - < SubType > Designer < / SubType > <nl> - < / None > <nl> - < None Include = " data \ README " > <nl> - < CopyToOutputDirectory > PreserveNewest < / CopyToOutputDirectory > <nl> - < / None > <nl> - < None Include = " data \ ca . pem " > <nl> + < Content Include = " data \ server1 . pem " > <nl> < CopyToOutputDirectory > PreserveNewest < / CopyToOutputDirectory > <nl> - < / None > <nl> - < None Include = " data \ server1 . key " > <nl> + < Pack > false < / Pack > <nl> + < / Content > <nl> + < Content Include = " data \ server1 . key " > <nl> < CopyToOutputDirectory > PreserveNewest < / CopyToOutputDirectory > <nl> - < / None > <nl> - < None Include = " data \ server1 . pem " > <nl> + < Pack > false < / Pack > <nl> + < / Content > <nl> + < Content Include = " data \ ca . pem " > <nl> < CopyToOutputDirectory > PreserveNewest < / CopyToOutputDirectory > <nl> - < / None > <nl> - < / ItemGroup > <nl> - < ItemGroup > <nl> - < Service Include = " { 82A7F48D - 3B50 - 4B1E - B82E - 3ADA8210C358 } " / > <nl> + < Pack > false < / Pack > <nl> + < / Content > <nl> < / ItemGroup > <nl> + <nl> < / Project > <nl> deleted file mode 100644 <nl> index c2f5bcb1637 . . 00000000000 <nl> mmm a / src / csharp / Grpc . IntegrationTesting / Grpc . IntegrationTesting . project . json <nl> ppp / dev / null <nl> <nl> - { <nl> - " frameworks " : { <nl> - " net45 " : { } <nl> - } , <nl> - " runtimes " : { <nl> - " win " : { } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index 357300ecb9b . . 00000000000 <nl> mmm a / src / csharp / Grpc . IntegrationTesting / Grpc . IntegrationTesting . xproj <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project ToolsVersion = " 14 . 0 . 25123 " DefaultTargets = " Build " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> - < PropertyGroup > <nl> - < VisualStudioVersion Condition = " ' $ ( VisualStudioVersion ) ' = = ' ' " > 14 . 0 . 25123 < / VisualStudioVersion > <nl> - < VSToolsPath Condition = " ' $ ( VSToolsPath ) ' = = ' ' " > $ ( MSBuildExtensionsPath32 ) \ Microsoft \ VisualStudio \ v $ ( VisualStudioVersion ) < / VSToolsPath > <nl> - < / PropertyGroup > <nl> - < Import Project = " $ ( VSToolsPath ) \ DNX \ Microsoft . DNX . Props " Condition = " ' $ ( VSToolsPath ) ' ! = ' ' " / > <nl> - < PropertyGroup Label = " Globals " > <nl> - < ProjectGuid > 20354386 - 3e71 - 4046 - a269 - 3bc2a06f3ec8 < / ProjectGuid > <nl> - < RootNamespace > Grpc . IntegrationTesting < / RootNamespace > <nl> - < BaseIntermediateOutputPath Condition = " ' $ ( BaseIntermediateOutputPath ) ' = = ' ' " > . . \ artifacts \ obj \ $ ( MSBuildProjectName ) < / BaseIntermediateOutputPath > <nl> - < OutputPath Condition = " ' $ ( OutputPath ) ' = = ' ' " > . \ bin \ < / OutputPath > <nl> - < / PropertyGroup > <nl> - < PropertyGroup > <nl> - < SchemaVersion > 2 . 0 < / SchemaVersion > <nl> - < / PropertyGroup > <nl> - < Import Project = " $ ( VSToolsPath ) \ DNX \ Microsoft . DNX . targets " Condition = " ' $ ( VSToolsPath ) ' ! = ' ' " / > <nl> - < / Project > <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 030f9d97b89 . . 00000000000 <nl> mmm a / src / csharp / Grpc . IntegrationTesting / packages . config <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < packages > <nl> - < package id = " Castle . Core " version = " 4 . 0 . 0 " targetFramework = " net45 " / > <nl> - < package id = " CommandLineParser " version = " 2 . 1 . 1 - beta " targetFramework = " net45 " / > <nl> - < package id = " Google . Apis " version = " 1 . 21 . 0 " targetFramework = " net45 " / > <nl> - < package id = " Google . Apis . Auth " version = " 1 . 21 . 0 " targetFramework = " net45 " / > <nl> - < package id = " Google . Apis . Core " version = " 1 . 21 . 0 " targetFramework = " net45 " / > <nl> - < package id = " Google . Protobuf " version = " 3 . 2 . 0 " targetFramework = " net45 " / > <nl> - < package id = " Moq " version = " 4 . 7 . 0 " targetFramework = " net45 " / > <nl> - < package id = " Newtonsoft . Json " version = " 9 . 0 . 1 " targetFramework = " net45 " / > <nl> - < package id = " NUnit " version = " 3 . 6 . 0 " targetFramework = " net45 " / > <nl> - < package id = " NUnitLite " version = " 3 . 6 . 0 " targetFramework = " net45 " / > <nl> - < package id = " System . Interactive . Async " version = " 3 . 1 . 1 " targetFramework = " net45 " / > <nl> - < package id = " Zlib . Portable . Signed " version = " 1 . 11 . 0 " targetFramework = " net45 " / > <nl> - < / packages > <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 40fc566adcf . . 00000000000 <nl> mmm a / src / csharp / Grpc . IntegrationTesting / project . json <nl> ppp / dev / null <nl> <nl> - { <nl> - " buildOptions " : { <nl> - " emitEntryPoint " : true <nl> - } , <nl> - " configurations " : { <nl> - " Debug " : { <nl> - " buildOptions " : { <nl> - " define " : [ " SIGNED " ] , <nl> - " keyFile " : " . . / keys / Grpc . snk " , <nl> - " xmlDoc " : true , <nl> - " compile " : { <nl> - " includeFiles " : [ " . . / Grpc . Core / Version . cs " ] <nl> - } , <nl> - " copyToOutput " : { <nl> - " mappings " : { <nl> - " data / ca . pem " : " . . / Grpc . IntegrationTesting / data / ca . pem " , <nl> - " data / server1 . key " : " . . / Grpc . IntegrationTesting / data / server1 . key " , <nl> - " data / server1 . pem " : " . . / Grpc . IntegrationTesting / data / server1 . pem " , <nl> - " grpc_csharp_ext . x64 . dll " : " . . / . . / . . / cmake / build / x64 / Debug / grpc_csharp_ext . dll " , <nl> - " grpc_csharp_ext . x86 . dll " : " . . / . . / . . / cmake / build / Win32 / Debug / grpc_csharp_ext . dll " , <nl> - " libgrpc_csharp_ext . x64 . so " : " . . / . . / . . / libs / dbg / libgrpc_csharp_ext . so " , <nl> - " libgrpc_csharp_ext . x64 . dylib " : " . . / . . / . . / libs / dbg / libgrpc_csharp_ext . dylib " <nl> - } <nl> - } <nl> - } <nl> - } , <nl> - " Release " : { <nl> - " buildOptions " : { <nl> - " define " : [ " SIGNED " ] , <nl> - " keyFile " : " . . / keys / Grpc . snk " , <nl> - " xmlDoc " : true , <nl> - " compile " : { <nl> - " includeFiles " : [ " . . / Grpc . Core / Version . cs " ] <nl> - } , <nl> - " copyToOutput " : { <nl> - " mappings " : { <nl> - " data / ca . pem " : " . . / Grpc . IntegrationTesting / data / ca . pem " , <nl> - " data / server1 . key " : " . . / Grpc . IntegrationTesting / data / server1 . key " , <nl> - " data / server1 . pem " : " . . / Grpc . IntegrationTesting / data / server1 . pem " , <nl> - " grpc_csharp_ext . x64 . dll " : " . . / . . / . . / cmake / build / x64 / Release / grpc_csharp_ext . dll " , <nl> - " grpc_csharp_ext . x86 . dll " : " . . / . . / . . / cmake / build / Win32 / Release / grpc_csharp_ext . dll " , <nl> - " libgrpc_csharp_ext . x64 . so " : " . . / . . / . . / libs / opt / libgrpc_csharp_ext . so " , <nl> - " libgrpc_csharp_ext . x64 . dylib " : " . . / . . / . . / libs / opt / libgrpc_csharp_ext . dylib " <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } , <nl> - <nl> - " dependencies " : { <nl> - " Grpc . Auth " : { <nl> - " target " : " project " <nl> - } , <nl> - " Grpc . Core " : { <nl> - " target " : " project " <nl> - } , <nl> - " Google . Protobuf " : " 3 . 2 . 0 " , <nl> - " CommandLineParser " : " 2 . 1 . 1 - beta " , <nl> - " Moq " : " 4 . 7 . 0 " , <nl> - " NUnit " : " 3 . 6 . 0 " , <nl> - " NUnitLite " : " 3 . 6 . 0 " <nl> - } , <nl> - " frameworks " : { <nl> - " net45 " : { <nl> - " frameworkAssemblies " : { } <nl> - } , <nl> - " netcoreapp1 . 0 " : { <nl> - " imports " : [ <nl> - " portable - net45 " <nl> - ] , <nl> - " dependencies " : { <nl> - " Microsoft . NETCore . App " : { <nl> - " type " : " platform " , <nl> - " version " : " 1 . 0 . 0 " <nl> - } , <nl> - " System . Linq . Expressions " : " 4 . 1 . 0 " <nl> - } <nl> - } <nl> - } <nl> - } <nl> old mode 100644 <nl> new mode 100755 <nl> index 7e2b551799e . . af6ade852b2 <nl> mmm a / src / csharp / Grpc . Reflection . Tests / Grpc . Reflection . Tests . csproj <nl> ppp b / src / csharp / Grpc . Reflection . Tests / Grpc . Reflection . Tests . csproj <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project ToolsVersion = " 4 . 0 " DefaultTargets = " Build " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> - < Import Project = " $ ( MSBuildExtensionsPath ) \ $ ( MSBuildToolsVersion ) \ Microsoft . Common . props " Condition = " Exists ( ' $ ( MSBuildExtensionsPath ) \ $ ( MSBuildToolsVersion ) \ Microsoft . Common . props ' ) " / > <nl> + < Project Sdk = " Microsoft . NET . Sdk " > <nl> + <nl> + < Import Project = " . . \ Grpc . Core \ Version . csproj . include " / > <nl> + < Import Project = " . . \ Grpc . Core \ Common . csproj . include " / > <nl> + <nl> < PropertyGroup > <nl> - < Configuration Condition = " ' $ ( Configuration ) ' = = ' ' " > Debug < / Configuration > <nl> - < Platform Condition = " ' $ ( Platform ) ' = = ' ' " > AnyCPU < / Platform > <nl> - < ProjectGuid > { B88F91D6 - 436D - 4C78 - 8B99 - 47800FA8DE03 } < / ProjectGuid > <nl> - < OutputType > Exe < / OutputType > <nl> - < AppDesignerFolder > Properties < / AppDesignerFolder > <nl> - < RootNamespace > Grpc . Reflection . Tests < / RootNamespace > <nl> + < TargetFrameworks > net45 ; netcoreapp1 . 0 < / TargetFrameworks > <nl> < AssemblyName > Grpc . Reflection . Tests < / AssemblyName > <nl> - < TargetFrameworkVersion > v4 . 5 < / TargetFrameworkVersion > <nl> - < FileAlignment > 512 < / FileAlignment > <nl> - < / PropertyGroup > <nl> - < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | AnyCPU ' " > <nl> - < DebugSymbols > true < / DebugSymbols > <nl> - < DebugType > full < / DebugType > <nl> - < Optimize > false < / Optimize > <nl> - < OutputPath > bin \ Debug \ < / OutputPath > <nl> - < ErrorReport > prompt < / ErrorReport > <nl> - < WarningLevel > 4 < / WarningLevel > <nl> - < / PropertyGroup > <nl> - < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Release | AnyCPU ' " > <nl> - < DebugType > pdbonly < / DebugType > <nl> - < Optimize > true < / Optimize > <nl> - < OutputPath > bin \ Release \ < / OutputPath > <nl> - < ErrorReport > prompt < / ErrorReport > <nl> - < WarningLevel > 4 < / WarningLevel > <nl> + < OutputType > Exe < / OutputType > <nl> + < PackageId > Grpc . Reflection . Tests < / PackageId > <nl> + < PackageTargetFallback Condition = " ' $ ( TargetFramework ) ' = = ' netcoreapp1 . 0 ' " > $ ( PackageTargetFallback ) ; portable - net45 < / PackageTargetFallback > <nl> + < RuntimeFrameworkVersion Condition = " ' $ ( TargetFramework ) ' = = ' netcoreapp1 . 0 ' " > 1 . 0 . 4 < / RuntimeFrameworkVersion > <nl> < / PropertyGroup > <nl> + <nl> < ItemGroup > <nl> - < Reference Include = " System " / > <nl> - < Reference Include = " System . Core " / > <nl> - < Reference Include = " System . Xml . Linq " / > <nl> - < Reference Include = " System . Data . DataSetExtensions " / > <nl> - < Reference Include = " Microsoft . CSharp " / > <nl> - < Reference Include = " System . Data " / > <nl> - < Reference Include = " System . Xml " / > <nl> - < Reference Include = " System . Interactive . Async " > <nl> - < HintPath > . . \ packages \ System . Interactive . Async . 3 . 1 . 1 \ lib \ net45 \ System . Interactive . Async . dll < / HintPath > <nl> - < / Reference > <nl> - < Reference Include = " Google . Protobuf " > <nl> - < HintPath > . . \ packages \ Google . Protobuf . 3 . 2 . 0 \ lib \ net45 \ Google . Protobuf . dll < / HintPath > <nl> - < / Reference > <nl> - < Reference Include = " nunit . framework " > <nl> - < HintPath > . . \ packages \ NUnit . 3 . 6 . 0 \ lib \ net45 \ nunit . framework . dll < / HintPath > <nl> - < / Reference > <nl> - < Reference Include = " nunitlite " > <nl> - < HintPath > . . \ packages \ NUnitLite . 3 . 6 . 0 \ lib \ net45 \ nunitlite . dll < / HintPath > <nl> - < / Reference > <nl> + < ProjectReference Include = " . . / Grpc . Reflection / Grpc . Reflection . csproj " / > <nl> < / ItemGroup > <nl> + <nl> < ItemGroup > <nl> - < Compile Include = " . . \ Grpc . Core \ Version . cs " > <nl> - < Link > Version . cs < / Link > <nl> - < / Compile > <nl> - < Compile Include = " SymbolRegistryTest . cs " / > <nl> - < Compile Include = " ReflectionClientServerTest . cs " / > <nl> - < Compile Include = " Properties \ AssemblyInfo . cs " / > <nl> - < Compile Include = " NUnitMain . cs " / > <nl> + < PackageReference Include = " NUnit " Version = " 3 . 6 . 0 " / > <nl> + < PackageReference Include = " NUnitLite " Version = " 3 . 6 . 0 " / > <nl> < / ItemGroup > <nl> - < ItemGroup > <nl> - < ProjectReference Include = " . . \ Grpc . Core \ Grpc . Core . csproj " > <nl> - < Project > { CCC4440E - 49F7 - 4790 - B0AF - FEABB0837AE7 } < / Project > <nl> - < Name > Grpc . Core < / Name > <nl> - < / ProjectReference > <nl> - < ProjectReference Include = " . . \ Grpc . Reflection \ Grpc . Reflection . csproj " > <nl> - < Project > { 4F18CF52 - B3DB - 4A77 - 97C5 - 7F7F4B6C1715 } < / Project > <nl> - < Name > Grpc . Reflection < / Name > <nl> - < / ProjectReference > <nl> - < / ItemGroup > <nl> - < ItemGroup > <nl> - < None Include = " Grpc . Reflection . Tests . project . json " / > <nl> - < None Include = " packages . config " / > <nl> + <nl> + < ItemGroup Condition = " ' $ ( TargetFramework ) ' = = ' net45 ' " > <nl> + < Reference Include = " System " / > <nl> + < Reference Include = " Microsoft . CSharp " / > <nl> < / ItemGroup > <nl> + <nl> < ItemGroup > <nl> - < Service Include = " { 82A7F48D - 3B50 - 4B1E - B82E - 3ADA8210C358 } " / > <nl> + < Compile Include = " . . \ Grpc . Core \ Version . cs " / > <nl> < / ItemGroup > <nl> - < Import Project = " $ ( MSBuildToolsPath ) \ Microsoft . CSharp . targets " / > <nl> - < ! - - To modify your build process , add your task inside one of the targets below and uncomment it . <nl> - Other similar extension points exist , see Microsoft . Common . targets . <nl> - < Target Name = " BeforeBuild " > <nl> - < / Target > <nl> - < Target Name = " AfterBuild " > <nl> - < / Target > <nl> - - - > <nl> - < / Project > <nl> \ No newline at end of file <nl> + <nl> + < / Project > <nl> deleted file mode 100644 <nl> index c2f5bcb1637 . . 00000000000 <nl> mmm a / src / csharp / Grpc . Reflection . Tests / Grpc . Reflection . Tests . project . json <nl> ppp / dev / null <nl> <nl> - { <nl> - " frameworks " : { <nl> - " net45 " : { } <nl> - } , <nl> - " runtimes " : { <nl> - " win " : { } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index 4a3100853d1 . . 00000000000 <nl> mmm a / src / csharp / Grpc . Reflection . Tests / Grpc . Reflection . Tests . xproj <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project ToolsVersion = " 14 . 0 . 25123 " DefaultTargets = " Build " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> - < PropertyGroup > <nl> - < VisualStudioVersion Condition = " ' $ ( VisualStudioVersion ) ' = = ' ' " > 14 . 0 . 25123 < / VisualStudioVersion > <nl> - < VSToolsPath Condition = " ' $ ( VSToolsPath ) ' = = ' ' " > $ ( MSBuildExtensionsPath32 ) \ Microsoft \ VisualStudio \ v $ ( VisualStudioVersion ) < / VSToolsPath > <nl> - < / PropertyGroup > <nl> - < Import Project = " $ ( VSToolsPath ) \ DNX \ Microsoft . DNX . Props " Condition = " ' $ ( VSToolsPath ) ' ! = ' ' " / > <nl> - < PropertyGroup Label = " Globals " > <nl> - < ProjectGuid > fe90181d - a4b3 - 4a5c - 8490 - f07561e18e3b < / ProjectGuid > <nl> - < RootNamespace > Grpc . Reflection . Tests < / RootNamespace > <nl> - < BaseIntermediateOutputPath Condition = " ' $ ( BaseIntermediateOutputPath ) ' = = ' ' " > . . \ artifacts \ obj \ $ ( MSBuildProjectName ) < / BaseIntermediateOutputPath > <nl> - < OutputPath Condition = " ' $ ( OutputPath ) ' = = ' ' " > . \ bin \ < / OutputPath > <nl> - < / PropertyGroup > <nl> - < PropertyGroup > <nl> - < SchemaVersion > 2 . 0 < / SchemaVersion > <nl> - < / PropertyGroup > <nl> - < Import Project = " $ ( VSToolsPath ) \ DNX \ Microsoft . DNX . targets " Condition = " ' $ ( VSToolsPath ) ' ! = ' ' " / > <nl> - < / Project > <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 8a7f7a0652a . . 00000000000 <nl> mmm a / src / csharp / Grpc . Reflection . Tests / packages . config <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < packages > <nl> - < package id = " Google . Protobuf " version = " 3 . 2 . 0 " targetFramework = " net45 " / > <nl> - < package id = " NUnit " version = " 3 . 6 . 0 " targetFramework = " net45 " / > <nl> - < package id = " NUnitLite " version = " 3 . 6 . 0 " targetFramework = " net45 " / > <nl> - < package id = " System . Interactive . Async " version = " 3 . 1 . 1 " targetFramework = " net45 " / > <nl> - < / packages > <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index fc05557c884 . . 00000000000 <nl> mmm a / src / csharp / Grpc . Reflection . Tests / project . json <nl> ppp / dev / null <nl> <nl> - { <nl> - " buildOptions " : { <nl> - " emitEntryPoint " : true <nl> - } , <nl> - " configurations " : { <nl> - " Debug " : { <nl> - " buildOptions " : { <nl> - " define " : [ " SIGNED " ] , <nl> - " keyFile " : " . . / keys / Grpc . snk " , <nl> - " xmlDoc " : true , <nl> - " compile " : { <nl> - " includeFiles " : [ " . . / Grpc . Core / Version . cs " ] <nl> - } , <nl> - " copyToOutput " : { <nl> - " mappings " : { <nl> - " grpc_csharp_ext . x64 . dll " : " . . / . . / . . / cmake / build / x64 / Debug / grpc_csharp_ext . dll " , <nl> - " grpc_csharp_ext . x86 . dll " : " . . / . . / . . / cmake / build / Win32 / Debug / grpc_csharp_ext . dll " , <nl> - " libgrpc_csharp_ext . x64 . so " : " . . / . . / . . / libs / dbg / libgrpc_csharp_ext . so " , <nl> - " libgrpc_csharp_ext . x64 . dylib " : " . . / . . / . . / libs / dbg / libgrpc_csharp_ext . dylib " <nl> - } <nl> - } <nl> - } <nl> - } , <nl> - " Release " : { <nl> - " buildOptions " : { <nl> - " define " : [ " SIGNED " ] , <nl> - " keyFile " : " . . / keys / Grpc . snk " , <nl> - " xmlDoc " : true , <nl> - " compile " : { <nl> - " includeFiles " : [ " . . / Grpc . Core / Version . cs " ] <nl> - } , <nl> - " copyToOutput " : { <nl> - " mappings " : { <nl> - " grpc_csharp_ext . x64 . dll " : " . . / . . / . . / cmake / build / x64 / Release / grpc_csharp_ext . dll " , <nl> - " grpc_csharp_ext . x86 . dll " : " . . / . . / . . / cmake / build / Win32 / Release / grpc_csharp_ext . dll " , <nl> - " libgrpc_csharp_ext . x64 . so " : " . . / . . / . . / libs / opt / libgrpc_csharp_ext . so " , <nl> - " libgrpc_csharp_ext . x64 . dylib " : " . . / . . / . . / libs / opt / libgrpc_csharp_ext . dylib " <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } , <nl> - <nl> - " dependencies " : { <nl> - " Grpc . Reflection " : { <nl> - " target " : " project " <nl> - } , <nl> - " NUnit " : " 3 . 6 . 0 " , <nl> - " NUnitLite " : " 3 . 6 . 0 " <nl> - } , <nl> - " frameworks " : { <nl> - " net45 " : { } , <nl> - " netcoreapp1 . 0 " : { <nl> - " imports " : [ <nl> - " portable - net45 " <nl> - ] , <nl> - " dependencies " : { <nl> - " Microsoft . NETCore . App " : { <nl> - " type " : " platform " , <nl> - " version " : " 1 . 0 . 0 " <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } <nl> old mode 100644 <nl> new mode 100755 <nl> index b0ab170e3f8 . . 70bfcc89c5c <nl> mmm a / src / csharp / Grpc . Reflection / Grpc . Reflection . csproj <nl> ppp b / src / csharp / Grpc . Reflection / Grpc . Reflection . csproj <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project ToolsVersion = " 4 . 0 " DefaultTargets = " Build " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> - < Import Project = " $ ( MSBuildExtensionsPath ) \ $ ( MSBuildToolsVersion ) \ Microsoft . Common . props " Condition = " Exists ( ' $ ( MSBuildExtensionsPath ) \ $ ( MSBuildToolsVersion ) \ Microsoft . Common . props ' ) " / > <nl> + < Project Sdk = " Microsoft . NET . Sdk " > <nl> + <nl> + < Import Project = " . . \ Grpc . Core \ Version . csproj . include " / > <nl> + < Import Project = " . . \ Grpc . Core \ Common . csproj . include " / > <nl> + <nl> < PropertyGroup > <nl> - < Configuration Condition = " ' $ ( Configuration ) ' = = ' ' " > Debug < / Configuration > <nl> - < Platform Condition = " ' $ ( Platform ) ' = = ' ' " > AnyCPU < / Platform > <nl> - < ProjectGuid > { 4F18CF52 - B3DB - 4A77 - 97C5 - 7F7F4B6C1715 } < / ProjectGuid > <nl> - < OutputType > Library < / OutputType > <nl> - < AppDesignerFolder > Properties < / AppDesignerFolder > <nl> - < RootNamespace > Grpc . Reflection < / RootNamespace > <nl> + < Copyright > Copyright 2016 , Google Inc . < / Copyright > <nl> + < AssemblyTitle > gRPC C # Reflection < / AssemblyTitle > <nl> + < VersionPrefix > $ ( GrpcCsharpVersion ) < / VersionPrefix > <nl> + < Authors > Google Inc . < / Authors > <nl> + < TargetFrameworks > net45 ; netstandard1 . 5 < / TargetFrameworks > <nl> < AssemblyName > Grpc . Reflection < / AssemblyName > <nl> - < TargetFrameworkVersion > v4 . 5 < / TargetFrameworkVersion > <nl> - < FileAlignment > 512 < / FileAlignment > <nl> - < DocumentationFile > bin \ $ ( Configuration ) \ Grpc . Reflection . Xml < / DocumentationFile > <nl> - < / PropertyGroup > <nl> - < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | AnyCPU ' " > <nl> - < DebugSymbols > true < / DebugSymbols > <nl> - < DebugType > full < / DebugType > <nl> - < Optimize > false < / Optimize > <nl> - < OutputPath > bin \ Debug \ < / OutputPath > <nl> - < ErrorReport > prompt < / ErrorReport > <nl> - < WarningLevel > 4 < / WarningLevel > <nl> - < / PropertyGroup > <nl> - < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Release | AnyCPU ' " > <nl> - < DebugType > pdbonly < / DebugType > <nl> - < Optimize > true < / Optimize > <nl> - < OutputPath > bin \ Release \ < / OutputPath > <nl> - < ErrorReport > prompt < / ErrorReport > <nl> - < WarningLevel > 4 < / WarningLevel > <nl> + < PackageId > Grpc . Reflection < / PackageId > <nl> + < PackageTags > gRPC reflection < / PackageTags > <nl> + < PackageProjectUrl > https : / / github . com / grpc / grpc < / PackageProjectUrl > <nl> + < PackageLicenseUrl > https : / / github . com / grpc / grpc / blob / master / LICENSE < / PackageLicenseUrl > <nl> + < NetStandardImplicitPackageVersion Condition = " ' $ ( TargetFramework ) ' = = ' netstandard1 . 5 ' " > 1 . 6 . 0 < / NetStandardImplicitPackageVersion > <nl> < / PropertyGroup > <nl> + <nl> < ItemGroup > <nl> - < Reference Include = " System " / > <nl> - < Reference Include = " System . Core " / > <nl> - < Reference Include = " System . Xml . Linq " / > <nl> - < Reference Include = " System . Data . DataSetExtensions " / > <nl> - < Reference Include = " Microsoft . CSharp " / > <nl> - < Reference Include = " System . Data " / > <nl> - < Reference Include = " System . Xml " / > <nl> - < Reference Include = " System . Interactive . Async " > <nl> - < HintPath > . . \ packages \ System . Interactive . Async . 3 . 1 . 1 \ lib \ net45 \ System . Interactive . Async . dll < / HintPath > <nl> - < / Reference > <nl> - < Reference Include = " Google . Protobuf " > <nl> - < HintPath > . . \ packages \ Google . Protobuf . 3 . 2 . 0 \ lib \ net45 \ Google . Protobuf . dll < / HintPath > <nl> - < / Reference > <nl> + < Compile Include = " . . \ Grpc . Core \ Version . cs " / > <nl> < / ItemGroup > <nl> + <nl> < ItemGroup > <nl> - < Compile Include = " . . \ Grpc . Core \ Version . cs " > <nl> - < Link > Version . cs < / Link > <nl> - < / Compile > <nl> - < Compile Include = " SymbolRegistry . cs " / > <nl> - < Compile Include = " ReflectionServiceImpl . cs " / > <nl> - < Compile Include = " Reflection . cs " / > <nl> - < Compile Include = " ReflectionGrpc . cs " / > <nl> - < Compile Include = " Properties \ AssemblyInfo . cs " / > <nl> + < ProjectReference Include = " . . / Grpc . Core / Grpc . Core . csproj " / > <nl> < / ItemGroup > <nl> + <nl> < ItemGroup > <nl> - < None Include = " Grpc . Reflection . project . json " / > <nl> - < None Include = " packages . config " / > <nl> + < PackageReference Include = " Google . Protobuf " Version = " $ ( GoogleProtobufVersion ) " / > <nl> < / ItemGroup > <nl> - < ItemGroup > <nl> - < ProjectReference Include = " . . \ Grpc . Core \ Grpc . Core . csproj " > <nl> - < Project > { CCC4440E - 49F7 - 4790 - B0AF - FEABB0837AE7 } < / Project > <nl> - < Name > Grpc . Core < / Name > <nl> - < / ProjectReference > <nl> + <nl> + < ItemGroup Condition = " ' $ ( TargetFramework ) ' = = ' net45 ' " > <nl> + < Reference Include = " System " / > <nl> + < Reference Include = " Microsoft . CSharp " / > <nl> < / ItemGroup > <nl> - < Import Project = " $ ( MSBuildToolsPath ) \ Microsoft . CSharp . targets " / > <nl> - < ! - - To modify your build process , add your task inside one of the targets below and uncomment it . <nl> - Other similar extension points exist , see Microsoft . Common . targets . <nl> - < Target Name = " BeforeBuild " > <nl> - < / Target > <nl> - < Target Name = " AfterBuild " > <nl> - < / Target > <nl> - - - > <nl> - < / Project > <nl> \ No newline at end of file <nl> + <nl> + < / Project > <nl> deleted file mode 100644 <nl> index c2f5bcb1637 . . 00000000000 <nl> mmm a / src / csharp / Grpc . Reflection / Grpc . Reflection . project . json <nl> ppp / dev / null <nl> <nl> - { <nl> - " frameworks " : { <nl> - " net45 " : { } <nl> - } , <nl> - " runtimes " : { <nl> - " win " : { } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index 833d98b1216 . . 00000000000 <nl> mmm a / src / csharp / Grpc . Reflection / Grpc . Reflection . xproj <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Project ToolsVersion = " 14 . 0 . 25123 " DefaultTargets = " Build " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> - < PropertyGroup > <nl> - < VisualStudioVersion Condition = " ' $ ( VisualStudioVersion ) ' = = ' ' " > 14 . 0 . 25123 < / VisualStudioVersion > <nl> - < VSToolsPath Condition = " ' $ ( VSToolsPath ) ' = = ' ' " > $ ( MSBuildExtensionsPath32 ) \ Microsoft \ VisualStudio \ v $ ( VisualStudioVersion ) < / VSToolsPath > <nl> - < / PropertyGroup > <nl> - < Import Project = " $ ( VSToolsPath ) \ DNX \ Microsoft . DNX . Props " Condition = " ' $ ( VSToolsPath ) ' ! = ' ' " / > <nl> - < PropertyGroup Label = " Globals " > <nl> - < ProjectGuid > 2b372155 - 80ba - 4cf9 - 82d6 - 4b938e8ec3a0 < / ProjectGuid > <nl> - < RootNamespace > Grpc . Reflection < / RootNamespace > <nl> - < BaseIntermediateOutputPath Condition = " ' $ ( BaseIntermediateOutputPath ) ' = = ' ' " > . . \ artifacts \ obj \ $ ( MSBuildProjectName ) < / BaseIntermediateOutputPath > <nl> - < OutputPath Condition = " ' $ ( OutputPath ) ' = = ' ' " > . \ bin \ < / OutputPath > <nl> - < / PropertyGroup > <nl> - < PropertyGroup > <nl> - < SchemaVersion > 2 . 0 < / SchemaVersion > <nl> - < / PropertyGroup > <nl> - < Import Project = " $ ( VSToolsPath ) \ DNX \ Microsoft . DNX . targets " Condition = " ' $ ( VSToolsPath ) ' ! = ' ' " / > <nl> - < / Project > <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index eec292b306d . . 00000000000 <nl> mmm a / src / csharp / Grpc . Reflection / packages . config <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < packages > <nl> - < package id = " Google . Protobuf " version = " 3 . 2 . 0 " targetFramework = " net45 " / > <nl> - < package id = " System . Interactive . Async " version = " 3 . 1 . 1 " targetFramework = " net45 " / > <nl> - < / packages > <nl> \ No newline at end of file <nl> mmm a / src / csharp / Grpc . sln <nl> ppp b / src / csharp / Grpc . sln <nl> <nl> - <nl> - Microsoft Visual Studio Solution File , Format Version 12 . 00 <nl> - # Visual Studio 2012 <nl> - VisualStudioVersion = 12 . 0 . 31101 . 0 <nl> - MinimumVisualStudioVersion = 10 . 0 . 40219 . 1 <nl> - Project ( " { FAE04EC0 - 301F - 11D3 - BF4B - 00C04F79EFBC } " ) = " Grpc . Examples " , " Grpc . Examples \ Grpc . Examples . csproj " , " { 7DC1433E - 3225 - 42C7 - B7EA - 546D56E27A4B } " <nl> - EndProject <nl> - Project ( " { FAE04EC0 - 301F - 11D3 - BF4B - 00C04F79EFBC } " ) = " Grpc . Core " , " Grpc . Core \ Grpc . Core . csproj " , " { CCC4440E - 49F7 - 4790 - B0AF - FEABB0837AE7 } " <nl> - EndProject <nl> - Project ( " { FAE04EC0 - 301F - 11D3 - BF4B - 00C04F79EFBC } " ) = " Grpc . Core . Tests " , " Grpc . Core . Tests \ Grpc . Core . Tests . csproj " , " { 86EC5CB4 - 4EA2 - 40A2 - 8057 - 86542A0353BB } " <nl> - EndProject <nl> - Project ( " { FAE04EC0 - 301F - 11D3 - BF4B - 00C04F79EFBC } " ) = " Grpc . Examples . Tests " , " Grpc . Examples . Tests \ Grpc . Examples . Tests . csproj " , " { 143B1C29 - C442 - 4BE0 - BF3F - A8F92288AC9F } " <nl> - EndProject <nl> - Project ( " { FAE04EC0 - 301F - 11D3 - BF4B - 00C04F79EFBC } " ) = " Grpc . Examples . MathClient " , " Grpc . Examples . MathClient \ Grpc . Examples . MathClient . csproj " , " { 61ECB8EE - 0C96 - 4F8E - B187 - 8E4D227417C0 } " <nl> - EndProject <nl> - Project ( " { FAE04EC0 - 301F - 11D3 - BF4B - 00C04F79EFBC } " ) = " Grpc . IntegrationTesting " , " Grpc . IntegrationTesting \ Grpc . IntegrationTesting . csproj " , " { C61154BA - DD4A - 4838 - 8420 - 0162A28925E0 } " <nl> - EndProject <nl> - Project ( " { FAE04EC0 - 301F - 11D3 - BF4B - 00C04F79EFBC } " ) = " Grpc . IntegrationTesting . Client " , " Grpc . IntegrationTesting . Client \ Grpc . IntegrationTesting . Client . csproj " , " { 3D166931 - BA2D - 416E - 95A3 - D36E8F6E90B9 } " <nl> - EndProject <nl> - Project ( " { FAE04EC0 - 301F - 11D3 - BF4B - 00C04F79EFBC } " ) = " Grpc . IntegrationTesting . Server " , " Grpc . IntegrationTesting . Server \ Grpc . IntegrationTesting . Server . csproj " , " { A654F3B8 - E859 - 4E6A - B30D - 227527DBEF0D } " <nl> - EndProject <nl> - Project ( " { FAE04EC0 - 301F - 11D3 - BF4B - 00C04F79EFBC } " ) = " Grpc . Examples . MathServer " , " Grpc . Examples . MathServer \ Grpc . Examples . MathServer . csproj " , " { BF62FE08 - 373A - 43D6 - 9D73 - 41CAA38B7011 } " <nl> - EndProject <nl> - Project ( " { FAE04EC0 - 301F - 11D3 - BF4B - 00C04F79EFBC } " ) = " Grpc . Auth " , " Grpc . Auth \ Grpc . Auth . csproj " , " { AE21D0EE - 9A2C - 4C15 - AB7F - 5224EED5B0EA } " <nl> - EndProject <nl> - Project ( " { 2150E333 - 8FDC - 42A3 - 9474 - 1A3956D46DE8 } " ) = " . nuget " , " . nuget " , " { B5B87121 - 35FE - 49D1 - 8CB1 - 8A91AAA398A9 } " <nl> - ProjectSection ( SolutionItems ) = preProject <nl> - . nuget \ packages . config = . nuget \ packages . config <nl> - EndProjectSection <nl> - EndProject <nl> - Project ( " { FAE04EC0 - 301F - 11D3 - BF4B - 00C04F79EFBC } " ) = " Grpc . HealthCheck " , " Grpc . HealthCheck \ Grpc . HealthCheck . csproj " , " { AA5E328A - 8835 - 49D7 - 98ED - C29F2B3049F0 } " <nl> - EndProject <nl> - Project ( " { FAE04EC0 - 301F - 11D3 - BF4B - 00C04F79EFBC } " ) = " Grpc . HealthCheck . Tests " , " Grpc . HealthCheck . Tests \ Grpc . HealthCheck . Tests . csproj " , " { F8C6D937 - C44B - 4EE3 - A431 - B0FBAEACE47D } " <nl> - EndProject <nl> - Project ( " { FAE04EC0 - 301F - 11D3 - BF4B - 00C04F79EFBC } " ) = " Grpc . IntegrationTesting . QpsWorker " , " Grpc . IntegrationTesting . QpsWorker \ Grpc . IntegrationTesting . QpsWorker . csproj " , " { B82B7DFE - 7F7B - 40EF - B3D6 - 064FF2B01294 } " <nl> - EndProject <nl> - Project ( " { FAE04EC0 - 301F - 11D3 - BF4B - 00C04F79EFBC } " ) = " Grpc . IntegrationTesting . StressClient " , " Grpc . IntegrationTesting . StressClient \ Grpc . IntegrationTesting . StressClient . csproj " , " { ADEBA147 - 80AE - 4710 - 82E9 - 5B7F93690266 } " <nl> - EndProject <nl> - Project ( " { FAE04EC0 - 301F - 11D3 - BF4B - 00C04F79EFBC } " ) = " Grpc . Reflection " , " Grpc . Reflection \ Grpc . Reflection . csproj " , " { 4F18CF52 - B3DB - 4A77 - 97C5 - 7F7F4B6C1715 } " <nl> - EndProject <nl> - Project ( " { FAE04EC0 - 301F - 11D3 - BF4B - 00C04F79EFBC } " ) = " Grpc . Reflection . Tests " , " Grpc . Reflection . Tests \ Grpc . Reflection . Tests . csproj " , " { B88F91D6 - 436D - 4C78 - 8B99 - 47800FA8DE03 } " <nl> - EndProject <nl> - Project ( " { FAE04EC0 - 301F - 11D3 - BF4B - 00C04F79EFBC } " ) = " Grpc . Core . Testing " , " Grpc . Core . Testing \ Grpc . Core . Testing . csproj " , " { 3AB047CA - 6CF9 - 435D - AA61 - 2D86C6FA2457 } " <nl> - EndProject <nl> - Global <nl> - GlobalSection ( SolutionConfigurationPlatforms ) = preSolution <nl> - Debug | Any CPU = Debug | Any CPU <nl> - Release | Any CPU = Release | Any CPU <nl> - EndGlobalSection <nl> - GlobalSection ( ProjectConfigurationPlatforms ) = postSolution <nl> - { 143B1C29 - C442 - 4BE0 - BF3F - A8F92288AC9F } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> - { 143B1C29 - C442 - 4BE0 - BF3F - A8F92288AC9F } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> - { 143B1C29 - C442 - 4BE0 - BF3F - A8F92288AC9F } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> - { 143B1C29 - C442 - 4BE0 - BF3F - A8F92288AC9F } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> - { 3D166931 - BA2D - 416E - 95A3 - D36E8F6E90B9 } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> - { 3D166931 - BA2D - 416E - 95A3 - D36E8F6E90B9 } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> - { 3D166931 - BA2D - 416E - 95A3 - D36E8F6E90B9 } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> - { 3D166931 - BA2D - 416E - 95A3 - D36E8F6E90B9 } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> - { 4F18CF52 - B3DB - 4A77 - 97C5 - 7F7F4B6C1715 } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> - { 4F18CF52 - B3DB - 4A77 - 97C5 - 7F7F4B6C1715 } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> - { 4F18CF52 - B3DB - 4A77 - 97C5 - 7F7F4B6C1715 } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> - { 4F18CF52 - B3DB - 4A77 - 97C5 - 7F7F4B6C1715 } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> - { 61ECB8EE - 0C96 - 4F8E - B187 - 8E4D227417C0 } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> - { 61ECB8EE - 0C96 - 4F8E - B187 - 8E4D227417C0 } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> - { 61ECB8EE - 0C96 - 4F8E - B187 - 8E4D227417C0 } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> - { 61ECB8EE - 0C96 - 4F8E - B187 - 8E4D227417C0 } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> - { 7DC1433E - 3225 - 42C7 - B7EA - 546D56E27A4B } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> - { 7DC1433E - 3225 - 42C7 - B7EA - 546D56E27A4B } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> - { 7DC1433E - 3225 - 42C7 - B7EA - 546D56E27A4B } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> - { 7DC1433E - 3225 - 42C7 - B7EA - 546D56E27A4B } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> - { 86EC5CB4 - 4EA2 - 40A2 - 8057 - 86542A0353BB } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> - { 86EC5CB4 - 4EA2 - 40A2 - 8057 - 86542A0353BB } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> - { 86EC5CB4 - 4EA2 - 40A2 - 8057 - 86542A0353BB } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> - { 86EC5CB4 - 4EA2 - 40A2 - 8057 - 86542A0353BB } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> - { A654F3B8 - E859 - 4E6A - B30D - 227527DBEF0D } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> - { A654F3B8 - E859 - 4E6A - B30D - 227527DBEF0D } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> - { A654F3B8 - E859 - 4E6A - B30D - 227527DBEF0D } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> - { A654F3B8 - E859 - 4E6A - B30D - 227527DBEF0D } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> - { AA5E328A - 8835 - 49D7 - 98ED - C29F2B3049F0 } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> - { AA5E328A - 8835 - 49D7 - 98ED - C29F2B3049F0 } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> - { AA5E328A - 8835 - 49D7 - 98ED - C29F2B3049F0 } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> - { AA5E328A - 8835 - 49D7 - 98ED - C29F2B3049F0 } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> - { ADEBA147 - 80AE - 4710 - 82E9 - 5B7F93690266 } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> - { ADEBA147 - 80AE - 4710 - 82E9 - 5B7F93690266 } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> - { ADEBA147 - 80AE - 4710 - 82E9 - 5B7F93690266 } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> - { ADEBA147 - 80AE - 4710 - 82E9 - 5B7F93690266 } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> - { AE21D0EE - 9A2C - 4C15 - AB7F - 5224EED5B0EA } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> - { AE21D0EE - 9A2C - 4C15 - AB7F - 5224EED5B0EA } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> - { AE21D0EE - 9A2C - 4C15 - AB7F - 5224EED5B0EA } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> - { AE21D0EE - 9A2C - 4C15 - AB7F - 5224EED5B0EA } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> - { B82B7DFE - 7F7B - 40EF - B3D6 - 064FF2B01294 } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> - { B82B7DFE - 7F7B - 40EF - B3D6 - 064FF2B01294 } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> - { B82B7DFE - 7F7B - 40EF - B3D6 - 064FF2B01294 } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> - { B82B7DFE - 7F7B - 40EF - B3D6 - 064FF2B01294 } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> - { B88F91D6 - 436D - 4C78 - 8B99 - 47800FA8DE03 } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> - { B88F91D6 - 436D - 4C78 - 8B99 - 47800FA8DE03 } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> - { B88F91D6 - 436D - 4C78 - 8B99 - 47800FA8DE03 } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> - { B88F91D6 - 436D - 4C78 - 8B99 - 47800FA8DE03 } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> - { BF62FE08 - 373A - 43D6 - 9D73 - 41CAA38B7011 } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> - { BF62FE08 - 373A - 43D6 - 9D73 - 41CAA38B7011 } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> - { BF62FE08 - 373A - 43D6 - 9D73 - 41CAA38B7011 } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> - { BF62FE08 - 373A - 43D6 - 9D73 - 41CAA38B7011 } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> - { C61154BA - DD4A - 4838 - 8420 - 0162A28925E0 } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> - { C61154BA - DD4A - 4838 - 8420 - 0162A28925E0 } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> - { C61154BA - DD4A - 4838 - 8420 - 0162A28925E0 } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> - { C61154BA - DD4A - 4838 - 8420 - 0162A28925E0 } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> - { CCC4440E - 49F7 - 4790 - B0AF - FEABB0837AE7 } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> - { CCC4440E - 49F7 - 4790 - B0AF - FEABB0837AE7 } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> - { CCC4440E - 49F7 - 4790 - B0AF - FEABB0837AE7 } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> - { CCC4440E - 49F7 - 4790 - B0AF - FEABB0837AE7 } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> - { F8C6D937 - C44B - 4EE3 - A431 - B0FBAEACE47D } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> - { F8C6D937 - C44B - 4EE3 - A431 - B0FBAEACE47D } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> - { F8C6D937 - C44B - 4EE3 - A431 - B0FBAEACE47D } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> - { F8C6D937 - C44B - 4EE3 - A431 - B0FBAEACE47D } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> - { 3AB047CA - 6CF9 - 435D - AA61 - 2D86C6FA2457 } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> - { 3AB047CA - 6CF9 - 435D - AA61 - 2D86C6FA2457 } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> - { 3AB047CA - 6CF9 - 435D - AA61 - 2D86C6FA2457 } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> - { 3AB047CA - 6CF9 - 435D - AA61 - 2D86C6FA2457 } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> - EndGlobalSection <nl> - GlobalSection ( NestedProjects ) = preSolution <nl> - EndGlobalSection <nl> - GlobalSection ( SolutionProperties ) = preSolution <nl> - HideSolutionNode = FALSE <nl> - EndGlobalSection <nl> - EndGlobal <nl> + <nl> + Microsoft Visual Studio Solution File , Format Version 12 . 00 <nl> + # Visual Studio 15 <nl> + VisualStudioVersion = 15 . 0 . 26228 . 4 <nl> + MinimumVisualStudioVersion = 10 . 0 . 40219 . 1 <nl> + Project ( " { 9A19103F - 16F7 - 4668 - BE54 - 9A1E7A4F7556 } " ) = " Grpc . Core " , " Grpc . Core \ Grpc . Core . csproj " , " { BD878CB3 - BDB4 - 46AB - 84EF - C3B4729F56BC } " <nl> + EndProject <nl> + Project ( " { 9A19103F - 16F7 - 4668 - BE54 - 9A1E7A4F7556 } " ) = " Grpc . Auth " , " Grpc . Auth \ Grpc . Auth . csproj " , " { 2A16007A - 5D67 - 4C53 - BEC8 - 51E5064D18BF } " <nl> + EndProject <nl> + Project ( " { 9A19103F - 16F7 - 4668 - BE54 - 9A1E7A4F7556 } " ) = " Grpc . Core . Testing " , " Grpc . Core . Testing \ Grpc . Core . Testing . csproj " , " { 05DC61DF - 26F3 - 4F51 - 8577 - 1ABE4F4388B0 } " <nl> + EndProject <nl> + Project ( " { 9A19103F - 16F7 - 4668 - BE54 - 9A1E7A4F7556 } " ) = " Grpc . Core . Tests " , " Grpc . Core . Tests \ Grpc . Core . Tests . csproj " , " { 02C79983 - 6011 - 43E2 - A52D - 75F9FC64663F } " <nl> + EndProject <nl> + Project ( " { 9A19103F - 16F7 - 4668 - BE54 - 9A1E7A4F7556 } " ) = " Grpc . Examples " , " Grpc . Examples \ Grpc . Examples . csproj " , " { C643975D - 5D26 - 4860 - 8002 - 3B62A132DA2B } " <nl> + EndProject <nl> + Project ( " { 9A19103F - 16F7 - 4668 - BE54 - 9A1E7A4F7556 } " ) = " Grpc . Examples . MathClient " , " Grpc . Examples . MathClient \ Grpc . Examples . MathClient . csproj " , " { 1F498972 - FD16 - 4A02 - B133 - C24652F14869 } " <nl> + EndProject <nl> + Project ( " { 9A19103F - 16F7 - 4668 - BE54 - 9A1E7A4F7556 } " ) = " Grpc . Examples . MathServer " , " Grpc . Examples . MathServer \ Grpc . Examples . MathServer . csproj " , " { 9F2A873E - 83E0 - 44C4 - 81D0 - DDBC1D36F8B0 } " <nl> + EndProject <nl> + Project ( " { 9A19103F - 16F7 - 4668 - BE54 - 9A1E7A4F7556 } " ) = " Grpc . Examples . Tests " , " Grpc . Examples . Tests \ Grpc . Examples . Tests . csproj " , " { 7022461C - 0D5E - 4817 - 9A5A - 3C027FD22457 } " <nl> + EndProject <nl> + Project ( " { 9A19103F - 16F7 - 4668 - BE54 - 9A1E7A4F7556 } " ) = " Grpc . HealthCheck " , " Grpc . HealthCheck \ Grpc . HealthCheck . csproj " , " { DBD57899 - 0148 - 4B0D - A8EA - DE3954FA657C } " <nl> + EndProject <nl> + Project ( " { 9A19103F - 16F7 - 4668 - BE54 - 9A1E7A4F7556 } " ) = " Grpc . HealthCheck . Tests " , " Grpc . HealthCheck . Tests \ Grpc . HealthCheck . Tests . csproj " , " { 033E4DC1 - 5D79 - 4308 - B8B1 - 9A1B71E39BA1 } " <nl> + EndProject <nl> + Project ( " { 9A19103F - 16F7 - 4668 - BE54 - 9A1E7A4F7556 } " ) = " Grpc . IntegrationTesting " , " Grpc . IntegrationTesting \ Grpc . IntegrationTesting . csproj " , " { CB43BF5B - 4D31 - 4347 - A97A - 0164B1248B39 } " <nl> + EndProject <nl> + Project ( " { 9A19103F - 16F7 - 4668 - BE54 - 9A1E7A4F7556 } " ) = " Grpc . IntegrationTesting . Client " , " Grpc . IntegrationTesting . Client \ Grpc . IntegrationTesting . Client . csproj " , " { 83CCB684 - 54E6 - 4552 - A00D - 3CF9291A1B27 } " <nl> + EndProject <nl> + Project ( " { 9A19103F - 16F7 - 4668 - BE54 - 9A1E7A4F7556 } " ) = " Grpc . IntegrationTesting . QpsWorker " , " Grpc . IntegrationTesting . QpsWorker \ Grpc . IntegrationTesting . QpsWorker . csproj " , " { 8ED094CD - DF46 - 4272 - A981 - 99F3DD184590 } " <nl> + EndProject <nl> + Project ( " { 9A19103F - 16F7 - 4668 - BE54 - 9A1E7A4F7556 } " ) = " Grpc . IntegrationTesting . Server " , " Grpc . IntegrationTesting . Server \ Grpc . IntegrationTesting . Server . csproj " , " { F3A264BE - A62F - 4B6A - 89A0 - 7CF7BB275460 } " <nl> + EndProject <nl> + Project ( " { 9A19103F - 16F7 - 4668 - BE54 - 9A1E7A4F7556 } " ) = " Grpc . IntegrationTesting . StressClient " , " Grpc . IntegrationTesting . StressClient \ Grpc . IntegrationTesting . StressClient . csproj " , " { 0BB94A8B - 9CE3 - 4A87 - 95BC - 90F8A53CC154 } " <nl> + EndProject <nl> + Project ( " { 9A19103F - 16F7 - 4668 - BE54 - 9A1E7A4F7556 } " ) = " Grpc . Reflection " , " Grpc . Reflection \ Grpc . Reflection . csproj " , " { 26807744 - FD0B - 494A - 9F99 - 0B171E9A892E } " <nl> + EndProject <nl> + Project ( " { 9A19103F - 16F7 - 4668 - BE54 - 9A1E7A4F7556 } " ) = " Grpc . Reflection . Tests " , " Grpc . Reflection . Tests \ Grpc . Reflection . Tests . csproj " , " { 335AD0A2 - F2CC - 4C2E - 853C - 26174206BEE7 } " <nl> + EndProject <nl> + Global <nl> + GlobalSection ( SolutionConfigurationPlatforms ) = preSolution <nl> + Debug | Any CPU = Debug | Any CPU <nl> + Release | Any CPU = Release | Any CPU <nl> + EndGlobalSection <nl> + GlobalSection ( ProjectConfigurationPlatforms ) = postSolution <nl> + { BD878CB3 - BDB4 - 46AB - 84EF - C3B4729F56BC } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> + { BD878CB3 - BDB4 - 46AB - 84EF - C3B4729F56BC } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> + { BD878CB3 - BDB4 - 46AB - 84EF - C3B4729F56BC } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> + { BD878CB3 - BDB4 - 46AB - 84EF - C3B4729F56BC } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> + { 2A16007A - 5D67 - 4C53 - BEC8 - 51E5064D18BF } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> + { 2A16007A - 5D67 - 4C53 - BEC8 - 51E5064D18BF } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> + { 2A16007A - 5D67 - 4C53 - BEC8 - 51E5064D18BF } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> + { 2A16007A - 5D67 - 4C53 - BEC8 - 51E5064D18BF } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> + { 05DC61DF - 26F3 - 4F51 - 8577 - 1ABE4F4388B0 } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> + { 05DC61DF - 26F3 - 4F51 - 8577 - 1ABE4F4388B0 } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> + { 05DC61DF - 26F3 - 4F51 - 8577 - 1ABE4F4388B0 } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> + { 05DC61DF - 26F3 - 4F51 - 8577 - 1ABE4F4388B0 } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> + { 02C79983 - 6011 - 43E2 - A52D - 75F9FC64663F } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> + { 02C79983 - 6011 - 43E2 - A52D - 75F9FC64663F } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> + { 02C79983 - 6011 - 43E2 - A52D - 75F9FC64663F } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> + { 02C79983 - 6011 - 43E2 - A52D - 75F9FC64663F } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> + { C643975D - 5D26 - 4860 - 8002 - 3B62A132DA2B } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> + { C643975D - 5D26 - 4860 - 8002 - 3B62A132DA2B } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> + { C643975D - 5D26 - 4860 - 8002 - 3B62A132DA2B } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> + { C643975D - 5D26 - 4860 - 8002 - 3B62A132DA2B } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> + { 1F498972 - FD16 - 4A02 - B133 - C24652F14869 } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> + { 1F498972 - FD16 - 4A02 - B133 - C24652F14869 } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> + { 1F498972 - FD16 - 4A02 - B133 - C24652F14869 } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> + { 1F498972 - FD16 - 4A02 - B133 - C24652F14869 } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> + { 9F2A873E - 83E0 - 44C4 - 81D0 - DDBC1D36F8B0 } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> + { 9F2A873E - 83E0 - 44C4 - 81D0 - DDBC1D36F8B0 } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> + { 9F2A873E - 83E0 - 44C4 - 81D0 - DDBC1D36F8B0 } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> + { 9F2A873E - 83E0 - 44C4 - 81D0 - DDBC1D36F8B0 } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> + { 7022461C - 0D5E - 4817 - 9A5A - 3C027FD22457 } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> + { 7022461C - 0D5E - 4817 - 9A5A - 3C027FD22457 } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> + { 7022461C - 0D5E - 4817 - 9A5A - 3C027FD22457 } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> + { 7022461C - 0D5E - 4817 - 9A5A - 3C027FD22457 } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> + { DBD57899 - 0148 - 4B0D - A8EA - DE3954FA657C } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> + { DBD57899 - 0148 - 4B0D - A8EA - DE3954FA657C } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> + { DBD57899 - 0148 - 4B0D - A8EA - DE3954FA657C } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> + { DBD57899 - 0148 - 4B0D - A8EA - DE3954FA657C } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> + { 033E4DC1 - 5D79 - 4308 - B8B1 - 9A1B71E39BA1 } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> + { 033E4DC1 - 5D79 - 4308 - B8B1 - 9A1B71E39BA1 } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> + { 033E4DC1 - 5D79 - 4308 - B8B1 - 9A1B71E39BA1 } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> + { 033E4DC1 - 5D79 - 4308 - B8B1 - 9A1B71E39BA1 } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> + { CB43BF5B - 4D31 - 4347 - A97A - 0164B1248B39 } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> + { CB43BF5B - 4D31 - 4347 - A97A - 0164B1248B39 } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> + { CB43BF5B - 4D31 - 4347 - A97A - 0164B1248B39 } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> + { CB43BF5B - 4D31 - 4347 - A97A - 0164B1248B39 } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> + { 83CCB684 - 54E6 - 4552 - A00D - 3CF9291A1B27 } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> + { 83CCB684 - 54E6 - 4552 - A00D - 3CF9291A1B27 } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> + { 83CCB684 - 54E6 - 4552 - A00D - 3CF9291A1B27 } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> + { 83CCB684 - 54E6 - 4552 - A00D - 3CF9291A1B27 } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> + { 8ED094CD - DF46 - 4272 - A981 - 99F3DD184590 } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> + { 8ED094CD - DF46 - 4272 - A981 - 99F3DD184590 } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> + { 8ED094CD - DF46 - 4272 - A981 - 99F3DD184590 } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> + { 8ED094CD - DF46 - 4272 - A981 - 99F3DD184590 } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> + { F3A264BE - A62F - 4B6A - 89A0 - 7CF7BB275460 } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> + { F3A264BE - A62F - 4B6A - 89A0 - 7CF7BB275460 } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> + { F3A264BE - A62F - 4B6A - 89A0 - 7CF7BB275460 } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> + { F3A264BE - A62F - 4B6A - 89A0 - 7CF7BB275460 } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> + { 0BB94A8B - 9CE3 - 4A87 - 95BC - 90F8A53CC154 } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> + { 0BB94A8B - 9CE3 - 4A87 - 95BC - 90F8A53CC154 } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> + { 0BB94A8B - 9CE3 - 4A87 - 95BC - 90F8A53CC154 } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> + { 0BB94A8B - 9CE3 - 4A87 - 95BC - 90F8A53CC154 } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> + { 26807744 - FD0B - 494A - 9F99 - 0B171E9A892E } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> + { 26807744 - FD0B - 494A - 9F99 - 0B171E9A892E } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> + { 26807744 - FD0B - 494A - 9F99 - 0B171E9A892E } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> + { 26807744 - FD0B - 494A - 9F99 - 0B171E9A892E } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> + { 335AD0A2 - F2CC - 4C2E - 853C - 26174206BEE7 } . Debug | Any CPU . ActiveCfg = Debug | Any CPU <nl> + { 335AD0A2 - F2CC - 4C2E - 853C - 26174206BEE7 } . Debug | Any CPU . Build . 0 = Debug | Any CPU <nl> + { 335AD0A2 - F2CC - 4C2E - 853C - 26174206BEE7 } . Release | Any CPU . ActiveCfg = Release | Any CPU <nl> + { 335AD0A2 - F2CC - 4C2E - 853C - 26174206BEE7 } . Release | Any CPU . Build . 0 = Release | Any CPU <nl> + EndGlobalSection <nl> + GlobalSection ( SolutionProperties ) = preSolution <nl> + HideSolutionNode = FALSE <nl> + EndGlobalSection <nl> + EndGlobal <nl> mmm a / src / csharp / README . md <nl> ppp b / src / csharp / README . md <nl> PREREQUISITES <nl> <nl> When using gRPC C # under . NET Core you only need to [ install . NET Core ] ( https : / / www . microsoft . com / net / core ) . <nl> <nl> - - Windows : . NET Framework 4 . 5 + , Visual Studio 2013 or 2015 <nl> + - Windows : . NET Framework 4 . 5 + , Visual Studio 2013 , 2015 , 2017 <nl> - Linux : Mono 4 + , MonoDevelop 5 . 9 + ( with NuGet add - in installed ) <nl> - Mac OS X : Xamarin Studio 5 . 9 + <nl> <nl> If you are a user of gRPC C # , go to Usage section above . <nl> $ python tools / run_tests / run_tests . py - c dbg - l csharp - - build_only <nl> ` ` ` <nl> <nl> - - Use Visual Studio / MonoDevelop / Xamarin Studio to open the solution Grpc . sln <nl> + - Use Visual Studio 2017 ( on Windows ) to open the solution ` Grpc . sln ` or use Visual Studio Code with C # extension ( on Linux and Mac ) . gRPC C # code has been migrated to <nl> + dotnet SDK ` . csproj ` projects that are much simpler to maintain , but are not yet supported by Xamarin Studio or Monodevelop ( the NuGet packages still <nl> + support both ` net45 ` and ` netstandard ` and can be used in all IDEs ) . <nl> <nl> RUNNING TESTS <nl> mmmmmmmmmmmm - <nl> gRPC C # is using NUnit as the testing framework . <nl> Under Visual Studio , make sure NUnit test adapter is installed ( under " Extensions and Updates " ) . <nl> Then you should be able to run all the tests using Test Explorer . <nl> <nl> - Under Monodevelop or Xamarin Studio , make sure you installed " NUnit support " in Add - in manager . <nl> - Then you should be able to run all the test from the Test View . <nl> - <nl> gRPC team uses a Python script to simplify facilitate running tests for <nl> different languages . <nl> <nl> mmm a / src / csharp / build_packages_dotnetcli . bat <nl> ppp b / src / csharp / build_packages_dotnetcli . bat <nl> <nl> <nl> @ rem Current package versions <nl> set VERSION = 1 . 3 . 0 - dev <nl> - set PROTOBUF_VERSION = 3 . 0 . 0 <nl> <nl> @ rem Adjust the location of nuget . exe <nl> set NUGET = C : \ nuget \ nuget . exe <nl> - set DOTNET = C : \ dotnet \ dotnet . exe <nl> + set DOTNET = dotnet <nl> <nl> set - ex <nl> <nl> xcopy / Y / I . . \ . . \ architecture = x64 , language = protoc , platform = linux \ artifacts \ * pr <nl> xcopy / Y / I . . \ . . \ architecture = x86 , language = protoc , platform = macos \ artifacts \ * protoc_plugins \ macosx_x86 \ <nl> xcopy / Y / I . . \ . . \ architecture = x64 , language = protoc , platform = macos \ artifacts \ * protoc_plugins \ macosx_x64 \ <nl> <nl> - % DOTNET % restore . | | goto : error <nl> + % DOTNET % restore Grpc . sln | | goto : error <nl> <nl> - % DOTNET % pack - - configuration Release Grpc . Core \ project . json - - output . . \ . . \ artifacts | | goto : error <nl> - % DOTNET % pack - - configuration Release Grpc . Core . Testing \ project . json - - output . . \ . . \ artifacts | | goto : error <nl> - % DOTNET % pack - - configuration Release Grpc . Auth \ project . json - - output . . \ . . \ artifacts | | goto : error <nl> - % DOTNET % pack - - configuration Release Grpc . HealthCheck \ project . json - - output . . \ . . \ artifacts | | goto : error <nl> - % DOTNET % pack - - configuration Release Grpc . Reflection \ project . json - - output . . \ . . \ artifacts | | goto : error <nl> + @ rem To be able to build , we also need to put grpc_csharp_ext to its normal location <nl> + xcopy / Y / I nativelibs \ windows_x64 \ grpc_csharp_ext . dll . . \ . . \ cmake \ build \ x64 \ Release \ <nl> + <nl> + % DOTNET % pack - - configuration Release Grpc . Core - - output . . \ . . \ . . \ artifacts | | goto : error <nl> + % DOTNET % pack - - configuration Release Grpc . Core . Testing - - output . . \ . . \ . . \ artifacts | | goto : error <nl> + % DOTNET % pack - - configuration Release Grpc . Auth - - output . . \ . . \ . . \ artifacts | | goto : error <nl> + % DOTNET % pack - - configuration Release Grpc . HealthCheck - - output . . \ . . \ . . \ artifacts | | goto : error <nl> + % DOTNET % pack - - configuration Release Grpc . Reflection - - output . . \ . . \ . . \ artifacts | | goto : error <nl> <nl> % NUGET % pack Grpc . nuspec - Version % VERSION % - OutputDirectory . . \ . . \ artifacts | | goto : error <nl> % NUGET % pack Grpc . Tools . nuspec - Version % VERSION % - OutputDirectory . . \ . . \ artifacts <nl> mmm a / src / csharp / build_packages_dotnetcli . sh <nl> ppp b / src / csharp / build_packages_dotnetcli . sh <nl> cp $ EXTERNAL_GIT_ROOT / architecture = x64 , language = protoc , platform = linux / artifacts / <nl> cp $ EXTERNAL_GIT_ROOT / architecture = x86 , language = protoc , platform = macos / artifacts / * protoc_plugins / macosx_x86 | | true <nl> cp $ EXTERNAL_GIT_ROOT / architecture = x64 , language = protoc , platform = macos / artifacts / * protoc_plugins / macosx_x64 | | true <nl> <nl> - dotnet restore . <nl> + dotnet restore Grpc . sln <nl> <nl> - dotnet pack - - configuration Release Grpc . Core / project . json - - output . . / . . / artifacts <nl> - dotnet pack - - configuration Release Grpc . Core . Testing / project . json - - output . . / . . / artifacts <nl> - dotnet pack - - configuration Release Grpc . Auth / project . json - - output . . / . . / artifacts <nl> - dotnet pack - - configuration Release Grpc . HealthCheck / project . json - - output . . / . . / artifacts <nl> - dotnet pack - - configuration Release Grpc . Reflection / project . json - - output . . / . . / artifacts <nl> + # To be able to build , we also need to put grpc_csharp_ext to its normal location <nl> + mkdir - p . . / . . / libs / opt <nl> + cp nativelibs / linux_x64 / libgrpc_csharp_ext . so . . / . . / libs / opt <nl> + <nl> + dotnet pack - - configuration Release Grpc . Core - - output . . / . . / . . / artifacts <nl> + dotnet pack - - configuration Release Grpc . Core . Testing - - output . . / . . / . . / artifacts <nl> + dotnet pack - - configuration Release Grpc . Auth - - output . . / . . / . . / artifacts <nl> + dotnet pack - - configuration Release Grpc . HealthCheck - - output . . / . . / . . / artifacts <nl> + dotnet pack - - configuration Release Grpc . Reflection - - output . . / . . / . . / artifacts <nl> <nl> nuget pack Grpc . nuspec - Version " 1 . 3 . 0 - dev " - OutputDirectory . . / . . / artifacts <nl> nuget pack Grpc . Tools . nuspec - Version " 1 . 3 . 0 - dev " - OutputDirectory . . / . . / artifacts <nl> deleted file mode 100644 <nl> index 32ff399ef94 . . 00000000000 <nl> mmm a / src / csharp / global . json <nl> ppp / dev / null <nl> <nl> - { <nl> - " sdk " : { <nl> - " version " : " 1 . 0 . 0 - preview2 - 003121 " <nl> - } <nl> - } <nl> \ No newline at end of file <nl> mmm a / src / node / index . js <nl> ppp b / src / node / index . js <nl> var Metadata = require ( ' . / src / metadata . js ' ) ; <nl> <nl> var grpc = require ( ' . / src / grpc_extension ' ) ; <nl> <nl> + var protobuf_js_5_common = require ( ' . / src / protobuf_js_5_common ' ) ; <nl> + var protobuf_js_6_common = require ( ' . / src / protobuf_js_6_common ' ) ; <nl> + <nl> grpc . setDefaultRootsPem ( fs . readFileSync ( SSL_ROOTS_PATH , ' ascii ' ) ) ; <nl> <nl> / * * <nl> - * Load a gRPC object from an existing ProtoBuf . Reflect object . <nl> - * @ param { ProtoBuf . Reflect . Namespace } value The ProtoBuf object to load . <nl> - * @ param { Object = } options Options to apply to the loaded object <nl> + * Load a ProtoBuf . js object as a gRPC object . The options object can provide <nl> + * the following options : <nl> + * - binaryAsBase64 : deserialize bytes values as base64 strings instead of <nl> + * Buffers . Defaults to false <nl> + * - longsAsStrings : deserialize long values as strings instead of objects . <nl> + * Defaults to true <nl> + * - enumsAsStrings : deserialize enum values as strings instead of numbers . <nl> + * Defaults to true <nl> + * - deprecatedArgumentOrder : Use the beta method argument order for client <nl> + * methods , with optional arguments after the callback . Defaults to false . <nl> + * This option is only a temporary stopgap measure to smooth an API breakage . <nl> + * It is deprecated , and new code should not use it . <nl> + * - protobufjsVersion : Available values are 5 , 6 , and ' detect ' . 5 and 6 <nl> + * respectively indicate that an object from the corresponding version of <nl> + * ProtoBuf . js is provided in the value argument . If the option is ' detect ' , <nl> + * gRPC will guess what the version is based on the structure of the value . <nl> + * Defaults to ' detect ' . <nl> + * @ param { Object } value The ProtoBuf . js reflection object to load <nl> + * @ param { Object = } options Options to apply to the loaded file <nl> * @ return { Object < string , * > } The resulting gRPC object <nl> * / <nl> exports . loadObject = function loadObject ( value , options ) { <nl> - var result = { } ; <nl> - if ( value . className = = = ' Namespace ' ) { <nl> - _ . each ( value . children , function ( child ) { <nl> - result [ child . name ] = loadObject ( child , options ) ; <nl> - } ) ; <nl> - return result ; <nl> - } else if ( value . className = = = ' Service ' ) { <nl> - return client . makeProtobufClientConstructor ( value , options ) ; <nl> - } else if ( value . className = = = ' Message ' | | value . className = = = ' Enum ' ) { <nl> - return value . build ( ) ; <nl> + options = _ . defaults ( options , common . defaultGrpcOptions ) ; <nl> + options = _ . defaults ( options , { ' protobufjsVersion ' : ' detect ' } ) ; <nl> + var protobufjsVersion ; <nl> + if ( options . protobufjsVersion = = = ' detect ' ) { <nl> + if ( protobuf_js_6_common . isProbablyProtobufJs6 ( value ) ) { <nl> + protobufjsVersion = 6 ; <nl> + } else if ( protobuf_js_5_common . isProbablyProtobufJs5 ( value ) ) { <nl> + protobufjsVersion = 5 ; <nl> + } else { <nl> + var error_message = ' Could not detect ProtoBuf . js version . Please ' + <nl> + ' specify the version number with the " protobufjs_version " option ' ; <nl> + throw new Error ( error_message ) ; <nl> + } <nl> } else { <nl> - return value ; <nl> + protobufjsVersion = options . protobufjsVersion ; <nl> + } <nl> + switch ( protobufjsVersion ) { <nl> + case 6 : return protobuf_js_6_common . loadObject ( value , options ) ; <nl> + case 5 : <nl> + var deprecation_message = ' Calling grpc . loadObject with an object ' + <nl> + ' generated by ProtoBuf . js 5 is deprecated . Please upgrade to ' + <nl> + ' ProtoBuf . js 6 . ' ; <nl> + common . log ( grpc . logVerbosity . INFO , deprecation_message ) ; <nl> + return protobuf_js_5_common . loadObject ( value , options ) ; <nl> + default : <nl> + throw new Error ( ' Unrecognized protobufjsVersion ' , protobufjsVersion ) ; <nl> } <nl> } ; <nl> <nl> var loadObject = exports . loadObject ; <nl> <nl> + function applyProtoRoot ( filename , root ) { <nl> + if ( _ . isString ( filename ) ) { <nl> + return filename ; <nl> + } <nl> + filename . root = path . resolve ( filename . root ) + ' / ' ; <nl> + root . resolvePath = function ( originPath , importPath , alreadyNormalized ) { <nl> + return ProtoBuf . util . path . resolve ( filename . root , <nl> + importPath , <nl> + alreadyNormalized ) ; <nl> + } ; <nl> + return filename . file ; <nl> + } <nl> + <nl> / * * <nl> * Load a gRPC object from a . proto file . The options object can provide the <nl> * following options : <nl> - * - convertFieldsToCamelCase : Loads this file with that option on protobuf . js <nl> - * set as specified . See <nl> - * https : / / github . com / dcodeIO / protobuf . js / wiki / Advanced - options for details <nl> + * - convertFieldsToCamelCase : Load this file with field names in camel case <nl> + * instead of their original case <nl> * - binaryAsBase64 : deserialize bytes values as base64 strings instead of <nl> * Buffers . Defaults to false <nl> * - longsAsStrings : deserialize long values as strings instead of objects . <nl> * Defaults to true <nl> + * - enumsAsStrings : deserialize enum values as strings instead of numbers . <nl> + * Defaults to true <nl> * - deprecatedArgumentOrder : Use the beta method argument order for client <nl> * methods , with optional arguments after the callback . Defaults to false . <nl> * This option is only a temporary stopgap measure to smooth an API breakage . <nl> var loadObject = exports . loadObject ; <nl> * @ return { Object < string , * > } The resulting gRPC object <nl> * / <nl> exports . load = function load ( filename , format , options ) { <nl> - if ( ! format ) { <nl> - format = ' proto ' ; <nl> - } <nl> - var convertFieldsToCamelCaseOriginal = ProtoBuf . convertFieldsToCamelCase ; <nl> - if ( options & & options . hasOwnProperty ( ' convertFieldsToCamelCase ' ) ) { <nl> - ProtoBuf . convertFieldsToCamelCase = options . convertFieldsToCamelCase ; <nl> - } <nl> - var builder ; <nl> - try { <nl> - switch ( format ) { <nl> - case ' proto ' : <nl> - builder = ProtoBuf . loadProtoFile ( filename ) ; <nl> - break ; <nl> - case ' json ' : <nl> - builder = ProtoBuf . loadJsonFile ( filename ) ; <nl> - break ; <nl> - default : <nl> - throw new Error ( ' Unrecognized format " ' + format + ' " ' ) ; <nl> - } <nl> - } finally { <nl> - ProtoBuf . convertFieldsToCamelCase = convertFieldsToCamelCaseOriginal ; <nl> - } <nl> - return loadObject ( builder . ns , options ) ; <nl> + / * Note : format is currently unused , because the API for loading a proto <nl> + file or a JSON file is identical in Protobuf . js 6 . In the future , there is <nl> + still the possibility of adding other formats that would be loaded <nl> + differently * / <nl> + options = _ . defaults ( options , common . defaultGrpcOptions ) ; <nl> + options . protobufjs_version = 6 ; <nl> + var root = new ProtoBuf . Root ( ) ; <nl> + var parse_options = { keepCase : ! options . convertFieldsToCamelCase } ; <nl> + return loadObject ( root . loadSync ( applyProtoRoot ( filename , root ) , <nl> + parse_options ) , <nl> + options ) ; <nl> } ; <nl> <nl> var log_template = _ . template ( <nl> mmm a / src / node / interop / interop_server . js <nl> ppp b / src / node / interop / interop_server . js <nl> function getServer ( port , tls ) { <nl> server_creds = grpc . ServerCredentials . createInsecure ( ) ; <nl> } <nl> var server = new grpc . Server ( options ) ; <nl> - server . addProtoService ( testProto . TestService . service , { <nl> + server . addService ( testProto . TestService . service , { <nl> emptyCall : handleEmpty , <nl> unaryCall : handleUnary , <nl> streamingOutputCall : handleStreamingOutput , <nl> mmm a / src / node / performance / benchmark_client_express . js <nl> ppp b / src / node / performance / benchmark_client_express . js <nl> function BenchmarkClient ( server_targets , channels , histogram_params , <nl> <nl> for ( var i = 0 ; i < channels ; i + + ) { <nl> var host_port ; <nl> - host_port = server_targets [ i % server_targets . length ] . split ( ' : ' ) <nl> + host_port = server_targets [ i % server_targets . length ] . split ( ' : ' ) ; <nl> var new_options = _ . assign ( { hostname : host_port [ 0 ] , port : + host_port [ 1 ] } , options ) ; <nl> new_options . agent = new protocol . Agent ( new_options ) ; <nl> this . client_options [ i ] = new_options ; <nl> BenchmarkClient . prototype . startClosedLoop = function ( <nl> if ( self . running ) { <nl> self . pending_calls + + ; <nl> var start_time = process . hrtime ( ) ; <nl> + function finishCall ( success ) { <nl> + if ( success ) { <nl> + var time_diff = process . hrtime ( start_time ) ; <nl> + self . histogram . add ( timeDiffToNanos ( time_diff ) ) ; <nl> + } <nl> + makeCall ( client_options ) ; <nl> + self . pending_calls - - ; <nl> + if ( ( ! self . running ) & & self . pending_calls = = 0 ) { <nl> + self . emit ( ' finished ' ) ; <nl> + } <nl> + } <nl> var req = self . request ( client_options , function ( res ) { <nl> var res_data = ' ' ; <nl> res . on ( ' data ' , function ( data ) { <nl> BenchmarkClient . prototype . startClosedLoop = function ( <nl> } ) ; <nl> res . on ( ' end ' , function ( ) { <nl> JSON . parse ( res_data ) ; <nl> - var time_diff = process . hrtime ( start_time ) ; <nl> - self . histogram . add ( timeDiffToNanos ( time_diff ) ) ; <nl> - makeCall ( client_options ) ; <nl> - self . pending_calls - - ; <nl> - if ( ( ! self . running ) & & self . pending_calls = = 0 ) { <nl> - self . emit ( ' finished ' ) ; <nl> - } <nl> + finishCall ( true ) ; <nl> } ) ; <nl> } ) ; <nl> req . write ( JSON . stringify ( argument ) ) ; <nl> req . end ( ) ; <nl> req . on ( ' error ' , function ( error ) { <nl> + if ( error . code = = = ' ECONNRESET ' | | error . code = = = ' ETIMEDOUT ' ) { <nl> + finishCall ( false ) ; <nl> + return ; <nl> + } <nl> self . emit ( ' error ' , new Error ( ' Client error : ' + error . message ) ) ; <nl> self . running = false ; <nl> } ) ; <nl> mmm a / src / node / performance / benchmark_server . js <nl> ppp b / src / node / performance / benchmark_server . js <nl> function BenchmarkServer ( host , port , tls , generic , response_size ) { <nl> streamingCall : makeStreamingGenericCall ( response_size ) <nl> } ) ; <nl> } else { <nl> - server . addProtoService ( serviceProto . BenchmarkService . service , { <nl> + server . addService ( serviceProto . BenchmarkService . service , { <nl> unaryCall : unaryCall , <nl> streamingCall : streamingCall <nl> } ) ; <nl> mmm a / src / node / performance / benchmark_server_express . js <nl> ppp b / src / node / performance / benchmark_server_express . js <nl> var EventEmitter = require ( ' events ' ) ; <nl> var util = require ( ' util ' ) ; <nl> <nl> var express = require ( ' express ' ) ; <nl> - var bodyParser = require ( ' body - parser ' ) <nl> + var bodyParser = require ( ' body - parser ' ) ; <nl> <nl> function unaryCall ( req , res ) { <nl> var reqObj = req . body ; <nl> function unaryCall ( req , res ) { <nl> <nl> function BenchmarkServer ( host , port , tls , generic , response_size ) { <nl> var app = express ( ) ; <nl> - app . use ( bodyParser . json ( ) ) <nl> + app . use ( bodyParser . json ( ) ) ; <nl> app . put ( ' / serviceProto . BenchmarkService . service / unaryCall ' , unaryCall ) ; <nl> this . input_host = host ; <nl> this . input_port = port ; <nl> mmm a / src / node / performance / worker . js <nl> ppp b / src / node / performance / worker . js <nl> var serviceProto = grpc . load ( { <nl> function runServer ( port , benchmark_impl ) { <nl> var server_creds = grpc . ServerCredentials . createInsecure ( ) ; <nl> var server = new grpc . Server ( ) ; <nl> - server . addProtoService ( serviceProto . WorkerService . service , <nl> - new WorkerServiceImpl ( benchmark_impl , server ) ) ; <nl> + server . addService ( serviceProto . WorkerService . service , <nl> + new WorkerServiceImpl ( benchmark_impl , server ) ) ; <nl> var address = ' 0 . 0 . 0 . 0 : ' + port ; <nl> server . bind ( address , server_creds ) ; <nl> server . start ( ) ; <nl> mmm a / src / node / src / client . js <nl> ppp b / src / node / src / client . js <nl> exports . makeClientConstructor = function ( methods , serviceName , <nl> _ . assign ( Client . prototype [ name ] , attrs ) ; <nl> } ) ; <nl> <nl> + Client . service = methods ; <nl> + <nl> return Client ; <nl> } ; <nl> <nl> exports . waitForClientReady = function ( client , deadline , callback ) { <nl> checkState ( ) ; <nl> } ; <nl> <nl> - / * * <nl> - * Creates a constructor for clients for the given service <nl> - * @ param { ProtoBuf . Reflect . Service } service The service to generate a client <nl> - * for <nl> - * @ param { Object = } options Options to apply to the client <nl> - * @ return { function ( string , Object ) } New client constructor <nl> - * / <nl> - exports . makeProtobufClientConstructor = function ( service , options ) { <nl> - var method_attrs = common . getProtobufServiceAttrs ( service , options ) ; <nl> - if ( ! options ) { <nl> - options = { deprecatedArgumentOrder : false } ; <nl> - } <nl> - var Client = exports . makeClientConstructor ( <nl> - method_attrs , common . fullyQualifiedName ( service ) , <nl> - options ) ; <nl> - Client . service = service ; <nl> - Client . service . grpc_options = options ; <nl> - return Client ; <nl> - } ; <nl> - <nl> / * * <nl> * Map of status code names to status codes <nl> * / <nl> mmm a / src / node / src / common . js <nl> ppp b / src / node / src / common . js <nl> <nl> <nl> var _ = require ( ' lodash ' ) ; <nl> <nl> - / * * <nl> - * Get a function that deserializes a specific type of protobuf . <nl> - * @ param { function ( ) } cls The constructor of the message type to deserialize <nl> - * @ param { bool = } binaryAsBase64 Deserialize bytes fields as base64 strings <nl> - * instead of Buffers . Defaults to false <nl> - * @ param { bool = } longsAsStrings Deserialize long values as strings instead of <nl> - * objects . Defaults to true <nl> - * @ return { function ( Buffer ) : cls } The deserialization function <nl> - * / <nl> - exports . deserializeCls = function deserializeCls ( cls , binaryAsBase64 , <nl> - longsAsStrings ) { <nl> - if ( binaryAsBase64 = = = undefined | | binaryAsBase64 = = = null ) { <nl> - binaryAsBase64 = false ; <nl> - } <nl> - if ( longsAsStrings = = = undefined | | longsAsStrings = = = null ) { <nl> - longsAsStrings = true ; <nl> - } <nl> - / * * <nl> - * Deserialize a buffer to a message object <nl> - * @ param { Buffer } arg_buf The buffer to deserialize <nl> - * @ return { cls } The resulting object <nl> - * / <nl> - return function deserialize ( arg_buf ) { <nl> - / / Convert to a native object with binary fields as Buffers ( first argument ) <nl> - / / and longs as strings ( second argument ) <nl> - return cls . decode ( arg_buf ) . toRaw ( binaryAsBase64 , longsAsStrings ) ; <nl> - } ; <nl> - } ; <nl> - <nl> - var deserializeCls = exports . deserializeCls ; <nl> - <nl> - / * * <nl> - * Get a function that serializes objects to a buffer by protobuf class . <nl> - * @ param { function ( ) } Cls The constructor of the message type to serialize <nl> - * @ return { function ( Cls ) : Buffer } The serialization function <nl> - * / <nl> - exports . serializeCls = function serializeCls ( Cls ) { <nl> - / * * <nl> - * Serialize an object to a Buffer <nl> - * @ param { Object } arg The object to serialize <nl> - * @ return { Buffer } The serialized object <nl> - * / <nl> - return function serialize ( arg ) { <nl> - return new Buffer ( new Cls ( arg ) . encode ( ) . toBuffer ( ) ) ; <nl> - } ; <nl> - } ; <nl> - <nl> - var serializeCls = exports . serializeCls ; <nl> - <nl> - / * * <nl> - * Get the fully qualified ( dotted ) name of a ProtoBuf . Reflect value . <nl> - * @ param { ProtoBuf . Reflect . Namespace } value The value to get the name of <nl> - * @ return { string } The fully qualified name of the value <nl> - * / <nl> - exports . fullyQualifiedName = function fullyQualifiedName ( value ) { <nl> - if ( value = = = null | | value = = = undefined ) { <nl> - return ' ' ; <nl> - } <nl> - var name = value . name ; <nl> - var parent_name = fullyQualifiedName ( value . parent ) ; <nl> - if ( parent_name ! = = ' ' ) { <nl> - name = parent_name + ' . ' + name ; <nl> - } <nl> - return name ; <nl> - } ; <nl> - <nl> - var fullyQualifiedName = exports . fullyQualifiedName ; <nl> - <nl> / * * <nl> * Wrap a function to pass null - like values through without calling it . If no <nl> * function is given , just uses the identity ; <nl> exports . wrapIgnoreNull = function wrapIgnoreNull ( func ) { <nl> } ; <nl> } ; <nl> <nl> - / * * <nl> - * Return a map from method names to method attributes for the service . <nl> - * @ param { ProtoBuf . Reflect . Service } service The service to get attributes for <nl> - * @ param { Object = } options Options to apply to these attributes <nl> - * @ return { Object } The attributes map <nl> - * / <nl> - exports . getProtobufServiceAttrs = function getProtobufServiceAttrs ( service , <nl> - options ) { <nl> - var prefix = ' / ' + fullyQualifiedName ( service ) + ' / ' ; <nl> - var binaryAsBase64 , longsAsStrings ; <nl> - if ( options ) { <nl> - binaryAsBase64 = options . binaryAsBase64 ; <nl> - longsAsStrings = options . longsAsStrings ; <nl> - } <nl> - / * This slightly awkward construction is used to make sure we only use <nl> - lodash @ 3 . 10 . 1 - compatible functions . A previous version used <nl> - _ . fromPairs , which would be cleaner , but was introduced in lodash <nl> - version 4 * / <nl> - return _ . zipObject ( _ . map ( service . children , function ( method ) { <nl> - return _ . camelCase ( method . name ) ; <nl> - } ) , _ . map ( service . children , function ( method ) { <nl> - return { <nl> - originalName : method . name , <nl> - path : prefix + method . name , <nl> - requestStream : method . requestStream , <nl> - responseStream : method . responseStream , <nl> - requestType : method . resolvedRequestType , <nl> - responseType : method . resolvedResponseType , <nl> - requestSerialize : serializeCls ( method . resolvedRequestType . build ( ) ) , <nl> - requestDeserialize : deserializeCls ( method . resolvedRequestType . build ( ) , <nl> - binaryAsBase64 , longsAsStrings ) , <nl> - responseSerialize : serializeCls ( method . resolvedResponseType . build ( ) ) , <nl> - responseDeserialize : deserializeCls ( method . resolvedResponseType . build ( ) , <nl> - binaryAsBase64 , longsAsStrings ) <nl> - } ; <nl> - } ) ) ; <nl> - } ; <nl> - <nl> / * * <nl> * The logger object for the gRPC module . Defaults to console . <nl> * / <nl> exports . log = function log ( severity , message ) { <nl> exports . logger . error ( message ) ; <nl> } <nl> } ; <nl> + <nl> + / * * <nl> + * Default options for loading proto files into gRPC <nl> + * / <nl> + exports . defaultGrpcOptions = { <nl> + convertFieldsToCamelCase : false , <nl> + binaryAsBase64 : false , <nl> + longsAsStrings : true , <nl> + enumsAsStrings : true , <nl> + deprecatedArgumentOrder : false <nl> + } ; <nl> new file mode 100644 <nl> index 00000000000 . . 62cf2f4acaa <nl> mmm / dev / null <nl> ppp b / src / node / src / protobuf_js_5_common . js <nl> <nl> + / * <nl> + * <nl> + * Copyright 2017 , 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> + * / <nl> + <nl> + ' use strict ' ; <nl> + <nl> + var _ = require ( ' lodash ' ) ; <nl> + var client = require ( ' . / client ' ) ; <nl> + <nl> + / * * <nl> + * Get a function that deserializes a specific type of protobuf . <nl> + * @ param { function ( ) } cls The constructor of the message type to deserialize <nl> + * @ param { bool = } binaryAsBase64 Deserialize bytes fields as base64 strings <nl> + * instead of Buffers . Defaults to false <nl> + * @ param { bool = } longsAsStrings Deserialize long values as strings instead of <nl> + * objects . Defaults to true <nl> + * @ return { function ( Buffer ) : cls } The deserialization function <nl> + * / <nl> + exports . deserializeCls = function deserializeCls ( cls , binaryAsBase64 , <nl> + longsAsStrings ) { <nl> + / * * <nl> + * Deserialize a buffer to a message object <nl> + * @ param { Buffer } arg_buf The buffer to deserialize <nl> + * @ return { cls } The resulting object <nl> + * / <nl> + return function deserialize ( arg_buf ) { <nl> + / / Convert to a native object with binary fields as Buffers ( first argument ) <nl> + / / and longs as strings ( second argument ) <nl> + return cls . decode ( arg_buf ) . toRaw ( binaryAsBase64 , longsAsStrings ) ; <nl> + } ; <nl> + } ; <nl> + <nl> + var deserializeCls = exports . deserializeCls ; <nl> + <nl> + / * * <nl> + * Get a function that serializes objects to a buffer by protobuf class . <nl> + * @ param { function ( ) } Cls The constructor of the message type to serialize <nl> + * @ return { function ( Cls ) : Buffer } The serialization function <nl> + * / <nl> + exports . serializeCls = function serializeCls ( Cls ) { <nl> + / * * <nl> + * Serialize an object to a Buffer <nl> + * @ param { Object } arg The object to serialize <nl> + * @ return { Buffer } The serialized object <nl> + * / <nl> + return function serialize ( arg ) { <nl> + return new Buffer ( new Cls ( arg ) . encode ( ) . toBuffer ( ) ) ; <nl> + } ; <nl> + } ; <nl> + <nl> + var serializeCls = exports . serializeCls ; <nl> + <nl> + / * * <nl> + * Get the fully qualified ( dotted ) name of a ProtoBuf . Reflect value . <nl> + * @ param { ProtoBuf . Reflect . Namespace } value The value to get the name of <nl> + * @ return { string } The fully qualified name of the value <nl> + * / <nl> + exports . fullyQualifiedName = function fullyQualifiedName ( value ) { <nl> + if ( value = = = null | | value = = = undefined ) { <nl> + return ' ' ; <nl> + } <nl> + var name = value . name ; <nl> + var parent_name = fullyQualifiedName ( value . parent ) ; <nl> + if ( parent_name ! = = ' ' ) { <nl> + name = parent_name + ' . ' + name ; <nl> + } <nl> + return name ; <nl> + } ; <nl> + <nl> + var fullyQualifiedName = exports . fullyQualifiedName ; <nl> + <nl> + / * * <nl> + * Return a map from method names to method attributes for the service . <nl> + * @ param { ProtoBuf . Reflect . Service } service The service to get attributes for <nl> + * @ param { Object = } options Options to apply to these attributes <nl> + * @ return { Object } The attributes map <nl> + * / <nl> + exports . getProtobufServiceAttrs = function getProtobufServiceAttrs ( service , <nl> + options ) { <nl> + var prefix = ' / ' + fullyQualifiedName ( service ) + ' / ' ; <nl> + var binaryAsBase64 , longsAsStrings ; <nl> + if ( options ) { <nl> + binaryAsBase64 = options . binaryAsBase64 ; <nl> + longsAsStrings = options . longsAsStrings ; <nl> + } <nl> + / * This slightly awkward construction is used to make sure we only use <nl> + lodash @ 3 . 10 . 1 - compatible functions . A previous version used <nl> + _ . fromPairs , which would be cleaner , but was introduced in lodash <nl> + version 4 * / <nl> + return _ . zipObject ( _ . map ( service . children , function ( method ) { <nl> + return _ . camelCase ( method . name ) ; <nl> + } ) , _ . map ( service . children , function ( method ) { <nl> + return { <nl> + originalName : method . name , <nl> + path : prefix + method . name , <nl> + requestStream : method . requestStream , <nl> + responseStream : method . responseStream , <nl> + requestType : method . resolvedRequestType , <nl> + responseType : method . resolvedResponseType , <nl> + requestSerialize : serializeCls ( method . resolvedRequestType . build ( ) ) , <nl> + requestDeserialize : deserializeCls ( method . resolvedRequestType . build ( ) , <nl> + binaryAsBase64 , longsAsStrings ) , <nl> + responseSerialize : serializeCls ( method . resolvedResponseType . build ( ) ) , <nl> + responseDeserialize : deserializeCls ( method . resolvedResponseType . build ( ) , <nl> + binaryAsBase64 , longsAsStrings ) <nl> + } ; <nl> + } ) ) ; <nl> + } ; <nl> + <nl> + var getProtobufServiceAttrs = exports . getProtobufServiceAttrs ; <nl> + <nl> + / * * <nl> + * Load a gRPC object from an existing ProtoBuf . Reflect object . <nl> + * @ param { ProtoBuf . Reflect . Namespace } value The ProtoBuf object to load . <nl> + * @ param { Object = } options Options to apply to the loaded object <nl> + * @ return { Object < string , * > } The resulting gRPC object <nl> + * / <nl> + exports . loadObject = function loadObject ( value , options ) { <nl> + var result = { } ; <nl> + if ( ! value ) { <nl> + return value ; <nl> + } <nl> + if ( value . hasOwnProperty ( ' ns ' ) ) { <nl> + return loadObject ( value . ns , options ) ; <nl> + } <nl> + if ( value . className = = = ' Namespace ' ) { <nl> + _ . each ( value . children , function ( child ) { <nl> + result [ child . name ] = loadObject ( child , options ) ; <nl> + } ) ; <nl> + return result ; <nl> + } else if ( value . className = = = ' Service ' ) { <nl> + return client . makeClientConstructor ( getProtobufServiceAttrs ( value , options ) , <nl> + options ) ; <nl> + } else if ( value . className = = = ' Message ' | | value . className = = = ' Enum ' ) { <nl> + return value . build ( ) ; <nl> + } else { <nl> + return value ; <nl> + } <nl> + } ; <nl> + <nl> + / * * <nl> + * The primary purpose of this method is to distinguish between reflection <nl> + * objects from different versions of ProtoBuf . js . This is just a heuristic , <nl> + * checking for properties that are ( currently ) specific to this version of <nl> + * ProtoBuf . js <nl> + * @ param { Object } obj The object to check <nl> + * @ return { boolean } Whether the object appears to be a Protobuf . js 5 <nl> + * ReflectionObject <nl> + * / <nl> + exports . isProbablyProtobufJs5 = function isProbablyProtobufJs5 ( obj ) { <nl> + return _ . isArray ( obj . children ) & & ( typeof obj . build = = = ' function ' ) ; <nl> + } ; <nl> new file mode 100644 <nl> index 00000000000 . . 00f11f27363 <nl> mmm / dev / null <nl> ppp b / src / node / src / protobuf_js_6_common . js <nl> <nl> + / * <nl> + * <nl> + * Copyright 2017 , 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> + * / <nl> + <nl> + ' use strict ' ; <nl> + <nl> + var _ = require ( ' lodash ' ) ; <nl> + var client = require ( ' . / client ' ) ; <nl> + <nl> + / * * <nl> + * Get a function that deserializes a specific type of protobuf . <nl> + * @ param { function ( ) } cls The constructor of the message type to deserialize <nl> + * @ param { bool = } binaryAsBase64 Deserialize bytes fields as base64 strings <nl> + * instead of Buffers . Defaults to false <nl> + * @ param { bool = } longsAsStrings Deserialize long values as strings instead of <nl> + * objects . Defaults to true <nl> + * @ return { function ( Buffer ) : cls } The deserialization function <nl> + * / <nl> + exports . deserializeCls = function deserializeCls ( cls , options ) { <nl> + var conversion_options = { <nl> + defaults : true , <nl> + bytes : options . binaryAsBase64 ? String : Buffer , <nl> + longs : options . longsAsStrings ? String : null , <nl> + enums : options . enumsAsStrings ? String : null , <nl> + oneofs : true <nl> + } ; <nl> + / * * <nl> + * Deserialize a buffer to a message object <nl> + * @ param { Buffer } arg_buf The buffer to deserialize <nl> + * @ return { cls } The resulting object <nl> + * / <nl> + return function deserialize ( arg_buf ) { <nl> + return cls . decode ( arg_buf ) . toObject ( conversion_options ) ; <nl> + } ; <nl> + } ; <nl> + <nl> + var deserializeCls = exports . deserializeCls ; <nl> + <nl> + / * * <nl> + * Get a function that serializes objects to a buffer by protobuf class . <nl> + * @ param { function ( ) } Cls The constructor of the message type to serialize <nl> + * @ return { function ( Cls ) : Buffer } The serialization function <nl> + * / <nl> + exports . serializeCls = function serializeCls ( cls ) { <nl> + / * * <nl> + * Serialize an object to a Buffer <nl> + * @ param { Object } arg The object to serialize <nl> + * @ return { Buffer } The serialized object <nl> + * / <nl> + return function serialize ( arg ) { <nl> + var message = cls . fromObject ( arg ) ; <nl> + return cls . encode ( message ) . finish ( ) ; <nl> + } ; <nl> + } ; <nl> + <nl> + var serializeCls = exports . serializeCls ; <nl> + <nl> + / * * <nl> + * Get the fully qualified ( dotted ) name of a ProtoBuf . Reflect value . <nl> + * @ param { ProtoBuf . ReflectionObject } value The value to get the name of <nl> + * @ return { string } The fully qualified name of the value <nl> + * / <nl> + exports . fullyQualifiedName = function fullyQualifiedName ( value ) { <nl> + if ( value = = = null | | value = = = undefined ) { <nl> + return ' ' ; <nl> + } <nl> + var name = value . name ; <nl> + var parent_fqn = fullyQualifiedName ( value . parent ) ; <nl> + if ( parent_fqn ! = = ' ' ) { <nl> + name = parent_fqn + ' . ' + name ; <nl> + } <nl> + return name ; <nl> + } ; <nl> + <nl> + var fullyQualifiedName = exports . fullyQualifiedName ; <nl> + <nl> + / * * <nl> + * Return a map from method names to method attributes for the service . <nl> + * @ param { ProtoBuf . Service } service The service to get attributes for <nl> + * @ param { Object = } options Options to apply to these attributes <nl> + * @ return { Object } The attributes map <nl> + * / <nl> + exports . getProtobufServiceAttrs = function getProtobufServiceAttrs ( service , <nl> + options ) { <nl> + var prefix = ' / ' + fullyQualifiedName ( service ) + ' / ' ; <nl> + service . resolveAll ( ) ; <nl> + return _ . zipObject ( _ . map ( service . methods , function ( method ) { <nl> + return _ . camelCase ( method . name ) ; <nl> + } ) , _ . map ( service . methods , function ( method ) { <nl> + return { <nl> + originalName : method . name , <nl> + path : prefix + method . name , <nl> + requestStream : ! ! method . requestStream , <nl> + responseStream : ! ! method . responseStream , <nl> + requestType : method . resolvedRequestType , <nl> + responseType : method . resolvedResponseType , <nl> + requestSerialize : serializeCls ( method . resolvedRequestType ) , <nl> + requestDeserialize : deserializeCls ( method . resolvedRequestType , options ) , <nl> + responseSerialize : serializeCls ( method . resolvedResponseType ) , <nl> + responseDeserialize : deserializeCls ( method . resolvedResponseType , options ) <nl> + } ; <nl> + } ) ) ; <nl> + } ; <nl> + <nl> + var getProtobufServiceAttrs = exports . getProtobufServiceAttrs ; <nl> + <nl> + exports . loadObject = function loadObject ( value , options ) { <nl> + var result = { } ; <nl> + if ( ! value ) { <nl> + return value ; <nl> + } <nl> + if ( value . hasOwnProperty ( ' methods ' ) ) { <nl> + / / It ' s a service object <nl> + var service_attrs = getProtobufServiceAttrs ( value , options ) ; <nl> + return client . makeClientConstructor ( service_attrs ) ; <nl> + } <nl> + <nl> + if ( value . hasOwnProperty ( ' nested ' ) ) { <nl> + / / It ' s a namespace or root object <nl> + _ . each ( value . nested , function ( nested , name ) { <nl> + result [ name ] = loadObject ( nested , options ) ; <nl> + } ) ; <nl> + return result ; <nl> + } <nl> + <nl> + / / Otherwise , it ' s not something we need to change <nl> + return value ; <nl> + } ; <nl> + <nl> + / * * <nl> + * The primary purpose of this method is to distinguish between reflection <nl> + * objects from different versions of ProtoBuf . js . This is just a heuristic , <nl> + * checking for properties that are ( currently ) specific to this version of <nl> + * ProtoBuf . js <nl> + * @ param { Object } obj The object to check <nl> + * @ return { boolean } Whether the object appears to be a Protobuf . js 6 <nl> + * ReflectionObject <nl> + * / <nl> + exports . isProbablyProtobufJs6 = function isProbablyProtobufJs6 ( obj ) { <nl> + return ( typeof obj . root = = = ' object ' ) & & ( typeof obj . resolve = = = ' function ' ) ; <nl> + } ; <nl> mmm a / src / node / src / server . js <nl> ppp b / src / node / src / server . js <nl> Server . prototype . addService = function ( service , implementation ) { <nl> <nl> / * * <nl> * Add a proto service to the server , with a corresponding implementation <nl> + * @ deprecated Use grpc . load and Server # addService instead <nl> * @ param { Protobuf . Reflect . Service } service The proto service descriptor <nl> * @ param { Object < String , function > } implementation Map of method names to <nl> * method implementation for the provided service . <nl> * / <nl> Server . prototype . addProtoService = function ( service , implementation ) { <nl> var options ; <nl> - if ( service . grpc_options ) { <nl> - options = service . grpc_options ; <nl> + var protobuf_js_5_common = require ( ' . / protobuf_js_5_common ' ) ; <nl> + var protobuf_js_6_common = require ( ' . / protobuf_js_6_common ' ) ; <nl> + common . log ( grpc . logVerbosity . INFO , <nl> + ' Server # addProtoService is deprecated . Use addService instead ' ) ; <nl> + if ( protobuf_js_5_common . isProbablyProtobufJs5 ( service ) ) { <nl> + options = _ . defaults ( service . grpc_options , common . defaultGrpcOptions ) ; <nl> + this . addService ( <nl> + protobuf_js_5_common . getProtobufServiceAttrs ( service , options ) , <nl> + implementation ) ; <nl> + } else if ( protobuf_js_6_common . isProbablyProtobufJs6 ( service ) ) { <nl> + options = _ . defaults ( service . grpc_options , common . defaultGrpcOptions ) ; <nl> + this . addService ( <nl> + protobuf_js_6_common . getProtobufServiceAttrs ( service , options ) , <nl> + implementation ) ; <nl> + } else { <nl> + / / We assume that this is a service attributes object <nl> + this . addService ( service , implementation ) ; <nl> } <nl> - this . addService ( common . getProtobufServiceAttrs ( service , options ) , <nl> - implementation ) ; <nl> } ; <nl> <nl> / * * <nl> mmm a / src / node / stress / metrics_server . js <nl> ppp b / src / node / stress / metrics_server . js <nl> function getAllGauges ( call ) { <nl> <nl> function MetricsServer ( port ) { <nl> var server = new grpc . Server ( ) ; <nl> - server . addProtoService ( metrics . MetricsService . service , { <nl> + server . addService ( metrics . MetricsService . service , { <nl> getGauge : _ . bind ( getGauge , this ) , <nl> getAllGauges : _ . bind ( getAllGauges , this ) <nl> } ) ; <nl> mmm a / src / node / test / common_test . js <nl> ppp b / src / node / test / common_test . js <nl> <nl> ' use strict ' ; <nl> <nl> var assert = require ( ' assert ' ) ; <nl> + var _ = require ( ' lodash ' ) ; <nl> <nl> - var common = require ( ' . . / src / common . js ' ) ; <nl> + var common = require ( ' . . / src / common ' ) ; <nl> + var protobuf_js_6_common = require ( ' . . / src / protobuf_js_6_common ' ) ; <nl> + <nl> + var serializeCls = protobuf_js_6_common . serializeCls ; <nl> + var deserializeCls = protobuf_js_6_common . deserializeCls ; <nl> <nl> var ProtoBuf = require ( ' protobufjs ' ) ; <nl> <nl> - var messages_proto = ProtoBuf . loadProtoFile ( <nl> - __dirname + ' / test_messages . proto ' ) . build ( ) ; <nl> + var messages_proto = new ProtoBuf . Root ( ) ; <nl> + messages_proto = messages_proto . loadSync ( <nl> + __dirname + ' / test_messages . proto ' , { keepCase : true } ) . resolveAll ( ) ; <nl> + <nl> + var default_options = common . defaultGrpcOptions ; <nl> <nl> describe ( ' Proto message long int serialize and deserialize ' , function ( ) { <nl> - var longSerialize = common . serializeCls ( messages_proto . LongValues ) ; <nl> - var longDeserialize = common . deserializeCls ( messages_proto . LongValues ) ; <nl> + var longSerialize = serializeCls ( messages_proto . LongValues ) ; <nl> + var longDeserialize = deserializeCls ( messages_proto . LongValues , <nl> + default_options ) ; <nl> var pos_value = ' 314159265358979 ' ; <nl> var neg_value = ' - 27182818284590 ' ; <nl> it ( ' should preserve positive int64 values ' , function ( ) { <nl> describe ( ' Proto message long int serialize and deserialize ' , function ( ) { <nl> neg_value ) ; <nl> } ) ; <nl> it ( ' should deserialize as a number with the right option set ' , function ( ) { <nl> - var longNumDeserialize = common . deserializeCls ( messages_proto . LongValues , <nl> - false , false ) ; <nl> + var num_options = _ . defaults ( { longsAsStrings : false } , default_options ) ; <nl> + var longNumDeserialize = deserializeCls ( messages_proto . LongValues , <nl> + num_options ) ; <nl> var serialized = longSerialize ( { int_64 : pos_value } ) ; <nl> assert . strictEqual ( typeof longDeserialize ( serialized ) . int_64 , ' string ' ) ; <nl> / * With the longsAsStrings option disabled , long values are represented as <nl> describe ( ' Proto message long int serialize and deserialize ' , function ( ) { <nl> } ) ; <nl> } ) ; <nl> describe ( ' Proto message bytes serialize and deserialize ' , function ( ) { <nl> - var sequenceSerialize = common . serializeCls ( messages_proto . SequenceValues ) ; <nl> - var sequenceDeserialize = common . deserializeCls ( <nl> - messages_proto . SequenceValues ) ; <nl> - var sequenceBase64Deserialize = common . deserializeCls ( <nl> - messages_proto . SequenceValues , true ) ; <nl> + var sequenceSerialize = serializeCls ( messages_proto . SequenceValues ) ; <nl> + var sequenceDeserialize = deserializeCls ( <nl> + messages_proto . SequenceValues , default_options ) ; <nl> + var b64_options = _ . defaults ( { binaryAsBase64 : true } , default_options ) ; <nl> + var sequenceBase64Deserialize = deserializeCls ( <nl> + messages_proto . SequenceValues , b64_options ) ; <nl> var buffer_val = new Buffer ( [ 0x69 , 0xb7 ] ) ; <nl> var base64_val = ' abc = ' ; <nl> it ( ' should preserve a buffer ' , function ( ) { <nl> describe ( ' Proto message bytes serialize and deserialize ' , function ( ) { <nl> var deserialized = sequenceBase64Deserialize ( serialized ) ; <nl> assert . strictEqual ( deserialized . bytes_field , base64_val ) ; <nl> } ) ; <nl> - / * The next two tests are specific tests to verify that issue <nl> - * https : / / github . com / grpc / grpc / issues / 5174 has been fixed . They are skipped <nl> - * because they will not pass until a protobuf . js release has been published <nl> - * with a fix for https : / / github . com / dcodeIO / protobuf . js / issues / 390 * / <nl> - it . skip ( ' should serialize a repeated field as packed by default ' , function ( ) { <nl> - var expected_serialize = new Buffer ( [ 0x12 , 0x01 , 0x01 , 0x0a ] ) ; <nl> + it ( ' should serialize a repeated field as packed by default ' , function ( ) { <nl> + var expected_serialize = new Buffer ( [ 0x12 , 0x01 , 0x0a ] ) ; <nl> var serialized = sequenceSerialize ( { repeated_field : [ 10 ] } ) ; <nl> assert . strictEqual ( expected_serialize . compare ( serialized ) , 0 ) ; <nl> } ) ; <nl> - it . skip ( ' should deserialize packed or unpacked repeated ' , function ( ) { <nl> - var serialized = new Buffer ( [ 0x12 , 0x01 , 0x01 , 0x0a ] ) ; <nl> + it ( ' should deserialize packed or unpacked repeated ' , function ( ) { <nl> + var expectedDeserialize = { <nl> + bytes_field : new Buffer ( ' ' ) , <nl> + repeated_field : [ 10 ] <nl> + } ; <nl> + var packedSerialized = new Buffer ( [ 0x12 , 0x01 , 0x0a ] ) ; <nl> + var unpackedSerialized = new Buffer ( [ 0x10 , 0x0a ] ) ; <nl> + var packedDeserialized ; <nl> + var unpackedDeserialized ; <nl> assert . doesNotThrow ( function ( ) { <nl> - sequenceDeserialize ( serialized ) ; <nl> + packedDeserialized = sequenceDeserialize ( packedSerialized ) ; <nl> } ) ; <nl> + assert . doesNotThrow ( function ( ) { <nl> + unpackedDeserialized = sequenceDeserialize ( unpackedSerialized ) ; <nl> + } ) ; <nl> + assert . deepEqual ( packedDeserialized , expectedDeserialize ) ; <nl> + assert . deepEqual ( unpackedDeserialized , expectedDeserialize ) ; <nl> + } ) ; <nl> + } ) ; <nl> + describe ( ' Proto message oneof serialize and deserialize ' , function ( ) { <nl> + var oneofSerialize = serializeCls ( messages_proto . OneOfValues ) ; <nl> + var oneofDeserialize = deserializeCls ( <nl> + messages_proto . OneOfValues , default_options ) ; <nl> + it ( ' Should have idempotent round trips ' , function ( ) { <nl> + var test_message = { oneof_choice : ' int_choice ' , int_choice : 5 } ; <nl> + var serialized1 = oneofSerialize ( test_message ) ; <nl> + var deserialized1 = oneofDeserialize ( serialized1 ) ; <nl> + assert . equal ( deserialized1 . int_choice , 5 ) ; <nl> + var serialized2 = oneofSerialize ( deserialized1 ) ; <nl> + var deserialized2 = oneofDeserialize ( serialized2 ) ; <nl> + assert . deepEqual ( deserialized1 , deserialized2 ) ; <nl> + } ) ; <nl> + it ( ' Should emit a property indicating which field was chosen ' , function ( ) { <nl> + var test_message1 = { oneof_choice : ' int_choice ' , int_choice : 5 } ; <nl> + var serialized1 = oneofSerialize ( test_message1 ) ; <nl> + var deserialized1 = oneofDeserialize ( serialized1 ) ; <nl> + assert . equal ( deserialized1 . oneof_choice , ' int_choice ' ) ; <nl> + var test_message2 = { oneof_choice : ' string_choice ' , string_choice : ' abc ' } ; <nl> + var serialized2 = oneofSerialize ( test_message2 ) ; <nl> + var deserialized2 = oneofDeserialize ( serialized2 ) ; <nl> + assert . equal ( deserialized2 . oneof_choice , ' string_choice ' ) ; <nl> + } ) ; <nl> + } ) ; <nl> + describe ( ' Proto message enum serialize and deserialize ' , function ( ) { <nl> + var enumSerialize = serializeCls ( messages_proto . EnumValues ) ; <nl> + var enumDeserialize = deserializeCls ( <nl> + messages_proto . EnumValues , default_options ) ; <nl> + var enumIntOptions = _ . defaults ( { enumsAsStrings : false } , default_options ) ; <nl> + var enumIntDeserialize = deserializeCls ( <nl> + messages_proto . EnumValues , enumIntOptions ) ; <nl> + it ( ' Should accept both names and numbers ' , function ( ) { <nl> + var nameSerialized = enumSerialize ( { enum_value : ' ONE ' } ) ; <nl> + var numberSerialized = enumSerialize ( { enum_value : 1 } ) ; <nl> + assert . strictEqual ( messages_proto . TestEnum . ONE , 1 ) ; <nl> + assert . deepEqual ( enumDeserialize ( nameSerialized ) , <nl> + enumDeserialize ( numberSerialized ) ) ; <nl> + } ) ; <nl> + it ( ' Should deserialize as a string the enumsAsStrings option ' , function ( ) { <nl> + var serialized = enumSerialize ( { enum_value : ' TWO ' } ) ; <nl> + var nameDeserialized = enumDeserialize ( serialized ) ; <nl> + var numberDeserialized = enumIntDeserialize ( serialized ) ; <nl> + assert . deepEqual ( nameDeserialized , { enum_value : ' TWO ' } ) ; <nl> + assert . deepEqual ( numberDeserialized , { enum_value : 2 } ) ; <nl> } ) ; <nl> } ) ; <nl> mmm a / src / node / test / credentials_test . js <nl> ppp b / src / node / test / credentials_test . js <nl> describe ( ' client credentials ' , function ( ) { <nl> before ( function ( ) { <nl> var proto = grpc . load ( __dirname + ' / test_service . proto ' ) ; <nl> server = new grpc . Server ( ) ; <nl> - server . addProtoService ( proto . TestService . service , { <nl> + server . addService ( proto . TestService . service , { <nl> unary : function ( call , cb ) { <nl> call . sendMetadata ( call . metadata ) ; <nl> cb ( null , { } ) ; <nl> mmm a / src / node / test / surface_test . js <nl> ppp b / src / node / test / surface_test . js <nl> <nl> ' use strict ' ; <nl> <nl> var assert = require ( ' assert ' ) ; <nl> + var _ = require ( ' lodash ' ) ; <nl> <nl> var surface_client = require ( ' . . / src / client . js ' ) ; <nl> + var common = require ( ' . . / src / common ' ) ; <nl> <nl> var ProtoBuf = require ( ' protobufjs ' ) ; <nl> <nl> var grpc = require ( ' . . ' ) ; <nl> <nl> - var math_proto = ProtoBuf . loadProtoFile ( __dirname + <nl> - ' / . . / . . / proto / math / math . proto ' ) ; <nl> + var math_proto = new ProtoBuf . Root ( ) ; <nl> + math_proto = math_proto . loadSync ( __dirname + <nl> + ' / . . / . . / proto / math / math . proto ' , { keepCase : true } ) ; <nl> <nl> var mathService = math_proto . lookup ( ' math . Math ' ) ; <nl> - <nl> - var _ = require ( ' lodash ' ) ; <nl> + var mathServiceAttrs = grpc . loadObject ( <nl> + mathService , common . defaultGrpcOptions ) . service ; <nl> <nl> / * * <nl> * This is used for testing functions with multiple asynchronous calls that <nl> describe ( ' File loader ' , function ( ) { <nl> grpc . load ( __dirname + ' / test_service . json ' , ' json ' ) ; <nl> } ) ; <nl> } ) ; <nl> - it ( ' Should fail to load a file with an unknown format ' , function ( ) { <nl> - assert . throws ( function ( ) { <nl> - grpc . load ( __dirname + ' / test_service . proto ' , ' fake_format ' ) ; <nl> - } ) ; <nl> - } ) ; <nl> } ) ; <nl> describe ( ' surface Server ' , function ( ) { <nl> var server ; <nl> describe ( ' Server . prototype . addProtoService ' , function ( ) { <nl> afterEach ( function ( ) { <nl> server . forceShutdown ( ) ; <nl> } ) ; <nl> - it ( ' Should succeed with a single service ' , function ( ) { <nl> + it ( ' Should succeed with a single proto service ' , function ( ) { <nl> assert . doesNotThrow ( function ( ) { <nl> server . addProtoService ( mathService , dummyImpls ) ; <nl> } ) ; <nl> } ) ; <nl> + it ( ' Should succeed with a single service attributes object ' , function ( ) { <nl> + assert . doesNotThrow ( function ( ) { <nl> + server . addProtoService ( mathServiceAttrs , dummyImpls ) ; <nl> + } ) ; <nl> + } ) ; <nl> + } ) ; <nl> + describe ( ' Server . prototype . addService ' , function ( ) { <nl> + var server ; <nl> + var dummyImpls = { <nl> + ' div ' : function ( ) { } , <nl> + ' divMany ' : function ( ) { } , <nl> + ' fib ' : function ( ) { } , <nl> + ' sum ' : function ( ) { } <nl> + } ; <nl> + beforeEach ( function ( ) { <nl> + server = new grpc . Server ( ) ; <nl> + } ) ; <nl> + afterEach ( function ( ) { <nl> + server . forceShutdown ( ) ; <nl> + } ) ; <nl> + it ( ' Should succeed with a single service ' , function ( ) { <nl> + assert . doesNotThrow ( function ( ) { <nl> + server . addService ( mathServiceAttrs , dummyImpls ) ; <nl> + } ) ; <nl> + } ) ; <nl> it ( ' Should fail with conflicting method names ' , function ( ) { <nl> - server . addProtoService ( mathService , dummyImpls ) ; <nl> + server . addService ( mathServiceAttrs , dummyImpls ) ; <nl> assert . throws ( function ( ) { <nl> - server . addProtoService ( mathService , dummyImpls ) ; <nl> + server . addService ( mathServiceAttrs , dummyImpls ) ; <nl> } ) ; <nl> } ) ; <nl> it ( ' Should allow method names as originally written ' , function ( ) { <nl> describe ( ' Server . prototype . addProtoService ' , function ( ) { <nl> it ( ' Should fail if the server has been started ' , function ( ) { <nl> server . start ( ) ; <nl> assert . throws ( function ( ) { <nl> - server . addProtoService ( mathService , dummyImpls ) ; <nl> + server . addService ( mathServiceAttrs , dummyImpls ) ; <nl> } ) ; <nl> } ) ; <nl> describe ( ' Default handlers ' , function ( ) { <nl> var client ; <nl> beforeEach ( function ( ) { <nl> - server . addProtoService ( mathService , { } ) ; <nl> + server . addService ( mathServiceAttrs , { } ) ; <nl> var port = server . bind ( ' localhost : 0 ' , server_insecure_creds ) ; <nl> - var Client = surface_client . makeProtobufClientConstructor ( mathService ) ; <nl> + var Client = grpc . loadObject ( mathService ) ; <nl> client = new Client ( ' localhost : ' + port , <nl> grpc . credentials . createInsecure ( ) ) ; <nl> server . start ( ) ; <nl> describe ( ' waitForClientReady ' , function ( ) { <nl> server = new grpc . Server ( ) ; <nl> port = server . bind ( ' localhost : 0 ' , grpc . ServerCredentials . createInsecure ( ) ) ; <nl> server . start ( ) ; <nl> - Client = surface_client . makeProtobufClientConstructor ( mathService ) ; <nl> + Client = grpc . loadObject ( mathService ) ; <nl> } ) ; <nl> beforeEach ( function ( ) { <nl> client = new Client ( ' localhost : ' + port , grpc . credentials . createInsecure ( ) ) ; <nl> describe ( ' Echo service ' , function ( ) { <nl> var server ; <nl> var client ; <nl> before ( function ( ) { <nl> - var test_proto = ProtoBuf . loadProtoFile ( __dirname + ' / echo_service . proto ' ) ; <nl> + var test_proto = new ProtoBuf . Root ( ) ; <nl> + test_proto = test_proto . loadSync ( __dirname + ' / echo_service . proto ' , <nl> + { keepCase : true } ) ; <nl> var echo_service = test_proto . lookup ( ' EchoService ' ) ; <nl> + var Client = grpc . loadObject ( echo_service ) ; <nl> server = new grpc . Server ( ) ; <nl> - server . addProtoService ( echo_service , { <nl> + server . addService ( Client . service , { <nl> echo : function ( call , callback ) { <nl> callback ( null , call . request ) ; <nl> } <nl> } ) ; <nl> var port = server . bind ( ' localhost : 0 ' , server_insecure_creds ) ; <nl> - var Client = surface_client . makeProtobufClientConstructor ( echo_service ) ; <nl> client = new Client ( ' localhost : ' + port , grpc . credentials . createInsecure ( ) ) ; <nl> server . start ( ) ; <nl> } ) ; <nl> describe ( ' Echo metadata ' , function ( ) { <nl> var server ; <nl> var metadata ; <nl> before ( function ( ) { <nl> - var test_proto = ProtoBuf . loadProtoFile ( __dirname + ' / test_service . proto ' ) ; <nl> + var test_proto = new ProtoBuf . Root ( ) ; <nl> + test_proto = test_proto . loadSync ( __dirname + ' / test_service . proto ' , <nl> + { keepCase : true } ) ; <nl> var test_service = test_proto . lookup ( ' TestService ' ) ; <nl> + var Client = grpc . loadObject ( test_service ) ; <nl> server = new grpc . Server ( ) ; <nl> - server . addProtoService ( test_service , { <nl> + server . addService ( Client . service , { <nl> unary : function ( call , cb ) { <nl> call . sendMetadata ( call . metadata ) ; <nl> cb ( null , { } ) ; <nl> describe ( ' Echo metadata ' , function ( ) { <nl> } <nl> } ) ; <nl> var port = server . bind ( ' localhost : 0 ' , server_insecure_creds ) ; <nl> - var Client = surface_client . makeProtobufClientConstructor ( test_service ) ; <nl> client = new Client ( ' localhost : ' + port , grpc . credentials . createInsecure ( ) ) ; <nl> server . start ( ) ; <nl> metadata = new grpc . Metadata ( ) ; <nl> describe ( ' Client malformed response handling ' , function ( ) { <nl> var client ; <nl> var badArg = new Buffer ( [ 0xFF ] ) ; <nl> before ( function ( ) { <nl> - var test_proto = ProtoBuf . loadProtoFile ( __dirname + ' / test_service . proto ' ) ; <nl> + var test_proto = new ProtoBuf . Root ( ) ; <nl> + test_proto = test_proto . loadSync ( __dirname + ' / test_service . proto ' , <nl> + { keepCase : true } ) ; <nl> var test_service = test_proto . lookup ( ' TestService ' ) ; <nl> var malformed_test_service = { <nl> unary : { <nl> describe ( ' Client malformed response handling ' , function ( ) { <nl> } <nl> } ) ; <nl> var port = server . bind ( ' localhost : 0 ' , server_insecure_creds ) ; <nl> - var Client = surface_client . makeProtobufClientConstructor ( test_service ) ; <nl> + var Client = grpc . loadObject ( test_service ) ; <nl> client = new Client ( ' localhost : ' + port , grpc . credentials . createInsecure ( ) ) ; <nl> server . start ( ) ; <nl> } ) ; <nl> describe ( ' Server serialization failure handling ' , function ( ) { <nl> var client ; <nl> var server ; <nl> before ( function ( ) { <nl> - var test_proto = ProtoBuf . loadProtoFile ( __dirname + ' / test_service . proto ' ) ; <nl> + var test_proto = new ProtoBuf . Root ( ) ; <nl> + test_proto = test_proto . loadSync ( __dirname + ' / test_service . proto ' , <nl> + { keepCase : true } ) ; <nl> var test_service = test_proto . lookup ( ' TestService ' ) ; <nl> var malformed_test_service = { <nl> unary : { <nl> describe ( ' Server serialization failure handling ' , function ( ) { <nl> } <nl> } ) ; <nl> var port = server . bind ( ' localhost : 0 ' , server_insecure_creds ) ; <nl> - var Client = surface_client . makeProtobufClientConstructor ( test_service ) ; <nl> + var Client = grpc . loadObject ( test_service ) ; <nl> client = new Client ( ' localhost : ' + port , grpc . credentials . createInsecure ( ) ) ; <nl> server . start ( ) ; <nl> } ) ; <nl> describe ( ' Other conditions ' , function ( ) { <nl> var server ; <nl> var port ; <nl> before ( function ( ) { <nl> - var test_proto = ProtoBuf . loadProtoFile ( __dirname + ' / test_service . proto ' ) ; <nl> + var test_proto = new ProtoBuf . Root ( ) ; <nl> + test_proto = test_proto . loadSync ( __dirname + ' / test_service . proto ' , <nl> + { keepCase : true } ) ; <nl> test_service = test_proto . lookup ( ' TestService ' ) ; <nl> + Client = grpc . loadObject ( test_service ) ; <nl> server = new grpc . Server ( ) ; <nl> var trailer_metadata = new grpc . Metadata ( ) ; <nl> trailer_metadata . add ( ' trailer - present ' , ' yes ' ) ; <nl> - server . addProtoService ( test_service , { <nl> + server . addService ( Client . service , { <nl> unary : function ( call , cb ) { <nl> var req = call . request ; <nl> if ( req . error ) { <nl> describe ( ' Other conditions ' , function ( ) { <nl> } <nl> } ) ; <nl> port = server . bind ( ' localhost : 0 ' , server_insecure_creds ) ; <nl> - Client = surface_client . makeProtobufClientConstructor ( test_service ) ; <nl> client = new Client ( ' localhost : ' + port , grpc . credentials . createInsecure ( ) ) ; <nl> server . start ( ) ; <nl> } ) ; <nl> describe ( ' Call propagation ' , function ( ) { <nl> var client ; <nl> var server ; <nl> before ( function ( ) { <nl> - var test_proto = ProtoBuf . loadProtoFile ( __dirname + ' / test_service . proto ' ) ; <nl> + var test_proto = new ProtoBuf . Root ( ) ; <nl> + test_proto = test_proto . loadSync ( __dirname + ' / test_service . proto ' , <nl> + { keepCase : true } ) ; <nl> test_service = test_proto . lookup ( ' TestService ' ) ; <nl> server = new grpc . Server ( ) ; <nl> - server . addProtoService ( test_service , { <nl> + Client = grpc . loadObject ( test_service ) ; <nl> + server . addService ( Client . service , { <nl> unary : function ( call ) { } , <nl> clientStream : function ( stream ) { } , <nl> serverStream : function ( stream ) { } , <nl> bidiStream : function ( stream ) { } <nl> } ) ; <nl> var port = server . bind ( ' localhost : 0 ' , server_insecure_creds ) ; <nl> - Client = surface_client . makeProtobufClientConstructor ( test_service ) ; <nl> client = new Client ( ' localhost : ' + port , grpc . credentials . createInsecure ( ) ) ; <nl> server . start ( ) ; <nl> } ) ; <nl> describe ( ' Call propagation ' , function ( ) { <nl> } ) ; <nl> call . cancel ( ) ; <nl> } ; <nl> - proxy . addProtoService ( test_service , proxy_impl ) ; <nl> + proxy . addService ( Client . service , proxy_impl ) ; <nl> var proxy_port = proxy . bind ( ' localhost : 0 ' , server_insecure_creds ) ; <nl> proxy . start ( ) ; <nl> var proxy_client = new Client ( ' localhost : ' + proxy_port , <nl> describe ( ' Call propagation ' , function ( ) { <nl> } ) ; <nl> call . cancel ( ) ; <nl> } ; <nl> - proxy . addProtoService ( test_service , proxy_impl ) ; <nl> + proxy . addService ( Client . service , proxy_impl ) ; <nl> var proxy_port = proxy . bind ( ' localhost : 0 ' , server_insecure_creds ) ; <nl> proxy . start ( ) ; <nl> var proxy_client = new Client ( ' localhost : ' + proxy_port , <nl> describe ( ' Call propagation ' , function ( ) { <nl> } ) ; <nl> call . cancel ( ) ; <nl> } ; <nl> - proxy . addProtoService ( test_service , proxy_impl ) ; <nl> + proxy . addService ( Client . service , proxy_impl ) ; <nl> var proxy_port = proxy . bind ( ' localhost : 0 ' , server_insecure_creds ) ; <nl> proxy . start ( ) ; <nl> var proxy_client = new Client ( ' localhost : ' + proxy_port , <nl> describe ( ' Call propagation ' , function ( ) { <nl> } ) ; <nl> call . cancel ( ) ; <nl> } ; <nl> - proxy . addProtoService ( test_service , proxy_impl ) ; <nl> + proxy . addService ( Client . service , proxy_impl ) ; <nl> var proxy_port = proxy . bind ( ' localhost : 0 ' , server_insecure_creds ) ; <nl> proxy . start ( ) ; <nl> var proxy_client = new Client ( ' localhost : ' + proxy_port , <nl> describe ( ' Call propagation ' , function ( ) { <nl> } <nl> } ) ; <nl> } ; <nl> - proxy . addProtoService ( test_service , proxy_impl ) ; <nl> + proxy . addService ( Client . service , proxy_impl ) ; <nl> var proxy_port = proxy . bind ( ' localhost : 0 ' , server_insecure_creds ) ; <nl> proxy . start ( ) ; <nl> var proxy_client = new Client ( ' localhost : ' + proxy_port , <nl> describe ( ' Call propagation ' , function ( ) { <nl> done ( ) ; <nl> } ) ; <nl> } ; <nl> - proxy . addProtoService ( test_service , proxy_impl ) ; <nl> + proxy . addService ( Client . service , proxy_impl ) ; <nl> var proxy_port = proxy . bind ( ' localhost : 0 ' , server_insecure_creds ) ; <nl> proxy . start ( ) ; <nl> var proxy_client = new Client ( ' localhost : ' + proxy_port , <nl> describe ( ' Cancelling surface client ' , function ( ) { <nl> var server ; <nl> before ( function ( ) { <nl> server = new grpc . Server ( ) ; <nl> - server . addProtoService ( mathService , { <nl> + server . addService ( mathServiceAttrs , { <nl> ' div ' : function ( stream ) { } , <nl> ' divMany ' : function ( stream ) { } , <nl> ' fib ' : function ( stream ) { } , <nl> ' sum ' : function ( stream ) { } <nl> } ) ; <nl> var port = server . bind ( ' localhost : 0 ' , server_insecure_creds ) ; <nl> - var Client = surface_client . makeProtobufClientConstructor ( mathService ) ; <nl> + var Client = surface_client . makeClientConstructor ( mathServiceAttrs ) ; <nl> client = new Client ( ' localhost : ' + port , grpc . credentials . createInsecure ( ) ) ; <nl> server . start ( ) ; <nl> } ) ; <nl> mmm a / src / node / test / test_messages . proto <nl> ppp b / src / node / test / test_messages . proto <nl> message SequenceValues { <nl> bytes bytes_field = 1 ; <nl> repeated int32 repeated_field = 2 ; <nl> } <nl> + <nl> + message OneOfValues { <nl> + oneof oneof_choice { <nl> + int32 int_choice = 1 ; <nl> + string string_choice = 2 ; <nl> + } <nl> + } <nl> + <nl> + enum TestEnum { <nl> + ZERO = 0 ; <nl> + ONE = 1 ; <nl> + TWO = 2 ; <nl> + } <nl> + <nl> + message EnumValues { <nl> + TestEnum enum_value = 1 ; <nl> + } <nl> \ No newline at end of file <nl> mmm a / src / proto / grpc / testing / BUILD <nl> ppp b / src / proto / grpc / testing / BUILD <nl> grpc_proto_library ( <nl> grpc_proto_library ( <nl> name = " services_proto " , <nl> srcs = [ " services . proto " ] , <nl> - deps = [ " control_proto " , " messages_proto " ] , <nl> + deps = [ <nl> + " control_proto " , <nl> + " messages_proto " , <nl> + " stats_proto " , <nl> + ] , <nl> ) <nl> <nl> grpc_proto_library ( <nl> mmm a / src / proto / grpc / testing / echo_messages . proto <nl> ppp b / src / proto / grpc / testing / echo_messages . proto <nl> message DebugInfo { <nl> string detail = 2 ; <nl> } <nl> <nl> + / / Error status client expects to see . <nl> + message ErrorStatus { <nl> + int32 code = 1 ; <nl> + string error_message = 2 ; <nl> + string binary_error_details = 3 ; <nl> + } <nl> + <nl> message RequestParams { <nl> bool echo_deadline = 1 ; <nl> int32 client_cancel_after_us = 2 ; <nl> message RequestParams { <nl> string expected_transport_security_type = 10 ; <nl> DebugInfo debug_info = 11 ; <nl> bool server_die = 12 ; / / Server should not see a request with this set . <nl> + string binary_error_details = 13 ; <nl> + ErrorStatus expected_error = 14 ; <nl> } <nl> <nl> message EchoRequest { <nl> mmm a / src / proto / grpc / testing / services . proto <nl> ppp b / src / proto / grpc / testing / services . proto <nl> syntax = " proto3 " ; <nl> <nl> import " src / proto / grpc / testing / messages . proto " ; <nl> import " src / proto / grpc / testing / control . proto " ; <nl> + import " src / proto / grpc / testing / stats . proto " ; <nl> <nl> package grpc . testing ; <nl> <nl> service WorkerService { <nl> / / Quit this worker <nl> rpc QuitWorker ( Void ) returns ( Void ) ; <nl> } <nl> + <nl> + service ReportQpsScenarioService { <nl> + / / Report results of a QPS test benchmark scenario . <nl> + rpc ReportScenario ( ScenarioResult ) returns ( Void ) ; <nl> + } <nl> mmm a / src / python / grpcio / grpc / _server . py <nl> ppp b / src / python / grpcio / grpc / _server . py <nl> def _serve ( state ) : <nl> state . rpc_states . remove ( rpc_state ) <nl> if _stop_serving ( state ) : <nl> return <nl> + # We want to force the deletion of the previous event <nl> + # ~ before ~ we poll again ; if the event has a reference <nl> + # to a shutdown Call object , this can induce spinlock . <nl> + event = None <nl> <nl> <nl> def _stop ( state , grace ) : <nl> mmm a / src / python / grpcio / grpc_core_dependencies . py <nl> ppp b / src / python / grpcio / grpc_core_dependencies . py <nl> <nl> ' src / core / lib / iomgr / iomgr_uv . c ' , <nl> ' src / core / lib / iomgr / iomgr_windows . c ' , <nl> ' src / core / lib / iomgr / load_file . c ' , <nl> + ' src / core / lib / iomgr / lockfree_event . c ' , <nl> ' src / core / lib / iomgr / network_status_tracker . c ' , <nl> ' src / core / lib / iomgr / polling_entity . c ' , <nl> ' src / core / lib / iomgr / pollset_set_uv . c ' , <nl> mmm a / src / ruby / end2end / channel_closing_driver . rb <nl> ppp b / src / ruby / end2end / channel_closing_driver . rb <nl> <nl> <nl> def main <nl> STDERR . puts ' start server ' <nl> - server_runner = ServerRunner . new <nl> + server_runner = ServerRunner . new ( EchoServerImpl ) <nl> server_port = server_runner . run <nl> <nl> sleep 1 <nl> mmm a / src / ruby / end2end / channel_state_driver . rb <nl> ppp b / src / ruby / end2end / channel_state_driver . rb <nl> <nl> <nl> def main <nl> STDERR . puts ' start server ' <nl> - server_runner = ServerRunner . new <nl> + server_runner = ServerRunner . new ( EchoServerImpl ) <nl> server_port = server_runner . run <nl> <nl> sleep 1 <nl> mmm a / src / ruby / end2end / end2end_common . rb <nl> ppp b / src / ruby / end2end / end2end_common . rb <nl> def echo ( echo_req , _ ) <nl> <nl> # ServerRunner starts an " echo server " that test clients can make calls to <nl> class ServerRunner <nl> - def initialize <nl> + def initialize ( service_impl ) <nl> + @ service_impl = service_impl <nl> end <nl> <nl> def run <nl> @ srv = GRPC : : RpcServer . new <nl> port = @ srv . add_http2_port ( ' 0 . 0 . 0 . 0 : 0 ' , : this_port_is_insecure ) <nl> - @ srv . handle ( EchoServerImpl ) <nl> + @ srv . handle ( @ service_impl ) <nl> <nl> @ thd = Thread . new do <nl> @ srv . run <nl> new file mode 100755 <nl> index 00000000000 . . d5a7db7d586 <nl> mmm / dev / null <nl> ppp b / src / ruby / end2end / killed_client_thread_client . rb <nl> <nl> + # ! / usr / bin / env ruby <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> + # Attempt to reproduce <nl> + # https : / / github . com / GoogleCloudPlatform / google - cloud - ruby / issues / 1327 <nl> + <nl> + require_relative ' . / end2end_common ' <nl> + <nl> + def main <nl> + server_port = ' ' <nl> + OptionParser . new do | opts | <nl> + opts . on ( ' - - client_control_port = P ' , String ) do <nl> + STDERR . puts ' client control port not used ' <nl> + end <nl> + opts . on ( ' - - server_port = P ' , String ) do | p | <nl> + server_port = p <nl> + end <nl> + end . parse ! <nl> + <nl> + thd = Thread . new do <nl> + stub = Echo : : EchoServer : : Stub . new ( " localhost : # { server_port } " , <nl> + : this_channel_is_insecure ) <nl> + stub . echo ( Echo : : EchoRequest . new ( request : ' hello ' ) ) <nl> + fail ' the clients rpc in this test shouldnt complete . ' \ <nl> + ' expecting SIGINT to happen in the middle of the call ' <nl> + end <nl> + thd . join <nl> + end <nl> + <nl> + main <nl> new file mode 100755 <nl> index 00000000000 . . f76d3e1746d <nl> mmm / dev / null <nl> ppp b / src / ruby / end2end / killed_client_thread_driver . rb <nl> <nl> + # ! / usr / bin / env ruby <nl> + <nl> + # Copyright 2016 , 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> + require_relative ' . / end2end_common ' <nl> + <nl> + # Service that sleeps for a long time upon receiving an ' echo request ' <nl> + # Also , this notifies @ call_started_cv once it has received a request . <nl> + class SleepingEchoServerImpl < Echo : : EchoServer : : Service <nl> + def initialize ( call_started , call_started_mu , call_started_cv ) <nl> + @ call_started = call_started <nl> + @ call_started_mu = call_started_mu <nl> + @ call_started_cv = call_started_cv <nl> + end <nl> + <nl> + def echo ( echo_req , _ ) <nl> + @ call_started_mu . synchronize do <nl> + @ call_started . set_true <nl> + @ call_started_cv . signal <nl> + end <nl> + sleep 1000 <nl> + Echo : : EchoReply . new ( response : echo_req . request ) <nl> + end <nl> + end <nl> + <nl> + # Mutable boolean <nl> + class BoolHolder <nl> + attr_reader : val <nl> + <nl> + def init <nl> + @ val = false <nl> + end <nl> + <nl> + def set_true <nl> + @ val = true <nl> + end <nl> + end <nl> + <nl> + def main <nl> + STDERR . puts ' start server ' <nl> + <nl> + call_started = BoolHolder . new <nl> + call_started_mu = Mutex . new <nl> + call_started_cv = ConditionVariable . new <nl> + <nl> + service_impl = SleepingEchoServerImpl . new ( call_started , <nl> + call_started_mu , <nl> + call_started_cv ) <nl> + server_runner = ServerRunner . new ( service_impl ) <nl> + server_port = server_runner . run <nl> + <nl> + STDERR . puts ' start client ' <nl> + _ , client_pid = start_client ( ' killed_client_thread_client . rb ' , <nl> + server_port ) <nl> + <nl> + call_started_mu . synchronize do <nl> + call_started_cv . wait ( call_started_mu ) until call_started . val <nl> + end <nl> + <nl> + # SIGINT the child process now that it ' s <nl> + # in the middle of an RPC ( happening on a non - main thread ) <nl> + Process . kill ( ' SIGINT ' , client_pid ) <nl> + STDERR . puts ' sent shutdown ' <nl> + <nl> + begin <nl> + Timeout . timeout ( 10 ) do <nl> + Process . wait ( client_pid ) <nl> + end <nl> + rescue Timeout : : Error <nl> + STDERR . puts " timeout wait for client pid # { client_pid } " <nl> + Process . kill ( ' SIGKILL ' , client_pid ) <nl> + Process . wait ( client_pid ) <nl> + STDERR . puts ' killed client child ' <nl> + raise ' Timed out waiting for client process . ' \ <nl> + ' It likely hangs when killed while in the middle of an rpc ' <nl> + end <nl> + <nl> + client_exit_code = $ CHILD_STATUS <nl> + if client_exit_code . termsig ! = 2 # SIGINT <nl> + fail ' expected client exit from SIGINT ' \ <nl> + " but got child status : # { client_exit_code } " <nl> + end <nl> + <nl> + server_runner . stop <nl> + end <nl> + <nl> + main <nl> mmm a / src / ruby / end2end / sig_handling_driver . rb <nl> ppp b / src / ruby / end2end / sig_handling_driver . rb <nl> <nl> <nl> def main <nl> STDERR . puts ' start server ' <nl> - server_runner = ServerRunner . new <nl> + server_runner = ServerRunner . new ( EchoServerImpl ) <nl> server_port = server_runner . run <nl> <nl> sleep 1 <nl> mmm a / src / ruby / end2end / sig_int_during_channel_watch_driver . rb <nl> ppp b / src / ruby / end2end / sig_int_during_channel_watch_driver . rb <nl> <nl> <nl> def main <nl> STDERR . puts ' start server ' <nl> - server_runner = ServerRunner . new <nl> + server_runner = ServerRunner . new ( EchoServerImpl ) <nl> server_port = server_runner . run <nl> <nl> sleep 1 <nl> mmm a / src / ruby / ext / grpc / rb_call . c <nl> ppp b / src / ruby / ext / grpc / rb_call . c <nl> static VALUE grpc_run_batch_stack_build_result ( run_batch_stack * st ) { <nl> Only one operation of each type can be active at once in any given <nl> batch * / <nl> static VALUE grpc_rb_call_run_batch ( VALUE self , VALUE ops_hash ) { <nl> - run_batch_stack st ; <nl> + run_batch_stack * st = NULL ; <nl> grpc_rb_call * call = NULL ; <nl> grpc_event ev ; <nl> grpc_call_error err ; <nl> static VALUE grpc_rb_call_run_batch ( VALUE self , VALUE ops_hash ) { <nl> VALUE rb_write_flag = rb_ivar_get ( self , id_write_flag ) ; <nl> unsigned write_flag = 0 ; <nl> void * tag = ( void * ) & st ; <nl> + <nl> if ( RTYPEDDATA_DATA ( self ) = = NULL ) { <nl> rb_raise ( grpc_rb_eCallError , " Cannot run batch on closed call " ) ; <nl> return Qnil ; <nl> static VALUE grpc_rb_call_run_batch ( VALUE self , VALUE ops_hash ) { <nl> if ( rb_write_flag ! = Qnil ) { <nl> write_flag = NUM2UINT ( rb_write_flag ) ; <nl> } <nl> - grpc_run_batch_stack_init ( & st , write_flag ) ; <nl> - grpc_run_batch_stack_fill_ops ( & st , ops_hash ) ; <nl> + st = gpr_malloc ( sizeof ( run_batch_stack ) ) ; <nl> + grpc_run_batch_stack_init ( st , write_flag ) ; <nl> + grpc_run_batch_stack_fill_ops ( st , ops_hash ) ; <nl> <nl> / * call grpc_call_start_batch , then wait for it to complete using <nl> * pluck_event * / <nl> - err = grpc_call_start_batch ( call - > wrapped , st . ops , st . op_num , tag , NULL ) ; <nl> + err = grpc_call_start_batch ( call - > wrapped , st - > ops , st - > op_num , tag , NULL ) ; <nl> if ( err ! = GRPC_CALL_OK ) { <nl> - grpc_run_batch_stack_cleanup ( & st ) ; <nl> + grpc_run_batch_stack_cleanup ( st ) ; <nl> + gpr_free ( st ) ; <nl> rb_raise ( grpc_rb_eCallError , <nl> " grpc_call_start_batch failed with % s ( code = % d ) " , <nl> grpc_call_error_detail_of ( err ) , err ) ; <nl> static VALUE grpc_rb_call_run_batch ( VALUE self , VALUE ops_hash ) { <nl> } <nl> / * Build and return the BatchResult struct result , <nl> if there is an error , it ' s reflected in the status * / <nl> - result = grpc_run_batch_stack_build_result ( & st ) ; <nl> - grpc_run_batch_stack_cleanup ( & st ) ; <nl> + result = grpc_run_batch_stack_build_result ( st ) ; <nl> + grpc_run_batch_stack_cleanup ( st ) ; <nl> + gpr_free ( st ) ; <nl> return result ; <nl> } <nl> <nl> mmm a / src / ruby / spec / generic / rpc_server_pool_spec . rb <nl> ppp b / src / ruby / spec / generic / rpc_server_pool_spec . rb <nl> <nl> expect ( p . ready_for_work ? ) . to be ( false ) <nl> end <nl> <nl> - it ' it stops being ready after all workers jobs waiting or running ' do <nl> + it ' it stops being ready after all workers are busy ' do <nl> p = Pool . new ( 5 ) <nl> p . start <nl> - job = proc { sleep ( 3 ) } # sleep so workers busy when done scheduling <nl> - 5 . times do <nl> - expect ( p . ready_for_work ? ) . to be ( true ) <nl> - p . schedule ( & job ) <nl> + <nl> + wait_mu = Mutex . new <nl> + wait_cv = ConditionVariable . new <nl> + wait = true <nl> + <nl> + job = proc do <nl> + wait_mu . synchronize do <nl> + wait_cv . wait ( wait_mu ) while wait <nl> + end <nl> end <nl> - expect ( p . ready_for_work ? ) . to be ( false ) <nl> - end <nl> <nl> - it ' it becomes ready again after jobs complete ' do <nl> - p = Pool . new ( 5 ) <nl> - p . start <nl> - job = proc { } <nl> 5 . times do <nl> expect ( p . ready_for_work ? ) . to be ( true ) <nl> p . schedule ( & job ) <nl> end <nl> + <nl> expect ( p . ready_for_work ? ) . to be ( false ) <nl> - sleep 5 # give the pool time do get at least one task done <nl> - expect ( p . ready_for_work ? ) . to be ( true ) <nl> + <nl> + wait_mu . synchronize do <nl> + wait = false <nl> + wait_cv . broadcast <nl> + end <nl> end <nl> end <nl> <nl> <nl> it ' stops jobs when there are long running jobs ' do <nl> p = Pool . new ( 1 ) <nl> p . start <nl> - o , q = Object . new , Queue . new <nl> + <nl> + wait_forever_mu = Mutex . new <nl> + wait_forever_cv = ConditionVariable . new <nl> + wait_forever = true <nl> + <nl> + job_running = Queue . new <nl> job = proc do <nl> - sleep ( 5 ) # long running <nl> - q . push ( o ) <nl> + job_running . push ( Object . new ) <nl> + wait_forever_mu . synchronize do <nl> + wait_forever_cv . wait while wait_forever <nl> + end <nl> end <nl> p . schedule ( & job ) <nl> - sleep ( 1 ) # should ensure the long job gets scheduled <nl> + job_running . pop <nl> expect { p . stop } . not_to raise_error <nl> end <nl> end <nl> mmm a / templates / CMakeLists . txt . template <nl> ppp b / templates / CMakeLists . txt . template <nl> <nl> # This file can be regenerated from the template by running <nl> # tools / buildgen / generate_projects . sh <nl> # <nl> - # Additionally , this is currently very experimental , and unsupported . <nl> - # Further work will happen on that file . <nl> - # <nl> # Copyright 2015 , Google Inc . <nl> # All rights reserved . <nl> # <nl> <nl> foreach ( FIL < % text > $ { ARGN } < / % text > ) <nl> get_filename_component ( ABS_FIL < % text > $ { FIL } < / % text > ABSOLUTE ) <nl> get_filename_component ( FIL_WE < % text > $ { FIL } < / % text > NAME_WE ) <nl> - file ( RELATIVE_PATH REL_FIL < % text > $ { CMAKE_SOURCE_DIR } < / % text > < % text > $ { ABS_FIL } < / % text > ) <nl> + file ( RELATIVE_PATH REL_FIL < % text > $ { CMAKE_CURRENT_SOURCE_DIR } < / % text > < % text > $ { ABS_FIL } < / % text > ) <nl> get_filename_component ( REL_DIR < % text > $ { REL_FIL } < / % text > DIRECTORY ) <nl> set ( RELFIL_WE " < % text > $ { REL_DIR } / $ { FIL_WE } < / % text > " ) <nl> <nl> <nl> < % text > $ { _protobuf_include_path } < / % text > <nl> < % text > $ { REL_FIL } < / % text > <nl> DEPENDS < % text > $ { ABS_FIL } < / % text > < % text > $ { _gRPC_PROTOBUF_PROTOC } < / % text > grpc_cpp_plugin <nl> - WORKING_DIRECTORY < % text > $ { CMAKE_SOURCE_DIR } < / % text > <nl> + WORKING_DIRECTORY < % text > $ { CMAKE_CURRENT_SOURCE_DIR } < / % text > <nl> COMMENT " Running gRPC C + + protocol buffer compiler on < % text > $ { FIL } < / % text > " <nl> VERBATIM ) <nl> <nl> <nl> PRIVATE < % text > $ { CMAKE_CURRENT_BINARY_DIR } < / % text > / third_party / cares / cares <nl> PRIVATE < % text > $ { CMAKE_CURRENT_BINARY_DIR } < / % text > / third_party / gflags / include <nl> % if lib . build in [ ' test ' , ' private ' ] and lib . language = = ' c + + ' : <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> % endif <nl> % if lib . language = = ' c + + ' : <nl> PRIVATE < % text > $ { _gRPC_PROTO_GENS_DIR } < / % text > <nl> <nl> % endif <nl> % endfor <nl> % if tgt . build = = ' test ' and tgt . language = = ' c + + ' : <nl> - third_party / googletest / src / gtest - all . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> % endif <nl> ) <nl> <nl> <nl> PRIVATE < % text > $ { CMAKE_CURRENT_BINARY_DIR } < / % text > / third_party / cares / cares <nl> PRIVATE < % text > $ { CMAKE_CURRENT_BINARY_DIR } < / % text > / third_party / gflags / include <nl> % if tgt . build in [ ' test ' , ' private ' ] and tgt . language = = ' c + + ' : <nl> - PRIVATE third_party / googletest / include <nl> - PRIVATE third_party / googletest <nl> + PRIVATE third_party / googletest / googletest / include <nl> + PRIVATE third_party / googletest / googletest <nl> % endif <nl> % if tgt . language = = ' c + + ' : <nl> PRIVATE < % text > $ { _gRPC_PROTO_GENS_DIR } < / % text > <nl> mmm a / templates / Makefile . template <nl> ppp b / templates / Makefile . template <nl> <nl> USE_BUILT_PROTOC = false <nl> endif <nl> <nl> - GTEST_LIB = - Ithird_party / googletest / include - Ithird_party / googletest third_party / googletest / src / gtest - all . cc <nl> + GTEST_LIB = - Ithird_party / googletest / googletest / include - Ithird_party / googletest / googletest third_party / googletest / googletest / src / gtest - all . cc <nl> GTEST_LIB + = - lgflags <nl> ifeq ( $ ( V ) , 1 ) <nl> E = @ : <nl> <nl> PC_REQUIRES_GRPCXX = <nl> PC_LIBS_GRPCXX = <nl> <nl> - CPPFLAGS : = - Ithird_party / googletest / include $ ( CPPFLAGS ) <nl> + CPPFLAGS : = - Ithird_party / googletest / googletest / include $ ( CPPFLAGS ) <nl> <nl> PROTOC_PLUGINS_ALL = \ <nl> % for tgt in targets : <nl> mmm a / templates / binding . gyp . template <nl> ppp b / templates / binding . gyp . template <nl> <nl> # the OpenSSL headers , from the downloaded Node development package , <nl> # which is typically located in ` . node - gyp ` in your home directory . <nl> ' target_name ' : ' WINDOWS_BUILD_WARNING ' , <nl> - ' actions ' : [ <nl> + ' rules ' : [ <nl> { <nl> - ' action_name ' : ' WINDOWS_BUILD_WARNING ' , <nl> + ' rule_name ' : ' WINDOWS_BUILD_WARNING ' , <nl> + ' extension ' : ' S ' , <nl> ' inputs ' : [ <nl> ' package . json ' <nl> ] , <nl> mmm a / templates / grpc . gemspec . template <nl> ppp b / templates / grpc . gemspec . template <nl> <nl> s . files + = Dir . glob ( ' include / grpc / * * / * ' ) <nl> s . test_files = Dir . glob ( ' src / ruby / spec / * * / * ' ) <nl> s . bindir = ' src / ruby / bin ' <nl> - s . require_paths = % w ( src / ruby / bin src / ruby / lib src / ruby / pb ) <nl> + s . require_paths = % w ( src / ruby / lib src / ruby / bin src / ruby / pb ) <nl> s . platform = Gem : : Platform : : RUBY <nl> <nl> s . add_dependency ' google - protobuf ' , ' ~ > 3 . 1 ' <nl> mmm a / templates / package . json . template <nl> ppp b / templates / package . json . template <nl> <nl> " lodash " : " ^ 4 . 15 . 0 " , <nl> " nan " : " ^ 2 . 0 . 0 " , <nl> " node - pre - gyp " : " ^ 0 . 6 . 0 " , <nl> - " protobufjs " : " ^ 5 . 0 . 0 " , <nl> + " protobufjs " : " ^ 6 . 7 . 0 " , <nl> " cares " : " ^ 1 . 1 . 5 " <nl> } , <nl> " devDependencies " : { <nl> deleted file mode 100644 <nl> index aa233db586c . . 00000000000 <nl> mmm a / templates / src / csharp / Grpc . Auth / project . json . template <nl> ppp / dev / null <nl> <nl> - % YAML 1 . 2 <nl> mmm - | <nl> - { <nl> - " version " : " $ { settings . csharp_version } " , <nl> - " title " : " gRPC C # Auth " , <nl> - " authors " : [ " Google Inc . " ] , <nl> - " copyright " : " Copyright 2015 , Google Inc . " , <nl> - " packOptions " : { <nl> - " summary " : " Auth library for C # implementation of gRPC - an RPC library and framework " , <nl> - " description " : " Auth library for C # implementation of gRPC - an RPC library and framework . See project site for more info . " , <nl> - " owners " : [ " grpc - packages " ] , <nl> - " licenseUrl " : " https : / / github . com / grpc / grpc / blob / master / LICENSE " , <nl> - " projectUrl " : " https : / / github . com / grpc / grpc " , <nl> - " requireLicenseAcceptance " : false , <nl> - " tags " : [ " gRPC RPC Protocol HTTP / 2 Auth OAuth2 " ] , <nl> - } , <nl> - " buildOptions " : { <nl> - " define " : [ " SIGNED " ] , <nl> - " keyFile " : " . . / keys / Grpc . snk " , <nl> - " xmlDoc " : true , <nl> - " compile " : { <nl> - " includeFiles " : [ " . . / Grpc . Core / Version . cs " ] <nl> - } <nl> - } , <nl> - " dependencies " : { <nl> - " Grpc . Core " : " $ { settings . csharp_version } " , <nl> - " Google . Apis . Auth " : " 1 . 21 . 0 " <nl> - } , <nl> - " frameworks " : { <nl> - " net45 " : { } , <nl> - " netstandard1 . 5 " : { <nl> - " dependencies " : { <nl> - " NETStandard . Library " : " 1 . 6 . 0 " <nl> - } <nl> - } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index 7aff9911455 . . 00000000000 <nl> mmm a / templates / src / csharp / Grpc . Core . Testing / project . json . template <nl> ppp / dev / null <nl> <nl> - % YAML 1 . 2 <nl> mmm - | <nl> - { <nl> - " version " : " $ { settings . csharp_version } " , <nl> - " title " : " gRPC C # Core Testing " , <nl> - " authors " : [ " Google Inc . " ] , <nl> - " copyright " : " Copyright 2017 , Google Inc . " , <nl> - " packOptions " : { <nl> - " summary " : " Testing support for gRPC C # " , <nl> - " description " : " Useful when testing code that uses gRPC . " , <nl> - " owners " : [ " grpc - packages " ] , <nl> - " licenseUrl " : " https : / / github . com / grpc / grpc / blob / master / LICENSE " , <nl> - " projectUrl " : " https : / / github . com / grpc / grpc " , <nl> - " requireLicenseAcceptance " : false , <nl> - " tags " : [ " gRPC test testing " ] <nl> - } , <nl> - " buildOptions " : { <nl> - " define " : [ " SIGNED " ] , <nl> - " keyFile " : " . . / keys / Grpc . snk " , <nl> - " xmlDoc " : true , <nl> - " compile " : { <nl> - " includeFiles " : [ " . . / Grpc . Core / Version . cs " ] <nl> - } <nl> - } , <nl> - " dependencies " : { <nl> - " Grpc . Core " : " $ { settings . csharp_version } " <nl> - } , <nl> - " frameworks " : { <nl> - " net45 " : { <nl> - " frameworkAssemblies " : { <nl> - " System . Runtime " : " " , <nl> - " System . IO " : " " <nl> - } <nl> - } , <nl> - " netstandard1 . 5 " : { <nl> - " dependencies " : { <nl> - " NETStandard . Library " : " 1 . 6 . 0 " <nl> - } <nl> - } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index b5f8190443a . . 00000000000 <nl> mmm a / templates / src / csharp / Grpc . Core . Tests / project . json . template <nl> ppp / dev / null <nl> <nl> - % YAML 1 . 2 <nl> mmm - | <nl> - { <nl> - < % include file = " . . / build_options . include " args = " executable = True " / > <nl> - " dependencies " : { <nl> - " Grpc . Core " : { <nl> - " target " : " project " <nl> - } , <nl> - " Newtonsoft . Json " : " 9 . 0 . 1 " , <nl> - " NUnit " : " 3 . 6 . 0 " , <nl> - " NUnitLite " : " 3 . 6 . 0 " , <nl> - " NUnit . ConsoleRunner " : " 3 . 6 . 0 " , <nl> - " OpenCover " : " 4 . 6 . 519 " , <nl> - " ReportGenerator " : " 2 . 4 . 4 . 0 " <nl> - } , <nl> - " frameworks " : { <nl> - " net45 " : { } , <nl> - " netcoreapp1 . 0 " : { <nl> - " imports " : [ <nl> - " portable - net45 " <nl> - ] , <nl> - " dependencies " : { <nl> - " Microsoft . NETCore . App " : { <nl> - " type " : " platform " , <nl> - " version " : " 1 . 0 . 0 " <nl> - } <nl> - } <nl> - } <nl> - } , <nl> - } <nl> new file mode 100755 <nl> index 00000000000 . . 30b8d26375b <nl> mmm / dev / null <nl> ppp b / templates / src / csharp / Grpc . Core / Version . csproj . include . template <nl> <nl> + % YAML 1 . 2 <nl> + mmm | <nl> + < ! - - This file is generated - - > <nl> + < Project > <nl> + < PropertyGroup > <nl> + < GrpcCsharpVersion > $ { settings . csharp_version } < / GrpcCsharpVersion > <nl> + < GoogleProtobufVersion > 3 . 2 . 0 < / GoogleProtobufVersion > <nl> + < / PropertyGroup > <nl> + < / Project > <nl> deleted file mode 100644 <nl> index 120a9943e30 . . 00000000000 <nl> mmm a / templates / src / csharp / Grpc . Core / project . json . template <nl> ppp / dev / null <nl> <nl> - % YAML 1 . 2 <nl> mmm - | <nl> - { <nl> - " version " : " $ { settings . csharp_version } " , <nl> - " title " : " gRPC C # Core " , <nl> - " authors " : [ " Google Inc . " ] , <nl> - " copyright " : " Copyright 2015 , Google Inc . " , <nl> - " packOptions " : { <nl> - " summary " : " Core C # implementation of gRPC - an RPC library and framework " , <nl> - " description " : " Core C # implementation of gRPC - an RPC library and framework . See project site for more info . " , <nl> - " owners " : [ " grpc - packages " ] , <nl> - " licenseUrl " : " https : / / github . com / grpc / grpc / blob / master / LICENSE " , <nl> - " projectUrl " : " https : / / github . com / grpc / grpc " , <nl> - " requireLicenseAcceptance " : false , <nl> - " tags " : [ " gRPC RPC Protocol HTTP / 2 " ] , <nl> - " files " : { <nl> - " mappings " : { <nl> - " build / net45 / " : " Grpc . Core . targets " , <nl> - " runtimes / win / native / grpc_csharp_ext . x86 . dll " : " . . / nativelibs / windows_x86 / grpc_csharp_ext . dll " , <nl> - " runtimes / win / native / grpc_csharp_ext . x64 . dll " : " . . / nativelibs / windows_x64 / grpc_csharp_ext . dll " , <nl> - " runtimes / linux / native / libgrpc_csharp_ext . x86 . so " : " . . / nativelibs / linux_x86 / libgrpc_csharp_ext . so " , <nl> - " runtimes / linux / native / libgrpc_csharp_ext . x64 . so " : " . . / nativelibs / linux_x64 / libgrpc_csharp_ext . so " , <nl> - " runtimes / osx / native / libgrpc_csharp_ext . x86 . dylib " : " . . / nativelibs / macosx_x86 / libgrpc_csharp_ext . dylib " , <nl> - " runtimes / osx / native / libgrpc_csharp_ext . x64 . dylib " : " . . / nativelibs / macosx_x64 / libgrpc_csharp_ext . dylib " <nl> - } <nl> - } <nl> - } , <nl> - " buildOptions " : { <nl> - " embed " : [ " . . / . . / . . / etc / roots . pem " ] , <nl> - " define " : [ " SIGNED " ] , <nl> - " keyFile " : " . . / keys / Grpc . snk " , <nl> - " xmlDoc " : true <nl> - } , <nl> - " dependencies " : { <nl> - " System . Interactive . Async " : " 3 . 1 . 1 " <nl> - } , <nl> - " frameworks " : { <nl> - " net45 " : { } , <nl> - " netstandard1 . 5 " : { <nl> - " dependencies " : { <nl> - " NETStandard . Library " : " 1 . 6 . 0 " , <nl> - " System . Runtime . Loader " : " 4 . 0 . 0 " , <nl> - " System . Threading . Thread " : " 4 . 0 . 0 " <nl> - } <nl> - } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index ae4ea2aaac7 . . 00000000000 <nl> mmm a / templates / src / csharp / Grpc . Examples . MathClient / project . json . template <nl> ppp / dev / null <nl> <nl> - % YAML 1 . 2 <nl> mmm - | <nl> - { <nl> - < % include file = " . . / build_options . include " args = " executable = True " / > <nl> - " dependencies " : { <nl> - " Grpc . Examples " : { <nl> - " target " : " project " <nl> - } <nl> - } , <nl> - " frameworks " : { <nl> - " net45 " : { } , <nl> - " netcoreapp1 . 0 " : { <nl> - " dependencies " : { <nl> - " Microsoft . NETCore . App " : { <nl> - " type " : " platform " , <nl> - " version " : " 1 . 0 . 0 " <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index ae4ea2aaac7 . . 00000000000 <nl> mmm a / templates / src / csharp / Grpc . Examples . MathServer / project . json . template <nl> ppp / dev / null <nl> <nl> - % YAML 1 . 2 <nl> mmm - | <nl> - { <nl> - < % include file = " . . / build_options . include " args = " executable = True " / > <nl> - " dependencies " : { <nl> - " Grpc . Examples " : { <nl> - " target " : " project " <nl> - } <nl> - } , <nl> - " frameworks " : { <nl> - " net45 " : { } , <nl> - " netcoreapp1 . 0 " : { <nl> - " dependencies " : { <nl> - " Microsoft . NETCore . App " : { <nl> - " type " : " platform " , <nl> - " version " : " 1 . 0 . 0 " <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index da60c017a36 . . 00000000000 <nl> mmm a / templates / src / csharp / Grpc . Examples . Tests / project . json . template <nl> ppp / dev / null <nl> <nl> - % YAML 1 . 2 <nl> mmm - | <nl> - { <nl> - < % include file = " . . / build_options . include " args = " executable = True " / > <nl> - " dependencies " : { <nl> - " Grpc . Examples " : { <nl> - " target " : " project " <nl> - } , <nl> - " NUnit " : " 3 . 6 . 0 " , <nl> - " NUnitLite " : " 3 . 6 . 0 " <nl> - } , <nl> - " frameworks " : { <nl> - " net45 " : { } , <nl> - " netcoreapp1 . 0 " : { <nl> - " imports " : [ <nl> - " portable - net45 " <nl> - ] , <nl> - " dependencies " : { <nl> - " Microsoft . NETCore . App " : { <nl> - " type " : " platform " , <nl> - " version " : " 1 . 0 . 0 " <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index 5de965cb1b7 . . 00000000000 <nl> mmm a / templates / src / csharp / Grpc . Examples / project . json . template <nl> ppp / dev / null <nl> <nl> - % YAML 1 . 2 <nl> mmm - | <nl> - { <nl> - < % include file = " . . / build_options . include " args = " executable = False " / > <nl> - " dependencies " : { <nl> - " Grpc . Core " : { <nl> - " target " : " project " <nl> - } , <nl> - " Google . Protobuf " : " 3 . 2 . 0 " <nl> - } , <nl> - " frameworks " : { <nl> - " net45 " : { } , <nl> - " netcoreapp1 . 0 " : { <nl> - " dependencies " : { <nl> - " Microsoft . NETCore . App " : { <nl> - " type " : " platform " , <nl> - " version " : " 1 . 0 . 0 " <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index 4a993326c32 . . 00000000000 <nl> mmm a / templates / src / csharp / Grpc . HealthCheck . Tests / project . json . template <nl> ppp / dev / null <nl> <nl> - % YAML 1 . 2 <nl> mmm - | <nl> - { <nl> - < % include file = " . . / build_options . include " args = " executable = True " / > <nl> - " dependencies " : { <nl> - " Grpc . HealthCheck " : { <nl> - " target " : " project " <nl> - } , <nl> - " NUnit " : " 3 . 6 . 0 " , <nl> - " NUnitLite " : " 3 . 6 . 0 " <nl> - } , <nl> - " frameworks " : { <nl> - " net45 " : { } , <nl> - " netcoreapp1 . 0 " : { <nl> - " imports " : [ <nl> - " portable - net45 " <nl> - ] , <nl> - " dependencies " : { <nl> - " Microsoft . NETCore . App " : { <nl> - " type " : " platform " , <nl> - " version " : " 1 . 0 . 0 " <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index 9cd0d83a9be . . 00000000000 <nl> mmm a / templates / src / csharp / Grpc . HealthCheck / project . json . template <nl> ppp / dev / null <nl> <nl> - % YAML 1 . 2 <nl> mmm - | <nl> - { <nl> - " version " : " $ { settings . csharp_version } " , <nl> - " title " : " gRPC C # Healthchecking " , <nl> - " authors " : [ " Google Inc . " ] , <nl> - " copyright " : " Copyright 2015 , Google Inc . " , <nl> - " packOptions " : { <nl> - " summary " : " Implementation of gRPC health service " , <nl> - " description " : " Example implementation of grpc . health . v1 service that can be used for health - checking . " , <nl> - " owners " : [ " grpc - packages " ] , <nl> - " licenseUrl " : " https : / / github . com / grpc / grpc / blob / master / LICENSE " , <nl> - " projectUrl " : " https : / / github . com / grpc / grpc " , <nl> - " requireLicenseAcceptance " : false , <nl> - " tags " : [ " gRPC health check " ] <nl> - } , <nl> - " buildOptions " : { <nl> - " define " : [ " SIGNED " ] , <nl> - " keyFile " : " . . / keys / Grpc . snk " , <nl> - " xmlDoc " : true , <nl> - " compile " : { <nl> - " includeFiles " : [ " . . / Grpc . Core / Version . cs " ] <nl> - } <nl> - } , <nl> - " dependencies " : { <nl> - " Grpc . Core " : " $ { settings . csharp_version } " , <nl> - " Google . Protobuf " : " 3 . 2 . 0 " <nl> - } , <nl> - " frameworks " : { <nl> - " net45 " : { } , <nl> - " netstandard1 . 5 " : { <nl> - " dependencies " : { <nl> - " NETStandard . Library " : " 1 . 6 . 0 " <nl> - } <nl> - } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index 83b8a9befa3 . . 00000000000 <nl> mmm a / templates / src / csharp / Grpc . IntegrationTesting . Client / project . json . template <nl> ppp / dev / null <nl> <nl> - % YAML 1 . 2 <nl> mmm - | <nl> - { <nl> - < % include file = " . . / build_options . include " args = " executable = True , includeData = True " / > <nl> - " dependencies " : { <nl> - " Grpc . IntegrationTesting " : { <nl> - " target " : " project " <nl> - } <nl> - } , <nl> - " frameworks " : { <nl> - " net45 " : { } , <nl> - " netcoreapp1 . 0 " : { <nl> - " imports " : [ <nl> - " portable - net45 " <nl> - ] , <nl> - " dependencies " : { <nl> - " Microsoft . NETCore . App " : { <nl> - " type " : " platform " , <nl> - " version " : " 1 . 0 . 0 " <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index 8304d20f2ec . . 00000000000 <nl> mmm a / templates / src / csharp / Grpc . IntegrationTesting . QpsWorker / project . json . template <nl> ppp / dev / null <nl> <nl> - % YAML 1 . 2 <nl> mmm - | <nl> - { <nl> - < % include file = " . . / build_options . include " args = " executable = True , includeData = True " / > <nl> - " dependencies " : { <nl> - " Grpc . IntegrationTesting " : { <nl> - " target " : " project " <nl> - } <nl> - } , <nl> - " frameworks " : { <nl> - " net45 " : { } , <nl> - " netcoreapp1 . 0 " : { <nl> - " imports " : [ <nl> - " portable - net45 " <nl> - ] , <nl> - " dependencies " : { <nl> - " Microsoft . NETCore . App " : { <nl> - " type " : " platform " , <nl> - " version " : " 1 . 0 . 0 " <nl> - } <nl> - } <nl> - } <nl> - } , <nl> - " runtimeOptions " : { <nl> - " configProperties " : { <nl> - " System . GC . Server " : true <nl> - } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index 83b8a9befa3 . . 00000000000 <nl> mmm a / templates / src / csharp / Grpc . IntegrationTesting . Server / project . json . template <nl> ppp / dev / null <nl> <nl> - % YAML 1 . 2 <nl> mmm - | <nl> - { <nl> - < % include file = " . . / build_options . include " args = " executable = True , includeData = True " / > <nl> - " dependencies " : { <nl> - " Grpc . IntegrationTesting " : { <nl> - " target " : " project " <nl> - } <nl> - } , <nl> - " frameworks " : { <nl> - " net45 " : { } , <nl> - " netcoreapp1 . 0 " : { <nl> - " imports " : [ <nl> - " portable - net45 " <nl> - ] , <nl> - " dependencies " : { <nl> - " Microsoft . NETCore . App " : { <nl> - " type " : " platform " , <nl> - " version " : " 1 . 0 . 0 " <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index 83b8a9befa3 . . 00000000000 <nl> mmm a / templates / src / csharp / Grpc . IntegrationTesting . StressClient / project . json . template <nl> ppp / dev / null <nl> <nl> - % YAML 1 . 2 <nl> mmm - | <nl> - { <nl> - < % include file = " . . / build_options . include " args = " executable = True , includeData = True " / > <nl> - " dependencies " : { <nl> - " Grpc . IntegrationTesting " : { <nl> - " target " : " project " <nl> - } <nl> - } , <nl> - " frameworks " : { <nl> - " net45 " : { } , <nl> - " netcoreapp1 . 0 " : { <nl> - " imports " : [ <nl> - " portable - net45 " <nl> - ] , <nl> - " dependencies " : { <nl> - " Microsoft . NETCore . App " : { <nl> - " type " : " platform " , <nl> - " version " : " 1 . 0 . 0 " <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index 74b928110f1 . . 00000000000 <nl> mmm a / templates / src / csharp / Grpc . IntegrationTesting / project . json . template <nl> ppp / dev / null <nl> <nl> - % YAML 1 . 2 <nl> mmm - | <nl> - { <nl> - < % include file = " . . / build_options . include " args = " executable = True , includeData = True " / > <nl> - " dependencies " : { <nl> - " Grpc . Auth " : { <nl> - " target " : " project " <nl> - } , <nl> - " Grpc . Core " : { <nl> - " target " : " project " <nl> - } , <nl> - " Google . Protobuf " : " 3 . 2 . 0 " , <nl> - " CommandLineParser " : " 2 . 1 . 1 - beta " , <nl> - " Moq " : " 4 . 7 . 0 " , <nl> - " NUnit " : " 3 . 6 . 0 " , <nl> - " NUnitLite " : " 3 . 6 . 0 " <nl> - } , <nl> - " frameworks " : { <nl> - " net45 " : { <nl> - " frameworkAssemblies " : { } <nl> - } , <nl> - " netcoreapp1 . 0 " : { <nl> - " imports " : [ <nl> - " portable - net45 " <nl> - ] , <nl> - " dependencies " : { <nl> - " Microsoft . NETCore . App " : { <nl> - " type " : " platform " , <nl> - " version " : " 1 . 0 . 0 " <nl> - } , <nl> - " System . Linq . Expressions " : " 4 . 1 . 0 " <nl> - } <nl> - } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index 65d200e30b5 . . 00000000000 <nl> mmm a / templates / src / csharp / Grpc . Reflection . Tests / project . json . template <nl> ppp / dev / null <nl> <nl> - % YAML 1 . 2 <nl> mmm - | <nl> - { <nl> - < % include file = " . . / build_options . include " args = " executable = True " / > <nl> - " dependencies " : { <nl> - " Grpc . Reflection " : { <nl> - " target " : " project " <nl> - } , <nl> - " NUnit " : " 3 . 6 . 0 " , <nl> - " NUnitLite " : " 3 . 6 . 0 " <nl> - } , <nl> - " frameworks " : { <nl> - " net45 " : { } , <nl> - " netcoreapp1 . 0 " : { <nl> - " imports " : [ <nl> - " portable - net45 " <nl> - ] , <nl> - " dependencies " : { <nl> - " Microsoft . NETCore . App " : { <nl> - " type " : " platform " , <nl> - " version " : " 1 . 0 . 0 " <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index e6f65f8ab39 . . 00000000000 <nl> mmm a / templates / src / csharp / Grpc . Reflection / project . json . template <nl> ppp / dev / null <nl> <nl> - % YAML 1 . 2 <nl> mmm - | <nl> - { <nl> - " version " : " $ { settings . csharp_version } " , <nl> - " title " : " gRPC C # Reflection " , <nl> - " authors " : [ " Google Inc . " ] , <nl> - " copyright " : " Copyright 2016 , Google Inc . " , <nl> - " packOptions " : { <nl> - " summary " : " Implementation of gRPC reflection service " , <nl> - " description " : " Provides information about services running on a gRPC C # server . " , <nl> - " owners " : [ " grpc - packages " ] , <nl> - " licenseUrl " : " https : / / github . com / grpc / grpc / blob / master / LICENSE " , <nl> - " projectUrl " : " https : / / github . com / grpc / grpc " , <nl> - " requireLicenseAcceptance " : false , <nl> - " tags " : [ " gRPC reflection " ] <nl> - } , <nl> - " buildOptions " : { <nl> - " define " : [ " SIGNED " ] , <nl> - " keyFile " : " . . / keys / Grpc . snk " , <nl> - " xmlDoc " : true , <nl> - " compile " : { <nl> - " includeFiles " : [ " . . / Grpc . Core / Version . cs " ] <nl> - } <nl> - } , <nl> - " dependencies " : { <nl> - " Grpc . Core " : " $ { settings . csharp_version } " , <nl> - " Google . Protobuf " : " 3 . 2 . 0 " <nl> - } , <nl> - " frameworks " : { <nl> - " net45 " : { } , <nl> - " netstandard1 . 5 " : { <nl> - " dependencies " : { <nl> - " NETStandard . Library " : " 1 . 6 . 0 " <nl> - } <nl> - } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index db4cc198039 . . 00000000000 <nl> mmm a / templates / src / csharp / build_options . include <nl> ppp / dev / null <nl> <nl> - < % page args = " executable = False , includeData = False " / > \ <nl> - " buildOptions " : { <nl> - % if executable : <nl> - " emitEntryPoint " : true <nl> - % endif <nl> - } , <nl> - % if executable : <nl> - " configurations " : { <nl> - " Debug " : { <nl> - " buildOptions " : { <nl> - " define " : [ " SIGNED " ] , <nl> - " keyFile " : " . . / keys / Grpc . snk " , <nl> - " xmlDoc " : true , <nl> - " compile " : { <nl> - " includeFiles " : [ " . . / Grpc . Core / Version . cs " ] <nl> - } , <nl> - " copyToOutput " : { <nl> - " mappings " : { <nl> - % if includeData : <nl> - " data / ca . pem " : " . . / Grpc . IntegrationTesting / data / ca . pem " , <nl> - " data / server1 . key " : " . . / Grpc . IntegrationTesting / data / server1 . key " , <nl> - " data / server1 . pem " : " . . / Grpc . IntegrationTesting / data / server1 . pem " , <nl> - % endif <nl> - " grpc_csharp_ext . x64 . dll " : " . . / . . / . . / cmake / build / x64 / Debug / grpc_csharp_ext . dll " , <nl> - " grpc_csharp_ext . x86 . dll " : " . . / . . / . . / cmake / build / Win32 / Debug / grpc_csharp_ext . dll " , <nl> - " libgrpc_csharp_ext . x64 . so " : " . . / . . / . . / libs / dbg / libgrpc_csharp_ext . so " , <nl> - " libgrpc_csharp_ext . x64 . dylib " : " . . / . . / . . / libs / dbg / libgrpc_csharp_ext . dylib " <nl> - } <nl> - } <nl> - } <nl> - } , <nl> - " Release " : { <nl> - " buildOptions " : { <nl> - " define " : [ " SIGNED " ] , <nl> - " keyFile " : " . . / keys / Grpc . snk " , <nl> - " xmlDoc " : true , <nl> - " compile " : { <nl> - " includeFiles " : [ " . . / Grpc . Core / Version . cs " ] <nl> - } , <nl> - " copyToOutput " : { <nl> - " mappings " : { <nl> - % if includeData : <nl> - " data / ca . pem " : " . . / Grpc . IntegrationTesting / data / ca . pem " , <nl> - " data / server1 . key " : " . . / Grpc . IntegrationTesting / data / server1 . key " , <nl> - " data / server1 . pem " : " . . / Grpc . IntegrationTesting / data / server1 . pem " , <nl> - % endif <nl> - " grpc_csharp_ext . x64 . dll " : " . . / . . / . . / cmake / build / x64 / Release / grpc_csharp_ext . dll " , <nl> - " grpc_csharp_ext . x86 . dll " : " . . / . . / . . / cmake / build / Win32 / Release / grpc_csharp_ext . dll " , <nl> - " libgrpc_csharp_ext . x64 . so " : " . . / . . / . . / libs / opt / libgrpc_csharp_ext . so " , <nl> - " libgrpc_csharp_ext . x64 . dylib " : " . . / . . / . . / libs / opt / libgrpc_csharp_ext . dylib " <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } , <nl> - % endif <nl> mmm a / templates / src / csharp / build_packages_dotnetcli . bat . template <nl> ppp b / templates / src / csharp / build_packages_dotnetcli . bat . template <nl> <nl> <nl> @ rem Current package versions <nl> set VERSION = $ { settings . csharp_version } <nl> - set PROTOBUF_VERSION = 3 . 0 . 0 <nl> <nl> @ rem Adjust the location of nuget . exe <nl> set NUGET = C : \ nuget \ nuget . exe <nl> - set DOTNET = C : \ dotnet \ dotnet . exe <nl> + set DOTNET = dotnet <nl> <nl> set - ex <nl> <nl> <nl> xcopy / Y / I . . \ . . \ architecture = x86 , language = protoc , platform = macos \ artifacts \ * protoc_plugins \ macosx_x86 $ { " \ \ " } <nl> xcopy / Y / I . . \ . . \ architecture = x64 , language = protoc , platform = macos \ artifacts \ * protoc_plugins \ macosx_x64 $ { " \ \ " } <nl> <nl> - % % DOTNET % restore . | | goto : error <nl> + % % DOTNET % restore Grpc . sln | | goto : error <nl> <nl> - % % DOTNET % pack - - configuration Release Grpc . Core \ project . json - - output . . \ . . \ artifacts | | goto : error <nl> - % % DOTNET % pack - - configuration Release Grpc . Core . Testing \ project . json - - output . . \ . . \ artifacts | | goto : error <nl> - % % DOTNET % pack - - configuration Release Grpc . Auth \ project . json - - output . . \ . . \ artifacts | | goto : error <nl> - % % DOTNET % pack - - configuration Release Grpc . HealthCheck \ project . json - - output . . \ . . \ artifacts | | goto : error <nl> - % % DOTNET % pack - - configuration Release Grpc . Reflection \ project . json - - output . . \ . . \ artifacts | | goto : error <nl> + @ rem To be able to build , we also need to put grpc_csharp_ext to its normal location <nl> + xcopy / Y / I nativelibs \ windows_x64 \ grpc_csharp_ext . dll . . \ . . \ cmake \ build \ x64 \ Release $ { " \ \ " } <nl> + <nl> + % % DOTNET % pack - - configuration Release Grpc . Core - - output . . \ . . \ . . \ artifacts | | goto : error <nl> + % % DOTNET % pack - - configuration Release Grpc . Core . Testing - - output . . \ . . \ . . \ artifacts | | goto : error <nl> + % % DOTNET % pack - - configuration Release Grpc . Auth - - output . . \ . . \ . . \ artifacts | | goto : error <nl> + % % DOTNET % pack - - configuration Release Grpc . HealthCheck - - output . . \ . . \ . . \ artifacts | | goto : error <nl> + % % DOTNET % pack - - configuration Release Grpc . Reflection - - output . . \ . . \ . . \ artifacts | | goto : error <nl> <nl> % % NUGET % pack Grpc . nuspec - Version % VERSION % - OutputDirectory . . \ . . \ artifacts | | goto : error <nl> % % NUGET % pack Grpc . Tools . nuspec - Version % VERSION % - OutputDirectory . . \ . . \ artifacts <nl> mmm a / templates / src / csharp / build_packages_dotnetcli . sh . template <nl> ppp b / templates / src / csharp / build_packages_dotnetcli . sh . template <nl> <nl> cp $ EXTERNAL_GIT_ROOT / architecture = x86 , language = protoc , platform = macos / artifacts / * protoc_plugins / macosx_x86 | | true <nl> cp $ EXTERNAL_GIT_ROOT / architecture = x64 , language = protoc , platform = macos / artifacts / * protoc_plugins / macosx_x64 | | true <nl> <nl> - dotnet restore . <nl> + dotnet restore Grpc . sln <nl> <nl> - dotnet pack - - configuration Release Grpc . Core / project . json - - output . . / . . / artifacts <nl> - dotnet pack - - configuration Release Grpc . Core . Testing / project . json - - output . . / . . / artifacts <nl> - dotnet pack - - configuration Release Grpc . Auth / project . json - - output . . / . . / artifacts <nl> - dotnet pack - - configuration Release Grpc . HealthCheck / project . json - - output . . / . . / artifacts <nl> - dotnet pack - - configuration Release Grpc . Reflection / project . json - - output . . / . . / artifacts <nl> + # To be able to build , we also need to put grpc_csharp_ext to its normal location <nl> + mkdir - p . . / . . / libs / opt <nl> + cp nativelibs / linux_x64 / libgrpc_csharp_ext . so . . / . . / libs / opt <nl> + <nl> + dotnet pack - - configuration Release Grpc . Core - - output . . / . . / . . / artifacts <nl> + dotnet pack - - configuration Release Grpc . Core . Testing - - output . . / . . / . . / artifacts <nl> + dotnet pack - - configuration Release Grpc . Auth - - output . . / . . / . . / artifacts <nl> + dotnet pack - - configuration Release Grpc . HealthCheck - - output . . / . . / . . / artifacts <nl> + dotnet pack - - configuration Release Grpc . Reflection - - output . . / . . / . . / artifacts <nl> <nl> nuget pack Grpc . nuspec - Version " $ { settings . csharp_version } " - OutputDirectory . . / . . / artifacts <nl> nuget pack Grpc . Tools . nuspec - Version " $ { settings . csharp_version } " - OutputDirectory . . / . . / artifacts <nl> mmm a / templates / tools / dockerfile / csharp_deps . include <nl> ppp b / templates / tools / dockerfile / csharp_deps . include <nl> RUN apt - key adv - - keyserver keyserver . ubuntu . com - - recv - keys 3FA7E0328081BFF6A14 <nl> RUN echo " deb http : / / download . mono - project . com / repo / debian wheezy main " | tee / etc / apt / sources . list . d / mono - xamarin . list <nl> RUN echo " deb http : / / download . mono - project . com / repo / debian wheezy - apache24 - compat main " | tee - a / etc / apt / sources . list . d / mono - xamarin . list <nl> RUN echo " deb http : / / download . mono - project . com / repo / debian wheezy - libjpeg62 - compat main " | tee - a / etc / apt / sources . list . d / mono - xamarin . list <nl> - RUN echo " deb http : / / download . mono - project . com / repo / debian wheezy - libtiff - compat main " | tee - a / etc / apt / sources . list . d / mono - xamarin . list <nl> <nl> # Install dependencies <nl> RUN apt - get update & & apt - get - y dist - upgrade & & apt - get install - y $ { ' \ \ ' } <nl> mmm a / templates / tools / dockerfile / csharp_dotnetcli_deps . include <nl> ppp b / templates / tools / dockerfile / csharp_dotnetcli_deps . include <nl> <nl> # Install dotnet SDK based on https : / / www . microsoft . com / net / core # debian <nl> RUN apt - get update & & apt - get install - y curl libunwind8 gettext <nl> - # dotnet - dev - 1 . 0 . 0 - preview2 - 003121 <nl> - RUN curl - sSL - o dotnet100 . tar . gz https : / / go . microsoft . com / fwlink / ? LinkID = 809130 <nl> + # dotnet - dev - 1 . 0 . 0 - preview2 - 003131 <nl> + RUN curl - sSL - o dotnet100 . tar . gz https : / / go . microsoft . com / fwlink / ? LinkID = 827530 <nl> RUN mkdir - p / opt / dotnet & & tar zxf dotnet100 . tar . gz - C / opt / dotnet <nl> # dotnet - dev - 1 . 0 . 1 <nl> RUN curl - sSL - o dotnet101 . tar . gz https : / / go . microsoft . com / fwlink / ? LinkID = 843453 <nl> mmm a / templates / tools / dockerfile / interoptest / grpc_interop_csharp / Dockerfile . template <nl> ppp b / templates / tools / dockerfile / interoptest / grpc_interop_csharp / Dockerfile . template <nl> <nl> < % include file = " . . / . . / apt_get_basic . include " / > <nl> < % include file = " . . / . . / python_deps . include " / > <nl> < % include file = " . . / . . / csharp_deps . include " / > <nl> + < % include file = " . . / . . / csharp_dotnetcli_deps . include " / > <nl> < % include file = " . . / . . / run_tests_addons . include " / > <nl> # Define the default command . <nl> CMD [ " bash " ] <nl> deleted file mode 100644 <nl> index 092f04dac6c . . 00000000000 <nl> mmm a / templates / tools / dockerfile / interoptest / grpc_interop_csharpcoreclr / Dockerfile . template <nl> ppp / dev / null <nl> <nl> - % YAML 1 . 2 <nl> mmm - | <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> - FROM debian : jessie <nl> - <nl> - < % include file = " . . / . . / apt_get_basic . include " / > <nl> - < % include file = " . . / . . / python_deps . include " / > <nl> - < % include file = " . . / . . / csharp_deps . include " / > <nl> - < % include file = " . . / . . / csharp_dotnetcli_deps . include " / > <nl> - < % include file = " . . / . . / run_tests_addons . include " / > <nl> - # Define the default command . <nl> - CMD [ " bash " ] <nl> - <nl> deleted file mode 100644 <nl> index 092f04dac6c . . 00000000000 <nl> mmm a / templates / tools / dockerfile / test / csharp_coreclr_x64 / Dockerfile . template <nl> ppp / dev / null <nl> <nl> - % YAML 1 . 2 <nl> mmm - | <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> - FROM debian : jessie <nl> - <nl> - < % include file = " . . / . . / apt_get_basic . include " / > <nl> - < % include file = " . . / . . / python_deps . include " / > <nl> - < % include file = " . . / . . / csharp_deps . include " / > <nl> - < % include file = " . . / . . / csharp_dotnetcli_deps . include " / > <nl> - < % include file = " . . / . . / run_tests_addons . include " / > <nl> - # Define the default command . <nl> - CMD [ " bash " ] <nl> - <nl> mmm a / templates / tools / dockerfile / test / csharp_jessie_x64 / Dockerfile . template <nl> ppp b / templates / tools / dockerfile / test / csharp_jessie_x64 / Dockerfile . template <nl> <nl> < % include file = " . . / . . / apt_get_basic . include " / > <nl> < % include file = " . . / . . / python_deps . include " / > <nl> < % include file = " . . / . . / csharp_deps . include " / > <nl> + < % include file = " . . / . . / csharp_dotnetcli_deps . include " / > <nl> < % include file = " . . / . . / run_tests_addons . include " / > <nl> # Define the default command . <nl> CMD [ " bash " ] <nl> mmm a / test / core / bad_client / bad_client . c <nl> ppp b / test / core / bad_client / bad_client . c <nl> void grpc_run_bad_client_test ( <nl> grpc_init ( ) ; <nl> <nl> / * Create endpoints * / <nl> - grpc_resource_quota * resource_quota = <nl> - grpc_resource_quota_create ( " bad_client_test " ) ; <nl> - sfd = grpc_iomgr_create_endpoint_pair ( " fixture " , resource_quota , 65536 ) ; <nl> - grpc_resource_quota_unref_internal ( & exec_ctx , resource_quota ) ; <nl> + sfd = grpc_iomgr_create_endpoint_pair ( " fixture " , NULL ) ; <nl> <nl> / * Create server , completion events * / <nl> a . server = grpc_server_create ( NULL , NULL ) ; <nl> mmm a / test / core / end2end / fixtures / h2_sockpair + trace . c <nl> ppp b / test / core / end2end / fixtures / h2_sockpair + trace . c <nl> static grpc_end2end_test_fixture chttp2_create_fixture_socketpair ( <nl> f . fixture_data = sfd ; <nl> f . cq = grpc_completion_queue_create ( NULL ) ; <nl> <nl> - grpc_resource_quota * resource_quota = grpc_resource_quota_create ( " fixture " ) ; <nl> - * sfd = grpc_iomgr_create_endpoint_pair ( " fixture " , resource_quota , 65536 ) ; <nl> - grpc_resource_quota_unref ( resource_quota ) ; <nl> + * sfd = grpc_iomgr_create_endpoint_pair ( " fixture " , NULL ) ; <nl> <nl> return f ; <nl> } <nl> mmm a / test / core / end2end / fixtures / h2_sockpair . c <nl> ppp b / test / core / end2end / fixtures / h2_sockpair . c <nl> static grpc_end2end_test_fixture chttp2_create_fixture_socketpair ( <nl> f . fixture_data = sfd ; <nl> f . cq = grpc_completion_queue_create ( NULL ) ; <nl> <nl> - grpc_resource_quota * resource_quota = grpc_resource_quota_create ( " fixture " ) ; <nl> - * sfd = grpc_iomgr_create_endpoint_pair ( " fixture " , resource_quota , 65536 ) ; <nl> - grpc_resource_quota_unref ( resource_quota ) ; <nl> + * sfd = grpc_iomgr_create_endpoint_pair ( " fixture " , NULL ) ; <nl> <nl> return f ; <nl> } <nl> mmm a / test / core / end2end / fixtures / h2_sockpair_1byte . c <nl> ppp b / test / core / end2end / fixtures / h2_sockpair_1byte . c <nl> static grpc_end2end_test_fixture chttp2_create_fixture_socketpair ( <nl> f . fixture_data = sfd ; <nl> f . cq = grpc_completion_queue_create ( NULL ) ; <nl> <nl> - grpc_resource_quota * resource_quota = grpc_resource_quota_create ( " fixture " ) ; <nl> - * sfd = grpc_iomgr_create_endpoint_pair ( " fixture " , resource_quota , 1 ) ; <nl> - grpc_resource_quota_unref ( resource_quota ) ; <nl> + grpc_arg a [ ] = { { . key = GRPC_ARG_TCP_READ_CHUNK_SIZE , <nl> + . type = GRPC_ARG_INTEGER , <nl> + . value . integer = 1 } , <nl> + { . key = GRPC_ARG_TCP_MIN_READ_CHUNK_SIZE , <nl> + . type = GRPC_ARG_INTEGER , <nl> + . value . integer = 1 } , <nl> + { . key = GRPC_ARG_TCP_MAX_READ_CHUNK_SIZE , <nl> + . type = GRPC_ARG_INTEGER , <nl> + . value . integer = 1 } } ; <nl> + grpc_channel_args args = { . num_args = GPR_ARRAY_SIZE ( a ) , . args = a } ; <nl> + * sfd = grpc_iomgr_create_endpoint_pair ( " fixture " , & args ) ; <nl> <nl> return f ; <nl> } <nl> new file mode 100644 <nl> index 00000000000 . . 4c6eb601ae3 <nl> Binary files / dev / null and b / test / core / end2end / fuzzers / server_fuzzer_corpus / clusterfuzz - testcase - 6312731374256128 differ <nl> mmm a / test / core / end2end / invalid_call_argument_test . c <nl> ppp b / test / core / end2end / invalid_call_argument_test . c <nl> <nl> * <nl> * / <nl> <nl> + # include < grpc / impl / codegen / port_platform . h > <nl> + <nl> # include < limits . h > <nl> # include < string . h > <nl> <nl> mmm a / test / core / end2end / tests / filter_call_init_fails . c <nl> ppp b / test / core / end2end / tests / filter_call_init_fails . c <nl> <nl> <nl> enum { TIMEOUT = 200000 } ; <nl> <nl> - static bool g_enable_filter = false ; <nl> + static bool g_enable_server_channel_filter = false ; <nl> + static bool g_enable_client_channel_filter = false ; <nl> + static bool g_enable_client_subchannel_filter = false ; <nl> <nl> static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> <nl> static void end_test ( grpc_end2end_test_fixture * f ) { <nl> grpc_completion_queue_destroy ( f - > cq ) ; <nl> } <nl> <nl> - / / Simple request via a server filter that always fails to initialize <nl> - / / the call . <nl> - static void test_request ( grpc_end2end_test_config config ) { <nl> + / / Simple request via a SERVER_CHANNEL filter that always fails to <nl> + / / initialize the call . <nl> + static void test_server_channel_filter ( grpc_end2end_test_config config ) { <nl> grpc_call * c ; <nl> grpc_call * s ; <nl> grpc_slice request_payload_slice = <nl> static void test_request ( grpc_end2end_test_config config ) { <nl> config . tear_down_data ( & f ) ; <nl> } <nl> <nl> + / / Simple request via a CLIENT_CHANNEL or CLIENT_DIRECT_CHANNEL filter <nl> + / / that always fails to initialize the call . <nl> + static void test_client_channel_filter ( grpc_end2end_test_config config ) { <nl> + grpc_call * c ; <nl> + grpc_slice request_payload_slice = <nl> + grpc_slice_from_copied_string ( " hello world " ) ; <nl> + grpc_byte_buffer * request_payload = <nl> + grpc_raw_byte_buffer_create ( & request_payload_slice , 1 ) ; <nl> + gpr_timespec deadline = five_seconds_from_now ( ) ; <nl> + grpc_end2end_test_fixture f = <nl> + begin_test ( config , " filter_call_init_fails " , NULL , NULL ) ; <nl> + cq_verifier * cqv = cq_verifier_create ( f . cq ) ; <nl> + grpc_op ops [ 6 ] ; <nl> + grpc_op * op ; <nl> + grpc_metadata_array initial_metadata_recv ; <nl> + grpc_metadata_array trailing_metadata_recv ; <nl> + grpc_metadata_array request_metadata_recv ; <nl> + grpc_byte_buffer * request_payload_recv = NULL ; <nl> + grpc_call_details call_details ; <nl> + grpc_status_code status ; <nl> + grpc_call_error error ; <nl> + grpc_slice details ; <nl> + <nl> + c = grpc_channel_create_call ( <nl> + f . client , NULL , GRPC_PROPAGATE_DEFAULTS , f . cq , <nl> + grpc_slice_from_static_string ( " / foo " ) , <nl> + get_host_override_slice ( " foo . test . google . fr : 1234 " , config ) , deadline , <nl> + NULL ) ; <nl> + GPR_ASSERT ( c ) ; <nl> + <nl> + grpc_metadata_array_init ( & initial_metadata_recv ) ; <nl> + grpc_metadata_array_init ( & trailing_metadata_recv ) ; <nl> + grpc_metadata_array_init ( & request_metadata_recv ) ; <nl> + grpc_call_details_init ( & call_details ) ; <nl> + <nl> + memset ( ops , 0 , sizeof ( ops ) ) ; <nl> + op = ops ; <nl> + op - > op = GRPC_OP_SEND_INITIAL_METADATA ; <nl> + op - > data . send_initial_metadata . count = 0 ; <nl> + op - > data . send_initial_metadata . metadata = NULL ; <nl> + op - > flags = 0 ; <nl> + op - > reserved = NULL ; <nl> + op + + ; <nl> + op - > op = GRPC_OP_SEND_MESSAGE ; <nl> + op - > data . send_message . send_message = request_payload ; <nl> + op - > flags = 0 ; <nl> + op - > reserved = NULL ; <nl> + op + + ; <nl> + op - > op = GRPC_OP_SEND_CLOSE_FROM_CLIENT ; <nl> + op - > flags = 0 ; <nl> + op - > reserved = NULL ; <nl> + op + + ; <nl> + op - > op = GRPC_OP_RECV_INITIAL_METADATA ; <nl> + op - > data . recv_initial_metadata . recv_initial_metadata = & initial_metadata_recv ; <nl> + op - > flags = 0 ; <nl> + op - > reserved = NULL ; <nl> + op + + ; <nl> + op - > op = GRPC_OP_RECV_STATUS_ON_CLIENT ; <nl> + op - > data . recv_status_on_client . trailing_metadata = & trailing_metadata_recv ; <nl> + op - > data . recv_status_on_client . status = & status ; <nl> + op - > data . recv_status_on_client . status_details = & details ; <nl> + op - > flags = 0 ; <nl> + op - > reserved = NULL ; <nl> + op + + ; <nl> + error = grpc_call_start_batch ( c , ops , ( size_t ) ( op - ops ) , tag ( 1 ) , NULL ) ; <nl> + GPR_ASSERT ( GRPC_CALL_OK = = error ) ; <nl> + <nl> + CQ_EXPECT_COMPLETION ( cqv , tag ( 1 ) , 1 ) ; <nl> + cq_verify ( cqv ) ; <nl> + <nl> + GPR_ASSERT ( status = = GRPC_STATUS_PERMISSION_DENIED ) ; <nl> + GPR_ASSERT ( 0 = = grpc_slice_str_cmp ( details , " access denied " ) ) ; <nl> + <nl> + grpc_slice_unref ( details ) ; <nl> + grpc_metadata_array_destroy ( & initial_metadata_recv ) ; <nl> + grpc_metadata_array_destroy ( & trailing_metadata_recv ) ; <nl> + grpc_metadata_array_destroy ( & request_metadata_recv ) ; <nl> + grpc_call_details_destroy ( & call_details ) ; <nl> + <nl> + grpc_call_destroy ( c ) ; <nl> + <nl> + cq_verifier_destroy ( cqv ) ; <nl> + <nl> + grpc_byte_buffer_destroy ( request_payload ) ; <nl> + grpc_byte_buffer_destroy ( request_payload_recv ) ; <nl> + <nl> + end_test ( & f ) ; <nl> + config . tear_down_data ( & f ) ; <nl> + } <nl> + <nl> + / / Simple request via a CLIENT_SUBCHANNEL filter that always fails to <nl> + / / initialize the call . <nl> + static void test_client_subchannel_filter ( grpc_end2end_test_config config ) { <nl> + grpc_call * c ; <nl> + grpc_slice request_payload_slice = <nl> + grpc_slice_from_copied_string ( " hello world " ) ; <nl> + grpc_byte_buffer * request_payload = <nl> + grpc_raw_byte_buffer_create ( & request_payload_slice , 1 ) ; <nl> + gpr_timespec deadline = five_seconds_from_now ( ) ; <nl> + grpc_end2end_test_fixture f = <nl> + begin_test ( config , " filter_call_init_fails " , NULL , NULL ) ; <nl> + cq_verifier * cqv = cq_verifier_create ( f . cq ) ; <nl> + grpc_op ops [ 6 ] ; <nl> + grpc_op * op ; <nl> + grpc_metadata_array initial_metadata_recv ; <nl> + grpc_metadata_array trailing_metadata_recv ; <nl> + grpc_metadata_array request_metadata_recv ; <nl> + grpc_byte_buffer * request_payload_recv = NULL ; <nl> + grpc_call_details call_details ; <nl> + grpc_status_code status ; <nl> + grpc_call_error error ; <nl> + grpc_slice details ; <nl> + <nl> + c = grpc_channel_create_call ( <nl> + f . client , NULL , GRPC_PROPAGATE_DEFAULTS , f . cq , <nl> + grpc_slice_from_static_string ( " / foo " ) , <nl> + get_host_override_slice ( " foo . test . google . fr : 1234 " , config ) , deadline , <nl> + NULL ) ; <nl> + GPR_ASSERT ( c ) ; <nl> + <nl> + grpc_metadata_array_init ( & initial_metadata_recv ) ; <nl> + grpc_metadata_array_init ( & trailing_metadata_recv ) ; <nl> + grpc_metadata_array_init ( & request_metadata_recv ) ; <nl> + grpc_call_details_init ( & call_details ) ; <nl> + <nl> + memset ( ops , 0 , sizeof ( ops ) ) ; <nl> + op = ops ; <nl> + op - > op = GRPC_OP_SEND_INITIAL_METADATA ; <nl> + op - > data . send_initial_metadata . count = 0 ; <nl> + op - > data . send_initial_metadata . metadata = NULL ; <nl> + op - > flags = 0 ; <nl> + op - > reserved = NULL ; <nl> + op + + ; <nl> + op - > op = GRPC_OP_SEND_MESSAGE ; <nl> + op - > data . send_message . send_message = request_payload ; <nl> + op - > flags = 0 ; <nl> + op - > reserved = NULL ; <nl> + op + + ; <nl> + op - > op = GRPC_OP_SEND_CLOSE_FROM_CLIENT ; <nl> + op - > flags = 0 ; <nl> + op - > reserved = NULL ; <nl> + op + + ; <nl> + op - > op = GRPC_OP_RECV_INITIAL_METADATA ; <nl> + op - > data . recv_initial_metadata . recv_initial_metadata = & initial_metadata_recv ; <nl> + op - > flags = 0 ; <nl> + op - > reserved = NULL ; <nl> + op + + ; <nl> + op - > op = GRPC_OP_RECV_STATUS_ON_CLIENT ; <nl> + op - > data . recv_status_on_client . trailing_metadata = & trailing_metadata_recv ; <nl> + op - > data . recv_status_on_client . status = & status ; <nl> + op - > data . recv_status_on_client . status_details = & details ; <nl> + op - > flags = 0 ; <nl> + op - > reserved = NULL ; <nl> + op + + ; <nl> + <nl> + error = grpc_call_start_batch ( c , ops , ( size_t ) ( op - ops ) , tag ( 1 ) , NULL ) ; <nl> + GPR_ASSERT ( GRPC_CALL_OK = = error ) ; <nl> + <nl> + CQ_EXPECT_COMPLETION ( cqv , tag ( 1 ) , 1 ) ; <nl> + cq_verify ( cqv ) ; <nl> + <nl> + GPR_ASSERT ( status = = GRPC_STATUS_PERMISSION_DENIED ) ; <nl> + GPR_ASSERT ( 0 = = grpc_slice_str_cmp ( details , " access denied " ) ) ; <nl> + <nl> + / / Reset and create a new call . ( The first call uses a different code <nl> + / / path in client_channel . c than subsequent calls on the same channel , <nl> + / / and we need to test both . ) <nl> + grpc_call_destroy ( c ) ; <nl> + status = GRPC_STATUS_OK ; <nl> + grpc_slice_unref ( details ) ; <nl> + details = grpc_empty_slice ( ) ; <nl> + <nl> + c = grpc_channel_create_call ( <nl> + f . client , NULL , GRPC_PROPAGATE_DEFAULTS , f . cq , <nl> + grpc_slice_from_static_string ( " / foo " ) , <nl> + get_host_override_slice ( " foo . test . google . fr : 1234 " , config ) , deadline , <nl> + NULL ) ; <nl> + GPR_ASSERT ( c ) ; <nl> + <nl> + error = grpc_call_start_batch ( c , ops , ( size_t ) ( op - ops ) , tag ( 2 ) , NULL ) ; <nl> + GPR_ASSERT ( GRPC_CALL_OK = = error ) ; <nl> + <nl> + CQ_EXPECT_COMPLETION ( cqv , tag ( 2 ) , 1 ) ; <nl> + cq_verify ( cqv ) ; <nl> + <nl> + GPR_ASSERT ( status = = GRPC_STATUS_PERMISSION_DENIED ) ; <nl> + GPR_ASSERT ( 0 = = grpc_slice_str_cmp ( details , " access denied " ) ) ; <nl> + <nl> + grpc_slice_unref ( details ) ; <nl> + grpc_metadata_array_destroy ( & initial_metadata_recv ) ; <nl> + grpc_metadata_array_destroy ( & trailing_metadata_recv ) ; <nl> + grpc_metadata_array_destroy ( & request_metadata_recv ) ; <nl> + grpc_call_details_destroy ( & call_details ) ; <nl> + <nl> + grpc_call_destroy ( c ) ; <nl> + <nl> + cq_verifier_destroy ( cqv ) ; <nl> + <nl> + grpc_byte_buffer_destroy ( request_payload ) ; <nl> + grpc_byte_buffer_destroy ( request_payload_recv ) ; <nl> + <nl> + end_test ( & f ) ; <nl> + config . tear_down_data ( & f ) ; <nl> + } <nl> + <nl> / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> * Test filter - always fails to initialize a call <nl> * / <nl> static const grpc_channel_filter test_filter = { <nl> * Registration <nl> * / <nl> <nl> - static bool maybe_add_filter ( grpc_exec_ctx * exec_ctx , <nl> - grpc_channel_stack_builder * builder , void * arg ) { <nl> - if ( g_enable_filter ) { <nl> + static bool maybe_add_server_channel_filter ( grpc_exec_ctx * exec_ctx , <nl> + grpc_channel_stack_builder * builder , <nl> + void * arg ) { <nl> + if ( g_enable_server_channel_filter ) { <nl> / / Want to add the filter as close to the end as possible , to make <nl> / / sure that all of the filters work well together . However , we <nl> / / can ' t add it at the very end , because the connected channel filter <nl> static bool maybe_add_filter ( grpc_exec_ctx * exec_ctx , <nl> } <nl> } <nl> <nl> + static bool maybe_add_client_channel_filter ( grpc_exec_ctx * exec_ctx , <nl> + grpc_channel_stack_builder * builder , <nl> + void * arg ) { <nl> + if ( g_enable_client_channel_filter ) { <nl> + / / Want to add the filter as close to the end as possible , to make <nl> + / / sure that all of the filters work well together . However , we <nl> + / / can ' t add it at the very end , because the connected channel filter <nl> + / / must be the last one . So we add it right before the last one . <nl> + grpc_channel_stack_builder_iterator * it = <nl> + grpc_channel_stack_builder_create_iterator_at_last ( builder ) ; <nl> + GPR_ASSERT ( grpc_channel_stack_builder_move_prev ( it ) ) ; <nl> + const bool retval = grpc_channel_stack_builder_add_filter_before ( <nl> + it , & test_filter , NULL , NULL ) ; <nl> + grpc_channel_stack_builder_iterator_destroy ( it ) ; <nl> + return retval ; <nl> + } else { <nl> + return true ; <nl> + } <nl> + } <nl> + <nl> + static bool maybe_add_client_subchannel_filter ( <nl> + grpc_exec_ctx * exec_ctx , grpc_channel_stack_builder * builder , void * arg ) { <nl> + if ( g_enable_client_subchannel_filter ) { <nl> + / / Want to add the filter as close to the end as possible , to make <nl> + / / sure that all of the filters work well together . However , we <nl> + / / can ' t add it at the very end , because the client channel filter <nl> + / / must be the last one . So we add it right before the last one . <nl> + grpc_channel_stack_builder_iterator * it = <nl> + grpc_channel_stack_builder_create_iterator_at_last ( builder ) ; <nl> + GPR_ASSERT ( grpc_channel_stack_builder_move_prev ( it ) ) ; <nl> + const bool retval = grpc_channel_stack_builder_add_filter_before ( <nl> + it , & test_filter , NULL , NULL ) ; <nl> + grpc_channel_stack_builder_iterator_destroy ( it ) ; <nl> + return retval ; <nl> + } else { <nl> + return true ; <nl> + } <nl> + } <nl> + <nl> static void init_plugin ( void ) { <nl> grpc_channel_init_register_stage ( GRPC_SERVER_CHANNEL , INT_MAX , <nl> - maybe_add_filter , NULL ) ; <nl> + maybe_add_server_channel_filter , NULL ) ; <nl> + grpc_channel_init_register_stage ( GRPC_CLIENT_CHANNEL , INT_MAX , <nl> + maybe_add_client_channel_filter , NULL ) ; <nl> + grpc_channel_init_register_stage ( GRPC_CLIENT_SUBCHANNEL , INT_MAX , <nl> + maybe_add_client_subchannel_filter , NULL ) ; <nl> + grpc_channel_init_register_stage ( GRPC_CLIENT_DIRECT_CHANNEL , INT_MAX , <nl> + maybe_add_client_channel_filter , NULL ) ; <nl> } <nl> <nl> static void destroy_plugin ( void ) { } <nl> <nl> void filter_call_init_fails ( grpc_end2end_test_config config ) { <nl> - g_enable_filter = true ; <nl> - test_request ( config ) ; <nl> - g_enable_filter = false ; <nl> + gpr_log ( GPR_INFO , " Testing SERVER_CHANNEL filter . " ) ; <nl> + g_enable_server_channel_filter = true ; <nl> + test_server_channel_filter ( config ) ; <nl> + g_enable_server_channel_filter = false ; <nl> + gpr_log ( GPR_INFO , " Testing CLIENT_CHANNEL / CLIENT_DIRECT_CHANNEL filter . " ) ; <nl> + g_enable_client_channel_filter = true ; <nl> + test_client_channel_filter ( config ) ; <nl> + g_enable_client_channel_filter = false ; <nl> + if ( config . feature_mask & FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL ) { <nl> + gpr_log ( GPR_INFO , " Testing CLIENT_SUBCHANNEL filter . " ) ; <nl> + g_enable_client_subchannel_filter = true ; <nl> + test_client_subchannel_filter ( config ) ; <nl> + g_enable_client_subchannel_filter = false ; <nl> + } <nl> } <nl> <nl> void filter_call_init_fails_pre_init ( void ) { <nl> mmm a / test / core / end2end / tests / max_connection_idle . c <nl> ppp b / test / core / end2end / tests / max_connection_idle . c <nl> <nl> # include < limits . h > <nl> # include < string . h > <nl> <nl> + # include < grpc / support / alloc . h > <nl> # include < grpc / support / log . h > <nl> # include < grpc / support / sync . h > <nl> # include < grpc / support / time . h > <nl> <nl> <nl> static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> <nl> + static void drain_cq ( grpc_completion_queue * cq ) { <nl> + grpc_event ev ; <nl> + do { <nl> + ev = grpc_completion_queue_next ( cq , grpc_timeout_seconds_to_deadline ( 5 ) , <nl> + NULL ) ; <nl> + } while ( ev . type ! = GRPC_QUEUE_SHUTDOWN ) ; <nl> + } <nl> + <nl> + static void simple_request_body ( grpc_end2end_test_config config , <nl> + grpc_end2end_test_fixture * f ) { <nl> + grpc_call * c ; <nl> + grpc_call * s ; <nl> + cq_verifier * cqv = cq_verifier_create ( f - > cq ) ; <nl> + grpc_op ops [ 6 ] ; <nl> + grpc_op * op ; <nl> + grpc_metadata_array initial_metadata_recv ; <nl> + grpc_metadata_array trailing_metadata_recv ; <nl> + grpc_metadata_array request_metadata_recv ; <nl> + grpc_call_details call_details ; <nl> + grpc_status_code status ; <nl> + grpc_call_error error ; <nl> + grpc_slice details ; <nl> + int was_cancelled = 2 ; <nl> + char * peer ; <nl> + <nl> + gpr_timespec deadline = grpc_timeout_seconds_to_deadline ( 5 ) ; <nl> + c = grpc_channel_create_call ( <nl> + f - > client , NULL , GRPC_PROPAGATE_DEFAULTS , f - > cq , <nl> + grpc_slice_from_static_string ( " / foo " ) , <nl> + get_host_override_slice ( " foo . test . google . fr : 1234 " , config ) , deadline , <nl> + NULL ) ; <nl> + GPR_ASSERT ( c ) ; <nl> + <nl> + peer = grpc_call_get_peer ( c ) ; <nl> + GPR_ASSERT ( peer ! = NULL ) ; <nl> + gpr_log ( GPR_DEBUG , " client_peer_before_call = % s " , peer ) ; <nl> + gpr_free ( peer ) ; <nl> + <nl> + grpc_metadata_array_init ( & initial_metadata_recv ) ; <nl> + grpc_metadata_array_init ( & trailing_metadata_recv ) ; <nl> + grpc_metadata_array_init ( & request_metadata_recv ) ; <nl> + grpc_call_details_init ( & call_details ) ; <nl> + <nl> + memset ( ops , 0 , sizeof ( ops ) ) ; <nl> + op = ops ; <nl> + op - > op = GRPC_OP_SEND_INITIAL_METADATA ; <nl> + op - > data . send_initial_metadata . count = 0 ; <nl> + op - > flags = 0 ; <nl> + op - > reserved = NULL ; <nl> + op + + ; <nl> + op - > op = GRPC_OP_SEND_CLOSE_FROM_CLIENT ; <nl> + op - > flags = 0 ; <nl> + op - > reserved = NULL ; <nl> + op + + ; <nl> + op - > op = GRPC_OP_RECV_INITIAL_METADATA ; <nl> + op - > data . recv_initial_metadata . recv_initial_metadata = & initial_metadata_recv ; <nl> + op - > flags = 0 ; <nl> + op - > reserved = NULL ; <nl> + op + + ; <nl> + op - > op = GRPC_OP_RECV_STATUS_ON_CLIENT ; <nl> + op - > data . recv_status_on_client . trailing_metadata = & trailing_metadata_recv ; <nl> + op - > data . recv_status_on_client . status = & status ; <nl> + op - > data . recv_status_on_client . status_details = & details ; <nl> + op - > flags = 0 ; <nl> + op - > reserved = NULL ; <nl> + op + + ; <nl> + error = grpc_call_start_batch ( c , ops , ( size_t ) ( op - ops ) , tag ( 1 ) , NULL ) ; <nl> + GPR_ASSERT ( GRPC_CALL_OK = = error ) ; <nl> + <nl> + error = <nl> + grpc_server_request_call ( f - > server , & s , & call_details , <nl> + & request_metadata_recv , f - > cq , f - > cq , tag ( 101 ) ) ; <nl> + GPR_ASSERT ( GRPC_CALL_OK = = error ) ; <nl> + CQ_EXPECT_COMPLETION ( cqv , tag ( 101 ) , 1 ) ; <nl> + cq_verify ( cqv ) ; <nl> + <nl> + peer = grpc_call_get_peer ( s ) ; <nl> + GPR_ASSERT ( peer ! = NULL ) ; <nl> + gpr_log ( GPR_DEBUG , " server_peer = % s " , peer ) ; <nl> + gpr_free ( peer ) ; <nl> + peer = grpc_call_get_peer ( c ) ; <nl> + GPR_ASSERT ( peer ! = NULL ) ; <nl> + gpr_log ( GPR_DEBUG , " client_peer = % s " , peer ) ; <nl> + gpr_free ( peer ) ; <nl> + <nl> + memset ( ops , 0 , sizeof ( ops ) ) ; <nl> + op = ops ; <nl> + op - > op = GRPC_OP_SEND_INITIAL_METADATA ; <nl> + op - > data . send_initial_metadata . count = 0 ; <nl> + op - > flags = 0 ; <nl> + op - > reserved = NULL ; <nl> + op + + ; <nl> + op - > op = GRPC_OP_SEND_STATUS_FROM_SERVER ; <nl> + op - > data . send_status_from_server . trailing_metadata_count = 0 ; <nl> + op - > data . send_status_from_server . status = GRPC_STATUS_UNIMPLEMENTED ; <nl> + grpc_slice status_details = grpc_slice_from_static_string ( " xyz " ) ; <nl> + op - > data . send_status_from_server . status_details = & status_details ; <nl> + op - > flags = 0 ; <nl> + op - > reserved = NULL ; <nl> + op + + ; <nl> + op - > op = GRPC_OP_RECV_CLOSE_ON_SERVER ; <nl> + op - > data . recv_close_on_server . cancelled = & was_cancelled ; <nl> + op - > flags = 0 ; <nl> + op - > reserved = NULL ; <nl> + op + + ; <nl> + error = grpc_call_start_batch ( s , ops , ( size_t ) ( op - ops ) , tag ( 102 ) , NULL ) ; <nl> + GPR_ASSERT ( GRPC_CALL_OK = = error ) ; <nl> + <nl> + CQ_EXPECT_COMPLETION ( cqv , tag ( 102 ) , 1 ) ; <nl> + CQ_EXPECT_COMPLETION ( cqv , tag ( 1 ) , 1 ) ; <nl> + cq_verify ( cqv ) ; <nl> + <nl> + GPR_ASSERT ( status = = GRPC_STATUS_UNIMPLEMENTED ) ; <nl> + GPR_ASSERT ( 0 = = grpc_slice_str_cmp ( details , " xyz " ) ) ; <nl> + GPR_ASSERT ( 0 = = grpc_slice_str_cmp ( call_details . method , " / foo " ) ) ; <nl> + validate_host_override_string ( " foo . test . google . fr : 1234 " , call_details . host , <nl> + config ) ; <nl> + GPR_ASSERT ( 0 = = call_details . flags ) ; <nl> + GPR_ASSERT ( was_cancelled = = 1 ) ; <nl> + <nl> + grpc_slice_unref ( details ) ; <nl> + grpc_metadata_array_destroy ( & initial_metadata_recv ) ; <nl> + grpc_metadata_array_destroy ( & trailing_metadata_recv ) ; <nl> + grpc_metadata_array_destroy ( & request_metadata_recv ) ; <nl> + grpc_call_details_destroy ( & call_details ) ; <nl> + <nl> + grpc_call_destroy ( c ) ; <nl> + grpc_call_destroy ( s ) ; <nl> + <nl> + cq_verifier_destroy ( cqv ) ; <nl> + } <nl> + <nl> static void test_max_connection_idle ( grpc_end2end_test_config config ) { <nl> grpc_end2end_test_fixture f = config . create_fixture ( NULL , NULL ) ; <nl> grpc_connectivity_state state = GRPC_CHANNEL_IDLE ; <nl> static void test_max_connection_idle ( grpc_end2end_test_config config ) { <nl> state = = GRPC_CHANNEL_TRANSIENT_FAILURE ) ; <nl> } <nl> <nl> + / * Use a simple request to cancel and reset the max idle timer * / <nl> + simple_request_body ( config , & f ) ; <nl> + <nl> / * wait for the channel to reach its maximum idle time * / <nl> grpc_channel_watch_connectivity_state ( <nl> f . client , GRPC_CHANNEL_READY , <nl> static void test_max_connection_idle ( grpc_end2end_test_config config ) { <nl> grpc_server_destroy ( f . server ) ; <nl> grpc_channel_destroy ( f . client ) ; <nl> grpc_completion_queue_shutdown ( f . cq ) ; <nl> + drain_cq ( f . cq ) ; <nl> grpc_completion_queue_destroy ( f . cq ) ; <nl> config . tear_down_data ( & f ) ; <nl> <nl> mmm a / test / core / iomgr / endpoint_pair_test . c <nl> ppp b / test / core / iomgr / endpoint_pair_test . c <nl> static grpc_endpoint_test_fixture create_fixture_endpoint_pair ( <nl> size_t slice_size ) { <nl> grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT ; <nl> grpc_endpoint_test_fixture f ; <nl> - grpc_resource_quota * resource_quota = <nl> - grpc_resource_quota_create ( " endpoint_pair_test " ) ; <nl> - grpc_endpoint_pair p = <nl> - grpc_iomgr_create_endpoint_pair ( " test " , resource_quota , slice_size ) ; <nl> - grpc_resource_quota_unref ( resource_quota ) ; <nl> + grpc_arg a [ ] = { { . key = GRPC_ARG_TCP_READ_CHUNK_SIZE , <nl> + . type = GRPC_ARG_INTEGER , <nl> + . value . integer = ( int ) slice_size } } ; <nl> + grpc_channel_args args = { . num_args = GPR_ARRAY_SIZE ( a ) , . args = a } ; <nl> + grpc_endpoint_pair p = grpc_iomgr_create_endpoint_pair ( " test " , & args ) ; <nl> <nl> f . client_ep = p . client ; <nl> f . server_ep = p . server ; <nl> mmm a / test / core / iomgr / error_test . c <nl> ppp b / test / core / iomgr / error_test . c <nl> static void print_error_string_reference ( ) { <nl> grpc_error * parent = <nl> GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING ( " Parent " , children , 2 ) ; <nl> <nl> - gpr_log ( GPR_DEBUG , " % s " , grpc_error_string ( parent ) ) ; <nl> - <nl> for ( size_t i = 0 ; i < 2 ; + + i ) { <nl> GRPC_ERROR_UNREF ( children [ i ] ) ; <nl> } <nl> static void test_special ( ) { <nl> GRPC_ERROR_UNREF ( error ) ; <nl> } <nl> <nl> + static void test_overflow ( ) { <nl> + grpc_error * error = GRPC_ERROR_CREATE_FROM_STATIC_STRING ( " Overflow " ) ; <nl> + <nl> + for ( size_t i = 0 ; i < 150 ; + + i ) { <nl> + error = grpc_error_add_child ( error , <nl> + GRPC_ERROR_CREATE_FROM_STATIC_STRING ( " Child " ) ) ; <nl> + } <nl> + <nl> + error = grpc_error_set_int ( error , GRPC_ERROR_INT_HTTP2_ERROR , 5 ) ; <nl> + error = <nl> + grpc_error_set_str ( error , GRPC_ERROR_STR_GRPC_MESSAGE , <nl> + grpc_slice_from_static_string ( " message for child 2 " ) ) ; <nl> + error = grpc_error_set_int ( error , GRPC_ERROR_INT_GRPC_STATUS , 5 ) ; <nl> + <nl> + intptr_t i ; <nl> + GPR_ASSERT ( grpc_error_get_int ( error , GRPC_ERROR_INT_HTTP2_ERROR , & i ) ) ; <nl> + GPR_ASSERT ( i = = 5 ) ; <nl> + GPR_ASSERT ( ! grpc_error_get_int ( error , GRPC_ERROR_INT_GRPC_STATUS , & i ) ) ; <nl> + <nl> + error = grpc_error_set_int ( error , GRPC_ERROR_INT_HTTP2_ERROR , 10 ) ; <nl> + GPR_ASSERT ( grpc_error_get_int ( error , GRPC_ERROR_INT_HTTP2_ERROR , & i ) ) ; <nl> + GPR_ASSERT ( i = = 10 ) ; <nl> + <nl> + GRPC_ERROR_UNREF ( error ) ; <nl> + ; <nl> + } <nl> + <nl> int main ( int argc , char * * argv ) { <nl> grpc_test_init ( argc , argv ) ; <nl> grpc_init ( ) ; <nl> int main ( int argc , char * * argv ) { <nl> test_create_referencing ( ) ; <nl> test_create_referencing_many ( ) ; <nl> test_special ( ) ; <nl> + test_overflow ( ) ; <nl> grpc_shutdown ( ) ; <nl> <nl> return 0 ; <nl> mmm a / test / core / iomgr / ev_epoll_linux_test . c <nl> ppp b / test / core / iomgr / ev_epoll_linux_test . c <nl> static void test_threading_wakeup ( grpc_exec_ctx * exec_ctx , void * arg , <nl> threading_shared * shared = arg ; <nl> + + shared - > wakeups ; <nl> + + thread_wakeups ; <nl> - GPR_ASSERT ( GRPC_LOG_IF_ERROR ( <nl> - " consume_wakeup " , grpc_wakeup_fd_consume_wakeup ( shared - > wakeup_fd ) ) ) ; <nl> - grpc_fd_notify_on_read ( exec_ctx , shared - > wakeup_desc , & shared - > on_wakeup ) ; <nl> - GPR_ASSERT ( GRPC_LOG_IF_ERROR ( " wakeup_next " , <nl> - grpc_wakeup_fd_wakeup ( shared - > wakeup_fd ) ) ) ; <nl> + if ( error = = GRPC_ERROR_NONE ) { <nl> + GPR_ASSERT ( GRPC_LOG_IF_ERROR ( <nl> + " consume_wakeup " , grpc_wakeup_fd_consume_wakeup ( shared - > wakeup_fd ) ) ) ; <nl> + grpc_fd_notify_on_read ( exec_ctx , shared - > wakeup_desc , & shared - > on_wakeup ) ; <nl> + GPR_ASSERT ( GRPC_LOG_IF_ERROR ( " wakeup_next " , <nl> + grpc_wakeup_fd_wakeup ( shared - > wakeup_fd ) ) ) ; <nl> + } <nl> } <nl> <nl> static void test_threading ( void ) { <nl> static void test_threading ( void ) { <nl> grpc_wakeup_fd_destroy ( & fd ) ; <nl> { <nl> grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT ; <nl> + grpc_fd_shutdown ( & exec_ctx , shared . wakeup_desc , GRPC_ERROR_CANCELLED ) ; <nl> grpc_fd_orphan ( & exec_ctx , shared . wakeup_desc , NULL , NULL , " done " ) ; <nl> grpc_pollset_shutdown ( & exec_ctx , shared . pollset , <nl> grpc_closure_create ( destroy_pollset , shared . pollset , <nl> mmm a / test / core / iomgr / fd_conservation_posix_test . c <nl> ppp b / test / core / iomgr / fd_conservation_posix_test . c <nl> int main ( int argc , char * * argv ) { <nl> <nl> for ( i = 0 ; i < 100 ; i + + ) { <nl> grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT ; <nl> - p = grpc_iomgr_create_endpoint_pair ( " test " , resource_quota , 1 ) ; <nl> + p = grpc_iomgr_create_endpoint_pair ( " test " , NULL ) ; <nl> grpc_endpoint_destroy ( & exec_ctx , p . client ) ; <nl> grpc_endpoint_destroy ( & exec_ctx , p . server ) ; <nl> grpc_exec_ctx_finish ( & exec_ctx ) ; <nl> mmm a / test / core / iomgr / sockaddr_utils_test . c <nl> ppp b / test / core / iomgr / sockaddr_utils_test . c <nl> static void test_sockaddr_to_string ( void ) { <nl> expect_sockaddr_str ( " ( sockaddr family = 123 ) " , & dummy , 0 ) ; <nl> expect_sockaddr_str ( " ( sockaddr family = 123 ) " , & dummy , 1 ) ; <nl> GPR_ASSERT ( grpc_sockaddr_to_uri ( & dummy ) = = NULL ) ; <nl> - <nl> - GPR_ASSERT ( errno = = 0x7EADBEEF ) ; <nl> } <nl> <nl> static void test_sockaddr_set_get_port ( void ) { <nl> mmm a / test / core / iomgr / tcp_posix_test . c <nl> ppp b / test / core / iomgr / tcp_posix_test . c <nl> static void read_test ( size_t num_bytes , size_t slice_size ) { <nl> <nl> create_sockets ( sv ) ; <nl> <nl> - grpc_resource_quota * resource_quota = grpc_resource_quota_create ( " read_test " ) ; <nl> - ep = grpc_tcp_create ( grpc_fd_create ( sv [ 1 ] , " read_test " ) , resource_quota , <nl> - slice_size , " test " ) ; <nl> - grpc_resource_quota_unref_internal ( & exec_ctx , resource_quota ) ; <nl> + grpc_arg a [ ] = { { . key = GRPC_ARG_TCP_READ_CHUNK_SIZE , <nl> + . type = GRPC_ARG_INTEGER , <nl> + . value . integer = ( int ) slice_size } } ; <nl> + grpc_channel_args args = { . num_args = GPR_ARRAY_SIZE ( a ) , . args = a } ; <nl> + ep = grpc_tcp_create ( & exec_ctx , grpc_fd_create ( sv [ 1 ] , " read_test " ) , & args , <nl> + " test " ) ; <nl> grpc_endpoint_add_to_pollset ( & exec_ctx , ep , g_pollset ) ; <nl> <nl> written_bytes = fill_socket_partial ( sv [ 0 ] , num_bytes ) ; <nl> static void large_read_test ( size_t slice_size ) { <nl> <nl> create_sockets ( sv ) ; <nl> <nl> - grpc_resource_quota * resource_quota = <nl> - grpc_resource_quota_create ( " large_read_test " ) ; <nl> - ep = grpc_tcp_create ( grpc_fd_create ( sv [ 1 ] , " large_read_test " ) , resource_quota , <nl> - slice_size , " test " ) ; <nl> - grpc_resource_quota_unref_internal ( & exec_ctx , resource_quota ) ; <nl> + grpc_arg a [ ] = { { . key = GRPC_ARG_TCP_READ_CHUNK_SIZE , <nl> + . type = GRPC_ARG_INTEGER , <nl> + . value . integer = ( int ) slice_size } } ; <nl> + grpc_channel_args args = { . num_args = GPR_ARRAY_SIZE ( a ) , . args = a } ; <nl> + ep = grpc_tcp_create ( & exec_ctx , grpc_fd_create ( sv [ 1 ] , " large_read_test " ) , <nl> + & args , " test " ) ; <nl> grpc_endpoint_add_to_pollset ( & exec_ctx , ep , g_pollset ) ; <nl> <nl> written_bytes = fill_socket ( sv [ 0 ] ) ; <nl> static void write_test ( size_t num_bytes , size_t slice_size ) { <nl> <nl> create_sockets ( sv ) ; <nl> <nl> - grpc_resource_quota * resource_quota = <nl> - grpc_resource_quota_create ( " write_test " ) ; <nl> - ep = grpc_tcp_create ( grpc_fd_create ( sv [ 1 ] , " write_test " ) , resource_quota , <nl> - GRPC_TCP_DEFAULT_READ_SLICE_SIZE , " test " ) ; <nl> - grpc_resource_quota_unref_internal ( & exec_ctx , resource_quota ) ; <nl> + grpc_arg a [ ] = { { . key = GRPC_ARG_TCP_READ_CHUNK_SIZE , <nl> + . type = GRPC_ARG_INTEGER , <nl> + . value . integer = ( int ) slice_size } } ; <nl> + grpc_channel_args args = { . num_args = GPR_ARRAY_SIZE ( a ) , . args = a } ; <nl> + ep = grpc_tcp_create ( & exec_ctx , grpc_fd_create ( sv [ 1 ] , " write_test " ) , & args , <nl> + " test " ) ; <nl> grpc_endpoint_add_to_pollset ( & exec_ctx , ep , g_pollset ) ; <nl> <nl> state . ep = ep ; <nl> static void release_fd_test ( size_t num_bytes , size_t slice_size ) { <nl> <nl> create_sockets ( sv ) ; <nl> <nl> - grpc_resource_quota * resource_quota = <nl> - grpc_resource_quota_create ( " release_fd_test " ) ; <nl> - ep = grpc_tcp_create ( grpc_fd_create ( sv [ 1 ] , " read_test " ) , resource_quota , <nl> - slice_size , " test " ) ; <nl> + grpc_arg a [ ] = { { . key = GRPC_ARG_TCP_READ_CHUNK_SIZE , <nl> + . type = GRPC_ARG_INTEGER , <nl> + . value . integer = ( int ) slice_size } } ; <nl> + grpc_channel_args args = { . num_args = GPR_ARRAY_SIZE ( a ) , . args = a } ; <nl> + ep = grpc_tcp_create ( & exec_ctx , grpc_fd_create ( sv [ 1 ] , " read_test " ) , & args , <nl> + " test " ) ; <nl> GPR_ASSERT ( grpc_tcp_fd ( ep ) = = sv [ 1 ] & & sv [ 1 ] > = 0 ) ; <nl> - grpc_resource_quota_unref_internal ( & exec_ctx , resource_quota ) ; <nl> grpc_endpoint_add_to_pollset ( & exec_ctx , ep , g_pollset ) ; <nl> <nl> written_bytes = fill_socket_partial ( sv [ 0 ] , num_bytes ) ; <nl> static grpc_endpoint_test_fixture create_fixture_tcp_socketpair ( <nl> create_sockets ( sv ) ; <nl> grpc_resource_quota * resource_quota = <nl> grpc_resource_quota_create ( " tcp_posix_test_socketpair " ) ; <nl> - f . client_ep = grpc_tcp_create ( grpc_fd_create ( sv [ 0 ] , " fixture : client " ) , <nl> - resource_quota , slice_size , " test " ) ; <nl> - f . server_ep = grpc_tcp_create ( grpc_fd_create ( sv [ 1 ] , " fixture : server " ) , <nl> - resource_quota , slice_size , " test " ) ; <nl> + grpc_arg a [ ] = { { . key = GRPC_ARG_TCP_READ_CHUNK_SIZE , <nl> + . type = GRPC_ARG_INTEGER , <nl> + . value . integer = ( int ) slice_size } } ; <nl> + grpc_channel_args args = { . num_args = GPR_ARRAY_SIZE ( a ) , . args = a } ; <nl> + f . client_ep = grpc_tcp_create ( <nl> + & exec_ctx , grpc_fd_create ( sv [ 0 ] , " fixture : client " ) , & args , " test " ) ; <nl> + f . server_ep = grpc_tcp_create ( <nl> + & exec_ctx , grpc_fd_create ( sv [ 1 ] , " fixture : server " ) , & args , " test " ) ; <nl> grpc_resource_quota_unref_internal ( & exec_ctx , resource_quota ) ; <nl> grpc_endpoint_add_to_pollset ( & exec_ctx , f . client_ep , g_pollset ) ; <nl> grpc_endpoint_add_to_pollset ( & exec_ctx , f . server_ep , g_pollset ) ; <nl> mmm a / test / core / security / credentials_test . c <nl> ppp b / test / core / security / credentials_test . c <nl> static void on_oauth2_creds_get_metadata_failure ( <nl> static void validate_compute_engine_http_request ( <nl> const grpc_httpcli_request * request ) { <nl> GPR_ASSERT ( request - > handshaker ! = & grpc_httpcli_ssl ) ; <nl> - GPR_ASSERT ( strcmp ( request - > host , " metadata " ) = = 0 ) ; <nl> + GPR_ASSERT ( strcmp ( request - > host , " metadata . google . internal " ) = = 0 ) ; <nl> GPR_ASSERT ( <nl> strcmp ( request - > http . path , <nl> " / computeMetadata / v1 / instance / service - accounts / default / token " ) = = <nl> mmm a / test / core / security / secure_endpoint_test . c <nl> ppp b / test / core / security / secure_endpoint_test . c <nl> <nl> # include < grpc / grpc . h > <nl> # include < grpc / support / alloc . h > <nl> # include < grpc / support / log . h > <nl> + # include < grpc / support / useful . h > <nl> # include " src / core / lib / iomgr / endpoint_pair . h " <nl> # include " src / core / lib / iomgr / iomgr . h " <nl> # include " src / core / lib / security / transport / secure_endpoint . h " <nl> static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair ( <nl> grpc_endpoint_test_fixture f ; <nl> grpc_endpoint_pair tcp ; <nl> <nl> - grpc_resource_quota * resource_quota = <nl> - grpc_resource_quota_create ( " secure_endpoint_test " ) ; <nl> - tcp = grpc_iomgr_create_endpoint_pair ( " fixture " , resource_quota , slice_size ) ; <nl> - grpc_resource_quota_unref_internal ( & exec_ctx , resource_quota ) ; <nl> + grpc_arg a [ ] = { { . key = GRPC_ARG_TCP_READ_CHUNK_SIZE , <nl> + . type = GRPC_ARG_INTEGER , <nl> + . value . integer = ( int ) slice_size } } ; <nl> + grpc_channel_args args = { . num_args = GPR_ARRAY_SIZE ( a ) , . args = a } ; <nl> + tcp = grpc_iomgr_create_endpoint_pair ( " fixture " , & args ) ; <nl> grpc_endpoint_add_to_pollset ( & exec_ctx , tcp . client , g_pollset ) ; <nl> grpc_endpoint_add_to_pollset ( & exec_ctx , tcp . server , g_pollset ) ; <nl> <nl> mmm a / test / cpp / end2end / end2end_test . cc <nl> ppp b / test / cpp / end2end / end2end_test . cc <nl> TEST_P ( End2endTest , BinaryTrailerTest ) { <nl> EXPECT_TRUE ( returned_info . ParseFromString ( ToString ( iter - > second ) ) ) ; <nl> } <nl> <nl> + TEST_P ( End2endTest , ExpectErrorTest ) { <nl> + ResetStub ( ) ; <nl> + <nl> + std : : vector < ErrorStatus > expected_status ; <nl> + expected_status . emplace_back ( ) ; <nl> + expected_status . back ( ) . set_code ( 13 ) ; / / INTERNAL <nl> + expected_status . back ( ) . set_error_message ( " text error message " ) ; <nl> + expected_status . back ( ) . set_binary_error_details ( " text error details " ) ; <nl> + expected_status . emplace_back ( ) ; <nl> + expected_status . back ( ) . set_code ( 13 ) ; / / INTERNAL <nl> + expected_status . back ( ) . set_error_message ( " text error message " ) ; <nl> + expected_status . back ( ) . set_binary_error_details ( <nl> + " \ x0 \ x1 \ x2 \ x3 \ x4 \ x5 \ x6 \ x8 \ x9 \ xA \ xB " ) ; <nl> + <nl> + for ( auto iter = expected_status . begin ( ) ; iter ! = expected_status . end ( ) ; <nl> + + + iter ) { <nl> + EchoRequest request ; <nl> + EchoResponse response ; <nl> + ClientContext context ; <nl> + request . set_message ( " Hello " ) ; <nl> + auto * error = request . mutable_param ( ) - > mutable_expected_error ( ) ; <nl> + error - > set_code ( iter - > code ( ) ) ; <nl> + error - > set_error_message ( iter - > error_message ( ) ) ; <nl> + error - > set_binary_error_details ( iter - > binary_error_details ( ) ) ; <nl> + <nl> + Status s = stub_ - > Echo ( & context , request , & response ) ; <nl> + EXPECT_FALSE ( s . ok ( ) ) ; <nl> + EXPECT_EQ ( iter - > code ( ) , s . error_code ( ) ) ; <nl> + EXPECT_EQ ( iter - > error_message ( ) , s . error_message ( ) ) ; <nl> + EXPECT_EQ ( iter - > binary_error_details ( ) , s . error_details ( ) ) ; <nl> + } <nl> + } <nl> + <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / Test with and without a proxy . <nl> class ProxyEnd2endTest : public End2endTest { <nl> mmm a / test / cpp / end2end / test_service_impl . cc <nl> ppp b / test / cpp / end2end / test_service_impl . cc <nl> Status TestServiceImpl : : Echo ( ServerContext * context , const EchoRequest * request , <nl> gpr_log ( GPR_ERROR , " The request should not reach application handler . " ) ; <nl> GPR_ASSERT ( 0 ) ; <nl> } <nl> + if ( request - > has_param ( ) & & request - > param ( ) . has_expected_error ( ) ) { <nl> + const auto & error = request - > param ( ) . expected_error ( ) ; <nl> + return Status ( static_cast < StatusCode > ( error . code ( ) ) , error . error_message ( ) , <nl> + error . binary_error_details ( ) ) ; <nl> + } <nl> int server_try_cancel = GetIntValueFromMetadata ( <nl> kServerTryCancelRequest , context - > client_metadata ( ) , DO_NOT_CANCEL ) ; <nl> if ( server_try_cancel > DO_NOT_CANCEL ) { <nl> mmm a / test / cpp / microbenchmarks / BUILD <nl> ppp b / test / cpp / microbenchmarks / BUILD <nl> licenses ( [ " notice " ] ) # 3 - clause BSD <nl> cc_test ( <nl> name = " noop - benchmark " , <nl> srcs = [ " noop - benchmark . cc " ] , <nl> - deps = [ " / / external : benchmark " ] , <nl> linkopts = [ " - pthread " ] , <nl> + deps = [ " / / external : benchmark " ] , <nl> ) <nl> <nl> cc_library ( <nl> name = " helpers " , <nl> srcs = [ " helpers . cc " ] , <nl> - hdrs = [ " helpers . h " , " fullstack_fixtures . h " , " fullstack_context_mutators . h " ] , <nl> - deps = [ " / / : grpc + + " , " / / external : benchmark " , " / / test / core / util : grpc_test_util " , " / / src / proto / grpc / testing : echo_proto " ] , <nl> + hdrs = [ <nl> + " fullstack_context_mutators . h " , <nl> + " fullstack_fixtures . h " , <nl> + " helpers . h " , <nl> + ] , <nl> linkopts = [ " - pthread " ] , <nl> + deps = [ <nl> + " / / : grpc + + " , <nl> + " / / external : benchmark " , <nl> + " / / src / proto / grpc / testing : echo_proto " , <nl> + " / / test / core / util : grpc_test_util " , <nl> + ] , <nl> ) <nl> <nl> cc_test ( <nl> cc_test ( <nl> deps = [ " : helpers " ] , <nl> ) <nl> <nl> + cc_test ( <nl> + name = " bm_cq_multiple_threads " , <nl> + srcs = [ " bm_cq_multiple_threads . cc " ] , <nl> + deps = [ " : helpers " ] , <nl> + ) <nl> + <nl> cc_test ( <nl> name = " bm_error " , <nl> srcs = [ " bm_error . cc " ] , <nl> cc_test ( <nl> name = " bm_fullstack_streaming_ping_pong " , <nl> srcs = [ " bm_fullstack_streaming_ping_pong . cc " ] , <nl> deps = [ " : helpers " ] , <nl> + ) <nl> <nl> - ) <nl> cc_test ( <nl> name = " bm_fullstack_streaming_pump " , <nl> srcs = [ " bm_fullstack_streaming_pump . cc " ] , <nl> new file mode 100644 <nl> index 00000000000 . . 86274632042 <nl> mmm / dev / null <nl> ppp b / test / cpp / microbenchmarks / bm_cq_multiple_threads . cc <nl> <nl> + / * <nl> + * <nl> + * Copyright 2017 , 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> + * / <nl> + <nl> + # include < benchmark / benchmark . h > <nl> + # include < string . h > <nl> + # include < atomic > <nl> + <nl> + # include < grpc / grpc . h > <nl> + # include < grpc / support / alloc . h > <nl> + # include < grpc / support / log . h > <nl> + # include " test / cpp / microbenchmarks / helpers . h " <nl> + <nl> + extern " C " { <nl> + # include " src / core / lib / iomgr / ev_posix . h " <nl> + # include " src / core / lib / iomgr / port . h " <nl> + # include " src / core / lib / surface / completion_queue . h " <nl> + } <nl> + <nl> + struct grpc_pollset { <nl> + gpr_mu mu ; <nl> + } ; <nl> + <nl> + namespace grpc { <nl> + namespace testing { <nl> + <nl> + static void * g_tag = ( void * ) ( intptr_t ) 10 ; / / Some random number <nl> + static grpc_completion_queue * g_cq ; <nl> + static grpc_event_engine_vtable g_vtable ; <nl> + <nl> + static void pollset_shutdown ( grpc_exec_ctx * exec_ctx , grpc_pollset * ps , <nl> + grpc_closure * closure ) { <nl> + grpc_closure_sched ( exec_ctx , closure , GRPC_ERROR_NONE ) ; <nl> + } <nl> + <nl> + static void pollset_init ( grpc_pollset * ps , gpr_mu * * mu ) { <nl> + gpr_mu_init ( & ps - > mu ) ; <nl> + * mu = & ps - > mu ; <nl> + } <nl> + <nl> + static void pollset_destroy ( grpc_pollset * ps ) { gpr_mu_destroy ( & ps - > mu ) ; } <nl> + <nl> + static grpc_error * pollset_kick ( grpc_pollset * p , grpc_pollset_worker * worker ) { <nl> + return GRPC_ERROR_NONE ; <nl> + } <nl> + <nl> + / * Callback when the tag is dequeued from the completion queue . Does nothing * / <nl> + static void cq_done_cb ( grpc_exec_ctx * exec_ctx , void * done_arg , <nl> + grpc_cq_completion * cq_completion ) { <nl> + gpr_free ( cq_completion ) ; <nl> + } <nl> + <nl> + / * Queues a completion tag . ZERO polling overhead * / <nl> + static grpc_error * pollset_work ( grpc_exec_ctx * exec_ctx , grpc_pollset * ps , <nl> + grpc_pollset_worker * * worker , gpr_timespec now , <nl> + gpr_timespec deadline ) { <nl> + gpr_mu_unlock ( & ps - > mu ) ; <nl> + grpc_cq_begin_op ( g_cq , g_tag ) ; <nl> + grpc_cq_end_op ( exec_ctx , g_cq , g_tag , GRPC_ERROR_NONE , cq_done_cb , NULL , <nl> + ( grpc_cq_completion * ) gpr_malloc ( sizeof ( grpc_cq_completion ) ) ) ; <nl> + grpc_exec_ctx_flush ( exec_ctx ) ; <nl> + gpr_mu_lock ( & ps - > mu ) ; <nl> + return GRPC_ERROR_NONE ; <nl> + } <nl> + <nl> + static void init_engine_vtable ( ) { <nl> + memset ( & g_vtable , 0 , sizeof ( g_vtable ) ) ; <nl> + <nl> + g_vtable . pollset_size = sizeof ( grpc_pollset ) ; <nl> + g_vtable . pollset_init = pollset_init ; <nl> + g_vtable . pollset_shutdown = pollset_shutdown ; <nl> + g_vtable . pollset_destroy = pollset_destroy ; <nl> + g_vtable . pollset_work = pollset_work ; <nl> + g_vtable . pollset_kick = pollset_kick ; <nl> + } <nl> + <nl> + static void setup ( ) { <nl> + grpc_init ( ) ; <nl> + init_engine_vtable ( ) ; <nl> + grpc_set_event_engine_test_only ( & g_vtable ) ; <nl> + <nl> + g_cq = grpc_completion_queue_create ( NULL ) ; <nl> + } <nl> + <nl> + static void teardown ( ) { <nl> + grpc_completion_queue_shutdown ( g_cq ) ; <nl> + grpc_completion_queue_destroy ( g_cq ) ; <nl> + } <nl> + <nl> + / * A few notes about Multi - threaded benchmarks : <nl> + <nl> + Setup : <nl> + The benchmark framework ensures that none of the threads proceed beyond the <nl> + state . KeepRunning ( ) call unless all the threads have called state . keepRunning <nl> + atleast once . So it is safe to do the initialization in one of the threads <nl> + before state . KeepRunning ( ) is called . <nl> + <nl> + Teardown : <nl> + The benchmark framework also ensures that no thread is running the benchmark <nl> + code ( i . e the code between two successive calls of state . KeepRunning ( ) ) if <nl> + state . KeepRunning ( ) returns false . So it is safe to do the teardown in one <nl> + of the threads after state . keepRunning ( ) returns false . <nl> + * / <nl> + static void BM_Cq_Throughput ( benchmark : : State & state ) { <nl> + TrackCounters track_counters ; <nl> + gpr_timespec deadline = gpr_inf_future ( GPR_CLOCK_MONOTONIC ) ; <nl> + <nl> + if ( state . thread_index = = 0 ) { <nl> + setup ( ) ; <nl> + } <nl> + <nl> + while ( state . KeepRunning ( ) ) { <nl> + GPR_ASSERT ( grpc_completion_queue_next ( g_cq , deadline , NULL ) . type = = <nl> + GRPC_OP_COMPLETE ) ; <nl> + } <nl> + <nl> + state . SetItemsProcessed ( state . iterations ( ) ) ; <nl> + <nl> + if ( state . thread_index = = 0 ) { <nl> + teardown ( ) ; <nl> + } <nl> + <nl> + track_counters . Finish ( state ) ; <nl> + } <nl> + <nl> + BENCHMARK ( BM_Cq_Throughput ) - > ThreadRange ( 1 , 16 ) - > UseRealTime ( ) ; <nl> + <nl> + } / / namespace testing <nl> + } / / namespace grpc <nl> + <nl> + BENCHMARK_MAIN ( ) ; <nl> mmm a / test / cpp / microbenchmarks / fullstack_fixtures . h <nl> ppp b / test / cpp / microbenchmarks / fullstack_fixtures . h <nl> class EndpointPairFixture : public BaseFixture { <nl> class SockPair : public EndpointPairFixture { <nl> public : <nl> SockPair ( Service * service ) <nl> - : EndpointPairFixture ( service , grpc_iomgr_create_endpoint_pair ( <nl> - " test " , Library : : get ( ) . rq ( ) , 8192 ) ) { } <nl> + : EndpointPairFixture ( service , <nl> + grpc_iomgr_create_endpoint_pair ( " test " , NULL ) ) { } <nl> } ; <nl> <nl> class InProcessCHTTP2 : public EndpointPairFixture { <nl> mmm a / test / cpp / qps / benchmark_config . cc <nl> ppp b / test / cpp / qps / benchmark_config . cc <nl> <nl> <nl> # include " test / cpp / qps / benchmark_config . h " <nl> # include < gflags / gflags . h > <nl> + # include < grpc + + / create_channel . h > <nl> + # include < grpc + + / security / credentials . h > <nl> + # include < grpc / support / log . h > <nl> <nl> DEFINE_bool ( enable_log_reporter , true , <nl> " Enable reporting of benchmark results through GprLog " ) ; <nl> DEFINE_string ( server_address , " localhost : 50052 " , <nl> <nl> DEFINE_string ( tag , " " , " Optional tag for the test " ) ; <nl> <nl> + DEFINE_string ( rpc_reporter_server_address , " " , <nl> + " Server address for rpc reporter to send results to " ) ; <nl> + <nl> + DEFINE_bool ( enable_rpc_reporter , false , " Enable use of RPC reporter " ) ; <nl> + <nl> / / In some distros , gflags is in the namespace google , and in some others , <nl> / / in gflags . This hack is enabling us to find both . <nl> namespace google { } <nl> static std : : shared_ptr < Reporter > InitBenchmarkReporters ( ) { <nl> composite_reporter - > add ( std : : unique_ptr < Reporter > ( <nl> new JsonReporter ( " JsonReporter " , FLAGS_scenario_result_file ) ) ) ; <nl> } <nl> + if ( FLAGS_enable_rpc_reporter ) { <nl> + GPR_ASSERT ( ! FLAGS_rpc_reporter_server_address . empty ( ) ) ; <nl> + composite_reporter - > add ( std : : unique_ptr < Reporter > ( new RpcReporter ( <nl> + " RpcReporter " , <nl> + grpc : : CreateChannel ( FLAGS_rpc_reporter_server_address , <nl> + grpc : : InsecureChannelCredentials ( ) ) ) ) ) ; <nl> + } <nl> <nl> return std : : shared_ptr < Reporter > ( composite_reporter ) ; <nl> } <nl> mmm a / test / cpp / qps / report . cc <nl> ppp b / test / cpp / qps / report . cc <nl> <nl> # include " test / cpp / qps / parse_json . h " <nl> # include " test / cpp / qps / stats . h " <nl> <nl> + # include < grpc + + / client_context . h > <nl> + # include " src / proto / grpc / testing / services . grpc . pb . h " <nl> + <nl> namespace grpc { <nl> namespace testing { <nl> <nl> void JsonReporter : : ReportCpuUsage ( const ScenarioResult & result ) { <nl> / / NOP - all reporting is handled by ReportQPS . <nl> } <nl> <nl> + void RpcReporter : : ReportQPS ( const ScenarioResult & result ) { <nl> + grpc : : ClientContext context ; <nl> + grpc : : Status status ; <nl> + Void dummy ; <nl> + <nl> + gpr_log ( GPR_INFO , " RPC reporter sending scenario result to server " ) ; <nl> + status = stub_ - > ReportScenario ( & context , result , & dummy ) ; <nl> + <nl> + if ( status . ok ( ) ) { <nl> + gpr_log ( GPR_INFO , " RpcReporter report RPC success ! " ) ; <nl> + } else { <nl> + gpr_log ( GPR_ERROR , " RpcReporter report RPC : code : % d . message : % s " , <nl> + status . error_code ( ) , status . error_message ( ) . c_str ( ) ) ; <nl> + } <nl> + } <nl> + <nl> + void RpcReporter : : ReportQPSPerCore ( const ScenarioResult & result ) { <nl> + / / NOP - all reporting is handled by ReportQPS . <nl> + } <nl> + <nl> + void RpcReporter : : ReportLatency ( const ScenarioResult & result ) { <nl> + / / NOP - all reporting is handled by ReportQPS . <nl> + } <nl> + <nl> + void RpcReporter : : ReportTimes ( const ScenarioResult & result ) { <nl> + / / NOP - all reporting is handled by ReportQPS . <nl> + } <nl> + <nl> + void RpcReporter : : ReportCpuUsage ( const ScenarioResult & result ) { <nl> + / / NOP - all reporting is handled by ReportQPS . <nl> + } <nl> + <nl> } / / namespace testing <nl> } / / namespace grpc <nl> mmm a / test / cpp / qps / report . h <nl> ppp b / test / cpp / qps / report . h <nl> <nl> <nl> # include " test / cpp / qps / driver . h " <nl> <nl> + # include < grpc + + / channel . h > <nl> + # include " src / proto / grpc / testing / services . grpc . pb . h " <nl> + <nl> namespace grpc { <nl> namespace testing { <nl> <nl> class JsonReporter : public Reporter { <nl> const string report_file_ ; <nl> } ; <nl> <nl> + class RpcReporter : public Reporter { <nl> + public : <nl> + RpcReporter ( const string & name , std : : shared_ptr < grpc : : Channel > channel ) <nl> + : Reporter ( name ) , stub_ ( ReportQpsScenarioService : : NewStub ( channel ) ) { } <nl> + <nl> + private : <nl> + void ReportQPS ( const ScenarioResult & result ) override ; <nl> + void ReportQPSPerCore ( const ScenarioResult & result ) override ; <nl> + void ReportLatency ( const ScenarioResult & result ) override ; <nl> + void ReportTimes ( const ScenarioResult & result ) override ; <nl> + void ReportCpuUsage ( const ScenarioResult & result ) override ; <nl> + <nl> + std : : unique_ptr < ReportQpsScenarioService : : Stub > stub_ ; <nl> + } ; <nl> + <nl> } / / namespace testing <nl> } / / namespace grpc <nl> <nl> mmm a / test / cpp / util / grpc_tool . cc <nl> ppp b / test / cpp / util / grpc_tool . cc <nl> bool GrpcTool : : ListServices ( int argc , const char * * argv , <nl> <nl> std : : vector < grpc : : string > service_list ; <nl> if ( ! desc_db . GetServices ( & service_list ) ) { <nl> + fprintf ( stderr , " Received an error when querying services endpoint . \ n " ) ; <nl> return false ; <nl> } <nl> <nl> mmm a / test / distrib / csharp / run_distrib_test . bat <nl> ppp b / test / distrib / csharp / run_distrib_test . bat <nl> <nl> cd / d % ~ dp0 <nl> <nl> @ rem extract input artifacts <nl> - powershell - Command " Add - Type - Assembly ' System . IO . Compression . FileSystem ' ; [ System . IO . Compression . ZipFile ] : : ExtractToDirectory ( ' . . / . . / . . / input_artifacts / csharp_nugets_dotnetcli . zip ' , ' TestNugetFeed ' ) ; " <nl> + powershell - Command " Add - Type - Assembly ' System . IO . Compression . FileSystem ' ; [ System . IO . Compression . ZipFile ] : : ExtractToDirectory ( ' . . / . . / . . / input_artifacts / csharp_nugets_windows_dotnetcli . zip ' , ' TestNugetFeed ' ) ; " <nl> <nl> update_version . sh auto <nl> <nl> mmm a / test / distrib / csharp / run_distrib_test . sh <nl> ppp b / test / distrib / csharp / run_distrib_test . sh <nl> set - ex <nl> <nl> cd $ ( dirname $ 0 ) <nl> <nl> - unzip - o " $ EXTERNAL_GIT_ROOT / input_artifacts / csharp_nugets_dotnetcli . zip " - d TestNugetFeed <nl> + unzip - o " $ EXTERNAL_GIT_ROOT / input_artifacts / csharp_nugets_windows_dotnetcli . zip " - d TestNugetFeed <nl> <nl> . / update_version . sh auto <nl> <nl> mmm a / test / distrib / csharp / run_distrib_test_dotnetcli . sh <nl> ppp b / test / distrib / csharp / run_distrib_test_dotnetcli . sh <nl> set - ex <nl> <nl> cd $ ( dirname $ 0 ) <nl> <nl> - unzip - o " $ EXTERNAL_GIT_ROOT / input_artifacts / csharp_nugets_dotnetcli . zip " - d TestNugetFeed <nl> + unzip - o " $ EXTERNAL_GIT_ROOT / input_artifacts / csharp_nugets_windows_dotnetcli . zip " - d TestNugetFeed <nl> <nl> . / update_version . sh auto <nl> <nl> mmm a / third_party / googletest <nl> ppp b / third_party / googletest <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit c99458533a9b4c743ed51537e25989ea55944908 <nl> + Subproject commit ec44c6c1675c25b9827aacd08c02433cccde7780 <nl> mmm a / third_party / gtest . BUILD <nl> ppp b / third_party / gtest . BUILD <nl> <nl> cc_library ( <nl> name = " gtest " , <nl> srcs = [ <nl> - " src / gtest - all . cc " , <nl> + " googletest / src / gtest - all . cc " , <nl> ] , <nl> - hdrs = glob ( [ " include / * * / * . h " , " src / * . cc " , " src / * . h " ] ) , <nl> + hdrs = glob ( [ " googletest / include / * * / * . h " , " googletest / src / * . cc " , " googletest / src / * . h " ] ) , <nl> includes = [ <nl> - " include " , <nl> + " googletest " , <nl> + " googletest / include " , <nl> ] , <nl> linkstatic = 1 , <nl> visibility = [ <nl> mmm a / third_party / protobuf <nl> ppp b / third_party / protobuf <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit 593e917c176b5bc5aafa57bf9f6030d749d91cd5 <nl> + Subproject commit 4a0dd03e52e09332c8fd0f8f26a8e0ae9f911182 <nl> mmm a / tools / distrib / python / grpcio_tools / protoc_lib_deps . py <nl> ppp b / tools / distrib / python / grpcio_tools / protoc_lib_deps . py <nl> <nl> # OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> <nl> # AUTO - GENERATED BY make_grpcio_tools . py ! <nl> - CC_FILES = [ ' google / protobuf / compiler / zip_writer . cc ' , ' google / protobuf / compiler / subprocess . cc ' , ' google / protobuf / compiler / ruby / ruby_generator . cc ' , ' google / protobuf / compiler / python / python_generator . cc ' , ' google / protobuf / compiler / plugin . pb . cc ' , ' google / protobuf / compiler / plugin . cc ' , ' google / protobuf / compiler / php / php_generator . cc ' , ' google / protobuf / compiler / objectivec / objectivec_primitive_field . cc ' , ' google / protobuf / compiler / objectivec / objectivec_oneof . cc ' , ' google / protobuf / compiler / objectivec / objectivec_message_field . cc ' , ' google / protobuf / compiler / objectivec / objectivec_message . cc ' , ' google / protobuf / compiler / objectivec / objectivec_map_field . cc ' , ' google / protobuf / compiler / objectivec / objectivec_helpers . cc ' , ' google / protobuf / compiler / objectivec / objectivec_generator . cc ' , ' google / protobuf / compiler / objectivec / objectivec_file . cc ' , ' google / protobuf / compiler / objectivec / objectivec_field . cc ' , ' google / protobuf / compiler / objectivec / objectivec_extension . cc ' , ' google / protobuf / compiler / objectivec / objectivec_enum_field . cc ' , ' google / protobuf / compiler / objectivec / objectivec_enum . cc ' , ' google / protobuf / compiler / js / well_known_types_embed . cc ' , ' google / protobuf / compiler / js / js_generator . cc ' , ' google / protobuf / compiler / javanano / javanano_primitive_field . cc ' , ' google / protobuf / compiler / javanano / javanano_message_field . cc ' , ' google / protobuf / compiler / javanano / javanano_message . cc ' , ' google / protobuf / compiler / javanano / javanano_map_field . cc ' , ' google / protobuf / compiler / javanano / javanano_helpers . cc ' , ' google / protobuf / compiler / javanano / javanano_generator . cc ' , ' google / protobuf / compiler / javanano / javanano_file . cc ' , ' google / protobuf / compiler / javanano / javanano_field . cc ' , ' google / protobuf / compiler / javanano / javanano_extension . cc ' , ' google / protobuf / compiler / javanano / javanano_enum_field . cc ' , ' google / protobuf / compiler / javanano / javanano_enum . cc ' , ' google / protobuf / compiler / java / java_string_field_lite . cc ' , ' google / protobuf / compiler / java / java_string_field . cc ' , ' google / protobuf / compiler / java / java_shared_code_generator . cc ' , ' google / protobuf / compiler / java / java_service . cc ' , ' google / protobuf / compiler / java / java_primitive_field_lite . cc ' , ' google / protobuf / compiler / java / java_primitive_field . cc ' , ' google / protobuf / compiler / java / java_name_resolver . cc ' , ' google / protobuf / compiler / java / java_message_lite . cc ' , ' google / protobuf / compiler / java / java_message_field_lite . cc ' , ' google / protobuf / compiler / java / java_message_field . cc ' , ' google / protobuf / compiler / java / java_message_builder_lite . cc ' , ' google / protobuf / compiler / java / java_message_builder . cc ' , ' google / protobuf / compiler / java / java_message . cc ' , ' google / protobuf / compiler / java / java_map_field_lite . cc ' , ' google / protobuf / compiler / java / java_map_field . cc ' , ' google / protobuf / compiler / java / java_lazy_message_field_lite . cc ' , ' google / protobuf / compiler / java / java_lazy_message_field . cc ' , ' google / protobuf / compiler / java / java_helpers . cc ' , ' google / protobuf / compiler / java / java_generator_factory . cc ' , ' google / protobuf / compiler / java / java_generator . cc ' , ' google / protobuf / compiler / java / java_file . cc ' , ' google / protobuf / compiler / java / java_field . cc ' , ' google / protobuf / compiler / java / java_extension_lite . cc ' , ' google / protobuf / compiler / java / java_extension . cc ' , ' google / protobuf / compiler / java / java_enum_lite . cc ' , ' google / protobuf / compiler / java / java_enum_field_lite . cc ' , ' google / protobuf / compiler / java / java_enum_field . cc ' , ' google / protobuf / compiler / java / java_enum . cc ' , ' google / protobuf / compiler / java / java_doc_comment . cc ' , ' google / protobuf / compiler / java / java_context . cc ' , ' google / protobuf / compiler / csharp / csharp_wrapper_field . cc ' , ' google / protobuf / compiler / csharp / csharp_source_generator_base . cc ' , ' google / protobuf / compiler / csharp / csharp_repeated_primitive_field . cc ' , ' google / protobuf / compiler / csharp / csharp_repeated_message_field . cc ' , ' google / protobuf / compiler / csharp / csharp_repeated_enum_field . cc ' , ' google / protobuf / compiler / csharp / csharp_reflection_class . cc ' , ' google / protobuf / compiler / csharp / csharp_primitive_field . cc ' , ' google / protobuf / compiler / csharp / csharp_message_field . cc ' , ' google / protobuf / compiler / csharp / csharp_message . cc ' , ' google / protobuf / compiler / csharp / csharp_map_field . cc ' , ' google / protobuf / compiler / csharp / csharp_helpers . cc ' , ' google / protobuf / compiler / csharp / csharp_generator . cc ' , ' google / protobuf / compiler / csharp / csharp_field_base . cc ' , ' google / protobuf / compiler / csharp / csharp_enum_field . cc ' , ' google / protobuf / compiler / csharp / csharp_enum . cc ' , ' google / protobuf / compiler / csharp / csharp_doc_comment . cc ' , ' google / protobuf / compiler / cpp / cpp_string_field . cc ' , ' google / protobuf / compiler / cpp / cpp_service . cc ' , ' google / protobuf / compiler / cpp / cpp_primitive_field . cc ' , ' google / protobuf / compiler / cpp / cpp_message_field . cc ' , ' google / protobuf / compiler / cpp / cpp_message . cc ' , ' google / protobuf / compiler / cpp / cpp_map_field . cc ' , ' google / protobuf / compiler / cpp / cpp_helpers . cc ' , ' google / protobuf / compiler / cpp / cpp_generator . cc ' , ' google / protobuf / compiler / cpp / cpp_file . cc ' , ' google / protobuf / compiler / cpp / cpp_field . cc ' , ' google / protobuf / compiler / cpp / cpp_extension . cc ' , ' google / protobuf / compiler / cpp / cpp_enum_field . cc ' , ' google / protobuf / compiler / cpp / cpp_enum . cc ' , ' google / protobuf / compiler / command_line_interface . cc ' , ' google / protobuf / compiler / code_generator . cc ' , ' google / protobuf / wrappers . pb . cc ' , ' google / protobuf / wire_format . cc ' , ' google / protobuf / util / type_resolver_util . cc ' , ' google / protobuf / util / time_util . cc ' , ' google / protobuf / util / message_differencer . cc ' , ' google / protobuf / util / json_util . cc ' , ' google / protobuf / util / internal / utility . cc ' , ' google / protobuf / util / internal / type_info_test_helper . cc ' , ' google / protobuf / util / internal / type_info . cc ' , ' google / protobuf / util / internal / protostream_objectwriter . cc ' , ' google / protobuf / util / internal / protostream_objectsource . cc ' , ' google / protobuf / util / internal / proto_writer . cc ' , ' google / protobuf / util / internal / object_writer . cc ' , ' google / protobuf / util / internal / json_stream_parser . cc ' , ' google / protobuf / util / internal / json_objectwriter . cc ' , ' google / protobuf / util / internal / json_escaping . cc ' , ' google / protobuf / util / internal / field_mask_utility . cc ' , ' google / protobuf / util / internal / error_listener . cc ' , ' google / protobuf / util / internal / default_value_objectwriter . cc ' , ' google / protobuf / util / internal / datapiece . cc ' , ' google / protobuf / util / field_mask_util . cc ' , ' google / protobuf / util / field_comparator . cc ' , ' google / protobuf / unknown_field_set . cc ' , ' google / protobuf / type . pb . cc ' , ' google / protobuf / timestamp . pb . cc ' , ' google / protobuf / text_format . cc ' , ' google / protobuf / stubs / substitute . cc ' , ' google / protobuf / stubs / mathlimits . cc ' , ' google / protobuf / struct . pb . cc ' , ' google / protobuf / source_context . pb . cc ' , ' google / protobuf / service . cc ' , ' google / protobuf / reflection_ops . cc ' , ' google / protobuf / message . cc ' , ' google / protobuf / map_field . cc ' , ' google / protobuf / io / zero_copy_stream_impl . cc ' , ' google / protobuf / io / tokenizer . cc ' , ' google / protobuf / io / strtod . cc ' , ' google / protobuf / io / printer . cc ' , ' google / protobuf / io / gzip_stream . cc ' , ' google / protobuf / generated_message_reflection . cc ' , ' google / protobuf / field_mask . pb . cc ' , ' google / protobuf / extension_set_heavy . cc ' , ' google / protobuf / empty . pb . cc ' , ' google / protobuf / dynamic_message . cc ' , ' google / protobuf / duration . pb . cc ' , ' google / protobuf / descriptor_database . cc ' , ' google / protobuf / descriptor . pb . cc ' , ' google / protobuf / descriptor . cc ' , ' google / protobuf / compiler / parser . cc ' , ' google / protobuf / compiler / importer . cc ' , ' google / protobuf / api . pb . cc ' , ' google / protobuf / any . pb . cc ' , ' google / protobuf / any . cc ' , ' google / protobuf / wire_format_lite . cc ' , ' google / protobuf / stubs / time . cc ' , ' google / protobuf / stubs / strutil . cc ' , ' google / protobuf / stubs / structurally_valid . cc ' , ' google / protobuf / stubs / stringprintf . cc ' , ' google / protobuf / stubs / stringpiece . cc ' , ' google / protobuf / stubs / statusor . cc ' , ' google / protobuf / stubs / status . cc ' , ' google / protobuf / stubs / once . cc ' , ' google / protobuf / stubs / int128 . cc ' , ' google / protobuf / stubs / common . cc ' , ' google / protobuf / stubs / bytestream . cc ' , ' google / protobuf / stubs / atomicops_internals_x86_msvc . cc ' , ' google / protobuf / stubs / atomicops_internals_x86_gcc . cc ' , ' google / protobuf / repeated_field . cc ' , ' google / protobuf / message_lite . cc ' , ' google / protobuf / io / zero_copy_stream_impl_lite . cc ' , ' google / protobuf / io / zero_copy_stream . cc ' , ' google / protobuf / io / coded_stream . cc ' , ' google / protobuf / generated_message_util . cc ' , ' google / protobuf / extension_set . cc ' , ' google / protobuf / arenastring . cc ' , ' google / protobuf / arena . cc ' , ' google / protobuf / compiler / js / embed . cc ' ] <nl> + CC_FILES = [ ' google / protobuf / compiler / zip_writer . cc ' , ' google / protobuf / compiler / subprocess . cc ' , ' google / protobuf / compiler / ruby / ruby_generator . cc ' , ' google / protobuf / compiler / python / python_generator . cc ' , ' google / protobuf / compiler / plugin . pb . cc ' , ' google / protobuf / compiler / plugin . cc ' , ' google / protobuf / compiler / php / php_generator . cc ' , ' google / protobuf / compiler / objectivec / objectivec_primitive_field . cc ' , ' google / protobuf / compiler / objectivec / objectivec_oneof . cc ' , ' google / protobuf / compiler / objectivec / objectivec_message_field . cc ' , ' google / protobuf / compiler / objectivec / objectivec_message . cc ' , ' google / protobuf / compiler / objectivec / objectivec_map_field . cc ' , ' google / protobuf / compiler / objectivec / objectivec_helpers . cc ' , ' google / protobuf / compiler / objectivec / objectivec_generator . cc ' , ' google / protobuf / compiler / objectivec / objectivec_file . cc ' , ' google / protobuf / compiler / objectivec / objectivec_field . cc ' , ' google / protobuf / compiler / objectivec / objectivec_extension . cc ' , ' google / protobuf / compiler / objectivec / objectivec_enum_field . cc ' , ' google / protobuf / compiler / objectivec / objectivec_enum . cc ' , ' google / protobuf / compiler / js / well_known_types_embed . cc ' , ' google / protobuf / compiler / js / js_generator . cc ' , ' google / protobuf / compiler / javanano / javanano_primitive_field . cc ' , ' google / protobuf / compiler / javanano / javanano_message_field . cc ' , ' google / protobuf / compiler / javanano / javanano_message . cc ' , ' google / protobuf / compiler / javanano / javanano_map_field . cc ' , ' google / protobuf / compiler / javanano / javanano_helpers . cc ' , ' google / protobuf / compiler / javanano / javanano_generator . cc ' , ' google / protobuf / compiler / javanano / javanano_file . cc ' , ' google / protobuf / compiler / javanano / javanano_field . cc ' , ' google / protobuf / compiler / javanano / javanano_extension . cc ' , ' google / protobuf / compiler / javanano / javanano_enum_field . cc ' , ' google / protobuf / compiler / javanano / javanano_enum . cc ' , ' google / protobuf / compiler / java / java_string_field_lite . cc ' , ' google / protobuf / compiler / java / java_string_field . cc ' , ' google / protobuf / compiler / java / java_shared_code_generator . cc ' , ' google / protobuf / compiler / java / java_service . cc ' , ' google / protobuf / compiler / java / java_primitive_field_lite . cc ' , ' google / protobuf / compiler / java / java_primitive_field . cc ' , ' google / protobuf / compiler / java / java_name_resolver . cc ' , ' google / protobuf / compiler / java / java_message_lite . cc ' , ' google / protobuf / compiler / java / java_message_field_lite . cc ' , ' google / protobuf / compiler / java / java_message_field . cc ' , ' google / protobuf / compiler / java / java_message_builder_lite . cc ' , ' google / protobuf / compiler / java / java_message_builder . cc ' , ' google / protobuf / compiler / java / java_message . cc ' , ' google / protobuf / compiler / java / java_map_field_lite . cc ' , ' google / protobuf / compiler / java / java_map_field . cc ' , ' google / protobuf / compiler / java / java_lazy_message_field_lite . cc ' , ' google / protobuf / compiler / java / java_lazy_message_field . cc ' , ' google / protobuf / compiler / java / java_helpers . cc ' , ' google / protobuf / compiler / java / java_generator_factory . cc ' , ' google / protobuf / compiler / java / java_generator . cc ' , ' google / protobuf / compiler / java / java_file . cc ' , ' google / protobuf / compiler / java / java_field . cc ' , ' google / protobuf / compiler / java / java_extension_lite . cc ' , ' google / protobuf / compiler / java / java_extension . cc ' , ' google / protobuf / compiler / java / java_enum_lite . cc ' , ' google / protobuf / compiler / java / java_enum_field_lite . cc ' , ' google / protobuf / compiler / java / java_enum_field . cc ' , ' google / protobuf / compiler / java / java_enum . cc ' , ' google / protobuf / compiler / java / java_doc_comment . cc ' , ' google / protobuf / compiler / java / java_context . cc ' , ' google / protobuf / compiler / csharp / csharp_wrapper_field . cc ' , ' google / protobuf / compiler / csharp / csharp_source_generator_base . cc ' , ' google / protobuf / compiler / csharp / csharp_repeated_primitive_field . cc ' , ' google / protobuf / compiler / csharp / csharp_repeated_message_field . cc ' , ' google / protobuf / compiler / csharp / csharp_repeated_enum_field . cc ' , ' google / protobuf / compiler / csharp / csharp_reflection_class . cc ' , ' google / protobuf / compiler / csharp / csharp_primitive_field . cc ' , ' google / protobuf / compiler / csharp / csharp_message_field . cc ' , ' google / protobuf / compiler / csharp / csharp_message . cc ' , ' google / protobuf / compiler / csharp / csharp_map_field . cc ' , ' google / protobuf / compiler / csharp / csharp_helpers . cc ' , ' google / protobuf / compiler / csharp / csharp_generator . cc ' , ' google / protobuf / compiler / csharp / csharp_field_base . cc ' , ' google / protobuf / compiler / csharp / csharp_enum_field . cc ' , ' google / protobuf / compiler / csharp / csharp_enum . cc ' , ' google / protobuf / compiler / csharp / csharp_doc_comment . cc ' , ' google / protobuf / compiler / cpp / cpp_string_field . cc ' , ' google / protobuf / compiler / cpp / cpp_service . cc ' , ' google / protobuf / compiler / cpp / cpp_primitive_field . cc ' , ' google / protobuf / compiler / cpp / cpp_message_field . cc ' , ' google / protobuf / compiler / cpp / cpp_message . cc ' , ' google / protobuf / compiler / cpp / cpp_map_field . cc ' , ' google / protobuf / compiler / cpp / cpp_helpers . cc ' , ' google / protobuf / compiler / cpp / cpp_generator . cc ' , ' google / protobuf / compiler / cpp / cpp_file . cc ' , ' google / protobuf / compiler / cpp / cpp_field . cc ' , ' google / protobuf / compiler / cpp / cpp_extension . cc ' , ' google / protobuf / compiler / cpp / cpp_enum_field . cc ' , ' google / protobuf / compiler / cpp / cpp_enum . cc ' , ' google / protobuf / compiler / command_line_interface . cc ' , ' google / protobuf / compiler / code_generator . cc ' , ' google / protobuf / wrappers . pb . cc ' , ' google / protobuf / wire_format . cc ' , ' google / protobuf / util / type_resolver_util . cc ' , ' google / protobuf / util / time_util . cc ' , ' google / protobuf / util / message_differencer . cc ' , ' google / protobuf / util / json_util . cc ' , ' google / protobuf / util / internal / utility . cc ' , ' google / protobuf / util / internal / type_info_test_helper . cc ' , ' google / protobuf / util / internal / type_info . cc ' , ' google / protobuf / util / internal / protostream_objectwriter . cc ' , ' google / protobuf / util / internal / protostream_objectsource . cc ' , ' google / protobuf / util / internal / proto_writer . cc ' , ' google / protobuf / util / internal / object_writer . cc ' , ' google / protobuf / util / internal / json_stream_parser . cc ' , ' google / protobuf / util / internal / json_objectwriter . cc ' , ' google / protobuf / util / internal / json_escaping . cc ' , ' google / protobuf / util / internal / field_mask_utility . cc ' , ' google / protobuf / util / internal / error_listener . cc ' , ' google / protobuf / util / internal / default_value_objectwriter . cc ' , ' google / protobuf / util / internal / datapiece . cc ' , ' google / protobuf / util / field_mask_util . cc ' , ' google / protobuf / util / field_comparator . cc ' , ' google / protobuf / util / delimited_message_util . cc ' , ' google / protobuf / unknown_field_set . cc ' , ' google / protobuf / type . pb . cc ' , ' google / protobuf / timestamp . pb . cc ' , ' google / protobuf / text_format . cc ' , ' google / protobuf / stubs / substitute . cc ' , ' google / protobuf / stubs / mathlimits . cc ' , ' google / protobuf / struct . pb . cc ' , ' google / protobuf / source_context . pb . cc ' , ' google / protobuf / service . cc ' , ' google / protobuf / reflection_ops . cc ' , ' google / protobuf / message . cc ' , ' google / protobuf / map_field . cc ' , ' google / protobuf / io / zero_copy_stream_impl . cc ' , ' google / protobuf / io / tokenizer . cc ' , ' google / protobuf / io / strtod . cc ' , ' google / protobuf / io / printer . cc ' , ' google / protobuf / io / gzip_stream . cc ' , ' google / protobuf / generated_message_reflection . cc ' , ' google / protobuf / field_mask . pb . cc ' , ' google / protobuf / extension_set_heavy . cc ' , ' google / protobuf / empty . pb . cc ' , ' google / protobuf / dynamic_message . cc ' , ' google / protobuf / duration . pb . cc ' , ' google / protobuf / descriptor_database . cc ' , ' google / protobuf / descriptor . pb . cc ' , ' google / protobuf / descriptor . cc ' , ' google / protobuf / compiler / parser . cc ' , ' google / protobuf / compiler / importer . cc ' , ' google / protobuf / api . pb . cc ' , ' google / protobuf / any . pb . cc ' , ' google / protobuf / any . cc ' , ' google / protobuf / wire_format_lite . cc ' , ' google / protobuf / stubs / time . cc ' , ' google / protobuf / stubs / strutil . cc ' , ' google / protobuf / stubs / structurally_valid . cc ' , ' google / protobuf / stubs / stringprintf . cc ' , ' google / protobuf / stubs / stringpiece . cc ' , ' google / protobuf / stubs / statusor . cc ' , ' google / protobuf / stubs / status . cc ' , ' google / protobuf / stubs / once . cc ' , ' google / protobuf / stubs / int128 . cc ' , ' google / protobuf / stubs / common . cc ' , ' google / protobuf / stubs / bytestream . cc ' , ' google / protobuf / stubs / atomicops_internals_x86_msvc . cc ' , ' google / protobuf / stubs / atomicops_internals_x86_gcc . cc ' , ' google / protobuf / repeated_field . cc ' , ' google / protobuf / message_lite . cc ' , ' google / protobuf / io / zero_copy_stream_impl_lite . cc ' , ' google / protobuf / io / zero_copy_stream . cc ' , ' google / protobuf / io / coded_stream . cc ' , ' google / protobuf / generated_message_util . cc ' , ' google / protobuf / extension_set . cc ' , ' google / protobuf / arenastring . cc ' , ' google / protobuf / arena . cc ' , ' google / protobuf / compiler / js / embed . cc ' ] <nl> PROTO_FILES = [ ' google / protobuf / wrappers . proto ' , ' google / protobuf / type . proto ' , ' google / protobuf / timestamp . proto ' , ' google / protobuf / struct . proto ' , ' google / protobuf / source_context . proto ' , ' google / protobuf / field_mask . proto ' , ' google / protobuf / empty . proto ' , ' google / protobuf / duration . proto ' , ' google / protobuf / descriptor . proto ' , ' google / protobuf / compiler / plugin . proto ' , ' google / protobuf / api . proto ' , ' google / protobuf / any . proto ' ] <nl> <nl> CC_INCLUDE = ' third_party / protobuf / src ' <nl> mmm a / tools / dockerfile / grpc_clang_format / clang_format_all_the_things . sh <nl> ppp b / tools / dockerfile / grpc_clang_format / clang_format_all_the_things . sh <nl> <nl> set - e <nl> <nl> # directories to run against <nl> - DIRS = " src / core / lib src / core / ext src / cpp test / core test / cpp include src / compiler " <nl> + DIRS = " src / core / lib src / core / tsi src / core / ext src / cpp test / core test / cpp include src / compiler " <nl> <nl> # file matching patterns to check <nl> GLOB = " * . h * . c * . cc " <nl> mmm a / tools / dockerfile / interoptest / grpc_interop_csharp / Dockerfile <nl> ppp b / tools / dockerfile / interoptest / grpc_interop_csharp / Dockerfile <nl> RUN apt - key adv - - keyserver keyserver . ubuntu . com - - recv - keys 3FA7E0328081BFF6A14 <nl> RUN echo " deb http : / / download . mono - project . com / repo / debian wheezy main " | tee / etc / apt / sources . list . d / mono - xamarin . list <nl> RUN echo " deb http : / / download . mono - project . com / repo / debian wheezy - apache24 - compat main " | tee - a / etc / apt / sources . list . d / mono - xamarin . list <nl> RUN echo " deb http : / / download . mono - project . com / repo / debian wheezy - libjpeg62 - compat main " | tee - a / etc / apt / sources . list . d / mono - xamarin . list <nl> - RUN echo " deb http : / / download . mono - project . com / repo / debian wheezy - libtiff - compat main " | tee - a / etc / apt / sources . list . d / mono - xamarin . list <nl> <nl> # Install dependencies <nl> RUN apt - get update & & apt - get - y dist - upgrade & & apt - get install - y \ <nl> RUN apt - get update & & apt - get - y dist - upgrade & & apt - get install - y \ <nl> <nl> RUN nuget update - self <nl> <nl> + # Install dotnet SDK based on https : / / www . microsoft . com / net / core # debian <nl> + RUN apt - get update & & apt - get install - y curl libunwind8 gettext <nl> + # dotnet - dev - 1 . 0 . 0 - preview2 - 003131 <nl> + RUN curl - sSL - o dotnet100 . tar . gz https : / / go . microsoft . com / fwlink / ? LinkID = 827530 <nl> + RUN mkdir - p / opt / dotnet & & tar zxf dotnet100 . tar . gz - C / opt / dotnet <nl> + # dotnet - dev - 1 . 0 . 1 <nl> + RUN curl - sSL - o dotnet101 . tar . gz https : / / go . microsoft . com / fwlink / ? LinkID = 843453 <nl> + RUN mkdir - p / opt / dotnet & & tar zxf dotnet101 . tar . gz - C / opt / dotnet <nl> + RUN ln - s / opt / dotnet / dotnet / usr / local / bin <nl> + <nl> + # Trigger the population of the local package cache <nl> + ENV NUGET_XMLDOC_MODE skip <nl> + RUN mkdir warmup \ <nl> + & & cd warmup \ <nl> + & & dotnet new \ <nl> + & & cd . . \ <nl> + & & rm - rf warmup <nl> + <nl> # Prepare ccache <nl> RUN ln - s / usr / bin / ccache / usr / local / bin / gcc <nl> RUN ln - s / usr / bin / ccache / usr / local / bin / g + + <nl> mmm a / tools / dockerfile / interoptest / grpc_interop_csharpcoreclr / Dockerfile <nl> ppp b / tools / dockerfile / interoptest / grpc_interop_csharpcoreclr / Dockerfile <nl> RUN apt - key adv - - keyserver keyserver . ubuntu . com - - recv - keys 3FA7E0328081BFF6A14 <nl> RUN echo " deb http : / / download . mono - project . com / repo / debian wheezy main " | tee / etc / apt / sources . list . d / mono - xamarin . list <nl> RUN echo " deb http : / / download . mono - project . com / repo / debian wheezy - apache24 - compat main " | tee - a / etc / apt / sources . list . d / mono - xamarin . list <nl> RUN echo " deb http : / / download . mono - project . com / repo / debian wheezy - libjpeg62 - compat main " | tee - a / etc / apt / sources . list . d / mono - xamarin . list <nl> - RUN echo " deb http : / / download . mono - project . com / repo / debian wheezy - libtiff - compat main " | tee - a / etc / apt / sources . list . d / mono - xamarin . list <nl> <nl> # Install dependencies <nl> RUN apt - get update & & apt - get - y dist - upgrade & & apt - get install - y \ <nl> RUN nuget update - self <nl> <nl> # Install dotnet SDK based on https : / / www . microsoft . com / net / core # debian <nl> RUN apt - get update & & apt - get install - y curl libunwind8 gettext <nl> - # dotnet - dev - 1 . 0 . 0 - preview2 - 003121 <nl> - RUN curl - sSL - o dotnet100 . tar . gz https : / / go . microsoft . com / fwlink / ? LinkID = 809130 <nl> + # dotnet - dev - 1 . 0 . 0 - preview2 - 003131 <nl> + RUN curl - sSL - o dotnet100 . tar . gz https : / / go . microsoft . com / fwlink / ? LinkID = 827530 <nl> RUN mkdir - p / opt / dotnet & & tar zxf dotnet100 . tar . gz - C / opt / dotnet <nl> # dotnet - dev - 1 . 0 . 1 <nl> RUN curl - sSL - o dotnet101 . tar . gz https : / / go . microsoft . com / fwlink / ? LinkID = 843453 <nl> mmm a / tools / dockerfile / stress_test / grpc_interop_stress_csharp / Dockerfile <nl> ppp b / tools / dockerfile / stress_test / grpc_interop_stress_csharp / Dockerfile <nl> RUN apt - key adv - - keyserver keyserver . ubuntu . com - - recv - keys 3FA7E0328081BFF6A14 <nl> RUN echo " deb http : / / download . mono - project . com / repo / debian wheezy main " | tee / etc / apt / sources . list . d / mono - xamarin . list <nl> RUN echo " deb http : / / download . mono - project . com / repo / debian wheezy - apache24 - compat main " | tee - a / etc / apt / sources . list . d / mono - xamarin . list <nl> RUN echo " deb http : / / download . mono - project . com / repo / debian wheezy - libjpeg62 - compat main " | tee - a / etc / apt / sources . list . d / mono - xamarin . list <nl> - RUN echo " deb http : / / download . mono - project . com / repo / debian wheezy - libtiff - compat main " | tee - a / etc / apt / sources . list . d / mono - xamarin . list <nl> <nl> # Install dependencies <nl> RUN apt - get update & & apt - get - y dist - upgrade & & apt - get install - y \ <nl> mmm a / tools / dockerfile / test / bazel / Dockerfile <nl> ppp b / tools / dockerfile / test / bazel / Dockerfile <nl> RUN curl https : / / bazel . build / bazel - release . pub . gpg | apt - key add - <nl> RUN apt - get - y update <nl> RUN apt - get - y install bazel <nl> <nl> + # Pin Bazel to 0 . 4 . 4 <nl> + # Installing Bazel via apt - get first is required before installing 0 . 4 . 4 to <nl> + # allow gRPC to build without errors . See https : / / github . com / grpc / grpc / issues / 10553 <nl> + RUN curl - fSsL - O https : / / github . com / bazelbuild / bazel / releases / download / 0 . 4 . 4 / bazel - 0 . 4 . 4 - installer - linux - x86_64 . sh <nl> + RUN chmod + x . / bazel - 0 . 4 . 4 - installer - linux - x86_64 . sh <nl> + RUN . / bazel - 0 . 4 . 4 - installer - linux - x86_64 . sh <nl> + <nl> RUN mkdir - p / var / local / jenkins <nl> <nl> # Define the default command . <nl> mmm a / tools / dockerfile / test / csharp_coreclr_x64 / Dockerfile <nl> ppp b / tools / dockerfile / test / csharp_coreclr_x64 / Dockerfile <nl> RUN apt - key adv - - keyserver keyserver . ubuntu . com - - recv - keys 3FA7E0328081BFF6A14 <nl> RUN echo " deb http : / / download . mono - project . com / repo / debian wheezy main " | tee / etc / apt / sources . list . d / mono - xamarin . list <nl> RUN echo " deb http : / / download . mono - project . com / repo / debian wheezy - apache24 - compat main " | tee - a / etc / apt / sources . list . d / mono - xamarin . list <nl> RUN echo " deb http : / / download . mono - project . com / repo / debian wheezy - libjpeg62 - compat main " | tee - a / etc / apt / sources . list . d / mono - xamarin . list <nl> - RUN echo " deb http : / / download . mono - project . com / repo / debian wheezy - libtiff - compat main " | tee - a / etc / apt / sources . list . d / mono - xamarin . list <nl> <nl> # Install dependencies <nl> RUN apt - get update & & apt - get - y dist - upgrade & & apt - get install - y \ <nl> RUN nuget update - self <nl> <nl> # Install dotnet SDK based on https : / / www . microsoft . com / net / core # debian <nl> RUN apt - get update & & apt - get install - y curl libunwind8 gettext <nl> - # dotnet - dev - 1 . 0 . 0 - preview2 - 003121 <nl> - RUN curl - sSL - o dotnet100 . tar . gz https : / / go . microsoft . com / fwlink / ? LinkID = 809130 <nl> + # dotnet - dev - 1 . 0 . 0 - preview2 - 003131 <nl> + RUN curl - sSL - o dotnet100 . tar . gz https : / / go . microsoft . com / fwlink / ? LinkID = 827530 <nl> RUN mkdir - p / opt / dotnet & & tar zxf dotnet100 . tar . gz - C / opt / dotnet <nl> # dotnet - dev - 1 . 0 . 1 <nl> RUN curl - sSL - o dotnet101 . tar . gz https : / / go . microsoft . com / fwlink / ? LinkID = 843453 <nl> mmm a / tools / dockerfile / test / csharp_jessie_x64 / Dockerfile <nl> ppp b / tools / dockerfile / test / csharp_jessie_x64 / Dockerfile <nl> RUN apt - key adv - - keyserver keyserver . ubuntu . com - - recv - keys 3FA7E0328081BFF6A14 <nl> RUN echo " deb http : / / download . mono - project . com / repo / debian wheezy main " | tee / etc / apt / sources . list . d / mono - xamarin . list <nl> RUN echo " deb http : / / download . mono - project . com / repo / debian wheezy - apache24 - compat main " | tee - a / etc / apt / sources . list . d / mono - xamarin . list <nl> RUN echo " deb http : / / download . mono - project . com / repo / debian wheezy - libjpeg62 - compat main " | tee - a / etc / apt / sources . list . d / mono - xamarin . list <nl> - RUN echo " deb http : / / download . mono - project . com / repo / debian wheezy - libtiff - compat main " | tee - a / etc / apt / sources . list . d / mono - xamarin . list <nl> <nl> # Install dependencies <nl> RUN apt - get update & & apt - get - y dist - upgrade & & apt - get install - y \ <nl> RUN apt - get update & & apt - get - y dist - upgrade & & apt - get install - y \ <nl> <nl> RUN nuget update - self <nl> <nl> + # Install dotnet SDK based on https : / / www . microsoft . com / net / core # debian <nl> + RUN apt - get update & & apt - get install - y curl libunwind8 gettext <nl> + # dotnet - dev - 1 . 0 . 0 - preview2 - 003131 <nl> + RUN curl - sSL - o dotnet100 . tar . gz https : / / go . microsoft . com / fwlink / ? LinkID = 827530 <nl> + RUN mkdir - p / opt / dotnet & & tar zxf dotnet100 . tar . gz - C / opt / dotnet <nl> + # dotnet - dev - 1 . 0 . 1 <nl> + RUN curl - sSL - o dotnet101 . tar . gz https : / / go . microsoft . com / fwlink / ? LinkID = 843453 <nl> + RUN mkdir - p / opt / dotnet & & tar zxf dotnet101 . tar . gz - C / opt / dotnet <nl> + RUN ln - s / opt / dotnet / dotnet / usr / local / bin <nl> + <nl> + # Trigger the population of the local package cache <nl> + ENV NUGET_XMLDOC_MODE skip <nl> + RUN mkdir warmup \ <nl> + & & cd warmup \ <nl> + & & dotnet new \ <nl> + & & cd . . \ <nl> + & & rm - rf warmup <nl> + <nl> # Prepare ccache <nl> RUN ln - s / usr / bin / ccache / usr / local / bin / gcc <nl> RUN ln - s / usr / bin / ccache / usr / local / bin / g + + <nl> new file mode 100644 <nl> index 00000000000 . . f9468757da2 <nl> mmm / dev / null <nl> ppp b / tools / dockerfile / test / cxx_alpine_x64 / Dockerfile <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> + FROM alpine : 3 . 3 <nl> + <nl> + # Install Git and basic packages . <nl> + RUN apk update & & apk add \ <nl> + autoconf \ <nl> + automake \ <nl> + bzip2 \ <nl> + build - base \ <nl> + cmake \ <nl> + ccache \ <nl> + curl \ <nl> + gcc \ <nl> + git \ <nl> + libtool \ <nl> + make \ <nl> + perl \ <nl> + strace \ <nl> + python - dev \ <nl> + py - pip \ <nl> + unzip \ <nl> + wget \ <nl> + zip <nl> + <nl> + # Install Python packages from PyPI <nl> + RUN pip install pip - - upgrade <nl> + RUN pip install virtualenv <nl> + RUN pip install futures = = 2 . 2 . 0 enum34 = = 1 . 0 . 4 protobuf = = 3 . 2 . 0 six = = 1 . 10 . 0 <nl> + <nl> + # Prepare ccache <nl> + RUN ln - s / usr / bin / ccache / usr / local / bin / gcc <nl> + RUN ln - s / usr / bin / ccache / usr / local / bin / g + + <nl> + RUN ln - s / usr / bin / ccache / usr / local / bin / cc <nl> + RUN ln - s / usr / bin / ccache / usr / local / bin / c + + <nl> + <nl> + # Install gflags <nl> + RUN git clone https : / / github . com / gflags / gflags . git & & cd gflags & & git checkout v2 . 2 . 0 <nl> + RUN cd gflags & & cmake . & & make & & make install <nl> + RUN ln - s / usr / local / include / gflags / usr / include / gflags <nl> + <nl> + RUN mkdir - p / var / local / jenkins <nl> + <nl> + # Define the default command . <nl> + CMD [ " bash " ] <nl> mmm a / tools / dockerfile / test / multilang_jessie_x64 / Dockerfile <nl> ppp b / tools / dockerfile / test / multilang_jessie_x64 / Dockerfile <nl> RUN apt - key adv - - keyserver keyserver . ubuntu . com - - recv - keys 3FA7E0328081BFF6A14 <nl> RUN echo " deb http : / / download . mono - project . com / repo / debian wheezy main " | tee / etc / apt / sources . list . d / mono - xamarin . list <nl> RUN echo " deb http : / / download . mono - project . com / repo / debian wheezy - apache24 - compat main " | tee - a / etc / apt / sources . list . d / mono - xamarin . list <nl> RUN echo " deb http : / / download . mono - project . com / repo / debian wheezy - libjpeg62 - compat main " | tee - a / etc / apt / sources . list . d / mono - xamarin . list <nl> - RUN echo " deb http : / / download . mono - project . com / repo / debian wheezy - libtiff - compat main " | tee - a / etc / apt / sources . list . d / mono - xamarin . list <nl> <nl> # Install dependencies <nl> RUN apt - get update & & apt - get - y dist - upgrade & & apt - get install - y \ <nl> old mode 100755 <nl> new mode 100644 <nl> similarity index 68 % <nl> rename from tools / run_tests / helper_scripts / build_csharp_coreclr . sh <nl> rename to tools / dockerfile / test / python_alpine_x64 / Dockerfile <nl> index dd5fd31c759 . . bdffbd35982 <nl> mmm a / tools / run_tests / helper_scripts / build_csharp_coreclr . sh <nl> ppp b / tools / dockerfile / test / python_alpine_x64 / Dockerfile <nl> <nl> - # ! / bin / bash <nl> # Copyright 2015 , Google Inc . <nl> # All rights reserved . <nl> # <nl> <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> - set - ex <nl> + FROM alpine : 3 . 3 <nl> <nl> - cd $ ( dirname $ 0 ) / . . / . . / . . / src / csharp <nl> + # Install Git and basic packages . <nl> + RUN apk update & & apk add \ <nl> + autoconf \ <nl> + automake \ <nl> + bzip2 \ <nl> + build - base \ <nl> + cmake \ <nl> + ccache \ <nl> + curl \ <nl> + gcc \ <nl> + git \ <nl> + libtool \ <nl> + make \ <nl> + perl \ <nl> + strace \ <nl> + python - dev \ <nl> + py - pip \ <nl> + unzip \ <nl> + wget \ <nl> + zip <nl> <nl> - # TODO ( jtattermusch ) : introduce caching <nl> - dotnet restore . <nl> + # Install Python packages from PyPI <nl> + RUN pip install pip - - upgrade <nl> + RUN pip install virtualenv <nl> + RUN pip install futures = = 2 . 2 . 0 enum34 = = 1 . 0 . 4 protobuf = = 3 . 2 . 0 six = = 1 . 10 . 0 <nl> <nl> - dotnet build - - configuration $ MSBUILD_CONFIG ' * * / project . json ' <nl> + # Prepare ccache <nl> + RUN ln - s / usr / bin / ccache / usr / local / bin / gcc <nl> + RUN ln - s / usr / bin / ccache / usr / local / bin / g + + <nl> + RUN ln - s / usr / bin / ccache / usr / local / bin / cc <nl> + RUN ln - s / usr / bin / ccache / usr / local / bin / c + + <nl> + <nl> + RUN mkdir - p / var / local / jenkins <nl> + <nl> + # Define the default command . <nl> + CMD [ " bash " ] <nl> mmm a / tools / doxygen / Doxyfile . c + + . internal <nl> ppp b / tools / doxygen / Doxyfile . c + + . internal <nl> src / core / lib / iomgr / iomgr_uv . c \ <nl> src / core / lib / iomgr / iomgr_windows . c \ <nl> src / core / lib / iomgr / load_file . c \ <nl> src / core / lib / iomgr / load_file . h \ <nl> + src / core / lib / iomgr / lockfree_event . c \ <nl> + src / core / lib / iomgr / lockfree_event . h \ <nl> src / core / lib / iomgr / network_status_tracker . c \ <nl> src / core / lib / iomgr / network_status_tracker . h \ <nl> src / core / lib / iomgr / polling_entity . c \ <nl> mmm a / tools / doxygen / Doxyfile . core . internal <nl> ppp b / tools / doxygen / Doxyfile . core . internal <nl> src / core / lib / iomgr / iomgr_uv . c \ <nl> src / core / lib / iomgr / iomgr_windows . c \ <nl> src / core / lib / iomgr / load_file . c \ <nl> src / core / lib / iomgr / load_file . h \ <nl> + src / core / lib / iomgr / lockfree_event . c \ <nl> + src / core / lib / iomgr / lockfree_event . h \ <nl> src / core / lib / iomgr / network_status_tracker . c \ <nl> src / core / lib / iomgr / network_status_tracker . h \ <nl> src / core / lib / iomgr / polling_entity . c \ <nl> mmm a / tools / gce / linux_performance_worker_init . sh <nl> ppp b / tools / gce / linux_performance_worker_init . sh <nl> sudo sh - c ' echo " deb [ arch = amd64 ] https : / / apt - mo . trafficmanager . net / repos / dotne <nl> sudo apt - key adv - - keyserver apt - mo . trafficmanager . net - - recv - keys 417A0893 <nl> sudo apt - get update <nl> sudo apt - get install - y dotnet - dev - 1 . 0 . 0 - preview2 - 003131 <nl> + sudo apt - get install - y dotnet - dev - 1 . 0 . 1 <nl> <nl> # Ruby dependencies <nl> gpg - - keyserver hkp : / / keys . gnupg . net - - recv - keys 409B6B1796C275462A1703113804BB82D39DC0E3 <nl> mmm a / tools / run_tests / generated / sources_and_headers . json <nl> ppp b / tools / run_tests / generated / sources_and_headers . json <nl> <nl> " third_party " : false , <nl> " type " : " target " <nl> } , <nl> + { <nl> + " deps " : [ <nl> + " benchmark " , <nl> + " gpr " , <nl> + " gpr_test_util " , <nl> + " grpc " , <nl> + " grpc + + " , <nl> + " grpc + + _test_util " , <nl> + " grpc_benchmark " , <nl> + " grpc_test_util " <nl> + ] , <nl> + " headers " : [ ] , <nl> + " is_filegroup " : false , <nl> + " language " : " c + + " , <nl> + " name " : " bm_cq_multiple_threads " , <nl> + " src " : [ <nl> + " test / cpp / microbenchmarks / bm_cq_multiple_threads . cc " <nl> + ] , <nl> + " third_party " : false , <nl> + " type " : " target " <nl> + } , <nl> { <nl> " deps " : [ <nl> " benchmark " , <nl> <nl> " src / core / lib / iomgr / iomgr_internal . h " , <nl> " src / core / lib / iomgr / iomgr_posix . h " , <nl> " src / core / lib / iomgr / load_file . h " , <nl> + " src / core / lib / iomgr / lockfree_event . h " , <nl> " src / core / lib / iomgr / network_status_tracker . h " , <nl> " src / core / lib / iomgr / polling_entity . h " , <nl> " src / core / lib / iomgr / pollset . h " , <nl> <nl> " src / core / lib / iomgr / iomgr_windows . c " , <nl> " src / core / lib / iomgr / load_file . c " , <nl> " src / core / lib / iomgr / load_file . h " , <nl> + " src / core / lib / iomgr / lockfree_event . c " , <nl> + " src / core / lib / iomgr / lockfree_event . h " , <nl> " src / core / lib / iomgr / network_status_tracker . c " , <nl> " src / core / lib / iomgr / network_status_tracker . h " , <nl> " src / core / lib / iomgr / polling_entity . c " , <nl> mmm a / tools / run_tests / generated / tests . json <nl> ppp b / tools / run_tests / generated / tests . json <nl> <nl> " posix " <nl> ] <nl> } , <nl> + { <nl> + " args " : [ <nl> + " - - benchmark_min_time = 0 " <nl> + ] , <nl> + " ci_platforms " : [ <nl> + " linux " , <nl> + " mac " , <nl> + " posix " <nl> + ] , <nl> + " cpu_cost " : 1 . 0 , <nl> + " exclude_configs " : [ ] , <nl> + " exclude_iomgrs " : [ ] , <nl> + " flaky " : false , <nl> + " gtest " : false , <nl> + " language " : " c + + " , <nl> + " name " : " bm_cq_multiple_threads " , <nl> + " platforms " : [ <nl> + " linux " , <nl> + " mac " , <nl> + " posix " <nl> + ] <nl> + } , <nl> { <nl> " args " : [ <nl> " - - benchmark_min_time = 0 " <nl> <nl> ] , <nl> " uses_polling " : false <nl> } , <nl> + { <nl> + " args " : [ <nl> + " test / core / end2end / fuzzers / server_fuzzer_corpus / clusterfuzz - testcase - 6312731374256128 " <nl> + ] , <nl> + " ci_platforms " : [ <nl> + " linux " <nl> + ] , <nl> + " cpu_cost " : 0 . 1 , <nl> + " exclude_configs " : [ <nl> + " tsan " <nl> + ] , <nl> + " exclude_iomgrs " : [ <nl> + " uv " <nl> + ] , <nl> + " flaky " : false , <nl> + " language " : " c " , <nl> + " name " : " server_fuzzer_one_entry " , <nl> + " platforms " : [ <nl> + " mac " , <nl> + " linux " <nl> + ] , <nl> + " uses_polling " : false <nl> + } , <nl> { <nl> " args " : [ <nl> " test / core / end2end / fuzzers / server_fuzzer_corpus / crash - 0f4b135c0242669ce425d2662168e9440f8a628d " <nl> similarity index 93 % <nl> rename from tools / run_tests / helper_scripts / build_csharp_coreclr . bat <nl> rename to tools / run_tests / helper_scripts / build_csharp . bat <nl> mmm a / tools / run_tests / helper_scripts / build_csharp_coreclr . bat <nl> ppp b / tools / run_tests / helper_scripts / build_csharp . bat <nl> setlocal <nl> <nl> cd / d % ~ dp0 \ . . \ . . \ . . \ src \ csharp <nl> <nl> - dotnet restore . | | goto : error <nl> - <nl> - dotnet build - - configuration % MSBUILD_CONFIG % " * * / project . json " | | goto : error <nl> + dotnet build - - configuration % MSBUILD_CONFIG % Grpc . sln | | goto : error <nl> <nl> endlocal <nl> <nl> mmm a / tools / run_tests / helper_scripts / build_csharp . sh <nl> ppp b / tools / run_tests / helper_scripts / build_csharp . sh <nl> set - ex <nl> <nl> cd $ ( dirname $ 0 ) / . . / . . / . . / src / csharp <nl> <nl> - # overriding NativeDependenciesConfigurationUnix is needed to make gcov code coverage work . <nl> - xbuild / p : Configuration = $ MSBUILD_CONFIG / p : NativeDependenciesConfigurationUnix = $ CONFIG Grpc . sln <nl> + if [ " $ CONFIG " = = " gcov " ] <nl> + then <nl> + # overriding NativeDependenciesConfigurationUnix makes C # project pick up the gcov flavor of grpc_csharp_ext <nl> + dotnet build - - configuration $ MSBUILD_CONFIG / p : NativeDependenciesConfigurationUnix = gcov Grpc . sln <nl> + else <nl> + dotnet build - - configuration $ MSBUILD_CONFIG Grpc . sln <nl> + fi <nl> mmm a / tools / run_tests / helper_scripts / build_python . sh <nl> ppp b / tools / run_tests / helper_scripts / build_python . sh <nl> fi <nl> ( $ PYTHON - m virtualenv $ VENV | | <nl> $ HOST_PYTHON - m virtualenv - p $ PYTHON $ VENV | | <nl> true ) <nl> - VENV_PYTHON = ` script_realpath - s " $ VENV / $ VENV_RELATIVE_PYTHON " ` <nl> + VENV_PYTHON = ` script_realpath " $ VENV / $ VENV_RELATIVE_PYTHON " ` <nl> <nl> # pip - installs the directory specified . Used because on MSYS the vanilla Windows <nl> # Python gets confused when parsing paths . <nl> mmm a / tools / run_tests / helper_scripts / pre_build_csharp . bat <nl> ppp b / tools / run_tests / helper_scripts / pre_build_csharp . bat <nl> cd build <nl> mkdir % ARCHITECTURE % <nl> cd % ARCHITECTURE % <nl> @ rem TODO ( jtattermusch ) : Stop hardcoding path to yasm once Jenkins workers can locate yasm correctly <nl> - cmake - G " Visual Studio 14 2015 " - A % ARCHITECTURE % - DgRPC_BUILD_TESTS = OFF - DCMAKE_ASM_NASM_COMPILER = " C : / Program Files ( x86 ) / yasm / yasm . exe " . . / . . / . . | | goto : error <nl> - cd . . \ . . \ . . <nl> + cmake - G " Visual Studio 14 2015 " - A % ARCHITECTURE % - DgRPC_BUILD_TESTS = OFF - DgRPC_MSVC_STATIC_RUNTIME = ON - DCMAKE_ASM_NASM_COMPILER = " C : / Program Files ( x86 ) / yasm / yasm . exe " . . / . . / . . | | goto : error <nl> <nl> - @ rem Location of nuget . exe <nl> - set NUGET = C : \ nuget \ nuget . exe <nl> + cd . . \ . . \ . . \ src \ csharp <nl> <nl> - if exist % NUGET % ( <nl> - @ rem TODO ( jtattermusch ) : Get rid of this hack . See # 8034 <nl> - @ rem Restore Grpc packages by packages since Nuget client 3 . 4 . 4 doesnt support restore <nl> - @ rem by solution <nl> - @ rem Moving into each directory to let the restores work based on per - project packages . config files <nl> - <nl> - cd src / csharp <nl> - <nl> - cd Grpc . Auth | | goto : error <nl> - % NUGET % restore - PackagesDirectory . . / packages | | goto : error <nl> - cd . . <nl> - <nl> - cd Grpc . Core | | goto : error <nl> - % NUGET % restore - PackagesDirectory . . / packages | | goto : error <nl> - cd . . <nl> - <nl> - cd Grpc . Core . Tests | | goto : error <nl> - % NUGET % restore - PackagesDirectory . . / packages | | goto : error <nl> - cd . . <nl> - <nl> - cd Grpc . Examples . MathClient | | goto : error <nl> - % NUGET % restore - PackagesDirectory . . / packages | | goto : error <nl> - cd . . <nl> - <nl> - cd Grpc . Examples . MathServer | | goto : error <nl> - % NUGET % restore - PackagesDirectory . . / packages | | goto : error <nl> - cd . . <nl> - <nl> - cd Grpc . Examples | | goto : error <nl> - % NUGET % restore - PackagesDirectory . . / packages | | goto : error <nl> - cd . . <nl> - <nl> - cd Grpc . HealthCheck . Tests | | goto : error <nl> - % NUGET % restore - PackagesDirectory . . / packages | | goto : error <nl> - cd . . <nl> - <nl> - cd Grpc . HealthCheck | | goto : error <nl> - % NUGET % restore - PackagesDirectory . . / packages | | goto : error <nl> - cd . . <nl> - <nl> - cd Grpc . IntegrationTesting | | goto : error <nl> - % NUGET % restore - PackagesDirectory . . / packages | | goto : error <nl> - <nl> - cd / d % ~ dp0 \ . . \ . . | | goto : error <nl> - ) <nl> + dotnet restore Grpc . sln | | goto : error <nl> <nl> endlocal <nl> <nl> mmm a / tools / run_tests / helper_scripts / pre_build_csharp . sh <nl> ppp b / tools / run_tests / helper_scripts / pre_build_csharp . sh <nl> set - ex <nl> # cd to gRPC csharp directory <nl> cd $ ( dirname $ 0 ) / . . / . . / . . / src / csharp <nl> <nl> - root = ` pwd ` <nl> - <nl> - if [ - x " $ ( command - v nuget ) " ] <nl> - then <nl> - # TODO ( jtattermusch ) : Get rid of this hack . See # 8034 <nl> - # Restoring Nuget packages by packages rather than by solution because of <nl> - # inability to restore by solution with Nuget client 3 . 4 . 4 <nl> - # Moving into each directory to let the restores work based on per - project packages . config files <nl> - cd Grpc . Auth <nl> - nuget restore - PackagesDirectory . . / packages <nl> - cd . . <nl> - <nl> - cd Grpc . Core . Tests <nl> - nuget restore - PackagesDirectory . . / packages <nl> - cd . . <nl> - <nl> - cd Grpc . Core <nl> - nuget restore - PackagesDirectory . . / packages <nl> - cd . . <nl> - <nl> - cd Grpc . Examples . MathClient <nl> - nuget restore - PackagesDirectory . . / packages <nl> - cd . . <nl> - <nl> - cd Grpc . Examples . MathServer <nl> - nuget restore - PackagesDirectory . . / packages <nl> - cd . . <nl> - <nl> - cd Grpc . Examples <nl> - nuget restore - PackagesDirectory . . / packages <nl> - cd . . <nl> - <nl> - cd Grpc . HealthCheck . Tests <nl> - nuget restore - PackagesDirectory . . / packages <nl> - cd . . <nl> - <nl> - cd Grpc . HealthCheck <nl> - nuget restore - PackagesDirectory . . / packages <nl> - cd . . <nl> - <nl> - cd Grpc . IntegrationTesting <nl> - nuget restore - PackagesDirectory . . / packages <nl> - cd . . <nl> - fi <nl> + dotnet restore Grpc . sln <nl> mmm a / tools / run_tests / helper_scripts / run_python . sh <nl> ppp b / tools / run_tests / helper_scripts / run_python . sh <nl> set - ex <nl> # change to grpc repo root <nl> cd $ ( dirname $ 0 ) / . . / . . / . . <nl> <nl> - PYTHON = ` realpath - s " $ { 1 : - py27 / bin / python } " ` <nl> + PYTHON = ` realpath " $ { 1 : - py27 / bin / python } " ` <nl> <nl> ROOT = ` pwd ` <nl> <nl> mmm a / tools / run_tests / helper_scripts / run_ruby_end2end_tests . sh <nl> ppp b / tools / run_tests / helper_scripts / run_ruby_end2end_tests . sh <nl> ruby src / ruby / end2end / sig_handling_driver . rb | | EXIT_CODE = 1 <nl> ruby src / ruby / end2end / channel_state_driver . rb | | EXIT_CODE = 1 <nl> ruby src / ruby / end2end / channel_closing_driver . rb | | EXIT_CODE = 1 <nl> ruby src / ruby / end2end / sig_int_during_channel_watch_driver . rb | | EXIT_CODE = 1 <nl> + ruby src / ruby / end2end / killed_client_thread_driver . rb | | EXIT_CODE = 1 <nl> exit $ EXIT_CODE <nl> mmm a / tools / run_tests / run_interop_tests . py <nl> ppp b / tools / run_tests / run_interop_tests . py <nl> def __str__ ( self ) : <nl> class CSharpLanguage : <nl> <nl> def __init__ ( self ) : <nl> - self . client_cwd = ' src / csharp / Grpc . IntegrationTesting . Client / bin / Debug ' <nl> - self . server_cwd = ' src / csharp / Grpc . IntegrationTesting . Server / bin / Debug ' <nl> + self . client_cwd = ' src / csharp / Grpc . IntegrationTesting . Client / bin / Debug / net45 ' <nl> + self . server_cwd = ' src / csharp / Grpc . IntegrationTesting . Server / bin / Debug / net45 ' <nl> self . safename = str ( self ) <nl> <nl> def client_cmd ( self , args ) : <nl> mmm a / tools / run_tests / run_tests . py <nl> ppp b / tools / run_tests / run_tests . py <nl> def _compiler_options ( self , use_docker , compiler ) : <nl> return ( ' jessie ' , self . _gcc_make_options ( version_suffix = ' - 4 . 8 ' ) ) <nl> elif compiler = = ' gcc5 . 3 ' : <nl> return ( ' ubuntu1604 ' , [ ] ) <nl> + elif compiler = = ' gcc_musl ' : <nl> + return ( ' alpine ' , [ ] ) <nl> elif compiler = = ' clang3 . 4 ' : <nl> # on ubuntu1404 , clang - 3 . 4 alias doesn ' t exist , just use ' clang ' <nl> return ( ' ubuntu1404 ' , self . _clang_make_options ( ) ) <nl> def dockerfile_dir ( self ) : <nl> return ' tools / dockerfile / test / python_ % s_ % s ' % ( self . python_manager_name ( ) , _docker_arch_suffix ( self . args . arch ) ) <nl> <nl> def python_manager_name ( self ) : <nl> - return ' pyenv ' if self . args . compiler in [ ' python3 . 5 ' , ' python3 . 6 ' ] else ' jessie ' <nl> + if self . args . compiler in [ ' python3 . 5 ' , ' python3 . 6 ' ] : <nl> + return ' pyenv ' <nl> + elif self . args . compiler = = ' python_alpine ' : <nl> + return ' alpine ' <nl> + else : <nl> + return ' jessie ' <nl> <nl> def _get_pythons ( self , args ) : <nl> if args . arch = = ' x86 ' : <nl> def _get_pythons ( self , args ) : <nl> return ( pypy27_config , ) <nl> elif args . compiler = = ' pypy3 ' : <nl> return ( pypy32_config , ) <nl> + elif args . compiler = = ' python_alpine ' : <nl> + return ( python27_config , ) <nl> else : <nl> raise Exception ( ' Compiler % s not supported . ' % args . compiler ) <nl> <nl> def configure ( self , config , args ) : <nl> if self . platform = = ' windows ' : <nl> _check_compiler ( self . args . compiler , [ ' coreclr ' , ' default ' ] ) <nl> _check_arch ( self . args . arch , [ ' default ' ] ) <nl> - self . _cmake_arch_option = ' x64 ' if self . args . compiler = = ' coreclr ' else ' Win32 ' <nl> + self . _cmake_arch_option = ' x64 ' <nl> self . _make_options = [ ] <nl> else : <nl> _check_compiler ( self . args . compiler , [ ' default ' , ' coreclr ' ] ) <nl> - if self . platform = = ' linux ' and self . args . compiler = = ' coreclr ' : <nl> - self . _docker_distro = ' coreclr ' <nl> - else : <nl> - self . _docker_distro = ' jessie ' <nl> + self . _docker_distro = ' jessie ' <nl> <nl> if self . platform = = ' mac ' : <nl> # TODO ( jtattermusch ) : EMBED_ZLIB = true currently breaks the mac build <nl> def test_specs ( self ) : <nl> tests_by_assembly = json . load ( f ) <nl> <nl> msbuild_config = _MSBUILD_CONFIG [ self . config . build_config ] <nl> - nunit_args = [ ' - - labels = All ' ] <nl> + nunit_args = [ ' - - labels = All ' , ' - - noresult ' , ' - - workers = 1 ' ] <nl> assembly_subdir = ' bin / % s ' % msbuild_config <nl> assembly_extension = ' . exe ' <nl> <nl> def test_specs ( self ) : <nl> runtime_cmd = [ ' dotnet ' , ' exec ' ] <nl> assembly_extension = ' . dll ' <nl> else : <nl> - nunit_args + = [ ' - - noresult ' , ' - - workers = 1 ' ] <nl> + assembly_subdir + = ' / net45 ' <nl> if self . platform = = ' windows ' : <nl> runtime_cmd = [ ] <nl> else : <nl> def make_options ( self ) : <nl> return self . _make_options ; <nl> <nl> def build_steps ( self ) : <nl> - if self . args . compiler = = ' coreclr ' : <nl> - if self . platform = = ' windows ' : <nl> - return [ [ ' tools \ \ run_tests \ \ helper_scripts \ \ build_csharp_coreclr . bat ' ] ] <nl> - else : <nl> - return [ [ ' tools / run_tests / helper_scripts / build_csharp_coreclr . sh ' ] ] <nl> + if self . platform = = ' windows ' : <nl> + return [ [ ' tools \ \ run_tests \ \ helper_scripts \ \ build_csharp . bat ' ] ] <nl> else : <nl> - if self . platform = = ' windows ' : <nl> - return [ [ ' vsprojects \ \ build_vs2015 . bat ' , <nl> - ' src / csharp / Grpc . sln ' , <nl> - ' / p : Configuration = % s ' % _MSBUILD_CONFIG [ self . config . build_config ] ] ] <nl> - else : <nl> - return [ [ ' tools / run_tests / helper_scripts / build_csharp . sh ' ] ] <nl> + return [ [ ' tools / run_tests / helper_scripts / build_csharp . sh ' ] ] <nl> <nl> def post_tests_steps ( self ) : <nl> if self . platform = = ' windows ' : <nl> def isclose ( a , b , rel_tol = 1e - 09 , abs_tol = 0 . 0 ) : <nl> help = ' Selects architecture to target . For some platforms " default " is the only supported choice . ' ) <nl> argp . add_argument ( ' - - compiler ' , <nl> choices = [ ' default ' , <nl> - ' gcc4 . 4 ' , ' gcc4 . 6 ' , ' gcc4 . 8 ' , ' gcc4 . 9 ' , ' gcc5 . 3 ' , <nl> + ' gcc4 . 4 ' , ' gcc4 . 6 ' , ' gcc4 . 8 ' , ' gcc4 . 9 ' , ' gcc5 . 3 ' , ' gcc_musl ' , <nl> ' clang3 . 4 ' , ' clang3 . 5 ' , ' clang3 . 6 ' , ' clang3 . 7 ' , <nl> ' vs2013 ' , ' vs2015 ' , <nl> - ' python2 . 7 ' , ' python3 . 4 ' , ' python3 . 5 ' , ' python3 . 6 ' , ' pypy ' , ' pypy3 ' , <nl> + ' python2 . 7 ' , ' python3 . 4 ' , ' python3 . 5 ' , ' python3 . 6 ' , ' pypy ' , ' pypy3 ' , ' python_alpine ' , <nl> ' node0 . 12 ' , ' node4 ' , ' node5 ' , ' node6 ' , ' node7 ' , <nl> ' electron1 . 3 ' , <nl> ' coreclr ' , <nl> mmm a / tools / run_tests / run_tests_matrix . py <nl> ppp b / tools / run_tests / run_tests_matrix . py <nl> def _create_portability_test_jobs ( extra_args = [ ] , inner_jobs = _DEFAULT_INNER_JOBS ) <nl> inner_jobs = inner_jobs ) <nl> <nl> # portability C and C + + on x64 <nl> - for compiler in [ ' gcc4 . 4 ' , ' gcc4 . 6 ' , ' gcc5 . 3 ' , <nl> + for compiler in [ ' gcc4 . 4 ' , ' gcc4 . 6 ' , ' gcc5 . 3 ' , ' gcc_musl ' , <nl> ' clang3 . 5 ' , ' clang3 . 6 ' , ' clang3 . 7 ' ] : <nl> test_jobs + = _generate_jobs ( languages = [ ' c ' ] , <nl> configs = [ ' dbg ' ] , <nl> def _create_portability_test_jobs ( extra_args = [ ] , inner_jobs = _DEFAULT_INNER_JOBS ) <nl> extra_args = extra_args , <nl> inner_jobs = inner_jobs ) <nl> <nl> - for compiler in [ ' gcc4 . 8 ' , ' gcc5 . 3 ' , <nl> + for compiler in [ ' gcc4 . 8 ' , ' gcc5 . 3 ' , ' gcc_musl ' , <nl> ' clang3 . 5 ' , ' clang3 . 6 ' , ' clang3 . 7 ' ] : <nl> test_jobs + = _generate_jobs ( languages = [ ' c + + ' ] , <nl> configs = [ ' dbg ' ] , <nl> def _create_portability_test_jobs ( extra_args = [ ] , inner_jobs = _DEFAULT_INNER_JOBS ) <nl> extra_args = extra_args , <nl> inner_jobs = inner_jobs ) <nl> <nl> + test_jobs + = _generate_jobs ( languages = [ ' python ' ] , <nl> + configs = [ ' dbg ' ] , <nl> + platforms = [ ' linux ' ] , <nl> + arch = ' default ' , <nl> + compiler = ' python_alpine ' , <nl> + labels = [ ' portability ' ] , <nl> + extra_args = extra_args , <nl> + inner_jobs = inner_jobs ) <nl> + <nl> test_jobs + = _generate_jobs ( languages = [ ' csharp ' ] , <nl> configs = [ ' dbg ' ] , <nl> platforms = [ ' linux ' ] , <nl> mmm a / tools / run_tests / sanity / check_submodules . sh <nl> ppp b / tools / run_tests / sanity / check_submodules . sh <nl> cat < < EOF | awk ' { print $ 1 } ' | sort > $ want_submodules <nl> 78684e5b222645828ca302e56b40b9daff2b2d27 third_party / boringssl ( 78684e5 ) <nl> 886e7d75368e3f4fab3f4d0d3584e4abfc557755 third_party / boringssl - with - bazel ( version_for_cocoapods_7 . 0 - 857 - g886e7d7 ) <nl> 30dbc81fb5ffdc98ea9b14b1918bfe4e8779b26e third_party / gflags ( v2 . 2 . 0 ) <nl> - c99458533a9b4c743ed51537e25989ea55944908 third_party / googletest ( release - 1 . 7 . 0 ) <nl> - 593e917c176b5bc5aafa57bf9f6030d749d91cd5 third_party / protobuf ( v3 . 1 . 0 - alpha - 1 - 326 - g593e917 ) <nl> + ec44c6c1675c25b9827aacd08c02433cccde7780 third_party / googletest ( release - 1 . 8 . 0 ) <nl> + 4a0dd03e52e09332c8fd0f8f26a8e0ae9f911182 third_party / protobuf ( v3 . 1 . 0 - alpha - 1 - 548 - g4a0dd03e ) <nl> bcad91771b7f0bff28a1cac1981d7ef2b9bcef3c third_party / thrift ( bcad917 ) <nl> 50893291621658f355bc5b4d450a8d06a563053d third_party / zlib ( v1 . 2 . 8 ) <nl> 7691f773af79bf75a62d1863fd0f13ebf9dc51b1 third_party / cares / cares ( 1 . 12 . 0 ) <nl> mmm a / vsprojects / vcxproj / grpc + + / grpc + + . vcxproj <nl> ppp b / vsprojects / vcxproj / grpc + + / grpc + + . vcxproj <nl> <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ iomgr_internal . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ iomgr_posix . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ load_file . h " / > <nl> + < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ lockfree_event . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ network_status_tracker . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ polling_entity . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ pollset . h " / > <nl> <nl> < / ClCompile > <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ load_file . c " > <nl> < / ClCompile > <nl> + < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ lockfree_event . c " > <nl> + < / ClCompile > <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ network_status_tracker . c " > <nl> < / ClCompile > <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ polling_entity . c " > <nl> mmm a / vsprojects / vcxproj / grpc + + / grpc + + . vcxproj . filters <nl> ppp b / vsprojects / vcxproj / grpc + + / grpc + + . vcxproj . filters <nl> <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ load_file . c " > <nl> < Filter > src \ core \ lib \ iomgr < / Filter > <nl> < / ClCompile > <nl> + < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ lockfree_event . c " > <nl> + < Filter > src \ core \ lib \ iomgr < / Filter > <nl> + < / ClCompile > <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ network_status_tracker . c " > <nl> < Filter > src \ core \ lib \ iomgr < / Filter > <nl> < / ClCompile > <nl> <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ load_file . h " > <nl> < Filter > src \ core \ lib \ iomgr < / Filter > <nl> < / ClInclude > <nl> + < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ lockfree_event . h " > <nl> + < Filter > src \ core \ lib \ iomgr < / Filter > <nl> + < / ClInclude > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ network_status_tracker . h " > <nl> < Filter > src \ core \ lib \ iomgr < / Filter > <nl> < / ClInclude > <nl> mmm a / vsprojects / vcxproj / grpc + + _unsecure / grpc + + _unsecure . vcxproj <nl> ppp b / vsprojects / vcxproj / grpc + + _unsecure / grpc + + _unsecure . vcxproj <nl> <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ iomgr_internal . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ iomgr_posix . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ load_file . h " / > <nl> + < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ lockfree_event . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ network_status_tracker . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ polling_entity . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ pollset . h " / > <nl> <nl> < / ClCompile > <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ load_file . c " > <nl> < / ClCompile > <nl> + < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ lockfree_event . c " > <nl> + < / ClCompile > <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ network_status_tracker . c " > <nl> < / ClCompile > <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ polling_entity . c " > <nl> mmm a / vsprojects / vcxproj / grpc + + _unsecure / grpc + + _unsecure . vcxproj . filters <nl> ppp b / vsprojects / vcxproj / grpc + + _unsecure / grpc + + _unsecure . vcxproj . filters <nl> <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ load_file . c " > <nl> < Filter > src \ core \ lib \ iomgr < / Filter > <nl> < / ClCompile > <nl> + < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ lockfree_event . c " > <nl> + < Filter > src \ core \ lib \ iomgr < / Filter > <nl> + < / ClCompile > <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ network_status_tracker . c " > <nl> < Filter > src \ core \ lib \ iomgr < / Filter > <nl> < / ClCompile > <nl> <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ load_file . h " > <nl> < Filter > src \ core \ lib \ iomgr < / Filter > <nl> < / ClInclude > <nl> + < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ lockfree_event . h " > <nl> + < Filter > src \ core \ lib \ iomgr < / Filter > <nl> + < / ClInclude > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ network_status_tracker . h " > <nl> < Filter > src \ core \ lib \ iomgr < / Filter > <nl> < / ClInclude > <nl> mmm a / vsprojects / vcxproj / grpc / grpc . vcxproj <nl> ppp b / vsprojects / vcxproj / grpc / grpc . vcxproj <nl> <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ iomgr_internal . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ iomgr_posix . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ load_file . h " / > <nl> + < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ lockfree_event . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ network_status_tracker . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ polling_entity . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ pollset . h " / > <nl> <nl> < / ClCompile > <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ load_file . c " > <nl> < / ClCompile > <nl> + < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ lockfree_event . c " > <nl> + < / ClCompile > <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ network_status_tracker . c " > <nl> < / ClCompile > <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ polling_entity . c " > <nl> mmm a / vsprojects / vcxproj / grpc / grpc . vcxproj . filters <nl> ppp b / vsprojects / vcxproj / grpc / grpc . vcxproj . filters <nl> <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ load_file . c " > <nl> < Filter > src \ core \ lib \ iomgr < / Filter > <nl> < / ClCompile > <nl> + < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ lockfree_event . c " > <nl> + < Filter > src \ core \ lib \ iomgr < / Filter > <nl> + < / ClCompile > <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ network_status_tracker . c " > <nl> < Filter > src \ core \ lib \ iomgr < / Filter > <nl> < / ClCompile > <nl> <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ load_file . h " > <nl> < Filter > src \ core \ lib \ iomgr < / Filter > <nl> < / ClInclude > <nl> + < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ lockfree_event . h " > <nl> + < Filter > src \ core \ lib \ iomgr < / Filter > <nl> + < / ClInclude > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ network_status_tracker . h " > <nl> < Filter > src \ core \ lib \ iomgr < / Filter > <nl> < / ClInclude > <nl> mmm a / vsprojects / vcxproj / grpc_test_util / grpc_test_util . vcxproj <nl> ppp b / vsprojects / vcxproj / grpc_test_util / grpc_test_util . vcxproj <nl> <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ iomgr_internal . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ iomgr_posix . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ load_file . h " / > <nl> + < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ lockfree_event . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ network_status_tracker . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ polling_entity . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ pollset . h " / > <nl> <nl> < / ClCompile > <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ load_file . c " > <nl> < / ClCompile > <nl> + < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ lockfree_event . c " > <nl> + < / ClCompile > <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ network_status_tracker . c " > <nl> < / ClCompile > <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ polling_entity . c " > <nl> mmm a / vsprojects / vcxproj / grpc_test_util / grpc_test_util . vcxproj . filters <nl> ppp b / vsprojects / vcxproj / grpc_test_util / grpc_test_util . vcxproj . filters <nl> <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ load_file . c " > <nl> < Filter > src \ core \ lib \ iomgr < / Filter > <nl> < / ClCompile > <nl> + < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ lockfree_event . c " > <nl> + < Filter > src \ core \ lib \ iomgr < / Filter > <nl> + < / ClCompile > <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ network_status_tracker . c " > <nl> < Filter > src \ core \ lib \ iomgr < / Filter > <nl> < / ClCompile > <nl> <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ load_file . h " > <nl> < Filter > src \ core \ lib \ iomgr < / Filter > <nl> < / ClInclude > <nl> + < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ lockfree_event . h " > <nl> + < Filter > src \ core \ lib \ iomgr < / Filter > <nl> + < / ClInclude > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ network_status_tracker . h " > <nl> < Filter > src \ core \ lib \ iomgr < / Filter > <nl> < / ClInclude > <nl> mmm a / vsprojects / vcxproj / grpc_unsecure / grpc_unsecure . vcxproj <nl> ppp b / vsprojects / vcxproj / grpc_unsecure / grpc_unsecure . vcxproj <nl> <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ iomgr_internal . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ iomgr_posix . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ load_file . h " / > <nl> + < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ lockfree_event . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ network_status_tracker . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ polling_entity . h " / > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ pollset . h " / > <nl> <nl> < / ClCompile > <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ load_file . c " > <nl> < / ClCompile > <nl> + < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ lockfree_event . c " > <nl> + < / ClCompile > <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ network_status_tracker . c " > <nl> < / ClCompile > <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ polling_entity . c " > <nl> mmm a / vsprojects / vcxproj / grpc_unsecure / grpc_unsecure . vcxproj . filters <nl> ppp b / vsprojects / vcxproj / grpc_unsecure / grpc_unsecure . vcxproj . filters <nl> <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ load_file . c " > <nl> < Filter > src \ core \ lib \ iomgr < / Filter > <nl> < / ClCompile > <nl> + < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ lockfree_event . c " > <nl> + < Filter > src \ core \ lib \ iomgr < / Filter > <nl> + < / ClCompile > <nl> < ClCompile Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ network_status_tracker . c " > <nl> < Filter > src \ core \ lib \ iomgr < / Filter > <nl> < / ClCompile > <nl> <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ load_file . h " > <nl> < Filter > src \ core \ lib \ iomgr < / Filter > <nl> < / ClInclude > <nl> + < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ lockfree_event . h " > <nl> + < Filter > src \ core \ lib \ iomgr < / Filter > <nl> + < / ClInclude > <nl> < ClInclude Include = " $ ( SolutionDir ) \ . . \ src \ core \ lib \ iomgr \ network_status_tracker . h " > <nl> < Filter > src \ core \ lib \ iomgr < / Filter > <nl> < / ClInclude > <nl>
|
Merge github . com : grpc / grpc into cpparena
|
grpc/grpc
|
c20fa90c6094599540e3a7ef16a5aa381580be33
|
2017-04-12T13:44:00Z
|
mmm a / src / app / ui / editor / editor . cpp <nl> ppp b / src / app / ui / editor / editor . cpp <nl> void Editor : : drawSpriteUnclippedRect ( ui : : Graphics * g , const gfx : : Rect & _rc ) <nl> if ( x > 0 ) { <nl> gfx : : Color color = color_utils : : color_for_ui ( m_docPref . grid . color ( ) ) ; <nl> g - > drawVLine ( color , <nl> - spriteRect . x + int ( m_proj . applyX < double > ( x ) ) , <nl> - enclosingRect . y + mainTilePosition ( ) . y , <nl> + spriteRect . x + m_proj . applyX ( mainTilePosition ( ) . x ) + int ( m_proj . applyX < double > ( x ) ) , <nl> + enclosingRect . y , <nl> enclosingRect . h ) ; <nl> } <nl> } <nl> void Editor : : drawSpriteUnclippedRect ( ui : : Graphics * g , const gfx : : Rect & _rc ) <nl> if ( y > 0 ) { <nl> gfx : : Color color = color_utils : : color_for_ui ( m_docPref . grid . color ( ) ) ; <nl> g - > drawHLine ( color , <nl> - enclosingRect . x + mainTilePosition ( ) . x , <nl> - spriteRect . y + int ( m_proj . applyY < double > ( y ) ) , <nl> + enclosingRect . x , <nl> + spriteRect . y + m_proj . applyY ( mainTilePosition ( ) . y ) + int ( m_proj . applyY < double > ( y ) ) , <nl> enclosingRect . w ) ; <nl> } <nl> } <nl> mmm a / src / app / ui / editor / editor . h <nl> ppp b / src / app / ui / editor / editor . h <nl> namespace app { <nl> / / Returns the visible area of the active sprite . <nl> gfx : : Rect getVisibleSpriteBounds ( ) ; <nl> <nl> + gfx : : Size canvasSize ( ) const ; <nl> gfx : : Point mainTilePosition ( ) const ; <nl> <nl> / / Changes the scroll to see the given point as the center of the editor . <nl> namespace app { <nl> void drawOneSpriteUnclippedRect ( ui : : Graphics * g , const gfx : : Rect & rc , int dx , int dy ) ; <nl> <nl> gfx : : Point calcExtraPadding ( const render : : Projection & proj ) ; <nl> - gfx : : Size canvasSize ( ) const ; <nl> <nl> void invalidateIfActive ( ) ; <nl> bool showAutoCelGuides ( ) ; <nl> mmm a / src / app / ui / editor / standby_state . cpp <nl> ppp b / src / app / ui / editor / standby_state . cpp <nl> bool StandbyState : : Decorator : : getSymmetryHandles ( Editor * editor , Handles & handle <nl> const auto & symmetry = Preferences : : instance ( ) . document ( editor - > document ( ) ) . symmetry ; <nl> auto mode = symmetry . mode ( ) ; <nl> if ( mode ! = app : : gen : : SymmetryMode : : NONE ) { <nl> - gfx : : RectF spriteBounds = gfx : : RectF ( editor - > sprite ( ) - > bounds ( ) ) ; <nl> - gfx : : RectF editorViewport = gfx : : RectF ( View : : getView ( editor ) - > viewportBounds ( ) ) ; <nl> + gfx : : Rect mainTileBounds ( editor - > mainTilePosition ( ) , <nl> + editor - > sprite ( ) - > bounds ( ) . size ( ) ) ; <nl> + gfx : : Rect canvasBounds ( gfx : : Point ( 0 , 0 ) , <nl> + editor - > canvasSize ( ) ) ; <nl> + gfx : : RectF editorViewport ( View : : getView ( editor ) - > viewportBounds ( ) ) ; <nl> skin : : SkinTheme * theme = static_cast < skin : : SkinTheme * > ( ui : : get_theme ( ) ) ; <nl> she : : Surface * part = theme - > parts . transformationHandle ( ) - > bitmap ( 0 ) ; <nl> <nl> bool StandbyState : : Decorator : : getSymmetryHandles ( Editor * editor , Handles & handle <nl> double pos = symmetry . xAxis ( ) ; <nl> gfx : : PointF pt1 , pt2 ; <nl> <nl> - pt1 = gfx : : PointF ( spriteBounds . x + pos , spriteBounds . y ) ; <nl> + pt1 = gfx : : PointF ( mainTileBounds . x + pos , canvasBounds . y ) ; <nl> pt1 = editor - > editorToScreenF ( pt1 ) ; <nl> - pt2 = gfx : : PointF ( spriteBounds . x + pos , spriteBounds . y + spriteBounds . h ) ; <nl> + pt2 = gfx : : PointF ( mainTileBounds . x + pos , canvasBounds . y2 ( ) ) ; <nl> pt2 = editor - > editorToScreenF ( pt2 ) ; <nl> pt1 . y = std : : max ( pt1 . y - part - > height ( ) , editorViewport . y ) ; <nl> pt2 . y = std : : min ( pt2 . y , editorViewport . point2 ( ) . y - part - > height ( ) ) ; <nl> bool StandbyState : : Decorator : : getSymmetryHandles ( Editor * editor , Handles & handle <nl> double pos = symmetry . yAxis ( ) ; <nl> gfx : : PointF pt1 , pt2 ; <nl> <nl> - pt1 = gfx : : PointF ( spriteBounds . x , spriteBounds . y + pos ) ; <nl> + pt1 = gfx : : PointF ( canvasBounds . x , mainTileBounds . y + pos ) ; <nl> pt1 = editor - > editorToScreenF ( pt1 ) ; <nl> - pt2 = gfx : : PointF ( spriteBounds . x + spriteBounds . w , spriteBounds . y + pos ) ; <nl> + pt2 = gfx : : PointF ( canvasBounds . x2 ( ) , mainTileBounds . y + pos ) ; <nl> pt2 = editor - > editorToScreenF ( pt2 ) ; <nl> pt1 . x = std : : max ( pt1 . x - part - > width ( ) , editorViewport . x ) ; <nl> pt2 . x = std : : min ( pt2 . x , editorViewport . point2 ( ) . x - part - > width ( ) ) ; <nl>
|
Show symmetry lines in the main tile
|
aseprite/aseprite
|
ee3ade44b8964368d0e7b51f3f8d819e8af517c0
|
2017-11-09T21:19:18Z
|
mmm a / website / js / base . js <nl> ppp b / website / js / base . js <nl> <nl> var offset = 0 ; <nl> <nl> if ( selector ! = = ' # ' ) { <nl> - offset = $ ( selector ) . offset ( ) . top - $ ( ' # top - nav ' ) . height ( ) * 1 . 5 ; <nl> - dst + = selector ; <nl> + var destination = $ ( selector ) ; <nl> + if ( destination . length ) { <nl> + offset = destination . offset ( ) . top - $ ( ' # top - nav ' ) . height ( ) * 1 . 5 ; <nl> + dst + = selector ; <nl> + } <nl> } <nl> $ ( ' html , body ' ) . animate ( { <nl> scrollTop : offset <nl> <nl> <nl> var top_nav = $ ( ' # top - nav . sticky - top ' ) ; <nl> if ( window . location . hash . length > 1 & & top_nav . length ) { <nl> - var offset = $ ( window . location . hash ) . offset ( ) . top - top_nav . height ( ) * 1 . 5 ; <nl> - $ ( ' html , body ' ) . animate ( { <nl> - scrollTop : offset <nl> - } , 70 ) ; <nl> + var hash_destination = $ ( window . location . hash ) ; <nl> + if ( hash_destination . length ) { <nl> + var offset = hash_destination . offset ( ) . top - top_nav . height ( ) * 1 . 5 ; <nl> + $ ( ' html , body ' ) . animate ( { <nl> + scrollTop : offset <nl> + } , 70 ) ; <nl> + } <nl> } <nl> <nl> $ ( ' img ' ) . each ( function ( ) { <nl>
|
[ docs ] handle incorrect hash in url ( )
|
ClickHouse/ClickHouse
|
528ac30a019ce173e5b613d6767aa7f4b326e02a
|
2020-05-18T10:31:01Z
|
mmm a / osquery / events / linux / probes / probes . cpp <nl> ppp b / osquery / events / linux / probes / probes . cpp <nl> namespace events { <nl> namespace { <nl> <nl> Expected < std : : string , LinuxProbesControl : : Error > toTracingPath ( <nl> - syscall : : Type type ) { <nl> + syscall : : EventType type ) { <nl> static const auto table = <nl> - std : : unordered_map < syscall : : Type , std : : string , EnumClassHash > { <nl> - { syscall : : Type : : KillEnter , " syscalls / sys_enter_kill " } , <nl> - { syscall : : Type : : KillExit , " syscalls / sys_exit_kill " } , <nl> - { syscall : : Type : : SetuidEnter , " syscalls / sys_enter_setuid " } , <nl> - { syscall : : Type : : SetuidExit , " syscalls / sys_exit_setuid " } , <nl> + std : : unordered_map < syscall : : EventType , std : : string , EnumClassHash > { <nl> + { syscall : : EventType : : KillEnter , " syscalls / sys_enter_kill " } , <nl> + { syscall : : EventType : : KillExit , " syscalls / sys_exit_kill " } , <nl> + { syscall : : EventType : : SetuidEnter , " syscalls / sys_enter_setuid " } , <nl> + { syscall : : EventType : : SetuidExit , " syscalls / sys_exit_setuid " } , <nl> } ; <nl> auto exp = tryTakeCopy ( table , type ) ; <nl> if ( exp . isError ( ) ) { <nl> ebpf : : PerfOutputsPoll < events : : syscall : : Event > & LinuxProbesControl : : getReader ( ) { <nl> namespace { <nl> <nl> Expected < EbpfTracepoint , LinuxProbesControl : : Error > createTracepointForSyscall ( <nl> - syscall : : Type type , PerfEventCpuMap const & cpu_map ) { <nl> + syscall : : EventType type , PerfEventCpuMap const & cpu_map ) { <nl> auto program_exp = genLinuxProgram ( BPF_PROG_TYPE_TRACEPOINT , cpu_map , type ) ; <nl> if ( program_exp . isError ( ) ) { <nl> return createError ( LinuxProbesControl : : Error : : SystemEbpf , <nl> Expected < EbpfTracepoint , LinuxProbesControl : : Error > createTracepointForSyscall ( <nl> } / / namespace <nl> <nl> ExpectedSuccess < LinuxProbesControl : : Error > <nl> - LinuxProbesControl : : traceEnterAndExit ( syscall : : Type type ) { <nl> - if ( type = = syscall : : Type : : Unknown ) { <nl> + LinuxProbesControl : : traceEnterAndExit ( syscall : : EventType type ) { <nl> + if ( type = = syscall : : EventType : : Unknown ) { <nl> return createError ( Error : : InvalidArgument , " Wrong syscall type : ' Unknown ' " ) ; <nl> } <nl> auto tracepoint_exp = <nl> createTracepointForSyscall ( type , cpu_to_perf_output_map_ ) ; <nl> if ( tracepoint_exp . isValue ( ) ) { <nl> - auto const inv_type = syscall : : flipType ( type ) ; <nl> + auto const inv_type = syscall : : flipEventType ( type ) ; <nl> auto inv_tracepoint_exp = <nl> createTracepointForSyscall ( inv_type , cpu_to_perf_output_map_ ) ; <nl> if ( inv_tracepoint_exp . isValue ( ) ) { <nl> LinuxProbesControl : : traceEnterAndExit ( syscall : : Type type ) { <nl> } <nl> <nl> ExpectedSuccess < LinuxProbesControl : : Error > LinuxProbesControl : : traceKill ( ) { <nl> - return traceEnterAndExit ( syscall : : Type : : KillEnter ) ; <nl> + return traceEnterAndExit ( syscall : : EventType : : KillEnter ) ; <nl> } <nl> <nl> ExpectedSuccess < LinuxProbesControl : : Error > LinuxProbesControl : : traceSetuid ( ) { <nl> - return traceEnterAndExit ( syscall : : Type : : SetuidEnter ) ; <nl> + return traceEnterAndExit ( syscall : : EventType : : SetuidEnter ) ; <nl> } <nl> <nl> } / / namespace events <nl> mmm a / osquery / events / linux / probes / probes . h <nl> ppp b / osquery / events / linux / probes / probes . h <nl> class LinuxProbesControl final { <nl> PerfEventCpuMap cpu_to_perf_output_map , <nl> ebpf : : PerfOutputsPoll < events : : syscall : : Event > output_poll ) ; <nl> <nl> - ExpectedSuccess < Error > traceEnterAndExit ( syscall : : Type type ) ; <nl> + ExpectedSuccess < Error > traceEnterAndExit ( syscall : : EventType type ) ; <nl> <nl> private : <nl> - std : : unordered_map < syscall : : Type , EbpfTracepoint , EnumClassHash > probes_ ; <nl> - <nl> + std : : unordered_map < syscall : : EventType , EbpfTracepoint , EnumClassHash > probes_ ; <nl> PerfEventCpuMap cpu_to_perf_output_map_ ; <nl> ebpf : : PerfOutputsPoll < events : : syscall : : Event > output_poll_ ; <nl> } ; <nl> mmm a / osquery / events / linux / probes / syscall_event . cpp <nl> ppp b / osquery / events / linux / probes / syscall_event . cpp <nl> namespace { <nl> <nl> static constexpr EnterExitJoiner : : CounterType kCounterLimit = 256 ; <nl> <nl> - EnterExitJoiner : : KeyType createKey ( Type const type , <nl> + EnterExitJoiner : : KeyType createKey ( EventType const type , <nl> __s32 const pid , <nl> __s32 const tgid ) { <nl> auto key = EnterExitJoiner : : KeyType ( static_cast < std : : uint32_t > ( pid ) ) ; <nl> boost : : optional < Event > EnterExitJoiner : : join ( Event in_event ) { <nl> counter_ = 0 ; <nl> } <nl> auto const inv_key = <nl> - createKey ( flipType ( in_event . type ) , in_event . pid , in_event . tgid ) ; <nl> + createKey ( flipEventType ( in_event . type ) , in_event . pid , in_event . tgid ) ; <nl> <nl> auto it = table_ . find ( inv_key ) ; <nl> if ( it = = table_ . end ( ) ) { <nl> boost : : optional < Event > EnterExitJoiner : : join ( Event in_event ) { <nl> return boost : : none ; <nl> } <nl> <nl> - if ( isTypeExit ( in_event . type ) ) { <nl> + if ( isEventTypeExit ( in_event . type ) ) { <nl> auto enter = std : : move ( it - > second ) ; <nl> enter . return_value = in_event . body . exit . ret ; <nl> table_ . erase ( it ) ; <nl> mmm a / osquery / events / linux / probes / syscall_event . h <nl> ppp b / osquery / events / linux / probes / syscall_event . h <nl> namespace osquery { <nl> namespace events { <nl> namespace syscall { <nl> <nl> - enum class Type : __s32 { <nl> + enum class EventType : __s32 { <nl> Unknown = 0 , <nl> KillEnter = 1 , <nl> KillExit = - KillEnter , <nl> enum class Type : __s32 { <nl> <nl> static constexpr std : : size_t kCommSize = 16u ; <nl> <nl> - constexpr Type flipType ( Type const type ) noexcept { <nl> - return static_cast < Type > ( <nl> - - static_cast < std : : underlying_type < Type > : : type > ( type ) ) ; <nl> + constexpr EventType flipEventType ( EventType const type ) noexcept { <nl> + return static_cast < EventType > ( <nl> + - static_cast < std : : underlying_type < EventType > : : type > ( type ) ) ; <nl> } <nl> <nl> - constexpr bool isTypeExit ( Type const type ) noexcept { <nl> - return static_cast < std : : underlying_type < Type > : : type > ( type ) < 0 ; <nl> + constexpr bool isEventTypeExit ( EventType const type ) noexcept { <nl> + return static_cast < std : : underlying_type < EventType > : : type > ( type ) < 0 ; <nl> } <nl> <nl> - constexpr bool isTypeEnter ( Type const type ) noexcept { <nl> - return 0 < static_cast < std : : underlying_type < Type > : : type > ( type ) ; <nl> + constexpr bool isEventTypeEnter ( EventType const type ) noexcept { <nl> + return 0 < static_cast < std : : underlying_type < EventType > : : type > ( type ) ; <nl> } <nl> <nl> struct Event { <nl> / / Common part for all events whether Enter or Exit <nl> - Type type ; <nl> + EventType type ; <nl> __s32 pid ; <nl> __s32 tgid ; <nl> <nl> mmm a / osquery / events / linux / probes / syscalls_programs . cpp <nl> ppp b / osquery / events / linux / probes / syscalls_programs . cpp <nl> bool constexpr kIsDebug = <nl> Expected < ebpf : : Program , ebpf : : Program : : Error > genLinuxKillEnterProgram ( <nl> enum bpf_prog_type prog_type , PerfEventCpuMap const & cpu_map ) { <nl> constexpr int kKillEnterSize = 44 ; <nl> - static_assert ( sizeof ( syscall : : Type ) + sizeof ( syscall : : Event : : pid ) + <nl> + static_assert ( sizeof ( syscall : : EventType ) + sizeof ( syscall : : Event : : pid ) + <nl> sizeof ( syscall : : Event : : tgid ) + <nl> sizeof ( syscall : : Event : : Body : : KillEnter ) = = <nl> kKillEnterSize , <nl> Expected < ebpf : : Program , ebpf : : Program : : Error > genLinuxKillEnterProgram ( <nl> { BPF_STX | BPF_DW | BPF_MEM , BPF_REG_10 , BPF_REG_1 , - 24 , 0 } , <nl> <nl> / / put syscall code into final event struct , @ see syscall : : Event : : type <nl> - { BPF_ST | BPF_W | BPF_MEM , BPF_REG_10 , 0 , - kKillEnterSize , static_cast < __s32 > ( syscall : : Type : : KillEnter ) } , / / Event . type <nl> + { BPF_ST | BPF_W | BPF_MEM , BPF_REG_10 , 0 , - kKillEnterSize , static_cast < __s32 > ( syscall : : EventType : : KillEnter ) } , / / Event . type <nl> <nl> / / call fanction get_current_uid_gid ( ) <nl> { BPF_JMP | BPF_K | BPF_CALL , 0 , 0 , 0 , BPF_FUNC_get_current_uid_gid } , <nl> Expected < ebpf : : Program , ebpf : : Program : : Error > genLinuxKillEnterProgram ( <nl> Expected < ebpf : : Program , ebpf : : Program : : Error > genLinuxSetuidEnterProgram ( <nl> enum bpf_prog_type prog_type , PerfEventCpuMap const & cpu_map ) { <nl> constexpr int kSetuidEnterSize = 40 ; <nl> - static_assert ( sizeof ( syscall : : Type ) + sizeof ( syscall : : Event : : pid ) + <nl> + static_assert ( sizeof ( syscall : : EventType ) + sizeof ( syscall : : Event : : pid ) + <nl> sizeof ( syscall : : Event : : tgid ) + <nl> sizeof ( syscall : : Event : : Body : : SetuidEnter ) = = <nl> kSetuidEnterSize , <nl> " A program below relies on certain size of output struct " ) ; <nl> - static_assert ( static_cast < __s32 > ( syscall : : Type : : SetuidEnter ) = = <nl> - - static_cast < __s32 > ( syscall : : Type : : SetuidExit ) , <nl> + static_assert ( static_cast < __s32 > ( syscall : : EventType : : SetuidEnter ) = = <nl> + - static_cast < __s32 > ( syscall : : EventType : : SetuidExit ) , <nl> " Enter and Exit codes must be convertible to each other by " <nl> " multiplying to - 1 " ) ; <nl> / / clang - format off <nl> Expected < ebpf : : Program , ebpf : : Program : : Error > genLinuxSetuidEnterProgram ( <nl> { BPF_STX | BPF_DW | BPF_MEM , BPF_REG_10 , BPF_REG_1 , - 24 , 0 } , <nl> { BPF_STX | BPF_W | BPF_MEM , BPF_REG_10 , BPF_REG_1 , - 16 , 0 } , <nl> <nl> - / / Event . type = SyscallEvent : : Type : : SetuidEnter <nl> - { BPF_ST | BPF_W | BPF_MEM , BPF_REG_10 , 0 , - kSetuidEnterSize , static_cast < __s32 > ( syscall : : Type : : SetuidEnter ) } , <nl> + / / Event . type = SyscallEvent : : EventType : : SetuidEnter <nl> + { BPF_ST | BPF_W | BPF_MEM , BPF_REG_10 , 0 , - kSetuidEnterSize , static_cast < __s32 > ( syscall : : EventType : : SetuidEnter ) } , <nl> <nl> { BPF_JMP | BPF_K | BPF_CALL , 0 , 0 , 0 , BPF_FUNC_get_current_uid_gid } , <nl> { BPF_STX | BPF_W | BPF_MEM , BPF_REG_10 , BPF_REG_0 , - 8 , 0 } , / / Event . uid <nl> Expected < ebpf : : Program , ebpf : : Program : : Error > genLinuxSetuidEnterProgram ( <nl> Expected < ebpf : : Program , ebpf : : Program : : Error > genLinuxExitProgram ( <nl> enum bpf_prog_type prog_type , <nl> PerfEventCpuMap const & cpu_map , <nl> - syscall : : Type type ) { <nl> + syscall : : EventType type ) { <nl> constexpr int kExitSize = 16 ; <nl> - static_assert ( sizeof ( syscall : : Type ) + sizeof ( syscall : : Event : : pid ) + <nl> + static_assert ( sizeof ( syscall : : EventType ) + sizeof ( syscall : : Event : : pid ) + <nl> sizeof ( syscall : : Event : : tgid ) + <nl> sizeof ( syscall : : Event : : Body : : Exit ) = = <nl> kExitSize , <nl> Expected < ebpf : : Program , ebpf : : Program : : Error > genLinuxExitProgram ( <nl> { BPF_ALU64 | BPF_X | BPF_MOV , BPF_REG_6 , BPF_REG_1 , 0 , 0 } , / / r6 = r1 <nl> { BPF_ALU64 | BPF_K | BPF_MOV , BPF_REG_1 , 0 , 0 , 0 } , / / r1 = 0 <nl> <nl> - { BPF_ST | BPF_W | BPF_MEM , BPF_REG_10 , 0 , - kExitSize , static_cast < __s32 > ( type ) } , / / type = syscall : : Type : : Exit * <nl> + { BPF_ST | BPF_W | BPF_MEM , BPF_REG_10 , 0 , - kExitSize , static_cast < __s32 > ( type ) } , / / type = syscall : : EventType : : Exit * <nl> <nl> { BPF_JMP | BPF_K | BPF_CALL , 0 , 0 , 0 , BPF_FUNC_get_current_pid_tgid } , <nl> { BPF_STX | BPF_W | BPF_MEM , BPF_REG_10 , BPF_REG_0 , - 12 , 0 } , / / Event . pid <nl> Expected < ebpf : : Program , ebpf : : Program : : Error > genLinuxExitProgram ( <nl> Expected < ebpf : : Program , ebpf : : Program : : Error > genLinuxProgram ( <nl> enum bpf_prog_type prog_type , <nl> PerfEventCpuMap const & cpu_map , <nl> - syscall : : Type type ) { <nl> - if ( syscall : : isTypeExit ( type ) ) { <nl> + syscall : : EventType type ) { <nl> + if ( syscall : : isEventTypeExit ( type ) ) { <nl> return genLinuxExitProgram ( prog_type , cpu_map , type ) ; <nl> - } else if ( syscall : : Type : : KillEnter = = type ) { <nl> + } else if ( syscall : : EventType : : KillEnter = = type ) { <nl> return genLinuxKillEnterProgram ( prog_type , cpu_map ) ; <nl> - } else if ( syscall : : Type : : SetuidEnter = = type ) { <nl> + } else if ( syscall : : EventType : : SetuidEnter = = type ) { <nl> return genLinuxSetuidEnterProgram ( prog_type , cpu_map ) ; <nl> } else { <nl> return createError ( ebpf : : Program : : Error : : Unknown , <nl> mmm a / osquery / events / linux / probes / syscalls_programs . h <nl> ppp b / osquery / events / linux / probes / syscalls_programs . h <nl> using PerfEventCpuMap = ebpf : : Map < int , int , BPF_MAP_TYPE_PERF_EVENT_ARRAY > ; <nl> Expected < ebpf : : Program , ebpf : : Program : : Error > genLinuxProgram ( <nl> enum bpf_prog_type prog_type , <nl> PerfEventCpuMap const & cpu_map , <nl> - syscall : : Type type ) ; <nl> + syscall : : EventType type ) ; <nl> <nl> } / / namespace events <nl> } / / namespace osquery <nl> mmm a / osquery / events / linux / probes / tests / syscall_event . cpp <nl> ppp b / osquery / events / linux / probes / tests / syscall_event . cpp <nl> namespace { <nl> class SyscallsTracepointTests : public testing : : Test { } ; <nl> class EnterExitJoinerTests : public testing : : Test { } ; <nl> <nl> - template < events : : syscall : : Type enter , events : : syscall : : Type exit > <nl> + template < events : : syscall : : EventType enter , events : : syscall : : EventType exit > <nl> void checkEventPair ( ) { <nl> - static_assert ( enter = = events : : syscall : : flipType ( exit ) , <nl> - " flipType have to flip Exit to Enter " ) ; <nl> - static_assert ( exit = = events : : syscall : : flipType ( enter ) , <nl> - " flipType have to flip Enter to Exit " ) ; <nl> - static_assert ( <nl> - enter = = events : : syscall : : flipType ( events : : syscall : : flipType ( enter ) ) , <nl> - " flipType applied twice to Enter have to return exactly the same Enter " ) ; <nl> - static_assert ( <nl> - exit = = events : : syscall : : flipType ( events : : syscall : : flipType ( exit ) ) , <nl> - " flipType applied twice to Exit have to return exactly the same Exit " ) ; <nl> + static_assert ( enter = = events : : syscall : : flipEventType ( exit ) , <nl> + " flipEventType have to flip Exit to Enter " ) ; <nl> + static_assert ( exit = = events : : syscall : : flipEventType ( enter ) , <nl> + " flipEventType have to flip Enter to Exit " ) ; <nl> + static_assert ( enter = = events : : syscall : : flipEventType ( <nl> + events : : syscall : : flipEventType ( enter ) ) , <nl> + " flipEventType applied twice to Enter have to return exactly " <nl> + " the same Enter " ) ; <nl> + static_assert ( exit = = events : : syscall : : flipEventType ( <nl> + events : : syscall : : flipEventType ( exit ) ) , <nl> + " flipEventType applied twice to Exit have to return exactly " <nl> + " the same Exit " ) ; <nl> } <nl> <nl> TEST_F ( SyscallsTracepointTests , SyscallEvent_flipType ) { <nl> - checkEventPair < events : : syscall : : Type : : KillEnter , <nl> - events : : syscall : : Type : : KillExit > ( ) ; <nl> - checkEventPair < events : : syscall : : Type : : SetuidEnter , <nl> - events : : syscall : : Type : : SetuidExit > ( ) ; <nl> - static_assert ( events : : syscall : : Type : : Unknown = = <nl> - events : : syscall : : flipType ( events : : syscall : : Type : : Unknown ) , <nl> - " syscall : : Type : : Unknown could not be fliped " ) ; <nl> + checkEventPair < events : : syscall : : EventType : : KillEnter , <nl> + events : : syscall : : EventType : : KillExit > ( ) ; <nl> + checkEventPair < events : : syscall : : EventType : : SetuidEnter , <nl> + events : : syscall : : EventType : : SetuidExit > ( ) ; <nl> + static_assert ( <nl> + events : : syscall : : EventType : : Unknown = = <nl> + events : : syscall : : flipEventType ( events : : syscall : : EventType : : Unknown ) , <nl> + " syscall : : EventType : : Unknown could not be fliped " ) ; <nl> } <nl> <nl> TEST_F ( SyscallsTracepointTests , SyscallEvent_isTypeExit ) { <nl> - static_assert ( events : : syscall : : isTypeExit ( events : : syscall : : Type : : KillExit ) , <nl> - " " ) ; <nl> - static_assert ( events : : syscall : : isTypeExit ( events : : syscall : : Type : : SetuidExit ) , <nl> - " " ) ; <nl> - static_assert ( ! events : : syscall : : isTypeExit ( events : : syscall : : Type : : Unknown ) , <nl> - " " ) ; <nl> static_assert ( <nl> - ! events : : syscall : : isTypeExit ( events : : syscall : : Type : : SetuidEnter ) , " " ) ; <nl> + events : : syscall : : isEventTypeExit ( events : : syscall : : EventType : : KillExit ) , <nl> + " " ) ; <nl> + static_assert ( <nl> + events : : syscall : : isEventTypeExit ( events : : syscall : : EventType : : SetuidExit ) , <nl> + " " ) ; <nl> static_assert ( <nl> - ! events : : syscall : : isTypeExit ( events : : syscall : : Type : : SetuidEnter ) , " " ) ; <nl> + ! events : : syscall : : isEventTypeExit ( events : : syscall : : EventType : : Unknown ) , <nl> + " " ) ; <nl> + static_assert ( ! events : : syscall : : isEventTypeExit ( <nl> + events : : syscall : : EventType : : SetuidEnter ) , <nl> + " " ) ; <nl> + static_assert ( ! events : : syscall : : isEventTypeExit ( <nl> + events : : syscall : : EventType : : SetuidEnter ) , <nl> + " " ) ; <nl> } <nl> <nl> TEST_F ( SyscallsTracepointTests , SyscallEvent_isTypeEnter ) { <nl> - static_assert ( ! events : : syscall : : isTypeEnter ( events : : syscall : : Type : : KillExit ) , <nl> - " " ) ; <nl> static_assert ( <nl> - ! events : : syscall : : isTypeEnter ( events : : syscall : : Type : : SetuidExit ) , " " ) ; <nl> - static_assert ( ! events : : syscall : : isTypeEnter ( events : : syscall : : Type : : Unknown ) , <nl> + ! events : : syscall : : isEventTypeEnter ( events : : syscall : : EventType : : KillExit ) , <nl> + " " ) ; <nl> + static_assert ( ! events : : syscall : : isEventTypeEnter ( <nl> + events : : syscall : : EventType : : SetuidExit ) , <nl> " " ) ; <nl> static_assert ( <nl> - events : : syscall : : isTypeEnter ( events : : syscall : : Type : : SetuidEnter ) , " " ) ; <nl> - static_assert ( <nl> - events : : syscall : : isTypeEnter ( events : : syscall : : Type : : SetuidEnter ) , " " ) ; <nl> + ! events : : syscall : : isEventTypeEnter ( events : : syscall : : EventType : : Unknown ) , <nl> + " " ) ; <nl> + static_assert ( events : : syscall : : isEventTypeEnter ( <nl> + events : : syscall : : EventType : : SetuidEnter ) , <nl> + " " ) ; <nl> + static_assert ( events : : syscall : : isEventTypeEnter ( <nl> + events : : syscall : : EventType : : SetuidEnter ) , <nl> + " " ) ; <nl> } <nl> <nl> TEST_F ( EnterExitJoinerTests , <nl> TEST_F ( EnterExitJoinerTests , <nl> auto joiner = events : : syscall : : EnterExitJoiner { } ; <nl> { <nl> auto enter_event = events : : syscall : : Event { } ; <nl> - enter_event . type = events : : syscall : : Type : : SetuidEnter ; <nl> + enter_event . type = events : : syscall : : EventType : : SetuidEnter ; <nl> enter_event . tgid = 146 ; <nl> enter_event . body . setuid_enter . arg_uid = 48 ; <nl> enter_event . body . setuid_enter . uid = 49 ; <nl> TEST_F ( EnterExitJoinerTests , <nl> } <nl> } <nl> auto exit_event = events : : syscall : : Event { } ; <nl> - exit_event . type = events : : syscall : : Type : : SetuidExit ; <nl> + exit_event . type = events : : syscall : : EventType : : SetuidExit ; <nl> exit_event . tgid = 146 ; <nl> exit_event . body . exit . ret = - 59 ; <nl> <nl> TEST_F ( EnterExitJoinerTests , <nl> <nl> auto event = joiner . join ( exit_event ) ; <nl> ASSERT_TRUE ( event ) ; <nl> - EXPECT_EQ ( event - > type , events : : syscall : : Type : : SetuidEnter ) ; <nl> + EXPECT_EQ ( event - > type , events : : syscall : : EventType : : SetuidEnter ) ; <nl> EXPECT_EQ ( event - > pid , pid ) ; <nl> EXPECT_EQ ( event - > tgid , 146 ) ; <nl> EXPECT_EQ ( event - > body . setuid_enter . arg_uid , 48 ) ; <nl> TEST_F ( EnterExitJoinerTests , EnterExitJoiner_one_non_paired_event_by_pid ) { <nl> auto joiner = events : : syscall : : EnterExitJoiner { } ; <nl> <nl> auto enter_event = events : : syscall : : Event { } ; <nl> - enter_event . type = events : : syscall : : Type : : SetuidEnter ; <nl> + enter_event . type = events : : syscall : : EventType : : SetuidEnter ; <nl> enter_event . pid = 45 ; <nl> enter_event . tgid = 146 ; <nl> enter_event . body . setuid_enter . arg_uid = 48 ; <nl> TEST_F ( EnterExitJoinerTests , EnterExitJoiner_one_non_paired_event_by_pid ) { <nl> ASSERT_FALSE ( out ) ; <nl> <nl> auto exit_event = events : : syscall : : Event { } ; <nl> - exit_event . type = events : : syscall : : Type : : SetuidExit ; <nl> + exit_event . type = events : : syscall : : EventType : : SetuidExit ; <nl> exit_event . pid = enter_event . pid + 12 ; / / pid is different <nl> exit_event . tgid = enter_event . tgid ; <nl> exit_event . body . exit . ret = - 59 ; <nl> TEST_F ( EnterExitJoinerTests , EnterExitJoiner_one_non_paired_event_by_type ) { <nl> auto joiner = events : : syscall : : EnterExitJoiner { } ; <nl> <nl> auto enter_event = events : : syscall : : Event { } ; <nl> - enter_event . type = events : : syscall : : Type : : SetuidEnter ; <nl> + enter_event . type = events : : syscall : : EventType : : SetuidEnter ; <nl> enter_event . pid = 45 ; <nl> enter_event . tgid = 146 ; <nl> enter_event . body . setuid_enter . arg_uid = 48 ; <nl> TEST_F ( EnterExitJoinerTests , EnterExitJoiner_one_non_paired_event_by_type ) { <nl> ASSERT_FALSE ( out ) ; <nl> <nl> auto exit_event = events : : syscall : : Event { } ; <nl> - exit_event . type = events : : syscall : : Type : : KillExit ; / / type is different <nl> + exit_event . type = events : : syscall : : EventType : : KillExit ; / / type is different <nl> exit_event . pid = enter_event . pid ; <nl> exit_event . tgid = enter_event . tgid ; <nl> exit_event . body . exit . ret = - 59 ; <nl> TEST_F ( EnterExitJoinerTests , EnterExitJoiner_many_same_enter_exit_events ) { <nl> auto joiner = events : : syscall : : EnterExitJoiner { } ; <nl> <nl> auto enter_event = events : : syscall : : Event { } ; <nl> - enter_event . type = events : : syscall : : Type : : SetuidEnter ; <nl> + enter_event . type = events : : syscall : : EventType : : SetuidEnter ; <nl> enter_event . pid = 218 ; <nl> enter_event . tgid = 146 ; <nl> enter_event . body . setuid_enter . arg_uid = 165 ; <nl> TEST_F ( EnterExitJoinerTests , EnterExitJoiner_many_same_enter_exit_events ) { <nl> } <nl> <nl> auto exit_event = events : : syscall : : Event { } ; <nl> - exit_event . type = events : : syscall : : Type : : SetuidExit ; <nl> + exit_event . type = events : : syscall : : EventType : : SetuidExit ; <nl> exit_event . pid = enter_event . pid ; <nl> exit_event . tgid = enter_event . tgid ; <nl> exit_event . body . exit . ret = - 59 ; <nl> TEST_F ( EnterExitJoinerTests , EnterExitJoiner_many_same_enter_exit_events ) { <nl> auto event = joiner . join ( exit_event ) ; <nl> ASSERT_TRUE ( event ) ; <nl> <nl> - EXPECT_EQ ( event - > type , events : : syscall : : Type : : SetuidEnter ) ; <nl> + EXPECT_EQ ( event - > type , events : : syscall : : EventType : : SetuidEnter ) ; <nl> EXPECT_EQ ( event - > pid , enter_event . pid ) ; <nl> EXPECT_EQ ( event - > tgid , enter_event . tgid ) ; <nl> EXPECT_EQ ( event - > body . setuid_enter . arg_uid , <nl>
|
Rename syscall : : Type to syscall : : EventType ( )
|
osquery/osquery
|
e7d1a56cfc879dfda41d741a434db840fe874864
|
2019-02-13T18:55:34Z
|
mmm a / src / library_browser . js <nl> ppp b / src / library_browser . js <nl> mergeInto ( LibraryManager . library , { <nl> # endif <nl> / / Set the background of the WebGL canvas to black <nl> canvas . style . backgroundColor = " black " ; <nl> + <nl> + / / Warn on context loss <nl> + canvas . addEventListener ( ' webglcontextlost ' , function ( event ) { <nl> + alert ( ' WebGL context lost . You will need to reload the page . ' ) ; <nl> + } , false ) ; <nl> } <nl> if ( setInModule ) { <nl> Module . ctx = ctx ; <nl>
|
warn on loss of webgl context
|
emscripten-core/emscripten
|
faf13f78df6aba1f4eddcca1f0778eaa878e1495
|
2012-05-14T23:17:02Z
|
mmm a / xbmc / pvr / windows / GUIWindowPVRChannels . cpp <nl> ppp b / xbmc / pvr / windows / GUIWindowPVRChannels . cpp <nl> void CGUIWindowPVRChannels : : UpdateData ( bool bUpdateSelectedFile / * = true * / ) <nl> CPVRChannelGroupPtr selectedGroup = SelectedGroup ( ) ; <nl> <nl> m_iSelected = m_parent - > m_viewControl . GetSelectedItem ( ) ; <nl> - m_parent - > m_viewControl . Clear ( ) ; <nl> + ShowBusyItem ( ) ; <nl> m_parent - > m_vecItems - > Clear ( ) ; <nl> m_parent - > m_viewControl . SetCurrentView ( m_iControlList ) ; <nl> <nl> mmm a / xbmc / pvr / windows / GUIWindowPVRCommon . cpp <nl> ppp b / xbmc / pvr / windows / GUIWindowPVRCommon . cpp <nl> bool CGUIWindowPVRCommon : : OnContextButtonFind ( CFileItem * item , CONTEXT_BUTTON bu <nl> <nl> return bReturn ; <nl> } <nl> + <nl> + void CGUIWindowPVRCommon : : ShowBusyItem ( void ) <nl> + { <nl> + / / FIXME : display a temporary entry so that the list can keep its focus <nl> + / / busy_items has to be static , because m_viewControl holds the pointer to it <nl> + static CFileItemList busy_items ; <nl> + if ( busy_items . IsEmpty ( ) ) <nl> + { <nl> + CFileItemPtr pItem ( new CFileItem ( g_localizeStrings . Get ( 1040 ) ) ) ; <nl> + busy_items . AddFront ( pItem , 0 ) ; <nl> + } <nl> + m_parent - > m_viewControl . SetItems ( busy_items ) ; <nl> + } <nl> mmm a / xbmc / pvr / windows / GUIWindowPVRCommon . h <nl> ppp b / xbmc / pvr / windows / GUIWindowPVRCommon . h <nl> namespace PVR <nl> virtual bool UpdateEpgForChannel ( CFileItem * item ) ; <nl> virtual bool ShowTimerSettings ( CFileItem * item ) ; <nl> virtual bool ShowNewTimerDialog ( void ) ; <nl> + virtual void ShowBusyItem ( void ) ; <nl> <nl> virtual bool OnContextButtonMenuHooks ( CFileItem * item , CONTEXT_BUTTON button ) ; <nl> virtual bool OnContextButtonSortAsc ( CFileItem * item , CONTEXT_BUTTON button ) ; <nl> mmm a / xbmc / pvr / windows / GUIWindowPVRGuide . cpp <nl> ppp b / xbmc / pvr / windows / GUIWindowPVRGuide . cpp <nl> void CGUIWindowPVRGuide : : UpdateData ( bool bUpdateSelectedFile / * = true * / ) <nl> <nl> / * lock the graphics context while updating * / <nl> CSingleLock graphicsLock ( g_graphicsContext ) ; <nl> - m_parent - > m_viewControl . Clear ( ) ; <nl> + ShowBusyItem ( ) ; <nl> m_parent - > m_vecItems - > Clear ( ) ; <nl> <nl> if ( m_iGuideView = = GUIDE_VIEW_CHANNEL ) <nl> mmm a / xbmc / pvr / windows / GUIWindowPVRRecordings . cpp <nl> ppp b / xbmc / pvr / windows / GUIWindowPVRRecordings . cpp <nl> void CGUIWindowPVRRecordings : : UpdateData ( bool bUpdateSelectedFile / * = true * / ) <nl> else <nl> m_strSelectedPath = m_parent - > m_vecItems - > GetPath ( ) ; <nl> <nl> - m_parent - > m_viewControl . Clear ( ) ; <nl> + ShowBusyItem ( ) ; <nl> m_parent - > m_vecItems - > Clear ( ) ; <nl> m_parent - > m_viewControl . SetCurrentView ( m_iControlList ) ; <nl> m_parent - > m_vecItems - > SetPath ( m_strSelectedPath ) ; <nl> mmm a / xbmc / pvr / windows / GUIWindowPVRSearch . cpp <nl> ppp b / xbmc / pvr / windows / GUIWindowPVRSearch . cpp <nl> void CGUIWindowPVRSearch : : UpdateData ( bool bUpdateSelectedFile / * = true * / ) <nl> CSingleLock graphicsLock ( g_graphicsContext ) ; <nl> <nl> m_iSelected = m_parent - > m_viewControl . GetSelectedItem ( ) ; <nl> - m_parent - > m_viewControl . Clear ( ) ; <nl> + ShowBusyItem ( ) ; <nl> m_parent - > m_vecItems - > Clear ( ) ; <nl> m_parent - > m_viewControl . SetCurrentView ( m_iControlList ) ; <nl> <nl> mmm a / xbmc / pvr / windows / GUIWindowPVRTimers . cpp <nl> ppp b / xbmc / pvr / windows / GUIWindowPVRTimers . cpp <nl> void CGUIWindowPVRTimers : : UpdateData ( bool bUpdateSelectedFile / * = true * / ) <nl> CSingleLock graphicsLock ( g_graphicsContext ) ; <nl> <nl> m_iSelected = m_parent - > m_viewControl . GetSelectedItem ( ) ; <nl> - m_parent - > m_viewControl . Clear ( ) ; <nl> + ShowBusyItem ( ) ; <nl> m_parent - > m_vecItems - > Clear ( ) ; <nl> m_parent - > m_viewControl . SetCurrentView ( m_iControlList ) ; <nl> m_parent - > m_vecItems - > SetPath ( " pvr : / / timers / " ) ; <nl>
|
[ pvr ] Show last view when restoring the PVR window .
|
xbmc/xbmc
|
a0475cd6498e5707bd8f1d04b1d5120cd192b06e
|
2012-11-16T22:21:23Z
|
mmm a / samples / cpp / 3calibration . cpp <nl> ppp b / samples / cpp / 3calibration . cpp <nl> using namespace std ; <nl> <nl> enum { DETECTION = 0 , CAPTURING = 1 , CALIBRATED = 2 } ; <nl> <nl> - static void help ( ) <nl> + static void help ( char * * argv ) <nl> { <nl> printf ( " \ nThis is a camera calibration sample that calibrates 3 horizontally placed cameras together . \ n " <nl> - " Usage : 3calibration \ n " <nl> + " Usage : % s \ n " <nl> " - w = < board_width > # the number of inner corners per one of board dimension \ n " <nl> " - h = < board_height > # the number of inner corners per another board dimension \ n " <nl> " [ - s = < squareSize > ] # square size in some user - defined units ( 1 by default ) \ n " <nl> static void help ( ) <nl> " [ - a = < aspectRatio > ] # fix aspect ratio ( fx / fy ) \ n " <nl> " [ - p ] # fix the principal point at the center \ n " <nl> " [ input_data ] # input data - text file with a list of the images of the board \ n " <nl> - " \ n " ) ; <nl> + " \ n " , argv [ 0 ] ) ; <nl> <nl> } <nl> <nl> int main ( int argc , char * * argv ) <nl> " { zt | | } { a | 1 | } { p | | } { @ input | | } " ) ; <nl> if ( parser . has ( " help " ) ) <nl> { <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> return 0 ; <nl> } <nl> boardSize . width = parser . get < int > ( " w " ) ; <nl> int main ( int argc , char * * argv ) <nl> inputFilename = parser . get < string > ( " @ input " ) ; <nl> if ( ! parser . check ( ) ) <nl> { <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> parser . printErrors ( ) ; <nl> return - 1 ; <nl> } <nl> mmm a / samples / cpp / calibration . cpp <nl> ppp b / samples / cpp / calibration . cpp <nl> const char * liveCaptureHelp = <nl> " ' g ' - start capturing images \ n " <nl> " ' u ' - switch undistortion on / off \ n " ; <nl> <nl> - static void help ( ) <nl> + static void help ( char * * argv ) <nl> { <nl> printf ( " This is a camera calibration sample . \ n " <nl> - " Usage : calibration \ n " <nl> + " Usage : % s \ n " <nl> " - w = < board_width > # the number of inner corners per one of board dimension \ n " <nl> " - h = < board_height > # the number of inner corners per another board dimension \ n " <nl> " [ - pt = < pattern > ] # the type of pattern : chessboard or circles ' grid \ n " <nl> static void help ( ) <nl> " # the text file can be generated with imagelist_creator \ n " <nl> " # - name of video file with a video of the board \ n " <nl> " # if input_data not specified , a live view from the camera is used \ n " <nl> - " \ n " ) ; <nl> + " \ n " , argv [ 0 ] ) ; <nl> printf ( " \ n % s " , usage ) ; <nl> printf ( " \ n % s " , liveCaptureHelp ) ; <nl> } <nl> int main ( int argc , char * * argv ) <nl> " { @ input_data | 0 | } " ) ; <nl> if ( parser . has ( " help " ) ) <nl> { <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> return 0 ; <nl> } <nl> boardSize . width = parser . get < int > ( " w " ) ; <nl> int main ( int argc , char * * argv ) <nl> inputFilename = parser . get < string > ( " @ input_data " ) ; <nl> if ( ! parser . check ( ) ) <nl> { <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> parser . printErrors ( ) ; <nl> return - 1 ; <nl> } <nl> mmm a / samples / cpp / camshiftdemo . cpp <nl> ppp b / samples / cpp / camshiftdemo . cpp <nl> <nl> - # include < opencv2 / core / utility . hpp > <nl> + # include " opencv2 / core / utility . hpp " <nl> # include " opencv2 / video / tracking . hpp " <nl> # include " opencv2 / imgproc . hpp " <nl> # include " opencv2 / videoio . hpp " <nl> string hot_keys = <nl> " \ tp - pause video \ n " <nl> " To initialize tracking , select the object with mouse \ n " ; <nl> <nl> - static void help ( ) <nl> + static void help ( const char * * argv ) <nl> { <nl> cout < < " \ nThis is a demo that shows mean - shift based tracking \ n " <nl> " You select a color objects such as your face and it tracks it . \ n " <nl> " This reads from video camera ( 0 by default , or the camera number the user enters \ n " <nl> - " Usage : \ n " <nl> - " . / camshiftdemo [ camera number ] \ n " ; <nl> + " Usage : \ n \ t " ; <nl> + cout < < argv [ 0 ] < < " [ camera number ] \ n " ; <nl> cout < < hot_keys ; <nl> } <nl> <nl> int main ( int argc , const char * * argv ) <nl> CommandLineParser parser ( argc , argv , keys ) ; <nl> if ( parser . has ( " help " ) ) <nl> { <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> return 0 ; <nl> } <nl> int camNum = parser . get < int > ( 0 ) ; <nl> int main ( int argc , const char * * argv ) <nl> <nl> if ( ! cap . isOpened ( ) ) <nl> { <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> cout < < " * * * Could not initialize capturing . . . * * * \ n " ; <nl> cout < < " Current parameter ' s value : \ n " ; <nl> parser . printMessage ( ) ; <nl> mmm a / samples / cpp / contours2 . cpp <nl> ppp b / samples / cpp / contours2 . cpp <nl> <nl> using namespace cv ; <nl> using namespace std ; <nl> <nl> - static void help ( ) <nl> + static void help ( char * * argv ) <nl> { <nl> cout <nl> - < < " \ nThis program illustrates the use of findContours and drawContours \ n " <nl> - < < " The original image is put up along with the image of drawn contours \ n " <nl> - < < " Usage : \ n " <nl> - < < " . / contours2 \ n " <nl> - < < " \ nA trackbar is put up which controls the contour level from - 3 to 3 \ n " <nl> - < < endl ; <nl> + < < " \ nThis program illustrates the use of findContours and drawContours \ n " <nl> + < < " The original image is put up along with the image of drawn contours \ n " <nl> + < < " Usage : \ n " ; <nl> + cout <nl> + < < argv [ 0 ] <nl> + < < " \ nA trackbar is put up which controls the contour level from - 3 to 3 \ n " <nl> + < < endl ; <nl> } <nl> <nl> const int w = 500 ; <nl> int main ( int argc , char * * argv ) <nl> cv : : CommandLineParser parser ( argc , argv , " { help h | | } " ) ; <nl> if ( parser . has ( " help " ) ) <nl> { <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> return 0 ; <nl> } <nl> Mat img = Mat : : zeros ( w , w , CV_8UC1 ) ; <nl> mmm a / samples / cpp / convexhull . cpp <nl> ppp b / samples / cpp / convexhull . cpp <nl> <nl> using namespace cv ; <nl> using namespace std ; <nl> <nl> - static void help ( ) <nl> + static void help ( char * * argv ) <nl> { <nl> cout < < " \ nThis sample program demonstrates the use of the convexHull ( ) function \ n " <nl> < < " Call : \ n " <nl> - < < " . / convexhull \ n " < < endl ; <nl> + < < argv [ 0 ] < < endl ; <nl> } <nl> <nl> int main ( int argc , char * * argv ) <nl> int main ( int argc , char * * argv ) <nl> CommandLineParser parser ( argc , argv , " { help h | | } " ) ; <nl> if ( parser . has ( " help " ) ) <nl> { <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> return 0 ; <nl> } <nl> Mat img ( 500 , 500 , CV_8UC3 ) ; <nl> mmm a / samples / cpp / cout_mat . cpp <nl> ppp b / samples / cpp / cout_mat . cpp <nl> <nl> using namespace std ; <nl> using namespace cv ; <nl> <nl> - static void help ( ) <nl> + static void help ( char * * argv ) <nl> { <nl> cout <nl> < < " \ nmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm \ n " <nl> static void help ( ) <nl> < < " That is , cv : : Mat M ( . . . ) ; cout < < M ; Now works . \ n " <nl> < < " Output can be formatted to OpenCV , matlab , python , numpy , csv and \ n " <nl> < < " C styles Usage : \ n " <nl> - < < " . / cvout_sample \ n " <nl> - < < " mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm \ n \ n " <nl> + < < argv [ 0 ] <nl> + < < " \ nmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm \ n \ n " <nl> < < endl ; <nl> } <nl> <nl> int main ( int argc , char * * argv ) <nl> cv : : CommandLineParser parser ( argc , argv , " { help h | | } " ) ; <nl> if ( parser . has ( " help " ) ) <nl> { <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> return 0 ; <nl> } <nl> Mat I = Mat : : eye ( 4 , 4 , CV_64F ) ; <nl> mmm a / samples / cpp / delaunay2 . cpp <nl> ppp b / samples / cpp / delaunay2 . cpp <nl> <nl> using namespace cv ; <nl> using namespace std ; <nl> <nl> - static void help ( ) <nl> + static void help ( char * * argv ) <nl> { <nl> cout < < " \ nThis program demonstrates iterative construction of \ n " <nl> - " delaunay triangulation and voronoi tessellation . \ n " <nl> - " It draws a random set of points in an image and then delaunay triangulates them . \ n " <nl> - " Usage : \ n " <nl> - " . / delaunay \ n " <nl> - " \ nThis program builds the triangulation interactively , you may stop this process by \ n " <nl> - " hitting any key . \ n " ; <nl> + " delaunay triangulation and voronoi tessellation . \ n " <nl> + " It draws a random set of points in an image and then delaunay triangulates them . \ n " <nl> + " Usage : \ n " ; <nl> + cout < < argv [ 0 ] ; <nl> + cout < < " \ n \ nThis program builds the triangulation interactively , you may stop this process by \ n " <nl> + " hitting any key . \ n " ; <nl> } <nl> <nl> static void draw_subdiv_point ( Mat & img , Point2f fp , Scalar color ) <nl> int main ( int argc , char * * argv ) <nl> cv : : CommandLineParser parser ( argc , argv , " { help h | | } " ) ; <nl> if ( parser . has ( " help " ) ) <nl> { <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> return 0 ; <nl> } <nl> <nl> mmm a / samples / cpp / detect_blob . cpp <nl> ppp b / samples / cpp / detect_blob . cpp <nl> using namespace std ; <nl> using namespace cv ; <nl> <nl> <nl> - static void help ( ) <nl> + static void help ( char * * argv ) <nl> { <nl> cout < < " \ n This program demonstrates how to use BLOB to detect and filter region \ n " <nl> - " Usage : \ n " <nl> - " . / detect_blob < image1 ( detect_blob . png as default ) > \ n " <nl> - " Press a key when image window is active to change descriptor " ; <nl> + < < " Usage : \ n " <nl> + < < argv [ 0 ] <nl> + < < " < image1 ( detect_blob . png as default ) > \ n " <nl> + < < " Press a key when image window is active to change descriptor " ; <nl> } <nl> <nl> <nl> int main ( int argc , char * argv [ ] ) <nl> cv : : CommandLineParser parser ( argc , argv , " { @ input | detect_blob . png | } { h help | | } " ) ; <nl> if ( parser . has ( " h " ) ) <nl> { <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> return 0 ; <nl> } <nl> fileName = parser . get < string > ( " @ input " ) ; <nl> int main ( int argc , char * argv [ ] ) <nl> uchar c3 = ( uchar ) rand ( ) ; <nl> palette . push_back ( Vec3b ( c1 , c2 , c3 ) ) ; <nl> } <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> <nl> <nl> / / These descriptors are going to be detecting and computing BLOBS with 6 different params <nl> mmm a / samples / cpp / detect_mser . cpp <nl> ppp b / samples / cpp / detect_mser . cpp <nl> using namespace std ; <nl> using namespace cv ; <nl> <nl> <nl> - static void help ( ) <nl> + static void help ( char * * argv ) <nl> { <nl> cout < < " \ nThis program demonstrates how to use MSER to detect extremal regions \ n " <nl> - " Usage : \ n " <nl> - " . / detect_mser < image1 ( without parameter a synthetic image is used as default ) > \ n " <nl> - " Press esc key when image window is active to change descriptor parameter \ n " <nl> - " Press 2 , 8 , 4 , 6 , + , - , or 5 keys in openGL windows to change view or use mouse \ n " ; <nl> + " Usage : \ n " <nl> + < < argv [ 0 ] < < " < image1 ( without parameter a synthetic image is used as default ) > \ n " <nl> + " Press esc key when image window is active to change descriptor parameter \ n " <nl> + " Press 2 , 8 , 4 , 6 , + , - , or 5 keys in openGL windows to change view or use mouse \ n " ; <nl> } <nl> <nl> struct MSERParams <nl> int main ( int argc , char * argv [ ] ) <nl> cv : : CommandLineParser parser ( argc , argv , " { help h | | } { @ input | | } " ) ; <nl> if ( parser . has ( " help " ) ) <nl> { <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> return 0 ; <nl> } <nl> <nl> int main ( int argc , char * argv [ ] ) <nl> for ( int i = 0 ; i < = numeric_limits < uint16_t > : : max ( ) ; i + + ) <nl> palette . push_back ( Vec3b ( ( uchar ) rand ( ) , ( uchar ) rand ( ) , ( uchar ) rand ( ) ) ) ; <nl> <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> <nl> MSERParams params ; <nl> <nl> mmm a / samples / cpp / digits . cpp <nl> ppp b / samples / cpp / digits . cpp <nl> const int SZ = 20 ; / / size of each digit is SZ x SZ <nl> const int CLASS_N = 10 ; <nl> const char * DIGITS_FN = " digits . png " ; <nl> <nl> - static void help ( ) <nl> + static void help ( char * * argv ) <nl> { <nl> cout < < <nl> " \ n " <nl> static void help ( ) <nl> " http : / / www . robots . ox . ac . uk / ~ vgg / publications / 2012 / Arandjelovic12 / arandjelovic12 . pdf \ n " <nl> " \ n " <nl> " Usage : \ n " <nl> - " . / digits \ n " < < endl ; <nl> + < < argv [ 0 ] < < endl ; <nl> } <nl> <nl> static void split2d ( const Mat & image , const Size cell_size , vector < Mat > & cells ) <nl> static void shuffle ( vector < Mat > & digits , vector < int > & labels ) <nl> labels = shuffled_labels ; <nl> } <nl> <nl> - int main ( ) <nl> + int main ( int / * argc * / , char * argv [ ] ) <nl> { <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> <nl> vector < Mat > digits ; <nl> vector < int > labels ; <nl> mmm a / samples / cpp / distrans . cpp <nl> ppp b / samples / cpp / distrans . cpp <nl> static void onTrackbar ( int , void * ) <nl> imshow ( " Distance Map " , dist8u ) ; <nl> } <nl> <nl> - static void help ( ) <nl> + static void help ( const char * * argv ) <nl> { <nl> printf ( " \ nProgram to demonstrate the use of the distance transform function between edge images . \ n " <nl> " Usage : \ n " <nl> - " . / distrans [ image_name - - default image is stuff . jpg ] \ n " <nl> + " % s [ image_name - - default image is stuff . jpg ] \ n " <nl> " \ nHot keys : \ n " <nl> " \ tESC - quit the program \ n " <nl> " \ tC - use C / Inf metric \ n " <nl> static void help ( ) <nl> " \ t0 - use precise distance transform \ n " <nl> " \ tv - switch to Voronoi diagram mode \ n " <nl> " \ tp - switch to pixel - based Voronoi diagram mode \ n " <nl> - " \ tSPACE - loop through all the modes \ n \ n " ) ; <nl> + " \ tSPACE - loop through all the modes \ n \ n " , argv [ 0 ] ) ; <nl> } <nl> <nl> const char * keys = <nl> const char * keys = <nl> int main ( int argc , const char * * argv ) <nl> { <nl> CommandLineParser parser ( argc , argv , keys ) ; <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> if ( parser . has ( " help " ) ) <nl> return 0 ; <nl> string filename = parser . get < string > ( 0 ) ; <nl> int main ( int argc , const char * * argv ) <nl> if ( gray . empty ( ) ) <nl> { <nl> printf ( " Cannot read image file : % s \ n " , filename . c_str ( ) ) ; <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> return - 1 ; <nl> } <nl> <nl> mmm a / samples / cpp / drawing . cpp <nl> ppp b / samples / cpp / drawing . cpp <nl> <nl> <nl> using namespace cv ; <nl> <nl> - static void help ( ) <nl> + static void help ( char * * argv ) <nl> { <nl> printf ( " \ nThis program demonstrates OpenCV drawing and text output functions . \ n " <nl> " Usage : \ n " <nl> - " . / drawing \ n " ) ; <nl> + " % s \ n " , argv [ 0 ] ) ; <nl> } <nl> static Scalar randomColor ( RNG & rng ) <nl> { <nl> static Scalar randomColor ( RNG & rng ) <nl> return Scalar ( icolor & 255 , ( icolor > > 8 ) & 255 , ( icolor > > 16 ) & 255 ) ; <nl> } <nl> <nl> - int main ( ) <nl> + int main ( int / * argc * / , char * * argv ) <nl> { <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> char wndname [ ] = " Drawing Demo " ; <nl> const int NUMBER = 100 ; <nl> const int DELAY = 5 ; <nl> mmm a / samples / cpp / edge . cpp <nl> ppp b / samples / cpp / edge . cpp <nl> static void onTrackbar ( int , void * ) <nl> imshow ( window_name2 , cedge ) ; <nl> } <nl> <nl> - static void help ( ) <nl> + static void help ( const char * * argv ) <nl> { <nl> printf ( " \ nThis sample demonstrates Canny edge detection \ n " <nl> " Call : \ n " <nl> - " / . edge [ image_name - - Default is fruits . jpg ] \ n \ n " ) ; <nl> + " % s [ image_name - - Default is fruits . jpg ] \ n \ n " , argv [ 0 ] ) ; <nl> } <nl> <nl> const char * keys = <nl> const char * keys = <nl> <nl> int main ( int argc , const char * * argv ) <nl> { <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> CommandLineParser parser ( argc , argv , keys ) ; <nl> string filename = parser . get < string > ( 0 ) ; <nl> <nl> int main ( int argc , const char * * argv ) <nl> if ( image . empty ( ) ) <nl> { <nl> printf ( " Cannot read image file : % s \ n " , filename . c_str ( ) ) ; <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> return - 1 ; <nl> } <nl> cedge . create ( image . size ( ) , image . type ( ) ) ; <nl> mmm a / samples / cpp / facedetect . cpp <nl> ppp b / samples / cpp / facedetect . cpp <nl> <nl> using namespace std ; <nl> using namespace cv ; <nl> <nl> - static void help ( ) <nl> + static void help ( const char * * argv ) <nl> { <nl> cout < < " \ nThis program demonstrates the use of cv : : CascadeClassifier class to detect objects ( Face + eyes ) . You can use Haar or LBP features . \ n " <nl> " This classifier can recognize many kinds of rigid objects , once the appropriate classifier is trained . \ n " <nl> " It ' s most known use is for faces . \ n " <nl> " Usage : \ n " <nl> - " . / facedetect [ - - cascade = < cascade_path > this is the primary trained classifier such as frontal face ] \ n " <nl> - " [ - - nested - cascade [ = nested_cascade_path this an optional secondary classifier such as eyes ] ] \ n " <nl> - " [ - - scale = < image scale greater or equal to 1 , try 1 . 3 for example > ] \ n " <nl> - " [ - - try - flip ] \ n " <nl> - " [ filename | camera_index ] \ n \ n " <nl> - " see facedetect . cmd for one call : \ n " <nl> - " . / facedetect - - cascade = \ " data / haarcascades / haarcascade_frontalface_alt . xml \ " - - nested - cascade = \ " data / haarcascades / haarcascade_eye_tree_eyeglasses . xml \ " - - scale = 1 . 3 \ n \ n " <nl> + < < argv [ 0 ] <nl> + < < " [ - - cascade = < cascade_path > this is the primary trained classifier such as frontal face ] \ n " <nl> + " [ - - nested - cascade [ = nested_cascade_path this an optional secondary classifier such as eyes ] ] \ n " <nl> + " [ - - scale = < image scale greater or equal to 1 , try 1 . 3 for example > ] \ n " <nl> + " [ - - try - flip ] \ n " <nl> + " [ filename | camera_index ] \ n \ n " <nl> + " example : \ n " <nl> + < < argv [ 0 ] <nl> + < < " - - cascade = \ " data / haarcascades / haarcascade_frontalface_alt . xml \ " - - nested - cascade = \ " data / haarcascades / haarcascade_eye_tree_eyeglasses . xml \ " - - scale = 1 . 3 \ n \ n " <nl> " During execution : \ n \ tHit any key to quit . \ n " <nl> " \ tUsing OpenCV version " < < CV_VERSION < < " \ n " < < endl ; <nl> } <nl> int main ( int argc , const char * * argv ) <nl> ) ; <nl> if ( parser . has ( " help " ) ) <nl> { <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> return 0 ; <nl> } <nl> cascadeName = parser . get < string > ( " cascade " ) ; <nl> int main ( int argc , const char * * argv ) <nl> if ( ! cascade . load ( samples : : findFile ( cascadeName ) ) ) <nl> { <nl> cerr < < " ERROR : Could not load classifier cascade " < < endl ; <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> return - 1 ; <nl> } <nl> if ( inputName . empty ( ) | | ( isdigit ( inputName [ 0 ] ) & & inputName . size ( ) = = 1 ) ) <nl> mmm a / samples / cpp / facial_features . cpp <nl> ppp b / samples / cpp / facial_features . cpp <nl> using namespace std ; <nl> using namespace cv ; <nl> <nl> / / Functions for facial feature detection <nl> - static void help ( ) ; <nl> + static void help ( char * * argv ) ; <nl> static void detectFaces ( Mat & , vector < Rect_ < int > > & , string ) ; <nl> static void detectEyes ( Mat & , vector < Rect_ < int > > & , string ) ; <nl> static void detectNose ( Mat & , vector < Rect_ < int > > & , string ) ; <nl> int main ( int argc , char * * argv ) <nl> " { eyes | | } { nose | | } { mouth | | } { help h | | } { @ image | | } { @ facexml | | } " ) ; <nl> if ( parser . has ( " help " ) ) <nl> { <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> return 0 ; <nl> } <nl> input_image_path = parser . get < string > ( " @ image " ) ; <nl> int main ( int argc , char * * argv ) <nl> return 0 ; <nl> } <nl> <nl> - static void help ( ) <nl> + static void help ( char * * argv ) <nl> { <nl> cout < < " \ nThis file demonstrates facial feature points detection using Haarcascade classifiers . \ n " <nl> " The program detects a face and eyes , nose and mouth inside the face . " <nl> " The code has been tested on the Japanese Female Facial Expression ( JAFFE ) database and found " <nl> " to give reasonably accurate results . \ n " ; <nl> <nl> - cout < < " \ nUSAGE : . / cpp - example - facial_features [ IMAGE ] [ FACE_CASCADE ] [ OPTIONS ] \ n " <nl> + cout < < " \ nUSAGE : " < < argv [ 0 ] < < " [ IMAGE ] [ FACE_CASCADE ] [ OPTIONS ] \ n " <nl> " IMAGE \ n \ tPath to the image of a face taken as input . \ n " <nl> " FACE_CASCSDE \ n \ t Path to a haarcascade classifier for face detection . \ n " <nl> " OPTIONS : \ nThere are 3 options available which are described in detail . There must be a " <nl> static void help ( ) <nl> <nl> <nl> cout < < " EXAMPLE : \ n " <nl> - " ( 1 ) . / cpp - example - facial_features image . jpg face . xml - eyes = eyes . xml - mouth = mouth . xml \ n " <nl> + " ( 1 ) " < < argv [ 0 ] < < " image . jpg face . xml - eyes = eyes . xml - mouth = mouth . xml \ n " <nl> " \ tThis will detect the face , eyes and mouth in image . jpg . \ n " <nl> - " ( 2 ) . / cpp - example - facial_features image . jpg face . xml - nose = nose . xml \ n " <nl> + " ( 2 ) " < < argv [ 0 ] < < " image . jpg face . xml - nose = nose . xml \ n " <nl> " \ tThis will detect the face and nose in image . jpg . \ n " <nl> - " ( 3 ) . / cpp - example - facial_features image . jpg face . xml \ n " <nl> + " ( 3 ) " < < argv [ 0 ] < < " image . jpg face . xml \ n " <nl> " \ tThis will detect only the face in image . jpg . \ n " ; <nl> <nl> cout < < " \ n \ nThe classifiers for face and eyes can be downloaded from : " <nl> mmm a / samples / cpp / fback . cpp <nl> ppp b / samples / cpp / fback . cpp <nl> <nl> using namespace cv ; <nl> using namespace std ; <nl> <nl> - static void help ( ) <nl> + static void help ( char * * argv ) <nl> { <nl> cout < < <nl> " \ nThis program demonstrates dense optical flow algorithm by Gunnar Farneback \ n " <nl> " Mainly the function : calcOpticalFlowFarneback ( ) \ n " <nl> " Call : \ n " <nl> - " . / fback \ n " <nl> - " This reads from video camera 0 \ n " < < endl ; <nl> + < < argv [ 0 ] <nl> + < < " This reads from video camera 0 \ n " < < endl ; <nl> } <nl> static void drawOptFlowMap ( const Mat & flow , Mat & cflowmap , int step , <nl> double , const Scalar & color ) <nl> int main ( int argc , char * * argv ) <nl> cv : : CommandLineParser parser ( argc , argv , " { help h | | } " ) ; <nl> if ( parser . has ( " help " ) ) <nl> { <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> return 0 ; <nl> } <nl> VideoCapture cap ( 0 ) ; <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> if ( ! cap . isOpened ( ) ) <nl> return - 1 ; <nl> <nl> mmm a / samples / cpp / ffilldemo . cpp <nl> ppp b / samples / cpp / ffilldemo . cpp <nl> <nl> using namespace cv ; <nl> using namespace std ; <nl> <nl> - static void help ( ) <nl> + static void help ( char * * argv ) <nl> { <nl> cout < < " \ nThis program demonstrated the floodFill ( ) function \ n " <nl> " Call : \ n " <nl> - " . / ffilldemo [ image_name - - Default : fruits . jpg ] \ n " < < endl ; <nl> + < < argv [ 0 ] <nl> + < < " [ image_name - - Default : fruits . jpg ] \ n " < < endl ; <nl> <nl> cout < < " Hot keys : \ n " <nl> " \ tESC - quit the program \ n " <nl> int main ( int argc , char * * argv ) <nl> parser . printMessage ( ) ; <nl> return 0 ; <nl> } <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> image0 . copyTo ( image ) ; <nl> cvtColor ( image0 , gray , COLOR_BGR2GRAY ) ; <nl> mask . create ( image0 . rows + 2 , image0 . cols + 2 , CV_8UC1 ) ; <nl> mmm a / samples / cpp / fitellipse . cpp <nl> ppp b / samples / cpp / fitellipse . cpp <nl> class canvas { <nl> <nl> } ; <nl> <nl> - static void help ( ) <nl> + static void help ( char * * argv ) <nl> { <nl> - cout < < <nl> - " \ nThis program is demonstration for ellipse fitting . The program finds \ n " <nl> - " contours and approximate it by ellipses . Three methods are used to find the \ n " <nl> - " elliptical fits : fitEllipse , fitEllipseAMS and fitEllipseDirect . \ n " <nl> - " Call : \ n " <nl> - " . / fitellipse [ image_name - - Default ellipses . jpg ] \ n " < < endl ; <nl> + cout < < " \ nThis program is demonstration for ellipse fitting . The program finds \ n " <nl> + " contours and approximate it by ellipses . Three methods are used to find the \ n " <nl> + " elliptical fits : fitEllipse , fitEllipseAMS and fitEllipseDirect . \ n " <nl> + " Call : \ n " <nl> + < < argv [ 0 ] < < " [ image_name - - Default ellipses . jpg ] \ n " < < endl ; <nl> } <nl> <nl> int sliderPos = 70 ; <nl> int main ( int argc , char * * argv ) <nl> cv : : CommandLineParser parser ( argc , argv , " { help h | | } { @ image | ellipses . jpg | } " ) ; <nl> if ( parser . has ( " help " ) ) <nl> { <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> return 0 ; <nl> } <nl> string filename = parser . get < string > ( " @ image " ) ; <nl> mmm a / samples / cpp / grabcut . cpp <nl> ppp b / samples / cpp / grabcut . cpp <nl> <nl> using namespace std ; <nl> using namespace cv ; <nl> <nl> - static void help ( ) <nl> + static void help ( char * * argv ) <nl> { <nl> cout < < " \ nThis program demonstrates GrabCut segmentation - - select an object in a region \ n " <nl> " and then grabcut will attempt to segment it out . \ n " <nl> " Call : \ n " <nl> - " . / grabcut < image_name > \ n " <nl> - " \ nSelect a rectangular area around the object you want to segment \ n " < < <nl> - " \ nHot keys : \ n " <nl> - " \ tESC - quit the program \ n " <nl> - " \ tr - restore the original image \ n " <nl> - " \ tn - next iteration \ n " <nl> - " \ n " <nl> - " \ tleft mouse button - set rectangle \ n " <nl> - " \ n " <nl> - " \ tCTRL + left mouse button - set GC_BGD pixels \ n " <nl> - " \ tSHIFT + left mouse button - set GC_FGD pixels \ n " <nl> - " \ n " <nl> - " \ tCTRL + right mouse button - set GC_PR_BGD pixels \ n " <nl> - " \ tSHIFT + right mouse button - set GC_PR_FGD pixels \ n " < < endl ; <nl> + < < argv [ 0 ] < < " < image_name > \ n " <nl> + " \ nSelect a rectangular area around the object you want to segment \ n " < < <nl> + " \ nHot keys : \ n " <nl> + " \ tESC - quit the program \ n " <nl> + " \ tr - restore the original image \ n " <nl> + " \ tn - next iteration \ n " <nl> + " \ n " <nl> + " \ tleft mouse button - set rectangle \ n " <nl> + " \ n " <nl> + " \ tCTRL + left mouse button - set GC_BGD pixels \ n " <nl> + " \ tSHIFT + left mouse button - set GC_FGD pixels \ n " <nl> + " \ n " <nl> + " \ tCTRL + right mouse button - set GC_PR_BGD pixels \ n " <nl> + " \ tSHIFT + right mouse button - set GC_PR_FGD pixels \ n " < < endl ; <nl> } <nl> <nl> const Scalar RED = Scalar ( 0 , 0 , 255 ) ; <nl> static void on_mouse ( int event , int x , int y , int flags , void * param ) <nl> int main ( int argc , char * * argv ) <nl> { <nl> cv : : CommandLineParser parser ( argc , argv , " { @ input | messi5 . jpg | } " ) ; <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> <nl> string filename = parser . get < string > ( " @ input " ) ; <nl> if ( filename . empty ( ) ) <nl> mmm a / samples / cpp / image_alignment . cpp <nl> ppp b / samples / cpp / image_alignment . cpp <nl> <nl> using namespace cv ; <nl> using namespace std ; <nl> <nl> - static void help ( void ) ; <nl> + static void help ( const char * * argv ) ; <nl> static int readWarp ( string iFilename , Mat & warp , int motionType ) ; <nl> static int saveWarp ( string fileName , const Mat & warp , int motionType ) ; <nl> static void draw_warped_roi ( Mat & image , const int width , const int height , Mat & W ) ; <nl> const std : : string keys = <nl> ; <nl> <nl> <nl> - static void help ( void ) <nl> + static void help ( const char * * argv ) <nl> { <nl> <nl> cout < < " \ nThis file demonstrates the use of the ECC image alignment algorithm . When one image " <nl> static void help ( void ) <nl> " are given , the initialization of the warp by command line parsing is possible . " <nl> " If inputWarp is missing , the identity transformation initializes the algorithm . \ n " < < endl ; <nl> <nl> - cout < < " \ nUsage example ( one image ) : \ n . / image_alignment fruits . jpg - o = outWarp . ecc " <nl> - " - m = euclidean - e = 1e - 6 - N = 70 - v = 1 \ n " < < endl ; <nl> + cout < < " \ nUsage example ( one image ) : \ n " <nl> + < < argv [ 0 ] <nl> + < < " fruits . jpg - o = outWarp . ecc " <nl> + " - m = euclidean - e = 1e - 6 - N = 70 - v = 1 \ n " < < endl ; <nl> <nl> - cout < < " \ nUsage example ( two images with initialization ) : \ n . / image_alignment yourInput . png yourTemplate . png " <nl> + cout < < " \ nUsage example ( two images with initialization ) : \ n " <nl> + < < argv [ 0 ] <nl> + < < " yourInput . png yourTemplate . png " <nl> " yourInitialWarp . ecc - o = outWarp . ecc - m = homography - e = 1e - 6 - N = 70 - v = 1 - w = yourFinalImage . png \ n " < < endl ; <nl> <nl> } <nl> int main ( const int argc , const char * argv [ ] ) <nl> parser . about ( " ECC demo " ) ; <nl> <nl> parser . printMessage ( ) ; <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> <nl> string imgFile = parser . get < string > ( 0 ) ; <nl> string tempImgFile = parser . get < string > ( 1 ) ; <nl> mmm a / samples / cpp / laplace . cpp <nl> ppp b / samples / cpp / laplace . cpp <nl> <nl> using namespace cv ; <nl> using namespace std ; <nl> <nl> - static void help ( ) <nl> + static void help ( char * * argv ) <nl> { <nl> cout < < <nl> " \ nThis program demonstrates Laplace point / edge detection using OpenCV function Laplacian ( ) \ n " <nl> " It captures from the camera of your choice : 0 , 1 , . . . default 0 \ n " <nl> " Call : \ n " <nl> - " . / laplace - c = < camera # , default 0 > - p = < index of the frame to be decoded / captured next > \ n " < < endl ; <nl> + < < argv [ 0 ] < < " - c = < camera # , default 0 > - p = < index of the frame to be decoded / captured next > \ n " < < endl ; <nl> } <nl> <nl> enum { GAUSSIAN , BLUR , MEDIAN } ; <nl> int smoothType = GAUSSIAN ; <nl> int main ( int argc , char * * argv ) <nl> { <nl> cv : : CommandLineParser parser ( argc , argv , " { c | 0 | } { p | | } " ) ; <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> <nl> VideoCapture cap ; <nl> string camera = parser . get < string > ( " c " ) ; <nl> mmm a / samples / cpp / letter_recog . cpp <nl> ppp b / samples / cpp / letter_recog . cpp <nl> using namespace std ; <nl> using namespace cv ; <nl> using namespace cv : : ml ; <nl> <nl> - static void help ( ) <nl> + static void help ( char * * argv ) <nl> { <nl> printf ( " \ nThe sample demonstrates how to train Random Trees classifier \ n " <nl> " ( or Boosting classifier , or MLP , or Knearest , or Nbayes , or Support Vector Machines - see main ( ) ) using the provided dataset . \ n " <nl> static void help ( ) <nl> " and the remaining 4000 ( 10000 for boosting ) - to test the classifier . \ n " <nl> " = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = \ n " ) ; <nl> printf ( " \ nThis is letter recognition sample . \ n " <nl> - " The usage : letter_recog [ - data = < path to letter - recognition . data > ] \ \ \ n " <nl> + " The usage : % s [ - data = < path to letter - recognition . data > ] \ \ \ n " <nl> " [ - save = < output XML file for the classifier > ] \ \ \ n " <nl> " [ - load = < XML file with the pre - trained classifier > ] \ \ \ n " <nl> - " [ - boost | - mlp | - knearest | - nbayes | - svm ] # to use boost / mlp / knearest / SVM classifier instead of default Random Trees \ n " ) ; <nl> + " [ - boost | - mlp | - knearest | - nbayes | - svm ] # to use boost / mlp / knearest / SVM classifier instead of default Random Trees \ n " , argv [ 0 ] ) ; <nl> } <nl> <nl> / / This function reads data and responses from the file < filename > <nl> int main ( int argc , char * argv [ ] ) <nl> else if ( parser . has ( " svm " ) ) <nl> method = 5 ; <nl> <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> <nl> if ( ( method = = 0 ? <nl> build_rtrees_classifier ( data_filename , filename_to_save , filename_to_load ) : <nl> mmm a / samples / cpp / matchmethod_orb_akaze_brisk . cpp <nl> ppp b / samples / cpp / matchmethod_orb_akaze_brisk . cpp <nl> <nl> using namespace std ; <nl> using namespace cv ; <nl> <nl> - static void help ( ) <nl> + static void help ( char * argv [ ] ) <nl> { <nl> cout < < " \ n This program demonstrates how to detect compute and match ORB BRISK and AKAZE descriptors \ n " <nl> - " Usage : \ n " <nl> - " . / matchmethod_orb_akaze_brisk - - image1 = < image1 ( basketball1 . png as default ) > - - image2 = < image2 ( basketball2 . png as default ) > \ n " <nl> + " Usage : \ n " <nl> + < < argv [ 0 ] < < " - - image1 = < image1 ( basketball1 . png as default ) > - - image2 = < image2 ( basketball2 . png as default ) > \ n " <nl> " Press a key when image window is active to change algorithm or descriptor " ; <nl> } <nl> <nl> int main ( int argc , char * argv [ ] ) <nl> " { help h | | } " ) ; <nl> if ( parser . has ( " help " ) ) <nl> { <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> return 0 ; <nl> } <nl> fileName . push_back ( samples : : findFile ( parser . get < string > ( 0 ) ) ) ; <nl> mmm a / samples / cpp / morphology2 . cpp <nl> ppp b / samples / cpp / morphology2 . cpp <nl> <nl> <nl> using namespace cv ; <nl> <nl> - static void help ( ) <nl> + static void help ( char * * argv ) <nl> { <nl> <nl> printf ( " \ nShow off image morphology : erosion , dialation , open and close \ n " <nl> - " Call : \ n morphology2 [ image ] \ n " <nl> - " This program also shows use of rect , ellipse and cross kernels \ n \ n " ) ; <nl> + " Call : \ n % s [ image ] \ n " <nl> + " This program also shows use of rect , ellipse and cross kernels \ n \ n " , argv [ 0 ] ) ; <nl> printf ( " Hot keys : \ n " <nl> " \ tESC - quit the program \ n " <nl> " \ tr - use rectangle structuring element \ n " <nl> int main ( int argc , char * * argv ) <nl> cv : : CommandLineParser parser ( argc , argv , " { help h | | } { @ image | baboon . jpg | } " ) ; <nl> if ( parser . has ( " help " ) ) <nl> { <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> return 0 ; <nl> } <nl> std : : string filename = samples : : findFile ( parser . get < std : : string > ( " @ image " ) ) ; <nl> if ( ( src = imread ( filename , IMREAD_COLOR ) ) . empty ( ) ) <nl> { <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> return - 1 ; <nl> } <nl> <nl> mmm a / samples / cpp / segment_objects . cpp <nl> ppp b / samples / cpp / segment_objects . cpp <nl> <nl> using namespace std ; <nl> using namespace cv ; <nl> <nl> - static void help ( ) <nl> + static void help ( char * * argv ) <nl> { <nl> printf ( " \ n " <nl> " This program demonstrated a simple method of connected components clean up of background subtraction \ n " <nl> " When the program starts , it begins learning the background . \ n " <nl> " You can toggle background learning on and off by hitting the space bar . \ n " <nl> " Call \ n " <nl> - " . / segment_objects [ video file , else it reads camera 0 ] \ n \ n " ) ; <nl> + " % s [ video file , else it reads camera 0 ] \ n \ n " , argv [ 0 ] ) ; <nl> } <nl> <nl> static void refineSegments ( const Mat & img , Mat & mask , Mat & dst ) <nl> int main ( int argc , char * * argv ) <nl> CommandLineParser parser ( argc , argv , " { help h | | } { @ input | | } " ) ; <nl> if ( parser . has ( " help " ) ) <nl> { <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> return 0 ; <nl> } <nl> string input = parser . get < std : : string > ( " @ input " ) ; <nl> mmm a / samples / cpp / select3dobj . cpp <nl> ppp b / samples / cpp / select3dobj . cpp <nl> <nl> # include < ctype . h > <nl> # include < stdio . h > <nl> # include < stdlib . h > <nl> + # include < string > <nl> <nl> using namespace std ; <nl> using namespace cv ; <nl> <nl> - const char * helphelp = <nl> - " \ nThis program ' s purpose is to collect data sets of an object and its segmentation mask . \ n " <nl> - " \ n " <nl> - " It shows how to use a calibrated camera together with a calibration pattern to \ n " <nl> - " compute the homography of the plane the calibration pattern is on . It also shows grabCut \ n " <nl> - " segmentation etc . \ n " <nl> - " \ n " <nl> - " select3dobj - w = < board_width > - h = < board_height > [ - s = < square_size > ] \ n " <nl> - " - i = < camera_intrinsics_filename > - o = < output_prefix > \ n " <nl> - " \ n " <nl> - " - w = < board_width > Number of chessboard corners wide \ n " <nl> - " - h = < board_height > Number of chessboard corners width \ n " <nl> - " [ - s = < square_size > ] Optional measure of chessboard squares in meters \ n " <nl> - " - i = < camera_intrinsics_filename > Camera matrix . yml file from calibration . cpp \ n " <nl> - " - o = < output_prefix > Prefix the output segmentation images with this \ n " <nl> - " [ video_filename / cameraId ] If present , read from that video file or that ID \ n " <nl> - " \ n " <nl> - " Using a camera ' s intrinsics ( from calibrating a camera - - see calibration . cpp ) and an \ n " <nl> - " image of the object sitting on a planar surface with a calibration pattern of \ n " <nl> - " ( board_width x board_height ) on the surface , we draw a 3D box around the object . From \ n " <nl> - " then on , we can move a camera and as long as it sees the chessboard calibration pattern , \ n " <nl> - " it will store a mask of where the object is . We get successive images using < output_prefix > \ n " <nl> - " of the segmentation mask containing the object . This makes creating training sets easy . \ n " <nl> - " It is best if the chessboard is odd x even in dimensions to avoid ambiguous poses . \ n " <nl> - " \ n " <nl> - " The actions one can use while the program is running are : \ n " <nl> - " \ n " <nl> - " Select object as 3D box with the mouse . \ n " <nl> - " First draw one line on the plane to outline the projection of that object on the plane \ n " <nl> - " Then extend that line into a box to encompass the projection of that object onto the plane \ n " <nl> - " The use the mouse again to extend the box upwards from the plane to encase the object . \ n " <nl> - " Then use the following commands \ n " <nl> - " ESC - Reset the selection \ n " <nl> - " SPACE - Skip the frame ; move to the next frame ( not in video mode ) \ n " <nl> - " ENTER - Confirm the selection . Grab next object in video mode . \ n " <nl> - " q - Exit the program \ n " <nl> - " \ n \ n " ; <nl> - <nl> + static string helphelp ( char * * argv ) <nl> + { <nl> + return string ( " \ nThis program ' s purpose is to collect data sets of an object and its segmentation mask . \ n " ) <nl> + + " \ n " <nl> + " It shows how to use a calibrated camera together with a calibration pattern to \ n " <nl> + " compute the homography of the plane the calibration pattern is on . It also shows grabCut \ n " <nl> + " segmentation etc . \ n " <nl> + " \ n " <nl> + + argv [ 0 ] <nl> + + " - w = < board_width > - h = < board_height > [ - s = < square_size > ] \ n " <nl> + " - i = < camera_intrinsics_filename > - o = < output_prefix > \ n " <nl> + " \ n " <nl> + " - w = < board_width > Number of chessboard corners wide \ n " <nl> + " - h = < board_height > Number of chessboard corners width \ n " <nl> + " [ - s = < square_size > ] Optional measure of chessboard squares in meters \ n " <nl> + " - i = < camera_intrinsics_filename > Camera matrix . yml file from calibration . cpp \ n " <nl> + " - o = < output_prefix > Prefix the output segmentation images with this \ n " <nl> + " [ video_filename / cameraId ] If present , read from that video file or that ID \ n " <nl> + " \ n " <nl> + " Using a camera ' s intrinsics ( from calibrating a camera - - see calibration . cpp ) and an \ n " <nl> + " image of the object sitting on a planar surface with a calibration pattern of \ n " <nl> + " ( board_width x board_height ) on the surface , we draw a 3D box around the object . From \ n " <nl> + " then on , we can move a camera and as long as it sees the chessboard calibration pattern , \ n " <nl> + " it will store a mask of where the object is . We get successive images using < output_prefix > \ n " <nl> + " of the segmentation mask containing the object . This makes creating training sets easy . \ n " <nl> + " It is best if the chessboard is odd x even in dimensions to avoid ambiguous poses . \ n " <nl> + " \ n " <nl> + " The actions one can use while the program is running are : \ n " <nl> + " \ n " <nl> + " Select object as 3D box with the mouse . \ n " <nl> + " First draw one line on the plane to outline the projection of that object on the plane \ n " <nl> + " Then extend that line into a box to encompass the projection of that object onto the plane \ n " <nl> + " The use the mouse again to extend the box upwards from the plane to encase the object . \ n " <nl> + " Then use the following commands \ n " <nl> + " ESC - Reset the selection \ n " <nl> + " SPACE - Skip the frame ; move to the next frame ( not in video mode ) \ n " <nl> + " ENTER - Confirm the selection . Grab next object in video mode . \ n " <nl> + " q - Exit the program \ n " <nl> + " \ n \ n " ; <nl> + } <nl> / / static void help ( ) <nl> / / { <nl> / / puts ( helphelp ) ; <nl> static bool readStringList ( const string & filename , vector < string > & l ) <nl> <nl> int main ( int argc , char * * argv ) <nl> { <nl> - const char * help = " Usage : select3dobj - w = < board_width > - h = < board_height > [ - s = < square_size > ] \ n " <nl> + string help = string ( " Usage : " ) + argv [ 0 ] + " - w = < board_width > - h = < board_height > [ - s = < square_size > ] \ n " + <nl> " \ t - i = < intrinsics_filename > - o = < output_prefix > [ video_filename / cameraId ] \ n " ; <nl> const char * screen_help = <nl> " Actions : \ n " <nl> int main ( int argc , char * * argv ) <nl> cv : : CommandLineParser parser ( argc , argv , " { help h | | } { w | | } { h | | } { s | 1 | } { i | | } { o | | } { @ input | 0 | } " ) ; <nl> if ( parser . has ( " help " ) ) <nl> { <nl> - puts ( helphelp ) ; <nl> - puts ( help ) ; <nl> + puts ( helphelp ( argv ) . c_str ( ) ) ; <nl> + puts ( help . c_str ( ) ) ; <nl> return 0 ; <nl> } <nl> string intrinsicsFilename ; <nl> int main ( int argc , char * * argv ) <nl> inputName = samples : : findFileOrKeep ( parser . get < string > ( " @ input " ) ) ; <nl> if ( ! parser . check ( ) ) <nl> { <nl> - puts ( help ) ; <nl> + puts ( help . c_str ( ) ) ; <nl> parser . printErrors ( ) ; <nl> return 0 ; <nl> } <nl> if ( boardSize . width < = 0 ) <nl> { <nl> printf ( " Incorrect - w parameter ( must be a positive integer ) \ n " ) ; <nl> - puts ( help ) ; <nl> + puts ( help . c_str ( ) ) ; <nl> return 0 ; <nl> } <nl> if ( boardSize . height < = 0 ) <nl> { <nl> printf ( " Incorrect - h parameter ( must be a positive integer ) \ n " ) ; <nl> - puts ( help ) ; <nl> + puts ( help . c_str ( ) ) ; <nl> return 0 ; <nl> } <nl> if ( squareSize < = 0 ) <nl> { <nl> printf ( " Incorrect - s parameter ( must be a positive real number ) \ n " ) ; <nl> - puts ( help ) ; <nl> + puts ( help . c_str ( ) ) ; <nl> return 0 ; <nl> } <nl> Mat cameraMatrix , distCoeffs ; <nl> mmm a / samples / cpp / stereo_calib . cpp <nl> ppp b / samples / cpp / stereo_calib . cpp <nl> <nl> using namespace cv ; <nl> using namespace std ; <nl> <nl> - static int print_help ( ) <nl> + static int print_help ( char * * argv ) <nl> { <nl> cout < < <nl> " Given a list of chessboard images , the number of corners ( nx , ny ) \ n " <nl> static int print_help ( ) <nl> " matrix separately ) stereo . \ n " <nl> " Calibrate the cameras and display the \ n " <nl> " rectified results along with the computed disparity images . \ n " < < endl ; <nl> - cout < < " Usage : \ n . / stereo_calib - w = < board_width default = 9 > - h = < board_height default = 6 > - s = < square_size default = 1 . 0 > < image list XML / YML file default = stereo_calib . xml > \ n " < < endl ; <nl> + cout < < " Usage : \ n " < < argv [ 0 ] < < " - w = < board_width default = 9 > - h = < board_height default = 6 > - s = < square_size default = 1 . 0 > < image list XML / YML file default = stereo_calib . xml > \ n " < < endl ; <nl> return 0 ; <nl> } <nl> <nl> int main ( int argc , char * * argv ) <nl> bool showRectified ; <nl> cv : : CommandLineParser parser ( argc , argv , " { w | 9 | } { h | 6 | } { s | 1 . 0 | } { nr | | } { help | | } { @ input | stereo_calib . xml | } " ) ; <nl> if ( parser . has ( " help " ) ) <nl> - return print_help ( ) ; <nl> + return print_help ( argv ) ; <nl> showRectified = ! parser . has ( " nr " ) ; <nl> imagelistfn = samples : : findFile ( parser . get < string > ( " @ input " ) ) ; <nl> boardSize . width = parser . get < int > ( " w " ) ; <nl> int main ( int argc , char * * argv ) <nl> if ( ! ok | | imagelist . empty ( ) ) <nl> { <nl> cout < < " can not open " < < imagelistfn < < " or the string list is empty " < < endl ; <nl> - return print_help ( ) ; <nl> + return print_help ( argv ) ; <nl> } <nl> <nl> StereoCalib ( imagelist , boardSize , squareSize , false , true , showRectified ) ; <nl> mmm a / samples / cpp / stereo_match . cpp <nl> ppp b / samples / cpp / stereo_match . cpp <nl> <nl> <nl> using namespace cv ; <nl> <nl> - static void print_help ( ) <nl> + static void print_help ( char * * argv ) <nl> { <nl> printf ( " \ nDemo stereo matching converting L and R images into disparity and point clouds \ n " ) ; <nl> - printf ( " \ nUsage : stereo_match < left_image > < right_image > [ - - algorithm = bm | sgbm | hh | sgbm3way ] [ - - blocksize = < block_size > ] \ n " <nl> + printf ( " \ nUsage : % s < left_image > < right_image > [ - - algorithm = bm | sgbm | hh | sgbm3way ] [ - - blocksize = < block_size > ] \ n " <nl> " [ - - max - disparity = < max_disparity > ] [ - - scale = scale_factor > ] [ - i = < intrinsic_filename > ] [ - e = < extrinsic_filename > ] \ n " <nl> - " [ - - no - display ] [ - o = < disparity_image > ] [ - p = < point_cloud_file > ] \ n " ) ; <nl> + " [ - - no - display ] [ - o = < disparity_image > ] [ - p = < point_cloud_file > ] \ n " , argv [ 0 ] ) ; <nl> } <nl> <nl> static void saveXYZ ( const char * filename , const Mat & mat ) <nl> int main ( int argc , char * * argv ) <nl> " { @ arg1 | | } { @ arg2 | | } { help h | | } { algorithm | | } { max - disparity | 0 | } { blocksize | 0 | } { no - display | | } { scale | 1 | } { i | | } { e | | } { o | | } { p | | } " ) ; <nl> if ( parser . has ( " help " ) ) <nl> { <nl> - print_help ( ) ; <nl> + print_help ( argv ) ; <nl> return 0 ; <nl> } <nl> img1_filename = samples : : findFile ( parser . get < std : : string > ( 0 ) ) ; <nl> int main ( int argc , char * * argv ) <nl> if ( alg < 0 ) <nl> { <nl> printf ( " Command - line parameter error : Unknown stereo algorithm \ n \ n " ) ; <nl> - print_help ( ) ; <nl> + print_help ( argv ) ; <nl> return - 1 ; <nl> } <nl> if ( numberOfDisparities < 1 | | numberOfDisparities % 16 ! = 0 ) <nl> { <nl> printf ( " Command - line parameter error : The max disparity ( - - maxdisparity = < . . . > ) must be a positive integer divisible by 16 \ n " ) ; <nl> - print_help ( ) ; <nl> + print_help ( argv ) ; <nl> return - 1 ; <nl> } <nl> if ( scale < 0 ) <nl> mmm a / samples / cpp / stitching_detailed . cpp <nl> ppp b / samples / cpp / stitching_detailed . cpp <nl> using namespace std ; <nl> using namespace cv ; <nl> using namespace cv : : detail ; <nl> <nl> - static void printUsage ( ) <nl> + static void printUsage ( char * * argv ) <nl> { <nl> cout < < <nl> " Rotation model images stitcher . \ n \ n " <nl> - " stitching_detailed img1 img2 [ . . . imgN ] [ flags ] \ n \ n " <nl> + < < argv [ 0 ] < < " img1 img2 [ . . . imgN ] [ flags ] \ n \ n " <nl> " Flags : \ n " <nl> " - - preview \ n " <nl> " Run stitching in the preview mode . Works faster than usual mode , \ n " <nl> static int parseCmdArgs ( int argc , char * * argv ) <nl> { <nl> if ( argc = = 1 ) <nl> { <nl> - printUsage ( ) ; <nl> + printUsage ( argv ) ; <nl> return - 1 ; <nl> } <nl> for ( int i = 1 ; i < argc ; + + i ) <nl> { <nl> if ( string ( argv [ i ] ) = = " - - help " | | string ( argv [ i ] ) = = " / ? " ) <nl> { <nl> - printUsage ( ) ; <nl> + printUsage ( argv ) ; <nl> return - 1 ; <nl> } <nl> else if ( string ( argv [ i ] ) = = " - - preview " ) <nl> mmm a / samples / cpp / tree_engine . cpp <nl> ppp b / samples / cpp / tree_engine . cpp <nl> <nl> using namespace cv ; <nl> using namespace cv : : ml ; <nl> <nl> - static void help ( ) <nl> + static void help ( char * * argv ) <nl> { <nl> printf ( <nl> " \ nThis sample demonstrates how to use different decision trees and forests including boosting and random trees . \ n " <nl> - " Usage : \ n \ t . / tree_engine [ - r = < response_column > ] [ - ts = type_spec ] < csv filename > \ n " <nl> + " Usage : \ n \ t % s [ - r = < response_column > ] [ - ts = type_spec ] < csv filename > \ n " <nl> " where - r = < response_column > specified the 0 - based index of the response ( 0 by default ) \ n " <nl> " - ts = specifies the var type spec in the form ord [ n1 , n2 - n3 , n4 - n5 , . . . ] cat [ m1 - m2 , m3 , m4 - m5 , . . . ] \ n " <nl> - " < csv filename > is the name of training data file in comma - separated value format \ n \ n " ) ; <nl> + " < csv filename > is the name of training data file in comma - separated value format \ n \ n " , argv [ 0 ] ) ; <nl> } <nl> <nl> static void train_and_print_errs ( Ptr < StatModel > model , const Ptr < TrainData > & data ) <nl> int main ( int argc , char * * argv ) <nl> cv : : CommandLineParser parser ( argc , argv , " { help h | | } { r | 0 | } { ts | | } { @ input | | } " ) ; <nl> if ( parser . has ( " help " ) ) <nl> { <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> return 0 ; <nl> } <nl> std : : string filename = parser . get < std : : string > ( " @ input " ) ; <nl> int main ( int argc , char * * argv ) <nl> if ( filename . empty ( ) | | ! parser . check ( ) ) <nl> { <nl> parser . printErrors ( ) ; <nl> - help ( ) ; <nl> + help ( argv ) ; <nl> return 0 ; <nl> } <nl> printf ( " \ nReading in % s . . . \ n \ n " , filename . c_str ( ) ) ; <nl>
|
Merge pull request from MoonChasing : master
|
opencv/opencv
|
921410356437d29cdb892fa57362e0d542186953
|
2020-03-01T10:15:55Z
|
deleted file mode 100644 <nl> index 9d082465ca . . 0000000000 <nl> mmm a / programs / snapshot / src / classes . js <nl> ppp / dev / null <nl> <nl> - class Registrant { <nl> - <nl> - constructor ( eth , eos = " " , balance = 0 ) { <nl> - this . eth = eth <nl> - this . eos = eos <nl> - this . balance = typeof balance = = ' object ' ? balance : new Balance ( ) <nl> - <nl> - this . index = null <nl> - this . accepted = null <nl> - this . error = false <nl> - } <nl> - <nl> - <nl> - accept ( callback ) { <nl> - <nl> - this . accepted = true <nl> - log ( " message " , ` [ # $ { this . index } ] accepted $ { this . eth } = > $ { this . eos } = > $ { this . balance . total . toFormat ( 4 ) } ` ) <nl> - } <nl> - <nl> - <nl> - reject ( ) { <nl> - this . accepted = false <nl> - let msg = " " <nl> - <nl> - if ( this . balance . exists ( ' reclaimed ' ) ) <nl> - log ( " reject " , ` [ # $ { this . index } ] rejected $ { this . eth } = > $ { this . eos } = > $ { this . balance . total . toFormat ( 4 ) } = > $ { this . error } ( $ { this . balance . reclaimed . toFormat ( 4 ) } reclaimed EOS tokens moved back to Reclaimable ) ` ) <nl> - else <nl> - log ( " reject " , ` [ # $ { this . index } ] rejected $ { this . eth } = > $ { this . eos } = > $ { this . balance . total . toFormat ( 4 ) } = > $ { this . error } ` ) <nl> - } <nl> - <nl> - judgement ( ) { <nl> - return this . valid ( ) ? this . accept ( ) : this . reject ( ) <nl> - } <nl> - <nl> - <nl> - set ( key , value ) { <nl> - return ( typeof this [ ` set_ $ { key } ` ] = = = " function " ) ? this [ ` set_ $ { key } ` ] ( value ) : this <nl> - } <nl> - <nl> - <nl> - set_index ( index ) { <nl> - this . index = index <nl> - return this / / for chaining <nl> - } <nl> - <nl> - <nl> - set_key ( eos_key ) { <nl> - / / Might be hex , try to convert it . <nl> - if ( eos_key . length = = 106 ) { <nl> - let eos_key_from_hex = web3 . toAscii ( eos_key ) <nl> - if ( eos_key_from_hex . startsWith ( ' EOS ' ) & & eos_key_from_hex . length = = 53 ) { <nl> - eos_key = eos_key_from_hex <nl> - } <nl> - } <nl> - / / Might be user error <nl> - else if ( eos_key . startsWith ( ' key ' ) ) { <nl> - let eos_key_mod = eos_key . substring ( 3 ) <nl> - if ( eos_key_mod . startsWith ( ' EOS ' ) & & eos_key_mod . length = = 53 ) { <nl> - eos_key = eos_key_mod <nl> - } <nl> - } <nl> - this . eos = eos_key <nl> - return this / / for chaining <nl> - } <nl> - <nl> - <nl> - / / Reject bad keys and zero balances , elseif was fastest ? : / <nl> - valid ( ) { <nl> - <nl> - / / Reject 0 balances <nl> - if ( this . balance . total . lt ( 1 ) ) { <nl> - this . error = ' balance_insufficient ' <nl> - } <nl> - <nl> - / / Everything else <nl> - else if ( ! this . eos . startsWith ( ' EOS ' ) ) { <nl> - <nl> - / / It ' s an empty key <nl> - if ( this . eos . length = = 0 ) { <nl> - this . error = ' key_is_empty ' <nl> - } <nl> - <nl> - / / It may be an EOS private key <nl> - else if ( this . eos . startsWith ( ' 5 ' ) ) { <nl> - this . error = ' key_is_private ' <nl> - } <nl> - <nl> - / / It almost looks like an EOS key / / # TODO ACTUALLY VALIDATE KEY ? <nl> - else if ( this . eos . startsWith ( ' EOS ' ) & & this . eos . length ! = 53 ) { <nl> - this . error = ' key_is_malformed ' <nl> - } <nl> - <nl> - / / ETH address <nl> - else if ( this . eos . startsWith ( ' 0x ' ) ) { <nl> - this . error = ' key_is_eth ' <nl> - } <nl> - <nl> - / / Reject everything else with junk label <nl> - else { <nl> - this . error = ' key_is_junk ' <nl> - } <nl> - } <nl> - <nl> - / / Accept BTS and STM keys , assume advanced users and correct format <nl> - if ( this . eos . startsWith ( ' BTS ' ) | | this . eos . startsWith ( ' STM ' ) ) { <nl> - this . error = false <nl> - } <nl> - <nl> - return ! this . error ? true : false <nl> - <nl> - } <nl> - } <nl> - <nl> - <nl> - <nl> - <nl> - class Balance { <nl> - <nl> - constructor ( ) { <nl> - this . wallet = web3 . toBigNumber ( 0 ) <nl> - this . unclaimed = web3 . toBigNumber ( 0 ) <nl> - this . reclaimed = web3 . toBigNumber ( 0 ) <nl> - this . total = web3 . toBigNumber ( 0 ) <nl> - } <nl> - <nl> - set ( type , balance ) { <nl> - this [ type ] = balance <nl> - return this / / chaining <nl> - } <nl> - <nl> - readable ( type = ' total ' ) { <nl> - this [ type ] = formatEOS ( this [ type ] ) <nl> - } <nl> - <nl> - exists ( type ) { <nl> - return ( typeof this [ type ] ! = = " undefined " & & this [ type ] . gt ( 0 ) ) <nl> - } <nl> - <nl> - get ( type ) { <nl> - return ( typeof this [ type ] ! = = " undefined " & & this [ type ] . gt ( 0 ) ) ? this [ type ] : false ; <nl> - } <nl> - <nl> - sum ( ) { <nl> - this . total = this . wallet . plus ( this . unclaimed ) . plus ( this . reclaimed ) <nl> - / / Save some dust , higher accuracy . <nl> - this . total = this . total . div ( WAD ) <nl> - this . wallet = this . wallet . div ( WAD ) <nl> - this . unclaimed = this . unclaimed . div ( WAD ) <nl> - this . reclaimed = this . reclaimed . div ( WAD ) <nl> - } <nl> - } <nl> - <nl> - <nl> - class Transaction { <nl> - <nl> - constructor ( eth , tx , type = " transfer " , amount ) { <nl> - this . eth = eth <nl> - this . eos = null <nl> - this . hash = tx <nl> - this . amount = amount <nl> - this . claimed = false <nl> - this . type = type <nl> - } <nl> - <nl> - claim ( eth ) { <nl> - return ( eth = = this . eth ) <nl> - ? ( <nl> - this . claimed = true , <nl> - log ( " success " , ` reclaimed $ { this . eth } = > $ { this . eos } = > $ { this . amount . div ( WAD ) . toFormat ( 4 ) } EOS < < < tx : https : / / etherscan . io / tx / $ { this . hash } ` ) <nl> - ) : log ( " error " , ` $ { eth } should ' t be claiming $ { this . eth } ' s transaction ` ) <nl> - } <nl> - <nl> - } <nl> - <nl> deleted file mode 100644 <nl> index 30effc5b4a . . 0000000000 <nl> mmm a / programs / snapshot / src / snapshot . js <nl> ppp / dev / null <nl> <nl> - / / For processing <nl> - let registrants = [ ] , <nl> - transactions = [ ] <nl> - <nl> - / / For Export <nl> - let output = { } <nl> - output . snapshot = [ ] <nl> - output . rejects = [ ] <nl> - output . reclaimable = [ ] <nl> - output . reclaimed = [ ] <nl> - output . logs = [ ] <nl> - <nl> - / / Web3 <nl> - const Web3 = require ( ' web3 ' ) <nl> - let web3 <nl> - let contract = { } <nl> - <nl> - / / Debugging <nl> - let debug <nl> - <nl> - window . onload = ( ) = > { init ( ) } <nl> - <nl> - const init = ( ) = > { <nl> - console . clear ( ) <nl> - log ( " large_text " , ' EOS Token Distribution ( testnet ) ' ) <nl> - if ( typeof console . time = = = ' function ' ) console . time ( ' Generated Snapshot ' ) <nl> - <nl> - web3 = new Web3 ( new Web3 . providers . HttpProvider ( NODE ) ) <nl> - <nl> - if ( ! web3 . isConnected ( ) ) <nl> - log ( " error " , ' web3 is disconnected ' ) , log ( " info " , ' Please make sure you have a local ethereum node runnning on localhost : 8345 ' ) , disconnected ( init ) <nl> - else if ( ! is_synced ( ) ) <nl> - log ( " error " , ` web3 is still syncing , retrying in 10 seconds . Current block : $ { web3 . eth . syncing . currentBlock } , Required Height : $ { SS_LAST_BLOCK } ` ) , node_syncing ( init ) <nl> - else <nl> - debug = new calculator ( ) , <nl> - <nl> - contract . $ crowdsale = web3 . eth . contract ( CROWDSALE_ABI ) . at ( CROWDSALE_ADDRESS ) , <nl> - contract . $ token = web3 . eth . contract ( TOKEN_ABI ) . at ( TOKEN_ADDRESS ) , <nl> - contract . $ utilities = web3 . eth . contract ( UTILITY_ABI ) . at ( UTILITY_ADDRESS ) , <nl> - <nl> - SS_PERIOD_ETH = period_eth_balance ( ) , <nl> - SS_LAST_BLOCK_TIME = get_last_block_time ( ) , <nl> - <nl> - async . series ( [ <nl> - scan_registry , <nl> - find_reclaimables , <nl> - distribute_tokens , <nl> - verify , <nl> - exporter <nl> - ] , <nl> - ( error , results ) = > { <nl> - if ( ! error ) { <nl> - log ( " success " , ' Distribution List Complete ' ) <nl> - log ( ' block ' , ' CSV Downloads Ready ' ) <nl> - if ( typeof console . timeEnd = = = ' function ' ) console . timeEnd ( ' Generated Snapshot ' ) <nl> - setTimeout ( ( ) = > { / / Makes downloads less glitchy <nl> - clearInterval ( ui_refresh ) <nl> - registrants = undefined , transactions = undefined / / object literals have been generated , unset array of resource consuming referenced objects . <nl> - <nl> - } , 5000 ) <nl> - } else { <nl> - log ( " error " , error ) <nl> - } <nl> - debug . refresh ( ) . output ( ) <nl> - } ) <nl> - } <nl> - <nl> - <nl> - / / Sets balances , validates registrant , adds to distribution if good <nl> - const distribute_tokens = ( finish ) = > { <nl> - log ( ' group ' , ' Distribution List ' ) <nl> - let index = 0 <nl> - const total = registrants . length <nl> - const iterate = ( ) = > { <nl> - if ( ! web3 . isConnected ( ) ) return disconnected ( reconnect = iterate ) <nl> - try { <nl> - let registrant = registrants [ index ] <nl> - <nl> - registrant <nl> - . set ( " index " , index ) <nl> - . set ( " key " , contract . $ crowdsale . keys ( registrant . eth ) ) <nl> - / / Every registrant has three different balances , <nl> - / / Wallet : Tokens in Wallet <nl> - / / Unclaimed : Tokens in contract <nl> - / / Reclaimed : Tokens sent to crowdsale / token contracts <nl> - . balance <nl> - / / Ask token contract what this user ' s EOS balance is <nl> - . set ( ' wallet ' , web3 . toBigNumber ( contract . $ token . balanceOf ( registrant . eth ) ) ) <nl> - / / Loop through periods and calculate unclaimed <nl> - . set ( ' unclaimed ' , web3 . toBigNumber ( sum_unclaimed ( registrant ) ) ) <nl> - / / Check reclaimable index for ethereum user , loop through tx <nl> - . set ( ' reclaimed ' , web3 . toBigNumber ( maybe_reclaim_tokens ( registrant ) ) ) <nl> - / / wallet + unclaimed + reclaimed <nl> - . sum ( ) <nl> - / / Reject or Accept <nl> - registrant . judgement ( ) <nl> - status_log ( ) <nl> - / / Runaway loops , calls iterate again or calls finish ( ) callback from async <nl> - setTimeout ( ( ) = > { <nl> - index + + , <nl> - ( index < total ) ? iterate ( ) : ( <nl> - console . groupEnd ( ) , <nl> - finish ( null , true ) <nl> - ) <nl> - } , 1 ) <nl> - } <nl> - / / This error is web3 related , try again and resume if successful <nl> - catch ( e ) { <nl> - log ( " error " , e ) ; <nl> - if ( ! web3 . isConnected ( ) ) { <nl> - log ( " message " , ` Attempting reconnect once per second , will resume from registrant $ { index } ` ) <nl> - disconnected ( reconnect = iterate ) <nl> - } <nl> - } <nl> - finally { <nl> - <nl> - } <nl> - } <nl> - <nl> - const sum_unclaimed = ( registrant ) = > { <nl> - / / Find all Buys <nl> - let buys = contract . $ utilities . userBuys ( registrant . eth ) . map ( web3 . toBigNumber ) <nl> - / / Find Claimed Balances <nl> - let claims = contract . $ utilities . userClaims ( registrant . eth ) <nl> - / / Compile the periods , and user parameters for each period for later reduction <nl> - const periods = iota ( Number ( CS_NUMBER_OF_PERIODS ) + 1 ) . map ( i = > { <nl> - let period = { } <nl> - period . tokens_available = web3 . toBigNumber ( period = = 0 ? CS_CREATE_FIRST_PERIOD : CS_CREATE_PER_PERIOD ) <nl> - period . total_eth = SS_PERIOD_ETH [ i ] <nl> - period . buys = buys [ i ] & & buys [ i ] <nl> - period . share = ! period . buys | | period . total_eth . equals ( 0 ) <nl> - ? web3 . toBigNumber ( 0 ) <nl> - : period . tokens_available . div ( period . total_eth ) . times ( period . buys ) <nl> - period . claimed = claims & & claims [ i ] <nl> - return period <nl> - } ) <nl> - <nl> - return web3 <nl> - . toBigNumber ( periods <nl> - / / Get periods by unclaimed and lte last block <nl> - . filter ( ( period , i ) = > { return i < = period_for ( SS_LAST_BLOCK_TIME ) & & ! period . claimed } ) <nl> - / / Sum the pre - calculated EOS balance of each resulting period <nl> - . reduce ( ( sum , period ) = > period . share . plus ( sum ) , web3 . toBigNumber ( 0 ) ) <nl> - ) <nl> - } <nl> - <nl> - / / Some users mistakenly sent their tokens to the contract or token address . Here we recover them if it is the case . <nl> - const maybe_reclaim_tokens = ( registrant ) = > { <nl> - let reclaimed_balance = web3 . toBigNumber ( 0 ) <nl> - let reclaimable_transactions = get_registrant_reclaimable ( registrant . eth ) <nl> - if ( reclaimable_transactions . length ) { <nl> - for ( let tx of reclaimable_transactions ) { <nl> - reclaimed_balance = tx . amount . plus ( reclaimed_balance ) <nl> - tx . eos = registrant . eos <nl> - tx . claim ( registrant . eth ) <nl> - } <nl> - if ( reclaimable_transactions . length > 1 ) <nl> - log ( " info " , ` Reclaimed $ { reclaimed_balance . div ( WAD ) . toFormat ( 4 ) } EOS from $ { reclaimable_transactions . length } tx for $ { registrant . eth } = > $ { registrant . eos } ` ) <nl> - } <nl> - return reclaimed_balance <nl> - } <nl> - <nl> - const status_log = ( ) = > { <nl> - if ( index % UI_SHOW_STATUS_EVERY = = 0 & & index ! = 0 ) debug . refresh ( ) , <nl> - console . group ( " Snapshot Status " ) , <nl> - log ( " success " , ` Progress : $ { debug . rates . percent_complete } % ` ) , <nl> - log ( " success " , ` mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm ` ) , <nl> - log ( " success " , ` Unclaimed : EOS $ { debug . distribution . $ balance_unclaimed . toFormat ( 4 ) } ` ) , <nl> - log ( " success " , ` In Wallets : EOS $ { debug . distribution . $ balance_wallets . toFormat ( 4 ) } ` ) , <nl> - log ( " success " , ` Reclaimed : EOS $ { debug . distribution . $ balance_reclaimed . toFormat ( 4 ) } ` ) , <nl> - log ( " success " , ` Total : EOS $ { debug . distribution . $ balances_found . toFormat ( 4 ) } ` ) , <nl> - log ( " error " , ` Rejected : EOS $ { debug . rejected . $ total . toFormat ( 4 ) } ` ) , <nl> - log ( " error " , ` Reclaimable : EOS $ { debug . distribution . $ balance_reclaimable . toFormat ( 4 ) } ` ) , <nl> - log ( " error " , ` Not Included : EOS $ { debug . distribution . $ balances_missing . toFormat ( 4 ) } ` ) , <nl> - console . groupEnd ( ) <nl> - } <nl> - <nl> - iterate ( ) <nl> - <nl> - } <nl> - <nl> - / / Crowdsale contract didnt store registrants in an array , so we need to scrap LogRegister using a polling function : / <nl> - <nl> - / / Builds Registrants List <nl> - const scan_registry = ( on_complete ) = > { <nl> - <nl> - console . group ( ' EOS Registrant List ' ) <nl> - <nl> - let registry_logs = [ ] ; <nl> - let message_freq = 10000 ; <nl> - let last_message = Date . now ( ) ; <nl> - <nl> - let group_index = 1 ; <nl> - <nl> - const on_result = ( log_register ) = > { <nl> - / / Since this is a watcher , we need to be sure the result isn ' t new . <nl> - if ( log_register . blockNumber < = SS_LAST_BLOCK ) { <nl> - <nl> - / / check that registrant isn ' t already in array <nl> - if ( ! registrants . filter ( registrant = > { return registrant . eth = = log_register . args . user } ) . length ) { <nl> - <nl> - let registrant = new Registrant ( log_register . args . user ) <nl> - registrants . push ( registrant ) <nl> - <nl> - / / Add the register transaction to transactions array , may be unnecessary . <nl> - / / let tx = new Transaction ( registrant . eth , log_register . transactionHash , ' register ' , web3 . toBigNumber ( 0 ) ) <nl> - / / transactions . push ( tx ) <nl> - <nl> - registry_logs . push ( ` $ { registrant . eth } = > $ { log_register . args . key } ( pending ) = > https : / / etherscan . io / tx / $ { log_register . transactionHash } ` ) <nl> - <nl> - / / now all your snowflakes are urine . . . <nl> - maybe_log ( ) <nl> - } <nl> - } <nl> - } <nl> - <nl> - const on_success = ( ) = > { <nl> - debug . refresh ( ) , <nl> - log_group ( ) , <nl> - console . groupEnd ( ) , <nl> - log ( " block " , ` $ { registrants . length } Total Registrants ` ) , <nl> - { found : Object . keys ( registrants ) . length } <nl> - } <nl> - <nl> - const on_error = ( ) = > " Web3 ' s watcher misbehaved while chugging along in the registry " <nl> - <nl> - let maybe_log = ( ) = > ( Date . now ( ) - message_freq > last_message ) ? ( log_group ( ) , true ) : false <nl> - <nl> - / / . . . and you can ’ t even find the cat . <nl> - let log_group = ( ) = > { <nl> - let group_msg = ` $ { group_index } . . . . $ { registry_logs . length } Found , Total : $ { registrants . length } ` ; <nl> - log ( " groupCollapsed " , group_msg ) , <nl> - ( OUTPUT_LOGGING ? output . logs . push ( group_msg ) : null ) , <nl> - registry_logs . forEach ( _log = > { <nl> - if ( VERBOSE_REGISTRY_LOGS ) log ( " message " , _log ) <nl> - if ( OUTPUT_LOGGING ) output . logs . push ( _log ) <nl> - } ) , <nl> - registry_logs = [ ] , <nl> - console . groupEnd ( ) , <nl> - group_index + + , <nl> - last_message = Date . now ( ) <nl> - } <nl> - <nl> - let async_watcher = LogWatcher ( SS_FIRST_BLOCK , SS_LAST_BLOCK , contract . $ crowdsale . LogRegister , null , on_complete , on_result , on_success , on_error , 2500 , 5000 ) <nl> - } <nl> - <nl> - <nl> - / / Builds list of EOS tokens sent to EOS crowdsale or token contract . <nl> - <nl> - const find_reclaimables = ( on_complete ) = > { <nl> - log ( ' group ' , ' Finding Reclaimable EOS Tokens ' ) <nl> - let index = 0 ; <nl> - const query = { to : [ ' 0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0 ' , ' 0xd0a6E6C54DbC68Db5db3A091B171A77407Ff7ccf ' ] } <nl> - <nl> - const on_result = ( reclaimable_tx ) = > { <nl> - if ( reclaimable_tx . blockNumber < = SS_LAST_BLOCK & & reclaimable_tx . args . value . gt ( web3 . toBigNumber ( 0 ) ) ) { <nl> - let tx = new Transaction ( reclaimable_tx . args . from , reclaimable_tx . transactionHash , ' transfer ' , reclaimable_tx . args . value ) <nl> - transactions . push ( tx ) <nl> - log ( " error " , ` $ { tx . eth } = > $ { web3 . toBigNumber ( tx . amount ) . div ( WAD ) } https : / / etherscan . io / tx / $ { tx . hash } ` ) <nl> - } <nl> - } <nl> - <nl> - const on_success = ( ) = > { <nl> - let result_total = get_transactions_reclaimable ( ) . length <nl> - debug . refresh ( ) , <nl> - console . groupEnd ( ) , <nl> - log ( " block " , ` $ { result_total | | 0 } reclaimable transactions found ` ) , <nl> - { found : result_total } <nl> - } <nl> - <nl> - const on_error = ( ) = > " Something bad happened while finding reclaimables " <nl> - <nl> - let async_watcher = LogWatcher ( SS_FIRST_BLOCK , SS_LAST_BLOCK , contract . $ token . Transfer , query , on_complete , on_result , on_success , on_error , 500 , 5000 ) <nl> - <nl> - } <nl> - <nl> - const verify = ( callback ) = > { <nl> - let valid = true ; <nl> - if ( ! [ . . . new Set ( get_registrants_accepted ( ) . map ( registrant = > registrant . eth ) ) ] . length = = get_registrants_accepted ( ) . length ) log ( " error " , ' Duplicate Entry Found ' ) , valid = false <nl> - return ( valid ) ? callback ( null , valid ) & & true : callback ( true ) & & false <nl> - } <nl> - <nl> - const exporter = ( callback ) = > { <nl> - if ( typeof console . time = = = ' function ' ) console . time ( ' Compiled Data to Output Arrays ' ) <nl> - <nl> - output . reclaimable = get_transactions_reclaimable ( ) . map ( tx = > { return { eth : tx . eth , tx : tx . hash , amount : formatEOS ( web3 . toBigNumber ( tx . amount ) . div ( WAD ) ) } } ) <nl> - output . reclaimed = get_transactions_reclaimed ( ) . map ( tx = > { return { eth : tx . eth , eos : tx . eos , tx : tx . hash , amount : formatEOS ( web3 . toBigNumber ( tx . amount ) . div ( WAD ) ) } } ) <nl> - output . snapshot = get_registrants_accepted ( ) . map ( registrant = > { return { eth : registrant . eth , eos : registrant . eos , balance : formatEOS ( registrant . balance . total ) } } ) <nl> - output . rejects = get_registrants_rejected ( ) . map ( registrant = > { return { error : registrant . error , eth : registrant . eth , eos : registrant . eos , balance : formatEOS ( registrant . balance . total ) } } ) <nl> - <nl> - if ( typeof console . timeEnd = = = ' function ' ) console . timeEnd ( ' Compiled Data to Output Arrays ' ) <nl> - <nl> - callback ( null , true ) <nl> - } <nl> \ No newline at end of file <nl>
|
remove lingering snapshot files
|
EOSIO/eos
|
b0cad23b4152cb6aef496b583835bd2fbf3a5c10
|
2017-09-03T09:20:21Z
|
deleted file mode 100644 <nl> index 7c687f6581aee . . 0000000000000 <nl> mmm a / tensorflow / core / kernels / mkl_conv_grad_bias_ops . cc <nl> ppp / dev / null <nl> <nl> - / * Copyright 2015 The TensorFlow Authors . All Rights Reserved . <nl> - <nl> - Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> - you may not use this file except in compliance with the License . <nl> - You may obtain a copy of the License at <nl> - <nl> - http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> - <nl> - Unless required by applicable law or agreed to in writing , software <nl> - distributed under the License is distributed on an " AS IS " BASIS , <nl> - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> - See the License for the specific language governing permissions and <nl> - limitations under the License . <nl> - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> - <nl> - / / See docs in . . / ops / nn_ops . cc . This opkernel uses MKL library , create MKL <nl> - / / layout and primitives , use MKL dnn primitives to compute convolution backward <nl> - / / bias . <nl> - <nl> - # ifdef INTEL_MKL <nl> - # ifdef INTEL_MKL_ML_ONLY <nl> - <nl> - # define USE_EIGEN_TENSOR <nl> - # define EIGEN_USE_THREADS <nl> - <nl> - # include " tensorflow / core / framework / numeric_op . h " <nl> - # include " tensorflow / core / framework / op_kernel . h " <nl> - # include " tensorflow / core / framework / register_types . h " <nl> - # include " tensorflow / core / framework / tensor . h " <nl> - # include " tensorflow / core / framework / tensor_shape . h " <nl> - # include " tensorflow / core / framework / tensor_slice . h " <nl> - # include " tensorflow / core / kernels / ops_util . h " <nl> - # include " tensorflow / core / lib / core / errors . h " <nl> - # include " tensorflow / core / lib / gtl / array_slice . h " <nl> - # include " tensorflow / core / platform / logging . h " <nl> - # include " tensorflow / core / platform / macros . h " <nl> - # include " tensorflow / core / util / padding . h " <nl> - # include " tensorflow / core / util / tensor_format . h " <nl> - # include " tensorflow / core / util / use_cudnn . h " <nl> - # include " tensorflow / core / util / work_sharder . h " <nl> - <nl> - # ifdef INTEL_MKL_ML_ONLY <nl> - # include " mkl_dnn . h " <nl> - # include " mkl_dnn_types . h " <nl> - # endif <nl> - # include " tensorflow / core / util / mkl_util . h " <nl> - <nl> - namespace tensorflow { <nl> - <nl> - typedef Eigen : : ThreadPoolDevice CPUDevice ; <nl> - <nl> - template < typename Device , class T > <nl> - class MklConv2DCustomBackpropBiasOp : public OpKernel { <nl> - public : <nl> - explicit MklConv2DCustomBackpropBiasOp ( OpKernelConstruction * context ) <nl> - : OpKernel ( context ) { <nl> - string data_format ; <nl> - OP_REQUIRES_OK ( context , context - > GetAttr ( " data_format " , & data_format ) ) ; <nl> - OP_REQUIRES ( context , FormatFromString ( data_format , & data_format_ ) , <nl> - errors : : InvalidArgument ( " Invalid data format " ) ) ; <nl> - } <nl> - ~ MklConv2DCustomBackpropBiasOp ( ) { } <nl> - <nl> - void Compute ( OpKernelContext * context ) override { <nl> - MklConvBackBiasOpContext mkl_context ; <nl> - const Tensor & input = MklGetInput ( context , 0 ) ; <nl> - GetMklShape ( context , 0 , & mkl_context . input_shape ) ; <nl> - bool input_is_mkl = mkl_context . input_shape . IsMklTensor ( ) ; <nl> - <nl> - if ( input_is_mkl ) { <nl> - OP_REQUIRES ( <nl> - context , mkl_context . input_shape . GetDimension ( ) = = 4 , <nl> - errors : : InvalidArgument ( " Input tensor must be 4 - dimensional " ) ) ; <nl> - } else { <nl> - OP_REQUIRES ( context , input . dims ( ) = = 4 , <nl> - errors : : InvalidArgument ( " input must be 4 - dimensional " , <nl> - input . shape ( ) . DebugString ( ) ) ) ; <nl> - } <nl> - <nl> - if ( input_is_mkl ) { <nl> - mkl_context . c_size = mkl_context . input_shape . GetSizes ( ) [ MklDims : : C ] ; <nl> - } else if ( data_format_ = = FORMAT_NHWC | | data_format_ = = FORMAT_NCHW ) { <nl> - mkl_context . c_size = GetTensorDim ( input , data_format_ , ' C ' ) ; <nl> - } else { <nl> - context - > CtxFailure ( errors : : InvalidArgument ( <nl> - " Unknown format " , " Format must be either NCHW or NHWC . " ) ) ; <nl> - return ; <nl> - } <nl> - TensorShape output_shape { mkl_context . c_size } ; <nl> - <nl> - Tensor * bias_backprop = nullptr ; <nl> - MklShape output_mkl_shape ; <nl> - output_mkl_shape . SetMklTensor ( false ) ; <nl> - AllocateOutputSetMklShape ( context , 0 , & bias_backprop , output_shape , <nl> - output_mkl_shape ) ; <nl> - <nl> - mkl_context . in_dims = 4 ; <nl> - <nl> - if ( input_is_mkl ) { / / get the shape from the mkl shape <nl> - mkl_context . in_sizes [ MklDims : : W ] = <nl> - mkl_context . input_shape . GetSizes ( ) [ MklDims : : W ] ; <nl> - mkl_context . in_sizes [ MklDims : : H ] = <nl> - mkl_context . input_shape . GetSizes ( ) [ MklDims : : H ] ; <nl> - mkl_context . in_sizes [ MklDims : : C ] = <nl> - mkl_context . input_shape . GetSizes ( ) [ MklDims : : C ] ; <nl> - mkl_context . in_sizes [ MklDims : : N ] = <nl> - mkl_context . input_shape . GetSizes ( ) [ MklDims : : N ] ; <nl> - } else { <nl> - mkl_context . in_sizes [ MklDims : : W ] = GetTensorDim ( input , data_format_ , ' W ' ) ; <nl> - mkl_context . in_sizes [ MklDims : : H ] = GetTensorDim ( input , data_format_ , ' H ' ) ; <nl> - mkl_context . in_sizes [ MklDims : : C ] = GetTensorDim ( input , data_format_ , ' C ' ) ; <nl> - mkl_context . in_sizes [ MklDims : : N ] = GetTensorDim ( input , data_format_ , ' N ' ) ; <nl> - GetStridesFromSizes ( data_format_ , mkl_context . in_strides , <nl> - mkl_context . in_sizes ) ; <nl> - } <nl> - <nl> - mkl_context . out_sizes [ 0 ] = mkl_context . c_size ; <nl> - mkl_context . out_strides [ 0 ] = 1 ; <nl> - <nl> - CHECK_EQ ( <nl> - dnnConvolutionCreateBackwardBias_F32 ( <nl> - & mkl_context . prim_conv_bwdbias , NULL , dnnAlgorithmConvolutionDirect , <nl> - mkl_context . in_dims , mkl_context . in_sizes ) , <nl> - E_SUCCESS ) ; <nl> - <nl> - mkl_context . MklCreateInputLayouts ( context ) ; <nl> - <nl> - Tensor mkl_tmp_input_buf , mkl_tmp_outbackprop_buf ; <nl> - mkl_context . MklPrepareConvolutionInputs ( context , & mkl_tmp_input_buf ) ; <nl> - mkl_context . MklPrepareConvolutionOutputs ( context , & mkl_tmp_outbackprop_buf , <nl> - bias_backprop ) ; <nl> - <nl> - CHECK_EQ ( <nl> - dnnExecute_F32 ( mkl_context . prim_conv_bwdbias , mkl_context . conv_res ) , <nl> - E_SUCCESS ) ; <nl> - if ( mkl_context . should_convert_output ) { <nl> - CHECK_EQ ( dnnConversionExecute_F32 ( <nl> - mkl_context . convert_outbackprop , mkl_context . outbackprop_buf , <nl> - static_cast < void * > ( bias_backprop - > flat < T > ( ) . data ( ) ) ) , <nl> - E_SUCCESS ) ; <nl> - } <nl> - / / deletes layouts <nl> - mkl_context . MklCleanup ( ) ; <nl> - } <nl> - <nl> - private : <nl> - typedef struct { <nl> - int in_dims ; <nl> - int c_size ; <nl> - size_t in_sizes [ 4 ] ; <nl> - size_t in_strides [ 4 ] ; <nl> - size_t out_sizes [ 1 ] ; <nl> - size_t out_strides [ 1 ] ; <nl> - size_t filter_sizes [ 4 ] ; <nl> - size_t filter_strides [ 4 ] ; <nl> - int input_offset [ 2 ] ; <nl> - size_t conv_stride [ 2 ] ; <nl> - MklShape input_shape ; <nl> - dnnPrimitive_t prim_conv_bwdbias ; <nl> - void * conv_res [ dnnResourceNumber ] ; <nl> - dnnLayout_t lt_input , lt_outbackprop ; <nl> - bool should_convert_output ; <nl> - dnnPrimitive_t convert_outbackprop ; <nl> - void * outbackprop_buf ; <nl> - <nl> - / / Create MKL dnnLayout_t objects for tensors coming into the layer <nl> - void MklCreateInputLayouts ( OpKernelContext * context ) { <nl> - bool input_is_mkl = input_shape . IsMklTensor ( ) ; <nl> - <nl> - CHECK_EQ ( dnnLayoutCreate_F32 ( & lt_outbackprop , 1 , out_sizes , out_strides ) , <nl> - E_SUCCESS ) ; <nl> - if ( input_is_mkl ) { <nl> - lt_input = static_cast < dnnLayout_t > ( input_shape . GetCurLayout ( ) ) ; <nl> - } else { <nl> - CHECK_EQ ( dnnLayoutCreate_F32 ( & lt_input , in_dims , in_sizes , in_strides ) , <nl> - E_SUCCESS ) ; <nl> - } <nl> - } <nl> - <nl> - / / Compare incoming output tensor layouts with MKL preferred layouts and <nl> - / / convert data to the preferred layout if necessary <nl> - void MklPrepareConvolutionOutputs ( OpKernelContext * context , <nl> - Tensor * mkl_tmp_outbackprop_buf , <nl> - Tensor * bias_backprop ) { <nl> - dnnLayout_t mkl_prim_internal_outbackprop = nullptr ; <nl> - CHECK_EQ ( dnnLayoutCreateFromPrimitive_F32 ( & mkl_prim_internal_outbackprop , <nl> - prim_conv_bwdbias , <nl> - dnnResourceDiffBias ) , <nl> - E_SUCCESS ) ; <nl> - should_convert_output = <nl> - ! dnnLayoutCompare_F32 ( lt_outbackprop , mkl_prim_internal_outbackprop ) ; <nl> - if ( should_convert_output ) { <nl> - CHECK_EQ ( dnnConversionCreate_F32 ( & convert_outbackprop , <nl> - mkl_prim_internal_outbackprop , <nl> - lt_outbackprop ) , <nl> - E_SUCCESS ) ; <nl> - AllocTmpBuffer ( context , mkl_tmp_outbackprop_buf , <nl> - mkl_prim_internal_outbackprop , & outbackprop_buf ) ; <nl> - conv_res [ dnnResourceDiffBias ] = outbackprop_buf ; <nl> - } else { <nl> - conv_res [ dnnResourceDiffBias ] = <nl> - static_cast < void * > ( const_cast < T * > ( bias_backprop - > flat < T > ( ) . data ( ) ) ) ; <nl> - } <nl> - <nl> - dnnLayoutDelete_F32 ( mkl_prim_internal_outbackprop ) ; <nl> - } <nl> - <nl> - / / Compare incoming input tensor layouts with MKL preferred layouts and <nl> - / / convert data to the preferred layout if necessary <nl> - void MklPrepareConvolutionInputs ( OpKernelContext * context , <nl> - Tensor * mkl_tmp_input_buf ) { <nl> - dnnLayout_t mkl_prim_internal_input = nullptr ; <nl> - dnnPrimitive_t mkl_convert_input = nullptr ; <nl> - void * input_buf = nullptr ; <nl> - const Tensor & input = MklGetInput ( context , 0 ) ; <nl> - <nl> - CHECK_EQ ( <nl> - dnnLayoutCreateFromPrimitive_F32 ( <nl> - & mkl_prim_internal_input , prim_conv_bwdbias , dnnResourceDiffDst ) , <nl> - E_SUCCESS ) ; <nl> - <nl> - if ( ! dnnLayoutCompare_F32 ( lt_input , mkl_prim_internal_input ) ) { <nl> - CHECK_EQ ( dnnConversionCreate_F32 ( & mkl_convert_input , lt_input , <nl> - mkl_prim_internal_input ) , <nl> - E_SUCCESS ) ; <nl> - AllocTmpBuffer ( context , mkl_tmp_input_buf , mkl_prim_internal_input , <nl> - & input_buf ) ; <nl> - CHECK_EQ ( dnnConversionExecute_F32 ( <nl> - mkl_convert_input , <nl> - static_cast < void * > ( const_cast < T * > ( input . flat < T > ( ) . data ( ) ) ) , <nl> - input_buf ) , <nl> - E_SUCCESS ) ; <nl> - conv_res [ dnnResourceDiffDst ] = input_buf ; <nl> - dnnDelete_F32 ( mkl_convert_input ) ; <nl> - } else { <nl> - conv_res [ dnnResourceDiffDst ] = <nl> - static_cast < void * > ( const_cast < T * > ( input . flat < T > ( ) . data ( ) ) ) ; <nl> - } <nl> - <nl> - dnnLayoutDelete_F32 ( mkl_prim_internal_input ) ; <nl> - } <nl> - <nl> - / / Cleanup member layouts and primitives <nl> - void MklCleanup ( ) { <nl> - bool input_is_mkl = input_shape . IsMklTensor ( ) ; <nl> - if ( ! input_is_mkl ) dnnLayoutDelete_F32 ( lt_input ) ; <nl> - dnnLayoutDelete_F32 ( lt_outbackprop ) ; <nl> - <nl> - if ( should_convert_output ) dnnDelete_F32 ( convert_outbackprop ) ; <nl> - dnnDelete_F32 ( prim_conv_bwdbias ) ; <nl> - } <nl> - } MklConvBackBiasOpContext ; <nl> - <nl> - TensorFormat data_format_ ; <nl> - TF_DISALLOW_COPY_AND_ASSIGN ( MklConv2DCustomBackpropBiasOp ) ; <nl> - } ; <nl> - <nl> - # define REGISTER_CPU_KERNELS ( T ) \ <nl> - REGISTER_KERNEL_BUILDER ( Name ( " _MklConv2DWithBiasBackpropBias " ) \ <nl> - . Device ( DEVICE_CPU ) \ <nl> - . TypeConstraint < T > ( " T " ) \ <nl> - . Label ( mkl_op_registry : : kMklOpLabel ) , \ <nl> - MklConv2DCustomBackpropBiasOp < CPUDevice , T > ) ; <nl> - <nl> - TF_CALL_float ( REGISTER_CPU_KERNELS ) ; <nl> - # undef REGISTER_CPU_KERNELS <nl> - } / * namespace tensorflow * / <nl> - # endif / * INTEL_MKL_ML_ONLY * / <nl> - # endif / * INTEL_MKL * / <nl>
|
Remove mkl_conv_grad_bias_ops . cc which has MKL ML impl . only
|
tensorflow/tensorflow
|
da3e12e51a9e69653b7c8e944a359427662ef3c7
|
2019-05-24T21:18:09Z
|
mmm a / buildscripts / burn_in_tests . py <nl> ppp b / buildscripts / burn_in_tests . py <nl> def parse_command_line ( ) : <nl> check_evergreen = False , <nl> evergreen_file = " etc / evergreen . yml " , <nl> selector_file = " etc / burn_in_tests . yml " , <nl> - executor_file = " with_server " , <nl> max_revisions = 25 , <nl> no_exec = False , <nl> report_file = " report . json " , <nl> - suite_files = None , <nl> + suite_files = " with_server " , <nl> test_list_file = None , <nl> test_list_outfile = None ) <nl> <nl> def find_changed_tests ( branch_name , base_commit , max_revisions , buildvariant , ch <nl> # The lines with untracked files start with ' ? ? ' . <nl> for line in untracked_files : <nl> if line . startswith ( " ? " ) : <nl> - ( status , line ) = line . split ( " " ) <nl> + ( status , line ) = line . split ( " " , 1 ) <nl> changed_files . append ( line ) <nl> <nl> for line in changed_files : <nl> def create_task_list ( evergreen_file , buildvariant , suites , exclude_tasks ) : <nl> # function . This allows the storage engine to be overridden . <nl> task_arg = " { } { } " . format ( task_arg , test_flags ) <nl> # Find the resmoke_args for matching suite names . <nl> - # Change the - - suites to - - executor <nl> - if ( re . compile ( ' - - suites = ' + suite + ' ( ? : \ s + | $ ) ' ) . match ( task_arg ) or <nl> - re . compile ( ' - - executor = ' + suite + ' ( ? : \ s + | $ ) ' ) . match ( task_arg ) ) : <nl> + if ( re . compile ( ' - - suites = ' + suite + ' ( ? : \ s + | $ ) ' ) . match ( task_arg ) ) : <nl> tasks_to_run [ task_name ] = { <nl> - " resmoke_args " : task_arg . replace ( " - - suites " , " - - executor " ) , <nl> - " tests " : suites [ suite ] } <nl> + " resmoke_args " : task_arg , <nl> + " tests " : suites [ suite ] <nl> + } <nl> <nl> return tasks_to_run <nl> <nl> def _save_report_data ( saved_data , pathname , task ) : <nl> <nl> <nl> def main ( ) : <nl> - values = collections . defaultdict ( list ) <nl> values , args = parse_command_line ( ) <nl> <nl> # If a resmoke . py command wasn ' t passed in , use a simple version . <nl> mmm a / buildscripts / resmokelib / config . py <nl> ppp b / buildscripts / resmokelib / config . py <nl> <nl> DEFAULT_INTEGRATION_TEST_LIST , <nl> DEFAULT_DBTEST_EXECUTABLE ] <nl> <nl> - # This is used internally to store the executor name that is passed on the command line . <nl> - # Specifically it ' s used to record in the logs which executor a test is being run under . <nl> - INTERNAL_EXECUTOR_NAME = None <nl> mmm a / buildscripts / resmokelib / parser . py <nl> ppp b / buildscripts / resmokelib / parser . py <nl> def parse_command_line ( ) : <nl> help = ( " Comma separated list of YAML files that each specify the configuration " <nl> " of a suite . If the file is located in the resmokeconfig / suites / " <nl> " directory , then the basename without the . yml extension can be " <nl> - " specified , e . g . ' core ' . " ) ) <nl> - <nl> - parser . add_option ( " - - executor " , dest = " executor_file " , metavar = " EXECUTOR " , <nl> - help = ( " A YAML file that specifies the executor configuration . If the file is " <nl> - " located in the resmokeconfig / suites / directory , then the basename " <nl> - " without the . yml extension can be specified , e . g . ' core_small_oplog ' . " <nl> - " If specified in combination with the - - suites option , then the suite " <nl> - " configuration takes precedence . " ) ) <nl> + " specified , e . g . ' core ' . If a list of files is passed in as " <nl> + " positional arguments , they will be run using the suites ' " <nl> + " configurations " ) ) <nl> <nl> parser . add_option ( " - - log " , dest = " logger_file " , metavar = " LOGGER " , <nl> help = ( " A YAML file that specifies the logging configuration . If the file is " <nl> def parse_command_line ( ) : <nl> parser . add_option ( " - - wiredTigerIndexConfigString " , dest = " wt_index_config " , metavar = " CONFIG " , <nl> help = " Set the WiredTiger index configuration setting for all mongod ' s . " ) <nl> <nl> - parser . set_defaults ( executor_file = " with_server " , <nl> - logger_file = " console " , <nl> + parser . add_option ( " - - executor " , dest = " executor_file " , <nl> + help = " OBSOLETE : Superceded by - - suites ; specify - - suites = SUITE path / to / test " <nl> + " to run a particular test under a particular suite configuration . " ) <nl> + <nl> + parser . set_defaults ( logger_file = " console " , <nl> dry_run = " off " , <nl> find_suites = False , <nl> list_suites = False , <nl> + suite_files = " with_server " , <nl> prealloc_journal = " off " , <nl> shuffle = " auto " , <nl> stagger_jobs = " off " ) <nl> def create_test_membership_map ( fail_on_missing_selector = False , test_kind = None ) : <nl> <nl> <nl> def get_suites ( values , args ) : <nl> - if ( values . suite_files is None and not args ) or ( values . suite_files is not None and args ) : <nl> - raise optparse . OptionValueError ( " Must specify either - - suites or a list of tests " ) <nl> - <nl> - _config . INTERNAL_EXECUTOR_NAME = values . executor_file <nl> + if values . executor_file : <nl> + raise optparse . OptionError ( <nl> + " superceded by - - suites ; specify - - suites = { } { } to run the test ( s ) under those suite " <nl> + " configuration ( s ) " . format ( values . executor_file , " " . join ( args ) ) , " - - executor " ) <nl> <nl> - # If there are no suites specified , but args , collect the specified files . <nl> + suite_roots = None <nl> if args : <nl> # Do not change the execution order of the tests passed as args , unless a tag option is <nl> # specified . If an option is specified , then sort the tests for consistent execution order . <nl> _config . ORDER_TESTS_BY_NAME = any ( tag_filter is not None for <nl> tag_filter in ( _config . EXCLUDE_WITH_ANY_TAGS , <nl> _config . INCLUDE_WITH_ANY_TAGS ) ) <nl> - # No specified config , just use the following , and default the logging and executor . <nl> - suite_config = _make_config ( args ) <nl> - _ensure_executor ( suite_config , values . executor_file ) <nl> - # The test_kind comes from the executor file . <nl> - _ensure_test_kind ( suite_config , <nl> - _get_yaml_config ( " executor " , values . executor_file ) , <nl> - values . executor_file ) <nl> - suite = testing . suite . Suite ( " < % s > " % suite_config [ " test_kind " ] , suite_config ) <nl> - return [ suite ] <nl> + # Build configuration for list of files to run . <nl> + suite_roots = _get_suite_roots ( args ) <nl> + <nl> <nl> suite_files = values . suite_files . split ( " , " ) <nl> <nl> suites = [ ] <nl> for suite_filename in suite_files : <nl> suite_config = _get_suite_config ( suite_filename ) <nl> - _ensure_executor ( suite_config , values . executor_file ) <nl> + if suite_roots : <nl> + # Override the suite ' s default test files with those passed in from the command line . <nl> + suite_config . update ( suite_roots ) <nl> suite = testing . suite . Suite ( suite_filename , suite_config ) <nl> suites . append ( suite ) <nl> return suites <nl> def _get_suite_config ( pathname ) : <nl> return _get_yaml_config ( " suite " , pathname ) <nl> <nl> <nl> - def _make_config ( files ) : <nl> + def _get_suite_roots ( files ) : <nl> return { " selector " : { " roots " : files } } <nl> <nl> <nl> def _get_yaml_config ( kind , pathname ) : <nl> return utils . load_yaml_file ( pathname ) <nl> <nl> <nl> - def _ensure_executor ( suite_config , pathname ) : <nl> - if " executor " not in suite_config : <nl> - # Named executors are specified as the basename of the file , without the . yml extension . <nl> - suite_config [ " executor " ] = _get_yaml_config ( " executor " , pathname ) . pop ( " executor " ) <nl> - <nl> - <nl> def _expand_user ( pathname ) : <nl> " " " <nl> Wrapper around os . path . expanduser ( ) to do nothing when given None . <nl> mmm a / buildscripts / resmokelib / testing / testcases / interface . py <nl> ppp b / buildscripts / resmokelib / testing / testcases / interface . py <nl> def _execute ( self , process ) : <nl> " " " <nl> Runs the specified process . <nl> " " " <nl> - <nl> - if config . INTERNAL_EXECUTOR_NAME is not None : <nl> - self . logger . info ( " Starting % s under executor % s . . . \ n % s " , <nl> - self . shortDescription ( ) , <nl> - config . INTERNAL_EXECUTOR_NAME , <nl> - process . as_command ( ) ) <nl> - else : <nl> - self . logger . info ( " Starting % s . . . \ n % s " , self . shortDescription ( ) , process . as_command ( ) ) <nl> + self . logger . info ( " Starting % s . . . \ n % s " , self . shortDescription ( ) , process . as_command ( ) ) <nl> <nl> process . start ( ) <nl> self . logger . info ( " % s started with pid % s . " , self . shortDescription ( ) , process . pid ) <nl> mmm a / etc / evergreen . yml <nl> ppp b / etc / evergreen . yml <nl> tasks : <nl> - func : " run tests " <nl> timeout_secs : 21600 # 6 hour timeout <nl> vars : <nl> - resmoke_args : - - executor = concurrency jstests / concurrency / fsm_all_simultaneous . js - - storageEngine = mmapv1 <nl> + resmoke_args : - - suites = concurrency jstests / concurrency / fsm_all_simultaneous . js - - storageEngine = mmapv1 <nl> <nl> - < < : * task_template <nl> name : concurrency_simultaneous_WT <nl> tasks : <nl> - func : " run tests " <nl> timeout_secs : 21600 # 6 hour timeout <nl> vars : <nl> - resmoke_args : - - executor = concurrency jstests / concurrency / fsm_all_simultaneous . js - - storageEngine = wiredTiger <nl> + resmoke_args : - - suites = concurrency jstests / concurrency / fsm_all_simultaneous . js - - storageEngine = wiredTiger <nl> <nl> - < < : * task_template <nl> name : rlp <nl>
|
SERVER - 28636 replace - - executor with - - suite in resmoke . py
|
mongodb/mongo
|
4d8d1745c9430b7aeb167e4249b639b73b50e07f
|
2017-06-22T22:29:34Z
|
mmm a / modules / perception / fusion / lib / data_fusion / existance_fusion / dst_existance_fusion / proto / BUILD . txt <nl> ppp b / modules / perception / fusion / lib / data_fusion / existance_fusion / dst_existance_fusion / proto / BUILD . txt <nl> load ( " / / tools : cpplint . bzl " , " cpplint " ) <nl> package ( default_visibility = [ " / / visibility : public " ] ) <nl> <nl> cc_proto_library ( <nl> - name = " dst_existance_fusion_config_poto " , <nl> + name = " dst_existance_fusion_config_proto " , <nl> deps = [ <nl> " : dst_existance_fusion_config_proto_lib " , <nl> ] , <nl> ) <nl> <nl> proto_library ( <nl> - name = " dst_existance_fusion_config_poto_lib " , <nl> + name = " dst_existance_fusion_config_proto_lib " , <nl> srcs = [ <nl> " dst_existance_fusion_config . proto " , <nl> ] , <nl> mmm a / modules / perception / fusion / lib / data_fusion / tracker / pbf_tracker / proto / BUILD . txt <nl> ppp b / modules / perception / fusion / lib / data_fusion / tracker / pbf_tracker / proto / BUILD . txt <nl> load ( " / / tools : cpplint . bzl " , " cpplint " ) <nl> package ( default_visibility = [ " / / visibility : public " ] ) <nl> <nl> cc_proto_library ( <nl> - name = " pbf_tracker_config_poto " , <nl> + name = " pbf_tracker_config_proto " , <nl> deps = [ <nl> " : pbf_tracker_config_proto_lib " , <nl> ] , <nl> ) <nl> <nl> proto_library ( <nl> - name = " pbf_tracker_config_poto_lib " , <nl> + name = " pbf_tracker_config_proto_lib " , <nl> srcs = [ <nl> " pbf_tracker_config . proto " , <nl> ] , <nl> mmm a / modules / perception / fusion / lib / data_fusion / type_fusion / dst_type_fusion / proto / BUILD . txt <nl> ppp b / modules / perception / fusion / lib / data_fusion / type_fusion / dst_type_fusion / proto / BUILD . txt <nl> load ( " / / tools : cpplint . bzl " , " cpplint " ) <nl> package ( default_visibility = [ " / / visibility : public " ] ) <nl> <nl> cc_proto_library ( <nl> - name = " dst_type_fusion_config_poto " , <nl> + name = " dst_type_fusion_config_proto " , <nl> deps = [ <nl> " : dst_type_fusion_config_proto_lib " , <nl> ] , <nl> ) <nl> <nl> proto_library ( <nl> - name = " dst_type_fusion_config_poto_lib " , <nl> + name = " dst_type_fusion_config_proto_lib " , <nl> srcs = [ <nl> " dst_type_fusion_config . proto " , <nl> ] , <nl> mmm a / modules / perception / fusion / lib / fusion_system / probabilistic_fusion / proto / BUILD . txt <nl> ppp b / modules / perception / fusion / lib / fusion_system / probabilistic_fusion / proto / BUILD . txt <nl> load ( " / / tools : cpplint . bzl " , " cpplint " ) <nl> package ( default_visibility = [ " / / visibility : public " ] ) <nl> <nl> cc_proto_library ( <nl> - name = " probabilistic_fusion_config_poto " , <nl> + name = " probabilistic_fusion_config_proto " , <nl> deps = [ <nl> " : probabilistic_fusion_config_proto_lib " , <nl> ] , <nl> ) <nl> <nl> proto_library ( <nl> - name = " probabilistic_fusion_config_poto_lib " , <nl> + name = " probabilistic_fusion_config_proto_lib " , <nl> srcs = [ <nl> " probabilistic_fusion_config . proto " , <nl> ] , <nl> mmm a / modules / perception / fusion / lib / gatekeeper / pbf_gatekeeper / proto / BUILD . txt <nl> ppp b / modules / perception / fusion / lib / gatekeeper / pbf_gatekeeper / proto / BUILD . txt <nl> load ( " / / tools : cpplint . bzl " , " cpplint " ) <nl> package ( default_visibility = [ " / / visibility : public " ] ) <nl> <nl> cc_proto_library ( <nl> - name = " pbf_gatekeeper_config_poto " , <nl> + name = " pbf_gatekeeper_config_proto " , <nl> deps = [ <nl> " : pbf_gatekeeper_config_proto_lib " , <nl> ] , <nl> ) <nl> <nl> proto_library ( <nl> - name = " pbf_gatekeeper_config_poto_lib " , <nl> + name = " pbf_gatekeeper_config_proto_lib " , <nl> srcs = [ <nl> " pbf_gatekeeper_config . proto " , <nl> ] , <nl> mmm a / modules / perception / lidar / lib / ground_detector / ground_service_detector / proto / BUILD . txt <nl> ppp b / modules / perception / lidar / lib / ground_detector / ground_service_detector / proto / BUILD . txt <nl> load ( " / / tools : cpplint . bzl " , " cpplint " ) <nl> package ( default_visibility = [ " / / visibility : public " ] ) <nl> <nl> cc_proto_library ( <nl> - name = " ground_service_detector_config_poto " , <nl> + name = " ground_service_detector_config_proto " , <nl> deps = [ <nl> " : ground_service_detector_config_proto_lib " , <nl> ] , <nl> ) <nl> <nl> proto_library ( <nl> - name = " ground_service_detector_config_poto_lib " , <nl> + name = " ground_service_detector_config_proto_lib " , <nl> srcs = [ <nl> " ground_service_detector_config . proto " , <nl> ] , <nl> mmm a / modules / perception / lidar / lib / ground_detector / spatio_temporal_ground_detector / proto / BUILD . txt <nl> ppp b / modules / perception / lidar / lib / ground_detector / spatio_temporal_ground_detector / proto / BUILD . txt <nl> load ( " / / tools : cpplint . bzl " , " cpplint " ) <nl> package ( default_visibility = [ " / / visibility : public " ] ) <nl> <nl> cc_proto_library ( <nl> - name = " spatio_temporal_ground_detector_config_poto " , <nl> + name = " spatio_temporal_ground_detector_config_proto " , <nl> deps = [ <nl> " : spatio_temporal_ground_detector_config_proto_lib " , <nl> ] , <nl> ) <nl> <nl> proto_library ( <nl> - name = " spatio_temporal_ground_detector_config_poto_lib " , <nl> + name = " spatio_temporal_ground_detector_config_proto_lib " , <nl> srcs = [ <nl> " spatio_temporal_ground_detector_config . proto " , <nl> ] , <nl> mmm a / modules / perception / lidar / lib / object_filter_bank / roi_boundary_filter / proto / BUILD . txt <nl> ppp b / modules / perception / lidar / lib / object_filter_bank / roi_boundary_filter / proto / BUILD . txt <nl> load ( " / / tools : cpplint . bzl " , " cpplint " ) <nl> package ( default_visibility = [ " / / visibility : public " ] ) <nl> <nl> cc_proto_library ( <nl> - name = " roi_boundary_filter_config_poto " , <nl> + name = " roi_boundary_filter_config_proto " , <nl> deps = [ <nl> " : roi_boundary_filter_config_proto_lib " , <nl> ] , <nl> ) <nl> <nl> proto_library ( <nl> - name = " roi_boundary_filter_config_poto_lib " , <nl> + name = " roi_boundary_filter_config_proto_lib " , <nl> srcs = [ <nl> " roi_boundary_filter_config . proto " , <nl> ] , <nl> mmm a / modules / perception / lidar / lib / pointcloud_preprocessor / BUILD <nl> ppp b / modules / perception / lidar / lib / pointcloud_preprocessor / BUILD <nl> cc_library ( <nl> " pointcloud_preprocessor . h " , <nl> ] , <nl> deps = [ <nl> - " @ eigen " , <nl> " / / framework : cybertron " , <nl> " / / modules / common / proto : error_code_proto " , <nl> " / / modules / common / proto : header_proto " , <nl> cc_library ( <nl> " / / modules / perception / lidar / common " , <nl> " / / modules / perception / lidar / lib / pointcloud_preprocessor / proto : pointcloud_preprocessor_config_proto " , <nl> " / / modules / perception / proto : perception_config_schema_proto " , <nl> + " @ eigen " , <nl> ] , <nl> ) <nl> <nl> deleted file mode 100644 <nl> index d7c56d94374 . . 00000000000 <nl> mmm a / modules / perception / lidar / lib / pointcloud_preprocessor / BUILD . txt <nl> ppp / dev / null <nl> <nl> - # DO NOT MODIFY <nl> - # THIS FILE IS GENERATED AUTOMATICALLY TO HELP WRITE BUILD FILE <nl> - # DELETE THIS FILE WHEN YOU HAVE CREATED THE COMPLETE BUILD FILE <nl> - load ( " / / tools : cpplint . bzl " , " cpplint " ) <nl> - <nl> - package ( default_visibility = [ " / / visibility : public " ] ) <nl> - <nl> - cc_library ( <nl> - name = " pointcloud_preprocessor " , <nl> - srcs = [ <nl> - " pointcloud_preprocessor . cc " , <nl> - ] , <nl> - hdrs = [ <nl> - " pointcloud_preprocessor . h " , <nl> - ] , <nl> - deps = [ <nl> - ] , <nl> - ) <nl> - <nl> - cpplint ( ) <nl> mmm a / modules / perception / lidar / lib / roi_filter / hdmap_roi_filter / proto / BUILD . txt <nl> ppp b / modules / perception / lidar / lib / roi_filter / hdmap_roi_filter / proto / BUILD . txt <nl> load ( " / / tools : cpplint . bzl " , " cpplint " ) <nl> package ( default_visibility = [ " / / visibility : public " ] ) <nl> <nl> cc_proto_library ( <nl> - name = " hdmap_roi_filter_poto " , <nl> + name = " hdmap_roi_filter_proto " , <nl> deps = [ <nl> " : hdmap_roi_filter_proto_lib " , <nl> ] , <nl> ) <nl> <nl> proto_library ( <nl> - name = " hdmap_roi_filter_poto_lib " , <nl> + name = " hdmap_roi_filter_proto_lib " , <nl> srcs = [ <nl> " hdmap_roi_filter . proto " , <nl> ] , <nl> mmm a / modules / perception / lidar / lib / scene_manager / ground_service / proto / BUILD . txt <nl> ppp b / modules / perception / lidar / lib / scene_manager / ground_service / proto / BUILD . txt <nl> load ( " / / tools : cpplint . bzl " , " cpplint " ) <nl> package ( default_visibility = [ " / / visibility : public " ] ) <nl> <nl> cc_proto_library ( <nl> - name = " ground_service_config_poto " , <nl> + name = " ground_service_config_proto " , <nl> deps = [ <nl> " : ground_service_config_proto_lib " , <nl> ] , <nl> ) <nl> <nl> proto_library ( <nl> - name = " ground_service_config_poto_lib " , <nl> + name = " ground_service_config_proto_lib " , <nl> srcs = [ <nl> " ground_service_config . proto " , <nl> ] , <nl> mmm a / modules / perception / lidar / lib / segmentation / cnnseg / proto / BUILD . txt <nl> ppp b / modules / perception / lidar / lib / segmentation / cnnseg / proto / BUILD . txt <nl> load ( " / / tools : cpplint . bzl " , " cpplint " ) <nl> package ( default_visibility = [ " / / visibility : public " ] ) <nl> <nl> cc_proto_library ( <nl> - name = " cnnseg_config_poto " , <nl> + name = " cnnseg_config_proto " , <nl> deps = [ <nl> " : cnnseg_config_proto_lib " , <nl> ] , <nl> ) <nl> <nl> proto_library ( <nl> - name = " cnnseg_config_poto_lib " , <nl> + name = " cnnseg_config_proto_lib " , <nl> srcs = [ <nl> " cnnseg_config . proto " , <nl> ] , <nl> proto_library ( <nl> ) <nl> <nl> cc_proto_library ( <nl> - name = " cnnseg_param_poto " , <nl> + name = " cnnseg_param_proto " , <nl> deps = [ <nl> " : cnnseg_param_proto_lib " , <nl> ] , <nl> ) <nl> <nl> proto_library ( <nl> - name = " cnnseg_param_poto_lib " , <nl> + name = " cnnseg_param_proto_lib " , <nl> srcs = [ <nl> " cnnseg_param . proto " , <nl> ] , <nl> proto_library ( <nl> ) <nl> <nl> cc_proto_library ( <nl> - name = " spp_engine_config_poto " , <nl> + name = " spp_engine_config_proto " , <nl> deps = [ <nl> " : spp_engine_config_proto_lib " , <nl> ] , <nl> ) <nl> <nl> proto_library ( <nl> - name = " spp_engine_config_poto_lib " , <nl> + name = " spp_engine_config_proto_lib " , <nl> srcs = [ <nl> " spp_engine_config . proto " , <nl> ] , <nl> mmm a / modules / perception / lidar / lib / tracker / hm_tracker / proto / BUILD . txt <nl> ppp b / modules / perception / lidar / lib / tracker / hm_tracker / proto / BUILD . txt <nl> load ( " / / tools : cpplint . bzl " , " cpplint " ) <nl> package ( default_visibility = [ " / / visibility : public " ] ) <nl> <nl> cc_proto_library ( <nl> - name = " hm_tracker_config_poto " , <nl> + name = " hm_tracker_config_proto " , <nl> deps = [ <nl> " : hm_tracker_config_proto_lib " , <nl> ] , <nl> ) <nl> <nl> proto_library ( <nl> - name = " hm_tracker_config_poto_lib " , <nl> + name = " hm_tracker_config_proto_lib " , <nl> srcs = [ <nl> " hm_tracker_config . proto " , <nl> ] , <nl>
|
Fixed BUILD . txt poto - > proto .
|
ApolloAuto/apollo
|
2f1b2595d69afd0a42a01e68bfc806d746636844
|
2018-09-26T20:28:45Z
|
mmm a / src / heap - inl . h <nl> ppp b / src / heap - inl . h <nl> MaybeObject * Heap : : AllocateOneByteInternalizedString ( Vector < const uint8_t > str , <nl> / / Compute map and object size . <nl> Map * map = ascii_internalized_string_map ( ) ; <nl> int size = SeqOneByteString : : SizeFor ( str . length ( ) ) ; <nl> + AllocationSpace space = SelectSpace ( size , OLD_DATA_SPACE , TENURED ) ; <nl> <nl> / / Allocate string . <nl> Object * result ; <nl> - { MaybeObject * maybe_result = ( size > Page : : kMaxNonCodeHeapObjectSize ) <nl> - ? lo_space_ - > AllocateRaw ( size , NOT_EXECUTABLE ) <nl> - : old_data_space_ - > AllocateRaw ( size ) ; <nl> + { MaybeObject * maybe_result = AllocateRaw ( size , space , OLD_DATA_SPACE ) ; <nl> if ( ! maybe_result - > ToObject ( & result ) ) return maybe_result ; <nl> } <nl> <nl> MaybeObject * Heap : : AllocateTwoByteInternalizedString ( Vector < const uc16 > str , <nl> / / Compute map and object size . <nl> Map * map = internalized_string_map ( ) ; <nl> int size = SeqTwoByteString : : SizeFor ( str . length ( ) ) ; <nl> + AllocationSpace space = SelectSpace ( size , OLD_DATA_SPACE , TENURED ) ; <nl> <nl> / / Allocate string . <nl> Object * result ; <nl> - { MaybeObject * maybe_result = ( size > Page : : kMaxNonCodeHeapObjectSize ) <nl> - ? lo_space_ - > AllocateRaw ( size , NOT_EXECUTABLE ) <nl> - : old_data_space_ - > AllocateRaw ( size ) ; <nl> + { MaybeObject * maybe_result = AllocateRaw ( size , space , OLD_DATA_SPACE ) ; <nl> if ( ! maybe_result - > ToObject ( & result ) ) return maybe_result ; <nl> } <nl> <nl> mmm a / src / heap . cc <nl> ppp b / src / heap . cc <nl> bool Heap : : CreateInitialMaps ( ) { <nl> MaybeObject * Heap : : AllocateHeapNumber ( double value , PretenureFlag pretenure ) { <nl> / / Statically ensure that it is safe to allocate heap numbers in paged <nl> / / spaces . <nl> + int size = HeapNumber : : kSize ; <nl> STATIC_ASSERT ( HeapNumber : : kSize < = Page : : kNonCodeObjectAreaSize ) ; <nl> - AllocationSpace space = ( pretenure = = TENURED ) ? OLD_DATA_SPACE : NEW_SPACE ; <nl> + AllocationSpace space = SelectSpace ( size , OLD_DATA_SPACE , pretenure ) ; <nl> <nl> Object * result ; <nl> - { MaybeObject * maybe_result = <nl> - AllocateRaw ( HeapNumber : : kSize , space , OLD_DATA_SPACE ) ; <nl> + { MaybeObject * maybe_result = AllocateRaw ( size , space , OLD_DATA_SPACE ) ; <nl> if ( ! maybe_result - > ToObject ( & result ) ) return maybe_result ; <nl> } <nl> <nl> MaybeObject * Heap : : AllocateByteArray ( int length , PretenureFlag pretenure ) { <nl> if ( length < 0 | | length > ByteArray : : kMaxLength ) { <nl> return Failure : : OutOfMemoryException ( 0x7 ) ; <nl> } <nl> - if ( pretenure = = NOT_TENURED ) { <nl> - return AllocateByteArray ( length ) ; <nl> - } <nl> - int size = ByteArray : : SizeFor ( length ) ; <nl> - AllocationSpace space = <nl> - ( size > Page : : kMaxNonCodeHeapObjectSize ) ? LO_SPACE : OLD_DATA_SPACE ; <nl> - Object * result ; <nl> - { MaybeObject * maybe_result = AllocateRaw ( size , space , space ) ; <nl> - if ( ! maybe_result - > ToObject ( & result ) ) return maybe_result ; <nl> - } <nl> - <nl> - reinterpret_cast < ByteArray * > ( result ) - > set_map_no_write_barrier ( <nl> - byte_array_map ( ) ) ; <nl> - reinterpret_cast < ByteArray * > ( result ) - > set_length ( length ) ; <nl> - return result ; <nl> - } <nl> - <nl> - <nl> - MaybeObject * Heap : : AllocateByteArray ( int length ) { <nl> - if ( length < 0 | | length > ByteArray : : kMaxLength ) { <nl> - return Failure : : OutOfMemoryException ( 0x8 ) ; <nl> - } <nl> int size = ByteArray : : SizeFor ( length ) ; <nl> - AllocationSpace space = <nl> - ( size > Page : : kMaxNonCodeHeapObjectSize ) ? LO_SPACE : NEW_SPACE ; <nl> + AllocationSpace space = SelectSpace ( size , OLD_DATA_SPACE , pretenure ) ; <nl> Object * result ; <nl> { MaybeObject * maybe_result = AllocateRaw ( size , space , OLD_DATA_SPACE ) ; <nl> if ( ! maybe_result - > ToObject ( & result ) ) return maybe_result ; <nl> MaybeObject * Heap : : AllocateExternalArray ( int length , <nl> ExternalArrayType array_type , <nl> void * external_pointer , <nl> PretenureFlag pretenure ) { <nl> - AllocationSpace space = ( pretenure = = TENURED ) ? OLD_DATA_SPACE : NEW_SPACE ; <nl> + int size = ExternalArray : : kAlignedSize ; <nl> + AllocationSpace space = SelectSpace ( size , OLD_DATA_SPACE , pretenure ) ; <nl> Object * result ; <nl> - { MaybeObject * maybe_result = AllocateRaw ( ExternalArray : : kAlignedSize , <nl> - space , <nl> - OLD_DATA_SPACE ) ; <nl> + { MaybeObject * maybe_result = AllocateRaw ( size , space , OLD_DATA_SPACE ) ; <nl> if ( ! maybe_result - > ToObject ( & result ) ) return maybe_result ; <nl> } <nl> <nl> MaybeObject * Heap : : AllocateJSObjectFromMap ( <nl> } <nl> <nl> / / Allocate the JSObject . <nl> - AllocationSpace space = <nl> - ( pretenure = = TENURED ) ? OLD_POINTER_SPACE : NEW_SPACE ; <nl> - if ( map - > instance_size ( ) > Page : : kMaxNonCodeHeapObjectSize ) space = LO_SPACE ; <nl> + int size = map - > instance_size ( ) ; <nl> + AllocationSpace space = SelectSpace ( size , OLD_POINTER_SPACE , pretenure ) ; <nl> Object * obj ; <nl> MaybeObject * maybe_obj = Allocate ( map , space ) ; <nl> if ( ! maybe_obj - > To ( & obj ) ) return maybe_obj ; <nl> MaybeObject * Heap : : AllocateJSObjectFromMapWithAllocationSite ( <nl> } <nl> <nl> / / Allocate the JSObject . <nl> - AllocationSpace space = NEW_SPACE ; <nl> - if ( map - > instance_size ( ) > Page : : kMaxNonCodeHeapObjectSize ) space = LO_SPACE ; <nl> + int size = map - > instance_size ( ) ; <nl> + AllocationSpace space = SelectSpace ( size , OLD_POINTER_SPACE , NOT_TENURED ) ; <nl> Object * obj ; <nl> MaybeObject * maybe_obj = <nl> AllocateWithAllocationSite ( map , space , allocation_site ) ; <nl> MaybeObject * Heap : : AllocateInternalizedStringImpl ( <nl> map = internalized_string_map ( ) ; <nl> size = SeqTwoByteString : : SizeFor ( chars ) ; <nl> } <nl> + AllocationSpace space = SelectSpace ( size , OLD_DATA_SPACE , TENURED ) ; <nl> <nl> / / Allocate string . <nl> Object * result ; <nl> - { MaybeObject * maybe_result = ( size > Page : : kMaxNonCodeHeapObjectSize ) <nl> - ? lo_space_ - > AllocateRaw ( size , NOT_EXECUTABLE ) <nl> - : old_data_space_ - > AllocateRaw ( size ) ; <nl> + { MaybeObject * maybe_result = AllocateRaw ( size , space , OLD_DATA_SPACE ) ; <nl> if ( ! maybe_result - > ToObject ( & result ) ) return maybe_result ; <nl> } <nl> <nl> MaybeObject * Heap : : AllocateRawOneByteString ( int length , <nl> } <nl> int size = SeqOneByteString : : SizeFor ( length ) ; <nl> ASSERT ( size < = SeqOneByteString : : kMaxSize ) ; <nl> - AllocationSpace space = ( pretenure = = TENURED ) ? OLD_DATA_SPACE : NEW_SPACE ; <nl> - AllocationSpace retry_space = OLD_DATA_SPACE ; <nl> - <nl> - if ( size > Page : : kMaxNonCodeHeapObjectSize ) { <nl> - / / Allocate in large object space , retry space will be ignored . <nl> - space = LO_SPACE ; <nl> - } <nl> + AllocationSpace space = SelectSpace ( size , OLD_DATA_SPACE , pretenure ) ; <nl> <nl> Object * result ; <nl> - { MaybeObject * maybe_result = AllocateRaw ( size , space , retry_space ) ; <nl> + { MaybeObject * maybe_result = AllocateRaw ( size , space , OLD_DATA_SPACE ) ; <nl> if ( ! maybe_result - > ToObject ( & result ) ) return maybe_result ; <nl> } <nl> <nl> MaybeObject * Heap : : AllocateRawTwoByteString ( int length , <nl> } <nl> int size = SeqTwoByteString : : SizeFor ( length ) ; <nl> ASSERT ( size < = SeqTwoByteString : : kMaxSize ) ; <nl> - AllocationSpace space = ( pretenure = = TENURED ) ? OLD_DATA_SPACE : NEW_SPACE ; <nl> - AllocationSpace retry_space = OLD_DATA_SPACE ; <nl> - <nl> - if ( size > Page : : kMaxNonCodeHeapObjectSize ) { <nl> - / / Allocate in large object space , retry space will be ignored . <nl> - space = LO_SPACE ; <nl> - } <nl> + AllocationSpace space = SelectSpace ( size , OLD_DATA_SPACE , pretenure ) ; <nl> <nl> Object * result ; <nl> - { MaybeObject * maybe_result = AllocateRaw ( size , space , retry_space ) ; <nl> + { MaybeObject * maybe_result = AllocateRaw ( size , space , OLD_DATA_SPACE ) ; <nl> if ( ! maybe_result - > ToObject ( & result ) ) return maybe_result ; <nl> } <nl> <nl> MaybeObject * Heap : : AllocateRawFixedArray ( int length , PretenureFlag pretenure ) { <nl> return Failure : : OutOfMemoryException ( 0xe ) ; <nl> } <nl> int size = FixedArray : : SizeFor ( length ) ; <nl> - AllocationSpace space = <nl> - ( pretenure = = TENURED ) ? OLD_POINTER_SPACE : NEW_SPACE ; <nl> - AllocationSpace retry_space = OLD_POINTER_SPACE ; <nl> - <nl> - if ( size > Page : : kMaxNonCodeHeapObjectSize ) { <nl> - / / Allocate in large object space , retry space will be ignored . <nl> - space = LO_SPACE ; <nl> - } <nl> + AllocationSpace space = SelectSpace ( size , OLD_POINTER_SPACE , pretenure ) ; <nl> <nl> - return AllocateRaw ( size , space , retry_space ) ; <nl> + return AllocateRaw ( size , space , OLD_POINTER_SPACE ) ; <nl> } <nl> <nl> <nl> MaybeObject * Heap : : AllocateRawFixedDoubleArray ( int length , <nl> return Failure : : OutOfMemoryException ( 0xf ) ; <nl> } <nl> int size = FixedDoubleArray : : SizeFor ( length ) ; <nl> - AllocationSpace space = ( pretenure = = TENURED ) ? OLD_DATA_SPACE : NEW_SPACE ; <nl> - AllocationSpace retry_space = OLD_DATA_SPACE ; <nl> - <nl> # ifndef V8_HOST_ARCH_64_BIT <nl> size + = kPointerSize ; <nl> # endif <nl> - <nl> - if ( size > Page : : kMaxNonCodeHeapObjectSize ) { <nl> - / / Allocate in large object space , retry space will be ignored . <nl> - space = LO_SPACE ; <nl> - } <nl> + AllocationSpace space = SelectSpace ( size , OLD_DATA_SPACE , pretenure ) ; <nl> <nl> HeapObject * object ; <nl> - { MaybeObject * maybe_object = AllocateRaw ( size , space , retry_space ) ; <nl> + { MaybeObject * maybe_object = AllocateRaw ( size , space , OLD_DATA_SPACE ) ; <nl> if ( ! maybe_object - > To < HeapObject > ( & object ) ) return maybe_object ; <nl> } <nl> <nl> STRUCT_LIST ( MAKE_CASE ) <nl> return Failure : : InternalError ( ) ; <nl> } <nl> int size = map - > instance_size ( ) ; <nl> - AllocationSpace space = <nl> - ( size > Page : : kMaxNonCodeHeapObjectSize ) ? LO_SPACE : OLD_POINTER_SPACE ; <nl> + AllocationSpace space = SelectSpace ( size , OLD_POINTER_SPACE , TENURED ) ; <nl> Object * result ; <nl> { MaybeObject * maybe_result = Allocate ( map , space ) ; <nl> if ( ! maybe_result - > ToObject ( & result ) ) return maybe_result ; <nl> mmm a / src / heap . h <nl> ppp b / src / heap . h <nl> class Heap { <nl> / / Returns Failure : : RetryAfterGC ( requested_bytes , space ) if the allocation <nl> / / failed . <nl> / / Please note this does not perform a garbage collection . <nl> - MUST_USE_RESULT MaybeObject * AllocateByteArray ( int length , <nl> - PretenureFlag pretenure ) ; <nl> - <nl> - / / Allocate a non - tenured byte array of the specified length <nl> - / / Returns Failure : : RetryAfterGC ( requested_bytes , space ) if the allocation <nl> - / / failed . <nl> - / / Please note this does not perform a garbage collection . <nl> - MUST_USE_RESULT MaybeObject * AllocateByteArray ( int length ) ; <nl> + MUST_USE_RESULT MaybeObject * AllocateByteArray ( <nl> + int length , <nl> + PretenureFlag pretenure = NOT_TENURED ) ; <nl> <nl> / / Allocates an external array of the specified length and type . <nl> / / Returns Failure : : RetryAfterGC ( requested_bytes , space ) if the allocation <nl> class Heap { <nl> <nl> inline void UpdateOldSpaceLimits ( ) ; <nl> <nl> + / / Selects the proper allocation space depending on the given object <nl> + / / size , pretenuring decision , and preferred old - space . <nl> + static AllocationSpace SelectSpace ( int object_size , <nl> + AllocationSpace preferred_old_space , <nl> + PretenureFlag pretenure ) { <nl> + ASSERT ( preferred_old_space = = OLD_POINTER_SPACE | | <nl> + preferred_old_space = = OLD_DATA_SPACE ) ; <nl> + if ( object_size > Page : : kMaxNonCodeHeapObjectSize ) return LO_SPACE ; <nl> + return ( pretenure = = TENURED ) ? preferred_old_space : NEW_SPACE ; <nl> + } <nl> + <nl> / / Allocate an uninitialized object in map space . The behavior is identical <nl> / / to Heap : : AllocateRaw ( size_in_bytes , MAP_SPACE ) , except that ( a ) it doesn ' t <nl> / / have to test the allocation space argument and ( b ) can reduce code size <nl>
|
Introduce Heap : : SelectSpace helper for allocations .
|
v8/v8
|
2febbdca9c6dd99c02eb5ca05ed34978ff46a331
|
2013-09-23T14:19:44Z
|
new file mode 100644 <nl> index 00000000000 . . bb1fa8da8b2 <nl> mmm / dev / null <nl> ppp b / example / gluon / image_classification . py <nl> <nl> + from __future__ import division <nl> + <nl> + import argparse , time <nl> + import logging <nl> + logging . basicConfig ( level = logging . INFO ) <nl> + <nl> + import mxnet as mx <nl> + from mxnet import gluon <nl> + from mxnet . gluon import nn <nl> + from mxnet . gluon . model_zoo import vision as models <nl> + from mxnet import autograd as ag <nl> + <nl> + from data import * <nl> + <nl> + # CLI <nl> + parser = argparse . ArgumentParser ( description = ' Train a model for image classification . ' ) <nl> + parser . add_argument ( ' - - dataset ' , type = str , default = ' mnist ' , <nl> + help = ' dataset to use . options are mnist , cifar10 , and dummy . ' ) <nl> + parser . add_argument ( ' - - batch - size ' , type = int , default = 32 , <nl> + help = ' training batch size per device ( CPU / GPU ) . ' ) <nl> + parser . add_argument ( ' - - gpus ' , type = int , default = 0 , <nl> + help = ' number of gpus to use . ' ) <nl> + parser . add_argument ( ' - - epochs ' , type = int , default = 3 , <nl> + help = ' number of training epochs . ' ) <nl> + parser . add_argument ( ' - - lr ' , type = float , default = 0 . 01 , <nl> + help = ' learning rate . default is 0 . 01 . ' ) <nl> + parser . add_argument ( ' - - wd ' , type = float , default = 0 . 0001 , <nl> + help = ' weight decay rate . default is 0 . 0001 . ' ) <nl> + parser . add_argument ( ' - - seed ' , type = int , default = 123 , <nl> + help = ' random seed to use . Default = 123 . ' ) <nl> + parser . add_argument ( ' - - benchmark ' , action = ' store_true ' , <nl> + help = ' whether to run benchmark . ' ) <nl> + parser . add_argument ( ' - - mode ' , type = str , <nl> + help = ' mode in which to train the model . options are symbolic , imperative , hybrid ' ) <nl> + parser . add_argument ( ' - - model ' , type = str , required = True , <nl> + help = ' type of model to use . see vision_model for options . ' ) <nl> + parser . add_argument ( ' - - use_thumbnail ' , action = ' store_true ' , <nl> + help = ' use thumbnail or not in resnet . default is false . ' ) <nl> + parser . add_argument ( ' - - batch - norm ' , action = ' store_true ' , <nl> + help = ' enable batch normalization or not in vgg . default is false . ' ) <nl> + parser . add_argument ( ' - - use - pretrained ' , action = ' store_true ' , <nl> + help = ' enable using pretrained model from gluon . ' ) <nl> + parser . add_argument ( ' - - log - interval ' , type = int , default = 50 , help = ' Number of batches to wait before logging . ' ) <nl> + opt = parser . parse_args ( ) <nl> + <nl> + print ( opt ) <nl> + <nl> + mx . random . seed ( opt . seed ) <nl> + <nl> + dataset_classes = { ' mnist ' : 10 , ' cifar10 ' : 10 , ' imagenet ' : 1000 , ' dummy ' : 1000 } <nl> + <nl> + batch_size , dataset , classes = opt . batch_size , opt . dataset , dataset_classes [ opt . dataset ] <nl> + <nl> + gpus = opt . gpus <nl> + <nl> + if opt . benchmark : <nl> + batch_size = 32 <nl> + dataset = ' dummy ' <nl> + classes = 1000 <nl> + <nl> + batch_size * = max ( 1 , gpus ) <nl> + context = [ mx . gpu ( i ) for i in range ( gpus ) ] if gpus > 0 else [ mx . cpu ( ) ] <nl> + <nl> + model_name = opt . model <nl> + <nl> + kwargs = { ' ctx ' : context , ' pretrained ' : opt . use_pretrained , ' classes ' : classes } <nl> + if model_name . startswith ( ' resnet ' ) : <nl> + kwargs [ ' thumbnail ' ] = opt . use_thumbnail <nl> + elif model_name . startswith ( ' vgg ' ) : <nl> + kwargs [ ' batch_norm ' ] = opt . batch_norm <nl> + <nl> + net = models . get_model ( opt . model , * * kwargs ) <nl> + <nl> + # get dataset iterators <nl> + if dataset = = ' mnist ' : <nl> + train_data , val_data = mnist_iterator ( batch_size , ( 1 , 32 , 32 ) ) <nl> + elif dataset = = ' cifar10 ' : <nl> + train_data , val_data = cifar10_iterator ( batch_size , ( 3 , 32 , 32 ) ) <nl> + elif dataset = = ' dummy ' : <nl> + if model_name = = ' inceptionv3 ' : <nl> + train_data , val_data = dummy_iterator ( batch_size , ( 3 , 299 , 299 ) ) <nl> + else : <nl> + train_data , val_data = dummy_iterator ( batch_size , ( 3 , 224 , 224 ) ) <nl> + <nl> + def test ( ctx ) : <nl> + metric = mx . metric . Accuracy ( ) <nl> + val_data . reset ( ) <nl> + for batch in val_data : <nl> + data = gluon . utils . split_and_load ( batch . data [ 0 ] , ctx_list = ctx , batch_axis = 0 ) <nl> + label = gluon . utils . split_and_load ( batch . label [ 0 ] , ctx_list = ctx , batch_axis = 0 ) <nl> + outputs = [ ] <nl> + for x in data : <nl> + outputs . append ( net ( x ) ) <nl> + metric . update ( label , outputs ) <nl> + return metric . get ( ) <nl> + <nl> + <nl> + def train ( epochs , ctx ) : <nl> + if isinstance ( ctx , mx . Context ) : <nl> + ctx = [ ctx ] <nl> + net . initialize ( mx . init . Xavier ( magnitude = 2 . 24 ) , ctx = ctx ) <nl> + trainer = gluon . Trainer ( net . collect_params ( ) , ' sgd ' , { ' learning_rate ' : opt . lr , ' wd ' : opt . wd } ) <nl> + metric = mx . metric . Accuracy ( ) <nl> + loss = gluon . loss . SoftmaxCrossEntropyLoss ( ) <nl> + <nl> + for epoch in range ( epochs ) : <nl> + tic = time . time ( ) <nl> + train_data . reset ( ) <nl> + metric . reset ( ) <nl> + btic = time . time ( ) <nl> + for i , batch in enumerate ( train_data ) : <nl> + data = gluon . utils . split_and_load ( batch . data [ 0 ] , ctx_list = ctx , batch_axis = 0 ) <nl> + label = gluon . utils . split_and_load ( batch . label [ 0 ] , ctx_list = ctx , batch_axis = 0 ) <nl> + outputs = [ ] <nl> + Ls = [ ] <nl> + with ag . record ( ) : <nl> + for x , y in zip ( data , label ) : <nl> + z = net ( x ) <nl> + L = loss ( z , y ) <nl> + # store the loss and do backward after we have done forward <nl> + # on all GPUs for better speed on multiple GPUs . <nl> + Ls . append ( L ) <nl> + outputs . append ( z ) <nl> + for L in Ls : <nl> + L . backward ( ) <nl> + trainer . step ( batch . data [ 0 ] . shape [ 0 ] ) <nl> + metric . update ( label , outputs ) <nl> + if opt . log_interval and not ( i + 1 ) % opt . log_interval : <nl> + name , acc = metric . get ( ) <nl> + logging . info ( ' [ Epoch % d Batch % d ] speed : % f samples / s , training : % s = % f ' % ( <nl> + epoch , i , batch_size / ( time . time ( ) - btic ) , name , acc ) ) <nl> + btic = time . time ( ) <nl> + <nl> + name , acc = metric . get ( ) <nl> + logging . info ( ' [ Epoch % d ] training : % s = % f ' % ( epoch , name , acc ) ) <nl> + logging . info ( ' [ Epoch % d ] time cost : % f ' % ( epoch , time . time ( ) - tic ) ) <nl> + name , val_acc = test ( ctx ) <nl> + logging . info ( ' [ Epoch % d ] validation : % s = % f ' % ( epoch , name , val_acc ) ) <nl> + <nl> + net . save_params ( ' image - classifier - % s - % d . params ' % ( opt . model , epochs ) ) <nl> + <nl> + if __name__ = = ' __main__ ' : <nl> + if opt . mode = = ' symbolic ' : <nl> + data = mx . sym . var ( ' data ' ) <nl> + out = net ( data ) <nl> + softmax = mx . sym . SoftmaxOutput ( out , name = ' softmax ' ) <nl> + mod = mx . mod . Module ( softmax , context = [ mx . gpu ( i ) for i in range ( gpus ) ] if gpus > 0 else [ mx . cpu ( ) ] ) <nl> + mod . fit ( train_data , num_epoch = opt . epochs , batch_end_callback = mx . callback . Speedometer ( batch_size , 1 ) ) <nl> + else : <nl> + if opt . mode = = ' hybrid ' : <nl> + net . hybridize ( ) <nl> + train ( opt . epochs , context ) <nl> deleted file mode 100644 <nl> index 44517eaf15f . . 00000000000 <nl> mmm a / example / gluon / resnet . py <nl> ppp / dev / null <nl> <nl> - from __future__ import division , print_function <nl> - <nl> - import argparse , time <nl> - import logging <nl> - logging . basicConfig ( level = logging . INFO ) <nl> - <nl> - import mxnet as mx <nl> - from mxnet import gluon <nl> - from mxnet . gluon import nn <nl> - from mxnet import autograd as ag <nl> - <nl> - from data import * <nl> - <nl> - # CLI <nl> - parser = argparse . ArgumentParser ( description = ' Train a resnet model for image classification . ' ) <nl> - parser . add_argument ( ' - - dataset ' , type = str , default = ' cifar10 ' , <nl> - help = ' dataset to use . options are mnist , cifar10 , and dummy . ' ) <nl> - parser . add_argument ( ' - - batch - size ' , type = int , default = 32 , <nl> - help = ' training batch size per device ( CPU / GPU ) . ' ) <nl> - parser . add_argument ( ' - - resnet - version ' , type = int , default = 1 , <nl> - help = ' whether to use ResnetV1 or ResnetV2 . default is 1 . ' ) <nl> - parser . add_argument ( ' - - resnet - layers ' , type = int , default = 50 , <nl> - help = ' layers of resnet to use . options are 18 , 50 . default is 50 . ' ) <nl> - parser . add_argument ( ' - - gpus ' , type = int , default = 0 , <nl> - help = ' number of gpus to use . ' ) <nl> - parser . add_argument ( ' - - epochs ' , type = int , default = 3 , <nl> - help = ' number of training epochs . ' ) <nl> - parser . add_argument ( ' - - lr ' , type = float , default = 0 . 01 , <nl> - help = ' learning Rate . default is 0 . 01 . ' ) <nl> - parser . add_argument ( ' - - seed ' , type = int , default = 123 , <nl> - help = ' random seed to use . Default = 123 . ' ) <nl> - parser . add_argument ( ' - - thumbnail ' , action = ' store_true ' , default = False , <nl> - help = ' use thumbnail or not . default is false . ' ) <nl> - parser . add_argument ( ' - - benchmark ' , action = ' store_true ' , default = False , <nl> - help = ' whether to run benchmark . ' ) <nl> - parser . add_argument ( ' - - symbolic ' , action = ' store_true ' , default = False , <nl> - help = ' whether to train in symbolic way with module . ' ) <nl> - parser . add_argument ( ' - - log - interval ' , type = int , default = 100 , <nl> - help = ' Number of batches to wait before logging . ' ) <nl> - opt = parser . parse_args ( ) <nl> - <nl> - print ( opt ) <nl> - <nl> - <nl> - # Define network <nl> - <nl> - def conv3x3 ( filters , stride , in_channels ) : <nl> - return nn . Conv2D ( filters , kernel_size = 3 , strides = stride , padding = 1 , <nl> - use_bias = False , in_channels = in_channels ) <nl> - <nl> - class BasicBlockV1 ( gluon . HybridBlock ) : <nl> - def __init__ ( self , filters , stride , downsample = False , in_channels = 0 , * * kwargs ) : <nl> - super ( BasicBlockV1 , self ) . __init__ ( * * kwargs ) <nl> - with self . name_scope ( ) : <nl> - self . conv1 = conv3x3 ( filters , stride , in_channels ) <nl> - self . bn1 = nn . BatchNorm ( in_channels = in_channels ) <nl> - self . conv2 = conv3x3 ( filters , 1 , filters ) <nl> - self . bn2 = nn . BatchNorm ( in_channels = filters ) <nl> - if downsample : <nl> - self . conv_ds = nn . Conv2D ( filters , kernel_size = 1 , strides = stride , use_bias = False , in_channels = in_channels ) <nl> - self . bn_ds = nn . BatchNorm ( in_channels = filters ) <nl> - self . downsample = downsample <nl> - <nl> - def hybrid_forward ( self , F , x ) : <nl> - residual = x <nl> - <nl> - out = self . conv1 ( x ) <nl> - out = self . bn1 ( out ) <nl> - out = F . Activation ( x , act_type = ' relu ' ) <nl> - <nl> - out = self . conv2 ( out ) <nl> - out = self . bn2 ( out ) <nl> - <nl> - if self . downsample : <nl> - residual = self . conv_ds ( x ) <nl> - residual = self . bn_ds ( residual ) <nl> - <nl> - out = residual + out <nl> - out = F . Activation ( out , act_type = ' relu ' ) <nl> - <nl> - return out <nl> - <nl> - <nl> - class BottleneckV1 ( gluon . HybridBlock ) : <nl> - def __init__ ( self , filters , stride , downsample = False , in_channels = 0 , * * kwargs ) : <nl> - super ( BottleneckV1 , self ) . __init__ ( * * kwargs ) <nl> - with self . name_scope ( ) : <nl> - self . conv1 = nn . Conv2D ( filters / / 4 , kernel_size = 1 , strides = 1 , in_channels = in_channels ) <nl> - self . bn1 = nn . BatchNorm ( in_channels = filters / / 4 ) <nl> - self . conv2 = conv3x3 ( filters / / 4 , stride , filters / / 4 ) <nl> - self . bn2 = nn . BatchNorm ( in_channels = filters / / 4 ) <nl> - self . conv3 = nn . Conv2D ( filters , kernel_size = 1 , strides = 1 , in_channels = filters / / 4 ) <nl> - self . bn3 = nn . BatchNorm ( in_channels = filters ) <nl> - if downsample : <nl> - self . conv_ds = nn . Conv2D ( filters , kernel_size = 1 , strides = stride , use_bias = False , in_channels = in_channels ) <nl> - self . bn_ds = nn . BatchNorm ( in_channels = filters ) <nl> - self . downsample = downsample <nl> - <nl> - def hybrid_forward ( self , F , x ) : <nl> - residual = x <nl> - <nl> - out = self . conv1 ( x ) <nl> - out = self . bn1 ( out ) <nl> - out = F . Activation ( out , act_type = ' relu ' ) <nl> - <nl> - out = self . conv2 ( out ) <nl> - out = self . bn2 ( out ) <nl> - out = F . Activation ( out , act_type = ' relu ' ) <nl> - <nl> - out = self . conv3 ( out ) <nl> - out = self . bn3 ( out ) <nl> - <nl> - if self . downsample : <nl> - residual = self . conv_ds ( x ) <nl> - residual = self . bn_ds ( residual ) <nl> - <nl> - out = out + residual <nl> - <nl> - out = F . Activation ( out , act_type = ' relu ' ) <nl> - return out <nl> - <nl> - <nl> - class ResnetV1 ( gluon . HybridBlock ) : <nl> - def __init__ ( self , block , classes , layers , filters , thumbnail = False , * * kwargs ) : <nl> - super ( ResnetV1 , self ) . __init__ ( * * kwargs ) <nl> - with self . name_scope ( ) : <nl> - assert len ( layers ) = = len ( filters ) - 1 <nl> - self . _thumbnail = thumbnail <nl> - if thumbnail : <nl> - self . conv0 = conv3x3 ( filters [ 0 ] , 1 , 3 ) <nl> - else : <nl> - self . conv0 = nn . Conv2D ( filters [ 0 ] , 7 , 2 , 3 , use_bias = False , <nl> - in_channels = 3 ) <nl> - self . bn0 = nn . BatchNorm ( in_channels = filters [ 0 ] ) <nl> - self . pool0 = nn . MaxPool2D ( 3 , 2 , 1 ) <nl> - <nl> - self . body = nn . HybridSequential ( ) <nl> - in_channels = filters [ 0 ] <nl> - for i in range ( len ( layers ) ) : <nl> - stride = 1 if i = = 0 else 2 <nl> - self . body . add ( self . _make_layer ( block , layers [ i ] , filters [ i + 1 ] , <nl> - stride , in_channels = filters [ i ] ) ) <nl> - in_channels = filters [ i + 1 ] <nl> - <nl> - self . pool1 = nn . GlobalAvgPool2D ( ) <nl> - self . dense1 = nn . Dense ( classes , in_units = filters [ - 1 ] ) <nl> - <nl> - def _make_layer ( self , block , layers , filters , stride , in_channels = 0 ) : <nl> - layer = nn . HybridSequential ( ) <nl> - layer . add ( block ( filters , stride , True , in_channels = in_channels ) ) <nl> - for i in range ( layers - 1 ) : <nl> - layer . add ( block ( filters , 1 , False , in_channels = filters ) ) <nl> - return layer <nl> - <nl> - def hybrid_forward ( self , F , x ) : <nl> - x = self . conv0 ( x ) <nl> - if not self . _thumbnail : <nl> - x = self . bn0 ( x ) <nl> - x = F . Activation ( x , act_type = ' relu ' ) <nl> - x = self . pool0 ( x ) <nl> - <nl> - x = self . body ( x ) <nl> - <nl> - x = self . pool1 ( x ) <nl> - x = x . reshape ( ( 0 , - 1 ) ) <nl> - x = self . dense1 ( x ) <nl> - <nl> - return x <nl> - <nl> - <nl> - class BasicBlockV2 ( gluon . HybridBlock ) : <nl> - def __init__ ( self , filters , stride , downsample = False , in_channels = 0 , * * kwargs ) : <nl> - super ( BasicBlockV2 , self ) . __init__ ( * * kwargs ) <nl> - with self . name_scope ( ) : <nl> - self . bn1 = nn . BatchNorm ( in_channels = in_channels ) <nl> - self . conv1 = conv3x3 ( filters , stride , in_channels ) <nl> - self . bn2 = nn . BatchNorm ( in_channels = filters ) <nl> - self . conv2 = conv3x3 ( filters , 1 , filters ) <nl> - if downsample : <nl> - self . downsample = nn . Conv2D ( filters , 1 , stride , use_bias = False , <nl> - in_channels = in_channels ) <nl> - else : <nl> - self . downsample = None <nl> - <nl> - def hybrid_forward ( self , F , x ) : <nl> - if not self . downsample : <nl> - residual = x <nl> - x = self . bn1 ( x ) <nl> - x = F . Activation ( x , act_type = ' relu ' ) <nl> - if self . downsample : <nl> - residual = self . downsample ( x ) <nl> - x = self . conv1 ( x ) <nl> - <nl> - x = self . bn2 ( x ) <nl> - x = F . Activation ( x , act_type = ' relu ' ) <nl> - x = self . conv2 ( x ) <nl> - <nl> - return x + residual <nl> - <nl> - <nl> - class BottleneckV2 ( gluon . HybridBlock ) : <nl> - def __init__ ( self , filters , stride , downsample = False , in_channels = 0 , * * kwargs ) : <nl> - super ( BottleneckV2 , self ) . __init__ ( * * kwargs ) <nl> - with self . name_scope ( ) : <nl> - self . bn1 = nn . BatchNorm ( in_channels = in_channels ) <nl> - self . conv1 = conv3x3 ( filters / / 4 , 1 , in_channels ) <nl> - self . bn2 = nn . BatchNorm ( in_channels = filters / / 4 ) <nl> - self . conv2 = conv3x3 ( filters / / 4 , stride , filters / / 4 ) <nl> - self . bn3 = nn . BatchNorm ( in_channels = filters / / 4 ) <nl> - self . conv3 = conv3x3 ( filters , 1 , filters / / 4 ) <nl> - if downsample : <nl> - self . downsample = nn . Conv2D ( filters , 1 , stride , use_bias = False , <nl> - in_channels = in_channels ) <nl> - else : <nl> - self . downsample = None <nl> - <nl> - def hybrid_forward ( self , F , x ) : <nl> - if not self . downsample : <nl> - residual = x <nl> - x = self . bn1 ( x ) <nl> - x = F . Activation ( x , act_type = ' relu ' ) <nl> - if self . downsample : <nl> - residual = self . downsample ( x ) <nl> - x = self . conv1 ( x ) <nl> - <nl> - x = self . bn2 ( x ) <nl> - x = F . Activation ( x , act_type = ' relu ' ) <nl> - x = self . conv2 ( x ) <nl> - <nl> - x = self . bn3 ( x ) <nl> - x = F . Activation ( x , act_type = ' relu ' ) <nl> - x = self . conv3 ( x ) <nl> - <nl> - return x + residual <nl> - <nl> - class ResnetV2 ( gluon . HybridBlock ) : <nl> - def __init__ ( self , block , classes , layers , filters , thumbnail = False , * * kwargs ) : <nl> - super ( ResnetV2 , self ) . __init__ ( * * kwargs ) <nl> - with self . name_scope ( ) : <nl> - assert len ( layers ) = = len ( filters ) - 1 <nl> - self . _thumbnail = thumbnail <nl> - self . bn_data = nn . BatchNorm ( in_channels = 3 , scale = False , center = False ) <nl> - if thumbnail : <nl> - self . conv0 = conv3x3 ( filters [ 0 ] , 1 , 3 ) <nl> - else : <nl> - self . conv0 = nn . Conv2D ( filters [ 0 ] , 7 , 2 , 3 , use_bias = False , <nl> - in_channels = 3 ) <nl> - self . bn0 = nn . BatchNorm ( in_channels = filters [ 0 ] ) <nl> - self . pool0 = nn . MaxPool2D ( 3 , 2 , 1 ) <nl> - <nl> - self . body = nn . HybridSequential ( ) <nl> - in_channels = filters [ 0 ] <nl> - for i in range ( len ( layers ) ) : <nl> - stride = 1 if i = = 0 else 2 <nl> - self . body . add ( self . _make_layer ( block , layers [ i ] , filters [ i + 1 ] , <nl> - stride , in_channels = in_channels ) ) <nl> - in_channels = filters [ i + 1 ] <nl> - <nl> - self . bn1 = nn . BatchNorm ( in_channels = in_channels ) <nl> - self . pool1 = nn . GlobalAvgPool2D ( ) <nl> - self . dense1 = nn . Dense ( classes , in_units = in_channels ) <nl> - <nl> - def _make_layer ( self , block , layers , filters , stride , in_channels = 0 ) : <nl> - layer = nn . HybridSequential ( ) <nl> - layer . add ( block ( filters , stride , True , in_channels = in_channels ) ) <nl> - for i in range ( layers - 1 ) : <nl> - layer . add ( block ( filters , 1 , False , in_channels = filters ) ) <nl> - return layer <nl> - <nl> - def hybrid_forward ( self , F , x ) : <nl> - x = self . bn_data ( x ) <nl> - x = self . conv0 ( x ) <nl> - if not self . _thumbnail : <nl> - x = self . bn0 ( x ) <nl> - x = F . Activation ( x , act_type = ' relu ' ) <nl> - x = self . pool0 ( x ) <nl> - <nl> - x = self . body ( x ) <nl> - <nl> - x = self . bn1 ( x ) <nl> - x = F . Activation ( x , act_type = ' relu ' ) <nl> - x = self . pool1 ( x ) <nl> - x = x . reshape ( ( 0 , - 1 ) ) <nl> - x = self . dense1 ( x ) <nl> - <nl> - return x <nl> - <nl> - # construct net <nl> - resnet_spec = { 18 : ( ' basic_block ' , [ 2 , 2 , 2 ] , [ 16 , 16 , 32 , 64 ] ) , <nl> - 34 : ( ' basic_block ' , [ 3 , 4 , 6 , 3 ] , [ 16 , 16 , 32 , 64 ] ) , <nl> - 50 : ( ' bottle_neck ' , [ 3 , 4 , 6 , 3 ] , [ 64 , 256 , 512 , 1024 , 2048 ] ) , <nl> - 101 : ( ' bottle_neck ' , [ 3 , 4 , 23 , 3 ] , [ 64 , 256 , 512 , 1024 , 2048 ] ) , <nl> - 152 : ( ' bottle_neck ' , [ 3 , 8 , 36 , 3 ] , [ 64 , 256 , 512 , 1024 , 2048 ] ) } <nl> - <nl> - resnet_net_versions = [ ResnetV1 , ResnetV2 ] <nl> - resnet_block_versions = [ { ' basic_block ' : BasicBlockV1 , ' bottle_neck ' : BottleneckV1 } , <nl> - { ' basic_block ' : BasicBlockV2 , ' bottle_neck ' : BottleneckV2 } ] <nl> - <nl> - def get_resnet ( version , num_layers , classes , use_thumbnail ) : <nl> - block_type , layers , filters = resnet_spec [ num_layers ] <nl> - resnet = resnet_net_versions [ version ] <nl> - block = resnet_block_versions [ version ] [ block_type ] <nl> - return resnet ( block , classes , layers , filters , use_thumbnail ) <nl> - <nl> - dataset_classes = { ' mnist ' : 10 , ' cifar10 ' : 10 , ' imagenet ' : 1000 , ' dummy ' : 1000 } <nl> - <nl> - batch_size , dataset , classes = opt . batch_size , opt . dataset , dataset_classes [ opt . dataset ] <nl> - <nl> - gpus , version = opt . gpus , opt . resnet_version - 1 <nl> - <nl> - if opt . benchmark : <nl> - batch_size = 32 <nl> - dataset = ' dummy ' <nl> - classes = 1000 <nl> - version = 0 <nl> - <nl> - <nl> - net = get_resnet ( version , opt . resnet_layers , classes , opt . thumbnail ) <nl> - <nl> - batch_size * = max ( 1 , gpus ) <nl> - <nl> - # get dataset iterators <nl> - if dataset = = ' mnist ' : <nl> - train_data , val_data = mnist_iterator ( batch_size , ( 1 , 32 , 32 ) ) <nl> - elif dataset = = ' cifar10 ' : <nl> - train_data , val_data = cifar10_iterator ( batch_size , ( 3 , 32 , 32 ) ) <nl> - elif dataset = = ' dummy ' : <nl> - train_data , val_data = dummy_iterator ( batch_size , ( 3 , 224 , 224 ) ) <nl> - <nl> - def test ( ctx ) : <nl> - metric = mx . metric . Accuracy ( ) <nl> - val_data . reset ( ) <nl> - for batch in val_data : <nl> - data = gluon . utils . split_and_load ( batch . data [ 0 ] , ctx_list = ctx , batch_axis = 0 ) <nl> - label = gluon . utils . split_and_load ( batch . label [ 0 ] , ctx_list = ctx , batch_axis = 0 ) <nl> - outputs = [ ] <nl> - for x in data : <nl> - outputs . append ( net ( x ) ) <nl> - metric . update ( label , outputs ) <nl> - return metric . get ( ) <nl> - <nl> - <nl> - def train ( epoch , ctx ) : <nl> - if isinstance ( ctx , mx . Context ) : <nl> - ctx = [ ctx ] <nl> - net . collect_params ( ) . initialize ( mx . init . Xavier ( magnitude = 2 . 24 ) , ctx = ctx ) <nl> - trainer = gluon . Trainer ( net . collect_params ( ) , ' sgd ' , { ' learning_rate ' : 0 . 1 } ) <nl> - metric = mx . metric . Accuracy ( ) <nl> - loss = gluon . loss . SoftmaxCrossEntropyLoss ( ) <nl> - <nl> - for epoch in range ( epoch ) : <nl> - tic = time . time ( ) <nl> - train_data . reset ( ) <nl> - metric . reset ( ) <nl> - btic = time . time ( ) <nl> - for i , batch in enumerate ( train_data ) : <nl> - data = gluon . utils . split_and_load ( batch . data [ 0 ] , ctx_list = ctx , batch_axis = 0 ) <nl> - label = gluon . utils . split_and_load ( batch . label [ 0 ] , ctx_list = ctx , batch_axis = 0 ) <nl> - outputs = [ ] <nl> - Ls = [ ] <nl> - with ag . record ( ) : <nl> - for x , y in zip ( data , label ) : <nl> - z = net ( x ) <nl> - L = loss ( z , y ) <nl> - # store the loss and do backward after we have done forward <nl> - # on all GPUs for better speed on multiple GPUs . <nl> - Ls . append ( L ) <nl> - outputs . append ( z ) <nl> - for L in Ls : <nl> - L . backward ( ) <nl> - trainer . step ( batch . data [ 0 ] . shape [ 0 ] ) <nl> - metric . update ( label , outputs ) <nl> - if opt . log_interval : <nl> - name , acc = metric . get ( ) <nl> - print ( ' [ Epoch % d Batch % d ] speed : % f samples / s , training : % s = % f ' % ( <nl> - epoch , i , batch_size / ( time . time ( ) - btic ) , name , acc ) ) <nl> - btic = time . time ( ) <nl> - <nl> - name , acc = metric . get ( ) <nl> - print ( ' [ Epoch % d ] training : % s = % f ' % ( epoch , name , acc ) ) <nl> - print ( ' [ Epoch % d ] time cost : % f ' % ( epoch , time . time ( ) - tic ) ) <nl> - <nl> - name , val_acc = test ( ctx ) <nl> - print ( ' [ Epoch % d ] validation : % s = % f ' % ( epoch , name , val_acc ) ) <nl> - <nl> - net . collect_params ( ) . save ( ' resnet . params ' ) <nl> - <nl> - <nl> - if __name__ = = ' __main__ ' : <nl> - if opt . symbolic : <nl> - data = mx . sym . var ( ' data ' ) <nl> - out = net ( data ) <nl> - softmax = mx . sym . SoftmaxOutput ( out , name = ' softmax ' ) <nl> - mod = mx . mod . Module ( softmax , context = [ mx . gpu ( i ) for i in range ( gpus ) ] if gpus > 0 else [ mx . cpu ( ) ] ) <nl> - mod . fit ( train_data , num_epoch = opt . epochs , batch_end_callback = mx . callback . Speedometer ( batch_size , 1 ) ) <nl> - else : <nl> - net . hybridize ( ) <nl> - train ( opt . epochs , [ mx . gpu ( i ) for i in range ( gpus ) ] if gpus > 0 else [ mx . cpu ( ) ] ) <nl> mmm a / python / mxnet / gluon / __init__ . py <nl> ppp b / python / mxnet / gluon / __init__ . py <nl> <nl> from . import utils <nl> <nl> from . import data <nl> + <nl> + from . import model_zoo <nl> new file mode 100644 <nl> index 00000000000 . . aa5f148513b <nl> mmm / dev / null <nl> ppp b / python / mxnet / gluon / model_zoo / __init__ . py <nl> <nl> + # coding : utf - 8 <nl> + " " " Predefined and pretrained models . " " " <nl> + <nl> + from . import model_store <nl> + <nl> + from . import vision <nl> new file mode 100644 <nl> index 00000000000 . . 871cfb061e2 <nl> mmm / dev / null <nl> ppp b / python / mxnet / gluon / model_zoo / custom_layers . py <nl> <nl> + # coding : utf - 8 <nl> + # pylint : disable = arguments - differ <nl> + " " " Custom neural network layers in model_zoo . " " " <nl> + <nl> + from . . block import Block , HybridBlock <nl> + <nl> + class HybridConcurrent ( HybridBlock ) : <nl> + " " " Lays ` HybridBlock ` s concurrently . <nl> + <nl> + Example : : <nl> + <nl> + net = HybridConcurrent ( ) <nl> + # use net ' s name_scope to give child Blocks appropriate names . <nl> + with net . name_scope ( ) : <nl> + net . add ( nn . Dense ( 10 , activation = ' relu ' ) ) <nl> + net . add ( nn . Dense ( 20 ) ) <nl> + net . add ( Identity ( ) ) <nl> + " " " <nl> + def __init__ ( self , concat_dim , prefix = None , params = None ) : <nl> + super ( HybridConcurrent , self ) . __init__ ( prefix = prefix , params = params ) <nl> + self . concat_dim = concat_dim <nl> + <nl> + def add ( self , block ) : <nl> + " " " Adds block on top of the stack . " " " <nl> + self . register_child ( block ) <nl> + <nl> + def hybrid_forward ( self , F , x ) : <nl> + out = [ ] <nl> + for block in self . _children : <nl> + out . append ( block ( x ) ) <nl> + out = F . concat ( * out , dim = self . concat_dim ) <nl> + return out <nl> + <nl> + def __repr__ ( self ) : <nl> + s = ' { name } ( \ n { modstr } \ n ) ' <nl> + modstr = ' \ n ' . join ( [ ' ( { key } ) : { block } ' . format ( key = key , <nl> + block = _indent ( block . __repr__ ( ) , 2 ) ) <nl> + for key , block in enumerate ( self . _children ) <nl> + if isinstance ( block , Block ) ] ) <nl> + return s . format ( name = self . __class__ . __name__ , <nl> + modstr = modstr ) <nl> + <nl> + <nl> + class Identity ( HybridBlock ) : <nl> + " " " Block that passes through the input directly . <nl> + <nl> + This layer is often used in conjunction with HybridConcurrent <nl> + block for residual connection . <nl> + <nl> + Example : : <nl> + <nl> + net = HybridConcurrent ( ) <nl> + # use net ' s name_scope to give child Blocks appropriate names . <nl> + with net . name_scope ( ) : <nl> + net . add ( nn . Dense ( 10 , activation = ' relu ' ) ) <nl> + net . add ( nn . Dense ( 20 ) ) <nl> + net . add ( Identity ( ) ) <nl> + " " " <nl> + def __init__ ( self , prefix = None , params = None ) : <nl> + super ( Identity , self ) . __init__ ( prefix = prefix , params = params ) <nl> + <nl> + def hybrid_forward ( self , F , x ) : <nl> + return x <nl> new file mode 100644 <nl> index 00000000000 . . 6a11626795f <nl> mmm / dev / null <nl> ppp b / python / mxnet / gluon / model_zoo / model_store . py <nl> <nl> + # coding : utf - 8 <nl> + " " " Model zoo for pre - trained models . " " " <nl> + from __future__ import print_function <nl> + __all__ = [ ' get_model_file ' , ' purge ' ] <nl> + import hashlib <nl> + import os <nl> + import zipfile <nl> + <nl> + from . . . test_utils import download <nl> + <nl> + _model_sha1 = { name : checksum for checksum , name in [ <nl> + ( ' 44335d1f0046b328243b32a26a4fbd62d9057b45 ' , ' alexnet ' ) , <nl> + ( ' f27dbf2dbd5ce9a80b102d89c7483342cd33cb31 ' , ' densenet121 ' ) , <nl> + ( ' b6c8a95717e3e761bd88d145f4d0a214aaa515dc ' , ' densenet161 ' ) , <nl> + ( ' 2603f878403c6aa5a71a124c4a3307143d6820e9 ' , ' densenet169 ' ) , <nl> + ( ' 1cdbc116bc3a1b65832b18cf53e1cb8e7da017eb ' , ' densenet201 ' ) , <nl> + ( ' ed47ec45a937b656fcc94dabde85495bbef5ba1f ' , ' inceptionv3 ' ) , <nl> + ( ' d2b128fa89477c2e20061607a53a8d9f66ce239d ' , ' resnet101_v1 ' ) , <nl> + ( ' 6562166cd597a6328a32a0ce47bb651df80b3bbb ' , ' resnet152_v1 ' ) , <nl> + ( ' 38d6d423c22828718ec3397924b8e116a03e6ac0 ' , ' resnet18_v1 ' ) , <nl> + ( ' 4dc2c2390a7c7990e0ca1e53aeebb1d1a08592d1 ' , ' resnet34_v1 ' ) , <nl> + ( ' 2a903ab21260c85673a78fe65037819a843a1f43 ' , ' resnet50_v1 ' ) , <nl> + ( ' 264ba4970a0cc87a4f15c96e25246a1307caf523 ' , ' squeezenet1 . 0 ' ) , <nl> + ( ' 33ba0f93753c83d86e1eb397f38a667eaf2e9376 ' , ' squeezenet1 . 1 ' ) , <nl> + ( ' dd221b160977f36a53f464cb54648d227c707a05 ' , ' vgg11 ' ) , <nl> + ( ' ee79a8098a91fbe05b7a973fed2017a6117723a8 ' , ' vgg11_bn ' ) , <nl> + ( ' 6bc5de58a05a5e2e7f493e2d75a580d83efde38c ' , ' vgg13 ' ) , <nl> + ( ' 7d97a06c3c7a1aecc88b6e7385c2b373a249e95e ' , ' vgg13_bn ' ) , <nl> + ( ' 649467530119c0f78c4859999e264e7bf14471a9 ' , ' vgg16 ' ) , <nl> + ( ' 6b9dbe6194e5bfed30fd7a7c9a71f7e5a276cb14 ' , ' vgg16_bn ' ) , <nl> + ( ' f713436691eee9a20d70a145ce0d53ed24bf7399 ' , ' vgg19 ' ) , <nl> + ( ' 9730961c9cea43fd7eeefb00d792e386c45847d6 ' , ' vgg19_bn ' ) ] } <nl> + <nl> + _url_format = ' https : / / { bucket } . s3 . amazonaws . com / gluon / models / { file_name } . zip ' <nl> + bucket = ' apache - mxnet ' <nl> + <nl> + def short_hash ( name ) : <nl> + if name not in _model_sha1 : <nl> + raise ValueError ( ' Pretrained model for { name } is not available . ' . format ( name = name ) ) <nl> + return _model_sha1 [ name ] [ : 8 ] <nl> + <nl> + def verified ( file_path , name ) : <nl> + sha1 = hashlib . sha1 ( ) <nl> + with open ( file_path , ' rb ' ) as f : <nl> + while True : <nl> + data = f . read ( 1048576 ) <nl> + if not data : <nl> + break <nl> + sha1 . update ( data ) <nl> + <nl> + return sha1 . hexdigest ( ) = = _model_sha1 [ name ] <nl> + <nl> + def get_model_file ( name , local_dir = os . path . expanduser ( ' ~ / . mxnet / models / ' ) ) : <nl> + r " " " Return location for the pretrained on local file system . <nl> + <nl> + This function will download from online model zoo when model cannot be found or has mismatch . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + name : str <nl> + Name of the model . <nl> + local_dir : str , default ' ~ / . mxnet / models ' <nl> + Location for keeping the model parameters . <nl> + <nl> + Returns <nl> + mmmmmm - <nl> + file_path <nl> + Path to the requested pretrained model file . <nl> + " " " <nl> + file_name = ' { name } - { short_hash } ' . format ( name = name , <nl> + short_hash = short_hash ( name ) ) <nl> + file_path = os . path . join ( local_dir , file_name + ' . params ' ) <nl> + if os . path . exists ( file_path ) : <nl> + if verified ( file_path , name ) : <nl> + return file_path <nl> + else : <nl> + print ( ' Mismatch in the content of model file detected . Downloading again . ' ) <nl> + else : <nl> + print ( ' Model file is not found . Downloading . ' ) <nl> + <nl> + if not os . path . exists ( local_dir ) : <nl> + os . makedirs ( local_dir ) <nl> + <nl> + download ( _url_format . format ( bucket = bucket , <nl> + file_name = file_name ) , <nl> + fname = file_name + ' . zip ' , <nl> + dirname = local_dir , <nl> + overwrite = True ) <nl> + zip_file_path = os . path . join ( local_dir , file_name + ' . zip ' ) <nl> + with zipfile . ZipFile ( zip_file_path ) as zf : <nl> + zf . extractall ( local_dir ) <nl> + os . remove ( zip_file_path ) <nl> + <nl> + if verified ( file_path , name ) : <nl> + return file_path <nl> + else : <nl> + raise ValueError ( ' Downloaded file has different hash . Please try again . ' ) <nl> + <nl> + def purge ( local_dir = os . path . expanduser ( ' ~ / . mxnet / models / ' ) ) : <nl> + r " " " Purge all pretrained model files in local file store . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + local_dir : str , default ' ~ / . mxnet / models ' <nl> + Location for keeping the model parameters . <nl> + " " " <nl> + files = os . listdir ( local_dir ) <nl> + for f in files : <nl> + if f . endswith ( " . params " ) : <nl> + os . remove ( os . path . join ( local_dir , f ) ) <nl> new file mode 100644 <nl> index 00000000000 . . e0498dcc6bc <nl> mmm / dev / null <nl> ppp b / python / mxnet / gluon / model_zoo / vision / __init__ . py <nl> <nl> + # coding : utf - 8 <nl> + # pylint : disable = wildcard - import , arguments - differ <nl> + r " " " Module for pre - defined neural network models . <nl> + This module contains definitions for the following model architectures : <nl> + - ` AlexNet ` _ <nl> + - ` DenseNet ` _ <nl> + - ` Inception V3 ` _ <nl> + - ` ResNet V1 ` _ <nl> + - ` ResNet V2 ` _ <nl> + - ` SqueezeNet ` _ <nl> + - ` VGG ` _ <nl> + You can construct a model with random weights by calling its constructor : <nl> + . . code : : python <nl> + import mxnet . gluon . models as models <nl> + resnet18 = models . resnet18_v1 ( ) <nl> + alexnet = models . alexnet ( ) <nl> + squeezenet = models . squeezenet1_0 ( ) <nl> + densenet = models . densenet_161 ( ) <nl> + We provide pre - trained models for all the models except ResNet V2 . <nl> + These can constructed by passing <nl> + ` ` pretrained = True ` ` : <nl> + . . code : : python <nl> + import mxnet . gluon . models as models <nl> + resnet18 = models . resnet18_v1 ( pretrained = True ) <nl> + alexnet = models . alexnet ( pretrained = True ) <nl> + Pretrained model is converted from torchvision . <nl> + All pre - trained models expect input images normalized in the same way , <nl> + i . e . mini - batches of 3 - channel RGB images of shape ( N x 3 x H x W ) , <nl> + where N is the batch size , and H and W are expected to be at least 224 . <nl> + The images have to be loaded in to a range of [ 0 , 1 ] and then normalized <nl> + using ` ` mean = [ 0 . 485 , 0 . 456 , 0 . 406 ] ` ` and ` ` std = [ 0 . 229 , 0 . 224 , 0 . 225 ] ` ` . <nl> + The transformation should preferrably happen at preprocessing . You can use <nl> + ` ` mx . image . color_normalize ` ` for such transformation : : <nl> + image = image / 255 <nl> + normalized = mx . image . color_normalize ( image , <nl> + mean = mx . nd . array ( [ 0 . 485 , 0 . 456 , 0 . 406 ] ) , <nl> + std = mx . nd . array ( [ 0 . 229 , 0 . 224 , 0 . 225 ] ) ) <nl> + <nl> + . . _AlexNet : https : / / arxiv . org / abs / 1404 . 5997 <nl> + . . _DenseNet : https : / / arxiv . org / abs / 1608 . 06993 <nl> + . . _Inception V3 : http : / / arxiv . org / abs / 1512 . 00567 <nl> + . . _ResNet V1 : https : / / arxiv . org / abs / 1512 . 03385 <nl> + . . _ResNet V2 : https : / / arxiv . org / abs / 1512 . 03385 <nl> + . . _SqueezeNet : https : / / arxiv . org / abs / 1602 . 07360 <nl> + . . _VGG : https : / / arxiv . org / abs / 1409 . 1556 <nl> + " " " <nl> + <nl> + from . alexnet import * <nl> + <nl> + from . densenet import * <nl> + <nl> + from . inception import * <nl> + <nl> + from . resnet import * <nl> + <nl> + from . squeezenet import * <nl> + <nl> + from . vgg import * <nl> + <nl> + def get_model ( name , * * kwargs ) : <nl> + " " " Returns a pre - defined model by name <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + name : str <nl> + Name of the model . <nl> + pretrained : bool <nl> + Whether to load the pretrained weights for model . <nl> + classes : int <nl> + Number of classes for the output layer . <nl> + <nl> + Returns <nl> + mmmmmm - <nl> + HybridBlock <nl> + The model . <nl> + " " " <nl> + models = { ' resnet18_v1 ' : resnet18_v1 , <nl> + ' resnet34_v1 ' : resnet34_v1 , <nl> + ' resnet50_v1 ' : resnet50_v1 , <nl> + ' resnet101_v1 ' : resnet101_v1 , <nl> + ' resnet152_v1 ' : resnet152_v1 , <nl> + ' resnet18_v2 ' : resnet18_v2 , <nl> + ' resnet34_v2 ' : resnet34_v2 , <nl> + ' resnet50_v2 ' : resnet50_v2 , <nl> + ' resnet101_v2 ' : resnet101_v2 , <nl> + ' resnet152_v2 ' : resnet152_v2 , <nl> + ' vgg11 ' : vgg11 , <nl> + ' vgg13 ' : vgg13 , <nl> + ' vgg16 ' : vgg16 , <nl> + ' vgg19 ' : vgg19 , <nl> + ' vgg11_bn ' : vgg11_bn , <nl> + ' vgg13_bn ' : vgg13_bn , <nl> + ' vgg16_bn ' : vgg16_bn , <nl> + ' vgg19_bn ' : vgg19_bn , <nl> + ' alexnet ' : alexnet , <nl> + ' densenet121 ' : densenet121 , <nl> + ' densenet161 ' : densenet161 , <nl> + ' densenet169 ' : densenet169 , <nl> + ' densenet201 ' : densenet201 , <nl> + ' squeezenet1 . 0 ' : squeezenet1_0 , <nl> + ' squeezenet1 . 1 ' : squeezenet1_1 , <nl> + ' inceptionv3 ' : inception_v3 , <nl> + } <nl> + name = name . lower ( ) <nl> + assert name in models , ' Model % s is not supported ' % name <nl> + return models [ name ] ( * * kwargs ) <nl> new file mode 100644 <nl> index 00000000000 . . dd5104d062f <nl> mmm / dev / null <nl> ppp b / python / mxnet / gluon / model_zoo / vision / alexnet . py <nl> <nl> + # coding : utf - 8 <nl> + # pylint : disable = arguments - differ <nl> + " " " Alexnet , implemented in Gluon . " " " <nl> + __all__ = [ ' AlexNet ' , ' alexnet ' ] <nl> + <nl> + from . . . . context import cpu <nl> + from . . . block import HybridBlock <nl> + from . . . import nn <nl> + <nl> + # Net <nl> + class AlexNet ( HybridBlock ) : <nl> + r " " " AlexNet model from the ` " One weird trick . . . " < https : / / arxiv . org / abs / 1404 . 5997 > ` _ paper . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + classes : int , default 1000 <nl> + Number of classes for the output layer . <nl> + " " " <nl> + def __init__ ( self , classes = 1000 , * * kwargs ) : <nl> + super ( AlexNet , self ) . __init__ ( * * kwargs ) <nl> + with self . name_scope ( ) : <nl> + self . features = nn . HybridSequential ( prefix = ' ' ) <nl> + with self . features . name_scope ( ) : <nl> + self . features . add ( nn . Conv2D ( 64 , kernel_size = 11 , strides = 4 , padding = 2 ) ) <nl> + self . features . add ( nn . Activation ( ' relu ' ) ) <nl> + self . features . add ( nn . MaxPool2D ( pool_size = 3 , strides = 2 ) ) <nl> + self . features . add ( nn . Conv2D ( 192 , kernel_size = 5 , padding = 2 ) ) <nl> + self . features . add ( nn . Activation ( ' relu ' ) ) <nl> + self . features . add ( nn . MaxPool2D ( pool_size = 3 , strides = 2 ) ) <nl> + self . features . add ( nn . Conv2D ( 384 , kernel_size = 3 , padding = 1 ) ) <nl> + self . features . add ( nn . Activation ( ' relu ' ) ) <nl> + self . features . add ( nn . Conv2D ( 256 , kernel_size = 3 , padding = 1 ) ) <nl> + self . features . add ( nn . Activation ( ' relu ' ) ) <nl> + self . features . add ( nn . Conv2D ( 256 , kernel_size = 3 , padding = 1 ) ) <nl> + self . features . add ( nn . Activation ( ' relu ' ) ) <nl> + self . features . add ( nn . MaxPool2D ( pool_size = 3 , strides = 2 ) ) <nl> + self . features . add ( nn . Flatten ( ) ) <nl> + <nl> + self . classifier = nn . HybridSequential ( prefix = ' ' ) <nl> + with self . classifier . name_scope ( ) : <nl> + self . classifier . add ( nn . Dropout ( 0 . 5 ) ) <nl> + self . classifier . add ( nn . Dense ( 4096 , activation = ' relu ' ) ) <nl> + self . classifier . add ( nn . Dropout ( 0 . 5 ) ) <nl> + self . classifier . add ( nn . Dense ( 4096 , activation = ' relu ' ) ) <nl> + self . classifier . add ( nn . Dense ( classes ) ) <nl> + <nl> + def hybrid_forward ( self , F , x ) : <nl> + x = self . features ( x ) <nl> + x = self . classifier ( x ) <nl> + return x <nl> + <nl> + # Constructor <nl> + def alexnet ( pretrained = False , ctx = cpu ( ) , * * kwargs ) : <nl> + r " " " AlexNet model from the ` " One weird trick . . . " < https : / / arxiv . org / abs / 1404 . 5997 > ` _ paper . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + pretrained : bool , default False <nl> + Whether to load the pretrained weights for model . <nl> + ctx : Context , default CPU <nl> + The context in which to load the pretrained weights . <nl> + " " " <nl> + net = AlexNet ( * * kwargs ) <nl> + if pretrained : <nl> + from . . model_store import get_model_file <nl> + net . load_params ( get_model_file ( ' alexnet ' ) , ctx = ctx ) <nl> + return net <nl> new file mode 100644 <nl> index 00000000000 . . 9e1ff779989 <nl> mmm / dev / null <nl> ppp b / python / mxnet / gluon / model_zoo / vision / densenet . py <nl> <nl> + # coding : utf - 8 <nl> + # pylint : disable = arguments - differ <nl> + " " " DenseNet , implemented in Gluon . " " " <nl> + __all__ = [ ' DenseNet ' , ' densenet121 ' , ' densenet161 ' , ' densenet169 ' , ' densenet201 ' ] <nl> + <nl> + from . . . . context import cpu <nl> + from . . . block import HybridBlock <nl> + from . . . import nn <nl> + from . . custom_layers import HybridConcurrent , Identity <nl> + <nl> + # Helpers <nl> + def _make_dense_block ( num_layers , bn_size , growth_rate , dropout , stage_index ) : <nl> + out = nn . HybridSequential ( prefix = ' stage % d_ ' % stage_index ) <nl> + with out . name_scope ( ) : <nl> + for _ in range ( num_layers ) : <nl> + out . add ( _make_dense_layer ( growth_rate , bn_size , dropout ) ) <nl> + return out <nl> + <nl> + def _make_dense_layer ( growth_rate , bn_size , dropout ) : <nl> + new_features = nn . HybridSequential ( prefix = ' ' ) <nl> + new_features . add ( nn . BatchNorm ( ) ) <nl> + new_features . add ( nn . Activation ( ' relu ' ) ) <nl> + new_features . add ( nn . Conv2D ( bn_size * growth_rate , kernel_size = 1 , use_bias = False ) ) <nl> + new_features . add ( nn . BatchNorm ( ) ) <nl> + new_features . add ( nn . Activation ( ' relu ' ) ) <nl> + new_features . add ( nn . Conv2D ( growth_rate , kernel_size = 3 , padding = 1 , use_bias = False ) ) <nl> + if dropout : <nl> + new_features . add ( nn . Dropout ( dropout ) ) <nl> + <nl> + out = HybridConcurrent ( concat_dim = 1 , prefix = ' ' ) <nl> + out . add ( Identity ( ) ) <nl> + out . add ( new_features ) <nl> + <nl> + return out <nl> + <nl> + def _make_transition ( num_output_features ) : <nl> + out = nn . HybridSequential ( prefix = ' ' ) <nl> + out . add ( nn . BatchNorm ( ) ) <nl> + out . add ( nn . Activation ( ' relu ' ) ) <nl> + out . add ( nn . Conv2D ( num_output_features , kernel_size = 1 , use_bias = False ) ) <nl> + out . add ( nn . AvgPool2D ( pool_size = 2 , strides = 2 ) ) <nl> + return out <nl> + <nl> + # Net <nl> + class DenseNet ( HybridBlock ) : <nl> + r " " " Densenet - BC model from the <nl> + ` " Densely Connected Convolutional Networks " < https : / / arxiv . org / pdf / 1608 . 06993 . pdf > ` _ paper . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + num_init_features : int <nl> + Number of filters to learn in the first convolution layer . <nl> + growth_rate : int <nl> + Number of filters to add each layer ( ` k ` in the paper ) . <nl> + block_config : list of int <nl> + List of integers for numbers of layers in each pooling block . <nl> + bn_size : int , default 4 <nl> + Multiplicative factor for number of bottle neck layers . <nl> + ( i . e . bn_size * k features in the bottleneck layer ) <nl> + dropout : float , default 0 <nl> + Rate of dropout after each dense layer . <nl> + classes : int , default 1000 <nl> + Number of classification classes . <nl> + " " " <nl> + def __init__ ( self , num_init_features , growth_rate , block_config , <nl> + bn_size = 4 , dropout = 0 , classes = 1000 , * * kwargs ) : <nl> + <nl> + super ( DenseNet , self ) . __init__ ( * * kwargs ) <nl> + with self . name_scope ( ) : <nl> + self . features = nn . HybridSequential ( prefix = ' ' ) <nl> + self . features . add ( nn . Conv2D ( num_init_features , kernel_size = 7 , <nl> + strides = 2 , padding = 3 , use_bias = False ) ) <nl> + self . features . add ( nn . BatchNorm ( ) ) <nl> + self . features . add ( nn . Activation ( ' relu ' ) ) <nl> + self . features . add ( nn . MaxPool2D ( pool_size = 3 , strides = 2 , padding = 1 ) ) <nl> + # Add dense blocks <nl> + num_features = num_init_features <nl> + for i , num_layers in enumerate ( block_config ) : <nl> + self . features . add ( _make_dense_block ( num_layers , bn_size , growth_rate , dropout , i + 1 ) ) <nl> + num_features = num_features + num_layers * growth_rate <nl> + if i ! = len ( block_config ) - 1 : <nl> + self . features . add ( _make_transition ( num_features / / 2 ) ) <nl> + num_features = num_features / / 2 <nl> + self . features . add ( nn . BatchNorm ( ) ) <nl> + self . features . add ( nn . Activation ( ' relu ' ) ) <nl> + self . features . add ( nn . AvgPool2D ( pool_size = 7 ) ) <nl> + self . features . add ( nn . Flatten ( ) ) <nl> + <nl> + self . classifier = nn . Dense ( classes ) <nl> + <nl> + def hybrid_forward ( self , F , x ) : <nl> + x = self . features ( x ) <nl> + x = self . classifier ( x ) <nl> + return x <nl> + <nl> + <nl> + # Specification <nl> + densenet_spec = { 121 : ( 64 , 32 , [ 6 , 12 , 24 , 16 ] ) , <nl> + 161 : ( 96 , 48 , [ 6 , 12 , 36 , 24 ] ) , <nl> + 169 : ( 64 , 32 , [ 6 , 12 , 32 , 32 ] ) , <nl> + 201 : ( 64 , 32 , [ 6 , 12 , 48 , 32 ] ) } <nl> + <nl> + <nl> + # Constructor <nl> + def get_densenet ( num_layers , pretrained = False , ctx = cpu ( ) , * * kwargs ) : <nl> + r " " " Densenet - BC model from the <nl> + ` " Densely Connected Convolutional Networks " < https : / / arxiv . org / pdf / 1608 . 06993 . pdf > ` _ paper . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + num_layers : int <nl> + Number of layers for the variant of densenet . Options are 121 , 161 , 169 , 201 . <nl> + pretrained : bool , default False <nl> + Whether to load the pretrained weights for model . <nl> + ctx : Context , default CPU <nl> + The context in which to load the pretrained weights . <nl> + " " " <nl> + num_init_features , growth_rate , block_config = densenet_spec [ num_layers ] <nl> + net = DenseNet ( num_init_features , growth_rate , block_config , * * kwargs ) <nl> + if pretrained : <nl> + from . . model_store import get_model_file <nl> + net . load_params ( get_model_file ( ' densenet % d ' % ( num_layers ) ) , ctx = ctx ) <nl> + return net <nl> + <nl> + def densenet121 ( * * kwargs ) : <nl> + r " " " Densenet - BC 121 - layer model from the <nl> + ` " Densely Connected Convolutional Networks " < https : / / arxiv . org / pdf / 1608 . 06993 . pdf > ` _ paper . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + pretrained : bool , default False <nl> + Whether to load the pretrained weights for model . <nl> + ctx : Context , default CPU <nl> + The context in which to load the pretrained weights . <nl> + " " " <nl> + return get_densenet ( 121 , * * kwargs ) <nl> + <nl> + def densenet161 ( * * kwargs ) : <nl> + r " " " Densenet - BC 161 - layer model from the <nl> + ` " Densely Connected Convolutional Networks " < https : / / arxiv . org / pdf / 1608 . 06993 . pdf > ` _ paper . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + pretrained : bool , default False <nl> + Whether to load the pretrained weights for model . <nl> + ctx : Context , default CPU <nl> + The context in which to load the pretrained weights . <nl> + " " " <nl> + return get_densenet ( 161 , * * kwargs ) <nl> + <nl> + def densenet169 ( * * kwargs ) : <nl> + r " " " Densenet - BC 169 - layer model from the <nl> + ` " Densely Connected Convolutional Networks " < https : / / arxiv . org / pdf / 1608 . 06993 . pdf > ` _ paper . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + pretrained : bool , default False <nl> + Whether to load the pretrained weights for model . <nl> + ctx : Context , default CPU <nl> + The context in which to load the pretrained weights . <nl> + " " " <nl> + return get_densenet ( 169 , * * kwargs ) <nl> + <nl> + def densenet201 ( * * kwargs ) : <nl> + r " " " Densenet - BC 201 - layer model from the <nl> + ` " Densely Connected Convolutional Networks " < https : / / arxiv . org / pdf / 1608 . 06993 . pdf > ` _ paper . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + pretrained : bool , default False <nl> + Whether to load the pretrained weights for model . <nl> + ctx : Context , default CPU <nl> + The context in which to load the pretrained weights . <nl> + " " " <nl> + return get_densenet ( 201 , * * kwargs ) <nl> new file mode 100644 <nl> index 00000000000 . . 8a28666d56c <nl> mmm / dev / null <nl> ppp b / python / mxnet / gluon / model_zoo / vision / inception . py <nl> <nl> + # coding : utf - 8 <nl> + # pylint : disable = arguments - differ <nl> + " " " Inception , implemented in Gluon . " " " <nl> + __all__ = [ ' Inception3 ' , ' inception_v3 ' ] <nl> + <nl> + from . . . . context import cpu <nl> + from . . . block import HybridBlock <nl> + from . . . import nn <nl> + from . . custom_layers import HybridConcurrent <nl> + <nl> + # Helpers <nl> + def _make_basic_conv ( * * kwargs ) : <nl> + out = nn . HybridSequential ( prefix = ' ' ) <nl> + out . add ( nn . Conv2D ( use_bias = False , * * kwargs ) ) <nl> + out . add ( nn . BatchNorm ( epsilon = 0 . 001 ) ) <nl> + out . add ( nn . Activation ( ' relu ' ) ) <nl> + return out <nl> + <nl> + def _make_branch ( use_pool , * conv_settings ) : <nl> + out = nn . HybridSequential ( prefix = ' ' ) <nl> + if use_pool = = ' avg ' : <nl> + out . add ( nn . AvgPool2D ( pool_size = 3 , strides = 1 , padding = 1 ) ) <nl> + elif use_pool = = ' max ' : <nl> + out . add ( nn . MaxPool2D ( pool_size = 3 , strides = 2 ) ) <nl> + setting_names = [ ' channels ' , ' kernel_size ' , ' strides ' , ' padding ' ] <nl> + for setting in conv_settings : <nl> + kwargs = { } <nl> + for i , value in enumerate ( setting ) : <nl> + if value is not None : <nl> + kwargs [ setting_names [ i ] ] = value <nl> + out . add ( _make_basic_conv ( * * kwargs ) ) <nl> + return out <nl> + <nl> + def _make_A ( pool_features , prefix ) : <nl> + out = HybridConcurrent ( concat_dim = 1 , prefix = prefix ) <nl> + with out . name_scope ( ) : <nl> + out . add ( _make_branch ( None , <nl> + ( 64 , 1 , None , None ) ) ) <nl> + out . add ( _make_branch ( None , <nl> + ( 48 , 1 , None , None ) , <nl> + ( 64 , 5 , None , 2 ) ) ) <nl> + out . add ( _make_branch ( None , <nl> + ( 64 , 1 , None , None ) , <nl> + ( 96 , 3 , None , 1 ) , <nl> + ( 96 , 3 , None , 1 ) ) ) <nl> + out . add ( _make_branch ( ' avg ' , <nl> + ( pool_features , 1 , None , None ) ) ) <nl> + return out <nl> + <nl> + def _make_B ( prefix ) : <nl> + out = HybridConcurrent ( concat_dim = 1 , prefix = prefix ) <nl> + with out . name_scope ( ) : <nl> + out . add ( _make_branch ( None , <nl> + ( 384 , 3 , 2 , None ) ) ) <nl> + out . add ( _make_branch ( None , <nl> + ( 64 , 1 , None , None ) , <nl> + ( 96 , 3 , None , 1 ) , <nl> + ( 96 , 3 , 2 , None ) ) ) <nl> + out . add ( _make_branch ( ' max ' ) ) <nl> + return out <nl> + <nl> + def _make_C ( channels_7x7 , prefix ) : <nl> + out = HybridConcurrent ( concat_dim = 1 , prefix = prefix ) <nl> + with out . name_scope ( ) : <nl> + out . add ( _make_branch ( None , <nl> + ( 192 , 1 , None , None ) ) ) <nl> + out . add ( _make_branch ( None , <nl> + ( channels_7x7 , 1 , None , None ) , <nl> + ( channels_7x7 , ( 1 , 7 ) , None , ( 0 , 3 ) ) , <nl> + ( 192 , ( 7 , 1 ) , None , ( 3 , 0 ) ) ) ) <nl> + out . add ( _make_branch ( None , <nl> + ( channels_7x7 , 1 , None , None ) , <nl> + ( channels_7x7 , ( 7 , 1 ) , None , ( 3 , 0 ) ) , <nl> + ( channels_7x7 , ( 1 , 7 ) , None , ( 0 , 3 ) ) , <nl> + ( channels_7x7 , ( 7 , 1 ) , None , ( 3 , 0 ) ) , <nl> + ( 192 , ( 1 , 7 ) , None , ( 0 , 3 ) ) ) ) <nl> + out . add ( _make_branch ( ' avg ' , <nl> + ( 192 , 1 , None , None ) ) ) <nl> + return out <nl> + <nl> + def _make_D ( prefix ) : <nl> + out = HybridConcurrent ( concat_dim = 1 , prefix = prefix ) <nl> + with out . name_scope ( ) : <nl> + out . add ( _make_branch ( None , <nl> + ( 192 , 1 , None , None ) , <nl> + ( 320 , 3 , 2 , None ) ) ) <nl> + out . add ( _make_branch ( None , <nl> + ( 192 , 1 , None , None ) , <nl> + ( 192 , ( 1 , 7 ) , None , ( 0 , 3 ) ) , <nl> + ( 192 , ( 7 , 1 ) , None , ( 3 , 0 ) ) , <nl> + ( 192 , 3 , 2 , None ) ) ) <nl> + out . add ( _make_branch ( ' max ' ) ) <nl> + return out <nl> + <nl> + def _make_E ( prefix ) : <nl> + out = HybridConcurrent ( concat_dim = 1 , prefix = prefix ) <nl> + with out . name_scope ( ) : <nl> + out . add ( _make_branch ( None , <nl> + ( 320 , 1 , None , None ) ) ) <nl> + <nl> + branch_3x3 = nn . HybridSequential ( prefix = ' ' ) <nl> + out . add ( branch_3x3 ) <nl> + branch_3x3 . add ( _make_branch ( None , <nl> + ( 384 , 1 , None , None ) ) ) <nl> + branch_3x3_split = HybridConcurrent ( concat_dim = 1 , prefix = ' ' ) <nl> + branch_3x3_split . add ( _make_branch ( None , <nl> + ( 384 , ( 1 , 3 ) , None , ( 0 , 1 ) ) ) ) <nl> + branch_3x3_split . add ( _make_branch ( None , <nl> + ( 384 , ( 3 , 1 ) , None , ( 1 , 0 ) ) ) ) <nl> + branch_3x3 . add ( branch_3x3_split ) <nl> + <nl> + branch_3x3dbl = nn . HybridSequential ( prefix = ' ' ) <nl> + out . add ( branch_3x3dbl ) <nl> + branch_3x3dbl . add ( _make_branch ( None , <nl> + ( 448 , 1 , None , None ) , <nl> + ( 384 , 3 , None , 1 ) ) ) <nl> + branch_3x3dbl_split = HybridConcurrent ( concat_dim = 1 , prefix = ' ' ) <nl> + branch_3x3dbl . add ( branch_3x3dbl_split ) <nl> + branch_3x3dbl_split . add ( _make_branch ( None , <nl> + ( 384 , ( 1 , 3 ) , None , ( 0 , 1 ) ) ) ) <nl> + branch_3x3dbl_split . add ( _make_branch ( None , <nl> + ( 384 , ( 3 , 1 ) , None , ( 1 , 0 ) ) ) ) <nl> + <nl> + out . add ( _make_branch ( ' avg ' , <nl> + ( 192 , 1 , None , None ) ) ) <nl> + return out <nl> + <nl> + def make_aux ( classes ) : <nl> + out = nn . HybridSequential ( prefix = ' ' ) <nl> + out . add ( nn . AvgPool2D ( pool_size = 5 , strides = 3 ) ) <nl> + out . add ( _make_basic_conv ( channels = 128 , kernel_size = 1 ) ) <nl> + out . add ( _make_basic_conv ( channels = 768 , kernel_size = 5 ) ) <nl> + out . add ( nn . Flatten ( ) ) <nl> + out . add ( nn . Dense ( classes ) ) <nl> + return out <nl> + <nl> + # Net <nl> + class Inception3 ( HybridBlock ) : <nl> + r " " " Inception v3 model from <nl> + ` " Rethinking the Inception Architecture for Computer Vision " <nl> + < http : / / arxiv . org / abs / 1512 . 00567 > ` _ paper . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + classes : int , default 1000 <nl> + Number of classification classes . <nl> + " " " <nl> + def __init__ ( self , classes = 1000 , * * kwargs ) : <nl> + super ( Inception3 , self ) . __init__ ( * * kwargs ) <nl> + # self . use_aux_logits = use_aux_logits <nl> + with self . name_scope ( ) : <nl> + self . features = nn . HybridSequential ( prefix = ' ' ) <nl> + self . features . add ( _make_basic_conv ( channels = 32 , kernel_size = 3 , strides = 2 ) ) <nl> + self . features . add ( _make_basic_conv ( channels = 32 , kernel_size = 3 ) ) <nl> + self . features . add ( _make_basic_conv ( channels = 64 , kernel_size = 3 , padding = 1 ) ) <nl> + self . features . add ( nn . MaxPool2D ( pool_size = 3 , strides = 2 ) ) <nl> + self . features . add ( _make_basic_conv ( channels = 80 , kernel_size = 1 ) ) <nl> + self . features . add ( _make_basic_conv ( channels = 192 , kernel_size = 3 ) ) <nl> + self . features . add ( nn . MaxPool2D ( pool_size = 3 , strides = 2 ) ) <nl> + self . features . add ( _make_A ( 32 , ' A1_ ' ) ) <nl> + self . features . add ( _make_A ( 64 , ' A2_ ' ) ) <nl> + self . features . add ( _make_A ( 64 , ' A3_ ' ) ) <nl> + self . features . add ( _make_B ( ' B_ ' ) ) <nl> + self . features . add ( _make_C ( 128 , ' C1_ ' ) ) <nl> + self . features . add ( _make_C ( 160 , ' C2_ ' ) ) <nl> + self . features . add ( _make_C ( 160 , ' C3_ ' ) ) <nl> + self . features . add ( _make_C ( 192 , ' C4_ ' ) ) <nl> + <nl> + self . classifier = nn . HybridSequential ( prefix = ' ' ) <nl> + self . classifier . add ( _make_D ( ' D_ ' ) ) <nl> + self . classifier . add ( _make_E ( ' E1_ ' ) ) <nl> + self . classifier . add ( _make_E ( ' E2_ ' ) ) <nl> + self . classifier . add ( nn . AvgPool2D ( pool_size = 8 ) ) <nl> + self . classifier . add ( nn . Dropout ( 0 . 5 ) ) <nl> + self . classifier . add ( nn . Flatten ( ) ) <nl> + self . classifier . add ( nn . Dense ( classes ) ) <nl> + <nl> + def hybrid_forward ( self , F , x ) : <nl> + x = self . features ( x ) <nl> + x = self . classifier ( x ) <nl> + return x <nl> + <nl> + # Constructor <nl> + def inception_v3 ( pretrained = False , ctx = cpu ( ) , * * kwargs ) : <nl> + r " " " Inception v3 model from <nl> + ` " Rethinking the Inception Architecture for Computer Vision " <nl> + < http : / / arxiv . org / abs / 1512 . 00567 > ` _ paper . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + pretrained : bool , default False <nl> + Whether to load the pretrained weights for model . <nl> + ctx : Context , default CPU <nl> + The context in which to load the pretrained weights . <nl> + " " " <nl> + net = Inception3 ( * * kwargs ) <nl> + if pretrained : <nl> + from . . model_store import get_model_file <nl> + net . load_params ( get_model_file ( ' inceptionv3 ' ) , ctx = ctx ) <nl> + return net <nl> new file mode 100644 <nl> index 00000000000 . . 2870911aa5c <nl> mmm / dev / null <nl> ppp b / python / mxnet / gluon / model_zoo / vision / resnet . py <nl> <nl> + # coding : utf - 8 <nl> + # pylint : disable = arguments - differ <nl> + " " " ResNets , implemented in Gluon . " " " <nl> + from __future__ import division <nl> + <nl> + __all__ = [ ' ResNetV1 ' , ' ResNetV2 ' , <nl> + ' resnet18_v1 ' , ' resnet34_v1 ' , ' resnet50_v1 ' , ' resnet101_v1 ' , ' resnet152_v1 ' , <nl> + ' resnet18_v2 ' , ' resnet34_v2 ' , ' resnet50_v2 ' , ' resnet101_v2 ' , ' resnet152_v2 ' , <nl> + ' get_resnet ' ] <nl> + <nl> + from . . . . context import cpu <nl> + from . . . block import HybridBlock <nl> + from . . . import nn <nl> + <nl> + # Helpers <nl> + def _conv3x3 ( channels , stride , in_channels ) : <nl> + return nn . Conv2D ( channels , kernel_size = 3 , strides = stride , padding = 1 , <nl> + use_bias = False , in_channels = in_channels ) <nl> + <nl> + <nl> + # Blocks <nl> + class BasicBlockV1 ( HybridBlock ) : <nl> + r " " " BasicBlock V1 from ` " Deep Residual Learning for Image Recognition " <nl> + < http : / / arxiv . org / abs / 1512 . 03385 > ` _ paper . <nl> + This is used for ResNet V1 for 18 , 34 layers . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + channels : int <nl> + Number of output channels . <nl> + stride : int <nl> + Stride size . <nl> + downsample : bool , default False <nl> + Whether to downsample the input . <nl> + in_channels : int , default 0 <nl> + Number of input channels . Default is 0 , to infer from the graph . <nl> + " " " <nl> + def __init__ ( self , channels , stride , downsample = False , in_channels = 0 , * * kwargs ) : <nl> + super ( BasicBlockV1 , self ) . __init__ ( * * kwargs ) <nl> + self . body = nn . HybridSequential ( prefix = ' ' ) <nl> + self . body . add ( _conv3x3 ( channels , stride , in_channels ) ) <nl> + self . body . add ( nn . BatchNorm ( ) ) <nl> + self . body . add ( nn . Activation ( ' relu ' ) ) <nl> + self . body . add ( _conv3x3 ( channels , 1 , channels ) ) <nl> + self . body . add ( nn . BatchNorm ( ) ) <nl> + if downsample : <nl> + self . downsample = nn . HybridSequential ( prefix = ' ' ) <nl> + self . downsample . add ( nn . Conv2D ( channels , kernel_size = 1 , strides = stride , <nl> + use_bias = False , in_channels = in_channels ) ) <nl> + self . downsample . add ( nn . BatchNorm ( ) ) <nl> + else : <nl> + self . downsample = None <nl> + <nl> + def hybrid_forward ( self , F , x ) : <nl> + residual = x <nl> + <nl> + x = self . body ( x ) <nl> + <nl> + if self . downsample : <nl> + residual = self . downsample ( residual ) <nl> + <nl> + x = F . Activation ( residual + x , act_type = ' relu ' ) <nl> + <nl> + return x <nl> + <nl> + <nl> + class BottleneckV1 ( HybridBlock ) : <nl> + r " " " Bottleneck V1 from ` " Deep Residual Learning for Image Recognition " <nl> + < http : / / arxiv . org / abs / 1512 . 03385 > ` _ paper . <nl> + This is used for ResNet V1 for 50 , 101 , 152 layers . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + channels : int <nl> + Number of output channels . <nl> + stride : int <nl> + Stride size . <nl> + downsample : bool , default False <nl> + Whether to downsample the input . <nl> + in_channels : int , default 0 <nl> + Number of input channels . Default is 0 , to infer from the graph . <nl> + " " " <nl> + def __init__ ( self , channels , stride , downsample = False , in_channels = 0 , * * kwargs ) : <nl> + super ( BottleneckV1 , self ) . __init__ ( * * kwargs ) <nl> + self . body = nn . HybridSequential ( prefix = ' ' ) <nl> + self . body . add ( nn . Conv2D ( channels / / 4 , kernel_size = 1 , strides = 1 ) ) <nl> + self . body . add ( nn . BatchNorm ( ) ) <nl> + self . body . add ( nn . Activation ( ' relu ' ) ) <nl> + self . body . add ( _conv3x3 ( channels / / 4 , stride , channels / / 4 ) ) <nl> + self . body . add ( nn . BatchNorm ( ) ) <nl> + self . body . add ( nn . Activation ( ' relu ' ) ) <nl> + self . body . add ( nn . Conv2D ( channels , kernel_size = 1 , strides = 1 ) ) <nl> + self . body . add ( nn . BatchNorm ( ) ) <nl> + if downsample : <nl> + self . downsample = nn . HybridSequential ( prefix = ' ' ) <nl> + self . downsample . add ( nn . Conv2D ( channels , kernel_size = 1 , strides = stride , <nl> + use_bias = False , in_channels = in_channels ) ) <nl> + self . downsample . add ( nn . BatchNorm ( ) ) <nl> + else : <nl> + self . downsample = None <nl> + <nl> + def hybrid_forward ( self , F , x ) : <nl> + residual = x <nl> + <nl> + x = self . body ( x ) <nl> + <nl> + if self . downsample : <nl> + residual = self . downsample ( residual ) <nl> + <nl> + x = F . Activation ( x + residual , act_type = ' relu ' ) <nl> + return x <nl> + <nl> + <nl> + class BasicBlockV2 ( HybridBlock ) : <nl> + r " " " BasicBlock V2 from <nl> + ` " Identity Mappings in Deep Residual Networks " <nl> + < https : / / arxiv . org / abs / 1603 . 05027 > ` _ paper . <nl> + This is used for ResNet V2 for 18 , 34 layers . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + channels : int <nl> + Number of output channels . <nl> + stride : int <nl> + Stride size . <nl> + downsample : bool , default False <nl> + Whether to downsample the input . <nl> + in_channels : int , default 0 <nl> + Number of input channels . Default is 0 , to infer from the graph . <nl> + " " " <nl> + def __init__ ( self , channels , stride , downsample = False , in_channels = 0 , * * kwargs ) : <nl> + super ( BasicBlockV2 , self ) . __init__ ( * * kwargs ) <nl> + self . bn1 = nn . BatchNorm ( ) <nl> + self . conv1 = _conv3x3 ( channels , stride , in_channels ) <nl> + self . bn2 = nn . BatchNorm ( ) <nl> + self . conv2 = _conv3x3 ( channels , 1 , channels ) <nl> + if downsample : <nl> + self . downsample = nn . Conv2D ( channels , 1 , stride , use_bias = False , <nl> + in_channels = in_channels ) <nl> + else : <nl> + self . downsample = None <nl> + <nl> + def hybrid_forward ( self , F , x ) : <nl> + residual = x <nl> + x = self . bn1 ( x ) <nl> + x = F . Activation ( x , act_type = ' relu ' ) <nl> + if self . downsample : <nl> + residual = self . downsample ( x ) <nl> + x = self . conv1 ( x ) <nl> + <nl> + x = self . bn2 ( x ) <nl> + x = F . Activation ( x , act_type = ' relu ' ) <nl> + x = self . conv2 ( x ) <nl> + <nl> + return x + residual <nl> + <nl> + <nl> + class BottleneckV2 ( HybridBlock ) : <nl> + r " " " Bottleneck V2 from <nl> + ` " Identity Mappings in Deep Residual Networks " <nl> + < https : / / arxiv . org / abs / 1603 . 05027 > ` _ paper . <nl> + This is used for ResNet V2 for 50 , 101 , 152 layers . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + channels : int <nl> + Number of output channels . <nl> + stride : int <nl> + Stride size . <nl> + downsample : bool , default False <nl> + Whether to downsample the input . <nl> + in_channels : int , default 0 <nl> + Number of input channels . Default is 0 , to infer from the graph . <nl> + " " " <nl> + def __init__ ( self , channels , stride , downsample = False , in_channels = 0 , * * kwargs ) : <nl> + super ( BottleneckV2 , self ) . __init__ ( * * kwargs ) <nl> + self . bn1 = nn . BatchNorm ( ) <nl> + self . conv1 = _conv3x3 ( channels / / 4 , 1 , in_channels ) <nl> + self . bn2 = nn . BatchNorm ( ) <nl> + self . conv2 = _conv3x3 ( channels / / 4 , stride , channels / / 4 ) <nl> + self . bn3 = nn . BatchNorm ( ) <nl> + self . conv3 = _conv3x3 ( channels , 1 , channels / / 4 ) <nl> + if downsample : <nl> + self . downsample = nn . Conv2D ( channels , 1 , stride , use_bias = False , <nl> + in_channels = in_channels ) <nl> + else : <nl> + self . downsample = None <nl> + <nl> + def hybrid_forward ( self , F , x ) : <nl> + residual = x <nl> + x = self . bn1 ( x ) <nl> + x = F . Activation ( x , act_type = ' relu ' ) <nl> + if self . downsample : <nl> + residual = self . downsample ( x ) <nl> + x = self . conv1 ( x ) <nl> + <nl> + x = self . bn2 ( x ) <nl> + x = F . Activation ( x , act_type = ' relu ' ) <nl> + x = self . conv2 ( x ) <nl> + <nl> + x = self . bn3 ( x ) <nl> + x = F . Activation ( x , act_type = ' relu ' ) <nl> + x = self . conv3 ( x ) <nl> + <nl> + return x + residual <nl> + <nl> + <nl> + # Nets <nl> + class ResNetV1 ( HybridBlock ) : <nl> + r " " " ResNet V1 model from <nl> + ` " Deep Residual Learning for Image Recognition " <nl> + < http : / / arxiv . org / abs / 1512 . 03385 > ` _ paper . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + block : HybridBlock <nl> + Class for the residual block . Options are BasicBlockV1 , BottleneckV1 . <nl> + layers : list of int <nl> + Numbers of layers in each block <nl> + channels : list of int <nl> + Numbers of channels in each block . Length should be one larger than layers list . <nl> + classes : int , default 1000 <nl> + Number of classification classes . <nl> + thumbnail : bool , default False <nl> + Enable thumbnail . <nl> + " " " <nl> + def __init__ ( self , block , layers , channels , classes = 1000 , thumbnail = False , * * kwargs ) : <nl> + super ( ResNetV1 , self ) . __init__ ( * * kwargs ) <nl> + assert len ( layers ) = = len ( channels ) - 1 <nl> + with self . name_scope ( ) : <nl> + self . features = nn . HybridSequential ( prefix = ' ' ) <nl> + if thumbnail : <nl> + self . features . add ( _conv3x3 ( channels [ 0 ] , 1 , 3 ) ) <nl> + else : <nl> + self . features . add ( nn . Conv2D ( channels [ 0 ] , 7 , 2 , 3 , use_bias = False , <nl> + in_channels = 3 ) ) <nl> + self . features . add ( nn . BatchNorm ( ) ) <nl> + self . features . add ( nn . Activation ( ' relu ' ) ) <nl> + self . features . add ( nn . MaxPool2D ( 3 , 2 , 1 ) ) <nl> + <nl> + for i , num_layer in enumerate ( layers ) : <nl> + stride = 1 if i = = 0 else 2 <nl> + self . features . add ( self . _make_layer ( block , num_layer , channels [ i + 1 ] , <nl> + stride , i + 1 , in_channels = channels [ i ] ) ) <nl> + <nl> + self . classifier = nn . HybridSequential ( prefix = ' ' ) <nl> + self . classifier . add ( nn . GlobalAvgPool2D ( ) ) <nl> + self . classifier . add ( nn . Flatten ( ) ) <nl> + self . classifier . add ( nn . Dense ( classes , in_units = channels [ - 1 ] ) ) <nl> + <nl> + def _make_layer ( self , block , layers , channels , stride , stage_index , in_channels = 0 ) : <nl> + layer = nn . HybridSequential ( prefix = ' stage % d_ ' % stage_index ) <nl> + with layer . name_scope ( ) : <nl> + layer . add ( block ( channels , stride , channels ! = in_channels , in_channels = in_channels , <nl> + prefix = ' ' ) ) <nl> + for _ in range ( layers - 1 ) : <nl> + layer . add ( block ( channels , 1 , False , in_channels = channels , prefix = ' ' ) ) <nl> + return layer <nl> + <nl> + def hybrid_forward ( self , F , x ) : <nl> + x = self . features ( x ) <nl> + x = self . classifier ( x ) <nl> + <nl> + return x <nl> + <nl> + <nl> + class ResNetV2 ( HybridBlock ) : <nl> + r " " " ResNet V2 model from <nl> + ` " Identity Mappings in Deep Residual Networks " <nl> + < https : / / arxiv . org / abs / 1603 . 05027 > ` _ paper . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + block : HybridBlock <nl> + Class for the residual block . Options are BasicBlockV1 , BottleneckV1 . <nl> + layers : list of int <nl> + Numbers of layers in each block <nl> + channels : list of int <nl> + Numbers of channels in each block . Length should be one larger than layers list . <nl> + classes : int , default 1000 <nl> + Number of classification classes . <nl> + thumbnail : bool , default False <nl> + Enable thumbnail . <nl> + " " " <nl> + def __init__ ( self , block , layers , channels , classes = 1000 , thumbnail = False , * * kwargs ) : <nl> + super ( ResNetV2 , self ) . __init__ ( * * kwargs ) <nl> + assert len ( layers ) = = len ( channels ) - 1 <nl> + with self . name_scope ( ) : <nl> + self . features = nn . HybridSequential ( prefix = ' ' ) <nl> + self . features . add ( nn . BatchNorm ( scale = False , center = False ) ) <nl> + if thumbnail : <nl> + self . features . add ( _conv3x3 ( channels [ 0 ] , 1 , 3 ) ) <nl> + else : <nl> + self . features . add ( nn . Conv2D ( channels [ 0 ] , 7 , 2 , 3 , use_bias = False , <nl> + in_channels = 3 ) ) <nl> + self . features . add ( nn . BatchNorm ( ) ) <nl> + self . features . add ( nn . Activation ( ' relu ' ) ) <nl> + self . features . add ( nn . MaxPool2D ( 3 , 2 , 1 ) ) <nl> + <nl> + in_channels = channels [ 0 ] <nl> + for i , num_layer in enumerate ( layers ) : <nl> + stride = 1 if i = = 0 else 2 <nl> + self . features . add ( self . _make_layer ( block , num_layer , channels [ i + 1 ] , <nl> + stride , i + 1 , in_channels = in_channels ) ) <nl> + in_channels = channels [ i + 1 ] <nl> + <nl> + self . classifier = nn . HybridSequential ( prefix = ' ' ) <nl> + self . classifier . add ( nn . BatchNorm ( ) ) <nl> + self . classifier . add ( nn . Activation ( ' relu ' ) ) <nl> + self . classifier . add ( nn . GlobalAvgPool2D ( ) ) <nl> + self . classifier . add ( nn . Flatten ( ) ) <nl> + self . classifier . add ( nn . Dense ( classes , in_units = in_channels ) ) <nl> + <nl> + def _make_layer ( self , block , layers , channels , stride , stage_index , in_channels = 0 ) : <nl> + layer = nn . HybridSequential ( prefix = ' stage % d_ ' % stage_index ) <nl> + with layer . name_scope ( ) : <nl> + layer . add ( block ( channels , stride , channels ! = in_channels , in_channels = in_channels , <nl> + prefix = ' ' ) ) <nl> + for _ in range ( layers - 1 ) : <nl> + layer . add ( block ( channels , 1 , False , in_channels = channels , prefix = ' ' ) ) <nl> + return layer <nl> + <nl> + def hybrid_forward ( self , F , x ) : <nl> + x = self . features ( x ) <nl> + x = self . classifier ( x ) <nl> + return x <nl> + <nl> + <nl> + # Specification <nl> + resnet_spec = { 18 : ( ' basic_block ' , [ 2 , 2 , 2 , 2 ] , [ 64 , 64 , 128 , 256 , 512 ] ) , <nl> + 34 : ( ' basic_block ' , [ 3 , 4 , 6 , 3 ] , [ 64 , 64 , 128 , 256 , 512 ] ) , <nl> + 50 : ( ' bottle_neck ' , [ 3 , 4 , 6 , 3 ] , [ 64 , 256 , 512 , 1024 , 2048 ] ) , <nl> + 101 : ( ' bottle_neck ' , [ 3 , 4 , 23 , 3 ] , [ 64 , 256 , 512 , 1024 , 2048 ] ) , <nl> + 152 : ( ' bottle_neck ' , [ 3 , 8 , 36 , 3 ] , [ 64 , 256 , 512 , 1024 , 2048 ] ) } <nl> + <nl> + resnet_net_versions = [ ResNetV1 , ResNetV2 ] <nl> + resnet_block_versions = [ { ' basic_block ' : BasicBlockV1 , ' bottle_neck ' : BottleneckV1 } , <nl> + { ' basic_block ' : BasicBlockV2 , ' bottle_neck ' : BottleneckV2 } ] <nl> + <nl> + <nl> + # Constructor <nl> + def get_resnet ( version , num_layers , pretrained = False , ctx = cpu ( ) , * * kwargs ) : <nl> + r " " " ResNet V1 model from ` " Deep Residual Learning for Image Recognition " <nl> + < http : / / arxiv . org / abs / 1512 . 03385 > ` _ paper . <nl> + ResNet V2 model from ` " Identity Mappings in Deep Residual Networks " <nl> + < https : / / arxiv . org / abs / 1603 . 05027 > ` _ paper . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + version : int <nl> + Version of ResNet . Options are 1 , 2 . <nl> + num_layers : int <nl> + Numbers of layers . Options are 18 , 34 , 50 , 101 , 152 . <nl> + pretrained : bool , default False <nl> + Whether to load the pretrained weights for model . <nl> + ctx : Context , default CPU <nl> + The context in which to load the pretrained weights . <nl> + " " " <nl> + block_type , layers , channels = resnet_spec [ num_layers ] <nl> + resnet_class = resnet_net_versions [ version - 1 ] <nl> + block_class = resnet_block_versions [ version - 1 ] [ block_type ] <nl> + net = resnet_class ( block_class , layers , channels , * * kwargs ) <nl> + if pretrained : <nl> + from . . model_store import get_model_file <nl> + net . load_params ( get_model_file ( ' resnet % d_v % d ' % ( num_layers , version ) ) , ctx = ctx ) <nl> + return net <nl> + <nl> + def resnet18_v1 ( * * kwargs ) : <nl> + r " " " ResNet - 18 V1 model from ` " Deep Residual Learning for Image Recognition " <nl> + < http : / / arxiv . org / abs / 1512 . 03385 > ` _ paper . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + pretrained : bool , default False <nl> + Whether to load the pretrained weights for model . <nl> + ctx : Context , default CPU <nl> + The context in which to load the pretrained weights . <nl> + " " " <nl> + return get_resnet ( 1 , 18 , * * kwargs ) <nl> + <nl> + def resnet34_v1 ( * * kwargs ) : <nl> + r " " " ResNet - 34 V1 model from ` " Deep Residual Learning for Image Recognition " <nl> + < http : / / arxiv . org / abs / 1512 . 03385 > ` _ paper . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + pretrained : bool , default False <nl> + Whether to load the pretrained weights for model . <nl> + ctx : Context , default CPU <nl> + The context in which to load the pretrained weights . <nl> + " " " <nl> + return get_resnet ( 1 , 34 , * * kwargs ) <nl> + <nl> + def resnet50_v1 ( * * kwargs ) : <nl> + r " " " ResNet - 50 V1 model from ` " Deep Residual Learning for Image Recognition " <nl> + < http : / / arxiv . org / abs / 1512 . 03385 > ` _ paper . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + pretrained : bool , default False <nl> + Whether to load the pretrained weights for model . <nl> + ctx : Context , default CPU <nl> + The context in which to load the pretrained weights . <nl> + " " " <nl> + return get_resnet ( 1 , 50 , * * kwargs ) <nl> + <nl> + def resnet101_v1 ( * * kwargs ) : <nl> + r " " " ResNet - 101 V1 model from ` " Deep Residual Learning for Image Recognition " <nl> + < http : / / arxiv . org / abs / 1512 . 03385 > ` _ paper . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + pretrained : bool , default False <nl> + Whether to load the pretrained weights for model . <nl> + ctx : Context , default CPU <nl> + The context in which to load the pretrained weights . <nl> + " " " <nl> + return get_resnet ( 1 , 101 , * * kwargs ) <nl> + <nl> + def resnet152_v1 ( * * kwargs ) : <nl> + r " " " ResNet - 152 V1 model from ` " Deep Residual Learning for Image Recognition " <nl> + < http : / / arxiv . org / abs / 1512 . 03385 > ` _ paper . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + pretrained : bool , default False <nl> + Whether to load the pretrained weights for model . <nl> + ctx : Context , default CPU <nl> + The context in which to load the pretrained weights . <nl> + " " " <nl> + return get_resnet ( 1 , 152 , * * kwargs ) <nl> + <nl> + def resnet18_v2 ( * * kwargs ) : <nl> + r " " " ResNet - 18 V2 model from ` " Identity Mappings in Deep Residual Networks " <nl> + < https : / / arxiv . org / abs / 1603 . 05027 > ` _ paper . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + pretrained : bool , default False <nl> + Whether to load the pretrained weights for model . <nl> + ctx : Context , default CPU <nl> + The context in which to load the pretrained weights . <nl> + " " " <nl> + return get_resnet ( 2 , 18 , * * kwargs ) <nl> + <nl> + def resnet34_v2 ( * * kwargs ) : <nl> + r " " " ResNet - 34 V2 model from ` " Identity Mappings in Deep Residual Networks " <nl> + < https : / / arxiv . org / abs / 1603 . 05027 > ` _ paper . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + pretrained : bool , default False <nl> + Whether to load the pretrained weights for model . <nl> + ctx : Context , default CPU <nl> + The context in which to load the pretrained weights . <nl> + " " " <nl> + return get_resnet ( 2 , 34 , * * kwargs ) <nl> + <nl> + def resnet50_v2 ( * * kwargs ) : <nl> + r " " " ResNet - 50 V2 model from ` " Identity Mappings in Deep Residual Networks " <nl> + < https : / / arxiv . org / abs / 1603 . 05027 > ` _ paper . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + pretrained : bool , default False <nl> + Whether to load the pretrained weights for model . <nl> + ctx : Context , default CPU <nl> + The context in which to load the pretrained weights . <nl> + " " " <nl> + return get_resnet ( 2 , 50 , * * kwargs ) <nl> + <nl> + def resnet101_v2 ( * * kwargs ) : <nl> + r " " " ResNet - 101 V2 model from ` " Identity Mappings in Deep Residual Networks " <nl> + < https : / / arxiv . org / abs / 1603 . 05027 > ` _ paper . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + pretrained : bool , default False <nl> + Whether to load the pretrained weights for model . <nl> + ctx : Context , default CPU <nl> + The context in which to load the pretrained weights . <nl> + " " " <nl> + return get_resnet ( 2 , 101 , * * kwargs ) <nl> + <nl> + def resnet152_v2 ( * * kwargs ) : <nl> + r " " " ResNet - 152 V2 model from ` " Identity Mappings in Deep Residual Networks " <nl> + < https : / / arxiv . org / abs / 1603 . 05027 > ` _ paper . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + pretrained : bool , default False <nl> + Whether to load the pretrained weights for model . <nl> + ctx : Context , default CPU <nl> + The context in which to load the pretrained weights . <nl> + " " " <nl> + return get_resnet ( 2 , 152 , * * kwargs ) <nl> new file mode 100644 <nl> index 00000000000 . . bfcb5cbc9ba <nl> mmm / dev / null <nl> ppp b / python / mxnet / gluon / model_zoo / vision / squeezenet . py <nl> <nl> + # coding : utf - 8 <nl> + # pylint : disable = arguments - differ <nl> + " " " SqueezeNet , implemented in Gluon . " " " <nl> + __all__ = [ ' SqueezeNet ' , ' squeezenet1_0 ' , ' squeezenet1_1 ' ] <nl> + <nl> + from . . . . context import cpu <nl> + from . . . block import HybridBlock <nl> + from . . . import nn <nl> + from . . custom_layers import HybridConcurrent <nl> + <nl> + # Helpers <nl> + def _make_fire ( squeeze_channels , expand1x1_channels , expand3x3_channels ) : <nl> + out = nn . HybridSequential ( prefix = ' ' ) <nl> + out . add ( _make_fire_conv ( squeeze_channels , 1 ) ) <nl> + <nl> + paths = HybridConcurrent ( concat_dim = 1 , prefix = ' ' ) <nl> + paths . add ( _make_fire_conv ( expand1x1_channels , 1 ) ) <nl> + paths . add ( _make_fire_conv ( expand3x3_channels , 3 , 1 ) ) <nl> + out . add ( paths ) <nl> + <nl> + return out <nl> + <nl> + def _make_fire_conv ( channels , kernel_size , padding = 0 ) : <nl> + out = nn . HybridSequential ( prefix = ' ' ) <nl> + out . add ( nn . Conv2D ( channels , kernel_size , padding = padding ) ) <nl> + out . add ( nn . Activation ( ' relu ' ) ) <nl> + return out <nl> + <nl> + # Net <nl> + class SqueezeNet ( HybridBlock ) : <nl> + r " " " SqueezeNet model from the ` " SqueezeNet : AlexNet - level accuracy with 50x fewer parameters <nl> + and < 0 . 5MB model size " < https : / / arxiv . org / abs / 1602 . 07360 > ` _ paper . <nl> + SqueezeNet 1 . 1 model from the ` official SqueezeNet repo <nl> + < https : / / github . com / DeepScale / SqueezeNet / tree / master / SqueezeNet_v1 . 1 > ` _ . <nl> + SqueezeNet 1 . 1 has 2 . 4x less computation and slightly fewer parameters <nl> + than SqueezeNet 1 . 0 , without sacrificing accuracy . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + version : str <nl> + Version of squeezenet . Options are ' 1 . 0 ' , ' 1 . 1 ' . <nl> + classes : int , default 1000 <nl> + Number of classification classes . <nl> + " " " <nl> + def __init__ ( self , version , classes = 1000 , * * kwargs ) : <nl> + super ( SqueezeNet , self ) . __init__ ( * * kwargs ) <nl> + assert version in [ ' 1 . 0 ' , ' 1 . 1 ' ] , ( " Unsupported SqueezeNet version { version } : " <nl> + " 1 . 0 or 1 . 1 expected " . format ( version = version ) ) <nl> + with self . name_scope ( ) : <nl> + self . features = nn . HybridSequential ( prefix = ' ' ) <nl> + if version = = ' 1 . 0 ' : <nl> + self . features . add ( nn . Conv2D ( 96 , kernel_size = 7 , strides = 2 ) ) <nl> + self . features . add ( nn . Activation ( ' relu ' ) ) <nl> + self . features . add ( nn . MaxPool2D ( pool_size = 3 , strides = 2 , ceil_mode = True ) ) <nl> + self . features . add ( _make_fire ( 16 , 64 , 64 ) ) <nl> + self . features . add ( _make_fire ( 16 , 64 , 64 ) ) <nl> + self . features . add ( _make_fire ( 32 , 128 , 128 ) ) <nl> + self . features . add ( nn . MaxPool2D ( pool_size = 3 , strides = 2 , ceil_mode = True ) ) <nl> + self . features . add ( _make_fire ( 32 , 128 , 128 ) ) <nl> + self . features . add ( _make_fire ( 48 , 192 , 192 ) ) <nl> + self . features . add ( _make_fire ( 48 , 192 , 192 ) ) <nl> + self . features . add ( _make_fire ( 64 , 256 , 256 ) ) <nl> + self . features . add ( nn . MaxPool2D ( pool_size = 3 , strides = 2 , ceil_mode = True ) ) <nl> + self . features . add ( _make_fire ( 64 , 256 , 256 ) ) <nl> + else : <nl> + self . features . add ( nn . Conv2D ( 64 , kernel_size = 3 , strides = 2 ) ) <nl> + self . features . add ( nn . Activation ( ' relu ' ) ) <nl> + self . features . add ( nn . MaxPool2D ( pool_size = 3 , strides = 2 , ceil_mode = True ) ) <nl> + self . features . add ( _make_fire ( 16 , 64 , 64 ) ) <nl> + self . features . add ( _make_fire ( 16 , 64 , 64 ) ) <nl> + self . features . add ( nn . MaxPool2D ( pool_size = 3 , strides = 2 , ceil_mode = True ) ) <nl> + self . features . add ( _make_fire ( 32 , 128 , 128 ) ) <nl> + self . features . add ( _make_fire ( 32 , 128 , 128 ) ) <nl> + self . features . add ( nn . MaxPool2D ( pool_size = 3 , strides = 2 , ceil_mode = True ) ) <nl> + self . features . add ( _make_fire ( 48 , 192 , 192 ) ) <nl> + self . features . add ( _make_fire ( 48 , 192 , 192 ) ) <nl> + self . features . add ( _make_fire ( 64 , 256 , 256 ) ) <nl> + self . features . add ( _make_fire ( 64 , 256 , 256 ) ) <nl> + <nl> + self . classifier = nn . HybridSequential ( prefix = ' ' ) <nl> + self . classifier . add ( nn . Dropout ( 0 . 5 ) ) <nl> + self . classifier . add ( nn . Conv2D ( classes , kernel_size = 1 ) ) <nl> + self . classifier . add ( nn . Activation ( ' relu ' ) ) <nl> + self . classifier . add ( nn . AvgPool2D ( 13 ) ) <nl> + self . classifier . add ( nn . Flatten ( ) ) <nl> + <nl> + def hybrid_forward ( self , F , x ) : <nl> + x = self . features ( x ) <nl> + x = self . classifier ( x ) <nl> + return x <nl> + <nl> + # Constructor <nl> + def get_squeezenet ( version , pretrained = False , ctx = cpu ( ) , * * kwargs ) : <nl> + r " " " SqueezeNet model from the ` " SqueezeNet : AlexNet - level accuracy with 50x fewer parameters <nl> + and < 0 . 5MB model size " < https : / / arxiv . org / abs / 1602 . 07360 > ` _ paper . <nl> + SqueezeNet 1 . 1 model from the ` official SqueezeNet repo <nl> + < https : / / github . com / DeepScale / SqueezeNet / tree / master / SqueezeNet_v1 . 1 > ` _ . <nl> + SqueezeNet 1 . 1 has 2 . 4x less computation and slightly fewer parameters <nl> + than SqueezeNet 1 . 0 , without sacrificing accuracy . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + version : str <nl> + Version of squeezenet . Options are ' 1 . 0 ' , ' 1 . 1 ' . <nl> + pretrained : bool , default False <nl> + Whether to load the pretrained weights for model . <nl> + ctx : Context , default CPU <nl> + The context in which to load the pretrained weights . <nl> + " " " <nl> + net = SqueezeNet ( version , * * kwargs ) <nl> + if pretrained : <nl> + from . . model_store import get_model_file <nl> + net . load_params ( get_model_file ( ' squeezenet % s ' % version ) , ctx = ctx ) <nl> + return net <nl> + <nl> + def squeezenet1_0 ( * * kwargs ) : <nl> + r " " " SqueezeNet 1 . 0 model from the ` " SqueezeNet : AlexNet - level accuracy with 50x fewer parameters <nl> + and < 0 . 5MB model size " < https : / / arxiv . org / abs / 1602 . 07360 > ` _ paper . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + pretrained : bool , default False <nl> + Whether to load the pretrained weights for model . <nl> + ctx : Context , default CPU <nl> + The context in which to load the pretrained weights . <nl> + " " " <nl> + return get_squeezenet ( ' 1 . 0 ' , * * kwargs ) <nl> + <nl> + def squeezenet1_1 ( * * kwargs ) : <nl> + r " " " SqueezeNet 1 . 1 model from the ` official SqueezeNet repo <nl> + < https : / / github . com / DeepScale / SqueezeNet / tree / master / SqueezeNet_v1 . 1 > ` _ . <nl> + SqueezeNet 1 . 1 has 2 . 4x less computation and slightly fewer parameters <nl> + than SqueezeNet 1 . 0 , without sacrificing accuracy . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + pretrained : bool , default False <nl> + Whether to load the pretrained weights for model . <nl> + ctx : Context , default CPU <nl> + The context in which to load the pretrained weights . <nl> + " " " <nl> + return get_squeezenet ( ' 1 . 1 ' , * * kwargs ) <nl> new file mode 100644 <nl> index 00000000000 . . 96a4fa1f370 <nl> mmm / dev / null <nl> ppp b / python / mxnet / gluon / model_zoo / vision / vgg . py <nl> <nl> + # coding : utf - 8 <nl> + # pylint : disable = arguments - differ <nl> + " " " VGG , implemented in Gluon . " " " <nl> + from __future__ import division <nl> + __all__ = [ ' VGG ' , <nl> + ' vgg11 ' , ' vgg13 ' , ' vgg16 ' , ' vgg19 ' , <nl> + ' vgg11_bn ' , ' vgg13_bn ' , ' vgg16_bn ' , ' vgg19_bn ' , <nl> + ' get_vgg ' ] <nl> + <nl> + from . . . . context import cpu <nl> + from . . . . initializer import Xavier <nl> + from . . . block import HybridBlock <nl> + from . . . import nn <nl> + <nl> + <nl> + class VGG ( HybridBlock ) : <nl> + r " " " VGG model from the ` " Very Deep Convolutional Networks for Large - Scale Image Recognition " <nl> + < https : / / arxiv . org / abs / 1409 . 1556 > ` _ paper . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + layers : list of int <nl> + Numbers of layers in each feature block . <nl> + filters : list of int <nl> + Numbers of filters in each feature block . List length should match the layers . <nl> + classes : int , default 1000 <nl> + Number of classification classes . <nl> + batch_norm : bool , default False <nl> + Use batch normalization . <nl> + " " " <nl> + def __init__ ( self , layers , filters , classes = 1000 , batch_norm = False , * * kwargs ) : <nl> + super ( VGG , self ) . __init__ ( * * kwargs ) <nl> + assert len ( layers ) = = len ( filters ) <nl> + with self . name_scope ( ) : <nl> + self . features = self . _make_features ( layers , filters , batch_norm ) <nl> + self . classifier = nn . HybridSequential ( prefix = ' ' ) <nl> + self . classifier . add ( nn . Dense ( 4096 , activation = ' relu ' , <nl> + weight_initializer = ' normal ' , <nl> + bias_initializer = ' zeros ' ) ) <nl> + self . classifier . add ( nn . Dropout ( rate = 0 . 5 ) ) <nl> + self . classifier . add ( nn . Dense ( 4096 , activation = ' relu ' , <nl> + weight_initializer = ' normal ' , <nl> + bias_initializer = ' zeros ' ) ) <nl> + self . classifier . add ( nn . Dropout ( rate = 0 . 5 ) ) <nl> + self . classifier . add ( nn . Dense ( classes , <nl> + weight_initializer = ' normal ' , <nl> + bias_initializer = ' zeros ' ) ) <nl> + <nl> + def _make_features ( self , layers , filters , batch_norm ) : <nl> + featurizer = nn . HybridSequential ( prefix = ' ' ) <nl> + for i , num in enumerate ( layers ) : <nl> + for _ in range ( num ) : <nl> + featurizer . add ( nn . Conv2D ( filters [ i ] , kernel_size = 3 , padding = 1 , <nl> + weight_initializer = Xavier ( rnd_type = ' gaussian ' , <nl> + factor_type = ' out ' , <nl> + magnitude = 2 ) , <nl> + bias_initializer = ' zeros ' ) ) <nl> + if batch_norm : <nl> + featurizer . add ( nn . BatchNorm ( ) ) <nl> + featurizer . add ( nn . Activation ( ' relu ' ) ) <nl> + featurizer . add ( nn . MaxPool2D ( strides = 2 ) ) <nl> + return featurizer <nl> + <nl> + def hybrid_forward ( self , F , x ) : <nl> + x = self . features ( x ) <nl> + x = self . classifier ( x ) <nl> + return x <nl> + <nl> + <nl> + # Specification <nl> + vgg_spec = { 11 : ( [ 1 , 1 , 2 , 2 , 2 ] , [ 64 , 128 , 256 , 512 , 512 ] ) , <nl> + 13 : ( [ 2 , 2 , 2 , 2 , 2 ] , [ 64 , 128 , 256 , 512 , 512 ] ) , <nl> + 16 : ( [ 2 , 2 , 3 , 3 , 3 ] , [ 64 , 128 , 256 , 512 , 512 ] ) , <nl> + 19 : ( [ 2 , 2 , 4 , 4 , 4 ] , [ 64 , 128 , 256 , 512 , 512 ] ) } <nl> + <nl> + <nl> + # Constructors <nl> + def get_vgg ( num_layers , pretrained = False , ctx = cpu ( ) , * * kwargs ) : <nl> + r " " " VGG model from the ` " Very Deep Convolutional Networks for Large - Scale Image Recognition " <nl> + < https : / / arxiv . org / abs / 1409 . 1556 > ` _ paper . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + num_layers : int <nl> + Number of layers for the variant of densenet . Options are 11 , 13 , 16 , 19 . <nl> + pretrained : bool , default False <nl> + Whether to load the pretrained weights for model . <nl> + ctx : Context , default CPU <nl> + The context in which to load the pretrained weights . <nl> + " " " <nl> + layers , filters = vgg_spec [ num_layers ] <nl> + net = VGG ( layers , filters , * * kwargs ) <nl> + if pretrained : <nl> + from . . model_store import get_model_file <nl> + batch_norm_suffix = ' _bn ' if kwargs . get ( ' batch_norm ' ) else ' ' <nl> + net . load_params ( get_model_file ( ' vgg % d % s ' % ( num_layers , batch_norm_suffix ) ) , ctx = ctx ) <nl> + return net <nl> + <nl> + def vgg11 ( * * kwargs ) : <nl> + r " " " VGG - 11 model from the ` " Very Deep Convolutional Networks for Large - Scale Image Recognition " <nl> + < https : / / arxiv . org / abs / 1409 . 1556 > ` _ paper . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + pretrained : bool , default False <nl> + Whether to load the pretrained weights for model . <nl> + ctx : Context , default CPU <nl> + The context in which to load the pretrained weights . <nl> + " " " <nl> + return get_vgg ( 11 , * * kwargs ) <nl> + <nl> + def vgg13 ( * * kwargs ) : <nl> + r " " " VGG - 13 model from the ` " Very Deep Convolutional Networks for Large - Scale Image Recognition " <nl> + < https : / / arxiv . org / abs / 1409 . 1556 > ` _ paper . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + pretrained : bool , default False <nl> + Whether to load the pretrained weights for model . <nl> + ctx : Context , default CPU <nl> + The context in which to load the pretrained weights . <nl> + " " " <nl> + return get_vgg ( 13 , * * kwargs ) <nl> + <nl> + def vgg16 ( * * kwargs ) : <nl> + r " " " VGG - 16 model from the ` " Very Deep Convolutional Networks for Large - Scale Image Recognition " <nl> + < https : / / arxiv . org / abs / 1409 . 1556 > ` _ paper . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + pretrained : bool , default False <nl> + Whether to load the pretrained weights for model . <nl> + ctx : Context , default CPU <nl> + The context in which to load the pretrained weights . <nl> + " " " <nl> + return get_vgg ( 16 , * * kwargs ) <nl> + <nl> + def vgg19 ( * * kwargs ) : <nl> + r " " " VGG - 19 model from the ` " Very Deep Convolutional Networks for Large - Scale Image Recognition " <nl> + < https : / / arxiv . org / abs / 1409 . 1556 > ` _ paper . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + pretrained : bool , default False <nl> + Whether to load the pretrained weights for model . <nl> + ctx : Context , default CPU <nl> + The context in which to load the pretrained weights . <nl> + " " " <nl> + return get_vgg ( 19 , * * kwargs ) <nl> + <nl> + def vgg11_bn ( * * kwargs ) : <nl> + r " " " VGG - 11 model with batch normalization from the <nl> + ` " Very Deep Convolutional Networks for Large - Scale Image Recognition " <nl> + < https : / / arxiv . org / abs / 1409 . 1556 > ` _ paper . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + pretrained : bool , default False <nl> + Whether to load the pretrained weights for model . <nl> + ctx : Context , default CPU <nl> + The context in which to load the pretrained weights . <nl> + " " " <nl> + kwargs [ ' batch_norm ' ] = True <nl> + return get_vgg ( 11 , * * kwargs ) <nl> + <nl> + def vgg13_bn ( * * kwargs ) : <nl> + r " " " VGG - 13 model with batch normalization from the <nl> + ` " Very Deep Convolutional Networks for Large - Scale Image Recognition " <nl> + < https : / / arxiv . org / abs / 1409 . 1556 > ` _ paper . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + pretrained : bool , default False <nl> + Whether to load the pretrained weights for model . <nl> + ctx : Context , default CPU <nl> + The context in which to load the pretrained weights . <nl> + " " " <nl> + kwargs [ ' batch_norm ' ] = True <nl> + return get_vgg ( 13 , * * kwargs ) <nl> + <nl> + def vgg16_bn ( * * kwargs ) : <nl> + r " " " VGG - 16 model with batch normalization from the <nl> + ` " Very Deep Convolutional Networks for Large - Scale Image Recognition " <nl> + < https : / / arxiv . org / abs / 1409 . 1556 > ` _ paper . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + pretrained : bool , default False <nl> + Whether to load the pretrained weights for model . <nl> + ctx : Context , default CPU <nl> + The context in which to load the pretrained weights . <nl> + " " " <nl> + kwargs [ ' batch_norm ' ] = True <nl> + return get_vgg ( 16 , * * kwargs ) <nl> + <nl> + def vgg19_bn ( * * kwargs ) : <nl> + r " " " VGG - 19 model with batch normalization from the <nl> + ` " Very Deep Convolutional Networks for Large - Scale Image Recognition " <nl> + < https : / / arxiv . org / abs / 1409 . 1556 > ` _ paper . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + pretrained : bool , default False <nl> + Whether to load the pretrained weights for model . <nl> + ctx : Context , default CPU <nl> + The context in which to load the pretrained weights . <nl> + " " " <nl> + kwargs [ ' batch_norm ' ] = True <nl> + return get_vgg ( 19 , * * kwargs ) <nl> mmm a / python / mxnet / gluon / nn / basic_layers . py <nl> ppp b / python / mxnet / gluon / nn / basic_layers . py <nl> class BatchNorm ( HybridBlock ) : <nl> set ` axis = 1 ` in ` BatchNorm ` . If ` layout = ' NHWC ' ` , then set ` axis = 3 ` . <nl> momentum : float , default 0 . 9 <nl> Momentum for the moving average . <nl> - epsilon : float , default 1e - 3 <nl> + epsilon : float , default 1e - 5 <nl> Small float added to variance to avoid dividing by zero . <nl> center : bool , default True <nl> If True , add offset of ` beta ` to normalized tensor . <nl> class BatchNorm ( HybridBlock ) : <nl> Output shape : <nl> Same shape as input . <nl> " " " <nl> - def __init__ ( self , axis = 1 , momentum = 0 . 9 , epsilon = 1e - 3 , center = True , scale = True , <nl> + def __init__ ( self , axis = 1 , momentum = 0 . 9 , epsilon = 1e - 5 , center = True , scale = True , <nl> beta_initializer = ' zeros ' , gamma_initializer = ' ones ' , <nl> running_mean_initializer = ' zeros ' , running_variance_initializer = ' ones ' , <nl> in_channels = 0 , * * kwargs ) : <nl> mmm a / python / mxnet / gluon / nn / conv_layers . py <nl> ppp b / python / mxnet / gluon / nn / conv_layers . py <nl> def hybrid_forward ( self , F , x , weight , bias = None ) : <nl> act = self . act ( act ) <nl> return act <nl> <nl> + def _alias ( self ) : <nl> + return ' conv ' <nl> + <nl> def __repr__ ( self ) : <nl> s = ' { name } ( { mapping } , kernel_size = { kernel } , stride = { stride } ' <nl> len_kernel_size = len ( self . _kwargs [ ' kernel ' ] ) <nl> mmm a / python / mxnet / symbol . py <nl> ppp b / python / mxnet / symbol . py <nl> def ones ( shape , dtype = None , * * kwargs ) : <nl> return _internal . _ones ( shape = shape , dtype = dtype , * * kwargs ) <nl> <nl> <nl> + def full ( shape , val , dtype = None , * * kwargs ) : <nl> + " " " Returns a new array of given shape and type , filled with the given value ` val ` . <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + shape : int or sequence of ints <nl> + Shape of the new array . <nl> + val : scalar <nl> + Fill value . <nl> + dtype : str or numpy . dtype , optional <nl> + The value type of the inner value , default to ` ` np . float32 ` ` . <nl> + <nl> + Returns <nl> + mmmmmm - <nl> + out : Symbol <nl> + The created Symbol <nl> + " " " <nl> + if dtype is None : <nl> + dtype = _numpy . float32 <nl> + return _internal . _MulScalar ( ones ( shape = shape , dtype = dtype , * * kwargs ) , scalar = val ) <nl> + <nl> + <nl> def arange ( start , stop = None , step = 1 . 0 , repeat = 1 , name = None , dtype = None ) : <nl> " " " Returns evenly spaced values within a given interval . <nl> <nl> mmm a / src / operator / batch_norm - inl . h <nl> ppp b / src / operator / batch_norm - inl . h <nl> constexpr int DEFAULT_AXIS = 1 ; <nl> <nl> / * ! \ brief Parameters for BatchNoram operator * / <nl> struct BatchNormParam : public dmlc : : Parameter < BatchNormParam > { <nl> - float eps ; <nl> + double eps ; <nl> float momentum ; <nl> bool fix_gamma ; <nl> bool use_global_stats ; <nl> struct BatchNormParam : public dmlc : : Parameter < BatchNormParam > { <nl> DMLC_DECLARE_PARAMETER ( BatchNormParam ) { <nl> DMLC_DECLARE_FIELD ( eps ) . set_default ( 1e - 3f ) <nl> . describe ( " Epsilon to prevent div 0 . " <nl> - " Must be bigger than CUDNN_BN_MIN_EPSILON " <nl> + " Must be no less than CUDNN_BN_MIN_EPSILON " <nl> " defined in cudnn . h when using cudnn ( usually 1e - 5 ) " ) ; <nl> DMLC_DECLARE_FIELD ( momentum ) . set_default ( 0 . 9f ) <nl> . describe ( " Momentum for moving average " ) ; <nl> mmm a / src / operator / cudnn_batch_norm - inl . h <nl> ppp b / src / operator / cudnn_batch_norm - inl . h <nl> class CuDNNBatchNormOp : public Operator { <nl> public : <nl> explicit CuDNNBatchNormOp ( BatchNormParam param ) { <nl> using namespace mshadow ; <nl> - CHECK_GT ( param . eps , CUDNN_BN_MIN_EPSILON ) <nl> - < < " CuDNN requires eps to be greater than " < < CUDNN_BN_MIN_EPSILON ; <nl> + CHECK_GE ( param . eps , CUDNN_BN_MIN_EPSILON ) <nl> + < < " CuDNN requires eps to be no less than " < < CUDNN_BN_MIN_EPSILON ; <nl> this - > param_ = param ; <nl> init_cudnn_ = false ; <nl> dtype_ = DataType < DType > : : kCudnnFlag ; <nl> new file mode 100644 <nl> index 00000000000 . . 7a38d606d2b <nl> mmm / dev / null <nl> ppp b / tests / python / unittest / test_gluon_model_zoo . py <nl> <nl> + import mxnet as mx <nl> + from mxnet . gluon import nn <nl> + from mxnet . gluon . model_zoo . custom_layers import HybridConcurrent , Identity <nl> + <nl> + <nl> + def test_concurrent ( ) : <nl> + model = HybridConcurrent ( concat_dim = 1 ) <nl> + model . add ( nn . Dense ( 128 , activation = ' tanh ' , in_units = 10 ) ) <nl> + model . add ( nn . Dense ( 64 , activation = ' tanh ' , in_units = 10 ) ) <nl> + model . add ( nn . Dense ( 32 , in_units = 10 ) ) <nl> + <nl> + # symbol <nl> + x = mx . sym . var ( ' data ' ) <nl> + y = model ( x ) <nl> + assert len ( y . list_arguments ( ) ) = = 7 <nl> + <nl> + # ndarray <nl> + model . collect_params ( ) . initialize ( mx . init . Xavier ( magnitude = 2 . 24 ) ) <nl> + x = model ( mx . nd . zeros ( ( 32 , 10 ) ) ) <nl> + assert x . shape = = ( 32 , 224 ) <nl> + x . wait_to_read ( ) <nl> + <nl> + <nl> + def test_identity ( ) : <nl> + model = Identity ( ) <nl> + x = mx . nd . random_uniform ( shape = ( 128 , 33 , 64 ) ) <nl> + mx . test_utils . assert_almost_equal ( model ( x ) . asnumpy ( ) , <nl> + x . asnumpy ( ) ) <nl> + <nl> + <nl> + if __name__ = = ' __main__ ' : <nl> + import nose <nl> + nose . runmodule ( ) <nl>
|
gluon models ( )
|
apache/incubator-mxnet
|
13bcb5a92ded56063a31ea7b7990dbb9634cca35
|
2017-07-30T19:03:14Z
|
mmm a / scene / resources / rectangle_shape_2d . cpp <nl> ppp b / scene / resources / rectangle_shape_2d . cpp <nl> void RectangleShape2D : : draw ( const RID & p_to_rid , const Color & p_color ) { <nl> <nl> Rect2 RectangleShape2D : : get_rect ( ) const { <nl> <nl> - Rect2 ( - extents , extents * 2 . 0 ) ; <nl> + return Rect2 ( - extents , extents * 2 . 0 ) ; <nl> <nl> } <nl> <nl>
|
Merge pull request from eska014 / master
|
godotengine/godot
|
4fef36825ebbbe4c3f9ecbd5a4cf052dbf309f9a
|
2015-09-22T12:38:46Z
|
mmm a / cocos / editor - support / cocostudio / WidgetReader / NodeReader / NodeReader . cpp <nl> ppp b / cocos / editor - support / cocostudio / WidgetReader / NodeReader / NodeReader . cpp <nl> namespace cocostudio <nl> float w = options - > size ( ) - > width ( ) ; <nl> float h = options - > size ( ) - > height ( ) ; <nl> int alpha = options - > alpha ( ) ; <nl> + Color3B color ( options - > color ( ) - > r ( ) , options - > color ( ) - > g ( ) , options - > color ( ) - > b ( ) ) ; <nl> <nl> node - > setName ( name ) ; <nl> <nl> namespace cocostudio <nl> if ( alpha ! = 255 ) <nl> node - > setOpacity ( alpha ) ; <nl> <nl> + node - > setColor ( color ) ; <nl> + <nl> node - > setTag ( tag ) ; <nl> node - > setUserObject ( timeline : : ActionTimelineData : : create ( actionTag ) ) ; <nl> <nl>
|
Add that parse " color " in NodeReader
|
cocos2d/cocos2d-x
|
69729bcd656181c13b5c752410a513b0eb7a2d5b
|
2014-12-01T08:27:21Z
|
mmm a / imgui . h <nl> ppp b / imgui . h <nl> struct ImGuiIO <nl> ImWchar InputCharacters [ 16 + 1 ] ; / / List of characters input ( translated by user from keypress + keyboard state ) . Fill using AddInputCharacter ( ) helper . <nl> <nl> / / Functions <nl> - IMGUI_API void AddInputCharacter ( ImWchar c ) ; / / Helper to add a new character into InputCharacters [ ] <nl> - IMGUI_API void AddInputCharactersUTF8 ( const char * utf8_chars ) ; / / Helper to add new characters into InputCharacters [ ] from an UTF - 8 string <nl> - inline void ClearInputCharacters ( ) { InputCharacters [ 0 ] = 0 ; } / / Helper to clear the text input buffer <nl> + IMGUI_API void AddInputCharacter ( ImWchar c ) ; / / Add new character into InputCharacters [ ] <nl> + IMGUI_API void AddInputCharactersUTF8 ( const char * utf8_chars ) ; / / Add new characters into InputCharacters [ ] from an UTF - 8 string <nl> + inline void ClearInputCharacters ( ) { InputCharacters [ 0 ] = 0 ; } / / Clear the text input buffer manually <nl> <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> - / / Output - Retrieve after calling NewFrame ( ) , you can use them to discard inputs or hide them from the rest of your application <nl> + / / Output - Retrieve after calling NewFrame ( ) <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> <nl> - bool WantCaptureMouse ; / / Mouse is hovering a window or widget is active ( = ImGui will use your mouse input ) <nl> - bool WantCaptureKeyboard ; / / Widget is active ( = ImGui will use your keyboard input ) <nl> - bool WantTextInput ; / / Some text input widget is active , which will read input characters from the InputCharacters array . <nl> - float Framerate ; / / Framerate estimation , in frame per second . Rolling average estimation based on IO . DeltaTime over 120 frames <nl> + bool WantCaptureMouse ; / / Mouse is hovering a window or widget is active ( = ImGui will use your mouse input ) . Use to hide mouse from the rest of your application <nl> + bool WantCaptureKeyboard ; / / Widget is active ( = ImGui will use your keyboard input ) . Use to hide keyboard from the rest of your application <nl> + bool WantTextInput ; / / Some text input widget is active , which will read input characters from the InputCharacters array . Use to activate on screen keyboard if your system needs one <nl> + float Framerate ; / / Application framerate estimation , in frame per second . Solely for convenience . Rolling average estimation based on IO . DeltaTime over 120 frames <nl> int MetricsAllocs ; / / Number of active memory allocations <nl> int MetricsRenderVertices ; / / Vertices output during last call to Render ( ) <nl> int MetricsRenderIndices ; / / Indices output during last call to Render ( ) = number of triangles * 3 <nl> - int MetricsActiveWindows ; / / Number of visible windows ( exclude child windows ) <nl> + int MetricsActiveWindows ; / / Number of visible root windows ( exclude child windows ) <nl> + ImVec2 MouseDelta ; / / Mouse delta . Note that this is zero if either current or previous position are negative , so a disappearing / reappearing mouse won ' t have a huge delta for one frame . <nl> <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> / / [ Private ] ImGui will maintain those fields . Forward compatibility not guaranteed ! <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> <nl> - ImVec2 MousePosPrev ; / / Previous mouse position <nl> - ImVec2 MouseDelta ; / / Mouse delta . Note that this is zero if either current or previous position are negative to allow mouse enabling / disabling . <nl> + ImVec2 MousePosPrev ; / / Previous mouse position temporary storage ( nb : not for public use , set to MousePos in NewFrame ( ) ) <nl> bool MouseClicked [ 5 ] ; / / Mouse button went from ! Down to Down <nl> ImVec2 MouseClickedPos [ 5 ] ; / / Position at time of clicking <nl> float MouseClickedTime [ 5 ] ; / / Time of last click ( used to figure out double - click ) <nl>
|
Comments , clarified use of io . MouseDelta ( )
|
ocornut/imgui
|
db593220fc419547b80e188b104051d39fc1a8e3
|
2016-12-23T10:34:23Z
|
mmm a / hphp / hack / hhi / container_functions . hhi <nl> ppp b / hphp / hack / hhi / container_functions . hhi <nl> function uksort < Tk , Tv > ( KeyedContainer < Tk , Tv > & $ arg , mixed $ c ) : bool ; <nl> / * * <nl> * Creates a ` dict ` from a ` KeyedTraversable ` , preserving keys and order . <nl> * / <nl> - < < __Rx > > <nl> - function dict < Tk , Tv > ( KeyedTraversable < Tk , Tv > $ arr ) : dict < Tk , Tv > ; <nl> + < < __Rx , __OnlyRxIfArgs > > <nl> + function dict < Tk , Tv > ( < < __OnlyRxIfImpl ( \ HH \ Rx \ Traversable : : class ) > > KeyedTraversable < Tk , Tv > $ arr ) : dict < Tk , Tv > ; <nl> / * * <nl> * Creates a ` vec ` from a ` Traversable ` , preserving order . Keys are not <nl> * preserved . <nl> * / <nl> - < < __Rx > > <nl> - function vec < Tv > ( Traversable < Tv > $ arr ) : vec < Tv > ; <nl> + < < __Rx , __OnlyRxIfArgs > > <nl> + function vec < Tv > ( < < __OnlyRxIfImpl ( \ HH \ Rx \ Traversable : : class ) > > Traversable < Tv > $ arr ) : vec < Tv > ; <nl> / * * <nl> * Create a ` keyset ` from a ` Traversable ` of strings or ints , preserving order . <nl> * Keys are not preserved . <nl> * / <nl> - < < __Rx > > <nl> - function keyset < Tv as arraykey > ( Traversable < Tv > $ arr ) : keyset < Tv > ; <nl> + < < __Rx , __OnlyRxIfArgs > > <nl> + function keyset < Tv as arraykey > ( < < __OnlyRxIfImpl ( \ HH \ Rx \ Traversable : : class ) > > Traversable < Tv > $ arr ) : keyset < Tv > ; <nl> mmm a / hphp / runtime / ext / array / ext_array . php <nl> ppp b / hphp / runtime / ext / array / ext_array . php <nl> function merge_xhp_attr_declarations ( darray $ arr1 , <nl> } <nl> <nl> namespace HH { <nl> - < < __Native , __IsFoldable > > <nl> - function dict ( mixed $ arr ) : dict ; <nl> + < < __Native , __IsFoldable , __Rx , __OnlyRxIfArgs > > <nl> + function dict ( < < __OnlyRxIfImpl ( \ HH \ Rx \ Traversable : : class ) > > mixed $ arr ) : dict ; <nl> <nl> - < < __Native , __IsFoldable > > <nl> - function vec ( mixed $ arr ) : vec ; <nl> + < < __Native , __IsFoldable , __Rx , __OnlyRxIfArgs > > <nl> + function vec ( < < __OnlyRxIfImpl ( \ HH \ Rx \ Traversable : : class ) > > mixed $ arr ) : vec ; <nl> <nl> - < < __Native , __IsFoldable > > <nl> - function keyset ( mixed $ arr ) : keyset ; <nl> + < < __Native , __IsFoldable , __Rx , __OnlyRxIfArgs > > <nl> + function keyset ( < < __OnlyRxIfImpl ( \ HH \ Rx \ Traversable : : class ) > > mixed $ arr ) : keyset ; <nl> <nl> - < < __Native , __IsFoldable > > <nl> - function varray ( mixed $ arr ) : varray ; <nl> + < < __Native , __IsFoldable , __Rx , __OnlyRxIfArgs > > <nl> + function varray ( < < __OnlyRxIfImpl ( \ HH \ Rx \ Traversable : : class ) > > mixed $ arr ) : varray ; <nl> <nl> - < < __Native , __IsFoldable > > <nl> - function darray ( mixed $ arr ) : darray ; <nl> + < < __Native , __IsFoldable , __Rx , __OnlyRxIfArgs > > <nl> + function darray ( < < __OnlyRxIfImpl ( \ HH \ Rx \ Traversable : : class ) > > mixed $ arr ) : darray ; <nl> <nl> / * * <nl> * array_key_cast ( ) can be used to convert a given value to the equivalent <nl>
|
Mark dict / vec / keyset as conditionally reactive .
|
facebook/hhvm
|
77c29e21db030387e9b0d9f187b74b8b16b47c55
|
2018-06-29T03:42:31Z
|
mmm a / src / io / inst_vector . h <nl> ppp b / src / io / inst_vector . h <nl> <nl> namespace mxnet { <nl> namespace io { <nl> / * ! <nl> - * \ brief tensor vector that can store sequence of tensor <nl> - * in a memory compact way , tensors do not have to be of same shape <nl> + * \ brief a vector of tensor with various shape <nl> + * <nl> + * data are stored in memory continously <nl> * / <nl> template < int dim , typename DType > <nl> class TensorVector { <nl> class TensorVector { <nl> TensorVector ( void ) { <nl> this - > Clear ( ) ; <nl> } <nl> - / / get i - th tensor <nl> + / * ! \ brief get the buffer to the i - th tensor * / <nl> inline mshadow : : Tensor < cpu , dim , DType > <nl> operator [ ] ( size_t i ) const { <nl> - CHECK ( i + 1 < offset_ . size ( ) ) ; <nl> - CHECK ( shape_ [ i ] . Size ( ) = = offset_ [ i + 1 ] - offset_ [ i ] ) ; <nl> + CHECK_LT ( i + 1 , offset_ . size ( ) ) ; <nl> + CHECK_EQ ( shape_ [ i ] . Size ( ) , offset_ [ i + 1 ] - offset_ [ i ] ) ; <nl> return mshadow : : Tensor < cpu , dim , DType > <nl> ( ( DType * ) dmlc : : BeginPtr ( content_ ) + offset_ [ i ] , shape_ [ i ] ) ; / / NOLINT ( * ) <nl> } <nl> class TensorVector { <nl> inline size_t Size ( void ) const { <nl> return shape_ . size ( ) ; <nl> } <nl> - / / push a tensor of certain shape <nl> - / / return the reference of the pushed tensor <nl> + / * ! \ brief allocate space given the shape ( data are copied ) * / <nl> inline void Push ( mshadow : : Shape < dim > shape ) { <nl> shape_ . push_back ( shape ) ; <nl> offset_ . push_back ( offset_ . back ( ) + shape . Size ( ) ) ; <nl> class TensorVector { <nl> } ; <nl> <nl> / * ! <nl> - * \ brief instance vector that can holds <nl> - * non - uniform shape data instance in a shape efficient way <nl> + * \ brief a list of ( label , example ) pairs , examples can have various shape <nl> * / <nl> class InstVector { <nl> public : <nl> + / * ! \ brief return the number of ( label , example ) pairs * / <nl> inline size_t Size ( void ) const { <nl> return index_ . size ( ) ; <nl> } <nl> - / / instance <nl> + / * \ brief get the i - th ( label , example ) pair * / <nl> inline DataInst operator [ ] ( size_t i ) const { <nl> DataInst inst ; <nl> inst . index = index_ [ i ] ; <nl> class InstVector { <nl> inst . data . push_back ( TBlob ( label_ [ i ] ) ) ; <nl> return inst ; <nl> } <nl> - / / get back of instance vector <nl> + / * \ brief get the last ( label , example ) pair * / <nl> inline DataInst Back ( ) const { <nl> return ( * this ) [ Size ( ) - 1 ] ; <nl> } <nl> class InstVector { <nl> data_ . Clear ( ) ; <nl> label_ . Clear ( ) ; <nl> } <nl> + / * <nl> + * \ brief push a ( label , example ) pair <nl> + * only reserved the space , while the data is not copied <nl> + * / <nl> inline void Push ( unsigned index , <nl> mshadow : : Shape < 3 > dshape , <nl> mshadow : : Shape < 1 > lshape ) { <nl> mmm a / src / io / iter_image_recordio . cc <nl> ppp b / src / io / iter_image_recordio . cc <nl> struct ImageRecParserParam : public dmlc : : Parameter < ImageRecParserParam > { <nl> int nthread ; <nl> / * ! \ brief whether to remain silent * / <nl> bool silent ; <nl> - / * ! \ brief number of distributed worker * / <nl> - int dist_num_worker , dist_worker_rank ; <nl> + / * ! \ brief virtually split the data into n parts * / <nl> + int num_parts ; <nl> + / * ! \ brief only read the i - th part * / <nl> + int part_index ; <nl> / * ! \ brief label - width * / <nl> int label_width ; <nl> / * ! \ brief input shape * / <nl> struct ImageRecParserParam : public dmlc : : Parameter < ImageRecParserParam > { <nl> . describe ( " How many labels for an image . " ) ; <nl> DMLC_DECLARE_FIELD ( silent ) . set_default ( false ) <nl> . describe ( " Whether to output parser information . " ) ; <nl> - DMLC_DECLARE_FIELD ( dist_num_worker ) . set_lower_bound ( 1 ) . set_default ( 1 ) <nl> - . describe ( " Dist worker number . " ) ; <nl> - DMLC_DECLARE_FIELD ( dist_worker_rank ) . set_default ( 0 ) <nl> - . describe ( " Dist worker rank . " ) ; <nl> + DMLC_DECLARE_FIELD ( num_parts ) . set_lower_bound ( 1 ) . set_default ( 1 ) <nl> + . describe ( " virtually split the data into n parts " ) ; <nl> + DMLC_DECLARE_FIELD ( part_index ) . set_default ( 0 ) <nl> + . describe ( " only read the i - th part " ) ; <nl> index_t input_shape_default [ ] = { 3 , 224 , 224 } ; <nl> DMLC_DECLARE_FIELD ( input_shape ) <nl> . set_default ( TShape ( input_shape_default , input_shape_default + 3 ) ) <nl> class ImageRecordIOParser { <nl> inline void ImageRecordIOParser : : Init ( <nl> const std : : vector < std : : pair < std : : string , std : : string > > & kwargs ) { <nl> / / initialize parameter <nl> - std : : vector < std : : pair < std : : string , std : : string > > kwargs_left ; <nl> / / init image rec param <nl> - kwargs_left = param_ . InitAllowUnknown ( kwargs ) ; <nl> + param_ . InitAllowUnknown ( kwargs ) ; <nl> int maxthread , threadget ; <nl> # pragma omp parallel <nl> { <nl> + / / why ? ( muli ) <nl> maxthread = std : : max ( omp_get_num_procs ( ) / 2 - 1 , 1 ) ; <nl> } <nl> param_ . nthread = std : : min ( maxthread , param_ . nthread ) ; <nl> inline void ImageRecordIOParser : : Init ( <nl> prnds_ . push_back ( new common : : RANDOM_ENGINE ( ( i + 1 ) * kRandMagic ) ) ; <nl> } <nl> <nl> - / / handling for hadoop <nl> - const char * ps_rank = getenv ( " PS_RANK " ) ; <nl> - if ( ps_rank ! = NULL ) { <nl> - param_ . dist_worker_rank = atoi ( ps_rank ) ; <nl> - } <nl> - <nl> if ( param_ . path_imglist . length ( ) ! = 0 ) { <nl> label_map_ = new ImageLabelMap ( param_ . path_imglist . c_str ( ) , <nl> param_ . label_width , param_ . silent ! = 0 ) ; <nl> inline void ImageRecordIOParser : : Init ( <nl> } <nl> CHECK ( param_ . path_imgrec . length ( ) ! = 0 ) <nl> < < " ImageRecordIOIterator : must specify image_rec " ; <nl> - # if MSHADOW_DIST_PS <nl> - param_ . dist_num_worker = : : ps : : RankSize ( ) ; <nl> - param_ . dist_worker_rank = : : ps : : MyRank ( ) ; <nl> - LOG ( INFO ) < < " rank " < < param_ . dist_worker_rank <nl> - < < " in " < < param_ . dist_num_worker ; <nl> - # endif <nl> - source_ = dmlc : : InputSplit : : Create <nl> - ( param_ . path_imgrec . c_str ( ) , param_ . dist_worker_rank , <nl> - param_ . dist_num_worker , " recordio " ) ; <nl> + <nl> + source_ = dmlc : : InputSplit : : Create ( <nl> + param_ . path_imgrec . c_str ( ) , param_ . part_index , <nl> + param_ . num_parts , " recordio " ) ; <nl> / / use 64 MB chunk when possible <nl> source_ - > HintChunkSize ( 8 < < 20UL ) ; <nl> } <nl> struct ImageRecordParam : public dmlc : : Parameter < ImageRecordParam > { <nl> } <nl> } ; <nl> <nl> + <nl> / / iterator on image recordio <nl> class ImageRecordIter : public IIterator < DataInst > { <nl> public : <nl> - ImageRecordIter ( ) <nl> - : data_ ( NULL ) { <nl> - } <nl> + ImageRecordIter ( ) : data_ ( NULL ) { } <nl> virtual ~ ImageRecordIter ( void ) { <nl> iter_ . Destroy ( ) ; <nl> - / / data can be NULL <nl> delete data_ ; <nl> } <nl> virtual void Init ( const std : : vector < std : : pair < std : : string , std : : string > > & kwargs ) { <nl> - std : : vector < std : : pair < std : : string , std : : string > > kwargs_left ; <nl> - / / init image rec param <nl> - kwargs_left = param_ . InitAllowUnknown ( kwargs ) ; <nl> + param_ . InitAllowUnknown ( kwargs ) ; <nl> / / use the kwarg to init parser <nl> parser_ . Init ( kwargs ) ; <nl> - / / init thread iter <nl> + / / prefetch at most 4 minbatches <nl> iter_ . set_max_capacity ( 4 ) ; <nl> + / / init thread iter <nl> iter_ . Init ( [ this ] ( std : : vector < InstVector > * * dptr ) { <nl> if ( * dptr = = NULL ) { <nl> * dptr = new std : : vector < InstVector > ( ) ; <nl> class ImageRecordIter : public IIterator < DataInst > { <nl> [ this ] ( ) { parser_ . BeforeFirst ( ) ; } ) ; <nl> / / Check Meanfile <nl> if ( param_ . mean_img . length ( ) ! = 0 ) { <nl> - dmlc : : Stream * fi = dmlc : : Stream : : Create ( param_ . mean_img . c_str ( ) , " r " , true ) ; <nl> + dmlc : : Stream * fi = <nl> + dmlc : : Stream : : Create ( param_ . mean_img . c_str ( ) , " r " , true ) ; <nl> if ( fi = = NULL ) { <nl> this - > CreateMeanImg ( ) ; <nl> } else { <nl> class ImageRecordIter : public IIterator < DataInst > { <nl> } <nl> } <nl> inst_ptr_ = 0 ; <nl> + shuffle_ = param_ . shuffle ; <nl> } <nl> virtual void BeforeFirst ( void ) { <nl> iter_ . BeforeFirst ( ) ; <nl> class ImageRecordIter : public IIterator < DataInst > { <nl> / / mean image <nl> mshadow : : TensorContainer < cpu , 3 > meanimg_ ; <nl> } ; <nl> + <nl> DMLC_REGISTER_PARAMETER ( ImageRecParserParam ) ; <nl> DMLC_REGISTER_PARAMETER ( ImageRecordParam ) ; <nl> MXNET_REGISTER_IO_CHAINED_ITER ( ImageRecordIter , ImageRecordIter , BatchAdaptIter ) <nl>
|
fix tiny bug in iter_image_rec , and tiny refactor
|
apache/incubator-mxnet
|
0a880daddb24b753c77dcb8125c2b336c1770bcc
|
2015-09-16T01:18:54Z
|
mmm a / scene / 2d / path_2d . cpp <nl> ppp b / scene / 2d / path_2d . cpp <nl> <nl> <nl> Rect2 Path2D : : _edit_get_rect ( ) const { <nl> <nl> - if ( curve - > get_point_count ( ) = = 0 ) <nl> + if ( ! curve . is_valid ( ) | | curve - > get_point_count ( ) = = 0 ) <nl> return Rect2 ( 0 , 0 , 0 , 0 ) ; <nl> <nl> Rect2 aabb = Rect2 ( curve - > get_point_position ( 0 ) , Vector2 ( 0 , 0 ) ) ; <nl>
|
Merge pull request from brainsick / path2d - curve - defense
|
godotengine/godot
|
19548753f1cce086857f67284e1e47cf9c8018c1
|
2018-01-23T06:47:34Z
|
mmm a / editor / plugins / sprite_frames_editor_plugin . cpp <nl> ppp b / editor / plugins / sprite_frames_editor_plugin . cpp <nl> void SpriteFramesEditor : : drop_data_fw ( const Point2 & p_point , const Variant & p_da <nl> <nl> void SpriteFramesEditor : : _bind_methods ( ) { <nl> <nl> - ClassDB : : bind_method ( D_METHOD ( " _gui_input " ) , & SpriteFramesEditor : : _gui_input ) ; <nl> ClassDB : : bind_method ( D_METHOD ( " _load_pressed " ) , & SpriteFramesEditor : : _load_pressed ) ; <nl> ClassDB : : bind_method ( D_METHOD ( " _empty_pressed " ) , & SpriteFramesEditor : : _empty_pressed ) ; <nl> ClassDB : : bind_method ( D_METHOD ( " _empty2_pressed " ) , & SpriteFramesEditor : : _empty2_pressed ) ; <nl>
|
Merge pull request from qarmin / fix_sprie_frames_editor
|
godotengine/godot
|
5fa5678eb70d6f12800a4862215f54f4c20a4a96
|
2019-02-09T17:27:40Z
|
mmm a / tensorflow / contrib / eager / python / examples / resnet50 / BUILD <nl> ppp b / tensorflow / contrib / eager / python / examples / resnet50 / BUILD <nl> cuda_py_test ( <nl> ] , <nl> shard_count = 4 , <nl> tags = [ <nl> - " noasan " , # Fix b / 118130911 <nl> - " nomsan " , # Fix b / 118130911 <nl> - " notsan " , # Fix b / 118130911 <nl> " optonly " , <nl> " oss_serial " , <nl> ] , <nl>
|
Re - enable Resnet50 test is ? san .
|
tensorflow/tensorflow
|
83d09b263428018a74650e64f007a8cec4d2bf5d
|
2019-04-25T21:24:49Z
|
mmm a / ports / freeglut / portfile . cmake <nl> ppp b / ports / freeglut / portfile . cmake <nl> <nl> include ( vcpkg_common_functions ) <nl> + set ( SOURCE_PATH $ { CURRENT_BUILDTREES_DIR } / src / freeglut - 3 . 0 . 0 ) <nl> vcpkg_download_distfile ( ARCHIVE <nl> URLS " http : / / downloads . sourceforge . net / project / freeglut / freeglut / 3 . 0 . 0 / freeglut - 3 . 0 . 0 . tar . gz " <nl> FILENAME " freeglut - 3 . 0 . 0 . tar . gz " <nl> else ( ) <nl> endif ( ) <nl> <nl> vcpkg_configure_cmake ( <nl> - SOURCE_PATH $ { CURRENT_BUILDTREES_DIR } / src / freeglut - 3 . 0 . 0 <nl> + SOURCE_PATH $ { SOURCE_PATH } <nl> OPTIONS <nl> - DFREEGLUT_BUILD_STATIC_LIBS = $ { FREEGLUT_STATIC } <nl> - DFREEGLUT_BUILD_SHARED_LIBS = $ { FREEGLUT_DYNAMIC } <nl> vcpkg_install_cmake ( ) <nl> file ( REMOVE_RECURSE $ { CURRENT_PACKAGES_DIR } / debug / include ) <nl> <nl> # Handle copyright <nl> - file ( COPY $ { CURRENT_BUILDTREES_DIR } / src / freeglut - 3 . 0 . 0 / COPYING DESTINATION $ { CURRENT_PACKAGES_DIR } / share / freeglut ) <nl> + file ( COPY $ { SOURCE_PATH } / COPYING DESTINATION $ { CURRENT_PACKAGES_DIR } / share / freeglut ) <nl> file ( RENAME $ { CURRENT_PACKAGES_DIR } / share / freeglut / COPYING $ { CURRENT_PACKAGES_DIR } / share / freeglut / copyright ) <nl> <nl> vcpkg_copy_pdbs ( ) <nl> \ No newline at end of file <nl>
|
[ freeglut ] Extract SOURCE_PATH variable
|
microsoft/vcpkg
|
e6ebc0369990c1d670d87bec248ffb04739df334
|
2016-12-07T23:21:30Z
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.